diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07480dd..dc586c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,244 +1,244 @@ -# Contributing to CheatEngine.SDK - -Thanks for contributing. CheatEngine.SDK is a Windows x64, .NET 10 SDK for Cheat Engine 7.7 plugins. Keep changes -focused, preserve existing patterns, and update documentation when behavior or public APIs change. - -## Prerequisites - -- Windows x64 -- .NET SDK 10.0.403 exactly. [`global.json`](global.json) sets `rollForward: disable`, because the NuGet lock files - record the packages that the SDK adds implicitly. Install it with - `winget install Microsoft.DotNet.SDK.10 --version 10.0.403`. -- PowerShell 7 (`pwsh`): every workflow step runs in it (`defaults.run.shell: pwsh`); useful for rehearsing a CI step - locally. -- Git - -Ordinary managed work uses the checked-in Lua bridge and does not need a C toolchain. If you change [ -`native/cheatengine-sdk-lua-bridge`](native/cheatengine-sdk-lua-bridge/README.md), also install xmake and a Windows x64 -C toolchain. - -## Build and test - -Run these commands from the repository root: - -```powershell -dotnet restore CheatEngine.SDK.slnx --locked-mode -dotnet build CheatEngine.SDK.slnx -c Debug --no-restore -dotnet test --solution CheatEngine.SDK.slnx -c Debug --fail-skips on -dotnet test --solution CheatEngine.SDK.slnx -c Release --fail-skips on -``` - -A locked restore fails when a lock file no longer matches the projects; see -[Lock files and Dependabot](#lock-files-and-dependabot). Locally, the packaging tests pack the SDK themselves; in CI -they consume the exact package of the run. - -To create the package locally: - -```powershell -dotnet pack src/CheatEngine.SDK -c Release -o artifacts/nuget -``` - -The pack validates the API against the published CheatEngine.SDK 1.0.0 package, so it needs nuget.org once, and it -embeds the SPDX SBOM. - -For manual host validation, use the [live-plugin guide](tests/CheatEngine.SDK.LivePlugin/README.md). - -## Continuous integration - -Pull requests run `Pull request CI`, pushes to `main` run `Main CI`, and version tags run `Release`. All three call the -reusable [`ci.yml`](.github/workflows/ci.yml), which builds each thing once and passes it on as an artifact. Every job -runs on a pinned runner label (`windows-2025` or `ubuntu-24.04`), every restore is locked against the committed lock -files, and no job uses a NuGet cache. Every step is a direct `dotnet`/`xmake`/`gh` CLI call or a standard action, never -a bespoke script: run the commands in a job's steps locally to rehearse it. - -| Job | What it checks | -|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `native` | Builds the Lua protection bridge with the pinned xmake, MSVC toolset and Windows SDK; checks that the checked-in DLL was built from the checked-in sources; builds the classic ABI fixture facts. A CI-built DLL that differs from the checked-in one is a notice, not a failure. | -| `build-test` (Debug, Release) | Builds the solution once per configuration. Release packs first and checks the single nupkg, its nuspec identity, its SBOM and its bridge; the packaging tests then consume that exact file through `CESDK_PACKAGED_UMBRELLA_NUPKG`, and the same file is uploaded as `nuget-package`. Debug excludes the packaging tests by trait (`--filter-not-trait "Category=Packaging"`), compares the ABI fixture facts and collects coverage. | -| `aot` | Publishes and runs the Native AOT probes. | -| `native-host-emulator` | Builds the C2 hostfxr host emulator (`tests/native-host-emulator`) under the pinned MSVC toolset; the Debug `build-test` leg downloads it and runs `NativeHostEmulatorTests` against it. It never contacts or qualifies a live Cheat Engine host. | -| `sonar` | Analyzes the code with SonarQube Cloud from the Debug coverage. | -| `lint` | Runs actionlint and zizmor with offline audits, each pinned by version (and, for actionlint, checksum). | -| `format` | Verifies the whitespace formatting of every C# file, including projects outside the solution. | -| `dependency-review` | Reviews dependency changes of pull requests against `.github/dependency-review-config.yml`; other events record a notice. | -| `lock-files` | Restores the solution and every out-of-solution project with `--locked-mode`: the committed lock files must equal a fresh restore. | -| `gate` | Produces `CI / Gate` from the results of every job above. | - -Both `build-test` legs run every `tests/**/*.Tests` module in a single `dotnet test --solution` call with -`--fail-skips on`, and hang and crash dumps. A skipped test fails the run, and the packaging tests are excluded from -Debug by trait, never skipped. - -### Required checks - -`CI / Gate` is the only required check. There is no merge queue. - -`CI / Gate` requires every job to succeed, with one exception: `sonar` must run and pass exactly when -`SONAR_EXPECTED` is true, and must be skipped otherwise. It is false for fork and Dependabot pull requests, which -receive no secrets, for release runs, which never request Sonar, and for the dormant `merge_group` clause. A Sonar run -that was not expected fails the gate too, and no other job may be skipped. The quality gate fails pull requests and is -only reported on `main`. Drafts do not run CI until they are marked ready for review. - -Give the pull request an imperative title of at most 72 characters (no trailing period, no Conventional Commit or area -prefix): pull requests are squash-merged, and the title becomes the commit subject on `main`. Record consumer-visible -changes under `[Unreleased]` in [`CHANGELOG.md`](CHANGELOG.md) in the same pull request. - -Advisory workflows run outside the gate: CodeQL (C#, C/C++ and the workflows), OpenSSF Scorecard, the online zizmor -audits, and the NuGet dependency graph submission. CodeRabbit reviews every pull request, but its findings and -pre-merge checks are advisory. - -### Workflow changes - -- `WorkflowContractTests` in the - [`tests/CheatEngine.SDK.Repository.Tests`](tests/CheatEngine.SDK.Repository.Tests/README.md) project freeze the - pipeline: job ids and names, `gate.needs` (a job missing from it fails), SHA-pinned actions, pinned - runners, timeouts, locked restores and the reserved artifact names. Change a workflow and its tests in the same pull - request. -- Dependabot does not update `runs-on`. Move to a new runner image in one pull request that changes every workflow - together with the label lists of the Repository tests. - -### Flaky tests - -Required runs never retry a test. With `--fail-skips on` a skipped test fails the run, so a flaky test cannot be hidden -with `Skip`: fix it or delete it in the pull request that finds it. - -### Run the checks locally - -```powershell -dotnet format whitespace . --folder --verify-no-changes --exclude artifacts # the format job -actionlint # 1.7.12, from the repository root -zizmor --offline .github # 1.30.1, reads .github/zizmor.yml -dotnet restore CheatEngine.SDK.slnx --locked-mode # the lock-files job -``` - -### Running the native host emulator locally - -```powershell -./tests/native-host-emulator/build.ps1 -OutputDirectory artifacts/native-host-emulator -$env:CESDK_NATIVE_HOST_EMULATOR_DIR = (Resolve-Path artifacts/native-host-emulator).Path -$env:CESDK_NATIVE_HOST_EMULATOR_REQUIRED = 'true' -dotnet test tests/CheatEngine.SDK.Hosting.Tests/CheatEngine.SDK.Hosting.Tests.csproj -c Debug --filter-class "*NativeHostEmulatorTests" -``` - -Without the environment variables, the module is green through the same required-mode opt-out pattern as the classic -ABI fixture; with `CESDK_NATIVE_HOST_EMULATOR_REQUIRED` unset or `false`, an absent emulator directory is skipped, not -required. - -## Lua concurrency contract - -`LuaRuntime` admits Lua work only on the plugin's captured main thread by default (ADR-07), with one documented -exception: the worker-side half of `MainThread.Invoke`'s `synchronize` hand-off. Admitting arbitrary worker threads is -an explicit, `[Experimental("CESDK5001")]` opt-in (`LuaRuntime.AdmitWorkerThreads()`), held unqualified until Q19 -passes at both C3 (local qualification) and C4 (two-copy qualification) — see -[`libs/CheatEngine.SDK.Hosting/README.md`](libs/CheatEngine.SDK.Hosting/README.md) for the full contract text and -[`analyzers/docs/CESDK5001.md`](analyzers/docs/CESDK5001.md) for the diagnostic. An external `resetLuaState()` call the -SDK was not told about is detected deterministically and refuses old owners; there is no public SDK reset API. - -## Style and analyzers - -- Follow [`.editorconfig`](.editorconfig): UTF-8, tab-based C# indentation (spaces only for continuation alignment), and - two-space configuration/project-file indentation. [`.gitattributes`](.gitattributes) owns working-tree line-ending - normalization: CRLF, except the LF-pinned bridge inputs `cheatengine_sdk_lua_bridge.c` and `xmake.lua`, whose hashes - are embedded in the bridge DLL. -- Formatting is part of the build: `EnforceCodeStyleInBuild` turns the style rules, including IDE0055 formatting, into - errors. Run `dotnet format CheatEngine.SDK.slnx --no-restore` before committing; the `format` job also checks the - projects outside the solution. -- Use file-scoped namespaces, explicit accessibility, PascalCase public members, and the local naming patterns already - present. -- Public APIs require XML documentation. Builds treat compiler and analyzer diagnostics as errors, except for configured - exceptions. The analysis level is pinned (`10.0-recommended`) and moves only with the SDK. -- Do not use LINQ, including query expressions or `System.Linq` operators. Prefer explicit loops and collection APIs. -- Preserve native Lua identifiers and ABI layouts. Avoid unrelated refactors. - -The package includes analyzers and code fixes. See the [diagnostic reference](analyzers/docs/README.md) for the `CESDK` -rules and their fixes. - -## Public API and compatibility - -- The six shipping libraries under `libs/` track their public API in `PublicAPI.Shipped.txt`, the surface of the - published 1.0.0 package, and `PublicAPI.Unshipped.txt`, the delta. A public API change updates - `PublicAPI.Unshipped.txt` in the same commit (RS0016 and RS0017 fail the build otherwise). `PublicAPI.Shipped.txt` - changes only at a release. -- Every pack is validated against CheatEngine.SDK 1.0.0. An intentional break is declared in - `src/CheatEngine.SDK/CompatibilitySuppressions.xml`, with its `*REMOVED*` line and a CHANGELOG entry. The file is - regenerated locally by the maintainer who integrates the change, never by CI. -- An enum added since 1.0.0 that reports a status or an outcome starts with a neutral zero member (`Unknown`); enums - that mirror Cheat Engine constants keep their 1.0.0 members. - -`CompatibilitySuppressions.xml` is regenerated only by the integrator, locally, with -`dotnet pack src/CheatEngine.SDK -c Release -p:ApiCompatGenerateSuppressionFile=true`; CI never passes that property. - -## Lock files and Dependabot - -- Every project restores against a committed `packages.lock.json`. Regenerate one with - `dotnet restore --force-evaluate` (never combined with `--locked-mode`, NU1005), on Windows with the pinned - SDK, after any change to `Directory.Packages.props`, a package reference, a project file or `global.json`, and commit - the result on its own (`Regenerate lock files after `). Never edit a lock file by hand; on a merge conflict, - take either side and restore again. -- Dependabot NuGet pull requests do not regenerate the SDK-implicit entries: check out the branch - (`gh pr checkout `), restore each changed project with `--force-evaluate`, commit and push. -- For a Dependabot `dotnet-sdk` pull request, install the new SDK, restore every project with `--force-evaluate`, - make the `global.json` `errorMessage` name the new version, and update the documentation that names the SDK. - -## NuGet audit - -Restore audits every direct and transitive package. High and critical advisories (NU1903, NU1904) fail every build; -lower severities are warnings. An advisory suppression is a last resort: only in `Directory.Build.props`, with a -justification and an expiry date, and never in a stable release. - -## Repository guards - -The MSBuild guards `CESDK9003` to `CESDK9009` fail the build when the supply-chain policy is weakened: the PublicAPI -files, the analysis-level pin, lock files and Central Package Management, package validation, the major version that -declared breaks require, the SBOM, and the NuGet audit. `Directory.Build.targets` and `Directory.Build.props` give the -condition and the fix of each one, next to the guard itself. - -## Qualification evidence - -Evidence has five levels: C0 static contract, C1 managed tests, C2 native fixture, C3 the exact Cheat Engine host with -the plugin loaded, and C4 several components. A C1 or C2 result is never presented as host-qualified, and no document -states a global percentage. A test that evidences a scenario carries `[Trait("Qualification", "Qxx")]` naming the Qxx -scenario of the audit's register (Q01-Q48) and the level it reaches. There is no local exact-host qualification -runner or committed evidence tree in this repository; C3/C4 evidence, when gathered, is described in the pull request -and release notes. - -## Documentation - -Keep relative Markdown links exact-case and resolvable, and never restore or link the retired `documentations/` tree. -Narrative documentation (qualification protocol, catalogues, migration guides) is not recreated under a repository -`docs/` folder; it lives outside both repositories, under the maintainer's own notes. A README packed into the NuGet -package uses absolute `https://` links only. - -## Branches and pull requests - -1. Update your local `main`, then create a focused branch from it. -2. Make the smallest change that solves the problem. -3. Run the relevant build, test, and package commands. -4. Open a pull request against `main`; do not push directly to the protected branch. -5. Record consumer-visible changes under `[Unreleased]` in [`CHANGELOG.md`](CHANGELOG.md). - -Fill in the pull request template: state the problem, resulting behavior, validation commands and results, the -qualification level of the evidence, public API and release impact, and any remaining live-host limitations. Include -documentation changes that the work requires. Pull requests are squash-merged once `CI / Gate` passes, so the pull -request title becomes the commit subject on `main`. - -## Commits - -Use focused commits with an imperative subject of at most 72 characters, without a Conventional Commit prefix or a -trailing period, such as `Fix CI validation findings`. The body explains why. Regenerated lock files go in their own -commit. Do not add `Co-authored-by` trailers. - -## Security - -Report vulnerabilities privately, as [`SECURITY.md`](SECURITY.md) describes, never in a public issue, discussion or pull -request. - -## Releases - -Versions are derived by MinVer from the nearest `v*` tag; the current minimum major/minor line is `2.0`, as configured -in [`Directory.Build.props`](Directory.Build.props). Pushing a valid `v..` tag (an optional SemVer -prerelease is allowed) starts the draft-first release workflow. It builds and tests the tag, attests the package -(provenance and SPDX 2.2 SBOM), and creates a draft release with the package, the SBOM, `SHA256SUMS` and the sigstore -bundles. After manual approval on the `nuget` environment it publishes that exact package, verifies it on nuget.org, -and only then publishes the release, whose notes are the `CHANGELOG.md` section of that version. See -[`RELEASING.md`](RELEASING.md), including its [qualification](RELEASING.md#qualification) expectations for a stable -release. +# Contributing to CheatEngine.SDK + +Thanks for contributing. CheatEngine.SDK is a Windows x64, .NET 10 SDK for Cheat Engine 7.7 plugins. Keep changes +focused, preserve existing patterns, and update documentation when behavior or public APIs change. + +## Prerequisites + +- Windows x64 +- .NET SDK 10.0.404 exactly. [`global.json`](global.json) sets `rollForward: disable`, because the NuGet lock files + record the packages that the SDK adds implicitly. Install it with + `winget install Microsoft.DotNet.SDK.10 --version 10.0.404`. +- PowerShell 7 (`pwsh`): every workflow step runs in it (`defaults.run.shell: pwsh`); useful for rehearsing a CI step + locally. +- Git + +Ordinary managed work uses the checked-in Lua bridge and does not need a C toolchain. If you change [ +`native/cheatengine-sdk-lua-bridge`](native/cheatengine-sdk-lua-bridge/README.md), also install xmake and a Windows x64 +C toolchain. + +## Build and test + +Run these commands from the repository root: + +```powershell +dotnet restore CheatEngine.SDK.slnx --locked-mode +dotnet build CheatEngine.SDK.slnx -c Debug --no-restore +dotnet test --solution CheatEngine.SDK.slnx -c Debug --fail-skips on +dotnet test --solution CheatEngine.SDK.slnx -c Release --fail-skips on +``` + +A locked restore fails when a lock file no longer matches the projects; see +[Lock files and Dependabot](#lock-files-and-dependabot). Locally, the packaging tests pack the SDK themselves; in CI +they consume the exact package of the run. + +To create the package locally: + +```powershell +dotnet pack src/CheatEngine.SDK -c Release -o artifacts/nuget +``` + +The pack validates the API against the published CheatEngine.SDK 1.0.0 package, so it needs nuget.org once, and it +embeds the SPDX SBOM. + +For manual host validation, use the [live-plugin guide](tests/CheatEngine.SDK.LivePlugin/README.md). + +## Continuous integration + +Pull requests run `Pull request CI`, pushes to `main` run `Main CI`, and version tags run `Release`. All three call the +reusable [`ci.yml`](.github/workflows/ci.yml), which builds each thing once and passes it on as an artifact. Every job +runs on a pinned runner label (`windows-2025` or `ubuntu-24.04`), every restore is locked against the committed lock +files, and no job uses a NuGet cache. Every step is a direct `dotnet`/`xmake`/`gh` CLI call or a standard action, never +a bespoke script: run the commands in a job's steps locally to rehearse it. + +| Job | What it checks | +|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `native` | Builds the Lua protection bridge with the pinned xmake, MSVC toolset and Windows SDK; checks that the checked-in DLL was built from the checked-in sources; builds the classic ABI fixture facts. A CI-built DLL that differs from the checked-in one is a notice, not a failure. | +| `build-test` (Debug, Release) | Builds the solution once per configuration. Release packs first and checks the single nupkg, its nuspec identity, its SBOM and its bridge; the packaging tests then consume that exact file through `CESDK_PACKAGED_UMBRELLA_NUPKG`, and the same file is uploaded as `nuget-package`. Debug excludes the packaging tests by trait (`--filter-not-trait "Category=Packaging"`), compares the ABI fixture facts and collects coverage. | +| `aot` | Publishes and runs the Native AOT probes. | +| `native-host-emulator` | Builds the C2 hostfxr host emulator (`tests/native-host-emulator`) under the pinned MSVC toolset; the Debug `build-test` leg downloads it and runs `NativeHostEmulatorTests` against it. It never contacts or qualifies a live Cheat Engine host. | +| `sonar` | Analyzes the code with SonarQube Cloud from the Debug coverage. | +| `lint` | Runs actionlint and zizmor with offline audits, each pinned by version (and, for actionlint, checksum). | +| `format` | Verifies the whitespace formatting of every C# file, including projects outside the solution. | +| `dependency-review` | Reviews dependency changes of pull requests against `.github/dependency-review-config.yml`; other events record a notice. | +| `lock-files` | Restores the solution and every out-of-solution project with `--locked-mode`: the committed lock files must equal a fresh restore. | +| `gate` | Produces `CI / Gate` from the results of every job above. | + +Both `build-test` legs run every `tests/**/*.Tests` module in a single `dotnet test --solution` call with +`--fail-skips on`, and hang and crash dumps. A skipped test fails the run, and the packaging tests are excluded from +Debug by trait, never skipped. + +### Required checks + +`CI / Gate` is the only required check. There is no merge queue. + +`CI / Gate` requires every job to succeed, with one exception: `sonar` must run and pass exactly when +`SONAR_EXPECTED` is true, and must be skipped otherwise. It is false for fork and Dependabot pull requests, which +receive no secrets, for release runs, which never request Sonar, and for the dormant `merge_group` clause. A Sonar run +that was not expected fails the gate too, and no other job may be skipped. The quality gate fails pull requests and is +only reported on `main`. Drafts do not run CI until they are marked ready for review. + +Give the pull request an imperative title of at most 72 characters (no trailing period, no Conventional Commit or area +prefix): pull requests are squash-merged, and the title becomes the commit subject on `main`. Record consumer-visible +changes under `[Unreleased]` in [`CHANGELOG.md`](CHANGELOG.md) in the same pull request. + +Advisory workflows run outside the gate: CodeQL (C#, C/C++ and the workflows), OpenSSF Scorecard, the online zizmor +audits, and the NuGet dependency graph submission. CodeRabbit reviews every pull request, but its findings and +pre-merge checks are advisory. + +### Workflow changes + +- `WorkflowContractTests` in the + [`tests/CheatEngine.SDK.Repository.Tests`](tests/CheatEngine.SDK.Repository.Tests/README.md) project freeze the + pipeline: job ids and names, `gate.needs` (a job missing from it fails), SHA-pinned actions, pinned + runners, timeouts, locked restores and the reserved artifact names. Change a workflow and its tests in the same pull + request. +- Dependabot does not update `runs-on`. Move to a new runner image in one pull request that changes every workflow + together with the label lists of the Repository tests. + +### Flaky tests + +Required runs never retry a test. With `--fail-skips on` a skipped test fails the run, so a flaky test cannot be hidden +with `Skip`: fix it or delete it in the pull request that finds it. + +### Run the checks locally + +```powershell +dotnet format whitespace . --folder --verify-no-changes --exclude artifacts # the format job +actionlint # 1.7.12, from the repository root +zizmor --offline .github # 1.30.1, reads .github/zizmor.yml +dotnet restore CheatEngine.SDK.slnx --locked-mode # the lock-files job +``` + +### Running the native host emulator locally + +```powershell +./tests/native-host-emulator/build.ps1 -OutputDirectory artifacts/native-host-emulator +$env:CESDK_NATIVE_HOST_EMULATOR_DIR = (Resolve-Path artifacts/native-host-emulator).Path +$env:CESDK_NATIVE_HOST_EMULATOR_REQUIRED = 'true' +dotnet test tests/CheatEngine.SDK.Hosting.Tests/CheatEngine.SDK.Hosting.Tests.csproj -c Debug --filter-class "*NativeHostEmulatorTests" +``` + +Without the environment variables, the module is green through the same required-mode opt-out pattern as the classic +ABI fixture; with `CESDK_NATIVE_HOST_EMULATOR_REQUIRED` unset or `false`, an absent emulator directory is skipped, not +required. + +## Lua concurrency contract + +`LuaRuntime` admits Lua work only on the plugin's captured main thread by default (ADR-07), with one documented +exception: the worker-side half of `MainThread.Invoke`'s `synchronize` hand-off. Admitting arbitrary worker threads is +an explicit, `[Experimental("CESDK5001")]` opt-in (`LuaRuntime.AdmitWorkerThreads()`), held unqualified until Q19 +passes at both C3 (local qualification) and C4 (two-copy qualification) — see +[`libs/CheatEngine.SDK.Hosting/README.md`](libs/CheatEngine.SDK.Hosting/README.md) for the full contract text and +[`analyzers/docs/CESDK5001.md`](analyzers/docs/CESDK5001.md) for the diagnostic. An external `resetLuaState()` call the +SDK was not told about is detected deterministically and refuses old owners; there is no public SDK reset API. + +## Style and analyzers + +- Follow [`.editorconfig`](.editorconfig): UTF-8, tab-based C# indentation (spaces only for continuation alignment), and + two-space configuration/project-file indentation. [`.gitattributes`](.gitattributes) owns working-tree line-ending + normalization: CRLF, except the LF-pinned bridge inputs `cheatengine_sdk_lua_bridge.c` and `xmake.lua`, whose hashes + are embedded in the bridge DLL. +- Formatting is part of the build: `EnforceCodeStyleInBuild` turns the style rules, including IDE0055 formatting, into + errors. Run `dotnet format CheatEngine.SDK.slnx --no-restore` before committing; the `format` job also checks the + projects outside the solution. +- Use file-scoped namespaces, explicit accessibility, PascalCase public members, and the local naming patterns already + present. +- Public APIs require XML documentation. Builds treat compiler and analyzer diagnostics as errors, except for configured + exceptions. The analysis level is pinned (`10.0-recommended`) and moves only with the SDK. +- Do not use LINQ, including query expressions or `System.Linq` operators. Prefer explicit loops and collection APIs. +- Preserve native Lua identifiers and ABI layouts. Avoid unrelated refactors. + +The package includes analyzers and code fixes. See the [diagnostic reference](analyzers/docs/README.md) for the `CESDK` +rules and their fixes. + +## Public API and compatibility + +- The six shipping libraries under `libs/` track their public API in `PublicAPI.Shipped.txt`, the surface of the + published 1.0.0 package, and `PublicAPI.Unshipped.txt`, the delta. A public API change updates + `PublicAPI.Unshipped.txt` in the same commit (RS0016 and RS0017 fail the build otherwise). `PublicAPI.Shipped.txt` + changes only at a release. +- Every pack is validated against CheatEngine.SDK 1.0.0. An intentional break is declared in + `src/CheatEngine.SDK/CompatibilitySuppressions.xml`, with its `*REMOVED*` line and a CHANGELOG entry. The file is + regenerated locally by the maintainer who integrates the change, never by CI. +- An enum added since 1.0.0 that reports a status or an outcome starts with a neutral zero member (`Unknown`); enums + that mirror Cheat Engine constants keep their 1.0.0 members. + +`CompatibilitySuppressions.xml` is regenerated only by the integrator, locally, with +`dotnet pack src/CheatEngine.SDK -c Release -p:ApiCompatGenerateSuppressionFile=true`; CI never passes that property. + +## Lock files and Dependabot + +- Every project restores against a committed `packages.lock.json`. Regenerate one with + `dotnet restore --force-evaluate` (never combined with `--locked-mode`, NU1005), on Windows with the pinned + SDK, after any change to `Directory.Packages.props`, a package reference, a project file or `global.json`, and commit + the result on its own (`Regenerate lock files after `). Never edit a lock file by hand; on a merge conflict, + take either side and restore again. +- Dependabot NuGet pull requests do not regenerate the SDK-implicit entries: check out the branch + (`gh pr checkout `), restore each changed project with `--force-evaluate`, commit and push. +- For a Dependabot `dotnet-sdk` pull request, install the new SDK, restore every project with `--force-evaluate`, + make the `global.json` `errorMessage` name the new version, and update the documentation that names the SDK. + +## NuGet audit + +Restore audits every direct and transitive package. High and critical advisories (NU1903, NU1904) fail every build; +lower severities are warnings. An advisory suppression is a last resort: only in `Directory.Build.props`, with a +justification and an expiry date, and never in a stable release. + +## Repository guards + +The MSBuild guards `CESDK9003` to `CESDK9009` fail the build when the supply-chain policy is weakened: the PublicAPI +files, the analysis-level pin, lock files and Central Package Management, package validation, the major version that +declared breaks require, the SBOM, and the NuGet audit. `Directory.Build.targets` and `Directory.Build.props` give the +condition and the fix of each one, next to the guard itself. + +## Qualification evidence + +Evidence has five levels: C0 static contract, C1 managed tests, C2 native fixture, C3 the exact Cheat Engine host with +the plugin loaded, and C4 several components. A C1 or C2 result is never presented as host-qualified, and no document +states a global percentage. A test that evidences a scenario carries `[Trait("Qualification", "Qxx")]` naming the Qxx +scenario of the audit's register (Q01-Q48) and the level it reaches. There is no local exact-host qualification +runner or committed evidence tree in this repository; C3/C4 evidence, when gathered, is described in the pull request +and release notes. + +## Documentation + +Keep relative Markdown links exact-case and resolvable, and never restore or link the retired `documentations/` tree. +Narrative documentation (qualification protocol, catalogues, migration guides) is not recreated under a repository +`docs/` folder; it lives outside both repositories, under the maintainer's own notes. A README packed into the NuGet +package uses absolute `https://` links only. + +## Branches and pull requests + +1. Update your local `main`, then create a focused branch from it. +2. Make the smallest change that solves the problem. +3. Run the relevant build, test, and package commands. +4. Open a pull request against `main`; do not push directly to the protected branch. +5. Record consumer-visible changes under `[Unreleased]` in [`CHANGELOG.md`](CHANGELOG.md). + +Fill in the pull request template: state the problem, resulting behavior, validation commands and results, the +qualification level of the evidence, public API and release impact, and any remaining live-host limitations. Include +documentation changes that the work requires. Pull requests are squash-merged once `CI / Gate` passes, so the pull +request title becomes the commit subject on `main`. + +## Commits + +Use focused commits with an imperative subject of at most 72 characters, without a Conventional Commit prefix or a +trailing period, such as `Fix CI validation findings`. The body explains why. Regenerated lock files go in their own +commit. Do not add `Co-authored-by` trailers. + +## Security + +Report vulnerabilities privately, as [`SECURITY.md`](SECURITY.md) describes, never in a public issue, discussion or pull +request. + +## Releases + +Versions are derived by MinVer from the nearest `v*` tag; the current minimum major/minor line is `2.0`, as configured +in [`Directory.Build.props`](Directory.Build.props). Pushing a valid `v..` tag (an optional SemVer +prerelease is allowed) starts the draft-first release workflow. It builds and tests the tag, attests the package +(provenance and SPDX 2.2 SBOM), and creates a draft release with the package, the SBOM, `SHA256SUMS` and the sigstore +bundles. After manual approval on the `nuget` environment it publishes that exact package, verifies it on nuget.org, +and only then publishes the release, whose notes are the `CHANGELOG.md` section of that version. See +[`RELEASING.md`](RELEASING.md), including its [qualification](RELEASING.md#qualification) expectations for a stable +release. diff --git a/RELEASING.md b/RELEASING.md index c89b26a..824fcff 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,254 +1,254 @@ -# Releasing CheatEngine.SDK - -NuGet releases are produced by `.github/workflows/release.yml` from version tags. This document describes the chain, -how to prepare and publish a release, and how anyone can verify one afterwards. - -> **Release evidence.** The 2.0 line uses this release chain. The older 1.0.0 release predates it: its GitHub release -> carries the nupkg only (no SBOM or checksums) and is not immutable. There is no automated qualification gate: before -> tagging a stable release, the maintainer confirms against the audit's Q02-Q10, Q40 and Q41 register (analyses/20 of -> the audit dossier) that the release is not claiming host qualification it has not earned, and records any open row -> as a known limitation in the release notes. - -## Overview - -```text -verify ─► ci ─► attest ─► draft-release ─► publish ─► verify-publication ─► finalize-release - │ │ │ │ │ │ - │ │ │ │ │ └ Release published and verified - │ │ │ │ └ nuget.org serves the attested package, repository-signed - │ │ │ └ push to nuget.org after approval of the nuget environment - │ │ └ draft release that already carries every asset - │ └ SBOM and its attestation, provenance attestation, SHA256SUMS - └ build and test the tag in Debug and Release, pack once, test that exact nupkg -``` - -| Job | What it does | -|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `verify` | Checks the SemVer tag, that it points to the first-parent history of `main`, that the version is not on nuget.org yet, and extracts the release notes from `CHANGELOG.md`. | -| `ci` | Runs `ci.yml` on the tag. The Release leg packs `CheatEngine.SDK..nupkg` (the file name must match the tag), runs the packaging tests on that exact file (`CESDK_PACKAGED_UMBRELLA_NUPKG`), and uploads it as `nuget-package`. | -| `attest` | Extracts the SPDX 2.2 SBOM embedded in the nupkg, creates the SLSA provenance attestation and the SBOM attestation of the nupkg (predicate `https://spdx.dev/Document/v2.2`), verifies both, and writes `SHA256SUMS`. | -| `draft-release` | Creates a **draft** release that already carries every asset, or completes an existing draft. It never uploads to a published release. | -| `publish` | Waits for approval of the `nuget` environment, checks the nupkg against `SHA256SUMS`, logs in through NuGet trusted publishing and pushes. | -| `verify-publication` | Waits until nuget.org lists the version, downloads the repository-signed copy and checks it: `dotnet nuget verify --all`, and every zip entry byte-identical to the attested package except the added `.signature.p7s`. | -| `finalize-release` | Publishes the release, then verifies what a consumer downloads (`SHA256SUMS`, `gh release verify`, `gh attestation verify`). | - -The `nuget-package` artifact is the release artifact: the file the packaging tests consumed is the file that is -attested, attached to the release and pushed to nuget.org. Never upload a locally built package: nuget.org versions -are immutable. - -**Why draft-first.** Once an -[immutable release](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases) -is published, its tag cannot move and its assets cannot be added, changed or deleted, so every asset must be attached -to the draft. That is why the attestations are created before publication: the draft must carry their bundles. -`finalize-release` only flips the draft to published once nuget.org has served the attested package. - -## Package identities - -One release has three package identities: the attested asset, its NuGet content hash, and the nuget.org signed copy. -`verify-publication` checks all three exist and agree; none of them is written to a separate manifest. The published -1.0.0 is the worked example (verified on 2026-09-23): - -| Identity | What it is | 1.0.0 | -|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Attested asset SHA-256 | SHA-256 of the unsigned nupkg CI packed: the GitHub release asset and the subject of the attestations. | `99bf90101cd13e0183c94759e43badc6a1e719ffc3e2c9fd0b93490abdac0632` | -| NuGet content hash | SHA-512 (base64) of that same unsigned file. It is the `contentHash` consumer lock files store and validate on restore ([NU1403](https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu1403)). | `n7nHqZ8vzo7Vf20jF0fkh/jUtR3yo1TwRGpXE7ERxZeJ4C5S/Nsft4lqOg7zGwfsD5Nh9tTVgdw4PrybJRF0gA==` | -| nuget.org signed file | nuget.org [repository-signs every package](https://learn.microsoft.com/nuget/reference/signed-packages-reference), so the file it serves has different bytes: the same entries plus `.signature.p7s`. | SHA-256 `3e8c98583ac71af25a5bd7053e7583fbafcd196139fae7c0b04bae9b40a7cd33`, SHA-512 `1a2B/E6reX5e636hfdb+Zdj3kT6817DuNES1RWvprhRyuyztE/56Zk2iHOMQIKpGH+O2Va8rYJxXXXTVq5aN9Q==` | - -The 1.0.0 signed copy has 28 entries and the asset 27; every common entry is byte-identical, and -`dotnet nuget verify --all` on the signed copy reports the content hash above. The native bridge inside 1.0.0 -(`build/native/cheatengine-sdk-lua-bridge.dll`) has SHA-256 -`da08c2ba03019da3a8c432ef061d5d6133fd2169ba3a6a8e9ac903353856d994` and source fingerprint -`8a63e00c7dd941212e7ef8c13d8c97f73142c5154bfbe5dbc5459e7131bb789b:2871368515be4c6fd235e49e793d5557e7c50229fcc8fbfd903efd39f9b754a8`. - -## One-time setup - -### Trusted publishing - -Create an organization-owned trusted publishing policy under the `CheatEngine` organization at - with these exact values: - -| Field | Value | -|------------------|----------------------------------------| -| Policy owner | `CheatEngine` (organization) | -| Repository owner | `CheatEngineNet` | -| Repository | `CheatEngine.SDK` | -| Workflow file | `release.yml` | -| Environment | `nuget` | -| Scope | Push new packages and package versions | -| Package glob | `CheatEngine.SDK` | - -The GitHub `nuget` environment must contain an environment secret named `NUGET_USER`. Its value must be the exact -nuget.org username of the administrator who created the policy, currently `AriusII`, not the organization name and not -an email address. Organization membership alone does not make another username valid for that policy; if a different -administrator recreates it, update `NUGET_USER` to that policy creator. The workflow exchanges GitHub's OIDC token for a -short-lived NuGet API key through `NuGet/login` -([trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing)); it never stores a long-lived -NuGet API key. Because the policy names `release.yml` and `nuget`, the login and push steps must stay in the `publish` -job of that file, and the login runs right before the push because the temporary key lives one hour. - -### Repository settings - -The maintainer applies these settings directly in the repository's GitHub settings: - -- Environment `nuget`: the maintainers who approve publications as required reviewers, with self-review allowed - (`prevent_self_review: false`) while a single maintainer releases; no administrator bypass; deployments limited to - tags matching `v*.*.*`; the `NUGET_USER` secret. -- A tag ruleset on `v*`: release tags cannot be moved or deleted. -- Immutable releases: enable them **only after this `release.yml` is on `main`**. The previous workflow uploaded onto an - existing published release, which an immutable release refuses. Until they are enabled, `finalize-release` warns that - the release has no release attestation and skips `gh release verify`. - -As observed on 2026-09-23, the `nuget` environment had a branch policy only (no required reviewer) and immutable -releases were disabled. - -## Prepare a release - -1. **Changelog.** Move the completed entries from `[Unreleased]` to a `## [X.Y.Z] - YYYY-MM-DD` section of - `CHANGELOG.md` and add its link reference. The body of that section becomes the GitHub release notes: a stable tag - fails without it; a prerelease tag uses its own `## [X.Y.Z-rc.N]` section when present, otherwise `[Unreleased]`. - Keep the four kinds of change the audit distinguishes apart, because each one breaks consumers differently: - - `### Added`: extensions (a new wrapper, option or API); - - `### Changed`: semantic corrections (the meaning of a result or boolean, a Lua arity or index convention, the - allowed thread, ownership conditions, an error category); - - `### Security`: refusal hardening (an operation that used to proceed and is now refused); - - `### Deployment`: package, native bridge, runtime policy or load-profile changes. - - `### Removed` and `### Deprecated` are used as Keep a Changelog defines them. Add a `### Qualification waivers` - section when the [qualification gate](#qualification-gate) needs one. -2. **Version line.** The 2.0 line is set by `MinVerMinimumMajorMinor` in `Directory.Build.props` (`2.0`); the exact - version comes from the `v..` tag. -3. **API compatibility.** Every pack validates `lib/net10.0` against the published 1.0.0 package, and - `src/CheatEngine.SDK/CompatibilitySuppressions.xml` lists exactly the intentional breaks; nothing else may differ. - Every suppressed break has a `### Changed`, `### Removed` or `### Security` entry in the version's section. -4. **Local validation** from the repository root, with .NET SDK 10.0.403: - - ```powershell - dotnet restore CheatEngine.SDK.slnx --locked-mode - dotnet build CheatEngine.SDK.slnx -c Debug --no-restore - dotnet test --solution CheatEngine.SDK.slnx -c Debug --no-build --fail-skips on --filter-not-trait "Category=Packaging" - dotnet build-server shutdown - dotnet build CheatEngine.SDK.slnx -c Release --no-restore - dotnet pack src/CheatEngine.SDK -c Release -o artifacts/nuget -p:MinVerVersionOverride=2.0.0 --no-restore - $env:CESDK_PACKAGED_UMBRELLA_NUPKG = (Resolve-Path artifacts/nuget/CheatEngine.SDK.2.0.0.nupkg).Path - dotnet test --solution CheatEngine.SDK.slnx -c Release --no-build --fail-skips on - Remove-Item Env:CESDK_PACKAGED_UMBRELLA_NUPKG - ``` - - Replace `2.0.0` with the version you rehearse; the pack needs nuget.org once for package validation. The Release test - run consumes exactly the packed file, as CI's Release leg does - ([exact-package run](tests/CheatEngine.SDK.Tests/README.md#run-the-tests)). This local package is a rehearsal: never - upload or publish it. -5. **Merge** the release pull request (squash) once `CI / Gate` passes. - -## Qualification - -A stable release follows Checkpoint F of the audit: a user must know what they can load, with which version and which -limits. There is no automated gate for this: before tagging a stable release, the maintainer checks the audit's Q02-Q10, -Q40 and Q41 register (analyses/20 of the audit dossier) against what this tree actually qualifies, and adds a -`### Qualification waivers` section to the version's CHANGELOG entry for any row that stays open, as `- Qxx: `. -The waivers are part of the release notes, so every consumer sees them. - -C1 and C2 results are never presented as host qualification: a C1 cell never stands in for a required C3 level. - -## Dry run - -Start `Release` manually from a branch (**Actions → Release → Run workflow**, or -`gh workflow run release.yml --ref `). The dry run executes `verify` (a notice instead of the tag checks), the -full `ci`, and `attest` without attestations. It uploads `nuget-package` and `attestation-bundles` (SBOM and -`SHA256SUMS`), creates no draft and publishes nothing. - -## Publish - -The release commit must first land on the first-parent history of `main`; the workflow rejects a tag from another -commit. From an up-to-date `main` checkout: - -```powershell -git tag -a v2.0.0 -m "Release 2.0.0" -git push origin v2.0.0 -``` - -The tag starts the chain of the [overview](#overview). When `draft-release` finishes, the draft release already shows -the nupkg, the SBOM, both attestation bundles and `SHA256SUMS`. `publish` then waits for a required reviewer to -approve the `nuget` deployment on the run page. After the push, nuget.org validates and indexes the package, which can -take several minutes; `verify-publication` polls for up to 35 minutes. `finalize-release` publishes the GitHub release -only after nuget.org serves the attested package, and its step summary shows the immutability status and the asset -checksums. - -## Verify a release - -Anyone can check a release without trusting this repository's word: - -```powershell -$v = '2.0.0' -gh release download "v$v" -R CheatEngineNet/CheatEngine.SDK -D release -Set-Location release - -# Immutable release: the release attestation covers the tag, the commit and every asset. -gh release verify "v$v" -R CheatEngineNet/CheatEngine.SDK -gh release verify-asset "v$v" "CheatEngine.SDK.$v.nupkg" -R CheatEngineNet/CheatEngine.SDK - -# Build provenance and SBOM of the package, signed by this workflow for this tag. -$identity = @('-R', 'CheatEngineNet/CheatEngine.SDK', - '--signer-workflow', 'CheatEngineNet/CheatEngine.SDK/.github/workflows/release.yml', - '--source-ref', "refs/tags/v$v", '--deny-self-hosted-runners') -gh attestation verify "CheatEngine.SDK.$v.nupkg" @identity -gh attestation verify "CheatEngine.SDK.$v.nupkg" @identity --predicate-type https://spdx.dev/Document/v2.2 - -# Checksums (sha256sum -c SHA256SUMS on Linux and macOS). -Get-Content SHA256SUMS | ForEach-Object { - $hash, $name = $_ -split ' ', 2 - if ((Get-FileHash $name -Algorithm SHA256).Hash -ne $hash) { throw "$name does not match SHA256SUMS." } -} -``` - -- The attestation bundles attached to the release (`*.provenance.sigstore.json`, `*.sbom.sigstore.json`) let - `gh attestation verify` check an asset against a bundle file with `--bundle ` instead of fetching the - attestation from GitHub ([`gh attestation verify`](https://cli.github.com/manual/gh_attestation_verify), - [verifying a release](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/verifying-the-integrity-of-a-release)). -- A consumer lock file holds the NuGet content hash: the `contentHash` of `CheatEngine.SDK` in `packages.lock.json` - equals the base64 SHA-512 of the release asset - (`[Convert]::ToBase64String([Security.Cryptography.SHA512]::HashData([IO.File]::ReadAllBytes("CheatEngine.SDK.$v.nupkg")))`). -- `dotnet nuget verify --all` on the file downloaded from nuget.org reports a nuget.org repository signature and the - same - content hash ([`dotnet nuget verify`](https://learn.microsoft.com/dotnet/core/tools/dotnet-nuget-verify)). Never run - it - on the GitHub asset: that file is unsigned by design and fails with - [NU3004](https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu3004). -- The `verify-publication` job automates these nuget.org checks directly in the workflow. - -**Reproducibility.** The promise is at the level of the DLLs and the native bridge: MinVer stamps the tag version, -`ContinuousIntegrationBuild` normalizes paths, and the source fingerprint embedded in the bridge names its C source and -build script. The nupkg itself is not byte-reproducible, because the SBOM it embeds has a generated document namespace -and creation time. The attested nupkg is therefore the identity of a release; a rebuild from the tag reproduces its -assemblies and bridge, not the nupkg bytes. A packed bridge that differs from the committed, audited one -(`native/cheatengine-sdk-lua-bridge/bridge-audit-manifest.json`) is reported as drift, never hidden and never a -failure: CI rebuilds the bridge with its pinned toolset. - -## After a release - -On `main`, in one pull request after the release: - -1. Raise `MinVerMinimumMajorMinor` in `Directory.Build.props` to the next development line (after `v2.0.0`: `2.1`), so - untagged builds become `2.1.0-alpha.0.N`. -2. Set `PackageValidationBaselineVersion` in `src/CheatEngine.SDK/CheatEngine.SDK.csproj` to the released version. -3. Delete `src/CheatEngine.SDK/CompatibilitySuppressions.xml`: the new baseline already contains those changes. -4. For each shipping library, apply the `*REMOVED*` lines of `PublicAPI.Unshipped.txt` to `PublicAPI.Shipped.txt`, move - the other lines into `PublicAPI.Shipped.txt` (ordinally sorted), and leave `PublicAPI.Unshipped.txt` with its - `#nullable enable` header only. -5. Open a new empty `[Unreleased]` section in `CHANGELOG.md`. - -## Re-running a release - -Use **Re-run failed jobs** only. Completed jobs are not repeated and the re-run reuses the artifacts of the original -attempt, so the tested, attested, attached and pushed package stays the same file. Artifacts are kept 90 days: re-run -within that window. - -- A draft that misses assets receives them. -- A push of an existing version is skipped as a duplicate. -- A release that is already published is never uploaded to: when it carries the same assets, `draft-release` reports it - and succeeds, and `finalize-release` only verifies it. -- **Re-run all jobs** rebuilds a new nupkg (its SBOM differs), so `draft-release` refuses a draft that holds the earlier - one. If that draft was never published, delete it and re-run. Once the version is on nuget.org, a full re-run stops - in `verify`. -- If `verify-publication` times out while nuget.org is still validating, re-run it. If it reports a different package, - stop: do not publish the draft, and investigate the push. +# Releasing CheatEngine.SDK + +NuGet releases are produced by `.github/workflows/release.yml` from version tags. This document describes the chain, +how to prepare and publish a release, and how anyone can verify one afterwards. + +> **Release evidence.** The 2.0 line uses this release chain. The older 1.0.0 release predates it: its GitHub release +> carries the nupkg only (no SBOM or checksums) and is not immutable. There is no automated qualification gate: before +> tagging a stable release, the maintainer confirms against the audit's Q02-Q10, Q40 and Q41 register (analyses/20 of +> the audit dossier) that the release is not claiming host qualification it has not earned, and records any open row +> as a known limitation in the release notes. + +## Overview + +```text +verify ─► ci ─► attest ─► draft-release ─► publish ─► verify-publication ─► finalize-release + │ │ │ │ │ │ + │ │ │ │ │ └ Release published and verified + │ │ │ │ └ nuget.org serves the attested package, repository-signed + │ │ │ └ push to nuget.org after approval of the nuget environment + │ │ └ draft release that already carries every asset + │ └ SBOM and its attestation, provenance attestation, SHA256SUMS + └ build and test the tag in Debug and Release, pack once, test that exact nupkg +``` + +| Job | What it does | +|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `verify` | Checks the SemVer tag, that it points to the first-parent history of `main`, that the version is not on nuget.org yet, and extracts the release notes from `CHANGELOG.md`. | +| `ci` | Runs `ci.yml` on the tag. The Release leg packs `CheatEngine.SDK..nupkg` (the file name must match the tag), runs the packaging tests on that exact file (`CESDK_PACKAGED_UMBRELLA_NUPKG`), and uploads it as `nuget-package`. | +| `attest` | Extracts the SPDX 2.2 SBOM embedded in the nupkg, creates the SLSA provenance attestation and the SBOM attestation of the nupkg (predicate `https://spdx.dev/Document/v2.2`), verifies both, and writes `SHA256SUMS`. | +| `draft-release` | Creates a **draft** release that already carries every asset, or completes an existing draft. It never uploads to a published release. | +| `publish` | Waits for approval of the `nuget` environment, checks the nupkg against `SHA256SUMS`, logs in through NuGet trusted publishing and pushes. | +| `verify-publication` | Waits until nuget.org lists the version, downloads the repository-signed copy and checks it: `dotnet nuget verify --all`, and every zip entry byte-identical to the attested package except the added `.signature.p7s`. | +| `finalize-release` | Publishes the release, then verifies what a consumer downloads (`SHA256SUMS`, `gh release verify`, `gh attestation verify`). | + +The `nuget-package` artifact is the release artifact: the file the packaging tests consumed is the file that is +attested, attached to the release and pushed to nuget.org. Never upload a locally built package: nuget.org versions +are immutable. + +**Why draft-first.** Once an +[immutable release](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases) +is published, its tag cannot move and its assets cannot be added, changed or deleted, so every asset must be attached +to the draft. That is why the attestations are created before publication: the draft must carry their bundles. +`finalize-release` only flips the draft to published once nuget.org has served the attested package. + +## Package identities + +One release has three package identities: the attested asset, its NuGet content hash, and the nuget.org signed copy. +`verify-publication` checks all three exist and agree; none of them is written to a separate manifest. The published +1.0.0 is the worked example (verified on 2026-09-23): + +| Identity | What it is | 1.0.0 | +|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Attested asset SHA-256 | SHA-256 of the unsigned nupkg CI packed: the GitHub release asset and the subject of the attestations. | `99bf90101cd13e0183c94759e43badc6a1e719ffc3e2c9fd0b93490abdac0632` | +| NuGet content hash | SHA-512 (base64) of that same unsigned file. It is the `contentHash` consumer lock files store and validate on restore ([NU1403](https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu1403)). | `n7nHqZ8vzo7Vf20jF0fkh/jUtR3yo1TwRGpXE7ERxZeJ4C5S/Nsft4lqOg7zGwfsD5Nh9tTVgdw4PrybJRF0gA==` | +| nuget.org signed file | nuget.org [repository-signs every package](https://learn.microsoft.com/nuget/reference/signed-packages-reference), so the file it serves has different bytes: the same entries plus `.signature.p7s`. | SHA-256 `3e8c98583ac71af25a5bd7053e7583fbafcd196139fae7c0b04bae9b40a7cd33`, SHA-512 `1a2B/E6reX5e636hfdb+Zdj3kT6817DuNES1RWvprhRyuyztE/56Zk2iHOMQIKpGH+O2Va8rYJxXXXTVq5aN9Q==` | + +The 1.0.0 signed copy has 28 entries and the asset 27; every common entry is byte-identical, and +`dotnet nuget verify --all` on the signed copy reports the content hash above. The native bridge inside 1.0.0 +(`build/native/cheatengine-sdk-lua-bridge.dll`) has SHA-256 +`da08c2ba03019da3a8c432ef061d5d6133fd2169ba3a6a8e9ac903353856d994` and source fingerprint +`8a63e00c7dd941212e7ef8c13d8c97f73142c5154bfbe5dbc5459e7131bb789b:2871368515be4c6fd235e49e793d5557e7c50229fcc8fbfd903efd39f9b754a8`. + +## One-time setup + +### Trusted publishing + +Create an organization-owned trusted publishing policy under the `CheatEngine` organization at + with these exact values: + +| Field | Value | +|------------------|----------------------------------------| +| Policy owner | `CheatEngine` (organization) | +| Repository owner | `CheatEngineNet` | +| Repository | `CheatEngine.SDK` | +| Workflow file | `release.yml` | +| Environment | `nuget` | +| Scope | Push new packages and package versions | +| Package glob | `CheatEngine.SDK` | + +The GitHub `nuget` environment must contain an environment secret named `NUGET_USER`. Its value must be the exact +nuget.org username of the administrator who created the policy, currently `AriusII`, not the organization name and not +an email address. Organization membership alone does not make another username valid for that policy; if a different +administrator recreates it, update `NUGET_USER` to that policy creator. The workflow exchanges GitHub's OIDC token for a +short-lived NuGet API key through `NuGet/login` +([trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing)); it never stores a long-lived +NuGet API key. Because the policy names `release.yml` and `nuget`, the login and push steps must stay in the `publish` +job of that file, and the login runs right before the push because the temporary key lives one hour. + +### Repository settings + +The maintainer applies these settings directly in the repository's GitHub settings: + +- Environment `nuget`: the maintainers who approve publications as required reviewers, with self-review allowed + (`prevent_self_review: false`) while a single maintainer releases; no administrator bypass; deployments limited to + tags matching `v*.*.*`; the `NUGET_USER` secret. +- A tag ruleset on `v*`: release tags cannot be moved or deleted. +- Immutable releases: enable them **only after this `release.yml` is on `main`**. The previous workflow uploaded onto an + existing published release, which an immutable release refuses. Until they are enabled, `finalize-release` warns that + the release has no release attestation and skips `gh release verify`. + +As observed on 2026-09-23, the `nuget` environment had a branch policy only (no required reviewer) and immutable +releases were disabled. + +## Prepare a release + +1. **Changelog.** Move the completed entries from `[Unreleased]` to a `## [X.Y.Z] - YYYY-MM-DD` section of + `CHANGELOG.md` and add its link reference. The body of that section becomes the GitHub release notes: a stable tag + fails without it; a prerelease tag uses its own `## [X.Y.Z-rc.N]` section when present, otherwise `[Unreleased]`. + Keep the four kinds of change the audit distinguishes apart, because each one breaks consumers differently: + - `### Added`: extensions (a new wrapper, option or API); + - `### Changed`: semantic corrections (the meaning of a result or boolean, a Lua arity or index convention, the + allowed thread, ownership conditions, an error category); + - `### Security`: refusal hardening (an operation that used to proceed and is now refused); + - `### Deployment`: package, native bridge, runtime policy or load-profile changes. + + `### Removed` and `### Deprecated` are used as Keep a Changelog defines them. Add a `### Qualification waivers` + section when the [qualification gate](#qualification-gate) needs one. +2. **Version line.** The 2.0 line is set by `MinVerMinimumMajorMinor` in `Directory.Build.props` (`2.0`); the exact + version comes from the `v..` tag. +3. **API compatibility.** Every pack validates `lib/net10.0` against the published 1.0.0 package, and + `src/CheatEngine.SDK/CompatibilitySuppressions.xml` lists exactly the intentional breaks; nothing else may differ. + Every suppressed break has a `### Changed`, `### Removed` or `### Security` entry in the version's section. +4. **Local validation** from the repository root, with .NET SDK 10.0.404: + + ```powershell + dotnet restore CheatEngine.SDK.slnx --locked-mode + dotnet build CheatEngine.SDK.slnx -c Debug --no-restore + dotnet test --solution CheatEngine.SDK.slnx -c Debug --no-build --fail-skips on --filter-not-trait "Category=Packaging" + dotnet build-server shutdown + dotnet build CheatEngine.SDK.slnx -c Release --no-restore + dotnet pack src/CheatEngine.SDK -c Release -o artifacts/nuget -p:MinVerVersionOverride=2.0.0 --no-restore + $env:CESDK_PACKAGED_UMBRELLA_NUPKG = (Resolve-Path artifacts/nuget/CheatEngine.SDK.2.0.0.nupkg).Path + dotnet test --solution CheatEngine.SDK.slnx -c Release --no-build --fail-skips on + Remove-Item Env:CESDK_PACKAGED_UMBRELLA_NUPKG + ``` + + Replace `2.0.0` with the version you rehearse; the pack needs nuget.org once for package validation. The Release test + run consumes exactly the packed file, as CI's Release leg does + ([exact-package run](tests/CheatEngine.SDK.Tests/README.md#run-the-tests)). This local package is a rehearsal: never + upload or publish it. +5. **Merge** the release pull request (squash) once `CI / Gate` passes. + +## Qualification + +A stable release follows Checkpoint F of the audit: a user must know what they can load, with which version and which +limits. There is no automated gate for this: before tagging a stable release, the maintainer checks the audit's Q02-Q10, +Q40 and Q41 register (analyses/20 of the audit dossier) against what this tree actually qualifies, and adds a +`### Qualification waivers` section to the version's CHANGELOG entry for any row that stays open, as `- Qxx: `. +The waivers are part of the release notes, so every consumer sees them. + +C1 and C2 results are never presented as host qualification: a C1 cell never stands in for a required C3 level. + +## Dry run + +Start `Release` manually from a branch (**Actions → Release → Run workflow**, or +`gh workflow run release.yml --ref `). The dry run executes `verify` (a notice instead of the tag checks), the +full `ci`, and `attest` without attestations. It uploads `nuget-package` and `attestation-bundles` (SBOM and +`SHA256SUMS`), creates no draft and publishes nothing. + +## Publish + +The release commit must first land on the first-parent history of `main`; the workflow rejects a tag from another +commit. From an up-to-date `main` checkout: + +```powershell +git tag -a v2.0.0 -m "Release 2.0.0" +git push origin v2.0.0 +``` + +The tag starts the chain of the [overview](#overview). When `draft-release` finishes, the draft release already shows +the nupkg, the SBOM, both attestation bundles and `SHA256SUMS`. `publish` then waits for a required reviewer to +approve the `nuget` deployment on the run page. After the push, nuget.org validates and indexes the package, which can +take several minutes; `verify-publication` polls for up to 35 minutes. `finalize-release` publishes the GitHub release +only after nuget.org serves the attested package, and its step summary shows the immutability status and the asset +checksums. + +## Verify a release + +Anyone can check a release without trusting this repository's word: + +```powershell +$v = '2.0.0' +gh release download "v$v" -R CheatEngineNet/CheatEngine.SDK -D release +Set-Location release + +# Immutable release: the release attestation covers the tag, the commit and every asset. +gh release verify "v$v" -R CheatEngineNet/CheatEngine.SDK +gh release verify-asset "v$v" "CheatEngine.SDK.$v.nupkg" -R CheatEngineNet/CheatEngine.SDK + +# Build provenance and SBOM of the package, signed by this workflow for this tag. +$identity = @('-R', 'CheatEngineNet/CheatEngine.SDK', + '--signer-workflow', 'CheatEngineNet/CheatEngine.SDK/.github/workflows/release.yml', + '--source-ref', "refs/tags/v$v", '--deny-self-hosted-runners') +gh attestation verify "CheatEngine.SDK.$v.nupkg" @identity +gh attestation verify "CheatEngine.SDK.$v.nupkg" @identity --predicate-type https://spdx.dev/Document/v2.2 + +# Checksums (sha256sum -c SHA256SUMS on Linux and macOS). +Get-Content SHA256SUMS | ForEach-Object { + $hash, $name = $_ -split ' ', 2 + if ((Get-FileHash $name -Algorithm SHA256).Hash -ne $hash) { throw "$name does not match SHA256SUMS." } +} +``` + +- The attestation bundles attached to the release (`*.provenance.sigstore.json`, `*.sbom.sigstore.json`) let + `gh attestation verify` check an asset against a bundle file with `--bundle ` instead of fetching the + attestation from GitHub ([`gh attestation verify`](https://cli.github.com/manual/gh_attestation_verify), + [verifying a release](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/verifying-the-integrity-of-a-release)). +- A consumer lock file holds the NuGet content hash: the `contentHash` of `CheatEngine.SDK` in `packages.lock.json` + equals the base64 SHA-512 of the release asset + (`[Convert]::ToBase64String([Security.Cryptography.SHA512]::HashData([IO.File]::ReadAllBytes("CheatEngine.SDK.$v.nupkg")))`). +- `dotnet nuget verify --all` on the file downloaded from nuget.org reports a nuget.org repository signature and the + same + content hash ([`dotnet nuget verify`](https://learn.microsoft.com/dotnet/core/tools/dotnet-nuget-verify)). Never run + it + on the GitHub asset: that file is unsigned by design and fails with + [NU3004](https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu3004). +- The `verify-publication` job automates these nuget.org checks directly in the workflow. + +**Reproducibility.** The promise is at the level of the DLLs and the native bridge: MinVer stamps the tag version, +`ContinuousIntegrationBuild` normalizes paths, and the source fingerprint embedded in the bridge names its C source and +build script. The nupkg itself is not byte-reproducible, because the SBOM it embeds has a generated document namespace +and creation time. The attested nupkg is therefore the identity of a release; a rebuild from the tag reproduces its +assemblies and bridge, not the nupkg bytes. A packed bridge that differs from the committed, audited one +(`native/cheatengine-sdk-lua-bridge/bridge-audit-manifest.json`) is reported as drift, never hidden and never a +failure: CI rebuilds the bridge with its pinned toolset. + +## After a release + +On `main`, in one pull request after the release: + +1. Raise `MinVerMinimumMajorMinor` in `Directory.Build.props` to the next development line (after `v2.0.0`: `2.1`), so + untagged builds become `2.1.0-alpha.0.N`. +2. Set `PackageValidationBaselineVersion` in `src/CheatEngine.SDK/CheatEngine.SDK.csproj` to the released version. +3. Delete `src/CheatEngine.SDK/CompatibilitySuppressions.xml`: the new baseline already contains those changes. +4. For each shipping library, apply the `*REMOVED*` lines of `PublicAPI.Unshipped.txt` to `PublicAPI.Shipped.txt`, move + the other lines into `PublicAPI.Shipped.txt` (ordinally sorted), and leave `PublicAPI.Unshipped.txt` with its + `#nullable enable` header only. +5. Open a new empty `[Unreleased]` section in `CHANGELOG.md`. + +## Re-running a release + +Use **Re-run failed jobs** only. Completed jobs are not repeated and the re-run reuses the artifacts of the original +attempt, so the tested, attested, attached and pushed package stays the same file. Artifacts are kept 90 days: re-run +within that window. + +- A draft that misses assets receives them. +- A push of an existing version is skipped as a duplicate. +- A release that is already published is never uploaded to: when it carries the same assets, `draft-release` reports it + and succeeds, and `finalize-release` only verifies it. +- **Re-run all jobs** rebuilds a new nupkg (its SBOM differs), so `draft-release` refuses a draft that holds the earlier + one. If that draft was never published, delete it and re-run. Once the version is on nuget.org, a full re-run stops + in `verify`. +- If `verify-publication` times out while nuget.org is still validating, re-run it. If it reports a different package, + stop: do not publish the draft, and investigate the push. diff --git a/global.json b/global.json index 2434f4a..bc3aac0 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,11 @@ -{ - "sdk": { - "version": "10.0.403", - "rollForward": "disable", - "allowPrerelease": false, - "errorMessage": "CheatEngine.SDK builds only with .NET SDK 10.0.403 exactly (global.json rollForward: disable, NuGet lock files). Install it with: winget install Microsoft.DotNet.SDK.10 --version 10.0.403" - }, - "test": { - "runner": "Microsoft.Testing.Platform" - } -} +{ + "sdk": { + "version": "10.0.404", + "rollForward": "disable", + "allowPrerelease": false, + "errorMessage": "CheatEngine.SDK builds only with .NET SDK 10.0.404 exactly (global.json rollForward: disable, NuGet lock files). Install it with: winget install Microsoft.DotNet.SDK.10 --version 10.0.404" + }, + "test": { + "runner": "Microsoft.Testing.Platform" + } +}