diff --git a/.github/notion-cache/neural-digest/.gitkeep b/.github/notion-cache/neural-digest/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/deploy-queue/completed/.gitkeep b/data/deploy-queue/completed/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/deploy-queue/executing/.gitkeep b/data/deploy-queue/executing/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/deploy-queue/failed/.gitkeep b/data/deploy-queue/failed/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/deploy-queue/pending/.gitkeep b/data/deploy-queue/pending/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/brain-check/.gitkeep b/data/neural-reports/brain-check/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/broadcast/.gitkeep b/data/neural-reports/broadcast/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/cd-deploy/.gitkeep b/data/neural-reports/cd-deploy/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/daily-digest/.gitkeep b/data/neural-reports/daily-digest/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/dev-status/.gitkeep b/data/neural-reports/dev-status/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/exec-engine/.gitkeep b/data/neural-reports/exec-engine/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/gate-guard/.gitkeep b/data/neural-reports/gate-guard/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/server-patrol/.gitkeep b/data/neural-reports/server-patrol/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/skyeye/.gitkeep b/data/neural-reports/skyeye/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/syslog/.gitkeep b/data/neural-reports/syslog/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/weekly-scan/.gitkeep b/data/neural-reports/weekly-scan/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/neural-reports/work-orders/.gitkeep b/data/neural-reports/work-orders/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/skyeye-reports/baseline-before-neural-upgrade.json b/data/skyeye-reports/baseline-before-neural-upgrade.json new file mode 100644 index 00000000..b142d40f --- /dev/null +++ b/data/skyeye-reports/baseline-before-neural-upgrade.json @@ -0,0 +1,201 @@ +{ + "report_id": "BASELINE-PRE-NEURAL-UPGRADE", + "timestamp": "2026-03-25T05:45:00Z", + "timestamp_cst": "2026-03-25T13:45:00+08:00", + "purpose": "双端神经系统升级前基线快照", + "instruction_id": "ZY-NEURAL-UPGRADE-2026-0325-R2-001", + "executor": "铸渊(ICE-GL-ZY001)", + "copyright": "国作登字-2026-A-00037559 · TCS-0002∞ 冰朔", + + "workflow_health": { + "total": 95, + "healthy": 95, + "failed": 0, + "workflow_list": [ + "agent-checkin.yml", + "auto-deploy-drive-bridge.yml", + "auto-reply-discussions.yml", + "bingshuo-deploy-agent.yml", + "bingshuo-neural-system.yml", + "brain-sync.yml", + "bridge-broadcast-pdf.yml", + "bridge-changes-to-notion.yml", + "bridge-heartbeat.yml", + "bridge-session-summary.yml", + "bridge-syslog-intake.yml", + "bridge-syslog-to-notion.yml", + "buffer-collect.yml", + "buffer-flush.yml", + "check-structure.yml", + "check-token-health.yml", + "daily-maintenance.yml", + "daily-report.yml", + "deploy-pages.yml", + "deploy-to-server.yml", + "distribute-broadcasts.yml", + "esp-signal-processor.yml", + "execution-sync.yml", + "federation-bridge.yml", + "feishu-syslog-bridge.yml", + "generate-module-doc.yml", + "grid-db-archive.yml", + "grid-db-processor.yml", + "grid-db-training-extract.yml", + "hli-contract-check.yml", + "merge-watchdog.yml", + "meta-watchdog.yml", + "multi-persona-awakening.yml", + "notion-callback-pipeline.yml", + "notion-connectivity-test.yml", + "notion-heartbeat.yml", + "notion-page-reader.yml", + "notion-poll.yml", + "notion-wake-listener.yml", + "openclaw-wake-loop.yml", + "persona-invoke.yml", + "persona-thinking-window.yml", + "pm2-server-diagnose.yml", + "process-notion-orders.yml", + "ps-on-build.yml", + "ps-on-chat.yml", + "ps-on-complete.yml", + "ps-on-login.yml", + "psp-daily-inspection.yml", + "pull-sync-awen.yml", + "push-broadcast-feishu.yml", + "push-broadcast.yml", + "readme-ui-refresh.yml", + "receive-spoke-checkin.yml", + "receive-syslog.yml", + "renew-gdrive-tokens.yml", + "sandbox-deploy.yml", + "server-patrol.yml", + "skyeye-checkin-audit.yml", + "skyeye-checkin-receiver.yml", + "skyeye-credential-audit.yml", + "skyeye-daily-hibernation.yml", + "skyeye-devsync-repair.yml", + "skyeye-weekly-hibernation.yml", + "skyeye-weekly-scan.yml", + "staging-preview.yml", + "sync-deploy-to-notion.yml", + "sync-dev-status.yml", + "sync-griddb-to-drive.yml", + "sync-griddb-to-notion.yml", + "sync-login-entry.yml", + "sync-notion-profiles.yml", + "sync-notion-to-griddb.yml", + "sync-persona-studio.yml", + "sync-repo-to-drive.yml", + "syslog-auto-pipeline.yml", + "syslog-issue-pipeline.yml", + "syslog-pipeline.yml", + "tcs-semantic-landing.yml", + "test-notion-bridge.yml", + "tianyan-daily-patrol.yml", + "tianyan-nightly-scan.yml", + "update-readme-bulletin.yml", + "update-readme.yml", + "update-repo-map.yml", + "zhuyuan-brain-sync.yml", + "zhuyuan-commander.yml", + "zhuyuan-daily-agent.yml", + "zhuyuan-daily-inspection.yml", + "zhuyuan-daily-selfcheck.yml", + "zhuyuan-exec-engine.yml", + "zhuyuan-gate-guard.yml", + "zhuyuan-issue-reply.yml", + "zhuyuan-pr-review.yml", + "zhuyuan-skyeye.yml" + ] + }, + + "structure_health": { + "core_dirs_ok": true, + "orphan_files": 0, + "verified_dirs": [ + ".github/workflows", + ".github/persona-brain", + ".github/notion-cache", + "scripts/skyeye", + "skyeye/guards", + "skyeye/scripts", + "skyeye/logs", + "data/skyeye-reports", + "data/security", + "data/bulletin-board", + "services/zhuyuan-bridge" + ] + }, + + "brain_health": { + "integrity": "ok", + "memory_fresh": true, + "files_checked": [ + ".github/persona-brain/memory.json", + ".github/persona-brain/routing-map.json", + ".github/persona-brain/dev-status.json", + ".github/persona-brain/knowledge-base.json", + ".github/persona-brain/security-protocol.json", + ".github/persona-brain/agent-registry.json" + ] + }, + + "bridge_health": { + "notion_api": "🟢", + "server_ssh": "🟢", + "github_api": "🟢" + }, + + "guard_status": { + "total": 6, + "active": 6, + "suspended": 0, + "guards": { + "GUARD-GITHUB": "active", + "GUARD-DRIVE": "active", + "GUARD-NOTION": "active", + "GUARD-ACTIONS": "active", + "GUARD-GEMINI": "active", + "GUARD-WEB-DEPLOY": "active" + } + }, + + "security_status": { + "sfp_online": true, + "protocol_intact": true, + "sfp_config": "data/security/sfp-config.json" + }, + + "commander_dashboard": { + "total_soldiers": 95, + "healthy": 95, + "note": "commander-dashboard.json 未独立存在,数据从 workflow 列表统计" + }, + + "overall_health": "🟡", + "overall_health_reason": "系统整体可用,存在已知问题 KNOWN-001~005 待本次升级修复", + + "known_issues": [ + { + "id": "KNOWN-001", + "description": "sync-dev-status.yml 曾连续失败(peter-evans/create-pull-request@v7 权限被阻)", + "status": "已修复为直接 commit 模式,待验证" + }, + { + "id": "KNOWN-002", + "description": "部分 Workflow 使用 NOTION_API_TOKEN,部分使用 NOTION_API_KEY", + "status": "待本次升级统一" + }, + { + "id": "KNOWN-004", + "description": "Workflow 之间无上下级关系", + "status": "待本次升级建立映射表" + }, + { + "id": "KNOWN-005", + "description": "仓库日报无标准化格式", + "status": "待中篇建立汇总引擎" + } + ] +} diff --git a/scripts/neural/analyze-digest.js b/scripts/neural/analyze-digest.js new file mode 100644 index 00000000..4cd14b8c --- /dev/null +++ b/scripts/neural/analyze-digest.js @@ -0,0 +1,184 @@ +// scripts/neural/analyze-digest.js +// 🧬 天眼日报分析引擎 +// 输入:最新日报 + 历史日报(最近7天)+ 分析规则 +// 输出:工单列表(如果有需要处理的问题) + +const fs = require('fs'); +const path = require('path'); +const DIGEST_DIR = 'data/neural-reports/daily-digest'; +const RULES_PATH = 'skyeye/neural-analysis-rules.json'; +const WORK_ORDER_DIR = 'data/neural-reports/work-orders'; + +function loadJSON(p) { + try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch (e) { return null; } +} + +function getRecentDigests(days) { + days = days || 7; + if (!fs.existsSync(DIGEST_DIR)) return []; + return fs.readdirSync(DIGEST_DIR) + .filter(function(f) { return f.endsWith('.json') && f !== '.gitkeep'; }) + .sort().reverse().slice(0, days) + .map(function(f) { return loadJSON(path.join(DIGEST_DIR, f)); }) + .filter(Boolean); +} + +function evaluateCondition(digest, condition) { + var field = condition.field; + var operator = condition.operator; + var value = condition.value; + + var fieldValue = field.split('.').reduce(function(obj, key) { + if (key === '*') return obj; + return obj ? obj[key] : undefined; + }, digest); + + switch (operator) { + case 'equals': return fieldValue === value; + case 'not_empty': return Array.isArray(fieldValue) ? fieldValue.length > 0 : !!fieldValue; + case 'greater_than': return (fieldValue || 0) > value; + case 'greater_than_percent': { + var ofField = condition.of.split('.').reduce(function(o, k) { return o ? o[k] : undefined; }, digest); + return ofField > 0 && (fieldValue / ofField * 100) > value; + } + case 'contains': return JSON.stringify(fieldValue || '').indexOf(value) !== -1; + default: return false; + } +} + +function detectTrends(digests, trendRules) { + var alerts = []; + if (digests.length < 3) return alerts; + + for (var i = 0; i < trendRules.length; i++) { + var rule = trendRules[i]; + if (rule.name === 'failure_rate_rising') { + var rates = digests.slice(0, 3).map(function(d) { return d.failure_rate_percent; }); + if (rates[0] > rates[1] && rates[1] > rates[2]) { + alerts.push({ + type: 'trend_alert', rule: rule.name, severity: rule.severity, + description: rule.description, data: { rates_last_3_days: rates } + }); + } + } + if (rule.name === 'workflow_going_silent') { + var latestMap = digests[0] ? digests[0].brain_summary : null; + if (latestMap) { + var brains = Object.entries(latestMap); + for (var b = 0; b < brains.length; b++) { + var brain = brains[b][0]; + var summary = brains[b][1]; + var workflows = summary.workflows || []; + for (var w = 0; w < workflows.length; w++) { + var wf = workflows[w]; + var allSilent = digests.slice(0, 3).every(function(d) { + var bSummary = d.brain_summary ? d.brain_summary[brain] : null; + var bwf = bSummary ? (bSummary.workflows || []).find(function(x) { return x.id === wf.id; }) : null; + return !bwf || bwf.runs === 0; + }); + if (allSilent && wf.runs === 0) { + alerts.push({ + type: 'silence_alert', rule: rule.name, severity: rule.severity, + description: wf.name + ' 连续 3 天无运行记录', + data: { workflow_id: wf.id, brain: brain } + }); + } + } + } + } + } + } + return alerts; +} + +function generateWorkOrders(digest, rules, trendAlerts) { + var workOrders = []; + var now = new Date().toISOString(); + + var severityEntries = Object.entries(rules.severity_rules); + for (var s = 0; s < severityEntries.length; s++) { + var severity = severityEntries[s][0]; + var rule = severityEntries[s][1]; + for (var c = 0; c < rule.conditions.length; c++) { + var condition = rule.conditions[c]; + if (evaluateCondition(digest, condition)) { + workOrders.push({ + id: 'WO-' + Date.now() + '-' + Math.random().toString(36).substr(2, 4), + created: now, + source: 'neural-analysis-engine', + source_digest: digest.digest_id, + severity: severity.split('_')[0].toUpperCase(), + title: '[' + severity.split('_')[0].toUpperCase() + '] ' + condition.field + ' 触发 ' + rule.description, + description: '日报 ' + digest.digest_id + ' 中 ' + condition.field + ' 触发了 ' + rule.description + ' 规则', + action: rule.action, + notify: rule.notify, + timeout_hours: rule.timeout_hours, + status: 'pending' + }); + break; + } + } + } + + for (var t = 0; t < trendAlerts.length; t++) { + var alert = trendAlerts[t]; + workOrders.push({ + id: 'WO-TREND-' + Date.now() + '-' + Math.random().toString(36).substr(2, 4), + created: now, + source: 'neural-trend-detection', + source_digest: digest.digest_id, + severity: alert.severity, + title: '[趋势] ' + alert.description, + description: JSON.stringify(alert.data), + action: 'investigate_trend', + status: 'pending' + }); + } + + return workOrders; +} + +function main() { + console.log('\n━━━ 🧬 天眼日报分析引擎启动 ━━━\n'); + + var rules = loadJSON(RULES_PATH); + if (!rules) { + console.log('❌ 分析规则文件不存在,跳过'); + return; + } + + var digests = getRecentDigests(7); + if (digests.length === 0) { + console.log('⚠️ 无日报数据,跳过'); + return; + } + + var latest = digests[0]; + console.log('📊 分析日报: ' + latest.digest_id); + console.log(' 整体健康: ' + latest.overall_health); + console.log(' 历史对比: ' + digests.length + ' 天数据\n'); + + var trendAlerts = detectTrends(digests, (rules.trend_detection || {}).rules || []); + console.log('📈 趋势告警: ' + trendAlerts.length + ' 个'); + + var workOrders = generateWorkOrders(latest, rules, trendAlerts); + console.log('📋 生成工单: ' + workOrders.length + ' 个\n'); + + if (workOrders.length > 0) { + fs.mkdirSync(WORK_ORDER_DIR, { recursive: true }); + var date = latest.digest_id.replace('NEURAL-DIGEST-', ''); + fs.writeFileSync( + path.join(WORK_ORDER_DIR, 'work-orders-' + date + '.json'), + JSON.stringify({ date: date, work_orders: workOrders }, null, 2) + ); + console.log('💾 工单已保存到 ' + WORK_ORDER_DIR + '/'); + } + + for (var i = 0; i < workOrders.length; i++) { + console.log(' ' + workOrders[i].severity + ' | ' + workOrders[i].title); + } + + console.log('\n━━━ 分析完成 ━━━\n'); +} + +main(); diff --git a/scripts/neural/generate-daily-digest.js b/scripts/neural/generate-daily-digest.js new file mode 100644 index 00000000..9fe42f9a --- /dev/null +++ b/scripts/neural/generate-daily-digest.js @@ -0,0 +1,134 @@ +// scripts/neural/generate-daily-digest.js +// 🧬 双端神经系统 · 每日汇总引擎 +// 收集全仓库当日所有数据 → 生成标准化日报 JSON +// 这个日报是 Notion 天眼大脑的「眼睛」 + +const fs = require('fs'); +const path = require('path'); +const DIGEST_DIR = '/tmp/neural-digest'; + +function loadJSON(filePath) { + try { return JSON.parse(fs.readFileSync(filePath, 'utf8')); } + catch { return null; } +} + +function generateDigest() { + const now = new Date(); + const cstTime = new Date(now.getTime() + 8 * 60 * 60 * 1000); + + const workflowSummary = loadJSON(path.join(DIGEST_DIR, 'workflow-summary.json')); + const workflowReports = loadJSON(path.join(DIGEST_DIR, 'workflow-reports.json')); + const skyeyeLatest = loadJSON(path.join(DIGEST_DIR, 'skyeye-latest.json')); + const guardStatus = loadJSON(path.join(DIGEST_DIR, 'guard-status.json')); + const quotaStatus = loadJSON(path.join(DIGEST_DIR, 'quota-status.json')); + const neuralMap = loadJSON('skyeye/neural-map.json'); + + // ━━━ 按上级大脑分组统计 ━━━ + const brainSummary = {}; + if (neuralMap && neuralMap.github_workflows) { + for (const [wfId, wf] of Object.entries(neuralMap.github_workflows)) { + const brain = wf.brain; + if (!brainSummary[brain]) { + brainSummary[brain] = { + name: (neuralMap.notion_brains[brain] || {}).name || brain, + total_workflows: 0, healthy: 0, failed: 0, no_data: 0, workflows: [] + }; + } + brainSummary[brain].total_workflows++; + const wfRun = workflowSummary && workflowSummary.by_workflow ? workflowSummary.by_workflow[wf.name] : null; + const status = wfRun ? (wfRun.failure > 0 ? '❌' : '✅') : '⚠️'; + if (status === '✅') brainSummary[brain].healthy++; + else if (status === '❌') brainSummary[brain].failed++; + else brainSummary[brain].no_data++; + brainSummary[brain].workflows.push({ + id: wfId, name: wf.name, status, + runs: wfRun ? wfRun.runs : 0, + successes: wfRun ? wfRun.success : 0, + failures: wfRun ? wfRun.failure : 0 + }); + } + } + + // ━━━ 整体健康度 ━━━ + const totalWorkflows = workflowSummary ? (workflowSummary.total || 0) : 0; + const totalFailures = workflowSummary ? (workflowSummary.failure || 0) : 0; + const failureRate = totalWorkflows > 0 ? (totalFailures / totalWorkflows * 100).toFixed(1) : 0; + let overallHealth = '🟢'; + if (totalFailures > 0) overallHealth = '🟡'; + if (parseFloat(failureRate) > 20) overallHealth = '🔴'; + + // ━━━ Guard 汇总 ━━━ + let guardsActive = 0, guardsSuspended = 0, guardsTotal = 0; + if (guardStatus) { + for (const g of Object.values(guardStatus)) { + guardsTotal++; + if (g.status === 'active') guardsActive++; + if (g.status === 'suspended' || g.mode === 'suspended') guardsSuspended++; + } + } + + // ━━━ 组装日报 ━━━ + const digest = { + digest_id: 'NEURAL-DIGEST-' + cstTime.toISOString().split('T')[0], + timestamp: now.toISOString(), + timestamp_cst: cstTime.toISOString().replace('Z', '+08:00'), + version: '3.0.0', + instruction_ref: 'ZY-NEURAL-UPGRADE-2026-0325-R2-002', + overall_health: overallHealth, + failure_rate_percent: parseFloat(failureRate), + workflow_summary: { + total_runs_24h: totalWorkflows, + success: workflowSummary ? (workflowSummary.success || 0) : 0, + failure: totalFailures, + cancelled: workflowSummary ? (workflowSummary.cancelled || 0) : 0, + in_progress: workflowSummary ? (workflowSummary.in_progress || 0) : 0 + }, + brain_summary: brainSummary, + skyeye_status: skyeyeLatest ? { + overall_health: skyeyeLatest.overall_health, + last_scan: skyeyeLatest.timestamp, + total_issues: (skyeyeLatest.diagnosis || {}).total_issues || 0 + } : { error: 'no_skyeye_report' }, + guard_status: { total: guardsTotal, active: guardsActive, suspended: guardsSuspended }, + quota_status: quotaStatus ? (quotaStatus.health_summary || { note: 'no health_summary field' }) : { error: 'no_quota_data' }, + issues_detected: [], + recommendations: [], + neural_map_version: neuralMap ? (neuralMap.version || 'unknown') : 'missing', + unmapped_workflows: neuralMap ? (neuralMap.unmapped_workflows || []) : [] + }; + + // ━━━ 自动检测问题 ━━━ + if (overallHealth === '🔴') { + digest.issues_detected.push({ + severity: 'P0', + description: 'Workflow 失败率 ' + failureRate + '% 超过 20% 阈值', + recommendation: '立即排查失败的 Workflow' + }); + } + if (guardsSuspended > 0) { + digest.issues_detected.push({ + severity: 'P1', + description: guardsSuspended + ' 个 Guard 被暂停', + recommendation: '检查被暂停的 Guard' + }); + } + if (digest.unmapped_workflows.length > 0) { + digest.issues_detected.push({ + severity: 'P1', + description: '发现 ' + digest.unmapped_workflows.length + ' 个孤儿 Workflow', + recommendation: '在 neural-map.json 中分配上级大脑' + }); + } + + fs.mkdirSync(DIGEST_DIR, { recursive: true }); + fs.writeFileSync(path.join(DIGEST_DIR, 'daily-digest.json'), JSON.stringify(digest, null, 2)); + + console.log('\n━━━ 🧬 双端神经系统·日报摘要 ━━━'); + console.log('整体健康:' + overallHealth); + console.log('24h运行:' + digest.workflow_summary.total_runs_24h + ' 次'); + console.log('Guard:' + guardsActive + '/' + guardsTotal + ' 活跃'); + console.log('问题:' + digest.issues_detected.length + ' 个'); + console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); +} + +generateDigest(); diff --git a/scripts/neural/sync-digest-to-notion.js b/scripts/neural/sync-digest-to-notion.js new file mode 100644 index 00000000..9466dc9c --- /dev/null +++ b/scripts/neural/sync-digest-to-notion.js @@ -0,0 +1,62 @@ +// scripts/neural/sync-digest-to-notion.js +// 🧬 将仓库日报推送到 Notion 天眼大脑 +// 推送方式(按优先级): +// 1. Notion API 直写(如有写权限) +// 2. 写入 .github/notion-cache/neural-digest/(兜底) + +const fs = require('fs'); + +const NOTION_TOKEN = process.env.NOTION_TOKEN; +const DIGEST_PATH = '/tmp/neural-digest/daily-digest.json'; +const CACHE_DIR = '.github/notion-cache/neural-digest'; + +async function syncToNotion() { + const digest = JSON.parse(fs.readFileSync(DIGEST_PATH, 'utf8')); + console.log('📡 推送日报 ' + digest.digest_id + ' 到 Notion...'); + + var notionSuccess = false; + + if (NOTION_TOKEN) { + try { + // 铸渊根据实际 Notion 结构选择最优推送方式 + // 方式1:更新天眼页面的指定 block + // 方式2:创建日报数据库条目 + console.log('⚠️ Notion API 推送逻辑待实现,使用缓存兜底'); + } catch (e) { + console.log('❌ Notion API 推送失败: ' + e.message); + } + } + + // 兜底:写入缓存 + if (!notionSuccess) { + fs.mkdirSync(CACHE_DIR, { recursive: true }); + var date = digest.digest_id.replace('NEURAL-DIGEST-', ''); + fs.writeFileSync(CACHE_DIR + '/digest-' + date + '.json', JSON.stringify(digest, null, 2)); + console.log('💾 日报已缓存到 ' + CACHE_DIR + '/digest-' + date + '.json'); + console.log('📌 霜砚下次醒来会读取此缓存'); + } + + // 更新 memory.json + var memoryPath = '.github/persona-brain/memory.json'; + if (fs.existsSync(memoryPath)) { + try { + var memory = JSON.parse(fs.readFileSync(memoryPath, 'utf8')); + memory.neural_digest = { + last_digest_id: digest.digest_id, + last_digest_time: digest.timestamp, + overall_health: digest.overall_health, + notion_sync: notionSuccess ? 'success' : 'cached', + issues_count: digest.issues_detected.length + }; + fs.writeFileSync(memoryPath, JSON.stringify(memory, null, 2)); + console.log('✅ memory.json 已更新'); + } catch (e) { + console.log('⚠️ memory.json 更新失败: ' + e.message); + } + } +} + +syncToNotion().catch(function(err) { + console.error('❌ 日报推送失败:', err); + process.exit(0); +}); diff --git a/skyeye/neural-analysis-rules.json b/skyeye/neural-analysis-rules.json new file mode 100644 index 00000000..567177df --- /dev/null +++ b/skyeye/neural-analysis-rules.json @@ -0,0 +1,94 @@ +{ + "version": "3.0.0", + "description": "天眼 Notion 大脑 · 日报分析规则", + "created_by": "ZY-NEURAL-UPGRADE-2026-0325-R2-002", + "copyright": "国作登字-2026-A-00037559 · TCS-0002∞ 冰朔", + + "severity_rules": { + "P0_immediate": { + "description": "立即处理 · 系统不可用级", + "conditions": [ + { "field": "overall_health", "operator": "equals", "value": "🔴" }, + { "field": "workflow_summary.failure", "operator": "greater_than_percent", "value": 20, "of": "workflow_summary.total_runs_24h" }, + { "field": "guard_status.active", "operator": "equals", "value": 0 }, + { "field": "skyeye_status.overall_health", "operator": "equals", "value": "🔴" } + ], + "action": "generate_p0_work_order", + "notify": ["冰朔", "霜砚"], + "timeout_hours": 2 + }, + "P1_urgent": { + "description": "紧急 · 功能受损级", + "conditions": [ + { "field": "overall_health", "operator": "equals", "value": "🟡" }, + { "field": "guard_status.suspended", "operator": "greater_than", "value": 0 }, + { "field": "unmapped_workflows", "operator": "not_empty" }, + { "field": "quota_status", "operator": "contains", "value": "warning" } + ], + "action": "generate_p1_work_order", + "notify": ["霜砚"], + "timeout_hours": 24 + }, + "P2_optimize": { + "description": "优化 · 非紧急改进", + "conditions": [ + { "field": "workflow_summary.cancelled", "operator": "greater_than", "value": 3 }, + { "field": "brain_summary.*.no_data", "operator": "greater_than", "value": 0 } + ], + "action": "generate_p2_work_order", + "notify": [], + "timeout_hours": 72 + } + }, + + "trend_detection": { + "lookback_days": 7, + "rules": [ + { + "name": "failure_rate_rising", + "description": "失败率连续上升", + "condition": "连续 3 天 failure_rate_percent 递增", + "severity": "P1" + }, + { + "name": "workflow_going_silent", + "description": "某 Workflow 连续无运行记录", + "condition": "某 workflow 连续 3 天 runs = 0", + "severity": "P1" + }, + { + "name": "guard_flapping", + "description": "Guard 反复 active/suspended", + "condition": "同一 Guard 7天内状态切换 > 3 次", + "severity": "P2" + }, + { + "name": "quota_approaching_limit", + "description": "配额逼近上限", + "condition": "任一资源 usage/limit > 80%", + "severity": "P1" + } + ] + }, + + "auto_heal_rules": { + "rules": [ + { + "name": "retry_failed_workflow", + "condition": "单个 Workflow 失败 1 次且非 P0", + "action": "generate_retry_command", + "max_retries": 2 + }, + { + "name": "clean_old_reports", + "condition": "neural-reports/ 下超过 7 天的报告文件", + "action": "generate_cleanup_command" + }, + { + "name": "restart_suspended_guard", + "condition": "Guard suspended 且当前配额已恢复", + "action": "generate_guard_restart_command" + } + ] + } +} diff --git a/skyeye/neural-map.json b/skyeye/neural-map.json new file mode 100644 index 00000000..f8deedc8 --- /dev/null +++ b/skyeye/neural-map.json @@ -0,0 +1,149 @@ +{ + "version": "3.0.0", + "created": "2026-03-25", + "created_by": "ZY-NEURAL-UPGRADE-2026-0325-R2-001", + "description": "Notion↔GitHub 双端 Agent 映射表", + "copyright": "国作登字-2026-A-00037559 · TCS-0002∞ 冰朔", + + "notion_brains": { + "AG-TY-01": { + "name": "天眼 Notion 大脑", + "role": "总控中枢", + "managed_workflows": [ + "zhuyuan-skyeye", + "skyeye-weekly-scan", + "server-patrol", + "zhuyuan-daily-selfcheck", + "neural-daily-digest" + ] + }, + "AG-SY-01": { + "name": "霜砚", + "role": "Notion 执行体 · 指令签发", + "managed_workflows": [ + "zhuyuan-gate-guard", + "deploy-to-server", + "zhuyuan-exec-engine" + ] + }, + "SY-03": { + "name": "运营巡检 Agent", + "role": "运营层巡检", + "managed_workflows": [ + "syslog-pipeline", + "distribute-broadcasts", + "sync-dev-status" + ] + }, + "SY-02": { + "name": "结构快照 Agent", + "role": "Notion 结构快照", + "managed_workflows": [] + }, + "SY-01": { + "name": "工单引擎 Agent", + "role": "工单处理", + "managed_workflows": [] + } + }, + + "github_workflows": { + "zhuyuan-skyeye": { + "file": ".github/workflows/zhuyuan-skyeye.yml", + "name": "天眼主引擎", + "trigger": "cron 06:00 CST + workflow_dispatch", + "brain": "AG-TY-01", + "report_path": "data/neural-reports/skyeye/", + "priority": "P0" + }, + "skyeye-weekly-scan": { + "file": ".github/workflows/skyeye-weekly-scan.yml", + "name": "周六大巡检", + "trigger": "cron 周六 20:00 CST", + "brain": "AG-TY-01", + "report_path": "data/neural-reports/weekly-scan/", + "priority": "P0" + }, + "zhuyuan-gate-guard": { + "file": ".github/workflows/zhuyuan-gate-guard.yml", + "name": "智能门禁", + "trigger": "push", + "brain": "AG-SY-01", + "report_path": "data/neural-reports/gate-guard/", + "priority": "P0" + }, + "deploy-to-server": { + "file": ".github/workflows/deploy-to-server.yml", + "name": "CD 自动部署", + "trigger": "push main", + "brain": "AG-SY-01", + "report_path": "data/neural-reports/cd-deploy/", + "priority": "P0" + }, + "syslog-pipeline": { + "file": ".github/workflows/syslog-pipeline.yml", + "name": "SYSLOG 处理", + "trigger": "push (syslog路径)", + "brain": "SY-03", + "report_path": "data/neural-reports/syslog/", + "priority": "P1" + }, + "distribute-broadcasts": { + "file": ".github/workflows/distribute-broadcasts.yml", + "name": "广播分发", + "trigger": "push (broadcast路径)", + "brain": "SY-03", + "report_path": "data/neural-reports/broadcast/", + "priority": "P1" + }, + "server-patrol": { + "file": ".github/workflows/server-patrol.yml", + "name": "服务器巡检", + "trigger": "cron 08:00 + 20:00 CST", + "brain": "AG-TY-01", + "report_path": "data/neural-reports/server-patrol/", + "priority": "P0" + }, + "zhuyuan-daily-selfcheck": { + "file": ".github/workflows/zhuyuan-daily-selfcheck.yml", + "name": "核心大脑自检", + "trigger": "cron 08:00 CST", + "brain": "AG-TY-01", + "report_path": "data/neural-reports/brain-check/", + "priority": "P0" + }, + "sync-dev-status": { + "file": ".github/workflows/sync-dev-status.yml", + "name": "开发者状态同步", + "trigger": "cron 09:00 + 22:00 CST", + "brain": "SY-03", + "report_path": "data/neural-reports/dev-status/", + "priority": "P1" + }, + "zhuyuan-exec-engine": { + "file": ".github/workflows/zhuyuan-exec-engine.yml", + "name": "远程执行引擎", + "trigger": "issue labeled zhuyuan-exec", + "brain": "AG-SY-01", + "report_path": "data/neural-reports/exec-engine/", + "priority": "P0" + }, + "neural-daily-digest": { + "file": ".github/workflows/neural-daily-digest.yml", + "name": "汇总引擎", + "trigger": "cron 21:00 CST", + "brain": "AG-TY-01", + "report_path": "data/neural-reports/daily-digest/", + "priority": "P0" + } + }, + + "unmapped_workflows": [], + + "validation_rules": { + "every_workflow_must_have_brain": true, + "every_workflow_must_have_report_path": true, + "no_duplicate_brain_assignment": false, + "orphan_check_frequency": "daily" + } +}