fix(dev): 優化 SDKMAN JDK 切換流程#2
Merged
Merged
Conversation
已安裝的 exact candidate 改走無狀態 runner,並同步修正 lock 診斷、文件與契約測試。
SamWang32191
commented
Jul 23, 2026
SamWang32191
left a comment
Owner
Author
There was a problem hiding this comment.
APPROVE (advisory) — 九個審查軸皆已完整檢查,未發現 must-fix
Coverage & checks
| Axis | Status |
|---|---|
| Correctness | clean — 追蹤 exact candidate 驗證、實體路徑、PATH 組裝、版本探測、payload exec 與各種 lock-path 分類 |
| Spec conformance | clean — 將 fast path、shell 指引、default-scope 拆分、lock 診斷與 0.1.8 升版逐項對回 10 個變更檔 |
| Scope (out-of-scope) | clean — 每個變更檔都可直接映射至 fast path、文件拆分、診斷、契約測試或 lockstep 升版意圖 |
| Convention conformance | clean — 對照 base ref 的 AGENTS.md,確認 stable SemVer、VERSION/manifest lockstep、marketplace 與繁體中文規則 |
| Security | clean — 檢查 identifier allowlist、absolute SDKMAN root、candidate regular-file target、argv 邊界與 unsafe lock-path 拒絕 |
| Readability & simplicity | clean — runner 收斂為 root、candidate、environment、probe、exec 五段,永久 default 流程隔離至具名 reference |
| Architecture | clean — 無狀態 exact-candidate runner 與有狀態安裝/project runner 的責任邊界清楚,未新增反向耦合或依賴 |
| Performance | clean — fast path 不再初始化 SDKMAN、建立 default-state lock、呼叫 sdk use 或 reconciliation,且候選列舉維持單層有界 |
| Test coverage | clean — 靜態核對新增 contract cases 已覆蓋 fast path、PATH、argv、probe、candidate、identifier 與 lock 診斷邊界 |
- Verified — GitHub 平台上的
SDKMAN JDK script contracts、Node.js 22、Node.js 24 與 GitGuardian 四項檢查皆成功;本輪為 static-only review,未在本機執行 PR 程式、測試或 build。 - Out-of-band — 以固定 head SHA 唯讀補查完整 runner/state helper,並以 base SHA 的 AGENTS.md 檢查規範符合性。
🤖 Reviewed by GPT-5.6
(self-review — 同一帳號;GitHub 會以 event=COMMENT 記錄且不顯示 badge,所以上述 verdict 僅供參考。)
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.
摘要
sdkman-switch-jdk對 Java/JDK 版本問題的觸發描述,並同步 plugin lockstep 版本至0.1.8sdk use、不讀寫 default,也不取得 default-state lockbash -c,避免 profile 覆寫 runner 選定的 JDK背景與原因
V2 integration task 多次使用這個 skill 時,遇到三類可避免的摩擦:隔離 runner 被既有 lock-path 狀態擋住、login shell 把 Java 8 切回 Java 21,以及 lock 建立失敗被誤報為型別錯誤。對已完整安裝的 exact candidate,這些 default-state 操作不是執行命令所需,因此改為直接設定精確
JAVA_HOME/PATH並execpayload。主要變更
run-java.sh僅驗證 SDKMAN root、candidate 與bin/java,不再 source SDKMAN 或修改 defaultSDKMAN_DIR、保留空 PATH 安全行為,並先以 exact Java 執行版本探測sdkman-current-state.sh區分 unsafe lock path 與 lock creation failureSKILL.md聚焦預設無狀態流程;永久 default 操作搬到references/default-scope.mdbash -c/bash -lc差異、invalid identifier、probe failure 與 lock 診斷驗證
/bin/bash test/sdkman-switch-jdk-contract.sh:40/40bash -nquick_validate.pyVERSION=0.1.8lockstep checkgit diff --check風險與取捨