From afc1897ef7e5fd9e6b54424bb8571f7ccf938184 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 06:39:45 +0000 Subject: [PATCH] fix: address code review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix execution-sync calling wrong method (pushExecutionLog → syncExecutionStatus) - Fix task queue preserving original fields on update - Fix redundant duplicate check in broadcast-listener - Fix workflow secret check pattern - Add Notion DB schema note in connector docs Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- .github/workflows/execution-sync.yml | 2 +- connectors/notion-sync/index.js | 6 +++--- core/broadcast-listener/index.js | 5 +---- core/execution-sync/index.js | 6 +----- core/task-queue/index.js | 8 +++++++- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/execution-sync.yml b/.github/workflows/execution-sync.yml index d101a56f..e8d5eebe 100644 --- a/.github/workflows/execution-sync.yml +++ b/.github/workflows/execution-sync.yml @@ -32,7 +32,7 @@ jobs: # ── Step 3: 同步到 Notion ── - name: 同步执行状态到 Notion - if: ${{ secrets.NOTION_TOKEN != '' }} + if: ${{ env.NOTION_TOKEN != '' }} env: NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }} diff --git a/connectors/notion-sync/index.js b/connectors/notion-sync/index.js index 645c6af4..63a25a88 100644 --- a/connectors/notion-sync/index.js +++ b/connectors/notion-sync/index.js @@ -4,15 +4,15 @@ * 功能: * - 读取 Notion 广播 * - 写回执行日志 - * - 同步任务状态 + * - 同步执行层状态 * * 同步结构: * Notion → 仓库(下行:读取广播/工单) * 仓库 → Notion(上行:写回日志/状态) * * 环境变量: - * NOTION_TOKEN — Notion API Token - * BROADCAST_DB_ID — 广播数据库 ID + * NOTION_TOKEN — Notion API Token + * BROADCAST_DB_ID — 广播数据库 ID(需包含 status 属性,值: 待执行/已完成) * EXECUTION_LOG_DB_ID — 执行日志数据库 ID * * 调用方式: diff --git a/core/broadcast-listener/index.js b/core/broadcast-listener/index.js index 4e0d3b84..d118e4ab 100644 --- a/core/broadcast-listener/index.js +++ b/core/broadcast-listener/index.js @@ -97,12 +97,9 @@ function isDuplicate(broadcastId) { try { const memory = JSON.parse(fs.readFileSync(MEMORY_PATH, 'utf-8')); const events = memory.events || []; - const today = new Date().toISOString().slice(0, 10); - return events.some(e => e.broadcast_id === broadcastId || - (e.type === 'broadcast' && e.description === broadcastId) || - (e.type === 'broadcast' && e.description === broadcastId && (e.date || '').startsWith(today)) + (e.type === 'broadcast' && e.description === broadcastId) ); } catch { return false; diff --git a/core/execution-sync/index.js b/core/execution-sync/index.js index fa2b0c66..58e7fec1 100644 --- a/core/execution-sync/index.js +++ b/core/execution-sync/index.js @@ -223,11 +223,7 @@ async function syncToNotion(statusData) { } console.log('📡 同步执行状态到 Notion...'); - await notionSync.pushExecutionLog({ - task_id: `execution-sync-${new Date().toISOString().slice(0, 10)}`, - status: statusData.execution_layer_status, - message: `v${statusData.version} | modules: ${statusData.core_modules.length} | workflows: ${statusData.workflows.count} | queue: ${statusData.task_queue.total}` - }); + await notionSync.syncExecutionStatus(statusData); } // CLI 入口 diff --git a/core/task-queue/index.js b/core/task-queue/index.js index 74f51542..ffb97b15 100644 --- a/core/task-queue/index.js +++ b/core/task-queue/index.js @@ -57,7 +57,13 @@ function enqueue(task) { // 去重:相同 task_id 只保留最新 const existing = queue.tasks.findIndex(t => t.task_id === task.task_id); if (existing !== -1) { - queue.tasks[existing] = { ...task, updated_at: new Date().toISOString() }; + const original = queue.tasks[existing]; + queue.tasks[existing] = { + ...original, + ...task, + queued_at: original.queued_at, + updated_at: new Date().toISOString() + }; console.log(`🔄 更新已有任务: ${task.task_id}`); } else { queue.tasks.push({