From d29f071ad422d8413963679cb0e0da5a146070db Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 00:29:16 +0800 Subject: [PATCH 01/12] test: add repeatable cross-version startup smoke --- .../2026-09-24-issue-12-startup-matrix.md | 24 +++ docs/testing/test-servers.md | 9 + scripts/test-servers/smoke.ps1 | 166 ++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md create mode 100644 scripts/test-servers/smoke.ps1 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 new file mode 100644 index 0000000..e90fd08 --- /dev/null +++ b/docs/testing/evidence/2026-09-24-issue-12-startup-matrix.md @@ -0,0 +1,24 @@ +# Issue #12 首輪跨版本啟動矩陣 + +- 受測基線:`develop` merge commit `3d64431`;唯一插件 JAR SHA-256:`99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`。 +- 本機建置:`mise exec -- .\gradlew.bat check shadowJar` 通過;本機未提供 MySQL service,相關整合測試依既有條件略過。PR #23 的獨立 MySQL CI 已通過。 +- 每個 profile 使用 TestLab 的獨立 `issue12-*` 實例、預設 SQLite、對應 mise Java。首次啟動與一次重啟都經 `smoke.ps1` 從 Console 執行 `ic admin doctor`,取得 `Runtime=ACTIVE`、儲存版本、正常 `stop`,且兩次停機後的 SQLite DB 與 anti-abuse key SHA-256 各自一致。所有七個受測實例的嚴格 UTF-8 log 檢查通過,沒有 InviteCode linkage/event 錯誤;測試後沒有殘留的矩陣 port listener。 + +| Profile | 核心/build | Java | 啟動與重啟 | +| --- | --- | --- | --- | +| `spigot-1.8.8` | Spigot 1.8.8/local BuildTools | `local-8` | 通過 | +| `spigot-1.12.2` | Spigot 1.12.2/local BuildTools | `local-8` | 通過 | +| `spigot-1.16.5` | Spigot 1.16.5/local BuildTools | `local-8` | 通過 | +| `spigot-latest` | Spigot 26.2/local BuildTools | `local-25` | 通過 | +| `paper-1.20.6` | Paper 1.20.6 build 151 | `local-21` | 通過 | +| `paper-1.21.8` | Paper 1.21.8 build 60 | `local-21` | 通過 | +| `paper-latest` | Paper 26.2 build 128 | `local-25` | 通過 | +| `folia-latest` | Folia 26.1.2 stable build 8,僅於 TestLab 本機 task Worktree 修正 profile 後 | `local-25` | 不通過:Folia 在載入階段拒絕插件 | + +另外以同一份 JAR 在 `paper-1.20.6` 的獨立 `issue12-json-paper-1206` 實例設為 `backend: JSON`,首次啟動與重啟均回報 `ACTIVE` 與 JSON 儲存版本 1;兩次正常停機後,`invitecode.json` 和 `anti-abuse.key` 的 SHA-256 各自一致。這是代表性 JSON 真實伺服器整合,並未測試 JSON 的玩家負載或跨 backend 搬移。 + +[PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 + +Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 + +本輪對 Spigot/Paper 只涵蓋無玩家的啟動、SQLite/JSON 初始化與重啟一致性。Issue #12 尚缺玩家/Console critical path、各版本實際 Claim 與 Reward recovery、MySQL 在代表性伺服器的整合、Vault/PlaceholderAPI 有無兩種情境、注入失敗/migration recovery、Folia 實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index c1d82ae..d7478f0 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -64,6 +64,15 @@ pwsh -NoProfile -File .\scripts\test-servers\start.ps1 -Profile paper-latest ## 每個 profile 的最低 smoke +已準備、記錄 EULA 接受狀態的隔離實例,可使用無玩家 smoke runner: + +```powershell +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`,確認 `ACTIVE`、整合狀態與儲存版本,正常送出 `stop`,檢查嚴格 UTF-8 log、儲存檔與 anti-abuse key,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`。它不會替使用者接受 EULA、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 + 1. 確認 InviteCode 啟用且沒有 linkage error、legacy material warning 或未處理 exception。 2. 確認所選 backend 首次啟動自動建立必要資料與 anti-abuse key(MySQL 使用外部密鑰),重新啟動後沿用既有資料。 3. 玩家與 Console 驗證 `/ic help`、`/ic reload`、Tab completion 與權限拒絕。 diff --git a/scripts/test-servers/smoke.ps1 b/scripts/test-servers/smoke.ps1 new file mode 100644 index 0000000..869828d --- /dev/null +++ b/scripts/test-servers/smoke.ps1 @@ -0,0 +1,166 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)][string] $Profile, + [Parameter(Mandatory = $true)][string] $Instance, + [ValidateSet('SQLITE', 'JSON')][string] $Backend = 'SQLITE', + [AllowNull()][string] $TestLabRoot, + [ValidateRange(10, 600)][int] $TimeoutSeconds = 180 +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" +. (Join-Path $PSScriptRoot "common.ps1") + +# Only operate on an already prepared, isolated TestLab 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" +} +[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 +$metadataPath = Join-Path $instancePath 'workspace.json' +if (-not (Test-Path -LiteralPath $metadataPath -PathType Leaf)) { + throw "找不到 TestLab instance:$metadataPath" +} +$metadata = Get-Content -LiteralPath $metadataPath -Raw -Encoding UTF8 | ConvertFrom-Json +if ($metadata.project -cne 'InviteCode' -or $metadata.instance -cne $Instance -or + $metadata.profile -cne $Profile -or -not $metadata.eulaAccepted) { + throw "TestLab metadata 不符,或尚未記錄 EULA 接受狀態:$Instance" +} +$pluginPath = Join-Path (Join-Path $instancePath 'plugins') $metadata.pluginFile +$serverPath = Join-Path $instancePath 'server.jar' +if (-not (Test-Path -LiteralPath $serverPath -PathType Leaf) -or + -not (Test-Path -LiteralPath $pluginPath -PathType Leaf)) { + throw "TestLab instance 缺少 server.jar 或插件 JAR:$Instance" +} +$pluginSha = (Get-FileHash -LiteralPath $pluginPath -Algorithm SHA256).Hash +if ($pluginSha -cne $metadata.pluginSha256) { + throw "插件 JAR 雜湊與 workspace.json 不符:$Instance" +} +if ((Get-FileHash -LiteralPath $serverPath -Algorithm SHA256).Hash -cne $metadata.serverSha256) { + throw "伺服器 JAR 雜湊與 workspace.json 不符:$Instance" +} +$logPath = Join-Path $instancePath 'logs\latest.log' +$dataPath = Join-Path $instancePath 'plugins\InviteCode' +$storagePath = Join-Path $dataPath 'storage.yml' +if (Test-Path -LiteralPath $storagePath -PathType Leaf) { + $configured = Get-Content -LiteralPath $storagePath -Raw -Encoding UTF8 + if ($configured -notmatch "(?m)^backend:\s*$Backend\s*$") { + throw "storage.yml 的 backend 與預期 $Backend 不符:$Instance" + } +} +elseif ($Backend -cne 'SQLITE') { + throw "非預設 backend 需要先建立 storage.yml:$Instance" +} +$mise = (Get-Command mise -CommandType Application -ErrorAction Stop | Select-Object -First 1).Source +$startInfo = [System.Diagnostics.ProcessStartInfo]::new() +$startInfo.FileName = $mise +$startInfo.WorkingDirectory = $instancePath +$startInfo.UseShellExecute = $false +$startInfo.CreateNoWindow = $true +$startInfo.RedirectStandardInput = $true +foreach ($argument in @('exec', "java@$($metadata.javaAlias)", '--', 'java', + '-Dfile.encoding=UTF-8', '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui')) { + [void] $startInfo.ArgumentList.Add($argument) +} +$process = [System.Diagnostics.Process]::new() +$process.StartInfo = $startInfo +$started = $false +$doctorSent = $false +$stopped = $false +$deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds) +$utf8Strict = [System.Text.UTF8Encoding]::new($false, $true) +function Read-LiveLog { + param([Parameter(Mandatory = $true)][string] $Path) + $stream = [System.IO.FileStream]::new($Path, [System.IO.FileMode]::Open, + [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite) + try { + $reader = [System.IO.StreamReader]::new($stream, $utf8Strict, $true) + return $reader.ReadToEnd() + } + finally { $stream.Dispose() } +} +try { + $runStartedAt = [DateTime]::UtcNow + if (-not $process.Start()) { throw "無法啟動 TestLab instance:$Instance" } + $started = $true + while ([DateTime]::UtcNow -lt $deadline) { + if ($process.HasExited) { break } + Start-Sleep -Milliseconds 500 + if (-not (Test-Path -LiteralPath $logPath -PathType Leaf)) { continue } + if ((Get-Item -LiteralPath $logPath).LastWriteTimeUtc -lt $runStartedAt) { continue } + try { $log = Read-LiveLog -Path $logPath } + catch [System.Text.DecoderFallbackException] { + # The writer may be in the middle of one UTF-8 character. The final + # read after a clean shutdown still enforces strict UTF-8. + continue + } + if ($log -match "Could not load plugin 'InviteCode.*not marked as supporting Folia") { + throw "Folia 拒絕載入尚未宣告支援的 InviteCode:$Instance" + } + if (-not $doctorSent -and $log -match 'Done \(' -and + $log -match '\[InviteCode\].*已啟用') { + $process.StandardInput.WriteLine('ic admin doctor') + $process.StandardInput.Flush() + $doctorSent = $true + } + if ($doctorSent -and $log -match 'Runtime=ACTIVE' -and + $log -match 'Integration:' -and $log -match "$Backend 儲存版本=") { + $process.StandardInput.WriteLine('stop') + $process.StandardInput.Flush() + $stopped = $true + break + } + } + if (-not $stopped) { + throw "Smoke 未在 $TimeoutSeconds 秒內取得 ACTIVE doctor 結果:$Instance" + } + if (-not $process.WaitForExit(30000)) { + throw "伺服器未在 stop 後 30 秒內結束:$Instance" + } + if ($process.ExitCode -ne 0) { + throw "伺服器結束碼為 $($process.ExitCode):$Instance" + } + $log = Read-LiveLog -Path $logPath + if ($log -match '(?i)NoSuchMethodError|NoSuchFieldError|Could not load.*InviteCode|Could not pass event.*InviteCode|Error occurred while (enabling|disabling) InviteCode') { + throw "伺服器 log 含 InviteCode linkage 或事件錯誤:$Instance" + } + $keyPath = Join-Path $dataPath 'anti-abuse.key' + $databasePath = Join-Path $dataPath $(if ($Backend -ceq 'JSON') { 'invitecode.json' } else { 'invitecode.db' }) + if (-not (Test-Path -LiteralPath $keyPath -PathType Leaf) -or + -not (Test-Path -LiteralPath $databasePath -PathType Leaf)) { + throw "$Backend 或 anti-abuse key 尚未建立:$Instance" + } + [pscustomobject]@{ + profile = $Profile + instance = $Instance + backend = $Backend + pluginSha256 = $pluginSha + serverSha256 = $metadata.serverSha256 + javaAlias = $metadata.javaAlias + doctorActive = $true + storageSha256 = (Get-FileHash -LiteralPath $databasePath -Algorithm SHA256).Hash + keySha256 = (Get-FileHash -LiteralPath $keyPath -Algorithm SHA256).Hash + logPath = $logPath + } | ConvertTo-Json -Compress +} +finally { + if ($started -and -not $process.HasExited) { + try { + $process.StandardInput.WriteLine('stop') + $process.StandardInput.Flush() + if (-not $process.WaitForExit(30000)) { + Write-Warning "測試伺服器未接受 stop,將終止本 runner 建立的程序樹:$Instance" + $process.Kill($true) + [void] $process.WaitForExit(10000) + } + } + catch { + if (-not $process.HasExited) { $process.Kill($true) } + } + } + $process.Dispose() +} From ef753e92d94f06eb9d8477b2d23db157753a12db Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 00:33:56 +0800 Subject: [PATCH 02/12] test: cover console help and reload in server smoke --- .../evidence/2026-09-24-issue-12-startup-matrix.md | 4 ++-- docs/testing/test-servers.md | 2 +- scripts/test-servers/smoke.ps1 | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) 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 e90fd08..2e75eba 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 @@ -2,7 +2,7 @@ - 受測基線:`develop` merge commit `3d64431`;唯一插件 JAR SHA-256:`99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`。 - 本機建置:`mise exec -- .\gradlew.bat check shadowJar` 通過;本機未提供 MySQL service,相關整合測試依既有條件略過。PR #23 的獨立 MySQL CI 已通過。 -- 每個 profile 使用 TestLab 的獨立 `issue12-*` 實例、預設 SQLite、對應 mise Java。首次啟動與一次重啟都經 `smoke.ps1` 從 Console 執行 `ic admin doctor`,取得 `Runtime=ACTIVE`、儲存版本、正常 `stop`,且兩次停機後的 SQLite DB 與 anti-abuse key SHA-256 各自一致。所有七個受測實例的嚴格 UTF-8 log 檢查通過,沒有 InviteCode linkage/event 錯誤;測試後沒有殘留的矩陣 port listener。 +- 每個 profile 使用 TestLab 的獨立 `issue12-*` 實例、預設 SQLite、對應 mise Java。首次啟動與一次重啟都經 `smoke.ps1` 從 Console 執行 `ic admin doctor`,取得 `Runtime=ACTIVE`、儲存版本、正常 `stop`,且兩次停機後的 SQLite DB 與 anti-abuse key SHA-256 各自一致。再以同一 runner 對七個實例驗證 Console `ic help`、`ic reload` 均回傳預期訊息。所有七個受測實例的嚴格 UTF-8 log 檢查通過,沒有 InviteCode linkage/event 錯誤;測試後沒有殘留的矩陣 port listener。 | Profile | 核心/build | Java | 啟動與重啟 | | --- | --- | --- | --- | @@ -15,7 +15,7 @@ | `paper-latest` | Paper 26.2 build 128 | `local-25` | 通過 | | `folia-latest` | Folia 26.1.2 stable build 8,僅於 TestLab 本機 task Worktree 修正 profile 後 | `local-25` | 不通過:Folia 在載入階段拒絕插件 | -另外以同一份 JAR 在 `paper-1.20.6` 的獨立 `issue12-json-paper-1206` 實例設為 `backend: JSON`,首次啟動與重啟均回報 `ACTIVE` 與 JSON 儲存版本 1;兩次正常停機後,`invitecode.json` 和 `anti-abuse.key` 的 SHA-256 各自一致。這是代表性 JSON 真實伺服器整合,並未測試 JSON 的玩家負載或跨 backend 搬移。 +另外以同一份 JAR 在 `paper-1.20.6` 的獨立 `issue12-json-paper-1206` 實例設為 `backend: JSON`,首次啟動與重啟均回報 `ACTIVE` 與 JSON 儲存版本 1;兩次正常停機後,`invitecode.json` 和 `anti-abuse.key` 的 SHA-256 各自一致。Console 的 `ic help` 與 `ic reload` 也通過。這是代表性 JSON 真實伺服器整合,並未測試 JSON 的玩家負載或跨 backend 搬移。 [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index d7478f0..882be56 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -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`,確認 `ACTIVE`、整合狀態與儲存版本,正常送出 `stop`,檢查嚴格 UTF-8 log、儲存檔與 anti-abuse key,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`。它不會替使用者接受 EULA、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 +Runner 核對 `workspace.json` 的 profile、EULA、核心與插件 JAR SHA-256;等待插件啟用後從 Console 執行 `ic admin doctor`、`ic help` 與 `ic reload`,確認 `ACTIVE`、整合狀態、儲存版本、指令說明與重新載入成功,正常送出 `stop`,檢查嚴格 UTF-8 log、儲存檔與 anti-abuse key,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`。它不會替使用者接受 EULA、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 1. 確認 InviteCode 啟用且沒有 linkage error、legacy material warning 或未處理 exception。 2. 確認所選 backend 首次啟動自動建立必要資料與 anti-abuse key(MySQL 使用外部密鑰),重新啟動後沿用既有資料。 diff --git a/scripts/test-servers/smoke.ps1 b/scripts/test-servers/smoke.ps1 index 869828d..a21cacb 100644 --- a/scripts/test-servers/smoke.ps1 +++ b/scripts/test-servers/smoke.ps1 @@ -70,6 +70,7 @@ $process = [System.Diagnostics.Process]::new() $process.StartInfo = $startInfo $started = $false $doctorSent = $false +$commandsSent = $false $stopped = $false $deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds) $utf8Strict = [System.Text.UTF8Encoding]::new($false, $true) @@ -108,7 +109,15 @@ try { $doctorSent = $true } if ($doctorSent -and $log -match 'Runtime=ACTIVE' -and - $log -match 'Integration:' -and $log -match "$Backend 儲存版本=") { + $log -match 'Integration:' -and $log -match "$Backend 儲存版本=" -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 設定已完整驗證並套用。') { $process.StandardInput.WriteLine('stop') $process.StandardInput.Flush() $stopped = $true @@ -116,7 +125,7 @@ try { } } if (-not $stopped) { - throw "Smoke 未在 $TimeoutSeconds 秒內取得 ACTIVE doctor 結果:$Instance" + throw "Smoke 未在 $TimeoutSeconds 秒內取得 ACTIVE doctor、help 與 reload 結果:$Instance" } if (-not $process.WaitForExit(30000)) { throw "伺服器未在 stop 後 30 秒內結束:$Instance" @@ -142,6 +151,7 @@ try { serverSha256 = $metadata.serverSha256 javaAlias = $metadata.javaAlias doctorActive = $true + consoleCommands = @('ic admin doctor', 'ic help', 'ic reload') storageSha256 = (Get-FileHash -LiteralPath $databasePath -Algorithm SHA256).Hash keySha256 = (Get-FileHash -LiteralPath $keyPath -Algorithm SHA256).Hash logPath = $logPath From 862971ba66e3e7f07588edff1ced06223e3e08f3 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 03:09:40 +0800 Subject: [PATCH 03/12] test: verify optional integrations in server smoke --- .../2026-09-24-issue-12-startup-matrix.md | 17 ++++++++++++++++- docs/testing/test-servers.md | 2 ++ scripts/test-servers/smoke.ps1 | 14 +++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) 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 2e75eba..c12d169 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 @@ -17,8 +17,23 @@ 另外以同一份 JAR 在 `paper-1.20.6` 的獨立 `issue12-json-paper-1206` 實例設為 `backend: JSON`,首次啟動與重啟均回報 `ACTIVE` 與 JSON 儲存版本 1;兩次正常停機後,`invitecode.json` 和 `anti-abuse.key` 的 SHA-256 各自一致。Console 的 `ic help` 與 `ic reload` 也通過。這是代表性 JSON 真實伺服器整合,並未測試 JSON 的玩家負載或跨 backend 搬移。 +## 外部整合的有/無情境 + +`smoke.ps1` 已加入整合狀態預期值檢查;不傳 switch 時要求 doctor 回報 PlaceholderAPI 與 Vault Economy 均為 `false`。先前七個純淨實例符合此條件,另於 Spigot 1.8.8 以新檢查重跑一次通過。 + +| 情境 | 獨立實例與受測外掛 | 結果 | +| --- | --- | --- | +| PlaceholderAPI 存在 | `issue12-papi-paper-1206`,Paper 1.20.6、PlaceholderAPI 2.12.3;外掛 JAR SHA-256 `FDE03259F5AF6938F3C33EEB4D814000A1ADABF1D2304CE14970BE81F609A437` | 首次啟動與重啟均 `PlaceholderAPI=true`、`Vault Economy=false`;SQLite DB 與 key 雜湊不變 | +| Vault Economy 存在 | `issue12-vault-212-paper-1218`,Paper 1.21.8、Vault 1.7.3-b131、EssentialsX 2.21.2;兩個 JAR SHA-256 分別為 `A6B5ED97F43A5CF5BBAF00A7C8CD23C5AFC9BD003F849875AF8B36E6CF77D01D`、`0B759026F02F3C547C32886F3666DB3C1F94CFF73E141AE5648313FD0D0BDFC6` | 首次啟動與重啟均 `Vault Economy=true`、`PlaceholderAPI=false`;Vault log 顯示 Essentials Economy hooked;SQLite DB 與 key 雜湊不變 | + +也在 Paper 26.2 與 1.21.8 試過 EssentialsX 2.22.0:doctor 可偵測 Vault Economy,但 EssentialsX 自行警告該伺服器版本不受支援,因此不把它當作乾淨的正向驗證。以上只確認外掛載入與 InviteCode 的服務偵測;尚未驗證實際 placeholder 展開、Vault 金額變化或發獎。 + +## 復原測試的現況 + +既有自動測試含 SQLite migration 失敗後的 rollback 與版本/資料保留、rollback 自身失敗時回報不確定狀態、Reward Action 在資料庫關閉後重開的 pending/interrupted recovery,以及 `UNCERTAIN` 只允許稽核後由管理員處理。核心測試也涵蓋外部 effect 執行後最終保存失敗時不自動重做。`mise exec -- .\gradlew.bat :invitecode-core:test :invitecode-storage-sql:test --rerun-tasks --no-daemon` 本輪通過,兩個 `test` task 均實際執行。這些是注入故障的程式層級證據,尚未在真實 Minecraft 伺服器上完成 Reward crash/restart 演練。MySQL 8.4 的儲存整合在 CI 的隔離 service 執行;本機沒有獨立 MySQL service,故本輪 MySQL 測試被略過,也沒有 MySQL 插件伺服器 smoke;不會使用現存的 MySQL 資料目錄代替隔離測試。 + [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 只涵蓋無玩家的啟動、SQLite/JSON 初始化與重啟一致性。Issue #12 尚缺玩家/Console critical path、各版本實際 Claim 與 Reward recovery、MySQL 在代表性伺服器的整合、Vault/PlaceholderAPI 有無兩種情境、注入失敗/migration recovery、Folia 實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 只涵蓋無玩家的啟動、SQLite/JSON 初始化、重啟一致性、Console help/reload/doctor 與外部服務偵測。Issue #12 尚缺玩家 critical path、各版本實際 Claim 與 Reward recovery、MySQL 在代表性伺服器的整合、Vault/PlaceholderAPI 實際功能、伺服器層級注入失敗/migration recovery、Folia 可載入後的實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 882be56..a5b51fe 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -73,6 +73,8 @@ pwsh -NoProfile -File .\scripts\test-servers\smoke.ps1 ` Runner 核對 `workspace.json` 的 profile、EULA、核心與插件 JAR SHA-256;等待插件啟用後從 Console 執行 `ic admin doctor`、`ic help` 與 `ic reload`,確認 `ACTIVE`、整合狀態、儲存版本、指令說明與重新載入成功,正常送出 `stop`,檢查嚴格 UTF-8 log、儲存檔與 anti-abuse key,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`。它不會替使用者接受 EULA、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 +預設預期 PlaceholderAPI 與 Vault Economy 都不存在。已在獨立實例安裝 PlaceholderAPI 時加上 `-ExpectPlaceholderApi`;已安裝 Vault 與經濟提供者時加上 `-ExpectVaultEconomy`。Runner 會核對 Console doctor 的實際整合狀態,輸出對應布林值;這只驗證服務偵測,不代表實際 placeholder 展開或經濟入帳已通過。 + 1. 確認 InviteCode 啟用且沒有 linkage error、legacy material warning 或未處理 exception。 2. 確認所選 backend 首次啟動自動建立必要資料與 anti-abuse key(MySQL 使用外部密鑰),重新啟動後沿用既有資料。 3. 玩家與 Console 驗證 `/ic help`、`/ic reload`、Tab completion 與權限拒絕。 diff --git a/scripts/test-servers/smoke.ps1 b/scripts/test-servers/smoke.ps1 index a21cacb..57b7580 100644 --- a/scripts/test-servers/smoke.ps1 +++ b/scripts/test-servers/smoke.ps1 @@ -3,6 +3,8 @@ param( [Parameter(Mandatory = $true)][string] $Profile, [Parameter(Mandatory = $true)][string] $Instance, [ValidateSet('SQLITE', 'JSON')][string] $Backend = 'SQLITE', + [switch] $ExpectPlaceholderApi, + [switch] $ExpectVaultEconomy, [AllowNull()][string] $TestLabRoot, [ValidateRange(10, 600)][int] $TimeoutSeconds = 180 ) @@ -72,6 +74,8 @@ $started = $false $doctorSent = $false $commandsSent = $false $stopped = $false +$placeholderExpected = $ExpectPlaceholderApi.IsPresent.ToString().ToLowerInvariant() +$vaultExpected = $ExpectVaultEconomy.IsPresent.ToString().ToLowerInvariant() $deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSeconds) $utf8Strict = [System.Text.UTF8Encoding]::new($false, $true) function Read-LiveLog { @@ -102,6 +106,11 @@ try { if ($log -match "Could not load plugin 'InviteCode.*not marked as supporting Folia") { 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") { + throw "外部整合診斷與預期不符:PlaceholderAPI=$placeholderExpected,Vault Economy=$vaultExpected;$Instance" + } if (-not $doctorSent -and $log -match 'Done \(' -and $log -match '\[InviteCode\].*已啟用') { $process.StandardInput.WriteLine('ic admin doctor') @@ -109,7 +118,8 @@ try { $doctorSent = $true } if ($doctorSent -and $log -match 'Runtime=ACTIVE' -and - $log -match 'Integration:' -and $log -match "$Backend 儲存版本=" -and + $log -match "Integration:PlaceholderAPI=$placeholderExpected,Vault Economy=$vaultExpected" -and + $log -match "$Backend 儲存版本=" -and -not $commandsSent) { $process.StandardInput.WriteLine('ic help') $process.StandardInput.WriteLine('ic reload') @@ -151,6 +161,8 @@ try { serverSha256 = $metadata.serverSha256 javaAlias = $metadata.javaAlias doctorActive = $true + placeholderApi = $ExpectPlaceholderApi.IsPresent + vaultEconomy = $ExpectVaultEconomy.IsPresent consoleCommands = @('ic admin doctor', 'ic help', 'ic reload') storageSha256 = (Get-FileHash -LiteralPath $databasePath -Algorithm SHA256).Hash keySha256 = (Get-FileHash -LiteralPath $keyPath -Algorithm SHA256).Hash From 6e4ecd6eb959692caffd498c9a20fac9ab3bd781 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 03:30:45 +0800 Subject: [PATCH 04/12] test: cover MySQL server startup and restart --- .../2026-09-24-issue-12-startup-matrix.md | 18 ++++++++--- docs/testing/test-servers.md | 2 +- scripts/test-servers/smoke.ps1 | 30 ++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) 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 c12d169..5dc1247 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 @@ -1,7 +1,7 @@ -# Issue #12 首輪跨版本啟動矩陣 +# Issue #12 跨版本啟動矩陣與整合驗證 - 受測基線:`develop` merge commit `3d64431`;唯一插件 JAR SHA-256:`99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`。 -- 本機建置:`mise exec -- .\gradlew.bat check shadowJar` 通過;本機未提供 MySQL service,相關整合測試依既有條件略過。PR #23 的獨立 MySQL CI 已通過。 +- 本機建置:`mise exec -- .\gradlew.bat check shadowJar` 通過。首輪沒有本機 MySQL service;本輪另建立完全隔離的 MySQL 8.4.11 服務並重跑相關整合測試,結果見下文。 - 每個 profile 使用 TestLab 的獨立 `issue12-*` 實例、預設 SQLite、對應 mise Java。首次啟動與一次重啟都經 `smoke.ps1` 從 Console 執行 `ic admin doctor`,取得 `Runtime=ACTIVE`、儲存版本、正常 `stop`,且兩次停機後的 SQLite DB 與 anti-abuse key SHA-256 各自一致。再以同一 runner 對七個實例驗證 Console `ic help`、`ic reload` 均回傳預期訊息。所有七個受測實例的嚴格 UTF-8 log 檢查通過,沒有 InviteCode linkage/event 錯誤;測試後沒有殘留的矩陣 port listener。 | Profile | 核心/build | Java | 啟動與重啟 | @@ -30,10 +30,20 @@ ## 復原測試的現況 -既有自動測試含 SQLite migration 失敗後的 rollback 與版本/資料保留、rollback 自身失敗時回報不確定狀態、Reward Action 在資料庫關閉後重開的 pending/interrupted recovery,以及 `UNCERTAIN` 只允許稽核後由管理員處理。核心測試也涵蓋外部 effect 執行後最終保存失敗時不自動重做。`mise exec -- .\gradlew.bat :invitecode-core:test :invitecode-storage-sql:test --rerun-tasks --no-daemon` 本輪通過,兩個 `test` task 均實際執行。這些是注入故障的程式層級證據,尚未在真實 Minecraft 伺服器上完成 Reward crash/restart 演練。MySQL 8.4 的儲存整合在 CI 的隔離 service 執行;本機沒有獨立 MySQL service,故本輪 MySQL 測試被略過,也沒有 MySQL 插件伺服器 smoke;不會使用現存的 MySQL 資料目錄代替隔離測試。 +既有自動測試含 SQLite migration 失敗後的 rollback 與版本/資料保留、rollback 自身失敗時回報不確定狀態、Reward Action 在資料庫關閉後重開的 pending/interrupted recovery,以及 `UNCERTAIN` 只允許稽核後由管理員處理。核心測試也涵蓋外部 effect 執行後最終保存失敗時不自動重做。`mise exec -- .\gradlew.bat :invitecode-core:test :invitecode-storage-sql:test --rerun-tasks --no-daemon` 通過,兩個 `test` task 均實際執行。這些是注入故障的程式層級證據,尚未在真實 Minecraft 伺服器上完成 Reward crash/restart 演練。 + +## MySQL 8.4 代表性伺服器整合 + +從 [Oracle 官方 MySQL 下載來源](https://dev.mysql.com/downloads/mysql/)取得 Windows ZIP,使用的 `mysql-8.4.11-winx64.zip` SHA-256 為 `A492371D687D2BAB088B0062581144A0044B8964BAEFDF4FAA579292B423D25C`。ZIP 解壓與資料目錄都在 TestLab 的 `artifacts/invitecode-issue12-mysql-8.4.11/`,與 `C:\Program Files\MySQL` 的既有資料完全分離。`mysqld --version` 為 8.4.11;服務只綁定 `127.0.0.1:63384`,使用隨機測試密碼、獨立 `invitecode_issue12` database 和專用 `invitecode_test` 帳號。測試密碼與 network secret 以目前 Windows 使用者的加密 CLIXML 暫存於該隔離 runtime,未寫入 repository、設定範本或 log。測試設定採 `tls-mode: REQUIRED`,因此未驗證正式預設的 `VERIFY_IDENTITY` 憑證身分檢查。 + +在此服務上強制重跑 `mise exec -- .\gradlew.bat :invitecode-storage-sql:test :invitecode-plugin:test --rerun-tasks --no-daemon`:storage SQL 51 個、plugin 17 個測試,皆無失敗或略過。測試所建的隨機 database 都已清理,除 MySQL 系統資料庫外只剩本次 `invitecode_issue12`。 + +`issue12-mysql-paper-1206` 使用 Paper 1.20.6 build 151 與同一份受測插件 JAR,`storage.yml` 指向上述隔離服務。首次啟動回報 `Runtime=ACTIVE`、`MYSQL 儲存版本=1`、自動初始化;從 Console 執行 `ic admin doctor`、`ic help`、`ic reload` 均成功。正常停機後資料庫有 13 張表、migration ledger `version=1,state=APPLIED`、初始化稽核紀錄 1 筆。以相同密碼與 network secret 重啟後仍為 `ACTIVE`,上述表數、ledger 與稽核筆數維持不變;插件資料夾沒有產生本機 `anti-abuse.key`。兩次 Paper log 沒有 InviteCode error/exception。測試後以 `mysqladmin shutdown` 關閉本次 MySQL 服務,63384 與 Paper 的 62060 埠都已釋放。此項驗證首次建表與再開啟,尚未涵蓋真實玩家 Claim 或 MySQL 的伺服器層級中斷復原。 + +Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實例;`ACTIVE`、Console 指令、本機儲存檔與 key 檢查均通過,確認新增 MYSQL 分支沒有破壞原本兩種 backend 的 smoke 路徑。 [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 只涵蓋無玩家的啟動、SQLite/JSON 初始化、重啟一致性、Console help/reload/doctor 與外部服務偵測。Issue #12 尚缺玩家 critical path、各版本實際 Claim 與 Reward recovery、MySQL 在代表性伺服器的整合、Vault/PlaceholderAPI 實際功能、伺服器層級注入失敗/migration recovery、Folia 可載入後的實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 涵蓋無玩家的啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor 與外部服務偵測。Issue #12 尚缺玩家 critical path、各版本實際 Claim 與 Reward recovery、Vault/PlaceholderAPI 實際功能、伺服器層級注入失敗/migration recovery、Folia 可載入後的實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index a5b51fe..4a9fbc8 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -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、儲存檔與 anti-abuse key,並輸出 JSON 結果。預設 backend 為 SQLite;對已明確設定 `backend: JSON` 的實例傳入 `-Backend JSON`。它不會替使用者接受 EULA、重建實例或模擬玩家。再次執行同一實例可比對重啟前後的資料與 key SHA-256。完整發行 gate 仍須依下列清單補足 critical user path 與外部整合情境。 +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 與外部整合情境。 預設預期 PlaceholderAPI 與 Vault Economy 都不存在。已在獨立實例安裝 PlaceholderAPI 時加上 `-ExpectPlaceholderApi`;已安裝 Vault 與經濟提供者時加上 `-ExpectVaultEconomy`。Runner 會核對 Console doctor 的實際整合狀態,輸出對應布林值;這只驗證服務偵測,不代表實際 placeholder 展開或經濟入帳已通過。 diff --git a/scripts/test-servers/smoke.ps1 b/scripts/test-servers/smoke.ps1 index 57b7580..2547d83 100644 --- a/scripts/test-servers/smoke.ps1 +++ b/scripts/test-servers/smoke.ps1 @@ -2,7 +2,7 @@ param( [Parameter(Mandatory = $true)][string] $Profile, [Parameter(Mandatory = $true)][string] $Instance, - [ValidateSet('SQLITE', 'JSON')][string] $Backend = 'SQLITE', + [ValidateSet('SQLITE', 'JSON', 'MYSQL')][string] $Backend = 'SQLITE', [switch] $ExpectPlaceholderApi, [switch] $ExpectVaultEconomy, [AllowNull()][string] $TestLabRoot, @@ -56,6 +56,11 @@ if (Test-Path -LiteralPath $storagePath -PathType Leaf) { elseif ($Backend -cne 'SQLITE') { throw "非預設 backend 需要先建立 storage.yml:$Instance" } +if ($Backend -ceq 'MYSQL' -and + ([string]::IsNullOrEmpty($env:INVITECODE_DB_PASSWORD) -or + [string]::IsNullOrEmpty($env:INVITECODE_NETWORK_SECRET))) { + throw 'MYSQL smoke 需要先在測試程序環境提供資料庫密碼與 network secret。' +} $mise = (Get-Command mise -CommandType Application -ErrorAction Stop | Select-Object -First 1).Source $startInfo = [System.Diagnostics.ProcessStartInfo]::new() $startInfo.FileName = $mise @@ -148,10 +153,21 @@ try { throw "伺服器 log 含 InviteCode linkage 或事件錯誤:$Instance" } $keyPath = Join-Path $dataPath 'anti-abuse.key' - $databasePath = Join-Path $dataPath $(if ($Backend -ceq 'JSON') { 'invitecode.json' } else { 'invitecode.db' }) - if (-not (Test-Path -LiteralPath $keyPath -PathType Leaf) -or - -not (Test-Path -LiteralPath $databasePath -PathType Leaf)) { - throw "$Backend 或 anti-abuse key 尚未建立:$Instance" + $storageSha256 = $null + $keySha256 = $null + if ($Backend -ceq 'MYSQL') { + if (Test-Path -LiteralPath $keyPath -PathType Leaf) { + throw "MYSQL 模式不應在本機建立 anti-abuse key:$Instance" + } + } + else { + $databasePath = Join-Path $dataPath $(if ($Backend -ceq 'JSON') { 'invitecode.json' } else { 'invitecode.db' }) + if (-not (Test-Path -LiteralPath $keyPath -PathType Leaf) -or + -not (Test-Path -LiteralPath $databasePath -PathType Leaf)) { + throw "$Backend 或 anti-abuse key 尚未建立:$Instance" + } + $storageSha256 = (Get-FileHash -LiteralPath $databasePath -Algorithm SHA256).Hash + $keySha256 = (Get-FileHash -LiteralPath $keyPath -Algorithm SHA256).Hash } [pscustomobject]@{ profile = $Profile @@ -164,8 +180,8 @@ try { placeholderApi = $ExpectPlaceholderApi.IsPresent vaultEconomy = $ExpectVaultEconomy.IsPresent consoleCommands = @('ic admin doctor', 'ic help', 'ic reload') - storageSha256 = (Get-FileHash -LiteralPath $databasePath -Algorithm SHA256).Hash - keySha256 = (Get-FileHash -LiteralPath $keyPath -Algorithm SHA256).Hash + storageSha256 = $storageSha256 + keySha256 = $keySha256 logPath = $logPath } | ConvertTo-Json -Compress } From b3751c4c6b3c4017ec3e453394ae4ab4927d8e55 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 04:26:23 +0800 Subject: [PATCH 05/12] test: exercise claim and offline rewards with synthetic players --- .gitignore | 1 + .../2026-09-24-issue-12-startup-matrix.md | 14 +- docs/testing/test-servers.md | 18 + .../test-servers/prepare-synthetic-player.ps1 | 53 + .../test-servers/synthetic-player/flow.cjs | 170 +++ .../synthetic-player/package-lock.json | 1039 +++++++++++++++++ .../synthetic-player/package.json | 12 + 7 files changed, 1306 insertions(+), 1 deletion(-) create mode 100644 scripts/test-servers/prepare-synthetic-player.ps1 create mode 100644 scripts/test-servers/synthetic-player/flow.cjs create mode 100644 scripts/test-servers/synthetic-player/package-lock.json create mode 100644 scripts/test-servers/synthetic-player/package.json diff --git a/.gitignore b/.gitignore index 1ef9605..e113f1f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ out/ *.db-shm *.db-wal .env +scripts/test-servers/synthetic-player/node_modules/ 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 5dc1247..30a1bc3 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 @@ -42,8 +42,20 @@ Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實例;`ACTIVE`、Console 指令、本機儲存檔與 key 檢查均通過,確認新增 MYSQL 分支沒有破壞原本兩種 backend 的 smoke 路徑。 +## 合成玩家 Claim 與離線 Reward + +測試專用 Mineflayer 4.39.0 fixture 使用固定 `package-lock.json`,`npm ci --ignore-scripts` 成功、`npm audit` 回報 0 個已知漏洞。它從正式玩家指令與 Console doctor 觀察結果,使用相同插件 JAR SHA-256 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`,每個版本各建立全新 SQLite TestLab 實例。測試設定限定英文指令訊息、`COMMAND_ONLY`、同 IP `ALLOW` 與 `LOGIN_DAYS at-least: 1`;本輪驗證的是預設 `MESSAGE` Reward,而非 Vault 發錢。 + +| Profile | 實例 | 合成玩家流程 | +| --- | --- | --- | +| Spigot 1.8.8 | `issue12-fixture-spigot-188` | 通過 | +| Paper 1.20.6 | `issue12-fixture-paper-1206` | 通過;Mineflayer/protodef 在登入時另有非致命封包解析警告 | +| Paper 1.21.8 | `issue12-fixture-paper-1218` | 通過 | + +每次流程由 A 執行 `/ic code` 後離線,B 執行 `/ic claim `、`/ic confirm`,收到 Invitation 已建立及 Qualification Reward 訊息。Console doctor 回報 `PENDING=1, PROCESSING=0, UNCERTAIN=0`;正常關機並重啟後仍為 `PENDING=1`。A 再登入收到離線補發訊息,doctor 變為 `PENDING=0`,`/ic stats` 顯示 `qualified=1`。以上驗證真實伺服器的玩家指令與訊息路徑,尚未測試伺服器在外部 Reward effect 期間非正常終止。Paper 1.20.6 的封包警告出自測試客戶端 `protodef`,伺服器端沒有 InviteCode error;該版本的其他客戶端封包相容性不能由此次流程推定。 + [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 涵蓋無玩家的啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor 與外部服務偵測。Issue #12 尚缺玩家 critical path、各版本實際 Claim 與 Reward recovery、Vault/PlaceholderAPI 實際功能、伺服器層級注入失敗/migration recovery、Folia 可載入後的實驗性 smoke 與最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、Vault/PlaceholderAPI 實際功能、外部效果期間的 Reward `UNCERTAIN` 與伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 4a9fbc8..e6faa20 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -84,6 +84,24 @@ Runner 核對 `workspace.json` 的 profile、EULA、核心與插件 JAR SHA-256 各次測試應記錄 `workspace.json`、受測 commit、JAR SHA-256、操作結果與 `logs/latest.log`。實際相容性證據尚未取得前,不得只因實例能建立就宣稱該版本受到支援。 +## 無真人的合成玩家流程 + +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。例如: + +```powershell +$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-paper-1206\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +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' +``` + +`-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 限定 Spigot 1.8.8、Paper 1.20.6 與 1.21.8;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋聊天/Dialog 輸入、Vault 金額、最新 Paper 26.2 或中斷於外部效果期間的 `UNCERTAIN` 復原。 + ## 自動檢查與最終真人驗收 日常開發與各功能階段先由 Agent 執行不需要玩家判斷的檢查,包括 Gradle 測試、JAR 結構與 Java 8 bytecode、伺服器啟動與正常停機、log 錯誤掃描、UTF-8 解碼、SQLite/防濫用密鑰初始化,以及適用時的重啟持久化。這些結果須綁定受測 commit 與 JAR SHA-256。 diff --git a/scripts/test-servers/prepare-synthetic-player.ps1 b/scripts/test-servers/prepare-synthetic-player.ps1 new file mode 100644 index 0000000..d521f40 --- /dev/null +++ b/scripts/test-servers/prepare-synthetic-player.ps1 @@ -0,0 +1,53 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8')] + [string] $Profile, + [Parameter(Mandatory = $true)][string] $Instance, + [Parameter(Mandatory = $true)][string] $Artifact, + [switch] $AcceptEula, + [AllowNull()][string] $TestLabRoot +) + +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 名稱。' +} +$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +Import-Module (Join-Path $lab 'scripts\TestLab.psm1') -Force +$instancePath = Get-TestLabInstancePath -Project 'InviteCode' -Instance $Instance +if (Test-Path -LiteralPath $instancePath) { + throw "合成玩家測試必須使用全新隔離實例;目標已存在:$instancePath" +} +& (Join-Path $PSScriptRoot 'prepare.ps1') -Profile $Profile -Instance $Instance ` + -Artifact $Artifact -TestLabRoot $lab -AcceptEula:$AcceptEula + +$data = Join-Path $instancePath 'plugins\InviteCode' +New-Item -ItemType Directory -Path $data -Force | Out-Null +$source = Join-Path (Get-InviteCodeRepositoryRoot) 'invitecode-plugin\src\main\resources\config\config.yml' +$configuration = Get-Content -LiteralPath $source -Raw -Encoding UTF8 +$configuration = $configuration.Replace('default: zh_TW', 'default: en_US').Replace( + 'use-client-locale: true', 'use-client-locale: false').Replace( + 'input-mode: AUTO', 'input-mode: COMMAND_ONLY').Replace( + 'matching-ip-action: DENY', 'matching-ip-action: ALLOW') +[System.IO.File]::WriteAllText( + (Join-Path $data 'config.yml'), $configuration, [System.Text.UTF8Encoding]::new($false) +) +$qualification = @' +config-version: 1 + +policies: + new-player: + any-of: + - all-of: + - id: first-login + type: LOGIN_DAYS + at-least: 1 +'@ +[System.IO.File]::WriteAllText( + (Join-Path $data 'qualifications.yml'), $qualification, [System.Text.UTF8Encoding]::new($false) +) +Write-Output "已建立合成玩家測試實例:$instancePath" diff --git a/scripts/test-servers/synthetic-player/flow.cjs b/scripts/test-servers/synthetic-player/flow.cjs new file mode 100644 index 0000000..cfbf9ad --- /dev/null +++ b/scripts/test-servers/synthetic-player/flow.cjs @@ -0,0 +1,170 @@ +const fs = require('node:fs') +const path = require('node:path') +const crypto = require('node:crypto') +const { spawn, spawnSync } = require('node:child_process') +const mineflayer = require('mineflayer') + +const 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']) +if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || + !metadata.instance.startsWith('issue12-') || !supportedProfiles.has(metadata.profile) || + !metadata.eulaAccepted) { + throw new Error('Expected a prepared, EULA-accepted, isolated InviteCode synthetic-player instance') +} + +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') +if (!/default: en_US/.test(config) || !/use-client-locale: false/.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') +} +if (fs.existsSync(path.join(dataDirectory, 'invitecode.db')) || + fs.existsSync(path.join(dataDirectory, 'anti-abuse.key'))) { + throw new Error('Synthetic-player flow requires a fresh instance with no existing player data') +} +const properties = fs.readFileSync(path.join(instancePath, 'server.properties'), 'utf8') +if (!/^server-ip=127\.0\.0\.1\s*$/m.test(properties) || + !/^online-mode=false\s*$/m.test(properties) || + !properties.includes(`server-port=${metadata.port}`)) { + throw new Error('Synthetic-player server must use its expected loopback port and offline test mode') +} +function sha256(file) { + return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex').toUpperCase() +} +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') +} + +const mise = process.env.MISE_EXE || 'mise' +let fatalError +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) +async function until(check, description, timeoutMs = 30000) { + const deadline = Date.now() + timeoutMs + while (Date.now() < deadline) { + if (fatalError) throw fatalError + const result = check() + if (result) return result + await delay(100) + } + throw new Error(`Timed out waiting for ${description}`) +} + +async function startServer() { + const child = spawn(mise, [ + 'exec', `java@${metadata.javaAlias}`, '--', 'java', '-Dfile.encoding=UTF-8', + '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui' + ], { cwd: instancePath, stdio: ['pipe', 'pipe', 'pipe'] }) + const state = { child, output: '' } + child.on('error', error => { fatalError = error }) + for (const stream of [child.stdout, child.stderr]) { + stream.setEncoding('utf8') + stream.on('data', chunk => { + state.output += chunk + for (const line of chunk.split(/\r?\n/)) { + if (/InviteCode|Reward backlog|ERROR|Exception|Stopping server/.test(line)) { + process.stdout.write(`SERVER ${line}\n`) + } + } + }) + } + 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) + return state +} + +async function stopServer(state) { + if (!state || state.child.exitCode !== null) return + state.child.stdin.write('stop\n') + try { + await until(() => state.child.exitCode !== null, 'server stop', 30000) + } catch (error) { + if (process.platform === 'win32' && state.child.pid) { + spawnSync('taskkill', ['/PID', String(state.child.pid), '/T', '/F'], { stdio: 'ignore' }) + } else { + state.child.kill() + } + throw error + } +} + +async function createBot(name) { + const bot = mineflayer.createBot({ + host: '127.0.0.1', port: metadata.port, username: name, + auth: 'offline', version: metadata.minecraftVersion + }) + const messages = [] + bot.on('messagestr', message => { + messages.push(message) + process.stdout.write(`${name}: ${message}\n`) + }) + bot.on('error', error => { + 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}`) }) + 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 } +} + +async function command(player, input, expected) { + const start = player.messages.length + player.bot.chat(input) + return until(() => player.messages.slice(start).map(message => message.match(expected)).find(Boolean), `${input}: ${expected}`) +} + +async function doctor(state, expected) { + const start = state.output.length + state.child.stdin.write('ic admin doctor\n') + await until(() => expected.test(state.output.slice(start)), `doctor ${expected}`) +} + +let server +let inviter +let invitee +async function main() { + try { + server = await startServer() + inviter = await createBot('IcTestA') + const code = (await command(inviter, '/ic code', /Your Invite Code is ([A-F0-9]{6})/))[1] + inviter.bot.quit() + inviter = null + await delay(500) + invitee = await createBot('IcTestB') + await command(invitee, `/ic claim ${code}`, /Inviter: IcTestA; Invite Code:/) + 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') + await doctor(server, /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + invitee.bot.quit() + invitee = null + await stopServer(server) + server = await startServer() + await doctor(server, /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + inviter = await createBot('IcTestA') + 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({ + result: 'PASS', profile: metadata.profile, minecraftVersion: metadata.minecraftVersion, + instance: metadata.instance, pluginSha256: metadata.pluginSha256, + checks: ['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 (server) await stopServer(server) + } +} + +main().catch(error => { console.error(error); process.exitCode = 1 }) diff --git a/scripts/test-servers/synthetic-player/package-lock.json b/scripts/test-servers/synthetic-player/package-lock.json new file mode 100644 index 0000000..f67d139 --- /dev/null +++ b/scripts/test-servers/synthetic-player/package-lock.json @@ -0,0 +1,1039 @@ +{ + "name": "invitecode-synthetic-player-smoke", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "invitecode-synthetic-player-smoke", + "version": "1.0.0", + "devDependencies": { + "mineflayer": "4.39.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.16.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.1.tgz", + "integrity": "sha512-nyxsA6NA4SVKh5YyRpbSXiMr7oQbwark7JU9LMeg6tJYTSPyAGkdx61wPT4gyxZfxlSxMMEyAsWaubBlNyIa1w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.3.tgz", + "integrity": "sha512-CO+SE4weOsfJf+C5LM8argzvotrXw252/ZU6SM2Tz63fEblhH1uuVaaO4ISYFuN4Q6BhTo7I3qIdi8ydUQCqhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.16.1", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.2.tgz", + "integrity": "sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@types/node-rsa": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/node-rsa/-/node-rsa-1.1.4.tgz", + "integrity": "sha512-dB0ECel6JpMnq5ULvpUTunx3yNm8e/dIkv8Zu9p2c8me70xIRUUG3q+qXRwcSf9rN3oqamv4116iHy90dJGRpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.24", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.24.tgz", + "integrity": "sha512-NRvUNC/JFGPJvqdAfEve8oginbM6V08u5NzLWpG8MwA2kTPOLnqk+wpwuPT+mp3aUsxyuT6m2gnrPuHYCruzEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-5.1.0.tgz", + "integrity": "sha512-UngHHsehZbiTjyyNmo8HvdoUDKMID1U9uVfrpFWUK/2UxPuVTKy5n+CzZQ3S488sW5vOhgh0lHqqynT8ouwgvw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "dev": true, + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "dev": true, + "license": "MIT" + }, + "node_modules/macaddress": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.4.tgz", + "integrity": "sha512-i8xVWoUjj2woYU8kbpQby86Kq7uF7xl2brtKREXUBWpfgqx1fKXEeYzDiVMVxA/IufC1d3xxwJRHtFCX+9IspA==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-data": { + "version": "3.117.0", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.117.0.tgz", + "integrity": "sha512-glKv0EEmVwKvJwdNAKAal2P7gi/nijU9rEMp8gJmqYYRVswS6hA0q9566lcGHH07Ocmpqw5bMRbARC25pR13gA==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.68.0", + "resolved": "https://registry.npmjs.org/minecraft-protocol/-/minecraft-protocol-1.68.0.tgz", + "integrity": "sha512-atAGg/fhIVqyK6voWvED5QA+4ah65PNwpoDnkHawWhVzQbwFii77KcF6OpsU/Xlbi0o9GpihHiPdORSxXEA+Ug==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@types/node-rsa": "^1.1.4", + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.merge": "^4.3.0", + "minecraft-data": "^3.109.0", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^3.1.1", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.17.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/mineflayer": { + "version": "4.39.0", + "resolved": "https://registry.npmjs.org/mineflayer/-/mineflayer-4.39.0.tgz", + "integrity": "sha512-HptE++dIG55aRmT7GIj3QComS6MhEXstE3RJSuYMFhLtobsQhJJsqWmY9ObfiLp84MrS6Q4Em+wUH0rVQMXLJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.114.0", + "minecraft-protocol": "^1.67.0", + "mojangson": "^2.0.4", + "prismarine-biome": "^1.1.1", + "prismarine-block": "^1.22.0", + "prismarine-chat": "^1.7.1", + "prismarine-chunk": "^1.41.0", + "prismarine-entity": "^2.5.0", + "prismarine-item": "^1.17.0", + "prismarine-nbt": "^2.0.0", + "prismarine-physics": "^1.11.1", + "prismarine-recipe": "^1.5.0", + "prismarine-registry": "^1.10.0", + "prismarine-windows": "^2.9.0", + "prismarine-world": "^3.6.0", + "protodef": "^1.18.0", + "typed-emitter": "^1.0.0", + "uuid-1345": "^1.0.2", + "vec3": "^0.1.7" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/mojangson": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.1.0.tgz", + "integrity": "sha512-uz0PPHAc/kRO5tBOmEZIWxLlne3NRqO2PRyvIXbU0523tItgpvt0XG83IFZgH21EaKY1/B9c9ca074/eZlI59Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.3.tgz", + "integrity": "sha512-m2fmM2dDm7GZQsY7KK2cme8agi+AAljILjQnof7p1ZMDe6dQ4bdnSMx0cPppudoeNv5hEFQirN6u+O4fDE0IWA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "dev": true, + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-3.1.1.tgz", + "integrity": "sha512-NuNrMGZdoigFKsvi1ZZgAEvNYNuE5qe6lo/tw+bqeNbkhpjHC0u1JNxLEujnfqduXI18e19PvUtWNMDl/gH7yw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^5.1.0", + "debug": "^4.3.3", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-biome": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prismarine-biome/-/prismarine-biome-1.4.0.tgz", + "integrity": "sha512-fD2WmjN8Zr/xA/jeMInReLgaDlznwA5xlaK529PzWuGzgjpc5ijVu1Lp1oqHyZn3WxOG/bRVtW1bU+tmgCurWA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prismarine-registry": "^1.1.0" + } + }, + "node_modules/prismarine-block": { + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/prismarine-block/-/prismarine-block-1.23.0.tgz", + "integrity": "sha512-j2UoU4KbXMvNlBw+aLkMOnEuMayYefznUfbrfv1VIbckG3RA9LpNWltOMHXuOR5YkHp8uIZPOclj95XC88jgGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.38.0", + "prismarine-biome": "^1.1.0", + "prismarine-chat": "^1.5.0", + "prismarine-item": "^1.10.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.1.0" + } + }, + "node_modules/prismarine-chat": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.13.0.tgz", + "integrity": "sha512-tvDbrQmJEoy09yLE5nnedGhQYxnRDaPRePMv7W39dFaHr2LGcA2JfCmH0vG5193+BsEFz3a5+0EpQSK8OW7YmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.2", + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-chunk": { + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/prismarine-chunk/-/prismarine-chunk-1.41.0.tgz", + "integrity": "sha512-KldSl3pDzPU7jcttxSYWNJ40rJMdiUxYvTpqXzqiQ3lIdNL1HAuJHPdscHcqlKJRB9Hw/cbFcROR1h5ncavY+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-biome": "^1.2.0", + "prismarine-block": "^1.14.1", + "prismarine-nbt": "^2.2.1", + "prismarine-registry": "^1.1.0", + "smart-buffer": "^4.1.0", + "uint4": "^0.1.2", + "vec3": "^0.1.3", + "xxhash-wasm": "^0.4.2" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/prismarine-entity": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/prismarine-entity/-/prismarine-entity-2.6.0.tgz", + "integrity": "sha512-/LlZRLOpACiXk+GqoaKi0XPBFnNMjb1d4OIzuSCSEgNMK6FUo3Wnin5yeSZ7ff3Ztt7yagN9lX2jSOafn6IIzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-chat": "^1.4.1", + "prismarine-item": "^1.11.2", + "prismarine-registry": "^1.4.0", + "vec3": "^0.1.4" + } + }, + "node_modules/prismarine-item": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/prismarine-item/-/prismarine-item-1.18.0.tgz", + "integrity": "sha512-8pEq6YfcneVvarvUFnex09a3+MR8/4NCQVyawIKAa3kh/g9dHLexoEcpQEgM3cmpg4gbLmspSiARGwed5uGhlg==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.8.0.tgz", + "integrity": "sha512-5D6FUZq0PNtf3v/41ImDlwThVesOv5adyqCRMZLzmkUGEmRJNNh5C6AsnvrClBftXs+IF0yqPnZoj8kcNPiMGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "protodef": "^1.18.0" + } + }, + "node_modules/prismarine-physics": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/prismarine-physics/-/prismarine-physics-1.11.1.tgz", + "integrity": "sha512-GO9Pqqg5Khs0YxvPqRXYi3Ep3/OoxnL3RtfMknrgddY0ogpT91bTna6HDTQXVeBinfCB3WU9vXaFoTND/3xqyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0", + "vec3": "^0.2.0" + } + }, + "node_modules/prismarine-physics/node_modules/vec3": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/vec3/-/vec3-0.2.0.tgz", + "integrity": "sha512-jOjU4zbCNWOKOGLHop1I0J2Ar4h5Zz76455LJhJKhiOJwI21QP6d5TnKklNZDKG+c5h71zWtPAbd9wh+Va57OQ==", + "dev": true, + "license": "BSD" + }, + "node_modules/prismarine-realms": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.6.0.tgz", + "integrity": "sha512-AwemW0vwxG9hQaFtg1twSV7eymB6QtYxGK0jjpxfdA2sdK15kU8jh8uD1o5XF0oxSMU+BbpzZMCmXtXq4QE6bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-recipe": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/prismarine-recipe/-/prismarine-recipe-1.5.0.tgz", + "integrity": "sha512-GRZHbsyBIUgVNF10vFRv2YWZj86vokCT5EWX6iK6gfx6h4FapgZT29V2DNkjv5+hmdzBCLZvfx1/RYr8VPeoGQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-registry": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.12.0.tgz", + "integrity": "sha512-OC5U6YrflY6OcAWRZEqe2HGZuNp0bIuP7H+oKEHD6rLfKNDxo8Ymx5eh2VvrZWnMVugpwID1Qj/UjA4MoCzNDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.70.0", + "prismarine-block": "^1.17.1", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/prismarine-windows": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/prismarine-windows/-/prismarine-windows-2.10.0.tgz", + "integrity": "sha512-ssXLGAr7W9JLvvLjYMoo1j4j6AdJaoIb0/HlqkWMWlQqvZJeiS4zyBjJY6+GtR4OzpjkEf6IvF5cNXhHFpbcZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-item": "^1.12.2", + "prismarine-registry": "^1.7.0", + "typed-emitter": "^2.1.0" + } + }, + "node_modules/prismarine-windows/node_modules/typed-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", + "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "rxjs": "*" + } + }, + "node_modules/prismarine-world": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/prismarine-world/-/prismarine-world-3.7.0.tgz", + "integrity": "sha512-M5euvNjQ3vIk689BSa0YC6PBwpVY35Oc6q6KyZ0IqyFtI+cQ9em+8l5OTAK/uu9/gzDDhR7cmm9L2WXgTXBQCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "vec3": "^0.1.7" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.19.0.tgz", + "integrity": "sha512-94f3GR7pk4Qi5YVLaLvWBfTGUIzzO8hyo7vFVICQuu5f5nwKtgGDaeC1uXIu49s5to/49QQhEYeL0aigu1jEGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^4.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.5.0.tgz", + "integrity": "sha512-GrPKsNpcd7/4bIAZN3Ojgk5ILsRX9s1IItzU+o29D1o0AKbIaLuBCmaSGbZE90Gn8zxF2/Vj8aPUHjo0AbgFdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "dev": true, + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/typed-emitter": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-1.4.0.tgz", + "integrity": "sha512-weBmoo3HhpKGgLBOYwe8EB31CzDFuaK7CCL+axXhUYhn4jo6DSkHnbefboCF5i4DQ2aMFe0C/FdTWcPdObgHyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/uint4": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/uint4/-/uint4-0.1.2.tgz", + "integrity": "sha512-lhEx78gdTwFWG+mt6cWAZD/R6qrIj0TTBeH5xwyuDJyswLNlGe+KVlUPQ6+mx5Ld332pS0AMUTo9hIly7YsWxQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/uuid": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/vec3": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/vec3/-/vec3-0.1.10.tgz", + "integrity": "sha512-Sr1U3mYtMqCOonGd3LAN9iqy0qF6C+Gjil92awyK/i2OwiUo9bm7PnLgFpafymun50mOjnDcg4ToTgRssrlTcw==", + "dev": true, + "license": "BSD" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/xxhash-wasm": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz", + "integrity": "sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA==", + "dev": true, + "license": "MIT" + }, + "node_modules/yggdrasil": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.8.0.tgz", + "integrity": "sha512-r5bKOhkZ52DJ6q034uSkdsdZLoFVhOmfDOagRs6h/JX5W7+XIPOMb+peCbElhLEoIckwt43NCUoNQbydOzuPcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^10.0.0" + } + } + } +} diff --git a/scripts/test-servers/synthetic-player/package.json b/scripts/test-servers/synthetic-player/package.json new file mode 100644 index 0000000..a029a3c --- /dev/null +++ b/scripts/test-servers/synthetic-player/package.json @@ -0,0 +1,12 @@ +{ + "name": "invitecode-synthetic-player-smoke", + "private": true, + "version": "1.0.0", + "description": "Test-only Minecraft clients for InviteCode release-gate smoke", + "devDependencies": { + "mineflayer": "4.39.0" + }, + "overrides": { + "uuid": "11.1.1" + } +} From a0529cba5ebe1f4f2700725e1b6f41bbdb776e5e Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 04:40:44 +0800 Subject: [PATCH 06/12] test: verify interrupted reward recovery on Spigot --- .../2026-09-24-issue-12-startup-matrix.md | 17 +- docs/testing/test-servers.md | 16 ++ .../test-servers/prepare-synthetic-player.ps1 | 33 +++ .../fault-plugin/FaultPlugin.java | 41 ++++ .../synthetic-player/fault-plugin/plugin.yml | 6 + .../synthetic-player/uncertain.cjs | 197 ++++++++++++++++++ 6 files changed, 308 insertions(+), 2 deletions(-) create mode 100644 scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java create mode 100644 scripts/test-servers/synthetic-player/fault-plugin/plugin.yml create mode 100644 scripts/test-servers/synthetic-player/uncertain.cjs 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 30a1bc3..e62d2cd 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 @@ -52,10 +52,23 @@ Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實 | Paper 1.20.6 | `issue12-fixture-paper-1206` | 通過;Mineflayer/protodef 在登入時另有非致命封包解析警告 | | Paper 1.21.8 | `issue12-fixture-paper-1218` | 通過 | -每次流程由 A 執行 `/ic code` 後離線,B 執行 `/ic claim `、`/ic confirm`,收到 Invitation 已建立及 Qualification Reward 訊息。Console doctor 回報 `PENDING=1, PROCESSING=0, UNCERTAIN=0`;正常關機並重啟後仍為 `PENDING=1`。A 再登入收到離線補發訊息,doctor 變為 `PENDING=0`,`/ic stats` 顯示 `qualified=1`。以上驗證真實伺服器的玩家指令與訊息路徑,尚未測試伺服器在外部 Reward effect 期間非正常終止。Paper 1.20.6 的封包警告出自測試客戶端 `protodef`,伺服器端沒有 InviteCode error;該版本的其他客戶端封包相容性不能由此次流程推定。 +每次流程由 A 執行 `/ic code` 後離線,B 執行 `/ic claim `、`/ic confirm`,收到 Invitation 已建立及 Qualification Reward 訊息。Console doctor 回報 `PENDING=1, PROCESSING=0, UNCERTAIN=0`;正常關機並重啟後仍為 `PENDING=1`。A 再登入收到離線補發訊息,doctor 變為 `PENDING=0`,`/ic stats` 顯示 `qualified=1`。以上驗證真實伺服器的玩家指令與訊息路徑;外部效果期間的非正常終止另見下節。Paper 1.20.6 的封包警告出自測試客戶端 `protodef`,伺服器端沒有 InviteCode error;該版本的其他客戶端封包相容性不能由此次流程推定。 + +## Reward 中斷與管理員決定 + +相同插件 JAR 在 Spigot 1.8.8、Java 8 的兩個全新隔離實例執行測試專用 `CONSOLE_COMMAND` Reward。`InviteCodeFaultProbe` 先 `fsync` 自己的效果進入標記,再以 exit code 83 強制中止 JVM;這是明確注入的預期故障,客戶端同時產生 `ECONNRESET`。重啟時 InviteCode log 均回報復原 1 筆 Action,Console doctor 為 `PENDING=1, PROCESSING=0, UNCERTAIN=1`,`admin inspect reward` 顯示 `status=UNCERTAIN`。Invitee 再登入後,標記仍只有 1 筆,證明此測試 Action 沒有被自動重做。 + +| 實例 | 管理員決定 | 結果 | +| --- | --- | --- | +| `issue12-uncertain-mark4-188` | `admin reward mark-delivered isolated-test` | Action 轉為 `DELIVERED`,標記仍 1 筆,doctor 的 `UNCERTAIN=0`;再次重啟後狀態與標記不變,通過 | +| `issue12-uncertain-retry2-188` | `admin reward retry isolated-test` | 收件者在線時,Action 再執行一次並轉為 `DELIVERED`,標記成 2 筆;再次重啟後狀態與標記不變,通過 | + +UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透過公開管理指令。兩實例測完均正常停止重啟後的伺服器,測試用 JVM 中斷沒有影響正式資料。測試演練刻意讓外部效果與最後狀態保存之間斷開;不證明 Vault、其他插件或非同步命令效果可 exactly-once。 + +[Mineflayer 官方文件](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)目前列出的支援版本到 26.1;本地 Mineflayer 4.39.0 對 `26.2` 直接回報 `unsupported protocol version: 26.2`。因此不能用它宣稱 Paper 26.2 玩家流程已通過;目前只有該版本的啟動、Console 與儲存 smoke 證據。待官方協定資料支援或有可靠的獨立測試客戶端後再補玩家流程,最後再做一次真人觀感驗收。 [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、Vault/PlaceholderAPI 實際功能、外部效果期間的 Reward `UNCERTAIN` 與伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、Vault/PlaceholderAPI 實際功能、伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index e6faa20..107b51c 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -102,6 +102,22 @@ node .\scripts\test-servers\synthetic-player\flow.cjs ` `-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 限定 Spigot 1.8.8、Paper 1.20.6 與 1.21.8;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋聊天/Dialog 輸入、Vault 金額、最新 Paper 26.2 或中斷於外部效果期間的 `UNCERTAIN` 復原。 +### 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' +$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 +``` + +`mark-delivered` 與 `retry` 各使用不同的新實例,勿重用上例的 `$name`;`MISE_EXE` 指向當前電腦實際安裝的 mise 執行檔。Runner 會檢查 loopback、EULA、JAR SHA-256 與全新資料庫,並只停止自己啟動的伺服器。第一次故障造成測試客戶端 `ECONNRESET` 是預期現象。重啟後 `UNCERTAIN=1`、重新登入不重發;`mark-delivered` 後標記仍只有一次,`retry` 後才增加至兩次並轉為 `DELIVERED`。這是隔離演練,不代表能證明外部系統中的所有實際效果。 + ## 自動檢查與最終真人驗收 日常開發與各功能階段先由 Agent 執行不需要玩家判斷的檢查,包括 Gradle 測試、JAR 結構與 Java 8 bytecode、伺服器啟動與正常停機、log 錯誤掃描、UTF-8 解碼、SQLite/防濫用密鑰初始化,以及適用時的重啟持久化。這些結果須綁定受測 commit 與 JAR SHA-256。 diff --git a/scripts/test-servers/prepare-synthetic-player.ps1 b/scripts/test-servers/prepare-synthetic-player.ps1 index d521f40..0dbe902 100644 --- a/scripts/test-servers/prepare-synthetic-player.ps1 +++ b/scripts/test-servers/prepare-synthetic-player.ps1 @@ -6,6 +6,7 @@ param( [Parameter(Mandatory = $true)][string] $Instance, [Parameter(Mandatory = $true)][string] $Artifact, [switch] $AcceptEula, + [switch] $RewardInterruption, [AllowNull()][string] $TestLabRoot ) @@ -16,6 +17,9 @@ $ErrorActionPreference = 'Stop' if ($Instance -cnotmatch '^issue12-[a-zA-Z0-9-]{1,72}$') { throw '合成玩家測試需要新的 issue12-* TestLab 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 @@ -50,4 +54,33 @@ policies: [System.IO.File]::WriteAllText( (Join-Path $data 'qualifications.yml'), $qualification, [System.Text.UTF8Encoding]::new($false) ) +if ($RewardInterruption) { + $rewards = @' +config-version: 1 + +qualification-rewards: + default: + inviter: + - type: MESSAGE + message: invite.qualified.inviter + invitee: + - type: CONSOLE_COMMAND + command: icfault + +milestone-rewards: {} +'@ + [System.IO.File]::WriteAllText( + (Join-Path $data 'rewards.yml'), $rewards, [System.Text.UTF8Encoding]::new($false) + ) + $faultSource = Join-Path $PSScriptRoot 'synthetic-player\fault-plugin' + $classes = Join-Path $instancePath 'fault-plugin-classes' + $faultJar = Join-Path $instancePath 'plugins\InviteCodeFaultProbe.jar' + New-Item -ItemType Directory -Path $classes -Force | Out-Null + & mise exec java@local-8 -- javac -source 8 -target 8 -cp (Join-Path $instancePath 'server.jar') ` + -d $classes (Join-Path $faultSource 'FaultPlugin.java') + if ($LASTEXITCODE -ne 0) { throw '測試專用 fault plugin 編譯失敗。' } + Copy-Item -LiteralPath (Join-Path $faultSource 'plugin.yml') -Destination (Join-Path $classes 'plugin.yml') + & mise exec java@local-8 -- jar cf $faultJar -C $classes . + if ($LASTEXITCODE -ne 0) { throw '測試專用 fault plugin 封裝失敗。' } +} Write-Output "已建立合成玩家測試實例:$instancePath" diff --git a/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java b/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java new file mode 100644 index 0000000..3941ed8 --- /dev/null +++ b/scripts/test-servers/synthetic-player/fault-plugin/FaultPlugin.java @@ -0,0 +1,41 @@ +package io.github.command1264.invitecode.test; + +import java.io.File; +import java.io.FileOutputStream; +import java.nio.charset.StandardCharsets; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + +/** Test-only external effect that terminates its isolated server before the caller can commit success. */ +public final class FaultPlugin extends JavaPlugin { + private boolean armed; + + @Override + public void onEnable() { + File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); + armed = 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."); + } + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!armed || !sender.equals(getServer().getConsoleSender()) || args.length != 0) return false; + getDataFolder().mkdirs(); + File marker = new File(getDataFolder(), "effect-entered.log"); + boolean repeated = marker.isFile() && marker.length() > 0; + try (FileOutputStream output = new FileOutputStream(marker, true)) { + output.write("effect-entered\n".getBytes(StandardCharsets.US_ASCII)); + output.getFD().sync(); + } catch (Exception error) { + throw new IllegalStateException("Cannot persist fault-injection marker", error); + } + if (!repeated) Runtime.getRuntime().halt(83); + return true; + } +} diff --git a/scripts/test-servers/synthetic-player/fault-plugin/plugin.yml b/scripts/test-servers/synthetic-player/fault-plugin/plugin.yml new file mode 100644 index 0000000..f1fc648 --- /dev/null +++ b/scripts/test-servers/synthetic-player/fault-plugin/plugin.yml @@ -0,0 +1,6 @@ +name: InviteCodeFaultProbe +version: 1.0.0 +main: io.github.command1264.invitecode.test.FaultPlugin +commands: + icfault: + description: Test-only abrupt termination after a durable marker. diff --git a/scripts/test-servers/synthetic-player/uncertain.cjs b/scripts/test-servers/synthetic-player/uncertain.cjs new file mode 100644 index 0000000..d7a18c8 --- /dev/null +++ b/scripts/test-servers/synthetic-player/uncertain.cjs @@ -0,0 +1,197 @@ +const fs = require('node:fs') +const path = require('node:path') +const crypto = require('node:crypto') +const { spawn, spawnSync } = require('node:child_process') +const mineflayer = require('mineflayer') + +const instancePath = path.resolve(process.argv[2] || '') +const resolution = process.argv[3] +if (!['mark-delivered', 'retry'].includes(resolution)) { + throw new Error('Usage: node uncertain.cjs ') +} +const metadata = JSON.parse(fs.readFileSync(path.join(instancePath, 'workspace.json'), 'utf8')) +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' || + !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}`) || + !rewardConfig.includes('command: icfault') || + !fs.existsSync(path.join(instancePath, 'plugins', 'InviteCodeFaultProbe.jar')) || + fs.existsSync(marker) || fs.existsSync(path.join(dataDirectory, 'invitecode.db'))) { + throw new Error('Expected a fresh, EULA-accepted, loopback-only reward-interruption instance') +} +function sha256(file) { + return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex').toUpperCase() +} +if (sha256(path.join(instancePath, 'server.jar')) !== metadata.serverSha256 || + sha256(path.join(instancePath, 'plugins', metadata.pluginFile)) !== metadata.pluginSha256) { + throw new Error('Server or InviteCode JAR differs from workspace.json') +} + +const mise = process.env.MISE_EXE || 'mise' +let expectedCrash = false +let clientError +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) +async function until(check, description, timeoutMs = 30000) { + const end = Date.now() + timeoutMs + while (Date.now() < end) { + if (clientError) throw clientError + const result = check() + if (result) return result + await delay(100) + } + throw new Error(`Timed out waiting for ${description}`) +} +function startServer() { + const child = spawn(mise, [ + 'exec', `java@${metadata.javaAlias}`, '--', 'java', '-Dfile.encoding=UTF-8', + '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui' + ], { cwd: instancePath, stdio: ['pipe', 'pipe', 'pipe'] }) + const state = { child, output: '' } + child.on('error', error => { state.error = error }) + for (const stream of [child.stdout, child.stderr]) { + stream.setEncoding('utf8') + stream.on('data', chunk => { + state.output += chunk + for (const line of chunk.split(/\r?\n/)) { + if (/InviteCode|FaultProbe|Reward backlog|RewardAction|ERROR|Exception/.test(line)) { + process.stdout.write(`SERVER ${line}\n`) + } + } + }) + } + return state +} +async function ready(state) { + await until(() => { + if (state.error) throw state.error + if (state.child.exitCode !== null) throw new Error(`Server exited before ready: ${state.child.exitCode}`) + return /InviteCode \S+ 已啟用/.test(state.output) && /Done \(/.test(state.output) + }, 'InviteCode active', 100000) +} +async function stop(state) { + if (!state || state.child.exitCode !== null) return + state.child.stdin.write('stop\n') + try { + await until(() => state.child.exitCode !== null, 'server stop', 30000) + } catch (error) { + if (process.platform === 'win32' && state.child.pid) { + spawnSync('taskkill', ['/PID', String(state.child.pid), '/T', '/F'], { stdio: 'ignore' }) + } else { + state.child.kill() + } + throw error + } +} +async function bot(name) { + const client = mineflayer.createBot({ + host: '127.0.0.1', port: metadata.port, username: name, + auth: 'offline', version: metadata.minecraftVersion + }) + const messages = [] + client.on('messagestr', message => { messages.push(message); process.stdout.write(`${name}: ${message}\n`) }) + client.on('error', error => { + if (expectedCrash && error.code === 'ECONNRESET') return + clientError = error + }) + await new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error(`${name} spawn timeout`)), 30000) + client.once('spawn', () => { clearTimeout(timer); resolve() }) + client.once('end', reason => { clearTimeout(timer); reject(new Error(`${name} ended before spawn: ${reason}`)) }) + }) + return { client, messages } +} +async function playerCommand(player, input, expected) { + const start = player.messages.length + player.client.chat(input) + return until(() => player.messages.slice(start).map(message => message.match(expected)).find(Boolean), input) +} +async function consoleCommand(state, input, expected) { + const start = state.output.length + state.child.stdin.write(`${input}\n`) + return until(() => state.output.slice(start).match(expected), input) +} +function markerCount() { + return fs.existsSync(marker) ? fs.readFileSync(marker, 'ascii').trim().split('\n').length : 0 +} +function actionId() { + const db = path.join(dataDirectory, 'invitecode.db') + if (!fs.existsSync(db)) throw new Error('SQLite database is missing') + const query = [ + 'import sqlite3,sys', + 'con=sqlite3.connect(sys.argv[1])', + "rows=con.execute(\"SELECT action_id FROM invitecode_reward_actions WHERE action_type='CONSOLE_COMMAND'\").fetchall()", + 'assert len(rows)==1, rows', + 'print(rows[0][0])' + ].join(';') + const result = spawnSync('py', ['-3', '-c', query, db], { encoding: 'utf8' }) + if (result.status !== 0) throw new Error(`Cannot discover test Reward Action: ${result.stderr}`) + return result.stdout.trim() +} + +let server +let inviter +let invitee +async function main() { + try { + server = startServer() + await ready(server) + inviter = await bot('IcFaultA') + const code = (await playerCommand(inviter, '/ic code', /Your Invite Code is ([A-F0-9]{6})/))[1] + inviter.client.quit() + inviter = null + await delay(500) + invitee = await bot('IcFaultB') + await playerCommand(invitee, `/ic claim ${code}`, /Inviter: IcFaultA; Invite Code:/) + expectedCrash = true + invitee.client.chat('/ic confirm') + await until(() => server.child.exitCode !== null, 'deliberate JVM halt', 30000) + if (server.child.exitCode !== 83 || markerCount() !== 1) { + throw new Error(`Fault probe did not create exactly one effect and halt with 83: exit=${server.child.exitCode}, marker=${markerCount()}`) + } + invitee = null + expectedCrash = false + server = startServer() + await ready(server) + await consoleCommand(server, 'ic admin doctor', /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=1/) + const id = actionId() + await consoleCommand(server, `ic admin inspect reward ${id}`, new RegExp(`RewardAction=${id} .*status=UNCERTAIN`)) + invitee = await bot('IcFaultB') + await delay(1000) + if (markerCount() !== 1) throw new Error('UNCERTAIN Action was automatically replayed on login') + await consoleCommand(server, `ic admin reward ${resolution} ${id} isolated-test`, + new RegExp(`Reward Action ${id} was resolved as ${resolution === 'retry' ? 'PENDING' : 'DELIVERED'}`)) + if (resolution === 'retry') { + await until(() => markerCount() === 2, 'explicit administrator retry') + await consoleCommand(server, `ic admin inspect reward ${id}`, new RegExp(`RewardAction=${id} .*status=DELIVERED`)) + } else if (markerCount() !== 1) { + throw new Error('MARK_DELIVERED unexpectedly repeated external effect') + } + await consoleCommand(server, 'ic admin doctor', /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + invitee.client.quit() + invitee = null + await stop(server) + server = startServer() + await ready(server) + await consoleCommand(server, `ic admin inspect reward ${id}`, new RegExp(`RewardAction=${id} .*status=DELIVERED`)) + await consoleCommand(server, 'ic admin doctor', /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + if (markerCount() !== (resolution === 'retry' ? 2 : 1)) { + throw new Error('Administrator resolution did not remain stable after restart') + } + process.stdout.write(JSON.stringify({ + result: 'PASS', scenario: 'reward-interruption', resolution, instance: metadata.instance, + profile: metadata.profile, pluginSha256: metadata.pluginSha256, markerCount: markerCount(), + checks: ['effect-entered', 'abrupt-halt', 'restart-recovery', 'no-automatic-retry', 'admin-resolution', 'resolution-after-restart'] + }) + '\n') + } finally { + if (inviter) inviter.client.quit() + if (invitee) invitee.client.quit() + if (server) await stop(server) + } +} +main().catch(error => { console.error(error); process.exitCode = 1 }) From 34809bdaa88bafb972af0dd50318774100ff3d27 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 05:05:45 +0800 Subject: [PATCH 07/12] test: verify Vault rewards and Placeholder qualification --- docs/configuration/qualifications.md | 2 + .../2026-09-24-issue-12-startup-matrix.md | 15 +- docs/testing/test-servers.md | 24 +++ .../prepare-integration-player.ps1 | 89 ++++++++ .../integration-probe/PapiProbePlugin.java | 59 +++++ .../integration-probe/VaultProbePlugin.java | 41 ++++ .../integration-probe/papi-plugin.yml | 8 + .../integration-probe/vault-plugin.yml | 8 + .../synthetic-player/integration.cjs | 201 ++++++++++++++++++ 9 files changed, 445 insertions(+), 2 deletions(-) create mode 100644 scripts/test-servers/prepare-integration-player.ps1 create mode 100644 scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java create mode 100644 scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java create mode 100644 scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml create mode 100644 scripts/test-servers/synthetic-player/integration-probe/vault-plugin.yml create mode 100644 scripts/test-servers/synthetic-player/integration.cjs diff --git a/docs/configuration/qualifications.md b/docs/configuration/qualifications.md index 22ddbf6..e91bb4b 100644 --- a/docs/configuration/qualifications.md +++ b/docs/configuration/qualifications.md @@ -32,6 +32,8 @@ policies: 時間接受 `ms`、`s`、`m`、`h`、`d` 簡寫或 ISO-8601 Duration,例如 `30m`、`1d`、`PT2H`。Placeholder operator 支援 `EQUALS`、`NOT_EQUALS`、`CONTAINS`、`GREATER_THAN`、`GREATER_THAN_OR_EQUAL`、`LESS_THAN` 與 `LESS_THAN_OR_EQUAL`;大小比較要求實際值與設定值都是數字。 +比較文字 `yes`、`no`、`on`、`off` 時,請將 `value` 寫成帶引號的字串,例如 `value: "yes"`。YAML 解析器可能把未加引號的寫法當成布林值,導致與 PlaceholderAPI 回傳的文字不相等。 + Permission、Placeholder 或外部 provider 不存在時,condition 預設產生 `UNKNOWN`。可明確設定安全的退回行為: ```yaml 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 e62d2cd..b1618f5 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 @@ -26,7 +26,18 @@ | PlaceholderAPI 存在 | `issue12-papi-paper-1206`,Paper 1.20.6、PlaceholderAPI 2.12.3;外掛 JAR SHA-256 `FDE03259F5AF6938F3C33EEB4D814000A1ADABF1D2304CE14970BE81F609A437` | 首次啟動與重啟均 `PlaceholderAPI=true`、`Vault Economy=false`;SQLite DB 與 key 雜湊不變 | | Vault Economy 存在 | `issue12-vault-212-paper-1218`,Paper 1.21.8、Vault 1.7.3-b131、EssentialsX 2.21.2;兩個 JAR SHA-256 分別為 `A6B5ED97F43A5CF5BBAF00A7C8CD23C5AFC9BD003F849875AF8B36E6CF77D01D`、`0B759026F02F3C547C32886F3666DB3C1F94CFF73E141AE5648313FD0D0BDFC6` | 首次啟動與重啟均 `Vault Economy=true`、`PlaceholderAPI=false`;Vault log 顯示 Essentials Economy hooked;SQLite DB 與 key 雜湊不變 | -也在 Paper 26.2 與 1.21.8 試過 EssentialsX 2.22.0:doctor 可偵測 Vault Economy,但 EssentialsX 自行警告該伺服器版本不受支援,因此不把它當作乾淨的正向驗證。以上只確認外掛載入與 InviteCode 的服務偵測;尚未驗證實際 placeholder 展開、Vault 金額變化或發獎。 +也在 Paper 26.2 與 1.21.8 試過 EssentialsX 2.22.0:doctor 可偵測 Vault Economy,但 EssentialsX 自行警告該伺服器版本不受支援,因此不把它當作乾淨的正向驗證。上表只確認外掛載入與 InviteCode 的服務偵測;實際效果另見下節。 + +### 合成玩家功能整合 + +使用相同 InviteCode JAR 與前述已驗證的第三方 JAR,另外建立全新 SQLite TestLab 實例。測試專用 Vault probe 透過註冊的 Vault `Economy` 服務唯讀查詢餘額;測試專用 PlaceholderAPI expansion 回傳玩家專屬 `no`/`yes`,由 Console 指令切換。Probe JAR 不屬於產品產物。 + +| 情境 | 實例與版本 | 可觀察結果 | +| --- | --- | --- | +| Vault 實際存款 | `issue12-vault-flow4-1218`,Paper 1.21.8/Vault 1.7.3-b131/EssentialsX 2.21.2 | Invitee 餘額 `0 → 37.5`,Invitation 已達資格;重啟並再次登入後餘額仍為 `37.5`,Reward backlog `PENDING=1, PROCESSING=0, UNCERTAIN=0`;通過 | +| PlaceholderAPI 實際資格 | `issue12-papi-flow5-1206`,Paper 1.20.6/PlaceholderAPI 2.12.3 | `%icprobe_ready%` 為 `no` 時 Invitation 待資格;切為 `yes` 後重新登入變成已達資格並收到 Invitee Reward,重啟後仍已達資格;通過 | + +Vault 的 `PENDING=1` 是離線 Inviter 的預設 `MESSAGE` Reward,並非存款卡住。Placeholder 的 `value` 須寫為 `"yes"`;首次試跑用未加引號的 `yes` 被 YAML 當作布林值,因而與 PlaceholderAPI 回傳文字不符,改成字串後通過。Paper 1.20.6 的 Mineflayer/protodef 仍出現既知非致命封包解析警告,伺服器端沒有對應的 InviteCode exception。兩個較早實例在玩家離線後立刻停機時出現 Paper 區塊生成執行緒錯誤,堆疊未涉及 InviteCode;測試器在首次停機前等待 10 秒後,新建的上述兩個實例沒有再出現此錯誤。這只能說明目前測試流程較穩定,不能斷定 Paper 錯誤的根因。此驗證覆蓋一個 Vault provider 與一個受控 Placeholder expansion,不代表所有第三方 provider 都相容。 ## 復原測試的現況 @@ -71,4 +82,4 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、Vault/PlaceholderAPI 實際功能、伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 107b51c..291bbb5 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -118,6 +118,30 @@ node .\scripts\test-servers\synthetic-player\uncertain.cjs ` `mark-delivered` 與 `retry` 各使用不同的新實例,勿重用上例的 `$name`;`MISE_EXE` 指向當前電腦實際安裝的 mise 執行檔。Runner 會檢查 loopback、EULA、JAR SHA-256 與全新資料庫,並只停止自己啟動的伺服器。第一次故障造成測試客戶端 `ECONNRESET` 是預期現象。重啟後 `UNCERTAIN=1`、重新登入不重發;`mark-delivered` 後標記仍只有一次,`retry` 後才增加至兩次並轉為 `DELIVERED`。這是隔離演練,不代表能證明外部系統中的所有實際效果。 +### 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。 + +```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' +$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 +node .\scripts\test-servers\synthetic-player\integration.cjs ` + 'D:\Code\Java\Plugin\TestLab\instances\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 +node .\scripts\test-servers\synthetic-player\integration.cjs ` + 'D:\Code\Java\Plugin\TestLab\instances\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 分開判讀。再次執行須改用新實例名稱。 + ## 自動檢查與最終真人驗收 日常開發與各功能階段先由 Agent 執行不需要玩家判斷的檢查,包括 Gradle 測試、JAR 結構與 Java 8 bytecode、伺服器啟動與正常停機、log 錯誤掃描、UTF-8 解碼、SQLite/防濫用密鑰初始化,以及適用時的重啟持久化。這些結果須綁定受測 commit 與 JAR SHA-256。 diff --git a/scripts/test-servers/prepare-integration-player.ps1 b/scripts/test-servers/prepare-integration-player.ps1 new file mode 100644 index 0000000..4d6a9d1 --- /dev/null +++ b/scripts/test-servers/prepare-integration-player.ps1 @@ -0,0 +1,89 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)][ValidateSet('Vault', 'Placeholder')][string] $Scenario, + [Parameter(Mandatory = $true)][string] $Instance, + [Parameter(Mandatory = $true)][string] $Artifact, + [Parameter(Mandatory = $true)][string] $SpigotApiJar, + [AllowNull()][string] $VaultJar, + [AllowNull()][string] $EconomyJar, + [AllowNull()][string] $PlaceholderApiJar, + [AllowNull()][string] $TestLabRoot, + [switch] $AcceptEula +) + +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' } +$required = if ($Scenario -ceq 'Vault') { @($SpigotApiJar, $VaultJar, $EconomyJar) } ` + else { @($SpigotApiJar, $PlaceholderApiJar) } +foreach ($candidate in $required) { + if ([string]::IsNullOrWhiteSpace($candidate) -or -not (Test-Path -LiteralPath $candidate -PathType Leaf)) { + throw "缺少測試依賴 JAR:$candidate" + } +} +$lab = Resolve-PluginTestLabRoot -ExplicitRoot $TestLabRoot +& (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 +$plugins = Join-Path $instancePath 'plugins' +$data = Join-Path $plugins 'InviteCode' +$probe = Join-Path $PSScriptRoot 'synthetic-player\integration-probe' +$classes = Join-Path $instancePath 'integration-probe-classes' +New-Item -ItemType Directory -Path $classes -Force | Out-Null + +if ($Scenario -ceq 'Vault') { + Copy-Item -LiteralPath $VaultJar -Destination (Join-Path $plugins 'Vault.jar') + Copy-Item -LiteralPath $EconomyJar -Destination (Join-Path $plugins 'EssentialsX.jar') + $classpath = "$SpigotApiJar;$VaultJar" + $source = Join-Path $probe 'VaultProbePlugin.java' + $descriptor = Join-Path $probe 'vault-plugin.yml' + $probeJar = Join-Path $plugins 'InviteCodeVaultProbe.jar' + $rewards = @' +config-version: 1 + +qualification-rewards: + default: + inviter: + - type: MESSAGE + message: invite.qualified.inviter + invitee: + - type: VAULT_ECONOMY + amount: 37.5 + +milestone-rewards: {} +'@ + [System.IO.File]::WriteAllText( + (Join-Path $data 'rewards.yml'), $rewards, [System.Text.UTF8Encoding]::new($false) + ) +} else { + Copy-Item -LiteralPath $PlaceholderApiJar -Destination (Join-Path $plugins 'PlaceholderAPI.jar') + $classpath = "$SpigotApiJar;$PlaceholderApiJar" + $source = Join-Path $probe 'PapiProbePlugin.java' + $descriptor = Join-Path $probe 'papi-plugin.yml' + $probeJar = Join-Path $plugins 'InviteCodePapiProbe.jar' + $qualification = @' +config-version: 1 + +policies: + new-player: + any-of: + - all-of: + - id: external-ready + type: PLACEHOLDER + placeholder: "%icprobe_ready%" + operator: EQUALS + value: "yes" +'@ + [System.IO.File]::WriteAllText( + (Join-Path $data 'qualifications.yml'), $qualification, [System.Text.UTF8Encoding]::new($false) + ) +} +& mise exec java@local-21 -- javac --release 8 -cp $classpath -d $classes $source +if ($LASTEXITCODE -ne 0) { throw 'Integration probe 編譯失敗。' } +Copy-Item -LiteralPath $descriptor -Destination (Join-Path $classes 'plugin.yml') +& mise exec java@local-21 -- jar cf $probeJar -C $classes . +if ($LASTEXITCODE -ne 0) { throw 'Integration probe 封裝失敗。' } +Write-Output "已建立 $Scenario 合成玩家測試實例:$instancePath" diff --git a/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java b/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java new file mode 100644 index 0000000..de53b54 --- /dev/null +++ b/scripts/test-servers/synthetic-player/integration-probe/PapiProbePlugin.java @@ -0,0 +1,59 @@ +package io.github.command1264.invitecode.test; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import me.clip.placeholderapi.PlaceholderAPI; +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.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<>(); + private boolean armed; + + @Override + public void onEnable() { + File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); + armed = 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."); + return; + } + if (!new ProbeExpansion().register()) throw new IllegalStateException("Cannot register icprobe expansion"); + } + + @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) { + sender.sendMessage("ICPROBE player-offline " + args[1]); + return true; + } + ready.add(player.getUniqueId()); + sender.sendMessage("ICPROBE ready " + args[1] + " " + + PlaceholderAPI.setPlaceholders(player, "%icprobe_ready%")); + return true; + } + + private final class ProbeExpansion extends PlaceholderExpansion { + @Override public String getIdentifier() { return "icprobe"; } + @Override public String getAuthor() { return "InviteCodeTest"; } + @Override public String getVersion() { return "1.0.0"; } + @Override public boolean persist() { return true; } + @Override public String onRequest(OfflinePlayer player, String identifier) { + if (!"ready".equals(identifier) || player == null) return null; + return ready.contains(player.getUniqueId()) ? "yes" : "no"; + } + } +} diff --git a/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java b/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java new file mode 100644 index 0000000..0f72e32 --- /dev/null +++ b/scripts/test-servers/synthetic-player/integration-probe/VaultProbePlugin.java @@ -0,0 +1,41 @@ +package io.github.command1264.invitecode.test; + +import java.io.File; +import java.math.BigDecimal; +import net.milkbowl.vault.economy.Economy; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.java.JavaPlugin; + +/** Test-only, read-only observation of the registered Vault Economy provider. */ +public final class VaultProbePlugin extends JavaPlugin { + private boolean armed; + + @Override + public void onEnable() { + File instance = getDataFolder().getAbsoluteFile().getParentFile().getParentFile(); + armed = 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."); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!armed || !sender.equals(getServer().getConsoleSender()) || args.length != 1) return false; + RegisteredServiceProvider registration = getServer().getServicesManager() + .getRegistration(Economy.class); + if (registration == null) { + sender.sendMessage("ICBALANCE unavailable"); + return true; + } + OfflinePlayer player = getServer().getOfflinePlayer(args[0]); + double balance = registration.getProvider().getBalance(player); + sender.sendMessage("ICBALANCE " + args[0] + " " + + BigDecimal.valueOf(balance).stripTrailingZeros().toPlainString()); + return true; + } +} diff --git a/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml b/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml new file mode 100644 index 0000000..3ba098b --- /dev/null +++ b/scripts/test-servers/synthetic-player/integration-probe/papi-plugin.yml @@ -0,0 +1,8 @@ +name: InviteCodePapiProbe +version: 1.0.0 +api-version: '1.13' +main: io.github.command1264.invitecode.test.PapiProbePlugin +depend: [PlaceholderAPI] +commands: + icprobe: + description: Test-only PlaceholderAPI value toggle. diff --git a/scripts/test-servers/synthetic-player/integration-probe/vault-plugin.yml b/scripts/test-servers/synthetic-player/integration-probe/vault-plugin.yml new file mode 100644 index 0000000..ad76c0c --- /dev/null +++ b/scripts/test-servers/synthetic-player/integration-probe/vault-plugin.yml @@ -0,0 +1,8 @@ +name: InviteCodeVaultProbe +version: 1.0.0 +api-version: '1.13' +main: io.github.command1264.invitecode.test.VaultProbePlugin +softdepend: [Vault, Essentials] +commands: + icbalance: + description: Test-only read-only Vault Economy balance query. diff --git a/scripts/test-servers/synthetic-player/integration.cjs b/scripts/test-servers/synthetic-player/integration.cjs new file mode 100644 index 0000000..eee7355 --- /dev/null +++ b/scripts/test-servers/synthetic-player/integration.cjs @@ -0,0 +1,201 @@ +const fs = require('node:fs') +const path = require('node:path') +const crypto = require('node:crypto') +const { spawn, spawnSync } = require('node:child_process') +const mineflayer = require('mineflayer') + +const instancePath = path.resolve(process.argv[2] || '') +const scenario = process.argv[3] +if (!['Vault', 'Placeholder'].includes(scenario)) { + 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' +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 || + !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}`) || + requiredJars.some(name => !fs.existsSync(path.join(pluginDirectory, name))) || + fs.existsSync(path.join(dataDirectory, 'invitecode.db')) || + fs.existsSync(path.join(dataDirectory, 'anti-abuse.key'))) { + throw new Error('Expected a fresh, EULA-accepted, loopback-only integration instance') +} +const qualification = fs.readFileSync(path.join(dataDirectory, 'qualifications.yml'), 'utf8') +const rewards = scenario === 'Vault' + ? fs.readFileSync(path.join(dataDirectory, 'rewards.yml'), 'utf8') : '' +if (scenario === 'Vault' ? !rewards.includes('amount: 37.5') + : !qualification.includes('placeholder: "%icprobe_ready%"')) { + throw new Error('Integration fixture configuration does not match the requested scenario') +} +function sha256(file) { + return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex').toUpperCase() +} +if (sha256(path.join(instancePath, 'server.jar')) !== metadata.serverSha256 || + sha256(path.join(pluginDirectory, metadata.pluginFile)) !== metadata.pluginSha256) { + throw new Error('Server or InviteCode JAR differs from workspace.json') +} + +const mise = process.env.MISE_EXE || 'mise' +let clientError +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) +async function until(check, description, timeoutMs = 30000) { + const end = Date.now() + timeoutMs + while (Date.now() < end) { + if (clientError) throw clientError + const result = check() + if (result) return result + await delay(100) + } + throw new Error(`Timed out waiting for ${description}`) +} +function startServer() { + const child = spawn(mise, [ + 'exec', `java@${metadata.javaAlias}`, '--', 'java', '-Dfile.encoding=UTF-8', + '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui' + ], { cwd: instancePath, stdio: ['pipe', 'pipe', 'pipe'] }) + const state = { child, output: '' } + child.on('error', error => { state.error = error }) + for (const stream of [child.stdout, child.stderr]) { + stream.setEncoding('utf8') + stream.on('data', chunk => { + state.output += chunk + for (const line of chunk.split(/\r?\n/)) { + if (/InviteCode|ICBALANCE|ICPROBE|Reward backlog|ERROR|Exception|Economy hooked|Successfully registered internal expansion/.test(line)) { + process.stdout.write(`SERVER ${line}\n`) + } + } + }) + } + return state +} +async function ready(state) { + await until(() => { + if (state.error) throw state.error + if (state.child.exitCode !== null) throw new Error(`Server exited before ready: ${state.child.exitCode}`) + return /InviteCode \S+ 已啟用/.test(state.output) && /Done \(/.test(state.output) + }, 'InviteCode active', 100000) +} +async function stop(state) { + if (!state || state.child.exitCode !== null) return + state.child.stdin.write('stop\n') + try { + await until(() => state.child.exitCode !== null, 'server stop', 30000) + } catch (error) { + if (process.platform === 'win32' && state.child.pid) { + spawnSync('taskkill', ['/PID', String(state.child.pid), '/T', '/F'], { stdio: 'ignore' }) + } else { + state.child.kill() + } + throw error + } +} +async function bot(name) { + const client = mineflayer.createBot({ + host: '127.0.0.1', port: metadata.port, username: name, + auth: 'offline', version: metadata.minecraftVersion + }) + const messages = [] + client.on('messagestr', message => { messages.push(message); process.stdout.write(`${name}: ${message}\n`) }) + client.on('error', error => { + if (error.name === 'PartialReadError') { + process.stderr.write(`${name} protocol warning: ${error.message}\n`) + } else clientError = error + }) + await new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error(`${name} spawn timeout`)), 30000) + client.once('spawn', () => { clearTimeout(timer); resolve() }) + client.once('end', reason => { clearTimeout(timer); reject(new Error(`${name} ended before spawn: ${reason}`)) }) + }) + return { client, messages } +} +async function playerCommand(player, input, expected) { + const start = player.messages.length + player.client.chat(input) + return until(() => player.messages.slice(start).map(message => message.match(expected)).find(Boolean), input) +} +async function consoleCommand(state, input, expected) { + const start = state.output.length + state.child.stdin.write(`${input}\n`) + return until(() => state.output.slice(start).match(expected), input) +} +async function balance(state, name, expected) { + const deadline = Date.now() + 30000 + while (Date.now() < deadline) { + const match = await consoleCommand(state, `icbalance ${name}`, /ICBALANCE IcVaultB ([0-9.]+)/) + if (Number(match[1]) === expected) return + await delay(250) + } + throw new Error(`Vault balance for ${name} did not reach ${expected}`) +} + +let server +let inviter +let invitee +async function main() { + try { + server = startServer() + await ready(server) + await consoleCommand(server, 'ic admin doctor', scenario === 'Vault' + ? /Integrations: PlaceholderAPI=false, Vault Economy=true/ + : /Integrations: PlaceholderAPI=true, Vault Economy=false/) + const inviterName = scenario === 'Vault' ? 'IcVaultA' : 'IcPapiA' + const inviteeName = scenario === 'Vault' ? 'IcVaultB' : 'IcPapiB' + inviter = await bot(inviterName) + const code = (await playerCommand(inviter, '/ic code', /Your Invite Code is ([A-F0-9]{6})/))[1] + inviter.client.quit() + inviter = null + await delay(500) + invitee = await bot(inviteeName) + if (scenario === 'Vault') { + await balance(server, inviteeName, 0) + } + await playerCommand(invitee, `/ic claim ${code}`, new RegExp(`Inviter: ${inviterName}; Invite Code:`)) + await playerCommand(invitee, '/ic confirm', /The Invitation has been created\./) + if (scenario === 'Vault') { + await balance(server, inviteeName, 37.5) + } else { + await playerCommand(invitee, '/ic status', /Invitation=awaiting qualification/) + await consoleCommand(server, `icprobe ready ${inviteeName}`, /ICPROBE ready IcPapiB yes/) + invitee.client.quit() + invitee = null + await delay(500) + invitee = await bot(inviteeName) + await playerCommand(invitee, '/ic status', /Invitation=qualified/) + await until(() => invitee.messages.some(message => message.includes('You have qualified as an invitee.')), + 'Placeholder Qualification Reward') + } + await consoleCommand(server, 'ic admin doctor', /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + invitee.client.quit() + invitee = null + await delay(10000) + await stop(server) + server = startServer() + await ready(server) + invitee = await bot(inviteeName) + await playerCommand(invitee, '/ic status', /Invitation=qualified/) + if (scenario === 'Vault') { + await balance(server, inviteeName, 37.5) + } + await consoleCommand(server, 'ic admin doctor', /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) + process.stdout.write(JSON.stringify({ + result: 'PASS', scenario, instance: metadata.instance, profile: metadata.profile, + pluginSha256: metadata.pluginSha256, + checks: scenario === 'Vault' + ? ['balance-before-0', 'qualification', 'vault-deposit-37.5', 'balance-after-restart-37.5'] + : ['placeholder-unsatisfied', 'placeholder-ready', 'qualified-after-rejoin', 'qualified-after-restart'] + }) + '\n') + } finally { + if (inviter) inviter.client.quit() + if (invitee) invitee.client.quit() + if (server) await stop(server) + } +} +main().catch(error => { console.error(error); process.exitCode = 1 }) From 7f2f7adb5797379003265357b7169e9710d718a3 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 05:21:40 +0800 Subject: [PATCH 08/12] test: verify SQLite migration recovery on Spigot --- .../2026-09-24-issue-12-startup-matrix.md | 10 +- docs/testing/test-servers.md | 16 ++ .../synthetic-player/migration-recovery.cjs | 170 ++++++++++++++++++ 3 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 scripts/test-servers/synthetic-player/migration-recovery.cjs 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 b1618f5..6a7e1f7 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 @@ -82,4 +82,12 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、伺服器層級 migration 故障復原、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 +本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、MySQL 初始化中斷續建的伺服器層級證據、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 + +## 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 由測試程式建造,**不是**舊版外掛實際產生的資料庫,也不代表曾有正式使用者需要遷移。 + +第一次重啟時,Console doctor 回報 `Runtime=MAINTENANCE`、schema 7 不符,未自動遷移。第二次重啟後,Console `ic admin storage migrate SQLITE injected-index-conflict` 回報遷移失敗,log 的根因是 `index invitecode_network_hash_expiry already exists`。停機後直接核對:版本仍為 7、v8 新表不存在、原索引與哨兵資料存在,`PRAGMA integrity_check=ok`,`anti-abuse.key` SHA-256 未變;證明這次 SQLite 交易中的前一步建表已回滾。預期的錯誤只出現在注入故障階段。 + +停機移除測試索引後,第三次啟動仍在維護模式;Console 明確遷移成功至 v8,doctor 轉為 `Runtime=ACTIVE`。第四次啟動直接進入 `ACTIVE`,版本 8、新表及正確索引存在,哨兵資料、密鑰與 integrity check 均保持正常。Runner 回報 `PASS`;加入 TestLab 路徑與固定埠檢查後,使用另一個全新 `issue12-migration-rollback2-188` 實例複驗也回報 `PASS`。所有伺服器均由 runner 正常關閉,51888 埠已釋放。此測試涵蓋 SQLite 的伺服器層級安全拒絕、失敗回滾與明確復原;尚未涵蓋在遷移交易進行中強制終止 JVM,亦未涵蓋 MySQL DDL 中斷續建。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 291bbb5..266d10f 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -118,6 +118,22 @@ node .\scripts\test-servers\synthetic-player\uncertain.cjs ` `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 會直接修改**自己的隔離資料庫**,不得指向正式伺服器或既有實例。 + +```powershell +$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-fixture-spigot-188\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$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" +``` + +上例只適用於已接受 Minecraft EULA 的本機 TestLab。每次執行須換用尚不存在的新實例名稱,受測 JAR 的雜湊須與 `workspace.json` 相同。此測試驗證 SQLite 在伺服器層級的遷移回滾與復原,不涵蓋 MySQL DDL 中斷續建或正式資料搬移。 + ### 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。 diff --git a/scripts/test-servers/synthetic-player/migration-recovery.cjs b/scripts/test-servers/synthetic-player/migration-recovery.cjs new file mode 100644 index 0000000..21c3b05 --- /dev/null +++ b/scripts/test-servers/synthetic-player/migration-recovery.cjs @@ -0,0 +1,170 @@ +const fs = require('node:fs') +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 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) || + !/^online-mode=false\s*$/m.test(properties) || + !properties.includes(`server-port=${metadata.port}`) || + fs.existsSync(dbPath) || fs.existsSync(keyPath)) { + throw new Error('Expected a fresh, EULA-accepted, loopback-only Spigot test instance') +} +const hash = file => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex').toUpperCase() +if (hash(path.join(instancePath, 'server.jar')) !== metadata.serverSha256 || + hash(path.join(instancePath, 'plugins', metadata.pluginFile)) !== metadata.pluginSha256) { + throw new Error('Server or plugin JAR differs from workspace.json') +} + +const fixture = ` +import sqlite3, sys +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 + with con: + con.execute('DROP TABLE invitecode_player_network_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')) + # This valid index name makes v8 fail after CREATE TABLE, testing transactional DDL rollback. + con.execute('CREATE INDEX invitecode_network_hash_expiry ON invitecode_players(first_seen_at)') + elif mode == 'repair': + 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 + 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() + index = con.execute("SELECT tbl_name FROM sqlite_master WHERE type='index' AND name='invitecode_network_hash_expiry'").fetchone() + if expected == 7: + assert table is None and index == ('invitecode_players',), (table, index) + else: + assert table == (1,) and index == ('invitecode_player_network_hashes',), (table, index) + assert con.execute('PRAGMA integrity_check').fetchone() == ('ok',) + else: + raise ValueError(mode) +finally: + con.close() +` +function sqlite(mode) { + const result = spawnSync('py', ['-3', '-c', fixture, mode, dbPath], { encoding: 'utf8' }) + if (result.status !== 0) throw new Error(`SQLite fixture ${mode} failed: ${result.stderr}`) +} +const mise = process.env.MISE_EXE || 'mise' +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) +async function until(check, what, timeout = 100000) { + const end = Date.now() + timeout + while (Date.now() < end) { + const result = check() + if (result) return result + await delay(100) + } + throw new Error(`Timed out: ${what}`) +} +function start() { + const child = spawn(mise, ['exec', `java@${metadata.javaAlias}`, '--', 'java', + '-Dfile.encoding=UTF-8', '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui'], + { cwd: instancePath, stdio: ['pipe', 'pipe', 'pipe'] }) + const server = { child, output: '' } + child.on('error', error => { server.error = error }) + for (const stream of [child.stdout, child.stderr]) { + stream.setEncoding('utf8') + stream.on('data', text => { + server.output += text + for (const line of text.split(/\r?\n/)) { + if (/InviteCode|Runtime=|儲存|migration|Exception|ERROR/.test(line)) process.stdout.write(`SERVER ${line}\n`) + } + }) + } + return server +} +async function ready(server, phase) { + await until(() => { + if (server.error) throw server.error + if (server.child.exitCode !== null) throw new Error(`Server exited early: ${server.child.exitCode}`) + return /Done \(/.test(server.output) && + (phase === 'ACTIVE' ? /InviteCode \S+ 已啟用/.test(server.output) : /已進入維護模式/.test(server.output)) + }, `server ${phase}`) +} +async function command(server, input, expected) { + const offset = server.output.length + server.child.stdin.write(`${input}\n`) + return until(() => server.output.slice(offset).match(expected), input, 30000) +} +async function stop(server) { + if (!server || server.child.exitCode !== null) return + server.child.stdin.write('stop\n') + try { + await until(() => server.child.exitCode !== null, 'server stop', 30000) + if (server.child.exitCode !== 0) throw new Error(`Server exit: ${server.child.exitCode}`) + } catch (error) { + if (server.child.exitCode === null) { + if (process.platform === 'win32') spawnSync('taskkill', ['/PID', String(server.child.pid), '/T', '/F'], { stdio: 'ignore' }) + else server.child.kill() + } + throw error + } +} +let server +async function main() { + try { + server = start() + await ready(server, 'ACTIVE') + await stop(server) + const keyHash = hash(keyPath) + sqlite('downgrade') + sqlite('assert-old') + + server = start() + await ready(server, 'MAINTENANCE') + await command(server, 'ic admin doctor', /Runtime=MAINTENANCE/) + await stop(server) + sqlite('assert-old') + if (hash(keyPath) !== keyHash) throw new Error('Network secret changed during rejected startup') + + server = start() + await ready(server, 'MAINTENANCE') + await command(server, 'ic admin storage migrate SQLITE injected-index-conflict', /Storage schema migration 失敗/) + await command(server, 'ic admin doctor', /Runtime=MAINTENANCE/) + await stop(server) + sqlite('assert-old') + if (hash(keyPath) !== keyHash) throw new Error('Network secret changed after failed migration') + + 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 doctor', /Runtime=ACTIVE/) + await stop(server) + sqlite('assert-current') + + server = start() + await ready(server, 'ACTIVE') + await command(server, 'ic admin doctor', /Runtime=ACTIVE/) + await stop(server) + sqlite('assert-current') + if (hash(keyPath) !== keyHash) throw new Error('Network secret changed after recovery') + process.stdout.write(JSON.stringify({ result: 'PASS', scenario: 'sqlite-migration-recovery', + instance: metadata.instance, profile: metadata.profile, pluginSha256: metadata.pluginSha256, + checks: ['no-auto-upgrade', 'maintenance', 'ddl-rollback', 'sentinel-preserved', + 'explicit-recovery', 'restart-durable', 'secret-preserved'] }) + '\n') + } finally { + if (server) await stop(server) + } +} +main().catch(error => { console.error(error); process.exitCode = 1 }) From 059f49a84c18dec0a71a4693080bd632f018f4ca Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 05:34:46 +0800 Subject: [PATCH 09/12] test: verify MySQL initialization recovery on Paper --- .../2026-09-24-issue-12-startup-matrix.md | 16 +- docs/testing/test-servers.md | 18 ++ .../mysql-migration-recovery.cjs | 215 ++++++++++++++++++ 3 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs 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 6a7e1f7..b736d27 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 @@ -47,9 +47,9 @@ Vault 的 `PENDING=1` 是離線 Inviter 的預設 `MESSAGE` Reward,並非存 從 [Oracle 官方 MySQL 下載來源](https://dev.mysql.com/downloads/mysql/)取得 Windows ZIP,使用的 `mysql-8.4.11-winx64.zip` SHA-256 為 `A492371D687D2BAB088B0062581144A0044B8964BAEFDF4FAA579292B423D25C`。ZIP 解壓與資料目錄都在 TestLab 的 `artifacts/invitecode-issue12-mysql-8.4.11/`,與 `C:\Program Files\MySQL` 的既有資料完全分離。`mysqld --version` 為 8.4.11;服務只綁定 `127.0.0.1:63384`,使用隨機測試密碼、獨立 `invitecode_issue12` database 和專用 `invitecode_test` 帳號。測試密碼與 network secret 以目前 Windows 使用者的加密 CLIXML 暫存於該隔離 runtime,未寫入 repository、設定範本或 log。測試設定採 `tls-mode: REQUIRED`,因此未驗證正式預設的 `VERIFY_IDENTITY` 憑證身分檢查。 -在此服務上強制重跑 `mise exec -- .\gradlew.bat :invitecode-storage-sql:test :invitecode-plugin:test --rerun-tasks --no-daemon`:storage SQL 51 個、plugin 17 個測試,皆無失敗或略過。測試所建的隨機 database 都已清理,除 MySQL 系統資料庫外只剩本次 `invitecode_issue12`。 +在此服務上強制重跑 `mise exec -- .\gradlew.bat :invitecode-storage-sql:test :invitecode-plugin:test --rerun-tasks --no-daemon`:storage SQL 51 個、plugin 17 個測試,皆無失敗或略過。當時測試所建的隨機 database 都已清理,除 MySQL 系統資料庫外只剩 `invitecode_issue12`;後續另保留兩個專用的中斷復原測試 database,見下文。 -`issue12-mysql-paper-1206` 使用 Paper 1.20.6 build 151 與同一份受測插件 JAR,`storage.yml` 指向上述隔離服務。首次啟動回報 `Runtime=ACTIVE`、`MYSQL 儲存版本=1`、自動初始化;從 Console 執行 `ic admin doctor`、`ic help`、`ic reload` 均成功。正常停機後資料庫有 13 張表、migration ledger `version=1,state=APPLIED`、初始化稽核紀錄 1 筆。以相同密碼與 network secret 重啟後仍為 `ACTIVE`,上述表數、ledger 與稽核筆數維持不變;插件資料夾沒有產生本機 `anti-abuse.key`。兩次 Paper log 沒有 InviteCode error/exception。測試後以 `mysqladmin shutdown` 關閉本次 MySQL 服務,63384 與 Paper 的 62060 埠都已釋放。此項驗證首次建表與再開啟,尚未涵蓋真實玩家 Claim 或 MySQL 的伺服器層級中斷復原。 +`issue12-mysql-paper-1206` 使用 Paper 1.20.6 build 151 與同一份受測插件 JAR,`storage.yml` 指向上述隔離服務。首次啟動回報 `Runtime=ACTIVE`、`MYSQL 儲存版本=1`、自動初始化;從 Console 執行 `ic admin doctor`、`ic help`、`ic reload` 均成功。正常停機後資料庫有 13 張表、migration ledger `version=1,state=APPLIED`、初始化稽核紀錄 1 筆。以相同密碼與 network secret 重啟後仍為 `ACTIVE`,上述表數、ledger 與稽核筆數維持不變;插件資料夾沒有產生本機 `anti-abuse.key`。兩次 Paper log 沒有 InviteCode error/exception。測試後以 `mysqladmin shutdown` 關閉本次 MySQL 服務,63384 與 Paper 的 62060 埠都已釋放。此項驗證首次建表與再開啟,尚未涵蓋真實玩家 Claim;合成中斷狀態的伺服器層級續建另見下節。 Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實例;`ACTIVE`、Console 指令、本機儲存檔與 key 檢查均通過,確認新增 MYSQL 分支沒有破壞原本兩種 backend 的 smoke 路徑。 @@ -82,8 +82,6 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 -本輪對 Spigot/Paper 涵蓋啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console help/reload/doctor、外部服務偵測,並在三個版本通過合成玩家 Claim 與離線 `MESSAGE` Reward 補發。另在 Spigot 1.8.8 通過外部指令中斷後的 `UNCERTAIN` 復原及兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款。Issue #12 尚缺最新 Paper 26.2 的玩家 critical path、MySQL 初始化中斷續建的伺服器層級證據、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 - ## 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 由測試程式建造,**不是**舊版外掛實際產生的資料庫,也不代表曾有正式使用者需要遷移。 @@ -91,3 +89,13 @@ Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數 第一次重啟時,Console doctor 回報 `Runtime=MAINTENANCE`、schema 7 不符,未自動遷移。第二次重啟後,Console `ic admin storage migrate SQLITE injected-index-conflict` 回報遷移失敗,log 的根因是 `index invitecode_network_hash_expiry already exists`。停機後直接核對:版本仍為 7、v8 新表不存在、原索引與哨兵資料存在,`PRAGMA integrity_check=ok`,`anti-abuse.key` SHA-256 未變;證明這次 SQLite 交易中的前一步建表已回滾。預期的錯誤只出現在注入故障階段。 停機移除測試索引後,第三次啟動仍在維護模式;Console 明確遷移成功至 v8,doctor 轉為 `Runtime=ACTIVE`。第四次啟動直接進入 `ACTIVE`,版本 8、新表及正確索引存在,哨兵資料、密鑰與 integrity check 均保持正常。Runner 回報 `PASS`;加入 TestLab 路徑與固定埠檢查後,使用另一個全新 `issue12-migration-rollback2-188` 實例複驗也回報 `PASS`。所有伺服器均由 runner 正常關閉,51888 埠已釋放。此測試涵蓋 SQLite 的伺服器層級安全拒絕、失敗回滾與明確復原;尚未涵蓋在遷移交易進行中強制終止 JVM,亦未涵蓋 MySQL DDL 中斷續建。 + +## MySQL 初始化中斷狀態的安全續建 + +新增 `mysql-migration-recovery.cjs`,使用全新 `issue12-mysql-recover1-1206`、`issue12-mysql-recover2-1206` 實例,以及各自命名的新 MySQL database。Paper 1.20.6 build 151、`local-21`、MySQL 8.4.11 與同一份產品 JAR(SHA-256 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`)。測試器從受測 JAR 讀取 schema 與 checksum,在全新 database 建立 `APPLYING` ledger、已提交的 `invitecode_players` 表及 `MigrationSentinel` 玩家;它模擬首次建表剛完成一張表後中斷,不會觸碰既有 `invitecode_issue12` database。 + +先將玩家名稱欄位改為 `VARCHAR(32)`:插件啟動後進入 `MAINTENANCE`,只保留 ledger 加玩家表兩張表、`APPLYING` 狀態和哨兵資料。修正回 `VARCHAR(64)` 後把 checksum 改錯:再次啟動仍進維護模式,沒有補建任何表。恢復正確 checksum 後,下一次普通啟動自動核對既有表並補齊至 13 張表;Console doctor 回報 `ACTIVE`,ledger 轉為 `APPLIED`,原哨兵資料與唯一一次初始化稽核保留。再次重啟仍為 `ACTIVE`,表數、ledger、稽核及哨兵資料不變。插件資料夾沒有建立本機 SQLite DB 或 `anti-abuse.key`。兩個獨立實例的 runner 均回報 `PASS`;第二次測試前,測試器已改為從 Paper 子程序環境移除 MySQL root 密碼。預期的兩次維護模式錯誤只出現在注入故障階段。 + +這是**合成的已提交 DDL 中斷狀態**,不是在 MySQL 實際執行 DDL 時殺掉 JVM;它證明產品在該持久化邊界的安全拒絕、續建與重啟持久性,不證明任意時間點的 crash 都能復原。測試採本機 `tls-mode: REQUIRED`,仍未驗證 `VERIFY_IDENTITY`。兩次 Paper 及隔離 MySQL 服務均已正常關閉,62060/63384 埠已釋放;專用 database 保留作為測試證據。 + +目前 Spigot/Paper 的啟動、SQLite/JSON/MySQL 代表性初始化、重啟一致性、Console 指令、外部服務偵測及三個版本的合成玩家 Claim/離線 `MESSAGE` Reward 已有證據。Spigot 1.8.8 通過 Reward 中斷後的 `UNCERTAIN` 復原與兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款;SQLite 與 MySQL 也完成上述伺服器層級遷移復原測試。Issue #12 仍缺最新 Paper 26.2 的玩家 critical path、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 266d10f..d1db177 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -134,6 +134,24 @@ node .\scripts\test-servers\synthetic-player\migration-recovery.cjs ` 上例只適用於已接受 Minecraft EULA 的本機 TestLab。每次執行須換用尚不存在的新實例名稱,受測 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。 + +先啟動 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 作為證據。 + +```powershell +$jar = 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-mysql-paper-1206\plugins\InviteCode-0.1.0-SNAPSHOT.jar' +$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" +``` + +執行上例前須已接受 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。 diff --git a/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs b/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs new file mode 100644 index 0000000..303a500 --- /dev/null +++ b/scripts/test-servers/synthetic-player/mysql-migration-recovery.cjs @@ -0,0 +1,215 @@ +const fs = require('node:fs') +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 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))), + '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' || + metadata.port !== 62060 || !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}`) || + !/^invitecode_issue12_test_[a-z0-9_]{1,35}$/.test(database) || + fs.existsSync(path.join(dataPath, 'storage.yml')) || + 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') +} +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}`) +} +const hash = bytes => crypto.createHash('sha256').update(bytes).digest('hex') +if (hash(fs.readFileSync(jarPath)).toUpperCase() !== metadata.pluginSha256 || + hash(fs.readFileSync(path.join(instancePath, 'server.jar'))).toUpperCase() !== metadata.serverSha256) { + throw new Error('Plugin or server JAR differs from workspace.json') +} +const resource = spawnSync('tar', ['-xOf', jarPath, 'mysql/V1__initial_schema.sql'], { encoding: 'utf8' }) +if (resource.status !== 0 || !resource.stdout.startsWith('-- @table invitecode_players')) { + throw new Error('Cannot read the bundled MySQL schema resource') +} +const checksum = hash(Buffer.from(resource.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(/;$/, '') +const sentinel = '00000000-0000-0000-0000-000000000012' + +function sql(statement) { + const result = spawnSync(mysqlExe, [ + '--host=127.0.0.1', '--port=63384', '--protocol=TCP', '--user=root', + '--batch', '--skip-column-names', '--execute', statement + ], { + encoding: 'utf8', + env: { ...process.env, MYSQL_PWD: process.env.INVITECODE_TEST_MYSQL_ROOT_PASSWORD }, + maxBuffer: 1024 * 1024 + }) + if (result.error || result.status !== 0) { + throw new Error(`Isolated MySQL fixture query failed: ${result.error?.message || result.stderr}`) + } + return result.stdout.trim() +} +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 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}'`) + if (player !== 'MigrationSentinel') throw new Error('Sentinel player was lost') + if (expectedState === 'APPLIED') { + const audits = Number(db("SELECT COUNT(*) FROM invitecode_audit_records WHERE action='STORAGE_MIGRATED'")) + if (audits !== 1) throw new Error(`Expected one initialization audit, got ${audits}`) + } +} + +const mise = process.env.MISE_EXE || 'mise' +const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) +async function until(check, label, timeout = 120000) { + const end = Date.now() + timeout + while (Date.now() < end) { + const result = check() + if (result) return result + await delay(100) + } + throw new Error(`Timed out: ${label}`) +} +function start() { + const serverEnvironment = { ...process.env } + delete serverEnvironment.INVITECODE_TEST_MYSQL_ROOT_PASSWORD + delete serverEnvironment.MYSQL_PWD + const child = spawn(mise, ['exec', `java@${metadata.javaAlias}`, '--', 'java', + '-Dfile.encoding=UTF-8', '-Dsun.stdout.encoding=UTF-8', '-Dsun.stderr.encoding=UTF-8', + '-Xms512M', '-Xmx1G', '-jar', 'server.jar', 'nogui'], + { cwd: instancePath, stdio: ['pipe', 'pipe', 'pipe'], env: serverEnvironment }) + const server = { child, output: '' } + child.on('error', error => { server.error = error }) + for (const stream of [child.stdout, child.stderr]) { + stream.setEncoding('utf8') + stream.on('data', text => { + server.output += text + for (const line of text.split(/\r?\n/)) { + if (/InviteCode|Runtime=|儲存|migration|Exception|ERROR/.test(line)) process.stdout.write(`SERVER ${line}\n`) + } + }) + } + return server +} +async function ready(server, phase) { + await until(() => { + if (server.error) throw server.error + if (server.child.exitCode !== null) throw new Error(`Server exited before ready: ${server.child.exitCode}`) + return /Done \(/.test(server.output) && + (phase === 'ACTIVE' ? /InviteCode \S+ 已啟用/.test(server.output) : /已進入維護模式/.test(server.output)) + }, `Paper ${phase}`) +} +async function command(server, input, expected) { + const offset = server.output.length + server.child.stdin.write(`${input}\n`) + return until(() => server.output.slice(offset).match(expected), input, 30000) +} +async function stop(server) { + if (!server || server.child.exitCode !== null) return + server.child.stdin.write('stop\n') + try { + await until(() => server.child.exitCode !== null, 'Paper stop', 30000) + if (server.child.exitCode !== 0) throw new Error(`Paper exit: ${server.child.exitCode}`) + } catch (error) { + if (server.child.exitCode === null) { + if (process.platform === 'win32') spawnSync('taskkill', ['/PID', String(server.child.pid), '/T', '/F'], { stdio: 'ignore' }) + else server.child.kill() + } + throw error + } +} + +let server +async function main() { + try { + if (sql(`SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name='${database}'`) !== '0') { + throw new Error(`Test database already exists: ${database}`) + } + sql(`CREATE DATABASE ${database} CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci`) + sql(`GRANT ALL PRIVILEGES ON ${database}.* TO 'invitecode_test'@'127.0.0.1'`) + db(`CREATE TABLE invitecode_schema_migrations ( + version INT NOT NULL PRIMARY KEY, + checksum CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + state VARCHAR(16) CHARACTER SET ascii NOT NULL + ) ENGINE=InnoDB`) + db(`INSERT INTO invitecode_schema_migrations(version,checksum,state) VALUES (1,'${checksum}','APPLYING')`) + db(playersDdl) + db(`INSERT INTO invitecode_players(player_id,first_seen_at,last_known_name) VALUES + ('${sentinel}','2026-09-24T00:00:00Z','MigrationSentinel')`) + db('ALTER TABLE invitecode_players MODIFY last_known_name VARCHAR(32) NULL') + state('APPLYING', 2) + + fs.mkdirSync(dataPath, { recursive: true }) + fs.writeFileSync(path.join(dataPath, 'storage.yml'), `config-version: 1 +backend: MYSQL +sqlite: + file: invitecode.db +json: + file: invitecode.json +mysql: + host: 127.0.0.1 + port: 63384 + database: ${database} + username: invitecode_test + password: "\${INVITECODE_DB_PASSWORD}" + network-secret: "\${INVITECODE_NETWORK_SECRET}" + connection-timeout: 5s + tls-mode: REQUIRED +`, 'utf8') + + server = start() + await ready(server, 'MAINTENANCE') + await command(server, 'ic admin doctor', /Runtime=MAINTENANCE/) + await stop(server) + state('APPLYING', 2) + + db('ALTER TABLE invitecode_players MODIFY last_known_name VARCHAR(64) NULL') + db(`UPDATE invitecode_schema_migrations SET checksum='${'0'.repeat(64)}' WHERE version=1`) + server = start() + await ready(server, 'MAINTENANCE') + await command(server, 'ic admin doctor', /Runtime=MAINTENANCE/) + await stop(server) + const badChecksum = db('SELECT checksum FROM invitecode_schema_migrations WHERE version=1') + if (badChecksum !== '0'.repeat(64)) throw new Error('Checksum was unexpectedly changed') + if (Number(sql(`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='${database}'`)) !== 2) { + throw new Error('Checksum mismatch created tables') + } + + db(`UPDATE invitecode_schema_migrations SET checksum='${checksum}' WHERE version=1`) + server = start() + await ready(server, 'ACTIVE') + await command(server, 'ic admin doctor', /Runtime=ACTIVE/) + await stop(server) + state('APPLIED', 13) + + server = start() + await ready(server, 'ACTIVE') + await command(server, 'ic admin doctor', /Runtime=ACTIVE/) + await stop(server) + state('APPLIED', 13) + 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') + } + process.stdout.write(JSON.stringify({ result: 'PASS', scenario: 'mysql-initialization-recovery', + instance: metadata.instance, database, pluginSha256: metadata.pluginSha256, + checks: ['malformed-table-fails-closed', 'checksum-mismatch-fails-closed', + 'applying-ledger-resumes', 'sentinel-preserved', 'applied-ledger-durable', 'no-local-secret'] }) + '\n') + } finally { + if (server) await stop(server) + } +} +main().catch(error => { console.error(error); process.exitCode = 1 }) From 1d9d973ea28438d3f0edef28002c074e69693f3b Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 06:45:40 +0800 Subject: [PATCH 10/12] test: verify Paper 26.2 synthetic player flow --- .gitignore | 1 + .../2026-09-24-issue-12-startup-matrix.md | 7 +- docs/testing/test-servers.md | 19 +- .../test-servers/prepare-synthetic-player.ps1 | 2 +- .../synthetic-player-26-2/package-lock.json | 1051 +++++++++++++++++ .../synthetic-player-26-2/package.json | 9 + .../test-servers/synthetic-player/flow.cjs | 16 +- 7 files changed, 1098 insertions(+), 7 deletions(-) create mode 100644 scripts/test-servers/synthetic-player-26-2/package-lock.json create mode 100644 scripts/test-servers/synthetic-player-26-2/package.json diff --git a/.gitignore b/.gitignore index e113f1f..96aec93 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ out/ *.db-wal .env scripts/test-servers/synthetic-player/node_modules/ +scripts/test-servers/synthetic-player-26-2/node_modules/ 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 b736d27..26be7e3 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 @@ -55,13 +55,14 @@ Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實 ## 合成玩家 Claim 與離線 Reward -測試專用 Mineflayer 4.39.0 fixture 使用固定 `package-lock.json`,`npm ci --ignore-scripts` 成功、`npm audit` 回報 0 個已知漏洞。它從正式玩家指令與 Console doctor 觀察結果,使用相同插件 JAR SHA-256 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`,每個版本各建立全新 SQLite TestLab 實例。測試設定限定英文指令訊息、`COMMAND_ONLY`、同 IP `ALLOW` 與 `LOGIN_DAYS at-least: 1`;本輪驗證的是預設 `MESSAGE` Reward,而非 Vault 發錢。 +測試專用官方 Mineflayer 4.39.0 fixture 使用固定 `package-lock.json`,`npm ci --ignore-scripts` 成功、當時 `npm audit` 回報 0 個已知漏洞,用於前三個版本。Paper 26.2 另用[獨立維護的 26.2 客戶端](https://github.com/Complexity-ML/mineflayer-26.2) `4.37.1+complexity.26.2.3`;其測試專用 lockfile 與官方版分開,`npm ci --ignore-scripts` 成功,`npm audit` 回報 6 個 moderate、0 個 high/critical,測試只連線 loopback/offline 伺服器。兩套測試都從正式玩家指令與 Console doctor 觀察結果,使用相同插件 JAR SHA-256 `99CE69BE0A38679EDD914AC608C0B0ACC85FE5BCD6A88D80B44FCEF3238BDADA`,每個版本各建立全新 SQLite TestLab 實例。測試設定限定英文指令訊息、`COMMAND_ONLY`、同 IP `ALLOW` 與 `LOGIN_DAYS at-least: 1`;本輪驗證的是預設 `MESSAGE` Reward,而非 Vault 發錢。 | Profile | 實例 | 合成玩家流程 | | --- | --- | --- | | Spigot 1.8.8 | `issue12-fixture-spigot-188` | 通過 | | Paper 1.20.6 | `issue12-fixture-paper-1206` | 通過;Mineflayer/protodef 在登入時另有非致命封包解析警告 | | Paper 1.21.8 | `issue12-fixture-paper-1218` | 通過 | +| Paper 26.2 build 129 | `issue12-flow-paper-262-1`、`issue12-flow-paper-262-2` | 兩個全新實例均通過;第二次使用 repository 固定的獨立客戶端 lockfile | 每次流程由 A 執行 `/ic code` 後離線,B 執行 `/ic claim `、`/ic confirm`,收到 Invitation 已建立及 Qualification Reward 訊息。Console doctor 回報 `PENDING=1, PROCESSING=0, UNCERTAIN=0`;正常關機並重啟後仍為 `PENDING=1`。A 再登入收到離線補發訊息,doctor 變為 `PENDING=0`,`/ic stats` 顯示 `qualified=1`。以上驗證真實伺服器的玩家指令與訊息路徑;外部效果期間的非正常終止另見下節。Paper 1.20.6 的封包警告出自測試客戶端 `protodef`,伺服器端沒有 InviteCode error;該版本的其他客戶端封包相容性不能由此次流程推定。 @@ -76,7 +77,7 @@ Runner 擴充後,再於 Paper 1.20.6 各重跑一次既有 SQLite 與 JSON 實 UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透過公開管理指令。兩實例測完均正常停止重啟後的伺服器,測試用 JVM 中斷沒有影響正式資料。測試演練刻意讓外部效果與最後狀態保存之間斷開;不證明 Vault、其他插件或非同步命令效果可 exactly-once。 -[Mineflayer 官方文件](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)目前列出的支援版本到 26.1;本地 Mineflayer 4.39.0 對 `26.2` 直接回報 `unsupported protocol version: 26.2`。因此不能用它宣稱 Paper 26.2 玩家流程已通過;目前只有該版本的啟動、Console 與儲存 smoke 證據。待官方協定資料支援或有可靠的獨立測試客戶端後再補玩家流程,最後再做一次真人觀感驗收。 +[Mineflayer 官方文件](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)目前列出的支援版本到 26.1;本地官方 Mineflayer 4.39.0 對 `26.2` 直接回報 `unsupported protocol version: 26.2`。本輪改用上述獨立客戶端後,兩個 Paper 26.2 build 129 實例都完成 Code、Claim、Confirm、Qualification、重啟後離線 Reward 補發與 Stats;Console doctor 的 `PENDING=1 → 0` 也符合預期。這是實際 26.2 伺服器玩家路徑證據,不代表上游 Mineflayer 已支援該版本,也不涵蓋真人客戶端的 Dialog 顯示或視覺體驗。 [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 @@ -98,4 +99,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 指令、外部服務偵測及三個版本的合成玩家 Claim/離線 `MESSAGE` Reward 已有證據。Spigot 1.8.8 通過 Reward 中斷後的 `UNCERTAIN` 復原與兩種管理員決定;Paper 1.20.6/1.21.8 分別通過 Placeholder 資格與 Vault 實際存款;SQLite 與 MySQL 也完成上述伺服器層級遷移復原測試。Issue #12 仍缺最新 Paper 26.2 的玩家 critical path、Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 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 也完成上述伺服器層級遷移復原測試。Issue #12 仍缺 Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index d1db177..f7adaf2 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -100,7 +100,24 @@ node .\scripts\test-servers\synthetic-player\flow.cjs ` 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-example-spigot-188' ``` -`-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 限定 Spigot 1.8.8、Paper 1.20.6 與 1.21.8;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋聊天/Dialog 輸入、Vault 金額、最新 Paper 26.2 或中斷於外部效果期間的 `UNCERTAIN` 復原。 +`-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 支援 Spigot 1.8.8、Paper 1.20.6、1.21.8 與 `paper-latest` 設為 26.2 時的獨立測試客戶端;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋聊天/Dialog 輸入、Vault 金額或中斷於外部效果期間的 `UNCERTAIN` 復原。 + +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` 固定下載內容。先安裝,再建立**全新**實例: + +```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' +$name = 'issue12-flow-paper-262-example' +pwsh -NoProfile -File .\scripts\test-servers\prepare-synthetic-player.ps1 ` + -Profile paper-latest -Instance $name -Artifact $jar -AcceptEula +$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" +``` + +Runner 會驗證 26.2 客戶端版本、TestLab metadata、EULA、loopback、離線模式與受測 JAR 的 SHA-256。這個獨立客戶端讓本機 26.2 玩家流程可測,但不代表官方 Mineflayer 已宣告支援,也不能代替最後的真人視覺與互動驗收。 ### Reward 外部效果中斷 diff --git a/scripts/test-servers/prepare-synthetic-player.ps1 b/scripts/test-servers/prepare-synthetic-player.ps1 index 0dbe902..847ac93 100644 --- a/scripts/test-servers/prepare-synthetic-player.ps1 +++ b/scripts/test-servers/prepare-synthetic-player.ps1 @@ -1,7 +1,7 @@ [CmdletBinding()] param( [Parameter(Mandatory = $true)] - [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8')] + [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest')] [string] $Profile, [Parameter(Mandatory = $true)][string] $Instance, [Parameter(Mandatory = $true)][string] $Artifact, diff --git a/scripts/test-servers/synthetic-player-26-2/package-lock.json b/scripts/test-servers/synthetic-player-26-2/package-lock.json new file mode 100644 index 0000000..d011f9e --- /dev/null +++ b/scripts/test-servers/synthetic-player-26-2/package-lock.json @@ -0,0 +1,1051 @@ +{ + "name": "invitecode-synthetic-player-26-2", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "invitecode-synthetic-player-26-2", + "version": "1.0.0", + "devDependencies": { + "mineflayer": "https://github.com/Complexity-ML/mineflayer-26.2/releases/download/complexity-26.2.3/mineflayer-complexity-26.2.3.tgz" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.16.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.1.tgz", + "integrity": "sha512-nyxsA6NA4SVKh5YyRpbSXiMr7oQbwark7JU9LMeg6tJYTSPyAGkdx61wPT4gyxZfxlSxMMEyAsWaubBlNyIa1w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.3.tgz", + "integrity": "sha512-CO+SE4weOsfJf+C5LM8argzvotrXw252/ZU6SM2Tz63fEblhH1uuVaaO4ISYFuN4Q6BhTo7I3qIdi8ydUQCqhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@azure/msal-common": "14.16.1", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@types/node": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.2.tgz", + "integrity": "sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@types/node-rsa": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/node-rsa/-/node-rsa-1.1.4.tgz", + "integrity": "sha512-dB0ECel6JpMnq5ULvpUTunx3yNm8e/dIkv8Zu9p2c8me70xIRUUG3q+qXRwcSf9rN3oqamv4116iHy90dJGRpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/readable-stream": { + "version": "4.0.24", + "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.24.tgz", + "integrity": "sha512-NRvUNC/JFGPJvqdAfEve8oginbM6V08u5NzLWpG8MwA2kTPOLnqk+wpwuPT+mp3aUsxyuT6m2gnrPuHYCruzEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@xboxreplay/xboxlive-auth": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@xboxreplay/xboxlive-auth/-/xboxlive-auth-5.1.0.tgz", + "integrity": "sha512-UngHHsehZbiTjyyNmo8HvdoUDKMID1U9uVfrpFWUK/2UxPuVTKy5n+CzZQ3S488sW5vOhgh0lHqqynT8ouwgvw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/aes-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/discontinuous-range": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", + "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/endian-toggle": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/endian-toggle/-/endian-toggle-0.0.0.tgz", + "integrity": "sha512-ShfqhXeHRE4TmggSlHXG8CMGIcsOsqDw/GcoPcosToE59Rm9e4aXaMhEQf2kPBsBRrKem1bbOAv5gOKnkliMFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "dev": true, + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.reduce": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", + "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", + "dev": true, + "license": "MIT" + }, + "node_modules/macaddress": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.4.tgz", + "integrity": "sha512-i8xVWoUjj2woYU8kbpQby86Kq7uF7xl2brtKREXUBWpfgqx1fKXEeYzDiVMVxA/IufC1d3xxwJRHtFCX+9IspA==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-data": { + "version": "3.111.0+complexity.26.2.5", + "resolved": "https://github.com/Complexity-ML/node-minecraft-data-26.2/releases/download/complexity-26.2.5/minecraft-data-complexity-26.2.5.tgz", + "integrity": "sha512-qaWFimsG9i4X9WS/9ZgRlbiVQptIEcn/8yqjAaWfzywZv5T0v+hAjmXqYea4ailVGXnnf8aJn27WDI8LQtSsfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-folder-path": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minecraft-folder-path/-/minecraft-folder-path-1.2.0.tgz", + "integrity": "sha512-qaUSbKWoOsH9brn0JQuBhxNAzTDMwrOXorwuRxdJKKKDYvZhtml+6GVCUrY5HRiEsieBEjCUnhVpDuQiKsiFaw==", + "dev": true, + "license": "MIT" + }, + "node_modules/minecraft-protocol": { + "version": "1.66.2+complexity.26.2.3", + "resolved": "https://github.com/Complexity-ML/node-minecraft-protocol-26.2/releases/download/complexity-26.2.3/minecraft-protocol-complexity-26.2.3.tgz", + "integrity": "sha512-aD394AkFoJ2QjebtP//xHioVybL0AfZY9IFv7YYbeZGmEAc60/PtbN+6QdMRNYnOA9ihQyB2PNNvYYIrhlBTng==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@types/node-rsa": "^1.1.4", + "@types/readable-stream": "^4.0.0", + "aes-js": "^3.1.2", + "buffer-equal": "^1.0.0", + "debug": "^4.3.2", + "endian-toggle": "^0.0.0", + "lodash.merge": "^4.3.0", + "minecraft-data": "https://github.com/Complexity-ML/node-minecraft-data-26.2/releases/download/complexity-26.2.5/minecraft-data-complexity-26.2.5.tgz", + "minecraft-folder-path": "^1.2.0", + "node-fetch": "^2.6.1", + "node-rsa": "^0.4.2", + "prismarine-auth": "^3.1.1", + "prismarine-chat": "^1.10.0", + "prismarine-nbt": "^2.5.0", + "prismarine-realms": "^1.2.0", + "protodef": "^1.17.0", + "readable-stream": "^4.1.0", + "uuid-1345": "^1.0.1", + "yggdrasil": "^1.4.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/mineflayer": { + "version": "4.37.1+complexity.26.2.3", + "resolved": "https://github.com/Complexity-ML/mineflayer-26.2/releases/download/complexity-26.2.3/mineflayer-complexity-26.2.3.tgz", + "integrity": "sha512-GHkM88KE6rE+MT6ISm+M7ltkJPa+9pf/xuiUDRhw2+Zosc/rpBqDqPGs3Cx+miDavFPOOvx2RJIG5lCQXeEZbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "https://github.com/Complexity-ML/node-minecraft-data-26.2/releases/download/complexity-26.2.5/minecraft-data-complexity-26.2.5.tgz", + "minecraft-protocol": "https://github.com/Complexity-ML/node-minecraft-protocol-26.2/releases/download/complexity-26.2.3/minecraft-protocol-complexity-26.2.3.tgz", + "mojangson": "^2.0.4", + "prismarine-biome": "^1.1.1", + "prismarine-block": "^1.22.0", + "prismarine-chat": "^1.7.1", + "prismarine-chunk": "https://github.com/Complexity-ML/prismarine-chunk-26.2/releases/download/complexity-26.2.0/prismarine-chunk-complexity-26.2.0.tgz", + "prismarine-entity": "^2.5.0", + "prismarine-item": "^1.17.0", + "prismarine-nbt": "^2.0.0", + "prismarine-physics": "https://github.com/Complexity-ML/prismarine-physics-26.2/releases/download/complexity-26.2.0/prismarine-physics-complexity-26.2.0.tgz", + "prismarine-recipe": "^1.5.0", + "prismarine-registry": "^1.10.0", + "prismarine-windows": "^2.9.0", + "prismarine-world": "^3.6.0", + "protodef": "^1.18.0", + "typed-emitter": "^1.0.0", + "uuid-1345": "^1.0.2", + "vec3": "^0.1.7" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/mojangson": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mojangson/-/mojangson-2.1.0.tgz", + "integrity": "sha512-uz0PPHAc/kRO5tBOmEZIWxLlne3NRqO2PRyvIXbU0523tItgpvt0XG83IFZgH21EaKY1/B9c9ca074/eZlI59Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "nearley": "^2.19.5" + } + }, + "node_modules/moo": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.3.tgz", + "integrity": "sha512-m2fmM2dDm7GZQsY7KK2cme8agi+AAljILjQnof7p1ZMDe6dQ4bdnSMx0cPppudoeNv5hEFQirN6u+O4fDE0IWA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nearley": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", + "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^2.19.0", + "moo": "^0.5.0", + "railroad-diagrams": "^1.0.0", + "randexp": "0.4.6" + }, + "bin": { + "nearley-railroad": "bin/nearley-railroad.js", + "nearley-test": "bin/nearley-test.js", + "nearley-unparse": "bin/nearley-unparse.js", + "nearleyc": "bin/nearleyc.js" + }, + "funding": { + "type": "individual", + "url": "https://nearley.js.org/#give-to-nearley" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-rsa": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", + "integrity": "sha512-Bvso6Zi9LY4otIZefYrscsUpo2mUpiAVIEmSZV2q41sP8tHZoert3Yu6zv4f/RXJqMNZQKCtnhDugIuCma23YA==", + "dev": true, + "license": "MIT", + "dependencies": { + "asn1": "0.2.3" + } + }, + "node_modules/prismarine-auth": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prismarine-auth/-/prismarine-auth-3.1.1.tgz", + "integrity": "sha512-NuNrMGZdoigFKsvi1ZZgAEvNYNuE5qe6lo/tw+bqeNbkhpjHC0u1JNxLEujnfqduXI18e19PvUtWNMDl/gH7yw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@azure/msal-node": "^2.0.2", + "@xboxreplay/xboxlive-auth": "^5.1.0", + "debug": "^4.3.3", + "smart-buffer": "^4.1.0", + "uuid-1345": "^1.0.2" + } + }, + "node_modules/prismarine-biome": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prismarine-biome/-/prismarine-biome-1.4.0.tgz", + "integrity": "sha512-fD2WmjN8Zr/xA/jeMInReLgaDlznwA5xlaK529PzWuGzgjpc5ijVu1Lp1oqHyZn3WxOG/bRVtW1bU+tmgCurWA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prismarine-registry": "^1.1.0" + } + }, + "node_modules/prismarine-block": { + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/prismarine-block/-/prismarine-block-1.23.0.tgz", + "integrity": "sha512-j2UoU4KbXMvNlBw+aLkMOnEuMayYefznUfbrfv1VIbckG3RA9LpNWltOMHXuOR5YkHp8uIZPOclj95XC88jgGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.38.0", + "prismarine-biome": "^1.1.0", + "prismarine-chat": "^1.5.0", + "prismarine-item": "^1.10.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.1.0" + } + }, + "node_modules/prismarine-chat": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/prismarine-chat/-/prismarine-chat-1.13.0.tgz", + "integrity": "sha512-tvDbrQmJEoy09yLE5nnedGhQYxnRDaPRePMv7W39dFaHr2LGcA2JfCmH0vG5193+BsEFz3a5+0EpQSK8OW7YmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.2", + "mojangson": "^2.0.1", + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-chunk": { + "version": "1.40.0+complexity.26.2.0", + "resolved": "https://github.com/Complexity-ML/prismarine-chunk-26.2/releases/download/complexity-26.2.0/prismarine-chunk-complexity-26.2.0.tgz", + "integrity": "sha512-xLulC4Ya3uNyjZGu/4yDbSEoOcA2BO9NaXGueDWVRvxFZoAYFZch5E6GXrIF1O4vb52Ijo8HDiIMlwab3cbn2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-biome": "^1.2.0", + "prismarine-block": "^1.14.1", + "prismarine-nbt": "^2.2.1", + "prismarine-registry": "^1.1.0", + "smart-buffer": "^4.1.0", + "uint4": "^0.1.2", + "vec3": "^0.1.3", + "xxhash-wasm": "^0.4.2" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/prismarine-entity": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/prismarine-entity/-/prismarine-entity-2.6.0.tgz", + "integrity": "sha512-/LlZRLOpACiXk+GqoaKi0XPBFnNMjb1d4OIzuSCSEgNMK6FUo3Wnin5yeSZ7ff3Ztt7yagN9lX2jSOafn6IIzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-chat": "^1.4.1", + "prismarine-item": "^1.11.2", + "prismarine-registry": "^1.4.0", + "vec3": "^0.1.4" + } + }, + "node_modules/prismarine-item": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/prismarine-item/-/prismarine-item-1.18.0.tgz", + "integrity": "sha512-8pEq6YfcneVvarvUFnex09a3+MR8/4NCQVyawIKAa3kh/g9dHLexoEcpQEgM3cmpg4gbLmspSiARGwed5uGhlg==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-nbt": "^2.0.0", + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-nbt": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prismarine-nbt/-/prismarine-nbt-2.8.0.tgz", + "integrity": "sha512-5D6FUZq0PNtf3v/41ImDlwThVesOv5adyqCRMZLzmkUGEmRJNNh5C6AsnvrClBftXs+IF0yqPnZoj8kcNPiMGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "protodef": "^1.18.0" + } + }, + "node_modules/prismarine-physics": { + "version": "1.11.0+complexity.26.2.0", + "resolved": "https://github.com/Complexity-ML/prismarine-physics-26.2/releases/download/complexity-26.2.0/prismarine-physics-complexity-26.2.0.tgz", + "integrity": "sha512-s76n0osy7Brc1eiZ3YRrsNsP8c9yd+tQ2mP3BvZeq1/cSOXOvpdEv6Ui3vlVMxGeLIq9oUtTbTPWWJ0xMBxegA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.0.0", + "prismarine-nbt": "^2.0.0", + "vec3": "^0.2.0" + } + }, + "node_modules/prismarine-physics/node_modules/vec3": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/vec3/-/vec3-0.2.0.tgz", + "integrity": "sha512-jOjU4zbCNWOKOGLHop1I0J2Ar4h5Zz76455LJhJKhiOJwI21QP6d5TnKklNZDKG+c5h71zWtPAbd9wh+Va57OQ==", + "dev": true, + "license": "BSD" + }, + "node_modules/prismarine-realms": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/prismarine-realms/-/prismarine-realms-1.6.0.tgz", + "integrity": "sha512-AwemW0vwxG9hQaFtg1twSV7eymB6QtYxGK0jjpxfdA2sdK15kU8jh8uD1o5XF0oxSMU+BbpzZMCmXtXq4QE6bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.3", + "node-fetch": "^2.6.1" + } + }, + "node_modules/prismarine-recipe": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/prismarine-recipe/-/prismarine-recipe-1.5.0.tgz", + "integrity": "sha512-GRZHbsyBIUgVNF10vFRv2YWZj86vokCT5EWX6iK6gfx6h4FapgZT29V2DNkjv5+hmdzBCLZvfx1/RYr8VPeoGQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prismarine-registry": "^1.4.0" + } + }, + "node_modules/prismarine-registry": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/prismarine-registry/-/prismarine-registry-1.12.0.tgz", + "integrity": "sha512-OC5U6YrflY6OcAWRZEqe2HGZuNp0bIuP7H+oKEHD6rLfKNDxo8Ymx5eh2VvrZWnMVugpwID1Qj/UjA4MoCzNDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minecraft-data": "^3.70.0", + "prismarine-block": "^1.17.1", + "prismarine-nbt": "^2.0.0" + } + }, + "node_modules/prismarine-windows": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/prismarine-windows/-/prismarine-windows-2.10.0.tgz", + "integrity": "sha512-ssXLGAr7W9JLvvLjYMoo1j4j6AdJaoIb0/HlqkWMWlQqvZJeiS4zyBjJY6+GtR4OzpjkEf6IvF5cNXhHFpbcZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prismarine-item": "^1.12.2", + "prismarine-registry": "^1.7.0", + "typed-emitter": "^2.1.0" + } + }, + "node_modules/prismarine-windows/node_modules/typed-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz", + "integrity": "sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "rxjs": "*" + } + }, + "node_modules/prismarine-world": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/prismarine-world/-/prismarine-world-3.7.0.tgz", + "integrity": "sha512-M5euvNjQ3vIk689BSa0YC6PBwpVY35Oc6q6KyZ0IqyFtI+cQ9em+8l5OTAK/uu9/gzDDhR7cmm9L2WXgTXBQCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "vec3": "^0.1.7" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/protodef": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/protodef/-/protodef-1.19.0.tgz", + "integrity": "sha512-94f3GR7pk4Qi5YVLaLvWBfTGUIzzO8hyo7vFVICQuu5f5nwKtgGDaeC1uXIu49s5to/49QQhEYeL0aigu1jEGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.reduce": "^4.6.0", + "protodef-validator": "^1.3.0", + "readable-stream": "^4.4.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/protodef-validator": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/protodef-validator/-/protodef-validator-1.5.0.tgz", + "integrity": "sha512-GrPKsNpcd7/4bIAZN3Ojgk5ILsRX9s1IItzU+o29D1o0AKbIaLuBCmaSGbZE90Gn8zxF2/Vj8aPUHjo0AbgFdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.5.4" + }, + "bin": { + "protodef-validator": "cli.js" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/railroad-diagrams": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", + "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/randexp": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", + "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "discontinuous-range": "1.0.0", + "ret": "~0.1.10" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "dev": true, + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/typed-emitter": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/typed-emitter/-/typed-emitter-1.4.0.tgz", + "integrity": "sha512-weBmoo3HhpKGgLBOYwe8EB31CzDFuaK7CCL+axXhUYhn4jo6DSkHnbefboCF5i4DQ2aMFe0C/FdTWcPdObgHyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/uint4": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/uint4/-/uint4-0.1.2.tgz", + "integrity": "sha512-lhEx78gdTwFWG+mt6cWAZD/R6qrIj0TTBeH5xwyuDJyswLNlGe+KVlUPQ6+mx5Ld332pS0AMUTo9hIly7YsWxQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/uuid-1345": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uuid-1345/-/uuid-1345-1.0.2.tgz", + "integrity": "sha512-bA5zYZui+3nwAc0s3VdGQGBfbVsJLVX7Np7ch2aqcEWFi5lsAEcmO3+lx3djM1npgpZI8KY2FITZ2uYTnYUYyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "macaddress": "^0.5.1" + } + }, + "node_modules/vec3": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/vec3/-/vec3-0.1.10.tgz", + "integrity": "sha512-Sr1U3mYtMqCOonGd3LAN9iqy0qF6C+Gjil92awyK/i2OwiUo9bm7PnLgFpafymun50mOjnDcg4ToTgRssrlTcw==", + "dev": true, + "license": "BSD" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/xxhash-wasm": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz", + "integrity": "sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA==", + "dev": true, + "license": "MIT" + }, + "node_modules/yggdrasil": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/yggdrasil/-/yggdrasil-1.8.0.tgz", + "integrity": "sha512-r5bKOhkZ52DJ6q034uSkdsdZLoFVhOmfDOagRs6h/JX5W7+XIPOMb+peCbElhLEoIckwt43NCUoNQbydOzuPcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.1", + "uuid": "^10.0.0" + } + }, + "node_modules/yggdrasil/node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + } + } +} diff --git a/scripts/test-servers/synthetic-player-26-2/package.json b/scripts/test-servers/synthetic-player-26-2/package.json new file mode 100644 index 0000000..f08ee9b --- /dev/null +++ b/scripts/test-servers/synthetic-player-26-2/package.json @@ -0,0 +1,9 @@ +{ + "name": "invitecode-synthetic-player-26-2", + "private": true, + "version": "1.0.0", + "description": "Test-only independent Minecraft 26.2 client for the InviteCode release gate", + "devDependencies": { + "mineflayer": "https://github.com/Complexity-ML/mineflayer-26.2/releases/download/complexity-26.2.3/mineflayer-complexity-26.2.3.tgz" + } +} diff --git a/scripts/test-servers/synthetic-player/flow.cjs b/scripts/test-servers/synthetic-player/flow.cjs index cfbf9ad..dada2d8 100644 --- a/scripts/test-servers/synthetic-player/flow.cjs +++ b/scripts/test-servers/synthetic-player/flow.cjs @@ -2,17 +2,29 @@ const fs = require('node:fs') const path = require('node:path') const crypto = require('node:crypto') const { spawn, spawnSync } = require('node:child_process') -const mineflayer = require('mineflayer') const 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']) +const supportedProfiles = new Set(['spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest']) if (metadata.project !== 'InviteCode' || metadata.instance !== path.basename(instancePath) || !metadata.instance.startsWith('issue12-') || !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 (metadata.profile === 'paper-latest' && + (!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') +} +const mineflayer = metadata.profile === 'paper-latest' ? require(clientPath) : require('mineflayer') +if (metadata.profile === 'paper-latest' && + require(path.join(clientPath, 'package.json')).version !== '4.37.1+complexity.26.2.3') { + throw new Error('Unexpected Paper 26.2 test client version') +} const dataDirectory = path.join(instancePath, 'plugins', 'InviteCode') const config = fs.readFileSync(path.join(dataDirectory, 'config.yml'), 'utf8') From 19f537a26260bfa6794bb19cdc4edd5e9205243a Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 06:54:44 +0800 Subject: [PATCH 11/12] docs: record Folia scheduler compatibility audit --- .../2026-09-24-issue-12-startup-matrix.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 26be7e3..b5f2d80 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 @@ -81,6 +81,19 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 [PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 +### Folia 程式路徑稽核(2026-09-24) + +這是原始碼與先前 Folia 載入 log 的稽核,**不是**可載入後的 smoke。依 [PaperMC 的 scheduler 分工](https://docs.papermc.io/paper/dev/folia-support/#schedulers),全域工作與玩家 entity 工作需要分別排程;不應把原本單一「server main thread」假設直接搬到 Folia。找到以下阻礙: + +| 路徑 | 現況 | Folia 前置工作 | +| --- | --- | --- | +| `InviteCodePlugin` 啟動與每分鐘資格掃描 | `AsyncOperationExecutor` 的所有完成 callback 都交給 `server.scheduler.runTask`;`runTaskTimer` 在同一工作中遍歷玩家,讀取其遊玩時間、權限與 Placeholder 資料 | 將不涉及玩家的 callback 與逐玩家工作分開;玩家資料只在所屬 entity 排程取得,並處理離線/移動後失效 | +| `PlayerWorkflowController` 聊天、Dialog 與 timeout | `runTask`、`runTaskLater` 回到傳統主執行緒,再以 UUID 找玩家、操作 session 或發訊息 | 把玩家互動導回其 entity scheduler;timeout 與斷線競爭需重新驗證 | +| Reward delivery | `BukkitRewardExecutionEnvironment` 以 `Bukkit.isPrimaryThread()` 作為所有 Reward 的共同前提,且同一路徑執行 Console command、Player command、訊息與 Vault deposit | 先定義各 Action 的執行位置;Console 與玩家效果不可假定由同一個執行緒安全完成,保留既有 `PROCESSING`/`UNCERTAIN` 語意 | +| 管理指令及外部 API | 背景完成 callback 可能對玩家 sender 回訊,管理指令亦可依 UUID 直接讀取玩家;API 重評估讀取玩家 Statistic 與 qualification inputs | 依 sender/玩家歸屬派送,避免在全域 callback 讀寫遠端 region 的玩家 | + +因此本輪不修改 `plugin.yml` 的 `folia-supported` 欄位,也不以測試用 JAR 強行宣告相容來冒充有效 smoke。若另行實作 Folia 支援,先設計 Java 8/Spigot 1.8 可載入的 scheduler 邊界與玩家離線時 callback 處理,再對 Console、玩家 Claim/Chat/Dialog、資格掃描、離線 Reward 與 Vault/Placeholder 整合建立跨 region 測試;最後才加入支援標記並在隔離 TestLab 重跑 Folia smoke。未完成前 Folia 保持**未支援、實驗性驗證未通過**,不阻擋已通過的 Spigot/Paper 路徑,但 Issue #12 的 Folia 項目仍未完成。 + Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 ## SQLite 遷移故障與復原(伺服器層級) @@ -99,4 +112,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 也完成上述伺服器層級遷移復原測試。Issue #12 仍缺 Folia 可載入後的實驗性 smoke,以及最終人工觀感驗收;不得據此宣布 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 的程式路徑稽核已完成,但可載入後的實驗性 smoke 仍缺,且最終人工觀感驗收尚未執行;不得據此宣布 1.0 發行 gate 通過。 From 3ea1af46c3ba05443f4f3c6a271a15f875aade21 Mon Sep 17 00:00:00 2001 From: Command1264 Date: Thu, 24 Sep 2026 07:37:44 +0800 Subject: [PATCH 12/12] feat: route InviteCode workflows through Folia-aware schedulers --- README.md | 4 +- docs/README.zh-TW.md | 4 +- docs/adr/0004-folia-scheduler-ownership.md | 9 ++ docs/operations/bukkit-workflow.md | 2 +- .../2026-09-24-issue-12-startup-matrix.md | 24 +++- docs/testing/test-servers.md | 18 ++- .../platform/bukkit/AsyncOperationExecutor.kt | 20 +++- .../BukkitRewardExecutionEnvironment.kt | 10 +- .../platform/bukkit/PlatformTaskDispatcher.kt | 59 +++++++++ .../bukkit/AsyncOperationExecutorTest.kt | 19 +++ .../platform/modern/FoliaTaskDispatcher.kt | 101 ++++++++++++++++ .../plugin/AdminWorkflowController.kt | 7 +- .../plugin/BukkitInviteCodeTabCompleter.kt | 6 +- .../invitecode/plugin/InviteCodePlugin.kt | 47 +++++--- .../plugin/PlayerWorkflowController.kt | 112 ++++++++++++------ .../src/main/resources/plugin.yml | 1 + .../plugin/BukkitCompatibilityTest.kt | 3 +- .../test-servers/prepare-synthetic-player.ps1 | 2 +- .../test-servers/synthetic-player/flow.cjs | 46 ++++++- 19 files changed, 414 insertions(+), 80 deletions(-) create mode 100644 docs/adr/0004-folia-scheduler-ownership.md create mode 100644 invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/PlatformTaskDispatcher.kt create mode 100644 invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/FoliaTaskDispatcher.kt diff --git a/README.md b/README.md index 667298c..662d009 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # InviteCode -InviteCode is a Kotlin invitation and referral rewards plugin for Spigot and Paper. `InviteCodeKt` is the repository name; the plugin and its data directory are named `InviteCode`. +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. The final player experience and cross-version server matrix 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. Folia 26.1.2 has passed an isolated experimental smoke test; optional integrations and the final player experience still require release-stage acceptance. 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 33684a5..63d3b08 100644 --- a/docs/README.zh-TW.md +++ b/docs/README.zh-TW.md @@ -2,10 +2,10 @@ 本文件為 InviteCode 的主要繁體中文維護者說明;精簡英文介紹請見 [`README.md`](../README.md)。 -InviteCode 是從零重寫的 Kotlin Minecraft 邀請與推薦獎勵插件;`InviteCodeKt` 是 repository 名稱,`Kt` 只表示實作使用 Kotlin。目標是以單一可安裝 JAR 支援 Spigot 與 Paper 1.8.8 到最新已測試版本,並透過隔離的 adapter 載入新版能力。 +InviteCode 是從零重寫的 Kotlin Minecraft 邀請與推薦獎勵插件;`InviteCodeKt` 是 repository 名稱,`Kt` 只表示實作使用 Kotlin。單一可安裝 JAR 支援 Spigot 與 Paper 1.8.8 到最新已測試版本,並以隔離 adapter 實驗性支援 Folia 26.1.2。 > [!IMPORTANT] -> 這個 repository 目前是 `0.1.0-SNAPSHOT`。舊版相容的 Bukkit 指令、聊天輸入、SQLite lifecycle、Qualification、可復原 Reward Delivery 與新版原生 Dialog adapter 已完成串接;跨版本自動化 smoke 已建立,玩家實際操作與畫面呈現仍留待發行前真人驗收。 +> 這個 repository 目前是 `0.1.0-SNAPSHOT`。舊版相容的 Bukkit 指令、聊天輸入、SQLite lifecycle、Qualification、可復原 Reward Delivery 與新版原生 Dialog adapter 已完成串接;Folia 26.1.2 的隔離合成玩家 smoke 也已通過。Folia 上的第三方整合與原生 Dialog 畫面、以及最終玩家體驗仍未完成驗收。 ## 專案目標 diff --git a/docs/adr/0004-folia-scheduler-ownership.md b/docs/adr/0004-folia-scheduler-ownership.md new file mode 100644 index 0000000..6fcea94 --- /dev/null +++ b/docs/adr/0004-folia-scheduler-ownership.md @@ -0,0 +1,9 @@ +# 依工作歸屬派送 Bukkit 與 Folia 任務 + +狀態:已採納(Folia 仍屬實驗性) + +InviteCode 繼續提供單一 Java 8 相容 JAR。舊版 Spigot/Paper 使用 Bukkit scheduler;Folia 使用隔離於 `invitecode-platform-modern` 的反射 adapter,避免舊版 JVM 載入新版 scheduler API。只在偵測到 Folia 時選擇其 adapter,`plugin.yml` 才宣告 `folia-supported: true`。 + +背景儲存操作仍由單一 executor 執行,且先保存 Reward Action 的 `PROCESSING` 狀態。完成 callback 依歸屬派送:全域狀態、Console 指令與 Vault Economy 路徑進入 global scheduler;玩家 Statistic、permission、Placeholder、指令、訊息及私密輸入進入玩家 entity scheduler。玩家參照由登入/離線事件管理,排程器跟隨玩家跨 region;玩家在 callback 前離線時,線上動作保持 `PENDING`,已開始而結果不明的外部動作仍依 [ADR 0002](./0002-durable-reward-delivery.md) 進入 `UNCERTAIN`,不可自動重試。 + +此設計讓 Spigot 1.8.8、Paper 26.2 與 Folia 26.1.2 的同一份 JAR 得到實測覆蓋,並可在 Folia 兩個 region 排程執行緒上處理相距遙遠的玩家。它不保證任意第三方 Vault/Placeholder provider、未測 Folia 版本或原生 Dialog 視覺行為相容;這些項目需各自測試,不能由 `folia-supported` 欄位推論。測試範圍與剩餘限制記錄於 [Issue #12 證據](../testing/evidence/2026-09-24-issue-12-startup-matrix.md)。 diff --git a/docs/operations/bukkit-workflow.md b/docs/operations/bukkit-workflow.md index 21e7401..0329426 100644 --- a/docs/operations/bukkit-workflow.md +++ b/docs/operations/bukkit-workflow.md @@ -1,6 +1,6 @@ # Bukkit 操作與維護 -本文件說明 InviteCode 在 Spigot/Paper 上的玩家流程、管理指令、儲存初始化、維護模式與人工驗收方式。可選擇 `SQLITE`、`MYSQL` 或小型單實例環境使用的 `JSON`。JSON 與 MySQL 的設定及復原細節分別見 [`json-storage.md`](./json-storage.md) 與 [`mysql-storage.md`](./mysql-storage.md)。 +本文件說明 InviteCode 在 Spigot/Paper 上的玩家流程、管理指令、儲存初始化、維護模式與人工驗收方式;Folia 26.1.2 目前僅有[實驗性 smoke 證據](../testing/evidence/2026-09-24-issue-12-startup-matrix.md),第三方整合尚未驗證。可選擇 `SQLITE`、`MYSQL` 或小型單實例環境使用的 `JSON`。JSON 與 MySQL 的設定及復原細節分別見 [`json-storage.md`](./json-storage.md) 與 [`mysql-storage.md`](./mysql-storage.md)。 ## 首次啟動 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 b5f2d80..9858699 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 @@ -13,7 +13,7 @@ | `paper-1.20.6` | Paper 1.20.6 build 151 | `local-21` | 通過 | | `paper-1.21.8` | Paper 1.21.8 build 60 | `local-21` | 通過 | | `paper-latest` | Paper 26.2 build 128 | `local-25` | 通過 | -| `folia-latest` | Folia 26.1.2 stable build 8,僅於 TestLab 本機 task Worktree 修正 profile 後 | `local-25` | 不通過:Folia 在載入階段拒絕插件 | +| `folia-latest` | Folia 26.1.2 stable build 8,僅於 TestLab 本機 task Worktree 修正 profile 後 | `local-25` | 初輪拒載;排程改造後啟動、Console、合成玩家與兩個 region 的實驗性 smoke 通過,細節見下節 | 另外以同一份 JAR 在 `paper-1.20.6` 的獨立 `issue12-json-paper-1206` 實例設為 `backend: JSON`,首次啟動與重啟均回報 `ACTIVE` 與 JSON 儲存版本 1;兩次正常停機後,`invitecode.json` 和 `anti-abuse.key` 的 SHA-256 各自一致。Console 的 `ic help` 與 `ic reload` 也通過。這是代表性 JSON 真實伺服器整合,並未測試 JSON 的玩家負載或跨 backend 搬移。 @@ -79,9 +79,9 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 [Mineflayer 官方文件](https://github.com/PrismarineJS/mineflayer/blob/master/docs/README.md)目前列出的支援版本到 26.1;本地官方 Mineflayer 4.39.0 對 `26.2` 直接回報 `unsupported protocol version: 26.2`。本輪改用上述獨立客戶端後,兩個 Paper 26.2 build 129 實例都完成 Code、Claim、Confirm、Qualification、重啟後離線 Reward 補發與 Stats;Console doctor 的 `PENDING=1 → 0` 也符合預期。這是實際 26.2 伺服器玩家路徑證據,不代表上游 Mineflayer 已支援該版本,也不涵蓋真人客戶端的 Dialog 顯示或視覺體驗。 -[PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。目前程式仍呼叫傳統 `server.scheduler`,不能為通過 smoke 而直接在正式 JAR 宣告 Folia 支援,必須先驗證 scheduler 與事件處理是否符合 Folia 邊界。Folia 26.1.2 在這台主機上還讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 +[PaperMC Folia 下載頁](https://papermc.io/downloads/folia)當時提供 26.1.2 stable build 8,將 26.2 標示為 experimental;TestLab `develop` 的 `folia-latest` 固定為 26.2 並只選 stable,因此初次無法建立實例。於 TestLab 獨立本機 `codex/fix/folia-stable-profile` Worktree 將 profile 指向 26.1.2 後,TestLab self-test 與 doctor 通過,實例可建立。Folia log 隨即顯示 `Could not load plugin 'InviteCode v0.1.0-SNAPSHOT' as it is not marked as supporting Folia!`;插件在載入前遭拒,尚未進入程式相容性測試。[PaperMC 的 Folia 開發文件](https://docs.papermc.io/paper/dev/folia-support/)也明確指出,加入支援標記仍不足以保證相容,須使用正確的 scheduler。當時程式仍呼叫傳統 `server.scheduler`,所以先完成下述排程稽核與改造,才在正式 JAR 宣告 Folia 支援。Folia 26.1.2 在這台主機上還曾讓 Console `/stop` 拋出伺服器內部 `NullPointerException`;runner 等待 30 秒後終止自己建立的程序樹,63620 port 已釋放。此項不與 InviteCode 載入失敗混為一談。 -### Folia 程式路徑稽核(2026-09-24) +### Folia 變更前程式路徑稽核(2026-09-24) 這是原始碼與先前 Folia 載入 log 的稽核,**不是**可載入後的 smoke。依 [PaperMC 的 scheduler 分工](https://docs.papermc.io/paper/dev/folia-support/#schedulers),全域工作與玩家 entity 工作需要分別排程;不應把原本單一「server main thread」假設直接搬到 Folia。找到以下阻礙: @@ -92,7 +92,21 @@ UUID 由測試程式透過 Python 標準 `sqlite3` 唯讀查得,斷言仍透 | Reward delivery | `BukkitRewardExecutionEnvironment` 以 `Bukkit.isPrimaryThread()` 作為所有 Reward 的共同前提,且同一路徑執行 Console command、Player command、訊息與 Vault deposit | 先定義各 Action 的執行位置;Console 與玩家效果不可假定由同一個執行緒安全完成,保留既有 `PROCESSING`/`UNCERTAIN` 語意 | | 管理指令及外部 API | 背景完成 callback 可能對玩家 sender 回訊,管理指令亦可依 UUID 直接讀取玩家;API 重評估讀取玩家 Statistic 與 qualification inputs | 依 sender/玩家歸屬派送,避免在全域 callback 讀寫遠端 region 的玩家 | -因此本輪不修改 `plugin.yml` 的 `folia-supported` 欄位,也不以測試用 JAR 強行宣告相容來冒充有效 smoke。若另行實作 Folia 支援,先設計 Java 8/Spigot 1.8 可載入的 scheduler 邊界與玩家離線時 callback 處理,再對 Console、玩家 Claim/Chat/Dialog、資格掃描、離線 Reward 與 Vault/Placeholder 整合建立跨 region 測試;最後才加入支援標記並在隔離 TestLab 重跑 Folia smoke。未完成前 Folia 保持**未支援、實驗性驗證未通過**,不阻擋已通過的 Spigot/Paper 路徑,但 Issue #12 的 Folia 項目仍未完成。 +當時沒有只靠修改 `plugin.yml` 強行宣告相容。後續依此稽核實作 Java 8/Spigot 1.8 可載入的排程 adapter,並加入 `folia-supported: true`;實際 smoke 證據與剩餘限制如下。 + +### Folia 排程改造與實驗性 smoke + +`PlatformTaskDispatcher` 讓舊版 Bukkit 使用既有 scheduler;Folia adapter 以反射隔離新版 API,將全域 callback、定時資格掃描與 Console Reward 排至 global scheduler,逐玩家資格取值、指令回覆、聊天/Dialog callback、訊息與 Player command Reward 排至 entity scheduler。玩家參照由登入/離線事件維護;Reward 仍先持久化狀態,再執行外部效果。`plugin.yml` 已加入 `folia-supported: true`,但這不代表未測試的 Folia 版本或外部插件組合可用。 + +| 實例與受測 JAR SHA-256 | 結果 | +| --- | --- | +| `issue12-folia-scheduler-1`/`22E0CB80...` | 載入、SQLite 初始化與 Console doctor 通過;關閉時反射到 Folia 非公開類別導致 `IllegalAccessException`,已改由公開 `ScheduledTask` 介面取消 | +| `issue12-folia-scheduler-2`、`issue12-folia-flow-1`/`C67B4768...` | 全新實例啟動、Console `doctor`/`help`/`reload`、正常關閉及合成玩家 Claim/重啟後離線訊息補發通過 | +| `issue12-folia-rewards-2`/`48EC4706...` | 預設 MESSAGE 外另加 Console `say` 與玩家 `help`;兩種指令均實際執行,唯讀查 SQLite 確認 `CONSOLE_COMMAND=DELIVERED 1`、`PLAYER_COMMAND=DELIVERED 1`、`MESSAGE=DELIVERED 2` | +| `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 通過**。 Spigot/Paper 26.2 的 log 有 Windows Perflib/OSHI/JNA 讀取系統計數器失敗及衍生的 system-report `NullPointerException`;堆疊未涉及 InviteCode,伺服器與插件仍可啟動、診斷並正常停機。這是測試主機/伺服器層級的已知雜訊,不能用它替代插件無錯誤的判定。 @@ -112,4 +126,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 的程式路徑稽核已完成,但可載入後的實驗性 smoke 仍缺,且最終人工觀感驗收尚未執行;不得據此宣布 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 已通過;原生 Dialog 視覺、Folia 第三方整合及最終人工觀感仍未驗證,不得據此宣布 1.0 發行 gate 通過。 diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index f7adaf2..2f5564a 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -100,7 +100,23 @@ node .\scripts\test-servers\synthetic-player\flow.cjs ` 'D:\Code\Java\Plugin\TestLab\instances\InviteCode\issue12-example-spigot-188' ``` -`-AcceptEula` 只能在使用者已接受 Minecraft EULA 的測試環境使用。Fixture 支援 Spigot 1.8.8、Paper 1.20.6、1.21.8 與 `paper-latest` 設為 26.2 時的獨立測試客戶端;同一測試埠的實例須依序執行。準備腳本把測試實例設定為 `en_US`、`COMMAND_ONLY`、同 IP `ALLOW`,並以登入 1 天即符合資格的政策觸發預設 `MESSAGE` Reward。這些都是隔離測試設定,產品預設不變。Runner 要求資料庫與 key 尚不存在,完成後正常關閉自己啟動的伺服器;再次測試須使用新實例名稱。輸出 `PASS` 只證明這些指令與訊息路徑,不涵蓋聊天/Dialog 輸入、Vault 金額或中斷於外部效果期間的 `UNCERTAIN` 復原。 +`-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-*` 實例: + +```powershell +$lab = 'D:\Code\Java\Plugin\TestLab\worktrees\fix-folia-stable-profile' +$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 +$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" +``` + +跨 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` 固定下載內容。先安裝,再建立**全新**實例: diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutor.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutor.kt index 25230cb..3093d43 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutor.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutor.kt @@ -25,18 +25,34 @@ class AsyncOperationExecutor( val acceptingOperations: Boolean get() = accepting.get() + fun callbacksOn(dispatch: (() -> Unit) -> Unit): BackgroundOperationExecutor = + object : BackgroundOperationExecutor { + override fun submit( + operation: () -> T, + onSuccess: (T) -> Unit, + onFailure: (Throwable) -> Unit, + ): Boolean = submitWithDispatcher(dispatch, operation, onSuccess, onFailure) + } + override fun submit( operation: () -> T, onSuccess: (T) -> Unit, onFailure: (Throwable) -> Unit, + ): Boolean = submitWithDispatcher(dispatchMain, operation, onSuccess, onFailure) + + private fun submitWithDispatcher( + dispatcher: (() -> Unit) -> Unit, + operation: () -> T, + onSuccess: (T) -> Unit, + onFailure: (Throwable) -> Unit, ): Boolean { if (!accepting.get()) return false return try { executor.execute { val result = runCatching(operation) if (accepting.get()) { - dispatchMain { - if (!accepting.get()) return@dispatchMain + dispatcher { + if (!accepting.get()) return@dispatcher result.fold(onSuccess, onFailure) } } diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt index cf3bdb8..d6b4477 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt @@ -4,6 +4,7 @@ import io.github.command1264.invitecode.core.OnlineRewardActionResult import io.github.command1264.invitecode.core.RewardExecutionEnvironment import org.bukkit.Bukkit import org.bukkit.Server +import org.bukkit.entity.Player import java.math.BigDecimal import java.util.UUID @@ -20,10 +21,11 @@ class BukkitRewardExecutionEnvironment( private val messages: RewardMessageResolver, private val economy: EconomyRewardGateway? = null, private val isPrimaryThread: () -> Boolean = Bukkit::isPrimaryThread, + private val playerLookup: (UUID) -> Player? = server::getPlayer, ) : RewardExecutionEnvironment { override fun isOnline(playerId: UUID): Boolean { requireMainThread() - return server.getPlayer(playerId)?.isOnline == true + return playerLookup(playerId)?.isOnline == true } override fun dispatchConsole(command: String): Boolean { @@ -33,7 +35,7 @@ class BukkitRewardExecutionEnvironment( override fun dispatchPlayer(playerId: UUID, command: String): OnlineRewardActionResult { requireMainThread() - val player = server.getPlayer(playerId) + val player = playerLookup(playerId) ?: return OnlineRewardActionResult.RECIPIENT_OFFLINE return if (player.performCommand(command)) { OnlineRewardActionResult.ACCEPTED @@ -44,7 +46,7 @@ class BukkitRewardExecutionEnvironment( override fun sendMessage(playerId: UUID, localeKey: String): OnlineRewardActionResult { requireMainThread() - val player = server.getPlayer(playerId) + val player = playerLookup(playerId) ?: return OnlineRewardActionResult.RECIPIENT_OFFLINE player.sendMessage(messages.resolve(playerId, localeKey)) return OnlineRewardActionResult.ACCEPTED @@ -63,7 +65,7 @@ class BukkitRewardExecutionEnvironment( private fun requireMainThread() { check(isPrimaryThread()) { - "Bukkit Reward operations must be called on the server main thread by AsyncRewardDeliveryWorkflow." + "Bukkit Reward operations must be called on a platform-owned thread by AsyncRewardDeliveryWorkflow." } } } diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/PlatformTaskDispatcher.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/PlatformTaskDispatcher.kt new file mode 100644 index 0000000..7e9d02b --- /dev/null +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/PlatformTaskDispatcher.kt @@ -0,0 +1,59 @@ +package io.github.command1264.invitecode.platform.bukkit + +import org.bukkit.Server +import org.bukkit.Bukkit +import org.bukkit.entity.Player +import org.bukkit.plugin.Plugin +import java.util.UUID + +/** Routes server-wide work and entity work to the threads that own them. */ +interface PlatformTaskDispatcher { + fun track(player: Player) + fun untrack(player: Player) + fun onlinePlayers(): Collection + fun onlinePlayerNames(): Collection + fun global(operation: () -> Unit) + fun player(player: Player, operation: () -> Unit, retired: () -> Unit = {}) + fun repeatGlobal(delayTicks: Long, periodTicks: Long, operation: () -> Unit): AutoCloseable + fun delayPlayer(player: Player, delayTicks: Long, operation: () -> Unit, retired: () -> Unit = {}) + fun onlinePlayer(playerId: UUID): Player? + fun currentPlayer(playerId: UUID): Player? + fun isManagedThread(): Boolean +} + +class BukkitTaskDispatcher(private val plugin: Plugin) : PlatformTaskDispatcher { + private val server: Server = plugin.server + + override fun track(player: Player) = Unit + + override fun untrack(player: Player) = Unit + + override fun onlinePlayers(): Collection = server.onlinePlayers + + override fun onlinePlayerNames(): Collection = server.onlinePlayers.map(Player::getName) + + override fun global(operation: () -> Unit) { + server.scheduler.runTask(plugin, Runnable(operation)) + } + + override fun player(player: Player, operation: () -> Unit, retired: () -> Unit) { + global { if (player.isOnline) operation() else retired() } + } + + override fun repeatGlobal(delayTicks: Long, periodTicks: Long, operation: () -> Unit): AutoCloseable { + val task = server.scheduler.runTaskTimer(plugin, Runnable(operation), delayTicks, periodTicks) + return AutoCloseable { task.cancel() } + } + + override fun delayPlayer(player: Player, delayTicks: Long, operation: () -> Unit, retired: () -> Unit) { + server.scheduler.runTaskLater(plugin, Runnable { + if (player.isOnline) operation() else retired() + }, delayTicks) + } + + override fun onlinePlayer(playerId: UUID): Player? = server.getPlayer(playerId) + + override fun currentPlayer(playerId: UUID): Player? = server.getPlayer(playerId) + + override fun isManagedThread(): Boolean = Bukkit.isPrimaryThread() +} diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutorTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutorTest.kt index 12785fe..06b3372 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutorTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncOperationExecutorTest.kt @@ -53,6 +53,25 @@ class AsyncOperationExecutorTest { callbacks.forEach { it.invoke() } } + @Test + fun `routes callbacks through the selected dispatcher`() { + val global = CopyOnWriteArrayList<() -> Unit>() + val player = CopyOnWriteArrayList<() -> Unit>() + val completed = CountDownLatch(1) + AsyncOperationExecutor("invitecode-test", global::add).use { executor -> + val playerOperations = executor.callbacksOn(player::add) + assertTrue(playerOperations.submit( + operation = { "player result" }, + onSuccess = { assertEquals("player result", it); completed.countDown() }, + onFailure = { throw AssertionError(it) }, + )) + waitForCallbacks(player) + assertTrue(global.isEmpty()) + player.removeAt(0).invoke() + assertTrue(completed.await(1, TimeUnit.SECONDS)) + } + } + private fun waitForCallbacks(callbacks: List<() -> Unit>) { repeat(100) { if (callbacks.isNotEmpty()) return diff --git a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/FoliaTaskDispatcher.kt b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/FoliaTaskDispatcher.kt new file mode 100644 index 0000000..0ed59cf --- /dev/null +++ b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/FoliaTaskDispatcher.kt @@ -0,0 +1,101 @@ +package io.github.command1264.invitecode.platform.modern + +import io.github.command1264.invitecode.platform.bukkit.BukkitTaskDispatcher +import io.github.command1264.invitecode.platform.bukkit.PlatformTaskDispatcher +import org.bukkit.entity.Player +import org.bukkit.plugin.Plugin +import java.util.UUID +import java.util.concurrent.ConcurrentHashMap +import java.util.function.Consumer + +/** Reflective so the same Java 8 JAR can still load on Spigot 1.8.8. */ +object PlatformTaskDispatchers { + fun create(plugin: Plugin): PlatformTaskDispatcher = + if (isFolia(plugin)) FoliaTaskDispatcher(plugin) else BukkitTaskDispatcher(plugin) + + private fun isFolia(plugin: Plugin): Boolean = try { + Class.forName("io.papermc.paper.threadedregions.RegionizedServer", false, plugin.server.javaClass.classLoader) + true + } catch (_: ClassNotFoundException) { + false + } +} + +private class FoliaTaskDispatcher(private val plugin: Plugin) : PlatformTaskDispatcher { + private val global = plugin.server.javaClass.getMethod("getGlobalRegionScheduler").invoke(plugin.server) + private val context = ThreadLocal() + private val players = ConcurrentHashMap() + private val playerNames = ConcurrentHashMap() + + override fun track(player: Player) { + players[player.uniqueId] = player + playerNames[player.uniqueId] = player.name + } + + override fun untrack(player: Player) { + if (players.remove(player.uniqueId, player)) playerNames.remove(player.uniqueId) + } + + override fun onlinePlayers(): Collection = players.values.toList() + + override fun onlinePlayerNames(): Collection = playerNames.values.toList() + + private fun inContext(owner: Any, operation: () -> Unit) { + val previous = context.get() + context.set(owner) + try { + operation() + } finally { + if (previous == null) context.remove() else context.set(previous) + } + } + + override fun global(operation: () -> Unit) { + val method = global.javaClass.getMethod("run", Plugin::class.java, Consumer::class.java) + method.invoke(global, plugin, Consumer { inContext(GLOBAL, operation) }) + } + + override fun player(player: Player, operation: () -> Unit, retired: () -> Unit) { + val scheduler = player.javaClass.getMethod("getScheduler").invoke(player) + val method = scheduler.javaClass.getMethod( + "run", Plugin::class.java, Consumer::class.java, Runnable::class.java, + ) + val task = method.invoke(scheduler, plugin, + Consumer { inContext(player.uniqueId, operation) }, Runnable { global(retired) }) + if (task == null) global(retired) + } + + override fun repeatGlobal(delayTicks: Long, periodTicks: Long, operation: () -> Unit): AutoCloseable { + val method = global.javaClass.getMethod( + "runAtFixedRate", Plugin::class.java, Consumer::class.java, + java.lang.Long.TYPE, java.lang.Long.TYPE, + ) + val task = requireNotNull(method.invoke(global, plugin, + Consumer { inContext(GLOBAL, operation) }, delayTicks, periodTicks)) + val taskType = Class.forName("io.papermc.paper.threadedregions.scheduler.ScheduledTask") + return AutoCloseable { taskType.getMethod("cancel").invoke(task) } + } + + override fun delayPlayer(player: Player, delayTicks: Long, operation: () -> Unit, retired: () -> Unit) { + val scheduler = player.javaClass.getMethod("getScheduler").invoke(player) + val method = scheduler.javaClass.getMethod( + "runDelayed", Plugin::class.java, Consumer::class.java, Runnable::class.java, java.lang.Long.TYPE, + ) + val task = method.invoke( + scheduler, plugin, Consumer { inContext(player.uniqueId, operation) }, + Runnable { global(retired) }, delayTicks, + ) + if (task == null) global(retired) + } + + override fun onlinePlayer(playerId: UUID): Player? = players[playerId] + + override fun currentPlayer(playerId: UUID): Player? = + if (context.get() == playerId) players[playerId] else null + + override fun isManagedThread(): Boolean = context.get() != null + + private companion object { + val GLOBAL = Any() + } +} diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt index b07f135..4f99daa 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt @@ -17,6 +17,7 @@ import io.github.command1264.invitecode.platform.bukkit.InviteCodeCommandId import io.github.command1264.invitecode.platform.bukkit.InviteCodeRuntimeConfiguration import io.github.command1264.invitecode.platform.bukkit.generator import io.github.command1264.invitecode.platform.bukkit.ParsedInviteCodeCommand +import io.github.command1264.invitecode.platform.bukkit.PlatformTaskDispatcher import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.plugin.Plugin @@ -30,6 +31,7 @@ class AdminWorkflowController( private val configuration: AtomicRuntimeSnapshot, private val storage: AtomicReference, private val operations: AsyncOperationExecutor, + private val tasks: PlatformTaskDispatcher, private val refreshPlayer: (UUID) -> Unit, private val now: () -> Instant = Instant::now, ) { @@ -230,7 +232,10 @@ class AdminWorkflowController( operation: (InviteCodeStorage) -> T, onSuccess: (T) -> Unit, ): Boolean { - val accepted = operations.submit( + val accepted = operations.callbacksOn { callback -> + if (sender is Player) tasks.player(sender, operation = callback) + else tasks.global(callback) + }.submit( operation = { operation(requireNotNull(storage.get()) { "SQLite storage is unavailable." }) }, onSuccess = onSuccess, onFailure = { error -> diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt index fb66fc6..047d14e 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt @@ -1,14 +1,14 @@ package io.github.command1264.invitecode.plugin import io.github.command1264.invitecode.platform.bukkit.InviteCodeTabCompletion -import org.bukkit.Server +import io.github.command1264.invitecode.platform.bukkit.PlatformTaskDispatcher import org.bukkit.command.Command import org.bukkit.command.CommandSender import org.bukkit.command.TabCompleter import org.bukkit.entity.Player internal class BukkitInviteCodeTabCompleter( - private val server: Server, + private val tasks: PlatformTaskDispatcher, ) : TabCompleter { override fun onTabComplete( sender: CommandSender, @@ -19,6 +19,6 @@ internal class BukkitInviteCodeTabCompleter( arguments = args.toList(), player = sender is Player, hasPermission = sender::hasPermission, - onlinePlayerNames = server.onlinePlayers.map(Player::getName), + onlinePlayerNames = tasks.onlinePlayerNames().toList(), ) } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt index e89a4fb..29b6530 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt @@ -19,8 +19,10 @@ import io.github.command1264.invitecode.platform.bukkit.PluginRuntimeState import io.github.command1264.invitecode.platform.bukkit.RuntimePhase import io.github.command1264.invitecode.platform.bukkit.RuntimeConfigurationReload import io.github.command1264.invitecode.platform.bukkit.NetworkAddressHasher +import io.github.command1264.invitecode.platform.bukkit.PlatformTaskDispatcher import io.github.command1264.invitecode.platform.modern.ModernPlatformCapabilities import io.github.command1264.invitecode.platform.modern.ModernPlatformIntegration +import io.github.command1264.invitecode.platform.modern.PlatformTaskDispatchers import io.github.command1264.invitecode.storage.json.JsonInviteCodeStorage import io.github.command1264.invitecode.storage.sql.BlockingOperationGuard import io.github.command1264.invitecode.storage.sql.SqliteInviteCodeStorage @@ -33,7 +35,6 @@ import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.ServicePriority -import org.bukkit.scheduler.BukkitTask import java.time.Duration import java.time.Instant import java.util.concurrent.atomic.AtomicReference @@ -48,13 +49,16 @@ class InviteCodePlugin : JavaPlugin() { private val sessions = ClaimInteractionSessions() private var operations: AsyncOperationExecutor? = null private var playerWorkflows: PlayerWorkflowController? = null - private var qualificationTask: BukkitTask? = null + private var qualificationTask: AutoCloseable? = null + private lateinit var tasks: PlatformTaskDispatcher private var modernIntegration: ModernPlatformIntegration? = null override fun onEnable() { saveBundledResources() + tasks = PlatformTaskDispatchers.create(this) + server.onlinePlayers.forEach(tasks::track) val executor = AsyncOperationExecutor("InviteCode-storage") { operation -> - server.scheduler.runTask(this, Runnable(operation)) + tasks.global(operation) } operations = executor val modern = ModernPlatformCapabilities.initialize(this) @@ -65,6 +69,7 @@ class InviteCodePlugin : JavaPlugin() { configuration, storage, executor, + tasks, sessions, externalQualificationProviders, networkHasher, @@ -92,8 +97,11 @@ class InviteCodePlugin : JavaPlugin() { configuration, storage, executor, + tasks, refreshPlayer = { playerId -> - server.getPlayer(playerId)?.let(playerWorkflows::registerPlayer) + tasks.onlinePlayer(playerId)?.let { player -> + tasks.player(player, operation = { playerWorkflows.registerPlayer(player) }) + } }, ) getCommand("invitecode")?.let { command -> @@ -108,19 +116,21 @@ class InviteCodePlugin : JavaPlugin() { doctor = ::doctor, ), ) - command.setTabCompleter(BukkitInviteCodeTabCompleter(server)) + command.setTabCompleter(BukkitInviteCodeTabCompleter(tasks)) } - qualificationTask = server.scheduler.runTaskTimer(this, Runnable { + qualificationTask = tasks.repeatGlobal(20L * 60L, 20L * 60L) { if (runtime.phase == RuntimePhase.ACTIVE) { - server.onlinePlayers.forEach(playerWorkflows::registerPlayer) + tasks.onlinePlayers().forEach { player -> + tasks.player(player, operation = { playerWorkflows.registerPlayer(player) }) + } } - }, 20L * 60L, 20L * 60L) + } start(executor) } override fun onDisable() { runtime.beginStopping() - qualificationTask?.cancel() + qualificationTask?.close() qualificationTask = null sessions.clear() modernIntegration?.dialogInput?.close() @@ -151,7 +161,9 @@ class InviteCodePlugin : JavaPlugin() { if (result.storageInitialized) { logger.info("已自動完成首次 ${result.configuration?.storage?.backend} 儲存與防濫用密鑰初始化。") } - server.onlinePlayers.forEach { playerWorkflows?.registerPlayer(it) } + tasks.onlinePlayers().forEach { player -> + tasks.player(player, operation = { playerWorkflows?.registerPlayer(player) }) + } logger.info("InviteCode ${description.version} 已啟用。") } else { val message = result.error?.message ?: "未知的啟動錯誤。" @@ -230,7 +242,7 @@ class InviteCodePlugin : JavaPlugin() { sendLocalized(sender, "admin.reload-stopping") return } - val accepted = executor.submit( + val accepted = executor.callbacksOn { callback -> dispatchSender(sender, callback) }.submit( operation = { val candidate = BukkitConfigurationLoader(dataFolder.toPath()) { key -> logger.warning("找不到語系訊息:$key") @@ -271,7 +283,7 @@ class InviteCodePlugin : JavaPlugin() { } val actor = sender.name val reason = requireNotNull(request.reason) - val accepted = executor.submit( + val accepted = executor.callbacksOn { callback -> dispatchSender(sender, callback) }.submit( operation = { val guard = BlockingOperationGuard.rejectingServerMainThread(Bukkit::isPrimaryThread) when (candidate.storage.backend) { @@ -322,7 +334,9 @@ class InviteCodePlugin : JavaPlugin() { networkHasher.getAndSet(hasher)?.close() } if (runtime.phase == RuntimePhase.MAINTENANCE) runtime.activate() - server.onlinePlayers.forEach { playerWorkflows?.registerPlayer(it) } + tasks.onlinePlayers().forEach { player -> + tasks.player(player, operation = { playerWorkflows?.registerPlayer(player) }) + } logger.info("$actor 以理由「$reason」完成 $target schema migration 至版本 ${result.version}。") sendLocalized(sender, "admin.storage-success", mapOf("version" to result.version.toString())) }, @@ -367,7 +381,7 @@ class InviteCodePlugin : JavaPlugin() { sendLocalized(sender, "admin.doctor-storage-offline") return } - val accepted = executor.submit( + val accepted = executor.callbacksOn { callback -> dispatchSender(sender, callback) }.submit( operation = { store.rewardBacklogCounts() }, onSuccess = { backlog -> sendLocalized( @@ -405,6 +419,11 @@ class InviteCodePlugin : JavaPlugin() { sender.sendMessage(messages.resolve(locale, key, variables)) } + private fun dispatchSender(sender: CommandSender, operation: () -> Unit) { + if (sender is Player) tasks.player(sender, operation = operation) + else tasks.global(operation) + } + private fun saveBundledResources() { BundledConfigurationInstaller(dataFolder.toPath(), ::getResource).installMissing() } 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 43eaadb..4a7ddb3 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 @@ -20,6 +20,7 @@ import io.github.command1264.invitecode.core.PermissionQualificationLookup import io.github.command1264.invitecode.core.PlayerNetworkHash import io.github.command1264.invitecode.core.PlaceholderQualificationLookup import io.github.command1264.invitecode.core.RewardActionExecutionContext +import io.github.command1264.invitecode.core.RewardActionType import io.github.command1264.invitecode.core.RewardDeliveryCoordinator import io.github.command1264.invitecode.core.StandardRewardActionExecutor import io.github.command1264.invitecode.core.PlayerClaimState @@ -44,6 +45,7 @@ import io.github.command1264.invitecode.platform.bukkit.parser import io.github.command1264.invitecode.platform.bukkit.ParsedInviteCodeCommand import io.github.command1264.invitecode.platform.bukkit.RewardMessageResolver import io.github.command1264.invitecode.platform.bukkit.NetworkAddressHasher +import io.github.command1264.invitecode.platform.bukkit.PlatformTaskDispatcher import io.github.command1264.invitecode.platform.bukkit.resolve import org.bukkit.OfflinePlayer import org.bukkit.entity.Player @@ -67,6 +69,7 @@ class PlayerWorkflowController( private val configuration: AtomicRuntimeSnapshot, private val storage: AtomicReference, private val operations: AsyncOperationExecutor, + private val tasks: PlatformTaskDispatcher, private val sessions: ClaimInteractionSessions, private val externalQualificationProviders: QualificationProviderRegistry, private val networkHasher: AtomicReference, @@ -84,14 +87,23 @@ class PlayerWorkflowController( requireNotNull(store.invitation(invitationId)) { "Invitation $invitationId does not exist." } }, onSuccess = { invitation -> - val player = plugin.server.getPlayer(invitation.inviteeId) val runtime = configuration.current().value - val playTime = player?.let { - Duration.ofMillis(BukkitStatisticCompatibility.playTimeTicks(it) * 50L) + val player = tasks.onlinePlayer(invitation.inviteeId) + if (player == null) { + submitQualificationEvaluation( + invitationId, null, runtime, QualificationInputs(emptyMap(), emptyMap()), future, + ) + } else { + tasks.player(player, operation = { + val playTime = Duration.ofMillis(BukkitStatisticCompatibility.playTimeTicks(player) * 50L) + val inputs = captureQualificationInputs(player, runtime) + submitQualificationEvaluation(invitationId, playTime, runtime, inputs, future) + }, retired = { + submitQualificationEvaluation( + invitationId, null, runtime, QualificationInputs(emptyMap(), emptyMap()), future, + ) + }) } - val inputs = player?.let { captureQualificationInputs(it, runtime) } - ?: QualificationInputs(emptyMap(), emptyMap()) - submitQualificationEvaluation(invitationId, playTime, runtime, inputs, future) }, onFailure = future::completeExceptionally, ) @@ -111,6 +123,7 @@ class PlayerWorkflowController( @EventHandler(priority = EventPriority.MONITOR) fun onJoin(event: PlayerJoinEvent) { + tasks.track(event.player) registerPlayer(event.player) } @@ -125,7 +138,8 @@ class PlayerWorkflowController( val externalInputs = captureQualificationInputs(player, snapshot.value) val networkAddress = player.address?.address?.address?.copyOf() submit( - playerId, + player, + globalCompletion = true, operation = { store -> val existing = store.player(playerId) val firstSeenAt = if ( @@ -181,13 +195,14 @@ class PlayerWorkflowController( val playerId = event.player.uniqueId val code = sessions.consumeChatInput(playerId, event.message) ?: return event.isCancelled = true - plugin.server.scheduler.runTask(plugin, Runnable { - plugin.server.getPlayer(playerId)?.let { beginClaim(it, code) } + tasks.player(event.player, operation = { + if (tasks.onlinePlayer(playerId) === event.player) beginClaim(event.player, code) }) } @EventHandler fun onQuit(event: PlayerQuitEvent) { + tasks.untrack(event.player) sessions.disconnect(event.player.uniqueId) nativeDialogInput.disconnect(event.player.uniqueId) } @@ -197,7 +212,7 @@ class PlayerWorkflowController( val snapshot = configuration.current() val generator = snapshot.value.general.inviteCode.format.generator() submit( - playerId, + player, operation = { store -> InviteCodeLifecycleService(store, generator, 64).assign(playerId, now()) }, @@ -218,9 +233,9 @@ class PlayerWorkflowController( when (claim.inputMode.resolve(capabilities)) { ClaimInputChannel.COMMAND_ONLY -> send(playerId, "command.claim.command-only") ClaimInputChannel.DIALOG -> { - if (!startDialogInput(player, runtime)) startChatInput(playerId, claim.chatInputTimeout) + if (!startDialogInput(player, runtime)) startChatInput(player, claim.chatInputTimeout) } - ClaimInputChannel.CHAT -> startChatInput(playerId, claim.chatInputTimeout) + ClaimInputChannel.CHAT -> startChatInput(player, claim.chatInputTimeout) } } @@ -240,13 +255,14 @@ class PlayerWorkflowController( maximumLength = 64, ), onSubmit = { rawCode -> - plugin.server.scheduler.runTask(plugin, Runnable { - val current = plugin.server.getPlayer(playerId) ?: return@Runnable - sessions.consumeDialogInput(playerId, rawCode)?.let { beginClaim(current, it) } + tasks.player(player, operation = { + if (tasks.onlinePlayer(playerId) === player) { + sessions.consumeDialogInput(playerId, rawCode)?.let { beginClaim(player, it) } + } }) }, onCancel = { - plugin.server.scheduler.runTask(plugin, Runnable { + tasks.player(player, operation = { if (sessions.cancel(playerId)) send(playerId, "command.claim.cancelled") }) }, @@ -255,18 +271,19 @@ class PlayerWorkflowController( sessions.cancel(playerId) return false } - scheduleTimeout(timeout) { + scheduleTimeout(player, timeout) { if (sessions.expireDialogInput(playerId)) { - plugin.server.getPlayer(playerId)?.let(nativeDialogInput::cancel) + tasks.onlinePlayer(playerId)?.let(nativeDialogInput::cancel) send(playerId, "command.claim.dialog-timeout") } } return true } - private fun startChatInput(playerId: UUID, timeout: Duration) { + private fun startChatInput(player: Player, timeout: Duration) { + val playerId = player.uniqueId sessions.startChatInput(playerId, timeout) - scheduleTimeout(timeout) { + scheduleTimeout(player, timeout) { if (sessions.expireChatInput(playerId)) send(playerId, "command.claim.chat-timeout") } send( @@ -280,7 +297,7 @@ class PlayerWorkflowController( val playerId = player.uniqueId val snapshot = configuration.current() submit( - playerId, + player, operation = { store -> prepareClaim(playerId, rawCode, snapshot.value, store) }, onSuccess = { prepared -> when (prepared) { @@ -289,7 +306,7 @@ class PlayerWorkflowController( PreparedClaim.Self -> send(playerId, "command.claim.self") is PreparedClaim.Ready -> { sessions.startConfirmation(prepared.confirmation) - scheduleTimeout(snapshot.value.general.claim.confirmationTimeout) { + scheduleTimeout(player, snapshot.value.general.claim.confirmationTimeout) { if (sessions.expireConfirmation(playerId)) { send(playerId, "command.claim.confirmation-timeout") } @@ -345,7 +362,7 @@ class PlayerWorkflowController( } val snapshot = configuration.current() submit( - playerId, + player, operation = { store -> val confirmed = confirmation.confirm(playerId, now()) InvitationClaimService( @@ -366,7 +383,7 @@ class PlayerWorkflowController( "invitee=${result.invitation.inviteeId}。", ) } - plugin.server.getPlayer(playerId)?.let(::registerPlayer) + tasks.onlinePlayer(playerId)?.let(::registerPlayer) } is InvitationClaimResult.MatchingNetworkDenied -> { send(playerId, "command.claim.matching-network-denied") @@ -396,7 +413,7 @@ class PlayerWorkflowController( val playerId = player.uniqueId val snapshot = configuration.current() submit( - playerId, + player, operation = { store -> val state = store.claimState(playerId) PlayerStatus( @@ -430,7 +447,7 @@ class PlayerWorkflowController( private fun stats(player: Player) { val playerId = player.uniqueId submit( - playerId, + player, operation = { store -> store.inviterInvitationStats(playerId) }, onSuccess = { result -> send( @@ -633,17 +650,29 @@ class PlayerWorkflowController( val environment = BukkitRewardExecutionEnvironment( plugin.server, RewardMessageResolver { playerId, localeKey -> - val locale = plugin.server.getPlayer(playerId)?.let(BukkitLocaleCompatibility::locale) + val locale = this.tasks.currentPlayer(playerId)?.let(BukkitLocaleCompatibility::locale) messages.resolve(locale, localeKey) }, economyGateway(), - ) - val workflow = AsyncRewardDeliveryWorkflow( - operations, - CoordinatorRewardActionStateStore(RewardDeliveryCoordinator(store)), - StandardRewardActionExecutor(environment), + isPrimaryThread = this.tasks::isManagedThread, + playerLookup = this.tasks::currentPlayer, ) tasks.forEach { task -> + val actionOperations = operations.callbacksOn { callback -> + when (task.action.type) { + RewardActionType.MESSAGE.name, RewardActionType.PLAYER_COMMAND.name -> { + val player = this.tasks.onlinePlayer(task.action.recipientId) + if (player == null) this.tasks.global(callback) + else this.tasks.player(player, operation = callback, retired = { this.tasks.global(callback) }) + } + else -> this.tasks.global(callback) + } + } + val workflow = AsyncRewardDeliveryWorkflow( + actionOperations, + CoordinatorRewardActionStateStore(RewardDeliveryCoordinator(store)), + StandardRewardActionExecutor(environment), + ) val accepted = workflow.process( task.action, task.context, @@ -657,15 +686,20 @@ class PlayerWorkflowController( } private fun submit( - playerId: UUID, + player: Player, + globalCompletion: Boolean = false, operation: (InviteCodeStorage) -> T, onSuccess: (T) -> Unit, ) { - val accepted = operations.submit( + val playerId = player.uniqueId + val callbackExecutor = if (globalCompletion) operations else operations.callbacksOn { callback -> + tasks.player(player, operation = callback) + } + val accepted = callbackExecutor.submit( operation = { operation(requireNotNull(storage.get()) { "SQLite storage is unavailable." }) }, onSuccess = onSuccess, onFailure = { error -> - send(playerId, "command.error") + tasks.player(player, operation = { send(playerId, "command.error") }) plugin.logger.log(Level.WARNING, "InviteCode 玩家操作失敗。", error) }, ) @@ -673,7 +707,7 @@ class PlayerWorkflowController( } private fun send(playerId: UUID, key: String, variables: Map = emptyMap()) { - val player = plugin.server.getPlayer(playerId) ?: return + val player = tasks.onlinePlayer(playerId) ?: return val messages = configuration.currentOrNull()?.value?.messages if (messages == null) { player.sendMessage("InviteCode 設定尚未載入。") @@ -683,7 +717,7 @@ class PlayerWorkflowController( } private fun resolve(playerId: UUID, key: String): String { - val player = plugin.server.getPlayer(playerId) ?: return "[offline]" + val player = tasks.onlinePlayer(playerId) ?: return "[offline]" return configuration.current().value.messages.resolve(BukkitLocaleCompatibility.locale(player), key) } @@ -691,9 +725,9 @@ class PlayerWorkflowController( return displayFormatter.display(code) } - private fun scheduleTimeout(duration: Duration, operation: () -> Unit) { + private fun scheduleTimeout(player: Player, duration: Duration, operation: () -> Unit) { val ticks = ((duration.toMillis() + 49L) / 50L).coerceAtLeast(1L) - plugin.server.scheduler.runTaskLater(plugin, Runnable(operation), ticks) + tasks.delayPlayer(player, ticks, operation) } private sealed class PreparedClaim { diff --git a/invitecode-plugin/src/main/resources/plugin.yml b/invitecode-plugin/src/main/resources/plugin.yml index 5869dfa..6fd677d 100644 --- a/invitecode-plugin/src/main/resources/plugin.yml +++ b/invitecode-plugin/src/main/resources/plugin.yml @@ -2,6 +2,7 @@ name: InviteCode version: "${version}" main: io.github.command1264.invitecode.plugin.InviteCodePlugin api-version: '1.13' +folia-supported: true description: Cross-version invitation and referral rewards plugin. authors: [Command1264] website: https://github.com/Command1264/InviteCodeKt diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitCompatibilityTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitCompatibilityTest.kt index baac78c..17d6f10 100644 --- a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitCompatibilityTest.kt +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitCompatibilityTest.kt @@ -24,10 +24,11 @@ class BukkitCompatibilityTest { } @Test - fun `Spigot 1_8 loader accepts the modern api-version metadata`() { + fun `Spigot 1_8 loader accepts modern and Folia metadata`() { val resource = requireNotNull(javaClass.getResourceAsStream("/plugin.yml")) val text = resource.bufferedReader(Charsets.UTF_8).use { it.readText() } assertTrue(text.lineSequence().any { it.trim() == "api-version: '1.13'" }) + assertTrue(text.lineSequence().any { it.trim() == "folia-supported: true" }) val description = javaClass.getResourceAsStream("/plugin.yml").use { input -> PluginDescriptionFile(requireNotNull(input)) diff --git a/scripts/test-servers/prepare-synthetic-player.ps1 b/scripts/test-servers/prepare-synthetic-player.ps1 index 847ac93..ad28c00 100644 --- a/scripts/test-servers/prepare-synthetic-player.ps1 +++ b/scripts/test-servers/prepare-synthetic-player.ps1 @@ -1,7 +1,7 @@ [CmdletBinding()] param( [Parameter(Mandatory = $true)] - [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest')] + [ValidateSet('spigot-1.8.8', 'paper-1.20.6', 'paper-1.21.8', 'paper-latest', 'folia-latest')] [string] $Profile, [Parameter(Mandatory = $true)][string] $Instance, [Parameter(Mandatory = $true)][string] $Artifact, diff --git a/scripts/test-servers/synthetic-player/flow.cjs b/scripts/test-servers/synthetic-player/flow.cjs index dada2d8..640aec0 100644 --- a/scripts/test-servers/synthetic-player/flow.cjs +++ b/scripts/test-servers/synthetic-player/flow.cjs @@ -6,7 +6,7 @@ const { spawn, spawnSync } = require('node:child_process') const 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']) +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) || !metadata.eulaAccepted) { @@ -16,6 +16,9 @@ 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 (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' && (!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') @@ -29,8 +32,10 @@ if (metadata.profile === 'paper-latest' && 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' if (!/default: en_US/.test(config) || !/use-client-locale: false/.test(config) || - !/input-mode: COMMAND_ONLY/.test(config) || !/matching-ip-action: ALLOW/.test(config) || + !(chatMode ? /input-mode: CHAT/.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') } @@ -145,16 +150,42 @@ async function doctor(state, expected) { let server let inviter let invitee +let regionA +let regionB async function main() { try { server = await startServer() + if (metadata.profile === 'folia-latest' && process.env.INVITECODE_FOLIA_MULTI_REGION === '1') { + regionA = await createBot('IcRegionA') + regionB = await createBot('IcRegionB') + server.child.stdin.write('tp IcRegionA 10000 80 10000\n') + server.child.stdin.write('tp IcRegionB -10000 80 -10000\n') + await until(() => Math.abs(regionA.bot.entity.position.x - 10000) < 2 && + Math.abs(regionB.bot.entity.position.x + 10000) < 2, 'bots in separate Folia regions') + await Promise.all([ + command(regionA, '/ic status', /Invitation status: eligible=/), + command(regionB, '/ic status', /Invitation status: eligible=/) + ]) + regionA.bot.quit() + regionB.bot.quit() + regionA = null + regionB = null + } inviter = await createBot('IcTestA') const code = (await command(inviter, '/ic code', /Your Invite Code is ([A-F0-9]{6})/))[1] inviter.bot.quit() inviter = null await delay(500) invitee = await createBot('IcTestB') - await command(invitee, `/ic claim ${code}`, /Inviter: IcTestA; Invite Code:/) + if (chatMode) { + 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') + } else { + await command(invitee, `/ic claim ${code}`, /Inviter: IcTestA; Invite Code:/) + } 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') await doctor(server, /Reward backlog: PENDING=1, PROCESSING=0, UNCERTAIN=0/) @@ -170,11 +201,18 @@ async function main() { process.stdout.write(JSON.stringify({ result: 'PASS', profile: metadata.profile, minecraftVersion: metadata.minecraftVersion, instance: metadata.instance, pluginSha256: metadata.pluginSha256, - checks: ['code', 'claim', 'confirm', 'qualification', 'pending-after-restart', 'offline-reward-on-login', 'stats'] + 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' + ] }) + '\n') } finally { if (inviter) inviter.bot.quit() if (invitee) invitee.bot.quit() + if (regionA) regionA.bot.quit() + if (regionB) regionB.bot.quit() if (server) await stopServer(server) } }