diff --git a/README.md b/README.md index 662d009..7f79612 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ InviteCode is a Kotlin invitation and referral rewards plugin for Spigot and Paper, with experimental Folia support. `InviteCodeKt` is the repository name; the plugin and its data directory are named `InviteCode`. -The project is currently `0.1.0-SNAPSHOT`. It builds one Java 8 compatible plugin JAR and keeps newer Minecraft APIs behind isolated adapters. SQLite and MySQL 8.4 are production storage backends; JSON is available for small single-instance installations. Folia 26.1.2 has passed an isolated experimental smoke test; optional integrations and the final player experience still require release-stage acceptance. +The project is currently `0.1.0-SNAPSHOT`. It builds one Java 8 compatible plugin JAR and keeps newer Minecraft APIs behind isolated adapters. SQLite and MySQL 8.4 are production storage backends; JSON is available for small single-instance installations. Cross-version, storage recovery, and optional integration checks are recorded in the [integrated artifact retest](docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.md). Folia remains experimental; automated checks and player acceptance are tracked separately. The complete maintainer guide is in [繁體中文](docs/README.zh-TW.md) and is the primary maintained documentation. See also the [product specification](docs/spec/invitecode-1.0.md), [Bukkit operations](docs/operations/bukkit-workflow.md), [JSON setup](docs/operations/json-storage.md), and [MySQL setup](docs/operations/mysql-storage.md). These documents are maintained in Traditional Chinese. diff --git a/docs/README.zh-TW.md b/docs/README.zh-TW.md index 63d3b08..d8204ca 100644 --- a/docs/README.zh-TW.md +++ b/docs/README.zh-TW.md @@ -94,7 +94,7 @@ Qualification Reward 與 Inviter Milestone Reward 會先以穩定冪等鍵保存 ## 真實伺服器測試 -專案的真實 Spigot/Paper/Folia 測試矩陣位於 [`test-servers/matrix.json`](../test-servers/matrix.json),並使用專案外的共用 TestLab 建立隔離實例。操作方式與 EULA 邊界請參閱 [`test-servers.md`](./testing/test-servers.md)。 +專案的真實 Spigot/Paper/Folia 測試矩陣位於 [`test-servers/matrix.json`](../test-servers/matrix.json),並使用專案外的共用 TestLab 建立隔離實例。操作方式與 EULA 邊界請參閱 [`test-servers.md`](./testing/test-servers.md);發行前真人測試見[最終驗收清單](./testing/final-human-acceptance.md)。 ## 目前狀態 diff --git a/docs/operations/bukkit-workflow.md b/docs/operations/bukkit-workflow.md index 0329426..a0075a6 100644 --- a/docs/operations/bukkit-workflow.md +++ b/docs/operations/bukkit-workflow.md @@ -31,7 +31,7 @@ Tab 建議會依發送者身分、權限與當前參數位置篩選。已完成 | `/invitecode status` | `invitecode.command.status` | 顯示 Claim Eligibility、Invitation 狀態與待補發 Reward 數。 | | `/invitecode stats` | `invitecode.command.stats` | 顯示等待資格與已達資格的邀請數。 | -聊天輸入會先取消公開聊天,再送入背景流程;原始訊息不會寫入 log。Dialog 提交後沿用同一組格式、資格與限時確認流程;取消按鈕、`/invitecode cancel`、登出或逾時只會清除短期 Session,不會建立或修改 Invitation。輸入、確認、逾時、成功、取消、登出或停用插件後,短期 Session 都會失效。玩家一旦建立 Invite Code、已有 Invitation,或超過 Claim Window,就不能使用他人的 Invite Code。 +聊天輸入會先取消公開聊天,再送入背景流程;原始訊息不會寫入 log。此時輸入 `cancel`(不分大小寫)也會私密取消,不會當作邀請碼解析。邀請碼訊息另外提供可點擊的複製入口:新版聊天 API 直接複製至剪貼簿,Spigot 1.8.8 則把原始碼填入聊天列,玩家可自行選取複製。確認摘要下方有綠色「同意」與紅色「不同意」,分別執行 `/invitecode confirm` 與 `/invitecode cancel`。Dialog 提交後沿用同一組格式、資格與限時確認流程;取消按鈕、`/invitecode cancel`、登出或逾時只會清除短期 Session,不會建立或修改 Invitation。輸入、確認、逾時、成功、取消、登出或停用插件後,短期 Session 都會失效。玩家一旦建立 Invite Code、已有 Invitation,或超過 Claim Window,就不能使用他人的 Invite Code。 玩家登入時,插件會以 SQLite 的 `anti-abuse.key` 或 MySQL 多實例共用的外部密鑰,對正規化網路位址執行 HMAC-SHA-256。資料庫只保存雜湊、密鑰識別碼與觀察/到期時間,絕不保存原始 IP。`anti-abuse.ip-hash-retention` 預設為 30 天;到期資料會在玩家登入時清除。邀請人與受邀人有尚未到期的相同雜湊時,`matching-ip-action` 的行為如下: @@ -76,7 +76,7 @@ Invitation、Eligibility、Code Rotation 與 Storage Migration 會留下 actor 玩家登入會補發自己的 `PENDING` Reward。玩家離線或 Vault Economy 不可用時維持 `PENDING`。插件啟動會先把上次中斷於 `PROCESSING` 的 Action 轉成 `UNCERTAIN`;這類外部結果不得自動重試,必須由管理員檢查後決定。 -背景 executor 執行 SQLite/MySQL 與 Qualification/Reward orchestration;Bukkit、聊天、指令、訊息與 Vault 操作只在 server main thread 執行。停用時會停止接受新工作並有界等待,不會讓背景執行緒同步等待主執行緒。 +背景 executor 執行 SQLite/MySQL 與 Qualification/Reward orchestration。Spigot/Paper 的 Bukkit 工作回到主執行緒;Folia 的全域工作走 global scheduler,玩家互動與資格取值走玩家 entity scheduler。Vault 的 Folia provider 相容性仍須個別驗證。停用時會停止接受新工作並有界等待,不會讓背景執行緒同步等待伺服器工作執行緒。 ## 人工驗收 diff --git a/docs/spec/invitecode-1.0.md b/docs/spec/invitecode-1.0.md index 37b4f7a..2a85662 100644 --- a/docs/spec/invitecode-1.0.md +++ b/docs/spec/invitecode-1.0.md @@ -10,7 +10,7 @@ InviteCode 在一名 Inviter 與一名 Invitee 之間建立一筆持久的 Invit - 一名 Invitee 最多只能有一名 Inviter;一名 Inviter 可以有多名 Invitee。 - 玩家只有在沒有 Invitation、尚未成為 Inviter,且仍在 Claim Window 內時才可 Claim。 - First Seen At 是 InviteCode 首次觀察到該玩家的時間;Claim Window 預設為 24 小時。 -- Claim 必須經過 30 秒內完成的確認,確認畫面顯示目前的 Inviter 名稱與邀請碼。 +- Claim 必須經過預設 60 秒內完成的確認,確認畫面顯示目前的 Inviter 名稱與邀請碼;期限可在設定中調整,並由伺服器執行。 - Claimed Invitation 只能成為 Qualified Invitation 一次;Qualification 為永久狀態。 - 一般玩家不能撤銷 Invitation。可稽核的管理操作支援 Unlink、Eligibility Reset、未 qualified Invitation 的 Transfer,以及 Force Qualification。 @@ -19,7 +19,7 @@ InviteCode 在一名 Inviter 與一名 Invitee 之間建立一筆持久的 Invit - 預設使用唯一的六字元十六進位 Color Invite Code。 - Minecraft 1.16 以上版本顯示邀請碼實際代表的 RGB 顏色;舊版 client 使用最接近的 legacy color。 - 未來可選擇啟用 Crockford Base32 與經過驗證的 custom code。 -- 有對應能力的新版 Paper 與 Spigot 伺服器使用原生 Dialog 文字輸入。 +- 有對應能力的新版 Paper 與 Spigot 伺服器使用原生 Dialog 文字輸入,並以第二個 Dialog 顯示邀請摘要與同意/不同意選項。按鈕文字與提示可設色;原生按鈕底色由客戶端決定。確認畫面顯示期限,不逐秒刷新。 - 舊版伺服器使用一次性的私密聊天輸入,timeout 為 60 秒。 - 所有版本都保留 `/invitecode claim `。 diff --git a/docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md b/docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md index 9858699..ccb17c3 100644 --- a/docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md +++ b/docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md @@ -106,10 +106,27 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 | `issue12-folia-regions-3`、`issue12-folia-chat-1`/`89DE0B80DD950EE2942766F11E1B4EB3B0B6F0FE3EBAF5984BE36BB525BF0BAC` | 兩個獨立實例通過;前者設定 Folia 2 條 region 排程執行緒,將兩名玩家傳送至相距約兩萬格的區域後並行執行 `/ic status`,再完成原本 Claim/Reward 流程;後者使用私密聊天輸入完成同一流程,log 未刊出邀請碼聊天內容 | | `issue12-folia-final4`/`FF187679BD246A30BC76A573C16179363D3A79909C0595FF97F25A13065661BC` | 最終 JAR 在同一全新實例結合 Folia 2 條 region 執行緒、相距約兩萬格玩家的並行 `/ic status`、私密聊天輸入、Claim/Qualification、重啟後離線 Reward 補發與 Stats;runner 回報 `PASS`,正常停機 | -較早同一個 `89DE0B80...` JAR 在全新的 `issue12-final-spigot-188` 與 `issue12-final-paper-262` 實例通過相同 Code、Claim、Confirmation、Qualification、重啟、離線 Reward 與 Stats 流程。最後的 `FF187679...` JAR 亦在全新 `issue12-spigot-final4` 與 `issue12-paper-final4` 實例完成上述完整流程,兩者 runner 均回報 `PASS`。以上皆使用 loopback、offline、已接受 EULA 的 TestLab 實例及 SQLite。各 runner 正常關閉自己啟動的服務。尚未驗證 Folia 上的原生 Dialog 畫面、Vault/PlaceholderAPI 與第三方 provider 的執行緒相容性,也未涵蓋不同 Folia 版本或長時間負載。這些限制不能由合成玩家 `PASS` 推定通過;發行文件只能稱 **Folia 26.1.2 實驗性 smoke 通過**。 +較早同一個 `89DE0B80...` JAR 在全新的 `issue12-final-spigot-188` 與 `issue12-final-paper-262` 實例通過相同 Code、Claim、Confirmation、Qualification、重啟、離線 Reward 與 Stats 流程。最後的 `FF187679...` JAR 亦在全新 `issue12-spigot-final4` 與 `issue12-paper-final4` 實例完成上述完整流程,兩者 runner 均回報 `PASS`。以上皆使用 loopback、offline、已接受 EULA 的 TestLab 實例及 SQLite。各 runner 正常關閉自己啟動的服務。當時尚未驗證 Folia 上的原生 Dialog 畫面、Vault/PlaceholderAPI 與第三方 provider 的執行緒相容性,也未涵蓋不同 Folia 版本或長時間負載;下節補記 PlaceholderAPI 與 Dialog 封包的有限驗證。這些限制不能由合成玩家 `PASS` 推定通過;發行文件只能稱 **Folia 26.1.2 實驗性 smoke 通過**。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 +### 最終 Folia Placeholder 與原生 Dialog 封包補驗 + +受測產品為已合併至 `develop` 的 `57b0f5d`,同一份 JAR SHA-256 `FF187679BD246A30BC76A573C16179363D3A79909C0595FF97F25A13065661BC`。這輪只調整測試 fixture 與驗收文件,沒有修改產品 JAR。各測試使用新的 loopback/offline TestLab 實例,runner 完成後停止自己啟動的伺服器。 + +| 全新實例 | Profile/情境 | 自動驗證結果 | +| --- | --- | --- | +| `issue12-folia-papi-final1` | Folia 26.1.2、PlaceholderAPI 2.12.3、測試 expansion | `PASS`:未達資格、Console 切換值、重新登入後達資格、重啟後維持資格 | +| `issue12-paper-papi-regression1` | Paper 1.20.6、同一 Placeholder fixture | `PASS`:同上四項;客戶端仍有已知非致命 protodef 解析警告 | +| `issue12-folia-dialog-protocol3` | Folia 26.1.2、`input-mode: DIALOG` | `PASS`:兩次收到原生 `show_dialog` 封包,各次 `/ic cancel` 後 Invitation 仍不存在;接續 command Claim/Confirm、資格、重啟後離線 Reward 與 Stats | +| `issue12-paper-dialog-protocol1` | Paper 26.2、`input-mode: DIALOG` | `PASS`:同上;伺服器另有既知 Windows OSHI/Perflib 雜訊,未見 InviteCode exception | + +Folia 的 Placeholder 測試 probe 將玩家名稱與 UUID 於登入事件快取,Console 只切換 thread-safe 測試值;實際 Placeholder 展開由 InviteCode 在玩家 entity scheduler 觸發。這支持上述特定組合,不能推定任意 Placeholder expansion 都具 Folia 相容性。現有 Vault 1.7.3-b131 與 EssentialsX 2.21.2 JAR 未宣告 Folia 支援,[EssentialsX 官方發行說明](https://github.com/EssentialsX/Essentials/releases)亦明示不支援 Folia,因此沒有在 Folia 強行執行 Vault 存款測試。 + +曾嘗試由合成客戶端送出自造的 Dialog submit 封包,Folia 因封包格式不合法踢出客戶端。這只能歸類為測試客戶端限制,不能當成 InviteCode 缺陷或原生提交成功的證據;最終 runner 改為只驗證伺服器送出的 Dialog 封包和 command 取消後的狀態,並在伺服器停止後才輸出 `PASS`。原生按鈕、Esc、輸入與視覺呈現仍列入[最終真人驗收](../final-human-acceptance.md)。 + +已準備 `issue12-human-paper-262`、`issue12-human-spigot-188`、`issue12-human-folia-2612` 三個獨立實例。它們的 JAR 雜湊均與上述基線相符,`AUTO` 輸入模式、繁體中文、同 IP 測試例外與登入一天資格設定已核對;三者未啟動、未建立玩家 DB,62620/51888/63620 埠均未在監聽。這只是待測環境準備完成,不能計入真人驗收通過。 + ## SQLite 遷移故障與復原(伺服器層級) 新增 `migration-recovery.cjs`,在全新 `issue12-migration-rollback1-188` 實例使用 Spigot 1.8.8、`local-8` 與同一份產品 JAR(SHA-256 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`)。初始化到 SQLite v8 並正常停機後,測試程式只在此隔離資料庫建立合成 v7 fixture:保留舊資料、加入 `MigrationSentinel` 玩家,並於既有 `invitecode_players` 表先建立 `invitecode_network_hash_expiry` 索引。這是為了讓插件 v8 遷移先成功 `CREATE TABLE`,再於 `CREATE INDEX` 發生名稱衝突。fixture 由測試程式建造,**不是**舊版外掛實際產生的資料庫,也不代表曾有正式使用者需要遷移。 @@ -126,4 +143,4 @@ Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數 這是**合成的已提交 DDL 中斷狀態**,不是在 MySQL 實際執行 DDL 時殺掉 JVM;它證明產品在該持久化邊界的安全拒絕、續建與重啟持久性,不證明任意時間點的 crash 都能復原。測試採本機 `tls-mode: REQUIRED`,仍未驗證 `VERIFY_IDENTITY`。兩次 Paper 及隔離 MySQL 服務均已正常關閉,62060/63384 埠已釋放;專用 database 保留作為測試證據。 -目前 Spigot/Paper 的啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console 指令、外部服務偵測,以及 Spigot 1.8.8、Paper 1.20.6/1.21.8/26.2 的合成玩家 Claim/離線 `MESSAGE` Reward 已有證據。Spigot 1.8.8 通過 Reward 中斷後的 `UNCERTAIN` 復原與兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款;SQLite 與 MySQL 也完成上述伺服器層級遷移復原測試。Folia 26.1.2 的實驗性啟動、玩家 Claim/Chat、跨 region 狀態查詢及三種 Reward Action smoke 已通過;原生 Dialog 視覺、Folia 第三方整合及最終人工觀感仍未驗證,不得據此宣布 1.0 發行 gate 通過。 +目前 Spigot/Paper 的啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console 指令、外部服務偵測,以及 Spigot 1.8.8、Paper 1.20.6/1.21.8/26.2 的合成玩家 Claim/離線 `MESSAGE` Reward 已有證據。Spigot 1.8.8 通過 Reward 中斷後的 `UNCERTAIN` 復原與兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款;SQLite 與 MySQL 也完成上述伺服器層級遷移復原測試。Folia 26.1.2 的實驗性啟動、玩家 Claim/Chat、跨 region 狀態查詢、三種 Reward Action smoke、特定 PlaceholderAPI expansion,以及原生 Dialog 開啟封包均已通過;原生 Dialog 畫面與按鈕、Folia Vault provider 及最終人工觀感仍未驗證,不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/evidence/2026-09-25-issue-12-ux-retest.md b/docs/testing/evidence/2026-09-25-issue-12-ux-retest.md new file mode 100644 index 0000000..10814c1 --- /dev/null +++ b/docs/testing/evidence/2026-09-25-issue-12-ux-retest.md @@ -0,0 +1,15 @@ +# Issue #12:聊天室互動 UX 修正與回歸 + +使用者完成 Paper 26.2、Spigot 1.8.8、Folia 26.1.2 第一輪真人功能測試後,回報主要流程大致正常,但需要可複製的邀請碼、可點擊的確認/取消選項,以及聊天輸入時的 `cancel`。排版與美術列為後續討論。本輪沿用 `codex/test/final-release-acceptance`,沒有修改既有三個真人測試實例或其資料。 + +受測產品 JAR:`InviteCode-0.1.0-SNAPSHOT.jar`,SHA-256 `B586955C62FAE5F09F284D94203D674D84E90E8BF8F6E7B6230C496466689813`。測試以 mise 選擇 Java 11 建置,再以各實例指定的 Java 8 或 25 執行伺服器。 + +`ClaimInteractionSessionsTest` 與 `PlayerChatActionsTest` 先於未實作時呈紅燈,實作後通過;`mise exec -- .\gradlew.bat check shadowJar --console=plain` 通過,包含 Java 8 bytecode 與插件 JAR 結構檢查。互動選項以 Spigot 1.8.8 的 Bungee 聊天 API 編譯:舊版 `SUGGEST_COMMAND` 把原始碼填入聊天列;有 `COPY_TO_CLIPBOARD` 的新版 runtime 則選用直接複製。單元測試確認舊版動作及紅綠按鈕的 `RUN_COMMAND` 目標,真人剪貼簿與點擊仍需驗收。 + +| 隔離實例 | 合成玩家結果 | +| --- | --- | +| `issue12-ux-spigot-188` | `PASS`:複製入口文字、聊天 `CaNcEl` 私密取消後 Invitation 為 none、再次 Claim、確認選項文字、資格、重啟及離線 Reward | +| `issue12-ux-paper-262` | `PASS`:複製入口與確認選項文字、Claim、資格、重啟及離線 Reward;有先前已知的 Windows OSHI/Perflib 雜訊,未見 InviteCode exception | +| `issue12-ux-folia-2612` | `PASS`:複製入口文字、聊天 `CaNcEl` 私密取消後 Invitation 為 none、再次 Claim、確認選項文字、資格、重啟及離線 Reward | + +三個合成實例使用新建 loopback/offline TestLab、同一 JAR 雜湊;runner 已停止啟動的伺服器。另建立三個空白的第二輪真人驗收實例 `issue12-ux-human-paper-262`、`issue12-ux-human-spigot-188`、`issue12-ux-human-folia-2612`,JAR 雜湊相同,尚未啟動。操作與待驗收項目見[最終真人驗收](../final-human-acceptance.md)。合成玩家只驗證元件文字已到達,沒有實際點擊剪貼簿或按鈕,故 Issue #12 的 UX 驗收仍未完成。 diff --git a/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.json b/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.json new file mode 100644 index 0000000..151a981 --- /dev/null +++ b/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.json @@ -0,0 +1,734 @@ +{ + "artifactTree": "ec68d7abe31dba52333a466ee0ed9e8526c2fd82", + "baseDevelop": "10ce7b5a3472efb71baf3239c97e51df57ab5584", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "junit": { + "suites": 51, + "tests": 230, + "skipped": 0, + "failures": 0, + "errors": 0 + }, + "instances": [ + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-folia-latest", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-folia-latest", + "profile": "folia-latest", + "minecraftVersion": "26.1.2", + "serverBuild": "8", + "javaAlias": "local-25", + "port": 63620, + "serverSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-1-20-6", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-paper-1-20-6", + "profile": "paper-1.20.6", + "minecraftVersion": "1.20.6", + "serverBuild": "151", + "javaAlias": "local-21", + "port": 62060, + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-1-21-8", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-paper-1-21-8", + "profile": "paper-1.21.8", + "minecraftVersion": "1.21.8", + "serverBuild": "60", + "javaAlias": "local-21", + "port": 62180, + "serverSha256": "8DE7C52C3B02403503D16FAC58003F1EFEF7DD7A0256786843927FA92EE57F1E", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-latest", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-paper-latest", + "profile": "paper-latest", + "minecraftVersion": "26.2", + "serverBuild": "129", + "javaAlias": "local-25", + "port": 62620, + "serverSha256": "B1D8F6BFA1B6101FA8E947B53041CB3BDF5540E7B83B6547CA19BA7EDEFEB083", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-12-2", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-spigot-1-12-2", + "profile": "spigot-1.12.2", + "minecraftVersion": "1.12.2", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51222, + "serverSha256": "CA59A730F5B1C2E85A2ABE907D9689CC2636BE0200F333C1E1B87E2D620D8513", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-16-5", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-spigot-1-16-5", + "profile": "spigot-1.16.5", + "minecraftVersion": "1.16.5", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51650, + "serverSha256": "C738DCB9AC8114228107BB4CDA97BFEC62A243C99FE0E7C6CAF9D424BD1EF93C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-8-8", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-spigot-1-8-8", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-latest", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-1002-spigot-latest", + "profile": "spigot-latest", + "minecraftVersion": "26.2", + "serverBuild": "local-buildtools", + "javaAlias": "local-25", + "port": 52620, + "serverSha256": "27A348344D42ED2BA76AAD6FCEEBB7A26365F09C9AC6EEA4C0918BA83BA7E3DD", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-chat188-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-chat188-1002", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-dialog262-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-dialog262-1002", + "profile": "paper-latest", + "minecraftVersion": "26.2", + "serverBuild": "129", + "javaAlias": "local-25", + "port": 62620, + "serverSha256": "B1D8F6BFA1B6101FA8E947B53041CB3BDF5540E7B83B6547CA19BA7EDEFEB083", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-dialogfolia-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-dialogfolia-1002", + "profile": "folia-latest", + "minecraftVersion": "26.1.2", + "serverBuild": "8", + "javaAlias": "local-25", + "port": 63620, + "serverSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-flow188-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-flow188-1002", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-flow262-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-flow262-1002", + "profile": "paper-latest", + "minecraftVersion": "26.2", + "serverBuild": "129", + "javaAlias": "local-25", + "port": 62620, + "serverSha256": "B1D8F6BFA1B6101FA8E947B53041CB3BDF5540E7B83B6547CA19BA7EDEFEB083", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-flowfolia-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-flowfolia-1002", + "profile": "folia-latest", + "minecraftVersion": "26.1.2", + "serverBuild": "8", + "javaAlias": "local-25", + "port": 63620, + "serverSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-json-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-json-1002", + "profile": "paper-1.20.6", + "minecraftVersion": "1.20.6", + "serverBuild": "151", + "javaAlias": "local-21", + "port": 62060, + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-mark-delivered-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-mark-delivered-1002", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-mysql2-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-mysql2-1002", + "profile": "paper-1.20.6", + "minecraftVersion": "1.20.6", + "serverBuild": "151", + "javaAlias": "local-21", + "port": 62060, + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-papi-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-papi-1002", + "profile": "paper-1.20.6", + "minecraftVersion": "1.20.6", + "serverBuild": "151", + "javaAlias": "local-21", + "port": 62060, + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-retry-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-retry-1002", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-sqlite-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-sqlite-1002", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "serverBuild": "local-buildtools", + "javaAlias": "local-8", + "port": 51888, + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + }, + { + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-vault2-1002", + "schemaVersion": 2, + "audience": "Agent", + "project": "InviteCode", + "instance": "issue12-final-vault2-1002", + "profile": "paper-1.21.8", + "minecraftVersion": "1.21.8", + "serverBuild": "60", + "javaAlias": "local-21", + "port": 62180, + "serverSha256": "8DE7C52C3B02403503D16FAC58003F1EFEF7DD7A0256786843927FA92EE57F1E", + "pluginFile": "InviteCode-0.1.0-SNAPSHOT.jar", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C" + } + ], + "runs": [ + { + "profile": "spigot-1.8.8", + "instance": "issue12-final-1002-spigot-1-8-8", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "javaAlias": "local-8", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-8-8\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\spigot-1.8.8-smoke.log" + }, + { + "profile": "spigot-1.12.2", + "instance": "issue12-final-1002-spigot-1-12-2", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "CA59A730F5B1C2E85A2ABE907D9689CC2636BE0200F333C1E1B87E2D620D8513", + "javaAlias": "local-8", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-12-2\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\spigot-1.12.2-smoke.log" + }, + { + "profile": "spigot-1.16.5", + "instance": "issue12-final-1002-spigot-1-16-5", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "C738DCB9AC8114228107BB4CDA97BFEC62A243C99FE0E7C6CAF9D424BD1EF93C", + "javaAlias": "local-8", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-16-5\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\spigot-1.16.5-smoke.log" + }, + { + "profile": "spigot-latest", + "instance": "issue12-final-1002-spigot-latest", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "27A348344D42ED2BA76AAD6FCEEBB7A26365F09C9AC6EEA4C0918BA83BA7E3DD", + "javaAlias": "local-25", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-latest\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\spigot-latest-smoke.log" + }, + { + "profile": "paper-1.20.6", + "instance": "issue12-final-1002-paper-1-20-6", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "javaAlias": "local-21", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-1-20-6\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\paper-1.20.6-smoke.log" + }, + { + "profile": "paper-1.21.8", + "instance": "issue12-final-1002-paper-1-21-8", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "8DE7C52C3B02403503D16FAC58003F1EFEF7DD7A0256786843927FA92EE57F1E", + "javaAlias": "local-21", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-1-21-8\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\paper-1.21.8-smoke.log" + }, + { + "profile": "paper-latest", + "instance": "issue12-final-1002-paper-latest", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "B1D8F6BFA1B6101FA8E947B53041CB3BDF5540E7B83B6547CA19BA7EDEFEB083", + "javaAlias": "local-25", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-paper-latest\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\paper-latest-smoke.log" + }, + { + "profile": "folia-latest", + "instance": "issue12-final-1002-folia-latest", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "javaAlias": "local-25", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-folia-latest\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\folia-latest-smoke.log" + }, + { + "result": "PASS", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "instance": "issue12-final-flow188-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\flow188.log" + }, + { + "result": "PASS", + "profile": "paper-latest", + "minecraftVersion": "26.2", + "instance": "issue12-final-flow262-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\flow262.log" + }, + { + "result": "PASS", + "profile": "folia-latest", + "minecraftVersion": "26.1.2", + "instance": "issue12-final-flowfolia-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "separate-region-status", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\flowfolia.log" + }, + { + "result": "PASS", + "scenario": "reward-interruption", + "resolution": "mark-delivered", + "instance": "issue12-final-mark-delivered-1002", + "profile": "spigot-1.8.8", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "markerCount": 1, + "checks": [ + "effect-entered", + "abrupt-halt", + "restart-recovery", + "no-automatic-retry", + "admin-resolution", + "resolution-after-restart" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\mark-delivered.log" + }, + { + "result": "PASS", + "scenario": "reward-interruption", + "resolution": "retry", + "instance": "issue12-final-retry-1002", + "profile": "spigot-1.8.8", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "markerCount": 2, + "checks": [ + "effect-entered", + "abrupt-halt", + "restart-recovery", + "no-automatic-retry", + "admin-resolution", + "resolution-after-restart" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\retry.log" + }, + { + "result": "PASS", + "scenario": "sqlite-migration-recovery", + "instance": "issue12-final-sqlite-1002", + "profile": "spigot-1.8.8", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "no-auto-upgrade", + "maintenance", + "ddl-rollback", + "sentinel-preserved", + "explicit-recovery", + "restart-durable", + "secret-preserved" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\sqlite-recovery.log" + }, + { + "result": "PASS", + "scenario": "mysql-initialization-recovery", + "instance": "issue12-final-mysql2-1002", + "database": "invitecode_issue12_test_final_mysql2_1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "malformed-table-fails-closed", + "checksum-mismatch-fails-closed", + "applying-ledger-resumes", + "sentinel-preserved", + "applied-ledger-durable", + "no-local-secret" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\mysql-service-retry\\recovery.log" + }, + { + "result": "PASS", + "scenario": "Vault", + "instance": "issue12-final-vault2-1002", + "profile": "paper-1.21.8", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "balance-before-0", + "qualification", + "vault-deposit-37.5", + "balance-after-restart-37.5" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\vault2.log" + }, + { + "result": "PASS", + "scenario": "Placeholder", + "instance": "issue12-final-papi-1002", + "profile": "paper-1.20.6", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "placeholder-unsatisfied", + "placeholder-ready", + "qualified-after-rejoin", + "qualified-after-restart" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\papi.log" + }, + { + "result": "PASS", + "profile": "paper-1.20.6", + "minecraftVersion": "1.20.6", + "instance": "issue12-final-json-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\json-flow.log" + }, + { + "result": "PASS", + "profile": "spigot-1.8.8", + "minecraftVersion": "1.8.8", + "instance": "issue12-final-chat188-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "private-chat-input", + "chat-cancel", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\chat188.log" + }, + { + "result": "PASS", + "profile": "paper-latest", + "minecraftVersion": "26.2", + "instance": "issue12-final-dialog262-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "input-and-confirmation-dialog-packets", + "command-cancel-preserves-state", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\dialog262.log" + }, + { + "result": "PASS", + "profile": "folia-latest", + "minecraftVersion": "26.1.2", + "instance": "issue12-final-dialogfolia-1002", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "checks": [ + "input-and-confirmation-dialog-packets", + "command-cancel-preserves-state", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\dialogfolia.log" + }, + { + "profile": "paper-1.20.6", + "instance": "issue12-final-json-1002", + "backend": "JSON", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "javaAlias": "local-21", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-json-1002\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\json-smoke-retry.log" + }, + { + "profile": "spigot-1.8.8", + "instance": "issue12-final-1002-spigot-1-8-8", + "backend": "SQLITE", + "pluginSha256": "BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C", + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "javaAlias": "local-8", + "doctorActive": true, + "placeholderApi": false, + "vaultEconomy": false, + "consoleCommands": [ + "ic admin doctor", + "ic help", + "ic reload" + ], + "logPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Agent\\InviteCode\\issue12-final-1002-spigot-1-8-8\\logs\\latest.log", + "runnerLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-final-release-acceptance\\invitecode-plugin\\build\\review-integration\\ec68d7a\\retest\\zh-smoke-retry.log" + } + ] +} diff --git a/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.md b/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.md new file mode 100644 index 0000000..3698478 --- /dev/null +++ b/docs/testing/evidence/2026-10-02-issue-12-final-artifact-retest.md @@ -0,0 +1,66 @@ +# Issue #12:同一整合 JAR 的隔離複驗 + +## 產物與範圍 + +本輪修正測試 runner 與文件,產品 runtime 沒有修改。沿用 `codex/test/final-release-acceptance`;預定目標為 `develop`,本輪沒有 push、PR、merge、tag 或發布。 + +受測產品是 `develop` 的 `10ce7b5a3472efb71baf3239c97e51df57ab5584` 與 UX 分支形成的整合 tree `ec68d7abe31dba52333a466ee0ed9e8526c2fd82`。所有伺服器情境均使用同一份 `InviteCode-0.1.0-SNAPSHOT.jar`,SHA-256: + +```text +BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C +``` + +JAR 保留於本 Worktree 的 `invitecode-plugin/build/review-integration/ec68d7a/`;原始 runner log 保留於其 `retest/`。可提交的[證據 manifest](./2026-10-02-issue-12-final-artifact-retest.json)記錄每次通過結果、實例路徑、實際核心 build、Java、port 與完整核心/插件雜湊;主 Agent 重新讀取並核對實體 JAR 雜湊,沒有只信任 metadata。 + +所有新實例都位於 `D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\`,使用獨立資料與 loopback/offline mode。測試前確認 port 未被監聽,依既有 EULA 授權建立新實例;不覆寫或操作 Human 世界/插件資料,不接入人工 Velocity。既有 Legacy 實例僅提供已取得第三方 JAR 的唯讀來源。Spigot 核心沿用 BuildTools `Server` 的既有編譯產物,本輪未重新編譯核心。 + +## Runner 修正與審查 + +- PowerShell 改用 `InstanceHarbor.psm1` API 並明確傳入 `-Audience Agent`;新增 `-InstanceHarborRoot`,保留舊 `-TestLabRoot` alias 與環境變數 fallback。明確指定無效 root 時直接拒絕。 +- Node runner 共用實體路徑檢查,要求 `workspace.json` schema 2、Agent audience、InviteCode project 與實例名稱相符;拒絕 Human、Legacy、路徑跳脫、Windows ADS 及根目錄 junction。保留原有 fresh-data、EULA、JAR 雜湊、profile、port、loopback/offline 檢查。 +- SQLite 故障 fixture 維持 v7→v8 的索引衝突,完整復原至 v9 並核對保留邀請碼表;MySQL 維持 V1 `APPLYING` 故障 fixture,復原後核對 V1/V2 checksum、`APPLIED` 與 14 張表。 +- 修正第三方/中斷測試對舊單行 confirmation 的假設,改核對新版邀請人、邀請碼與同意/不同意提示;MySQL CLI 多行結果正規化 Windows CRLF。Console smoke 同時接受繁體中文與英文訊息。 +- 邊界驗證採 RED→GREEN:PowerShell 行為測試通過;Node 五項測試通過且沒有 skip,包含實例及 instances 根目錄 junction 逃逸。所有 PowerShell/CJS 語法及 `git diff --check` 通過。 +- 獨立靜態審查發現 P2 根目錄 junction 缺口,補測與修正後再次確認解除;沒有未處理的 Critical/High 問題。 + +## 同產物結果 + +| 核心 profile | 實際 Minecraft/build | Java | SQLite 啟動、doctor、help、reload、stop | +| --- | --- | --- | --- | +| Spigot 1.8.8 | 1.8.8/local-buildtools | local-8 | 通過 | +| Spigot 1.12.2 | 1.12.2/local-buildtools | local-8 | 通過 | +| Spigot 1.16.5 | 1.16.5/local-buildtools | local-8 | 通過 | +| Spigot latest | 26.2/local-buildtools | local-25 | 通過 | +| Paper 1.20.6 | 1.20.6/151 | local-21 | 通過 | +| Paper 1.21.8 | 1.21.8/60 | local-21 | 通過 | +| Paper latest | 26.2/129 | local-25 | 通過 | +| Folia latest | 26.1.2/8 | local-25 | 通過,維持實驗性 | + +其他通過情境: + +- Spigot 1.8.8、Paper 26.2、Folia 26.1.2:邀請碼、Claim、Confirm、Qualification、重啟後 Pending Reward、Inviter 登入補發及 Stats;Folia 額外驗證兩個分離 region 的 Status。 +- Spigot 1.8.8 私密聊天輸入及大小寫混合 `CaNcEl` 取消;Paper/Folia 原生輸入與確認 Dialog 封包、指令取消不建立 Invitation,後續獎勵與重啟流程。 +- Reward 外部效果後故意 halt 83:重啟標為 UNCERTAIN、不自動重播;管理員 `mark-delivered` 保持一次效果,`retry` 明確產生第二次效果,處置經重啟保留。 +- SQLite:啟動不偷偷升級舊 schema、維護模式、DDL 交易回滾、哨兵玩家保留、明確遷移到 v9、重啟持久化與原 key 保留。 +- MySQL 8.4.11:錯誤表結構與 checksum 均拒絕初始化;修復後續建並保留哨兵玩家,兩個 ledger 版本與 14 張表經重啟保留,不建立本機 SQLite 或 key。 +- Paper 1.21.8/Vault 1.7.3/EssentialsX 2.21.2:餘額由 0 成為 37.5,重啟後仍為 37.5。 +- Paper 1.20.6/PlaceholderAPI 2.12.3:資格先不成立,測試 expansion 切換後重新登入達資格,Reward 與狀態經重啟保留。 +- Paper 1.20.6/JSON:完整邀請及離線獎勵流程,重啟後 Console doctor/help/reload、JSON 與 key 存在。修正雙語 smoke 後,英文 JSON 與繁體中文 Spigot 均再次通過。 + +整合來源快照以已核對的 `mise java@local-8` 執行 Gradle Wrapper `check --rerun-tasks --no-daemon`,提供專用 loopback MySQL 測試服務:51 個 suite、230 項測試、0 failures、0 errors、0 skipped;Java 8 bytecode 與插件 JAR 檢查均通過。先前跳過的 MySQL 測試已補齊。此建置使用整合來源,沒有更換上方所有 runtime 測試使用的固定 JAR。 + +## 曾失敗的測試與限制 + +保留首輪失敗 log,不將其當作通過證據:Vault runner 等待舊分號串接 confirmation、MySQL CLI ledger 的 CRLF 比較、英文 JSON smoke 的中文限定 regex;修正後分別以全新 Vault/MySQL 實例或正常停機的同一 JSON 隔離實例通過複驗。最初含點號的名稱被 smoke 名稱限制拒絕,該未啟動實例沒有覆寫;合法 profile 名稱現可保留點號。 + +Paper 26.2 的 Windows OSHI/Perflib 計數器與 OSProcess 錯誤出自核心環境,Paper 1.20.6 合成客戶端也有 protodef 封包解析警告;另有 JVM Unsafe/第三方 deprecation 警告。上述 log 已保留;不當作 InviteCode 的 linkage 缺陷,也不隱藏。插件流程與持久化斷言均完成,沒有為本任務修改 Windows registry 或第三方依賴。 + +測試結束後正常停止各 runner 的伺服器與隔離 MySQL;矩陣八個 port 及 MySQL 63384/63385 皆沒有 listener。保留實例、測試資料與 log 作為證據,沒有清理固定 Human 伺服器。 + +同產物的自動矩陣與復原證據缺口已解除。Folia 第三方整合仍有限制,本輪未複驗 Folia Vault 或 PlaceholderAPI;Paper 的結果不代表 Folia 已通過。合成客戶端不能證明原生按鈕點擊、外觀、RGB 或剪貼簿操作;這些真人結果仍綁定先前受測 JAR,見[真人紀錄](../final-human-acceptance.md)。本輪沒有改動 runtime,不要求使用者重做已確認的完整三台 UX 流程;正式發行前仍須對齊最後安裝產物與人工證據,不能宣稱新整合 JAR 已真人驗收。 + +## 下一步與 Git 交付 + +依 [Issue #12 的驗收條件](https://github.com/Command1264/InviteCodeKt/issues/12)及 [Roadmap #1 的發行門檻](https://github.com/Command1264/InviteCodeKt/issues/1),下一步是審閱本輪同產物證據、授權 push 並建立目標 `develop` 的 PR。這是已有 runtime/UX 實作的交付階段,沒有新增 dependency 或需要重做的設計前置。第一個動作是針對本輪提交版本確認遠端交付授權;PR 使用 `Refs #12`,保留真人產物差異與 Folia 限制,不自動關閉 Issue 或正式發行。合併須另取得目前 HEAD 與 `develop` 的明確確認。 + +Issue #26 的跨 backend 搬移已有另一個獨立 Worktree 候選 `8c57de5`,本輪未修改或驗收它;不因 roadmap 仍列為 open 而重新實作或擅自合併。 diff --git a/docs/testing/evidence/2026-10-02-issue-12-integration-review.md b/docs/testing/evidence/2026-10-02-issue-12-integration-review.md new file mode 100644 index 0000000..e19ce3e --- /dev/null +++ b/docs/testing/evidence/2026-10-02-issue-12-integration-review.md @@ -0,0 +1,62 @@ +# Issue #12:整合審查與發行門檻核對 + +本文件記錄複驗前的審查時點。後續修正與同產物自動結果見[整合候選複驗紀錄](./2026-10-02-issue-12-final-artifact-retest.md);下列「尚須複驗」是原始發現,現況以後續證據為準。真人結果仍依受測 JAR 分開,Issue/PR 與 merge 狀態不由本機文件推定。 + +## 固定審查範圍 + +- 目標:`origin/develop`,`10ce7b5a3472efb71baf3239c97e51df57ab5584`。 +- 來源:`codex/test/final-release-acceptance`,`5d8e0e7`。 +- 共同基線:`57b0f5dbc8f1111d3a2a5e379bea7ff737ecd0c7`。 +- 差異:`git diff 10ce7b5a...5d8e0e7`;24 個檔案,638 行新增、84 行刪除。 +- `git merge-tree --write-tree` 成功,沒有衝突;暫存整合 tree 為 `ec68d7abe31dba52333a466ee0ed9e8526c2fd82`。 +- 本輪只建立整合樹及其暫存來源快照,沒有將來源或目標分支合併,沒有 remote write。 + +## Standards 軸 + +獨立靜態審查未發現可由專案規則支持的 correctness/safety 問題,也沒有具體值得列出的 code smell。變更保留 storage、privacy、reward delivery 與 Java 8 相容性邊界。主要 runtime 差異可以與最新 develop 的匿名化功能無衝突整合;這不代替真實伺服器驗證。 + +## Spec 軸 + +**P1:最終整合候選 JAR 尚未取得同產物發行矩陣證據。** Issue #12 要求「完全相同的插件 JAR 可在版本範圍兩端啟動並執行 critical user path」。舊啟動矩陣使用 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`;本輪真人 UX 操作使用 `889DAD100D56D18C425D7299FD759EAA3DD822C863CF55FF486F7D8F372EFE3C` 加外部語系修正。這些證據不能直接標為最新 develop 加 UX 的整合 JAR 已通過。 + +其餘指定 UX 項目均有對應實作,未發現明顯 scope creep。這項發現是發行證據缺口,並非已證實 runtime 缺陷。Issue #12 仍保持未完成;不以本輪審查關閉它。 + +## 主 Agent 整合驗證 + +將整合 tree 匯出至獨立暫存目錄,透過既有 Gradle Wrapper 與已核對的 `mise java@local-8` 執行 `check shadowJar --no-daemon`。建置、`verifyJava8Bytecode` 與 `verifyPluginJar` 均通過。JUnit XML 共 51 個 suite、230 項測試、0 failures、0 errors、14 skipped;跳過項目均為需要隔離 MySQL 服務的測試,本輪沒有啟動該服務。 + +整合 JAR SHA-256:`BA2D48E7EB774FAB464F41B8B468A142B1E559C4169B55DDA5EA42A89552C50C`。保留於本 Worktree 的 `invitecode-plugin/build/review-integration/ec68d7a/InviteCode-0.1.0-SNAPSHOT.jar`。產物對應上述整合 tree,尚未部署至任何固定 Human 測服,亦沒有對它取得新的真人驗收。 + +## 發行條件核對 + +| Issue #12 條件 | 現有證據與本輪結論 | +| --- | --- | +| 舊版、中間版本及新版 smoke | 舊矩陣已通過;整合 JAR 尚須複驗。 | +| 同 JAR 兩端 critical user path | 舊 UX 產物有合成與真人證據;整合 JAR 尚須複驗。 | +| SQLite 邊界與 JSON/MySQL integration | 整合快照的 SQLite/JSON 本機測試通過;MySQL 本輪跳過。伺服器層級證據仍屬舊產物。 | +| Vault/PlaceholderAPI 有/無 | 舊產物有獨立偵測及效果證據;整合 JAR 尚須代表性複驗。 | +| Folia 實驗性 smoke | 舊產物有 region、聊天、Dialog 封包與真人結果;整合 JAR 尚須 smoke,Folia Vault 仍未驗證。 | +| Reward/migration 失敗復原 | 舊產物及本機測試有證據;舊 SQLite runner 不能直接驗證 schema 9。 | +| 文件與已知限制符合證據 | 真人通過項目已記錄;舊路徑與 runner 需更新,不宣稱完整 1.0 發行通過。 | + +## 複驗工具的已知阻擋 + +1. `scripts/test-servers/synthetic-player/migration-recovery.cjs` 仍要求初始 schema 8,復原訊息也只接受版本 8;最新 develop 使用 schema 9。應保留 v7→v8 故障注入語義,同時正確建立/驗證 schema 9 的完整復原狀態。 +2. 同一 runner 硬編碼 `TestLab/instances/InviteCode` 路徑,與目前 `InstanceHarbor/instances/Agent/InviteCode` 邊界不同;`common.ps1` 自動發現也仍搜尋 TestLab。必須明確使用 Agent 實例並保留路徑、metadata、全新資料、loopback、EULA 與雜湊核對,不能只刪除安全檢查。 +3. 修正 runner 後,使用同一個整合 JAR 與新 Agent 實例複驗,不重建或覆寫 Human 測服;檢查 matrix port 是否未被使用。MySQL 必須使用專用隔離資料庫,不連到固定測服資料。 + +## 本機 PR 草稿 + +建議標題:`完成邀請碼互動與原生 Dialog 確認,補齊真人驗收紀錄` + +目標分支:`develop`。在複驗缺口解決前保持 draft,不用 `Closes #12`。 + +建議說明: + +> 邀請碼現在可直接點擊並顯示可翻譯的懸浮提示;Claim 在開啟輸入前檢查資格,聊天輸入支援 cancel。新版原生 Dialog 與舊版聊天提供同意/不同意確認、期限與紅綠文字,確認期限提示移除末尾冒號。三台固定 Human 測服的確認畫面、按鈕、逾時及重啟後資料保留已由使用者確認通過。 +> +> 與 develop 的匿名化功能可無衝突整合。整合快照已通過 Java 8 check、shadowJar、bytecode 及 JAR 驗證;230 項測試沒有失敗,14 項隔離 MySQL 測試在本輪跳過。最終整合 JAR 的跨版本與外部整合複驗仍待補齊,Folia 第三方整合保留實驗性限制。Refs #12;詳見本審查紀錄。 + +## 建議下一步 + +依 Issue #12「驗收條件」,先修正 InstanceHarbor Agent 路徑與 SQLite schema 9 的測試 runner,再以固定整合 JAR 補跑兩端 critical path、migration/Reward recovery 及代表性 JSON/MySQL/第三方整合。前置條件是維持獨立測試資料、未使用的 port 與已驗證核心;本輪不需要使用者重做剛通過的三台 UX 操作。最後依影響決定是否還需要最終產物的真人快速複驗,並取得 push/PR 及指定版本 merge 授權。 diff --git a/docs/testing/final-human-acceptance.md b/docs/testing/final-human-acceptance.md new file mode 100644 index 0000000..5caf892 --- /dev/null +++ b/docs/testing/final-human-acceptance.md @@ -0,0 +1,75 @@ +# InviteCode 最終真人驗收 + +## 同產物自動複驗 + +2026-10-02 的整合候選自動結果見[同 JAR 複驗紀錄](./evidence/2026-10-02-issue-12-final-artifact-retest.md)。該輪僅使用新的 InstanceHarbor Agent 實例,沒有部署至下述固定 Human 測服。下述使用者已確認的真人結果維持有效,但受測產物不同;不可將自動封包檢查稱為整合 JAR 的真人畫面驗收。本輪只修正測試 runner 與文件,沒有改動產品 runtime,無須重做剛通過的完整三台 UX 流程。 + +歷史區段中的 `start.ps1`/TestLab 路徑僅供追溯,現在專案 runner 明確只操作 Agent 實例。固定 Human 測服的操作依 InstanceHarbor 現行管理入口與本節核對過的 `instances/Human/InviteCode` 路徑進行,不使用自動測試腳本。 + +## 2026-10-02 固定測服複驗回饋 + +目前真人操作使用 InstanceHarbor 的 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\` 下三台固定測服:`invitecode-spigot-1.8.8`、`invitecode-paper-26.2`、`invitecode-folia-26.1.2`,各自保留原有世界與插件資料;下方舊 TestLab 路徑是歷史紀錄。 + +使用者在同一台電腦以兩個帳號操作時回報同網路 Claim 被拒絕;Folia 當次 log 亦有相符拒絕紀錄,因此同網路 `DENY` 拒絕項目記為真人通過,不推論其他網路策略或三台完整功能均通過。三台固定測服的 `config.yml` 已備份並暫時改成 `anti-abuse.matching-ip-action: ALLOW`,供單機雙帳號後續驗收;產品預設保持 `DENY`。完成測試後把此值改回 `DENY` 並執行 `/ic reload`。 + +確認期限文字移除中文及英文末尾冒號,包含聊天確認與原生 Dialog 的 prompt。既有測服的 `messages/zh_TW.yml`、`messages/en_US.yml` 先備份再同步修正;這些文字和網路策略可透過 `/ic reload` 套用,無須替換運行中的 JAR。此次受測為既有 JAR `889DAD100D56D18C425D7299FD759EAA3DD822C863CF55FF486F7D8F372EFE3C` 加上 `13d9c9c` 的外部語系修正,並非其他分支的新 JAR。 + +使用者於本輪確認 Folia 26.1.2、Paper 26.2、Spigot 1.8.8 的確認畫面、同意/不同意、逾時與重啟後資料保留「全部通過」。這些真人項目記為通過;期限排版由本輪確認畫面複驗涵蓋。同網路 `ALLOW` 測試完成後恢復為 `DENY`。此結果不替代其餘 Issue #12 發行門檻審查,也不代表 merge 或正式發行授權。下方尚待/暫緩敘述為歷史各輪交接狀態,以本節的已確認項目為準。 + +此清單處理合成玩家無法判斷的畫面與互動。Issue #12 的自動證據見[測試矩陣](./evidence/2026-09-24-issue-12-startup-matrix.md)。使用者已於三個版本完成第一輪真人功能測試,回報主要流程大致正常,並提出下方 UX 修正;新版本仍待真人驗收,不宣稱 1.0 發行門檻完成,也不更新 `main` 或發布 JAR。 + +目前依使用者決定,第三輪與後續真人驗收暫緩,待多插件、多伺服器的真人驗收管理方案就緒後集中執行。自動驗證的通過結果與真人驗收狀態分開記錄;這項暫緩不阻擋獨立的本機開發與自動檢查,也不表示 Issue #12 已完成驗收。下列實例與步驟保留作為當前版本的交接資料;正式開始真人驗收前,須先核對當時的分支 HEAD、JAR 雜湊、實例內容與新方案的啟動/路由方式,再決定是否沿用這些實例。 + +第一輪受測產品基線是 `develop` 合併 commit `57b0f5d`,插件 `InviteCode-0.1.0-SNAPSHOT.jar` SHA-256 為 `FF187679BD246A30BC76A573C16179363D3A79909C0595FF97F25A13065661BC`。以下三個 TestLab 實例已留下第一輪玩家資料,使用者回報均已關閉;它們是歷史驗收對象,不用於新 JAR 的 UX 複驗。測試設定固定 `zh_TW`、同 IP `ALLOW`、登入 1 天即符合資格,這些是**測試專用**設定,不代表正式環境建議值。 + +| 實例 | 版本與連線位址 | 主要人工驗收 | +| --- | --- | --- | +| `issue12-human-paper-262` | Paper 26.2,`127.0.0.1:62620` | 原生 Dialog、繁體中文、六碼 HEX 的 RGB、指令與獎勵 | +| `issue12-human-spigot-188` | Spigot 1.8.8,`127.0.0.1:51888` | 私密聊天退回、legacy 顏色、舊版指令 | +| `issue12-human-folia-2612` | Folia 26.1.2,`127.0.0.1:63620` | 實驗性原生 Dialog 與玩家互動;不得據此推論 Vault 相容 | + +使用相符版本的 Minecraft Java 客戶端。請在**可見的 PowerShell 7** 視窗中,一次只啟動一個實例;本機已核對 `C:\Program Files\PowerShell\7\pwsh.exe` 為 PowerShell 7.6.6。執行下列其中一行,看到伺服器 `Done` 與 InviteCode 已啟用後再連線。結束時在該視窗的伺服器 Console 輸入 `stop`,確認程序關閉後才換下一個實例。 + +```powershell +& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile paper-latest -Instance issue12-human-paper-262 +& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile spigot-1.8.8 -Instance issue12-human-spigot-188 +& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile folia-latest -Instance issue12-human-folia-2612 -TestLabRoot 'D:\Code\Java\Plugin\TestLab\worktrees\fix-folia-stable-profile' +``` + +每個實例使用兩名新玩家 A、B;建議使用兩個 Minecraft 客戶端,讓 A 可直接檢查是否收到 B 的公開聊天。開始前在 Console 執行 `ic admin doctor`,預期 `Runtime=ACTIVE`,Paper/Folia 顯示 `Dialog=PAPER`,Spigot 1.8.8 顯示 `Dialog=NONE`。玩家分別確認 `/ic help`、Tab 補全與 `/ic status` 可讀,Console 的管理指令可用,普通玩家不能執行管理指令。 + +在 Paper 26.2 與 Folia 26.1.2,讓 A 用 `/ic code` 取得六碼 HEX;B 執行 `/ic claim`。預期出現可輸入邀請碼、可提交及可取消的原生 Dialog,繁體中文不亂碼。先按原生取消鍵及試一次 Esc,確認沒有 Invitation;再次開啟後輸入 A 的碼並按**原生提交按鈕**,預期顯示 A 與碼的確認摘要,`/ic status` 此時仍無 Invitation。執行 `/ic confirm` 後,預期 Invitation 建立並達資格。這一段的**按鈕點擊、畫面外觀、鍵盤輸入與取消行為**尚無自動化證據,須由真人判斷;合成測試只確認伺服器送出 Dialog 封包及 `/ic cancel` 不建立 Invitation。 + +在 Spigot 1.8.8,B 執行 `/ic claim` 後,預期改為聊天輸入提示;輸入 A 的邀請碼不得被 A 或其他玩家當作公開聊天看到。確認摘要出現後仍須 `/ic confirm` 才建立 Invitation。比較兩端的邀請碼顏色:新版須符合該六碼 HEX 的 RGB,舊版則顯示最接近的 legacy 顏色。所有實例的 `/ic stats`、離線後再次登入的 Pending Reward 訊息、Console `ic admin doctor` 均應維持一致,且沒有 InviteCode exception。 + +若上述任一步驟失敗,請保留該實例的 `workspace.json`、`logs/latest.log` 與 `plugins/InviteCode/`,不要重建或清空;回覆「版本/實例、通過或失敗的步驟、實際看到的文字或畫面、相關 log」。不需提供帳號憑證。若全部通過,請分別回覆 Paper、Spigot、Folia 的結果,以及 Dialog 提交/取消、顏色與繁體中文是否正確。接著再判定 Issue #12 的發行門檻;Folia Vault 仍需使用**明確支援 Folia** 的 Vault 與經濟提供者另測,目前既有 EssentialsX 不能作為該測試對象。 + +## UX 修正的第二輪驗收 + +本輪 JAR SHA-256 為 `B586955C62FAE5F09F284D94203D674D84E90E8BF8F6E7B6230C496466689813`;自動證據見[UX 回歸紀錄](./evidence/2026-09-25-issue-12-ux-retest.md)。以下是另外建立的三個**空白、未啟動**實例;保留第一輪資料,請勿覆蓋原實例。三者仍用 `zh_TW`、同 IP `ALLOW` 與登入一天資格,依序使用對應版本客戶端、可見 PowerShell 7 視窗啟動,一次只開一台,測完在 Console 輸入 `stop`。 + +| 第二輪實例 | 連線位址 | 啟動指令 | +| --- | --- | --- | +| `issue12-ux-human-paper-262` | Paper 26.2,`127.0.0.1:62620` | `& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile paper-latest -Instance issue12-ux-human-paper-262` | +| `issue12-ux-human-spigot-188` | Spigot 1.8.8,`127.0.0.1:51888` | `& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile spigot-1.8.8 -Instance issue12-ux-human-spigot-188` | +| `issue12-ux-human-folia-2612` | Folia 26.1.2,`127.0.0.1:63620` | `& 'D:\Code\Java\Plugin\InviteCodeKt\repo\scripts\test-servers\start.ps1' -Profile folia-latest -Instance issue12-ux-human-folia-2612 -TestLabRoot 'D:\Code\Java\Plugin\TestLab\worktrees\fix-folia-stable-profile'` | + +每台只須複驗新的 UX:A 輸入 `/ic code`,點擊下方複製入口;Paper/Folia 預期直接複製六碼原始碼,Spigot 1.8.8 預期填入聊天列供手動選取複製,且原有邀請碼 RGB/legacy 顏色仍正常。B 先輸入 `/ic claim`;在 Spigot 聊天模式輸入 `cancel`,預期私密取消、`/ic status` 仍無 Invitation,再重新輸入 A 的碼。Paper/Folia 以原生 Dialog 提交。確認摘要下方應有綠色「同意」、紅色「不同意」;先點「不同意」,確認沒有 Invitation;重新輸入碼後點「同意」,預期建立 Invitation。請特別檢查按鈕真的執行了對應指令、沒有公開聊天或亂碼。不同意後若需再試,請重新開啟 Claim;避免在同一 Invitee 已建立 Invitation 後重複測。 + +三台合成玩家流程、回歸測試與 JAR 檢查已通過;**真人剪貼簿、聊天按鈕點擊與外觀**仍待本輪驗收。排版與美術優化已記錄為後續討論,不納入本輪判定。請分別回覆三個實例的「複製/選取、紅綠按鈕、聊天 `cancel`、繁體中文」結果;若失敗,保留該實例的 log 和資料並描述實際畫面。通過後還須判定 Issue #12 的發行門檻;Folia Vault provider 仍未驗證。 + +## 第三輪 UX 驗收(待真人操作) + +本輪 JAR SHA-256 為 `889DAD100D56D18C425D7299FD759EAA3DD822C863CF55FF486F7D8F372EFE3C`。`/ic code` 的六碼本身可點擊並有可翻譯懸浮提示;新版直接複製、舊版填入聊天列。`/ic claim` 在開啟輸入流程前檢查資格,提交碼與最後確認仍複查。確認期限預設改為 60 秒,可由 `config.yml` 調整。舊版聊天確認使用四行摘要與第五行綠/紅選項;有 Dialog 能力的 Paper/Spigot 在輸入後開啟第二個原生確認 Dialog,其文字按鈕為綠/紅色,提示可翻譯,底色由 Minecraft 客戶端決定。畫面顯示設定期限,伺服器到期後關閉 Dialog,不逐秒刷新數字。 + +Paper 26.2、Spigot 26.2、Spigot 1.8.8、Folia 26.1.2 的隔離合成玩家流程已通過;除舊版 Spigot 外均收到了輸入與確認 Dialog 封包,四者完成 Claim、獎勵與重啟。這些證據不證明真人客戶端的按鈕點擊、剪貼簿或畫面顏色。測試實例均已由 runner 正常關閉。第三輪真人驗收須使用另外建立、雜湊相符的空白實例,不要沿用第二輪 JAR 或玩家資料。 + +| 第三輪真人實例 | 連線位址 | 可見 PowerShell 7 視窗中的啟動指令 | +| --- | --- | --- | +| `issue12-ux3-human-paper-262` | Paper 26.2,`127.0.0.1:62620` | `& 'D:\Code\Java\Plugin\InviteCodeKt\worktrees\test-final-release-acceptance\scripts\test-servers\start.ps1' -Profile paper-latest -Instance issue12-ux3-human-paper-262` | +| `issue12-ux3-human-spigot-188` | Spigot 1.8.8,`127.0.0.1:51888` | `& 'D:\Code\Java\Plugin\InviteCodeKt\worktrees\test-final-release-acceptance\scripts\test-servers\start.ps1' -Profile spigot-1.8.8 -Instance issue12-ux3-human-spigot-188` | +| `issue12-ux3-human-folia-2612` | Folia 26.1.2,`127.0.0.1:63620` | `& 'D:\Code\Java\Plugin\InviteCodeKt\worktrees\test-final-release-acceptance\scripts\test-servers\start.ps1' -Profile folia-latest -Instance issue12-ux3-human-folia-2612 -TestLabRoot 'D:\Code\Java\Plugin\TestLab\worktrees\fix-folia-stable-profile'` | + +三者預設 `zh_TW` 且會跟隨玩家客戶端語系;驗收繁體中文時請將客戶端設為繁體中文。測試政策為同 IP `ALLOW`、登入 1 天達資格,且 `workspace.json` 的插件雜湊皆等於本節所列 JAR。請一次只開一台;看到 `Done` 與 InviteCode 已啟用後才連線,測完在該伺服器 Console 輸入 `stop`,確認結束後再啟動下一台。 + +真人依序只開一台:A 執行 `/ic code`,滑鼠移到**六碼本身**應出現提示,點擊後新版剪貼簿應只有六碼,舊版則填入聊天列。B 執行 `/ic claim`,原生輸入 Dialog 送出碼後應顯示邀請人、顏色正確的邀請碼、問題與期限、綠色「同意」和紅色「不同意」;Spigot 1.8.8 應顯示相同語意的五行聊天確認。先點「不同意」確認沒有 Invitation,再以新流程點「同意」確認建立。另用已用碼、已成為 Inviter 或逾期的玩家試 `/ic claim`,應立即顯示原因且不出現輸入框。預期沒有 InviteCode exception;回覆各版本的「複製、資格預檢、Dialog/聊天確認、按鈕、繁體中文」結果與實際畫面差異。真人通過後,才繼續 Issue #12 的發行門檻判定;Folia Vault provider 仍未驗證。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 2f5564a..269d3dc 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -1,6 +1,6 @@ # InviteCode 真實測試伺服器 -InviteCode 使用專案外的 `D:\Code\Java\Plugin\TestLab` 共用伺服器核心快取與工具,但每個 profile、Worktree 與驗收版本都建立獨立實例。World、插件設定、SQLite、log 與其他可變狀態不跨實例共用。 +InviteCode 使用專案外的 `D:\Code\Java\Plugin\InstanceHarbor` 共用伺服器核心快取與工具,但每個 profile、Worktree 與驗收版本都建立獨立實例。World、插件設定、SQLite、log 與其他可變狀態不跨實例共用。 ## 測試矩陣 @@ -26,7 +26,7 @@ pwsh -NoProfile -File .\scripts\test-servers\validate.ps1 pwsh -NoProfile -File .\scripts\test-servers\doctor.ps1 ``` -若 TestLab foundation 尚未合併,可用 `-TestLabRoot` 指向其 task Worktree。平常也可設定 `PLUGIN_TEST_LAB_HOME`。 +平常使用 `D:\Code\Java\Plugin\InstanceHarbor\repo`,也可設定 `PLUGIN_INSTANCEHARBOR_HOME` 或傳入 `-InstanceHarborRoot` 指向核對過的 repository。舊 `-TestLabRoot` 參數仍作為 alias;測試實例一律建立在 `instances/Agent/InviteCode/`,不使用 Human 或舊版實例。 ## 建立測試實例 @@ -71,7 +71,7 @@ pwsh -NoProfile -File .\scripts\test-servers\smoke.ps1 ` -Profile spigot-1.8.8 -Instance issue12-spigot-188 ``` -Runner 核對 `workspace.json` 的 profile、EULA、核心與插件 JAR SHA-256;等待插件啟用後從 Console 執行 `ic admin doctor`、`ic help` 與 `ic reload`,確認 `ACTIVE`、整合狀態、儲存版本、指令說明與重新載入成功,正常送出 `stop`,檢查嚴格 UTF-8 log,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`,對 `backend: MYSQL` 的實例傳入 `-Backend MYSQL`。SQLite/JSON 會檢查本機儲存檔與 anti-abuse key;MySQL 要求測試程序環境有 `INVITECODE_DB_PASSWORD`、`INVITECODE_NETWORK_SECRET`,並確認沒有在插件資料夾建立本機 key。MySQL 的資料庫 schema/ledger 須另用該獨立服務的用戶端核對,Runner 對這兩個本機檔案雜湊輸出 `null`。它不會替使用者接受 EULA、建立資料庫、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256;MySQL 改核對 ledger、表與稽核紀錄。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 +Runner 核對實體 Agent 路徑、`workspace.json` schema 2/audience、profile、EULA、loopback/offline mode、未被監聽的 port、核心與插件 JAR SHA-256;等待插件啟用後從 Console 執行 `ic admin doctor`、`ic help` 與 `ic reload`,確認 `ACTIVE`、整合狀態、儲存版本、指令說明與重新載入成功,正常送出 `stop`,檢查嚴格 UTF-8 log,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`,對 `backend: MYSQL` 的實例傳入 `-Backend MYSQL`。SQLite/JSON 會檢查本機儲存檔與 anti-abuse key;MySQL 要求測試程序環境有 `INVITECODE_DB_PASSWORD`、`INVITECODE_NETWORK_SECRET`,並確認沒有在插件資料夾建立本機 key。MySQL 的資料庫 schema/ledger 須另用該獨立服務的用戶端核對,Runner 對這兩個本機檔案雜湊輸出 `null`。它不會替使用者接受 EULA、建立資料庫、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256;MySQL 改核對 ledger、表與稽核紀錄。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 預設預期 PlaceholderAPI 與 Vault Economy 都不存在。已在獨立實例安裝 PlaceholderAPI 時加上 `-ExpectPlaceholderApi`;已安裝 Vault 與經濟提供者時加上 `-ExpectVaultEconomy`。Runner 會核對 Console doctor 的實際整合狀態,輸出對應布林值;這只驗證服務偵測,不代表實際 placeholder 展開或經濟入帳已通過。 @@ -88,41 +88,43 @@ Runner 核對 `workspace.json` 的 profile、EULA、核心與插件 JAR SHA-256 Issue #12 的測試專用 fixture 以 Mineflayer 建立兩名離線模式的本機合成玩家,透過正式玩家指令與 Console doctor 驗證 Invite Code、Claim Confirmation、Qualification、離線 Reward 跨重啟補發與 Stats。先用 `npm.cmd ci --ignore-scripts --prefix .\scripts\test-servers\synthetic-player` 安裝固定版本的測試依賴;這些套件不會封裝進插件 JAR。 -使用同一份待驗證的插件 JAR,為每次執行建立全新的 `issue12-*` TestLab instance。例如: +使用同一份待驗證的插件 JAR,為每次執行建立全新的 `issue12-*` InstanceHarbor instance。例如: ```powershell -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-paper-1206\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path pwsh -NoProfile -File .\scripts\test-servers\prepare-synthetic-player.ps1 ` -Profile spigot-1.8.8 -Instance issue12-example-spigot-188 ` -Artifact $jar -AcceptEula $env:MISE_EXE = (Get-Command mise -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\flow.cjs ` - 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-example-spigot-188' + 'D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\issue12-example-spigot-188' ``` `-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 支援 Spigot 1.8.8、Paper 1.20.6、1.21.8、`paper-latest` 設為 26.2 時的獨立測試客戶端,以及 `folia-latest` 設為 26.1.2 時的實驗性測試;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋原生 Dialog 視覺、Vault 金額或中斷於外部效果期間的 `UNCERTAIN` 復原。 -Folia 26.1.2 的實驗性 fixture 需使用已選到該版本的 TestLab root。本機 `TestLab/worktrees/fix-folia-stable-profile` 提供這個 profile;若它尚未整合到 TestLab `develop`,請明確傳入 `-TestLabRoot`。與其他版本一樣,先安裝 `scripts/test-servers/synthetic-player/` 的固定測試依賴,並為每次測試選全新 `issue12-*` 實例: +驗證聊天輸入與 `cancel` 時,可在**全新**實例首次啟動前把 `input-mode` 改成 `CHAT`,並設定 `INVITECODE_CHAT_INPUT=1` 執行同一 runner。它會先傳入大小寫混用的 `CaNcEl`,確認沒有建立 Invitation,再重新輸入邀請碼;同時確認複製入口與確認選項的文字已送達。元件的 ClickEvent 指令與舊版複製退回方式由單元測試檢查;剪貼簿和實際點擊效果仍須真人驗收。 + +Folia 26.1.2 的實驗性 fixture 使用目前 InstanceHarbor `repo` 的 `folia-latest` profile;建立後仍須核對 `workspace.json` 的實際版本。與其他版本一樣,先安裝 `scripts/test-servers/synthetic-player/` 的固定測試依賴,並為每次測試選全新 `issue12-*` 實例: ```powershell -$lab = 'D:\Code\Java\Plugin\TestLab\worktrees\fix-folia-stable-profile' +$lab = 'D:\Code\Java\Plugin\InstanceHarbor\repo' $name = 'issue12-folia-example' pwsh -NoProfile -File .\scripts\test-servers\prepare-synthetic-player.ps1 ` -Profile folia-latest -Instance $name ` -Artifact .\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar ` - -TestLabRoot $lab -AcceptEula + -InstanceHarborRoot $lab -AcceptEula $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\flow.cjs ` - "D:\Code\Java\Plugin\TestLab\instances\InviteCode\$name" + "D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\$name" ``` 跨 region 驗證須在**另一個全新實例首次啟動前**將其 `config/paper-global.yml` 的 `threaded-regions.threads` 設為 `2`,再設定 `$env:INVITECODE_FOLIA_MULTI_REGION = '1'` 執行同一 runner;它會把兩名合成玩家送往相距約兩萬格的區域,並行執行 `/ic status`。私密聊天驗證也使用新實例,將其 `plugins/InviteCode/config.yml` 設為 `input-mode: CHAT`,並設定 `$env:INVITECODE_FOLIA_CHAT = '1'`;原生 Dialog 畫面仍需後續人工驗收。完整實例、JAR 雜湊與結果見 [Issue #12 證據](./evidence/2026-09-24-issue-12-startup-matrix.md)。 -Paper 26.2 的玩家測試使用[獨立維護的 Mineflayer 26.2](https://github.com/Complexity-ML/mineflayer-26.2),它並非 [PrismarineJS 官方 Mineflayer](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)。它只存在於 `scripts/test-servers/synthetic-player-26-2/` 的測試依賴,JAR 不會封裝它;安裝時停用 npm scripts,並僅連線至 EULA 已接受的 loopback/offline TestLab。`package-lock.json` 固定下載內容。先安裝,再建立**全新**實例: +Paper 26.2 的玩家測試使用[獨立維護的 Mineflayer 26.2](https://github.com/Complexity-ML/mineflayer-26.2),它並非 [PrismarineJS 官方 Mineflayer](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)。它只存在於 `scripts/test-servers/synthetic-player-26-2/` 的測試依賴,JAR 不會封裝它;安裝時停用 npm scripts,並僅連線至 EULA 已接受的 loopback/offline InstanceHarbor。`package-lock.json` 固定下載內容。先安裝,再建立**全新**實例: ```powershell npm.cmd ci --ignore-scripts --prefix .\scripts\test-servers\synthetic-player-26-2 -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-paper-latest\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path $name = 'issue12-flow-paper-262-example' pwsh -NoProfile -File .\scripts\test-servers\prepare-synthetic-player.ps1 ` -Profile paper-latest -Instance $name -Artifact $jar -AcceptEula @@ -130,87 +132,95 @@ $env:INVITECODE_SYNTHETIC_CLIENT_262 = (Resolve-Path ` .\scripts\test-servers\synthetic-player-26-2\node_modules\mineflayer).Path $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\flow.cjs ` - "D:\Code\Java\Plugin\TestLab\instances\InviteCode\$name" + "D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\$name" ``` -Runner 會驗證 26.2 客戶端版本、TestLab metadata、EULA、loopback、離線模式與受測 JAR 的 SHA-256。這個獨立客戶端讓本機 26.2 玩家流程可測,但不代表官方 Mineflayer 已宣告支援,也不能代替最後的真人視覺與互動驗收。 +Runner 會驗證 26.2 客戶端版本、InstanceHarbor metadata、EULA、loopback、離線模式與受測 JAR 的 SHA-256。這個獨立客戶端讓本機 26.2 玩家流程可測,但不代表官方 Mineflayer 已宣告支援,也不能代替最後的真人視覺與互動驗收。 ### Reward 外部效果中斷 在**全新的** Spigot 1.8.8 隔離實例上,`-RewardInterruption` 會以本機 `mise java@local-8` 編譯測試專用 `InviteCodeFaultProbe.jar`,並把 Invitee 的 Reward 設為 `CONSOLE_COMMAND: icfault`。此指令先將效果進入標記同步寫入自己的資料夾,第一次呼叫隨即以 `Runtime.halt(83)` 強制終止測試 JVM;只有同一實例的管理員明確 `retry`,第二次呼叫才會正常返回。它絕不可放到正式伺服器。需要 Python 3 的標準 `sqlite3` 模組,僅用於找出測試 Action UUID;狀態斷言透過 Console `doctor` 與 `inspect reward`。 ```powershell -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-fixture-spigot-188\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path $name = 'issue12-uncertain-example-188' pwsh -NoProfile -File .\scripts\test-servers\prepare-synthetic-player.ps1 ` -Profile spigot-1.8.8 -Instance $name -Artifact $jar -AcceptEula -RewardInterruption $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\uncertain.cjs ` - "D:\Code\Java\Plugin\TestLab\instances\InviteCode\$name" mark-delivered + "D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\$name" mark-delivered ``` `mark-delivered` 與 `retry` 各使用不同的新實例,勿重用上例的 `$name`;`MISE_EXE` 指向當前電腦實際安裝的 mise 執行檔。Runner 會檢查 loopback、EULA、JAR SHA-256 與全新資料庫,並只停止自己啟動的伺服器。第一次故障造成測試客戶端 `ECONNRESET` 是預期現象。重啟後 `UNCERTAIN=1`、重新登入不重發;`mark-delivered` 後標記仍只有一次,`retry` 後才增加至兩次並轉為 `DELIVERED`。這是隔離演練,不代表能證明外部系統中的所有實際效果。 ### SQLite 遷移失敗與復原 -`migration-recovery.cjs` 使用全新的 Spigot 1.8.8/SQLite 隔離實例。它先讓插件正常初始化,再於停機時用 Python 3 標準 `sqlite3` 建立測試用 v7 schema 與哨兵玩家資料,並以同名索引阻擋 v8 遷移的第二個 DDL。Runner 檢查重啟不自動升級、管理指令失敗後交易回滾、哨兵資料與 `anti-abuse.key` 保留;清除測試衝突後,透過 Console 明確遷移到 v8,再重啟驗證。此 fixture 會直接修改**自己的隔離資料庫**,不得指向正式伺服器或既有實例。 +`migration-recovery.cjs` 使用全新的 Spigot 1.8.8/SQLite 隔離實例。它先讓插件正常初始化,再於停機時用 Python 3 標準 `sqlite3` 建立測試用 v7 schema 與哨兵玩家資料,並以同名索引阻擋 v8 遷移的第二個 DDL。Runner 檢查重啟不自動升級、管理指令失敗後交易回滾、哨兵資料與 `anti-abuse.key` 保留;清除測試衝突後,透過 Console 明確遷移到 v9(包含匿名化所需的邀請碼保留表),再重啟驗證。此 fixture 會直接修改**自己的隔離資料庫**,不得指向正式伺服器或既有實例。 ```powershell -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-fixture-spigot-188\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path $name = 'issue12-migration-example-188' pwsh -NoProfile -File .\scripts\test-servers\prepare.ps1 ` -Profile spigot-1.8.8 -Instance $name -Artifact $jar -AcceptEula $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\migration-recovery.cjs ` - "D:\Code\Java\Plugin\TestLab\instances\InviteCode\$name" + "D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\$name" ``` -上例只適用於已接受 Minecraft EULA 的本機 TestLab。每次執行須換用尚不存在的新實例名稱,受測 JAR 的雜湊須與 `workspace.json` 相同。此測試驗證 SQLite 在伺服器層級的遷移回滾與復原,不涵蓋 MySQL DDL 中斷續建或正式資料搬移。 +上例只適用於已接受 Minecraft EULA 的本機 InstanceHarbor。每次執行須換用尚不存在的新實例名稱,受測 JAR 的雜湊須與 `workspace.json` 相同。此測試驗證 SQLite 在伺服器層級的遷移回滾與復原,不涵蓋 MySQL DDL 中斷續建或正式資料搬移。 ### MySQL 初始化中斷後續建 -`mysql-migration-recovery.cjs` 在全新 Paper 1.20.6 TestLab 實例及專用 `invitecode_issue12_test_*` database 建立合成 `APPLYING` ledger、一張已提交的玩家表與哨兵資料。先把玩家表欄位改壞,驗證插件進入維護模式且未補建;修正欄位後再注入錯誤 checksum,驗證同樣拒絕;最後恢復 checksum,驗證啟動自動續建、ledger 轉為 `APPLIED`、玩家資料保留,且重啟不重複初始化。這是從已提交 DDL 邊界重建的**合成中斷狀態**,並非在正式建表過程中強制終止 JVM。 +`mysql-migration-recovery.cjs` 在全新 Paper 1.20.6 InstanceHarbor 實例及專用 `invitecode_issue12_test_*` database 建立合成 `APPLYING` ledger、一張已提交的玩家表與哨兵資料。先把玩家表欄位改壞,驗證插件進入維護模式且未補建;修正欄位後再注入錯誤 checksum,驗證同樣拒絕;最後恢復 checksum,驗證啟動自動續建、ledger 轉為 `APPLIED`、玩家資料保留,且重啟不重複初始化。這是從已提交 DDL 邊界重建的**合成中斷狀態**,並非在正式建表過程中強制終止 JVM。 -先啟動 TestLab 隔離的 MySQL 8.4.11 服務,使其只在 `127.0.0.1:63384` 接受連線;測試程序須有 `INVITECODE_TEST_MYSQL_ROOT_PASSWORD`、`INVITECODE_DB_PASSWORD`、`INVITECODE_NETWORK_SECRET`,均從 TestLab 使用者專屬加密暫存還原至目前程序環境,不寫入 repository 或命令列。測試器只接受 TestLab 中尚未啟動過的 `issue12-*` Paper 1.20.6 實例,驗證 EULA、loopback、JAR 雜湊與固定埠後,才建立新 database;拒絕覆寫既有 database。MySQL root 密碼不傳給 Paper 子程序。測試結束後關閉自己啟動的 Paper,再由測試操作者正常關閉隔離 MySQL 服務;保留測試 database 作為證據。 +先啟動 InstanceHarbor 隔離的 MySQL 8.4.11 服務,使其只在 `127.0.0.1:63384` 接受連線;測試程序須有 `INVITECODE_TEST_MYSQL_ROOT_PASSWORD`、`INVITECODE_DB_PASSWORD`、`INVITECODE_NETWORK_SECRET`,均從 InstanceHarbor 使用者專屬加密暫存還原至目前程序環境,不寫入 repository 或命令列。測試器只接受 InstanceHarbor 中尚未啟動過的 `issue12-*` Paper 1.20.6 實例,驗證 EULA、loopback、JAR 雜湊與固定埠後,才建立新 database;拒絕覆寫既有 database。MySQL root 密碼不傳給 Paper 子程序。測試結束後關閉自己啟動的 Paper,再由測試操作者正常關閉隔離 MySQL 服務;保留測試 database 作為證據。 ```powershell -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-mysql-paper-1206\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path $name = 'issue12-mysql-recover-example-1206' pwsh -NoProfile -File .\scripts\test-servers\prepare.ps1 ` -Profile paper-1.20.6 -Instance $name -Artifact $jar -AcceptEula $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source node .\scripts\test-servers\synthetic-player\mysql-migration-recovery.cjs ` - "D:\Code\Java\Plugin\TestLab\instances\InviteCode\$name" + "D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\$name" ``` 執行上例前須已接受 Minecraft EULA,且上述三個環境變數與隔離 MySQL 服務均已準備妥當。每次複驗使用新的實例名稱,以免重用有資料的 database。測試目前使用受控本機 `tls-mode: REQUIRED`,不證明正式預設 `VERIFY_IDENTITY` 的憑證驗證。 ### Vault 與 PlaceholderAPI 的實際路徑 -`prepare-integration-player.ps1` 以全新 `issue12-*` 實例測試已取得的外部插件 JAR。Vault 情境使用 Paper 1.21.8、Vault、EssentialsX 與測試專用唯讀餘額指令;Placeholder 情境使用 Paper 1.20.6、PlaceholderAPI 與測試專用 `%icprobe_ready%` 擴充。兩種 probe 都只在 loopback、離線模式及 TestLab 實例內啟用,不會封裝進 InviteCode JAR。編譯 probe 需要既有 Spigot 1.8.8 `server.jar` 作為 Bukkit API classpath,並以 `mise java@local-21` 產生 Java 8 bytecode。 +`prepare-integration-player.ps1` 以全新 `issue12-*` 實例測試已取得的外部插件 JAR。Vault 情境使用 Paper 1.21.8、Vault、EssentialsX 與測試專用唯讀餘額指令;Placeholder 情境使用 Paper 1.20.6、PlaceholderAPI 與測試專用 `%icprobe_ready%` 擴充。兩種 probe 都只在 loopback、離線模式及 `instances/Agent/InviteCode/issue12-*` 實體路徑內啟用,不會封裝進 InviteCode JAR。編譯 probe 需要既有 Spigot 1.8.8 `server.jar` 作為 Bukkit API classpath,並以 `mise java@local-21` 產生 Java 8 bytecode。 ```powershell -$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-fixture-spigot-188\plugins\InviteCode-0.1.0-SNAPSHOT.jar' -$api = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-fixture-spigot-188\server.jar' +$jar = (Resolve-Path '.\invitecode-plugin\build\libs\InviteCode-0.1.0-SNAPSHOT.jar').Path +$api = 'D:\Code\Java\Plugin\BuildTools\Server\spigot-1.8.8.jar' $env:MISE_EXE = (Get-Command mise.exe -CommandType Application | Select-Object -First 1).Source pwsh -NoProfile -File .\scripts\test-servers\prepare-integration-player.ps1 ` -Scenario Vault -Instance issue12-vault-example-1218 -Artifact $jar -SpigotApiJar $api ` - -VaultJar 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-vault-212-paper-1218\plugins\Vault.jar' ` - -EconomyJar 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-vault-212-paper-1218\plugins\EssentialsX-2.21.2.jar' -AcceptEula + -VaultJar 'D:\Code\Java\Plugin\InstanceHarbor\instances\InviteCode\issue12-vault-212-paper-1218\plugins\Vault.jar' ` + -EconomyJar 'D:\Code\Java\Plugin\InstanceHarbor\instances\InviteCode\issue12-vault-212-paper-1218\plugins\EssentialsX-2.21.2.jar' -AcceptEula node .\scripts\test-servers\synthetic-player\integration.cjs ` - 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-vault-example-1218' Vault + 'D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\issue12-vault-example-1218' Vault pwsh -NoProfile -File .\scripts\test-servers\prepare-integration-player.ps1 ` -Scenario Placeholder -Instance issue12-papi-example-1206 -Artifact $jar -SpigotApiJar $api ` - -PlaceholderApiJar 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-papi-paper-1206\plugins\PlaceholderAPI.jar' -AcceptEula + -PlaceholderApiJar 'D:\Code\Java\Plugin\InstanceHarbor\instances\InviteCode\issue12-papi-paper-1206\plugins\PlaceholderAPI.jar' -AcceptEula node .\scripts\test-servers\synthetic-player\integration.cjs ` - 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-papi-example-1206' Placeholder + 'D:\Code\Java\Plugin\InstanceHarbor\instances\Agent\InviteCode\issue12-papi-example-1206' Placeholder ``` 只在已接受 Minecraft EULA 的測試環境使用 `-AcceptEula`。Vault 測試要求 Invitee 的 Vault 餘額從 0 變為 37.5,重啟並重新登入後仍為 37.5;Placeholder 測試要求切換前 Invitation 保持待資格、切換後重新登入才達資格並收到 Reward,重啟後維持已達資格。Paper 1.20.6 上 Mineflayer/protodef 可能輸出非致命封包解析警告,應與伺服器及 InviteCode log 分開判讀。再次執行須改用新實例名稱。 +Placeholder fixture 另可傳入 `-PlaceholderProfile folia-latest` 與指向 Folia 26.1.2 的 `-InstanceHarborRoot`,再用相同 `integration.cjs ... Placeholder` 流程驗證。測試 probe 的玩家名稱快取與資格集合使用跨執行緒容器,並標記 `folia-supported: true`;Console 只切換測試值,實際 Placeholder 展開由 InviteCode 在玩家 entity scheduler 觸發。此結果僅涵蓋 PlaceholderAPI 2.12.3 與測試用 expansion。既有 Vault/EssentialsX 2.21.2 JAR 未宣告 Folia 支援,[EssentialsX 發行說明](https://github.com/EssentialsX/Essentials/releases)亦明確不支援 Folia,不能把 Paper 的存款測試推定為 Folia Vault 通過。 + +`flow.cjs` 在 Folia 26.1.2 或 Paper 26.2 的全新實例上可設 `INVITECODE_DIALOG_PROTOCOL=1`,並將實例的 `input-mode` 設為 `DIALOG`。Runner 驗證兩次輸入與一次確認的原生 `show_dialog` 封包;取消輸入後 Invitation 仍不存在,再以 command 完成 Claim/Reward 與重啟流程。合成客戶端無法證明畫面、原生按鈕點擊與輸入提交正確;這些步驟見[最終真人驗收](./final-human-acceptance.md)。 + ## 自動檢查與最終真人驗收 日常開發與各功能階段先由 Agent 執行不需要玩家判斷的檢查,包括 Gradle 測試、JAR 結構與 Java 8 bytecode、伺服器啟動與正常停機、log 錯誤掃描、UTF-8 解碼、SQLite/防濫用密鑰初始化,以及適用時的重啟持久化。這些結果須綁定受測 commit 與 JAR SHA-256。 需要真人觀察或實際玩家操作的項目集中到插件功能接近完成、準備發行候選版本時執行一次完整驗收,包括指令與 Tab completion、聊天及 Dialog 輸入、顏色與語系顯示、Claim/Confirmation/Status/Stats,以及實際獎勵體驗。延後的真人項目維持「待最終真人驗收」,不得因自動 smoke 通過而標記為已通過,也不阻擋仍在開發中的本機 checkpoint。 + +## 整合候選複驗 + +最新 develop 與 UX 分支整合後的同 JAR 複驗,見 [2026-10-02 複驗紀錄](./evidence/2026-10-02-issue-12-final-artifact-retest.md)。測試 runner 邊界可用 `pwsh -NoProfile -File scripts/test-servers/test-common.ps1` 與 `node --test scripts/test-servers/synthetic-player/instance-boundary.test.cjs` 驗證。 diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt index e947ed9..e75288d 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt @@ -5,6 +5,11 @@ import java.time.Duration import java.time.Instant import java.util.UUID +sealed class ChatInputResult { + data class Code(val value: String) : ChatInputResult() + object Cancelled : ChatInputResult() +} + class ClaimInteractionSessions( private val now: () -> Instant = Instant::now, ) { @@ -38,11 +43,13 @@ class ClaimInteractionSessions( } @Synchronized - fun consumeChatInput(playerId: UUID, message: String): String? { + fun consumeChatInput(playerId: UUID, message: String): ChatInputResult? { val session = sessions[playerId] as? Session.ChatInput ?: return null sessions.remove(playerId) if (now().isAfter(session.expiresAt)) return null - return message.trim() + val value = message.trim() + return if (value.equals("cancel", ignoreCase = true)) ChatInputResult.Cancelled + else ChatInputResult.Code(value) } @Synchronized diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt index 066c0d3..4c35dc6 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt @@ -11,6 +11,20 @@ data class NativeDialogRequest( val maximumLength: Int, ) +data class NativeDialogConfirmationRequest( + val title: String, + val inviterLine: String, + val codeLabel: String, + val code: String, + val codeRgb: Int?, + val question: String, + val timeoutPrompt: String, + val agree: String, + val disagree: String, + val agreeHint: String, + val disagreeHint: String, +) + interface NativeDialogInput : AutoCloseable { val available: Boolean @@ -21,6 +35,13 @@ interface NativeDialogInput : AutoCloseable { onCancel: () -> Unit, ): Boolean + fun showConfirmation( + player: Player, + request: NativeDialogConfirmationRequest, + onConfirm: () -> Unit, + onDecline: () -> Unit, + ): Boolean = false + fun cancel(player: Player) fun disconnect(playerId: UUID) diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt index 29f51b9..14aed87 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt @@ -52,9 +52,13 @@ class ClaimInteractionSessionsTest { sessions.startChatInput(playerId, Duration.ofSeconds(60)) assertTrue(sessions.hasChatInput(playerId)) - assertEquals("a1b2c3", sessions.consumeChatInput(playerId, " a1b2c3 ")) + assertEquals(ChatInputResult.Code("a1b2c3"), sessions.consumeChatInput(playerId, " a1b2c3 ")) assertNull(sessions.consumeChatInput(playerId, "second")) + sessions.startChatInput(playerId, Duration.ofSeconds(60)) + assertEquals(ChatInputResult.Cancelled, sessions.consumeChatInput(playerId, " CaNcEl ")) + assertNull(sessions.consumeChatInput(playerId, "A1B2C3")) + sessions.startChatInput(playerId, Duration.ofSeconds(60)) now = now.plusSeconds(61) assertNull(sessions.consumeChatInput(playerId, "expired")) diff --git a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt index 604fab5..f4aecc6 100644 --- a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt +++ b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt @@ -1,6 +1,7 @@ package io.github.command1264.invitecode.platform.modern import io.github.command1264.invitecode.platform.bukkit.NativeDialogInput +import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest import io.github.command1264.invitecode.platform.bukkit.UnavailableNativeDialogInput import org.bukkit.entity.Player @@ -23,12 +24,15 @@ internal sealed class DialogResponse { data class Submitted(override val playerId: UUID, val value: String?) : DialogResponse() data class Cancelled(override val playerId: UUID) : DialogResponse() + data class Confirmed(override val playerId: UUID) : DialogResponse() + data class Declined(override val playerId: UUID) : DialogResponse() } internal interface DialogBackend { val provider: String fun register(listener: (DialogResponse) -> Unit) fun show(player: Player, request: NativeDialogRequest) + fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) fun close(player: Player) } @@ -36,10 +40,10 @@ internal class ReflectiveNativeDialogInput( private val backend: DialogBackend, private val logger: Logger, ) : NativeDialogInput { - private data class Callbacks( - val onSubmit: (String) -> Unit, - val onCancel: () -> Unit, - ) + private sealed class Callbacks { + data class Input(val onSubmit: (String) -> Unit, val onCancel: () -> Unit) : Callbacks() + data class Confirmation(val onConfirm: () -> Unit, val onDecline: () -> Unit) : Callbacks() + } private val callbacks = ConcurrentHashMap() override val available: Boolean = true @@ -55,7 +59,7 @@ internal class ReflectiveNativeDialogInput( onSubmit: (String) -> Unit, onCancel: () -> Unit, ): Boolean { - callbacks[player.uniqueId] = Callbacks(onSubmit, onCancel) + callbacks[player.uniqueId] = Callbacks.Input(onSubmit, onCancel) return try { backend.show(player, request) true @@ -70,6 +74,27 @@ internal class ReflectiveNativeDialogInput( } } + override fun showConfirmation( + player: Player, + request: NativeDialogConfirmationRequest, + onConfirm: () -> Unit, + onDecline: () -> Unit, + ): Boolean { + callbacks[player.uniqueId] = Callbacks.Confirmation(onConfirm, onDecline) + return try { + backend.showConfirmation(player, request) + true + } catch (error: ReflectiveOperationException) { + callbacks.remove(player.uniqueId) + logger.log(Level.WARNING, "無法開啟原生 Claim Confirmation Dialog,將退回聊天確認。", error) + false + } catch (error: LinkageError) { + callbacks.remove(player.uniqueId) + logger.log(Level.WARNING, "原生 Claim Confirmation Dialog API 不相容,將退回聊天確認。", error) + false + } + } + override fun cancel(player: Player) { callbacks.remove(player.uniqueId) ?: return try { @@ -90,10 +115,20 @@ internal class ReflectiveNativeDialogInput( } private fun handle(response: DialogResponse) { - val callback = callbacks.remove(response.playerId) ?: return - when (response) { - is DialogResponse.Submitted -> callback.onSubmit(response.value.orEmpty()) - is DialogResponse.Cancelled -> callback.onCancel() + val callback = callbacks[response.playerId] ?: return + when { + callback is Callbacks.Input && response is DialogResponse.Submitted -> { + if (callbacks.remove(response.playerId, callback)) callback.onSubmit(response.value.orEmpty()) + } + callback is Callbacks.Input && response is DialogResponse.Cancelled -> { + if (callbacks.remove(response.playerId, callback)) callback.onCancel() + } + callback is Callbacks.Confirmation && response is DialogResponse.Confirmed -> { + if (callbacks.remove(response.playerId, callback)) callback.onConfirm() + } + callback is Callbacks.Confirmation && response is DialogResponse.Declined -> { + if (callbacks.remove(response.playerId, callback)) callback.onDecline() + } } } @@ -138,6 +173,10 @@ private class PaperDialogBackend private constructor( private val connectionPlayer: Method, private val responseText: Method, private val componentText: Method, + private val componentColoredText: Method, + private val textColorRgb: Method, + private val componentAppend: Method, + private val plainMessage: Method, private val keyFactory: Method, private val dialogInputText: Method, private val textWidth: Method, @@ -145,11 +184,13 @@ private class PaperDialogBackend private constructor( private val textBuild: Method, private val dialogBaseBuilder: Method, private val baseInputs: Method, + private val baseBody: Method, private val baseCanClose: Method, private val baseBuild: Method, private val customClick: Method, private val actionButtonBuilder: Method, private val buttonAction: Method, + private val buttonTooltip: Method, private val buttonBuild: Method, private val confirmationType: Method, private val dialogCreate: Method, @@ -186,26 +227,57 @@ private class PaperDialogBackend private constructor( showDialog.invoke(player, dialog) } + override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { + val baseBuilder = dialogBaseBuilder.invoke(null, componentText.invoke(null, request.title)) + val codeText = request.codeRgb?.let { rgb -> + componentColoredText.invoke(null, request.code, textColorRgb.invoke(null, rgb)) + } ?: componentText.invoke(null, request.code) + val codeLine = componentAppend.invoke(componentText.invoke(null, request.codeLabel), codeText) + baseBody.invoke(baseBuilder, listOf( + plainMessage.invoke(null, componentText.invoke(null, request.inviterLine)), + plainMessage.invoke(null, codeLine), + plainMessage.invoke(null, componentText.invoke(null, request.question)), + plainMessage.invoke(null, componentText.invoke(null, request.timeoutPrompt)), + )) + baseCanClose.invoke(baseBuilder, true) + val base = baseBuild.invoke(baseBuilder) + val type = confirmationType.invoke( + null, + button(request.agree, CONFIRM_ACTION, 0x55FF55, request.agreeHint), + button(request.disagree, DECLINE_ACTION, 0xFF5555, request.disagreeHint), + ) + val dialog = dialogCreate.invoke(null, Consumer { factory -> + val builder = registryFactoryEmpty.invoke(factory) + dialogBuilderBase.invoke(builder, base) + dialogBuilderType.invoke(builder, type) + }) + showDialog.invoke(player, dialog) + } + override fun close(player: Player) { closeDialog.invoke(player) } - private fun button(label: String, actionId: String): Any { - val component = componentText.invoke(null, label) + private fun button(label: String, actionId: String, rgb: Int? = null, tooltip: String? = null): Any { + val component = rgb?.let { componentColoredText.invoke(null, label, textColorRgb.invoke(null, it)) } + ?: componentText.invoke(null, label) val key = keyFactory.invoke(null, actionId) val action = customClick.invoke(null, key, null) val builder = actionButtonBuilder.invoke(null, component) buttonAction.invoke(builder, action) + if (tooltip != null) buttonTooltip.invoke(builder, componentText.invoke(null, tooltip)) return buttonBuild.invoke(builder) } override fun readResponse(event: Event): DialogResponse? { val identifier = eventIdentifier.invoke(event).toString() - if (identifier != SUBMIT_ACTION && identifier != CANCEL_ACTION) return null + if (identifier !in setOf(SUBMIT_ACTION, CANCEL_ACTION, CONFIRM_ACTION, DECLINE_ACTION)) return null val connection = eventConnection.invoke(event) if (!gameConnectionClass.isInstance(connection)) return null val player = connectionPlayer.invoke(connection) as? Player ?: return null if (identifier == CANCEL_ACTION) return DialogResponse.Cancelled(player.uniqueId) + if (identifier == CONFIRM_ACTION) return DialogResponse.Confirmed(player.uniqueId) + if (identifier == DECLINE_ACTION) return DialogResponse.Declined(player.uniqueId) val response = eventResponse.invoke(event) ?: return DialogResponse.Submitted(player.uniqueId, null) return DialogResponse.Submitted(player.uniqueId, responseText.invoke(response, INPUT_KEY) as? String) } @@ -214,6 +286,8 @@ private class PaperDialogBackend private constructor( fun create(plugin: Plugin, logger: Logger): DialogBackend? = try { val event = load("io.papermc.paper.event.player.PlayerCustomClickEvent").asSubclass(Event::class.java) val component = load("net.kyori.adventure.text.Component") + val textColor = load("net.kyori.adventure.text.format.TextColor") + val dialogBody = load("io.papermc.paper.registry.data.dialog.body.DialogBody") val key = load("net.kyori.adventure.key.Key") val binaryTag = load("net.kyori.adventure.nbt.api.BinaryTagHolder") val dialogInput = load("io.papermc.paper.registry.data.dialog.input.DialogInput") @@ -241,6 +315,10 @@ private class PaperDialogBackend private constructor( connectionPlayer = gameConnection.getMethod("getPlayer"), responseText = responseView.getMethod("getText", String::class.java), componentText = component.getMethod("text", String::class.java), + componentColoredText = component.getMethod("text", String::class.java, textColor), + textColorRgb = textColor.getMethod("color", Int::class.javaPrimitiveType!!), + componentAppend = component.getMethod("append", component), + plainMessage = dialogBody.getMethod("plainMessage", component), keyFactory = key.getMethod("key", String::class.java), dialogInputText = dialogInput.getMethod("text", String::class.java, component), textWidth = textBuilder.getMethod("width", Int::class.javaPrimitiveType!!), @@ -248,11 +326,13 @@ private class PaperDialogBackend private constructor( textBuild = textBuilder.getMethod("build"), dialogBaseBuilder = dialogBase.getMethod("builder", component), baseInputs = baseBuilder.getMethod("inputs", List::class.java), + baseBody = baseBuilder.getMethod("body", List::class.java), baseCanClose = baseBuilder.getMethod("canCloseWithEscape", Boolean::class.javaPrimitiveType!!), baseBuild = baseBuilder.getMethod("build"), customClick = dialogAction.getMethod("customClick", key, binaryTag), actionButtonBuilder = actionButton.getMethod("builder", component), buttonAction = buttonBuilder.getMethod("action", dialogAction), + buttonTooltip = buttonBuilder.getMethod("tooltip", component), buttonBuild = buttonBuilder.getMethod("build"), confirmationType = dialogType.getMethod("confirmation", actionButton, actionButton), dialogCreate = dialog.getMethod("create", Consumer::class.java), @@ -284,14 +364,22 @@ private class SpigotDialogBackend private constructor( private val jsonObjectGet: Method, private val jsonAsString: Method, private val textComponentConstructor: Constructor<*>, + private val setColor: Method, + private val addExtra: Method, + private val chatColorOf: Method, + private val greenColor: Any, + private val redColor: Any, + private val plainMessageConstructor: Constructor<*>, private val textInputConstructor: Constructor<*>, private val textWidth: Method, private val textMaximumLength: Method, private val dialogBaseConstructor: Constructor<*>, private val baseInputs: Method, + private val baseBody: Method, private val baseCanClose: Method, private val actionConstructor: Constructor<*>, private val buttonConstructor: Constructor<*>, + private val buttonTooltip: Method, private val confirmationConstructor: Constructor<*>, private val confirmationYes: Method, private val confirmationNo: Method, @@ -313,20 +401,48 @@ private class SpigotDialogBackend private constructor( showDialog.invoke(player, dialog) } + override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { + val base = dialogBaseConstructor.newInstance(text(request.title)) + val codeLine = text(request.codeLabel) + val codeText = text(request.code) + request.codeRgb?.let { rgb -> + setColor.invoke(codeText, chatColorOf.invoke(null, "#%06X".format(rgb))) + } + addExtra.invoke(codeLine, codeText) + baseBody.invoke(base, listOf( + plainMessageConstructor.newInstance(text(request.inviterLine)), + plainMessageConstructor.newInstance(codeLine), + plainMessageConstructor.newInstance(text(request.question)), + plainMessageConstructor.newInstance(text(request.timeoutPrompt)), + )) + baseCanClose.invoke(base, true) + val dialog = confirmationConstructor.newInstance(base) + confirmationYes.invoke(dialog, button(request.agree, CONFIRM_ACTION, greenColor, request.agreeHint)) + confirmationNo.invoke(dialog, button(request.disagree, DECLINE_ACTION, redColor, request.disagreeHint)) + showDialog.invoke(player, dialog) + } + override fun close(player: Player) { clearDialog.invoke(player) } private fun text(value: String): Any = textComponentConstructor.newInstance(value) - private fun button(label: String, actionId: String): Any = - buttonConstructor.newInstance(text(label), actionConstructor.newInstance(actionId)) + private fun button(label: String, actionId: String, color: Any? = null, tooltip: String? = null): Any { + val component = text(label) + if (color != null) setColor.invoke(component, color) + val button = buttonConstructor.newInstance(component, actionConstructor.newInstance(actionId)) + if (tooltip != null) buttonTooltip.invoke(button, text(tooltip)) + return button + } override fun readResponse(event: Event): DialogResponse? { val identifier = eventId.invoke(event).toString() - if (identifier != SUBMIT_ACTION && identifier != CANCEL_ACTION) return null + if (identifier !in setOf(SUBMIT_ACTION, CANCEL_ACTION, CONFIRM_ACTION, DECLINE_ACTION)) return null val player = eventPlayer.invoke(event) as? Player ?: return null if (identifier == CANCEL_ACTION) return DialogResponse.Cancelled(player.uniqueId) + if (identifier == CONFIRM_ACTION) return DialogResponse.Confirmed(player.uniqueId) + if (identifier == DECLINE_ACTION) return DialogResponse.Declined(player.uniqueId) val data = eventData.invoke(event) ?: return DialogResponse.Submitted(player.uniqueId, null) val jsonObject = jsonAsObject.invoke(data) val element = jsonObjectGet.invoke(jsonObject, INPUT_KEY) @@ -338,7 +454,9 @@ private class SpigotDialogBackend private constructor( fun create(plugin: Plugin, logger: Logger): DialogBackend? = try { val event = load("org.bukkit.event.player.PlayerCustomClickEvent").asSubclass(Event::class.java) val baseComponent = load("net.md_5.bungee.api.chat.BaseComponent") + val chatColor = load("net.md_5.bungee.api.ChatColor") val textComponent = load("net.md_5.bungee.api.chat.TextComponent") + val plainMessage = load("net.md_5.bungee.api.dialog.body.PlainMessageBody") val dialogInput = load("net.md_5.bungee.api.dialog.input.DialogInput") val textInput = load("net.md_5.bungee.api.dialog.input.TextInput") val dialogBase = load("net.md_5.bungee.api.dialog.DialogBase") @@ -362,14 +480,22 @@ private class SpigotDialogBackend private constructor( jsonObjectGet = jsonObject.getMethod("get", String::class.java), jsonAsString = jsonElement.getMethod("getAsString"), textComponentConstructor = textComponent.getConstructor(String::class.java), + setColor = baseComponent.getMethod("setColor", chatColor), + addExtra = baseComponent.getMethod("addExtra", baseComponent), + chatColorOf = chatColor.getMethod("of", String::class.java), + greenColor = chatColor.getField("GREEN").get(null), + redColor = chatColor.getField("RED").get(null), + plainMessageConstructor = plainMessage.getConstructor(baseComponent), textInputConstructor = textInput.getConstructor(String::class.java, baseComponent), textWidth = textInput.getMethod("width", Int::class.javaObjectType), textMaximumLength = textInput.getMethod("maxLength", Int::class.javaObjectType), dialogBaseConstructor = dialogBase.getConstructor(baseComponent), baseInputs = dialogBase.getMethod("inputs", List::class.java), + baseBody = dialogBase.getMethod("body", List::class.java), baseCanClose = dialogBase.getMethod("canCloseWithEscape", Boolean::class.javaObjectType), actionConstructor = customAction.getConstructor(String::class.java), buttonConstructor = button.getConstructor(baseComponent, action), + buttonTooltip = button.getMethod("tooltip", baseComponent), confirmationConstructor = confirmation.getConstructor(dialogBase), confirmationYes = confirmation.getMethod("yes", button), confirmationNo = confirmation.getMethod("no", button), @@ -393,3 +519,5 @@ private fun load(name: String): Class<*> = Class.forName(name) private const val INPUT_KEY = "invite_code" private const val SUBMIT_ACTION = "invitecode:claim_dialog_submit" private const val CANCEL_ACTION = "invitecode:claim_dialog_cancel" +private const val CONFIRM_ACTION = "invitecode:claim_confirmation_confirm" +private const val DECLINE_ACTION = "invitecode:claim_confirmation_decline" diff --git a/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt b/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt index 8ed9d2d..cbd955a 100644 --- a/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt +++ b/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt @@ -3,6 +3,7 @@ package io.github.command1264.invitecode.platform.modern import io.github.command1264.invitecode.core.InviteCode import io.github.command1264.invitecode.core.InviteCodeFormats import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest +import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest import org.bukkit.entity.Player import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -103,6 +104,41 @@ class ReflectiveNativeDialogInputTest { assertTrue(submissions.isEmpty()) } + @Test + fun `confirmation accepts only the matching dialog action once`() { + val backend = FakeDialogBackend() + val adapter = ReflectiveNativeDialogInput(backend, Logger.getAnonymousLogger()) + val playerId = UUID.randomUUID() + val player = player(playerId) + var confirmations = 0 + var declines = 0 + + assertTrue(adapter.showConfirmation(player, confirmationRequest, { confirmations++ }, { declines++ })) + backend.emit(DialogResponse.Submitted(playerId, "A1B2C3")) + backend.emit(DialogResponse.Confirmed(playerId)) + backend.emit(DialogResponse.Confirmed(playerId)) + assertEquals(1, confirmations) + assertEquals(0, declines) + + assertTrue(adapter.showConfirmation(player, confirmationRequest, { confirmations++ }, { declines++ })) + backend.emit(DialogResponse.Declined(playerId)) + assertEquals(1, confirmations) + assertEquals(1, declines) + } + + @Test + fun `failed confirmation dialog does not leave an active callback`() { + val backend = FakeDialogBackend(failShow = true) + val adapter = ReflectiveNativeDialogInput(backend, Logger.getAnonymousLogger()) + val playerId = UUID.randomUUID() + var confirmations = 0 + + assertFalse(adapter.showConfirmation(player(playerId), confirmationRequest, { confirmations++ }, {})) + backend.emit(DialogResponse.Confirmed(playerId)) + + assertEquals(0, confirmations) + } + private fun player(playerId: UUID): Player = Proxy.newProxyInstance( javaClass.classLoader, arrayOf(Player::class.java), @@ -129,6 +165,10 @@ class ReflectiveNativeDialogInputTest { private companion object { val request = NativeDialogRequest("Title", "Code", "Confirm", "Cancel", 64) + val confirmationRequest = NativeDialogConfirmationRequest( + "Confirm", "Inviter: Alice", "Code: ", "A1B2C3", 0xA1B2C3, + "Use this code?", "Choose within 60 seconds:", "Agree", "Disagree", "Click to agree", "Click to disagree", + ) } } @@ -148,6 +188,10 @@ private class FakeDialogBackend( if (failShow) throw NoSuchMethodException("showDialog") } + override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { + if (failShow) throw NoSuchMethodException("showDialog") + } + override fun close(player: Player) { closeCount++ } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt new file mode 100644 index 0000000..393914c --- /dev/null +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt @@ -0,0 +1,52 @@ +package io.github.command1264.invitecode.plugin + +import net.md_5.bungee.api.ChatColor +import net.md_5.bungee.api.chat.BaseComponent +import net.md_5.bungee.api.chat.ClickEvent +import net.md_5.bungee.api.chat.HoverEvent +import net.md_5.bungee.api.chat.TextComponent + +/** Interactive chat affordances isolated from the legacy text and RGB Invite Code formatter. */ +internal object PlayerChatActions { + fun codeMessage( + template: String, + displayedCode: String, + code: String, + copyHint: String, + selectHint: String, + ): Array { + // COPY_TO_CLIPBOARD is absent from the Bungee chat API bundled by Spigot 1.8.8. + val clipboard = enumValues().firstOrNull { it.name == "COPY_TO_CLIPBOARD" } + val action = clipboard ?: ClickEvent.Action.SUGGEST_COMMAND + val marker = "{code}" + val before = if (marker in template) template.substringBefore(marker) else template + " " + val after = if (marker in template) template.substringAfter(marker) else "" + val codeComponents = TextComponent.fromLegacyText(displayedCode) + codeComponents.forEach { component -> + component.clickEvent = ClickEvent(action, code) + component.hoverEvent = HoverEvent( + HoverEvent.Action.SHOW_TEXT, + arrayOf(TextComponent(if (clipboard != null) copyHint else selectHint)), + ) + } + return TextComponent.fromLegacyText(before) + codeComponents + TextComponent.fromLegacyText(after) + } + + fun confirmation( + agreeLabel: String, + disagreeLabel: String, + agreeHint: String, + disagreeHint: String, + ): Array = arrayOf( + TextComponent("[$agreeLabel]").apply { + color = ChatColor.GREEN + clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/invitecode confirm") + hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, arrayOf(TextComponent(agreeHint))) + }, + TextComponent(" [$disagreeLabel]").apply { + color = ChatColor.RED + clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/invitecode cancel") + hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, arrayOf(TextComponent(disagreeHint))) + }, + ) +} diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt index 4a7ddb3..119b812 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt @@ -33,11 +33,13 @@ import io.github.command1264.invitecode.platform.bukkit.EconomyRewardGateway import io.github.command1264.invitecode.platform.bukkit.AsyncOperationExecutor import io.github.command1264.invitecode.platform.bukkit.AtomicRuntimeSnapshot import io.github.command1264.invitecode.platform.bukkit.ClaimInteractionSessions +import io.github.command1264.invitecode.platform.bukkit.ChatInputResult import io.github.command1264.invitecode.platform.bukkit.ClaimInputChannel import io.github.command1264.invitecode.platform.bukkit.InviteCodeDisplayFormatter import io.github.command1264.invitecode.platform.bukkit.InviteCodeCommandId import io.github.command1264.invitecode.platform.bukkit.InviteCodeRuntimeConfiguration import io.github.command1264.invitecode.platform.bukkit.NativeDialogInput +import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest import io.github.command1264.invitecode.platform.bukkit.PlatformCapabilities import io.github.command1264.invitecode.platform.bukkit.generator @@ -193,10 +195,15 @@ class PlayerWorkflowController( @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) fun onChat(event: AsyncPlayerChatEvent) { val playerId = event.player.uniqueId - val code = sessions.consumeChatInput(playerId, event.message) ?: return + val input = sessions.consumeChatInput(playerId, event.message) ?: return event.isCancelled = true tasks.player(event.player, operation = { - if (tasks.onlinePlayer(playerId) === event.player) beginClaim(event.player, code) + if (tasks.onlinePlayer(playerId) === event.player) { + when (input) { + is ChatInputResult.Code -> beginClaim(event.player, input.value) + ChatInputResult.Cancelled -> send(playerId, "command.claim.cancelled") + } + } }) } @@ -217,26 +224,46 @@ class PlayerWorkflowController( InviteCodeLifecycleService(store, generator, 64).assign(playerId, now()) }, onSuccess = { code -> - send(playerId, "command.code.value", mapOf("code" to display(code.code))) + val player = tasks.onlinePlayer(playerId) ?: return@submit + val messages = configuration.current().value.messages + val locale = BukkitLocaleCompatibility.locale(player) + player.spigot().sendMessage(*PlayerChatActions.codeMessage( + messages.resolve(locale, "command.code.value"), + display(code.code), + code.code.displayValue(), + messages.resolve(locale, "command.code.copy"), + messages.resolve(locale, "command.code.select"), + )) }, ) } private fun claim(player: Player, code: String?) { val playerId = player.uniqueId - if (code != null) { - beginClaim(player, code) - return - } - val runtime = configuration.current().value - val claim = runtime.general.claim - when (claim.inputMode.resolve(capabilities)) { - ClaimInputChannel.COMMAND_ONLY -> send(playerId, "command.claim.command-only") - ClaimInputChannel.DIALOG -> { - if (!startDialogInput(player, runtime)) startChatInput(player, claim.chatInputTimeout) + val snapshot = configuration.current() + submit( + player, + operation = { store -> + ClaimEligibilityPolicy(snapshot.value.general.claim.window).evaluate(store.claimState(playerId), now()) + }, + onSuccess = { eligibility -> + if (!eligibility.eligible) { + sendEligibility(playerId, eligibility) + } else if (code != null) { + beginClaim(player, code) + } else { + val runtime = configuration.current().value + val claim = runtime.general.claim + when (claim.inputMode.resolve(capabilities)) { + ClaimInputChannel.COMMAND_ONLY -> send(playerId, "command.claim.command-only") + ClaimInputChannel.DIALOG -> { + if (!startDialogInput(player, runtime)) startChatInput(player, claim.chatInputTimeout) + } + ClaimInputChannel.CHAT -> startChatInput(player, claim.chatInputTimeout) + } + } } - ClaimInputChannel.CHAT -> startChatInput(player, claim.chatInputTimeout) - } + ) } private fun startDialogInput(player: Player, runtime: InviteCodeRuntimeConfiguration): Boolean { @@ -301,6 +328,7 @@ class PlayerWorkflowController( operation = { store -> prepareClaim(playerId, rawCode, snapshot.value, store) }, onSuccess = { prepared -> when (prepared) { + is PreparedClaim.Ineligible -> sendEligibility(playerId, prepared.eligibility) PreparedClaim.Invalid -> send(playerId, "command.claim.invalid-code") PreparedClaim.Unavailable -> send(playerId, "command.claim.unavailable") PreparedClaim.Self -> send(playerId, "command.claim.self") @@ -308,18 +336,64 @@ class PlayerWorkflowController( sessions.startConfirmation(prepared.confirmation) scheduleTimeout(player, snapshot.value.general.claim.confirmationTimeout) { if (sessions.expireConfirmation(playerId)) { + tasks.onlinePlayer(playerId)?.let(nativeDialogInput::cancel) send(playerId, "command.claim.confirmation-timeout") } } - send( - playerId, + val currentPlayer = tasks.onlinePlayer(playerId) ?: return@submit + val messages = configuration.current().value.messages + val locale = BukkitLocaleCompatibility.locale(currentPlayer) + if (snapshot.value.general.claim.inputMode.resolve(capabilities) == ClaimInputChannel.DIALOG) { + val confirmation = prepared.confirmation + val shown = nativeDialogInput.showConfirmation( + currentPlayer, + NativeDialogConfirmationRequest( + title = messages.resolve(locale, "command.claim.confirmation-title"), + inviterLine = messages.resolve( + locale, "command.claim.confirmation-inviter", + mapOf("inviter" to confirmation.inviterName), + ), + codeLabel = messages.resolve(locale, "command.claim.confirmation-code-label"), + code = confirmation.inviteCode.displayValue(), + codeRgb = confirmation.inviteCode.color?.rgb, + question = messages.resolve(locale, "command.claim.confirmation-question"), + timeoutPrompt = messages.resolve( + locale, "command.claim.confirmation-prompt", + mapOf("seconds" to snapshot.value.general.claim.confirmationTimeout.seconds.toString()), + ), + agree = messages.resolve(locale, "command.claim.agree"), + disagree = messages.resolve(locale, "command.claim.disagree"), + agreeHint = messages.resolve(locale, "command.claim.agree-hover"), + disagreeHint = messages.resolve(locale, "command.claim.disagree-hover"), + ), + onConfirm = { + tasks.player(currentPlayer, operation = { + if (tasks.onlinePlayer(playerId) === currentPlayer) confirm(currentPlayer) + }) + }, + onDecline = { + tasks.player(currentPlayer, operation = { + if (tasks.onlinePlayer(playerId) === currentPlayer) cancel(currentPlayer) + }) + }, + ) + if (shown) return@submit + } + messages.resolve( + locale, "command.claim.confirmation", mapOf( "inviter" to prepared.confirmation.inviterName, "code" to display(prepared.confirmation.inviteCode), "seconds" to snapshot.value.general.claim.confirmationTimeout.seconds.toString(), ), - ) + ).lines().forEach(currentPlayer::sendMessage) + currentPlayer.spigot().sendMessage(*PlayerChatActions.confirmation( + messages.resolve(locale, "command.claim.agree"), + messages.resolve(locale, "command.claim.disagree"), + messages.resolve(locale, "command.claim.agree-hover"), + messages.resolve(locale, "command.claim.disagree-hover"), + )) } } }, @@ -332,6 +406,8 @@ class PlayerWorkflowController( runtime: InviteCodeRuntimeConfiguration, store: InviteCodeStorage, ): PreparedClaim { + val eligibility = ClaimEligibilityPolicy(runtime.general.claim.window).evaluate(store.claimState(inviteeId), now()) + if (!eligibility.eligible) return PreparedClaim.Ineligible(eligibility) val format = runtime.general.inviteCode.format.parser() val code = try { InviteCode.parse(rawCode, format) @@ -360,6 +436,7 @@ class PlayerWorkflowController( send(playerId, "command.claim.no-confirmation") return } + nativeDialogInput.cancel(player) val snapshot = configuration.current() submit( player, @@ -731,6 +808,7 @@ class PlayerWorkflowController( } private sealed class PreparedClaim { + data class Ineligible(val eligibility: ClaimEligibility) : PreparedClaim() object Invalid : PreparedClaim() object Unavailable : PreparedClaim() object Self : PreparedClaim() diff --git a/invitecode-plugin/src/main/resources/config/config.yml b/invitecode-plugin/src/main/resources/config/config.yml index 2344073..b65afbf 100644 --- a/invitecode-plugin/src/main/resources/config/config.yml +++ b/invitecode-plugin/src/main/resources/config/config.yml @@ -11,7 +11,7 @@ invite-code: claim: window: 24h input-mode: AUTO - confirmation-timeout: 30s + confirmation-timeout: 60s chat-input-timeout: 60s existing-player-policy: START_WINDOW diff --git a/invitecode-plugin/src/main/resources/config/messages/en_US.yml b/invitecode-plugin/src/main/resources/config/messages/en_US.yml index c34f6f4..b852f0e 100644 --- a/invitecode-plugin/src/main/resources/config/messages/en_US.yml +++ b/invitecode-plugin/src/main/resources/config/messages/en_US.yml @@ -8,9 +8,11 @@ runtime: command: code: value: "Your Invite Code is {code}" + copy: "Click to copy to clipboard" + select: "Click to insert the Invite Code into chat, then copy it" claim: command-only: "Use /invitecode claim ." - chat-started: "Enter the Invite Code in chat within {seconds} seconds. It will not be published." + chat-started: "Enter the Invite Code in chat within {seconds} seconds. It will not be published. Type cancel to stop." chat-timeout: "Invite Code chat input expired. Run /invitecode claim again." dialog-title: "Enter Invite Code" dialog-label: "Six-character Invite Code" @@ -20,7 +22,16 @@ command: invalid-code: "The Invite Code format is invalid. Check it and try again." unavailable: "That Invite Code does not exist, was rotated, or is no longer active." self: "You cannot use your own Invite Code." - confirmation: "Inviter: {inviter}; Invite Code: {code}. Use /invitecode confirm within {seconds} seconds, or /invitecode cancel." + confirmation: "Inviter: {inviter}\nInvite Code: {code}\nUse this Invite Code?\nChoose within {seconds} seconds" + confirmation-title: "Confirm Invite Code" + confirmation-inviter: "Inviter: {inviter}" + confirmation-code-label: "Invite Code: " + confirmation-question: "Use this Invite Code?" + confirmation-prompt: "Choose within {seconds} seconds" + agree: "Agree" + disagree: "Disagree" + agree-hover: "Click to agree and use this Invite Code" + disagree-hover: "Click to disagree and cancel" confirmation-timeout: "The Claim Confirmation expired. Enter the Invite Code again." no-confirmation: "There is no Claim to confirm, or it has expired." claimed: "The Invitation has been created." diff --git a/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml b/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml index ea5afce..fd53733 100644 --- a/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml +++ b/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml @@ -8,9 +8,11 @@ runtime: command: code: value: "你的邀請碼是 {code}" + copy: "點擊複製到剪貼簿" + select: "點擊將邀請碼填入聊天列,再手動複製" claim: command-only: "請使用 /invitecode claim <邀請碼>。" - chat-started: "請在 {seconds} 秒內於聊天輸入邀請碼;內容不會公開。" + chat-started: "請在 {seconds} 秒內於聊天輸入邀請碼;內容不會公開。輸入 cancel 可取消。" chat-timeout: "邀請碼聊天輸入已逾時,請重新執行 /invitecode claim。" dialog-title: "輸入 Invite Code" dialog-label: "六位 Invite Code" @@ -20,7 +22,16 @@ command: invalid-code: "邀請碼格式無效,請檢查後再試一次。" unavailable: "此邀請碼不存在、已輪替或已失效。" self: "你不能使用自己的邀請碼。" - confirmation: "邀請人為 {inviter},邀請碼為 {code}。請在 {seconds} 秒內使用 /invitecode confirm 確認,或使用 /invitecode cancel 取消。" + confirmation: "邀請人:{inviter}\n邀請碼:{code}\n是否使用這組邀請碼?\n請在 {seconds} 秒內選擇" + confirmation-title: "確認邀請碼" + confirmation-inviter: "邀請人:{inviter}" + confirmation-code-label: "邀請碼:" + confirmation-question: "是否使用這組邀請碼?" + confirmation-prompt: "請在 {seconds} 秒內選擇" + agree: "同意" + disagree: "不同意" + agree-hover: "點擊同意並使用邀請碼" + disagree-hover: "點擊不同意並取消" confirmation-timeout: "邀請確認已逾時,請重新輸入邀請碼。" no-confirmation: "沒有可確認的邀請,或確認已逾時。" claimed: "邀請關係已建立。" diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt new file mode 100644 index 0000000..4ce6108 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt @@ -0,0 +1,43 @@ +package io.github.command1264.invitecode.plugin + +import net.md_5.bungee.api.ChatColor +import net.md_5.bungee.api.chat.ClickEvent +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Test + +class PlayerChatActionsTest { + @Test + fun `the displayed code itself offers the raw code to a legacy client`() { + val components = PlayerChatActions.codeMessage( + "你的邀請碼是 {code}", "§aA1B2C3§r", "A1B2C3", "點擊複製到剪貼簿", "點擊填入聊天列", + ) + val codeComponents = components.filter { it.toPlainText().contains("A1B2C3") } + + assertEquals("你的邀請碼是 A1B2C3", components.joinToString("") { it.toPlainText() }) + assertEquals(1, codeComponents.size) + assertEquals(ChatColor.GREEN, codeComponents.single().color) + assertEquals(ClickEvent.Action.SUGGEST_COMMAND, codeComponents.single().clickEvent.action) + assertEquals("A1B2C3", codeComponents.single().clickEvent.value) + assertEquals("點擊填入聊天列", codeComponents.single().hoverEvent.value.single().toPlainText()) + assertEquals(null, components.first().clickEvent) + } + + @Test + fun `confirmation actions execute only their respective commands`() { + val buttons = PlayerChatActions.confirmation("同意", "不同意", "點擊同意並使用邀請碼", "點擊不同意並取消") + + assertEquals(2, buttons.size) + assertEquals("[同意]", buttons[0].text) + assertEquals(ChatColor.GREEN, buttons[0].color) + assertEquals(ClickEvent.Action.RUN_COMMAND, buttons[0].clickEvent.action) + assertEquals("/invitecode confirm", buttons[0].clickEvent.value) + assertEquals("點擊同意並使用邀請碼", buttons[0].hoverEvent.value.single().toPlainText()) + assertEquals(" [不同意]", buttons[1].text) + assertEquals(ChatColor.RED, buttons[1].color) + assertEquals(ClickEvent.Action.RUN_COMMAND, buttons[1].clickEvent.action) + assertEquals("/invitecode cancel", buttons[1].clickEvent.value) + assertEquals("點擊不同意並取消", buttons[1].hoverEvent.value.single().toPlainText()) + assertFalse(buttons[0].clickEvent.value == buttons[1].clickEvent.value) + } +} diff --git a/scripts/test-servers/common.ps1 b/scripts/test-servers/common.ps1 index 0d09743..224cc3a 100644 --- a/scripts/test-servers/common.ps1 +++ b/scripts/test-servers/common.ps1 @@ -28,27 +28,53 @@ function Get-InviteCodeTestProfile { return $matches[0] } -function Resolve-PluginTestLabRoot { +function Resolve-PluginInstanceHarborRoot { param([AllowNull()][string] $ExplicitRoot) $candidates = [System.Collections.Generic.List[string]]::new() if (-not [string]::IsNullOrWhiteSpace($ExplicitRoot)) { - $candidates.Add($ExplicitRoot) + $resolved = [System.IO.Path]::GetFullPath($ExplicitRoot) + if (-not (Test-Path -LiteralPath (Join-Path $resolved 'scripts\InstanceHarbor.psm1') -PathType Leaf)) { + throw "指定的 InstanceHarbor repository 無效:$resolved" + } + return $resolved + } + if (-not [string]::IsNullOrWhiteSpace($env:PLUGIN_INSTANCEHARBOR_HOME)) { + $candidates.Add($env:PLUGIN_INSTANCEHARBOR_HOME) } if (-not [string]::IsNullOrWhiteSpace($env:PLUGIN_TEST_LAB_HOME)) { $candidates.Add($env:PLUGIN_TEST_LAB_HOME) } $cursor = [System.IO.DirectoryInfo]::new((Get-InviteCodeRepositoryRoot)) while ($null -ne $cursor) { - $candidates.Add((Join-Path $cursor.FullName "TestLab\repo")) + $candidates.Add((Join-Path $cursor.FullName "InstanceHarbor\repo")) $cursor = $cursor.Parent } foreach ($candidate in $candidates) { $resolved = [System.IO.Path]::GetFullPath($candidate) - if (Test-Path -LiteralPath (Join-Path $resolved "scripts\prepare-instance.ps1") -PathType Leaf) { + if (Test-Path -LiteralPath (Join-Path $resolved "scripts\InstanceHarbor.psm1") -PathType Leaf) { return $resolved } } - throw "找不到 TestLab。請合併 TestLab foundation、設定 PLUGIN_TEST_LAB_HOME,或傳入 -TestLabRoot。" + throw "找不到 InstanceHarbor。請設定 PLUGIN_INSTANCEHARBOR_HOME,或傳入 -InstanceHarborRoot。" +} + +function Assert-InviteCodeAgentInstance { + param([string] $Path, [string] $InstancesRoot, [object] $Metadata, [string] $Profile) + $root = [IO.Path]::GetFullPath($InstancesRoot) + $expected = [IO.Path]::GetFullPath((Join-Path $root "Agent\InviteCode\$($Metadata.instance)")) + if ($Metadata.instance -cnotmatch '^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$' -or + [IO.Path]::GetFullPath($Path) -cne $expected -or $Metadata.schemaVersion -ne 2 -or + $Metadata.audience -cne 'Agent' -or $Metadata.project -cne 'InviteCode' -or + $Metadata.profile -cne $Profile -or -not $Metadata.eulaAccepted -or + $Metadata.pluginFile -cnotmatch '^[a-zA-Z0-9][a-zA-Z0-9._-]*\.jar$') { + throw '測試僅允許 metadata 相符的 InstanceHarbor Agent 實例。' + } + # Reject junctions before any launch or data write; lexical containment alone is insufficient. + $cursor = Get-Item -LiteralPath $Path -ErrorAction Stop + while ($null -ne $cursor) { + if ($cursor.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw "Agent 路徑不允許 junction/symlink:$($cursor.FullName)" } + $cursor = $cursor.Parent + } } function Resolve-InviteCodePluginArtifact { diff --git a/scripts/test-servers/doctor.ps1 b/scripts/test-servers/doctor.ps1 index 1617da3..329a022 100644 --- a/scripts/test-servers/doctor.ps1 +++ b/scripts/test-servers/doctor.ps1 @@ -1,11 +1,11 @@ [CmdletBinding()] -param([AllowNull()][string] $TestLabRoot) +param([Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot) . (Join-Path $PSScriptRoot "common.ps1") -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot $matrix = Get-InviteCodeTestMatrix -Import-Module (Join-Path $lab "scripts\TestLab.psm1") -Force -$labProfiles = @(Get-TestLabProfiles) +Import-Module (Join-Path $lab "scripts\InstanceHarbor.psm1") -Force +$labProfiles = @(Get-InstanceHarborProfiles) $rows = foreach ($profile in $matrix.profiles) { $labProfile = @($labProfiles | Where-Object id -CEQ $profile.id) @@ -20,14 +20,14 @@ $rows = foreach ($profile in $matrix.profiles) { Profile = $profile.id Purpose = $profile.purpose Required = $profile.requiredForRelease - TestLab = $labProfile.Count -eq 1 + InstanceHarbor = $labProfile.Count -eq 1 Java = $javaAvailable Runtime = $javaDetail } } -Write-Host "TestLab:$lab" +Write-Host "InstanceHarbor:$lab" $rows | Format-Table -AutoSize -if (@($rows | Where-Object { -not $_.TestLab -or -not $_.Java }).Count -gt 0) { - throw "InviteCode 測試矩陣仍有缺少的 TestLab profile 或 Java runtime。" +if (@($rows | Where-Object { -not $_.InstanceHarbor -or -not $_.Java }).Count -gt 0) { + throw "InviteCode 測試矩陣仍有缺少的 InstanceHarbor profile 或 Java runtime。" } diff --git a/scripts/test-servers/prepare-integration-player.ps1 b/scripts/test-servers/prepare-integration-player.ps1 index 4d6a9d1..fef3a0d 100644 --- a/scripts/test-servers/prepare-integration-player.ps1 +++ b/scripts/test-servers/prepare-integration-player.ps1 @@ -4,10 +4,11 @@ param( [Parameter(Mandatory = $true)][string] $Instance, [Parameter(Mandatory = $true)][string] $Artifact, [Parameter(Mandatory = $true)][string] $SpigotApiJar, + [ValidateSet('paper-1.20.6', 'folia-latest')][string] $PlaceholderProfile = 'paper-1.20.6', [AllowNull()][string] $VaultJar, [AllowNull()][string] $EconomyJar, [AllowNull()][string] $PlaceholderApiJar, - [AllowNull()][string] $TestLabRoot, + [Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot, [switch] $AcceptEula ) @@ -15,7 +16,7 @@ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' . (Join-Path $PSScriptRoot 'common.ps1') -$profile = if ($Scenario -ceq 'Vault') { 'paper-1.21.8' } else { 'paper-1.20.6' } +$profile = if ($Scenario -ceq 'Vault') { 'paper-1.21.8' } else { $PlaceholderProfile } $required = if ($Scenario -ceq 'Vault') { @($SpigotApiJar, $VaultJar, $EconomyJar) } ` else { @($SpigotApiJar, $PlaceholderApiJar) } foreach ($candidate in $required) { @@ -23,11 +24,11 @@ foreach ($candidate in $required) { throw "缺少測試依賴 JAR:$candidate" } } -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot & (Join-Path $PSScriptRoot 'prepare-synthetic-player.ps1') -Profile $profile -Instance $Instance ` - -Artifact $Artifact -TestLabRoot $lab -AcceptEula:$AcceptEula -Import-Module (Join-Path $lab 'scripts\TestLab.psm1') -Force -$instancePath = Get-TestLabInstancePath -Project 'InviteCode' -Instance $Instance + -Artifact $Artifact -InstanceHarborRoot $lab -AcceptEula:$AcceptEula +Import-Module (Join-Path $lab 'scripts\InstanceHarbor.psm1') -Force +$instancePath = Get-InstanceHarborInstancePath -Project 'InviteCode' -Audience Agent -Instance $Instance $plugins = Join-Path $instancePath 'plugins' $data = Join-Path $plugins 'InviteCode' $probe = Join-Path $PSScriptRoot 'synthetic-player\integration-probe' diff --git a/scripts/test-servers/prepare-synthetic-player.ps1 b/scripts/test-servers/prepare-synthetic-player.ps1 index ad28c00..bdec867 100644 --- a/scripts/test-servers/prepare-synthetic-player.ps1 +++ b/scripts/test-servers/prepare-synthetic-player.ps1 @@ -1,33 +1,33 @@ [CmdletBinding()] param( [Parameter(Mandatory = $true)] - [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest', 'folia-latest')] + [ValidateSet('spigot-1.8.8', 'spigot-latest', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest', 'folia-latest')] [string] $Profile, [Parameter(Mandatory = $true)][string] $Instance, [Parameter(Mandatory = $true)][string] $Artifact, [switch] $AcceptEula, [switch] $RewardInterruption, - [AllowNull()][string] $TestLabRoot + [Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' . (Join-Path $PSScriptRoot 'common.ps1') -if ($Instance -cnotmatch '^issue12-[a-zA-Z0-9-]{1,72}$') { - throw '合成玩家測試需要新的 issue12-* TestLab instance 名稱。' +if ($Instance -cnotmatch '^issue12-[a-zA-Z0-9-]{1,56}$') { + throw '合成玩家測試需要新的 issue12-* InstanceHarbor instance 名稱。' } if ($RewardInterruption -and $Profile -cne 'spigot-1.8.8') { throw 'Reward 中斷測試目前只在 Spigot 1.8.8 的隔離實例執行。' } -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot -Import-Module (Join-Path $lab 'scripts\TestLab.psm1') -Force -$instancePath = Get-TestLabInstancePath -Project 'InviteCode' -Instance $Instance +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot +Import-Module (Join-Path $lab 'scripts\InstanceHarbor.psm1') -Force +$instancePath = Get-InstanceHarborInstancePath -Project 'InviteCode' -Audience Agent -Instance $Instance if (Test-Path -LiteralPath $instancePath) { throw "合成玩家測試必須使用全新隔離實例;目標已存在:$instancePath" } & (Join-Path $PSScriptRoot 'prepare.ps1') -Profile $Profile -Instance $Instance ` - -Artifact $Artifact -TestLabRoot $lab -AcceptEula:$AcceptEula + -Artifact $Artifact -InstanceHarborRoot $lab -AcceptEula:$AcceptEula $data = Join-Path $instancePath 'plugins\InviteCode' New-Item -ItemType Directory -Path $data -Force | Out-Null diff --git a/scripts/test-servers/prepare.ps1 b/scripts/test-servers/prepare.ps1 index 0c73812..37753db 100644 --- a/scripts/test-servers/prepare.ps1 +++ b/scripts/test-servers/prepare.ps1 @@ -2,7 +2,7 @@ param( [Parameter(Mandatory = $true)][string] $Profile, [AllowNull()][string] $Artifact, - [AllowNull()][string] $TestLabRoot, + [Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot, [AllowNull()][string] $Instance, [switch] $AcceptEula, [switch] $Replace @@ -10,12 +10,12 @@ param( . (Join-Path $PSScriptRoot "common.ps1") $matrixProfile = Get-InviteCodeTestProfile -Id $Profile -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot $jar = Resolve-InviteCodePluginArtifact -ExplicitArtifact $Artifact $instanceName = if ([string]::IsNullOrWhiteSpace($Instance)) { "invitecode-$Profile" } else { $Instance } & (Join-Path $lab "scripts\prepare-instance.ps1") ` - -Project "InviteCode" ` + -Project "InviteCode" -Audience Agent ` -Instance $instanceName ` -Profile $Profile ` -PluginJar $jar ` @@ -23,5 +23,5 @@ $instanceName = if ([string]::IsNullOrWhiteSpace($Instance)) { "invitecode-$Prof -AcceptEula:$AcceptEula ` -Replace:$Replace if ($LASTEXITCODE -ne 0) { - throw "TestLab prepare-instance 失敗,結束碼為 $LASTEXITCODE。" + throw "InstanceHarbor prepare-instance 失敗,結束碼為 $LASTEXITCODE。" } diff --git a/scripts/test-servers/smoke.ps1 b/scripts/test-servers/smoke.ps1 index 2547d83..fcf3acb 100644 --- a/scripts/test-servers/smoke.ps1 +++ b/scripts/test-servers/smoke.ps1 @@ -5,7 +5,7 @@ param( [ValidateSet('SQLITE', 'JSON', 'MYSQL')][string] $Backend = 'SQLITE', [switch] $ExpectPlaceholderApi, [switch] $ExpectVaultEconomy, - [AllowNull()][string] $TestLabRoot, + [Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot, [ValidateRange(10, 600)][int] $TimeoutSeconds = 180 ) @@ -13,29 +13,37 @@ Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" . (Join-Path $PSScriptRoot "common.ps1") -# Only operate on an already prepared, isolated TestLab instance. EULA acceptance +# Only operate on an already prepared, isolated InstanceHarbor instance. EULA acceptance # and replacement remain explicit prepare-instance operations. -if ($Instance -cnotmatch '^[a-zA-Z0-9][a-zA-Z0-9-]{0,79}$') { - throw "無效的 TestLab instance 名稱:$Instance" +if ($Instance -cnotmatch '^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$') { + throw "無效的 InstanceHarbor instance 名稱:$Instance" } [void] (Get-InviteCodeTestProfile -Id $Profile) -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot -Import-Module (Join-Path $lab 'scripts\TestLab.psm1') -Force -$instancePath = Get-TestLabInstancePath -Project 'InviteCode' -Instance $Instance +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot +Import-Module (Join-Path $lab 'scripts\InstanceHarbor.psm1') -Force +$instancePath = Get-InstanceHarborInstancePath -Project 'InviteCode' -Audience Agent -Instance $Instance $metadataPath = Join-Path $instancePath 'workspace.json' if (-not (Test-Path -LiteralPath $metadataPath -PathType Leaf)) { - throw "找不到 TestLab instance:$metadataPath" + throw "找不到 InstanceHarbor instance:$metadataPath" } $metadata = Get-Content -LiteralPath $metadataPath -Raw -Encoding UTF8 | ConvertFrom-Json +Assert-InviteCodeAgentInstance -Path $instancePath -InstancesRoot (Get-InstanceHarborContext).InstancesRoot -Metadata $metadata -Profile $Profile if ($metadata.project -cne 'InviteCode' -or $metadata.instance -cne $Instance -or $metadata.profile -cne $Profile -or -not $metadata.eulaAccepted) { - throw "TestLab metadata 不符,或尚未記錄 EULA 接受狀態:$Instance" + throw "InstanceHarbor metadata 不符,或尚未記錄 EULA 接受狀態:$Instance" } $pluginPath = Join-Path (Join-Path $instancePath 'plugins') $metadata.pluginFile $serverPath = Join-Path $instancePath 'server.jar' +$properties = Get-Content -LiteralPath (Join-Path $instancePath 'server.properties') -Raw -Encoding UTF8 +if ($properties -notmatch '(?m)^server-ip=127\.0\.0\.1\s*$' -or + $properties -notmatch '(?m)^online-mode=false\s*$' -or + $properties -notmatch "(?m)^server-port=$($metadata.port)\s*$" -or + @(Get-NetTCPConnection -LocalPort $metadata.port -State Listen -ErrorAction SilentlyContinue).Count -gt 0) { + throw 'Smoke 需要 loopback、offline mode、正確且未被監聽的 port。' +} if (-not (Test-Path -LiteralPath $serverPath -PathType Leaf) -or -not (Test-Path -LiteralPath $pluginPath -PathType Leaf)) { - throw "TestLab instance 缺少 server.jar 或插件 JAR:$Instance" + throw "InstanceHarbor instance 缺少 server.jar 或插件 JAR:$Instance" } $pluginSha = (Get-FileHash -LiteralPath $pluginPath -Algorithm SHA256).Hash if ($pluginSha -cne $metadata.pluginSha256) { @@ -81,6 +89,8 @@ $commandsSent = $false $stopped = $false $placeholderExpected = $ExpectPlaceholderApi.IsPresent.ToString().ToLowerInvariant() $vaultExpected = $ExpectVaultEconomy.IsPresent.ToString().ToLowerInvariant() +$integrationPattern = '(?:Integration:|Integrations: )PlaceholderAPI=(true|false)(?:,|, )Vault Economy=(true|false)' +$expectedIntegrationPattern = "(?:Integration:|Integrations: )PlaceholderAPI=$placeholderExpected(?:,|, )Vault Economy=$vaultExpected" $deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds) $utf8Strict = [System.Text.UTF8Encoding]::new($false, $true) function Read-LiveLog { @@ -95,7 +105,7 @@ function Read-LiveLog { } try { $runStartedAt = [DateTime]::UtcNow - if (-not $process.Start()) { throw "無法啟動 TestLab instance:$Instance" } + if (-not $process.Start()) { throw "無法啟動 InstanceHarbor instance:$Instance" } $started = $true while ([DateTime]::UtcNow -lt $deadline) { if ($process.HasExited) { break } @@ -112,8 +122,8 @@ try { throw "Folia 拒絕載入尚未宣告支援的 InviteCode:$Instance" } if ($doctorSent -and - $log -match 'Integration:PlaceholderAPI=(true|false),Vault Economy=(true|false)' -and - $log -notmatch "Integration:PlaceholderAPI=$placeholderExpected,Vault Economy=$vaultExpected") { + $log -match $integrationPattern -and + $log -notmatch $expectedIntegrationPattern) { throw "外部整合診斷與預期不符:PlaceholderAPI=$placeholderExpected,Vault Economy=$vaultExpected;$Instance" } if (-not $doctorSent -and $log -match 'Done \(' -and @@ -123,16 +133,16 @@ try { $doctorSent = $true } if ($doctorSent -and $log -match 'Runtime=ACTIVE' -and - $log -match "Integration:PlaceholderAPI=$placeholderExpected,Vault Economy=$vaultExpected" -and - $log -match "$Backend 儲存版本=" -and + $log -match $expectedIntegrationPattern -and + $log -match "$Backend (?:儲存版本|storage version)=" -and -not $commandsSent) { $process.StandardInput.WriteLine('ic help') $process.StandardInput.WriteLine('ic reload') $process.StandardInput.Flush() $commandsSent = $true } - if ($commandsSent -and $log -match 'InviteCode 可用指令:' -and - $log -match 'InviteCode 設定已完整驗證並套用。') { + if ($commandsSent -and $log -match '(?:InviteCode 可用指令:|Available InviteCode commands:)' -and + $log -match '(?:InviteCode 設定已完整驗證並套用。|InviteCode validated and applied the complete configuration snapshot\.)') { $process.StandardInput.WriteLine('stop') $process.StandardInput.Flush() $stopped = $true diff --git a/scripts/test-servers/start.ps1 b/scripts/test-servers/start.ps1 index a2cf8ff..bfb716f 100644 --- a/scripts/test-servers/start.ps1 +++ b/scripts/test-servers/start.ps1 @@ -1,16 +1,16 @@ [CmdletBinding()] param( [Parameter(Mandatory = $true)][string] $Profile, - [AllowNull()][string] $TestLabRoot, + [Alias("TestLabRoot")][AllowNull()][string] $InstanceHarborRoot, [AllowNull()][string] $Instance ) . (Join-Path $PSScriptRoot "common.ps1") [void] (Get-InviteCodeTestProfile -Id $Profile) -$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +$lab = Resolve-PluginInstanceHarborRoot -ExplicitRoot $InstanceHarborRoot $instanceName = if ([string]::IsNullOrWhiteSpace($Instance)) { "invitecode-$Profile" } else { $Instance } -& (Join-Path $lab "scripts\start-instance.ps1") -Project "InviteCode" -Instance $instanceName +& (Join-Path $lab "scripts\start-instance.ps1") -Project "InviteCode" -Audience Agent -Instance $instanceName if ($LASTEXITCODE -ne 0) { - throw "TestLab start-instance 失敗,結束碼為 $LASTEXITCODE。" + throw "InstanceHarbor start-instance 失敗,結束碼為 $LASTEXITCODE。" } diff --git a/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java b/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java index 3941ed8..3885a39 100644 --- a/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java +++ b/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java @@ -13,13 +13,24 @@ public final class FaultPlugin extends JavaPlugin { @Override public void onEnable() { - File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); - armed = instance.getName().startsWith("issue12-") + File instance; + try { + instance = getDataFolder().getCanonicalFile().getParentFile().getParentFile(); + } catch (java.io.IOException error) { + throw new IllegalStateException("Cannot resolve isolated Agent instance", error); + } + File project = instance.getParentFile(); + File audience = project == null ? null : project.getParentFile(); + File instances = audience == null ? null : audience.getParentFile(); + armed = project != null && "InviteCode".equals(project.getName()) + && audience != null && "Agent".equals(audience.getName()) + && instances != null && "instances".equals(instances.getName()) + && instance.getName().startsWith("issue12-") && new File(instance, "workspace.json").isFile() && "127.0.0.1".equals(getServer().getIp()) && !getServer().getOnlineMode(); if (!armed) { - getLogger().severe("Fault probe disabled outside an isolated loopback TestLab instance."); + getLogger().severe("Fault probe disabled outside an isolated loopback InstanceHarbor Agent instance."); } } diff --git a/scripts/test-servers/synthetic-player/flow.cjs b/scripts/test-servers/synthetic-player/flow.cjs index 640aec0..09972c1 100644 --- a/scripts/test-servers/synthetic-player/flow.cjs +++ b/scripts/test-servers/synthetic-player/flow.cjs @@ -2,39 +2,45 @@ const fs = require('node:fs') const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') +const { assertAgentInstance } = require('./instance-boundary.cjs') -const instancePath = path.resolve(process.argv[2] || '') +let instancePath = path.resolve(process.argv[2] || '') const metadataPath = path.join(instancePath, 'workspace.json') const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf8')) -const supportedProfiles = new Set(['spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest', 'folia-latest']) -if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || - !metadata.instance.startsWith('issue12-') || !supportedProfiles.has(metadata.profile) || +instancePath = assertAgentInstance(instancePath, metadata) +const supportedProfiles = new Set(['spigot-1.8.8', 'spigot-latest', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest', 'folia-latest']) +if (!supportedProfiles.has(metadata.profile) || !metadata.eulaAccepted) { throw new Error('Expected a prepared, EULA-accepted, isolated InviteCode synthetic-player instance') } const clientPath = process.env.INVITECODE_SYNTHETIC_CLIENT_262 -if (metadata.profile === 'paper-latest' && metadata.minecraftVersion !== '26.2') { - throw new Error('The pinned independent test client only supports Paper 26.2') +if (['paper-latest', 'spigot-latest'].includes(metadata.profile) && metadata.minecraftVersion !== '26.2') { + throw new Error('The pinned independent test client only supports Minecraft 26.2') } if (metadata.profile === 'folia-latest' && metadata.minecraftVersion !== '26.1.2') { throw new Error('The pinned official test client only supports the selected Folia 26.1.2 fixture') } -if (metadata.profile === 'paper-latest' && +if (['paper-latest', 'spigot-latest'].includes(metadata.profile) && (!clientPath || !path.isAbsolute(clientPath) || !fs.existsSync(path.join(clientPath, 'package.json')))) { - throw new Error('Paper 26.2 needs an absolute test-only client path in INVITECODE_SYNTHETIC_CLIENT_262') + throw new Error('Minecraft 26.2 needs an absolute test-only client path in INVITECODE_SYNTHETIC_CLIENT_262') } -const mineflayer = metadata.profile === 'paper-latest' ? require(clientPath) : require('mineflayer') -if (metadata.profile === 'paper-latest' && +const mineflayer = ['paper-latest', 'spigot-latest'].includes(metadata.profile) ? require(clientPath) : require('mineflayer') +if (['paper-latest', 'spigot-latest'].includes(metadata.profile) && require(path.join(clientPath, 'package.json')).version !== '4.37.1+complexity.26.2.3') { - throw new Error('Unexpected Paper 26.2 test client version') + throw new Error('Unexpected Minecraft 26.2 test client version') } const dataDirectory = path.join(instancePath, 'plugins', 'InviteCode') const config = fs.readFileSync(path.join(dataDirectory, 'config.yml'), 'utf8') const qualifications = fs.readFileSync(path.join(dataDirectory, 'qualifications.yml'), 'utf8') -const chatMode = metadata.profile === 'folia-latest' && process.env.INVITECODE_FOLIA_CHAT === '1' +const chatMode = process.env.INVITECODE_CHAT_INPUT === '1' || + (metadata.profile === 'folia-latest' && process.env.INVITECODE_FOLIA_CHAT === '1') +const dialogMode = ['folia-latest', 'paper-latest', 'spigot-latest'].includes(metadata.profile) && + process.env.INVITECODE_DIALOG_PROTOCOL === '1' +if (chatMode && dialogMode) throw new Error('Select either chat or dialog protocol input') if (!/default: en_US/.test(config) || !/use-client-locale: false/.test(config) || - !(chatMode ? /input-mode: CHAT/.test(config) : /input-mode: COMMAND_ONLY/.test(config)) || + !(chatMode ? /input-mode: CHAT/.test(config) + : dialogMode ? /input-mode: DIALOG/.test(config) : /input-mode: COMMAND_ONLY/.test(config)) || !/matching-ip-action: ALLOW/.test(config) || !/type: LOGIN_DAYS\s+at-least: 1/.test(qualifications)) { throw new Error('Synthetic-player fixture configuration does not match the expected isolated test policy') @@ -54,7 +60,7 @@ function sha256(file) { } if (sha256(path.join(instancePath, 'server.jar')) !== metadata.serverSha256 || sha256(path.join(instancePath, 'plugins', metadata.pluginFile)) !== metadata.pluginSha256) { - throw new Error('TestLab server or plugin artifact differs from workspace.json') + throw new Error('InstanceHarbor server or plugin artifact differs from workspace.json') } const mise = process.env.MISE_EXE || 'mise' @@ -118,6 +124,7 @@ async function createBot(name) { auth: 'offline', version: metadata.minecraftVersion }) const messages = [] + const state = { bot, messages, expectedClose: false } bot.on('messagestr', message => { messages.push(message) process.stdout.write(`${name}: ${message}\n`) @@ -126,13 +133,15 @@ async function createBot(name) { if (error.name !== 'PartialReadError') fatalError = error process.stderr.write(`${name} protocol warning: ${error.name}: ${error.message}\n`) }) - bot.on('kicked', reason => { fatalError = new Error(`${name} kicked: ${reason}`) }) + bot.on('kicked', reason => { + if (!state.expectedClose) fatalError = new Error(`${name} kicked: ${reason}`) + }) await new Promise((resolve, reject) => { const timer = setTimeout(() => reject(new Error(`${name} spawn timeout`)), 30000) bot.once('spawn', () => { clearTimeout(timer); resolve() }) bot.once('end', reason => { clearTimeout(timer); reject(new Error(`${name} ended before spawn: ${reason}`)) }) }) - return { bot, messages } + return state } async function command(player, input, expected) { @@ -152,6 +161,7 @@ let inviter let invitee let regionA let regionB +let passed async function main() { try { server = await startServer() @@ -177,14 +187,37 @@ async function main() { inviter = null await delay(500) invitee = await createBot('IcTestB') - if (chatMode) { + if (dialogMode) { + const dialogs = [] + invitee.bot._client.on('show_dialog', packet => dialogs.push(packet)) + invitee.bot.chat('/ic claim') + await until(() => dialogs.length === 1, 'native dialog packet') + await command(invitee, '/ic cancel', /cancelled/i) + await command(invitee, '/ic status', /Invitation=none/) + invitee.bot.chat('/ic claim') + await until(() => dialogs.length === 2, 'second native dialog packet') + await command(invitee, '/ic cancel', /cancelled/i) + await command(invitee, '/ic status', /Invitation=none/) + invitee.bot.chat(`/ic claim ${code}`) + await until(() => dialogs.length === 3, 'native confirmation dialog packet') + } else if (chatMode) { + await command(invitee, '/ic claim', /Enter the Invite Code in chat/) + const cancelStart = invitee.messages.length + invitee.bot.chat('CaNcEl') + await until(() => invitee.messages.slice(cancelStart).some(message => /cancelled/i.test(message)), + 'private chat cancel') + await command(invitee, '/ic status', /Invitation=none/) await command(invitee, '/ic claim', /Enter the Invite Code in chat/) const start = invitee.messages.length invitee.bot.chat(code) await until(() => invitee.messages.slice(start).some(message => - /Inviter: IcTestA; Invite Code:/.test(message)), 'private chat claim confirmation') + /Inviter: IcTestA/.test(message)), 'private chat claim confirmation') } else { - await command(invitee, `/ic claim ${code}`, /Inviter: IcTestA; Invite Code:/) + await command(invitee, `/ic claim ${code}`, /Inviter: IcTestA/) + } + if (!dialogMode) { + await until(() => invitee.messages.some(message => message.includes('[Agree]') && + message.includes('[Disagree]')), 'clickable confirmation labels') } await command(invitee, '/ic confirm', /The Invitation has been created\./) await until(() => invitee.messages.some(message => message.includes('You have qualified as an invitee.')), 'Invitee Reward') @@ -198,23 +231,29 @@ async function main() { await until(() => inviter.messages.some(message => message.includes('Your invitation has qualified.')), 'offline Inviter Reward') await doctor(server, /Reward backlog: PENDING=0, PROCESSING=0, UNCERTAIN=0/) await command(inviter, '/ic stats', /qualified=1/) - process.stdout.write(JSON.stringify({ + passed = { result: 'PASS', profile: metadata.profile, minecraftVersion: metadata.minecraftVersion, instance: metadata.instance, pluginSha256: metadata.pluginSha256, checks: [ ...(metadata.profile === 'folia-latest' && process.env.INVITECODE_FOLIA_MULTI_REGION === '1' ? ['separate-region-status'] : []), ...(chatMode ? ['private-chat-input'] : []), - 'code', 'claim', 'confirm', 'qualification', 'pending-after-restart', 'offline-reward-on-login', 'stats' + ...(chatMode ? ['chat-cancel'] : []), + ...(dialogMode ? ['input-and-confirmation-dialog-packets', 'command-cancel-preserves-state'] : []), + 'code', 'claim', 'confirm', 'qualification', + 'pending-after-restart', 'offline-reward-on-login', 'stats' ] - }) + '\n') + } } finally { - if (inviter) inviter.bot.quit() - if (invitee) invitee.bot.quit() - if (regionA) regionA.bot.quit() - if (regionB) regionB.bot.quit() + for (const player of [inviter, invitee, regionA, regionB]) { + if (player) { + player.expectedClose = true + player.bot.quit() + } + } if (server) await stopServer(server) } + process.stdout.write(JSON.stringify(passed) + '\n') } main().catch(error => { console.error(error); process.exitCode = 1 }) diff --git a/scripts/test-servers/synthetic-player/instance-boundary.cjs b/scripts/test-servers/synthetic-player/instance-boundary.cjs new file mode 100644 index 0000000..1952602 --- /dev/null +++ b/scripts/test-servers/synthetic-player/instance-boundary.cjs @@ -0,0 +1,39 @@ +const fs = require('node:fs') +const path = require('node:path') + +const DEFAULT_INSTANCES_ROOT = 'D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances' + +function assertAgentInstance(instancePath, metadata, instancesRoot = DEFAULT_INSTANCES_ROOT) { + const requestedPath = path.resolve(instancePath) + let physicalPath + let physicalRoot + try { + if (fs.lstatSync(instancesRoot).isSymbolicLink()) { + throw new Error('instances root must not be a link or junction') + } + physicalPath = fs.realpathSync(requestedPath) + physicalRoot = fs.realpathSync(instancesRoot) + } catch (error) { + throw new Error(`Expected an existing physical Agent instance path: ${error.message}`) + } + const relative = path.relative(physicalRoot, physicalPath) + const parts = relative.split(path.sep) + const instance = path.basename(physicalPath) + if (relative.startsWith('..') || path.isAbsolute(relative) || parts.length !== 3 || + parts[0] !== 'Agent' || parts[1] !== 'InviteCode' || parts[2] !== instance || + !/^issue12-[a-z0-9-]+$/.test(instance) || + !metadata || metadata.schemaVersion !== 2 || metadata.audience !== 'Agent' || + metadata.project !== 'InviteCode' || metadata.instance !== instance) { + throw new Error('Expected an Agent instance at the physical InstanceHarbor/instances/Agent/InviteCode/issue12-* path') + } + if (metadata.pluginFile !== undefined && + (typeof metadata.pluginFile !== 'string' || !metadata.pluginFile || + path.basename(metadata.pluginFile) !== metadata.pluginFile || /[\\/]/.test(metadata.pluginFile) || + /[:]/.test(metadata.pluginFile) || metadata.pluginFile.length > 64 || + metadata.pluginFile === '.' || metadata.pluginFile === '..')) { + throw new Error('workspace.json pluginFile must be a safe basename') + } + return physicalPath +} + +module.exports = { assertAgentInstance } diff --git a/scripts/test-servers/synthetic-player/instance-boundary.test.cjs b/scripts/test-servers/synthetic-player/instance-boundary.test.cjs new file mode 100644 index 0000000..d36e3cd --- /dev/null +++ b/scripts/test-servers/synthetic-player/instance-boundary.test.cjs @@ -0,0 +1,81 @@ +const assert = require('node:assert/strict') +const fs = require('node:fs') +const os = require('node:os') +const path = require('node:path') +const test = require('node:test') +const { assertAgentInstance } = require('./instance-boundary.cjs') + +function fixture() { + const temporary = fs.mkdtempSync(path.join(os.tmpdir(), 'invitecode-boundary-')) + const instancesRoot = path.join(temporary, 'InstanceHarbor', 'instances') + const instancePath = path.join(instancesRoot, 'Agent', 'InviteCode', 'issue12-test') + fs.mkdirSync(instancePath, { recursive: true }) + return { + temporary, + instancesRoot, + instancePath, + metadata: { + schemaVersion: 2, + audience: 'Agent', + project: 'InviteCode', + instance: 'issue12-test', + pluginFile: 'InviteCode.jar' + } + } +} + +test('accepts a physical Agent/InviteCode issue12 instance', t => { + const f = fixture() + t.after(() => fs.rmSync(f.temporary, { recursive: true, force: true })) + assert.equal(assertAgentInstance(f.instancePath, f.metadata, f.instancesRoot), f.instancePath) +}) + +test('rejects Human and Legacy directories even when renamed issue12', t => { + const f = fixture() + t.after(() => fs.rmSync(f.temporary, { recursive: true, force: true })) + for (const audience of ['Human', 'Legacy']) { + const candidate = path.join(f.instancesRoot, audience, 'InviteCode', 'issue12-test') + fs.mkdirSync(candidate, { recursive: true }) + assert.throws(() => assertAgentInstance(candidate, f.metadata, f.instancesRoot), /Agent instance/) + } +}) + +test('rejects incorrect metadata and unsafe plugin filenames', t => { + const f = fixture() + t.after(() => fs.rmSync(f.temporary, { recursive: true, force: true })) + for (const patch of [ + { schemaVersion: 1 }, { audience: 'Human' }, { project: 'Other' }, { instance: 'issue12-other' }, + { pluginFile: '..\\InviteCode.jar' }, { pluginFile: 'subdir/InviteCode.jar' }, + { pluginFile: 'InviteCode.jar:stream' }, { pluginFile: `${'a'.repeat(61)}.jar` } + ]) { + assert.throws(() => assertAgentInstance(f.instancePath, { ...f.metadata, ...patch }, f.instancesRoot), /Agent instance|pluginFile/) + } +}) + +test('rejects a symlink or junction escaping the Agent boundary', t => { + const f = fixture() + t.after(() => fs.rmSync(f.temporary, { recursive: true, force: true })) + const human = path.join(f.instancesRoot, 'Human', 'InviteCode', 'issue12-test') + fs.mkdirSync(human, { recursive: true }) + fs.rmSync(f.instancePath, { recursive: true }) + try { + fs.symlinkSync(human, f.instancePath, process.platform === 'win32' ? 'junction' : 'dir') + } catch (error) { + if (process.platform === 'win32' && ['EPERM', 'EACCES', 'UNKNOWN'].includes(error.code)) { + t.skip(`junction creation unavailable: ${error.code}`) + return + } + throw error + } + assert.throws(() => assertAgentInstance(f.instancePath, f.metadata, f.instancesRoot), /physical path|Agent instance/) +}) + +test('rejects a redirected instances root even with a matching Agent subtree', t => { + const f = fixture() + t.after(() => fs.rmSync(f.temporary, { recursive: true, force: true })) + const redirected = path.join(f.temporary, 'outside') + fs.mkdirSync(path.join(redirected, 'Agent', 'InviteCode', 'issue12-test'), { recursive: true }) + fs.rmSync(f.instancesRoot, { recursive: true }) + fs.symlinkSync(redirected, f.instancesRoot, process.platform === 'win32' ? 'junction' : 'dir') + assert.throws(() => assertAgentInstance(f.instancePath, f.metadata, f.instancesRoot), /root.*link|root.*junction/) +}) diff --git a/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java b/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java index de53b54..1a662d6 100644 --- a/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java +++ b/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java @@ -1,48 +1,67 @@ package io.github.command1264.invitecode.test; import java.io.File; -import java.util.HashSet; +import java.util.Map; import java.util.Set; import java.util.UUID; -import me.clip.placeholderapi.PlaceholderAPI; +import java.util.concurrent.ConcurrentHashMap; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; /** Test-only PlaceholderAPI expansion whose value changes through a console command. */ -public final class PapiProbePlugin extends JavaPlugin { - private final Set ready = new HashSet<>(); +public final class PapiProbePlugin extends JavaPlugin implements Listener { + private final Set ready = ConcurrentHashMap.newKeySet(); + private final Map playersByName = new ConcurrentHashMap<>(); private boolean armed; @Override public void onEnable() { - File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); - armed = instance.getName().startsWith("issue12-") + File instance; + try { + instance = getDataFolder().getCanonicalFile().getParentFile().getParentFile(); + } catch (java.io.IOException error) { + throw new IllegalStateException("Cannot resolve isolated Agent instance", error); + } + File project = instance.getParentFile(); + File audience = project == null ? null : project.getParentFile(); + File instances = audience == null ? null : audience.getParentFile(); + armed = project != null && "InviteCode".equals(project.getName()) + && audience != null && "Agent".equals(audience.getName()) + && instances != null && "instances".equals(instances.getName()) + && instance.getName().startsWith("issue12-") && new File(instance, "workspace.json").isFile() && "127.0.0.1".equals(getServer().getIp()) && !getServer().getOnlineMode(); if (!armed) { - getLogger().severe("Placeholder probe disabled outside an isolated loopback TestLab instance."); + getLogger().severe("Placeholder probe disabled outside an isolated loopback InstanceHarbor Agent instance."); return; } + getServer().getPluginManager().registerEvents(this, this); if (!new ProbeExpansion().register()) throw new IllegalStateException("Cannot register icprobe expansion"); } + @EventHandler + public void onJoin(PlayerJoinEvent event) { + playersByName.put(event.getPlayer().getName(), event.getPlayer().getUniqueId()); + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!armed || !sender.equals(getServer().getConsoleSender()) || args.length != 2 || !"ready".equals(args[0])) return false; - Player player = getServer().getPlayerExact(args[1]); - if (player == null) { + UUID playerId = playersByName.get(args[1]); + if (playerId == null) { sender.sendMessage("ICPROBE player-offline " + args[1]); return true; } - ready.add(player.getUniqueId()); - sender.sendMessage("ICPROBE ready " + args[1] + " " - + PlaceholderAPI.setPlaceholders(player, "%icprobe_ready%")); + ready.add(playerId); + sender.sendMessage("ICPROBE ready " + args[1] + " yes"); return true; } diff --git a/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java b/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java index 0f72e32..8fe6e3b 100644 --- a/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java +++ b/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java @@ -15,12 +15,23 @@ public final class VaultProbePlugin extends JavaPlugin { @Override public void onEnable() { - File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); - armed = instance.getName().startsWith("issue12-") + File instance; + try { + instance = getDataFolder().getCanonicalFile().getParentFile().getParentFile(); + } catch (java.io.IOException error) { + throw new IllegalStateException("Cannot resolve isolated Agent instance", error); + } + File project = instance.getParentFile(); + File audience = project == null ? null : project.getParentFile(); + File instances = audience == null ? null : audience.getParentFile(); + armed = project != null && "InviteCode".equals(project.getName()) + && audience != null && "Agent".equals(audience.getName()) + && instances != null && "instances".equals(instances.getName()) + && instance.getName().startsWith("issue12-") && new File(instance, "workspace.json").isFile() && "127.0.0.1".equals(getServer().getIp()) && !getServer().getOnlineMode(); - if (!armed) getLogger().severe("Vault probe disabled outside an isolated loopback TestLab instance."); + if (!armed) getLogger().severe("Vault probe disabled outside an isolated loopback InstanceHarbor Agent instance."); } @Override diff --git a/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml b/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml index 3ba098b..82fd5f2 100644 --- a/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml +++ b/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml @@ -1,6 +1,7 @@ name: InviteCodePapiProbe version: 1.0.0 api-version: '1.13' +folia-supported: true main: io.github.command1264.invitecode.test.PapiProbePlugin depend: [PlaceholderAPI] commands: diff --git a/scripts/test-servers/synthetic-player/integration.cjs b/scripts/test-servers/synthetic-player/integration.cjs index eee7355..e86abec 100644 --- a/scripts/test-servers/synthetic-player/integration.cjs +++ b/scripts/test-servers/synthetic-player/integration.cjs @@ -3,22 +3,23 @@ const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') const mineflayer = require('mineflayer') +const { assertAgentInstance } = require('./instance-boundary.cjs') -const instancePath = path.resolve(process.argv[2] || '') +let instancePath = path.resolve(process.argv[2] || '') const scenario = process.argv[3] if (!['Vault', 'Placeholder'].includes(scenario)) { - throw new Error('Usage: node integration.cjs ') + throw new Error('Usage: node integration.cjs ') } const metadata = JSON.parse(fs.readFileSync(path.join(instancePath, 'workspace.json'), 'utf8')) -const expectedProfile = scenario === 'Vault' ? 'paper-1.21.8' : 'paper-1.20.6' +instancePath = assertAgentInstance(instancePath, metadata) +const expectedProfiles = scenario === 'Vault' ? ['paper-1.21.8'] : ['paper-1.20.6', 'folia-latest'] const dataDirectory = path.join(instancePath, 'plugins', 'InviteCode') const properties = fs.readFileSync(path.join(instancePath, 'server.properties'), 'utf8') const pluginDirectory = path.join(instancePath, 'plugins') const requiredJars = scenario === 'Vault' ? ['Vault.jar', 'EssentialsX.jar', 'InviteCodeVaultProbe.jar'] : ['PlaceholderAPI.jar', 'InviteCodePapiProbe.jar'] -if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || - !metadata.instance.startsWith('issue12-') || metadata.profile !== expectedProfile || +if (!expectedProfiles.includes(metadata.profile) || !metadata.eulaAccepted || !/^server-ip=127\.0\.0\.1\s*$/m.test(properties) || !/^online-mode=false\s*$/m.test(properties) || !properties.includes(`server-port=${metadata.port}`) || @@ -157,7 +158,10 @@ async function main() { if (scenario === 'Vault') { await balance(server, inviteeName, 0) } - await playerCommand(invitee, `/ic claim ${code}`, new RegExp(`Inviter: ${inviterName}; Invite Code:`)) + await playerCommand(invitee, `/ic claim ${code}`, new RegExp(`Inviter: ${inviterName}`)) + await until(() => invitee.messages.some(message => message.includes(`Invite Code: ${code}`)) && + invitee.messages.some(message => message.includes('[Agree]') && message.includes('[Disagree]')), + 'multiline claim confirmation') await playerCommand(invitee, '/ic confirm', /The Invitation has been created\./) if (scenario === 'Vault') { await balance(server, inviteeName, 37.5) diff --git a/scripts/test-servers/synthetic-player/migration-recovery.cjs b/scripts/test-servers/synthetic-player/migration-recovery.cjs index 21c3b05..f27bfcc 100644 --- a/scripts/test-servers/synthetic-player/migration-recovery.cjs +++ b/scripts/test-servers/synthetic-player/migration-recovery.cjs @@ -3,16 +3,15 @@ const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') -const instancePath = path.resolve(process.argv[2] || '') -const metadata = JSON.parse(fs.readFileSync(path.join(instancePath, 'workspace.json'), 'utf8')) +const { assertAgentInstance } = require('./instance-boundary.cjs') +const requestedPath = path.resolve(process.argv[2] || '') +const metadata = JSON.parse(fs.readFileSync(path.join(requestedPath, 'workspace.json'), 'utf8')) +const instancePath = assertAgentInstance(requestedPath, metadata) const properties = fs.readFileSync(path.join(instancePath, 'server.properties'), 'utf8') const dataPath = path.join(instancePath, 'plugins', 'InviteCode') const dbPath = path.join(dataPath, 'invitecode.db') const keyPath = path.join(dataPath, 'anti-abuse.key') if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || - path.basename(path.dirname(instancePath)) !== 'InviteCode' || - path.basename(path.dirname(path.dirname(instancePath))) !== 'instances' || - path.basename(path.dirname(path.dirname(path.dirname(instancePath)))) !== 'TestLab' || !metadata.instance.startsWith('issue12-') || metadata.profile !== 'spigot-1.8.8' || metadata.port !== 51888 || !metadata.eulaAccepted || !/^server-ip=127\.0\.0\.1\s*$/m.test(properties) || @@ -33,9 +32,10 @@ mode, filename = sys.argv[1:] con = sqlite3.connect(filename) try: if mode == 'downgrade': - assert con.execute('SELECT version FROM invitecode_schema_version').fetchone()[0] == 8 + assert con.execute('SELECT version FROM invitecode_schema_version').fetchone()[0] == 9 with con: con.execute('DROP TABLE invitecode_player_network_hashes') + con.execute('DROP TABLE invitecode_reserved_code_hashes') con.execute('UPDATE invitecode_schema_version SET version=7') con.execute('INSERT INTO invitecode_players(player_id, first_seen_at, last_known_name) VALUES (?, ?, ?)', ('00000000-0000-0000-0000-000000000012', '2026-09-24T00:00:00Z', 'MigrationSentinel')) @@ -45,14 +45,17 @@ try: with con: con.execute('DROP INDEX invitecode_network_hash_expiry') elif mode in ('assert-old', 'assert-current'): - expected = 8 if mode == 'assert-current' else 7 + expected = 9 if mode == 'assert-current' else 7 assert con.execute('SELECT version FROM invitecode_schema_version').fetchone()[0] == expected assert con.execute("SELECT last_known_name FROM invitecode_players WHERE player_id='00000000-0000-0000-0000-000000000012'").fetchone() == ('MigrationSentinel',) table = con.execute("SELECT 1 FROM sqlite_master WHERE type='table' AND name='invitecode_player_network_hashes'").fetchone() + reserved = con.execute("SELECT 1 FROM sqlite_master WHERE type='table' AND name='invitecode_reserved_code_hashes'").fetchone() index = con.execute("SELECT tbl_name FROM sqlite_master WHERE type='index' AND name='invitecode_network_hash_expiry'").fetchone() if expected == 7: + assert reserved is None assert table is None and index == ('invitecode_players',), (table, index) else: + assert reserved == (1,) assert table == (1,) and index == ('invitecode_player_network_hashes',), (table, index) assert con.execute('PRAGMA integrity_check').fetchone() == ('ok',) else: @@ -148,7 +151,7 @@ async function main() { sqlite('repair') server = start() await ready(server, 'MAINTENANCE') - await command(server, 'ic admin storage migrate SQLITE repaired-index-conflict', /Storage schema migration 已完成,目前版本為 8/) + await command(server, 'ic admin storage migrate SQLITE repaired-index-conflict', /Storage schema migration 已完成,目前版本為 9/) await command(server, 'ic admin doctor', /Runtime=ACTIVE/) await stop(server) sqlite('assert-current') diff --git a/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs b/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs index 303a500..f8207be 100644 --- a/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs +++ b/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs @@ -2,20 +2,19 @@ const fs = require('node:fs') const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') +const { assertAgentInstance } = require('./instance-boundary.cjs') -const instancePath = path.resolve(process.argv[2] || '') +let instancePath = path.resolve(process.argv[2] || '') const metadata = JSON.parse(fs.readFileSync(path.join(instancePath, 'workspace.json'), 'utf8')) +instancePath = assertAgentInstance(instancePath, metadata) const properties = fs.readFileSync(path.join(instancePath, 'server.properties'), 'utf8') const dataPath = path.join(instancePath, 'plugins', 'InviteCode') const jarPath = path.join(instancePath, 'plugins', metadata.pluginFile) const database = `invitecode_issue12_test_${metadata.instance.replace(/^issue12-/, '').replace(/-/g, '_')}` -const mysqlExe = path.join(path.dirname(path.dirname(path.dirname(instancePath))), +const instanceHarborRoot = path.resolve(instancePath, '..', '..', '..', '..') +const mysqlExe = path.join(instanceHarborRoot, 'artifacts', 'invitecode-issue12-mysql-8.4.11', 'mysql-8.4.11-winx64', 'bin', 'mysql.exe') -if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || - path.basename(path.dirname(instancePath)) !== 'InviteCode' || - path.basename(path.dirname(path.dirname(instancePath))) !== 'instances' || - path.basename(path.dirname(path.dirname(path.dirname(instancePath)))) !== 'TestLab' || - !/^issue12-[a-z0-9-]+$/.test(metadata.instance) || metadata.profile !== 'paper-1.20.6' || +if (metadata.schemaVersion !== 2 || metadata.profile !== 'paper-1.20.6' || metadata.port !== 62060 || !metadata.eulaAccepted || !/^server-ip=127\.0\.0\.1\s*$/m.test(properties) || !/^online-mode=false\s*$/m.test(properties) || @@ -25,7 +24,7 @@ if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(ins fs.existsSync(path.join(dataPath, 'invitecode.db')) || fs.existsSync(path.join(dataPath, 'anti-abuse.key')) || !fs.existsSync(mysqlExe)) { - throw new Error('Expected a fresh, EULA-accepted, loopback-only MySQL TestLab instance') + throw new Error('Expected a fresh, EULA-accepted, loopback-only MySQL Agent instance') } for (const name of ['INVITECODE_TEST_MYSQL_ROOT_PASSWORD', 'INVITECODE_DB_PASSWORD', 'INVITECODE_NETWORK_SECRET']) { if (!process.env[name]) throw new Error(`Missing test-only environment variable ${name}`) @@ -40,6 +39,11 @@ if (resource.status !== 0 || !resource.stdout.startsWith('-- @table invitecode_p throw new Error('Cannot read the bundled MySQL schema resource') } const checksum = hash(Buffer.from(resource.stdout, 'utf8')) +const v2Resource = spawnSync('tar', ['-xOf', jarPath, 'mysql/V2__reserved_code_hashes.sql'], { encoding: 'utf8' }) +if (v2Resource.status !== 0 || !v2Resource.stdout.startsWith('-- @table invitecode_reserved_code_hashes')) { + throw new Error('Cannot read the bundled MySQL V2 schema resource') +} +const v2Checksum = hash(Buffer.from(v2Resource.stdout, 'utf8')) const firstTable = resource.stdout.match(/^-- @table invitecode_players\s*\r?\n([\s\S]*?)(?=^-- @table invitecode_metadata)/m) if (!firstTable) throw new Error('Bundled MySQL schema has no players table') const playersDdl = firstTable[1].trim().replace(/;$/, '') @@ -57,12 +61,15 @@ function sql(statement) { if (result.error || result.status !== 0) { throw new Error(`Isolated MySQL fixture query failed: ${result.error?.message || result.stderr}`) } - return result.stdout.trim() + return result.stdout.trim().replace(/\r\n/g, '\n') } function db(statement) { return sql(`USE ${database}; ${statement}`) } function state(expectedState, expectedTables) { - const summary = db("SELECT CONCAT(version, ':', state, ':', checksum) FROM invitecode_schema_migrations") - if (summary !== `1:${expectedState}:${checksum}`) throw new Error(`Unexpected migration ledger: ${summary}`) + const summary = db("SELECT CONCAT(version, ':', state, ':', checksum) FROM invitecode_schema_migrations ORDER BY version") + const expectedLedger = expectedState === 'APPLYING' + ? `1:APPLYING:${checksum}` + : `1:APPLIED:${checksum}\n2:APPLIED:${v2Checksum}` + if (summary !== expectedLedger) throw new Error(`Unexpected migration ledger: ${summary}`) const tables = Number(sql(`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='${database}'`)) if (tables !== expectedTables) throw new Error(`Expected ${expectedTables} tables, got ${tables}`) const player = db(`SELECT last_known_name FROM invitecode_players WHERE player_id='${sentinel}'`) @@ -194,13 +201,13 @@ mysql: await ready(server, 'ACTIVE') await command(server, 'ic admin doctor', /Runtime=ACTIVE/) await stop(server) - state('APPLIED', 13) + state('APPLIED', 14) server = start() await ready(server, 'ACTIVE') await command(server, 'ic admin doctor', /Runtime=ACTIVE/) await stop(server) - state('APPLIED', 13) + state('APPLIED', 14) if (fs.existsSync(path.join(dataPath, 'anti-abuse.key')) || fs.existsSync(path.join(dataPath, 'invitecode.db'))) { throw new Error('MySQL mode unexpectedly created local SQLite files') } diff --git a/scripts/test-servers/synthetic-player/uncertain.cjs b/scripts/test-servers/synthetic-player/uncertain.cjs index d7a18c8..b537721 100644 --- a/scripts/test-servers/synthetic-player/uncertain.cjs +++ b/scripts/test-servers/synthetic-player/uncertain.cjs @@ -3,19 +3,20 @@ const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') const mineflayer = require('mineflayer') +const { assertAgentInstance } = require('./instance-boundary.cjs') -const instancePath = path.resolve(process.argv[2] || '') +let instancePath = path.resolve(process.argv[2] || '') const resolution = process.argv[3] if (!['mark-delivered', 'retry'].includes(resolution)) { - throw new Error('Usage: node uncertain.cjs ') + throw new Error('Usage: node uncertain.cjs ') } const metadata = JSON.parse(fs.readFileSync(path.join(instancePath, 'workspace.json'), 'utf8')) +instancePath = assertAgentInstance(instancePath, metadata) const dataDirectory = path.join(instancePath, 'plugins', 'InviteCode') const marker = path.join(instancePath, 'plugins', 'InviteCodeFaultProbe', 'effect-entered.log') const properties = fs.readFileSync(path.join(instancePath, 'server.properties'), 'utf8') const rewardConfig = fs.readFileSync(path.join(dataDirectory, 'rewards.yml'), 'utf8') -if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || - !metadata.instance.startsWith('issue12-') || metadata.profile !== 'spigot-1.8.8' || +if (metadata.profile !== 'spigot-1.8.8' || !metadata.eulaAccepted || !/^server-ip=127\.0\.0\.1\s*$/m.test(properties) || !/^online-mode=false\s*$/m.test(properties) || !properties.includes(`server-port=${metadata.port}`) || @@ -147,7 +148,10 @@ async function main() { inviter = null await delay(500) invitee = await bot('IcFaultB') - await playerCommand(invitee, `/ic claim ${code}`, /Inviter: IcFaultA; Invite Code:/) + await playerCommand(invitee, `/ic claim ${code}`, /Inviter: IcFaultA/) + await until(() => invitee.messages.some(message => message.includes(`Invite Code: ${code}`)) && + invitee.messages.some(message => message.includes('[Agree]') && message.includes('[Disagree]')), + 'multiline claim confirmation') expectedCrash = true invitee.client.chat('/ic confirm') await until(() => server.child.exitCode !== null, 'deliberate JVM halt', 30000) diff --git a/scripts/test-servers/test-common.ps1 b/scripts/test-servers/test-common.ps1 new file mode 100644 index 0000000..294f3b9 --- /dev/null +++ b/scripts/test-servers/test-common.ps1 @@ -0,0 +1,51 @@ +. (Join-Path $PSScriptRoot 'common.ps1') +$root = Join-Path ([IO.Path]::GetTempPath()) ('invitecode-boundary-' + [guid]::NewGuid().ToString('N')) +try { + $instance = Join-Path $root 'Agent/InviteCode/issue12-boundary' + New-Item -ItemType Directory -Path $instance -Force | Out-Null + $metadata = [pscustomobject]@{ schemaVersion = 2; audience = 'Agent'; project = 'InviteCode'; instance = 'issue12-boundary'; profile = 'spigot-1.8.8'; eulaAccepted = $true; pluginFile = 'InviteCode.jar' } + Assert-InviteCodeAgentInstance -Path $instance -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' + foreach ($audience in @('Human', 'Legacy')) { + $metadata.audience = $audience + $rejected = $false + try { Assert-InviteCodeAgentInstance -Path $instance -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' } + catch { $rejected = $true } + if (-not $rejected) { throw "未拒絕 $audience metadata。" } + } + $metadata.audience = 'Agent' + $metadata.pluginFile = '../outside.jar' + $rejected = $false + try { Assert-InviteCodeAgentInstance -Path $instance -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' } + catch { $rejected = $true } + if (-not $rejected) { throw '未拒絕 pluginFile 路徑跳脫。' } + $metadata.pluginFile = 'InviteCode.jar' + $human = Join-Path $root 'Human/InviteCode/issue12-boundary' + New-Item -ItemType Directory -Path $human -Force | Out-Null + $rejected = $false + try { Assert-InviteCodeAgentInstance -Path $human -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' } + catch { $rejected = $true } + if (-not $rejected) { throw '未拒絕 Human 路徑。' } + $metadata.schemaVersion = 1 + $rejected = $false + try { Assert-InviteCodeAgentInstance -Path $instance -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' } + catch { $rejected = $true } + if (-not $rejected) { throw '未拒絕舊 metadata schema。' } + $metadata.schemaVersion = 2 + $linked = Join-Path $root 'Agent/InviteCode/issue12-linked' + New-Item -ItemType Junction -Path $linked -Target $human -ErrorAction Stop | Out-Null + $metadata.instance = 'issue12-linked' + $rejected = $false + try { Assert-InviteCodeAgentInstance -Path $linked -InstancesRoot $root -Metadata $metadata -Profile 'spigot-1.8.8' } + catch { $rejected = $true } + if (-not $rejected) { throw '未拒絕指向 Human 的 junction。' } + $rejected = $false + try { Resolve-PluginInstanceHarborRoot -ExplicitRoot $root | Out-Null } + catch { $rejected = $true } + if (-not $rejected) { throw '指定錯誤 repository 時不應靜默改用另一份。' } + Write-Output 'PASS: Agent path and metadata boundaries' +} +finally { + if ($root.StartsWith([IO.Path]::GetTempPath(), [StringComparison]::OrdinalIgnoreCase)) { + Remove-Item -LiteralPath $root -Recurse -Force + } +}