Skip to content

feat(contract): verify explicitly pinned source content - #7321

Merged
huangruiteng merged 2 commits into
loopx-project:mainfrom
hhyykk:feat/top-level-invariants
Oct 27, 2026
Merged

huangruiteng merged 2 commits into
loopx-project:mainfrom
hhyykk:feat/top-level-invariants

Conversation

@hhyykk

@hhyykk hhyykk commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem and result

A local source may explicitly pin accepted file bytes. Health checks should detect drift of that pin without turning ordinary repository knowledge into an immutable contract or enabling software policy by filename.

This proposal now contains only the generic content-integrity slice. The former auto-discovery, bootstrap-generated obligations, AST/regex scanner and its four rule types have been removed. bootstrap --goal-doc stays mutable and does not generate a pin. Ordinary bootstrap/check/status retain default behavior when no explicit source pin is present.

Ownership and scope

  • The existing private Goal registry can carry a file-content sha256 beside path in authority_sources. Only these explicit pins are checked. A source-reference hash and a registry witness remain distinct contracts.
  • The read-only local filesystem adapter reports changed, missing or unreadable content through the existing Goal-scoped health diagnostics. It never updates locks, documents or memory.
  • Recovery restores accepted bytes, or uses the existing authorized registry-edit boundary to revise an explicitly reviewed pin, followed by health readback. Current prose and recalled memory cannot approve that revision.
  • Repository memory and semantic preference providers remain advisory and own their existing recall/freshness/application lifecycle. No new memory system, graph, scanner, approval workflow or mandatory SPEC format is introduced.

The scanner's from-import bypass is eliminated by withdrawing that scanner from this proposal, not by claiming an incomplete resolver is now sound. A future scoped engineering check must be independently designed and verified.

Validation

Final exact head and results are recorded in the author follow-up comment. 27 source-integrity, project-onboarding and contract-health tests pass on the current main baseline. These exercise public bootstrap/check, implicit-discovery rejection, unpinned document updates, explicit-pin mismatch and restore, read-only locks, state-prose non-approval, explicit registry revision and missing/unreadable source diagnostics. No new frontend capability is claimed: existing check/status remain the consumers of an internal integrity adapter.

The current broader contract-health suite also passes after adopting main's canonical-fixture repairs. No PostgreSQL store behavior is changed and no PostgreSQL or full-CI qualification is claimed here.

中文设计说明

本 PR 收窄为显式来源 pin 的只读完整性校验。知识材料和 memory 可以持续更新;文件名、--goal-doc 和一次读取都不自动授予约束效力。撤出自动发现、指令注入及整个源码扫描器,因而也不再交付可被 from-import 绕过的规则。约束仍归已有验收/权限 owner,检索与新鲜度仍归已有 memory provider。只有私有 registry 显式固定的文件字节版本参与校验;还原字节或单独评审并修订 pin 后,重新回读健康状态。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

评审对象:576af8b44def7095aaec839c5e159ed49829d88d。两项阻塞:

  • [P2] 将软件扫描从默认通用健康路径隔离。 check_contract 的新参数默认是 True,普通 CLI 和 status 调用都不传它。一次性项目仅包含声明缺少文件的规范、没有任何显式启用操作,同输入旧基线 check 为 exit 0,当前为 exit 1;当前直接传 False 又通过。bootstrap 同时已经快照软件规则并生成 Agent 义务,所以内部 bool 也不能隔离完整行为。将源码规则从普通 check/status 的默认路径分离,通过显式、带作用域的工程检查启用;只改 Python 默认参数仍不足以隔离 bootstrap 已生成的新增义务。保留来源校验的独立 owner,并补开/关与旧版默认行为对照。
  • [P2] 检查 from-import 中的实际子模块。 ImportFrom 分支 只比较 node.module。声明禁止 pkg.db 时,import pkg.db 会报错,改成 from pkg import db 却返回 ok=True/errors=[],实际 Python 导入仍加载同一个被禁止的模块。检查 ImportFrom 的模块与导入成员组合,正确处理子模块和相对导入;把 import pkg.db 与 from pkg import db 作为同一禁止依赖的成对反例,避免靠改写合法 import 绕过。

动机

把已有项目接入 LoopX、随后正常检查状态或继续修改代码的用户,会受到自动发现的仓库规范影响。旧版普通 bootstrap 后的 check 不执行这些软件规则;新版仅凭规范文件名就把源码规则接入默认健康检查,即使用户没有显式启用工程扫描。来源摘要锁能发现修改和删除,但当前 head 的默认 CLI 出现新增拒绝,同时一个普通静态导入写法能让禁止依赖检查返回干净结果。本次评审不否定来源完整性需求,也不要求完成整个 TypeScript 迁移;要求把通用完整性与可选软件检查分清,并让已声明规则可靠。

改动思路

来源完整性与软件源代码约束属于两项不同责任;后者不能仅因发现文件名就在通用健康路径默认启用。保留有用的来源校验,先把软件扫描移到显式工程检查边界,并修复已声明导入规则的漏检;无需等待整套控制面迁移。这里应区分三类机制:文件字节及历史接受版本的完整性是通用来源事实;AST/正则扫描是软件工程领域策略;文件读取是只读 provider IO。复用通用诊断容器不会让领域策略自动成为 Kernel 的默认责任。既有注册来源 witness 核的是注册字节身份,与单份文档内容锁不同,不能因同用 SHA-256 就硬合并;已有工程检查能力的显式作用域则是可复用边界。

具体改动

采用作者引用的 docs/architecture.md,固定规格版本 59464f9741fe177381743eadaaffebbb54e5472e:Runtime Responsibility Model 的 capability/domain-policy 与 Kernel 分工未满足;Guided Autonomy, Not Recommendation Lock-In 对显式 typed 强制边界的要求也未满足。修复针对上述当前默认/范围问题,不将未来整套迁移当作前置门。来源摘要在现有测试里能够发现改动、删除,并且 active-state prose 不能批准换锁,这些正向价值保留。

关键代码讲解

  1. build_goal_entry 给已存在的显式 goal 文档加摘要,并自动发现四个候选规范位置;它还保存解析规则、原理和 immutable 文件摘要。缺少的显式文档仍保持旧的无摘要注册。
  2. check_contract 始终加入来源摘要诊断,并在新增参数为真时加入软件规则。默认值为真且现有公共调用方省略参数,实际行为与“Slice 2 opt-in”不符;bootstrap 的新增指令也没有同一个开关。
  3. verify_authority_source_digests 保留旧无摘要记录,对缺少、不可读和内容改变产生 Goal 诊断。需要保留该兼容意义,而不是删除旧来源格式;测试里直接改字典摘要并不等同普通授权恢复旅程。
  4. _check_python_forbidden_imports 区分 Import/ImportFrom,后一支丢失导入成员,使同一个子模块依赖得到不同结论。文件有 381 行生产逻辑,同时维护解析、扫描、IO 和策略,不能以 268 行新测试证明整体责任合适。

对主干的风险

独立运行新增测试 13 过,现有 bootstrap/contract 与架构边界测试 601 过、1 跳过;该跳过是同一原生 Windows/PowerShell 用例,base/head 的早期条件、源码和原因相同。原生 premerge 的 6 项直接、6 项 catalog 和 8 项风险检查通过,没有手工 hold;这些绿色结果没有覆盖上述反例。按当前策略没有读取、轮询或等待 CI。

同输入生产路径 旧基线 当前完整 head
普通 bootstrap 后默认 CLI check,无显式工程启用 exit 0,干净 exit 1,软件规则错误
当前内部显式停用软件 probe 旧版无该参数 通过,但 bootstrap 指令/快照仍已产生
同一禁止子模块的直接 import / from-import 尚无此规则 前者拒绝,后者错误通过

两臂都使用真实 bootstrap、公共 CLI 和一次性 File 注册/runtime,未修改活跃 Goal。首次夹具放在被忽略私有树里,两个 CLI 都因独立的 public-boundary 扫描拒绝;原失败保留,随后在全新系统临时目录完整重放两臂,没有删除或关闭生产扫描来制造结果。当前两个反例均稳定成立。修复后应重跑默认/显式开关、完整生成指令和规则元数据、来源变更/删除/合法恢复,以及直接/from/相对导入的正反矩阵。

语义与 CI 对齐

本 PR 新建了来源种类、规则 kind、快照字段及健康诊断语义,kind: str 加注释不是 typed 规则合同;静态 advisory 未报 candidate 也不能证明没有新词汇。软件策略应归显式工程 owner,通用来源完整性应复用当前 typed 边界和诊断语义。include_architecture_invariants 是机器执行分支,失败会产生健康错误,不宜表述成仅供参考的指导。现行原生校验通过仍不能覆盖默认范围和导入漏检。

我的整体评价

REQUEST_CHANGES。来源摘要锁有可验证的价值,但完整提案仍包含默认行为回归和错误的规则通过,用户的正常检查及后续恢复没有形成可用闭环。长期有效工作是否保持尚未证明;用户体验已观察到无额外启用却新增拒绝。来源完整性与软件源代码约束属于两项不同责任;后者不能仅因发现文件名就在通用健康路径默认启用。保留有用的来源校验,先把软件扫描移到显式工程检查边界,并修复已声明导入规则的漏检;无需等待整套控制面迁移。已检查 bootstrap 生成的 Agent Markdown、CLI check 和 status collection:本 PR 没有修改渲染页面组件,问题在默认策略和诊断,因此不以截图充当其正确性证据。未验证范围:原生 Windows/PowerShell、完整跨平台 CI、已安装客户端、长期扫描成本和获授权锁更新后的真实继续工作未获本次资格;这些不替代已复现的两项缺陷。这是当前精确 head 的评审结论,不要求用户代作者操作,也不授予合并、安装或额外执行权限。

English verdict: REQUEST_CHANGES 576af8b. Ordinary bootstrap/check implicitly enables the claimed optional software probe, and a normal from-import bypasses the declared forbidden submodule rule. Independent CLI counterexamples reproduce despite passing focused/regression tests and native premerge; separate the responsibility/activation boundary and repair import resolution.

@huangruiteng
huangruiteng force-pushed the feat/top-level-invariants branch from 576af8b to e7ef333 Compare October 27, 2026 08:53
@huangruiteng huangruiteng changed the title feat(contract): add authority source digest locks and executable invariants probe feat(contract): verify explicitly pinned source content Oct 27, 2026
@huangruiteng

huangruiteng commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Final rebased head: b9f99f115fff5ae15680ae8e060b483f372079b2, base 17b2a0f9b818dc6e6fe77ccc567b20ff91b3bc40.

The scope remains explicit source-content pins only: no automatic spec discovery, bootstrap-generated obligations, default AST/regex scanner or implicit freezing through --goal-doc. The old from-import bypass is eliminated by withdrawing that scanner from this proposal, not by claiming its resolver was repaired.

Knowledge retrieval/freshness, accepted constraints and content-integrity IO remain separate owners. Existing repository-memory and semantic-preference adapters are unchanged; no new memory system or mandatory SPEC format. Current prose or recalled memory cannot approve a registry pin revision.

27 source-integrity/onboarding/contract-health tests pass on this base; Ruff and standard premerge pass (4 direct checks, compile, 18 selected checks). Main's canonical-fixture repairs are reused; the four health-test failures recorded on the earlier base are not current failures and are not silently relabelled historical passes. No full-CI, PostgreSQL or new frontend capability claim.

已同步新主线并推回作者 fork,保持知识可演化、约束显式生效的边界;请复审新 head。

hhyykk and others added 2 commits October 27, 2026 17:25
…riants probe

Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
…edge

Signed-off-by: huangruiteng <huangrt01@163.com>
@huangruiteng
huangruiteng force-pushed the feat/top-level-invariants branch from e7ef333 to b9f99f1 Compare October 27, 2026 09:32

@loopx-agent loopx-agent left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

未发现当前 head 的阻断问题;这是对完整提案的重新评审,旧评审保留其原版本。

动机 / Motivation

显式固定本地文档版本、依赖 Goal 健康检查的维护者和 Agent。同一已登记文档被改写时,旧版不检查内容;当前版本仅在显式 pin 存在时报告变化,恢复原字节后重新通过。未固定来源继续可变,显式 pin 的变化、缺失和不可读进入原 Goal 健康诊断。不发现规范文件、不扫描源码架构、不自动生成约束,不修改 memory、registry pin 或批准来源变更。

本次按维护者修订后的范围判断,而不是要求恢复已经撤回的源码规则扫描。接受依据是 #7321 (comment),spec_revision 2026-10-27T09:32:42Z;同时核对修改前 docs/architecture.md 的 Runtime Responsibility Model 与 Guided Autonomy(17b2a0f9b818dc6e6fe77ccc567b20ff91b3bc40)。当前实现完成这项有界检查,不代表整个知识治理或长期 Goal 完成。

改动思路 / Approach

文件字节测量保留在小型 Python IO adapter,范围与健康状态复用原 Goal health owner,职责和恢复边界清楚。本 PR 交付显式本地来源内容完整性检查;知识检索、接受约束与来源变更授权继续归原 owner。已有来源引用的脱敏 hash 和 registry witness 都不能代替当前文件字节,因而这里需要显式内容 pin。来源更新仍须原 registry 写权限,当前文档、Agent 声明或召回记忆不能自行批准换锁。普通文件名和 --goal-doc 均不会启用扫描,也没有新增确认轮次。

具体改动 / Changes

四个路径的完整 diff 已核对:source_integrity.py 提供文件 IO;contract.py 将结果接入现有健康诊断;architecture.md 明确默认与恢复;新测试保护显式 pin 与普通来源的区别。

关键代码讲解

逐项验收:S7321-PIN 在同一合成输入上,旧 17b2a0f9b818dc6e6fe77ccc567b20ff91b3bc40 的 check 忽略漂移而 exit0,当前 head 在真实 File/SQLite 均 exit1。S7321-DEFAULT 的无 pin check/status 完整输出仅规范化观察时间,双侧一致;架构式文件名、from-import 和可变 goal-doc 没有产生义务。S7321-RECOVERY 通过实际删除、chmod000、伪造批准正文、后建未 pin 来源及同项目另一 Goal 的反例;恢复文件/权限后健康通过,并成功写入和读回一个实际 Todo。各次读取前后文件字节、registry 与 state 保持不变,fixture 准备和恢复写入另计。

PASS:owning/adjacent suites 64 passed、1 skipped;跳过项明确要求原生 Windows 与 PowerShell7,未冒称执行。额外 30 个真实 CLI 场景 通过。Ruff、diff check、增量语义 advisory、标准 premerge 6 direct + 18 selected 全部通过。首评前已有物理 CQR cqr_e1ed3fd5f3ba5c089977,原生 premerge 校验其精确 scope 有效。未查询、轮询或等待 CI。

对主干的风险 / Risks

语义与 CI 对齐

新增拒绝仅在操作者显式 pin 的来源上发生,这是当前接受范围内的行为变化;未固定知识继续可变。错误按结构化 Goal scope 归属,避免通过字符串前缀扩大阻断。文件 IO 留在 Python adapter 是对现有健康消费者的有界扩展,没有第二个授权、记忆、状态或调度 owner。恢复既可还原接受字节,也可由原 owner 独立审阅后修订 pin,不能让读取操作悄悄接受漂移。

最强未验证项是正式安装和原生 Windows 路径,以及实际长期模型采用/完整成本。当前真实后端和恢复反例不等于这些资格;显式大文件校验成本也未量化为性能收益。较早 head 的自动架构扫描及 from-import 绕过已通过删除整个机制退出当前边界,不是沿用旧批准。

我的整体评价 / Verdict

文件字节测量保留在小型 Python IO adapter,范围与健康状态复用原 Goal health owner,职责和恢复边界清楚。本 PR 交付显式本地来源内容完整性检查;知识检索、接受约束与来源变更授权继续归原 owner。未改渲染组件;已检查 check/status 共享健康投影与现有调用路径,本切片不需要新增页面截图。正式安装及真实模型采用未验证。仓库经验条目属于不同的恢复/RFC案例,本轮没有据其推导批准或权限;决定依据是当前来源和实际反例。默认未 pin 的长程工作被保留,pin 失败后可恢复到实际任务操作。APPROVE 仅属于此精确 head 的代码结论,旧 CHANGES_REQUESTED 的 GitHub 状态须另行对账,合并权限和 readiness 仍是独立门。

English verdict: APPROVE b9f99f115fff5ae15680ae8e060b483f372079b2 — explicit source pins are read-only and Goal-scoped; default parity, real File/SQLite recovery, 64 tests and native premerge passed. Native Windows and installed adoption remain unverified.

@huangruiteng
huangruiteng merged commit 3017339 into loopx-project:main Oct 27, 2026
27 of 41 checks passed
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.

3 participants