feat: 执行层自动开发循环升级 v5.1

新增模块:
- core/context-loader: 执行前系统上下文加载器

升级模块:
- core/task-queue: 新增任务类型 (system/dev/maintenance/auto-task)
- core/system-check: 新增自动任务生成 (generateAutoTasks)
- core/execution-sync: 包含 context-loader 模块检查

更新:
- .github/workflows/execution-sync.yml: 集成上下文加载步骤
- docs/execution-layer-map.md: 新增自动开发循环文档
- brain/master-brain.md: v5.0 → v5.1
- brain/system-health.json: 新增 auto_dev_loop/context_loader 状态
- package.json: 新增 core:context 脚本

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-14 06:57:30 +00:00
parent afc1897ef7
commit b162ac507f
9 changed files with 332 additions and 40 deletions

View File

@ -22,15 +22,19 @@ jobs:
with: with:
node-version: '20' node-version: '20'
# ── Step 1: 运行系统自检 ── # ── Step 1: 加载执行上下文 ──
- name: 运行系统自检 - name: 加载执行上下文
run: node core/system-check run: node core/context-loader
# ── Step 2: 生成执行状态报告 ── # ── Step 2: 运行系统自检 ──
- name: 运行系统自检
run: node core/system-check --auto-tasks
# ── Step 3: 生成执行状态报告 ──
- name: 生成执行状态报告 - name: 生成执行状态报告
run: node core/execution-sync report run: node core/execution-sync report
# ── Step 3: 同步到 Notion ── # ── Step 4: 同步到 Notion ──
- name: 同步执行状态到 Notion - name: 同步执行状态到 Notion
if: ${{ env.NOTION_TOKEN != '' }} if: ${{ env.NOTION_TOKEN != '' }}
env: env:
@ -38,7 +42,7 @@ jobs:
EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }} EXECUTION_LOG_DB_ID: ${{ secrets.EXECUTION_LOG_DB_ID }}
run: node core/execution-sync sync run: node core/execution-sync sync
# ── Step 4: 提交状态报告 ── # ── Step 5: 提交状态报告 ──
- name: 提交状态报告 - name: 提交状态报告
run: | run: |
git config user.name "铸渊 Execution Sync" git config user.name "铸渊 Execution Sync"

View File

@ -1,12 +1,12 @@
# 铸渊执行层 · 系统导航主文件 # 铸渊执行层 · 系统导航主文件
# Master Brain · v5.0 # Master Brain · v5.1
# 数字地球系统通信协议 v5.0 — AGE-5 升级版 # 数字地球系统通信协议 v5.1 — AGE-5 自动开发循环升级
--- ---
## 系统版本 ## 系统版本
**v5.0** — 数字地球系统通信协议 · 仓库执行层系统升级 **v5.1** — 数字地球系统通信协议 · 自动开发循环升级
--- ---
@ -60,13 +60,14 @@
--- ---
## v5.0 升级模块 ## v5.1 执行层模块
| 入口 | 路径 | 说明 | | 入口 | 路径 | 说明 |
|------|------|------| |------|------|------|
| 上下文加载 | `core/context-loader/index.js` | 执行前系统上下文加载 |
| 广播监听 | `core/broadcast-listener/index.js` | 广播监听与任务解析 | | 广播监听 | `core/broadcast-listener/index.js` | 广播监听与任务解析 |
| 任务队列 | `core/task-queue/index.js` | 任务调度与执行 | | 任务队列 | `core/task-queue/index.js` | 任务调度与执行(含类型分类) |
| 系统自检 | `core/system-check/index.js` | 仓库自检系统 | | 系统自检 | `core/system-check/index.js` | 仓库自检 + 自动任务生成 |
| 执行同步 | `core/execution-sync/index.js` | 执行层状态同步 | | 执行同步 | `core/execution-sync/index.js` | 执行层状态同步 |
| Notion 同步 | `connectors/notion-sync/index.js` | 双向数据同步 | | Notion 同步 | `connectors/notion-sync/index.js` | 双向数据同步 |
| 模型路由 | `connectors/model-router/index.js` | 模型调用路由 | | 模型路由 | `connectors/model-router/index.js` | 模型调用路由 |
@ -88,6 +89,7 @@
5. **巡检维护** — 每日自动巡检系统健康状态 5. **巡检维护** — 每日自动巡检系统健康状态
6. **信号处理** — 处理 SYSLOG、广播、开发者工单 6. **信号处理** — 处理 SYSLOG、广播、开发者工单
7. **状态上报** — 向 Notion认知层报告执行结果 7. **状态上报** — 向 Notion认知层报告执行结果
8. **自动开发循环** — 自检发现问题后自动生成修复/优化任务
--- ---
@ -104,4 +106,4 @@
--- ---
*本文件由铸渊维护 · 系统版本 5.0 · 数字地球系统通信协议 · AGE-5* *本文件由铸渊维护 · 系统版本 5.1 · 数字地球系统通信协议 · AGE-5*

View File

@ -1,5 +1,5 @@
{ {
"version": "5.0", "version": "5.1",
"last_check": "2026-03-14 03:38:09+08:00", "last_check": "2026-03-14 03:38:09+08:00",
"communication": "synced", "communication": "synced",
"automation": "stable", "automation": "stable",
@ -8,6 +8,8 @@
"execution_layer_status": "stable", "execution_layer_status": "stable",
"notion_bridge": "active", "notion_bridge": "active",
"execution_sync": "enabled", "execution_sync": "enabled",
"auto_dev_loop": "enabled",
"context_loader": "active",
"task_queue": "running", "task_queue": "running",
"brain_integrity": { "brain_integrity": {
"complete": true, "complete": true,
@ -19,12 +21,13 @@
"broadcast_listener": "enabled", "broadcast_listener": "enabled",
"task_queue": "enabled", "task_queue": "enabled",
"system_check": "enabled", "system_check": "enabled",
"execution_sync": "enabled" "execution_sync": "enabled",
"context_loader": "enabled"
}, },
"connectors": { "connectors": {
"notion_sync": "enabled", "notion_sync": "enabled",
"model_router": "enabled" "model_router": "enabled"
}, },
"workflow_count": 42, "workflow_count": 43,
"checked_by": "scripts/generate-system-health.js" "checked_by": "scripts/generate-system-health.js"
} }

View File

@ -0,0 +1,166 @@
/**
* core/context-loader 上下文加载器
*
* 职责
* - 在执行任务前加载系统上下文
* - 提供系统状态执行层结构当前任务任务来源等信息
*
* 加载内容
* - 系统状态brain/system-health.json
* - 执行层结构core/ 模块状态
* - 当前任务队列
* - 任务来源标识
*
* 执行流程
* context-loader 加载系统认知 加载任务上下文 返回上下文对象
*
* 调用方式
* node core/context-loader
*/
const fs = require('fs');
const path = require('path');
const ROOT = path.resolve(__dirname, '../..');
/**
* 加载系统状态
*/
function loadSystemHealth() {
const healthPath = path.join(ROOT, 'brain/system-health.json');
if (!fs.existsSync(healthPath)) return null;
try {
return JSON.parse(fs.readFileSync(healthPath, 'utf-8'));
} catch {
return null;
}
}
/**
* 加载执行层模块结构
*/
function loadModuleStructure() {
const modules = [
{ name: 'broadcast-listener', path: 'core/broadcast-listener/index.js' },
{ name: 'task-queue', path: 'core/task-queue/index.js' },
{ name: 'system-check', path: 'core/system-check/index.js' },
{ name: 'execution-sync', path: 'core/execution-sync/index.js' },
{ name: 'context-loader', path: 'core/context-loader/index.js' }
];
const connectors = [
{ name: 'notion-sync', path: 'connectors/notion-sync/index.js' },
{ name: 'model-router', path: 'connectors/model-router/index.js' }
];
return {
core: modules.map(m => ({
...m,
status: fs.existsSync(path.join(ROOT, m.path)) ? 'active' : 'missing'
})),
connectors: connectors.map(c => ({
...c,
status: fs.existsSync(path.join(ROOT, c.path)) ? 'active' : 'missing'
}))
};
}
/**
* 加载当前任务队列概况
*/
function loadQueueSummary() {
const queuePath = path.join(ROOT, 'core/task-queue/queue.json');
if (!fs.existsSync(queuePath)) {
return { total: 0, pending: 0, running: 0 };
}
try {
const queue = JSON.parse(fs.readFileSync(queuePath, 'utf-8'));
const tasks = queue.tasks || [];
return {
total: tasks.length,
pending: tasks.filter(t => t.status === 'pending').length,
running: tasks.filter(t => t.status === 'running').length
};
} catch {
return { total: 0, pending: 0, running: 0 };
}
}
/**
* 加载铸渊身份认知
*/
function loadIdentity() {
return {
name: '铸渊',
role: '仓库执行人格体',
responsibilities: [
'执行系统广播任务',
'维护执行层结构',
'同步执行状态',
'运行自动化流程',
'自动开发循环'
],
principles: [
'Notion 负责系统认知',
'仓库负责执行与运行',
'不修改主脑规则',
'不改变编号体系',
'不破坏现有自动化'
]
};
}
/**
* 加载完整系统上下文
*/
function loadContext() {
const now = new Date();
const beijingTime = new Date(now.getTime() + 8 * 60 * 60 * 1000)
.toISOString().replace('T', ' ').slice(0, 19) + '+08:00';
const context = {
loaded_at: beijingTime,
identity: loadIdentity(),
system_health: loadSystemHealth(),
module_structure: loadModuleStructure(),
queue_summary: loadQueueSummary()
};
return context;
}
// CLI 入口
if (require.main === module) {
console.log('🧠 铸渊上下文加载器 v5.1');
console.log('═'.repeat(40));
const ctx = loadContext();
console.log(`\n⏰ 加载时间: ${ctx.loaded_at}`);
console.log(`\n👤 身份: ${ctx.identity.name}${ctx.identity.role}`);
const health = ctx.system_health;
if (health) {
console.log(`\n💚 系统版本: v${health.version}`);
console.log(` 状态: ${health.system_health}`);
console.log(` 执行层: ${health.execution_layer_status}`);
} else {
console.log('\n⚠ 系统状态未加载');
}
const mods = ctx.module_structure;
const activeCore = mods.core.filter(m => m.status === 'active').length;
const activeConn = mods.connectors.filter(c => c.status === 'active').length;
console.log(`\n🔧 核心模块: ${activeCore}/${mods.core.length}`);
console.log(`🔌 连接器: ${activeConn}/${mods.connectors.length}`);
const q = ctx.queue_summary;
console.log(`\n📋 任务队列: ${q.total} 总 / ${q.pending} 待处理 / ${q.running} 执行中`);
console.log('\n✅ 上下文加载完成');
}
module.exports = { loadContext, loadSystemHealth, loadModuleStructure, loadQueueSummary, loadIdentity };

View File

@ -26,7 +26,8 @@ function collectCoreModules() {
{ name: 'broadcast-listener', path: 'core/broadcast-listener/index.js' }, { name: 'broadcast-listener', path: 'core/broadcast-listener/index.js' },
{ name: 'task-queue', path: 'core/task-queue/index.js' }, { name: 'task-queue', path: 'core/task-queue/index.js' },
{ name: 'system-check', path: 'core/system-check/index.js' }, { name: 'system-check', path: 'core/system-check/index.js' },
{ name: 'execution-sync', path: 'core/execution-sync/index.js' } { name: 'execution-sync', path: 'core/execution-sync/index.js' },
{ name: 'context-loader', path: 'core/context-loader/index.js' }
]; ];
return modules.map(m => ({ return modules.map(m => ({
@ -189,9 +190,11 @@ ${connTable}
## 执行闭环 ## 执行闭环
\`\`\` \`\`\`
Notion 广播 broadcast-listener task-queue 执行 context-loader broadcast-listener task-queue 执行
execution-sync notion-sync Notion 主脑更新 execution-sync system-check 自动任务生成
notion-sync Notion 主脑更新
\`\`\` \`\`\`
`; `;

View File

@ -29,6 +29,7 @@ const REQUIRED_DIRS = [
'core/task-queue', 'core/task-queue',
'core/system-check', 'core/system-check',
'core/execution-sync', 'core/execution-sync',
'core/context-loader',
'connectors/notion-sync', 'connectors/notion-sync',
'connectors/model-router', 'connectors/model-router',
'.github/workflows', '.github/workflows',
@ -114,6 +115,7 @@ function checkCoreModules() {
{ name: 'task-queue', path: 'core/task-queue/index.js' }, { name: 'task-queue', path: 'core/task-queue/index.js' },
{ name: 'system-check', path: 'core/system-check/index.js' }, { name: 'system-check', path: 'core/system-check/index.js' },
{ name: 'execution-sync', path: 'core/execution-sync/index.js' }, { name: 'execution-sync', path: 'core/execution-sync/index.js' },
{ name: 'context-loader', path: 'core/context-loader/index.js' },
{ name: 'notion-sync', path: 'connectors/notion-sync/index.js' }, { name: 'notion-sync', path: 'connectors/notion-sync/index.js' },
{ name: 'model-router', path: 'connectors/model-router/index.js' } { name: 'model-router', path: 'connectors/model-router/index.js' }
]; ];
@ -177,7 +179,7 @@ function generateReport(dirResults, fileResults, workflows, modules, jsonResults
].length; ].length;
const report = { const report = {
version: '5.0', version: '5.1',
checked_at: new Date().toISOString(), checked_at: new Date().toISOString(),
summary: { summary: {
total_checks: totalChecks, total_checks: totalChecks,
@ -197,11 +199,90 @@ function generateReport(dirResults, fileResults, workflows, modules, jsonResults
return report; return report;
} }
/**
* 根据自检结果生成自动任务
*/
function generateAutoTasks(report) {
const tasks = [];
const timestamp = new Date().toISOString();
// 检查目录缺失 → 生成修复任务
const missingDirs = (report.directories || []).filter(d => !d.exists);
for (const dir of missingDirs) {
tasks.push({
task_id: `auto-fix-dir-${dir.path.replace(/\//g, '-')}-${timestamp.slice(0, 10)}`,
type: 'auto-task',
source: 'system-check',
priority: 'high',
status: 'pending',
executor: 'zhuyuan',
description: `修复缺失目录: ${dir.path}`
});
}
// 检查文件缺失 → 生成修复任务
const missingFiles = (report.files || []).filter(f => !f.exists);
for (const file of missingFiles) {
tasks.push({
task_id: `auto-fix-file-${file.path.replace(/\//g, '-')}-${timestamp.slice(0, 10)}`,
type: 'auto-task',
source: 'system-check',
priority: 'high',
status: 'pending',
executor: 'zhuyuan',
description: `修复缺失文件: ${file.path}`
});
}
// 检查模块缺失 → 生成修复任务
const missingModules = (report.modules || []).filter(m => !m.exists);
for (const mod of missingModules) {
tasks.push({
task_id: `auto-fix-module-${mod.name}-${timestamp.slice(0, 10)}`,
type: 'auto-task',
source: 'system-check',
priority: 'normal',
status: 'pending',
executor: 'zhuyuan',
description: `修复缺失模块: ${mod.name}`
});
}
// JSON 完整性失败 → 生成修复任务
const invalidJson = (report.json_integrity || []).filter(j => !j.valid);
for (const json of invalidJson) {
tasks.push({
task_id: `auto-fix-json-${json.path.replace(/\//g, '-')}-${timestamp.slice(0, 10)}`,
type: 'auto-task',
source: 'system-check',
priority: 'high',
status: 'pending',
executor: 'zhuyuan',
description: `修复 JSON 文件: ${json.path} (${json.reason})`
});
}
// 健康分数低 → 生成结构优化任务
if (report.summary && report.summary.health_score < 100) {
tasks.push({
task_id: `auto-optimize-structure-${timestamp.slice(0, 10)}`,
type: 'maintenance-task',
source: 'system-check',
priority: 'low',
status: 'pending',
executor: 'zhuyuan',
description: `结构优化: 健康分数 ${report.summary.health_score}%`
});
}
return tasks;
}
/** /**
* 主执行函数 * 主执行函数
*/ */
function run() { function run() {
console.log('🏥 铸渊仓库自检系统 v5.0'); console.log('🏥 铸渊仓库自检系统 v5.1');
console.log('═'.repeat(40)); console.log('═'.repeat(40));
const dirResults = checkDirectories(); const dirResults = checkDirectories();
@ -234,6 +315,17 @@ if (require.main === module) {
fs.writeFileSync(reportPath, JSON.stringify(report, null, 2), 'utf-8'); fs.writeFileSync(reportPath, JSON.stringify(report, null, 2), 'utf-8');
console.log(`\n📝 报告已保存: ${reportPath}`); console.log(`\n📝 报告已保存: ${reportPath}`);
} }
// 可选:生成自动任务
if (process.argv.includes('--auto-tasks')) {
const autoTasks = generateAutoTasks(report);
if (autoTasks.length > 0) {
console.log(`\n🔄 生成 ${autoTasks.length} 个自动任务:`);
autoTasks.forEach(t => console.log(` 📋 ${t.task_id}: ${t.description}`));
} else {
console.log('\n✅ 系统健康,无需生成自动任务');
}
}
} }
module.exports = { run, checkDirectories, checkFiles, checkWorkflows, checkCoreModules, checkJsonIntegrity }; module.exports = { run, generateAutoTasks, checkDirectories, checkFiles, checkWorkflows, checkCoreModules, checkJsonIntegrity };

View File

@ -3,21 +3,29 @@
* *
* 任务结构 * 任务结构
* task_id 唯一任务标识 * task_id 唯一任务标识
* source 来源broadcast / maintenance / dev * source 来源broadcast / maintenance / dev / auto
* type 类型system-task / dev-task / maintenance-task / auto-task
* priority 优先级high / normal / low * priority 优先级high / normal / low
* status 状态pending / running / completed / failed * status 状态pending / running / completed / failed
* executor 执行者zhuyuan * executor 执行者zhuyuan
* *
* 任务类型
* system-task 系统级任务广播状态同步
* dev-task 开发任务代码变更功能开发
* maintenance-task 维护任务结构修复文档更新
* auto-task 自动生成任务自检发现的问题
*
* 任务来源 * 任务来源
* - Notion 广播 * - Notion 广播
* - 系统维护任务 * - 系统维护任务
* - 开发任务 * - 开发任务
* - 自动开发循环生成
* *
* 执行流程 * 执行流程
* 任务进入队列 执行器运行 执行结果写回 * 任务进入队列 按优先级去重 执行器运行 执行结果写回
* *
* 调用方式 * 调用方式
* node core/task-queue [status|run|add] * node core/task-queue [status|run|cleanup]
*/ */
const fs = require('fs'); const fs = require('fs');
@ -31,12 +39,12 @@ const QUEUE_PATH = path.join(ROOT, 'core/task-queue/queue.json');
*/ */
function loadQueue() { function loadQueue() {
if (!fs.existsSync(QUEUE_PATH)) { if (!fs.existsSync(QUEUE_PATH)) {
return { version: '5.0', tasks: [], last_updated: null }; return { version: '5.1', tasks: [], last_updated: null };
} }
try { try {
return JSON.parse(fs.readFileSync(QUEUE_PATH, 'utf-8')); return JSON.parse(fs.readFileSync(QUEUE_PATH, 'utf-8'));
} catch { } catch {
return { version: '5.0', tasks: [], last_updated: null }; return { version: '5.1', tasks: [], last_updated: null };
} }
} }
@ -160,7 +168,13 @@ function status() {
running: tasks.filter(t => t.status === 'running').length, running: tasks.filter(t => t.status === 'running').length,
completed: tasks.filter(t => t.status === 'completed').length, completed: tasks.filter(t => t.status === 'completed').length,
failed: tasks.filter(t => t.status === 'failed').length, failed: tasks.filter(t => t.status === 'failed').length,
last_updated: queue.last_updated last_updated: queue.last_updated,
by_type: {
'system-task': tasks.filter(t => t.type === 'system-task').length,
'dev-task': tasks.filter(t => t.type === 'dev-task').length,
'maintenance-task': tasks.filter(t => t.type === 'maintenance-task').length,
'auto-task': tasks.filter(t => t.type === 'auto-task').length
}
}; };
return stats; return stats;
@ -203,6 +217,12 @@ if (require.main === module) {
console.log(` 已完成: ${s.completed}`); console.log(` 已完成: ${s.completed}`);
console.log(` 失败: ${s.failed}`); console.log(` 失败: ${s.failed}`);
console.log(` 更新时间: ${s.last_updated || '无'}`); console.log(` 更新时间: ${s.last_updated || '无'}`);
if (s.total > 0) {
console.log(' 任务类型分布:');
for (const [type, count] of Object.entries(s.by_type)) {
if (count > 0) console.log(` ${type}: ${count}`);
}
}
break; break;
} }
case 'run': { case 'run': {

View File

@ -1,7 +1,7 @@
# 执行层结构地图 — execution-layer-map.md # 执行层结构地图 — execution-layer-map.md
> 铸渊执行层状态同步系统产物 · TCS-0002∞ > 铸渊执行层自动开发循环升级产物 · TCS-0002∞
> 生成时间2026-03-14 > 生成时间2026-03-14 · v5.1
--- ---
@ -16,11 +16,9 @@
仓库执行层(铸渊) 仓库执行层(铸渊)
自动开发循环
自动化执行系统 自动化执行系统
执行层状态同步
Notion 主脑更新
``` ```
--- ---
@ -29,9 +27,10 @@ Notion 主脑更新
| 模块 | 路径 | 职责 | | 模块 | 路径 | 职责 |
|------|------|------| |------|------|------|
| 上下文加载 | `core/context-loader/index.js` | 执行前加载系统上下文与身份认知 |
| 广播监听 | `core/broadcast-listener/index.js` | 监听并解析 Notion 广播为可执行任务 | | 广播监听 | `core/broadcast-listener/index.js` | 监听并解析 Notion 广播为可执行任务 |
| 任务队列 | `core/task-queue/index.js` | 任务入队、调度、优先级管理 | | 任务队列 | `core/task-queue/index.js` | 任务入队、调度、优先级管理、类型分类 |
| 系统自检 | `core/system-check/index.js` | 仓库结构完整性检查 | | 系统自检 | `core/system-check/index.js` | 仓库结构完整性检查 + 自动任务生成 |
| 执行同步 | `core/execution-sync/index.js` | 生成执行状态报告并同步到 Notion | | 执行同步 | `core/execution-sync/index.js` | 生成执行状态报告并同步到 Notion |
--- ---
@ -73,22 +72,24 @@ Notion 主脑更新
--- ---
## 执行闭环 ## 执行闭环(自动开发循环 v5.1
``` ```
Notion 广播(主脑下发 context-loader上下文加载
broadcast-listener广播监听 broadcast-listener广播监听
task-queue任务排队 task-queue任务排队 · 类型: system/dev/maintenance/auto
执行器运行 执行器运行
execution-sync状态采集 execution-sync状态采集
system-check自检 + 自动任务生成)
connectors/notion-sync状态回写 connectors/notion-sync状态回写
Notion 主脑更新 Notion 主脑更新
生成下一任务 生成下一任务(自动开发循环)
``` ```

View File

@ -35,6 +35,7 @@
"core:queue": "node core/task-queue status", "core:queue": "node core/task-queue status",
"core:check": "node core/system-check", "core:check": "node core/system-check",
"core:sync": "node core/execution-sync report", "core:sync": "node core/execution-sync report",
"core:context": "node core/context-loader",
"connector:notion": "node connectors/notion-sync status", "connector:notion": "node connectors/notion-sync status",
"connector:model": "node connectors/model-router" "connector:model": "node connectors/model-router"
}, },