Repository navigation
fix(wpm): interaction audit fixes - outdated receipt anchoring, install --json, help force semantics (#1156) - #1158
Merged
Merged
Conversation
Measured-driven audit of the five reported friction points, each reproduced
or refuted against a worktree build before fixing:
- outdated vs index update (fixed): installed versions now anchor on install
receipts (.wpm/installed/*.json, destinations verified) instead of the
local index copy. Comparing the local index against the freshly fetched
remote index made 'wpm outdated' permanently claim 'all installed packages
are up to date' after any 'wpm index update', even while old files were
still on disk. Pre-receipt installs keep the index-version fallback.
- install --json (fixed): 'wpm install' now supports --json with one
machine-readable payload on stdout (schema 1, results[] with statuses
installed/already_installed/would_install/not_found/not_installable/
preflight_failed/download_failed/error + errors[]), matching uninstall.
All human progress (downloading, extracting, installing files, alias/shim
notes, auto index refresh) routes to stderr in --json mode; the download
progress bar is suppressed so WT_SESSION cannot pollute the stream.
already_installed exits 0 per apt convention; failures exit non-zero.
- index update --json (fixed): emits {schema,status,source} on stdout, human
line to stderr. Auto-refreshes inside other commands never leak a payload
into the caller's stdout (update_index grows a json_payload flag).
- help: 'install' now documents its --force reinstall/overwrite semantics
(the Options entry alone did not say reinstalling is possible).
- uninstall piped stdin / -y (already fixed on this branch, verified):
0095bab's confirmation reads std::cin, so 'echo y | wpm uninstall x'
confirms, 'n'/EOF abort without removal, and -y works in any position.
- locked destination files (already correct, verified): install --force and
uninstall fail loudly with exit 1 and a 'failed to install/remove'
message; nothing is silently skipped.
Regression tests: 9 new cases in tests/unit/wpm (piped y/n/EOF confirmation,
-y skip, help force wording, locked-file install/uninstall exit codes,
outdated-after-index-update receipt anchoring, install --json exact payload
purity, index update --json payload). wpm group: 50/50 pass.
Note: per AGENTS.md the new/changed i18n keys (command.wpm.custom_help
fallback text, command.wpm.error.download_failed_generic/copy_failed/
shim_failed/alias_failed) need a follow-up catalog sync in
unixwin/winuxcmd-i18n; English fallbacks land here first.
Closes #1156
…ing (#1158) in download_artifact
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.
Closes #1156
实测驱动的逐项处置表
uninstall的 y/N 确认不读管道 stdinecho y | wpm uninstall jq正确确认并卸载;n/EOF 中止且不删文件。0095bab(已在 origin/main)改为std::getline(std::cin, ...)。#1154 事故中的旧发布版二进制早于该提交install --force未在 help 的 install 说明中出现--help的 install 行仅写 "install one or more packages",Options 段的-f, --force未说明可重装usr/bin/jq.exe(无 FILE_SHARE_DELETE 打开)后:install --force→ exit 1 +wpm: failed to install ... being used by another process;uninstall -y→ exit 1 +failed to remove,removed=0 failed=1。#1154 实测的"报成功但文件未变"根因是下载缓存键不含版本(疑点 3),非锁文件跳过outdated/index update/install索引副本不一致窗口期outdated用本地索引版本 vs 远程索引版本:一旦wpm index update,本地==远程,此后永久报 "all installed packages are up to date",即使磁盘上仍是旧版(receipt 里记录的实装版本为 1.0.0、远程 2.0.0 时仍报无更新,已实测复现)outdated改以 install receipts(.wpm/installed/*.json,且校验 destinations 仍在磁盘)为已装版本来源,无 receipt 的旧式安装回退到本地索引;outdated从此不依赖本地索引副本。+回归测试-y覆盖、--json缺失-y:已生效——唯一交互提示是 uninstall 确认,-y/--yes 任意位置解析均跳过(实测wpm -y uninstall jq与wpm uninstall jq -y等价);GNU/apt 惯例上-y不应隐含--force重装,维持现状。--json:install 缺失(实测输出人读文本)、list 已有install --json输出单一 JSON payload(schema 1、results[]、failed,状态机 installed/already_installed/would_install/not_found/not_installable/preflight_failed/download_failed/error,errors[] 内联),全部人读进度走 stderr,下载进度条在 --json 下禁用;already_installed按 apt 惯例 exit 0。附带index update --json输出 payload(且命令内自动刷新不再向调用方 stdout 泄漏第二个 JSON 文档)。+回归测试(含 stdout 纯净性断言)实现说明
outdated:receipts 优先(receipt_install_records),本地索引回退仅覆盖无 receipt 的历史安装;比较基准从"本地索引副本"改为"磁盘实装版本",疑点 4 的不一致窗口整体消除。install --json:install_package增加json_result出参,全部退出路径经finish()记录结果;preflight_install_destinations增加 messages 出参供 payload 的 errors[] 使用;download_artifact/extract_archive/copy_artifact_files/create_package_shims/create_package_aliases/cleanup_legacy_flat_artifacts/refresh_index_once/update_index增加 json 路由参数。wpm restore/install --from走同一install_packages通道,自动获得 --json 支持。测试
tests/winuxcmd-tests.exe --gtest_filter=wpm.*:50/50 通过(41 存量 + 9 新增,覆盖管道 y/n/EOF、-y 跳过提示、help force 文案、锁文件 install/uninstall 非零退出、outdated 在 index update 后的 receipt 锚定、install --json 精确 payload 与 stdout 纯净性、index update --json payload)。--gtest_filter=winuxcmd.*:28/28 通过。-DBUILD_FFI=OFF,pcre2 复用主仓缓存)。后续(不在本 PR)
command.wpm.custom_helpfallback、command.wpm.error.download_failed_generic/copy_failed/shim_failed/alias_failed)需在unixwin/winuxcmd-i18n补 zh-CN 目录并 bump VERSION;本 PR 先落英文 fallback。