Skip to content

Commit 045e53b

Browse files
committed
fix governance chain drift
1 parent f3df5b4 commit 045e53b

4 files changed

Lines changed: 56 additions & 26 deletions

File tree

‎changelogs/unreleased.md‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,4 @@
88

99
## 2026-05-27
1010

11-
- 暂无未发布变更。
12-
13-
## 2026-05-26
14-
15-
- 澄清 init/update 同步语义:默认 `init/update` 会同步 Copilot `.github/` 并链式部署 Claude Code adapter,`--claude` 为 Claude-only 路径;同步更新 README、CLI help 与项目 Profile。
16-
- 修复本轮全面审查问题清单:补齐 validate V2/V3/V6/V8/V19 覆盖,新增 `scripts/check-syntax.js`,并将 `test:all` 扩展为发布前全量验证链路(validate、Hook/MCP/fallback/migrate、pack、website build、root/website audit、语法检查)。
17-
- 修复 Hook/MCP/fallback 运行时边界:支持 `optimizations`、`scenario-tests` 任务根,避免只读搜索危险命令字样被误拦,补充无 `WHERE` 的 `DELETE FROM` 阻断与回归测试。
18-
- 修复 CLI 与分发一致性:`init`/`init --claude` 自动创建 `.devcodex/.audit-state/` 并写入 `.gitignore`,`status`/`doctor` 支持 workspace-namespace profile,`detectAgent` 优先宿主环境变量。
19-
- 同步规范、模板与文档站:统一 active-root/workspace-namespace、报告产物 Markdown 链接、G1~G11、data runtime/template 语义与 analyze 子类型口径。
20-
- 清理维护态记录分发边界:将源仓真实治理台账迁入 `.devcodex/.maintainer-state/` 本地维护态,npm 包仅保留空模板与示例说明。
21-
- 修复 Stop hook 可见回复读取根因:Copilot Stop payload 只提供 `transcript_path` 时,Hook 会从 JSONL transcript 解析最新 assistant 正文,再执行入口检查、合规块与产物路径检测,避免把“未读取 transcript”误报为用户未输出产物。
22-
- 明确 devcodex-v1 本地开发同步边界:修改分发源后必须在工作区根同步 `.github/.claude`,不再把源码仓根 `.github/.claude` 作为部署副本目标。
23-
- 修复复审遗留问题:MCP `.mcp.json` smoke test 改为在临时目标项目中验证 `.claude/mcp` 部署产物,避免依赖源码仓未跟踪副本假绿。
24-
- 修复产物路径单行链接边界:Hook 现在能识别位于回复末尾的产物区 Markdown 链接,并补充 Stop reminder 回归测试。
25-
- 修复 V8 部署同步误报:父级 `.github/.claude` 同步检查改为内容哈希优先,避免内容一致但 mtime 较旧时继续产生 stale warning。
26-
- 同步 audit-state finding 状态枚举:规范与校验统一支持 `pending`、`in-progress`、`transferred`、`superseded` 等状态,并阻断终态未解决 findings。
27-
- 修复 hook 关闭阶段与 bootstrap 阶段重复提醒:同一轮相同缺失项只提示一次,并同步当前工作区 `.github/.claude` 部署副本。
28-
- 修复产物路径检测兼容性:支持反引号包裹的 Windows 绝对路径,并允许产物区单行 Markdown 链接被识别为已输出产物。
29-
- 修复 Claude Code MCP 启动契约:`.mcp.json` 改为跨平台相对路径参数,新增按真实 `.mcp.json` 启动服务器的 smoke test。
30-
- 修复 `devcodex status` 在 workspace namespace 项目目录下误判 profile 缺失的问题,并收紧 audit-state 终态 open findings 校验。
31-
- 调整 lifecycle hook 默认执行策略为 `safety-only`:bootstrap、CP gate、Auto 白名单等流程问题改为提醒放行,仅危险命令继续硬拦,避免多项目/附件场景下读取与澄清工具被自锁。
32-
- 增强多项目目标识别:支持从提示词裸项目名和附件路径推断目标项目,并补充 hook runtime 回归测试。
11+
- 修复治理链小修批次:统一 MCP SUMMARY 新建模板、清理已发布 unreleased 残留、同步 Profile scripts 资产清单,并增强 validate 对 release/profile/audit-state 漂移的防回归检查。

‎mcp/memory-server.js‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,26 @@ function summaryFilePath(agent, args = {}) {
244244
)
245245
}
246246

247+
function summaryProjectLabel(args = {}) {
248+
if (!LAYOUT.enabled) return path.basename(resolveProjectRoot(args.project)) || 'project'
249+
const explicitScope = Object.prototype.hasOwnProperty.call(args, 'scope') && String(args.scope || '').trim()
250+
const projectName = resolveProjectName(args.project)
251+
const scope = explicitScope ? resolveScope(args.scope) : (projectName ? 'project' : DEFAULT_SCOPE)
252+
if (scope === 'workspace') return 'workspace'
253+
return projectName || CONTEXT_PROJECT || 'project'
254+
}
255+
256+
function summaryHeader(agent, args = {}) {
257+
return [
258+
`# Agent SUMMARY — ${agent || DEFAULT_AGENT}`,
259+
'',
260+
`> 项目:${summaryProjectLabel(args)}`,
261+
'',
262+
'| 日期 | 会话 | 类型 | 摘要 | 关联报告 | 关联记忆 | 状态 |',
263+
'|------|:----:|------|------|---------|---------|:----:|'
264+
].join('\n') + '\n'
265+
}
266+
247267
function taskSessionsPath(kind, requirement, args = {}) {
248268
return path.join(
249269
getActiveRoot(args), kind,
@@ -329,9 +349,8 @@ function handleMemorySummaryAppend(args) {
329349
const existing = readFile(p)
330350

331351
if (!existing) {
332-
const header = '| 日期 | 会话 | 类型 | 摘要 | 关联报告 | 关联记忆 | 状态 |\n|------|------|------|------|---------|---------|------|\n'
333352
fs.mkdirSync(path.dirname(p), { recursive: true })
334-
fs.writeFileSync(p, header + args.row + '\n', 'utf8')
353+
fs.writeFileSync(p, summaryHeader(args.agent || DEFAULT_AGENT, args) + args.row + '\n', 'utf8')
335354
} else {
336355
appendFile(p, args.row + '\n')
337356
}

‎scripts/test-mcp-servers.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ function testMemoryDefaultAgent() {
181181
assert.ok(fs.existsSync(path.join(
182182
TEMP_ROOT, '.devcodex', '.memory', 'clients', 'claude-code', 'SUMMARY.md'
183183
)))
184+
const summaryPath = path.join(TEMP_ROOT, '.devcodex', '.memory', 'clients', 'claude-code', 'SUMMARY.md')
185+
const summary = fs.readFileSync(summaryPath, 'utf8')
186+
assert.ok(summary.includes('# Agent SUMMARY — claude-code'))
187+
assert.ok(summary.includes('> 项目:'))
188+
assert.ok(summary.includes('|------|:----:|------|------|---------|---------|:----:|'))
184189
assert.ok(!fs.existsSync(path.join(TEMP_ROOT, '.devcodex', '.memory', 'clients', 'claude')))
185190
}
186191

@@ -292,6 +297,12 @@ function testWorkspaceNamespaceMemoryScope() {
292297
assert.ok(fs.existsSync(path.join(
293298
TEMP_ROOT, '.devcodex', 'workspace', '.memory', 'clients', 'claude-code', 'SUMMARY.md'
294299
)))
300+
const workspaceSummary = fs.readFileSync(path.join(
301+
TEMP_ROOT, '.devcodex', 'workspace', '.memory', 'clients', 'claude-code', 'SUMMARY.md'
302+
), 'utf8')
303+
assert.ok(workspaceSummary.includes('# Agent SUMMARY — claude-code'))
304+
assert.ok(workspaceSummary.includes('> 项目:workspace'))
305+
assert.ok(workspaceSummary.includes('|------|:----:|------|------|---------|---------|:----:|'))
295306
}
296307

297308
function testWorkspaceRootMemoryScopeRequiresExplicitTarget() {

‎scripts/validate.js‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,16 @@ function checkV15() {
969969
violations++
970970
}
971971
}
972+
973+
if (state.state === 'paused') {
974+
const unresolved = Array.isArray(state.findings)
975+
? state.findings.filter(finding => unresolvedFindingStates.has(String(finding.status || '').toLowerCase()))
976+
: []
977+
if (unresolved.length && (!state.linkedReport || !state.lastCheckpoint || !state.lastCheckpoint.reason)) {
978+
warn(`[V15] paused audit-state with unresolved findings must include linkedReport and lastCheckpoint.reason: .devcodex/.audit-state/${sf}`)
979+
violations++
980+
}
981+
}
972982
}
973983

974984
console.log(`[V15] audit-state consistency checked: ${stateFiles.length} files, ${violations} violation(s)`)
@@ -1060,12 +1070,15 @@ function checkV18() {
10601070
function checkV19() {
10611071
const promptCount = walk(path.join(ROOT, 'prompts')).filter(f => f.endsWith('.prompt.md')).length
10621072
const dataTemplateCount = walk(path.join(ROOT, 'data', 'templates')).filter(f => f.endsWith('.md')).length
1073+
const scriptCount = walk(path.join(ROOT, 'scripts')).filter(f => f.endsWith('.js')).length
10631074
const checks = [
10641075
{ file: 'README.md', needle: `Prompt 模板(${promptCount} 个)` },
10651076
{ file: activePath('profile', '01-项目信息.md'), needle: `| **Prompt** | ${promptCount} |`, rawPath: false },
10661077
{ file: activePath('profile', '01-项目信息.md'), needle: `prompts ${promptCount}`, rawPath: false },
10671078
{ file: activePath('profile', '02-架构约束.md'), needle: `Prompt 模板文件(.prompt.md,中文)${promptCount} 个`, rawPath: false },
1068-
{ file: activePath('profile', '01-项目信息.md'), needle: `| **data 模板** | ${dataTemplateCount} |`, rawPath: false }
1079+
{ file: activePath('profile', '01-项目信息.md'), needle: `| **data 模板** | ${dataTemplateCount} |`, rawPath: false },
1080+
{ file: activePath('profile', '01-项目信息.md'), needle: `| **CLI 工程脚本** | ${scriptCount} |`, rawPath: false },
1081+
{ file: activePath('profile', '01-项目信息.md'), needle: 'scripts/check-syntax.js', rawPath: false }
10691082
]
10701083
for (const check of checks) {
10711084
const filePath = check.rawPath === false ? check.file : path.join(ROOT, check.file)
@@ -1078,7 +1091,7 @@ function checkV19() {
10781091
err(`[V19] asset count drift in ${check.rawPath === false ? path.relative(ROOT, check.file) : check.file}: expected text "${check.needle}"`)
10791092
}
10801093
}
1081-
console.log(`[V19] asset counts checked: prompts=${promptCount}, data-templates=${dataTemplateCount}`)
1094+
console.log(`[V19] asset counts checked: prompts=${promptCount}, data-templates=${dataTemplateCount}, scripts=${scriptCount}`)
10821095
}
10831096

10841097
function checkV20() {
@@ -1130,6 +1143,14 @@ function checkV20() {
11301143
}
11311144
}
11321145
}
1146+
const unreleased = read(path.join(ROOT, 'changelogs', 'unreleased.md'))
1147+
if (unreleased.includes('暂无未发布变更')) {
1148+
const dateHeadings = [...unreleased.matchAll(/^## \d{4}-\d{2}-\d{2}/gm)]
1149+
const contentAfterEmptyMarker = unreleased.split('暂无未发布变更').slice(1).join('暂无未发布变更')
1150+
if (dateHeadings.length > 1 || /^## \d{4}-\d{2}-\d{2}/m.test(contentAfterEmptyMarker)) {
1151+
err('[V20] changelogs/unreleased.md mixes empty-template marker with archived date sections')
1152+
}
1153+
}
11331154
console.log('[V20] release/changelog dual-track semantics checked')
11341155
}
11351156

0 commit comments

Comments
 (0)