Repository navigation
feat(xvm): make self doctor see the binding state - #394
Merged
Merged
Conversation
The selection layer fails closed, so a malformed or dangling release makes `xlings use` refuse. That is correct, but doctor only knew about shims and payloads, so the refusal was a dead end: nothing in xlings could name the offending entry and the user was left reading versions.json by hand. Add xvm::inspect_binding_state, a pure function over (db, workspace) that checks the invariants the selection layer relies on: every active version is registered every release resolves, with all members present members of one release are active together, or not at all Each finding carries the XvmUserError code, the entry, the JSON Pointer when the problem is metadata-level, and a hint naming the command that fixes it. A release short one member is reported once, not once per member. Pre-0.4.70 databases carry no group metadata and are not flagged. Pure by construction -- no Config, no filesystem, no network -- so every case is reachable from a unit test and doctor stays a renderer. Read-only. Repair lands separately: deactivating a group or dropping metadata should be spelled out before it happens. Not included, and worth recording why. The plan called for bindingIntegrityIssues to stop being serialized, on the grounds that derived data should not become stored state. Implementing it failed seven tests from #384 that assert the opposite, and they are right: an entry whose bindingGroup did not parse holds no group in memory, so rewriting the record without the marker would drop the malformed value entirely and silently launder a corrupt entry into a healthy group-less one -- back to the mixed-toolchain risk, with nothing left to show it happened. The real defect is that rewriting an unparsed record loses information either way; fixing it means preserving the original JSON for such entries, which is its own change.
This was referenced Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
评审 §3.4 的"死路"场景:
doctor 只检查 shim 和 payload,完全不认识 binding 元数据。校验层 fail-closed 是对的,但在 xlings 里没有任何东西能说出是哪条条目坏了,用户只能手读
versions.json。Change
新增
xvm::inspect_binding_state—— 对(db, workspace)的纯函数,检查选择层依赖的不变量:每条 finding 带
XvmUserError的 code、出错条目、metadata 级问题的 JSON Pointer、以及指明修复命令的 hint。纯函数(不碰 Config / 文件系统 / 网络),所以每个分支都能单测覆盖,doctor 退化为渲染器。
只读。修复动作单独提交 —— 停用一个组或丢弃元数据,应该在发生前先讲清楚。
Tests
7 条,含两条"不该误报"的护栏:
CleanStateReportsNothingNamesTheCorruptFieldAndItsEntryReportsAReleaseWithAMissingMemberReportsAnIncoherentActiveReleaseReportsAnActiveVersionThatIsNotRegisteredABrokenReleaseIsReportedOncePerReleaseLegacyStateWithoutGroupsIsNotFlagged计划中的一项没做,原因值得记录
计划 P1.3 要求停止序列化
bindingIntegrityIssues(理由:派生数据不该变成存储状态)。实现后失败了 #384 的 7 条测试,而它们是对的。一条
bindingGroup没解析成功的记录,内存里根本不持有那个 group。不写回 marker 就意味着保存时把畸形值整个丢掉 —— 损坏条目被静默洗白成一条健康的无组条目,退回混合工具链风险,且不留任何痕迹。#384 的持久化正是在防这个。真正的缺陷是:重写一条没能解析的记录,无论写不写 marker 都会丢信息。正确修法是为这类条目保留原始 JSON,那是独立的一次改动。已撤销该部分,序列化行为保持 #384 原样。
Verification
CI 状态为已知上游拉取签名(见 #386),依计划 §3.1.1 合入集成分支。