后端与接口
设计 PlanetScale Webhook…
适用于需要评审或推荐 PlanetScale webhooks,把告警、异常、schema 建议和部署生命周期事件接到人工通知、工程系统或代理安全队列的场景。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
设计 PlanetScale Webho特定
解决思路
- 评审并推荐 PlanetScale webhooks,用于通知人和触发安全自动化;未经批准不要创建或更新 webhooks。
- 设定设计原则:webhooks 可以触发自动化,但自动化默认只能产出 recommendations、issues、branches 或 pull requests;未经明确人工批准,不得直接变更生产数据库或生产应用行为。
- 评估 General 和 Postgres 事件 `branch.anomaly`:新的 Insights anomaly。
- 评估 General 和 Postgres 事件 `branch.out_of_memory`:Postgres out-of-memory event。
- 评估 General 和 Postgres 事件 `branch.primary_promoted`:primary failover/promotion。
- 评估 General 和 Postgres 事件 `branch.ready`:branch created and ready。
- 评估 General 和 Postgres 事件 `branch.sleeping`:branch sleeping。
- 评估 General 和 Postgres 事件 `branch.start_maintenance`:maintenance starting。
- 评估 General 和 Postgres 事件 `cluster.storage`:storage threshold or growth event。
- 评估 General 和 Postgres 事件 `database.access_request`:access request。
- 评估 General 和 Postgres 事件 `branch.schema_recommendation`:schema recommendation event when available。
- 评估 General 和 Postgres 事件 `webhook.test`:test event。
- 评估 Vitess deploy 生命周期事件 `deploy_request.opened`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.queued`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.in_progress`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.pending_cutover`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.schema_applied`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.errored`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.reverted`。
- 评估 Vitess deploy 生命周期事件 `deploy_request.closed`。
- 评估 Vitess deploy 生命周期事件 `keyspace.storage`。
- 人工告警路由:将 `branch.anomaly` 发送到 incident 或 operations channels。
- 人工告警路由:将 `branch.out_of_memory` 发送到 incident 或 operations channels。
- 人工告警路由:将 `branch.primary_promoted` 发送到 incident 或 operations channels。
- 人工告警路由:将 `branch.start_maintenance` 发送到 incident 或 operations channels。
- 人工告警路由:将 `cluster.storage` 发送到 incident 或 operations channels。
- 人工告警路由:将 `keyspace.storage` 发送到 incident 或 operations channels。
- 人工告警路由:将 `deploy_request.errored` 发送到 incident 或 operations channels。
- 人工告警路由:将 `deploy_request.reverted` 发送到 incident 或 operations channels。
- 工程通知路由:将 `deploy_request.opened` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `deploy_request.queued` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `deploy_request.in_progress` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `deploy_request.pending_cutover` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `deploy_request.schema_applied` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `deploy_request.closed` 发送到 Slack、Linear/Jira 或 deployment channels。
- 工程通知路由:将 `branch.schema_recommendation` 发送到 Slack、Linear/Jira 或 deployment channels。
- 代理接入队列路由:将 `branch.anomaly` 发送到 agent-safe workflow。
- 代理接入队列路由:将 `branch.schema_recommendation` 发送到 agent-safe workflow。
- 代理接入队列路由:将 `deploy_request.errored` 发送到 agent-safe workflow。
- 代理接入队列路由:将 `cluster.storage` 发送到 agent-safe workflow。
- 代理接入队列路由:将 `keyspace.storage` 发送到 agent-safe workflow。
- 定义代理无需批准即可产出的内容:triage summary、probable cause、linked Insights/query patterns。
- 定义代理无需批准即可产出的内容:recommended schema、code、Traffic Control 或 operational change。
- 定义代理无需批准即可产出的内容:pull request against application code。
- 定义代理无需批准即可产出的内容:development branch with DDL or migration applied。
- 定义代理无需批准即可产出的内容:open deploy request into a review-protected branch。
- 定义代理无需批准即可产出的内容:issue 或 ticket。
- 代理 output 不得自行越过 review gate:no production deploys、PR merges、Traffic Control enforcement、credential rotation 或 network changes;这些需要 human action 或 standing authorization per `../planetscale-autonomous-execution-mode/SKILL.md`。
- 只推荐满足以下要求的接收端:HTTPS endpoint。
- 只推荐满足以下要求的接收端:快速返回 2xx;耗时工作异步排队。
- 只推荐满足以下要求的接收端:不依赖跟随 redirects。
- 只推荐满足以下要求的接收端:使用 PlanetScale webhook signature header 和 webhook secret 做签名验证。
- 只推荐满足以下要求的接收端:按 event ID 或 timestamp/resource tuple 做幂等。
- 只推荐满足以下要求的接收端:具备 dead-letter queue 或 retry-safe logging。
- 只推荐满足以下要求的接收端:具备 human-readable audit trail。
- 只推荐满足以下要求的接收端:有明确 owner 和 escalation path。
- 只推荐满足以下要求的接收端:有 secret rotation procedure。
- Anomaly to PR flow:接收 `branch.anomaly`。
- Anomaly to PR flow:验证签名。
- Anomaly to PR flow:排队 job。
- Anomaly to PR flow:获取 anomaly details 和相关 Insights query patterns。
- Anomaly to PR flow:通过 SQLCommenter tags 和 repository search 定位代码路径。
- Anomaly to PR flow:分类为 schema、code、Traffic Control 或 unknown。
- Anomaly to PR flow:生成报告和可选 PR。
- Anomaly to PR flow:请人工批准会影响数据库的工作。
- Schema recommendation to branch/deploy flow(Vitess):接收 `branch.schema_recommendation`。
- Schema recommendation to branch/deploy flow(Vitess):获取 recommendation details。
- Schema recommendation to branch/deploy flow(Vitess):将 DDL 应用到 development branch。
- Schema recommendation to branch/deploy flow(Vitess):打开 pull request,包含 fingerprint、metrics 和预期效果。
- Schema recommendation to branch/deploy flow(Vitess):打开 deploy request;DR 和 PR 一起作为可审查单元,打开它们无需批准。
- Schema recommendation to branch/deploy flow(Vitess):人工批准后部署,或在 allowlist 此 deploy class 的 standing authorization 下自主部署(`../planetscale-autonomous-execution-mode/SKILL.md`)。
- Schema recommendation to branch/deploy flow(Postgres):接收 `branch.schema_recommendation`。
- Schema recommendation to branch/deploy flow(Postgres):获取 recommendation details。
- Schema recommendation to branch/deploy flow(Postgres):将 DDL 转换为 application migration。
- Schema recommendation to branch/deploy flow(Postgres):在非生产分支上测试,并把结果记录到 PR。
- Schema recommendation to branch/deploy flow(Postgres):打开 PR。
- Schema recommendation to branch/deploy flow(Postgres):合并时通过 deployment pipeline 应用到生产;没有 pipeline 时需明确批准。
- Deploy request lifecycle flow(Vitess):打开时通知。
- Deploy request lifecycle flow(Vitess):验证 owner 和关联的 application PR。
- Deploy request lifecycle flow(Vitess):queued 或 in progress 时告警。
- Deploy request lifecycle flow(Vitess):errored 或 reverted 时强烈告警。
- Deploy request lifecycle flow(Vitess):pending cutover 时通知,并要求 owner 对 gated deployments 进行确认。
- Deploy request lifecycle flow(Vitess):记录 schema applied,并与 application deploy 关联。
- 阻止并不要推荐:webhook 直接运行 production DDL,绕过 PR/deploy-request workflow。(通过 branch、PR 和 deploy request 驱动 DDL 是受支持模式,不是 anti-pattern。)
- 阻止并不要推荐:webhook 把 schema recommendations 直接应用到 production,且没有可审查 artifact。
- 阻止并不要推荐:webhook 直接 enforce Traffic Control。
- 阻止并不要推荐:webhook 直接修改 IP restrictions。
- 阻止并不要推荐:webhook 直接轮换 credentials。
- 阻止并不要推荐:webhook 将 secrets 或带 literals 的 raw SQL 发到公开 Slack 频道。
- 阻止并不要推荐:webhook receiver 忽略 signature verification。
- 阻止并不要推荐:webhook receiver 在返回 2xx 前做长时间运行的工作。
- 输出时返回:现有 webhook inventory。
- 输出时返回:缺失的 recommended subscriptions。
- 输出时返回:destination quality review。
- 输出时返回:signature verification status。
- 输出时返回:automation opportunities。
- 输出时返回:unsafe automation risks。
- 输出时返回:需要批准的 proposed webhook changes。
- 最后以这句话结尾:“No webhooks or automation endpoints have been created, updated, or deleted.”
适用边界 · 注意事项
- 不使用 PlanetScale Webhooks,或没有 PlanetScale 组织、数据库和 webhook 管理权限时。
- 没有 HTTPS 接收端、签名密钥、异步队列或 dead-letter/retry-safe 机制时,不应推荐复杂自动化。
- 尚未建立人工审批或长期授权(standing authorization)时,不应让代理触发生产部署、PR 合并、Traffic Control enforcement、凭据轮换或网络变更。