diff --git a/.gitattributes b/.gitattributes
index 16ac5ebe..43965b08 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,35 @@
deploy/netflow-agent/*.sh text eol=lf
deploy/netflow-agent/*.py text eol=lf
+# Migration hashes authenticate exact reviewed bytes, including existing CRLF files.
+# Preserve those bytes on every checkout instead of applying core.autocrlf.
+backend/drizzle/*.sql -text
+
+# Receipts pinned by SHA-256 over their exact CRLF bytes; keep them byte-for-byte.
+/docs/bandwidth-operator-effect-ledger.md -text
+/docs/bandwidth-operator-metadata-effect-contract.md -text
+/docs/mcp-2gb-operating-progress-20261028.json -text
+/docs/mcp-chr-ospf-source-cleanup.json -text
+/docs/mcp-chr-ssh-forwarding-policy-observation-v1.json -text
+/docs/mcp-db-connected-publisher-source-applied-20261102.json -text
+/docs/mcp-db-publisher-journal-lease-source-applied-20261102.json -text
+/docs/mcp-db-registry-fusion-acceptance-20261101.json -text
+/docs/mcp-db-registry-read-contract-acceptance-20261101.json -text
+/docs/mcp-guarded-peer-sources-acceptance-20261029.json -text
+/docs/mcp-ipsec-user-create-acceptance-v2.json -text
+/docs/mcp-linux-inventory-collector-raw-acceptance-20261101.json -text
+/docs/mcp-netflow-settings-acceptance-v2.json -text
+/docs/mcp-node-key-effect-progress-20261029.json -text
+/docs/mcp-operator-peer-metadata-managed-acceptance-20261028.json -text
+/docs/mcp-operator-public-metadata-progress-20261028.json -text
+/docs/mcp-portal-permission-catalog-source-applied-20261103.json -text
+/docs/mcp-public-registry-metadata-acceptance-20261028.json -text
+/docs/mcp-publisher-current-operator-linux-acceptance-20261103.json -text
+/docs/mcp-routing-manual-inverse-charge-reproduction-20261101.json -text
+/docs/mcp-routing-manual-inverse-charge-reproduction-20261101.md -text
+/docs/mcp-routing-manual-inverse-six-case-acceptance-20261101.json -text
+/docs/mcp-routing-manual-inverse-six-case-acceptance-20261101.md -text
+/docs/mcp-routing44-upgrade-bridge-acceptance-20261101.json -text
+/docs/mcp-server-poll-expiry-alignment-source-applied-20261102.json -text
+/docs/mcp-two-chr-v40-execution-20261106.json -text
+/docs/mcp-vrf-production-ticket-acceptance-v1.json -text
+/docs/netflow-agent.md -text
diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml
index 11d8f720..38c57dd0 100644
--- a/.gitea/workflows/docker.yml
+++ b/.gitea/workflows/docker.yml
@@ -153,8 +153,9 @@ jobs:
NODE
cp packages/contracts/package.json packages/contracts/tsconfig.json "$STAGING/packages/contracts/"
cp -R packages/contracts/src "$STAGING/packages/contracts/"
- cp backend/package.json backend/tsconfig.json "$STAGING/backend/"
+ cp backend/package.json backend/tsconfig.json backend/mcp-coverage.json "$STAGING/backend/"
cp -R backend/src "$STAGING/backend/"
+ node backend/scripts/stage-database-operator.mjs "$STAGING/backend/scripts"
mkdir -p "$STAGING/deploy/netflow-agent"
cp deploy/netflow-agent/install.sh "$STAGING/deploy/netflow-agent/"
if [ -d backend/drizzle ]; then
diff --git a/.gitea/workflows/mcp-acceptance-preview.yml b/.gitea/workflows/mcp-acceptance-preview.yml
new file mode 100644
index 00000000..bd6fd721
--- /dev/null
+++ b/.gitea/workflows/mcp-acceptance-preview.yml
@@ -0,0 +1,274 @@
+name: MCP isolated acceptance preview images
+'on':
+ workflow_dispatch:
+ inputs:
+ expected_sha:
+ description: Exact reviewed full commit SHA on the selected ref; includes all accepted source changes
+ required: true
+ type: string
+ auth_portal_origin:
+ description: Canonical isolated browser-facing Auth Portal HTTP(S) origin; no path, credentials or query
+ required: true
+ type: string
+ default: http://127.0.0.1:55175
+permissions:
+ contents: read
+ packages: write
+jobs:
+ backend-preview:
+ if: ${{ gitea.event_name == 'workflow_dispatch' }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 40
+ env:
+ COMPONENT: backend
+ EXPECTED_SHA: ${{ inputs.expected_sha }}
+ DISPATCH_SHA: ${{ gitea.sha }}
+ DISPATCH_EVENT: ${{ gitea.event_name }}
+ REPOSITORY: ${{ gitea.repository }}
+ RUN_ID: ${{ gitea.run_id }}
+ RUN_ATTEMPT: ${{ gitea.run_attempt }}
+ steps:
+ - name: Checkout exact dispatch commit
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ gitea.sha }}
+ persist-credentials: false
+ - name: Use existing Linux Node22 build toolchain
+ uses: actions/setup-node@v4
+ with:
+ node-version: '22'
+ - name: Verify source and isolated preview destination
+ shell: bash
+ run: |
+ set -euo pipefail
+ test "$DISPATCH_EVENT" = workflow_dispatch
+ [[ "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]]
+ test "$EXPECTED_SHA" = "$DISPATCH_SHA"
+ test "$(git rev-parse HEAD)" = "$EXPECTED_SHA"
+ git diff --exit-code
+ git diff --cached --exit-code
+ [[ "$RUN_ID" =~ ^[0-9]+$ && "$RUN_ATTEMPT" =~ ^[0-9]+$ ]]
+ owner=$(printf '%s' "$REPOSITORY" | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')
+ name=$(printf '%s' "$REPOSITORY" | cut -d/ -f2 | tr '[:upper:]' '[:lower:]')
+ [[ "$owner" =~ ^[a-z0-9][a-z0-9._-]*$ && "$name" =~ ^[a-z0-9][a-z0-9._-]*$ ]]
+ stem=$(printf '%s' "$name" | sed -E 's/-[0-9]+$//')
+ echo "IMAGE_NAME=git.shx.one/$owner/$stem-$COMPONENT-mcp-acceptance" >> "$GITHUB_ENV"
+ echo "PREVIEW_TAG=mcp-acceptance-$EXPECTED_SHA-$RUN_ID-$RUN_ATTEMPT" >> "$GITHUB_ENV"
+ echo "PREVIEW_CACHE=git.shx.one/$owner/$stem-$COMPONENT-mcp-acceptance-buildcache:node-buildcache" >> "$GITHUB_ENV"
+ mkdir -p .ci/acceptance-evidence
+ node <<'NODE'
+ const fs=require('node:fs'),cp=require('node:child_process'),crypto=require('node:crypto');
+ const files=cp.execFileSync('git',['ls-files','-z'],{encoding:'utf8'}).split('\0').filter(Boolean);
+ const inputs=files.map(path=>{const info=fs.lstatSync(path);if(!info.isFile()||info.isSymbolicLink())throw Error('Regular tracked source inputs required');const data=fs.readFileSync(path);return {path,sha256:crypto.createHash('sha256').update(data).digest('hex'),bytes:data.length}});
+ fs.writeFileSync('.ci/acceptance-evidence/source.json',JSON.stringify({format:'mcp-preview-source-v1',repository:process.env.REPOSITORY,sourceSha:process.env.EXPECTED_SHA,sourceTree:cp.execFileSync('git',['rev-parse','HEAD^{tree}'],{encoding:'utf8'}).trim(),platform:'linux/amd64',component:process.env.COMPONENT,runId:process.env.RUN_ID,runAttempt:process.env.RUN_ATTEMPT,authPortalOrigin:process.env.AUTH_PORTAL_ORIGIN??null,inputs},null,2)+'\n');
+ NODE
+ - name: Prepare existing scoped Docker context
+ shell: bash
+ run: |
+ set -euo pipefail
+ STAGING=".ci/docker/backend"
+ rm -rf "$STAGING"
+ mkdir -p "$STAGING/packages/contracts" "$STAGING/backend"
+ cp package-lock.json "$STAGING/"
+ node <<'NODE'
+ const fs = require("node:fs")
+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"))
+ pkg.workspaces = ["packages/*", "backend"]
+ pkg.dependencies = {}
+ pkg.devDependencies = {}
+ delete pkg.scripts
+ fs.writeFileSync(".ci/docker/backend/package.json", `${JSON.stringify(pkg, null, 2)}\n`)
+ NODE
+ cp packages/contracts/package.json packages/contracts/tsconfig.json "$STAGING/packages/contracts/"
+ cp -R packages/contracts/src "$STAGING/packages/contracts/"
+ cp backend/package.json backend/tsconfig.json backend/mcp-coverage.json "$STAGING/backend/"
+ cp -R backend/src "$STAGING/backend/"
+ mkdir -p "$STAGING/deploy/netflow-agent"
+ cp deploy/netflow-agent/install.sh "$STAGING/deploy/netflow-agent/"
+ if [ -d backend/drizzle ]; then
+ cp -R backend/drizzle "$STAGING/backend/"
+ fi
+ node backend/scripts/stage-database-operator.mjs "$STAGING/backend/scripts"
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+ - name: Log in to existing Gitea registry
+ uses: docker/login-action@v3
+ with:
+ registry: git.shx.one
+ username: ${{ gitea.actor }}
+ password: ${{ secrets.ACTIONS_PAT }}
+ - name: Build and push isolated acceptance image
+ id: build
+ uses: docker/build-push-action@v5
+ with:
+ context: .ci/docker/backend
+ file: backend/Dockerfile
+ platforms: linux/amd64
+ push: true
+ tags: ${{ env.IMAGE_NAME }}:${{ env.PREVIEW_TAG }}
+ build-args: APP_VERSION=${{ env.PREVIEW_TAG }}
+ cache-from: type=gha,scope=mcp-acceptance-backend
+ cache-to: type=gha,scope=mcp-acceptance-backend,mode=max
+ provenance: mode=min
+ sbom: true
+ labels: |-
+ org.opencontainers.image.revision=${{ gitea.sha }}
+ org.opencontainers.image.version=${{ env.PREVIEW_TAG }}
+ io.mmapp.acceptance-only=true
+ - name: Record exact digest and build metadata
+ shell: bash
+ env:
+ IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
+ BUILD_METADATA: ${{ steps.build.outputs.metadata }}
+ run: |
+ set -euo pipefail
+ node <<'NODE'
+ const fs=require('node:fs'),crypto=require('node:crypto');
+ const digest=process.env.IMAGE_DIGEST;if(!/^sha256:[a-f0-9]{64}$/.test(digest))throw Error('Exact registry digest required');
+ const metadata=JSON.parse(process.env.BUILD_METADATA);const source=fs.readFileSync('.ci/acceptance-evidence/source.json');
+ fs.writeFileSync('.ci/acceptance-evidence/image.json',JSON.stringify({format:'mcp-preview-image-v1',sourceSha:process.env.EXPECTED_SHA,sourceProofSha256:crypto.createHash('sha256').update(source).digest('hex'),image:process.env.IMAGE_NAME,tag:process.env.PREVIEW_TAG,digest,pinnedReference:process.env.IMAGE_NAME+'@'+digest,platform:'linux/amd64',component:process.env.COMPONENT,authPortalOrigin:process.env.AUTH_PORTAL_ORIGIN??null,buildMetadata:metadata,productionDeployed:false,wholeInstallation2GbAccepted:false},null,2)+'\n');
+ console.log('Acceptance image digest: '+process.env.IMAGE_NAME+'@'+digest);
+ NODE
+ - name: Retain source and image binding artifacts
+ uses: actions/upload-artifact@v3
+ with:
+ name: mcp-acceptance-${{ env.COMPONENT }}-${{ gitea.sha }}-${{ gitea.run_id }}-${{ gitea.run_attempt }}
+ path: .ci/acceptance-evidence/*.json
+ if-no-files-found: error
+ retention-days: 14
+ frontend-preview:
+ if: ${{ gitea.event_name == 'workflow_dispatch' }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 40
+ env:
+ COMPONENT: frontend
+ EXPECTED_SHA: ${{ inputs.expected_sha }}
+ DISPATCH_SHA: ${{ gitea.sha }}
+ DISPATCH_EVENT: ${{ gitea.event_name }}
+ REPOSITORY: ${{ gitea.repository }}
+ RUN_ID: ${{ gitea.run_id }}
+ RUN_ATTEMPT: ${{ gitea.run_attempt }}
+ AUTH_PORTAL_ORIGIN_REQUEST: ${{ inputs.auth_portal_origin }}
+ steps:
+ - name: Checkout exact dispatch commit
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ gitea.sha }}
+ persist-credentials: false
+ - name: Use existing Linux Node22 build toolchain
+ uses: actions/setup-node@v4
+ with:
+ node-version: '22'
+ - name: Validate explicit isolated portal origin
+ shell: bash
+ run: |
+ set -euo pipefail
+ node <<'NODE'
+ const fs=require('node:fs'),assert=require('node:assert/strict');
+ const raw=process.env.AUTH_PORTAL_ORIGIN_REQUEST;
+ assert(typeof raw==='string'&&raw.length>0&&raw.length<=2048&&!/[\x00-\x20\x7f]/.test(raw),'Bounded canonical HTTP(S) origin required');
+ const origin=new URL(raw);
+ assert(['http:','https:'].includes(origin.protocol)&&!origin.username&&!origin.password&&origin.pathname==='/'&&!origin.search&&!origin.hash&&origin.origin!=='null'&&origin.origin===raw,'Canonical origin only; credentials/path/query/hash refused');
+ fs.appendFileSync(process.env.GITHUB_ENV,'AUTH_PORTAL_ORIGIN='+origin.origin+'\n');
+ NODE
+ - name: Verify source and isolated preview destination
+ shell: bash
+ run: |
+ set -euo pipefail
+ test "$DISPATCH_EVENT" = workflow_dispatch
+ [[ "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]]
+ test "$EXPECTED_SHA" = "$DISPATCH_SHA"
+ test "$(git rev-parse HEAD)" = "$EXPECTED_SHA"
+ git diff --exit-code
+ git diff --cached --exit-code
+ [[ "$RUN_ID" =~ ^[0-9]+$ && "$RUN_ATTEMPT" =~ ^[0-9]+$ ]]
+ owner=$(printf '%s' "$REPOSITORY" | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')
+ name=$(printf '%s' "$REPOSITORY" | cut -d/ -f2 | tr '[:upper:]' '[:lower:]')
+ [[ "$owner" =~ ^[a-z0-9][a-z0-9._-]*$ && "$name" =~ ^[a-z0-9][a-z0-9._-]*$ ]]
+ stem=$(printf '%s' "$name" | sed -E 's/-[0-9]+$//')
+ echo "IMAGE_NAME=git.shx.one/$owner/$stem-$COMPONENT-mcp-acceptance" >> "$GITHUB_ENV"
+ echo "PREVIEW_TAG=mcp-acceptance-$EXPECTED_SHA-$RUN_ID-$RUN_ATTEMPT" >> "$GITHUB_ENV"
+ echo "PREVIEW_CACHE=git.shx.one/$owner/$stem-$COMPONENT-mcp-acceptance-buildcache:node-buildcache" >> "$GITHUB_ENV"
+ mkdir -p .ci/acceptance-evidence
+ node <<'NODE'
+ const fs=require('node:fs'),cp=require('node:child_process'),crypto=require('node:crypto');
+ const files=cp.execFileSync('git',['ls-files','-z'],{encoding:'utf8'}).split('\0').filter(Boolean);
+ const inputs=files.map(path=>{const info=fs.lstatSync(path);if(!info.isFile()||info.isSymbolicLink())throw Error('Regular tracked source inputs required');const data=fs.readFileSync(path);return {path,sha256:crypto.createHash('sha256').update(data).digest('hex'),bytes:data.length}});
+ fs.writeFileSync('.ci/acceptance-evidence/source.json',JSON.stringify({format:'mcp-preview-source-v1',repository:process.env.REPOSITORY,sourceSha:process.env.EXPECTED_SHA,sourceTree:cp.execFileSync('git',['rev-parse','HEAD^{tree}'],{encoding:'utf8'}).trim(),platform:'linux/amd64',component:process.env.COMPONENT,runId:process.env.RUN_ID,runAttempt:process.env.RUN_ATTEMPT,authPortalOrigin:process.env.AUTH_PORTAL_ORIGIN??null,inputs},null,2)+'\n');
+ NODE
+ - name: Prepare existing scoped Docker context
+ shell: bash
+ run: |
+ set -euo pipefail
+ STAGING=".ci/docker/frontend"
+ rm -rf "$STAGING"
+ mkdir -p "$STAGING/packages/contracts" "$STAGING/public"
+ cp package-lock.json next.config.ts tsconfig.json postcss.config.mjs eslint.config.mjs components.json "$STAGING/"
+ node <<'NODE'
+ const fs = require("node:fs")
+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"))
+ pkg.workspaces = ["packages/*"]
+ fs.writeFileSync(".ci/docker/frontend/package.json", `${JSON.stringify(pkg, null, 2)}\n`)
+ NODE
+ cp packages/contracts/package.json packages/contracts/tsconfig.json "$STAGING/packages/contracts/"
+ cp -R packages/contracts/src "$STAGING/packages/contracts/"
+ for dir in app components lib shared entities public hooks; do
+ if [ -d "$dir" ]; then
+ cp -R "$dir" "$STAGING/"
+ fi
+ done
+ test -f "$STAGING/public/release-manifest.json"
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+ - name: Log in to existing Gitea registry
+ uses: docker/login-action@v3
+ with:
+ registry: git.shx.one
+ username: ${{ gitea.actor }}
+ password: ${{ secrets.ACTIONS_PAT }}
+ - name: Build and push isolated acceptance image
+ id: build
+ uses: docker/build-push-action@v5
+ with:
+ context: .ci/docker/frontend
+ file: Dockerfile.frontend
+ platforms: linux/amd64
+ push: true
+ tags: ${{ env.IMAGE_NAME }}:${{ env.PREVIEW_TAG }}
+ build-args: |-
+ BACKEND_INTERNAL_URL=http://backend:8000
+ NEXT_PUBLIC_BACKEND_URL=same-origin
+ NEXT_PUBLIC_DEFAULT_DATA_SOURCE=live
+ NEXT_PUBLIC_ALLOW_MOCK_DATA=false
+ NEXT_PUBLIC_AUTH_PORTAL_URL=${{ env.AUTH_PORTAL_ORIGIN }}
+ NEXT_PUBLIC_APP_VERSION=${{ env.PREVIEW_TAG }}
+ NEXT_PUBLIC_RELEASE_URL=
+ cache-from: type=gha,scope=mcp-acceptance-frontend
+ cache-to: type=gha,scope=mcp-acceptance-frontend,mode=max
+ provenance: mode=min
+ sbom: true
+ labels: |-
+ org.opencontainers.image.revision=${{ gitea.sha }}
+ org.opencontainers.image.version=${{ env.PREVIEW_TAG }}
+ io.mmapp.acceptance-only=true
+ - name: Record exact digest and build metadata
+ shell: bash
+ env:
+ IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
+ BUILD_METADATA: ${{ steps.build.outputs.metadata }}
+ run: |
+ set -euo pipefail
+ node <<'NODE'
+ const fs=require('node:fs'),crypto=require('node:crypto');
+ const digest=process.env.IMAGE_DIGEST;if(!/^sha256:[a-f0-9]{64}$/.test(digest))throw Error('Exact registry digest required');
+ const metadata=JSON.parse(process.env.BUILD_METADATA);const source=fs.readFileSync('.ci/acceptance-evidence/source.json');
+ fs.writeFileSync('.ci/acceptance-evidence/image.json',JSON.stringify({format:'mcp-preview-image-v1',sourceSha:process.env.EXPECTED_SHA,sourceProofSha256:crypto.createHash('sha256').update(source).digest('hex'),image:process.env.IMAGE_NAME,tag:process.env.PREVIEW_TAG,digest,pinnedReference:process.env.IMAGE_NAME+'@'+digest,platform:'linux/amd64',component:process.env.COMPONENT,authPortalOrigin:process.env.AUTH_PORTAL_ORIGIN??null,buildMetadata:metadata,productionDeployed:false,wholeInstallation2GbAccepted:false},null,2)+'\n');
+ console.log('Acceptance image digest: '+process.env.IMAGE_NAME+'@'+digest);
+ NODE
+ - name: Retain source and image binding artifacts
+ uses: actions/upload-artifact@v3
+ with:
+ name: mcp-acceptance-${{ env.COMPONENT }}-${{ gitea.sha }}-${{ gitea.run_id }}-${{ gitea.run_attempt }}
+ path: .ci/acceptance-evidence/*.json
+ if-no-files-found: error
+ retention-days: 14
diff --git a/.gitignore b/.gitignore
index af2e1542..12c176cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,6 +52,8 @@ Thumbs.db
.vercel/
tmp/
temp/
+.mcp-state/
+backend/.mcp-state/
.ci/docker/
.claude/settings.local.json
@@ -70,3 +72,15 @@ __pycache__/
# NetFlow agent host state (when Compose is installed in a checkout)
/data/netflow-wireguard/
/data/netflow-agent-socket/
+# Compiled disposable memory-acceptance entry; not a production image artifact.
+backend/dist-mcp-memory/
+backend/dist-operator/
+
+# Agent-local permissions can contain commands with deployment credentials.
+/.claude/settings.local.json
+
+# Local scratch and disposable build outputs (root-anchored).
+/tmp-*
+/.next-*/
+/.serena/
+/backend/dist-*/
diff --git a/README.md b/README.md
index 61f365ba..ba88872f 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,8 @@
## Содержание
+Разрабатываемый MCP для AI-клиентов: [настройка, возможности и ограничения](docs/mcp.md), [включение по шагам](docs/mcp-enable-guide.md), [полный план реализации](docs/mcp-implementation-plan.md).
+
1. [Состав монорепозитория](#состав-монорепозитория)
2. [Архитектура](#архитектура)
3. [Локальная разработка](#локальная-разработка)
diff --git a/app/(main)/ipsec/page.tsx b/app/(main)/ipsec/page.tsx
index cac40f17..a13dd808 100644
--- a/app/(main)/ipsec/page.tsx
+++ b/app/(main)/ipsec/page.tsx
@@ -53,6 +53,7 @@ import {
patchIpsecUser,
restoreIpsecRevision,
} from "@/shared/api/ipsec"
+import type { IpsecExistingCertExportOptions } from "@/shared/api/ipsec"
import type {
IpsecCertBundle,
IpsecCertInfoDto,
@@ -203,7 +204,12 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
const [certError, setCertError] = useState(null)
const certEpoch = useRef(0)
const certPending = useRef(false)
- useEffect(() => () => { certEpoch.current += 1 }, [])
+ const certFailedAttempts = useRef(new Set())
+ const certActive = useRef<{ targetKey: string; controller: AbortController } | null>(null)
+ const [certAttemptFailed, setCertAttemptFailed] = useState(false)
+ const [certRole, setCertRole] = useState("client")
+ const [certSession, setCertSession] = useState(0)
+ useEffect(() => () => { certEpoch.current += 1; certActive.current?.controller.abort() }, [])
const [search, setSearch] = useState("")
const [initOpen, setInitOpen] = useState(false)
@@ -460,6 +466,9 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
setCertBundle(res.bundle)
setCertClient(res.client ?? null)
setCertByName(null)
+ setCertRole("client")
+ setCertAttemptFailed(false)
+ setCertSession(session => session + 1)
setCertOpen(true)
}
} finally {
@@ -487,52 +496,71 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
}
}
- const loadCert = async (serverId: string, request: () => Promise) => {
+ const loadCert = async (serverId: string, targetKey: string, request: (signal: AbortSignal) => Promise) => {
if (certPending.current) return
certPending.current = true
+ const controller = new AbortController()
+ certActive.current = { targetKey, controller }
const epoch = ++certEpoch.current
setCertBusy(true)
setCertError(null)
try {
assertDeviceReady(serverId)
- const bundle = await request()
- if (epoch === certEpoch.current) setCertBundle(bundle)
+ const bundle = await request(controller.signal)
+ if (epoch === certEpoch.current) {
+ setCertBundle(bundle)
+ certFailedAttempts.current.delete(targetKey)
+ setCertAttemptFailed(false)
+ }
} catch (error) {
- if (epoch === certEpoch.current) setCertError(error instanceof Error ? error.message : "Ошибка экспорта сертификата")
+ certFailedAttempts.current.add(targetKey)
+ if (epoch === certEpoch.current) {
+ setCertAttemptFailed(true)
+ setCertError(error instanceof Error ? error.message : "Ошибка экспорта сертификата")
+ }
} finally {
- if (epoch === certEpoch.current) { certPending.current = false; setCertBusy(false) }
+ if (epoch === certEpoch.current) { certPending.current = false; certActive.current = null; setCertBusy(false) }
}
}
- const openCert = async (client: IpsecClientDto) => {
- const byName = client.kind === "cert" && Boolean(client.certName)
+ const openCert = (client: IpsecClientDto) => {
+ if (certPending.current) return
+ const byName = !client.rosId.startsWith("identity:") && client.kind === "cert" && Boolean(client.certName)
+ const targetKey = JSON.stringify([client.serverId, byName ? "certificate" : "client", byName ? client.certName : client.rosId])
certEpoch.current += 1
certPending.current = false
setCertClient(byName ? null : client)
setCertByName(byName ? { serverId: client.serverId, name: client.certName! } : null)
setCertBundle(null)
+ setCertError(null)
+ setCertAttemptFailed(certFailedAttempts.current.has(targetKey))
+ setCertRole(summaries.find(summary => summary.serverId === client.serverId)?.certs?.find(cert => cert.name === client.certName)?.role ?? "client")
+ setCertSession(session => session + 1)
setCertOpen(true)
- const passphrase = crypto.randomUUID()
- await loadCert(client.serverId, () => byName
- ? exportIpsecCertByName(backendUrl, client.serverId, client.certName!, passphrase)
- : exportIpsecUserCert(backendUrl, client.serverId, client.rosId, passphrase))
}
- const openCertByName = async (serverId: string, cert: IpsecCertInfoDto) => {
+ const openCertByName = (serverId: string, cert: IpsecCertInfoDto) => {
+ if (certPending.current) return
certEpoch.current += 1
certPending.current = false
setCertByName({ serverId, name: cert.name })
setCertClient(null)
setCertBundle(null)
+ setCertError(null)
+ setCertAttemptFailed(certFailedAttempts.current.has(JSON.stringify([serverId, "certificate", cert.name])))
+ setCertRole(cert.role ?? "other")
+ setCertSession(session => session + 1)
setCertOpen(true)
- await loadCert(serverId, () => exportIpsecCertByName(backendUrl, serverId, cert.name, crypto.randomUUID()))
}
- const reexportCert = async (passphrase: string) => {
+ const reexportCert = async (passphrase: string, options: IpsecExistingCertExportOptions) => {
if (!certClient && !certByName) return
- await loadCert(certByName?.serverId ?? certClient!.serverId, () => certByName
- ? exportIpsecCertByName(backendUrl, certByName.serverId, certByName.name, passphrase)
- : exportIpsecUserCert(backendUrl, certClient!.serverId, certClient!.rosId, passphrase))
+ if (options.privateKeyExport !== true || (certRole === "ca" && !options.caPrivateKeyExport)) return
+ const serverId = certByName?.serverId ?? certClient!.serverId
+ const targetKey = JSON.stringify([serverId, certByName ? "certificate" : "client", certByName?.name ?? certClient!.rosId])
+ await loadCert(serverId, targetKey, signal => certByName
+ ? exportIpsecCertByName(backendUrl, certByName.serverId, certByName.name, passphrase, options, { signal })
+ : exportIpsecUserCert(backendUrl, certClient!.serverId, certClient!.rosId, passphrase, options, { signal }))
}
const deletingCertificateIdentity = pendingDelete?.kind === "user" && pendingDelete.client.kind === "cert" && pendingDelete.client.rosId.startsWith("identity:")
@@ -919,14 +947,25 @@ function IpsecPage({ selectedServerId, setSelectedServerId, workspaceTab, setWor
/>
{
- if (!v) { certEpoch.current += 1; certPending.current = false; setCertBusy(false); setCertBundle(null); setCertClient(null); setCertByName(null) }
+ if (!v) {
+ if (certActive.current) {
+ certFailedAttempts.current.add(certActive.current.targetKey)
+ certActive.current.controller.abort()
+ certActive.current = null
+ }
+ certEpoch.current += 1; certPending.current = false; setCertBusy(false); setCertBundle(null); setCertClient(null); setCertByName(null)
+ }
setCertOpen(v)
}}
error={certError}
bundle={certBundle}
busy={certBusy}
+ certificateRole={certRole}
+ targetName={certByName?.name ?? certClient?.certName ?? certClient?.name}
+ previousAttemptFailed={certAttemptFailed}
onReexport={reexportCert}
/>
diff --git a/app/(main)/mcp/page.tsx b/app/(main)/mcp/page.tsx
new file mode 100644
index 00000000..4dc14875
--- /dev/null
+++ b/app/(main)/mcp/page.tsx
@@ -0,0 +1,6 @@
+import { Suspense } from "react"
+import { McpWorkspace } from "@/components/mcp/mcp-workspace"
+
+export default function McpPage() {
+ return Загрузка MCP…
}>
+}
diff --git a/app/(main)/traffic/page.tsx b/app/(main)/traffic/page.tsx
index aa6fef19..b6da6a9a 100644
--- a/app/(main)/traffic/page.tsx
+++ b/app/(main)/traffic/page.tsx
@@ -924,18 +924,21 @@ export default function TrafficPage() {
})
return () => { cancelled = true }
}
- void Promise.all([
- getTrafficFlows(backendUrl, range),
- getFlowExporters(backendUrl, range),
- getFlowClients(backendUrl, range),
- ]).then(([stats, exporters, clients]) => {
+ const loadFlowCards = async () => {
+ // These reads share the collector's constrained admission budget.
+ const stats = await getTrafficFlows(backendUrl, range)
+ if (cancelled) return
+ const exporters = await getFlowExporters(backendUrl, range)
+ if (cancelled) return
+ const clients = await getFlowClients(backendUrl, range)
if (cancelled) return
setFlowResult({ key: flowKey, receivedAt: Date.now(), stats, exporters: exporters.exporters, clients: clients.clients })
setSelectedId(prev => {
const list = flowScope === "users" ? clients.clients : exporters.exporters
return list.some(x => x.id === prev) ? prev : (list[0]?.id ?? "")
})
- }).catch(e => {
+ }
+ void loadFlowCards().catch(e => {
if (!cancelled) setFlowResult({ key: flowKey, error: e instanceof Error ? e.message : "Не удалось загрузить потоки" })
})
return () => { cancelled = true }
diff --git a/app/(main)/users/page.tsx b/app/(main)/users/page.tsx
index 8e561cde..55186232 100644
--- a/app/(main)/users/page.tsx
+++ b/app/(main)/users/page.tsx
@@ -74,6 +74,7 @@ function UsersContent() {
const isLive = mode === "live"
const canRead = can("mm:users:read")
const canWrite = can("mm:users:write")
+ const canManagePermissions = !isLive || can("mm:settings:admin")
const canReadServers = can("mm:servers:read")
const [users, setUsers] = useState(() => isLive ? [] : INIT_USERS)
@@ -184,8 +185,8 @@ function UsersContent() {
setSaving(true); setSaveError(null); setOperationNotice(null)
try {
const saved = await saveUserSteps(form, checkpoint, {
- create: f => createAppUser(backendUrl, userProfileRequest(f), init()),
- update: (id, f) => updateAppUser(backendUrl, id, userProfileRequest(f), init()),
+ create: f => createAppUser(backendUrl, userProfileRequest(f, canManagePermissions), init()),
+ update: (id, f) => updateAppUser(backendUrl, id, userProfileRequest(f, canManagePermissions), init()),
read: id => getAppUser(backendUrl, id, init()),
removeBinding: (userId, id) => deleteUserBinding(backendUrl, userId, id, init()),
addBinding: (userId, b) => createUserBinding(backendUrl, userId, {
@@ -328,6 +329,7 @@ function UsersContent() {
users={users}
servers={serverOptions}
isLive={isLive}
+ canManagePermissions={canManagePermissions}
backendUrl={backendUrl}
saving={saving}
saveError={saveError}
diff --git a/app/globals.css b/app/globals.css
index ae204b9d..31af6717 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -1,7 +1,16 @@
-@import "tailwindcss";
+@import "tailwindcss" source(none);
@import "tw-animate-css";
@import "shadcn/tailwind.css";
+/* Scan application sources only; local test archives and generated bundles
+ must not become utility classes in the production stylesheet. */
+@source "./";
+@source "../components";
+@source "../entities";
+@source "../hooks";
+@source "../lib";
+@source "../shared";
+
/* SVG focus follows the object shape, never the text/foreignObject bounding box. */
.network-map-focusable {
outline: none;
diff --git a/backend/.env.example b/backend/.env.example
index ad027360..88f654b3 100644
--- a/backend/.env.example
+++ b/backend/.env.example
@@ -1,5 +1,33 @@
# PostgreSQL connection string
DATABASE_URL=postgres://mmapp:mmapp@127.0.0.1:5432/mmapp
+# Optional operator-approved request and CA for runtime PostgreSQL TLS and SQL identity checks.
+# DATABASE_RUNTIME_REQUEST_FILE=/run/config/mmapp/approved-request.json
+# DATABASE_RUNTIME_REQUEST_SHA256=
+# DATABASE_RUNTIME_CA_FILE=/run/config/mmapp/postgresql-ca.pem
+# Optional live operator activation directory (mount the directory read-only).
+# DATABASE_RUNTIME_ACTIVATION_DIRECTORY=/var/lib/mmapp/source-activation
+# DATABASE_RUNTIME_ACTIVATION_SHA256=
+# Optional operator-approved logical schema SHA-256 from db:inspect-schema.
+# DATABASE_RUNTIME_SCHEMA_SHA256=
+# Restore-aware signed writer profile. Requires source activation, schema pin and restore checkpoint.
+# DATABASE_RUNTIME_WRITER_APPROVAL_FILE=/run/config/mmapp/writer-approval.json
+# DATABASE_RUNTIME_WRITER_APPROVAL_SHA256=
+# Protected exports use the approved capture role and require this private password file.
+# The PostgreSQL TLS peer must present the approved self-signed non-CA leaf.
+# DATABASE_ARCHIVE_PASSWORD_FILE=/run/secrets/mmapp_database_archive_password
+# Optional owner connection URI file for restore and its schema migrations.
+# DATABASE_RESTORE_URL_FILE=/run/secrets/mmapp_database_restore_url
+# Opt in on every backend/CLI after provisioning the restore quarantine in mmapp_control.
+# DATABASE_RESTORE_QUARANTINE=true
+# Optional operator-approved pair for verifying one archive's restored data.
+# Requires DATABASE_RESTORE_QUARANTINE and DATABASE_RESTORE_URL_FILE.
+# DATABASE_RESTORE_ARCHIVE_SHA256=
+# DATABASE_RESTORE_DATA_SHA256=
+# Optional checkpoint in an operator-managed directory outside the PostgreSQL and MCP state backups.
+# Mount the whole directory read-only. Restore requires a staged pending checkpoint.
+# DATABASE_RESTORE_CHECKPOINT_FILE=/run/config/mmapp-restore/database-restore-checkpoint.json
+# Local socket served by the operator-side db:serve-restore-claims process.
+# DATABASE_RESTORE_CHECKPOINT_CLAIM_SOCKET=/run/mmapp-restore/claims.sock
# SQLite file used only for one-shot boot ETL (empty PG + existing mikrotik.db)
DATABASE_PATH=./mikrotik.db
@@ -17,5 +45,37 @@ AUTH_REQUIRED=false
AUTH_JWT_SECRET=dev-secret-change-me
AUTH_ISSUER=https://auth.shnt.top
AUTH_PORTAL_URL=http://localhost:5175
+# Optional portal -> MCP revocation webhook. Separate random secret, at least 32 characters.
+# Portal must send signed events to /_internal/mcp/portal/revocations; see docs/mcp.md.
+# MCP_PORTAL_WEBHOOK_SECRET=
+# MCP_PUBLIC_URL=https://manager.example/mcp
+# MCP_STATE_DIR=/var/lib/mikrotik-manager/mcp-state
+# Optional separate, externally provisioned bandwidth control source. No automatic
+# schema/key/identity creation. See docs/mcp-bandwidth-control-source.md.
+# Use the restricted control runtime role, never the owner/application role.
+# MMAPP_BANDWIDTH_CONTROL_URL=postgresql://bandwidth_runtime:change-me@control-db:5432/bandwidth_control
+# MMAPP_BANDWIDTH_CONTROL_ATTESTATION_FILE=/etc/mmapp/control/source.json
+# MMAPP_BANDWIDTH_CONTROL_TRUST_KEY_FILE=/etc/mmapp/control/issuer-public.pem
+# SHA256 of the Ed25519 public SPKI DER, pinned outside the attestation itself.
+# MMAPP_BANDWIDTH_CONTROL_TRUST_KEY_SHA256=
+# MMAPP_BANDWIDTH_CONTROL_EVENT_KEY_FILE=/etc/mmapp/control/event.key
+# Separate persistent registry issuer key (raw 32 bytes, different from event.key)
+# and operator bootstrap signed by the pinned control-source Ed25519 issuer.
+# These inputs grant no actor/network permissions and create no registry rows.
+# MMAPP_BANDWIDTH_NODE_ISSUER_KEY_FILE=/etc/mmapp/control/node-issuer.key
+# MMAPP_BANDWIDTH_NODE_ISSUER_KEY_SHA256=
+# MMAPP_BANDWIDTH_NODE_BOOTSTRAP_FILE=/etc/mmapp/control/node-bootstrap.json
# Optional: enabled by the NetFlow agent Compose installer. Linux Unix socket only.
# FLOW_AGENT_SOCKET=/run/mm-netflow-host/agent.sock
+
+# Optional UDP NetFlow v9/IPFIX template lifetime in milliseconds (restart required).
+# Collector policy defaults to 90 minutes, not a RouterOS default. Set at least
+# 3 times the longest configured exporter template refresh interval; data does
+# not refresh templates. Missing/expired templates refuse decoding, not zero traffic.
+# FLOW_TEMPLATE_LIFETIME_MS=5400000
+
+# Optional NetFlow read admission: standard (default) or constrained.
+# Constrained admits two responses (UI + AI), limits SQL sources to 2 MiB,
+# cumulative sources to 4 MiB and encoded responses to 2 MiB; large reads refuse.
+# This is not a complete installation memory limit. See docs/mcp-2gb-resource-acceptance.md.
+# MM_FLOW_READ_RESOURCE_PROFILE=standard
diff --git a/backend/Dockerfile b/backend/Dockerfile
index 95fb213e..b591b870 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -55,7 +55,9 @@ COPY --from=build /app/package.json /app/package-lock.json ./
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/packages/contracts ./packages/contracts
COPY --from=build /app/backend/dist ./backend/dist
+COPY --from=build /app/backend/dist-operator ./backend/dist-operator
COPY --from=build /app/backend/package.json ./backend/package.json
+COPY --from=build /app/backend/mcp-coverage.json ./backend/mcp-coverage.json
COPY --from=build /app/backend/drizzle ./backend/drizzle
COPY deploy/netflow-agent/install.sh ./deploy/netflow-agent/install.sh
# Nested install from lockfile (dotenv etc.) — ESM resolves from /app/backend/dist → ../node_modules
diff --git a/backend/drizzle/0008_alert_outbox_outcomes.sql b/backend/drizzle/0008_alert_outbox_outcomes.sql
index 60ebf17b..4f8b89a6 100644
--- a/backend/drizzle/0008_alert_outbox_outcomes.sql
+++ b/backend/drizzle/0008_alert_outbox_outcomes.sql
@@ -1,6 +1,6 @@
--- Захват перед POST и удержание неизвестных исходов. Исторические строки не меняются.
-BEGIN;
-ALTER TABLE alert_outbox DROP CONSTRAINT IF EXISTS alert_outbox_status_check;
-ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_status_check
- CHECK (status IN ('pending', 'processing', 'unknown', 'sent', 'failed'));
-COMMIT;
+-- Захват перед POST и удержание неизвестных исходов. Исторические строки не меняются.
+BEGIN;
+ALTER TABLE alert_outbox DROP CONSTRAINT IF EXISTS alert_outbox_status_check;
+ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_status_check
+ CHECK (status IN ('pending', 'processing', 'unknown', 'sent', 'failed'));
+COMMIT;
diff --git a/backend/drizzle/0009_alert_outbox_resolution.sql b/backend/drizzle/0009_alert_outbox_resolution.sql
index fbedccf1..f8af6ff2 100644
--- a/backend/drizzle/0009_alert_outbox_resolution.sql
+++ b/backend/drizzle/0009_alert_outbox_resolution.sql
@@ -1,4 +1,4 @@
-BEGIN;
-ALTER TABLE alert_outbox ADD COLUMN IF NOT EXISTS resolution_version integer NOT NULL DEFAULT 0;
-ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_resolution_version_check CHECK (resolution_version >= 0);
-COMMIT;
+BEGIN;
+ALTER TABLE alert_outbox ADD COLUMN IF NOT EXISTS resolution_version integer NOT NULL DEFAULT 0;
+ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_resolution_version_check CHECK (resolution_version >= 0);
+COMMIT;
diff --git a/backend/drizzle/0010_ping_measurement_known.sql b/backend/drizzle/0010_ping_measurement_known.sql
index 239552e7..10a55fdc 100644
--- a/backend/drizzle/0010_ping_measurement_known.sql
+++ b/backend/drizzle/0010_ping_measurement_known.sql
@@ -1,3 +1,3 @@
--- A failed command is an attempt, not a measured packet-loss percentage.
-ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS measurement_known BOOLEAN NOT NULL DEFAULT true;
-ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS observation_error TEXT;
+-- A failed command is an attempt, not a measured packet-loss percentage.
+ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS measurement_known BOOLEAN NOT NULL DEFAULT true;
+ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS observation_error TEXT;
diff --git a/backend/drizzle/0011_traffic_collection_state.sql b/backend/drizzle/0011_traffic_collection_state.sql
index f5c5245f..78331da4 100644
--- a/backend/drizzle/0011_traffic_collection_state.sql
+++ b/backend/drizzle/0011_traffic_collection_state.sql
@@ -1,8 +1,8 @@
-CREATE TABLE IF NOT EXISTS traffic_collection_state (
- server_id BIGINT PRIMARY KEY REFERENCES servers(id) ON DELETE CASCADE,
- server_updated_at TIMESTAMPTZ NOT NULL,
- last_attempt_at TIMESTAMPTZ NOT NULL,
- last_succeeded_at TIMESTAMPTZ,
- status TEXT NOT NULL CHECK(status IN ('pending', 'ok', 'error')),
- error TEXT
-);
+CREATE TABLE IF NOT EXISTS traffic_collection_state (
+ server_id BIGINT PRIMARY KEY REFERENCES servers(id) ON DELETE CASCADE,
+ server_updated_at TIMESTAMPTZ NOT NULL,
+ last_attempt_at TIMESTAMPTZ NOT NULL,
+ last_succeeded_at TIMESTAMPTZ,
+ status TEXT NOT NULL CHECK(status IN ('pending', 'ok', 'error')),
+ error TEXT
+);
diff --git a/backend/drizzle/0012_traffic_counter_identity.sql b/backend/drizzle/0012_traffic_counter_identity.sql
index 9d48866b..dcb7de8d 100644
--- a/backend/drizzle/0012_traffic_counter_identity.sql
+++ b/backend/drizzle/0012_traffic_counter_identity.sql
@@ -1 +1 @@
-ALTER TABLE traffic_samples ADD COLUMN IF NOT EXISTS native_counter_identity TEXT;
+ALTER TABLE traffic_samples ADD COLUMN IF NOT EXISTS native_counter_identity TEXT;
diff --git a/backend/drizzle/0013_scheduler_retention_index.sql b/backend/drizzle/0013_scheduler_retention_index.sql
index ec1ef14d..a0e12c57 100644
--- a/backend/drizzle/0013_scheduler_retention_index.sql
+++ b/backend/drizzle/0013_scheduler_retention_index.sql
@@ -1,4 +1,4 @@
--- Retention runs after each scheduler receipt; avoid scanning the complete history.
--- On a busy existing installation, pre-create this same index CONCURRENTLY
--- outside a transaction before deploying (deploy/PRODUCTION-RETENTION-INDEX.md).
-CREATE INDEX IF NOT EXISTS idx_scheduler_runs_finished_at ON scheduler_runs (finished_at);
+-- Retention runs after each scheduler receipt; avoid scanning the complete history.
+-- On a busy existing installation, pre-create this same index CONCURRENTLY
+-- outside a transaction before deploying (deploy/PRODUCTION-RETENTION-INDEX.md).
+CREATE INDEX IF NOT EXISTS idx_scheduler_runs_finished_at ON scheduler_runs (finished_at);
diff --git a/backend/drizzle/0015_mcp.sql b/backend/drizzle/0015_mcp.sql
new file mode 100644
index 00000000..abafc705
--- /dev/null
+++ b/backend/drizzle/0015_mcp.sql
@@ -0,0 +1,101 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_settings (
+ id integer PRIMARY KEY CHECK(id=1), enabled boolean NOT NULL DEFAULT false,
+ requests_retention_days integer NOT NULL DEFAULT 30 CHECK(requests_retention_days BETWEEN 1 AND 365),
+ audit_retention_days integer NOT NULL DEFAULT 180 CHECK(audit_retention_days BETWEEN 30 AND 3650),
+ updated_at timestamptz NOT NULL DEFAULT now()
+);
+INSERT INTO mcp_settings(id) VALUES(1) ON CONFLICT DO NOTHING;
+CREATE TABLE IF NOT EXISTS mcp_connections (
+ id uuid PRIMARY KEY, name text NOT NULL, owner_id text NOT NULL, owner_permissions jsonb NOT NULL,
+ policy jsonb NOT NULL, generation text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(),
+ updated_at timestamptz NOT NULL DEFAULT now(), last_used_at timestamptz
+);
+CREATE TABLE IF NOT EXISTS mcp_credentials (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id) ON DELETE CASCADE,
+ digest text NOT NULL UNIQUE, kind text NOT NULL CHECK(kind IN ('bearer','access','refresh')),
+ expires_at timestamptz NOT NULL, revoked_at timestamptz, created_at timestamptz NOT NULL DEFAULT now(),
+ family_id uuid, client_id text, audience text
+);
+CREATE INDEX IF NOT EXISTS mcp_credentials_connection ON mcp_credentials(connection_id);
+CREATE TABLE IF NOT EXISTS mcp_audit (
+ id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, actor_id text NOT NULL, action text NOT NULL,
+ connection_id uuid, payload jsonb NOT NULL DEFAULT '{}', created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE INDEX IF NOT EXISTS mcp_audit_time ON mcp_audit(created_at,id);
+CREATE TABLE IF NOT EXISTS mcp_requests (
+ id uuid PRIMARY KEY, connection_id uuid REFERENCES mcp_connections(id) ON DELETE SET NULL,
+ actor_id text, tool text NOT NULL, server_ids bigint[] NOT NULL DEFAULT '{}',
+ status text NOT NULL, input jsonb NOT NULL DEFAULT '{}', result jsonb, error_code text,
+ duration_ms integer, created_at timestamptz NOT NULL DEFAULT now(), finished_at timestamptz
+);
+CREATE INDEX IF NOT EXISTS mcp_requests_connection_time ON mcp_requests(connection_id,created_at,id);
+CREATE INDEX IF NOT EXISTS mcp_requests_server ON mcp_requests USING gin(server_ids);
+CREATE TABLE IF NOT EXISTS mcp_protections (
+ id uuid PRIMARY KEY, object_ref jsonb NOT NULL, reason text NOT NULL DEFAULT '',
+ created_by text NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_plans (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id), operation_id text NOT NULL,
+ operation_version integer NOT NULL, policy_version integer NOT NULL, generation text NOT NULL,
+ payload jsonb NOT NULL, evidence jsonb NOT NULL, state text NOT NULL, expires_at timestamptz NOT NULL,
+ approved_by text, approved_at timestamptz, created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE INDEX IF NOT EXISTS mcp_plans_connection ON mcp_plans(connection_id,created_at);
+CREATE TABLE IF NOT EXISTS mcp_operations (
+ id uuid PRIMARY KEY, plan_id uuid NOT NULL UNIQUE REFERENCES mcp_plans(id),
+ connection_id uuid NOT NULL REFERENCES mcp_connections(id), idempotency_key text NOT NULL,
+ state text NOT NULL DEFAULT 'pending', verification text NOT NULL DEFAULT 'pending',
+ result jsonb, error_code text, created_at timestamptz NOT NULL DEFAULT now(), finished_at timestamptz,
+ UNIQUE(connection_id,idempotency_key)
+);
+CREATE TABLE IF NOT EXISTS mcp_operation_steps (
+ operation_id uuid NOT NULL REFERENCES mcp_operations(id), step_index integer NOT NULL,
+ server_id bigint, state text NOT NULL, before_state jsonb, intended_state jsonb, result jsonb,
+ created_at timestamptz NOT NULL DEFAULT now(), finished_at timestamptz,
+ PRIMARY KEY(operation_id,step_index)
+);
+CREATE TABLE IF NOT EXISTS mcp_budget_buckets (
+ connection_id uuid NOT NULL REFERENCES mcp_connections(id) ON DELETE CASCADE,
+ kind text NOT NULL, bucket timestamptz NOT NULL, used integer NOT NULL CHECK(used>=0),
+ PRIMARY KEY(connection_id,kind,bucket)
+);
+CREATE TABLE IF NOT EXISTS mcp_read_leases (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id) ON DELETE CASCADE,
+ expires_at timestamptz NOT NULL
+);
+CREATE TABLE IF NOT EXISTS mcp_grants (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id) ON DELETE CASCADE,
+ payload jsonb NOT NULL, revoked_at timestamptz
+);
+CREATE TABLE IF NOT EXISTS mcp_secrets (
+ id uuid PRIMARY KEY, purpose text NOT NULL, server_id bigint, ciphertext text NOT NULL,
+ created_by text NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_artifacts (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id),
+ filename text NOT NULL, media_type text NOT NULL, ciphertext text NOT NULL,
+ expires_at timestamptz NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_oauth_clients (
+ id text PRIMARY KEY, name text NOT NULL, redirect_uris jsonb NOT NULL, enabled boolean NOT NULL DEFAULT true,
+ created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_oauth_requests (
+ id uuid PRIMARY KEY, client_id text NOT NULL REFERENCES mcp_oauth_clients(id),
+ redirect_uri text NOT NULL, challenge text NOT NULL, state text, resource text NOT NULL,
+ scope text NOT NULL, expires_at timestamptz NOT NULL, consumed_at timestamptz,
+ connection_id uuid REFERENCES mcp_connections(id), code_digest text UNIQUE
+);
+CREATE TABLE IF NOT EXISTS mcp_routing_profiles (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id),
+ version integer NOT NULL DEFAULT 1, config jsonb NOT NULL, state jsonb NOT NULL DEFAULT '{}',
+ enabled boolean NOT NULL DEFAULT false, grant_expires_at timestamptz NOT NULL,
+ updated_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_drift (
+ id uuid PRIMARY KEY, operation_id uuid NOT NULL REFERENCES mcp_operations(id),
+ server_id bigint, expected jsonb NOT NULL, observed jsonb NOT NULL,
+ acknowledged_at timestamptz, detected_at timestamptz NOT NULL DEFAULT now()
+);
+COMMIT;
diff --git a/backend/drizzle/0016_mcp_routing_observations.sql b/backend/drizzle/0016_mcp_routing_observations.sql
new file mode 100644
index 00000000..b7301661
--- /dev/null
+++ b/backend/drizzle/0016_mcp_routing_observations.sql
@@ -0,0 +1,12 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_routing_observations (
+ id uuid PRIMARY KEY, src_server_id bigint NOT NULL, dst_server_id bigint NOT NULL,
+ src_interface text NOT NULL, dst_interface text NOT NULL, family text NOT NULL CHECK(family IN ('ipv4','ipv6')),
+ routing_table text NOT NULL DEFAULT 'main', ping_ms double precision, loss_pct double precision,
+ dl_mbps double precision, ul_mbps double precision, ping_at timestamptz, bandwidth_at timestamptz,
+ context_verified boolean NOT NULL DEFAULT false, source text NOT NULL,
+ created_at timestamptz NOT NULL DEFAULT now(), CHECK(ping_ms IS NULL OR ping_ms>=0),
+ CHECK(loss_pct IS NULL OR loss_pct BETWEEN 0 AND 100), CHECK(dl_mbps IS NULL OR dl_mbps>=0), CHECK(ul_mbps IS NULL OR ul_mbps>=0)
+);
+CREATE INDEX IF NOT EXISTS mcp_routing_observations_leg ON mcp_routing_observations(src_server_id,dst_server_id,src_interface,family,routing_table,created_at DESC);
+COMMIT;
diff --git a/backend/drizzle/0017_mcp_controller.sql b/backend/drizzle/0017_mcp_controller.sql
new file mode 100644
index 00000000..988405bd
--- /dev/null
+++ b/backend/drizzle/0017_mcp_controller.sql
@@ -0,0 +1,7 @@
+BEGIN;
+ALTER TABLE mcp_routing_profiles ADD COLUMN IF NOT EXISTS credential_id uuid REFERENCES mcp_credentials(id);
+ALTER TABLE mcp_routing_profiles ADD COLUMN IF NOT EXISTS generation text;
+ALTER TABLE mcp_routing_profiles ADD COLUMN IF NOT EXISTS policy_version integer;
+CREATE INDEX IF NOT EXISTS mcp_routing_profiles_enabled ON mcp_routing_profiles(updated_at) WHERE enabled;
+CREATE UNIQUE INDEX IF NOT EXISTS mcp_drift_open_step ON mcp_drift(operation_id,(expected->>'stepIndex')) WHERE acknowledged_at IS NULL;
+COMMIT;
diff --git a/backend/drizzle/0018_mcp_owner_validation.sql b/backend/drizzle/0018_mcp_owner_validation.sql
new file mode 100644
index 00000000..fd91b038
--- /dev/null
+++ b/backend/drizzle/0018_mcp_owner_validation.sql
@@ -0,0 +1,3 @@
+BEGIN;
+ALTER TABLE mcp_connections ADD COLUMN IF NOT EXISTS owner_valid_until timestamptz NOT NULL DEFAULT now();
+COMMIT;
diff --git a/backend/drizzle/0019_mcp_recovery.sql b/backend/drizzle/0019_mcp_recovery.sql
new file mode 100644
index 00000000..11d803b6
--- /dev/null
+++ b/backend/drizzle/0019_mcp_recovery.sql
@@ -0,0 +1,7 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_operation_checkpoints (
+ operation_id uuid NOT NULL REFERENCES mcp_operations(id), step_index integer NOT NULL,
+ before_sealed text NOT NULL, after_sealed text, created_at timestamptz NOT NULL DEFAULT now(),
+ PRIMARY KEY(operation_id,step_index)
+);
+COMMIT;
diff --git a/backend/drizzle/0020_mcp_management.sql b/backend/drizzle/0020_mcp_management.sql
new file mode 100644
index 00000000..e83b8806
--- /dev/null
+++ b/backend/drizzle/0020_mcp_management.sql
@@ -0,0 +1,8 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_management_channels (
+ id uuid PRIMARY KEY, server_id bigint NOT NULL UNIQUE REFERENCES servers(id) ON DELETE CASCADE,
+ config_sealed text NOT NULL, identity_hash text NOT NULL, attestation text NOT NULL,
+ created_by text NOT NULL, generation text NOT NULL, expires_at timestamptz NOT NULL,
+ verified_at timestamptz NOT NULL DEFAULT now(), revoked_at timestamptz
+);
+COMMIT;
diff --git a/backend/drizzle/0021_mcp_path_checks.sql b/backend/drizzle/0021_mcp_path_checks.sql
new file mode 100644
index 00000000..6396545f
--- /dev/null
+++ b/backend/drizzle/0021_mcp_path_checks.sql
@@ -0,0 +1,8 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_path_checks (
+ id uuid PRIMARY KEY, connection_id uuid NOT NULL REFERENCES mcp_connections(id),
+ profile_hash text NOT NULL, candidate_id text NOT NULL, status text NOT NULL CHECK(status IN ('passed','failed','unknown')),
+ evidence jsonb NOT NULL, created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE INDEX IF NOT EXISTS mcp_path_checks_latest ON mcp_path_checks(connection_id,profile_hash,candidate_id,created_at DESC);
+COMMIT;
diff --git a/backend/drizzle/0022_mcp_recovery_intents.sql b/backend/drizzle/0022_mcp_recovery_intents.sql
new file mode 100644
index 00000000..2fdc29c6
--- /dev/null
+++ b/backend/drizzle/0022_mcp_recovery_intents.sql
@@ -0,0 +1,7 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_recovery_intents (
+ operation_id uuid PRIMARY KEY REFERENCES mcp_operations(id), state text NOT NULL,
+ authority_profile_id uuid NOT NULL REFERENCES mcp_routing_profiles(id),
+ created_at timestamptz NOT NULL DEFAULT now(), finished_at timestamptz
+);
+COMMIT;
diff --git a/backend/drizzle/0023_mcp_protocol_limits.sql b/backend/drizzle/0023_mcp_protocol_limits.sql
new file mode 100644
index 00000000..1ec810d4
--- /dev/null
+++ b/backend/drizzle/0023_mcp_protocol_limits.sql
@@ -0,0 +1,6 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_unauthorized_buckets (
+ bucket timestamptz NOT NULL, client_hash text NOT NULL, reason text NOT NULL,
+ attempts integer NOT NULL DEFAULT 1, PRIMARY KEY(bucket,client_hash,reason)
+);
+COMMIT;
diff --git a/backend/drizzle/0024_user_interface_types.sql b/backend/drizzle/0024_user_interface_types.sql
new file mode 100644
index 00000000..0d209333
--- /dev/null
+++ b/backend/drizzle/0024_user_interface_types.sql
@@ -0,0 +1,4 @@
+BEGIN;
+ALTER TABLE user_interface_bindings DROP CONSTRAINT IF EXISTS user_interface_bindings_interface_type_check;
+ALTER TABLE user_interface_bindings ADD CONSTRAINT user_interface_bindings_interface_type_check CHECK(interface_type IN ('ether','bridge','vlan','vxlan','gre','wg','ipsec','other'));
+COMMIT;
diff --git a/backend/drizzle/0025_mcp_portal_revocation.sql b/backend/drizzle/0025_mcp_portal_revocation.sql
new file mode 100644
index 00000000..b0e5f9a4
--- /dev/null
+++ b/backend/drizzle/0025_mcp_portal_revocation.sql
@@ -0,0 +1,11 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_owner_revocations (
+ owner_id text PRIMARY KEY, invalid_before timestamptz NOT NULL,
+ updated_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE TABLE IF NOT EXISTS mcp_portal_events (
+ id uuid PRIMARY KEY, owner_id text NOT NULL, payload_hash text NOT NULL,
+ created_at timestamptz NOT NULL DEFAULT now()
+);
+CREATE INDEX IF NOT EXISTS mcp_portal_events_time ON mcp_portal_events(created_at);
+COMMIT;
diff --git a/backend/drizzle/0026_mcp_owner_claims_issued.sql b/backend/drizzle/0026_mcp_owner_claims_issued.sql
new file mode 100644
index 00000000..c55e64e9
--- /dev/null
+++ b/backend/drizzle/0026_mcp_owner_claims_issued.sql
@@ -0,0 +1,3 @@
+BEGIN;
+ALTER TABLE mcp_connections ADD COLUMN IF NOT EXISTS owner_claims_issued_at timestamptz NOT NULL DEFAULT to_timestamp(0);
+COMMIT;
diff --git a/backend/drizzle/0027_mcp_readiness.sql b/backend/drizzle/0027_mcp_readiness.sql
new file mode 100644
index 00000000..a1713014
--- /dev/null
+++ b/backend/drizzle/0027_mcp_readiness.sql
@@ -0,0 +1,8 @@
+CREATE INDEX IF NOT EXISTS mcp_audit_handshake_cooldown
+ ON mcp_audit(connection_id, created_at DESC)
+ WHERE action = 'connection.handshake.start';
+CREATE INDEX IF NOT EXISTS mcp_credentials_readiness_expired
+ ON mcp_credentials(connection_id, expires_at)
+ WHERE client_id = 'mcp-readiness-probe';
+CREATE INDEX IF NOT EXISTS mcp_grants_credential
+ ON mcp_grants(connection_id, (payload->>'credentialId'));
diff --git a/backend/drizzle/0028_mcp_artifact_scope.sql b/backend/drizzle/0028_mcp_artifact_scope.sql
new file mode 100644
index 00000000..7da202f5
--- /dev/null
+++ b/backend/drizzle/0028_mcp_artifact_scope.sql
@@ -0,0 +1,2 @@
+ALTER TABLE mcp_artifacts ADD COLUMN IF NOT EXISTS access_scope jsonb;
+CREATE INDEX IF NOT EXISTS mcp_artifacts_expiry ON mcp_artifacts(expires_at);
diff --git a/backend/drizzle/0029_mcp_routing_sources.sql b/backend/drizzle/0029_mcp_routing_sources.sql
new file mode 100644
index 00000000..688aa804
--- /dev/null
+++ b/backend/drizzle/0029_mcp_routing_sources.sql
@@ -0,0 +1,23 @@
+BEGIN;
+ALTER TABLE servers ADD COLUMN IF NOT EXISTS routing_endpoint_epoch uuid NOT NULL DEFAULT gen_random_uuid();
+CREATE OR REPLACE FUNCTION mm_routing_endpoint_epoch() RETURNS trigger LANGUAGE plpgsql AS $$
+BEGIN
+ IF ROW(NEW.host,NEW.port,NEW.username,NEW.password,NEW.use_ssl,NEW.verify_ssl,NEW.enabled)
+ IS DISTINCT FROM ROW(OLD.host,OLD.port,OLD.username,OLD.password,OLD.use_ssl,OLD.verify_ssl,OLD.enabled) THEN
+ NEW.routing_endpoint_epoch := gen_random_uuid();
+ ELSE
+ NEW.routing_endpoint_epoch := OLD.routing_endpoint_epoch;
+ END IF;
+ RETURN NEW;
+END $$;
+DROP TRIGGER IF EXISTS mm_routing_endpoint_epoch ON servers;
+CREATE TRIGGER mm_routing_endpoint_epoch BEFORE UPDATE ON servers FOR EACH ROW EXECUTE FUNCTION mm_routing_endpoint_epoch();
+ALTER TABLE mcp_routing_observations ADD COLUMN IF NOT EXISTS source_proof text;
+DO $$ BEGIN
+ IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname='mcp_routing_observation_source_proof' AND conrelid='mcp_routing_observations'::regclass) THEN
+ ALTER TABLE mcp_routing_observations ADD CONSTRAINT mcp_routing_observation_source_proof CHECK(source_proof IS NULL OR source_proof ~ '^[a-f0-9]{64}$');
+ END IF;
+END $$;
+-- Existing measurements stay readable but unsigned. Never attest old samples
+-- using today's endpoint: that would invent capture-time provenance.
+COMMIT;
diff --git a/backend/drizzle/0030_mcp_scoped_configuration_checkpoint.sql b/backend/drizzle/0030_mcp_scoped_configuration_checkpoint.sql
new file mode 100644
index 00000000..3356853d
--- /dev/null
+++ b/backend/drizzle/0030_mcp_scoped_configuration_checkpoint.sql
@@ -0,0 +1,6 @@
+BEGIN;
+-- Service-owned exact read-back must survive a subsequent network probe failure.
+-- Generic after_sealed remains an array of resource snapshots.
+ALTER TABLE mcp_operation_checkpoints ADD COLUMN IF NOT EXISTS configuration_sealed text;
+ALTER TABLE mcp_operation_checkpoints ADD COLUMN IF NOT EXISTS configuration_proof text;
+COMMIT;
diff --git a/backend/drizzle/0031_mcp_scoped_recovery.sql b/backend/drizzle/0031_mcp_scoped_recovery.sql
new file mode 100644
index 00000000..08b40e2b
--- /dev/null
+++ b/backend/drizzle/0031_mcp_scoped_recovery.sql
@@ -0,0 +1,24 @@
+BEGIN;
+CREATE TABLE IF NOT EXISTS mcp_scoped_recovery_intents (
+ source_operation_id uuid NOT NULL REFERENCES mcp_operations(id),
+ source_step_index integer NOT NULL CHECK(source_step_index>=0),
+ source_receipt_id uuid NOT NULL,
+ source_configuration_proof text NOT NULL,
+ recovery_receipt_id uuid NOT NULL UNIQUE,
+ recovery_operation_id uuid REFERENCES mcp_operations(id),
+ mode text NOT NULL CHECK(mode IN ('manual','reserved')),
+ authority_profile_id uuid REFERENCES mcp_routing_profiles(id),
+ authority_profile_version integer,
+ intent_sealed text NOT NULL,
+ intent_proof text NOT NULL,
+ state text NOT NULL CHECK(state IN ('intent','verified','unknown')),
+ deadline timestamptz NOT NULL,
+ created_at timestamptz NOT NULL DEFAULT now(),
+ finished_at timestamptz,
+ verified_sealed text,
+ verified_proof text,
+ PRIMARY KEY(source_operation_id,source_step_index),
+ CHECK(mode='manual' OR authority_profile_id IS NOT NULL AND authority_profile_version IS NOT NULL),
+ CHECK((state='verified')=(verified_sealed IS NOT NULL AND verified_proof IS NOT NULL))
+);
+COMMIT;
diff --git a/backend/drizzle/0032_flow_write_receipts.sql b/backend/drizzle/0032_flow_write_receipts.sql
new file mode 100644
index 00000000..051a7504
--- /dev/null
+++ b/backend/drizzle/0032_flow_write_receipts.sql
@@ -0,0 +1,10 @@
+-- Immutable commit evidence shared by ingestion and REST/MCP fact rebuild.
+-- No raw flow payload, IP addresses, credentials or notification contents belong here.
+CREATE TABLE IF NOT EXISTS flow_write_receipts (
+ batch_id uuid PRIMARY KEY,
+ kind text NOT NULL CHECK (kind IN ('ingest', 'facts', 'rebuild')),
+ source_proof text NOT NULL CHECK (source_proof ~ '^[a-f0-9]{64}$'),
+ result jsonb NOT NULL CHECK (jsonb_typeof(result) = 'object' AND octet_length(result::text) <= 65536),
+ committed_at timestamptz NOT NULL DEFAULT now()
+);
+-- Receipts are intentionally not pruned: an owned unknown batch may still need them.
diff --git a/backend/drizzle/0033_flow_settings_intents.sql b/backend/drizzle/0033_flow_settings_intents.sql
new file mode 100644
index 00000000..c2bec1b9
--- /dev/null
+++ b/backend/drizzle/0033_flow_settings_intents.sql
@@ -0,0 +1,11 @@
+-- A claim survives unknown results and is never recycled for another attempt.
+CREATE TABLE IF NOT EXISTS flow_settings_intents (
+ receipt_id uuid NOT NULL,
+ phase text NOT NULL CHECK (phase IN ('configuration', 'listener')),
+ request_proof text NOT NULL,
+ state text NOT NULL DEFAULT 'claimed' CHECK (state IN ('claimed', 'completed')),
+ result jsonb,
+ created_at timestamptz NOT NULL DEFAULT now(),
+ PRIMARY KEY (receipt_id, phase)
+);
+INSERT INTO traffic_flow_settings(id) VALUES(1) ON CONFLICT DO NOTHING;
diff --git a/backend/drizzle/0034_vrf_production_tickets.sql b/backend/drizzle/0034_vrf_production_tickets.sql
new file mode 100644
index 00000000..600a9cbe
--- /dev/null
+++ b/backend/drizzle/0034_vrf_production_tickets.sql
@@ -0,0 +1,19 @@
+-- Precondition receipts only. No executor capability is granted by this table.
+CREATE TABLE IF NOT EXISTS vrf_production_tickets (
+ ticket_id uuid PRIMARY KEY,
+ plan_id uuid NOT NULL UNIQUE REFERENCES mcp_plans(id),
+ connection_id uuid NOT NULL REFERENCES mcp_connections(id),
+ server_id bigint NOT NULL REFERENCES servers(id),
+ owner_id text NOT NULL,
+ action_id text NOT NULL CHECK (action_id IN ('ros.vrf.create','ros.vrf.update','ros.vrf.delete')),
+ action_version integer NOT NULL CHECK (action_version > 0),
+ source_proof text NOT NULL CHECK (source_proof ~ '^[a-f0-9]{64}$'),
+ digest text NOT NULL CHECK (digest ~ '^[a-f0-9]{64}$'),
+ ciphertext text NOT NULL,
+ state text NOT NULL DEFAULT 'issued' CHECK (state IN ('issued','claimed')),
+ issued_at timestamptz NOT NULL,
+ expires_at timestamptz NOT NULL,
+ claimed_at timestamptz,
+ CHECK (expires_at > issued_at AND expires_at <= issued_at + interval '5 minutes'),
+ CHECK ((state='issued' AND claimed_at IS NULL) OR (state='claimed' AND claimed_at IS NOT NULL))
+);
diff --git a/backend/drizzle/0035_server_probe_journal.sql b/backend/drizzle/0035_server_probe_journal.sql
new file mode 100644
index 00000000..06ee09de
--- /dev/null
+++ b/backend/drizzle/0035_server_probe_journal.sql
@@ -0,0 +1,67 @@
+-- Durable diagnostic attempts; this migration registers no MCP action.
+BEGIN;
+
+CREATE TABLE server_probe_executions (
+ receipt_id uuid PRIMARY KEY, binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),
+ identity_kind text NOT NULL CHECK(identity_kind IN ('mcp','rest')),
+ execution_id uuid NOT NULL, actor_id text NOT NULL CHECK(length(actor_id) BETWEEN 1 AND 200),
+ authentication text NOT NULL CHECK(authentication IN ('mcp','jwt','local')),
+ mcp_connection_id uuid REFERENCES mcp_connections(id), mcp_credential_id uuid REFERENCES mcp_credentials(id), request_id text,
+ authority_issued_at bigint NOT NULL CHECK(authority_issued_at>=0), authority_expires_at timestamptz NOT NULL,
+ source_server_id integer NOT NULL CHECK(source_server_id>0), destination_server_id integer CHECK(destination_server_id>0),
+ tool text NOT NULL CHECK(tool IN ('ping','traceroute','bandwidth','dns','route','mtu')),
+ state text NOT NULL DEFAULT 'claimed' CHECK(state IN ('claimed','completed','failed','cancelled')),
+ attempted_stages integer CHECK(attempted_stages BETWEEN 0 AND 11), completed_stages integer CHECK(completed_stages BETWEEN 0 AND attempted_stages),
+ receipt_ciphertext text CHECK(octet_length(receipt_ciphertext)<=262144), receipt_proof text CHECK(receipt_proof ~ '^[a-f0-9]{64}$'),
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(), finished_at timestamptz,
+ UNIQUE(identity_kind,execution_id),
+ CHECK((identity_kind='mcp' AND authentication='mcp' AND mcp_connection_id IS NOT NULL AND mcp_credential_id IS NOT NULL AND request_id IS NULL)
+ OR (identity_kind='rest' AND authentication IN ('jwt','local') AND mcp_connection_id IS NULL AND mcp_credential_id IS NULL AND request_id IS NOT NULL AND length(request_id) BETWEEN 1 AND 200)),
+ CHECK((tool='bandwidth')=(destination_server_id IS NOT NULL)),
+ CHECK((state='claimed' AND receipt_ciphertext IS NULL AND receipt_proof IS NULL AND finished_at IS NULL AND attempted_stages IS NULL AND completed_stages IS NULL)
+ OR (state<>'claimed' AND receipt_ciphertext IS NOT NULL AND receipt_proof IS NOT NULL AND finished_at IS NOT NULL AND attempted_stages IS NOT NULL AND completed_stages IS NOT NULL))
+);
+CREATE TABLE server_probe_execution_stages (
+ receipt_id uuid NOT NULL REFERENCES server_probe_executions(receipt_id), stage_index integer NOT NULL CHECK(stage_index BETWEEN 1 AND 11),
+ kind text NOT NULL CHECK(kind IN ('source-dns-A','native-ping','native-traceroute','native-bandwidth','native-route-read',
+ 'manager-dns-A','manager-dns-AAAA','manager-dns-MX','manager-dns-NS','manager-dns-TXT','manager-dns-CNAME','manager-dns-PTR',
+ 'native-mtu-1500','native-mtu-1492','native-mtu-1480','native-mtu-1476','native-mtu-1472','native-mtu-1468','native-mtu-1400','native-mtu-1280','native-mtu-1024','native-mtu-576')),
+ timeout_ms integer NOT NULL CHECK(timeout_ms BETWEEN 1 AND 120000),
+ state text NOT NULL DEFAULT 'intent' CHECK(state IN ('intent','received')),
+ outcome text CHECK(outcome IN ('received','source-unavailable')),
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(), received_at timestamptz,
+ PRIMARY KEY(receipt_id,stage_index),
+ CHECK((state='intent' AND outcome IS NULL AND received_at IS NULL) OR (state='received' AND outcome IS NOT NULL AND received_at IS NOT NULL))
+);
+CREATE TABLE server_probe_execution_quarantines (
+ receipt_id uuid PRIMARY KEY, binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),
+ identity_kind text NOT NULL CHECK(identity_kind IN ('mcp','rest')), execution_id uuid NOT NULL,
+ identity_proof text NOT NULL CHECK(identity_proof ~ '^[a-f0-9]{64}$'),
+ error_code text NOT NULL CHECK(error_code ~ '^[A-Z_]{1,64}$'),
+ attempted_stages integer NOT NULL CHECK(attempted_stages BETWEEN 0 AND 11), completed_stages integer NOT NULL CHECK(completed_stages BETWEEN 0 AND attempted_stages),
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(), UNIQUE(identity_kind,execution_id)
+);
+CREATE FUNCTION server_probe_execution_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' THEN RAISE EXCEPTION 'probe execution journal is append only'; END IF;
+ IF OLD.state<>'claimed' OR (to_jsonb(OLD)-ARRAY['state','attempted_stages','completed_stages','receipt_ciphertext','receipt_proof','finished_at']) IS DISTINCT FROM
+ (to_jsonb(NEW)-ARRAY['state','attempted_stages','completed_stages','receipt_ciphertext','receipt_proof','finished_at']) OR NEW.state='claimed'
+ THEN RAISE EXCEPTION 'probe execution identity or terminal receipt is immutable'; END IF;
+ IF EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=OLD.receipt_id) THEN RAISE EXCEPTION 'probe execution quarantined'; END IF;
+ RETURN NEW; END $$;
+CREATE TRIGGER server_probe_execution_immutable BEFORE UPDATE OR DELETE ON server_probe_executions FOR EACH ROW EXECUTE FUNCTION server_probe_execution_immutable();
+CREATE FUNCTION server_probe_stage_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' THEN RAISE EXCEPTION 'probe stage journal is append only'; END IF;
+ PERFORM receipt_id FROM server_probe_executions WHERE receipt_id=NEW.receipt_id AND state='claimed' FOR UPDATE;
+ IF NOT FOUND OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=NEW.receipt_id) THEN RAISE EXCEPTION 'probe attempt is not executable'; END IF;
+ IF TG_OP='INSERT' AND (NEW.stage_index<>(SELECT COALESCE(max(stage_index),0)+1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id)
+ OR EXISTS(SELECT 1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id AND state<>'received'))
+ THEN RAISE EXCEPTION 'probe stages must be serial and contiguous'; END IF;
+ IF TG_OP='UPDATE' AND (OLD.state<>'intent' OR NEW.state<>'received' OR (to_jsonb(OLD)-ARRAY['state','outcome','received_at']) IS DISTINCT FROM (to_jsonb(NEW)-ARRAY['state','outcome','received_at']))
+ THEN RAISE EXCEPTION 'probe stage terminal state is immutable'; END IF;
+ RETURN NEW; END $$;
+CREATE TRIGGER server_probe_stage_immutable BEFORE INSERT OR UPDATE OR DELETE ON server_probe_execution_stages FOR EACH ROW EXECUTE FUNCTION server_probe_stage_immutable();
+CREATE FUNCTION server_probe_quarantine_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'probe quarantine is immutable'; END $$;
+CREATE TRIGGER server_probe_quarantine_immutable BEFORE UPDATE OR DELETE ON server_probe_execution_quarantines FOR EACH ROW EXECUTE FUNCTION server_probe_quarantine_immutable();
+
+INSERT INTO schema_migrations(id) VALUES ('0035_server_probe_journal') ON CONFLICT (id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0036_diagnostic_cancellations.sql b/backend/drizzle/0036_diagnostic_cancellations.sql
new file mode 100644
index 00000000..3c678241
--- /dev/null
+++ b/backend/drizzle/0036_diagnostic_cancellations.sql
@@ -0,0 +1,14 @@
+-- Durable stop requests for opt-in diagnostics, not configuration rollback.
+BEGIN;
+CREATE TABLE mcp_diagnostic_cancellations (
+ operation_id uuid PRIMARY KEY REFERENCES mcp_operations(id),
+ connection_id uuid NOT NULL REFERENCES mcp_connections(id),
+ actor_id text NOT NULL CHECK (length(actor_id) BETWEEN 1 AND 200),
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp()
+);
+CREATE FUNCTION mcp_diagnostic_cancellation_immutable() RETURNS trigger LANGUAGE plpgsql AS $$
+BEGIN RAISE EXCEPTION 'diagnostic cancellation request is immutable'; END $$;
+CREATE TRIGGER mcp_diagnostic_cancellation_immutable BEFORE UPDATE OR DELETE ON mcp_diagnostic_cancellations
+ FOR EACH ROW EXECUTE FUNCTION mcp_diagnostic_cancellation_immutable();
+INSERT INTO schema_migrations(id) VALUES ('0036_diagnostic_cancellations') ON CONFLICT (id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0037_server_probe_storage_v2.sql b/backend/drizzle/0037_server_probe_storage_v2.sql
new file mode 100644
index 00000000..9c922f78
--- /dev/null
+++ b/backend/drizzle/0037_server_probe_storage_v2.sql
@@ -0,0 +1,226 @@
+-- Fresh-only enrollment of empty diagnostic tables. No historical backfill,
+-- source-generation claim, public registration or automatic cleanup is granted.
+BEGIN;
+LOCK TABLE server_probe_executions,server_probe_execution_stages,server_probe_execution_quarantines,mcp_diagnostic_cancellations IN ACCESS EXCLUSIVE MODE;
+DO $$ BEGIN
+ IF EXISTS(SELECT 1 FROM server_probe_executions)
+ OR EXISTS(SELECT 1 FROM server_probe_execution_stages)
+ OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines)
+ OR EXISTS(SELECT 1 FROM mcp_diagnostic_cancellations)
+ THEN RAISE EXCEPTION 'nonempty legacy diagnostic history prevents fresh storage enrollment'; END IF;
+ IF EXISTS(SELECT 1 FROM pg_catalog.pg_class WHERE relname IN
+ ('server_probe_storage_usage','server_probe_storage_admissions','server_probe_execution_payloads'))
+ THEN RAISE EXCEPTION 'unmarked diagnostic storage relation prevents fresh storage enrollment'; END IF;
+ IF NOT EXISTS(SELECT 1 FROM mcp_settings WHERE id=1 AND requests_retention_days BETWEEN 1 AND 365)
+ THEN RAISE EXCEPTION 'authoritative probe retention setting unavailable'; END IF;
+END $$;
+
+CREATE TABLE server_probe_storage_usage (
+ scope text PRIMARY KEY CHECK(scope='global' OR (scope LIKE 'owner:%' AND length(scope) BETWEEN 7 AND 206)),
+ admissions bigint NOT NULL DEFAULT 0 CHECK(admissions>=0),
+ reserved_files bigint NOT NULL DEFAULT 0 CHECK(reserved_files>=0 AND reserved_files<=admissions),
+ reserved_bytes bigint NOT NULL DEFAULT 0 CHECK(reserved_bytes>=0),
+ CHECK(reserved_bytes=admissions*32768+reserved_files*262144)
+);
+CREATE TABLE server_probe_storage_admissions (
+ receipt_id uuid PRIMARY KEY,
+ owner_id text NOT NULL CHECK(length(owner_id) BETWEEN 1 AND 200),
+ identity_kind text NOT NULL CHECK(identity_kind IN ('mcp','rest')), execution_id uuid NOT NULL,
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),
+ authority_expires_at timestamptz NOT NULL,
+ claim_token uuid, claim_attempted_at timestamptz,
+ purged_at timestamptz, cancelled_at timestamptz, created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
+ retention_days integer NOT NULL CHECK(retention_days BETWEEN 1 AND 365),
+ safety_ms integer NOT NULL DEFAULT 60000 CHECK(safety_ms BETWEEN 60000 AND 86400000),
+ gc_not_before timestamptz NOT NULL DEFAULT 'infinity',
+ CHECK(gc_not_before>=authority_expires_at+make_interval(days=>retention_days)+safety_ms*interval '1 millisecond'),
+ UNIQUE(identity_kind,execution_id),
+ CHECK(claim_token IS NULL OR (claim_attempted_at IS NULL AND purged_at IS NULL AND cancelled_at IS NULL)),
+ CHECK(cancelled_at IS NULL OR (claim_token IS NULL AND claim_attempted_at IS NOT NULL))
+);
+CREATE INDEX server_probe_storage_admissions_owner_age ON server_probe_storage_admissions(owner_id,authority_expires_at,receipt_id);
+CREATE TABLE server_probe_execution_payloads (
+ receipt_id uuid PRIMARY KEY REFERENCES server_probe_executions(receipt_id),
+ receipt_ciphertext text NOT NULL CHECK(octet_length(receipt_ciphertext) BETWEEN 1 AND 262144),
+ receipt_proof text NOT NULL CHECK(receipt_proof ~ '^[a-f0-9]{64}$')
+);
+INSERT INTO server_probe_storage_usage(scope,admissions,reserved_files,reserved_bytes) VALUES('global',0,0,0);
+
+-- PostgreSQL drops table CHECKs dependent on this column together with it.
+-- The locked empty-table guard precedes this column removal; no data is copied.
+ALTER TABLE server_probe_executions DROP COLUMN receipt_ciphertext;
+ALTER TABLE server_probe_executions ADD CONSTRAINT server_probe_storage_terminal_state CHECK(
+ (state='claimed' AND receipt_proof IS NULL AND finished_at IS NULL AND attempted_stages IS NULL AND completed_stages IS NULL)
+ OR(state<>'claimed' AND receipt_proof IS NOT NULL AND finished_at IS NOT NULL AND attempted_stages IS NOT NULL AND completed_stages IS NOT NULL));
+
+-- Predicate only: it performs no DELETE. Every guarded exception below must
+-- independently satisfy the persisted lifetime, actual current retention and
+-- original terminal operation. The GUC alone never grants cleanup authority.
+CREATE FUNCTION server_probe_storage_gc_allowed(id uuid) RETURNS boolean LANGUAGE plpgsql SET TimeZone='UTC' AS $$
+DECLARE a server_probe_storage_admissions%ROWTYPE; activity timestamptz; current_retention integer; terminal_at timestamptz;
+BEGIN
+ IF current_setting('mm.probe_storage_gc',true) IS DISTINCT FROM 'on' THEN RETURN false; END IF;
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));
+ SELECT * INTO a FROM server_probe_storage_admissions WHERE receipt_id=id FOR UPDATE;
+ IF NOT FOUND OR a.gc_not_before>=clock_timestamp() OR a.authority_expires_at>=clock_timestamp() THEN RETURN false; END IF;
+ SELECT settings.requests_retention_days INTO current_retention FROM mcp_settings settings WHERE settings.id=1;
+ IF current_retention IS NULL OR current_retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;
+ terminal_at:=a.created_at;
+ IF a.identity_kind='mcp' THEN
+ SELECT GREATEST(o.finished_at,p.expires_at,COALESCE(cancellation.created_at,o.finished_at)) INTO terminal_at
+ FROM mcp_operations o JOIN mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN mcp_connections owner_connection ON owner_connection.id=o.connection_id
+ LEFT JOIN mcp_diagnostic_cancellations cancellation ON cancellation.operation_id=o.id
+ WHERE o.id=a.execution_id AND owner_connection.owner_id=a.owner_id AND p.operation_id='servers.probes.run'
+ AND o.state IN ('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL
+ AND (cancellation.operation_id IS NULL OR(cancellation.connection_id=o.connection_id AND cancellation.actor_id=a.owner_id))
+ FOR UPDATE OF o,p,owner_connection;
+ IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;
+ END IF;
+ SELECT GREATEST(a.created_at,a.authority_expires_at,terminal_at,COALESCE(a.cancelled_at,a.created_at),
+ COALESCE((SELECT finished_at FROM server_probe_executions WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM server_probe_execution_quarantines WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(GREATEST(created_at,COALESCE(received_at,created_at))) FROM server_probe_execution_stages WHERE receipt_id=id),a.created_at)) INTO activity;
+ RETURN activity+make_interval(days=>GREATEST(a.retention_days,current_retention))+a.safety_ms*interval '1 millisecond'clock_timestamp()
+ THEN RETURN NEW; END IF;
+ IF OLD.purged_at IS NULL AND NEW.purged_at IS NOT NULL AND NEW.claim_token IS NULL
+ AND NEW.claim_attempted_at IS NOT DISTINCT FROM OLD.claim_attempted_at THEN
+ SELECT GREATEST(OLD.authority_expires_at,COALESCE(e.finished_at,OLD.authority_expires_at),COALESCE(q.created_at,OLD.authority_expires_at)) INTO activity
+ FROM (SELECT 1) x LEFT JOIN server_probe_executions e ON e.receipt_id=OLD.receipt_id
+ LEFT JOIN server_probe_execution_quarantines q ON q.receipt_id=OLD.receipt_id;
+ IF activityGREATEST(OLD.retention_days,current_retention)) THEN RETURN NEW; END IF;
+ END IF;
+ RAISE EXCEPTION 'probe admission transition refused';
+END $$;
+CREATE TRIGGER server_probe_storage_admission_guard BEFORE INSERT OR UPDATE OR DELETE ON server_probe_storage_admissions
+ FOR EACH ROW EXECUTE FUNCTION server_probe_storage_admission_guard();
+
+CREATE FUNCTION server_probe_storage_anchor_guard() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE a server_probe_storage_admissions%ROWTYPE;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));
+ SELECT * INTO a FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;
+ IF NOT FOUND OR a.owner_id<>NEW.actor_id OR a.identity_kind<>NEW.identity_kind OR a.execution_id<>NEW.execution_id
+ OR a.binding_proof<>NEW.binding_proof OR a.authority_expires_at<>NEW.authority_expires_at
+ OR a.purged_at IS NOT NULL OR a.cancelled_at IS NOT NULL OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()
+ THEN RAISE EXCEPTION 'probe anchor has no live consumed admission'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_probe_storage_anchor_guard BEFORE INSERT OR UPDATE ON server_probe_executions
+ FOR EACH ROW EXECUTE FUNCTION server_probe_storage_anchor_guard();
+
+CREATE OR REPLACE FUNCTION server_probe_execution_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' THEN
+ IF server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'probe execution lifetime has not elapsed';
+ END IF;
+ IF OLD.state<>'claimed' OR (to_jsonb(OLD)-ARRAY['state','attempted_stages','completed_stages','receipt_proof','finished_at']) IS DISTINCT FROM
+ (to_jsonb(NEW)-ARRAY['state','attempted_stages','completed_stages','receipt_proof','finished_at']) OR NEW.state='claimed'
+ THEN RAISE EXCEPTION 'probe execution identity or terminal receipt is immutable'; END IF;
+ IF EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=OLD.receipt_id)
+ THEN RAISE EXCEPTION 'probe execution quarantined'; END IF;
+ RETURN NEW; END $$;
+
+CREATE FUNCTION server_probe_storage_stage_guard() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));
+ PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id AND purged_at IS NULL AND cancelled_at IS NULL
+ AND claim_token IS NULL AND claim_attempted_at IS NOT NULL AND authority_expires_at>clock_timestamp() FOR UPDATE;
+ IF NOT FOUND THEN RAISE EXCEPTION 'probe stage has no live admission'; END IF;
+ RETURN NEW; END $$;
+CREATE TRIGGER server_probe_storage_stage_guard BEFORE INSERT OR UPDATE ON server_probe_execution_stages
+ FOR EACH ROW EXECUTE FUNCTION server_probe_storage_stage_guard();
+
+CREATE FUNCTION server_probe_storage_quarantine_guard() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));
+ PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id AND identity_kind=NEW.identity_kind
+ AND execution_id=NEW.execution_id AND binding_proof=NEW.binding_proof FOR UPDATE;
+ IF NOT FOUND THEN RAISE EXCEPTION 'probe quarantine has no committed matching admission'; END IF;
+ RETURN NEW; END $$;
+CREATE TRIGGER server_probe_storage_quarantine_guard BEFORE INSERT ON server_probe_execution_quarantines
+ FOR EACH ROW EXECUTE FUNCTION server_probe_storage_quarantine_guard();
+
+CREATE FUNCTION server_probe_storage_payload_guard() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE a server_probe_storage_admissions%ROWTYPE; e server_probe_executions%ROWTYPE;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));
+ IF TG_OP='UPDATE' THEN RAISE EXCEPTION 'probe payload is immutable'; END IF;
+ IF TG_OP='DELETE' THEN
+ PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=OLD.receipt_id AND purged_at IS NOT NULL FOR UPDATE;
+ IF NOT FOUND AND NOT server_probe_storage_gc_allowed(OLD.receipt_id) THEN RAISE EXCEPTION 'probe payload is not purged'; END IF;
+ RETURN OLD;
+ END IF;
+ SELECT * INTO a FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;
+ IF NOT FOUND OR a.purged_at IS NOT NULL OR a.cancelled_at IS NOT NULL OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()
+ THEN RAISE EXCEPTION 'probe payload has no live admission'; END IF;
+ SELECT * INTO e FROM server_probe_executions WHERE receipt_id=NEW.receipt_id FOR UPDATE;
+ IF NOT FOUND OR e.state='claimed' OR e.receipt_proof<>NEW.receipt_proof OR e.actor_id<>a.owner_id OR e.binding_proof<>a.binding_proof
+ OR e.identity_kind<>a.identity_kind OR e.execution_id<>a.execution_id OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines q
+ WHERE q.receipt_id=NEW.receipt_id OR(q.identity_kind=a.identity_kind AND q.execution_id=a.execution_id))
+ THEN RAISE EXCEPTION 'probe payload terminal identity mismatch or quarantine'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_probe_storage_payload_guard BEFORE INSERT OR UPDATE OR DELETE ON server_probe_execution_payloads
+ FOR EACH ROW EXECUTE FUNCTION server_probe_storage_payload_guard();
+-- Preserve every original INSERT/UPDATE rule; only the already-validated
+-- lifetime predicate can admit DELETE; no cleanup is scheduled by migration.
+CREATE OR REPLACE FUNCTION server_probe_stage_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' THEN
+ IF server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'probe stage lifetime has not elapsed';
+ END IF;
+ PERFORM receipt_id FROM server_probe_executions WHERE receipt_id=NEW.receipt_id AND state='claimed' FOR UPDATE;
+ IF NOT FOUND OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=NEW.receipt_id) THEN RAISE EXCEPTION 'probe attempt is not executable'; END IF;
+ IF TG_OP='INSERT' AND (NEW.stage_index<>(SELECT COALESCE(max(stage_index),0)+1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id)
+ OR EXISTS(SELECT 1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id AND state<>'received'))
+ THEN RAISE EXCEPTION 'probe stages must be serial and contiguous'; END IF;
+ IF TG_OP='UPDATE' AND (OLD.state<>'intent' OR NEW.state<>'received' OR (to_jsonb(OLD)-ARRAY['state','outcome','received_at']) IS DISTINCT FROM (to_jsonb(NEW)-ARRAY['state','outcome','received_at']))
+ THEN RAISE EXCEPTION 'probe stage terminal state is immutable'; END IF;
+ RETURN NEW; END $$;
+CREATE OR REPLACE FUNCTION server_probe_quarantine_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' AND server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'probe quarantine remains immutable'; END $$;
+CREATE OR REPLACE FUNCTION mcp_diagnostic_cancellation_immutable() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE original_receipt uuid;
+BEGIN
+ IF TG_OP='DELETE' THEN
+ SELECT a.receipt_id INTO original_receipt FROM server_probe_storage_admissions a
+ JOIN mcp_operations o ON o.id=a.execution_id AND o.connection_id=OLD.connection_id
+ WHERE a.identity_kind='mcp' AND a.execution_id=OLD.operation_id AND a.owner_id=OLD.actor_id;
+ IF FOUND AND server_probe_storage_gc_allowed(original_receipt) THEN RETURN OLD; END IF;
+ END IF;
+ RAISE EXCEPTION 'diagnostic cancellation lifetime has not elapsed';
+END $$;
+INSERT INTO schema_migrations(id) VALUES ('0037_server_probe_storage_v2') ON CONFLICT (id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0038_server_poll_journal_and_writer_guards.sql b/backend/drizzle/0038_server_poll_journal_and_writer_guards.sql
new file mode 100644
index 00000000..0f072ccb
--- /dev/null
+++ b/backend/drizzle/0038_server_poll_journal_and_writer_guards.sql
@@ -0,0 +1,59 @@
+-- Initial poll journal and adopted partition-writer backstop.
+-- Mixed old replicas MUST be drained before activation: triggers alone run
+-- after relation access and cannot replace pre-DML shared writer admission.
+BEGIN;
+DO $$ BEGIN
+ PERFORM pg_catalog.pg_advisory_xact_lock(8723110::bigint);
+ IF EXISTS(SELECT 1 FROM pg_catalog.pg_class WHERE relname=ANY(ARRAY['server_poll_executions','server_poll_intents','server_poll_acks','server_poll_receipts','server_poll_quarantines']))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_proc WHERE proname=ANY(ARRAY['server_poll_journal_immutable','server_partition_writer_guard']))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_trigger WHERE tgname='server_partition_writer_guard')
+ THEN RAISE EXCEPTION 'unmarked poll journal or partition guard requires explicit reconciliation'; END IF;
+END $$;
+CREATE TABLE server_poll_executions (
+ receipt_id uuid PRIMARY KEY,identity_kind text NOT NULL CHECK(identity_kind IN ('mcp','rest')),execution_id uuid NOT NULL,
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),context_ciphertext text NOT NULL CHECK(octet_length(context_ciphertext)<=2097152),
+ context_proof text NOT NULL CHECK(context_proof ~ '^[a-f0-9]{64}$'),created_at timestamptz NOT NULL DEFAULT clock_timestamp(),UNIQUE(identity_kind,execution_id));
+CREATE TABLE server_poll_intents (
+ receipt_id uuid REFERENCES server_poll_executions(receipt_id),stage text NOT NULL CHECK(stage ~ '^(native\.(identity|resource|interfaces|addresses)|publish\.[0-9]{1,4})$'),
+ before_proof text NOT NULL CHECK(before_proof ~ '^[a-f0-9]{64}$'),effect_proof text NOT NULL CHECK(effect_proof ~ '^[a-f0-9]{64}$'),
+ intent_proof text NOT NULL CHECK(intent_proof ~ '^[a-f0-9]{64}$'),created_at timestamptz NOT NULL DEFAULT clock_timestamp(),PRIMARY KEY(receipt_id,stage));
+CREATE TABLE server_poll_acks (
+ receipt_id uuid NOT NULL,stage text NOT NULL,result_proof text NOT NULL CHECK(result_proof ~ '^[a-f0-9]{64}$'),outcome text NOT NULL CHECK(outcome IN ('confirmed','read-failed')),
+ ack_proof text NOT NULL CHECK(ack_proof ~ '^[a-f0-9]{64}$'),created_at timestamptz NOT NULL DEFAULT clock_timestamp(),PRIMARY KEY(receipt_id,stage),FOREIGN KEY(receipt_id,stage) REFERENCES server_poll_intents(receipt_id,stage),CHECK(stage LIKE 'native.%' OR outcome='confirmed'));
+CREATE TABLE server_poll_receipts (
+ receipt_id uuid PRIMARY KEY REFERENCES server_poll_executions(receipt_id),receipt_ciphertext text NOT NULL CHECK(octet_length(receipt_ciphertext)<=262144),receipt_proof text NOT NULL CHECK(receipt_proof ~ '^[a-f0-9]{64}$'),created_at timestamptz NOT NULL DEFAULT clock_timestamp());
+CREATE TABLE server_poll_quarantines (
+ receipt_id uuid PRIMARY KEY,identity_kind text NOT NULL CHECK(identity_kind IN ('mcp','rest')),execution_id uuid NOT NULL,context_proof text NOT NULL CHECK(context_proof ~ '^[a-f0-9]{64}$'),created_at timestamptz NOT NULL DEFAULT clock_timestamp(),UNIQUE(identity_kind,execution_id));
+CREATE FUNCTION server_poll_journal_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'server poll journal is append only'; END $$;
+CREATE TRIGGER server_poll_execution_immutable BEFORE UPDATE OR DELETE ON server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable();
+CREATE TRIGGER server_poll_intent_immutable BEFORE UPDATE OR DELETE ON server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable();
+CREATE TRIGGER server_poll_ack_immutable BEFORE UPDATE OR DELETE ON server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable();
+CREATE TRIGGER server_poll_receipt_immutable BEFORE UPDATE OR DELETE ON server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable();
+CREATE TRIGGER server_poll_quarantine_immutable BEFORE UPDATE OR DELETE ON server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable();
+CREATE FUNCTION public.server_partition_writer_guard() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN PERFORM pg_advisory_xact_lock_shared(8723110::bigint); IF TG_OP='DELETE' THEN RETURN OLD; END IF; RETURN NEW; END; $$;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_buckets" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_buckets" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_minute_stats" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_minute_stats" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_minute_dims" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_minute_dims" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_daily_dims" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_daily_dims" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_hour_facts" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_hour_facts" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."flow_daily_facts" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."flow_daily_facts" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."traffic_samples" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."traffic_samples" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."servers_rest_ping_samples" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."servers_rest_ping_samples" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."uptime_probe_samples" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."uptime_probe_samples" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."uptime_resource_samples" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."uptime_resource_samples" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."server_snapshots" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."server_snapshots" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR UPDATE OR DELETE ON public."internet_path_snapshots" FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public."internet_path_snapshots" ENABLE ALWAYS TRIGGER server_partition_writer_guard;
+INSERT INTO schema_migrations(id) VALUES ('0038_server_poll_journal_and_writer_guards') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0039_server_poll_storage.sql b/backend/drizzle/0039_server_poll_storage.sql
new file mode 100644
index 00000000..1a9e66bd
--- /dev/null
+++ b/backend/drizzle/0039_server_poll_storage.sql
@@ -0,0 +1,175 @@
+-- Fresh-only enrollment of the reviewed bounded poll journal. No historical backfill.
+-- Fixed logical quota; physical heap/index/WAL and vacuum remain independent.
+-- Requires the empty 0038 poll journal. No scheduling or public activation.
+BEGIN;
+LOCK TABLE server_poll_executions,server_poll_intents,server_poll_acks,server_poll_receipts,server_poll_quarantines IN ACCESS EXCLUSIVE MODE;
+DO $$ BEGIN
+ IF EXISTS(SELECT 1 FROM server_poll_executions) OR EXISTS(SELECT 1 FROM server_poll_intents)
+ OR EXISTS(SELECT 1 FROM server_poll_acks) OR EXISTS(SELECT 1 FROM server_poll_receipts)
+ OR EXISTS(SELECT 1 FROM server_poll_quarantines)
+ THEN RAISE EXCEPTION 'nonempty poll journal needs explicit reconciliation'; END IF;
+ IF NOT EXISTS(SELECT 1 FROM mcp_settings WHERE id=1 AND requests_retention_days BETWEEN 1 AND 365)
+ THEN RAISE EXCEPTION 'poll retention unavailable'; END IF;
+ IF EXISTS(SELECT 1 FROM pg_catalog.pg_class WHERE relname IN('server_poll_storage_usage','server_poll_storage_admissions'))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_proc WHERE proname IN('server_poll_storage_gc_allowed','server_poll_storage_admission_guard','server_poll_storage_row_guard','server_poll_storage_row_meter'))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_trigger WHERE tgname LIKE 'server_poll_storage_%')
+ THEN RAISE EXCEPTION 'unmarked poll storage requires explicit reconciliation'; END IF;
+END $$;
+CREATE TABLE server_poll_storage_usage (
+ scope text PRIMARY KEY CHECK(scope='global' OR(scope LIKE 'owner:%' AND length(scope) BETWEEN 7 AND 206)),
+ admissions bigint NOT NULL DEFAULT 0 CHECK(admissions>=0 AND admissions<=128),
+ reserved_rows bigint NOT NULL DEFAULT 0 CHECK(reserved_rows=admissions*4019),
+ reserved_bytes bigint NOT NULL DEFAULT 0 CHECK(reserved_bytes=admissions*8421376),
+ CHECK(scope='global' OR admissions<=8)
+);
+CREATE TABLE server_poll_storage_admissions (
+ receipt_id uuid PRIMARY KEY, identity_kind text NOT NULL CHECK(identity_kind IN('mcp','rest')),
+ execution_id uuid NOT NULL, connection_id uuid, owner_id text NOT NULL CHECK(length(owner_id) BETWEEN 1 AND 200 AND btrim(owner_id)=owner_id AND owner_id !~ '[[:cntrl:]]'),
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'), context_proof text NOT NULL CHECK(context_proof ~ '^[a-f0-9]{64}$'),
+ authority_issued_at timestamptz NOT NULL CHECK(isfinite(authority_issued_at)),
+ authority_expires_at timestamptz NOT NULL CHECK(isfinite(authority_expires_at) AND authority_expires_at>authority_issued_at),
+ max_stages integer NOT NULL CHECK(max_stages BETWEEN 8 AND 2008),
+ claim_token uuid, claim_attempted_at timestamptz, created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
+ retention_days integer NOT NULL CHECK(retention_days BETWEEN 1 AND 365),
+ safety_ms integer NOT NULL DEFAULT 60000 CHECK(safety_ms=60000),
+ gc_not_before timestamptz NOT NULL CHECK(isfinite(gc_not_before)),
+ used_rows integer NOT NULL DEFAULT 0 CHECK(used_rows BETWEEN 0 AND 4019 AND used_rows<=max_stages*2+3),
+ used_bytes bigint NOT NULL DEFAULT 0 CHECK(used_bytes BETWEEN 0 AND 8388608),
+ UNIQUE(identity_kind,execution_id),
+ CHECK((identity_kind='mcp' AND connection_id IS NOT NULL) OR(identity_kind='rest' AND connection_id IS NULL)),
+ CHECK((claim_token IS NOT NULL AND claim_attempted_at IS NULL) OR(claim_token IS NULL AND claim_attempted_at IS NOT NULL)),
+ CHECK(gc_not_before>=authority_expires_at+make_interval(days=>retention_days)+interval '60 seconds')
+);
+CREATE INDEX server_poll_storage_expiry ON server_poll_storage_admissions(gc_not_before,receipt_id);
+INSERT INTO server_poll_storage_usage(scope) VALUES('global');
+
+-- Every guard is installed in this same empty-enrollment transaction;
+-- no historical admission or journal identity is inferred or imported.
+CREATE FUNCTION server_poll_storage_gc_allowed(id uuid) RETURNS boolean LANGUAGE plpgsql SET TimeZone='UTC' AS $$
+DECLARE a server_poll_storage_admissions%ROWTYPE; retention integer; activity timestamptz; terminal_at timestamptz;
+BEGIN
+ IF current_setting('mm.poll_storage_gc',true) IS DISTINCT FROM 'on' THEN RETURN false; END IF;
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ SELECT * INTO a FROM server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;
+ IF NOT FOUND OR a.authority_expires_at>=clock_timestamp() OR a.gc_not_before>=clock_timestamp() THEN RETURN false; END IF;
+ SELECT requests_retention_days INTO retention FROM mcp_settings WHERE mcp_settings.id=1 FOR SHARE;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;
+ terminal_at:=a.created_at;
+ IF a.identity_kind='mcp' THEN
+ SELECT GREATEST(o.finished_at,p.expires_at) INTO terminal_at FROM mcp_operations o
+ JOIN mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN mcp_connections c ON c.id=o.connection_id
+ WHERE o.id=a.execution_id AND o.connection_id=a.connection_id AND c.owner_id=a.owner_id AND p.operation_id='servers.poll'
+ AND o.state IN('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL
+ FOR UPDATE OF o,p,c;
+ IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;
+ END IF;
+ SELECT GREATEST(a.authority_expires_at,a.created_at,COALESCE(a.claim_attempted_at,a.created_at),terminal_at,
+ COALESCE((SELECT created_at FROM server_poll_executions WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM server_poll_intents WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM server_poll_acks WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM server_poll_receipts WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM server_poll_quarantines WHERE receipt_id=id),a.created_at)) INTO activity;
+ RETURN activity+make_interval(days=>GREATEST(a.retention_days,retention))+a.safety_ms*interval '1 millisecond'=1 AND reserved_rows>=4019 AND reserved_bytes>=8421376;
+ GET DIAGNOSTICS charged=ROW_COUNT;
+ IF charged<>2 THEN RAISE EXCEPTION 'poll quota refund mismatch'; END IF;
+ RETURN OLD;
+ END IF;
+ IF TG_OP='UPDATE' THEN
+ IF(to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes']) IS DISTINCT FROM
+ (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes']) THEN RAISE EXCEPTION 'poll admission identity is immutable'; END IF;
+ IF OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL
+ AND NEW.used_rows=OLD.used_rows AND NEW.used_bytes=OLD.used_bytes AND OLD.authority_expires_at>clock_timestamp()
+ THEN NEW.claim_attempted_at:=clock_timestamp(); RETURN NEW; END IF;
+ IF OLD.claim_token IS NOT DISTINCT FROM NEW.claim_token AND OLD.claim_attempted_at IS NOT DISTINCT FROM NEW.claim_attempted_at
+ AND NEW.used_rows=OLD.used_rows+1 AND NEW.used_bytes>OLD.used_bytes THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'poll admission cannot refresh, reopen or refund itself';
+ END IF;
+ SELECT requests_retention_days INTO retention FROM mcp_settings WHERE id=1;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 OR NEW.authority_issued_at>clock_timestamp()
+ OR NEW.authority_expires_at<=clock_timestamp() OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL
+ OR NEW.used_rows<>0 OR NEW.used_bytes<>0
+ THEN RAISE EXCEPTION 'new poll admission needs original live authority'; END IF;
+ IF EXISTS(SELECT 1 FROM server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id OR(identity_kind=NEW.identity_kind AND execution_id=NEW.execution_id))
+ THEN RAISE EXCEPTION 'poll identity already spent'; END IF;
+ NEW.created_at:=clock_timestamp(); NEW.retention_days:=retention; NEW.safety_ms:=60000;
+ NEW.gc_not_before:=NEW.authority_expires_at+make_interval(days=>retention)+interval '60 seconds';
+ INSERT INTO server_poll_storage_usage(scope) VALUES('owner:'||NEW.owner_id) ON CONFLICT DO NOTHING;
+ IF(SELECT count(*) FROM server_poll_storage_usage WHERE scope IN('global','owner:'||NEW.owner_id)
+ AND admissions2 THEN RAISE EXCEPTION 'poll admission quota exhausted'; END IF;
+ UPDATE server_poll_storage_usage SET admissions=admissions+1,reserved_rows=reserved_rows+4019,reserved_bytes=reserved_bytes+8421376
+ WHERE scope IN('global','owner:'||NEW.owner_id);
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll admission quota unavailable'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_poll_storage_admission_guard BEFORE INSERT OR UPDATE OR DELETE ON server_poll_storage_admissions
+ FOR EACH ROW EXECUTE FUNCTION server_poll_storage_admission_guard();
+
+CREATE FUNCTION server_poll_storage_row_guard() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE a server_poll_storage_admissions%ROWTYPE; n integer;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ SELECT * INTO a FROM server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;
+ IF NOT FOUND THEN RAISE EXCEPTION 'poll journal needs a committed admission'; END IF;
+ IF TG_TABLE_NAME='server_poll_quarantines' THEN
+ IF NEW.identity_kind<>a.identity_kind OR NEW.execution_id<>a.execution_id OR NEW.context_proof<>a.context_proof
+ THEN RAISE EXCEPTION 'poll quarantine admission mismatch'; END IF;
+ ELSE
+ IF a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()
+ THEN RAISE EXCEPTION 'poll admission is not consumed and live'; END IF;
+ END IF;
+ IF TG_TABLE_NAME='server_poll_executions' THEN
+ IF NEW.identity_kind<>a.identity_kind OR NEW.execution_id<>a.execution_id OR NEW.context_proof<>a.context_proof OR NEW.binding_proof<>a.binding_proof
+ THEN RAISE EXCEPTION 'poll anchor admission mismatch'; END IF;
+ ELSIF TG_TABLE_NAME IN('server_poll_intents','server_poll_acks') THEN
+ IF NEW.stage LIKE 'publish.%' AND substring(NEW.stage FROM 9)::integer>=a.max_stages-4 THEN RAISE EXCEPTION 'poll stage exceeds private reservation'; END IF;
+ IF TG_TABLE_NAME='server_poll_intents' THEN SELECT count(*) INTO n FROM server_poll_intents WHERE receipt_id=NEW.receipt_id;
+ ELSE SELECT count(*) INTO n FROM server_poll_acks WHERE receipt_id=NEW.receipt_id; END IF;
+ IF n>=a.max_stages THEN RAISE EXCEPTION 'poll stage row budget exhausted'; END IF;
+ END IF;
+ IF TG_TABLE_NAME<>'server_poll_quarantines' AND EXISTS(SELECT 1 FROM server_poll_quarantines WHERE receipt_id=NEW.receipt_id)
+ THEN RAISE EXCEPTION 'poll identity quarantined'; END IF;
+ NEW.created_at:=clock_timestamp();
+ RETURN NEW;
+END $$;
+-- Meter actual inserts, not BEFORE attempts: ON CONFLICT DO NOTHING must not
+-- spend another row/byte allowance for a marker which was never inserted.
+CREATE FUNCTION server_poll_storage_row_meter() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE cost bigint; n integer;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ cost:=pg_column_size(NEW);
+ UPDATE server_poll_storage_admissions SET used_rows=used_rows+1,used_bytes=used_bytes+cost
+ WHERE receipt_id=NEW.receipt_id AND used_rows1 THEN RAISE EXCEPTION 'poll journal byte or row budget exhausted'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_poll_storage_anchor_guard BEFORE INSERT ON server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard();
+CREATE TRIGGER server_poll_storage_intent_guard BEFORE INSERT ON server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard();
+CREATE TRIGGER server_poll_storage_ack_guard BEFORE INSERT ON server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard();
+CREATE TRIGGER server_poll_storage_receipt_guard BEFORE INSERT ON server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard();
+CREATE TRIGGER server_poll_storage_quarantine_guard BEFORE INSERT ON server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard();
+CREATE TRIGGER server_poll_storage_anchor_meter AFTER INSERT ON server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter();
+CREATE TRIGGER server_poll_storage_intent_meter AFTER INSERT ON server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter();
+CREATE TRIGGER server_poll_storage_ack_meter AFTER INSERT ON server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter();
+CREATE TRIGGER server_poll_storage_receipt_meter AFTER INSERT ON server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter();
+CREATE TRIGGER server_poll_storage_quarantine_meter AFTER INSERT ON server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter();
+CREATE OR REPLACE FUNCTION server_poll_journal_immutable() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN
+ IF TG_OP='DELETE' AND server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'server poll journal is immutable before its full lifetime elapses';
+END $$;
+INSERT INTO schema_migrations(id) VALUES ('0039_server_poll_storage') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0040_mcp_routing_reservations.sql b/backend/drizzle/0040_mcp_routing_reservations.sql
new file mode 100644
index 00000000..94cffba5
--- /dev/null
+++ b/backend/drizzle/0040_mcp_routing_reservations.sql
@@ -0,0 +1,56 @@
+-- Additive, inactive reserved recovery ledger. Existing manual evidence is retained.
+-- Legacy reserved rows cannot prove an original two-write debit: never backfill them.
+BEGIN;
+LOCK TABLE public.mcp_scoped_recovery_intents IN ACCESS EXCLUSIVE MODE;
+DO $$ BEGIN
+ IF EXISTS(SELECT 1 FROM public.mcp_scoped_recovery_intents WHERE mode='reserved')
+ THEN RAISE EXCEPTION 'legacy reserved recovery needs explicit reconciliation'; END IF;
+ IF EXISTS(SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+ WHERE n.nspname='public' AND c.relname IN('mcp_routing_reservations','mcp_routing_reservation_slots','mcp_routing_reservation_slots_window'))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_attribute a WHERE a.attrelid='public.mcp_scoped_recovery_intents'::regclass
+ AND NOT a.attisdropped AND a.attname IN('reservation_id','slot_phase','inverse_intent_sealed','inverse_intent_proof','inverse_configuration_sealed','inverse_configuration_proof'))
+ OR EXISTS(SELECT 1 FROM pg_catalog.pg_constraint c WHERE c.conrelid='public.mcp_scoped_recovery_intents'::regclass
+ AND c.conname IN('scoped_reservation_slot_shape','reserved_inverse_evidence_pairs'))
+ THEN RAISE EXCEPTION 'unmarked routing reservation objects need explicit reconciliation'; END IF;
+END $$;
+CREATE TABLE public.mcp_routing_reservations (
+ id uuid PRIMARY KEY,
+ source_plan_id uuid NOT NULL REFERENCES public.mcp_plans(id),
+ source_operation_id uuid NOT NULL REFERENCES public.mcp_operations(id),
+ source_step_index integer NOT NULL CHECK(source_step_index=0),
+ profile_id uuid NOT NULL REFERENCES public.mcp_routing_profiles(id),
+ connection_id uuid NOT NULL REFERENCES public.mcp_connections(id),
+ binding_sealed text NOT NULL,binding_proof text NOT NULL,
+ state_sealed text NOT NULL,state_proof text NOT NULL,revision integer NOT NULL CHECK(revision>=1),
+ deadline timestamptz NOT NULL,created_at timestamptz NOT NULL DEFAULT now(),
+ UNIQUE(source_operation_id,source_step_index)
+);
+CREATE TABLE public.mcp_routing_reservation_slots (
+ reservation_id uuid NOT NULL REFERENCES public.mcp_routing_reservations(id),
+ profile_id uuid NOT NULL REFERENCES public.mcp_routing_profiles(id),
+ lane text NOT NULL CHECK(lane IN ('forward','inverse')),
+ state text NOT NULL CHECK(state IN ('held','spent','proven-unused','unknown')),
+ created_at timestamptz NOT NULL DEFAULT now(),PRIMARY KEY(reservation_id,lane)
+);
+CREATE INDEX mcp_routing_reservation_slots_window ON public.mcp_routing_reservation_slots(profile_id,created_at);
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN reservation_id uuid REFERENCES public.mcp_routing_reservations(id);
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN slot_phase text NOT NULL DEFAULT 'recovery-intent';
+ALTER TABLE public.mcp_scoped_recovery_intents ALTER COLUMN source_configuration_proof DROP NOT NULL;
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN inverse_intent_sealed text;
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN inverse_intent_proof text;
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN inverse_configuration_sealed text;
+ALTER TABLE public.mcp_scoped_recovery_intents ADD COLUMN inverse_configuration_proof text;
+ALTER TABLE public.mcp_scoped_recovery_intents ADD CONSTRAINT scoped_reservation_slot_shape CHECK (
+ (mode='manual' AND reservation_id IS NULL AND slot_phase='recovery-intent' AND source_configuration_proof IS NOT NULL)
+ OR (mode='reserved' AND reservation_id IS NOT NULL AND
+ ((slot_phase='reservation-held' AND source_configuration_proof IS NULL)
+ OR (slot_phase IN ('reservation-bound','reserved-attempt') AND source_configuration_proof IS NOT NULL)))
+);
+ALTER TABLE public.mcp_scoped_recovery_intents ADD CONSTRAINT reserved_inverse_evidence_pairs CHECK (
+ (inverse_intent_sealed IS NULL)=(inverse_intent_proof IS NULL)
+ AND (inverse_configuration_sealed IS NULL)=(inverse_configuration_proof IS NULL)
+ AND (inverse_configuration_sealed IS NULL OR inverse_intent_sealed IS NOT NULL)
+ AND (inverse_intent_sealed IS NULL OR mode='reserved')
+);
+INSERT INTO public.schema_migrations(id) VALUES ('0040_mcp_routing_reservations') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0041_server_poll_terminal_archives.sql b/backend/drizzle/0041_server_poll_terminal_archives.sql
new file mode 100644
index 00000000..7eb3d37b
--- /dev/null
+++ b/backend/drizzle/0041_server_poll_terminal_archives.sql
@@ -0,0 +1,333 @@
+-- Additive terminal poll archives. Existing 0040 full journals are retained.
+-- No compaction, retention run, source backfill or worker activation occurs here.
+BEGIN;
+DO $$ BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ IF EXISTS(SELECT 1 FROM pg_class WHERE relname='server_poll_archives')
+ OR EXISTS(SELECT 1 FROM pg_attribute WHERE attrelid='public.server_poll_storage_admissions'::regclass AND NOT attisdropped AND attname IN('storage_state','compact_at','archive_bytes','original_activity_at','compaction_claim','compaction_claimed_at','compaction_claim_xid'))
+ OR EXISTS(SELECT 1 FROM pg_attribute WHERE attrelid='public.server_poll_storage_usage'::regclass AND NOT attisdropped AND attname IN('compacted_admissions','archive_bytes'))
+ OR EXISTS(SELECT 1 FROM pg_proc WHERE proname IN('server_poll_storage_source_payload','server_poll_storage_compact_allowed','server_poll_storage_accounting_valid','server_poll_archive_insert_guard','server_poll_archive_insert_finish','server_poll_archive_immutable','server_poll_archive_final_guard','server_poll_compacted_row_guard'))
+ OR EXISTS(SELECT 1 FROM pg_trigger WHERE tgname IN('server_poll_archive_insert_guard','server_poll_archive_insert_finish','server_poll_archive_immutable','server_poll_archive_final_guard','server_poll_admission_final_guard','server_poll_compact_final_guard','server_poll_compacted_anchor_guard','server_poll_compacted_intent_guard','server_poll_compacted_ack_guard','server_poll_compacted_receipt_guard','server_poll_compacted_quarantine_guard'))
+ THEN RAISE EXCEPTION 'unmarked poll archive objects require explicit reconciliation'; END IF;
+END $$;
+LOCK TABLE server_poll_storage_usage,server_poll_storage_admissions,server_poll_executions,server_poll_intents,server_poll_acks,server_poll_receipts,server_poll_quarantines IN ACCESS EXCLUSIVE MODE;
+DO $$ BEGIN
+ IF (SELECT count(*) FROM server_poll_storage_usage WHERE scope='global')<>1
+ OR EXISTS(SELECT 1 FROM server_poll_storage_usage u WHERE
+ u.admissions<>(SELECT count(*) FROM server_poll_storage_admissions a WHERE u.scope='global' OR u.scope='owner:'||a.owner_id)
+ OR u.reserved_rows<>u.admissions*4019 OR u.reserved_bytes<>u.admissions*8421376)
+ OR EXISTS(SELECT 1 FROM server_poll_storage_admissions a WHERE NOT EXISTS(SELECT 1 FROM server_poll_storage_usage u WHERE u.scope='owner:'||a.owner_id))
+ THEN RAISE EXCEPTION 'existing poll accounting requires explicit reconciliation'; END IF;
+ IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid='public.server_poll_storage_usage'::regclass AND conname='server_poll_storage_usage_check'
+ AND pg_get_constraintdef(oid)='CHECK ((reserved_rows = (admissions * 4019)))')
+ OR NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid='public.server_poll_storage_usage'::regclass AND conname='server_poll_storage_usage_check1'
+ AND pg_get_constraintdef(oid)='CHECK ((reserved_bytes = (admissions * 8421376)))')
+ THEN RAISE EXCEPTION 'original poll accounting constraints require explicit reconciliation'; END IF;
+END $$;
+ALTER TABLE server_poll_storage_admissions
+ ADD COLUMN storage_state text NOT NULL DEFAULT 'full' CHECK(storage_state IN('full','compacted')),
+ ADD COLUMN compact_at timestamptz,
+ ADD COLUMN archive_bytes integer,
+ ADD COLUMN original_activity_at timestamptz,
+ ADD COLUMN compaction_claim uuid,
+ ADD COLUMN compaction_claimed_at timestamptz,
+ ADD COLUMN compaction_claim_xid xid8,
+ ADD CONSTRAINT server_poll_compaction_claim_shape CHECK(
+ (compaction_claim IS NULL AND compaction_claimed_at IS NULL AND compaction_claim_xid IS NULL)
+ OR(compaction_claim IS NOT NULL AND compaction_claimed_at IS NOT NULL AND compaction_claim_xid IS NOT NULL AND isfinite(compaction_claimed_at))),
+ ADD CONSTRAINT server_poll_storage_compact_shape CHECK(
+ (storage_state='full' AND compact_at IS NULL AND archive_bytes IS NULL AND original_activity_at IS NULL)
+ OR(storage_state='compacted' AND identity_kind='mcp' AND claim_token IS NULL AND claim_attempted_at IS NOT NULL
+ AND compaction_claim IS NOT NULL AND compaction_claimed_at IS NOT NULL AND compaction_claim_xid IS NOT NULL
+ AND compact_at IS NOT NULL AND archive_bytes IS NOT NULL AND original_activity_at IS NOT NULL
+ AND isfinite(compact_at) AND archive_bytes BETWEEN 1 AND 131072 AND isfinite(original_activity_at)
+ AND original_activity_at>=created_at AND compact_at>authority_expires_at+safety_ms*interval '1 millisecond'));
+ALTER TABLE server_poll_storage_usage
+ DROP CONSTRAINT server_poll_storage_usage_check,
+ DROP CONSTRAINT server_poll_storage_usage_check1,
+ ADD COLUMN compacted_admissions bigint NOT NULL DEFAULT 0 CHECK(compacted_admissions>=0),
+ ADD COLUMN archive_bytes bigint NOT NULL DEFAULT 0 CHECK(archive_bytes>=0),
+ ADD CONSTRAINT server_poll_storage_rows_charge CHECK(reserved_rows=admissions*4019+compacted_admissions*2
+ AND reserved_rows<=CASE WHEN scope='global' THEN 514432 ELSE 32152 END),
+ ADD CONSTRAINT server_poll_storage_bytes_charge CHECK(reserved_bytes=admissions*8421376+compacted_admissions*32768+archive_bytes
+ AND reserved_bytes<=CASE WHEN scope='global' THEN 1077936128 ELSE 67371008 END),
+ ADD CONSTRAINT server_poll_storage_archive_charge CHECK(archive_bytes>=compacted_admissions AND archive_bytes<=compacted_admissions*131072);
+CREATE TABLE server_poll_archives (
+ receipt_id uuid PRIMARY KEY REFERENCES server_poll_storage_admissions(receipt_id),version smallint NOT NULL CHECK(version=1),
+ execution_id uuid NOT NULL UNIQUE,connection_id uuid NOT NULL,owner_id text NOT NULL,
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),context_proof text NOT NULL CHECK(context_proof ~ '^[a-f0-9]{64}$'),
+ source_digest text NOT NULL CHECK(source_digest ~ '^[a-f0-9]{64}$'),source_sha256 text NOT NULL CHECK(source_sha256 ~ '^[a-f0-9]{64}$'),
+ terminal_digest text NOT NULL CHECK(terminal_digest ~ '^[a-f0-9]{64}$'),
+ original_activity_at timestamptz NOT NULL CHECK(isfinite(original_activity_at)),original_expires_at timestamptz NOT NULL CHECK(isfinite(original_expires_at)),
+ decoded_bytes integer NOT NULL CHECK(decoded_bytes BETWEEN 1 AND 16777216),compressed_bytes integer NOT NULL CHECK(compressed_bytes BETWEEN 1 AND 98048),
+ ciphertext text NOT NULL,ciphertext_bytes integer NOT NULL CHECK(ciphertext_bytes BETWEEN 1 AND 131072 AND ciphertext_bytes=octet_length(ciphertext)),
+ archive_proof text NOT NULL CHECK(archive_proof ~ '^[a-f0-9]{64}$'),
+ created_at timestamptz NOT NULL,compaction_xid xid8 NOT NULL
+);
+
+-- SQL checks structure/ownership/current rows. The fixed private producer and
+-- historical reader additionally authenticate every existing keyed proof and
+-- the archive MAC; SQL never receives an encryption/HMAC key or boolean grant.
+CREATE FUNCTION server_poll_storage_compact_allowed(id uuid) RETURNS boolean LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE a public.server_poll_storage_admissions%ROWTYPE; o public.mcp_operations%ROWTYPE; p public.mcp_plans%ROWTYPE; s public.mcp_operation_steps%ROWTYPE; n integer; pubs integer; activity timestamptz;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;
+ IF NOT FOUND OR a.storage_state<>'full' OR a.identity_kind<>'mcp' OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL
+ OR a.authority_expires_at+a.safety_ms*interval '1 millisecond'>=clock_timestamp()
+ OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=id OR(identity_kind=a.identity_kind AND execution_id=a.execution_id))
+ THEN RETURN false; END IF;
+ IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;
+ IF NOT pg_try_advisory_xact_lock(hashtextextended('server-poll-execution-v1:mcp:'||a.execution_id::text,0)) THEN RETURN false; END IF;
+ IF NOT pg_try_advisory_xact_lock(hashtextextended('server-poll-receipt-v1:'||a.receipt_id::text,0)) THEN RETURN false; END IF;
+ BEGIN
+ SELECT * INTO o FROM public.mcp_operations WHERE mcp_operations.id=a.execution_id AND connection_id=a.connection_id FOR UPDATE NOWAIT;
+ IF NOT FOUND OR o.state<>'applied' OR o.verification<>'passed' OR o.error_code IS NOT NULL OR o.finished_at IS NULL THEN RETURN false; END IF;
+ SELECT * INTO p FROM public.mcp_plans WHERE mcp_plans.id=o.plan_id AND connection_id=a.connection_id FOR UPDATE NOWAIT;
+ IF NOT FOUND OR p.operation_id<>'servers.poll' OR p.operation_version<>1 OR p.state<>'completed' OR p.approved_by IS NULL OR p.approved_at IS NULL
+ OR p.created_at>p.approved_at OR p.approved_at>o.created_at OR o.created_at>=LEAST(p.expires_at,a.authority_expires_at) THEN RETURN false; END IF;
+ SELECT * INTO s FROM public.mcp_operation_steps WHERE operation_id=o.id AND step_index=0 FOR UPDATE NOWAIT;
+ IF NOT FOUND OR s.state<>'verified' OR s.server_id IS NOT NULL OR s.result IS NULL OR s.finished_at IS NULL
+ OR(SELECT count(*) FROM public.mcp_operation_steps WHERE operation_id=o.id)<>1
+ OR NOT EXISTS(SELECT 1 FROM public.mcp_connections c WHERE c.id=a.connection_id AND c.owner_id=a.owner_id)
+ OR s.intended_state->>'kind' IS DISTINCT FROM 'service' OR s.intended_state->>'service' IS DISTINCT FROM 'servers.poll'
+ OR s.intended_state#>>'{input,receiptId}' IS DISTINCT FROM id::text
+ OR s.result->>'operationId' IS DISTINCT FROM o.id::text OR s.result->>'receiptId' IS DISTINCT FROM id::text
+ OR s.result->'nativeReads' IS DISTINCT FROM '4'::jsonb
+ OR s.result->'complete' IS DISTINCT FROM 'true'::jsonb OR s.result->'maintenanceComplete' IS DISTINCT FROM 'true'::jsonb
+ OR s.result->'configurationVerified' IS DISTINCT FROM 'true'::jsonb OR s.result->'automaticReplay' IS DISTINCT FROM 'false'::jsonb
+ THEN RETURN false; END IF;
+ EXCEPTION WHEN lock_not_available THEN RETURN false; END;
+ IF NOT EXISTS(SELECT 1 FROM public.server_poll_executions e WHERE e.receipt_id=id AND e.identity_kind=a.identity_kind AND e.execution_id=a.execution_id AND e.binding_proof=a.binding_proof AND e.context_proof=a.context_proof)
+ OR NOT EXISTS(SELECT 1 FROM public.server_poll_receipts r WHERE r.receipt_id=id AND r.created_atpubs+4 OR pubs NOT IN(a.max_stages-6,a.max_stages-4) OR a.used_rows<>2*n+2
+ OR(SELECT count(*) FROM public.server_poll_acks WHERE receipt_id=id)<>n
+ OR s.result->'confirmedPublications' IS DISTINCT FROM to_jsonb(pubs)
+ OR s.result->'completedPublications' IS DISTINCT FROM to_jsonb(pubs)
+ OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=id AND outcome<>'confirmed')
+ OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=id AND created_at>=a.authority_expires_at)
+ OR EXISTS(SELECT 1 FROM unnest(ARRAY['native.identity','native.resource','native.interfaces','native.addresses']) wanted(stage)
+ WHERE NOT EXISTS(SELECT 1 FROM public.server_poll_intents i JOIN public.server_poll_acks k USING(receipt_id,stage) WHERE i.receipt_id=id AND i.stage=wanted.stage AND k.outcome='confirmed'))
+ OR EXISTS(SELECT 1 FROM generate_series(0,pubs-1) wanted(stage) WHERE NOT EXISTS(SELECT 1 FROM public.server_poll_intents i JOIN public.server_poll_acks k USING(receipt_id,stage) WHERE i.receipt_id=id AND i.stage='publish.'||wanted.stage::text AND k.outcome='confirmed'))
+ THEN RETURN false; END IF;
+ SELECT GREATEST(a.authority_expires_at,a.created_at,a.claim_attempted_at,o.finished_at,p.expires_at,s.finished_at,
+ (SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),(SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),
+ (SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),(SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id)) INTO activity;
+ RETURN isfinite(activity) AND activity+a.safety_ms*interval '1 millisecond'16777216 THEN RETURN NULL; END IF;
+ RETURN payload;
+END $$;
+CREATE FUNCTION server_poll_storage_accounting_valid() RETURNS boolean LANGUAGE sql SET search_path=pg_catalog,public AS $$
+ WITH charges AS (
+ SELECT owner_id,CASE WHEN storage_state='full' THEN 1 ELSE 0 END::bigint AS heavy,
+ CASE WHEN storage_state='compacted' THEN 1 ELSE 0 END::bigint AS compact,
+ COALESCE(archive_bytes,0)::bigint AS archives,
+ CASE WHEN storage_state='full' THEN 4019 ELSE 2 END::bigint AS rows,
+ CASE WHEN storage_state='full' THEN 8421376 ELSE 32768+archive_bytes END::bigint AS bytes
+ FROM public.server_poll_storage_admissions
+ ), expected AS (
+ SELECT 'global' AS scope,COALESCE(sum(heavy),0) AS heavy,COALESCE(sum(compact),0) AS compact,COALESCE(sum(archives),0) AS archives,COALESCE(sum(rows),0) AS rows,COALESCE(sum(bytes),0) AS bytes FROM charges
+ UNION ALL SELECT 'owner:'||owner_id,sum(heavy),sum(compact),sum(archives),sum(rows),sum(bytes) FROM charges GROUP BY owner_id
+ ) SELECT NOT EXISTS(SELECT 1 FROM public.server_poll_storage_usage u FULL JOIN expected e USING(scope)
+ WHERE u.scope IS NULL OR u.admissions<>COALESCE(e.heavy,0) OR u.compacted_admissions<>COALESCE(e.compact,0)
+ OR u.archive_bytes<>COALESCE(e.archives,0) OR u.reserved_rows<>COALESCE(e.rows,0) OR u.reserved_bytes<>COALESCE(e.bytes,0))
+ AND NOT EXISTS(SELECT 1 FROM public.server_poll_storage_admissions a LEFT JOIN public.server_poll_archives r USING(receipt_id)
+ WHERE (a.storage_state='full' AND r.receipt_id IS NOT NULL) OR(a.storage_state='compacted' AND(r.receipt_id IS NULL OR a.archive_bytes<>r.ciphertext_bytes)))
+$$;
+CREATE FUNCTION server_poll_archive_insert_guard() RETURNS trigger LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE a public.server_poll_storage_admissions%ROWTYPE; payload jsonb; activity timestamptz;
+BEGIN
+ payload:=public.server_poll_storage_source_payload(NEW.receipt_id);
+ IF payload IS NULL OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'poll source is not eligible for terminal archive'; END IF;
+ SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;
+ SELECT GREATEST(a.authority_expires_at,a.created_at,a.claim_attempted_at,(payload#>>'{terminal,operation,finished_at}')::timestamptz,
+ (payload#>>'{terminal,plan,expires_at}')::timestamptz,(payload#>>'{terminal,step,finished_at}')::timestamptz,
+ (payload#>>'{journal,execution,created_at}')::timestamptz,(payload#>>'{journal,receipt,created_at}')::timestamptz,
+ (SELECT max((v->>'created_at')::timestamptz) FROM jsonb_array_elements(payload#>'{journal,intents}') v),
+ (SELECT max((v->>'created_at')::timestamptz) FROM jsonb_array_elements(payload#>'{journal,acks}') v)) INTO activity;
+ IF a.compaction_claim IS NULL OR a.compaction_claimed_at IS NULL OR NOT isfinite(a.compaction_claimed_at)
+ OR a.compaction_claim_xid IS NULL OR a.compaction_claim_xid=pg_current_xact_id()
+ OR NEW.version<>1 OR NEW.execution_id<>a.execution_id OR NEW.connection_id<>a.connection_id OR NEW.owner_id<>a.owner_id
+ OR NEW.binding_proof<>a.binding_proof OR NEW.context_proof<>a.context_proof OR NEW.original_expires_at<>a.authority_expires_at
+ OR NEW.original_activity_at<>activity OR NEW.decoded_bytes<>octet_length(payload::text)
+ OR NEW.source_sha256<>encode(sha256(convert_to(payload::text,'UTF8')),'hex')
+ OR NEW.ciphertext_bytes<>octet_length(NEW.ciphertext) OR NEW.ciphertext_bytes>131072
+ OR NEW.ciphertext !~ '^[A-Za-z0-9+/]+={0,2}$'
+ OR replace(encode(decode(NEW.ciphertext,'base64'),'base64'),E'\n','')<>NEW.ciphertext
+ OR octet_length(decode(NEW.ciphertext,'base64'))<>NEW.compressed_bytes+28
+ THEN RAISE EXCEPTION 'poll archive does not match the entire immutable source'; END IF;
+ NEW.created_at:=clock_timestamp(); NEW.compaction_xid:=pg_current_xact_id();
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_poll_archive_insert_guard BEFORE INSERT ON server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_poll_archive_insert_guard();
+
+CREATE OR REPLACE FUNCTION server_poll_journal_immutable() RETURNS trigger LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$ BEGIN
+ IF TG_OP='DELETE' AND EXISTS(SELECT 1 FROM public.server_poll_archives r JOIN public.server_poll_storage_admissions a USING(receipt_id)
+ WHERE r.receipt_id=OLD.receipt_id AND r.compaction_xid=pg_current_xact_id() AND a.storage_state='full') THEN RETURN OLD; END IF;
+ IF TG_OP='DELETE' AND public.server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'server poll journal is immutable outside complete archive or original lifetime GC';
+END $$;
+CREATE OR REPLACE FUNCTION server_poll_storage_admission_guard() RETURNS trigger LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE retention integer; charged integer; r public.server_poll_archives%ROWTYPE;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ IF TG_OP='DELETE' THEN
+ IF NOT public.server_poll_storage_gc_allowed(OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id) THEN RAISE EXCEPTION 'poll lifetime or children prevent admission deletion'; END IF;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions-CASE WHEN OLD.storage_state='full' THEN 1 ELSE 0 END,
+ compacted_admissions=compacted_admissions-CASE WHEN OLD.storage_state='compacted' THEN 1 ELSE 0 END,
+ archive_bytes=archive_bytes-COALESCE(OLD.archive_bytes,0),
+ reserved_rows=reserved_rows-CASE WHEN OLD.storage_state='full' THEN 4019 ELSE 2 END,
+ reserved_bytes=reserved_bytes-CASE WHEN OLD.storage_state='full' THEN 8421376 ELSE 32768+OLD.archive_bytes END
+ WHERE scope IN('global','owner:'||OLD.owner_id);
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll quota refund mismatch'; END IF; RETURN OLD;
+ END IF;
+ IF TG_OP='UPDATE' THEN
+ -- This durable one-shot marker is written and ACKed in its OWN transaction
+ -- before archive construction. A committed/unknown claim never resets and
+ -- the worker never retries destructive work against an already claimed full
+ -- source. Claim time is maintenance metadata, not renewed execution activity.
+ IF OLD.storage_state='full' AND NEW.storage_state='full' AND OLD.compaction_claim IS NULL AND OLD.compaction_claimed_at IS NULL AND OLD.compaction_claim_xid IS NULL
+ AND NEW.compaction_claim IS NOT NULL AND NEW.compaction_claim_xid IS NULL
+ AND(to_jsonb(OLD)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])=(to_jsonb(NEW)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])
+ AND public.server_poll_storage_compact_allowed(OLD.receipt_id)
+ THEN NEW.compaction_claimed_at:=clock_timestamp(); NEW.compaction_claim_xid:=pg_current_xact_id(); RETURN NEW; END IF;
+ IF(to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) IS DISTINCT FROM
+ (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) THEN RAISE EXCEPTION 'poll admission identity is immutable'; END IF;
+ IF OLD.storage_state<>'full' THEN RAISE EXCEPTION 'compacted poll identity cannot reopen or change'; END IF;
+ IF NEW.storage_state='compacted' THEN
+ SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND compaction_xid=pg_current_xact_id();
+ IF NOT FOUND OR NEW.used_rows<>OLD.used_rows OR NEW.used_bytes<>OLD.used_bytes OR NEW.claim_token IS DISTINCT FROM OLD.claim_token
+ OR NEW.claim_attempted_at IS DISTINCT FROM OLD.claim_attempted_at OR NEW.archive_bytes<>r.ciphertext_bytes OR NEW.original_activity_at<>r.original_activity_at
+ OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)
+ THEN RAISE EXCEPTION 'poll compaction requires the complete current-transaction archive'; END IF;
+ NEW.compact_at:=r.created_at;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions-1,compacted_admissions=compacted_admissions+1,
+ archive_bytes=archive_bytes+r.ciphertext_bytes,reserved_rows=reserved_rows-4019+2,reserved_bytes=reserved_bytes-8421376+32768+r.ciphertext_bytes
+ WHERE scope IN('global','owner:'||OLD.owner_id) AND admissions>=1;
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll compaction charge mismatch'; END IF;
+ RETURN NEW;
+ END IF;
+ IF NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL THEN RAISE EXCEPTION 'full poll cannot carry archive metadata'; END IF;
+ IF OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL
+ AND NEW.used_rows=OLD.used_rows AND NEW.used_bytes=OLD.used_bytes AND OLD.authority_expires_at>clock_timestamp()
+ THEN NEW.claim_attempted_at:=clock_timestamp(); RETURN NEW; END IF;
+ IF OLD.claim_token IS NOT DISTINCT FROM NEW.claim_token AND OLD.claim_attempted_at IS NOT DISTINCT FROM NEW.claim_attempted_at
+ AND NEW.used_rows=OLD.used_rows+1 AND NEW.used_bytes>OLD.used_bytes THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'poll admission cannot refresh, reopen or refund itself';
+ END IF;
+ IF NEW.storage_state<>'full' OR NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL
+ OR NEW.compaction_claim IS NOT NULL OR NEW.compaction_claimed_at IS NOT NULL OR NEW.compaction_claim_xid IS NOT NULL
+ OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'new poll requires full reservation and exact ledger'; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 OR NEW.authority_issued_at>clock_timestamp() OR NEW.authority_expires_at<=clock_timestamp()
+ OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL OR NEW.used_rows<>0 OR NEW.used_bytes<>0 THEN RAISE EXCEPTION 'new poll admission needs original live authority'; END IF;
+ IF EXISTS(SELECT 1 FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id OR(identity_kind=NEW.identity_kind AND execution_id=NEW.execution_id)) THEN RAISE EXCEPTION 'poll identity already spent'; END IF;
+ NEW.created_at:=clock_timestamp(); NEW.retention_days:=retention; NEW.safety_ms:=60000;
+ NEW.gc_not_before:=NEW.authority_expires_at+make_interval(days=>retention)+interval '60 seconds';
+ INSERT INTO public.server_poll_storage_usage(scope) VALUES('owner:'||NEW.owner_id) ON CONFLICT DO NOTHING;
+ IF(SELECT count(*) FROM public.server_poll_storage_usage WHERE scope IN('global','owner:'||NEW.owner_id)
+ AND admissions2 THEN RAISE EXCEPTION 'poll admission quota exhausted'; END IF;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions+1,reserved_rows=reserved_rows+4019,reserved_bytes=reserved_bytes+8421376 WHERE scope IN('global','owner:'||NEW.owner_id);
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll admission quota unavailable'; END IF;
+ RETURN NEW;
+END $$;
+CREATE FUNCTION server_poll_archive_insert_finish() RETURNS trigger LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$ BEGIN
+ DELETE FROM public.server_poll_acks WHERE receipt_id=NEW.receipt_id;
+ DELETE FROM public.server_poll_intents WHERE receipt_id=NEW.receipt_id;
+ DELETE FROM public.server_poll_receipts WHERE receipt_id=NEW.receipt_id;
+ DELETE FROM public.server_poll_executions WHERE receipt_id=NEW.receipt_id;
+ UPDATE public.server_poll_storage_admissions SET storage_state='compacted',compact_at=NEW.created_at,archive_bytes=NEW.ciphertext_bytes,original_activity_at=NEW.original_activity_at WHERE receipt_id=NEW.receipt_id AND storage_state='full';
+ IF NOT FOUND THEN RAISE EXCEPTION 'poll admission did not transition with archive'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_poll_archive_insert_finish AFTER INSERT ON server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_poll_archive_insert_finish();
+
+CREATE OR REPLACE FUNCTION server_poll_storage_gc_allowed(id uuid) RETURNS boolean LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE a public.server_poll_storage_admissions%ROWTYPE; retention integer; activity timestamptz; terminal_at timestamptz;
+BEGIN
+ IF current_setting('mm.poll_storage_gc',true) IS DISTINCT FROM 'on' THEN RETURN false; END IF;
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;
+ IF NOT FOUND OR a.authority_expires_at>=clock_timestamp() OR a.gc_not_before>=clock_timestamp() THEN RETURN false; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE mcp_settings.id=1 FOR SHARE;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;
+ terminal_at:=a.created_at;
+ IF a.identity_kind='mcp' THEN
+ IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;
+ BEGIN
+ SELECT GREATEST(o.finished_at,p.expires_at) INTO terminal_at FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id JOIN public.mcp_connections c ON c.id=o.connection_id
+ WHERE o.id=a.execution_id AND o.connection_id=a.connection_id AND c.owner_id=a.owner_id AND p.operation_id='servers.poll'
+ AND o.state IN('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL FOR UPDATE OF o,p NOWAIT;
+ IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;
+ EXCEPTION WHEN lock_not_available THEN RETURN false; END;
+ END IF;
+ IF a.storage_state='compacted' THEN activity:=GREATEST(a.original_activity_at,a.authority_expires_at,terminal_at);
+ ELSE
+ SELECT GREATEST(a.authority_expires_at,a.created_at,COALESCE(a.claim_attempted_at,a.created_at),terminal_at,
+ COALESCE((SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM public.server_poll_quarantines WHERE receipt_id=id),a.created_at)) INTO activity;
+ END IF;
+ RETURN isfinite(activity) AND activity+make_interval(days=>GREATEST(a.retention_days,retention))+a.safety_ms*interval '1 millisecond' 'public' OR TG_TABLE_NAME NOT IN
+ ('traffic_settings', 'uptime_settings', 'internet_path_settings')
+ OR TG_LEVEL <> 'ROW' OR TG_WHEN <> 'BEFORE' THEN
+ RAISE EXCEPTION 'unexpected poll settings epoch trigger target';
+ END IF;
+ IF TG_OP = 'INSERT' THEN
+ -- Never accept an epoch supplied by an importer or application caller.
+ NEW.poll_configuration_epoch := pg_catalog.gen_random_uuid();
+ ELSIF TG_OP = 'UPDATE' THEN
+ -- Every unknown/future field is configuration by default. Only these four
+ -- current collector fields are excluded; created_at stays significant.
+ IF (pg_catalog.to_jsonb(NEW) - ARRAY['poll_configuration_epoch',
+ 'last_collected_at', 'last_duration_ms', 'last_error', 'updated_at'])
+ IS DISTINCT FROM
+ (pg_catalog.to_jsonb(OLD) - ARRAY['poll_configuration_epoch',
+ 'last_collected_at', 'last_duration_ms', 'last_error', 'updated_at']) THEN
+ NEW.poll_configuration_epoch := pg_catalog.gen_random_uuid();
+ ELSE
+ NEW.poll_configuration_epoch := OLD.poll_configuration_epoch;
+ END IF;
+ ELSE
+ RAISE EXCEPTION 'unexpected poll settings epoch trigger operation';
+ END IF;
+ RETURN NEW;
+END;
+$epoch$;
+CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.traffic_settings
+FOR EACH ROW EXECUTE FUNCTION public.server_poll_settings_epoch_guard();
+CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.uptime_settings
+FOR EACH ROW EXECUTE FUNCTION public.server_poll_settings_epoch_guard();
+CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.internet_path_settings
+FOR EACH ROW EXECUTE FUNCTION public.server_poll_settings_epoch_guard();
+ALTER TABLE public.traffic_settings ENABLE ALWAYS TRIGGER server_poll_settings_epoch;
+ALTER TABLE public.uptime_settings ENABLE ALWAYS TRIGGER server_poll_settings_epoch;
+ALTER TABLE public.internet_path_settings ENABLE ALWAYS TRIGGER server_poll_settings_epoch;
+INSERT INTO schema_migrations(id) VALUES('0042_server_poll_settings_epoch') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0043_mcp_routing_forward_charges.sql b/backend/drizzle/0043_mcp_routing_forward_charges.sql
new file mode 100644
index 00000000..a2f68777
--- /dev/null
+++ b/backend/drizzle/0043_mcp_routing_forward_charges.sql
@@ -0,0 +1,62 @@
+-- Durable persistent-forward charge; no execution authority is issued.
+-- Reuses the accepted B2.a immutable-parent charging rule, narrowed to ONE
+-- forward charge. Existing 0040 two-slot reservations/0031 remain untouched.
+-- This SQL cannot authenticate a binding or grant execution authority.
+BEGIN;
+DO $$ BEGIN
+ IF to_regclass('public.mcp_routing_forward_charges') IS NOT NULL
+ THEN RAISE EXCEPTION 'unmarked forward charge storage requires explicit reconciliation'; END IF;
+END $$;
+CREATE TABLE public.mcp_routing_forward_charges (
+ -- Logical historical identities, intentionally NOT lifetime FKs. INSERT is
+ -- checked against the actual current source below; later source/profile
+ -- retention cannot erase this charge or be blocked forever by old charges.
+ source_operation_id uuid PRIMARY KEY,
+ source_plan_id uuid NOT NULL,
+ source_step_index integer NOT NULL CHECK(source_step_index=0),
+ profile_id uuid NOT NULL,
+ connection_id uuid NOT NULL,
+ charge_units integer NOT NULL DEFAULT 1 CHECK(charge_units=1),
+ binding_sealed text NOT NULL CHECK(octet_length(binding_sealed) BETWEEN 1 AND 262144),
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),
+ created_at timestamptz NOT NULL
+);
+CREATE INDEX mcp_routing_forward_charges_window
+ ON public.mcp_routing_forward_charges(profile_id,created_at);
+CREATE INDEX mcp_routing_forward_charges_retention
+ ON public.mcp_routing_forward_charges(created_at,source_operation_id);
+-- The immutable parent IS the charged unit. No mutable status/child can drop it
+-- from the hourly projection after reject/unknown, human save or restart.
+CREATE FUNCTION public.mcp_routing_forward_charge_source() RETURNS trigger LANGUAGE plpgsql AS $$
+BEGIN
+ IF NOT EXISTS(
+ SELECT 1 FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_routing_profiles r ON r.id=NEW.profile_id AND r.connection_id=o.connection_id
+ WHERE o.id=NEW.source_operation_id AND p.id=NEW.source_plan_id
+ AND o.connection_id=NEW.connection_id AND o.state='pending' AND p.state='executing'
+ AND p.operation_id='routing.community.switch' AND p.operation_version=7
+ ) THEN RAISE EXCEPTION 'forward charge differs from actual pending admission source'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER mcp_routing_forward_charge_source BEFORE INSERT ON public.mcp_routing_forward_charges
+ FOR EACH ROW EXECUTE FUNCTION public.mcp_routing_forward_charge_source();
+CREATE FUNCTION public.mcp_routing_forward_charge_immutable() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE retention integer;
+BEGIN
+ IF TG_OP<>'DELETE' THEN RAISE EXCEPTION 'immutable forward charge; rewrite/refund forbidden'; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1 FOR SHARE;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365
+ OR OLD.created_at>clock_timestamp()-interval '1 hour'
+ OR OLD.created_at>=clock_timestamp()-make_interval(days=>retention)
+ OR EXISTS(SELECT 1 FROM public.mcp_operations WHERE id=OLD.source_operation_id AND state IN('pending','running'))
+ THEN RAISE EXCEPTION 'forward charge is still retained or unresolved'; END IF;
+ RETURN OLD;
+END $$;
+CREATE TRIGGER mcp_routing_forward_charge_immutable BEFORE UPDATE OR DELETE ON public.mcp_routing_forward_charges
+ FOR EACH ROW EXECUTE FUNCTION public.mcp_routing_forward_charge_immutable();
+CREATE TRIGGER mcp_routing_forward_charge_no_truncate BEFORE TRUNCATE ON public.mcp_routing_forward_charges
+ FOR EACH STATEMENT EXECUTE FUNCTION public.mcp_routing_forward_charge_immutable();
+-- DDL and exact file marker commit atomically. No SECURITY DEFINER or grants.
+INSERT INTO public.schema_migrations (id) VALUES ('0043_mcp_routing_forward_charges') ON CONFLICT (id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0044_mcp_routing_manual_inverse_charges.sql b/backend/drizzle/0044_mcp_routing_manual_inverse_charges.sql
new file mode 100644
index 00000000..d175494f
--- /dev/null
+++ b/backend/drizzle/0044_mcp_routing_manual_inverse_charges.sql
@@ -0,0 +1,93 @@
+-- Additive durable scoped manual inverse-one charge. No execution grant.
+-- Existing 0043 is immutable. Logical charge identities outlive family FKs.
+BEGIN;
+DO $$ BEGIN
+ IF to_regclass('public.mcp_routing_manual_inverse_charges') IS NOT NULL
+ THEN RAISE EXCEPTION 'unmarked manual inverse storage requires reconciliation'; END IF;
+END $$;
+CREATE TABLE public.mcp_routing_manual_inverse_charges (
+ recovery_operation_id uuid PRIMARY KEY,
+ recovery_plan_id uuid NOT NULL,
+ source_operation_id uuid NOT NULL,
+ source_plan_id uuid NOT NULL,
+ source_step_index integer NOT NULL CHECK(source_step_index=0),
+ profile_id uuid NOT NULL,
+ profile_version integer NOT NULL CHECK(profile_version>0),
+ connection_id uuid NOT NULL,
+ owner_id text NOT NULL CHECK(octet_length(owner_id) BETWEEN 1 AND 1000),
+ charge_units integer NOT NULL CHECK(charge_units=1),
+ binding_sealed text NOT NULL CHECK(octet_length(binding_sealed) BETWEEN 1 AND 262144),
+ binding_proof text NOT NULL CHECK(binding_proof ~ '^[a-f0-9]{64}$'),
+ created_at timestamptz NOT NULL,
+ CONSTRAINT mcp_manual_inverse_source_step_unique UNIQUE(source_operation_id,source_step_index)
+);
+CREATE INDEX mcp_routing_manual_inverse_charges_window
+ ON public.mcp_routing_manual_inverse_charges(profile_id,created_at);
+CREATE INDEX mcp_routing_manual_inverse_charges_retention
+ ON public.mcp_routing_manual_inverse_charges(created_at,recovery_operation_id);
+CREATE INDEX mcp_scoped_recovery_manual_history
+ ON public.mcp_scoped_recovery_intents(mode,source_operation_id,source_step_index)
+ WHERE mode='manual';
+CREATE FUNCTION public.mcp_routing_manual_inverse_charge_source() RETURNS trigger LANGUAGE plpgsql AS $$
+BEGIN
+ IF NOT EXISTS(
+ SELECT 1 FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_routing_profiles r ON r.id=NEW.profile_id AND r.connection_id=o.connection_id
+ JOIN public.mcp_operations source ON source.id=NEW.source_operation_id AND source.connection_id=o.connection_id
+ JOIN public.mcp_plans sp ON sp.id=source.plan_id AND sp.connection_id=source.connection_id
+ JOIN public.mcp_connections c ON c.id=o.connection_id
+ WHERE o.id=NEW.recovery_operation_id AND p.id=NEW.recovery_plan_id
+ AND o.connection_id=NEW.connection_id AND c.owner_id=NEW.owner_id
+ AND r.version=NEW.profile_version AND o.state='pending' AND p.state='executing'
+ AND p.operation_id='operations.recover' AND p.operation_version=7
+ AND sp.id=NEW.source_plan_id AND sp.operation_id='routing.community.switch' AND sp.operation_version=7
+ AND source.state IN('applied','partial')
+ ) THEN RAISE EXCEPTION 'manual inverse charge differs from pending admission'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER mcp_routing_manual_inverse_charge_source BEFORE INSERT ON public.mcp_routing_manual_inverse_charges
+ FOR EACH ROW EXECUTE FUNCTION public.mcp_routing_manual_inverse_charge_source();
+CREATE FUNCTION public.mcp_routing_manual_inverse_charge_immutable() RETURNS trigger LANGUAGE plpgsql AS $$
+DECLARE retention integer;
+BEGIN
+ IF TG_OP<>'DELETE' THEN RAISE EXCEPTION 'immutable manual inverse charge; rewrite/refund forbidden'; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1 FOR SHARE;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365
+ OR OLD.created_at>clock_timestamp()-interval '1 hour'
+ OR OLD.created_at>=clock_timestamp()-make_interval(days=>retention)
+ OR EXISTS(SELECT 1 FROM public.mcp_operations WHERE id=OLD.recovery_operation_id AND state IN('pending','running'))
+ THEN RAISE EXCEPTION 'manual inverse charge still retained or unresolved'; END IF;
+ RETURN OLD;
+END $$;
+CREATE TRIGGER mcp_routing_manual_inverse_charge_immutable BEFORE UPDATE OR DELETE ON public.mcp_routing_manual_inverse_charges
+ FOR EACH ROW EXECUTE FUNCTION public.mcp_routing_manual_inverse_charge_immutable();
+CREATE TRIGGER mcp_routing_manual_inverse_charge_no_truncate BEFORE TRUNCATE ON public.mcp_routing_manual_inverse_charges
+ FOR EACH STATEMENT EXECUTE FUNCTION public.mcp_routing_manual_inverse_charge_immutable();
+-- This is a version/identity fence, never authentication of encrypted source.
+-- Old binaries cannot create a fresh v6 manual intent after this DDL commits.
+-- Already-claimed old work requires the normal drained-writer cutover.
+CREATE FUNCTION public.mcp_scoped_recovery_manual_version() RETURNS trigger LANGUAGE plpgsql AS $$
+BEGIN
+ IF NEW.mode='manual' AND NOT pg_try_advisory_xact_lock(hashtextextended('mcp-runner-admission',0))
+ THEN RAISE EXCEPTION 'manual intent admission snapshot busy'; END IF;
+ IF NEW.mode='manual' AND NOT EXISTS(
+ SELECT 1 FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_operation_steps s ON s.operation_id=o.id AND s.step_index=0
+ JOIN public.mcp_operations source ON source.id=NEW.source_operation_id AND source.connection_id=o.connection_id
+ WHERE o.id=NEW.recovery_operation_id AND o.state='running'
+ AND p.state='executing' AND p.operation_id='operations.recover' AND p.operation_version=7
+ AND NEW.source_step_index=0 AND s.state='intent'
+ AND s.intended_state->>'kind'='service'
+ AND s.intended_state->>'service'='routing.community.scoped.recover'
+ AND s.intended_state->'input'->>'mode'='manual'
+ AND s.intended_state->'input'->>'sourceOperationId'=NEW.source_operation_id::text
+ AND s.intended_state->'input'->>'receiptId'=NEW.recovery_receipt_id::text
+ ) THEN RAISE EXCEPTION 'manual inverse requires current exact running recovery'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER mcp_scoped_recovery_manual_version BEFORE INSERT ON public.mcp_scoped_recovery_intents
+ FOR EACH ROW EXECUTE FUNCTION public.mcp_scoped_recovery_manual_version();
+INSERT INTO public.schema_migrations(id) VALUES('0044_mcp_routing_manual_inverse_charges') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0045_mcp_operation_replay_tombstones.sql b/backend/drizzle/0045_mcp_operation_replay_tombstones.sql
new file mode 100644
index 00000000..08b3d253
--- /dev/null
+++ b/backend/drizzle/0045_mcp_operation_replay_tombstones.sql
@@ -0,0 +1,13 @@
+BEGIN;
+CREATE TABLE public.mcp_operation_replay_tombstones (
+ operation_id uuid PRIMARY KEY,
+ plan_id uuid NOT NULL UNIQUE,
+ connection_id uuid NOT NULL REFERENCES public.mcp_connections(id),
+ idempotency_digest text NOT NULL CHECK (idempotency_digest ~ '^[0-9a-f]{64}$'),
+ action_id text NOT NULL CHECK (length(action_id) BETWEEN 1 AND 200),
+ target_server_ids bigint[] NOT NULL CHECK (array_position(target_server_ids, NULL) IS NULL),
+ target_global boolean NOT NULL,
+ UNIQUE (connection_id,idempotency_digest)
+);
+INSERT INTO public.schema_migrations(id) VALUES ('0045_mcp_operation_replay_tombstones') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0046_server_poll_operation_retirement.sql b/backend/drizzle/0046_server_poll_operation_retirement.sql
new file mode 100644
index 00000000..7cc40b5d
--- /dev/null
+++ b/backend/drizzle/0046_server_poll_operation_retirement.sql
@@ -0,0 +1,186 @@
+-- Inactive poll-history V1-to-V2 retirement. Application owner authenticates
+-- both ciphertext versions; SQL independently fences identity and lifetime.
+BEGIN;
+LOCK TABLE public.server_poll_archives,public.server_poll_storage_admissions IN ACCESS EXCLUSIVE MODE;
+ALTER TABLE public.server_poll_archives DROP CONSTRAINT server_poll_archives_version_check;
+ALTER TABLE public.server_poll_archives ADD CONSTRAINT server_poll_archives_version_check
+ CHECK(version=1 OR (version=2 AND decoded_bytes<=24576 AND compressed_bytes<=24576 AND ciphertext_bytes<=33000));
+
+CREATE OR REPLACE FUNCTION public.server_poll_archive_immutable() RETURNS trigger
+LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF TG_OP='DELETE' AND public.server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;
+ IF TG_OP='UPDATE' AND OLD.version=1 AND NEW.version=2
+ AND current_setting('mm.poll_retire_receipt',true)=OLD.receipt_id::text
+ AND NEW.ciphertext_bytes<=OLD.ciphertext_bytes
+ AND NEW.ciphertext ~ '^[A-Za-z0-9+/]+={0,2}$'
+ AND replace(encode(decode(NEW.ciphertext,'base64'),'base64'),E'\n','')=NEW.ciphertext
+ AND octet_length(decode(NEW.ciphertext,'base64'))=NEW.compressed_bytes+28
+ AND (to_jsonb(OLD)-ARRAY['version','source_digest','source_sha256','decoded_bytes','compressed_bytes','ciphertext','ciphertext_bytes','archive_proof'])=
+ (to_jsonb(NEW)-ARRAY['version','source_digest','source_sha256','decoded_bytes','compressed_bytes','ciphertext','ciphertext_bytes','archive_proof'])
+ AND EXISTS(
+ SELECT 1 FROM public.server_poll_storage_admissions a JOIN public.mcp_operations o ON o.id=a.execution_id AND o.connection_id=a.connection_id
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_operation_steps s ON s.operation_id=o.id AND s.step_index=0
+ JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=o.id AND t.plan_id=p.id AND t.connection_id=o.connection_id
+ JOIN public.mcp_connections c ON c.id=o.connection_id AND c.owner_id=a.owner_id
+ WHERE a.receipt_id=OLD.receipt_id AND a.identity_kind='mcp' AND a.storage_state='compacted'
+ AND a.execution_id=OLD.execution_id AND a.connection_id=OLD.connection_id AND a.owner_id=OLD.owner_id
+ AND a.binding_proof=OLD.binding_proof AND a.context_proof=OLD.context_proof AND a.archive_bytes=OLD.ciphertext_bytes
+ AND a.original_activity_at=OLD.original_activity_at AND a.authority_expires_at=OLD.original_expires_at
+ AND o.state='applied' AND o.verification='passed' AND o.error_code IS NULL AND isfinite(o.finished_at)
+ AND o.finished_at0
+ ) THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'poll archive immutable outside exact retirement or original lifetime GC';
+END $$;
+
+CREATE FUNCTION public.server_poll_retirement_final_guard() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF NOT EXISTS(SELECT 1 FROM public.mcp_operation_replay_tombstones t
+ WHERE t.operation_id=NEW.execution_id AND t.connection_id=NEW.connection_id AND t.action_id='servers.poll'
+ AND t.target_global AND NOT EXISTS(SELECT 1 FROM public.mcp_plans p WHERE p.id=t.plan_id))
+ OR EXISTS(SELECT 1 FROM public.mcp_operations o WHERE o.id=NEW.execution_id)
+ OR NOT public.server_poll_storage_accounting_valid()
+ THEN RAISE EXCEPTION 'poll retirement is incomplete'; END IF;
+ RETURN NULL;
+END $$;
+CREATE CONSTRAINT TRIGGER server_poll_retirement_final_guard AFTER UPDATE ON public.server_poll_archives
+ DEFERRABLE INITIALLY DEFERRED FOR EACH ROW WHEN(OLD.version=1 AND NEW.version=2)
+ EXECUTE FUNCTION public.server_poll_retirement_final_guard();
+
+CREATE OR REPLACE FUNCTION server_poll_storage_admission_guard() RETURNS trigger LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE retention integer; charged integer; r public.server_poll_archives%ROWTYPE;
+BEGIN
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ IF TG_OP='DELETE' THEN
+ IF NOT public.server_poll_storage_gc_allowed(OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id) THEN RAISE EXCEPTION 'poll lifetime or children prevent admission deletion'; END IF;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions-CASE WHEN OLD.storage_state='full' THEN 1 ELSE 0 END,
+ compacted_admissions=compacted_admissions-CASE WHEN OLD.storage_state='compacted' THEN 1 ELSE 0 END,
+ archive_bytes=archive_bytes-COALESCE(OLD.archive_bytes,0),
+ reserved_rows=reserved_rows-CASE WHEN OLD.storage_state='full' THEN 4019 ELSE 2 END,
+ reserved_bytes=reserved_bytes-CASE WHEN OLD.storage_state='full' THEN 8421376 ELSE 32768+OLD.archive_bytes END
+ WHERE scope IN('global','owner:'||OLD.owner_id);
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll quota refund mismatch'; END IF; RETURN OLD;
+ END IF;
+ IF TG_OP='UPDATE' THEN
+ IF OLD.storage_state='compacted' AND NEW.storage_state='compacted'
+ AND current_setting('mm.poll_retire_receipt',true)=OLD.receipt_id::text
+ AND (to_jsonb(OLD)-'archive_bytes')=(to_jsonb(NEW)-'archive_bytes') THEN
+ SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND version=2;
+ IF NOT FOUND OR r.ciphertext_bytes<>NEW.archive_bytes OR NEW.archive_bytes>OLD.archive_bytes
+ OR r.execution_id<>OLD.execution_id OR r.connection_id<>OLD.connection_id OR r.owner_id<>OLD.owner_id
+ THEN RAISE EXCEPTION 'retired poll charge source mismatch'; END IF;
+ UPDATE public.server_poll_storage_usage
+ SET archive_bytes=archive_bytes-OLD.archive_bytes+NEW.archive_bytes,
+ reserved_bytes=reserved_bytes-OLD.archive_bytes+NEW.archive_bytes
+ WHERE scope IN ('global','owner:'||OLD.owner_id) AND compacted_admissions>=1 AND archive_bytes>=OLD.archive_bytes;
+ GET DIAGNOSTICS charged=ROW_COUNT;
+ IF charged<>2 THEN RAISE EXCEPTION 'retired poll charge adjustment mismatch'; END IF;
+ RETURN NEW;
+ END IF;
+ -- This durable one-shot marker is written and ACKed in its OWN transaction
+ -- before archive construction. A committed/unknown claim never resets and
+ -- the worker never retries destructive work against an already claimed full
+ -- source. Claim time is maintenance metadata, not renewed execution activity.
+ IF OLD.storage_state='full' AND NEW.storage_state='full' AND OLD.compaction_claim IS NULL AND OLD.compaction_claimed_at IS NULL AND OLD.compaction_claim_xid IS NULL
+ AND NEW.compaction_claim IS NOT NULL AND NEW.compaction_claim_xid IS NULL
+ AND(to_jsonb(OLD)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])=(to_jsonb(NEW)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])
+ AND public.server_poll_storage_compact_allowed(OLD.receipt_id)
+ THEN NEW.compaction_claimed_at:=clock_timestamp(); NEW.compaction_claim_xid:=pg_current_xact_id(); RETURN NEW; END IF;
+ IF(to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) IS DISTINCT FROM
+ (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) THEN RAISE EXCEPTION 'poll admission identity is immutable'; END IF;
+ IF OLD.storage_state<>'full' THEN RAISE EXCEPTION 'compacted poll identity cannot reopen or change'; END IF;
+ IF NEW.storage_state='compacted' THEN
+ SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND compaction_xid=pg_current_xact_id();
+ IF NOT FOUND OR NEW.used_rows<>OLD.used_rows OR NEW.used_bytes<>OLD.used_bytes OR NEW.claim_token IS DISTINCT FROM OLD.claim_token
+ OR NEW.claim_attempted_at IS DISTINCT FROM OLD.claim_attempted_at OR NEW.archive_bytes<>r.ciphertext_bytes OR NEW.original_activity_at<>r.original_activity_at
+ OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)
+ OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)
+ THEN RAISE EXCEPTION 'poll compaction requires the complete current-transaction archive'; END IF;
+ NEW.compact_at:=r.created_at;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions-1,compacted_admissions=compacted_admissions+1,
+ archive_bytes=archive_bytes+r.ciphertext_bytes,reserved_rows=reserved_rows-4019+2,reserved_bytes=reserved_bytes-8421376+32768+r.ciphertext_bytes
+ WHERE scope IN('global','owner:'||OLD.owner_id) AND admissions>=1;
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll compaction charge mismatch'; END IF;
+ RETURN NEW;
+ END IF;
+ IF NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL THEN RAISE EXCEPTION 'full poll cannot carry archive metadata'; END IF;
+ IF OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL
+ AND NEW.used_rows=OLD.used_rows AND NEW.used_bytes=OLD.used_bytes AND OLD.authority_expires_at>clock_timestamp()
+ THEN NEW.claim_attempted_at:=clock_timestamp(); RETURN NEW; END IF;
+ IF OLD.claim_token IS NOT DISTINCT FROM NEW.claim_token AND OLD.claim_attempted_at IS NOT DISTINCT FROM NEW.claim_attempted_at
+ AND NEW.used_rows=OLD.used_rows+1 AND NEW.used_bytes>OLD.used_bytes THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'poll admission cannot refresh, reopen or refund itself';
+ END IF;
+ IF NEW.storage_state<>'full' OR NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL
+ OR NEW.compaction_claim IS NOT NULL OR NEW.compaction_claimed_at IS NOT NULL OR NEW.compaction_claim_xid IS NOT NULL
+ OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'new poll requires full reservation and exact ledger'; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 OR NEW.authority_issued_at>clock_timestamp() OR NEW.authority_expires_at<=clock_timestamp()
+ OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL OR NEW.used_rows<>0 OR NEW.used_bytes<>0 THEN RAISE EXCEPTION 'new poll admission needs original live authority'; END IF;
+ IF EXISTS(SELECT 1 FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id OR(identity_kind=NEW.identity_kind AND execution_id=NEW.execution_id)) THEN RAISE EXCEPTION 'poll identity already spent'; END IF;
+ NEW.created_at:=clock_timestamp(); NEW.retention_days:=retention; NEW.safety_ms:=60000;
+ NEW.gc_not_before:=NEW.authority_expires_at+make_interval(days=>retention)+interval '60 seconds';
+ INSERT INTO public.server_poll_storage_usage(scope) VALUES('owner:'||NEW.owner_id) ON CONFLICT DO NOTHING;
+ IF(SELECT count(*) FROM public.server_poll_storage_usage WHERE scope IN('global','owner:'||NEW.owner_id)
+ AND admissions2 THEN RAISE EXCEPTION 'poll admission quota exhausted'; END IF;
+ UPDATE public.server_poll_storage_usage SET admissions=admissions+1,reserved_rows=reserved_rows+4019,reserved_bytes=reserved_bytes+8421376 WHERE scope IN('global','owner:'||NEW.owner_id);
+ GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll admission quota unavailable'; END IF;
+ RETURN NEW;
+END $$;
+CREATE OR REPLACE FUNCTION server_poll_storage_gc_allowed(id uuid) RETURNS boolean LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE a public.server_poll_storage_admissions%ROWTYPE; retention integer; activity timestamptz; terminal_at timestamptz;
+BEGIN
+ IF current_setting('mm.poll_storage_gc',true) IS DISTINCT FROM 'on' THEN RETURN false; END IF;
+ PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));
+ SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;
+ IF NOT FOUND OR a.authority_expires_at>=clock_timestamp() OR a.gc_not_before>=clock_timestamp() THEN RETURN false; END IF;
+ SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE mcp_settings.id=1 FOR SHARE;
+ IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;
+ terminal_at:=a.created_at;
+ IF a.identity_kind='mcp' THEN
+ IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;
+ BEGIN
+ SELECT GREATEST(o.finished_at,p.expires_at) INTO terminal_at FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id JOIN public.mcp_connections c ON c.id=o.connection_id
+ WHERE o.id=a.execution_id AND o.connection_id=a.connection_id AND c.owner_id=a.owner_id AND p.operation_id='servers.poll'
+ AND o.state IN('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL FOR UPDATE OF o,p NOWAIT;
+ IF NOT FOUND THEN
+ IF a.storage_state<>'compacted' OR EXISTS(SELECT 1 FROM public.mcp_operations o WHERE o.id=a.execution_id) OR NOT EXISTS (
+ SELECT 1 FROM public.mcp_operation_replay_tombstones t JOIN public.mcp_connections c ON c.id=t.connection_id
+ WHERE t.operation_id=a.execution_id AND t.connection_id=a.connection_id AND c.owner_id=a.owner_id
+ AND t.action_id='servers.poll' AND t.target_global AND cardinality(t.target_server_ids)>0
+ AND NOT EXISTS(SELECT 1 FROM public.mcp_plans WHERE mcp_plans.id=t.plan_id)
+ ) OR EXISTS(SELECT 1 FROM public.server_poll_archives r WHERE r.receipt_id=id AND
+ (r.version<>2 OR r.execution_id<>a.execution_id OR r.connection_id<>a.connection_id OR r.owner_id<>a.owner_id
+ OR r.original_activity_at IS DISTINCT FROM a.original_activity_at OR r.original_expires_at<>a.authority_expires_at
+ OR r.binding_proof<>a.binding_proof OR r.context_proof<>a.context_proof OR r.ciphertext_bytes<>a.archive_bytes))
+ THEN RETURN false; END IF;
+ terminal_at:=a.original_activity_at;
+ END IF;
+ IF terminal_at IS NULL THEN RETURN false; END IF;
+ EXCEPTION WHEN lock_not_available THEN RETURN false; END;
+ END IF;
+ IF a.storage_state='compacted' THEN activity:=GREATEST(a.original_activity_at,a.authority_expires_at,terminal_at);
+ ELSE
+ SELECT GREATEST(a.authority_expires_at,a.created_at,COALESCE(a.claim_attempted_at,a.created_at),terminal_at,
+ COALESCE((SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM public.server_poll_quarantines WHERE receipt_id=id),a.created_at)) INTO activity;
+ END IF;
+ RETURN isfinite(activity) AND activity+make_interval(days=>GREATEST(a.retention_days,retention))+a.safety_ms*interval '1 millisecond'1 AND NOT EXISTS(
+ SELECT 1 FROM public.server_poll_storage_admissions a WHERE a.receipt_id=OLD.receipt_id
+ ) THEN RETURN OLD; END IF;
+ RAISE EXCEPTION 'poll retirement claim cannot be replaced or reopened';
+END $$;
+CREATE TRIGGER server_poll_retirement_claim_immutable
+ BEFORE INSERT OR UPDATE OR DELETE ON public.server_poll_retirement_claims
+ FOR EACH ROW EXECUTE FUNCTION public.server_poll_retirement_claim_immutable();
+CREATE TRIGGER server_poll_retirement_claim_no_truncate
+ BEFORE TRUNCATE ON public.server_poll_retirement_claims
+ FOR EACH STATEMENT EXECUTE FUNCTION public.server_poll_retirement_claim_immutable();
+CREATE FUNCTION public.server_poll_retirement_requires_claim() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF NOT EXISTS(SELECT 1 FROM public.server_poll_retirement_claims c
+ WHERE c.receipt_id=OLD.receipt_id AND c.old_archive_proof=OLD.archive_proof
+ AND c.claim_token::text=current_setting('mm.poll_retire_claim',true)
+ AND c.claim_xid<>pg_current_xact_id())
+ THEN RAISE EXCEPTION 'poll retirement requires prior exact claim'; END IF;
+ RETURN NEW;
+END $$;
+CREATE TRIGGER server_poll_retirement_requires_claim BEFORE UPDATE ON public.server_poll_archives
+ FOR EACH ROW WHEN(OLD.version=1 AND NEW.version=2)
+ EXECUTE FUNCTION public.server_poll_retirement_requires_claim();
+INSERT INTO public.schema_migrations(id) VALUES ('0047_server_poll_retirement_claims') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0048_mcp_ordinary_retirement_claims.sql b/backend/drizzle/0048_mcp_ordinary_retirement_claims.sql
new file mode 100644
index 00000000..c0107ac5
--- /dev/null
+++ b/backend/drizzle/0048_mcp_ordinary_retirement_claims.sql
@@ -0,0 +1,27 @@
+BEGIN;
+CREATE TABLE public.mcp_ordinary_retirement_claims (
+ operation_id uuid PRIMARY KEY,
+ plan_id uuid NOT NULL UNIQUE,
+ connection_id uuid NOT NULL REFERENCES public.mcp_connections(id),
+ source_proof text NOT NULL CHECK(source_proof ~ '^[0-9a-f]{64}$'),
+ claim_token uuid NOT NULL,
+ claim_xid xid8 NOT NULL DEFAULT pg_current_xact_id()
+);
+CREATE FUNCTION public.mcp_ordinary_retirement_claim_immutable() RETURNS trigger
+LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(
+ SELECT 1 FROM public.mcp_operations o JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ WHERE o.id=NEW.operation_id AND o.plan_id=NEW.plan_id AND o.connection_id=NEW.connection_id
+ AND o.state='applied' AND o.verification='passed' AND o.error_code IS NULL
+ AND isfinite(o.finished_at) AND o.finished_at>'version') IS NOT DISTINCT FROM '1'
+ AND (source->>'receiptId') IS NOT DISTINCT FROM receipt_id::text
+ AND (source->>'executionId') IS NOT DISTINCT FROM operation_id::text)
+);
+CREATE FUNCTION public.server_probe_retired_source_immutable() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$
+BEGIN
+ RAISE EXCEPTION 'retired diagnostic source is immutable';
+END $$;
+CREATE TRIGGER server_probe_retired_source_immutable
+ BEFORE UPDATE OR DELETE ON public.server_probe_retired_sources
+ FOR EACH ROW EXECUTE FUNCTION public.server_probe_retired_source_immutable();
+CREATE TRIGGER server_probe_retired_source_no_truncate BEFORE TRUNCATE ON public.server_probe_retired_sources
+ FOR EACH STATEMENT EXECUTE FUNCTION public.server_probe_retired_source_immutable();
+INSERT INTO public.schema_migrations(id) VALUES ('0050_server_probe_retired_sources') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0051_server_probe_retirement_claims.sql b/backend/drizzle/0051_server_probe_retirement_claims.sql
new file mode 100644
index 00000000..15e52072
--- /dev/null
+++ b/backend/drizzle/0051_server_probe_retirement_claims.sql
@@ -0,0 +1,52 @@
+BEGIN;
+CREATE TABLE public.server_probe_retirement_claims (
+ receipt_id uuid PRIMARY KEY,
+ operation_id uuid NOT NULL UNIQUE,
+ plan_id uuid NOT NULL UNIQUE,
+ connection_id uuid NOT NULL,
+ source_proof text NOT NULL CHECK(source_proof ~ '^[a-f0-9]{64}$'),
+ claim_token uuid NOT NULL,
+ claim_xid xid8 NOT NULL DEFAULT pg_current_xact_id()
+);
+CREATE FUNCTION public.server_probe_retirement_claim_guard() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public SET TimeZone='UTC' AS $$
+BEGIN
+ IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(
+ SELECT 1 FROM public.server_probe_storage_admissions a
+ JOIN public.mcp_operations o ON o.id=a.execution_id
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_connections c ON c.id=o.connection_id AND c.owner_id=a.owner_id
+ WHERE a.receipt_id=NEW.receipt_id AND a.identity_kind='mcp' AND a.claim_token IS NULL
+ AND a.claim_attempted_at IS NOT NULL AND a.cancelled_at IS NULL AND a.purged_at IS NULL
+ AND o.id=NEW.operation_id AND p.id=NEW.plan_id AND c.id=NEW.connection_id
+ AND o.state='applied' AND o.verification='inconclusive' AND o.error_code IS NULL
+ AND isfinite(o.finished_at) AND o.finished_atpg_current_xact_id() AND r.claim_token::text=current_setting('mm.probe_retirement_claim',true)
+ AND NEW.source->>'planId'=r.plan_id::text AND NEW.source->>'connectionId'=r.connection_id::text
+ AND NEW.source->>'ownerId'=a.owner_id AND NEW.source->>'bindingProof'=a.binding_proof
+ AND NEW.source->'serverIds'=to_jsonb(t.target_server_ids)
+ ) THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'diagnostic archive requires an exact committed retirement claim';
+END $$;
+CREATE TRIGGER server_probe_retired_source_insert_guard BEFORE INSERT ON public.server_probe_retired_sources
+ FOR EACH ROW EXECUTE FUNCTION public.server_probe_retired_source_insert_guard();
+INSERT INTO public.schema_migrations(id) VALUES ('0051_server_probe_retirement_claims') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0052_server_probe_retired_gc.sql b/backend/drizzle/0052_server_probe_retired_gc.sql
new file mode 100644
index 00000000..18fc51ea
--- /dev/null
+++ b/backend/drizzle/0052_server_probe_retired_gc.sql
@@ -0,0 +1,96 @@
+BEGIN;
+ALTER TABLE public.server_probe_retired_sources
+ DROP CONSTRAINT server_probe_retired_sources_receipt_id_fkey,
+ ADD CONSTRAINT server_probe_retired_sources_receipt_id_fkey
+ FOREIGN KEY(receipt_id) REFERENCES public.server_probe_storage_admissions(receipt_id) ON DELETE CASCADE;
+
+CREATE FUNCTION public.server_probe_retired_gc_allowed(target_receipt uuid,current_retention integer) RETURNS boolean
+LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+DECLARE activity timestamptz; retained_days integer; safety integer;
+BEGIN
+ IF current_setting('mm.probe_storage_gc',true) IS DISTINCT FROM 'on'
+ OR current_setting('mm.probe_retired_gc_receipt',true) IS DISTINCT FROM target_receipt::text THEN RETURN false; END IF;
+ SELECT (r.source->>'activityAt')::timestamptz,a.retention_days,a.safety_ms
+ INTO activity,retained_days,safety
+ FROM public.server_probe_retired_sources r
+ JOIN public.server_probe_storage_admissions a ON a.receipt_id=r.receipt_id AND a.execution_id=r.operation_id
+ JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=r.operation_id
+ JOIN public.mcp_connections c ON c.id=t.connection_id AND c.owner_id=a.owner_id
+ WHERE r.receipt_id=target_receipt AND r.proof=current_setting('mm.probe_retired_gc_proof',true)
+ AND a.identity_kind='mcp' AND a.cancelled_at IS NULL AND a.claim_token IS NULL AND isfinite(a.claim_attempted_at)
+ AND t.action_id='servers.probes.run' AND NOT t.target_global
+ AND r.source->>'planId'=t.plan_id::text AND r.source->>'connectionId'=c.id::text
+ AND r.source->'serverIds'=to_jsonb(t.target_server_ids) AND r.source->>'ownerId'=a.owner_id
+ AND r.source->>'bindingProof'=a.binding_proof
+ AND (r.source->>'authorityExpiresAt')::timestamptz=a.authority_expires_at
+ AND (r.source->>'gcNotBefore')::timestamptz=a.gc_not_before
+ AND (r.source->>'retentionDays')::int=a.retention_days AND (r.source->>'safetyMs')::int=a.safety_ms
+ AND isfinite(a.authority_expires_at) AND isfinite(a.gc_not_before)
+ AND a.authority_expires_atactivity))
+ OR EXISTS(SELECT 1 FROM public.server_probe_execution_stages s WHERE s.receipt_id=target_receipt
+ AND GREATEST(s.created_at,COALESCE(s.received_at,s.created_at))>activity)
+ THEN RETURN false; END IF;
+ RETURN activity+make_interval(days=>GREATEST(retained_days,current_retention))
+ +GREATEST(safety,60000)*interval '1 millisecond'=clock_timestamp() OR a.authority_expires_at>=clock_timestamp() THEN RETURN false; END IF;
+ SELECT settings.requests_retention_days INTO current_retention FROM mcp_settings settings WHERE settings.id=1;
+ IF current_retention IS NULL OR current_retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;
+ IF EXISTS(SELECT 1 FROM public.server_probe_retired_sources WHERE receipt_id=id) THEN
+ RETURN public.server_probe_retired_gc_allowed(id,current_retention);
+ END IF;
+ terminal_at:=a.created_at;
+ IF a.identity_kind='mcp' THEN
+ SELECT GREATEST(o.finished_at,p.expires_at,COALESCE(cancellation.created_at,o.finished_at)) INTO terminal_at
+ FROM mcp_operations o JOIN mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN mcp_connections owner_connection ON owner_connection.id=o.connection_id
+ LEFT JOIN mcp_diagnostic_cancellations cancellation ON cancellation.operation_id=o.id
+ WHERE o.id=a.execution_id AND owner_connection.owner_id=a.owner_id AND p.operation_id='servers.probes.run'
+ AND o.state IN ('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL
+ AND (cancellation.operation_id IS NULL OR(cancellation.connection_id=o.connection_id AND cancellation.actor_id=a.owner_id))
+ FOR UPDATE OF o,p,owner_connection;
+ IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;
+ END IF;
+ SELECT GREATEST(a.created_at,a.authority_expires_at,terminal_at,COALESCE(a.cancelled_at,a.created_at),
+ COALESCE((SELECT finished_at FROM server_probe_executions WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT created_at FROM server_probe_execution_quarantines WHERE receipt_id=id),a.created_at),
+ COALESCE((SELECT max(GREATEST(created_at,COALESCE(received_at,created_at))) FROM server_probe_execution_stages WHERE receipt_id=id),a.created_at)) INTO activity;
+ RETURN activity+make_interval(days=>GREATEST(a.retention_days,current_retention))+a.safety_ms*interval '1 millisecond'>'version') IS NOT DISTINCT FROM '1'
+ AND (source->>'executionId') IS NOT DISTINCT FROM operation_id::text
+ AND (source->>'receiptId') IS NOT DISTINCT FROM receipt_id::text)
+);
+CREATE FUNCTION public.server_probe_terminal_proof_guard() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF TG_OP='INSERT' THEN
+ IF EXISTS(
+ SELECT 1 FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_connections c ON c.id=o.connection_id
+ JOIN public.server_probe_storage_admissions a ON a.execution_id=o.id AND a.identity_kind='mcp' AND a.owner_id=c.owner_id
+ JOIN public.server_probe_executions j ON j.receipt_id=a.receipt_id
+ JOIN public.server_probe_execution_payloads b ON b.receipt_id=a.receipt_id AND b.receipt_proof=j.receipt_proof
+ WHERE o.id=NEW.operation_id AND a.receipt_id=NEW.receipt_id AND a.purged_at IS NULL AND a.cancelled_at IS NULL
+ AND a.claim_token IS NULL AND a.claim_attempted_at IS NOT NULL
+ AND o.state='applied' AND o.verification='inconclusive' AND o.error_code IS NULL
+ AND p.state='completed' AND p.operation_id='servers.probes.run' AND p.operation_version=1
+ AND j.state='completed' AND j.execution_id=o.id AND j.mcp_connection_id=c.id AND j.actor_id=c.owner_id
+ AND NEW.source->>'connectionId'=c.id::text AND NEW.source->>'planId'=p.id::text
+ AND NEW.source->>'ownerId'=a.owner_id AND NEW.source->>'bindingProof'=a.binding_proof
+ AND NEW.source->>'receiptProof'=b.receipt_proof
+ AND NEW.source->>'ciphertextSha256'=encode(sha256(convert_to(b.receipt_ciphertext,'UTF8')),'hex')
+ ) THEN RETURN NEW; END IF;
+ ELSIF TG_OP='DELETE' THEN
+ IF EXISTS(
+ SELECT 1 FROM public.server_probe_retirement_claims r
+ JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=r.operation_id AND t.plan_id=r.plan_id AND t.connection_id=r.connection_id
+ WHERE r.operation_id=OLD.operation_id AND r.receipt_id=OLD.receipt_id AND r.source_proof=OLD.source_proof
+ AND r.claim_xid<>pg_current_xact_id() AND r.claim_token::text=current_setting('mm.probe_retirement_claim',true)
+ AND t.action_id='servers.probes.run' AND NOT t.target_global AND t.idempotency_digest=OLD.idempotency_digest
+ AND OLD.source->'serverIds'=to_jsonb(t.target_server_ids)
+ ) THEN RETURN OLD; END IF;
+ END IF;
+ RAISE EXCEPTION 'diagnostic terminal proof must match its original source or exact retirement claim';
+END $$;
+CREATE TRIGGER server_probe_terminal_proof_guard BEFORE INSERT OR UPDATE OR DELETE
+ ON public.server_probe_terminal_proofs FOR EACH ROW EXECUTE FUNCTION public.server_probe_terminal_proof_guard();
+CREATE TRIGGER server_probe_terminal_proof_no_truncate BEFORE TRUNCATE
+ ON public.server_probe_terminal_proofs FOR EACH STATEMENT EXECUTE FUNCTION public.server_probe_terminal_proof_guard();
+
+CREATE OR REPLACE FUNCTION public.server_probe_retirement_claim_guard() RETURNS trigger
+LANGUAGE plpgsql SET search_path=pg_catalog,public SET TimeZone='UTC' AS $$
+BEGIN
+ IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(
+ SELECT 1 FROM public.mcp_operations o
+ JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ JOIN public.mcp_connections c ON c.id=o.connection_id
+ WHERE o.id=NEW.operation_id AND p.id=NEW.plan_id AND c.id=NEW.connection_id
+ AND o.state='applied' AND o.verification='inconclusive' AND o.error_code IS NULL
+ AND isfinite(o.finished_at) AND o.finished_at>'ownerId'=c.owner_id AND f.source->>'connectionId'=c.id::text AND f.source->>'planId'=p.id::text)
+ AND NOT EXISTS(SELECT 1 FROM public.server_probe_storage_admissions a
+ WHERE a.receipt_id=NEW.receipt_id OR(a.identity_kind='mcp' AND a.execution_id=o.id))))
+ ) THEN RETURN NEW; END IF;
+ RAISE EXCEPTION 'diagnostic retirement claim cannot be replaced or reopened';
+END $$;
+INSERT INTO public.schema_migrations(id) VALUES ('0053_server_probe_terminal_proofs') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0054_mcp_geoip_retirement.sql b/backend/drizzle/0054_mcp_geoip_retirement.sql
new file mode 100644
index 00000000..6b59b470
--- /dev/null
+++ b/backend/drizzle/0054_mcp_geoip_retirement.sql
@@ -0,0 +1,18 @@
+BEGIN;
+CREATE OR REPLACE FUNCTION public.mcp_ordinary_retirement_claim_immutable() RETURNS trigger
+LANGUAGE plpgsql SET TimeZone='UTC' SET search_path=pg_catalog,public AS $$
+BEGIN
+ IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(
+ SELECT 1 FROM public.mcp_operations o JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id
+ WHERE o.id=NEW.operation_id AND o.plan_id=NEW.plan_id AND o.connection_id=NEW.connection_id
+ AND o.state='applied' AND o.verification='passed' AND o.error_code IS NULL
+ AND isfinite(o.finished_at) AND o.finished_at>'kind'='service'
+ AND s.intended_state->>'service'='routing.community.scoped.recover'
+ AND s.intended_state->'input'->>'mode'='manual'
+ AND s.intended_state->'input'->>'sourceOperationId'=NEW.source_operation_id::text
+ AND s.intended_state->'input'->>'receiptId'=NEW.recovery_receipt_id::text
+ ) THEN RAISE EXCEPTION 'manual inverse requires current exact running recovery'; END IF;
+ RETURN NEW;
+END $$;
+INSERT INTO public.schema_migrations(id) VALUES('0056_mcp_manual_inverse_recovery_v8') ON CONFLICT(id) DO NOTHING;
+COMMIT;
diff --git a/backend/drizzle/0057_mcp_routing_charge_audit_index.sql b/backend/drizzle/0057_mcp_routing_charge_audit_index.sql
new file mode 100644
index 00000000..c5e17796
--- /dev/null
+++ b/backend/drizzle/0057_mcp_routing_charge_audit_index.sql
@@ -0,0 +1,8 @@
+BEGIN;
+
+CREATE INDEX mcp_audit_routing_charge_profile_window
+ ON public.mcp_audit (connection_id, (payload -> 'anchor' ->> 'profileId'), created_at, id)
+ WHERE action = 'routing.charge.admitted';
+
+INSERT INTO public.schema_migrations (id) VALUES ('0057_mcp_routing_charge_audit_index') ON CONFLICT (id) DO NOTHING;
+COMMIT;
diff --git a/backend/mcp-coverage.json b/backend/mcp-coverage.json
new file mode 100644
index 00000000..df94ca49
--- /dev/null
+++ b/backend/mcp-coverage.json
@@ -0,0 +1,2265 @@
+{
+ "version": 1,
+ "routes": [
+ {
+ "method": "DELETE",
+ "path": "/api/backups/:id",
+ "status": "mediated",
+ "operations": [
+ "backups.delete"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/firewall/address-lists",
+ "status": "mediated",
+ "operations": [
+ "firewall.addressLists.delete"
+ ],
+ "reason": "Общий REST/MCP address-list сервис: scoped ID, human plan, консервативные защиты зависимых правил, полный stable proof, отдельная проверка expiry window, shared locks/read-back/revision/no retry."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/firewall/rules",
+ "status": "mediated",
+ "operations": [
+ "firewall.rules.delete"
+ ],
+ "reason": "Общий REST/MCP сервис формы Firewall: человеческий sealed plan, scoped native ID, полный matcher/order proof, статическая цель, shared locks, read-back, отдельный статус ревизии и отсутствие retry."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/gre/tunnels",
+ "status": "mediated",
+ "operations": [
+ "network.gre.delete"
+ ],
+ "reason": "Общий REST/MCP GRE business executor: интерфейс и v4/v6 адреса, staged disabled, opaque native proof/dependencies, PSK purpose reference, protections/budget/locks, per-command read-back, partial/unknown без retry; SQL/HTTP проверены."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/ipsec/certs/:serverId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.certificates.delete"
+ ],
+ "reason": "Общий REST/MCP single certificate DELETE любого выбранного сертификата: force только для peer/identity ссылок, CA/CRL guards без обхода, native ID/private proof, intent/read-back, история и exact VERIFIED; SQL/HTTP any-cert/force/alias/lost/revoke/ABA/privacy приняты. Native force-reference поведение принимается отдельно на CHR."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/ipsec/peers/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.peers.delete"
+ ],
+ "reason": "Общий REST/MCP сервис принят SQL/HTTP: права и human approval, private source fences, bounded transport, точная семантика, partial/unknown без повторов; сетевой forwarding не заявляется."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/ipsec/server/:serverId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.server.delete"
+ ],
+ "reason": "Полный общий REST/MCP server removal: точный ordered manifest, зависимости foreign MC/pool и peer/certificate, полный certificate graph и объявленные CA cascade, preservation profiles/proposals, staged ACK/private read-back и история. Human/server/protection/budget guards; unknown не повторяется. SQL/HTTP parity, runtime countdown и dynamic policy exclusions приняты; настоящий CHR cascade отдельно не проверялся."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/ipsec/users/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.users.delete"
+ ],
+ "reason": "Общий REST/MCP executor полного удаления клиента с необязательным сертификатом, dependency/source proofs, последовательными intent/read-back, managed-only историей и SQL/HTTP-приёмкой без replay."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/mcp/grants/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/mcp/management-channels/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/mcp/oauth/clients/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/mcp/protections/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/servers/:id",
+ "status": "mediated",
+ "operations": [
+ "servers.delete"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/users/:id",
+ "status": "mediated",
+ "operations": [
+ "users.delete"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/users/:id/bindings/:bindingId",
+ "status": "mediated",
+ "operations": [
+ "users.binding_remove"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/wireguard/interfaces/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.interfaces.delete",
+ "ros.wireguard.delete"
+ ],
+ "reason": "Общий REST/MCP каскад с запечатанными зависимостями, отдельным бюджетом каждой команды, read-back и остановкой без повтора; native alias не приобретает каскадных полномочий."
+ },
+ {
+ "method": "DELETE",
+ "path": "/api/wireguard/peers/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.peers.delete",
+ "ros.wireguard_peer.delete"
+ ],
+ "reason": "Общий REST/MCP сервис удаления peer: подтверждённый parent, привязки пользователей, полный непрозрачный private proof, защита сервера/интерфейса, drift и endpoint ABA, одна команда DELETE, проверка остальных peers, partial/unknown без повтора и отдельный receipt ревизии."
+ },
+ {
+ "method": "DELETE",
+ "path": "/mcp",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/.well-known/oauth-authorization-server",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/.well-known/oauth-protected-resource",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/alerts",
+ "status": "mediated",
+ "operations": [
+ "alerts.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/alerts/outbox",
+ "status": "mediated",
+ "operations": [
+ "alerts.outbox.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/auth/config",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Bootstrap/health авторизации интерфейса; бизнес-операция MCP отсутствует."
+ },
+ {
+ "method": "GET",
+ "path": "/api/backups",
+ "status": "mediated",
+ "operations": [
+ "backups.list"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/backups/:id/download",
+ "status": "mediated",
+ "operations": [
+ "backups.download"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "GET",
+ "path": "/api/backups/jobs/:jobId",
+ "status": "mediated",
+ "operations": [
+ "backups.jobs.read"
+ ],
+ "reason": "Общий реестр фактической REST backup-очереди: доступ только к целиком разрешённой задаче, проверка устройств и прогресса, ограниченные страницы результатов, без notes/имён/путей/текстов ошибок. Временные задачи очищаются при закрытии приложения и restore; несовпадающие или неоднозначные ID не угадываются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/backups/schedule",
+ "status": "mediated",
+ "operations": [
+ "backups.schedule.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/backups/storage",
+ "status": "mediated",
+ "operations": [
+ "backups.storage.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/bfd/sessions",
+ "status": "mediated",
+ "operations": [
+ "routing.bfd.sessions.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/bgp/catalog",
+ "status": "mediated",
+ "operations": [
+ "routing.bgp.catalog.read"
+ ],
+ "reason": "Общие BGP catalog poll/parser; серверы ограничиваются до опроса, пагинация и failures сохраняются явно."
+ },
+ {
+ "method": "GET",
+ "path": "/api/bgp/sessions",
+ "status": "mediated",
+ "operations": [
+ "routing.bgp.sessions.read"
+ ],
+ "reason": "Общий readBgpSessionsForServer/parser и pollBgpCatalog; эффективный scope до SQL/native, серверная и строковая пагинация, failures/incomplete сохраняют частичный отказ вместо успешного пустого списка."
+ },
+ {
+ "method": "GET",
+ "path": "/api/bgp/sessions/raw/:id",
+ "status": "mediated",
+ "operations": [
+ "routing.bgp.sessions.raw.read"
+ ],
+ "reason": "Общий readRawBgpSessionsForServer, scope/disabled до native GET, bounded raw DTO с метаданными сервера и маскированием ключей до выдачи/аудита."
+ },
+ {
+ "method": "GET",
+ "path": "/api/certificates",
+ "status": "mediated",
+ "operations": [
+ "certificates.state.read"
+ ],
+ "reason": "Общий REST/MCP источник сертификатов с проверкой schema и clock offset; refresh только повторяет чтение без записи. Область до опроса, unknown в MCP, native keys исключены; HTTP/SQL parity и malformed failure проверены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/certificates/acme-settings",
+ "status": "mediated",
+ "operations": [
+ "certificates.acme.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/certificates/issue/:jobId",
+ "status": "mediated",
+ "operations": [
+ "certificates.jobs.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/certificates/renew-settings",
+ "status": "mediated",
+ "operations": [
+ "certificates.renew.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/certificates/state",
+ "status": "mediated",
+ "operations": [
+ "certificates.state.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/containers",
+ "status": "mediated",
+ "operations": [
+ "containers.state.read"
+ ],
+ "reason": "Общий REST/MCP collector контейнеров; область до опроса, стабильные страницы, explicit partial/unsupported, env values и cmd скрыты в MCP. Реальные HTTP/SQL тесты сравнивают legacy каталог и observed DTO."
+ },
+ {
+ "method": "GET",
+ "path": "/api/containers/state",
+ "status": "mediated",
+ "operations": [
+ "containers.state.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/events",
+ "status": "mediated",
+ "operations": [
+ "events.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/evobgp/settings",
+ "status": "mediated",
+ "operations": [
+ "evobgp.settings.read"
+ ],
+ "reason": "Общие readEvoBgpSettings/publicEvoBgpSettings без создания строки и без API-ключа; полный эффективный каталог проверяется до чтения."
+ },
+ {
+ "method": "GET",
+ "path": "/api/filters/gre-tunnels",
+ "status": "mediated",
+ "operations": [
+ "routing.gre.catalog.read"
+ ],
+ "reason": "Общие fetchServerFilters/pollGreCatalog с REST; разрешённые серверы отбираются до опроса, выдача ограничена, IPsec secret не передаётся, ошибки устройств сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/filters/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.filters.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/api/filters/rules",
+ "status": "mediated",
+ "operations": [
+ "routing.filters.catalog.read"
+ ],
+ "reason": "Общий REST/MCP live/cache reader BGP-in, scope до опроса/SQL, native order/unknown flags, scoped stale fallback; MCP observer не обновляет cache/revisions и не подтверждает эффекты parser hints."
+ },
+ {
+ "method": "GET",
+ "path": "/api/firewall/all",
+ "status": "mediated",
+ "operations": [
+ "firewall.state.read"
+ ],
+ "reason": "Общий listFirewallAll/fetchFirewallState с областью до HTTP; MCP получает observed flags/counters без legacy defaults, отдельные matcher-поля, пагинацию и failures. Неполные flags/ошибки не сохраняются как observed revision."
+ },
+ {
+ "method": "GET",
+ "path": "/api/firewall/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.firewall.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/api/geoip",
+ "status": "mediated",
+ "operations": [
+ "geoip.read"
+ ],
+ "reason": "Общий buildGeoipStatus: только локальные readers и метаданные; глобальная эффективная область проверяется до чтения."
+ },
+ {
+ "method": "GET",
+ "path": "/api/gre/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.gre.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/api/gre/tunnels",
+ "status": "mediated",
+ "operations": [
+ "network.gre.state.read"
+ ],
+ "reason": "Общий REST/MCP опрос GRE и IPv4/IPv6-адресов; ограничение серверов до чтения, страницы адресов, nullable-наблюдения, происхождение метаданных, PSK скрыт; MCP не сохраняет историю и не подтверждает forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/internet-path/latest",
+ "status": "mediated",
+ "operations": [
+ "routing.internet-path.latest.read"
+ ],
+ "reason": "Общий latest-row REST/MCP reader, scoped JSON-проекция в SQL до разбора скрытых записей, проверка server bindings и схемы, вложенная пагинация, известные нули/unknown и secret-free whitelist. Возвращается сохранённая интерпретация с возрастом/stale/clockSkew; она не доказывает текущий маршрут или forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/internet-path/settings",
+ "status": "mediated",
+ "operations": [
+ "internet-path.settings.read"
+ ],
+ "reason": "Общий сервис настроек коллектора; полная область серверов, защита зависимостей, подтверждённый план и проверка сохранения."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ipsec",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.state.read"
+ ],
+ "reason": "Общий REST polling/parser по выбранным серверам до HTTP; MCP использует safe observed DTO без key material, nullable flags/counters и явные failures. Пагинация каталогов и вложенных peers/VTEP/certificates, без обновления истории конфигурации или утверждения о forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ipsec/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.ipsec.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs",
+ "status": "mediated",
+ "operations": [
+ "logs.query"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/:id",
+ "status": "mediated",
+ "operations": [
+ "logs.get"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/:id/context",
+ "status": "mediated",
+ "operations": [
+ "logs.context"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/export",
+ "status": "mediated",
+ "operations": [
+ "logs.export"
+ ],
+ "reason": "Общий REST/MCP SQL-источник с server scope до бюджета 50000 строк/8 MiB; маскированная зашифрованная выгрузка с атомарной квотой и отдельным logs.export.read для чтения частей с повторной авторизацией."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/live",
+ "status": "mediated",
+ "operations": [
+ "logs.follow"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/settings",
+ "status": "mediated",
+ "operations": [
+ "logs.settings.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/logs/summary",
+ "status": "mediated",
+ "operations": [
+ "logs.summary"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/artifacts/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/audit",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/catalog",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/connections",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/connections/:id/grants",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/coverage",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/database/receipts/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/database/receipts/:id/audit-status",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Человеческая административная сверка аудита внешней квитанции восстановления: управление самим MCP, без отдельного AI-инструмента."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/devices/:serverId/:resource",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/devices/catalog",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/devices/:serverId/bridge-vlan/configuration",
+ "status": "mediated",
+ "operations": ["network.bridge-vlan.read"],
+ "reason": "Чтение связанной конфигурации bridge/VLAN через общую типизированную модель и проверку доступа MCP."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/drift",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/management-channels",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/oauth/clients",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/oauth/requests/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/operations",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/overview",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/plans",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/plans/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/protections",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/requests",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/routing-profiles",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/mcp/settings",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ospf/all",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.state.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ospf/catalog",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.catalog.read"
+ ],
+ "reason": "Общий OSPF/BFD catalog parser; область серверов ограничивается до опроса, коллекции и серверы выдаются страницами с явными failures."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ospf/instances",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.state.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ospf/interfaces",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.state.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/ospf/neighbors",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.state.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/recursive-routes",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.routes.read"
+ ],
+ "reason": "Общий REST/MCP reader с явным live/stale fallback, строгими effective properties, устойчивыми логическими ID и scoped SQL. MCP observer не меняет кеш/ревизии; malformed source не объявляется успешным пустым каталогом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/recursive-routes/catalog",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.catalog.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/recursive-routes/gateways",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.gateways.read"
+ ],
+ "reason": "Общий REST/MCP reader шлюзов приложения с агрегацией up/down/unknown, пагинацией и ограничением сервера до опроса; active не трактуется как подтверждение передачи пакетов."
+ },
+ {
+ "method": "GET",
+ "path": "/api/recursive-routes/gateways/catalog",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.gateways.catalog.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/recursive-routes/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.recursive-routes.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/api/scheduler/runs",
+ "status": "mediated",
+ "operations": [
+ "scheduler.runs"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/scheduler/status",
+ "status": "mediated",
+ "operations": [
+ "scheduler.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers",
+ "status": "mediated",
+ "operations": [
+ "servers.list"
+ ],
+ "reason": "Общий сервис каталога с ограничениями серверов и типизированным MCP-ответом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers-api-ping/settings",
+ "status": "mediated",
+ "operations": [
+ "servers.api-ping.settings.read"
+ ],
+ "reason": "Общий сервис настроек коллектора; полная область серверов, защита зависимостей, подтверждённый план и проверка сохранения."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id",
+ "status": "mediated",
+ "operations": [
+ "servers.list"
+ ],
+ "reason": "Общий сервис каталога с ограничениями серверов и типизированным MCP-ответом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/bgp/sessions",
+ "status": "mediated",
+ "operations": [
+ "routing.bgp.sessions.read"
+ ],
+ "reason": "Явный serverId в общем sessions-адаптере: общий reader/parser и poller, scope до опроса; диагностические ошибки/неизвестные счётчики не подменяются нулём."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/containers",
+ "status": "mediated",
+ "operations": [
+ "containers.state.read"
+ ],
+ "reason": "Общий REST/MCP collector контейнеров; область до опроса, стабильные страницы, explicit partial/unsupported, env values и cmd скрыты в MCP. Реальные HTTP/SQL тесты сравнивают legacy каталог и observed DTO."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/ospf",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.state.read"
+ ],
+ "reason": "Общие REST/MCP state-read сервисы и модели; legacy REST сохраняет defaults совместимости, MCP возвращает observed DTO с null/Unknown. Серверная область до опроса, пагинация, явные failures, areas и отдельное чтение BFD."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/ros-src-address",
+ "status": "mediated",
+ "operations": [
+ "servers.source-address.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/snapshots",
+ "status": "mediated",
+ "operations": [
+ "servers.snapshots.read"
+ ],
+ "reason": "Общий сервис REST/MCP с ограниченным типизированным DTO; права и серверная область проверяются до SQL/DNS/опроса, выдача ограничена, ошибки и неизвестные значения сохраняются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/vxlan",
+ "status": "mediated",
+ "operations": [
+ "network.vxlan.state.read"
+ ],
+ "reason": "Общий REST polling/parser по выбранным серверам до HTTP; MCP использует safe observed DTO без key material, nullable flags/counters и явные failures. Пагинация каталогов и вложенных peers/VTEP/certificates, без обновления истории конфигурации или утверждения о forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/servers/:id/wan-runtime",
+ "status": "mediated",
+ "operations": [
+ "servers.wan-runtime.read"
+ ],
+ "reason": "Общий readWanRuntimeForServer и модель IPv4/main: scope/disabled до native GET, bound DHCP, explicit unknown/ambiguous default и адреса, ошибка источника не выдаётся за пустое состояние; forwarding не подтверждается."
+ },
+ {
+ "method": "GET",
+ "path": "/api/sidebar-counts",
+ "status": "mediated",
+ "operations": [
+ "system.sidebar.counts.read"
+ ],
+ "reason": "Общий REST/MCP readSidebarCounts: SQL COUNT без DTO/привязок пользователей, global allow + все права источников, каталог до 100 серверов до native reads, coalescing, null/unknown отличается от zero, source interval и nonatomic snapshot; реальные SQL/permission/no-native-on-denial проверки."
+ },
+ {
+ "method": "GET",
+ "path": "/api/statistics",
+ "status": "mediated",
+ "operations": [
+ "statistics.read"
+ ],
+ "reason": "Общий SQL-сервис статистики/pivot; MCP требует выбранный сервер и период до 31 дня, обновляет только его интерфейсы."
+ },
+ {
+ "method": "GET",
+ "path": "/api/statistics/pivot",
+ "status": "mediated",
+ "operations": [
+ "statistics.pivot"
+ ],
+ "reason": "Общий SQL-сервис статистики/pivot; MCP требует выбранный сервер и период до 31 дня, обновляет только его интерфейсы."
+ },
+ {
+ "method": "GET",
+ "path": "/api/system/database/backup",
+ "status": "mediated",
+ "operations": [
+ "database.backup"
+ ],
+ "reason": "Общий backup service/event: обязательное human approval, полный global/server scope, exclusive drain, bounded real pg_dump, private temporary libpq service file, encrypted signed receipt и download только JWT владельца; SQL/HTTP проверены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/bound-interfaces",
+ "status": "mediated",
+ "operations": [
+ "traffic.bindings.history.read"
+ ],
+ "reason": "Общий расчёт привязок по сохранённым samples: scoped user eligibility до JSON/метрик, user/server/binding pages, скрытые peer keys/comments, known zero/unknown, binding drift proof и отсутствие RouterOS/планов записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.talkers.read"
+ ],
+ "reason": "Общая REST/MCP проекция разговоров; серверная область применяется до SQL и pending, источник ограничен, глобальные runtime/host-поля не раскрываются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/analytics",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.analytics.read"
+ ],
+ "reason": "Общий REST analytics engine в scoped режиме: сервер до SQL, topology без скрытых пользователей/ключей, обход общего кэша, bounded read и страницы, source/access/topology fences; retained данные и контекстные оценки скоростей явно разделены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/clients",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.clients.read"
+ ],
+ "reason": "Общие REST/MCP readers: scope до SQL/агрегации и каталогов, hidden-binding exclusion, bounded pages/counters, наблюдаемые retained rows вместо выдуманных online/wire rates; клиентская attribution и coverage явно ограничены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/exporters",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.exporters.read"
+ ],
+ "reason": "Общие REST/MCP readers: scope до SQL/агрегации и каталогов, hidden-binding exclusion, bounded pages/counters, наблюдаемые retained rows вместо выдуманных online/wire rates; клиентская attribution и coverage явно ограничены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/host-files",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.hostFiles.export"
+ ],
+ "reason": "Общий REST builder файлов NetFlow; полный глобальный допуск и человеческий план создают зашифрованный owner-only артефакт. Ключи не возвращаются MCP; скачивание через JWT повторно проверяет credential/права/область/источник/подпись/hash/срок."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/host-status",
+ "status": "mediated",
+ "operations": [
+ "netflow.host.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/live",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.live.read"
+ ],
+ "reason": "Ограниченное наблюдение через общий live-сервис REST/MCP: scope до источника, uncached выборки, отмена и отзыв доступа, общий лимит подписок и SQL/HTTP-приёмка."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/map-hops",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.map.read"
+ ],
+ "reason": "Общий REST map engine со scoped SQL/pending/topology, отказом от общего кэша/enrichment, проверками источника/настроек/доступа, лимитами и вложенными страницами; предполагаемые связи не выдаются за traceroute или forwarding proof."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/monthly",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.monthly.read"
+ ],
+ "reason": "Общие REST/MCP readers: scope до SQL/агрегации и каталогов, hidden-binding exclusion, bounded pages/counters, наблюдаемые retained rows вместо выдуманных online/wire rates; клиентская attribution и coverage явно ограничены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flow/settings",
+ "status": "mediated",
+ "operations": [
+ "netflow.settings.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/flows",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.talkers.read"
+ ],
+ "reason": "Общая REST/MCP проекция разговоров; серверная область применяется до SQL и pending, источник ограничен, глобальные runtime/host-поля не раскрываются."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/servers",
+ "status": "mediated",
+ "operations": [
+ "traffic.servers.history.read"
+ ],
+ "reason": "Общий REST/MCP reader сохранённой истории: scoped SQL/context до чтения, enabled каталог и страницы серверов, подтверждённый ноль/unknown masks, freshness, предел строк без частичных итогов, без RouterOS и observer writes."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/servers/:id",
+ "status": "mediated",
+ "operations": [
+ "traffic.server.history.read"
+ ],
+ "reason": "Общий REST/MCP расчёт сервера/интерфейса по сохранённым counters; scoped SQL до разбора, disabled/stale/error не становятся текущим нулём, known volume отдельно от coverage, bounded range/rows, без опроса."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/servers/:id/interfaces",
+ "status": "mediated",
+ "operations": [
+ "traffic.server.interfaces.read"
+ ],
+ "reason": "Общий REST/MCP интерфейсный reader за 24 часа: aggregate-only, nullable statusKnown/freshness, будущие samples исключены, страницы/предел строк, без current-state и forwarding claims."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/servers/:id/live",
+ "status": "mediated",
+ "operations": [
+ "traffic.live.read"
+ ],
+ "reason": "Общий readTrafficLiveSample; MCP возвращает ограниченную серию до трёх срезов вместо бесконечного SSE. Полнота суммы, направление RX/TX, отзыв доступа и смена источника проверяются перед каждым новым native-запросом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/settings",
+ "status": "mediated",
+ "operations": [
+ "traffic.settings.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/users",
+ "status": "mediated",
+ "operations": [
+ "traffic.users.history.read"
+ ],
+ "reason": "Общий расчёт REST/MCP: eligibility/scope до SQL JSON, исключение пользователей со скрытыми привязками, страницы пользователей/серверов/привязок, явный subtotal, guarded global unbound, freshness и проверка drift без observer writes."
+ },
+ {
+ "method": "GET",
+ "path": "/api/traffic/users/:id",
+ "status": "mediated",
+ "operations": [
+ "traffic.user.history.read"
+ ],
+ "reason": "Общий REST/MCP user-traffic builder с scoped SQL input вместо глобальной гидрации: nullable masks, peer-specific counters без вывода ключа, completeness выбранных источников, guards прав/server/binding proof."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/overview",
+ "status": "mediated",
+ "operations": [
+ "uptime.overview.read"
+ ],
+ "reason": "Общий readUptimeOverview; SQL scope до samples/provenance, bounded pages/window, unknown вместо UI zeros, явный historical fallback, повторные source/probe/grant checks, только stored data без сетевых команд и секретов."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/probes",
+ "status": "mediated",
+ "operations": [
+ "uptime.ping.probes.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/settings",
+ "status": "mediated",
+ "operations": [
+ "uptime.settings.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/sources/:id/interfaces",
+ "status": "mediated",
+ "operations": [
+ "uptime.ping.interfaces.read"
+ ],
+ "reason": "Общий reader/model интерфейсов: scope/disabled до native, effective disabled, unknown flag явно непригоден; пагинация и ошибки не подменяются пустым успехом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/speed-probes",
+ "status": "mediated",
+ "operations": [
+ "uptime.speed.probes.read"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/speed-test/endpoints/:id/interfaces",
+ "status": "mediated",
+ "operations": [
+ "uptime.speed.interfaces.read"
+ ],
+ "reason": "Общий reader/model с IPv4 address candidates, без выдуманных flags; bounded пагинация и адреса, неизвестное состояние видно отдельно."
+ },
+ {
+ "method": "GET",
+ "path": "/api/uptime/speed-test/runs",
+ "status": "mediated",
+ "operations": [
+ "uptime.speed.runs.read"
+ ],
+ "reason": "Общий readSpeedHistoryRuns/mapSpeedHistoryRun; оба serverId ограничены в SQL до LIMIT/OFFSET и parser, стабильный порядок, unknown/zero сохранены."
+ },
+ {
+ "method": "GET",
+ "path": "/api/users",
+ "status": "mediated",
+ "operations": [
+ "users.list"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/users/:id",
+ "status": "mediated",
+ "operations": [
+ "users.get"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "GET",
+ "path": "/api/users/interface-catalog",
+ "status": "mediated",
+ "operations": [
+ "users.interfaces.read"
+ ],
+ "reason": "Общий сервис каталога с ограничениями серверов и типизированным MCP-ответом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/users/interface-catalog-state",
+ "status": "mediated",
+ "operations": [
+ "users.interfaces.state"
+ ],
+ "reason": "Общий сервис каталога с ограничениями серверов и типизированным MCP-ответом."
+ },
+ {
+ "method": "GET",
+ "path": "/api/vxlan",
+ "status": "mediated",
+ "operations": [
+ "network.vxlan.state.read"
+ ],
+ "reason": "Общий REST polling/parser по выбранным серверам до HTTP; MCP использует safe observed DTO без key material, nullable flags/counters и явные failures. Пагинация каталогов и вложенных peers/VTEP/certificates, без обновления истории конфигурации или утверждения о forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/wireguard",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.state.read"
+ ],
+ "reason": "Общий REST polling/parser по выбранным серверам до HTTP; MCP использует safe observed DTO без key material, nullable flags/counters и явные failures. Пагинация каталогов и вложенных peers/VTEP/certificates, без обновления истории конфигурации или утверждения о forwarding."
+ },
+ {
+ "method": "GET",
+ "path": "/api/wireguard/revisions",
+ "status": "mediated",
+ "operations": [
+ "config.wireguard.revisions.read"
+ ],
+ "reason": "Общий listRevisions с REST: только метаданные, максимум 50 записей; серверная область и права проверяются до SQL, payload ревизии не выдаётся."
+ },
+ {
+ "method": "GET",
+ "path": "/health",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Bootstrap/health авторизации интерфейса; бизнес-операция MCP отсутствует."
+ },
+ {
+ "method": "GET",
+ "path": "/mcp",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "GET",
+ "path": "/oauth/authorize",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/firewall/address-lists",
+ "status": "mediated",
+ "operations": [
+ "firewall.addressLists.toggle"
+ ],
+ "reason": "Общий REST/MCP address-list сервис: scoped ID, human plan, консервативные защиты зависимых правил, полный stable proof, отдельная проверка expiry window, shared locks/read-back/revision/no retry."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/firewall/rules",
+ "status": "mediated",
+ "operations": [
+ "firewall.rules.toggle"
+ ],
+ "reason": "Общий REST/MCP сервис формы Firewall: человеческий sealed plan, scoped native ID, полный matcher/order proof, статическая цель, shared locks, read-back, отдельный статус ревизии и отсутствие retry."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/gre/tunnels",
+ "status": "mediated",
+ "operations": [
+ "network.gre.update"
+ ],
+ "reason": "Общий REST/MCP GRE business executor: интерфейс и v4/v6 адреса, staged disabled, opaque native proof/dependencies, PSK purpose reference, protections/budget/locks, per-command read-back, partial/unknown без retry; SQL/HTTP проверены."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/ipsec/peers/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.peers.update"
+ ],
+ "reason": "Общий REST/MCP peer PATCH всех REST-полей, same-value/native empty strings и history-only noop; certificate presence отклоняется. Native alias сохраняет comment и входит в общий private proof/intent/read-back/history. SQL/HTTP lost/ignored/collateral/reference mismatch/grant/protection/reconcile приняты; native rename gate остаётся отдельным."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/ipsec/users/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.users.update"
+ ],
+ "reason": "Полный общий REST/MCP PATCH клиента: display name, static IPv4/pool reset, PSK reference, Remote ID/disabled, cert-only promotion/ignored fields, чужой mode-config upsert с consumer closure, история, полный private proof и staged ACK/read-back. Human/server/operation/protection guards и SQL/HTTP parity приняты; lost ACK не повторяется."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/uptime/probes/:id",
+ "status": "mediated",
+ "operations": [
+ "uptime.ping.visibility.update"
+ ],
+ "reason": "Общий guarded updateProbeShowOnDashboard: scoped конфигурация, approval, защиты глобального probe ID, проверка drift/read-back без запуска сетевых измерений."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/users/:id",
+ "status": "mediated",
+ "operations": [
+ "users.update",
+ "users.permissions.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/wireguard/interfaces/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.interfaces.update"
+ ],
+ "reason": "Общий REST/MCP WireGuard PATCH: все поля, scoped key refs, rename peer/address ссылок, primary/secondary адреса, private dependency proof, actual byte limits, epoch ABA, intent/fences/read-back и exact VERIFIED reconcile без replay. Сторонние routing/firewall/application зависимости требуют отдельного плана; SQL/HTTP проверены, native readiness отдельно не заявляется."
+ },
+ {
+ "method": "PATCH",
+ "path": "/api/wireguard/peers/:serverId/:rosId",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.peers.update",
+ "ros.wireguard_peer.update"
+ ],
+ "reason": "Общий REST/MCP сервис изменения peer: зависимости, приватный proof, один PATCH, точный read-back и отдельная read-only сверка без повтора."
+ },
+ {
+ "method": "POST",
+ "path": "/_internal/mcp/portal/revocations",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/alerts/outbox/:id/retry",
+ "status": "mediated",
+ "operations": [
+ "alerts.outbox.retry"
+ ],
+ "reason": "Общий REST/MCP повтор unknown: human approval, acknowledged duplicate risk, private row source proof under lock, CAS version/status and application protections; подтверждается только постановка в очередь."
+ },
+ {
+ "method": "POST",
+ "path": "/api/alerts/telegram/test",
+ "status": "mediated",
+ "operations": [
+ "alerts.telegram.test"
+ ],
+ "reason": "Общий REST/MCP test payload и единственный guarded POST после человеческого подтверждения. Full global/server scope, owner/purpose secretRef, private proof и late fence; ack не delivery, reject/unknown без повтора, bounded response и запрет redirect."
+ },
+ {
+ "method": "POST",
+ "path": "/api/backups/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "backups.restore"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/backups/create",
+ "status": "mediated",
+ "operations": [
+ "backups.create"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/backups/storage/sync",
+ "status": "mediated",
+ "operations": [
+ "backups.storage.sync"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/backups/storage/test",
+ "status": "mediated",
+ "operations": [
+ "backups.storage.test"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/certificates/acme-settings/test",
+ "status": "mediated",
+ "operations": [
+ "certificates.acme.test"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/certificates/issue",
+ "status": "mediated",
+ "operations": [
+ "certificates.issue"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/certificates/refresh",
+ "status": "mediated",
+ "operations": [
+ "certificates.state.read"
+ ],
+ "reason": "Общий REST/MCP источник сертификатов с проверкой schema и clock offset; refresh только повторяет чтение без записи. Область до опроса, unknown в MCP, native keys исключены; HTTP/SQL parity и malformed failure проверены."
+ },
+ {
+ "method": "POST",
+ "path": "/api/events/batch",
+ "status": "mediated",
+ "operations": [
+ "events.batch.append"
+ ],
+ "reason": "Общий REST/MCP client batch insert: все поля и payload, server UUID, human approval/full global scope, bounded encrypted plan, atomic insert и exact VERIFIED read-only global/portal reconcile; lost acknowledgement/tamper/late pause/protection не повторяются. Это записи журнала, не доказательства системных действий."
+ },
+ {
+ "method": "POST",
+ "path": "/api/evobgp/catalog",
+ "status": "mediated",
+ "operations": [
+ "evobgp.catalog.read"
+ ],
+ "reason": "Общие parser/formatter и distinct server counts, полный эффективный scope до HTTP/SQL, credentials только из БД, bounded GET без redirects, пагинация всех коллекций с fingerprint и сохранением неизвестных счётчиков."
+ },
+ {
+ "method": "POST",
+ "path": "/api/evobgp/test",
+ "status": "mediated",
+ "operations": [
+ "evobgp.connection.check"
+ ],
+ "reason": "Общий ограниченный modules GET; MCP принимает сохранённый ключ или owner/destination-bound secret reference вместо открытого секрета. Полная серверная область проверяется до HTTP, результат не отражает upstream payload и не сохраняет настройки."
+ },
+ {
+ "method": "POST",
+ "path": "/api/filters/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "filters.revision.restore"
+ ],
+ "reason": "Общий guarded applyFiltersToServer; scoped filters revision/checksum повторно проверяются после approval, те же зависимости/защиты и native/DB/revision read-back, human only."
+ },
+ {
+ "method": "POST",
+ "path": "/api/firewall/address-lists",
+ "status": "mediated",
+ "operations": [
+ "firewall.addressLists.create"
+ ],
+ "reason": "Общий REST/MCP address-list сервис: scoped ID, human plan, консервативные защиты зависимых правил, полный stable proof, отдельная проверка expiry window, shared locks/read-back/revision/no retry."
+ },
+ {
+ "method": "POST",
+ "path": "/api/firewall/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "firewall.revision.restore"
+ ],
+ "reason": "Общий строгий REST/MCP restore: scoped revision fingerprint, full native proof, точный static порядок/дубликаты, staged disabled preparation, per-command read-back, защиты/бюджет/locks и no retry."
+ },
+ {
+ "method": "POST",
+ "path": "/api/firewall/rules",
+ "status": "mediated",
+ "operations": [
+ "firewall.rules.create"
+ ],
+ "reason": "Общий REST/MCP сервис формы Firewall: человеческий sealed plan, scoped native ID, полный matcher/order proof, статическая цель, shared locks, read-back, отдельный статус ревизии и отсутствие retry."
+ },
+ {
+ "method": "POST",
+ "path": "/api/firewall/rules/move",
+ "status": "mediated",
+ "operations": [
+ "firewall.rules.move"
+ ],
+ "reason": "Общий moveFirewallRule: точные ID/порядок и все matcher-поля без счётчиков, static source/destination, sealed человеческий план, защиты всей таблицы/сервера, fingerprint перед POST, read-back, без retry и явное состояние сохранения ревизии."
+ },
+ {
+ "method": "POST",
+ "path": "/api/geoip/update",
+ "status": "mediated",
+ "operations": [
+ "geoip.update"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/gre/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "network.gre.revision.restore"
+ ],
+ "reason": "Общий строгий REST/MCP GRE restore: весь раздел и IPv4/IPv6 адреса, зависимости и защиты, отключение перед адресами, приватные proof/PSK, human approval, поштучный read-back и отказ без повторной записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/gre/tunnels",
+ "status": "mediated",
+ "operations": [
+ "network.gre.create"
+ ],
+ "reason": "Общий REST/MCP GRE business executor: интерфейс и v4/v6 адреса, staged disabled, opaque native proof/dependencies, PSK purpose reference, protections/budget/locks, per-command read-back, partial/unknown без retry; SQL/HTTP проверены."
+ },
+ {
+ "method": "POST",
+ "path": "/api/ipsec/certs/:serverId/export",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.existing-certificates.export"
+ ],
+ "reason": "Общий REST/MCP executor существующего сертификата: оба selector и все роли, явный private/CA intent, human MCP plan, actor/key no-replay, exact owned file/read/cleanup, encrypted owner-only artifact/TTL; синтетическая SQL/HTTP/portal и browser приёмка. Native CHR отдельно."
+ },
+ {
+ "method": "POST",
+ "path": "/api/ipsec/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.revisions.restore"
+ ],
+ "reason": "Общий REST/MCP revision restore: strict fingerprint/schema, private whole-state proof, PKI/profile/policy/pool dependencies, exact clears, human approval и read-back без replay. Утраченные PKI ключи не генерируются."
+ },
+ {
+ "method": "POST",
+ "path": "/api/ipsec/server/init",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.server.init"
+ ],
+ "reason": "Общий REST/MCP init: полная форма, raw dependency closure, подпись только новых ACK-owned сертификатов, human approval, per-command fences/read-back и обязательная история."
+ },
+ {
+ "method": "POST",
+ "path": "/api/ipsec/users",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.users.create"
+ ],
+ "reason": "Full shared guarded client creation, purpose-bound secret refs, human-approved encrypted PKCS12 artifact and owner portal; private export separately authorized"
+ },
+ {
+ "method": "POST",
+ "path": "/api/ipsec/users/:serverId/:rosId/cert",
+ "status": "mediated",
+ "operations": [
+ "network.ipsec.existing-certificates.export"
+ ],
+ "reason": "Общий REST/MCP executor существующего сертификата: оба selector и все роли, явный private/CA intent, human MCP plan, actor/key no-replay, exact owned file/read/cleanup, encrypted owner-only artifact/TTL; синтетическая SQL/HTTP/portal и browser приёмка. Native CHR отдельно."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections/:id/check",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections/:id/grants",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections/:id/revalidate",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections/:id/rotate",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/connections/:id/status",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/database/archives",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/database/plan",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/devices/:serverId/:resource/plan",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/devices/:serverId/bridge-vlan/configuration/plan",
+ "status": "mediated",
+ "operations": ["network.bridge-vlan.configure"],
+ "reason": "Подготовка связанного плана bridge/VLAN через тот же MCP-инструмент; выполнение требует человеческого подтверждения."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/management-channels",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/oauth/clients",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/oauth/consent",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/operations/:id/reconcile",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/operations/:id/recover",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/pause",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/plans/:id/apply",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/plans/:id/decision",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/policy/preview",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/protections",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/routing-profiles/:id/check",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/routing-profiles/:id/pause",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/routing-profiles/plan",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/secrets",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/mcp/stop-automation",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/api/network/resolve-hosts",
+ "status": "mediated",
+ "operations": [
+ "network.hosts.resolve"
+ ],
+ "reason": "Общий bounded resolveNetworkHosts: явный global grant и network-write как в REST, IPv4/DNS/IDN validation, IPv6 literal без DNS как unsupported, дедупликация, TTL/cache/pending/deadline caps, stage access/cancel fences и различение manager resolver от RouterOS/path proof."
+ },
+ {
+ "method": "POST",
+ "path": "/api/recursive-routes/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.revision.restore"
+ ],
+ "reason": "Общий applyRecursiveToServer/executeRecursiveApply с REST: scoped revision/fingerprint, максимум 50 маршрутов, effective properties, зависимости фильтров/таблиц/интерфейсов, полный бюджет create+delete+metadata и read-back native/revision."
+ },
+ {
+ "method": "POST",
+ "path": "/api/scheduler/jobs/:jobKey/run-now",
+ "status": "mediated",
+ "operations": [
+ "scheduler.run"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/scheduler/refresh",
+ "status": "mediated",
+ "operations": [
+ "scheduler.refresh"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers",
+ "status": "mediated",
+ "operations": [
+ "servers.create"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers-api-ping/collect-now",
+ "status": "mediated",
+ "operations": [
+ "servers.api-ping.collect"
+ ],
+ "reason": "Общий полный manual executor REST/MCP: все включённые устройства, samples/partition maintenance/settings и отложенный глобальный alert engine. GLOBAL + весь каталог, человеческий план, явный skipped при busy, audit/idempotency и no replay; SQL/HTTP приёмка пройдена без реальных уведомлений."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/containers/remove",
+ "status": "mediated",
+ "operations": [
+ "containers.remove"
+ ],
+ "reason": "Общий removeContainer/removeStoppedContainer с REST: fresh stopped-only, идентичность конфигурации/интерфейса, защиты родителя и подтверждение удаления. Native delete alias использует тот же план."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/containers/restart",
+ "status": "mediated",
+ "operations": [
+ "containers.restart"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/containers/start",
+ "status": "mediated",
+ "operations": [
+ "containers.start"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/containers/stop",
+ "status": "mediated",
+ "operations": [
+ "containers.stop"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/exec",
+ "status": "mediated",
+ "operations": [
+ "servers.terminal.read"
+ ],
+ "reason": "Общий REST/MCP allowlist терминальной диагностики: 15 типизированных сценариев, все aliases и форматирование, прежнее servers:write право, полный scope/epoch до credentials, bounded transport/output и отзыв между запросами. SQL/REST parity подтверждена; произвольные CLI-команды не принимаются."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/ospf/optimize",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.application.optimize"
+ ],
+ "reason": "Общий legacy REST ranker/apply; human-only полный каталог, private source/prefix proofs, native dispatch/read-back и отдельное восстановление."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/ospf/optimize/preview",
+ "status": "mediated",
+ "operations": [
+ "routing.ospf.application.preview"
+ ],
+ "reason": "Общий REST/MCP reader рейтинга приложения; peer scope и probes отсекаются SQL до чтения, latest aggregate traffic требует известной дельты. MCP разделяет modeled/observed, ограничивает страницы/peers, повторно проверяет доступ/источник перед GET/POST и отменяет HTTP при остановке. Preview не создаёт план и не заменяет строгий family/VRF-aware optimizer."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/poll",
+ "status": "mediated",
+ "operations": [
+ "servers.poll"
+ ],
+ "reason": "Полный human-approved servers.poll: исходный sealed допуск и actual operation ID, общий снимок/обслуживание истории, quota-bound durable журнал, сохранённая квитанция без повтора native. UI REST-обработчик сохранён; retained admission limits MCP применяются отдельно."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/:id/probes/run",
+ "status": "mediated",
+ "operations": [
+ "servers.probes.run"
+ ],
+ "reason": "Общий v2 service executor для всех6 диагностик: REST JWT/local и MCP human plan, durable stages/receipts, общие квоты, текущие права, отмена и bounded retention; публичная регистрация и SQL/HTTP/DNS приёмка проверены."
+ },
+ {
+ "method": "POST",
+ "path": "/api/servers/test-connection",
+ "status": "mediated",
+ "operations": [
+ "servers.test-connection"
+ ],
+ "reason": "Общий REST/MCP сервис принят SQL/HTTP: права и human approval, private source fences, bounded transport, точная семантика, partial/unknown без повторов; сетевой forwarding не заявляется."
+ },
+ {
+ "method": "POST",
+ "path": "/api/system/database/restore",
+ "status": "mediated",
+ "operations": [
+ "database.restore"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/collect-now",
+ "status": "mediated",
+ "operations": [
+ "traffic.collect"
+ ],
+ "reason": "Полный общий REST/MCP executor: GLOBAL и весь каталог, человеческий план, штатные samples/settings/locks и глобальный alert hook. SQL/HTTP приёмка на одноразовой БД/localhost; busy/partial/unknown без автоматического повтора, квитанция не подтверждает доставку уведомлений."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow-overlay",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.overlay.apply"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow/host-reconcile",
+ "status": "mediated",
+ "operations": [
+ "netflow.host.reconcile"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow/overlay",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.overlay.apply"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow/purge",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.purge"
+ ],
+ "reason": "Полный общий REST/MCP сценарий: human/global scope, acknowledged drain всех retiring workers, транзакционная очистка, сохранение настроек/ключей/peers, утверждённый partition inventory/budget, journal/restart, SQL/HTTP-приёмка и unknown без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow/rebuild-facts",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.facts.rebuild"
+ ],
+ "reason": "Общий REST/MCP rebuild: обязательное human/global/full-server подтверждение, строгий drain существующих writers, атомарные кубы/событие/квитанция, source/protection guards и отдельная read-only сверка без replay. Принят на настоящей временной SQL-базе через MCP и JWT REST; живой worker отдельно не запускался."
+ },
+ {
+ "method": "POST",
+ "path": "/api/traffic/flow/settings/generate-keys",
+ "status": "mediated",
+ "operations": [
+ "traffic.flow.settings.generate-keys"
+ ],
+ "reason": "Shared full-config CAS, single-use durable receipt, human approval; public key only, no collector or host apply"
+ },
+ {
+ "method": "POST",
+ "path": "/api/uptime/collect-now",
+ "status": "mediated",
+ "operations": [
+ "uptime.collect"
+ ],
+ "reason": "Полный общий REST/MCP executor: GLOBAL и весь каталог, человеческий план, штатные samples/settings/locks и глобальный alert hook. SQL/HTTP приёмка на одноразовой БД/localhost; busy/partial/unknown без автоматического повтора, квитанция не подтверждает доставку уведомлений."
+ },
+ {
+ "method": "POST",
+ "path": "/api/uptime/probes/collect-group",
+ "status": "mediated",
+ "operations": [
+ "uptime.ping.group.collect"
+ ],
+ "reason": "Полный общий REST/MCP executor: GLOBAL и весь каталог, человеческий план, штатные samples/settings/locks и глобальный alert hook. SQL/HTTP приёмка на одноразовой БД/localhost; busy/partial/unknown без автоматического повтора, квитанция не подтверждает доставку уведомлений."
+ },
+ {
+ "method": "POST",
+ "path": "/api/uptime/speed-test",
+ "status": "mediated",
+ "operations": [
+ "uptime.speed.test"
+ ],
+ "reason": "Обычный RouterOS bandwidth-test через общий speed-сервис: MCP проверяет оба server scope, человеческое подтверждение, срок и лимит нагрузки; общие блокировки, аудит и стандартная история. Без отдельного реестра узлов, ключей и Docker-окон; no replay при unknown."
+ },
+ {
+ "method": "POST",
+ "path": "/api/users",
+ "status": "mediated",
+ "operations": [
+ "users.create"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/users/:id/bindings",
+ "status": "mediated",
+ "operations": [
+ "users.binding_add"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "POST",
+ "path": "/api/wireguard/export",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.export"
+ ],
+ "reason": "Общий REST/MCP export для rsc/conf/peer-conf: явный private-key opt-in, human approval, зашифрованный файл на 15 минут только владельцу через JWT; модель получает квитанцию. Полная SQL/HTTP-проверка форматов, обоих ID пира, source/grant/checkpoint и tamper; неоднозначное или невоспроизводимое состояние отклоняется."
+ },
+ {
+ "method": "POST",
+ "path": "/api/wireguard/import",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.import.preview",
+ "network.wireguard.import"
+ ],
+ "reason": "Общий REST/MCP импорт .rsc/.conf: owner/purpose/server contentRef, скрытые ключи, disabled preparation и selective activation всех peers/address/interface, отдельные object refs и полный command budget, per-command durable intent/fence/read-back, prefix checkpoint, exact VERIFIED reconcile; partial/unknown без автоматического повтора или компенсации."
+ },
+ {
+ "method": "POST",
+ "path": "/api/wireguard/interfaces",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.interfaces.create"
+ ],
+ "reason": "Общий сервис REST/MCP, scoped источники и защиты, человеческое подтверждение, intent/read-back или безопасный human-only artifact, SQL/HTTP-приёмка и сверка без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/api/wireguard/peers",
+ "status": "mediated",
+ "operations": [
+ "network.wireguard.peers.create"
+ ],
+ "reason": "Общий REST/MCP peer create и native alias: полная форма, существующий parent/dependencies, secret refs, staged disabled, per-command fences/read-back, exact verified checkpoint, partial/unknown без retry; SQL/HTTP проверены."
+ },
+ {
+ "method": "POST",
+ "path": "/api/wireguard/revisions/:id/restore",
+ "status": "mediated",
+ "operations": [
+ "config.wireguard.revisions.restore"
+ ],
+ "reason": "Общий REST/MCP whole-section restore: строгая ревизия, encrypted desired keys, полный dependency inventory, staged disable, exact clears, per-command fences и read-back без replay."
+ },
+ {
+ "method": "POST",
+ "path": "/mcp",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/oauth/revoke",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "POST",
+ "path": "/oauth/token",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/alerts/rules",
+ "status": "mediated",
+ "operations": [
+ "alerts.replace"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/alerts/telegram",
+ "status": "mediated",
+ "operations": [
+ "alerts.telegram.update"
+ ],
+ "reason": "Общий guarded REST/MCP selective-update сервис; полный global/server scope, человеческий план, owner/purpose secretRef или явное очищение, private source/reference proof, проверки перед записью и read-back. Сообщения не отправляются."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/backups/schedule",
+ "status": "mediated",
+ "operations": [
+ "backups.schedule.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/backups/storage",
+ "status": "mediated",
+ "operations": [
+ "backups.storage.update"
+ ],
+ "reason": "Общий REST updateBackupStorageSettings: глобальный человеческий план, полный каталог серверов/защиты, owner/destination-bound secretRef вместо literal secret, keyed credential proof, защита S3-архивов и занятости, полная проверка конфигурации/сохранённого ключа, partial при несовпадении и idempotency. Настройка не объявляется проверкой доступности S3."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/certificates/acme-settings",
+ "status": "mediated",
+ "operations": [
+ "certificates.acme.update"
+ ],
+ "reason": "Общий REST/MCP settings executor: owner/purpose secret refs, full global scope, human approval, bounded private SQL/source proof, CAS/read-back, verified exact receipt и no replay; SQL/HTTP проверены."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/certificates/renew-settings",
+ "status": "mediated",
+ "operations": [
+ "certificates.renew.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/evobgp/settings",
+ "status": "mediated",
+ "operations": [
+ "evobgp.settings.update"
+ ],
+ "reason": "Общий guarded writeEvoBgpSettings/schema; подтверждение человеком, URL-bound opaque secret вместо ключа, явное удаление ключа, fingerprint всех настроек и полного каталога, read-back включая ключ без его выдачи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/filters/rules",
+ "status": "mediated",
+ "operations": [
+ "filters.rules.replace"
+ ],
+ "reason": "Общий guarded applyFiltersToServer: human approval, совместные filters/network/BGP права, HMAC источника и routing dependencies, server-wide protections, безопасный compiler, native read-back до metadata/revision, без удаления чужих правил и автоматического повтора."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/firewall/address-lists",
+ "status": "mediated",
+ "operations": [
+ "firewall.addressLists.update"
+ ],
+ "reason": "Общий REST/MCP address-list сервис: scoped ID, human plan, консервативные защиты зависимых правил, полный stable proof, отдельная проверка expiry window, shared locks/read-back/revision/no retry."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/firewall/rules",
+ "status": "mediated",
+ "operations": [
+ "firewall.rules.update"
+ ],
+ "reason": "Общий REST/MCP сервис формы Firewall: человеческий sealed plan, scoped native ID, полный matcher/order proof, статическая цель, shared locks, read-back, отдельный статус ревизии и отсутствие retry."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/geoip",
+ "status": "mediated",
+ "operations": [
+ "geoip.settings.update"
+ ],
+ "reason": "Общий schema/updateGeoipSettings и refreshScheduler; защищённый human-approved план, полный каталог зависимостей, fingerprint конфигурации без observer metadata и read-back сохранённых полей."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/internet-path/settings",
+ "status": "mediated",
+ "operations": [
+ "internet-path.settings.update"
+ ],
+ "reason": "Общий сервис настроек коллектора; полная область серверов, защита зависимостей, подтверждённый план и проверка сохранения."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/logs/settings",
+ "status": "mediated",
+ "operations": [
+ "logs.settings.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/mcp/connections/:id",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/mcp/settings",
+ "status": "excluded",
+ "operations": [],
+ "reason": "Управление самим MCP, транспорт или машинная авторизация: отдельного AI-инструмента нет."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/recursive-routes",
+ "status": "mediated",
+ "operations": [
+ "routing.recursive.routes.replace"
+ ],
+ "reason": "Общий applyRecursiveToServer для полного apply/copy набора до 50 строк: человеческий план, стоимость create+delete+metadata, sealed native/DB/filter proof, устойчивые ID, проверка зависимостей и каждого нового/удаляемого маршрута, независимый native/cache/revision read-back и отсутствие повторов при partial/unknown."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/servers-api-ping/settings",
+ "status": "mediated",
+ "operations": [
+ "servers.api-ping.settings.update"
+ ],
+ "reason": "Общий сервис настроек коллектора; полная область серверов, защита зависимостей, подтверждённый план и проверка сохранения."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/servers/:id",
+ "status": "mediated",
+ "operations": [
+ "servers.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/traffic/flow/settings",
+ "status": "mediated",
+ "operations": [
+ "netflow.settings.update"
+ ],
+ "reason": "Full 10-field shared CAS and fenced main/worker lifecycle, global store/RIPE scope, human approval and durable two-phase receipt; readiness separate"
+ },
+ {
+ "method": "PUT",
+ "path": "/api/traffic/settings",
+ "status": "mediated",
+ "operations": [
+ "traffic.settings.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/uptime/probes",
+ "status": "mediated",
+ "operations": [
+ "uptime.ping.probes.replace"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/uptime/settings",
+ "status": "mediated",
+ "operations": [
+ "uptime.settings.update"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ },
+ {
+ "method": "PUT",
+ "path": "/api/uptime/speed-probes",
+ "status": "mediated",
+ "operations": [
+ "uptime.speed.probes.replace"
+ ],
+ "reason": "Типизированный MCP-адаптер этого сервисного сценария; применяются собственные scopes, лимиты, проверка зависимостей и подтверждение записи."
+ }
+ ]
+}
diff --git a/backend/package.json b/backend/package.json
index 69c92320..0d91f54e 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -1,48 +1,192 @@
{
"name": "mikrotik-manager-backend",
"version": "1.0.0",
- "description": "MikroTik Manager backend — Fastify + Drizzle + PostgreSQL",
+ "description": "MikroTik Manager backend — Fastify + Drizzle + PostgreSQL",
"type": "module",
"scripts": {
- "test:logs": "tsx src/services/router-logs-model.test.ts && tsx src/plugins/auth.logs.test.ts && tsx src/services/mikrotik-logs.test.ts",
+ "test:mcp:module-completion": "tsx src/services/ipsec-server-init-model.test.ts && tsx src/modules/mcp/ipsec-server-init-actions.test.ts && tsx src/services/wireguard-revision-restore.test.ts && tsx src/modules/mcp/vrf-ticket-runtime.test.ts && tsx src/services/ipsec-restore.test.ts && tsx src/services/ipsec-pool-dependencies.test.ts && tsx src/services/vrf-production-transition.test.ts && tsx src/services/vrf-production-action-binding.test.ts && tsx src/services/ipsec-revision-restore-model.test.ts && tsx src/modules/mcp/ipsec-revision-actions.test.ts && tsx src/modules/mcp/service-native-progress.test.ts && tsx src/services/ipsec-revision-restore.test.ts && tsx src/services/ipsec-revision-secret.test.ts",
+ "test:mcp:module-completion:pg": "node scripts/test-mcp-postgres.mjs --module-completion --restore",
+ "test:mcp:pg": "node scripts/test-mcp-postgres.mjs",
+ "test:mcp:pg:sharded": "node scripts/test-mcp-postgres-sharded.mjs",
+ "test:mcp:users-bindings:pg": "node scripts/test-mcp-postgres.mjs --users-bindings",
+ "test:mcp:bridge-vlan:pg": "node scripts/test-mcp-postgres.mjs --bridge-vlan-configuration",
+ "test:mcp:external-process:pg": "node scripts/mcp-external-process/run-owned.mjs",
+ "test:mcp:bridge-vlan:sdk": "node scripts/mcp-external-process/run-owned.mjs .. bridge-vlan",
+ "test:traffic-flow:ownership": "tsx src/services/traffic-flow-batch-proof.test.ts && tsx src/services/traffic-flow-owned-batch.test.ts && tsx src/services/traffic-flow-owned-writer.test.ts && tsx src/services/traffic-flow-write-transaction.test.ts && tsx src/services/traffic-flow-writer-exclusion.test.ts && tsx src/services/traffic-flow-drain-protocol.test.ts && tsx src/services/traffic-flow-facts-rebuild-execution.test.ts && tsx src/services/traffic-flow-facts-rebuild-source.test.ts && tsx src/services/traffic-flow-facts-rebuild-classifier.test.ts && tsx src/services/traffic-flow-facts-rebuild-service.test.ts && tsx src/services/traffic-flow-ripe-prune-owned.test.ts && tsx src/services/traffic-flow-engine-owned.test.ts && tsx src/routes/traffic-flow-rebuild.test.ts && tsx src/services/traffic-flow-settings-execution.test.ts",
+ "test:traffic-flow:rebuild:pg": "node scripts/test-mcp-postgres.mjs --flow-rebuild",
+ "test:traffic-flow:pg": "node scripts/test-mcp-postgres.mjs --flow-writes",
+ "test:traffic-flow:quality:pg": "node scripts/test-mcp-postgres.mjs --flow-quality",
+ "test:traffic-flow:chr-evidence": "tsx --test src/test/traffic-flow-chr-capture-check.test.ts src/test/traffic-flow-chr-wire.test.ts src/test/traffic-flow-chr-target-harness.test.ts src/test/traffic-flow-chr-owned-sequence.test.ts src/test/traffic-flow-chr-reconcile.test.ts",
+ "test:changed": "node scripts/test-changed.mjs",
+ "test:mcp:pg:all": "node scripts/test-mcp-postgres.mjs --all",
+ "mcp:stdio": "node dist/scripts/mcp-stdio.js",
+ "mcp:stdio:dev": "tsx src/scripts/mcp-stdio.ts",
+ "test:logs": "tsx src/services/router-logs-export.test.ts && tsx src/services/router-logs-model.test.ts && tsx src/plugins/auth.logs.test.ts && tsx src/services/mikrotik-logs.test.ts",
"test:logs:pg": "tsx src/services/router-logs-sql.test.ts",
- "test:sidebar-counts": "tsx src/services/complete-count.test.ts && tsx src/routes/sidebar-counts.test.ts",
+ "test:sidebar-counts": "tsx src/services/sidebar-counts.test.ts && tsx src/services/complete-count.test.ts && tsx src/routes/sidebar-counts.test.ts",
"dev": "tsx watch src/index.ts",
- "build": "npm run build -w @mmapp/contracts && tsc",
+ "build": "npm run build -w @mmapp/contracts && tsc && npm run build:database-operator",
+ "build:database-operator": "node scripts/build-database-operator.mjs",
"test:alerts-telegram": "tsx src/services/alerts-outbox-retry.test.ts && tsx src/services/alerts-outbox-overview.test.ts && tsx src/services/alert-engine/outbox-execution.test.ts && tsx src/services/alerts-telegram-delivery.test.ts && tsx src/services/alerts-revision.test.ts && tsx src/services/alerts-overview.test.ts && tsx ../packages/contracts/src/alerts-normalization.test.ts && tsx src/services/alerts-config-execution.test.ts && tsx src/services/alerts-telegram-settings.test.ts && tsx src/services/alerts-telegram-send.test.ts && tsx src/routes/alerts.test.ts && tsx src/plugins/auth.alerts.test.ts",
- "test:alert-engine": "tsx src/services/alert-engine/server-signal-identity.test.ts && tsx src/services/alert-engine/collector-source-signals.test.ts && tsx src/services/alert-engine/monitoring-history.test.ts && tsx src/services/alert-engine/groups.test.ts && tsx src/services/alert-engine/evaluate-rule.test.ts && tsx src/services/gre-tunnels-live.test.ts && tsx src/services/bgp-peers-live.test.ts && tsx src/services/gre-bgp-snapshot-collector.test.ts && tsx src/services/gre-bgp-snapshot-history.test.ts && tsx src/services/gre-bgp-snapshot-sql.test.ts && tsx src/services/alert-engine/collector-source-sql.test.ts && tsx src/services/alert-engine/confirm-stability.test.ts",
+ "test:alert-engine": "tsx src/services/alert-engine/execution-access.test.ts && tsx src/services/alert-engine/server-signal-identity.test.ts && tsx src/services/alert-engine/collector-source-signals.test.ts && tsx src/services/alert-engine/monitoring-history.test.ts && tsx src/services/alert-engine/groups.test.ts && tsx src/services/alert-engine/evaluate-rule.test.ts && tsx src/services/gre-tunnels-live.test.ts && tsx src/services/bgp-peers-live.test.ts && tsx src/services/gre-bgp-snapshot-collector.test.ts && tsx src/services/gre-bgp-snapshot-history.test.ts && tsx src/services/gre-bgp-snapshot-sql.test.ts && tsx src/services/alert-engine/collector-source-sql.test.ts && tsx src/services/alert-engine/confirm-stability.test.ts",
"start": "node dist/index.js",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
+ "db:prepare": "tsx src/scripts/prepare-database.ts",
+ "db:complete-restore": "tsx src/scripts/complete-database-restore.ts",
+ "db:serve-restore-claims": "tsx src/scripts/serve-restore-checkpoint-claims.ts",
+ "db:seal-restore-checkpoint": "tsx src/scripts/seal-database-restore-checkpoint.ts",
+ "db:stage-restore-checkpoint": "tsx src/scripts/stage-database-restore-checkpoint.ts",
+ "db:inspect-restore-checkpoint": "tsx src/scripts/inspect-database-restore-checkpoint.ts",
+ "db:inspect-schema": "tsx src/scripts/inspect-database-schema.ts",
"db:studio": "drizzle-kit studio",
"db:migrate-from-sqlite": "tsx src/scripts/migrate-sqlite-to-pg.ts",
"facts:rebuild": "tsx src/scripts/rebuild-flow-facts.ts",
- "test:probes": "tsx src/routes/probes.test.ts && tsx src/routes/probes.cancel.test.ts && tsx src/services/ping-measurement.test.ts && tsx src/services/uptime-probe-observations.test.ts && tsx src/services/ping-measurement-sql.test.ts",
- "test:exec": "tsx src/services/mikrotik-logs.test.ts && tsx src/routes/exec.test.ts && tsx src/plugins/auth.exec.test.ts",
- "test:auth": "tsx src/plugins/auth-path.test.ts && tsx src/lib/permissions.test.ts && tsx src/plugins/auth.smoke.test.ts && tsx src/plugins/auth.ospf-optimizer.test.ts",
- "test:wireguard": "npx tsx src/services/wireguard-config.test.ts && npx tsx src/services/wireguard-ipv6.test.ts && npx tsx --test src/services/wireguard-import.test.ts src/services/wireguard-import-apply.test.ts src/services/wireguard-import-revision.test.ts src/services/wireguard-delete.test.ts && npx tsx src/routes/wireguard-import.test.ts",
+ "test:mcp:vrf-cleanup": "tsx src/test/chr-vrf-companion-cleanup-proof.test.ts && tsx src/test/chr-vrf-companion-disabled-cleanup-proof.test.ts && tsx src/test/chr-vrf-companion-transfer-cleanup-proof.test.ts",
+ "test:probes": "npm run test:speed-workflow && tsx src/services/manual-data-collection-execution.test.ts && tsx src/routes/manual-data-collection.test.ts && tsx src/services/network-host-resolution.test.ts && tsx src/routes/probes.test.ts && tsx src/routes/probes.cancel.test.ts && tsx src/services/ping-measurement.test.ts && tsx src/services/uptime-probe-observations.test.ts && tsx src/services/ping-measurement-sql.test.ts",
+ "test:exec": "tsx src/services/mikrotik-logs.test.ts && tsx src/services/terminal-diagnostics.test.ts && tsx src/routes/exec.test.ts && tsx src/plugins/auth.exec.test.ts",
+ "test:auth": "tsx --test src/modules/mcp/routing-manual-inverse-history.test.ts && tsx src/db/application-writer-profile-registry-structure.test.ts && tsx src/db/application-writer-profile-registry-read.test.ts && tsx src/db/application-writer-profile-registry-read-parity.test.ts && tsx src/db/application-writer-profile-format.test.ts && tsx src/plugins/auth-path.test.ts && tsx src/lib/permissions.test.ts && tsx src/plugins/auth-provenance.test.ts && tsx src/services/bandwidth-rest-speed-original.test.ts && tsx src/plugins/auth.smoke.test.ts && tsx src/plugins/auth.ospf-optimizer.test.ts && npm run test:mcp",
+ "test:mcp": "node scripts/vrf-production-profile.test.mjs && node src/services/vrf-production-peer-telemetry.test.mjs && node src/services/vrf-execution-diagnostic.test.mjs && node src/services/vrf-transition-refusal.test.mjs && node src/services/vrf-production-gre-cycle.test.mjs && tsx src/services/vrf-production-gre-link-local.test.ts && tsx src/services/vrf-production-bridge-delete.test.ts && tsx src/services/vrf-production-transition.test.ts && tsx --test src/services/routeros-snapshot-read.test.ts src/services/bridge-vlan-configuration.test.ts src/modules/mcp/bridge-vlan-projection.test.ts src/modules/mcp/vrf-preparation-diagnostic.test.ts && tsx --test src/services/server-poll-error-provenance.test.ts && tsx --test src/modules/mcp/plan-expiry.test.ts src/modules/mcp/result-budget.test.ts src/modules/mcp/result-delivery.test.ts src/modules/mcp/wire-admission.test.ts src/modules/mcp/flow-envelope-allowance.test.ts src/modules/mcp/sdk-terminal-budget.test.ts src/modules/mcp/inflight-owner.test.ts && npm run test:database-source-binding && tsx --test src/modules/mcp/integration-fixture-expiry.test.ts && npm run test:mcp:operation-origin && npm run test:mcp:service-context && npm run test:mcp:operation-locks && tsx --test src/modules/mcp/routing-community-public.test.ts src/modules/mcp/management-transport.test.ts src/modules/mcp/routing-community-context-model.test.ts src/modules/mcp/routing-community-context-native.test.ts ../packages/contracts/src/mcp-routing.test.ts && tsx src/modules/mcp/human-artifact-receipts.test.ts && tsx src/modules/mcp/chr-overlay-readiness.test.ts && tsx src/modules/mcp/chr-recovery-source.test.ts && tsx src/modules/mcp/chr-native-failure.test.ts && tsx src/modules/mcp/ospf-owner-graph.test.ts && tsx src/modules/mcp/routing-measurement-address.test.ts && tsx src/modules/mcp/routing-observation-source.test.ts && tsx src/services/traffic-flow-talkers-model.test.ts && tsx src/services/bgp-prefix-model.test.ts && tsx src/services/vrf-members.test.ts && tsx src/services/routing-gateway-reference.test.ts && tsx src/services/bgp-export-model.test.ts && tsx src/services/traffic-history-model.test.ts && tsx src/services/internet-path-snapshot.test.ts && tsx src/services/internet-path-observation.test.ts && tsx src/modules/mcp/coverage.test.ts && tsx src/modules/mcp/policy.test.ts && tsx src/modules/mcp/events-batch-model.test.ts && tsx src/modules/mcp/operation-revisions.test.ts && tsx src/modules/mcp/native-create-identity.test.ts && tsx src/modules/mcp/ros-step-verification.test.ts && tsx src/modules/mcp/ros-prefix.test.ts && tsx src/modules/mcp/native-conservation-http.test.ts && tsx src/modules/mcp/security.test.ts && tsx src/modules/mcp/state-file-publish.test.ts && tsx src/modules/mcp/routing-model.test.ts && tsx src/modules/mcp/routing-observations-model.test.ts && tsx src/modules/mcp/ospf-health.test.ts && tsx src/modules/mcp/ecmp-preflight.test.ts && tsx src/modules/mcp/recursive-recovery.test.ts && tsx src/modules/mcp/control-path-model.test.ts && tsx src/modules/mcp/routing-community-scoped-model.test.ts && tsx src/modules/mcp/routing-community-scoped-native.test.ts && tsx src/modules/mcp/path-verification.test.ts && tsx src/modules/mcp/database-maintenance.test.ts && tsx src/routes/mcp.test.ts && tsx ../lib/auth-mcp.test.ts && tsx --test src/modules/mcp/routing-controller-fence.test.ts && tsx src/test/chr-vrf-companion-proof.test.ts && tsx src/test/chr-vrf-companion-telemetry.test.ts && tsx src/test/chr-vrf-companion-address-space.test.ts && tsx src/modules/mcp/flow-facts-rebuild-actions.test.ts && tsx src/modules/mcp/ipsec-peer-create-dependencies.test.ts && tsx src/services/ipsec-certificate-update-model.test.ts && tsx src/modules/mcp/ipsec-native-dispatch.test.ts && tsx src/modules/mcp/ipsec-user-update-actions.test.ts && tsx src/modules/mcp/ipsec-server-delete-actions.test.ts && tsx src/services/ipsec-proof-telemetry.test.ts && tsx src/services/vrf-production-admission.test.ts && tsx src/modules/mcp/flow-host-keys-actions.test.ts && tsx src/services/vrf-production-read.test.ts && tsx --test src/services/vrf-production-wireguard-alias.test.ts && tsx src/modules/mcp/ipsec-user-create-actions.test.ts && tsx src/modules/mcp/flow-settings-actions.test.ts && tsx src/services/vrf-production-ticket-store.test.ts && npm run test:mcp:routing-baseline",
+ "test:wireguard": "tsx src/services/mikrotik-response-bounds.test.ts && tsx --test src/services/wireguard-dependency-read.test.ts && tsx src/services/wireguard-interface-update.test.ts && tsx src/services/wireguard-peer-update.test.ts && npx tsx src/services/wireguard-config.test.ts && npx tsx src/services/wireguard-ipv6.test.ts && npx tsx --test src/services/wireguard-import.test.ts src/services/wireguard-import-apply.test.ts src/services/wireguard-import-revision.test.ts src/services/wireguard-delete.test.ts && npx tsx src/routes/wireguard-import.test.ts && tsx src/services/wireguard-interface-create.test.ts && tsx src/services/wireguard-peer-create.test.ts && tsx src/services/wireguard-import-plan.test.ts && tsx src/services/wireguard-import-execution.test.ts && tsx src/modules/mcp/wireguard-import-actions.test.ts && tsx --test src/services/wireguard-export.test.ts",
"test:traffic-rate": "tsx src/services/traffic-rate.test.ts && tsx src/services/traffic-observation.test.ts && tsx src/services/traffic-freshness.test.ts && tsx src/services/traffic-live.test.ts && tsx src/services/traffic-observation-sql.test.ts && tsx src/services/traffic-history-sql.test.ts && tsx src/services/traffic-live-sql.test.ts && tsx src/services/traffic-volume-sql.test.ts && tsx src/services/traffic-binding-status.test.ts && tsx src/services/traffic-status-sql.test.ts && tsx src/services/traffic-gap.test.ts && tsx src/services/traffic-identity.test.ts && tsx src/services/traffic-membership.test.ts && tsx src/services/traffic-aggregate-peak.test.ts && tsx src/services/traffic-users-cache.test.ts && tsx src/services/traffic-collection-lock.test.ts && tsx src/services/traffic-concurrency-sql.test.ts",
- "test:traffic-flow": "tsx src/routes/traffic-flow-query.test.ts && tsx src/services/traffic-flow-month.test.ts && tsx src/services/traffic-flow-parse.test.ts && tsx src/services/traffic-flow-ipv6-pipeline.test.ts && tsx src/services/traffic-flow-map-exporter.test.ts && tsx src/services/traffic-flow-ifaces.test.ts && tsx src/services/traffic-flow-ifindex.test.ts && tsx src/services/traffic-flow-dedup.test.ts && tsx src/services/traffic-flow-planes.test.ts && tsx src/services/traffic-flow-ip.test.ts && tsx src/services/traffic-flow-dest.test.ts && tsx src/services/traffic-flow-classify.test.ts && tsx src/services/traffic-flow-ripe.test.ts && tsx src/services/traffic-flow-brands.test.ts && tsx src/services/traffic-flow-ingest.test.ts && tsx src/services/traffic-flow-analytics.test.ts && tsx src/services/traffic-flow-map-hops.test.ts && tsx src/services/traffic-flow-purge.test.ts && tsx src/services/geoip-download.test.ts && tsx src/services/traffic-flow-geoip.test.ts && tsx src/services/traffic-flow-facts.test.ts && tsx src/services/traffic-flow-facts-filter.test.ts && tsx src/services/traffic-flow-facts-rebuild.test.ts && tsx src/services/statistics-aggregate.test.ts",
- "test:users": "tsx src/modules/users/iface-type.test.ts && tsx src/modules/users/bindings.test.ts && tsx src/modules/users/interface-inventory.test.ts && tsx src/routes/users-catalog.test.ts",
+ "test:traffic-flow": "tsx --test src/services/traffic-flow-heartbeat.test.ts src/services/traffic-flow-heartbeat-wiring.test.ts src/services/traffic-flow-heartbeat-receiver.test.ts src/services/traffic-flow-ingest-quality.test.ts src/services/traffic-flow-quality-contract.test.ts && tsx src/services/traffic-flow-catalog-read.test.ts && tsx src/routes/traffic-flow-query.test.ts && tsx src/services/traffic-flow-month.test.ts && tsx src/services/traffic-flow-parse.test.ts && tsx src/services/traffic-flow-ipv6-pipeline.test.ts && tsx src/services/traffic-flow-map-exporter.test.ts && tsx src/services/traffic-flow-ifaces.test.ts && tsx src/services/traffic-flow-ifindex.test.ts && tsx src/services/traffic-flow-dedup.test.ts && tsx src/services/traffic-flow-planes.test.ts && tsx src/services/traffic-flow-ip.test.ts && tsx src/services/traffic-flow-dest.test.ts && tsx src/services/traffic-flow-classify.test.ts && tsx src/services/traffic-flow-ripe.test.ts && tsx src/services/traffic-flow-brands.test.ts && tsx src/services/traffic-flow-ingest.test.ts && tsx src/services/traffic-flow-analytics.test.ts && tsx src/services/traffic-flow-map-hops.test.ts && tsx src/services/traffic-flow-purge.test.ts && tsx src/services/geoip-download.test.ts && tsx src/services/traffic-flow-geoip.test.ts && tsx src/services/traffic-flow-fact-accumulator.test.ts && tsx src/services/traffic-flow-facts.test.ts && tsx src/services/traffic-flow-facts-filter.test.ts && tsx src/services/traffic-flow-facts-rebuild.test.ts && tsx src/services/statistics-aggregate.test.ts && tsx src/services/geoip-manual-update.test.ts && tsx src/services/traffic-flow-overlay-model.test.ts && npm run test:traffic-flow:ownership && tsx src/services/traffic-flow-worker-platform.test.ts && tsx src/services/traffic-flow-template-cache.test.ts && tsx --test src/services/traffic-flow-template-lifetime.test.ts && tsx src/services/traffic-flow-protocol-scope.test.ts && npm run test:traffic-flow:read-budget && npm run test:traffic-flow:resource-profile",
+ "test:users": "tsx ../packages/contracts/src/users.test.ts && tsx src/modules/users/iface-type.test.ts && tsx src/modules/users/binding-target.test.ts && tsx src/modules/users/bindings.test.ts && tsx src/modules/users/interface-inventory.test.ts && tsx src/routes/users-catalog.test.ts",
"test:pg": "tsx src/db/pg-pool.test.ts && tsx src/db/sql-bind.test.ts && tsx src/db/sqlite-json.test.ts && tsx src/db/traffic-flags.test.ts && tsx src/db/pg-schema.test.ts && tsx src/db/scheduler-retention-index.test.ts && tsx src/services/config-revisions.test.ts",
- "test:recursive-routes": "tsx src/routes/recursive-routes.test.ts && tsx src/services/recursive-route-catalog.test.ts && tsx src/services/recursive-effective-properties.test.ts && tsx src/services/recursive-apply.test.ts",
- "test:config-sync": "tsx src/utils/server-id.test.ts && tsx src/services/config-apply-plan.test.ts && tsx src/services/entity-snapshots.test.ts && tsx src/services/gre-native-identity.test.ts && tsx src/services/gre-ipv6.test.ts && tsx src/routes/gre-ipv6-validation.test.ts && tsx src/services/network-disabled-server.test.ts",
- "test:ros-file": "tsx src/services/ros-file-contents.test.ts && tsx src/services/mikrotik-response.test.ts",
+ "test:recursive-routes": "tsx src/services/recursive-route-identity.test.ts && tsx src/routes/recursive-routes.test.ts && tsx src/services/recursive-route-catalog.test.ts && tsx src/services/recursive-effective-properties.test.ts && tsx src/services/recursive-apply.test.ts",
+ "test:config-sync": "tsx src/services/owned-routing-policy.test.ts && tsx src/services/routing-filter-body.test.ts && tsx src/services/bgp-community-policy-model.test.ts && tsx src/services/bgp-connection-read.test.ts && tsx src/services/bgp-filter-binding-model.test.ts && tsx src/services/filter-rules-write-model.test.ts && tsx src/services/filter-rules-mutation.test.ts && tsx src/utils/server-id.test.ts && tsx src/services/config-apply-plan.test.ts && tsx src/services/entity-snapshots.test.ts && tsx src/services/gre-native-identity.test.ts && tsx src/services/gre-ipv6.test.ts && tsx src/routes/gre-ipv6-validation.test.ts && tsx src/services/network-disabled-server.test.ts",
+ "test:ros-file": "tsx src/services/mikrotik-get-cancel.test.ts && tsx src/services/ros-file-contents.test.ts && tsx src/services/mikrotik-response.test.ts && tsx src/services/mikrotik-owned-file.test.ts && tsx --test src/services/mikrotik-owned-file-zeroization.test.ts",
"test:scheduler": "tsx src/services/scheduler-running.test.ts && tsx src/services/scheduler-recorded-run.test.ts && tsx src/routes/scheduler.test.ts",
- "test:backups": "tsx src/services/backup-local-file-state.test.ts && tsx src/services/router-config-export.test.ts && tsx src/services/backup-scheduler-run.test.ts && tsx src/services/backup-restore.test.ts && tsx src/services/backup-deletion.test.ts && tsx src/services/backup-dto.test.ts && tsx src/services/backup-storage-update.test.ts && tsx src/services/backup-job-execution.test.ts && tsx src/routes/backups-operations.test.ts && tsx src/services/s3-backup-client.test.ts",
- "test:ipsec": "tsx src/services/ipsec-config.test.ts && tsx src/services/ipsec-state.test.ts && tsx src/routes/ipsec-history.test.ts && tsx src/services/ipsec-restore.test.ts && tsx src/services/ipsec-operation.test.ts && tsx src/routes/ipsec-mutation.test.ts && tsx src/routes/ipsec-nat.test.ts && tsx src/routes/ipsec-group.test.ts",
- "test:live-maps": "tsx src/services/gre-keepalive.test.ts && tsx src/services/gre-read.test.ts && tsx src/services/ospf-route-parse.test.ts && tsx src/services/vxlan-live.test.ts && tsx src/routes/vxlan.test.ts && tsx src/services/containers-live.test.ts && tsx src/services/firewall-poll.test.ts && tsx src/services/gre-catalog-poll.test.ts && tsx src/routes/filters-gre-catalog.test.ts && tsx src/routes/bgp-catalog.test.ts && tsx src/services/bgp-catalog-parse.test.ts && tsx src/routes/ospf-catalog.test.ts && tsx src/services/ospf-observed-values.test.ts && tsx src/routes/ospf-legacy.test.ts",
+ "test:backups": "tsx src/modules/mcp/backup-storage-actions.test.ts && tsx src/services/backup-job-read.test.ts && tsx src/services/backup-local-file-state.test.ts && tsx src/services/router-config-export.test.ts && tsx src/services/backup-scheduler-run.test.ts && tsx src/services/backup-restore.test.ts && tsx src/services/backup-deletion.test.ts && tsx src/services/backup-dto.test.ts && tsx src/services/backup-storage-update.test.ts && tsx src/services/backup-job-execution.test.ts && tsx src/routes/backups-operations.test.ts && tsx src/services/s3-backup-client.test.ts && tsx src/services/backup-content-bounds.test.ts",
+ "test:ipsec": "tsx src/services/ipsec-config.test.ts && tsx src/services/ipsec-state.test.ts && tsx src/routes/ipsec-history.test.ts && tsx src/services/ipsec-restore.test.ts && tsx src/services/ipsec-operation.test.ts && tsx src/routes/ipsec-mutation.test.ts && tsx src/routes/ipsec-nat.test.ts && tsx src/routes/ipsec-group.test.ts && tsx src/services/ipsec-peer-delete.test.ts && tsx src/modules/mcp/ipsec-peer-delete-actions.test.ts && tsx src/services/ipsec-user-delete.test.ts && tsx src/modules/mcp/ipsec-user-delete-actions.test.ts && tsx src/services/ipsec-certificate-delete.test.ts && tsx src/modules/mcp/ipsec-certificate-delete-actions.test.ts && tsx src/services/ipsec-peer-update.test.ts && tsx src/modules/mcp/ipsec-peer-update-actions.test.ts && tsx src/services/ipsec-user-update-model.test.ts && tsx src/modules/mcp/ipsec-user-update-actions.test.ts && tsx src/services/ipsec-server-delete-model.test.ts && tsx src/modules/mcp/ipsec-server-delete-actions.test.ts && tsx src/services/ipsec-proof-telemetry.test.ts && tsx src/services/ipsec-user-create-model.test.ts",
+ "test:live-maps": "tsx src/services/gre-revision-restore.test.ts && tsx src/services/gre-native-mutation.test.ts && tsx src/services/gre-mutation.test.ts && tsx src/services/filter-rules-observed.test.ts && tsx src/services/firewall-revision-restore.test.ts && tsx src/services/firewall-address-write.test.ts && tsx src/services/firewall-rule-write.test.ts && tsx src/services/gre-observed-read.test.ts && tsx src/services/network-observed-read.test.ts && tsx src/services/firewall-rule-move.test.ts && tsx src/services/ospf-state-read.test.ts && tsx src/modules/mcp/readiness-http.test.ts && tsx src/services/probe-interface-model.test.ts && tsx src/services/wan-runtime-model.test.ts && tsx src/services/gre-keepalive.test.ts && tsx src/services/gre-read.test.ts && tsx src/services/ospf-route-parse.test.ts && tsx src/services/vxlan-live.test.ts && tsx src/routes/vxlan.test.ts && tsx src/services/containers-live.test.ts && tsx src/services/firewall-poll.test.ts && tsx src/services/gre-catalog-poll.test.ts && tsx src/routes/filters-gre-catalog.test.ts && tsx src/routes/bgp-catalog.test.ts && tsx src/services/bgp-catalog-parse.test.ts && tsx src/routes/ospf-catalog.test.ts && tsx src/services/ospf-observed-values.test.ts && tsx src/routes/ospf-legacy.test.ts",
"test": "node scripts/test.mjs",
- "test:evolution": "tsx src/services/evobgp-catalog.test.ts && tsx src/routes/evobgp-catalog.test.ts && tsx src/routes/evobgp-settings.test.ts && tsx src/plugins/auth.evolution-settings.test.ts",
- "test:netflow-purge": "tsx src/db/operation-lock.test.ts && tsx src/services/traffic-flow-purge-execution.test.ts && tsx src/routes/traffic-flow-purge.test.ts",
- "test:netflow-settings": "tsx src/services/traffic-flow-host-file-builders.test.ts && tsx src/services/traffic-flow-key-execution.test.ts && tsx src/routes/traffic-flow-settings.test.ts && tsx src/plugins/auth.netflow-settings.test.ts && tsx src/services/traffic-flow-agent-install.test.ts && tsx src/services/traffic-flow-agent-client.test.ts && tsx src/services/traffic-flow-operation-queue.test.ts && tsx src/routes/traffic-flow-host.test.ts",
+ "test:evolution": "tsx src/services/evobgp-catalog.test.ts && tsx src/services/evobgp-client.test.ts && tsx src/routes/evobgp-catalog.test.ts && tsx src/routes/evobgp-settings.test.ts && tsx src/plugins/auth.evolution-settings.test.ts",
+ "test:netflow-purge": "tsx src/db/operation-lock.test.ts && tsx src/services/traffic-flow-purge-execution.test.ts && tsx src/services/flow-purge-partitions.test.ts && tsx --test src/services/traffic-flow-worker-lifecycle.test.ts && tsx src/routes/traffic-flow-purge.test.ts",
+ "test:netflow-settings": "tsx src/services/traffic-flow-host-file-builders.test.ts && tsx src/services/traffic-flow-key-execution.test.ts && tsx src/routes/traffic-flow-settings.test.ts && tsx src/plugins/auth.netflow-settings.test.ts && tsx src/services/traffic-flow-agent-install.test.ts && tsx src/services/traffic-flow-agent-client.test.ts && tsx src/services/traffic-flow-operation-queue.test.ts && tsx src/routes/traffic-flow-host.test.ts && tsx src/services/traffic-flow-settings-execution.test.ts && tsx src/modules/mcp/flow-host-keys-actions.test.ts && tsx src/services/traffic-flow-lifecycle-fence.test.ts && tsx src/services/traffic-flow-settings-store.test.ts && tsx src/services/traffic-flow-settings-service.test.ts && tsx src/modules/mcp/flow-settings-actions.test.ts",
"test:geoip": "tsx src/services/geoip-download.test.ts && tsx src/services/traffic-flow-geoip.test.ts && tsx src/plugins/auth.geoip.test.ts",
- "test:ospf-optimizer": "tsx src/services/ospf-optimizer-identity.test.ts && tsx src/services/ospf-optimizer-metrics.test.ts && tsx src/services/ospf-optimizer-plan.test.ts && tsx src/services/ospf-effective-disabled.test.ts && tsx src/routes/ospf-optimizer.test.ts",
+ "test:ospf-optimizer": "tsx src/services/ospf-cost-optimization.test.ts && tsx src/modules/mcp/ospf-legacy-source.test.ts && tsx src/services/ospf-legacy-optimization.test.ts && tsx src/services/ospf-template-flags.test.ts && tsx src/services/ospf-route-proof.test.ts && tsx src/services/ospf-link-catalog.test.ts && tsx src/services/ospf-identity-catalog.test.ts && tsx src/services/ospf-template-cost-write.test.ts && tsx src/services/ospf-template-cost-http.test.ts && tsx src/services/ospf-optimizer-identity.test.ts && tsx src/services/ospf-optimizer-metrics.test.ts && tsx src/services/ospf-optimizer-plan.test.ts && tsx src/services/ospf-effective-disabled.test.ts && tsx src/routes/ospf-optimizer.test.ts",
"test:containers": "tsx src/services/containers-live.test.ts && tsx src/services/containers-state.test.ts && tsx src/services/container-removal.test.ts && tsx src/routes/containers-state.test.ts",
- "test:certificates": "tsx src/services/certificate-installation.test.ts && tsx src/services/certificate-renew-collector.test.ts && tsx src/services/certificate-issue-execution.test.ts && tsx src/services/certificate-issue-request.test.ts && tsx src/routes/certificates-issue.test.ts && tsx src/services/certificate-issue-dto.test.ts && tsx src/services/certificate-parse.test.ts && tsx src/services/certificates-state.test.ts && tsx src/routes/certificates-state.test.ts",
- "test:system-database": "tsx src/services/system-database-partition-restore.test.ts && tsx src/services/system-database-cache.test.ts && tsx src/services/database-background-work.test.ts && tsx src/services/database-request-gate.test.ts && tsx src/services/traffic-flow-worker-shutdown.test.ts && tsx src/services/system-database-restore-execution.test.ts && tsx src/services/system-database-operation.test.ts && tsx src/routes/system-database.test.ts && tsx src/plugins/auth.system-database.test.ts",
- "test:all": "npm run test:logs && npm run test:probes && npm run test:exec && npm run test:alert-engine && npm run test:alerts-telegram && npm run test:auth && npm run test:wireguard && npm run test:ipsec && npm run test:traffic-rate && npm run test:traffic-flow && npm run test:users && npm run test:pg && npm run test:backups && npm run test:scheduler && npm run test:live-maps && npm run test:ospf-optimizer && npm run test:recursive-routes && npm run test:config-sync && npm run test:ros-file && npm run test:containers && npm run test:certificates && npm run test:netflow-settings && npm run test:netflow-purge && npm run test:evolution && npm run test:system-database && npm run test:server-privacy",
- "test:server-privacy": "tsx src/routes/server-secrets-sql.test.ts"
+ "test:certificates": "tsx src/services/certificate-installation.test.ts && tsx src/services/certificate-renew-collector.test.ts && tsx src/services/certificate-issue-execution.test.ts && tsx src/services/certificate-issue-request.test.ts && tsx src/routes/certificates-issue.test.ts && tsx src/services/certificate-issue-dto.test.ts && tsx src/services/certificate-parse.test.ts && tsx src/services/certificates-state.test.ts && tsx src/routes/certificates-state.test.ts && tsx src/services/acme-settings-test.test.ts && tsx src/services/acme-settings-update-model.test.ts && tsx src/modules/mcp/acme-settings-actions.test.ts",
+ "test:system-database": "tsx src/services/bounded-database-dump.test.ts && tsx src/services/database-dump-connection.test.ts && tsx src/services/system-database-partition-restore.test.ts && tsx src/services/system-database-cache.test.ts && tsx src/services/database-background-work.test.ts && tsx src/services/database-request-gate.test.ts && tsx --test src/services/detached-database-admission.test.ts && tsx src/services/traffic-flow-worker-shutdown.test.ts && tsx src/services/system-database-restore-execution.test.ts && tsx src/services/system-database-operation.test.ts && tsx src/services/system-database-schema-readiness.test.ts && tsx --test src/routes/mcp-oauth-database-admission.test.ts && tsx src/routes/system-database.test.ts && tsx src/plugins/auth.system-database.test.ts && tsx src/services/database-control-archive-boundary.test.ts && tsx src/db/database-schema-control-model.test.ts && tsx src/db/database-schema-control.test.ts && tsx src/db/controlled-migrations.test.ts && tsx src/db/controlled-schema-verification.test.ts && tsx --test src/db/migration-data-inventory.test.ts && tsx --test src/services/database-maintenance-startup.test.ts && tsx --test src/services/database-restore-audit.test.ts && tsx --test src/services/database-maintenance-resolution.test.ts && tsx --test scripts/database-maintenance-resolution.test.mts && tsx src/db/database-runtime-schema.test.ts",
+ "test:all": "npm run test:logs && npm run test:probes && npm run test:exec && npm run test:alert-engine && npm run test:alerts-telegram && npm run test:auth && npm run test:wireguard && npm run test:ipsec && npm run test:traffic-rate && npm run test:traffic-flow && npm run test:users && npm run test:pg && npm run test:sidebar-counts && npm run test:backups && npm run test:scheduler && npm run test:live-maps && npm run test:ospf-optimizer && npm run test:recursive-routes && npm run test:config-sync && npm run test:ros-file && npm run test:containers && npm run test:certificates && npm run test:netflow-settings && npm run test:netflow-purge && npm run test:evolution && npm run test:system-database && npm run test:server-privacy && npm run test:mcp:module-completion && npm run test:mcp:loopback-agent && npm run test:server-probe-management && npm run test:server-poll-management && npm run test:mcp:routing-authority && npm run test:mcp:native-readers && npm run test:mcp:chr-acquisition && npm run test:mcp:shared-context && npm run test:mcp:telemetry-configuration",
+ "test:server-privacy": "tsx ../packages/contracts/src/servers.test.ts && tsx src/routes/server-secrets-sql.test.ts && tsx --test src/services/server-connection-test.test.ts",
+ "test:mcp:flow-rebuild:pg": "node scripts/test-mcp-postgres.mjs --flow-rebuild-mcp",
+ "test:mcp:flow-host-keys:pg": "node scripts/test-mcp-postgres.mjs --flow-host-keys",
+ "test:mcp:loopback-agent": "tsx src/test/loopback-http-agent.test.ts",
+ "test:mcp:pending-foundations": "tsx src/services/server-poll-execution.test.ts && tsx src/services/server-probe-execution.test.ts && tsx src/services/ipsec-existing-certificate-export.test.ts && tsx src/modules/mcp/ipsec-existing-certificate-export-actions.test.ts && tsx src/modules/mcp/ipsec-existing-certificate-export-production.test.ts && tsx src/services/ipsec-existing-certificate-export-rest.test.ts && tsx src/services/ipsec-existing-certificate-export-rest-production.test.ts && tsx src/services/ipsec-existing-certificate-export-rest-journal.test.ts && tsx src/services/ipsec-existing-certificate-export-rest-http.test.ts && tsx src/services/ipsec-existing-certificate-export-artifact.test.ts && tsx src/modules/mcp/ipsec-existing-certificate-export-registration.test.ts",
+ "test:mcp:ipsec-create:pg": "node scripts/test-mcp-postgres.mjs --module-completion --only=ipsec-create --restore",
+ "test:mcp:ipsec-export-journal:pg": "node scripts/test-mcp-postgres.mjs --ipsec-export-journal --restore",
+ "test:mcp:ipsec-export:http:pg": "node scripts/test-mcp-postgres.mjs --ipsec-export-http --restore",
+ "test:mcp:diagnostic-cancel-host:pg": "node scripts/test-mcp-postgres.mjs --diagnostic-cancel-host --restore",
+ "test:server-probe-management": "tsx src/services/server-probe-authority.test.ts && tsx src/services/server-probe-public-result.test.ts && tsx src/services/server-probe-execution.test.ts && tsx src/services/server-probe-rest-contract.test.ts && tsx src/services/server-probe-rest-execution.test.ts && tsx src/services/server-probe-journal.test.ts && tsx src/services/server-probe-journal-history.test.ts && tsx src/modules/mcp/server-probe-actions.test.ts && tsx src/modules/mcp/diagnostic-cancellation.test.ts && tsx src/modules/mcp/service-diagnostic-progress.test.ts && tsx src/services/mikrotik-get-admission.test.ts && tsx src/services/server-probe-storage-journal-adapter.test.ts && npm run test:server-probe-history && npm run test:server-probe-storage-models",
+ "test:server-poll-http:pg": "node scripts/test-server-poll-http-owned.mjs",
+ "test:server-poll-approval:pg": "node scripts/test-server-poll-approval-owned.mjs",
+ "test:server-poll-atomic:pg": "node scripts/test-server-poll-atomic-owned.mjs",
+ "test:source-capture-adopted:pg": "node scripts/test-source-capture-adopted-postgres.mjs",
+ "test:server-poll-settings-epoch:pg": "node scripts/test-server-poll-settings-epoch-owned.mjs",
+ "test:server-poll-management": "tsx --test src/services/server-poll-maintenance-planner.test.ts src/services/server-poll-maintenance-groups.test.ts && tsx src/services/server-poll-execution.test.ts && tsx src/services/server-poll-production.test.ts && tsx src/services/server-poll-journal.test.ts && tsx src/services/server-poll-authority.test.ts && tsx src/services/server-poll-rest.test.ts && tsx src/services/server-partition-maintenance-lease.test.ts && npm run test:server-poll-storage && npm run test:partition-writers && tsx --test src/services/server-poll-history-verification.test.ts src/services/server-poll-terminal-source.test.ts src/services/server-poll-terminal-archive.test.ts src/services/server-poll-archive-accounting.test.ts src/services/server-poll-terminal-compaction.test.ts src/services/server-poll-history-reader.test.ts src/modules/mcp/server-poll-actions.test.ts src/modules/mcp/server-poll-production.test.ts src/modules/mcp/server-poll-registration.test.ts && tsx src/modules/mcp/effective-connection-source.test.ts && tsx src/services/server-poll-cost-diagnostics.test.ts && tsx src/services/server-poll-journal-snapshot.test.ts && tsx src/modules/mcp/principal-security-source.test.ts && tsx --test src/modules/mcp/poll-runtime-policy-source.test.ts src/modules/mcp/poll-policy-coordinator.test.ts && tsx src/services/server-poll-http.test.ts && tsx --test src/services/server-poll-approval-context.test.ts",
+ "test:server-poll-storage": "tsx src/services/server-poll-capacity.test.ts && tsx src/services/server-poll-storage-model.test.ts && tsx src/services/server-poll-storage.test.ts && tsx src/services/server-poll-storage-journal.test.ts && tsx src/services/server-poll-storage-retention.test.ts",
+ "test:bandwidth-admission:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-admission --restore",
+ "test:bandwidth-control-source:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-control-source --restore",
+ "test:bandwidth-control-source": "tsx src/services/bandwidth-control-role.test.ts && tsx src/services/bandwidth-control-catalog.test.ts && tsx --test src/services/bandwidth-control-identity.test.ts",
+ "bandwidth:control:seal": "tsx src/scripts/seal-bandwidth-control-source.ts",
+ "test:bandwidth-node-observation": "tsx src/services/bandwidth-node-observation.test.ts",
+ "test:bandwidth-peers": "tsx src/services/bandwidth-peer-observation.test.ts && tsx src/services/bandwidth-peer-network-observation.test.ts && tsx src/services/bandwidth-peer-direct-observation.test.ts && tsx src/services/bandwidth-operator-enrollment.test.ts && tsx --test --test-concurrency=1 src/services/bandwidth-control-registry-frame.test.ts src/services/bandwidth-control-registry-identity.test.ts src/services/bandwidth-node-identity.test.ts src/services/bandwidth-node-registry-batch.test.ts src/services/bandwidth-operator-docker-stop.test.ts src/services/bandwidth-operator-writer-window.test.ts src/services/bandwidth-operator-writer-composition.test.ts src/services/bandwidth-operator-registry.test.ts src/services/bandwidth-external-node-registry.test.ts src/services/bandwidth-external-node-registry-catalog.test.ts src/services/bandwidth-external-node-registry-role.test.ts src/modules/mcp/routing-bandwidth-original.test.ts src/services/bandwidth-peer-identity.test.ts src/services/bandwidth-peer-resolver.test.ts && node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/bandwidth-node-proof-batch.test.ts src/services/bandwidth-node-key-effect.test.ts src/services/bandwidth-control-file.test.ts src/services/bandwidth-node-bootstrap-v2.test.ts src/services/bandwidth-peer-fence.test.ts src/services/bandwidth-operator-public-files.test.ts src/services/bandwidth-registry-combined.test.ts && npm run test:bandwidth-public-metadata && npm run test:bandwidth-public-registry && npm run test:bandwidth-peer-metadata && npm run test:bandwidth-guarded-peer-sources",
+ "test:bandwidth-peers:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-external-registry",
+ "test:bandwidth-rest-origin:pg": "node scripts/test-mcp-postgres.mjs --rest-speed-original",
+ "test:peer-speed-workflow:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-speed-workflow",
+ "test:scheduled-speed-original:pg": "node scripts/test-mcp-postgres.mjs --scheduled-speed-original",
+ "test:operator-docker:pg": "node scripts/test-mcp-postgres.mjs --operator-docker-sql",
+ "test:bandwidth-public-metadata": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/bandwidth-control-public-metadata.test.ts src/services/bandwidth-node-public-metadata.test.ts",
+ "test:bandwidth-public-registry:pg": "node scripts/test-mcp-postgres.mjs --public-registry-metadata",
+ "test:bandwidth-public-registry": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/bandwidth-control-public-registry.test.ts src/services/bandwidth-node-public-registry.test.ts",
+ "test:bandwidth-peer-metadata": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/bandwidth-peer-metadata.test.ts src/services/bandwidth-peer-metadata-source.test.ts src/services/bandwidth-operator-metadata.test.ts",
+ "test:operator-peer-metadata:pg": "node scripts/test-mcp-postgres.mjs --operator-peer-metadata",
+ "test:bandwidth-guarded-peer-sources": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/server-probe-storage-connection.test.ts src/services/bandwidth-operator-peer-source-guard.test.ts src/services/bandwidth-external-peer-source.test.ts src/services/bandwidth-managed-peer-source.test.ts src/services/bandwidth-operator-peer-source-composition.test.ts",
+ "test:guarded-peer-sources:pg": "node scripts/test-mcp-postgres.mjs --external-peer-metadata",
+ "test:mcp:operation-origin": "node --experimental-test-module-mocks --import tsx --test src/modules/mcp/operation-execution-origin.test.ts",
+ "test:mcp:operation-origin:pg": "node scripts/test-mcp-postgres.mjs --mcp-operation-origin",
+ "test:mcp:speed-original": "node --import tsx --test src/modules/mcp/speed-bandwidth-original.test.ts",
+ "test:mcp:speed-original:pg": "node scripts/test-mcp-postgres.mjs --mcp-speed-original",
+ "test:router-configuration-guard:pg": "node scripts/test-mcp-postgres.mjs --router-configuration-guard",
+ "test:router-configuration-writer": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/router-configuration-writer-context.test.ts src/services/router-configuration-native-transport.test.ts",
+ "test:scheduled-speed-original": "node --experimental-test-module-mocks --import tsx src/services/bandwidth-scheduled-speed-original.test.ts",
+ "test:peer-speed-workflow": "node --experimental-test-module-mocks --import tsx --test src/services/bandwidth-speed-run-identity.test.ts src/services/bandwidth-speed-workflow.test.ts",
+ "test:bandwidth-node-registry:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-node-registry --restore",
+ "test:mcp:poll-terminal-claim-loss:pg": "node scripts/test-mcp-postgres.mjs --poll-terminal-archive-claim-loss --restore",
+ "test:mcp:poll-terminal-history-cold:pg": "node scripts/test-mcp-postgres.mjs --poll-terminal-archive-history-cold --restore",
+ "test:mcp:poll-terminal-history:pg": "node scripts/test-mcp-postgres.mjs --poll-terminal-archive-history --restore",
+ "test:mcp:poll-terminal-archive-lost-ack:pg": "node scripts/test-mcp-postgres.mjs --poll-terminal-archive-lost-ack --restore",
+ "test:mcp:poll-terminal-archive:pg": "node scripts/test-mcp-postgres.mjs --poll-terminal-archive --restore",
+ "test:mcp:poll-archive-schema:pg": "node scripts/test-mcp-postgres.mjs --poll-archive-schema",
+ "test:mcp:telemetry-configuration:pg": "node scripts/test-mcp-postgres.mjs --telemetry-settings-configuration",
+ "test:mcp:telemetry-configuration": "tsx --test src/modules/mcp/telemetry-settings-configuration.test.ts",
+ "test:mcp:routing-schema:pg": "node scripts/test-mcp-postgres.mjs --routing-reservation-schema",
+ "test:mcp:reserved-step": "tsx --test src/modules/mcp/routing-reserved-step.test.ts",
+ "test:mcp:routing-forward-rounds:pg": "node scripts/test-mcp-postgres.mjs --routing-network-forward-rounds",
+ "test:mcp:routing-original-effects:pg": "node scripts/test-mcp-postgres.mjs --routing-original-effects",
+ "test:flow-active-services:pg": "node scripts/test-mcp-postgres.mjs --flow-active-services",
+ "test:flow-active-rebuild:pg": "node scripts/test-mcp-postgres.mjs --flow-active-rebuild",
+ "test:flow-worker-ipc:pg": "node scripts/test-mcp-postgres.mjs --flow-worker-ipc",
+ "test:manual-uptime:pg": "node scripts/test-mcp-postgres.mjs --manual-uptime",
+ "test:manual-ping-group:pg": "node scripts/test-mcp-postgres.mjs --manual-ping-group",
+ "test:manual-traffic:pg": "node scripts/test-mcp-postgres.mjs --manual-traffic",
+ "test:manual-remaining": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/modules/mcp/manual-uptime-actions.test.ts src/modules/mcp/manual-ping-group-actions.test.ts src/modules/mcp/manual-traffic-actions.test.ts src/services/manual-data-collection-execution.test.ts src/routes/manual-data-collection.test.ts",
+ "test:manual-api-ping:pg": "node scripts/test-mcp-postgres.mjs --manual-api-ping",
+ "test:manual-api-ping": "node --experimental-test-module-mocks --import tsx --test src/modules/mcp/manual-api-ping-actions.test.ts src/services/manual-data-collection-execution.test.ts src/routes/manual-data-collection.test.ts",
+ "test:simple-speed:pg": "node scripts/test-mcp-postgres.mjs --simple-speed",
+ "test:simple-speed:chr": "node scripts/test-mcp-postgres.mjs --simple-speed-chr",
+ "test:simple-speed": "node --experimental-test-module-mocks --import tsx --test src/modules/mcp/speed-test-actions.test.ts src/services/uptime-speed-service.test.ts && node --import tsx --test src/routes/speed-test.test.ts src/services/speed-run-persistence.test.ts src/services/btest-node-locks.test.ts src/services/bandwidth-test-status.test.ts src/services/bandwidth-test-rates.test.ts",
+ "test:bandwidth-node-key-effect": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/bandwidth-node-key-effect.test.ts src/services/bandwidth-node-proof-batch.test.ts",
+ "test:bandwidth-node-source": "tsx src/services/bandwidth-node-registry-role.test.ts && tsx src/services/bandwidth-node-registry-catalog.test.ts",
+ "test:bandwidth-node-source:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-node-source --restore",
+ "test:mcp:service-context": "tsx --test src/services/config-mcp-service-execution.test.ts src/modules/mcp/temporary-grant-origin.test.ts src/modules/mcp/routing-measurement-origin.test.ts",
+ "test:mcp:service-context:pg": "node scripts/test-mcp-postgres.mjs --service-execution-origin",
+ "test:mcp:operation-locks": "tsx --test src/services/operation-config-lock-lease.test.ts && npm run test:scheduler-automatic",
+ "test:mcp:operation-locks:pg": "node scripts/test-mcp-postgres.mjs --operation-locks",
+ "test:scheduler-automatic": "node --test src/services/scheduler-automatic-root.test.mjs src/services/scheduler-automatic-authority.test.mjs",
+ "test:speed-workflow": "npm run test:router-configuration-writer && npm run test:mcp:speed-original && npm run test:scheduled-speed-original && npm run test:peer-speed-workflow && npm run test:bandwidth-node-observation && npm run test:bandwidth-native-permit && tsx src/services/bandwidth-admission.test.ts && tsx src/services/btest-node-locks.test.ts && tsx src/services/mikrotik-speed-admission.test.ts && tsx src/services/bandwidth-test-status.test.ts && tsx src/services/bandwidth-test-rates.test.ts && tsx src/services/speed-run-persistence.test.ts && tsx src/routes/speed-test.test.ts && tsx src/routes/speed-probes-write.test.ts",
+ "test:bandwidth-native-dispatch": "node --experimental-test-module-mocks --import tsx --test --test-concurrency=1 src/services/mikrotik-managed-source.test.ts src/services/bandwidth-native-dispatch-composite.test.ts src/services/bandwidth-peer-execution-host-fence.test.ts src/services/bandwidth-native-dispatch-source.test.ts src/services/bandwidth-native-dispatch.test.ts src/services/bandwidth-native-permit.test.ts src/services/bandwidth-admission.test.ts src/services/mikrotik-speed-admission.test.ts",
+ "test:bandwidth-native-permit": "tsx src/services/bandwidth-native-permit.test.ts",
+ "test:bandwidth-native-permit:pg": "node scripts/test-mcp-postgres.mjs --bandwidth-control-source --restore",
+ "test:server-poll-mcp": "tsx src/services/server-poll-boundary.test.ts && tsx src/modules/mcp/server-poll-actions.test.ts && tsx src/modules/mcp/server-poll-production.test.ts && tsx src/modules/mcp/server-poll-registration.test.ts",
+ "test:server-poll-storage:pg": "node scripts/test-mcp-postgres.mjs --server-poll-storage --restore",
+ "test:server-poll-storage-fresh:pg": "node scripts/test-mcp-postgres.mjs --server-poll-storage-fresh --restore",
+ "test:partition-writers": "tsx src/services/partition-write-transaction.test.ts && tsx src/services/collector-partition-writes.test.ts && tsx src/db/partitions-writer.test.ts && tsx src/db/migrate-partition-admission.test.ts && tsx src/db/migration-manifest.test.ts && tsx src/db/sqlite-import-partition-admission.test.ts && tsx src/services/system-database-partition-restore.test.ts && tsx src/services/traffic-flow-write-transaction.test.ts && tsx src/services/traffic-flow-facts-rebuild-cli.test.ts",
+ "test:mcp:routing-authority": "tsx --test src/modules/mcp/routing-switch-ledger-contract.test.ts && tsx src/modules/mcp/routing-profile-authority.test.ts && tsx src/modules/mcp/routing-recovery-authority.test.ts && tsx src/modules/mcp/routing-reservation.test.ts && tsx src/modules/mcp/routing-community-reserved-source.test.ts && tsx src/modules/mcp/routing-network-verifier-model.test.ts && tsx --test src/test/committed-scoped-checkpoint-observer.test.ts && node --test src/modules/mcp/routing-forward-transport-charge.test.cjs",
+ "test:mcp:native-readers": "tsx src/modules/mcp/routing-network-verifier-model.test.ts && tsx src/modules/mcp/routing-network-native-parser.test.ts && tsx src/modules/mcp/routing-network-native-session.test.ts && tsx src/db/migration-schema-inventory.test.ts && tsx src/modules/mcp/routing-network-observation-assembly.test.ts && tsx src/modules/mcp/routing-network-configuration-bridge.test.ts && tsx --test src/services/routing-table-fib.test.ts src/services/routing-topology-observation.test.ts && node --test src/modules/mcp/routing-original-effects.test.mjs src/modules/mcp/routing-original-effects-caller.test.mjs src/modules/mcp/routing-original-effects-controller.test.mjs src/modules/mcp/routing-network-execution-origin.test.mjs",
+ "test:mcp:native-readers:pg": "node scripts/test-mcp-postgres.mjs --routing-network-native --restore",
+ "test:mcp:schema-inventory:pg": "node scripts/test-mcp-postgres.mjs --migration-schema-inventory --restore",
+ "test:mcp:native-tls": "tsx src/modules/mcp/routing-network-native-tls.test.ts",
+ "test:mcp:schema-control:pg": "node scripts/test-mcp-postgres.mjs --database-schema-control --restore",
+ "test:mcp:chr-acquisition": "node --test scripts/acceptance/chr-recursive-observation.test.mjs",
+ "test:mcp:controlled-migrations:pg": "node scripts/test-mcp-postgres.mjs --controlled-migrations --restore",
+ "test:mcp:shared-context": "tsx --test src/modules/mcp/routing-network-scoped-context.test.ts",
+ "test:mcp:controlled-reference:pg": "node scripts/test-mcp-postgres.mjs --controlled-schema-reference --restore",
+ "test:server-probe-storage-fresh:pg": "node scripts/test-mcp-postgres.mjs --probe-storage-fresh --restore",
+ "test:server-poll-durable:pg": "node scripts/test-mcp-postgres.mjs --server-poll-durable --restore",
+ "test:server-probe-legacy:pg": "node scripts/test-mcp-postgres.mjs --probe-legacy-orphans",
+ "test:server-probe-storage:pg": "node scripts/test-mcp-postgres.mjs --probe-storage-journal",
+ "test:server-probe-history": "tsx --test src/services/server-probe-storage-history.test.ts src/services/server-probe-retired-source.test.ts",
+ "test:server-probe-history:pg": "node scripts/test-mcp-postgres.mjs --probe-storage-history",
+ "test:server-probe-retirement:pg": "node scripts/test-mcp-postgres.mjs --probe-operation-retirement",
+ "test:server-probe-storage-models": "tsx src/services/server-probe-journal-maintenance.test.ts && tsx src/modules/mcp/diagnostic-cancellation-source.test.ts && tsx src/services/server-probe-storage-source.test.ts && tsx src/services/server-probe-storage-connection.test.ts && tsx src/modules/mcp/server-probe-storage-host.test.ts && tsx src/services/server-probe-storage-rest.test.ts && tsx src/services/server-probe-storage-metadata.test.ts && tsx src/services/server-probe-legacy-verifier.test.ts && tsx src/services/server-probe-legacy-snapshot.test.ts && tsx src/services/server-probe-legacy-inspection.test.ts && tsx src/db/database-source-observation.test.ts && tsx src/services/server-probe-retention.test.ts && tsx src/modules/mcp/server-probe-registration.test.ts",
+ "test:mcp:migration-data:pg": "node scripts/test-mcp-postgres.mjs --migration-data-inventory --restore",
+ "test:mcp:poll-memory:pg": "npm run build -w @mmapp/contracts && node scripts/acceptance/build-poll-memory.mjs && node scripts/test-mcp-postgres.mjs --poll-memory",
+ "test:mcp:poll-memory-bootstrap:pg": "npm run build -w @mmapp/contracts && node scripts/acceptance/build-poll-memory.mjs && node scripts/test-mcp-postgres.mjs --poll-memory-bootstrap",
+ "test:mcp:poll-memory-cost:pg": "npm run build -w @mmapp/contracts && node scripts/acceptance/build-poll-memory.mjs && node scripts/test-mcp-postgres.mjs --poll-memory-cost",
+ "test:mcp:poll-journal-snapshot:pg": "node scripts/test-mcp-postgres.mjs --poll-journal-snapshot",
+ "test:mcp:principal-security-source:pg": "node scripts/test-mcp-postgres.mjs --principal-security-source",
+ "test:traffic-flow:read-budget": "tsx --test src/services/traffic-flow-read-budget.test.ts src/modules/mcp/flow-read-quality.test.ts && node scripts/test-flow-read-adapters.mjs",
+ "test:traffic-flow:read-http:pg": "node scripts/test-flow-read-http-owned.mjs",
+ "test:traffic-flow:read-source:pg": "tsx scripts/test-flow-read-sql-owned.mts",
+ "test:mcp:routing-baseline": "tsx --test src/modules/mcp/routing-controller-active-writer.test.ts src/modules/mcp/routing-controller-baseline.test.ts src/modules/mcp/routing-controller-fence.test.ts src/modules/mcp/routing-community-public.test.ts src/modules/mcp/routing-controller-overlap.test.ts",
+ "test:mcp:routing-baseline:pg": "node scripts/test-routing-controller-baseline.mjs",
+ "test:mcp:routing-baseline-inverse:pg": "node scripts/test-routing-controller-baseline.mjs --default-scoped",
+ "test:sqlite-import-control:pg": "node scripts/test-sqlite-import-control-postgres.mjs",
+ "test:traffic-flow:resource-profile": "tsx --test src/services/traffic-flow-read-resource-profile.test.ts && node scripts/test-flow-read-profile-startup.mjs",
+ "test:traffic-flow:settings-read-profiles:pg": "node scripts/test-flow-settings-read-profiles-owned.mjs",
+ "test:database-source-binding": "node scripts/test-database-source-binding.mjs"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.888.0",
@@ -50,6 +194,10 @@
"@fastify/jwt": "^10.2.2",
"@fastify/type-provider-zod": "^1.0.0",
"@mmapp/contracts": "1.0.0",
+ "@modelcontextprotocol/client": "2.3.1",
+ "@modelcontextprotocol/fastify": "2.0.1",
+ "@modelcontextprotocol/node": "2.1.1",
+ "@modelcontextprotocol/server": "2.3.1",
"acme-client": "^5.4.0",
"better-sqlite3": "^12.9.0",
"dotenv": "^16.4.7",
@@ -66,6 +214,7 @@
"@types/node": "^22.15.3",
"@types/pg": "^8.23.1",
"drizzle-kit": "^0.31.10",
+ "embedded-postgres": "18.4.0-beta.17",
"jose": "^6.2.11",
"pino-pretty": "^13.1.3",
"tsx": "^4.19.3",
diff --git a/backend/scripts/acceptance/build-chr-netflow-collector-smoke.mjs b/backend/scripts/acceptance/build-chr-netflow-collector-smoke.mjs
new file mode 100644
index 00000000..b4ccefe9
--- /dev/null
+++ b/backend/scripts/acceptance/build-chr-netflow-collector-smoke.mjs
@@ -0,0 +1,72 @@
+import { createHash } from 'node:crypto';
+import { execFileSync } from 'node:child_process';
+import { cpSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const root = fileURLToPath(new URL('../../../', import.meta.url));
+const baseRevision = 'bf3d50e1ff2ee3b5c9268991a255c3b49ce6378e';
+const sha = bytes => createHash('sha256').update(bytes).digest('hex');
+const require = (value, reason) => { if (!value) throw Error(reason); };
+const git = (...args) => execFileSync('git', args, { cwd: root, stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 4 * 1024 * 1024 });
+const fromRoot = filename => path.join(root, filename);
+const readJson = bytes => JSON.parse(bytes.toString('utf8'));
+const manifestPath = ['backend/package.json', 'packages/contracts/package.json'];
+const runtimeKeys = ['type', 'exports', 'engines', 'dependencies', 'optionalDependencies', 'peerDependencies'];
+const normalizeLock = bytes => bytes.toString('utf8').replace(/\r\n/g, '\n');
+const sort = values => [...new Set(values)].sort();
+
+function runtimePins() {
+ const lockFile = readFileSync(fromRoot('package-lock.json'));
+ require(normalizeLock(lockFile) === normalizeLock(git('show', baseRevision + ':package-lock.json')), 'Runtime lock differs from cached source');
+ const lock = readJson(lockFile).packages;
+ return manifestPath.flatMap(filename => {
+ const current = readJson(readFileSync(fromRoot(filename)));
+ const cached = readJson(git('show', baseRevision + ':' + filename));
+ for (const key of runtimeKeys) {
+ require(JSON.stringify(current[key]) === JSON.stringify(cached[key]), 'Runtime package manifest differs from cached source');
+ }
+ const workspace = path.posix.dirname(filename);
+ return sort(Object.keys(current.dependencies ?? {})).filter(name => name !== '@mmapp/contracts').map(name => {
+ const nested = workspace + '/node_modules/' + name, shared = 'node_modules/' + name;
+ const installed = lock[nested] ? nested : shared;
+ const version = lock[installed]?.version;
+ require(typeof version === 'string', 'Runtime dependency pin unavailable');
+ return { path: installed + '/package.json', name, version };
+ });
+ }).filter((item, index, all) => all.findIndex(other => other.path === item.path) === index);
+}
+
+function compile(project, outDir) {
+ execFileSync(process.execPath, [fromRoot('node_modules/typescript/bin/tsc'), '--project', fromRoot(project), '--outDir', outDir,
+ '--declaration', 'false', '--declarationMap', 'false', '--sourceMap', 'false', '--incremental', 'false'],
+ { cwd: root, stdio: 'inherit' });
+}
+
+function files(directory, prefix = '') {
+ return readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name)).flatMap(entry => {
+ const key = prefix + entry.name, item = path.join(directory, entry.name);
+ if (entry.isDirectory()) return files(item, key + '/');
+ require(entry.isFile(), 'Packet contains a nonregular entry');
+ const bytes = readFileSync(item);
+ return [{ path: key, size: bytes.length, sha256: sha(bytes) }];
+ });
+}
+
+const [runId, ...extra] = process.argv.slice(2);
+require(/^[a-f0-9]{8}$/.test(runId ?? '') && !extra.length, 'Expected one eight-digit hexadecimal run ID');
+const directory = fromRoot('tmp/mcp-netflow-smoke-packet-' + runId);
+const dependencies = runtimePins();
+mkdirSync(directory);
+compile('packages/contracts/tsconfig.json', path.join(directory, 'contracts-dist'));
+compile('backend/tsconfig.json', path.join(directory, 'dist'));
+require(statSync(path.join(directory, 'dist/test/traffic-flow-chr-collector-bootstrap.js')).isFile(), 'Compiled collector entry unavailable');
+cpSync(fromRoot('backend/drizzle'), path.join(directory, 'drizzle'), { recursive: true, errorOnExist: true });
+const entries = files(directory);
+require(entries.length > 0 && entries.length <= 4096 && entries.reduce((sum, entry) => sum + entry.size, 0) <= 128 * 1024 * 1024,
+ 'Packet budget exceeded');
+const body = Buffer.from(JSON.stringify({ format: 'mmapp-netflow-collector-smoke-v1', cachedSourceRevision: baseRevision, dependencies,
+ files: entries }, null, 2) + '\n');
+writeFileSync(path.join(directory, 'manifest.json'), body, { flag: 'wx' });
+console.log(JSON.stringify({ directory, manifestSha256: sha(body), files: entries.length, dependencies: dependencies.length,
+ collectorStarted: false, networkUsed: false }));
diff --git a/backend/scripts/acceptance/build-installation-memory.mjs b/backend/scripts/acceptance/build-installation-memory.mjs
new file mode 100644
index 00000000..5fba363a
--- /dev/null
+++ b/backend/scripts/acceptance/build-installation-memory.mjs
@@ -0,0 +1,22 @@
+/** Separate output: never replace an in-flight or accepted poll-memory tree. */
+import assert from 'node:assert/strict'
+import { mkdir, lstat } from 'node:fs/promises'
+import { dirname, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import ts from 'typescript'
+assert(process.argv.length===2||process.argv.length===3,'Supply at most one new output name')
+const outputName=process.argv[2]??'dist-installation-memory'
+assert(/^dist-installation-memory(?:-[a-z0-9-]{3,64})?$/.test(outputName),'Invalid compiled output name')
+const backend=resolve(dirname(fileURLToPath(import.meta.url)),'../..'), output=resolve(backend,outputName)
+const existing=await lstat(output).catch(error=>{if(error.code!=='ENOENT')throw error})
+assert(!existing,'Use a new output directory; no implicit cleanup or concurrent rebuild')
+await mkdir(output)
+const configPath=resolve(backend,'tsconfig.json'),config=ts.readConfigFile(configPath,ts.sys.readFile)
+assert(!config.error)
+const parsed=ts.parseJsonConfigFileContent(config.config,ts.sys,backend,undefined,configPath)
+const options={...parsed.options,rootDir:resolve(backend,'src'),outDir:output,noEmit:false,noEmitOnError:true,declaration:false,declarationMap:false,sourceMap:false,incremental:false,composite:false,tsBuildInfoFile:undefined}
+const roots=['src/services/installation-co-load.owned.test.ts','src/services/traffic-flow-collector-worker.ts'].map(file=>resolve(backend,file))
+const program=ts.createProgram({rootNames:roots,options}),diagnostics=ts.getPreEmitDiagnostics(program)
+if(diagnostics.length)throw Error(ts.formatDiagnosticsWithColorAndContext(diagnostics,{getCurrentDirectory:()=>backend,getCanonicalFileName:file=>file,getNewLine:()=> '\n'}))
+assert(!program.emit().emitSkipped)
+console.log(JSON.stringify({output,rootEntries:roots.length,actualWorkerIncluded:true,productionModulesSubstituted:false}))
diff --git a/backend/scripts/acceptance/build-poll-memory.mjs b/backend/scripts/acceptance/build-poll-memory.mjs
new file mode 100644
index 00000000..6a837d2f
--- /dev/null
+++ b/backend/scripts/acceptance/build-poll-memory.mjs
@@ -0,0 +1,36 @@
+/** Emit one owned memory entry plus its actual production import tree. The
+ * measured child runs plain node, not the TypeScript compiler or tsx. */
+import assert from 'node:assert/strict'
+import { lstat, rm } from 'node:fs/promises'
+import { dirname, basename, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import ts from 'typescript'
+
+const backend = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
+const output = resolve(backend, 'dist-mcp-memory')
+assert.equal(dirname(output), backend)
+assert.equal(basename(output), 'dist-mcp-memory')
+const existing = await lstat(output).catch(error => { if (error.code !== 'ENOENT') throw error })
+assert(!existing?.isSymbolicLink(), 'Refuse to clean a redirected output directory')
+if (existing) await rm(output, { recursive: true })
+const configPath = resolve(backend, 'tsconfig.json')
+const config = ts.readConfigFile(configPath, ts.sys.readFile)
+const format = diagnostics => ts.formatDiagnosticsWithColorAndContext(diagnostics, {
+ getCurrentDirectory: () => backend, getCanonicalFileName: name => name, getNewLine: () => '\n',
+})
+if (config.error) throw Error(format([config.error]))
+const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, backend, undefined, configPath)
+if (parsed.errors.length) throw Error(format(parsed.errors))
+const entry = resolve(backend, 'src/services/server-poll-memory.owned.test.ts')
+const options = { ...parsed.options, rootDir: resolve(backend, 'src'), outDir: output,
+ noEmit: false, noEmitOnError: true, declaration: false, declarationMap: false, sourceMap: false,
+ incremental: false, composite: false, tsBuildInfoFile: undefined }
+// Deliberately override tsconfig include/exclude with this single test root.
+// TypeScript still follows all normal imports; no module/path/IO substitutes.
+const program = ts.createProgram({ rootNames: [entry], options })
+const diagnostics = ts.getPreEmitDiagnostics(program)
+if (diagnostics.length) throw Error(format(diagnostics))
+const emitted = program.emit()
+if (emitted.emitSkipped || emitted.diagnostics.length) throw Error(format(emitted.diagnostics) || 'Memory entry emit skipped')
+console.log(JSON.stringify({ compiledPollMemoryEntry: resolve(output, 'services/server-poll-memory.owned.test.js'),
+ outputDirectory: output, rootEntries: 1, noEmitOnError: true, measuredChildUsesTsx: false }))
diff --git a/backend/scripts/acceptance/chr-netflow-collector-container.py b/backend/scripts/acceptance/chr-netflow-collector-container.py
new file mode 100644
index 00000000..97a26206
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-collector-container.py
@@ -0,0 +1,325 @@
+"""Fixed, opt-in local Docker owner for the disposable NetFlow collector."""
+import argparse
+import json
+import os
+import re
+import secrets
+import stat
+import subprocess
+import sys
+from pathlib import Path
+
+PG_IMAGE = 'postgres@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873'
+NODE_IMAGE = 'git.shx.one/denozord/mikrotikmanager-backend-mcp-acceptance@sha256:151ab635caca5f2f6b50a9d0c27980a1559d7bd67f0e3a8d2b74cfa3f9ec6945'
+CID = re.compile(r'[a-f0-9]{64}\Z')
+RUN = re.compile(r'[a-f0-9]{8}\Z')
+LABEL = 'io.mmapp.netflow.run'
+ENV = {'PATH': '/usr/sbin:/usr/bin:/sbin:/bin', 'LC_ALL': 'C',
+ 'HOME': '/nonexistent', 'DOCKER_CONFIG': '/nonexistent'}
+
+
+def require(value, code):
+ if not value:
+ raise ValueError(code)
+
+
+def root(run):
+ require(isinstance(run, str) and RUN.fullmatch(run), 'RUN_ID_REFUSED')
+ return '/tmp/mcp-netflow-' + run
+
+
+def mounts(source, target, readonly=False):
+ return ['--mount', 'type=bind,src=' + source + ',dst=' + target + (',readonly' if readonly else '')]
+
+
+def build_pg(run, uid, gid):
+ base = root(run)
+ require(type(uid) is int and 0 < uid <= 65534 and type(gid) is int and 0 < gid <= 65534, 'FIXTURE_ACCOUNT_REFUSED')
+ return [
+ 'create', '--pull=never', '--name', 'mm-nf-pg-' + run,
+ '--label', LABEL + '=' + run, '--label', 'io.mmapp.netflow.role=postgres',
+ '--network=none', '--user', f'{uid}:{gid}', '--read-only',
+ '--cap-drop=ALL', '--security-opt=no-new-privileges',
+ '--memory=192m', '--memory-swap=192m',
+ '--tmpfs', '/tmp:rw,nosuid,nodev,noexec,mode=1777,size=32m',
+ '--tmpfs', '/var/run/postgresql:rw,nosuid,nodev,noexec,mode=1777,size=1m',
+ *mounts(base + '/pg', '/owned-pg'),
+ *mounts(base + '/pg-socket', base + '/pg-socket'),
+ *mounts(base + '/pg-password', '/run/mm-netflow-pg-secret', True),
+ '--env', 'PGDATA=/owned-pg/data', '--env', 'POSTGRES_USER=mcp_test',
+ '--env', 'POSTGRES_DB=mcp_netflow_' + run,
+ '--env', 'POSTGRES_PASSWORD_FILE=/run/mm-netflow-pg-secret',
+ '--env', 'POSTGRES_INITDB_ARGS=--auth-local=scram-sha-256 --auth-host=scram-sha-256',
+ PG_IMAGE, 'postgres', '-c', 'listen_addresses=', '-c', 'unix_socket_directories=' + base + '/pg-socket',
+ '-c', 'unix_socket_permissions=0700',
+ ]
+
+
+def build_node(run, uid, gid, anchor_id, port, namespace, host_namespace, packet_digest):
+ base = root(run)
+ require(type(uid) is int and 0 < uid <= 65534 and type(gid) is int and 0 < gid <= 65534, 'FIXTURE_ACCOUNT_REFUSED')
+ require(isinstance(anchor_id, str) and CID.fullmatch(anchor_id), 'ANCHOR_ID_REFUSED')
+ require(isinstance(packet_digest, str) and CID.fullmatch(packet_digest), 'PACKET_PIN_REFUSED')
+ require(type(port) is int and 49152 <= port <= 65535, 'COLLECTOR_PORT_REFUSED')
+ require(all(type(pair) in (tuple, list) and len(pair) == 2 and
+ all(type(value) is int and 0 < value < 2**64 for value in pair)
+ for pair in (namespace, host_namespace)) and list(namespace) != list(host_namespace), 'NAMESPACE_PINS_REFUSED')
+ return [
+ 'create', '--pull=never', '--name', 'mm-nf-node-' + run,
+ '--label', LABEL + '=' + run, '--label', 'io.mmapp.netflow.role=collector',
+ '--network=container:' + anchor_id, '--user', f'{uid}:{gid}', '--read-only',
+ '--cap-drop=ALL', '--security-opt=no-new-privileges', '--interactive', '--tty',
+ '--memory=320m', '--memory-swap=320m',
+ '--tmpfs', '/tmp:rw,nosuid,nodev,noexec,mode=1777,size=32m',
+ *mounts(base + '/collector', base),
+ *mounts(base + '/pg-socket', base + '/pg-socket'),
+ *mounts(base + '/pg-password', '/run/mm-netflow-pg-secret', True),
+ *mounts(base + '/packet/dist', '/app/backend/dist', True),
+ *mounts(base + '/packet/drizzle', '/app/backend/drizzle', True),
+ *mounts(base + '/packet/contracts-dist', '/app/packages/contracts/dist', True),
+ *mounts(base + '/packet/manifest.json', '/run/mm-netflow-packet.json', True),
+ '--workdir', base, '--env', 'MMAPP_OWN_CHR_NETFLOW_COLLECTOR=true',
+ '--env', 'MMAPP_NETFLOW_PACKET_SHA256=' + packet_digest,
+ '--entrypoint', 'node', NODE_IMAGE,
+ '--max-old-space-size=160', '--max-semi-space-size=8',
+ '/app/backend/dist/test/traffic-flow-chr-collector-bootstrap.js',
+ '--container-collector-cycle', run, str(port), *map(str, namespace), *map(str, host_namespace),
+ ]
+
+
+def capture_args(run, first, second, port):
+ root(run)
+ require((first, second) == ('198.18.241.2', '198.18.241.9') and
+ type(port) is int and 49152 <= port <= 65535, 'CAPTURE_SCOPE_REFUSED')
+ return ['nsenter', '--net=/run/netns/nf' + run + 'nc', '--',
+ 'tcpdump', '-n', '-p', '-U', '-i', 'nf' + run + 'cv', '-y', 'EN10MB', '-s', '4138',
+ '-c', '64', '-w', '-', 'udp and dst host 198.18.242.3 and dst port ' + str(port) +
+ ' and (src host ' + first + ' or src host ' + second + ')']
+
+
+def local_docker():
+ require(sys.platform == 'linux' and os.geteuid() == 0 and
+ os.environ.get('MMAPP_OWN_CHR_NETFLOW_CONTAINER') == 'true', 'DOCKER_OWNER_REFUSED')
+ socket = Path('/var/run/docker.sock')
+ require(stat.S_ISSOCK(socket.stat().st_mode), 'LOCAL_DOCKER_SOCKET_UNAVAILABLE')
+ choices = [Path(folder, 'docker') for folder in ('/usr/bin', '/usr/sbin', '/bin')]
+ binary = next((path.resolve(strict=True) for path in choices if path.is_file()), None)
+ require(binary is not None and binary.stat().st_uid == 0 and not binary.stat().st_mode & 0o022,
+ 'DOCKER_BINARY_UNPINNED')
+
+ def call(*args):
+ result = subprocess.run([str(binary), '--host', 'unix:///var/run/docker.sock', *args],
+ env=ENV, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
+ stderr=subprocess.DEVNULL, timeout=30)
+ require(result.returncode == 0 and len(result.stdout) <= 256 * 1024, 'DOCKER_OUTCOME_UNCONFIRMED')
+ return result.stdout.decode('utf-8', 'strict').strip()
+
+ def attach(cid):
+ require(CID.fullmatch(cid) and sys.stdin.isatty() and sys.stdout.isatty(), 'EXACT_TTY_REFUSED')
+ return subprocess.run([str(binary), '--host', 'unix:///var/run/docker.sock', 'start', '--attach', '--interactive', cid],
+ env=ENV, timeout=330).returncode
+
+ return call, attach
+
+
+def prepare_private_storage(run, uid, gid):
+ """Create only new private bind sources. A retained fixture is never reused."""
+ require(sys.platform == 'linux' and os.geteuid() == 0 and
+ os.environ.get('MMAPP_OWN_CHR_NETFLOW_CONTAINER') == 'true', 'DOCKER_OWNER_REFUSED')
+ require(type(uid) is int and 0 < uid <= 65534 and type(gid) is int and 0 < gid <= 65534, 'FIXTURE_ACCOUNT_REFUSED')
+ base = Path(root(run))
+ info = base.lstat()
+ require(base.resolve(strict=True) == base and stat.S_ISDIR(info.st_mode) and info.st_uid == uid and
+ stat.S_IMODE(info.st_mode) == 0o700, 'FIXTURE_ROOT_REFUSED')
+ for name in ('pg', 'pg-socket', 'collector'):
+ directory = base / name
+ directory.mkdir(mode=0o700)
+ os.chown(directory, uid, gid, follow_symlinks=False)
+ fd = os.open(base / 'pg-password', os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o400)
+ with os.fdopen(fd, 'wb') as output:
+ output.write((secrets.token_hex(32) + '\n').encode('ascii'))
+ output.flush()
+ os.fsync(output.fileno())
+ os.fchown(output.fileno(), uid, gid)
+
+
+class CollectorContainerOwner:
+ """Outer Linux parent retains each acknowledged ID and journals it.
+
+ An unknown create/start/retire acknowledgement requires reconciliation.
+ It never searches by label, restarts, prunes, or removes a matched name.
+ """
+ def __init__(self, run, docker, checkpoint):
+ root(run)
+ self.run, self.docker, self.checkpoint = run, docker, checkpoint
+ self.ids = {}
+ self.attempted = set()
+ self.verified_exits = {}
+ self.anchor_start = None
+ self.adopted = None
+ self.topology_retired = False
+
+ def image(self, reference):
+ rows = json.loads(self.docker('image', 'inspect', reference))
+ require(len(rows) == 1 and reference in rows[0]['RepoDigests'] and rows[0]['Os'] == 'linux' and
+ re.fullmatch(r'sha256:[a-f0-9]{64}', rows[0]['Id']), 'CACHED_IMAGE_UNPINNED')
+ return rows[0]['Id']
+
+ def inspect(self, cid, role, image_id, network):
+ require(CID.fullmatch(cid), 'CONTAINER_ID_UNPINNED')
+ rows = json.loads(self.docker('container', 'inspect', cid))
+ require(len(rows) == 1, 'CONTAINER_UNCONFIRMED')
+ row = rows[0]
+ labels = row['Config']['Labels']
+ memory = (192 if role == 'postgres' else 320) * 1024 * 1024
+ require(row['Id'] == cid and row['Image'] == image_id and labels[LABEL] == self.run and
+ labels['io.mmapp.netflow.role'] == role and row['HostConfig']['NetworkMode'] == network and
+ not row['HostConfig']['Privileged'] and not row['HostConfig']['PortBindings'] and
+ row['HostConfig']['ReadonlyRootfs'] is True and row['HostConfig']['CapDrop'] == ['ALL'] and
+ not row['HostConfig']['CapAdd'] and row['HostConfig']['Memory'] == memory and
+ row['HostConfig']['MemorySwap'] == memory, 'CONTAINER_SCOPE_DRIFT')
+ return row['State']
+
+ def _create(self, role, argv, reference, network):
+ require(role not in self.attempted, 'CONTAINER_REPLAY_REFUSED')
+ self.attempted.add(role)
+ image_id = self.image(reference)
+ self.checkpoint(role, 'create-intent', None)
+ cid = self.docker(*argv)
+ require(CID.fullmatch(cid), 'CREATE_ACK_UNCONFIRMED')
+ self.checkpoint(role, 'create-acknowledged', cid)
+ state = self.inspect(cid, role, image_id, network)
+ require(state['Status'] == 'created' and state['Running'] is False, 'CREATED_STATE_UNCONFIRMED')
+ self.ids[role] = (cid, image_id, network)
+ self.checkpoint(role, 'create-verified', cid)
+ return cid
+
+ def create_anchor(self, uid, gid):
+ return self._create('postgres', build_pg(self.run, uid, gid), PG_IMAGE, 'none')
+
+ def create_collector(self, uid, gid, port, namespace, host_namespace, packet_digest, assert_packet):
+ anchor_id, image_id, network = self.ids['postgres']
+ anchor = self.inspect(anchor_id, 'postgres', image_id, network)
+ require(anchor['Running'] is True and anchor['Pid'] > 0, 'ANCHOR_PID_UNCONFIRMED')
+ require(self.adopted is not None, 'C_ADOPTION_UNCONFIRMED')
+ adopted, read_mount = self.adopted
+ require(adopted == self.anchor_namespace() and adopted['namespace'] == list(namespace) and
+ adopted['hostNamespace'] == list(host_namespace) and read_mount() == adopted['namespace'],
+ 'C_ADOPTION_DRIFT')
+ assert_packet()
+ return self._create('collector', build_node(self.run, uid, gid, anchor_id, port, namespace, host_namespace, packet_digest),
+ NODE_IMAGE, 'container:' + anchor_id)
+
+ def start_anchor(self):
+ cid, image_id, network = self.ids['postgres']
+ require('postgres-start' not in self.attempted, 'CONTAINER_REPLAY_REFUSED')
+ self.attempted.add('postgres-start')
+ self.checkpoint('postgres', 'start-intent', cid)
+ require(self.docker('start', cid) == cid, 'START_ACK_UNCONFIRMED')
+ state = self.inspect(cid, 'postgres', image_id, network)
+ require(state['Running'] is True and type(state['Pid']) is int and state['Pid'] > 0 and
+ re.fullmatch(r'\d{4}-\d{2}-\d{2}T[0-9:.]+Z', state['StartedAt']), 'ANCHOR_PID_UNCONFIRMED')
+ self.checkpoint('postgres', 'start-verified', cid)
+ self.anchor_start = (state['Pid'], state['StartedAt'])
+ return state['Pid']
+
+ def anchor_namespace(self):
+ """Return live anchor and host netns pins for the topology owner."""
+ require(sys.platform == 'linux' and os.geteuid() == 0, 'LINUX_OWNER_REQUIRED')
+ cid, image_id, network = self.ids['postgres']
+ state = self.inspect(cid, 'postgres', image_id, network)
+ pid = state['Pid']
+ started_at = state['StartedAt']
+ require(state['Running'] is True and self.anchor_start == (pid, started_at), 'ANCHOR_PID_UNCONFIRMED')
+ pin = Path('/proc', str(pid), 'ns/net').stat()
+ host = Path('/proc/self/ns/net').stat()
+ namespace, host_namespace = [pin.st_dev, pin.st_ino], [host.st_dev, host.st_ino]
+ latest = self.inspect(cid, 'postgres', image_id, network)
+ require(latest['Running'] is True and latest['Pid'] == pid and latest['StartedAt'] == started_at and
+ namespace != host_namespace,
+ 'ANCHOR_NAMESPACE_DRIFT')
+ return {'containerId': cid, 'pid': pid, 'startedAt': started_at,
+ 'namespace': namespace, 'hostNamespace': host_namespace}
+
+ def create_linux_topology(self, executor, backend, journal, planned, pins):
+ """Bridge the exact live anchor into the existing guarded Linux owner."""
+ name = 'nf' + self.run + 'nc'
+ require(pins['nonce'][:8] == self.run and planned['names']['C'] == name, 'TOPOLOGY_RUN_DIFFERS')
+ require('topology-adopt' not in self.attempted, 'C_ADOPTION_REPLAY_REFUSED')
+ self.attempted.add('topology-adopt')
+ result = executor(backend, journal, planned, pins, read_collector_anchor=self.anchor_namespace)
+ adopted = journal.value['collectorAnchor']
+ require(adopted == self.anchor_namespace() and backend.namespace(name) == adopted['namespace'],
+ 'C_ADOPTION_DRIFT')
+ self.adopted = (adopted, lambda: backend.namespace(name))
+ return result
+
+ def assert_linux_anchor_exited(self, recorded):
+ """Validate the journalled container and its exact exit before C cleanup."""
+ cid, image_id, network = self.ids['postgres']
+ require(recorded['containerId'] == cid and 'postgres' in self.verified_exits and
+ ('collector' not in self.ids or 'collector' in self.verified_exits), 'ANCHOR_EXIT_NOT_OWNED')
+ state = self.inspect(cid, 'postgres', image_id, network)
+ require(state['Running'] is False and state['Status'] == 'exited' and state['Pid'] == 0 and
+ state['StartedAt'] == recorded['startedAt'] == self.verified_exits['postgres'], 'ANCHOR_EXIT_UNCONFIRMED')
+
+ def cleanup_linux_topology(self, executor, backend, journal, planned):
+ require(self.adopted is not None and self.adopted[0] == journal.value.get('collectorAnchor') and
+ backend.root_baseline() == journal.value.get('rootBaseline'), 'TOPOLOGY_CLEANUP_SCOPE_DRIFT')
+ executor(backend, journal, planned, assert_collector_anchor_exited=self.assert_linux_anchor_exited)
+ require(journal.value['state'] == 'retired' and backend.root_baseline() == journal.value['rootBaseline'],
+ 'TOPOLOGY_CLEANUP_UNCONFIRMED')
+ self.topology_retired = True
+
+ def start_collector(self, attach):
+ cid, image_id, network = self.ids['collector']
+ require('collector-start' not in self.attempted, 'CONTAINER_REPLAY_REFUSED')
+ require(self.adopted is not None and self.adopted[0] == self.anchor_namespace() and
+ self.adopted[1]() == self.adopted[0]['namespace'], 'C_ADOPTION_DRIFT')
+ self.attempted.add('collector-start')
+ self.checkpoint('collector', 'start-intent', cid)
+ status = attach(cid)
+ state = self.inspect(cid, 'collector', image_id, network)
+ require(state['Running'] is False and state['Status'] == 'exited' and state['Pid'] == 0 and
+ state['ExitCode'] == status and re.fullmatch(r'\d{4}-\d{2}-\d{2}T[0-9:.]+Z', state['StartedAt']),
+ 'COLLECTOR_EXIT_UNCONFIRMED')
+ self.checkpoint('collector', 'exit-verified', cid)
+ self.verified_exits['collector'] = state['StartedAt']
+ require(status == 0, 'COLLECTOR_RUN_REFUSED')
+
+ def stop_anchor(self, assert_restored):
+ cid, image_id, network = self.ids['postgres']
+ require('postgres-stop' not in self.attempted, 'CONTAINER_REPLAY_REFUSED')
+ require('collector' not in self.ids or 'collector' in self.verified_exits, 'COLLECTOR_EXIT_UNCONFIRMED')
+ self.attempted.add('postgres-stop')
+ assert_restored()
+ self.checkpoint('postgres', 'stop-intent', cid)
+ current = self.inspect(cid, 'postgres', image_id, network)
+ require(current['Running'] is True and self.anchor_start == (current['Pid'], current['StartedAt']), 'ANCHOR_START_DRIFT')
+ require(self.docker('stop', '--time', '15', cid) == cid, 'STOP_ACK_UNCONFIRMED')
+ state = self.inspect(cid, 'postgres', image_id, network)
+ require(state['Running'] is False and state['Status'] == 'exited' and state['Pid'] == 0 and
+ state['StartedAt'] == self.anchor_start[1] and state['ExitCode'] == 0, 'ANCHOR_EXIT_UNCONFIRMED')
+ self.checkpoint('postgres', 'exit-verified', cid)
+ self.verified_exits['postgres'] = state['StartedAt']
+
+ def retire_exited(self, role):
+ cid, image_id, network = self.ids[role]
+ operation = role + '-retire'
+ require(operation not in self.attempted, 'CONTAINER_REPLAY_REFUSED')
+ require(role != 'postgres' or self.adopted is None or self.topology_retired, 'C_RETIREMENT_UNCONFIRMED')
+ self.attempted.add(operation)
+ state = self.inspect(cid, role, image_id, network)
+ require(role in self.verified_exits and state['Running'] is False and state['Status'] == 'exited' and
+ state['Pid'] == 0 and state['StartedAt'] == self.verified_exits[role], 'EXIT_NOT_CONFIRMED')
+ self.checkpoint(role, 'retire-intent', cid)
+ require(self.docker('rm', cid) == cid, 'RETIRE_ACK_UNCONFIRMED')
+ self.checkpoint(role, 'retire-acknowledged', cid)
+
+
+if __name__ == '__main__':
+ cli = argparse.ArgumentParser()
+ cli.add_argument('--check-only', required=True, metavar='RUN_ID')
+ args = cli.parse_args()
+ print(json.dumps({'fixtureRoot': root(args.check_only), 'postgresImage': PG_IMAGE, 'nodeImage': NODE_IMAGE,
+ 'requiresOwnedCollectorNamespace': True, 'dockerUsed': False, 'networkUsed': False}))
diff --git a/backend/scripts/acceptance/chr-netflow-collector-container.test.py b/backend/scripts/acceptance/chr-netflow-collector-container.test.py
new file mode 100644
index 00000000..7dea37fe
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-collector-container.test.py
@@ -0,0 +1,143 @@
+import json
+import runpy
+import unittest
+from pathlib import Path
+
+owner = runpy.run_path(str(Path(__file__).with_name('chr-netflow-collector-container.py')))
+RUN = 'a012bcde'
+PG_ID = 'a' * 64
+NODE_ID = 'b' * 64
+PACKET = 'd' * 64
+IMAGE_ID = 'sha256:' + 'c' * 64
+STARTED = '2026-11-04T12:00:00.000Z'
+
+
+class DockerFixture:
+ def __init__(self):
+ self.calls = []
+ self.records = {}
+ self.lose_create = False
+
+ def __call__(self, *args):
+ self.calls.append(args)
+ if args[:2] == ('image', 'inspect'):
+ return json.dumps([{'Id': IMAGE_ID, 'Os': 'linux', 'RepoDigests': [args[2]]}])
+ if args[0] == 'create':
+ if self.lose_create:
+ raise RuntimeError('lost ACK')
+ pg = '--network=none' in args
+ role, cid = ('postgres', PG_ID) if pg else ('collector', NODE_ID)
+ self.records[cid] = {'Id': cid, 'Image': IMAGE_ID, 'Config': {'Labels': {
+ owner['LABEL']: RUN, 'io.mmapp.netflow.role': role}},
+ 'HostConfig': {'NetworkMode': 'none' if pg else 'container:' + PG_ID, 'Privileged': False,
+ 'PortBindings': None, 'ReadonlyRootfs': True, 'CapDrop': ['ALL'], 'CapAdd': None,
+ 'Memory': (192 if pg else 320) * 1024 * 1024,
+ 'MemorySwap': (192 if pg else 320) * 1024 * 1024},
+ 'State': {'Running': False, 'Status': 'created', 'Pid': 0}}
+ return cid
+ cid = args[-1]
+ if args[:2] == ('container', 'inspect'):
+ return json.dumps([self.records[cid]])
+ if args[0] == 'start':
+ self.records[cid]['State'] = {'Running': True, 'Status': 'running', 'Pid': 42, 'StartedAt': STARTED}
+ elif args[0] == 'stop':
+ self.records[cid]['State'] = {'Running': False, 'Status': 'exited', 'Pid': 0, 'StartedAt': STARTED, 'ExitCode': 0}
+ elif args[0] == 'rm':
+ del self.records[cid]
+ else:
+ raise AssertionError(args)
+ return cid
+
+
+class TestCollectorLauncher(unittest.TestCase):
+ def test_exact_images_no_pull_no_privilege_and_fixed_namespace(self):
+ pg = owner['build_pg'](RUN, 1000, 1000)
+ node = owner['build_node'](RUN, 1000, 1000, PG_ID, 50100, (4, 5), (4, 6), PACKET)
+ self.assertIn('--network=none', pg)
+ self.assertIn('--network=container:' + PG_ID, node)
+ self.assertIn('listen_addresses=', pg)
+ for argv in (pg, node):
+ self.assertIn('--pull=never', argv)
+ self.assertIn('--cap-drop=ALL', argv)
+ self.assertNotIn('--privileged', argv)
+ self.assertNotIn('/var/run/docker.sock', ' '.join(argv))
+ self.assertNotIn('POSTGRES_PASSWORD=', ' '.join(pg))
+ with self.assertRaisesRegex(ValueError, 'NAMESPACE_PINS'):
+ owner['build_node'](RUN, 1000, 1000, PG_ID, 50100, (4, 5), (4, 5), PACKET)
+ self.assertIn('EN10MB', owner['capture_args'](RUN, '198.18.241.2', '198.18.241.9', 50100))
+
+ def test_one_shot_ack_exact_ids_and_verified_cleanup(self):
+ docker, journal = DockerFixture(), []
+ launcher = owner['CollectorContainerOwner'](RUN, docker, lambda *entry: journal.append(entry))
+ self.assertEqual(launcher.create_anchor(1000, 1000), PG_ID)
+ self.assertEqual(launcher.start_anchor(), 42)
+ with self.assertRaisesRegex(ValueError, 'ADOPTION_UNCONFIRMED'):
+ launcher.create_collector(1000, 1000, 50100, (4, 5), (4, 6), PACKET, lambda: None)
+ anchor = {'containerId': PG_ID, 'pid': 42, 'startedAt': STARTED, 'namespace': [4, 5], 'hostNamespace': [4, 6]}
+ launcher.anchor_namespace = lambda: anchor
+ name = 'nf' + RUN + 'nc'
+
+ class Topology:
+ def namespace(self, target):
+ return [4, 5] if target == name else None
+
+ def root_baseline(self):
+ return 'root-baseline'
+
+ class Journal:
+ value = {}
+
+ def provision(backend, journal, planned, pins, read_collector_anchor):
+ journal.value.update(collectorAnchor=read_collector_anchor(), rootBaseline='root-baseline', state='created')
+ return {'ns:' + name: backend.namespace(name)}
+
+ def cleanup(backend, journal, planned, assert_collector_anchor_exited):
+ assert_collector_anchor_exited(journal.value['collectorAnchor'])
+ journal.value['state'] = 'retired'
+
+ topology, topology_journal, planned = Topology(), Journal(), {'names': {'C': name}}
+ launcher.create_linux_topology(provision, topology, topology_journal, planned, {'nonce': RUN + '0' * 24})
+ self.assertEqual(launcher.create_collector(1000, 1000, 50100, (4, 5), (4, 6), PACKET, lambda: None), NODE_ID)
+ with self.assertRaisesRegex(ValueError, 'EXIT_NOT_OWNED'):
+ launcher.cleanup_linux_topology(cleanup, topology, topology_journal, planned)
+
+ def attach(cid):
+ self.assertEqual(cid, NODE_ID)
+ docker.records[cid]['State'] = {'Running': False, 'Status': 'exited', 'Pid': 0, 'ExitCode': 0, 'StartedAt': STARTED}
+ return 0
+
+ launcher.start_collector(attach)
+ launcher.retire_exited('collector')
+ launcher.stop_anchor(lambda: None)
+ with self.assertRaisesRegex(ValueError, 'C_RETIREMENT_UNCONFIRMED'):
+ launcher.retire_exited('postgres')
+ launcher.cleanup_linux_topology(cleanup, topology, topology_journal, planned)
+ launcher.retire_exited('postgres')
+ self.assertEqual(docker.records, {})
+ self.assertIn(('collector', 'exit-verified', NODE_ID), journal)
+ self.assertEqual([call for call in docker.calls if call[0] == 'rm'], [('rm', NODE_ID), ('rm', PG_ID)])
+
+ def test_lost_create_ack_is_not_replayed_or_cleaned_by_name(self):
+ docker, journal = DockerFixture(), []
+ docker.lose_create = True
+ launcher = owner['CollectorContainerOwner'](RUN, docker, lambda *entry: journal.append(entry))
+ with self.assertRaisesRegex(RuntimeError, 'lost ACK'):
+ launcher.create_anchor(1000, 1000)
+ with self.assertRaisesRegex(ValueError, 'REPLAY'):
+ launcher.create_anchor(1000, 1000)
+ self.assertEqual(journal, [('postgres', 'create-intent', None)])
+ self.assertEqual([call[0] for call in docker.calls], ['image', 'create'])
+
+ def test_anchor_process_replaced_under_same_container_id_is_never_stopped(self):
+ docker = DockerFixture()
+ launcher = owner['CollectorContainerOwner'](RUN, docker, lambda *_: None)
+ launcher.create_anchor(1000, 1000)
+ launcher.start_anchor()
+ docker.records[PG_ID]['State']['StartedAt'] = '2026-11-04T13:00:00.000Z'
+ with self.assertRaisesRegex(ValueError, 'ANCHOR_START_DRIFT'):
+ launcher.stop_anchor(lambda: None)
+ self.assertFalse(any(call[0] == 'stop' for call in docker.calls))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/backend/scripts/acceptance/chr-netflow-collector-smoke.py b/backend/scripts/acceptance/chr-netflow-collector-smoke.py
new file mode 100644
index 00000000..124ea606
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-collector-smoke.py
@@ -0,0 +1,242 @@
+"""Disposable collector-only cycle. No RouterOS clients or capture are opened."""
+import argparse
+import gzip
+import hashlib
+import io
+import json
+import os
+import re
+import runpy
+import stat
+import subprocess
+import sys
+import tarfile
+import time
+from pathlib import Path
+
+owner = runpy.run_path(str(Path(__file__).with_name('chr-netflow-collector-container.py')))
+require = owner['require']
+MAX_PACKET = 128 * 1024 * 1024
+PACKET_PATH = re.compile(r'(?:dist|drizzle|contracts-dist)/(?:[A-Za-z0-9_.-]+/)*[A-Za-z0-9_.-]+\Z')
+
+
+def verify_packet(directory, digest, require_root=False):
+ require(re.fullmatch(r'[a-f0-9]{64}', digest), 'PACKET_DIGEST_REFUSED')
+ require(directory.resolve(strict=True) == directory and directory.is_dir(), 'PACKET_DIRECTORY_REFUSED')
+ manifest = directory / 'manifest.json'
+ info = manifest.lstat()
+ require(stat.S_ISREG(info.st_mode) and 0 < info.st_size <= 1048576, 'PACKET_MANIFEST_REFUSED')
+ raw = manifest.read_bytes()
+ require(hashlib.sha256(raw).hexdigest() == digest, 'PACKET_MANIFEST_DRIFT')
+ value = json.loads(raw)
+ require(value.get('format') == 'mmapp-netflow-collector-smoke-v1' and
+ value.get('cachedSourceRevision') == 'bf3d50e1ff2ee3b5c9268991a255c3b49ce6378e' and
+ type(value.get('files')) is list and 1 <= len(value['files']) <= 4096, 'PACKET_MANIFEST_REFUSED')
+ total, listed = 0, {'manifest.json'}
+ for row in value['files']:
+ relative = row.get('path', '')
+ require(PACKET_PATH.fullmatch(relative) and
+ not any(part in ('.', '..') for part in relative.split('/')) and relative not in listed and
+ type(row.get('size')) is int and 0 < row['size'] <= 2 * 1024 * 1024 and
+ re.fullmatch(r'[a-f0-9]{64}', row.get('sha256', '')), 'PACKET_FILE_REFUSED')
+ item = directory / relative
+ info = item.lstat()
+ total += row['size']
+ require(total <= MAX_PACKET and stat.S_ISREG(info.st_mode) and item.resolve(strict=True) == item and
+ info.st_size == row['size'] and hashlib.sha256(item.read_bytes()).hexdigest() == row['sha256'], 'PACKET_FILE_DRIFT')
+ listed.add(relative)
+ observed = set()
+ for folder, directories, filenames in os.walk(directory, followlinks=False):
+ parent = Path(folder)
+ for entry in [parent, *(parent / name for name in directories + filenames)]:
+ info = entry.lstat()
+ require(not stat.S_ISLNK(info.st_mode) and
+ (not require_root or info.st_uid == 0 and not info.st_mode & 0o022), 'PACKET_OWNERSHIP_REFUSED')
+ observed.update((parent / filename).relative_to(directory).as_posix() for filename in filenames)
+ require(observed == listed and 'dist/test/traffic-flow-chr-collector-bootstrap.js' in listed, 'PACKET_FILE_SET_DRIFT')
+ return {'files': len(listed) - 1, 'bytes': total, 'manifestSha256': digest}
+
+
+def pack(directory, digest):
+ match = re.fullmatch(r'mcp-netflow-smoke-packet-([a-f0-9]{8})', directory.name)
+ require(match is not None, 'PACKET_DIRECTORY_REFUSED')
+ verified = verify_packet(directory, digest)
+ archive = directory.parent / ('mcp-netflow-collector-smoke-' + match[1] + '.tar.gz')
+ manifest = json.loads((directory / 'manifest.json').read_bytes())
+ script_root = Path(__file__).resolve().parent
+ scripts = ('chr-netflow-collector-smoke.py', 'chr-netflow-collector-container.py')
+ with archive.open('xb') as destination, gzip.GzipFile(fileobj=destination, mode='wb', filename='', mtime=0) as compressed:
+ with tarfile.open(fileobj=compressed, mode='w|', format=tarfile.USTAR_FORMAT) as tar:
+ def add(name, body):
+ item = tarfile.TarInfo(name)
+ item.mode = 0o644
+ item.size = len(body)
+ tar.addfile(item, io.BytesIO(body))
+ for name in scripts:
+ add(name, (script_root / name).read_bytes())
+ add('packet/manifest.json', (directory / 'manifest.json').read_bytes())
+ for row in manifest['files']:
+ add('packet/' + row['path'], (directory / row['path']).read_bytes())
+ with archive.open('rb') as stream:
+ archive_sha = hashlib.file_digest(stream, 'sha256').hexdigest()
+ return {**verified, 'archive': str(archive), 'archiveSha256': archive_sha, 'dockerUsed': False, 'networkUsed': False}
+
+
+class SmokeNamespace:
+ """Only the C alias and one local dummy address, never the transit topology."""
+ def __init__(self, run, ip, namespace, checkpoint):
+ self.name, self.device = 'nf' + run + 'nc', 'nf' + run + 'cv'
+ self.ip, self.namespace, self.checkpoint = ip, namespace, checkpoint
+ self.anchor = None
+
+ def create(self, read_anchor):
+ require(self.anchor is None and self.namespace(self.name) is None, 'SMOKE_NAMESPACE_PRESENT')
+ anchor = read_anchor()
+ require(anchor['namespace'] != anchor['hostNamespace'] and read_anchor() == anchor, 'SMOKE_ANCHOR_DRIFT')
+ self.checkpoint('smoke', 'attach-intent', anchor)
+ self.ip('netns', 'attach', self.name, str(anchor['pid']))
+ require(self.namespace(self.name) == anchor['namespace'] and read_anchor() == anchor, 'SMOKE_ATTACH_UNCONFIRMED')
+ self.checkpoint('smoke', 'attach-verified', anchor)
+ self.anchor = anchor
+ def current():
+ require(self.namespace(self.name) == anchor['namespace'] and read_anchor() == anchor, 'SMOKE_ANCHOR_DRIFT')
+ links = json.loads(self.ip('-n', self.name, '-j', 'link', 'show'))
+ require([item['ifname'] for item in links] == ['lo'], 'SMOKE_NAMESPACE_NOT_EMPTY')
+ self.checkpoint('smoke', 'dummy-intent', self.device)
+ current()
+ self.ip('-n', self.name, 'link', 'add', self.device, 'type', 'dummy')
+ current()
+ created = json.loads(self.ip('-n', self.name, '-j', '-d', 'link', 'show', 'dev', self.device))
+ require(len(created) == 1 and created[0]['ifname'] == self.device and
+ created[0]['linkinfo']['info_kind'] == 'dummy' and created[0]['ifindex'] > 0, 'SMOKE_DUMMY_UNCONFIRMED')
+ self.ip('-n', self.name, 'address', 'add', '198.18.242.3/32', 'dev', self.device)
+ current()
+ self.ip('-n', self.name, 'link', 'set', self.device, 'up')
+ rows = json.loads(self.ip('-n', self.name, '-j', '-d', 'address', 'show', 'dev', self.device))
+ routes = json.loads(self.ip('-n', self.name, '-j', '-4', 'route', 'show', 'table', 'all'))
+ require(len(rows) == 1 and rows[0]['ifname'] == self.device and rows[0]['linkinfo']['info_kind'] == 'dummy' and
+ rows[0]['ifindex'] == created[0]['ifindex'] and
+ 'UP' in rows[0]['flags'] and any(row.get('local') == '198.18.242.3' and row.get('prefixlen') == 32
+ for row in rows[0]['addr_info']) and all(row.get('dst') != 'default' for row in routes) and
+ self.namespace(self.name) == anchor['namespace'] and read_anchor() == anchor, 'SMOKE_DUMMY_UNCONFIRMED')
+ self.checkpoint('smoke', 'dummy-verified', rows[0]['ifindex'])
+ return anchor
+
+ def restore(self, assert_anchor_exited):
+ require(self.anchor is not None and self.namespace(self.name) == self.anchor['namespace'],
+ 'SMOKE_NAMESPACE_DRIFT')
+ assert_anchor_exited(self.anchor)
+ require(not self.ip('netns', 'pids', self.name).strip(), 'SMOKE_NAMESPACE_BUSY')
+ self.checkpoint('smoke', 'delete-intent', self.anchor)
+ self.ip('netns', 'delete', self.name)
+ require(self.namespace(self.name) is None, 'SMOKE_NAMESPACE_RETIREMENT_UNCONFIRMED')
+ self.checkpoint('smoke', 'delete-verified', self.anchor)
+
+
+def linux_ip():
+ binary = next((item.resolve(strict=True) for item in (Path('/usr/sbin/ip'), Path('/usr/bin/ip'), Path('/sbin/ip'))
+ if item.is_file()), None)
+ require(binary is not None and binary.stat().st_uid == 0 and not binary.stat().st_mode & 0o022, 'IP_BINARY_UNPINNED')
+
+ def call(*args):
+ result = subprocess.run([str(binary), *args], env=owner['ENV'], stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, timeout=8)
+ require(result.returncode == 0 and len(result.stdout) <= 128 * 1024, 'IP_OUTCOME_UNCONFIRMED')
+ return result.stdout.decode('utf-8', 'strict')
+ return call
+
+
+def ns_pin(name):
+ try:
+ row = Path('/run/netns', name).lstat()
+ except FileNotFoundError:
+ return None
+ require(stat.S_ISREG(row.st_mode) and row.st_uid == 0, 'SMOKE_NAMESPACE_HANDLE_UNSAFE')
+ return [row.st_dev, row.st_ino]
+
+
+def run_smoke(run, uid, gid, port, digest):
+ docker, attach = owner['local_docker']()
+ base = Path(owner['root'](run))
+ packet = base / 'packet'
+ verify_packet(packet, digest, require_root=True)
+ ip = linux_ip()
+ require(ns_pin('nf' + run + 'nc') is None, 'SMOKE_NAMESPACE_PRESENT')
+ journal = os.open(base / 'collector-smoke.jsonl', os.O_CREAT | os.O_EXCL | os.O_WRONLY | os.O_NOFOLLOW, 0o600)
+ with os.fdopen(journal, 'w', encoding='utf-8') as report:
+ def checkpoint(role, phase, value):
+ report.write(json.dumps({'role': role, 'phase': phase, 'value': value}, separators=(',', ':')) + '\n')
+ report.flush()
+ os.fsync(report.fileno())
+
+ checkpoint('smoke', 'packet-verified', digest)
+ owner['prepare_private_storage'](run, uid, gid)
+ runner = owner['CollectorContainerOwner'](run, docker, checkpoint)
+ runner.create_anchor(uid, gid)
+ runner.start_anchor()
+ scope = SmokeNamespace(run, ip, ns_pin, checkpoint)
+ # Reuse the container owner's live-C admission and retirement checks.
+ class Journal:
+ value = {}
+ class Backend:
+ def namespace(self, name):
+ return ns_pin(name)
+ def root_baseline(self):
+ raw = [ip('-j', '-4', 'route', 'show', 'table', 'all'), ip('-j', '-d', 'link', 'show')]
+ # Link counters/traffic are outside root configuration; use exact names and ifindex.
+ links = sorted((row['ifname'], row['ifindex']) for row in json.loads(raw[1]))
+ return hashlib.sha256(json.dumps([json.loads(raw[0]), links], sort_keys=True).encode()).hexdigest()
+ def provision(backend, ledger, _plan, _pins, read_collector_anchor):
+ baseline = backend.root_baseline()
+ anchor = scope.create(read_collector_anchor)
+ require(backend.root_baseline() == baseline, 'ROOT_NETWORK_DRIFT')
+ ledger.value.update(collectorAnchor=anchor, rootBaseline=baseline, state='created')
+ return anchor
+ def cleanup(_backend, ledger, _plan, assert_collector_anchor_exited):
+ scope.restore(assert_collector_anchor_exited)
+ ledger.value['state'] = 'retired'
+ backend, ledger, plan = Backend(), Journal(), {'names': {'C': scope.name}}
+ pin = runner.create_linux_topology(provision, backend, ledger, plan, {'nonce': run + '0' * 24})
+ wait_until = time.monotonic() + 20
+ socket = base / 'pg-socket' / '.s.PGSQL.5432'
+ while not socket.exists() and time.monotonic() < wait_until:
+ time.sleep(.1)
+ require(stat.S_ISSOCK(socket.lstat().st_mode), 'PRIVATE_PG_NOT_READY')
+ runner.create_collector(uid, gid, port, pin['namespace'], pin['hostNamespace'], digest,
+ lambda: verify_packet(packet, digest, require_root=True))
+ runner.start_collector(attach)
+ runner.retire_exited('collector')
+ runner.stop_anchor(lambda: require(ledger.value['state'] == 'created', 'SMOKE_TOPOLOGY_DRIFT'))
+ runner.cleanup_linux_topology(cleanup, backend, ledger, plan)
+ runner.retire_exited('postgres')
+ checkpoint('smoke', 'complete', None)
+ return {'collectorSmokeCompleted': True, 'chrMutations': 0, 'capturePerformed': False, 'nativeAcceptance': False}
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ sub = parser.add_subparsers(dest='mode', required=True)
+ check = sub.add_parser('check')
+ check.add_argument('packet', type=Path)
+ check.add_argument('sha256')
+ package = sub.add_parser('pack')
+ package.add_argument('packet', type=Path)
+ package.add_argument('sha256')
+ run = sub.add_parser('run')
+ run.add_argument('run_id')
+ run.add_argument('uid', type=int)
+ run.add_argument('gid', type=int)
+ run.add_argument('port', type=int)
+ run.add_argument('sha256')
+ args = parser.parse_args()
+ try:
+ if args.mode == 'check':
+ result = {**verify_packet(args.packet.resolve(), args.sha256), 'dockerUsed': False, 'networkUsed': False}
+ elif args.mode == 'pack':
+ result = pack(args.packet.resolve(), args.sha256)
+ else:
+ result = run_smoke(args.run_id, args.uid, args.gid, args.port, args.sha256)
+ print(json.dumps(result))
+ except (OSError, ValueError, RuntimeError, subprocess.SubprocessError, KeyError) as error:
+ print(json.dumps({'completed': False, 'failureClass': type(error).__name__, 'automaticReplay': False}))
+ raise SystemExit(1) from None
diff --git a/backend/scripts/acceptance/chr-netflow-collector-smoke.test.py b/backend/scripts/acceptance/chr-netflow-collector-smoke.test.py
new file mode 100644
index 00000000..d7b8f6b9
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-collector-smoke.test.py
@@ -0,0 +1,69 @@
+import hashlib
+import json
+from pathlib import Path
+import runpy
+import tempfile
+import unittest
+
+smoke = runpy.run_path(str(Path(__file__).with_name('chr-netflow-collector-smoke.py')))
+
+
+class SmokeTests(unittest.TestCase):
+ def test_pin_and_file_set_drift_fail_closed(self):
+ with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parents[3] / 'tmp') as temp:
+ root = Path(temp).resolve()
+ entry = root / 'dist/test/traffic-flow-chr-collector-bootstrap.js'
+ entry.parent.mkdir(parents=True)
+ entry.write_bytes(b'owned fixture\n')
+ body = json.dumps({'format': 'mmapp-netflow-collector-smoke-v1',
+ 'cachedSourceRevision': 'bf3d50e1ff2ee3b5c9268991a255c3b49ce6378e',
+ 'files': [{'path': entry.relative_to(root).as_posix(), 'size': entry.stat().st_size,
+ 'sha256': hashlib.sha256(entry.read_bytes()).hexdigest()}]}).encode()
+ (root / 'manifest.json').write_bytes(body)
+ digest = hashlib.sha256(body).hexdigest()
+ self.assertEqual(smoke['verify_packet'](root, digest)['files'], 1)
+ entry.write_bytes(b'foreign data!\n')
+ with self.assertRaisesRegex(ValueError, 'FILE_DRIFT'):
+ smoke['verify_packet'](root, digest)
+ with self.assertRaisesRegex(ValueError, 'MANIFEST_DRIFT'):
+ smoke['verify_packet'](root, '0' * 64)
+
+ def test_exact_dummy_namespace_and_busy_cleanup(self):
+ anchor = {'containerId': 'a' * 64, 'pid': 42, 'namespace': [10, 20], 'hostNamespace': [10, 21]}
+ calls, journal = [], []
+ namespace = None
+ busy = True
+ name, device = 'nfa012bcdenc', 'nfa012bcdecv'
+ link = {'ifname': device, 'ifindex': 5, 'linkinfo': {'info_kind': 'dummy'}, 'flags': ['UP'],
+ 'addr_info': [{'local': '198.18.242.3', 'prefixlen': 32}]}
+ def ip(*args):
+ nonlocal namespace
+ calls.append(args)
+ if args[:2] == ('netns', 'attach'):
+ self.assertEqual(args, ('netns', 'attach', name, '42'))
+ namespace = anchor['namespace']
+ elif args[:2] == ('netns', 'pids'):
+ return '42' if busy else ''
+ elif args[:2] == ('netns', 'delete'):
+ self.assertEqual(args, ('netns', 'delete', name))
+ namespace = None
+ elif args == ('-n', name, '-j', 'link', 'show'):
+ return json.dumps([{'ifname': 'lo'}])
+ elif '-d' in args:
+ return json.dumps([link])
+ elif 'route' in args:
+ return '[]'
+ return ''
+ fixture = smoke['SmokeNamespace']('a012bcde', ip, lambda _name: namespace, lambda *row: journal.append(row))
+ self.assertEqual(fixture.create(lambda: anchor), anchor)
+ self.assertIn(('-n', name, 'address', 'add', '198.18.242.3/32', 'dev', device), calls)
+ with self.assertRaisesRegex(ValueError, 'NAMESPACE_BUSY'):
+ fixture.restore(lambda pin: self.assertEqual(pin, anchor))
+ self.assertNotIn(('netns', 'delete', name), calls)
+ busy = False
+ fixture.restore(lambda pin: self.assertEqual(pin, anchor))
+ self.assertEqual(journal[-1][1], 'delete-verified')
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/backend/scripts/acceptance/chr-netflow-drain-witness-pg.mjs b/backend/scripts/acceptance/chr-netflow-drain-witness-pg.mjs
new file mode 100644
index 00000000..54dbafc0
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-drain-witness-pg.mjs
@@ -0,0 +1,123 @@
+import assert from 'node:assert/strict'
+import { execFileSync } from 'node:child_process'
+import { randomBytes } from 'node:crypto'
+import { lstat, mkdtemp, rm } from 'node:fs/promises'
+import { createServer } from 'node:net'
+import { tmpdir } from 'node:os'
+import { isAbsolute, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import EmbeddedPostgres from 'embedded-postgres'
+import pg from 'pg'
+import { applySqlMigrations } from '../../src/db/migrate.ts'
+import { MIGRATION_MANIFEST } from '../../src/db/migration-manifest.ts'
+
+assert.deepEqual(process.argv.slice(2), ['--owned-embedded'])
+const bin = process.env.MMAPP_PG_CLIENT_BIN
+assert(bin && isAbsolute(bin) && resolve(bin) === bin, 'Set MMAPP_PG_CLIENT_BIN to the exact local PostgreSQL client directory')
+const psql = join(bin, process.platform === 'win32' ? 'psql.exe' : 'psql')
+const executable = await lstat(psql)
+assert(executable.isFile() && !executable.isSymbolicLink(), 'PostgreSQL client must be a regular file')
+const clientEnv = Object.fromEntries(Object.entries(process.env).filter(([name]) => !/^PG/i.test(name)))
+const run = (command, args, options = {}) => execFileSync(command, args, {
+ timeout: 10000, maxBuffer: 16384, encoding: 'utf8', windowsHide: true, ...options,
+})
+assert.match(run(psql, ['--version'], { env: clientEnv }), /^psql \(PostgreSQL\) (?:1[6-9]|[2-9][0-9])\./)
+const witness = fileURLToPath(new URL('../../../tmp/mcp-netflow-linux-topology-20261104/collector-drain-witness.py', import.meta.url))
+const { IDENTITY_SQL, SQL } = JSON.parse(run('python', ['-I', '-B', '-c',
+ 'import json,runpy,sys; m=runpy.run_path(sys.argv[1]); print(json.dumps({k:m[k] for k in ("IDENTITY_SQL","SQL")}))', witness]))
+assert(typeof SQL === 'string' && typeof IDENTITY_SQL === 'string')
+
+const directory = await mkdtemp(join(tmpdir(), 'mm-netflow-drain-pg-'))
+const password = randomBytes(24).toString('hex')
+const host = '127.0.0.1', database = 'postgres', user = 'mcp_test'
+const listener = createServer()
+let embedded, pool, started = false
+try {
+ await new Promise((done, reject) => { listener.once('error', reject); listener.listen(0, host, done) })
+ const { port } = listener.address()
+ await new Promise((done, reject) => listener.close(error => error ? reject(error) : done()))
+ embedded = new EmbeddedPostgres({
+ databaseDir: join(directory, 'pg'), port, user, password, persistent: true, createPostgresUser: false,
+ initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', host, '-c', 'unix_socket_directories='],
+ onLog: () => {}, onError: () => {},
+ })
+ await embedded.initialise()
+ await embedded.start()
+ started = true
+ pool = new pg.Pool({ host, port, database, user, password, max: 1, connectionTimeoutMillis: 5000 })
+ await applySqlMigrations(pool)
+ const { rows: [version] } = await pool.query("SELECT current_setting('server_version_num')::int AS number, (SELECT count(*)::int FROM schema_migrations) AS migrations")
+ assert(version.number >= 180000 && version.number <= 189999)
+ assert.equal(version.migrations, MIGRATION_MANIFEST.length)
+
+ const runId = 'a012bcde', owner = 'netflow-operator-' + runId, collectorPort = 51000
+ const read = (sql, probePort = collectorPort) => JSON.parse(run(psql, ['-X', '-w', '-qAt',
+ '-h', host, '-p', String(port), '-U', user, '-d', database, '-v', 'ON_ERROR_STOP=1',
+ '-v', 'database=' + database, '-v', 'socket_dir=/tmp/mcp-netflow-' + runId + '/pg-socket',
+ '-v', 'run_id=' + runId, '-v', 'port=' + probePort],
+ { env: { ...clientEnv, PGCONNECT_TIMEOUT: '2', PGPASSWORD: password }, input: sql }).trim())
+ const identity = read(IDENTITY_SQL)
+ assert.deepEqual(Object.keys(identity).sort(), ['oid', 'source'])
+ assert.match(identity.oid, /^[1-9][0-9]{0,9}$/)
+ // The production source predicate deliberately rejects this TCP fixture.
+ assert.equal(identity.source, false)
+ const expect = (planCount, enabled, verified, ordered = true, sqlPort = collectorPort) =>
+ assert.deepEqual(read(SQL, sqlPort), { ...identity, connectionCount: 1, planCount, enabled, verified, ordered })
+
+ const uuid = index => 'a012bcde-0000-4000-8000-' + String(index).padStart(12, '0')
+ const connection = uuid(1)
+ await pool.query(`INSERT INTO mcp_connections(id,name,owner_id,owner_permissions,policy,generation)
+ VALUES($1,$2,$3,'[]','{}','inert-witness')`, [connection, 'Owned NetFlow ' + runId, owner])
+ await pool.query("UPDATE traffic_flow_settings SET collector_ip='198.18.242.3', flow_listen_port=$1, enabled=false WHERE id=1", [collectorPort])
+ expect(0, false, [])
+
+ async function seed(index, enabled) {
+ const plan = uuid(index), operation = uuid(index + 1), receipt = uuid(index + 2)
+ const base = Date.UTC(2026, 0, 1) + index * 1000
+ const at = offset => new Date(base + offset)
+ const result = { receiptId: receipt, configurationConfirmed: true, receiptConfirmed: true,
+ listener: 'request-acknowledged', automaticReplay: false }
+ await pool.query(`INSERT INTO mcp_plans(id,connection_id,operation_id,operation_version,policy_version,generation,payload,evidence,state,expires_at,approved_by,approved_at,created_at)
+ VALUES($1,$2,'netflow.settings.update',3,1,'inert-witness','{}','{}','completed',$3,$4,$5,$6)`,
+ [plan, connection, at(9000), owner, at(100), at(0)])
+ await pool.query(`INSERT INTO mcp_operations(id,plan_id,connection_id,idempotency_key,state,verification,created_at,finished_at)
+ VALUES($1,$2,$3,$4,'applied','passed',$5,$6)`, [operation, plan, connection, 'inert-' + index, at(200), at(400)])
+ await pool.query(`INSERT INTO mcp_operation_steps(operation_id,step_index,state,intended_state,result,created_at,finished_at)
+ VALUES($1,0,'verified',$2,$3,$4,$5)`,
+ [operation, { service: 'netflow.settings.update', input: { receiptId: receipt, enabled } }, result, at(300), at(400)])
+ await pool.query(`INSERT INTO mcp_audit(actor_id,action,connection_id,payload,created_at)
+ VALUES($1,'plan.approve',$2,$3,$4)`, [owner, connection, { planId: plan }, at(100)])
+ await pool.query(`INSERT INTO flow_settings_intents(receipt_id,phase,request_proof,state,result,created_at)
+ VALUES($1,'configuration','inert-proof','completed',$2,$3),($1,'listener','inert-proof','completed',$2,$3)`, [receipt, result, at(300)])
+ await pool.query('UPDATE traffic_flow_settings SET enabled=$1 WHERE id=1', [enabled])
+ return [plan, operation, receipt]
+ }
+ const enabled = await seed(10, true)
+ expect(1, true, [enabled])
+ const disabled = await seed(20, false)
+ expect(2, false, [enabled, disabled])
+ expect(2, null, [enabled, disabled], true, collectorPort + 1)
+
+ await pool.query("UPDATE flow_settings_intents SET request_proof='foreign' WHERE receipt_id=$1 AND phase='listener'", [disabled[2]])
+ expect(2, false, [enabled])
+ await pool.query("UPDATE flow_settings_intents SET request_proof='inert-proof' WHERE receipt_id=$1 AND phase='listener'", [disabled[2]])
+ const { rows: [duplicate] } = await pool.query(`INSERT INTO mcp_audit(actor_id,action,connection_id,payload)
+ VALUES($1,'plan.approve',$2,$3) RETURNING id`, [owner, connection, { planId: disabled[0] }])
+ expect(2, false, [enabled])
+ await pool.query('DELETE FROM mcp_audit WHERE id=$1', [duplicate.id])
+ const { rows: [original] } = await pool.query(`UPDATE mcp_operations SET finished_at=(SELECT created_at + interval '1 second' FROM mcp_plans WHERE id=$2)
+ WHERE id=$1 RETURNING created_at`, [enabled[1], disabled[0]])
+ expect(2, false, [enabled, disabled], false)
+ await pool.query("UPDATE mcp_operations SET finished_at=$2::timestamptz + interval '200 milliseconds' WHERE id=$1", [enabled[1], original.created_at])
+ expect(2, false, [enabled, disabled])
+ console.log(JSON.stringify({ migrations: version.migrations, exactPsqlQueries: true, inertEnableDisableAndRejections: true,
+ linuxSocketSourceAccepted: false, realMcpExecutionClaimed: false }))
+} finally {
+ try {
+ await pool?.end()
+ } finally {
+ if (started) await embedded.stop()
+ if (listener.listening) await new Promise(done => listener.close(done))
+ await rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
+ }
+}
diff --git a/backend/scripts/acceptance/chr-netflow-endpoint-discovery.mjs b/backend/scripts/acceptance/chr-netflow-endpoint-discovery.mjs
new file mode 100644
index 00000000..348049ed
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-endpoint-discovery.mjs
@@ -0,0 +1,221 @@
+import { createHash } from 'node:crypto';
+import { readFile } from 'node:fs/promises';
+import { isIPv4 } from 'node:net';
+import { pathToFileURL } from 'node:url';
+
+const routes = Object.freeze(['/system/resource', '/ip/traffic-flow', '/ip/traffic-flow/target']);
+const policyRoutes = Object.freeze(['/system/resource', '/ip/settings', '/ip/firewall/connection/tracking',
+ '/ip/firewall/filter', '/ip/firewall/raw', '/ip/firewall/mangle', '/ip/firewall/nat', '/routing/rule', '/ip/vrf']);
+const counterFields = ['ifindex', 'rx-packet', 'tx-packet', 'fp-rx-byte', 'fp-tx-byte', 'fp-rx-packet', 'fp-tx-packet'];
+const nativeId = value => typeof value === 'string' && /^\*[a-f0-9]{1,16}$/i.test(value);
+const ports = Object.freeze({ '194.226.121.150': 19081, '104.165.244.7': 19082 });
+const attestation = 'verified-known-host-161.104.46.222-owned-forward';
+const reviewedTransportHash = '67d86dbae2710a25145df8ab9469029182f21a31972c49f063cdb6bc3daa8ea6';
+const sha = bytes => createHash('sha256').update(bytes).digest('hex');
+const deny = () => { throw new Error('NetFlow discovery refused'); };
+
+export async function loadPinnedNetFlowTransport(policy = false) {
+ const allowedPaths = policy ? policyRoutes : routes;
+ return loadTransport(allowedPaths, allowedPaths.length * 2, policy ? 131072 : 65536);
+}
+
+async function loadTransport(allowedPaths, requests, responseLimit, totalLimit = responseLimit * requests) {
+ const bytes = await readFile(new URL('./chr-recursive-observation.mjs', import.meta.url));
+ if (sha(bytes) !== reviewedTransportHash) deny();
+ const reviewed = bytes.toString('utf8');
+ const source = reviewed.slice(0, reviewed.indexOf('async function privateStdin()'))
+ .replace(/const ROOT = .*?;/, 'const ROOT = null;')
+ .replace(/export const PATHS = Object.freeze\(\[[\s\S]*?\]\);/, `export const PATHS = Object.freeze(${JSON.stringify(allowedPaths)});`)
+ .replace('response: 1048576, bytes: 8388608, requests: 256',
+ `response: ${responseLimit}, bytes: ${totalLimit}, requests: ${requests}`);
+ const transport = await import('data:text/javascript;base64,' + Buffer.from(source).toString('base64'));
+ if (JSON.stringify(transport.PATHS) !== JSON.stringify(allowedPaths)) deny();
+ for (const [host, port] of Object.entries(ports)) {
+ if (endpoint(transport, host) !== `http://127.0.0.1:${port}`) deny();
+ }
+ return transport;
+}
+
+export async function discoverPinnedInterfaceCounterShape(read) {
+ const devices = [];
+ for (const host of Object.keys(ports)) {
+ const inventory = await read(host, '/interface');
+ if (!Array.isArray(inventory) || inventory.length > 256 ||
+ inventory.some(row => !nativeId(row?.['.id'])) ||
+ new Set(inventory.map(row => row['.id'])).size !== inventory.length) deny();
+ const preferred = type => inventory.find(row => row.type === type &&
+ observedFlag(row.running) === true && observedFlag(row.disabled) === false);
+ const chosen = preferred('wg') ?? preferred('ether');
+ if (!chosen) {
+ devices.push({ status: 'no-eligible-interface' });
+ continue;
+ }
+ const exact = single(await read(host, '/interface/' + encodeURIComponent(chosen['.id'])));
+ if (exact['.id'] !== chosen['.id'] || exact.type !== chosen.type ||
+ observedFlag(exact.running) !== true || observedFlag(exact.disabled) !== false) deny();
+ const fields = Object.fromEntries(counterFields.map(key => {
+ const value = exact[key];
+ return [key, { present: Object.hasOwn(exact, key),
+ type: value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value }];
+ }));
+ devices.push({ status: 'shape-observed', fields });
+ }
+ return { devices, ingressVerified: false, capturePerformed: false, mutationsPerformed: false };
+}
+
+function endpoint(transport, host) {
+ return transport.configuration(['--source', host, '--transport', 'ssh-loopback', '--output',
+ 'tmp/netflow-endpoint-discovery', '--owned-tunnel-attestation', attestation]).endpoint;
+}
+
+function bool(value) {
+ if (value === true || value === 'true') return true;
+ if (value === false || value === 'false') return false;
+ return deny();
+}
+
+function single(rows) {
+ if (rows.length !== 1) deny();
+ return rows[0];
+}
+
+function observedFlag(value) {
+ if ([true, 'true', 'yes'].includes(value)) return true;
+ if ([false, 'false', 'no'].includes(value)) return false;
+ return null;
+}
+
+export async function discoverPinnedNetFlowPolicy(read) {
+ const exporters = [];
+ for (const host of Object.keys(ports)) {
+ const resource = single(await read(host, policyRoutes[0]));
+ if (typeof resource.version !== 'string' || !/^\d+\.\d+(?:\.\d+)?(?: \([a-z-]+\))?$/.test(resource.version)) deny();
+ const ip = single(await read(host, policyRoutes[1]));
+ const tracking = single(await read(host, policyRoutes[2]));
+ const firewall = {};
+ const vetoes = [];
+ const ipForward = observedFlag(ip['ip-forward']);
+ const allowFastPath = observedFlag(ip['allow-fast-path']);
+ const conntrack = tracking.enabled === 'auto' ? 'auto' : observedFlag(tracking.enabled);
+ if (ipForward !== true) vetoes.push('ip-forward-not-confirmed');
+ if (allowFastPath !== false) vetoes.push('fast-path-not-confirmed-disabled');
+ if (conntrack !== true) vetoes.push('conntrack-not-explicitly-enabled');
+ for (const path of policyRoutes.slice(3, 7)) {
+ const rows = await read(host, path);
+ const enabled = rows.filter(row => observedFlag(row.disabled) !== true);
+ firewall[path.split('/').at(-1)] = {
+ total: rows.length,
+ notExplicitlyDisabled: enabled.length,
+ fastTrack: enabled.filter(row => row.action === 'fasttrack-connection').length,
+ };
+ }
+ const routingRules = await read(host, policyRoutes[7]);
+ const activeRoutingRules = routingRules.filter(row => observedFlag(row.disabled) !== true).length;
+ if (activeRoutingRules) vetoes.push('routing-policy-present');
+ const vrfs = await read(host, policyRoutes[8]);
+ const mainVrfOnly = vrfs.length === 1 && vrfs[0].name === 'main' && vrfs[0].interfaces === 'all' &&
+ observedFlag(vrfs[0].disabled) !== true;
+ if (!mainVrfOnly) vetoes.push('main-vrf-only-not-confirmed');
+ exporters.push({ host, version: resource.version, ipForward, allowFastPath, conntrack, firewall,
+ activeRoutingRules, vrfCount: vrfs.length, mainVrfOnly, vetoes });
+ }
+ return {
+ status: exporters.some(item => item.vetoes.length) ? 'pre-topology-veto' : 'no-global-veto-observed',
+ exporters, routeSelectionVerified: false, tuplePolicyVerified: false,
+ ingressVerified: false, capturePerformed: false, mutationsPerformed: false,
+ };
+}
+
+function target(row) {
+ if (bool(row.disabled) || row.version !== 'ipfix') return null;
+ const destination = row['dst-address'];
+ const portText = String(row.port);
+ if (!isIPv4(destination) || !/^[1-9][0-9]{0,4}$/.test(portText) || Number(portText) > 65535) deny();
+ const source = row['src-address'];
+ if (source !== undefined && source !== '' && !isIPv4(source)) deny();
+ return { destination, port: Number(portText), configuredSource: source && source !== '0.0.0.0' ? source : null };
+}
+
+export async function discoverPinnedNetFlowEndpoints(read) {
+ const exporters = [];
+ for (const host of Object.keys(ports)) {
+ const resource = single(await read(host, routes[0]));
+ if (typeof resource.version !== 'string' || !/^\d+\.\d+(?:\.\d+)?(?: \([a-z-]+\))?$/.test(resource.version)) deny();
+ const enabled = bool(single(await read(host, routes[1])).enabled);
+ const rows = await read(host, routes[2]);
+ if (rows.length > 64) deny();
+ const configuredTargets = rows.map(target).filter(Boolean);
+ exporters.push({ host, version: resource.version, enabled, configuredTargets });
+ }
+ const [first, second] = exporters;
+ const sameEndpoint = (a, b) => a.destination === b.destination && a.port === b.port;
+ const common = first.enabled && second.enabled
+ ? first.configuredTargets.filter(a => second.configuredTargets.some(b => sameEndpoint(a, b)))
+ : [];
+ const unique = common.length === 1 && second.configuredTargets.filter(b => sameEndpoint(common[0], b)).length === 1;
+ return {
+ status: common.length === 0 ? 'no-common-active-ipfix-target' : unique ? 'configured-endpoint' : 'ambiguous-endpoint',
+ configuredEndpoint: unique ? { destination: common[0].destination, port: common[0].port } : null,
+ exporters,
+ ingressVerified: false,
+ capturePerformed: false,
+ mutationsPerformed: false,
+ };
+}
+
+async function main() {
+ const mode = process.argv.slice(2);
+ if (mode.length !== 1) deny();
+ const policy = mode[0] === '--check-policy' || mode[0] === '--read-pinned-policy';
+ const counters = mode[0] === '--check-counters' || mode[0] === '--read-pinned-counters';
+ const transport = counters ? await loadTransport(['/interface'], 4, 131072) : await loadPinnedNetFlowTransport(policy);
+ if (mode[0] === '--check-only' || mode[0] === '--check-policy') {
+ console.log(JSON.stringify({ transportSha256: reviewedTransportHash, loopbackPorts: ports, readPaths: transport.PATHS, networkUsed: false }));
+ return;
+ }
+ if (mode[0] === '--check-counters') {
+ const detail = await loadTransport(['/interface/*A'], 4, 16384);
+ if (detail.PATHS[0] !== '/interface/*A') deny();
+ console.log(JSON.stringify({ transportSha256: reviewedTransportHash, loopbackPorts: ports,
+ readPaths: ['/interface', '/interface/'], networkUsed: false }));
+ return;
+ }
+ if (!['--read-pinned', '--read-pinned-policy', '--read-pinned-counters'].includes(mode[0]) || process.stdin.isTTY) deny();
+ const chunks = [];
+ let length = 0;
+ for await (const chunk of process.stdin) {
+ length += chunk.length;
+ if (length > 4096) deny();
+ chunks.push(chunk);
+ }
+ const input = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
+ if (!input || input.attestation !== attestation ||
+ Object.keys(input).length !== 2 || !input.passwords || Object.keys(input.passwords).length !== 2) deny();
+ const passwords = Object.keys(ports).map(host => input.passwords[host]);
+ if (passwords.some(password => typeof password !== 'string' || !/^[^\u0000-\u001f\u007f]{1,512}$/u.test(password))) deny();
+ const authorizations = passwords.map(password => 'Basic ' + Buffer.from('admin:' + password).toString('base64'));
+ const secrets = [...passwords, ...authorizations, ...authorizations.map(value => value.slice(6))].map(value => Buffer.from(value));
+ const budget = { requests: 0, bytes: 0, rows: 0, deadline: Date.now() + 30000 };
+ const discovery = counters ? discoverPinnedInterfaceCounterShape : policy ? discoverPinnedNetFlowPolicy : discoverPinnedNetFlowEndpoints;
+ const report = await discovery(async (host, route) => {
+ const authorization = authorizations[Object.keys(ports).indexOf(host)];
+ let selected = transport;
+ if (counters && route !== '/interface') {
+ if (!route.startsWith('/interface/') || !nativeId(route.slice('/interface/'.length))) deny();
+ selected = await loadTransport([route], 4, 16384, 524288);
+ }
+ const response = await selected.readResponse(endpoint(selected, host), route, authorization, budget);
+ if (secrets.some(secret => response.body.includes(secret))) deny();
+ return response.rows;
+ });
+ const output = JSON.stringify(report);
+ if (secrets.some(secret => Buffer.from(output).includes(secret))) deny();
+ console.log(output);
+}
+
+if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
+ main().catch(() => {
+ console.error('NetFlow discovery refused');
+ process.exitCode = 1;
+ });
+}
diff --git a/backend/scripts/acceptance/chr-netflow-endpoint-discovery.test.mjs b/backend/scripts/acceptance/chr-netflow-endpoint-discovery.test.mjs
new file mode 100644
index 00000000..386cbcc2
--- /dev/null
+++ b/backend/scripts/acceptance/chr-netflow-endpoint-discovery.test.mjs
@@ -0,0 +1,102 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { discoverPinnedInterfaceCounterShape, discoverPinnedNetFlowEndpoints, discoverPinnedNetFlowPolicy, loadPinnedNetFlowTransport } from './chr-netflow-endpoint-discovery.mjs';
+
+const hosts = ['194.226.121.150', '104.165.244.7'];
+const routes = ['/system/resource', '/ip/traffic-flow', '/ip/traffic-flow/target'];
+const target = { disabled: 'false', version: 'ipfix', 'dst-address': '192.0.2.10', port: '2055', 'src-address': '0.0.0.0' };
+
+function fixture(targets, enabled = ['true', 'true']) {
+ const calls = [];
+ const read = async (host, path) => {
+ calls.push([host, path]);
+ if (path === routes[0]) return [{ version: '7.24.5 (stable)' }];
+ if (path === routes[1]) return [{ enabled: enabled[hosts.indexOf(host)] }];
+ assert.equal(path, routes[2]);
+ return targets[hosts.indexOf(host)];
+ };
+ return { read, calls };
+}
+
+test('loads the reviewed source with the exact read-only path and relay fence', async () => {
+ const transport = await loadPinnedNetFlowTransport();
+ assert.deepEqual(transport.PATHS, routes);
+ assert.throws(() => transport.readResponse('http://127.0.0.1:19082', '/ip/address', '', {}), /request-budget/);
+ assert.throws(() => transport.readResponse('http://127.0.0.1:19083', routes[0], '', {}), /non-whitelisted-endpoint/);
+});
+
+test('reports only a common configured endpoint, with no ingress or capture claim', async () => {
+ const { read, calls } = fixture([[target], [{ ...target, 'src-address': '192.0.2.20' }]]);
+ const report = await discoverPinnedNetFlowEndpoints(read);
+ assert.deepEqual(calls, hosts.flatMap(host => routes.map(path => [host, path])));
+ assert.equal(report.status, 'configured-endpoint');
+ assert.deepEqual(report.configuredEndpoint, { destination: '192.0.2.10', port: 2055 });
+ assert.deepEqual(report.exporters.map(item => item.configuredTargets[0].configuredSource), [null, '192.0.2.20']);
+ assert.equal(report.ingressVerified, false);
+ assert.equal(report.capturePerformed, false);
+ assert.equal(report.mutationsPerformed, false);
+});
+
+test('returns successful absence for missing or disabled baseline', async () => {
+ for (const input of [
+ fixture([[], [target]]),
+ fixture([[target], [target]], [true, false]),
+ fixture([[target], [{ ...target, disabled: true }]]),
+ fixture([[target], [{ ...target, version: '9' }]]),
+ ]) {
+ const result = await discoverPinnedNetFlowEndpoints(input.read);
+ assert.equal(result.status, 'no-common-active-ipfix-target');
+ assert.equal(result.configuredEndpoint, null);
+ }
+});
+
+test('refuses malformed relevant rows and withholds ambiguous common endpoints', async () => {
+ const result = await discoverPinnedNetFlowEndpoints(fixture([[target], [target, target]]).read);
+ assert.equal(result.status, 'ambiguous-endpoint');
+ assert.equal(result.configuredEndpoint, null);
+ await assert.rejects(discoverPinnedNetFlowEndpoints(fixture([[target], [{ ...target, port: '65536' }]]).read), /^Error: NetFlow discovery refused$/);
+});
+
+test('reports preliminary global vetoes and counts with no claim on tuple policy or routes', async () => {
+ const transport = await loadPinnedNetFlowTransport(true);
+ const calls = [];
+ const report = await discoverPinnedNetFlowPolicy(async (host, path) => {
+ calls.push([host, path]);
+ return ({
+ '/system/resource': [{ version: '7.24.5 (stable)' }],
+ '/ip/settings': [{ 'ip-forward': 'yes', 'allow-fast-path': host === hosts[0] ? 'yes' : 'no' }],
+ '/ip/firewall/connection/tracking': [{ enabled: host === hosts[0] ? 'auto' : 'yes' }],
+ '/ip/firewall/filter': [{ action: 'fasttrack-connection' }, { action: 'drop', disabled: 'true' }],
+ '/ip/firewall/raw': [], '/ip/firewall/mangle': [], '/ip/firewall/nat': [],
+ '/routing/rule': host === hosts[0] ? [{}] : [],
+ '/ip/vrf': [{ name: 'main', interfaces: 'all' }],
+ })[path];
+ });
+ assert.deepEqual(calls, hosts.flatMap(host => transport.PATHS.map(path => [host, path])));
+ assert.equal(report.status, 'pre-topology-veto');
+ assert.deepEqual(report.exporters[0].vetoes, ['fast-path-not-confirmed-disabled', 'conntrack-not-explicitly-enabled', 'routing-policy-present']);
+ assert.deepEqual(report.exporters[1].vetoes, []);
+ assert.deepEqual(report.exporters[0].firewall.filter, { total: 2, notExplicitlyDisabled: 1, fastTrack: 1 });
+ assert.equal(report.routeSelectionVerified, false);
+ assert.equal(report.tuplePolicyVerified, false);
+ assert.equal(report.ingressVerified, false);
+});
+
+test('counter shape reads exact selected native IDs and emits no identities or counter values', async () => {
+ const ether = { '.id': '*A', name: 'private-ether', type: 'ether', running: 'true', disabled: 'false' };
+ const wg = { ...ether, '.id': '*B', name: 'private-wg', type: 'wg' };
+ const calls = [];
+ const report = await discoverPinnedInterfaceCounterShape(async (host, route) => {
+ calls.push([host, route]);
+ if (route === '/interface') return host === hosts[0] ? [ether, wg] : [ether];
+ return [{ ...(host === hosts[0] ? wg : ether), ifindex: '61455', 'rx-packet': 71922, 'fp-rx-byte': null }];
+ });
+ assert.deepEqual(calls, [[hosts[0], '/interface'], [hosts[0], '/interface/*B'], [hosts[1], '/interface'], [hosts[1], '/interface/*A']]);
+ assert.deepEqual(report.devices[0].fields.ifindex, { present: true, type: 'string' });
+ assert.deepEqual(report.devices[0].fields['rx-packet'], { present: true, type: 'number' });
+ assert.deepEqual(report.devices[0].fields['fp-rx-byte'], { present: true, type: 'null' });
+ assert.deepEqual(report.devices[0].fields['tx-packet'], { present: false, type: 'undefined' });
+ assert.doesNotMatch(JSON.stringify(report), /private|61455|71922|104\.165|194\.226|\*[AB]/);
+ await assert.rejects(discoverPinnedInterfaceCounterShape(async (_host, route) =>
+ route === '/interface' ? [ether] : [{ ...ether, '.id': '*C' }]), /discovery refused/);
+});
diff --git a/backend/scripts/acceptance/chr-recursive-direct-links.mjs b/backend/scripts/acceptance/chr-recursive-direct-links.mjs
new file mode 100644
index 00000000..3fc9077a
--- /dev/null
+++ b/backend/scripts/acceptance/chr-recursive-direct-links.mjs
@@ -0,0 +1,86 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { lstat, readFile } from 'node:fs/promises';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { decodeBody, SOURCES } from './chr-recursive-observation.mjs';
+
+const reviewedReportSha256 = 'fccf5171c8e50730a3e7c1fcceeeb77f1e946589ac4a56c6e04668e0ff4663f9';
+const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
+const opaqueId = value => typeof value === 'string' && /^\*[a-f0-9]+$/i.test(value);
+const decimalIndex = value => typeof value === 'string' && /^[1-9][0-9]{0,15}$/.test(value);
+
+export function inspectDirectLinks(routes, nexthops, interfaces, tables) {
+ function keyed(rows, field, valid) {
+ const index = new Map();
+ for (const row of rows) {
+ const key = row[field];
+ assert(valid(key) && !index.has(key), 'Missing or ambiguous ' + field);
+ index.set(key, row);
+ }
+ return index;
+ }
+ const byNexthopId = keyed(nexthops, '.id', opaqueId);
+ const byInterfaceIndex = keyed(interfaces, 'ifindex', decimalIndex);
+ const byTableName = keyed(tables, 'name', value => typeof value === 'string' && value !== '' && !/^[0-9]+$/.test(value));
+ let opaqueReferences = 0, namedInterfaceCorroborations = 0, interfaceIdSubstitutionRefusals = 0;
+ for (const route of routes) {
+ assert(byTableName.has(route['routing-table']), 'Missing named routing table');
+ if (!Object.hasOwn(route, 'nexthop-id')) continue;
+ const nexthop = byNexthopId.get(route['nexthop-id']);
+ assert(nexthop, 'No exact opaque nexthop match');
+ opaqueReferences++;
+ const gateway = route['immediate-gw'];
+ const name = typeof gateway === 'string' ? /%([^%@]+)$/.exec(gateway)?.[1] : undefined;
+ if (!name) continue;
+ const index = nexthop['immediate-gw.interface-idx'];
+ const observed = byInterfaceIndex.get(index);
+ assert(observed?.name === name && interfaces.filter(row => row.name === name).length === 1,
+ 'No exact named interface corroboration for ifindex');
+ namedInterfaceCorroborations++;
+ if (!interfaces.some(row => row.id === index && row.name === name)) interfaceIdSubstitutionRefusals++;
+ }
+ assert(opaqueReferences && namedInterfaceCorroborations && interfaceIdSubstitutionRefusals, 'Capture lacks discriminating direct links');
+ return { opaqueReferences, namedInterfaceCorroborations, interfaceIdSubstitutionRefusals,
+ tableNames: byTableName.size, recursiveLinkRows: nexthops.filter(row => Object.keys(row).some(key => key === 'links' || key.startsWith('links.'))).length };
+}
+
+async function readPinned(directory, filename, digest) {
+ const file = path.join(directory, filename), stat = await lstat(file);
+ assert(stat.isFile() && !stat.isSymbolicLink() && stat.size <= 1048576, 'Unavailable bounded raw file');
+ const bytes = await readFile(file);
+ assert(bytes.length === stat.size && sha256(bytes) === digest, 'Raw capture hash changed');
+ return bytes;
+}
+
+export async function checkReviewedDirectLinks(directory) {
+ const report = JSON.parse(await readPinned(directory, 'report.json', reviewedReportSha256));
+ const sources = [];
+ for (const source of report.sources) {
+ assert(source.complete && source.versionBracketEqual && SOURCES[source.source]?.serverId === source.serverId);
+ const read = async (index, resource) => {
+ const record = source.records[index];
+ assert(record.resource === resource && record.status === 200 && record.version === '7.24.5 (stable)');
+ assert(record.file === `server${source.serverId}-${String(index + 1).padStart(2, '0')}-${resource.slice(1).replaceAll('/', '-')}.json`);
+ return decodeBody(await readPinned(directory, record.file, record.rawSha256)).rows;
+ };
+ const routes = await read(1, '/routing/route'), nexthops = await read(2, '/routing/nexthop');
+ assert.deepEqual(await read(7, '/routing/route'), routes);
+ assert.deepEqual(await read(6, '/routing/nexthop'), nexthops);
+ assert.equal(source.records[1].rawSha256, source.records[7].rawSha256);
+ assert.equal(source.records[2].rawSha256, source.records[6].rawSha256);
+ const interfaces = await read(3, '/interface'), tables = await read(4, '/routing/table');
+ sources.push({ serverId: source.serverId, ...inspectDirectLinks(routes, nexthops, interfaces, tables) });
+ }
+ return { reviewedReportSha256, sources, recursiveIdentity: 'unknown', semanticProof: false };
+}
+
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ try {
+ assert(process.argv.length === 3, 'Supply the reviewed offline capture directory');
+ process.stdout.write(JSON.stringify(await checkReviewedDirectLinks(process.argv[2])) + '\n');
+ } catch {
+ process.stderr.write('Reviewed direct-link corroboration refused.\n');
+ process.exitCode = 1;
+ }
+}
diff --git a/backend/scripts/acceptance/chr-recursive-direct-links.test.mjs b/backend/scripts/acceptance/chr-recursive-direct-links.test.mjs
new file mode 100644
index 00000000..f989fe19
--- /dev/null
+++ b/backend/scripts/acceptance/chr-recursive-direct-links.test.mjs
@@ -0,0 +1,17 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { inspectDirectLinks } from './chr-recursive-direct-links.mjs';
+
+test('direct evidence requires exact opaque reference and corroborated ifindex namespace', () => {
+ const route = { 'routing-table': 'main', 'nexthop-id': '*A', 'immediate-gw': '192.0.2.1%ether1' };
+ const nexthop = { '.id': '*A', 'immediate-gw.interface-idx': '4' };
+ const iface = { id: '9', ifindex: '4', name: 'ether1' };
+ const table = { '.id': '*0', name: 'main' };
+ assert.deepEqual(inspectDirectLinks([route], [nexthop], [iface], [table]), {
+ opaqueReferences: 1, namedInterfaceCorroborations: 1, interfaceIdSubstitutionRefusals: 1, tableNames: 1, recursiveLinkRows: 0,
+ });
+ assert.throws(() => inspectDirectLinks([{ ...route, 'nexthop-id': '*a' }], [nexthop], [iface], [table]), /exact opaque/);
+ assert.throws(() => inspectDirectLinks([{ ...route, 'routing-table': '0' }], [nexthop], [iface], [table]), /named routing table/);
+ assert.throws(() => inspectDirectLinks([route], [nexthop], [{ ...iface, id: '4', ifindex: '9' }], [table]), /corroboration/);
+ assert.throws(() => inspectDirectLinks([route], [nexthop], [iface, { ...iface, id: '3' }], [table]), /ambiguous ifindex/);
+});
diff --git a/backend/scripts/acceptance/chr-recursive-observation.mjs b/backend/scripts/acceptance/chr-recursive-observation.mjs
new file mode 100644
index 00000000..95f06378
--- /dev/null
+++ b/backend/scripts/acceptance/chr-recursive-observation.mjs
@@ -0,0 +1,177 @@
+import { request as httpRequest } from 'node:http';
+import { request as httpsRequest } from 'node:https';
+import { createHash } from 'node:crypto';
+import { mkdir, realpath, lstat, writeFile } from 'node:fs/promises';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
+export const SOURCES = Object.freeze({
+ '194.226.121.150': Object.freeze({ serverId: 1, port: 19081 }),
+ '104.165.244.7': Object.freeze({ serverId: 2, port: 19082 }),
+});
+export const PATHS = Object.freeze([
+ '/system/resource', '/routing/route', '/routing/nexthop', '/interface',
+ '/routing/table', '/ip/vrf', '/routing/nexthop', '/routing/route', '/system/resource',
+]);
+const LIMITS = Object.freeze({ response: 1048576, bytes: 8388608, requests: 256, rows: 1000, totalRows: 10000, duration: 120000 });
+const sha = value => createHash('sha256').update(value).digest('hex');
+const deny = code => { throw new Error(code); };
+
+export function configuration(args) {
+ const options = {};
+ for (let i = 0; i < args.length; i += 2) {
+ if (!['--source', '--transport', '--output', '--owned-tunnel-attestation'].includes(args[i]) || !args[i + 1] || options[args[i]] !== undefined) deny('invalid-options');
+ options[args[i]] = args[i + 1];
+ }
+ const source = options['--source'], transport = options['--transport'];
+ if (!Object.hasOwn(SOURCES, source) || !['https', 'ssh-loopback'].includes(transport) || !options['--output']) deny('invalid-source-or-transport');
+ const attestation = options['--owned-tunnel-attestation'];
+ if (transport === 'ssh-loopback' && attestation !== 'verified-known-host-161.104.46.222-owned-forward') deny('owned-tunnel-attestation-required');
+ if (transport === 'https' && attestation !== undefined) deny('irrelevant-tunnel-attestation');
+ return { source, serverId: SOURCES[source].serverId, transport, output: options['--output'],
+ endpoint: transport === 'https' ? `https://${source}:443` : `http://127.0.0.1:${SOURCES[source].port}`,
+ tunnelAttestation: attestation ?? null };
+}
+
+export async function privateDirectory(output, root = ROOT) {
+ // Reject symlinks/junctions at every existing component, including tmp itself.
+ const base = path.resolve(root, 'tmp'), target = path.resolve(root, output);
+ const relative = path.relative(base, target);
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) deny('output-must-be-inside-tmp');
+ await mkdir(base, { recursive: true, mode: 0o700 });
+ if ((await lstat(base)).isSymbolicLink() || await realpath(base) !== base) deny('output-symlink-refused');
+ let current = base;
+ for (const part of relative.split(path.sep)) {
+ current = path.join(current, part);
+ try { await mkdir(current, { mode: 0o700 }); } catch (error) { if (error.code !== 'EEXIST') throw error; }
+ const stat = await lstat(current);
+ if (!stat.isDirectory() || stat.isSymbolicLink() || await realpath(current) !== current) deny('output-symlink-refused');
+ }
+ // Exclusive claim prevents mixing runs and refuses existing captures.
+ await writeFile(path.join(target, 'capture.claim'), 'chr-recursive-observation-v1\n', { flag: 'wx', mode: 0o600 });
+ return target;
+}
+
+export function decodeBody(body) {
+ let text, payload;
+ try { text = new TextDecoder('utf-8', { fatal: true }).decode(body); payload = JSON.parse(text); } catch { deny('invalid-utf8-or-json'); }
+ const rows = Array.isArray(payload) ? payload : payload && typeof payload === 'object' ? [payload] : deny('invalid-row-shape');
+ if (rows.length > LIMITS.rows || rows.some(row => !row || typeof row !== 'object' || Array.isArray(row))) deny('row-limit-or-shape');
+ return { rows };
+}
+
+export function readResponse(endpoint, resource, authorization, budget) {
+ const allowed = Object.entries(SOURCES).flatMap(([host, item]) => [`https://${host}:443`, `http://127.0.0.1:${item.port}`]);
+ if (!allowed.includes(endpoint)) deny('non-whitelisted-endpoint');
+ if (!PATHS.includes(resource) || budget.bytes >= LIMITS.bytes || budget.rows >= LIMITS.totalRows || ++budget.requests > LIMITS.requests || Date.now() >= budget.deadline) deny('request-budget');
+ const url = new URL('/rest' + resource, endpoint);
+ return new Promise((resolve, reject) => {
+ const fail = (code, status) => reject(Object.assign(new Error(code), Number.isInteger(status) ? { httpStatus: status } : {}));
+ const req = (url.protocol === 'https:' ? httpsRequest : httpRequest)(url, {
+ method: 'GET', agent: false, rejectUnauthorized: true, maxHeaderSize: 16384,
+ headers: { Authorization: authorization, Accept: 'application/json', 'Accept-Encoding': 'identity' },
+ }, res => {
+ const chunks = []; let size = 0;
+ res.on('data', chunk => {
+ size += chunk.length; budget.bytes += chunk.length;
+ if (size > LIMITS.response || budget.bytes > LIMITS.bytes) { req.destroy(); fail('byte-limit'); return; }
+ chunks.push(chunk);
+ });
+ res.on('aborted', () => fail('response-aborted'));
+ res.on('error', () => fail('response-failed'));
+ res.on('end', () => {
+ const body = Buffer.concat(chunks);
+ // Raw failed HTTP responses are excluded: error bodies can reflect secrets.
+ if (res.statusCode !== 200) return fail('http-status-refused', res.statusCode);
+ const type = res.headers['content-type'];
+ if (typeof type !== 'string' || !/^application\/json(?:\s*;\s*charset=utf-8)?$/i.test(type) || res.headers['content-encoding'] && res.headers['content-encoding'] !== 'identity') return fail('response-encoding-refused');
+ try {
+ const { rows } = decodeBody(body);
+ budget.rows += rows.length;
+ if (budget.rows > LIMITS.totalRows || Date.now() >= budget.deadline) return fail('response-budget');
+ resolve({ body, rows, status: res.statusCode, contentType: type });
+ } catch { fail('invalid-response'); }
+ });
+ });
+ const timer = setTimeout(() => { req.destroy(); fail('absolute-deadline'); }, Math.max(1, budget.deadline - Date.now()));
+ req.on('error', () => fail('transport-failed'));
+ req.on('close', () => clearTimeout(timer));
+ req.end();
+ });
+}
+
+export async function acquire(config, credentials) {
+ if (typeof credentials?.username !== 'string' || !credentials.username || credentials.username.length > 256 || /[:\r\n]/.test(credentials.username) || typeof credentials.password !== 'string' || !credentials.password || credentials.password.length > 4096 || /[\r\n]/.test(credentials.password)) deny('invalid-private-credentials');
+ // Validate caller configuration again; exported API cannot supply a custom host.
+ const fixed = configuration(['--source', config.source, '--transport', config.transport, '--output', config.output,
+ ...(config.tunnelAttestation ? ['--owned-tunnel-attestation', config.tunnelAttestation] : [])]);
+ const directory = await privateDirectory(fixed.output);
+ const budget = { requests: 0, bytes: 0, rows: 0, deadline: Date.now() + LIMITS.duration };
+ const authorization = 'Basic ' + Buffer.from(credentials.username + ':' + credentials.password).toString('base64');
+ const report = { format: 'chr-recursive-raw-acquisition-v1', source: fixed.source, serverId: fixed.serverId,
+ transport: fixed.transport, tunnelAttestation: fixed.tunnelAttestation, startedAt: new Date().toISOString(),
+ semanticProof: false, complete: false, snapshotBracket: null, records: [], limits: LIMITS };
+ let version, attemptedResource;
+ try {
+ for (const [index, resource] of PATHS.entries()) {
+ attemptedResource = resource;
+ const startedAt = new Date().toISOString();
+ const response = await readResponse(fixed.endpoint, resource, authorization, budget);
+ // Never persist a body reflecting the private credential or Basic value.
+ if ([credentials.password, authorization].some(secret => response.body.includes(Buffer.from(secret)))) deny('credential-reflection-refused');
+ if (resource === '/system/resource') {
+ const current = response.rows.length === 1 && response.rows[0].version;
+ if (typeof current !== 'string' || !/^7\.2[0-6](?:\.\d{1,3})?(?: \((?:stable|long-term)\))?$/.test(current) || version && version !== current) deny('unsupported-or-drifting-version');
+ version = current;
+ }
+ const file = `${String(index + 1).padStart(2, '0')}-${resource.slice(1).replaceAll('/', '-')}.json`;
+ await writeFile(path.join(directory, file), response.body, { flag: 'wx', mode: 0o600 });
+ report.records.push({ file, resource, startedAt, finishedAt: new Date().toISOString(), version,
+ status: response.status, contentType: response.contentType, bytes: response.body.length, rows: response.rows.length, rawSha256: sha(response.body) });
+ }
+ const hashFor = resource => report.records.filter(record => record.resource === resource).map(record => record.rawSha256);
+ const [firstRoute, lastRoute] = hashFor('/routing/route');
+ const [firstNexthop, lastNexthop] = hashFor('/routing/nexthop');
+ report.snapshotBracket = {
+ routeByteEqual: firstRoute === lastRoute,
+ nexthopByteEqual: firstNexthop === lastNexthop,
+ };
+ report.complete = true;
+ } catch (error) {
+ report.failure = 'acquisition-incomplete';
+ report.failedResource = attemptedResource;
+ if (Number.isInteger(error.httpStatus) && error.httpStatus >= 100 && error.httpStatus <= 599) report.failedHttpStatus = error.httpStatus;
+ }
+ report.finishedAt = new Date().toISOString();
+ report.usage = { requests: budget.requests, bytes: budget.bytes, rows: budget.rows };
+ await writeFile(path.join(directory, 'report.json'), JSON.stringify(report, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
+ return report;
+}
+
+async function privateStdin() {
+ // Piped stdin is private (no terminal echo). TTY raw mode hides all input.
+ const input = process.stdin, chunks = []; let size = 0;
+ if (input.isTTY) { process.stderr.write('Private credentials JSON (hidden), then Enter: '); input.setRawMode(true); }
+ try {
+ for await (const chunk of input) {
+ size += chunk.length;
+ if (size > 8192) deny('private-input-limit');
+ if (input.isTTY && chunk.includes(3)) deny('private-input-cancelled');
+ chunks.push(chunk);
+ if (input.isTTY && (chunk.includes(13) || chunk.includes(10))) break;
+ }
+ return JSON.parse(Buffer.concat(chunks).toString('utf8').trim());
+ } finally { if (input.isTTY) { input.setRawMode(false); process.stderr.write('\n'); } }
+}
+
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ try {
+ const config = configuration(process.argv.slice(2));
+ const report = await acquire(config, await privateStdin());
+ // Stdout contains metadata only; no native bodies, credentials or errors.
+ process.stdout.write(JSON.stringify({ complete: report.complete, snapshotBracket: report.snapshotBracket,
+ semanticProof: false, source: report.source, records: report.records.length }) + '\n');
+ if (!report.complete) process.exitCode = 1;
+ } catch { process.stderr.write('Read-only acquisition refused or incomplete.\n'); process.exitCode = 1; }
+}
diff --git a/backend/scripts/acceptance/chr-recursive-observation.test.mjs b/backend/scripts/acceptance/chr-recursive-observation.test.mjs
new file mode 100644
index 00000000..08b840c7
--- /dev/null
+++ b/backend/scripts/acceptance/chr-recursive-observation.test.mjs
@@ -0,0 +1,96 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { createServer } from 'node:http';
+import { randomUUID, createHash } from 'node:crypto';
+import { readFile, readdir } from 'node:fs/promises';
+import { fileURLToPath } from 'node:url';
+import { configuration, decodeBody, readResponse, acquire, privateDirectory, PATHS } from './chr-recursive-observation.mjs';
+
+test('source/transport allowlist refuses arbitrary hosts, plaintext external, missing tunnel attestation and option injection', () => {
+ const args = ['--source', '194.226.121.150', '--transport', 'https', '--output', 'tmp/acquisition-test'];
+ assert.equal(configuration(args).endpoint, 'https://194.226.121.150:443');
+ for (const changes of [args.map(x => x === '194.226.121.150' ? 'example.org' : x), args.map(x => x === 'https' ? 'http' : x),
+ args.map(x => x === 'https' ? 'ssh-loopback' : x), [...args, '--password', 'forbidden'], [...args, '--source', '104.165.244.7']]) assert.throws(() => configuration(changes));
+ const tunnel = configuration([...args.map(x => x === 'https' ? 'ssh-loopback' : x), '--owned-tunnel-attestation', 'verified-known-host-161.104.46.222-owned-forward']);
+ assert.equal(tunnel.endpoint, 'http://127.0.0.1:19081');
+});
+
+test('full own fixture saves nine exact immutable captures and metadata; reflected errors never enter reports', async () => {
+ const output = fileURLToPath(new URL('../../../tmp/chr-recursive-own-fixture-' + randomUUID(), import.meta.url)), seen = [];
+ let reflect = false, driftingResource;
+ const server = createServer((req, res) => {
+ seen.push(req.url); res.setHeader('Content-Type', 'application/json');
+ if (reflect) { res.statusCode = 401; res.end('{"message":"own-fixture-secret-only"}'); return; }
+ if (req.url === '/rest/system/resource') res.end('[{"version":"7.26"}]\n');
+ else if (req.url === driftingResource && seen.indexOf(req.url) !== seen.length - 1) res.end('[{".id":"*2"}]\n');
+ else res.end('[{".id":"*1"}]\n');
+ });
+ await new Promise((resolve, reject) => { server.once('error', reject); server.listen(19081, '127.0.0.1', resolve); });
+ const makeConfig = destination => configuration(['--source', '194.226.121.150', '--transport', 'ssh-loopback', '--output', destination,
+ '--owned-tunnel-attestation', 'verified-known-host-161.104.46.222-owned-forward']);
+ try {
+ const report = await acquire(makeConfig(output), { username: 'own-fixture', password: 'own-fixture-secret-only' });
+ assert.equal(report.complete, true); assert.equal(report.semanticProof, false);
+ assert.deepEqual(report.snapshotBracket, { routeByteEqual: true, nexthopByteEqual: true });
+ assert.deepEqual(seen, PATHS.map(resource => '/rest' + resource));
+ for (const record of report.records) {
+ const body = await readFile(output + '/' + record.file);
+ assert.equal(createHash('sha256').update(body).digest('hex'), record.rawSha256);
+ assert.equal(body.length, record.bytes); assert.equal(record.version, '7.26');
+ }
+ await assert.rejects(acquire(makeConfig(output), { username: 'own-fixture', password: 'own-fixture-secret-only' }));
+ assert.equal(seen.length, 9);
+ await assert.rejects(privateDirectory('../outside-tmp'));
+ for (const resource of ['route', 'nexthop']) {
+ seen.length = 0;
+ driftingResource = '/rest/routing/' + resource;
+ const driftOutput = output + '-' + resource;
+ const drift = await acquire(makeConfig(driftOutput), { username: 'own-fixture', password: 'own-fixture-secret-only' });
+ assert.equal(drift.complete, true);
+ assert.equal(drift.semanticProof, false);
+ assert.deepEqual(drift.snapshotBracket, { routeByteEqual: resource !== 'route', nexthopByteEqual: resource !== 'nexthop' });
+ assert.equal(drift.records.length, 9);
+ assert.deepEqual(JSON.parse(await readFile(driftOutput + '/report.json', 'utf8')).snapshotBracket, drift.snapshotBracket);
+ }
+ reflect = true;
+ const failedOutput = output + '-failed';
+ const failed = await acquire(makeConfig(failedOutput), { username: 'own-fixture', password: 'own-fixture-secret-only' });
+ assert.equal(failed.complete, false); assert.equal(failed.records.length, 0);
+ assert.equal(failed.snapshotBracket, null);
+ assert.equal(failed.failedResource, '/system/resource'); assert.equal(failed.failedHttpStatus, 401);
+ assert.deepEqual((await readdir(failedOutput)).sort(), ['capture.claim', 'report.json']);
+ assert(!String(await readFile(failedOutput + '/report.json')).includes('own-fixture-secret-only'));
+ } finally { await new Promise(resolve => server.close(resolve)); }
+});
+
+test('exact UTF8 and row bounds fail closed', () => {
+ assert.equal(decodeBody(Buffer.from('[{"version":"7.26"}]')).rows.length, 1);
+ for (const body of [Buffer.from([0xff]), Buffer.from('null'), Buffer.from('[[]]'), Buffer.from(JSON.stringify(Array.from({ length: 1001 }, () => ({}))))]) assert.throws(() => decodeBody(body));
+});
+
+test('own loopback fixture observes exact GET paths, refuses redirect/error/encoding/bytes, no retry or follow', async () => {
+ let mode = 'normal', requests = 0;
+ const server = createServer((req, res) => {
+ requests++;
+ assert.equal(req.method, 'GET'); assert.equal(req.url, '/rest/system/resource');
+ res.setHeader('Content-Type', 'application/json');
+ if (mode === 'redirect') { res.statusCode = 302; res.setHeader('Location', 'http://example.invalid'); res.end('[]'); }
+ else if (mode === 'error') { res.statusCode = 401; res.end('{"error":"reflected-private-input"}'); }
+ else if (mode === 'encoding') { res.setHeader('Content-Encoding', 'gzip'); res.end('[]'); }
+ else if (mode === 'oversized') res.end(' '.repeat(1048577));
+ else res.end('[{"version":"7.26"}]\n');
+ });
+ await new Promise((resolve, reject) => { server.once('error', reject); server.listen(19081, '127.0.0.1', resolve); });
+ const budget = () => ({ requests: 0, bytes: 0, rows: 0, deadline: Date.now() + 5000 });
+ try {
+ const first = await readResponse('http://127.0.0.1:19081', PATHS[0], 'Basic own-fixture', budget());
+ assert.equal(first.body.toString(), '[{"version":"7.26"}]\n');
+ for (mode of ['redirect', 'error', 'encoding', 'oversized']) await assert.rejects(readResponse('http://127.0.0.1:19081', PATHS[0], 'Basic own-fixture', budget()));
+ assert.equal(requests, 5);
+ assert.throws(() => readResponse('http://194.226.121.150', PATHS[0], '', budget()));
+ assert.throws(() => readResponse('http://127.0.0.1:19081', '/system/reboot', '', budget()));
+ assert.throws(() => readResponse('http://127.0.0.1:19081', PATHS[0], '', { ...budget(), requests: 256 }));
+ assert.throws(() => readResponse('http://127.0.0.1:19081', PATHS[0], '', { ...budget(), deadline: 0 }));
+ assert.equal(requests, 5);
+ } finally { await new Promise(resolve => server.close(resolve)); }
+});
diff --git a/backend/scripts/acceptance/installation-memory-budget.mjs b/backend/scripts/acceptance/installation-memory-budget.mjs
new file mode 100644
index 00000000..4fbcf8f8
--- /dev/null
+++ b/backend/scripts/acceptance/installation-memory-budget.mjs
@@ -0,0 +1,155 @@
+/** Arithmetic preflight only. No Docker/host access, changes or workload admission.
+ * Roles are operator-supplied labels, not authenticated service identities.
+ * Even a fitting budget cannot prove runtime <=2GB or permission to change limits. */
+const MiB = 1024 * 1024
+const roles = new Set(['backend', 'postgres', 'frontend', 'portal', 'proxy', 'agent', 'other'])
+const singleton = new Set(['backend', 'postgres', 'frontend', 'portal'])
+const integer = value => Number.isSafeInteger(value) && value >= 0
+const exact = (value, fields) => value !== null && typeof value === 'object' && !Array.isArray(value)
+ && Object.keys(value).sort().join('|') === [...fields].sort().join('|')
+const id = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value)
+
+export function evaluateInstallationMemoryBudget(input) {
+ if (!exact(input, ['hostMemTotalBytes', 'osReserveBytes', 'observedContainerIds', 'containers'])
+ || !integer(input.hostMemTotalBytes) || !integer(input.osReserveBytes)
+ || !Array.isArray(input.observedContainerIds) || !Array.isArray(input.containers)
+ || input.observedContainerIds.length > 128 || input.containers.length > 128) throw Error('Invalid bounded installation inventory')
+ if (input.observedContainerIds.some(value => !id(value)) || new Set(input.observedContainerIds).size !== input.observedContainerIds.length) throw Error('Invalid observed container set')
+ const seen = new Set(), counts = new Map(), reasons = new Set()
+ let configuredBytes = 0
+ for (const row of input.containers) {
+ if (!exact(row, ['id', 'role', 'configuredLimitBytes']) || !id(row.id) || !roles.has(row.role)
+ || !integer(row.configuredLimitBytes) || seen.has(row.id)) throw Error('Invalid container budget')
+ seen.add(row.id); counts.set(row.role, (counts.get(row.role) ?? 0) + 1)
+ if (row.configuredLimitBytes === 0) reasons.add('UNBOUNDED_CONTAINER')
+ if (row.configuredLimitBytes > input.hostMemTotalBytes) reasons.add('CONTAINER_LIMIT_EXCEEDS_HOST')
+ if (!Number.isSafeInteger(configuredBytes + row.configuredLimitBytes)) throw Error('Container budget overflow')
+ configuredBytes += row.configuredLimitBytes
+ }
+ if (seen.size !== input.observedContainerIds.length || input.observedContainerIds.some(value => !seen.has(value))) reasons.add('INCOMPLETE_HOST_CONTAINER_INVENTORY')
+ for (const role of ['backend', 'postgres', 'frontend']) if (!counts.has(role)) reasons.add('REQUIRED_SERVICE_MISSING')
+ for (const role of singleton) if ((counts.get(role) ?? 0) > 1) reasons.add('DUPLICATE_APPLICATION_STACK')
+ if (input.hostMemTotalBytes === 0 || input.hostMemTotalBytes > 2 * 1024 * MiB) reasons.add('HOST_OUTSIDE_2GIB_TARGET')
+ if (input.osReserveBytes < 512 * MiB) reasons.add('OS_RESERVE_BELOW_CANDIDATE_FLOOR')
+ if (!Number.isSafeInteger(configuredBytes + input.osReserveBytes)) throw Error('Installation budget overflow')
+ const plannedBytes = configuredBytes + input.osReserveBytes
+ if (plannedBytes > input.hostMemTotalBytes) reasons.add('INSTALLATION_BUDGET_EXCEEDS_HOST')
+ return Object.freeze({ scope: 'arithmetic-preflight-only', budgetFits: reasons.size === 0,
+ wholeInstallation2GbAccepted: false, runtimeAcceptanceClaimed: false, changesAuthorized: false,
+ configuredContainerBytes: configuredBytes, osReserveBytes: input.osReserveBytes,
+ plannedBytes, remainingBytes: input.hostMemTotalBytes - plannedBytes,
+ observedContainers: input.observedContainerIds.length, reasons: Object.freeze([...reasons].sort()) })
+}
+
+/** Project the whitelist-only read-only inventory. Never substitute idle RSS or
+ * Docker's reported host ceiling for HostConfig.Memory. Labels/freshness are
+ * not authenticated here; this result must not be used as mutation authority. */
+export function evaluateObservedInstallationBudget(inventory, roleById, osReserveBytes = 512 * MiB) {
+ if (!inventory || inventory.readOnly !== true || inventory.containerSetStable !== true
+ || inventory.environmentRead !== false || inventory.serviceChanges !== false || inventory.newFixtureStarted !== false
+ || !Array.isArray(inventory.containers) || inventory.containers.length > 128
+ || !roleById || typeof roleById !== 'object' || Array.isArray(roleById)) throw Error('Invalid read-only installation inventory')
+ const containers = inventory.containers.map(row => {
+ if (!row || !id(row.id) || row.running !== true || !integer(row.memoryLimitBytes)
+ || !/^sha256:[a-f0-9]{64}$/.test(row.imageId) || !Number.isFinite(Date.parse(row.startedAt))) throw Error('Incomplete configured-limit observation')
+ const label = Object.getOwnPropertyDescriptor(roleById, row.id)
+ if (!label || typeof label.value !== 'string' || !roles.has(label.value)) throw Error('Explicit container role missing')
+ return { id: row.id, role: label.value, configuredLimitBytes: row.memoryLimitBytes }
+ })
+ const observedContainerIds = containers.map(row => row.id)
+ if (Object.keys(roleById).length !== observedContainerIds.length || Object.keys(roleById).some(key => !observedContainerIds.includes(key))) throw Error('Foreign or incomplete role inventory')
+ const budget = evaluateInstallationMemoryBudget({ hostMemTotalBytes: inventory.hostMemTotalBytes, osReserveBytes, observedContainerIds, containers })
+ return Object.freeze({ ...budget, configuredLimitsSource: 'observed-HostConfig.Memory', roleLabelsAuthenticated: false, inventoryFreshnessProven: false })
+}
+
+/** NEW pure raw-text bridge for measure-memory schema2/3. This is NOT the
+ * separate GET-only inventory contract consumed by evaluateObserved above.
+ * No file/container/socket access or mutation authority. Parse raw text only:
+ * precision lost by a caller's previous JSON.parse cannot be recovered. */
+export function evaluateMeasuredInstallationBudget(rawText, roleById, osReserveBytes = 512 * MiB) {
+ if (typeof rawText !== 'string') throw Error('Raw measurement JSON text required; preparsed precision cannot be recovered')
+ if (Buffer.byteLength(rawText, 'utf8') > 32 * 1024 * 1024) throw Error('Measurement text bound exceeded')
+ // A narrow numeric lexical gate BEFORE JSON.parse, not a JSON parser. The
+ // Python producer emits only integer JSON numbers (PSI averages are strings).
+ // Reject decimal/exponent/unsafe integers even where JSON.parse would round
+ // a fractional lexeme into a seemingly safe integer. JSON.parse checks syntax.
+ const number = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y
+ let quoted = false, escaped = false
+ for (let index = 0; index < rawText.length; index++) {
+ const char = rawText[index]
+ if (quoted) { if (escaped) escaped = false; else if (char === '\\') escaped = true; else if (char === '"') quoted = false; continue }
+ if (char === '"') { quoted = true; continue }
+ if (char === '-' || char >= '0' && char <= '9') {
+ number.lastIndex = index; const token = number.exec(rawText)?.[0]
+ if (!token || token === '-0' || !/^-?(?:0|[1-9][0-9]*)$/.test(token) || token.replace('-', '').length > 16) throw Error('Unsafe or noninteger measurement JSON number')
+ const value = BigInt(token)
+ if (value < -9007199254740991n || value > 9007199254740991n) throw Error('Unsafe measurement JSON integer')
+ index = number.lastIndex - 1
+ }
+ }
+ const data = JSON.parse(rawText)
+ if (!data || ![2, 3].includes(data.schemaVersion) || data.readOnlyDockerAndProc !== true || data.serviceChanges !== 0
+ || data.summary?.acceptancePassed !== false || !Array.isArray(data.observations) || !data.observations.length || data.observations.length > 300
+ || !roleById || typeof roleById !== 'object' || Array.isArray(roleById)) throw Error('Unsupported or incomplete memory measurement')
+ const nonnegativeSafe = value => Number.isSafeInteger(value) && value >= 0
+ const limit = value => value === 'max' || nonnegativeSafe(value) ? value : null
+ const swap = row => row.configuredMemorySwapStatus === 'available' && Number.isSafeInteger(row.configuredMemorySwapBytes) && row.configuredMemorySwapBytes >= -1 ? row.configuredMemorySwapBytes : null
+ const cpu = value => value && ['nr_periods', 'nr_throttled', 'throttled_usec'].every(key => nonnegativeSafe(value[key]))
+ ? Object.fromEntries(['nr_periods', 'nr_throttled', 'throttled_usec'].map(key => [key, value[key]])) : null
+ const pressure = host => {
+ if (host.memoryPressure?.status !== 'available') return null
+ const result = {}
+ for (const key of ['some', 'full']) {
+ const value = host.memoryPressure.metrics?.[key]
+ if (!value || !nonnegativeSafe(value.totalMicros)) return null
+ for (const avg of ['avg10Percent', 'avg60Percent', 'avg300Percent']) {
+ if (typeof value[avg] !== 'string' || !/^[0-9]{1,3}\.[0-9]{2}$/.test(value[avg]) || Number(value[avg]) > 100) return null
+ }
+ result[key] = Object.fromEntries(['avg10Percent', 'avg60Percent', 'avg300Percent', 'totalMicros'].map(name => [name, value[name]]))
+ }
+ return result
+ }
+ let baseline, hostMemory, priorElapsed = -1, complete = data.schemaVersion === 3
+ const extendedObservations = []
+ for (const observation of data.observations) {
+ if (!observation?.host || !nonnegativeSafe(observation.elapsedMs) || observation.elapsedMs < priorElapsed || observation.elapsedMs > 360000
+ || !nonnegativeSafe(observation.host.MemTotalBytes) || !observation.host.MemTotalBytes
+ || !Array.isArray(observation.containers) || !observation.containers.length || observation.containers.length > 16) throw Error('Incomplete bounded measurement sample')
+ priorElapsed = observation.elapsedMs
+ hostMemory ??= observation.host.MemTotalBytes
+ if (hostMemory !== observation.host.MemTotalBytes) throw Error('Measurement host memory changed')
+ const ids = new Set(), identities = [], extended = []
+ for (const row of observation.containers) {
+ if (!row || !id(row.id) || ids.has(row.id) || !/^sha256:[a-f0-9]{64}$/.test(row.imageId) || (typeof row.startedAt !== 'string' || !Number.isFinite(Date.parse(row.startedAt)))
+ || row.running !== true || row.runningAfter !== true || row.identityStableDuringSample !== true || row.oomKilled !== false || row.oomKilledAfter !== false
+ || !nonnegativeSafe(row.restartCount) || !Number.isSafeInteger(row.pid) || row.pid < 1 || row.pid > 2147483647 || !nonnegativeSafe(row.configuredLimitBytes)) throw Error('Unavailable measurement container identity or configured cap')
+ ids.add(row.id); identities.push([row.id, row.imageId, row.startedAt, row.pid, row.restartCount, row.configuredLimitBytes, data.schemaVersion === 3 ? swap(row) : null])
+ if (data.schemaVersion === 3) {
+ const metrics = row.cgroupV2?.metrics, memoryMax = limit(metrics?.['memory.max']), swapMax = limit(metrics?.['memory.swap.max'])
+ const cpuThrottling = cpu(metrics?.['cpu.stat']), configuredMemorySwapBytes = swap(row)
+ const available = row.cgroupV2?.status === 'available' && row.resourceLimitsStableDuringSample === true
+ && memoryMax !== null && swapMax !== null && cpuThrottling !== null && configuredMemorySwapBytes !== null
+ complete &&= available
+ extended.push({id: row.id, memoryMax, swapMax, configuredMemorySwapBytes, cpuThrottling, available})
+ } else extended.push({id: row.id, memoryMax: null, swapMax: null, configuredMemorySwapBytes: null, cpuThrottling: null, available: false})
+ }
+ identities.sort((a, b) => a[0].localeCompare(b[0]))
+ const encoded = JSON.stringify(identities)
+ baseline ??= encoded
+ if (encoded !== baseline) throw Error('Measurement container set, identity or memory cap changed')
+ const memoryPressure = data.schemaVersion === 3 ? pressure(observation.host) : null
+ complete &&= memoryPressure !== null
+ extendedObservations.push({elapsedMs: observation.elapsedMs, memoryPressure, containers: extended})
+ }
+ const captured = JSON.parse(baseline)
+ if (Object.keys(roleById).length !== captured.length || Object.keys(roleById).some(key => !captured.some(row => row[0] === key))) throw Error('Incomplete or foreign measured role inventory')
+ const containers = captured.map(([identifier, _image, _start, _pid, _restart, configuredLimitBytes]) => {
+ const descriptor = Object.getOwnPropertyDescriptor(roleById, identifier)
+ if (!descriptor || typeof descriptor.value !== 'string' || !roles.has(descriptor.value)) throw Error('Explicit measured container role missing')
+ return {id: identifier, role: descriptor.value, configuredLimitBytes}
+ })
+ const budget = evaluateInstallationMemoryBudget({hostMemTotalBytes: hostMemory, osReserveBytes, observedContainerIds: containers.map(row => row.id), containers})
+ return Object.freeze({...budget, measurementSchemaVersion: data.schemaVersion, measurementSamples: data.observations.length,
+ extendedMetricsComplete: complete, extendedObservations: Object.freeze(extendedObservations),
+ roleLabelsAuthenticated: false, inventoryFreshnessProven: false, hostContainerInventoryComplete: false, measurementSelectedContainersOnly: true, noSwapAccepted: false, sourceGenerationAuthenticated: false})
+}
diff --git a/backend/scripts/acceptance/installation-memory-budget.test.mjs b/backend/scripts/acceptance/installation-memory-budget.test.mjs
new file mode 100644
index 00000000..0fa4270b
--- /dev/null
+++ b/backend/scripts/acceptance/installation-memory-budget.test.mjs
@@ -0,0 +1,46 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { evaluateInstallationMemoryBudget as evaluate } from './installation-memory-budget.mjs'
+const MiB = 1024 * 1024
+function fixture() {
+ const containers = [['backend',512],['postgres',384],['frontend',160],['portal',192]].map(([role, limit], i) => ({ id: String(i+1).repeat(64), role, configuredLimitBytes: limit * MiB }))
+ return { hostMemTotalBytes: 2021212 * 1024, osReserveBytes: 512 * MiB, observedContainerIds: containers.map(row => row.id), containers }
+}
+test('complete four-service candidate fits arithmetic, never runtime acceptance or change permission', () => {
+ const input = fixture(), before = structuredClone(input), result = evaluate(input)
+ assert.equal(result.budgetFits,true); assert.equal(result.plannedBytes,1760 * MiB)
+ assert.equal(result.wholeInstallation2GbAccepted,false); assert.equal(result.runtimeAcceptanceClaimed,false); assert.equal(result.changesAuthorized,false)
+ assert(Object.isFrozen(result)); assert(Object.isFrozen(result.reasons)); assert.deepEqual(input,before)
+})
+test('coexisting baseline and owned app/PG cannot represent one installation', () => {
+ const input = fixture()
+ for (const [i,role,limit] of [[5,'backend',320],[6,'postgres',192]]) { input.containers.push({id:String(i).repeat(64),role,configuredLimitBytes:limit*MiB}); input.observedContainerIds.push(String(i).repeat(64)) }
+ const result = evaluate(input)
+ assert.equal(result.budgetFits,false); assert(result.reasons.includes('DUPLICATE_APPLICATION_STACK')); assert(result.reasons.includes('INSTALLATION_BUDGET_EXCEEDS_HOST'))
+})
+test('unknown host containers, missing and foreign inventory entries refuse', () => {
+ for (const mode of ['omitted','foreign','missing-service']) {
+ const input = fixture()
+ if (mode === 'omitted') input.observedContainerIds.push('a'.repeat(64))
+ if (mode === 'foreign') input.containers[0].id='b'.repeat(64)
+ if (mode === 'missing-service') { input.containers.splice(0,1); input.observedContainerIds.splice(0,1) }
+ const result = evaluate(input); assert.equal(result.budgetFits,false)
+ assert(result.reasons.includes(mode === 'missing-service'?'REQUIRED_SERVICE_MISSING':'INCOMPLETE_HOST_CONTAINER_INVENTORY'))
+ }
+})
+test('unlimited cap is distinct from observed idle RSS or Docker host limit display', () => {
+ const input = fixture(); input.containers[0].configuredLimitBytes=0
+ assert(evaluate(input).reasons.includes('UNBOUNDED_CONTAINER'))
+ input.containers[0].configuredLimitBytes=3*1024*MiB
+ assert(evaluate(input).reasons.includes('CONTAINER_LIMIT_EXCEEDS_HOST'))
+})
+test('extra service, reserve and physical host all count toward the same budget', () => {
+ const input = fixture(); input.containers.push({id:'a'.repeat(64),role:'other',configuredLimitBytes:256*MiB}); input.observedContainerIds.push('a'.repeat(64))
+ assert(evaluate(input).reasons.includes('INSTALLATION_BUDGET_EXCEEDS_HOST'))
+ const low = fixture(); low.osReserveBytes=128*MiB; assert(evaluate(low).reasons.includes('OS_RESERVE_BELOW_CANDIDATE_FLOOR'))
+ const large = fixture(); large.hostMemTotalBytes=4*1024*MiB; assert(evaluate(large).reasons.includes('HOST_OUTSIDE_2GIB_TARGET'))
+})
+test('malformed, duplicate, fractional, oversized or unsafe inventory rejects without I/O', () => {
+ const mutations = [input=>{input.inject='unknown'},input=>{input.containers[0].role='invented'},input=>{input.containers[0].configuredLimitBytes=-1},input=>{input.containers[0].configuredLimitBytes=0.5},input=>{input.containers[0].id='../foreign'},input=>{input.containers[1].id=input.containers[0].id},input=>{input.observedContainerIds.push(input.observedContainerIds[0])},input=>{input.containers[0].configuredLimitBytes=Number.MAX_SAFE_INTEGER},input=>{input.observedContainerIds=Array(129).fill('a'.repeat(64))}]
+ for (const mutate of mutations) { const input=fixture();mutate(input);assert.throws(()=>evaluate(input)) }
+})
diff --git a/backend/scripts/acceptance/installation-memory-measurement.test.mjs b/backend/scripts/acceptance/installation-memory-measurement.test.mjs
new file mode 100644
index 00000000..fdca0423
--- /dev/null
+++ b/backend/scripts/acceptance/installation-memory-measurement.test.mjs
@@ -0,0 +1,25 @@
+import assert from 'node:assert/strict'
+import {test} from 'node:test'
+import {evaluateMeasuredInstallationBudget as evaluate,evaluateInstallationMemoryBudget as legacy} from './installation-memory-budget.mjs'
+const MiB=1024*1024
+function fixture(version=3){
+ const roles=['backend','postgres','frontend','portal'],caps=[512,384,160,192]
+ const containers=roles.map((role,i)=>({id:String(i+1).repeat(64),imageId:'sha256:'+'a'.repeat(64),startedAt:'2026-11-02T00:00:00Z',pid:i+1,restartCount:0,running:true,runningAfter:true,identityStableDuringSample:true,oomKilled:false,oomKilledAfter:false,configuredLimitBytes:caps[i]*MiB,reportedLimitBytes:2*1024*MiB,
+ ...(version===3?{configuredMemorySwapBytes:caps[i]*MiB,configuredMemorySwapStatus:'available',resourceLimitsStableDuringSample:true,cgroupV2:{status:'available',metrics:{'memory.max':caps[i]*MiB,'memory.swap.max':0,'cpu.stat':{nr_periods:10,nr_throttled:2,throttled_usec:1234,notWhitelisted:999}}}}:{cgroupV2:{status:'available',metrics:{'memory.current':1,'memory.peak':2}}})}))
+ const p={avg10Percent:'0.00',avg60Percent:'0.01',avg300Percent:'1.25',totalMicros:123456}
+ const host={MemTotalBytes:2069721088,MemAvailableBytes:1000000000,pswpin:0,pswpout:0,oom_kill:0,...(version===3?{memoryPressure:{status:'available',metrics:{some:p,full:{...p,totalMicros:0}}}}:{})}
+ const data={schemaVersion:version,readOnlyDockerAndProc:true,serviceChanges:0,summary:{acceptancePassed:false},observations:[{elapsedMs:0,host,containers},{elapsedMs:1000,host:structuredClone(host),containers:structuredClone(containers)}]}
+ return {data,roleById:Object.fromEntries(containers.map((c,i)=>[c.id,roles[i]])),raw:()=>JSON.stringify(data)}
+}
+test('real schema2 producer contract remains arithmetic-only; missing extended measurements stay unknown',()=>{const f=fixture(2),r=evaluate(f.raw(),f.roleById);assert.equal(r.budgetFits,true);assert.equal(r.plannedBytes,1760*MiB);assert.equal(r.measurementSchemaVersion,2);assert.equal(r.extendedMetricsComplete,false);assert.equal(r.extendedObservations[0].memoryPressure,null);assert.equal(r.extendedObservations[0].containers[0].memoryMax,null);assert.equal(r.wholeInstallation2GbAccepted,false)})
+test('schema3 projects only fixed new fields and never converts data to runtime/no-swap authority',()=>{const f=fixture(),r=evaluate(f.raw(),f.roleById);assert.equal(r.extendedMetricsComplete,true);assert.equal(r.measurementSamples,2);assert.equal(r.extendedObservations[0].containers[0].cpuThrottling.throttled_usec,1234);assert.equal(r.extendedObservations[0].memoryPressure.some.avg300Percent,'1.25');assert(!JSON.stringify(r).includes('notWhitelisted'));assert.equal(r.runtimeAcceptanceClaimed,false);assert.equal(r.changesAuthorized,false);assert.equal(r.noSwapAccepted,false);assert.equal(r.inventoryFreshnessProven,false);assert.equal(r.hostContainerInventoryComplete,false);assert.equal(r.measurementSelectedContainersOnly,true)})
+test('numeric unlimited max/zero/-1/daemon-default preserve their different observed meanings',()=>{const f=fixture();for(const o of f.data.observations){const c=o.containers[0];c.cgroupV2.metrics['memory.max']='max';c.cgroupV2.metrics['memory.swap.max']='max';c.configuredMemorySwapBytes=-1}let r=evaluate(f.raw(),f.roleById);assert.equal(r.extendedObservations[0].containers[0].memoryMax,'max');assert.equal(r.extendedObservations[0].containers[0].configuredMemorySwapBytes,-1);assert.equal(r.noSwapAccepted,false);for(const o of f.data.observations)o.containers[0].configuredMemorySwapBytes=0;r=evaluate(f.raw(),f.roleById);assert.equal(r.extendedObservations[0].containers[0].configuredMemorySwapBytes,0)})
+test('missing schema3 fields, partial cgroup and invalid PSI are unknown rather than zero',()=>{for(const mutate of [o=>{delete o.containers[0].configuredMemorySwapBytes},o=>{o.containers[0].cgroupV2.status='partial'},o=>{o.containers[0].cgroupV2.metrics['memory.max']=null},o=>{delete o.containers[0].cgroupV2.metrics['cpu.stat'].nr_periods},o=>{o.host.memoryPressure.metrics.some.avg10Percent='100.01'},o=>{o.host.memoryPressure.status='unavailable'}]){const f=fixture();for(const o of f.data.observations)mutate(o);const r=evaluate(f.raw(),f.roleById);assert.equal(r.extendedMetricsComplete,false);assert.equal(r.wholeInstallation2GbAccepted,false)}})
+test('unsafe uint64 raw lexemes fail before JSON.parse; no rounded Number is recovered',()=>{for(const token of ['9007199254740992','9007199254740993','18446744073709551615','1.0000000000000001','9007199254740991.1','1e0','-0']){const f=fixture(),raw=f.raw().replace('123456',token);assert.throws(()=>evaluate(raw,f.roleById),/Unsafe|noninteger/);assert.throws(()=>evaluate(JSON.parse(raw),f.roleById),/Raw measurement JSON text required/)} })
+test('safe integer boundary is exact and large number-like text inside strings is not parsed as a counter',()=>{const f=fixture();for(const o of f.data.observations)o.host.memoryPressure.metrics.some.totalMicros=Number.MAX_SAFE_INTEGER;f.data.ignored='9007199254740993 1.0000000000000001 \\" escaped';const r=evaluate(f.raw(),f.roleById);assert.equal(r.extendedObservations[0].memoryPressure.some.totalMicros,Number.MAX_SAFE_INTEGER);assert(!JSON.stringify(r).includes('ignored'))})
+test('malformed JSON, unsupported schemas or claimed producer acceptance refuse',()=>{const f=fixture();assert.throws(()=>evaluate('{bad',f.roleById));for(const mutate of [d=>{d.schemaVersion=1},d=>{d.schemaVersion=4},d=>{d.serviceChanges=1},d=>{d.readOnlyDockerAndProc=false},d=>{d.summary.acceptancePassed=true},d=>{d.observations=[]}]){const x=fixture();mutate(x.data);assert.throws(()=>evaluate(x.raw(),x.roleById))}})
+test('full IDs, complete stable container set, OOM/running/process/image/caps stay mandatory',()=>{for(const mutate of [d=>{d.observations[1].containers.pop()},d=>{d.observations[1].containers.push(d.observations[1].containers[0])},d=>{d.observations[1].containers[0].pid++},d=>{d.observations[1].containers[0].runningAfter=false},d=>{d.observations[1].containers[0].oomKilledAfter=true},d=>{d.observations[1].containers[0].configuredLimitBytes++},d=>{d.observations[1].containers[0].configuredMemorySwapBytes++},d=>{d.observations[1].host.MemTotalBytes++},d=>{d.observations[1].containers[0].startedAt=123}]){const f=fixture();mutate(f.data);assert.throws(()=>evaluate(f.raw(),f.roleById))}})
+test('role labels remain exact own DATA descriptors, never an inherited/accessor authority',()=>{for(const kind of ['getter','inherited','missing','foreign']){const f=fixture(),key=f.data.observations[0].containers[0].id;if(kind==='getter')Object.defineProperty(f.roleById,key,{enumerable:true,get(){assert.fail('Getter executed')}});if(kind==='inherited'){const x=Object.create({[key]:'backend'});for(const [id,role]of Object.entries(f.roleById))if(id!==key)x[id]=role;f.roleById=x}if(kind==='missing')delete f.roleById[key];if(kind==='foreign')f.roleById['f'.repeat(64)]='other';assert.throws(()=>evaluate(f.raw(),f.roleById))}})
+test('legacy arithmetic export keeps soft metadata and no-runtime semantics',()=>{const f=fixture(),input={hostMemTotalBytes:2069721088,osReserveBytes:512*MiB,observedContainerIds:Object.keys(f.roleById),containers:f.data.observations[0].containers.map(c=>({id:c.id,role:f.roleById[c.id],configuredLimitBytes:c.configuredLimitBytes}))};assert.equal(legacy(input).budgetFits,true);assert.equal(legacy(input).changesAuthorized,false)})
+import {readFileSync} from 'node:fs'
+test('actual base/candidate Python producers interoperate through synthetic raw wire files',()=>{for(const version of [2,3]){const raw=readFileSync(new URL('./schema'+version+'.main.synthetic.json',import.meta.url),'utf8');const r=evaluate(raw,{['a'.repeat(64)]:'backend'});assert.equal(r.measurementSchemaVersion,version);assert.equal(r.extendedMetricsComplete,version===3);assert.equal(r.budgetFits,false);assert.equal(r.wholeInstallation2GbAccepted,false);if(version===3){assert.equal(r.extendedObservations[0].containers[0].configuredMemorySwapBytes,1024);assert.equal(r.extendedObservations[0].memoryPressure.some.totalMicros,123456)}}})
diff --git a/backend/scripts/acceptance/installation-memory-observation.test.mjs b/backend/scripts/acceptance/installation-memory-observation.test.mjs
new file mode 100644
index 00000000..32685ba4
--- /dev/null
+++ b/backend/scripts/acceptance/installation-memory-observation.test.mjs
@@ -0,0 +1,31 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { evaluateObservedInstallationBudget as evaluate } from './installation-memory-budget.mjs'
+const MiB=1024*1024
+function fixture() {
+ const containers=['backend','postgres','frontend','portal'].map((role,index)=>({id:String(index+1).repeat(64),role,running:true,imageId:'sha256:'+'a'.repeat(64),startedAt:'2026-10-28T12:00:00Z',memoryLimitBytes:0,reportedLimitBytes:2*1024*MiB}))
+ const roleById=Object.fromEntries(containers.map(row=>[row.id,row.role]))
+ return {inventory:{readOnly:true,containerSetStable:true,environmentRead:false,serviceChanges:false,newFixtureStarted:false,hostMemTotalBytes:2021212*1024,containers},roleById}
+}
+test('observed zero configured caps stay unbounded despite positive Docker reported host limits',()=>{
+ const f=fixture(), result=evaluate(f.inventory,f.roleById)
+ assert.equal(result.budgetFits,false);assert(result.reasons.includes('UNBOUNDED_CONTAINER'));assert.equal(result.configuredContainerBytes,0)
+ assert.equal(result.wholeInstallation2GbAccepted,false);assert.equal(result.roleLabelsAuthenticated,false);assert.equal(result.inventoryFreshnessProven,false)
+})
+test('complete explicit configured caps can fit arithmetic without becoming runtime acceptance',()=>{
+ const f=fixture();[512,384,160,192].forEach((limit,index)=>{f.inventory.containers[index].memoryLimitBytes=limit*MiB})
+ const result=evaluate(f.inventory,f.roleById);assert(result.budgetFits);assert.equal(result.plannedBytes,1760*MiB);assert.equal(result.changesAuthorized,false)
+})
+test('uncertain snapshots, started fixtures and missing limit/identity fields refuse',()=>{
+ for(const mutate of [f=>{f.inventory.containerSetStable=false},f=>{f.inventory.serviceChanges=true},f=>{f.inventory.newFixtureStarted=true},f=>{delete f.inventory.containers[0].memoryLimitBytes},f=>{f.inventory.containers[0].running=false},f=>{f.inventory.containers[0].imageId='unknown'},f=>{f.inventory.containers[0].startedAt='invalid'}]){const f=fixture();mutate(f);assert.throws(()=>evaluate(f.inventory,f.roleById))}
+})
+test('missing, foreign, inherited and accessor role labels cannot silently classify a service',()=>{
+ for(const mode of ['missing','foreign','inherited','accessor']){
+ const f=fixture(),key=f.inventory.containers[0].id
+ if(mode==='missing')delete f.roleById[key]
+ if(mode==='foreign')f.roleById['f'.repeat(64)]='other'
+ if(mode==='inherited'){const labels=Object.create({[key]:'backend'});for(const [id,role]of Object.entries(f.roleById))if(id!==key)labels[id]=role;f.roleById=labels}
+ if(mode==='accessor')Object.defineProperty(f.roleById,key,{enumerable:true,get(){assert.fail('Role getter must not execute')}})
+ assert.throws(()=>evaluate(f.inventory,f.roleById))
+ }
+})
diff --git a/backend/scripts/acceptance/mcp-routing-forward-observer.mjs b/backend/scripts/acceptance/mcp-routing-forward-observer.mjs
new file mode 100644
index 00000000..e5fe5b5b
--- /dev/null
+++ b/backend/scripts/acceptance/mcp-routing-forward-observer.mjs
@@ -0,0 +1,58 @@
+import assert from 'node:assert/strict'
+import { setTimeout as delay } from 'node:timers/promises'
+import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
+import { resumeMcpSteps } from './mcp-step-journal.mjs'
+
+const [phase, port, planId, connectionId] = process.argv.slice(2)
+assert(process.send && process.env.MCP_FIXTURE_TOKEN && ['dispatch', 'resume'].includes(phase))
+const uuid = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i
+assert.match(planId, uuid)
+assert.match(connectionId, uuid)
+const client = new Client({ name: 'owned-routing-observer', version: '1.0.0' })
+async function call(name, args) {
+ const reply = await client.callTool({ name, arguments: args })
+ assert(!reply.isError, 'MCP fixture call failed: ' + name)
+ return reply.structuredContent?.result ?? JSON.parse(reply.content[0].text)
+}
+
+try {
+ await client.connect(new StreamableHTTPClientTransport(new URL(`http://127.0.0.1:${port}/mcp`), {
+ requestInit: { headers: { Authorization: 'Bearer ' + process.env.MCP_FIXTURE_TOKEN } },
+ }))
+ let operationId
+ const result = await resumeMcpSteps({ journal: 'routing-forward.jsonl', fixture: `routing-scoped-forward:${connectionId}:${planId}`, steps: [{
+ id: 'forward-apply', kind: 'apply',
+ async run({ idempotencyKey, accept }) {
+ assert.equal(phase, 'dispatch', 'A resumed observer cannot send apply')
+ const receipt = await call('mm_change_apply', { planId, idempotencyKey })
+ assert.deepEqual([receipt.plan_id, receipt.connection_id], [planId, connectionId])
+ accept(receipt.id)
+ // The supervisor terminates this process after the journal fsync.
+ process.send(receipt.id)
+ await new Promise(resolve => process.once('disconnect', resolve))
+ throw new Error('Observer was disconnected by its supervisor')
+ },
+ async reconcile({ accepted }) {
+ assert.equal(phase, 'resume')
+ assert.ok(accepted)
+ const deadline = Date.now() + 60_000
+ while (Date.now() < deadline) {
+ const receipt = await call('mm_operation_get', { operationId: accepted })
+ assert.deepEqual([receipt.id, receipt.plan_id, receipt.connection_id], [accepted, planId, connectionId])
+ if (!['pending', 'running'].includes(receipt.state)) {
+ assert.deepEqual([receipt.state, receipt.verification], ['applied', 'passed'])
+ operationId = accepted
+ return { state: 'verified', evidence: accepted }
+ }
+ await delay(400)
+ }
+ return { state: 'unknown' }
+ },
+ }] })
+ assert.deepEqual(result, { status: 'passed' })
+ assert.ok(operationId)
+ await new Promise((resolve, reject) => process.send(operationId, error => error ? reject(error) : resolve()))
+} finally {
+ await client.close()
+ if (process.connected) process.disconnect()
+}
diff --git a/backend/scripts/acceptance/mcp-server-poll-steps.mjs b/backend/scripts/acceptance/mcp-server-poll-steps.mjs
new file mode 100644
index 00000000..d8503207
--- /dev/null
+++ b/backend/scripts/acceptance/mcp-server-poll-steps.mjs
@@ -0,0 +1,84 @@
+import assert from 'node:assert/strict'
+import { resumeMcpSteps } from './mcp-step-journal.mjs'
+
+const uuid = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i
+
+function isProtocolStorageBusy(error) {
+ const text = error?.data?.text
+ if (error?.name !== 'SdkHttpError' || error.status !== 503 ||
+ typeof text !== 'string' || Buffer.byteLength(text) > 1024) return false
+ try {
+ const body = JSON.parse(text)
+ return body?.code === 'PROTOCOL_STORAGE_BUSY'
+ } catch {
+ return false
+ }
+}
+
+/** The caller supplies an already registered synthetic test server and owner review. */
+export function resumeServerPoll({ journal, fixture, serverId, connectionId, call, findPlan, findAcceptedOperation, assertApproved }) {
+ assert(Number.isSafeInteger(serverId) && serverId > 0)
+ assert.match(connectionId, uuid)
+ const find = async args => {
+ const planId = await findPlan?.({ ...args, connectionId, serverId })
+ return planId ? { state: 'verified', evidence: planId } : { state: 'unknown' }
+ }
+ return resumeMcpSteps({ journal, fixture: `${fixture}:server-${serverId}:connection-${connectionId}`, steps: [
+ { id: 'mm_server_poll_plan', kind: 'plan', reconcile: find, async run({ accept }) {
+ const result = await call('mm_server_poll_plan', { serverId })
+ accept(result.planId)
+ return result.planId
+ } },
+ { id: 'manager.plan-approved', kind: 'read', async run({ evidence }) {
+ const planId = evidence.get('mm_server_poll_plan')
+ await assertApproved(planId)
+ return planId
+ } },
+ { id: 'mm_change_apply', kind: 'apply',
+ async reconcile(args) {
+ const id = args.accepted ?? await findAcceptedOperation?.({
+ ...args, connectionId, planId: args.evidence.get('mm_server_poll_plan'),
+ })
+ return id ? { state: 'verified', evidence: id } : { state: 'unknown' }
+ },
+ async run({ evidence, idempotencyKey, accept }) {
+ const planId = evidence.get('mm_server_poll_plan')
+ const result = await call('mm_change_apply', { planId, idempotencyKey })
+ accept(result.id)
+ return result.id
+ } },
+ { id: 'mm_operation_get', kind: 'read', async run({ evidence }) {
+ const operationId = evidence.get('mm_change_apply')
+ let result
+ try {
+ result = await call('mm_operation_get', { operationId })
+ } catch (error) {
+ if (!isProtocolStorageBusy(error)) throw error
+ throw Object.assign(new Error('MCP протокольное хранилище занято', { cause: error }), {
+ code: 'PROTOCOL_STORAGE_BUSY',
+ })
+ }
+ assert.equal(result.id, operationId)
+ assert.equal(result.plan_id, evidence.get('mm_server_poll_plan'))
+ assert.equal(result.connection_id, connectionId)
+ if (result.state !== 'applied' || result.verification !== 'passed') {
+ const code = ['pending', 'running'].includes(result.state) ? 'POLL_PENDING' : 'POLL_UNVERIFIED'
+ throw Object.assign(new Error('Poll terminal result is unverified'), { code })
+ }
+ assert.equal(result.steps.length, 1)
+ assert.equal(result.steps[0].state, 'verified')
+ const receipt = result.steps[0].result
+ assert.equal(receipt.operationId, operationId)
+ assert.match(receipt.receiptId, uuid)
+ assert.equal(receipt.nativeReads, 4)
+ assert.equal(receipt.complete, true)
+ assert.equal(receipt.maintenanceComplete, true)
+ assert.equal(receipt.configurationVerified, true)
+ assert.equal(receipt.automaticReplay, false)
+ assert(Number.isSafeInteger(receipt.completedPublications) && receipt.completedPublications >= 2)
+ assert.equal(receipt.confirmedPublications, receipt.completedPublications)
+ assert.equal(receipt.snapshot.serverId, serverId)
+ return operationId
+ } },
+ ] })
+}
diff --git a/backend/scripts/acceptance/mcp-step-journal.mjs b/backend/scripts/acceptance/mcp-step-journal.mjs
new file mode 100644
index 00000000..810ce148
--- /dev/null
+++ b/backend/scripts/acceptance/mcp-step-journal.mjs
@@ -0,0 +1,119 @@
+import assert from 'node:assert/strict'
+import { createHash } from 'node:crypto'
+import { closeSync, constants, fstatSync, fsyncSync, openSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'
+import { isDeepStrictEqual } from 'node:util'
+
+const key = /^[a-z0-9][a-z0-9_.:-]{0,127}$/i
+const evidenceId = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i
+const errorCode = /^[A-Z][A-Z0-9_]{0,63}$/
+const validEvidence = (receipt, kind) => receipt === null ? kind === 'read' : typeof receipt === 'string' && evidenceId.test(receipt)
+
+/** A test journal only. The caller owns the fixture and all reconciliation reads. */
+export async function resumeMcpSteps({ journal, fixture, steps }) {
+ assert(key.test(fixture))
+ const scope = steps.map(({ id, kind }) => ({ id, kind }))
+ assert(scope.length && new Set(scope.map(step => step.id)).size === scope.length)
+ assert(scope.every(({ id, kind }) => key.test(id) && ['read', 'plan', 'apply'].includes(kind)))
+
+ // One process owns a journal at a time. A leftover lock requires operator reconciliation.
+ const lock = openSync(journal + '.lock', 'wx', 0o600)
+ let records
+ try {
+ let fd
+ try {
+ fd = openSync(journal, constants.O_RDWR | constants.O_APPEND | constants.O_CREAT | (constants.O_NOFOLLOW ?? 0), 0o600)
+ assert(fstatSync(fd).isFile(), 'Test journal must be a regular file')
+ const raw = readFileSync(fd, 'utf8')
+ assert(!raw || raw.endsWith('\n'), 'Truncated test receipt')
+ records = raw.trimEnd().split('\n').filter(Boolean).map(line => JSON.parse(line))
+ const header = { phase: 'fixture', fixture, steps: scope }
+ const append = entry => {
+ writeFileSync(fd, JSON.stringify(entry) + '\n', 'utf8')
+ fsyncSync(fd)
+ records.push(entry)
+ }
+ if (!records.length) append(header)
+ assert(isDeepStrictEqual(records[0], header), 'Test fixture or ordered step list changed')
+ const state = new Map()
+ let cursor = 0
+ for (const entry of records.slice(1)) {
+ const previous = state.get(entry.id)
+ assert(scope[cursor]?.id === entry.id, 'Unexpected test receipt order')
+ if (entry.phase === 'started') {
+ assert(!previous || previous.phase === 'retryable', 'Unexpected resumed dispatch')
+ assert(entry.attempt === (previous?.attempt ?? 0) + 1, 'Unexpected test attempt')
+ } else {
+ assert(['started', 'accepted', 'failed'].includes(previous?.phase) && entry.attempt === previous.attempt, 'Unbound test receipt')
+ assert(['passed', 'retryable', 'accepted', 'failed'].includes(entry.phase), 'Unknown test receipt')
+ if (entry.phase === 'accepted') {
+ assert(previous.phase === 'started' && scope[cursor].kind !== 'read' &&
+ validEvidence(entry.evidence, scope[cursor].kind), 'Invalid MCP acceptance receipt')
+ }
+ if (entry.phase === 'failed') {
+ assert(previous.phase !== 'failed' && typeof entry.code === 'string' && errorCode.test(entry.code), 'Invalid failure receipt')
+ assert(entry.accepted === (previous.phase === 'accepted' ? previous.evidence : null), 'MCP acceptance receipt changed')
+ }
+ if (entry.phase === 'passed') {
+ assert(validEvidence(entry.evidence, scope[cursor].kind), 'Invalid stored MCP receipt ID')
+ const accepted = previous.phase === 'accepted' ? previous.evidence : previous.accepted
+ assert(!accepted || accepted === entry.evidence, 'MCP acceptance receipt changed')
+ cursor++
+ }
+ if (entry.phase === 'retryable') {
+ assert(entry.accepted === null && (previous.phase === 'started' ||
+ previous.phase === 'failed' && previous.accepted === null), 'Cannot retry an accepted MCP step')
+ }
+ }
+ state.set(entry.id, entry)
+ }
+ const evidence = new Map([...state].filter(([, entry]) => entry.phase === 'passed').map(([id, entry]) => [id, entry.evidence]))
+ const attemptKey = (step, attempt) => 'acceptance-' + createHash('sha256')
+ .update(JSON.stringify([fixture, step.id, step.kind, attempt])).digest('hex')
+ const record = (step, attempt, phase, details = {}) => append({ id: step.id, attempt, phase, ...details })
+ const complete = (step, attempt, receipt) => {
+ assert(validEvidence(receipt, step.kind), 'Invalid MCP receipt ID')
+ record(step, attempt, 'passed', { evidence: receipt })
+ evidence.set(step.id, receipt)
+ }
+ for (const step of steps.slice(cursor)) {
+ const previous = state.get(step.id)
+ let attempt = previous?.attempt ?? 0
+ if (previous && ['started', 'accepted', 'failed'].includes(previous.phase)) {
+ const accepted = previous.phase === 'accepted' ? previous.evidence : previous.accepted ?? null
+ const result = step.kind === 'read' ? { state: 'no-effect' } :
+ await step.reconcile?.({ attempt, accepted, idempotencyKey: attemptKey(step, attempt), evidence: new Map(evidence) })
+ if (result?.state === 'verified') {
+ assert(!accepted || accepted === result.evidence, 'Reconciled a different MCP receipt')
+ complete(step, attempt, result.evidence)
+ continue
+ }
+ if (accepted || result?.state !== 'no-effect') return { status: 'reconcile', step: step.id }
+ record(step, attempt, 'retryable', { accepted })
+ }
+ attempt++
+ record(step, attempt, 'started')
+ let receipt
+ let accepted = null
+ try {
+ receipt = await step.run({ attempt, idempotencyKey: attemptKey(step, attempt), evidence: new Map(evidence), accept(id) {
+ assert(accepted === null && step.kind !== 'read' && validEvidence(id, step.kind), 'Invalid MCP acceptance receipt')
+ record(step, attempt, 'accepted', { evidence: id })
+ accepted = id
+ } })
+ } catch (error) {
+ const code = typeof error?.code === 'string' && errorCode.test(error.code) ? error.code : 'TEST_STEP_FAILED'
+ record(step, attempt, 'failed', { code, accepted })
+ return { status: 'failed', step: step.id }
+ }
+ assert(!accepted || accepted === receipt, 'Verified a different MCP receipt')
+ complete(step, attempt, receipt)
+ }
+ return { status: 'passed' }
+ } finally {
+ if (fd !== undefined) closeSync(fd)
+ }
+ } finally {
+ closeSync(lock)
+ unlinkSync(journal + '.lock')
+ }
+}
diff --git a/backend/scripts/acceptance/mcp-step-journal.test.mjs b/backend/scripts/acceptance/mcp-step-journal.test.mjs
new file mode 100644
index 00000000..749c0ec9
--- /dev/null
+++ b/backend/scripts/acceptance/mcp-step-journal.test.mjs
@@ -0,0 +1,176 @@
+import assert from 'node:assert/strict'
+import { appendFileSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import test from 'node:test'
+import { resumeMcpSteps } from './mcp-step-journal.mjs'
+import { resumeServerPoll } from './mcp-server-poll-steps.mjs'
+
+const uuid = 'ec4c6a09-3c3b-4a37-a370-c8821321807c'
+const connectionId = 'd0d96834-948b-4cea-81d8-d8f9dc5e1429'
+const operationId = 'c2cc9f5d-6d62-43b5-a6d2-ba7bedbd4fc1'
+const pollReceipt = { operationId, receiptId: uuid, nativeReads: 4, complete: true,
+ maintenanceComplete: true, configurationVerified: true, automaticReplay: false,
+ confirmedPublications: 22, completedPublications: 22, snapshot: { serverId: 3, status: 'online' } }
+function options(t, steps) {
+ const dir = mkdtempSync(join(tmpdir(), 'mm-mcp-step-test-'))
+ t.after(() => rmSync(dir, { recursive: true }))
+ return { journal: join(dir, 'history.jsonl'), fixture: 'owned-test', steps }
+}
+
+test('resumes the failed read and preserves successful reads and failed attempts', async t => {
+ const calls = []
+ const config = options(t, [
+ { id: 'first', kind: 'read', run: async () => { calls.push('first'); return null } },
+ { id: 'second', kind: 'read', run: async ({ attempt }) => {
+ calls.push('second:' + attempt)
+ if (attempt === 1) throw Error('test failure')
+ return null
+ } },
+ ])
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'failed', step: 'second' })
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'passed' })
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'passed' })
+ assert.deepEqual(calls, ['first', 'second:1', 'second:2'])
+ assert.deepEqual(readFileSync(config.journal, 'utf8').trim().split('\n').map(line => JSON.parse(line).phase),
+ ['fixture', 'started', 'passed', 'started', 'failed', 'retryable', 'started', 'passed'])
+})
+
+test('unknown apply awaits reconciliation and a verified receipt advances without resending', async t => {
+ let sends = 0
+ let verified = false
+ let sentKey
+ const config = options(t, [
+ { id: 'plan', kind: 'plan', run: async () => uuid },
+ { id: 'apply', kind: 'apply', run: async ({ evidence, accept, idempotencyKey }) => {
+ assert.equal(evidence.get('plan'), uuid)
+ sentKey = idempotencyKey
+ sends++
+ accept(uuid)
+ throw Error('lost reply')
+ }, reconcile: async ({ accepted, idempotencyKey }) => {
+ assert.equal(accepted, uuid)
+ assert.equal(idempotencyKey, sentKey)
+ return verified ? { state: 'verified', evidence: uuid } : { state: 'no-effect' }
+ } },
+ { id: 'next', kind: 'read', run: async ({ evidence }) => { assert.equal(evidence.get('apply'), uuid); return null } },
+ ])
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'failed', step: 'apply' })
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'reconcile', step: 'apply' })
+ verified = true
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'passed' })
+ assert.equal(sends, 1)
+})
+
+test('cannot resume a different fixture or an altered ordered step list', async t => {
+ const config = options(t, [{ id: 'read', kind: 'read', run: async () => null }])
+ await resumeMcpSteps(config)
+ await assert.rejects(resumeMcpSteps({ ...config, fixture: 'other' }), /fixture or ordered step/)
+ await assert.rejects(resumeMcpSteps({ ...config, steps: [{ ...config.steps[0], id: 'other' }] }), /fixture or ordered step/)
+})
+
+test('refuses a stored retry marker after an accepted apply', async t => {
+ const config = options(t, [{ id: 'apply', kind: 'apply', async run({ accept }) {
+ accept(uuid)
+ throw new Error('lost reply')
+ } }])
+ await resumeMcpSteps(config)
+ appendFileSync(config.journal, JSON.stringify({ id: 'apply', attempt: 1, phase: 'retryable', accepted: null }) + '\n')
+ await assert.rejects(resumeMcpSteps(config), /Cannot retry an accepted MCP step/)
+})
+
+test('the poll scenario resumes owner review and then reads the same accepted operation', async t => {
+ const { journal, fixture } = options(t, [])
+ const calls = []
+ let approved = false
+ let running = true
+ let storageBusy = true
+ const config = { journal, fixture, serverId: 3, connectionId, assertApproved: async id => {
+ assert.equal(id, uuid)
+ if (!approved) throw Error('approval not visible')
+ }, async call(tool, args) {
+ calls.push(tool)
+ if (tool === 'mm_server_poll_plan') { assert.deepEqual(args, { serverId: 3 }); return { planId: uuid } }
+ if (tool === 'mm_change_apply') {
+ assert.equal(args.planId, uuid)
+ assert.match(args.idempotencyKey, /^acceptance-[0-9a-f]{64}$/)
+ return { id: operationId }
+ }
+ assert.deepEqual(args, { operationId })
+ if (storageBusy) throw Object.assign(new Error('MCP storage busy'), {
+ name: 'SdkHttpError', status: 503, data: { text: '{"code":"PROTOCOL_STORAGE_BUSY"}' },
+ })
+ return { id: operationId, plan_id: uuid, connection_id: connectionId,
+ ...(running ? { state: 'running' } : { state: 'applied', verification: 'passed',
+ steps: [{ state: 'verified', result: pollReceipt }] }) }
+ } }
+ assert.equal((await resumeServerPoll(config)).step, 'manager.plan-approved')
+ approved = true
+ assert.equal((await resumeServerPoll(config)).step, 'mm_operation_get')
+ storageBusy = false
+ assert.equal((await resumeServerPoll(config)).step, 'mm_operation_get')
+ running = false
+ assert.deepEqual(await resumeServerPoll(config), { status: 'passed' })
+ await assert.rejects(resumeServerPoll({ ...config, connectionId: uuid }), /fixture or ordered step/)
+ assert.deepEqual(calls, ['mm_server_poll_plan', 'mm_change_apply', 'mm_operation_get', 'mm_operation_get', 'mm_operation_get'])
+ const failures = readFileSync(journal, 'utf8').trim().split('\n').map(line => JSON.parse(line))
+ .filter(entry => entry.id === 'mm_operation_get' && entry.phase === 'failed')
+ assert.deepEqual(failures.map(entry => entry.code), ['PROTOCOL_STORAGE_BUSY', 'POLL_PENDING'])
+})
+
+test('recovers a lost poll apply response by the exact connection, plan and idempotency key', async t => {
+ const { journal, fixture } = options(t, [])
+ let key, sends = 0, wrongBinding = true
+ const config = { journal, fixture, serverId: 3, connectionId, assertApproved: async () => {},
+ async findAcceptedOperation(binding) {
+ assert.equal(binding.connectionId, connectionId)
+ assert.equal(binding.planId, uuid)
+ assert.equal(binding.idempotencyKey, key)
+ return operationId
+ },
+ async call(tool, args) {
+ if (tool === 'mm_server_poll_plan') return { planId: uuid }
+ if (tool === 'mm_change_apply') {
+ sends++
+ key = args.idempotencyKey
+ throw Error('apply response lost')
+ }
+ return { id: operationId, plan_id: uuid, connection_id: wrongBinding ? uuid : connectionId,
+ state: 'applied', verification: 'passed', steps: [{ state: 'verified', result: pollReceipt }] }
+ },
+ }
+ assert.equal((await resumeServerPoll(config)).step, 'mm_change_apply')
+ assert.equal((await resumeServerPoll(config)).step, 'mm_operation_get')
+ wrongBinding = false
+ assert.deepEqual(await resumeServerPoll(config), { status: 'passed' })
+ assert.equal(sends, 1)
+})
+
+test('rejects incomplete or misbound terminal poll receipts before recording success', async t => {
+ const { journal, fixture } = options(t, [])
+ const calls = []
+ const receipts = [
+ { ...pollReceipt, operationId: uuid },
+ { ...pollReceipt, receiptId: undefined },
+ { ...pollReceipt, confirmedPublications: 21 },
+ { ...pollReceipt, confirmedPublications: 0, completedPublications: 0 },
+ { ...pollReceipt, maintenanceComplete: false },
+ { ...pollReceipt, snapshot: { serverId: 4, status: 'online' } },
+ pollReceipt,
+ ]
+ const config = { journal, fixture, serverId: 3, connectionId, assertApproved: async () => {},
+ async call(tool, args) {
+ calls.push(tool)
+ if (tool === 'mm_server_poll_plan') return { planId: uuid }
+ if (tool === 'mm_change_apply') return { id: operationId }
+ assert.deepEqual(args, { operationId })
+ return { id: operationId, plan_id: uuid, connection_id: connectionId, state: 'applied', verification: 'passed',
+ steps: [{ state: 'verified', result: receipts.shift() }] }
+ },
+ }
+ for (let i = 0; i < 6; i++) {
+ assert.deepEqual(await resumeServerPoll(config), { status: 'failed', step: 'mm_operation_get' })
+ }
+ assert.deepEqual(await resumeServerPoll(config), { status: 'passed' })
+ assert.deepEqual(calls, ['mm_server_poll_plan', 'mm_change_apply', ...Array(7).fill('mm_operation_get')])
+})
diff --git a/backend/scripts/acceptance/measure-memory-extended.test.py b/backend/scripts/acceptance/measure-memory-extended.test.py
new file mode 100644
index 00000000..159bd71b
--- /dev/null
+++ b/backend/scripts/acceptance/measure-memory-extended.test.py
@@ -0,0 +1,193 @@
+"""Synthetic-only: no Docker/socket, real /proc/cgroup reads, process enumeration or main()."""
+import copy
+import importlib.util
+from pathlib import Path
+from types import SimpleNamespace
+import unittest
+from unittest.mock import patch
+
+AREA = Path(__file__).parent
+spec = importlib.util.spec_from_file_location('memory_measurement_extended', AREA / 'measure-memory.py')
+m = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(m)
+
+MEMINFO = 'MemTotal: 2048 kB\nMemAvailable: 1024 kB\nSwapTotal: 4096 kB\nSwapFree: 3072 kB\n'
+VMSTAT = 'pswpin 20\npswpout 30\noom_kill 0\n'
+PSI = 'some avg10=0.00 avg60=1.25 avg300=100.00 total=123456\nfull avg10=0.00 avg60=0.01 avg300=1.00 total=0\n'
+ID = 'a' * 64
+CG = '/sys/fs/cgroup/system.slice/docker-' + ID + '.scope'
+
+class Synthetic(unittest.TestCase):
+ def setUp(self):
+ self.reads = []
+ self.gets = []
+ self.before = {'Id': ID, 'Image': 'sha256:' + 'b' * 64, 'RestartCount': 0,
+ 'State': {'StartedAt': '2026-11-02T00:00:00Z', 'Pid': 123, 'Running': True, 'OOMKilled': False},
+ 'HostConfig': {'Memory': 512, 'MemorySwap': 1024}, 'Config': {'Env': ['SECRET=never-retain']}}
+ self.stats = {'id': ID, 'memory_stats': {'usage': 100, 'limit': 2048, 'stats': {'inactive_file': 30}}}
+ self.files = {'/proc/meminfo': MEMINFO, '/proc/vmstat': VMSTAT, '/proc/pressure/memory': PSI,
+ '/proc/self/mountinfo': '1 0 0:1 / /sys/fs/cgroup rw - cgroup2 cgroup rw\n',
+ '/proc/123/cgroup': '0::/system.slice/docker-' + ID + '.scope\n',
+ '/proc/123/stat': '123 (owned fixture) S ' + ' '.join(['0'] * 18 + ['987'] + ['0'] * 8),
+ CG + '/memory.current': '100\n', CG + '/memory.peak': '200\n',
+ CG + '/memory.events': 'low 0\nhigh 0\nmax 0\noom 0\noom_kill 0\n',
+ CG + '/memory.swap.current': '0\n', CG + '/memory.swap.peak': '0\n',
+ CG + '/memory.swap.events': 'high 0\nmax 0\nfail 0\n',
+ CG + '/memory.max': '512\n', CG + '/memory.swap.max': '512\n',
+ CG + '/cpu.stat': 'usage_usec 50\nuser_usec 30\nsystem_usec 20\nnr_periods 10\nnr_throttled 2\nthrottled_usec 1234\nnr_bursts 0\n'}
+ def deny(*_args, **_kwargs):
+ raise AssertionError('Real external/OS I/O is forbidden by synthetic test')
+ # Module-local OS proxy avoids changing unittest/Python's filesystem operations.
+ fake_os = SimpleNamespace(**vars(m.os))
+ fake_os.path = SimpleNamespace(**vars(m.os.path))
+ fake_os.sep = '/' # synthetic Linux path contract, not this Windows host
+ fake_os.open = deny
+ fake_os.stat = deny
+ fake_os.path.realpath = deny
+ self.enterContext(patch.object(m, 'os', fake_os))
+ self.enterContext(patch.object(m, 'read_bounded', side_effect=deny))
+ self.enterContext(patch.object(m, 'docker_get', side_effect=deny))
+ self.enterContext(patch.object(m.socket, 'socket', side_effect=deny))
+
+ def read(self, name, expected_device=None, deadline=None):
+ self.reads.append(name)
+ if name not in self.files:
+ raise FileNotFoundError('synthetic missing')
+ value = self.files[name]
+ if isinstance(value, BaseException):
+ raise value
+ return value
+
+ def observe(self, after=None, realpath=None, statter=None):
+ after = copy.deepcopy(self.before) if after is None else after
+ def get(name, deadline=None):
+ self.gets.append(name)
+ if self.gets == ['/containers/' + ID + '/json']:
+ return copy.deepcopy(self.before)
+ if self.gets == ['/containers/' + ID + '/json', '/containers/' + ID + '/stats?stream=false&one-shot=true']:
+ return copy.deepcopy(self.stats)
+ if self.gets == ['/containers/' + ID + '/json', '/containers/' + ID + '/stats?stream=false&one-shot=true', '/containers/' + ID + '/json']:
+ return copy.deepcopy(after)
+ raise AssertionError('Unexpected Docker path or extra request')
+ def statter_default(name):
+ allowed = {'/sys/fs/cgroup': (8, 1), CG: (8, 2), '/proc/123/root': (8, 3)}
+ if name not in allowed:
+ raise AssertionError('Unexpected stat path')
+ dev, ino = allowed[name]
+ return SimpleNamespace(st_dev=dev, st_ino=ino)
+ with patch.object(m, 'read_bounded', side_effect=self.read), patch.object(m, 'docker_get', side_effect=get), \
+ patch.object(m.os.path, 'realpath', side_effect=realpath or (lambda p: p)), \
+ patch.object(m.os, 'stat', side_effect=statter or statter_default):
+ return m.collect_container(ID)
+
+ def test_limits_max_zero_finite_are_not_missing_or_host_ram(self):
+ for value, expected in [('max\n', 'max'), ('max', 'max'), ('0\n', 0), ('512\n', 512), (str(2**64-1), 2**64-1)]:
+ self.assertEqual(m.parse_limit(value), expected)
+ for bad in ('MAX', '-1', ' 0', '00', '1.0', str(2**64), 'max\n\n'):
+ with self.assertRaises(ValueError): m.parse_limit(bad)
+
+ def test_cpu_throttling_units_required_fields_and_output_whitelist(self):
+ parsed = m.parse_cpu_throttling(self.files[CG + '/cpu.stat'])
+ self.assertEqual(parsed, {'nr_periods':10,'nr_throttled':2,'throttled_usec':1234})
+ for bad in ('nr_periods 1\nnr_throttled 0\n', 'nr_periods 1\nnr_periods 2\nnr_throttled 0\nthrottled_usec 0\n', 'nr_periods -1\nnr_throttled 0\nthrottled_usec 0\n'):
+ with self.assertRaises(ValueError): m.parse_cpu_throttling(bad)
+
+ def test_pressure_fixed_groups_percent_and_microseconds(self):
+ parsed = m.parse_memory_pressure(PSI)
+ self.assertEqual(parsed['some'], {'avg10Percent':'0.00','avg60Percent':'1.25','avg300Percent':'100.00','totalMicros':123456})
+ self.assertEqual(parsed['full']['totalMicros'], 0)
+ for bad in (PSI.replace('100.00','100.01'), PSI.replace('1.25','nan'), PSI.replace('total=0','total=-1'), PSI.splitlines()[0], PSI.replace('full','some'), PSI+'extra\n', PSI.replace('total=0','total='+str(2**64))):
+ with self.assertRaises(ValueError): m.parse_memory_pressure(bad)
+
+ def test_docker_memoryswap_raw_minus1_zero_finite_and_missing_differ(self):
+ for raw in (-1,0,512,2**63-1):
+ item = copy.deepcopy(self.before); item['HostConfig']['MemorySwap'] = raw
+ self.assertEqual(m.configured_memory_swap(item), raw)
+ for bad in (None,False,True,'0',-2,2**63):
+ item = copy.deepcopy(self.before); item['HostConfig']['MemorySwap'] = bad
+ self.assertIsNone(m.configured_memory_swap(item))
+ for host in ({},None,[]):
+ self.assertIsNone(m.configured_memory_swap({'HostConfig':host}))
+
+ def test_real_collection_paths_are_only_fixed_host_and_retained_cgroup(self):
+ row = self.observe()
+ self.assertTrue(row['identityStableDuringSample'])
+ self.assertTrue(row['resourceLimitsStableDuringSample'])
+ self.assertEqual(row['configuredMemorySwapBytes'], 1024)
+ self.assertEqual(row['cgroupV2']['status'], 'available')
+ self.assertEqual(row['cgroupV2']['metrics']['memory.max'], 512)
+ self.assertEqual(row['cgroupV2']['metrics']['cpu.stat']['throttled_usec'], 1234)
+ self.assertTrue(set(self.reads).issubset(set(self.files)))
+ self.assertNotIn('SECRET', str(row)); self.assertNotIn('Env', str(row))
+ self.assertEqual(len(self.gets), 3)
+
+ def test_unlimited_limits_do_not_become_numeric_zero(self):
+ self.files[CG+'/memory.max']='max\n'; self.files[CG+'/memory.swap.max']='max\n'
+ row=self.observe();self.assertEqual(row['cgroupV2']['metrics']['memory.max'],'max');self.assertEqual(row['cgroupV2']['metrics']['memory.swap.max'],'max')
+
+ def test_each_new_cgroup_source_missing_or_malformed_is_unknown(self):
+ for name in ('memory.max','memory.swap.max','cpu.stat'):
+ for value in (None,'not-a-counter\n'):
+ with self.subTest(name=name,value=value):
+ self.setUp_fixture_only()
+ if value is None: self.files.pop(CG+'/'+name)
+ else: self.files[CG+'/'+name]=value
+ row=self.observe();self.assertEqual(row['cgroupV2']['status'],'partial');self.assertIsNone(row['cgroupV2']['metrics'][name]);self.assertIn(name,row['cgroupV2']['unavailable'])
+ def setUp_fixture_only(self):
+ # Recreate dictionary, not guards/patches; no real I/O.
+ self.files.update({CG+'/memory.max':'512\n',CG+'/memory.swap.max':'512\n',CG+'/cpu.stat':'nr_periods 10\nnr_throttled 2\nthrottled_usec 1234\n'});self.gets=[]
+
+ def test_missing_or_changed_swap_configuration_cannot_authenticate_limits(self):
+ after=copy.deepcopy(self.before);after['HostConfig']['MemorySwap']=2048
+ row=self.observe(after);self.assertFalse(row['resourceLimitsStableDuringSample']);self.assertEqual(row['cgroupV2']['status'],'partial');self.assertIsNone(row['cgroupV2']['metrics']['memory.swap.max'])
+ self.gets=[];self.before['HostConfig'].pop('MemorySwap');after=copy.deepcopy(self.before)
+ row=self.observe(after);self.assertIsNone(row['configuredMemorySwapBytes']);self.assertEqual(row['configuredMemorySwapStatus'],'unavailable');self.assertIsNone(row['resourceLimitsStableDuringSample']);self.assertEqual(row['cgroupV2']['status'],'partial')
+
+ def test_memory_limit_change_cannot_reuse_stable_container_identity_as_limit_proof(self):
+ after=copy.deepcopy(self.before);after['HostConfig']['Memory']=1024
+ row=self.observe(after)
+ self.assertTrue(row['identityStableDuringSample'])
+ self.assertFalse(row['resourceLimitsStableDuringSample'])
+ for key in ('memory.max','memory.swap.max'):
+ self.assertIsNone(row['cgroupV2']['metrics'][key])
+ self.assertEqual(row['cgroupV2']['unavailable'][key],'container-resource-limits-changed-or-unavailable')
+
+ def test_legacy_projection_fields_keep_cache_limit_and_rss_distinctions(self):
+ item=copy.deepcopy(self.before);item['HostConfig'].pop('MemorySwap');item['HostConfig']['Memory']=0
+ row=m.project_container(item,self.stats,ID)
+ self.assertEqual(row['usageIncludingCacheBytes'],100)
+ self.assertEqual(row['usageMinusInactiveFileBytes'],70)
+ self.assertEqual(row['configuredLimitBytes'],0)
+ self.assertEqual(row['reportedLimitBytes'],2048)
+ self.assertEqual(row['configuredMemorySwapStatus'],'unavailable')
+ self.assertIsNone(row['configuredMemorySwapBytes'])
+
+ def test_identity_drift_symlink_and_pid_generation_still_refuse(self):
+ after=copy.deepcopy(self.before);after['State']['Pid']=456
+ row=self.observe(after);self.assertFalse(row['identityStableDuringSample']);self.assertIsNone(row['resourceLimitsStableDuringSample']);self.assertEqual(row['cgroupV2']['status'],'unavailable')
+ self.gets=[];row=self.observe(realpath=lambda p:'/other' if p.endswith('memory.swap.max') else p);self.assertEqual(row['cgroupV2']['status'],'partial');self.assertIsNone(row['cgroupV2']['metrics']['memory.swap.max'])
+ self.gets=[]
+ with patch.object(m,'process_generation',side_effect=[(1,8,3),(2,8,3)]):
+ self.assertEqual(self.observe()['cgroupV2']['status'],'unavailable')
+
+ def test_host_collection_whitelists_one_psi_file_and_missing_is_explicit(self):
+ with patch.object(m,'read_bounded',side_effect=self.read):
+ host=m.collect_host();self.assertEqual(host['memoryPressure']['status'],'available');self.assertEqual(host['MemTotalBytes'],2048*1024)
+ self.assertEqual(self.reads,['/proc/meminfo','/proc/vmstat','/proc/pressure/memory'])
+ self.files.pop('/proc/pressure/memory');host=m.collect_host();self.assertEqual(host['memoryPressure']['status'],'unavailable');self.assertIsNone(host['memoryPressure']['metrics'])
+
+ def test_deadline_never_becomes_partial_or_success(self):
+ self.files[CG+'/cpu.stat']=m.ObservationDeadlineExceeded('fixture-deadline')
+ with self.assertRaises(m.ObservationDeadlineExceeded): self.observe()
+ with patch.object(m,'read_bounded',side_effect=[MEMINFO,VMSTAT,m.ObservationDeadlineExceeded('fixture-deadline')]):
+ with self.assertRaises(m.ObservationDeadlineExceeded): m.collect_host()
+
+ def test_summary_exposes_unknown_and_never_authorizes_runtime(self):
+ row=self.observe()
+ with patch.object(m,'read_bounded',side_effect=self.read):host=m.collect_host()
+ sample={'elapsedMs':0,'host':host,'containers':[row]}
+ out=m.summarize([sample]);self.assertTrue(out['allResourceLimitsStableDuringSample']);self.assertTrue(out['allHostMemoryPressureAvailable']);self.assertFalse(out['acceptancePassed'])
+ row['resourceLimitsStableDuringSample']=None;host['memoryPressure']['status']='unavailable'
+ out=m.summarize([sample]);self.assertFalse(out['allResourceLimitsStableDuringSample']);self.assertFalse(out['allHostMemoryPressureAvailable']);self.assertFalse(out['acceptancePassed'])
+
+if __name__=='__main__': unittest.main()
diff --git a/backend/scripts/acceptance/measure-memory.py b/backend/scripts/acceptance/measure-memory.py
new file mode 100644
index 00000000..cbec1bd3
--- /dev/null
+++ b/backend/scripts/acceptance/measure-memory.py
@@ -0,0 +1,459 @@
+"""Bounded Linux/Docker memory observation; GET only, no service changes.
+
+Run alongside the named acceptance workload. Output is evidence, never an
+automatic declaration that a 2 GB deployment has passed its load acceptance.
+Requires Python 3 and read access to /proc and the local Docker socket.
+"""
+import argparse
+import http.client
+import json
+import os
+import re
+import socket
+import stat
+import threading
+import time
+
+MAX_RESPONSE = 4 * 1024 * 1024
+MAX_FILE_BYTES = 65536
+MAX_FILE_LINES = 256
+CGROUP_ROOT = '/sys/fs/cgroup'
+CGROUP_FILES = ('memory.current', 'memory.peak', 'memory.events',
+ 'memory.swap.current', 'memory.swap.peak', 'memory.swap.events',
+ 'memory.max', 'memory.swap.max', 'cpu.stat')
+
+
+class CgroupUnavailable(ValueError):
+ """Fixed reason codes only; never include private paths or raw content."""
+
+
+class ObservationDeadlineExceeded(RuntimeError):
+ pass
+
+
+def check_deadline(deadline):
+ if deadline is not None and time.monotonic() >= deadline:
+ raise ObservationDeadlineExceeded('Observation time bound exceeded')
+
+
+def read_bounded(path, expected_device=None, deadline=None):
+ # Fixed production paths only; no CLI path or executable is accepted.
+ check_deadline(deadline)
+ descriptor = os.open(path, os.O_RDONLY | getattr(os, 'O_NOFOLLOW', 0) | getattr(os, 'O_NONBLOCK', 0))
+ with os.fdopen(descriptor, 'rb') as handle:
+ identity = os.fstat(handle.fileno())
+ if not stat.S_ISREG(identity.st_mode) or (expected_device is not None and identity.st_dev != expected_device):
+ raise ValueError('Non-regular observation')
+ raw = handle.read(MAX_FILE_BYTES + 1)
+ check_deadline(deadline)
+ if len(raw) > MAX_FILE_BYTES:
+ raise ValueError('Observation file too large')
+ text = raw.decode('ascii')
+ if len(text.splitlines()) > MAX_FILE_LINES:
+ raise ValueError('Too many observation lines')
+ return text
+
+
+def parse_counter(text):
+ if not re.fullmatch(r'(?:0|[1-9][0-9]{0,19})\n?', text):
+ raise ValueError('Invalid counter')
+ value = int(text)
+ if value > 2 ** 64 - 1:
+ raise ValueError('Counter overflow')
+ return value
+
+
+def parse_events(text, required):
+ lines = text.splitlines()
+ if not 1 <= len(lines) <= 32:
+ raise ValueError('Invalid event count')
+ result = {}
+ for line in lines:
+ fields = line.split(' ')
+ if len(fields) != 2 or not re.fullmatch(r'[a-z_]{1,64}', fields[0]) or fields[0] in result:
+ raise ValueError('Invalid event')
+ result[fields[0]] = parse_counter(fields[1])
+ if not set(required).issubset(result):
+ raise ValueError('Incomplete events')
+ return result
+
+
+
+def parse_limit(text):
+ # Preserve unlimited vs zero vs unavailable; never substitute host RAM.
+ return 'max' if text in ('max', 'max\n') else parse_counter(text)
+
+
+def parse_cpu_throttling(text):
+ required = ('nr_periods', 'nr_throttled', 'throttled_usec')
+ parsed = parse_events(text, required)
+ # Kernel extensions are validated but do not expand the output whitelist.
+ return {key: parsed[key] for key in required}
+
+
+def parse_memory_pressure(text):
+ rows = text.splitlines()
+ if len(rows) != 2:
+ raise ValueError('Incomplete memory pressure')
+ result = {}
+ for line in rows:
+ match = re.fullmatch(r'(some|full) avg10=([0-9]{1,3}\.[0-9]{2}) avg60=([0-9]{1,3}\.[0-9]{2}) avg300=([0-9]{1,3}\.[0-9]{2}) total=((?:0|[1-9][0-9]{0,19}))', line)
+ if not match or match[1] in result:
+ raise ValueError('Invalid memory pressure')
+ for value in match.group(2, 3, 4):
+ whole, fraction = value.split('.')
+ if int(whole) * 100 + int(fraction) > 10000:
+ raise ValueError('Invalid memory pressure percentage')
+ result[match[1]] = {'avg10Percent': match[2], 'avg60Percent': match[3],
+ 'avg300Percent': match[4], 'totalMicros': parse_counter(match[5])}
+ if set(result) != {'some', 'full'}:
+ raise ValueError('Incomplete memory pressure')
+ return result
+
+
+def configured_memory_swap(inspect):
+ # Docker MemorySwap is TOTAL memory+swap; 0 means daemon default, -1 unlimited.
+ host = inspect.get('HostConfig')
+ value = host.get('MemorySwap') if isinstance(host, dict) else None
+ if type(value) is not int or not -1 <= value <= 2 ** 63 - 1:
+ return None
+ return value
+
+
+def resource_limits_stable(before, after):
+ values = []
+ for item in (before, after):
+ host = item.get('HostConfig')
+ memory = host.get('Memory') if isinstance(host, dict) else None
+ swap = configured_memory_swap(item)
+ if type(memory) is not int or not 0 <= memory <= 2 ** 63 - 1 or swap is None:
+ return None
+ values.append((memory, swap))
+ return values[0] == values[1]
+
+
+def collect_host(deadline=None):
+ memory = parse_host(read_bounded('/proc/meminfo', deadline=deadline),
+ read_bounded('/proc/vmstat', deadline=deadline))
+ try:
+ pressure = parse_memory_pressure(read_bounded('/proc/pressure/memory', deadline=deadline))
+ memory['memoryPressure'] = {'status': 'available', 'metrics': pressure, 'reason': None}
+ except (OSError, ValueError, UnicodeError):
+ memory['memoryPressure'] = {'status': 'unavailable', 'metrics': None,
+ 'reason': 'missing-unreadable-or-malformed'}
+ return memory
+
+
+def container_identity(inspect, identifier):
+ state = inspect['State']
+ if (inspect.get('Id') != identifier or not re.fullmatch(r'[a-f0-9]{64}', identifier)
+ or type(state.get('Pid')) is not int or not 0 < state['Pid'] <= 2 ** 31 - 1
+ or state.get('Running') is not True or type(state.get('OOMKilled')) is not bool
+ or not isinstance(state.get('StartedAt'), str) or not state['StartedAt']
+ or type(inspect.get('RestartCount')) is not int or inspect['RestartCount'] < 0
+ or not isinstance(inspect.get('Image'), str) or not inspect['Image']):
+ raise ValueError('Unavailable container identity')
+ return (identifier, inspect['Image'], state['StartedAt'], state['Pid'], inspect['RestartCount'], state['OOMKilled'])
+
+
+def cgroup_location(pid, identifier, deadline=None):
+ check_deadline(deadline)
+ mounts = read_bounded('/proc/self/mountinfo', deadline=deadline).splitlines()
+ # Namespace-relative/subtree mounts are deliberately unsupported: their
+ # root cannot authenticate a host container's complete cgroup membership.
+ matches = [line.split(' - ', 1) for line in mounts if ' - ' in line]
+ if not any(left.split()[3:5] == ['/', CGROUP_ROOT] and right.split()[0] == 'cgroup2'
+ for left, right in matches):
+ raise CgroupUnavailable('unsupported-or-unavailable-host-cgroup2-mount')
+ membership = read_bounded('/proc/' + str(pid) + '/cgroup', deadline=deadline)
+ lines = membership.splitlines()
+ if len(lines) != 1 or not lines[0].startswith('0::/'):
+ raise CgroupUnavailable('unsupported-v1-hybrid-or-malformed-membership')
+ relative = lines[0][3:]
+ parts = relative.split('/')[1:]
+ if (not parts or any(not p or p in ('.', '..') or not re.fullmatch(r'[A-Za-z0-9_.:-]{1,128}', p) for p in parts)
+ or parts[-1] not in (identifier, 'docker-' + identifier + '.scope')):
+ raise ValueError('Unbound cgroup membership')
+ root = os.path.realpath(CGROUP_ROOT)
+ path = os.path.realpath(CGROUP_ROOT + relative)
+ if root != CGROUP_ROOT or path != root + relative or not path.startswith(root + os.sep):
+ raise ValueError('Cgroup path escaped')
+ return path, membership
+
+
+def process_generation(pid, deadline=None):
+ check_deadline(deadline)
+ raw = read_bounded('/proc/' + str(pid) + '/stat', deadline=deadline)
+ prefix, suffix = raw.rsplit(')', 1)
+ if prefix.split(' ', 1)[0] != str(pid) or ' (' not in prefix:
+ raise ValueError('Invalid process identity')
+ fields = suffix.split()
+ if len(fields) < 20:
+ raise ValueError('Incomplete process identity')
+ start = parse_counter(fields[19])
+ root = os.stat('/proc/' + str(pid) + '/root')
+ return start, root.st_dev, root.st_ino
+
+
+def unavailable_cgroup(reason):
+ return {'version': 2, 'status': 'unavailable', 'reason': reason,
+ 'metrics': {name: None for name in CGROUP_FILES}, 'unavailable': {name: reason for name in CGROUP_FILES}}
+
+
+def collect_container(identifier, deadline=None):
+ check_deadline(deadline)
+ before = docker_get('/containers/' + identifier + '/json', deadline)
+ stats = docker_get('/containers/' + identifier + '/stats?stream=false&one-shot=true', deadline)
+ check_deadline(deadline)
+ result = project_container(before, stats, identifier)
+ cgroup = unavailable_cgroup('identity-unavailable')
+ try:
+ identity = container_identity(before, identifier)
+ pid = identity[3]
+ generation = process_generation(pid, deadline)
+ path, membership = cgroup_location(pid, identifier, deadline)
+ directory = os.stat(path)
+ if directory.st_dev != os.stat(CGROUP_ROOT).st_dev:
+ raise ValueError('Cgroup filesystem changed')
+ metrics, missing = {}, {}
+ for name in CGROUP_FILES:
+ check_deadline(deadline)
+ try:
+ candidate = path + '/' + name
+ if os.path.realpath(candidate) != candidate:
+ raise ValueError('Symlinked metric')
+ raw = read_bounded(candidate, directory.st_dev, deadline=deadline)
+ check_deadline(deadline)
+ if name == 'memory.events':
+ metrics[name] = parse_events(raw, ('low', 'high', 'max', 'oom', 'oom_kill'))
+ elif name == 'memory.swap.events':
+ metrics[name] = parse_events(raw, ('high', 'max', 'fail'))
+ elif name in ('memory.max', 'memory.swap.max'):
+ metrics[name] = parse_limit(raw)
+ elif name == 'cpu.stat':
+ metrics[name] = parse_cpu_throttling(raw)
+ else:
+ metrics[name] = parse_counter(raw)
+ except (OSError, ValueError, UnicodeError):
+ metrics[name] = None
+ missing[name] = 'missing-unreadable-or-malformed'
+ check_deadline(deadline)
+ after_path, after_membership = cgroup_location(pid, identifier, deadline)
+ after_directory = os.stat(path)
+ if (process_generation(pid, deadline) != generation or after_path != path or after_membership != membership
+ or (directory.st_dev, directory.st_ino) != (after_directory.st_dev, after_directory.st_ino)):
+ cgroup = unavailable_cgroup('process-or-cgroup-changed')
+ else:
+ cgroup = {'version': 2, 'status': 'partial' if missing else 'available',
+ 'reason': 'some-metrics-unavailable' if missing else None,
+ 'metrics': metrics, 'unavailable': missing,
+ 'peakScope': 'cgroup lifetime or since external reset; not an isolated workload peak',
+ 'provenance': 'fixed host cgroup2 mount + exact Docker ID membership + process/root generation'}
+ except CgroupUnavailable as error:
+ cgroup = unavailable_cgroup(str(error))
+ except (OSError, ValueError, KeyError, IndexError, UnicodeError):
+ cgroup = unavailable_cgroup('identity-process-or-cgroup-unavailable-or-unsupported')
+ # Even failed cgroup observations are bracketed by a fresh Docker inspect.
+ check_deadline(deadline)
+ after = docker_get('/containers/' + identifier + '/json', deadline)
+ check_deadline(deadline)
+ try:
+ stable = container_identity(before, identifier) == container_identity(after, identifier)
+ except (ValueError, KeyError, TypeError):
+ stable = False
+ if not stable:
+ cgroup = unavailable_cgroup('container-identity-changed-or-unavailable')
+ limits_stable = resource_limits_stable(before, after) if stable else None
+ if stable and limits_stable is not True and cgroup['status'] != 'unavailable':
+ for key in ('memory.max', 'memory.swap.max'):
+ cgroup['metrics'][key] = None
+ cgroup['unavailable'][key] = 'container-resource-limits-changed-or-unavailable'
+ cgroup['status'] = 'partial'
+ cgroup['reason'] = 'some-metrics-unavailable'
+ result.update({'resourceLimitsStableDuringSample': limits_stable,
+ 'pid': before['State'].get('Pid'), 'identityStableDuringSample': stable,
+ 'runningAfter': after.get('State', {}).get('Running'),
+ 'oomKilledAfter': after.get('State', {}).get('OOMKilled'), 'cgroupV2': cgroup})
+ return result
+
+
+def docker_get(path, deadline=None):
+ deadline = time.monotonic() + 5 if deadline is None else deadline
+ check_deadline(deadline)
+ connection = http.client.HTTPConnection('localhost', timeout=min(5, deadline - time.monotonic()))
+ owned_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ connection.sock = owned_socket
+ # A socket timeout alone permits an endless body that drips bytes. The
+ # watchdog owns precisely this request's socket, including after HTTP's
+ # Connection:close detaches it from HTTPConnection into HTTPResponse.
+ def expire():
+ try:
+ owned_socket.shutdown(socket.SHUT_RDWR)
+ except OSError:
+ pass
+ finally:
+ owned_socket.close()
+ watchdog = threading.Timer(max(0, deadline - time.monotonic()), expire)
+ watchdog.daemon = True
+ watchdog_started = False
+ response = None
+ try:
+ watchdog.start()
+ watchdog_started = True
+ owned_socket.settimeout(min(5, max(0.001, deadline - time.monotonic())))
+ check_deadline(deadline)
+ owned_socket.connect('/var/run/docker.sock')
+ check_deadline(deadline)
+ connection.request('GET', '/v1.45' + path, headers={'Connection': 'close'})
+ response = connection.getresponse()
+ raw = response.read(MAX_RESPONSE + 1)
+ check_deadline(deadline)
+ if response.status != 200 or len(raw) > MAX_RESPONSE:
+ raise ValueError('Docker observation unavailable')
+ result = json.loads(raw)
+ check_deadline(deadline)
+ return result
+ except Exception:
+ check_deadline(deadline)
+ raise
+ finally:
+ watchdog.cancel()
+ if watchdog_started:
+ watchdog.join()
+ try:
+ if response is not None:
+ response.close()
+ finally:
+ try:
+ connection.close()
+ finally:
+ owned_socket.close()
+
+
+def nonnegative(value):
+ if type(value) is not int or value < 0:
+ raise ValueError('Invalid numeric observation')
+ return value
+
+
+def parse_host(meminfo, vmstat):
+ memory = {}
+ for line in meminfo.splitlines():
+ fields = line.split()
+ if fields and fields[0] in ('MemTotal:', 'MemAvailable:', 'SwapTotal:', 'SwapFree:'):
+ if len(fields) != 3 or fields[2] != 'kB':
+ raise ValueError('Invalid meminfo units')
+ memory[fields[0][:-1] + 'Bytes'] = nonnegative(int(fields[1])) * 1024
+ if len(memory) != 4 or memory['MemAvailableBytes'] > memory['MemTotalBytes'] or memory['SwapFreeBytes'] > memory['SwapTotalBytes']:
+ raise ValueError('Incomplete host memory observation')
+ for line in vmstat.splitlines():
+ fields = line.split()
+ if fields and fields[0] in ('pswpin', 'pswpout', 'oom_kill'):
+ memory[fields[0]] = nonnegative(int(fields[1]))
+ return memory
+
+
+def project_container(inspect, stats, identifier):
+ if inspect.get('Id') != identifier or stats.get('id') != identifier:
+ raise ValueError('Pinned container changed')
+ state = inspect['State']
+ memory = stats['memory_stats']
+ usage = nonnegative(memory['usage'])
+ inactive = memory.get('stats', {}).get('inactive_file')
+ if inactive is not None:
+ inactive = nonnegative(inactive)
+ if inactive > usage:
+ raise ValueError('Invalid cache observation')
+ return {
+ 'id': identifier, 'imageId': inspect['Image'],
+ 'startedAt': state['StartedAt'], 'running': state['Running'] is True,
+ 'oomKilled': state.get('OOMKilled'), 'restartCount': inspect.get('RestartCount'),
+ 'usageIncludingCacheBytes': usage, 'inactiveFileBytes': inactive,
+ 'usageMinusInactiveFileBytes': usage - inactive if inactive is not None else None,
+ 'configuredLimitBytes': nonnegative(inspect['HostConfig']['Memory']),
+ 'configuredMemorySwapBytes': configured_memory_swap(inspect),
+ 'configuredMemorySwapStatus': 'available' if configured_memory_swap(inspect) is not None else 'unavailable',
+ 'reportedLimitBytes': nonnegative(memory['limit']),
+ 'swapUsageBytes': memory.get('swap_usage'),
+ }
+
+
+def summarize(samples):
+ if not samples:
+ raise ValueError('No observations')
+ baseline = {c['id']: (c['imageId'], c['startedAt'], c['restartCount'], c.get('pid'), c.get('oomKilled')) for c in samples[0]['containers']}
+ stable = all({c['id']: (c['imageId'], c['startedAt'], c['restartCount'], c.get('pid'), c.get('oomKilled')) for c in sample['containers']} == baseline
+ and all(c.get('identityStableDuringSample', True) for c in sample['containers']) for sample in samples)
+ counters = {}
+ for field in ('pswpin', 'pswpout', 'oom_kill'):
+ first = samples[0]['host'].get(field)
+ last = samples[-1]['host'].get(field)
+ counters[field + 'Delta'] = last - first if first is not None and last is not None and last >= first else None
+ return {
+ 'samples': len(samples), 'elapsedMs': samples[-1]['elapsedMs'],
+ 'hostMemTotalBytes': samples[0]['host']['MemTotalBytes'],
+ 'minHostAvailableBytes': min(s['host']['MemAvailableBytes'] for s in samples),
+ 'maxObservedContainerUsageIncludingCacheBytes': max(sum(c['usageIncludingCacheBytes'] for c in s['containers']) for s in samples),
+ 'containerIdentityAndStartStable': stable,
+ 'allObservedRunning': all(c['running'] is True and c.get('runningAfter') is True
+ and c.get('identityStableDuringSample') is True for s in samples for c in s['containers']),
+ 'anyObservedOomKilled': any(c['oomKilled'] is True or c.get('oomKilledAfter') is True for s in samples for c in s['containers']),
+ 'allCgroupV2MetricsAvailable': all(s['containers'] and all(c.get('cgroupV2', {}).get('status') == 'available' for c in s['containers']) for s in samples),
+ **counters,
+ 'allResourceLimitsStableDuringSample': all(c.get('resourceLimitsStableDuringSample') is True for s in samples for c in s['containers']) and all(s['containers'] for s in samples),
+ 'allHostMemoryPressureAvailable': all(s['host'].get('memoryPressure', {}).get('status') == 'available' for s in samples),
+ 'acceptancePassed': False,
+ 'scope': 'sampled evidence only; correlate with workload, limits, errors and latency; unsampled peaks are unknown',
+ }
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--daemon-id', required=True)
+ parser.add_argument('--container', action='append', required=True)
+ parser.add_argument('--samples', type=int, default=30)
+ parser.add_argument('--interval', type=float, default=1)
+ parser.add_argument('--output', required=True)
+ args = parser.parse_args()
+ if os.name != 'posix' or not hasattr(socket, 'AF_UNIX'):
+ parser.error('Run on the Linux Docker host')
+ if not re.fullmatch(r'[A-Za-z0-9-]{8,128}', args.daemon_id) or not 1 <= len(args.container) <= 16 or len(set(args.container)) != len(args.container) or any(not re.fullmatch(r'[a-f0-9]{64}', c) for c in args.container):
+ parser.error('Pin exact daemon ID and 1..16 distinct full container IDs')
+ if not 1 <= args.samples <= 300 or not 0.2 <= args.interval <= 10 or args.samples * args.interval > 300:
+ parser.error('Observation bound: 300 samples / 300 seconds')
+ started = time.monotonic()
+ deadline = started + 360
+ if docker_get('/info', deadline).get('ID') != args.daemon_id:
+ raise ValueError('Pinned Docker daemon changed')
+ samples = []
+ for index in range(args.samples):
+ check_deadline(deadline)
+ host = collect_host(deadline)
+ containers = []
+ for identifier in args.container:
+ check_deadline(deadline)
+ containers.append(collect_container(identifier, deadline))
+ check_deadline(deadline)
+ samples.append({'elapsedMs': round((time.monotonic() - started) * 1000), 'host': host, 'containers': containers})
+ if index + 1 < args.samples:
+ time.sleep(min(args.interval, max(0, deadline - time.monotonic())))
+ check_deadline(deadline)
+ if docker_get('/info', deadline).get('ID') != args.daemon_id:
+ raise ValueError('Pinned Docker daemon changed')
+ result = {'schemaVersion': 3, 'readOnlyDockerAndProc': True, 'serviceChanges': 0, 'summary': summarize(samples), 'observations': samples}
+ encoded = json.dumps(result, indent=2) + '\n'
+ check_deadline(deadline)
+ # Refuse to replace an existing evidence file. Never dump Docker env/logs.
+ with open(args.output, 'x', encoding='utf-8') as handle:
+ check_deadline(deadline)
+ handle.write(encoded)
+ check_deadline(deadline)
+ print(json.dumps(result['summary']))
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except Exception as error:
+ print(json.dumps({'status': 'observation-refused', 'errorClass': type(error).__name__, 'serviceChanges': 0}))
+ raise SystemExit(1)
diff --git a/backend/scripts/acceptance/measure-memory.test.py b/backend/scripts/acceptance/measure-memory.test.py
new file mode 100644
index 00000000..a9ac7dc4
--- /dev/null
+++ b/backend/scripts/acceptance/measure-memory.test.py
@@ -0,0 +1,384 @@
+import copy
+import importlib.util
+from pathlib import Path
+import os
+import tempfile
+import io
+import sys
+import threading
+import time
+import unittest
+from unittest.mock import patch
+
+spec = importlib.util.spec_from_file_location('memory_measure', Path(__file__).with_name('measure-memory.py'))
+measure = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(measure)
+
+
+class MemoryEvidenceTests(unittest.TestCase):
+ def test_host_units_and_missing_fields(self):
+ raw = 'MemTotal: 2048 kB\nMemAvailable: 1024 kB\nSwapTotal: 4096 kB\nSwapFree: 3072 kB\n'
+ parsed = measure.parse_host(raw, 'pswpin 20\npswpout 30\noom_kill 1\n')
+ self.assertEqual(parsed['MemTotalBytes'], 2048 * 1024)
+ self.assertEqual(parsed['pswpin'], 20)
+ for invalid in (raw.replace('kB', 'MB'), raw.replace('MemAvailable: 1024 kB\n', ''), raw.replace('MemAvailable: 1024', 'MemAvailable: 4096')):
+ with self.assertRaises(ValueError):
+ measure.parse_host(invalid, '')
+
+ def test_cache_and_no_configured_limit_are_distinct(self):
+ item = {'Id': 'a' * 64, 'Image': 'sha256:fixed', 'State': {'StartedAt': 't0', 'Running': True}, 'HostConfig': {'Memory': 0}}
+ stats = {'id': 'a' * 64, 'memory_stats': {'usage': 100, 'limit': 2048, 'stats': {'inactive_file': 30}}}
+ result = measure.project_container(item, stats, 'a' * 64)
+ self.assertEqual(result['usageIncludingCacheBytes'], 100)
+ self.assertEqual(result['usageMinusInactiveFileBytes'], 70)
+ self.assertEqual(result['configuredLimitBytes'], 0)
+ with self.assertRaises(ValueError):
+ measure.project_container(item, stats, 'b' * 64)
+
+ def test_simultaneous_peak_is_not_sum_of_separate_peaks(self):
+ host = {'MemTotalBytes': 2048, 'MemAvailableBytes': 1024, 'pswpin': 3, 'pswpout': 5, 'oom_kill': 1}
+ def container(identifier, usage):
+ return {'id': identifier, 'imageId': 'i', 'startedAt': 't0', 'restartCount': 0, 'running': True, 'oomKilled': False, 'usageIncludingCacheBytes': usage}
+ samples = [{'elapsedMs': 0, 'host': host, 'containers': [container('a', 100), container('b', 20)]},
+ {'elapsedMs': 1000, 'host': {**host, 'pswpin': 4}, 'containers': [container('a', 20), container('b', 100)]}]
+ result = measure.summarize(samples)
+ self.assertEqual(result['maxObservedContainerUsageIncludingCacheBytes'], 120)
+ self.assertEqual(result['pswpinDelta'], 1)
+ self.assertTrue(result['containerIdentityAndStartStable'])
+ self.assertFalse(result['acceptancePassed'])
+ changed = copy.deepcopy(samples)
+ changed[-1]['containers'][0]['startedAt'] = 't1'
+ changed[-1]['containers'][1]['oomKilled'] = True
+ self.assertFalse(measure.summarize(changed)['containerIdentityAndStartStable'])
+ self.assertTrue(measure.summarize(changed)['anyObservedOomKilled'])
+
+ def test_counter_rollback_is_unknown(self):
+ samples = [{'elapsedMs': i, 'host': {'MemTotalBytes': 2, 'MemAvailableBytes': 1, 'pswpin': value}, 'containers': []} for i, value in enumerate([100, 2])]
+ self.assertIsNone(measure.summarize(samples)['pswpinDelta'])
+
+
+class CgroupEvidenceTests(unittest.TestCase):
+ identifier = 'a' * 64
+ path = '/sys/fs/cgroup/system.slice/docker-' + identifier + '.scope'
+
+ def setUp(self):
+ self.before = {'Id': self.identifier, 'Image': 'sha256:fixed', 'RestartCount': 0,
+ 'State': {'StartedAt': 'original-start', 'Pid': 123, 'Running': True, 'OOMKilled': False},
+ 'HostConfig': {'Memory': 512, 'MemorySwap': 1024}}
+ self.stats = {'id': self.identifier, 'memory_stats': {'usage': 100, 'limit': 512, 'stats': {'inactive_file': 30}}}
+ self.files = {
+ '/proc/self/mountinfo': '1 0 0:1 / /sys/fs/cgroup rw - cgroup2 cgroup rw\n',
+ '/proc/123/cgroup': '0::/system.slice/docker-' + self.identifier + '.scope\n',
+ '/proc/123/stat': '123 (a name with ) parentheses) S ' + ' '.join(['0'] * 18 + ['987'] + ['0'] * 8),
+ self.path + '/memory.max': '512\n', self.path + '/memory.swap.max': '512\n',
+ self.path + '/cpu.stat': 'nr_periods 10\nnr_throttled 2\nthrottled_usec 1234\n',
+ self.path + '/memory.current': '100\n', self.path + '/memory.peak': '200\n',
+ self.path + '/memory.events': 'low 0\nhigh 1\nmax 2\noom 3\noom_kill 4\n',
+ self.path + '/memory.swap.current': '5\n', self.path + '/memory.swap.peak': '6\n',
+ self.path + '/memory.swap.events': 'high 0\nmax 2\nfail 1\n',
+ }
+
+ def observe(self, after=None, reader=None, resolver=None, statter=None):
+ def read(path, _expected_device=None, deadline=None):
+ if path not in self.files:
+ raise FileNotFoundError()
+ return self.files[path]
+ queries = []
+ def get(path, deadline=None):
+ queries.append(path)
+ if '/stats?' in path:
+ return self.stats
+ return self.before if len(queries) == 1 else (after or self.before)
+ with patch.object(measure, 'docker_get', side_effect=get), \
+ patch.object(measure, 'read_bounded', side_effect=reader or read), \
+ patch.object(measure.os.path, 'realpath', side_effect=resolver or (lambda path: path)), \
+ patch.object(measure.os, 'stat', side_effect=statter or (lambda path: os.stat_result((0, 7, 8, 0, 0, 0, 0, 0, 0, 0)))), \
+ patch.object(measure.os, 'sep', '/'):
+ result = measure.collect_container(self.identifier)
+ self.assertEqual(queries, ['/containers/' + self.identifier + '/json',
+ '/containers/' + self.identifier + '/stats?stream=false&one-shot=true',
+ '/containers/' + self.identifier + '/json'])
+ return result
+
+ def test_exact_identity_metrics_and_docker_cache_are_distinct(self):
+ result = self.observe()
+ self.assertTrue(result['identityStableDuringSample'])
+ self.assertEqual(result['usageMinusInactiveFileBytes'], 70)
+ self.assertEqual(result['cgroupV2']['status'], 'available')
+ self.assertEqual(result['cgroupV2']['metrics']['memory.current'], 100)
+ self.assertEqual(result['cgroupV2']['metrics']['memory.peak'], 200)
+ self.assertEqual(result['cgroupV2']['metrics']['memory.events']['oom_kill'], 4)
+ self.assertEqual(result['cgroupV2']['metrics']['memory.swap.current'], 5)
+ self.assertEqual(result['cgroupV2']['metrics']['memory.swap.peak'], 6)
+ self.assertEqual(result['cgroupV2']['metrics']['memory.swap.events']['fail'], 1)
+
+ def test_optional_swap_peak_missing_is_unknown_not_zero(self):
+ del self.files[self.path + '/memory.swap.peak']
+ result = self.observe()['cgroupV2']
+ self.assertEqual(result['status'], 'partial')
+ self.assertIsNone(result['metrics']['memory.swap.peak'])
+ self.assertEqual(result['metrics']['memory.peak'], 200)
+ self.assertIn('memory.swap.peak', result['unavailable'])
+
+ def test_each_missing_metric_is_explicit_unknown(self):
+ for name in measure.CGROUP_FILES:
+ with self.subTest(name=name):
+ value = self.files.pop(self.path + '/' + name)
+ result = self.observe()['cgroupV2']
+ self.assertIsNone(result['metrics'][name])
+ self.assertEqual(result['status'], 'partial')
+ self.files[self.path + '/' + name] = value
+
+ def test_malformed_metrics_never_coerce_to_zero(self):
+ for value in ('-1\n', '+1\n', ' 1\n', '01\n', '1\n2\n', '18446744073709551616\n', 'max\n'):
+ with self.subTest(value=value):
+ self.files[self.path + '/memory.current'] = value
+ self.assertIsNone(self.observe()['cgroupV2']['metrics']['memory.current'])
+ for value in ('oom 1\noom 2\n', 'low 0\nhigh -1\nmax 0\noom 0\noom_kill 0\n', 'low 0\n', 'low 0\n'):
+ with self.subTest(value=value):
+ self.files[self.path + '/memory.events'] = value
+ self.assertIsNone(self.observe()['cgroupV2']['metrics']['memory.events'])
+
+ def test_docker_identity_drift_invalidates_entire_cgroup_sample(self):
+ for field, value in [('Pid', 124), ('StartedAt', 'new'), ('OOMKilled', True), ('Running', False)]:
+ after = copy.deepcopy(self.before); after['State'][field] = value
+ result = self.observe(after)
+ self.assertFalse(result['identityStableDuringSample'])
+ self.assertTrue(all(value is None for value in result['cgroupV2']['metrics'].values()))
+ for field, value in [('Id', 'b' * 64), ('RestartCount', 1), ('Image', 'sha256:new')]:
+ after = copy.deepcopy(self.before); after[field] = value
+ self.assertEqual(self.observe(after)['cgroupV2']['status'], 'unavailable')
+
+ def test_process_reuse_rootfs_swap_and_membership_move_are_unknown(self):
+ for changed in ('/proc/123/stat', '/proc/123/cgroup'):
+ count = 0
+ def read(path, _expected_device=None, deadline=None):
+ nonlocal count
+ if path == changed:
+ count += 1
+ if count == 2:
+ return self.files[path].replace('987', '988') if path.endswith('/stat') else '0::/docker/' + 'b' * 64 + '\n'
+ return self.files[path]
+ self.assertEqual(self.observe(reader=read)['cgroupV2']['status'], 'unavailable')
+ count = 0
+ def statter(path):
+ nonlocal count
+ if path == '/proc/123/root':
+ count += 1
+ return os.stat_result((0, count, 8, 0, 0, 0, 0, 0, 0, 0))
+ self.assertEqual(self.observe(statter=statter)['cgroupV2']['status'], 'unavailable')
+
+ def test_unsupported_v1_namespace_subtree_and_unbound_membership(self):
+ original = self.files['/proc/123/cgroup']
+ for value in ('2:memory:/docker/' + self.identifier + '\n', '0::/\n', '0::/docker/' + 'b' * 64 + '\n',
+ '0::/docker/' + self.identifier + '/../other\n', original.rstrip() + '/child\n', original + original):
+ self.files['/proc/123/cgroup'] = value
+ self.assertEqual(self.observe()['cgroupV2']['status'], 'unavailable')
+ self.files['/proc/123/cgroup'] = original
+ self.files['/proc/self/mountinfo'] = '1 0 0:1 /subtree /sys/fs/cgroup rw - cgroup2 cgroup rw\n'
+ self.assertEqual(self.observe()['cgroupV2']['status'], 'unavailable')
+
+ def test_symlink_outside_or_to_other_container_is_refused(self):
+ for destination in ('/etc', '/sys/fs/cgroup/docker/' + 'b' * 64):
+ self.assertEqual(self.observe(resolver=lambda path: destination if path == self.path else path)['cgroupV2']['status'], 'unavailable')
+ result = self.observe(resolver=lambda path: '/etc/passwd' if path.endswith('/memory.current') else path)
+ self.assertIsNone(result['cgroupV2']['metrics']['memory.current'])
+
+ def test_cgroup_directory_replacement_or_nested_filesystem_is_unknown(self):
+ for nested in (False, True):
+ calls = 0
+ def statter(path):
+ nonlocal calls
+ if path == self.path:
+ calls += 1
+ inode = 8 if path == self.path and calls > 1 else 7
+ device = 9 if nested and path == self.path else 8
+ return os.stat_result((0, inode, device, 0, 0, 0, 0, 0, 0, 0))
+ result = self.observe(statter=statter)['cgroupV2']
+ self.assertEqual(result['status'], 'unavailable')
+ self.assertTrue(all(value is None for value in result['metrics'].values()))
+
+ def test_pid_reuse_unreadable_process_and_after_oom_stay_unknown(self):
+ after = copy.deepcopy(self.before); after['State']['OOMKilled'] = True
+ result = self.observe(after)
+ host = {'MemTotalBytes': 2048, 'MemAvailableBytes': 1024}
+ summary = measure.summarize([{'elapsedMs': 0, 'host': host, 'containers': [result]}])
+ self.assertTrue(summary['anyObservedOomKilled'])
+ self.assertFalse(summary['containerIdentityAndStartStable'])
+ self.assertFalse(summary['allCgroupV2MetricsAvailable'])
+ self.assertFalse(summary['acceptancePassed'])
+ def read(path, _expected_device=None, deadline=None):
+ if path == '/proc/123/stat':
+ raise PermissionError()
+ return self.files[path]
+ self.assertEqual(self.observe(reader=read)['cgroupV2']['status'], 'unavailable')
+
+ def test_real_temp_files_are_bounded_and_strictly_ascii(self):
+ with tempfile.TemporaryDirectory(dir=Path(__file__).resolve().parent) as directory:
+ path = Path(directory) / 'memory.current'
+ path.write_bytes(b'123\n')
+ self.assertEqual(measure.parse_counter(measure.read_bounded(path)), 123)
+ with self.assertRaises(ValueError):
+ measure.read_bounded(path, path.stat().st_dev + 1)
+ for raw in (b'0' * (measure.MAX_FILE_BYTES + 1), b'0\n' * (measure.MAX_FILE_LINES + 1), b'\xff'):
+ path.write_bytes(raw)
+ with self.assertRaises((ValueError, UnicodeError)):
+ measure.read_bounded(path)
+
+ def test_after_stopped_or_unknown_identity_cannot_summarize_running(self):
+ for value in (False, None):
+ after = copy.deepcopy(self.before); after['State']['Running'] = value
+ result = self.observe(after)
+ self.assertIs(result['runningAfter'], value)
+ summary = measure.summarize([{'elapsedMs': 0, 'host': {'MemTotalBytes': 2048, 'MemAvailableBytes': 1024}, 'containers': [result]}])
+ self.assertFalse(summary['allObservedRunning'])
+ result = self.observe()
+ summary = measure.summarize([{'elapsedMs': 0, 'host': {'MemTotalBytes': 2048, 'MemAvailableBytes': 1024}, 'containers': [result]}])
+ self.assertTrue(summary['allObservedRunning'])
+
+ def test_event_future_counters_retained_but_duplicates_and_overflow_refuse(self):
+ self.assertEqual(measure.parse_events('high 0\nmax 1\nfail 2\nfuture 3\n', ('high', 'max', 'fail'))['future'], 3)
+ for value in ('x 1\nx 2\n', 'x 18446744073709551616\n', ''.join('x_' + str(i) + ' 0\n' for i in range(33))):
+ with self.assertRaises(ValueError):
+ measure.parse_events(value, ())
+
+
+class DeadlineEvidenceTests(unittest.TestCase):
+ def test_expired_http_never_opens_socket_or_schedules_watchdog(self):
+ with patch.object(measure.time, 'monotonic', return_value=10), \
+ patch.object(measure.socket, 'socket') as own_socket, patch.object(measure.threading, 'Timer') as timer:
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.docker_get('/info', 10)
+ own_socket.assert_not_called()
+ timer.assert_not_called()
+
+ def test_expired_container_read_never_starts_io(self):
+ with patch.object(measure.time, 'monotonic', return_value=10), patch.object(measure, 'docker_get') as get:
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.collect_container('a' * 64, 10)
+ get.assert_not_called()
+
+ def test_near_cutoff_after_stats_stops_before_proc_or_more_gets(self):
+ clock, queries = [9.9], []
+ def get(path, deadline):
+ self.assertEqual(deadline, 10)
+ queries.append(path)
+ if len(queries) == 2:
+ clock[0] = 10
+ return {}
+ with patch.object(measure.time, 'monotonic', side_effect=lambda: clock[0]), \
+ patch.object(measure, 'docker_get', side_effect=get), patch.object(measure, 'read_bounded') as read:
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.collect_container('a' * 64, 10)
+ self.assertEqual(len(queries), 2)
+ read.assert_not_called()
+
+ def test_metric_deadline_is_not_downgraded_to_partial_or_followed_by_io(self):
+ fixture = CgroupEvidenceTests(); fixture.setUp()
+ clock, reads, queries = [9.9], [], []
+ def read(path, _device=None, deadline=None):
+ self.assertEqual(deadline, 10)
+ reads.append(path)
+ if path.endswith('/memory.current'):
+ clock[0] = 10
+ return fixture.files[path]
+ def get(path, deadline):
+ queries.append(path)
+ return fixture.stats if '/stats?' in path else fixture.before
+ with patch.object(measure.time, 'monotonic', side_effect=lambda: clock[0]), \
+ patch.object(measure, 'docker_get', side_effect=get), patch.object(measure, 'read_bounded', side_effect=read), \
+ patch.object(measure.os.path, 'realpath', side_effect=lambda path: path), \
+ patch.object(measure.os, 'stat', return_value=os.stat_result((0, 7, 8, 0, 0, 0, 0, 0, 0, 0))), \
+ patch.object(measure.os, 'sep', '/'):
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.collect_container(fixture.identifier, 10)
+ self.assertEqual(reads[-1], fixture.path + '/memory.current')
+ self.assertEqual(len(queries), 2)
+
+ def test_final_daemon_check_crosses_deadline_without_writing_report(self):
+ clock, calls = [0], []
+ def get(path, deadline):
+ self.assertEqual(deadline, 360)
+ calls.append(path)
+ if len(calls) == 2:
+ clock[0] = 361
+ return {'ID': 'owned-daemon'}
+ host = 'MemTotal: 2048 kB\nMemAvailable: 1024 kB\nSwapTotal: 0 kB\nSwapFree: 0 kB\n'
+ args = ['measure-memory.py', '--daemon-id', 'owned-daemon', '--container', 'a' * 64, '--samples', '1', '--output', 'NEVER_CREATED']
+ with patch.object(sys, 'argv', args), patch.object(measure.os, 'name', 'posix'), \
+ patch.object(measure.socket, 'AF_UNIX', 1, create=True), \
+ patch.object(measure.time, 'monotonic', side_effect=lambda: clock[0]), patch.object(measure, 'docker_get', side_effect=get), \
+ patch.object(measure, 'read_bounded', side_effect=[host, '', 'some avg10=0.00 avg60=0.00 avg300=0.00 total=0\nfull avg10=0.00 avg60=0.00 avg300=0.00 total=0\n']), patch.object(measure, 'collect_container', return_value={}), \
+ patch.object(measure, 'summarize', return_value={}), patch('builtins.open') as output:
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.main()
+ output.assert_not_called()
+
+ def test_slow_body_absolute_deadline_closes_only_own_socket_and_joins(self):
+ # A real HTTPResponse/BufferedReader and real watchdog timer, with an
+ # in-memory socket transport. No AF_UNIX availability or local network
+ # permissions are needed on Windows. Inactivity timeouts never fire:
+ # the body keeps producing bytes until shutdown interrupts the read.
+ class DripBody(io.RawIOBase):
+ def __init__(self, stopped):
+ self.header = b'HTTP/1.1 200 OK\r\nContent-Length: 1000\r\nConnection: close\r\n\r\n'
+ self.stopped = stopped
+ self.body_reads = 0
+ def readable(self):
+ return True
+ def readinto(self, buffer):
+ if self.header:
+ value, self.header = self.header[:len(buffer)], self.header[len(buffer):]
+ buffer[:len(value)] = value
+ return len(value)
+ if self.stopped.wait(0.01):
+ return 0
+ self.body_reads += 1
+ buffer[0] = 32
+ return 1
+ class SocketTransport:
+ def __init__(self):
+ self.stopped = threading.Event()
+ self.body = DripBody(self.stopped)
+ self.closed = False
+ self.request = b''
+ def connect(self, path):
+ self.path = path
+ def settimeout(self, value):
+ self.timeout = value
+ def sendall(self, value):
+ self.request += value
+ def makefile(self, _mode):
+ return io.BufferedReader(self.body)
+ def shutdown(self, _how):
+ self.stopped.set()
+ def close(self):
+ self.closed = True
+ client, unrelated = SocketTransport(), SocketTransport()
+ started = time.monotonic()
+ original_timer = measure.threading.Timer
+ timers = []
+ def timer(*args, **kwargs):
+ value = original_timer(*args, **kwargs)
+ timers.append(value)
+ return value
+ with patch.object(measure.socket, 'AF_UNIX', 1, create=True), \
+ patch.object(measure.socket, 'socket', return_value=client), \
+ patch.object(measure.threading, 'Timer', side_effect=timer):
+ with self.assertRaises(measure.ObservationDeadlineExceeded):
+ measure.docker_get('/info', started + 0.12)
+ self.assertLess(time.monotonic() - started, 1.5)
+ self.assertTrue(client.closed)
+ self.assertTrue(client.stopped.is_set())
+ self.assertGreater(client.body.body_reads, 0)
+ self.assertFalse(unrelated.closed)
+ self.assertFalse(unrelated.stopped.is_set())
+ self.assertEqual(client.path, '/var/run/docker.sock')
+ self.assertIn(b'GET /v1.45/info ', client.request)
+ self.assertEqual(len(timers), 1)
+ self.assertFalse(timers[0].is_alive(), 'No deadline callback can perform late I/O after return')
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/backend/scripts/acceptance/run-installation-memory.mjs b/backend/scripts/acceptance/run-installation-memory.mjs
new file mode 100644
index 00000000..1f874dc9
--- /dev/null
+++ b/backend/scripts/acceptance/run-installation-memory.mjs
@@ -0,0 +1,63 @@
+/** Local smoke preparation only: owns a new embedded PG and one compiled child.
+ * Does not represent frontend/portal/Docker/whole-installation acceptance. */
+import assert from 'node:assert/strict'
+import fs from 'node:fs/promises'
+import { createRequire } from 'node:module'
+import { tmpdir } from 'node:os'
+import { join,resolve,dirname,basename } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { createServer } from 'node:net'
+import { randomBytes,createHash } from 'node:crypto'
+import { spawn } from 'node:child_process'
+const root=resolve(dirname(fileURLToPath(import.meta.url)),'../../..')
+assert(process.argv.length>=3&&process.argv.length<=5,'Supply a unique evidence name, optional compiled output and delayed-approval scenario')
+const delayedApproval=process.argv[4]==='delayed-approval'
+assert(process.argv[4]===undefined||delayedApproval,'Unknown isolated scenario')
+const name=process.argv[2];assert(/^[a-z0-9][a-z0-9-]{3,99}$/.test(name),'Invalid evidence name')
+const outputName=process.argv[3]??'dist-installation-memory'
+assert(/^dist-installation-memory(?:-[a-z0-9-]{3,64})?$/.test(outputName),'Invalid compiled output name')
+const prefix=resolve(root,'tmp',name), statusPath=prefix+'-status.json'
+const exclusive=await fs.open(statusPath,'wx');await exclusive.close()
+const state={scope:'local-backend-coload-only',wholeInstallation2GbAccepted:false,compiledOutputName:outputName,delayedHumanApprovalScenario:delayedApproval,status:'starting',nodeExitCode:null,sourcePinsUnchanged:false,cleanupConfirmed:false,startedAt:new Date().toISOString(),wrapperPid:process.pid}
+const save=()=>fs.writeFile(statusPath,JSON.stringify(state,null,2)+'\n');await save()
+const require=createRequire(new URL('../../package.json',import.meta.url)),EmbeddedPostgres=require('embedded-postgres').default
+const directory=await fs.mkdtemp(join(tmpdir(),'mm-mcp-test-')),server=createServer()
+await new Promise(done=>server.listen(0,'127.0.0.1',done));const port=server.address().port;await new Promise(done=>server.close(done))
+const password=randomBytes(24).toString('hex')
+const postgres=new EmbeddedPostgres({databaseDir:join(directory,'pg'),port,user:'mcp_test',password,persistent:true,createPostgresUser:false,
+ initdbFlags:['--encoding=UTF8'],postgresFlags:['-h','127.0.0.1'],onLog:()=>{},onError:()=>{}})
+const output=resolve(root,'backend',outputName),entry=resolve(output,'services/installation-co-load.owned.test.js')
+async function pins() {
+ const rows=[]
+ async function walk(dir){for(const item of await fs.readdir(dir,{withFileTypes:true})){const file=join(dir,item.name);if(item.isDirectory())await walk(file);else rows.push({path:file.slice(root.length+1).replaceAll('\\','/'),sha256:createHash('sha256').update(await fs.readFile(file)).digest('hex')})}}
+ await walk(output);return rows.sort((a,b)=>a.path.localeCompare(b.path))
+}
+const before=await pins();await fs.writeFile(prefix+'-pins.json',JSON.stringify({before},null,2)+'\n')
+let log,timer
+try {
+ await postgres.initialise();await postgres.start()
+ log=await fs.open(prefix+'.log','wx')
+ const retained=Object.fromEntries(['SystemRoot','WINDIR','TEMP','TMP','LANG','LC_ALL'].filter(key=>process.env[key]).map(key=>[key,process.env[key]]))
+ const child=spawn(process.execPath,['--max-old-space-size=192','--max-semi-space-size=16',entry],{cwd:directory,windowsHide:true,stdio:['ignore',log.fd,log.fd],env:{...retained,
+ NODE_OPTIONS:'',NODE_ENV:'test',PORT:'8000',AUTH_ISSUER:'https://auth.shnt.top',AUTH_PORTAL_URL:'http://localhost:5175',SQLITE_IMPORT_FULL_HISTORY:'false',
+ MM_FLOW_READ_RESOURCE_PROFILE:'constrained',DATABASE_URL:`postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,DATABASE_PATH:join(directory,'no-legacy.sqlite'),
+ MCP_STATE_DIR:join(directory,'state'),AUTH_REQUIRED:'true',AUTH_JWT_SECRET:randomBytes(32).toString('hex'),MCP_PUBLIC_URL:'http://localhost:8000/mcp',MMAPP_OWN_INSTALLATION_COLOAD:'true',MMAPP_OWN_COLOAD_DELAYED_APPROVAL:String(delayedApproval)}})
+ state.status='running';state.childPid=child.pid;await save()
+ timer=setTimeout(()=>{state.outerTimedOut=true;child.kill()},300000)
+ state.nodeExitCode=await new Promise((done,reject)=>{child.once('error',reject);child.once('exit',code=>done(code??1))})
+ clearTimeout(timer);await log.close();log=undefined
+ const after=await pins();state.sourcePinsUnchanged=JSON.stringify(before)===JSON.stringify(after)
+ await fs.writeFile(prefix+'-pins.json',JSON.stringify({before,after,unchanged:state.sourcePinsUnchanged},null,2)+'\n')
+ process.exitCode=state.nodeExitCode===0&&state.sourcePinsUnchanged?0:1
+}catch(error){state.failure=error instanceof Error?error.name:'UnknownError';process.exitCode=1}
+finally {
+ if(timer)clearTimeout(timer);if(log)await log.close()
+ try{
+ if(postgres.process?.exitCode===null)await postgres.stop()
+ const actual=await fs.realpath(directory),parent=await fs.realpath(tmpdir())
+ assert.equal(dirname(actual),parent);assert.match(basename(actual),/^mm-mcp-test-[A-Za-z0-9-]+$/);assert.equal((await fs.lstat(directory)).isSymbolicLink(),false)
+ await fs.rm(actual,{recursive:true,force:true,maxRetries:20,retryDelay:100});state.cleanupConfirmed=true
+ }catch{state.cleanupConfirmed=false;process.exitCode=1}
+ state.status='terminal';state.finishedAt=new Date().toISOString();await save();console.log(JSON.stringify(state))
+}
+if(state.cleanupConfirmed)process.exit(process.exitCode??1)
diff --git a/backend/scripts/acceptance/s3-ui-limited-restore.cjs b/backend/scripts/acceptance/s3-ui-limited-restore.cjs
index dc0e2919..03590b67 100644
--- a/backend/scripts/acceptance/s3-ui-limited-restore.cjs
+++ b/backend/scripts/acceptance/s3-ui-limited-restore.cjs
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-require-imports -- standalone CommonJS Playwright script */
const fs = require('fs'), assert = require('node:assert/strict'), { createHash } = require('crypto');
const { chromium, expect } = require('@playwright/test');
(async () => {
diff --git a/backend/scripts/acceptance/schema2.main.synthetic.json b/backend/scripts/acceptance/schema2.main.synthetic.json
new file mode 100644
index 00000000..69e72147
--- /dev/null
+++ b/backend/scripts/acceptance/schema2.main.synthetic.json
@@ -0,0 +1,81 @@
+{
+ "schemaVersion": 2,
+ "readOnlyDockerAndProc": true,
+ "serviceChanges": 0,
+ "summary": {
+ "samples": 1,
+ "elapsedMs": 0,
+ "hostMemTotalBytes": 2097152,
+ "minHostAvailableBytes": 1048576,
+ "maxObservedContainerUsageIncludingCacheBytes": 100,
+ "containerIdentityAndStartStable": true,
+ "allObservedRunning": true,
+ "anyObservedOomKilled": false,
+ "allCgroupV2MetricsAvailable": true,
+ "pswpinDelta": 0,
+ "pswpoutDelta": 0,
+ "oom_killDelta": 0,
+ "acceptancePassed": false,
+ "scope": "sampled evidence only; correlate with workload, limits, errors and latency; unsampled peaks are unknown"
+ },
+ "observations": [
+ {
+ "elapsedMs": 0,
+ "host": {
+ "MemTotalBytes": 2097152,
+ "MemAvailableBytes": 1048576,
+ "SwapTotalBytes": 4194304,
+ "SwapFreeBytes": 3145728,
+ "pswpin": 20,
+ "pswpout": 30,
+ "oom_kill": 0
+ },
+ "containers": [
+ {
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "imageId": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
+ "startedAt": "2026-11-02T00:00:00Z",
+ "running": true,
+ "oomKilled": false,
+ "restartCount": 0,
+ "usageIncludingCacheBytes": 100,
+ "inactiveFileBytes": 30,
+ "usageMinusInactiveFileBytes": 70,
+ "configuredLimitBytes": 512,
+ "reportedLimitBytes": 2048,
+ "swapUsageBytes": null,
+ "pid": 123,
+ "identityStableDuringSample": true,
+ "runningAfter": true,
+ "oomKilledAfter": false,
+ "cgroupV2": {
+ "version": 2,
+ "status": "available",
+ "reason": null,
+ "metrics": {
+ "memory.current": 100,
+ "memory.peak": 200,
+ "memory.events": {
+ "low": 0,
+ "high": 0,
+ "max": 0,
+ "oom": 0,
+ "oom_kill": 0
+ },
+ "memory.swap.current": 0,
+ "memory.swap.peak": 0,
+ "memory.swap.events": {
+ "high": 0,
+ "max": 0,
+ "fail": 0
+ }
+ },
+ "unavailable": {},
+ "peakScope": "cgroup lifetime or since external reset; not an isolated workload peak",
+ "provenance": "fixed host cgroup2 mount + exact Docker ID membership + process/root generation"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/backend/scripts/acceptance/schema3.main.synthetic.json b/backend/scripts/acceptance/schema3.main.synthetic.json
new file mode 100644
index 00000000..10c097c1
--- /dev/null
+++ b/backend/scripts/acceptance/schema3.main.synthetic.json
@@ -0,0 +1,111 @@
+{
+ "schemaVersion": 3,
+ "readOnlyDockerAndProc": true,
+ "serviceChanges": 0,
+ "summary": {
+ "samples": 1,
+ "elapsedMs": 0,
+ "hostMemTotalBytes": 2097152,
+ "minHostAvailableBytes": 1048576,
+ "maxObservedContainerUsageIncludingCacheBytes": 100,
+ "containerIdentityAndStartStable": true,
+ "allObservedRunning": true,
+ "anyObservedOomKilled": false,
+ "allCgroupV2MetricsAvailable": true,
+ "pswpinDelta": 0,
+ "pswpoutDelta": 0,
+ "oom_killDelta": 0,
+ "allResourceLimitsStableDuringSample": true,
+ "allHostMemoryPressureAvailable": true,
+ "acceptancePassed": false,
+ "scope": "sampled evidence only; correlate with workload, limits, errors and latency; unsampled peaks are unknown"
+ },
+ "observations": [
+ {
+ "elapsedMs": 0,
+ "host": {
+ "MemTotalBytes": 2097152,
+ "MemAvailableBytes": 1048576,
+ "SwapTotalBytes": 4194304,
+ "SwapFreeBytes": 3145728,
+ "pswpin": 20,
+ "pswpout": 30,
+ "oom_kill": 0,
+ "memoryPressure": {
+ "status": "available",
+ "metrics": {
+ "some": {
+ "avg10Percent": "0.00",
+ "avg60Percent": "1.25",
+ "avg300Percent": "100.00",
+ "totalMicros": 123456
+ },
+ "full": {
+ "avg10Percent": "0.00",
+ "avg60Percent": "0.01",
+ "avg300Percent": "1.00",
+ "totalMicros": 0
+ }
+ },
+ "reason": null
+ }
+ },
+ "containers": [
+ {
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "imageId": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
+ "startedAt": "2026-11-02T00:00:00Z",
+ "running": true,
+ "oomKilled": false,
+ "restartCount": 0,
+ "usageIncludingCacheBytes": 100,
+ "inactiveFileBytes": 30,
+ "usageMinusInactiveFileBytes": 70,
+ "configuredLimitBytes": 512,
+ "configuredMemorySwapBytes": 1024,
+ "configuredMemorySwapStatus": "available",
+ "reportedLimitBytes": 2048,
+ "swapUsageBytes": null,
+ "resourceLimitsStableDuringSample": true,
+ "pid": 123,
+ "identityStableDuringSample": true,
+ "runningAfter": true,
+ "oomKilledAfter": false,
+ "cgroupV2": {
+ "version": 2,
+ "status": "available",
+ "reason": null,
+ "metrics": {
+ "memory.current": 100,
+ "memory.peak": 200,
+ "memory.events": {
+ "low": 0,
+ "high": 0,
+ "max": 0,
+ "oom": 0,
+ "oom_kill": 0
+ },
+ "memory.swap.current": 0,
+ "memory.swap.peak": 0,
+ "memory.swap.events": {
+ "high": 0,
+ "max": 0,
+ "fail": 0
+ },
+ "memory.max": 512,
+ "memory.swap.max": 512,
+ "cpu.stat": {
+ "nr_periods": 10,
+ "nr_throttled": 2,
+ "throttled_usec": 1234
+ }
+ },
+ "unavailable": {},
+ "peakScope": "cgroup lifetime or since external reset; not an isolated workload peak",
+ "provenance": "fixed host cgroup2 mount + exact Docker ID membership + process/root generation"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/backend/scripts/build-database-operator.mjs b/backend/scripts/build-database-operator.mjs
new file mode 100644
index 00000000..688573c3
--- /dev/null
+++ b/backend/scripts/build-database-operator.mjs
@@ -0,0 +1,103 @@
+/** Build-time only. Fixed operator artifact; never invoked by server startup. */
+import assert from 'node:assert/strict'
+import {createHash} from 'node:crypto'
+import {isBuiltin} from 'node:module'
+import {readFile,writeFile,mkdir,stat,lstat,readdir} from 'node:fs/promises'
+import path from 'node:path'
+import {fileURLToPath,pathToFileURL} from 'node:url'
+import ts from 'typescript'
+
+import {OPERATOR_SOURCES} from './database-operator-sources.mjs'
+export {OPERATOR_SOURCES}
+
+const emitted=source=>source.replace(/\.mts$/,'.mjs').replace(/\.ts$/,'.js')
+const digest=value=>createHash('sha256').update(value).digest('hex')
+const packageName=specifier=>specifier.startsWith('@')?specifier.split('/').slice(0,2).join('/'):specifier.split('/')[0]
+/** The transformer changes only module specifier AST nodes, never SQL/string data. */
+export function compileOperatorModule(source,fileName){
+ const rewrite=specifier=>specifier.replace(/^(\.\.\/|\.\.\/\.\.\/)src\//,'$1dist/')
+ const result=ts.transpileModule(source,{fileName,reportDiagnostics:true,compilerOptions:{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.ESNext,verbatimModuleSyntax:true,newLine:ts.NewLineKind.LineFeed},transformers:{before:[context=>{
+ const visit=node=>{
+ if(ts.isImportDeclaration(node)&&ts.isStringLiteral(node.moduleSpecifier))return context.factory.updateImportDeclaration(node,node.modifiers,node.importClause,context.factory.createStringLiteral(rewrite(node.moduleSpecifier.text)),node.attributes)
+ if(ts.isExportDeclaration(node)&&node.moduleSpecifier&&ts.isStringLiteral(node.moduleSpecifier))return context.factory.updateExportDeclaration(node,node.modifiers,node.isTypeOnly,node.exportClause,context.factory.createStringLiteral(rewrite(node.moduleSpecifier.text)),node.attributes)
+ if(ts.isCallExpression(node)&&node.expression.kind===ts.SyntaxKind.ImportKeyword){
+ assert(node.arguments.length===1&&ts.isStringLiteral(node.arguments[0]),'Only fixed literal operator dynamic imports are supported')
+ return context.factory.updateCallExpression(node,node.expression,node.typeArguments,[context.factory.createStringLiteral(rewrite(node.arguments[0].text))])
+ }
+ return ts.visitEachChild(node,visit,context)
+ }
+ return sourceFile=>ts.visitNode(sourceFile,visit)
+ }]}})
+ const errors=result.diagnostics?.filter(item=>item.category===ts.DiagnosticCategory.Error)??[]
+ assert.equal(errors.length,0,'Operator transpilation diagnostics: '+errors.map(item=>ts.flattenDiagnosticMessageText(item.messageText,' ')).join('; '))
+ return result.outputText
+}
+export function moduleSpecifiers(source,fileName){
+ const parsed=ts.createSourceFile(fileName,source,ts.ScriptTarget.ES2022,true,ts.ScriptKind.JS),specifiers=[]
+ const visit=node=>{
+ if((ts.isImportDeclaration(node)||ts.isExportDeclaration(node))&&node.moduleSpecifier){assert(ts.isStringLiteral(node.moduleSpecifier));specifiers.push(node.moduleSpecifier.text)}
+ if(ts.isCallExpression(node)&&node.expression.kind===ts.SyntaxKind.ImportKeyword){assert(node.arguments.length===1&&ts.isStringLiteral(node.arguments[0]),'Computed runtime import refused');specifiers.push(node.arguments[0].text)}
+ ts.forEachChild(node,visit)
+ }
+ visit(parsed);return specifiers
+}
+export async function buildDatabaseOperator({backendDirectory=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..'),outputDirectory=path.join(backendDirectory,'dist-operator')}={}){
+ const backend=path.resolve(backendDirectory),output=path.resolve(outputDirectory),packageJson=JSON.parse(await readFile(path.join(backend,'package.json'),'utf8'))
+ const modules=new Map(),allowed=new Set(OPERATOR_SOURCES.map(emitted)),runtimeDependencies=new Set(),distImports=new Set()
+ const productionDependency=specifier=>{
+ if(isBuiltin(specifier))return
+ const dependency=packageName(specifier);assert(Object.hasOwn(packageJson.dependencies,dependency),'Operator runtime dependency must be production: '+dependency);runtimeDependencies.add(dependency)
+ }
+ for(const file of OPERATOR_SOURCES){
+ const raw=await readFile(path.join(backend,'scripts',file)),code=compileOperatorModule(new TextDecoder('utf-8',{fatal:true}).decode(raw),file),target=emitted(file)
+ const imports=moduleSpecifiers(code,target)
+ for(const specifier of imports){
+ assert(!/\.(?:ts|mts)$/.test(specifier)&&!/(?:^|\/)src\//.test(specifier),'Source runtime import refused')
+ if(specifier.startsWith('.')){
+ const resolved=path.posix.normalize(path.posix.join(path.posix.dirname(target),specifier))
+ if(resolved.startsWith('../dist/')){
+ const relative=resolved.slice('../dist/'.length)
+ assert(relative.endsWith('.js')&&!relative.split('/').includes('..'),'Fixed compiled backend helper required')
+ assert((await stat(path.join(backend,'dist',relative))).isFile(),'Run backend tsc before operator build')
+ distImports.add(relative)
+ }else assert(allowed.has(resolved),'Operator import outside fixed build graph: '+specifier)
+ }else productionDependency(specifier)
+ }
+ modules.set(target,{code,source:file,sourceSha256:digest(raw),sha256:digest(code),imports})
+ }
+ // Validate the referenced compiled helper closure as part of the production
+ // build, not only in tests. Keep this bounded to the small operator graph.
+ const backendDistModules=new Map()
+ async function visitDist(file){
+ assert(file.endsWith('.js')&&!/[\\:]/.test(file)&&!file.startsWith('/')&&!file.split('/').includes('..')&&!file.split('/').includes('src'),'Compiled helper escaped backend/dist')
+ if(backendDistModules.has(file))return
+ assert(backendDistModules.size<64,'Operator compiled helper graph exceeded 64 modules')
+ const raw=await readFile(path.join(backend,'dist',file)),imports=moduleSpecifiers(new TextDecoder('utf-8',{fatal:true}).decode(raw),file)
+ backendDistModules.set(file,{file,sha256:digest(raw),imports})
+ for(const specifier of imports){
+ assert(!/\.(?:ts|mts)$/.test(specifier)&&!/(?:^|\/)src\//.test(specifier),'Source runtime import refused')
+ if(specifier.startsWith('.'))await visitDist(path.posix.normalize(path.posix.join(path.posix.dirname(file),specifier)))
+ else productionDependency(specifier)
+ }
+ }
+ for(const file of distImports)await visitDist(file)
+ // Refuse stale/unlisted output rather than shipping an extra file (e.g. a key)
+ // through Docker's directory COPY. Never delete/adopt unknown build contents.
+ try{
+ assert((await lstat(output)).isDirectory(),'Ordinary operator output directory required')
+ for(const item of await readdir(output,{recursive:true,withFileTypes:true})){
+ const relative=path.relative(output,path.join(item.parentPath,item.name)).split(path.sep).join('/')
+ assert(item.isDirectory()?relative==='writer-profile':item.isFile()&&(allowed.has(relative)||relative==='build-manifest.json'),'Unexpected operator output entry: '+relative)
+ }
+ }catch(error){if(error.code!=='ENOENT')throw error}
+ // Validate the whole fixed graph before publishing any generated module.
+ await mkdir(output,{recursive:true})
+ for(const [file,module] of modules){await mkdir(path.dirname(path.join(output,file)),{recursive:true});await writeFile(path.join(output,file),module.code)}
+ const manifest={format:'application-database-operator-build-v1',compilerVersion:ts.version,entrypoints:['database-writer-bootstrap-operator.mjs','database-writer-profile-operator.mjs'],modules:[...modules].map(([file,module])=>({file,source:module.source,sourceSha256:module.sourceSha256,sha256:module.sha256,imports:module.imports})),backendDistImports:[...distImports].sort(),backendDistModules:[...backendDistModules.values()].sort((a,b)=>a.file.localeCompare(b.file)),runtimeDependencies:[...runtimeDependencies].sort(),automaticStartup:false,readyAuthorized:false}
+ await writeFile(path.join(output,'build-manifest.json'),JSON.stringify(manifest,null,2)+'\n')
+ return manifest
+}
+if(process.argv[1]&&import.meta.url===pathToFileURL(path.resolve(process.argv[1])).href){
+ assert.equal(process.argv.length,2,'Build takes no runtime configuration or key arguments')
+ const result=await buildDatabaseOperator();console.log(JSON.stringify({event:'database-operator-built',modules:result.modules.length,automaticStartup:false,readyAuthorized:false}))
+}
diff --git a/backend/scripts/build-database-operator.test.mjs b/backend/scripts/build-database-operator.test.mjs
new file mode 100644
index 00000000..b5681e7e
--- /dev/null
+++ b/backend/scripts/build-database-operator.test.mjs
@@ -0,0 +1,101 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import {readFile,writeFile,mkdir,copyFile,mkdtemp,rename} from 'node:fs/promises'
+import {spawnSync} from 'node:child_process'
+import path from 'node:path'
+import {fileURLToPath,pathToFileURL} from 'node:url'
+import {buildDatabaseOperator,compileOperatorModule,moduleSpecifiers,OPERATOR_SOURCES} from './build-database-operator.mjs'
+import {stageDatabaseOperatorScripts} from './stage-database-operator.mjs'
+
+const backend=process.env.OPERATOR_BUILD_TEST_BACKEND??path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..')
+test('AST rewrite changes static/export/dynamic module specifiers and preserves SQL/string values',()=>{
+ const code=compileOperatorModule(`import {x} from '../src/db/x.js'; export {y} from '../../src/db/y.js'; const module=()=>import('../src/db/z.js'); export const sql="SELECT '../src/db/x.js'";`,'fixture.mts')
+ assert.deepEqual(moduleSpecifiers(code,'fixture.mjs'),['../dist/db/x.js','../../dist/db/y.js','../dist/db/z.js'])
+ assert(code.includes(`SELECT '../src/db/x.js'`));assert.throws(()=>compileOperatorModule('const load=name=>import(name)','fixture.mts'),/fixed literal/)
+})
+test('fixed artifact is reproducible, resolves the compiled backend graph, and runs with plain Node22',async()=>{
+ assert.equal(Number(process.versions.node.split('.')[0]),22,'Run this acceptance with the production Node22 major')
+ const temporaryParent=process.env.OPERATOR_BUILD_TEST_TMP??path.resolve(backend,'../tmp');await mkdir(temporaryParent,{recursive:true})
+ const temporary=await mkdtemp(path.join(temporaryParent,'db-operator-build-')),projectBackend=path.join(temporary,'backend'),output=path.join(projectBackend,'dist-operator')
+ const packageJson=JSON.parse(await readFile(path.join(backend,'package.json'),'utf8'))
+ await mkdir(projectBackend,{recursive:true});await writeFile(path.join(projectBackend,'package.json'),JSON.stringify({type:'module',dependencies:packageJson.dependencies}))
+ const first=await buildDatabaseOperator({backendDirectory:backend,outputDirectory:output}),second=await buildDatabaseOperator({backendDirectory:backend,outputDirectory:output})
+ assert.deepEqual(first,second);assert.equal(first.modules.length,OPERATOR_SOURCES.length);assert.equal(first.modules.length,31);assert.deepEqual(first.runtimeDependencies,['dotenv','pg','zod']);assert.equal(first.backendDistModules.length,30)
+ assert(first.modules.some(item=>item.file==='writer-profile/registry-enrollment.mjs'))
+ assert(first.modules.some(item=>item.file==='writer-profile/marker-fence-enrollment.mjs'))
+ assert(first.modules.some(item=>item.file==='writer-profile/fixed58-build-definition.js'))
+ assert(first.backendDistImports.includes('db/database-restore-quarantine-profile.js'))
+ assert(first.backendDistImports.includes('db/database-source-activation-record.js'))
+ assert(first.backendDistImports.includes('services/server-probe-legacy-source-inventory.js'))
+ assert(first.backendDistImports.includes('services/server-probe-legacy-archive-approval.js'))
+ assert(first.backendDistImports.includes('services/server-probe-legacy-handoff-inspection.js'))
+ assert(first.backendDistImports.includes('db/legacy-probe-0037-body.js'))
+ assert(first.backendDistImports.includes('db/controlled-schema-reference-core.js'))
+ assert(first.backendDistImports.includes('services/database-dump-connection.js'))
+ const copied=new Set()
+ async function copyDist(relative){
+ if(copied.has(relative))return;copied.add(relative)
+ const original=path.join(backend,'dist',relative),target=path.join(projectBackend,'dist',relative),source=await readFile(original,'utf8')
+ await mkdir(path.dirname(target),{recursive:true});await copyFile(original,target)
+ for(const specifier of moduleSpecifiers(source,relative)){
+ assert(!specifier.includes('/src/'));assert(!/\.(?:ts|mts)$/.test(specifier))
+ if(specifier.startsWith('.')){const dependency=path.posix.normalize(path.posix.join(path.posix.dirname(relative),specifier));assert(!dependency.startsWith('../'));await copyDist(dependency)}
+ else if(!specifier.startsWith('node:')){const name=specifier.startsWith('@')?specifier.split('/').slice(0,2).join('/'):specifier.split('/')[0];assert(Object.hasOwn(packageJson.dependencies,name),'Compiled helper has undeclared production dependency '+name)}
+ }
+ }
+ for(const relative of first.backendDistImports)await copyDist(relative)
+ assert.deepEqual([...copied].sort(),first.backendDistModules.map(item=>item.file).sort())
+ // Exercise the real build entry point with its default backend/output paths.
+ const scripts=path.join(projectBackend,'scripts')
+ assert.equal(await stageDatabaseOperatorScripts(scripts,path.join(backend,'scripts')),OPERATOR_SOURCES.length+2)
+ const buildScript=path.join(scripts,'build-database-operator.mjs')
+ const built=spawnSync(process.execPath,[buildScript],{cwd:temporary,env:{...process.env,NODE_OPTIONS:''},encoding:'utf8',timeout:30000})
+ assert.equal(built.status,0,built.stderr);assert.equal(JSON.parse(built.stdout.trim()).modules,first.modules.length)
+ assert.deepEqual(JSON.parse(await readFile(path.join(output,'build-manifest.json'),'utf8')),first)
+ const configFile=path.join(projectBackend,'dist','config.js'),originalConfig=await readFile(configFile,'utf8')
+ for(const injected of ["import 'tsx';","import '../src/config.js';","import '../outside.js';"]){
+ await writeFile(configFile,originalConfig+'\n'+injected)
+ await assert.rejects(buildDatabaseOperator({backendDirectory:projectBackend,outputDirectory:output}),/production|Source runtime import|escaped backend\/dist/)
+ }
+ await writeFile(configFile,originalConfig)
+ await writeFile(path.join(output,'unexpected-private.pem'),'not a key; stale-output test')
+ await assert.rejects(buildDatabaseOperator({backendDirectory:backend,outputDirectory:output}),/Unexpected operator output entry/)
+ const {unlink}=await import('node:fs/promises');await unlink(path.join(output,'unexpected-private.pem'))
+ await rename(path.join(projectBackend,'scripts'),path.join(temporary,'build-inputs'))
+ const guard=path.join(temporary,'runtime-guard.mjs'),telemetry=path.join(temporary,'telemetry.json')
+ const denied=[...new Set([...Object.keys(packageJson.devDependencies),'typescript','tsx'])]
+ // Block development imports and connections in the actual plain-Node process.
+ await writeFile(guard,`import {registerHooks,syncBuiltinESMExports} from 'node:module';import net from 'node:net';import tls from 'node:tls';import {writeFileSync} from 'node:fs';const denied=new Set(${JSON.stringify(denied)});let connections=0;const refuse=()=>{connections++;throw Error('Unexpected operator network connection')};net.Socket.prototype.connect=refuse;tls.connect=refuse;syncBuiltinESMExports();registerHooks({resolve(specifier,context,next){const name=specifier.startsWith('@')?specifier.split('/').slice(0,2).join('/'):specifier.split('/')[0];if(denied.has(name)||/\\.(?:ts|mts)$/.test(specifier)||specifier.includes('/backend/src/'))throw Error('Nonproduction import '+specifier);return next(specifier,context)}});process.on('exit',()=>writeFileSync(${JSON.stringify(telemetry)},JSON.stringify({connections})));`)
+ const env={...process.env,NODE_ENV:'production',NODE_OPTIONS:'',AUTH_REQUIRED:'false',DOTENV_CONFIG_QUIET:'true'}
+ // The workspace tmp projection resolves installed packages from its ancestor
+ // node_modules; the runtime hook rejects every development dependency.
+ const modulesToImport=first.modules.map(item=>path.join(output,item.file))
+ const importer=path.join(temporary,'import-all.mjs');await writeFile(importer,`import {pathToFileURL} from 'node:url';for(const file of ${JSON.stringify(modulesToImport)})await import(pathToFileURL(file).href);console.log(JSON.stringify({imported:${modulesToImport.length},readyAuthorized:false}));`)
+ const imported=spawnSync(process.execPath,['--import',pathToFileURL(guard).href,importer],{cwd:temporary,env,encoding:'utf8',timeout:30000})
+ assert.equal(imported.status,0,imported.stderr);assert.equal(JSON.parse(imported.stdout.trim()).imported,first.modules.length);assert.equal(JSON.parse(await readFile(telemetry,'utf8')).connections,0)
+ const refusals=[]
+ for(const [entry,event,args] of [['database-writer-bootstrap-operator.mjs','application-writer-bootstrap-refused',['invalid']],['database-writer-profile-operator.mjs','application-writer-profile-publication-refused',['invalid']],['database-writer-profile-operator.mjs','database-maintenance-command-refused',['maintenance-inspect']],['database-writer-profile-operator.mjs','database-maintenance-command-refused',['maintenance-resolve']],['database-writer-profile-operator.mjs','database-source-activation-refused',['source-activate']],['database-writer-profile-operator.mjs','database-legacy-inspection-refused',['legacy-inspect']],['database-writer-profile-operator.mjs','application-writer-registry-enrollment-refused',['registry-enroll']],['database-writer-profile-operator.mjs','application-writer-marker-fence-enrollment-refused',['marker-fence-enroll']],['database-writer-profile-operator.mjs','application-writer-restore-profile-enrollment-refused',['restore-profile-enroll']]]){
+ const child=spawnSync(process.execPath,['--import',pathToFileURL(guard).href,path.join(output,entry),...args],{cwd:temporary,env,encoding:'utf8',timeout:30000})
+ assert.equal(child.status,1,child.stderr);assert.equal(child.stdout,'');assert.equal(JSON.parse(child.stderr.trim()).event,event);assert.equal(JSON.parse(await readFile(telemetry,'utf8')).connections,0);refusals.push(event)
+ }
+ const catalogue=spawnSync(process.execPath,['--import',pathToFileURL(guard).href,path.join(output,'database-writer-profile-operator.mjs'),'source-catalogue-inspect'],{cwd:temporary,env,encoding:'utf8',timeout:30000})
+ assert.equal(catalogue.status,1,catalogue.stderr);assert.equal(catalogue.stdout,'');assert.equal(JSON.parse(catalogue.stderr.trim()).event,'application-writer-source-catalogue-inspection-refused')
+ assert.equal(JSON.parse(await readFile(telemetry,'utf8')).connections,0);refusals.push('application-writer-source-catalogue-inspection-refused')
+ for(const command of ['legacy-export','legacy-custody','legacy-handoff-inspect','legacy-cold-verify','legacy-handoff-execute','legacy-handoff-adopt','legacy-handoff-release','legacy-control-reference','legacy-source58-preflight','source58-foundation-enroll','source57-admission-enroll']){
+ const invalid=spawnSync(process.execPath,['--import',pathToFileURL(guard).href,path.join(output,'database-writer-profile-operator.mjs'),command],{cwd:temporary,env,encoding:'utf8',timeout:30000})
+ const event={
+ 'legacy-handoff-inspect':'database-legacy-handoff-inspection-refused','legacy-cold-verify':'database-legacy-cold-proof-refused',
+ 'legacy-handoff-execute':'database-legacy-handoff-execution-refused',
+ 'legacy-handoff-adopt':'database-legacy-handoff-adoption-refused',
+ 'legacy-handoff-release':'database-legacy-handoff-release-refused',
+ 'legacy-control-reference':'database-legacy-control-reference-refused',
+ 'legacy-source58-preflight':'database-legacy-source58-preflight-refused',
+ 'source58-foundation-enroll':'database-source58-foundation-refused',
+ 'source57-admission-enroll':'database-source57-admission-refused',
+ }[command]??`database-${command}-refused`
+ assert.equal(invalid.status,1,invalid.stderr);assert.equal(invalid.stdout,'');assert.equal(JSON.parse(invalid.stderr.trim()).event,event)
+ assert.equal(JSON.parse(await readFile(telemetry,'utf8')).connections,0);refusals.push(event)
+ }
+ const receipt={node:process.version,projection:temporary,modules:first.modules.length,compiledBackendModules:copied.size,buildCliExitCode:built.status,importedModules:modulesToImport.length,invalidArgumentsRefused:refusals,developmentDependenciesBlocked:denied,networkConnections:0,productionActivated:false,readyAuthorized:false}
+ await writeFile(path.join(temporary,'acceptance-receipt.json'),JSON.stringify(receipt,null,2)+'\n');console.log(JSON.stringify(receipt))
+})
diff --git a/backend/scripts/database-maintenance-resolution.test.mts b/backend/scripts/database-maintenance-resolution.test.mts
new file mode 100644
index 00000000..c01ee4aa
--- /dev/null
+++ b/backend/scripts/database-maintenance-resolution.test.mts
@@ -0,0 +1,100 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import {mkdtemp,mkdir,writeFile,readFile,readdir,rm,unlink,lstat} from 'node:fs/promises'
+import {createHash,randomUUID} from 'node:crypto'
+import {rootCertificates} from 'node:tls'
+import {EventEmitter} from 'node:events'
+import path from 'node:path'
+import {fileURLToPath,pathToFileURL} from 'node:url'
+import {runInNewContext} from 'node:vm'
+import {createRequire} from 'node:module'
+import * as strictReader from '../src/services/database-maintenance-startup.js'
+import * as grammar from '../src/services/database-maintenance-resolution.js'
+import * as manifest from '../src/db/migration-manifest.js'
+import * as contract from './writer-profile/operator-contract.mjs'
+const backend=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..'),require=createRequire(import.meta.url),ts=require('typescript'),hash=(value:Buffer|string)=>createHash('sha256').update(value).digest('hex')
+async function own(work:(root:string)=>Promise){const temp=path.resolve(backend,'../tmp');await mkdir(temp,{recursive:true});const root=await mkdtemp(path.join(temp,'owned-resolution-command-'));try{await work(root)}finally{assert.equal(path.dirname(root),temp);assert(path.basename(root).startsWith('owned-resolution-command-'));await rm(root,{recursive:true,force:true})}}
+async function model(root:string,localHost?:string){
+ let owners=0,sql=0,releaseFailure=false,poolEndFailure=false,published=0,wrongOwner=false,controlSchema=false,observationFailure:Error|undefined
+ const capturedScopes:unknown[]=[]
+ const state=path.join(root,'state');await mkdir(state);await mkdir(path.join(state,'restore-vault'));await writeFile(path.join(state,'access-generation'),Buffer.alloc(32,7));const uncertain=randomUUID(),at=new Date().toISOString(),record=(value:string)=>JSON.stringify({operationId:uncertain,state:value,at})+'\n';await writeFile(path.join(state,'database-maintenance.jsonl'),record('intent')+record('unconfirmed'))
+ const source={systemIdentifier:'1234567890',databaseOid:'12345',databaseName:'managed',serverVersionNum:180004,inRecovery:false}
+ const schema={sha256:'a'.repeat(64),observedRaw:{sha256:'b'.repeat(64)},observedPhysical:{sha256:'c'.repeat(64)},sections:{relations:manifest.CURRENT_REQUIRED_TABLES.map(name=>({namespace:'public',name,kind:'r',persistence:'p',row_security:false,force_row_security:false})),columns:[{namespace:'public',relation:'schema_migrations',name:'id',dropped:false,type:'text'}]}}
+ class Pool {on(){};constructor(options:unknown){const ssl=(options as {ssl:false|{rejectUnauthorized:boolean}}).ssl;if(ssl===false)assert(['127.0.0.1','::1'].includes((options as {host:string}).host));else assert(ssl.rejectUnauthorized)}async connect(){owners++;const client=new EventEmitter();return Object.assign(client,{release:()=>{owners--;if(releaseFailure)throw Error('Synthetic release uncertainty')},query:async(text:string)=>{sql++;if(text.includes('pg_try_advisory_lock'))return {rows:[{locked:true}],command:'SELECT'};if(text.includes('pg_advisory_unlock'))return {rows:[{unlocked:true}],command:'SELECT'};if(text.includes('pg_namespace'))return {rows:controlSchema?[{nspname:'mmapp_control'}]:[],command:'SELECT'};if(text.includes('pg_control_system')){if(observationFailure)throw observationFailure;return {rows:[source],command:'SELECT'}};if(text.startsWith('SELECT id FROM public.schema_migrations'))return {rows:manifest.MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)})),command:'SELECT'};return {rows:[],command:text.split(' ')[0]}}})}async end(){assert.equal(owners,0);if(poolEndFailure)throw Error('Synthetic pool retirement uncertainty')}}
+ const protectedSource=await readFile(path.join(backend,'scripts/writer-profile/operator-files.mjs'),'utf8'),protectedExports:Record={},actualUid=(await lstat(state)).uid
+ const protectedCode=ts.transpileModule(protectedSource,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText
+ runInNewContext(protectedCode,{exports:protectedExports,require,Buffer,process:{platform:'linux',getuid:()=>actualUid+1},Object,Error})
+ const protectedDirectory=async(directory:string)=>{assert(path.resolve(directory).startsWith(root+path.sep)||path.resolve(directory)===root);if(wrongOwner)await (protectedExports.protectedDirectory as (path:string)=>Promise)(directory);await readdir(directory)}
+ // Explicit MODELED protection adapter: native POSIX mode/ownership and hardlink
+ // fsync publication remain separate Linux acceptance, never a Windows claim.
+ const files={sha:hash,protectedDirectory,readProtected:async(file:string,maximum:number,pin?:string)=>{assert(file.startsWith(root+path.sep));const raw=await readFile(file);assert(raw.length>0&&raw.length<=maximum);if(pin)assert.equal(hash(raw),pin);return raw},writeFile:async(file:string,raw:Buffer)=>{assert(file.startsWith(root+path.sep));await writeFile(file,raw,{flag:'wx'});published++},withJournalLease:async(directory:string,work:()=>Promise)=>{const lock=path.join(directory,'publisher-lease.lock');await writeFile(lock,'owned',{flag:'wx'});try{return await work()}finally{await unlink(lock)}}}
+ const readRecords=async(directory:string)=>{const records=path.join(directory,'maintenance-acceptances');let names:string[];try{names=await readdir(records)}catch(error){if((error as NodeJS.ErrnoException).code==='ENOENT')return [];throw error};assert(names.every(name=>/^[a-f0-9-]{36}\.json$/.test(name)));return Promise.all(names.sort().map(name=>readFile(path.join(records,name))))}
+ const moduleFile=path.join(backend,'scripts/writer-profile/maintenance-resolution.mts'),sourceText=(await readFile(moduleFile,'utf8')).replaceAll('import.meta.url',JSON.stringify(pathToFileURL(moduleFile).href)),exports:Record={}
+ const dependencies:Record={'./operator-files.mjs':files,'./operator-contract.mjs':contract,'../../src/services/database-maintenance-startup.js':{...strictReader,readMaintenanceAcceptanceRecords:readRecords},'../../src/services/database-maintenance-resolution.js':grammar,'../../src/db/migration-schema-inventory.js':{captureMigrationSchema:async(_client:unknown,options:{scope:unknown;includeControlEventTriggers?:boolean})=>{capturedScopes.push({...options.scope as object,includeControlEventTriggers:options.includeControlEventTriggers});return schema}},'../../src/db/migration-manifest.js':manifest,pg:{Pool}}
+ const code=ts.transpileModule(sourceText,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText
+ runInNewContext(code,{exports,require:(name:string)=>name in dependencies?dependencies[name]:require(name),Buffer,URL,process:{env:{}},Date,Object,Map,Set,Error,console})
+ const command=exports.maintenanceMain as (args:string[])=>Promise>
+ const tlsTransport={format:'database-maintenance-transport-v1',connection:{host:'db.example.invalid',port:5432,user:'existing-maintenance-user',password:'synthetic-only',database:'managed'},tls:{serverName:'db.example.invalid',spkiSha256:'f'.repeat(64)}},localTransport=(host:string)=>({format:'database-maintenance-transport-v1',mode:'local-loopback',connection:{...tlsTransport.connection,host}})
+ const configs={transport:localHost===undefined?tlsTransport:localTransport(localHost),'runtime-target':{format:'database-maintenance-runtime-target-v1',databaseUrl:'postgresql://db.example.invalid:5432/managed?sslmode=require'}}
+ const args=['--state-dir',state]
+ for(const [name,value]of Object.entries(configs)){const raw=Buffer.from(JSON.stringify(value)),file=path.join(root,name+'.json');await writeFile(file,raw);args.push('--'+name,file,'--'+name+'-sha256',hash(raw))}
+ const ca=Buffer.from(rootCertificates[0]),caFile=path.join(root,'ca.pem');await writeFile(caFile,ca);if(localHost===undefined)args.push('--ca',caFile,'--ca-sha256',hash(ca))
+ const output=path.join(root,'inspection.json')
+ async function inspect(destination=output){return command(['maintenance-inspect',...args,'--output',destination])}
+ async function approve(change?:(value:Record)=>void){const raw=await readFile(output),inspection=JSON.parse(raw.toString()),approval={format:'database-maintenance-current-state-approval-v1',resolutionId:randomUUID(),decision:'accept-observed-current-state',actorId:'host-human-reviewer',inspectionSha256:hash(raw),issuedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+60000).toISOString(),managedBackendStopped:true,historicOutcomesRemainUnknown:true,automaticRestore:false};assert(inspection.createdAt<=approval.issuedAt);change?.(approval);const bytes=Buffer.from(JSON.stringify(approval)),file=path.join(root,'approval.json');await writeFile(file,bytes);return ['maintenance-resolve',...args,'--inspection',output,'--inspection-sha256',hash(raw),'--approval',file,'--approval-sha256',hash(bytes)]}
+ const toLocal=async(host='127.0.0.1')=>{const raw=Buffer.from(JSON.stringify(localTransport(host)));await writeFile(path.join(root,'transport.json'),raw);args[args.indexOf('--transport-sha256')+1]=hash(raw);for(const flag of ['--ca','--ca-sha256']){const at=args.indexOf(flag);if(at>=0)args.splice(at,2)}}
+ const configuration=exports.maintenancePoolConfiguration as (value:unknown,ca?:Buffer,pin?:string)=>{options:Record;transportBinding:{mode:string;endpointSha256:string}}
+ return {command,inspect,approve,toLocal,configuration,readRecords,state,output,sql:()=>sql,published:()=>published,failRelease:()=>{releaseFailure=true},failEnd:()=>{poolEndFailure=true},driftSchema:()=>{schema.sha256='0'.repeat(64)},driftTarget:()=>{source.databaseOid='54321'},wrongOwner:()=>{wrongOwner=true},withControlSchema:()=>{controlSchema=true},scopes:()=>capturedScopes,failObservation:(error:Error)=>{observationFailure=error}}
+}
+test('actual operator commands inspect then separately approved resolve; old uncertain bytes never rewritten',()=>own(async root=>{
+ const fixture=await model(root),journal=path.join(fixture.state,'database-maintenance.jsonl'),before=await readFile(journal),inspected=await fixture.inspect();assert.equal(inspected.humanApprovalRequired,true);assert.equal((await fixture.readRecords(fixture.state)).length,0)
+ const result=await fixture.command(await fixture.approve());assert.equal(result.outcome,'committed');assert.equal(result.historicOutcomesChanged,false);assert.equal(result.archiveDataEquivalenceProved,false);assert.equal(result.automaticRestore,false)
+ assert.deepEqual(await readFile(journal),before);const records=await fixture.readRecords(fixture.state),facts=await strictReader.readMaintenanceRecoveryFacts(fixture.state);assert.equal(records.length,1);const accepted=grammar.evaluateMaintenanceAcceptances(records,facts.journal,facts.vault.evidence,grammar.runtimeDatabaseTargetSha256('postgresql://db.example.invalid:5432/managed?sslmode=require'));assert.equal(accepted.count,1)
+ fixture.driftSchema();const afterStatus=await fixture.inspect(path.join(root,'after-inspection.json'));assert.equal(afterStatus.state,'historically-accepted');assert.equal(afterStatus.humanApprovalRequired,false);assert.equal(afterStatus.historicOutcomesChanged,false)
+ await assert.rejects(fixture.command(await fixture.approve()),/No new unresolved|already|assert|Assertion/i)
+}))
+for(const type of ['expired','not-stopped','wrong-inspection'])test('actual resolve refuses '+type+' approval before connecting SQL',()=>own(async root=>{
+ const fixture=await model(root);await fixture.inspect();const args=await fixture.approve(value=>{if(type==='expired')value.expiresAt=new Date(Date.now()-1).toISOString();if(type==='not-stopped')value.managedBackendStopped=false;if(type==='wrong-inspection')value.inspectionSha256='0'.repeat(64)}),before=fixture.sql();await assert.rejects(fixture.command(args));assert.equal(fixture.sql(),before);assert.equal((await fixture.readRecords(fixture.state)).length,0)
+}))
+for(const type of ['release','pool-end','schema-drift','target-drift','external-drift'])test('actual resolve refuses '+type+' before acceptance publication',()=>own(async root=>{
+ const fixture=await model(root);await fixture.inspect();const args=await fixture.approve();if(type==='release')fixture.failRelease();if(type==='pool-end')fixture.failEnd()
+ if(type==='schema-drift')fixture.driftSchema();if(type==='target-drift')fixture.driftTarget()
+ if(type==='external-drift')await appendFileSafe(path.join(fixture.state,'database-maintenance.jsonl'))
+ await assert.rejects(fixture.command(args));assert.equal((await fixture.readRecords(fixture.state)).length,0)
+}))
+async function appendFileSafe(file:string){await writeFile(file,await readFile(file,'utf8')+JSON.stringify({operationId:randomUUID(),state:'intent',at:new Date().toISOString()})+'\n')}
+test('existing shipped main dispatches both commands before writer-profile role/source flags',async()=>{
+ const source=await readFile(path.join(backend,'scripts/database-writer-profile-operator.mts'),'utf8');assert(source.indexOf("['maintenance-inspect','maintenance-resolve']")own(async root=>{
+ const fixture=await model(root);fixture.wrongOwner();await assert.rejects(fixture.inspect());assert.equal(fixture.sql(),0);assert.equal(fixture.published(),0);assert.equal((await fixture.readRecords(fixture.state)).length,0)
+}))
+
+test('explicit local-loopback supports both IP families and binds selected mode in actual inspect/resolve',async()=>{
+ for(const host of ['127.0.0.1','::1'])await own(async root=>{const fixture=await model(root,host);await fixture.inspect();const result=await fixture.command(await fixture.approve());assert.equal(result.outcome,'committed');const records=await fixture.readRecords(fixture.state);assert.equal(JSON.parse(records[0].toString()).knownCurrent.transport.mode,'local-loopback')})
+})
+test('plaintext remote/DNS/unspecified/mapped hosts refuse before SQL and never fall back',async()=>{
+ for(const host of ['db.example.invalid','localhost','0.0.0.0','192.0.2.1','[::1]','::ffff:127.0.0.1'])await own(async root=>{const fixture=await model(root,host);await assert.rejects(fixture.inspect());assert.equal(fixture.sql(),0);assert.equal(fixture.published(),0)})
+})
+test('an approval for TLS observation cannot resolve through a changed local-loopback transport',()=>own(async root=>{
+ const fixture=await model(root);await fixture.inspect();await fixture.toLocal();await assert.rejects(fixture.command(await fixture.approve()));assert.equal((await fixture.readRecords(fixture.state)).length,0)
+}))
+test('local mode explicitly disables SSL/environment substitution; TLS remains verified default without fallback',()=>own(async root=>{
+ const fixture=await model(root),ConnectionParameters=require('pg/lib/connection-parameters'),raw={format:'database-maintenance-transport-v1',mode:'local-loopback',connection:{host:'127.0.0.1',port:5432,user:'existing-user',password:'synthetic-only',database:'managed'}}
+ const previous={PGHOST:process.env.PGHOST,PGSSLMODE:process.env.PGSSLMODE,PGOPTIONS:process.env.PGOPTIONS};process.env.PGHOST='remote.invalid';process.env.PGSSLMODE='require';process.env.PGOPTIONS='-c role=foreign'
+ try{const config=fixture.configuration(raw),actual=new ConnectionParameters(config.options);assert.equal(actual.host,'127.0.0.1');assert.equal(actual.ssl,false);assert.equal(actual.options,contract.STARTUP_OPTIONS);assert.equal(config.transportBinding.mode,'local-loopback')}
+ finally{for(const [key,value]of Object.entries(previous)){if(value===undefined)delete process.env[key];else process.env[key]=value}}
+ const ca=Buffer.from(rootCertificates[0]),tls={format:'database-maintenance-transport-v1',connection:{...raw.connection,host:'db.example.invalid'},tls:{serverName:'db.example.invalid',spkiSha256:'f'.repeat(64)}}
+ assert.throws(()=>fixture.configuration(tls));const secure=fixture.configuration(tls,ca,hash(ca));assert.equal(secure.transportBinding.mode,'tls');assert.equal((secure.options.ssl as {rejectUnauthorized:boolean}).rejectUnauthorized,true)
+ assert.throws(()=>fixture.configuration({...raw,mode:'plaintext'}));assert.throws(()=>fixture.configuration({...tls,mode:null},ca,hash(ca)));assert.throws(()=>fixture.configuration(raw,ca,hash(ca)))
+}))
+
+// A normal installation has no optional writer-profile schema. Observation must
+// select its exact namespace set without requiring installation of that system.
+test('maintenance observes with and without the optional control namespace',async()=>{
+ for(const present of [false,true])await own(async root=>{const fixture=await model(root);if(present)fixture.withControlSchema();await fixture.inspect();assert.equal(JSON.stringify(fixture.scopes()),JSON.stringify([{applicationNamespaces:present?['public','mmapp_control']:['public'],includeControlEventTriggers:present}]))})
+})
+test('original observation failure survives confirmed rollback/unlock/release',()=>own(async root=>{
+ const fixture=await model(root),failure=Error('Synthetic original observation failure');fixture.failObservation(failure);await assert.rejects(fixture.inspect(),error=>error===failure);assert.equal(fixture.published(),0);assert.equal((await fixture.readRecords(fixture.state)).length,0)
+}))
diff --git a/backend/scripts/database-operator-sources.mjs b/backend/scripts/database-operator-sources.mjs
new file mode 100644
index 00000000..9bd71bfa
--- /dev/null
+++ b/backend/scripts/database-operator-sources.mjs
@@ -0,0 +1,17 @@
+/** The fixed build inputs shared by the operator and Docker staging. */
+export const OPERATOR_SOURCES=Object.freeze([
+ 'database-writer-bootstrap-operator.mjs','database-writer-profile-operator.mts',
+ 'writer-profile/operator-files.mjs','writer-profile/operator-contract.mjs','writer-profile/publisher.mjs','writer-profile/context.mjs',
+ 'writer-profile/protected-source-registry.mts','writer-profile/maintenance-resolution.mts','writer-profile/source-activation.mts',
+ 'writer-profile/legacy-cold-verification.mts',
+ 'writer-profile/legacy-handoff-execution.mts',
+ 'writer-profile/legacy-control-reference.mts',
+ 'writer-profile/source58-foundation.mts',
+ 'writer-profile/source57-admission-plan.mts',
+ 'writer-profile/registry-enrollment.mts',
+ 'writer-profile/marker-fence-enrollment.mts',
+ 'writer-profile/catalogue.mts','writer-profile/catalogue-value-bridge.ts','writer-profile/catalogue-projection.ts','writer-profile/catalogue-leaves.ts',
+ 'writer-profile/application-writer-profile-catalogue.ts','writer-profile/application-writer-profile-catalogue-values.ts',
+ 'writer-profile/application-writer-profile-catalogue-parent-policy.ts','writer-profile/application-writer-profile-canonical.ts',
+ 'writer-profile/fixed44-build-sql.ts','writer-profile/fixed44-build-definition.ts','writer-profile/fixed56-build-definition.ts','writer-profile/fixed56-build-delta.ts','writer-profile/fixed57-build-definition.ts','writer-profile/fixed58-build-definition.ts','writer-profile/expanded44-data-policy.ts',
+])
diff --git a/backend/scripts/database-source-binding-operator.ts b/backend/scripts/database-source-binding-operator.ts
new file mode 100644
index 00000000..c4f892dd
--- /dev/null
+++ b/backend/scripts/database-source-binding-operator.ts
@@ -0,0 +1,74 @@
+/** Offline operator-only issuer proposal. Never imported by runtime/startup.
+ * Effective key/registry ACL isolation is required before deployment acceptance;
+ * mode bits and possession of CLI arguments do not establish that isolation. */
+import { createPrivateKey, createPublicKey, sign } from "node:crypto"
+import { mkdir, open, realpath } from "node:fs/promises"
+import path from "node:path"
+import { z } from "zod"
+import { DATABASE_SOURCE_SIGNATURE_DOMAINS, sourceBindingBodySchema, sourceBindingBytes, sourceBindingCanonical, sourceBindingSha256,
+ readDatabaseSourceBindingRegistry, type DatabaseSourceDeploymentPin } from "../src/db/database-source-binding.js"
+
+const requestSchema = sourceBindingBodySchema.omit({ format: true, ordinal: true })
+export type DatabaseSourceOperatorRequest = z.infer
+function outside(parent: string, child: string) {
+ const relative = path.relative(parent, child)
+ return !!relative && (relative.startsWith(".." + path.sep) || relative === ".." || path.isAbsolute(relative))
+}
+export async function provisionDatabaseSourceBindingOffline(options: { request: DatabaseSourceOperatorRequest; privateKeyFile: string;
+ outputDirectory: string; previousPin?: DatabaseSourceDeploymentPin }) {
+ const request = requestSchema.parse(options.request)
+ const privatePath = await realpath(options.privateKeyFile), output = path.resolve(options.outputDirectory)
+ const parent = await realpath(path.dirname(output))
+ if (parent !== path.dirname(output) || !outside(output, privatePath)) throw Error("Private operator key must be outside new registry, without ambiguous parent links")
+ const stat = await open(privatePath, "r")
+ let privateBytes: Buffer
+ try { const meta = await stat.stat(); if (!meta.isFile() || meta.size < 1 || meta.size > 8192) throw Error("Bounded operator private key required"); privateBytes = await stat.readFile() }
+ finally { await stat.close() }
+ const privateKey = createPrivateKey(privateBytes); privateBytes.fill(0)
+ if (privateKey.type !== "private" || privateKey.asymmetricKeyType !== "ed25519") throw Error("Independent Ed25519 operator key required")
+ const publicKey = createPublicKey(privateKey), spki = publicKey.export({ type: "spki", format: "der" })
+ const publicKeySpkiSha256 = sourceBindingSha256(spki)
+ const previous = options.previousPin ? await readDatabaseSourceBindingRegistry(options.previousPin) : undefined
+ if (previous && (previous.body.installationId !== request.installationId || previous.body.sourceIdentityId !== request.sourceIdentityId ||
+ previous.publicKeySpkiSha256 !== publicKeySpkiSha256 || previous.body.generation === request.generation || previous.body.ordinal >= Number.MAX_SAFE_INTEGER)) throw Error("Previous current head/identity/key or distinct new generation required")
+ const body = sourceBindingBodySchema.parse({ ...request, format: "database-source-binding-v1", ordinal: previous ? previous.body.ordinal + 1 : 1 })
+ const signed = (domain: string, payload: unknown) => sourceBindingBytes({ body: payload,
+ signature: sign(null, Buffer.from(domain + sourceBindingCanonical(payload)), privateKey).toString("base64url") })
+ const bindingBytes = signed(DATABASE_SOURCE_SIGNATURE_DOMAINS.binding, body), bindingSha256 = sourceBindingSha256(bindingBytes)
+ const head = { format: "database-source-registry-head-v1", installationId: body.installationId, sourceIdentityId: body.sourceIdentityId,
+ generation: body.generation, ordinal: body.ordinal, bindingSha256, previousHeadSha256: previous?.headSha256 ?? null }
+ const headBytes = signed(DATABASE_SOURCE_SIGNATURE_DOMAINS.head, head), currentHeadSha256 = sourceBindingSha256(headBytes)
+ // No recursive mkdir and no existing-state adoption. A partial output remains
+ // for explicit operator review; uncertainty is never retried/overwritten.
+ await mkdir(output, { mode: 0o700 })
+ const publish = async (filename: string, bytes: Buffer | string) => {
+ const handle = await open(path.join(output, filename), "wx", 0o600)
+ try { await handle.writeFile(bytes); await handle.sync() } finally { await handle.close() }
+ }
+ await publish("operator-public.pem", publicKey.export({ type: "spki", format: "pem" }))
+ await publish("binding-" + bindingSha256 + ".json", bindingBytes)
+ await publish("head-" + currentHeadSha256 + ".json", headBytes)
+ const deploymentPin = { registryDirectory: output, installationId: body.installationId, publicKeySpkiSha256, currentHeadSha256 }
+ // Public review artifact only; not installed into any application config.
+ await publish("proposed-deployment-pin.json", sourceBindingBytes(deploymentPin))
+ return Object.freeze({ deploymentPin: Object.freeze(deploymentPin), keyIsolationVerified: false as const,
+ platformProtectionVerified: false as const, generationAuthenticated: false as const, readyAuthorized: false as const })
+}
+
+export async function databaseSourceBindingOperatorCli(args: string[]) {
+ const allowed = new Set(["request", "private-key", "output", "previous-pin"]), values = new Map()
+ for (const arg of args) {
+ const match = /^--([a-z-]+)=(.+)$/.exec(arg)
+ if (!match || !allowed.has(match[1]) || values.has(match[1])) throw Error("Exact explicit offline operator arguments required")
+ values.set(match[1], match[2])
+ }
+ if (!["request", "private-key", "output"].every(key => values.has(key))) throw Error("Missing explicit offline operator arguments")
+ const boundedJson = async (filename: string) => {
+ const handle = await open(filename, "r")
+ try { const stat = await handle.stat(); if (!stat.isFile() || stat.size < 1 || stat.size > 8192) throw Error("Bounded operator input required"); return JSON.parse(await handle.readFile("utf8")) as unknown }
+ finally { await handle.close() }
+ }
+ const request = requestSchema.parse(await boundedJson(values.get("request")!))
+ const previousPin = values.has("previous-pin") ? await boundedJson(values.get("previous-pin")!) as DatabaseSourceDeploymentPin : undefined
+ return provisionDatabaseSourceBindingOffline({ request, privateKeyFile: values.get("private-key")!, outputDirectory: values.get("output")!, previousPin })
+}
diff --git a/backend/scripts/database-writer-bootstrap-operator.mjs b/backend/scripts/database-writer-bootstrap-operator.mjs
new file mode 100644
index 00000000..ada79f75
--- /dev/null
+++ b/backend/scripts/database-writer-bootstrap-operator.mjs
@@ -0,0 +1,105 @@
+/** Explicit offline operator init. No database, application imports or activation. */
+import assert from 'node:assert/strict'
+import {createHash, generateKeyPairSync} from 'node:crypto'
+import {constants} from 'node:fs'
+import {lstat, realpath, open, mkdir, link, unlink} from 'node:fs/promises'
+import path from 'node:path'
+import {pathToFileURL} from 'node:url'
+
+const digest = bytes => createHash('sha256').update(bytes).digest('hex')
+const hex = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value)
+const uuid = value => typeof value === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(value)
+const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key))
+const roles = ['runtime', 'operator', 'capture', 'publisher', 'control']
+export function deploymentRequest(value) {
+ assert(exact(value, ['format', 'installationId', 'sourceHeadSha256', 'source', 'roles', 'tls']))
+ assert(value.format === 'application-writer-bootstrap-request-v1' && uuid(value.installationId) && hex(value.sourceHeadSha256))
+ assert(exact(value.source, ['systemIdentifier', 'databaseOid', 'databaseName', 'serverVersionNum', 'inRecovery']))
+ assert(typeof value.source.systemIdentifier === 'string' && /^[1-9][0-9]{0,19}$/.test(value.source.systemIdentifier) && BigInt(value.source.systemIdentifier) <= 18446744073709551615n)
+ assert(typeof value.source.databaseOid === 'string' && /^[1-9][0-9]{0,9}$/.test(value.source.databaseOid) && BigInt(value.source.databaseOid) <= 4294967295n)
+ assert(typeof value.source.databaseName === 'string' && /^[^\x00-\x1f\x7f]{1,63}$/.test(value.source.databaseName))
+ assert(Number.isInteger(value.source.serverVersionNum) && value.source.serverVersionNum >= 180000 && value.source.serverVersionNum <= 189999 && value.source.inRecovery === false)
+ assert(exact(value.roles, roles))
+ for (const role of roles) {
+ const pair = value.roles[role]
+ assert(exact(pair, ['name', 'signedOid']) && typeof pair.name === 'string' && /^[a-z_][a-z0-9_]{0,62}$/.test(pair.name))
+ assert(typeof pair.signedOid === 'string' && /^[1-9][0-9]{0,9}$/.test(pair.signedOid) && BigInt(pair.signedOid) <= 4294967295n)
+ }
+ assert(new Set(roles.map(role => value.roles[role].name)).size === 5 && new Set(roles.map(role => value.roles[role].signedOid)).size === 5)
+ assert(exact(value.tls, ['serverName', 'caSha256', 'spkiSha256']) && typeof value.tls.serverName === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9.-]{0,252}$/.test(value.tls.serverName) && hex(value.tls.caSha256) && hex(value.tls.spkiSha256))
+ return structuredClone(value)
+}
+export function createBootstrapMaterial(raw, requestSha256) {
+ const request = deploymentRequest(raw)
+ assert(hex(requestSha256))
+ const {privateKey, publicKey} = generateKeyPairSync('ed25519')
+ const publicKeyPem = publicKey.export({format: 'pem', type: 'spki'}).toString()
+ const publicKeySpkiSha256 = digest(publicKey.export({format: 'der', type: 'spki'}))
+ return {
+ privateKeyPem: privateKey.export({format: 'pem', type: 'pkcs8'}).toString(), publicKeyPem,
+ bootstrap: {format: 'application-writer-bootstrap-v1', verificationSubject: {installationId: request.installationId, publicKeyPem, publicKeySpkiSha256},
+ deploymentRequest: request, deploymentRequestSha256: requestSha256, keyOrigin: 'explicit-offline-operator-init',
+ databaseObserved: false, rolesAuthenticated: false, sourceAuthenticated: false, approvedDefinitionSha256: null,
+ publicationAuthorized: false, generationAuthenticated: false, readyAuthorized: false},
+ }
+}
+async function protectedDirectory(directory) {
+ assert(process.platform !== 'win32' && typeof process.getuid === 'function', 'Protected POSIX ownership required; Windows ACL backend unavailable')
+ assert(path.isAbsolute(directory) && await realpath(directory) === directory)
+ const uid = process.getuid(), stat = await lstat(directory)
+ assert(stat.isDirectory() && !stat.isSymbolicLink() && stat.uid === uid && (stat.mode & 0o077) === 0)
+ for (let ancestor = path.dirname(directory);; ancestor = path.dirname(ancestor)) {
+ const metadata = await lstat(ancestor)
+ assert(metadata.isDirectory() && !metadata.isSymbolicLink() && (metadata.uid === uid || metadata.uid === 0))
+ assert((metadata.mode & 0o022) === 0 || metadata.uid === 0 && (metadata.mode & 0o1000) !== 0)
+ if (ancestor === path.dirname(ancestor)) break
+ }
+ return stat
+}
+async function publish(directory, name, bytes) {
+ await protectedDirectory(directory)
+ const temporary = path.join(directory, '.' + name + '.pending'), destination = path.join(directory, name)
+ const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600)
+ try { await handle.writeFile(bytes); await handle.sync() } finally { await handle.close() }
+ await link(temporary, destination) // Atomic no-replace publication, never rename-overwrite.
+ await unlink(temporary)
+ const parent = await open(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW)
+ try { await parent.sync() } finally { await parent.close() }
+}
+export async function initializeBootstrap({outputDirectory, deploymentFile, deploymentSha256}) {
+ assert(path.isAbsolute(outputDirectory) && path.resolve(outputDirectory) === outputDirectory && hex(deploymentSha256))
+ await protectedDirectory(path.dirname(outputDirectory))
+ assert(path.isAbsolute(deploymentFile) && await realpath(deploymentFile) === deploymentFile)
+ const requestHandle = await open(deploymentFile, constants.O_RDONLY | constants.O_NOFOLLOW)
+ let bytes
+ try {
+ const before = await requestHandle.stat()
+ assert(before.isFile() && before.uid === process.getuid() && (before.mode & 0o077) === 0 && before.size > 0 && before.size <= 16384)
+ bytes = Buffer.alloc(before.size + 1)
+ let size = 0
+ while (size < bytes.length) { const read = await requestHandle.read(bytes, size, bytes.length - size, size); if (!read.bytesRead) break; size += read.bytesRead }
+ const after = await requestHandle.stat()
+ assert(size === before.size && after.size === before.size && after.mtimeMs === before.mtimeMs && after.ctimeMs === before.ctimeMs)
+ bytes = bytes.subarray(0, size)
+ } finally { await requestHandle.close() }
+ assert(digest(bytes) === deploymentSha256, 'Explicit independently approved deployment digest required')
+ const request = deploymentRequest(JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes)))
+ await mkdir(outputDirectory, {mode: 0o700}) // EEXIST refuses; never adopt/overwrite.
+ const material = createBootstrapMaterial(request, deploymentSha256)
+ await publish(outputDirectory, 'signing-private.pem', material.privateKeyPem)
+ await publish(outputDirectory, 'operator-public.pem', material.publicKeyPem)
+ await publish(outputDirectory, 'bootstrap.json', JSON.stringify(material.bootstrap, null, 2) + '\n') // Completion marker last.
+ return {event: 'application-writer-bootstrap-initialized', installationId: request.installationId,
+ publicKeySpkiSha256: material.bootstrap.verificationSubject.publicKeySpkiSha256,
+ deploymentRequestSha256: deploymentSha256, databaseObserved: false, publicationAuthorized: false, readyAuthorized: false}
+}
+export async function main(args) {
+ assert(args.length === 7 && args[0] === 'init')
+ const values = new Map()
+ for (let i = 1; i < args.length; i += 2) { assert(['--output', '--deployment', '--deployment-sha256'].includes(args[i]) && !values.has(args[i])); values.set(args[i], args[i + 1]) }
+ return initializeBootstrap({outputDirectory: values.get('--output'), deploymentFile: values.get('--deployment'), deploymentSha256: values.get('--deployment-sha256')})
+}
+if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
+ try { console.log(JSON.stringify(await main(process.argv.slice(2)))) }
+ catch { console.error(JSON.stringify({event: 'application-writer-bootstrap-refused', publicationAuthorized: false, readyAuthorized: false})); process.exitCode = 1 }
+}
diff --git a/backend/scripts/database-writer-bootstrap-operator.test.mjs b/backend/scripts/database-writer-bootstrap-operator.test.mjs
new file mode 100644
index 00000000..e9dcca71
--- /dev/null
+++ b/backend/scripts/database-writer-bootstrap-operator.test.mjs
@@ -0,0 +1,43 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import {createHash, createPrivateKey, createPublicKey, sign, verify} from 'node:crypto'
+import {mkdtemp, rm, writeFile, readdir, readFile, stat, chmod} from 'node:fs/promises'
+import path from 'node:path'
+import {tmpdir} from 'node:os'
+import {deploymentRequest, createBootstrapMaterial, initializeBootstrap, main} from './database-writer-bootstrap-operator.mjs'
+const hash = b => createHash('sha256').update(b).digest('hex')
+const request = () => ({format: 'application-writer-bootstrap-request-v1', installationId: 'f8b410ef-11ba-4419-b6a6-e735e505450b', sourceHeadSha256: 'a'.repeat(64),
+ source: {systemIdentifier: '7387529813445422155', databaseOid: '16384', databaseName: 'operator-fixture', serverVersionNum: 180004, inRecovery: false},
+ roles: Object.fromEntries(['runtime', 'operator', 'capture', 'publisher', 'control'].map((name, i) => [name, {name: 'fixture_' + name, signedOid: String(20000 + i)}])),
+ tls: {serverName: 'db.example.invalid', caSha256: 'b'.repeat(64), spkiSha256: 'c'.repeat(64)}})
+test('real distinct Ed25519 keypairs sign/verify and preserve externally pinned subject without authorization', () => {
+ const value = request(), a = createBootstrapMaterial(value, 'd'.repeat(64)), b = createBootstrapMaterial(value, 'd'.repeat(64))
+ const privateKey = createPrivateKey(a.privateKeyPem), publicKey = createPublicKey(a.publicKeyPem), message = Buffer.from('owned-key-roundtrip')
+ assert(verify(null, message, publicKey, sign(null, message, privateKey))); assert(!verify(null, Buffer.from('changed'), publicKey, sign(null, message, privateKey)))
+ assert.equal(hash(publicKey.export({format: 'der', type: 'spki'})), a.bootstrap.verificationSubject.publicKeySpkiSha256)
+ assert.notEqual(a.publicKeyPem, b.publicKeyPem); assert.equal(a.bootstrap.verificationSubject.installationId, value.installationId)
+ assert.equal(a.bootstrap.publicationAuthorized, false); assert.equal(a.bootstrap.readyAuthorized, false); assert.equal(a.bootstrap.approvedDefinitionSha256, null)
+ assert.equal(a.bootstrap.databaseObserved, false); assert(!JSON.stringify(a.bootstrap).includes('PRIVATE KEY')); value.roles.runtime.name = 'changed'; assert.notEqual(a.bootstrap.deploymentRequest.roles.runtime.name, 'changed')
+})
+test('missing roles/head/transport pin and malformed identities refuse rather than invent trust', () => {
+ for (const change of [v => delete v.roles.control, v => delete v.sourceHeadSha256, v => delete v.tls.spkiSha256, v => v.roles.operator = v.roles.runtime, v => v.source.databaseOid = 16384, v => v.source.inRecovery = true, v => v.extra = true]) {
+ const value = request(); change(value); assert.throws(() => deploymentRequest(value))
+ }
+})
+test('unknown/duplicate CLI options refuse without an implicit startup mode', async () => {
+ for (const args of [[], ['publish'], ['init', '--output', '/x', '--output', '/y', '--deployment-sha256', 'd'.repeat(64)]]) await assert.rejects(main(args))
+})
+test('actual protected filesystem init, no-replace and mismatched digest; unsupported Windows writes nothing', async () => {
+ const parent = await mkdtemp(path.join(tmpdir(), 'mm-bootstrap-init-')), output = path.join(parent, 'keys'), file = path.join(parent, 'deployment.json'), bytes = Buffer.from(JSON.stringify(request()))
+ try {
+ await chmod(parent, 0o700); await writeFile(file, bytes, {mode: 0o600})
+ const options = {outputDirectory: output, deploymentFile: file, deploymentSha256: hash(bytes)}
+ if (process.platform === 'win32') { await assert.rejects(initializeBootstrap(options), /Windows ACL backend unavailable/); assert.deepEqual(await readdir(parent), ['deployment.json']); return }
+ await assert.rejects(initializeBootstrap({...options, deploymentSha256: '0'.repeat(64)})); assert.deepEqual(await readdir(parent), ['deployment.json'])
+ const receipt = await initializeBootstrap(options); assert.equal(receipt.publicationAuthorized, false); assert(!JSON.stringify(receipt).includes('PRIVATE KEY'))
+ assert.equal((await stat(output)).mode & 0o777, 0o700); assert.equal((await stat(path.join(output, 'signing-private.pem'))).mode & 0o777, 0o600)
+ const first = await readFile(path.join(output, 'signing-private.pem')); await assert.rejects(initializeBootstrap(options), {code: 'EEXIST'}); assert.deepEqual(await readFile(path.join(output, 'signing-private.pem')), first)
+ assert.deepEqual((await readdir(output)).sort(), ['bootstrap.json', 'operator-public.pem', 'signing-private.pem'])
+ assert.equal(JSON.parse(await readFile(path.join(output, 'bootstrap.json'), 'utf8')).verificationSubject.publicKeySpkiSha256, receipt.publicKeySpkiSha256)
+ } finally { await rm(parent, {recursive: true, force: true}) }
+})
diff --git a/backend/scripts/database-writer-profile-operator.mts b/backend/scripts/database-writer-profile-operator.mts
new file mode 100644
index 00000000..0792f264
--- /dev/null
+++ b/backend/scripts/database-writer-profile-operator.mts
@@ -0,0 +1,186 @@
+/** Explicit operator process only. No HTTP, runtime import, role provisioning or READY. */
+import assert from 'node:assert/strict'
+import path from 'node:path'
+import {pathToFileURL} from 'node:url'
+import {createPrivateKey,createPublicKey,sign} from 'node:crypto'
+import {readdir} from 'node:fs/promises'
+import {readProtected,protectedDirectory,sha,withJournalLease,writeFile} from './writer-profile/operator-files.mjs'
+import {approval,upgradeApproval,reconciliationApproval,poolOptions,roleKeys,assertJsDriverEnvironment} from './writer-profile/operator-contract.mjs'
+import {deploymentRequest} from './database-writer-bootstrap-operator.mjs'
+const hex=(v:unknown)=>typeof v==='string'&&/^[a-f0-9]{64}$/.test(v)
+const parse=(b:Buffer)=>JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(b))
+const sourceCommands=['source-activate','source-revoke','source-status']
+export async function main(args:string[]){
+ if(args[0]==='legacy-cold-verify')return (await import('./writer-profile/legacy-cold-verification.mjs')).verifyLegacyColdMain(args)
+ if(args[0]==='source58-foundation-enroll'||args[0]==='source57-admission-enroll')return (await import('./writer-profile/source58-foundation.mjs')).source58FoundationMain(args)
+ if(args[0]==='legacy-control-reference'||args[0]==='legacy-source58-preflight')return (await import('./writer-profile/legacy-control-reference.mjs')).legacyControlReferenceMain(args)
+ if(['legacy-handoff-execute','legacy-handoff-adopt','legacy-handoff-release'].includes(args[0]))return (await import('./writer-profile/legacy-handoff-execution.mjs')).legacyHandoffExecuteMain(args)
+ if(['registry-enroll','registry-inspect','restore-profile-enroll'].includes(args[0]))return (await import('./writer-profile/registry-enrollment.mjs')).registryEnrollmentMain(args)
+ if(args[0]==='marker-fence-enroll')return (await import('./writer-profile/marker-fence-enrollment.mjs')).markerFenceEnrollmentMain(args)
+ if(sourceCommands.includes(args[0]))return (await import('./writer-profile/source-activation.mjs')).sourceActivationMain(args)
+ if(['maintenance-inspect','maintenance-resolve'].includes(args[0]))return (await import('./writer-profile/maintenance-resolution.mjs')).maintenanceMain(args)
+ const legacyCustody=args[0]==='legacy-custody'
+ const legacyHandoff=args[0]==='legacy-handoff-inspect'
+ const legacyExport=legacyCustody||args[0]==='legacy-export'
+ const legacyInspection=legacyExport||legacyHandoff||args[0]==='legacy-inspect'
+ const catalogueInspection=args[0]==='source-catalogue-inspect'
+ const activePreflight=args[0]==='source-preflight',preflight=activePreflight||args[0]==='preflight'
+ const upgrade=args[0]==='upgrade'
+ const writes=upgrade||args[0]==='publish'
+ const flags=['bootstrap','bootstrap-sha256','transport','transport-sha256','ca','source-registry','source-spki-sha256']
+ if(!legacyInspection)flags.push('definition','definition-sha256')
+ if(!legacyInspection&&!catalogueInspection)flags.push('approval','approval-sha256','journal')
+ if(legacyInspection||catalogueInspection||activePreflight||writes)flags.push('activation-directory','activation-sha256')
+ if(legacyExport)flags.push('archive-directory','source-signing-key')
+ if(legacyHandoff)flags.push('archive-directory','handoff-intent-sha256')
+ assert((legacyInspection||catalogueInspection||preflight||writes||args[0]==='reconcile')&&args.length===1+2*flags.length)
+ assertJsDriverEnvironment(process.env)
+ const values=new Map()
+ for(let i=1;ivalues.get(name)!
+ for(const flag of flags.filter(f=>f.endsWith('sha256')))assert(hex(get(flag)))
+ const bootstrap=parse(await readProtected(get('bootstrap'),32768,get('bootstrap-sha256')))
+ assert(bootstrap.format==='application-writer-bootstrap-v1'&&bootstrap.publicationAuthorized===false&&bootstrap.readyAuthorized===false)
+ const request=deploymentRequest(bootstrap.deploymentRequest),subject=bootstrap.verificationSubject
+ assert(subject.installationId===request.installationId&&hex(subject.publicKeySpkiSha256)&&sha(createPublicKey(subject.publicKeyPem).export({format:'der',type:'spki'}))===subject.publicKeySpkiSha256)
+ const pinned=legacyInspection||catalogueInspection?undefined:(args[0]==='reconcile'?reconciliationApproval:upgrade?upgradeApproval:approval)(parse(await readProtected(get('approval'),16384,get('approval-sha256'))))
+ const definition=legacyInspection?undefined:parse(await readProtected(get('definition'),4194304,get('definition-sha256')))
+ const transport=parse(await readProtected(get('transport'),16384,get('transport-sha256')))
+ const ca=await readProtected(get('ca'),65536,request.tls.caSha256)
+ const options=poolOptions(transport,request,ca)
+ if(!legacyInspection&&!catalogueInspection)await protectedDirectory(get('journal'))
+ await protectedDirectory(get('source-registry'))
+ const privateKeyFile=path.join(path.dirname(get('bootstrap')),'signing-private.pem')
+ if(writes){const key=await readProtected(privateKeyFile,8192);key.fill(0)}
+ // All explicit trust files are checked before app helper/PG imports. No .env URL is used.
+ // Existing source helper loads config/dotenv. Complete it BEFORE pg's first
+ // import so a newly loaded NODE_PG_FORCE_NATIVE cannot select another driver.
+ const {createProtectedDatabaseSourceBindingVerifier}=await import('./writer-profile/protected-source-registry.mjs')
+ assertJsDriverEnvironment(process.env)
+ const [{default:pg},{createConnectedPublisher,requireCurrentCatalogueDefinition},{collectSource44Catalogue,collectSource56Catalogue,collectSource57Catalogue,collectSource58Catalogue,approvedDefinition}]=await Promise.all([
+ import('pg'),import('./writer-profile/publisher.mjs'),import('./writer-profile/catalogue.mjs')])
+ assertJsDriverEnvironment(process.env)
+ const reviewedDefinition=legacyInspection?undefined:approvedDefinition(definition)
+ const collectCatalogues={44:collectSource44Catalogue,56:collectSource56Catalogue,57:collectSource57Catalogue,58:collectSource58Catalogue}
+ const collectCatalogue=collectCatalogues[reviewedDefinition&&'edition' in reviewedDefinition?reviewedDefinition.edition:44]
+ if(!legacyInspection&&!catalogueInspection){
+ assert.equal(reviewedDefinition!.definitionSha256,pinned!.definitionSha256)
+ if(args[0]!=='reconcile')requireCurrentCatalogueDefinition(pinned,reviewedDefinition)
+ }
+ const installation=Object.freeze({...subject,roles:Object.fromEntries(roleKeys.map(k=>[k,request.roles[k].signedOid])),roleBindings:request.roles,expectedSource:request.source,tls:Object.freeze({...request.tls})})
+ const sourcePin={registryDirectory:get('source-registry'),installationId:subject.installationId,publicKeySpkiSha256:get('source-spki-sha256'),currentHeadSha256:request.sourceHeadSha256}
+ const archiveDirectory=legacyExport?get('archive-directory'):undefined
+ let handoff
+ if(legacyHandoff){
+ const {verifyLegacyProbeHandoffIntent}=await import('../src/services/server-probe-legacy-handoff-inspection.js')
+ const directory=get('archive-directory'),maximum=64*1024*1024
+ const [archive,signedApproval,coldArchive,intent,operatorPublicKeyPem]=await Promise.all([
+ readProtected(path.join(directory,'legacy-probe.dump'),maximum),readProtected(path.join(directory,'legacy-probe-approval.json'),4096),
+ readProtected(path.join(directory,'legacy-probe-cold.dump'),maximum),
+ readProtected(path.join(directory,'legacy-probe-handoff-intent.json'),4096,get('handoff-intent-sha256')),
+ readProtected(path.join(sourcePin.registryDirectory,'operator-public.pem'),4096),
+ ])
+ handoff=await verifyLegacyProbeHandoffIntent(sourcePin,{archive,signedApproval,coldArchive,intent,operatorPublicKeyPem})
+ }
+ // Use the same protected registry evidence for inspection and publication.
+ const verifier=createProtectedDatabaseSourceBindingVerifier(sourcePin)
+ async function connected(sourceVerifier:typeof verifier,deadlineAt:number){
+ const publisher=createConnectedPublisher(installation,(s:Parameters[0])=>collectCatalogue(s,installation),sourceVerifier,pinned,reviewedDefinition)
+ const pool=new pg.Pool(options)
+ // A pool-level async error never becomes raw stdout or a retry signal.
+ let asyncFailure=false;pool.on('error',()=>{asyncFailure=true})
+ let result,primary:unknown,failed=false
+ try{
+ const journalDirectory=get('journal')
+ if(legacyInspection)result=await publisher.inspectLegacyStorage(pool,{deadlineAt,archiveDirectory,custody:legacyCustody,handoff})
+ else if(catalogueInspection)result=await publisher.inspectCurrentCatalogue(pool,{deadlineAt})
+ else if(preflight)result=await publisher.preflightCurrentProfile(pool,{deadlineAt})
+ else if(args[0]==='reconcile')result=await publisher.reconcilePendingPublication(pool,{journalDirectory,deadlineAt})
+ else{
+ const publication={privateKeyFile,expectedHeadSha256:pinned.expectedHeadSha256,journalDirectory,validityMs:pinned.validityMs,deadlineAt}
+ result=upgrade?await publisher.upgradeCurrentProfile(pool,publication):await publisher.publishCurrentProfile(pool,publication)
+ }
+ }
+ catch(error){primary=error;failed=true}
+ try{await pool.end()}catch(error){primary??=error;failed=true}
+ if(legacyInspection&&result?.state==='observed'&&result.source.platformProtectionVerified===true&&!failed&&!asyncFailure){
+ const {installationId,sourceIdentityId,generation,ordinal,headSha256,bindingSha256}=result.source
+ if(legacyHandoff){assert(result.resolution);return {event:'database-legacy-handoff-inspection',...result.resolution,sourceActivationMatched:true,conversionAllowed:false}}
+ return {...(legacyExport?{archive:result.archive}:{}),...(result.lineageSnapshot?{lineageSnapshot:result.lineageSnapshot}:{}),event:'database-legacy-inspection',outcome:'observed',snapshot:result.snapshot,
+ source:{installationId,sourceIdentityId,generation,ordinal,headSha256,bindingSha256},sourceActivationMatched:true,
+ platformProtectionVerified:true,generationAuthenticated:false,allWriterDrainAuthenticated:false,
+ conversionAllowed:false,readyAuthorized:false,automaticReplay:false}
+ }
+ if(catalogueInspection&&result?.state==='observed'&&result.platformProtectionVerified===true&&!failed&&!asyncFailure){
+ const {state:_state,...catalogue}=result
+ return {event:'application-writer-source-catalogue-inspection',outcome:'observed',...catalogue,automaticReplay:false,writerAuthorized:false}
+ }
+ if(preflight&&result?.state==='matched'&&result.platformProtectionVerified===true&&!failed&&!asyncFailure)return {event:'application-writer-profile-preflight',outcome:'matched',epoch:result.epoch,headSha256:result.headSha256,notAfter:result.notAfter,sourceMatched:true,rolesMatched:true,catalogueMatched:true,platformProtectionVerified:true,writerAuthorized:false,cleanupUnconfirmed:false,automaticReplay:false,generationAuthenticated:false,readyAuthorized:false}
+ if(result?.outcome==='committed')return {event:'application-writer-profile-publication',outcome:'committed',epoch:result.epoch,headSha256:result.headSha256,notAfter:result.notAfter,
+ cleanupUnconfirmed:result.cleanupUnconfirmed||asyncFailure||failed,journalUnconfirmed:!!result.journalUnconfirmed,automaticReplay:false,generationAuthenticated:false,readyAuthorized:false}
+ if(args[0]==='reconcile'&&result&&!failed&&!asyncFailure&&['idle','confirmed','not-committed'].includes(result.state))return {event:'application-writer-profile-reconciliation',outcome:result.state,headSha256:result.headSha256??null,cleanupUnconfirmed:false,journalUnconfirmed:false,automaticReplay:false,generationAuthenticated:false,readyAuthorized:false}
+ throw primary??Error('Publisher terminal unconfirmed')
+ }
+ const deadlineAt=Date.now()+120000
+ if(!legacyInspection&&!catalogueInspection&&!activePreflight&&!writes)return connected(verifier,deadlineAt)
+ const {withActiveSource}=await import('./writer-profile/source-activation.mjs')
+ const publisherRole=request.roles.publisher.name
+ const expectedSource={...request.source,databaseOid:Number(request.source.databaseOid),sessionUser:publisherRole,currentUser:publisherRole}
+ const active=()=>withActiveSource({directory:get('activation-directory'),expectedSha256:get('activation-sha256'),sourcePin,expectedSource,tlsSpkiSha256:request.tls.spkiSha256,deadlineAt},verifier,
+ guardedVerifier=>connected(guardedVerifier,deadlineAt))
+ if(archiveDirectory)return withJournalLease(archiveDirectory,async()=>{
+ assert.deepEqual(await readdir(archiveDirectory),['publisher-lease.lock'],'Empty protected archive directory required')
+ const keyBytes=await readProtected(get('source-signing-key'),8192)
+ let key
+ try{key=createPrivateKey(keyBytes)}finally{keyBytes.fill(0)}
+ assert(key.asymmetricKeyType==='ed25519'&&sha(createPublicKey(key).export({type:'spki',format:'der'}))===sourcePin.publicKeySpkiSha256,'Source signer differs from deployment pin')
+ const {sourceBindingBytes,sourceBindingCanonical}=await import('../src/db/database-source-binding.js')
+ const {LEGACY_PROBE_ARCHIVE_APPROVAL_DOMAIN,LEGACY_PROBE_CUSTODY_APPROVAL_DOMAIN}=await import('../src/services/server-probe-legacy-archive-approval.js')
+ const result=await active()
+ assert(result.event==='database-legacy-inspection'&&Buffer.isBuffer(result.archive)&&Date.now()createHash('sha256').update(v).digest('hex')
+const pinned=()=>({format:'application-writer-publication-approval-v1',manifestSha256:'a'.repeat(64),definitionSha256:'b'.repeat(64),catalogSha256:'c'.repeat(64),expectedHeadSha256:null,validityMs:86400000,expiresAt:Date.now()+60000})
+test('approval is explicit, exact, future-bounded and does not learn missing expected fields',()=>{
+ const value=pinned();assert.deepEqual(approval(value),value)
+ for(const change of [(v:any)=>delete v.definitionSha256,(v:any)=>delete v.catalogSha256,(v:any)=>v.expiresAt=Date.now(),(v:any)=>v.validityMs=86400001,(v:any)=>v.expectedHeadSha256='observed',(v:any)=>v.provider=true]){const v=pinned();change(v);assert.throws(()=>approval(v))}
+})
+test('isolated Pool1 options require pinned CA/host/role/database and native TLS verification',()=>{
+ const ca=Buffer.from(rootCertificates[0]),request={roles:{publisher:{name:'installation_policy_signer'}},source:{databaseName:'owned'},tls:{serverName:'db.example.invalid',caSha256:hash(ca),spkiSha256:hash(new X509Certificate(ca).publicKey.export({format:'der',type:'spki'}))}}
+ const transport={host:'db.example.invalid',port:5432,user:'installation_policy_signer',password:'test-only',database:'owned'},config=poolOptions(transport,request,ca)
+ assert.equal(config.max,1);assert.equal(config.connectionTimeoutMillis,5000);assert.equal(config.ssl.rejectUnauthorized,true)
+ assert(config.ssl.checkServerIdentity('attacker.invalid',new X509Certificate(ca).toLegacyObject()) instanceof Error)
+ for(const changed of [{...transport,user:'admin'},{...transport,host:'attacker.invalid'},{...transport,database:'other'},{...transport,connectionString:'postgres://env-substitution'},{...transport,port:0}])assert.throws(()=>poolOptions(changed,request,ca))
+ assert.throws(()=>poolOptions(transport,request,Buffer.from('not approved CA')))
+})
+test('real production envelope parser accepts operator-key signature and rejects tamper/foreign key',()=>{
+ const now=Date.now(),{publicKey,privateKey}=generateKeyPairSync('ed25519'),installation={installationId:'788629ed-e00d-4af8-bc33-c705e5a7b62d',publicKeyPem:publicKey.export({type:'spki',format:'pem'}).toString(),publicKeySpkiSha256:hash(publicKey.export({type:'spki',format:'der'}))}
+ const body={format:'application-writer-policy-v1',installationId:installation.installationId,epoch:'1',issuedAt:now,notBefore:now,notAfter:now+86400000,source:{systemIdentifier:'7348518042453055651',databaseOid:'16384',databaseName:'owned',serverVersionNum:180004,inRecovery:false},sourceObservationSha256:'a'.repeat(64),roles:{runtime:'20001',operator:'20002',capture:'20003',publisher:'20004',control:'20005'},manifestSha256:'b'.repeat(64),definitionSha256:'c'.repeat(64),catalogSha256:'d'.repeat(64),futureLeaves:'fixed12-native-policy-v1'}
+ const signature=sign(null,Buffer.from(POLICY_DOMAIN+canonical(body)),privateKey).toString('base64url')
+ assert.equal(signedEnvelope(bytes({body,signature}),'policy',installation).body.epoch,'1')
+ assert.throws(()=>signedEnvelope(bytes({body:{...body,catalogSha256:'e'.repeat(64)},signature}),'policy',installation))
+ const other=generateKeyPairSync('ed25519').publicKey;assert.throws(()=>signedEnvelope(bytes({body,signature}),'policy',{...installation,publicKeyPem:other.export({type:'spki',format:'pem'}).toString(),publicKeySpkiSha256:hash(other.export({type:'spki',format:'der'}))}))
+})
+test('actual pg ConnectionParameters cannot inherit malicious PGOPTIONS and native selection refuses',()=>{
+ const require=createRequire(new URL('../package.json',import.meta.url)),ConnectionParameters=require('pg/lib/connection-parameters')
+ const original=process.env.PGOPTIONS;process.env.PGOPTIONS='-c role=attacker -c search_path=attacker'
+ try{
+ const ca=Buffer.from(rootCertificates[0]),request={roles:{publisher:{name:'installation_policy_signer'}},source:{databaseName:'owned'},tls:{serverName:'db.example.invalid',caSha256:hash(ca),spkiSha256:'a'.repeat(64)}}
+ const config=poolOptions({host:'db.example.invalid',port:5432,user:'installation_policy_signer',password:'test-only',database:'owned'},request,ca)
+ const actual=new ConnectionParameters(config);assert.equal(actual.options,STARTUP_OPTIONS);assert(!actual.options.includes('attacker'));assert.match(actual.options,/(^| )-c jit=off( |$)/);assert.equal(actual.user,'installation_policy_signer');assert.equal(actual.ssl.rejectUnauthorized,true)
+ }finally{if(original===undefined)delete process.env.PGOPTIONS;else process.env.PGOPTIONS=original}
+ assert.doesNotThrow(()=>assertJsDriverEnvironment({}));for(const value of ['1','0','',undefined])assert.throws(()=>assertJsDriverEnvironment({NODE_PG_FORCE_NATIVE:value}))
+})
+
+test('reconciliation accepts expired original approval as copied inspection data; publication still refuses',()=>{
+ const value={...pinned(),expiresAt:1},copy=reconciliationApproval(value)
+ assert.deepEqual(copy,value);assert.notEqual(copy,value);assert.throws(()=>approval(value))
+ copy.catalogSha256='d'.repeat(64);assert.equal(value.catalogSha256,'c'.repeat(64))
+ const future=pinned();assert.deepEqual(approval(future),reconciliationApproval(future))
+})
+test('reconciliation keeps exact digest/head/schema and original lifetime bounds',()=>{
+ for(const mutate of [(v:any)=>delete v.definitionSha256,(v:any)=>v.catalogSha256='observed',(v:any)=>v.expectedHeadSha256='foreign',(v:any)=>v.extra=true,(v:any)=>v.format='other',(v:any)=>v.validityMs=0,(v:any)=>v.validityMs=86400001,(v:any)=>v.expiresAt=0,(v:any)=>v.expiresAt=-1,(v:any)=>v.expiresAt=Number.MAX_SAFE_INTEGER+1]){
+ const value={...pinned(),expiresAt:1};mutate(value);assert.throws(()=>reconciliationApproval(value));assert.throws(()=>approval(value))
+ }
+})
+test('publication expiry guard remains mandatory at the real clock boundary',()=>{
+ const value=pinned();value.expiresAt=Date.now();assert.throws(()=>approval(value));assert.deepEqual(reconciliationApproval(value),value)
+})
+test('restore rebind requires a protected exact old head and changed approved catalogue',()=>{
+ const value={...pinned(),format:REBIND58_APPROVAL_FORMAT,previousCatalogSha256:'d'.repeat(64),expectedHeadSha256:'e'.repeat(64)}
+ assert.deepEqual(upgradeApproval(value),value)
+ assert.throws(()=>approval(value))
+ assert.throws(()=>upgradeApproval({...value,previousCatalogSha256:value.catalogSha256}))
+ assert.throws(()=>upgradeApproval({...value,expectedHeadSha256:null}))
+ assert.throws(()=>upgradeApproval({...value,expiresAt:1}))
+})
diff --git a/backend/scripts/database-writer-profile-preflight.test.mts b/backend/scripts/database-writer-profile-preflight.test.mts
new file mode 100644
index 00000000..0d7bc996
--- /dev/null
+++ b/backend/scripts/database-writer-profile-preflight.test.mts
@@ -0,0 +1,355 @@
+// Candidate component tests. Actual signature/current reader, modeled PG/source/catalogue.
+// No genuine SQL, TLS session, filesystem ACL or generation acceptance is claimed.
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import fs from 'node:fs/promises'
+import {createRequire} from 'node:module'
+import {runInNewContext} from 'node:vm'
+import {EventEmitter} from 'node:events'
+import path from 'node:path'
+import * as format from '../src/db/application-writer-profile-format.ts'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../src/db/migration-manifest.ts'
+import {readCurrentApplicationWriterProfile} from '../src/db/application-writer-profile-registry-read.ts'
+import {syntheticFixture,stagedModelClient} from '../src/db/application-writer-profile-registry-read-model.test.ts'
+import {approvedDefinition} from './writer-profile/catalogue.mts'
+import {BUILD44_PROVENANCE,FIXED44_ROLE_TEMPLATE} from './writer-profile/fixed44-build-definition.ts'
+import {BUILD56_PROVENANCE} from './writer-profile/fixed56-build-definition.ts'
+import {BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE} from './writer-profile/fixed57-build-definition.ts'
+import {approval as parseApproval,upgradeApproval,reconciliationApproval,isUpgradeApprovalFormat,UPGRADE_APPROVAL_FORMAT,UPGRADE57_APPROVAL_FORMAT} from './writer-profile/operator-contract.mjs'
+const require=createRequire(new URL('../package.json',import.meta.url)),ts=require('typescript'),pg=require('pg')
+const candidate=await fs.readFile(new URL('./writer-profile/publisher.mjs',import.meta.url),'utf8')
+interface PreflightDiagnostics {state:string;headSha256:string;sourceMatched:boolean;rolesMatched:boolean;catalogueMatched:boolean;platformProtectionVerified:boolean;writerAuthorized:boolean;generationAuthenticated:boolean;readyAuthorized:boolean}
+type PublishOptions={privateKeyFile:string;expectedHeadSha256:string|null;journalDirectory:string;deadlineAt:number;validityMs?:number}
+interface PublisherModule {
+ requireCurrentCatalogueDefinition(approval:unknown,definition:unknown):string
+ createConnectedPublisher(installation:unknown,collect:()=>Promise,sourceVerifier:{verify:()=>Promise<{platformProtectionVerified:boolean}>},approval:unknown,definition:unknown):{
+ inspectLegacyStorage(pool:unknown,options:{deadlineAt:number}):Promise<{state:string;snapshot:{rowCount:number}}>
+ preflightCurrentProfile(pool:unknown,options:{deadlineAt:number}):Promise
+ publishCurrentProfile(pool:unknown,options:PublishOptions):Promise<{outcome:string}>
+ upgradeCurrentProfile(pool:unknown,options:PublishOptions):Promise<{outcome:string;epoch:string;headSha256:string}>
+ }
+}
+interface OperatorModule {main(args:string[]):Promise<{event:string;outcome:string;platformProtectionVerified:boolean;writerAuthorized:boolean;readyAuthorized:boolean;sourceActivationMatched?:boolean}>}
+function compile(source:string,modules:Record):T{
+ const exports:Record={};const compiled=ts.transpileModule(source.split('\nif(process.argv[1]')[0].replaceAll('import.meta.url',JSON.stringify('file:///candidate-not-cli.mts')),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText
+ runInNewContext(compiled,{exports,require:(name:string)=>{assert(name in modules,'Unapproved import '+name);return modules[name]},Buffer,URL,TextDecoder,Date,setTimeout,clearTimeout,Object,Error,AggregateError,Promise,Map,Set,process:{env:{},argv:[]}}, {filename:'candidate.mjs'})
+ // The isolated VM loads the exact source above; tests exercise this narrow export contract.
+ return exports as T
+}
+const frozenDefinition=approvedDefinition({format:'application-writer-source44-definition-approval-v1',provenance:BUILD44_PROVENANCE,template:FIXED44_ROLE_TEMPLATE})
+const frozenMigrations=MIGRATION_MANIFEST.slice(0,44),markerIds=frozenMigrations.map(pin=>pin.file.slice(0,-4))
+const markerSql='SELECT id FROM public.schema_migrations ORDER BY id COLLATE "C" LIMIT $1'
+function fixture(fault='',forPublication=false,upgradeMode?:'upgrade'|'upgrade57'|'ordinary-renewal'){
+ const f=syntheticFixture('1'),security={sha256:'e'.repeat(64),roles:{...f.policy.roles}}
+ const predecessor=upgradeMode==='upgrade57'?BUILD56_PROVENANCE:BUILD44_PROVENANCE
+ const successor=upgradeMode==='upgrade57'?BUILD57_PROVENANCE:BUILD56_PROVENANCE
+ const target=upgradeMode?{definitionSha256:successor.templateSha256,manifestSha256:successor.manifestSha256}:frozenDefinition
+ const targetMigrations=MIGRATION_MANIFEST.slice(0,upgradeMode==='upgrade57'?57:56)
+ const catalogue={...target,catalogSha256:'f'.repeat(64),leafCount:117}
+ const currentBuild=fault==='current-build'||fault==='current-approved-frozen-definition'
+ f.policy.manifestSha256=predecessor.manifestSha256;f.policy.definitionSha256=predecessor.templateSha256
+ f.policy.catalogSha256=upgradeMode?'d'.repeat(64):format.sha(format.canonical({base:catalogue.catalogSha256,security:security.sha256}))
+ if(fault==='signed-source')f.policy.source.databaseOid='999'
+ if(fault==='signed-role')f.policy.roles.operator='99'
+ if(fault==='signed-catalogue')f.policy.catalogSha256='1'.repeat(64)
+ if(fault==='signed-definition')f.policy.definitionSha256='1'.repeat(64)
+ if(fault==='signed-manifest')f.policy.manifestSha256='1'.repeat(64)
+ if(fault==='expired'){f.policy.issuedAt=Date.now()-60000;f.policy.notBefore=f.policy.issuedAt;f.policy.notAfter=Date.now()-1000}
+ const raw=f.signBody(f.policy,format.POLICY_DOMAIN),hash=format.sha(raw),top=f.state.latest[0]
+ top.policy_sha256=hash;top.head_bytes=f.signBody({format:'application-writer-head-v1',installationId:f.subject.installationId,epoch:'1',policySha256:hash,previousHeadSha256:null},format.HEAD_DOMAIN);top.head_sha256=format.sha(top.head_bytes)
+ f.state.current[0].head_sha256=top.head_sha256;f.state.policy=[{policy_sha256:hash,policy_bytes:raw}]
+ const priorHead=top.head_sha256
+ if(fault==='tamper')f.state.policy[0].policy_bytes=Buffer.from(raw.toString().replace('synthetic','tampered'))
+ if(fault==='empty'){f.state.current=[];f.state.latest=[];f.state.policy=[]}
+ const model=stagedModelClient(f.state),queries:string[]=[],events:string[]=[],markerLimits:unknown[][]=[]
+ const writes:{sql:string;values?:unknown[]}[]=[]
+ let clocks=0,checkouts=0
+ const client=Object.assign(new EventEmitter(),{query:async(sql:string,values?:unknown[])=>{
+ queries.push(sql)
+ if(/^(INSERT|UPDATE) INTO |^UPDATE mmapp_control\./.test(sql))writes.push({sql,values})
+ if(sql.includes('clock_timestamp()')&&++clocks===2&&fault==='late-clock')return {rows:[{now:'1'}]}
+ if(sql===markerSql){
+ markerLimits.push(values??[])
+ const expected=upgradeMode?targetMigrations.map(pin=>pin.file.slice(0,-4)):markerIds
+ const ids=fault==='marker-missing'?expected.slice(0,-1):fault==='marker-extra'||fault==='marker-drift'&&markerLimits.length===2?[...expected,'9999_foreign']:expected
+ return {rows:ids.map(id=>({id}))}
+ }
+ if(sql.startsWith('WITH')||sql.includes('clock_timestamp()'))return model.client.query(sql,values)
+ if(sql.startsWith('SELECT pg_catalog.pg_advisory_unlock'))return {rows:[{released:true}]}
+ if(sql==='ROLLBACK')return {rows:[],command:fault==='rollback-ack'?'':'ROLLBACK'}
+ if(sql.startsWith('INSERT INTO mmapp_control.current')||sql.startsWith('UPDATE mmapp_control.current'))return {rows:[{id:1}]}
+ return {rows:[],command:sql.split(' ')[0]}
+ },release:(bad:boolean)=>{events.push('release:'+bad)}})
+ const pool=new pg.Pool();pool.connect=async()=>{checkouts++;return client}
+ const source={systemIdentifier:'123',databaseOid:'456',databaseName:'synthetic',serverVersionNum:180004,inRecovery:false}
+ let contexts=0,verifications=0
+ const installation={...f.subject,expectedSource:source,roleBindings:{publisher:{name:'publisher',signedOid:'14'}}}
+ const pinned={expiresAt:Date.now()+60000,manifestSha256:['approval-manifest','current-approved-frozen-definition'].includes(fault)?migrationManifestDigest():target.manifestSha256,definitionSha256:catalogue.definitionSha256,catalogSha256:format.sha(format.canonical({base:catalogue.catalogSha256,security:security.sha256})),...(upgradeMode==='upgrade'||upgradeMode==='upgrade57'?{
+ format:upgradeMode==='upgrade57'&&fault!=='wrong-transition'?UPGRADE57_APPROVAL_FORMAT:UPGRADE_APPROVAL_FORMAT,expectedHeadSha256:fault==='wrong-head'?'0'.repeat(64):priorHead,previousCatalogSha256:fault==='wrong-previous-catalogue'?'0'.repeat(64):'d'.repeat(64),validityMs:60000,
+ }:{})}
+ const definition=fault==='static-definition'?{...target,definitionSha256:'0'.repeat(64)}:target
+ const privateKeyFile=path.resolve('modeled-fixture-key.pem'),journalDirectory=path.resolve('modeled-journal'),files=new Map()
+ if(forPublication)files.set(privateKeyFile,Buffer.from(f.privateKey.export({format:'pem',type:'pkcs8'})))
+ function file(filename:string){const value=files.get(filename);if(!value)throw Object.assign(Error('Fixture file absent'),{code:'ENOENT'});return value}
+ function stat(filename:string){return {size:file(filename).length,dev:1,ino:1,isFile:()=>true,isSymbolicLink:()=>false}}
+ const modules={
+ pg,'node:crypto':require('node:crypto'),'node:fs/promises':{realpath:async(file:string)=>file,lstat:async(filename:string)=>stat(filename),unlink:async(filename:string)=>files.delete(filename),open:async(filename:string)=>({stat:async()=>stat(filename),readFile:async()=>Buffer.from(file(filename)),close:async()=>{}})},'node:path':path,
+ './fixed44-build-definition.js':{BUILD44_PROVENANCE},'./fixed56-build-definition.js':{BUILD56_PROVENANCE},'./fixed57-build-definition.js':{BUILD57_PROVENANCE},
+ './operator-contract.mjs':{UPGRADE_APPROVAL_FORMAT,UPGRADE57_APPROVAL_FORMAT,isUpgradeApprovalFormat,upgradeApproval,retainPublisherTlsPeer:(actual:unknown)=>{
+ assert.equal(actual,client)
+ if(fault==='initial-tls')throw Error('TLS peer refused')
+ return ()=>{if(fault==='lost-tls'&&verifications===2)throw Error('Retained TLS lost')}
+ }},
+ './operator-files.mjs':{withJournalLease:async(_directory:string,work:()=>Promise)=>{assert(forPublication);events.push('journal-lease');return work()},writeFile:async(filename:string,value:Buffer)=>{assert(forPublication);files.set(filename,value)}},
+ '../../src/db/database-source-observation.js':{captureDatabaseSourceObservation:async()=>{events.push('capture-source');return {}},assertDatabaseSourceObservationCurrent:async()=>{events.push('fresh-source');if(fault==='late-source')throw Error('Source changed')}},
+ '../../src/services/server-probe-legacy-source-inventory.js':{captureLegacyProbeStorage:async()=>{events.push('capture-legacy');return {rowCount:1}}},
+ '../../src/db/migration-manifest.js':{MIGRATION_MANIFEST:currentBuild?MIGRATION_MANIFEST:upgradeMode?targetMigrations:frozenMigrations,migrationManifestDigest:()=>currentBuild?migrationManifestDigest():target.manifestSha256},
+ '../../src/db/application-writer-profile-format.js':format,
+ './context.mjs':{ownedContext:async()=>{contexts++;if(fault==='late-actor'&&contexts===2)throw Error('Actor changed');return {pid:1,source}},sameOwned:(a:unknown,b:unknown)=>assert.deepEqual(a,b),sourceCoordinates:(v:{source:typeof source})=>v.source,protectedStructure:async()=>{events.push('roles');if(fault==='role-structure')throw Error('Unsafe role');return security},readCurrent:forPublication&&!upgradeMode?async()=>null:readCurrentApplicationWriterProfile,HISTORY:'history',CURRENT:'current'},
+ }
+ const api=compile(candidate,modules).createConnectedPublisher(installation,async()=>{events.push('catalogue');if(fault==='catalogue-eof')throw Error('Incomplete EOF');return fault==='catalogue-manifest'?{...catalogue,manifestSha256:migrationManifestDigest()}:fault==='catalogue-definition'?{...catalogue,definitionSha256:'0'.repeat(64)}:catalogue},{verify:async()=>{verifications++;events.push('verify-source');if(fault==='source-verifier')throw Error('Unsigned source');if(fault==='late-expiry'&&verifications===2)pinned.expiresAt=1;return {platformProtectionVerified:!(fault==='initial-unprotected'&&verifications===1||fault==='terminal-unprotected'&&verifications===2)}}},pinned,definition)
+ const publication=()=>({privateKeyFile,journalDirectory,expectedHeadSha256:upgradeMode?pinned.expectedHeadSha256??priorHead:null,deadlineAt:Date.now()+30000,validityMs:60000})
+ return {run:()=>api.preflightCurrentProfile(pool,{deadlineAt:Date.now()+30000}),inspectLegacy:()=>api.inspectLegacyStorage(pool,{deadlineAt:Date.now()+30000}),publish:()=>api.publishCurrentProfile(pool,publication()),upgrade:()=>api.upgradeCurrentProfile(pool,publication()),queries,events,markerLimits,files,writes,priorHead,pinned,get checkouts(){return checkouts},f}
+}
+test('legacy inspection requires retained TLS, terminal source proof and acknowledged rollback',async()=>{
+ const valid=fixture(),result=await valid.inspectLegacy()
+ assert.equal(result.state,'observed');assert.equal(result.snapshot.rowCount,1);assert.equal(valid.checkouts,1)
+ assert.deepEqual(valid.events,['capture-source','verify-source','capture-legacy','verify-source','fresh-source','release:false'])
+ assert.equal(valid.queries.filter(q=>q==='ROLLBACK').length,1);assert(!valid.queries.includes('COMMIT'))
+ for(const fault of ['initial-tls','lost-tls','late-source','rollback-ack'])await assert.rejects(fixture(fault).inspectLegacy())
+})
+test('current44 preflight authenticates signed current and actual component inputs on one read-only lease',async()=>{
+ const f=fixture(),result=await f.run();assert.equal(result.state,'matched');assert.equal(result.headSha256,f.f.state.current[0].head_sha256)
+ assert.equal(result.sourceMatched,true);assert.equal(result.rolesMatched,true);assert.equal(result.catalogueMatched,true)
+ assert.equal(result.platformProtectionVerified,true)
+ assert.equal(result.writerAuthorized,false);assert.equal(result.generationAuthenticated,false);assert.equal(result.readyAuthorized,false)
+ assert.equal(f.queries.filter(q=>q.startsWith('BEGIN')).length,1);assert(f.queries.includes('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY'));assert.equal(f.queries.filter(q=>q==='ROLLBACK').length,1)
+ assert.equal(format.canonical(f.markerLimits),'[[45]]')
+ assert(!f.queries.some(q=>/^(?:INSERT|UPDATE|DELETE|COMMIT|CREATE|ALTER|DROP)\b/.test(q)));assert.equal(f.events.at(-1),'release:false')
+ assert.deepEqual(f.events.slice(0,6),['capture-source','verify-source','roles','catalogue','verify-source','fresh-source'])
+})
+test('publisher refuses before SQL on a wrong peer and stops SQL when the retained TLS socket is lost',async()=>{
+ const initial=fixture('initial-tls')
+ await assert.rejects(initial.run());assert.deepEqual(initial.queries,[]);assert.deepEqual(initial.events,['release:true'])
+ const lost=fixture('lost-tls')
+ await assert.rejects(lost.run());assert.equal(lost.events.at(-1),'release:true')
+ assert(!lost.queries.some(q=>q==='ROLLBACK'||q.includes('pg_advisory_unlock')))
+})
+for(const fault of ['initial-unprotected','terminal-unprotected'])test('preflight cannot promote '+fault+' into protected evidence',async()=>{
+ const f=fixture(fault),result=await f.run();assert.equal(result.platformProtectionVerified,false)
+ assert.equal(result.writerAuthorized,false);assert.equal(result.readyAuthorized,false)
+ assert(!f.queries.some(q=>/^(?:INSERT|UPDATE|DELETE|COMMIT|CREATE|ALTER|DROP)\b/.test(q)))
+})
+for(const fault of ['tamper','empty','expired','signed-source','signed-role','signed-catalogue','signed-definition','signed-manifest','role-structure','catalogue-eof','source-verifier','late-source','late-actor','late-expiry','late-clock','rollback-ack'])test('preflight refuses '+fault+' without any write or replay',async()=>{
+ const f=fixture(fault);await assert.rejects(f.run());assert(!f.queries.some(q=>/^(?:INSERT|UPDATE|DELETE|COMMIT|CREATE|ALTER|DROP)\b/.test(q)));assert.equal(f.queries.filter(q=>q.startsWith('BEGIN')).length,1)
+})
+for(const fault of ['current-build','current-approved-frozen-definition','approval-manifest','static-definition'])test('incompatible static manifest/definition refuses '+fault+' before either pool checkout or publication lease',async()=>{
+ const f=fixture(fault,true)
+ await assert.rejects(f.run(),/Approved catalogue definition is not bound/)
+ await assert.rejects(f.publish(),/Approved catalogue definition is not bound/)
+ assert.equal(f.checkouts,0);assert.deepEqual(f.events,[]);assert.deepEqual(f.queries,[])
+})
+for(const fault of ['catalogue-manifest','catalogue-definition','marker-missing','marker-extra'])test('retained preflight refuses '+fault+' and rolls back',async()=>{
+ const f=fixture(fault)
+ await assert.rejects(f.run(),error=>error instanceof Error&&/Catalogue evidence differs|Exact current migration marker/.test((error.cause as Error).message))
+ assert.equal(f.checkouts,1);assert.equal(f.queries.filter(q=>q==='ROLLBACK').length,1)
+ assert(!f.queries.some(q=>/^(?:INSERT|UPDATE|DELETE|COMMIT)\b/.test(q)))
+ if(fault.startsWith('marker-'))assert.equal(format.canonical(f.markerLimits),'[[45]]')
+ else assert.deepEqual(f.markerLimits,[])
+})
+test('publication checks exact marker set on both retained transactions and refuses late marker drift before registry writes',async()=>{
+ const positive=fixture('',true)
+ assert.equal((await positive.publish()).outcome,'committed')
+ assert.equal(positive.checkouts,1);assert.equal(format.canonical(positive.markerLimits),'[[45],[45]]')
+ assert.equal(positive.queries.filter(q=>q==='COMMIT').length,2)
+ const drift=fixture('marker-drift',true)
+ await assert.rejects(drift.publish(),error=>error instanceof Error&&/Exact current migration marker/.test((error.cause as Error).message))
+ assert.equal(drift.checkouts,1);assert.equal(format.canonical(drift.markerLimits),'[[45],[45]]')
+ assert.equal(drift.queries.filter(q=>q==='COMMIT').length,1);assert.equal(drift.queries.filter(q=>q==='ROLLBACK').length,1)
+ assert(!drift.queries.some(q=>/^(?:INSERT|UPDATE|DELETE)\b/.test(q)))
+ assert([...drift.files.keys()].some(filename=>filename.endsWith('pending-publication.json')))
+})
+test('explicit 44 to 56 upgrade pins the signed predecessor, exact catalogue and CAS',async()=>{
+ const f=fixture('',true,'upgrade')
+ const approved=upgradeApproval(f.pinned)
+ assert.equal(approved.expectedHeadSha256,f.priorHead)
+ assert.throws(()=>parseApproval(approved))
+ for(const changed of [{expectedHeadSha256:null},{previousCatalogSha256:undefined},{expiresAt:1}]) {
+ assert.throws(()=>upgradeApproval({...approved,...changed}))
+ }
+ assert.equal(reconciliationApproval({...approved,expiresAt:1}).expectedHeadSha256,f.priorHead)
+ const result=await f.upgrade()
+ assert.equal(result.outcome,'committed');assert.equal(result.epoch,'2')
+ assert.equal(format.canonical(f.markerLimits),'[[57],[57]]')
+ assert.equal(f.writes.length,2)
+ const [history,current]=f.writes
+ assert.match(history.sql,/INSERT INTO mmapp_control.history/)
+ assert.equal(format.canonical(history.values?.slice(0,6)),format.canonical([f.f.subject.installationId,'2',result.headSha256,f.f.subject.installationId,'1',f.priorHead]))
+ const policy=format.signedEnvelope(history.values![7] as Buffer,'policy',f.f.subject).body
+ const head=format.signedEnvelope(history.values![8] as Buffer,'head',f.f.subject).body
+ assert.deepEqual(policy.source,f.f.policy.source);assert.deepEqual(policy.roles,f.f.policy.roles)
+ assert.equal(policy.manifestSha256,BUILD56_PROVENANCE.manifestSha256);assert.equal(policy.definitionSha256,BUILD56_PROVENANCE.templateSha256)
+ assert.equal(head.previousHeadSha256,f.priorHead)
+ assert.equal(format.canonical(current.values),format.canonical(['2',result.headSha256,f.f.subject.installationId,'1',f.priorHead]))
+})
+
+test('upgrade refuses drift and ordinary renewal cannot perform the 44 to 56 transition',async()=>{
+ for(const fault of ['wrong-head','wrong-previous-catalogue','signed-manifest','signed-definition','signed-role','signed-source','marker-drift','initial-unprotected','terminal-unprotected']){
+ const f=fixture(fault,true,'upgrade')
+ await assert.rejects(f.upgrade())
+ assert.deepEqual(f.writes,[],fault)
+ }
+ const explicit=fixture('',true,'upgrade')
+ await assert.rejects(explicit.publish(),/explicit upgrade command/)
+ assert.equal(explicit.checkouts,0)
+ const renewal=fixture('',true,'ordinary-renewal')
+ await assert.rejects(renewal.publish(),error=>error instanceof Error&&/Renewal cannot adopt/.test((error.cause as Error).message))
+ assert.deepEqual(renewal.writes,[])
+})
+
+test('explicit 56 to 57 upgrade signs only the exact reviewed successor',async()=>{
+ const definition=approvedDefinition({format:'application-writer-source57-definition-approval-v1',provenance:BUILD57_PROVENANCE,template:FIXED57_ROLE_TEMPLATE})
+ assert.equal(definition.manifestSha256,migrationManifestDigest())
+ assert.throws(()=>approvedDefinition({format:'application-writer-source57-definition-approval-v1',provenance:BUILD57_PROVENANCE,template:FIXED44_ROLE_TEMPLATE}))
+ const f=fixture('',true,'upgrade57')
+ await assert.rejects(f.publish(),/explicit upgrade command/)
+ const result=await f.upgrade()
+ assert.equal(result.outcome,'committed')
+ assert.equal(format.canonical(f.markerLimits),'[[58],[58]]')
+ const history=f.writes[0]
+ const policy=format.signedEnvelope(history.values![7] as Buffer,'policy',f.f.subject).body
+ const head=format.signedEnvelope(history.values![8] as Buffer,'head',f.f.subject).body
+ assert.equal(policy.manifestSha256,definition.manifestSha256)
+ assert.equal(policy.definitionSha256,definition.definitionSha256)
+ assert.equal(head.previousHeadSha256,f.priorHead)
+ for(const fault of ['wrong-transition','wrong-previous-catalogue','signed-manifest','signed-definition']){
+ const refused=fixture(fault,true,'upgrade57')
+ await assert.rejects(refused.upgrade())
+ assert.deepEqual(refused.writes,[],fault)
+ }
+})
+
+test('operator requires the protected source verifier for preflight, publication and reconciliation',async()=>{
+ const cli=await fs.readFile(new URL('./database-writer-profile-operator.mts',import.meta.url),'utf8'),f=syntheticFixture('1'),reads:string[]=[],events:string[]=[]
+ const request={installationId:f.subject.installationId,roles:Object.fromEntries(['runtime','operator','capture','publisher','control'].map((k,i)=>[k,{name:k,signedOid:String(i+11)}])),source:f.policy.source,sourceHeadSha256:'a'.repeat(64),tls:{caSha256:'a'.repeat(64),spkiSha256:'d'.repeat(64)}}
+ const files:Record={bootstrap:{format:'application-writer-bootstrap-v1',publicationAuthorized:false,readyAuthorized:false,deploymentRequest:request,verificationSubject:f.subject},approval:{expiresAt:Date.now()+60000,definitionSha256:'b'.repeat(64)},definition:{},transport:{},ca:'fixture','signing-private.pem':'fixture'}
+ let failEnd=false,asyncError=false,protectedRefused=false,activationRefused=false,incompatibleDefinition=false
+ let catalogueEdition:44|56|57=44
+ const catalogueCalls:number[]=[]
+ const retainedPools:Pool[]=[]
+ class Pool extends EventEmitter{constructor(){super();retainedPools.push(this)}async end(){events.push('pool-end');if(failEnd)throw Error('Pool cleanup unconfirmed')}}
+ const result={state:'matched',epoch:'1',headSha256:'c'.repeat(64),notAfter:Date.now()+60000,platformProtectionVerified:true}
+ const protectedVerifier={verify:async()=>({platformProtectionVerified:true})}
+ const guardedVerifier={...protectedVerifier}
+ const modules={
+ 'node:assert/strict':assert,'node:path':require('node:path'),'node:url':require('node:url'),'node:crypto':require('node:crypto'),
+ './writer-profile/operator-files.mjs':{readProtected:async(file:string)=>{reads.push(file);assert(file in files);return Buffer.from(JSON.stringify(files[file]))},protectedDirectory:async()=>{},sha:format.sha},
+ './writer-profile/operator-contract.mjs':{approval:(value:unknown)=>{events.push('approval');return value},upgradeApproval:(value:unknown)=>{events.push('upgrade-approval');return upgradeApproval(value)},reconciliationApproval:(value:unknown)=>{events.push('reconciliation-approval');return value},poolOptions:()=>{events.push('transport');return {}},roleKeys:['runtime','operator','capture','publisher','control'],assertJsDriverEnvironment:()=>{}},
+ './database-writer-bootstrap-operator.mjs':{deploymentRequest:(value:unknown)=>value},
+ './writer-profile/protected-source-registry.mjs':{createProtectedDatabaseSourceBindingVerifier:(pin:{registryDirectory:string;currentHeadSha256:string})=>{events.push('protected-source');assert.equal(pin.registryDirectory,'source-registry');assert.equal(pin.currentHeadSha256,request.sourceHeadSha256);if(protectedRefused)throw Error('Protected source refused');return protectedVerifier}},
+ './writer-profile/source-activation.mjs':{withActiveSource:async(input:{directory:string;expectedSha256:string;sourcePin:{currentHeadSha256:string};expectedSource:unknown;tlsSpkiSha256:string;deadlineAt:number},verifier:unknown,work:(verifier:unknown)=>Promise)=>{
+ assert.equal(verifier,protectedVerifier);assert.equal(input.directory,'active-registry');assert.equal(input.expectedSha256,'e'.repeat(64))
+ assert.equal(input.sourcePin.currentHeadSha256,request.sourceHeadSha256);assert.equal(input.tlsSpkiSha256,request.tls.spkiSha256);assert(input.deadlineAt>Date.now())
+ assert.equal(format.canonical(input.expectedSource),format.canonical({...request.source,databaseOid:Number(request.source.databaseOid),sessionUser:'publisher',currentUser:'publisher'}))
+ events.push('activation-admission');if(activationRefused)throw Error('Activation refused')
+ const value=await work(guardedVerifier);events.push('activation-terminal');return value
+ }},
+ pg:{Pool},'./writer-profile/publisher.mjs':{requireCurrentCatalogueDefinition:()=>{if(incompatibleDefinition)throw Error('Build manifest refused')},createConnectedPublisher:(_installation:unknown,collect:(session:unknown)=>Promise,verifier:unknown)=>{
+ assert.equal(verifier,events.includes('activation-admission')?guardedVerifier:protectedVerifier)
+ return {
+ inspectLegacyStorage:async()=>{events.push('legacy-inspect');return {state:'observed',snapshot:{rowCount:1,sha256:'9'.repeat(64)},source:{platformProtectionVerified:true,generation:'source-generation'}}},
+ preflightCurrentProfile:async()=>{await collect({});events.push('preflight');if(asyncError){const activePool=retainedPools.at(-1);assert(activePool);activePool.emit('error',Error('Async pool fault'))}return result},
+ publishCurrentProfile:async()=>{await collect({});events.push('publish');return {...result,outcome:'committed'}},
+ upgradeCurrentProfile:async()=>{await collect({});events.push('upgrade');return {...result,outcome:'committed'}},
+ reconcilePendingPublication:async()=>{events.push('reconcile');return {state:'confirmed',headSha256:result.headSha256}},
+ }
+ }},
+ './writer-profile/catalogue.mjs':{
+ collectSource44Catalogue:async()=>{catalogueCalls.push(44)},
+ collectSource56Catalogue:async()=>{catalogueCalls.push(56)},
+ collectSource57Catalogue:async()=>{catalogueCalls.push(57)},
+ approvedDefinition:()=>({...(catalogueEdition===44?{}:{edition:catalogueEdition}),definitionSha256:'b'.repeat(64),manifestSha256:frozenDefinition.manifestSha256}),
+ },
+ }
+ const flags=['bootstrap','bootstrap-sha256','approval','approval-sha256','definition','definition-sha256','transport','transport-sha256','ca','source-registry','source-spki-sha256','journal'],args=['preflight',...flags.flatMap(flag=>['--'+flag,flag.endsWith('sha256')?'a'.repeat(64):flag])]
+ const output=await compile(cli,modules).main(args)
+ assert.equal(output.event,'application-writer-profile-preflight');assert.equal(output.outcome,'matched');assert.equal(output.platformProtectionVerified,true);assert.equal(output.writerAuthorized,false);assert.equal(output.readyAuthorized,false)
+ assert.deepEqual(reads,['bootstrap','approval','definition','transport','ca']);assert.deepEqual(events,['approval','transport','protected-source','preflight','pool-end'])
+ failEnd=true;await assert.rejects(compile(cli,modules).main(args),/Pool cleanup unconfirmed/)
+ failEnd=false;asyncError=true;await assert.rejects(compile(cli,modules).main(args),/Publisher terminal unconfirmed/)
+ asyncError=false;result.platformProtectionVerified=false;await assert.rejects(compile(cli,modules).main(args),/Publisher terminal unconfirmed/)
+ result.platformProtectionVerified=true;protectedRefused=true;const before=retainedPools.length
+ await assert.rejects(compile(cli,modules).main(args),/Protected source refused/);assert.equal(retainedPools.length,before,'Protection failure must not open a Pool or fall back')
+ const activationFlags=['--activation-directory','active-registry','--activation-sha256','e'.repeat(64)]
+ const activated=(command:string)=>[command,...args.slice(1),...activationFlags]
+ for(const [command,approvalEvent,outcome] of [['publish','approval','committed'],['reconcile','reconciliation-approval','confirmed']]){
+ const commandArgs=command==='publish'?activated(command):[command,...args.slice(1)]
+ const poolCount=retainedPools.length
+ await assert.rejects(compile(cli,modules).main(commandArgs),/Protected source refused/)
+ assert.equal(retainedPools.length,poolCount)
+ protectedRefused=false
+ events.length=0;reads.length=0
+ const terminal=await compile(cli,modules).main(commandArgs)
+ assert.equal(terminal.outcome,outcome);assert.equal(terminal.readyAuthorized,false)
+ assert.deepEqual(events,command==='publish'
+ ?[approvalEvent,'transport','protected-source','activation-admission',command,'pool-end','activation-terminal']
+ :[approvalEvent,'transport','protected-source',command,'pool-end'])
+ assert.equal(reads.includes('signing-private.pem'),command==='publish')
+ protectedRefused=true
+ }
+ const activeArgs=activated('source-preflight')
+ protectedRefused=false;activationRefused=true;events.length=0;reads.length=0
+ const beforeActivation=retainedPools.length
+ await assert.rejects(compile(cli,modules).main(activeArgs),/Activation refused/)
+ assert.equal(retainedPools.length,beforeActivation)
+ assert.deepEqual(events,['approval','transport','protected-source','activation-admission'])
+ await assert.rejects(compile(cli,modules).main(['publish',...args.slice(1)]))
+ await assert.rejects(compile(cli,modules).main(activated('publish')), /Activation refused/)
+ assert.equal(retainedPools.length,beforeActivation)
+ activationRefused=false;events.length=0;reads.length=0
+ const active=await compile(cli,modules).main(activeArgs)
+ assert.equal(active.event,'application-writer-profile-source-preflight');assert.equal(active.sourceActivationMatched,true)
+ assert.equal(active.readyAuthorized,false);assert.equal(active.writerAuthorized,false)
+ assert.deepEqual(events,['approval','transport','protected-source','activation-admission','preflight','pool-end','activation-terminal'])
+ assert.deepEqual(reads,['bootstrap','approval','definition','transport','ca'])
+ const legacyFlags=['bootstrap','bootstrap-sha256','transport','transport-sha256','ca','source-registry','source-spki-sha256']
+ const legacyArgs=['legacy-inspect',...legacyFlags.flatMap(flag=>['--'+flag,flag.endsWith('sha256')?'a'.repeat(64):flag]),...activationFlags]
+ events.length=0;reads.length=0
+ const legacy=await compile(cli,modules).main(legacyArgs)
+ assert.equal(legacy.event,'database-legacy-inspection');assert.equal(legacy.outcome,'observed');assert.equal(legacy.readyAuthorized,false)
+ assert.deepEqual(events,['transport','protected-source','activation-admission','legacy-inspect','pool-end','activation-terminal'])
+ assert.deepEqual(reads,['bootstrap','transport','ca'])
+ await assert.rejects(compile(cli,modules).main(legacyArgs.slice(0,-2)))
+ activationRefused=true;await assert.rejects(compile(cli,modules).main(legacyArgs),/Activation refused/);activationRefused=false
+ assert(catalogueCalls.length>0&&catalogueCalls.every(edition=>edition===44))
+ catalogueEdition=56;catalogueCalls.length=0
+ for(const commandArgs of [args,activeArgs,activated('publish')]){
+ events.length=0
+ await compile(cli,modules).main(commandArgs)
+ }
+ assert.deepEqual(catalogueCalls,[56,56,56])
+ const publicationApproval=files.approval
+ files.approval={...fixture('',true,'upgrade').pinned,definitionSha256:'b'.repeat(64)}
+ events.length=0;reads.length=0;catalogueCalls.length=0
+ const upgraded=await compile(cli,modules).main(activated('upgrade'))
+ assert.equal(upgraded.outcome,'committed')
+ assert.deepEqual(events,['upgrade-approval','transport','protected-source','activation-admission','upgrade','pool-end','activation-terminal'])
+ assert.deepEqual(catalogueCalls,[56])
+ assert(reads.includes('signing-private.pem'))
+ catalogueEdition=57
+ files.approval={...fixture('',true,'upgrade57').pinned,definitionSha256:'b'.repeat(64)}
+ events.length=0;reads.length=0;catalogueCalls.length=0
+ assert.equal((await compile(cli,modules).main(activated('upgrade'))).outcome,'committed')
+ assert.deepEqual(catalogueCalls,[57])
+ files.approval=publicationApproval
+ catalogueEdition=44;catalogueCalls.length=0
+ incompatibleDefinition=true;events.length=0;reads.length=0
+ const beforeBuildRefusal=retainedPools.length
+ for(const incompatibleArgs of [args,activeArgs,activated('publish')])await assert.rejects(compile(cli,modules).main(incompatibleArgs),/Build manifest refused/)
+ assert.equal(retainedPools.length,beforeBuildRefusal)
+ assert(!events.some(event=>event==='protected-source'||event==='activation-admission'))
+ const historical=await compile(cli,modules).main(['reconcile',...args.slice(1)])
+ assert.equal(historical.outcome,'confirmed');assert.equal(historical.readyAuthorized,false)
+ assert.deepEqual(catalogueCalls,[])
+})
+
diff --git a/backend/scripts/flow-read-profile-http-client.mjs b/backend/scripts/flow-read-profile-http-client.mjs
new file mode 100644
index 00000000..0228f76a
--- /dev/null
+++ b/backend/scripts/flow-read-profile-http-client.mjs
@@ -0,0 +1,45 @@
+if(!process.send)throw Error('Owned profile load client requires an IPC parent')
+function requireLoopback(value){const url=new URL(value);if(url.protocol!=='http:'||!['127.0.0.1','localhost','[::1]'].includes(url.hostname)||url.username||url.password)throw Error('Owned test client only permits localhost HTTP')}
+import {Client,StreamableHTTPClientTransport} from '@modelcontextprotocol/client'
+import {getHeapStatistics} from 'node:v8'
+const clients=new Map(),requests=new Map(),streams=new Map();let serial=0,peakRss=0,peakHeap=0
+const sample=()=>{const m=process.memoryUsage();peakRss=Math.max(peakRss,m.rss);peakHeap=Math.max(peakHeap,m.heapUsed);return{memory:m,peakRss,peakHeap,maxRssBytes:process.resourceUsage().maxRSS*1024,effectiveHeapSizeLimitBytes:getHeapStatistics().heap_size_limit}}
+const timer=setInterval(sample,20)
+const summarize=result=>{const row=result.structuredContent?.result??{};return{isError:result.isError===true,structuredContent:{result:{dataQuality:row.dataQuality??null,collectorQualityUnavailableReason:row.collectorQualityUnavailableReason,retainedRowsBytes:row.retainedRowsBytes,analyticsBytes:row.analytics?.bytes,eventBytes:row.events?.map(x=>x.data?.bytes),exporters:row.exporters?.length,clients:row.clients?.length,month:row.month}},hiddenSourceLeaked:JSON.stringify(result).includes('HIDDEN_MEMORY_SOURCE'),encodedBytes:Buffer.byteLength(JSON.stringify(result)),error:result.isError?result.content:undefined}}
+async function run(message){
+ const p=message.payload??{}
+ if(p.endpoint)requireLoopback(p.endpoint);if(p.url)requireLoopback(p.url)
+ if(message.operation==='connect'){
+ const client=new Client({name:'external-owned-memory-client',version:'1'});await client.connect(new StreamableHTTPClientTransport(new URL(p.endpoint+'/mcp'),{requestInit:{headers:{authorization:'Bearer '+p.token}}}));const id=++serial;clients.set(id,client);return{id}
+ }
+ if(message.operation==='tool')return summarize(await clients.get(p.clientId).callTool(p.input))
+ if(message.operation==='close'){await clients.get(p.clientId)?.close();clients.delete(p.clientId);return{closed:true}}
+ if(message.operation==='sse-open'){
+ const abort=new AbortController(),response=await fetch(p.url,{signal:abort.signal});if(response.status!==200)throw Error('SSE status '+response.status)
+ const reader=response.body.getReader(),decoder=new TextDecoder();let text=''
+ for(;;){const chunk=await reader.read();if(chunk.done)throw Error('SSE closed before sample');text+=decoder.decode(chunk.value,{stream:true});const match=/event: (sample|error)\ndata: ([^\n]+)\n\n/.exec(text);if(match){if(match[1]!=='sample')throw Error('SSE source unavailable');const body=JSON.parse(match[2]),id=++serial;streams.set(id,{abort,reader});return{id,bytes:body.bytes}}}
+ }
+ if(message.operation==='sse-close'){const stream=streams.get(p.streamId);stream?.abort.abort();await stream?.reader.cancel().catch(()=>{});streams.delete(p.streamId);return{closed:true}}
+ if(message.operation==='http'){
+ const abort=new AbortController();requests.set(message.id,abort)
+ try{const response=await fetch(p.url,{...p.options,signal:abort.signal}),body=await response.arrayBuffer();let summary;if(response.status===200&&(p.url.includes('/exporters')||p.url.includes('/analytics'))){const parsed=JSON.parse(new TextDecoder().decode(body));summary={exporters:parsed.exporters?.length,bytes:parsed.bytes}}return{status:response.status,bytes:body.byteLength,summary,text:body.byteLength<4096?new TextDecoder().decode(body):''}}
+ finally{requests.delete(message.id)}
+ }
+ if(message.operation==='batch'){
+ const response=await fetch(p.endpoint+'/mcp',{method:'POST',headers:{authorization:'Bearer '+p.token,'content-type':'application/json',accept:'application/json, text/event-stream','mcp-protocol-version':'2025-06-18'},body:JSON.stringify([1,2].map(id=>({jsonrpc:'2.0',id,method:'tools/call',params:{name:'mm_netflow_analytics_report_get',arguments:{serverId:1,minutes:5}}})))})
+ if(response.status!==200)throw Error('Batch HTTP status '+response.status)
+ const reader=response.body.getReader(),decoder=new TextDecoder(),messages=[];let text=''
+ for(;;){const chunk=await reader.read();if(chunk.done)break;text+=decoder.decode(chunk.value,{stream:true});let end;while((end=text.indexOf('\n\n'))>=0){const frame=text.slice(0,end);text=text.slice(end+2);for(const line of frame.split('\n'))if(line.startsWith('data: ')){const row=JSON.parse(line.slice(6));messages.push(row);if(row.error||row.result?.isError)process.send?.({type:'client-progress',id:message.id,refusals:1})}}}
+ if(messages.length!==2)throw Error('Expected two batch replies')
+ return{successes:messages.filter(row=>!row.error&&!row.result?.isError).length,refusals:messages.filter(row=>row.error||row.result?.isError).length}
+ }
+ throw Error('Unknown external client operation')
+}
+process.on('message',async message=>{
+ if(message.type==='abort'){requests.get(message.requestId)?.abort();return}
+ if(message.type==='shutdown'){for(const abort of requests.values())abort.abort();for(const stream of streams.values())stream.abort.abort();for(const client of clients.values())try{await client.close()}catch{}clearInterval(timer);process.send?.({type:'client-report',report:sample()},()=>process.exit(0));return}
+ if(message.type!=='client-command')return
+ try{const result=await run(message);process.send?.({type:'client-result',id:message.id,ok:true,result})}
+ catch(error){process.send?.({type:'client-result',id:message.id,ok:false,error:error instanceof Error?error.message:String(error)})}
+})
+process.send?.({type:'client-ready',report:sample()})
diff --git a/backend/scripts/legacy-probe-0037-owned.mjs b/backend/scripts/legacy-probe-0037-owned.mjs
new file mode 100644
index 00000000..fef7be51
--- /dev/null
+++ b/backend/scripts/legacy-probe-0037-owned.mjs
@@ -0,0 +1,196 @@
+import assert from 'node:assert/strict'
+import {createPublicKey,generateKeyPairSync,randomBytes,randomUUID,sign,X509Certificate} from 'node:crypto'
+import {readFile,mkdir,writeFile} from 'node:fs/promises'
+import {basename,dirname,join,resolve} from 'node:path'
+import {tmpdir} from 'node:os'
+
+export async function verifyOwnedLegacy0037Handoff(pg,options,leafBytes,client,directory,inspectOnly=false){
+ assert.equal(dirname(directory),resolve(tmpdir()))
+ assert.match(basename(directory),/^mm-archive-leaf-tls-/)
+ const fixtureState=join(directory,'mm-mcp-test-legacy-0037','state')
+ await mkdir(fixtureState,{recursive:true,mode:0o700})
+ const tail=inspectOnly==='tail'?{user:'owned_commit_operator',password:randomBytes(24).toString('hex')}:null
+ const localLogin=tail??options
+ Object.assign(process.env,{MMAPP_OWN_PROBE_LEGACY_0037:'true',MMAPP_OWN_PROBE_LEGACY_ORPHANS:'true',
+ DATABASE_URL:`postgres://${localLogin.user}:${localLogin.password}@127.0.0.1:${options.port}/postgres`,MCP_STATE_DIR:fixtureState,AUTH_REQUIRED:'false'})
+ const [{applyLegacyProbeFixtureMigrations},{initialDatabaseSchemaControlState},{runOwnedLegacyProbe0037Handoff},
+ {captureLegacyProbeLineage,captureLegacyProbeStorage,LEGACY_PROBE_CUSTODY_LOCK,LEGACY_PROBE_RELATIONS},
+ {runPinnedDatabaseSnapshotDump,runPinnedLegacyProbeSnapshotDump},{LEGACY_PROBE_CUSTODY_APPROVAL_DOMAIN},
+ {sourceBindingBytes,sourceBindingCanonical,sourceBindingSha256,readDatabaseSourceBindingRegistry},
+ {provisionDatabaseSourceBindingOffline},{retainPublisherTlsPeer},security,{collectLegacyServerProbeSnapshot}]=await Promise.all([
+ import('../src/db/legacy-probe-fixture.ts'),import('../src/db/database-schema-control-model.ts'),import('../src/db/proposals/server-probe-legacy-0037-owned.ts'),
+ import('../src/services/server-probe-legacy-source-inventory.ts'),import('../src/services/database-dump-connection.ts'),import('../src/services/server-probe-legacy-archive-approval.ts'),
+ import('../src/db/database-source-binding.ts'),import('./database-source-binding-operator.ts'),import('./writer-profile/operator-contract.mjs'),
+ import('../src/modules/mcp/security.ts'),import('../src/services/server-probe-legacy-snapshot.ts'),
+ ])
+ const live=new pg.Pool({...options,max:4}),coldDatabase='mm_owned_legacy_cold_'+randomUUID().replaceAll('-','')
+ let cold,coldAdmin
+ const store=async(name,value)=>{const file=join(directory,name);await writeFile(file,value,{flag:'wx',mode:0o600});return file}
+ const inspect=async(sql)=>{
+ await sql.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ try {
+ let sqlState
+ const summary=await collectLegacyServerProbeSnapshot({query:async(text,values)=>{
+ try { return await sql.query(text,values) } catch(error) { sqlState=error.code;throw error }
+ }},{deadlineAt:Date.now()+30000})
+ assert.equal(summary.complete,true,JSON.stringify({reasons:summary.reasons,sqlState}))
+ const snapshot=await captureLegacyProbeStorage(sql),lineage=await captureLegacyProbeLineage(sql)
+ return {summary,snapshot,lineage}
+ } finally { await sql.query('ROLLBACK') }
+ }
+ try{
+ if(tail){
+ // Use the same canonical application owner from the first byte. The
+ // signed reference compares live owners and ACLs as part of its digest.
+ await live.query(`CREATE ROLE ${tail.user} LOGIN CREATEDB PASSWORD '${tail.password}';
+ ALTER DATABASE postgres OWNER TO ${tail.user}; COMMENT ON DATABASE postgres IS NULL`)
+ const application=new pg.Pool({...options,...tail,max:4})
+ try{await applyLegacyProbeFixtureMigrations(application)}finally{await application.end()}
+ }else await applyLegacyProbeFixtureMigrations(live)
+ await live.query(`CREATE SCHEMA mmapp_control; CREATE TABLE mmapp_control.database_schema_state(id smallint PRIMARY KEY CHECK(id=1),revision bigint NOT NULL CHECK(revision>=0),state jsonb NOT NULL);
+ CREATE TABLE mmapp_control.database_schema_intents(id uuid PRIMARY KEY,intent jsonb NOT NULL,terminal jsonb)`)
+ await live.query('INSERT INTO mmapp_control.database_schema_state VALUES(1,0,$1::jsonb)',[JSON.stringify(initialDatabaseSchemaControlState())])
+ const owner='owned-legacy-history-owner',generation=randomUUID(),connection=randomUUID(),credential=randomUUID(),plan=randomUUID(),operation=randomUUID()
+ const restReceipt=randomUUID(),restExecution=randomUUID(),mcpReceipt=randomUUID(),quarantine=randomUUID(),quarantinedExecution=randomUUID()
+ const expiresAt=Date.UTC(2000,0,1),issuedAt=expiresAt-3600000,expiry=new Date(expiresAt).toISOString(),bindingProof='a'.repeat(64)
+ await live.query("INSERT INTO mcp_connections(id,name,owner_id,owner_permissions,policy,generation) VALUES($1,'owned history',$2,'[]','{}',$3)",[connection,owner,generation])
+ await live.query("INSERT INTO mcp_credentials(id,connection_id,digest,kind,expires_at) VALUES($1,$2,$3,'bearer',$4)",[credential,connection,randomUUID(),expiry])
+ const binding={version:1,operation:'servers.probes.run',principal:{connectionId:connection,credentialId:credential,credentialExpiresAt:expiry},
+ ownerId:owner,issuedAt,authorityExpiresAt:expiresAt,prepared:{receiptId:mcpReceipt,serverId:1,tool:'ping',expiresAt:expiry,
+ bindingCiphertext:await security.encryptSecret('owned original provider request')},bindingProof,stageBudget:2}
+ const step={kind:'service',service:'servers.probes.run',input:{receiptId:mcpReceipt,serverId:1,
+ inputDigest:await security.privateSecretFingerprint(security.fingerprint(binding),'server-probe-mcp-binding-v1'),
+ bindingCiphertext:await security.encryptSecret(JSON.stringify(binding))}}
+ const evidence={sealed:await security.encryptSecret(JSON.stringify({steps:[step],target:{scope:'servers',serverIds:[1]},requiresHuman:true,
+ verificationScope:'acknowledgement',mutationCost:2,validUntil:expiry}))}
+ await live.query(`INSERT INTO mcp_plans(id,connection_id,operation_id,operation_version,policy_version,generation,payload,evidence,state,expires_at,approved_by)
+ VALUES($1,$2,'servers.probes.run',1,1,$3,'{}',$4::jsonb,'completed',$5,$6)`,[plan,connection,generation,JSON.stringify(evidence),expiry,owner])
+ await live.query("INSERT INTO mcp_operations(id,plan_id,connection_id,idempotency_key,state,finished_at) VALUES($1,$2,$3,$4,'applied',clock_timestamp())",[operation,plan,connection,randomUUID()])
+ await live.query("INSERT INTO mcp_operation_steps(operation_id,step_index,state,intended_state) VALUES($1,0,'intent',$2::jsonb)",[operation,JSON.stringify(security.redact(step))])
+ await live.query('INSERT INTO mcp_diagnostic_cancellations(operation_id,connection_id,actor_id) VALUES($1,$2,$3)',[operation,connection,owner])
+ const context={identity:{kind:'rest',ownerId:owner,executionId:restExecution,requestId:'owned-original-request',authentication:'jwt',issuedAt,expiresAt},sourceServerId:1,tool:'ping'}
+ await live.query(`INSERT INTO server_probe_executions(receipt_id,binding_proof,identity_kind,execution_id,actor_id,authentication,request_id,authority_issued_at,authority_expires_at,source_server_id,tool)
+ VALUES($1,$2,'rest',$3,$4,'jwt','owned-original-request',$5,$6,1,'ping')`,[restReceipt,bindingProof,restExecution,owner,issuedAt,expiry])
+ await live.query("INSERT INTO server_probe_execution_stages(receipt_id,stage_index,kind,timeout_ms,state,outcome,received_at) VALUES($1,1,'native-ping',1000,'received','received',clock_timestamp())",[restReceipt])
+ const receipt={receiptId:restReceipt,tool:'ping',serverId:1,state:'completed',httpStatus:200,output:'owned original result',data:{kind:'ping'},
+ attemptedStages:1,completedStages:1,automaticReplay:false,forwardingVerified:false}
+ const plaintext=JSON.stringify({version:1,context,bindingProof,receipt})
+ await live.query(`UPDATE server_probe_executions SET state='completed',attempted_stages=1,completed_stages=1,finished_at=clock_timestamp(),receipt_ciphertext=$2,receipt_proof=$3
+ WHERE receipt_id=$1`,[restReceipt,await security.encryptSecret(plaintext),await security.privateSecretFingerprint(security.fingerprint(plaintext),'server-probe-journal-v1:receipt')])
+ await live.query(`INSERT INTO server_probe_execution_quarantines(receipt_id,binding_proof,identity_kind,execution_id,identity_proof,error_code,attempted_stages,completed_stages)
+ VALUES($1,repeat('b',64),'rest',$2,repeat('c',64),'JOURNAL_UNKNOWN',0,0)`,[quarantine,quarantinedExecution])
+ const dependencySql=`SELECT jsonb_build_object('operation',to_jsonb(o),'plan',to_jsonb(p),'connection',to_jsonb(c),'step',to_jsonb(s),'credential',to_jsonb(k)) AS original
+ FROM public.mcp_operations o JOIN public.mcp_plans p ON p.id=o.plan_id JOIN public.mcp_connections c ON c.id=o.connection_id
+ JOIN public.mcp_operation_steps s ON s.operation_id=o.id JOIN public.mcp_credentials k ON k.connection_id=c.id WHERE o.id=$1 AND k.id=$2`
+ const dependencies=(await live.query(dependencySql,[operation,credential])).rows
+ assert.equal(dependencies.length,1)
+ const dependencyHash=sourceBindingSha256(sourceBindingBytes(dependencies))
+ const beforeClient=await live.connect()
+ let before
+ try { before=await inspect(beforeClient) } finally { beforeClient.release() }
+ assert.equal(before.snapshot.rowCount,4);assert.equal(before.lineage.rowCount,4)
+ assert.equal(before.summary.counts.verified,2,JSON.stringify(before.summary.reasons));assert.equal(before.summary.counts.unresolved,1)
+
+ const privateKey=generateKeyPairSync('ed25519').privateKey, signer=await store('owned-source-signer.pem',privateKey.export({type:'pkcs8',format:'pem'}))
+ const privatePassword=await store('owned-archive-password',options.password+'\n')
+ const peerLeaf=new X509Certificate(leafBytes),host='localhost',exporter=await live.connect()
+ let originalPin,archive,fullArchive,signedApproval
+ try{
+ retainPublisherTlsPeer(exporter,{serverName:host,spkiSha256:sourceBindingSha256(peerLeaf.publicKey.export({type:'spki',format:'der'}))})()
+ await exporter.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ await exporter.query(LEGACY_PROBE_CUSTODY_LOCK)
+ const {rows:[identity]}=await exporter.query(`SELECT current_database() AS "databaseName",current_user::text AS "currentUser",session_user::text AS "sessionUser",
+ (pg_catalog.pg_control_system()).system_identifier::text AS "systemIdentifier",pg_catalog.pg_is_in_recovery() AS "inRecovery",
+ current_setting('server_version_num')::int AS "serverVersionNum",d.oid::int AS "databaseOid",r.oid::text AS "signedOid"
+ FROM pg_catalog.pg_database d,pg_catalog.pg_roles r WHERE d.datname=current_database() AND r.rolname=current_user`)
+ const {signedOid,...source}=identity
+ const installationId=randomUUID(),sourceIdentityId=randomUUID(),request={installationId,sourceIdentityId,generation,source}
+ ;({deploymentPin:originalPin}=await provisionDatabaseSourceBindingOffline({request,privateKeyFile:signer,outputDirectory:join(directory,'owned-original-registry')}))
+ const registry=await readDatabaseSourceBindingRegistry(originalPin)
+ const storage=await captureLegacyProbeStorage(exporter),lineage=await captureLegacyProbeLineage(exporter)
+ assert.deepEqual(storage,before.snapshot);assert.deepEqual(lineage,before.lineage)
+ const {rows:[{snapshot}]}=await exporter.query('SELECT pg_catalog.pg_export_snapshot() AS snapshot')
+ const peer={host,port:options.port,database:'postgres',capture:{name:options.user,signedOid},leaf:peerLeaf.toString()}
+ archive=await runPinnedLegacyProbeSnapshotDump(peer,options.password,snapshot,directory,{})
+ fullArchive=await runPinnedDatabaseSnapshotDump(peer,privatePassword,snapshot,{})
+ const body={format:'legacy-probe-custody-approval-v1',installationId,sourceIdentityId,generation,ordinal:1,
+ headSha256:registry.headSha256,bindingSha256:registry.head.bindingSha256,archiveSha256:sourceBindingSha256(archive),
+ storageSha256:storage.sha256,lineageSha256:lineage.sha256}
+ signedApproval=sourceBindingBytes({body,signature:sign(null,Buffer.from(LEGACY_PROBE_CUSTODY_APPROVAL_DOMAIN+sourceBindingCanonical(body)),privateKey).toString('base64url')})
+ } finally { try { await exporter.query('ROLLBACK') } finally { exporter.release() } }
+ await store('owned-legacy-probe.dump',archive);await store('owned-legacy-probe-approval.json',signedApproval)
+ const archiveFile=await store('owned-full-cold.dump',fullArchive)
+ const {stdout:toc}=await client('pg_restore',['--list',archiveFile],'pinned')
+ assert.doesNotMatch(toc,/mmapp_control/)
+ await live.query(`CREATE DATABASE ${coldDatabase} TEMPLATE template0`)
+ coldAdmin=new pg.Client({...options,database:coldDatabase});await coldAdmin.connect()
+ if(/\bSCHEMA - public\b/.test(toc))await coldAdmin.query('DROP SCHEMA public RESTRICT')
+ try { await client('pg_restore',['--dbname='+coldDatabase,'--exit-on-error','--no-owner',archiveFile],'pinned') }
+ catch { throw Error('Owned full legacy cold restore failed') }
+ const coldPassword=randomUUID()
+ await coldAdmin.query(`CREATE ROLE owned_legacy_reader LOGIN PASSWORD '${coldPassword}'; GRANT USAGE ON SCHEMA public TO owned_legacy_reader; GRANT SELECT ON TABLE
+ ${['schema_migrations','mcp_operations','mcp_operation_steps','mcp_plans','mcp_connections','mcp_credentials',...LEGACY_PROBE_RELATIONS].map(name=>`public.${name}`).join(', ')} TO owned_legacy_reader`)
+ cold=new pg.Client({...options,database:coldDatabase,user:'owned_legacy_reader',password:coldPassword});await cold.connect()
+ const coldState=join(directory,'owned-cold-key-state')
+ await mkdir(coldState,{mode:0o700})
+ const archivedKey=await readFile(join(fixtureState,'encryption-key'))
+ try { await writeFile(join(coldState,'encryption-key'),archivedKey,{flag:'wx',mode:0o600}) } finally { archivedKey.fill(0) }
+ const assertCold=async()=>{
+ let read
+ process.env.MCP_STATE_DIR=coldState
+ try { read=await inspect(cold) } finally { process.env.MCP_STATE_DIR=fixtureState }
+ assert.deepEqual(read,before)
+ assert.equal(sourceBindingSha256(sourceBindingBytes((await cold.query(dependencySql,[operation,credential])).rows)),dependencyHash)
+ assert((await cold.query('SELECT execution_id FROM public.server_probe_executions WHERE receipt_id=$1',[restReceipt])).rows[0]?.execution_id===restExecution,'Original receipt ID drift')
+ assert((await cold.query('SELECT execution_id FROM public.server_probe_execution_quarantines WHERE receipt_id=$1',[quarantine])).rows[0]?.execution_id===quarantinedExecution,'Original unresolved ID drift')
+ await assert.rejects(cold.query('DELETE FROM public.server_probe_execution_quarantines WHERE receipt_id=$1',[quarantine]),{code:'42501'})
+ }
+ await assertCold()
+ if(['cold','execute','adopt','release','tail'].includes(inspectOnly)){
+ const {verifyOwnedLegacyColdCommand}=await import('./legacy-probe-cold-verify-owned.mjs')
+ return await verifyOwnedLegacyColdCommand({live,coldAdmin,cold,options,directory,coldState,leafBytes,originalPin,archive,fullArchive,signedApproval,
+ execute:inspectOnly!=='cold',adopt:['adopt','release','tail'].includes(inspectOnly),release:['release','tail'].includes(inspectOnly),
+ tail,sourcePrivateKey:privateKey})
+ }
+ if(inspectOnly){
+ const {verifyOwnedHandoffInspector}=await import('./legacy-probe-handoff-inspect-owned.mjs')
+ return await verifyOwnedHandoffInspector({live,directory,options,leafBytes,originalPin,archive,fullArchive,signedApproval,privateKey,intentOnly:inspectOnly==='intent'})
+ }
+ const operatorPublicKeyPem=Buffer.from(createPublicKey(privateKey).export({type:'spki',format:'pem'}))
+ const archiveApproval={archive,signedApproval,operatorPublicKeyPem}, input={live,cold,coldDatabase,fixtureDirectory:directory,originalPin,archiveApproval}
+ const expectPre0037=async()=>{
+ const sql=await live.connect()
+ try { assert.deepEqual(await inspect(sql),before) } finally { sql.release() }
+ const {rows:[row]}=await live.query(`SELECT count(*)::int AS markers, to_regclass('public.server_probe_storage_admissions')::text AS v2
+ FROM public.schema_migrations`)
+ assert.deepEqual(row,{markers:36,v2:null})
+ }
+ await assert.rejects(runOwnedLegacyProbe0037Handoff({...input,archiveApproval:{...archiveApproval,archive:Buffer.concat([archive,Buffer.from('tamper')])}}),/approval refused/)
+ await coldAdmin.query("UPDATE public.mcp_operation_steps SET intended_state='{\"drift\":true}' WHERE operation_id=$1",[operation])
+ await assert.rejects(runOwnedLegacyProbe0037Handoff(input),{code:'ERR_ASSERTION'})
+ await coldAdmin.query('UPDATE public.mcp_operation_steps SET intended_state=$2::jsonb WHERE operation_id=$1',
+ [operation,JSON.stringify(dependencies[0].original.step.intended_state)])
+ await expectPre0037()
+ const competingWriter=await live.connect()
+ try{
+ await competingWriter.query('BEGIN')
+ await competingWriter.query('LOCK TABLE public.mcp_plans IN ROW EXCLUSIVE MODE')
+ await assert.rejects(runOwnedLegacyProbe0037Handoff(input),{code:'55P03'})
+ } finally { try { await competingWriter.query('ROLLBACK') } finally { competingWriter.release() } }
+ await assert.rejects(runOwnedLegacyProbe0037Handoff({...input,failAfterBody:true}),{code:'22012'})
+ await expectPre0037()
+ const outcome=await runOwnedLegacyProbe0037Handoff(input)
+ assert.deepEqual(outcome,{archivedRows:4,lineageRows:4,readyAuthorized:false})
+ await assertCold()
+ assert.equal(sourceBindingSha256(sourceBindingBytes((await live.query(dependencySql,[operation,credential])).rows)),dependencyHash)
+ const {rows:history}=await live.query("SELECT terminal->>'outcome' AS outcome FROM mmapp_control.database_schema_intents ORDER BY (intent->>'epoch')::int")
+ assert.deepEqual(history,[{outcome:'observed-failure'},{outcome:'observed-success'}])
+ return {ownedAtomicLegacy0037Handoff:true,coldArchiveRows:4,verifiedHistoricalIdentities:2,unresolvedHistoricalIdentities:1,readyAuthorized:false}
+ } finally {
+ await Promise.allSettled([cold?.end(),coldAdmin?.end(),live.end()])
+ if(inspectOnly){
+ const {closePool}=await import('../src/db/index.ts')
+ await closePool()
+ }
+ }
+}
diff --git a/backend/scripts/legacy-probe-cold-verify-owned.mjs b/backend/scripts/legacy-probe-cold-verify-owned.mjs
new file mode 100644
index 00000000..4012f622
--- /dev/null
+++ b/backend/scripts/legacy-probe-cold-verify-owned.mjs
@@ -0,0 +1,78 @@
+import assert from 'node:assert/strict'
+import {createPublicKey,generateKeyPairSync,X509Certificate} from 'node:crypto'
+import {mkdir,open,readFile,realpath,readdir,unlink,writeFile} from 'node:fs/promises'
+import {dirname,join,sep} from 'node:path'
+
+export async function modelOwnedOperatorFiles(directory,sha){
+ if(process.platform!=='win32')return
+ const {mock}=await import('node:test'),url=new URL('./writer-profile/operator-files.mjs',import.meta.url),files=await import(url.href)
+ const protectedDirectory=async path=>{assert(path===directory||path.startsWith(directory+sep));assert.equal(await realpath(path),path)}
+ return mock.module(url,{namedExports:{...files,protectedDirectory,async writeFile(path,blob,opts){
+ await protectedDirectory(dirname(path));const file=await open(path,opts.flag,opts.mode);try{await file.writeFile(blob);await file.sync()}finally{await file.close()}
+ },async readProtected(path,limit,hash){
+ await protectedDirectory(dirname(path));const bytes=await readFile(path);assert(bytes.length>0&&bytes.length<=limit);if(hash!==undefined)assert.equal(sha(bytes),hash);return bytes
+ },async withJournalLease(path,work){
+ await protectedDirectory(path);const lock=join(path,'publisher-lease.lock'),file=await open(lock,'wx',0o600)
+ try{return await work()}finally{await file.close();await unlink(lock)}
+ }}})
+}
+
+export async function verifyOwnedLegacyColdCommand({live,coldAdmin,cold,options,directory,coldState,leafBytes,originalPin,archive,fullArchive,signedApproval,execute,adopt,release,tail,sourcePrivateKey}){
+ assert.equal(process.env.MMAPP_OWN_PROBE_LEGACY_0037,'true')
+ const [{sourceBindingBytes,sourceBindingSha256},{captureLegacyProbeCredentialDigest,verifyLegacyColdProof},{captureLegacyProbeStorage,captureLegacyProbeLineage}]=await Promise.all([
+ import('../src/db/database-source-binding.ts'),import('../src/services/server-probe-legacy-cold-proof.ts'),import('../src/services/server-probe-legacy-source-inventory.ts'),
+ ])
+ const sha=sourceBindingSha256,store=async(path,data)=>{await writeFile(path,data,{flag:'wx',mode:0o600});return path}
+ const archiveDirectory=join(directory,'cold-protected-archive'),outputDirectory=join(directory,'cold-proof-output')
+ await mkdir(archiveDirectory,{mode:0o700});await mkdir(outputDirectory,{mode:0o700})
+ for(const [name,data] of [['legacy-probe.dump',archive],['legacy-probe-approval.json',signedApproval],['legacy-probe-cold.dump',fullArchive]])await store(join(archiveDirectory,name),data)
+ await coldAdmin.query('GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO owned_legacy_reader')
+ const {rows:[identity]}=await cold.query(`SELECT current_database() AS "databaseName", current_user::text AS "currentUser", session_user::text AS "sessionUser",
+ (pg_catalog.pg_control_system()).system_identifier::text AS "systemIdentifier",pg_catalog.pg_is_in_recovery() AS "inRecovery",
+ current_setting('server_version_num')::int AS "serverVersionNum",d.oid::int AS "databaseOid",r.oid::text AS "roleOid"
+ FROM pg_catalog.pg_database d,pg_catalog.pg_roles r WHERE d.datname=current_database() AND r.rolname=current_user`)
+ const {roleOid,...coldSource}=identity
+ const key=generateKeyPairSync('ed25519').privateKey,publicKey=createPublicKey(key),host='localhost'
+ const signerSpkiSha256=sha(publicKey.export({type:'spki',format:'der'}))
+ const storedKey=await readFile(join(coldState,'encryption-key'));const keySha256=sha(storedKey);storedKey.fill(0)
+ const approval=sourceBindingBytes({format:'legacy-probe-cold-verification-approval-v1',installationId:originalPin.installationId,
+ sourceHeadSha256:originalPin.currentHeadSha256,sourceSignerSpkiSha256:originalPin.publicKeySpkiSha256,custodySha256:sha(signedApproval),
+ coldArchiveSha256:sha(fullArchive),coldSignerSpkiSha256:signerSpkiSha256,keySha256,coldSource,coldRoleOid:roleOid,
+ tls:{serverName:host,caSha256:sha(leafBytes),spkiSha256:sha(new X509Certificate(leafBytes).publicKey.export({type:'spki',format:'der'}))},expiresAt:Date.now()+120000})
+ const transport=sourceBindingBytes({host,port:options.port,user:cold.user,password:cold.password,database:cold.database})
+ const argv=['legacy-cold-verify','--approval',await store(join(directory,'cold-verification.json'),approval),'--approval-sha256',sha(approval),
+ '--transport',await store(join(directory,'cold-transport.json'),transport),'--transport-sha256',sha(transport),
+ '--ca',await store(join(directory,'cold-ca.pem'),leafBytes),'--source-registry',originalPin.registryDirectory,'--archive-directory',archiveDirectory,
+ '--legacy-key-directory',coldState,'--cold-signing-key',await store(join(directory,'cold-signing.pem'),key.export({type:'pkcs8',format:'pem'})),
+ '--output-directory',outputDirectory]
+ const modeledFiles=await modelOwnedOperatorFiles(directory,sha)
+ try{
+ const {main}=await import('./database-writer-profile-operator.mts')
+ if(!execute){
+ await coldAdmin.query('GRANT UPDATE ON public.mcp_credentials TO owned_legacy_reader')
+ try{await assert.rejects(main(argv),/read-only privileges/)}finally{await coldAdmin.query('REVOKE UPDATE ON public.mcp_credentials FROM owned_legacy_reader')}
+ assert.deepEqual(await readdir(outputDirectory),[])
+ }
+ const result=await main(argv),proof=await readFile(join(outputDirectory,result.proofFile))
+ assert.equal(result.event,'database-legacy-cold-proof');assert.equal(result.proofSha256,sha(proof));assert.equal(result.conversionAllowed,false)
+ const source=await live.connect()
+ try{
+ await source.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ const storage=await captureLegacyProbeStorage(source),lineage=await captureLegacyProbeLineage(source)
+ const pinned={publicKeyPem:Buffer.from(publicKey.export({type:'spki',format:'pem'})),signerSpkiSha256,
+ sourceSignerSpkiSha256:originalPin.publicKeySpkiSha256,approvalSha256:sha(approval),coldArchiveSha256:sha(fullArchive),custodySha256:sha(signedApproval),
+ storageSha256:storage.sha256,lineageSha256:lineage.sha256}
+ const verified=verifyLegacyColdProof(proof,pinned)
+ assert.equal(verified.credentialSha256,await captureLegacyProbeCredentialDigest(source));assert.equal(verified.keySha256,keySha256)
+ assert.deepEqual(verified.coldSource,coldSource)
+ assert.throws(()=>verifyLegacyColdProof(proof,{...pinned,coldArchiveSha256:'0'.repeat(64)}),/proof refused/)
+ assert.throws(()=>verifyLegacyColdProof(proof,{...pinned,sourceSignerSpkiSha256:signerSpkiSha256}),/proof refused/)
+ }finally{try{await source.query('ROLLBACK')}finally{source.release()}}
+ if(execute){
+ const {verifyOwnedLegacyExecution}=await import('./legacy-probe-handoff-execute-owned.mjs')
+ return await verifyOwnedLegacyExecution({main,live,options,directory,archiveDirectory,coldState,leafBytes,originalPin,fullArchive,signedApproval,
+ adopt,release,tail,sourcePrivateKey,coldPrivateKey:key,coldPublicKey:publicKey,proof,coldApprovalSha256:sha(approval)})
+ }
+ return {coldProofIssued:true,distinctIssuerVerified:true,credentialDigestMatched:true,writePrivilegedRoleRefused:true,readyAuthorized:false}
+ }finally{modeledFiles?.restore()}
+}
diff --git a/backend/scripts/legacy-probe-handoff-execute-owned.mjs b/backend/scripts/legacy-probe-handoff-execute-owned.mjs
new file mode 100644
index 00000000..9d3a4f67
--- /dev/null
+++ b/backend/scripts/legacy-probe-handoff-execute-owned.mjs
@@ -0,0 +1,259 @@
+import assert from 'node:assert/strict'
+import {randomBytes,randomUUID,sign,X509Certificate} from 'node:crypto'
+import {mkdir,readFile,writeFile} from 'node:fs/promises'
+import {join} from 'node:path'
+import pg from 'pg'
+
+export async function verifyOwnedLegacyExecution({main,live,options,directory,archiveDirectory,coldState,leafBytes,originalPin,fullArchive,signedApproval,
+ adopt,release,tail,sourcePrivateKey,coldPrivateKey,coldPublicKey,proof,coldApprovalSha256}){
+ assert.equal(process.env.MMAPP_OWN_PROBE_LEGACY_0037,'true')
+ const [{sourceBindingBytes,sourceBindingCanonical,sourceBindingSha256,readDatabaseSourceBindingRegistry},{readReviewedLegacyProbe0037},
+ {LEGACY_HANDOFF_EXECUTION_DOMAIN,LEGACY_HANDOFF_RELEASE_DOMAIN},{captureLegacyHandoffSchema},{LEGACY_PROBE_RELATIONS},{acquireDatabaseSchemaControl},{observation,exactHistory},
+ {MIGRATION_MANIFEST,migrationManifestDigest},{DATABASE_RESTORE_QUARANTINE_DDL},{createBootstrapMaterial}]=await Promise.all([
+ import('../src/db/database-source-binding.ts'),import('../src/db/legacy-probe-0037-body.ts'),import('./writer-profile/legacy-handoff-execution.mts'),
+ import('../src/services/server-probe-legacy-handoff-inspection.ts'),import('../src/services/server-probe-legacy-source-inventory.ts'),
+ import('../src/db/database-schema-control.ts'),import('../src/db/controlled-migration-history.ts'),import('../src/db/migration-manifest.ts'),
+ import('../src/db/database-restore-quarantine.ts'),import('./database-writer-bootstrap-operator.mjs'),
+ ])
+ const sha=sourceBindingSha256,store=async(path,data)=>{await writeFile(path,data,{flag:'wx',mode:0o600});return path}
+ const publisher=options.user,operator='owned_commit_operator',control='owned_commit_control'
+ const appPassword=tail?.password??randomBytes(24).toString('hex'),controlPassword=randomBytes(24).toString('hex')
+ await live.query(DATABASE_RESTORE_QUARANTINE_DDL)
+ if(tail)assert.equal(tail.user,operator)
+ else await live.query(`CREATE ROLE ${operator} LOGIN PASSWORD '${appPassword}'; GRANT ${publisher} TO ${operator}; ALTER SCHEMA public OWNER TO ${operator}`)
+ await live.query(`CREATE ROLE ${control} LOGIN PASSWORD '${controlPassword}';
+ CREATE ROLE owned_commit_runtime NOLOGIN; CREATE ROLE owned_commit_capture NOLOGIN;
+ GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${control},${operator}; GRANT pg_read_all_stats TO ${control};
+ GRANT USAGE ON SCHEMA mmapp_control TO ${control},${operator}; GRANT SELECT, UPDATE ON mmapp_control.database_schema_state,mmapp_control.database_restore_quarantine TO ${control},${operator};
+ GRANT SELECT, INSERT, UPDATE ON mmapp_control.database_schema_intents TO ${control},${operator}`)
+ let runTail
+ if(tail){
+ const [{pool},{executeControlledSqlMigrations},{LEGACY_CONTROL_REFERENCE_DOMAIN,readControlledSchemaReference},{verifyControlledSchemaCurrentState}]=await Promise.all([
+ import('../src/db/index.ts'),import('../src/db/controlled-migrations.ts'),import('../src/db/controlled-schema-reference-core.ts'),
+ import('../src/db/controlled-schema-verification.ts'),
+ ])
+ runTail=async(quarantined,handoff)=>{
+ const files=[],fileHashes=new Map(MIGRATION_MANIFEST.map(pin=>[pin.sha256,pin.file]))
+ const originalConnect=pool.connect
+ pool.connect=async()=>{
+ const owned=await originalConnect.call(pool),query=owned.query,release=owned.release
+ owned.query=function(text,...args){
+ const file=typeof text==='string'&&fileHashes.get(sha(Buffer.from(text)))
+ if(file)files.push(file)
+ return query.call(this,text,...args)
+ }
+ owned.release=function(...args){owned.query=query;owned.release=release;return release.apply(this,args)}
+ return owned
+ }
+ try{
+ if(quarantined){
+ await assert.rejects(executeControlledSqlMigrations(),error=>error.cause?.message==='Authenticated legacy migration release required')
+ assert.deepEqual(files,[])
+ return
+ }
+ const result=await executeControlledSqlMigrations()
+ assert.equal(result.completedFiles,MIGRATION_MANIFEST.length);assert.equal(result.ready,false)
+ assert.deepEqual(files,MIGRATION_MANIFEST.slice(37).map(pin=>pin.file))
+ }finally{pool.connect=originalConnect}
+ const referenceRoles={publisher:request.roles.publisher,operator:request.roles.operator,control:request.roles.control}
+ const approvalBody={format:'legacy-control-reference-approval-v1',manifestSha256,sourceHeadSha256:source.headSha256,
+ sourceTlsSpkiSha256:tls.spkiSha256,...referenceRoles,expiresAt:Date.now()+90000}
+ const referenceArgs=async(body,filename)=>{
+ const bytes=sourceBindingBytes({body,signature:sign(null,Buffer.from(LEGACY_CONTROL_REFERENCE_DOMAIN+sourceBindingCanonical(body)),coldPrivateKey).toString('base64url')})
+ const flags=['--bootstrap','--bootstrap-sha256','--publisher-transport','--publisher-transport-sha256','--operator-transport','--operator-transport-sha256',
+ '--ca','--source-registry','--source-spki-sha256','--activation-directory','--activation-sha256','--cold-public-key','--cold-spki-sha256']
+ return ['legacy-control-reference',...flags.flatMap(flag=>[flag,args[args.indexOf(flag)+1]]),
+ '--approval',await store(join(directory,filename),bytes),'--approval-sha256',sha(bytes)]
+ }
+ await assert.rejects(main(await referenceArgs({...approvalBody,control:referenceRoles.operator},'wrong-control-reference.json')),/independent split-control approval/)
+ const approved=await referenceArgs(approvalBody,'control-reference.json')
+ const reference=await main(approved),current=await verifyControlledSchemaCurrentState()
+ assert.equal(reference.splitControlApprovalSha256,approved.at(-1));assert.equal(reference.referenceDatabaseDropped,true)
+ assert.equal((await readControlledSchemaReference()).sha256,current.schemaSha256)
+ assert.equal(current.schemaSha256,reference.logicalSchemaSha256);assert.equal(current.referenceStatus,'matched');assert.equal(current.ready,false)
+ assert.equal(current.currentPristineDataInvariants,false)
+ await live.query('GRANT USAGE ON SCHEMA mmapp_control TO owned_commit_runtime')
+ try{
+ const extra=await verifyControlledSchemaCurrentState()
+ assert.equal(extra.referenceStatus,'different');assert.equal(extra.ready,false);assert.equal(extra.dataFacts.length,0)
+ }finally{await live.query('REVOKE USAGE ON SCHEMA mmapp_control FROM owned_commit_runtime')}
+ const [{LEGACY_SOURCE58_PREFLIGHT_DOMAIN},{RESTORE_WRITER_PROFILE_DEFINITION_SHA256}]=await Promise.all([
+ import('../src/db/legacy-source58-transition.ts'),import('../src/db/database-restore-quarantine-profile.ts'),
+ ])
+ const targetCatalogueSha256=sha(Buffer.from('owned signed intended Source58 target; installation outside this preflight'))
+ const target={format:'legacy-source58-preflight-approval-v1',manifestSha256,sourceHeadSha256:source.headSha256,
+ sourceTlsSpkiSha256:tls.spkiSha256,currentSchemaSha256:reference.logicalSchemaSha256,...handoff,
+ targetDefinitionSha256:RESTORE_WRITER_PROFILE_DEFINITION_SHA256,targetCatalogueSha256,roles:request.roles,expiresAt:Date.now()+90000}
+ const preflightArgs=async(body,name)=>{
+ const bytes=sourceBindingBytes({body,signature:sign(null,Buffer.from(LEGACY_SOURCE58_PREFLIGHT_DOMAIN+sourceBindingCanonical(body)),coldPrivateKey).toString('base64url')})
+ const flags=approved.slice(1,-4),operatorAt=flags.indexOf('--operator-transport')
+ flags.splice(operatorAt,4)
+ return ['legacy-source58-preflight',...flags,'--approval',await store(join(directory,name),bytes),'--approval-sha256',sha(bytes)]
+ }
+ await assert.rejects(main(await preflightArgs({...target,releaseApprovalSha256:'0'.repeat(64)},'wrong-source58-target.json')),/exact authenticated release/)
+ const observed=await main(await preflightArgs(target,'source58-target.json'))
+ assert.equal(observed.authenticatedFiles,MIGRATION_MANIFEST.length);assert.equal(observed.transitionAuthorized,false);assert.equal(observed.readyAuthorized,false)
+ assert.equal(observed.approvedTargetCatalogueSha256,targetCatalogueSha256)
+ const expectedBlockers=['CONTROL_NAMESPACE_OWNER','QUARANTINE_OWNER','WRITER_REGISTRY_MISSING','REVIEWED_MARKER_FENCE_MISSING',
+ 'ROLE_PROFILE_OPERATOR','ROLE_PROFILE_PUBLISHER','ROLE_PROFILE_RUNTIME','ROLE_PROFILE_CAPTURE']
+ assert.deepEqual(observed.blockers,expectedBlockers)
+ return {manifestSha256,logicalSchemaSha256:current.schemaSha256,referenceLogicalSchemaSha256:reference.logicalSchemaSha256,
+ referenceStatus:current.referenceStatus,splitControlApprovalSha256:reference.splitControlApprovalSha256,exactSplitControlCatalogueMatched:true,
+ invalidRoleRefused:true,excessNamespaceAclRefused:true,
+ referenceDatabaseDropped:reference.referenceDatabaseDropped,
+ files,legacySource58PredecessorAttested:true,wrongReleasePinRefused:true,source58Blockers:observed.blockers,
+ source58TransitionAuthorized:false,readyAuthorized:current.ready,historicalDataEquivalent:current.historicalDataEquivalent}
+ }
+ }
+ const manifestSha256=migrationManifestDigest(),controller=await acquireDatabaseSchemaControl(live)
+ try{
+ for(const migration of MIGRATION_MANIFEST.slice(0,36)){
+ const id=randomUUID(),begun=await controller.transition({type:'begin',id,kind:'migration',manifestSha256,artifactSha256:migration.sha256})
+ await controller.transition({type:'terminal',id,outcome:'observed-success',observationSha256:await observation(begun.state.intent,migration)})
+ }
+ }finally{await controller.close()}
+ const {body,pin}=await readReviewedLegacyProbe0037(),preview=new pg.Client({...options,user:operator,password:appPassword})
+ await preview.connect()
+ let preSchemaSha256,postSchemaSha256
+ try{
+ await preview.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ preSchemaSha256=await captureLegacyHandoffSchema(preview,Date.now()+30000);await preview.query('ROLLBACK')
+ await preview.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ WRITE')
+ await preview.query(`TRUNCATE TABLE ${LEGACY_PROBE_RELATIONS.map(name=>`ONLY public.${name}`).join(', ')} CONTINUE IDENTITY RESTRICT`)
+ await preview.query(body);await preview.query('SET TRANSACTION READ ONLY')
+ postSchemaSha256=await captureLegacyHandoffSchema(preview,Date.now()+30000)
+ }finally{try{await preview.query('ROLLBACK')}finally{await preview.end()}}
+ assert.notEqual(preSchemaSha256,postSchemaSha256)
+ const source=await readDatabaseSourceBindingRegistry(originalPin),host='localhost',tls={serverName:host,caSha256:sha(leafBytes),
+ spkiSha256:sha(new X509Certificate(leafBytes).publicKey.export({type:'spki',format:'der'}))}
+ const names={publisher,operator,control,runtime:'owned_commit_runtime',capture:'owned_commit_capture'}
+ const {rows:rows}=await live.query('SELECT rolname AS name,oid::text AS "signedOid" FROM pg_catalog.pg_roles WHERE rolname=ANY($1)',[Object.values(names)])
+ const request={format:'application-writer-bootstrap-request-v1',installationId:originalPin.installationId,sourceHeadSha256:originalPin.currentHeadSha256,tls,
+ roles:Object.fromEntries(Object.entries(names).map(([scope,name])=>[scope,rows.find(role=>role.name===name)])),source:{systemIdentifier:source.body.source.systemIdentifier,
+ databaseOid:String(source.body.source.databaseOid),databaseName:source.body.source.databaseName,serverVersionNum:source.body.source.serverVersionNum,inRecovery:false}}
+ const bootstrap=sourceBindingBytes(createBootstrapMaterial(request,sha(sourceBindingBytes(request))).bootstrap)
+ const activeDirectory=join(directory,'owned-execute-activation');await mkdir(activeDirectory,{mode:0o700})
+ const activation=sourceBindingBytes({format:'database-source-activation-v1',activationDirectory:activeDirectory,installationId:originalPin.installationId,
+ sourceIdentityId:source.body.sourceIdentityId,status:'active',publicKeySpkiSha256:originalPin.publicKeySpkiSha256,
+ generations:[{generation:source.body.generation,headSha256:source.headSha256,bindingSha256:source.head.bindingSha256,tlsSpkiSha256:tls.spkiSha256}]})
+ await store(join(activeDirectory,'source-activation.json'),activation)
+ const operationId=randomUUID(),approvalBody={format:'legacy-probe-0037-execution-approval-v1',decision:'execute-and-commit',operationId,
+ sourceHeadSha256:originalPin.currentHeadSha256,sourceTlsSpkiSha256:tls.spkiSha256,custodySha256:sha(signedApproval),coldArchiveSha256:sha(fullArchive),
+ coldProofSha256:sha(proof),coldApprovalSha256,preSchemaSha256,postSchemaSha256,manifestSha256,migrationSha256:pin.sha256,protectedRuntimePaused:true,expiresAt:Date.now()+90000}
+ const approved=sourceBindingBytes({body:approvalBody,signature:sign(null,Buffer.from(LEGACY_HANDOFF_EXECUTION_DOMAIN+sourceBindingCanonical(approvalBody)),coldPrivateKey).toString('base64url')})
+ await store(join(archiveDirectory,'legacy-probe-cold-proof.json'),proof)
+ const shared=['--bootstrap',await store(join(directory,'execute-bootstrap.json'),bootstrap),'--bootstrap-sha256',sha(bootstrap),
+ '--ca',await store(join(directory,'execute-ca.pem'),leafBytes),'--source-registry',originalPin.registryDirectory,'--source-spki-sha256',originalPin.publicKeySpkiSha256,
+ '--activation-directory',activeDirectory,'--activation-sha256',sha(activation),'--archive-directory',archiveDirectory]
+ const args=['legacy-handoff-execute',...shared,'--legacy-key-directory',coldState,'--source-signing-key',await store(join(directory,'execute-source-key.pem'),sourcePrivateKey.export({type:'pkcs8',format:'pem'})),
+ '--approval',await store(join(directory,'execute-approval.json'),approved),'--approval-sha256',sha(approved),'--cold-public-key',await store(join(directory,'execute-cold-pub.pem'),coldPublicKey.export({type:'spki',format:'pem'})),
+ '--cold-spki-sha256',sha(coldPublicKey.export({type:'spki',format:'der'}))]
+ let publisherTransport,publisherSha
+ for(const [scope,user,password] of [['publisher',publisher,options.password],['operator',operator,appPassword],['control',control,controlPassword]]){
+ const transport=sourceBindingBytes({host,port:options.port,database:options.database,user,password})
+ const file=await store(join(directory,'execute-'+scope+'.json'),transport);args.push('--'+scope+'-transport',file,'--'+scope+'-transport-sha256',sha(transport))
+ if(scope==='publisher'){publisherTransport=file;publisherSha=sha(transport)}
+ }
+ const {rows:[credential]}=await live.query('SELECT id,digest FROM public.mcp_credentials LIMIT 1')
+ await live.query('UPDATE public.mcp_credentials SET digest=$2 WHERE id=$1',[credential.id,randomUUID()])
+ try{await assert.rejects(main(args),/Original credentials differ/)}finally{await live.query('UPDATE public.mcp_credentials SET digest=$2 WHERE id=$1',[credential.id,credential.digest])}
+ assert.equal((await live.query('SELECT operation_id FROM mmapp_control.database_restore_quarantine')).rows[0].operation_id,null)
+ const connect=pg.Pool.prototype.connect
+ let applicationCommits=0
+ pg.Pool.prototype.connect=function(...args){
+ const connection=connect.apply(this,args)
+ if(args.length||this.options.application_name!=='mmapp-legacy-handoff-owner')return connection
+ return connection.then(client=>{
+ const query=client.query
+ client.query=function(text,...params){
+ const result=query.call(this,text,...params)
+ if(text!=='COMMIT')return result
+ return result.then(()=>{applicationCommits++;throw Error('owned application COMMIT ACK lost')})
+ }
+ return client
+ })
+ }
+ try{await assert.rejects(main(args),{code:'LEGACY_HANDOFF_EXECUTION_UNKNOWN'})}finally{pg.Pool.prototype.connect=connect}
+ assert.equal(applicationCommits,1)
+ const intent=await readFile(join(archiveDirectory,'legacy-probe-handoff-intent.json'))
+ const unknown=JSON.parse(await readFile(join(archiveDirectory,'legacy-probe-handoff-application-unknown.json'),'utf8'))
+ assert.equal(unknown.operationId,operationId);assert.equal(unknown.automaticReplay,false)
+ const inspectArgs=['legacy-handoff-inspect',...shared,'--transport',publisherTransport,'--transport-sha256',publisherSha,'--handoff-intent-sha256',sha(intent)]
+ const inspected=await main(inspectArgs)
+ assert.equal(inspected.outcome,'committed');assert.equal(inspected.operationId,operationId);assert.equal(inspected.quarantineActive,true)
+ assert.equal((await live.query('SELECT operation_id FROM mmapp_control.database_restore_quarantine')).rows[0].operation_id,operationId)
+ await assert.rejects(main(args),{code:'DATABASE_RESTORE_QUARANTINE_UNAVAILABLE'})
+ assert.equal(applicationCommits,1)
+ if(adopt){
+ assert.equal(inspected.adoptionRecorded,false)
+ const adoptArgs=[...args];adoptArgs[0]='legacy-handoff-adopt'
+ adoptArgs.splice(adoptArgs.indexOf('--source-signing-key'),2,'--handoff-intent-sha256',sha(intent))
+ let action=adoptArgs,unknownCode='LEGACY_HANDOFF_ADOPTION_UNKNOWN',releaseApprovalSha256
+ if(release){
+ const adopted=await main(adoptArgs)
+ assert.equal(adopted.quarantineActive,true)
+ if(runTail)await runTail(true)
+ const signedRelease=async(adoptionSha256,name)=>{
+ const body={format:'legacy-probe-0037-release-approval-v1',decision:'release-migration-quarantine',operationId,intentSha256:sha(intent),adoptionSha256,
+ sourceHeadSha256:originalPin.currentHeadSha256,sourceTlsSpkiSha256:tls.spkiSha256,coldArchiveSha256:sha(fullArchive),
+ coldProofSha256:sha(proof),postSchemaSha256,manifestSha256,migrationSha256:pin.sha256,protectedRuntimePaused:true,expiresAt:Date.now()+90000}
+ const bytes=sourceBindingBytes({body,signature:sign(null,Buffer.from(LEGACY_HANDOFF_RELEASE_DOMAIN+sourceBindingCanonical(body)),coldPrivateKey).toString('base64url')})
+ return ['legacy-handoff-release',...adoptArgs.slice(1),'--release-approval',await store(join(directory,name),bytes),'--release-approval-sha256',sha(bytes)]
+ }
+ await assert.rejects(main(await signedRelease('0'.repeat(64),'wrong-release.json')),/Exact committed legacy handoff phase/)
+ assert.equal((await main(inspectArgs)).quarantineActive,true)
+ action=await signedRelease(adopted.observationSha256,'release.json')
+ releaseApprovalSha256=action.at(-1);unknownCode='LEGACY_HANDOFF_RELEASE_UNKNOWN'
+ }
+ let controlCommits=0
+ pg.Pool.prototype.connect=function(...parameters){
+ const connection=connect.apply(this,parameters)
+ if(parameters.length||this.options.application_name!=='mmapp-writer-registry-enroll')return connection
+ return connection.then(client=>{
+ const query=client.query
+ client.query=function(text,...params){
+ const result=query.call(this,text,...params)
+ if(text!=='COMMIT')return result
+ return result.then(ack=>{if(++controlCommits===2)throw Error('owned adoption COMMIT ACK lost');return ack})
+ }
+ return client
+ })
+ }
+ try{await assert.rejects(main(action),{code:unknownCode})}finally{pg.Pool.prototype.connect=connect}
+ assert.equal(controlCommits,2)
+ const readback=await main(inspectArgs)
+ assert.equal(readback.adoptionRecorded,true);assert.equal(readback.outcome,'committed');assert.equal(readback.readyAuthorized,false)
+ const {rows:[gate]}=await live.query('SELECT q.operation_id::text AS active,s.state FROM mmapp_control.database_restore_quarantine q CROSS JOIN mmapp_control.database_schema_state s WHERE q.id=1 AND s.id=1')
+ const {rows:history}=await live.query('SELECT id::text,intent,terminal FROM mmapp_control.database_schema_intents')
+ assert.equal(gate.active,release?null:operationId);assert.equal(gate.state.intent,null)
+ assert.equal(gate.state.terminal.intent.artifactSha256,sha(intent))
+ assert.equal(await exactHistory(history,gate.state,manifestSha256,true),37)
+ if(release){
+ assert.equal(readback.releaseRecorded,true);assert.equal(readback.quarantineActive,false);assert.equal(readback.releaseApprovalSha256,releaseApprovalSha256)
+ assert.equal(gate.state.terminal.legacyRelease.approvalSha256,releaseApprovalSha256)
+ const {rows:[head]}=await live.query('SELECT journal_prefix_bytes,journal_prefix_sha256 FROM mmapp_control.database_restore_quarantine')
+ assert.deepEqual(head,{journal_prefix_bytes:null,journal_prefix_sha256:null})
+ const unknown=JSON.parse(await readFile(join(archiveDirectory,'legacy-probe-handoff-release-unknown.json'),'utf8'))
+ assert.deepEqual(unknown,{format:'legacy-probe-0037-release-unknown-v1',operationId,intentSha256:sha(intent),automaticReplay:false})
+ await assert.rejects(main(action),/Legacy release attempt requires inspection/)
+ if(runTail){
+ const markers=()=>live.query('SELECT id,xmin::text AS xmin,applied_at::text FROM public.schema_migrations ORDER BY id').then(result=>result.rows)
+ const ledger=()=>live.query('SELECT id::text,xmin::text AS xmin,intent,terminal FROM mmapp_control.database_schema_intents ORDER BY id').then(result=>result.rows)
+ const beforeMarkers=await markers(),beforeLedger=await ledger()
+ const result=await runTail(false,{operationId,intentSha256:sha(intent),releaseApprovalSha256})
+ assert.deepEqual((await markers()).slice(0,37),beforeMarkers)
+ const afterLedger=new Map((await ledger()).map(row=>[row.id,row]))
+ assert(beforeLedger.every(row=>JSON.stringify(row)===JSON.stringify(afterLedger.get(row.id))))
+ assert.equal((await main(inspectArgs)).releaseRecorded,true)
+ return {controlledLegacyTailCompleted:true,quarantinedDispatchRefused:true,originalReceiptsAndMarkersPreserved:true,...result}
+ }
+ return {legacyHandoffReleased:true,wrongAdoptionRefused:true,releaseAckLossObserved:true,exactAuthenticatedPrefix:37,
+ replayRefused:true,restoreJournalUnchanged:true,readyAuthorized:false}
+ }
+ const unknown=JSON.parse(await readFile(join(archiveDirectory,'legacy-probe-handoff-adoption-unknown.json'),'utf8'))
+ assert.deepEqual(unknown,{format:'legacy-probe-0037-adoption-unknown-v1',operationId,intentSha256:sha(intent),automaticReplay:false})
+ await assert.rejects(main(adoptArgs),/Legacy adoption attempt requires inspection/)
+ return {legacyHandoffAdopted:true,adoptionAckLossObserved:true,exactAuthenticatedPrefix:37,replayRefused:true,quarantineCleared:false,readyAuthorized:false}
+ }
+ return {legacyHandoffExecuted:true,credentialDriftRefused:true,applicationAckLossObserved:true,committedReconciled:true,quarantineCleared:false,readyAuthorized:false}
+}
diff --git a/backend/scripts/legacy-probe-handoff-inspect-owned.mjs b/backend/scripts/legacy-probe-handoff-inspect-owned.mjs
new file mode 100644
index 00000000..2fd4c08d
--- /dev/null
+++ b/backend/scripts/legacy-probe-handoff-inspect-owned.mjs
@@ -0,0 +1,177 @@
+import assert from 'node:assert/strict'
+import {randomUUID,sign,X509Certificate} from 'node:crypto'
+import {mkdir,open,readFile,realpath,unlink,writeFile} from 'node:fs/promises'
+import {dirname,join,sep} from 'node:path'
+
+export async function verifyOwnedHandoffInspector({live,directory,options,leafBytes,originalPin,archive,fullArchive,signedApproval,privateKey,intentOnly=false}){
+ assert.equal(process.env.MMAPP_OWN_PROBE_LEGACY_0037,'true')
+ const [{acquireDatabaseSchemaControl},{observation},{MIGRATION_MANIFEST,migrationManifestDigest},
+ {captureMigrationSchema},{ownedLegacyProbe0037Body},{sourceBindingBytes,sourceBindingCanonical,sourceBindingSha256,readDatabaseSourceBindingRegistry},
+ {LEGACY_PROBE_HANDOFF_DOMAIN},{createBootstrapMaterial},{LEGACY_PROBE_RELATIONS,LEGACY_PROBE_CUSTODY_RELATIONS},{DATABASE_RESTORE_QUARANTINE_DDL,beginDatabaseRestoreQuarantine}]=await Promise.all([
+ import('../src/db/database-schema-control.ts'),import('../src/db/controlled-migration-history.ts'),import('../src/db/migration-manifest.ts'),
+ import('../src/db/migration-schema-inventory.ts'),import('../src/db/proposals/server-probe-legacy-0037-owned.ts'),import('../src/db/database-source-binding.ts'),
+ import('../src/services/server-probe-legacy-handoff-inspection.ts'),import('./database-writer-bootstrap-operator.mjs'),
+ import('../src/services/server-probe-legacy-source-inventory.ts'),import('../src/db/database-restore-quarantine.ts'),
+ ])
+ const store=async(path,data)=>{await writeFile(path,data,{flag:'wx',mode:0o600});return path}
+ const {body:migrationBody,pin}=await ownedLegacyProbe0037Body(),manifestSha256=migrationManifestDigest()
+ const truncate=`TRUNCATE TABLE ${LEGACY_PROBE_RELATIONS.map(name=>`ONLY public.${name}`).join(', ')} CONTINUE IDENTITY RESTRICT`
+ const base=await live.connect()
+ let before,after
+ const schema=async sql=>{
+ await sql.query("SET LOCAL search_path=pg_catalog; SET LOCAL TimeZone='UTC'; SET LOCAL DateStyle='ISO, YMD'")
+ return (await captureMigrationSchema(sql,{scope:{applicationNamespaces:['public'],excludedControlNamespaces:['mmapp_control']},deadlineAt:Date.now()+30000})).sha256
+ }
+ try {
+ await base.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');before=await schema(base);await base.query('ROLLBACK')
+ await base.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ WRITE')
+ await base.query(truncate);await base.query(migrationBody);await base.query('SET TRANSACTION READ ONLY');after=await schema(base)
+ } finally { try { await base.query('ROLLBACK') } finally { base.release() } }
+ assert.notEqual(before,after)
+ await live.query(DATABASE_RESTORE_QUARANTINE_DDL)
+ const control=await acquireDatabaseSchemaControl(live)
+ try {
+ // The guarded fixture already installed exactly these 36 files on the owned DB.
+ for(const migration of MIGRATION_MANIFEST.slice(0,36)){
+ const id=randomUUID(), begun=await control.transition({type:'begin',id,kind:'migration',manifestSha256,artifactSha256:migration.sha256})
+ await control.transition({type:'terminal',id,outcome:'observed-success',observationSha256:await observation(begun.state.intent,migration)})
+ }
+ } finally { await control.close() }
+ const baseline=(await live.query('SELECT state FROM mmapp_control.database_schema_state WHERE id=1')).rows[0].state
+ const registry=await readDatabaseSourceBindingRegistry(originalPin),record=registry.body.source,host='localhost'
+ const tls={serverName:host,caSha256:sourceBindingSha256(leafBytes),spkiSha256:sourceBindingSha256(new X509Certificate(leafBytes).publicKey.export({type:'spki',format:'der'}))}
+ const names={publisher:options.user,runtime:'owned_handoff_runtime',operator:'owned_handoff_operator',control:'owned_handoff_control',capture:'owned_handoff_capture'}
+ await live.query(Object.values(names).filter(name=>name!==options.user).map(name=>`CREATE ROLE ${name} NOLOGIN`).join(';'))
+ const {rows:roles}=await live.query('SELECT rolname AS name,oid::text AS "signedOid" FROM pg_catalog.pg_roles WHERE rolname=ANY($1)',[Object.values(names)])
+ const request={format:'application-writer-bootstrap-request-v1',installationId:originalPin.installationId,sourceHeadSha256:originalPin.currentHeadSha256,tls,
+ roles:Object.fromEntries(Object.entries(names).map(([scope,name])=>[scope,roles.find(role=>role.name===name)])),
+ source:{systemIdentifier:record.systemIdentifier,databaseOid:String(record.databaseOid),databaseName:record.databaseName,serverVersionNum:record.serverVersionNum,inRecovery:false}}
+ const boot=sourceBindingBytes(createBootstrapMaterial(request,sourceBindingSha256(sourceBindingBytes(request))).bootstrap)
+ const transport=sourceBindingBytes({host,port:options.port,user:options.user,password:options.password,database:options.database})
+ const activationDirectory=join(directory,'owned-handoff-active');await mkdir(activationDirectory,{mode:0o700})
+ const activation=sourceBindingBytes({format:'database-source-activation-v1',activationDirectory,installationId:originalPin.installationId,
+ sourceIdentityId:registry.body.sourceIdentityId,status:'active',publicKeySpkiSha256:originalPin.publicKeySpkiSha256,
+ generations:[{generation:registry.body.generation,headSha256:registry.headSha256,bindingSha256:registry.head.bindingSha256,tlsSpkiSha256:tls.spkiSha256}]})
+ await store(join(activationDirectory,'source-activation.json'),activation)
+ const argv=['legacy-handoff-inspect','--bootstrap',await store(join(directory,'owned-handoff-bootstrap.json'),boot),'--bootstrap-sha256',sourceBindingSha256(boot),
+ '--transport',await store(join(directory,'owned-handoff-transport.json'),transport),'--transport-sha256',sourceBindingSha256(transport),
+ '--ca',await store(join(directory,'owned-handoff-ca.pem'),leafBytes),'--source-registry',originalPin.registryDirectory,'--source-spki-sha256',originalPin.publicKeySpkiSha256,
+ '--activation-directory',activationDirectory,'--activation-sha256',sourceBindingSha256(activation)]
+ let modeledFiles
+ if(process.platform==='win32'){
+ const {mock}=await import('node:test'),url=new URL('./writer-profile/operator-files.mjs',import.meta.url),files=await import(url.href)
+ const protectedDirectory=async path=>{assert(path===directory||path.startsWith(directory+sep));assert.equal(await realpath(path),path)}
+ modeledFiles=mock.module(url,{namedExports:{...files,protectedDirectory,async writeFile(path,blob,options){
+ await protectedDirectory(dirname(path));const file=await open(path,options.flag,options.mode)
+ try{await file.writeFile(blob);await file.sync()}finally{await file.close()}
+ },async readProtected(path,limit,hash){
+ await protectedDirectory(dirname(path));const bytes=await readFile(path);assert(bytes.length>0&&bytes.length<=limit);if(hash!==undefined)assert.equal(sourceBindingSha256(bytes),hash);return bytes
+ },async withJournalLease(path,work){
+ await protectedDirectory(path);const lock=join(path,'publisher-lease.lock'),file=await open(lock,'wx',0o600)
+ try{return await work()}finally{await file.close();await unlink(lock)}
+ }}})
+ }
+ try{
+ const {main}=await import('./database-writer-profile-operator.mts')
+ const {publishLegacyHandoffIntent}=await import('./writer-profile/publisher.mjs')
+ if(intentOnly){
+ const cases=['no-drain','control-refusal','acknowledged','lost-ack']
+ for(const testCase of cases){
+ const operationId=randomUUID(),archiveDirectory=join(directory,operationId);await mkdir(archiveDirectory,{mode:0o700})
+ for(const [name,blob] of [['legacy-probe.dump',archive],['legacy-probe-approval.json',signedApproval],['legacy-probe-cold.dump',fullArchive]])await store(join(archiveDirectory,name),blob)
+ const application=await live.connect()
+ if(testCase==='control-refusal')await live.query(`CREATE FUNCTION mmapp_control.owned_refuse_quarantine() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'owned control refusal'; END $$;
+ CREATE TRIGGER owned_refuse_quarantine BEFORE UPDATE ON mmapp_control.database_restore_quarantine FOR EACH ROW EXECUTE FUNCTION mmapp_control.owned_refuse_quarantine()`)
+ let control,commits=0
+ try{
+ if(testCase!=='no-drain')for(const key of [8723130,8723102,8723110])await application.query('SELECT pg_advisory_lock($1::bigint)',[key])
+ await application.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ WRITE')
+ if(testCase!=='no-drain')await application.query(`LOCK TABLE ${[...LEGACY_PROBE_CUSTODY_RELATIONS,'mcp_settings'].map(name=>`public.${name}`).join(', ')} IN ACCESS EXCLUSIVE MODE NOWAIT`)
+ const {rows:[{xid}]}=await application.query('SELECT pg_current_xact_id()::text AS xid')
+ const intent={format:'legacy-probe-0037-handoff-intent-v1',operationId,applicationXid:xid,approvalSha256:sourceBindingSha256(signedApproval),
+ coldArchiveSha256:sourceBindingSha256(fullArchive),preSchemaSha256:before,postSchemaSha256:after,manifestSha256,migrationSha256:pin.sha256}
+ const signedIntent=sourceBindingBytes({body:intent,signature:sign(null,Buffer.from(LEGACY_PROBE_HANDOFF_DOMAIN+sourceBindingCanonical(intent)),privateKey).toString('base64url')})
+ control=await acquireDatabaseSchemaControl({async connect(){
+ const client=await live.connect()
+ return {release:bad=>client.release(bad),async query(text,values){
+ const result=await client.query(text,values)
+ if(text==='COMMIT'&&++commits===2&&testCase==='lost-ack')throw Error('owned control COMMIT ACK lost')
+ return result
+ }}
+ }})
+ const publish=()=>publishLegacyHandoffIntent({application,control,sourcePin:originalPin,tlsPin:tls,archiveDirectory,signedIntent,deadlineAt:Date.now()+30000})
+ const intentFile=join(archiveDirectory,'legacy-probe-handoff-intent.json'), unknownFile=join(archiveDirectory,'legacy-probe-handoff-control-unknown.json')
+ if(testCase==='acknowledged'){
+ const receipt=await publish();assert.equal(receipt.intentRecorded,true);assert.equal(receipt.readyAuthorized,false)
+ }else if(testCase==='no-drain'){
+ await assert.rejects(publish(),/exclusive drain no longer held/)
+ await assert.rejects(readFile(intentFile),{code:'ENOENT'})
+ }else await assert.rejects(publish(),{outcomeUnknown:testCase==='lost-ack'})
+ if(testCase!=='no-drain')assert.equal(sourceBindingSha256(await readFile(intentFile)),sourceBindingSha256(signedIntent))
+ if(testCase==='lost-ack'){
+ const observation=JSON.parse(await readFile(unknownFile,'utf8'))
+ assert.equal(observation.operationId,operationId);assert.equal(observation.automaticReplay,false)
+ await assert.rejects(publish(),{code:'EEXIST'})
+ assert.equal(commits,2)
+ }else await assert.rejects(readFile(unknownFile),{code:'ENOENT'})
+ const recorded=testCase==='acknowledged'||testCase==='lost-ack'
+ const {rows:[facts]}=await live.query(`SELECT q.operation_id,s.state->'intent'->>'id' AS pending,
+ (SELECT count(*)::int FROM mmapp_control.database_schema_intents) AS history
+ FROM mmapp_control.database_restore_quarantine q CROSS JOIN mmapp_control.database_schema_state s WHERE q.id=1 AND s.id=1`)
+ assert.deepEqual(facts,{operation_id:recorded?operationId:null,pending:recorded?operationId:null,history:recorded?37:36})
+ await application.query('ROLLBACK')
+ await application.query('SELECT pg_advisory_unlock_all()')
+ if(recorded){
+ const result=await main([...argv,'--archive-directory',archiveDirectory,'--handoff-intent-sha256',sourceBindingSha256(signedIntent)])
+ assert.equal(result.outcome,'rolled-back');assert.equal(result.operationId,operationId);assert.equal(result.quarantineActive,true)
+ }
+ if(recorded&&testCase!=='lost-ack'){
+ await live.query('DELETE FROM mmapp_control.database_schema_intents WHERE id=$1',[operationId])
+ await live.query('UPDATE mmapp_control.database_schema_state SET state=$1::jsonb WHERE id=1',[JSON.stringify(baseline)])
+ await live.query('UPDATE mmapp_control.database_restore_quarantine SET operation_id=NULL WHERE id=1')
+ }
+ }finally{
+ try{await control?.close()}finally{application.release(true)}
+ if(testCase==='control-refusal')await live.query('DROP TRIGGER owned_refuse_quarantine ON mmapp_control.database_restore_quarantine; DROP FUNCTION mmapp_control.owned_refuse_quarantine()')
+ }
+ }
+ return {legacyHandoffIntentPublished:true,controlRefusalAtomic:true,controlAckLossRecordedUnknown:true,applicationCommit:false,readyAuthorized:false}
+ }
+ for(const commits of [false,true]){
+ const operationId=randomUUID(),archiveDirectory=join(directory,operationId);await mkdir(archiveDirectory,{mode:0o700})
+ for(const [name,blob] of [['legacy-probe.dump',archive],['legacy-probe-approval.json',signedApproval],['legacy-probe-cold.dump',fullArchive]])await store(join(archiveDirectory,name),blob)
+ const application=await live.connect()
+ try{
+ await application.query('BEGIN');const {rows:[{xid}]}=await application.query('SELECT pg_current_xact_id()::text AS xid')
+ const body={format:'legacy-probe-0037-handoff-intent-v1',operationId,applicationXid:xid,approvalSha256:sourceBindingSha256(signedApproval),
+ coldArchiveSha256:sourceBindingSha256(fullArchive),preSchemaSha256:before,postSchemaSha256:after,manifestSha256,migrationSha256:pin.sha256}
+ const intent=sourceBindingBytes({body,signature:sign(null,Buffer.from(LEGACY_PROBE_HANDOFF_DOMAIN+sourceBindingCanonical(body)),privateKey).toString('base64url')})
+ const file=await open(join(archiveDirectory,'legacy-probe-handoff-intent.json'),'wx',0o600)
+ try { await file.writeFile(intent);await file.sync() } finally { await file.close() }
+ const input=[...argv,'--archive-directory',archiveDirectory,'--handoff-intent-sha256',sourceBindingSha256(intent)]
+ const controller=await acquireDatabaseSchemaControl(live)
+ try{await controller.transition({type:'begin',id:operationId,kind:'migration',manifestSha256,artifactSha256:sourceBindingSha256(intent)})}finally{await controller.close()}
+ await beginDatabaseRestoreQuarantine(live,operationId)
+ const inspect=async expected=>{
+ const result=await main(input)
+ assert.deepEqual({outcome:result.outcome,operationId:result.operationId,quarantine:result.quarantineActive,ready:result.readyAuthorized},
+ {outcome:expected,operationId,quarantine:true,ready:false})
+ const {rows:[gates]}=await live.query(`SELECT q.operation_id,s.state->'intent'->>'id' AS pending
+ FROM mmapp_control.database_restore_quarantine q CROSS JOIN mmapp_control.database_schema_state s WHERE q.id=1 AND s.id=1`)
+ assert.deepEqual(gates,{operation_id:operationId,pending:operationId})
+ }
+ await inspect('unknown')
+ if(commits){await application.query(truncate);await application.query(migrationBody)}
+ await application.query(commits?'COMMIT':'ROLLBACK')
+ await inspect(commits?'committed':'rolled-back')
+ if(!commits){
+ // Own harness resets its control-only fixture for the independent COMMIT case.
+ await live.query('DELETE FROM mmapp_control.database_schema_intents WHERE id=$1',[operationId])
+ await live.query('UPDATE mmapp_control.database_schema_state SET state=$1::jsonb WHERE id=1',[JSON.stringify(baseline)])
+ await live.query('UPDATE mmapp_control.database_restore_quarantine SET operation_id=NULL WHERE id=1')
+ }
+ }finally{try{await application.query('ROLLBACK')}finally{application.release()}}
+ }
+ } finally { modeledFiles?.restore() }
+ return {legacyHandoffInspection:true,unknownObserved:true,rollbackObserved:true,commitObserved:true,quarantineCleared:false,readyAuthorized:false}
+}
diff --git a/backend/scripts/mcp-external-process/bridge-vlan-client.mjs b/backend/scripts/mcp-external-process/bridge-vlan-client.mjs
new file mode 100644
index 00000000..50046272
--- /dev/null
+++ b/backend/scripts/mcp-external-process/bridge-vlan-client.mjs
@@ -0,0 +1,73 @@
+/** External SDK consumer. No application/store/runtime/database imports. */
+import assert from 'node:assert/strict'
+import { randomUUID } from 'node:crypto'
+import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
+
+const endpoint = new URL(process.env.OWN_MCP_ENDPOINT)
+assert.equal(process.env.OWN_EXTERNAL_CLIENT, 'true')
+assert.equal(endpoint.hostname, '127.0.0.1')
+assert.notEqual(process.pid, Number(process.env.OWN_SERVER_PID))
+const client = new Client({ name: 'owned-linked-bridge-vlan-sdk', version: '1.0.0' })
+const boundedFetch = async (input, init) => {
+ const url = new URL(typeof input === 'string' || input instanceof URL ? input : input.url)
+ assert.equal(url.origin, endpoint.origin)
+ return fetch(input, { ...init, redirect: 'manual', signal: AbortSignal.timeout(10000) })
+}
+const payload = result => {
+ const text = result.content.find(item => item.type === 'text')?.text
+ assert(text && Buffer.byteLength(text) < 131072)
+ return JSON.parse(text)
+}
+const call = async (name, args) => {
+ const result = await client.callTool({ name, arguments: args }, undefined, { timeout: 10000 })
+ assert(!result.isError, JSON.stringify(payload(result)))
+ return payload(result)
+}
+try {
+ await client.connect(new StreamableHTTPClientTransport(endpoint, {
+ requestInit: { headers: { authorization: 'Bearer ' + process.env.OWN_MCP_TOKEN } }, fetch: boundedFetch,
+ }), { timeout: 10000 })
+ const tools = (await client.listTools({}, { timeout: 10000 })).tools
+ const read = tools.find(tool => tool.name === 'mm_bridge_vlan_configuration_get')
+ const configure = tools.find(tool => tool.name === 'mm_bridge_vlan_configuration_plan')
+ assert(read && configure)
+ assert.match(read.description, /Полная конфигурация bridge VLAN/)
+ assert.match(read.description, /Возвращает данные только из разрешённой области/)
+ assert.match(configure.description, /Связанный план VLAN membership, PVID и bridge filtering/)
+ assert.match(configure.description, /Подготавливает неизменяемый план/)
+ assert.equal(read.annotations.readOnlyHint, true)
+ assert.equal(configure.annotations.readOnlyHint, false)
+ assert.deepEqual(read.inputSchema.required, ['serverId'])
+ assert.deepEqual(configure.inputSchema.required, ['serverId', 'bridgeId', 'desired'])
+ const desiredSchema = configure.inputSchema.properties.desired
+ for (const name of ['ports', 'vlans', 'removePortIds', 'removeVlanIds']) assert(desiredSchema.properties[name])
+ const serverId = Number(process.env.OWN_ALLOWED_SERVER)
+ const state = (await call(read.name, { serverId })).state
+ assert.equal(state.bridges[0]['.id'], '*1')
+ assert(state.interfaces.some(item => item.resource === 'ethernet' && item.id === '*3' && item.name === 'ether3'))
+ assert.equal(state.vlans[0]['vlan-ids'], '10')
+ const cpu = { resource: 'bridge', id: '*1' }, access = { resource: 'ethernet', id: '*2' }, trunk = { resource: 'ethernet', id: '*3' }
+ const plan = await call(configure.name, { serverId, bridgeId: '*1', desired: {
+ filtering: true, pvid: 1,
+ ports: [{ id: '*10', interface: access, pvid: 10, ingressFiltering: true, frameTypes: 'admit-all', disabled: false },
+ { interface: trunk, pvid: 1, ingressFiltering: true, frameTypes: 'admit-only-vlan-tagged', disabled: false }],
+ vlans: [{ id: '*11', vlanIds: '10', tagged: [cpu], untagged: [access], disabled: false },
+ { vlanIds: '20', tagged: [cpu, trunk], untagged: [], disabled: false }], removePortIds: [], removeVlanIds: [],
+ } })
+ assert.equal(plan.state, 'awaiting-approval')
+ assert.equal(typeof plan.planId, 'string')
+ assert.equal(plan.changes.requiresHuman, true)
+ assert.deepEqual(plan.changes.steps.map(item => [item.step.resource, item.step.action]),
+ [['bridge_vlan', 'create'], ['bridge_port', 'create'], ['bridge', 'update']])
+ const denied = await client.callTool({ name: 'mm_change_apply', arguments: { planId: plan.planId, idempotencyKey: randomUUID() } }, undefined, { timeout: 10000 })
+ assert.equal(denied.isError, true)
+ const deniedPayload = payload(denied)
+ assert(JSON.stringify(deniedPayload).includes('APPROVAL_REQUIRED'))
+ const readback = (await call(read.name, { serverId })).state
+ assert.deepEqual(readback, state)
+ process.send({ kind: 'result', result: { externalSdkProcess: true, transport: 'streamable-http', clientPid: process.pid,
+ listedTools: [read, configure], state, plan, applyDenial: deniedPayload, unchangedReadback: true } })
+} finally {
+ await client.close()
+ process.disconnect?.()
+}
diff --git a/backend/scripts/mcp-external-process/bridge-vlan-fixture.ts b/backend/scripts/mcp-external-process/bridge-vlan-fixture.ts
new file mode 100644
index 00000000..7e106061
--- /dev/null
+++ b/backend/scripts/mcp-external-process/bridge-vlan-fixture.ts
@@ -0,0 +1,84 @@
+import assert from 'node:assert/strict'
+import { spawn } from 'node:child_process'
+import { createServer } from 'node:http'
+import { writeFile } from 'node:fs/promises'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+import { isAbsolute, resolve } from 'node:path'
+
+assert.equal(process.env.OWN_EXTERNAL_PROCESS_PG, 'true')
+assert.equal(process.env.NODE_ENV, 'test')
+assert(isAbsolute(process.env.OWN_EXTERNAL_SOURCE_ROOT!))
+assert(isAbsolute(process.env.OWN_EXTERNAL_RESULT_FILE!))
+const database = new URL(process.env.DATABASE_URL!)
+assert.equal(database.hostname, '127.0.0.1'); assert.equal(database.username, 'mcp_test')
+assert.equal(database.pathname, '/postgres'); assert.notEqual(database.port, '5432')
+const source = (path: string) => pathToFileURL(resolve(process.env.OWN_EXTERNAL_SOURCE_ROOT!, 'backend/src', path)).href
+const rows: Record[]> = {
+ '/interface/ethernet': [{ '.id': '*2', name: 'ether2', disabled: 'false' }, { '.id': '*3', name: 'ether3', disabled: 'false' }, { '.id': '*4', name: 'ether-mgmt', disabled: 'false' }],
+ '/interface/bridge': [{ '.id': '*1', name: 'br-users', pvid: '1', 'vlan-filtering': 'false', 'frame-types': 'admit-all', 'ingress-filtering': 'true', mvrp: 'false', disabled: 'false' }],
+ '/interface/bridge/port': [{ '.id': '*10', bridge: 'br-users', interface: 'ether2', pvid: '10', 'ingress-filtering': 'true', 'frame-types': 'admit-all', disabled: 'false' }],
+ '/interface/bridge/vlan': [{ '.id': '*11', bridge: 'br-users', 'vlan-ids': '10', tagged: 'br-users', untagged: 'ether2', disabled: 'false', dynamic: 'false' }],
+ '/interface/vlan': [], '/interface/gre': [], '/interface/wireguard': [], '/interface/vxlan': [],
+ '/ip/address': [{ '.id': '*20', interface: 'ether-mgmt', address: '127.0.0.1/8', disabled: 'false', dynamic: 'false' }], '/ipv6/address': [],
+}
+const requests: string[] = []
+let writeAttempts = 0
+const router = createServer((req, res) => {
+ res.setHeader('content-type', 'application/json')
+ const path = decodeURIComponent(new URL(req.url!, 'http://127.0.0.1').pathname.replace(/^\/rest/, ''))
+ requests.push(req.method + ' ' + path)
+ if (req.method !== 'GET') { writeAttempts++; res.writeHead(405); res.end('{}'); return }
+ if (req.headers.authorization !== 'Basic ' + Buffer.from('fixture:fixture-only').toString('base64')) { res.writeHead(401); res.end('{}'); return }
+ if (!Object.hasOwn(rows, path)) { res.writeHead(404); res.end('{}'); return }
+ res.end(JSON.stringify(rows[path]))
+})
+await new Promise(done => router.listen(0, '127.0.0.1', done))
+const { pool, closePool } = await import(source('db/index.js'))
+const { applySqlMigrations } = await import(source('db/migrate.js'))
+const { mcpConnectionCreateSchema } = await import('@mmapp/contracts/mcp')
+const { createMcpConnection, updateMcpSettings } = await import(source('modules/mcp/store.js'))
+const { buildApp } = await import(source('index.js'))
+const actor = { id: 'owned-bridge-vlan-sdk-owner', email: 'bridge-sdk@example.invalid', name: 'Owned bridge VLAN SDK owner', apps: ['mm'], permissions: ['mm:settings:admin', 'mm:mcp:admin', 'mm:network:admin', 'mm:servers:admin'], expiresAt: Date.now() + 3600000, issuedAt: Date.now() - 1000 }
+let app: Awaited> | undefined
+let child: ReturnType | undefined
+let childExit: Promise | undefined
+try {
+ await applySqlMigrations(pool)
+ const serverId = (await pool.query("INSERT INTO servers(name,host,port,use_ssl,enabled,username,password) VALUES('owned bridge VLAN SDK','127.0.0.1',$1,false,true,'fixture','fixture-only') RETURNING id", [(router.address() as { port: number }).port])).rows[0].id
+ await updateMcpSettings({ enabled: true }, actor)
+ app = await buildApp({ startScheduler: false, logger: false })
+ await app.listen({ host: '127.0.0.1', port: 0 })
+ const endpoint = `http://127.0.0.1:${(app.server.address() as { port: number }).port}/mcp`
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({ name: 'Owned bridge VLAN external SDK', mode: 'autonomous',
+ expiresAt: new Date(Date.now() + 1200000).toISOString(), permissions: ['mm:network:write'],
+ scope: { serverIds: [serverId], operationIds: ['network.bridge-vlan.read', 'network.bridge-vlan.configure', 'changes.apply'], allowGlobal: false },
+ limits: { callsPerMinute: 120, mutationsPerHour: 100 } }), actor)
+ let result: unknown, stdout = '', stderr = ''
+ child = spawn(process.execPath, [fileURLToPath(new URL('./bridge-vlan-client.mjs', import.meta.url))], { cwd: process.cwd(), windowsHide: true,
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'], env: { ...Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'PATH', 'Path'].filter(k => process.env[k]).map(k => [k, process.env[k]!])),
+ OWN_EXTERNAL_CLIENT: 'true', OWN_MCP_ENDPOINT: endpoint, OWN_MCP_TOKEN: issued.token, OWN_SERVER_PID: String(process.pid), OWN_ALLOWED_SERVER: String(serverId) } })
+ child.on('message', (message: { kind: string; result?: unknown }) => { if (message.kind === 'result') result = message.result })
+ child.stdout?.on('data', chunk => { stdout += String(chunk); if (stdout.length > 1048576) child?.kill() })
+ child.stderr?.on('data', chunk => { stderr += String(chunk); if (stderr.length > 1048576) child?.kill() })
+ childExit = new Promise((done, reject) => { child!.once('exit', code => done(code ?? 1)); child!.once('error', reject) })
+ const timeout = setTimeout(() => child?.kill(), 60000)
+ const code = await childExit; clearTimeout(timeout)
+ assert.equal(code, 0, stderr.slice(0, 3000)); assert(result)
+ assert.equal(writeAttempts, 0)
+ assert.equal((await pool.query('SELECT count(*)::int AS count FROM mcp_operations')).rows[0].count, 0)
+ const plans = (await pool.query('SELECT operation_id,state,approved_by FROM mcp_plans')).rows
+ assert.equal(plans.length, 1); assert.equal(plans[0].operation_id, 'network.bridge-vlan.configure')
+ assert.equal(plans[0].state, 'awaiting-approval'); assert.equal(plans[0].approved_by, null)
+ const audit = (await pool.query('SELECT tool,status,error_code FROM mcp_requests ORDER BY created_at')).rows
+ assert(audit.some(row => row.error_code === 'APPROVAL_REQUIRED'))
+ const serialized = JSON.stringify({ result, stdout, stderr, audit })
+ assert(!serialized.includes(issued.token)); assert(!serialized.includes('fixture-only'))
+ const final = { ...(result as object), actualOwnPg: true, actualProductionHttpServer: true, serverFixturePid: process.pid,
+ connectionMode: 'autonomous', plans, audit, nativeReadRequests: requests, nativeWriteAttempts: writeAttempts,
+ appliedOperations: 0, syntheticRouterOnly: true, productionDatabaseTouched: false, portalContacted: false }
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(final, null, 2))
+ console.log('Owned bridge VLAN SDK passed:', JSON.stringify({ listedTools: 2, planState: plans[0].state, nativeReadRequests: requests.length, nativeWriteAttempts: writeAttempts }))
+} finally {
+ if (child && child.exitCode === null && child.signalCode === null) { child.kill(); await childExit }
+ try { await app?.close() } finally { try { await closePool() } finally { router.closeIdleConnections(); await new Promise((done, reject) => router.close(error => error ? reject(error) : done())) } }
+}
diff --git a/backend/scripts/mcp-external-process/client.mjs b/backend/scripts/mcp-external-process/client.mjs
new file mode 100644
index 00000000..f147c573
--- /dev/null
+++ b/backend/scripts/mcp-external-process/client.mjs
@@ -0,0 +1,412 @@
+/** External SDK consumer: imports NO server/store/runtime/database module. */
+import assert from 'node:assert/strict'
+import { randomUUID, createHash } from 'node:crypto'
+import { Client, StreamableHTTPClientTransport, auth } from '@modelcontextprotocol/client'
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'
+const endpoint = new URL(process.env.OWN_MCP_ENDPOINT), origin = endpoint.origin
+assert.equal(endpoint.hostname, '127.0.0.1'); assert.equal(process.env.OWN_EXTERNAL_CLIENT, 'true')
+let phase = 'start', next = 0, maxResponseBytes = 0, stderrBytes = 0, bridgePid = null
+const responseLimitBytes = 1024 * 1024
+const pending = new Map(), cases = []
+const activeClients = new Set()
+let closing = false
+async function closeClients() { await Promise.allSettled([...activeClients].map(client => client.close())) }
+async function interrupted() { if (closing) return; closing = true; await closeClients(); process.disconnect?.(); process.exitCode = 1 }
+process.on('SIGTERM', interrupted); process.on('SIGINT', interrupted); process.on('disconnect', interrupted)
+process.on('message', m => { if (m?.kind === 'reply') { const p = pending.get(m.id); pending.delete(m.id); if (m.error) p?.reject(Error('Fixture control refused')); else p?.resolve(m.value) } })
+const control = command => new Promise((resolve, reject) => { const id = ++next; pending.set(id, { resolve, reject }); process.send({ kind: 'control', command, id }) })
+async function boundedFetch(input, init) {
+ const url = new URL(typeof input === 'string' || input instanceof URL ? input : input.url)
+ assert.equal(url.origin, origin, 'External fixture refuses all nonlocal origins')
+ const response = await fetch(input, { ...init, redirect: 'manual', signal: init?.signal ? AbortSignal.any([init.signal, AbortSignal.timeout(5000)]) : AbortSignal.timeout(5000) })
+ const chunks = []; let count = 0
+ if (response.body) {
+ const reader = response.body.getReader()
+ try {
+ for (;;) { const item = await reader.read(); if (item.done) break; count += item.value.length; if (count >= responseLimitBytes) { await reader.cancel(); throw Error('Own external client response bound') }; chunks.push(item.value) }
+ } finally { reader.releaseLock() }
+ }
+ const bytes = Buffer.concat(chunks); maxResponseBytes = Math.max(maxResponseBytes, bytes.length)
+ return new Response(bytes.length ? bytes : null, { status: response.status, statusText: response.statusText, headers: response.headers })
+}
+function content(result) {
+ assert(!result.isError)
+ const text = result.content.find(c => c.type === 'text')?.text
+ const parsed = JSON.parse(text)
+ assert(!text.includes(process.env.OWN_SERVER_SECRET)); assert(Buffer.byteLength(text) < 65536)
+ return parsed
+}
+async function denied(work) { try { const r = await work(); assert.equal(r?.isError, true) } catch (e) { if (e?.code === 'ERR_ASSERTION') throw e; assert(!/timeout|timed out/i.test(String(e?.message)), 'A timeout is not authorization denial') } }
+async function opened(mode, token, maxBufferSize = 131072) {
+ const client = new Client({ name: 'actual-external-process-' + mode, version: '1.0.0' })
+ activeClients.add(client)
+ let transport
+ if (mode === 'http') transport = new StreamableHTTPClientTransport(endpoint, { requestInit: { headers: { authorization: 'Bearer ' + token } }, fetch: boundedFetch })
+ else {
+ transport = new StdioClientTransport({ command: process.execPath, args: ['--import', import.meta.resolve('tsx'), process.env.OWN_BRIDGE_FILE],
+ cwd: process.cwd(), env: { MCP_URL: endpoint.href, MCP_TOKEN: token }, stderr: 'pipe', maxBufferSize })
+ transport.stderr?.on('data', chunk => { stderrBytes += chunk.length; const text = String(chunk); assert(!text.includes(token)); assert(stderrBytes < 1048576) })
+ const start = transport.start.bind(transport)
+ transport.start = async () => { await start(); bridgePid = transport.pid; assert(bridgePid && bridgePid !== process.pid && bridgePid !== Number(process.env.OWN_SERVER_PID)); process.send({ kind: 'bridge-pid', pid: bridgePid }) }
+ }
+ const connecting = client.connect(transport, { timeout: 10000 })
+ try { await connecting; return client }
+ catch (e) { await client.close().catch(() => {}); throw e }
+}
+async function scoped(client) {
+ const list = await client.listTools({}, { timeout: 5000 })
+ assert.deepEqual(list.tools.map(t => t.name), ['mm_servers_list'])
+ const result = content(await client.callTool({ name: 'mm_servers_list', arguments: { limit: 1, offset: 0 } }, undefined, { timeout: 5000 }))
+ assert.equal(result.items.length, 1); assert.equal(result.items[0].id, Number(process.env.OWN_ALLOWED_SERVER))
+ await denied(() => client.callTool({ name: 'mm_servers_list', arguments: { serverId: Number(process.env.OWN_FORBIDDEN_SERVER) } }, undefined, { timeout: 5000 }))
+ await denied(() => client.callTool({ name: 'mm_servers_list', arguments: { limit: 501 } }, undefined, { timeout: 5000 }))
+ await denied(() => client.callTool({ name: 'mm_servers_delete_plan', arguments: { serverId: Number(process.env.OWN_ALLOWED_SERVER) } }, undefined, { timeout: 5000 }))
+}
+try {
+ assert.notEqual(process.pid, Number(process.env.OWN_SERVER_PID))
+ phase = 'http:owner-logs-lifecycle'
+ {
+ const headers = { authorization: 'Bearer ' + process.env.OWN_PORTAL_JWT, 'content-type': 'application/json' }
+ const allowedServer = Number(process.env.OWN_ALLOWED_SERVER), forbiddenServer = Number(process.env.OWN_FORBIDDEN_SERVER)
+ const issuedResponse = await boundedFetch(origin + '/api/mcp/connections', {
+ method: 'POST', headers,
+ body: JSON.stringify({ name: 'Owned portal log reader', mode: 'observer', expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions: ['mm:servers:read'], scope: { serverIds: [allowedServer], operationIds: ['logs.query'], allowGlobal: false } }),
+ })
+ assert.equal(issuedResponse.status, 200)
+ const { connection, token } = await issuedResponse.json()
+ const client = await opened('http', token)
+ const queryLogs = serverId => client.callTool({
+ name: 'mm_logs_query', arguments: { serverId, q: 'external-sdk-log-', limit: 1 },
+ }, undefined, { timeout: 5000 })
+ try {
+ assert.deepEqual((await client.listTools({}, { timeout: 5000 })).tools.map(tool => tool.name), ['mm_logs_query'])
+ const result = content(await queryLogs(allowedServer))
+ assert.deepEqual(result.entries.map(entry => entry.serverId), [allowedServer])
+ await denied(() => queryLogs(forbiddenServer))
+ const monitor = await boundedFetch(origin + '/api/mcp/requests?' + new URLSearchParams({
+ connectionId: connection.id, tool: 'mm_logs_query',
+ }), { headers })
+ assert.equal(monitor.status, 200)
+ const body = await monitor.text()
+ assert(!body.includes(token))
+ const { items } = JSON.parse(body)
+ assert.equal(items.length, 2)
+ assert(items.every(row => row.connection_id === connection.id && row.tool === 'mm_logs_query'))
+ assert(items.some(row => row.status === 'denied'))
+ assert(items.some(row => row.error_code === null && row.finished_at && row.result?.entries?.[0]?.serverId === allowedServer))
+
+ const revoke = await boundedFetch(origin + '/api/mcp/connections/' + connection.id + '/status', {
+ method: 'POST', headers, body: JSON.stringify({ status: 'revoked' }),
+ })
+ assert.equal(revoke.status, 200)
+ await denied(() => queryLogs(allowedServer))
+ await assert.rejects(opened('http', token))
+ cases.push('http: owner API issues restricted log access, monitors allow/deny and revokes the same SDK connection')
+ } finally { await client.close().catch(() => {}) }
+ }
+ for (const mode of ['http', 'stdio']) {
+ phase = mode + ':issue'; const initial = await control('new-connection'); let token = initial.token
+ phase = mode + ':initialize'; let client = await opened(mode, token)
+ try {
+ await scoped(client); cases.push(mode + ': separate SDK process initializes, filters tool/host scope, bounds page/result and redacts credentials')
+ phase = mode + ':policy-edit'
+ const editScope = async operationIds => {
+ const response = await boundedFetch(origin + '/api/mcp/connections/' + initial.connectionId, {
+ method: 'PUT', headers: { authorization: 'Bearer ' + process.env.OWN_PORTAL_JWT, 'content-type': 'application/json' },
+ body: JSON.stringify({ name: 'Owned external SDK process', mode: 'observer', expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions: ['mm:servers:read'], scope: { serverIds: [Number(process.env.OWN_ALLOWED_SERVER)], operationIds, allowGlobal: false }, limits: { callsPerMinute: 200 } }),
+ })
+ assert.equal(response.status, 200)
+ }
+ await editScope(['logs.query'])
+ assert.deepEqual((await client.listTools({}, { timeout: 5000 })).tools.map(tool => tool.name), ['mm_logs_query'])
+ const allowedServer = Number(process.env.OWN_ALLOWED_SERVER), forbiddenServer = Number(process.env.OWN_FORBIDDEN_SERVER)
+ const queryLogs = arguments_ => client.callTool({ name: 'mm_logs_query', arguments: arguments_ }, undefined, { timeout: 5000 })
+ const filters = { q: 'external-sdk-log-', limit: 1 }
+ const first = content(await queryLogs(filters))
+ assert.ok(first.nextCursor)
+ const second = content(await queryLogs({ ...filters, cursor: first.nextCursor }))
+ assert.equal(second.nextCursor, null)
+ assert.deepEqual([first.entries, second.entries].map(entries => entries.map(({ serverId, message }) => ({ serverId, message }))), [
+ [{ serverId: allowedServer, message: 'external-sdk-log-1' }],
+ [{ serverId: allowedServer, message: 'external-sdk-log-2' }],
+ ])
+ await denied(() => queryLogs({ ...filters, serverId: forbiddenServer }))
+ cases.push(mode + ': populated log search pages return only allowed server records and reject the forbidden server')
+ await denied(() => client.callTool({ name: 'mm_servers_list', arguments: {} }, { timeout: 5000 }))
+ await editScope([])
+ assert.deepEqual((await client.listTools({}, { timeout: 5000 })).tools, [])
+ await editScope(['servers.list'])
+ await scoped(client)
+ cases.push(mode + ': established client observes removed and restored tool scope through the web policy API')
+ if (mode === 'stdio' && process.env.OWN_EXTERNAL_CLEANUP_FAULT === 'failure') throw Error('Owned deliberate external client failure with bridge active')
+ if (mode === 'stdio' && process.env.OWN_EXTERNAL_CLEANUP_FAULT === 'timeout') { process.send({ kind: 'arm-cleanup-timeout' }); await new Promise(() => {}) }
+ phase = mode + ':result-bound'; await control('large-result')
+ try {
+ const bounded = content(await client.callTool({ name: 'mm_servers_list', arguments: { limit: 1 } }, undefined, { timeout: 5000 }))
+ assert.equal(bounded.items[0].comment.length, 16000); assert(!bounded.items[0].comment.includes('OWNED_TRUNCATION_TAIL'))
+ cases.push(mode + ': actual production public-string16k bound truncates owned40k comment through real SDK result')
+ } finally { await control('reset-result') }
+ phase = mode + ':rotate'; const rotated = await control('rotate'); await denied(() => client.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 }))
+ await client.close(); await assert.rejects(opened(mode, token)); token = rotated.token; client = await opened(mode, token)
+ content(await client.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 })); cases.push(mode + ': old credential and reconnect refused after rotation; fresh transport reconnect succeeds')
+ phase = mode + ':pause'; await control('pause'); await denied(() => client.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 }))
+ await control('resume'); content(await client.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 })); cases.push(mode + ': established client observes pause/resume on real requests')
+ phase = mode + ':revoke'; await control('revoke'); await denied(() => client.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 }))
+ await client.close(); await assert.rejects(opened(mode, token)); cases.push(mode + ': permanent revocation blocks established and newly initialized external clients')
+ } finally { await client.close().catch(() => {}) }
+ }
+ phase = 'http:body-bound'; const bound = await control('new-connection')
+ // Exercise the declared length check without racing the rejected upload.
+ const { request } = await import('node:http')
+ const oversized = await new Promise((resolve, reject) => {
+ const req = request(endpoint, { method: 'POST', headers: { authorization: 'Bearer ' + bound.token,
+ 'content-type': 'application/json', accept: 'application/json,text/event-stream', connection: 'close',
+ 'content-length': '1048577' }, signal: AbortSignal.timeout(5000) }, response => {
+ let bytes = 0
+ response.on('data', chunk => {
+ bytes += chunk.length
+ if (bytes >= 65536) req.destroy(Error('Oversized refusal response'))
+ })
+ response.once('error', reject)
+ response.once('end', () => resolve(response.statusCode))
+ })
+ req.once('error', reject)
+ req.flushHeaders()
+ })
+ assert.equal(oversized, 413)
+ cases.push('actual HTTP request envelope over1MiB refused before tool execution; successful client results remain bounded')
+
+ phase = 'sdk:pkce'; const grant = await control('new-connection')
+ const metadata = { client_name: 'owned-external-sdk-pkce', redirect_uris: [origin + '/owned-callback'], grant_types: ['authorization_code', 'refresh_token'], response_types: ['code'], token_endpoint_auth_method: 'none', scope: 'mcp' }
+ const registered = await boundedFetch(origin + '/api/mcp/oauth/clients', { method: 'POST', headers: { authorization: 'Bearer ' + process.env.OWN_PORTAL_JWT, 'content-type': 'application/json' }, body: JSON.stringify({ name: metadata.client_name, redirectUris: metadata.redirect_uris }) })
+ assert.equal(registered.status, 200); const clientId = (await registered.json()).clientId
+ let tokens, verifier, authorizationCode, authorizationIssuer, discovery, consentAllowed = true
+ const state = randomUUID()
+ const provider = { redirectUrl: metadata.redirect_uris[0], clientMetadata: metadata, clientInformation: () => ({ client_id: clientId, token_endpoint_auth_method: 'none' }),
+ tokens: () => tokens, saveTokens: v => { tokens = v }, saveCodeVerifier: v => { verifier = v }, codeVerifier: () => verifier, state: () => state,
+ discoveryState: () => discovery, saveDiscoveryState: v => { discovery = v }, invalidateCredentials: scope => { if (scope === 'tokens') tokens = undefined },
+ redirectToAuthorization: async url => {
+ if (!consentAllowed) throw Error('Synthetic consent disabled after revocation')
+ assert.equal(url.origin, origin); assert.equal(url.searchParams.get('code_challenge_method'), 'S256')
+ assert.equal(url.searchParams.get('code_challenge'), createHash('sha256').update(verifier).digest('base64url'))
+ const response = await boundedFetch(url); assert.equal(response.status, 302)
+ const requestId = new URL(response.headers.get('location')).searchParams.get('oauthRequest'); assert(requestId)
+ const consent = await boundedFetch(origin + '/api/mcp/oauth/consent', { method: 'POST', headers: { authorization: 'Bearer ' + process.env.OWN_PORTAL_JWT, 'content-type': 'application/json' }, body: JSON.stringify({ requestId, connectionId: grant.connectionId, approve: true }) })
+ assert.equal(consent.status, 200); const callback = new URL((await consent.json()).redirectUrl)
+ assert.equal(callback.searchParams.get('state'), state); authorizationCode = callback.searchParams.get('code'); authorizationIssuer = callback.searchParams.get('iss')
+ } }
+ phase = 'sdk:pkce-redirect'; assert.equal(await auth(provider, { serverUrl: endpoint, scope: 'mcp', fetchFn: boundedFetch }), 'REDIRECT')
+ assert(authorizationCode && verifier); assert.equal(authorizationIssuer, origin)
+ phase = 'sdk:pkce-exchange'; assert.equal(await auth(provider, { serverUrl: endpoint, authorizationCode, iss: authorizationIssuer, fetchFn: boundedFetch }), 'AUTHORIZED')
+ assert(tokens?.access_token && tokens?.refresh_token)
+ const oauthClient = new Client({ name: 'external-sdk-real-pkce-mock-portal', version: '1.0.0' })
+ activeClients.add(oauthClient)
+ try {
+ phase = 'sdk:pkce-initialize'; await oauthClient.connect(new StreamableHTTPClientTransport(endpoint, { authProvider: provider, fetch: boundedFetch }), { timeout: 10000 })
+ content(await oauthClient.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 }))
+ cases.push('installed SDK auth() discovers actual OAuth metadata, produces PKCE/S256, exchanges one-use code and calls scoped tool; portal JWT/consent is synthetic')
+ phase = 'sdk:pkce-revoke'; const access = tokens.access_token, refresh = tokens.refresh_token
+ const revoked = await boundedFetch(origin + '/oauth/revoke', { method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ token: refresh, client_id: clientId }).toString() }); assert.equal(revoked.status, 200)
+ consentAllowed = false; await assert.rejects(opened('http', access))
+ await denied(() => oauthClient.callTool({ name: 'mm_servers_list', arguments: {} }, undefined, { timeout: 5000 }))
+ cases.push('actual OAuth family revocation refuses established and fresh external transport; no implicit new consent granted')
+ } finally { await oauthClient.close().catch(() => {}) }
+ phase = 'discovery:issue'
+ const catalogue = await control('discovery-connection')
+ const expectedNames = catalogue.names.toSorted()
+ assert(expectedNames.includes('mm_logs_follow'))
+ const discoveryByTransport = {}
+ for (const mode of ['http', 'stdio']) {
+ phase = `discovery:${mode}`
+ const client = await opened(mode, catalogue.token, responseLimitBytes)
+ try {
+ const names = [], cursors = new Set()
+ let cursor, largestPageBytes = 0, pages = 0
+ do {
+ const page = await client.listTools(cursor ? { cursor } : {}, { timeout: 10000 })
+ assert(page.tools.length > 0)
+ for (const tool of page.tools) {
+ assert.equal(tool.inputSchema.type, 'object')
+ names.push(tool.name)
+ }
+ const encoded = JSON.stringify(page)
+ assert(!encoded.includes(catalogue.token) && !encoded.includes(process.env.OWN_SERVER_SECRET))
+ largestPageBytes = Math.max(largestPageBytes, Buffer.byteLength(encoded))
+ assert(largestPageBytes < responseLimitBytes)
+ pages++
+ cursor = page.nextCursor
+ if (cursor) { assert(!cursors.has(cursor)); cursors.add(cursor) }
+ assert(names.length <= expectedNames.length)
+ } while (cursor)
+ assert.deepEqual(names.toSorted(), expectedNames)
+ discoveryByTransport[mode] = { tools: names.length, pages, largestPageBytes }
+ cases.push(mode + ': external SDK discovers every delegated tool exactly once with an object input schema')
+ } finally { await client.close().catch(() => {}) }
+ }
+ phase = 'discovery:revoke'
+ await control('revoke')
+ for (const [mode, arm] of [['http', 'arm-log-revocation'], ['stdio', 'arm-log-revocation-after-commit'], ['http', 'arm-log-follow-revocation']]) {
+ phase = mode + ':' + arm
+ const { token } = await control(arm)
+ const logClient = await opened(mode, token)
+ try {
+ const follow = arm === 'arm-log-follow-revocation'
+ const tool = follow ? 'mm_logs_follow' : 'mm_logs_query'
+ const filters = { q: follow ? 'external-sdk-live-event' : 'external-sdk-log-1', limit: 1 }
+ if (follow) {
+ Object.assign(filters, { serverId: Number(process.env.OWN_ALLOWED_SERVER), waitSeconds: 0 })
+ const start = content(await logClient.callTool({ name: tool, arguments: filters }, undefined, { timeout: 5000 }))
+ assert.deepEqual(start.entries, [])
+ assert.equal(typeof start.cursor, 'string')
+ filters.cursor = start.cursor
+ filters.waitSeconds = 10
+ }
+ const query = logClient.callTool({ name: tool, arguments: filters }, undefined, { timeout: 10000 })
+ const checked = query.then(result => {
+ assert.equal(result.isError, true)
+ const wire = JSON.stringify(result)
+ assert.match(wire, /OWNER_CLAIMS_REVOKED|UNAUTHORIZED/)
+ assert.doesNotMatch(wire, /external-sdk-log-1|external-sdk-live-event|"entries"|"nextCursor"|"cursor"/)
+ })
+ const deliver = async () => {
+ if (follow) await control('publish-follow-fixture-row')
+ await control('deliver-log-revocation')
+ }
+ await Promise.all([checked, deliver()])
+ await assert.rejects(opened(mode, token))
+ cases.push(mode + ': signed portal revocation ' + (mode === 'stdio' ? 'after' : 'before') + ' audit commit denies ' + tool + ' result and reconnect')
+ } finally { await logClient.close().catch(() => {}) }
+ }
+ phase = 'portal:revoke-export-download'
+ const exportAccess = await control('new-artifact-connection')
+ const exportClient = await opened('http', exportAccess.token)
+ try {
+ const exported = content(await exportClient.callTool({ name: 'mm_logs_export', arguments: {
+ serverId: Number(process.env.OWN_ALLOWED_SERVER), q: 'external-sdk-log-1', format: 'json',
+ } }, undefined, { timeout: 5000 }))
+ assert.equal(exported.rows, 1)
+ assert.equal(exported.downloadPath, '/api/mcp/artifacts/' + exported.artifactId)
+ assert.doesNotMatch(JSON.stringify(exported), /external-sdk-log-1/)
+ const download = jwt => boundedFetch(origin + exported.downloadPath, { headers: { authorization: 'Bearer ' + jwt } })
+ const before = await download(exportAccess.ownerJwt)
+ assert.equal(before.status, 200)
+ assert.equal(before.headers.get('cache-control'), 'private, no-store')
+ const bytes = Buffer.from(await before.arrayBuffer())
+ assert.equal(createHash('sha256').update(bytes).digest('hex'), exported.sha256)
+ assert.match(bytes.toString('utf8'), /external-sdk-log-1/)
+ const fresh = await control('revoke-artifact-owner')
+ for (const jwt of [exportAccess.ownerJwt, fresh.ownerJwt]) {
+ const refused = await download(jwt)
+ assert.ok([401, 403].includes(refused.status))
+ assert.equal(refused.headers.has('content-disposition'), false)
+ assert.doesNotMatch(await refused.text(), /external-sdk-log-1/)
+ }
+ const management = await boundedFetch(origin + '/api/mcp/connections', { headers: { authorization: 'Bearer ' + fresh.ownerJwt } })
+ assert.equal(management.status, 200)
+ cases.push('portal owner revocation blocks an existing unexpired log artifact even with refreshed owner login')
+ } finally { await exportClient.close().catch(() => {}) }
+ phase = 'portal:approved-plan-apply'
+ {
+ const headers = { authorization: 'Bearer ' + process.env.OWN_PORTAL_JWT, 'content-type': 'application/json' }
+ const settings = async () => {
+ const response = await boundedFetch(origin + '/api/logs/settings', { headers })
+ assert.equal(response.status, 200)
+ return response.json()
+ }
+ const before = await settings()
+ const intervalSec = before.intervalSec === 60 ? 61 : 60
+ const issued = await boundedFetch(origin + '/api/mcp/connections', {
+ method: 'POST', headers,
+ body: JSON.stringify({ name: 'Owned portal log settings approval', mode: 'approval',
+ expiresAt: new Date(Date.now() + 600000).toISOString(), permissions: ['mm:settings:admin'],
+ scope: { serverIds: [Number(process.env.OWN_ALLOWED_SERVER), Number(process.env.OWN_FORBIDDEN_SERVER)],
+ operationIds: ['logs.settings.update', 'changes.apply', 'operations.read'], allowGlobal: true } }),
+ })
+ assert.equal(issued.status, 200)
+ const { connection, token } = await issued.json()
+ const client = await opened('http', token)
+ try {
+ phase = 'portal:read-approved-plan-preview'
+ const call = (name, arguments_) => client.callTool({ name, arguments: arguments_ }, undefined, { timeout: 5000 })
+ const plan = content(await call('mm_logs_settings_update_plan', { settings: { intervalSec } }))
+ assert.equal(plan.state, 'awaiting-approval')
+ const planUrl = origin + '/api/mcp/plans/' + plan.planId
+ const review = await boundedFetch(planUrl, { headers })
+ assert.equal(review.status, 200)
+ const preview = await review.json()
+ assert.equal(preview.id, plan.planId)
+ assert.equal(preview.connectionId, connection.id)
+ assert.equal(preview.operationId, 'logs.settings.update')
+ assert.equal(preview.state, 'awaiting-approval')
+ assert.deepEqual(preview.input.settings, { intervalSec })
+ phase = 'portal:refuse-unapproved-plan'
+ const idempotencyKey = randomUUID()
+ const apply = () => call('mm_change_apply', { planId: plan.planId, idempotencyKey })
+ await denied(apply)
+ assert.deepEqual(await settings(), before)
+ phase = 'portal:approve-exact-plan'
+ const decision = await boundedFetch(planUrl + '/decision', {
+ method: 'POST', headers, body: JSON.stringify({ approve: true }),
+ })
+ assert.equal(decision.status, 200)
+ phase = 'portal:apply-and-read-settings'
+ const operation = content(await apply())
+ assert.match(operation.id, /^[a-f0-9-]{36}$/)
+ let terminal
+ const deadline = Date.now() + 10000
+ do {
+ terminal = content(await call('mm_operation_get', { operationId: operation.id }))
+ if (!['pending', 'running'].includes(terminal.state)) break
+ await new Promise(resolve => setTimeout(resolve, 100))
+ } while (Date.now() < deadline)
+ assert.equal(terminal.state, 'applied')
+ assert.equal(terminal.verification, 'passed')
+ assert.deepEqual(await settings(), { ...before, intervalSec })
+ assert.equal(content(await apply()).id, operation.id)
+
+ phase = 'portal:monitor-applied-plan'
+ const list = await boundedFetch(origin + '/api/mcp/operations?' + new URLSearchParams({ connectionId: connection.id }), { headers })
+ assert.equal(list.status, 200)
+ const { items } = await list.json()
+ assert.deepEqual(items.map(({ id, plan_id, state, verification }) => ({ id, plan_id, state, verification })), [
+ { id: operation.id, plan_id: plan.planId, state: 'applied', verification: 'passed' },
+ ])
+ phase = 'portal:revoke-after-apply'
+ const revoked = await boundedFetch(origin + '/api/mcp/connections/' + connection.id + '/status', {
+ method: 'POST', headers, body: JSON.stringify({ status: 'revoked' }),
+ })
+ assert.equal(revoked.status, 200)
+ await denied(apply)
+ await assert.rejects(opened('http', token))
+ cases.push('portal API approves the exact log settings plan; SDK applies once and owner sees the verified operation')
+ } finally { await client.close().catch(() => {}) }
+ }
+ phase = 'portal:revoke-approved-plan'
+ const planAccess = await control('new-revocable-plan-connection')
+ const planClient = await opened('http', planAccess.token)
+ try {
+ const plan = content(await planClient.callTool({ name: 'mm_logs_settings_update_plan', arguments: {
+ settings: { enabled: false },
+ } }, undefined, { timeout: 5000 }))
+ assert.equal(plan.state, 'awaiting-approval')
+ const approved = await boundedFetch(origin + '/api/mcp/plans/' + plan.planId + '/decision', {
+ method: 'POST', headers: { authorization: 'Bearer ' + planAccess.ownerJwt, 'content-type': 'application/json' },
+ body: JSON.stringify({ approve: true }),
+ })
+ assert.equal(approved.status, 200)
+ assert.deepEqual(await approved.json(), { ok: true })
+ await control('revoke-approved-plan-owner')
+ await denied(() => planClient.callTool({ name: 'mm_change_apply', arguments: {
+ planId: plan.planId, idempotencyKey: randomUUID(),
+ } }, undefined, { timeout: 5000 }))
+ cases.push('signed portal revocation invalidates the exact approved log settings plan before apply')
+ } finally { await planClient.close().catch(() => {}) }
+ process.send({ kind: 'result', result: { cases: cases.length, names: cases, externalClientPid: process.pid, serverPid: Number(process.env.OWN_SERVER_PID), bridgePid,
+ sdkOnlyExternalClient: true, maxObservedHttpResponseBytes: maxResponseBytes, clientResponseLimitBytes: responseLimitBytes, stdioSdkBufferLimitBytes: 131072,
+ discoveryByTransport, discoveryStdioSdkBufferLimitBytes: responseLimitBytes,
+ actualPublicStringLimitObserved: 16000, wholeGenericResultEnvelopeLimitAccepted: false,
+ syntheticPortalJwtAndConsent: true, liveAuthPortal: false, livePortalSender: false, endUserUi: false, wholeExternalDirectionComplete: false } })
+} catch (error) { process.send?.({ kind: 'failure', phase, errorType: error?.name ?? 'Error', completedCases: cases }); process.exitCode = 1 }
+finally { closing = true; await closeClients(); process.disconnect?.() }
diff --git a/backend/scripts/mcp-external-process/logs-read-client.mjs b/backend/scripts/mcp-external-process/logs-read-client.mjs
new file mode 100644
index 00000000..741d29d0
--- /dev/null
+++ b/backend/scripts/mcp-external-process/logs-read-client.mjs
@@ -0,0 +1,205 @@
+import assert from 'node:assert/strict'
+import { createHash } from 'node:crypto'
+import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
+import { resumeMcpSteps } from '../acceptance/mcp-step-journal.mjs'
+
+async function withClient(endpoint, token, run) {
+ const client = new Client({ name: 'owned-logs-sdk', version: '1.0.0' })
+ try {
+ await client.connect(new StreamableHTTPClientTransport(endpoint, {
+ requestInit: { headers: { authorization: 'Bearer ' + token } },
+ }), { timeout: 5000 })
+ return await run(async (name, args = {}) => {
+ const reply = await client.callTool({ name, arguments: args }, undefined, { timeout: 5000 })
+ assert(!reply.isError, name + ' failed')
+ return reply.structuredContent.result
+ })
+ } finally {
+ await client.close()
+ }
+}
+
+export async function verifyLogsHistory(endpoint, token, serverId, entries, journal, fixture, appendEvent) {
+ assert.equal(endpoint.hostname, '127.0.0.1')
+ const [newest, oldest] = entries
+ const filters = { serverId, q: 'external-sdk-log-', levels: ['info'] }
+ const config = { journal, fixture, steps: [
+ { id: 'mm_logs_query', async check(call) {
+ const first = await call('mm_logs_query', { ...filters, limit: 1 })
+ assert.deepEqual(first.entries.map(entry => entry.id), [newest.id])
+ assert.ok(first.nextCursor)
+ const next = await call('mm_logs_query', { ...filters, limit: 1, cursor: first.nextCursor })
+ assert.deepEqual(next.entries.map(entry => entry.id), [oldest.id])
+ assert.equal(next.nextCursor, null)
+ } },
+ { id: 'mm_logs_summary_get', async check(call) {
+ const summary = await call('mm_logs_summary_get', filters)
+ assert.equal(summary.total, 2)
+ assert.equal(summary.levels.info, 2)
+ } },
+ { id: 'mm_logs_get', async check(call) {
+ const entry = await call('mm_logs_get', { serverId, id: newest.id })
+ assert.equal(entry.id, newest.id)
+ assert.equal(entry.serverId, serverId)
+ assert.equal(entry.message, newest.message)
+ } },
+ { id: 'mm_logs_context_get', async check(call) {
+ const context = await call('mm_logs_context_get', { serverId, id: newest.id })
+ assert.equal(context.entry.id, newest.id)
+ assert.deepEqual(context.before.map(entry => [entry.serverId, entry.id]), [[serverId, oldest.id]])
+ assert.deepEqual(context.after, [])
+ } },
+ { id: 'mm_logs_follow', async check(call) {
+ const args = { ...filters, limit: 1, waitSeconds: 0 }
+ const first = await call('mm_logs_follow', args)
+ assert.deepEqual(first.entries, [], 'Initial follow starts at the current watermark')
+ assert.ok(first.cursor)
+ const id = await appendEvent()
+ const next = await call('mm_logs_follow', { ...args, cursor: first.cursor })
+ assert.deepEqual(next.entries.map(entry => entry.id), [id])
+ const end = await call('mm_logs_follow', { ...args, cursor: next.cursor })
+ assert.deepEqual(end.entries, [])
+ } },
+ ].map(({ id, check }) => ({ id, kind: 'read', async run() {
+ await withClient(endpoint, token, check)
+ return null
+ } })) }
+ const result = await resumeMcpSteps(config)
+ assert.equal(result.status, 'passed', JSON.stringify(result))
+ return config.steps.map(step => step.id)
+}
+
+export async function verifyLogsSettingsPlan(endpoint, token, connectionId, ownerJwt, journal, fixture) {
+ assert.equal(endpoint.hostname, '127.0.0.1')
+ const owner = async (path, body) => {
+ const response = await fetch(new URL(path, endpoint), {
+ headers: { authorization: 'Bearer ' + ownerJwt, 'content-type': 'application/json' },
+ redirect: 'error',
+ signal: AbortSignal.timeout(5000),
+ ...(body && { method: 'POST', body: JSON.stringify(body) }),
+ })
+ assert.equal(response.status, 200, path)
+ return response.json()
+ }
+ const settingsPath = '/api/logs/settings'
+ const before = await owner(settingsPath)
+ const intervalSec = before.intervalSec === 60 ? 61 : 60
+ return withClient(endpoint, token, async call => {
+ const planStep = 'mm_logs_settings_update_plan'
+ const applyStep = 'mm_change_apply'
+ const config = { journal, fixture, steps: [
+ { id: planStep, kind: 'plan', async run({ accept }) {
+ const plan = await call(planStep, { settings: { intervalSec } })
+ accept(plan.planId)
+ assert.equal(plan.state, 'awaiting-approval')
+ return plan.planId
+ } },
+ { id: 'owner.decision', kind: 'apply', async run({ evidence, accept }) {
+ const planId = evidence.get(planStep)
+ const path = '/api/mcp/plans/' + planId
+ const plan = await owner(path)
+ assert.equal(plan.id, planId)
+ assert.equal(plan.operationId, 'logs.settings.update')
+ assert.equal(plan.connectionId, connectionId)
+ assert.equal(plan.state, 'awaiting-approval')
+ assert.deepEqual(plan.input.settings, { intervalSec })
+ assert.deepEqual(await owner(settingsPath), before)
+ assert.deepEqual(await owner(path + '/decision', { approve: true }), { ok: true })
+ accept(planId)
+ return planId
+ }, async reconcile({ evidence }) {
+ const planId = evidence.get(planStep)
+ const plan = await owner('/api/mcp/plans/' + planId)
+ return plan.state === 'approved' && plan.connectionId === connectionId
+ ? { state: 'verified', evidence: planId } : { state: 'unknown' }
+ } },
+ { id: applyStep, kind: 'apply', async run({ evidence, idempotencyKey, accept }) {
+ const operation = await call(applyStep, { planId: evidence.get(planStep), idempotencyKey })
+ accept(operation.id)
+ return operation.id
+ } },
+ { id: 'mm_operation_get', kind: 'read', async run({ evidence, attempt }) {
+ if (attempt === 1) throw Object.assign(new Error('Simulated interruption before status read'), { code: 'FIXTURE_INTERRUPTED' })
+ const operationId = evidence.get(applyStep)
+ const deadline = Date.now() + 10000
+ let operation
+ do {
+ operation = await call('mm_operation_get', { operationId })
+ assert.equal(operation.id, operationId)
+ assert.equal(operation.plan_id, evidence.get(planStep))
+ assert.equal(operation.connection_id, connectionId)
+ if (!['pending', 'running'].includes(operation.state)) break
+ await new Promise(resolve => setTimeout(resolve, 100))
+ } while (Date.now() < deadline)
+ assert.equal(operation.state, 'applied')
+ assert.equal(operation.verification, 'passed')
+ assert.deepEqual(await owner(settingsPath), { ...before, intervalSec })
+ return operationId
+ } },
+ ] }
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'failed', step: 'mm_operation_get' }, journal)
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'passed' }, journal)
+ return config.steps.map(step => step.id)
+ })
+}
+
+export async function verifyLogsReads(endpoint, serverId, exportToken, settingsToken, ownerJwt, journal, fixture) {
+ assert.equal(endpoint.hostname, '127.0.0.1')
+ const publish = async (call, accept) => {
+ const artifact = await call('mm_logs_export', { serverId, q: 'external-sdk-log-1', format: 'json' })
+ accept(artifact.artifactId)
+ assert.equal(artifact.rows, 1)
+ return artifact.artifactId
+ }
+ const read = async (call, artifactId) => {
+ const first = await call('mm_logs_export_read', { artifactId, limit: 16 })
+ assert(Number.isSafeInteger(first.bytes) && first.bytes > 16 && first.bytes <= 8192)
+ assert.equal(first.offset, 0)
+ assert.equal(first.nextOffset, 16)
+ assert.equal(first.complete, false)
+ const last = await call('mm_logs_export_read', { artifactId, offset: first.nextOffset })
+ assert.equal(last.offset, 16)
+ assert.equal(last.nextOffset, null)
+ assert.equal(last.complete, true)
+ for (const part of [first, last]) {
+ assert.equal(part.artifactId, artifactId)
+ assert.equal(part.sha256, first.sha256)
+ assert.equal(part.bytes, first.bytes)
+ }
+ const content = Buffer.concat([first, last].map(part => Buffer.from(part.dataBase64, 'base64')))
+ assert.equal(content.length, first.bytes)
+ assert.equal(createHash('sha256').update(content).digest('hex'), first.sha256)
+ assert.match(content.toString('utf8'), /external-sdk-log-1/)
+ assert.doesNotMatch(content.toString('utf8'), /external-sdk-log-2/)
+ return artifactId
+ }
+ const config = { journal, fixture, steps: [
+ { id: 'mm_logs_export', kind: 'apply',
+ run: ({ accept }) => withClient(endpoint, exportToken, call => publish(call, accept)),
+ // An unknown publication has no idempotency key. Stop for reconciliation.
+ },
+ { id: 'mm_logs_export_read', kind: 'read',
+ run: ({ evidence }) => withClient(endpoint, exportToken, call => read(call, evidence.get('mm_logs_export'))),
+ },
+ { id: 'mm_logs_settings_get', kind: 'read', async run({ attempt }) {
+ if (attempt === 1) throw Object.assign(new Error('Simulated interruption before settings read'), {
+ code: 'FIXTURE_INTERRUPTED',
+ })
+ await withClient(endpoint, settingsToken, async call => {
+ const response = await fetch(new URL('/api/logs/settings', endpoint), {
+ headers: { authorization: 'Bearer ' + ownerJwt },
+ redirect: 'error',
+ signal: AbortSignal.timeout(5000),
+ })
+ assert.equal(response.status, 200)
+ const expected = await response.json()
+ assert.equal(expected.enabled, false)
+ assert.deepEqual(await call('mm_logs_settings_get'), expected)
+ })
+ return null
+ } },
+ ] }
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'failed', step: 'mm_logs_settings_get' }, journal)
+ assert.deepEqual(await resumeMcpSteps(config), { status: 'passed' }, journal)
+ return config.steps.map(step => step.id)
+}
diff --git a/backend/scripts/mcp-external-process/poll-steps-fixture.mjs b/backend/scripts/mcp-external-process/poll-steps-fixture.mjs
new file mode 100644
index 00000000..30dda747
--- /dev/null
+++ b/backend/scripts/mcp-external-process/poll-steps-fixture.mjs
@@ -0,0 +1,147 @@
+import assert from 'node:assert/strict'
+import { createServer } from 'node:http'
+import { join } from 'node:path'
+import { setTimeout as delay } from 'node:timers/promises'
+import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
+import { resumeServerPoll } from '../acceptance/mcp-server-poll-steps.mjs'
+
+export async function verifyPollSteps(endpoint, pool, jwt, output) {
+ assert.equal(endpoint.hostname, '127.0.0.1')
+ const replies = {
+ '/rest/system/identity': { name: 'Owned synthetic router' },
+ '/rest/system/resource': { version: '7.owned', 'board-name': 'Owned', uptime: '1h', 'cpu-load': '2', 'free-memory': '1024', 'total-memory': '2048' },
+ '/rest/interface': [{ name: 'ether1', type: 'ether' }],
+ '/rest/ip/address': [{ interface: 'ether1', address: '192.0.2.1/24' }],
+ }
+ const native = []
+ const router = createServer((request, response) => {
+ native.push(request.url)
+ if (request.method !== 'GET' || !Object.hasOwn(replies, request.url)) return response.writeHead(403).end()
+ response.setHeader('content-type', 'application/json')
+ response.end(JSON.stringify(replies[request.url]))
+ })
+ let client
+ try {
+ await new Promise((resolve, reject) => router.once('error', reject).listen(0, '127.0.0.1', resolve))
+ const { rows: [server] } = await pool.query(`INSERT INTO servers(name,host,port,use_ssl,verify_ssl,enabled,username,password)
+ VALUES('Owned poll','127.0.0.1',$1,false,false,true,'owned-router','fixture') RETURNING id`, [router.address().port])
+ const serverId = Number(server.id)
+ const { rows: catalogue } = await pool.query('SELECT id FROM servers ORDER BY id')
+ const owner = async (path, body) => {
+ const response = await fetch(new URL(path, endpoint), {
+ headers: { authorization: 'Bearer ' + jwt, 'content-type': 'application/json' },
+ ...(body && { method: 'POST', body: JSON.stringify(body) }),
+ redirect: 'error', signal: AbortSignal.timeout(5000),
+ })
+ assert.equal(response.status, 200, path)
+ return response.json()
+ }
+ const { connection, token } = await owner('/api/mcp/connections', {
+ name: 'Owned poll steps', mode: 'approval', expiresAt: new Date(Date.now() + 180000).toISOString(),
+ permissions: ['mm:servers:read', 'mm:servers:write', 'mm:settings:admin'],
+ scope: { serverIds: catalogue.map(row => Number(row.id)), operationIds: ['servers.poll', 'changes.apply', 'operations.read'], allowGlobal: true },
+ limits: { callsPerMinute: 120, mutationsPerHour: 10000, objectsPerPlan: 10000 },
+ })
+ const connect = async () => {
+ await client?.close()
+ client = new Client({ name: 'owned-poll-steps', version: '1.0.0' })
+ await client.connect(new StreamableHTTPClientTransport(endpoint, {
+ requestInit: { headers: { authorization: 'Bearer ' + token } },
+ }), { timeout: 5000 })
+ }
+ await connect()
+ const journal = join(output, 'poll-' + connection.id + '.jsonl')
+ let planId
+ let approvedExpiresAt
+ let operationId
+ let operation
+ let interruptStatus = true
+ let applyKey
+ const config = {
+ journal, fixture: 'owned-poll', serverId, connectionId: connection.id,
+ async findAcceptedOperation({ connectionId: scope, planId: plan, idempotencyKey }) {
+ assert.equal(operationId, undefined)
+ assert.equal(scope, connection.id)
+ assert.equal(plan, planId)
+ assert.equal(idempotencyKey, applyKey)
+ const { rows } = await pool.query(`SELECT id FROM mcp_operations
+ WHERE connection_id=$1 AND plan_id=$2 AND idempotency_key=$3`, [scope, plan, idempotencyKey])
+ assert.equal(rows.length, 1)
+ operationId = rows[0].id
+ return operationId
+ },
+ async call(name, args) {
+ if (name === 'mm_operation_get' && interruptStatus) {
+ interruptStatus = false
+ assert.equal(args.operationId, operationId)
+ throw Object.assign(new Error('Simulated interruption before reading status'), { code: 'FIXTURE_INTERRUPTED' })
+ }
+ const reply = await client.callTool({ name, arguments: args }, undefined, { timeout: name === 'mm_server_poll_plan' ? 45000 : 5000 })
+ if (reply.isError) {
+ const error = JSON.parse(reply.content.find(item => item.type === 'text').text)
+ const code = /^[A-Z0-9_]{1,64}$/.test(error.code) ? error.code : 'POLL_SDK_ERROR'
+ console.error('Owned SDK tool refused:', name, code)
+ throw Object.assign(new Error(name + ' failed'), { code })
+ }
+ const result = reply.structuredContent.result
+ if (name === 'mm_server_poll_plan') planId = result.planId
+ if (name === 'mm_change_apply') {
+ assert.equal(applyKey, undefined, 'Apply cannot be sent twice')
+ applyKey = args.idempotencyKey
+ // The endpoint accepted the request, but the journal never sees its response.
+ throw Object.assign(new Error('Simulated lost apply response'), { code: 'FIXTURE_LOST_APPLY' })
+ }
+ if (name === 'mm_operation_get') operation = result
+ return result
+ },
+ async assertApproved(id) {
+ const plan = await owner('/api/mcp/plans/' + id)
+ assert.equal(plan.connectionId, connection.id)
+ assert.equal(plan.operationId, 'servers.poll')
+ if (plan.state !== 'approved') throw Object.assign(new Error('Waiting for owner approval'), { code: 'POLL_AWAITING_APPROVAL' })
+ const expiresAt = Date.parse(plan.expiresAt)
+ assert(expiresAt > Date.now(), 'Approved poll must have a live expiry')
+ approvedExpiresAt = expiresAt
+ },
+ }
+ assert.deepEqual(await resumeServerPoll(config), { status: 'failed', step: 'manager.plan-approved' }, journal)
+ assert.ok(planId)
+ assert.deepEqual(await owner('/api/mcp/plans/' + planId + '/decision', { approve: true }), { ok: true })
+ assert.deepEqual(await resumeServerPoll(config), { status: 'failed', step: 'mm_change_apply' }, journal)
+ assert.ok(applyKey)
+ assert.equal(operationId, undefined)
+ await connect()
+ assert.deepEqual(await resumeServerPoll(config), { status: 'failed', step: 'mm_operation_get' }, journal)
+ assert.ok(operationId)
+ await connect()
+ const observationStartedAt = Date.now()
+ let state
+ while (true) {
+ const { rows } = await pool.query('SELECT state FROM mcp_operations WHERE id=$1 AND connection_id=$2', [operationId, connection.id])
+ state = rows[0]?.state
+ const remaining = approvedExpiresAt - Date.now()
+ if (!['pending', 'running'].includes(state) || remaining <= 0) break
+ await delay(Math.min(500, remaining))
+ }
+ const observedMs = Date.now() - observationStartedAt
+ const approvedLifetimeRemainingAtStartMs = approvedExpiresAt - observationStartedAt
+ assert.deepEqual(await resumeServerPoll(config), { status: 'passed' },
+ `${journal} DB state ${state} after ${observedMs} ms (original approval window ${approvedLifetimeRemainingAtStartMs} ms at start)`)
+ assert.equal(operation.id, operationId)
+ const receipt = operation.steps[0].result
+ assert.equal(receipt.snapshot.status, 'online')
+ assert.deepEqual(native.sort(), Object.keys(replies).sort())
+ const { rows } = await pool.query(`SELECT tool,count(*)::int AS count FROM mcp_requests
+ WHERE connection_id=$1 AND tool IN ('mm_server_poll_plan','mm_change_apply','mm_operation_get') GROUP BY tool`, [connection.id])
+ const calls = Object.fromEntries(rows.map(row => [row.tool, row.count]))
+ assert.equal(calls.mm_server_poll_plan, 1)
+ assert.equal(calls.mm_change_apply, 1)
+ assert.equal(calls.mm_operation_get, 1)
+ return { journal, operationId, calls, reconciledLostApply: true, sdkReconnects: 2, nativeReads: native.length, publications: receipt.completedPublications,
+ state: operation.state, verification: operation.verification, localPostgres: true, sdkHttp: true,
+ approvedExpiresAt: new Date(approvedExpiresAt).toISOString(), approvedLifetimeRemainingAtStartMs, observedMs }
+ } finally {
+ await client?.close()
+ if (router.listening) await new Promise((resolve, reject) => router.close(error => error ? reject(error) : resolve()))
+ }
+}
diff --git a/backend/scripts/mcp-external-process/result-envelope-fixture.mjs b/backend/scripts/mcp-external-process/result-envelope-fixture.mjs
new file mode 100644
index 00000000..5241d367
--- /dev/null
+++ b/backend/scripts/mcp-external-process/result-envelope-fixture.mjs
@@ -0,0 +1,138 @@
+import assert from 'node:assert/strict'
+import { randomUUID } from 'node:crypto'
+import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'
+
+const limit = 1024 * 1024
+const budgetMeta = 'io.mikrotikmanager/result-budget'
+const comment = 'Ж'.repeat(11000)
+const payloadBytes = value => Buffer.byteLength(JSON.stringify(value), 'utf8')
+const tools = ['mm_servers_list', 'mm_logs_settings_update_plan', 'mm_change_apply', 'mm_operation_get']
+
+export async function verifyResultEnvelope(endpoint, pool, jwt, bridgeFile) {
+ assert.equal(new URL(endpoint).hostname, '127.0.0.1')
+ const { rows: [{ count: existingServers }] } = await pool.query('SELECT count(*)::int AS count FROM servers')
+ await pool.query(`
+ INSERT INTO servers(name,host,enabled,comment)
+ SELECT 'owned-envelope-'||n, '192.0.2.'||(10+n), false, $1 FROM generate_series(1,24) AS n
+ `, [comment])
+ const { rows: servers } = await pool.query('SELECT id FROM servers ORDER BY id')
+ // Independently observe actual writes, including an accidental repeat with unchanged settings.
+ await pool.query(`
+ CREATE TABLE owned_log_settings_writes (interval_sec integer NOT NULL);
+ CREATE FUNCTION owned_count_log_settings_write() RETURNS trigger LANGUAGE plpgsql AS $$
+ BEGIN
+ INSERT INTO owned_log_settings_writes VALUES (NEW.interval_sec);
+ RETURN NEW;
+ END $$;
+ CREATE TRIGGER owned_count_log_settings_write AFTER UPDATE ON router_log_settings
+ FOR EACH ROW EXECUTE FUNCTION owned_count_log_settings_write()`)
+ const headers = { authorization: 'Bearer ' + jwt, 'content-type': 'application/json' }
+ const json = async (path, body) => {
+ const response = await fetch(new URL(path, endpoint), {
+ headers, signal: AbortSignal.timeout(10000), ...(body ? { method: 'POST', body: JSON.stringify(body) } : {}),
+ })
+ assert.equal(response.status, 200, path)
+ return response.json()
+ }
+ const cases = []
+ for (const mode of ['http', 'stdio']) {
+ const { connection, token } = await json('/api/mcp/connections', {
+ name: 'Owned result envelope ' + mode, mode: 'approval', expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions: ['mm:servers:read', 'mm:settings:admin'],
+ limits: { serversPerPlan: servers.length, mutationsPerHour: servers.length },
+ scope: { serverIds: servers.map(row => Number(row.id)), allowGlobal: true,
+ operationIds: ['servers.list', 'logs.settings.update', 'changes.apply', 'operations.read'] },
+ })
+ const client = new Client({ name: 'owned-result-envelope-' + mode, version: '1.0.0' })
+ const transport = mode === 'http'
+ ? new StreamableHTTPClientTransport(new URL(endpoint), { requestInit: { headers: { authorization: 'Bearer ' + token } } })
+ : new StdioClientTransport({ command: process.execPath, args: ['--import', import.meta.resolve('tsx'), bridgeFile],
+ cwd: process.cwd(), env: { MCP_URL: endpoint, MCP_TOKEN: token }, maxBufferSize: limit + 65536, stderr: 'pipe' })
+ transport.stderr?.on('data', () => {})
+ try {
+ await client.connect(transport, { timeout: 10000 })
+ const observedTools = (await client.listTools({}, { timeout: 5000 })).tools.map(tool => tool.name)
+ assert.deepEqual(observedTools.sort(), [...tools].sort())
+ const call = async (name, args) => {
+ const result = await client.callTool({ name, arguments: args }, undefined, { timeout: 10000 })
+ assert(payloadBytes(result) <= limit, mode + ' ' + name)
+ return result
+ }
+ const output = result => {
+ if (result.isError) assert.fail(JSON.parse(result.content[0].text).code)
+ const text = JSON.parse(result.content[0].text)
+ assert.deepEqual(result.structuredContent.result, text)
+ return text
+ }
+ const accepted = await call('mm_servers_list', { limit: 23, offset: existingServers })
+ const page = output(accepted)
+ assert.equal(page.items.length, 23)
+ assert(page.items.every(item => item.comment === comment))
+ assert(payloadBytes(accepted) >= 1000000)
+ // Even without field names and framing this page's duplicated UTF-8 text exceeds 1 MiB.
+ assert(24 * Buffer.byteLength(comment, 'utf8') * 2 > limit)
+ const refused = await call('mm_servers_list', { limit: 24, offset: existingServers })
+ assert.equal(refused.isError, true)
+ assert.equal(refused.structuredContent, undefined)
+ assert.equal(JSON.parse(refused.content[0].text).code, 'RESULT_TOO_LARGE')
+ assert.deepEqual(refused._meta[budgetMeta], {
+ version: 1, detailsOmitted: true, reason: 'byte-budget', automaticReplay: false,
+ })
+
+ const before = await json('/api/logs/settings')
+ const intervalSec = before.intervalSec === 60 ? 61 : 60
+ const plan = output(await call('mm_logs_settings_update_plan', { settings: { intervalSec } }))
+ assert.equal(plan.state, 'awaiting-approval')
+ await json('/api/mcp/plans/' + plan.planId + '/decision', { approve: true })
+ const applyArgs = { planId: plan.planId, idempotencyKey: randomUUID() }
+ const operation = output(await call('mm_change_apply', applyArgs))
+ let terminal
+ for (const end = Date.now() + 10000; Date.now() < end;) {
+ terminal = output(await call('mm_operation_get', { operationId: operation.id }))
+ if (!['pending', 'running'].includes(terminal.state)) break
+ await new Promise(resolve => setTimeout(resolve, 100))
+ }
+ assert.equal(terminal.state, 'applied')
+ assert.equal(terminal.verification, 'passed')
+ const writes = async () => (await pool.query('SELECT count(*)::int AS n FROM owned_log_settings_writes')).rows[0].n
+ const checkEffect = async () => {
+ assert.equal(await writes(), cases.length + 1)
+ assert.deepEqual(await json('/api/logs/settings'), { ...before, intervalSec })
+ }
+ await checkEffect()
+
+ // Supply namespaced synthetic optional details to the actual, already applied operation.
+ // The ordinary runtime read and duplicate-apply paths must keep its original outcome.
+ const oversizedDetails = JSON.stringify(Array(24).fill(comment))
+ const staged = await pool.query(`
+ UPDATE mcp_operations SET result=jsonb_set(COALESCE(result, '{}'::jsonb), '{ownedEnvelopeDetails}', $2::jsonb)
+ WHERE id=$1 AND state='applied' RETURNING id`, [operation.id, oversizedDetails])
+ assert.equal(staged.rowCount, 1)
+ const compactRead = await call('mm_operation_get', { operationId: operation.id })
+ const compactApply = await call('mm_change_apply', applyArgs)
+ for (const compact of [compactRead, compactApply]) {
+ assert(payloadBytes(compact) < 2048)
+ assert.deepEqual(compact._meta[budgetMeta], refused._meta[budgetMeta])
+ assert.deepEqual(output(compact), {
+ id: operation.id, plan_id: plan.planId, state: 'applied', verification: 'passed', error_code: null,
+ })
+ }
+ await checkEffect()
+ const { rows: [counts] } = await pool.query(`
+ SELECT
+ (SELECT count(*)::int FROM mcp_operations WHERE connection_id=$1) AS operations,
+ (SELECT count(*)::int FROM mcp_operation_steps WHERE operation_id=$2 AND state='verified') AS verified_steps,
+ (SELECT count(*)::int FROM mcp_requests WHERE connection_id=$1 AND tool='mm_change_apply') AS apply_requests
+ `, [connection.id, operation.id])
+ assert.deepEqual(counts, { operations: 1, verified_steps: 1, apply_requests: 2 })
+ cases.push({ mode, nearLimitBytes: payloadBytes(accepted), refusalBytes: payloadBytes(refused),
+ compactReadBytes: payloadBytes(compactRead), compactApplyBytes: payloadBytes(compactApply),
+ ...counts, settingsWrites: 1 })
+ } finally {
+ await client.close()
+ }
+ }
+ return { scope: 'complete CallToolResult from HTTP SDK and production stdio bridge on owned PostgreSQL',
+ limitBytes: limit, wholeGenericResultEnvelopeLimitAccepted: true, cases }
+}
diff --git a/backend/scripts/mcp-external-process/run-owned.mjs b/backend/scripts/mcp-external-process/run-owned.mjs
new file mode 100644
index 00000000..b4d11f08
--- /dev/null
+++ b/backend/scripts/mcp-external-process/run-owned.mjs
@@ -0,0 +1,60 @@
+import EmbeddedPostgres from 'embedded-postgres'
+import { mkdtemp, rm, mkdir, readFile, writeFile } from 'node:fs/promises'
+import { join, resolve, relative, isAbsolute } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { randomBytes, createHash } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn } from 'node:child_process'
+const sourceRoot = resolve(process.argv[2] ?? fileURLToPath(new URL('../../../', import.meta.url)))
+const scenario = process.argv[3] ?? 'acceptance'
+if (!['acceptance', 'bridge-vlan', 'logs-read', 'logs-history', 'logs-settings', 'poll-steps', 'result-envelope'].includes(scenario)) throw Error('Unsupported owned external scenario')
+const logsScenario = scenario.startsWith('logs-')
+const envelopeScenario = scenario === 'result-envelope'
+const reportRoot = resolve(sourceRoot, scenario === 'bridge-vlan' ? 'tmp/mcp-bridge-vlan-sdk-20261105' :
+ logsScenario || scenario === 'poll-steps' || envelopeScenario ? 'tmp/mcp-external-' + scenario : 'tmp/mcp-external-process-acceptance')
+await mkdir(reportRoot, { recursive: true })
+const output = scenario === 'poll-steps' || envelopeScenario ? await mkdtemp(join(reportRoot, 'run-')) : reportRoot
+const paths = ['backend/src/scripts/mcp-stdio.ts', 'backend/src/routes/mcp-transport.ts', 'backend/src/routes/mcp-oauth.ts', 'backend/src/modules/mcp/store.ts',
+ 'backend/src/modules/mcp/runtime.ts', 'backend/src/modules/mcp/actions.ts', 'backend/src/modules/mcp/security.ts', 'backend/src/modules/mcp/protocol-limits.ts',
+ 'backend/src/modules/mcp/portal-revocation.ts', 'backend/src/plugins/auth.ts', 'backend/src/index.ts', 'node_modules/@modelcontextprotocol/client/package.json', 'node_modules/@modelcontextprotocol/server/package.json']
+if (scenario !== 'bridge-vlan') paths.push('backend/scripts/mcp-external-process/client.mjs', 'backend/scripts/mcp-external-process/server-fixture.ts',
+ 'backend/src/routes/mcp-portal.ts', 'backend/src/modules/mcp/portal-revocation-event.ts', 'backend/src/services/router-logs-query.ts')
+else paths.push('backend/scripts/mcp-external-process/bridge-vlan-client.mjs', 'backend/scripts/mcp-external-process/bridge-vlan-fixture.ts',
+ 'backend/src/modules/mcp/bridge-vlan-actions.ts', 'backend/src/services/bridge-vlan-configuration.ts', 'packages/contracts/src/bridge-vlan.ts')
+if (logsScenario) paths.push('backend/scripts/mcp-external-process/logs-read-client.mjs',
+ 'backend/scripts/acceptance/mcp-step-journal.mjs', 'backend/src/modules/mcp/log-artifacts.ts')
+if (scenario === 'poll-steps') paths.push('backend/scripts/mcp-external-process/poll-steps-fixture.mjs',
+ 'backend/scripts/acceptance/mcp-step-journal.mjs', 'backend/scripts/acceptance/mcp-server-poll-steps.mjs',
+ 'backend/src/modules/mcp/server-poll-production.ts', 'backend/src/services/server-poll-execution.ts')
+if (envelopeScenario) paths.push('backend/scripts/mcp-external-process/run-owned.mjs', 'backend/scripts/mcp-external-process/result-envelope-fixture.mjs',
+ 'backend/src/modules/mcp/result-budget.ts', 'backend/src/modules/mcp/result-delivery.ts', 'backend/src/modules/mcp/flow-envelope-allowance.ts',
+ 'backend/src/modules/mcp/sdk-terminal-budget.ts', 'backend/src/modules/mcp/stdio-terminal-budget.ts')
+async function pins() { const result = []; for (const path of paths) result.push({ path, sha256: createHash('sha256').update(await readFile(resolve(sourceRoot, path))).digest('hex') }); return result }
+const before = await pins(), directory = await mkdtemp(join(resolve(sourceRoot, 'tmp'), 'mm-mcp-external-')), state = join(directory, 'state'); await mkdir(state)
+const listener = createServer(); await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve)); const port = listener.address().port; await new Promise(resolve => listener.close(resolve))
+const password = randomBytes(24).toString('hex')
+const postgres = new EmbeddedPostgres({ databaseDir: join(directory, 'pg'), port, user: 'mcp_test', password, persistent: true, createPostgresUser: false,
+ initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', '127.0.0.1'], onLog: () => {}, onError: () => {} })
+try {
+ await postgres.initialise(); await postgres.start()
+ process.exitCode = await new Promise((done, reject) => {
+ const child = spawn(process.execPath, ['--import', import.meta.resolve('tsx'), fileURLToPath(new URL(scenario === 'bridge-vlan' ? './bridge-vlan-fixture.ts' : './server-fixture.ts', import.meta.url))], { cwd: directory,
+ windowsHide: true, stdio: 'inherit', env: { ...Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'PATH', 'Path'].filter(k => process.env[k]).map(k => [k, process.env[k]])),
+ OWN_EXTERNAL_CLEANUP_FAULT: process.env.OWN_EXTERNAL_CLEANUP_FAULT, OWN_EXTERNAL_LOGS_SCENARIO: logsScenario ? scenario : '',
+ OWN_EXTERNAL_POLL_STEPS: scenario === 'poll-steps' ? 'true' : '',
+ OWN_EXTERNAL_RESULT_ENVELOPE: envelopeScenario ? 'true' : '',
+ OWN_EXTERNAL_SOURCE_ROOT: sourceRoot, OWN_EXTERNAL_RESULT_FILE: join(output, 'result.json'), NODE_ENV: 'test', OWN_EXTERNAL_PROCESS_PG: 'true', DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`, DATABASE_PATH: join(directory, 'no-legacy.sqlite'),
+ MCP_STATE_DIR: state, AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: 'owned-external-synthetic-issuer-test-only', AUTH_ISSUER: 'https://synthetic-portal.invalid', AUTH_PORTAL_URL: 'https://synthetic-portal.invalid' } })
+ child.once('error', reject); child.once('exit', code => done(code ?? 1))
+ })
+ const after = await pins(), unchanged = JSON.stringify(before) === JSON.stringify(after)
+ await writeFile(join(output, 'source-pins.json'), JSON.stringify({ before, after, unchanged, exitCode: process.exitCode }, null, 2))
+ if (scenario === 'poll-steps') console.log('Poll checkpoint evidence:', output)
+ if (envelopeScenario) console.log('Result envelope evidence:', output)
+ console.log('External-client source/SDK pins unchanged:', unchanged); if (!unchanged) process.exitCode = 1
+} finally {
+ await postgres.stop(); const target = resolve(directory), rel = relative(resolve(resolve(sourceRoot, 'tmp')), target)
+ if (!rel || rel.startsWith('..') || isAbsolute(rel) || !target.includes('mm-mcp-external-')) throw Error('Unsafe exact owned cleanup')
+ await rm(target, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 }); console.log('Owned external-client PostgreSQL stopped and exact temp directory removed')
+}
+process.exit(process.exitCode ?? 0)
diff --git a/backend/scripts/mcp-external-process/server-fixture.ts b/backend/scripts/mcp-external-process/server-fixture.ts
new file mode 100644
index 00000000..a8c4cf29
--- /dev/null
+++ b/backend/scripts/mcp-external-process/server-fixture.ts
@@ -0,0 +1,424 @@
+import assert from "node:assert/strict"
+import { createHash, createHmac, randomUUID } from "node:crypto"
+import { spawn } from "node:child_process"
+import { createServer } from "node:net"
+import { fileURLToPath, pathToFileURL } from "node:url"
+import { dirname, resolve, isAbsolute } from "node:path"
+import { SignJWT } from "jose"
+import { writeFile } from "node:fs/promises"
+assert.equal(process.env.OWN_EXTERNAL_PROCESS_PG, "true"); assert.equal(process.env.NODE_ENV, "test")
+assert(process.env.OWN_EXTERNAL_SOURCE_ROOT && isAbsolute(process.env.OWN_EXTERNAL_SOURCE_ROOT))
+assert(process.env.OWN_EXTERNAL_RESULT_FILE && isAbsolute(process.env.OWN_EXTERNAL_RESULT_FILE))
+const source = (path: string) => pathToFileURL(resolve(process.env.OWN_EXTERNAL_SOURCE_ROOT!, "backend/src", path)).href
+const database = new URL(process.env.DATABASE_URL ?? "")
+assert.equal(database.hostname, "127.0.0.1"); assert.equal(database.username, "mcp_test"); assert.equal(database.pathname, "/postgres"); assert.notEqual(database.port, "5432")
+const listener = createServer(); await new Promise(r => listener.listen(0, "127.0.0.1", r)); const port = (listener.address() as { port: number }).port
+await new Promise(r => listener.close(() => r()))
+const origin = `http://127.0.0.1:${port}`, endpoint = origin + "/mcp"
+process.env.MCP_PUBLIC_URL = endpoint; process.env.MCP_UI_URL = origin; process.env.CORS_ORIGIN = origin
+const { pool, closePool } = await import(source("db/index.js"))
+const { applySqlMigrations } = await import(source("db/migrate.js"))
+const { mcpConnectionCreateSchema } = await import("@mmapp/contracts/mcp")
+const { createMcpConnection, rotateConnectionToken, setConnectionStatus, updateMcpSettings } = await import(source("modules/mcp/store.js"))
+const { listActions } = await import(source("modules/mcp/actions.js")) as typeof import("../../src/modules/mcp/actions.js")
+const { env } = await import(source("config.js"))
+const { buildApp } = await import(source("index.js"))
+const { stopSchedulerForDatabaseOperation } = await import(source("services/scheduler.js"))
+const actor = { id: "owned-external-process-owner", email: "external@example.invalid", name: "Owned external SDK fixture", apps: ["mm"],
+ permissions: ["mm:settings:admin", "mm:mcp:admin", "mm:servers:admin"], expiresAt: Date.now() + 3600000, issuedAt: Date.now() - 1000 }
+let currentId: string | undefined, app: Awaited> | undefined, child: ReturnType | undefined
+const credentials: string[] = []
+const bridgePids = new Set()
+let childExit: Promise | undefined
+let releaseLogRead: (() => void) | undefined
+let logReadCompleted: Promise | undefined
+let revocationOwnerId: string | undefined
+const revokedLogRequests: { connectionId: string; tool: string }[] = []
+const originalConnect = pool.connect
+const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
+async function deliverPortalRevocation(ownerId: string) {
+ const secret = randomUUID() + randomUUID()
+ process.env.MCP_PORTAL_WEBHOOK_SECRET = secret
+ const occurredAt = Date.now(), timestamp = String(Math.floor(occurredAt / 1000))
+ const eventId = randomUUID(), body = JSON.stringify({ version: 2, eventId, userId: ownerId, type: "permissions.changed", eventOccurredAt: occurredAt })
+ const signature = "sha256=" + createHmac("sha256", secret).update(timestamp + "." + body).digest("hex")
+ const response = await fetch(origin + "/_internal/mcp/portal/revocations", {
+ method: "POST", headers: { "content-type": "application/json", "x-mm-timestamp": timestamp, "x-mm-signature": signature },
+ body, signal: AbortSignal.timeout(5000),
+ })
+ assert.equal(response.status, 200)
+ assert.deepEqual(await response.json(), { ok: true, duplicate: false })
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_portal_events WHERE id=$1", [eventId])).rows[0].count, 1)
+ return occurredAt
+}
+function alive(pid: number) { try { process.kill(pid, 0); return true } catch (error) { if ((error as NodeJS.ErrnoException).code === "ESRCH") return false; throw error } }
+async function drainChildAndBridges() {
+ if (child && child.exitCode === null && child.signalCode === null) { child.kill(); await Promise.race([childExit, delay(5000).then(() => { throw Error("Owned external child failed to exit") })]) }
+ const deadline = Date.now() + 5000
+ while ([...bridgePids].some(alive) && Date.now() < deadline) await delay(25)
+ const remaining = [...bridgePids].filter(alive)
+ for (const pid of remaining) process.kill(pid)
+ const killDeadline = Date.now() + 5000
+ while (remaining.some(alive) && Date.now() < killDeadline) await delay(25)
+ assert(!remaining.some(alive), "Owned SDK bridge grandchild failed to exit")
+ console.log("Owned client and all observed production bridge processes exited:", JSON.stringify({ childPid: child?.pid, exitCode: child?.exitCode, signalCode: child?.signalCode, bridgePids: [...bridgePids] }))
+}
+try {
+ await applySqlMigrations(pool)
+ for (const table of ["traffic_settings", "uptime_settings", "traffic_flow_settings", "servers_api_ping_settings", "certificate_renew_settings", "backup_schedule_settings", "geoip_settings", "internet_path_settings", "router_log_settings"]) await pool.query(`UPDATE ${table} SET enabled=false WHERE id=1`)
+ const secret = "OWNED_DEVICE_CREDENTIAL_MUST_NOT_ESCAPE"
+ const allowed = (await pool.query("INSERT INTO servers(name,host,enabled,password) VALUES('owned allowed','192.0.2.1',false,$1) RETURNING id", [secret])).rows[0].id
+ const forbidden = (await pool.query("INSERT INTO servers(name,host,enabled) VALUES('owned forbidden','192.0.2.2',false) RETURNING id")).rows[0].id
+ await pool.query(`INSERT INTO router_log_entries(server_id,server_name,host,router_id,raw_time,received_at,effective_at,topics,level,message,generation)
+ SELECT id,name,host,'fixture','00:00:01',now(),now()-n*interval '1 second',ARRAY['system'],'info','external-sdk-log-'||n,0
+ FROM servers CROSS JOIN generate_series(1,2) AS n WHERE id=ANY($1::int[])`, [[allowed, forbidden]])
+ await updateMcpSettings({ enabled: true }, actor)
+ app = await buildApp({ startScheduler: false, logger: false }); await app.listen({ port, host: "127.0.0.1" })
+ // Settings changes call refreshScheduler even when startup skipped it.
+ await stopSchedulerForDatabaseOperation()
+ const jwt = await new SignJWT({ sub: actor.id, apps: actor.apps, permissions: actor.permissions }).setProtectedHeader({ alg: "HS256" }).setIssuer(env.authIssuer).setIssuedAt().setExpirationTime("1h").sign(new TextEncoder().encode(env.jwtSecret))
+ if (process.env.OWN_EXTERNAL_RESULT_ENVELOPE === "true") {
+ const { verifyResultEnvelope } = await import("./result-envelope-fixture.mjs")
+ const report = await verifyResultEnvelope(endpoint, pool, jwt, fileURLToPath(new URL("../../src/scripts/mcp-stdio.ts", import.meta.url)))
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(report, null, 2))
+ console.log(JSON.stringify(report))
+ } else if (process.env.OWN_EXTERNAL_POLL_STEPS === "true") {
+ const { ensurePartitionFor } = await import(source("db/partitions.js"))
+ const { verifyPollSteps } = await import("./poll-steps-fixture.mjs")
+ await ensurePartitionFor(pool, "server_snapshots", "week", new Date())
+ const report = await verifyPollSteps(new URL(endpoint), pool, jwt, dirname(process.env.OWN_EXTERNAL_RESULT_FILE!))
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(report, null, 2))
+ console.log(JSON.stringify(report))
+ } else if (process.env.OWN_EXTERNAL_LOGS_SCENARIO === "logs-settings") {
+ const access = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned logs settings approval", mode: "approval", expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions: ["mm:settings:admin"], scope: { serverIds: [Number(allowed), Number(forbidden)],
+ operationIds: ["logs.settings.update", "changes.apply", "operations.read"], allowGlobal: true },
+ }), actor)
+ const fixture = `settings-${access.connection.id}`
+ const journal = resolve(dirname(process.env.OWN_EXTERNAL_RESULT_FILE!), fixture + ".jsonl")
+ const { verifyLogsSettingsPlan } = await import("./logs-read-client.mjs")
+ const cases = await verifyLogsSettingsPlan(new URL(endpoint), access.token, access.connection.id, jwt, journal, fixture)
+ const { rows } = await pool.query(`SELECT tool,count(*)::int AS count FROM mcp_requests
+ WHERE connection_id=$1 AND tool NOT LIKE 'protocol:%' GROUP BY tool ORDER BY tool`, [access.connection.id])
+ const calls = Object.fromEntries(rows.map(row => [row.tool, row.count]))
+ assert.deepEqual(Object.keys(calls).sort(), ["mm_change_apply", "mm_logs_settings_update_plan", "mm_operation_get"])
+ assert.equal(calls.mm_change_apply, 1)
+ assert.equal(calls.mm_logs_settings_update_plan, 1)
+ assert(calls.mm_operation_get >= 1)
+ const report = { cases, journal, calls, localPostgres: true, sdkHttp: true }
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(report, null, 2))
+ console.log(JSON.stringify(report))
+ } else if (process.env.OWN_EXTERNAL_LOGS_SCENARIO === "logs-history") {
+ // Follow checks that the server is enabled; collection is disabled and the
+ // synthetic server resolves to loopback even if that changes.
+ await pool.query("UPDATE servers SET enabled=true,host='127.0.0.1' WHERE id=$1", [allowed])
+ await pool.query(`UPDATE router_log_entries
+ SET effective_at=date_trunc('second',now())-interval '1 second'
+ + CASE WHEN message='external-sdk-log-1' THEN interval '200 microseconds' ELSE interval '100 microseconds' END
+ WHERE server_id=$1`, [allowed])
+ const history = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned logs history reader", mode: "observer", expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions: ["mm:servers:read"], scope: { serverIds: [Number(allowed)],
+ operationIds: ["logs.query", "logs.summary", "logs.get", "logs.context", "logs.follow"], allowGlobal: false },
+ }), actor)
+ const { rows } = await pool.query("SELECT id::text,message FROM router_log_entries WHERE server_id=$1 ORDER BY effective_at DESC", [allowed])
+ assert.equal(rows.length, 2)
+ const fixture = `history-${history.connection.id}`
+ const journal = resolve(dirname(process.env.OWN_EXTERNAL_RESULT_FILE!), fixture + ".jsonl")
+ const { verifyLogsHistory } = await import("./logs-read-client.mjs")
+ const appendEvent = async () => (await pool.query(`INSERT INTO router_log_entries
+ (server_id,server_name,host,router_id,raw_time,received_at,effective_at,topics,level,message,generation)
+ SELECT id,name,host,'fixture','00:00:02',now(),now(),ARRAY['system'],'info','external-sdk-log-live',0
+ FROM servers WHERE id=$1 RETURNING id::text`, [allowed])).rows[0].id
+ const cases = await verifyLogsHistory(new URL(endpoint), history.token, Number(allowed), rows, journal, fixture, appendEvent)
+ const report = { cases, journal, localPostgres: true, sdkHttp: true }
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(report, null, 2))
+ console.log(JSON.stringify(report))
+ } else if (process.env.OWN_EXTERNAL_LOGS_SCENARIO === "logs-read") {
+ const expiresAt = new Date(Date.now() + 600000).toISOString()
+ const exporter = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned logs export reader", mode: "observer", expiresAt, permissions: ["mm:servers:read"],
+ scope: { serverIds: [Number(allowed)], operationIds: ["logs.export", "logs.export.read"], allowGlobal: false },
+ }), actor)
+ const settings = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned logs settings reader", mode: "observer", expiresAt, permissions: ["mm:settings:admin"],
+ scope: { serverIds: [], operationIds: ["logs.settings.read"], allowGlobal: true },
+ }), actor)
+ const { verifyLogsReads } = await import("./logs-read-client.mjs")
+ const fixture = `logs-${exporter.connection.id}`
+ const journal = resolve(dirname(process.env.OWN_EXTERNAL_RESULT_FILE!), fixture + ".jsonl")
+ const cases = await verifyLogsReads(new URL(endpoint), Number(allowed), exporter.token, settings.token, jwt, journal, fixture)
+ const { rows } = await pool.query(`SELECT tool, count(*)::int AS count FROM mcp_requests
+ WHERE connection_id=ANY($1::uuid[]) AND tool NOT LIKE 'protocol:%'
+ GROUP BY tool ORDER BY tool`, [[exporter.connection.id, settings.connection.id]])
+ assert.deepEqual(rows, [
+ { tool: "mm_logs_export", count: 1 },
+ { tool: "mm_logs_export_read", count: 2 },
+ { tool: "mm_logs_settings_get", count: 1 },
+ ])
+ const report = { cases, journal, toolCalls: rows, localPostgres: true, sdkHttp: true, nativeRouterCalls: 0 }
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(report, null, 2))
+ console.log(JSON.stringify(report))
+ } else {
+ const artifactOwner = { ...actor, id: actor.id + "-artifact" }
+ const signArtifactOwner = () => new SignJWT({ sub: artifactOwner.id, apps: artifactOwner.apps, permissions: artifactOwner.permissions })
+ .setProtectedHeader({ alg: "HS256" }).setIssuer(env.authIssuer).setIssuedAt().setExpirationTime("1h").sign(new TextEncoder().encode(env.jwtSecret))
+ let artifactConnectionId: string | undefined
+ const planOwner = { ...actor, id: actor.id + "-approved-plan", permissions: [...actor.permissions, "mm:mcp:approve"] }
+ let planConnectionId: string | undefined
+ const portalHeaders = { authorization: `Bearer ${jwt}`, "content-type": "application/json" }
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_connections WHERE owner_id=$1", [actor.id])).rows[0].count, 0)
+ const callback = "http://localhost:45678/callback?registered=1"
+ const registration = await fetch(origin + "/api/mcp/oauth/clients", { method: "POST", headers: portalHeaders,
+ body: JSON.stringify({ name: "Owned denial fixture", redirectUris: [callback] }) })
+ assert.equal(registration.status, 200)
+ const { clientId } = await registration.json() as { clientId: string }
+ const consent = (payload: Record, headers = portalHeaders) => fetch(origin + "/api/mcp/oauth/consent", { method: "POST", headers, body: JSON.stringify(payload) })
+ const authorize = async (state: string) => {
+ const parameters = new URLSearchParams({ client_id: clientId, redirect_uri: callback, response_type: "code", resource: endpoint,
+ code_challenge_method: "S256", code_challenge: createHash("sha256").update("v".repeat(64)).digest("base64url"), state })
+ const response = await fetch(`${origin}/oauth/authorize?${parameters}`, { redirect: "manual" })
+ assert.equal(response.status, 302)
+ const requestId = new URL(response.headers.get("location")!).searchParams.get("oauthRequest")
+ assert.ok(requestId)
+ return requestId
+ }
+ const requestId = await authorize("deny-without-connection")
+ assert.equal((await consent({ requestId, approve: false }, { ...portalHeaders, authorization: "" })).status, 401)
+ assert.equal((await consent({ requestId, approve: true })).status, 400)
+ const refusals = await Promise.all([consent({ requestId, approve: false }), consent({ requestId, approve: false })])
+ assert.deepEqual(refusals.map(response => response.status).sort(), [200, 404])
+ const { redirectUrl } = await refusals.find(response => response.status === 200)!.json() as { redirectUrl: string }
+ const redirect = new URL(redirectUrl)
+ const expected = new URL(callback)
+ expected.searchParams.set("state", "deny-without-connection")
+ expected.searchParams.set("iss", origin)
+ expected.searchParams.set("error", "access_denied")
+ assert.equal(redirect.href, expected.href)
+ const otherOwner = { ...actor, id: "owned-external-process-other-owner" }
+ const unrelated = await createMcpConnection(mcpConnectionCreateSchema.parse({ name: "Unrelated paused connection", mode: "observer",
+ expiresAt: new Date(Date.now() + 600000).toISOString(), permissions: ["mm:servers:read"],
+ scope: { serverIds: [Number(allowed)], operationIds: ["servers.list"], allowGlobal: false } }), otherOwner)
+ await setConnectionStatus(unrelated.connection.id, "paused", otherOwner)
+ const legacyRequestId = await authorize("legacy-denial")
+ const legacy = await consent({ requestId: legacyRequestId, connectionId: unrelated.connection.id, approve: false })
+ assert.equal(legacy.status, 200)
+ assert.equal((await consent({ requestId: legacyRequestId, connectionId: unrelated.connection.id, approve: false })).status, 404)
+ const expired = await createMcpConnection(mcpConnectionCreateSchema.parse({ name: "Expired connection", mode: "observer",
+ expiresAt: new Date(Date.now() + 600000).toISOString(), permissions: ["mm:servers:read"],
+ scope: { serverIds: [Number(allowed)], operationIds: ["servers.list"], allowGlobal: false } }), actor)
+ await pool.query("UPDATE mcp_connections SET policy=jsonb_set(policy,'{expiresAt}',to_jsonb($2::text)) WHERE id=$1", [expired.connection.id, "2000-01-01T00:00:00Z"])
+ const expiredRequestId = await authorize("expired-approval")
+ assert.equal((await consent({ requestId: expiredRequestId, connectionId: expired.connection.id, approve: true })).status, 403)
+ const expiredRequest = (await pool.query("SELECT consumed_at,code_digest,connection_id FROM mcp_oauth_requests WHERE id=$1", [expiredRequestId])).rows[0]
+ assert.deepEqual(expiredRequest, { consumed_at: null, code_digest: null, connection_id: null })
+ assert.equal((await consent({ requestId: expiredRequestId, approve: false })).status, 200)
+ const deniedRows = (await pool.query("SELECT consumed_at,code_digest,connection_id FROM mcp_oauth_requests WHERE client_id=$1", [clientId])).rows
+ assert.equal(deniedRows.length, 3)
+ assert(deniedRows.every(row => row.consumed_at instanceof Date && row.code_digest === null && row.connection_id === null))
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_credentials WHERE client_id=$1", [clientId])).rows[0].count, 0)
+ const denialAudit = (await pool.query("SELECT actor_id,connection_id,payload FROM mcp_audit WHERE action='oauth.consent' AND payload->>'clientId'=$1", [clientId])).rows
+ assert.equal(denialAudit.length, 3)
+ assert(denialAudit.every(row => row.actor_id === actor.id && row.connection_id === null && row.payload.approved === false))
+ console.log("OAuth consent: expired approval refused before code issuance, denial uses exact redirect and one-use request without credentials")
+ const transcript: unknown[] = []; let failure: unknown, result: unknown
+ child = spawn(process.execPath, [fileURLToPath(new URL("./client.mjs", import.meta.url))], { cwd: process.cwd(), windowsHide: true, stdio: ["ignore", "pipe", "pipe", "ipc"],
+ env: { ...Object.fromEntries(["SystemRoot", "WINDIR", "TEMP", "TMP", "PATH", "Path"].filter(k => process.env[k]).map(k => [k, process.env[k]!])),
+ OWN_EXTERNAL_CLIENT: "true", OWN_MCP_ENDPOINT: endpoint, OWN_SERVER_PID: String(process.pid), OWN_ALLOWED_SERVER: String(allowed), OWN_FORBIDDEN_SERVER: String(forbidden),
+ OWN_BRIDGE_FILE: fileURLToPath(new URL(source("scripts/mcp-stdio.ts"))), OWN_PORTAL_JWT: jwt, OWN_SERVER_SECRET: secret, OWN_EXTERNAL_CLEANUP_FAULT: process.env.OWN_EXTERNAL_CLEANUP_FAULT } })
+ childExit = new Promise(resolve => { child!.once("exit", status => resolve(status ?? 1)); child!.once("error", () => resolve(1)) })
+ let stderr = "", stdout = ""
+ child.stderr?.on("data", chunk => { stderr += String(chunk); if (stderr.length > 1048576) child?.kill() })
+ child.stdout?.on("data", chunk => { stdout += String(chunk); if (stdout.length > 1048576) child?.kill() })
+ child.on("message", async (raw: unknown) => {
+ const message = raw as { kind: string; command?: string; id?: number; pid?: number; result?: unknown; phase?: string; errorType?: string }
+ if (message.kind === "bridge-pid") { assert(Number.isSafeInteger(message.pid) && message.pid! > 0 && message.pid !== process.pid && message.pid !== child?.pid); bridgePids.add(message.pid!); return }
+ if (message.kind === "arm-cleanup-timeout" && process.env.OWN_EXTERNAL_CLEANUP_FAULT === "timeout") { setTimeout(() => { failure = { phase: "owned-deliberate-cleanup-timeout" }; child?.kill() }, 25); return }
+ if (message.kind === "result") { result = message.result; return }
+ if (message.kind === "failure") { failure = { phase: message.phase, errorType: message.errorType }; return }
+ if (message.kind !== "control" || !Number.isSafeInteger(message.id)) return
+ try {
+ let value: unknown
+ if (message.command === "new-revocable-plan-connection") {
+ assert(!planConnectionId)
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned approved plan revocation", mode: "approval", permissions: ["mm:settings:admin"],
+ expiresAt: new Date(Date.now() + 600000).toISOString(),
+ scope: { serverIds: [Number(allowed), Number(forbidden)], operationIds: ["logs.settings.update", "changes.apply"], allowGlobal: true },
+ }), planOwner)
+ currentId = planConnectionId = issued.connection.id
+ const ownerJwt = await new SignJWT({ sub: planOwner.id, apps: planOwner.apps, permissions: planOwner.permissions })
+ .setProtectedHeader({ alg: "HS256" }).setIssuer(env.authIssuer).setIssuedAt().setExpirationTime("1h").sign(new TextEncoder().encode(env.jwtSecret))
+ credentials.push(issued.token, ownerJwt)
+ value = { token: issued.token, ownerJwt }
+ } else if (message.command === "revoke-approved-plan-owner") {
+ assert(planConnectionId && currentId === planConnectionId)
+ const plans = (await pool.query("SELECT id,state,approved_by FROM mcp_plans WHERE connection_id=$1", [planConnectionId])).rows
+ assert.equal(plans.length, 1)
+ assert.equal(plans[0].state, "approved")
+ assert.equal(plans[0].approved_by, planOwner.id)
+ await deliverPortalRevocation(planOwner.id)
+ value = { ok: true }
+ } else if (message.command === "new-artifact-connection") {
+ assert(!artifactConnectionId)
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned export revocation", mode: "observer", permissions: ["mm:servers:read"],
+ expiresAt: new Date(Date.now() + 600000).toISOString(),
+ scope: { serverIds: [Number(allowed)], operationIds: ["logs.export"], allowGlobal: false },
+ }), artifactOwner)
+ currentId = artifactConnectionId = issued.connection.id
+ const ownerJwt = await signArtifactOwner()
+ credentials.push(issued.token, ownerJwt)
+ value = { token: issued.token, ownerJwt }
+ } else if (message.command === "revoke-artifact-owner") {
+ assert(artifactConnectionId && currentId === artifactConnectionId)
+ const occurredAt = await deliverPortalRevocation(artifactOwner.id)
+ while (Math.floor(Date.now() / 1000) <= Math.floor(occurredAt / 1000)) await delay(25)
+ const ownerJwt = await signArtifactOwner()
+ credentials.push(ownerJwt)
+ value = { ownerJwt }
+ } else if (["arm-log-revocation", "arm-log-revocation-after-commit", "arm-log-follow-revocation"].includes(message.command ?? "")) {
+ assert(!releaseLogRead)
+ const afterCommit = message.command === "arm-log-revocation-after-commit"
+ const follow = message.command === "arm-log-follow-revocation"
+ const owner = { ...actor, id: `${actor.id}-${follow ? "follow" : afterCommit ? "postcommit" : "precommit"}` }
+ revocationOwnerId = owner.id
+ if (follow) {
+ await pool.query("UPDATE servers SET enabled=true WHERE id=$1", [allowed])
+ await pool.query("UPDATE router_log_settings SET enabled=true WHERE id=1")
+ }
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned portal revocation during log read", mode: "observer", permissions: ["mm:servers:read"],
+ expiresAt: new Date(Date.now() + 600000).toISOString(),
+ scope: { serverIds: [Number(allowed)], operationIds: [follow ? "logs.follow" : "logs.query"], allowGlobal: false },
+ }), owner)
+ currentId = issued.connection.id
+ revokedLogRequests.push({ connectionId: currentId, tool: follow ? "mm_logs_follow" : "mm_logs_query" })
+ credentials.push(issued.token)
+ let completed!: () => void
+ logReadCompleted = new Promise(resolve => { completed = resolve })
+ const hold = new Promise(resolve => { releaseLogRead = resolve })
+ pool.connect = ((callback?: unknown) => {
+ if (typeof callback === "function") return Reflect.apply(originalConnect, pool, [callback])
+ return (async () => {
+ const client = await originalConnect.call(pool)
+ const query = client.query, release = client.release
+ let completingLog = false
+ client.query = (async (...args: unknown[]) => {
+ const params = args[1]
+ if (typeof args[0] === "string" && args[0].startsWith("UPDATE mcp_requests SET status=$2,result=")
+ && Array.isArray(params) && params[1] === "completed" && String(params[2]).includes(follow ? "external-sdk-live-event" : "external-sdk-log-1")) {
+ completingLog = true
+ if (!afterCommit) { completed(); await hold }
+ }
+ const result = await Reflect.apply(query, client, args)
+ if (afterCommit && completingLog && args[0] === "COMMIT") { completed(); await hold }
+ return result
+ }) as typeof query
+ client.release = error => {
+ client.query = query
+ client.release = release
+ release(error)
+ }
+ return client
+ })()
+ }) as typeof originalConnect
+ value = { token: issued.token }
+ } else if (message.command === "publish-follow-fixture-row") {
+ assert(releaseLogRead && currentId && revokedLogRequests.at(-1)?.tool === "mm_logs_follow")
+ const deadline = Date.now() + 3000
+ for (;;) {
+ const live = await pool.query("SELECT count(*)::int AS count FROM mcp_read_leases WHERE connection_id=$1", [currentId])
+ if (live.rows[0].count === 1) break
+ assert(Date.now() < deadline, "Owned follow did not acquire a live read lease")
+ await delay(25)
+ }
+ await pool.query(`INSERT INTO router_log_entries(server_id,server_name,host,router_id,raw_time,received_at,effective_at,topics,level,message,generation)
+ SELECT id,name,host,'fixture','00:00:01',now(),now(),ARRAY['system'],'info','external-sdk-live-event',0
+ FROM servers WHERE id=$1`, [allowed])
+ value = { ok: true }
+ } else if (message.command === "deliver-log-revocation") {
+ assert(logReadCompleted && releaseLogRead && currentId && revocationOwnerId)
+ try {
+ await Promise.race([logReadCompleted, delay(5000).then(() => { throw Error("Owned log read did not reach the barrier") })])
+ await deliverPortalRevocation(revocationOwnerId)
+ value = { ok: true }
+ } finally {
+ pool.connect = originalConnect
+ releaseLogRead()
+ releaseLogRead = undefined
+ logReadCompleted = undefined
+ revocationOwnerId = undefined
+ }
+ } else if (message.command === "new-connection") {
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({ name: "Owned external SDK process", mode: "observer", expiresAt: new Date(Date.now() + 1200000).toISOString(),
+ permissions: ["mm:servers:read"], scope: { serverIds: [Number(allowed)], operationIds: ["servers.list"], allowGlobal: false }, limits: { callsPerMinute: 200 } }), actor)
+ currentId = issued.connection.id; credentials.push(issued.token); value = { token: issued.token, connectionId: currentId }
+ } else if (message.command === "discovery-connection") {
+ const operations = listActions().map(action => action.operation)
+ const permissions = [...new Set(operations.flatMap(operation => operation.requiredPermissions))]
+ const issued = await createMcpConnection(mcpConnectionCreateSchema.parse({
+ name: "Owned full catalogue discovery", mode: "approval", expiresAt: new Date(Date.now() + 600000).toISOString(),
+ permissions, scope: { serverIds: [Number(allowed)], operationIds: operations.map(operation => operation.id), allowGlobal: true },
+ }), { ...actor, permissions: [...new Set([...actor.permissions, ...permissions])] })
+ currentId = issued.connection.id
+ credentials.push(issued.token)
+ value = { token: issued.token, names: operations.map(operation => operation.toolName) }
+ } else if (message.command === "large-result" || message.command === "reset-result") {
+ await pool.query("UPDATE servers SET comment=$2 WHERE id=$1", [allowed, message.command === "large-result" ? "Z".repeat(40000) + "OWNED_TRUNCATION_TAIL" : ""])
+ value = { ok: true }
+ } else {
+ assert(currentId)
+ if (message.command === "rotate") { const rotated = await rotateConnectionToken(currentId, actor); credentials.push(rotated.token); value = rotated }
+ else if (message.command === "pause" || message.command === "resume" || message.command === "revoke") { await setConnectionStatus(currentId, message.command === "pause" ? "paused" : message.command === "resume" ? "active" : "revoked", actor); value = { ok: true } }
+ else throw Error("Unsupported exact fixture control")
+ }
+ transcript.push({ command: message.command, connectionId: currentId })
+ child?.send({ kind: "reply", id: message.id, value })
+ } catch { child?.send({ kind: "reply", id: message.id, error: true }) }
+ })
+ const timer = setTimeout(() => { failure = { phase: "whole-external-client-deadline" }; child?.kill() }, 120000)
+ const code = await childExit; clearTimeout(timer)
+ if (code !== 0 || !result) { console.log("OWNED_EXTERNAL_PROCESS_FAILURE", JSON.stringify({ code, failure, stdout: stdout.slice(0,1000), stderr: stderr.slice(0,1000) })); throw Error("External SDK process did not complete") }
+ const logs = JSON.stringify((await pool.query("SELECT tool,input,result,error_code FROM mcp_requests ORDER BY created_at")).rows)
+ assert.equal(revokedLogRequests.length, 3)
+ assert.ok(planConnectionId)
+ const invalidated = (await pool.query("SELECT state FROM mcp_plans WHERE connection_id=$1", [planConnectionId])).rows
+ assert.deepEqual(invalidated, [{ state: "invalidated" }])
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_operations WHERE connection_id=$1", [planConnectionId])).rows[0].count, 0)
+ assert.equal((await pool.query("SELECT enabled FROM router_log_settings WHERE id=1")).rows[0].enabled, true)
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_artifacts WHERE connection_id=$1 AND expires_at>now()", [artifactConnectionId])).rows[0].count, 1)
+ for (const { connectionId, tool } of revokedLogRequests) {
+ const revokedRead = (await pool.query("SELECT status,error_code,result FROM mcp_requests WHERE connection_id=$1 AND tool=$2 AND status='error'", [connectionId, tool])).rows
+ assert.equal(revokedRead.length, 1)
+ assert.equal(revokedRead[0].status, "error")
+ assert.deepEqual(Object.keys(revokedRead[0].result), ["message"])
+ assert.doesNotMatch(JSON.stringify(revokedRead[0].result), /external-sdk-log-1|external-sdk-live-event|"entries"|"nextCursor"|"cursor"/)
+ assert.ok(["OWNER_CLAIMS_REVOKED", "UNAUTHORIZED"].includes(revokedRead[0].error_code))
+ assert.equal((await pool.query("SELECT count(*)::int AS count FROM mcp_read_leases WHERE connection_id=$1", [connectionId])).rows[0].count, 0)
+ }
+ for (const token of [...credentials, jwt, secret]) { assert(!logs.includes(token)); assert(!stdout.includes(token)); assert(!stderr.includes(token)) }
+ const final = { ...(result as object), actualOwnPg: true, actualProductionHttpServer: true, serverFixturePid: process.pid,
+ controlTransitions: transcript, auditCredentialLeakAbsent: true, denialWithoutConnection: true,
+ legacyDenialIgnoresPausedForeignConnection: true, nativeRouterCalls: 0, productionDatabaseTouched: false }
+ await writeFile(process.env.OWN_EXTERNAL_RESULT_FILE!, JSON.stringify(final, null, 2))
+ console.log("Owned external process SDK result:", JSON.stringify(final))
+ }
+} finally {
+ pool.connect = originalConnect
+ releaseLogRead?.()
+ try {
+ await drainChildAndBridges()
+ } finally {
+ try {
+ if (app) await app.close()
+ } finally {
+ try {
+ await stopSchedulerForDatabaseOperation()
+ } finally {
+ await closePool()
+ }
+ }
+ }
+}
diff --git a/backend/scripts/mcp-external-process/stdio-follow.test.mjs b/backend/scripts/mcp-external-process/stdio-follow.test.mjs
new file mode 100644
index 00000000..96be4004
--- /dev/null
+++ b/backend/scripts/mcp-external-process/stdio-follow.test.mjs
@@ -0,0 +1,73 @@
+import assert from 'node:assert/strict'
+import { createServer } from 'node:http'
+import { fileURLToPath } from 'node:url'
+import { test } from 'node:test'
+import { Client } from '@modelcontextprotocol/client'
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'
+import { createMcpHandler, McpServer } from '@modelcontextprotocol/server'
+import { toNodeHandler } from '@modelcontextprotocol/node'
+
+test('stdio cancellation reaches the in-flight upstream logs follow', { timeout: 15000 }, async () => {
+ const entered = Promise.withResolvers()
+ const cancelled = Promise.withResolvers()
+ const finish = Promise.withResolvers()
+ const handler = createMcpHandler(() => {
+ const server = new McpServer({ name: 'owned-stdio-follow', version: '1.0.0' })
+ server.server.registerCapabilities({ tools: {} })
+ server.server.setRequestHandler('tools/call', async ({ params }, context) => {
+ assert.equal(params.name, 'mm_logs_follow')
+ const signal = context.mcpReq.signal
+ const abort = () => { cancelled.resolve(); finish.resolve() }
+ if (signal.aborted) abort()
+ else signal.addEventListener('abort', abort, { once: true })
+ entered.resolve()
+ try { await finish.promise } finally { signal.removeEventListener('abort', abort) }
+ return { content: [] }
+ })
+ return server
+ }, { legacy: 'stateless' })
+ const dispatch = toNodeHandler(handler)
+ const http = createServer((req, res) => {
+ res.once('close', () => {
+ if (req.method === 'POST' && !res.writableFinished) { cancelled.resolve(); finish.resolve() }
+ })
+ void dispatch(req, res)
+ })
+ const client = new Client({ name: 'owned-stdio-client', version: '1.0.0' })
+ const within = (promise, phase) => {
+ const signal = AbortSignal.timeout(5000)
+ return new Promise((resolve, reject) => {
+ const abort = () => reject(new Error(phase, { cause: signal.reason }))
+ signal.addEventListener('abort', abort, { once: true })
+ promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort))
+ })
+ }
+ try {
+ await new Promise(resolve => http.listen(0, '127.0.0.1', resolve))
+ const transport = new StdioClientTransport({
+ command: process.execPath,
+ args: ['--import', import.meta.resolve('tsx'), fileURLToPath(new URL('../../src/scripts/mcp-stdio.ts', import.meta.url))],
+ env: { MCP_URL: `http://127.0.0.1:${http.address().port}/mcp`, MCP_TOKEN: 'synthetic-stdio-test' },
+ stderr: 'pipe',
+ })
+ const outbound = []
+ const send = transport.send.bind(transport)
+ transport.send = (message, options) => { outbound.push(message.method); return send(message, options) }
+ await within(client.connect(transport), 'stdio connection deadline')
+ const caller = new AbortController()
+ const call = client.callTool({ name: 'mm_logs_follow', arguments: {} }, { signal: caller.signal })
+ const rejected = assert.rejects(call)
+ void rejected.catch(() => {})
+ await within(entered.promise, 'upstream did not receive follow')
+ caller.abort()
+ assert(outbound.includes('notifications/cancelled'), JSON.stringify(outbound))
+ await within(Promise.all([cancelled.promise, rejected]), 'upstream did not observe cancellation')
+ await within(client.ping(), 'bridge did not remain usable')
+ } finally {
+ finish.resolve()
+ await client.close()
+ http.closeAllConnections()
+ await handler.close()
+ await new Promise(resolve => http.close(resolve))
+ }
+})
diff --git a/backend/scripts/provision-database-source-binding.mjs b/backend/scripts/provision-database-source-binding.mjs
new file mode 100644
index 00000000..b1791f7e
--- /dev/null
+++ b/backend/scripts/provision-database-source-binding.mjs
@@ -0,0 +1,10 @@
+// Explicit offline command only. Run with the TS loader; never startup/import.
+import { databaseSourceBindingOperatorCli } from './database-source-binding-operator.ts'
+try {
+ const result = await databaseSourceBindingOperatorCli(process.argv.slice(2))
+ console.log(JSON.stringify(result, null, 2))
+} catch {
+ // Do not reflect request contents, key data or untrusted filenames.
+ console.error('Offline operator source-binding provisioning refused; inspect the explicitly selected output before any new manual invocation')
+ process.exitCode = 1
+}
diff --git a/backend/scripts/source57-publication-owned.mjs b/backend/scripts/source57-publication-owned.mjs
new file mode 100644
index 00000000..105bd566
--- /dev/null
+++ b/backend/scripts/source57-publication-owned.mjs
@@ -0,0 +1,115 @@
+import assert from 'node:assert/strict'
+import {access,mkdir,readFile} from 'node:fs/promises'
+import {join} from 'node:path'
+
+export async function verifyOwnedSource57Publication({pg,control,operator,actor,main,directory,store,sha,bootstrapMaterial,bootstrap,request,pin,registry,tls,
+ activation,activationDirectory,publisherTransport,publisherTransportSha256,controlTransport,controlTransportSha256,ca,quarantine,publishSource58}){
+ const [{collectSource57Catalogue},{BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE},{readProtectedRegistryStructureData},
+ {readCurrentApplicationWriterProfile},{sourceBindingBytes},{bytes,canonical},{retainPublisherTlsPeer}]=await Promise.all([
+ import('./writer-profile/catalogue.mts'),import('./writer-profile/fixed57-build-definition.ts'),
+ import('../src/db/application-writer-profile-registry-structure.ts'),import('../src/db/application-writer-profile-registry-read.ts'),
+ import('../src/db/database-source-binding.ts'),import('../src/db/application-writer-profile-format.ts'),import('./writer-profile/operator-contract.mjs'),
+ ])
+ const bootstrapDir=join(directory,'source57-offline-bootstrap'),journal=join(directory,'source57-publication-journal')
+ await mkdir(bootstrapDir,{mode:0o700});await mkdir(journal,{mode:0o700})
+ const bootstrapFile=await store('source57-offline-bootstrap/bootstrap.json',bootstrap)
+ await store('source57-offline-bootstrap/signing-private.pem',bootstrapMaterial.privateKeyPem)
+ const definition=sourceBindingBytes({format:'application-writer-source57-definition-approval-v1',provenance:BUILD57_PROVENANCE,template:FIXED57_ROLE_TEMPLATE})
+ const definitionFile=await store('source57-definition.json',definition)
+ const subject=bootstrapMaterial.bootstrap.verificationSubject
+
+ // Review the already-provisioned isolated source through a separate ordinary
+ // operator backend, rather than letting the product publisher derive approval.
+ const approvedCatalogue=await (async()=>{
+ const client=await operator.connect()
+ try{
+ const retain=retainPublisherTlsPeer(client,tls)
+ await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ const [base,security]=[await collectSource57Catalogue(client,{roleBindings:request.roles}),await readProtectedRegistryStructureData(client,request.roles)]
+ retain()
+ return sha(canonical({base:base.catalogSha256,security:security.sha256}))
+ }finally{await client.query('ROLLBACK');client.release(true)}
+ })()
+ const shared=['--bootstrap',bootstrapFile,'--bootstrap-sha256',sha(bootstrap),'--transport',publisherTransport,'--transport-sha256',publisherTransportSha256,
+ '--ca',ca,'--source-registry',pin.registryDirectory,'--source-spki-sha256',pin.publicKeySpkiSha256,
+ '--definition',definitionFile,'--definition-sha256',sha(definition),'--journal',journal,
+ '--activation-directory',activationDirectory,'--activation-sha256',sha(activation)]
+ const approval=async(expectedHeadSha256,name)=>{
+ const payload=sourceBindingBytes({format:'application-writer-publication-approval-v1',manifestSha256:BUILD57_PROVENANCE.manifestSha256,
+ definitionSha256:BUILD57_PROVENANCE.templateSha256,catalogSha256:approvedCatalogue,expectedHeadSha256,validityMs:120000,expiresAt:Date.now()+90000})
+ return ['--approval',await store(name,payload),'--approval-sha256',sha(payload)]
+ }
+ const observe=async()=>{
+ const connection=await operator.connect()
+ try{
+ const retained=retainPublisherTlsPeer(connection,tls)
+ await connection.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ const current=await readCurrentApplicationWriterProfile(connection,subject)
+ retained()
+ return current
+ }finally{await connection.query('ROLLBACK');connection.release(true)}
+ }
+ const genesisArgs=await approval(null,'source57-genesis-approval.json')
+ const genesis=await main(['publish',...shared,...genesisArgs])
+ assert.equal(genesis.epoch,'1');assert.equal(genesis.cleanupUnconfirmed,false);assert.equal(genesis.journalUnconfirmed,false)
+ const first=await observe()
+ assert.equal(first.epoch,'1');assert.equal(first.headSha256,genesis.headSha256);assert.equal(first.policy.catalogSha256,approvedCatalogue)
+ assert.deepEqual(first.policy.source,request.source)
+ assert.deepEqual(first.policy.roles,Object.fromEntries(Object.entries(request.roles).map(([name,role])=>[name,role.signedOid])))
+
+ if(!quarantine){
+ await assert.rejects(main(['publish',...shared,...genesisArgs]),error=>error.cause?.message==='Expected protected current head mismatch')
+ assert.equal((await observe()).headSha256,first.headSha256)
+ }
+ const renewArgs=await approval(genesis.headSha256,'source57-renewal-approval.json')
+ const renewed=await main(['publish',...shared,...renewArgs])
+ assert.equal(renewed.epoch,'2');assert.equal(renewed.cleanupUnconfirmed,false);assert.equal(renewed.journalUnconfirmed,false)
+ const second=await observe();assert.equal(second.epoch,'2');assert.equal(second.headSha256,renewed.headSha256)
+ const {rows:links}=await control.query(`SELECT epoch::text,head_sha256,previous_head_sha256
+ FROM mmapp_control.application_writer_profile_history WHERE installation_id=$1 ORDER BY epoch`,[subject.installationId])
+ assert.deepEqual(links,[{epoch:'1',head_sha256:genesis.headSha256,previous_head_sha256:null},
+ {epoch:'2',head_sha256:renewed.headSha256,previous_head_sha256:genesis.headSha256}])
+ const preflight=['source-preflight',...shared,...renewArgs]
+ const checked=await main(preflight)
+ assert.equal(checked.outcome,'matched');assert.equal(checked.headSha256,renewed.headSha256);assert.equal(checked.platformProtectionVerified,true)
+ if(quarantine){
+ const {verifyOwnedSource58RestoreEnrollment}=await import('./source58-restore-enrollment-owned.mjs')
+ return await verifyOwnedSource58RestoreEnrollment({pg,control,actor,main,store,sha,request,approvedCatalogue,subject,renewed,observe,
+ bootstrapFile,bootstrap,controlTransport,controlTransportSha256,ca,shared,publishSource58})
+ }
+
+ const staleActivation=[...preflight]
+ staleActivation[staleActivation.indexOf('--activation-sha256')+1]='0'.repeat(64)
+ await assert.rejects(main(staleActivation),/Active activation digest changed/)
+ const replaceSignature=value=>({...value,signature:(value.signature[0]==='A'?'B':'A')+value.signature.slice(1)})
+ const badRegistry=join(directory,'source57-invalid-source-signature');await mkdir(badRegistry,{mode:0o700})
+ const headName='head-'+pin.currentHeadSha256+'.json',bindingName='binding-'+registry.head.bindingSha256+'.json'
+ const invalid=sourceBindingBytes(replaceSignature(JSON.parse(await readFile(join(pin.registryDirectory,headName),'utf8'))))
+ await store('source57-invalid-source-signature/operator-public.pem',await readFile(join(pin.registryDirectory,'operator-public.pem')))
+ await store('source57-invalid-source-signature/'+bindingName,await readFile(join(pin.registryDirectory,bindingName)))
+ await store('source57-invalid-source-signature/head-'+sha(invalid)+'.json',invalid)
+ const refusedActivation=join(directory,'source57-invalid-activation');await mkdir(refusedActivation,{mode:0o700})
+ const activationApproval=sourceBindingBytes({format:'database-source-activation-approval-v1',activationDirectory:refusedActivation,
+ sourcePin:{...pin,registryDirectory:badRegistry,currentHeadSha256:sha(invalid)},tlsSpkiSha256:tls.spkiSha256,expectedActivationSha256:null})
+ await assert.rejects(main(['source-activate','--directory',refusedActivation,'--approval',await store('source57-invalid-activation-approval.json',activationApproval),
+ '--approval-sha256',sha(activationApproval)]),{code:'DATABASE_SOURCE_BINDING_REFUSED'})
+ await assert.rejects(access(join(refusedActivation,'source-activation.json')),{code:'ENOENT'})
+
+ const {rows:[previous]}=await control.query(`SELECT head_bytes FROM mmapp_control.application_writer_profile_history WHERE installation_id=$1 AND epoch=1`,[subject.installationId])
+ const replacePredecessor=raw=>control.query(`UPDATE mmapp_control.application_writer_profile_history SET head_bytes=$2
+ WHERE installation_id=$1 AND epoch=1`,[subject.installationId,raw])
+ await replacePredecessor(bytes(replaceSignature(JSON.parse(previous.head_bytes.toString('utf8')))))
+ try{
+ await assert.rejects(observe(),/Installation signature refused/)
+ await assert.rejects(main(preflight),error=>error.cause?.message==='Installation signature refused')
+ }finally{await replacePredecessor(previous.head_bytes)}
+ assert.equal((await observe()).headSha256,renewed.headSha256)
+ const runtime=actor('runtime')
+ try{await assert.rejects(readCurrentApplicationWriterProfile(runtime,subject),{code:'42501'})}finally{await runtime.end()}
+ const {rows:[gate]}=await control.query("SELECT pg_catalog.to_regclass('mmapp_control.database_restore_quarantine') IS NULL AS absent")
+ assert.equal(gate.absent,true)
+ return {source57PublicationVerified:true,exactRetainedSourcePreflight:true,independentCatalogueReviewed:true,publishedEpochs:['1','2'],
+ signedGenesisAndPredecessorVerified:true,signedPredecessorTamperingRefused:true,wrongWriterCasRejected:true,activationDigestTamperingRefused:true,
+ forgedSourceHeadSignatureRefused:true,runtimeRegistryReadRefusedBefore58:true,catalogueSha256:approvedCatalogue,writerHeadSha256:renewed.headSha256,
+ source58QuarantineInstalled:false,readyAuthorized:false}
+}
diff --git a/backend/scripts/source58-foundation-owned.mjs b/backend/scripts/source58-foundation-owned.mjs
new file mode 100644
index 00000000..8cb30027
--- /dev/null
+++ b/backend/scripts/source58-foundation-owned.mjs
@@ -0,0 +1,169 @@
+import assert from 'node:assert/strict'
+import {generateKeyPairSync,randomBytes,randomUUID,sign,X509Certificate} from 'node:crypto'
+import {mkdir,writeFile} from 'node:fs/promises'
+import {basename,dirname,join,resolve} from 'node:path'
+import {tmpdir} from 'node:os'
+import {modelOwnedOperatorFiles} from './legacy-probe-cold-verify-owned.mjs'
+
+export async function verifyOwnedSource58Foundation(pg,options,leaf,directory,admission=false){
+ assert.equal(options.host,'127.0.0.1');assert.equal(options.database,'postgres');assert.equal(options.user,'archive_leaf_fixture')
+ assert.equal(dirname(directory),resolve(tmpdir()));assert.match(basename(directory),/^mm-archive-leaf-tls-/)
+ process.env.DATABASE_URL=`postgres://${options.user}:${options.password}@127.0.0.1:${options.port}/postgres`
+ const [{sourceBindingBytes,sourceBindingCanonical,sourceBindingSha256,readDatabaseSourceBindingRegistry},{provisionDatabaseSourceBindingOffline},
+ {migrationManifestDigest},{RESTORE_WRITER_PROFILE_DEFINITION_SHA256},{captureMigrationSchema},{applySqlMigrations},{createBootstrapMaterial}]=await Promise.all([
+ import('../src/db/database-source-binding.ts'),import('./database-source-binding-operator.ts'),import('../src/db/migration-manifest.ts'),
+ import('../src/db/database-restore-quarantine-profile.ts'),import('../src/db/migration-schema-inventory.ts'),import('../src/db/migrate.ts'),
+ import('./database-writer-bootstrap-operator.mjs'),
+ ])
+ const control=new pg.Pool(options),passwords={},names={control:options.user,operator:'owned_source58_operator',publisher:'owned_source58_publisher',
+ runtime:'owned_source58_runtime',capture:'owned_source58_capture'}
+ const sha=sourceBindingSha256,store=async(name,bytes)=>{const file=join(directory,name);await writeFile(file,bytes,{flag:'wx',mode:0o600});return file}
+ const restoreProfile=admission==='quarantine'||admission==='upgrade'
+ const publishes=admission==='publication'||restoreProfile
+ let publisher,operator,modeled
+ try{
+ for(const scope of ['operator','publisher','runtime','capture']){
+ passwords[scope]=randomBytes(24).toString('hex')
+ await control.query(`CREATE ROLE ${names[scope]} LOGIN PASSWORD '${passwords[scope]}'`)
+ }
+ await control.query(`REVOKE ALL ON DATABASE postgres FROM PUBLIC;
+ GRANT CONNECT ON DATABASE postgres TO ${[names.operator,names.publisher,names.runtime,names.capture].join(', ')};
+ ALTER SCHEMA public OWNER TO ${names.operator}; CREATE SCHEMA mmapp_control;
+ GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${names.operator}, ${names.publisher}`)
+ const actor=scope=>new pg.Pool({...options,user:names[scope],password:passwords[scope]})
+ publisher=actor('publisher');operator=actor('operator')
+ await applySqlMigrations(operator)
+ const {rows:[source]}=await publisher.query(`SELECT current_database() AS "databaseName",current_user::text AS "currentUser",session_user::text AS "sessionUser",
+ (pg_catalog.pg_control_system()).system_identifier::text AS "systemIdentifier",pg_catalog.pg_is_in_recovery() AS "inRecovery",
+ current_setting('server_version_num')::int AS "serverVersionNum",d.oid::int AS "databaseOid"
+ FROM pg_catalog.pg_database d WHERE d.datname=current_database()`)
+ const {rows:liveRoles}=await control.query('SELECT rolname AS name,oid::text AS "signedOid" FROM pg_catalog.pg_roles WHERE rolname=ANY($1::text[])',[Object.values(names)])
+ const roles=Object.fromEntries(Object.entries(names).map(([scope,name])=>[scope,liveRoles.find(role=>role.name===name)]))
+ const sourceKey=generateKeyPairSync('ed25519'),approver=generateKeyPairSync('ed25519')
+ const signer=await store('foundation-source-key.pem',sourceKey.privateKey.export({format:'pem',type:'pkcs8'}))
+ const {deploymentPin:pin}=await provisionDatabaseSourceBindingOffline({request:{installationId:randomUUID(),sourceIdentityId:randomUUID(),generation:randomUUID(),source},
+ privateKeyFile:signer,outputDirectory:join(directory,'foundation-source-registry')})
+ const registry=await readDatabaseSourceBindingRegistry(pin)
+ const tls={serverName:'localhost',caSha256:sha(leaf),spkiSha256:sha(new X509Certificate(leaf).publicKey.export({format:'der',type:'spki'}))}
+ const request={format:'application-writer-bootstrap-request-v1',installationId:pin.installationId,sourceHeadSha256:registry.headSha256,roles,tls,
+ source:{systemIdentifier:source.systemIdentifier,databaseOid:String(source.databaseOid),databaseName:source.databaseName,serverVersionNum:source.serverVersionNum,inRecovery:false}}
+ const bootstrapMaterial=createBootstrapMaterial(request,sha(sourceBindingBytes(request)))
+ const bootstrap=sourceBindingBytes(bootstrapMaterial.bootstrap)
+ const activationDirectory=join(directory,'foundation-activation');await mkdir(activationDirectory,{mode:0o700})
+ const activation=sourceBindingBytes({format:'database-source-activation-v1',activationDirectory,installationId:pin.installationId,sourceIdentityId:registry.body.sourceIdentityId,
+ status:'active',publicKeySpkiSha256:pin.publicKeySpkiSha256,generations:[{generation:registry.body.generation,headSha256:registry.headSha256,
+ bindingSha256:registry.head.bindingSha256,tlsSpkiSha256:tls.spkiSha256}]})
+ await store('foundation-activation/source-activation.json',activation)
+ const states=async(includeControlEventTriggers=false)=>{
+ const client=await control.connect()
+ try{
+ await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ await client.query("SET LOCAL search_path=pg_catalog; SET LOCAL TimeZone='UTC'; SET LOCAL DateStyle='ISO, YMD'; SET LOCAL statement_timeout='5s'")
+ return await captureMigrationSchema(client,{scope:{applicationNamespaces:['public','mmapp_control']},includeControlEventTriggers})
+ }finally{await client.query('ROLLBACK');client.release(true)}
+ }
+ const baseline=await states()
+ modeled=await modelOwnedOperatorFiles(directory,sha)
+ const [{main},{SOURCE58_FOUNDATION_DOMAIN,source58FoundationSqlSha256}]=await Promise.all([
+ import('./database-writer-profile-operator.mts'),import('./writer-profile/source58-foundation.mts'),
+ ])
+ const manifestSha256=migrationManifestDigest(),foundationSha256=source58FoundationSqlSha256(roles)
+ const approved={format:'source58-foundation-approval-v1',decision:'install-foundations',bootstrapSha256:sha(bootstrap),
+ sourceHeadSha256:registry.headSha256,sourceTlsSpkiSha256:tls.spkiSha256,manifestSha256,definitionSha256:RESTORE_WRITER_PROFILE_DEFINITION_SHA256,
+ preSchemaSha256:baseline.sha256,foundationSha256,expiresAt:Date.now()+90000}
+ const args=['source58-foundation-enroll','--bootstrap',await store('foundation-bootstrap.json',bootstrap),'--bootstrap-sha256',sha(bootstrap),
+ '--source-registry',pin.registryDirectory,'--source-spki-sha256',pin.publicKeySpkiSha256,'--activation-directory',activationDirectory,
+ '--activation-sha256',sha(activation),'--ca',await store('foundation-ca.pem',leaf),
+ '--approval-public-key',await store('foundation-approval-pub.pem',approver.publicKey.export({format:'pem',type:'spki'})),
+ '--approval-spki-sha256',sha(approver.publicKey.export({format:'der',type:'spki'}))]
+ for(const [scope,password] of [['publisher',passwords.publisher],['control',options.password]]){
+ const transport=sourceBindingBytes({host:'localhost',port:options.port,user:names[scope],password,database:options.database})
+ args.push('--'+scope+'-transport',await store('foundation-'+scope+'-transport.json',transport),'--'+scope+'-transport-sha256',sha(transport))
+ }
+ const approve=async(body,name)=>{
+ const bytes=sourceBindingBytes({body,signature:sign(null,Buffer.from(SOURCE58_FOUNDATION_DOMAIN+sourceBindingCanonical(body)),approver.privateKey).toString('base64url')})
+ return [...args,'--approval',await store(name,bytes),'--approval-sha256',sha(bytes)]
+ }
+ if(!publishes){
+ await assert.rejects(main(await approve({...approved,preSchemaSha256:'0'.repeat(64)},'foundation-wrong-base.json')),/Exact signed pre-foundation catalogue required/)
+ assert.equal((await states()).sha256,baseline.sha256)
+ }
+ const install=await approve(approved,'foundation-approval.json'),result=await main(install)
+ assert.equal(result.event,'database-source58-foundation');assert.equal(result.outcome,'committed');assert.equal(result.foundationSha256,foundationSha256)
+ assert.equal(result.readyAuthorized,false);assert.equal(result.cleanupUnconfirmed,false)
+ if(!publishes){
+ await assert.rejects(main(install),/Unenrolled staging control namespace and marker required/)
+ await assert.rejects(operator.query('CREATE TABLE public.owned_foundation_ddl(id int)'),{code:'55000'})
+ const connection=await operator.connect()
+ try{
+ await connection.query('BEGIN')
+ await connection.query('SELECT pg_catalog.pg_advisory_xact_lock_shared(8723110::bigint)')
+ await connection.query('CREATE TABLE public.owned_foundation_ddl(id int)')
+ }finally{await connection.query('ROLLBACK');connection.release(true)}
+ }
+ const {rows:[state]}=await control.query(`SELECT
+ (SELECT count(*)::int FROM mmapp_control.application_writer_profile_current) AS heads,
+ (SELECT count(*)::int FROM mmapp_control.application_writer_profile_history) AS history,
+ pg_catalog.to_regclass('mmapp_control.database_restore_quarantine') IS NULL AS quarantine_absent,
+ (SELECT count(*)::int FROM pg_catalog.pg_trigger WHERE tgrelid='public.schema_migrations'::regclass AND NOT tgisinternal) AS marker_triggers`)
+ assert.deepEqual(state,{heads:0,history:0,quarantine_absent:true,marker_triggers:0})
+ if(admission){
+ const [{SOURCE57_ADMISSION_DOMAIN},{source57AdmissionSqlSha256},{BUILD57_PROVENANCE},
+ {assertReviewedMigrationMarkerGuard},{collectSource57Catalogue},{readProtectedRegistryStructureData},{canonical}]=await Promise.all([
+ import('./writer-profile/source58-foundation.mts'),import('./writer-profile/source57-admission-plan.mts'),import('./writer-profile/fixed57-build-definition.ts'),
+ import('../src/db/partition-guard-inheritance.ts'),import('./writer-profile/catalogue.mts'),
+ import('../src/db/application-writer-profile-registry-structure.ts'),import('./writer-profile/application-writer-profile-canonical.ts'),
+ ])
+ const predecessor=await states(true),admissionSha256=source57AdmissionSqlSha256(roles)
+ const {foundationSha256:_foundation,...common}=approved
+ const body={...common,format:'source57-admission-approval-v1',decision:'install-admission',
+ definitionSha256:BUILD57_PROVENANCE.templateSha256,preSchemaSha256:predecessor.sha256,admissionSha256,expiresAt:Date.now()+90000}
+ const issue=async(body,name)=>{
+ const bytes=sourceBindingBytes({body,signature:sign(null,Buffer.from(SOURCE57_ADMISSION_DOMAIN+sourceBindingCanonical(body)),approver.privateKey).toString('base64url')})
+ return ['source57-admission-enroll',...args.slice(1),'--approval',await store(name,bytes),'--approval-sha256',sha(bytes)]
+ }
+ if(!publishes){
+ await assert.rejects(main(await issue({...body,preSchemaSha256:'0'.repeat(64)},'admission-wrong-base.json')),/Exact signed pre-admission catalogue required/)
+ assert.equal((await states(true)).sha256,predecessor.sha256)
+ }
+ const admissionArgs=await issue(body,'admission-approval.json'),result=await main(admissionArgs)
+ assert.equal(result.admissionSha256,admissionSha256);assert.equal(result.readyAuthorized,false)
+ if(publishes){
+ const {verifyOwnedSource57Publication}=await import('./source57-publication-owned.mjs')
+ return await verifyOwnedSource57Publication({pg,control,operator,actor,main,directory,store,sha,bootstrapMaterial,bootstrap,request,pin,registry,tls,
+ activation,activationDirectory,publisherTransport:args[args.indexOf('--publisher-transport')+1],publisherTransportSha256:args[args.indexOf('--publisher-transport-sha256')+1],
+ controlTransport:args[args.indexOf('--control-transport')+1],controlTransportSha256:args[args.indexOf('--control-transport-sha256')+1],
+ ca:args[args.indexOf('--ca')+1],quarantine:restoreProfile,publishSource58:admission==='upgrade'})
+ }
+ await assert.rejects(main(admissionArgs),/Unenrolled public relations and empty Source57 writer registry required/)
+ const markerReader=await operator.connect()
+ try{
+ await markerReader.query('BEGIN')
+ await markerReader.query('SELECT pg_catalog.pg_advisory_xact_lock_shared(8723110::bigint)')
+ await assertReviewedMigrationMarkerGuard(markerReader)
+ }finally{await markerReader.query('ROLLBACK');markerReader.release(true)}
+ await assert.rejects(operator.query('TRUNCATE public.schema_migrations'),{code:'55000'})
+ const runtime=actor('runtime')
+ try{
+ assert.equal((await runtime.query('SELECT count(*)::int AS n FROM public.schema_migrations')).rows[0].n,57)
+ await assert.rejects(runtime.query('UPDATE public.schema_migrations SET applied_at=now()'),{code:'42501'})
+ }finally{await runtime.end()}
+ const verified=await publisher.connect()
+ try{
+ await verified.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ const [catalogue,security]=[await collectSource57Catalogue(verified,{roleBindings:roles}),await readProtectedRegistryStructureData(verified,roles)]
+ assert.equal(sha(canonical({base:catalogue.catalogSha256,security:security.sha256})),result.catalogueSha256)
+ }finally{await verified.query('ROLLBACK');verified.release(true)}
+ return {source57AdmissionInstalled:true,exactSource57CatalogueVerified:true,admissionSha256,catalogueSha256:result.catalogueSha256,
+ realOperatorReviewedMarkerAccepted:true,unadmittedMarkerTruncateRefused:true,runtimeMarkerUpdateRefused:true,existing57MarkersPreserved:true,
+ signedWrongPredecessorRefused:true,replayRefused:true,publishedWriterHead:false,restoreQuarantineInstalled:false,readyAuthorized:false}
+ }
+ return {source58FoundationInstalled:true,signedWrongPredecessorRefused:true,replayRefused:true,operatorDdlWithoutAttemptLockRefused:true,
+ operatorDdlUnderAttemptLockVerified:true,registryEmpty:true,markerCohortInstalled:false,readyAuthorized:false,
+ foundationSha256,registryStructureSha256:result.registryStructureSha256}
+ }finally{
+ modeled?.restore()
+ await Promise.all([control.end(),publisher?.end(),operator?.end()])
+ await (await import('../src/db/index.ts')).closePool()
+ }
+}
diff --git a/backend/scripts/source58-publication-owned.mjs b/backend/scripts/source58-publication-owned.mjs
new file mode 100644
index 00000000..f4c6d2a4
--- /dev/null
+++ b/backend/scripts/source58-publication-owned.mjs
@@ -0,0 +1,66 @@
+import assert from 'node:assert/strict'
+
+export async function verifyOwnedSource58Publication({control,actor,main,store,sha,request,subject,renewed,approvedCatalogue,candidate,
+ candidateArgs,inspect,manifestSha256,definitionSha256}){
+ const [{sourceBindingBytes},{bytes},{approvedRuntimeWriterProfile},{retainPublisherTlsPeer}]=await Promise.all([
+ import('../src/db/database-source-binding.ts'),import('../src/db/application-writer-profile-format.ts'),
+ import('../src/db/database-runtime-writer-profile.ts'),import('./writer-profile/operator-contract.mjs'),
+ ])
+ const catalogueApproval=async(format,name,previousCatalogue)=>{
+ const payload=sourceBindingBytes({format,manifestSha256,definitionSha256,catalogSha256:candidate.sha256,
+ expectedHeadSha256:renewed.headSha256,validityMs:120000,expiresAt:Date.now()+90000,
+ ...(previousCatalogue?{previousCatalogSha256:previousCatalogue}:{})})
+ return ['--approval',await store(name,payload),'--approval-sha256',sha(payload)]
+ }
+ const readRuntime=async(profile)=>{
+ const runtime=actor('runtime'),reader=await runtime.connect()
+ try{
+ const retain=retainPublisherTlsPeer(reader,request.tls)
+ await reader.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ const {rows:[identity]}=await reader.query(`SELECT oid::text AS oid,current_database() AS db
+ FROM pg_catalog.pg_roles WHERE rolname=SESSION_USER AND SESSION_USER=CURRENT_USER AND NOT (rolsuper OR rolcreaterole OR rolcreatedb OR rolbypassrls)`)
+ assert.deepEqual(identity,{oid:request.roles.runtime.signedOid,db:request.source.databaseName})
+ const result=await profile.check(reader);retain();profile.assertLive()
+ return result
+ }finally{try{await reader.query('ROLLBACK')}finally{reader.release(true);await runtime.end()}}
+ }
+ const runtimeApproval=(epoch,head)=>approvedRuntimeWriterProfile(sourceBindingBytes({format:'database-runtime-writer-approval-v1',
+ publicKeyPem:subject.publicKeyPem,publicKeySpkiSha256:subject.publicKeySpkiSha256,minimumEpoch:epoch,minimumHeadSha256:head}),
+ {installationId:subject.installationId,source:request.source,roles:Object.fromEntries(Object.entries(request.roles).map(([scope,role])=>[scope,role.signedOid]))})
+ await assert.rejects(readRuntime(runtimeApproval(renewed.epoch,renewed.headSha256)),/подписанный профиль записи PostgreSQL не подтверждён/)
+ const upgradeApproval=await catalogueApproval('application-writer-upgrade57-to58-approval-v1','restore58-upgrade-approval.json',approvedCatalogue)
+ const published=await main(['upgrade',...candidateArgs,...upgradeApproval])
+ assert.equal(published.epoch,'3');assert.equal(published.outcome,'committed')
+ assert.equal(published.cleanupUnconfirmed,false);assert.equal(published.journalUnconfirmed,false)
+ assert.equal(published.readyAuthorized,false)
+
+ const inspectArgs=['source-catalogue-inspect',...inspect]
+ const verified=await main(inspectArgs)
+ assert.equal(verified.outcome,'observed');assert.equal(verified.epoch,'3')
+ assert.equal(verified.headSha256,published.headSha256);assert.equal(verified.catalogSha256,candidate.sha256)
+ const preflightApproval=await catalogueApproval('application-writer-publication-approval-v1','restore58-preflight-approval.json')
+ const confirmed=await main(['source-preflight',...candidateArgs,...preflightApproval])
+ assert.equal(confirmed.outcome,'matched');assert.equal(confirmed.headSha256,published.headSha256)
+ const runtimeProfile=runtimeApproval('3',published.headSha256)
+ const current=await readRuntime(runtimeProfile)
+ assert.equal(current.epoch,'3');assert.equal(current.sha256,published.headSha256)
+
+ const {rows:[predecessor]}=await control.query(`SELECT head_bytes,head_sha256 FROM mmapp_control.application_writer_profile_history
+ WHERE installation_id=$1 AND epoch=2`,[subject.installationId])
+ assert.equal(predecessor.head_sha256,renewed.headSha256)
+ const parsed=JSON.parse(predecessor.head_bytes.toString('utf8'))
+ parsed.signature=(parsed.signature[0]==='A'?'B':'A')+parsed.signature.slice(1)
+ const replace=raw=>control.query(`UPDATE mmapp_control.application_writer_profile_history SET head_bytes=$2
+ WHERE installation_id=$1 AND epoch=2`,[subject.installationId,raw])
+ await replace(bytes(parsed))
+ try{
+ await assert.rejects(main(inspectArgs),error=>error.cause?.message==='Installation signature refused')
+ await assert.rejects(readRuntime(runtimeProfile),/Installation signature refused/)
+ }finally{await replace(predecessor.head_bytes)}
+ assert.equal((await readRuntime(runtimeProfile)).sha256,published.headSha256)
+ assert.equal((await main(inspectArgs)).headSha256,published.headSha256)
+ return {source58WriterHeadPublished:true,source58PublishedEpoch:published.epoch,source57PredecessorEpoch:renewed.epoch,
+ source58CatalogueSha256:candidate.sha256,source58HeadSha256:published.headSha256,source58CatalogueInspectionAccepted:true,
+ source58ProtectedPreflightMatched:true,restrictedRuntimeProfileAccepted:true,prepublicationRuntimeProfileRefused:true,
+ tamperedPredecessorRefusedByOperatorAndRuntime:true,exactBytesRestoredBothReadersAccepted:true,readyAuthorized:false}
+}
diff --git a/backend/scripts/source58-restore-enrollment-owned.mjs b/backend/scripts/source58-restore-enrollment-owned.mjs
new file mode 100644
index 00000000..8dd92690
--- /dev/null
+++ b/backend/scripts/source58-restore-enrollment-owned.mjs
@@ -0,0 +1,124 @@
+import assert from 'node:assert/strict'
+
+export async function verifyOwnedSource58RestoreEnrollment({pg,control,actor,main,store,sha,request,approvedCatalogue,subject,renewed,observe,
+ bootstrapFile,bootstrap,controlTransport,controlTransportSha256,ca,shared,publishSource58}){
+ const [{collectSource57Catalogue,collectSource58Catalogue},{BUILD58_PROVENANCE,FIXED58_ROLE_TEMPLATE},
+ {readProtectedRegistryStructureData},{readCurrentApplicationWriterProfile},{restoreProfileEnrollmentSql},
+ {sourceBindingBytes},{bytes,canonical,KEY},{retainPublisherTlsPeer}]=await Promise.all([
+ import('./writer-profile/catalogue.mts'),import('./writer-profile/fixed58-build-definition.ts'),
+ import('../src/db/application-writer-profile-registry-structure.ts'),import('../src/db/application-writer-profile-registry-read.ts'),
+ import('../src/db/database-restore-quarantine-profile.ts'),import('../src/db/database-source-binding.ts'),
+ import('../src/db/application-writer-profile-format.ts'),import('./writer-profile/operator-contract.mjs'),
+ ])
+ const catalogue=async(client,edition)=>{
+ const security=await readProtectedRegistryStructureData(client,request.roles,edition===58)
+ const base=await (edition===58?collectSource58Catalogue:collectSource57Catalogue)(client,{roleBindings:request.roles})
+ return {sha256:sha(canonical({base:base.catalogSha256,security:security.sha256})),securitySha256:security.sha256}
+ }
+ const assertQuarantineAbsent=async()=>{
+ const {rows:[state]}=await control.query(`SELECT pg_catalog.to_regclass('mmapp_control.database_restore_quarantine') IS NULL AS absent,
+ pg_catalog.has_schema_privilege($1,'mmapp_control','USAGE') AS runtime_schema,
+ pg_catalog.has_table_privilege($1,'mmapp_control.application_writer_profile_current','SELECT') AS runtime_registry`,[request.roles.runtime.name])
+ assert.deepEqual(state,{absent:true,runtime_schema:false,runtime_registry:false})
+ }
+ const client=await control.connect()
+ let candidate
+ try{
+ const retain=retainPublisherTlsPeer(client,request.tls)
+ await client.query('BEGIN')
+ try{
+ await client.query('SET LOCAL search_path=pg_catalog')
+ await client.query('SELECT pg_catalog.pg_advisory_xact_lock($1::bigint)',[KEY])
+ await client.query('LOCK TABLE mmapp_control.application_writer_profile_current, mmapp_control.application_writer_profile_history IN SHARE MODE')
+ const {rows:[identity]}=await client.query(`SELECT oid::text AS oid, current_database() AS db,
+ (pg_catalog.pg_control_system()).system_identifier::text AS system,
+ (SELECT oid::text FROM pg_catalog.pg_database WHERE datname=current_database()) AS database_oid
+ FROM pg_catalog.pg_roles WHERE rolname=SESSION_USER AND SESSION_USER=CURRENT_USER`)
+ assert.deepEqual(identity,{oid:request.roles.control.signedOid,db:request.source.databaseName,system:request.source.systemIdentifier,database_oid:request.source.databaseOid})
+ const predecessor=await readCurrentApplicationWriterProfile(client,subject)
+ assert.equal(predecessor.headSha256,renewed.headSha256)
+ assert.equal(predecessor.policy.catalogSha256,approvedCatalogue)
+ assert.equal((await catalogue(client,57)).sha256,approvedCatalogue)
+ await client.query(restoreProfileEnrollmentSql(request.roles.runtime.name,request.roles.operator.name))
+ candidate=await catalogue(client,58);retain()
+ }finally{assert.equal((await client.query('ROLLBACK')).command,'ROLLBACK')}
+ await client.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ try{
+ assert.equal((await catalogue(client,57)).sha256,approvedCatalogue)
+ assert.equal((await readCurrentApplicationWriterProfile(client,subject)).headSha256,renewed.headSha256)
+ retain()
+ }finally{assert.equal((await client.query('ROLLBACK')).command,'ROLLBACK')}
+ }finally{client.release(true)}
+ await assertQuarantineAbsent()
+ assert.notEqual(candidate.sha256,approvedCatalogue)
+
+ const independentApproval=sourceBindingBytes({format:'application-writer-restore-profile-enrollment-v1',
+ catalogSha256:candidate.sha256,definitionSha256:BUILD58_PROVENANCE.templateSha256,deploymentRequest:request,
+ expectedHeadSha256:renewed.headSha256,manifestSha256:BUILD58_PROVENANCE.manifestSha256,previousCatalogSha256:approvedCatalogue})
+ const enroll=['restore-profile-enroll','--bootstrap',bootstrapFile,'--bootstrap-sha256',sha(bootstrap),
+ '--approval',await store('restore58-reviewed-approval.json',independentApproval),'--approval-sha256',sha(independentApproval),
+ '--transport',controlTransport,'--transport-sha256',controlTransportSha256,'--ca',ca]
+ if(!publishSource58){
+ const {rows:[first]}=await control.query(`SELECT head_bytes FROM mmapp_control.application_writer_profile_history
+ WHERE installation_id=$1 AND epoch=1`,[subject.installationId])
+ const envelope=JSON.parse(first.head_bytes.toString('utf8'))
+ envelope.signature=(envelope.signature[0]==='A'?'B':'A')+envelope.signature.slice(1)
+ const replace=raw=>control.query(`UPDATE mmapp_control.application_writer_profile_history SET head_bytes=$2
+ WHERE installation_id=$1 AND epoch=1`,[subject.installationId,raw])
+ await replace(bytes(envelope))
+ const connect=pg.Pool.prototype.connect
+ let ddlSent=0
+ pg.Pool.prototype.connect=function(...parameters){
+ const connection=connect.apply(this,parameters)
+ if(parameters.length||this.options.application_name!=='mmapp-writer-registry-enroll')return connection
+ return connection.then(client=>{
+ const query=client.query
+ client.query=function(text,...args){
+ if(typeof text==='string'&&text.includes('CREATE TABLE mmapp_control.database_restore_quarantine'))ddlSent++
+ return query.call(this,text,...args)
+ }
+ return client
+ })
+ }
+ try{await assert.rejects(main(enroll),/Installation signature refused/)}
+ finally{pg.Pool.prototype.connect=connect;await replace(first.head_bytes)}
+ assert.equal(ddlSent,0);await assertQuarantineAbsent()
+ }
+
+ const installed=await main(enroll)
+ assert.equal(installed.outcome,'committed');assert.equal(installed.cleanupUnconfirmed,false)
+ assert.equal(installed.registryStructureSha256,candidate.securitySha256);assert.equal(installed.readyAuthorized,false)
+ const definition=sourceBindingBytes({format:'application-writer-source58-definition-approval-v1',provenance:BUILD58_PROVENANCE,template:FIXED58_ROLE_TEMPLATE})
+ const candidateArgs=[...shared]
+ candidateArgs[candidateArgs.indexOf('--definition')+1]=await store('restore58-definition.json',definition)
+ candidateArgs[candidateArgs.indexOf('--definition-sha256')+1]=sha(definition)
+ const inspect=[...candidateArgs]
+ inspect.splice(inspect.indexOf('--journal'),2)
+ await assert.rejects(main(['source-catalogue-inspect',...inspect]),error=>error.cause?.message==='Approved source58 predecessor required')
+ if(publishSource58){
+ const {verifyOwnedSource58Publication}=await import('./source58-publication-owned.mjs')
+ return await verifyOwnedSource58Publication({control,actor,main,store,sha,request,subject,renewed,approvedCatalogue,candidate,
+ candidateArgs,inspect,manifestSha256:BUILD58_PROVENANCE.manifestSha256,definitionSha256:BUILD58_PROVENANCE.templateSha256})
+ }
+ const publisher=actor('publisher'),reader=await publisher.connect()
+ try{
+ const retain=retainPublisherTlsPeer(reader,request.tls)
+ await reader.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ assert.equal((await catalogue(reader,58)).sha256,candidate.sha256)
+ assert.equal((await readCurrentApplicationWriterProfile(reader,subject)).headSha256,renewed.headSha256)
+ retain()
+ }finally{await reader.query('ROLLBACK');reader.release(true);await publisher.end()}
+ assert.equal((await observe()).headSha256,renewed.headSha256)
+ const runtime=actor('runtime')
+ try{
+ assert.equal((await readCurrentApplicationWriterProfile(runtime,subject)).headSha256,renewed.headSha256)
+ const {rows:[row]}=await runtime.query('SELECT operation_id,journal_prefix_bytes,journal_prefix_sha256 FROM mmapp_control.database_restore_quarantine WHERE id=1')
+ assert.deepEqual(row,{operation_id:null,journal_prefix_bytes:null,journal_prefix_sha256:null})
+ await assert.rejects(runtime.query('UPDATE mmapp_control.database_restore_quarantine SET operation_id=NULL'),{code:'42501'})
+ }finally{await runtime.end()}
+ return {source58RestoreProfileInstalled:true,rolledBackCandidateCount:1,rollbackRestoredExactSource57:true,
+ independentlyPinnedTargetMatched:true,source57HeadPreserved:true,invalidPredecessorSignatureRefusedBeforeDdl:true,
+ runtimeReadQuarantineAndRegistry:true,runtimeQuarantineWriteRefused:true,source58CatalogueSha256:candidate.sha256,
+ source58InspectionStillRequiresPublishedHead:true,
+ source58WriterHeadPublished:false,readyAuthorized:false}
+}
diff --git a/backend/scripts/stage-database-operator.mjs b/backend/scripts/stage-database-operator.mjs
new file mode 100644
index 00000000..19e93738
--- /dev/null
+++ b/backend/scripts/stage-database-operator.mjs
@@ -0,0 +1,29 @@
+/** Build-time only: copy the exact operator inputs into a scoped Docker context. */
+import assert from 'node:assert/strict'
+import {constants} from 'node:fs'
+import {copyFile,lstat,mkdir} from 'node:fs/promises'
+import path from 'node:path'
+import {fileURLToPath,pathToFileURL} from 'node:url'
+import {OPERATOR_SOURCES} from './database-operator-sources.mjs'
+
+const scriptsDirectory=path.dirname(fileURLToPath(import.meta.url))
+const buildInputs=Object.freeze(['build-database-operator.mjs','database-operator-sources.mjs',...OPERATOR_SOURCES])
+
+export async function stageDatabaseOperatorScripts(destination,source=scriptsDirectory){
+ const from=path.resolve(source),to=path.resolve(destination)
+ assert(from!==to,'A separate operator staging directory is required')
+ // Refuse an incomplete source tree before writing any staged files.
+ for(const file of buildInputs)assert((await lstat(path.join(from,file))).isFile(),'Regular operator build input required: '+file)
+ for(const file of buildInputs){
+ const target=path.join(to,file)
+ await mkdir(path.dirname(target),{recursive:true})
+ await copyFile(path.join(from,file),target,constants.COPYFILE_EXCL)
+ }
+ return buildInputs.length
+}
+
+if(process.argv[1]&&import.meta.url===pathToFileURL(path.resolve(process.argv[1])).href){
+ assert(process.argv.length===3&&process.argv[2],'A single Docker scripts destination is required')
+ const files=await stageDatabaseOperatorScripts(process.argv[2])
+ console.log(JSON.stringify({event:'database-operator-inputs-staged',files}))
+}
diff --git a/backend/scripts/test-changed.mjs b/backend/scripts/test-changed.mjs
new file mode 100644
index 00000000..238123c6
--- /dev/null
+++ b/backend/scripts/test-changed.mjs
@@ -0,0 +1,63 @@
+// Runs only the backend tests that import a changed file (regression of what was touched).
+// npm --prefix backend run test:changed -- [--since=] [--list]
+// Default scope: uncommitted and untracked files. --since=[ uses `git diff ][` instead.
+// shortcut: one-level import match by file basename, not a real module graph; upgrade if basenames collide.
+// PostgreSQL-backed tests are listed with their npm profile, never run here.
+import { execFileSync, spawnSync } from "node:child_process"
+import { readdirSync, readFileSync } from "node:fs"
+import { basename, extname, join, relative, sep } from "node:path"
+
+const flag = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.slice(name.length + 3)
+const listOnly = process.argv.includes("--list")
+const since = flag("since")
+const backend = new URL("../", import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, "$1").replace(/\/$/, "")
+const git = (...args) => execFileSync("git", args, { encoding: "utf8", maxBuffer: 1 << 28 }).split("\n").filter(Boolean)
+const top = git("-C", backend, "rev-parse", "--show-toplevel")[0]
+const changed = [...new Set(since ? git("-C", top, "diff", "--name-only", since)
+ : [...git("-C", top, "diff", "--name-only", "HEAD"), ...git("-C", top, "ls-files", "--others", "--exclude-standard")])]
+ .filter(file => file.startsWith("backend/") && /\.(ts|mts|mjs|js)$/.test(file))
+
+const isTest = file => /\.test\.(ts|mts|mjs)$/.test(file)
+const tests = []
+const walk = dir => {
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
+ if (entry.name === "node_modules" || entry.name.startsWith("dist")) continue
+ const path = join(dir, entry.name)
+ if (entry.isDirectory()) walk(path)
+ else if (isTest(entry.name)) tests.push({ path, rel: relative(top, path).split(sep).join("/"), text: readFileSync(path, "utf8") })
+ }
+}
+walk(join(backend, "src")); walk(join(backend, "scripts"))
+
+const escape = text => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
+const selected = new Map()
+for (const file of changed) {
+ const base = basename(file, extname(file))
+ const importer = new RegExp(`[/"'\`]${escape(base)}(\\.(js|ts|mjs))?["'\`]`)
+ for (const test of tests) if (test.rel === file || basename(test.rel).startsWith(base + ".") || importer.test(test.text)) selected.set(test.rel, test)
+}
+
+const scripts = JSON.parse(readFileSync(join(backend, "package.json"), "utf8")).scripts
+const needsPostgres = test => /\.(sql|owned|pg)\.test\./.test(test.rel) || /embedded-postgres|EmbeddedPostgres/.test(test.text) || test.rel.endsWith("modules/mcp/integration.test.ts")
+const profileFor = test => Object.entries(scripts).find(([, command]) => command.includes(basename(test.rel)))?.[0]
+const runnable = [], database = []
+for (const test of selected.values()) (needsPostgres(test) ? database : runnable).push(test)
+
+console.log(`changed backend files: ${changed.length}; matching tests: ${selected.size} (run here: ${runnable.length}, PostgreSQL: ${database.length})`)
+const profiles = new Set()
+for (const test of database) {
+ const profile = test.rel.endsWith("modules/mcp/integration.test.ts") ? "test:mcp:pg" : profileFor(test)
+ profiles.add(profile ?? "test:mcp:pg:all")
+ console.log(` PostgreSQL: ${test.rel} -> ${profile ? `npm --prefix backend run ${profile}` : "no profile found, see test:mcp:pg:all"}`)
+}
+if (profiles.size) console.log(`PostgreSQL profiles to run separately: ${[...profiles].join(", ")}`)
+if (listOnly || !runnable.length) { for (const test of runnable) console.log(` run: ${test.rel}`); process.exit(0) }
+
+let failed = 0
+for (const [runner, group] of [["tsx", runnable.filter(test => !test.rel.endsWith(".mjs"))], ["node", runnable.filter(test => test.rel.endsWith(".mjs"))]]) {
+ if (!group.length) continue
+ const args = runner === "tsx" ? ["tsx", "--test", ...group.map(test => test.path)] : ["--test", ...group.map(test => test.path)]
+ const result = spawnSync(runner === "tsx" ? "npx" : process.execPath, args, { cwd: backend, stdio: "inherit", shell: runner === "tsx", env: { ...process.env, NODE_ENV: "test" } })
+ if (result.status !== 0) failed = 1
+}
+process.exit(failed)
diff --git a/backend/scripts/test-database-archive-leaf-tls.mjs b/backend/scripts/test-database-archive-leaf-tls.mjs
new file mode 100644
index 00000000..54aee9df
--- /dev/null
+++ b/backend/scripts/test-database-archive-leaf-tls.mjs
@@ -0,0 +1,399 @@
+import assert from 'node:assert/strict'
+import {execFile} from 'node:child_process'
+import {createHash, generateKeyPairSync, randomBytes, randomUUID, X509Certificate} from 'node:crypto'
+import {chmod, copyFile, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, unlink, writeFile} from 'node:fs/promises'
+import {createServer} from 'node:net'
+import {tmpdir} from 'node:os'
+import {basename, dirname, join} from 'node:path'
+import {promisify} from 'node:util'
+
+const mode = process.argv[2]
+assert(process.argv.length === 3 && ['--openssl-only', '--owned-postgres', '--owned-legacy', '--owned-legacy-custody', '--owned-legacy-custody-shape', '--owned-legacy-0037-handoff', '--owned-legacy-handoff-inspect', '--owned-legacy-handoff-intent', '--owned-legacy-cold-verify', '--owned-legacy-handoff-execute','--owned-legacy-handoff-adopt','--owned-legacy-handoff-release','--owned-legacy-handoff-tail','--owned-source58-foundation','--owned-source57-admission','--owned-source57-publication','--owned-source58-restore-enrollment','--owned-source58-publication'].includes(mode))
+const openssl = process.env.MMAPP_TLS_FIXTURE_OPENSSL || 'openssl'
+const clientBinary = name => process.env.MMAPP_PG_CLIENT_BIN
+ ? join(process.env.MMAPP_PG_CLIENT_BIN, name + (process.platform === 'win32' ? '.exe' : '')) : name
+const run = promisify(execFile)
+const temporary = await realpath(tmpdir())
+const directory = await realpath(await mkdtemp(join(temporary, 'mm-archive-leaf-tls-')))
+const execute = (command, args, options = {}) => run(command, args, {
+ cwd: directory, timeout: 15000, maxBuffer: 1024 * 1024, windowsHide: true, ...options,
+})
+const certificate = name => join(directory, `${name}.pem`)
+const key = name => join(directory, `${name}.key`)
+const host = 'localhost'
+const leafExtensions = ['basicConstraints=critical,CA:FALSE', 'keyUsage=critical,digitalSignature,keyEncipherment',
+ 'extendedKeyUsage=serverAuth', 'subjectAltName=DNS:localhost']
+const request = name => ['req', '-new', '-newkey', 'rsa:2048', '-nodes', '-subj',
+ `/CN=${name === 'delegated' ? 'Owned delegated fixture' : host}`, '-keyout', key(name)]
+
+async function issueCertificates() {
+ await execute(openssl, [...request('pinned'), '-x509', '-days', '2', '-out', certificate('pinned'),
+ ...leafExtensions.flatMap(extension => ['-addext', extension])])
+ await execute(openssl, ['req', '-new', '-x509', '-newkey', 'rsa:2048', '-nodes', '-subj', '/CN=Owned fixture CA',
+ '-keyout', key('ca'), '-out', certificate('ca'), '-days', '2', '-addext', 'basicConstraints=critical,CA:TRUE',
+ '-addext', 'keyUsage=critical,keyCertSign,cRLSign'])
+ const extensions = join(directory, 'leaf.cnf')
+ await writeFile(extensions, leafExtensions.join('\n') + '\n', {flag:'wx'})
+ for (const [name, issuer] of [['substitute', 'ca'], ['delegated', 'pinned']]) {
+ const csr = join(directory, `${name}.csr`)
+ await execute(openssl, [...request(name), '-out', csr])
+ await execute(openssl, ['x509', '-req', '-in', csr, '-CA', certificate(issuer), '-CAkey', key(issuer), '-set_serial', '3',
+ '-days', '2', '-extfile', extensions, '-out', certificate(name)])
+ }
+ const [pinned, substitute, delegated] = await Promise.all(['pinned', 'substitute', 'delegated'].map(async name => new X509Certificate(await readFile(certificate(name)))))
+ const spki = cert => createHash('sha256').update(cert.publicKey.export({type:'spki', format:'der'})).digest('hex')
+ assert.equal(pinned.ca, false)
+ assert.equal(pinned.subject, pinned.issuer)
+ assert(pinned.verify(pinned.publicKey))
+ assert(delegated.verify(pinned.publicKey))
+ assert.equal(new Set([spki(pinned), spki(substitute), spki(delegated)]).size, 3)
+ const verify = (trust, name) => execute(openssl, ['verify', '-purpose', 'sslserver', '-verify_hostname', host,
+ '-no-CApath', '-no-CAstore', '-CAfile', certificate(trust), certificate(name)])
+ await verify('pinned', 'pinned')
+ await verify('ca', 'substitute')
+ await assert.rejects(verify('pinned', 'substitute'), {stderr: /unable to get local issuer certificate/i})
+ await assert.rejects(verify('pinned', 'delegated'), {stderr: /invalid CA certificate|key usage does not include certificate signing/i})
+}
+
+async function verifyLegacyExport(pg, options, leafBytes, client) {
+ const holder = new pg.Client(options)
+ const {port,database} = options
+ const hash = value => createHash('sha256').update(value).digest('hex')
+ const pinned = new X509Certificate(leafBytes)
+ const custody=mode==='--owned-legacy-custody'
+ if(custody)Object.assign(process.env,{DATABASE_URL:`postgres://${options.user}:${options.password}@127.0.0.1:${port}/${database}`,MCP_STATE_DIR:join(directory,'legacy-app-state'),AUTH_REQUIRED:'false'})
+ let app
+ await holder.connect()
+ try {
+ const {rows:[source]} = await holder.query(`SELECT d.oid::text AS "databaseOid", d.datname AS "databaseName",
+ (pg_catalog.pg_control_system()).system_identifier::text AS "systemIdentifier",
+ pg_catalog.current_setting('server_version_num')::int AS "serverVersionNum",false AS "inRecovery"
+ FROM pg_catalog.pg_database d WHERE d.datname=pg_catalog.current_database()`)
+ const [{createConnectedPublisher}, {poolOptions}, {MIGRATION_MANIFEST}, {captureLegacyProbeStorage, captureLegacyProbeLineage, LEGACY_PROBE_RELATIONS}] = await Promise.all([
+ import('./writer-profile/publisher.mjs'), import('./writer-profile/operator-contract.mjs'), import('../src/db/migration-manifest.ts'),
+ import('../src/services/server-probe-legacy-source-inventory.ts'),
+ ])
+ const fixtureSchema = `CREATE TABLE public.schema_migrations(id text PRIMARY KEY);
+ CREATE TABLE public.mcp_plans(id uuid PRIMARY KEY, connection_id uuid, operation_id text, operation_version integer, state text, approved_by text, evidence jsonb);
+ CREATE TABLE public.mcp_connections(id uuid PRIMARY KEY, owner_id text);
+ CREATE TABLE public.mcp_operations(id uuid PRIMARY KEY, plan_id uuid, connection_id uuid, state text);
+ CREATE TABLE public.mcp_operation_steps(operation_id uuid, step_index integer, state text, intended_state jsonb);
+ CREATE TABLE public.mcp_owner_revocations(owner_id text PRIMARY KEY, invalid_before timestamptz);
+ CREATE TABLE public.mcp_credentials(id uuid PRIMARY KEY)`
+ const diagnosticDdl = await Promise.all(MIGRATION_MANIFEST.slice(34,36).map(pin => readFile(new URL(`../drizzle/${pin.file}`, import.meta.url), 'utf8')))
+ const historicalMarkers = MIGRATION_MANIFEST.slice(0,34).map(pin => pin.file.slice(0,-4))
+ const prepareLegacy = async sql => {
+ await sql.query(fixtureSchema)
+ await sql.query('INSERT INTO public.schema_migrations SELECT unnest($1::text[])', [historicalMarkers])
+ for (const migration of diagnosticDdl) await sql.query(migration)
+ }
+ await prepareLegacy(holder)
+ if(mode==='--owned-legacy-custody-shape'){
+ const inspectShape=async()=>{
+ await holder.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ try { await captureLegacyProbeStorage(holder);return await captureLegacyProbeLineage(holder) }
+ finally { await holder.query('ROLLBACK') }
+ }
+ assert.equal((await inspectShape()).rowCount,0)
+ await holder.query('CREATE TABLE public.owned_inherited_mcp_operations() INHERITS (public.mcp_operations)')
+ await assert.rejects(inspectShape(),/Exact ordinary legacy custody tables required/)
+ return
+ }
+ // The raw archive also carries unresolved identities. No marker or proof is produced by export.
+ const anchor = randomUUID(), quarantine = randomUUID(), operation = randomUUID(), connection = randomUUID(), plan = randomUUID(), executionId = randomUUID()
+ const sourceRows = async sql => {
+ await sql.query("INSERT INTO public.mcp_operations VALUES($1,$2,$3,'applied')", [operation,plan,connection])
+ await sql.query("INSERT INTO public.mcp_connections VALUES($1,'owned-actor')", [connection])
+ await sql.query("INSERT INTO public.mcp_plans VALUES($1,$2,'servers.probes.run',1,'completed','owned-actor','{}')", [plan,connection])
+ await sql.query("INSERT INTO public.mcp_operation_steps VALUES($1,0,'intent','{}')", [operation])
+ }
+ await sourceRows(holder)
+ const issuedAt = Date.UTC(2000,0,1)-3600000, expiresAt = Date.UTC(2000,0,1), bindingProof='a'.repeat(64)
+ await holder.query(`INSERT INTO public.server_probe_executions(receipt_id,binding_proof,identity_kind,execution_id,actor_id,authentication,request_id,authority_issued_at,authority_expires_at,source_server_id,tool)
+ VALUES($1,$3,'rest',$2,'owned-actor','jwt','owned-request',$4,$5,1,'ping')`, [anchor,executionId,bindingProof,issuedAt,new Date(expiresAt)])
+ await holder.query("INSERT INTO public.server_probe_execution_stages(receipt_id,stage_index,kind,timeout_ms) VALUES($1,1,'native-ping',1000)", [anchor])
+ if(custody){
+ const {encryptSecret, fingerprint, privateSecretFingerprint}=await import('../src/modules/mcp/security.ts')
+ const context={identity:{kind:'rest',ownerId:'owned-actor',executionId,requestId:'owned-request',authentication:'jwt',issuedAt,expiresAt},sourceServerId:1,tool:'ping'}
+ const receipt={receiptId:anchor,tool:'ping',serverId:1,state:'completed',httpStatus:200,output:'owned historical receipt',data:{kind:'ping'},attemptedStages:1,completedStages:1,automaticReplay:false,forwardingVerified:false}
+ const plaintext=JSON.stringify({version:1,context,bindingProof,receipt})
+ await holder.query("UPDATE public.server_probe_execution_stages SET state='received',outcome='received',received_at=clock_timestamp() WHERE receipt_id=$1", [anchor])
+ await holder.query(`UPDATE public.server_probe_executions SET state='completed',attempted_stages=1,completed_stages=1,finished_at=clock_timestamp(),receipt_ciphertext=$2,receipt_proof=$3 WHERE receipt_id=$1`,
+ [anchor,await encryptSecret(plaintext),await privateSecretFingerprint(fingerprint(plaintext),'server-probe-journal-v1:receipt')])
+ }
+ await holder.query(`INSERT INTO public.server_probe_execution_quarantines(receipt_id,binding_proof,identity_kind,execution_id,identity_proof,error_code,attempted_stages,completed_stages)
+ VALUES($1,repeat('b',64),'rest',$2,repeat('c',64),'JOURNAL_UNKNOWN',0,0)`, [quarantine, randomUUID()])
+ await holder.query("INSERT INTO public.mcp_diagnostic_cancellations(operation_id,connection_id,actor_id) VALUES($1,$2,'owned-actor')", [operation, connection])
+ const publisherPassword = randomBytes(24).toString('hex'), publisher = 'archive_legacy_publisher'
+ const roleNames = {publisher,runtime:'archive_legacy_runtime',capture:'archive_legacy_capture',operator:'archive_legacy_operator',control:'archive_legacy_control'}
+ await holder.query(`CREATE ROLE ${publisher} LOGIN PASSWORD '${publisherPassword}';
+ ${Object.values(roleNames).filter(role => role !== publisher).map(role => `CREATE ROLE ${role} NOLOGIN`).join('; ')};
+ GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${publisher};
+ GRANT SELECT ON public.schema_migrations, ${LEGACY_PROBE_RELATIONS.map(name => `public.${name}`).join(', ')} TO ${publisher}`)
+ const {rows:roleRows} = await holder.query('SELECT rolname AS name, oid::text AS "signedOid" FROM pg_catalog.pg_roles WHERE rolname=ANY($1)', [Object.values(roleNames)])
+ const roles = Object.fromEntries(Object.entries(roleNames).map(([scope,name])=>[scope,roleRows.find(row=>row.name===name)]))
+ const tls = {serverName:host,caSha256:hash(leafBytes),spkiSha256:hash(pinned.publicKey.export({format:'der', type:'spki'}))}
+ const transport = {host,port,user:publisher,password:publisherPassword,database}
+ const installation = {roleBindings:roles,expectedSource:source,tls}
+ const [{createBootstrapMaterial}, {provisionDatabaseSourceBindingOffline}, {sourceBindingBytes, readDatabaseSourceBindingRegistry}, {verifyLegacyProbeArchiveApproval}] = await Promise.all([
+ import('./database-writer-bootstrap-operator.mjs'), import('./database-source-binding-operator.ts'),
+ import('../src/db/database-source-binding.ts'), import('../src/services/server-probe-legacy-archive-approval.ts'),
+ ])
+ const fixtureFile = async (name, bytes) => { const file=join(directory,name); await writeFile(file,bytes,{flag:'wx',mode:0o600});return file }
+ const keyFile = await fixtureFile('legacy-source-signer.pem',generateKeyPairSync('ed25519').privateKey.export({type:'pkcs8',format:'pem'}))
+ const installationId = randomUUID(), sourceIdentityId = randomUUID(), generation = randomUUID()
+ const registryDirectory = join(directory,'legacy-registry')
+ const {deploymentPin} = await provisionDatabaseSourceBindingOffline({privateKeyFile:keyFile,outputDirectory:registryDirectory,
+ request:{installationId,sourceIdentityId,generation,source:{...source,databaseOid:Number(source.databaseOid),sessionUser:publisher,currentUser:publisher}}})
+ const boot = {format:'application-writer-bootstrap-request-v1',installationId,sourceHeadSha256:deploymentPin.currentHeadSha256,source,roles,tls}
+ const bootstrap = sourceBindingBytes(createBootstrapMaterial(boot,hash(sourceBindingBytes(boot))).bootstrap)
+ const wire = sourceBindingBytes(transport), activationDirectory=join(directory,'legacy-activation'), archiveDirectory=join(directory,'legacy-export')
+ const registry = await readDatabaseSourceBindingRegistry(deploymentPin)
+ const activation = sourceBindingBytes({format:'database-source-activation-v1',activationDirectory,installationId,sourceIdentityId,status:'active',
+ publicKeySpkiSha256:deploymentPin.publicKeySpkiSha256,generations:[{generation,headSha256:registry.headSha256,bindingSha256:registry.head.bindingSha256,tlsSpkiSha256:tls.spkiSha256}]})
+ await mkdir(activationDirectory,{mode:0o700});await mkdir(archiveDirectory,{mode:0o700})
+ await fixtureFile('legacy-activation/source-activation.json',activation)
+ const argv=[custody?'legacy-custody':'legacy-export','--bootstrap',await fixtureFile('legacy-bootstrap.json',bootstrap),'--bootstrap-sha256',hash(bootstrap),
+ '--transport',await fixtureFile('legacy-transport.json',wire),'--transport-sha256',hash(wire),'--ca',certificate('pinned'),
+ '--source-registry',registryDirectory,'--source-spki-sha256',deploymentPin.publicKeySpkiSha256,
+ '--activation-directory',activationDirectory,'--activation-sha256',hash(activation),'--archive-directory',archiveDirectory,'--source-signing-key', keyFile]
+ let modeledFiles
+ if(process.platform==='win32'){
+ const {mock}=await import('node:test'), filesUrl=new URL('./writer-profile/operator-files.mjs',import.meta.url)
+ const files=await import(filesUrl.href)
+ const protectedDirectory=async path=>{assert(path===directory||path.startsWith(directory+'\\'));assert.equal(await realpath(path),path)}
+ modeledFiles=mock.module(filesUrl,{namedExports:{...files,protectedDirectory,async readProtected(path,limit,pin){
+ await protectedDirectory(dirname(path));const bytes=await readFile(path);assert(bytes.length>0&&bytes.length<=limit);
+ if(pin!==undefined)assert.equal(hash(bytes),pin);return bytes
+ },writeFile,async withJournalLease(path,work){
+ await protectedDirectory(path);const lock=join(path,'publisher-lease.lock'),handle=await open(lock,'wx',0o600)
+ try{return await work()}finally{await handle.close();await unlink(lock)}
+ }}})
+ }
+ try {
+ const {main}=await import('./database-writer-profile-operator.mts')
+ if(custody){
+ await assert.rejects(main(argv),error=>error.cause?.code==='42501')
+ const lockedTables=['schema_migrations','mcp_plans','mcp_connections','mcp_operations','mcp_operation_steps',...LEGACY_PROBE_RELATIONS].map(name=>`public.${name}`).join(', ')
+ await holder.query(`GRANT SELECT, MAINTAIN ON TABLE ${lockedTables} TO ${publisher}`)
+ await holder.query('BEGIN')
+ try {
+ await holder.query("UPDATE public.mcp_operations SET state='failed' WHERE id=$1",[operation])
+ await assert.rejects(main(argv),error=>error.cause?.code==='55P03')
+ } finally { await holder.query('ROLLBACK') }
+ assert.deepEqual(await readdir(archiveDirectory),[])
+ }
+ const legacy=await main(argv)
+ assert.equal(legacy.event,custody?'database-legacy-custody':'database-legacy-export');assert.equal(legacy.conversionAllowed,false);assert.equal(legacy.readyAuthorized,false)
+ assert.equal(legacy.snapshot.rowCount,4);assert.equal(JSON.stringify(legacy).includes('owned-actor'),false)
+ assert.deepEqual((await readdir(archiveDirectory)).sort(),[legacy.approvalFile,legacy.dumpFile].sort())
+ const legacyFile=join(archiveDirectory,legacy.dumpFile),archive=await readFile(legacyFile)
+ const signedApproval=await readFile(join(archiveDirectory,legacy.approvalFile)),operatorPublicKeyPem=await readFile(join(registryDirectory,'operator-public.pem'))
+ const verified=await verifyLegacyProbeArchiveApproval(deploymentPin,{archive,signedApproval,operatorPublicKeyPem})
+ assert.equal(verified.storageSha256,legacy.snapshot.sha256);assert.equal(verified.archiveSha256,legacy.archiveSha256)
+ await assert.rejects(verifyLegacyProbeArchiveApproval(deploymentPin,{archive:Buffer.concat([archive,Buffer.from('tamper')]),signedApproval,operatorPublicKeyPem}))
+ await assert.rejects(main(argv),/Empty protected archive directory required/)
+ const {stdout:legacyToc} = await client('pg_restore',['--list',legacyFile],'pinned')
+ const entries = legacyToc.split(/\r?\n/).filter(line => line && !line.startsWith(';'))
+ assert.equal(entries.length,4)
+ assert.deepEqual(entries.map(line => line.match(/ TABLE DATA public (\S+) /)?.[1]).sort(), [...LEGACY_PROBE_RELATIONS].sort())
+ await holder.query('CREATE DATABASE archive_legacy_restored')
+ const restored = new pg.Client({...options,database:'archive_legacy_restored'})
+ await restored.connect()
+ try {
+ await prepareLegacy(restored)
+ await sourceRows(restored)
+ // A sterile verification target keeps the exact column shapes and
+ // foreign keys. Production lifecycle triggers have no role in this readback.
+ await restored.query(`DROP TRIGGER server_probe_execution_immutable ON public.server_probe_executions;
+ DROP TRIGGER server_probe_stage_immutable ON public.server_probe_execution_stages;
+ DROP TRIGGER server_probe_quarantine_immutable ON public.server_probe_execution_quarantines;
+ DROP TRIGGER mcp_diagnostic_cancellation_immutable ON public.mcp_diagnostic_cancellations`)
+ try {
+ await client('pg_restore',['--dbname=archive_legacy_restored','--data-only','--exit-on-error','--no-owner',legacyFile],'pinned')
+ } catch { throw Error('Legacy archive restore failed on the isolated verification database') }
+ await restored.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ assert.deepEqual(await captureLegacyProbeStorage(restored),legacy.snapshot)
+ await restored.query('ROLLBACK')
+ } finally { await restored.end() }
+ let checks=0
+ const legacyPool = new pg.Pool(poolOptions(transport, {roles,source,tls}, leafBytes))
+ const operator = createConnectedPublisher(installation, undefined, {async verify() {
+ if (++checks === 2) throw Error('owned terminal source refusal')
+ if(custody){
+ await holder.query("SET lock_timeout='200ms'")
+ try { await assert.rejects(holder.query("UPDATE public.mcp_operations SET state='failed' WHERE id=$1",[operation]),{code:'55P03'}) }
+ finally { await holder.query('RESET lock_timeout') }
+ }
+ return {platformProtectionVerified:true}
+ }})
+ try {
+ await assert.rejects(operator.inspectLegacyStorage(legacyPool,{deadlineAt:Date.now()+30000,archiveDirectory:directory,custody}),
+ error=>error.cause?.message==='owned terminal source refusal')
+ assert.equal(checks,2)
+ } finally { await legacyPool.end() }
+ if(custody){
+ app=await import('../src/db/index.ts')
+ const {inspectLegacyServerProbeSource}=await import('../src/services/server-probe-legacy-inspection.ts')
+ const now=Date.now(),actor={id:'owned-historical-settings-admin',email:'',name:'',apps:['mm'],permissions:['mm:settings:admin'],issuedAt:now-1000,expiresAt:now+60000}
+ const expectation={archive,signedApproval,operatorPublicKeyPem}
+ const inspect=evidence=>inspectLegacyServerProbeSource(actor,{deadlineAt:Date.now()+30000},undefined,evidence,deploymentPin)
+ const inspected=await inspect(expectation)
+ assert.equal(verified.format,'legacy-probe-custody-approval-v1');assert.equal(verified.lineageSha256,legacy.lineageSnapshot.sha256)
+ assert.equal(legacy.lineageSnapshot.rowCount,4);assert.deepEqual(inspected.lineageSnapshot,legacy.lineageSnapshot)
+ assert.equal(inspected.summary.counts.verified,1);assert.equal(inspected.summary.counts.unresolved,2)
+ assert.equal(inspected.summary.automaticReplay,false);assert.equal(inspected.conversionAllowed,false)
+ await holder.query("UPDATE public.mcp_operation_steps SET intended_state='{\"drift\":true}' WHERE operation_id=$1",[operation])
+ await assert.rejects(inspect(expectation),{code:'STATE_UNAVAILABLE'})
+ await holder.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ try { assert.deepEqual(await captureLegacyProbeStorage(holder),legacy.snapshot) }
+ finally { await holder.query('ROLLBACK') }
+ }
+ } finally { modeledFiles?.restore() }
+ } finally { await app?.pool.end();await holder.end() }
+}
+
+async function verifyOwnedPostgres() {
+ const [{default:EmbeddedPostgres}, {default:pg}] = await Promise.all([import('embedded-postgres'), import('pg')])
+ const listener = createServer()
+ await new Promise((resolve, reject) => listener.once('error', reject).listen(0, '127.0.0.1', resolve))
+ const port = listener.address().port
+ await new Promise((resolve, reject) => listener.close(error => error ? reject(error) : resolve()))
+ const user = 'archive_leaf_fixture', database = 'postgres', password = randomBytes(24).toString('hex')
+ const serverCertificate = certificate('server'), serverKey = key('server')
+ const postgres = new EmbeddedPostgres({databaseDir: join(directory, 'pg'), port, user, password, persistent:true,
+ createPostgresUser:false, initdbFlags:['--encoding=UTF8'], postgresFlags:['-h', '127.0.0.1', '-c', 'ssl=on',
+ '-c', `ssl_cert_file=${serverCertificate}`, '-c', `ssl_key_file=${serverKey}`], onLog:()=>{}, onError:()=>{}})
+ const childEnvironment = Object.fromEntries(['PATH', 'SystemRoot', 'WINDIR', 'TEMP', 'TMP'].filter(name => process.env[name])
+ .map(name => [name, process.env[name]]))
+ const serviceFiles = new Map()
+ for (const trust of ['pinned', 'ca']) {
+ const file = join(directory, `pg-service-${trust}.conf`)
+ await writeFile(file, `[owned_archive]\nhost=${host}\nhostaddr=127.0.0.1\nport=${port}\nuser=${user}\npassword=${password}\ndbname=${database}\nsslmode=verify-full\nsslrootcert=${certificate(trust)}\ngssencmode=disable\nconnect_timeout=5\n`,
+ {flag:'wx', mode:0o600})
+ serviceFiles.set(trust, file)
+ }
+ const client = (name, args, trust, options = {}) => execute(clientBinary(name), args, {
+ env:{...childEnvironment, PGSERVICE:'owned_archive', PGSERVICEFILE:serviceFiles.get(trust)}, ...options,
+ })
+ const check = trust => client('psql', ['--no-psqlrc', '--no-password', '--tuples-only', '--no-align', '--command',
+ 'SELECT ssl FROM pg_catalog.pg_stat_ssl WHERE pid=pg_catalog.pg_backend_pid()'], trust)
+ const dump = (trust, extra = []) => client('pg_dump', ['--no-password', '--format=custom', '--data-only', '--strict-names',
+ '--table=public.archive_probe', ...extra], trust, {encoding:'buffer'})
+ const badCertificate = async promise => assert.rejects(promise, error => /certificate verify failed|certificate verification failed/i.test(String(error.stderr)))
+ let started = false
+ async function startWith(name) {
+ await copyFile(certificate(name), serverCertificate)
+ await copyFile(key(name), serverKey)
+ await chmod(serverKey, 0o600)
+ await postgres.start()
+ started = true
+ }
+ async function stop() { await postgres.stop(); started = false }
+ try {
+ await postgres.initialise()
+ if(process.env.MMAPP_PG_CLIENT_BIN) process.env.PATH = process.env.MMAPP_PG_CLIENT_BIN + (process.platform === 'win32' ? ';' : ':') + process.env.PATH
+ await startWith('pinned')
+ assert.equal((await check('pinned')).stdout.trim(), 't')
+ const options = {host:'127.0.0.1', port, user, password, database, connectionTimeoutMillis:5000, statement_timeout:5000,
+ ssl:{ca:await readFile(certificate('pinned')), servername:host, rejectUnauthorized:true}}
+ if(['--owned-source58-foundation','--owned-source57-admission','--owned-source57-publication','--owned-source58-restore-enrollment','--owned-source58-publication'].includes(mode)){
+ const {verifyOwnedSource58Foundation}=await import('./source58-foundation-owned.mjs')
+ return await verifyOwnedSource58Foundation(pg,options,await readFile(certificate('pinned')),directory,
+ mode==='--owned-source58-publication'?'upgrade':mode==='--owned-source58-restore-enrollment'?'quarantine':
+ mode==='--owned-source57-publication'?'publication':mode==='--owned-source57-admission')
+ }
+ if(['--owned-legacy-0037-handoff','--owned-legacy-handoff-inspect','--owned-legacy-handoff-intent','--owned-legacy-cold-verify','--owned-legacy-handoff-execute','--owned-legacy-handoff-adopt','--owned-legacy-handoff-release','--owned-legacy-handoff-tail'].includes(mode)){
+ const {verifyOwnedLegacy0037Handoff}=await import('./legacy-probe-0037-owned.mjs')
+ return await verifyOwnedLegacy0037Handoff(pg,options,await readFile(certificate('pinned')),client,directory,
+ mode==='--owned-legacy-handoff-tail'?'tail':mode==='--owned-legacy-handoff-release'?'release':mode==='--owned-legacy-handoff-adopt'?'adopt':mode==='--owned-legacy-handoff-execute'?'execute':mode==='--owned-legacy-cold-verify'?'cold':mode==='--owned-legacy-handoff-intent'?'intent':mode==='--owned-legacy-handoff-inspect')
+ }
+ if (mode.startsWith('--owned-legacy')) return await verifyLegacyExport(pg, options, await readFile(certificate('pinned')), client)
+ const holder = new pg.Client(options), writer = new pg.Client(options)
+ let snapshot, productionPeer, archivePasswordFile, runPinnedDatabaseSnapshotDump
+ try {
+ await holder.connect()
+ await writer.connect()
+ await holder.query('CREATE TABLE public.archive_probe(id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY); INSERT INTO public.archive_probe DEFAULT VALUES')
+ await holder.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ snapshot = (await holder.query('SELECT pg_catalog.pg_export_snapshot() AS snapshot')).rows[0].snapshot
+ await writer.query('INSERT INTO public.archive_probe DEFAULT VALUES')
+ const {stdout:archive} = await dump('pinned', [`--snapshot=${snapshot}`])
+ assert.equal(archive.subarray(0, 5).toString(), 'PGDMP')
+ const file = join(directory, 'archive-probe.dump')
+ await writeFile(file, archive, {flag:'wx', mode:0o600})
+ const {stdout:decoded} = await client('pg_restore', ['--data-only', '--file=-', file], 'pinned')
+ assert.match(decoded.replaceAll('\r\n', '\n'), /COPY public\.archive_probe \(id\) FROM stdin;\n1\n\\\.\n/)
+ await holder.query('ROLLBACK')
+ const runtimePassword = randomBytes(24).toString('hex'), capturePassword = randomBytes(24).toString('hex')
+ archivePasswordFile = join(directory, 'archive-password')
+ await writeFile(archivePasswordFile, capturePassword, {flag:'wx',mode:0o600})
+ await holder.query(`CREATE ROLE archive_runtime LOGIN PASSWORD '${runtimePassword}'; CREATE ROLE archive_capture LOGIN PASSWORD '${capturePassword}';
+ REVOKE TEMP ON DATABASE postgres FROM PUBLIC; GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO archive_runtime;
+ GRANT SELECT ON TABLE public.archive_probe TO archive_runtime, archive_capture;
+ GRANT SELECT ON SEQUENCE public.archive_probe_id_seq TO archive_capture;
+ CREATE SCHEMA mmapp_control; CREATE TABLE mmapp_control.hidden_marker(value text)`)
+ const roles = Object.fromEntries((await holder.query(`SELECT CASE WHEN rolname='archive_runtime' THEN 'runtime' ELSE 'capture' END AS scope,
+ rolname AS name,oid::text AS "signedOid" FROM pg_catalog.pg_roles WHERE rolname IN ('archive_runtime','archive_capture')`))
+ .rows.map(({scope,...role})=>[scope,role]))
+ const {rows:[source]} = await holder.query(`SELECT d.oid::text AS "databaseOid", d.datname AS "databaseName",
+ (pg_catalog.pg_control_system()).system_identifier::text AS "systemIdentifier",
+ pg_catalog.current_setting('server_version_num')::int AS "serverVersionNum",false AS "inRecovery"
+ FROM pg_catalog.pg_database d WHERE d.datname=pg_catalog.current_database()`)
+ const hash = value => createHash('sha256').update(value).digest('hex')
+ const leafBytes = await readFile(certificate('pinned')), pinned = new X509Certificate(leafBytes)
+ const requestBytes = Buffer.from(JSON.stringify({format:'application-writer-bootstrap-request-v1',installationId:'92ae9f9b-b324-425f-9ed5-77be7c000947',
+ sourceHeadSha256:'f'.repeat(64),source,roles,tls:{serverName:host,caSha256:hash(leafBytes),
+ spkiSha256:hash(pinned.publicKey.export({format:'der', type:'spki'}))}}))
+ const requestFile = join(directory, 'runtime-request.json')
+ await writeFile(requestFile,requestBytes,{flag:'wx',mode:0o600})
+ Object.assign(process.env,{DATABASE_URL:`postgres://archive_runtime:${runtimePassword}@${host}:${port}/${database}`,
+ DATABASE_RUNTIME_REQUEST_FILE:requestFile,DATABASE_RUNTIME_REQUEST_SHA256:hash(requestBytes),DATABASE_RUNTIME_CA_FILE:certificate('pinned'),
+ MCP_STATE_DIR:join(directory,'state')})
+ const [{exportProtectedDatabaseSnapshot},{pool,readRuntimeDatabaseArchivePeer},{withSystemDatabaseOperationLock},dumpConnection] = await Promise.all([
+ import('../src/services/database-protected-archive.ts'), import('../src/db/index.ts'), import('../src/db/operation-lock.ts'), import('../src/services/database-dump-connection.ts'),
+ ])
+ runPinnedDatabaseSnapshotDump = dumpConnection.runPinnedDatabaseSnapshotDump
+ try {
+ const protectedArchive = await withSystemDatabaseOperationLock(()=>pool.connect(),async (runtime,discard)=>{
+ productionPeer=readRuntimeDatabaseArchivePeer(runtime)
+ return exportProtectedDatabaseSnapshot(runtime,discard,archivePasswordFile)
+ })
+ const actualArchive = join(directory,'protected.dump')
+ await writeFile(actualArchive,protectedArchive,{flag:'wx',mode:0o600})
+ const productionToc = (await client('pg_restore',['--list',actualArchive],'pinned')).stdout
+ assert.match(productionToc,/TABLE DATA public archive_probe /)
+ assert.match(productionToc,/SEQUENCE SET public archive_probe_id_seq /)
+ assert.doesNotMatch(productionToc,/mmapp_control|hidden_marker/)
+ } finally { await pool.end() }
+
+ } finally { await Promise.all([holder.end(), writer.end()]) }
+ await stop()
+ await startWith('substitute')
+ assert.equal((await check('ca')).stdout.trim(), 't')
+ assert.equal((await dump('ca')).stdout.subarray(0, 5).toString(), 'PGDMP')
+ await badCertificate(check('pinned'))
+ await badCertificate(dump('pinned'))
+ const assertPinnedDumpRefused = () => assert.rejects(runPinnedDatabaseSnapshotDump(productionPeer, archivePasswordFile, snapshot, {}),
+ error=>error.code==='DATABASE_DUMP_EXIT'&&error.diagnosticKinds.includes('tls'))
+ await assertPinnedDumpRefused()
+ await stop()
+ await startWith('delegated')
+ await badCertificate(check('pinned'))
+ await badCertificate(dump('pinned'))
+ await assertPinnedDumpRefused()
+ } finally { if (started) await stop() }
+}
+
+try {
+ await issueCertificates()
+ const result=mode==='--openssl-only'?undefined:await verifyOwnedPostgres()
+ console.log(JSON.stringify({mode, exactLeafAccepted:true, ordinaryCaSubstitutionRefused:true,
+ nonCaDelegationRefused:true, realSnapshotDump:mode === '--owned-postgres', protectedProductDump:mode === '--owned-postgres',
+ legacyArchiveRoundTrip:mode === '--owned-legacy'||mode === '--owned-legacy-custody',legacyCustodyLockedAndVerified:mode === '--owned-legacy-custody',
+ inheritedCustodyTablesRefused:mode === '--owned-legacy-custody-shape',...result}))
+} finally {
+ assert.equal(dirname(directory), temporary)
+ assert(basename(directory).startsWith('mm-archive-leaf-tls-'))
+ await rm(directory, {recursive:true, force:true, maxRetries:10, retryDelay:250})
+}
diff --git a/backend/scripts/test-database-source-binding.mjs b/backend/scripts/test-database-source-binding.mjs
new file mode 100644
index 00000000..6e3de3dd
--- /dev/null
+++ b/backend/scripts/test-database-source-binding.mjs
@@ -0,0 +1,17 @@
+// Synthetic signatures/files only. Deliberately discard configured DB URLs,
+// environment preload hooks and application secrets, including during SQL suites.
+import { spawn } from 'node:child_process'
+import { createRequire } from 'node:module'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+
+if (process.argv.length !== 2) throw Error('Source-binding synthetic runner takes no arguments')
+const require = createRequire(import.meta.url)
+const env = Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'LANG', 'LC_ALL']
+ .filter(key => typeof process.env[key] === 'string').map(key => [key, process.env[key]]))
+const child = spawn(process.execPath, ['--import', pathToFileURL(require.resolve('tsx')).href, '--test',
+ fileURLToPath(new URL('../src/db/database-source-binding.test.ts', import.meta.url))], {
+ cwd: new URL('../', import.meta.url), env: { ...env, MMAPP_OWN_SOURCE_BINDING_SYNTHETIC: 'true' },
+ windowsHide: true, stdio: 'inherit',
+})
+child.once('error', () => { console.error('Source-binding synthetic child could not start'); process.exitCode = 1 })
+child.once('exit', code => { process.exitCode = code ?? 1 })
diff --git a/backend/scripts/test-database-writer-retained-tls.mjs b/backend/scripts/test-database-writer-retained-tls.mjs
new file mode 100644
index 00000000..2402f71b
--- /dev/null
+++ b/backend/scripts/test-database-writer-retained-tls.mjs
@@ -0,0 +1,549 @@
+import assert from 'node:assert/strict'
+import {execFile, execFileSync} from 'node:child_process'
+import {randomBytes, randomUUID, X509Certificate} from 'node:crypto'
+import {setDefaultResultOrder} from 'node:dns'
+import {mkdtemp, mkdir, cp, readFile, writeFile, rename, rm, chmod, access} from 'node:fs/promises'
+import {createServer} from 'node:net'
+import {tmpdir} from 'node:os'
+import {dirname, join, resolve} from 'node:path'
+import {fileURLToPath} from 'node:url'
+import {promisify} from 'node:util'
+import EmbeddedPostgres from 'embedded-postgres'
+import pg from 'pg'
+import {tsImport} from 'tsx/esm/api'
+import {poolOptions, retainPublisherTlsPeer} from './writer-profile/operator-contract.mjs'
+import {sha} from './writer-profile/operator-files.mjs'
+
+const openssl = process.env.MMAPP_TLS_FIXTURE_OPENSSL || 'openssl'
+const activationOnly = process.argv.includes('--activation-only')
+const schemaOnly = process.argv.includes('--schema-only')
+const runtimeRoleOnly = process.argv.includes('--runtime-role-only')
+const registryOnly = process.argv.includes('--registry-only')
+const run = promisify(execFile)
+setDefaultResultOrder('ipv4first')
+const host = 'localhost'
+const reservePort = async () => {
+ const listener = createServer()
+ await new Promise((ready, reject) => listener.once('error', reject).listen(0, '127.0.0.1', ready))
+ return listener
+}
+const releasePort = listener => new Promise((ready, reject) => listener.close(error => error ? reject(error) : ready()))
+const sourcePort = await reservePort()
+const clonePort = await reservePort()
+const port = sourcePort.address().port, clonePortNumber = clonePort.address().port
+await Promise.all([releasePort(sourcePort), releasePort(clonePort)])
+const transport = {host, port, user: 'mcp_test', password: randomBytes(24).toString('hex'), database: 'postgres'}
+const runtime = 'tls_fixture_runtime', runtimePassword = randomBytes(24).toString('hex')
+const runtimeUrl = targetPort => `postgresql://${runtime}:${runtimePassword}@${host}:${targetPort}/${transport.database}`
+const runtimeRefused = {code: 'DATABASE_RUNTIME_SOURCE_REFUSED'}
+const certFile = 'server.pem', keyFile = 'server-key.pem'
+const root = await mkdtemp(join(tmpdir(), 'mm-writer-tls-owned-'))
+const databaseDir = join(root, 'pg'), cloneDir = join(root, 'pg-clone')
+const sourceTlsDir = join(root, 'source-tls'), cloneTlsDir = join(root, 'clone-tls')
+const postgresLog = []
+const cluster = (databaseDir, port, tlsDir) => new EmbeddedPostgres({databaseDir, port, user: transport.user, password: transport.password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'],
+ postgresFlags: ['-h', '127.0.0.1', '-c', 'ssl=on', '-c', `ssl_cert_file=${join(tlsDir, certFile)}`, '-c', `ssl_key_file=${join(tlsDir, keyFile)}`, '-c', 'log_line_prefix=[%u] '],
+ onLog: message => { postgresLog.push(message) }, onError: () => {}})
+const postgres = cluster(databaseDir, port, sourceTlsDir), clone = cluster(cloneDir, clonePortNumber, cloneTlsDir)
+let sourceStarted = false, cloneStarted = false
+const fingerprint = ca => sha(new X509Certificate(ca).publicKey.export({format:'der', type:'spki'}))
+const issue = async tlsDir => {
+ await mkdir(tlsDir, {mode:0o700})
+ execFileSync(openssl, ['req', '-new', '-newkey', 'rsa:2048', '-x509', '-nodes', '-days', '1', '-subj', '/CN=localhost',
+ '-addext', 'subjectAltName=DNS:localhost', '-keyout', keyFile, '-out', certFile], {cwd: tlsDir, stdio: 'ignore', windowsHide: true})
+ await chmod(join(tlsDir, keyFile), 0o600)
+ return readFile(join(tlsDir, certFile))
+}
+const withClient = async (config, work) => {
+ const pool = new pg.Pool({connectionTimeoutMillis:5000, ...config})
+ let client
+ try { client = await pool.connect(); return await work(client) }
+ finally { client?.release(true); await pool.end() }
+}
+const query = "SELECT (pg_control_system()).system_identifier::text AS system, oid::text AS oid FROM pg_database WHERE datname=current_database()"
+const createRuntime = async client => {
+ await client.query(`CREATE ROLE ${runtime} LOGIN PASSWORD '${runtimePassword}'; GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${runtime}`)
+ const {rows: [{oid}]} = await client.query('SELECT oid::text FROM pg_catalog.pg_roles WHERE rolname=$1', [runtime])
+ return oid
+}
+const runtimeFiles = async (request, ca, targetPort = port) => {
+ const requestFile = join(root, 'runtime-request.json'), caFile = join(root, 'runtime-ca.pem')
+ const bytes = Buffer.from(JSON.stringify(request))
+ await Promise.all([writeFile(requestFile, bytes), writeFile(caFile, ca)])
+ return {databaseUrl: runtimeUrl(targetPort), requestFile, requestSha256: sha(bytes), caFile}
+}
+const unexpectedConnection = () => assert.fail('Unverified runtime connection became available to application SQL')
+
+async function verifyRegistryEnrollment(owner, runtimeRequest, ca) {
+ const {mock} = await import('node:test')
+ const filesUrl = new URL('./writer-profile/operator-files.mjs', import.meta.url)
+ const files = await import(filesUrl.href)
+ const {MIGRATION_MANIFEST, migrationManifestDigest} = await tsImport('../src/db/migration-manifest.ts', import.meta.url)
+ const {FIXED56_ROLE_TEMPLATE} = await tsImport('./writer-profile/fixed56-build-definition.ts', import.meta.url)
+ const operator = runtimeRequest.roles.operator.name, capture = runtimeRequest.roles.capture.name
+ const publisher = runtimeRequest.roles.publisher.name, control = runtimeRequest.roles.control.name
+ const password = randomBytes(24).toString('hex')
+ const guard = name => FIXED56_ROLE_TEMPLATE.functions.find(row => row.namespace === 'mmapp_control' && row.proname === name).definition
+ await owner.query(`CREATE ROLE ${operator} LOGIN; CREATE ROLE ${capture} LOGIN; CREATE ROLE ${publisher} LOGIN;
+ CREATE ROLE ${control} LOGIN PASSWORD '${password}'; ALTER SCHEMA mmapp_control OWNER TO ${control};
+ REVOKE ALL ON SCHEMA mmapp_control FROM PUBLIC;
+ GRANT USAGE ON SCHEMA mmapp_control TO ${operator}, ${publisher};
+ CREATE TABLE public.schema_migrations (id text PRIMARY KEY);
+ GRANT SELECT ON TABLE public.schema_migrations TO ${control};
+ GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${operator}, ${publisher}, ${control};
+ ${guard('candidate_require_preadmission')}; ${guard('candidate_truncate_preadmitted')};
+ ALTER FUNCTION mmapp_control.candidate_require_preadmission() OWNER TO ${control};
+ ALTER FUNCTION mmapp_control.candidate_truncate_preadmitted() OWNER TO ${control};
+ REVOKE ALL ON FUNCTION mmapp_control.candidate_require_preadmission(), mmapp_control.candidate_truncate_preadmitted() FROM PUBLIC;
+ GRANT EXECUTE ON FUNCTION mmapp_control.candidate_truncate_preadmitted() TO ${operator}`)
+ await owner.query('INSERT INTO public.schema_migrations SELECT unnest($1::text[])', [MIGRATION_MANIFEST.map(pin => pin.file.slice(0, -4))])
+ const keys = Object.keys(runtimeRequest.roles)
+ const names = keys.map(key => runtimeRequest.roles[key].name)
+ const {rows} = await owner.query('SELECT rolname AS name, oid::text AS oid FROM pg_catalog.pg_roles WHERE rolname=ANY($1)', [names])
+ const roles = Object.fromEntries(keys.map((key, index) => [key, {name:names[index], signedOid:rows.find(row => row.name === names[index]).oid}]))
+ const manifestSha256 = migrationManifestDigest()
+ const bytes = new Map([
+ ['owned-approval', Buffer.from(JSON.stringify({format:'application-writer-registry-enrollment-v1', manifestSha256,
+ deploymentRequest:{...runtimeRequest, roles}}))],
+ ['owned-transport', Buffer.from(JSON.stringify({...transport, user:control, password}))],
+ ['owned-ca', ca],
+ ])
+ // Windows fixture supplies protected bytes. The real TLS, SQL and catalog verifier run unchanged.
+ const fileFixture = mock.module(filesUrl, {namedExports:{...files, async readProtected(name, max, expected) {
+ const value = bytes.get(name)
+ assert(value && value.length <= max && sha(value) === expected)
+ return value
+ }}})
+ try {
+ const {registryEnrollmentMain} = await import('./writer-profile/registry-enrollment.mts')
+ const args = ['registry-enroll', '--approval', 'owned-approval', '--approval-sha256', sha(bytes.get('owned-approval')),
+ '--transport', 'owned-transport', '--transport-sha256', sha(bytes.get('owned-transport')), '--ca', 'owned-ca']
+ const inspectArgs = ['registry-inspect', ...args.slice(1)]
+ const count = async () => (await owner.query(`SELECT count(*)::int AS n FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n
+ ON n.oid=c.relnamespace WHERE n.nspname='mmapp_control' AND c.relname IN ('application_writer_profile_history','application_writer_profile_current')`)).rows[0].n
+ assert.equal((await registryEnrollmentMain(inspectArgs)).outcome, 'absent')
+ assert.equal(await count(), 0)
+ await owner.query('CREATE TABLE mmapp_control.application_writer_profile_history (id int)')
+ try { await assert.rejects(registryEnrollmentMain(inspectArgs), /relations are incomplete/) }
+ finally { await owner.query('DROP TABLE mmapp_control.application_writer_profile_history') }
+ await owner.query(`GRANT pg_read_all_data TO ${runtime}`)
+ try {
+ await assert.rejects(registryEnrollmentMain(args), /Role ownership\/membership/)
+ assert.equal(await count(), 0)
+ } finally { await owner.query(`REVOKE pg_read_all_data FROM ${runtime}`) }
+ const report = await registryEnrollmentMain(args)
+ assert.equal(report.outcome, 'committed')
+ assert.equal(report.readyAuthorized, false)
+ assert.equal(report.cleanupUnconfirmed, false)
+ assert.equal(report.manifestSha256, manifestSha256)
+ assert.match(report.registryStructureSha256, /^[a-f0-9]{64}$/)
+ assert.equal(await count(), 2)
+ const observed = await registryEnrollmentMain(inspectArgs)
+ assert.equal(observed.outcome, 'installed')
+ assert.equal(observed.registryStructureSha256, report.registryStructureSha256)
+ await owner.query(`GRANT UPDATE ON mmapp_control.application_writer_profile_history TO ${runtime}`)
+ try { await assert.rejects(registryEnrollmentMain(inspectArgs), /effective grant boundary/) }
+ finally { await owner.query(`REVOKE UPDATE ON mmapp_control.application_writer_profile_history FROM ${runtime}`) }
+ await assert.rejects(registryEnrollmentMain(args), /Registry target\/owner\/absence refused/)
+ assert.equal(await count(), 2)
+ console.log('Owned registry enrollment and inspection: live TLS, strict catalog readback, rollback on role drift, ACL drift and repeat enrollment refused')
+ } finally { fileFixture.restore() }
+}
+
+async function verifyRuntimeRolePrivileges(owner, createPool) {
+ const settable = 'tls_fixture_settable'
+ await owner.query(`CREATE ROLE ${settable} NOLOGIN;
+ CREATE TABLE public.runtime_privilege_fixture (value int);
+ INSERT INTO public.runtime_privilege_fixture VALUES (1);
+ GRANT SELECT, UPDATE ON public.runtime_privilege_fixture TO ${runtime}`)
+ const withRuntime = async work => {
+ const fresh = createPool(1)
+ try { await work(fresh) } finally { await fresh.end() }
+ }
+ await withRuntime(async fresh => {
+ const {rows} = await fresh.query('UPDATE public.runtime_privilege_fixture SET value=2 RETURNING value')
+ assert.deepEqual(rows, [{value:2}])
+ })
+ for (const [grant, revoke] of [
+ [`GRANT pg_write_all_data TO ${runtime} WITH INHERIT TRUE, SET FALSE`, `REVOKE pg_write_all_data FROM ${runtime}`],
+ [`GRANT ${settable} TO ${runtime} WITH INHERIT FALSE, SET TRUE`, `REVOKE ${settable} FROM ${runtime}`],
+ [`GRANT ${runtime} TO ${settable}`, `REVOKE ${runtime} FROM ${settable}`],
+ [`GRANT TEMPORARY ON DATABASE postgres TO ${runtime}`, `REVOKE TEMPORARY ON DATABASE postgres FROM ${runtime}`],
+ [`GRANT CREATE ON SCHEMA mmapp_control TO ${runtime}`, `REVOKE CREATE ON SCHEMA mmapp_control FROM ${runtime}`],
+ [`GRANT SET ON PARAMETER session_replication_role TO ${runtime}`, `REVOKE SET ON PARAMETER session_replication_role FROM ${runtime}`],
+ [`ALTER TABLE public.runtime_privilege_fixture OWNER TO ${runtime}`,
+ `ALTER TABLE public.runtime_privilege_fixture OWNER TO ${transport.user};
+ GRANT SELECT, UPDATE ON public.runtime_privilege_fixture TO ${runtime}`],
+ ]) {
+ await owner.query(grant)
+ try {
+ await withRuntime(async fresh => assert.rejects(
+ fresh.query('UPDATE public.runtime_privilege_fixture SET value=3'), runtimeRefused, grant,
+ ))
+ assert.deepEqual((await owner.query('SELECT value FROM public.runtime_privilege_fixture')).rows, [{value:2}])
+ } finally { await owner.query(revoke) }
+ }
+ await withRuntime(async fresh => assert.deepEqual(
+ (await fresh.query('SELECT value FROM public.runtime_privilege_fixture')).rows, [{value:2}],
+ ))
+ await withRuntime(async retained => {
+ await retained.query('SELECT 1')
+ assert.equal(retained.idleCount, 1)
+ await owner.query(`GRANT ${settable} TO ${runtime}`)
+ try {
+ await assert.rejects(retained.query('UPDATE public.runtime_privilege_fixture SET value=3'), runtimeRefused)
+ assert.equal(retained.idleCount, 0)
+ } finally { await owner.query(`REVOKE ${settable} FROM ${runtime}`) }
+ await retained.query('SELECT 1')
+ assert.equal(retained.idleCount, 1)
+ await owner.query(`GRANT TEMPORARY ON DATABASE postgres TO ${runtime}`)
+ try {
+ await assert.rejects(retained.connect(), runtimeRefused)
+ assert.equal(retained.idleCount, 0)
+ } finally { await owner.query(`REVOKE TEMPORARY ON DATABASE postgres FROM ${runtime}`) }
+ assert.deepEqual((await retained.query('SELECT value FROM public.runtime_privilege_fixture')).rows, [{value:2}])
+ })
+ console.log('Runtime roles: direct DML accepted; unsafe privilege drift refused on fresh and retained TLS connections before application SQL')
+}
+
+async function verifyRuntimeActivation(createPool, ownerPool, request) {
+ const {sourceBindingBytes} = await tsImport('../src/db/database-source-binding.ts', import.meta.url)
+ const {DATABASE_SOURCE_ACTIVATION_FILENAME} = await tsImport('../src/db/database-source-activation-record.ts', import.meta.url)
+ const directory = join(root, 'activation')
+ const file = join(directory, DATABASE_SOURCE_ACTIVATION_FILENAME), pending = `${file}.pending`
+ const state = {
+ format: 'database-source-activation-v1', activationDirectory: directory, installationId: request.installationId,
+ sourceIdentityId: randomUUID(), publicKeySpkiSha256: 'c'.repeat(64), status: 'active',
+ generations: [{generation: randomUUID(), headSha256: request.sourceHeadSha256, bindingSha256: 'b'.repeat(64),
+ tlsSpkiSha256: request.tls.spkiSha256}],
+ }
+ const active = sourceBindingBytes(state)
+ const revoked = sourceBindingBytes({...state, status:'revoked'})
+ const publish = async bytes => {
+ await writeFile(pending, bytes, {flag:'wx', mode:0o600})
+ await rename(pending, file)
+ }
+ await mkdir(directory, {mode:0o700})
+ await publish(active)
+ await ownerPool.query(`CREATE SEQUENCE mmapp_control.activation_query; GRANT USAGE ON mmapp_control.activation_query TO ${runtime}`)
+ const blockedSql = "SELECT nextval('mmapp_control.activation_query')"
+ const pidSql = 'SELECT pg_backend_pid() AS pid'
+ const directoryKey = 'DATABASE_RUNTIME_ACTIVATION_DIRECTORY', digestKey = 'DATABASE_RUNTIME_ACTIVATION_SHA256'
+ const previousDirectory = process.env[directoryKey], previousDigest = process.env[digestKey]
+ process.env[directoryKey] = directory
+ process.env[digestKey] = sha(active)
+ let pool
+ try {
+ pool = createPool(1)
+ const {rows:[{pid}]} = await pool.query(pidSql)
+ const retained = await pool.connect()
+ let queued
+ try {
+ assert.equal((await retained.query(pidSql)).rows[0].pid, pid)
+ queued = assert.rejects(pool.connect().then(client => {
+ client.release()
+ unexpectedConnection()
+ }), runtimeRefused)
+ await writeFile(pending, revoked, {flag:'wx', mode:0o600})
+ } finally { retained.release() }
+ await queued
+ await assert.rejects(pool.query(blockedSql), runtimeRefused)
+ await rm(pending)
+ assert.equal((await pool.query(pidSql)).rowCount, 1)
+ assert.equal(pool.idleCount, 1)
+ await publish(revoked)
+ await assert.rejects(pool.query(blockedSql), runtimeRefused)
+ await assert.rejects(pool.connect().then(client => {
+ client.release()
+ unexpectedConnection()
+ }), runtimeRefused)
+ const refuseFresh = async expectedDigest => {
+ process.env[digestKey] = expectedDigest
+ await assert.rejects(async () => {
+ const fresh = createPool(1)
+ try { await fresh.query(blockedSql) }
+ finally { await fresh.end() }
+ }, runtimeRefused)
+ }
+ await refuseFresh(sha(revoked))
+ await publish(active)
+ await refuseFresh('0'.repeat(64))
+ assert.equal((await pool.query(pidSql)).rowCount, 1)
+ const [generation] = state.generations
+ const newHead = 'd'.repeat(64), newSpki = 'e'.repeat(64)
+ for (const wrongState of [
+ {...state, installationId:randomUUID()},
+ {...state, generations:[{...generation, headSha256:newHead}]},
+ {...state, generations:[{...generation, tlsSpkiSha256:newSpki}]},
+ {...state, generations:[generation, {...generation, generation:randomUUID(), headSha256:newHead, tlsSpkiSha256:newSpki}]},
+ ]) {
+ const wrong = sourceBindingBytes(wrongState)
+ await publish(wrong)
+ await refuseFresh(sha(wrong))
+ }
+ const {rows:[{is_called}]} = await ownerPool.query('SELECT is_called FROM mmapp_control.activation_query')
+ assert.equal(is_called, false, 'Refused application SQL reached PostgreSQL')
+ } finally {
+ if (previousDirectory === undefined) delete process.env[directoryKey]
+ else process.env[directoryKey] = previousDirectory
+ if (previousDigest === undefined) delete process.env[digestKey]
+ else process.env[digestKey] = previousDigest
+ await pool?.end()
+ }
+ console.log('Runtime activation: retained PostgreSQL client admitted under active pin; pending, revoked, digest and latest generation mismatches refused before application SQL')
+}
+
+async function verifyRestrictedStartup(ownerPool, validFiles) {
+ const sqlitePath = join(root, 'fixture.sqlite')
+ const runBackend = (args, env) => run(process.execPath, ['--import', import.meta.resolve('tsx'), ...args], {
+ cwd: root, timeout: 120_000, windowsHide: true, env: {
+ SystemRoot: process.env.SystemRoot, PATH: process.env.PATH, TEMP: process.env.TEMP, TMP: process.env.TMP,
+ NODE_ENV: 'test', DATABASE_PATH: sqlitePath, MCP_STATE_DIR: join(root, 'startup-state'), ...env,
+ },
+ })
+ const prepare = fileURLToPath(new URL('../src/scripts/prepare-database.ts', import.meta.url))
+ const ownerUrl = `postgresql://${transport.user}:${transport.password}@127.0.0.1:${transport.port}/${transport.database}`
+ await runBackend([prepare], {DATABASE_URL: ownerUrl})
+ await ownerPool.query(`REVOKE CREATE ON SCHEMA public FROM PUBLIC;
+ GRANT SELECT ON public.schema_migrations, public.traffic_settings, public.uptime_settings,
+ public.internet_path_settings, public.data_migration, public.servers TO ${runtime};
+ ALTER ROLE ${runtime} SET log_statement = 'all'`)
+ const {FIXED56_ROLE_TEMPLATE} = await tsImport('./writer-profile/fixed56-build-definition.ts', import.meta.url)
+ const guardFunction = name => FIXED56_ROLE_TEMPLATE.functions.find(row => row.namespace === 'mmapp_control' && row.proname === name)
+ const admissionGuard = guardFunction('candidate_require_preadmission')
+ const truncateGuard = guardFunction('candidate_truncate_preadmitted')
+ const operatorGuard = guardFunction('candidate_operator_ddl')
+ const trigger = FIXED56_ROLE_TEMPLATE.triggers.find(row => row.relname === 'mcp_operation_replay_tombstones' && row.tgname === 'candidate_truncate_preadmitted')
+ const eventTrigger = FIXED56_ROLE_TEMPLATE.events.find(row => row.evtname === 'candidate_operator_ddl')
+ assert.equal(trigger.tgenabled, 'A')
+ assert.equal(eventTrigger.evtenabled, 'O')
+ assert.equal(eventTrigger.evttags, null)
+ await ownerPool.query(`${admissionGuard.definition}; ${truncateGuard.definition}; ${trigger.definition};
+ ALTER TABLE public.mcp_operation_replay_tombstones ENABLE ALWAYS TRIGGER candidate_truncate_preadmitted;
+ ${operatorGuard.definition.replace('@mm-role:operator@', 'tls_operator')};
+ CREATE EVENT TRIGGER ${eventTrigger.evtname} ON ${eventTrigger.evtevent} EXECUTE FUNCTION ${eventTrigger.function};
+ REVOKE ALL ON FUNCTION mmapp_control.candidate_require_preadmission(), mmapp_control.candidate_truncate_preadmitted(),
+ mmapp_control.candidate_operator_ddl() FROM PUBLIC`)
+
+ const databaseModule = new URL('../src/db/index.ts', import.meta.url).href
+ const bootstrapModule = new URL('../src/db/bootstrap.ts', import.meta.url).href
+ const runtimeEnv = {
+ DATABASE_URL: validFiles.databaseUrl, DATABASE_RUNTIME_REQUEST_FILE: validFiles.requestFile,
+ DATABASE_RUNTIME_REQUEST_SHA256: validFiles.requestSha256, DATABASE_RUNTIME_CA_FILE: validFiles.caFile,
+ }
+ const schemaRefused = 'DATABASE_RUNTIME_SCHEMA_REFUSED'
+ const startup = async (expectedError, schemaSha256) => {
+ const start = postgresLog.length
+ await runBackend(['--input-type=module', '--eval', `
+ import assert from 'node:assert/strict';
+ import {closePool, pool} from ${JSON.stringify(databaseModule)};
+ import {initDatabase} from ${JSON.stringify(bootstrapModule)};
+ try {
+ const {rows: [role]} = await pool.query(\`SELECT session_user::text AS login,
+ current_user::text AS principal, has_schema_privilege('public', 'CREATE') AS create_schema,
+ has_database_privilege(current_database(), 'CREATE,TEMP') AS create_database\`);
+ assert.deepEqual(role, {login:${JSON.stringify(runtime)}, principal:${JSON.stringify(runtime)}, create_schema:false, create_database:false});
+ const expected = process.argv[1];
+ if (expected === ${JSON.stringify(schemaRefused)}) await assert.rejects(initDatabase(), {code: expected});
+ else if (expected) await assert.rejects(initDatabase(), new RegExp(expected));
+ else await initDatabase();
+ } finally { await closePool(); }
+ `, expectedError ?? ''], {
+ ...runtimeEnv,
+ ...(schemaSha256 === undefined ? {} : {DATABASE_RUNTIME_SCHEMA_SHA256: schemaSha256}),
+ })
+ const statements = postgresLog.slice(start).join('').split(new RegExp(`\\[${runtime}\\] (?:LOG: +(?:statement|execute [^:]+)|STATEMENT):`, 'g')).slice(1)
+ const readsMigrationHistory = statements.some(statement => /^\s*SELECT id FROM public\.schema_migrations\b/i.test(statement))
+ assert.equal(readsMigrationHistory, expectedError !== schemaRefused, 'Migration history must be read only after the schema guard passes')
+ if (schemaSha256 !== undefined) {
+ assert(statements.some(statement => /^\s*BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY\b/i.test(statement)))
+ assert(statements.some(statement => /^\s*\/\* migration-schema:columns \*\//i.test(statement)))
+ }
+ if (expectedError === schemaRefused) {
+ assert(!statements.some(statement => /\bFROM\s+(?:public\.)?(?:data_migration|servers|traffic_settings|uptime_settings|internet_path_settings)\b/i.test(statement)), 'Refused startup must stop before application reads')
+ }
+ assert(!statements.some(statement => /^\s*(CREATE|ALTER|DROP|INSERT|UPDATE|DELETE|TRUNCATE|COPY|CALL|DO)\b/i.test(statement)), 'PostgreSQL observed no runtime DDL or data writes during startup')
+ }
+
+ const {captureRuntimeDatabaseSchema} = await tsImport('../src/db/database-runtime-schema.ts', import.meta.url)
+ const {withSystemDatabaseOperationLock} = await tsImport('../src/db/operation-lock.ts', import.meta.url)
+ const capture = () => withSystemDatabaseOperationLock(() => ownerPool.connect(), captureRuntimeDatabaseSchema)
+ const baseline = await capture()
+ const {format, serverVersion, sha256} = baseline
+ const inspect = fileURLToPath(new URL('../src/scripts/inspect-database-schema.ts', import.meta.url))
+ const {stdout} = await runBackend([inspect], runtimeEnv)
+ assert.deepEqual(JSON.parse(stdout), {format, schemaSha256: sha256, serverVersion})
+ await startup(undefined, sha256)
+ const migrations = () => ownerPool.query('SELECT id, applied_at FROM public.schema_migrations ORDER BY id').then(result => result.rows)
+ const before = await migrations()
+ await ownerPool.query('ALTER TABLE public.traffic_settings ALTER COLUMN interval_sec SET DEFAULT 31')
+ await startup(schemaRefused, sha256)
+ assert.deepEqual(await migrations(), before)
+ const {rows: [{column_default}]} = await ownerPool.query(`SELECT column_default FROM information_schema.columns
+ WHERE table_schema = 'public' AND table_name = 'traffic_settings' AND column_name = 'interval_sec'`)
+ assert.equal(column_default, '31')
+ await ownerPool.query('ALTER TABLE public.traffic_settings ALTER COLUMN interval_sec SET DEFAULT 30')
+ console.log('Restricted application startup: accepted the operator schema digest over TLS and refused changed column default before application reads without runtime DDL or data writes')
+
+ const publicRows = ({sections}) => Object.values(sections).map(rows => rows.filter(row => row.namespace === 'public'))
+ const assertControlDrift = async () => {
+ const changed = await capture()
+ assert.notEqual(changed.sha256, sha256)
+ assert.deepEqual(publicRows(changed), publicRows(baseline))
+ await startup(schemaRefused, sha256)
+ assert.deepEqual(await migrations(), before)
+ }
+ const driftedBody = admissionGuard.definition.replace('pg_advisory_xact_lock_shared(8723110::bigint)', 'pg_advisory_xact_lock_shared(8723111::bigint)')
+ assert.notEqual(driftedBody, admissionGuard.definition)
+ await ownerPool.query(driftedBody)
+ await assertControlDrift()
+ await ownerPool.query(admissionGuard.definition)
+ await ownerPool.query(`GRANT EXECUTE ON FUNCTION mmapp_control.candidate_truncate_preadmitted() TO ${runtime}`)
+ await assertControlDrift()
+ await ownerPool.query(`REVOKE EXECUTE ON FUNCTION mmapp_control.candidate_truncate_preadmitted() FROM ${runtime}`)
+ await ownerPool.query(`ALTER EVENT TRIGGER ${eventTrigger.evtname} DISABLE`)
+ await assertControlDrift()
+ await ownerPool.query(`ALTER EVENT TRIGGER ${eventTrigger.evtname} ENABLE`)
+ await startup(undefined, sha256)
+ console.log('Restricted application startup: refused control guard body, ACL and event trigger state drift with the public catalog and migration markers intact')
+ await startup()
+ const currentPartition = `flow_buckets_d_${new Date().toISOString().slice(0, 10).replaceAll('-', '')}`
+ const expiredPartition = 'flow_buckets_d_20000101'
+ const partitionExists = async name => (await ownerPool.query('SELECT to_regclass($1) IS NOT NULL AS present', [`public.${name}`])).rows[0].present
+ await ownerPool.query(`DROP TABLE public.${currentPartition}; CREATE TABLE public.${expiredPartition}
+ PARTITION OF public.flow_buckets FOR VALUES FROM ('2000-01-01T00:00:00Z') TO ('2000-01-02T00:00:00Z')`)
+ await startup(`Required PostgreSQL partition ${currentPartition} is absent or incompatible`)
+ assert.equal(await partitionExists(currentPartition), false)
+
+ const {rows: [migration]} = await ownerPool.query('DELETE FROM public.schema_migrations WHERE id = (SELECT max(id) FROM public.schema_migrations) RETURNING id, applied_at')
+ await startup('Версия схемы PostgreSQL не совпадает')
+ const maintain = () => runBackend([prepare, '--partitions-only'], {DATABASE_URL: ownerUrl})
+ await assert.rejects(maintain(), /Версия схемы PostgreSQL не совпадает/)
+ assert.equal(await partitionExists(currentPartition), false)
+ assert.equal(await partitionExists(expiredPartition), true)
+ assert.equal((await ownerPool.query('SELECT id FROM public.schema_migrations WHERE id=$1', [migration.id])).rowCount, 0)
+ await ownerPool.query('INSERT INTO public.schema_migrations (id, applied_at) VALUES ($1, $2)', [migration.id, migration.applied_at])
+
+ await writeFile(sqlitePath, 'SQLite format 3\0')
+ await maintain()
+ assert.equal(await partitionExists(currentPartition), true)
+ assert.equal(await partitionExists(expiredPartition), false)
+ assert.deepEqual(await migrations(), before)
+ await startup('оператор должен завершить импорт SQLite')
+ await rm(sqlitePath)
+ await startup()
+ console.log('Operator partition maintenance: missing migration refused before partition DDL; missing and expired partitions handled without migrations or SQLite import')
+}
+
+try {
+ await postgres.initialise()
+ const first = await issue(sourceTlsDir)
+ await postgres.start(); sourceStarted = true
+ const pin = {serverName:host, caSha256:sha(first), spkiSha256:fingerprint(first)}
+ const request = {tls:pin, roles:{publisher:{name:transport.user}}, source:{databaseName:transport.database}}
+ const baseline = await withClient(poolOptions(transport, request, first), async client => {
+ const retained = retainPublisherTlsPeer(client, pin)
+ retained()
+ const {rows:[source]} = await client.query(query)
+ const {rows:[status]} = await client.query('SELECT ssl FROM pg_stat_ssl WHERE pid=pg_backend_pid()')
+ assert.equal(status.ssl, true)
+ await client.query(`CREATE SCHEMA mmapp_control; GRANT USAGE ON SCHEMA mmapp_control TO PUBLIC;
+ CREATE TABLE mmapp_control.notes (note text PRIMARY KEY); INSERT INTO mmapp_control.notes VALUES ('original')`)
+ await client.query('REVOKE CREATE, TEMP ON DATABASE postgres FROM PUBLIC; REVOKE EXECUTE ON FUNCTION pg_catalog.pg_control_system() FROM PUBLIC')
+ source.runtimeOid = await createRuntime(client)
+ const {rows: [{server_version_num}]} = await client.query('SHOW server_version_num')
+ source.serverVersionNum = Number(server_version_num)
+ const connection = client.connection, socket = connection.stream
+ connection.stream = undefined
+ try { assert.throws(retained, /retained TLS peer unavailable/) } finally { connection.stream = socket }
+ return source
+ })
+ await withClient({...transport, ssl:false}, async client => assert.throws(() => retainPublisherTlsPeer(client,pin), /retained TLS peer unavailable/))
+
+ const runtimeRequest = {
+ format: 'application-writer-bootstrap-request-v1', installationId: randomUUID(), sourceHeadSha256: 'a'.repeat(64),
+ source: {systemIdentifier: baseline.system, databaseOid: baseline.oid, databaseName: transport.database,
+ serverVersionNum: baseline.serverVersionNum, inRecovery: false},
+ roles: {runtime: {name: runtime, signedOid: baseline.runtimeOid}, operator: {name: 'tls_operator', signedOid: '30000'},
+ capture: {name: 'tls_capture', signedOid: '30001'}, publisher: {name: 'tls_publisher', signedOid: '30002'},
+ control: {name: 'tls_control', signedOid: '30003'}},
+ tls: pin,
+ }
+ const validFiles = await runtimeFiles(runtimeRequest, first)
+ Object.assign(process.env, {DATABASE_URL: validFiles.databaseUrl, DATABASE_RUNTIME_REQUEST_FILE: validFiles.requestFile,
+ DATABASE_RUNTIME_REQUEST_SHA256: validFiles.requestSha256, DATABASE_RUNTIME_CA_FILE: validFiles.caFile})
+ const {pool: appPool, createPool} = await tsImport('../src/db/index.ts', import.meta.url)
+ const {readRuntimeDatabasePoolOptions} = await tsImport('../src/db/database-runtime-source.ts', import.meta.url)
+ try {
+ const {rows: [identity]} = await appPool.query(`SELECT session_user::text AS login, current_user::text AS principal,
+ (SELECT ssl FROM pg_catalog.pg_stat_ssl WHERE pid=pg_backend_pid()) AS tls,
+ pg_catalog.has_database_privilege(current_database(), 'CREATE,TEMP') AS can_create_or_temp`)
+ assert.deepEqual(identity, {login: runtime, principal: runtime, tls: true, can_create_or_temp: false})
+ await assert.rejects(appPool.query('SELECT * FROM mmapp_control.notes'), {code: '42501'})
+ } finally { await appPool.end() }
+ const ownerPool = new pg.Pool(poolOptions(transport, request, first))
+ try {
+ if (registryOnly) await verifyRegistryEnrollment(ownerPool, runtimeRequest, first)
+ else {
+ if (!schemaOnly && !activationOnly) await verifyRuntimeRolePrivileges(ownerPool, createPool)
+ if (!schemaOnly && !runtimeRoleOnly) await verifyRuntimeActivation(createPool, ownerPool, runtimeRequest)
+ if (!activationOnly && !runtimeRoleOnly) await verifyRestrictedStartup(ownerPool, validFiles)
+ }
+ } finally { await ownerPool.end() }
+ if (!activationOnly && !schemaOnly && !runtimeRoleOnly && !registryOnly) {
+ assert.throws(() => readRuntimeDatabasePoolOptions({...validFiles, databaseUrl: `${validFiles.databaseUrl}?sslmode=disable`}), runtimeRefused)
+ assert.throws(() => readRuntimeDatabasePoolOptions({...validFiles, requestSha256: '0'.repeat(64)}), runtimeRefused)
+ await withClient(poolOptions(transport, request, first), client => client.query(`REVOKE EXECUTE ON FUNCTION pg_catalog.pg_control_system() FROM ${runtime}`))
+ await assert.rejects(withClient(readRuntimeDatabasePoolOptions(validFiles), unexpectedConnection), runtimeRefused)
+ await withClient(poolOptions(transport, request, first), client => client.query(`GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_system() TO ${runtime}`))
+ const wrongDb = await runtimeFiles({...runtimeRequest, source: {...runtimeRequest.source, databaseOid: String(Number(baseline.oid) + 1)}}, first)
+ await assert.rejects(withClient(readRuntimeDatabasePoolOptions(wrongDb), unexpectedConnection), runtimeRefused)
+ await runtimeFiles(runtimeRequest, first)
+ await postgres.stop(); sourceStarted = false
+ await cp(databaseDir, cloneDir, {recursive:true, force:false, errorOnExist:true})
+ await assert.rejects(access(join(cloneDir, keyFile)), {code:'ENOENT'})
+ const second = await issue(cloneTlsDir)
+ assert.notEqual(fingerprint(second), pin.spkiSha256)
+ await postgres.start(); sourceStarted = true
+ await clone.start(); cloneStarted = true
+ const cloneTransport = {...transport, port:clonePortNumber}
+ const bothTrusted = Buffer.concat([first,second])
+ await assert.rejects(withClient(poolOptions(cloneTransport, {...request,tls:{...pin,caSha256:sha(bothTrusted)}}, bothTrusted),
+ () => assert.fail('Wrong physical cluster must not reach application SQL')), /TLS SPKI refused/)
+ await withClient({...cloneTransport, ssl:{ca:bothTrusted, servername:host, rejectUnauthorized:true}}, async client => {
+ assert.equal(client.connection.stream.authorized, true)
+ const {rows:[source]} = await client.query(query)
+ assert.deepEqual(source, {system: baseline.system, oid: baseline.oid})
+ assert.throws(() => retainPublisherTlsPeer(client,pin), /TLS SPKI refused/)
+ retainPublisherTlsPeer(client,{...pin,spkiSha256:fingerprint(second)})()
+ assert.deepEqual((await client.query('SELECT note FROM mmapp_control.notes')).rows, [{note:'original'}])
+ await client.query("INSERT INTO mmapp_control.notes VALUES ('clone-only')")
+ })
+ const cloneFiles = await runtimeFiles({...runtimeRequest, tls: {...pin, caSha256: sha(bothTrusted)}}, bothTrusted, clonePortNumber)
+ await assert.rejects(withClient(readRuntimeDatabasePoolOptions(cloneFiles), unexpectedConnection), runtimeRefused)
+ await runtimeFiles(runtimeRequest, first)
+ await withClient(poolOptions(transport, request, first), async client => {
+ retainPublisherTlsPeer(client,pin)()
+ assert.deepEqual((await client.query('SELECT note FROM mmapp_control.notes')).rows, [{note:'original'}])
+ await client.query(`DROP OWNED BY ${runtime}; DROP ROLE ${runtime}`)
+ assert.notEqual(await createRuntime(client), baseline.runtimeOid)
+ })
+ const freshAppPool = createPool(1)
+ try { await assert.rejects(freshAppPool.query('SELECT 1'), runtimeRefused) }
+ finally { await freshAppPool.end() }
+ console.log('Genuine PostgreSQL TLS: original accepted; independently writable physical clone with identical DB coordinates and a different CA-valid TLS key refused')
+ console.log('Runtime pool: restricted login accepted; TLS override, incorrect request digest, missing observation grant, wrong database OID, clone key and recreated role refused')
+ }
+} finally {
+ const stops = await Promise.allSettled([
+ cloneStarted ? clone.stop() : undefined,
+ sourceStarted ? postgres.stop() : undefined,
+ ])
+ assert(stops.every(result => result.status === 'fulfilled'), 'Owned cluster stop unconfirmed')
+ assert.equal(dirname(resolve(root)), resolve(tmpdir()))
+ assert.match(root, /mm-writer-tls-owned-/)
+ await rm(root, {recursive:true, force:true, maxRetries:20, retryDelay:100})
+ await assert.rejects(access(root), {code:'ENOENT'})
+ console.log('Owned PostgreSQL and temporary TLS material removed')
+}
diff --git a/backend/scripts/test-flow-read-adapters.mjs b/backend/scripts/test-flow-read-adapters.mjs
new file mode 100644
index 00000000..a3206a16
--- /dev/null
+++ b/backend/scripts/test-flow-read-adapters.mjs
@@ -0,0 +1,93 @@
+import assert from 'node:assert/strict'
+import ts from 'typescript'
+import { readFileSync } from 'node:fs'
+import { createRequire } from 'node:module'
+import { resolve } from 'node:path'
+const require=createRequire(import.meta.url),zod=require('zod'),here=import.meta.dirname
+function evaluate(source,mocks={}){
+ // eslint-disable-next-line @next/next/no-assign-module-variable -- CommonJS wrapper emulation
+ const exports={},module={exports}
+ const code=ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText
+ new Function('require','exports','module',code)(id=>{if(id==='zod')return zod;if(Object.hasOwn(mocks,id))return mocks[id];throw Error('Unexpected dependency '+id)},exports,module)
+ return module.exports
+}
+const contracts=evaluate(readFileSync(resolve(here,'../../packages/contracts/src/traffic-flow.ts'),'utf8'))
+let quality=null,slotReleases=0
+const qualityHelper=evaluate(readFileSync(resolve(here,'../src/modules/mcp/flow-read-quality.ts'),'utf8'),{
+ '@mmapp/contracts/traffic-flow':contracts,'../../services/traffic-flow-ingest.js':{getFlowRuntimeCounters:async()=>({dataQuality:quality})},'./traffic-history-actions.js':{assertTrafficHistoryAccess:async()=>{}},
+})
+const server={id:1,name:'selected',type:'jump-host'},dto={bpsNow:0,bpsWire:0,bpsOverlay:0,bytesWire:0,live:false,rxSeries:[],txSeries:[],services:[]}
+const window={rows:[],topRowsPerBucketLimit:20,topConversationsLimit:20,since:'from',until:'to'}
+class McpError extends Error{constructor(code,message,statusCode){super(message);this.code=code;this.statusCode=statusCode}}
+const mocks={
+ './flow-read-quality.js':qualityHelper,
+ '@mmapp/contracts/traffic-flow':{...contracts,flowAnalyticsDtoSchema:{parse:x=>x},flowMapHopsDtoSchema:{parse:x=>x}},
+ '../../services/traffic-flow-analytics.js':{buildFlowAnalytics:async()=>dto,getFlowMonthly:async()=>({month:'2026-10',bytes:0,countries:[],services:[],asns:[]}),safeBuildLiveFlowSample:async()=>({event:'sample',data:dto}),LIVE_ANALYTICS_MINUTES:5},
+ '../../services/traffic-flow-map-hops.js':{buildFlowMapHops:async()=>({live:false,hops:[]})},
+ '../../services/traffic-flow-source-limits.js':{readFlowSourceLimits:async()=>({topN:20}),readFlowMapSourceLimits:async()=>({topN:20,mapServiceMinSharePct:5})},
+ '../servers/repository/servers-repository.js':{getServerRowById:async()=>server},
+ '../../services/traffic-flow-server-source.js':{getBoundedFlowServerRowById:async()=>server},
+ './flow-source-scope.js':{assertBoundedFlowSource:async()=>{},flowCatalogDevices:async()=>({selected:[server],incomplete:false})},
+ './traffic-history-actions.js':{assertTrafficHistoryAccess:async()=>{},assertTrafficHistorySource:async()=>{}},
+ './security.js':{McpError},'node:util':require('node:util'),'node:timers/promises':require('node:timers/promises'),
+ '../../services/traffic-flow-live-slots.js':{FLOW_LIVE_TICK_MS:2000,tryAcquireFlowLiveSlot:()=>true,releaseFlowLiveSlot:()=>slotReleases++},
+ '../../services/traffic-flow-settings.js':{getTrafficFlowSettingsRow:async()=>({topN:20})},
+ '../../services/traffic-flow-ifindex.js':{resolveIfaceName:()=>''},
+ '../../services/traffic-flow-talkers-model.js':{projectFlowTalkers:()=>({talkers:[],totalConversations:0})},
+ '../../services/traffic-flow-catalog-read.js':{readFlowCatalogWindow:async()=>window,readFlowExporterInputs:async()=>({window,catalog:{list:[server]},configuredIds:new Set([1]),configurationMembershipVerified:true}),readFlowClientInputs:async()=>({users:[],total:0,window}),observeFlowExporter:()=>({id:'1'}),observeFlowClient:()=>({})},
+ './catalog-scope.js':{catalogPaging:zod.z.object({offset:zod.z.number().default(0),limit:zod.z.number().default(50)}),catalogDevices:async()=>({selected:[server],incomplete:false})},
+}
+const actions=[]
+for(const [file,method] of [['flow-catalog-actions.ts','registerFlowCatalogActions'],['flow-analytics-actions.ts','registerFlowAnalyticsActions'],['flow-map-actions.ts','registerFlowMapActions'],['flow-live-actions.ts','registerFlowLiveActions']]){
+ const actionModule=evaluate(readFileSync(resolve(here,'../src/modules/mcp',file),'utf8'),mocks)
+ actionModule[method]((...args)=>actions.push({id:args[0],schema:args[7],read:args[8].read}))
+}
+assert.equal(actions.length,7)
+const base={version:1,collectorEpoch:'00000000-0000-4000-8000-000000000001',scope:'collector-global',exportCoverage:'unverified',localAdmission:'partial',records:'1',bytes:'10',packets:'1',knownLowerBounds:{records:'1',bytes:'10',packets:'1'},firstAt:'2026-10-29T00:00:00.000Z',lastAt:'2026-10-29T00:00:00.000Z',intervalUnknown:false,reasons:{'aggregate-capacity':true,'ring-capacity':false,'key-width':false,'unsafe-numeric':false},counterOverflow:false,rawRowsPolicy:'topN-and-pending-cap-not-complete',lifetimeScope:'current-collector-isolate'}
+const clean={...base,localAdmission:'no-local-loss-observed',records:'0',bytes:'0',packets:'0',knownLowerBounds:{records:'0',bytes:'0',packets:'0'},firstAt:null,lastAt:null,reasons:{'aggregate-capacity':false,'ring-capacity':false,'key-width':false,'unsafe-numeric':false}}
+const cases=[null,base,{...base,localAdmission:'loss-quantity-unknown',bytes:null},{...base,localAdmission:'no-local-loss-observed'},clean]
+let count=0
+for(const globalAllowed of [false,true])for(const state of cases){
+ quality=state
+ for(const action of actions){
+ const input=action.schema.parse(action.id==='traffic.flow.monthly.read'?{month:'2026-10'}:{serverId:1}),context={connection:{policy:{scope:{serverIds:[1],allowGlobal:globalAllowed,operationIds:globalAllowed?['netflow.settings.read']:[]}}}}
+ const output=await action.read(input,context),expected=contracts.flowIngestQualitySchema.safeParse(globalAllowed?state:null)
+ assert.deepEqual(output.dataQuality,expected.success?expected.data:null,action.id)
+ assert.equal(output.collectorQualityAvailable,expected.success,action.id)
+ assert.equal(output.collectorQualityScope,'current-collector-isolate',action.id)
+ assert.equal(output.incomplete,['traffic.flow.talkers.read','traffic.flow.analytics.read','traffic.flow.map.read','traffic.flow.live.read'].includes(action.id),action.id+' preserves original result completeness')
+ assert.equal(output.collectorObservationIncomplete,!expected.success||expected.data.localAdmission!=='no-local-loss-observed',action.id)
+ assert.equal(output.coverageVerified,false,action.id);assert.equal(output.exportCoverage,'unverified',action.id)
+ count++
+ }
+}
+assert.equal(slotReleases,10)
+console.log('PASS '+count+' actual registered MCP read adapter invocations: unavailable, partial, unknown quantities and invalid healthy claim; inert source/auth adapters; real semantic quality schema')
+
+let sourceChecks = 0, sourceChanged = false, legacy
+const { registerLegacyFlowAnalyticsAction } = evaluate(readFileSync(resolve(here, '../src/modules/mcp/flow-analytics-actions.ts'), 'utf8'), {
+ ...mocks,
+ './flow-source-scope.js': { async assertBoundedFlowSource(_context, selected) {
+ assert.equal(selected, server)
+ sourceChecks++
+ if (sourceChanged) throw new McpError('STATE_CONFLICT', 'Source changed', 409)
+ } },
+ '../../services/traffic-flow-analytics.js': { async buildFlowAnalytics(query, scope) {
+ assert.deepEqual(query, { serverId: 1, minutes: 15, iface: 'ether1', skipHeavy: true })
+ assert.deepEqual(scope.serverIds, [1])
+ assert.equal(scope.maxRows, 20000)
+ await scope.authorize()
+ return { ...dto, bytes: 42, sources: [{ id: '192.0.2.1', label: 'private label' }], destinations: [] }
+ } },
+})
+registerLegacyFlowAnalyticsAction((...args) => { legacy = args })
+assert.equal(legacy[1], 'mm_netflow_analytics_get')
+const legacyInput = legacy[7].parse({ serverId: 1, interface: 'ether1' })
+const legacyContext = { connection: { policy: { scope: { serverIds: [1] } } } }
+const legacyOutput = await legacy[8].read(legacyInput, legacyContext)
+assert.equal(legacyOutput.bytes, 42)
+assert.deepEqual(legacyOutput.sources, [{ id: '192.0.2.1', label: '192.0.2.1' }])
+assert.equal(sourceChecks, 1)
+sourceChanged = true
+await assert.rejects(legacy[8].read(legacyInput, legacyContext), { code: 'STATE_CONFLICT' })
+console.log('PASS legacy MCP NetFlow analytics uses scoped source admission and preserves the legacy projection')
diff --git a/backend/scripts/test-flow-read-http-owned.mjs b/backend/scripts/test-flow-read-http-owned.mjs
new file mode 100644
index 00000000..7bf639f1
--- /dev/null
+++ b/backend/scripts/test-flow-read-http-owned.mjs
@@ -0,0 +1,76 @@
+import EmbeddedPostgres from 'embedded-postgres'
+import { build, stop } from 'esbuild'
+import { mkdtemp, rm, readFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join, resolve, dirname } from 'node:path'
+import { createServer } from 'node:net'
+import { randomBytes } from 'node:crypto'
+import { spawn } from 'node:child_process'
+import assert from 'node:assert/strict'
+import { pathToFileURL } from 'node:url'
+
+if (process.argv.length !== 2) throw Error('Read HTTP acceptance requires its own disposable cluster and no arguments')
+const repo = resolve(import.meta.dirname, '../..')
+const directory = await mkdtemp(join(tmpdir(), 'mm-flow-http-owned-'))
+const bundleDirectory = await mkdtemp(join(repo, 'tmp', 'mm-flow-http-owned-bundle-'))
+const listener = createServer()
+await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve))
+const port = listener.address().port
+await new Promise(resolve => listener.close(resolve))
+const password = randomBytes(24).toString('hex')
+const postgres = new EmbeddedPostgres({
+ databaseDir: join(directory, 'pg'), port, user: 'mcp_test', password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'],
+ postgresFlags: ['-h', '127.0.0.1', '-c', 'work_mem=4MB'],
+ onLog: () => {}, onError: () => {},
+})
+let started = false
+let outcome = 1
+try {
+ const file = join(bundleDirectory, 'read-http-owned.mjs')
+ // Current application sources only: no candidate overlays or generated mocks.
+ await build({
+ entryPoints: [join(repo, 'backend/src/services/traffic-flow-read-http.owned.test.ts')],
+ outfile: file, platform: 'node', format: 'esm', bundle: true,
+ packages: 'external', sourcemap: 'inline',
+ banner: { js: "import {createRequire as __ownedCreateRequire} from 'node:module';const require=__ownedCreateRequire(import.meta.url);" },
+ plugins: [{ name: 'contracts-source', setup(builder) {
+ builder.onResolve({ filter: /^@mmapp\/contracts(?:\/.*)?$/ }, args => ({
+ path: resolve(repo, 'packages/contracts/src', args.path.replace(/^@mmapp\/contracts\/?/, '') || 'index') + '.ts',
+ }))
+ builder.onLoad({ filter: /\.ts$/ }, async args => ({
+ contents: (await readFile(args.path, 'utf8')).replaceAll('import.meta.url', JSON.stringify(pathToFileURL(args.path).href)),
+ loader: 'ts',
+ }))
+ } }],
+ })
+ await postgres.initialise()
+ await postgres.start()
+ started = true
+ const exit = await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, [file], {
+ cwd: directory, windowsHide: true, stdio: 'inherit',
+ env: { ...process.env,
+ DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,
+ DATABASE_PATH: join(directory, 'unused.sqlite'), MCP_STATE_DIR: join(directory, 'state'),
+ AUTH_REQUIRED: 'true', AUTH_ISSUER: 'https://auth.test.local',
+ AUTH_JWT_SECRET: 'owned-flow-http-only-secret', MCP_PUBLIC_URL: 'http://localhost:8000/mcp', NODE_ENV: 'test',
+ NODE_PATH: join(repo, 'node_modules'),
+ },
+ })
+ child.once('error', reject)
+ child.once('exit', resolve)
+ })
+ outcome = exit ?? 1
+} finally {
+ if (started) await postgres.stop()
+ assert.equal(dirname(resolve(directory)), resolve(tmpdir()))
+ assert.match(directory, /mm-flow-http-owned-/)
+ await rm(directory, { recursive: true, force: true, maxRetries: 20, retryDelay: 100 })
+ assert.equal(dirname(resolve(bundleDirectory)), resolve(repo, 'tmp'))
+ assert.match(bundleDirectory, /mm-flow-http-owned-bundle-/)
+ await rm(bundleDirectory, { recursive: true, force: true, maxRetries: 20, retryDelay: 100 })
+ stop()
+ console.log('Owned read HTTP cluster stopped and temporary resources removed')
+}
+process.exitCode = outcome
diff --git a/backend/scripts/test-flow-read-profile-startup.mjs b/backend/scripts/test-flow-read-profile-startup.mjs
new file mode 100644
index 00000000..50075de3
--- /dev/null
+++ b/backend/scripts/test-flow-read-profile-startup.mjs
@@ -0,0 +1,28 @@
+import{readFile,writeFile,mkdtemp,rm}from'node:fs/promises'
+import{resolve,join,dirname}from'node:path'
+import{spawn}from'node:child_process'
+import assert from'node:assert/strict'
+import ts from'typescript'
+import{build,stop}from'esbuild'
+const repo=resolve(import.meta.dirname,'../..'),folder=await mkdtemp(join(repo,'tmp','mm-flow-profile-startup-owned-'))
+async function run(file,cwd,explicit,expected){
+ const env={...process.env,NODE_ENV:'test',AUTH_REQUIRED:'false',DATABASE_URL:'postgresql://unused:unused@127.0.0.1:1/unused',EXPECT_PROFILE:expected};delete env.MM_FLOW_READ_RESOURCE_PROFILE;if(explicit!==undefined)env.MM_FLOW_READ_RESOURCE_PROFILE=explicit
+ return new Promise((resolve,reject)=>{let output='';const child=spawn(process.execPath,[file],{cwd,env,windowsHide:true,stdio:['ignore','pipe','pipe']});child.stdout.on('data',x=>output+=x);child.stderr.on('data',x=>output+=x);child.once('error',reject);child.once('exit',code=>resolve({code,output}))})
+}
+try{
+ const source=await readFile(resolve(repo,'backend/src/services/traffic-flow-read-resource-profile.ts'),'utf8'),js=ts.transpileModule(source,{compilerOptions:{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.ESNext}}).outputText
+ await writeFile(join(folder,'profile.mjs'),js);await writeFile(join(folder,'eager-negative.mjs'),js+'\ngetFlowReadResourceProfile();\n');await writeFile(join(folder,'load-env.mjs'),"import{config}from'dotenv';config({quiet:true});");await writeFile(join(folder,'.env'),'MM_FLOW_READ_RESOURCE_PROFILE=constrained\n')
+ for(const[profile,success]of[['profile.mjs',true],['eager-negative.mjs',false]]){
+ await writeFile(join(folder,'policy.mjs'),`import{getFlowReadResourceProfile}from'./${profile}';import'./load-env.mjs';export const policy=getFlowReadResourceProfile();`)
+ await writeFile(join(folder,'order.mjs'),"import assert from'node:assert/strict';import{policy}from'./policy.mjs';assert.equal(policy.name,'constrained');")
+ const result=await run(join(folder,'order.mjs'),folder,undefined,'constrained');if(success)assert.equal(result.code,0,result.output);else{assert.notEqual(result.code,0);assert.match(result.output,/standard/)}
+ }
+ const abs=path=>JSON.stringify(resolve(repo,path).replaceAll('\\','/'))
+ await writeFile(join(folder,'actual.ts'),`import{getFlowReadResourceProfile}from${abs('backend/src/services/traffic-flow-read-resource-profile.ts')};import{FLOW_READ_RESERVATION_BYTES}from${abs('backend/src/services/traffic-flow-read-policy.ts')};import{pool}from${abs('backend/src/db/index.ts')};import assert from'node:assert/strict';const p=getFlowReadResourceProfile();assert.equal(p.name,process.env.EXPECT_PROFILE);assert.equal(FLOW_READ_RESERVATION_BYTES,p.reservationBytes);assert.equal(p.parallelSql,8);process.env.MM_FLOW_READ_RESOURCE_PROFILE=p.name==='standard'?'constrained':'standard';assert.equal(getFlowReadResourceProfile().name,p.name);await pool.end();`)
+ await build({entryPoints:[join(folder,'actual.ts')],outfile:join(folder,'actual.mjs'),bundle:true,format:'esm',platform:'node',packages:'external'})
+ for(const[label,dotenv,explicit,expected]of[['standard','standard',undefined,'standard'],['dotenv-constrained','constrained',undefined,'constrained'],['explicit-standard','constrained','standard','standard'],['invalid','constrained','invalid','INVALID']]){
+ await writeFile(join(folder,'.env'),'MM_FLOW_READ_RESOURCE_PROFILE='+dotenv+'\n');const result=await run(join(folder,'actual.mjs'),folder,explicit,expected)
+ if(expected==='INVALID'){assert.notEqual(result.code,0);assert.match(result.output,/MM_FLOW_READ_RESOURCE_PROFILE must be/)}else assert.equal(result.code,0,label+':'+result.output)
+ }
+ console.log('PASS pure import order/.env actual policy/explicit override/invalid profile/immutable selection')
+}finally{stop();assert.equal(dirname(folder),resolve(repo,'tmp'));await rm(folder,{recursive:true,force:true,maxRetries:10,retryDelay:100})}
diff --git a/backend/scripts/test-flow-read-sql-owned.mts b/backend/scripts/test-flow-read-sql-owned.mts
new file mode 100644
index 00000000..1d53a5a0
--- /dev/null
+++ b/backend/scripts/test-flow-read-sql-owned.mts
@@ -0,0 +1,71 @@
+import assert from 'node:assert/strict'
+import EmbeddedPostgres from 'embedded-postgres'
+import pg from 'pg'
+import { mkdtemp, rm, readFile } from 'node:fs/promises'
+import ts from 'typescript'
+import { createRequire } from 'node:module'
+import { getTableColumns } from 'drizzle-orm'
+import { drizzle } from 'drizzle-orm/node-postgres'
+import { servers } from '../src/db/schema.js'
+import { tmpdir } from 'node:os'
+import { join, resolve, dirname } from 'node:path'
+import { createServer } from 'node:net'
+import { randomBytes } from 'node:crypto'
+import { readBoundedFlowSql } from '../src/services/traffic-flow-bounded-sql.js'
+
+if(process.argv.length!==2)throw Error('Read source acceptance requires its own disposable cluster and no arguments')
+const directory=await mkdtemp(join(tmpdir(),'mm-flow-read-owned-'))
+const listener=createServer();await new Promise(resolve=>listener.listen(0,'127.0.0.1',resolve))
+const address=listener.address();assert.ok(address&&typeof address!=='string');const port=address.port
+await new Promise(resolve=>listener.close(()=>resolve()))
+const password=randomBytes(24).toString('hex')
+const postgres=new EmbeddedPostgres({databaseDir:join(directory,'pg'),port,user:'mcp_test',password,persistent:true,createPostgresUser:false,initdbFlags:['--encoding=UTF8'],postgresFlags:['-h','127.0.0.1','-c','work_mem=4MB','-c','statement_timeout=10000'],onLog:()=>{},onError:()=>{}})
+let pool:pg.Pool|undefined,started=false
+try{
+ await postgres.initialise();await postgres.start();started=true
+ pool=new pg.Pool({host:'127.0.0.1',port,user:'mcp_test',password,database:'postgres',max:2})
+ const max={maxRows:3,maxEncodedBytes:1024}
+ const query='SELECT i AS id,$1::text AS text FROM generate_series(1,3) i ORDER BY i'
+ const normal=await pool.query(query,['я'])
+ assert.deepEqual(await readBoundedFlowSql(pool,query,['я'],max),normal.rows)
+ assert.deepEqual(await readBoundedFlowSql(pool,'SELECT 1 id WHERE false',[],max),[])
+ await assert.rejects(readBoundedFlowSql(pool,'SELECT i FROM generate_series(1,4) i',[],max),/превышает/)
+ await assert.rejects(readBoundedFlowSql(pool,'SELECT repeat(\'я\',10000) text',[],max),/превышает/)
+ await assert.rejects(readBoundedFlowSql(pool,'SELECT repeat(\'a\',600) text FROM generate_series(1,2)',[],max),/превышает/)
+ const large='SELECT 9223372036854775807::bigint AS counter,\'2026-10-29T12:00:00Z\'::timestamptz AS at,123456789012345678901234567890::numeric AS exact'
+ assert.deepEqual(await readBoundedFlowSql(pool,large,[],max),(await pool.query(large)).rows,'bigint/numeric/timestamp parser behavior is preserved')
+ for(const [name,value] of [['__flowRowCount',"'1'::text"],['__flowEncodedBytes',"'1'::text"],['__flowPresent','true']])await assert.rejects(readBoundedFlowSql(pool,`SELECT ${value} AS "${name}"`,[],max),/Reserved NetFlow source column collision/)
+ let overflowPayloads=0
+ const watched={query:async(sql:string,values:unknown[])=>{const result=await pool!.query(sql,values);overflowPayloads=result.rows.filter(row=>row.__flowPresent===true).length;return result}}
+ await assert.rejects(readBoundedFlowSql(watched,'SELECT repeat(\'a\',1000000) text FROM generate_series(1,20)',[],max),/превышает/)
+ assert.equal(overflowPayloads,0,'20 MiB source must send only a null sentinel row; no source payload is decoded in Node')
+ await pool.query('CREATE TABLE flow_read_growth(text text);INSERT INTO flow_read_growth VALUES(\'a\')')
+ let calls=0,growthDecodedRows=0
+ const growing={query:async(sql:string,values:unknown[])=>{
+ const result=await pool!.query(sql,values);calls++
+ if(calls===1)await pool!.query('UPDATE flow_read_growth SET text=repeat(\'a\',100000)')
+ if(calls===2)growthDecodedRows=result.rows.filter(row=>row.__flowPresent===true).length
+ return result
+ }}
+ await assert.rejects(readBoundedFlowSql(growing,'SELECT text FROM flow_read_growth',[],max),/превышает/)
+ assert.equal(calls,2);assert.equal(growthDecodedRows,0,'Concurrent growth cannot bypass the preflight reservation')
+ const columns=Object.entries(getTableColumns(servers)),quote=(s:string)=>'"'+s.replaceAll('"','""')+'"'
+ await pool.query('CREATE TABLE servers('+columns.map(([,column])=>quote(column.name)+' '+column.getSQLType()).join(',')+')')
+ await pool.query('INSERT INTO servers(id,name,host,created_at,updated_at) VALUES(1,\'selected\',\'192.0.2.1\',\'2026-10-29T00:00:00Z\',\'2026-10-29T00:00:00Z\')')
+ const code=ts.transpileModule(await readFile(new URL('../src/services/traffic-flow-server-source.ts',import.meta.url),'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText
+ const serverModule={exports:{} as {readBoundedFlowServerRows:(ids:number[])=>Promise}},localRequire=createRequire(import.meta.url)
+ const mocks:Record={'drizzle-orm':localRequire('drizzle-orm'),'../db/schema.js':{servers},'../db/index.js':{pool},'./traffic-flow-bounded-sql.js':{readBoundedFlowSql}}
+ new Function('require','module','exports',code)((id:string)=>{if(!(id in mocks))throw Error('Unexpected dependency '+id);return mocks[id]},serverModule,serverModule.exports)
+ assert.deepEqual(await serverModule.exports.readBoundedFlowServerRows([1]),await drizzle(pool).select().from(servers),'Full server rows preserve Drizzle fingerprint inputs including timestamp strings')
+ await pool.query('UPDATE servers SET password=repeat(\'x\',5*1024*1024)')
+ await assert.rejects(serverModule.exports.readBoundedFlowServerRows([1]),/превышает/)
+ console.log('PASS actual owned PostgreSQL: complete rows, empty result, count refusal, UTF-8 byte refusal, cumulative source refusal, parser parity, oversize no-decode sentinel and concurrent-growth fence')
+ console.log('PASS actual bounded server source versus Drizzle mapping parity; 5 MiB credential/config text refused before source decode')
+}finally{
+ await pool?.end();if(started)await postgres.stop()
+ // Only the exact private mkdtemp child is eligible; never shell deletion.
+ assert.equal(dirname(resolve(directory)),resolve(tmpdir()))
+ assert.equal(directory.includes('mm-flow-read-owned-'),true)
+ await rm(directory,{recursive:true,force:true,maxRetries:20,retryDelay:100})
+ console.log('Owned source SQL cluster stopped and temporary resources removed')
+}
diff --git a/backend/scripts/test-flow-settings-read-profiles-owned.mjs b/backend/scripts/test-flow-settings-read-profiles-owned.mjs
new file mode 100644
index 00000000..bf2d4de2
--- /dev/null
+++ b/backend/scripts/test-flow-settings-read-profiles-owned.mjs
@@ -0,0 +1,60 @@
+import EmbeddedPostgres from 'embedded-postgres'
+import { build,stop } from 'esbuild'
+import { mkdtemp,readFile,rm } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { resolve,join,dirname } from 'node:path'
+import { pathToFileURL } from 'node:url'
+import { randomBytes } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn } from 'node:child_process'
+import assert from 'node:assert/strict'
+if(process.argv.length!==2)throw Error('Profile settings tests accept no database or target arguments')
+const terminal=child=>child.exitCode!==null||child.signalCode!==null||child.pid===undefined
+async function stopOwnedChild(child,graceful=false){
+ if(!child||terminal(child))return
+ await new Promise((done,reject)=>{
+ let timer,forceTimer
+ const finish=()=>{clearTimeout(timer);clearTimeout(forceTimer);child.removeListener('exit',finish);done()}
+ child.once('exit',finish)
+ const force=()=>{
+ if(terminal(child)){finish();return}
+ child.kill('SIGKILL')
+ forceTimer=setTimeout(()=>{if(terminal(child))finish();else{child.removeListener('exit',finish);reject(Error('Owned child failed to reach confirmed terminal state: '+child.pid))}},10000)
+ }
+ timer=setTimeout(force,graceful?5000:10000)
+ if(graceful&&child.connected)child.send({type:'shutdown'},error=>{if(error&&!terminal(child))child.kill()})
+ else child.kill()
+ if(terminal(child))finish()
+ })
+}
+const repo=resolve(import.meta.dirname,'../..'),bundle=await mkdtemp(join(repo,'tmp','mm-profile-cold-bundle-'))
+try{
+ const compiled=join(bundle,'case.mjs'),driverFile=resolve(repo,'backend/scripts/flow-read-profile-http-client.mjs')
+ await build({entryPoints:[resolve(repo,'backend/src/services/traffic-flow-settings-read-profile.owned.test.ts')],outfile:compiled,platform:'node',format:'esm',bundle:true,packages:'external',banner:{js:"import{createRequire as __req}from'node:module';const require=__req(import.meta.url);"},plugins:[{name:'current-source',setup(b){b.onResolve({filter:/^@mmapp\/contracts(?:\/.*)?$/},a=>({path:resolve(repo,'packages/contracts/src',a.path.replace(/^@mmapp\/contracts\/?/,'')||'index')+'.ts'}));b.onLoad({filter:/\.ts$/},async a=>({contents:(await readFile(a.path,'utf8')).replaceAll('import.meta.url',JSON.stringify(pathToFileURL(a.path).href)),loader:'ts'}))}}]})
+ for(const profile of ['standard','constrained']){
+ const directory=await mkdtemp(join(tmpdir(),'mm-flow-profile-cold-owned-')),listener=createServer()
+ await new Promise(resolve=>listener.listen(0,'127.0.0.1',resolve));const port=listener.address().port;await new Promise(resolve=>listener.close(resolve))
+ const password=randomBytes(24).toString('hex'),postgres=new EmbeddedPostgres({databaseDir:join(directory,'pg'),port,user:'mcp_test',password,persistent:true,createPostgresUser:false,initdbFlags:['--encoding=UTF8'],postgresFlags:['-h','127.0.0.1','-c','shared_buffers=64MB','-c','work_mem=2MB'],onLog:()=>{},onError:()=>{}})
+ let started=false,client,app
+ try{
+ await postgres.initialise();await postgres.start();started=true
+ await new Promise((done,reject)=>{client=spawn(process.execPath,[driverFile],{cwd:directory,windowsHide:true,stdio:['ignore','inherit','inherit','ipc'],env:{...process.env,NODE_OPTIONS:'--max-old-space-size=192 --max-semi-space-size=16'}});client.on('message',message=>{if(message.type==='client-ready')done();if((message.type==='client-result'||message.type==='client-progress')&&app?.connected)app.send(message)});client.once('error',reject);client.once('exit',code=>{if(!app)reject(Error('Client startup exit '+code))})})
+ const outcome=await new Promise((done,reject)=>{
+ app=spawn(process.execPath,[compiled],{cwd:directory,windowsHide:true,stdio:['ignore','inherit','inherit','ipc'],env:{...process.env,NODE_OPTIONS:'--max-old-space-size=192 --max-semi-space-size=16',MM_FLOW_READ_RESOURCE_PROFILE:profile,MMAPP_OWN_FLOW_PROFILE_TEST:'true',DATABASE_URL:`postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,DATABASE_PATH:join(directory,'unused.sqlite'),MCP_STATE_DIR:join(directory,'state'),AUTH_REQUIRED:'true',AUTH_ISSUER:'https://auth.test.local',AUTH_JWT_SECRET:'owned-profile-only',MCP_PUBLIC_URL:'http://localhost:8000/mcp',NODE_ENV:'test'}})
+ const timeout=setTimeout(()=>reject(Error('Profile cold test timed out')),120000)
+ app.on('message',message=>{if(message.type==='client-command')client.send(message)})
+ app.once('error',error=>{clearTimeout(timeout);reject(error)});app.once('exit',code=>{clearTimeout(timeout);done(code??1)})
+ })
+ assert.equal(outcome,0,profile+' public/settings profile failed')
+ }finally{
+ const stopped=await Promise.allSettled([stopOwnedChild(app),stopOwnedChild(client,true)])
+ for(const result of stopped)if(result.status==='rejected')throw result.reason
+ if(started)await postgres.stop()
+ assert.equal(dirname(resolve(directory)),resolve(tmpdir()));assert.match(directory,/mm-flow-profile-cold-owned-/);await rm(directory,{recursive:true,force:true,maxRetries:20,retryDelay:100})
+ }
+ }
+}finally{stop();assert.equal(dirname(resolve(bundle)),resolve(repo,'tmp'));await rm(bundle,{recursive:true,force:true,maxRetries:20,retryDelay:100})}
+
+// All owned children and files are confirmed closed above; avoid library ambient handles keeping the CLI alive.
+console.log('PASS both owned profile fixtures and confirmed child cleanup')
+process.exit(0)
diff --git a/backend/scripts/test-mcp-postgres-sharded.mjs b/backend/scripts/test-mcp-postgres-sharded.mjs
new file mode 100644
index 00000000..890a1ebd
--- /dev/null
+++ b/backend/scripts/test-mcp-postgres-sharded.mjs
@@ -0,0 +1,50 @@
+// Runs the primary MCP PostgreSQL integration suite with its slowest self-contained acceptances
+// moved to parallel shards. Every process owns a disposable PostgreSQL (test-mcp-postgres.mjs).
+// Coverage equals `node scripts/test-mcp-postgres.mjs`: the primary run skips exactly the names
+// the shards run (MCP_INTEGRATION_SKIP), and an unknown name fails both sides.
+import { spawn } from 'node:child_process'
+import { fileURLToPath } from 'node:url'
+
+// Grouped by measured duration (2026-11-19, after the service speed-ups): each shard ~60-150 s,
+// the primary ~220 s. Fewer, fuller shards leave more CPU to the primary.
+const shards = {
+ 'scoped-forward-inverse': ['acceptScopedRouteCommunitySwitch:forward', 'acceptScopedRouteCommunitySwitch:inverse'],
+ 'scoped-route-ai': ['acceptScopedRouteCommunitySwitch:route-ai'],
+ wireguard: ['acceptWireguardInterfaceCreation', 'acceptRouteCommunityContextMcp', 'acceptWireguardPeerCreation', 'acceptWireguardInterfaceUpdate', 'acceptWireguardImport'],
+ misc: ['verifyMcpBgpExport', 'verifyMcpBgpFilterBinding', 'verifyMcpBgpCommunityPolicy', 'verifyMcpBgpPrefixes', 'verifyMcpFilterWrites', 'verifyMcpUptimeOverview', 'verifyMcpPathCompletion', 'verifyMcpLogArtifacts', 'verifyMcpFlowLive', 'verifyMcpControlPathContext', 'acceptManagementTransport', 'acceptRouteCommunityContextCompatibilityMcp', 'acceptNativeConservation', 'acceptNativeCreateId'],
+ 'overlay-ipsec': ['verifyMcpFlowOverlay', 'acceptWireguardInterfaceDeletion', 'acceptIpsecPeerDeletion', 'acceptIpsecUserDeletion', 'acceptIpsecCertificateDeletion', 'acceptIpsecPeerUpdate'],
+}
+const harness = fileURLToPath(new URL('./test-mcp-postgres.mjs', import.meta.url))
+const cwd = fileURLToPath(new URL('../', import.meta.url))
+const started = performance.now()
+const seconds = () => ((performance.now() - started) / 1000).toFixed(0).padStart(4)
+
+function run(label, args, env) {
+ return new Promise(resolve => {
+ const child = spawn(process.execPath, [harness, ...args], { cwd, env: { ...process.env, ...env }, stdio: ['ignore', 'pipe', 'pipe'] })
+ for (const stream of [child.stdout, child.stderr]) {
+ let pending = ''
+ stream.setEncoding('utf8')
+ stream.on('data', chunk => {
+ const lines = (pending + chunk).split(/\r?\n/)
+ pending = lines.pop()
+ for (const line of lines) if (line) console.log(`${seconds()}s [${label}] ${line}`)
+ })
+ stream.on('end', () => { if (pending) console.log(`${seconds()}s [${label}] ${pending}`) })
+ }
+ child.once('error', error => { console.error(`[${label}] ${error.message}`); resolve({ label, code: 1, at: seconds() }) })
+ child.once('exit', code => resolve({ label, code: code ?? 1, at: seconds() }))
+ })
+}
+
+const jobs = [run('primary', [], { MCP_INTEGRATION_SKIP: Object.values(shards).flat().join(',') })]
+for (const [label, names] of Object.entries(shards)) {
+ // Stagger starts: each harness picks a free port just before PostgreSQL binds it.
+ await new Promise(resolve => setTimeout(resolve, 1500))
+ jobs.push(run(label, [`--acceptance-shard=${names.join(',')}`], {}))
+}
+const results = await Promise.all(jobs)
+console.log('\nMCP PostgreSQL sharded run:')
+for (const result of results) console.log(` ${result.code === 0 ? 'PASS' : 'FAIL'} ${result.label} (exit ${result.code}, done at ${result.at.trim()}s)`)
+console.log(` total ${seconds().trim()}s`)
+process.exitCode = results.every(result => result.code === 0) ? 0 : 1
diff --git a/backend/scripts/test-mcp-postgres.mjs b/backend/scripts/test-mcp-postgres.mjs
new file mode 100644
index 00000000..1b4defb5
--- /dev/null
+++ b/backend/scripts/test-mcp-postgres.mjs
@@ -0,0 +1,422 @@
+import EmbeddedPostgres from 'embedded-postgres'
+import { runOwnedVrfProductionProfile } from './vrf-production-profile.mjs'
+import { mkdtemp, rm, readFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join, resolve, relative, isAbsolute, delimiter, dirname } from 'node:path'
+import { randomBytes } from 'node:crypto'
+import { fileURLToPath } from 'node:url'
+import { createServer } from 'node:net'
+import { spawn, execFile } from 'node:child_process'
+
+// Explicit targeted reruns use a fresh owned regression database. They never
+// claim the primary integration or terminal restore was rerun.
+// Fixed groups only; ordinary full/selected regression semantics stay unchanged.
+function profilesOnlyGroup(args) {
+ const groups = args.filter(arg => arg.startsWith('--profiles-group='))
+ if (!groups.length) return null
+ const group = groups[0].slice('--profiles-group='.length)
+ if (groups.length !== 1 || args.length !== 3 || !args.includes('--all') || !args.includes('--profiles-only') || !['base37', 'vrf1'].includes(group)) {
+ throw new Error('Fixed profile group requires exactly --all --profiles-only --profiles-group=base37|vrf1')
+ }
+ return group
+}
+function regressionProfiles(profiles, selected, group) {
+ if (group === null) return [...new Set([...profiles, 'test:logs:pg', ...(!selected ? ['test:vrf:production'] : [])])]
+ if (!['base37', 'vrf1'].includes(group) || selected || profiles.length !== 36 || new Set(profiles).size !== 36 || profiles.includes('test:logs:pg') || profiles.includes('test:vrf:production')) {
+ throw new Error('Fixed 37+1 profile coverage changed; review groups before running')
+ }
+ return group === 'base37' ? [...profiles, 'test:logs:pg'] : ['test:vrf:production']
+}
+// End fixed-group pure selectors.
+const profilesGroup = profilesOnlyGroup(process.argv.slice(2))
+const profilesOnly = process.argv.includes('--profiles-only')
+if (profilesOnly && (process.argv.length !== 4 + (profilesGroup ? 1 : 0) || !process.argv.includes('--all') ||
+ process.argv.slice(2).some(arg => !['--all', '--profiles-only', ...(profilesGroup ? ['--profiles-group=' + profilesGroup] : [])].includes(arg)))) {
+ throw new Error('Profiles-only requires exactly --all --profiles-only, without restore, selected profiles or other flags')
+}
+const regressionOnly = process.argv.includes('--regression-only')
+if (regressionOnly && (!process.argv.includes('--all') || process.argv.filter(arg => arg.startsWith('--profile=')).length !== 1 ||
+ process.argv.slice(2).some(arg => !['--all', '--regression-only'].includes(arg) && !arg.startsWith('--profile=')))) {
+ throw new Error('Regression-only requires exactly --all --regression-only --profile=, without restore or other profiles')
+}
+const operatorDockerSql = process.argv.includes('--operator-docker-sql')
+if (operatorDockerSql && process.argv.slice(2).some(arg => arg !== '--operator-docker-sql')) throw new Error('Operator Docker SQL requires a separate disposable cluster without restore')
+const pollMemoryCost = process.argv.includes('--poll-memory-cost')
+const pollMemoryBootstrap = process.argv.includes('--poll-memory-bootstrap')
+const pollMemory = process.argv.includes('--poll-memory') || pollMemoryCost || pollMemoryBootstrap
+if (pollMemory && (process.argv.length !== 3 || process.argv[2] !== (pollMemoryBootstrap ? '--poll-memory-bootstrap' : pollMemoryCost ? '--poll-memory-cost' : '--poll-memory'))) throw new Error('Compiled poll memory requires its own disposable cluster without other profiles')
+const pollMemoryEnvironment = Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'LANG', 'LC_ALL']
+ .filter(key => typeof process.env[key] === 'string').map(key => [key, process.env[key]]))
+const pollJournalSnapshot = process.argv.includes('--poll-journal-snapshot')
+if (pollJournalSnapshot && process.argv.slice(2).some(arg => arg !== '--poll-journal-snapshot')) throw new Error('Journal snapshot lock evidence requires its own disposable cluster')
+const principalSecuritySource = process.argv.includes('--principal-security-source')
+if (principalSecuritySource && process.argv.slice(2).some(arg => arg !== '--principal-security-source')) throw new Error('Principal security source requires its own disposable cluster')
+const protocolLimits = process.argv.slice(2).includes('--protocol-limits')
+if (protocolLimits && process.argv.length !== 3) throw new Error('Protocol limits acceptance requires its own disposable cluster')
+const pollArchiveFlags = ['--poll-terminal-archive', '--poll-terminal-archive-lost-ack', '--poll-terminal-archive-history', '--poll-terminal-archive-history-cold', '--poll-terminal-archive-claim-loss']
+const chosenArchiveFlags = process.argv.slice(2).filter(arg => pollArchiveFlags.includes(arg))
+const pollArchiveLostAck = chosenArchiveFlags[0] === '--poll-terminal-archive-lost-ack'
+const pollArchiveCold = chosenArchiveFlags[0] === '--poll-terminal-archive-history-cold'
+const pollArchiveHistory = chosenArchiveFlags[0] === '--poll-terminal-archive-history' || pollArchiveCold
+const pollArchiveClaimLoss = chosenArchiveFlags[0] === '--poll-terminal-archive-claim-loss'
+const pollTerminalArchive = chosenArchiveFlags.length > 0
+if (pollTerminalArchive && (chosenArchiveFlags.length !== 1 || process.argv.slice(2).some(arg => ![chosenArchiveFlags[0], '--restore'].includes(arg)))) throw new Error('Poll terminal archive requires its own disposable cluster')
+const pollArchiveSchema = process.argv.includes('--poll-archive-schema')
+if (pollArchiveSchema && process.argv.slice(2).some(arg => arg !== '--poll-archive-schema')) throw new Error('Poll archive schema requires its own disposable cluster')
+const telemetrySettingsConfiguration = process.argv.includes('--telemetry-settings-configuration')
+if (telemetrySettingsConfiguration && process.argv.slice(2).some(arg => arg !== '--telemetry-settings-configuration')) throw new Error('Telemetry settings configuration requires its own disposable cluster')
+const routingReservationSchema = process.argv.includes('--routing-reservation-schema')
+if (routingReservationSchema && process.argv.slice(2).some(arg => arg !== '--routing-reservation-schema')) throw new Error('Routing reservation schema requires its own disposable cluster')
+const routingOriginalEffects = process.argv.includes('--routing-original-effects')
+const routingControllerFailoverOnly = process.argv.includes('--controller-failover-only')
+const routingForwardRounds = routingOriginalEffects || process.argv.includes('--routing-network-forward-rounds')
+if (routingControllerFailoverOnly && !routingOriginalEffects) throw new Error('Controller failover requires --routing-original-effects')
+if (routingForwardRounds && process.argv.slice(2).some(arg => arg !== (routingOriginalEffects ? '--routing-original-effects' : '--routing-network-forward-rounds') &&
+ !(routingControllerFailoverOnly && arg === '--controller-failover-only'))) throw new Error('Routing forward rounds requires its own disposable cluster')
+const flowActiveServices = process.argv.includes('--flow-active-services')
+if (flowActiveServices && process.argv.slice(2).some(arg => arg !== '--flow-active-services')) throw new Error('Flow active services requires its own disposable cluster')
+const flowActiveRebuild = process.argv.includes('--flow-active-rebuild')
+if (flowActiveRebuild && process.argv.slice(2).some(arg => arg !== '--flow-active-rebuild')) throw new Error('Flow active rebuild requires its own disposable cluster')
+const flowQuality = process.argv.includes('--flow-quality')
+if (flowQuality && process.argv.slice(2).some(arg => arg !== '--flow-quality')) throw new Error('Flow quality requires its own disposable cluster')
+const flowWorkerIpc = process.argv.includes('--flow-worker-ipc')
+if (flowWorkerIpc && process.argv.slice(2).some(arg => arg !== '--flow-worker-ipc')) throw new Error('Flow worker IPC requires its own disposable cluster')
+const manualUptime = process.argv.includes('--manual-uptime')
+if (manualUptime && process.argv.slice(2).some(arg => arg !== '--manual-uptime')) throw new Error('Manual uptime requires its own disposable cluster')
+const manualPingGroup = process.argv.includes('--manual-ping-group')
+if (manualPingGroup && process.argv.slice(2).some(arg => arg !== '--manual-ping-group')) throw new Error('Manual Ping group requires its own disposable cluster')
+const manualTraffic = process.argv.includes('--manual-traffic')
+if (manualTraffic && process.argv.slice(2).some(arg => arg !== '--manual-traffic')) throw new Error('Manual traffic requires its own disposable cluster')
+const manualApiPing = process.argv.includes('--manual-api-ping')
+if (manualApiPing && process.argv.slice(2).some(arg => arg !== '--manual-api-ping')) throw new Error('Manual API Ping requires its own disposable cluster')
+const simpleSpeed = process.argv.includes('--simple-speed')
+if (simpleSpeed && process.argv.slice(2).some(arg => arg !== '--simple-speed')) throw new Error('Simple speed acceptance requires its own disposable cluster')
+const simpleSpeedChr = process.argv.includes('--simple-speed-chr')
+if (simpleSpeedChr && process.argv.slice(2).some(arg => arg !== '--simple-speed-chr')) throw new Error('Simple speed CHR acceptance requires its own disposable cluster')
+const publicRegistryMetadata = process.argv.includes('--public-registry-metadata')
+if (publicRegistryMetadata && process.argv.slice(2).some(arg => arg !== '--public-registry-metadata')) throw new Error('Public registry metadata requires a separate disposable cluster without restore')
+const operatorPeerMetadata = process.argv.includes('--operator-peer-metadata')
+if (operatorPeerMetadata && process.argv.slice(2).some(arg => arg !== '--operator-peer-metadata')) throw new Error('Operator peer metadata requires a separate disposable cluster without restore')
+const externalPeerMetadata = process.argv.includes('--external-peer-metadata')
+if (externalPeerMetadata && process.argv.slice(2).some(arg => arg !== '--external-peer-metadata')) throw new Error('Guarded external peer metadata requires a separate disposable cluster without restore')
+const pollOperationRetirement = process.argv.includes('--poll-operation-retirement')
+const pollRetirementFocused = process.argv.includes('--skip-poll-capacity')
+if (pollRetirementFocused && !pollOperationRetirement) throw new Error('--skip-poll-capacity requires --poll-operation-retirement')
+const ordinaryOperationRetirement = process.argv.includes('--ordinary-operation-retirement')
+const probeOperationRetirement = process.argv.includes('--probe-operation-retirement')
+const mcpOperationOrigin = process.argv.includes('--mcp-operation-origin') || pollOperationRetirement || ordinaryOperationRetirement || probeOperationRetirement
+if (mcpOperationOrigin && process.argv.slice(2).some(arg => !(pollOperationRetirement && arg === '--skip-poll-capacity') &&
+ arg !== (probeOperationRetirement ? '--probe-operation-retirement' : ordinaryOperationRetirement ? '--ordinary-operation-retirement' : pollOperationRetirement ? '--poll-operation-retirement' : '--mcp-operation-origin'))) throw new Error('MCP operation root requires a separate disposable cluster without restore')
+const mcpSpeedOriginal = process.argv.includes('--mcp-speed-original')
+if (mcpSpeedOriginal && process.argv.slice(2).some(arg => arg !== '--mcp-speed-original')) throw new Error('MCP speed component requires a separate disposable cluster without restore')
+const routerConfigurationGuard = process.argv.includes('--router-configuration-guard')
+if (routerConfigurationGuard && process.argv.slice(2).some(arg => arg !== '--router-configuration-guard')) throw new Error('Router configuration guard requires a separate disposable cluster without restore')
+const scheduledSpeedOriginal = process.argv.includes('--scheduled-speed-original')
+if (scheduledSpeedOriginal && process.argv.slice(2).some(arg => arg !== '--scheduled-speed-original')) throw new Error('Scheduled speed origin requires a separate disposable cluster without restore')
+const bandwidthSpeedWorkflow = process.argv.includes('--bandwidth-speed-workflow')
+if (bandwidthSpeedWorkflow && process.argv.slice(2).some(arg => arg !== '--bandwidth-speed-workflow')) throw new Error('Whole speed workflow requires its own disposable cluster; restore is not implemented')
+const restSpeedOriginal = process.argv.includes('--rest-speed-original')
+if (restSpeedOriginal && process.argv.slice(2).some(arg => arg !== '--rest-speed-original')) throw new Error('REST speed origin acceptance requires its own disposable cluster; restore is not implemented for this profile')
+const operationLocks = process.argv.includes('--operation-locks')
+const serviceExecutionOrigin = process.argv.includes('--service-execution-origin')
+const bandwidthNodeSource = process.argv.includes('--bandwidth-node-source')
+const bandwidthExternalRegistry = process.argv.includes('--bandwidth-external-registry')
+if (bandwidthExternalRegistry && process.argv.slice(2).some(arg => arg !== '--bandwidth-external-registry')) throw new Error('External registry acceptance requires its own disposable cluster; restore is not implemented for this profile')
+const bandwidthNodeRegistry = process.argv.includes('--bandwidth-node-registry')
+const bandwidthControlSource = process.argv.includes('--bandwidth-control-source')
+const bandwidthAdmission = process.argv.includes('--bandwidth-admission')
+const diagnosticCancelHost = process.argv.includes('--diagnostic-cancel-host')
+const ipsecExportHttp = process.argv.includes('--ipsec-export-http')
+const ipsecExportJournal = process.argv.includes('--ipsec-export-journal')
+const routingRecoveryAuthority = process.argv.includes('--routing-recovery-authority')
+const legacyFlowRebuild = process.argv.includes('--legacy-flow-rebuild')
+const serverPollStorageFresh = process.argv.includes('--server-poll-storage-fresh')
+const serverPollStorage = process.argv.includes('--server-poll-storage')
+const serverPollDurable = process.argv.includes('--server-poll-durable')
+const collectorPartitionWriters = process.argv.includes('--collector-partition-writers')
+const routingReservations = process.argv.includes('--routing-reservations')
+const routingReservationRuntime = process.argv.includes('--routing-reservation-runtime')
+const routingNetworkNative = process.argv.includes('--routing-network-native')
+const migrationDataInventory = process.argv.includes('--migration-data-inventory')
+const migrationSchemaInventory = process.argv.includes('--migration-schema-inventory')
+const databaseSchemaControl = process.argv.includes('--database-schema-control')
+const controlledMigrations = process.argv.includes('--controlled-migrations')
+const controlledSchemaReference = process.argv.includes('--controlled-schema-reference')
+const probeStorageHistory = process.argv.includes('--probe-storage-history')
+const probeStorageJournal = process.argv.includes('--probe-storage-journal')
+const probeLegacyOrphans = process.argv.includes('--probe-legacy-orphans')
+const probeStorageFresh = process.argv.includes('--probe-storage-fresh')
+for (const [selected, flag] of [[operationLocks, '--operation-locks'], [serviceExecutionOrigin, '--service-execution-origin'], [bandwidthNodeSource, '--bandwidth-node-source'], [bandwidthNodeRegistry, '--bandwidth-node-registry'], [bandwidthExternalRegistry, '--bandwidth-external-registry'], [bandwidthControlSource, '--bandwidth-control-source'], [bandwidthAdmission, '--bandwidth-admission'], [serverPollStorageFresh, '--server-poll-storage-fresh'], [serverPollStorage, '--server-poll-storage'], [diagnosticCancelHost, '--diagnostic-cancel-host'], [ipsecExportHttp, '--ipsec-export-http'], [ipsecExportJournal, '--ipsec-export-journal'], [routingRecoveryAuthority, '--routing-recovery-authority'], [legacyFlowRebuild, '--legacy-flow-rebuild'], [serverPollDurable, '--server-poll-durable'], [collectorPartitionWriters, '--collector-partition-writers'], [routingReservations, '--routing-reservations'], [routingReservationRuntime, '--routing-reservation-runtime'], [routingNetworkNative, '--routing-network-native'], [migrationDataInventory, '--migration-data-inventory'], [migrationSchemaInventory, '--migration-schema-inventory'], [databaseSchemaControl, '--database-schema-control'], [controlledMigrations, '--controlled-migrations'], [controlledSchemaReference, '--controlled-schema-reference'], [probeStorageHistory, '--probe-storage-history'], [probeStorageJournal, '--probe-storage-journal'], [probeLegacyOrphans, '--probe-legacy-orphans'], [probeStorageFresh, '--probe-storage-fresh']]) {
+ if (selected && process.argv.slice(2).some(arg => ![flag, '--restore'].includes(arg))) throw new Error('Focused writer/recovery acceptance requires a separate disposable run')
+}
+const probeJournal = process.argv.includes('--server-probe-journal')
+if (probeJournal && process.argv.slice(2).some(arg => !['--server-probe-journal', '--restore'].includes(arg))) throw new Error('Server probe journal acceptance requires a separate disposable run')
+const flowHostKeys = process.argv.includes('--flow-host-keys')
+if (flowHostKeys && process.argv.slice(2).some(arg => !['--flow-host-keys','--restore'].includes(arg))) throw new Error('Host keys acceptance requires a separate disposable run')
+const flowRebuildMcp = process.argv.includes('--flow-rebuild-mcp')
+if (flowRebuildMcp && process.argv.slice(2).some(arg => arg !== '--flow-rebuild-mcp')) throw new Error('MCP flow rebuild acceptance requires a separate disposable run')
+const flowRebuild = process.argv.includes('--flow-rebuild')
+if (flowRebuild && process.argv.slice(2).some(arg => arg !== '--flow-rebuild')) throw new Error('Flow rebuild SQL acceptance requires a separate disposable run')
+const flowWrites = process.argv.includes('--flow-writes')
+if (flowWrites && process.argv.slice(2).some(arg => arg !== '--flow-writes')) throw new Error('Flow writer SQL acceptance requires a separate disposable run')
+const chrGreMutation = process.argv.includes('--chr-gre-mutation')
+const chrGreRevision = process.argv.includes('--chr-gre-revision')
+const chrGreRevisionRecovery = process.argv.includes('--chr-gre-revision-recovery')
+const chrRead = process.argv.includes('--chr-read')
+const chrIdentity = process.argv.includes('--chr-ospf-identity-read')
+const chrRecursive = process.argv.includes('--chr-recursive-restore')
+const chrFirewallRestore = process.argv.includes('--chr-firewall-restore')
+const chrAddress = process.argv.includes('--chr-address-list')
+const chrFirewallWrite = process.argv.includes('--chr-firewall-write')
+const chrFirewallMove = process.argv.includes('--chr-firewall-move')
+const chrVpn = process.argv.includes('--chr-vpn-catalog')
+const chrFilters = process.argv.includes('--chr-filter-write')
+const chrLegacyOspf = process.argv.includes('--chr-ospf-legacy')
+const greRevision = process.argv.includes('--gre-revision')
+const usersBindings = process.argv.includes('--users-bindings')
+if (usersBindings && (process.argv.length !== 3 || process.argv[2] !== '--users-bindings')) throw new Error('User bindings acceptance requires its own disposable cluster')
+const bridgeVlanConfiguration = process.argv.includes('--bridge-vlan-configuration')
+if (bridgeVlanConfiguration && process.argv.slice(2).some(arg => arg !== '--bridge-vlan-configuration')) throw new Error('Bridge VLAN acceptance requires its own disposable cluster')
+const applicationAdapters = process.argv.includes('--application-adapters')
+const scopedRoutingDiagnostics = process.argv.includes('--scoped-routing-diagnostics')
+const interfaceEventsCompatibility = process.argv.includes('--interface-events-compatibility')
+const eventsOnly = process.argv.includes('--events-only')
+const legacyBgpOnly = process.argv.includes('--legacy-bgp-only')
+if ((eventsOnly || legacyBgpOnly) && (!interfaceEventsCompatibility || process.argv.length !== 4)) {
+ throw new Error('A focused events or legacy-BGP run requires the isolated interface events profile')
+}
+const wireguardExport = process.argv.includes('--wireguard-export')
+if (wireguardExport && process.argv.includes('--wireguard-transfer')) throw new Error('Choose WireGuard transfer or export acceptance mode')
+const wireguardTransfer = process.argv.includes('--wireguard-transfer') || wireguardExport
+const scopedCheckpointAdapters = process.argv.includes('--scoped-checkpoint-adapters')
+const nativeConservation = process.argv.includes('--native-conservation')
+// Parallel shard of self-contained acceptances (scripts/test-mcp-postgres-sharded.mjs); no terminal restore stage.
+const acceptanceShard = process.argv.find(arg => arg.startsWith('--acceptance-shard='))?.slice('--acceptance-shard='.length)
+if (acceptanceShard !== undefined && (!acceptanceShard || process.argv.length !== 3)) throw new Error('--acceptance-shard= runs alone')
+const nativeCreateId = process.argv.includes('--native-create-id')
+const moduleCompletion = process.argv.includes('--module-completion')
+const completionTarget = process.argv.find(arg => arg.startsWith('--only='))?.slice(7) ?? 'all'
+if (!['all','wireguard','ipsec-init','ipsec-restore','ipsec-delete','ipsec-create','vrf'].includes(completionTarget) || (completionTarget !== 'all' && !moduleCompletion)) throw new Error('Unknown isolated module target')
+if (moduleCompletion && process.argv.slice(2).some(arg => !['--module-completion', '--restore', `--only=${completionTarget}`].includes(arg))) throw new Error('Module completion acceptance requires a separate disposable run')
+const ipsecAdapters = process.argv.includes('--ipsec-adapters') || moduleCompletion
+if (nativeCreateId && (ipsecAdapters || process.argv.includes('--recovery-maintenance'))) throw new Error('Choose native CREATE ID or another focused acceptance mode')
+if (ipsecAdapters && process.argv.includes('--recovery-maintenance')) throw new Error('Choose IPsec adapters or recovery maintenance acceptance mode')
+if (nativeConservation && (nativeCreateId || ipsecAdapters || process.argv.includes('--recovery-maintenance'))) throw new Error('Choose native conservation or another focused acceptance mode')
+const managementAdmissionOnly = process.argv.includes('--management-admission-only')
+const administrationAdmissionOnly = process.argv.includes('--administration-admission-only')
+const configurationAuditOnly = process.argv.includes('--configuration-audit-only')
+const routerRequestDrainOnly = process.argv.includes('--router-request-drain-only')
+const restReplicaOnly = process.argv.includes('--rest-replica-admission-only')
+const restoreQuarantineOnly = process.argv.includes('--restore-quarantine-only')
+const logsSdkScenario = process.argv.includes('--logs-request-lease-only') ? 'lease-loss' : process.argv.includes('--logs-sdk-cancellation-only') ? 'caller-cancel' : ''
+const sqliteImportCliOnly = process.argv.includes('--sqlite-import-cli-only')
+const recoveryMaintenance = process.argv.includes('--recovery-maintenance') || managementAdmissionOnly || administrationAdmissionOnly || configurationAuditOnly || routerRequestDrainOnly || restReplicaOnly || restoreQuarantineOnly || !!logsSdkScenario || sqliteImportCliOnly || ipsecAdapters || nativeCreateId || nativeConservation
+if (Number(chrGreMutation) + Number(chrGreRevision) + Number(chrGreRevisionRecovery) + Number(chrFirewallRestore) + Number(chrAddress) + Number(chrFirewallWrite) + Number(chrRead) + Number(chrIdentity) + Number(chrRecursive) + Number(chrFirewallMove) + Number(chrVpn) + Number(chrFilters) + Number(chrLegacyOspf) + Number(process.argv.includes('--chr')) > 1) throw new Error('Choose exactly one CHR acceptance mode')
+const chr = process.argv.includes('--chr') || chrGreMutation || chrGreRevision || chrGreRevisionRecovery || chrFirewallRestore || chrAddress || chrFirewallWrite || chrRead || chrIdentity || chrRecursive || chrFirewallMove || chrVpn || chrFilters || chrLegacyOspf
+if (recoveryMaintenance && (chr || greRevision || applicationAdapters || scopedRoutingDiagnostics || interfaceEventsCompatibility || wireguardTransfer || scopedCheckpointAdapters)) throw new Error('Recovery maintenance SQL/HTTP mode cannot run with another focused mode')
+if (scopedCheckpointAdapters && (chr || greRevision || applicationAdapters || scopedRoutingDiagnostics || interfaceEventsCompatibility || wireguardTransfer)) throw new Error('Scoped checkpoint SQL/HTTP mode cannot run with another focused mode')
+if (wireguardTransfer && (chr || greRevision || applicationAdapters || scopedRoutingDiagnostics || interfaceEventsCompatibility)) throw new Error('WireGuard transfer SQL/HTTP mode cannot run with another focused mode')
+if (interfaceEventsCompatibility && (chr || greRevision || applicationAdapters || scopedRoutingDiagnostics)) throw new Error('Interface events SQL/HTTP mode cannot run with other focused modes')
+if (scopedRoutingDiagnostics && (chr || greRevision || applicationAdapters)) throw new Error('Scoped routing SQL/HTTP mode cannot run with other focused modes')
+if (applicationAdapters && (chr || greRevision)) throw new Error('Application SQL/HTTP mode cannot run with other focused modes')
+if (greRevision && chr) throw new Error('GRE revision SQL/HTTP mode cannot run with CHR acceptance')
+if (chr) {
+ if (!process.env.MMAPP_TEST_CHR_HOSTS || !process.env.MMAPP_TEST_CHR_USER) throw new Error('CHR hosts and user must be explicitly configured')
+ if (!process.env.MMAPP_TEST_CHR_PASSWORD) {
+ if (!process.stdin.isTTY) throw new Error('Use a terminal for the private CHR password prompt')
+ process.stdout.write('CHR password (hidden): ')
+ process.env.MMAPP_TEST_CHR_PASSWORD = await new Promise((resolve, reject) => {
+ let value = ''
+ const timer = setTimeout(() => finish(new Error('Password input timed out')), 60000)
+ const finish = error => {
+ clearTimeout(timer); process.stdin.off('data', read); process.stdin.setRawMode(false); process.stdin.pause(); process.stdout.write('\n')
+ if (error) reject(error); else resolve(value)
+ }
+ const read = chunk => {
+ for (const character of chunk.toString()) {
+ if (character === '\r' || character === '\n') { finish(); return }
+ if (character === '\u0003') { finish(new Error('Cancelled')); return }
+ if (character === '\u007f' || character === '\b') value = value.slice(0, -1)
+ else value += character
+ }
+ }
+ process.stdin.setRawMode(true); process.stdin.resume(); process.stdin.on('data', read)
+ })
+ }
+}
+
+// A private disposable cluster: never reads backend/.env or the application DB.
+const directory = await mkdtemp(join(tmpdir(), 'mm-mcp-test-'))
+const listener = createServer()
+await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve))
+const port = listener.address().port
+await new Promise(resolve => listener.close(resolve))
+const password = randomBytes(24).toString('hex')
+const postgres = new EmbeddedPostgres({ databaseDir: join(directory, 'pg'), port, user: 'mcp_test', password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', '127.0.0.1'],
+ onLog: () => {}, onError: () => {} })
+let exitCode = 1
+let vrfChildrenExitConfirmed = true
+try {
+ await postgres.initialise()
+ await postgres.start()
+ const binaries = await import(`@embedded-postgres/${process.platform === 'win32' ? 'windows' : process.platform}-${process.arch}`)
+ const testPath = [process.env.MMAPP_PG_CLIENT_BIN, dirname(binaries.postgres), process.env.PATH ?? process.env.Path ?? ''].filter(Boolean).join(delimiter)
+ if (!profilesOnly && (restoreQuarantineOnly || process.argv.includes('--restore') || process.env.MMAPP_PG_CLIENT_BIN)) {
+ for (const command of ['pg_dump', 'pg_restore']) await new Promise((resolve, reject) => {
+ execFile(command, ['--version'], { env: { ...process.env, PATH: testPath }, windowsHide: true, timeout: 5000, maxBuffer: 4096 }, error => {
+ if (error) reject(new Error(`Restore acceptance requires working ${command}; set MMAPP_PG_CLIENT_BIN to the PostgreSQL client bin directory`))
+ else resolve()
+ })
+ })
+ console.log('PostgreSQL restore client tools preflight PASS')
+ }
+ if (regressionOnly) console.log('Selected regression only: primary integration and terminal restore are not run')
+ if (profilesOnly) console.log('Profiles-only regression matrix: primary integration NOT RUN; terminal restore NOT RUN; full acceptance is not claimed')
+ const result = regressionOnly || profilesOnly ? 0 : await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, pollMemory ? ['--max-old-space-size=192', '--max-semi-space-size=16', fileURLToPath(new URL('../dist-mcp-memory/services/server-poll-memory.owned.test.js', import.meta.url))] : ['--import', 'tsx', ...(flowActiveRebuild ? ['--import', new URL('../src/services/traffic-flow-active-rebuild-preload.mjs', import.meta.url).href] : []), acceptanceShard ? 'src/modules/mcp/acceptance-shard.test.ts' : usersBindings ? 'src/modules/mcp/users-bindings-owned.test.ts' : bridgeVlanConfiguration ? 'src/modules/mcp/bridge-vlan-configuration-http.test.ts' : protocolLimits ? 'src/modules/mcp/protocol-limits.owned.test.ts' : principalSecuritySource ? 'src/modules/mcp/principal-security-source.owned.test.ts' : pollJournalSnapshot ? 'src/services/server-poll-journal-snapshot.owned.test.ts' : pollTerminalArchive ? 'src/services/server-poll-terminal-archive.owned.test.ts' : pollArchiveSchema ? 'src/db/server-poll-terminal-archives.sql.test.ts' : telemetrySettingsConfiguration ? 'src/modules/mcp/telemetry-settings-configuration.owned.test.ts' : routingReservationSchema ? 'src/db/routing-reservation-schema.owned.test.ts' : routingForwardRounds ? 'src/modules/mcp/routing-network-forward-rounds.owned.test.ts' : flowActiveServices ? 'src/services/traffic-flow-active-services.owned.test.ts' : flowActiveRebuild ? 'src/services/traffic-flow-active-rebuild.owned.test.ts' : flowQuality ? 'src/services/traffic-flow-quality.owned.test.ts' : flowWorkerIpc ? 'src/services/traffic-flow-worker-ipc.owned.test.ts' : manualUptime ? 'src/modules/mcp/manual-uptime-http.test.ts' : manualPingGroup ? 'src/modules/mcp/manual-ping-group-http.test.ts' : manualTraffic ? 'src/modules/mcp/manual-traffic-http.test.ts' : manualApiPing ? 'src/modules/mcp/manual-api-ping-http.test.ts' : simpleSpeedChr ? 'src/modules/mcp/simple-speed-chr.test.ts' : simpleSpeed ? 'src/modules/mcp/simple-speed-http.test.ts' : externalPeerMetadata ? 'src/services/bandwidth-external-peer-metadata.sql.test.ts' : operatorPeerMetadata ? 'src/services/bandwidth-operator-metadata.sql.test.ts' : publicRegistryMetadata ? 'src/services/bandwidth-public-registry.sql.test.ts' : operatorDockerSql ? 'src/services/bandwidth-operator-docker-stop.sql.test.ts' : probeOperationRetirement ? 'src/services/server-probe-operation-retirement.owned.test.ts' : ordinaryOperationRetirement ? 'src/modules/mcp/ordinary-operation-retirement.owned.test.ts' : pollOperationRetirement ? 'src/services/server-poll-operation-retirement.owned.test.ts' : mcpOperationOrigin ? 'src/modules/mcp/operation-execution-origin.sql.test.ts' : mcpSpeedOriginal ? 'src/modules/mcp/speed-bandwidth-original.sql.test.ts' : routerConfigurationGuard ? 'src/services/router-configuration-guard.sql.test.ts' : scheduledSpeedOriginal ? 'src/services/bandwidth-scheduled-speed-original.sql.test.ts' : bandwidthSpeedWorkflow ? 'src/services/bandwidth-speed-workflow.sql.test.ts' : restSpeedOriginal ? 'src/services/bandwidth-rest-speed-original.sql.test.ts' : operationLocks ? 'src/services/operation-config-lock-lease.sql.test.ts' : serviceExecutionOrigin ? 'src/modules/mcp/service-execution-origin.sql.test.ts' : bandwidthNodeSource ? 'src/services/bandwidth-node-source.sql.test.ts' : bandwidthExternalRegistry ? 'src/services/bandwidth-external-node-registry.sql.test.ts' : bandwidthNodeRegistry ? 'src/services/bandwidth-node-registry.sql.test.ts' : bandwidthControlSource ? 'src/services/bandwidth-control-source.sql.test.ts' : bandwidthAdmission ? 'src/services/bandwidth-admission.sql.test.ts' : serverPollStorageFresh ? 'src/services/server-poll-storage-fresh.sql.test.ts' : serverPollStorage ? 'src/services/server-poll-storage.sql.test.ts' : probeStorageFresh ? 'src/services/server-probe-storage-fresh.sql.test.ts' : probeLegacyOrphans ? 'src/services/server-probe-legacy-orphans.sql.test.ts' : diagnosticCancelHost ? 'src/modules/mcp/diagnostic-cancellation-storage.sql.test.ts' : ipsecExportHttp ? 'src/modules/mcp/ipsec-existing-certificate-export-http.sql.test.ts' : ipsecExportJournal ? 'src/services/ipsec-existing-certificate-export-rest-journal.sql.test.ts' : migrationDataInventory ? 'src/db/migration-data-inventory.sql.test.ts' : probeStorageHistory ? 'src/services/server-probe-storage-history.sql.test.ts' : probeStorageJournal ? 'src/services/server-probe-storage-journal.sql.test.ts' : controlledSchemaReference ? 'src/db/controlled-schema-reference.sql.test.ts' : controlledMigrations ? 'src/db/controlled-migrations.sql.test.ts' : databaseSchemaControl ? 'src/db/database-schema-control.sql.test.ts' : migrationSchemaInventory ? 'src/db/migration-schema-inventory.sql.test.ts' : routingNetworkNative ? 'src/modules/mcp/routing-network-native.sql.test.ts' : routingReservationRuntime ? 'src/modules/mcp/routing-reservation-runtime.sql.test.ts' : routingReservations ? 'src/modules/mcp/routing-reservation.sql.test.ts' : collectorPartitionWriters ? 'src/services/collector-partition-writes.sql.test.ts' : serverPollDurable ? 'src/services/server-poll-durable-session.sql.test.ts' : routingRecoveryAuthority ? 'src/modules/mcp/routing-recovery-authority.sql.test.ts' : legacyFlowRebuild ? 'src/test/legacy-flow-rebuild-sql.ts' : probeJournal ? 'src/services/server-probe-journal.sql.test.ts' : flowHostKeys ? 'src/modules/mcp/flow-host-keys-http.test.ts' : flowRebuildMcp ? 'src/modules/mcp/flow-facts-rebuild-http.test.ts' : flowRebuild ? 'src/test/flow-facts-rebuild-sql.ts' : flowWrites ? 'src/services/traffic-flow-write-transaction.pg.test.ts' : nativeConservation ? 'src/modules/mcp/native-conservation-sql.test.ts' : nativeCreateId ? 'src/modules/mcp/native-create-id-http.test.ts' : ipsecAdapters ? "src/modules/mcp/ipsec-adapters-http.test.ts" : recoveryMaintenance ? "src/modules/mcp/recovery-maintenance-http.test.ts" : scopedCheckpointAdapters ? "src/modules/mcp/scoped-checkpoint-adapters-http.test.ts" : wireguardTransfer ? 'src/modules/mcp/wireguard-transfer-http.test.ts' : interfaceEventsCompatibility ? 'src/modules/mcp/interface-events-compatibility-http.test.ts' : scopedRoutingDiagnostics ? 'src/modules/mcp/scoped-routing-diagnostics-http.test.ts' : applicationAdapters ? 'src/modules/mcp/application-adapters-http.test.ts' : greRevision ? 'src/modules/mcp/gre-revision-http.test.ts' : chrGreRevisionRecovery ? 'src/modules/mcp/chr-gre-revision-recovery.test.ts' : chrGreRevision ? 'src/modules/mcp/chr-gre-revision.test.ts' : chrLegacyOspf ? 'src/modules/mcp/chr-ospf-legacy.test.ts' : chrFilters ? 'src/modules/mcp/chr-filter-write.test.ts' : chrGreMutation ? 'src/modules/mcp/chr-gre-mutation.test.ts' : chrFirewallRestore ? 'src/modules/mcp/chr-firewall-restore.test.ts' : chrAddress ? 'src/modules/mcp/chr-address-list.test.ts' : chrFirewallWrite ? 'src/modules/mcp/chr-firewall-write.test.ts' : chrVpn ? 'src/modules/mcp/chr-vpn-catalog.test.ts' : chrFirewallMove ? 'src/modules/mcp/chr-firewall-move.test.ts' : chrRecursive ? 'src/modules/mcp/chr-recursive-restore.test.ts' : chrIdentity ? 'src/modules/mcp/chr-ospf-identity-readonly.test.ts' : chrRead ? 'src/modules/mcp/chr-readonly-acceptance.test.ts' : chr ? 'src/modules/mcp/chr-acceptance.test.ts' : 'src/modules/mcp/integration.test.ts'], {
+ cwd: pollMemory ? directory : new URL('../', import.meta.url), stdio: 'inherit', env: { ...(pollMemory ? pollMemoryEnvironment : process.env),
+ MMAPP_OWN_SKIP_POLL_CAPACITY: String(pollRetirementFocused),
+ MMAPP_OWN_PROTOCOL_LIMITS: String(protocolLimits),
+ MMAPP_OWN_EVENTS_ONLY: String(eventsOnly),
+ MMAPP_OWN_MANAGEMENT_ADMISSION_ONLY: String(managementAdmissionOnly),
+ MMAPP_OWN_ADMINISTRATION_ADMISSION_ONLY: String(administrationAdmissionOnly),
+ MMAPP_OWN_CONFIGURATION_AUDIT_ONLY: String(configurationAuditOnly),
+ MMAPP_OWN_ROUTER_REQUEST_DRAIN_ONLY: String(routerRequestDrainOnly),
+ MMAPP_OWN_REST_REPLICA_ONLY: String(restReplicaOnly),
+ MMAPP_OWN_RESTORE_QUARANTINE_ONLY: String(restoreQuarantineOnly),
+ MMAPP_OWN_LOGS_SDK_SCENARIO: logsSdkScenario,
+ MCP_ACCEPTANCE_SHARD: acceptanceShard ?? '',
+ MMAPP_OWN_SQLITE_IMPORT_CLI_ONLY: String(sqliteImportCliOnly),
+ MMAPP_OWN_LEGACY_BGP_ONLY: String(legacyBgpOnly),
+ ...(routingOriginalEffects ? { MMAPP_OWN_ROUTING_ORIGINAL_EFFECTS: 'true' } : {}),
+ MMAPP_OWN_ROUTING_CONTROLLER_FAILOVER_ONLY: String(routingControllerFailoverOnly),
+ DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,
+ DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
+ MCP_STATE_DIR: join(directory, 'state'), AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: 'mcp-integration-test-only', MMAPP_TEST_WG_EXPORT_ONLY: String(wireguardExport),
+ MCP_PUBLIC_URL: 'http://localhost:8000/mcp', NODE_ENV: 'test', PATH: testPath, NODE_OPTIONS: pollMemory ? '' : process.env.NODE_OPTIONS, MMAPP_OWN_PRINCIPAL_SECURITY_SOURCE: String(principalSecuritySource), MMAPP_OWN_POLL_JOURNAL_SNAPSHOT: String(pollJournalSnapshot), MMAPP_OWN_POLL_MEMORY: String(pollMemory), MMAPP_OWN_POLL_BOOTSTRAP: String(pollMemoryBootstrap), MMAPP_OWN_POLL_COST_DIAGNOSTICS: String(pollMemoryCost), MMAPP_OWN_POLL_ARCHIVE_CLAIM_LOSS: String(pollArchiveClaimLoss), MMAPP_OWN_POLL_ARCHIVE_HISTORY: String(pollArchiveHistory), MMAPP_OWN_POLL_ARCHIVE_COLD: String(pollArchiveCold), MMAPP_OWN_POLL_ARCHIVE_LOST_ACK: String(pollArchiveLostAck), MMAPP_OWN_POLL_TERMINAL_ARCHIVE: String(pollTerminalArchive), MMAPP_OWN_POLL_ARCHIVE_SCHEMA: String(pollArchiveSchema), MMAPP_OWN_TELEMETRY_SETTINGS_CONFIGURATION: String(telemetrySettingsConfiguration), MMAPP_OWN_ROUTING_RESERVATION_SCHEMA: String(routingReservationSchema), MMAPP_OWN_ROUTING_FORWARD_ROUNDS: String(routingForwardRounds), MMAPP_OWN_FLOW_ACTIVE_SERVICES: String(flowActiveServices), MMAPP_OWN_FLOW_ACTIVE_REBUILD: String(flowActiveRebuild), MMAPP_OWN_FLOW_QUALITY: String(flowQuality), MMAPP_OWN_FLOW_WORKER_IPC: String(flowWorkerIpc), MMAPP_OWN_MANUAL_UPTIME: String(manualUptime), MMAPP_OWN_MANUAL_PING_GROUP: String(manualPingGroup), MMAPP_OWN_MANUAL_TRAFFIC: String(manualTraffic), MMAPP_OWN_MANUAL_API_PING: String(manualApiPing), MMAPP_OWN_SIMPLE_SPEED: String(simpleSpeed), MMAPP_OWN_SIMPLE_SPEED_CHR: String(simpleSpeedChr), MMAPP_OWN_DIAGNOSTIC_CANCEL_HOST: String(diagnosticCancelHost), MMAPP_OWN_OPERATOR_DOCKER_SQL: String(operatorDockerSql), MMAPP_OWN_PUBLIC_REGISTRY_METADATA: String(publicRegistryMetadata), MMAPP_OWN_OPERATOR_PEER_METADATA: String(operatorPeerMetadata), MMAPP_OWN_EXTERNAL_PEER_METADATA: String(externalPeerMetadata), MMAPP_OWN_BANDWIDTH_EXTERNAL_REGISTRY: String(externalPeerMetadata || operatorPeerMetadata || publicRegistryMetadata || operatorDockerSql || mcpSpeedOriginal || bandwidthSpeedWorkflow || bandwidthExternalRegistry), MMAPP_OWN_BANDWIDTH_SPEED_WORKFLOW: String(bandwidthSpeedWorkflow), MMAPP_OWN_REST_SPEED_ORIGINAL: String(restSpeedOriginal), MMAPP_OWN_MCP_OPERATION_ORIGIN: String(mcpOperationOrigin), MMAPP_OWN_PROBE_OPERATION_RETIREMENT: String(probeOperationRetirement), MMAPP_OWN_MCP_SPEED_ORIGINAL: String(mcpSpeedOriginal), MMAPP_OWN_SCHEDULED_SPEED_ORIGINAL: String(scheduledSpeedOriginal), MMAPP_TEST_ROUTER_GUARD_OWNED: String(routerConfigurationGuard), MMAPP_TEST_ROUTER_GUARD_CLUSTER_DISPOSABLE: String(routerConfigurationGuard), MMAPP_TEST_ROUTER_GUARD_ADMIN_URL: routerConfigurationGuard ? `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres` : '', MMAPP_OWN_BANDWIDTH_ADMISSION: String(externalPeerMetadata || operatorPeerMetadata || publicRegistryMetadata || operatorDockerSql || mcpOperationOrigin || mcpSpeedOriginal || scheduledSpeedOriginal || bandwidthSpeedWorkflow || restSpeedOriginal || bandwidthExternalRegistry || operationLocks || serviceExecutionOrigin || bandwidthAdmission || bandwidthControlSource || bandwidthNodeRegistry || bandwidthNodeSource), MMAPP_OWN_BANDWIDTH_RESTORE: String((bandwidthAdmission || bandwidthControlSource || bandwidthNodeRegistry || bandwidthNodeSource) && process.argv.includes('--restore')), MMAPP_OWN_IPSEC_EXPORT_HTTP: String(ipsecExportHttp), MMAPP_OWN_IPSEC_EXPORT_JOURNAL: String(ipsecExportJournal), MMAPP_OWN_SQL_DB: 'postgres', MMAPP_OWN_PROBE_LEGACY_ORPHANS: String(probeLegacyOrphans), MMAPP_OWN_PROBE_STORAGE_HISTORY: String(probeStorageHistory), MMAPP_OWN_PROBE_STORAGE_FRESH: String(probeStorageFresh), MMAPP_OWN_PROBE_STORAGE_JOURNAL: String(probeStorageJournal || probeStorageFresh), MMAPP_OWN_CONTROLLED_SCHEMA_REFERENCE: String(controlledSchemaReference), MMAPP_OWN_CONTROLLED_MIGRATIONS: String(controlledMigrations), MMAPP_OWN_DATABASE_SCHEMA_CONTROL: String(databaseSchemaControl), MMAPP_OWN_MIGRATION_DATA_INVENTORY: String(migrationDataInventory), MMAPP_OWN_MIGRATION_SCHEMA_INVENTORY: String(migrationSchemaInventory), MMAPP_OWN_ROUTING_NETWORK_NATIVE: String(routingNetworkNative), MMAPP_OWN_ROUTING_RESERVATIONS: String(routingReservations || routingReservationRuntime), MMAPP_OWN_COLLECTOR_PARTITION_WRITERS: String(collectorPartitionWriters), MMAPP_OWN_SERVER_POLL_STORAGE_FRESH: String(serverPollStorageFresh), MMAPP_OWN_SERVER_POLL_STORAGE: String(serverPollStorage), MMAPP_OWN_SERVER_POLL_DURABLE: String(serverPollDurable), MMAPP_OWN_ROUTING_RECOVERY_AUTHORITY: String(routingRecoveryAuthority), MMAPP_OWN_LEGACY_FLOW_REBUILD: String(legacyFlowRebuild), MMAPP_OWN_PROBE_JOURNAL: String(probeJournal), MMAPP_MODULE_COMPLETION_ONLY: String(moduleCompletion), MMAPP_MODULE_COMPLETION_TARGET: completionTarget, MMAPP_OWN_FLOW_HOST_KEYS: String(flowHostKeys), MMAPP_OWN_MCP_FLOW_REBUILD: String(flowRebuildMcp), MMAPP_OWN_FLOW_WRITES: String(flowWrites), MMAPP_OWN_FLOW_REBUILD: String(flowRebuild) },
+ })
+ child.once('error', reject); child.once('exit', code => resolve(code ?? 1))
+ })
+ exitCode = result
+ if (result === 0 && restoreQuarantineOnly) console.log('Restore quarantine: focused real PostgreSQL restore scenario complete')
+ else if (result === 0 && !acceptanceShard && !regressionOnly && !profilesOnly && !usersBindings && !bridgeVlanConfiguration && !protocolLimits && !pollMemory && !principalSecuritySource && !pollJournalSnapshot && !pollArchiveSchema && !telemetrySettingsConfiguration && !routingReservationSchema && !routingForwardRounds && !flowActiveServices && !flowActiveRebuild && !flowQuality && !flowWorkerIpc && !manualUptime && !manualPingGroup && !manualTraffic && !manualApiPing && !simpleSpeed && !simpleSpeedChr && !externalPeerMetadata && !operatorPeerMetadata && !publicRegistryMetadata && !operatorDockerSql && !mcpOperationOrigin && !mcpSpeedOriginal && !routerConfigurationGuard && !scheduledSpeedOriginal && !bandwidthSpeedWorkflow && !restSpeedOriginal && !operationLocks && !serviceExecutionOrigin && !bandwidthNodeSource && !bandwidthNodeRegistry && !bandwidthExternalRegistry && !bandwidthControlSource && !bandwidthAdmission && !probeLegacyOrphans && !probeStorageJournal && !probeStorageHistory && !probeJournal && !chr && !flowWrites && !flowRebuild && !flowRebuildMcp && (process.argv.includes('--restore') || process.env.MMAPP_PG_CLIENT_BIN)) {
+ exitCode = await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, ['--import', 'tsx', 'src/modules/mcp/database-restore.test.ts'], {
+ cwd: new URL('../', import.meta.url), stdio: 'inherit', env: { ...process.env,
+ DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,
+ DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
+ MCP_STATE_DIR: join(directory, 'state'), AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: 'mcp-integration-test-only',
+ MCP_PUBLIC_URL: 'http://localhost:8000/mcp', NODE_ENV: 'test', PATH: testPath,
+ MMAPP_OWN_SQL_DB: 'postgres', MMAPP_OWN_TERMINAL_RESTORE: 'true', MMAPP_OWN_TERMINAL_DATA_EQUIVALENCE: String(migrationDataInventory) },
+ })
+ child.once('error', reject); child.once('exit', code => resolve(code ?? 1))
+ })
+ }
+ else if (result === 0 && pollArchiveSchema) console.log('Poll archive schema: owned nonempty40 preservation, numbered41 and structural refusal guards; no positive MCP archive claim')
+ else if (result === 0 && telemetrySettingsConfiguration) console.log('Telemetry settings: genuine MCP/SQL configuration binding, collector metadata tolerated; no native or external sources')
+ else if (result === 0 && routingReservationSchema) console.log('Routing reservation numbered0040: ownSQL fresh/legacy/manual preservation; no READY, backfill, capabilities or public native activation')
+ else if (result === 0 && routingOriginalEffects) console.log('Routing original effects: approved manual revision 2 and original effects checked against disposable PostgreSQL and synthetic RouterOS HTTP')
+ else if (result === 0 && routingForwardRounds) console.log('Routing forward rounds: genuine approved running CONFIG_APPLIED, shared cumulative native budget; logs/security/autoRecovery remain unaccepted')
+ else if (result === 0 && flowActiveServices) console.log('Flow active settings/purge: production services and main Worker; disposable SQL/localhost only')
+ else if (result === 0 && flowActiveRebuild) console.log(process.env.MMAPP_OWN_FLOW_ACTIVE_READ === 'true'
+ ? 'Flow active analytics: production UDP Worker, REST and MCP; disposable SQL/localhost only'
+ : 'Flow active rebuild: production shared service and genuine Worker drain; disposable SQL/localhost only')
+ else if (result === 0 && flowQuality) console.log('Flow quality: production engine and genuine receipt SQL, explicit COMMIT ACK fault on owned cluster only; no CHR/whole-installation RAM claim')
+ else if (result === 0 && flowWorkerIpc) console.log('Flow worker IPC: production main/Worker lifecycle, localhost UDP, owned PostgreSQL only; real CHR and concurrent-spawn acceptance remain separate')
+ else if (result === 0 && manualUptime) console.log('Manual uptime: full resources then ping, actual shared service and deferred alerts; owned PostgreSQL/localhost only')
+ else if (result === 0 && manualPingGroup) console.log('Manual Ping group: existing normalization/mutex/samples/conditional global alerts; owned PostgreSQL/localhost only')
+ else if (result === 0 && manualTraffic) console.log('Manual traffic: full scheduler/events/settings/retention/alerts shared by REST and MCP; owned PostgreSQL/localhost only')
+ else if (result === 0 && manualApiPing) console.log('Manual API Ping: ordinary global collector with alerts hook, own PostgreSQL and localhost only')
+ else if (result === 0 && simpleSpeed) console.log('Simple RouterOS speed: public MCP/REST, ordinary shared service, own PostgreSQL and localhost RouterOS only')
+ else if (result === 0 && simpleSpeedChr) console.log('Simple RouterOS speed: own PostgreSQL, real two-CHR bounded test and ordinary MCP approval; no router configuration changes')
+ else if (result === 0 && externalPeerMetadata) console.log('Guarded peer sources: actual managed/external SQL-owner and localhost license composition; Q/catalog attestation synthetic, full operator window remains open')
+ else if (result === 0 && operatorPeerMetadata) console.log('Operator peer metadata: actual managed endpoint SQL and genuine localhost license origin; synthetic Q, external metadata and full operator window remain open')
+ else if (result === 0 && publicRegistryMetadata) console.log('Public registry metadata: actual owned PostgreSQL and same physical lease; no secret/Q/native/write authority or backend-window acceptance')
+ else if (result === 0 && operatorDockerSql) console.log('Operator Docker SQL: actual owned PostgreSQL with mocked Docker HTTP only; not a real Docker/backend-window acceptance')
+ else if (result === 0 && ordinaryOperationRetirement) console.log('Ordinary operation retirement: owned actual logs-settings apply and worker')
+ else if (result === 0 && pollOperationRetirement) console.log('Poll operation retirement: owned authenticated historical fixtures and current reader/GC')
+ else if (result === 0 && probeOperationRetirement) console.log('Diagnostic retirement: actual owned worker tick, PostgreSQL and product read/replay; no live scheduling')
+ else if (result === 0 && mcpOperationOrigin) console.log('MCP operation root: owned PostgreSQL ordinary runner provenance; no restore/recovery, global writer activation, CHR or deployment')
+ else if (result === 0 && mcpSpeedOriginal) console.log('MCP speed: genuine trusted service context with real connection/grant/SQL, host receipt and localhost native; synthetic Q/mapping; not a public MCP runner/action acceptance')
+ else if (result === 0 && routerConfigurationGuard) console.log('Router configuration guard: dedicated owned databases/roles and localhost native fixture; no application migration, production activation or real CHR')
+ else if (result === 0 && scheduledSpeedOriginal) console.log('Scheduled speed original: genuine fixed-job scheduler authority, actual owned SQL and localhost read-only TCP; no legacy collector, native bandwidth, history or runtime activation')
+ else if (result === 0 && bandwidthSpeedWorkflow) console.log('Whole speed workflow: actual REST/JWT, signed v2 control SQL, native fixture HTTP and history; synthetic Q/mapping; no runtime activation or real CHR')
+ else if (result === 0 && restSpeedOriginal) console.log('REST speed original profile: owned application SQL and localhost read-only TCP; no bandwidth POST, history, runtime activation or real CHR')
+ else if (result === 0 && operationLocks) console.log('Operation lock profile: owned PostgreSQL/localhost fixtures; no terminal restore or real CHR')
+ else if (result === 0 && serviceExecutionOrigin) console.log('Service origin profile: owned SQL only; no terminal restore or native networking')
+ else if (result === 0 && (bandwidthAdmission || bandwidthControlSource || bandwidthNodeRegistry || bandwidthExternalRegistry || bandwidthNodeSource)) console.log('Bandwidth proposal profile: dedicated owned data round-trip only; no normal enrollment or production restore claim')
+ else if (result === 0 && (probeLegacyOrphans || probeStorageJournal || probeStorageHistory || probeJournal)) console.log('Legacy-only profile: positive current-version terminal restore belongs to --probe-storage-fresh; no migration marker fabricated')
+ else if (result === 0 && profilesOnly) console.log(profilesGroup ? 'Profiles-only fixed group: ' + profilesGroup + '; partial matrix on its own fresh database' : 'Profiles-only: running the unchanged complete regression list plus mandatory test:logs:pg on one fresh owned database')
+ else if (result === 0 && serverPollStorageFresh && process.env.MMAPP_OWN_SERVER_POLL_SETTINGS_EPOCH === 'true') console.log('Targeted settings epoch upgrade and actual pg_dump/restore accepted; full primary/poll-storage terminal restore not run')
+ else if (result === 0 && !chr && !flowWrites && !flowRebuild && !flowRebuildMcp) console.log('Terminal restore not run: use --restore with PostgreSQL client tools on PATH, or set MMAPP_PG_CLIENT_BIN')
+ if (exitCode === 0 && (serverPollStorage || serverPollStorageFresh) && (process.argv.includes('--restore') || process.env.MMAPP_PG_CLIENT_BIN)) {
+ exitCode = await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, ['--import', 'tsx', 'src/services/server-poll-storage-restore.sql.test.ts'], {
+ cwd: new URL('../', import.meta.url), stdio: 'inherit', env: { ...process.env,
+ DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`,
+ DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
+ MCP_STATE_DIR: join(directory, 'state'), AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: 'mcp-integration-test-only',
+ NODE_ENV: 'test', PATH: testPath, MMAPP_OWN_SERVER_POLL_STORAGE_RESTORE: 'true' },
+ })
+ child.once('error', reject); child.once('exit', code => resolve(code ?? 1))
+ })
+ }
+ if (exitCode === 0 && process.argv.includes('--all')) {
+ if (!process.env.npm_execpath) throw new Error('Run --all through npm run test:mcp:pg:all')
+ const database = 'mm_accept_166_' + Date.now()
+ await postgres.createDatabase(database)
+ const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'))
+ let profiles = packageJson.scripts['test:all'].split(/\s*&&\s*/).map(command => command.replace('npm run ', ''))
+ if (process.argv.includes('--remaining')) profiles = profiles.slice(profiles.indexOf('test:traffic-flow'))
+ const selected = process.argv.find(value => value.startsWith('--profile='))?.slice('--profile='.length)
+ if (selected) {
+ if (![...profiles, 'test:logs:pg', 'test:vrf:production'].includes(selected)) throw new Error('Unknown regression profile')
+ profiles = [selected]
+ }
+ const failures = []
+ const requiredProfiles = regressionOnly ? [selected] : regressionProfiles(profiles, selected, profilesGroup)
+ for (const script of requiredProfiles) {
+ const startedAt = Date.now()
+ console.log('Regression profile started:', script)
+ if (script === 'test:vrf:production') {
+ vrfChildrenExitConfirmed = false
+ const receipt = await runOwnedVrfProductionProfile({ directory, database, databaseUrl: `postgresql://mcp_test:${password}@127.0.0.1:${port}/${database}` })
+ vrfChildrenExitConfirmed = receipt.childExitConfirmed
+ if (!receipt.accepted) failures.push(script)
+ console.log('Regression profile finished:', JSON.stringify({ profile: script, passed: receipt.accepted, durationMs: Date.now() - startedAt }))
+ if (!vrfChildrenExitConfirmed) break
+ continue
+ }
+ const status = await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, [process.env.npm_execpath, 'run', script], {
+ cwd: new URL('../', import.meta.url), stdio: 'inherit', env: { ...process.env,
+ DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/${database}`,
+ DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
+ MMAPP_OWN_SQL_DB: database, MCP_STATE_DIR: join(directory, 'regression-state'),
+ REQUIRE_TEST_POSTGRES: '1',
+ LOGS_PERFORMANCE: process.argv.includes('--performance') ? '1' : '0',
+ AUTH_REQUIRED: 'false', NODE_ENV: 'test' },
+ })
+ child.once('error', reject); child.once('exit', code => resolve(code ?? 1))
+ })
+ if (status !== 0) failures.push(script)
+ console.log('Regression profile finished:', JSON.stringify({ profile: script, passed: status === 0, durationMs: Date.now() - startedAt }))
+ }
+ exitCode = failures.length ? 1 : 0
+ console.log('Regression failed profiles:', failures.length ? failures.join(', ') : 'none')
+ if (profilesOnly) console.log('Profiles-only matrix result:', exitCode === 0 ? 'PASS' : 'FAIL', 'profiles=' + requiredProfiles.length, ...(profilesGroup ? ['group=' + profilesGroup, 'completeMatrix=false'] : []), 'primaryIntegration=NOT_RUN terminalRestore=NOT_RUN fullAcceptance=false')
+ }
+} catch (error) {
+ exitCode = 1
+ console.error(error)
+} finally {
+ await postgres.stop()
+ const rel = relative(resolve(tmpdir()), resolve(directory))
+ if (!rel || rel.startsWith('..') || isAbsolute(rel) || !rel.startsWith('mm-mcp-test-')) throw new Error('Unsafe test cleanup path')
+ if (vrfChildrenExitConfirmed) await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 250 })
+ else console.error('VRF child exit unconfirmed; own test directory retained')
+ process.exitCode = exitCode
+}
+// embedded-postgres installs a beforeExit hook that otherwise forces exit(0).
+process.exit(exitCode)
diff --git a/backend/scripts/test-routing-controller-baseline.mjs b/backend/scripts/test-routing-controller-baseline.mjs
new file mode 100644
index 00000000..2ae3d41f
--- /dev/null
+++ b/backend/scripts/test-routing-controller-baseline.mjs
@@ -0,0 +1,75 @@
+import EmbeddedPostgres from 'embedded-postgres'
+import { createRequire } from 'node:module'
+import { mkdir, mkdtemp, readdir, readFile, writeFile, cp, rm } from 'node:fs/promises'
+import { resolve, join, relative, dirname, basename } from 'node:path'
+import { randomBytes, createHash } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn } from 'node:child_process'
+
+const modes = ['--default-scoped', '--main-only', '--control-path-context', '--scoped-bare-readback', '--scoped-resume-forward', '--scoped-inverse-expiry', '--scoped-inverse-post-probe-expiry', '--scoped-inverse-checkpoint-drift', '--scoped-inverse-route-effects', '--scoped-inverse-effects-checkpoint-drift', '--scoped-inverse-lost-ack', '--manual-forward-expiry', '--manual-forward-post-intent-expiry']
+const allowed = new Set([...modes, '--check-only']), args = process.argv.slice(2)
+const selected = modes.filter(flag => args.includes(flag))
+if (args.some(arg => !allowed.has(arg)) || new Set(args).size !== args.length || selected.length > 1) throw new Error('Usage: node backend/scripts/test-routing-controller-baseline.mjs [' + modes.join(' | ') + '] [--check-only]')
+const root = resolve(import.meta.dirname, '../..'), require = createRequire(import.meta.url), ts = require('typescript')
+const mode = selected[0]?.slice(2) ?? 'main-and-forward-rounds'
+const target = join(root, 'backend/src/modules/mcp/routing-controller-active-writer.ts')
+await readFile(target)
+await readFile(join(root, 'backend/src/modules/mcp/routing-main-transition.ts'))
+await readFile(join(root, 'backend/src/modules/mcp/routing-controller-baseline-acceptance.ts'))
+if (process.argv.includes('--check-only')) { console.log(JSON.stringify({ mode, sourcePresent: true, acceptanceExecuted: false, productionApplied: false })); process.exit(0) }
+await mkdir(join(root, 'tmp'), { recursive: true })
+const ownedPrefix = 'mm-mcp-test-routing-controller-baseline-'
+const directory = await mkdtemp(join(root, 'tmp', ownedPrefix)), output = join(directory, 'dist'), sourcePins = []
+const hash = buffer => createHash('sha256').update(buffer).digest('hex')
+async function compile(sourceDirectory) {
+ for (const entry of await readdir(sourceDirectory, { withFileTypes: true })) {
+ const path = join(sourceDirectory, entry.name)
+ if (entry.isDirectory()) { await compile(path); continue }
+ const name = relative(join(root, 'backend/src'), path).replaceAll('\\', '/')
+ if (name.endsWith('.test.ts') || name.endsWith('.d.ts')) continue
+ const bytes = await readFile(path), emitted = join(output, name.replace(/\.ts$/, '.js'))
+ await mkdir(dirname(emitted), { recursive: true })
+ await writeFile(emitted, name.endsWith('.ts') ? ts.transpileModule(bytes.toString('utf8'), { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext, esModuleInterop: true, resolveJsonModule: true } }).outputText : bytes)
+ sourcePins.push({ path: name, sourceSha256: hash(bytes), emittedSha256: hash(await readFile(emitted)) })
+ }
+}
+await writeFile(join(directory, 'package.json'), '{"type":"module"}')
+await compile(join(root, 'backend/src'))
+if (mode === 'scoped-resume-forward') {
+ for (const file of ['mcp-step-journal.mjs', 'mcp-routing-forward-observer.mjs']) {
+ await cp(new URL('./acceptance/' + file, import.meta.url), join(directory, file))
+ }
+}
+await cp(join(root, 'backend/drizzle'), join(directory, 'drizzle'), { recursive: true })
+await writeFile(join(directory, 'snapshot-manifest.json'), JSON.stringify({ mode, productionApplied: false, wholeMutableWorktreeFrozen: false, sourcePins }, null, 2))
+const listener = createServer()
+await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve))
+const port = listener.address().port
+await new Promise(resolve => listener.close(resolve))
+const password = randomBytes(24).toString('hex')
+const postgres = new EmbeddedPostgres({ databaseDir: join(directory, 'pg'), port, user: 'mcp_test', password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', '127.0.0.1'], onLog: () => {}, onError: () => {} })
+let exitCode = 1, log = ''
+console.log(`Owned routing baseline acceptance: ${directory}; mode=${mode}`)
+try {
+ await postgres.initialise(); await postgres.start()
+ const retained = Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'PATH', 'Path', 'LOCALAPPDATA', 'APPDATA'].filter(key => process.env[key]).map(key => [key, process.env[key]]))
+ exitCode = await new Promise((resolve, reject) => {
+ const child = spawn(process.execPath, [join(output, 'test/routing-controller-baseline-acceptance-main.js')], { cwd: directory, windowsHide: true,
+ env: { ...retained, DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/postgres`, DATABASE_PATH: join(directory, 'no-legacy.sqlite'),
+ MCP_STATE_DIR: join(directory, 'state'), NODE_ENV: 'test', AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: 'routing-baseline-test-only', MCP_PUBLIC_URL: 'http://localhost:8000/mcp',
+ MMAPP_ROUTING_BASELINE_OWN_SQL: 'true', MMAPP_ROUTING_BASELINE_MODE: mode } })
+ child.stdout.on('data', bytes => { process.stdout.write(bytes); log += bytes }); child.stderr.on('data', bytes => { process.stderr.write(bytes); log += bytes })
+ child.once('error', reject); child.once('exit', code => resolve(code ?? 1))
+ })
+} finally {
+ await writeFile(join(directory, 'runtime.log'), log)
+ // embedded-postgres waits for a new exit event; avoid waiting again if its
+ // owned child has already exited. This never targets another database.
+ if (postgres.process?.exitCode === null) await postgres.stop()
+ if (dirname(resolve(directory)) !== resolve(root, 'tmp') || !basename(directory).startsWith(ownedPrefix)) throw new Error('Owned routing cleanup boundary changed')
+ await rm(join(directory, 'pg'), { recursive: true, force: true, maxRetries: 20, retryDelay: 100 })
+ console.log('Owned routing PostgreSQL stopped and its data removed; snapshot/log evidence retained')
+}
+console.log(JSON.stringify({ runDirectory: directory, mode, exitCode, productionApplied: false }))
+process.exitCode = exitCode
diff --git a/backend/scripts/test-server-poll-approval-owned.mjs b/backend/scripts/test-server-poll-approval-owned.mjs
new file mode 100644
index 00000000..35cb769b
--- /dev/null
+++ b/backend/scripts/test-server-poll-approval-owned.mjs
@@ -0,0 +1,17 @@
+/** Fixed local delayed-approval acceptance; only the original guarded runner
+ * creates/removes a disposable PostgreSQL. No target or restore arguments. */
+import assert from 'node:assert/strict'
+import {spawn} from 'node:child_process'
+import {dirname,resolve} from 'node:path'
+import {fileURLToPath} from 'node:url'
+assert.equal(process.argv.length,2)
+const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..')
+const environment={...process.env,NODE_ENV:'test',MMAPP_OWN_SERVER_POLL_DELAYED_APPROVAL:'true',
+ MMAPP_OWN_SERVER_POLL_HTTP_ROUTE:'false',MMAPP_OWN_SERVER_POLL_SETTINGS_EPOCH:'false'}
+// This fixed profile never requests the original runner's full terminal restore.
+delete environment.MMAPP_PG_CLIENT_BIN
+const child=spawn(process.execPath,[resolve(root,'backend/scripts/test-mcp-postgres.mjs'),'--server-poll-storage-fresh'],{
+ cwd:root,windowsHide:true,stdio:'inherit',env:environment,
+})
+const code=await new Promise((done,reject)=>{child.once('error',reject);child.once('exit',code=>done(code??1))})
+process.exitCode=code
diff --git a/backend/scripts/test-server-poll-atomic-owned.mjs b/backend/scripts/test-server-poll-atomic-owned.mjs
new file mode 100644
index 00000000..a350fe89
--- /dev/null
+++ b/backend/scripts/test-server-poll-atomic-owned.mjs
@@ -0,0 +1,12 @@
+/** Fixed disposable PostgreSQL profile, no target/deploy/restore arguments. */
+import assert from 'node:assert/strict'
+import {spawn} from 'node:child_process'
+import {dirname,resolve} from 'node:path'
+import {fileURLToPath} from 'node:url'
+assert.equal(process.argv.length,2)
+const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..')
+const environment={...process.env,NODE_ENV:'test',MMAPP_OWN_SERVER_POLL_ATOMIC_MAINTENANCE:'true',MMAPP_OWN_SERVER_POLL_DELAYED_APPROVAL:'false',MMAPP_OWN_SERVER_POLL_HTTP_ROUTE:'false',MMAPP_OWN_SERVER_POLL_SETTINGS_EPOCH:'false'}
+delete environment.MMAPP_PG_CLIENT_BIN
+const child=spawn(process.execPath,[resolve(root,'backend/scripts/test-mcp-postgres.mjs'),'--server-poll-storage-fresh'],{cwd:root,windowsHide:true,stdio:'inherit',env:environment})
+const code=await new Promise((done,reject)=>{child.once('error',reject);child.once('exit',code=>done(code??1))})
+process.exitCode=code
diff --git a/backend/scripts/test-server-poll-http-owned.mjs b/backend/scripts/test-server-poll-http-owned.mjs
new file mode 100644
index 00000000..9ca5aeaa
--- /dev/null
+++ b/backend/scripts/test-server-poll-http-owned.mjs
@@ -0,0 +1,13 @@
+/** Owns no application resources directly: the original guarded PostgreSQL
+ * runner creates/removes its fresh cluster and supplies every connection. */
+import assert from 'node:assert/strict'
+import {spawn} from 'node:child_process'
+import {dirname,resolve} from 'node:path'
+import {fileURLToPath} from 'node:url'
+assert.equal(process.argv.length,2,'HTTP poll acceptance takes no target or connection arguments')
+const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..')
+const child=spawn(process.execPath,[resolve(root,'backend/scripts/test-mcp-postgres.mjs'),'--server-poll-storage-fresh'],{
+ cwd:root,windowsHide:true,stdio:'inherit',env:{...process.env,NODE_ENV:'test',MMAPP_OWN_SERVER_POLL_HTTP_ROUTE:'true'},
+})
+const code=await new Promise((done,reject)=>{child.once('error',reject);child.once('exit',code=>done(code??1))})
+process.exitCode=code
diff --git a/backend/scripts/test-server-poll-settings-epoch-owned.mjs b/backend/scripts/test-server-poll-settings-epoch-owned.mjs
new file mode 100644
index 00000000..b0fcebb0
--- /dev/null
+++ b/backend/scripts/test-server-poll-settings-epoch-owned.mjs
@@ -0,0 +1,13 @@
+/** Fixed-target numbered migration and restore acceptance. Only the existing guarded runner creates
+ * the disposable PostgreSQL; no connection/remote/restore arguments accepted. */
+import assert from 'node:assert/strict'
+import {spawn} from 'node:child_process'
+import {dirname,resolve} from 'node:path'
+import {fileURLToPath} from 'node:url'
+assert.equal(process.argv.length,2,'Settings epoch acceptance takes no target or connection arguments')
+const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..')
+const child=spawn(process.execPath,[resolve(root,'backend/scripts/test-mcp-postgres.mjs'),'--server-poll-storage-fresh'],{
+ cwd:root,windowsHide:true,stdio:'inherit',env:{...process.env,NODE_ENV:'test',MMAPP_OWN_SERVER_POLL_SETTINGS_EPOCH:'true',MMAPP_OWN_SERVER_POLL_HTTP_ROUTE:'false'},
+})
+const code=await new Promise((done,reject)=>{child.once('error',reject);child.once('exit',code=>done(code??1))})
+process.exitCode=code
diff --git a/backend/scripts/test-source-capture-adopted-postgres.mjs b/backend/scripts/test-source-capture-adopted-postgres.mjs
new file mode 100644
index 00000000..90278d1a
--- /dev/null
+++ b/backend/scripts/test-source-capture-adopted-postgres.mjs
@@ -0,0 +1,87 @@
+// Isolated regression only: no application config, configured DB URL or startup.
+import { mkdtemp, rm, readFile, writeFile, mkdir } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join, resolve, relative, isAbsolute, basename } from 'node:path'
+import { fileURLToPath, pathToFileURL } from 'node:url'
+import { createRequire } from 'node:module'
+import { randomBytes, createHash } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn } from 'node:child_process'
+
+const args = process.argv.slice(2)
+if (args.length > 1 || args[0] && !args[0].startsWith('--source-root=')) throw Error('Only --source-root=PATH review override is supported')
+const sourceRoot = args[0] ? resolve(args[0].slice('--source-root='.length)) : fileURLToPath(new URL('../../', import.meta.url))
+const require = createRequire(join(sourceRoot, 'backend/package.json'))
+const { default: EmbeddedPostgres } = await import(pathToFileURL(require.resolve('embedded-postgres')).href)
+const sources = ['backend/src/services/partition-write-transaction.ts', 'backend/src/db/sqlite-import-control-writes.ts',
+ 'backend/src/db/migration-schema-inventory.ts', 'backend/src/db/migration-data-inventory.ts', 'backend/src/db/schema.ts', 'backend/src/db/index.ts']
+const ownFiles = [fileURLToPath(import.meta.url), fileURLToPath(new URL('../src/db/database-source-capture-adopted.sql-helper.ts', import.meta.url)),
+ fileURLToPath(new URL('../src/db/database-source-capture-adopted.sql.test.ts', import.meta.url))]
+async function pins() {
+ const files = [...sources.map(path => ({ path, absolute: join(sourceRoot, path) })), ...ownFiles.map(absolute => ({ path: 'executed-fixture/' + basename(absolute), absolute }))]
+ return Promise.all(files.map(async ({ path, absolute }) => ({ path, sha256: createHash('sha256').update(await readFile(absolute)).digest('hex') })))
+}
+const before = await pins()
+const directory = await mkdtemp(join(tmpdir(), 'mm-source-capture-'))
+const password = randomBytes(24).toString('hex'), ownerToken = randomBytes(24).toString('hex')
+let postgres, failure, phase = 'port-and-owner-manifest', failedPhase, childExitCode = 1, unchanged = false, clusterStopped = false, directoryRemoved = false
+try {
+ const listener = createServer()
+ await new Promise((done, reject) => { listener.once('error', reject); listener.listen(0, '127.0.0.1', done) })
+ const port = listener.address().port
+ await new Promise((done, reject) => listener.close(error => error ? reject(error) : done()))
+ await writeFile(join(directory, 'owned-source-capture.json'), JSON.stringify({ ownerToken, port, username: 'source_operator' }), { flag: 'wx' })
+ postgres = new EmbeddedPostgres({ databaseDir: join(directory, 'pg'), port, user: 'source_operator', password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', '127.0.0.1'], onLog: () => {}, onError: () => {} })
+ phase = 'initialise-owned-postgres'; await postgres.initialise()
+ phase = 'start-owned-postgres'; await postgres.start()
+ phase = 'owned-sql-child'
+ childExitCode = await new Promise((done, reject) => {
+ const child = spawn(process.execPath, ['--import', pathToFileURL(require.resolve('tsx')).href, ownFiles[2]], {
+ cwd: directory, windowsHide: true, stdio: 'inherit', env: {
+ ...Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'PATH', 'Path'].filter(key => process.env[key]).map(key => [key, process.env[key]])),
+ MMAPP_OWN_SOURCE_CAPTURE: 'true', MMAPP_OWN_SOURCE_CAPTURE_DIRECTORY: directory, MMAPP_OWN_SOURCE_CAPTURE_ROOT: sourceRoot,
+ MMAPP_OWN_SOURCE_CAPTURE_TOKEN: ownerToken, MMAPP_OWN_SOURCE_CAPTURE_ADMIN_URL: `postgresql://source_operator:${password}@127.0.0.1:${port}/postgres`,
+ },
+ })
+ // No child subprocesses are spawned by the SQL fixture. Kill only this
+ // exact Node child on timeout, then await exit before stopping own cluster.
+ let timedOut = false
+ const timer = setTimeout(() => { timedOut = true; child.kill(); }, 120000)
+ child.once('error', error => { clearTimeout(timer); reject(error) })
+ child.once('exit', code => { clearTimeout(timer); done(timedOut ? 1 : code ?? 1) })
+ })
+} catch (error) { failure = error; failedPhase = phase }
+finally {
+ try {
+ if (postgres) await postgres.stop()
+ clusterStopped = true
+ } catch (error) { failure ??= error }
+ // Delete only when stop succeeded, retaining failed-stop files for diagnosis.
+ if (clusterStopped) {
+ try {
+ const root = resolve(tmpdir()), target = resolve(directory), rel = relative(root, target)
+ if (!rel || rel.startsWith('..') || isAbsolute(rel) || !basename(target).startsWith('mm-source-capture-')) throw Error('Unsafe owned source capture cleanup path')
+ await rm(target, { recursive: true, force: true }); directoryRemoved = true
+ } catch (error) { failure ??= error }
+ }
+ try {
+ const after = await pins()
+ unchanged = JSON.stringify(before) === JSON.stringify(after)
+ await mkdir(join(sourceRoot, 'tmp'), { recursive: true })
+ const evidencePath = join(sourceRoot, 'tmp', basename(directory) + '-pins.json')
+ await writeFile(evidencePath, JSON.stringify({ format: 'adopted-source-capture-owned-pins-v1', date: new Date().toISOString(),
+ before, after, unchanged, childExitCode, clusterStopped, directoryRemoved,
+ allWriterDrainAuthenticated: false, sourceGenerationAuthenticated: false, readyAuthorized: false }, null, 2))
+ console.log('Owned source capture evidence:', evidencePath)
+ } catch (error) { failure ??= error }
+}
+console.log(JSON.stringify({ childExitCode, sourcePinsUnchanged: unchanged, clusterStopped, directoryRemoved,
+ allWriterDrainAuthenticated: false, sourceGenerationAuthenticated: false, readyAuthorized: false }))
+// Never print connection strings or credentials in fixture error output.
+if (failure) {
+ const text = String(failure)
+ const knownCode = ['ENOMEM', 'EACCES', 'EPERM', 'ENOENT', 'EADDRINUSE', 'ENOSPC'].find(code => text.includes(code)) ?? 'UNCLASSIFIED'
+ console.error(JSON.stringify({ ownedRunnerFailure: true, phase: failedPhase ?? 'pins-or-cleanup', knownCode }))
+}
+process.exitCode = failure || !unchanged || !clusterStopped || !directoryRemoved ? 1 : childExitCode
diff --git a/backend/scripts/test-sqlite-import-control-postgres.mjs b/backend/scripts/test-sqlite-import-control-postgres.mjs
new file mode 100644
index 00000000..b825f08c
--- /dev/null
+++ b/backend/scripts/test-sqlite-import-control-postgres.mjs
@@ -0,0 +1,51 @@
+// Permanent runner candidate: fresh loopback PostgreSQL, no app config/.env.
+import EmbeddedPostgres from 'embedded-postgres'
+import { mkdtemp, rm, readFile, writeFile, mkdir } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join, resolve, relative, isAbsolute } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { randomBytes, createHash } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn } from 'node:child_process'
+const args = process.argv.slice(2)
+if (args.length > 1 || args[0] && !args[0].startsWith('--production-root=')) throw Error('Only an explicit source-root override is supported for TMP review')
+const sourceRoot = args[0] ? resolve(args[0].slice('--production-root='.length)) : fileURLToPath(new URL('../../', import.meta.url))
+const sources = ['backend/src/services/partition-write-transaction.ts', 'backend/src/db/sqlite-import-control-writes.ts', 'backend/src/db/sqlite-import.ts', 'backend/src/db/schema.ts']
+async function pins() {
+ const result = []
+ for (const path of sources) result.push({ path, sha256: createHash('sha256').update(await readFile(join(sourceRoot, path))).digest('hex') })
+ return result
+}
+const before = await pins(), directory = await mkdtemp(join(tmpdir(), 'mm-import-control-'))
+const listener = createServer(); await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve))
+const port = listener.address().port; await new Promise(resolve => listener.close(resolve))
+const password = randomBytes(24).toString('hex')
+const postgres = new EmbeddedPostgres({ databaseDir: join(directory, 'pg'), port, user: 'import_operator', password,
+ persistent: true, createPostgresUser: false, initdbFlags: ['--encoding=UTF8'], postgresFlags: ['-h', '127.0.0.1'], onLog: () => {}, onError: () => {} })
+try {
+ await postgres.initialise(); await postgres.start()
+ process.exitCode = await new Promise((done, reject) => {
+ const child = spawn(process.execPath, ['--import', import.meta.resolve('tsx'), fileURLToPath(new URL('../src/db/sqlite-import-control-writes.sql.test.ts', import.meta.url))], {
+ cwd: directory, windowsHide: true, stdio: 'inherit', env: {
+ ...Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'PATH', 'Path'].filter(k => process.env[k]).map(k => [k, process.env[k]])),
+ MMAPP_OWN_IMPORT_CONTROL: 'true', MMAPP_OWN_IMPORT_DIRECTORY: directory, MMAPP_OWN_IMPORT_SOURCE_ROOT: sourceRoot,
+ MMAPP_OWN_IMPORT_ADMIN_URL: `postgresql://import_operator:${password}@127.0.0.1:${port}/postgres` },
+ })
+ child.once('error', reject); child.once('exit', code => done(code ?? 1))
+ })
+ const after = await pins(), unchanged = JSON.stringify(before) === JSON.stringify(after)
+ const report = { format: 'sqlite-import-control-owned-pins-v1', date: new Date().toISOString(), before, after, unchanged, childExitCode: process.exitCode }
+ // Keep generated evidence out of source directories after integration.
+ // This is a local test artifact, never a production authority record.
+ await mkdir(join(sourceRoot, 'tmp'), { recursive: true })
+ await writeFile(join(sourceRoot, 'tmp', 'sqlite-import-control-source-pins.json'), JSON.stringify(report, null, 2))
+ console.log('Current production source pins unchanged:', unchanged)
+ if (!unchanged) process.exitCode = 1
+} finally {
+ await postgres.stop()
+ const root = resolve(tmpdir()), target = resolve(directory), rel = relative(root, target)
+ if (!rel || rel.startsWith('..') || isAbsolute(rel) || !target.includes('mm-import-control-')) throw Error('Unsafe owned import cleanup path')
+ await rm(target, { recursive: true, force: true })
+ console.log('Owned importer PostgreSQL stopped and exact temp directory removed')
+}
+process.exit(process.exitCode ?? 0)
diff --git a/backend/scripts/vrf-production-profile.mjs b/backend/scripts/vrf-production-profile.mjs
new file mode 100644
index 00000000..cd6d74da
--- /dev/null
+++ b/backend/scripts/vrf-production-profile.mjs
@@ -0,0 +1,152 @@
+import assert from 'node:assert/strict'
+import { mkdir, writeFile, realpath, lstat, mkdtemp, open } from 'node:fs/promises'
+import { basename, join, resolve, relative, isAbsolute } from 'node:path'
+import { createRequire } from 'node:module'
+import { pathToFileURL, fileURLToPath } from 'node:url'
+import { randomBytes } from 'node:crypto'
+import { spawn } from 'node:child_process'
+
+
+const diagnosticLogCap = 1024 * 1024
+const diagnosticNames = new Set(['Error', 'AssertionError', 'McpError', 'TypeError', 'RangeError'])
+const diagnosticCodes = new Set(['ERR_ASSERTION', 'VERIFICATION_FAILED', 'DEVICE_UNAVAILABLE', 'PLAN_EXPIRED', 'RATE_LIMITED', 'VRF_ACK_JOURNAL_UNCONFIRMED', 'VRF_VERIFIED_CHECKPOINT_UNCONFIRMED', '42883', '22P02'])
+/** Pure projection only: no arbitrary log text, SQL, native rows or credentials. */
+export function projectVrfDiagnostics(log, privateValues = [], expectedSlice = null) {
+ assert.equal(typeof log, 'string'); assert(Array.isArray(privateValues))
+ assert(Buffer.byteLength(log) <= diagnosticLogCap, 'Diagnostic source log exceeded existing cap')
+ let redacted = log
+ for (const value of [...privateValues, 'owned-vrf-loopback-password'].filter(value => typeof value === 'string' && value).sort((a,b) => b.length-a.length)) redacted = redacted.split(value).join('[REDACTED]')
+ redacted = redacted.replace(/postgres(?:ql)?:\/\/[^\s'"]+/gi, '[REDACTED_DATABASE_URL]')
+ .replace(/mmcp_[a-z]+_[A-Za-z0-9_-]+/g, '[REDACTED_MCP_TOKEN]')
+ .replace(/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, '[REDACTED_JWT]')
+ const records = [], acceptedCaseSequence = []; let malformedLines = 0, omittedLines = 0, incrementalRecords = 0, truncatedRecords = 0, droppedCaseLabels = 0, lastAcceptedCase = null, finalComponentPresent = false
+ const labelPattern = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$/
+ const retainLabel = label => { if (typeof label !== 'string' || !labelPattern.test(label)) { droppedCaseLabels++; return }; if (acceptedCaseSequence.length === 128) { acceptedCaseSequence.shift(); droppedCaseLabels++ }; acceptedCaseSequence.push(label); lastAcceptedCase = label }
+ const retain = value => { if (records.length === 128) { records.shift(); truncatedRecords++ } records.push(value) }
+ for (const line of redacted.split(/\r?\n/).filter(Boolean)) {
+ let value; try { value = JSON.parse(line) } catch {
+ malformedLines++
+ const name = /^(Error|AssertionError|McpError|TypeError|RangeError)(?:[ :\[]|$)/.exec(line)?.[1]
+ if (name) retain({ diagnosticError: true, safeName: name, safeCode: line.includes('[ERR_ASSERTION]') ? 'ERR_ASSERTION' : 'other' })
+ const normalized = line.replaceAll('\\', '/'), position = /vrf-production-execution-owned\.(?:ts|mts):(\d{1,7}):(\d{1,7})\)?$/.exec(normalized)
+ if (position && (normalized.includes('/backend/src/test/vrf-production-execution-owned.ts:') || normalized.includes('/tmp/mcp-vrf-all68-staged-20261101/vrf-production-execution-owned.mts:'))) retain({ source: 'owned-vrf-fixture', line: Number(position[1]), column: Number(position[2]) })
+ continue
+ }
+ if (!value || typeof value !== 'object' || Array.isArray(value)) { omittedLines++; continue }
+ const row = {}
+ if (value.acceptedCase) { incrementalRecords++; row.acceptedCaseRecord = true; const labels = Array.isArray(value.acceptedCase) ? value.acceptedCase : [value.acceptedCase]; if (labels.length <= 68) for (const label of labels) retainLabel(label); else droppedCaseLabels += labels.length }
+ if (Array.isArray(value.accepted)) { row.finalCaseCount = value.accepted.length; if (expectedSlice !== null && value.slice === expectedSlice) finalComponentPresent = true }
+ if (['planned','queued','running','applied','failed','cancelled','unknown','expired','rejected','unconfirmed'].includes(value.operationState)) row.operationState = value.operationState
+ for (const key of ['phase', 'elapsedMs', 'nativeReads', 'nativeWrites', 'roundTrips', 'lastSqlMs', 'totalSqlMs', 'maxSqlMs']) if (Number.isSafeInteger(value[key]) && value[key] >= 0) row[key] = value[key]
+ if (Number.isSafeInteger(value.wireguardPeerTelemetryTicks) && value.wireguardPeerTelemetryTicks > 0 && value.wireguardPeerTelemetryTicks <= 10000) row.wireguardPeerTelemetryTicks = value.wireguardPeerTelemetryTicks
+ if (value.diagnosticWaitSql === true) row.diagnosticWaitSql = true
+ if (value.diagnosticError === true) { row.diagnosticError = true; row.safeName = diagnosticNames.has(value.safeName) ? value.safeName : 'other'; row.safeCode = diagnosticCodes.has(value.safeCode) ? value.safeCode : 'other' }
+ if (!Object.keys(row).length) { omittedLines++; continue }
+ retain(row)
+ }
+ return { version: 1, rawLogRetained: false, sourceCapBytes: diagnosticLogCap, capturedLogBytes: Buffer.byteLength(log), malformedLines, omittedLines, incrementalRecords, truncatedRecords, finalComponentPresent, acceptedCaseSequence, lastAcceptedCase, droppedCaseLabels, records }
+}
+export function vrfSliceDiagnostic(result, log, childBudgetMs, privateValues = []) {
+ assert(result && typeof result === 'object')
+ assert(['baseline','physical','vlan','disabled','mixed','reconcile','sql-journal','guards','coexistence','alias','gre'].includes(result.slice))
+ assert(Number.isSafeInteger(result.code) && typeof result.childExitConfirmed === 'boolean')
+ assert(Number.isSafeInteger(result.caseCount) && result.caseCount >= 0)
+ assert.equal(childBudgetMs, result.slice === 'baseline' ? 240000 : result.slice === 'disabled' ? 180000 : 120000)
+ assert(result.failure === null || ['child-deadline','child-log-limit','child-signal','child-error','child-error-after-pid','child-exit-unconfirmed','missing-component-receipt'].includes(result.failure))
+ assert(result.accepted === (result.code === 0 && result.failure === null && result.childExitConfirmed))
+ return { ...result, capMs: childBudgetMs, diagnostics: projectVrfDiagnostics(log, privateValues, result.slice), scope: 'same-owned-PG-test-only', actualRouter: false, forwardingVerified: false }
+}
+async function writeDiagnostic(path, value, maxBytes = 65536) {
+ const bytes = Buffer.from(JSON.stringify(value, null, 2) + '\n'); assert(bytes.length <= maxBytes)
+ const stream = await open(path, 'wx', 0o600)
+ try { await stream.writeFile(bytes); await stream.sync() } finally { await stream.close() }
+}
+
+/** Existing test runner owns the PG lifecycle. This component creates only
+ * bounded Node children on that same synthetic DB, with an empty private cwd.
+ * It never reads backend/.env, creates a PG, or accepts an application URL. */
+export async function runOwnedVrfProductionProfile({ directory, database, databaseUrl }) {
+ const target = new URL(databaseUrl)
+ assert.equal(target.hostname, '127.0.0.1'); assert.equal(target.username, 'mcp_test')
+ assert(/^mm_accept_166_\d+$/.test(database)); assert.equal(target.pathname, '/' + database)
+ const owned = resolve(directory)
+ assert.equal(await realpath(owned), owned); assert(basename(owned).startsWith('mm-mcp-test-'))
+ assert(!(await lstat(owned)).isSymbolicLink())
+ // Fixed destination derived from this source module, never caller/env controlled.
+ const repository = fileURLToPath(new URL('../../', import.meta.url)), reportRoot = join(repository, 'tmp')
+ assert.equal(await realpath(reportRoot), reportRoot); assert(!(await lstat(reportRoot)).isSymbolicLink())
+ const diagnosticDirectory = await mkdtemp(join(reportRoot, 'mcp-vrf-profile-'))
+ assert.equal(await realpath(diagnosticDirectory), diagnosticDirectory); assert(!(await lstat(diagnosticDirectory)).isSymbolicLink())
+ assert.equal(relative(reportRoot, diagnosticDirectory), basename(diagnosticDirectory)); assert(basename(diagnosticDirectory).startsWith('mcp-vrf-profile-'))
+ const persist = (name, value) => writeDiagnostic(join(diagnosticDirectory, name), value)
+ const diagnosticPath = relative(repository, diagnosticDirectory)
+ await persist('started.json', { version: 1, status: 'running', accepted: false, childExitConfirmed: false, scope: 'same-owned-PG-test-only' })
+ console.log(JSON.stringify({ profile: 'test:vrf:production', diagnosticDirectory: diagnosticPath, status: 'running' }))
+ const results = []
+ let currentSlice = null, currentChildExitConfirmed = false, lastSliceResult = null
+ try {
+ const entry = fileURLToPath(new URL('../src/test/vrf-production-execution-owned.ts', import.meta.url))
+ const report = fileURLToPath(new URL('../../docs/mcp-chr-vrf-companion-native-v5.json', import.meta.url))
+ const loader = pathToFileURL(createRequire(import.meta.url).resolve('tsx')).href
+ const safe = Object.fromEntries(['SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'LANG', 'LC_ALL'].filter(key => typeof process.env[key] === 'string').map(key => [key, process.env[key]]))
+ // Diagnose the disabled lifecycle first, then the synthetic GRE extension.
+ // Every original case remains required by the same full74 gate and caps.
+ for (const slice of ['disabled', 'gre', 'baseline', 'physical', 'vlan', 'mixed', 'reconcile', 'sql-journal', 'guards', 'coexistence', 'alias']) {
+ currentSlice = slice; currentChildExitConfirmed = false; lastSliceResult = null
+ await persist(slice + '-started.json', { version: 1, slice, status: 'running', accepted: false, childExitConfirmed: false })
+ // Nine disabled lifecycle operations need their own aggregate child cap;
+ // measured seven operations alone consumed 105.5s under the original120s.
+ const childBudgetMs = slice === 'baseline' ? 240000 : slice === 'disabled' ? 180000 : 120000
+ const cwd = join(owned, 'vrf-production-' + slice), rel = relative(owned, cwd)
+ assert(rel && !rel.startsWith('..') && !isAbsolute(rel)); await mkdir(cwd)
+ assert.equal(await realpath(cwd), cwd); assert(!(await lstat(cwd)).isSymbolicLink())
+ let log = '', failure = null, exited = false, stopTimer, unknownTimer
+ const authSecret = randomBytes(32).toString('hex')
+ const child = spawn(process.execPath, ['--import', loader, entry], { cwd, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'], env: {
+ ...safe, NODE_OPTIONS: '', NODE_ENV: 'test', DATABASE_URL: databaseUrl,
+ DATABASE_PATH: join(cwd, 'no-legacy.sqlite'), MCP_STATE_DIR: join(cwd, 'state'),
+ AUTH_REQUIRED: 'true', AUTH_JWT_SECRET: authSecret, MCP_PUBLIC_URL: 'http://localhost:8000/mcp',
+ MMAPP_OWN_VRF_EXECUTION: 'true', MMAPP_VRF_EXECUTION_SLICE: slice, MMAPP_VRF_NATIVE_REPORT: report,
+ MMAPP_VRF_SHARED_OWNED_PG: 'true', MMAPP_OWN_SQL_DB: database,
+ } })
+ const stop = reason => {
+ failure ??= reason
+ if (exited) return
+ child.kill('SIGTERM')
+ stopTimer ??= setTimeout(() => { if (!exited) child.kill('SIGKILL') }, 5000)
+ }
+ const deadline = setTimeout(() => stop('child-deadline'), childBudgetMs)
+ for (const stream of [child.stdout, child.stderr]) stream.on('data', bytes => {
+ if (Buffer.byteLength(log) + bytes.length > 1024 * 1024) { stop('child-log-limit'); return }
+ log += bytes.toString()
+ })
+ const code = await new Promise(resolveExit => {
+ child.once('exit', (status, signal) => { exited = true; if (signal) failure ??= 'child-signal'; resolveExit(status ?? 1) })
+ child.once('error', () => { failure ??= 'child-error'; if (!child.pid) { exited = true; resolveExit(1) } else stop('child-error-after-pid') })
+ unknownTimer = setTimeout(() => { if (!exited) { stop('child-exit-unconfirmed'); resolveExit(1) } }, childBudgetMs + 15000)
+ })
+ clearTimeout(deadline); clearTimeout(stopTimer); clearTimeout(unknownTimer)
+ const expectedCases = { baseline: 11, physical: 7, vlan: 9, disabled: 9, mixed: 7, reconcile: 6, 'sql-journal': 1, guards: 11, coexistence: 3, alias: 4, gre: 6 }
+ const component = log.trim().split(/\r?\n/).flatMap(line => { try { return [JSON.parse(line)] } catch { return [] } }).findLast(value => value.slice === slice && Array.isArray(value.accepted))
+ if (!component || component.accepted.length !== expectedCases[slice] || component.actualSql !== true || component.actualCrypto !== true || component.actualAuthPolicyApprovalRuntime !== true || component.fakeVerifier !== false || component.actualRouter !== false || component.forwardingVerified !== false) failure ??= 'missing-component-receipt'
+ if (slice === 'gre' && (!Number.isSafeInteger(component?.wireguardPeerTelemetryTicks) || component.wireguardPeerTelemetryTicks <= 6 || component.wireguardPeerTelemetryTicks > 10000)) failure ??= 'missing-component-receipt'
+ const result = { slice, accepted: code === 0 && !failure && exited, caseCount: component?.accepted?.length ?? 0, code, failure, childPid: child.pid ?? null, childExitConfirmed: exited }
+ lastSliceResult = result; currentChildExitConfirmed = exited
+ const diagnostic = vrfSliceDiagnostic(result, log, childBudgetMs, [databaseUrl, target.password, decodeURIComponent(target.password), authSecret])
+ await persist(slice + '-result.json', diagnostic)
+ // Persist outside the owner's cleanup boundary BEFORE any next slice/return.
+ await writeFile(join(cwd, 'fixture.log'), JSON.stringify(diagnostic.diagnostics, null, 2))
+ await writeFile(join(cwd, 'acceptance.json'), JSON.stringify(result, null, 2))
+ results.push(result)
+ console.log(JSON.stringify({ profile: 'test:vrf:production', ...result }))
+ if (!result.accepted) break
+ }
+ const receipt = { accepted: results.length === 11 && results.every(result => result.accepted), childExitConfirmed: results.every(result => result.childExitConfirmed), sameOwnedPg: true, actualRouter: false, forwardingVerified: false, results }
+ await persist('terminal.json', { version: 1, status: 'terminal', ...receipt, requiredCases: 74, completedCases: results.reduce((sum, value) => sum + value.caseCount, 0), diagnosticDirectory: diagnosticPath })
+ await writeFile(join(owned, 'vrf-production-acceptance.json'), JSON.stringify(receipt, null, 2))
+ return receipt
+ } catch {
+ await persist('wrapper-failure.json', { version: 1, status: 'refused', accepted: false, phase: currentSlice, failure: 'wrapper-exception', childExitConfirmed: currentChildExitConfirmed && results.every(value => value.childExitConfirmed), completedSlices: results.length, lastSliceResult, results })
+ throw Error('VRF profile refused; bounded diagnostics retained at ' + diagnosticPath)
+ }
+}
diff --git a/backend/scripts/vrf-production-profile.test.mjs b/backend/scripts/vrf-production-profile.test.mjs
new file mode 100644
index 00000000..cfcd4bc4
--- /dev/null
+++ b/backend/scripts/vrf-production-profile.test.mjs
@@ -0,0 +1,45 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { vrfSliceDiagnostic } from './vrf-production-profile.mjs'
+
+test('only the nine-operation disabled slice receives its measured aggregate budget', () => {
+ for (const [slice, capMs] of [['disabled', 180000], ['gre', 120000], ['baseline', 240000]]) {
+ const result = { slice, accepted: false, caseCount: 0, code: 1, failure: 'child-deadline', childExitConfirmed: true }
+ assert.equal(vrfSliceDiagnostic(result, '', capMs).capMs, capMs)
+ for (const otherCap of [120000, 180000, 240000].filter(value => value !== capMs)) assert.throws(() => vrfSliceDiagnostic(result, '', otherCap))
+ }
+})
+
+test('GRE lifecycle diagnostic retains the six-case receipt with existing privacy bounds', () => {
+ const accepted = ['vrf-create', 'vrf-rename', 'vrf-disable', 'vrf-reenable', 'vrf-membership-transfer-a-to-b', 'vrf-delete-addresses-remain']
+ const result = { slice: 'gre', accepted: true, caseCount: 6, code: 0, failure: null, childExitConfirmed: true }
+ const log = accepted.map((acceptedCase, index) => JSON.stringify({ slice: 'gre', acceptedCase, nativeWrites: 1, wireguardPeerTelemetryTicks: (index + 1) * 4, password: 'fixture-private-value' }))
+ log.push(JSON.stringify({ slice: 'gre', accepted, wireguardPeerTelemetryTicks: 24, rawShape: 'synthetic GRE lifecycle', password: 'fixture-private-value' }))
+ const diagnostic = vrfSliceDiagnostic(result, log.join('\n'), 120000, ['fixture-private-value'])
+ assert.deepEqual(diagnostic.diagnostics.acceptedCaseSequence, accepted)
+ assert.equal(diagnostic.diagnostics.finalComponentPresent, true)
+ assert.equal(diagnostic.diagnostics.rawLogRetained, false)
+ assert.deepEqual(diagnostic.diagnostics.records.map(row => row.wireguardPeerTelemetryTicks), [4, 8, 12, 16, 20, 24, 24])
+ assert.equal(diagnostic.actualRouter, false)
+ assert.equal(diagnostic.forwardingVerified, false)
+ assert.equal(JSON.stringify(diagnostic).includes('fixture-private-value'), false)
+ assert.throws(() => vrfSliceDiagnostic(result, '', 240000))
+})
+
+test('peer telemetry diagnostic rejects nonnumeric and out-of-budget values', () => {
+ const result = { slice: 'gre', accepted: false, caseCount: 0, code: 1, failure: 'missing-component-receipt', childExitConfirmed: true }
+ for (const wireguardPeerTelemetryTicks of [0, -1, 10001, 1.5, 'private-raw-value', { secret: 'private-raw-value' }]) {
+ const diagnostic = vrfSliceDiagnostic(result, JSON.stringify({ slice: 'gre', wireguardPeerTelemetryTicks }), 120000)
+ assert.equal(diagnostic.diagnostics.records.some(row => Object.hasOwn(row, 'wireguardPeerTelemetryTicks')), false)
+ assert.equal(JSON.stringify(diagnostic).includes('private-raw-value'), false)
+ }
+})
+
+test('a partial GRE lifecycle is diagnostic evidence without a final component receipt', () => {
+ const result = { slice: 'gre', accepted: false, caseCount: 0, code: 1, failure: 'child-deadline', childExitConfirmed: true }
+ const diagnostic = vrfSliceDiagnostic(result, JSON.stringify({ slice: 'gre', acceptedCase: 'vrf-create' }), 120000)
+ assert.equal(diagnostic.accepted, false)
+ assert.equal(diagnostic.diagnostics.finalComponentPresent, false)
+ assert.equal(diagnostic.diagnostics.lastAcceptedCase, 'vrf-create')
+ assert.equal(diagnostic.capMs, 120000)
+})
diff --git a/backend/scripts/writer-profile/application-writer-profile-canonical.ts b/backend/scripts/writer-profile/application-writer-profile-canonical.ts
new file mode 100644
index 00000000..7f9716b0
--- /dev/null
+++ b/backend/scripts/writer-profile/application-writer-profile-canonical.ts
@@ -0,0 +1,9 @@
+import {createHash} from 'node:crypto'
+
+/** Exact writer-profile v1 canonical bytes. Pure value codec; no trust/authority. */
+export function canonical(value:unknown):string {
+ return JSON.stringify(value,(_key,item:unknown)=>item&&typeof item==='object'&&!Array.isArray(item)
+ ?Object.fromEntries(Object.entries(item).sort(([a],[b])=>ab?1:0)):item)
+}
+export const sha=(value:Uint8Array|string)=>createHash('sha256').update(value).digest('hex')
+export const bytes=(value:unknown)=>Buffer.from(canonical(value)+'\n','utf8')
diff --git a/backend/scripts/writer-profile/application-writer-profile-catalogue-parent-policy.ts b/backend/scripts/writer-profile/application-writer-profile-catalogue-parent-policy.ts
new file mode 100644
index 00000000..35e14240
--- /dev/null
+++ b/backend/scripts/writer-profile/application-writer-profile-catalogue-parent-policy.ts
@@ -0,0 +1,9 @@
+// Fixed12 source-partition DATA policy, candidate build artifact for review.
+// No observed-schema enrollment, caller policy, expected catalogue or authority.
+import {canonical,sha} from './application-writer-profile-canonical.js'
+const PERIODS=Object.freeze({flow_buckets:'d',flow_minute_stats:'d',flow_minute_dims:'d',flow_daily_dims:'m',flow_hour_facts:'d',flow_daily_facts:'m',traffic_samples:'w',servers_rest_ping_samples:'w',uptime_probe_samples:'w',uptime_resource_samples:'w',server_snapshots:'w',internet_path_snapshots:'w'} as const)
+export type FixedCatalogueParentPeriodData='d'|'w'|'m'
+export const FIXED_CATALOGUE_PARENT_POLICY_DATA_SHA256=sha(canonical(PERIODS))
+export function fixedCatalogueParentPeriodData(name:string):FixedCatalogueParentPeriodData|undefined {
+ return Object.hasOwn(PERIODS,name)?PERIODS[name as keyof typeof PERIODS]:undefined
+}
diff --git a/backend/scripts/writer-profile/application-writer-profile-catalogue-values.ts b/backend/scripts/writer-profile/application-writer-profile-catalogue-values.ts
new file mode 100644
index 00000000..2d28a0c1
--- /dev/null
+++ b/backend/scripts/writer-profile/application-writer-profile-catalogue-values.ts
@@ -0,0 +1,90 @@
+// Private typed VALUE framing only. No SQL/pool/role/current-schema attestation.
+// Transport limits are inherited unchanged from the accepted paged DATA codec;
+// they DO NOT expand the legacy2048 total-constraint policy.
+import {createHash,type Hash} from 'node:crypto'
+import {canonical as writerCanonical} from './application-writer-profile-canonical.js'
+
+export type Json = null|boolean|number|string|Json[]|{[key:string]:Json}
+export type CatalogueKind='global'|'base'|'leaf'
+export interface CatalogueRecord {kind:CatalogueKind;identity:string;value:{[key:string]:Json}}
+export const FRAME_LIMITS=Object.freeze({chunkBytes:4096,pageRows:128,recordBytes:2*1024*1024,streamBytes:64*1024*1024,identityBytes:1024,depth:64})
+export interface StreamMetrics {records:number;chunks:number;pages:number;payloadBytes:number;estimatedDataRowBytes:number;maxPagePayloadBytes:number;maxRecordBytes:number}
+export interface CatalogueValueDigest {format:'catalogue-values-v2';baseSha256:string;leafSha256:string;snapshotSha256:string;metrics:Readonly;authority:false}
+const rank:Record={global:0,base:1,leaf:2}
+const domain=(name:string)=>createHash('sha256').update('mmapp:catalogue-'+name+':v2\0')
+function object(value:unknown):value is Record{return !!value&&typeof value==='object'&&!Array.isArray(value)&&Object.getPrototypeOf(value)===Object.prototype}
+function exactJson(value:Json,depth=0):void {
+ if(depth>FRAME_LIMITS.depth)throw Error('Catalogue nesting bound')
+ if(value===null||typeof value==='boolean'||typeof value==='string')return
+ if(typeof value==='number'){if(!Number.isSafeInteger(value)||Object.is(value,-0))throw Error('Exact integer/string catalogue scalar required');return}
+ if(Array.isArray(value)){for(const item of value)exactJson(item,depth+1);return}
+ if(!object(value))throw Error('Plain catalogue JSON required')
+ for(const key of Object.keys(value))exactJson(value[key] as Json,depth+1)
+}
+function canonical(value:Json):string{exactJson(value);return writerCanonical(value)}
+function update(hash:Hash,encoded:Buffer){const length=Buffer.alloc(4);length.writeUInt32BE(encoded.length);hash.update(length);hash.update(encoded)}
+function record(bytes:Buffer,kind:CatalogueKind,identity:string):CatalogueRecord{
+ const parsed:unknown=JSON.parse(new TextDecoder('utf8',{fatal:true}).decode(bytes))
+ if(!object(parsed)||Object.keys(parsed).sort().join(',')!=='identity,kind,value'||parsed.kind!==kind||parsed.identity!==identity||!object(parsed.value))throw Error('Exact catalogue record shape required')
+ // canonical() also rejects numbers/prototypes outside the scalar contract.
+ canonical(parsed as unknown as Json)
+ return parsed as unknown as CatalogueRecord
+}
+export class CatalogueValueStream {
+ private readonly base=domain('base-values');private readonly leaf=domain('leaf-values');private readonly snapshot=domain('snapshot-values')
+ private readonly metrics:StreamMetrics={records:0,chunks:0,pages:0,payloadBytes:0,estimatedDataRowBytes:0,maxPagePayloadBytes:0,maxRecordBytes:0}
+ private next=1n;private parts:Buffer[]=[];private bytes=0;private expectedParts=0;private currentKind?:CatalogueKind;private currentIdentity=''
+ private previous?:{kind:CatalogueKind;identity:string};private finished=false;private accepting=false;private failed=false;private baseRecords=0;private leafRecords=0;
+ *acceptPage(rows:readonly unknown[]):Generator{
+ if(this.finished||this.accepting||this.failed||!Array.isArray(rows)||rows.length>FRAME_LIMITS.pageRows){this.failed=true;throw Error('Closed/oversized catalogue page')}
+ this.accepting=true;let complete=false
+ try{
+ this.metrics.pages++;let pageBytes=0
+ for(const raw of rows){
+ if(!object(raw)||Object.keys(raw).sort().join(',')!=='chunk_count,chunk_index,identity,kind,payload,record_id')throw Error('Exact cursor row shape required')
+ const {record_id:id,chunk_index:part,chunk_count:count,kind,identity,payload}=raw
+ if(typeof id!=='string'||!/^[1-9][0-9]{0,18}$/.test(id)||BigInt(id)!==this.next||typeof kind!=='string'||!Object.hasOwn(rank,kind)||typeof identity!=='string'||Buffer.byteLength(identity)<1||Buffer.byteLength(identity)>FRAME_LIMITS.identityBytes||!Number.isInteger(part)||!Number.isInteger(count)||typeof part!=='number'||typeof count!=='number'||count<1||count>FRAME_LIMITS.recordBytes/FRAME_LIMITS.chunkBytes||part!==this.parts.length||part>=count||!Buffer.isBuffer(payload)||payload.length<1||payload.length>FRAME_LIMITS.chunkBytes||partFRAME_LIMITS.recordBytes||pageBytes>FRAME_LIMITS.pageRows*FRAME_LIMITS.chunkBytes||this.metrics.payloadBytes>FRAME_LIMITS.streamBytes)throw Error('Catalogue byte budget exceeded')
+ if(part===count-1){
+ const value=record(Buffer.concat(this.parts,this.bytes),k,identity),encoded=Buffer.from(canonical(value as unknown as Json))
+ if(encoded.length>FRAME_LIMITS.recordBytes)throw Error('Canonical catalogue record overflow')
+ const dynamic=k==='leaf'||k==='global'&&identity==='source_size'
+ update(this.snapshot,encoded);update(dynamic?this.leaf:this.base,encoded)
+ if(dynamic)this.leafRecords++;else this.baseRecords++
+ this.metrics.records++;this.metrics.maxRecordBytes=Math.max(this.metrics.maxRecordBytes,this.bytes);this.previous={kind:k,identity};this.next++;this.parts=[];this.bytes=0;this.expectedParts=0
+ yield value
+ }
+ }
+ this.metrics.maxPagePayloadBytes=Math.max(this.metrics.maxPagePayloadBytes,pageBytes)
+ complete=true
+ }finally{this.accepting=false;if(!complete)this.failed=true}
+ }
+ finish():CatalogueValueDigest{
+ if(this.finished||this.accepting||this.failed||this.parts.length)throw Error('Catalogue stream incomplete/closed')
+ this.finished=true
+ // Each digest includes its own record count, so empty/partitioned streams
+ // cannot acquire an ambiguous concatenation encoding.
+ const digest=(hash:Hash,count:number)=>{const end=Buffer.alloc(8);end.writeBigUInt64BE(BigInt(count));return hash.update(end).digest('hex')}
+ return Object.freeze({format:'catalogue-values-v2',baseSha256:digest(this.base,this.baseRecords),leafSha256:digest(this.leaf,this.leafRecords),snapshotSha256:digest(this.snapshot,this.metrics.records),metrics:Object.freeze({...this.metrics}),authority:false})
+ }
+}
+
+
+
+/** Fail-closed DATA counter for the unchanged legacy total constraint ceiling.
+ * Paging is not permission to reset/reinterpret that total on every page. */
+export class FixedCatalogueConstraintRowBudgetData {
+ private count=0;private failed=false
+ acceptRows(rows:readonly unknown[]):number {
+ if(this.failed||!Array.isArray(rows)){this.failed=true;throw Error('Closed/invalid constraint row budget')}
+ if(this.count+rows.length>2048){this.failed=true;throw Error('Legacy total constraint row cap2048 exceeded')}
+ this.count+=rows.length;return this.count
+ }
+}
diff --git a/backend/scripts/writer-profile/application-writer-profile-catalogue.ts b/backend/scripts/writer-profile/application-writer-profile-catalogue.ts
new file mode 100644
index 00000000..853ee0c4
--- /dev/null
+++ b/backend/scripts/writer-profile/application-writer-profile-catalogue.ts
@@ -0,0 +1,104 @@
+// Private staged full-catalogue DATA verifier. No pool, issuer, cache, authority or READY.
+// Exact reviewed source templates are statically imported.
+import {canonical,sha} from './application-writer-profile-canonical.js'
+import {fixedCatalogueParentPeriodData} from './application-writer-profile-catalogue-parent-policy.js'
+import {type CatalogueRecord} from './application-writer-profile-catalogue-values.js'
+import {BUILD44_PROVENANCE,FIXED44_ROLE_TEMPLATE} from './fixed44-build-definition.js'
+import {BUILD56_PROVENANCE,FIXED56_ROLE_TEMPLATE} from './fixed56-build-definition.js'
+import {BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE} from './fixed57-build-definition.js'
+import {BUILD58_PROVENANCE,FIXED58_ROLE_TEMPLATE,normalizeFixed58RestoreRows} from './fixed58-build-definition.js'
+import {GLOBALS,GROUPS,object,rows,sorted,text,projectCatalogueData,type CatalogueEdition,type Inventory,type Row,type Json} from './catalogue-projection.js'
+import {validateCatalogueLeafData} from './catalogue-leaves.js'
+import {catalogueTopologyPolicy,Expanded44TopologyBudgetData} from './expanded44-data-policy.js'
+export type LogicalRole='runtime'|'operator'|'capture'|'publisher'|'control'
+// Same DATA shape as RegistryRoleBindingsData. Provenance must come from protected host separately.
+export type InstallationRoleBindingsData=Readonly>>
+const ROLE_KEYS:readonly LogicalRole[]=['runtime','operator','capture','publisher','control']
+const EXTRAS=['source_size','namespace_policy','publisher_column_escape'] as const
+const definitions = {
+ 44: { provenance: BUILD44_PROVENANCE, template: FIXED44_ROLE_TEMPLATE },
+ 56: { provenance: BUILD56_PROVENANCE, template: FIXED56_ROLE_TEMPLATE },
+ 57: { provenance: BUILD57_PROVENANCE, template: FIXED57_ROLE_TEMPLATE },
+ 58: { provenance: BUILD58_PROVENANCE, template: FIXED58_ROLE_TEMPLATE },
+}
+const exact=(a:unknown,b:unknown,label:string)=>{if(canonical(a)!==canonical(b))throw Error('Writer catalogue refused: '+label)}
+function captureBindings(input:InstallationRoleBindingsData):Readonly> {
+ exact(Object.keys(input).sort(),[...ROLE_KEYS].sort(),'binding roles')
+ const names=new Set(),oids=new Set(),result={} as Record
+ for(const role of ROLE_KEYS){const binding=input[role];exact(Object.keys(binding).sort(),['name','signedOid'],'binding fields')
+ // Deliberately narrow deparse envelope; unsupported quoted/reserved names fail closed.
+ if(!/^[a-z_][a-z0-9_]{0,62}$/.test(binding.name)||!/^[1-9][0-9]{0,9}$/.test(binding.signedOid)||BigInt(binding.signedOid)>4294967295n||names.has(binding.name)||oids.has(binding.signedOid))throw Error('Explicit distinct installation role binding required')
+ names.add(binding.name);oids.add(binding.signedOid);result[role]=binding.name
+ }
+ return Object.freeze(result)
+}
+function instantiateExpected(names:Readonly>, template:Readonly):Inventory {
+ const walk=(value:Json,key=''):Json=>{if(typeof value==='string')return value.replace(/@mm-role:(runtime|operator|capture|publisher|control)@/g,(_match,role:LogicalRole)=>names[role]);if(Array.isArray(value)){const result=value.map(v=>walk(v));return key==='acl'?(result as string[]).sort():result}if(value&&typeof value==='object')return Object.fromEntries(Object.entries(value).map(([k,v])=>[k,walk(v,k)]));return value}
+ const data=walk(template as unknown as Json) as unknown as Inventory
+ return Object.fromEntries(Object.entries(data).map(([key,data])=>[key,sorted(data)]))
+}
+export class Fixed44CatalogueDataVerifier {
+ private readonly names:Readonly>;private readonly expected:Inventory;private readonly bindingsDigest:string
+ private readonly globals:Inventory={};private headers:Row[]|undefined;private globalDone=false;private closed=false;private failed=false
+ private readonly bases=new Set();private readonly leaves=new Set();private readonly templates=new Map()
+ private readonly topology:Expanded44TopologyBudgetData;private counts?:Row
+ private readonly policy:ReturnType
+ constructor(bindings:InstallationRoleBindingsData, private readonly edition:CatalogueEdition=44){
+ this.names=captureBindings(bindings)
+ this.expected=instantiateExpected(this.names,definitions[edition].template)
+ this.bindingsDigest=sha(canonical(bindings))
+ this.policy=catalogueTopologyPolicy(edition)
+ this.topology=new Expanded44TopologyBudgetData(edition)
+ }
+ consume(record:CatalogueRecord):void {if(this.closed||this.failed)throw Error('Closed/refused catalogue verifier');try{this.consumeOpen(record)}catch(error){this.failed=true;throw error}}
+ private consumeOpen(record:CatalogueRecord):void {
+ if(record.kind==='global'){
+ if(this.globalDone)throw Error('Late global refused');exact(Object.keys(record.value),['rows'],'global shape');const data=rows(record.value.rows)
+ if(record.identity==='base_tables'){if(this.headers)throw Error('Duplicate base header');this.headers=data;return}
+ if(![...GLOBALS,...EXTRAS].includes(record.identity as typeof GLOBALS[number])||Object.hasOwn(this.globals,record.identity))throw Error('Unknown/duplicate global section')
+ this.globals[record.identity]=data;return
+ }
+ this.closeGlobals()
+ if(record.kind==='leaf'&&record.identity==='!inventory_counts'){if(this.counts||this.bases.size!==this.policy.baseRelations)throw Error('Early/duplicate counts');exact(Object.keys(record.value).sort(),['base','leaf'],'count shape');this.counts=record.value;return}
+ exact(Object.keys(record.value).sort(),['table',...GROUPS].sort(),'relation shape')
+ const table=object(record.value.table),groups:Inventory={}
+ if(table.relname!==record.identity||table.relpersistence!=='p')throw Error('Relation identity/persistence refused')
+ for(const name of GROUPS)groups[name]=rows(record.value[name])
+ if(record.kind==='base'){
+ if(this.counts||table.relispartition!==false||this.bases.has(record.identity))throw Error('Duplicate/late base')
+ const header=this.headers!.find(t=>t.relname===record.identity);if(!header)throw Error('Foreign base refused');exact(table,header,'header/table')
+ const actual=projectCatalogueData({...this.globals,...groups,tables:this.headers!})
+ for(const name of GROUPS)exact(this.edition===58?normalizeFixed58RestoreRows(record.identity,name,actual[name]):actual[name],
+ this.expected[name].filter(r=>r.relname===record.identity),'base '+name+' '+record.identity)
+ this.topology.acceptRelation('base',record.identity,groups);this.bases.add(record.identity);if(fixedCatalogueParentPeriodData(record.identity))this.templates.set(record.identity,{table,groups});return
+ }
+ if(record.kind!=='leaf'||!this.counts||this.bases.size!==this.policy.baseRelations||this.leaves.has(record.identity))throw Error('Early/duplicate leaf')
+ const edges=groups.inheritance;if(edges.length!==1)throw Error('Exact one leaf edge required')
+ const parent=this.templates.get(text(edges[0].parent));if(!parent)throw Error('Foreign leaf parent refused')
+ const raw:Inventory={...this.globals,tables:[parent.table,table],inheritance:edges}
+ for(const name of GROUPS)if(name!=='inheritance')raw[name]=[...parent.groups[name],...groups[name]]
+ validateCatalogueLeafData(raw,parent.table,table);this.topology.acceptRelation('leaf',record.identity,groups,text(edges[0].parent));this.leaves.add(record.identity)
+ }
+ private closeGlobals():void {
+ if(this.globalDone)return
+ if(!this.headers)throw Error('Missing base header')
+ exact(Object.keys(this.globals).sort(),[...GLOBALS,...EXTRAS].sort(),'complete globals')
+ const blank=Object.fromEntries(GROUPS.map(name=>[name,[]])) as Inventory
+ const projected=projectCatalogueData({...this.globals,...blank,tables:this.headers})
+ exact(projected.tables,this.expected.tables,'exact source'+this.edition+' base identities/owner/ACL')
+ for(const name of GLOBALS)exact(projected[name],this.expected[name],'global '+name)
+ const size=this.globals.source_size
+ if(size.length!==1)throw Error('Source size shape refused')
+ exact(Object.keys(size[0]).sort(),['tables','function_bytes','default_bytes','check_bytes','trigger_bytes'].sort(),'source size fields')
+ if(typeof size[0].tables!=='number'||!Number.isSafeInteger(size[0].tables)||size[0].tables<1||size[0].tables>this.policy.maxRelations)throw Error('Expanded'+this.edition+' total relation DATA cap exceeded')
+ if(['function_bytes','default_bytes','check_bytes','trigger_bytes'].some(k=>typeof size[0][k]!=='string'||!/^[0-9]+$/.test(text(size[0][k]))||BigInt(text(size[0][k]))>2097152n))throw Error('Source byte bound refused')
+ if(this.globals.namespace_policy.length!==1)throw Error('Namespace shape refused')
+ exact(Object.keys(this.globals.namespace_policy[0]).sort(),['relations','rules','routines','types','namespaces','default_acl'].sort(),'namespace fields')
+ if(Object.values(this.globals.namespace_policy[0]).some(v=>v!==false)||this.globals.publisher_column_escape.length)throw Error('Namespace/column escape refused')
+ this.globalDone=true
+ }
+ finish(){if(this.closed||this.failed)throw Error('Closed/refused catalogue verifier');try{this.closeGlobals();const base=this.policy.baseRelations;if(this.bases.size!==base||this.templates.size!==this.policy.parents||!this.counts||this.counts.base!==base||this.counts.leaf!==this.leaves.size||this.globals.source_size[0].tables!==base+this.leaves.size)throw Error('Incomplete catalogue/counts');this.closed=true
+ const provenance=definitions[this.edition].provenance
+ return Object.freeze({format:`fixed${this.edition}-catalogue-expanded-data-v1` as const,policyVersion:this.policy.version,topology:this.topology.finish(),admissionClassificationVerified:false,definitionSha256:provenance.templateSha256,manifestSha256:provenance.manifestSha256,baseRelations:this.bases.size,leafRelations:this.leaves.size,bindingsDataSha256:this.bindingsDigest,cleanFourRoleSqlVerified:false,productionInstallationPolicyApproved:false,authority:false,readyAuthorized:false,defaultSupportAuthorized:false})
+ }catch(error){this.failed=true;throw error}}
+}
diff --git a/backend/scripts/writer-profile/catalogue-leaves.ts b/backend/scripts/writer-profile/catalogue-leaves.ts
new file mode 100644
index 00000000..211bd64d
--- /dev/null
+++ b/backend/scripts/writer-profile/catalogue-leaves.ts
@@ -0,0 +1,39 @@
+// Typed port of the accepted twelve-parent leaf checks, with duplicate detection in stream owner.
+import {canonical} from './application-writer-profile-canonical.js'
+import {fixedCatalogueParentPeriodData} from './application-writer-profile-catalogue-parent-policy.js'
+import {omit,sorted,text,type Inventory,type Row} from './catalogue-projection.js'
+const guards=['candidate_application_statement_guard','candidate_truncate_preadmitted','server_partition_writer_guard']
+const exact=(a:unknown,b:unknown,label:string)=>{if(canonical(a)!==canonical(b))throw Error('Catalogue leaf refused: '+label)}
+export function validateCatalogueLeafData(raw:Inventory,parent:Row,leaf:Row):void {
+ const parentName=text(parent.relname),name=text(leaf.relname),period=fixedCatalogueParentPeriodData(parentName)
+ const edges=raw.inheritance
+ if(edges.length!==1||edges[0].parent!==parentName||edges[0].child!==name)throw Error('Exact direct leaf parent required')
+ const suffix=name.slice(parentName.length+1)
+ if(!period||!name.startsWith(parentName+'_')||!new RegExp('^'+period+'_[0-9]{'+(period==='m'?6:8)+'}$').test(suffix)||leaf.relkind!=='r'||leaf.relpersistence!=='p'||leaf.relispartition!==true||leaf.owner!==parent.owner||leaf.namespace!=='public'||leaf.relrowsecurity!==false||leaf.relforcerowsecurity!==false||leaf.partition_key!==null)throw Error('Fixed managed leaf identity/owner refused')
+ const stamp=suffix.slice(2),iso=stamp.slice(0,4)+'-'+stamp.slice(4,6)+'-'+(period==='m'?'01':stamp.slice(6,8))
+ const start=new Date(iso+'T00:00:00.000Z'),end=new Date(start)
+ if(!Number.isFinite(+start)||start.toISOString().slice(0,10)!==iso||period==='w'&&start.getUTCDay()!==1)throw Error('Leaf calendar refused')
+ if(period==='m')end.setUTCMonth(end.getUTCMonth()+1);else end.setUTCDate(end.getUTCDate()+(period==='w'?7:1))
+ if(start.getUTCFullYear()<100||end.getUTCFullYear()>9998)throw Error('Bounded leaf calendar refused')
+ const bounds=/^FOR VALUES FROM \('([^']+)'\) TO \('([^']+)'\)$/.exec(text(leaf.partition_bound))
+ const instant=(s:string)=>Date.parse(s.length===10?s+'T00:00:00.000Z':s)
+ if(!bounds||instant(bounds[1])!==+start||instant(bounds[2])!==+end)throw Error('Leaf UTC bound refused')
+ const acl=(r:Row)=>r.acl===null?null:(r.acl as string[]).slice().sort()
+ exact(acl(leaf),acl(parent),'ACL')
+ exact(leaf.reloptions,['flow_hour_facts','flow_daily_facts'].includes(parentName)?['fillfactor=70','autovacuum_vacuum_scale_factor=0.05','autovacuum_vacuum_cost_limit=2000']:null,'storage')
+ exact(raw.columns.filter(r=>r.relname===name).map(r=>({...r,relname:parentName})),raw.columns.filter(r=>r.relname===parentName),'columns/defaults/identity')
+ const functions=new Map(raw.functions.map(f=>[text(f.oid),text(f.namespace)+'.'+text(f.proname)+'('+text(f.arguments)+')']))
+ const user=raw.triggers.filter(t=>t.relname===name&&!t.tgisinternal),source=raw.triggers.filter(t=>t.relname===parentName&&!t.tgisinternal)
+ if(user.length!==3||source.length!==3||new Set(user.map(t=>t.tgname)).size!==3||user.some(t=>!guards.includes(text(t.tgname))))throw Error('Leaf guard set refused')
+ for(const t of user){const p=source.find(p=>p.tgname===t.tgname)
+ if(!p||t.tgtype!==p.tgtype||t.tgenabled!=='A'||functions.get(text(t.tgfoid))!==functions.get(text(p.tgfoid))||t.tgnargs!==0||t.arg_bytes!==0||t.unconditional!==true||t.tgdeferrable!==false||t.tginitdeferred!==false||t.tgoldtable!==null||t.tgnewtable!==null||t.tgconstraint!=='0'||(t.tgname==='server_partition_writer_guard'?t.tgparentid!==p.oid:t.tgparentid!=='0'))throw Error('Leaf trigger structure refused')
+ exact(text(t.definition).replaceAll(name,parentName),p.definition,'guard definition')
+ }
+ const inherited=raw.triggers.filter(t=>t.relname===name&&t.tgisinternal),parentInternal=raw.triggers.filter(t=>t.relname===parentName&&t.tgisinternal)
+ if(inherited.length!==parentInternal.length||new Set(inherited.map(t=>t.tgparentid)).size!==inherited.length||inherited.some(t=>!parentInternal.some(p=>t.tgparentid===p.oid&&t.tgfoid===p.tgfoid&&t.tgtype===p.tgtype&&t.tgenabled===p.tgenabled&&t.tgnargs===p.tgnargs&&t.arg_bytes===p.arg_bytes&&t.unconditional===p.unconditional&&t.tgdeferrable===p.tgdeferrable&&t.tginitdeferred===p.tginitdeferred&&t.tgoldtable===p.tgoldtable&&t.tgnewtable===p.tgnewtable)))throw Error('Inherited FK trigger identity/state refused')
+ const constraints=(relname:string)=>sorted(raw.constraints.filter(r=>r.relname===relname).map(r=>omit(r,['relname','conname'])))
+ exact(constraints(name),constraints(parentName),'constraints')
+ const indexes=(relname:string)=>sorted(raw.indexes.filter(r=>r.relname===relname).map(r=>{const m=/^CREATE (UNIQUE )?INDEX [^]+? ON (?:ONLY )?public\.[a-z_0-9]+ (USING [^]+)$/.exec(text(r.definition));if(!m)throw Error('Leaf index template refused');return {...omit(r,['relname','index_name','definition']),definition:m[2]}}))
+ exact(indexes(name),indexes(parentName),'indexes')
+ exact(raw.roleGrants.filter(r=>r.relname===name).map(r=>omit(r,['relname'])),raw.roleGrants.filter(r=>r.relname===parentName).map(r=>omit(r,['relname'])),'effective grants')
+}
diff --git a/backend/scripts/writer-profile/catalogue-projection.ts b/backend/scripts/writer-profile/catalogue-projection.ts
new file mode 100644
index 00000000..5f5c3c5e
--- /dev/null
+++ b/backend/scripts/writer-profile/catalogue-projection.ts
@@ -0,0 +1,35 @@
+// Private DATA projection. OIDs remain checked through structural readers separately.
+import {canonical} from './application-writer-profile-canonical.js'
+export type Json=null|boolean|number|string|Json[]|{[key:string]:Json}
+export type Row=Record
+export type Inventory=Record
+export const GROUPS=['columns','triggers','constraints','indexes','roleGrants','inheritance'] as const
+export type CatalogueEdition = 44 | 56 | 57 | 58
+export const GLOBALS=['database','effectiveDatabase','effectiveFunctions','effectiveSchemas','effectiveSequences','events','functions','identities','memberships','parameters','roles','schemas','settings','sequences'] as const
+export const sorted=(rows:Row[])=>rows.slice().sort((a,b)=>canonical(a)canonical(b)?1:0)
+export const omit=(row:Row,names:readonly string[]):Row=>Object.fromEntries(Object.entries(row).filter(([key])=>!names.includes(key)))
+export function text(value:Json|undefined):string {if(typeof value!=='string')throw Error('Catalogue string required');return value}
+export function object(value:Json|undefined):Row {if(!value||typeof value!=='object'||Array.isArray(value))throw Error('Catalogue object required');return value}
+export function rows(value:Json|undefined):Row[] {if(!Array.isArray(value))throw Error('Catalogue array required');return value.map(object)}
+const acl=(value:Json):Json=>value===null?null:rowsOfStrings(value).slice().sort()
+function rowsOfStrings(value:Json):string[]{if(!Array.isArray(value)||value.some(v=>typeof v!=='string'))throw Error('Catalogue string array required');return value as string[]}
+export function projectCatalogueData(raw:Inventory):Inventory {
+ const bases=new Set(raw.tables.filter(t=>t.relispartition===false).map(t=>text(t.relname)))
+ const names=new Map(raw.tables.map(t=>[text(t.oid),text(t.relname)]))
+ const functions=new Map(raw.functions.map(f=>[text(f.oid),text(f.namespace)+'.'+text(f.proname)+'('+text(f.arguments)+')']))
+ const base=(data:Row[])=>data.filter(r=>bases.has(text(r.relname)))
+ const result:Inventory={
+ tables:base(raw.tables).map(r=>({...omit(r,['oid','relpersistence']),acl:acl(r.acl)})),
+ columns:base(raw.columns),identities:raw.identities.map(r=>omit(r,['relation_oid'])),
+ sequences:raw.sequences.map(r=>{const owner=names.get(text(r.owner_relation_oid));if(!owner)throw Error('Sequence owner relation missing');return {...omit(r,['oid','owner_relation_oid']),acl:acl(r.acl),owner_relation:owner}}),
+ functions:raw.functions.map(r=>({...omit(r,['oid']),acl:acl(r.acl)})),
+ triggers:base(raw.triggers).map(t=>({...omit(t,['oid','tgfoid','tgparentid','tgconstraint']),tgname:t.tgisinternal?text(t.tgname).replace(/_[0-9]+$/,'_{oid}'):t.tgname,function:functions.get(text(t.tgfoid))??'pg_catalog#'+text(t.tgfoid),parent:t.tgparentid!=='0',constraint:t.tgconstraint!=='0',definition:t.tgisinternal?text(t.definition).replace(/(RI_ConstraintTrigger_[ac])_[0-9]+/g,'$1_{oid}'):t.definition})),
+ inheritance:raw.inheritance.filter(r=>bases.has(text(r.child))),constraints:base(raw.constraints),indexes:base(raw.indexes),
+ schemas:raw.schemas.map(r=>({...r,acl:acl(r.acl)})),database:raw.database.map(r=>({...r,datname:'current-database',acl:acl(r.acl)})),
+ effectiveSchemas:raw.effectiveSchemas,effectiveDatabase:raw.effectiveDatabase,memberships:raw.memberships,
+ effectiveFunctions:raw.effectiveFunctions.map(r=>omit(r,['oid'])),effectiveSequences:raw.effectiveSequences,
+ events:raw.events.map(r=>{const fn=functions.get(text(r.function_oid));if(!fn)throw Error('Event function missing');return {...omit(r,['function_oid']),function:fn}}),
+ parameters:raw.parameters,settings:raw.settings.map(r=>({...r,database:r.database==='all-databases'?r.database:'current-database'})),roles:raw.roles,roleGrants:base(raw.roleGrants),
+ }
+ return Object.fromEntries(Object.entries(result).map(([name,data])=>[name,sorted(data)]))
+}
diff --git a/backend/scripts/writer-profile/catalogue-value-bridge.ts b/backend/scripts/writer-profile/catalogue-value-bridge.ts
new file mode 100644
index 00000000..c12ab27e
--- /dev/null
+++ b/backend/scripts/writer-profile/catalogue-value-bridge.ts
@@ -0,0 +1,15 @@
+// Typed bounded VALUE -> fixed44 semantic bridge. Requires real EOF, never emits authority.
+// SQL retained cursor/context/source-before-and-after remains the protected host's obligation.
+import {CatalogueValueStream} from './application-writer-profile-catalogue-values.js'
+import {Fixed44CatalogueDataVerifier,type InstallationRoleBindingsData} from './application-writer-profile-catalogue.js'
+import type {CatalogueEdition} from './catalogue-projection.js'
+export class Fixed44CatalogueValueBridgeData {
+ private readonly values=new CatalogueValueStream();private readonly schema:Fixed44CatalogueDataVerifier
+ private eof=false;private closed=false;private failed=false
+ constructor(bindings:InstallationRoleBindingsData,edition:CatalogueEdition=44){this.schema=new Fixed44CatalogueDataVerifier(bindings,edition)}
+ acceptPage(page:readonly unknown[]):void {
+ if(this.eof||this.closed||this.failed)throw Error('Closed/refused VALUE catalogue bridge')
+ try{for(const record of this.values.acceptPage(page))this.schema.consume(record);if(page.length===0)this.eof=true}catch(error){this.failed=true;throw error}
+ }
+ finish(){if(this.closed||this.failed||!this.eof)throw Error('Real cursor EOF required for VALUE catalogue bridge');try{const values=this.values.finish(),catalogue=this.schema.finish();this.closed=true;return Object.freeze({values,catalogue,authority:false,sourceGenerationAuthenticated:false,allWriterDrainAuthenticated:false,readyAuthorized:false})}catch(error){this.failed=true;throw error}}
+}
diff --git a/backend/scripts/writer-profile/catalogue.mts b/backend/scripts/writer-profile/catalogue.mts
new file mode 100644
index 00000000..18405670
--- /dev/null
+++ b/backend/scripts/writer-profile/catalogue.mts
@@ -0,0 +1,57 @@
+import assert from 'node:assert/strict'
+import {Fixed44CatalogueValueBridgeData} from './catalogue-value-bridge.js'
+import {FIXED44_CATALOGUE_BUILD_SQL} from './fixed44-build-sql.js'
+import {BUILD44_PROVENANCE,FIXED44_ROLE_TEMPLATE} from './fixed44-build-definition.js'
+import {BUILD56_PROVENANCE,FIXED56_ROLE_TEMPLATE} from './fixed56-build-definition.js'
+import {BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE} from './fixed57-build-definition.js'
+import {BUILD58_PROVENANCE,FIXED58_ROLE_TEMPLATE} from './fixed58-build-definition.js'
+import {assertRestoreProfileQuarantine} from '../../src/db/database-restore-quarantine-profile.js'
+import {canonical,sha} from './application-writer-profile-canonical.js'
+import type {CatalogueEdition} from './catalogue-projection.js'
+export function approvedDefinition(value:unknown){
+ assert(value&&typeof value==='object');const v=value as Record
+ assert.deepEqual(Object.keys(v).sort(),['format','provenance','template'])
+ if(v.format==='application-writer-source44-definition-approval-v1'){
+ assert.equal(canonical(v.provenance),canonical(BUILD44_PROVENANCE));assert.equal(canonical(v.template),canonical(FIXED44_ROLE_TEMPLATE))
+ return Object.freeze({definitionSha256:BUILD44_PROVENANCE.templateSha256,manifestSha256:BUILD44_PROVENANCE.manifestSha256})
+ }
+ if(v.format==='application-writer-source57-definition-approval-v1'){
+ assert.equal(canonical(v.provenance),canonical(BUILD57_PROVENANCE));assert.equal(canonical(v.template),canonical(FIXED57_ROLE_TEMPLATE))
+ return Object.freeze({edition:57 as const,definitionSha256:BUILD57_PROVENANCE.templateSha256,manifestSha256:BUILD57_PROVENANCE.manifestSha256})
+ }
+ if(v.format==='application-writer-source58-definition-approval-v1'){
+ assert.equal(canonical(v.provenance),canonical(BUILD58_PROVENANCE));assert.equal(canonical(v.template),canonical(FIXED58_ROLE_TEMPLATE))
+ return Object.freeze({edition:58 as const,definitionSha256:BUILD58_PROVENANCE.templateSha256,manifestSha256:BUILD58_PROVENANCE.manifestSha256})
+ }
+ assert.equal(v.format,'application-writer-source56-definition-approval-v1')
+ assert.equal(canonical(v.provenance),canonical(BUILD56_PROVENANCE));assert.equal(canonical(v.template),canonical(FIXED56_ROLE_TEMPLATE))
+ return Object.freeze({edition:56 as const,definitionSha256:BUILD56_PROVENANCE.templateSha256,manifestSha256:BUILD56_PROVENANCE.manifestSha256})
+}
+type CatalogueSession = {query:(sql:string,values?:unknown[])=>Promise<{rows:Record[]} >}
+type CatalogueInstallation = {roleBindings:ConstructorParameters[0]}
+assert.equal(FIXED44_CATALOGUE_BUILD_SQL.split('LIMIT 104').length,2)
+const fixed56Sql = FIXED44_CATALOGUE_BUILD_SQL.replace('LIMIT 104','LIMIT 110')
+/** Real incremental DATA verifier on caller's retained transaction. No pool or attestor. */
+export const collectSource44Catalogue = (s:CatalogueSession, installation:CatalogueInstallation) => collectCatalogue(s, installation, 44)
+export const collectSource56Catalogue = (s:CatalogueSession, installation:CatalogueInstallation) => collectCatalogue(s, installation, 56)
+export const collectSource57Catalogue = (s:CatalogueSession, installation:CatalogueInstallation) => collectCatalogue(s, installation, 57)
+export const collectSource58Catalogue = (s:CatalogueSession, installation:CatalogueInstallation) => collectCatalogue(s, installation, 58)
+async function collectCatalogue(s:CatalogueSession,installation:CatalogueInstallation,edition:CatalogueEdition){
+ const settings=(await s.query("SELECT pg_catalog.current_setting('search_path') AS path,pg_catalog.current_setting('TimeZone') AS zone,pg_catalog.current_setting('DateStyle') AS dates")).rows
+ assert.equal(settings.length,1);assert(['path','zone','dates'].every(k=>typeof settings[0][k]==='string'))
+ let cursor=false,primary:unknown,failed=false
+ try{
+ await s.query("SELECT pg_catalog.set_config('search_path','pg_catalog, public',true),pg_catalog.set_config('TimeZone','UTC',true),pg_catalog.set_config('DateStyle','ISO, YMD',true)")
+ const bindings=installation.roleBindings,values=['operator','runtime','capture','publisher','control'].map(k=>bindings[k as keyof typeof bindings].name)
+ if(edition===58)await assertRestoreProfileQuarantine(s,bindings.runtime.name,bindings.operator.name,bindings.control.name)
+ const bridge=new Fixed44CatalogueValueBridgeData(bindings,edition)
+ await s.query('DECLARE mm_publisher44 NO SCROLL CURSOR WITHOUT HOLD FOR '+(edition===44?FIXED44_CATALOGUE_BUILD_SQL:fixed56Sql),values);cursor=true
+ for(;;){const page=(await s.query('FETCH FORWARD 128 FROM mm_publisher44')).rows;bridge.acceptPage(page);if(page.length===0)break}
+ const result=bridge.finish();await s.query('CLOSE mm_publisher44');cursor=false
+ return {catalogSha256:sha(canonical({values:result.values.snapshotSha256,catalogue:result.catalogue})),definitionSha256:result.catalogue.definitionSha256,manifestSha256:result.catalogue.manifestSha256,leafCount:result.catalogue.leafRelations}
+ }catch(error){primary=error;failed=true;throw error}
+ finally{
+ try{if(cursor)await s.query('CLOSE mm_publisher44');await s.query("SELECT pg_catalog.set_config('search_path',$1,true),pg_catalog.set_config('TimeZone',$2,true),pg_catalog.set_config('DateStyle',$3,true)",[settings[0].path,settings[0].zone,settings[0].dates])}
+ catch(error){if(failed)throw new AggregateError([primary,error],'Catalogue and context cleanup failed');throw error}
+ }
+}
diff --git a/backend/scripts/writer-profile/context.mjs b/backend/scripts/writer-profile/context.mjs
new file mode 100644
index 00000000..dceb75c3
--- /dev/null
+++ b/backend/scripts/writer-profile/context.mjs
@@ -0,0 +1,28 @@
+// Internal fixed SQL/state verification. No signing, provisioning, pool or issuer.
+import {canonical} from '../../src/db/application-writer-profile-format.js'
+import {readProtectedRegistryStructureData} from '../../src/db/application-writer-profile-registry-structure.js'
+export {readCurrentApplicationWriterProfile as readCurrent,HISTORY,CURRENT} from '../../src/db/application-writer-profile-registry-read.js'
+
+
+const same=(a,b,phase)=>{if(canonical(a)!==canonical(b))throw Error('Protected registry refused: '+phase)}
+export async function ownedContext(client,installation,actor,phase){
+ const rows=(await client.query(`SELECT CURRENT_USER::text AS actor,SESSION_USER::text AS login,r.oid::text AS role_oid,
+ d.oid::text AS database_oid,d.datname AS database_name,pg_catalog.pg_backend_pid() AS pid,
+ pg_catalog.pg_current_xact_id_if_assigned()::text AS xid,pg_catalog.current_setting('transaction_read_only') AS read_only,
+ pg_catalog.current_setting('transaction_isolation') AS isolation,pg_catalog.current_setting('server_version_num')::int AS version,
+ pg_catalog.pg_is_in_recovery() AS recovery,control.system_identifier::text AS system_identifier,
+ (EXTRACT(EPOCH FROM pg_catalog.clock_timestamp())*1000)::bigint::text AS server_now,
+ EXISTS(SELECT 1 FROM pg_catalog.pg_locks l WHERE l.pid=pg_catalog.pg_backend_pid() AND l.locktype='advisory'
+ AND l.database=d.oid AND l.classid=0 AND l.objid=8723110 AND l.objsubid=1 AND l.granted
+ AND l.mode=ANY($1::text[])) AS admitted
+ FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_control_system() control
+ WHERE r.rolname=CURRENT_USER AND d.datname=pg_catalog.current_database()`,[phase.startsWith('publisher')?['ExclusiveLock']:['ShareLock','ExclusiveLock']])).rows
+ const c=rows[0],expectedOid=installation.roleBindings.publisher.signedOid
+ if(actor!==installation.roleBindings.publisher.name||rows.length!==1||!c||c.actor!==actor||c.login!==actor||c.role_oid!==expectedOid||c.recovery!==false||c.version<180000||c.version>=190000||c.admitted!==true||!Number.isSafeInteger(c.pid)||!/^[1-9][0-9]*$/.test(c.database_oid)||!(/^[1-9][0-9]{0,19}$/).test(c.system_identifier))throw Error('Distinct actual actor/source/admission context refused')
+ if(phase==='publisher-read'&&(c.read_only!=='on'||c.isolation!=='repeatable read')||phase==='publisher-inspect'&&(c.read_only!=='on'||c.isolation!=='read committed')||['publisher-write','operator'].includes(phase)&&(c.read_only!=='off'||c.isolation!=='read committed'||!(/^[1-9][0-9]*$/).test(c.xid??'')))throw Error('Distinct owned transaction context refused')
+ return c
+}
+export function sameOwned(a,b){same(Object.fromEntries(['actor','login','role_oid','database_oid','database_name','pid','xid','read_only','isolation','version','recovery','system_identifier','admitted'].map(k=>[k,a[k]])),Object.fromEntries(['actor','login','role_oid','database_oid','database_name','pid','xid','read_only','isolation','version','recovery','system_identifier','admitted'].map(k=>[k,b[k]])),'backend/fullXID/lifetime')}
+export const sourceCoordinates=c=>({systemIdentifier:c.system_identifier,databaseOid:c.database_oid,databaseName:c.database_name,serverVersionNum:c.version,inRecovery:false})
+
+export function protectedStructure(client,installation,runtimeReads=false){return readProtectedRegistryStructureData(client,installation.roleBindings,runtimeReads)}
diff --git a/backend/scripts/writer-profile/expanded44-data-policy.ts b/backend/scripts/writer-profile/expanded44-data-policy.ts
new file mode 100644
index 00000000..eb8358bc
--- /dev/null
+++ b/backend/scripts/writer-profile/expanded44-data-policy.ts
@@ -0,0 +1,134 @@
+// VERSIONED DATA-only candidate. Never installation policy, enrollment or writer permission.
+import {BUILD44_PROVENANCE,FIXED44_ROLE_TEMPLATE} from './fixed44-build-definition.js'
+import {BUILD56_PROVENANCE,FIXED56_ROLE_TEMPLATE} from './fixed56-build-definition.js'
+import {BUILD57_PROVENANCE} from './fixed57-build-definition.js'
+import {BUILD58_PROVENANCE} from './fixed58-build-definition.js'
+import {fixedCatalogueParentPeriodData} from './application-writer-profile-catalogue-parent-policy.js'
+import {GROUPS,type CatalogueEdition,type Inventory} from './catalogue-projection.js'
+export const EXPANDED44_POLICY_VERSION='source44-managed-leaves-3000-data-v1' as const
+const PLANNED=2000,EXPIRED=1000,PER_PARENT=1000,LEAVES=PLANNED+EXPIRED
+const source=FIXED44_ROLE_TEMPLATE
+const baseNames=new Set(source.tables.map(row=>String(row.relname)))
+const parents=[...baseNames].filter(name=>fixedCatalogueParentPeriodData(name)!==undefined)
+const perRelation=new Map([...baseNames].map(name=>[name,Object.fromEntries(GROUPS.map(group=>[group,source[group].filter(row=>(group==='inheritance'?row.child:row.relname)===name).length])) as Record]))
+const base=Object.freeze(Object.fromEntries(GROUPS.map(group=>[group,source[group].length])) as Record)
+const leafMax=Object.freeze(Object.fromEntries(GROUPS.map(group=>[group,group==='inheritance'?1:Math.max(...parents.map(name=>perRelation.get(name)![group]))])) as Record)
+if(baseNames.size!==104||source.tables.length!==104||parents.length!==12||leafMax.columns!==18||leafMax.constraints!==17||leafMax.triggers!==5||leafMax.indexes!==2||leafMax.roleGrants!==4)throw Error('Exact reviewed source44 topology changed; rederive policy')
+for(const row of source.constraints)if(parents.includes(String(row.relname))&&!['n','c','p','f'].includes(String(row.contype)))throw Error('Unreviewed parent constraint semantics')
+const total=Object.freeze(Object.fromEntries(GROUPS.map(group=>[group,base[group]+LEAVES*leafMax[group]])) as Record)
+export const EXPANDED44_DATA_POLICY=Object.freeze({version:EXPANDED44_POLICY_VERSION,baseRelations:baseNames.size,parents:parents.length,maxPlannedLeaves:PLANNED,maxExpiredBacklog:EXPIRED,maxManagedLeaves:LEAVES,maxPerParent:PER_PARENT,maxRelations:baseNames.size+LEAVES,maxWeightedPlan:2000,baseRows:base,maxLeafRows:leafMax,maxRows:total,definitionSha256:BUILD44_PROVENANCE.templateSha256,authority:false,productionInstallationPolicyApproved:false,settingsAdmissionAuthorized:false,readyAuthorized:false})
+const source56PerRelation = new Map(FIXED56_ROLE_TEMPLATE.tables.map(({relname}) => [String(relname), Object.fromEntries(
+ GROUPS.map(group => [group, FIXED56_ROLE_TEMPLATE[group].filter(row => (group === 'inheritance' ? row.child : row.relname) === relname).length]),
+) as Record]))
+const source56BaseRows = Object.freeze(Object.fromEntries(GROUPS.map(group => [group, FIXED56_ROLE_TEMPLATE[group].length])) as Record)
+if (source56PerRelation.size !== 110 || FIXED56_ROLE_TEMPLATE.tables.length !== 110 ||
+ [...source56PerRelation.keys()].filter(name => fixedCatalogueParentPeriodData(name)).length !== parents.length ||
+ parents.some(name => GROUPS.some(group => source56PerRelation.get(name)?.[group] !== perRelation.get(name)![group]))) {
+ throw Error('Unexpected source56 base or managed partition topology')
+}
+const EXPANDED56_DATA_POLICY = Object.freeze({
+ ...EXPANDED44_DATA_POLICY,
+ version: 'source56-managed-leaves-3000-data-v1',
+ baseRelations: source56PerRelation.size,
+ maxRelations: source56PerRelation.size + LEAVES,
+ baseRows: source56BaseRows,
+ maxRows: Object.freeze(Object.fromEntries(GROUPS.map(group => [group, source56BaseRows[group] + LEAVES * leafMax[group]])) as Record),
+ definitionSha256: BUILD56_PROVENANCE.templateSha256,
+})
+const auditCounts = source56PerRelation.get('mcp_audit')!
+const source57PerRelation = new Map(source56PerRelation).set('mcp_audit', {...auditCounts, indexes: auditCounts.indexes + 1})
+const EXPANDED57_DATA_POLICY = Object.freeze({
+ ...EXPANDED56_DATA_POLICY,
+ version: 'source57-managed-leaves-3000-data-v1',
+ baseRows: Object.freeze({...source56BaseRows, indexes: source56BaseRows.indexes + 1}),
+ maxRows: Object.freeze({...EXPANDED56_DATA_POLICY.maxRows, indexes: EXPANDED56_DATA_POLICY.maxRows.indexes + 1}),
+ definitionSha256: BUILD57_PROVENANCE.templateSha256,
+})
+const EXPANDED58_DATA_POLICY = Object.freeze({
+ ...EXPANDED57_DATA_POLICY,
+ version: 'source58-managed-leaves-3000-data-v1',
+ definitionSha256: BUILD58_PROVENANCE.templateSha256,
+})
+const policies = {44: EXPANDED44_DATA_POLICY, 56: EXPANDED56_DATA_POLICY, 57: EXPANDED57_DATA_POLICY, 58: EXPANDED58_DATA_POLICY}
+const relationCounts = {44: perRelation, 56: source56PerRelation, 57: source57PerRelation, 58: source57PerRelation}
+export const catalogueTopologyPolicy = (edition: CatalogueEdition) => policies[edition]
+export const expanded44ParentRowCountsData=()=>Object.freeze(Object.fromEntries(parents.map(name=>[name,Object.freeze({...perRelation.get(name)!})])))
+export interface ManagedLeafData {readonly parent:string;readonly name:string}
+export function validateManagedLeafNameData(input:ManagedLeafData):void {
+ if(!input||Object.keys(input).sort().join(',')!=='name,parent'||typeof input.parent!=='string'||typeof input.name!=='string')throw Error('Exact managed leaf DATA shape required')
+ const period=fixedCatalogueParentPeriodData(input.parent)
+ if(!period||!input.name.startsWith(input.parent+'_'+period+'_'))throw Error('Unknown/cross-parent managed leaf')
+ const stamp=input.name.slice(input.parent.length+3)
+ if(!new RegExp('^[0-9]{'+(period==='m'?6:8)+'}$').test(stamp))throw Error('Managed leaf name shape refused')
+ const iso=stamp.slice(0,4)+'-'+stamp.slice(4,6)+'-'+(period==='m'?'01':stamp.slice(6,8)),start=new Date(iso+'T00:00:00Z'),end=new Date(start)
+ if(!Number.isFinite(+start)||start.toISOString().slice(0,10)!==iso||period==='w'&&start.getUTCDay()!==1)throw Error('Managed leaf calendar refused')
+ if(period==='m')end.setUTCMonth(end.getUTCMonth()+1);else end.setUTCDate(end.getUTCDate()+(period==='w'?7:1))
+ if(start.getUTCFullYear()<100||end.getUTCFullYear()>9998)throw Error('Managed leaf bounded calendar refused')
+}
+/** Only exact template-validated relation counts enter this sticky cumulative DATA budget. */
+export class Expanded44TopologyBudgetData {
+ constructor(private readonly edition: CatalogueEdition = 44) {}
+ private readonly names=new Set();private readonly perParent=new Map();private readonly rows=Object.fromEntries(GROUPS.map(g=>[g,0])) as Record
+ private bases=0;private leaves=0;private failed=false;private closed=false
+ acceptRelation(kind:'base'|'leaf',name:string,groups:Inventory,parent?:string):void {
+ try{
+ const policy = catalogueTopologyPolicy(this.edition)
+ const counts = relationCounts[this.edition]
+ if(this.failed||this.closed||this.names.has(name)||this.names.size>=policy.maxRelations)throw Error('Closed/duplicate/total relation DATA envelope')
+ const expected=kind==='base'&&parent===undefined?counts.get(name):kind==='leaf'&&parent!==undefined&&parents.includes(parent)?{...counts.get(parent)!,inheritance:1}:undefined
+ if(!expected)throw Error('Unknown source'+this.edition+' base/parent')
+ if(kind==='leaf'){
+ validateManagedLeafNameData({name,parent:parent!})
+ if(this.leaves>=LEAVES||(this.perParent.get(parent!)??0)>=PER_PARENT)throw Error('Managed leaf total/per-parent DATA envelope')
+ }
+ for(const group of GROUPS){if(!Array.isArray(groups[group])||groups[group].length!==expected[group]||this.rows[group]+groups[group].length>policy.maxRows[group])throw Error('Exact source'+this.edition+' '+group+' DATA row envelope')}
+ this.names.add(name);for(const group of GROUPS)this.rows[group]+=groups[group].length
+ if(kind==='base')this.bases++;else{this.leaves++;this.perParent.set(parent!,1+(this.perParent.get(parent!)??0))}
+ }catch(error){this.failed=true;throw error}
+ }
+ finish(){if(this.failed||this.closed||this.bases!==catalogueTopologyPolicy(this.edition).baseRelations)throw Error('Incomplete/refused expanded topology DATA');this.closed=true;return Object.freeze({baseRelations:this.bases,leafRelations:this.leaves,rows:Object.freeze({...this.rows}),perParent:Object.freeze(Object.fromEntries(this.perParent)),authority:false})}
+}
+/** Proposed projected admission DATA, not a trusted expiry observation or permission.
+ * Genuine host must classify current leaves and bind same-session maintenance/settings separately.
+ * Planned can include future leaves not present yet. Unclassified current leaves refuse.
+ */
+export function validateExpanded44AdmissionData(input:Readonly<{current:readonly ManagedLeafData[];planned:readonly ManagedLeafData[];expiredBacklog:readonly ManagedLeafData[]}>){
+ if(!input||Object.keys(input).sort().join(',')!=='current,expiredBacklog,planned')throw Error('Exact admission DATA fields required')
+ const parse=(values:readonly ManagedLeafData[],cap:number)=>{if(!Array.isArray(values)||values.length>cap)throw Error('Admission DATA list envelope');const map=new Map();for(const row of values){validateManagedLeafNameData(row);if(map.has(row.name))throw Error('Duplicate admission leaf');map.set(row.name,row)}return map}
+ const current=parse(input.current,LEAVES),planned=parse(input.planned,PLANNED),expired=parse(input.expiredBacklog,EXPIRED)
+ let weighted=0;for(const row of planned.values())weighted+=['flow_hour_facts','flow_daily_facts'].includes(row.parent)?2:1
+ if(weighted>2000)throw Error('Source weighted planned budget exceeded')
+ const projected=new Map(planned)
+ for(const [name,row]of expired){if(projected.has(name)||!current.has(name))throw Error('Overlapping/noncurrent expired DATA');projected.set(name,row)}
+ for(const [name,row]of current){const classified=projected.get(name);if(!classified||classified.parent!==row.parent)throw Error('Unclassified/cross-parent current leaf DATA')}
+ if(projected.size>LEAVES)throw Error('Projected managed leaves DATA envelope')
+ const perParent=new Map();for(const row of projected.values()){const count=1+(perParent.get(row.parent)??0);if(count>PER_PARENT)throw Error('Projected per-parent DATA envelope');perParent.set(row.parent,count)}
+ return Object.freeze({version:EXPANDED44_POLICY_VERSION,currentLeaves:current.size,plannedLeaves:planned.size,expiredBacklog:expired.size,projectedLeaves:projected.size,weightedPlan:weighted,perParent:Object.freeze(Object.fromEntries(perParent)),authority:false,expiryClassificationAuthenticated:false,settingsAdmissionAuthorized:false,readyAuthorized:false})
+}
+
+/** Exact query meaning, not deparser-byte guesses. Unknown internal tree sizes
+ * remain the unchanged actual SQL scalar preflight's obligation. */
+export const EXPANDED44_SOURCE_SIZE_SEMANTICS_DATA=Object.freeze({
+ function_bytes:'sum pg_proc.prosrc UTF8 bytes; fixed global functions, no per-leaf routine copy',
+ default_bytes:'sum pg_attrdef.adbin::text pg_node_tree bytes; NOT default_expression deparser bytes',
+ check_bytes:'sum pg_constraint.conbin::text pg_node_tree bytes; NOT pg_get_constraintdef bytes',
+ trigger_bytes:'sum octet_length(tgqual::text)+octet_length(tgargs); NULL qualifier terms are ignored by SQL sum; NOT trigger definition bytes',
+ unchangedEachSourceScalarLimitBytes:2097152,internalTreeSizesDerived:false,actualSqlRequired:true,authority:false
+})
+export const expanded44LeafSourceShapeFactsData=()=>Object.freeze(Object.fromEntries(parents.map(parent=>{
+ const columns=source.columns.filter(row=>row.relname===parent),constraints=source.constraints.filter(row=>row.relname===parent),triggers=source.triggers.filter(row=>row.relname===parent)
+ return [parent,Object.freeze({defaultExpressionRows:columns.filter(row=>row.default_expression!==null).length,checkExpressionRows:constraints.filter(row=>row.contype==='c').length,qualifierRows:triggers.filter(row=>row.unconditional!==true).length,argumentBytes:triggers.reduce((sum,row)=>sum+Number(row.arg_bytes),0),routineCopiesPerLeaf:0,internalTreeBytesKnown:false})]
+})))
+
+/** Exact extremum of expression ROW COUNTS, not an invented pg_node_tree byte cap.
+ * Unit leaf costs +1000 capacity/parent +3000 total => top3 source costs.
+ * Different scalar extrema may require different valid topologies.
+ */
+export function expanded44SourceShapeExtremaData(){
+ const facts=expanded44LeafSourceShapeFactsData()
+ const maximize=(field:'defaultExpressionRows'|'checkExpressionRows')=>{
+ const selected=Object.entries(facts).sort((a,b)=>b[1][field]-a[1][field]||(a[0]sum+value[field]*PER_PARENT,0),cohorts:Object.freeze(selected.map(([parent,value])=>Object.freeze({parent,leaves:PER_PARENT,rowsPerLeaf:value[field]})))})
+ }
+ return Object.freeze({baseDefaultExpressionRows:source.columns.filter(row=>row.default_expression!==null).length,baseCheckExpressionRows:source.constraints.filter(row=>row.contype==='c').length,baseQualifiedTriggerRows:source.triggers.filter(row=>row.unconditional!==true).length,maxAddedDefaultExpressionRows:maximize('defaultExpressionRows'),maxAddedCheckExpressionRows:maximize('checkExpressionRows'),perLeafQualifiedTriggerRows:0,perLeafRoutineCopies:0,internalTreeByteUpperBoundKnown:false,actualSqlSourceScalarGateRequired:true,authority:false})
+}
diff --git a/backend/scripts/writer-profile/fixed44-build-definition.ts b/backend/scripts/writer-profile/fixed44-build-definition.ts
new file mode 100644
index 00000000..01389ab8
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed44-build-definition.ts
@@ -0,0 +1,4 @@
+// OFFLINE source-derived candidate; clean4role SQL verification PENDING. No installation enrollment.
+import type {Inventory} from "./catalogue-projection.js"
+export const BUILD44_PROVENANCE={"format":"source44-build-candidate-v1","manifestSha256":"fffae3381732e6f276ba276aca7185f6a87587edf8272ba42763b7f49bc59ef5","reviewed43Sha256":"4dd21cf909628f2750294e0d4398064d5219f6547c1bcebec910efabe9d57dcd","migration44Sha256":"37b88d1679be9bb47f16ccc8cae7373f20f9c05e7a8f662c3775f18d78bb5613","templateSha256":"56bbe286968fd950e5239672158f198eb2d600b7fa2fcb290c2ec5befd08d90c","baseTables":104,"newColumns":13,"newConstraints":21,"newFunctions":3,"newIndexes":5,"newApplicationTriggers":4,"newInheritedWriterGuards":3,"sourceNamingAlgorithm":"PG18 makeObjectName balanced ASCII byte truncation; ChooseConstraintName collision-free branch only; collisions refuse","namingSources":["https://raw.githubusercontent.com/postgres/postgres/REL_18_STABLE/src/backend/commands/indexcmds.c","https://raw.githubusercontent.com/postgres/postgres/REL_18_STABLE/src/backend/catalog/pg_constraint.c"],"cleanFourRoleSqlVerified":false,"productionInstallationPolicyApproved":false,"authority":false} as const
+export const FIXED44_ROLE_TEMPLATE:Readonly={"columns":[{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"access_scope","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_artifacts","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"account_private_key","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"''::text","relname":"acme_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ack_proof","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_poll_acks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"acknowledged_at","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_drift","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"action","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_audit","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"action","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'route'::text","relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"action_id","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"action_version","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"active","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"true","relname":"app_users","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"actor_id","attnotnull":false,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"actor_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_audit","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"actor_id","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_diagnostic_cancellations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"actor_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"admissions","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"admissions","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"0","relname":"server_probe_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"after_sealed","attnotnull":false,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_operation_checkpoints","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"api_key","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"evobgp_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"applied_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"now()","relname":"schema_migrations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"approved_at","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"approved_by","attnotnull":false,"attnum":11,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"archive_bytes","attnotnull":false,"attnum":21,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"archive_bytes","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"archive_proof","attnotnull":true,"attnum":17,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_asn_meta","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"0","relname":"flow_ip_meta","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"flow_daily_facts","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"flow_hour_facts","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"asn_build_at","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"attempted_stages","attnotnull":false,"attnum":16,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"attempted_stages","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_quarantines","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"attempts","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"1","relname":"mcp_unauthorized_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"attestation","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_management_channels","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"audience","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"mcp_credentials","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"audit_retention_days","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"180","relname":"mcp_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authentication","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_expires_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_expires_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_expires_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_issued_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_issued_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_profile_id","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_profile_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"authority_profile_version","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"avatar","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"''::text","relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bandwidth_at","attnotnull":false,"attnum":13,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"base_url","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"evobgp_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"batch_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_write_receipts","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"before_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_poll_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"before_sealed","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_operation_checkpoints","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"before_state","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_operation_steps","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_poll_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_probe_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_poll_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_routing_forward_charges","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_proof","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_sealed","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_sealed","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_routing_forward_charges","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"binding_sealed","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"board_name","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bot_token","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"alert_telegram_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_unauthorized_buckets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_budget_buckets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_buckets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_hour_facts","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_minute_dims","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bucket_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_minute_stats","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"0","relname":"flow_minute_stats","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"flow_daily_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"flow_minute_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"flow_daily_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"flow_hour_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"bytes","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cancelled_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"candidate_id","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_path_checks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cert_name","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"challenge","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"channel","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'telegram'::text","relname":"alert_outbox","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"charge_units","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"charge_units","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"1","relname":"mcp_routing_forward_charges","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"chat_id","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"alert_telegram_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"check_gateway","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":"''::text","relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ciphertext","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":null,"relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ciphertext","attnotnull":true,"attnum":15,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ciphertext","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_secrets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ciphertext","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_artifacts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ciphertext_bytes","attnotnull":true,"attnum":16,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_attempted_at","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_attempted_at","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_token","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_token","attnotnull":false,"attnum":7,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claimed_at","attnotnull":false,"attnum":14,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"client_hash","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_unauthorized_buckets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"client_id","attnotnull":false,"attnum":9,"attstorage":"x","default_expression":null,"relname":"mcp_credentials","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"client_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cloudflare_api_token","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"acme_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"code_digest","attnotnull":false,"attnum":11,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"collector_ip","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'10.255.254.1'::text","relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"combine_mode","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'any'::text","relname":"alert_groups","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"comment","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":"''::text","relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"comment","attnotnull":true,"attnum":13,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"comment","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"''::text","relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"committed_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"flow_write_receipts","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"community","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"community_name","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compact_at","attnotnull":false,"attnum":20,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compacted_admissions","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compaction_claim","attnotnull":false,"attnum":23,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compaction_claim_xid","attnotnull":false,"attnum":25,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"xid8"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compaction_claimed_at","attnotnull":false,"attnum":24,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compaction_xid","attnotnull":true,"attnum":19,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"xid8"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"completed_stages","attnotnull":false,"attnum":17,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"completed_stages","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_quarantines","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"compressed_bytes","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"condition","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"condition_line","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"alert_rule_conditions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"config","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_routing_profiles","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"config_sealed","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_management_channels","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"configuration_proof","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_operation_checkpoints","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"configuration_sealed","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_operation_checkpoints","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"confirm_stability_sec","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"alert_rules","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_oauth_requests","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":false,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_requests","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_audit","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_budget_buckets","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_artifacts","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_credentials","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_diagnostic_cancellations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_grants","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_path_checks","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_read_leases","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_profiles","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_operations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"consumed_at","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_oauth_requests","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_ciphertext","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_poll_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_poll_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_proof","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_poll_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_proof","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_proof","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"server_poll_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"context_verified","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"false","relname":"mcp_routing_observations","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"conversations","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"flow_minute_stats","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cooldown","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"'5м'::text","relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cooldown_override","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"alert_groups","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"''::text","relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"flow_ip_meta","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"flow_daily_facts","type":"character(2)"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"flow_hour_facts","type":"character(2)"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"country_build_at","attnotnull":false,"attnum":7,"attstorage":"p","default_expression":null,"relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cpu_load","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"cpu_load","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"now()","relname":"filter_rules","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"now()","relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"now()","relname":"app_users","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"now()","relname":"mcp_requests","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"now()","relname":"uptime_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"now()","relname":"mcp_plans","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"now()","relname":"mcp_routing_reservations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"now()","relname":"uptime_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"now()","relname":"alert_rules","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"now()","relname":"mcp_scoped_recovery_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"now()","relname":"recursive_routes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":16,"attstorage":"p","default_expression":"now()","relname":"mcp_routing_observations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":18,"attstorage":"p","default_expression":"now()","relname":"servers","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":18,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":19,"attstorage":"p","default_expression":"now()","relname":"traffic_flow_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"events","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":20,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_probe_executions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":20,"attstorage":"p","default_expression":"now()","relname":"uptime_speed_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":21,"attstorage":"p","default_expression":"now()","relname":"uptime_speed_test_runs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"clock_timestamp()","relname":"mcp_diagnostic_cancellations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_receipts","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"now()","relname":"mcp_portal_events","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"now()","relname":"mcp_recovery_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_quarantines","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"mcp_oauth_clients","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"mcp_operation_checkpoints","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"mcp_protections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"mcp_routing_reservation_slots","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_acks","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"now()","relname":"alert_groups","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"now()","relname":"flow_settings_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"now()","relname":"mcp_audit","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"now()","relname":"mcp_secrets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_poll_executions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_probe_execution_stages","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"mcp_artifacts","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"mcp_connections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"mcp_credentials","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"mcp_path_checks","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"servers_api_ping_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"config_revisions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"internet_path_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"mcp_operation_steps","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"traffic_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"backup_entries","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"clock_timestamp()","relname":"server_probe_execution_quarantines","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"alert_outbox","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"mcp_operations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"user_interface_bindings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_by","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_protections","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_by","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_secrets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"created_by","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_management_channels","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"credential_id","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_routing_profiles","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"day","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_daily_dims","type":"date"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"day","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"flow_daily_facts","type":"date"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"deadline","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"deadline","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"decoded_bytes","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dedupe_key","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_outbox","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"default_zone_id","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"''::text","relname":"acme_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"description","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"''::text","relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"destination_server_id","attnotnull":false,"attnum":13,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"detected_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"mcp_drift","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"digest","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_credentials","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"digest","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":null,"relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dim","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_daily_dims","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dim","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_minute_dims","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"direction","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":"'both'::text","relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"direction","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"'both'::text","relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"directory_url","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"'https://acme-v02.api.letsencrypt.org/directory'::text","relname":"acme_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"disabled","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"false","relname":"recursive_routes","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"distance","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"1","relname":"recursive_routes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dl_mbps","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst","attnotnull":true,"attnum":4,"attstorage":"m","default_expression":null,"relname":"flow_buckets","type":"inet"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_address","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_address","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_interface","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"''::text","relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_interface","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_interface","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"''::text","relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_interface_address","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_port","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_server_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_server_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"dst_server_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"duration_ms","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_requests","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"duration_ms","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"scheduler_runs","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"duration_sec","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"10","relname":"uptime_speed_test_runs","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"duration_sec","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"10","relname":"uptime_speed_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"effect_proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_poll_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"effective_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"email","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"''::text","relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"true","relname":"servers","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"false","relname":"mcp_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"false","relname":"router_log_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"false","relname":"servers_api_ping_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"false","relname":"traffic_flow_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"backup_schedule_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"certificate_renew_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"geoip_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"internet_path_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"traffic_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":"true","relname":"uptime_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"false","relname":"evobgp_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"true","relname":"alert_groups","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"true","relname":"mcp_oauth_clients","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"false","relname":"mcp_routing_profiles","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"true","relname":"alert_rules","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"true","relname":"uptime_probes","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"enabled","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"true","relname":"uptime_speed_probes","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"entity_id","attnotnull":false,"attnum":9,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"entity_type","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error","attnotnull":false,"attnum":13,"attstorage":"x","default_expression":null,"relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error","attnotnull":false,"attnum":20,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"servers_rest_ping_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"scheduler_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"traffic_collection_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error_code","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_operations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error_code","attnotnull":false,"attnum":9,"attstorage":"x","default_expression":null,"relname":"mcp_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"error_code","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"etags_json","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'{}'::jsonb","relname":"geoip_settings","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"event_at","attnotnull":false,"attnum":7,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"event_type","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"evidence","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_path_checks","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"evidence","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_poll_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_poll_quarantines","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_quarantines","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"execution_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expected","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_drift","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_read_leases","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_credentials","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_artifacts","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_management_channels","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"expires_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_oauth_requests","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"failures","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"0","relname":"router_log_collection_state","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"family","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"family_id","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_credentials","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"fetched_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"flow_asn_meta","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"fetched_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"flow_ip_meta","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"filename","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_artifacts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"filename","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"fingerprint","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"config_revisions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_operations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"certificate_issue_jobs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"mcp_requests","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":15,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":21,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_recovery_intents","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_operation_steps","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"finished_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"scheduler_runs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"fired_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"alert_history","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"flags","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"0","relname":"traffic_samples","type":"smallint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"flow_end_ms","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"flow_listen_port","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"4739","relname":"traffic_flow_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"flow_start_ms","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"format","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'rsc'::text","relname":"backup_schedule_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"free_hdd_space","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"free_memory","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"free_memory","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"frequency","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'daily'::text","relname":"backup_schedule_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gap_at","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"router_log_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gateway","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gateway","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"''::text","relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gateway_tunnel_id","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"''::text","relname":"filter_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gc_not_before","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"'infinity'::timestamp with time zone","relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"gc_not_before","attnotnull":true,"attnum":16,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"mcp_routing_profiles","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"router_log_collection_state","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_connections","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"generation","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_management_channels","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"grant_expires_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"mcp_routing_profiles","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"group_id","attnotnull":false,"attnum":13,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"group_id","attnotnull":false,"attnum":3,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"holder","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"flow_asn_meta","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"holder","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"''::text","relname":"flow_ip_meta","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"host","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"router_log_collection_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"host","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"host","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"host_private_key","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"''::text","relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"host_public_key","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"''::text","relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"hour","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"3","relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"hub_server_id","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"traffic_flow_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"acme_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"alert_engine_cursor","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"alert_telegram_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"backup_schedule_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"backup_storage_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"certificate_renew_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"data_migration","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"evobgp_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"geoip_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"internet_path_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_artifacts","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_connections","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_credentials","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_drift","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_grants","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_management_channels","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_oauth_requests","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_operations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_path_checks","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_portal_events","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_protections","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_read_leases","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_requests","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_profiles","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_secrets","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"router_log_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"servers_api_ping_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"traffic_flow_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"traffic_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"uptime_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_groups","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_outbox","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_rule_conditions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_rule_targets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"config_revisions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_clients","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"scheduler_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"schema_migrations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"uptime_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"idempotency_key","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_operations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_hash","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_management_channels","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_kind","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_name","attnotnull":false,"attnum":12,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"identity_proof","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_quarantines","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"iface","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_daily_facts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"iface","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_hour_facts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"in_iface","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":"''::text","relname":"flow_buckets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"input","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"'{}'::jsonb","relname":"mcp_requests","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"intended_state","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_operation_steps","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"intent_proof","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"intent_proof","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_poll_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"intent_sealed","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interface_name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"traffic_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interface_name","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interface_type","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'other'::text","relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"10","relname":"router_log_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"120","relname":"servers_api_ping_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"21600","relname":"certificate_renew_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"30","relname":"traffic_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"300","relname":"internet_path_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"15","relname":"uptime_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"interval_sec","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"uptime_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"invalid_before","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_owner_revocations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"inverse_configuration_proof","attnotnull":false,"attnum":23,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"inverse_configuration_sealed","attnotnull":false,"attnum":22,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"inverse_intent_proof","attnotnull":false,"attnum":21,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"inverse_intent_sealed","attnotnull":false,"attnum":20,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"issued_at","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"job_key","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"scheduler_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"keep_count","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"7","relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"keep_local_copy","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"true","relname":"backup_storage_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"key","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"flow_daily_dims","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"key","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"flow_minute_dims","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"key_type","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"'rsa2048'::text","relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_engine_prev_live","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"flow_write_receipts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_budget_buckets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_stages","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_credentials","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"kind","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'manual'::text","relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"lan_subnet","attnotnull":true,"attnum":15,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"lane","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservation_slots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_attempt_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"traffic_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_check_at","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"uptime_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"servers_api_ping_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"certificate_renew_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"internet_path_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"traffic_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_collected_at","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"router_log_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_datagram_at","attnotnull":false,"attnum":14,"attstorage":"p","default_expression":null,"relname":"traffic_flow_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"uptime_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"servers_api_ping_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"certificate_renew_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"internet_path_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_duration_ms","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"traffic_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":11,"attstorage":"x","default_expression":null,"relname":"alert_outbox","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":12,"attstorage":"x","default_expression":null,"relname":"uptime_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":13,"attstorage":"x","default_expression":null,"relname":"backup_schedule_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":14,"attstorage":"x","default_expression":null,"relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":16,"attstorage":"x","default_expression":null,"relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"geoip_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"servers_api_ping_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"certificate_renew_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"internet_path_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"router_log_collection_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_error","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"traffic_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_exporter_ip","attnotnull":false,"attnum":15,"attstorage":"x","default_expression":null,"relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_fired_at","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"alert_engine_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_payload_hash","attnotnull":false,"attnum":3,"attstorage":"x","default_expression":null,"relname":"alert_engine_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_ping_at","attnotnull":false,"attnum":17,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_ping_error","attnotnull":false,"attnum":18,"attstorage":"x","default_expression":null,"relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_ping_loss_pct","attnotnull":false,"attnum":16,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_ping_rtt_ms","attnotnull":false,"attnum":15,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_run_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_run_at","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"backup_schedule_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_rx_avg_mbps","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_seen","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"app_users","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_source_finished_at","attnotnull":false,"attnum":2,"attstorage":"p","default_expression":null,"relname":"alert_engine_cursor","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_status","attnotnull":false,"attnum":13,"attstorage":"x","default_expression":null,"relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_succeeded_at","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"traffic_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_success_at","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_test_at","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"backup_storage_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_test_error","attnotnull":false,"attnum":12,"attstorage":"x","default_expression":null,"relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_tx_avg_mbps","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"last_used_at","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_connections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"lat","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"flow_ip_meta","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"latency_ms","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"servers_rest_ping_samples","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"latency_ms","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"level","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"level","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"lng","attnotnull":false,"attnum":5,"attstorage":"p","default_expression":null,"relname":"flow_ip_meta","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"login","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"loss_pct","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"loss_pct","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"uptime_probe_samples","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"map_service_min_share_pct","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"5","relname":"traffic_flow_settings","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"max_retries","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"3","relname":"alert_outbox","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"max_stages","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"mcp_connection_id","attnotnull":false,"attnum":7,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"mcp_credential_id","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"measurement_known","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"true","relname":"uptime_probe_samples","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"media_type","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_artifacts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"message","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"message","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"message","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"message_thread_id","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"alert_telegram_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"mgmt_tunnel_ip","attnotnull":true,"attnum":17,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"minute","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"mode","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"month_day","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"1","relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_groups","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_connections","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_clients","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"name","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"uptime_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"nat_dst","attnotnull":false,"attnum":16,"attstorage":"m","default_expression":null,"relname":"flow_buckets","type":"inet"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"nat_dst_port","attnotnull":true,"attnum":18,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"nat_src","attnotnull":false,"attnum":15,"attstorage":"m","default_expression":null,"relname":"flow_buckets","type":"inet"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"nat_src_port","attnotnull":true,"attnum":17,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"native_counter_identity","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"traffic_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"next_attempt_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"alert_outbox","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"next_hop","attnotnull":false,"attnum":12,"attstorage":"m","default_expression":null,"relname":"flow_buckets","type":"inet"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"next_poll_at","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"router_log_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"note","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"config_revisions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"notes","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"object_ref","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_protections","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"observation_error","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"uptime_probe_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"observed","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_drift","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ok","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"servers_rest_ping_samples","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ok","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"1","relname":"flow_ip_meta","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_diagnostic_cancellations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_operation_checkpoints","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_operation_steps","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_drift","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_version","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"original_activity_at","attnotnull":false,"attnum":22,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"original_activity_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"original_expires_at","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"out_iface","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"''::text","relname":"flow_buckets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"outcome","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_stages","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"outcome","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_poll_acks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_claims_issued_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"to_timestamp((0)::double precision)","relname":"mcp_connections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"mcp_owner_revocations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_portal_events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_probe_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_connections","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_poll_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_id","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_permissions","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_connections","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"owner_valid_until","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"now()","relname":"mcp_connections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"flow_minute_stats","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"flow_daily_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"flow_minute_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"flow_daily_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"flow_hour_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"packets_received","attnotnull":true,"attnum":17,"attstorage":"p","default_expression":"0","relname":"traffic_flow_settings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"password","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_grants","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'{}'::jsonb","relname":"mcp_audit","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"config_revisions","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload_hash","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_engine_confirm_pending","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"payload_hash","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_portal_events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"peer_name","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"''::text","relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"peer_public_key","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"traffic_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"peer_public_key","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"''::text","relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"phase","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"flow_settings_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_at","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_enabled","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"true","relname":"uptime_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_error","attnotnull":false,"attnum":18,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_loss_pct","attnotnull":false,"attnum":17,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_ms","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ping_rtt_ms","attnotnull":false,"attnum":16,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_operations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"policy","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_connections","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"policy_version","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"mcp_routing_profiles","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"policy_version","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_plans","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"poll_configuration_epoch","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"gen_random_uuid()","relname":"internet_path_settings","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"poll_configuration_epoch","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"gen_random_uuid()","relname":"traffic_settings","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"poll_configuration_epoch","attnotnull":true,"attnum":15,"attstorage":"p","default_expression":"gen_random_uuid()","relname":"uptime_settings","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"polled_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"port","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"443","relname":"servers","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"prefix","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"flow_ip_meta","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"prefix","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'10.255.254.0/24'::text","relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"probe_filter","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'—'::text","relname":"uptime_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"probe_id","attnotnull":false,"attnum":2,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"probe_id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"uptime_probe_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"probe_interval_sec","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"15","relname":"uptime_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_hash","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_path_checks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservation_slots","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_id","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_id","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"profile_version","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"proto","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"smallint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"protocol","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"'tcp'::text","relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"protocol","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'tcp'::text","relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"provider","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"'local'::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"public_endpoint","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"''::text","relname":"traffic_flow_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"purged_at","attnotnull":false,"attnum":9,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"purpose","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_secrets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"raw_time","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reason","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"mcp_protections","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reason","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_unauthorized_buckets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_ciphertext","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_receipts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_ciphertext","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_payloads","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_settings_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_acks","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_quarantines","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_receipts","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_payloads","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_quarantines","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_stages","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_proof","attnotnull":false,"attnum":19,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_poll_receipts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_execution_payloads","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"received_at","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_stages","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"received_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_mode","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"'always'::text","relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_operation_id","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_receipt_id","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"recovery_stability_sec","attnotnull":false,"attnum":12,"attstorage":"p","default_expression":null,"relname":"alert_rules","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"redirect_uri","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"redirect_uris","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_clients","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"renew_before_days","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"30","relname":"certificate_renew_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"request_id","attnotnull":false,"attnum":9,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"request_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_settings_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"requested_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"now()","relname":"certificate_issue_jobs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"requests_retention_days","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"30","relname":"mcp_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reservation_id","attnotnull":false,"attnum":18,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reservation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservation_slots","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reserved_bytes","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reserved_bytes","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"server_probe_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reserved_files","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"0","relname":"server_probe_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"reserved_rows","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_usage","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"resolution_version","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":"0","relname":"alert_outbox","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"resource","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"resources_enabled","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"true","relname":"uptime_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"flow_settings_intents","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_operation_steps","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_operations","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"mcp_requests","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"flow_write_receipts","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"result_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_poll_acks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":null,"relname":"server_probe_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":null,"relname":"server_poll_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"14","relname":"internet_path_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"14","relname":"router_log_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"14","relname":"traffic_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_days","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"14","relname":"uptime_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retention_hours","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"24","relname":"traffic_flow_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"retry_count","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"alert_outbox","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"revision","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"revoked_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"mcp_management_channels","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"revoked_at","attnotnull":false,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_grants","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"revoked_at","attnotnull":false,"attnum":6,"attstorage":"p","default_expression":null,"relname":"mcp_credentials","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"role","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'viewer'::text","relname":"app_users","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ros_version","attnotnull":false,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"router_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"routing_endpoint_epoch","attnotnull":true,"attnum":20,"attstorage":"p","default_expression":"gen_random_uuid()","relname":"servers","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"routing_table","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"'main'::text","relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"routing_table","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'main'::text","relname":"recursive_routes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rtt_ms","attnotnull":false,"attnum":3,"attstorage":"p","default_expression":null,"relname":"uptime_probe_samples","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_chat_id","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"''::text","relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_id","attnotnull":false,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_id","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_engine_confirm_pending","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_rule_conditions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"alert_rule_targets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rule_name","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rx_avg_mbps","attnotnull":false,"attnum":15,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rx_bps","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"0","relname":"traffic_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"rx_bytes","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"traffic_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_access_key_id","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":"''::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_bucket","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"''::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_endpoint","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_etag","attnotnull":false,"attnum":11,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_force_path_style","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"true","relname":"backup_storage_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_key","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_prefix","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'mikrotik'::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_region","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"'us-east-1'::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"s3_secret_access_key","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":"''::text","relname":"backup_storage_settings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"safety_ms","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"60000","relname":"server_probe_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"safety_ms","attnotnull":true,"attnum":15,"attstorage":"p","default_expression":"60000","relname":"server_poll_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sampled_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"internet_path_snapshots","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sampled_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"servers_rest_ping_samples","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sampled_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"uptime_probe_samples","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sampled_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"uptime_resource_samples","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sampled_at","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"traffic_samples","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"scope","attnotnull":false,"attnum":7,"attstorage":"p","default_expression":null,"relname":"recursive_routes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"scope","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"server_poll_storage_usage","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"scope","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"server_probe_storage_usage","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"scope","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"scope_key","attnotnull":true,"attnum":1,"attstorage":"x","default_expression":null,"relname":"alert_engine_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"section","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"config_revisions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sent_at","attnotnull":false,"attnum":10,"attstorage":"p","default_expression":null,"relname":"alert_outbox","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sent_ok","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"true","relname":"alert_history","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":false,"attnum":2,"attstorage":"p","default_expression":null,"relname":"backup_entries","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":false,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_drift","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":false,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_operation_steps","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":false,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_secrets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_buckets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_daily_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_daily_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_hour_facts","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_minute_dims","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"flow_minute_stats","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"router_log_collection_state","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"servers_rest_ping_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"traffic_collection_state","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"traffic_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"config_revisions","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"filter_rules","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_management_channels","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"recursive_routes","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"user_interface_bindings","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_id","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"certificate_issue_jobs","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_ids","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'{}'::bigint[]","relname":"mcp_requests","type":"bigint[]"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_name","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"router_log_collection_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_name","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_name","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"server_updated_at","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"traffic_collection_state","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"service","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"flow_daily_facts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"service","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"flow_hour_facts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"severity","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"alert_history","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"severity","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"show_on_dashboard","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"false","relname":"uptime_probes","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"since_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"alert_engine_confirm_pending","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"site","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":"''::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"size_bytes","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"backup_entries","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"slot_phase","attnotnull":true,"attnum":19,"attstorage":"x","default_expression":"'recovery-intent'::text","relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"snapshot","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"router_log_collection_state","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_index","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"alert_rule_conditions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_index","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"0","relname":"alert_rule_targets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_order","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"0","relname":"uptime_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_order","attnotnull":true,"attnum":19,"attstorage":"p","default_expression":"0","relname":"uptime_speed_probes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_order","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"0","relname":"filter_rules","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sort_order","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"0","relname":"recursive_routes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source","attnotnull":true,"attnum":15,"attstorage":"x","default_expression":null,"relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"'manual'::text","relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"config_revisions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_configuration_proof","attnotnull":false,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_digest","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_module","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_operation_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_operation_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_plan_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":false,"attnum":17,"attstorage":"x","default_expression":null,"relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"flow_write_receipts","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_receipt_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_server_id","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":null,"relname":"server_probe_executions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_sha256","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_step_index","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_step_index","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_routing_forward_charges","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_step_index","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_routing_reservations","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_step_index","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_routing_manual_inverse_charges","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"speed_enabled","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"true","relname":"uptime_settings","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"speed_interval_sec","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"60","relname":"uptime_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sqlite_imported_at","attnotnull":false,"attnum":2,"attstorage":"p","default_expression":null,"relname":"data_migration","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sqlite_path","attnotnull":false,"attnum":3,"attstorage":"x","default_expression":null,"relname":"data_migration","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"sqlite_sha256","attnotnull":false,"attnum":4,"attstorage":"x","default_expression":null,"relname":"data_migration","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src","attnotnull":true,"attnum":3,"attstorage":"m","default_expression":null,"relname":"flow_buckets","type":"inet"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_address","attnotnull":false,"attnum":7,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_interface","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"''::text","relname":"uptime_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_interface","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"''::text","relname":"uptime_speed_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_interface","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_routing_observations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_interface","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"''::text","relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_interface_address","attnotnull":false,"attnum":9,"attstorage":"x","default_expression":null,"relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_port","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"flow_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"uptime_probes","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_server_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"uptime_speed_probes","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"src_server_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"stage","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_acks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"stage","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"stage_index","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_stages","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"started_at","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"certificate_issue_jobs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"started_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"scheduler_runs","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_oauth_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":11,"attstorage":"x","default_expression":"'issued'::text","relname":"vrf_production_tickets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":12,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":15,"attstorage":"x","default_expression":"'claimed'::text","relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"mcp_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"'claimed'::text","relname":"flow_settings_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_operation_steps","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservation_slots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'intent'::text","relname":"server_probe_execution_stages","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'pending'::text","relname":"mcp_operations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'{}'::jsonb","relname":"mcp_routing_profiles","type":"jsonb"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":null,"relname":"mcp_plans","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state_proof","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"state_sealed","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":null,"relname":"mcp_routing_reservations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":19,"attstorage":"x","default_expression":"'done'::text","relname":"uptime_speed_test_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"'queued'::text","relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'offline'::text","relname":"uptime_resource_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":"'pending'::text","relname":"alert_outbox","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'down'::text","relname":"uptime_probe_samples","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_path_checks","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"scheduler_runs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"traffic_collection_state","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"status","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"step","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":"'queued'::text","relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"step_index","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_operation_checkpoints","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"step_index","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_operation_steps","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"storage","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'local'::text","relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"storage_state","attnotnull":true,"attnum":19,"attstorage":"x","default_expression":"'full'::text","relname":"server_poll_storage_admissions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"alert_rule_targets","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"uptime_probes","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target_scope","attnotnull":false,"attnum":8,"attstorage":"p","default_expression":null,"relname":"recursive_routes","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"terminal_digest","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":null,"relname":"server_poll_archives","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ticket_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"vrf_production_tickets","type":"uuid"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"timeout_ms","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_probe_execution_stages","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"title","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"events","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"tool","attnotnull":true,"attnum":14,"attstorage":"x","default_expression":null,"relname":"server_probe_executions","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"tool","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_requests","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"top_n","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":"200","relname":"traffic_flow_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"topics","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":null,"relname":"router_log_entries","type":"text[]"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"total_hdd_space","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"total_memory","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"total_memory","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"trust_store","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'www,api'::text","relname":"certificate_issue_jobs","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"tx_avg_mbps","attnotnull":false,"attnum":14,"attstorage":"p","default_expression":null,"relname":"uptime_speed_test_runs","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"tx_bps","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"0","relname":"traffic_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"tx_bytes","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"traffic_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"type","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"alert_rules","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"type","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'home-router'::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"ul_mbps","attnotnull":false,"attnum":11,"attstorage":"p","default_expression":null,"relname":"mcp_routing_observations","type":"double precision"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"unique_dst","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"flow_minute_stats","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"unique_src","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"0","relname":"flow_minute_stats","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"update_interval_sec","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"604800","relname":"geoip_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":10,"attstorage":"p","default_expression":"now()","relname":"user_interface_bindings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"now()","relname":"filter_rules","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":11,"attstorage":"p","default_expression":"now()","relname":"geoip_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":"now()","relname":"app_users","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":12,"attstorage":"p","default_expression":"now()","relname":"uptime_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":13,"attstorage":"p","default_expression":"now()","relname":"backup_storage_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"now()","relname":"backup_schedule_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":14,"attstorage":"p","default_expression":"now()","relname":"uptime_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":15,"attstorage":"p","default_expression":"now()","relname":"alert_rules","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":15,"attstorage":"p","default_expression":"now()","relname":"recursive_routes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":19,"attstorage":"p","default_expression":"now()","relname":"servers","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":20,"attstorage":"p","default_expression":"now()","relname":"traffic_flow_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":21,"attstorage":"p","default_expression":"now()","relname":"uptime_speed_probes","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"now()","relname":"alert_engine_cursor","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"now()","relname":"alert_engine_prev_live","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"now()","relname":"mcp_owner_revocations","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"alert_telegram_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"evobgp_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"now()","relname":"mcp_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"now()","relname":"acme_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"now()","relname":"alert_groups","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"certificate_renew_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"mcp_connections","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"mcp_routing_profiles","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"now()","relname":"servers_api_ping_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"internet_path_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"updated_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"traffic_settings","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"upload_error","attnotnull":false,"attnum":12,"attstorage":"x","default_expression":null,"relname":"backup_entries","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"uptime","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"uptime_seconds","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"0","relname":"uptime_resource_samples","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"use_ssl","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"true","relname":"servers","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"used","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"mcp_budget_buckets","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"used_bytes","attnotnull":true,"attnum":18,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_admissions","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"used_rows","attnotnull":true,"attnum":17,"attstorage":"p","default_expression":"0","relname":"server_poll_storage_admissions","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"user_id","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"user_interface_bindings","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"username","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":"'admin'::text","relname":"servers","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"verification","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":"'pending'::text","relname":"mcp_operations","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"verified_at","attnotnull":true,"attnum":9,"attstorage":"p","default_expression":"now()","relname":"mcp_management_channels","type":"timestamp with time zone"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"verified_proof","attnotnull":false,"attnum":17,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"verified_sealed","attnotnull":false,"attnum":16,"attstorage":"x","default_expression":null,"relname":"mcp_scoped_recovery_intents","type":"text"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"verify_ssl","attnotnull":true,"attnum":8,"attstorage":"p","default_expression":"false","relname":"servers","type":"boolean"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"version","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_poll_archives","type":"smallint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"version","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":"1","relname":"mcp_routing_profiles","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"week_day","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"0","relname":"backup_schedule_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"wg_listen_port","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":"51821","relname":"traffic_flow_settings","type":"integer"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"a","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_audit","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"a","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"router_log_entries","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"d","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"filter_rules","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"d","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"internet_path_snapshots","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"d","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"recursive_routes","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"d","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_snapshots","type":"bigint"},{"acl":null,"attcompression":"","attgenerated":"","attidentity":"d","attname":"id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"servers","type":"bigint"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"domain_names","attnotnull":true,"attnum":7,"attstorage":"x","default_expression":null,"relname":"certificate_issue_jobs","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"payload_json","attnotnull":false,"attnum":10,"attstorage":"x","default_expression":null,"relname":"events","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"payload_json","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":"'{}'::jsonb","relname":"alert_engine_prev_live","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"payload_json","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"internet_path_snapshots","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"payload_json","attnotnull":true,"attnum":8,"attstorage":"x","default_expression":null,"relname":"alert_outbox","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"peers_json","attnotnull":true,"attnum":18,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"traffic_flow_settings","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"raw_interfaces","attnotnull":false,"attnum":13,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"raw_ip_addresses","attnotnull":false,"attnum":14,"attstorage":"x","default_expression":null,"relname":"server_snapshots","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"report_json","attnotnull":false,"attnum":5,"attstorage":"x","default_expression":null,"relname":"data_migration","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"result_json","attnotnull":false,"attnum":8,"attstorage":"x","default_expression":null,"relname":"scheduler_runs","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"sections_json","attnotnull":true,"attnum":9,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"app_users","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"server_ids_json","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"backup_schedule_settings","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"servers_json","attnotnull":true,"attnum":10,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"app_users","type":"jsonb"},{"acl":null,"attcompression":"l","attgenerated":"","attidentity":"","attname":"wan_uplinks","attnotnull":true,"attnum":16,"attstorage":"x","default_expression":"'[]'::jsonb","relname":"servers","type":"jsonb"}],"constraints":[{"condeferrable":false,"condeferred":false,"conname":"acme_settings_account_private_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL account_private_key","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_cloudflare_api_token_not_null","contype":"n","convalidated":true,"definition":"NOT NULL cloudflare_api_token","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_default_zone_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL default_zone_id","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_directory_url_not_null","contype":"n","convalidated":true,"definition":"NOT NULL directory_url","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"acme_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"acme_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_confirm_pending_payload_hash_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload_hash","relname":"alert_engine_confirm_pending"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_confirm_pending_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (rule_id)","relname":"alert_engine_confirm_pending"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_confirm_pending_rule_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rule_id","relname":"alert_engine_confirm_pending"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_confirm_pending_since_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL since_at","relname":"alert_engine_confirm_pending"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_cursor_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"alert_engine_cursor"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_cursor_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_engine_cursor"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_cursor_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_engine_cursor"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_cursor_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"alert_engine_cursor"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_prev_live_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((kind = ANY (ARRAY['gre'::text, 'bgp'::text])))","relname":"alert_engine_prev_live"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_prev_live_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"alert_engine_prev_live"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_prev_live_payload_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload_json","relname":"alert_engine_prev_live"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_prev_live_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (kind)","relname":"alert_engine_prev_live"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_prev_live_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"alert_engine_prev_live"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_state_last_fired_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL last_fired_at","relname":"alert_engine_state"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_state_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (scope_key)","relname":"alert_engine_state"},{"condeferrable":false,"condeferred":false,"conname":"alert_engine_state_scope_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL scope_key","relname":"alert_engine_state"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_combine_mode_check","contype":"c","convalidated":true,"definition":"CHECK ((combine_mode = ANY (ARRAY['any'::text, 'all'::text])))","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_combine_mode_not_null","contype":"n","convalidated":true,"definition":"NOT NULL combine_mode","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_groups_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"alert_groups"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_fired_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL fired_at","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_message_not_null","contype":"n","convalidated":true,"definition":"NOT NULL message","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_rule_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rule_name","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_sent_ok_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sent_ok","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_severity_check","contype":"c","convalidated":true,"definition":"CHECK ((severity = ANY (ARRAY['critical'::text, 'warning'::text, 'info'::text])))","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_history_severity_not_null","contype":"n","convalidated":true,"definition":"NOT NULL severity","relname":"alert_history"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_channel_check","contype":"c","convalidated":true,"definition":"CHECK ((channel = 'telegram'::text))","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_channel_not_null","contype":"n","convalidated":true,"definition":"NOT NULL channel","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_dedupe_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dedupe_key","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_max_retries_not_null","contype":"n","convalidated":true,"definition":"NOT NULL max_retries","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_next_attempt_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL next_attempt_at","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_payload_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload_json","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_resolution_version_check","contype":"c","convalidated":true,"definition":"CHECK ((resolution_version >= 0))","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_resolution_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL resolution_version","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_retry_count_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retry_count","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['pending'::text, 'processing'::text, 'unknown'::text, 'sent'::text, 'failed'::text])))","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_outbox_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"alert_outbox"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_condition_line_not_null","contype":"n","convalidated":true,"definition":"NOT NULL condition_line","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_rule_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (rule_id) REFERENCES alert_rules(id) ON DELETE CASCADE","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_rule_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rule_id","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_conditions_sort_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_index","relname":"alert_rule_conditions"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_rule_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (rule_id) REFERENCES alert_rules(id) ON DELETE CASCADE","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_rule_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rule_id","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_sort_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_index","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rule_targets_target_not_null","contype":"n","convalidated":true,"definition":"NOT NULL target","relname":"alert_rule_targets"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_condition_not_null","contype":"n","convalidated":true,"definition":"NOT NULL condition","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_cooldown_not_null","contype":"n","convalidated":true,"definition":"NOT NULL cooldown","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_group_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (group_id) REFERENCES alert_groups(id) ON DELETE SET NULL","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_recovery_mode_check","contype":"c","convalidated":true,"definition":"CHECK ((recovery_mode = ANY (ARRAY['always'::text, 'never'::text, 'conditional'::text])))","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_recovery_mode_not_null","contype":"n","convalidated":true,"definition":"NOT NULL recovery_mode","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_rule_chat_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rule_chat_id","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_severity_check","contype":"c","convalidated":true,"definition":"CHECK ((severity = ANY (ARRAY['critical'::text, 'warning'::text, 'info'::text])))","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_severity_not_null","contype":"n","convalidated":true,"definition":"NOT NULL severity","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_target_not_null","contype":"n","convalidated":true,"definition":"NOT NULL target","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL type","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_rules_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"alert_rules"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_bot_token_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bot_token","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_chat_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL chat_id","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"alert_telegram_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"alert_telegram_settings"},{"condeferrable":false,"condeferred":false,"conname":"app_users_active_not_null","contype":"n","convalidated":true,"definition":"NOT NULL active","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_avatar_not_null","contype":"n","convalidated":true,"definition":"NOT NULL avatar","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_email_not_null","contype":"n","convalidated":true,"definition":"NOT NULL email","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_login_key","contype":"u","convalidated":true,"definition":"UNIQUE (login)","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_login_not_null","contype":"n","convalidated":true,"definition":"NOT NULL login","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_role_check","contype":"c","convalidated":true,"definition":"CHECK ((role = ANY (ARRAY['admin'::text, 'operator'::text, 'viewer'::text])))","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_role_not_null","contype":"n","convalidated":true,"definition":"NOT NULL role","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_sections_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sections_json","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_servers_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL servers_json","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"app_users_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"app_users"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_filename_not_null","contype":"n","convalidated":true,"definition":"NOT NULL filename","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((kind = ANY (ARRAY['manual'::text, 'auto'::text])))","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE SET NULL","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_server_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_name","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_size_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL size_bytes","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_storage_check","contype":"c","convalidated":true,"definition":"CHECK ((storage = ANY (ARRAY['local'::text, 's3'::text, 'both'::text])))","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_entries_storage_not_null","contype":"n","convalidated":true,"definition":"NOT NULL storage","relname":"backup_entries"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_format_check","contype":"c","convalidated":true,"definition":"CHECK ((format = ANY (ARRAY['rsc'::text, 'backup'::text])))","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_format_not_null","contype":"n","convalidated":true,"definition":"NOT NULL format","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_frequency_check","contype":"c","convalidated":true,"definition":"CHECK ((frequency = ANY (ARRAY['daily'::text, 'weekly'::text, 'monthly'::text])))","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_frequency_not_null","contype":"n","convalidated":true,"definition":"NOT NULL frequency","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_hour_not_null","contype":"n","convalidated":true,"definition":"NOT NULL hour","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_keep_count_not_null","contype":"n","convalidated":true,"definition":"NOT NULL keep_count","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_minute_not_null","contype":"n","convalidated":true,"definition":"NOT NULL minute","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_month_day_not_null","contype":"n","convalidated":true,"definition":"NOT NULL month_day","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_server_ids_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_ids_json","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_schedule_settings_week_day_not_null","contype":"n","convalidated":true,"definition":"NOT NULL week_day","relname":"backup_schedule_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_keep_local_copy_not_null","contype":"n","convalidated":true,"definition":"NOT NULL keep_local_copy","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_provider_check","contype":"c","convalidated":true,"definition":"CHECK ((provider = ANY (ARRAY['local'::text, 's3'::text])))","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_provider_not_null","contype":"n","convalidated":true,"definition":"NOT NULL provider","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_access_key_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_access_key_id","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_bucket_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_bucket","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_endpoint_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_endpoint","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_force_path_style_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_force_path_style","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_prefix_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_prefix","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_region_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_region","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_s3_secret_access_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL s3_secret_access_key","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"backup_storage_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"backup_storage_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_cert_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL cert_name","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_domain_names_not_null","contype":"n","convalidated":true,"definition":"NOT NULL domain_names","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_key_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL key_type","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_requested_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL requested_at","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_source_check","contype":"c","convalidated":true,"definition":"CHECK ((source = ANY (ARRAY['manual'::text, 'scheduler'::text])))","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_source_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['queued'::text, 'running'::text, 'done'::text, 'failed'::text])))","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_step_not_null","contype":"n","convalidated":true,"definition":"NOT NULL step","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_issue_jobs_trust_store_not_null","contype":"n","convalidated":true,"definition":"NOT NULL trust_store","relname":"certificate_issue_jobs"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_renew_before_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL renew_before_days","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"certificate_renew_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"certificate_renew_settings"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_fingerprint_not_null","contype":"n","convalidated":true,"definition":"NOT NULL fingerprint","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_payload_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_section_not_null","contype":"n","convalidated":true,"definition":"NOT NULL section","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"config_revisions_source_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source","relname":"config_revisions"},{"condeferrable":false,"condeferred":false,"conname":"data_migration_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"data_migration"},{"condeferrable":false,"condeferred":false,"conname":"data_migration_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"data_migration"},{"condeferrable":false,"condeferred":false,"conname":"data_migration_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"data_migration"},{"condeferrable":false,"condeferred":false,"conname":"events_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_event_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL event_type","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_level_check","contype":"c","convalidated":true,"definition":"CHECK ((level = ANY (ARRAY['critical'::text, 'warning'::text, 'info'::text])))","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_level_not_null","contype":"n","convalidated":true,"definition":"NOT NULL level","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_message_not_null","contype":"n","convalidated":true,"definition":"NOT NULL message","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_source_module_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_module","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"events_title_not_null","contype":"n","convalidated":true,"definition":"NOT NULL title","relname":"events"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_api_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL api_key","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_base_url_not_null","contype":"n","convalidated":true,"definition":"NOT NULL base_url","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"evobgp_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"evobgp_settings"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_action_check","contype":"c","convalidated":true,"definition":"CHECK ((action = ANY (ARRAY['route'::text, 'blackhole'::text])))","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_action_not_null","contype":"n","convalidated":true,"definition":"NOT NULL action","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_community_not_null","contype":"n","convalidated":true,"definition":"NOT NULL community","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_description_not_null","contype":"n","convalidated":true,"definition":"NOT NULL description","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_gateway_not_null","contype":"n","convalidated":true,"definition":"NOT NULL gateway","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_gateway_tunnel_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL gateway_tunnel_id","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_sort_order_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_order","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"filter_rules_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"filter_rules"},{"condeferrable":false,"condeferred":false,"conname":"flow_asn_meta_asn_not_null","contype":"n","convalidated":true,"definition":"NOT NULL asn","relname":"flow_asn_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_asn_meta_fetched_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL fetched_at","relname":"flow_asn_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_asn_meta_holder_not_null","contype":"n","convalidated":true,"definition":"NOT NULL holder","relname":"flow_asn_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_asn_meta_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (asn)","relname":"flow_asn_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_bucket_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket_at","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_dst_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_dst_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_port","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_flow_end_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL flow_end_ms","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_flow_start_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL flow_start_ms","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_in_iface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL in_iface","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_nat_dst_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL nat_dst_port","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_nat_src_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL nat_src_port","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_out_iface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL out_iface","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, bucket_at, src, dst, proto, src_port, dst_port, in_iface)","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_proto_not_null","contype":"n","convalidated":true,"definition":"NOT NULL proto","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_src_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_buckets_src_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_port","relname":"flow_buckets"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_day_not_null","contype":"n","convalidated":true,"definition":"NOT NULL day","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_dim_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dim","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL key","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, day, dim, key)","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_dims_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_daily_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_asn_not_null","contype":"n","convalidated":true,"definition":"NOT NULL asn","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_country_not_null","contype":"n","convalidated":true,"definition":"NOT NULL country","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_day_not_null","contype":"n","convalidated":true,"definition":"NOT NULL day","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_iface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL iface","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, day, iface, country, service, asn)","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_daily_facts_service_not_null","contype":"n","convalidated":true,"definition":"NOT NULL service","relname":"flow_daily_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_asn_not_null","contype":"n","convalidated":true,"definition":"NOT NULL asn","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_bucket_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket_at","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_country_not_null","contype":"n","convalidated":true,"definition":"NOT NULL country","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_iface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL iface","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, bucket_at, iface, country, service, asn)","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_hour_facts_service_not_null","contype":"n","convalidated":true,"definition":"NOT NULL service","relname":"flow_hour_facts"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_asn_not_null","contype":"n","convalidated":true,"definition":"NOT NULL asn","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_country_not_null","contype":"n","convalidated":true,"definition":"NOT NULL country","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_fetched_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL fetched_at","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_holder_not_null","contype":"n","convalidated":true,"definition":"NOT NULL holder","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_ok_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ok","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (prefix)","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_ip_meta_prefix_not_null","contype":"n","convalidated":true,"definition":"NOT NULL prefix","relname":"flow_ip_meta"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_bucket_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket_at","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_dim_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dim","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL key","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, bucket_at, dim, key)","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_dims_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_minute_dims"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_bucket_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket_at","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bytes","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_conversations_not_null","contype":"n","convalidated":true,"definition":"NOT NULL conversations","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_packets_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, bucket_at)","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_unique_dst_not_null","contype":"n","convalidated":true,"definition":"NOT NULL unique_dst","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_minute_stats_unique_src_not_null","contype":"n","convalidated":true,"definition":"NOT NULL unique_src","relname":"flow_minute_stats"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_phase_check","contype":"c","convalidated":true,"definition":"CHECK ((phase = ANY (ARRAY['configuration'::text, 'listener'::text])))","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_phase_not_null","contype":"n","convalidated":true,"definition":"NOT NULL phase","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id, phase)","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_request_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL request_proof","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['claimed'::text, 'completed'::text])))","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_settings_intents_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"flow_settings_intents"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_batch_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL batch_id","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_committed_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL committed_at","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((kind = ANY (ARRAY['ingest'::text, 'facts'::text, 'rebuild'::text])))","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (batch_id)","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_result_check","contype":"c","convalidated":true,"definition":"CHECK (((jsonb_typeof(result) = 'object'::text) AND (octet_length((result)::text) <= 65536)))","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_result_not_null","contype":"n","convalidated":true,"definition":"NOT NULL result","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_source_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((source_proof ~ '^[a-f0-9]{64}$'::text))","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"flow_write_receipts_source_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_proof","relname":"flow_write_receipts"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_etags_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL etags_json","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_update_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL update_interval_sec","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"geoip_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"geoip_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_poll_configuration_epoch_not_null","contype":"n","convalidated":true,"definition":"NOT NULL poll_configuration_epoch","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"internet_path_settings"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_snapshots_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"internet_path_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_snapshots_payload_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload_json","relname":"internet_path_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_snapshots_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id, sampled_at)","relname":"internet_path_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"internet_path_snapshots_sampled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sampled_at","relname":"internet_path_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ciphertext","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_filename_not_null","contype":"n","convalidated":true,"definition":"NOT NULL filename","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_media_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL media_type","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_artifacts_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_artifacts"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_action_not_null","contype":"n","convalidated":true,"definition":"NOT NULL action","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_actor_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL actor_id","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_payload_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_audit_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_audit"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_bucket_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id) ON DELETE CASCADE","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (connection_id, kind, bucket)","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_used_check","contype":"c","convalidated":true,"definition":"CHECK ((used >= 0))","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_budget_buckets_used_not_null","contype":"n","convalidated":true,"definition":"NOT NULL used","relname":"mcp_budget_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_generation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL generation","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_owner_claims_issued_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_claims_issued_at","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_owner_permissions_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_permissions","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_owner_valid_until_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_valid_until","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_policy_not_null","contype":"n","convalidated":true,"definition":"NOT NULL policy","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_connections_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"mcp_connections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id) ON DELETE CASCADE","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_digest_key","contype":"u","convalidated":true,"definition":"UNIQUE (digest)","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL digest","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((kind = ANY (ARRAY['bearer'::text, 'access'::text, 'refresh'::text])))","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_credentials_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_credentials"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_actor_id_check","contype":"c","convalidated":true,"definition":"CHECK (((length(actor_id) >= 1) AND (length(actor_id) <= 200)))","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_actor_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL actor_id","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_diagnostic_cancellations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id)","relname":"mcp_diagnostic_cancellations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_detected_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL detected_at","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_expected_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expected","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_observed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL observed","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_drift_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_drift"},{"condeferrable":false,"condeferred":false,"conname":"mcp_grants_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id) ON DELETE CASCADE","relname":"mcp_grants"},{"condeferrable":false,"condeferred":false,"conname":"mcp_grants_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_grants"},{"condeferrable":false,"condeferred":false,"conname":"mcp_grants_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_grants"},{"condeferrable":false,"condeferred":false,"conname":"mcp_grants_payload_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload","relname":"mcp_grants"},{"condeferrable":false,"condeferred":false,"conname":"mcp_grants_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_grants"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_attestation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL attestation","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_config_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL config_sealed","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_created_by_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_by","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_generation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL generation","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_identity_hash_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_hash","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_server_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (server_id)","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_management_channels_verified_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL verified_at","relname":"mcp_management_channels"},{"condeferrable":false,"condeferred":false,"conname":"mcp_manual_inverse_source_step_unique","contype":"u","convalidated":true,"definition":"UNIQUE (source_operation_id, source_step_index)","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_clients_redirect_uris_not_null","contype":"n","convalidated":true,"definition":"NOT NULL redirect_uris","relname":"mcp_oauth_clients"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_challenge_not_null","contype":"n","convalidated":true,"definition":"NOT NULL challenge","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_client_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (client_id) REFERENCES mcp_oauth_clients(id)","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_client_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL client_id","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_code_digest_key","contype":"u","convalidated":true,"definition":"UNIQUE (code_digest)","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_redirect_uri_not_null","contype":"n","convalidated":true,"definition":"NOT NULL redirect_uri","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_resource_not_null","contype":"n","convalidated":true,"definition":"NOT NULL resource","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_oauth_requests_scope_not_null","contype":"n","convalidated":true,"definition":"NOT NULL scope","relname":"mcp_oauth_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_before_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL before_sealed","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id, step_index)","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_checkpoints_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL step_index","relname":"mcp_operation_checkpoints"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id, step_index)","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operation_steps_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL step_index","relname":"mcp_operation_steps"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_connection_id_idempotency_key_key","contype":"u","convalidated":true,"definition":"UNIQUE (connection_id, idempotency_key)","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_idempotency_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL idempotency_key","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_plan_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (plan_id) REFERENCES mcp_plans(id)","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_plan_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (plan_id)","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL plan_id","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_operations_verification_not_null","contype":"n","convalidated":true,"definition":"NOT NULL verification","relname":"mcp_operations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_owner_revocations_invalid_before_not_null","contype":"n","convalidated":true,"definition":"NOT NULL invalid_before","relname":"mcp_owner_revocations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_owner_revocations_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"mcp_owner_revocations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_owner_revocations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (owner_id)","relname":"mcp_owner_revocations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_owner_revocations_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"mcp_owner_revocations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_candidate_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL candidate_id","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_evidence_not_null","contype":"n","convalidated":true,"definition":"NOT NULL evidence","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_profile_hash_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_hash","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['passed'::text, 'failed'::text, 'unknown'::text])))","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_path_checks_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"mcp_path_checks"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_evidence_not_null","contype":"n","convalidated":true,"definition":"NOT NULL evidence","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_generation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL generation","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_operation_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_version","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_payload_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_policy_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL policy_version","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_plans_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_plans"},{"condeferrable":false,"condeferred":false,"conname":"mcp_portal_events_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_portal_events"},{"condeferrable":false,"condeferred":false,"conname":"mcp_portal_events_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_portal_events"},{"condeferrable":false,"condeferred":false,"conname":"mcp_portal_events_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"mcp_portal_events"},{"condeferrable":false,"condeferred":false,"conname":"mcp_portal_events_payload_hash_not_null","contype":"n","convalidated":true,"definition":"NOT NULL payload_hash","relname":"mcp_portal_events"},{"condeferrable":false,"condeferred":false,"conname":"mcp_portal_events_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_portal_events"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_created_by_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_by","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_object_ref_not_null","contype":"n","convalidated":true,"definition":"NOT NULL object_ref","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_protections_reason_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reason","relname":"mcp_protections"},{"condeferrable":false,"condeferred":false,"conname":"mcp_read_leases_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id) ON DELETE CASCADE","relname":"mcp_read_leases"},{"condeferrable":false,"condeferred":false,"conname":"mcp_read_leases_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_read_leases"},{"condeferrable":false,"condeferred":false,"conname":"mcp_read_leases_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"mcp_read_leases"},{"condeferrable":false,"condeferred":false,"conname":"mcp_read_leases_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_read_leases"},{"condeferrable":false,"condeferred":false,"conname":"mcp_read_leases_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_read_leases"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_authority_profile_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (authority_profile_id) REFERENCES mcp_routing_profiles(id)","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_authority_profile_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_profile_id","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id)","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_recovery_intents_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id) ON DELETE SET NULL","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_input_not_null","contype":"n","convalidated":true,"definition":"NOT NULL input","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_server_ids_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_ids","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_requests_tool_not_null","contype":"n","convalidated":true,"definition":"NOT NULL tool","relname":"mcp_requests"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_binding_sealed_check","contype":"c","convalidated":true,"definition":"CHECK (((octet_length(binding_sealed) >= 1) AND (octet_length(binding_sealed) <= 262144)))","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_binding_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_sealed","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_charge_units_check","contype":"c","convalidated":true,"definition":"CHECK ((charge_units = 1))","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_charge_units_not_null","contype":"n","convalidated":true,"definition":"NOT NULL charge_units","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (source_operation_id)","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_profile_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_id","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_source_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_operation_id","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_source_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_plan_id","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_source_step_index_check","contype":"c","convalidated":true,"definition":"CHECK ((source_step_index = 0))","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_forward_charges_source_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_step_index","relname":"mcp_routing_forward_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charg_recovery_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL recovery_operation_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_binding_sealed_check","contype":"c","convalidated":true,"definition":"CHECK (((octet_length(binding_sealed) >= 1) AND (octet_length(binding_sealed) <= 262144)))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_binding_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_sealed","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_charge_units_check","contype":"c","convalidated":true,"definition":"CHECK ((charge_units = 1))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_charge_units_not_null","contype":"n","convalidated":true,"definition":"NOT NULL charge_units","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_owner_id_check","contype":"c","convalidated":true,"definition":"CHECK (((octet_length(owner_id) >= 1) AND (octet_length(owner_id) <= 1000)))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (recovery_operation_id)","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_profile_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_profile_version_check","contype":"c","convalidated":true,"definition":"CHECK ((profile_version > 0))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_profile_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_version","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_recovery_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL recovery_plan_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_source_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_operation_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_source_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_plan_id","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_source_step_index_check","contype":"c","convalidated":true,"definition":"CHECK ((source_step_index = 0))","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_manual_inverse_charges_source_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_step_index","relname":"mcp_routing_manual_inverse_charges"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observation_source_proof","contype":"c","convalidated":true,"definition":"CHECK (((source_proof IS NULL) OR (source_proof ~ '^[a-f0-9]{64}$'::text)))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_context_verified_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_verified","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_dl_mbps_check","contype":"c","convalidated":true,"definition":"CHECK (((dl_mbps IS NULL) OR (dl_mbps >= (0)::double precision)))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_dst_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_interface","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_dst_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_server_id","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_family_check","contype":"c","convalidated":true,"definition":"CHECK ((family = ANY (ARRAY['ipv4'::text, 'ipv6'::text])))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_family_not_null","contype":"n","convalidated":true,"definition":"NOT NULL family","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_loss_pct_check","contype":"c","convalidated":true,"definition":"CHECK (((loss_pct IS NULL) OR ((loss_pct >= (0)::double precision) AND (loss_pct <= (100)::double precision))))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_ping_ms_check","contype":"c","convalidated":true,"definition":"CHECK (((ping_ms IS NULL) OR (ping_ms >= (0)::double precision)))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_routing_table_not_null","contype":"n","convalidated":true,"definition":"NOT NULL routing_table","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_source_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_src_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_interface","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_src_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_server_id","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_observations_ul_mbps_check","contype":"c","convalidated":true,"definition":"CHECK (((ul_mbps IS NULL) OR (ul_mbps >= (0)::double precision)))","relname":"mcp_routing_observations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_config_not_null","contype":"n","convalidated":true,"definition":"NOT NULL config","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_credential_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (credential_id) REFERENCES mcp_credentials(id)","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_grant_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL grant_expires_at","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_profiles_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL version","relname":"mcp_routing_profiles"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_lane_check","contype":"c","convalidated":true,"definition":"CHECK ((lane = ANY (ARRAY['forward'::text, 'inverse'::text])))","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_lane_not_null","contype":"n","convalidated":true,"definition":"NOT NULL lane","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (reservation_id, lane)","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_profile_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (profile_id) REFERENCES mcp_routing_profiles(id)","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_profile_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_id","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_reservation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (reservation_id) REFERENCES mcp_routing_reservations(id)","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_reservation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reservation_id","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['held'::text, 'spent'::text, 'proven-unused'::text, 'unknown'::text])))","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservation_slots_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_routing_reservation_slots"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_binding_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_sealed","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_deadline_not_null","contype":"n","convalidated":true,"definition":"NOT NULL deadline","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_profile_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (profile_id) REFERENCES mcp_routing_profiles(id)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_profile_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL profile_id","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_revision_check","contype":"c","convalidated":true,"definition":"CHECK ((revision >= 1))","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_revision_not_null","contype":"n","convalidated":true,"definition":"NOT NULL revision","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (source_operation_id) REFERENCES mcp_operations(id)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_operation_id","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_operation_id_source_step_in_key","contype":"u","convalidated":true,"definition":"UNIQUE (source_operation_id, source_step_index)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_plan_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (source_plan_id) REFERENCES mcp_plans(id)","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_plan_id","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_step_index_check","contype":"c","convalidated":true,"definition":"CHECK ((source_step_index = 0))","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_source_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_step_index","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_state_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state_proof","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_routing_reservations_state_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state_sealed","relname":"mcp_routing_reservations"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_authority_profile_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (authority_profile_id) REFERENCES mcp_routing_profiles(id)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_check","contype":"c","convalidated":true,"definition":"CHECK (((mode = 'manual'::text) OR ((authority_profile_id IS NOT NULL) AND (authority_profile_version IS NOT NULL))))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_check1","contype":"c","convalidated":true,"definition":"CHECK (((state = 'verified'::text) = ((verified_sealed IS NOT NULL) AND (verified_proof IS NOT NULL))))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_deadline_not_null","contype":"n","convalidated":true,"definition":"NOT NULL deadline","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_intent_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL intent_proof","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_intent_sealed_not_null","contype":"n","convalidated":true,"definition":"NOT NULL intent_sealed","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_mode_check","contype":"c","convalidated":true,"definition":"CHECK ((mode = ANY (ARRAY['manual'::text, 'reserved'::text])))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_mode_not_null","contype":"n","convalidated":true,"definition":"NOT NULL mode","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (source_operation_id, source_step_index)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_recovery_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (recovery_operation_id) REFERENCES mcp_operations(id)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_recovery_receipt_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (recovery_receipt_id)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_recovery_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL recovery_receipt_id","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_reservation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (reservation_id) REFERENCES mcp_routing_reservations(id)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_slot_phase_not_null","contype":"n","convalidated":true,"definition":"NOT NULL slot_phase","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_source_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (source_operation_id) REFERENCES mcp_operations(id)","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_source_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_operation_id","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_source_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_receipt_id","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_source_step_index_check","contype":"c","convalidated":true,"definition":"CHECK ((source_step_index >= 0))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_source_step_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_step_index","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['intent'::text, 'verified'::text, 'unknown'::text])))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_scoped_recovery_intents_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ciphertext","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_created_by_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_by","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_secrets_purpose_not_null","contype":"n","convalidated":true,"definition":"NOT NULL purpose","relname":"mcp_secrets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_audit_retention_days_check","contype":"c","convalidated":true,"definition":"CHECK (((audit_retention_days >= 30) AND (audit_retention_days <= 3650)))","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_audit_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL audit_retention_days","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_requests_retention_days_check","contype":"c","convalidated":true,"definition":"CHECK (((requests_retention_days >= 1) AND (requests_retention_days <= 365)))","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_requests_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL requests_retention_days","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"mcp_settings"},{"condeferrable":false,"condeferred":false,"conname":"mcp_unauthorized_buckets_attempts_not_null","contype":"n","convalidated":true,"definition":"NOT NULL attempts","relname":"mcp_unauthorized_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_unauthorized_buckets_bucket_not_null","contype":"n","convalidated":true,"definition":"NOT NULL bucket","relname":"mcp_unauthorized_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_unauthorized_buckets_client_hash_not_null","contype":"n","convalidated":true,"definition":"NOT NULL client_hash","relname":"mcp_unauthorized_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_unauthorized_buckets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (bucket, client_hash, reason)","relname":"mcp_unauthorized_buckets"},{"condeferrable":false,"condeferred":false,"conname":"mcp_unauthorized_buckets_reason_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reason","relname":"mcp_unauthorized_buckets"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_check_gateway_not_null","contype":"n","convalidated":true,"definition":"NOT NULL check_gateway","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_comment_not_null","contype":"n","convalidated":true,"definition":"NOT NULL comment","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_country_not_null","contype":"n","convalidated":true,"definition":"NOT NULL country","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_disabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL disabled","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_distance_not_null","contype":"n","convalidated":true,"definition":"NOT NULL distance","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_dst_address_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_address","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_gateway_not_null","contype":"n","convalidated":true,"definition":"NOT NULL gateway","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_routing_table_not_null","contype":"n","convalidated":true,"definition":"NOT NULL routing_table","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_sort_order_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_order","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"recursive_routes_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"recursive_routes"},{"condeferrable":false,"condeferred":false,"conname":"reserved_inverse_evidence_pairs","contype":"c","convalidated":true,"definition":"CHECK ((((inverse_intent_sealed IS NULL) = (inverse_intent_proof IS NULL)) AND ((inverse_configuration_sealed IS NULL) = (inverse_configuration_proof IS NULL)) AND ((inverse_configuration_sealed IS NULL) OR (inverse_intent_sealed IS NOT NULL)) AND ((inverse_intent_sealed IS NULL) OR (mode = 'reserved'::text))))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_failures_not_null","contype":"n","convalidated":true,"definition":"NOT NULL failures","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_generation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL generation","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_host_not_null","contype":"n","convalidated":true,"definition":"NOT NULL host","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id)","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_server_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_name","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_collection_state_snapshot_not_null","contype":"n","convalidated":true,"definition":"NOT NULL snapshot","relname":"router_log_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_effective_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL effective_at","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_generation_not_null","contype":"n","convalidated":true,"definition":"NOT NULL generation","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_host_not_null","contype":"n","convalidated":true,"definition":"NOT NULL host","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_level_not_null","contype":"n","convalidated":true,"definition":"NOT NULL level","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_message_not_null","contype":"n","convalidated":true,"definition":"NOT NULL message","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_raw_time_not_null","contype":"n","convalidated":true,"definition":"NOT NULL raw_time","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_received_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL received_at","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_router_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL router_id","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_server_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_name","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_entries_topics_not_null","contype":"n","convalidated":true,"definition":"NOT NULL topics","relname":"router_log_entries"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_interval_sec_check","contype":"c","convalidated":true,"definition":"CHECK (((interval_sec >= 5) AND (interval_sec <= 3600)))","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_retention_days_check","contype":"c","convalidated":true,"definition":"CHECK (((retention_days >= 1) AND (retention_days <= 365)))","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"router_log_settings_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"router_log_settings"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_duration_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL duration_ms","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_finished_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL finished_at","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_job_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL job_key","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_started_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL started_at","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['ok'::text, 'error'::text])))","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"scheduler_runs_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"scheduler_runs"},{"condeferrable":false,"condeferred":false,"conname":"schema_migrations_applied_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL applied_at","relname":"schema_migrations"},{"condeferrable":false,"condeferred":false,"conname":"schema_migrations_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"schema_migrations"},{"condeferrable":false,"condeferred":false,"conname":"schema_migrations_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"schema_migrations"},{"condeferrable":false,"condeferred":false,"conname":"scoped_reservation_slot_shape","contype":"c","convalidated":true,"definition":"CHECK ((((mode = 'manual'::text) AND (reservation_id IS NULL) AND (slot_phase = 'recovery-intent'::text) AND (source_configuration_proof IS NOT NULL)) OR ((mode = 'reserved'::text) AND (reservation_id IS NOT NULL) AND (((slot_phase = 'reservation-held'::text) AND (source_configuration_proof IS NULL)) OR ((slot_phase = ANY (ARRAY['reservation-bound'::text, 'reserved-attempt'::text])) AND (source_configuration_proof IS NOT NULL))))))","relname":"mcp_scoped_recovery_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_ack_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((ack_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_ack_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ack_proof","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_check","contype":"c","convalidated":true,"definition":"CHECK (((stage ~~ 'native.%'::text) OR (outcome = 'confirmed'::text)))","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_outcome_check","contype":"c","convalidated":true,"definition":"CHECK ((outcome = ANY (ARRAY['confirmed'::text, 'read-failed'::text])))","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_outcome_not_null","contype":"n","convalidated":true,"definition":"NOT NULL outcome","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id, stage)","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_receipt_id_stage_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id, stage) REFERENCES server_poll_intents(receipt_id, stage)","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_result_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((result_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_result_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL result_proof","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_acks_stage_not_null","contype":"n","convalidated":true,"definition":"NOT NULL stage","relname":"server_poll_acks"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_archive_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((archive_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_archive_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL archive_proof","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_check","contype":"c","convalidated":true,"definition":"CHECK ((((ciphertext_bytes >= 1) AND (ciphertext_bytes <= 131072)) AND (ciphertext_bytes = octet_length(ciphertext))))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_ciphertext_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ciphertext_bytes","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ciphertext","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_compaction_xid_not_null","contype":"n","convalidated":true,"definition":"NOT NULL compaction_xid","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_compressed_bytes_check","contype":"c","convalidated":true,"definition":"CHECK (((compressed_bytes >= 1) AND (compressed_bytes <= 98048)))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_compressed_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL compressed_bytes","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_context_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((context_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_context_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_proof","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_decoded_bytes_check","contype":"c","convalidated":true,"definition":"CHECK (((decoded_bytes >= 1) AND (decoded_bytes <= 16777216)))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_decoded_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL decoded_bytes","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (execution_id)","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_original_activity_at_check","contype":"c","convalidated":true,"definition":"CHECK (isfinite(original_activity_at))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_original_activity_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL original_activity_at","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_original_expires_at_check","contype":"c","convalidated":true,"definition":"CHECK (isfinite(original_expires_at))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_original_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL original_expires_at","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_poll_storage_admissions(receipt_id)","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_source_digest_check","contype":"c","convalidated":true,"definition":"CHECK ((source_digest ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_source_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_digest","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_source_sha256_check","contype":"c","convalidated":true,"definition":"CHECK ((source_sha256 ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_source_sha256_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_sha256","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_terminal_digest_check","contype":"c","convalidated":true,"definition":"CHECK ((terminal_digest ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_terminal_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL terminal_digest","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_version_check","contype":"c","convalidated":true,"definition":"CHECK ((version = 1))","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL version","relname":"server_poll_archives"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_compaction_claim_shape","contype":"c","convalidated":true,"definition":"CHECK ((((compaction_claim IS NULL) AND (compaction_claimed_at IS NULL) AND (compaction_claim_xid IS NULL)) OR ((compaction_claim IS NOT NULL) AND (compaction_claimed_at IS NOT NULL) AND (compaction_claim_xid IS NOT NULL) AND isfinite(compaction_claimed_at))))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_context_ciphertext_check","contype":"c","convalidated":true,"definition":"CHECK ((octet_length(context_ciphertext) <= 2097152))","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_context_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_ciphertext","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_context_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((context_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_context_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_proof","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_executions_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_before_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((before_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_before_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL before_proof","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_effect_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((effect_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_effect_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL effect_proof","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_intent_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((intent_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_intent_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL intent_proof","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id, stage)","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_poll_executions(receipt_id)","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_stage_check","contype":"c","convalidated":true,"definition":"CHECK ((stage ~ '^(native\\.(identity|resource|interfaces|addresses)|publish\\.[0-9]{1,4})$'::text))","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_intents_stage_not_null","contype":"n","convalidated":true,"definition":"NOT NULL stage","relname":"server_poll_intents"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_context_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((context_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_context_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_proof","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_quarantines_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_ciphertext_check","contype":"c","convalidated":true,"definition":"CHECK ((octet_length(receipt_ciphertext) <= 262144))","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_ciphertext","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_poll_executions(receipt_id)","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((receipt_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_receipts_receipt_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_proof","relname":"server_poll_receipts"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_authority_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_expires_at","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_authority_issued_at_check","contype":"c","convalidated":true,"definition":"CHECK (isfinite(authority_issued_at))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_authority_issued_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_issued_at","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_check","contype":"c","convalidated":true,"definition":"CHECK ((isfinite(authority_expires_at) AND (authority_expires_at > authority_issued_at)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_check1","contype":"c","convalidated":true,"definition":"CHECK ((((used_rows >= 0) AND (used_rows <= 4019)) AND (used_rows <= ((max_stages * 2) + 3))))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_check2","contype":"c","convalidated":true,"definition":"CHECK ((((identity_kind = 'mcp'::text) AND (connection_id IS NOT NULL)) OR ((identity_kind = 'rest'::text) AND (connection_id IS NULL))))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_check3","contype":"c","convalidated":true,"definition":"CHECK ((((claim_token IS NOT NULL) AND (claim_attempted_at IS NULL)) OR ((claim_token IS NULL) AND (claim_attempted_at IS NOT NULL))))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_check4","contype":"c","convalidated":true,"definition":"CHECK ((gc_not_before >= ((authority_expires_at + make_interval(days => retention_days)) + '00:01:00'::interval)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_context_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((context_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_context_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL context_proof","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_gc_not_before_check","contype":"c","convalidated":true,"definition":"CHECK (isfinite(gc_not_before))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_gc_not_before_not_null","contype":"n","convalidated":true,"definition":"NOT NULL gc_not_before","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_max_stages_check","contype":"c","convalidated":true,"definition":"CHECK (((max_stages >= 8) AND (max_stages <= 2008)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_max_stages_not_null","contype":"n","convalidated":true,"definition":"NOT NULL max_stages","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_owner_id_check","contype":"c","convalidated":true,"definition":"CHECK ((((length(owner_id) >= 1) AND (length(owner_id) <= 200)) AND (btrim(owner_id) = owner_id) AND (owner_id !~ '[[:cntrl:]]'::text)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_retention_days_check","contype":"c","convalidated":true,"definition":"CHECK (((retention_days >= 1) AND (retention_days <= 365)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_safety_ms_check","contype":"c","convalidated":true,"definition":"CHECK ((safety_ms = 60000))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_safety_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL safety_ms","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_storage_state_check","contype":"c","convalidated":true,"definition":"CHECK ((storage_state = ANY (ARRAY['full'::text, 'compacted'::text])))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_storage_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL storage_state","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_used_bytes_check","contype":"c","convalidated":true,"definition":"CHECK (((used_bytes >= 0) AND (used_bytes <= 8388608)))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_used_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL used_bytes","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_admissions_used_rows_not_null","contype":"n","convalidated":true,"definition":"NOT NULL used_rows","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_archive_charge","contype":"c","convalidated":true,"definition":"CHECK (((archive_bytes >= compacted_admissions) AND (archive_bytes <= (compacted_admissions * 131072))))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_bytes_charge","contype":"c","convalidated":true,"definition":"CHECK (((reserved_bytes = (((admissions * 8421376) + (compacted_admissions * 32768)) + archive_bytes)) AND (reserved_bytes <=\nCASE\n WHEN (scope = 'global'::text) THEN 1077936128\n ELSE 67371008\nEND)))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_compact_shape","contype":"c","convalidated":true,"definition":"CHECK ((((storage_state = 'full'::text) AND (compact_at IS NULL) AND (archive_bytes IS NULL) AND (original_activity_at IS NULL)) OR ((storage_state = 'compacted'::text) AND (identity_kind = 'mcp'::text) AND (claim_token IS NULL) AND (claim_attempted_at IS NOT NULL) AND (compaction_claim IS NOT NULL) AND (compaction_claimed_at IS NOT NULL) AND (compaction_claim_xid IS NOT NULL) AND (compact_at IS NOT NULL) AND (archive_bytes IS NOT NULL) AND (original_activity_at IS NOT NULL) AND isfinite(compact_at) AND ((archive_bytes >= 1) AND (archive_bytes <= 131072)) AND isfinite(original_activity_at) AND (original_activity_at >= created_at) AND (compact_at > (authority_expires_at + ((safety_ms)::double precision * '00:00:00.001'::interval))))))","relname":"server_poll_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_rows_charge","contype":"c","convalidated":true,"definition":"CHECK (((reserved_rows = ((admissions * 4019) + (compacted_admissions * 2))) AND (reserved_rows <=\nCASE\n WHEN (scope = 'global'::text) THEN 514432\n ELSE 32152\nEND)))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_admissions_check","contype":"c","convalidated":true,"definition":"CHECK (((admissions >= 0) AND (admissions <= 128)))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_admissions_not_null","contype":"n","convalidated":true,"definition":"NOT NULL admissions","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_archive_bytes_check","contype":"c","convalidated":true,"definition":"CHECK ((archive_bytes >= 0))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_archive_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL archive_bytes","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_check2","contype":"c","convalidated":true,"definition":"CHECK (((scope = 'global'::text) OR (admissions <= 8)))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_compacted_admissions_check","contype":"c","convalidated":true,"definition":"CHECK ((compacted_admissions >= 0))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_compacted_admissions_not_null","contype":"n","convalidated":true,"definition":"NOT NULL compacted_admissions","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (scope)","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_reserved_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reserved_bytes","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_reserved_rows_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reserved_rows","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_scope_check","contype":"c","convalidated":true,"definition":"CHECK (((scope = 'global'::text) OR ((scope ~~ 'owner:%'::text) AND ((length(scope) >= 7) AND (length(scope) <= 206)))))","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_poll_storage_usage_scope_not_null","contype":"n","convalidated":true,"definition":"NOT NULL scope","relname":"server_poll_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_ciphertext_check","contype":"c","convalidated":true,"definition":"CHECK (((octet_length(receipt_ciphertext) >= 1) AND (octet_length(receipt_ciphertext) <= 262144)))","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_ciphertext","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_probe_executions(receipt_id)","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((receipt_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_payloads_receipt_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_proof","relname":"server_probe_execution_payloads"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantin_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_attempted_stages_check","contype":"c","convalidated":true,"definition":"CHECK (((attempted_stages >= 0) AND (attempted_stages <= 11)))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_attempted_stages_not_null","contype":"n","convalidated":true,"definition":"NOT NULL attempted_stages","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_check","contype":"c","convalidated":true,"definition":"CHECK (((completed_stages >= 0) AND (completed_stages <= attempted_stages)))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_completed_stages_not_null","contype":"n","convalidated":true,"definition":"NOT NULL completed_stages","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_error_code_check","contype":"c","convalidated":true,"definition":"CHECK ((error_code ~ '^[A-Z_]{1,64}$'::text))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_error_code_not_null","contype":"n","convalidated":true,"definition":"NOT NULL error_code","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_identity_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_identity_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_proof","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_quarantines_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_execution_quarantines"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_check","contype":"c","convalidated":true,"definition":"CHECK ((((state = 'intent'::text) AND (outcome IS NULL) AND (received_at IS NULL)) OR ((state = 'received'::text) AND (outcome IS NOT NULL) AND (received_at IS NOT NULL))))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((kind = ANY (ARRAY['source-dns-A'::text, 'native-ping'::text, 'native-traceroute'::text, 'native-bandwidth'::text, 'native-route-read'::text, 'manager-dns-A'::text, 'manager-dns-AAAA'::text, 'manager-dns-MX'::text, 'manager-dns-NS'::text, 'manager-dns-TXT'::text, 'manager-dns-CNAME'::text, 'manager-dns-PTR'::text, 'native-mtu-1500'::text, 'native-mtu-1492'::text, 'native-mtu-1480'::text, 'native-mtu-1476'::text, 'native-mtu-1472'::text, 'native-mtu-1468'::text, 'native-mtu-1400'::text, 'native-mtu-1280'::text, 'native-mtu-1024'::text, 'native-mtu-576'::text])))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL kind","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_outcome_check","contype":"c","convalidated":true,"definition":"CHECK ((outcome = ANY (ARRAY['received'::text, 'source-unavailable'::text])))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id, stage_index)","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_probe_executions(receipt_id)","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_stage_index_check","contype":"c","convalidated":true,"definition":"CHECK (((stage_index >= 1) AND (stage_index <= 11)))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_stage_index_not_null","contype":"n","convalidated":true,"definition":"NOT NULL stage_index","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['intent'::text, 'received'::text])))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_timeout_ms_check","contype":"c","convalidated":true,"definition":"CHECK (((timeout_ms >= 1) AND (timeout_ms <= 120000)))","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_execution_stages_timeout_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL timeout_ms","relname":"server_probe_execution_stages"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_actor_id_check","contype":"c","convalidated":true,"definition":"CHECK (((length(actor_id) >= 1) AND (length(actor_id) <= 200)))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_actor_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL actor_id","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_attempted_stages_check","contype":"c","convalidated":true,"definition":"CHECK (((attempted_stages >= 0) AND (attempted_stages <= 11)))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_authentication_check","contype":"c","convalidated":true,"definition":"CHECK ((authentication = ANY (ARRAY['mcp'::text, 'jwt'::text, 'local'::text])))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_authentication_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authentication","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_authority_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_expires_at","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_authority_issued_at_check","contype":"c","convalidated":true,"definition":"CHECK ((authority_issued_at >= 0))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_authority_issued_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_issued_at","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_check","contype":"c","convalidated":true,"definition":"CHECK (((completed_stages >= 0) AND (completed_stages <= attempted_stages)))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_check1","contype":"c","convalidated":true,"definition":"CHECK ((((identity_kind = 'mcp'::text) AND (authentication = 'mcp'::text) AND (mcp_connection_id IS NOT NULL) AND (mcp_credential_id IS NOT NULL) AND (request_id IS NULL)) OR ((identity_kind = 'rest'::text) AND (authentication = ANY (ARRAY['jwt'::text, 'local'::text])) AND (mcp_connection_id IS NULL) AND (mcp_credential_id IS NULL) AND (request_id IS NOT NULL) AND ((length(request_id) >= 1) AND (length(request_id) <= 200)))))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_check2","contype":"c","convalidated":true,"definition":"CHECK (((tool = 'bandwidth'::text) = (destination_server_id IS NOT NULL)))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_destination_server_id_check","contype":"c","convalidated":true,"definition":"CHECK ((destination_server_id > 0))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_mcp_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (mcp_connection_id) REFERENCES mcp_connections(id)","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_mcp_credential_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (mcp_credential_id) REFERENCES mcp_credentials(id)","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_receipt_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((receipt_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_source_server_id_check","contype":"c","convalidated":true,"definition":"CHECK ((source_server_id > 0))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_source_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_server_id","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['claimed'::text, 'completed'::text, 'failed'::text, 'cancelled'::text])))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_tool_check","contype":"c","convalidated":true,"definition":"CHECK ((tool = ANY (ARRAY['ping'::text, 'traceroute'::text, 'bandwidth'::text, 'dns'::text, 'route'::text, 'mtu'::text])))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_executions_tool_not_null","contype":"n","convalidated":true,"definition":"NOT NULL tool","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_authority_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL authority_expires_at","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_binding_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((binding_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_binding_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL binding_proof","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_check","contype":"c","convalidated":true,"definition":"CHECK ((gc_not_before >= ((authority_expires_at + make_interval(days => retention_days)) + ((safety_ms)::double precision * '00:00:00.001'::interval))))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_check1","contype":"c","convalidated":true,"definition":"CHECK (((claim_token IS NULL) OR ((claim_attempted_at IS NULL) AND (purged_at IS NULL) AND (cancelled_at IS NULL))))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_check2","contype":"c","convalidated":true,"definition":"CHECK (((cancelled_at IS NULL) OR ((claim_token IS NULL) AND (claim_attempted_at IS NOT NULL))))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_execution_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL execution_id","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_gc_not_before_not_null","contype":"n","convalidated":true,"definition":"NOT NULL gc_not_before","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_identity_kind_check","contype":"c","convalidated":true,"definition":"CHECK ((identity_kind = ANY (ARRAY['mcp'::text, 'rest'::text])))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_identity_kind_execution_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (identity_kind, execution_id)","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_identity_kind_not_null","contype":"n","convalidated":true,"definition":"NOT NULL identity_kind","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_owner_id_check","contype":"c","convalidated":true,"definition":"CHECK (((length(owner_id) >= 1) AND (length(owner_id) <= 200)))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_retention_days_check","contype":"c","convalidated":true,"definition":"CHECK (((retention_days >= 1) AND (retention_days <= 365)))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_safety_ms_check","contype":"c","convalidated":true,"definition":"CHECK (((safety_ms >= 60000) AND (safety_ms <= 86400000)))","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_admissions_safety_ms_not_null","contype":"n","convalidated":true,"definition":"NOT NULL safety_ms","relname":"server_probe_storage_admissions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_terminal_state","contype":"c","convalidated":true,"definition":"CHECK ((((state = 'claimed'::text) AND (receipt_proof IS NULL) AND (finished_at IS NULL) AND (attempted_stages IS NULL) AND (completed_stages IS NULL)) OR ((state <> 'claimed'::text) AND (receipt_proof IS NOT NULL) AND (finished_at IS NOT NULL) AND (attempted_stages IS NOT NULL) AND (completed_stages IS NOT NULL))))","relname":"server_probe_executions"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_admissions_check","contype":"c","convalidated":true,"definition":"CHECK ((admissions >= 0))","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_admissions_not_null","contype":"n","convalidated":true,"definition":"NOT NULL admissions","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_check","contype":"c","convalidated":true,"definition":"CHECK (((reserved_files >= 0) AND (reserved_files <= admissions)))","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_check1","contype":"c","convalidated":true,"definition":"CHECK ((reserved_bytes = ((admissions * 32768) + (reserved_files * 262144))))","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (scope)","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_reserved_bytes_check","contype":"c","convalidated":true,"definition":"CHECK ((reserved_bytes >= 0))","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_reserved_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reserved_bytes","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_reserved_files_not_null","contype":"n","convalidated":true,"definition":"NOT NULL reserved_files","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_scope_check","contype":"c","convalidated":true,"definition":"CHECK (((scope = 'global'::text) OR ((scope ~~ 'owner:%'::text) AND ((length(scope) >= 7) AND (length(scope) <= 206)))))","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_probe_storage_usage_scope_not_null","contype":"n","convalidated":true,"definition":"NOT NULL scope","relname":"server_probe_storage_usage"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id, polled_at)","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_polled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL polled_at","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['online'::text, 'offline'::text])))","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"server_snapshots_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"server_snapshots"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_api_ping_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"servers_api_ping_settings"},{"condeferrable":false,"condeferred":false,"conname":"servers_asn_not_null","contype":"n","convalidated":true,"definition":"NOT NULL asn","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_comment_not_null","contype":"n","convalidated":true,"definition":"NOT NULL comment","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_country_not_null","contype":"n","convalidated":true,"definition":"NOT NULL country","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_host_not_null","contype":"n","convalidated":true,"definition":"NOT NULL host","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_lan_subnet_not_null","contype":"n","convalidated":true,"definition":"NOT NULL lan_subnet","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_mgmt_tunnel_ip_not_null","contype":"n","convalidated":true,"definition":"NOT NULL mgmt_tunnel_ip","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_password_not_null","contype":"n","convalidated":true,"definition":"NOT NULL password","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL port","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_rest_ping_samples_ok_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ok","relname":"servers_rest_ping_samples"},{"condeferrable":false,"condeferred":false,"conname":"servers_rest_ping_samples_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, sampled_at)","relname":"servers_rest_ping_samples"},{"condeferrable":false,"condeferred":false,"conname":"servers_rest_ping_samples_sampled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sampled_at","relname":"servers_rest_ping_samples"},{"condeferrable":false,"condeferred":false,"conname":"servers_rest_ping_samples_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"servers_rest_ping_samples"},{"condeferrable":false,"condeferred":false,"conname":"servers_rest_ping_samples_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"servers_rest_ping_samples"},{"condeferrable":false,"condeferred":false,"conname":"servers_routing_endpoint_epoch_not_null","contype":"n","convalidated":true,"definition":"NOT NULL routing_endpoint_epoch","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_site_not_null","contype":"n","convalidated":true,"definition":"NOT NULL site","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_type_check","contype":"c","convalidated":true,"definition":"CHECK ((type = ANY (ARRAY['jump-host'::text, 'exit-node'::text, 'home-router'::text])))","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL type","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_use_ssl_not_null","contype":"n","convalidated":true,"definition":"NOT NULL use_ssl","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_username_not_null","contype":"n","convalidated":true,"definition":"NOT NULL username","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_verify_ssl_not_null","contype":"n","convalidated":true,"definition":"NOT NULL verify_ssl","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"servers_wan_uplinks_not_null","contype":"n","convalidated":true,"definition":"NOT NULL wan_uplinks","relname":"servers"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_last_attempt_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL last_attempt_at","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id)","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_server_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_updated_at","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['pending'::text, 'ok'::text, 'error'::text])))","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_collection_state_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"traffic_collection_state"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_collector_ip_not_null","contype":"n","convalidated":true,"definition":"NOT NULL collector_ip","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_flow_listen_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL flow_listen_port","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_host_private_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL host_private_key","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_host_public_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL host_public_key","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_map_service_min_share_pct_not_null","contype":"n","convalidated":true,"definition":"NOT NULL map_service_min_share_pct","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_packets_received_not_null","contype":"n","convalidated":true,"definition":"NOT NULL packets_received","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_peers_json_not_null","contype":"n","convalidated":true,"definition":"NOT NULL peers_json","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_prefix_not_null","contype":"n","convalidated":true,"definition":"NOT NULL prefix","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_public_endpoint_not_null","contype":"n","convalidated":true,"definition":"NOT NULL public_endpoint","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_retention_hours_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_hours","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_top_n_not_null","contype":"n","convalidated":true,"definition":"NOT NULL top_n","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_flow_settings_wg_listen_port_not_null","contype":"n","convalidated":true,"definition":"NOT NULL wg_listen_port","relname":"traffic_flow_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_flags_not_null","contype":"n","convalidated":true,"definition":"NOT NULL flags","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_interface_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interface_name","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_peer_public_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL peer_public_key","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, sampled_at, interface_name, peer_public_key)","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_rx_bps_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rx_bps","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_rx_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL rx_bytes","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_sampled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sampled_at","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_tx_bps_not_null","contype":"n","convalidated":true,"definition":"NOT NULL tx_bps","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_samples_tx_bytes_not_null","contype":"n","convalidated":true,"definition":"NOT NULL tx_bytes","relname":"traffic_samples"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_poll_configuration_epoch_not_null","contype":"n","convalidated":true,"definition":"NOT NULL poll_configuration_epoch","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"traffic_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"traffic_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_loss_pct_not_null","contype":"n","convalidated":true,"definition":"NOT NULL loss_pct","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_measurement_known_not_null","contype":"n","convalidated":true,"definition":"NOT NULL measurement_known","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (probe_id, sampled_at)","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_probe_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (probe_id) REFERENCES uptime_probes(id) ON DELETE CASCADE","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_probe_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL probe_id","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_sampled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sampled_at","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['up'::text, 'warn'::text, 'down'::text])))","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probe_samples_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"uptime_probe_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL name","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_probe_filter_not_null","contype":"n","convalidated":true,"definition":"NOT NULL probe_filter","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_show_on_dashboard_not_null","contype":"n","convalidated":true,"definition":"NOT NULL show_on_dashboard","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_sort_order_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_order","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_src_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_interface","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_src_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (src_server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_src_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_server_id","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_target_not_null","contype":"n","convalidated":true,"definition":"NOT NULL target","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_probes_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"uptime_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_cpu_load_not_null","contype":"n","convalidated":true,"definition":"NOT NULL cpu_load","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_free_hdd_space_not_null","contype":"n","convalidated":true,"definition":"NOT NULL free_hdd_space","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_free_memory_not_null","contype":"n","convalidated":true,"definition":"NOT NULL free_memory","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (server_id, sampled_at)","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_sampled_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sampled_at","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['online'::text, 'offline'::text])))","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_total_hdd_space_not_null","contype":"n","convalidated":true,"definition":"NOT NULL total_hdd_space","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_total_memory_not_null","contype":"n","convalidated":true,"definition":"NOT NULL total_memory","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_resource_samples_uptime_seconds_not_null","contype":"n","convalidated":true,"definition":"NOT NULL uptime_seconds","relname":"uptime_resource_samples"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_id_check","contype":"c","convalidated":true,"definition":"CHECK ((id = 1))","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interval_sec","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_ping_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ping_enabled","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_poll_configuration_epoch_not_null","contype":"n","convalidated":true,"definition":"NOT NULL poll_configuration_epoch","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_probe_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL probe_interval_sec","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_resources_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL resources_enabled","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_retention_days_not_null","contype":"n","convalidated":true,"definition":"NOT NULL retention_days","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_speed_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL speed_enabled","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_speed_interval_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL speed_interval_sec","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_settings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"uptime_settings"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_direction_check","contype":"c","convalidated":true,"definition":"CHECK ((direction = ANY (ARRAY['transmit'::text, 'receive'::text, 'both'::text])))","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_direction_not_null","contype":"n","convalidated":true,"definition":"NOT NULL direction","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_dst_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_interface","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_dst_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (dst_server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_dst_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_server_id","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_duration_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL duration_sec","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_enabled_not_null","contype":"n","convalidated":true,"definition":"NOT NULL enabled","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_last_status_check","contype":"c","convalidated":true,"definition":"CHECK ((last_status = ANY (ARRAY['done'::text, 'error'::text])))","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_protocol_check","contype":"c","convalidated":true,"definition":"CHECK ((protocol = ANY (ARRAY['tcp'::text, 'udp'::text])))","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_protocol_not_null","contype":"n","convalidated":true,"definition":"NOT NULL protocol","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_sort_order_not_null","contype":"n","convalidated":true,"definition":"NOT NULL sort_order","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_src_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_interface","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_src_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (src_server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_src_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_server_id","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_probes_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"uptime_speed_probes"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_direction_check","contype":"c","convalidated":true,"definition":"CHECK ((direction = ANY (ARRAY['transmit'::text, 'receive'::text, 'both'::text])))","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_direction_not_null","contype":"n","convalidated":true,"definition":"NOT NULL direction","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_dst_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_interface","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_dst_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (dst_server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_dst_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL dst_server_id","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_duration_sec_not_null","contype":"n","convalidated":true,"definition":"NOT NULL duration_sec","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_protocol_check","contype":"c","convalidated":true,"definition":"CHECK ((protocol = ANY (ARRAY['tcp'::text, 'udp'::text])))","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_protocol_not_null","contype":"n","convalidated":true,"definition":"NOT NULL protocol","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_src_interface_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_interface","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_src_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (src_server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_src_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL src_server_id","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_status_check","contype":"c","convalidated":true,"definition":"CHECK ((status = ANY (ARRAY['done'::text, 'error'::text])))","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"uptime_speed_test_runs_status_not_null","contype":"n","convalidated":true,"definition":"NOT NULL status","relname":"uptime_speed_test_runs"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_comment_not_null","contype":"n","convalidated":true,"definition":"NOT NULL comment","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_created_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL created_at","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL id","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_interface_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interface_name","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_interface_type_check","contype":"c","convalidated":true,"definition":"CHECK ((interface_type = ANY (ARRAY['ether'::text, 'bridge'::text, 'vlan'::text, 'vxlan'::text, 'gre'::text, 'wg'::text, 'ipsec'::text, 'other'::text])))","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_interface_type_not_null","contype":"n","convalidated":true,"definition":"NOT NULL interface_type","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_peer_name_not_null","contype":"n","convalidated":true,"definition":"NOT NULL peer_name","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_peer_public_key_not_null","contype":"n","convalidated":true,"definition":"NOT NULL peer_public_key","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (id)","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_server_id_interface_name_peer_publi_key","contype":"u","convalidated":true,"definition":"UNIQUE (server_id, interface_name, peer_public_key)","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_updated_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL updated_at","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_user_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (user_id) REFERENCES app_users(id) ON DELETE CASCADE","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"user_interface_bindings_user_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL user_id","relname":"user_interface_bindings"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_action_id_check","contype":"c","convalidated":true,"definition":"CHECK ((action_id = ANY (ARRAY['ros.vrf.create'::text, 'ros.vrf.update'::text, 'ros.vrf.delete'::text])))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_action_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL action_id","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_action_version_check","contype":"c","convalidated":true,"definition":"CHECK ((action_version > 0))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_action_version_not_null","contype":"n","convalidated":true,"definition":"NOT NULL action_version","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_check","contype":"c","convalidated":true,"definition":"CHECK (((expires_at > issued_at) AND (expires_at <= (issued_at + '00:05:00'::interval))))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_check1","contype":"c","convalidated":true,"definition":"CHECK ((((state = 'issued'::text) AND (claimed_at IS NULL)) OR ((state = 'claimed'::text) AND (claimed_at IS NOT NULL))))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_ciphertext_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ciphertext","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_digest_check","contype":"c","convalidated":true,"definition":"CHECK ((digest ~ '^[a-f0-9]{64}$'::text))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL digest","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_expires_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL expires_at","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_issued_at_not_null","contype":"n","convalidated":true,"definition":"NOT NULL issued_at","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_owner_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL owner_id","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (ticket_id)","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_plan_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (plan_id) REFERENCES mcp_plans(id)","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_plan_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (plan_id)","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL plan_id","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_server_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (server_id) REFERENCES servers(id)","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_server_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL server_id","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_source_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((source_proof ~ '^[a-f0-9]{64}$'::text))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_source_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_proof","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_state_check","contype":"c","convalidated":true,"definition":"CHECK ((state = ANY (ARRAY['issued'::text, 'claimed'::text])))","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_state_not_null","contype":"n","convalidated":true,"definition":"NOT NULL state","relname":"vrf_production_tickets"},{"condeferrable":false,"condeferred":false,"conname":"vrf_production_tickets_ticket_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL ticket_id","relname":"vrf_production_tickets"},{"condeferrable":true,"condeferred":true,"conname":"server_poll_admission_final_guard","contype":"t","convalidated":true,"definition":"TRIGGER DEFERRABLE INITIALLY DEFERRED","relname":"server_poll_storage_admissions"},{"condeferrable":true,"condeferred":true,"conname":"server_poll_archive_final_guard","contype":"t","convalidated":true,"definition":"TRIGGER DEFERRABLE INITIALLY DEFERRED","relname":"server_poll_archives"},{"condeferrable":true,"condeferred":true,"conname":"server_poll_compact_final_guard","contype":"t","convalidated":true,"definition":"TRIGGER DEFERRABLE INITIALLY DEFERRED","relname":"server_poll_storage_admissions"}],"database":[{"acl":["@mm-role:control@=CTc/@mm-role:control@","@mm-role:capture@=c/@mm-role:control@","@mm-role:operator@=c/@mm-role:control@","@mm-role:publisher@=c/@mm-role:control@","@mm-role:runtime@=c/@mm-role:control@"],"datname":"current-database","owner":"@mm-role:control@"}],"effectiveDatabase":[{"connect":true,"create":false,"rolname":"@mm-role:capture@","temporary":false},{"connect":true,"create":false,"rolname":"@mm-role:operator@","temporary":false},{"connect":true,"create":false,"rolname":"@mm-role:publisher@","temporary":false},{"connect":true,"create":false,"rolname":"@mm-role:runtime@","temporary":false}],"effectiveFunctions":[{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_operator_ddl","rolname":"@mm-role:capture@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_operator_ddl","rolname":"@mm-role:operator@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_operator_ddl","rolname":"@mm-role:publisher@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_operator_ddl","rolname":"@mm-role:runtime@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_require_preadmission","rolname":"@mm-role:capture@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_require_preadmission","rolname":"@mm-role:operator@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_require_preadmission","rolname":"@mm-role:publisher@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_require_preadmission","rolname":"@mm-role:runtime@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_truncate_preadmitted","rolname":"@mm-role:capture@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_truncate_preadmitted","rolname":"@mm-role:publisher@"},{"arguments":"","execute":false,"nspname":"mmapp_control","proname":"candidate_truncate_preadmitted","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"mmapp_control","proname":"candidate_truncate_preadmitted","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_diagnostic_cancellation_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_diagnostic_cancellation_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_diagnostic_cancellation_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_diagnostic_cancellation_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_source","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_source","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_source","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_forward_charge_source","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_source","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_source","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_source","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_routing_manual_inverse_charge_source","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_scoped_recovery_manual_version","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_scoped_recovery_manual_version","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_scoped_recovery_manual_version","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mcp_scoped_recovery_manual_version","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"mm_routing_endpoint_epoch","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"mm_routing_endpoint_epoch","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"mm_routing_endpoint_epoch","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"mm_routing_endpoint_epoch","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_partition_writer_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_partition_writer_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_partition_writer_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_partition_writer_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_final_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_final_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_final_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_final_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_finish","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_finish","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_finish","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_finish","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_archive_insert_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_compacted_row_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_compacted_row_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_compacted_row_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_compacted_row_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_journal_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_journal_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_journal_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_journal_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_settings_epoch_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_settings_epoch_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_settings_epoch_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_settings_epoch_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_accounting_valid","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_accounting_valid","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_accounting_valid","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_accounting_valid","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_admission_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_admission_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_admission_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_admission_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_meter","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_meter","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_meter","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_poll_storage_row_meter","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_execution_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_execution_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_execution_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_execution_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_quarantine_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_quarantine_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_quarantine_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_quarantine_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_stage_immutable","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_stage_immutable","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_stage_immutable","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_stage_immutable","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_admission_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_admission_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_admission_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_admission_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_anchor_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_anchor_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_anchor_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_anchor_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_payload_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_payload_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_payload_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_payload_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_quarantine_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_quarantine_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_quarantine_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_quarantine_guard","rolname":"@mm-role:runtime@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_stage_guard","rolname":"@mm-role:capture@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_stage_guard","rolname":"@mm-role:operator@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_stage_guard","rolname":"@mm-role:publisher@"},{"arguments":"","execute":true,"nspname":"public","proname":"server_probe_storage_stage_guard","rolname":"@mm-role:runtime@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_compact_allowed","rolname":"@mm-role:capture@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_compact_allowed","rolname":"@mm-role:operator@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_compact_allowed","rolname":"@mm-role:publisher@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_compact_allowed","rolname":"@mm-role:runtime@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_gc_allowed","rolname":"@mm-role:capture@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_gc_allowed","rolname":"@mm-role:operator@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_gc_allowed","rolname":"@mm-role:publisher@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_poll_storage_gc_allowed","rolname":"@mm-role:runtime@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_probe_storage_gc_allowed","rolname":"@mm-role:capture@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_probe_storage_gc_allowed","rolname":"@mm-role:operator@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_probe_storage_gc_allowed","rolname":"@mm-role:publisher@"},{"arguments":"id uuid","execute":true,"nspname":"public","proname":"server_probe_storage_gc_allowed","rolname":"@mm-role:runtime@"},{"arguments":"receipt_uuid uuid","execute":true,"nspname":"public","proname":"server_poll_storage_source_payload","rolname":"@mm-role:capture@"},{"arguments":"receipt_uuid uuid","execute":true,"nspname":"public","proname":"server_poll_storage_source_payload","rolname":"@mm-role:operator@"},{"arguments":"receipt_uuid uuid","execute":true,"nspname":"public","proname":"server_poll_storage_source_payload","rolname":"@mm-role:publisher@"},{"arguments":"receipt_uuid uuid","execute":true,"nspname":"public","proname":"server_poll_storage_source_payload","rolname":"@mm-role:runtime@"}],"effectiveSchemas":[{"create":false,"nspname":"mmapp_control","rolname":"@mm-role:capture@","usage":false},{"create":false,"nspname":"mmapp_control","rolname":"@mm-role:operator@","usage":true},{"create":false,"nspname":"mmapp_control","rolname":"@mm-role:publisher@","usage":true},{"create":false,"nspname":"mmapp_control","rolname":"@mm-role:runtime@","usage":false},{"create":false,"nspname":"public","rolname":"@mm-role:capture@","usage":true},{"create":false,"nspname":"public","rolname":"@mm-role:publisher@","usage":true},{"create":false,"nspname":"public","rolname":"@mm-role:runtime@","usage":true},{"create":true,"nspname":"public","rolname":"@mm-role:operator@","usage":true}],"effectiveSequences":[{"read":false,"relname":"filter_rules_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"filter_rules_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"internet_path_snapshots_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"internet_path_snapshots_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"mcp_audit_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"mcp_audit_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"recursive_routes_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"recursive_routes_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"router_log_entries_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"router_log_entries_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"server_snapshots_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"server_snapshots_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":false,"relname":"servers_id_seq","rolname":"@mm-role:publisher@","update":false,"usage":false},{"read":false,"relname":"servers_id_seq","rolname":"@mm-role:runtime@","update":false,"usage":false},{"read":true,"relname":"filter_rules_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"filter_rules_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"internet_path_snapshots_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"internet_path_snapshots_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"mcp_audit_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"mcp_audit_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"recursive_routes_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"recursive_routes_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"router_log_entries_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"router_log_entries_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"server_snapshots_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"server_snapshots_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true},{"read":true,"relname":"servers_id_seq","rolname":"@mm-role:capture@","update":false,"usage":false},{"read":true,"relname":"servers_id_seq","rolname":"@mm-role:operator@","update":true,"usage":true}],"events":[{"evtenabled":"O","evtevent":"ddl_command_start","evtname":"candidate_operator_ddl","evttags":null,"function":"mmapp_control.candidate_operator_ddl()","function_name":"candidate_operator_ddl","function_namespace":"mmapp_control","owner":"@mm-role:control@"}],"functions":[{"acl":["@mm-role:control@=X/@mm-role:control@","@mm-role:operator@=X/@mm-role:control@"],"arguments":"","definition":"CREATE OR REPLACE FUNCTION mmapp_control.candidate_truncate_preadmitted()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'pg_catalog'\nAS $function$\nBEGIN PERFORM mmapp_control.candidate_require_preadmission(); RETURN NULL; END $function$\n","language":"plpgsql","namespace":"mmapp_control","owner":"@mm-role:control@","proconfig":["search_path=pg_catalog"],"prokind":"f","proname":"candidate_truncate_preadmitted","prosecdef":true},{"acl":["@mm-role:control@=X/@mm-role:control@"],"arguments":"","definition":"CREATE OR REPLACE FUNCTION mmapp_control.candidate_operator_ddl()\n RETURNS event_trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'pg_catalog'\nAS $function$\nBEGIN\n IF SESSION_USER='@mm-role:operator@' THEN PERFORM mmapp_control.candidate_require_preadmission(); END IF;\nEND $function$\n","language":"plpgsql","namespace":"mmapp_control","owner":"@mm-role:control@","proconfig":["search_path=pg_catalog"],"prokind":"f","proname":"candidate_operator_ddl","prosecdef":true},{"acl":["@mm-role:control@=X/@mm-role:control@"],"arguments":"","definition":"CREATE OR REPLACE FUNCTION mmapp_control.candidate_require_preadmission()\n RETURNS void\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'pg_catalog'\nAS $function$\nBEGIN\n IF NOT EXISTS(SELECT 1 FROM pg_catalog.pg_locks WHERE pid=pg_catalog.pg_backend_pid()\n AND locktype='advisory' AND classid=0 AND objid=8723110 AND objsubid=1\n AND granted AND mode IN ('ShareLock','ExclusiveLock')) THEN\n RAISE EXCEPTION 'operator SQL requires preheld writer admission' USING ERRCODE='55000';\n END IF;\n PERFORM pg_catalog.pg_advisory_xact_lock_shared(8723110::bigint);\nEND $function$\n","language":"plpgsql","namespace":"mmapp_control","owner":"@mm-role:control@","proconfig":["search_path=pg_catalog"],"prokind":"f","proname":"candidate_require_preadmission","prosecdef":true},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_diagnostic_cancellation_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE original_receipt uuid;\nBEGIN\n IF TG_OP='DELETE' THEN\n SELECT a.receipt_id INTO original_receipt FROM server_probe_storage_admissions a\n JOIN mcp_operations o ON o.id=a.execution_id AND o.connection_id=OLD.connection_id\n WHERE a.identity_kind='mcp' AND a.execution_id=OLD.operation_id AND a.owner_id=OLD.actor_id;\n IF FOUND AND server_probe_storage_gc_allowed(original_receipt) THEN RETURN OLD; END IF;\n END IF;\n RAISE EXCEPTION 'diagnostic cancellation lifetime has not elapsed';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_diagnostic_cancellation_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_routing_forward_charge_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE retention integer;\nBEGIN\n IF TG_OP<>'DELETE' THEN RAISE EXCEPTION 'immutable forward charge; rewrite/refund forbidden'; END IF;\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1 FOR SHARE;\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365\n OR OLD.created_at>clock_timestamp()-interval '1 hour'\n OR OLD.created_at>=clock_timestamp()-make_interval(days=>retention)\n OR EXISTS(SELECT 1 FROM public.mcp_operations WHERE id=OLD.source_operation_id AND state IN('pending','running'))\n THEN RAISE EXCEPTION 'forward charge is still retained or unresolved'; END IF;\n RETURN OLD;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_routing_forward_charge_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_routing_forward_charge_source()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nBEGIN\n IF NOT EXISTS(\n SELECT 1 FROM public.mcp_operations o\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN public.mcp_routing_profiles r ON r.id=NEW.profile_id AND r.connection_id=o.connection_id\n WHERE o.id=NEW.source_operation_id AND p.id=NEW.source_plan_id\n AND o.connection_id=NEW.connection_id AND o.state='pending' AND p.state='executing'\n AND p.operation_id='routing.community.switch' AND p.operation_version=7\n ) THEN RAISE EXCEPTION 'forward charge differs from actual pending admission source'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_routing_forward_charge_source","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_routing_manual_inverse_charge_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\r\nDECLARE retention integer;\r\nBEGIN\r\n IF TG_OP<>'DELETE' THEN RAISE EXCEPTION 'immutable manual inverse charge; rewrite/refund forbidden'; END IF;\r\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1 FOR SHARE;\r\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365\r\n OR OLD.created_at>clock_timestamp()-interval '1 hour'\r\n OR OLD.created_at>=clock_timestamp()-make_interval(days=>retention)\r\n OR EXISTS(SELECT 1 FROM public.mcp_operations WHERE id=OLD.recovery_operation_id AND state IN('pending','running'))\r\n THEN RAISE EXCEPTION 'manual inverse charge still retained or unresolved'; END IF;\r\n RETURN OLD;\r\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_routing_manual_inverse_charge_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_routing_manual_inverse_charge_source()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\r\nBEGIN\r\n IF NOT EXISTS(\r\n SELECT 1 FROM public.mcp_operations o\r\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\r\n JOIN public.mcp_routing_profiles r ON r.id=NEW.profile_id AND r.connection_id=o.connection_id\r\n JOIN public.mcp_operations source ON source.id=NEW.source_operation_id AND source.connection_id=o.connection_id\r\n JOIN public.mcp_plans sp ON sp.id=source.plan_id AND sp.connection_id=source.connection_id\r\n JOIN public.mcp_connections c ON c.id=o.connection_id\r\n WHERE o.id=NEW.recovery_operation_id AND p.id=NEW.recovery_plan_id\r\n AND o.connection_id=NEW.connection_id AND c.owner_id=NEW.owner_id\r\n AND r.version=NEW.profile_version AND o.state='pending' AND p.state='executing'\r\n AND p.operation_id='operations.recover' AND p.operation_version=7\r\n AND sp.id=NEW.source_plan_id AND sp.operation_id='routing.community.switch' AND sp.operation_version=7\r\n AND source.state IN('applied','partial')\r\n ) THEN RAISE EXCEPTION 'manual inverse charge differs from pending admission'; END IF;\r\n RETURN NEW;\r\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_routing_manual_inverse_charge_source","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_scoped_recovery_manual_version()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\r\nBEGIN\r\n IF NEW.mode='manual' AND NOT pg_try_advisory_xact_lock(hashtextextended('mcp-runner-admission',0))\r\n THEN RAISE EXCEPTION 'manual intent admission snapshot busy'; END IF;\r\n IF NEW.mode='manual' AND NOT EXISTS(\r\n SELECT 1 FROM public.mcp_operations o\r\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\r\n JOIN public.mcp_operation_steps s ON s.operation_id=o.id AND s.step_index=0\r\n JOIN public.mcp_operations source ON source.id=NEW.source_operation_id AND source.connection_id=o.connection_id\r\n WHERE o.id=NEW.recovery_operation_id AND o.state='running'\r\n AND p.state='executing' AND p.operation_id='operations.recover' AND p.operation_version=7\r\n AND NEW.source_step_index=0 AND s.state='intent'\r\n AND s.intended_state->>'kind'='service'\r\n AND s.intended_state->>'service'='routing.community.scoped.recover'\r\n AND s.intended_state->'input'->>'mode'='manual'\r\n AND s.intended_state->'input'->>'sourceOperationId'=NEW.source_operation_id::text\r\n AND s.intended_state->'input'->>'receiptId'=NEW.recovery_receipt_id::text\r\n ) THEN RAISE EXCEPTION 'manual inverse requires current exact running recovery'; END IF;\r\n RETURN NEW;\r\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_scoped_recovery_manual_version","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mm_routing_endpoint_epoch()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nBEGIN\n IF ROW(NEW.host,NEW.port,NEW.username,NEW.password,NEW.use_ssl,NEW.verify_ssl,NEW.enabled)\n IS DISTINCT FROM ROW(OLD.host,OLD.port,OLD.username,OLD.password,OLD.use_ssl,OLD.verify_ssl,OLD.enabled) THEN\n NEW.routing_endpoint_epoch := gen_random_uuid();\n ELSE\n NEW.routing_endpoint_epoch := OLD.routing_endpoint_epoch;\n END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mm_routing_endpoint_epoch","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_partition_writer_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog'\nAS $function$ BEGIN PERFORM pg_advisory_xact_lock_shared(8723110::bigint); IF TG_OP='DELETE' THEN RETURN OLD; END IF; RETURN NEW; END; $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog"],"prokind":"f","proname":"server_partition_writer_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_archive_final_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE id uuid; a public.server_poll_storage_admissions%ROWTYPE;\nBEGIN\n id:=CASE WHEN TG_OP='DELETE' THEN OLD.receipt_id ELSE NEW.receipt_id END;\n SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id;\n IF FOUND AND a.storage_state='compacted' AND(EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=id)\n OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=id)\n OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=id))\n THEN RAISE EXCEPTION 'compacted poll retained incomplete original children'; END IF;\n IF NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'poll final archive or exact ledger mismatch'; END IF;\n RETURN NULL;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_archive_final_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_archive_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$ BEGIN\n IF TG_OP='DELETE' AND public.server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'poll archive is immutable until original full retention GC';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_archive_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_archive_insert_finish()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$ BEGIN\n DELETE FROM public.server_poll_acks WHERE receipt_id=NEW.receipt_id;\n DELETE FROM public.server_poll_intents WHERE receipt_id=NEW.receipt_id;\n DELETE FROM public.server_poll_receipts WHERE receipt_id=NEW.receipt_id;\n DELETE FROM public.server_poll_executions WHERE receipt_id=NEW.receipt_id;\n UPDATE public.server_poll_storage_admissions SET storage_state='compacted',compact_at=NEW.created_at,archive_bytes=NEW.ciphertext_bytes,original_activity_at=NEW.original_activity_at WHERE receipt_id=NEW.receipt_id AND storage_state='full';\n IF NOT FOUND THEN RAISE EXCEPTION 'poll admission did not transition with archive'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_archive_insert_finish","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_archive_insert_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE a public.server_poll_storage_admissions%ROWTYPE; payload jsonb; activity timestamptz;\nBEGIN\n payload:=public.server_poll_storage_source_payload(NEW.receipt_id);\n IF payload IS NULL OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'poll source is not eligible for terminal archive'; END IF;\n SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;\n SELECT GREATEST(a.authority_expires_at,a.created_at,a.claim_attempted_at,(payload#>>'{terminal,operation,finished_at}')::timestamptz,\n (payload#>>'{terminal,plan,expires_at}')::timestamptz,(payload#>>'{terminal,step,finished_at}')::timestamptz,\n (payload#>>'{journal,execution,created_at}')::timestamptz,(payload#>>'{journal,receipt,created_at}')::timestamptz,\n (SELECT max((v->>'created_at')::timestamptz) FROM jsonb_array_elements(payload#>'{journal,intents}') v),\n (SELECT max((v->>'created_at')::timestamptz) FROM jsonb_array_elements(payload#>'{journal,acks}') v)) INTO activity;\n IF a.compaction_claim IS NULL OR a.compaction_claimed_at IS NULL OR NOT isfinite(a.compaction_claimed_at)\n OR a.compaction_claim_xid IS NULL OR a.compaction_claim_xid=pg_current_xact_id()\n OR NEW.version<>1 OR NEW.execution_id<>a.execution_id OR NEW.connection_id<>a.connection_id OR NEW.owner_id<>a.owner_id\n OR NEW.binding_proof<>a.binding_proof OR NEW.context_proof<>a.context_proof OR NEW.original_expires_at<>a.authority_expires_at\n OR NEW.original_activity_at<>activity OR NEW.decoded_bytes<>octet_length(payload::text)\n OR NEW.source_sha256<>encode(sha256(convert_to(payload::text,'UTF8')),'hex')\n OR NEW.ciphertext_bytes<>octet_length(NEW.ciphertext) OR NEW.ciphertext_bytes>131072\n OR NEW.ciphertext !~ '^[A-Za-z0-9+/]+={0,2}$'\n OR replace(encode(decode(NEW.ciphertext,'base64'),'base64'),E'\\n','')<>NEW.ciphertext\n OR octet_length(decode(NEW.ciphertext,'base64'))<>NEW.compressed_bytes+28\n THEN RAISE EXCEPTION 'poll archive does not match the entire immutable source'; END IF;\n NEW.created_at:=clock_timestamp(); NEW.compaction_xid:=pg_current_xact_id();\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["TimeZone=UTC","search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_archive_insert_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_compacted_row_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$ BEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n IF EXISTS(SELECT 1 FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id AND storage_state='compacted') THEN RAISE EXCEPTION 'compacted poll journal cannot reopen'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_compacted_row_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_journal_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$ BEGIN\n IF TG_OP='DELETE' AND EXISTS(SELECT 1 FROM public.server_poll_archives r JOIN public.server_poll_storage_admissions a USING(receipt_id)\n WHERE r.receipt_id=OLD.receipt_id AND r.compaction_xid=pg_current_xact_id() AND a.storage_state='full') THEN RETURN OLD; END IF;\n IF TG_OP='DELETE' AND public.server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'server poll journal is immutable outside complete archive or original lifetime GC';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_journal_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_settings_epoch_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog'\nAS $function$\r\nBEGIN\r\n IF TG_TABLE_SCHEMA <> 'public' OR TG_TABLE_NAME NOT IN\r\n ('traffic_settings', 'uptime_settings', 'internet_path_settings')\r\n OR TG_LEVEL <> 'ROW' OR TG_WHEN <> 'BEFORE' THEN\r\n RAISE EXCEPTION 'unexpected poll settings epoch trigger target';\r\n END IF;\r\n IF TG_OP = 'INSERT' THEN\r\n -- Never accept an epoch supplied by an importer or application caller.\r\n NEW.poll_configuration_epoch := pg_catalog.gen_random_uuid();\r\n ELSIF TG_OP = 'UPDATE' THEN\r\n -- Every unknown/future field is configuration by default. Only these four\r\n -- current collector fields are excluded; created_at stays significant.\r\n IF (pg_catalog.to_jsonb(NEW) - ARRAY['poll_configuration_epoch',\r\n 'last_collected_at', 'last_duration_ms', 'last_error', 'updated_at'])\r\n IS DISTINCT FROM\r\n (pg_catalog.to_jsonb(OLD) - ARRAY['poll_configuration_epoch',\r\n 'last_collected_at', 'last_duration_ms', 'last_error', 'updated_at']) THEN\r\n NEW.poll_configuration_epoch := pg_catalog.gen_random_uuid();\r\n ELSE\r\n NEW.poll_configuration_epoch := OLD.poll_configuration_epoch;\r\n END IF;\r\n ELSE\r\n RAISE EXCEPTION 'unexpected poll settings epoch trigger operation';\r\n END IF;\r\n RETURN NEW;\r\nEND;\r\n$function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog"],"prokind":"f","proname":"server_poll_settings_epoch_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_accounting_valid()\n RETURNS boolean\n LANGUAGE sql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\n WITH charges AS (\n SELECT owner_id,CASE WHEN storage_state='full' THEN 1 ELSE 0 END::bigint AS heavy,\n CASE WHEN storage_state='compacted' THEN 1 ELSE 0 END::bigint AS compact,\n COALESCE(archive_bytes,0)::bigint AS archives,\n CASE WHEN storage_state='full' THEN 4019 ELSE 2 END::bigint AS rows,\n CASE WHEN storage_state='full' THEN 8421376 ELSE 32768+archive_bytes END::bigint AS bytes\n FROM public.server_poll_storage_admissions\n ), expected AS (\n SELECT 'global' AS scope,COALESCE(sum(heavy),0) AS heavy,COALESCE(sum(compact),0) AS compact,COALESCE(sum(archives),0) AS archives,COALESCE(sum(rows),0) AS rows,COALESCE(sum(bytes),0) AS bytes FROM charges\n UNION ALL SELECT 'owner:'||owner_id,sum(heavy),sum(compact),sum(archives),sum(rows),sum(bytes) FROM charges GROUP BY owner_id\n ) SELECT NOT EXISTS(SELECT 1 FROM public.server_poll_storage_usage u FULL JOIN expected e USING(scope)\n WHERE u.scope IS NULL OR u.admissions<>COALESCE(e.heavy,0) OR u.compacted_admissions<>COALESCE(e.compact,0)\n OR u.archive_bytes<>COALESCE(e.archives,0) OR u.reserved_rows<>COALESCE(e.rows,0) OR u.reserved_bytes<>COALESCE(e.bytes,0))\n AND NOT EXISTS(SELECT 1 FROM public.server_poll_storage_admissions a LEFT JOIN public.server_poll_archives r USING(receipt_id)\n WHERE (a.storage_state='full' AND r.receipt_id IS NOT NULL) OR(a.storage_state='compacted' AND(r.receipt_id IS NULL OR a.archive_bytes<>r.ciphertext_bytes)))\n$function$\n","language":"sql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_storage_accounting_valid","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_admission_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE retention integer; charged integer; r public.server_poll_archives%ROWTYPE;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n IF TG_OP='DELETE' THEN\n IF NOT public.server_poll_storage_gc_allowed(OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id) THEN RAISE EXCEPTION 'poll lifetime or children prevent admission deletion'; END IF;\n UPDATE public.server_poll_storage_usage SET admissions=admissions-CASE WHEN OLD.storage_state='full' THEN 1 ELSE 0 END,\n compacted_admissions=compacted_admissions-CASE WHEN OLD.storage_state='compacted' THEN 1 ELSE 0 END,\n archive_bytes=archive_bytes-COALESCE(OLD.archive_bytes,0),\n reserved_rows=reserved_rows-CASE WHEN OLD.storage_state='full' THEN 4019 ELSE 2 END,\n reserved_bytes=reserved_bytes-CASE WHEN OLD.storage_state='full' THEN 8421376 ELSE 32768+OLD.archive_bytes END\n WHERE scope IN('global','owner:'||OLD.owner_id);\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll quota refund mismatch'; END IF; RETURN OLD;\n END IF;\n IF TG_OP='UPDATE' THEN\n -- This durable one-shot marker is written and ACKed in its OWN transaction\n -- before archive construction. A committed/unknown claim never resets and\n -- the worker never retries destructive work against an already claimed full\n -- source. Claim time is maintenance metadata, not renewed execution activity.\n IF OLD.storage_state='full' AND NEW.storage_state='full' AND OLD.compaction_claim IS NULL AND OLD.compaction_claimed_at IS NULL AND OLD.compaction_claim_xid IS NULL\n AND NEW.compaction_claim IS NOT NULL AND NEW.compaction_claim_xid IS NULL\n AND(to_jsonb(OLD)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])=(to_jsonb(NEW)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])\n AND public.server_poll_storage_compact_allowed(OLD.receipt_id)\n THEN NEW.compaction_claimed_at:=clock_timestamp(); NEW.compaction_claim_xid:=pg_current_xact_id(); RETURN NEW; END IF;\n IF(to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) IS DISTINCT FROM\n (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) THEN RAISE EXCEPTION 'poll admission identity is immutable'; END IF;\n IF OLD.storage_state<>'full' THEN RAISE EXCEPTION 'compacted poll identity cannot reopen or change'; END IF;\n IF NEW.storage_state='compacted' THEN\n SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND compaction_xid=pg_current_xact_id();\n IF NOT FOUND OR NEW.used_rows<>OLD.used_rows OR NEW.used_bytes<>OLD.used_bytes OR NEW.claim_token IS DISTINCT FROM OLD.claim_token\n OR NEW.claim_attempted_at IS DISTINCT FROM OLD.claim_attempted_at OR NEW.archive_bytes<>r.ciphertext_bytes OR NEW.original_activity_at<>r.original_activity_at\n OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)\n THEN RAISE EXCEPTION 'poll compaction requires the complete current-transaction archive'; END IF;\n NEW.compact_at:=r.created_at;\n UPDATE public.server_poll_storage_usage SET admissions=admissions-1,compacted_admissions=compacted_admissions+1,\n archive_bytes=archive_bytes+r.ciphertext_bytes,reserved_rows=reserved_rows-4019+2,reserved_bytes=reserved_bytes-8421376+32768+r.ciphertext_bytes\n WHERE scope IN('global','owner:'||OLD.owner_id) AND admissions>=1;\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll compaction charge mismatch'; END IF;\n RETURN NEW;\n END IF;\n IF NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL THEN RAISE EXCEPTION 'full poll cannot carry archive metadata'; END IF;\n IF OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL\n AND NEW.used_rows=OLD.used_rows AND NEW.used_bytes=OLD.used_bytes AND OLD.authority_expires_at>clock_timestamp()\n THEN NEW.claim_attempted_at:=clock_timestamp(); RETURN NEW; END IF;\n IF OLD.claim_token IS NOT DISTINCT FROM NEW.claim_token AND OLD.claim_attempted_at IS NOT DISTINCT FROM NEW.claim_attempted_at\n AND NEW.used_rows=OLD.used_rows+1 AND NEW.used_bytes>OLD.used_bytes THEN RETURN NEW; END IF;\n RAISE EXCEPTION 'poll admission cannot refresh, reopen or refund itself';\n END IF;\n IF NEW.storage_state<>'full' OR NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL\n OR NEW.compaction_claim IS NOT NULL OR NEW.compaction_claimed_at IS NOT NULL OR NEW.compaction_claim_xid IS NOT NULL\n OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'new poll requires full reservation and exact ledger'; END IF;\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1;\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 OR NEW.authority_issued_at>clock_timestamp() OR NEW.authority_expires_at<=clock_timestamp()\n OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL OR NEW.used_rows<>0 OR NEW.used_bytes<>0 THEN RAISE EXCEPTION 'new poll admission needs original live authority'; END IF;\n IF EXISTS(SELECT 1 FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id OR(identity_kind=NEW.identity_kind AND execution_id=NEW.execution_id)) THEN RAISE EXCEPTION 'poll identity already spent'; END IF;\n NEW.created_at:=clock_timestamp(); NEW.retention_days:=retention; NEW.safety_ms:=60000;\n NEW.gc_not_before:=NEW.authority_expires_at+make_interval(days=>retention)+interval '60 seconds';\n INSERT INTO public.server_poll_storage_usage(scope) VALUES('owner:'||NEW.owner_id) ON CONFLICT DO NOTHING;\n IF(SELECT count(*) FROM public.server_poll_storage_usage WHERE scope IN('global','owner:'||NEW.owner_id)\n AND admissions2 THEN RAISE EXCEPTION 'poll admission quota exhausted'; END IF;\n UPDATE public.server_poll_storage_usage SET admissions=admissions+1,reserved_rows=reserved_rows+4019,reserved_bytes=reserved_bytes+8421376 WHERE scope IN('global','owner:'||NEW.owner_id);\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll admission quota unavailable'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["TimeZone=UTC","search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_storage_admission_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_row_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE a server_poll_storage_admissions%ROWTYPE; n integer;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n SELECT * INTO a FROM server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;\n IF NOT FOUND THEN RAISE EXCEPTION 'poll journal needs a committed admission'; END IF;\n IF TG_TABLE_NAME='server_poll_quarantines' THEN\n IF NEW.identity_kind<>a.identity_kind OR NEW.execution_id<>a.execution_id OR NEW.context_proof<>a.context_proof\n THEN RAISE EXCEPTION 'poll quarantine admission mismatch'; END IF;\n ELSE\n IF a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()\n THEN RAISE EXCEPTION 'poll admission is not consumed and live'; END IF;\n END IF;\n IF TG_TABLE_NAME='server_poll_executions' THEN\n IF NEW.identity_kind<>a.identity_kind OR NEW.execution_id<>a.execution_id OR NEW.context_proof<>a.context_proof OR NEW.binding_proof<>a.binding_proof\n THEN RAISE EXCEPTION 'poll anchor admission mismatch'; END IF;\n ELSIF TG_TABLE_NAME IN('server_poll_intents','server_poll_acks') THEN\n IF NEW.stage LIKE 'publish.%' AND substring(NEW.stage FROM 9)::integer>=a.max_stages-4 THEN RAISE EXCEPTION 'poll stage exceeds private reservation'; END IF;\n IF TG_TABLE_NAME='server_poll_intents' THEN SELECT count(*) INTO n FROM server_poll_intents WHERE receipt_id=NEW.receipt_id;\n ELSE SELECT count(*) INTO n FROM server_poll_acks WHERE receipt_id=NEW.receipt_id; END IF;\n IF n>=a.max_stages THEN RAISE EXCEPTION 'poll stage row budget exhausted'; END IF;\n END IF;\n IF TG_TABLE_NAME<>'server_poll_quarantines' AND EXISTS(SELECT 1 FROM server_poll_quarantines WHERE receipt_id=NEW.receipt_id)\n THEN RAISE EXCEPTION 'poll identity quarantined'; END IF;\n NEW.created_at:=clock_timestamp();\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_poll_storage_row_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_row_meter()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE cost bigint; n integer;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n cost:=pg_column_size(NEW);\n UPDATE server_poll_storage_admissions SET used_rows=used_rows+1,used_bytes=used_bytes+cost\n WHERE receipt_id=NEW.receipt_id AND used_rows1 THEN RAISE EXCEPTION 'poll journal byte or row budget exhausted'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_poll_storage_row_meter","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_execution_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$ BEGIN\n IF TG_OP='DELETE' THEN\n IF server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'probe execution lifetime has not elapsed';\n END IF;\n IF OLD.state<>'claimed' OR (to_jsonb(OLD)-ARRAY['state','attempted_stages','completed_stages','receipt_proof','finished_at']) IS DISTINCT FROM\n (to_jsonb(NEW)-ARRAY['state','attempted_stages','completed_stages','receipt_proof','finished_at']) OR NEW.state='claimed'\n THEN RAISE EXCEPTION 'probe execution identity or terminal receipt is immutable'; END IF;\n IF EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=OLD.receipt_id)\n THEN RAISE EXCEPTION 'probe execution quarantined'; END IF;\n RETURN NEW; END $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_execution_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_quarantine_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$ BEGIN\n IF TG_OP='DELETE' AND server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'probe quarantine remains immutable'; END $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_quarantine_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_stage_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$ BEGIN\n IF TG_OP='DELETE' THEN\n IF server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'probe stage lifetime has not elapsed';\n END IF;\n PERFORM receipt_id FROM server_probe_executions WHERE receipt_id=NEW.receipt_id AND state='claimed' FOR UPDATE;\n IF NOT FOUND OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines WHERE receipt_id=NEW.receipt_id) THEN RAISE EXCEPTION 'probe attempt is not executable'; END IF;\n IF TG_OP='INSERT' AND (NEW.stage_index<>(SELECT COALESCE(max(stage_index),0)+1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id)\n OR EXISTS(SELECT 1 FROM server_probe_execution_stages WHERE receipt_id=NEW.receipt_id AND state<>'received'))\n THEN RAISE EXCEPTION 'probe stages must be serial and contiguous'; END IF;\n IF TG_OP='UPDATE' AND (OLD.state<>'intent' OR NEW.state<>'received' OR (to_jsonb(OLD)-ARRAY['state','outcome','received_at']) IS DISTINCT FROM (to_jsonb(NEW)-ARRAY['state','outcome','received_at']))\n THEN RAISE EXCEPTION 'probe stage terminal state is immutable'; END IF;\n RETURN NEW; END $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_stage_immutable","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_storage_admission_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE current_retention integer; activity timestamptz;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));\n IF TG_OP='DELETE' THEN\n IF server_probe_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'probe admission lifetime has not elapsed';\n END IF;\n SELECT requests_retention_days INTO current_retention FROM mcp_settings WHERE id=1;\n IF current_retention IS NULL OR current_retention NOT BETWEEN 1 AND 365 THEN RAISE EXCEPTION 'probe retention unavailable'; END IF;\n IF TG_OP='INSERT' THEN\n IF NEW.purged_at IS NOT NULL OR (NEW.cancelled_at IS NULL AND\n (NEW.authority_expires_at<=clock_timestamp() OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL))\n OR (NEW.cancelled_at IS NOT NULL AND (NEW.claim_token IS NOT NULL OR NEW.claim_attempted_at IS NULL))\n THEN RAISE EXCEPTION 'invalid fresh probe admission'; END IF;\n IF NEW.cancelled_at IS NOT NULL THEN NEW.cancelled_at:=clock_timestamp(); NEW.claim_attempted_at:=NEW.cancelled_at; END IF;\n NEW.retention_days:=current_retention; RETURN NEW;\n END IF;\n IF (to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','purged_at','cancelled_at']) IS DISTINCT FROM\n (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','purged_at','cancelled_at'])\n THEN RAISE EXCEPTION 'immutable probe admission identity'; END IF;\n IF OLD.cancelled_at IS DISTINCT FROM NEW.cancelled_at THEN\n IF OLD.cancelled_at IS NULL AND NEW.cancelled_at IS NOT NULL AND NEW.claim_token IS NULL\n AND NEW.purged_at IS NOT DISTINCT FROM OLD.purged_at AND NEW.claim_attempted_at IS NOT NULL\n AND (OLD.claim_attempted_at IS NULL OR NEW.claim_attempted_at IS NOT DISTINCT FROM OLD.claim_attempted_at)\n THEN NEW.cancelled_at:=clock_timestamp(); IF OLD.claim_attempted_at IS NULL THEN NEW.claim_attempted_at:=NEW.cancelled_at; END IF; RETURN NEW; END IF;\n RAISE EXCEPTION 'probe cancellation is irreversible';\n END IF;\n IF OLD.purged_at IS NULL AND NEW.purged_at IS NULL AND OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL\n AND OLD.cancelled_at IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL AND OLD.authority_expires_at>clock_timestamp()\n THEN RETURN NEW; END IF;\n IF OLD.purged_at IS NULL AND NEW.purged_at IS NOT NULL AND NEW.claim_token IS NULL\n AND NEW.claim_attempted_at IS NOT DISTINCT FROM OLD.claim_attempted_at THEN\n SELECT GREATEST(OLD.authority_expires_at,COALESCE(e.finished_at,OLD.authority_expires_at),COALESCE(q.created_at,OLD.authority_expires_at)) INTO activity\n FROM (SELECT 1) x LEFT JOIN server_probe_executions e ON e.receipt_id=OLD.receipt_id\n LEFT JOIN server_probe_execution_quarantines q ON q.receipt_id=OLD.receipt_id;\n IF activityGREATEST(OLD.retention_days,current_retention)) THEN RETURN NEW; END IF;\n END IF;\n RAISE EXCEPTION 'probe admission transition refused';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_storage_admission_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_storage_anchor_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE a server_probe_storage_admissions%ROWTYPE;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));\n SELECT * INTO a FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;\n IF NOT FOUND OR a.owner_id<>NEW.actor_id OR a.identity_kind<>NEW.identity_kind OR a.execution_id<>NEW.execution_id\n OR a.binding_proof<>NEW.binding_proof OR a.authority_expires_at<>NEW.authority_expires_at\n OR a.purged_at IS NOT NULL OR a.cancelled_at IS NOT NULL OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()\n THEN RAISE EXCEPTION 'probe anchor has no live consumed admission'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_storage_anchor_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_storage_payload_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\nDECLARE a server_probe_storage_admissions%ROWTYPE; e server_probe_executions%ROWTYPE;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));\n IF TG_OP='UPDATE' THEN RAISE EXCEPTION 'probe payload is immutable'; END IF;\n IF TG_OP='DELETE' THEN\n PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=OLD.receipt_id AND purged_at IS NOT NULL FOR UPDATE;\n IF NOT FOUND AND NOT server_probe_storage_gc_allowed(OLD.receipt_id) THEN RAISE EXCEPTION 'probe payload is not purged'; END IF;\n RETURN OLD;\n END IF;\n SELECT * INTO a FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id FOR UPDATE;\n IF NOT FOUND OR a.purged_at IS NOT NULL OR a.cancelled_at IS NOT NULL OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL OR a.authority_expires_at<=clock_timestamp()\n THEN RAISE EXCEPTION 'probe payload has no live admission'; END IF;\n SELECT * INTO e FROM server_probe_executions WHERE receipt_id=NEW.receipt_id FOR UPDATE;\n IF NOT FOUND OR e.state='claimed' OR e.receipt_proof<>NEW.receipt_proof OR e.actor_id<>a.owner_id OR e.binding_proof<>a.binding_proof\n OR e.identity_kind<>a.identity_kind OR e.execution_id<>a.execution_id OR EXISTS(SELECT 1 FROM server_probe_execution_quarantines q\n WHERE q.receipt_id=NEW.receipt_id OR(q.identity_kind=a.identity_kind AND q.execution_id=a.execution_id))\n THEN RAISE EXCEPTION 'probe payload terminal identity mismatch or quarantine'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_storage_payload_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_storage_quarantine_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$ BEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));\n PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id AND identity_kind=NEW.identity_kind\n AND execution_id=NEW.execution_id AND binding_proof=NEW.binding_proof FOR UPDATE;\n IF NOT FOUND THEN RAISE EXCEPTION 'probe quarantine has no committed matching admission'; END IF;\n RETURN NEW; END $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_storage_quarantine_guard","prosecdef":false},{"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_storage_stage_guard()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$ BEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-probe-storage-v2',0));\n PERFORM receipt_id FROM server_probe_storage_admissions WHERE receipt_id=NEW.receipt_id AND purged_at IS NULL AND cancelled_at IS NULL\n AND claim_token IS NULL AND claim_attempted_at IS NOT NULL AND authority_expires_at>clock_timestamp() FOR UPDATE;\n IF NOT FOUND THEN RAISE EXCEPTION 'probe stage has no live admission'; END IF;\n RETURN NEW; END $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"server_probe_storage_stage_guard","prosecdef":false},{"acl":null,"arguments":"id uuid","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_compact_allowed(id uuid)\n RETURNS boolean\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE a public.server_poll_storage_admissions%ROWTYPE; o public.mcp_operations%ROWTYPE; p public.mcp_plans%ROWTYPE; s public.mcp_operation_steps%ROWTYPE; n integer; pubs integer; activity timestamptz;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;\n IF NOT FOUND OR a.storage_state<>'full' OR a.identity_kind<>'mcp' OR a.claim_token IS NOT NULL OR a.claim_attempted_at IS NULL\n OR a.authority_expires_at+a.safety_ms*interval '1 millisecond'>=clock_timestamp()\n OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=id OR(identity_kind=a.identity_kind AND execution_id=a.execution_id))\n THEN RETURN false; END IF;\n IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;\n IF NOT pg_try_advisory_xact_lock(hashtextextended('server-poll-execution-v1:mcp:'||a.execution_id::text,0)) THEN RETURN false; END IF;\n IF NOT pg_try_advisory_xact_lock(hashtextextended('server-poll-receipt-v1:'||a.receipt_id::text,0)) THEN RETURN false; END IF;\n BEGIN\n SELECT * INTO o FROM public.mcp_operations WHERE mcp_operations.id=a.execution_id AND connection_id=a.connection_id FOR UPDATE NOWAIT;\n IF NOT FOUND OR o.state<>'applied' OR o.verification<>'passed' OR o.error_code IS NOT NULL OR o.finished_at IS NULL THEN RETURN false; END IF;\n SELECT * INTO p FROM public.mcp_plans WHERE mcp_plans.id=o.plan_id AND connection_id=a.connection_id FOR UPDATE NOWAIT;\n IF NOT FOUND OR p.operation_id<>'servers.poll' OR p.operation_version<>1 OR p.state<>'completed' OR p.approved_by IS NULL OR p.approved_at IS NULL\n OR p.created_at>p.approved_at OR p.approved_at>o.created_at OR o.created_at>=LEAST(p.expires_at,a.authority_expires_at) THEN RETURN false; END IF;\n SELECT * INTO s FROM public.mcp_operation_steps WHERE operation_id=o.id AND step_index=0 FOR UPDATE NOWAIT;\n IF NOT FOUND OR s.state<>'verified' OR s.server_id IS NOT NULL OR s.result IS NULL OR s.finished_at IS NULL\n OR(SELECT count(*) FROM public.mcp_operation_steps WHERE operation_id=o.id)<>1\n OR NOT EXISTS(SELECT 1 FROM public.mcp_connections c WHERE c.id=a.connection_id AND c.owner_id=a.owner_id)\n OR s.intended_state->>'kind' IS DISTINCT FROM 'service' OR s.intended_state->>'service' IS DISTINCT FROM 'servers.poll'\n OR s.intended_state#>>'{input,receiptId}' IS DISTINCT FROM id::text\n OR s.result->>'operationId' IS DISTINCT FROM o.id::text OR s.result->>'receiptId' IS DISTINCT FROM id::text\n OR s.result->'nativeReads' IS DISTINCT FROM '4'::jsonb\n OR s.result->'complete' IS DISTINCT FROM 'true'::jsonb OR s.result->'maintenanceComplete' IS DISTINCT FROM 'true'::jsonb\n OR s.result->'configurationVerified' IS DISTINCT FROM 'true'::jsonb OR s.result->'automaticReplay' IS DISTINCT FROM 'false'::jsonb\n THEN RETURN false; END IF;\n EXCEPTION WHEN lock_not_available THEN RETURN false; END;\n IF NOT EXISTS(SELECT 1 FROM public.server_poll_executions e WHERE e.receipt_id=id AND e.identity_kind=a.identity_kind AND e.execution_id=a.execution_id AND e.binding_proof=a.binding_proof AND e.context_proof=a.context_proof)\n OR NOT EXISTS(SELECT 1 FROM public.server_poll_receipts r WHERE r.receipt_id=id AND r.created_atpubs+4 OR pubs NOT IN(a.max_stages-6,a.max_stages-4) OR a.used_rows<>2*n+2\n OR(SELECT count(*) FROM public.server_poll_acks WHERE receipt_id=id)<>n\n OR s.result->'confirmedPublications' IS DISTINCT FROM to_jsonb(pubs)\n OR s.result->'completedPublications' IS DISTINCT FROM to_jsonb(pubs)\n OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=id AND outcome<>'confirmed')\n OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=id AND created_at>=a.authority_expires_at)\n OR EXISTS(SELECT 1 FROM unnest(ARRAY['native.identity','native.resource','native.interfaces','native.addresses']) wanted(stage)\n WHERE NOT EXISTS(SELECT 1 FROM public.server_poll_intents i JOIN public.server_poll_acks k USING(receipt_id,stage) WHERE i.receipt_id=id AND i.stage=wanted.stage AND k.outcome='confirmed'))\n OR EXISTS(SELECT 1 FROM generate_series(0,pubs-1) wanted(stage) WHERE NOT EXISTS(SELECT 1 FROM public.server_poll_intents i JOIN public.server_poll_acks k USING(receipt_id,stage) WHERE i.receipt_id=id AND i.stage='publish.'||wanted.stage::text AND k.outcome='confirmed'))\n THEN RETURN false; END IF;\n SELECT GREATEST(a.authority_expires_at,a.created_at,a.claim_attempted_at,o.finished_at,p.expires_at,s.finished_at,\n (SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),(SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),\n (SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),(SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id)) INTO activity;\n RETURN isfinite(activity) AND activity+a.safety_ms*interval '1 millisecond'=clock_timestamp() OR a.gc_not_before>=clock_timestamp() THEN RETURN false; END IF;\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE mcp_settings.id=1 FOR SHARE;\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;\n terminal_at:=a.created_at;\n IF a.identity_kind='mcp' THEN\n IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;\n BEGIN\n SELECT GREATEST(o.finished_at,p.expires_at) INTO terminal_at FROM public.mcp_operations o\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id JOIN public.mcp_connections c ON c.id=o.connection_id\n WHERE o.id=a.execution_id AND o.connection_id=a.connection_id AND c.owner_id=a.owner_id AND p.operation_id='servers.poll'\n AND o.state IN('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL FOR UPDATE OF o,p NOWAIT;\n IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;\n EXCEPTION WHEN lock_not_available THEN RETURN false; END;\n END IF;\n IF a.storage_state='compacted' THEN activity:=GREATEST(a.original_activity_at,a.authority_expires_at,terminal_at);\n ELSE\n SELECT GREATEST(a.authority_expires_at,a.created_at,COALESCE(a.claim_attempted_at,a.created_at),terminal_at,\n COALESCE((SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM public.server_poll_quarantines WHERE receipt_id=id),a.created_at)) INTO activity;\n END IF;\n RETURN isfinite(activity) AND activity+make_interval(days=>GREATEST(a.retention_days,retention))+a.safety_ms*interval '1 millisecond'=clock_timestamp() OR a.authority_expires_at>=clock_timestamp() THEN RETURN false; END IF;\n SELECT settings.requests_retention_days INTO current_retention FROM mcp_settings settings WHERE settings.id=1;\n IF current_retention IS NULL OR current_retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;\n terminal_at:=a.created_at;\n IF a.identity_kind='mcp' THEN\n SELECT GREATEST(o.finished_at,p.expires_at,COALESCE(cancellation.created_at,o.finished_at)) INTO terminal_at\n FROM mcp_operations o JOIN mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN mcp_connections owner_connection ON owner_connection.id=o.connection_id\n LEFT JOIN mcp_diagnostic_cancellations cancellation ON cancellation.operation_id=o.id\n WHERE o.id=a.execution_id AND owner_connection.owner_id=a.owner_id AND p.operation_id='servers.probes.run'\n AND o.state IN ('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL\n AND (cancellation.operation_id IS NULL OR(cancellation.connection_id=o.connection_id AND cancellation.actor_id=a.owner_id))\n FOR UPDATE OF o,p,owner_connection;\n IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;\n END IF;\n SELECT GREATEST(a.created_at,a.authority_expires_at,terminal_at,COALESCE(a.cancelled_at,a.created_at),\n COALESCE((SELECT finished_at FROM server_probe_executions WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM server_probe_execution_quarantines WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(GREATEST(created_at,COALESCE(received_at,created_at))) FROM server_probe_execution_stages WHERE receipt_id=id),a.created_at)) INTO activity;\n RETURN activity+make_interval(days=>GREATEST(a.retention_days,current_retention))+a.safety_ms*interval '1 millisecond'16777216 THEN RETURN NULL; END IF;\n RETURN payload;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["TimeZone=UTC","search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_storage_source_payload","prosecdef":false}],"identities":[{"attidentity":"a","attname":"id","column_number":1,"relname":"mcp_audit","sequence_name":"public.mcp_audit_id_seq"},{"attidentity":"a","attname":"id","column_number":1,"relname":"router_log_entries","sequence_name":"public.router_log_entries_id_seq"},{"attidentity":"d","attname":"id","column_number":1,"relname":"filter_rules","sequence_name":"public.filter_rules_id_seq"},{"attidentity":"d","attname":"id","column_number":1,"relname":"internet_path_snapshots","sequence_name":"public.internet_path_snapshots_id_seq"},{"attidentity":"d","attname":"id","column_number":1,"relname":"recursive_routes","sequence_name":"public.recursive_routes_id_seq"},{"attidentity":"d","attname":"id","column_number":1,"relname":"server_snapshots","sequence_name":"public.server_snapshots_id_seq"},{"attidentity":"d","attname":"id","column_number":1,"relname":"servers","sequence_name":"public.servers_id_seq"}],"indexes":[{"definition":"CREATE INDEX idx_alert_history_fired_at ON public.alert_history USING btree (fired_at)","index_name":"idx_alert_history_fired_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_history"},{"definition":"CREATE INDEX idx_alert_history_rule_id ON public.alert_history USING btree (rule_id)","index_name":"idx_alert_history_rule_id","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_history"},{"definition":"CREATE INDEX idx_alert_outbox_pending_next ON public.alert_outbox USING btree (next_attempt_at) WHERE (status = 'pending'::text)","index_name":"idx_alert_outbox_pending_next","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_outbox"},{"definition":"CREATE INDEX idx_alert_outbox_status_next_attempt ON public.alert_outbox USING btree (status, next_attempt_at)","index_name":"idx_alert_outbox_status_next_attempt","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_outbox"},{"definition":"CREATE INDEX idx_alert_rule_conditions_rule ON public.alert_rule_conditions USING btree (rule_id)","index_name":"idx_alert_rule_conditions_rule","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_rule_conditions"},{"definition":"CREATE INDEX idx_alert_rule_targets_rule ON public.alert_rule_targets USING btree (rule_id)","index_name":"idx_alert_rule_targets_rule","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"alert_rule_targets"},{"definition":"CREATE INDEX idx_backup_entries_server_created ON public.backup_entries USING btree (server_id, created_at)","index_name":"idx_backup_entries_server_created","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"backup_entries"},{"definition":"CREATE INDEX idx_config_revisions_server_section_created ON public.config_revisions USING btree (server_id, section, created_at DESC)","index_name":"idx_config_revisions_server_section_created","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"config_revisions"},{"definition":"CREATE INDEX idx_events_created_at ON public.events USING btree (created_at DESC)","index_name":"idx_events_created_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"events"},{"definition":"CREATE INDEX idx_events_event_type_created_at ON public.events USING btree (event_type, created_at DESC)","index_name":"idx_events_event_type_created_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"events"},{"definition":"CREATE INDEX idx_events_level_created_at ON public.events USING btree (level, created_at DESC)","index_name":"idx_events_level_created_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"events"},{"definition":"CREATE INDEX idx_events_source_created_at ON public.events USING btree (source_module, created_at DESC)","index_name":"idx_events_source_created_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"events"},{"definition":"CREATE INDEX idx_filter_rules_server_sort ON public.filter_rules USING btree (server_id, sort_order)","index_name":"idx_filter_rules_server_sort","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"filter_rules"},{"definition":"CREATE INDEX idx_flow_buckets_server_time ON ONLY public.flow_buckets USING btree (server_id, bucket_at)","index_name":"idx_flow_buckets_server_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"flow_buckets"},{"definition":"CREATE INDEX idx_flow_daily_dims_day ON ONLY public.flow_daily_dims USING btree (day, dim)","index_name":"idx_flow_daily_dims_day","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"flow_daily_dims"},{"definition":"CREATE INDEX idx_flow_minute_dims_time ON ONLY public.flow_minute_dims USING btree (bucket_at, dim)","index_name":"idx_flow_minute_dims_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"flow_minute_dims"},{"definition":"CREATE INDEX idx_internet_path_snapshots_sampled ON ONLY public.internet_path_snapshots USING btree (sampled_at)","index_name":"idx_internet_path_snapshots_sampled","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"internet_path_snapshots"},{"definition":"CREATE INDEX idx_recursive_routes_server_sort ON public.recursive_routes USING btree (server_id, sort_order)","index_name":"idx_recursive_routes_server_sort","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"recursive_routes"},{"definition":"CREATE INDEX idx_scheduler_runs_finished_at ON public.scheduler_runs USING btree (finished_at)","index_name":"idx_scheduler_runs_finished_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"scheduler_runs"},{"definition":"CREATE INDEX idx_scheduler_runs_job_time ON public.scheduler_runs USING btree (job_key, started_at)","index_name":"idx_scheduler_runs_job_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"scheduler_runs"},{"definition":"CREATE INDEX idx_server_snapshots_server_time ON ONLY public.server_snapshots USING btree (server_id, polled_at)","index_name":"idx_server_snapshots_server_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"server_snapshots"},{"definition":"CREATE INDEX idx_traffic_samples_server_iface_time ON ONLY public.traffic_samples USING btree (server_id, interface_name, sampled_at)","index_name":"idx_traffic_samples_server_iface_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"traffic_samples"},{"definition":"CREATE INDEX idx_uptime_probes_server_sort ON public.uptime_probes USING btree (src_server_id, sort_order)","index_name":"idx_uptime_probes_server_sort","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"uptime_probes"},{"definition":"CREATE INDEX idx_uptime_speed_probes_src_sort ON public.uptime_speed_probes USING btree (src_server_id, sort_order)","index_name":"idx_uptime_speed_probes_src_sort","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"uptime_speed_probes"},{"definition":"CREATE INDEX idx_uptime_speed_test_runs_created_at ON public.uptime_speed_test_runs USING btree (created_at)","index_name":"idx_uptime_speed_test_runs_created_at","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"uptime_speed_test_runs"},{"definition":"CREATE INDEX idx_user_iface_bind_user ON public.user_interface_bindings USING btree (user_id)","index_name":"idx_user_iface_bind_user","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"user_interface_bindings"},{"definition":"CREATE INDEX mcp_artifacts_expiry ON public.mcp_artifacts USING btree (expires_at)","index_name":"mcp_artifacts_expiry","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_artifacts"},{"definition":"CREATE INDEX mcp_audit_handshake_cooldown ON public.mcp_audit USING btree (connection_id, created_at DESC) WHERE (action = 'connection.handshake.start'::text)","index_name":"mcp_audit_handshake_cooldown","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_audit"},{"definition":"CREATE INDEX mcp_audit_time ON public.mcp_audit USING btree (created_at, id)","index_name":"mcp_audit_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_audit"},{"definition":"CREATE INDEX mcp_credentials_connection ON public.mcp_credentials USING btree (connection_id)","index_name":"mcp_credentials_connection","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_credentials"},{"definition":"CREATE INDEX mcp_credentials_readiness_expired ON public.mcp_credentials USING btree (connection_id, expires_at) WHERE (client_id = 'mcp-readiness-probe'::text)","index_name":"mcp_credentials_readiness_expired","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_credentials"},{"definition":"CREATE INDEX mcp_grants_credential ON public.mcp_grants USING btree (connection_id, ((payload ->> 'credentialId'::text)))","index_name":"mcp_grants_credential","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_grants"},{"definition":"CREATE INDEX mcp_path_checks_latest ON public.mcp_path_checks USING btree (connection_id, profile_hash, candidate_id, created_at DESC)","index_name":"mcp_path_checks_latest","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_path_checks"},{"definition":"CREATE INDEX mcp_plans_connection ON public.mcp_plans USING btree (connection_id, created_at)","index_name":"mcp_plans_connection","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_plans"},{"definition":"CREATE INDEX mcp_portal_events_time ON public.mcp_portal_events USING btree (created_at)","index_name":"mcp_portal_events_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_portal_events"},{"definition":"CREATE INDEX mcp_requests_connection_time ON public.mcp_requests USING btree (connection_id, created_at, id)","index_name":"mcp_requests_connection_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_requests"},{"definition":"CREATE INDEX mcp_requests_server ON public.mcp_requests USING gin (server_ids)","index_name":"mcp_requests_server","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_requests"},{"definition":"CREATE INDEX mcp_routing_forward_charges_retention ON public.mcp_routing_forward_charges USING btree (created_at, source_operation_id)","index_name":"mcp_routing_forward_charges_retention","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_forward_charges"},{"definition":"CREATE INDEX mcp_routing_forward_charges_window ON public.mcp_routing_forward_charges USING btree (profile_id, created_at)","index_name":"mcp_routing_forward_charges_window","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_forward_charges"},{"definition":"CREATE INDEX mcp_routing_manual_inverse_charges_retention ON public.mcp_routing_manual_inverse_charges USING btree (created_at, recovery_operation_id)","index_name":"mcp_routing_manual_inverse_charges_retention","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_manual_inverse_charges"},{"definition":"CREATE INDEX mcp_routing_manual_inverse_charges_window ON public.mcp_routing_manual_inverse_charges USING btree (profile_id, created_at)","index_name":"mcp_routing_manual_inverse_charges_window","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_manual_inverse_charges"},{"definition":"CREATE INDEX mcp_routing_observations_leg ON public.mcp_routing_observations USING btree (src_server_id, dst_server_id, src_interface, family, routing_table, created_at DESC)","index_name":"mcp_routing_observations_leg","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_observations"},{"definition":"CREATE INDEX mcp_routing_profiles_enabled ON public.mcp_routing_profiles USING btree (updated_at) WHERE enabled","index_name":"mcp_routing_profiles_enabled","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_profiles"},{"definition":"CREATE INDEX mcp_routing_reservation_slots_window ON public.mcp_routing_reservation_slots USING btree (profile_id, created_at)","index_name":"mcp_routing_reservation_slots_window","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_routing_reservation_slots"},{"definition":"CREATE INDEX mcp_scoped_recovery_manual_history ON public.mcp_scoped_recovery_intents USING btree (mode, source_operation_id, source_step_index) WHERE (mode = 'manual'::text)","index_name":"mcp_scoped_recovery_manual_history","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"mcp_scoped_recovery_intents"},{"definition":"CREATE INDEX router_logs_level_time ON public.router_log_entries USING btree (level, effective_at DESC)","index_name":"router_logs_level_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX router_logs_received ON public.router_log_entries USING btree (received_at)","index_name":"router_logs_received","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX router_logs_server_cursor ON public.router_log_entries USING btree (server_id, id)","index_name":"router_logs_server_cursor","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX router_logs_server_time ON public.router_log_entries USING btree (server_id, effective_at DESC, id DESC)","index_name":"router_logs_server_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX router_logs_time ON public.router_log_entries USING btree (effective_at DESC, id DESC)","index_name":"router_logs_time","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX router_logs_topics ON public.router_log_entries USING gin (topics)","index_name":"router_logs_topics","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE INDEX server_poll_storage_expiry ON public.server_poll_storage_admissions USING btree (gc_not_before, receipt_id)","index_name":"server_poll_storage_expiry","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"server_poll_storage_admissions"},{"definition":"CREATE INDEX server_probe_storage_admissions_owner_age ON public.server_probe_storage_admissions USING btree (owner_id, authority_expires_at, receipt_id)","index_name":"server_probe_storage_admissions_owner_age","indisprimary":false,"indisready":true,"indisunique":false,"indisvalid":true,"relname":"server_probe_storage_admissions"},{"definition":"CREATE UNIQUE INDEX acme_settings_pkey ON public.acme_settings USING btree (id)","index_name":"acme_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"acme_settings"},{"definition":"CREATE UNIQUE INDEX alert_engine_confirm_pending_pkey ON public.alert_engine_confirm_pending USING btree (rule_id)","index_name":"alert_engine_confirm_pending_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_engine_confirm_pending"},{"definition":"CREATE UNIQUE INDEX alert_engine_cursor_pkey ON public.alert_engine_cursor USING btree (id)","index_name":"alert_engine_cursor_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_engine_cursor"},{"definition":"CREATE UNIQUE INDEX alert_engine_prev_live_pkey ON public.alert_engine_prev_live USING btree (kind)","index_name":"alert_engine_prev_live_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_engine_prev_live"},{"definition":"CREATE UNIQUE INDEX alert_engine_state_pkey ON public.alert_engine_state USING btree (scope_key)","index_name":"alert_engine_state_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_engine_state"},{"definition":"CREATE UNIQUE INDEX alert_groups_pkey ON public.alert_groups USING btree (id)","index_name":"alert_groups_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_groups"},{"definition":"CREATE UNIQUE INDEX alert_history_pkey ON public.alert_history USING btree (id)","index_name":"alert_history_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_history"},{"definition":"CREATE UNIQUE INDEX alert_outbox_pkey ON public.alert_outbox USING btree (id)","index_name":"alert_outbox_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_outbox"},{"definition":"CREATE UNIQUE INDEX alert_rule_conditions_pkey ON public.alert_rule_conditions USING btree (id)","index_name":"alert_rule_conditions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_rule_conditions"},{"definition":"CREATE UNIQUE INDEX alert_rule_targets_pkey ON public.alert_rule_targets USING btree (id)","index_name":"alert_rule_targets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_rule_targets"},{"definition":"CREATE UNIQUE INDEX alert_rules_pkey ON public.alert_rules USING btree (id)","index_name":"alert_rules_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_rules"},{"definition":"CREATE UNIQUE INDEX alert_telegram_settings_pkey ON public.alert_telegram_settings USING btree (id)","index_name":"alert_telegram_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_telegram_settings"},{"definition":"CREATE UNIQUE INDEX app_users_login_key ON public.app_users USING btree (login)","index_name":"app_users_login_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"app_users"},{"definition":"CREATE UNIQUE INDEX app_users_pkey ON public.app_users USING btree (id)","index_name":"app_users_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"app_users"},{"definition":"CREATE UNIQUE INDEX backup_entries_pkey ON public.backup_entries USING btree (id)","index_name":"backup_entries_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"backup_entries"},{"definition":"CREATE UNIQUE INDEX backup_schedule_settings_pkey ON public.backup_schedule_settings USING btree (id)","index_name":"backup_schedule_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"backup_schedule_settings"},{"definition":"CREATE UNIQUE INDEX backup_storage_settings_pkey ON public.backup_storage_settings USING btree (id)","index_name":"backup_storage_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"backup_storage_settings"},{"definition":"CREATE UNIQUE INDEX certificate_issue_jobs_pkey ON public.certificate_issue_jobs USING btree (id)","index_name":"certificate_issue_jobs_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"certificate_issue_jobs"},{"definition":"CREATE UNIQUE INDEX certificate_renew_settings_pkey ON public.certificate_renew_settings USING btree (id)","index_name":"certificate_renew_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"certificate_renew_settings"},{"definition":"CREATE UNIQUE INDEX config_revisions_pkey ON public.config_revisions USING btree (id)","index_name":"config_revisions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"config_revisions"},{"definition":"CREATE UNIQUE INDEX data_migration_pkey ON public.data_migration USING btree (id)","index_name":"data_migration_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"data_migration"},{"definition":"CREATE UNIQUE INDEX events_pkey ON public.events USING btree (id)","index_name":"events_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"events"},{"definition":"CREATE UNIQUE INDEX evobgp_settings_pkey ON public.evobgp_settings USING btree (id)","index_name":"evobgp_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"evobgp_settings"},{"definition":"CREATE UNIQUE INDEX filter_rules_pkey ON public.filter_rules USING btree (id)","index_name":"filter_rules_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"filter_rules"},{"definition":"CREATE UNIQUE INDEX flow_asn_meta_pkey ON public.flow_asn_meta USING btree (asn)","index_name":"flow_asn_meta_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_asn_meta"},{"definition":"CREATE UNIQUE INDEX flow_buckets_pkey ON ONLY public.flow_buckets USING btree (server_id, bucket_at, src, dst, proto, src_port, dst_port, in_iface)","index_name":"flow_buckets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_buckets"},{"definition":"CREATE UNIQUE INDEX flow_daily_dims_pkey ON ONLY public.flow_daily_dims USING btree (server_id, day, dim, key)","index_name":"flow_daily_dims_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_daily_dims"},{"definition":"CREATE UNIQUE INDEX flow_daily_facts_pkey ON ONLY public.flow_daily_facts USING btree (server_id, day, iface, country, service, asn)","index_name":"flow_daily_facts_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_daily_facts"},{"definition":"CREATE UNIQUE INDEX flow_hour_facts_pkey ON ONLY public.flow_hour_facts USING btree (server_id, bucket_at, iface, country, service, asn)","index_name":"flow_hour_facts_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_hour_facts"},{"definition":"CREATE UNIQUE INDEX flow_ip_meta_pkey ON public.flow_ip_meta USING btree (prefix)","index_name":"flow_ip_meta_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_ip_meta"},{"definition":"CREATE UNIQUE INDEX flow_minute_dims_pkey ON ONLY public.flow_minute_dims USING btree (server_id, bucket_at, dim, key)","index_name":"flow_minute_dims_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_minute_dims"},{"definition":"CREATE UNIQUE INDEX flow_minute_stats_pkey ON ONLY public.flow_minute_stats USING btree (server_id, bucket_at)","index_name":"flow_minute_stats_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_minute_stats"},{"definition":"CREATE UNIQUE INDEX flow_settings_intents_pkey ON public.flow_settings_intents USING btree (receipt_id, phase)","index_name":"flow_settings_intents_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_settings_intents"},{"definition":"CREATE UNIQUE INDEX flow_write_receipts_pkey ON public.flow_write_receipts USING btree (batch_id)","index_name":"flow_write_receipts_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"flow_write_receipts"},{"definition":"CREATE UNIQUE INDEX geoip_settings_pkey ON public.geoip_settings USING btree (id)","index_name":"geoip_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"geoip_settings"},{"definition":"CREATE UNIQUE INDEX idx_alert_outbox_dedupe ON public.alert_outbox USING btree (dedupe_key)","index_name":"idx_alert_outbox_dedupe","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"alert_outbox"},{"definition":"CREATE UNIQUE INDEX idx_backup_entries_filename ON public.backup_entries USING btree (filename)","index_name":"idx_backup_entries_filename","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"backup_entries"},{"definition":"CREATE UNIQUE INDEX internet_path_settings_pkey ON public.internet_path_settings USING btree (id)","index_name":"internet_path_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"internet_path_settings"},{"definition":"CREATE UNIQUE INDEX internet_path_snapshots_pkey ON ONLY public.internet_path_snapshots USING btree (id, sampled_at)","index_name":"internet_path_snapshots_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"internet_path_snapshots"},{"definition":"CREATE UNIQUE INDEX mcp_artifacts_pkey ON public.mcp_artifacts USING btree (id)","index_name":"mcp_artifacts_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_artifacts"},{"definition":"CREATE UNIQUE INDEX mcp_audit_pkey ON public.mcp_audit USING btree (id)","index_name":"mcp_audit_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_audit"},{"definition":"CREATE UNIQUE INDEX mcp_budget_buckets_pkey ON public.mcp_budget_buckets USING btree (connection_id, kind, bucket)","index_name":"mcp_budget_buckets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_budget_buckets"},{"definition":"CREATE UNIQUE INDEX mcp_connections_pkey ON public.mcp_connections USING btree (id)","index_name":"mcp_connections_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_connections"},{"definition":"CREATE UNIQUE INDEX mcp_credentials_digest_key ON public.mcp_credentials USING btree (digest)","index_name":"mcp_credentials_digest_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_credentials"},{"definition":"CREATE UNIQUE INDEX mcp_credentials_pkey ON public.mcp_credentials USING btree (id)","index_name":"mcp_credentials_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_credentials"},{"definition":"CREATE UNIQUE INDEX mcp_diagnostic_cancellations_pkey ON public.mcp_diagnostic_cancellations USING btree (operation_id)","index_name":"mcp_diagnostic_cancellations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_diagnostic_cancellations"},{"definition":"CREATE UNIQUE INDEX mcp_drift_open_step ON public.mcp_drift USING btree (operation_id, ((expected ->> 'stepIndex'::text))) WHERE (acknowledged_at IS NULL)","index_name":"mcp_drift_open_step","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_drift"},{"definition":"CREATE UNIQUE INDEX mcp_drift_pkey ON public.mcp_drift USING btree (id)","index_name":"mcp_drift_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_drift"},{"definition":"CREATE UNIQUE INDEX mcp_grants_pkey ON public.mcp_grants USING btree (id)","index_name":"mcp_grants_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_grants"},{"definition":"CREATE UNIQUE INDEX mcp_management_channels_pkey ON public.mcp_management_channels USING btree (id)","index_name":"mcp_management_channels_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_management_channels"},{"definition":"CREATE UNIQUE INDEX mcp_management_channels_server_id_key ON public.mcp_management_channels USING btree (server_id)","index_name":"mcp_management_channels_server_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_management_channels"},{"definition":"CREATE UNIQUE INDEX mcp_manual_inverse_source_step_unique ON public.mcp_routing_manual_inverse_charges USING btree (source_operation_id, source_step_index)","index_name":"mcp_manual_inverse_source_step_unique","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_manual_inverse_charges"},{"definition":"CREATE UNIQUE INDEX mcp_oauth_clients_pkey ON public.mcp_oauth_clients USING btree (id)","index_name":"mcp_oauth_clients_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_oauth_clients"},{"definition":"CREATE UNIQUE INDEX mcp_oauth_requests_code_digest_key ON public.mcp_oauth_requests USING btree (code_digest)","index_name":"mcp_oauth_requests_code_digest_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_oauth_requests"},{"definition":"CREATE UNIQUE INDEX mcp_oauth_requests_pkey ON public.mcp_oauth_requests USING btree (id)","index_name":"mcp_oauth_requests_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_oauth_requests"},{"definition":"CREATE UNIQUE INDEX mcp_operation_checkpoints_pkey ON public.mcp_operation_checkpoints USING btree (operation_id, step_index)","index_name":"mcp_operation_checkpoints_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_operation_checkpoints"},{"definition":"CREATE UNIQUE INDEX mcp_operation_steps_pkey ON public.mcp_operation_steps USING btree (operation_id, step_index)","index_name":"mcp_operation_steps_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_operation_steps"},{"definition":"CREATE UNIQUE INDEX mcp_operations_connection_id_idempotency_key_key ON public.mcp_operations USING btree (connection_id, idempotency_key)","index_name":"mcp_operations_connection_id_idempotency_key_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_operations"},{"definition":"CREATE UNIQUE INDEX mcp_operations_pkey ON public.mcp_operations USING btree (id)","index_name":"mcp_operations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_operations"},{"definition":"CREATE UNIQUE INDEX mcp_operations_plan_id_key ON public.mcp_operations USING btree (plan_id)","index_name":"mcp_operations_plan_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_operations"},{"definition":"CREATE UNIQUE INDEX mcp_owner_revocations_pkey ON public.mcp_owner_revocations USING btree (owner_id)","index_name":"mcp_owner_revocations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_owner_revocations"},{"definition":"CREATE UNIQUE INDEX mcp_path_checks_pkey ON public.mcp_path_checks USING btree (id)","index_name":"mcp_path_checks_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_path_checks"},{"definition":"CREATE UNIQUE INDEX mcp_plans_pkey ON public.mcp_plans USING btree (id)","index_name":"mcp_plans_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_plans"},{"definition":"CREATE UNIQUE INDEX mcp_portal_events_pkey ON public.mcp_portal_events USING btree (id)","index_name":"mcp_portal_events_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_portal_events"},{"definition":"CREATE UNIQUE INDEX mcp_protections_pkey ON public.mcp_protections USING btree (id)","index_name":"mcp_protections_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_protections"},{"definition":"CREATE UNIQUE INDEX mcp_read_leases_pkey ON public.mcp_read_leases USING btree (id)","index_name":"mcp_read_leases_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_read_leases"},{"definition":"CREATE UNIQUE INDEX mcp_recovery_intents_pkey ON public.mcp_recovery_intents USING btree (operation_id)","index_name":"mcp_recovery_intents_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_recovery_intents"},{"definition":"CREATE UNIQUE INDEX mcp_requests_pkey ON public.mcp_requests USING btree (id)","index_name":"mcp_requests_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_requests"},{"definition":"CREATE UNIQUE INDEX mcp_routing_forward_charges_pkey ON public.mcp_routing_forward_charges USING btree (source_operation_id)","index_name":"mcp_routing_forward_charges_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_forward_charges"},{"definition":"CREATE UNIQUE INDEX mcp_routing_manual_inverse_charges_pkey ON public.mcp_routing_manual_inverse_charges USING btree (recovery_operation_id)","index_name":"mcp_routing_manual_inverse_charges_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_manual_inverse_charges"},{"definition":"CREATE UNIQUE INDEX mcp_routing_observations_pkey ON public.mcp_routing_observations USING btree (id)","index_name":"mcp_routing_observations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_observations"},{"definition":"CREATE UNIQUE INDEX mcp_routing_profiles_pkey ON public.mcp_routing_profiles USING btree (id)","index_name":"mcp_routing_profiles_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_profiles"},{"definition":"CREATE UNIQUE INDEX mcp_routing_reservation_slots_pkey ON public.mcp_routing_reservation_slots USING btree (reservation_id, lane)","index_name":"mcp_routing_reservation_slots_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_reservation_slots"},{"definition":"CREATE UNIQUE INDEX mcp_routing_reservations_pkey ON public.mcp_routing_reservations USING btree (id)","index_name":"mcp_routing_reservations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_reservations"},{"definition":"CREATE UNIQUE INDEX mcp_routing_reservations_source_operation_id_source_step_in_key ON public.mcp_routing_reservations USING btree (source_operation_id, source_step_index)","index_name":"mcp_routing_reservations_source_operation_id_source_step_in_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_routing_reservations"},{"definition":"CREATE UNIQUE INDEX mcp_scoped_recovery_intents_pkey ON public.mcp_scoped_recovery_intents USING btree (source_operation_id, source_step_index)","index_name":"mcp_scoped_recovery_intents_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_scoped_recovery_intents"},{"definition":"CREATE UNIQUE INDEX mcp_scoped_recovery_intents_recovery_receipt_id_key ON public.mcp_scoped_recovery_intents USING btree (recovery_receipt_id)","index_name":"mcp_scoped_recovery_intents_recovery_receipt_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_scoped_recovery_intents"},{"definition":"CREATE UNIQUE INDEX mcp_secrets_pkey ON public.mcp_secrets USING btree (id)","index_name":"mcp_secrets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_secrets"},{"definition":"CREATE UNIQUE INDEX mcp_settings_pkey ON public.mcp_settings USING btree (id)","index_name":"mcp_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_settings"},{"definition":"CREATE UNIQUE INDEX mcp_unauthorized_buckets_pkey ON public.mcp_unauthorized_buckets USING btree (bucket, client_hash, reason)","index_name":"mcp_unauthorized_buckets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"mcp_unauthorized_buckets"},{"definition":"CREATE UNIQUE INDEX recursive_routes_pkey ON public.recursive_routes USING btree (id)","index_name":"recursive_routes_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"recursive_routes"},{"definition":"CREATE UNIQUE INDEX router_log_collection_state_pkey ON public.router_log_collection_state USING btree (server_id)","index_name":"router_log_collection_state_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"router_log_collection_state"},{"definition":"CREATE UNIQUE INDEX router_log_entries_pkey ON public.router_log_entries USING btree (id)","index_name":"router_log_entries_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"router_log_entries"},{"definition":"CREATE UNIQUE INDEX router_log_settings_pkey ON public.router_log_settings USING btree (id)","index_name":"router_log_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"router_log_settings"},{"definition":"CREATE UNIQUE INDEX scheduler_runs_pkey ON public.scheduler_runs USING btree (id)","index_name":"scheduler_runs_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"scheduler_runs"},{"definition":"CREATE UNIQUE INDEX schema_migrations_pkey ON public.schema_migrations USING btree (id)","index_name":"schema_migrations_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"schema_migrations"},{"definition":"CREATE UNIQUE INDEX server_poll_acks_pkey ON public.server_poll_acks USING btree (receipt_id, stage)","index_name":"server_poll_acks_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_acks"},{"definition":"CREATE UNIQUE INDEX server_poll_archives_execution_id_key ON public.server_poll_archives USING btree (execution_id)","index_name":"server_poll_archives_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_archives"},{"definition":"CREATE UNIQUE INDEX server_poll_archives_pkey ON public.server_poll_archives USING btree (receipt_id)","index_name":"server_poll_archives_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_archives"},{"definition":"CREATE UNIQUE INDEX server_poll_executions_identity_kind_execution_id_key ON public.server_poll_executions USING btree (identity_kind, execution_id)","index_name":"server_poll_executions_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_executions"},{"definition":"CREATE UNIQUE INDEX server_poll_executions_pkey ON public.server_poll_executions USING btree (receipt_id)","index_name":"server_poll_executions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_executions"},{"definition":"CREATE UNIQUE INDEX server_poll_intents_pkey ON public.server_poll_intents USING btree (receipt_id, stage)","index_name":"server_poll_intents_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_intents"},{"definition":"CREATE UNIQUE INDEX server_poll_quarantines_identity_kind_execution_id_key ON public.server_poll_quarantines USING btree (identity_kind, execution_id)","index_name":"server_poll_quarantines_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_quarantines"},{"definition":"CREATE UNIQUE INDEX server_poll_quarantines_pkey ON public.server_poll_quarantines USING btree (receipt_id)","index_name":"server_poll_quarantines_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_quarantines"},{"definition":"CREATE UNIQUE INDEX server_poll_receipts_pkey ON public.server_poll_receipts USING btree (receipt_id)","index_name":"server_poll_receipts_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_receipts"},{"definition":"CREATE UNIQUE INDEX server_poll_storage_admissions_identity_kind_execution_id_key ON public.server_poll_storage_admissions USING btree (identity_kind, execution_id)","index_name":"server_poll_storage_admissions_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_storage_admissions"},{"definition":"CREATE UNIQUE INDEX server_poll_storage_admissions_pkey ON public.server_poll_storage_admissions USING btree (receipt_id)","index_name":"server_poll_storage_admissions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_storage_admissions"},{"definition":"CREATE UNIQUE INDEX server_poll_storage_usage_pkey ON public.server_poll_storage_usage USING btree (scope)","index_name":"server_poll_storage_usage_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_poll_storage_usage"},{"definition":"CREATE UNIQUE INDEX server_probe_execution_payloads_pkey ON public.server_probe_execution_payloads USING btree (receipt_id)","index_name":"server_probe_execution_payloads_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_execution_payloads"},{"definition":"CREATE UNIQUE INDEX server_probe_execution_quarantin_identity_kind_execution_id_key ON public.server_probe_execution_quarantines USING btree (identity_kind, execution_id)","index_name":"server_probe_execution_quarantin_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_execution_quarantines"},{"definition":"CREATE UNIQUE INDEX server_probe_execution_quarantines_pkey ON public.server_probe_execution_quarantines USING btree (receipt_id)","index_name":"server_probe_execution_quarantines_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_execution_quarantines"},{"definition":"CREATE UNIQUE INDEX server_probe_execution_stages_pkey ON public.server_probe_execution_stages USING btree (receipt_id, stage_index)","index_name":"server_probe_execution_stages_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_execution_stages"},{"definition":"CREATE UNIQUE INDEX server_probe_executions_identity_kind_execution_id_key ON public.server_probe_executions USING btree (identity_kind, execution_id)","index_name":"server_probe_executions_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_executions"},{"definition":"CREATE UNIQUE INDEX server_probe_executions_pkey ON public.server_probe_executions USING btree (receipt_id)","index_name":"server_probe_executions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_executions"},{"definition":"CREATE UNIQUE INDEX server_probe_storage_admissions_identity_kind_execution_id_key ON public.server_probe_storage_admissions USING btree (identity_kind, execution_id)","index_name":"server_probe_storage_admissions_identity_kind_execution_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_storage_admissions"},{"definition":"CREATE UNIQUE INDEX server_probe_storage_admissions_pkey ON public.server_probe_storage_admissions USING btree (receipt_id)","index_name":"server_probe_storage_admissions_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_storage_admissions"},{"definition":"CREATE UNIQUE INDEX server_probe_storage_usage_pkey ON public.server_probe_storage_usage USING btree (scope)","index_name":"server_probe_storage_usage_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_probe_storage_usage"},{"definition":"CREATE UNIQUE INDEX server_snapshots_pkey ON ONLY public.server_snapshots USING btree (id, polled_at)","index_name":"server_snapshots_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"server_snapshots"},{"definition":"CREATE UNIQUE INDEX servers_api_ping_settings_pkey ON public.servers_api_ping_settings USING btree (id)","index_name":"servers_api_ping_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"servers_api_ping_settings"},{"definition":"CREATE UNIQUE INDEX servers_pkey ON public.servers USING btree (id)","index_name":"servers_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"servers"},{"definition":"CREATE UNIQUE INDEX servers_rest_ping_samples_pkey ON ONLY public.servers_rest_ping_samples USING btree (server_id, sampled_at)","index_name":"servers_rest_ping_samples_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"servers_rest_ping_samples"},{"definition":"CREATE UNIQUE INDEX traffic_collection_state_pkey ON public.traffic_collection_state USING btree (server_id)","index_name":"traffic_collection_state_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"traffic_collection_state"},{"definition":"CREATE UNIQUE INDEX traffic_flow_settings_pkey ON public.traffic_flow_settings USING btree (id)","index_name":"traffic_flow_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"traffic_flow_settings"},{"definition":"CREATE UNIQUE INDEX traffic_samples_pkey ON ONLY public.traffic_samples USING btree (server_id, sampled_at, interface_name, peer_public_key)","index_name":"traffic_samples_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"traffic_samples"},{"definition":"CREATE UNIQUE INDEX traffic_settings_pkey ON public.traffic_settings USING btree (id)","index_name":"traffic_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"traffic_settings"},{"definition":"CREATE UNIQUE INDEX uptime_probe_samples_pkey ON ONLY public.uptime_probe_samples USING btree (probe_id, sampled_at)","index_name":"uptime_probe_samples_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_probe_samples"},{"definition":"CREATE UNIQUE INDEX uptime_probes_pkey ON public.uptime_probes USING btree (id)","index_name":"uptime_probes_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_probes"},{"definition":"CREATE UNIQUE INDEX uptime_resource_samples_pkey ON ONLY public.uptime_resource_samples USING btree (server_id, sampled_at)","index_name":"uptime_resource_samples_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_resource_samples"},{"definition":"CREATE UNIQUE INDEX uptime_settings_pkey ON public.uptime_settings USING btree (id)","index_name":"uptime_settings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_settings"},{"definition":"CREATE UNIQUE INDEX uptime_speed_probes_pkey ON public.uptime_speed_probes USING btree (id)","index_name":"uptime_speed_probes_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_speed_probes"},{"definition":"CREATE UNIQUE INDEX uptime_speed_test_runs_pkey ON public.uptime_speed_test_runs USING btree (id)","index_name":"uptime_speed_test_runs_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"uptime_speed_test_runs"},{"definition":"CREATE UNIQUE INDEX user_interface_bindings_pkey ON public.user_interface_bindings USING btree (id)","index_name":"user_interface_bindings_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"user_interface_bindings"},{"definition":"CREATE UNIQUE INDEX user_interface_bindings_server_id_interface_name_peer_publi_key ON public.user_interface_bindings USING btree (server_id, interface_name, peer_public_key)","index_name":"user_interface_bindings_server_id_interface_name_peer_publi_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"user_interface_bindings"},{"definition":"CREATE UNIQUE INDEX vrf_production_tickets_pkey ON public.vrf_production_tickets USING btree (ticket_id)","index_name":"vrf_production_tickets_pkey","indisprimary":true,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"vrf_production_tickets"},{"definition":"CREATE UNIQUE INDEX vrf_production_tickets_plan_id_key ON public.vrf_production_tickets USING btree (plan_id)","index_name":"vrf_production_tickets_plan_id_key","indisprimary":false,"indisready":true,"indisunique":true,"indisvalid":true,"relname":"vrf_production_tickets"}],"inheritance":[],"memberships":[{"admin_option":false,"granted_role":"pg_read_all_settings","grantor":"@mm-role:control@","inherit_option":true,"member":"pg_monitor","set_option":true},{"admin_option":false,"granted_role":"pg_read_all_stats","grantor":"@mm-role:control@","inherit_option":true,"member":"pg_monitor","set_option":true},{"admin_option":false,"granted_role":"pg_stat_scan_tables","grantor":"@mm-role:control@","inherit_option":true,"member":"pg_monitor","set_option":true}],"parameters":[{"can_set":false,"name":"event_triggers","rolname":"@mm-role:capture@"},{"can_set":false,"name":"event_triggers","rolname":"@mm-role:operator@"},{"can_set":false,"name":"event_triggers","rolname":"@mm-role:publisher@"},{"can_set":false,"name":"event_triggers","rolname":"@mm-role:runtime@"},{"can_set":false,"name":"session_replication_role","rolname":"@mm-role:capture@"},{"can_set":false,"name":"session_replication_role","rolname":"@mm-role:operator@"},{"can_set":false,"name":"session_replication_role","rolname":"@mm-role:publisher@"},{"can_set":false,"name":"session_replication_role","rolname":"@mm-role:runtime@"}],"roleGrants":[{"delete":false,"insert":false,"read":false,"relname":"acme_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_engine_confirm_pending","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_engine_cursor","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_engine_prev_live","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_engine_state","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_groups","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_history","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_outbox","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_rule_conditions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_rule_targets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_rules","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"alert_telegram_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"app_users","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"backup_entries","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"backup_schedule_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"backup_storage_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"certificate_issue_jobs","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"certificate_renew_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"config_revisions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"data_migration","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"events","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"evobgp_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"filter_rules","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_asn_meta","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_buckets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_daily_dims","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_daily_facts","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_hour_facts","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_ip_meta","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_minute_dims","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_minute_stats","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_settings_intents","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"flow_write_receipts","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"geoip_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"internet_path_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"internet_path_snapshots","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_artifacts","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_audit","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_budget_buckets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_connections","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_credentials","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_diagnostic_cancellations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_drift","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_grants","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_management_channels","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_oauth_clients","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_oauth_requests","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_operation_checkpoints","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_operation_steps","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_operations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_owner_revocations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_path_checks","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_plans","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_portal_events","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_protections","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_read_leases","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_recovery_intents","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_requests","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_forward_charges","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_manual_inverse_charges","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_observations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_profiles","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_reservation_slots","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_routing_reservations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_scoped_recovery_intents","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_secrets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"mcp_unauthorized_buckets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"recursive_routes","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"router_log_collection_state","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"router_log_entries","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"router_log_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"scheduler_runs","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_acks","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_archives","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_executions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_intents","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_quarantines","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_receipts","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_storage_admissions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_poll_storage_usage","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_execution_payloads","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_execution_quarantines","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_execution_stages","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_executions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_storage_admissions","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_probe_storage_usage","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"server_snapshots","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"servers","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"servers_api_ping_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"servers_rest_ping_samples","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"traffic_collection_state","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"traffic_flow_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"traffic_samples","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"traffic_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_probe_samples","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_probes","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_resource_samples","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_settings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_speed_probes","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"uptime_speed_test_runs","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"user_interface_bindings","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":false,"relname":"vrf_production_tickets","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"acme_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_engine_confirm_pending","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_engine_cursor","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_engine_prev_live","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_engine_state","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_groups","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_history","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_outbox","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_rule_conditions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_rule_targets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_rules","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"alert_telegram_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"app_users","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"backup_entries","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"backup_schedule_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"backup_storage_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"certificate_issue_jobs","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"certificate_renew_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"config_revisions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"data_migration","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"data_migration","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"events","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"evobgp_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"filter_rules","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_asn_meta","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_buckets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_daily_dims","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_daily_facts","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_hour_facts","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_ip_meta","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_minute_dims","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_minute_stats","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_settings_intents","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"flow_write_receipts","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"geoip_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"internet_path_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"internet_path_snapshots","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_artifacts","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_audit","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_budget_buckets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_connections","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_credentials","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_diagnostic_cancellations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_drift","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_grants","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_management_channels","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_oauth_clients","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_oauth_requests","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_operation_checkpoints","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_operation_steps","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_operations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_owner_revocations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_path_checks","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_plans","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_portal_events","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_protections","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_read_leases","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_recovery_intents","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_requests","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_forward_charges","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_manual_inverse_charges","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_observations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_profiles","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_reservation_slots","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_routing_reservations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_scoped_recovery_intents","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_secrets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"mcp_unauthorized_buckets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"recursive_routes","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"router_log_collection_state","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"router_log_entries","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"router_log_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"scheduler_runs","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"schema_migrations","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"schema_migrations","rolname":"@mm-role:publisher@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"schema_migrations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_acks","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_archives","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_executions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_intents","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_quarantines","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_receipts","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_storage_admissions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_poll_storage_usage","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_execution_payloads","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_execution_quarantines","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_execution_stages","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_executions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_storage_admissions","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_probe_storage_usage","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"server_snapshots","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"servers","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"servers_api_ping_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"servers_rest_ping_samples","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"traffic_collection_state","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"traffic_flow_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"traffic_samples","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"traffic_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_probe_samples","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_probes","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_resource_samples","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_settings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_speed_probes","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"uptime_speed_test_runs","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"user_interface_bindings","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":false,"insert":false,"read":true,"relname":"vrf_production_tickets","rolname":"@mm-role:capture@","trigger":false,"truncate":false,"update":false},{"delete":true,"insert":true,"read":true,"relname":"acme_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"acme_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_confirm_pending","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_confirm_pending","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_cursor","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_cursor","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_prev_live","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_prev_live","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_state","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_engine_state","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_groups","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_groups","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_history","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_history","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_outbox","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_outbox","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rule_conditions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rule_conditions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rule_targets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rule_targets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rules","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_rules","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_telegram_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"alert_telegram_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"app_users","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"app_users","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_entries","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_entries","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_schedule_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_schedule_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_storage_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"backup_storage_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"certificate_issue_jobs","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"certificate_issue_jobs","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"certificate_renew_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"certificate_renew_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"config_revisions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"config_revisions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"data_migration","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"events","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"events","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"evobgp_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"evobgp_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"filter_rules","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"filter_rules","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_asn_meta","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_asn_meta","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_buckets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_buckets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_daily_dims","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_daily_dims","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_daily_facts","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_daily_facts","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_hour_facts","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_hour_facts","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_ip_meta","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_ip_meta","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_minute_dims","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_minute_dims","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_minute_stats","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_minute_stats","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_settings_intents","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_settings_intents","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_write_receipts","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"flow_write_receipts","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"geoip_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"geoip_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"internet_path_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"internet_path_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"internet_path_snapshots","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"internet_path_snapshots","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_artifacts","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_artifacts","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_audit","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_audit","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_budget_buckets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_budget_buckets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_connections","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_connections","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_credentials","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_credentials","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_diagnostic_cancellations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_diagnostic_cancellations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_drift","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_drift","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_grants","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_grants","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_management_channels","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_management_channels","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_oauth_clients","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_oauth_clients","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_oauth_requests","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_oauth_requests","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operation_checkpoints","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operation_checkpoints","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operation_steps","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operation_steps","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_operations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_owner_revocations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_owner_revocations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_path_checks","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_path_checks","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_plans","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_plans","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_portal_events","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_portal_events","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_protections","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_protections","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_read_leases","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_read_leases","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_recovery_intents","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_recovery_intents","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_requests","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_requests","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_forward_charges","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_forward_charges","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_manual_inverse_charges","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_manual_inverse_charges","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_observations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_observations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_profiles","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_profiles","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_reservation_slots","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_reservation_slots","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_reservations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_routing_reservations","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_scoped_recovery_intents","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_scoped_recovery_intents","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_secrets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_secrets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_unauthorized_buckets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"mcp_unauthorized_buckets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"recursive_routes","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"recursive_routes","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_collection_state","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_collection_state","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_entries","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_entries","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"router_log_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"scheduler_runs","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"scheduler_runs","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"schema_migrations","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_acks","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_acks","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_archives","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_archives","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_executions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_executions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_intents","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_intents","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_quarantines","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_quarantines","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_receipts","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_receipts","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_storage_admissions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_storage_admissions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_storage_usage","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_poll_storage_usage","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_payloads","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_payloads","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_quarantines","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_quarantines","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_stages","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_execution_stages","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_executions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_executions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_storage_admissions","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_storage_admissions","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_storage_usage","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_probe_storage_usage","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_snapshots","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"server_snapshots","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers_api_ping_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers_api_ping_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers_rest_ping_samples","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"servers_rest_ping_samples","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_collection_state","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_collection_state","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_flow_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_flow_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_samples","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_samples","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"traffic_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_probe_samples","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_probe_samples","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_probes","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_probes","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_resource_samples","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_resource_samples","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_settings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_settings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_speed_probes","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_speed_probes","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_speed_test_runs","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"uptime_speed_test_runs","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"user_interface_bindings","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"user_interface_bindings","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true},{"delete":true,"insert":true,"read":true,"relname":"vrf_production_tickets","rolname":"@mm-role:operator@","trigger":true,"truncate":true,"update":true},{"delete":true,"insert":true,"read":true,"relname":"vrf_production_tickets","rolname":"@mm-role:runtime@","trigger":false,"truncate":false,"update":true}],"roles":[{"rolbypassrls":false,"rolcanlogin":true,"rolcreatedb":false,"rolcreaterole":false,"rolinherit":true,"rolname":"@mm-role:capture@","rolreplication":false,"rolsuper":false},{"rolbypassrls":false,"rolcanlogin":true,"rolcreatedb":false,"rolcreaterole":false,"rolinherit":true,"rolname":"@mm-role:operator@","rolreplication":false,"rolsuper":false},{"rolbypassrls":false,"rolcanlogin":true,"rolcreatedb":false,"rolcreaterole":false,"rolinherit":true,"rolname":"@mm-role:publisher@","rolreplication":false,"rolsuper":false},{"rolbypassrls":false,"rolcanlogin":true,"rolcreatedb":false,"rolcreaterole":false,"rolinherit":true,"rolname":"@mm-role:runtime@","rolreplication":false,"rolsuper":false},{"rolbypassrls":true,"rolcanlogin":true,"rolcreatedb":true,"rolcreaterole":true,"rolinherit":true,"rolname":"@mm-role:control@","rolreplication":true,"rolsuper":true}],"schemas":[{"acl":["@mm-role:control@=UC/@mm-role:control@","@mm-role:operator@=U/@mm-role:control@","@mm-role:publisher@=U/@mm-role:control@"],"nspname":"mmapp_control","owner":"@mm-role:control@"},{"acl":["@mm-role:capture@=U/@mm-role:operator@","@mm-role:operator@=UC/@mm-role:operator@","@mm-role:publisher@=U/@mm-role:operator@","@mm-role:runtime@=U/@mm-role:operator@"],"nspname":"public","owner":"@mm-role:operator@"}],"sequences":[{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"filter_rules","relname":"filter_rules_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"internet_path_snapshots","relname":"internet_path_snapshots_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"mcp_audit","relname":"mcp_audit_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"recursive_routes","relname":"recursive_routes_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"router_log_entries","relname":"router_log_entries_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"server_snapshots","relname":"server_snapshots_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=rwU/@mm-role:operator@"],"deptype":"i","namespace":"public","owner":"@mm-role:operator@","owner_column":1,"owner_relation":"servers","relname":"servers_id_seq","seqcache":"1","seqcycle":false,"seqincrement":"1","seqmax":"9223372036854775807","seqmin":"1","seqstart":"1","type_oid":20}],"settings":[],"tables":[{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:publisher@=r/@mm-role:operator@","@mm-role:runtime@=r/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"schema_migrations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (bucket_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_buckets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (bucket_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_hour_facts","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (bucket_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_minute_dims","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (bucket_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_minute_stats","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (day)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_daily_dims","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (day)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"flow_daily_facts","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (polled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"server_snapshots","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (sampled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"internet_path_snapshots","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (sampled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"servers_rest_ping_samples","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (sampled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"traffic_samples","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (sampled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"uptime_probe_samples","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":"RANGE (sampled_at)","relforcerowsecurity":false,"relispartition":false,"relkind":"p","relname":"uptime_resource_samples","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"acme_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_engine_confirm_pending","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_engine_cursor","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_engine_prev_live","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_engine_state","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_groups","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_history","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_outbox","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_rule_conditions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_rule_targets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_rules","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"alert_telegram_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"app_users","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"backup_entries","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"backup_schedule_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"backup_storage_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"certificate_issue_jobs","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"certificate_renew_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"config_revisions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"events","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"evobgp_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"filter_rules","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"flow_asn_meta","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"flow_ip_meta","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"flow_settings_intents","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"flow_write_receipts","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"geoip_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"internet_path_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_artifacts","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_audit","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_budget_buckets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_connections","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_credentials","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_diagnostic_cancellations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_drift","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_grants","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_management_channels","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_oauth_clients","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_oauth_requests","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_operation_checkpoints","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_operation_steps","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_operations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_owner_revocations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_path_checks","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_plans","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_portal_events","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_protections","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_read_leases","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_recovery_intents","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_requests","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_forward_charges","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_manual_inverse_charges","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_observations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_profiles","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_reservation_slots","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_routing_reservations","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_scoped_recovery_intents","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_secrets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"mcp_unauthorized_buckets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"recursive_routes","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"router_log_collection_state","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"router_log_entries","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"router_log_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"scheduler_runs","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_acks","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_archives","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_executions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_intents","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_quarantines","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_receipts","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_storage_admissions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_poll_storage_usage","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_execution_payloads","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_execution_quarantines","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_execution_stages","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_executions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_storage_admissions","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"server_probe_storage_usage","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"servers","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"servers_api_ping_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"traffic_collection_state","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"traffic_flow_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"traffic_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"uptime_probes","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"uptime_settings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"uptime_speed_probes","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"uptime_speed_test_runs","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"user_interface_bindings","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=arwd/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"vrf_production_tickets","reloptions":null,"relrowsecurity":false},{"acl":["@mm-role:capture@=r/@mm-role:operator@","@mm-role:operator@=arwdDxtm/@mm-role:operator@","@mm-role:runtime@=r/@mm-role:operator@"],"namespace":"public","owner":"@mm-role:operator@","partition_bound":null,"partition_key":null,"relforcerowsecurity":false,"relispartition":false,"relkind":"r","relname":"data_migration","reloptions":null,"relrowsecurity":false}],"triggers":[{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.acme_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"acme_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_confirm_pending FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_confirm_pending","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_cursor FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_cursor","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_prev_live FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_prev_live","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_state FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_groups FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_groups","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_history FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_history","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_outbox FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_outbox","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rule_conditions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rule_conditions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rule_targets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rule_targets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rules FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_telegram_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_telegram_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.app_users FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"app_users","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_entries FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_schedule_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_schedule_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_storage_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_storage_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.certificate_issue_jobs FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"certificate_issue_jobs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.certificate_renew_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"certificate_renew_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.config_revisions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"config_revisions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.data_migration FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"data_migration","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.events FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.evobgp_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"evobgp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.filter_rules FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"filter_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_asn_meta FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_asn_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_buckets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_daily_dims FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_daily_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_daily_facts FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_daily_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_hour_facts FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_hour_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_ip_meta FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_ip_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_minute_dims FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_minute_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_minute_stats FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_minute_stats","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_settings_intents FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_settings_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_write_receipts FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_write_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.geoip_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"geoip_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.internet_path_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"internet_path_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.internet_path_snapshots FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"internet_path_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_artifacts FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_artifacts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_audit FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_audit","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_budget_buckets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_budget_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_connections FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_credentials FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_diagnostic_cancellations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_drift FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_drift","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_grants FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_grants","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_management_channels FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_management_channels","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_oauth_clients FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_oauth_clients","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_oauth_requests FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operation_checkpoints FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operation_checkpoints","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operation_steps FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operation_steps","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_owner_revocations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_owner_revocations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_path_checks FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_path_checks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_plans FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_portal_events FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_portal_events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_protections FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_protections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_read_leases FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_read_leases","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_recovery_intents FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_requests FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_forward_charges FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_manual_inverse_charges FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_observations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_observations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_profiles FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_reservation_slots FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_reservations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_scoped_recovery_intents FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_secrets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_secrets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_unauthorized_buckets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_unauthorized_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.recursive_routes FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"recursive_routes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_collection_state FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_entries FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.scheduler_runs FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"scheduler_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.schema_migrations FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"schema_migrations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_acks FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_archives FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_executions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_intents FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_quarantines FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_receipts FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_storage_admissions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_storage_usage FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_payloads FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_quarantines FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_stages FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_executions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_storage_admissions FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_storage_usage FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_snapshots FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers_api_ping_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers_api_ping_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers_rest_ping_samples FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers_rest_ping_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_collection_state FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_flow_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_flow_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_samples FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_probe_samples FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_probe_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_probes FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_resource_samples FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_resource_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_settings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_speed_probes FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_speed_test_runs FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.user_interface_bindings FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.vrf_production_tickets FOR EACH STATEMENT EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_application_statement_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":30,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.acme_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"acme_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_engine_confirm_pending FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_engine_confirm_pending","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_engine_cursor FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_engine_cursor","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_engine_prev_live FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_engine_prev_live","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_engine_state FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_engine_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_groups FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_groups","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_history FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_history","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_outbox FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_outbox","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_rule_conditions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_rule_conditions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_rule_targets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_rule_targets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_rules FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.alert_telegram_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"alert_telegram_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.app_users FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"app_users","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.backup_entries FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"backup_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.backup_schedule_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"backup_schedule_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.backup_storage_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"backup_storage_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.certificate_issue_jobs FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"certificate_issue_jobs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.certificate_renew_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"certificate_renew_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.config_revisions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"config_revisions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.data_migration FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"data_migration","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.events FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.evobgp_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"evobgp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.filter_rules FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"filter_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_asn_meta FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_asn_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_buckets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_daily_dims FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_daily_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_daily_facts FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_daily_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_hour_facts FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_hour_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_ip_meta FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_ip_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_minute_dims FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_minute_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_minute_stats FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_minute_stats","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_settings_intents FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_settings_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.flow_write_receipts FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"flow_write_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.geoip_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"geoip_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.internet_path_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"internet_path_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.internet_path_snapshots FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"internet_path_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_artifacts FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_artifacts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_audit FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_audit","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_budget_buckets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_budget_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_connections FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_credentials FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_diagnostic_cancellations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_drift FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_drift","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_grants FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_grants","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_management_channels FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_management_channels","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_oauth_clients FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_oauth_clients","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_oauth_requests FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_operation_checkpoints FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_operation_checkpoints","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_operation_steps FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_operation_steps","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_operations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_owner_revocations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_owner_revocations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_path_checks FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_path_checks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_plans FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_portal_events FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_portal_events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_protections FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_protections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_read_leases FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_read_leases","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_recovery_intents FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_requests FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_forward_charges FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_manual_inverse_charges FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_observations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_observations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_profiles FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_reservation_slots FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_routing_reservations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_scoped_recovery_intents FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_secrets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_secrets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.mcp_unauthorized_buckets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"mcp_unauthorized_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.recursive_routes FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"recursive_routes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.router_log_collection_state FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"router_log_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.router_log_entries FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"router_log_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.router_log_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"router_log_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.scheduler_runs FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"scheduler_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.schema_migrations FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"schema_migrations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_acks FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_archives FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_executions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_intents FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_quarantines FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_receipts FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_storage_admissions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_poll_storage_usage FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_poll_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_execution_payloads FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_execution_quarantines FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_execution_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_execution_stages FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_executions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_storage_admissions FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_probe_storage_usage FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_probe_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.server_snapshots FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"server_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.servers FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.servers_api_ping_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"servers_api_ping_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.servers_rest_ping_samples FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"servers_rest_ping_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.traffic_collection_state FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"traffic_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.traffic_flow_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"traffic_flow_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.traffic_samples FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"traffic_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.traffic_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"traffic_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_probe_samples FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_probe_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_probes FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_resource_samples FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_resource_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_settings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_speed_probes FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.uptime_speed_test_runs FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.user_interface_bindings FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.vrf_production_tickets FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()","function":"mmapp_control.candidate_truncate_preadmitted()","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"candidate_truncate_preadmitted","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_diagnostic_cancellation_immutable BEFORE DELETE OR UPDATE ON public.mcp_diagnostic_cancellations FOR EACH ROW EXECUTE FUNCTION mcp_diagnostic_cancellation_immutable()","function":"public.mcp_diagnostic_cancellation_immutable()","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_diagnostic_cancellation_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_forward_charge_immutable BEFORE DELETE OR UPDATE ON public.mcp_routing_forward_charges FOR EACH ROW EXECUTE FUNCTION mcp_routing_forward_charge_immutable()","function":"public.mcp_routing_forward_charge_immutable()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_forward_charge_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_forward_charge_no_truncate BEFORE TRUNCATE ON public.mcp_routing_forward_charges FOR EACH STATEMENT EXECUTE FUNCTION mcp_routing_forward_charge_immutable()","function":"public.mcp_routing_forward_charge_immutable()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_forward_charge_no_truncate","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_forward_charge_source BEFORE INSERT ON public.mcp_routing_forward_charges FOR EACH ROW EXECUTE FUNCTION mcp_routing_forward_charge_source()","function":"public.mcp_routing_forward_charge_source()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_forward_charge_source","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_manual_inverse_charge_immutable BEFORE DELETE OR UPDATE ON public.mcp_routing_manual_inverse_charges FOR EACH ROW EXECUTE FUNCTION mcp_routing_manual_inverse_charge_immutable()","function":"public.mcp_routing_manual_inverse_charge_immutable()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_manual_inverse_charge_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_manual_inverse_charge_no_truncate BEFORE TRUNCATE ON public.mcp_routing_manual_inverse_charges FOR EACH STATEMENT EXECUTE FUNCTION mcp_routing_manual_inverse_charge_immutable()","function":"public.mcp_routing_manual_inverse_charge_immutable()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_manual_inverse_charge_no_truncate","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":34,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_routing_manual_inverse_charge_source BEFORE INSERT ON public.mcp_routing_manual_inverse_charges FOR EACH ROW EXECUTE FUNCTION mcp_routing_manual_inverse_charge_source()","function":"public.mcp_routing_manual_inverse_charge_source()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_routing_manual_inverse_charge_source","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mcp_scoped_recovery_manual_version BEFORE INSERT ON public.mcp_scoped_recovery_intents FOR EACH ROW EXECUTE FUNCTION mcp_scoped_recovery_manual_version()","function":"public.mcp_scoped_recovery_manual_version()","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mcp_scoped_recovery_manual_version","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER mm_routing_endpoint_epoch BEFORE UPDATE ON public.servers FOR EACH ROW EXECUTE FUNCTION mm_routing_endpoint_epoch()","function":"public.mm_routing_endpoint_epoch()","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"mm_routing_endpoint_epoch","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":19,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.acme_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"acme_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_confirm_pending FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_confirm_pending","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_cursor FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_cursor","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_prev_live FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_prev_live","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_engine_state FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_engine_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_groups FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_groups","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_history FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_history","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_outbox FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_outbox","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rule_conditions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rule_conditions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rule_targets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rule_targets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_rules FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.alert_telegram_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"alert_telegram_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.app_users FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"app_users","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_entries FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_schedule_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_schedule_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.backup_storage_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"backup_storage_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.certificate_issue_jobs FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"certificate_issue_jobs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.certificate_renew_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"certificate_renew_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.config_revisions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"config_revisions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.data_migration FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"data_migration","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.events FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.evobgp_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"evobgp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.filter_rules FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"filter_rules","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_asn_meta FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_asn_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_buckets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_daily_dims FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_daily_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_daily_facts FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_daily_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_hour_facts FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_hour_facts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_ip_meta FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_ip_meta","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_minute_dims FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_minute_dims","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_minute_stats FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_minute_stats","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_settings_intents FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_settings_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.flow_write_receipts FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"flow_write_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.geoip_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"geoip_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.internet_path_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"internet_path_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.internet_path_snapshots FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"internet_path_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_artifacts FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_artifacts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_audit FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_audit","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_budget_buckets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_budget_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_connections FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_credentials FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_diagnostic_cancellations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_drift FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_drift","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_grants FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_grants","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_management_channels FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_management_channels","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_oauth_clients FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_oauth_clients","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_oauth_requests FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operation_checkpoints FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operation_checkpoints","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operation_steps FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operation_steps","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_operations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_owner_revocations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_owner_revocations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_path_checks FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_path_checks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_plans FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_portal_events FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_portal_events","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_protections FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_protections","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_read_leases FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_read_leases","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_recovery_intents FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_requests FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_requests","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_forward_charges FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_forward_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_manual_inverse_charges FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_manual_inverse_charges","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_observations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_observations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_profiles FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_reservation_slots FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_routing_reservations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_scoped_recovery_intents FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_secrets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_secrets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.mcp_unauthorized_buckets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"mcp_unauthorized_buckets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.recursive_routes FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"recursive_routes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_collection_state FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_entries FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_entries","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.router_log_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"router_log_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.scheduler_runs FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"scheduler_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.schema_migrations FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"schema_migrations","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_storage_admissions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_storage_usage FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_poll_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_payloads FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_quarantines FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_quarantines","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_stages FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_executions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_storage_admissions FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_storage_admissions","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_storage_usage FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_probe_storage_usage","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_snapshots FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"server_snapshots","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers_api_ping_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers_api_ping_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.servers_rest_ping_samples FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"servers_rest_ping_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_collection_state FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_collection_state","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_flow_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_flow_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_samples FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.traffic_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"traffic_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_probe_samples FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_probe_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_probes FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_resource_samples FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_resource_samples","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_settings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_speed_probes FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.uptime_speed_test_runs FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.user_interface_bindings FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.vrf_production_tickets FOR EACH ROW EXECUTE FUNCTION server_partition_writer_guard()","function":"public.server_partition_writer_guard()","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_partition_writer_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_ack_immutable BEFORE DELETE OR UPDATE ON public.server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable()","function":"public.server_poll_journal_immutable()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_ack_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_archive_immutable BEFORE DELETE OR UPDATE ON public.server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_poll_archive_immutable()","function":"public.server_poll_archive_immutable()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_archive_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_archive_insert_finish AFTER INSERT ON public.server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_poll_archive_insert_finish()","function":"public.server_poll_archive_insert_finish()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_archive_insert_finish","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_archive_insert_guard BEFORE INSERT ON public.server_poll_archives FOR EACH ROW EXECUTE FUNCTION server_poll_archive_insert_guard()","function":"public.server_poll_archive_insert_guard()","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_archive_insert_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_compacted_ack_guard BEFORE INSERT ON public.server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_compacted_row_guard()","function":"public.server_poll_compacted_row_guard()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_compacted_ack_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_compacted_anchor_guard BEFORE INSERT ON public.server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_compacted_row_guard()","function":"public.server_poll_compacted_row_guard()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_compacted_anchor_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_compacted_intent_guard BEFORE INSERT ON public.server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_compacted_row_guard()","function":"public.server_poll_compacted_row_guard()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_compacted_intent_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_compacted_quarantine_guard BEFORE INSERT ON public.server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_compacted_row_guard()","function":"public.server_poll_compacted_row_guard()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_compacted_quarantine_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_compacted_receipt_guard BEFORE INSERT ON public.server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_compacted_row_guard()","function":"public.server_poll_compacted_row_guard()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_compacted_receipt_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_execution_immutable BEFORE DELETE OR UPDATE ON public.server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable()","function":"public.server_poll_journal_immutable()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_execution_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_intent_immutable BEFORE DELETE OR UPDATE ON public.server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable()","function":"public.server_poll_journal_immutable()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_intent_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_quarantine_immutable BEFORE DELETE OR UPDATE ON public.server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable()","function":"public.server_poll_journal_immutable()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_quarantine_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_receipt_immutable BEFORE DELETE OR UPDATE ON public.server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_journal_immutable()","function":"public.server_poll_journal_immutable()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_receipt_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.internet_path_settings FOR EACH ROW EXECUTE FUNCTION server_poll_settings_epoch_guard()","function":"public.server_poll_settings_epoch_guard()","parent":false,"relname":"internet_path_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_settings_epoch","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":23,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.traffic_settings FOR EACH ROW EXECUTE FUNCTION server_poll_settings_epoch_guard()","function":"public.server_poll_settings_epoch_guard()","parent":false,"relname":"traffic_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_settings_epoch","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":23,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_settings_epoch BEFORE INSERT OR UPDATE ON public.uptime_settings FOR EACH ROW EXECUTE FUNCTION server_poll_settings_epoch_guard()","function":"public.server_poll_settings_epoch_guard()","parent":false,"relname":"uptime_settings","tgdeferrable":false,"tgenabled":"A","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_settings_epoch","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":23,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_ack_guard BEFORE INSERT ON public.server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard()","function":"public.server_poll_storage_row_guard()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_ack_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_ack_meter AFTER INSERT ON public.server_poll_acks FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter()","function":"public.server_poll_storage_row_meter()","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_ack_meter","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_admission_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_poll_storage_admissions FOR EACH ROW EXECUTE FUNCTION server_poll_storage_admission_guard()","function":"public.server_poll_storage_admission_guard()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_admission_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_anchor_guard BEFORE INSERT ON public.server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard()","function":"public.server_poll_storage_row_guard()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_anchor_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_anchor_meter AFTER INSERT ON public.server_poll_executions FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter()","function":"public.server_poll_storage_row_meter()","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_anchor_meter","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_intent_guard BEFORE INSERT ON public.server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard()","function":"public.server_poll_storage_row_guard()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_intent_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_intent_meter AFTER INSERT ON public.server_poll_intents FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter()","function":"public.server_poll_storage_row_meter()","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_intent_meter","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_quarantine_guard BEFORE INSERT ON public.server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard()","function":"public.server_poll_storage_row_guard()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_quarantine_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_quarantine_meter AFTER INSERT ON public.server_poll_quarantines FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter()","function":"public.server_poll_storage_row_meter()","parent":false,"relname":"server_poll_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_quarantine_meter","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_receipt_guard BEFORE INSERT ON public.server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_guard()","function":"public.server_poll_storage_row_guard()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_receipt_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_poll_storage_receipt_meter AFTER INSERT ON public.server_poll_receipts FOR EACH ROW EXECUTE FUNCTION server_poll_storage_row_meter()","function":"public.server_poll_storage_row_meter()","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_poll_storage_receipt_meter","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_execution_immutable BEFORE DELETE OR UPDATE ON public.server_probe_executions FOR EACH ROW EXECUTE FUNCTION server_probe_execution_immutable()","function":"public.server_probe_execution_immutable()","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_execution_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_quarantine_immutable BEFORE DELETE OR UPDATE ON public.server_probe_execution_quarantines FOR EACH ROW EXECUTE FUNCTION server_probe_quarantine_immutable()","function":"public.server_probe_quarantine_immutable()","parent":false,"relname":"server_probe_execution_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_quarantine_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":27,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_stage_immutable BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_stages FOR EACH ROW EXECUTE FUNCTION server_probe_stage_immutable()","function":"public.server_probe_stage_immutable()","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_stage_immutable","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_storage_admission_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_storage_admissions FOR EACH ROW EXECUTE FUNCTION server_probe_storage_admission_guard()","function":"public.server_probe_storage_admission_guard()","parent":false,"relname":"server_probe_storage_admissions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_storage_admission_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_storage_anchor_guard BEFORE INSERT OR UPDATE ON public.server_probe_executions FOR EACH ROW EXECUTE FUNCTION server_probe_storage_anchor_guard()","function":"public.server_probe_storage_anchor_guard()","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_storage_anchor_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":23,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_storage_payload_guard BEFORE INSERT OR DELETE OR UPDATE ON public.server_probe_execution_payloads FOR EACH ROW EXECUTE FUNCTION server_probe_storage_payload_guard()","function":"public.server_probe_storage_payload_guard()","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_storage_payload_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":31,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_storage_quarantine_guard BEFORE INSERT ON public.server_probe_execution_quarantines FOR EACH ROW EXECUTE FUNCTION server_probe_storage_quarantine_guard()","function":"public.server_probe_storage_quarantine_guard()","parent":false,"relname":"server_probe_execution_quarantines","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_storage_quarantine_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":7,"unconditional":true},{"arg_bytes":0,"constraint":false,"definition":"CREATE TRIGGER server_probe_storage_stage_guard BEFORE INSERT OR UPDATE ON public.server_probe_execution_stages FOR EACH ROW EXECUTE FUNCTION server_probe_storage_stage_guard()","function":"public.server_probe_storage_stage_guard()","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":false,"tgname":"server_probe_storage_stage_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":23,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.alert_groups FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_setnull_del\"()","function":"pg_catalog#1650","parent":false,"relname":"alert_groups","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.alert_rules FROM alert_rule_conditions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.alert_rules FROM alert_rule_targets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.app_users FROM user_interface_bindings NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"app_users","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_artifacts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_budget_buckets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_diagnostic_cancellations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_grants NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_oauth_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_path_checks NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_read_leases NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_setnull_del\"()","function":"pg_catalog#1650","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_connections FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_credentials FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_credentials FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_oauth_clients FROM mcp_oauth_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_oauth_clients","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_diagnostic_cancellations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_drift NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_operation_checkpoints NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_operation_steps NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_operations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_plans FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_plans FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_plans FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_profiles FROM mcp_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_profiles FROM mcp_routing_reservation_slots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_profiles FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_profiles FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_reservations FROM mcp_routing_reservation_slots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.mcp_routing_reservations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_poll_executions FROM server_poll_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_poll_executions FROM server_poll_receipts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_poll_intents FROM server_poll_acks NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_poll_storage_admissions FROM server_poll_archives NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_probe_executions FROM server_probe_execution_payloads NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.server_probe_executions FROM server_probe_execution_stages NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM backup_entries NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_setnull_del\"()","function":"pg_catalog#1650","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM certificate_issue_jobs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM config_revisions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM filter_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_buckets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_daily_dims NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_daily_facts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_hour_facts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_minute_dims NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM flow_minute_stats NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM mcp_management_channels NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM recursive_routes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM server_snapshots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM servers_rest_ping_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM traffic_collection_state NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM traffic_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_resource_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_speed_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_speed_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_speed_test_runs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM uptime_speed_test_runs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM user_interface_bindings NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.servers FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_del\"()","function":"pg_catalog#1654","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER DELETE ON public.uptime_probes FROM uptime_probe_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_cascade_del\"()","function":"pg_catalog#1646","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":9,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.alert_groups FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"alert_groups","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.alert_rules FROM alert_rule_conditions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.alert_rules FROM alert_rule_targets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.app_users FROM user_interface_bindings NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"app_users","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_artifacts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_budget_buckets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_diagnostic_cancellations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_grants NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_oauth_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_path_checks NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_read_leases NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_connections FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_connections","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_credentials FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_credentials FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_oauth_clients FROM mcp_oauth_requests NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_oauth_clients","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_diagnostic_cancellations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_drift NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_operation_checkpoints NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_operation_steps NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_plans FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_plans FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_plans FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_routing_reservation_slots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_routing_reservation_slots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_scoped_recovery_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_poll_executions FROM server_poll_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_poll_executions FROM server_poll_receipts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_poll_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_poll_intents FROM server_poll_acks NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_poll_storage_admissions FROM server_poll_archives NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_probe_executions FROM server_probe_execution_payloads NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.server_probe_executions FROM server_probe_execution_stages NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM backup_entries NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM certificate_issue_jobs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM config_revisions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM filter_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_buckets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_daily_dims NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_daily_facts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_hour_facts NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_minute_dims NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM flow_minute_stats NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM mcp_management_channels NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM recursive_routes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM server_snapshots NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM servers_rest_ping_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM traffic_collection_state NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM traffic_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_resource_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_speed_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_speed_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_speed_test_runs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM uptime_speed_test_runs NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM user_interface_bindings NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.servers FROM vrf_production_tickets NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"servers","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_a_{oid}\" AFTER UPDATE ON public.uptime_probes FROM uptime_probe_samples NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_noaction_upd\"()","function":"pg_catalog#1655","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_a_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.alert_rule_conditions FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"alert_rule_conditions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.alert_rule_targets FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"alert_rule_targets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.alert_rules FROM alert_groups NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.backup_entries FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"backup_entries","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.certificate_issue_jobs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"certificate_issue_jobs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.config_revisions FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"config_revisions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.filter_rules FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"filter_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_buckets FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_buckets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_daily_dims FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_daily_dims","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_daily_facts FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_daily_facts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_hour_facts FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_hour_facts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_minute_dims FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_minute_dims","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.flow_minute_stats FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"flow_minute_stats","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_artifacts FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_artifacts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_budget_buckets FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_budget_buckets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_credentials FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_diagnostic_cancellations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_diagnostic_cancellations FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_drift FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_drift","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_grants FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_grants","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_management_channels FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_management_channels","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_oauth_requests FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_oauth_requests FROM mcp_oauth_clients NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_operation_checkpoints FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_operation_checkpoints","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_operation_steps FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_operation_steps","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_operations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_operations FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_path_checks FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_path_checks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_plans FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_read_leases FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_read_leases","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_recovery_intents FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_requests FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_profiles FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_profiles FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservation_slots FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservation_slots FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservations FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservations FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_routing_reservations FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_scoped_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_scoped_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_scoped_recovery_intents FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.mcp_scoped_recovery_intents FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.recursive_routes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"recursive_routes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_poll_acks FROM server_poll_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_poll_archives FROM server_poll_storage_admissions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_poll_intents FROM server_poll_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_poll_receipts FROM server_poll_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_probe_execution_payloads FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_probe_execution_stages FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_probe_executions FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_probe_executions FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.server_snapshots FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"server_snapshots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.servers_rest_ping_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"servers_rest_ping_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.traffic_collection_state FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"traffic_collection_state","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.traffic_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"traffic_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_probe_samples FROM uptime_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_probe_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_resource_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_resource_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_speed_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_speed_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_speed_test_runs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.uptime_speed_test_runs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.user_interface_bindings FROM app_users NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.user_interface_bindings FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.vrf_production_tickets FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.vrf_production_tickets FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER INSERT ON public.vrf_production_tickets FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_ins\"()","function":"pg_catalog#1644","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":5,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.alert_rule_conditions FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"alert_rule_conditions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.alert_rule_targets FROM alert_rules NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"alert_rule_targets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.alert_rules FROM alert_groups NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"alert_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.backup_entries FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"backup_entries","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.certificate_issue_jobs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"certificate_issue_jobs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.config_revisions FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"config_revisions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.filter_rules FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"filter_rules","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_buckets FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_buckets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_daily_dims FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_daily_dims","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_daily_facts FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_daily_facts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_hour_facts FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_hour_facts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_minute_dims FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_minute_dims","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.flow_minute_stats FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"flow_minute_stats","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_artifacts FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_artifacts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_budget_buckets FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_budget_buckets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_credentials FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_credentials","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_diagnostic_cancellations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_diagnostic_cancellations FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_diagnostic_cancellations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_drift FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_drift","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_grants FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_grants","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_management_channels FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_management_channels","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_oauth_requests FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_oauth_requests FROM mcp_oauth_clients NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_oauth_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_operation_checkpoints FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_operation_checkpoints","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_operation_steps FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_operation_steps","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_operations FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_operations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_path_checks FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_path_checks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_plans FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_plans","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_read_leases FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_read_leases","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_recovery_intents FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_requests FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_requests","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_profiles FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_profiles","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservation_slots FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservation_slots FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservation_slots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_routing_reservations FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_routing_reservations","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_scoped_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_scoped_recovery_intents FROM mcp_operations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_scoped_recovery_intents FROM mcp_routing_profiles NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.mcp_scoped_recovery_intents FROM mcp_routing_reservations NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"mcp_scoped_recovery_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.recursive_routes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"recursive_routes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_poll_acks FROM server_poll_intents NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_poll_acks","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_poll_archives FROM server_poll_storage_admissions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_poll_archives","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_poll_intents FROM server_poll_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_poll_intents","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_poll_receipts FROM server_poll_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_poll_receipts","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_probe_execution_payloads FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_probe_execution_payloads","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_probe_execution_stages FROM server_probe_executions NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_probe_execution_stages","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_probe_executions FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_probe_executions FROM mcp_credentials NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_probe_executions","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.server_snapshots FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"server_snapshots","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.servers_rest_ping_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"servers_rest_ping_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.traffic_collection_state FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"traffic_collection_state","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.traffic_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"traffic_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_probe_samples FROM uptime_probes NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_probe_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_resource_samples FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_resource_samples","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_speed_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_speed_probes FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_speed_probes","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_speed_test_runs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.uptime_speed_test_runs FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"uptime_speed_test_runs","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.user_interface_bindings FROM app_users NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.user_interface_bindings FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"user_interface_bindings","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.vrf_production_tickets FROM mcp_connections NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.vrf_production_tickets FROM mcp_plans NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER \"RI_ConstraintTrigger_c_{oid}\" AFTER UPDATE ON public.vrf_production_tickets FROM servers NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE FUNCTION \"RI_FKey_check_upd\"()","function":"pg_catalog#1645","parent":false,"relname":"vrf_production_tickets","tgdeferrable":false,"tgenabled":"O","tginitdeferred":false,"tgisinternal":true,"tgname":"RI_ConstraintTrigger_c_{oid}","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER server_poll_admission_final_guard AFTER INSERT OR DELETE ON public.server_poll_storage_admissions DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION server_poll_archive_final_guard()","function":"public.server_poll_archive_final_guard()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":true,"tgenabled":"O","tginitdeferred":true,"tgisinternal":false,"tgname":"server_poll_admission_final_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":13,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER server_poll_archive_final_guard AFTER INSERT OR DELETE ON public.server_poll_archives DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION server_poll_archive_final_guard()","function":"public.server_poll_archive_final_guard()","parent":false,"relname":"server_poll_archives","tgdeferrable":true,"tgenabled":"O","tginitdeferred":true,"tgisinternal":false,"tgname":"server_poll_archive_final_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":13,"unconditional":true},{"arg_bytes":0,"constraint":true,"definition":"CREATE CONSTRAINT TRIGGER server_poll_compact_final_guard AFTER UPDATE ON public.server_poll_storage_admissions DEFERRABLE INITIALLY DEFERRED FOR EACH ROW WHEN ((old.storage_state IS DISTINCT FROM new.storage_state)) EXECUTE FUNCTION server_poll_archive_final_guard()","function":"public.server_poll_archive_final_guard()","parent":false,"relname":"server_poll_storage_admissions","tgdeferrable":true,"tgenabled":"O","tginitdeferred":true,"tgisinternal":false,"tgname":"server_poll_compact_final_guard","tgnargs":0,"tgnewtable":null,"tgoldtable":null,"tgtype":17,"unconditional":false}]}
diff --git a/backend/scripts/writer-profile/fixed44-build-sql.ts b/backend/scripts/writer-profile/fixed44-build-sql.ts
new file mode 100644
index 00000000..1aa5e244
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed44-build-sql.ts
@@ -0,0 +1,2 @@
+// Fixed query from accepted43, role-literal parameters only; limits/framing unchanged. Clean44 SQL proof pending.
+export const FIXED44_CATALOGUE_BUILD_SQL="WITH c_tables AS NOT MATERIALIZED (SELECT c.oid::text AS oid,n.nspname AS namespace,c.relname,c.relkind,c.relispartition,c.relpersistence,c.relrowsecurity,c.relforcerowsecurity,c.reloptions,\n pg_catalog.pg_get_userbyid(c.relowner) AS owner,c.relacl::text[] AS acl,pg_catalog.pg_get_expr(c.relpartbound,c.oid) AS partition_bound,\n pg_catalog.pg_get_partkeydef(c.oid) AS partition_key FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.relkind IN('r','p')),\nc_columns AS NOT MATERIALIZED (SELECT c.relname,a.attnum::int,a.attname,pg_catalog.format_type(a.atttypid,a.atttypmod) AS type,\n a.attnotnull,a.attidentity,a.attgenerated,a.attstorage,a.attcompression,a.attacl::text[] AS acl,pg_catalog.pg_get_expr(d.adbin,d.adrelid) AS default_expression\n FROM pg_catalog.pg_attribute a JOIN pg_catalog.pg_class c ON c.oid=a.attrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n LEFT JOIN pg_catalog.pg_attrdef d ON d.adrelid=a.attrelid AND d.adnum=a.attnum\n WHERE n.nspname='public' AND c.relkind IN('r','p') AND a.attnum>0 AND NOT a.attisdropped),\nc_identities AS NOT MATERIALIZED (SELECT c.relname,c.oid::text AS relation_oid,a.attnum::int AS column_number,a.attname,a.attidentity,\n pg_catalog.pg_get_serial_sequence(pg_catalog.format('%I.%I',n.nspname,c.relname),a.attname) AS sequence_name\n FROM pg_catalog.pg_attribute a JOIN pg_catalog.pg_class c ON c.oid=a.attrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.relkind IN('r','p') AND NOT c.relispartition AND a.attnum>0 AND NOT a.attisdropped AND a.attidentity<>'' LIMIT 33),\nc_sequences AS NOT MATERIALIZED (SELECT s.oid::text AS oid,n.nspname AS namespace,s.relname,pg_catalog.pg_get_userbyid(s.relowner) AS owner,\n s.relacl::text[] AS acl,q.seqtypid::int AS type_oid,q.seqstart::text,q.seqincrement::text,q.seqmax::text,q.seqmin::text,q.seqcache::text,q.seqcycle,\n d.refobjid::text AS owner_relation_oid,d.refobjsubid::int AS owner_column,d.deptype\n FROM pg_catalog.pg_class s JOIN pg_catalog.pg_namespace n ON n.oid=s.relnamespace JOIN pg_catalog.pg_sequence q ON q.seqrelid=s.oid\n LEFT JOIN pg_catalog.pg_depend d ON d.classid='pg_catalog.pg_class'::regclass AND d.objid=s.oid AND d.objsubid=0 AND d.refclassid='pg_catalog.pg_class'::regclass AND d.refobjsubid>0 AND d.deptype IN('a','i')\n WHERE n.nspname='public' LIMIT 33),\nc_functions AS NOT MATERIALIZED (SELECT p.oid::text,n.nspname AS namespace,p.proname,pg_catalog.pg_get_function_identity_arguments(p.oid) AS arguments,\n p.prokind,p.prosecdef,p.proconfig,p.proacl::text[] AS acl,pg_catalog.pg_get_userbyid(p.proowner) AS owner,l.lanname AS language,\n pg_catalog.pg_get_functiondef(p.oid) AS definition FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace\n JOIN pg_catalog.pg_language l ON l.oid=p.prolang WHERE n.nspname IN('public','mmapp_control') AND p.prokind IN('f','p') LIMIT 257),\nc_triggers AS NOT MATERIALIZED (SELECT t.oid::text AS oid,c.relname,t.tgname,t.tgtype::int,t.tgenabled,t.tgisinternal,t.tgfoid::text,t.tgparentid::text,t.tgconstraint::text,t.tgdeferrable,t.tginitdeferred,t.tgoldtable,t.tgnewtable,\n t.tgnargs,octet_length(t.tgargs)::int AS arg_bytes,t.tgqual IS NULL AS unconditional,pg_catalog.pg_get_triggerdef(t.oid) AS definition\n FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public'),\nc_inheritance AS NOT MATERIALIZED (SELECT p.relname AS parent,c.relname AS child FROM pg_catalog.pg_inherits i\n JOIN pg_catalog.pg_class p ON p.oid=i.inhparent JOIN pg_catalog.pg_class c ON c.oid=i.inhrelid JOIN pg_catalog.pg_namespace n ON n.oid=p.relnamespace\n WHERE n.nspname='public' AND p.relkind IN('r','p')),\nc_constraints AS NOT MATERIALIZED (SELECT c.relname,k.conname,k.contype,k.convalidated,k.condeferrable,k.condeferred,\n pg_catalog.pg_get_constraintdef(k.oid) AS definition FROM pg_catalog.pg_constraint k JOIN pg_catalog.pg_class c ON c.oid=k.conrelid\n JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public'),\nc_indexes AS NOT MATERIALIZED (SELECT c.relname,i.relname AS index_name,x.indisvalid,x.indisready,x.indisunique,x.indisprimary,\n pg_catalog.pg_get_indexdef(i.oid) AS definition FROM pg_catalog.pg_index x JOIN pg_catalog.pg_class c ON c.oid=x.indrelid\n JOIN pg_catalog.pg_class i ON i.oid=x.indexrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public'),\nc_schemas AS NOT MATERIALIZED (SELECT nspname,pg_catalog.pg_get_userbyid(nspowner) AS owner,nspacl::text[] AS acl FROM pg_catalog.pg_namespace WHERE nspname IN('public','mmapp_control')),\nc_database AS NOT MATERIALIZED (SELECT datname,pg_catalog.pg_get_userbyid(datdba) AS owner,datacl::text[] AS acl FROM pg_catalog.pg_database WHERE datname=current_database()),\nc_effectiveSchemas AS NOT MATERIALIZED (SELECT r.rolname,n.nspname,pg_catalog.has_schema_privilege(r.oid,n.oid,'USAGE') AS usage,\n pg_catalog.has_schema_privilege(r.oid,n.oid,'CREATE') AS create FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_namespace n\n WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name) AND n.nspname IN('public','mmapp_control')),\nc_effectiveDatabase AS NOT MATERIALIZED (SELECT r.rolname,pg_catalog.has_database_privilege(r.oid,d.oid,'CONNECT') AS connect,\n pg_catalog.has_database_privilege(r.oid,d.oid,'CREATE') AS create,pg_catalog.has_database_privilege(r.oid,d.oid,'TEMP') AS temporary\n FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_database d WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name) AND d.datname=current_database()),\nc_memberships AS NOT MATERIALIZED (SELECT role.rolname AS granted_role,member.rolname AS member,grantor.rolname AS grantor,m.admin_option,m.inherit_option,m.set_option\n FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles role ON role.oid=m.roleid JOIN pg_catalog.pg_roles member ON member.oid=m.member\n JOIN pg_catalog.pg_roles grantor ON grantor.oid=m.grantor LIMIT 257),\nc_effectiveFunctions AS NOT MATERIALIZED (SELECT r.rolname,n.nspname,p.oid::text AS oid,p.proname,\n pg_catalog.pg_get_function_identity_arguments(p.oid) AS arguments,pg_catalog.has_function_privilege(r.oid,p.oid,'EXECUTE') AS execute\n FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace\n WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name) AND n.nspname IN('public','mmapp_control') AND p.prokind IN('f','p')\n LIMIT 1025),\nc_effectiveSequences AS NOT MATERIALIZED (SELECT r.rolname,c.relname,pg_catalog.has_sequence_privilege(r.oid,c.oid,'USAGE') AS usage,\n pg_catalog.has_sequence_privilege(r.oid,c.oid,'SELECT') AS read,pg_catalog.has_sequence_privilege(r.oid,c.oid,'UPDATE') AS update\n FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name) AND n.nspname='public' AND c.relkind='S' LIMIT 129),\nc_events AS NOT MATERIALIZED (SELECT e.evtname,e.evtevent,e.evtenabled,pg_catalog.pg_get_userbyid(e.evtowner) AS owner,e.evtfoid::text AS function_oid,e.evttags,\n n.nspname AS function_namespace,p.proname AS function_name FROM pg_catalog.pg_event_trigger e JOIN pg_catalog.pg_proc p ON p.oid=e.evtfoid\n JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace LIMIT 33),\nc_parameters AS NOT MATERIALIZED (SELECT r.rolname,v.name,pg_catalog.has_parameter_privilege(r.oid,v.name,'SET') AS can_set\n FROM pg_catalog.pg_roles r CROSS JOIN(VALUES('event_triggers'),('session_replication_role'))v(name)\n WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name)),\nc_rawSettings AS NOT MATERIALIZED (SELECT COALESCE(d.datname,'all-databases') AS database,COALESCE(r.rolname,'all-roles') AS role,s.setconfig\n FROM pg_catalog.pg_db_role_setting s LEFT JOIN pg_catalog.pg_database d ON d.oid=s.setdatabase LEFT JOIN pg_catalog.pg_roles r ON r.oid=s.setrole\n WHERE(s.setdatabase=0 OR d.datname=current_database())AND(s.setrole=0 OR r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name)) LIMIT 33),\nc_roles AS NOT MATERIALIZED (SELECT rolname,rolsuper,rolcreatedb,rolcreaterole,rolreplication,rolbypassrls,rolinherit,rolcanlogin FROM pg_catalog.pg_roles WHERE rolname IN($5::pg_catalog.name,$2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name,$4::pg_catalog.name)),\nc_roleGrants AS NOT MATERIALIZED (SELECT r.rolname,c.relname,pg_catalog.has_table_privilege(r.oid,c.oid,'SELECT') AS read,\n pg_catalog.has_table_privilege(r.oid,c.oid,'INSERT') AS insert,pg_catalog.has_table_privilege(r.oid,c.oid,'UPDATE') AS update,\n pg_catalog.has_table_privilege(r.oid,c.oid,'DELETE') AS delete,pg_catalog.has_table_privilege(r.oid,c.oid,'TRUNCATE') AS truncate,\n pg_catalog.has_table_privilege(r.oid,c.oid,'TRIGGER') AS trigger FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_class c\n JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name)\n AND n.nspname='public' AND c.relkind IN('r','p')),\nrecords AS (SELECT 'global'::text AS kind,'identities'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.relname),'[]'::jsonb)) AS value FROM c_identities q\nUNION ALL\nSELECT 'global'::text AS kind,'sequences'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.relname),'[]'::jsonb)) AS value FROM c_sequences q\nUNION ALL\nSELECT 'global'::text AS kind,'functions'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.namespace,q.proname,q.arguments),'[]'::jsonb)) AS value FROM c_functions q\nUNION ALL\nSELECT 'global'::text AS kind,'schemas'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.nspname),'[]'::jsonb)) AS value FROM c_schemas q\nUNION ALL\nSELECT 'global'::text AS kind,'database'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.datname),'[]'::jsonb)) AS value FROM c_database q\nUNION ALL\nSELECT 'global'::text AS kind,'effectiveSchemas'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname,q.nspname),'[]'::jsonb)) AS value FROM c_effectiveSchemas q\nUNION ALL\nSELECT 'global'::text AS kind,'effectiveDatabase'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname),'[]'::jsonb)) AS value FROM c_effectiveDatabase q\nUNION ALL\nSELECT 'global'::text AS kind,'memberships'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.granted_role,q.member,q.grantor),'[]'::jsonb)) AS value FROM c_memberships q\nUNION ALL\nSELECT 'global'::text AS kind,'effectiveFunctions'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname,q.nspname,q.proname,q.arguments),'[]'::jsonb)) AS value FROM c_effectiveFunctions q\nUNION ALL\nSELECT 'global'::text AS kind,'effectiveSequences'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname,q.relname),'[]'::jsonb)) AS value FROM c_effectiveSequences q\nUNION ALL\nSELECT 'global'::text AS kind,'events'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.evtname),'[]'::jsonb)) AS value FROM c_events q\nUNION ALL\nSELECT 'global'::text AS kind,'parameters'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname,q.name),'[]'::jsonb)) AS value FROM c_parameters q\nUNION ALL\nSELECT 'global'::text AS kind,'settings'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg((pg_catalog.to_jsonb(q)-'setconfig')||pg_catalog.jsonb_build_object('keys',ARRAY(SELECT pg_catalog.split_part(v,'=',1) FROM pg_catalog.unnest(q.setconfig)v),'valueSha256',pg_catalog.encode(pg_catalog.sha256(pg_catalog.convert_to(pg_catalog.to_jsonb(q.setconfig)::text,'UTF8')),'hex')) ORDER BY q.database,q.role),'[]'::jsonb)) AS value FROM c_rawSettings q\nUNION ALL\nSELECT 'global'::text AS kind,'roles'::text AS identity,pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname),'[]'::jsonb)) AS value FROM c_roles q\nUNION ALL\nSELECT 'global','source_size',pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q)),'[]'::jsonb)) FROM(SELECT\n (SELECT count(*) FROM(SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relkind IN('r','p'))s) AS tables,\n (SELECT COALESCE(sum(pg_catalog.octet_length(p.prosrc)),0)::text FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace WHERE n.nspname IN('public','mmapp_control')) AS function_bytes,\n (SELECT COALESCE(sum(pg_catalog.octet_length(d.adbin::text)),0)::text FROM pg_catalog.pg_attrdef d JOIN pg_catalog.pg_class c ON c.oid=d.adrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public') AS default_bytes,\n (SELECT COALESCE(sum(pg_catalog.octet_length(k.conbin::text)),0)::text FROM pg_catalog.pg_constraint k JOIN pg_catalog.pg_namespace n ON n.oid=k.connamespace WHERE n.nspname IN('public','mmapp_control')) AS check_bytes,\n (SELECT COALESCE(sum(pg_catalog.octet_length(t.tgqual::text)+pg_catalog.octet_length(t.tgargs)),0)::text FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public') AS trigger_bytes)q\nUNION ALL\nSELECT 'global','publisher_column_escape',pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q)),'[]'::jsonb)) FROM(SELECT c.relname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relkind IN('r','p') AND c.relname<>'schema_migrations' AND(pg_catalog.has_any_column_privilege($4::pg_catalog.name::pg_catalog.name,c.oid,'SELECT') OR pg_catalog.has_any_column_privilege($4::pg_catalog.name::pg_catalog.name,c.oid,'INSERT') OR pg_catalog.has_any_column_privilege($4::pg_catalog.name::pg_catalog.name,c.oid,'UPDATE') OR pg_catalog.has_any_column_privilege($4::pg_catalog.name::pg_catalog.name,c.oid,'REFERENCES')) LIMIT 1)q\nUNION ALL\nSELECT 'global','namespace_policy',pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q)),'[]'::jsonb)) FROM(SELECT\n EXISTS(SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relkind NOT IN('r','p','S','i','I')) AS relations,\n EXISTS(SELECT 1 FROM pg_catalog.pg_rewrite r JOIN pg_catalog.pg_class c ON c.oid=r.ev_class JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public') AS rules,\n EXISTS(SELECT 1 FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace WHERE n.nspname IN('public','mmapp_control') AND p.prokind NOT IN('f','p')) AS routines,\n EXISTS(SELECT 1 FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON n.oid=t.typnamespace LEFT JOIN pg_catalog.pg_class c ON c.oid=t.typrelid LEFT JOIN pg_catalog.pg_type e ON e.oid=t.typelem LEFT JOIN pg_catalog.pg_class ec ON ec.oid=e.typrelid WHERE n.nspname='public' AND(t.typtype='c' AND c.relkind IN('r','p') OR t.typelem<>0 AND e.typarray=t.oid AND ec.relkind IN('r','p')) IS NOT TRUE) AS types,\n EXISTS(SELECT 1 FROM pg_catalog.pg_namespace n WHERE n.nspname NOT IN('public','mmapp_control','pg_catalog','information_schema') AND n.nspname!~'^pg_(toast|temp_)') AS namespaces,\n EXISTS(SELECT 1 FROM pg_catalog.pg_default_acl d JOIN pg_catalog.pg_roles r ON r.oid=d.defaclrole WHERE r.rolname IN($5::pg_catalog.name,$2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name)) AS default_acl)q\nUNION ALL\nSELECT 'global','base_tables',pg_catalog.jsonb_build_object('rows',COALESCE(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.relname COLLATE \"C\"),'[]'::jsonb)) FROM(SELECT * FROM c_tables WHERE NOT relispartition ORDER BY relname COLLATE \"C\" LIMIT 104)q\nUNION ALL\nSELECT 'leaf','!inventory_counts',pg_catalog.jsonb_build_object('base',(SELECT count(*)::int FROM c_tables WHERE NOT relispartition),'leaf',(SELECT count(*)::int FROM c_tables WHERE relispartition))\nUNION ALL\nSELECT CASE WHEN bundle_relation.relispartition THEN 'leaf' ELSE 'base' END,bundle_relation.relname,pg_catalog.jsonb_build_object('table',pg_catalog.to_jsonb(bundle_relation),\n'columns',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.attnum) FROM(SELECT c.relname,a.attnum::int,a.attname,pg_catalog.format_type(a.atttypid,a.atttypmod) AS type,\n a.attnotnull,a.attidentity,a.attgenerated,a.attstorage,a.attcompression,a.attacl::text[] AS acl,pg_catalog.pg_get_expr(d.adbin,d.adrelid) AS default_expression\n FROM pg_catalog.pg_attribute a JOIN pg_catalog.pg_class c ON c.oid=a.attrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n LEFT JOIN pg_catalog.pg_attrdef d ON d.adrelid=a.attrelid AND d.adnum=a.attnum\n WHERE n.nspname='public' AND c.relkind IN('r','p') AND a.attnum>0 AND NOT a.attisdropped AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb),\n'triggers',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.tgname) FROM(SELECT t.oid::text AS oid,c.relname,t.tgname,t.tgtype::int,t.tgenabled,t.tgisinternal,t.tgfoid::text,t.tgparentid::text,t.tgconstraint::text,t.tgdeferrable,t.tginitdeferred,t.tgoldtable,t.tgnewtable,\n t.tgnargs,octet_length(t.tgargs)::int AS arg_bytes,t.tgqual IS NULL AS unconditional,pg_catalog.pg_get_triggerdef(t.oid) AS definition\n FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb),\n'constraints',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.conname) FROM(SELECT c.relname,k.conname,k.contype,k.convalidated,k.condeferrable,k.condeferred,\n pg_catalog.pg_get_constraintdef(k.oid) AS definition FROM pg_catalog.pg_constraint k JOIN pg_catalog.pg_class c ON c.oid=k.conrelid\n JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb),\n'indexes',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.index_name) FROM(SELECT c.relname,i.relname AS index_name,x.indisvalid,x.indisready,x.indisunique,x.indisprimary,\n pg_catalog.pg_get_indexdef(i.oid) AS definition FROM pg_catalog.pg_index x JOIN pg_catalog.pg_class c ON c.oid=x.indrelid\n JOIN pg_catalog.pg_class i ON i.oid=x.indexrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace\n WHERE n.nspname='public' AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb),\n'roleGrants',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.rolname) FROM(SELECT r.rolname,c.relname,pg_catalog.has_table_privilege(r.oid,c.oid,'SELECT') AS read,\n pg_catalog.has_table_privilege(r.oid,c.oid,'INSERT') AS insert,pg_catalog.has_table_privilege(r.oid,c.oid,'UPDATE') AS update,\n pg_catalog.has_table_privilege(r.oid,c.oid,'DELETE') AS delete,pg_catalog.has_table_privilege(r.oid,c.oid,'TRUNCATE') AS truncate,\n pg_catalog.has_table_privilege(r.oid,c.oid,'TRIGGER') AS trigger FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_class c\n JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE r.rolname IN($2::pg_catalog.name,$3::pg_catalog.name,$1::pg_catalog.name,$4::pg_catalog.name)\n AND n.nspname='public' AND c.relkind IN('r','p') AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb),\n'inheritance',COALESCE((SELECT pg_catalog.jsonb_agg(pg_catalog.to_jsonb(q) ORDER BY q.parent,q.child) FROM(SELECT p.relname AS parent,c.relname AS child FROM pg_catalog.pg_inherits i\n JOIN pg_catalog.pg_class p ON p.oid=i.inhparent JOIN pg_catalog.pg_class c ON c.oid=i.inhrelid JOIN pg_catalog.pg_namespace n ON n.oid=p.relnamespace\n WHERE n.nspname='public' AND p.relkind IN('r','p') AND c.oid=bundle_relation.oid::oid)q),'[]'::jsonb)) FROM c_tables bundle_relation),\nnumbered AS(SELECT row_number() OVER(ORDER BY CASE kind WHEN 'global' THEN 0 WHEN 'base' THEN 1 ELSE 2 END,identity COLLATE \"C\") AS record_no,kind,identity,pg_catalog.convert_to(pg_catalog.jsonb_build_object('kind',kind,'identity',identity,'value',value)::text,'UTF8') AS encoded FROM records),\nframed AS(SELECT *,CASE WHEN pg_catalog.octet_length(encoded)>2097152 THEN 0 ELSE (pg_catalog.octet_length(encoded)+4095)/4096 END AS chunks FROM numbered)\nSELECT record_no::text AS record_id,part::int AS chunk_index,chunks::int AS chunk_count,kind,identity,CASE WHEN chunks=0 THEN NULL::bytea ELSE substring(encoded FROM part*4096+1 FOR 4096) END AS payload FROM framed CROSS JOIN LATERAL pg_catalog.generate_series(0,GREATEST(0,chunks-1))part ORDER BY record_no,part"
diff --git a/backend/scripts/writer-profile/fixed56-build-definition.ts b/backend/scripts/writer-profile/fixed56-build-definition.ts
new file mode 100644
index 00000000..86b77d20
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed56-build-definition.ts
@@ -0,0 +1,22 @@
+import { canonical, sha } from "./application-writer-profile-canonical.js"
+import { sorted, type Inventory } from "./catalogue-projection.js"
+import { FIXED44_ROLE_TEMPLATE } from "./fixed44-build-definition.js"
+import { FIXED56_DELTA } from "./fixed56-build-delta.js"
+
+export const BUILD56_PROVENANCE = Object.freeze({
+ format: "source56-build-candidate-v1",
+ manifestSha256: "b371d8d261f7dd69cf0e2ebc48d4316e3ad804360046bbaaf20e715da8812521",
+ templateSha256: "e6c2ea106e6fcbd8af7a3ed3ded052c2267be92d3bad41c2ef9e62ec95d2b3d9",
+})
+
+export const FIXED56_ROLE_TEMPLATE: Readonly = Object.freeze(Object.fromEntries(
+ Object.entries(FIXED44_ROLE_TEMPLATE).map(([section, rows]) => {
+ const delta = FIXED56_DELTA[section]
+ const removed = new Set(delta?.remove)
+ return [section, sorted([...rows.filter((_, index) => !removed.has(index)), ...(delta?.add ?? [])])]
+ }),
+))
+
+if (sha(canonical(FIXED56_ROLE_TEMPLATE)) !== BUILD56_PROVENANCE.templateSha256) {
+ throw new Error("Fixed56 writer catalogue changed")
+}
diff --git a/backend/scripts/writer-profile/fixed56-build-delta.ts b/backend/scripts/writer-profile/fixed56-build-delta.ts
new file mode 100644
index 00000000..81ef239f
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed56-build-delta.ts
@@ -0,0 +1,303 @@
+// Build data from the owned PostgreSQL 18 current56 ACL candidate. Removal indices are relative to the exact fixed44 template.
+import type { Row } from "./catalogue-projection.js"
+
+export const FIXED56_DELTA: Readonly> = {
+ columns: {
+ remove: [],
+ add: [
+ {"acl":["@mm-role:runtime@=w/@mm-role:operator@"],"attcompression":"","attgenerated":"","attidentity":"","attname":"capture_proof","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"server_probe_terminal_proofs","type":"text"},
+ {"acl":["@mm-role:runtime@=w/@mm-role:operator@"],"attcompression":"","attgenerated":"","attidentity":"","attname":"proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_probe_retired_sources","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"action_id","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_token","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_poll_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_token","attnotnull":true,"attnum":5,"attstorage":"p","default_expression":null,"relname":"mcp_ordinary_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_token","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":null,"relname":"server_probe_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_xid","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":"pg_current_xact_id()","relname":"server_poll_retirement_claims","type":"xid8"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_xid","attnotnull":true,"attnum":6,"attstorage":"p","default_expression":"pg_current_xact_id()","relname":"mcp_ordinary_retirement_claims","type":"xid8"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"claim_xid","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":"pg_current_xact_id()","relname":"server_probe_retirement_claims","type":"xid8"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"mcp_ordinary_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"connection_id","attnotnull":true,"attnum":4,"attstorage":"p","default_expression":null,"relname":"server_probe_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"idempotency_digest","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"idempotency_digest","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_probe_terminal_proofs","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"old_archive_proof","attnotnull":true,"attnum":2,"attstorage":"x","default_expression":null,"relname":"server_poll_retirement_claims","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"mcp_ordinary_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_terminal_proofs","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_probe_retired_sources","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"operation_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_probe_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"plan_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"mcp_ordinary_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"plan_id","attnotnull":true,"attnum":3,"attstorage":"p","default_expression":null,"relname":"server_probe_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_poll_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_retired_sources","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":1,"attstorage":"p","default_expression":null,"relname":"server_probe_retirement_claims","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"receipt_id","attnotnull":true,"attnum":2,"attstorage":"p","default_expression":null,"relname":"server_probe_terminal_proofs","type":"uuid"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_retired_sources","type":"jsonb"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source","attnotnull":true,"attnum":3,"attstorage":"x","default_expression":null,"relname":"server_probe_terminal_proofs","type":"jsonb"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"mcp_ordinary_retirement_claims","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":true,"attnum":4,"attstorage":"x","default_expression":null,"relname":"server_probe_terminal_proofs","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"source_proof","attnotnull":true,"attnum":5,"attstorage":"x","default_expression":null,"relname":"server_probe_retirement_claims","type":"text"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target_global","attnotnull":true,"attnum":7,"attstorage":"p","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"boolean"},
+ {"acl":null,"attcompression":"","attgenerated":"","attidentity":"","attname":"target_server_ids","attnotnull":true,"attnum":6,"attstorage":"x","default_expression":null,"relname":"mcp_operation_replay_tombstones","type":"bigint[]"},
+ ],
+ },
+ constraints: {
+ remove: [725],
+ add: [
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombston_connection_id_idempotency_dig_key","contype":"u","convalidated":true,"definition":"UNIQUE (connection_id, idempotency_digest)","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_action_id_check","contype":"c","convalidated":true,"definition":"CHECK (((length(action_id) >= 1) AND (length(action_id) <= 200)))","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_action_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL action_id","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_idempotency_digest_check","contype":"c","convalidated":true,"definition":"CHECK ((idempotency_digest ~ '^[0-9a-f]{64}$'::text))","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_idempotency_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL idempotency_digest","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id)","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_plan_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (plan_id)","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL plan_id","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_target_global_not_null","contype":"n","convalidated":true,"definition":"NOT NULL target_global","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_target_server_ids_check","contype":"c","convalidated":true,"definition":"CHECK ((array_position(target_server_ids, NULL::bigint) IS NULL))","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_operation_replay_tombstones_target_server_ids_not_null","contype":"n","convalidated":true,"definition":"NOT NULL target_server_ids","relname":"mcp_operation_replay_tombstones"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_claim_token_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_token","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_claim_xid_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_xid","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_connection_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (connection_id) REFERENCES mcp_connections(id)","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id)","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_plan_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (plan_id)","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL plan_id","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_source_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((source_proof ~ '^[0-9a-f]{64}$'::text))","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"mcp_ordinary_retirement_claims_source_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_proof","relname":"mcp_ordinary_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_archives_version_check","contype":"c","convalidated":true,"definition":"CHECK (((version = 1) OR ((version = 2) AND (decoded_bytes <= 24576) AND (compressed_bytes <= 24576) AND (ciphertext_bytes <= 33000))))","relname":"server_poll_archives"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_claim_token_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_token","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_claim_xid_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_xid","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_old_archive_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((old_archive_proof ~ '^[0-9a-f]{64}$'::text))","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_old_archive_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL old_archive_proof","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_poll_storage_admissions(receipt_id) ON DELETE CASCADE","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_poll_retirement_claims_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_poll_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_check","contype":"c","convalidated":true,"definition":"CHECK (((NOT ((source ->> 'version'::text) IS DISTINCT FROM '1'::text)) AND (NOT ((source ->> 'receiptId'::text) IS DISTINCT FROM (receipt_id)::text)) AND (NOT ((source ->> 'executionId'::text) IS DISTINCT FROM (operation_id)::text))))","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operation_replay_tombstones(operation_id)","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_operation_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (operation_id)","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((proof ~ '^[0-9a-f]{64}$'::text))","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL proof","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_receipt_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (receipt_id) REFERENCES server_probe_storage_admissions(receipt_id) ON DELETE CASCADE","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_source_check","contype":"c","convalidated":true,"definition":"CHECK (((jsonb_typeof(source) = 'object'::text) AND ((octet_length((source)::text) >= 1) AND (octet_length((source)::text) <= 8192))))","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retired_sources_source_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source","relname":"server_probe_retired_sources"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_claim_token_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_token","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_claim_xid_not_null","contype":"n","convalidated":true,"definition":"NOT NULL claim_xid","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_connection_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL connection_id","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_operation_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (operation_id)","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (receipt_id)","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_plan_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (plan_id)","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_plan_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL plan_id","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_source_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((source_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_retirement_claims_source_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_proof","relname":"server_probe_retirement_claims"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_capture_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((capture_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_capture_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL capture_proof","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_check","contype":"c","convalidated":true,"definition":"CHECK (((NOT ((source ->> 'version'::text) IS DISTINCT FROM '1'::text)) AND (NOT ((source ->> 'executionId'::text) IS DISTINCT FROM (operation_id)::text)) AND (NOT ((source ->> 'receiptId'::text) IS DISTINCT FROM (receipt_id)::text))))","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_idempotency_digest_check","contype":"c","convalidated":true,"definition":"CHECK ((idempotency_digest ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_idempotency_digest_not_null","contype":"n","convalidated":true,"definition":"NOT NULL idempotency_digest","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_operation_id_fkey","contype":"f","convalidated":true,"definition":"FOREIGN KEY (operation_id) REFERENCES mcp_operations(id)","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_operation_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL operation_id","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_pkey","contype":"p","convalidated":true,"definition":"PRIMARY KEY (operation_id)","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_receipt_id_key","contype":"u","convalidated":true,"definition":"UNIQUE (receipt_id)","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_receipt_id_not_null","contype":"n","convalidated":true,"definition":"NOT NULL receipt_id","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_source_check","contype":"c","convalidated":true,"definition":"CHECK (((jsonb_typeof(source) = 'object'::text) AND ((octet_length((source)::text) >= 1) AND (octet_length((source)::text) <= 8192))))","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_source_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_source_proof_check","contype":"c","convalidated":true,"definition":"CHECK ((source_proof ~ '^[a-f0-9]{64}$'::text))","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":false,"condeferred":false,"conname":"server_probe_terminal_proofs_source_proof_not_null","contype":"n","convalidated":true,"definition":"NOT NULL source_proof","relname":"server_probe_terminal_proofs"},
+ {"condeferrable":true,"condeferred":true,"conname":"server_poll_retirement_final_guard","contype":"t","convalidated":true,"definition":"TRIGGER DEFERRABLE INITIALLY DEFERRED","relname":"server_poll_archives"},
+ ],
+ },
+ database: {
+ remove: [0],
+ add: [
+ {"acl":["@mm-role:capture@=c/@mm-role:control@","@mm-role:control@=CTc/@mm-role:control@","@mm-role:operator@=c/@mm-role:control@","@mm-role:publisher@=c/@mm-role:control@","@mm-role:runtime@=c/@mm-role:control@"],"datname":"current-database","owner":"@mm-role:control@"},
+ ],
+ },
+ effectiveFunctions: {
+ remove: [],
+ add: [
+ {"arguments":"","execute":true,"nspname":"public","proname":"mcp_ordinary_retirement_claim_immutable","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"mcp_ordinary_retirement_claim_immutable","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"mcp_ordinary_retirement_claim_immutable","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"mcp_ordinary_retirement_claim_immutable","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_claim_immutable","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_claim_immutable","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_claim_immutable","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_claim_immutable","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_final_guard","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_final_guard","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_final_guard","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_final_guard","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_requires_claim","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_requires_claim","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_requires_claim","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_poll_retirement_requires_claim","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_immutable","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_immutable","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_immutable","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_immutable","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_insert_guard","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_insert_guard","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_insert_guard","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retired_source_insert_guard","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retirement_claim_guard","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retirement_claim_guard","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retirement_claim_guard","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_retirement_claim_guard","rolname":"@mm-role:runtime@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_terminal_proof_guard","rolname":"@mm-role:capture@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_terminal_proof_guard","rolname":"@mm-role:operator@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_terminal_proof_guard","rolname":"@mm-role:publisher@"},
+ {"arguments":"","execute":true,"nspname":"public","proname":"server_probe_terminal_proof_guard","rolname":"@mm-role:runtime@"},
+ {"arguments":"target_receipt uuid, current_retention integer","execute":true,"nspname":"public","proname":"server_probe_retired_gc_allowed","rolname":"@mm-role:capture@"},
+ {"arguments":"target_receipt uuid, current_retention integer","execute":true,"nspname":"public","proname":"server_probe_retired_gc_allowed","rolname":"@mm-role:operator@"},
+ {"arguments":"target_receipt uuid, current_retention integer","execute":true,"nspname":"public","proname":"server_probe_retired_gc_allowed","rolname":"@mm-role:publisher@"},
+ {"arguments":"target_receipt uuid, current_retention integer","execute":true,"nspname":"public","proname":"server_probe_retired_gc_allowed","rolname":"@mm-role:runtime@"},
+ ],
+ },
+ functions: {
+ remove: [7,8,12,19,31,32],
+ add: [
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.mcp_ordinary_retirement_claim_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(\n SELECT 1 FROM public.mcp_operations o JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n WHERE o.id=NEW.operation_id AND o.plan_id=NEW.plan_id AND o.connection_id=NEW.connection_id\n AND o.state='applied' AND o.verification='passed' AND o.error_code IS NULL\n AND isfinite(o.finished_at) AND o.finished_at>'kind'='service'\n AND s.intended_state->>'service'='routing.community.scoped.recover'\n AND s.intended_state->'input'->>'mode'='manual'\n AND s.intended_state->'input'->>'sourceOperationId'=NEW.source_operation_id::text\n AND s.intended_state->'input'->>'receiptId'=NEW.recovery_receipt_id::text\n ) THEN RAISE EXCEPTION 'manual inverse requires current exact running recovery'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":null,"prokind":"f","proname":"mcp_scoped_recovery_manual_version","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_archive_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF TG_OP='DELETE' AND public.server_poll_storage_gc_allowed(OLD.receipt_id) THEN RETURN OLD; END IF;\n IF TG_OP='UPDATE' AND OLD.version=1 AND NEW.version=2\n AND current_setting('mm.poll_retire_receipt',true)=OLD.receipt_id::text\n AND NEW.ciphertext_bytes<=OLD.ciphertext_bytes\n AND NEW.ciphertext ~ '^[A-Za-z0-9+/]+={0,2}$'\n AND replace(encode(decode(NEW.ciphertext,'base64'),'base64'),E'\\n','')=NEW.ciphertext\n AND octet_length(decode(NEW.ciphertext,'base64'))=NEW.compressed_bytes+28\n AND (to_jsonb(OLD)-ARRAY['version','source_digest','source_sha256','decoded_bytes','compressed_bytes','ciphertext','ciphertext_bytes','archive_proof'])=\n (to_jsonb(NEW)-ARRAY['version','source_digest','source_sha256','decoded_bytes','compressed_bytes','ciphertext','ciphertext_bytes','archive_proof'])\n AND EXISTS(\n SELECT 1 FROM public.server_poll_storage_admissions a JOIN public.mcp_operations o ON o.id=a.execution_id AND o.connection_id=a.connection_id\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN public.mcp_operation_steps s ON s.operation_id=o.id AND s.step_index=0\n JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=o.id AND t.plan_id=p.id AND t.connection_id=o.connection_id\n JOIN public.mcp_connections c ON c.id=o.connection_id AND c.owner_id=a.owner_id\n WHERE a.receipt_id=OLD.receipt_id AND a.identity_kind='mcp' AND a.storage_state='compacted'\n AND a.execution_id=OLD.execution_id AND a.connection_id=OLD.connection_id AND a.owner_id=OLD.owner_id\n AND a.binding_proof=OLD.binding_proof AND a.context_proof=OLD.context_proof AND a.archive_bytes=OLD.ciphertext_bytes\n AND a.original_activity_at=OLD.original_activity_at AND a.authority_expires_at=OLD.original_expires_at\n AND o.state='applied' AND o.verification='passed' AND o.error_code IS NULL AND isfinite(o.finished_at)\n AND o.finished_at0\n ) THEN RETURN NEW; END IF;\n RAISE EXCEPTION 'poll archive immutable outside exact retirement or original lifetime GC';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["TimeZone=UTC","search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_archive_immutable","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_retirement_claim_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(\n SELECT 1 FROM public.server_poll_archives r WHERE r.receipt_id=NEW.receipt_id\n AND r.version=1 AND r.archive_proof=NEW.old_archive_proof\n ) THEN RETURN NEW; END IF;\n IF TG_OP='DELETE' AND pg_trigger_depth()>1 AND NOT EXISTS(\n SELECT 1 FROM public.server_poll_storage_admissions a WHERE a.receipt_id=OLD.receipt_id\n ) THEN RETURN OLD; END IF;\n RAISE EXCEPTION 'poll retirement claim cannot be replaced or reopened';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_retirement_claim_immutable","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_retirement_final_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF NOT EXISTS(SELECT 1 FROM public.mcp_operation_replay_tombstones t\n WHERE t.operation_id=NEW.execution_id AND t.connection_id=NEW.connection_id AND t.action_id='servers.poll'\n AND t.target_global AND NOT EXISTS(SELECT 1 FROM public.mcp_plans p WHERE p.id=t.plan_id))\n OR EXISTS(SELECT 1 FROM public.mcp_operations o WHERE o.id=NEW.execution_id)\n OR NOT public.server_poll_storage_accounting_valid()\n THEN RAISE EXCEPTION 'poll retirement is incomplete'; END IF;\n RETURN NULL;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_retirement_final_guard","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_retirement_requires_claim()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF NOT EXISTS(SELECT 1 FROM public.server_poll_retirement_claims c\n WHERE c.receipt_id=OLD.receipt_id AND c.old_archive_proof=OLD.archive_proof\n AND c.claim_token::text=current_setting('mm.poll_retire_claim',true)\n AND c.claim_xid<>pg_current_xact_id())\n THEN RAISE EXCEPTION 'poll retirement requires prior exact claim'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_retirement_requires_claim","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_admission_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE retention integer; charged integer; r public.server_poll_archives%ROWTYPE;\nBEGIN\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n IF TG_OP='DELETE' THEN\n IF NOT public.server_poll_storage_gc_allowed(OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id) THEN RAISE EXCEPTION 'poll lifetime or children prevent admission deletion'; END IF;\n UPDATE public.server_poll_storage_usage SET admissions=admissions-CASE WHEN OLD.storage_state='full' THEN 1 ELSE 0 END,\n compacted_admissions=compacted_admissions-CASE WHEN OLD.storage_state='compacted' THEN 1 ELSE 0 END,\n archive_bytes=archive_bytes-COALESCE(OLD.archive_bytes,0),\n reserved_rows=reserved_rows-CASE WHEN OLD.storage_state='full' THEN 4019 ELSE 2 END,\n reserved_bytes=reserved_bytes-CASE WHEN OLD.storage_state='full' THEN 8421376 ELSE 32768+OLD.archive_bytes END\n WHERE scope IN('global','owner:'||OLD.owner_id);\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll quota refund mismatch'; END IF; RETURN OLD;\n END IF;\n IF TG_OP='UPDATE' THEN\n IF OLD.storage_state='compacted' AND NEW.storage_state='compacted'\n AND current_setting('mm.poll_retire_receipt',true)=OLD.receipt_id::text\n AND (to_jsonb(OLD)-'archive_bytes')=(to_jsonb(NEW)-'archive_bytes') THEN\n SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND version=2;\n IF NOT FOUND OR r.ciphertext_bytes<>NEW.archive_bytes OR NEW.archive_bytes>OLD.archive_bytes\n OR r.execution_id<>OLD.execution_id OR r.connection_id<>OLD.connection_id OR r.owner_id<>OLD.owner_id\n THEN RAISE EXCEPTION 'retired poll charge source mismatch'; END IF;\n UPDATE public.server_poll_storage_usage\n SET archive_bytes=archive_bytes-OLD.archive_bytes+NEW.archive_bytes,\n reserved_bytes=reserved_bytes-OLD.archive_bytes+NEW.archive_bytes\n WHERE scope IN ('global','owner:'||OLD.owner_id) AND compacted_admissions>=1 AND archive_bytes>=OLD.archive_bytes;\n GET DIAGNOSTICS charged=ROW_COUNT;\n IF charged<>2 THEN RAISE EXCEPTION 'retired poll charge adjustment mismatch'; END IF;\n RETURN NEW;\n END IF;\n -- This durable one-shot marker is written and ACKed in its OWN transaction\n -- before archive construction. A committed/unknown claim never resets and\n -- the worker never retries destructive work against an already claimed full\n -- source. Claim time is maintenance metadata, not renewed execution activity.\n IF OLD.storage_state='full' AND NEW.storage_state='full' AND OLD.compaction_claim IS NULL AND OLD.compaction_claimed_at IS NULL AND OLD.compaction_claim_xid IS NULL\n AND NEW.compaction_claim IS NOT NULL AND NEW.compaction_claim_xid IS NULL\n AND(to_jsonb(OLD)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])=(to_jsonb(NEW)-ARRAY['compaction_claim','compaction_claimed_at','compaction_claim_xid'])\n AND public.server_poll_storage_compact_allowed(OLD.receipt_id)\n THEN NEW.compaction_claimed_at:=clock_timestamp(); NEW.compaction_claim_xid:=pg_current_xact_id(); RETURN NEW; END IF;\n IF(to_jsonb(OLD)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) IS DISTINCT FROM\n (to_jsonb(NEW)-ARRAY['claim_token','claim_attempted_at','used_rows','used_bytes','storage_state','compact_at','archive_bytes','original_activity_at']) THEN RAISE EXCEPTION 'poll admission identity is immutable'; END IF;\n IF OLD.storage_state<>'full' THEN RAISE EXCEPTION 'compacted poll identity cannot reopen or change'; END IF;\n IF NEW.storage_state='compacted' THEN\n SELECT * INTO r FROM public.server_poll_archives WHERE receipt_id=OLD.receipt_id AND compaction_xid=pg_current_xact_id();\n IF NOT FOUND OR NEW.used_rows<>OLD.used_rows OR NEW.used_bytes<>OLD.used_bytes OR NEW.claim_token IS DISTINCT FROM OLD.claim_token\n OR NEW.claim_attempted_at IS DISTINCT FROM OLD.claim_attempted_at OR NEW.archive_bytes<>r.ciphertext_bytes OR NEW.original_activity_at<>r.original_activity_at\n OR EXISTS(SELECT 1 FROM public.server_poll_executions WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_intents WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_acks WHERE receipt_id=OLD.receipt_id)\n OR EXISTS(SELECT 1 FROM public.server_poll_receipts WHERE receipt_id=OLD.receipt_id) OR EXISTS(SELECT 1 FROM public.server_poll_quarantines WHERE receipt_id=OLD.receipt_id)\n THEN RAISE EXCEPTION 'poll compaction requires the complete current-transaction archive'; END IF;\n NEW.compact_at:=r.created_at;\n UPDATE public.server_poll_storage_usage SET admissions=admissions-1,compacted_admissions=compacted_admissions+1,\n archive_bytes=archive_bytes+r.ciphertext_bytes,reserved_rows=reserved_rows-4019+2,reserved_bytes=reserved_bytes-8421376+32768+r.ciphertext_bytes\n WHERE scope IN('global','owner:'||OLD.owner_id) AND admissions>=1;\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll compaction charge mismatch'; END IF;\n RETURN NEW;\n END IF;\n IF NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL THEN RAISE EXCEPTION 'full poll cannot carry archive metadata'; END IF;\n IF OLD.claim_token IS NOT NULL AND NEW.claim_token IS NULL AND OLD.claim_attempted_at IS NULL AND NEW.claim_attempted_at IS NOT NULL\n AND NEW.used_rows=OLD.used_rows AND NEW.used_bytes=OLD.used_bytes AND OLD.authority_expires_at>clock_timestamp()\n THEN NEW.claim_attempted_at:=clock_timestamp(); RETURN NEW; END IF;\n IF OLD.claim_token IS NOT DISTINCT FROM NEW.claim_token AND OLD.claim_attempted_at IS NOT DISTINCT FROM NEW.claim_attempted_at\n AND NEW.used_rows=OLD.used_rows+1 AND NEW.used_bytes>OLD.used_bytes THEN RETURN NEW; END IF;\n RAISE EXCEPTION 'poll admission cannot refresh, reopen or refund itself';\n END IF;\n IF NEW.storage_state<>'full' OR NEW.compact_at IS NOT NULL OR NEW.archive_bytes IS NOT NULL OR NEW.original_activity_at IS NOT NULL\n OR NEW.compaction_claim IS NOT NULL OR NEW.compaction_claimed_at IS NOT NULL OR NEW.compaction_claim_xid IS NOT NULL\n OR NOT public.server_poll_storage_accounting_valid() THEN RAISE EXCEPTION 'new poll requires full reservation and exact ledger'; END IF;\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE id=1;\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 OR NEW.authority_issued_at>clock_timestamp() OR NEW.authority_expires_at<=clock_timestamp()\n OR NEW.claim_token IS NULL OR NEW.claim_attempted_at IS NOT NULL OR NEW.used_rows<>0 OR NEW.used_bytes<>0 THEN RAISE EXCEPTION 'new poll admission needs original live authority'; END IF;\n IF EXISTS(SELECT 1 FROM public.server_poll_storage_admissions WHERE receipt_id=NEW.receipt_id OR(identity_kind=NEW.identity_kind AND execution_id=NEW.execution_id)) THEN RAISE EXCEPTION 'poll identity already spent'; END IF;\n NEW.created_at:=clock_timestamp(); NEW.retention_days:=retention; NEW.safety_ms:=60000;\n NEW.gc_not_before:=NEW.authority_expires_at+make_interval(days=>retention)+interval '60 seconds';\n INSERT INTO public.server_poll_storage_usage(scope) VALUES('owner:'||NEW.owner_id) ON CONFLICT DO NOTHING;\n IF(SELECT count(*) FROM public.server_poll_storage_usage WHERE scope IN('global','owner:'||NEW.owner_id)\n AND admissions2 THEN RAISE EXCEPTION 'poll admission quota exhausted'; END IF;\n UPDATE public.server_poll_storage_usage SET admissions=admissions+1,reserved_rows=reserved_rows+4019,reserved_bytes=reserved_bytes+8421376 WHERE scope IN('global','owner:'||NEW.owner_id);\n GET DIAGNOSTICS charged=ROW_COUNT; IF charged<>2 THEN RAISE EXCEPTION 'poll admission quota unavailable'; END IF;\n RETURN NEW;\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["TimeZone=UTC","search_path=pg_catalog, public"],"prokind":"f","proname":"server_poll_storage_admission_guard","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_retired_source_immutable()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF TG_OP='DELETE' THEN\n IF current_setting('mm.probe_storage_gc',true)='on'\n AND current_setting('mm.probe_retired_gc_receipt',true)=OLD.receipt_id::text\n AND current_setting('mm.probe_retired_gc_proof',true)=OLD.proof\n AND NOT EXISTS(SELECT 1 FROM public.server_probe_storage_admissions WHERE receipt_id=OLD.receipt_id)\n AND NOT EXISTS(SELECT 1 FROM public.server_probe_executions WHERE receipt_id=OLD.receipt_id)\n AND NOT EXISTS(SELECT 1 FROM public.server_probe_execution_payloads WHERE receipt_id=OLD.receipt_id)\n AND NOT EXISTS(SELECT 1 FROM public.server_probe_execution_stages WHERE receipt_id=OLD.receipt_id)\n THEN RETURN OLD; END IF;\n END IF;\n RAISE EXCEPTION 'retired diagnostic source is immutable';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_probe_retired_source_immutable","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_retired_source_insert_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF EXISTS(\n SELECT 1 FROM public.server_probe_retirement_claims r\n JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=r.operation_id AND t.plan_id=r.plan_id\n AND t.connection_id=r.connection_id AND t.action_id='servers.probes.run' AND NOT t.target_global\n JOIN public.mcp_operations o ON o.id=r.operation_id AND o.plan_id=r.plan_id AND o.connection_id=r.connection_id\n JOIN public.server_probe_storage_admissions a ON a.receipt_id=r.receipt_id AND a.execution_id=r.operation_id\n WHERE r.receipt_id=NEW.receipt_id AND r.operation_id=NEW.operation_id AND r.source_proof=NEW.proof\n AND r.claim_xid<>pg_current_xact_id() AND r.claim_token::text=current_setting('mm.probe_retirement_claim',true)\n AND NEW.source->>'planId'=r.plan_id::text AND NEW.source->>'connectionId'=r.connection_id::text\n AND NEW.source->>'ownerId'=a.owner_id AND NEW.source->>'bindingProof'=a.binding_proof\n AND NEW.source->'serverIds'=to_jsonb(t.target_server_ids)\n ) THEN RETURN NEW; END IF;\n RAISE EXCEPTION 'diagnostic archive requires an exact committed retirement claim';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_probe_retired_source_insert_guard","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_retirement_claim_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\n SET \"TimeZone\" TO 'UTC'\nAS $function$\nBEGIN\n IF TG_OP='INSERT' AND NEW.claim_xid=pg_current_xact_id() AND EXISTS(\n SELECT 1 FROM public.mcp_operations o\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN public.mcp_connections c ON c.id=o.connection_id\n WHERE o.id=NEW.operation_id AND p.id=NEW.plan_id AND c.id=NEW.connection_id\n AND o.state='applied' AND o.verification='inconclusive' AND o.error_code IS NULL\n AND isfinite(o.finished_at) AND o.finished_at>'ownerId'=c.owner_id AND f.source->>'connectionId'=c.id::text AND f.source->>'planId'=p.id::text)\n AND NOT EXISTS(SELECT 1 FROM public.server_probe_storage_admissions a\n WHERE a.receipt_id=NEW.receipt_id OR(a.identity_kind='mcp' AND a.execution_id=o.id))))\n ) THEN RETURN NEW; END IF;\n RAISE EXCEPTION 'diagnostic retirement claim cannot be replaced or reopened';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public","TimeZone=UTC"],"prokind":"f","proname":"server_probe_retirement_claim_guard","prosecdef":false},
+ {"acl":null,"arguments":"","definition":"CREATE OR REPLACE FUNCTION public.server_probe_terminal_proof_guard()\n RETURNS trigger\n LANGUAGE plpgsql\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nBEGIN\n IF TG_OP='INSERT' THEN\n IF EXISTS(\n SELECT 1 FROM public.mcp_operations o\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN public.mcp_connections c ON c.id=o.connection_id\n JOIN public.server_probe_storage_admissions a ON a.execution_id=o.id AND a.identity_kind='mcp' AND a.owner_id=c.owner_id\n JOIN public.server_probe_executions j ON j.receipt_id=a.receipt_id\n JOIN public.server_probe_execution_payloads b ON b.receipt_id=a.receipt_id AND b.receipt_proof=j.receipt_proof\n WHERE o.id=NEW.operation_id AND a.receipt_id=NEW.receipt_id AND a.purged_at IS NULL AND a.cancelled_at IS NULL\n AND a.claim_token IS NULL AND a.claim_attempted_at IS NOT NULL\n AND o.state='applied' AND o.verification='inconclusive' AND o.error_code IS NULL\n AND p.state='completed' AND p.operation_id='servers.probes.run' AND p.operation_version=1\n AND j.state='completed' AND j.execution_id=o.id AND j.mcp_connection_id=c.id AND j.actor_id=c.owner_id\n AND NEW.source->>'connectionId'=c.id::text AND NEW.source->>'planId'=p.id::text\n AND NEW.source->>'ownerId'=a.owner_id AND NEW.source->>'bindingProof'=a.binding_proof\n AND NEW.source->>'receiptProof'=b.receipt_proof\n AND NEW.source->>'ciphertextSha256'=encode(sha256(convert_to(b.receipt_ciphertext,'UTF8')),'hex')\n ) THEN RETURN NEW; END IF;\n ELSIF TG_OP='DELETE' THEN\n IF EXISTS(\n SELECT 1 FROM public.server_probe_retirement_claims r\n JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=r.operation_id AND t.plan_id=r.plan_id AND t.connection_id=r.connection_id\n WHERE r.operation_id=OLD.operation_id AND r.receipt_id=OLD.receipt_id AND r.source_proof=OLD.source_proof\n AND r.claim_xid<>pg_current_xact_id() AND r.claim_token::text=current_setting('mm.probe_retirement_claim',true)\n AND t.action_id='servers.probes.run' AND NOT t.target_global AND t.idempotency_digest=OLD.idempotency_digest\n AND OLD.source->'serverIds'=to_jsonb(t.target_server_ids)\n ) THEN RETURN OLD; END IF;\n END IF;\n RAISE EXCEPTION 'diagnostic terminal proof must match its original source or exact retirement claim';\nEND $function$\n","language":"plpgsql","namespace":"public","owner":"@mm-role:operator@","proconfig":["search_path=pg_catalog, public"],"prokind":"f","proname":"server_probe_terminal_proof_guard","prosecdef":false},
+ {"acl":null,"arguments":"id uuid","definition":"CREATE OR REPLACE FUNCTION public.server_poll_storage_gc_allowed(id uuid)\n RETURNS boolean\n LANGUAGE plpgsql\n SET \"TimeZone\" TO 'UTC'\n SET search_path TO 'pg_catalog', 'public'\nAS $function$\nDECLARE a public.server_poll_storage_admissions%ROWTYPE; retention integer; activity timestamptz; terminal_at timestamptz;\nBEGIN\n IF current_setting('mm.poll_storage_gc',true) IS DISTINCT FROM 'on' THEN RETURN false; END IF;\n PERFORM pg_advisory_xact_lock(hashtextextended('server-poll-storage-v1',0));\n SELECT * INTO a FROM public.server_poll_storage_admissions WHERE receipt_id=id FOR UPDATE;\n IF NOT FOUND OR a.authority_expires_at>=clock_timestamp() OR a.gc_not_before>=clock_timestamp() THEN RETURN false; END IF;\n SELECT requests_retention_days INTO retention FROM public.mcp_settings WHERE mcp_settings.id=1 FOR SHARE;\n IF retention IS NULL OR retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;\n terminal_at:=a.created_at;\n IF a.identity_kind='mcp' THEN\n IF NOT pg_try_advisory_xact_lock(hashtextextended('mcp-operation:'||a.execution_id::text,0)) THEN RETURN false; END IF;\n BEGIN\n SELECT GREATEST(o.finished_at,p.expires_at) INTO terminal_at FROM public.mcp_operations o\n JOIN public.mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id JOIN public.mcp_connections c ON c.id=o.connection_id\n WHERE o.id=a.execution_id AND o.connection_id=a.connection_id AND c.owner_id=a.owner_id AND p.operation_id='servers.poll'\n AND o.state IN('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL FOR UPDATE OF o,p NOWAIT;\n IF NOT FOUND THEN\n IF a.storage_state<>'compacted' OR EXISTS(SELECT 1 FROM public.mcp_operations o WHERE o.id=a.execution_id) OR NOT EXISTS (\n SELECT 1 FROM public.mcp_operation_replay_tombstones t JOIN public.mcp_connections c ON c.id=t.connection_id\n WHERE t.operation_id=a.execution_id AND t.connection_id=a.connection_id AND c.owner_id=a.owner_id\n AND t.action_id='servers.poll' AND t.target_global AND cardinality(t.target_server_ids)>0\n AND NOT EXISTS(SELECT 1 FROM public.mcp_plans WHERE mcp_plans.id=t.plan_id)\n ) OR EXISTS(SELECT 1 FROM public.server_poll_archives r WHERE r.receipt_id=id AND\n (r.version<>2 OR r.execution_id<>a.execution_id OR r.connection_id<>a.connection_id OR r.owner_id<>a.owner_id\n OR r.original_activity_at IS DISTINCT FROM a.original_activity_at OR r.original_expires_at<>a.authority_expires_at\n OR r.binding_proof<>a.binding_proof OR r.context_proof<>a.context_proof OR r.ciphertext_bytes<>a.archive_bytes))\n THEN RETURN false; END IF;\n terminal_at:=a.original_activity_at;\n END IF;\n IF terminal_at IS NULL THEN RETURN false; END IF;\n EXCEPTION WHEN lock_not_available THEN RETURN false; END;\n END IF;\n IF a.storage_state='compacted' THEN activity:=GREATEST(a.original_activity_at,a.authority_expires_at,terminal_at);\n ELSE\n SELECT GREATEST(a.authority_expires_at,a.created_at,COALESCE(a.claim_attempted_at,a.created_at),terminal_at,\n COALESCE((SELECT created_at FROM public.server_poll_executions WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(created_at) FROM public.server_poll_intents WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(created_at) FROM public.server_poll_acks WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM public.server_poll_receipts WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM public.server_poll_quarantines WHERE receipt_id=id),a.created_at)) INTO activity;\n END IF;\n RETURN isfinite(activity) AND activity+make_interval(days=>GREATEST(a.retention_days,retention))+a.safety_ms*interval '1 millisecond'=clock_timestamp() OR a.authority_expires_at>=clock_timestamp() THEN RETURN false; END IF;\n SELECT settings.requests_retention_days INTO current_retention FROM mcp_settings settings WHERE settings.id=1;\n IF current_retention IS NULL OR current_retention NOT BETWEEN 1 AND 365 THEN RETURN false; END IF;\n IF EXISTS(SELECT 1 FROM public.server_probe_retired_sources WHERE receipt_id=id) THEN\n RETURN public.server_probe_retired_gc_allowed(id,current_retention);\n END IF;\n terminal_at:=a.created_at;\n IF a.identity_kind='mcp' THEN\n SELECT GREATEST(o.finished_at,p.expires_at,COALESCE(cancellation.created_at,o.finished_at)) INTO terminal_at\n FROM mcp_operations o JOIN mcp_plans p ON p.id=o.plan_id AND p.connection_id=o.connection_id\n JOIN mcp_connections owner_connection ON owner_connection.id=o.connection_id\n LEFT JOIN mcp_diagnostic_cancellations cancellation ON cancellation.operation_id=o.id\n WHERE o.id=a.execution_id AND owner_connection.owner_id=a.owner_id AND p.operation_id='servers.probes.run'\n AND o.state IN ('applied','failed','unknown','rejected','partial','cancelled') AND o.finished_at IS NOT NULL\n AND (cancellation.operation_id IS NULL OR(cancellation.connection_id=o.connection_id AND cancellation.actor_id=a.owner_id))\n FOR UPDATE OF o,p,owner_connection;\n IF NOT FOUND OR terminal_at IS NULL THEN RETURN false; END IF;\n END IF;\n SELECT GREATEST(a.created_at,a.authority_expires_at,terminal_at,COALESCE(a.cancelled_at,a.created_at),\n COALESCE((SELECT finished_at FROM server_probe_executions WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT created_at FROM server_probe_execution_quarantines WHERE receipt_id=id),a.created_at),\n COALESCE((SELECT max(GREATEST(created_at,COALESCE(received_at,created_at))) FROM server_probe_execution_stages WHERE receipt_id=id),a.created_at)) INTO activity;\n RETURN activity+make_interval(days=>GREATEST(a.retention_days,current_retention))+a.safety_ms*interval '1 millisecond'>'activityAt')::timestamptz,a.retention_days,a.safety_ms\n INTO activity,retained_days,safety\n FROM public.server_probe_retired_sources r\n JOIN public.server_probe_storage_admissions a ON a.receipt_id=r.receipt_id AND a.execution_id=r.operation_id\n JOIN public.mcp_operation_replay_tombstones t ON t.operation_id=r.operation_id\n JOIN public.mcp_connections c ON c.id=t.connection_id AND c.owner_id=a.owner_id\n WHERE r.receipt_id=target_receipt AND r.proof=current_setting('mm.probe_retired_gc_proof',true)\n AND a.identity_kind='mcp' AND a.cancelled_at IS NULL AND a.claim_token IS NULL AND isfinite(a.claim_attempted_at)\n AND t.action_id='servers.probes.run' AND NOT t.target_global\n AND r.source->>'planId'=t.plan_id::text AND r.source->>'connectionId'=c.id::text\n AND r.source->'serverIds'=to_jsonb(t.target_server_ids) AND r.source->>'ownerId'=a.owner_id\n AND r.source->>'bindingProof'=a.binding_proof\n AND (r.source->>'authorityExpiresAt')::timestamptz=a.authority_expires_at\n AND (r.source->>'gcNotBefore')::timestamptz=a.gc_not_before\n AND (r.source->>'retentionDays')::int=a.retention_days AND (r.source->>'safetyMs')::int=a.safety_ms\n AND isfinite(a.authority_expires_at) AND isfinite(a.gc_not_before)\n AND a.authority_expires_atactivity))\n OR EXISTS(SELECT 1 FROM public.server_probe_execution_stages s WHERE s.receipt_id=target_receipt\n AND GREATEST(s.created_at,COALESCE(s.received_at,s.created_at))>activity)\n THEN RETURN false; END IF;\n RETURN activity+make_interval(days=>GREATEST(retained_days,current_retention))\n +GREATEST(safety,60000)*interval '1 millisecond' = Object.freeze({
+ ...FIXED56_ROLE_TEMPLATE,
+ indexes: sorted([...FIXED56_ROLE_TEMPLATE.indexes, {
+ relname: "mcp_audit",
+ index_name: "mcp_audit_routing_charge_profile_window",
+ indisvalid: true,
+ indisready: true,
+ indisunique: false,
+ indisprimary: false,
+ definition: "CREATE INDEX mcp_audit_routing_charge_profile_window ON public.mcp_audit USING btree (connection_id, (((payload -> 'anchor'::text) ->> 'profileId'::text)), created_at, id) WHERE (action = 'routing.charge.admitted'::text)",
+ }]),
+})
+
+if (sha(canonical(FIXED57_ROLE_TEMPLATE)) !== BUILD57_PROVENANCE.templateSha256) {
+ throw new Error("Fixed57 writer catalogue changed")
+}
diff --git a/backend/scripts/writer-profile/fixed58-build-definition.test.mts b/backend/scripts/writer-profile/fixed58-build-definition.test.mts
new file mode 100644
index 00000000..1a04a2bb
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed58-build-definition.test.mts
@@ -0,0 +1,25 @@
+import assert from "node:assert/strict"
+import { test } from "node:test"
+import { sorted } from "./catalogue-projection.js"
+import { FIXED57_ROLE_TEMPLATE } from "./fixed57-build-definition.js"
+import { FIXED58_ROLE_TEMPLATE, normalizeFixed58RestoreRows } from "./fixed58-build-definition.js"
+
+test("source58 accepts only the reviewed dump layouts and leaves raw catalogue data intact", () => {
+ const relation = "server_probe_executions"
+ const reviewed = FIXED57_ROLE_TEMPLATE.columns.filter(row => row.relname === relation)
+ const compact = reviewed.map(row => typeof row.attnum === "number" && row.attnum > 18 ? { ...row, attnum: row.attnum - 1 } : row)
+ assert.deepEqual(normalizeFixed58RestoreRows(relation, "columns", compact), sorted(reviewed))
+ assert(compact.some(row => row.attnum === 18))
+ const moved = compact.map(row => row.attnum === 18 ? { ...row, attnum: 16 } : row)
+ assert.notDeepEqual(normalizeFixed58RestoreRows(relation, "columns", moved), sorted(reviewed))
+ const checks = FIXED58_ROLE_TEMPLATE.restorePortable.filter(row => typeof row.conname === "string")
+ assert.equal(checks.length, 3)
+ for (const check of checks) {
+ const original = FIXED57_ROLE_TEMPLATE.constraints.find(row => row.relname === check.relname && row.conname === check.conname)!
+ const restored = { ...original, definition: check.definition }
+ assert.deepEqual(normalizeFixed58RestoreRows(String(check.relname), "constraints", [restored]), [original])
+ assert.equal(restored.definition, check.definition)
+ const weakened = { ...restored, definition: "CHECK (true)" }
+ assert.deepEqual(normalizeFixed58RestoreRows(String(check.relname), "constraints", [weakened]), [weakened])
+ }
+})
diff --git a/backend/scripts/writer-profile/fixed58-build-definition.ts b/backend/scripts/writer-profile/fixed58-build-definition.ts
new file mode 100644
index 00000000..f42c5282
--- /dev/null
+++ b/backend/scripts/writer-profile/fixed58-build-definition.ts
@@ -0,0 +1,50 @@
+import { canonical, sha } from "./application-writer-profile-canonical.js"
+import { sorted, type Inventory, type Row } from "./catalogue-projection.js"
+import { BUILD57_PROVENANCE, FIXED57_ROLE_TEMPLATE } from "./fixed57-build-definition.js"
+import { RESTORE_WRITER_PROFILE_DEFINITION_SHA256, RESTORE_WRITER_PROFILE_MANIFEST_SHA256, restoreProfileEnrollmentSql } from "../../src/db/database-restore-quarantine-profile.js"
+
+const compactedProbeLayout = { relname: "server_probe_executions", removedAttnum: 18 }
+const restoredChecks = [
+ { relname: "server_poll_archives", conname: "server_poll_archives_check",
+ definition: "CHECK (((ciphertext_bytes >= 1) AND (ciphertext_bytes <= 131072) AND (ciphertext_bytes = octet_length(ciphertext))))" },
+ { relname: "server_poll_storage_admissions", conname: "server_poll_storage_admissions_owner_id_check",
+ definition: "CHECK (((length(owner_id) >= 1) AND (length(owner_id) <= 200) AND (btrim(owner_id) = owner_id) AND (owner_id !~ '[[:cntrl:]]'::text)))" },
+ { relname: "server_poll_storage_admissions", conname: "server_poll_storage_admissions_check1",
+ definition: "CHECK (((used_rows >= 0) AND (used_rows <= 4019) AND (used_rows <= ((max_stages * 2) + 3))))" },
+]
+
+export const FIXED58_ROLE_TEMPLATE: Readonly = Object.freeze({
+ ...FIXED57_ROLE_TEMPLATE,
+ schemas: sorted(FIXED57_ROLE_TEMPLATE.schemas.map(row => row.nspname === "mmapp_control"
+ ? { ...row, acl: [...row.acl as string[], "@mm-role:runtime@=U/@mm-role:control@"].sort() } : row)),
+ effectiveSchemas: sorted(FIXED57_ROLE_TEMPLATE.effectiveSchemas.map(row => row.nspname === "mmapp_control" && row.rolname === "@mm-role:runtime@"
+ ? { ...row, usage: true } : row)),
+ restoreControl: [{ enrollmentSha256: sha(restoreProfileEnrollmentSql("restore_runtime", "restore_operator")) }],
+ restorePortable: [compactedProbeLayout, ...restoredChecks],
+})
+
+export function normalizeFixed58RestoreRows(relation: string, group: string, rows: Row[]): Row[] {
+ if (relation === compactedProbeLayout.relname && group === "columns" && rows.some(row => row.attnum === compactedProbeLayout.removedAttnum)) {
+ // Exact comparison below still checks names, their order, types, ACL and other properties.
+ return sorted(rows.map(row => typeof row.attnum === "number" && row.attnum >= compactedProbeLayout.removedAttnum
+ ? { ...row, attnum: row.attnum + 1 } : row))
+ }
+ if (group === "constraints" && restoredChecks.some(check => check.relname === relation)) {
+ return sorted(rows.map(row => {
+ const restored = restoredChecks.find(check => check.relname === relation && check.conname === row.conname && check.definition === row.definition)
+ return restored ? { ...row, definition: FIXED57_ROLE_TEMPLATE.constraints.find(original =>
+ original.relname === relation && original.conname === restored.conname)!.definition } : row
+ }))
+ }
+ return rows
+}
+
+export const BUILD58_PROVENANCE = Object.freeze({
+ format: "source58-restore-profile-v1",
+ manifestSha256: RESTORE_WRITER_PROFILE_MANIFEST_SHA256,
+ templateSha256: RESTORE_WRITER_PROFILE_DEFINITION_SHA256,
+})
+
+if (sha(canonical(FIXED58_ROLE_TEMPLATE)) !== BUILD58_PROVENANCE.templateSha256 || BUILD58_PROVENANCE.manifestSha256 !== BUILD57_PROVENANCE.manifestSha256) {
+ throw new Error("Fixed58 writer catalogue changed")
+}
diff --git a/backend/scripts/writer-profile/legacy-cold-verification.mts b/backend/scripts/writer-profile/legacy-cold-verification.mts
new file mode 100644
index 00000000..30773f23
--- /dev/null
+++ b/backend/scripts/writer-profile/legacy-cold-verification.mts
@@ -0,0 +1,95 @@
+import assert from 'node:assert/strict'
+import {createPrivateKey,createPublicKey,sign} from 'node:crypto'
+import path from 'node:path'
+import {z} from 'zod'
+import {assertJsDriverEnvironment,poolOptions,retainPublisherTlsPeer} from './operator-contract.mjs'
+import {readProtected,withJournalLease,writeFile,sha} from './operator-files.mjs'
+import {readProtectedDatabaseSourceBindingRegistry} from './protected-source-registry.mjs'
+import {sourceBindingBodySchema,sourceBindingBytes,sourceBindingCanonical} from '../../src/db/database-source-binding.js'
+import {assertDatabaseSourceObservationCurrent,captureDatabaseSourceObservation} from '../../src/db/database-source-observation.js'
+import {verifyLegacyProbeArchiveApproval} from '../../src/services/server-probe-legacy-archive-approval.js'
+import {captureLegacyProbeCredentialDigest,LEGACY_COLD_DIGEST,LEGACY_PROBE_COLD_PROOF_DOMAIN,legacyColdProofBody} from '../../src/services/server-probe-legacy-cold-proof.js'
+import {captureLegacyProbeLineage,captureLegacyProbeStorage} from '../../src/services/server-probe-legacy-source-inventory.js'
+
+const approvalSchema=z.object({format:z.literal('legacy-probe-cold-verification-approval-v1'),installationId:z.uuid(),
+ sourceHeadSha256:LEGACY_COLD_DIGEST,sourceSignerSpkiSha256:LEGACY_COLD_DIGEST,custodySha256:LEGACY_COLD_DIGEST,coldArchiveSha256:LEGACY_COLD_DIGEST,
+ coldSignerSpkiSha256:LEGACY_COLD_DIGEST,keySha256:LEGACY_COLD_DIGEST,coldSource:sourceBindingBodySchema.shape.source,
+ coldRoleOid:z.string().regex(/^[1-9][0-9]{0,9}$/),tls:z.object({serverName:z.string().regex(/^[A-Za-z0-9][A-Za-z0-9.-]{0,252}$/),
+ caSha256:LEGACY_COLD_DIGEST,spkiSha256:LEGACY_COLD_DIGEST}).strict(),expiresAt:z.number().int().positive()}).strict()
+const parse=(bytes:Buffer)=>JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes))
+export async function verifyLegacyColdMain(args:string[]){
+ assert(args[0]==='legacy-cold-verify');assertJsDriverEnvironment(process.env)
+ const flags=['approval','approval-sha256','transport','transport-sha256','ca','source-registry','archive-directory','legacy-key-directory','cold-signing-key','output-directory']
+ assert.equal(args.length,1+flags.length*2)
+ const values=new Map()
+ for(let i=1;ivalues.get(name)!
+ const approvalSha256=LEGACY_COLD_DIGEST.parse(get('approval-sha256'))
+ const approval=approvalSchema.parse(parse(await readProtected(get('approval'),8192,approvalSha256)))
+ assert(approval.expiresAt>Date.now()&&approval.expiresAt-Date.now()<=900000&&approval.coldSignerSpkiSha256!==approval.sourceSignerSpkiSha256)
+ const deadlineAt=Math.min(Date.now()+60000,approval.expiresAt),pin={registryDirectory:get('source-registry'),installationId:approval.installationId,
+ publicKeySpkiSha256:approval.sourceSignerSpkiSha256,currentHeadSha256:approval.sourceHeadSha256}
+ const directory=get('archive-directory'),maxArchive=64*1024*1024
+ const [ca,transport,archive,signedApproval,coldArchive,operatorPublicKeyPem]=await Promise.all([
+ readProtected(get('ca'),65536,approval.tls.caSha256),readProtected(get('transport'),16384,LEGACY_COLD_DIGEST.parse(get('transport-sha256'))),
+ readProtected(path.join(directory,'legacy-probe.dump'),maxArchive),readProtected(path.join(directory,'legacy-probe-approval.json'),4096,approval.custodySha256),
+ readProtected(path.join(directory,'legacy-probe-cold.dump'),maxArchive,approval.coldArchiveSha256),readProtected(path.join(pin.registryDirectory,'operator-public.pem'),4096),
+ ])
+ const legacyKey=await readProtected(path.join(get('legacy-key-directory'),'encryption-key'),32,approval.keySha256)
+ try{assert.equal(legacyKey.length,32)}finally{legacyKey.fill(0)}
+ const keyBytes=await readProtected(get('cold-signing-key'),8192)
+ let key
+ try{key=createPrivateKey(keyBytes)}finally{keyBytes.fill(0)}
+ assert(key.asymmetricKeyType==='ed25519'&&sha(createPublicKey(key).export({type:'spki',format:'der'}))===approval.coldSignerSpkiSha256)
+ assert.equal(coldArchive.subarray(0,5).toString(),'PGDMP')
+ const custody=await verifyLegacyProbeArchiveApproval(pin,{archive,signedApproval,operatorPublicKeyPem})
+ assert.equal(custody.format,'legacy-probe-custody-approval-v1')
+ const original=await readProtectedDatabaseSourceBindingRegistry(pin,{deadlineAt})
+ const cold=approval.coldSource
+ assert(cold.systemIdentifier!==original.body.source.systemIdentifier||cold.databaseOid!==original.body.source.databaseOid,'Cold database must differ from the original source')
+ assert(cold.serverVersionNum>=180000&&cold.serverVersionNum<190000,'Cold verification requires PostgreSQL 18')
+ assert.equal(cold.currentUser,cold.sessionUser)
+ const options=poolOptions(parse(transport),{source:cold,roles:{publisher:{name:cold.sessionUser}},tls:approval.tls},ca)
+ const {default:pg}=await import('pg');assertJsDriverEnvironment(process.env)
+ return withJournalLease(get('output-directory'),async()=>{
+ const pool=new pg.Pool(options)
+ let failed=false;pool.on('error',()=>{failed=true})
+ let hashes
+ try{
+ const client=await pool.connect()
+ try{
+ const retained=retainPublisherTlsPeer(client,approval.tls)
+ const sql={query:async(text:string,values?:unknown[])=>{
+ assert(!failed&&Date.now()0&&storage.sha256===custody.storageSha256&&lineage.sha256===custody.lineageSha256,'Restored cold rows differ from signed custody')
+ hashes={storageSha256:storage.sha256,lineageSha256:lineage.sha256,credentialSha256:await captureLegacyProbeCredentialDigest(sql)}
+ await assertDatabaseSourceObservationCurrent(sql,observation,{deadlineAt})
+ assert.equal((await sql.query('ROLLBACK')).command,'ROLLBACK')
+ } finally {client.release(true)}
+ } finally {await pool.end()}
+ assert(!failed&&Date.now()JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes))
+
+export async function legacyControlReferenceMain(args:string[]) {
+ const preflight=args[0]==='legacy-source58-preflight'
+ const flags=['bootstrap','bootstrap-sha256','publisher-transport','publisher-transport-sha256',
+ 'ca','source-registry','source-spki-sha256','activation-directory','activation-sha256','approval','approval-sha256','cold-public-key','cold-spki-sha256']
+ if(!preflight)flags.push('operator-transport','operator-transport-sha256')
+ assert((preflight||args[0]==='legacy-control-reference')&&args.length===1+2*flags.length)
+ assertJsDriverEnvironment(process.env)
+ const values=new Map()
+ for(let i=1;ivalues.get(name)!
+ for(const flag of flags.filter(name=>name.endsWith('sha256')))assert(/^[a-f0-9]{64}$/.test(get(flag)))
+ await protectedDirectory(mcpStateDirectory())
+ const bootstrap=parse(await readProtected(get('bootstrap'),32768,get('bootstrap-sha256'))),request=deploymentRequest(bootstrap.deploymentRequest)
+ assert(bootstrap.format==='application-writer-bootstrap-v1'&&bootstrap.publicationAuthorized===false&&bootstrap.readyAuthorized===false)
+ const sourcePin={registryDirectory:get('source-registry'),installationId:request.installationId,
+ publicKeySpkiSha256:get('source-spki-sha256'),currentHeadSha256:request.sourceHeadSha256}
+ const [bytes,coldKey]=await Promise.all([readProtected(get('approval'),8192,get('approval-sha256')),readProtected(get('cold-public-key'),4096)])
+ const pins={coldSpkiSha256:get('cold-spki-sha256'),sourceSpkiSha256:sourcePin.publicKeySpkiSha256,
+ sourceHeadSha256:sourcePin.currentHeadSha256,sourceTlsSpkiSha256:request.tls.spkiSha256,roles:request.roles}
+ const approval=preflight?undefined:verifyLegacyControlReferenceApproval(bytes,coldKey,pins)
+ const transition=preflight?verifyLegacySource58PreflightApproval(bytes,coldKey,pins):undefined
+ const ca=await readProtected(get('ca'),65536,request.tls.caSha256)
+ const transport=async(role:'publisher'|'operator')=>poolOptions(parse(await readProtected(get(role+'-transport'),16384,get(role+'-transport-sha256'))),request,ca,role)
+ const [publisher,application]=await Promise.all([transport('publisher'),preflight?undefined:transport('operator')])
+ const {default:pg}=await import('pg')
+ assertJsDriverEnvironment(process.env)
+ const deadlineAt=Math.min((transition??approval)!.expiresAt,Date.now()+120000)
+ const expectedSource={...request.source,databaseOid:Number(request.source.databaseOid),sessionUser:request.roles.publisher.name,currentUser:request.roles.publisher.name}
+ return withActiveSource({directory:get('activation-directory'),expectedSha256:get('activation-sha256'),sourcePin,expectedSource,
+ tlsSpkiSha256:request.tls.spkiSha256,deadlineAt},createProtectedDatabaseSourceBindingVerifier(sourcePin),async verifier=>{
+ const source=new pg.Pool(publisher),liveApplication=application&&new pg.Pool(application)
+ let failed=false
+ for(const pool of [source,liveApplication])pool?.on('error',()=>{failed=true})
+ const retain=(client:PoolClient)=>{
+ const peer=retainPublisherTlsPeer(client,request.tls)
+ return ()=>{assert(!failed);peer()}
+ }
+ async function observe(inspect?:(sql:SchemaInventoryClient)=>Promise){
+ const client=await source.connect()
+ try{
+ const peer=retain(client),sql={query:async(text:string,parameters?:unknown[])=>{
+ peer();assert(Date.now()inspectApprovedLegacySource58Predecessor(sql,transition,deadlineAt))
+ return {event:'database-legacy-source58-preflight',outcome:'observed',...observation}
+ }
+ assert(approval&&application&&liveApplication)
+ await observe()
+ const result=await provisionControlledSchemaReferenceOn({approval,liveApplication,application,publisher,systemIdentifier:request.source.systemIdentifier,
+ sourceDatabaseOid:request.source.databaseOid,retain,beforePublish:async()=>{await observe()}})
+ return {event:'database-legacy-control-reference',outcome:'committed',...result}
+ }finally{await Promise.all([source.end(),liveApplication?.end()])}
+ })
+}
diff --git a/backend/scripts/writer-profile/legacy-handoff-execution.mts b/backend/scripts/writer-profile/legacy-handoff-execution.mts
new file mode 100644
index 00000000..7653fab1
--- /dev/null
+++ b/backend/scripts/writer-profile/legacy-handoff-execution.mts
@@ -0,0 +1,243 @@
+import assert from 'node:assert/strict'
+import {createPrivateKey,createPublicKey,sign,verify} from 'node:crypto'
+import path from 'node:path'
+import {lstat} from 'node:fs/promises'
+import {z} from 'zod'
+import {assertJsDriverEnvironment,poolOptions,retainPublisherTlsPeer} from './operator-contract.mjs'
+import {readProtected,writeFile,sha} from './operator-files.mjs'
+import {createProtectedDatabaseSourceBindingVerifier} from './protected-source-registry.mjs'
+import {withActiveSource} from './source-activation.mjs'
+import {publishLegacyHandoffIntent} from './publisher.mjs'
+import {deploymentRequest} from '../database-writer-bootstrap-operator.mjs'
+import {acquireDatabaseSchemaControl} from '../../src/db/database-schema-control.js'
+import {assertDatabaseRestoreQuarantineOpen} from '../../src/db/database-restore-quarantine.js'
+import {captureDatabaseSourceObservation,assertDatabaseSourceObservationCurrent} from '../../src/db/database-source-observation.js'
+import {sourceBindingBytes,sourceBindingCanonical} from '../../src/db/database-source-binding.js'
+import {readReviewedLegacyProbe0037} from '../../src/db/legacy-probe-0037-body.js'
+import {migrationManifestDigest} from '../../src/db/migration-manifest.js'
+import {SYSTEM_DATABASE_OPERATION_LOCK,SYSTEM_DATABASE_REQUEST_LOCK} from '../../src/db/operation-lock.js'
+import {LEGACY_COLD_DIGEST,verifyLegacyColdProof,captureLegacyProbeCredentialDigest} from '../../src/services/server-probe-legacy-cold-proof.js'
+import {verifyLegacyProbeArchiveApproval} from '../../src/services/server-probe-legacy-archive-approval.js'
+import {captureLegacyHandoffSchema,checkLegacyHandoffPostState,LEGACY_HANDOFF_ADOPTION_RELATIONS,LEGACY_PROBE_HANDOFF_DOMAIN,
+ verifyLegacyHandoffAdoption,verifyLegacyProbeHandoffIntent} from '../../src/services/server-probe-legacy-handoff-inspection.js'
+import {captureLegacyProbeStorage,LEGACY_PROBE_CUSTODY_RELATIONS,LEGACY_PROBE_RELATIONS} from '../../src/services/server-probe-legacy-source-inventory.js'
+import type {PoolClient} from 'pg'
+
+export const LEGACY_HANDOFF_EXECUTION_DOMAIN='mmapp:legacy-probe-0037-execute:ed25519:v1\n'
+export const LEGACY_HANDOFF_RELEASE_DOMAIN='mmapp:legacy-probe-0037-release:ed25519:v1\n'
+const hash=LEGACY_COLD_DIGEST
+const approvalEnvelope=z.object({body:z.object({format:z.literal('legacy-probe-0037-execution-approval-v1'),decision:z.literal('execute-and-commit'),
+ operationId:z.uuidv4(),sourceHeadSha256:hash,sourceTlsSpkiSha256:hash,custodySha256:hash,coldArchiveSha256:hash,coldProofSha256:hash,
+ coldApprovalSha256:hash,preSchemaSha256:hash,postSchemaSha256:hash,manifestSha256:hash,migrationSha256:hash,
+ protectedRuntimePaused:z.literal(true),expiresAt:z.number().int().positive()}).strict(),signature:z.string().regex(/^[A-Za-z0-9_-]{86}$/)}).strict()
+const releaseEnvelope=approvalEnvelope.extend({body:z.object({format:z.literal('legacy-probe-0037-release-approval-v1'),
+ decision:z.literal('release-migration-quarantine'),operationId:z.uuidv4(),intentSha256:hash,adoptionSha256:hash,sourceHeadSha256:hash,
+ sourceTlsSpkiSha256:hash,coldArchiveSha256:hash,coldProofSha256:hash,postSchemaSha256:hash,manifestSha256:hash,migrationSha256:hash,
+ protectedRuntimePaused:z.literal(true),expiresAt:z.number().int().positive()}).strict()})
+const parse=(raw:Buffer)=>JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(raw))
+const pendingUnknown=()=>Object.assign(Error('Legacy 0037 outcome must be inspected'),{code:'LEGACY_HANDOFF_EXECUTION_UNKNOWN'})
+
+export async function legacyHandoffExecuteMain(args:string[]){
+ const release=args[0]==='legacy-handoff-release',adopt=release||args[0]==='legacy-handoff-adopt'
+ assert(adopt||args[0]==='legacy-handoff-execute');assertJsDriverEnvironment(process.env)
+ const flags=['bootstrap','bootstrap-sha256','publisher-transport','publisher-transport-sha256','operator-transport','operator-transport-sha256',
+ 'control-transport','control-transport-sha256','ca','source-registry','source-spki-sha256','activation-directory','activation-sha256',
+ 'archive-directory','legacy-key-directory','approval','approval-sha256','cold-public-key','cold-spki-sha256',adopt?'handoff-intent-sha256':'source-signing-key']
+ if(release)flags.push('release-approval','release-approval-sha256')
+ assert.equal(args.length,1+flags.length*2)
+ const values=new Map()
+ for(let i=1;ivalues.get(name)!
+ for(const flag of flags.filter(name=>name.endsWith('sha256')))hash.parse(get(flag))
+ const bootstrap=parse(await readProtected(get('bootstrap'),32768,get('bootstrap-sha256'))),request=deploymentRequest(bootstrap.deploymentRequest)
+ assert(bootstrap.format==='application-writer-bootstrap-v1'&&bootstrap.publicationAuthorized===false&&bootstrap.readyAuthorized===false)
+ const sourcePin=Object.freeze({registryDirectory:get('source-registry'),installationId:request.installationId,
+ publicKeySpkiSha256:get('source-spki-sha256'),currentHeadSha256:request.sourceHeadSha256})
+ const coldSignerSpkiSha256=get('cold-spki-sha256'),coldPublicKey=await readProtected(get('cold-public-key'),4096)
+ const approvingKey=createPublicKey(coldPublicKey)
+ assert(coldSignerSpkiSha256!==sourcePin.publicKeySpkiSha256&&approvingKey.asymmetricKeyType==='ed25519'&&sha(approvingKey.export({type:'spki',format:'der'}))===coldSignerSpkiSha256)
+ const approvalBytes=await readProtected(get('approval'),8192,get('approval-sha256')),raw=parse(approvalBytes)
+ const {body:approval,signature}=approvalEnvelope.parse(raw),signatureBytes=Buffer.from(signature,'base64url')
+ assert(sourceBindingBytes(raw).equals(approvalBytes)&&signatureBytes.toString('base64url')===signature&&verify(null,
+ Buffer.from(LEGACY_HANDOFF_EXECUTION_DOMAIN+sourceBindingCanonical(approval)),approvingKey,signatureBytes),'Independent exact 0037 execution approval required')
+ const {body:migration,pin}=await readReviewedLegacyProbe0037()
+ assert((adopt||approval.expiresAt>Date.now()&&approval.expiresAt-Date.now()<=900000)&&approval.migrationSha256===pin.sha256&&approval.manifestSha256===migrationManifestDigest()&&
+ approval.sourceHeadSha256===sourcePin.currentHeadSha256&&approval.sourceTlsSpkiSha256===request.tls.spkiSha256)
+ const archiveDirectory=get('archive-directory'),max=64*1024*1024
+ const [archive,signedApproval,coldProof,operatorPublicKeyPem]=await Promise.all([
+ readProtected(path.join(archiveDirectory,'legacy-probe.dump'),max),readProtected(path.join(archiveDirectory,'legacy-probe-approval.json'),4096,approval.custodySha256),
+ readProtected(path.join(archiveDirectory,'legacy-probe-cold-proof.json'),8192,approval.coldProofSha256),readProtected(path.join(sourcePin.registryDirectory,'operator-public.pem'),4096),
+ ])
+ const coldArchive=await readProtected(path.join(archiveDirectory,'legacy-probe-cold.dump'),max,approval.coldArchiveSha256)
+ const custody=await verifyLegacyProbeArchiveApproval(sourcePin,{archive,signedApproval,operatorPublicKeyPem})
+ assert.equal(custody.format,'legacy-probe-custody-approval-v1')
+ const coldPin={publicKeyPem:coldPublicKey,signerSpkiSha256:coldSignerSpkiSha256,sourceSignerSpkiSha256:sourcePin.publicKeySpkiSha256,
+ approvalSha256:approval.coldApprovalSha256,custodySha256:approval.custodySha256,coldArchiveSha256:approval.coldArchiveSha256,
+ storageSha256:custody.storageSha256,lineageSha256:custody.lineageSha256}
+ const coldObservedAt=adopt?parse(coldProof)?.body?.observedAt:undefined
+ if(adopt)assert(Number.isSafeInteger(coldObservedAt))
+ const cold=verifyLegacyColdProof(coldProof,coldPin,coldObservedAt)
+ const legacyKey=await readProtected(path.join(get('legacy-key-directory'),'encryption-key'),32,cold.keySha256)
+ try{assert.equal(legacyKey.length,32)}finally{legacyKey.fill(0)}
+ let key,adopting
+ let releaseProof:{approvalSha256:string;adoptionSha256:string}|undefined,releaseExpiresAt=Infinity
+ const stage=release?'release':'adoption'
+ const adoptionUnknownFile=path.join(archiveDirectory,`legacy-probe-handoff-${stage}-unknown.json`)
+ const adoptionAttemptFile=path.join(archiveDirectory,`legacy-probe-handoff-${stage}-attempt.json`)
+ if(adopt){
+ for(const file of [adoptionAttemptFile,adoptionUnknownFile]){
+ try{await lstat(file);throw Error(`Legacy ${stage} attempt requires inspection`)}catch(error){if((error as NodeJS.ErrnoException).code!=='ENOENT')throw error}
+ }
+ const intent=await readProtected(path.join(archiveDirectory,'legacy-probe-handoff-intent.json'),4096,get('handoff-intent-sha256'))
+ adopting=await verifyLegacyProbeHandoffIntent(sourcePin,{archive,signedApproval,coldArchive,intent,operatorPublicKeyPem})
+ assert(adopting.operationId===approval.operationId&&adopting.approvalSha256===approval.custodySha256&&adopting.coldArchiveSha256===approval.coldArchiveSha256&&
+ adopting.preSchemaSha256===approval.preSchemaSha256&&adopting.postSchemaSha256===approval.postSchemaSha256&&
+ adopting.executionApprovalSha256===sha(approvalBytes)&&adopting.coldProofSha256===approval.coldProofSha256,'Execution approval differs from durable handoff')
+ if(release){
+ const bytes=await readProtected(get('release-approval'),8192,get('release-approval-sha256')),raw=parse(bytes)
+ const {body,signature}=releaseEnvelope.parse(raw),sig=Buffer.from(signature,'base64url')
+ assert(sourceBindingBytes(raw).equals(bytes)&&sig.toString('base64url')===signature&&verify(null,
+ Buffer.from(LEGACY_HANDOFF_RELEASE_DOMAIN+sourceBindingCanonical(body)),approvingKey,sig),'Independent signed release approval required')
+ assert(body.operationId===adopting.operationId&&body.intentSha256===adopting.intentSha256&&body.sourceHeadSha256===approval.sourceHeadSha256&&
+ body.sourceTlsSpkiSha256===approval.sourceTlsSpkiSha256&&body.coldArchiveSha256===approval.coldArchiveSha256&&body.coldProofSha256===approval.coldProofSha256&&
+ body.postSchemaSha256===approval.postSchemaSha256&&body.manifestSha256===approval.manifestSha256&&body.migrationSha256===approval.migrationSha256&&
+ body.expiresAt>Date.now()&&body.expiresAt-Date.now()<=900000,'Release approval differs from exact legacy handoff')
+ releaseProof={approvalSha256:sha(bytes),adoptionSha256:body.adoptionSha256};releaseExpiresAt=body.expiresAt
+ }
+ }else{
+ const keyBytes=await readProtected(get('source-signing-key'),8192)
+ try{key=createPrivateKey(keyBytes)}finally{keyBytes.fill(0)}
+ assert(key.asymmetricKeyType==='ed25519'&&sha(createPublicKey(key).export({type:'spki',format:'der'}))===sourcePin.publicKeySpkiSha256)
+ }
+ const ca=await readProtected(get('ca'),65536,request.tls.caSha256)
+ const transport=async(role:'publisher'|'operator'|'control')=>poolOptions(parse(await readProtected(get(role+'-transport'),16384,get(role+'-transport-sha256'))),request,ca,role)
+ const [publisherOptions,applicationOptions,controlOptions]=await Promise.all([transport('publisher'),transport('operator'),transport('control')])
+ const {default:pg}=await import('pg');assertJsDriverEnvironment(process.env)
+ const deadlineAt=adopt?Math.min(Date.now()+120000,releaseExpiresAt):Math.min(Date.now()+120000,approval.expiresAt,cold.expiresAt)
+ const expectedSource={...request.source,databaseOid:Number(request.source.databaseOid),sessionUser:request.roles.publisher.name,currentUser:request.roles.publisher.name}
+ const verifier=createProtectedDatabaseSourceBindingVerifier(sourcePin)
+ return withActiveSource({directory:get('activation-directory'),expectedSha256:get('activation-sha256'),sourcePin,expectedSource,
+ tlsSpkiSha256:request.tls.spkiSha256,deadlineAt},verifier,async sourceVerifier=>{
+ const publisher=new pg.Pool(publisherOptions),application=new pg.Pool({...applicationOptions,application_name:'mmapp-legacy-handoff-owner'}),controlPool=new pg.Pool(controlOptions)
+ let failed=false,committed=false,commitSent=false,controlUnknown=false,recorded=false,app:PoolClient|undefined,control
+ let intentSha256:string|undefined,cleanupUnconfirmed=false
+ for(const pool of [publisher,application,controlPool])pool.on('error',()=>{failed=true})
+ const fence=()=>assert(!failed&&Date.now(){
+ const retained=retainPublisherTlsPeer(client,request.tls)
+ return {query:async(text:string,values?:unknown[])=>{fence();retained();const result=await client.query(text,values);retained();fence();return result}}
+ }
+ const assertRole=async(sql:ReturnType,role:'publisher'|'operator'|'control')=>{
+ const {rows:[actual]}=await sql.query(`SELECT r.rolname AS actor,r.oid::text AS role_oid,d.oid::text AS db_oid,d.datname AS db_name,
+ c.system_identifier::text AS system,pg_catalog.current_setting('server_version_num')::int AS version,pg_catalog.pg_is_in_recovery() AS recovery
+ FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_control_system() c
+ WHERE r.rolname=CURRENT_USER AND r.rolname=SESSION_USER AND d.datname=pg_catalog.current_database()`)
+ assert.deepEqual(actual,{actor:request.roles[role].name,role_oid:request.roles[role].signedOid,db_oid:request.source.databaseOid,
+ db_name:request.source.databaseName,system:request.source.systemIdentifier,version:request.source.serverVersionNum,recovery:false})
+ }
+ const observePublisher=async(checkSchema:boolean,inspect?:(sql:ReturnType)=>Promise)=>{
+ const client=await publisher.connect()
+ try{
+ const sql=retainedSql(client)
+ await assertRole(sql,'publisher')
+ await sql.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY')
+ await sql.query("SET LOCAL TimeZone='UTC'; SET LOCAL DateStyle='ISO, YMD'")
+ const observation=await captureDatabaseSourceObservation(sql,{deadlineAt})
+ await sourceVerifier.verify(sql,observation,{deadlineAt})
+ if(checkSchema)assert.equal(await captureLegacyHandoffSchema(sql,deadlineAt),approval.preSchemaSha256,'Original 0036 catalogue differs from reviewed approval')
+ const result=await inspect?.(sql)
+ await assertDatabaseSourceObservationCurrent(sql,observation,{deadlineAt})
+ assert.equal((await sql.query('ROLLBACK')).command,'ROLLBACK')
+ return result
+ }finally{client.release(true)}
+ }
+ try{
+ control=await acquireDatabaseSchemaControl({async connect(){
+ const client=await controlPool.connect()
+ try{
+ const sql=retainedSql(client);await assertRole(sql,'control')
+ if(adopting){
+ const {rows:[gate]}=await sql.query(`SELECT q.operation_id::text AS active,s.state->'intent'->>'id' AS pending,
+ s.state->'terminal'->'intent'->>'id' AS adopted
+ FROM mmapp_control.database_restore_quarantine q CROSS JOIN mmapp_control.database_schema_state s WHERE q.id=1 AND s.id=1`)
+ assert(gate?.active===adopting.operationId&&(release?gate.pending===null&&gate.adopted===adopting.operationId:gate.pending===adopting.operationId),'Exact quarantined legacy phase required')
+ }else await assertDatabaseRestoreQuarantineOpen(sql)
+ return {...sql,release:(destroy?:boolean)=>client.release(destroy)}
+ }catch(error){client.release(true);throw error}
+ }})
+ app=await application.connect();const sql=retainedSql(app)
+ await assertRole(sql,'operator')
+ for(const lock of [SYSTEM_DATABASE_REQUEST_LOCK,SYSTEM_DATABASE_OPERATION_LOCK,8723110]){
+ const {rows:[row]}=await sql.query('SELECT pg_catalog.pg_try_advisory_lock($1::bigint) AS held',[lock]);assert.equal(row.held,true,'Legacy exclusive drain unavailable')
+ }
+ await sql.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ WRITE')
+ if(adopting){
+ await sql.query(`LOCK TABLE ${LEGACY_HANDOFF_ADOPTION_RELATIONS.map(name=>`public.${name}`).join(', ')} IN SHARE MODE NOWAIT`)
+ const adoption=await observePublisher(false,observer=>verifyLegacyHandoffAdoption(sql,observer,adopting,deadlineAt,releaseProof))
+ assert(adoption);await observePublisher(false)
+ assert(adoption.appliedAt<=Date.now()&&adoption.appliedAt<=approval.expiresAt&&approval.expiresAt-adoption.appliedAt<=900000,'Original approval was outside its signed execution window')
+ verifyLegacyColdProof(coldProof,coldPin,adoption.appliedAt)
+ await writeFile(adoptionAttemptFile,sourceBindingBytes({format:`legacy-probe-0037-${stage}-attempt-v1`,
+ operationId:adopting.operationId,intentSha256:adopting.intentSha256,automaticReplay:false}),{flag:'wx',mode:0o600})
+ try{
+ const receipt=release?await control.releaseLegacyHandoff(adoption):await control.adoptLegacyHandoff(adoption)
+ const terminal=receipt.state.terminal!
+ return {event:`database-legacy-handoff-${stage}`,outcome:'committed',operationId:adopting.operationId,intentSha256:adopting.intentSha256,
+ observationSha256:terminal.legacyRelease?.observationSha256??terminal.observationSha256,quarantineActive:!release,automaticReplay:false,readyAuthorized:false}
+ }catch(error){
+ if((error as {outcomeUnknown?:boolean})?.outcomeUnknown===true){
+ const value=sourceBindingBytes({format:`legacy-probe-0037-${stage}-unknown-v1`,operationId:adopting.operationId,intentSha256:adopting.intentSha256,automaticReplay:false})
+ try{await writeFile(adoptionUnknownFile,value,{flag:'wx',mode:0o600})}catch{/* Preserve the existing intent and control history. */}
+ throw Object.assign(Error(`Legacy 0037 ${stage} must be inspected`),{code:release?'LEGACY_HANDOFF_RELEASE_UNKNOWN':'LEGACY_HANDOFF_ADOPTION_UNKNOWN'})
+ }
+ throw error
+ }
+ }
+ const historyTables=[...LEGACY_PROBE_CUSTODY_RELATIONS,'mcp_credentials','mcp_settings'].sort().map(name=>`public.${name}`).join(', ')
+ await sql.query(`LOCK TABLE ${historyTables} IN SHARE MODE NOWAIT`)
+ await observePublisher(true)
+ await sql.query(`LOCK TABLE ${historyTables} IN ACCESS EXCLUSIVE MODE NOWAIT`)
+ await captureLegacyProbeStorage(sql)
+ assert.equal(await captureLegacyProbeCredentialDigest(sql),cold.credentialSha256,'Original credentials differ from verified cold rows')
+ const {rows:[triggers]}=await sql.query(`SELECT EXISTS(SELECT FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid
+ WHERE c.relnamespace='public'::regnamespace AND c.relname::text=ANY($1::text[]) AND (t.tgtype::int & 32)<>0) AS truncate_trigger`,[LEGACY_PROBE_RELATIONS])
+ assert.equal(triggers.truncate_trigger,false,'Unreviewed diagnostic TRUNCATE trigger')
+ const {rows:[{xid}]}=await sql.query('SELECT pg_catalog.pg_current_xact_id()::text AS xid')
+ const intent={format:'legacy-probe-0037-handoff-intent-v1',operationId:approval.operationId,applicationXid:xid,
+ approvalSha256:approval.custodySha256,coldArchiveSha256:approval.coldArchiveSha256,preSchemaSha256:approval.preSchemaSha256,
+ postSchemaSha256:approval.postSchemaSha256,manifestSha256:approval.manifestSha256,migrationSha256:approval.migrationSha256,
+ executionApprovalSha256:sha(approvalBytes),coldProofSha256:approval.coldProofSha256}
+ assert(key)
+ const signedIntent=sourceBindingBytes({body:intent,signature:sign(null,Buffer.from(LEGACY_PROBE_HANDOFF_DOMAIN+sourceBindingCanonical(intent)),key).toString('base64url')})
+ intentSha256=sha(signedIntent)
+ try{await publishLegacyHandoffIntent({application:app,control,sourcePin,tlsPin:request.tls,archiveDirectory,signedIntent,deadlineAt});recorded=true}
+ catch(error){const state=error as {outcomeUnknown?:boolean;controlAcknowledged?:boolean};controlUnknown=state?.outcomeUnknown===true||state?.controlAcknowledged===true;throw error}
+ await sql.query("SET LOCAL search_path=public,pg_catalog,pg_temp; SET LOCAL synchronous_commit=on")
+ await sql.query(`TRUNCATE TABLE ${LEGACY_PROBE_RELATIONS.map(name=>`ONLY public.${name}`).join(', ')} CONTINUE IDENTITY RESTRICT`)
+ await sql.query(migration)
+ await sql.query('SET TRANSACTION READ ONLY')
+ assert(await checkLegacyHandoffPostState(sql,approval.postSchemaSha256,xid,deadlineAt),'Exact 0037 post-state refused')
+ await observePublisher(false)
+ fence();commitSent=true
+ // Observe the physical acknowledgement before any subsequent check can fail.
+ assert.equal((await app.query('COMMIT')).command,'COMMIT');committed=true
+ }catch(error){
+ if(!commitSent&&app){try{await app.query('ROLLBACK')}catch{/* Destroy the checked-out application backend. */}}
+ if(commitSent||controlUnknown||recorded){
+ if(commitSent){
+ const value=sourceBindingBytes({format:'legacy-probe-0037-application-unknown-v1',operationId:approval.operationId,intentSha256,automaticReplay:false})
+ try{await writeFile(path.join(archiveDirectory,'legacy-probe-handoff-application-unknown.json'),value,{flag:'wx',mode:0o600})}catch{/* Existing protected intent remains the recovery reference. */}
+ }
+ throw pendingUnknown()
+ }
+ throw error
+ }finally{
+ try{await control?.close()}catch{cleanupUnconfirmed=true}
+ try{app?.release(true)}catch{cleanupUnconfirmed=true}
+ const closed=await Promise.allSettled([publisher.end(),application.end(),controlPool.end()]);cleanupUnconfirmed ||= closed.some(result=>result.status==='rejected')
+ }
+ assert(recorded&&committed)
+ return {event:'database-legacy-handoff-execution',outcome:'committed',operationId:approval.operationId,intentSha256,quarantineActive:true,
+ cleanupUnconfirmed:cleanupUnconfirmed||failed,automaticReplay:false,readyAuthorized:false}
+ })
+}
diff --git a/backend/scripts/writer-profile/maintenance-resolution.mts b/backend/scripts/writer-profile/maintenance-resolution.mts
new file mode 100644
index 00000000..6371baa2
--- /dev/null
+++ b/backend/scripts/writer-profile/maintenance-resolution.mts
@@ -0,0 +1,132 @@
+/** Explicit host-operator inspection/acceptance. No restore, service restart, role
+ * enrollment or source/READY issuer. Populated data is accepted, not certified. */
+import assert from 'node:assert/strict'
+import path from 'node:path'
+import {fileURLToPath} from 'node:url'
+import {mkdir,readdir} from 'node:fs/promises'
+import {readProtected,protectedDirectory,writeFile,withJournalLease,sha} from './operator-files.mjs'
+import {poolOptions,STARTUP_OPTIONS,assertJsDriverEnvironment} from './operator-contract.mjs'
+import {readMaintenanceRecoveryFacts,readMaintenanceAcceptanceRecords} from '../../src/services/database-maintenance-startup.js'
+import {parseMaintenanceJSON,runtimeDatabaseTargetSha256,evaluateMaintenanceAcceptances,validateMaintenanceKnownCurrent,validateMaintenanceAcceptance,MAINTENANCE_ACCEPTANCE_FORMAT,type MaintenanceKnownCurrent} from '../../src/services/database-maintenance-resolution.js'
+import {captureMigrationSchema} from '../../src/db/migration-schema-inventory.js'
+import {MIGRATION_MANIFEST,CURRENT_REQUIRED_TABLES,migrationManifestDigest,inventoryMigrationDirectory} from '../../src/db/migration-manifest.js'
+import type {Pool,PoolClient} from 'pg'
+const hex=(v:unknown):v is string=>typeof v==='string'&&/^[a-f0-9]{64}$/.test(v)
+function object(v:unknown):asserts v is Record{assert(v&&typeof v==='object'&&!Array.isArray(v))}
+function exact(v:unknown,keys:string[]):asserts v is Record{object(v);assert.equal(Object.keys(v).sort().join('\0'),keys.sort().join('\0'))}
+const stamp=(v:unknown):v is string=>typeof v==='string'&&Number.isFinite(Date.parse(v))&&new Date(v).toISOString()===v
+const stable=(v:unknown)=>JSON.stringify(v)
+const flags=['state-dir','transport','transport-sha256','runtime-target','runtime-target-sha256']
+const validityMs=900000
+/** Explicit local-container transport never falls back from TLS or environment.
+ * Caller launch review supplies --network container:;
+ * this module has no Docker socket/API and claims only loopback + physical SQL proof. */
+export function maintenancePoolConfiguration(value:unknown,ca?:Buffer,caSha256?:string){
+ object(value);const mode=value.mode===undefined?'tls':value.mode;assert(mode==='tls'||mode==='local-loopback')
+ exact(value,mode==='local-loopback'?['format','mode','connection']:value.mode===undefined?['format','connection','tls']:['format','mode','connection','tls'])
+ assert.equal(value.format,'database-maintenance-transport-v1');exact(value.connection,['host','port','user','password','database']);const connection=value.connection
+ assert(typeof connection.host==='string'&&typeof connection.user==='string'&&/^[^\x00-\x1f\x7f]{1,63}$/.test(connection.user)&&typeof connection.password==='string'&&connection.password.length>0&&connection.password.length<=4096&&!connection.password.includes('\0')&&typeof connection.database==='string'&&/^[^\x00-\x1f\x7f]{1,63}$/.test(connection.database)&&typeof connection.port==='number'&&Number.isSafeInteger(connection.port)&&Number(connection.port)>0&&Number(connection.port)<=65535)
+ let options,identity:unknown
+ if(mode==='tls'){
+ exact(value.tls,['serverName','spkiSha256']);assert(typeof value.tls.serverName==='string'&&/^[a-zA-Z0-9][a-zA-Z0-9.-]{0,252}$/.test(value.tls.serverName)&&hex(value.tls.spkiSha256));assert(ca&&hex(caSha256))
+ options=poolOptions(connection,{roles:{publisher:{name:connection.user}},source:{databaseName:connection.database},tls:{...value.tls,caSha256}},ca)
+ identity={mode,host:connection.host,port:connection.port,database:connection.database,tls:{...value.tls,caSha256}}
+ }else{
+ assert(connection.host==='127.0.0.1'||connection.host==='::1','Plaintext maintenance requires exact loopback and reviewed PostgreSQL container namespace');assert(ca===undefined&&caSha256===undefined)
+ options={host:connection.host,port:connection.port,user:connection.user,password:connection.password,database:connection.database,max:1,connectionTimeoutMillis:5000,idleTimeoutMillis:5000,statement_timeout:10000,lock_timeout:5000,options:STARTUP_OPTIONS,application_name:'mmapp-maintenance-acceptance',client_encoding:'UTF8',ssl:false}
+ identity={mode,host:connection.host,port:connection.port,database:connection.database}
+ }
+ return {options,transportBinding:{mode,endpointSha256:sha(stable(identity))} as MaintenanceKnownCurrent['transport']}
+}
+export function maintenanceApproval(value:unknown,inspectionSha256:string,inspectionCreatedAt:string){
+ exact(value,['format','resolutionId','decision','actorId','inspectionSha256','issuedAt','expiresAt','managedBackendStopped','historicOutcomesRemainUnknown','automaticRestore'])
+ assert(value.format==='database-maintenance-current-state-approval-v1'&&value.decision==='accept-observed-current-state'&&typeof value.resolutionId==='string'&&/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value.resolutionId))
+ assert(typeof value.actorId==='string'&&/^[^\x00-\x1f\x7f]{1,160}$/.test(value.actorId)&&value.inspectionSha256===inspectionSha256&&stamp(value.issuedAt)&&stamp(value.expiresAt))
+ const now=Date.now();assert(Date.parse(value.issuedAt)>=Date.parse(inspectionCreatedAt)&&Date.parse(value.issuedAt)<=now&&now,transport:MaintenanceKnownCurrent['transport']){
+ let client:PoolClient|undefined,locked=false,begun=false,bad=false,faulted=false
+ const fault=()=>{faulted=true},live=()=>{assert(!faulted)}
+ try{
+ client=await pool.connect();client.on('error',fault);client.on('end',fault)
+ const query=async(text:string,values:unknown[]=[])=>{live();const result=await client!.query(text,values);live();return result}
+ await query("SET statement_timeout='10s'");await query("SET lock_timeout='5s'")
+ const lease=await query('SELECT pg_catalog.pg_try_advisory_lock(8723110::bigint) AS locked');assert(lease.rows.length===1&&lease.rows[0].locked===true);locked=true
+ await query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');begun=true
+ for(const sql of ["SET LOCAL search_path=pg_catalog","SET LOCAL TimeZone='UTC'","SET LOCAL DateStyle='ISO, YMD'","SET LOCAL standard_conforming_strings=on","SET LOCAL statement_timeout='10s'"])await query(sql)
+ const identity=await query(`SELECT c.system_identifier::text AS "systemIdentifier",d.oid::text AS "databaseOid",d.datname AS "databaseName",pg_catalog.current_setting('server_version_num')::int AS "serverVersionNum",pg_catalog.pg_is_in_recovery() AS "inRecovery" FROM pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_control_system() c WHERE d.datname=pg_catalog.current_database()`)
+ assert.equal(identity.rows.length,1)
+ // The optional writer-profile control schema is not installed by ordinary
+ // application migrations. Observe its presence in this same transaction;
+ // detailed capture still refuses every other unexpected namespace.
+ const control=await query("SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname='mmapp_control'")
+ assert(control.rows.length<=1&&control.rows.every(row=>row.nspname==='mmapp_control'))
+ // Same scope as the runtime catalogue snapshot: source58 places public triggers on mmapp_control functions, which a
+ // public-only capture reports as unsupported external dependencies.
+ const withControl=control.rows.length===1
+ const schema=await captureMigrationSchema({query:async(text,values)=>query(text,values)},{scope:{applicationNamespaces:withControl?['public','mmapp_control']:['public']},includeControlEventTriggers:withControl,deadlineAt:Date.now()+60000})
+ const marker=schema.sections.relations.find(row=>row.namespace==='public'&&row.name==='schema_migrations'),column=schema.sections.columns.find(row=>row.namespace==='public'&&row.relation==='schema_migrations'&&row.name==='id'&&row.dropped===false)
+ assert(marker?.kind==='r'&&marker.persistence==='p'&&marker.row_security===false&&marker.force_row_security===false&&column?.type==='text')
+ for(const table of CURRENT_REQUIRED_TABLES)assert(schema.sections.relations.some(row=>row.namespace==='public'&&row.name===table&&['r','p'].includes(String(row.kind))&&row.row_security===false&&row.force_row_security===false))
+ const markers=(await query('SELECT id FROM public.schema_migrations ORDER BY id LIMIT $1',[MIGRATION_MANIFEST.length+1])).rows
+ assert.equal(stable(markers),stable(MIGRATION_MANIFEST.map(entry=>({id:entry.file.slice(0,-4)}))))
+ const knownCurrent={transport,source:identity.rows[0],schemaSha256:schema.sha256,rawSchemaSha256:schema.observedRaw.sha256,physicalSchemaSha256:schema.observedPhysical.sha256,manifestSha256:migrationManifestDigest(),markersSha256:sha(stable(markers))}
+ validateMaintenanceKnownCurrent(knownCurrent)
+ const end=await query('ROLLBACK');assert.equal(end.command,'ROLLBACK');begun=false
+ const unlock=await query('SELECT pg_catalog.pg_advisory_unlock(8723110::bigint) AS unlocked');assert(unlock.rows.length===1&&unlock.rows[0].unlocked===true);locked=false
+ return {knownCurrent,schema}
+ }catch(error){bad=true;throw error}finally{
+ if(client){let cleanupFailed=false
+ try{if(begun&&!faulted){const end=await client.query('ROLLBACK');assert.equal(end.command,'ROLLBACK')}if(locked&&!faulted){const end=await client.query('SELECT pg_catalog.pg_advisory_unlock(8723110::bigint) AS unlocked');assert(end.rows[0]?.unlocked===true)}}catch{cleanupFailed=true}
+ try{client.off('error',fault);client.off('end',fault)}catch{cleanupFailed=true}
+ try{client.release(bad||faulted||cleanupFailed)}catch{cleanupFailed=true}
+ assert(!cleanupFailed&&!faulted,'Read-only maintenance owner cleanup unconfirmed')
+ }
+ }
+}
+async function snapshot(stateDirectory:string,target:string,records:readonly Buffer[]){
+ const state=await readMaintenanceRecoveryFacts(stateDirectory);assert(state.kind==='journal'&&state.generation)
+ const accepted=evaluateMaintenanceAcceptances(records,state.journal,state.vault.evidence,target)
+ const unresolvedOperations=state.operations.filter(op=>op.state!=='applied'),vaultCoverage=state.vault.evidence.filter(marker=>state.vault.unresolvedFiles.includes(marker.file))
+ const newUnresolved=unresolvedOperations.some(op=>!accepted.acceptedCoreIds.has(op.operationId))||state.vault.unresolvedFiles.some(file=>!accepted.acceptedVaultFiles.has(file))
+ return {newUnresolved,external:{journalCoverage:{prefixBytes:state.journal.length,sha256:sha(state.journal),unresolvedOperations},vaultCoverage,generationObservedSha256:sha(state.generation),previousResolutionSha256:accepted.headSha256}}
+}
+export async function maintenanceMain(args:string[]){
+ assertJsDriverEnvironment(process.env);const resolve=args[0]==='maintenance-resolve';assert(resolve||args[0]==='maintenance-inspect')
+ const required=[...flags,...(resolve?['inspection','inspection-sha256','approval','approval-sha256']:['output'])],names=[...required,'ca','ca-sha256'],values=new Map()
+ assert(args.length===1+required.length*2||args.length===1+(required.length+2)*2)
+ for(let i=1;ivalues.get(name)!
+ for(const name of [...values.keys()].filter(name=>name.endsWith('sha256')))assert(hex(get(name)))
+ const stateDirectory=get('state-dir');await protectedDirectory(stateDirectory)
+ const transport=parseMaintenanceJSON(await readProtected(get('transport'),16384,get('transport-sha256')));object(transport);const mode=transport.mode===undefined?'tls':transport.mode;assert(mode==='tls'||mode==='local-loopback');assert(values.has('ca')===(mode==='tls'))
+ const ca=mode==='tls'?await readProtected(get('ca'),65536,get('ca-sha256')):undefined
+ const runtime=parseMaintenanceJSON(await readProtected(get('runtime-target'),16384,get('runtime-target-sha256')));exact(runtime,['format','databaseUrl']);assert(runtime.format==='database-maintenance-runtime-target-v1'&&typeof runtime.databaseUrl==='string');const runtimeUrl=new URL(runtime.databaseUrl);assert(!runtimeUrl.username&&!runtimeUrl.password)
+ const target=runtimeDatabaseTargetSha256(runtime.databaseUrl),{options,transportBinding}=maintenancePoolConfiguration(transport,ca,mode==='tls'?get('ca-sha256'):undefined)
+ exact(transport.connection,['host','port','user','password','database']);assert.equal(decodeURIComponent(runtimeUrl.pathname.slice(1)),transport.connection.database)
+ const records=await readMaintenanceAcceptanceRecords(stateDirectory);if(resolve)assert(records.length<64,'Maintenance acceptance history bound reached');const currentState=await snapshot(stateDirectory,target,records),before=currentState.external;if(resolve)assert(currentState.newUnresolved,'No new unresolved history to accept')
+ await inventoryMigrationDirectory(path.join(path.dirname(path.dirname(path.dirname(fileURLToPath(import.meta.url)))),'drizzle'))
+ let inspection:Record|undefined,approved:ReturnType|undefined
+ if(resolve){inspection=parseMaintenanceJSON(await readProtected(get('inspection'),67108864,get('inspection-sha256'))) as Record;exact(inspection,['format','createdAt','expiresAt','runtimeTargetSha256','acceptanceRequired','external','knownCurrent','schema']);assert(inspection.format==='database-maintenance-current-state-inspection-v1'&&stamp(inspection.createdAt)&&stamp(inspection.expiresAt)&&Date.parse(inspection.createdAt)<=Date.now()&&Date.now(){const pool=new pg.Pool(options);let failed=false;pool.on('error',()=>{failed=true});try{const result=await observeMaintenanceCurrent(pool,transportBinding);await pool.end();assert(!failed);return result}catch(error){try{await pool.end()}catch{/* preserve refusal */}throw error}}
+ if(!resolve){const result=await runProof();assert.equal(stable((await snapshot(stateDirectory,target,await readMaintenanceAcceptanceRecords(stateDirectory))).external),stable(before));const nowMs=Date.now(),now=new Date(nowMs).toISOString(),out={format:'database-maintenance-current-state-inspection-v1',createdAt:now,expiresAt:new Date(nowMs+validityMs).toISOString(),runtimeTargetSha256:target,acceptanceRequired:currentState.newUnresolved,external:before,...result};const raw=Buffer.from(stable(out));assert(raw.length<=67108864);await writeFile(get('output'),raw,{flag:'wx',mode:0o600});return {event:'database-maintenance-inspection',inspectionSha256:sha(raw),unresolvedCoreOperations:before.journalCoverage.unresolvedOperations.length,unresolvedVaultFiles:before.vaultCoverage.length,state:currentState.newUnresolved?'inspection-required':before.previousResolutionSha256?'historically-accepted':'no-unresolved-history',historicalAcceptanceHeadSha256:before.previousResolutionSha256,humanApprovalRequired:currentState.newUnresolved,knownCurrentObserved:true,archiveDataEquivalenceProved:false,historicOutcomesChanged:false,automaticRestore:false}}
+ const resolutionDirectory=path.join(stateDirectory,'maintenance-acceptances');await mkdir(resolutionDirectory,{recursive:true,mode:0o700});await protectedDirectory(resolutionDirectory)
+ return withJournalLease(resolutionDirectory,async()=>{
+ // Existing immutable records are reread while our proven O_EXCL lease is held.
+ // Runtime reader refuses this lease; never infer stale ownership from PID/time.
+ const expected=records.map(raw=>{const v=parseMaintenanceJSON(raw) as {resolutionId:string};return v.resolutionId+'.json'}).sort()
+ assert.equal((await readdir(resolutionDirectory)).sort().join('\0'),[...expected,'publisher-lease.lock'].sort().join('\0'))
+ for(let i=0;iJSON.parse(new TextDecoder('utf8',{fatal:true}).decode(bytes))
+const receiptEvent='application-writer-marker-fence-enrollment'
+
+// The reviewed fixed57 migration-marker cohort, qualified independently of search_path.
+const installSql=`CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON public.schema_migrations
+ FOR EACH STATEMENT EXECUTE FUNCTION public.server_partition_writer_guard();
+CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON public.schema_migrations
+ FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted();
+CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.schema_migrations
+ FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard();
+ALTER TABLE public.schema_migrations ENABLE ALWAYS TRIGGER candidate_application_statement_guard;
+ALTER TABLE public.schema_migrations ENABLE ALWAYS TRIGGER candidate_truncate_preadmitted;
+ALTER TABLE public.schema_migrations ENABLE ALWAYS TRIGGER server_partition_writer_guard;`
+export const reviewedMarkerFenceSql=installSql
+
+const targetSql=`SELECT d.oid::text AS "databaseOid", d.datname::text AS "databaseName",
+ control.system_identifier::text AS "systemIdentifier", pg_catalog.current_setting('server_version_num')::int AS "serverVersionNum",
+ pg_catalog.pg_is_in_recovery() AS "inRecovery", r.oid::text AS "roleOid"
+ FROM pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_control_system() control
+ WHERE d.datname=pg_catalog.current_database() AND r.rolname=SESSION_USER AND SESSION_USER=CURRENT_USER AND r.rolname=$1
+ AND pg_catalog.current_setting('transaction_read_only')='off' AND pg_catalog.current_setting('session_replication_role')='origin'
+ AND pg_catalog.current_setting('event_triggers')='on'`
+
+const eventSql=`SELECT e.evtname::text, e.evtevent::text, e.evtenabled::text, e.evttags,
+ pg_catalog.pg_get_userbyid(e.evtowner) AS owner, n.nspname AS function_namespace,p.proname AS function_name,
+ p.proowner::text AS function_owner, p.proacl::text[] AS acl, pg_catalog.pg_get_functiondef(p.oid) AS definition
+ FROM pg_catalog.pg_event_trigger e JOIN pg_catalog.pg_proc p ON p.oid=e.evtfoid
+ JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace LIMIT 2`
+
+type EnrollmentQuery=>(text:string,parameters?:unknown[])=>Promise<{rows:R[]}>
+type Source={databaseOid:string;databaseName:string;systemIdentifier:string;serverVersionNum:number;inRecovery:false}
+
+/** SQL component for the retained operator transaction. The command owns TLS, approval and terminal acknowledgement. */
+export async function enrollMarkerFenceInTransaction(query:EnrollmentQuery,bindings:RegistryRoleBindingsData,source:Source,expectedCatalogue:string){
+ await query('SET LOCAL search_path = pg_catalog')
+ await query('SELECT pg_catalog.pg_advisory_xact_lock($1::bigint)',[KEY])
+ const {operator,control}=bindings
+ assert.deepEqual((await query(targetSql,[operator.name])).rows,[{...source,roleOid:operator.signedOid}])
+ const security=await readProtectedRegistryStructureData({query},bindings)
+ await query('LOCK TABLE ONLY public.schema_migrations IN ACCESS EXCLUSIVE MODE')
+ const markers=MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)}))
+ const actualMarkers=await query('SELECT id FROM public.schema_migrations ORDER BY id COLLATE "C" LIMIT $1',[markers.length+1])
+ assert.deepEqual(actualMarkers.rows,markers,'Marker fence requires exact current migration markers')
+ await assertReviewedMigrationMarkerGuard({query},'unenrolled')
+ const [{function:_function,owner:_owner,...event}]=FIXED57_ROLE_TEMPLATE.events
+ const allowedFunction=FIXED57_ROLE_TEMPLATE.functions.find(fn=>fn.proname==='candidate_operator_ddl')!
+ assert.deepEqual((await query(eventSql)).rows,[{...event,owner:control.name,function_owner:control.signedOid,
+ acl:[`${control.name}=X/${control.name}`],definition:allowedFunction.definition.replace('@mm-role:operator@',operator.name)}],
+ 'Marker fence requires the exact reviewed operator DDL gate before writing')
+ await query(installSql)
+ await assertReviewedMigrationMarkerGuard({query})
+ const catalogue=await collectSource57Catalogue({query},{roleBindings:bindings})
+ assert.equal(sha(canonical({base:catalogue.catalogSha256,security:security.sha256})),expectedCatalogue,'Enrolled catalogue differs from approval')
+}
+
+export async function markerFenceEnrollmentMain(args:string[]){
+ assert(args[0]==='marker-fence-enroll'&&args.length===1+2*flags.length)
+ assertJsDriverEnvironment(process.env)
+ const flagsByName=new Map()
+ for(let i=1;ireadProtected(flagsByName.get(name)!,maximum,pin)
+ const approval=json(await read('approval',16384,flagsByName.get('approval-sha256')!))
+ const manifestSha256=migrationManifestDigest()
+ assert.deepEqual(Object.keys(approval).sort(),['catalogSha256','definitionSha256','deploymentRequest','format','manifestSha256'])
+ assert(approval.format==='application-writer-marker-fence-enrollment-v1'&&approval.manifestSha256===manifestSha256&&
+ manifestSha256===BUILD57_PROVENANCE.manifestSha256&&approval.definitionSha256===BUILD57_PROVENANCE.templateSha256&&
+ typeof approval.catalogSha256==='string'&&digest.test(approval.catalogSha256))
+ const request=deploymentRequest(approval.deploymentRequest),bindings:RegistryRoleBindingsData=request.roles
+ const transport=json(await read('transport',16384,flagsByName.get('transport-sha256')!))
+ const ca=await read('ca',65536,request.tls.caSha256)
+ const options=poolOptions(transport,request,ca,'operator')
+ const {default:pg}=await import('pg')
+ const pool=new pg.Pool({...options,query_timeout:12_000})
+ const deadline=Date.now()+120_000
+ let client:PoolClient|undefined,commitSent=false,committed=false,failure:unknown
+ const onError=(error:Error)=>{failure??=error}
+ pool.on('error',onError)
+ try{
+ const connected=await pool.connect()
+ client=connected
+ connected.on('error',onError)
+ const assertPeer=retainPublisherTlsPeer(connected,request.tls)
+ const fence=()=>{if(failure)throw failure;assert(Date.now()>(text:string,parameters?:unknown[])=>{
+ fence()
+ const result=await connected.query(text,parameters)
+ fence()
+ return result
+ }
+ await query('BEGIN')
+ await enrollMarkerFenceInTransaction(query,bindings,request.source,approval.catalogSha256)
+ fence()
+ commitSent=true
+ const ack=await connected.query('COMMIT')
+ assert.equal(ack.command,'COMMIT')
+ committed=true
+ }catch(error){failure??=error}
+ finally{
+ try{client?.release(true)}catch(error){failure??=error}
+ try{await pool.end()}catch(error){failure??=error}
+ }
+ if(committed)return {event:receiptEvent,outcome:'committed',installationId:request.installationId,manifestSha256,
+ catalogSha256:approval.catalogSha256,cleanupUnconfirmed:!!failure,automaticReplay:false,readyAuthorized:false}
+ if(commitSent)throw Object.assign(Error('Marker fence enrollment requires inspection',{cause:failure}),{code:'MARKER_FENCE_TERMINAL_UNKNOWN'})
+ throw failure??Error('Marker fence enrollment refused')
+}
diff --git a/backend/scripts/writer-profile/marker-fence-enrollment.test.mts b/backend/scripts/writer-profile/marker-fence-enrollment.test.mts
new file mode 100644
index 00000000..864dafa5
--- /dev/null
+++ b/backend/scripts/writer-profile/marker-fence-enrollment.test.mts
@@ -0,0 +1,67 @@
+import assert from 'node:assert/strict'
+import {EventEmitter} from 'node:events'
+import {mock,test} from 'node:test'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../../src/db/migration-manifest.js'
+import {canonical,sha} from '../../src/db/application-writer-profile-format.js'
+import {BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE} from './fixed57-build-definition.js'
+
+test('marker enrollment gates exact DDL on the retained operator and checks the approved result before COMMIT',async()=>{
+ const roles=Object.fromEntries(['runtime','operator','capture','publisher','control'].map((role,index)=>[role,{name:`app_${role}`,signedOid:String(20000+index)}]))
+ const source={databaseOid:'30000',databaseName:'fixture',systemIdentifier:'121212',serverVersionNum:180004,inRecovery:false}
+ const pin='a'.repeat(64)
+ const deploymentRequest={format:'application-writer-bootstrap-request-v1',installationId:'7435bc0c-b7c8-40d8-be88-5f6ae478a221',sourceHeadSha256:pin,
+ source,roles,tls:{serverName:'localhost',caSha256:pin,spkiSha256:pin}}
+ const approval={format:'application-writer-marker-fence-enrollment-v1',manifestSha256:migrationManifestDigest(),definitionSha256:BUILD57_PROVENANCE.templateSha256,
+ catalogSha256:sha(canonical({base:pin,security:pin})),deploymentRequest}
+ const args=['marker-fence-enroll','--approval','approval','--approval-sha256',pin,'--transport','transport','--transport-sha256',pin,'--ca','ca']
+ const [{function:_function,owner:_owner,...event}]=FIXED57_ROLE_TEMPLATE.events
+ const expectedFunction=FIXED57_ROLE_TEMPLATE.functions.find(fn=>fn.proname==='candidate_operator_ddl')!
+ const eventRow={...event,owner:roles.control.name,function_owner:roles.control.signedOid,acl:[`${roles.control.name}=X/${roles.control.name}`],
+ definition:expectedFunction.definition.replace('@mm-role:operator@',roles.operator.name)}
+ let scenario='success'
+ const calls:string[]=[]
+ class Client extends EventEmitter{
+ async query(sql:string){
+ calls.push(sql)
+ if(sql.includes('pg_catalog.pg_control_system()'))return {rows:[{...source,roleOid:roles.operator.signedOid}]}
+ if(sql.includes('FROM public.schema_migrations'))return {rows:MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)}))}
+ if(sql.includes('pg_catalog.pg_event_trigger'))return {rows:[scenario==='event-drift'?{...eventRow,evtenabled:'D'}:eventRow]}
+ if(sql==='COMMIT'&&scenario==='lost-ack')throw Error('Synthetic ACK loss')
+ return {command:sql,rows:[]}
+ }
+ release(destroy:boolean){assert(destroy);calls.push('release')}
+ }
+ class Pool extends EventEmitter{
+ async connect(){return new Client()}
+ async end(){calls.push('end')}
+ }
+ mock.module('pg',{defaultExport:{Pool}})
+ mock.module('./operator-files.mjs',{namedExports:{readProtected:async(path:string,_limit:number,expected:string)=>{
+ assert.equal(expected,pin);return Buffer.from(JSON.stringify(path==='approval'?approval:{}))
+ }}})
+ mock.module('./operator-contract.mjs',{namedExports:{assertJsDriverEnvironment:()=>{},poolOptions:(_transport:unknown,request:typeof deploymentRequest,_ca:Buffer,role:string)=>{
+ assert.deepEqual(request,deploymentRequest);assert.equal(role,'operator');return {}
+ },retainPublisherTlsPeer:()=>()=>{}}})
+ mock.module('../../src/db/application-writer-profile-registry-structure.js',{namedExports:{readProtectedRegistryStructureData:async()=>({sha256:pin})}})
+ mock.module('../../src/db/partition-guard-inheritance.js',{namedExports:{assertReviewedMigrationMarkerGuard:async(_sql:unknown,state='installed')=>{
+ calls.push(state);if(scenario==='partial'&&state==='unenrolled')throw Error('Synthetic preexisting guard')
+ }}})
+ mock.module('./catalogue.mjs',{namedExports:{collectSource57Catalogue:async()=>{
+ calls.push('collect');return {catalogSha256:scenario==='catalogue-drift'?'b'.repeat(64):pin}
+ }}})
+ const {markerFenceEnrollmentMain}=await import('./marker-fence-enrollment.mjs')
+ const result=await markerFenceEnrollmentMain(args)
+ assert.equal(result.outcome,'committed');assert.equal(result.readyAuthorized,false)
+ const exclusive=calls.findIndex(sql=>sql.includes('pg_advisory_xact_lock')),table=calls.findIndex(sql=>sql.startsWith('LOCK TABLE'))
+ const ddl=calls.findIndex(sql=>sql.startsWith('CREATE TRIGGER'))
+ assert(exclusive>=0&&exclusive]sql.startsWith('CREATE TRIGGER')).length,['catalogue-drift','lost-ack'].includes(variant)?1:0)
+ assert.equal(calls.filter(sql=>sql==='COMMIT').length,variant==='lost-ack'?1:0)
+ assert.deepEqual(calls.slice(-2),['release','end'])
+ }
+})
diff --git a/backend/scripts/writer-profile/operator-contract.mjs b/backend/scripts/writer-profile/operator-contract.mjs
new file mode 100644
index 00000000..295ca0c8
--- /dev/null
+++ b/backend/scripts/writer-profile/operator-contract.mjs
@@ -0,0 +1,66 @@
+import assert from 'node:assert/strict'
+import {X509Certificate} from 'node:crypto'
+import {checkServerIdentity,TLSSocket} from 'node:tls'
+import {sha} from './operator-files.mjs'
+export const roleKeys=Object.freeze(['runtime','operator','capture','publisher','control'])
+// jit=off: JIT compilation of the large catalogue queries alone can exceed the fixed capture limits (5 s plans on PostgreSQL 18).
+export const STARTUP_OPTIONS='-c statement_timeout=10000 -c lock_timeout=5000 -c client_encoding=UTF8 -c jit=off'
+export function assertJsDriverEnvironment(environment){assert(!Object.hasOwn(environment,'NODE_PG_FORCE_NATIVE'),'Native pg driver selector refused')}
+const hex=v=>typeof v==='string'&&/^[a-f0-9]{64}$/.test(v)
+const exact=(v,keys)=>v&&typeof v==='object'&&!Array.isArray(v)&&Object.keys(v).length===keys.length&&keys.every(k=>Object.hasOwn(v,k))
+const publicationFormat='application-writer-publication-approval-v1'
+export const UPGRADE_APPROVAL_FORMAT='application-writer-upgrade44-to56-approval-v1'
+export const UPGRADE57_APPROVAL_FORMAT='application-writer-upgrade56-to57-approval-v1'
+export const UPGRADE58_APPROVAL_FORMAT='application-writer-upgrade57-to58-approval-v1'
+export const REBIND58_APPROVAL_FORMAT='application-writer-rebind58-after-restore-approval-v1'
+export const isUpgradeApprovalFormat=format=>[UPGRADE_APPROVAL_FORMAT,UPGRADE57_APPROVAL_FORMAT,UPGRADE58_APPROVAL_FORMAT,REBIND58_APPROVAL_FORMAT].includes(format)
+function parsedApproval(value,format=publicationFormat){
+ const upgrade=isUpgradeApprovalFormat(format)
+ const keys=['format','manifestSha256','definitionSha256','catalogSha256','expectedHeadSha256','validityMs','expiresAt']
+ if(upgrade)keys.push('previousCatalogSha256')
+ assert(exact(value,keys)&&value.format===format)
+ assert(['manifestSha256','definitionSha256','catalogSha256'].every(k=>hex(value[k])))
+ assert(upgrade?hex(value.expectedHeadSha256)&&hex(value.previousCatalogSha256):value.expectedHeadSha256===null||hex(value.expectedHeadSha256))
+ if(format===REBIND58_APPROVAL_FORMAT)assert(value.catalogSha256!==value.previousCatalogSha256,'Restored catalogue must have a distinct independently approved digest')
+ assert(Number.isSafeInteger(value.validityMs)&&value.validityMs>0&&value.validityMs<=86400000&&Number.isSafeInteger(value.expiresAt)&&value.expiresAt>0)
+ return structuredClone(value)
+}
+export function approval(value){
+ const pinned=parsedApproval(value);assert(pinned.expiresAt>Date.now());return pinned
+}
+export function upgradeApproval(value){
+ assert(isUpgradeApprovalFormat(value?.format))
+ const pinned=parsedApproval(value,value.format);assert(pinned.expiresAt>Date.now());return pinned
+}
+// Pinned historical inspection data only; never publication authorization.
+export function reconciliationApproval(value){return parsedApproval(value,isUpgradeApprovalFormat(value?.format)?value.format:publicationFormat)}
+function peerError(pin,host,cert){
+ const failed=checkServerIdentity(pin.serverName,cert);if(failed)return failed
+ try{if(host!==pin.serverName||sha(new X509Certificate(cert.raw).publicKey.export({format:'der',type:'spki'}))!==pin.spkiSha256)return Error('Publisher TLS SPKI refused')}catch{return Error('Publisher TLS certificate refused')}
+}
+
+// pg replaces connection.stream with the negotiated TLS socket. Hold its
+// identity on the retained client; handshake callbacks are not session evidence.
+export function retainPublisherTlsPeer(client,pin){
+ const socket=client.connection?.stream
+ const assertCurrent=()=>{
+ assert(socket instanceof TLSSocket&&client.connection?.stream===socket&&socket.encrypted&&socket.authorized&&!socket.destroyed&&socket.writable,'Publisher retained TLS peer unavailable')
+ }
+ assertCurrent()
+ const failed=peerError(pin,socket.servername,socket.getPeerCertificate());if(failed)throw failed
+ socket.disableRenegotiation()
+ return assertCurrent
+}
+export function poolOptions(transport,request,ca,role='publisher'){
+ assert(role==='publisher'||role==='control'||role==='operator')
+ assert(exact(transport,['host','port','user','password','database']))
+ assert(typeof transport.host==='string'&&transport.host===request.tls.serverName&&Number.isSafeInteger(transport.port)&&transport.port>0&&transport.port<=65535&&transport.user===request.roles[role].name&&typeof transport.password==='string'&&transport.password.length>0&&transport.password.length<=4096&&transport.database===request.source.databaseName)
+ assert(sha(ca)===request.tls.caSha256);new X509Certificate(ca)
+ return {host:transport.host,port:transport.port,user:transport.user,password:transport.password,database:transport.database,max:1,connectionTimeoutMillis:5000,idleTimeoutMillis:5000,statement_timeout:10000,lock_timeout:5000,options:STARTUP_OPTIONS,application_name:role==='control'?'mmapp-writer-registry-enroll':role==='operator'?'mmapp-writer-marker-fence-enroll':'mmapp-writer-publisher',client_encoding:'UTF8',
+ ssl:{ca,servername:request.tls.serverName,rejectUnauthorized:true,checkServerIdentity:(host,cert)=>peerError(request.tls,host,cert)}}
+}
+export function assertPublicationApproval(current,catalogue,structure,pinned,manifestSha256){
+ assert(pinned.expiresAt>Date.now()&&pinned.manifestSha256===manifestSha256&&pinned.definitionSha256===catalogue.definitionSha256)
+ assert(sha(JSON.stringify({base:catalogue.catalogSha256,security:structure.sha256}))===pinned.catalogSha256)
+ assert((current?.headSha256??null)===pinned.expectedHeadSha256)
+}
diff --git a/backend/scripts/writer-profile/operator-files.mjs b/backend/scripts/writer-profile/operator-files.mjs
new file mode 100644
index 00000000..1b40ada9
--- /dev/null
+++ b/backend/scripts/writer-profile/operator-files.mjs
@@ -0,0 +1,58 @@
+import assert from 'node:assert/strict'
+import {constants} from 'node:fs'
+import {open,lstat,realpath,link,unlink} from 'node:fs/promises'
+import path from 'node:path'
+import {createHash} from 'node:crypto'
+export const sha=bytes=>createHash('sha256').update(bytes).digest('hex')
+export async function protectedDirectory(directory){
+ assert(process.platform!=='win32'&&typeof process.getuid==='function','Native Windows ACL backend unavailable')
+ assert(path.isAbsolute(directory)&&await realpath(directory)===directory)
+ const uid=process.getuid(),s=await lstat(directory)
+ assert(s.isDirectory()&&!s.isSymbolicLink()&&s.uid===uid&&(s.mode&0o077)===0)
+ for(let p=path.dirname(directory);;p=path.dirname(p)){const s=await lstat(p);assert(s.isDirectory()&&!s.isSymbolicLink()&&(s.uid===uid||s.uid===0));assert((s.mode&0o022)===0||s.uid===0&&(s.mode&0o1000)!==0);if(p===path.dirname(p))break}
+}
+export async function readProtected(file,maximum,expectedSha){
+ await protectedDirectory(path.dirname(file));assert(await realpath(file)===file)
+ const f=await open(file,constants.O_RDONLY|constants.O_NOFOLLOW)
+ try{
+ const a=await f.stat();assert(a.isFile()&&a.uid===process.getuid()&&(a.mode&0o077)===0&&a.size>0&&a.size<=maximum)
+ const out=Buffer.alloc(a.size+1);let size=0
+ while(size{const d=await open(directory,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW);try{await d.sync()}finally{await d.close()}}
+ try{
+ identity=await handle.stat({bigint:true});await handle.writeFile('mmapp-writer-journal-lease-v1\n');await handle.sync();await syncDirectory()
+ result=await work()
+ }catch(error){primary=error;failed=true}
+ finally{
+ try{
+ await protectedDirectory(directory)
+ const current=await lstat(filename,{bigint:true})
+ if(!identity||!current.isFile()||current.isSymbolicLink()||current.dev!==identity.dev||current.ino!==identity.ino)throw Error('Journal lease identity changed')
+ await unlink(filename);await syncDirectory()
+ }catch(error){cleanupFailed=true;primary??=error}
+ try{await handle.close()}catch(error){cleanupFailed=true;primary??=error}
+ }
+ // Known COMMIT remains known if the filesystem cleanup fails later.
+ if(!failed&&result?.outcome==='committed'&&cleanupFailed)return Object.freeze({...result,journalUnconfirmed:true})
+ if(failed||cleanupFailed)throw primary
+ return result
+}
diff --git a/backend/scripts/writer-profile/operator-journal-lease.test.mjs b/backend/scripts/writer-profile/operator-journal-lease.test.mjs
new file mode 100644
index 00000000..5c98577c
--- /dev/null
+++ b/backend/scripts/writer-profile/operator-journal-lease.test.mjs
@@ -0,0 +1,68 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import {mkdtemp, chmod, readdir, writeFile, readFile, unlink, rm} from 'node:fs/promises'
+import {tmpdir} from 'node:os'
+import path from 'node:path'
+import {withJournalLease} from './operator-files.mjs'
+
+const posix = process.platform !== 'win32'
+async function owned(work) {
+ const directory = await mkdtemp(path.join(tmpdir(), 'mm-operator-lease-'))
+ try { await chmod(directory, 0o700); await work(directory) }
+ finally { await rm(directory, {recursive: true, force: true}) }
+}
+
+test('Windows refuses before callback or lease creation', {skip: posix}, async () => {
+ await owned(async directory => {
+ let called = false
+ await assert.rejects(withJournalLease(directory, async () => { called = true }), /Windows ACL/)
+ assert.equal(called, false)
+ assert.deepEqual(await readdir(directory), [])
+ })
+})
+
+test('POSIX cooperative exclusion spans the entire callback and cleanup', {skip: !posix}, async () => {
+ await owned(async directory => {
+ let entered, release
+ const ready = new Promise(resolve => { entered = resolve })
+ const held = new Promise(resolve => { release = resolve })
+ const first = withJournalLease(directory, async () => { entered(); await held; return 'first' })
+ await ready
+ try {
+ let secondCalled = false
+ await assert.rejects(withJournalLease(directory, async () => { secondCalled = true }), {code: 'EEXIST'})
+ assert.equal(secondCalled, false)
+ assert.deepEqual(await readdir(directory), ['publisher-lease.lock'])
+ } finally { release(); await first }
+ assert.deepEqual(await readdir(directory), [])
+ assert.equal(await withJournalLease(directory, async () => 'next'), 'next')
+ })
+})
+
+test('POSIX unknown work retains its pending cursor and original error', {skip: !posix}, async () => {
+ await owned(async directory => {
+ const pending = path.join(directory, 'pending-publication.json'), failure = new Error('unknown publication')
+ await assert.rejects(withJournalLease(directory, async () => {
+ await writeFile(pending, 'pending', {flag: 'wx', mode: 0o600})
+ throw failure
+ }), error => error === failure)
+ assert.equal(await readFile(pending, 'utf8'), 'pending')
+ assert.deepEqual(await readdir(directory), ['pending-publication.json'])
+ })
+})
+
+test('POSIX foreign replacement remains and known COMMIT survives cleanup refusal', {skip: !posix}, async () => {
+ await owned(async directory => {
+ const lease = path.join(directory, 'publisher-lease.lock')
+ const result = await withJournalLease(directory, async () => {
+ await unlink(lease)
+ await writeFile(lease, 'foreign lease', {flag: 'wx', mode: 0o600})
+ return {outcome: 'committed', epoch: '9', headSha256: 'a'.repeat(64)}
+ })
+ assert.equal(result.outcome, 'committed')
+ assert.equal(result.epoch, '9')
+ assert.equal(result.journalUnconfirmed, true)
+ assert.equal(await readFile(lease, 'utf8'), 'foreign lease')
+ await assert.rejects(withJournalLease(directory, async () => assert.fail('foreign lease was adopted')), {code: 'EEXIST'})
+ })
+})
diff --git a/backend/scripts/writer-profile/protected-source-registry.mts b/backend/scripts/writer-profile/protected-source-registry.mts
new file mode 100644
index 00000000..4b2db065
--- /dev/null
+++ b/backend/scripts/writer-profile/protected-source-registry.mts
@@ -0,0 +1,84 @@
+/** Explicit operator/lifecycle read component. No startup, grants or READY. */
+import assert from 'node:assert/strict'
+import {lstat} from 'node:fs/promises'
+import path from 'node:path'
+import {protectedDirectory,readProtected} from './operator-files.mjs'
+import {createDatabaseSourceBindingVerifier,readDatabaseSourceBindingRegistry,
+ type DatabaseSourceDeploymentPin} from '../../src/db/database-source-binding.js'
+import type {DatabaseSourceObservation,DatabaseSourceObservationOptions} from '../../src/db/database-source-observation.js'
+import type {ProbeStorageSql} from '../../src/services/server-probe-journal-maintenance.js'
+
+const hex=(value:unknown):value is string=>typeof value==='string'&&/^[a-f0-9]{64}$/.test(value)
+function fence(options:DatabaseSourceObservationOptions){
+ assert(Number.isSafeInteger(options.deadlineAt)&&Date.now()={}
+ for(let p=pin.registryDirectory;;p=path.dirname(p)){
+ directories[p]=await identity(p,p===pin.registryDirectory)
+ if(p===path.dirname(p))break
+ }
+ const names=['operator-public.pem','head-'+pin.currentHeadSha256+'.json']
+ const content:Record={},identities:Record={}
+ const collect=async(name:string,maximum:number,expected?:string)=>{
+ const filename=path.join(pin.registryDirectory,name)
+ const before=await identity(filename,true)
+ content[name]=await readProtected(filename,maximum,expected)
+ assert.equal(await identity(filename,true),before,'Protected source file changed during read')
+ identities[name]=before
+ }
+ await collect(names[0],4096)
+ await collect(names[1],8192,pin.currentHeadSha256)
+ const head=JSON.parse(new TextDecoder('utf8',{fatal:true}).decode(content[names[1]]))
+ assert(hex(head?.body?.bindingSha256),'Pinned source binding digest required')
+ const bindingName='binding-'+head.body.bindingSha256+'.json'
+ await collect(bindingName,8192,head.body.bindingSha256)
+ await protectedDirectory(pin.registryDirectory)
+ for(const [directory,wanted]of Object.entries(directories))assert.equal(await identity(directory,directory===pin.registryDirectory),wanted,'Protected source directory changed')
+ return {directories,identities,content}
+}
+function same(before:Awaited>,after:Awaited>){
+ assert.deepEqual(after.directories,before.directories,'Protected source directory drift')
+ assert.deepEqual(after.identities,before.identities,'Protected source identity/mode drift')
+ assert.deepEqual(after.content,before.content,'Protected source content drift')
+}
+function captured(raw:DatabaseSourceDeploymentPin){
+ const pin=Object.freeze({...raw})
+ // Existing strict deployment schema rejects unknown/malformed pin fields.
+ const verifier=createDatabaseSourceBindingVerifier(pin)
+ return {pin,verifier}
+}
+
+/** Signature/head/source DATA plus actual POSIX protection of the pinned files.
+ * The supplied pin still needs independent deployment approval; protection
+ * cannot distinguish a restored clone/generation or authenticate all writers. */
+export async function readProtectedDatabaseSourceBindingRegistry(raw:DatabaseSourceDeploymentPin,options:DatabaseSourceObservationOptions){
+ const {pin}=captured(raw);const lifetime={...options};fence(lifetime)
+ const before=await protectedState(pin);fence(lifetime)
+ const result=await readDatabaseSourceBindingRegistry(pin);fence(lifetime)
+ const after=await protectedState(pin);fence(lifetime);same(before,after)
+ return Object.freeze({...result,platformProtectionVerified:true as const,
+ generationAuthenticated:false as const,allWriterDrainAuthenticated:false as const,readyAuthorized:false as const})
+}
+
+/** Same-facade source verification is retained; filesystem JSON is never a
+ * source observation, writer capability or independent generation authority. */
+export function createProtectedDatabaseSourceBindingVerifier(raw:DatabaseSourceDeploymentPin){
+ const {pin,verifier}=captured(raw)
+ return Object.freeze({async verify(sql:ProbeStorageSql,observation:DatabaseSourceObservation,options:DatabaseSourceObservationOptions){
+ const lifetime={...options};fence(lifetime)
+ const before=await protectedState(pin);fence(lifetime)
+ const result=await verifier.verify(sql,observation,lifetime);fence(lifetime)
+ const after=await protectedState(pin);fence(lifetime);same(before,after)
+ return Object.freeze({...result,platformProtectionVerified:true as const,
+ generationAuthenticated:false as const,allWriterDrainAuthenticated:false as const,readyAuthorized:false as const})
+ }})
+}
diff --git a/backend/scripts/writer-profile/protected-source-registry.test.mts b/backend/scripts/writer-profile/protected-source-registry.test.mts
new file mode 100644
index 00000000..07436e8c
--- /dev/null
+++ b/backend/scripts/writer-profile/protected-source-registry.test.mts
@@ -0,0 +1,85 @@
+/** Genuine Ed25519/files; POSIX permission metadata is modeled on Windows.
+ * No SQL, service, deployment or real POSIX acceptance is claimed. */
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import fs from 'node:fs/promises'
+import path from 'node:path'
+import os from 'node:os'
+import crypto from 'node:crypto'
+import {createRequire} from 'node:module'
+import type {Stats,BigIntStats} from 'node:fs'
+import type {DatabaseSourceDeploymentPin} from '../../src/db/database-source-binding.ts'
+import type * as ProtectedApi from './protected-source-registry.mts'
+import {runInNewContext} from 'node:vm'
+import {readProtectedDatabaseSourceBindingRegistry} from './protected-source-registry.mts'
+import {readDatabaseSourceBindingRegistry,sourceBindingBytes,sourceBindingCanonical,sourceBindingSha256,DATABASE_SOURCE_SIGNATURE_DOMAINS} from '../../src/db/database-source-binding.ts'
+const require=createRequire(import.meta.url),ts=require('typescript')
+const helperSource=await fs.readFile(new URL('./operator-files.mjs',import.meta.url),'utf8')
+const source=await fs.readFile(new URL('./protected-source-registry.mts',import.meta.url),'utf8')
+const deadline=()=>({deadlineAt:Date.now()+10000})
+function compile(text:string){return ts.transpileModule(text,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText}
+function evaluate>(text:string,imports:Record,processModel:unknown=process):T{
+ const exports:Record={}
+ runInNewContext(compile(text),{exports,require:(name:string)=>imports[name]??require(name),process:processModel,Buffer,TextDecoder,console})
+ return exports as T
+}
+interface Fixture {pin:DatabaseSourceDeploymentPin;faults:Record;api:typeof ProtectedApi;verificationReads:()=>number;root:string}
+async function own(work:(f:Fixture)=>Promise){
+ const root=await fs.mkdtemp(path.join(os.tmpdir(),'mm-protected-source-'))
+ try{
+ const key=crypto.generateKeyPairSync('ed25519'),installationId=crypto.randomUUID()
+ const signed=(body:unknown,domain:string)=>sourceBindingBytes({body,signature:crypto.sign(null,Buffer.from(domain+sourceBindingCanonical(body)),key.privateKey).toString('base64url')})
+ const body={format:'database-source-binding-v1',installationId,sourceIdentityId:crypto.randomUUID(),generation:crypto.randomUUID(),ordinal:1,
+ source:{systemIdentifier:'123',databaseOid:16384,databaseName:'synthetic',sessionUser:'capture',currentUser:'capture',inRecovery:false,serverVersionNum:180004}}
+ const binding=signed(body,DATABASE_SOURCE_SIGNATURE_DOMAINS.binding),bindingSha256=sourceBindingSha256(binding)
+ const head=signed({format:'database-source-registry-head-v1',installationId,sourceIdentityId:body.sourceIdentityId,generation:body.generation,ordinal:1,bindingSha256,previousHeadSha256:null},DATABASE_SOURCE_SIGNATURE_DOMAINS.head)
+ const pin={registryDirectory:root,installationId,publicKeySpkiSha256:sourceBindingSha256(key.publicKey.export({format:'der',type:'spki'})),currentHeadSha256:sourceBindingSha256(head)}
+ await fs.writeFile(path.join(root,'operator-public.pem'),key.publicKey.export({format:'pem',type:'spki'}),{mode:0o600})
+ await fs.writeFile(path.join(root,'head-'+pin.currentHeadSha256+'.json'),head,{mode:0o600})
+ await fs.writeFile(path.join(root,'binding-'+bindingSha256+'.json'),binding,{mode:0o600})
+ const faults={modeFile:false,modeDirectory:false,symlink:false,replacement:false,lateMode:false,changed:false};let verificationReads=0
+ const metadata=(s:Stats|BigIntStats,filename:string,big:boolean)=>{
+ const n=(value:number)=>big?BigInt(value):value,isRoot=filename===root,isFile=s.isFile()
+ const mode=(isFile?0o100600:0o40700)|((isFile&&faults.modeFile||isRoot&&faults.modeDirectory||isFile&&faults.lateMode&&faults.changed)?0o022:0)
+ return {...s,mode:n(mode),uid:n(1000),gid:n(1000),ino:faults.replacement&&faults.changed&&isFile?(typeof s.ino==='bigint'?s.ino+1n:s.ino+1):s.ino,
+ isFile:()=>isFile,isDirectory:()=>s.isDirectory(),isSymbolicLink:()=>faults.symlink&&isRoot}
+ }
+ const modelFs={...fs,lstat:async(filename:string,options?:{bigint?:boolean})=>metadata(await fs.lstat(filename,{bigint:options?.bigint===true}),filename,options?.bigint===true),open:async(filename:string,flags:number)=>{
+ const file=await fs.open(filename,flags)
+ return {stat:async()=>metadata(await file.stat(),filename,false),read:file.read.bind(file),close:file.close.bind(file)}
+ }}
+ const processModel={platform:'linux',getuid:()=>1000}
+ const proven=evaluate(helperSource,{'node:fs/promises':modelFs},processModel)
+ const bindingModule={readDatabaseSourceBindingRegistry:async(p:DatabaseSourceDeploymentPin)=>{
+ verificationReads++;const result=await readDatabaseSourceBindingRegistry(p);faults.changed=true;return result
+ },createDatabaseSourceBindingVerifier:()=>({verify:async()=>{verificationReads++;faults.changed=true;return {genuineSourceFactsMatched:true,generationAuthenticated:false,readyAuthorized:false}}})}
+ const api=evaluate(source,{'node:fs/promises':modelFs,'./operator-files.mjs':proven,'../../src/db/database-source-binding.js':bindingModule},processModel)
+ await work({pin,faults,api,verificationReads:()=>verificationReads,root})
+ }finally{const rel=path.relative(os.tmpdir(),root);assert(rel&&!rel.startsWith('..')&&!path.isAbsolute(rel));await fs.rm(root,{recursive:true,force:true})}
+}
+
+test('unsupported Windows refuses before registry signature reads',{skip:process.platform!=='win32'},async()=>{
+ await assert.rejects(readProtectedDatabaseSourceBindingRegistry({registryDirectory:path.resolve('not-created-protected-source'),installationId:crypto.randomUUID(),publicKeySpkiSha256:'a'.repeat(64),currentHeadSha256:'b'.repeat(64)},deadline()),/Windows ACL/)
+})
+test('proven POSIX helpers plus genuine signature/head bytes retain false generation/READY',()=>own(async f=>{
+ const value=await f.api.readProtectedDatabaseSourceBindingRegistry(f.pin,deadline())
+ assert.equal(value.platformProtectionVerified,true);assert.equal(value.generationAuthenticated,false);assert.equal(value.allWriterDrainAuthenticated,false);assert.equal(value.readyAuthorized,false)
+ assert.equal(value.headSha256,f.pin.currentHeadSha256);assert.equal(f.verificationReads(),1)
+}))
+for(const fault of ['modeFile','modeDirectory','symlink'])test(fault+' refuses before cryptographic registry read',()=>own(async f=>{
+ f.faults[fault]=true;await assert.rejects(f.api.readProtectedDatabaseSourceBindingRegistry(f.pin,deadline()));assert.equal(f.verificationReads(),0)
+}))
+for(const fault of ['replacement','lateMode'])test(fault+' during genuine signature verification refuses protected output',()=>own(async f=>{
+ f.faults[fault]=true;await assert.rejects(f.api.readProtectedDatabaseSourceBindingRegistry(f.pin,deadline()));assert.equal(f.verificationReads(),1)
+}))
+test('expired/aborted lifetime refuses before filesystem or source access',()=>own(async f=>{
+ const abort=new AbortController();abort.abort()
+ for(const options of [{deadlineAt:Date.now()-1},{deadlineAt:Date.now()+1000,signal:abort.signal}])await assert.rejects(f.api.readProtectedDatabaseSourceBindingRegistry(f.pin,options))
+ assert.equal(f.verificationReads(),0)
+}))
+test('source verifier drift cannot grant protected output',()=>own(async f=>{
+ f.faults.lateMode=true
+ const verify=f.api.createProtectedDatabaseSourceBindingVerifier(f.pin).verify
+ await assert.rejects(verify({} as Parameters[0],{} as Parameters[1],deadline()))
+ assert.equal(f.verificationReads(),1)
+}))
diff --git a/backend/scripts/writer-profile/publisher.mjs b/backend/scripts/writer-profile/publisher.mjs
new file mode 100644
index 00000000..bffc7412
--- /dev/null
+++ b/backend/scripts/writer-profile/publisher.mjs
@@ -0,0 +1,345 @@
+// OPERATOR/CLI ONLY. Runtime host must never import this private-key module.
+import pg from 'pg'
+import {createPrivateKey,createPublicKey,sign,X509Certificate} from 'node:crypto'
+import {open,lstat,realpath,unlink} from 'node:fs/promises'
+import {readProtected,writeFile,withJournalLease} from './operator-files.mjs'
+import {retainPublisherTlsPeer,upgradeApproval,isUpgradeApprovalFormat,UPGRADE_APPROVAL_FORMAT,UPGRADE57_APPROVAL_FORMAT,UPGRADE58_APPROVAL_FORMAT,REBIND58_APPROVAL_FORMAT} from './operator-contract.mjs'
+import {BUILD44_PROVENANCE} from './fixed44-build-definition.js'
+import {BUILD56_PROVENANCE} from './fixed56-build-definition.js'
+import {BUILD57_PROVENANCE} from './fixed57-build-definition.js'
+import {BUILD58_PROVENANCE} from './fixed58-build-definition.js'
+import path from 'node:path'
+import {captureDatabaseSourceObservation,assertDatabaseSourceObservationCurrent} from '../../src/db/database-source-observation.js'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../../src/db/migration-manifest.js'
+
+
+import {ownedContext,sameOwned,sourceCoordinates,protectedStructure,readCurrent,HISTORY,CURRENT} from './context.mjs'
+import {bytes,canonical,sha,nextEpoch,POLICY_DOMAIN,HEAD_DOMAIN,KEY,liveValidity,policySchema,headSchema,publicKey} from '../../src/db/application-writer-profile-format.js'
+const upgradeTransitions = {
+ [UPGRADE_APPROVAL_FORMAT]: { predecessor: BUILD44_PROVENANCE, successor: BUILD56_PROVENANCE, oldEdition: 44, newEdition: 56 },
+ [UPGRADE57_APPROVAL_FORMAT]: { predecessor: BUILD56_PROVENANCE, successor: BUILD57_PROVENANCE, oldEdition: 56, newEdition: 57 },
+ [UPGRADE58_APPROVAL_FORMAT]: { predecessor: BUILD57_PROVENANCE, successor: BUILD58_PROVENANCE, oldEdition: 57, newEdition: 58 },
+ [REBIND58_APPROVAL_FORMAT]: { predecessor: BUILD58_PROVENANCE, successor: BUILD58_PROVENANCE, oldEdition: 58, newEdition: 58 },
+}
+export function requireCurrentCatalogueDefinition(approval,definition){
+ const manifestSha256=migrationManifestDigest()
+ if(approval.manifestSha256!==manifestSha256||definition.manifestSha256!==manifestSha256||definition.definitionSha256!==approval.definitionSha256)throw Error('Approved catalogue definition is not bound to this build migration manifest')
+ return manifestSha256
+}
+
+/** Trusted held owner only. The independent issuer supplies the signed bytes. */
+export async function publishLegacyHandoffIntent({application,control,sourcePin,tlsPin,archiveDirectory,signedIntent,deadlineAt}){
+ if(!Buffer.isBuffer(signedIntent)||signedIntent.length===0||signedIntent.length>4096)throw Error('Bounded signed legacy intent required')
+ const intentBytes=Buffer.from(signedIntent),pin=Object.freeze({...sourcePin})
+ if(!Number.isSafeInteger(deadlineAt)||Date.now()>=deadlineAt||deadlineAt-Date.now()>120000)throw Error('Bounded held legacy handoff lifetime required')
+ const live=retainPublisherTlsPeer(application,tlsPin)
+ const fence=()=>{live();if(Date.now()>=deadlineAt)throw Error('Held legacy handoff deadline exceeded')}
+ let controlAcknowledged=false
+ try{return await withJournalLease(archiveDirectory,async()=>{
+ const {assertHeldLegacyProbeOwner,verifyHeldLegacyProbeOwner,verifyLegacyProbeHandoffIntent}=await import('../../src/services/server-probe-legacy-handoff-inspection.js')
+ const {readProtectedDatabaseSourceBindingRegistry}=await import('./protected-source-registry.mjs')
+ await readProtectedDatabaseSourceBindingRegistry(pin,{deadlineAt})
+ const [archive,signedApproval,coldArchive,operatorPublicKeyPem]=await Promise.all([
+ readProtected(path.join(archiveDirectory,'legacy-probe.dump'),64*1024*1024),
+ readProtected(path.join(archiveDirectory,'legacy-probe-approval.json'),4096),
+ readProtected(path.join(archiveDirectory,'legacy-probe-cold.dump'),64*1024*1024),
+ readProtected(path.join(pin.registryDirectory,'operator-public.pem'),4096),
+ ])
+ const intent=await verifyLegacyProbeHandoffIntent(pin,{archive,signedApproval,coldArchive,intent:intentBytes,operatorPublicKeyPem})
+ const sql={query:async(text,values)=>{fence();const result=await application.query(text,values);fence();return result}}
+ const proof=await verifyHeldLegacyProbeOwner(sql,intent)
+ const intentFile=path.join(archiveDirectory,'legacy-probe-handoff-intent.json')
+ await writeFile(intentFile,intentBytes,{flag:'wx',mode:0o600})
+ await readProtected(intentFile,4096,intent.intentSha256)
+ await assertHeldLegacyProbeOwner(sql,proof)
+ try{await control.beginLegacyHandoff(proof);controlAcknowledged=true}catch(error){
+ if(error?.outcomeUnknown===true){
+ const unknown=bytes({format:'legacy-probe-0037-control-unknown-v1',operationId:intent.operationId,intentSha256:intent.intentSha256,automaticReplay:false})
+ try{await writeFile(path.join(archiveDirectory,'legacy-probe-handoff-control-unknown.json'),unknown,{flag:'wx',mode:0o600})}catch{/* The durable signed intent remains for inspection. */}
+ }
+ throw error
+ }
+ await assertHeldLegacyProbeOwner(sql,proof)
+ return Object.freeze({operationId:intent.operationId,intentSha256:intent.intentSha256,intentRecorded:true,quarantineActive:true,automaticReplay:false,readyAuthorized:false})
+ })}catch(error){
+ if(controlAcknowledged)throw Object.assign(Error('Legacy handoff quarantine is pending inspection',{cause:error}),{controlAcknowledged:true})
+ throw error
+ }
+}
+
+export function createConnectedPublisher(installation,collectFixedCatalogue,sourceVerifier,approval,definition){
+ const PUBLISHER=installation.roleBindings.publisher.name
+class ProfilePublicationError extends Error{
+ automaticReplay=false
+ constructor(outcome,phase,proposal,cleanupUnconfirmed,cause){super('Protected policy publication requires exact inspection',{cause});Object.assign(this,{outcome,phase,proposal,cleanupUnconfirmed})}
+}
+async function privateKey(filename){
+ const resolved=await realpath(filename),meta=await lstat(filename)
+ if(resolved!==path.resolve(filename)||!meta.isFile()||meta.isSymbolicLink()||meta.size<1||meta.size>8192)throw Error('Explicit bounded operator-only key file required')
+ const handle=await open(resolved,'r');let data
+ try{const stat=await handle.stat();if(stat.dev!==meta.dev||stat.ino!==meta.ino||stat.size!==meta.size)throw Error('Operator key changed');data=await handle.readFile();if(data.length!==stat.size)throw Error('Operator key size changed')}finally{await handle.close()}
+ let key;try{key=createPrivateKey(data)}finally{data.fill(0)}
+ if(key.asymmetricKeyType!=='ed25519'||sha(createPublicKey(key).export({format:'der',type:'spki'}))!==installation.publicKeySpkiSha256)throw Error('Private key does not match fixed installation')
+ publicKey(installation);return key
+}
+// One retained actual Pool client; no injected SQL facade, SET ROLE, new pool,
+// detached application callbacks or cleanup/COMMIT races.
+async function session(pool,deadlineAt,work){
+ if(!(pool instanceof pg.Pool)||!Number.isSafeInteger(deadlineAt)||deadlineAt<=Date.now()||deadlineAt-Date.now()>120000)throw Error('Bounded genuine publisher pool/lifetime required')
+ let client,assertTransport,retired=false,released=false,locked=false,begun=false,commitSent=false,committed=false,confirmedValue,proposal,phase='checkout',stopReject,cleanupUnconfirmed=false
+ const lifetime=new AbortController()
+ const stopped=new Promise((_,reject)=>{stopReject=reject});void stopped.catch(()=>{})
+ const release=bad=>{if(!client||released)return;released=true;client.off('error',fault);client.off('end',fault);try{client.release(bad)}catch{cleanupUnconfirmed=true}}
+ const fault=()=>{if(retired)return;retired=true;cleanupUnconfirmed=true;lifetime.abort();release(true);stopReject(Error('Publisher connection/lifetime ended'))}
+ const timer=setTimeout(fault,Math.max(1,deadlineAt-Date.now())),bounded=p=>Promise.race([p,stopped])
+ const fence=()=>{
+ if(retired||Date.now()>=deadlineAt)throw Error('Publisher lifetime closed')
+ try{assertTransport()}catch(error){fault();throw error}
+ }
+ const query=async(text,values)=>{fence();return bounded(client.query(text,values))}
+ const state={query,signal:lifetime.signal,archiveLeaf:()=>{
+ fence()
+ const leaf=new X509Certificate(client.connection.stream.getPeerCertificate().raw)
+ // libpq trusts this certificate directly and must not accept a delegated certificate.
+ if(leaf.ca||leaf.subject!==leaf.issuer||!leaf.verify(leaf.publicKey))throw Error('Publisher archive requires a self-signed non-CA TLS leaf')
+ return leaf.toString()
+ },phase:value=>{phase=value},proposal:value=>{proposal=Object.freeze(value)},begun:value=>{begun=value},commit:async value=>{
+ fence()
+ confirmedValue=Object.freeze({...value})
+ commitSent=true
+ const response=await bounded(client.query('COMMIT').then(result=>{if(result.command==='COMMIT'){committed=true;begun=false}return result}))
+ if(response.command!=='COMMIT')throw Error('Publisher COMMIT acknowledgement absent')
+ }}
+ let value,primary,failed=false
+ try{
+ const pending=pool.connect().then(value=>{client=value;if(retired){release(true);return value}client.on('error',fault);client.on('end',fault);return value});void pending.catch(()=>{})
+ await bounded(pending);if(retired)throw Error('Late publisher checkout')
+ try{assertTransport=retainPublisherTlsPeer(client,installation.tls)}catch(error){retired=true;release(true);throw error}
+ await query("SET statement_timeout='10s'");await query("SET lock_timeout='5s'")
+ phase='exclusive-admission';await query('SELECT pg_catalog.pg_advisory_lock($1::bigint)',[KEY]);locked=true
+ value=await work(state)
+ }catch(error){failed=true;primary=error}
+ finally{
+ if(!retired&&client){
+ if(begun&&!commitSent)try{const r=await query('ROLLBACK');if(r.command!=='ROLLBACK')throw Error('Publisher rollback unconfirmed');begun=false}catch{fault()}
+ if(commitSent&&!committed){cleanupUnconfirmed=true;retired=true;release(true)}
+ if(!retired&&locked)try{const r=await query('SELECT pg_catalog.pg_advisory_unlock($1::bigint) AS released',[KEY]);if(r.rows.length!==1||r.rows[0].released!==true)throw Error('Publisher unlock unconfirmed');locked=false}catch{fault()}
+ if(!retired)try{await query('RESET lock_timeout');await query('RESET statement_timeout')}catch{fault()}
+ }
+ clearTimeout(timer);release(retired||cleanupUnconfirmed||begun||locked||committed&&failed)
+ }
+ if(committed)return Object.freeze({...confirmedValue,...value,outcome:'committed',proposal,cleanupUnconfirmed:cleanupUnconfirmed||retired||failed,automaticReplay:false})
+ if(failed||cleanupUnconfirmed||retired)throw new ProfilePublicationError(commitSent||begun?'unknown':'not-committed',phase,proposal,cleanupUnconfirmed||retired,primary)
+ return value
+}
+async function observeCurrentCatalogue(s,manifestSha256){
+ const security=await protectedStructure(s,installation,definition?.edition===58),catalogue=await collectFixedCatalogue(s)
+ if(catalogue.manifestSha256!==manifestSha256||catalogue.definitionSha256!==definition.definitionSha256)throw Error('Catalogue evidence differs from the approved migration manifest/definition')
+ // Inspect one extra row so an unexpected marker cannot hide after the expected prefix.
+ const expected=MIGRATION_MANIFEST.map(pin=>pin.file.slice(0,-4))
+ const markers=(await s.query('SELECT id FROM public.schema_migrations ORDER BY id COLLATE "C" LIMIT $1',[expected.length+1])).rows.map(row=>row.id)
+ if(canonical(markers)!==canonical(expected))throw Error('Exact current migration marker metadata required')
+ return {security,catalogue,catalogSha256:sha(canonical({base:catalogue.catalogSha256,security:security.sha256}))}
+}
+async function publishCurrentProfile(pool,{privateKeyFile,expectedHeadSha256,journalDirectory,validityMs=86400000,deadlineAt=Date.now()+120000},manifestSha256,upgrade){
+ const approved=upgrade??approval
+ if(!Number.isSafeInteger(validityMs)||validityMs<1||validityMs>86400000||expectedHeadSha256!==null&&!(/^[a-f0-9]{64}$/).test(expectedHeadSha256))throw Error('Explicit previous head and bounded validity required')
+ const key=await privateKey(privateKeyFile),directory=await realpath(journalDirectory),pendingFile=path.join(directory,'pending-publication.json')
+ try{await lstat(pendingFile);throw Error('Pending publication must be reconciled before signing')}catch(error){if(error.code!=='ENOENT')throw error}
+ const result=await session(pool,deadlineAt,async s=>{
+ s.phase('publisher-read');await s.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');s.begun(true)
+ const first=await ownedContext(s,installation,PUBLISHER,'publisher-read')
+ const facade=Object.freeze({query:(sql,values)=>s.query(sql,values)}),options={deadlineAt}
+ const observation=await captureDatabaseSourceObservation(facade,options)
+ const sourceEvidence=await sourceVerifier.verify(facade,observation,options)
+ if(upgrade&&sourceEvidence.platformProtectionVerified!==true)throw Error('Upgrade requires protected source evidence')
+ if(canonical(sourceCoordinates(first))!==canonical(installation.expectedSource))throw Error('Pinned source mismatch')
+ const {security,catalogue,catalogSha256}=await observeCurrentCatalogue(s,manifestSha256)
+ const old=await readCurrent(s,installation,{allowEmpty:true,validNow:false})
+ if((old?.headSha256??null)!==expectedHeadSha256)throw Error('Expected protected current head mismatch')
+ if(approved.expiresAt<=Date.now()||approved.catalogSha256!==catalogSha256)throw Error('Independently approved policy differs from actual catalogue')
+ const sameSubject=old&&canonical(old.policy.source)===canonical(sourceCoordinates(first))&&canonical(old.policy.roles)===canonical(security.roles)
+ if(upgrade){
+ const {predecessor,oldEdition}=upgradeTransitions[upgrade.format]
+ if(!sameSubject||old.policy.manifestSha256!==predecessor.manifestSha256||
+ old.policy.definitionSha256!==predecessor.templateSha256||old.policy.catalogSha256!==upgrade.previousCatalogSha256){
+ throw Error(`Upgrade requires the exact signed source${oldEdition} predecessor on the same source and roles`)
+ }
+ }else if(old&&(!sameSubject||old.policy.manifestSha256!==manifestSha256||old.policy.definitionSha256!==catalogue.definitionSha256||old.policy.catalogSha256!==catalogSha256)){
+ throw Error('Renewal cannot adopt a changed source/subject/policy')
+ }
+ const terminalSourceEvidence=await sourceVerifier.verify(facade,observation,options)
+ if(upgrade&&terminalSourceEvidence.platformProtectionVerified!==true)throw Error('Upgrade requires terminal protected source evidence')
+ await assertDatabaseSourceObservationCurrent(facade,observation,options);sameOwned(first,await ownedContext(s,installation,PUBLISHER,'publisher-read'))
+ await s.query('COMMIT');s.begun(false)
+ const number=old?nextEpoch(old.epoch):'1',now=Date.now()
+ const body=policySchema.parse({format:'application-writer-policy-v1',installationId:installation.installationId,epoch:number,issuedAt:now,notBefore:now,notAfter:now+validityMs,source:sourceCoordinates(first),sourceObservationSha256:sha(canonical(observation)),roles:security.roles,manifestSha256,definitionSha256:catalogue.definitionSha256,catalogSha256,futureLeaves:'fixed12-native-policy-v1'})
+ const envelope=(domain,body)=>bytes({body,signature:sign(null,Buffer.from(domain+canonical(body)),key).toString('base64url')})
+ const policyBytes=envelope(POLICY_DOMAIN,body),policySha256=sha(policyBytes)
+ const head=headSchema.parse({format:'application-writer-head-v1',installationId:installation.installationId,epoch:number,policySha256,previousHeadSha256:old?.headSha256??null})
+ const headBytes=envelope(HEAD_DOMAIN,head),headSha256=sha(headBytes)
+ const proposal={installationId:installation.installationId,epoch:number,headSha256,previousHeadSha256:head.previousHeadSha256,policySha256,publisherPid:first.pid}
+ s.proposal(proposal)
+ // Public, bounded, exclusively created journal; neither key nor SQL data.
+ await writeFile(path.join(directory,'proposal-'+headSha256+'.json'),bytes(proposal),{flag:'wx',mode:0o600})
+ await writeFile(pendingFile,bytes(proposal),{flag:'wx',mode:0o600})
+ s.phase('publisher-write');await s.query('BEGIN ISOLATION LEVEL READ COMMITTED READ WRITE');s.begun(true)
+ await s.query('SELECT pg_catalog.pg_current_xact_id()');await s.query('SELECT pg_catalog.pg_advisory_xact_lock_shared($1::bigint)',[KEY])
+ const owner=await ownedContext(s,installation,PUBLISHER,'publisher-write')
+ if(owner.pid!==first.pid||canonical(sourceCoordinates(owner))!==canonical(sourceCoordinates(first)))throw Error('Retained publisher source/backend changed')
+ await s.query(`SELECT id FROM mmapp_control.${CURRENT} WHERE id=1 FOR UPDATE`)
+ const current=await readCurrent(s,installation,{allowEmpty:true,validNow:false})
+ if((current?.headSha256??null)!==expectedHeadSha256)throw Error('CAS predecessor changed')
+ const again=await observeCurrentCatalogue(s,manifestSha256)
+ if(again.catalogSha256!==catalogSha256)throw Error('Policy drift during retained exclusive publication')
+ if(Date.now()>=body.notAfter||Date.now()>=approved.expiresAt)throw Error('Policy or approval expired before publication dispatch')
+ await s.query(`INSERT INTO mmapp_control.${HISTORY}(installation_id,epoch,head_sha256,previous_installation_id,previous_epoch,previous_head_sha256,policy_sha256,policy_bytes,head_bytes) VALUES($1::uuid,$2::bigint,$3,$4::uuid,$5::bigint,$6,$7,$8::bytea,$9::bytea)`,[installation.installationId,number,headSha256,old?installation.installationId:null,old?.epoch??null,old?.headSha256??null,policySha256,policyBytes,headBytes])
+ const changed=old?await s.query(`UPDATE mmapp_control.${CURRENT} SET epoch=$1::bigint,head_sha256=$2 WHERE id=1 AND installation_id=$3::uuid AND epoch=$4::bigint AND head_sha256=$5 RETURNING id`,[number,headSha256,installation.installationId,old.epoch,old.headSha256]):await s.query(`INSERT INTO mmapp_control.${CURRENT}(id,installation_id,epoch,head_sha256) VALUES(1,$1::uuid,$2::bigint,$3) RETURNING id`,[installation.installationId,number,headSha256])
+ if(changed.rows.length!==1)throw Error('Exactly one protected current CAS required')
+ sameOwned(owner,await ownedContext(s,installation,PUBLISHER,'publisher-write'));if(Date.now()>=body.notAfter||Date.now()>=approved.expiresAt)throw Error('Policy or approval expired before publication terminal');s.phase('commit');const result={epoch:number,headSha256,notAfter:body.notAfter};await s.commit(result)
+ const terminal=await ownedContext(s,installation,PUBLISHER,'publisher-session')
+ if(terminal.pid!==first.pid||canonical(sourceCoordinates(terminal))!==canonical(sourceCoordinates(first)))throw Error('Publisher session continuity unconfirmed after actual ACK')
+ return result
+ })
+ // A journal failure cannot turn a confirmed publication into retryable failure.
+ if(result.outcome==='committed'&&!result.cleanupUnconfirmed){try{const cursor=await boundedPending(pendingFile);if(cursor.headSha256!==result.headSha256)throw Error('Pending cursor differs');await unlink(pendingFile)}catch{return Object.freeze({...result,journalUnconfirmed:true})}}
+ return result
+}
+async function inspectPublication(pool,proposal,{deadlineAt=Date.now()+120000}={}){
+ if(!proposal||proposal.installationId!==installation.installationId||!(/^[a-f0-9]{64}$/).test(proposal.headSha256)||proposal.previousHeadSha256!==null&&!(/^[a-f0-9]{64}$/).test(proposal.previousHeadSha256))throw Error('Bounded public proposal required')
+ return session(pool,deadlineAt,async s=>{
+ s.phase('publication-inspection');await s.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');s.begun(true)
+ const first=await ownedContext(s,installation,PUBLISHER,'publisher-read');await protectedStructure(s,installation,definition?.edition===58)
+ if(canonical(sourceCoordinates(first))!==canonical(installation.expectedSource))throw Error('Pinned inspection source mismatch')
+ const facade=Object.freeze({query:(sql,values)=>s.query(sql,values)}),options={deadlineAt}
+ const observation=await captureDatabaseSourceObservation(facade,options);await sourceVerifier.verify(facade,observation,options)
+ const current=await readCurrent(s,installation,{allowEmpty:true,validNow:false})
+ const proposed=(await s.query(`SELECT epoch::text,head_sha256 FROM mmapp_control.${HISTORY} WHERE installation_id=$1::uuid AND epoch=$2::bigint`,[installation.installationId,proposal.epoch])).rows
+ await sourceVerifier.verify(facade,observation,options);sameOwned(first,await ownedContext(s,installation,PUBLISHER,'publisher-read'))
+ const response=await s.query('ROLLBACK');if(response.command!=='ROLLBACK')throw Error('Inspection terminal unconfirmed');s.begun(false)
+ if(current?.headSha256===proposal.headSha256&&proposed.length===1&&proposed[0].head_sha256===proposal.headSha256)return {state:'confirmed',headSha256:current.headSha256}
+ if((current?.headSha256??null)===proposal.previousHeadSha256&&proposed.length===0)return {state:'not-committed',headSha256:current?.headSha256??null}
+ throw Error('Publication state requires operator inspection; no retry')
+ })
+}
+// Read-only diagnostics on the actual protected publisher session. This does
+// not admit application/operator writes, bootstrap, restore, or READY.
+async function preflightCurrentProfile(pool,{deadlineAt=Date.now()+120000}={}){
+ const manifestSha256=requireCurrentCatalogueDefinition(approval,definition)
+ return session(pool,deadlineAt,async s=>{
+ s.phase('profile-preflight');await s.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');s.begun(true)
+ const first=await ownedContext(s,installation,PUBLISHER,'publisher-read')
+ if(canonical(sourceCoordinates(first))!==canonical(installation.expectedSource))throw Error('Pinned preflight source mismatch')
+ const facade=Object.freeze({query:(sql,values)=>s.query(sql,values)}),options={deadlineAt}
+ const observation=await captureDatabaseSourceObservation(facade,options),initialSource=await sourceVerifier.verify(facade,observation,options)
+ const {security,catalogue,catalogSha256}=await observeCurrentCatalogue(s,manifestSha256)
+ const current=await readCurrent(s,installation)
+ if(!current)throw Error('Current signed policy required for preflight')
+ if(approval.expiresAt<=Date.now()||approval.catalogSha256!==catalogSha256)throw Error('Independent preflight approval differs from actual catalogue')
+ if(canonical(current.policy.source)!==canonical(sourceCoordinates(first))||canonical(current.policy.roles)!==canonical(security.roles)||current.policy.manifestSha256!==manifestSha256||current.policy.definitionSha256!==catalogue.definitionSha256||current.policy.catalogSha256!==catalogSha256)throw Error('Current signed policy differs from actual source/roles/catalogue')
+ const terminalSource=await sourceVerifier.verify(facade,observation,options);await assertDatabaseSourceObservationCurrent(facade,observation,options)
+ sameOwned(first,await ownedContext(s,installation,PUBLISHER,'publisher-read'))
+ // Recheck the live interval after the potentially lengthy catalogue walk.
+ const clock=(await s.query('SELECT (EXTRACT(EPOCH FROM pg_catalog.clock_timestamp())*1000)::bigint::text AS now')).rows
+ if(clock.length!==1)throw Error('Preflight terminal server clock unavailable')
+ liveValidity(current.policy,Number(clock[0].now))
+ if(approval.expiresAt<=Date.now())throw Error('Preflight approval expired before terminal')
+ const terminal=await s.query('ROLLBACK');if(terminal.command!=='ROLLBACK')throw Error('Preflight terminal unconfirmed');s.begun(false)
+ return Object.freeze({state:'matched',epoch:current.epoch,headSha256:current.headSha256,notAfter:current.policy.notAfter,
+ sourceMatched:true,rolesMatched:true,catalogueMatched:true,platformProtectionVerified:initialSource?.platformProtectionVerified===true&&terminalSource?.platformProtectionVerified===true,writerAuthorized:false,generationAuthenticated:false,readyAuthorized:false})
+ })
+}
+async function inspectCurrentCatalogue(pool,{deadlineAt=Date.now()+120000}={}){
+ const manifestSha256=migrationManifestDigest()
+ if(definition?.edition!==58||definition.manifestSha256!==manifestSha256||definition.definitionSha256!==BUILD58_PROVENANCE.templateSha256)throw Error('Approved source58 definition required')
+ return session(pool,deadlineAt,async s=>{
+ s.phase('source-catalogue-inspection');await s.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');s.begun(true)
+ const first=await ownedContext(s,installation,PUBLISHER,'publisher-read')
+ if(canonical(sourceCoordinates(first))!==canonical(installation.expectedSource))throw Error('Pinned inspection source mismatch')
+ const facade=Object.freeze({query:(sql,values)=>s.query(sql,values)}),options={deadlineAt}
+ const observation=await captureDatabaseSourceObservation(facade,options)
+ const initial=await sourceVerifier.verify(facade,observation,options)
+ const {security,catalogSha256}=await observeCurrentCatalogue(s,manifestSha256)
+ const current=await readCurrent(s,installation,{validNow:false})
+ if(!current||current.policy.definitionSha256!==definition.definitionSha256||current.policy.manifestSha256!==manifestSha256||
+ canonical(current.policy.source)!==canonical(sourceCoordinates(first))||canonical(current.policy.roles)!==canonical(security.roles)){
+ throw Error('Approved source58 predecessor required')
+ }
+ const terminal=await sourceVerifier.verify(facade,observation,options)
+ if(initial.platformProtectionVerified!==true||terminal.platformProtectionVerified!==true)throw Error('Protected source evidence required')
+ await assertDatabaseSourceObservationCurrent(facade,observation,options)
+ sameOwned(first,await ownedContext(s,installation,PUBLISHER,'publisher-read'))
+ if((await s.query('ROLLBACK')).command!=='ROLLBACK')throw Error('Catalogue inspection rollback unconfirmed')
+ s.begun(false)
+ return Object.freeze({state:'observed',epoch:current.epoch,headSha256:current.headSha256,previousCatalogSha256:current.policy.catalogSha256,
+ catalogSha256,manifestSha256,definitionSha256:definition.definitionSha256,platformProtectionVerified:true,readyAuthorized:false})
+ })
+}
+async function inspectLegacyStorage(pool,{deadlineAt,archiveDirectory,custody=false,handoff}){
+ const {captureLegacyProbeStorage,captureLegacyProbeLineage,LEGACY_PROBE_CUSTODY_LOCK}=await import('../../src/services/server-probe-legacy-source-inventory.js')
+ return session(pool,deadlineAt,async s=>{
+ s.phase('legacy-storage-inspection');await s.query('BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY');s.begun(true)
+ if(custody)await s.query(LEGACY_PROBE_CUSTODY_LOCK)
+ const first=await ownedContext(s,installation,PUBLISHER,'publisher-read')
+ if(canonical(sourceCoordinates(first))!==canonical(installation.expectedSource))throw Error('Pinned legacy source mismatch')
+ const facade=Object.freeze({query:(sql,values)=>s.query(sql,values)}),options={deadlineAt}
+ await s.query("SET LOCAL TimeZone = 'UTC'; SET LOCAL DateStyle = 'ISO, YMD'")
+ const observation=await captureDatabaseSourceObservation(facade,options)
+ const initial=await sourceVerifier.verify(facade,observation,options)
+ if(handoff&&initial.platformProtectionVerified!==true)throw Error('Protected legacy handoff source required')
+ const resolution=handoff?await (await import('../../src/services/server-probe-legacy-handoff-inspection.js')).observeLegacyProbeHandoff(facade,handoff,deadlineAt):undefined
+ const snapshot=handoff?undefined:await captureLegacyProbeStorage(facade)
+ const lineageSnapshot=custody?await captureLegacyProbeLineage(facade):undefined
+ let archive
+ if(archiveDirectory!==undefined){
+ if(initial.platformProtectionVerified!==true)throw Error('Protected legacy source evidence required')
+ s.phase('legacy-storage-export')
+ const {runPinnedLegacyProbeSnapshotDump}=await import('../../src/services/database-dump-connection.js')
+ const {rows}=await s.query('SELECT pg_catalog.pg_export_snapshot() AS snapshot')
+ const {host,port,database,password}=pool.options
+ if(host!==installation.tls.serverName||database!==first.database_name||!Number.isInteger(port)||typeof password!=='string')throw Error('Legacy export transport mismatch')
+ const peer={host,port,database,capture:installation.roleBindings.publisher,leaf:s.archiveLeaf()}
+ archive=await runPinnedLegacyProbeSnapshotDump(peer,password,rows[0]?.snapshot,archiveDirectory,{signal:s.signal,timeoutMs:Math.max(1,deadlineAt-Date.now())})
+ if(archive.subarray(0,5).toString()!=='PGDMP')throw Error('Legacy export did not return a PostgreSQL archive')
+ }
+ const source=await sourceVerifier.verify(facade,observation,options)
+ await assertDatabaseSourceObservationCurrent(facade,observation,options)
+ sameOwned(first,await ownedContext(s,installation,PUBLISHER,'publisher-read'))
+ const terminal=await s.query('ROLLBACK');if(terminal.command!=='ROLLBACK')throw Error('Legacy inspection rollback unconfirmed');s.begun(false)
+ return Object.freeze({state:'observed',snapshot,source,...(archive ? {archive} : {}),...(lineageSnapshot?{lineageSnapshot}:{}),...(resolution?{resolution}:{})})
+ })
+}
+async function boundedPending(filename){
+ const h=await open(filename,'r');try{const stat=await h.stat();if(!stat.isFile()||stat.size<1||stat.size>2048)throw Error('Bounded operator pending cursor required');const raw=await h.readFile();if(raw.length!==stat.size)throw Error('Pending cursor changed');const p=JSON.parse(raw.toString('utf8'));if(!bytes(p).equals(raw)||Object.keys(p).sort().join(',')!=='epoch,headSha256,installationId,policySha256,previousHeadSha256,publisherPid'||!(/^[1-9][0-9]*$/).test(p.epoch)||!Number.isSafeInteger(p.publisherPid))throw Error('Exact pending cursor refused');return p}finally{await h.close()}
+}
+async function reconcilePendingPublication(pool,{journalDirectory,deadlineAt=Date.now()+120000}){
+ const directory=await realpath(journalDirectory),filename=path.join(directory,'pending-publication.json')
+ let proposal;try{proposal=await boundedPending(filename)}catch(error){if(error.code==='ENOENT')return {state:'idle'};throw error}
+ const result=await inspectPublication(pool,proposal,{deadlineAt})
+ const after=await boundedPending(filename);if(canonical(after)!==canonical(proposal))throw Error('Pending cursor changed during protected inspection')
+ await unlink(filename)
+ return {...result,proposal}
+}
+return Object.freeze({
+ inspectLegacyStorage,
+ inspectCurrentCatalogue,
+ preflightCurrentProfile,
+ publishCurrentProfile:async(pool,options)=>{
+ if(isUpgradeApprovalFormat(approval.format))throw Error('Upgrade approval requires the explicit upgrade command')
+ const manifestSha256=requireCurrentCatalogueDefinition(approval,definition)
+ return withJournalLease(options.journalDirectory,()=>publishCurrentProfile(pool,options,manifestSha256))
+ },
+ upgradeCurrentProfile:async(pool,options)=>{
+ const upgrade=upgradeApproval(approval)
+ const manifestSha256=requireCurrentCatalogueDefinition(upgrade,definition)
+ const {successor,newEdition}=upgradeTransitions[upgrade.format]
+ if(manifestSha256!==successor.manifestSha256||definition.definitionSha256!==successor.templateSha256||
+ upgrade.expectedHeadSha256!==options.expectedHeadSha256||upgrade.validityMs!==options.validityMs){
+ throw Error(`Exact source${newEdition} upgrade target and predecessor approval required`)
+ }
+ return withJournalLease(options.journalDirectory,()=>publishCurrentProfile(pool,options,manifestSha256,upgrade))
+ },
+ inspectPublication,
+ reconcilePendingPublication:(pool,options)=>withJournalLease(options.journalDirectory,()=>reconcilePendingPublication(pool,options)),
+})
+}
diff --git a/backend/scripts/writer-profile/registry-enrollment.mts b/backend/scripts/writer-profile/registry-enrollment.mts
new file mode 100644
index 00000000..a924ecf2
--- /dev/null
+++ b/backend/scripts/writer-profile/registry-enrollment.mts
@@ -0,0 +1,185 @@
+import assert from 'node:assert/strict'
+import type {PoolClient} from 'pg'
+import {deploymentRequest} from '../database-writer-bootstrap-operator.mjs'
+import {assertJsDriverEnvironment,poolOptions,retainPublisherTlsPeer} from './operator-contract.mjs'
+import {readProtected} from './operator-files.mjs'
+import {KEY,canonical,publicKey,sha} from '../../src/db/application-writer-profile-format.js'
+import {readCurrentApplicationWriterProfile} from '../../src/db/application-writer-profile-registry-read.js'
+import {BUILD57_PROVENANCE} from './fixed57-build-definition.js'
+import {readProtectedRegistryStructureData,type RegistryRoleBindingsData} from '../../src/db/application-writer-profile-registry-structure.js'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../../src/db/migration-manifest.js'
+import {RESTORE_WRITER_PROFILE_DEFINITION_SHA256,RESTORE_WRITER_PROFILE_MANIFEST_SHA256,restoreProfileEnrollmentSql} from '../../src/db/database-restore-quarantine-profile.js'
+
+const baseFlags=['approval','approval-sha256','transport','transport-sha256','ca']
+const digest=/^[a-f0-9]{64}$/
+const json=(bytes:Buffer)=>JSON.parse(new TextDecoder('utf8',{fatal:true}).decode(bytes))
+
+// The accepted registry fixture's two tables and relation ACLs. Other schema
+// objects and cross-owner metadata grants are setup prerequisites.
+const registrySql=`CREATE TABLE mmapp_control.application_writer_profile_history (
+ installation_id uuid NOT NULL, epoch bigint NOT NULL CHECK(epoch>0),
+ head_sha256 text NOT NULL CHECK(head_sha256~'^[a-f0-9]{64}$'),
+ previous_installation_id uuid, previous_epoch bigint, previous_head_sha256 text,
+ policy_sha256 text NOT NULL CHECK(policy_sha256~'^[a-f0-9]{64}$'),
+ policy_bytes bytea NOT NULL CHECK(octet_length(policy_bytes) BETWEEN 1 AND 1048576),
+ head_bytes bytea NOT NULL CHECK(octet_length(head_bytes) BETWEEN 1 AND 8192),
+ PRIMARY KEY(installation_id,epoch), UNIQUE(installation_id,epoch,head_sha256),
+ CHECK((epoch=1 AND previous_installation_id IS NULL AND previous_epoch IS NULL AND previous_head_sha256 IS NULL)
+ OR(epoch>1 AND previous_installation_id IS NOT NULL AND previous_installation_id=installation_id
+ AND previous_epoch IS NOT NULL AND previous_epoch=epoch-1 AND previous_head_sha256 IS NOT NULL)),
+ FOREIGN KEY(previous_installation_id,previous_epoch,previous_head_sha256)
+ REFERENCES mmapp_control.application_writer_profile_history(installation_id,epoch,head_sha256) MATCH FULL
+);
+CREATE TABLE mmapp_control.application_writer_profile_current (
+ id smallint PRIMARY KEY CHECK(id=1), installation_id uuid NOT NULL, epoch bigint NOT NULL, head_sha256 text NOT NULL,
+ FOREIGN KEY(installation_id,epoch,head_sha256) REFERENCES mmapp_control.application_writer_profile_history(installation_id,epoch,head_sha256)
+);`
+
+const targetSql=(inspect:boolean,restoreProfile:boolean)=>`SELECT d.oid::text AS "databaseOid", d.datname::text AS "databaseName",
+ control.system_identifier::text AS "systemIdentifier", pg_catalog.current_setting('server_version_num')::int AS "serverVersionNum",
+ pg_catalog.pg_is_in_recovery() AS "inRecovery", r.oid::text AS "roleOid"
+ FROM pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_control_system() control
+ JOIN pg_catalog.pg_namespace n ON n.nspname='mmapp_control'
+ WHERE d.datname=pg_catalog.current_database() AND r.rolname=SESSION_USER AND SESSION_USER=CURRENT_USER
+ AND r.rolname=$1 AND n.nspowner=r.oid AND pg_catalog.current_setting('transaction_read_only')='${inspect?'on':'off'}'
+ AND pg_catalog.current_setting('session_replication_role')='origin' AND pg_catalog.current_setting('event_triggers')='on'
+ ${inspect||restoreProfile?'':`AND NOT EXISTS (SELECT 1 FROM pg_catalog.pg_class c WHERE c.relnamespace=n.oid
+ AND c.relname IN('application_writer_profile_history','application_writer_profile_current'))`}`
+const registryRelNames = ['application_writer_profile_current','application_writer_profile_history']
+
+export function writerRegistryEnrollmentSql(bindings:RegistryRoleBindingsData){
+ const {operator,publisher}=bindings
+ return [registrySql,`REVOKE ALL ON mmapp_control.application_writer_profile_history, mmapp_control.application_writer_profile_current FROM PUBLIC;
+ GRANT SELECT ON mmapp_control.application_writer_profile_history, mmapp_control.application_writer_profile_current TO "${operator.name}";
+ GRANT SELECT, INSERT ON mmapp_control.application_writer_profile_history TO "${publisher.name}";
+ GRANT SELECT, INSERT, UPDATE ON mmapp_control.application_writer_profile_current TO "${publisher.name}"`]
+}
+
+/** Exact registry body for a separately authorized, retained control transaction. */
+export async function enrollWriterRegistryInTransaction(sql:Parameters[0],bindings:RegistryRoleBindingsData){
+ for(const statement of writerRegistryEnrollmentSql(bindings))await sql.query(statement)
+ return readProtectedRegistryStructureData(sql,bindings)
+}
+
+export async function registryEnrollmentMain(args:string[]){
+ const inspect=args[0]==='registry-inspect'
+ const restoreProfile=args[0]==='restore-profile-enroll'
+ const flags=restoreProfile?[...baseFlags,'bootstrap','bootstrap-sha256']:baseFlags
+ assert((inspect||restoreProfile||args[0]==='registry-enroll')&&args.length===1+2*flags.length)
+ assertJsDriverEnvironment(process.env)
+ const values=new Map()
+ for(let i=1;ivalues.get(name)!
+ const approval=json(await readProtected(get('approval'),16384,get('approval-sha256')))
+ const manifestSha256=migrationManifestDigest()
+ if(restoreProfile){
+ assert.deepEqual(Object.keys(approval).sort(),['catalogSha256','definitionSha256','deploymentRequest','expectedHeadSha256','format','manifestSha256','previousCatalogSha256'])
+ assert(approval.format==='application-writer-restore-profile-enrollment-v1'&&manifestSha256===RESTORE_WRITER_PROFILE_MANIFEST_SHA256&&
+ approval.definitionSha256===RESTORE_WRITER_PROFILE_DEFINITION_SHA256&&[approval.catalogSha256,approval.previousCatalogSha256,approval.expectedHeadSha256]
+ .every(value=>typeof value==='string'&&digest.test(value)))
+ }else{
+ assert.deepEqual(Object.keys(approval).sort(),['deploymentRequest','format','manifestSha256'])
+ assert(approval.format==='application-writer-registry-enrollment-v1')
+ }
+ assert.equal(approval.manifestSha256,manifestSha256)
+ const request=deploymentRequest(approval.deploymentRequest)
+ let subject:Parameters[0]|undefined
+ if(restoreProfile){
+ const bootstrap=json(await readProtected(get('bootstrap'),32768,get('bootstrap-sha256')))
+ assert(bootstrap.format==='application-writer-bootstrap-v1'&&bootstrap.publicationAuthorized===false&&bootstrap.readyAuthorized===false&&
+ canonical(deploymentRequest(bootstrap.deploymentRequest))===canonical(request),'Independently pinned bootstrap required for restore enrollment')
+ assert(bootstrap.verificationSubject?.installationId===request.installationId)
+ subject=bootstrap.verificationSubject
+ publicKey(subject!)
+ }
+ const bindings:RegistryRoleBindingsData=request.roles
+ const transport=json(await readProtected(get('transport'),16384,get('transport-sha256')))
+ const ca=await readProtected(get('ca'),65536,request.tls.caSha256)
+ const options=poolOptions(transport,request,ca,'control')
+ const {default:pg}=await import('pg')
+ const pool=new pg.Pool({...options,query_timeout:12_000})
+ const deadline=Date.now()+120_000
+ let client:PoolClient|undefined,commitSent=false,committed=false,cleanupUnconfirmed=false
+ let registryStructureSha256:string|undefined
+ let observed:'absent'|'installed'|undefined
+ let failure:unknown
+ const onError=(error:Error)=>{failure??=error}
+ pool.on('error',onError)
+ try{
+ const connected=await pool.connect()
+ client=connected
+ connected.on('error',onError)
+ const assertPeer=retainPublisherTlsPeer(connected,request.tls)
+ const fence=()=>{if(failure)throw failure;assert(Date.now()>(text:string,parameters?:unknown[])=>{
+ fence()
+ const result=await connected.query(text,parameters)
+ fence()
+ return result
+ }
+ await query(inspect?'BEGIN READ ONLY':'BEGIN')
+ await query('SET LOCAL search_path = pg_catalog')
+ await query('SELECT pg_catalog.pg_advisory_xact_lock($1::bigint)',[KEY])
+ const {control,operator,runtime}=bindings
+ const target=await query(targetSql(inspect,restoreProfile),[control.name])
+ assert.deepEqual(target.rows,[{...request.source,roleOid:control.signedOid}],'Registry target/owner/absence refused')
+ const roles=await query<{name:string;oid:string}>('SELECT rolname::text AS name, oid::text AS oid FROM pg_catalog.pg_roles WHERE rolname=ANY($1::text[])',
+ [Object.values(bindings).map(role=>role.name)])
+ assert.deepEqual(new Map(roles.rows.map(role=>[role.name,role.oid])),new Map(Object.values(bindings).map(role=>[role.name,role.signedOid])))
+ const markers=MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)}))
+ const actualMarkers=await query('SELECT id FROM public.schema_migrations ORDER BY id COLLATE "C" LIMIT $1',[markers.length+1])
+ assert.deepEqual(actualMarkers.rows,markers,'Registry enrollment requires exact current migration markers')
+ if(inspect){
+ const relations=await query<{name:string}>(`SELECT c.relname::text AS name FROM pg_catalog.pg_class c
+ JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='mmapp_control'
+ AND c.relname=ANY($1::text[]) ORDER BY c.relname COLLATE "C"`,[registryRelNames])
+ if(relations.rows.length){
+ assert.deepEqual(relations.rows.map(row=>row.name),registryRelNames,'Registry relations are incomplete')
+ registryStructureSha256=(await readProtectedRegistryStructureData({query},bindings)).sha256
+ }
+ assert.equal((await query('ROLLBACK')).command,'ROLLBACK')
+ observed=relations.rows.length?'installed':'absent'
+ }else{
+ if(restoreProfile){
+ const {collectSource57Catalogue,collectSource58Catalogue}=await import('./catalogue.mjs')
+ const previous=await readProtectedRegistryStructureData({query},bindings),before=await collectSource57Catalogue({query},{roleBindings:bindings})
+ assert.equal(sha(canonical({base:before.catalogSha256,security:previous.sha256})),approval.previousCatalogSha256)
+ await query('LOCK TABLE mmapp_control.application_writer_profile_current, mmapp_control.application_writer_profile_history IN SHARE MODE')
+ const current=await readCurrentApplicationWriterProfile({query},subject!)
+ assert(current?.headSha256===approval.expectedHeadSha256&¤t.policy.manifestSha256===BUILD57_PROVENANCE.manifestSha256&&
+ current.policy.definitionSha256===BUILD57_PROVENANCE.templateSha256&¤t.policy.catalogSha256===approval.previousCatalogSha256&&
+ canonical(current.policy.source)===canonical(request.source)&&canonical(current.policy.roles)===canonical(previous.roles),
+ 'Exact signed Source57 predecessor required for restore enrollment')
+ await query(restoreProfileEnrollmentSql(runtime.name,operator.name))
+ const installed=await readProtectedRegistryStructureData({query},bindings,true),after=await collectSource58Catalogue({query},{roleBindings:bindings})
+ registryStructureSha256=installed.sha256
+ assert.equal(sha(canonical({base:after.catalogSha256,security:installed.sha256})),approval.catalogSha256)
+ assert.equal((await readCurrentApplicationWriterProfile({query},subject!))?.headSha256,current.headSha256)
+ }else{
+ registryStructureSha256=(await enrollWriterRegistryInTransaction({query},bindings)).sha256
+ }
+ fence()
+ commitSent=true
+ const ack=await connected.query('COMMIT')
+ assert.equal(ack.command,'COMMIT')
+ committed=true
+ }
+ }catch(error){failure??=error}
+ finally{
+ // Destroying the retained session rolls back any unsuccessful open transaction.
+ try{client?.release(true)}catch(error){failure??=error;cleanupUnconfirmed=true}
+ try{await pool.end()}catch(error){failure??=error;cleanupUnconfirmed=true}
+ }
+ if(committed)return {event:restoreProfile?'application-writer-restore-profile-enrollment':'application-writer-registry-enrollment',outcome:'committed',
+ installationId:request.installationId,manifestSha256,registryStructureSha256,cleanupUnconfirmed:cleanupUnconfirmed||!!failure,
+ automaticReplay:false,readyAuthorized:false}
+ if(observed&&!failure)return {event:'application-writer-registry-inspection',outcome:observed,
+ installationId:request.installationId,manifestSha256,registryStructureSha256,automaticReplay:false,readyAuthorized:false}
+ if(commitSent)throw Object.assign(Error('Registry enrollment requires inspection',{cause:failure}),{code:'WRITER_REGISTRY_TERMINAL_UNKNOWN'})
+ throw failure??Error('Registry enrollment refused')
+}
diff --git a/backend/scripts/writer-profile/registry-enrollment.test.mts b/backend/scripts/writer-profile/registry-enrollment.test.mts
new file mode 100644
index 00000000..d956a0a9
--- /dev/null
+++ b/backend/scripts/writer-profile/registry-enrollment.test.mts
@@ -0,0 +1,74 @@
+import assert from 'node:assert/strict'
+import {EventEmitter} from 'node:events'
+import {mock,test} from 'node:test'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../../src/db/migration-manifest.js'
+
+test('enrollment uses the independently pinned owner, validates readback, and never retries an unknown COMMIT',async()=>{
+ const digest='a'.repeat(64)
+ const roles=Object.fromEntries(['runtime','operator','capture','publisher','control'].map((role,index)=>[role,{name:`app_${role}`,signedOid:String(20000+index)}]))
+ const source={databaseOid:'30000',databaseName:'fixture',systemIdentifier:'121212',serverVersionNum:180004,inRecovery:false}
+ const deploymentRequest={format:'application-writer-bootstrap-request-v1',installationId:'7435bc0c-b7c8-40d8-be88-5f6ae478a221',sourceHeadSha256:digest,
+ source,roles,tls:{serverName:'localhost',caSha256:digest,spkiSha256:digest}}
+ const manifestSha256=migrationManifestDigest()
+ const approval={format:'application-writer-registry-enrollment-v1',manifestSha256,deploymentRequest}
+ const args=['registry-enroll','--approval','approval','--approval-sha256',digest,'--transport','transport','--transport-sha256',digest,'--ca','ca']
+ let mode='success'
+ const trace:string[]=[]
+ class Client extends EventEmitter{
+ async query(sql:string){
+ trace.push(sql)
+ if(sql.includes('pg_catalog.pg_control_system()'))return {rows:mode==='wrong-target'?[]:[{...source,roleOid:roles.control.signedOid}]}
+ if(sql.includes('AS name, oid::text'))return {rows:Object.values(roles).map(role=>({name:role.name,oid:role.signedOid}))}
+ if(sql.includes('FROM public.schema_migrations'))return {rows:mode==='wrong-markers'?[]:MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)}))}
+ if(sql.includes('c.relname=ANY'))return {rows:mode==='absent'?[]:
+ ['application_writer_profile_current',...(mode==='partial'?[]:['application_writer_profile_history'])].map(name=>({name}))}
+ if(sql==='COMMIT'&&mode==='ack-lost')throw Error('Synthetic ACK loss')
+ if(sql==='ROLLBACK'&&mode==='rollback-lost')throw Error('Synthetic ROLLBACK loss')
+ return {command:sql,rows:[]}
+ }
+ release(destroy:boolean){assert(destroy);trace.push('release')}
+ }
+ class Pool extends EventEmitter{
+ async connect(){trace.push('connect');return new Client()}
+ async end(){trace.push('end')}
+ }
+ mock.module('pg',{defaultExport:{Pool}})
+ mock.module('./operator-files.mjs',{namedExports:{readProtected:async(path:string,_limit:number,expected:string)=>{
+ assert.equal(expected,digest)
+ return Buffer.from(JSON.stringify(path==='approval'?approval:{}))
+ }}})
+ mock.module('./operator-contract.mjs',{namedExports:{assertJsDriverEnvironment:()=>{},poolOptions:(_transport:unknown,request:typeof deploymentRequest,_ca:Buffer,role:string)=>{
+ assert.deepEqual(request,deploymentRequest);assert.equal(role,'control');return {}
+ },retainPublisherTlsPeer:()=>()=>{}}})
+ mock.module('../../src/db/application-writer-profile-registry-structure.js',{namedExports:{readProtectedRegistryStructureData:async()=>{
+ trace.push('profile-verified');if(mode==='drift')throw Error('Synthetic catalogue drift')
+ return {sha256:digest}
+ }}})
+ const {registryEnrollmentMain}=await import('./registry-enrollment.mjs')
+ const before=await registryEnrollmentMain(args)
+ assert.equal(before.outcome,'committed');assert.equal(before.registryStructureSha256,digest);assert.equal(before.readyAuthorized,false)
+ const lock=trace.findIndex(sql=>sql.includes('pg_advisory_xact_lock')),ddl=trace.findIndex(sql=>sql.startsWith('CREATE TABLE'))
+ assert(lock>=0&&locksql.startsWith('CREATE TABLE')).length,scenario.startsWith('wrong-')?0:1)
+ assert.equal(trace.filter(sql=>sql==='COMMIT').length,scenario==='ack-lost'?1:0)
+ }
+ const inspectArgs=['registry-inspect',...args.slice(1)]
+ for(const scenario of ['absent','installed','partial','drift','rollback-lost']){
+ mode=scenario;trace.length=0
+ if(scenario==='absent'||scenario==='installed'){
+ const result=await registryEnrollmentMain(inspectArgs)
+ assert.equal(result.outcome,scenario)
+ assert.equal(result.registryStructureSha256,scenario==='installed'?digest:undefined)
+ assert.equal(result.readyAuthorized,false)
+ assert.deepEqual(trace.slice(-3),['ROLLBACK','release','end'])
+ }else await assert.rejects(registryEnrollmentMain(inspectArgs),Error)
+ assert.equal(trace[1],'BEGIN READ ONLY')
+ assert.equal(trace.some(sql=>sql.startsWith('CREATE TABLE')||sql==='COMMIT'),false)
+ }
+})
diff --git a/backend/scripts/writer-profile/source-activation.mts b/backend/scripts/writer-profile/source-activation.mts
new file mode 100644
index 00000000..1009d830
--- /dev/null
+++ b/backend/scripts/writer-profile/source-activation.mts
@@ -0,0 +1,149 @@
+/** Deployment operator state. Store outside PGDATA, backups and runtime mounts. */
+import assert from 'node:assert/strict'
+import {constants} from 'node:fs'
+import {lstat,open,rename} from 'node:fs/promises'
+import path from 'node:path'
+import {z} from 'zod'
+import {DATABASE_SOURCE_ACTIVATION_FILENAME as filename,MAX_DATABASE_SOURCE_ACTIVATION_BYTES as maximum,
+ databaseSourceActivationRecordSchema,parseDatabaseSourceActivationRecord,type DatabaseSourceActivationRecord as State} from '../../src/db/database-source-activation-record.js'
+import {sourceBindingBytes,sourceBindingCanonical,type DatabaseSourceBindingBody} from '../../src/db/database-source-binding.js'
+import {protectedDirectory,readProtected,sha,withJournalLease} from './operator-files.mjs'
+import {readProtectedDatabaseSourceBindingRegistry, type createProtectedDatabaseSourceBindingVerifier} from './protected-source-registry.mjs'
+
+const digest=z.string().regex(/^[a-f0-9]{64}$/),uuid=z.string().uuid()
+const sourcePin=z.object({registryDirectory:z.string().min(1).max(4096),installationId:uuid,publicKeySpkiSha256:digest,currentHeadSha256:digest}).strict()
+const directoryPath=z.string().min(1).max(4096)
+const approval=z.object({format:z.literal('database-source-activation-approval-v1'),activationDirectory:directoryPath,sourcePin,tlsSpkiSha256:digest,
+ expectedActivationSha256:digest.nullable()}).strict()
+const parse=(bytes:Buffer):unknown=>JSON.parse(new TextDecoder('utf8',{fatal:true}).decode(bytes))
+
+async function present(file:string){
+ try{await lstat(file);return true}catch(error){if((error as NodeJS.ErrnoException).code==='ENOENT')return false;throw error}
+}
+
+// Caller holds the same protected lease used by all activation writers.
+async function current(directory:string){
+ const file=path.join(directory,filename)
+ assert(!await present(file+'.pending'),'Unresolved activation transition')
+ if(!await present(file))return undefined
+ const bytes=await readProtected(file,maximum),state=parseDatabaseSourceActivationRecord(bytes)
+ assert.equal(state.activationDirectory,directory,'Activation record belongs to another directory')
+ return {state,activationSha256:sha(bytes)}
+}
+
+async function persist(directory:string,state:State){
+ await protectedDirectory(directory)
+ const bytes=sourceBindingBytes(databaseSourceActivationRecordSchema.parse(state))
+ assert(bytes.length<=maximum)
+ const file=path.join(directory,filename),pending=file+'.pending'
+ const parent=await open(directory,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW)
+ let confirmed=false,cleanupUnconfirmed=false
+ try{
+ const handle=await open(pending,constants.O_WRONLY|constants.O_CREAT|constants.O_EXCL|constants.O_NOFOLLOW,0o600)
+ try{await handle.writeFile(bytes);await handle.sync()}finally{await handle.close()}
+ try{await rename(pending,file);await parent.sync()}
+ catch{throw Object.assign(Error('Activation terminal requires inspection'),{code:'SOURCE_ACTIVATION_TERMINAL_UNKNOWN'})}
+ confirmed=true
+ }finally{try{await parent.close()}catch{cleanupUnconfirmed=confirmed}}
+ return {activationSha256:sha(bytes),cleanupUnconfirmed}
+}
+
+function receipt(state:State,activationSha256:string,outcome:'committed'|'observed'){
+ return {event:'database-source-activation',outcome,activationSha256,status:state.status,
+ ordinal:state.generations.length,...state.generations.at(-1),generationAuthenticated:false,readyAuthorized:false,automaticReplay:false}
+}
+
+type SourceVerifier=ReturnType
+
+/** Keep revocation and generation changes fenced through SQL and pool cleanup. */
+export async function withActiveSource(input:{directory:string,expectedSha256:string,sourcePin:z.infer,expectedSource:DatabaseSourceBindingBody['source'],tlsSpkiSha256:string,deadlineAt:number},
+ verifier:SourceVerifier,work:(guardedVerifier:SourceVerifier)=>Promise){
+ const {directory,deadlineAt}=input
+ const expectedSha256=digest.parse(input.expectedSha256),tlsSpkiSha256=digest.parse(input.tlsSpkiSha256)
+ const pin=sourcePin.parse(input.sourcePin)
+ return withJournalLease(directory,async()=>{
+ async function readActive(){
+ assert(Date.now()){
+ await readActive()
+ const evidence=await verifier.verify(...args)
+ assert(evidence.platformProtectionVerified&&evidence.operatorSignatureVerified&&evidence.currentHeadPinVerified&&evidence.genuineSourceFactsMatched,'Unprotected activation source evidence')
+ assertGeneration(evidence)
+ await readActive()
+ sourceChecks++
+ return evidence
+ }})
+ const result=await work(guardedVerifier)
+ try{
+ assert.equal(sourceChecks,2,'Initial and terminal source evidence required')
+ await readActive()
+ }catch(error){
+ // The retained SQL session already acknowledged COMMIT.
+ if(result&&typeof result==='object'&&'outcome' in result&&result.outcome==='committed')return {...result,cleanupUnconfirmed:true}
+ throw error
+ }
+ return result
+ })
+}
+
+export async function sourceActivationMain(args:string[]){
+ const command=args[0], flags=command==='source-activate'?['directory','approval','approval-sha256']:
+ command==='source-revoke'?['directory','expected-sha256']:['directory']
+ assert(['source-activate','source-revoke','source-status'].includes(command)&&args.length===1+2*flags.length)
+ const values=new Map()
+ for(let i=1;i{
+ const before=await current(directory)
+ if(command==='source-status'){
+ assert(before,'Activation record absent')
+ return receipt(before.state,before.activationSha256,'observed')
+ }
+ if(command==='source-revoke'){
+ const expected=digest.parse(values.get('expected-sha256'))
+ assert(before?.activationSha256===expected&&before.state.status==='active','Active activation digest changed')
+ const revoked={...before.state,status:'revoked' as const}
+ const saved=await persist(directory,revoked)
+ return {...receipt(revoked,saved.activationSha256,'committed'),cleanupUnconfirmed:saved.cleanupUnconfirmed}
+ }
+ const request=approval.parse(parse(await readProtected(values.get('approval')!,16384,digest.parse(values.get('approval-sha256')))))
+ assert.equal(request.activationDirectory,directory,'Approval belongs to another activation directory')
+ assert.equal(before?.activationSha256??null,request.expectedActivationSha256,'Activation predecessor changed')
+ const registry=await readProtectedDatabaseSourceBindingRegistry(request.sourcePin,{deadlineAt:Date.now()+120000})
+ const previous=before?.state.generations??[]
+ assert.equal(registry.head.ordinal,previous.length+1,'Source ordinal changed')
+ assert.equal(registry.head.previousHeadSha256,previous.at(-1)?.headSha256??null,'Signed predecessor differs')
+ if(before){
+ assert.equal(registry.head.installationId,before.state.installationId)
+ assert.equal(registry.head.sourceIdentityId,before.state.sourceIdentityId)
+ assert.equal(registry.publicKeySpkiSha256,before.state.publicKeySpkiSha256)
+ }
+ assert(!previous.some(item=>item.generation.toLowerCase()===registry.head.generation.toLowerCase()||item.tlsSpkiSha256===request.tlsSpkiSha256),'Generation or TLS key was already used')
+ const next:State={format:'database-source-activation-v1',activationDirectory:directory,installationId:registry.head.installationId,
+ sourceIdentityId:registry.head.sourceIdentityId,publicKeySpkiSha256:registry.publicKeySpkiSha256,status:'active',
+ generations:[...previous,{generation:registry.head.generation,headSha256:registry.headSha256,
+ bindingSha256:registry.head.bindingSha256,tlsSpkiSha256:request.tlsSpkiSha256}]}
+ const saved=await persist(directory,next)
+ return {...receipt(next,saved.activationSha256,'committed'),cleanupUnconfirmed:saved.cleanupUnconfirmed}
+ })
+}
diff --git a/backend/scripts/writer-profile/source-activation.test.mts b/backend/scripts/writer-profile/source-activation.test.mts
new file mode 100644
index 00000000..8d536f4c
--- /dev/null
+++ b/backend/scripts/writer-profile/source-activation.test.mts
@@ -0,0 +1,153 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import fs from 'node:fs/promises'
+import path from 'node:path'
+import os from 'node:os'
+import {createHash,generateKeyPairSync,randomUUID} from 'node:crypto'
+import {createRequire} from 'node:module'
+import {runInNewContext} from 'node:vm'
+import {provisionDatabaseSourceBindingOffline} from '../database-source-binding-operator.ts'
+import * as activationRecord from '../../src/db/database-source-activation-record.ts'
+import {readDatabaseSourceBindingRegistry,sourceBindingBytes,sourceBindingCanonical,type DatabaseSourceDeploymentPin} from '../../src/db/database-source-binding.ts'
+import type * as Activation from './source-activation.mts'
+
+const require=createRequire(import.meta.url),ts=require('typescript')
+const source=await fs.readFile(new URL('./source-activation.mts',import.meta.url),'utf8')
+const sha=(value:Buffer)=>createHash('sha256').update(value).digest('hex')
+
+test('protected activation transition model preserves revocation and refuses concurrent, stale or reused generations',async()=>{
+ const root=await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(),'mm-source-activation-test-')))
+ try{
+ // Genuine issuer signatures and filesystem files. Windows models the
+ // protection/lease boundary and directory fsync used on the POSIX target.
+ const lock=path.join(root,'test-lease'),state=path.join(root,'source-activation.json')
+ const files={sha,protectedDirectory:async(directory:string)=>{assert.equal(directory,root)},
+ readProtected:async(filename:string,maximum:number,expected?:string)=>{
+ assert.equal(path.dirname(filename),root)
+ const bytes=await fs.readFile(filename);assert(bytes.length<=maximum)
+ if(expected)assert.equal(sha(bytes),expected)
+ return bytes
+ },async withJournalLease(directory:string,work:()=>Promise){
+ assert.equal(directory,root);const handle=await fs.open(lock,'wx')
+ try{return await work()}finally{await handle.close();await fs.unlink(lock)}
+ }}
+ let parentFailure=''
+ const modelFs={...fs,open:async(filename:string,flags:number,mode?:number)=>filename===root?
+ {sync:async()=>{if(parentFailure==='sync')throw Error('fixture directory sync failure')},
+ close:async()=>{if(parentFailure==='close')throw Error('fixture directory close failure')}}:fs.open(filename,flags,mode)}
+ const imports:Record={'node:fs/promises':modelFs,'./operator-files.mjs':files,
+ './protected-source-registry.mjs':{readProtectedDatabaseSourceBindingRegistry:readDatabaseSourceBindingRegistry},
+ '../../src/db/database-source-activation-record.js':activationRecord,
+ '../../src/db/database-source-binding.js':{sourceBindingBytes,sourceBindingCanonical}}
+ const load=()=>{
+ const exports={}
+ const compiled=ts.transpileModule(source,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText
+ runInNewContext(compiled,{exports,require:(name:string)=>imports[name]??require(name),Buffer,TextDecoder})
+ return exports as typeof Activation
+ }
+ const {withActiveSource}=load()
+ let {sourceActivationMain:run}=load()
+ const privateKeyFile=path.join(root,'issuer.pem'),key=generateKeyPairSync('ed25519').privateKey
+ await fs.writeFile(privateKeyFile,key.export({format:'pem',type:'pkcs8'}),{mode:0o600})
+ const installationId=randomUUID(),sourceIdentityId=randomUUID()
+ const issue=async(previousPin?:DatabaseSourceDeploymentPin,generation=randomUUID())=>{
+ return (await provisionDatabaseSourceBindingOffline({privateKeyFile,previousPin,outputDirectory:path.join(root,randomUUID()),
+ request:{installationId,sourceIdentityId,generation,source:{systemIdentifier:'123',databaseOid:16384,databaseName:'synthetic',
+ sessionUser:'publisher',currentUser:'publisher',inRecovery:false,serverVersionNum:180004}}})).deploymentPin
+ }
+ const status=['source-status','--directory',root]
+ const revoke=(expected:string)=>['source-revoke','--directory',root,'--expected-sha256',expected]
+ const activate=async(pin:DatabaseSourceDeploymentPin,tlsSpkiSha256:string,expectedActivationSha256:string|null,activationDirectory=root)=>{
+ const bytes=sourceBindingBytes({format:'database-source-activation-approval-v1',activationDirectory,sourcePin:pin,tlsSpkiSha256,expectedActivationSha256})
+ const file=path.join(root,randomUUID()+'.json');await fs.writeFile(file,bytes,{mode:0o600,flag:'wx'})
+ return ['source-activate','--directory',root,'--approval',file,'--approval-sha256',sha(bytes)]
+ }
+ const g1=await issue(undefined,'5ac5e8bd-0eb2-498b-901a-dd2010cd4b31'),g2=await issue(g1),g3=await issue(g2)
+ await assert.rejects(run(await activate(g1,'1'.repeat(64),null,path.join(root,'other'))),/another activation directory/)
+ const start=await activate(g1,'1'.repeat(64),null)
+ const races=await Promise.allSettled([run(start),run(start)])
+ assert.deepEqual(races.map(value=>value.status).sort(),['fulfilled','rejected'],races.map(value=>value.status==='rejected'?String(value.reason):value.status).join(', '))
+ const first=await run(status)
+ assert.equal(first.ordinal,1);assert.equal(first.headSha256,g1.currentHeadSha256)
+ assert.equal(first.generationAuthenticated,false)
+ const firstBytes=await fs.readFile(state)
+ const record=activationRecord.parseDatabaseSourceActivationRecord(firstBytes)
+ const [generation]=record.generations
+ await fs.writeFile(state,Buffer.concat([firstBytes,Buffer.from('\n')]))
+ await assert.rejects(run(status),/Noncanonical activation record/)
+ await fs.writeFile(state,sourceBindingBytes({...record,generations:[generation,{...generation,
+ generation:generation.generation.toUpperCase(),headSha256:'c'.repeat(64),tlsSpkiSha256:'d'.repeat(64)}]}))
+ await assert.rejects(run(status),/Reused activation identity/)
+ await fs.writeFile(state,firstBytes)
+ const registry=await readDatabaseSourceBindingRegistry(g1)
+ const evidence={format:'database-source-binding-evidence-v1' as const,
+ installationId:registry.head.installationId,sourceIdentityId:registry.head.sourceIdentityId,generation:registry.head.generation,
+ ordinal:registry.head.ordinal,bindingSha256:registry.head.bindingSha256,headSha256:registry.headSha256,
+ operatorSignatureVerified:true as const,currentHeadPinVerified:true as const,
+ genuineSourceFactsMatched:true as const,platformProtectionVerified:true as const,generationAuthenticated:false as const,
+ allWriterDrainAuthenticated:false as const,readyAuthorized:false as const}
+ // The actual preflight exercises the checked-out PostgreSQL client. The guard fixture models its source verifier.
+ type Verifier=Parameters[1]
+ const verifierArgs=[] as unknown as Parameters
+ const preflight={directory:root,sourcePin:g1,expectedSource:registry.body.source,expectedSha256:first.activationSha256,tlsSpkiSha256:'1'.repeat(64),deadlineAt:Date.now()+30000}
+ const refuseConnect=()=>{throw Error('Reached SQL connection before activation was trusted')}
+ const verifier={verify:async()=>evidence}
+ await assert.rejects(withActiveSource({...preflight,expectedSha256:'0'.repeat(64)},verifier,refuseConnect),/activation digest changed/)
+ await assert.rejects(withActiveSource({...preflight,tlsSpkiSha256:'2'.repeat(64)},verifier,refuseConnect),/Activation key differs/)
+ await assert.rejects(withActiveSource({...preflight,sourcePin:g2},verifier,refuseConnect),/differs from signed source generation/)
+ await assert.rejects(withActiveSource({...preflight,expectedSource:{...preflight.expectedSource,currentUser:'different'}},verifier,refuseConnect),/differs from reviewed configuration/)
+ let verifications=0
+ const result=await withActiveSource(preflight,{verify:async()=>{verifications++;return evidence}},async guarded=>{
+ assert.equal(await guarded.verify(...verifierArgs),evidence)
+ await assert.rejects(run(revoke(first.activationSha256)),{code:'EEXIST'})
+ assert.equal(await guarded.verify(...verifierArgs),evidence)
+ return 'matched'
+ })
+ assert.equal(result,'matched');assert.equal(verifications,2)
+ await assert.rejects(fs.access(lock),{code:'ENOENT'})
+ await assert.rejects(withActiveSource(preflight,verifier,async guarded=>{
+ await guarded.verify(...verifierArgs)
+ }),/Initial and terminal source evidence required/)
+ const committed=await withActiveSource(preflight,verifier,async guarded=>{
+ await guarded.verify(...verifierArgs)
+ await guarded.verify(...verifierArgs)
+ await fs.writeFile(state+'.pending','interrupted',{flag:'wx'})
+ return {outcome:'committed',epoch:'1'}
+ })
+ assert.deepEqual({...committed},{outcome:'committed',epoch:'1',cleanupUnconfirmed:true})
+ await fs.unlink(state+'.pending')
+ let reads=0
+ await assert.rejects(withActiveSource(preflight,{verify:async()=>++reads===1?evidence:{...evidence,bindingSha256:'0'.repeat(64)}},async guarded=>{
+ await guarded.verify(...verifierArgs)
+ await guarded.verify(...verifierArgs)
+ }),/differs from signed source generation/)
+ await fs.writeFile(state+'.pending','interrupted',{flag:'wx'})
+ await assert.rejects(withActiveSource(preflight,verifier,refuseConnect),/Unresolved activation transition/)
+ await fs.unlink(state+'.pending')
+ await assert.rejects(run(start),/predecessor changed/)
+ const revoked=await run(revoke(first.activationSha256))
+ await assert.rejects(withActiveSource({...preflight,expectedSha256:revoked.activationSha256},verifier,refuseConnect),/activation digest changed/)
+ run=load().sourceActivationMain
+ assert.equal((await run(status)).status,'revoked')
+ await assert.rejects(run(revoke(first.activationSha256)),/digest changed/)
+ await assert.rejects(run(await activate(g3,'3'.repeat(64),revoked.activationSha256)),/ordinal changed/)
+ const second=await run(await activate(g2,'2'.repeat(64),revoked.activationSha256))
+ assert.equal(second.ordinal,2);assert.equal(second.status,'active')
+ await assert.rejects(run(await activate(g3,'1'.repeat(64),second.activationSha256)),/already used/)
+ const repeatedGeneration=await issue(g2,first.generation!.toUpperCase())
+ await assert.rejects(run(await activate(repeatedGeneration,'3'.repeat(64),second.activationSha256)),/already used/)
+ await assert.rejects(run(await activate({...g3,currentHeadSha256:'0'.repeat(64)},'3'.repeat(64),second.activationSha256)))
+ assert.equal((await run(status)).activationSha256,second.activationSha256)
+ parentFailure='sync'
+ await assert.rejects(run(revoke(second.activationSha256)),{code:'SOURCE_ACTIVATION_TERMINAL_UNKNOWN'})
+ parentFailure='close'
+ const observed=await run(status)
+ assert.equal(observed.status,'revoked')
+ const third=await run(await activate(g3,'3'.repeat(64),observed.activationSha256))
+ assert.equal(third.outcome,'committed')
+ assert('cleanupUnconfirmed' in third && third.cleanupUnconfirmed===true)
+ await fs.writeFile(state+'.pending','interrupted',{flag:'wx'})
+ await assert.rejects(run(status),/Unresolved activation transition/)
+ await assert.rejects(run(revoke(third.activationSha256)),/Unresolved activation transition/)
+ }finally{await fs.rm(root,{recursive:true,force:true})}
+})
diff --git a/backend/scripts/writer-profile/source57-admission-plan.mts b/backend/scripts/writer-profile/source57-admission-plan.mts
new file mode 100644
index 00000000..23f845a5
--- /dev/null
+++ b/backend/scripts/writer-profile/source57-admission-plan.mts
@@ -0,0 +1,48 @@
+import assert from 'node:assert/strict'
+import {FIXED57_ROLE_TEMPLATE} from './fixed57-build-definition.js'
+import {fixedCatalogueParentPeriodData} from './application-writer-profile-catalogue-parent-policy.js'
+import {reviewedMarkerFenceSql} from './marker-fence-enrollment.mjs'
+import {sourceBindingBytes,sourceBindingSha256} from '../../src/db/database-source-binding.js'
+import type {RegistryRoleBindingsData} from '../../src/db/application-writer-profile-registry-structure.js'
+
+const privileges={r:'SELECT',a:'INSERT',w:'UPDATE',d:'DELETE'} as const
+const identifier=(value:unknown)=>{assert(typeof value==='string'&&/^[a-z_][a-z0-9_]{0,62}$/.test(value));return '"'+value+'"'}
+const qualified=(value:unknown)=>'public.'+identifier(value)
+const allowedScopes=['runtime','publisher','capture'] as const
+
+export function reviewedSource57Admission(roles:RegistryRoleBindingsData){
+ const sql:string[]=[]
+ function grants(entries:unknown,suffix:string,column?:string){
+ assert(Array.isArray(entries))
+ for(const entry of entries){
+ assert(typeof entry==='string')
+ if(entry==='@mm-role:operator@=arwdDxtm/@mm-role:operator@'||entry==='@mm-role:operator@=rwU/@mm-role:operator@')continue
+ const match=/^@mm-role:(runtime|publisher|capture)@=([rawd]+)\/@mm-role:operator@$/.exec(entry)
+ assert(match&&allowedScopes.includes(match[1] as typeof allowedScopes[number]))
+ const allowed=[...match[2]].map(key=>privileges[key as keyof typeof privileges]+(column?` (${column})`:'')).join(', ')
+ sql.push(`GRANT ${allowed} ON ${suffix} TO ${identifier(roles[match[1] as typeof allowedScopes[number]].name)}`)
+ }
+ }
+ for(const table of FIXED57_ROLE_TEMPLATE.tables){
+ const name=qualified(table.relname)
+ grants(table.acl,'TABLE '+name)
+ if(table.relname==='schema_migrations')continue
+ if(!fixedCatalogueParentPeriodData(String(table.relname))){
+ sql.push(`CREATE TRIGGER server_partition_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON ${name} FOR EACH ROW EXECUTE FUNCTION public.server_partition_writer_guard()`,
+ `ALTER TABLE ONLY ${name} ENABLE ALWAYS TRIGGER server_partition_writer_guard`)
+ }
+ sql.push(`CREATE TRIGGER candidate_application_statement_guard BEFORE INSERT OR DELETE OR UPDATE ON ${name} FOR EACH STATEMENT EXECUTE FUNCTION public.server_partition_writer_guard()`,
+ `ALTER TABLE ONLY ${name} ENABLE ALWAYS TRIGGER candidate_application_statement_guard`,
+ `CREATE TRIGGER candidate_truncate_preadmitted BEFORE TRUNCATE ON ${name} FOR EACH STATEMENT EXECUTE FUNCTION mmapp_control.candidate_truncate_preadmitted()`,
+ `ALTER TABLE ONLY ${name} ENABLE ALWAYS TRIGGER candidate_truncate_preadmitted`)
+ }
+ for(const column of FIXED57_ROLE_TEMPLATE.columns){
+ if(column.acl!==null)grants(column.acl,'TABLE '+qualified(column.relname),identifier(column.attname))
+ }
+ for(const sequence of FIXED57_ROLE_TEMPLATE.sequences)grants(sequence.acl,'SEQUENCE '+qualified(sequence.relname))
+ sql.push(reviewedMarkerFenceSql)
+ const tables=FIXED57_ROLE_TEMPLATE.tables.map(row=>({name:row.relname,kind:row.relkind}))
+ const sequences=FIXED57_ROLE_TEMPLATE.sequences.map(row=>({name:row.relname}))
+ return {sql,tables,sequences,sha256:sourceBindingSha256(sourceBindingBytes(sql))}
+}
+export function source57AdmissionSqlSha256(roles:RegistryRoleBindingsData){return reviewedSource57Admission(roles).sha256}
diff --git a/backend/scripts/writer-profile/source58-foundation.mts b/backend/scripts/writer-profile/source58-foundation.mts
new file mode 100644
index 00000000..22fbcccc
--- /dev/null
+++ b/backend/scripts/writer-profile/source58-foundation.mts
@@ -0,0 +1,231 @@
+import assert from 'node:assert/strict'
+import {createPublicKey,verify} from 'node:crypto'
+import type {PoolClient} from 'pg'
+import {z} from 'zod'
+import {deploymentRequest} from '../database-writer-bootstrap-operator.mjs'
+import {assertJsDriverEnvironment,poolOptions,retainPublisherTlsPeer} from './operator-contract.mjs'
+import {readProtected,sha} from './operator-files.mjs'
+import {createProtectedDatabaseSourceBindingVerifier} from './protected-source-registry.mjs'
+import {withActiveSource} from './source-activation.mjs'
+import {BUILD57_PROVENANCE,FIXED57_ROLE_TEMPLATE} from './fixed57-build-definition.js'
+import {BUILD58_PROVENANCE} from './fixed58-build-definition.js'
+import {enrollWriterRegistryInTransaction,writerRegistryEnrollmentSql} from './registry-enrollment.mjs'
+import {reviewedSource57Admission} from './source57-admission-plan.mjs'
+import {collectSource57Catalogue} from './catalogue.mjs'
+import {canonical} from './application-writer-profile-canonical.js'
+import {readProtectedRegistryStructureData} from '../../src/db/application-writer-profile-registry-structure.js'
+import {captureDatabaseSourceObservation} from '../../src/db/database-source-observation.js'
+import {sourceBindingBytes,sourceBindingCanonical} from '../../src/db/database-source-binding.js'
+import {captureMigrationSchema} from '../../src/db/migration-schema-inventory.js'
+import {MIGRATION_MANIFEST,migrationManifestDigest} from '../../src/db/migration-manifest.js'
+import {SYSTEM_DATABASE_OPERATION_LOCK,SYSTEM_DATABASE_REQUEST_LOCK} from '../../src/db/operation-lock.js'
+
+export const SOURCE58_FOUNDATION_DOMAIN='mmapp:source58-foundation:ed25519:v1\n'
+export const SOURCE57_ADMISSION_DOMAIN='mmapp:source57-admission:ed25519:v1\n'
+const hash=z.string().regex(/^[a-f0-9]{64}$/)
+const fields={
+ bootstrapSha256:hash,sourceHeadSha256:hash,sourceTlsSpkiSha256:hash,manifestSha256:hash,definitionSha256:hash,
+ preSchemaSha256:hash,expiresAt:z.number().int().positive(),
+}
+const approval=z.object({body:z.discriminatedUnion('format',[
+ z.object({...fields,format:z.literal('source58-foundation-approval-v1'),decision:z.literal('install-foundations'),foundationSha256:hash}).strict(),
+ z.object({...fields,format:z.literal('source57-admission-approval-v1'),decision:z.literal('install-admission'),admissionSha256:hash}).strict(),
+ ]),
+ signature:z.string().regex(/^[A-Za-z0-9_-]{86}$/)}).strict()
+const parse=(bytes:Buffer)=>JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes))
+type Request=ReturnType
+type Sql={query:>(text:string,values?:unknown[])=>Promise<{rows:T[];command?:string}>}
+const keys=['candidate_require_preadmission','candidate_truncate_preadmitted','candidate_operator_ddl','server_partition_writer_guard']
+const sorted=(rows:Record[])=>rows.map(sourceBindingCanonical).sort()
+const withSortedAcl=(row:Record)=>({...row,acl:Array.isArray(row.acl)?[...row.acl].sort():row.acl})
+const identifier=(name:string)=>{assert(/^[a-z_][a-z0-9_]{0,62}$/.test(name));return '"'+name+'"'}
+const bind=(text:string,roles:Request['roles'])=>text.replace(/@mm-role:(operator|control|publisher|runtime|capture)@/g,(_,scope)=>roles[scope].name)
+
+function reviewedFoundation(roles:Request['roles']){
+ const expected=FIXED57_ROLE_TEMPLATE.functions.filter(row=>keys.includes(String(row.proname))).map(row=>JSON.parse(bind(sourceBindingCanonical(row),roles)))
+ const publicGuard=expected.find(row=>row.namespace==='public')
+ const functions=keys.slice(0,3).map(name=>expected.find(row=>row.proname===name).definition.replace('CREATE OR REPLACE FUNCTION ','CREATE FUNCTION '))
+ const schemas=FIXED57_ROLE_TEMPLATE.schemas.map(row=>JSON.parse(bind(sourceBindingCanonical(row),roles)))
+ const events=FIXED57_ROLE_TEMPLATE.events.map(row=>JSON.parse(bind(sourceBindingCanonical(row),roles)))
+ const {operator,publisher,runtime,capture}=roles
+ const sql=[
+ 'ALTER FUNCTION public.server_partition_writer_guard() SET search_path = pg_catalog',
+ 'REVOKE ALL ON SCHEMA public, mmapp_control FROM PUBLIC',
+ `GRANT USAGE ON SCHEMA public TO ${[publisher,runtime,capture].map(role=>identifier(role.name)).join(', ')}`,
+ `GRANT USAGE ON SCHEMA mmapp_control TO ${[operator,publisher].map(role=>identifier(role.name)).join(', ')}`,
+ ...functions,
+ `REVOKE ALL ON FUNCTION ${keys.slice(0,3).map(name=>'mmapp_control.'+name+'()').join(', ')} FROM PUBLIC`,
+ `GRANT EXECUTE ON FUNCTION mmapp_control.candidate_truncate_preadmitted() TO ${identifier(operator.name)}`,
+ 'CREATE EVENT TRIGGER candidate_operator_ddl ON ddl_command_start EXECUTE FUNCTION mmapp_control.candidate_operator_ddl()',
+ ]
+ return {expected,publicGuard,schemas,events,sql,sha256:sha(sourceBindingBytes([...sql,...writerRegistryEnrollmentSql(roles)]))}
+}
+export function source58FoundationSqlSha256(roles:Request['roles']){return reviewedFoundation(roles).sha256}
+
+const functionSql=`SELECT n.nspname AS namespace,p.proname, pg_catalog.pg_get_function_identity_arguments(p.oid) AS arguments,
+ l.lanname AS language,pg_catalog.pg_get_userbyid(p.proowner) AS owner,p.proconfig,p.prokind,p.prosecdef,p.proacl::text[] AS acl,
+ pg_catalog.pg_get_functiondef(p.oid) AS definition
+ FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace JOIN pg_catalog.pg_language l ON l.oid=p.prolang
+ WHERE (n.nspname='public' AND p.proname=$1) OR (n.nspname='mmapp_control' AND p.proname=ANY($2::text[])) LIMIT 5`
+const eventSql=`SELECT e.evtname,e.evtevent,e.evtenabled,e.evttags, pg_catalog.pg_get_userbyid(e.evtowner) AS owner,
+ n.nspname AS function_namespace,p.proname AS function_name,n.nspname||'.'||p.proname||'()' AS function
+ FROM pg_catalog.pg_event_trigger e JOIN pg_catalog.pg_proc p ON p.oid=e.evtfoid
+ JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace LIMIT 2`
+
+async function checkTarget(sql:Sql,request:Request){
+ const subject=await sql.query(`SELECT (pg_catalog.pg_control_system()).system_identifier::text AS system,d.oid::text AS database,
+ d.datname AS name,pg_catalog.current_setting('server_version_num')::int AS version,r.oid::text AS role,r.rolsuper AS superuser,
+ n.nspowner::text AS control_owner, pub.nspowner::text AS public_owner
+ FROM pg_catalog.pg_database d CROSS JOIN pg_catalog.pg_roles r
+ JOIN pg_catalog.pg_namespace n ON n.nspname='mmapp_control'
+ JOIN pg_catalog.pg_namespace pub ON pub.nspname='public'
+ WHERE d.datname=pg_catalog.current_database() AND r.rolname=SESSION_USER AND SESSION_USER=CURRENT_USER
+ AND NOT pg_catalog.pg_is_in_recovery() AND pg_catalog.current_setting('session_replication_role')='origin'
+ AND pg_catalog.current_setting('event_triggers')='on'`)
+ const {source,roles}=request
+ assert.deepEqual(subject.rows,[{system:source.systemIdentifier,database:source.databaseOid,name:source.databaseName,version:source.serverVersionNum,
+ role:roles.control.signedOid,superuser:true,control_owner:roles.control.signedOid,public_owner:roles.operator.signedOid}],'Exact authorized control DBA and namespace owners required')
+ const {rows}=await sql.query(`SELECT rolname AS name,oid::text AS oid FROM pg_catalog.pg_roles WHERE rolname=ANY($1::text[])`,[Object.values(roles).map(role=>role.name)])
+ assert.deepEqual(sorted(rows),sorted(Object.values(roles).map(role=>({name:role.name,oid:role.signedOid}))),'Exact five role OIDs required')
+ const markers=await sql.query('SELECT id FROM ONLY public.schema_migrations ORDER BY id COLLATE "C" LIMIT $1',[MIGRATION_MANIFEST.length+1])
+ assert.deepEqual(markers.rows,MIGRATION_MANIFEST.map(pin=>({id:pin.file.slice(0,-4)})),'Exact current migration markers required')
+}
+
+async function checkFresh(sql:Sql,review:ReturnType){
+ const fresh=await sql.query(`SELECT NOT EXISTS(SELECT FROM pg_catalog.pg_class WHERE relnamespace='mmapp_control'::pg_catalog.regnamespace)
+ AND NOT EXISTS(SELECT FROM pg_catalog.pg_proc WHERE pronamespace='mmapp_control'::pg_catalog.regnamespace)
+ AND NOT EXISTS(SELECT FROM pg_catalog.pg_type WHERE typnamespace='mmapp_control'::pg_catalog.regnamespace)
+ AND NOT EXISTS(SELECT FROM pg_catalog.pg_event_trigger)
+ AND NOT EXISTS(SELECT FROM pg_catalog.pg_trigger WHERE tgrelid='public.schema_migrations'::pg_catalog.regclass AND NOT tgisinternal) AS empty`)
+ assert.deepEqual(fresh.rows,[{empty:true}],'Unenrolled staging control namespace and marker required')
+ const funcs=await sql.query(functionSql,[keys[3],keys.slice(0,3)])
+ assert.deepEqual(funcs.rows,[{...review.publicGuard,proconfig:null,definition:review.publicGuard.definition.replace(" SET search_path TO 'pg_catalog'\n",'')}],
+ 'Original numbered public guard required')
+}
+
+async function checkFoundation(sql:Sql,review:ReturnType){
+ const functions=(await sql.query(functionSql,[keys[3],keys.slice(0,3)])).rows
+ assert.deepEqual(sorted(functions.map(withSortedAcl)),sorted(review.expected.map(withSortedAcl)),'Exact reviewed guard function readback required')
+ assert.deepEqual(sorted((await sql.query(eventSql)).rows),sorted(review.events),'Exact reviewed event trigger readback required')
+ const schemas=await sql.query(`SELECT nspname,pg_catalog.pg_get_userbyid(nspowner) AS owner,nspacl::text[] AS acl
+ FROM pg_catalog.pg_namespace WHERE nspname IN('public','mmapp_control')`)
+ assert.deepEqual(sorted(schemas.rows.map(withSortedAcl)),sorted(review.schemas.map(withSortedAcl)),'Exact reviewed schema ACL required')
+}
+
+async function checkUnenrolledRelations(sql:Sql,plan:ReturnType,operatorOid:string){
+ const tables=await sql.query(`SELECT c.relname AS name,c.relkind::text AS kind,c.relowner::text AS owner FROM pg_catalog.pg_class c
+ WHERE c.relnamespace='public'::pg_catalog.regnamespace AND c.relkind IN ('r','p') LIMIT $1`,[plan.tables.length+1])
+ assert.deepEqual(sorted(tables.rows),sorted(plan.tables.map(row=>({...row,owner:operatorOid}))),'Exact unpartitioned staging relation inventory required')
+ const sequences=await sql.query(`SELECT c.relname AS name,c.relowner::text AS owner FROM pg_catalog.pg_class c
+ WHERE c.relnamespace='public'::pg_catalog.regnamespace AND c.relkind='S' LIMIT $1`,[plan.sequences.length+1])
+ assert.deepEqual(sorted(sequences.rows),sorted(plan.sequences.map(row=>({...row,owner:operatorOid}))),'Exact staging sequence inventory required')
+ const {rows}=await sql.query(`SELECT NOT EXISTS(SELECT FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid
+ WHERE c.relnamespace='public'::pg_catalog.regnamespace AND t.tgname IN ('candidate_application_statement_guard','candidate_truncate_preadmitted'))
+ AND NOT EXISTS(SELECT FROM mmapp_control.application_writer_profile_history) AND NOT EXISTS(SELECT FROM mmapp_control.application_writer_profile_current)
+ AND pg_catalog.to_regclass('mmapp_control.database_restore_quarantine') IS NULL AS fresh`)
+ assert.deepEqual(rows,[{fresh:true}],'Unenrolled public relations and empty Source57 writer registry required')
+}
+
+export async function source58FoundationMain(args:string[]){
+ const flags=['bootstrap','bootstrap-sha256','publisher-transport','publisher-transport-sha256','control-transport','control-transport-sha256','ca',
+ 'source-registry','source-spki-sha256','activation-directory','activation-sha256','approval','approval-sha256','approval-public-key','approval-spki-sha256']
+ const admission=args[0]==='source57-admission-enroll'
+ assert((admission||args[0]==='source58-foundation-enroll')&&args.length===1+2*flags.length);assertJsDriverEnvironment(process.env)
+ const values=new Map()
+ for(let index=1;indexvalues.get(name)!
+ for(const flag of flags.filter(name=>name.endsWith('sha256')))hash.parse(get(flag))
+ const bootstrap=parse(await readProtected(get('bootstrap'),32768,get('bootstrap-sha256'))),request=deploymentRequest(bootstrap.deploymentRequest)
+ assert(bootstrap.format==='application-writer-bootstrap-v1'&&bootstrap.publicationAuthorized===false&&bootstrap.readyAuthorized===false)
+ const bytes=await readProtected(get('approval'),8192,get('approval-sha256')),raw=parse(bytes),{body,signature}=approval.parse(raw)
+ const pem=await readProtected(get('approval-public-key'),4096),key=createPublicKey(pem),sig=Buffer.from(signature,'base64url')
+ const sourcePin={registryDirectory:get('source-registry'),installationId:request.installationId,publicKeySpkiSha256:get('source-spki-sha256'),currentHeadSha256:request.sourceHeadSha256}
+ assert(!pem.includes('PRIVATE KEY')&&key.asymmetricKeyType==='ed25519'&&get('approval-spki-sha256')!==sourcePin.publicKeySpkiSha256&&
+ sha(key.export({type:'spki',format:'der'}))===get('approval-spki-sha256')&&sourceBindingBytes(raw).equals(bytes)&&sig.toString('base64url')===signature&&
+ verify(null,Buffer.from((admission?SOURCE57_ADMISSION_DOMAIN:SOURCE58_FOUNDATION_DOMAIN)+sourceBindingCanonical(body)),key,sig),'Independent signed operator approval required')
+ const review=reviewedFoundation(request.roles)
+ const relationPlan=admission?reviewedSource57Admission(request.roles):undefined
+ const planMatches=body.format==='source57-admission-approval-v1'?
+ admission&&body.definitionSha256===BUILD57_PROVENANCE.templateSha256&&body.admissionSha256===relationPlan?.sha256:
+ !admission&&body.definitionSha256===BUILD58_PROVENANCE.templateSha256&&body.foundationSha256===review.sha256
+ assert(body.bootstrapSha256===get('bootstrap-sha256')&&body.sourceHeadSha256===sourcePin.currentHeadSha256&&body.sourceTlsSpkiSha256===request.tls.spkiSha256&&
+ body.manifestSha256===migrationManifestDigest()&&planMatches&&body.expiresAt>Date.now()&&body.expiresAt-Date.now()<=900000,'Exact reviewed writer plan required')
+ const ca=await readProtected(get('ca'),65536,request.tls.caSha256)
+ const transport=async(role:'publisher'|'control')=>poolOptions(parse(await readProtected(get(role+'-transport'),16384,get(role+'-transport-sha256'))),request,ca,role)
+ const [publisherOptions,controlOptions]=await Promise.all([transport('publisher'),transport('control')])
+ const {default:pg}=await import('pg');assertJsDriverEnvironment(process.env)
+ const expectedSource={...request.source,databaseOid:Number(request.source.databaseOid),sessionUser:request.roles.publisher.name,currentUser:request.roles.publisher.name}
+ const deadlineAt=Math.min(body.expiresAt,Date.now()+120000)
+ return withActiveSource({directory:get('activation-directory'),expectedSha256:get('activation-sha256'),sourcePin,expectedSource,
+ tlsSpkiSha256:request.tls.spkiSha256,deadlineAt},createProtectedDatabaseSourceBindingVerifier(sourcePin),async verifier=>{
+ const publisher=new pg.Pool(publisherOptions),control=new pg.Pool(controlOptions)
+ let lost=false,commitSent=false,committed=false,cleanupUnconfirmed=false,client:PoolClient|undefined,registryStructureSha256:string|undefined,catalogueSha256:string|undefined
+ for(const pool of [publisher,control])pool.on('error',()=>{lost=true})
+ const retained=(client:PoolClient)=>{
+ const check=retainPublisherTlsPeer(client,request.tls)
+ return {check,sql:{query:async>(text:string,values?:unknown[])=>{
+ assert(!lost&&Date.now()(text,values)
+ check();assert(!lost&&Date.now()result.status==='rejected')
+ }
+ assert(committed&®istryStructureSha256)
+ return {event:admission?'database-source57-admission':'database-source58-foundation',outcome:'committed',approvalSha256:sha(bytes),
+ ...(relationPlan?{admissionSha256:relationPlan.sha256,catalogueSha256}:{foundationSha256:review.sha256}),
+ registryStructureSha256,cleanupUnconfirmed:cleanupUnconfirmed||lost,automaticReplay:false,readyAuthorized:false}
+ })
+}
diff --git a/backend/src/config.ts b/backend/src/config.ts
index 5a44b666..cf88fc0d 100644
--- a/backend/src/config.ts
+++ b/backend/src/config.ts
@@ -12,6 +12,7 @@ const isProd = process.env.NODE_ENV === "production"
const envSchema = z.object({
DATABASE_URL: z.string().default("postgres://mmapp:mmapp@127.0.0.1:5432/mmapp"),
+ DATABASE_RESTORE_URL_FILE: z.string().optional(),
DATABASE_PATH: z.string().default("./mikrotik.db"),
SQLITE_IMPORT_FULL_HISTORY: z.boolean().default(false),
PORT: z.coerce.number().int().positive().default(8000),
@@ -24,6 +25,7 @@ const envSchema = z.object({
const raw = {
DATABASE_URL: process.env.DATABASE_URL,
+ DATABASE_RESTORE_URL_FILE: process.env.DATABASE_RESTORE_URL_FILE?.trim() || undefined,
DATABASE_PATH: process.env.DATABASE_PATH,
SQLITE_IMPORT_FULL_HISTORY: boolEnv(process.env.SQLITE_IMPORT_FULL_HISTORY, false),
PORT: process.env.PORT,
@@ -58,6 +60,7 @@ if (parsed.data.AUTH_REQUIRED && parsed.data.AUTH_JWT_SECRET.length < 8) {
export const env = {
DATABASE_URL: parsed.data.DATABASE_URL,
+ DATABASE_RESTORE_URL_FILE: parsed.data.DATABASE_RESTORE_URL_FILE,
DATABASE_PATH: parsed.data.DATABASE_PATH,
sqliteImportFullHistory: parsed.data.SQLITE_IMPORT_FULL_HISTORY,
PORT: parsed.data.PORT,
diff --git a/backend/src/db/application-operator-transactions.ts b/backend/src/db/application-operator-transactions.ts
new file mode 100644
index 00000000..7d07f9d3
--- /dev/null
+++ b/backend/src/db/application-operator-transactions.ts
@@ -0,0 +1,194 @@
+import {randomBytes} from 'node:crypto'
+import pg,{type PoolClient,type QueryResult,type QueryResultRow} from 'pg'
+
+export interface ApplicationOperatorSql {
+ query(text:string,values?:unknown[]):Promise>
+}
+export type PairDecision={disposition:'commit'|'rollback';value:T}
+export type PairResult={disposition:'committed'|'rolled-back';value:T}
+type Outcome='not-started'|'rolled-back'|'committed'|'unknown'
+export class ApplicationOperatorTransactionError extends Error {
+ readonly automaticReplay=false
+ constructor(readonly outcome:Outcome,readonly phase:string,readonly committedValue:T|undefined,readonly hasCommittedValue:boolean,readonly cleanupUnconfirmed:boolean,options?:ErrorOptions){
+ super('Application/operator transaction pairing refused; do not replay automatically',options)
+ }
+}
+const CONTEXT=`SELECT CURRENT_USER::text AS actor,SESSION_USER::text AS login,
+ d.oid::text AS database_oid,pg_catalog.pg_backend_pid() AS pid,
+ pg_catalog.current_setting('server_version_num')::int AS version,
+ pg_catalog.current_setting('transaction_read_only') AS read_only,
+ pg_catalog.pg_current_xact_id_if_assigned()::text AS xid,
+ (r.rolsuper OR r.rolcreatedb OR r.rolcreaterole OR r.rolreplication OR r.rolbypassrls) AS unsafe,
+ EXISTS(SELECT 1 FROM pg_catalog.pg_namespace n WHERE n.nspname='public' AND n.nspowner=r.oid) AS owns_public,
+ EXISTS(SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relowner=r.oid) AS owns_application_object,
+ pg_catalog.pg_has_role(r.oid,($1::pg_catalog.regrole)::pg_catalog.oid,'MEMBER') AS member_operator
+ FROM pg_catalog.pg_roles r CROSS JOIN pg_catalog.pg_database d WHERE r.rolname=CURRENT_USER AND d.datname=pg_catalog.current_database()`
+const WITNESS=`SELECT pid,database::text AS database_oid,mode,granted FROM pg_catalog.pg_locks
+ WHERE locktype='advisory' AND database=(SELECT oid FROM pg_catalog.pg_database WHERE datname=pg_catalog.current_database())
+ AND classid=$1::oid AND objid=$2::oid AND objsubid=2 ORDER BY pid,mode LIMIT 3`
+type Context={actor:string;login:string;database_oid:string;pid:number;version:number;read_only:'on'|'off';xid:string|null;unsafe:boolean;owns_public:boolean;owns_application_object:boolean;member_operator:boolean}
+function exactContext(rows:QueryResultRow[],actor:string,readOnly:boolean):Context {
+ const row=rows[0] as Context|undefined
+ if(rows.length!==1||!row||row.actor!==actor||row.login!==actor||!Number.isSafeInteger(row.pid)||row.pid<=0||!/^\d+$/.test(row.database_oid)||row.version<180000||row.version>=190000||row.read_only!==(readOnly?'on':'off')||row.unsafe!==false||typeof row.member_operator!=='boolean'||typeof row.owns_public!=='boolean'||typeof row.owns_application_object!=='boolean'||row.xid!==null&&!/^[1-9][0-9]*$/.test(row.xid))throw Error('Actual PG18 expected role/transaction context unavailable')
+ if(readOnly&&(row.owns_public||row.owns_application_object||row.member_operator))throw Error('Runtime role is an application owner/operator member')
+ if(!readOnly&&!row.owns_public)throw Error('Operator is not the explicitly configured application schema owner')
+ return row
+}
+// Defensive direct-boundary refusal, NOT an untrusted SQL parser/sandbox.
+// Only fixed trusted application statements may reach this internal facade.
+function fixedApplicationStatement(text:string){
+ if(typeof text!=='string'||!text.trim()||Buffer.byteLength(text)>1048576)throw Error('Bounded trusted application SQL required')
+ const head=text.replace(/^(?:\s|--[^\r\n]*(?:\r?\n|$)|\/\*[^]*?\*\/)+/,'')
+ if(/^(?:BEGIN|START\s+TRANSACTION|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE|PREPARE\s+TRANSACTION|SET\s+(?:(?:LOCAL|SESSION)\s+)?ROLE|RESET\s+ROLE)\b/i.test(head))throw Error('Transaction and role ownership belongs to pairing component')
+}
+/** Private trusted host assembly only. No source/profile issuer, SQL sandbox,
+ * configured URL, Pool creation, role provisioning, fallback or READY grant. */
+export function createApplicationOperatorTransactions(config:{runtimePool:pg.Pool;operatorPool:pg.Pool;runtimeRole:string;operatorRole:string;maxConcurrentPairs:1|2}){
+ const {runtimePool,operatorPool,runtimeRole,operatorRole,maxConcurrentPairs}=config
+ if(!(runtimePool instanceof pg.Pool)||!(operatorPool instanceof pg.Pool)||runtimePool===operatorPool||runtimeRole===operatorRole||![runtimeRole,operatorRole].every(role=>/^[a-z_][a-z0-9_]{0,62}$/.test(role))||![1,2].includes(maxConcurrentPairs))throw Error('Fixed actual pools, separated roles and bounded capacity required')
+ const runtimeConnect=runtimePool.connect.bind(runtimePool),operatorConnect=operatorPool.connect.bind(operatorPool)
+ let activePairs=0,poisoned=false
+ return Object.freeze({
+ async run(work:(tx:ApplicationOperatorSql)=>Promise>,input:{deadlineAt:number;signal?:AbortSignal;authorize?:()=>Promise}):Promise>{
+ const options=Object.freeze({deadlineAt:input.deadlineAt,signal:input.signal,authorize:input.authorize})
+ if(poisoned||activePairs>=maxConcurrentPairs||typeof work!=='function'||!Number.isSafeInteger(options.deadlineAt)||options.deadlineAt<=Date.now()||options.deadlineAt-Date.now()>120000||options.signal?.aborted)throw new ApplicationOperatorTransactionError('not-started','admission',undefined,false,poisoned)
+ activePairs++
+ let runtime:PoolClient|undefined,operator:PoolClient|undefined,runtimeReleased=false,operatorReleased=false
+ let runtimeBegun=false,operatorBegun=false,commitSent=false,commitConfirmed=false,operatorTerminal=false,witnessTerminal=false
+ let phase='checkout-runtime',accepting=false,retired=false,primary:unknown,hasPrimary=false,workFailed=false,queuedFailure:unknown,queuedFailed=false,tail:Promise=Promise.resolve()
+ const retain=(cause:unknown)=>{if(!hasPrimary){primary=cause;hasPrimary=true}}
+ let committedValue:T|undefined,hasCommittedValue=false,decision:PairDecision|undefined
+ const random=randomBytes(8),first=random.readInt32BE(0),second=random.readInt32BE(4),key=[first,second],unsigned=[first>>>0,second>>>0]
+ const errors=new Mapvoid>()
+ let stopReject!:(error:Error)=>void
+ const stopped=new Promise((_,reject)=>{stopReject=reject});void stopped.catch(()=>{})
+ const dispose=(client:PoolClient|undefined,unsafe:boolean)=>{
+ if(!client)return
+ if(client===runtime){if(runtimeReleased)return;runtimeReleased=true}
+ else if(client===operator){if(operatorReleased)return;operatorReleased=true}
+ const listener=errors.get(client)
+ if(listener){client.off('error',listener);client.off('end',listener)}
+ try{client.release(unsafe)}catch(error){poisoned=true;retain(error)}
+ }
+ const stop=(cause:unknown)=>{
+ if(retired)return
+ retired=true;accepting=false;poisoned=true;retain(cause)
+ dispose(operator,true);dispose(runtime,true)
+ stopReject(new ApplicationOperatorTransactionError(commitConfirmed?'committed':operatorBegun?'unknown':'not-started',phase,committedValue,hasCommittedValue,true,{cause}))
+ }
+ const fence=()=>{if(retired||options.signal?.aborted||Date.now()>=options.deadlineAt)throw hasPrimary?primary:Error('Pairing lifetime expired')}
+ const bounded=(operation:Promise)=>Promise.race([operation,stopped])
+ const observe=(client:PoolClient)=>{const listener=()=>stop(Error('Owned physical connection ended unexpectedly'));errors.set(client,listener);client.on('error',listener);client.on('end',listener)}
+ const borrow=async(connect:()=>Promise,kind:'runtime'|'operator')=>{
+ const pending=connect().then(client=>{
+ if(kind==='runtime')runtime=client;else operator=client
+ if(retired){dispose(client,true);return client}
+ observe(client);return client
+ })
+ // Handler remains attached if cancellation wins; a late checkout is retired.
+ void pending.catch(()=>{})
+ const client=await bounded(pending);fence();return client
+ }
+ const query=async(client:PoolClient,text:string,values?:unknown[])=>{fence();const result=await bounded(client.query(text,values));fence();return result}
+ const authorize=async()=>{fence();await bounded(Promise.resolve().then(()=>options.authorize?.()));fence()}
+ const onAbort=()=>stop(Error('Pairing cancelled'))
+ const timer=setTimeout(()=>stop(Error('Pairing deadline exceeded')),Math.max(1,options.deadlineAt-Date.now()))
+ options.signal?.addEventListener('abort',onAbort,{once:true})
+ let operatorContext:Context|undefined,runtimeContext:Context|undefined
+ const assertPair=async()=>{
+ if(!operator||!operatorContext||!runtimeContext)throw Error('Live pair is not established')
+ try{
+ const current=exactContext((await query(operator,CONTEXT,[operatorRole])).rows,operatorRole,false)
+ if(current.pid!==operatorContext.pid||current.xid!==operatorContext.xid||current.database_oid!==operatorContext.database_oid||current.xid===null)throw Error('Operator backend/owned writable transaction changed')
+ const locks=(await query(operator,WITNESS,unsigned)).rows
+ if(locks.length!==1||locks[0].pid!==runtimeContext.pid||locks[0].database_oid!==runtimeContext.database_oid||locks[0].mode!=='ShareLock'||locks[0].granted!==true)throw Error('Original runtime witness is not live on this application database')
+ }catch(error){stop(error);throw error}
+ }
+ try{
+ await authorize();runtime=await borrow(runtimeConnect,'runtime')
+ await query(runtime,'BEGIN ISOLATION LEVEL READ COMMITTED READ ONLY');runtimeBegun=true
+ await query(runtime,"SET LOCAL statement_timeout='10s'");await query(runtime,"SET LOCAL lock_timeout='5s'")
+ runtimeContext=exactContext((await query(runtime,CONTEXT,[operatorRole])).rows,runtimeRole,true)
+ await query(runtime,'SELECT pg_catalog.pg_advisory_xact_lock_shared($1::int,$2::int)',key)
+ phase='checkout-operator';operator=await borrow(operatorConnect,'operator')
+ await query(operator,'BEGIN ISOLATION LEVEL READ COMMITTED READ WRITE');operatorBegun=true
+ await query(operator,"SET LOCAL statement_timeout='120s'");await query(operator,"SET LOCAL lock_timeout='10s'");await query(operator,'SET LOCAL synchronous_commit=on')
+ await query(operator,'SELECT pg_catalog.pg_current_xact_id()')
+ operatorContext=exactContext((await query(operator,CONTEXT,[operatorRole])).rows,operatorRole,false)
+ if(operatorContext.xid===null)throw Error('Owned writable transaction identity unavailable')
+ phase='live-source-pair'
+ const attempt=(await query(operator,'SELECT pg_catalog.pg_try_advisory_xact_lock($1::int,$2::int) AS acquired',key)).rows
+ if(attempt.length!==1||attempt[0].acquired!==false)throw Error('Operator is not paired to original live application database')
+ await assertPair();await authorize();phase='work';accepting=true
+ const facade:ApplicationOperatorSql=Object.freeze({query:(text:string,values?:unknown[]):Promise>=>{
+ const rejected=(error:unknown):Promise>=>{const failure=Promise.reject(error);void failure.catch(()=>{});return failure}
+ if(!accepting||retired)return rejected(new ApplicationOperatorTransactionError(commitConfirmed?'committed':'unknown','closed-facade',committedValue,hasCommittedValue,false))
+ try{fixedApplicationStatement(text)}catch(error){if(!queuedFailed){queuedFailure=error;queuedFailed=true}return rejected(error)}
+ const parameters=values?.slice()
+ const pending=tail.then(async()=>{
+ if(queuedFailed)throw queuedFailure
+ await authorize();await assertPair()
+ const result=await query(operator!,text,parameters)
+ await assertPair();await authorize();return result as QueryResult