Skip to content

feat(governance): add classified governance migration transaction - #32

Closed
Kucell wants to merge 12 commits into
mainfrom
feat/rdg-ms008-governance-migration
Closed

Kucell wants to merge 12 commits into
mainfrom
feat/rdg-ms008-governance-migration

Conversation

@Kucell

@Kucell Kucell commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Superseded by a convergence PR based on current main. Main independently landed overlapping MS-008 foundations while this branch was in progress; closing to avoid duplicate history and preserve only the delta (classification correction + rollback/resume hardening).

@Kucell Kucell closed this Oct 6, 2026
@Kucell
Kucell deleted the feat/rdg-ms008-governance-migration branch October 22, 2026 06:54
Kucell added a commit that referenced this pull request Oct 29, 2026
* chore(v116): assemble reviewed source candidates for release integration

* fix(evolution): ship dry-run preservation in both language templates

* fix(advisor): require exact scope and observed Host admission evidence

* feat(advisor): read canonical task snapshots and prepare bounded reasoning proposals

* fix(update): fail closed on scan errors and preserve migration ownership

* fix(governance): validate serializer audit labels without granting authority

* fix(update): report runtime scan errors as failed verification

* fix(checkout): describe the existing governance gitlink

* feat(evolution): queue bounded archive proposals with offline preservation checks

* test(release): verify exact candidate tar and isolated installed CLI

* test(runtime): add fail-closed strict fixture components and isolated review CI

* test(runtime): restore lstat mock before Node 22 fixture cleanup

* fix(packaging): resolve plugin components from shipped template paths

* fix(l3-fixture): recheck synchronous admission before IPC sends

Default-off cooperative fixture only; preserve recorded effects on acknowledgement denial. Add mock regressions. Review snapshot; new tests NOT_RUN.

* test(l3-fixture): prepare exact-input bounded Tier I canary

Run only on a single-commit canary change with current-head source identity matching the fixed reviewed closure. Isolated Node24, synthetic authority only, explicit UNKNOWN failure. Review snapshot; NOT_RUN.

* test(release): isolate exact-head CLI regression validation

Import four reviewed blobs from 4984916. Run only the nine reviewed CLI cases in disposable credential-free snapshots; preserve publication identity and live-main gates unchanged. No publish invoked.

* feat(advisor): expose bound readonly query with focused offline CI

* test(advisor): isolate fixed fixture faults from query write guard

* test(release): verify fixed registry baseline identity bytes

* feat(advisor): observe canonical plan and paired approval records read-only

Integrate exact nine-file candidate 03b54b4; retain task blob, Mission contract, and plan resource identity at one observed Git revision. Add only the reviewed 33-input offline query CI closure with 84 expected cases on Node 18, 22, and 24. No authority grant or Host execution.

* test(dispatch): isolate actual Phase 0 bin boundary without changing execution

* feat(governance): integrate bounded local Git atomic batch storage

Import the final independently reviewed three-file candidate 93f2473 with pre-encoding bounds and owner/mode checks. Add readonly exact-head two-input Node22/24 CI for 47 synthetic storage cases plus one test container. No production authority, existing governance writes, remote synchronization, or Host enablement.

* test(dispatch): include eager state registry resource in isolated bin source

* test(release): exercise pinned registry baseline upgrade with preservation evidence

* fix(templates): preserve executable modes and assert registry upgrade compatibility

* chore(release): prepare unreleased 1.16.0 candidate and correct capability claims

* feat(runtime): add inert S1 authority interfaces and fail-closed ordering regressions

* test(runtime): keep ordering fixtures inside Node permission boundary

* test(runtime): seed in-memory lease for authorization ordering fixture

* feat(governance): prepare inactive canonical controller and bounded offline CI

* fix(governance): disable reverse indexes for bounded Git pack imports

* test(release): align candidate checks with preserved governance gitlink

Update only the three exact candidate gitlink expectations to merged main pin 7b17677b1646cdbf54e29bf44cb9a11100c90d34. Preserve equality checks, published 1.15.4 baseline identity, permissions and validation commands. No governance checkout, Host execution or publication.

* test(release): pin reconciled management helpers for upgrade acceptance

* feat(runtime): add inert admission and strict-entry transaction prototype

* feat(runtime): prepare inactive Linux file-sink milestone

* test(release): align strict candidate checks with preserved governance pin

Update two exact expected-gitlink constants to e75626fb201e6bb8a25b6f86d59b4154c9100bdb after PR81 preservation. Keep all identity assertions, execution boundaries, historical registry-upgrade pins and inactive capability workflow unchanged.

* test(feedback): verify fixed offline suites on hosted Node 22 and 24

Add the reviewed 45-test feedback job to the existing read-only canonical workflow while preserving its original 50-test job. Pin source closure and child commands; verify network tripwires, receipts, source integrity and cleanup. This ordinary synthetic test environment permits genuine fsync and is not Host sandbox or formal release acceptance.

* ci(linux): 启用已批准的单次隔离能力探测

固定源码 0098505,仅允许首次运行与首次尝试。
在只读权限的临时 Ubuntu 上探测,不安装、不提权、不使用密钥或模型。
保留失败即停止的运行时门槛,不自动重试。
本次不代表文件落盘、真实宿主或正式发布验收通过。

* fix(release): 收敛 1.16.0 建议型范围并修正升级模板选择

更新发布范围和 review-only 证据辅助器说明,版本保持 1.16.0,明确尚未发布。
升级按语言模板优先、shared 补缺、相对路径去重,保留已有文件;Darwin Git 子进程固定 TMPDIR=/tmp,不继承调用者值。
Inner mirror: 9ec504c66ba10551ac714fcb140545148a3a9d37。
验证:260/260、Phase-0 22/22、parity 3/3、边界及打包检查通过;SamHMI dry-run 退出 0,无观测到的写入。
保持现有执行权限边界,不启用 Host、Linux 探测或实际升级用户项目。本提交不代表已发布。

* chore(agent): 对齐包含治理主线增量的 1.16.0 候选指针

仅将 .agent 从 9ec504c66ba10551ac714fcb140545148a3a9d37 更新为上述新治理提交 184694dc8fdba873a2846cbec2ffd23518d830ff。
Inner mirror: 184694dc8fdba873a2846cbec2ffd23518d830ff。
保留原候选和治理主线增量,消除子模块历史分叉;不改产品源码、版本或执行权限,不实际升级用户项目、不发布。

* fix(ci): 对齐建议型候选校验并补齐升级测试隔离

将 bound-query 的精确测试计数从 84 更新为 85,保留零失败、零跳过检查。
在现有显式依赖边界内加载真实 report 构建器,阻止延迟 verify 导入逃逸,保持 CI 的最小 13 文件闭包及升级预演、执行计划、幂等和定制保护回归。
将打包及 CLI 校验严格绑定治理提交 184694dc8fdba873a2846cbec2ffd23518d830ff。
独立复审最终 feedback 源码闭包后,将审核基线绑定至 9a98b41 及其精确树;保留全部逐文件模式、哈希和执行边界校验。
Inner mirror: 184694dc8fdba873a2846cbec2ffd23518d830ff。
不改产品运行代码、版本或执行权限,不启用 Host 或探测,不代表已发布。

* fix(ci): 严格验证治理 PIN 并修复测试隔离门禁

fetch main 仅用于获取对象,必须成功检出产品 gitlink 指定的治理提交。
在测试前再次断言治理 HEAD 等于 PIN,保留 pnpm test:ci 与现有权限。
同步三个独立知识检查模板的 markdown-it 内嵌实现、MIT 许可和一致性回归。
修正 strictHermetic 拼写,增加真实非 curated 写入负对照。
在性能断言失败时关闭资源并清理临时目录,保持全部性能阈值。

Inner mirror: 8ff035cea8446759fdc321dedb7ed48384a45881.

* test(mcp): 隔离安装后端回归的目录缓存

为真实 CLI 子进程提供临时空目录缓存,避免冷缓存时联网并写入用户 home。
将未知 ID 的结果断言收紧为 rejected,验证缓存内容及临时目录不变。
测试结束恢复原环境变量并清理夹具,不修改生产逻辑或 strict-hermetic 门禁。

* fix(ci): 同步离线闭包身份并补足许可并发失败诊断

将 Runtime Owner 的 manifest 与物化闭包数量同步为已审核源码的 259 和 267。
将 feedback 审查来源固定为 c5eae77 及其真实 tree。
同步 feedback 的 259 项 manifest、254 个 JS、266 个物化文件和 271 次 API 请求计数。
保留逐文件 mode/blob、实际加载数量、45 项测试、子进程计数、seccomp 和源码不变检查。
为许可并发测试输出失败子进程的实际错误码及 open/reserve 阶段,不改变成功断言或生产逻辑。
本提交不宣称许可跨存储提交窗口已修复,也不新增 M-044 实施、身份、ACL、Host 或部署权限。

Inner mirror: d7edc4ed8571815d95c032e50b74fdd562a96acf.

* fix(coordination): 引入受保护存储的跨域协调锁 (M-044/MS-004)

业务库提交与它��外部见证必须共享一个稳定的锁域。SQLite 在进程死亡时
会释放这个锁,因此它绝不能通过 unlink 来"清理"竞争。

- 新增 protected-store-lock.js:以 SQLite 的 BEGIN IMMEDIATE 承载锁域,
  身份由目录与锁文件的 dev+ino 构成,锁域被替换时以 expectedIdentity 拒绝
- 锁文件的权限、硬链接数与属主逐项校验,任何一项不符都 fail-closed
- 路径未被重定向的判定改为「锚点以下不得有符号链接分量」:macOS 的
  /var -> /private/var 是平台自身的别名,原先 realpathSync(dir) !== dir
  的比较会把每个建在临时目录下的合法锚点都误判为攻击。平台命名空间
  以下的分量才受检查,这与 protected-anchor.js 的 anchorDirFor 采用同一
  套语义,两处对「合法锚点是什么」的判断不再冲突。锁域被替换仍然由
  dev+ino 身份比对捕获
- 测试夹具把临时根目录规范化为 canonical 路径,否则 macOS 上同一路径
  存在两种拼写,测试比较的是未经解析的拼写而实现用的是解析后的拼写

* fix(test): 同步 phase-zero 源码闭包计数至 260

main 的 PR #133 引入 lib/template-layers.js,被 lib/setup/index.js 依赖,
属于 phase-zero 审阅闭包的新增成员。manifest 的 sources 由 259 增至 260,
其中 .js 子集由 254 增至 255。

同步更新硬编码计数的四处断言:

- tests/helpers/phase-zero-source.js
- tests/dispatch/phase-zero-source-proof.test.js
- .github/workflows/phase-zero-bin-boundary.yml
- .github/workflows/runtime-owner-s1.yml
- .github/workflows/canonical-control-offline.yml

protected_source_blobs 的 bin/cli.js 与 lib/dispatch/execute.js 指纹复核未变。

* fix(knowledge-lint): 修正活跃任务 fallback 解析并补齐三处缺失的回归覆盖

回退解析有两个缺陷:分节正则的终止条件用 `$`,在 multiline 下匹配行尾
而非真正 EOF,导致视图末尾的活跃任务段落被截断、统计恒为 0;表格分隔行
过滤只认 `|:---|`,`| --- |` 被当作数据行计入。修正后同步分发层
templates/_shared 的同一实现,保持 L1/L3 内容对等。

同时从 1.16 候选的中间态 worktree 回收三处有效但未进入主线的回归覆盖:

- templates/_shared/.../agent-review-benchmark/scripts/render-pr-comment.test.js
  评审评论渲染器的回归:不得凭空发明内容、不得丢条、必须确定性
- tests/memory/knowledge-task-fallback.test.js
  未迁移项目的活跃任务回退统计
- tests/management/task-state-public-gates.test.js
  公开任务视图的漂移检测与重复活跃段门禁

三个用例均按 _shared 模板分层定位实现,不再按语言层各存一份。

* feat(migration): 并入离线迁移只读检视(阶段 1)

`cortex-agent migration inspect|plan --project <root>` 只读检视范围内的
治理数据格式,输出 JSON。不备份、不改写、不恢复、不切换、不激活任何
数据;`upgrade` 行为不变。

- 只读清点:相对路径、文件模式与哈希,不输出记录正文
- 确定性计划:绑定清单摘要,含可执行操作的计划一律不产生
- 未解析即未解析:未知标记、记录、字段与引用保持 unresolved,绝不推断
- 安全读取器需要 Linux /proc/self/fd,以保留目录句柄并拒绝符号链接、
  硬链接与路径替换攻击;其他平台返回 MIGRATION_SAFE_READER_UNSUPPORTED,
  不提供不安全回退
- 固定路径的 schema 与样例必须与发布的字节一致;索引单独校验并交叉核对
- 迁移资格、静止性与可执行性一律为 false;两次一致的扫描只是漂移检测,
  不构成写入者已停止的证据

架构 P-001 (88556bac) 与 P-002 (ab037f05) 均已获批并通过独立评审,
评审结论为 PASS 且无遗留合同级 MustFix。

phase-zero 源码闭包随之扩充:迁移实现 5 个文件与 5 份发布自有 schema
进入闭包,计数由 260 增至 270;bin/cli.js 的 protected 指纹随只读
migration 路由同步更新并在 manifest notes 中留痕。

* chore(governance): 治理仓 gitlink 指向 1.16 合并成果 e470fca1

治理仓 main 快进到 e470fca1(合并 1.16 候选治理线与主线 L1/L3 对等修复)。
外层仓库的 .agent gitlink 随之指向该提交。

治理仓工作区仍保留其他会话的 442 项未提交改动,未纳入本次提交。

* chore(governance): 治理仓 gitlink 同步 knowledge-lint EOF 修复

* chore(governance): 同步治理仓上游框架通用性规则合并 (#32)

* fix(ci): 同步模板分层路径与离线闭包基线至 1.16 候选

模板分层后 en/zh 不再持有 management-api 与 evolution-pipeline 脚本,
isolation 与 preservation 门禁改为只引用 _shared 真实路径。
治理仓 gitlink 期望值同步到已推送的 180e71b5。

canonical-control-offline 的 feedback 闭包基线由 c5eae77 重指到已推送的
c42ce5a,同步物化计数 266->277、API 请求 271->282、加载源 231->232;
基线重指已用旧基线反向验证测量方法(231 精确命中既有断言)。

本提交不改动生产逻辑,不放宽任何断言,不新增依赖。

* fix(ci): 修正模板分层后的离线验收路径假设

模板分层后 evolve.js 只存在于 _shared,语言覆盖层不再各自携带副本。
offline-package 验收改为断言 _shared 存在且 en/zh 不重新引入该副本,
把原先的三份同 blob 不变量收紧为更强的单一副本不变量;
self-check 缺席检查补齐 _base 层。

feedback 闭包的 .agent 路径守卫原先只放行 templates/_shared/.agent,
无法容纳 _base 层的模板内容。改为只放行 templates/<层>/.agent/,
仓库根 .agent 治理目录仍被排除,边界不放宽。

* fix(distribution): 修正 plugin 清单指向已迁移的共享层子代理

模板分层把 session-manager.md 迁到 _shared 后,plugin.json 的 agents 声明
仍指向已不存在的 zh 路径,离线打包验收因此失败。改为指向共享层真实路径。

本提交只修分发清单路径,不改子代理内容。

* fix(ci): 分离 evolve 共享层路径与覆盖层路径的验收语义

required 清单只要求共享层 evolve.js 存在;覆盖层不引入副本由独立断言保证。
此前把两者混用同一列表,导致要求三层都存在。

* fix(ci): 发布基线验收的可执行模板路径改按共享层解析

模板分层后 evolve.js 与 management-api/index.js 只存在于 _shared,
三层路径清单会要求已被分层移除的文件。改为只列共享层真实路径。

历史发布版本的 helper blob 指纹保持不动,那是已发布 tar 的独立证据。

* fix(ci): 修正 evolve 路径重命名后的残留引用

evolve_paths 拆分为 evolve_path 与 evolve_overlays 后,装载点仍引用旧名,
运行时 NameError。改为引用共享层真实路径。

* fix(ci): 受管脚本当前字节按模板分层优先级解析

模板分层后 evolve.js 只存在于 _shared,语言覆盖层不再携带副本。
fixture 断言改为按分层优先级(覆盖层优先,共享层兜底)解析目标文件,
与安装器实际解析规则一致。

---------

Co-authored-by: cortex-agent <cortex-agent@local>
Kucell added a commit that referenced this pull request Nov 2, 2026
* chore(v116): assemble reviewed source candidates for release integration

* fix(evolution): ship dry-run preservation in both language templates

* fix(advisor): require exact scope and observed Host admission evidence

* feat(advisor): read canonical task snapshots and prepare bounded reasoning proposals

* fix(update): fail closed on scan errors and preserve migration ownership

* fix(governance): validate serializer audit labels without granting authority

* fix(update): report runtime scan errors as failed verification

* fix(checkout): describe the existing governance gitlink

* feat(evolution): queue bounded archive proposals with offline preservation checks

* test(release): verify exact candidate tar and isolated installed CLI

* test(runtime): add fail-closed strict fixture components and isolated review CI

* test(runtime): restore lstat mock before Node 22 fixture cleanup

* fix(packaging): resolve plugin components from shipped template paths

* fix(l3-fixture): recheck synchronous admission before IPC sends

Default-off cooperative fixture only; preserve recorded effects on acknowledgement denial. Add mock regressions. Review snapshot; new tests NOT_RUN.

* test(l3-fixture): prepare exact-input bounded Tier I canary

Run only on a single-commit canary change with current-head source identity matching the fixed reviewed closure. Isolated Node24, synthetic authority only, explicit UNKNOWN failure. Review snapshot; NOT_RUN.

* test(release): isolate exact-head CLI regression validation

Import four reviewed blobs from 4984916. Run only the nine reviewed CLI cases in disposable credential-free snapshots; preserve publication identity and live-main gates unchanged. No publish invoked.

* feat(advisor): expose bound readonly query with focused offline CI

* test(advisor): isolate fixed fixture faults from query write guard

* test(release): verify fixed registry baseline identity bytes

* feat(advisor): observe canonical plan and paired approval records read-only

Integrate exact nine-file candidate 03b54b4; retain task blob, Mission contract, and plan resource identity at one observed Git revision. Add only the reviewed 33-input offline query CI closure with 84 expected cases on Node 18, 22, and 24. No authority grant or Host execution.

* test(dispatch): isolate actual Phase 0 bin boundary without changing execution

* feat(governance): integrate bounded local Git atomic batch storage

Import the final independently reviewed three-file candidate 93f2473 with pre-encoding bounds and owner/mode checks. Add readonly exact-head two-input Node22/24 CI for 47 synthetic storage cases plus one test container. No production authority, existing governance writes, remote synchronization, or Host enablement.

* test(dispatch): include eager state registry resource in isolated bin source

* test(release): exercise pinned registry baseline upgrade with preservation evidence

* fix(templates): preserve executable modes and assert registry upgrade compatibility

* chore(release): prepare unreleased 1.16.0 candidate and correct capability claims

* feat(runtime): add inert S1 authority interfaces and fail-closed ordering regressions

* test(runtime): keep ordering fixtures inside Node permission boundary

* test(runtime): seed in-memory lease for authorization ordering fixture

* feat(governance): prepare inactive canonical controller and bounded offline CI

* fix(governance): disable reverse indexes for bounded Git pack imports

* test(release): align candidate checks with preserved governance gitlink

Update only the three exact candidate gitlink expectations to merged main pin 7b17677b1646cdbf54e29bf44cb9a11100c90d34. Preserve equality checks, published 1.15.4 baseline identity, permissions and validation commands. No governance checkout, Host execution or publication.

* test(release): pin reconciled management helpers for upgrade acceptance

* feat(runtime): add inert admission and strict-entry transaction prototype

* feat(runtime): prepare inactive Linux file-sink milestone

* test(release): align strict candidate checks with preserved governance pin

Update two exact expected-gitlink constants to e75626fb201e6bb8a25b6f86d59b4154c9100bdb after PR81 preservation. Keep all identity assertions, execution boundaries, historical registry-upgrade pins and inactive capability workflow unchanged.

* test(feedback): verify fixed offline suites on hosted Node 22 and 24

Add the reviewed 45-test feedback job to the existing read-only canonical workflow while preserving its original 50-test job. Pin source closure and child commands; verify network tripwires, receipts, source integrity and cleanup. This ordinary synthetic test environment permits genuine fsync and is not Host sandbox or formal release acceptance.

* ci(linux): 启用已批准的单次隔离能力探测

固定源码 0098505,仅允许首次运行与首次尝试。
在只读权限的临时 Ubuntu 上探测,不安装、不提权、不使用密钥或模型。
保留失败即停止的运行时门槛,不自动重试。
本次不代表文件落盘、真实宿主或正式发布验收通过。

* fix(release): 收敛 1.16.0 建议型范围并修正升级模板选择

更新发布范围和 review-only 证据辅助器说明,版本保持 1.16.0,明确尚未发布。
升级按语言模板优先、shared 补缺、相对路径去重,保留已有文件;Darwin Git 子进程固定 TMPDIR=/tmp,不继承调用者值。
Inner mirror: 9ec504c66ba10551ac714fcb140545148a3a9d37。
验证:260/260、Phase-0 22/22、parity 3/3、边界及打包检查通过;SamHMI dry-run 退出 0,无观测到的写入。
保持现有执行权限边界,不启用 Host、Linux 探测或实际升级用户项目。本提交不代表已发布。

* chore(agent): 对齐包含治理主线增量的 1.16.0 候选指针

仅将 .agent 从 9ec504c66ba10551ac714fcb140545148a3a9d37 更新为上述新治理提交 184694dc8fdba873a2846cbec2ffd23518d830ff。
Inner mirror: 184694dc8fdba873a2846cbec2ffd23518d830ff。
保留原候选和治理主线增量,消除子模块历史分叉;不改产品源码、版本或执行权限,不实际升级用户项目、不发布。

* fix(ci): 对齐建议型候选校验并补齐升级测试隔离

将 bound-query 的精确测试计数从 84 更新为 85,保留零失败、零跳过检查。
在现有显式依赖边界内加载真实 report 构建器,阻止延迟 verify 导入逃逸,保持 CI 的最小 13 文件闭包及升级预演、执行计划、幂等和定制保护回归。
将打包及 CLI 校验严格绑定治理提交 184694dc8fdba873a2846cbec2ffd23518d830ff。
独立复审最终 feedback 源码闭包后,将审核基线绑定至 9a98b41 及其精确树;保留全部逐文件模式、哈希和执行边界校验。
Inner mirror: 184694dc8fdba873a2846cbec2ffd23518d830ff。
不改产品运行代码、版本或执行权限,不启用 Host 或探测,不代表已发布。

* fix(ci): 严格验证治理 PIN 并修复测试隔离门禁

fetch main 仅用于获取对象,必须成功检出产品 gitlink 指定的治理提交。
在测试前再次断言治理 HEAD 等于 PIN,保留 pnpm test:ci 与现有权限。
同步三个独立知识检查模板的 markdown-it 内嵌实现、MIT 许可和一致性回归。
修正 strictHermetic 拼写,增加真实非 curated 写入负对照。
在性能断言失败时关闭资源并清理临时目录,保持全部性能阈值。

Inner mirror: 8ff035cea8446759fdc321dedb7ed48384a45881.

* test(mcp): 隔离安装后端回归的目录缓存

为真实 CLI 子进程提供临时空目录缓存,避免冷缓存时联网并写入用户 home。
将未知 ID 的结果断言收紧为 rejected,验证缓存内容及临时目录不变。
测试结束恢复原环境变量并清理夹具,不修改生产逻辑或 strict-hermetic 门禁。

* fix(ci): 同步离线闭包身份并补足许可并发失败诊断

将 Runtime Owner 的 manifest 与物化闭包数量同步为已审核源码的 259 和 267。
将 feedback 审查来源固定为 c5eae77 及其真实 tree。
同步 feedback 的 259 项 manifest、254 个 JS、266 个物化文件和 271 次 API 请求计数。
保留逐文件 mode/blob、实际加载数量、45 项测试、子进程计数、seccomp 和源码不变检查。
为许可并发测试输出失败子进程的实际错误码及 open/reserve 阶段,不改变成功断言或生产逻辑。
本提交不宣称许可跨存储提交窗口已修复,也不新增 M-044 实施、身份、ACL、Host 或部署权限。

Inner mirror: d7edc4ed8571815d95c032e50b74fdd562a96acf.

* fix(coordination): 引入受保护存储的跨域协调锁 (M-044/MS-004)

业务库提交与它��外部见证必须共享一个稳定的锁域。SQLite 在进程死亡时
会释放这个锁,因此它绝不能通过 unlink 来"清理"竞争。

- 新增 protected-store-lock.js:以 SQLite 的 BEGIN IMMEDIATE 承载锁域,
  身份由目录与锁文件的 dev+ino 构成,锁域被替换时以 expectedIdentity 拒绝
- 锁文件的权限、硬链接数与属主逐项校验,任何一项不符都 fail-closed
- 路径未被重定向的判定改为「锚点以下不得有符号链接分量」:macOS 的
  /var -> /private/var 是平台自身的别名,原先 realpathSync(dir) !== dir
  的比较会把每个建在临时目录下的合法锚点都误判为攻击。平台命名空间
  以下的分量才受检查,这与 protected-anchor.js 的 anchorDirFor 采用同一
  套语义,两处对「合法锚点是什么」的判断不再冲突。锁域被替换仍然由
  dev+ino 身份比对捕获
- 测试夹具把临时根目录规范化为 canonical 路径,否则 macOS 上同一路径
  存在两种拼写,测试比较的是未经解析的拼写而实现用的是解析后的拼写

* fix(test): 同步 phase-zero 源码闭包计数至 260

main 的 PR #133 引入 lib/template-layers.js,被 lib/setup/index.js 依赖,
属于 phase-zero 审阅闭包的新增成员。manifest 的 sources 由 259 增至 260,
其中 .js 子集由 254 增至 255。

同步更新硬编码计数的四处断言:

- tests/helpers/phase-zero-source.js
- tests/dispatch/phase-zero-source-proof.test.js
- .github/workflows/phase-zero-bin-boundary.yml
- .github/workflows/runtime-owner-s1.yml
- .github/workflows/canonical-control-offline.yml

protected_source_blobs 的 bin/cli.js 与 lib/dispatch/execute.js 指纹复核未变。

* fix(knowledge-lint): 修正活跃任务 fallback 解析并补齐三处缺失的回归覆盖

回退解析有两个缺陷:分节正则的终止条件用 `$`,在 multiline 下匹配行尾
而非真正 EOF,导致视图末尾的活跃任务段落被截断、统计恒为 0;表格分隔行
过滤只认 `|:---|`,`| --- |` 被当作数据行计入。修正后同步分发层
templates/_shared 的同一实现,保持 L1/L3 内容对等。

同时从 1.16 候选的中间态 worktree 回收三处有效但未进入主线的回归覆盖:

- templates/_shared/.../agent-review-benchmark/scripts/render-pr-comment.test.js
  评审评论渲染器的回归:不得凭空发明内容、不得丢条、必须确定性
- tests/memory/knowledge-task-fallback.test.js
  未迁移项目的活跃任务回退统计
- tests/management/task-state-public-gates.test.js
  公开任务视图的漂移检测与重复活跃段门禁

三个用例均按 _shared 模板分层定位实现,不再按语言层各存一份。

* feat(migration): 并入离线迁移只读检视(阶段 1)

`cortex-agent migration inspect|plan --project <root>` 只读检视范围内的
治理数据格式,输出 JSON。不备份、不改写、不恢复、不切换、不激活任何
数据;`upgrade` 行为不变。

- 只读清点:相对路径、文件模式与哈希,不输出记录正文
- 确定性计划:绑定清单摘要,含可执行操作的计划一律不产生
- 未解析即未解析:未知标记、记录、字段与引用保持 unresolved,绝不推断
- 安全读取器需要 Linux /proc/self/fd,以保留目录句柄并拒绝符号链接、
  硬链接与路径替换攻击;其他平台返回 MIGRATION_SAFE_READER_UNSUPPORTED,
  不提供不安全回退
- 固定路径的 schema 与样例必须与发布的字节一致;索引单独校验并交叉核对
- 迁移资格、静止性与可执行性一律为 false;两次一致的扫描只是漂移检测,
  不构成写入者已停止的证据

架构 P-001 (88556bac) 与 P-002 (ab037f05) 均已获批并通过独立评审,
评审结论为 PASS 且无遗留合同级 MustFix。

phase-zero 源码闭包随之扩充:迁移实现 5 个文件与 5 份发布自有 schema
进入闭包,计数由 260 增至 270;bin/cli.js 的 protected 指纹随只读
migration 路由同步更新并在 manifest notes 中留痕。

* chore(governance): 治理仓 gitlink 指向 1.16 合并成果 e470fca1

治理仓 main 快进到 e470fca1(合并 1.16 候选治理线与主线 L1/L3 对等修复)。
外层仓库的 .agent gitlink 随之指向该提交。

治理仓工作区仍保留其他会话的 442 项未提交改动,未纳入本次提交。

* chore(governance): 治理仓 gitlink 同步 knowledge-lint EOF 修复

* chore(governance): 同步治理仓上游框架通用性规则合并 (#32)

* feat(coordination): 增加跨机许可的受管 CLI 入口

跨机许可的库能力此前已在 origin/main(批次签发与验签、登记型锚点域、
跨机登记与取钥路径),但没有可调用的受管入口:bin/cli.js 里没有任何
permit 派发,引用这些模块的文件只有模块自身,零调用方。既有真机实测
走的是直接 require 产品模块的探针,不是产品 CLI。

本次补上产品入口与它依赖的编排层:

- lib/commands/permit-managed-cli.js:薄适配层,五个子命令
  issue/register/key/verify/revoke,零判定逻辑;直接调用被拒绝,
  必须在已认证的受管会话内经 executor 通道执行。
- lib/coordination/permit-authority-service.js:受保护服务侧的批次密钥
  持有与签发,私钥不落盘、不进参数、不进环境变量、不传给子进程。
- lib/coordination/permit-target-service.js:目标侧事实取自 pin 域,
  不接受命令行断言作为已观测事实。
- lib/coordination/permit-revocation-signing.js:撤销列表以签名信封签发。
- lib/coordination/permit-batch-session.js、permit-managed-session.js:
  批次编排与受管会话接入。
- lib/governed/managed-caller-{session,supervisor}.js:应答方向绑定与
  事实来源 fail-closed 的补强。

安全约束(不可放宽):公钥只从 pin 域取;时钟中毒即拒;撤销强制;
deadline 必须从 reserve() 返回值读回而非自行推导;代码与命令不含任何
实战项目标识。

验证:全量 616 个测试文件跑完,8 项失败与 6 项超时经逐项甄别均非本次
引入——4 项为并行资源竞争(单独串行复跑全部通过),2 项在未改动的
origin/main 基线上同样失败(受保护事务存储限定 Linux 平台),2 项为磁盘
空间耗尽所致。专项串行通过:permit-authority-admission 99.4s、
permit-authority-signing-gate 39.2s、permit-witness-worker-isolation 5.0s、
permit-legacy-archive-evidence 77.7s、permit-phase-a-sqlite 18.3s。
门禁 check-framework-generality、check-l3-boundary、check-template-parity、
check-portable-paths 全部通过。

本批不含原生 witness 包、legacy 迁移与 SQLite 线——它们的真实 Windows
服务身份与证书/密钥 ACL 尚无实测验收证据,须另行评审后单独交付。
本批也不主张任何跨机许可断言在真实受保护部署上成立。

Refs M-044, MS-004

* fix(coordination): 补齐受管许可入口依赖的见证契约与锁域能力

第一批把跨机许可的受管入口交付到产品 CLI,但它的依赖闭包没有
完整入库,干净 checkout 下 CI 的 full-test 因此失败:

- lib/coordination/protected-permit-store.js 新增 34 处 witness 调用
  (canonicalBytes / deriveTransition / createCheckpoint /
  normalizeTargetState / assertCheckpointMatches / LIMITS),却引用了
  从未提交过的 lib/coordination/permit-witness-contract.js。
- lib/coordination/protected-pin-store.js 改为以格式 3 的域标记绑定
  固定 SQLite 锁 inode,调用 coordination.assertWindowsFilePermissions
  与 coordination.assertAnchorPathIsNotRedirected,但已提交的
  protected-store-lock.js 尚未导出这两个成员。
- protected-pin-store 的 open()/initialize() 语义已分离,配套测试仍
  以 open() 打开未初始化目录,并缺少三个 fixture
  (protected-pin-store-process.js、protected-pin-store-v1-source.txt、
  protected-pin-store-v2-source.txt)。

本次按已核对的字节内容补齐上述六个文件。它们与第二批交付清单
记录的 SHA-256 逐字节一致,不引入新的实现,只修复第一批的交付边界。

影响面:

- permit-witness-contract.js 仅依赖 node 内置模块,不触网、不读环境
  凭据、不做认证或授权判定;其头部自述为「候选状态契约与离线编解码,
  不是见证服务,也不是授权」。
- protected-store-lock.js 的两个新成员只做锚点路径与 Windows ACL 的
  可写性检查:祖先链遇符号链接即 fail-closed(原先是 break 继续),
  并按 Windows 原生适配器判定写者集合。
- 三个 fixture 是测试夹具(一个子进程夹具与两份 legacy 格式源码快照)。

安全约束(不可放宽):不新增任何跨机许可断言;不主张任何断言在真实
受保护部署上成立;第一批仍不含原生 witness 包、legacy 迁移与 SQLite
线——它们的真实 Windows 服务身份与证书/密钥 ACL 尚无实测验收证据,
须另行评审后单独交付。

验证:干净检出(8d8c1e12 + 本次六个文件)上,先前因缺模块失败的
八个测试文件全部通过——cross-machine-permit、permit-batch-session、
permit-delivery、permit-managed-flow、permit-revocation-signing、
permit-target-service、protected-permit-store、protected-pin-store。
全量 558 个测试文件跑完,554 通过、4 失败;四项均为
governance/github-control-store、governance/git-transaction-store、
runtime-port/strict-entry、runtime-state/runtime-admission,在未改动的
origin/main 基线上同样失败(createGitTransactionStore 限定 Linux 平台),
非本次引入,CI 的 ubuntu 运行时不受影响。

Refs M-044, MS-004

* ci(governance): 更新 feedback 复审闭包基线至独立复核通过的提交

独立复核者对 1b11a3f 裁定 PASS,
并给出确切的新基线值对:

  reviewed     = 1b11a3f
  baseline.sha = 2670520

tree SHA 由复核者独立执行 git rev-parse '1b11a3f5^{tree}' 得出;实施方
独立复算一致。

复核依据(见 .agent/missions/M-044/evidence/
ms004-batch1-closure-independent-review-r2-2026-11-01.md):

- 277 文件闭包相对旧复审基线 274 项字节一致、3 项不同,mode 差异 0;
  三项变化与上一轮冻结提交字节完全一致。
- 静态相对依赖扫描与 d1bfad4 对照未发现新增缺失;witness 模块已在提交树内,
  protected-permit-store.js 可独立加载。
- 两组指定测试分别 146/146 与 70/70 通过。
- 五个无受管会话子命令均退出 3,permit --help 退出 0,目录无变化。
- 六个补入文件的安全边界已复核。

本 workflow 文件不在 277 文件闭包内,更新这两处值不产生自引用。

Refs M-044, MS-004

* feat(coordination): 阶段 A 机器外见证权威、受保护事务与旧项目自动迁移

在 1.15.7 补丁线内交付阶段 A:受保护许可存储、跨机见证契约、受保护事务
的恢复路径,以及旧版 schema-1 存储到受保护结构的自动迁移。许可的授予、
消费与结算在跨进程互斥的协调域内完成,未开始的迁移注册只能凭可验证的
撤销证明显式退出。

关键修复:

- 协调库在 WAL 模式改取排他锁,锁落在稳定主库文件上直到原生 close;
  取得事务后复核模式,切入 WAL 以 ERR_COORDINATION_BUSY 拒绝。
- 撤销证明将审计外层身份与对象集合分开比较。审计外层(计划、库、撤销
  人、原因)必须完全一致;对象集合只允许新增经完整校验的撤销审计,
  因此先前的计划不会因历史增长而永久失效,也不会放过 by/reason 篡改。
- 协调库的 -wal/-shm/-journal 按精确文件名准入为锁域成员,其瞬时字节
  不进入历史证据,主库仍按身份绑定。
- 受保护锚点解析返回真实路径并在解析期间比对设备/inode;协调库附属
  文件在打开前与锁内均复核,外部硬链接目标不再被改写。

版本载体同步为 1.15.7(npm 上 1.15.7 从未发布,这是 1.15.x 补丁线的
下一个版本,不是降级)。

已知边界:外部见证服务未配置,生产准入保持关闭;WAL/排他锁尚未在真实
Windows 验证;真实断电持久性、设备写缓存与跨主机回滚未验证;此前中止的
SQLite schema 安全反例验收仍未完成。

已通过第十一轮独立只读复核(ACCEPT)。

* fix(test): 区分未改动的 1.15.7 与在其之上重建的 1.15.7 安装

旧版升级演练的 installed 引擎必须运行「未改动的 1.15.7」生产者:它产生
旧版的高水位压缩历史,再由候选版消费以验证升级路径。

安装 1.15.7 版本号但源码是在其之上重建的产物(阶段 A 就是这种情况),
并不是那个未改动的生产者,不能替代它。原实现把源码摘要不符当作硬失败,
于是任何重建过的 1.15.7 安装都会让整个套件失败,而不是退回到冻结的
生产者覆盖。

现在源码不是未改动构建时报 HIGHWATER_INSTALLED_NOT_LEGACY,可用性判定
把它当作「旧版生产者不可用」并跳过 installed 分支;版本号不是 1.15.7
仍然是硬失败,未改动的安装缺失也仍然是硬失败。冻结的生产者覆盖保持不变,
并且可以用 CORTEX_LEGACY_1157_ROOT 指向一个真实的旧 1.15.7 安装来恢复
installed 覆盖。

permit-legacy-archive-evidence 18 通过 0 失败 1 跳过,
permit-legacy-highwater-compaction 6 通过 0 失败 1 跳过,
permit-legacy-sqlite-rehearsal 39 通过 0 失败。

* chore(governance): 同步治理仓进度记录提交

* fix(governance): 对齐 .agent 指针与 upstream main 的 380bf119

合并 origin/main 时,子模块冲突被后续的 git add 以工作区 HEAD 覆盖,导致
提交里的 .agent 指针是 3e65a4a9 而非上游权威的 380bf119,触发 CI 的
governance gitlink drift 失败。此处把指针对齐到上游权威提交。

* chore(governance): 同步治理仓指针与发布验收的 gitlink 期望值

治理仓进度记录提交 bf4e2518 已推送(治理记录仓库按 vcs-pr-flow 规则 §5.1
允许直推 main)。主仓 gitlink 与两处发布验收 workflow 的 EXPECTED_GITLINK
同步到该提交,三者保持一致,避免 CI 的 governance gitlink drift 失败。

* fix(migration): 只读迁移检视纳入当前产品版本戳

1.15.7 补丁线写入的 .agent/.cortex-version 此前会被 offline-migration
的来源白名单判为 UNSUPPORTED_PRODUCT_PROVENANCE,导致新写戳的项目无法
通过只读迁移检视。白名单纳入当前产品版本,并新增以 package.json 版本
为输入的回归,避免以后版本再漂移。来源标记仍只作来源证据。

* ci(governance): 更新 feedback 复审闭包基线并对齐候选版本门禁

- feedback 闭包基线更新到第 13 轮独立复审裁定的值对:
  reviewed=62255f121c13d6cc09d98c34eb41f7ffe58f7fd2
  baseline.sha=b5e433a626b0edbca78bbb1e3f5b9401a9fff68f
  该值对下 277 项闭包 blob/type/mode 与 HEAD 精确一致。
- registry 升级验收的候选版本期望值随产品版本改为 1.15.7。
- 只读迁移检视文档补上 1.15.7 产品来源标记。

* fix(test): 修正 stage 发布夹具的双层嵌套路径

tests/commands/local-publish-validate-stage.test.js 通过 path.join(__dirname,
'fixtures/local-publish-validate-stage-child.cjs') 预加载子进程夹具,但夹具被放在
tests/commands/fixtures/fixtures/ 下,多了一层目录,CI 上子进程以
MODULE_NOT_FOUND 失败,导致 local-publish-validate-stage 与 Stage A 见证验证
两个作业整组失败。把夹具移回 tests/commands/fixtures/ 下,内容不变。

* fix(test): 测试产物移出工作副本并为慢文件声明显式预算

阶段 A 的新测试把仓库工作副本的 .agent/runtime/ 当产物根直接写,CI 的
strict-hermetic 门禁报出 NON-HERMETIC;并发复制 .agent/ 时又撞上正在
写入的条目,使无关测试组一起失败。

- 新增 tests/helpers/runtime-sandbox.js:每个测试进程一个一次性沙箱项目,
  产物根落在沙箱的 .agent/runtime/,子进程经环境变量继承同一沙箱根。
- 63 个测试/夹具的产物根迁到沙箱,保留原有断言强度与并发竞争语义。
- agent-sandbox 复制时排除 runtime/(运行时状态不是治理模板,复制它只会
  与并发写入者竞争),cleanup 改为带重试的删除,撕裂副本不再让套件失败。

runner 的单文件 60s 上限与两个慢文件自声明的 timeout 相互矛盾:
permit-authority-admission 的 1024 次耐久事务需约 108 秒,
permit-witness-managed-host 需约 59 秒,CI 上两者都被 SIGKILL。

- runner 支持按文件显式声明长预算(首行 // @runner-timeout N)。
  声明只会抬高该文件自己的上限,不会放宽任何其它文件;全局 --max-time
  仍然约束整轮运行。
- 对声明了长预算的文件,idle 超时不再早于文件级上限触发:node --test
  只在测试结束时输出,一个长测试与挂死无法区分。
- 为 7 个慢文件声明与其既有断言相称的预算。

* fix(test): 修正独立物化测试的依赖并放宽负载敏感的 native deadline

- tests/update/upgrade-failure-preservation.test.js 由 migration-preservation.yml
  以逐文件物化方式取用,不 checkout 仓库其它文件,因此不能依赖共享的
  tests/helpers/runtime-sandbox。改为文件内自带的临时沙箱,仍不写工作副本。

- native fixture 的 deadline 场景此前给整个 session 300ms 预算,握手往返
  在负载较高的机器上会先耗尽该预算,导致 ready-ACK 阶段就返回 DEADLINE,
  而该场景本意是证明 deadline 触发正确。放宽到与其它模式一致的 3s。

- 为在并行负载下超过默认挂起检测窗口的文件补上显式预算声明。

* chore(test): 输出 SQLite observer 的逐模式判定以便定位平台差异

native observer 的 Linux 判定与 macOS 不同,断言只显示实际值不显示
observer 的完整状态。把每个模式的判定打印到作业日志,使差异可直接
对照,而不是只能从断言不匹配里推测。

* fix(swift): 修正 V2 测试中局部变量遮蔽存储属性导致的 Swift 6 编译失败

send(_:) 用 let queue = lock.withLock { ... return queue! } 声明局部变量,
闭包内未限定的 queue 会被解析为正在声明的绑定本身,Swift 6 编译器报
cannot reference invalid declaration。改用 target 作局部名并显式 self.queue
取存储属性,与 ExchangeTests 的既有写法一致。

* fix(test): 修正 Linux 64 位重定向下 SQLite observer 的 syscall 插桩失效

* fix(test): 让锁竞争的时限断言绑定实现声明的等待预算

SQLite busy handler 的 timeout 是名义预算:它按退避序列睡眠,耗尽后才返回
SQLITE_BUSY,实测墙钟等于名义预算加上宿主为每次睡眠附加的调度延迟。

macOS CI 上该延迟可达约 5 秒:同一批 1866 个用例中,锁竞争的两个用例比
Linux 慢约 1.7 到 2 倍,而其余定时类用例均在 1 倍附近,因此并非 runner 整体
变慢。这些断言自 1.16.0 候选引入后从未在 macOS 上跑过——承载它们的
workflow 只存在于本分支。

用例要证明的是竞争有界、失败且不自动重试业务工作,具体经过多少毫秒并不
是被测性质。原先写死的 10000 毫秒把宿主调度细节变成了误报。改为从实现
声明的 TIMEOUT_MS 推导上限,使断言随实现演进,且仍能拦下真正的无限等待
(16000 毫秒依然越界)。

* fix(test): 让替换竞态场景显式证明竞态确实发生过

race 模式此前只断言 unknown > 0:观测到替换时 unknown 递增,竞态没发生时
unknown 为 0。子进程的失败对父进程不可见(exit(91) 不会被 waitpid 检查),因此
竞态没跑 与 观测器拒绝了每一次替换 在断言前完全同形,失败被伪装成成功。

改为让竞态子进程在共享内存里精确统计已完成的交换次数,父进程在子进程停止后读
回该值,作为独立证据输出为 raceSwaps。测试同时要求 raceSwaps > 0 与
unknown > 0:前者证明竞态真实发生,后者证明观测器确实撞上并拒绝了替换。

握手改为对共享计数的有界轮询,不再用阻塞的管道读,竞态无法交换时会被报告
为竞态未运行而不会挂死整个用例。

反证:阻断子进程的交换后,用例明确失败并报出该原因,而不是通过。

* fix(coordination): 让 deadline 定时器只负责唤醒,判定统一由单调钟决定

模块内其余 6 处 deadline 判定都经由 expired() 重新读取单调钟,唯独定时器回调直接
fail("DEADLINE"),不核对墙钟。定时器以毫秒为基准调度,而 deadline 以纳秒
比较,因此存在定时器早于 deadline 触发、通道在期限之前就宣告到期的路径。
ubuntu CI 上偶发失败于 assert.ok(process.hrtime.bigint() >= deadlineNs),本地可
复现(真实 connectBounded 40 次出现 1 次)。

改为定时器只作为唤醒机制:回调重新读取单调钟,未到期则按剩余时间重排,到期
才失败。deadline 本身不移动,进度也不延长它。

同时修正初始化边界:deadline 若在准入检查之后、连接之前到期,通道已经进入
终态,不能再 connect——Node 的 Socket.connect 会重新初始化已销毁的 socket。

补充两个用例:
- 持续进度不延长期限。原有断言只有下界,无法区分绝对期限与 inactivity
  timeout;新增用例让 peer 逐字节滴送,若实现被改成 inactivity 变体则该用
  例明确失败(实测 overshoot 0.25~2.8ms vs 变体 266ms)。
- 初始化期间到期不再 connect。去掉 state 守卫后该用例明确失败。

独立复核报告:.agent-work/review/deadline-timer-review-result.md

---------

Co-authored-by: cortex-agent <cortex-agent@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant