From 1405745c6fc049c7df2217304e8df801c728fb68 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Fri, 2 Oct 2026 23:30:59 +0800 Subject: [PATCH] test: verify current artifact and harden startup cleanup --- README.md | 2 +- docs/README.zh-TW.md | 2 + .../current-artifact-human-acceptance.md | 46 ++ ...02-issue-12-current-artifact-manifest.json | 419 ++++++++++++++++++ ...-10-02-issue-12-current-artifact-retest.md | 50 +++ docs/testing/final-human-acceptance.md | 6 +- docs/testing/test-servers.md | 4 + .../test-servers/synthetic-player/flow.cjs | 57 ++- .../synthetic-player/startup-cleanup.test.cjs | 93 ++++ 9 files changed, 665 insertions(+), 14 deletions(-) create mode 100644 docs/testing/current-artifact-human-acceptance.md create mode 100644 docs/testing/evidence/2026-10-02-issue-12-current-artifact-manifest.json create mode 100644 docs/testing/evidence/2026-10-02-issue-12-current-artifact-retest.md create mode 100644 scripts/test-servers/synthetic-player/startup-cleanup.test.cjs diff --git a/README.md b/README.md index 04e41ef..d241458 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. 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 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 [current artifact retest](docs/testing/evidence/2026-10-02-issue-12-current-artifact-retest.md). Folia remains experimental; automated checks and [player acceptance](docs/testing/current-artifact-human-acceptance.md) 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), [MySQL setup](docs/operations/mysql-storage.md), [offline anonymization](docs/operations/offline-anonymization.md), and [cross-backend transfer](docs/operations/cross-backend-transfer.md). These documents are maintained in Traditional Chinese. diff --git a/docs/README.zh-TW.md b/docs/README.zh-TW.md index 75cac67..de6632f 100644 --- a/docs/README.zh-TW.md +++ b/docs/README.zh-TW.md @@ -102,4 +102,6 @@ Qualification Reward 與 Inviter Milestone Reward 會先以穩定冪等鍵保存 ## 目前狀態 +最新 develop 產物、跨核心/backend 證據及固定 Human 部署狀態見[本輪驗證紀錄](./testing/evidence/2026-10-02-issue-12-current-artifact-retest.md)。真人驗收使用保留資料的三台固定測服,依[短版步驟](./testing/current-artifact-human-acceptance.md)補齊最終產物證據;歷史已通過項目保留,正式發行與遠端交付另依授權。 + 實作工作記錄於本 repository 的 GitHub Issues。不規劃相容或匯入舊版 InviteCode 的資料與設定。 diff --git a/docs/testing/current-artifact-human-acceptance.md b/docs/testing/current-artifact-human-acceptance.md new file mode 100644 index 0000000..444f90e --- /dev/null +++ b/docs/testing/current-artifact-human-acceptance.md @@ -0,0 +1,46 @@ +# 最新產物短版真人驗收 + +本輪只補最終產物證據。先前三台確認畫面、同意/不同意、逾時與重啟通過的紀錄保留,不要求重新執行整套長流程。自動結果與部署狀態見[最新產物驗證紀錄](./evidence/2026-10-02-issue-12-current-artifact-retest.md)。三台部署與 migration、重啟及資料保留比對已完成,可執行下列步驟。 + +## 待驗收版本 + +- 產品來源:`418c8298e8deb6c7fdef66d6e0ff67f78d807a89`,已合入 develop `fb215c09ee4bbce96050ef4aebf97a1905ed984a`。 +- 插件 SHA-256:`D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C`。 +- 固定測服:`invitecode-spigot-1.8.8`、`invitecode-paper-26.2`、`invitecode-folia-26.1.2`,位於 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\`。 +- 使用既有世界、帳號與邀請資料;不清空資料、不重設資格。三台保持同 IP `DENY`,本清單不需要新的成功 Claim。 + +## 每台依序操作 + +1. 從 Windows 開始功能表開啟已安裝的 **PowerShell 7**,在桌面視窗執行: + + ```powershell + & 'C:\Program Files\PowerShell\7\pwsh.exe' -NoProfile -File 'D:\Code\Java\Plugin\InstanceHarbor\repo\scripts\manage-human-servers.ps1' + ``` + + 依名稱選擇一台 InviteCode 測服啟動;不要依照舊截圖的編號。共用 `lobby` 與 Velocity 也必須運行。用 `V` 加該台編號查看當次 `Done`、InviteCode 已啟用,再確認正確 port 監聽。只看到啟動請求不算完成。 + +2. 用 Minecraft 連到 `localhost:25565`,再輸入該台路由: + + ```text + /server invitecode-spigot-1.8.8 + /server invitecode-paper-26.2 + /server invitecode-folia-26.1.2 + ``` + + 每次只執行目前那台的指令。預期切服成功,`/ic help` 正常,繁體中文沒有亂碼。Spigot 的舊版行為用 1.8.8 客戶端確認;Paper 用 26.2 客戶端;Folia 用代理已支援的客戶端版本。客戶端語言設為繁體中文。 + +3. **曾建立邀請碼的帳號**輸入 `/ic code`。將滑鼠放在六碼本身,預期出現複製提示。Paper/Folia 點擊後貼到本機文字編輯器,應只有六碼,沒有色碼或額外文字;Spigot 1.8.8 點擊後應把六碼填入聊天列,可手動選取複製,勿按 Enter 公開送出。顏色、懸浮文字與繁體中文應正常。 + +4. **已使用邀請碼的帳號**輸入 `/ic claim`。預期立即告知已使用/不符合資格,不開啟輸入 Dialog 或聊天輸入流程。曾建立邀請碼的帳號也可檢查,預期立即回覆 Inviter 不能 Claim。這些拒絕是正確結果,不需要關閉同 IP 檢查。 + +5. 輸入 `/ic status`、`/ic stats`,記錄邀請狀態與數量。切回 `/server lobby`,在 TUI 用 `S` 加該台編號正常停止,等待「已停止」後重新啟動;再切回該台、輸入上述兩個指令。預期原邀請碼與邀請關係保留,沒有 InviteCode exception。數量若因正常資格達成而變動,保留 log 並回報原因,不用自行重設資料。 + +6. 完成後切回 lobby,正常停止該台,再對下一台重複步驟 1–5。測試結束後三台 InviteCode 都關閉;共用入口若其他測試還需要使用,不必為本插件關閉。 + +## 回覆及限制 + +請分別回覆三台的「切服/指令、六碼提示與複製、資格預檢、繁體中文、重啟保留」是否通過;失敗時附實際畫面或文字及 `logs/latest.log`,保留原資料,不重建伺服器。不要提供帳號密碼或 anti-abuse key。 + +此短版不會重新建立 Invitation。原生 Dialog 的實際提交與同意/不同意沿用已確認的歷史結果;合成封包只算自動證據。若日後要以全新合資格帳號複驗完整流程,再另外界定測試帳號與可回復資料;不要為了開啟 Dialog 直接 unlink 或清空現有資料。 + +真人結果通過後,仍須完成 Issue #12 的門檻結論與文件交付;這不代表允許 push、PR、merge、tag 或正式發行。Folia 保持實驗性,第三方 provider 的支援範圍另列限制。 diff --git a/docs/testing/evidence/2026-10-02-issue-12-current-artifact-manifest.json b/docs/testing/evidence/2026-10-02-issue-12-current-artifact-manifest.json new file mode 100644 index 0000000..e0a79b0 --- /dev/null +++ b/docs/testing/evidence/2026-10-02-issue-12-current-artifact-manifest.json @@ -0,0 +1,419 @@ +{ + "schemaVersion": 1, + "sourceDevelop": "fb215c09ee4bbce96050ef4aebf97a1905ed984a", + "productSource": "418c8298e8deb6c7fdef66d6e0ff67f78d807a89", + "artifact": { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\artifacts\\merged-issue26-418c829\\worktree\\invitecode-plugin\\build\\issue26-evidence\\InviteCode-418c829.jar", + "sha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C" + }, + "startupMatrix": [ + { + "profile": "spigot-1.8.8", + "port": 63801, + "javaAlias": "local-8", + "serverSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-spigot-1.8.8.log" + }, + { + "profile": "spigot-1.12.2", + "port": 63802, + "javaAlias": "local-8", + "serverSha256": "CA59A730F5B1C2E85A2ABE907D9689CC2636BE0200F333C1E1B87E2D620D8513", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-spigot-1.12.2.log" + }, + { + "profile": "spigot-1.16.5", + "port": 63803, + "javaAlias": "local-8", + "serverSha256": "C738DCB9AC8114228107BB4CDA97BFEC62A243C99FE0E7C6CAF9D424BD1EF93C", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-spigot-1.16.5.log" + }, + { + "profile": "spigot-latest", + "port": 63804, + "javaAlias": "local-25", + "serverSha256": "27A348344D42ED2BA76AAD6FCEEBB7A26365F09C9AC6EEA4C0918BA83BA7E3DD", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-spigot-latest.log" + }, + { + "profile": "paper-1.20.6", + "port": 63805, + "javaAlias": "local-21", + "serverSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-paper-1.20.6.log" + }, + { + "profile": "paper-1.21.8", + "port": 63806, + "javaAlias": "local-21", + "serverSha256": "8DE7C52C3B02403503D16FAC58003F1EFEF7DD7A0256786843927FA92EE57F1E", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-paper-1.21.8.log" + }, + { + "profile": "paper-latest", + "port": 63807, + "javaAlias": "local-25", + "serverSha256": "B1D8F6BFA1B6101FA8E947B53041CB3BDF5540E7B83B6547CA19BA7EDEFEB083", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-paper-latest.log" + }, + { + "profile": "folia-latest", + "port": 63808, + "javaAlias": "local-25", + "serverSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "result": "PASS", + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\smoke-folia-latest.log" + } + ], + "playerAndProviderFlows": [ + { + "id": "spigot188", + "result": "PASS", + "checks": [ + "private-chat-input", + "chat-cancel", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ] + }, + { + "id": "paper262", + "result": "PASS", + "checks": [ + "input-and-confirmation-dialog-packets", + "command-cancel-preserves-state", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ] + }, + { + "id": "folia2612", + "result": "PASS", + "checks": [ + "input-and-confirmation-dialog-packets", + "command-cancel-preserves-state", + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ] + }, + { + "id": "vault1218", + "result": "PASS", + "checks": [ + "balance-before-0", + "qualification", + "vault-deposit-37.5", + "balance-after-restart-37.5" + ] + } + ], + "additionalBackendAndProviderGates": [ + { + "name": "papi-placeholder-paper1206", + "result": "PASS", + "checks": [ + "placeholder-unsatisfied", + "placeholder-ready", + "qualified-after-rejoin", + "qualified-after-restart" + ], + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-verification-20261002\\papi-flow.log" + }, + { + "name": "json-playerflow-paper1206", + "result": "PASS", + "checks": [ + "code", + "claim", + "confirm", + "qualification", + "pending-after-restart", + "offline-reward-on-login", + "stats" + ], + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-verification-20261002\\json-flow-final.log" + }, + { + "name": "mysql-interrupted-migration-recovery", + "result": "PASS", + "checks": [ + "malformed-table-fails-closed", + "checksum-mismatch-fails-closed", + "applying-ledger-resumes", + "sentinel-preserved", + "applied-ledger-durable", + "no-local-secret" + ], + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-verification-20261002\\mysql-migration-recovery-shortname.log" + }, + { + "name": "actual-plugin-mysql-guard-lock", + "result": "PASS", + "checks": [ + "empty-db-initializes-active", + "transfer-lock-contention-maintenance", + "release-lock-recovers-active", + "guard-fails-closed", + "drop-owned-fixture-guard-recovers-active", + "sentinel-preserved" + ], + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-verification-20261002\\actual-mysql-guard-lock-final.log" + } + ], + "recovery": [ + { + "scenario": "sqlite", + "result": { + "result": "PASS", + "scenario": "sqlite-migration-recovery", + "instance": "issue12-current-recovery-sqlite", + "profile": "spigot-1.8.8", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "checks": [ + "no-auto-upgrade", + "maintenance", + "ddl-rollback", + "sentinel-preserved", + "explicit-recovery", + "restart-durable", + "secret-preserved" + ] + }, + "port": 63811, + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\recovery\\sqlite.log" + }, + { + "scenario": "mark-delivered", + "result": { + "result": "PASS", + "scenario": "reward-interruption", + "resolution": "mark-delivered", + "instance": "issue12-current-recovery-mark-delivered", + "profile": "spigot-1.8.8", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "markerCount": 1, + "checks": [ + "effect-entered", + "abrupt-halt", + "restart-recovery", + "no-automatic-retry", + "admin-resolution", + "resolution-after-restart" + ] + }, + "port": 63812, + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\recovery\\mark-delivered.log" + }, + { + "scenario": "retry", + "result": { + "result": "PASS", + "scenario": "reward-interruption", + "resolution": "retry", + "instance": "issue12-current-recovery-retry", + "profile": "spigot-1.8.8", + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "markerCount": 2, + "checks": [ + "effect-entered", + "abrupt-halt", + "restart-recovery", + "no-automatic-retry", + "admin-resolution", + "resolution-after-restart" + ] + }, + "port": 63813, + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\recovery\\retry.log" + } + ], + "runnerRegression": { + "tests": 7, + "passed": 7, + "failed": 0, + "skipped": 0, + "log": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\runner-tests-reviewed.log", + "postPatchRealFlowLog": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\recovery\\runner-recheck.log" + }, + "humanDeployment": [ + { + "result": "PASS", + "name": "invitecode-spigot-1.8.8", + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8", + "port": 10101, + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "schemaBefore": 8, + "schemaAfter": 9, + "keyUnchanged": true, + "worldUnchangedBeforeBoot": true, + "backupPath": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\artifacts\\human-issue12-fb215c0\\invitecode-spigot-1.8.8", + "stopped": true + }, + { + "result": "PASS", + "name": "invitecode-paper-26.2", + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.2", + "port": 20101, + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "schemaBefore": 8, + "schemaAfter": 9, + "keyUnchanged": true, + "worldUnchangedBeforeBoot": true, + "backupPath": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\artifacts\\human-issue12-fb215c0\\invitecode-paper-26.2", + "stopped": true + }, + { + "result": "PASS", + "name": "invitecode-folia-26.1.2", + "instancePath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "port": 30101, + "pluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "schemaBefore": 8, + "schemaAfter": 9, + "keyUnchanged": true, + "worldUnchangedBeforeBoot": true, + "backupPath": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\artifacts\\human-issue12-fb215c0\\invitecode-folia-26.1.2", + "stopped": true + } + ], + "dataPreservation": [ + { + "result": "PASS", + "name": "invitecode-spigot-1.8.8", + "schemaBefore": 8, + "schemaAfter": 9, + "allExistingBusinessRowsPreserved": true, + "preservedTables": [ + "invitecode_players", + "invitecode_codes", + "invitecode_invitations", + "invitecode_qualification_facts", + "invitecode_reward_deliveries", + "invitecode_reward_actions", + "invitecode_reward_delivery_transitions", + "invitecode_reward_action_transitions", + "invitecode_player_login_days", + "invitecode_player_network_hashes" + ], + "previousAuditRowsPreserved": true, + "newMigrationAuditCount": 1, + "reservedCodeHashesEmpty": true, + "integrityCheck": "ok", + "foreignKeyCheck": "ok", + "unchangedWorldUids": [ + "world\\uid.dat" + ], + "worldPlayerFilesPreservedCount": 0 + }, + { + "result": "PASS", + "name": "invitecode-paper-26.2", + "schemaBefore": 8, + "schemaAfter": 9, + "allExistingBusinessRowsPreserved": true, + "preservedTables": [ + "invitecode_players", + "invitecode_codes", + "invitecode_invitations", + "invitecode_qualification_facts", + "invitecode_reward_deliveries", + "invitecode_reward_actions", + "invitecode_reward_delivery_transitions", + "invitecode_reward_action_transitions", + "invitecode_player_login_days", + "invitecode_player_network_hashes" + ], + "previousAuditRowsPreserved": true, + "newMigrationAuditCount": 1, + "reservedCodeHashesEmpty": true, + "integrityCheck": "ok", + "foreignKeyCheck": "ok", + "unchangedWorldUids": [], + "worldPlayerFilesPreservedCount": 8 + }, + { + "result": "PASS", + "name": "invitecode-folia-26.1.2", + "schemaBefore": 8, + "schemaAfter": 9, + "allExistingBusinessRowsPreserved": true, + "preservedTables": [ + "invitecode_players", + "invitecode_codes", + "invitecode_invitations", + "invitecode_qualification_facts", + "invitecode_reward_deliveries", + "invitecode_reward_actions", + "invitecode_reward_delivery_transitions", + "invitecode_reward_action_transitions", + "invitecode_player_login_days", + "invitecode_player_network_hashes" + ], + "previousAuditRowsPreserved": true, + "newMigrationAuditCount": 1, + "reservedCodeHashesEmpty": true, + "integrityCheck": "ok", + "foreignKeyCheck": "ok", + "unchangedWorldUids": [], + "worldPlayerFilesPreservedCount": 8 + } + ], + "rawManifests": [ + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-startup-matrix-20261002\\matrix.json", + "sha256": "6979BB046DB9DE8AB655A85CCEE49A29730732F0428F7C8652FE01A6C3CF786B" + }, + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-20261002-run1\\results.json", + "sha256": "A4848B4BAAF5C7BB167470DCD52AC5B2925246EB67DDFF6F80923EDAACAEE715" + }, + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\issue12-current-artifact-verification-20261002\\evidence-summary.json", + "sha256": "EEB130DB1D895D3FD4824F525C314C589BD214A0FED57746276907090C1C5D9A" + }, + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\recovery\\results.json", + "sha256": "5252EE904494D22AD7ADDAC164CF95D26648B799B26FD2991282ACDD56BB0115" + }, + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\human\\deployment.json", + "sha256": "468DE7A620BD09B6120D40D72C6BA9C16969C4DDC48CE4815570A3C59578F050" + }, + { + "path": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\test-issue-12-current-artifact\\invitecode-plugin\\build\\current-artifact\\human\\data-preservation.json", + "sha256": "B0FE6096503A3D456B9AA6872B5BBE3843FFD1ECEEF24AB66A94D05C10893605" + } + ], + "humanClientAcceptance": "PENDING", + "remoteWritesPerformed": false +} diff --git a/docs/testing/evidence/2026-10-02-issue-12-current-artifact-retest.md b/docs/testing/evidence/2026-10-02-issue-12-current-artifact-retest.md new file mode 100644 index 0000000..3e7eaed --- /dev/null +++ b/docs/testing/evidence/2026-10-02-issue-12-current-artifact-retest.md @@ -0,0 +1,50 @@ +# Issue #12:最新 develop 產物驗證 + +## 受測版本與資料邊界 + +本輪從 `develop` 的 `fb215c09ee4bbce96050ef4aebf97a1905ed984a` 建立 `codex/test/issue-12-current-artifact`。PR #29 的產品來源 `418c8298e8deb6c7fdef66d6e0ff67f78d807a89` 與此 develop 的 tree 相同;本輪沿用已完成建置檢查的固定 JAR,不重新建置另一個產物。 + +```text +D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C +``` + +JAR:`D:\Code\Java\Plugin\InviteCodeKt\artifacts\merged-issue26-418c829\worktree\invitecode-plugin\build\issue26-evidence\InviteCode-418c829.jar`。原始 runtime log、runner 輸出與 manifest 保留在本 Worktree 的 `invitecode-plugin/build/current-artifact/`。 + +自動測試僅操作本輪新建的 `InstanceHarbor/instances/Agent/InviteCode/` 隔離實例,不接入人工 Velocity,不把 Human 世界或玩家資料當成 fixture。沿用 InstanceHarbor 的持續 EULA 授權、已編譯 BuildTools 核心與既有測試依賴。JDK 由 mise 的已安裝 local alias 選擇,未安裝新 Java 或新增 production dependency。 + +## 已有與本輪證據 + +最新候選已完成 Java 8 `check shadowJar`,55 suites/244 tests,零失敗、錯誤與跳過;搬移失敗及 guard 復原見[Issue #26 紀錄](./2026-10-02-issue-26-transfer-retest.md)。本輪不無故重做這些檢查,補齊此同一 JAR 的伺服器驗證。 + +本輪 SQLite 隔離 fixture 已通過:拒絕偷偷升級、維護模式、v7→v8 索引衝突造成 DDL 交易回滾、哨兵資料保留、正式遷移至 v9、重啟及原 anti-abuse key 保留。runner 的暫存副本只將隔離 port 斷言由 51888 改為 63811,其餘斷言與正式 runner 相同;沒有修改產品或正式 runner。 + +兩個獨立 Spigot 1.8.8 fixture 已通過外部效果後 JVM halt 83、重啟標記 UNCERTAIN、玩家登入不自動重播,以及管理員 `mark-delivered`/`retry` 後重啟持久化。外部效果分別維持一次/明確重試成為兩次。故障後測試客戶端 ECONNRESET 是預期現象;不推論未測的作業系統斷電或資料庫服務中斷。 + +同一 D6AF JAR 的本輪結果全部通過,逐項核心雜湊、JDK、port、斷言與原始 log 索引見[證據 manifest](./2026-10-02-issue-12-current-artifact-manifest.json): + +| 門檻 | 本輪結果 | +| --- | --- | +| 核心啟動矩陣 | Spigot 1.8.8/1.12.2/1.16.5/26.2、Paper 1.20.6/1.21.8/26.2、Folia 26.1.2,8 組 enable、doctor ACTIVE、help、reload 與正常停止全部通過 | +| 玩家完整流程 | Spigot CHAT、Paper/Folia Dialog 合成封包,包含 claim、confirm、資格、離線補發與重啟持久化 | +| Vault/PAPI | 真實 Vault + EssentialsX 的 0→37.5 及重啟;PlaceholderAPI 資格未達成→達成→重啟保留 | +| JSON | 完整邀請、離線獎勵與重啟流程 | +| MySQL 8.4.11 | 空庫初始化、DDL/checksum fail-closed、APPLYING 恢復、共享 lock/guard 拒絕及解除後恢復、哨兵保留 | +| SQLite/獎勵故障 | 交易回滾與正式復原;UNCERTAIN 不自動重播、mark-delivered/retry 持久化 | + +首次 JSON 啟動逾時暴露 runner 未回收自有子程序。本輪以外部假 Java 程序的 CLI 測試先 RED 再 GREEN,修正啟動失敗及輸入 pipe 斷線的 bounded cleanup;7 個 Node 回歸測試全部通過,並以修正後 runner 再跑一次真實 Spigot 完整流程通過。假程序 fixture 已封存到 build 證據目錄,不算 Minecraft 相容性證據。初期路徑、fixture 設定及 Windows MySQL 長路徑失敗保留 log,僅最終有效 fixture 結果計為通過。最終有效流程的 Agent 測服及自有 MySQL 已正常停止,所有本輪測試 port 已釋放,臨時 credential 檔已移除。首次 JSON 洩漏的自有程序曾在核對 PID 後強制回收,該失敗不計為通過。 + +## 固定 Human 測服部署與資料保留 + +既有 Spigot 1.8.8/10101、Paper 26.2/20101、Folia 26.1.2/30101 三台足夠,不建立新 Human 實例。TUI 可辨識三者且部署前皆已停止;Velocity 已有對應唯一的 legacy forwarding 路由。設定相符與 port 監聽不是本輪真人切服證據,仍需使用者操作。 + +部署前實際插件都是 `889DAD100D56D18C425D7299FD759EAA3DD822C863CF55FF486F7D8F372EFE3C`,SQLite schema 8,各有 2 名玩家、1 筆 Invitation、0 筆 Reward Action。備份位於 `D:\Code\Java\Plugin\InviteCodeKt\artifacts\human-issue12-fb215c0\`,包含原 JAR、InviteCode 資料與設定、workspace、server.properties、spigot.yml,逐檔 SHA-256 已核對;世界檔案另記錄雜湊,沒有重建或覆寫。 + +三台現已部署同一 D6AF JAR,以正式 `ic admin storage migrate SQLITE issue12-current-artifact` 完成 schema 8→9,重啟後 doctor ACTIVE,正常停止。逐表比對確認所有既有業務資料與舊稽核列相同,各僅新增一筆 STORAGE_MIGRATED;integrity_check 與 foreign_key_check 通過,anti-abuse key 相同。替換後首次啟動前世界檔案雜湊皆相同;啟停後 Spigot 世界 uid.dat 相同,新版沒有 uid.dat,改核對其既有世界玩家檔案全部相同。正常啟停會改變世界時間等檔案,不宣稱啟停後所有世界 bytes 相同。此為部署所需的資料版本升級,不執行匿名化、不重設資格、不 unlink 邀請。當前同 IP 策略 `DENY` 保持不變;本輪短版真人步驟優先使用既有帳號狀態,不要求新成功 Claim。 + +## 真人與交付狀態 + +使用者先前已確認三台的確認畫面、同意/不同意、逾時與重啟全部通過,見[真人紀錄](../final-human-acceptance.md)。本輪不抹除那些結果,也不因測服不足而暫緩。最終產物部署、遷移、自動矩陣及資料比對已完成。TUI 再次發現三台且皆已停止,共用 lobby/Velocity 仍監聽。接下來依[短版真人步驟](../current-artifact-human-acceptance.md)驗證實際客戶端的六碼 hover/複製、繁體中文、資格預檢與重啟狀態。37 個相關 UI class bytes 與歷史受測 JAR 相同;另一個 RuntimeCommandExecutor 的 javap 方法反組譯相同,保留歷史確認畫面與按鈕驗收,但不冒稱本輪已有真人登入。 + +Folia 保持實驗性;Paper 的第三方結果不代表 Folia 第三方已驗證。未執行的真人畫面及按鈕不可用合成封包取代。 + +本輪未 push、建立 PR、merge、tag 或發布。依 [Issue #12 驗收條件](https://github.com/Command1264/InviteCodeKt/issues/12)與 [Roadmap #1 發行門檻](https://github.com/Command1264/InviteCodeKt/issues/1),下一步是由使用者回覆固定 Human 短版真人驗收;驗收通過後才整理 Issue #12 的發行門檻結論,遠端交付與正式發行仍需明確授權。 diff --git a/docs/testing/final-human-acceptance.md b/docs/testing/final-human-acceptance.md index 5caf892..ca40bd5 100644 --- a/docs/testing/final-human-acceptance.md +++ b/docs/testing/final-human-acceptance.md @@ -1,6 +1,10 @@ # InviteCode 最終真人驗收 -## 同產物自動複驗 +## 最新 develop 產物 + +最新 `fb215c0` 產品來源的同 JAR 證據及固定 Human 部署狀態見[本輪驗證紀錄](./evidence/2026-10-02-issue-12-current-artifact-retest.md)。本輪真人操作依[短版驗收清單](./current-artifact-human-acceptance.md),保留既有世界、玩家與已通過的歷史結果,不因測服不存在而暫緩。下列 BA2D48 與 889DAD 產物區段是歷史證據,不能代替最終 D6AF 產物的當次驗收。 + +## 同產物自動複驗(先前產物) 2026-10-02 的整合候選自動結果見[同 JAR 複驗紀錄](./evidence/2026-10-02-issue-12-final-artifact-retest.md)。該輪僅使用新的 InstanceHarbor Agent 實例,沒有部署至下述固定 Human 測服。下述使用者已確認的真人結果維持有效,但受測產物不同;不可將自動封包檢查稱為整合 JAR 的真人畫面驗收。本輪只修正測試 runner 與文件,沒有改動產品 runtime,無須重做剛通過的完整三台 UX 流程。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 269d3dc..2d394a1 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -86,6 +86,10 @@ Runner 核對實體 Agent 路徑、`workspace.json` schema 2/audience、profil ## 無真人的合成玩家流程 +`flow.cjs` 的伺服器啟動等待預設為 180 秒,正常停止等待為 30 秒;可在測試程序設定 `INVITECODE_SERVER_START_TIMEOUT_MS`/`INVITECODE_SERVER_STOP_TIMEOUT_MS`,兩者只接受 100–600000 的整數毫秒。首次啟動超時也會清理自己啟動的程序;正常 `stop` 失敗時驗證程序樹終止結果並回報失敗,不把強制清理算成流程通過。這些環境變數只影響測試 runner,不改變插件設定。 + +本機 Windows 已準備 InstanceHarbor 及固定 Node 依賴時,可執行 `node --test .\scripts\test-servers\synthetic-player\instance-boundary.test.cjs .\scripts\test-servers\synthetic-player\startup-cleanup.test.cjs`。後者透過 runner CLI 與假的外部 Java 程序驗證啟動期限、正常停止及停止失敗的清理,不啟動 Minecraft;只建立自己的唯一 Agent fixture,保留證據至 Worktree `invitecode-plugin/build/current-artifact/startup-cleanup-fixtures/` 後移除該精確葉目錄,不累積假測服。真實核心與玩家結果仍須另外驗證,見[最新產物紀錄](./evidence/2026-10-02-issue-12-current-artifact-retest.md)。 + 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-*` InstanceHarbor instance。例如: diff --git a/scripts/test-servers/synthetic-player/flow.cjs b/scripts/test-servers/synthetic-player/flow.cjs index 09972c1..1793722 100644 --- a/scripts/test-servers/synthetic-player/flow.cjs +++ b/scripts/test-servers/synthetic-player/flow.cjs @@ -64,12 +64,20 @@ if (sha256(path.join(instancePath, 'server.jar')) !== metadata.serverSha256 || } const mise = process.env.MISE_EXE || 'mise' +const serverStartTimeoutMs = Number(process.env.INVITECODE_SERVER_START_TIMEOUT_MS || 180000) +const serverStopTimeoutMs = Number(process.env.INVITECODE_SERVER_STOP_TIMEOUT_MS || 30000) +for (const [name, timeout] of [['INVITECODE_SERVER_START_TIMEOUT_MS', serverStartTimeoutMs], + ['INVITECODE_SERVER_STOP_TIMEOUT_MS', serverStopTimeoutMs]]) { + if (!Number.isInteger(timeout) || timeout < 100 || timeout > 600000) { + throw new Error(`${name} must be an integer between 100 and 600000`) + } +} let fatalError const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) -async function until(check, description, timeoutMs = 30000) { +async function until(check, description, timeoutMs = 30000, failOnFatalError = true) { const deadline = Date.now() + timeoutMs while (Date.now() < deadline) { - if (fatalError) throw fatalError + if (failOnFatalError && fatalError) throw fatalError const result = check() if (result) return result await delay(100) @@ -96,25 +104,50 @@ async function startServer() { } }) } - await until(() => { - if (child.exitCode !== null) throw new Error(`Server exited before InviteCode was ready: ${child.exitCode}`) - return /InviteCode \S+ 已啟用/.test(state.output) && /Done \(/.test(state.output) - }, 'InviteCode ACTIVE', 100000) + try { + await until(() => { + if (child.exitCode !== null) throw new Error(`Server exited before InviteCode was ready: ${child.exitCode}`) + return /InviteCode \S+ 已啟用/.test(state.output) && /Done \(/.test(state.output) + }, 'InviteCode ACTIVE', serverStartTimeoutMs) + } catch (error) { + // main has not received this child yet; a failed startup must clean up its own process. + try { await stopServer(state) } catch (cleanupError) { + throw new AggregateError([error, cleanupError], 'Server startup failed and cleanup also failed') + } + throw error + } return state } async function stopServer(state) { if (!state || state.child.exitCode !== null) return - state.child.stdin.write('stop\n') + let inputError + const onInputError = error => { inputError = error } + state.child.stdin.on('error', onInputError) try { - await until(() => state.child.exitCode !== null, 'server stop', 30000) + await new Promise((resolve, reject) => { + state.child.stdin.write('stop\n', error => error ? reject(error) : resolve()) + }) + await until(() => { + if (inputError) throw inputError + return state.child.exitCode !== null + }, 'server stop', serverStopTimeoutMs, false) } catch (error) { - if (process.platform === 'win32' && state.child.pid) { - spawnSync('taskkill', ['/PID', String(state.child.pid), '/T', '/F'], { stdio: 'ignore' }) - } else { - state.child.kill() + if (state.child.exitCode === null && state.child.pid) { + if (process.platform === 'win32') { + const killed = spawnSync('taskkill', ['/PID', String(state.child.pid), '/T', '/F'], { encoding: 'utf8' }) + if (killed.error || killed.status !== 0) { + throw new AggregateError([error, killed.error || new Error(killed.stderr || `taskkill exit ${killed.status}`)], + 'Owned server process could not be terminated') + } + } else if (!state.child.kill()) { + throw new AggregateError([error, new Error('kill returned false')], 'Owned server process could not be terminated') + } + await until(() => state.child.exitCode !== null, 'forced server stop', serverStopTimeoutMs, false) } throw error + } finally { + state.child.stdin.removeListener('error', onInputError) } } diff --git a/scripts/test-servers/synthetic-player/startup-cleanup.test.cjs b/scripts/test-servers/synthetic-player/startup-cleanup.test.cjs new file mode 100644 index 0000000..f9aec33 --- /dev/null +++ b/scripts/test-servers/synthetic-player/startup-cleanup.test.cjs @@ -0,0 +1,93 @@ +const assert = require('node:assert/strict') +const crypto = require('node:crypto') +const fs = require('node:fs') +const path = require('node:path') +const { spawn, spawnSync } = require('node:child_process') +const test = require('node:test') + +// This Windows-only runner check substitutes the external Java process, never Minecraft data. +// Preserve evidence in the Worktree, then remove only the exact self-created fixture. +async function checkStartupCleanup(closeInput = false) { + const root = 'D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances' + assert.equal(fs.lstatSync(root).isSymbolicLink(), false) + const parent = path.join(root, 'Agent', 'InviteCode') + assert.equal(fs.realpathSync(parent), path.join(fs.realpathSync(root), 'Agent', 'InviteCode'), 'self-test parent must not redirect into other data') + const name = `issue12-startup-cleanup-${crypto.randomBytes(6).toString('hex')}` + const instance = path.join(root, 'Agent', 'InviteCode', name) + fs.mkdirSync(instance) + const data = path.join(instance, 'plugins', 'InviteCode') + fs.mkdirSync(data, { recursive: true }) + const server = Buffer.from('runner self-test server placeholder') + const plugin = Buffer.from('runner self-test plugin placeholder') + const hash = bytes => crypto.createHash('sha256').update(bytes).digest('hex').toUpperCase() + fs.writeFileSync(path.join(instance, 'server.jar'), server) + fs.writeFileSync(path.join(instance, 'plugins', 'InviteCode.jar'), plugin) + fs.writeFileSync(path.join(instance, 'workspace.json'), JSON.stringify({ + schemaVersion: 2, audience: 'Agent', project: 'InviteCode', instance: name, + profile: 'spigot-1.8.8', minecraftVersion: '1.8.8', javaAlias: 'local-8', port: 63819, + pluginFile: 'InviteCode.jar', pluginSha256: hash(plugin), serverSha256: hash(server), + eulaAccepted: true, runnerSelfTest: true + })) + fs.writeFileSync(path.join(instance, 'server.properties'), 'server-ip=127.0.0.1\nonline-mode=false\nserver-port=63819\n') + fs.writeFileSync(path.join(data, 'config.yml'), 'default: en_US\nuse-client-locale: false\ninput-mode: COMMAND_ONLY\nmatching-ip-action: ALLOW\n') + fs.writeFileSync(path.join(data, 'qualifications.yml'), 'type: LOGIN_DAYS\nat-least: 1\n') + fs.writeFileSync(path.join(instance, 'exec'), String.raw` +const fs = require('node:fs') +fs.writeFileSync('external-process.pid', String(process.pid)) +process.stdout.write('Done (0.01s)!\n') +${closeInput ? 'process.stdin.destroy()' : ''} +process.stdin.setEncoding('utf8') +process.stdin.on('data', input => { + if (input.trim() === 'stop') { + fs.writeFileSync('external-process-stopped.txt', 'normal stop received') + process.exit(0) + } +}) +setInterval(() => {}, 1000) +`) + const runner = spawn(process.execPath, [path.join(__dirname, 'flow.cjs'), instance], { + env: { ...process.env, MISE_EXE: process.execPath, INVITECODE_SERVER_START_TIMEOUT_MS: '500', INVITECODE_SERVER_STOP_TIMEOUT_MS: '500', + INVITECODE_CHAT_INPUT: '0', INVITECODE_FOLIA_CHAT: '0', INVITECODE_DIALOG_PROTOCOL: '0' }, + stdio: ['ignore', 'pipe', 'pipe'] + }) + let output = '' + for (const stream of [runner.stdout, runner.stderr]) stream.on('data', chunk => { output += chunk.toString('utf8') }) + let timer + try { + const code = await Promise.race([ + new Promise((resolve, reject) => { runner.once('error', reject); runner.once('exit', resolve) }), + new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('runner exceeded configured startup deadline and cleanup allowance')), 6000) }) + ]) + assert.notEqual(code, 0, 'failure must be reported') + assert.match(output, /Timed out waiting for InviteCode ACTIVE/) + if (!closeInput) assert.equal(fs.readFileSync(path.join(instance, 'external-process-stopped.txt'), 'utf8'), 'normal stop received') + const pid = Number(fs.readFileSync(path.join(instance, 'external-process.pid'), 'utf8')) + assert.throws(() => process.kill(pid, 0), /ESRCH|no such process/i) + } finally { + clearTimeout(timer) + if (runner.exitCode === null && runner.pid) { + // Only the explicitly created self-test process tree; no real server is targeted. + const killed = spawnSync('taskkill', ['/PID', String(runner.pid), '/T', '/F'], { encoding: 'utf8' }) + assert.equal(killed.status, 0, killed.stderr) + } + const pidPath = path.join(instance, 'external-process.pid') + if (fs.existsSync(pidPath)) { + const pid = Number(fs.readFileSync(pidPath, 'utf8')) + let alive = false + try { process.kill(pid, 0); alive = true } catch (error) { if (error.code !== 'ESRCH') throw error } + if (alive) { + const killed = spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], { encoding: 'utf8' }) + assert.equal(killed.status, 0, killed.stderr) + } + } + fs.writeFileSync(path.join(instance, 'runner.log'), output) + const evidence = path.resolve(__dirname, '..', '..', '..', 'invitecode-plugin', 'build', 'current-artifact', 'startup-cleanup-fixtures', name) + fs.cpSync(instance, evidence, { recursive: true, errorOnExist: true, force: false }) + assert.equal(fs.realpathSync(instance), path.join(fs.realpathSync(parent), name)) + assert.equal(path.basename(instance), name) + fs.rmSync(instance, { recursive: true }) + } +} + +test('startup deadline stops the owned server normally before reporting failure', { timeout: 15000 }, () => checkStartupCleanup()) +test('startup failure ends its owned process even when the console input pipe is broken', { timeout: 15000 }, () => checkStartupCleanup(true))