Repository navigation
feat(xvm): tell the user why an install or removal was refused - #393
Merged
Merged
Conversation
The validation layers fail closed, which is only worth doing if the
person on the other side is told what happened. They were not: a
rejected batch went to log::warn and the command returned false, so at
the default log level the user saw 'install failed' and nothing else.
That reads as xlings breaking rather than as the package being
malformed, and it leaves no way out. It is also new -- several of these
refusals are cases that used to succeed by silently overwriting.
Add xvm::XvmUserError with a stable code, the owning release, the
offending target and JSON Pointer, and a hint that names an action.
Every kind of all three error enums maps to one; the mapping is a switch
with no default, so a new enumerator warns at compile time, and a test
enumerates all forty of them and fails on any that is unclassified,
hintless, or shares a code with another.
Wire it into the three installer paths that previously warned and
returned false. Each passes nothingChanged=true, which is checked rather
than assumed: selection runs before any mutation, and the metadata batch
works on copies it swaps in only on success, so every failure path
returns with the stored state untouched.
[error] exact registration is owned by 'pkgindex:[email protected]'
code: xvm-ownership-conflict
provider: pkgindex:[email protected]
at: [email protected]
field: /nodes/2
hint: another package already owns this exact name and
version; uninstall that package first, or install
this one at a different version
nothing was changed
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
#384 让校验层 fail-closed,但失败只走
log::warn+return false。默认日志级别下用户只看到install failed,看不到原因,也没有出口。这在两个意义上是新问题:
OwnershipConflict、HeaderAmbiguous)在origin/main上是静默覆盖成功的。用户的第一感受会是"升级之后我原来能装的包装不上了",而不是"我的包有问题"。Change
新增
xvm::XvmUserError—— 稳定 code、所属 release、出错的 target 与 JSON Pointer、以及一条指明动作的 hint。三个错误枚举(
RegistrationErrorKind17 +RemovalErrorKind8 +BindingErrorKind15 = 40 个)全部建立映射。穷尽性双保险:switch 不带
default(新增枚举值编译期告警)+ 单测逐个列举全部 40 个值,对任何未分类、无 hint、或 code 重复的一律失败。nothing was changed是断言,不是修辞三处接线全部传
nothingChanged=true,且逐处核对过而非假设:snapshot_xpkg_removal_context)在任何变更之前运行apply_xpkg_xvm_metadata_batch在candidateDb/Workspace/Installed副本上工作,只在成功时swap回去 —— 所有失败路径都在 swap 之前 return测试
NothingWasChangedIsOnlyClaimedWhenAsked保证这行字不会在没人担保时出现。Tests
EveryRegistrationKindHasACodeAndHintEveryRemovalKindHasACodeAndHintEveryBindingKindHasACodeAndHintRenderCarriesEveryFieldTheUserNeedsNothingWasChangedIsOnlyClaimedWhenAskedPeerOfAnAsymmetricEdgeIsShownVerification
CI 状态为已知上游拉取签名(见 #386),依计划 §3.1.1 合入集成分支。