shuangyan-notebook/第五域 · Fifth Domain/⚒️ 铸渊·协作指令|GitHub ↔ Notion 桥接协议/📡 铸渊指令|回执自动回流·Notion指令回执追踪表写入配置(ZY-RECEIPT-SYNC-20 a7aadc43fdc34d859b8d6fe71aea0bd8.md
Guanghu Domestic Migration a27e87cb99 chore: import sanitized domestic snapshot for REPO-007
Source snapshot: 97d7f0fae96dc04b7ddad56fc1db6a108ed662cc

[SEC-CLEAN] · pre-push-clean v1.0 · 109处敏感信息已自动转乱码
2026-07-17 15:59:55 +08:00

198 lines
5.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
belongs_to:
- "[[INDEX · 铸渊·协作指令GitHub ↔ Notion 桥接协议]]"
---
# 📡 铸渊指令回执自动回流·Notion指令回执追踪表写入配置ZY-RECEIPT-SYNC-2026-0325-001· 霜砚签发 · 冰朔授权
<aside>
📡
**指令编号**ZY-RECEIPT-SYNC-2026-0325-001
**签发**霜砚AG-SY-01
**授权**冰朔TCS-0002∞
**日期**2026-03-25
**优先级**P1神经系统闭环关键路径
**前置依赖**R2三篇已执行完毕 ✅
</aside>
---
## 一、背景与目标
当前状态:
-`track-work-orders.js` 已存在R2-003 产出)
-`NOTION_API_KEY` Secret 已对齐KNOWN-002 修复)
-`track-work-orders.js` 尚未配置写入目标 Notion 数据库
- ❌ 回执目前靠人类手动粘贴 → 需要自动化
**目标**:让铸渊每次执行完霜砚签发的指令后,自动将回执写入 Notion 侧「指令回执追踪表」,实现 **指令→执行→回执** 全链路自动闭环。
---
## 二、Notion 侧已就绪
### 2.1 数据库信息
- **数据库名称**:📡 指令回执追踪表
- **位置**:光湖语言壳 · Notion端 · 统一网关 下
- **Notion API 写入方式**:通过 `NOTION_API_KEY` 调用 Notion API
### 2.2 字段映射表(铸渊写入时使用)
| **Notion 字段名** | **类型** | **铸渊写入值** | **示例** |
| --- | --- | --- | --- |
| 指令编号 | title | 指令ID | ZY-NEURAL-UPGRADE-2026-0325-R2-001 |
| 指令摘要 | text | 简要描述 | 双端神经系统升级·上篇 |
| 执行状态 | status | ✅ 已完成 / ❌ 执行失败 / ⏸️ 已挂起 | ✅ 已完成 |
| 铸渊回执 | text | 结构化回执内容 | ✅ 基线快照已创建 · 架构盘点19/19 |
| 回执时间 | date | ISO-8601 日期 | 2026-03-25 |
| 新增文件数 | number | 整数 | 28 |
| 修改文件数 | number | 整数 | 43 |
| 关联Agent | text | 相关Notion Agent编号 | TY-01 天眼诊断引擎 |
| 回执超时 | select | 🟢 正常 / 🟡 接近超时 / 🔴 已超时 | 🟢 正常 |
---
## 三、铸渊执行步骤
### Phase 1配置 `track-work-orders.js` 写入目标
**文件**`scripts/neural/track-work-orders.js`
需要做的修改:
1. **读取 Notion 数据库 ID** — 指令回执追踪表的数据库 ID 需要写入配置
2. **在脚本顶部配置区添加**
```jsx
const RECEIPT_TRACKER_CONFIG = {
// 指令回执追踪表 · Notion Database ID
// 位于:光湖语言壳 > 统一网关 > 指令回执追踪表
databaseId: '<从 Notion URL 中提取的 database ID>',
// 字段映射
fieldMap: {
instructionId: '指令编号', // title
summary: '指令摘要', // text
status: '执行状态', // status
receipt: '铸渊回执', // text
receiptTime: '回执时间', // date
newFiles: '新增文件数', // number
modifiedFiles: '修改文件数', // number
relatedAgent: '关联Agent', // text
timeoutStatus: '回执超时', // select
},
// 超时阈值(小时)
timeoutThresholds: {
warning: 24, // 24h → 🟡 接近超时
critical: 72, // 72h → 🔴 已超时
}
};
```
1. **添加写入函数**
```jsx
async function writeReceiptToNotion(receipt) {
const notion = new Client({ auth: process.env.NOTION_API_KEY });
// 先查询是否已有该指令编号的记录
const existing = await notion.databases.query({
database_id: RECEIPT_TRACKER_CONFIG.databaseId,
filter: {
property: '指令编号',
title: { equals: receipt.instructionId }
}
});
if (existing.results.length > 0) {
// 更新已有记录
await notion.pages.update({
page_id: existing.results[0].id,
properties: buildNotionProperties(receipt)
});
} else {
// 创建新记录
await notion.pages.create({
parent: { database_id: RECEIPT_TRACKER_CONFIG.databaseId },
properties: buildNotionProperties(receipt)
});
}
}
```
### Phase 2在每个 Workflow 的自报告 step 后追加回执写入
在 R2-002 已添加的自报告 step **之后**,追加一个 step
```yaml
- name: Sync receipt to Notion
if: always()
env:
NOTION_API_KEY: $ secrets.NOTION_API_KEY
run: |
node scripts/neural/track-work-orders.js \
--instruction-id "$ github.event.inputs.instruction_id || 'AUTO' " \
--status "$ job.status " \
--workflow "$ github.workflow "
```
### Phase 3验证
1. 手动触发一个 Workflow`brain-self-check.yml`
2. 确认执行后指令回执追踪表中出现新记录
3. 确认字段映射正确
---
## 四、铁律
1. **每条指令必须有回执** — 写入失败 ≠ 静默,必须在 SYSLOG 中报错
2. **回执写入不阻塞主流程**`if: always()` + 错误捕获,写入失败不影响 Workflow 本身
3. **幂等** — 同一指令编号重复写入 = 更新(不创建重复记录)
4. **超时自动标记** — 签发超过 24h 无回执 → 🟡 · 超过 72h → 🔴(由天眼巡检时检查)
---
## 五、回执格式
铸渊执行完本指令后,回执需包含:
<aside>
📋
**回执编号**ZY-RECEIPT-SYNC-2026-0325-001-ACK
**执行结果**
- [ ] Phase 1track-work-orders.js 配置写入目标已更新
- [ ] Phase 2Workflow 追加回执写入 step
- [ ] Phase 3验证通过指令回执追踪表有新记录
**新增/修改文件数**
**Neural System Version**3.0.0
</aside>
---
> 📌 **本指令版本**ZY-RECEIPT-SYNC-2026-0325-001 v1.0
>
> 🧊 **签发**霜砚AG-SY-01  📅 **日期**2026-03-25
>
> 🔗 **前置指令**ZY-NEURAL-UPGRADE-2026-0325-R2三篇 · 已执行)
>
> 📌 **版权**:国作登字-2026-A-00037559
>