diff --git a/.gitattributes b/.gitattributes index a499574a..dfe07704 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,40 +1,2 @@ # Auto detect text files and perform LF normalization * text=auto - -# Shell scripts keep LF in the working tree as well as in the index. Left to -# `text=auto`, a Windows clone writes them with carriage returns, and the -# documented Linux path then dies inside the container in under a second: the -# shebang reads as the interpreter `bash\r`, which does not exist. Nothing about -# that failure names line endings, and the same clone builds and tests fine -# everywhere else, so it reads as a broken image rather than a broken checkout. -# -# A clone checked out before this rule keeps its carriage returns, because the -# blob is unchanged and git has no reason to rewrite the file. The one-line -# repair is in native/GameCult.Mesh.Quic.Native/README.md, beside the container -# path it unblocks. -*.sh text eol=lf - -# The committed CultMesh QUIC native binaries (cut 6, packaging) ride the -# deploy `git archive` as raw bytes. `* text=auto` already autodetects them as -# binary by content, but that autodetection is a heuristic; say so explicitly -# so no future text-processing rule (a diff driver, an export filter) can -# apply text conversion and poison the committed digests in SHA256SUMS. -packages/cultmesh-ts/native/**/*.dll binary -packages/cultmesh-ts/native/**/*.so binary -packages/cultmesh-ts/native/**/*.so.* binary - -# The digest list and manifest beside them keep LF on every checkout. Left to -# `text=auto`, a Windows clone writes them with carriage returns, and the -# documented `sha256sum -c SHA256SUMS` then fails on every line (each filename -# ends in `\r`) while CI, checking out on Linux, stays green. -packages/cultmesh-ts/native/SHA256SUMS text eol=lf -packages/cultmesh-ts/native/MANIFEST.txt text eol=lf - -# CultMath source keeps CRLF in the working tree on every checkout. The release -# gate compares the CultMath.dll it builds with the one org.gamecult.cultmath -# tracks, byte for byte, and the bytes follow the checkout's line endings: the -# pdb's document checksums feed the DLL's pdb id, timestamp and MVID. The -# tracked DLL was built from CRLF source, so CRLF here keeps it valid, and an -# LF-configured or Linux clone builds the same bytes as a Windows one. The index -# stays LF; only the checkout changes. -packages/cultmath/src/** text eol=crlf diff --git a/.github/workflows/cultmesh-portability.yml b/.github/workflows/cultmesh-portability.yml index 520a4836..ce361fc8 100644 --- a/.github/workflows/cultmesh-portability.yml +++ b/.github/workflows/cultmesh-portability.yml @@ -95,46 +95,3 @@ jobs: dotnet test tests/GameCult.Mesh.Tests/GameCult.Mesh.Tests.csproj --filter FullyQualifiedName~Document_OneHundredThousandDistinctLeaseCyclesLeaveNoResourcesOrCallbacks --logger "console;verbosity=minimal" - - # The TypeScript side of the CultMesh authority rules. This job is the - # only one that runs on both Windows and Linux for main, codex/** and - # pull requests: cultnet-interop.yml is windows-latest and main-only, so - # until these steps existed the shared verifier's tests never ran on - # Linux at all, and the browser client's never ran in CI on any OS. - # packages/cultnet-ts verifies both vector files; cultmesh-browser proves - # the browser client reads the shared rules rather than its own. - - name: Verify the CultMesh authority rules with the TypeScript verifier - run: npm run test --workspace packages/cultnet-ts - - - name: Verify the browser client against the shared TypeScript verifier - run: npm run test --workspace packages/cultmesh-browser - - # The realtime frame codec. Its byte parity rests on two vector files, - # contracts/cultmesh/realtime-frame-vectors.json written by the C# - # reference and decoded by this step, and realtime-frame-vectors.ts-written.json - # written by this codec and decoded by the C# step below. Neither half ran - # in CI on any OS until these two steps existed, so a codec that agreed - # only with itself would have gone green. - - name: Verify the realtime frame codec with the TypeScript codec - run: npm run test --workspace packages/cultmesh-ts - - # Both directions of the CultMesh authority vectors: the C#-written - # file (contracts/cultmesh/authority-route-vectors.json) and the - # TypeScript-signed file (authority-route-vectors.ts-signed.json) are - # verified by the C# reference here; the TypeScript side verifies both - # in the step above. CULTMESH_WRITE_VECTORS is never set in CI: the - # committed files are the contract. - - name: Verify the CultMesh authority vectors with the C# reference - run: >- - dotnet test tests/GameCult.Mesh.Tests/GameCult.Mesh.Tests.csproj - --filter FullyQualifiedName~AuthorityProof - --logger "console;verbosity=minimal" - - # The other half of the frame parity: the C# reference decodes and - # re-encodes the vector file the TypeScript codec wrote. A fixture - # authored on one side alone would only agree with itself. - - name: Verify the realtime frame vectors with the C# reference - run: >- - dotnet test tests/GameCult.Mesh.Tests/GameCult.Mesh.Tests.csproj - --filter FullyQualifiedName~RealtimeWireProtocol - --logger "console;verbosity=minimal" diff --git a/.github/workflows/cultnet-interop.yml b/.github/workflows/cultnet-interop.yml index 9072e0cb..6876a76a 100644 --- a/.github/workflows/cultnet-interop.yml +++ b/.github/workflows/cultnet-interop.yml @@ -12,13 +12,6 @@ jobs: name: C# / TypeScript / Rust / Python / Kotlin runs-on: windows-latest timeout-minutes: 60 - # Windows runners default to pwsh, which does not stop when a native command fails: a - # multi-command step reported only its last command, and a failing cultnet-py suite - # went green that way. Git Bash runs as `bash -e -o pipefail`, so every command counts. - # Steps that name `shell: pwsh` check $LASTEXITCODE themselves. - defaults: - run: - shell: bash env: DOTNET: dotnet @@ -72,36 +65,6 @@ jobs: "KOTLIN_JAVA_HOME=$env:JAVA_HOME" | Out-File -FilePath $env:GITHUB_ENV -Append "$kotlinHome\bin" | Out-File -FilePath $env:GITHUB_PATH -Append - - name: Verify CultNet schema contracts stayed consolidated - shell: pwsh - run: | - $ErrorActionPreference = "Stop" - # packages/cultnet-rs/contracts/cultnet/ holds R-AB's vendored byte copies (the crate must build - # when copied alone). Their drift guard is packages/cultnet-rs/tests/schema_discovery_contracts.rs:74-99. - $tracked = git ls-files '*.schema.json' - if ($LASTEXITCODE -ne 0) { throw "git ls-files failed" } - $stray = $tracked | Where-Object { $_ -notmatch '^(packages/cultnet-rs/)?contracts/cultnet/' } - # -I skips binary files: unity/org.gamecult.cultlib/Runtime/Plugins/GameCult.Networking.dll - # still embeds the retired namespace until it is rebuilt (REC-032 D4, deferred). - $oldNamespace = git grep -I -lE 'GameCult/cultnet-ts/(integration/)?contracts' -- ':!.voidbot' - if ($LASTEXITCODE -eq 2) { - throw "git grep failed" - } - if ($stray) { - Write-Host "Schema files found outside contracts/cultnet/:" - $stray | ForEach-Object { Write-Host " $_" } - } - if ($oldNamespace) { - Write-Host "Files still referencing the retired GameCult/cultnet-ts contracts namespace:" - $oldNamespace | ForEach-Object { Write-Host " $_" } - } - if ($stray -or $oldNamespace) { - throw "CultNet schema contracts drifted out of contracts/cultnet/ (REC-032). See CultLib/contracts/cultnet/ and rewrite any `$id back to https://github.com/GameCult/CultLib/contracts/cultnet/." - } - # git grep exits 1 when nothing matches, and the runner's pwsh wrapper - # ends the step with that $LASTEXITCODE; a clean tree must pass. - exit 0 - - name: Install Node dependencies run: npm install --no-package-lock diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index eb798bdf..6061ca7a 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -10,8 +10,8 @@ name: Publish packages # # Tag a release to publish, for example `cultcache-ts-v0.13.6` or # `cultnet-py-v0.1.0`. The tag's version must match the version in the package -# manifest; scripts/release-after-suite.mjs refuses the release otherwise rather -# than shipping a mislabelled artifact. +# manifest; the workflow refuses the publish otherwise rather than shipping a +# mislabelled artifact. on: push: @@ -42,12 +42,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: - # fetch-depth: 0 so the semver check in the release step can see every previously - # published tag, not just the one that triggered this run. - name: Check out CultLib uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Node uses: actions/setup-node@v4 @@ -55,30 +51,29 @@ jobs: node-version: 24.x registry-url: https://registry.npmjs.org - # The release-checks suite, which Publish runs, needs .NET for the API gate. - - name: Set up .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 10.0.x - - name: Install workspace dependencies run: npm ci - # Manual runs publish nothing, so they build and test here. A tag run's - # Publish runs these tests itself. + - name: Verify the tag matches the manifest version + if: startsWith(github.ref, 'refs/tags/cultcache-ts-v') + run: | + manifest="$(node -p "require('./packages/cultcache-ts/package.json').version")" + tagged="${GITHUB_REF_NAME#cultcache-ts-v}" + if [ "$manifest" != "$tagged" ]; then + echo "tag $GITHUB_REF_NAME does not match manifest version $manifest" >&2 + exit 1 + fi + - name: Build and test - if: ${{ !startsWith(github.ref, 'refs/tags/') }} working-directory: packages/cultcache-ts run: npm test - # One process checks that the tag is the manifest version, runs the - # release-checks suite, the semver policy check (docs/semver-policy.md) - # and npm test, and only then runs npm publish --access public. Only - # npm publish receives the token. It starts without NODE_OPTIONS, so no - # preloaded module runs inside it. + # Scoped packages default to restricted even on public npm, and this is + # MIT like the rest of the repo, so say public explicitly. - name: Publish if: startsWith(github.ref, 'refs/tags/cultcache-ts-v') - run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs npm-publish packages/cultcache-ts "$GITHUB_REF" + working-directory: packages/cultcache-ts + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -110,13 +105,9 @@ jobs: echo "run=false" >> "$GITHUB_OUTPUT" fi - # fetch-depth: 0 so the semver check in the release step can see every previously - # published tag, not just the one that triggered this run. - name: Check out CultLib if: steps.selected.outputs.run == 'true' uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Python if: steps.selected.outputs.run == 'true' @@ -124,33 +115,29 @@ jobs: with: python-version: "3.12" - - name: Set up Node - if: steps.selected.outputs.run == 'true' - uses: actions/setup-node@v4 - with: - node-version: 24.x - - - name: Set up .NET - if: steps.selected.outputs.run == 'true' - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 10.0.x + - name: Verify the tag matches the manifest version + if: steps.selected.outputs.run == 'true' && startsWith(github.ref, 'refs/tags/') + run: | + manifest="$(python -c "import tomllib,pathlib;print(tomllib.loads(pathlib.Path('packages/${{ matrix.package }}/pyproject.toml').read_text())['project']['version'])")" + tagged="${GITHUB_REF_NAME#${{ matrix.package }}-v}" + if [ "$manifest" != "$tagged" ]; then + echo "tag $GITHUB_REF_NAME does not match manifest version $manifest" >&2 + exit 1 + fi # Lower layers install from source so a release of one package is tested # against the sibling revision it was cut with, not whatever PyPI has. - - name: Install + - name: Install and test if: steps.selected.outputs.run == 'true' - run: python -m pip install --upgrade build -e packages/cultcache-py -e packages/cultnet-py -e packages/cultmesh-py + run: | + python -m pip install -e packages/cultcache-py -e packages/cultnet-py -e packages/cultmesh-py + python -m unittest discover -s packages/${{ matrix.package }}/tests - # One process checks, on a tag, that the tag is the manifest version, runs - # the release-checks suite, on a tag the semver policy check - # (docs/semver-policy.md), and the package's unit tests, and only then - # builds the sdist and wheel. Publish uploads only what this step built, - # so it has nothing to upload unless every check passed. It starts without - # NODE_OPTIONS, so no preloaded module runs inside it. - name: Build sdist and wheel if: steps.selected.outputs.run == 'true' - run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} "$GITHUB_REF" + run: | + python -m pip install --upgrade build + python -m build packages/${{ matrix.package }} - name: Publish if: steps.selected.outputs.run == 'true' && startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/quic-native.yml b/.github/workflows/quic-native.yml deleted file mode 100644 index 9b16cbeb..00000000 --- a/.github/workflows/quic-native.yml +++ /dev/null @@ -1,202 +0,0 @@ -name: CultMesh QUIC native - -# Builds and, on a tag, releases the CultMesh QUIC native binaries that -# packages/cultmesh-ts/native/{win32-x64,linux-x64} commits (cut 6, -# docs/typescript-quic-realtime-cut.md:2108-2159). Under Q8 Option 1 the -# operator downloads a tagged run's Release assets, verifies every digest -# against this workflow's own logs and SHA256SUMS, and commits the bytes; -# nothing here writes to the tree. Under Q6 A, the Linux artifact comes only -# from the pinned debian:13 container below, never from a local or Yggdrasil -# build. - -on: - push: - branches: - - main - tags: - - "cultmesh-quic-native-v*" - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - # Push to main and pull_request run this job only: it proves the tree's - # committed bytes still match the manifest they shipped with. A tag push - # also runs it, alongside the two builds and the release. - verify-committed: - name: Verify committed binaries match SHA256SUMS - if: >- - github.event_name == 'pull_request' || - (github.event_name == 'push' && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/cultmesh-quic-native-v'))) - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - name: Check out CultLib - uses: actions/checkout@v4 - - - name: sha256sum -c SHA256SUMS - run: | - set -euo pipefail - if [ ! -f packages/cultmesh-ts/native/SHA256SUMS ]; then - echo "packages/cultmesh-ts/native/SHA256SUMS is missing" >&2 - exit 1 - fi - cd packages/cultmesh-ts/native - sha256sum -c SHA256SUMS - - # workflow_dispatch and a cultmesh-quic-native-v* tag run the two builds. - # A dry (workflow_dispatch) run uploads artifacts and creates no release. - build-win32-x64: - name: Build win32-x64 - if: >- - github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cultmesh-quic-native-v')) - runs-on: windows-latest - timeout-minutes: 20 - steps: - - name: Check out CultLib - uses: actions/checkout@v4 - - - name: Build the native QUIC bridge - shell: pwsh - run: .\scripts\build-quic-native.ps1 -OutputDirectory artifacts\quic-native\win32-x64 - - - name: Print toolchain version and digests - shell: pwsh - run: | - $ErrorActionPreference = "Stop" - $compilerCmake = Get-ChildItem -Recurse -LiteralPath "artifacts\quic-native-build\x64\Release" -Filter "CMakeCXXCompiler.cmake" | - Select-Object -First 1 - if ($compilerCmake) { - Select-String -LiteralPath $compilerCmake.FullName -Pattern "CMAKE_CXX_COMPILER_VERSION" | - ForEach-Object { Write-Host $_.Line.Trim() } - } - Get-FileHash -Algorithm SHA256 artifacts\quic-native\win32-x64\gamecult_mesh_quic_native.dll - Get-FileHash -Algorithm SHA256 artifacts\quic-native\win32-x64\msquic.dll - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: quic-native-win32-x64 - path: artifacts/quic-native/win32-x64 - if-no-files-found: error - - build-linux-x64: - name: Build linux-x64 - if: >- - github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cultmesh-quic-native-v')) - runs-on: ubuntu-latest - # Q6 A: this pinned Debian 13 container is the only permitted Linux - # release builder. The digest is the pin; the `debian:13` tag is only a - # label. The artifact links against this image's glibc (2.41); a bare - # ubuntu-latest runner carries glibc 2.39, which is not the deploy host's - # OS (docs/typescript-quic-realtime-cut.md:2192-2197). - container: - image: debian:13@sha256:f324c7ff54321e8d9c588493a20244965938ce0aa50bbd1022d38010e9ffc4b1 - timeout-minutes: 20 - steps: - - name: Check out CultLib - uses: actions/checkout@v4 - - - name: Install build tools - run: | - set -euo pipefail - apt-get update - apt-get install -y --no-install-recommends cmake ninja-build g++ curl ca-certificates dpkg - - - name: Build the native QUIC bridge - run: ./scripts/build-quic-native.sh artifacts/quic-native/linux-x64 - - - name: Print toolchain version and digests - run: | - g++ --version - sha256sum artifacts/quic-native/linux-x64/libgamecult_mesh_quic_native.so - sha256sum artifacts/quic-native/linux-x64/libmsquic.so.2 - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: quic-native-linux-x64 - path: artifacts/quic-native/linux-x64 - if-no-files-found: error - - # Only this job has write permission, and only a tag push runs it. It - # attaches a draft MANIFEST.txt: the fields both build jobs cannot know - # (host names, MSVC version, the pinned dependency sources) are left for - # the operator to fill in from this run's own logs before committing the - # binaries, per 11.5's manifest paragraph. - release: - name: Release native binaries - needs: [build-win32-x64, build-linux-x64] - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cultmesh-quic-native-v') - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: write - steps: - - name: Check out CultLib - uses: actions/checkout@v4 - - - name: Download win32-x64 artifact - uses: actions/download-artifact@v4 - with: - name: quic-native-win32-x64 - path: release/win32-x64 - - - name: Download linux-x64 artifact - uses: actions/download-artifact@v4 - with: - name: quic-native-linux-x64 - path: release/linux-x64 - - - name: Write SHA256SUMS and a draft MANIFEST.txt - run: | - set -euo pipefail - cd release - # Relative paths matching packages/cultmesh-ts/native/ exactly, so - # this file is the one the operator commits verbatim (11.5, 11.7). - sha256sum \ - win32-x64/gamecult_mesh_quic_native.dll \ - win32-x64/msquic.dll \ - linux-x64/libgamecult_mesh_quic_native.so \ - linux-x64/libmsquic.so.2 \ - > SHA256SUMS - cat > MANIFEST.txt <.v9 and resolves through both runtimes under that one rule. hashAlias is .v1 and is refused as unmatched by both - it is not a wire form either runtime's production call sites ever produce or accept, and it is kept in the fixture specifically to pin that neither runtime resolves it.", - "//references": "R-AF, 2026-09-23: a reference's `references[].targetKey` is the only thing a stored edge actually carries on the wire - GameCult.Caching.MessagePack.CultRecordRefFormatter serializes a CultRecordRef as a bare key string (probed: MessagePackSerializer.Serialize on a real Design field produced the single msgpack string 'a-eq', nothing else). This fixture used to also carry a `targetSchema` per reference; it was never anything but documentation - SelectionParityVectorTests.BuildDocument and cultnet-rs's build_row both read only targetKey to construct the edge - and it is removed rather than kept as a field the wire does not have. Resolving which row an edge names is by targetKey alone, filtered to the declared role's target leaves (D9); see citer_narrow below for the shared-key shape that rule is pinned against.", - "schemas": { - "leaf_a": { - "schemaId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff", - "nameAlias": "leaf_a.v9", - "hashAlias": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff.v1", - "indexes": [ - { "name": "kind", "numeric": false }, - { "name": "mass", "numeric": true } - ] - }, - "leaf_b": { - "schemaId": "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42", - "nameAlias": "leaf_b.v9", - "hashAlias": "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42.v1", - "indexes": [ - { "name": "kind", "numeric": false }, - { "name": "mass", "numeric": true } - ] - }, - "citer": { - "schemaId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc", - "nameAlias": "citer.v9", - "hashAlias": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc.v1", - "roles": [ - { "name": "Design", "targets": ["leaf_a", "leaf_b"] } - ] - }, - "citer_narrow": { - "//": "R-AF: a citer whose declared reference target is one leaf only (leaf_a), so a record key shared by a leaf_a row and a leaf_b row has exactly one candidate inside the declared target and exactly one outside it - the shape neither runtime's parity vectors covered before this cut (zero duplicate record keys across the original ten rows).", - "schemaId": "sha256:ee192f6526a8f8cdec7044551aa2c8e28c612426766bb270605023bc94e2614d", - "nameAlias": "citer_narrow.v9", - "hashAlias": "sha256:ee192f6526a8f8cdec7044551aa2c8e28c612426766bb270605023bc94e2614d.v1", - "roles": [ - { "name": "narrow_ref", "targets": ["leaf_a"] } - ] - } - }, - "rows": [ - { "schema": "leaf_a", "key": "a-lo", "ordinal": 1, "fields": { "kind": "weapon", "mass": "4" } }, - { "schema": "leaf_a", "key": "a-eq", "ordinal": 2, "fields": { "kind": "weapon", "mass": "5" } }, - { "schema": "leaf_b", "key": "b-hi", "ordinal": 3, "fields": { "kind": "armor", "mass": "6" } }, - { "schema": "leaf_a", "key": "shared-1", "ordinal": 4, "fields": { "kind": "shared", "mass": "1" } }, - { "schema": "leaf_b", "key": "shared-2", "ordinal": 5, "fields": { "kind": "shared", "mass": "1" } }, - { "schema": "leaf_a", "key": "shared-3", "ordinal": 6, "fields": { "kind": "shared", "mass": "1" } }, - { - "schema": "citer", - "key": "citer-1", - "ordinal": 7, - "references": [ { "role": "Design", "targetKey": "a-eq" } ] - }, - { - "//": "R-D: 2233759.25 is exactly representable as an f32 and sits on a round-to-even tie between two shortest-form spellings; its exact canonical decimal is 2233759.25 either way. kind=tie so no weapon/armor/shared case can sweep it up.", - "schema": "leaf_a", "key": "tie-mass", "ordinal": 8, "fields": { "kind": "tie", "mass": "2233759.25" } - }, - { - "//": "R-C: BMP private-use key (U+E000), same ordinal as the astral row below so the tiebreak - not the ordinal - decides order. kind=unicode, mass=0 so no unfiltered or mass>1 case reaches these.", - "schema": "leaf_a", "key": "-row", "ordinal": 9, "fields": { "kind": "unicode", "mass": "0" } - }, - { - "//": "R-C: astral key (U+1F602, encoded as a surrogate pair whose high half 0xD83D is less than 0xE000 - a UTF-16 code-unit compare sorts this first; code-point order sorts it after the BMP row above).", - "schema": "leaf_a", "key": "😂-row", "ordinal": 9, "fields": { "kind": "unicode", "mass": "0" } - }, - { - "//": "R-AF shape 1: the only row at this key is outside citer_narrow's declared target (leaf_a only) - resolving the edge below must refuse reference_outside_target in both runtimes, not silently accept an empty page. kind=narrow-fixture (not \"shared\") so this row never sweeps into shared_index_value_three_rows, which pins an exact count of 3.", - "schema": "leaf_b", "key": "narrow-only", "ordinal": 10, "fields": { "kind": "narrow-fixture", "mass": "1" } - }, - { - "//": "R-AF shape 2: two rows share this key, one inside citer_narrow's declared target and one outside it - resolving the edge below must accept, deterministically picking the leaf_a row, in both runtimes.", - "schema": "leaf_a", "key": "dup-key", "ordinal": 11, "fields": { "kind": "narrow-fixture", "mass": "1" } - }, - { - "schema": "leaf_b", "key": "dup-key", "ordinal": 12, "fields": { "kind": "narrow-fixture", "mass": "1" } - }, - { - "schema": "citer_narrow", - "key": "narrow-citer-refused", - "ordinal": 13, - "references": [ { "role": "narrow_ref", "targetKey": "narrow-only" } ] - }, - { - "schema": "citer_narrow", - "key": "narrow-citer-accepted", - "ordinal": 14, - "references": [ { "role": "narrow_ref", "targetKey": "dup-key" } ] - }, - { - "//": "R-AJ: a tied ordinal across two DIFFERENT schemas (leaf_a and leaf_b), not two rows of the same leaf like the astral/BMP pair above - the shape the row order's schemaId tiebreak needs and the original ten rows never had. Keys are anti-correlated with the real schema ids on purpose: leaf_b's real id sorts before leaf_a's (sha256:b1f2... < sha256:ff35...), so leaf_b gets the alphabetically-*later* key (\"zz-tie-schema\") and leaf_a gets the *earlier* one (\"aa-tie-schema\") - a schemaId-first order and a recordKey-first order disagree here on purpose, so only the correct composition produces leaf_b's row first.", - "schema": "leaf_b", "key": "zz-tie-schema", "ordinal": 15, "fields": { "kind": "tie-schema", "mass": "1" } - }, - { - "schema": "leaf_a", "key": "aa-tie-schema", "ordinal": 15, "fields": { "kind": "tie-schema", "mass": "1" } - }, - { - "//": "R-AO, 2026-09-23: 'dup-key' already carries two rows (leaf_a ordinal 11, leaf_b ordinal 12) - both are in citer's Design role's declared target ([leaf_a, leaf_b], unlike citer_narrow's narrow_ref above, which only ever had one in-target candidate at a shared key). This citer is the first row in this file (hence in both runtimes' row order) to name 'dup-key' through Design, so resolving it must deterministically pick the leaf_a row - the first in-target candidate in the caller's order - never the leaf_b row, in both runtimes.", - "schema": "citer", - "key": "citer-both-in-target", - "ordinal": 16, - "references": [ { "role": "Design", "targetKey": "dup-key" } ] - } - ] -} diff --git a/contracts/cultnet/interop/selection-vectors.rs-written.json b/contracts/cultnet/interop/selection-vectors.rs-written.json deleted file mode 100644 index a9b635c4..00000000 --- a/contracts/cultnet/interop/selection-vectors.rs-written.json +++ /dev/null @@ -1,282 +0,0 @@ -{ - "vectors": [ - { - "name": "any_of_plus_ge_conjunction", - "selectionMessagePackBase64": "g6ZmaWVsZHOSg6VpbmRleKRraW5kom9wpmFueV9vZqZ2YWx1ZXORpndlYXBvboOlaW5kZXikbWFzc6JvcKJnZaZudW1iZXKhNapwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "descending_with_limit", - "selectionMessagePackBase64": "g6pwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nw6VsaW1pdAM=", - "asOf": 1, - "expectedIds": [ - "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-both-in-target", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/aa-tie-schema", - "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42/zz-tie-schema" - ], - "matched": 18, - "hasNext": true, - "expectedEdges": [] - }, - { - "name": "gt_numeric_boundary", - "selectionMessagePackBase64": "g6ZmaWVsZHORg6VpbmRleKRtYXNzom9womd0pm51bWJlcqExqnByb2plY3Rpb26maGVhZGVyqmRlc2NlbmRpbmfC", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-lo", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42/b-hi", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/tie-mass" - ], - "matched": 4, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "incoming_exists_true", - "selectionMessagePackBase64": "hKdzY2hlbWFzkdlHc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmalY2l0ZWSCpHJvbGWmRGVzaWdupmV4aXN0c8OqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/dup-key" - ], - "matched": 2, - "hasNext": false, - "expectedEdges": [ - { - "fromId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-1", - "role": "Design", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "payloadBase64": null - }, - { - "fromId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-both-in-target", - "role": "Design", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/dup-key", - "payloadBase64": null - } - ] - }, - { - "name": "incoming_negation", - "selectionMessagePackBase64": "hKdzY2hlbWFzkdlHc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmalY2l0ZWSCpHJvbGWmRGVzaWdupmV4aXN0c8KqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-lo", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-1", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-3", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/tie-mass", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/-row", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/😂-row", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/aa-tie-schema" - ], - "matched": 7, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "shared_index_value_three_rows", - "selectionMessagePackBase64": "g6ZmaWVsZHORg6VpbmRleKRraW5kom9wpmFueV9vZqZ2YWx1ZXORpnNoYXJlZKpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-1", - "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42/shared-2", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-3" - ], - "matched": 3, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "hop_by_role_cites_exact_id", - "selectionMessagePackBase64": "hKRrZXlzkadjaXRlci0xpWNpdGVzgqZ0YXJnZXSCqHNjaGVtYUlk2UdzaGEyNTY6ZmYzNWYzZDlkNmRlM2YxMDY2YjkzNjllNzNmZTZjNzY0OGU4ODM2OGQxOGVmYzIyNzVjOTk0NzMwY2Q4NGNmZqlyZWNvcmRLZXmkYS1lcaRyb2xlpkRlc2lnbqpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedIds": [ - "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-1" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [ - { - "fromId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-1", - "role": "Design", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "payloadBase64": null - } - ] - }, - { - "name": "hop_by_role_cites_name_alias", - "selectionMessagePackBase64": "hKRrZXlzkadjaXRlci0xpWNpdGVzgqZ0YXJnZXSCqHNjaGVtYUlkqWxlYWZfYS52OalyZWNvcmRLZXmkYS1lcaRyb2xlpkRlc2lnbqpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedIds": [ - "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-1" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [ - { - "fromId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-1", - "role": "Design", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "payloadBase64": null - } - ] - }, - { - "name": "schemas_by_hash_alias", - "selectionMessagePackBase64": "g6dzY2hlbWFzkdlKc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmYudjGqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "schemas_by_name_alias", - "selectionMessagePackBase64": "g6dzY2hlbWFzkalsZWFmX2EudjmqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-lo", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/a-eq", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-1", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/shared-3", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/tie-mass", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/-row", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/😂-row", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/dup-key", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/aa-tie-schema" - ], - "matched": 9, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "float_tie_exact_ge", - "selectionMessagePackBase64": "g6ZmaWVsZHORg6VpbmRleKRtYXNzom9womdlpm51bWJlcqoyMjMzNzU5LjI1qnByb2plY3Rpb26maGVhZGVyqmRlc2NlbmRpbmfC", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/tie-mass" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "astral_key_code_point_order", - "selectionMessagePackBase64": "g6ZmaWVsZHORg6VpbmRleKRraW5kom9wpmFueV9vZqZ2YWx1ZXORp3VuaWNvZGWqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/-row", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/😂-row" - ], - "matched": 2, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "row_tiebreak_schema_id_before_record_key_at_tied_ordinal", - "selectionMessagePackBase64": "g6ZmaWVsZHORg6VpbmRleKRraW5kom9wpmFueV9vZqZ2YWx1ZXORqnRpZS1zY2hlbWGqcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:b1f2407d0227a79dcbffdf7ea317f827eec64be38a3f61b7d4e99e81e3b24b42/zz-tie-schema", - "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/aa-tie-schema" - ], - "matched": 2, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "shared_key_narrow_ref_resolves_leaf_within_target", - "selectionMessagePackBase64": "hKRrZXlzkbVuYXJyb3ctY2l0ZXItYWNjZXB0ZWSlY2l0ZXOCpnRhcmdldIKoc2NoZW1hSWTZR3NoYTI1NjpmZjM1ZjNkOWQ2ZGUzZjEwNjZiOTM2OWU3M2ZlNmM3NjQ4ZTg4MzY4ZDE4ZWZjMjI3NWM5OTQ3MzBjZDg0Y2ZmqXJlY29yZEtleadkdXAta2V5pHJvbGWqbmFycm93X3JlZqpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedIds": [ - "sha256:ee192f6526a8f8cdec7044551aa2c8e28c612426766bb270605023bc94e2614d/narrow-citer-accepted" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [ - { - "fromId": "sha256:ee192f6526a8f8cdec7044551aa2c8e28c612426766bb270605023bc94e2614d/narrow-citer-accepted", - "role": "narrow_ref", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/dup-key", - "payloadBase64": null - } - ] - }, - { - "name": "shared_key_design_resolves_the_first_in_target_candidate_in_row_order", - "selectionMessagePackBase64": "hKRrZXlzkbRjaXRlci1ib3RoLWluLXRhcmdldKVjaXRlc4KmdGFyZ2V0gqhzY2hlbWFJZNlHc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmapcmVjb3JkS2V5p2R1cC1rZXmkcm9sZaZEZXNpZ26qcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedIds": [ - "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-both-in-target" - ], - "matched": 1, - "hasNext": false, - "expectedEdges": [ - { - "fromId": "sha256:9d0bc9aebc3619b07aabf564f98667afde41444c1b866661d777687d443608dc/citer-both-in-target", - "role": "Design", - "toId": "sha256:ff35f3d9d6de3f1066b9369e73fe6c7648e88368d18efc2275c994730cd84cff/dup-key", - "payloadBase64": null - } - ] - }, - { - "name": "refuses_empty_schemas_list", - "selectionMessagePackBase64": "g6dzY2hlbWFzkKpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedRefusalField": "schemas", - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "refuses_blank_key_entry", - "selectionMessagePackBase64": "g6RrZXlzkqRhLWVxoyAgIKpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedRefusalField": "keys", - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "refuses_unmatched_cites_target_schema", - "selectionMessagePackBase64": "g6VjaXRlc4KmdGFyZ2V0gqhzY2hlbWFJZLlzaGEyNTY6bm90LWEta25vd24tc2NoZW1hqXJlY29yZEtleaRhLWVxpHJvbGWmRGVzaWduqnByb2plY3Rpb26maGVhZGVyqmRlc2NlbmRpbmfC", - "asOf": 1, - "expectedRefusalField": "cites.target.schemaId", - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "refuses_cites_target_by_hash_shaped_alias", - "selectionMessagePackBase64": "g6VjaXRlc4KmdGFyZ2V0gqhzY2hlbWFJZNlKc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmYudjGpcmVjb3JkS2V5pGEtZXGkcm9sZaZEZXNpZ26qcHJvamVjdGlvbqZoZWFkZXKqZGVzY2VuZGluZ8I=", - "asOf": 1, - "expectedRefusalField": "cites.target.schemaId", - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - }, - { - "name": "shared_key_narrow_ref_refuses_when_only_candidate_is_outside_target", - "selectionMessagePackBase64": "hKRrZXlzkbRuYXJyb3ctY2l0ZXItcmVmdXNlZKVjaXRlc4KmdGFyZ2V0gqhzY2hlbWFJZNlHc2hhMjU2OmZmMzVmM2Q5ZDZkZTNmMTA2NmI5MzY5ZTczZmU2Yzc2NDhlODgzNjhkMThlZmMyMjc1Yzk5NDczMGNkODRjZmapcmVjb3JkS2V5q25hcnJvdy1vbmx5pHJvbGWqbmFycm93X3JlZqpwcm9qZWN0aW9upmhlYWRlcqpkZXNjZW5kaW5nwg==", - "asOf": 1, - "expectedEvaluationRefusal": "reference_outside_target", - "expectedIds": [], - "matched": 0, - "hasNext": false, - "expectedEdges": [] - } - ] -} \ No newline at end of file diff --git a/docs/cultcache-publication-cut.md b/docs/cultcache-publication-cut.md deleted file mode 100644 index 8a7cb2fc..00000000 --- a/docs/cultcache-publication-cut.md +++ /dev/null @@ -1,840 +0,0 @@ -# CultCache publication: the cache owns "published once", and order stays data - -Status, 2026-09-29: Cuts 1-3 landed on `main`. Cut 3 merged at `ae8576d`. Imagination pass 4 re-took Cuts 4-6 -against `3bf1c0c`. Q-P5 is ruled (A). Cut 4 is ready for Hands. -- F4, pinning `Held`'s publish-on-throw guard, is done: Cut 3 pinned it. -- F3 (observer removal on unsubscribe) and F1 (the false "getters run once" claim for conditional commits on variant - stores) were Cut 3 follow-ups; confirm against the Cut 3 merge. - -Recorded: -- F2, the Q-P2 hazard. A rethrown observer exception makes a committed write look cancelled or refused. The - only live typed catch around a cache write is AetheriaEve `Aetheria.State.Daemon/Program.cs:3722`. It needs a - fail-fast handler, and no production code installs one. -- F5: subscribe and unsubscribe cost O(n). -- F6: writes after `Dispose` are dropped silently. - -Map written by Imagination pass 1, 2026-09-29. The ends are the -operator ruling of 2026-09-30: every committed cache change reaches subscribers -exactly once. This document owns the means. - -- **Body.** CultLib `main` `65311c9ad770828adafe40c2c14b2d3da517628e`. Every - `file:line` is against it unless it names the branch. -- **Superseded attempt.** `origin/hands/cultnet-publish-commits`, tip - `28248eb`, base `f9f107a`. Soul pass 3 said do not merge it, and that stands. - - Main has not touched `CultCache.cs`, `CultNetDatabase.cs`, the composition - doc or the networking tests since `f9f107a`: `git diff --stat` is empty. - - `git merge-tree 65311c9 28248eb` is clean. -- **Scope.** The C# cache's publication and CultNetDatabase's use of it. There - is no wire-format change and no other runtime changes (§6). - - -## Rulings (operator, 2026-09-30) - -- **Q-P1 A: order as data.** Each change is published exactly once, on its writer's thread, before the write - returns, and carries its `Sequence`. The shard log is written in cache order by the gate-held journal. Wire - peers drop changes that are stale by `Sequence`. The turnstile (`bcae483`/`4562340`) and the drainer are - both rejected. -- **Q-P2 A:** a throwing observer does not stop the others. Every observer runs, the exception is rethrown to - the writer afterwards, and the observer stays subscribed. The commit stands. -- **Q-P3 A:** a public `CultCache.AddJournal(...)`, with reentry guarded. -- **Q-P4 A:** Cut 6, which drops stale changes per key on the wire, lands in this campaign. -- **Q-P5 A (2026-09-29):** a primary that cannot log a committed change throws a typed `CultNetShardLogException` - naming the shard and the burned sequence, after publication, not derived from `InvalidOperationException`. - -## The finding that shapes this map - -The direction Imagination was handed was: "ordered delivery belongs in the -cache's own publication, on the writer's thread, so a writer delivers its own -changes before returning". That design **has been built before, and it was -deleted**. - -- `bcae483` (2026-09-13 20:09) made the cache a delivery scheduler: tickets, a - delivery gate, turn waits and per-thread queues for reentrant writes. -- `4562340`, 34 minutes later, deleted it: "It deadlocked inside CultLib: a - load's delivery reaching a CultNetDatabaseSubscriptionServer observer that - needs _lifecycleGate, while a subscribe's demand handler holding that gate - writes the cache and waits for the delivery's turn." -- It replaced it with **order as data**: a per-cache `Sequence`, and no - delivery scheduler. -- The regression tests it left, `ObserverWritingTheSameCacheDoesNotWaitOnOtherDeliveries` - (`ConditionalCommitTests.cs:763`) and - `SubscriptionDemandHandlerWritingCacheDuringDeliveryDoesNotDeadlock` - (`NetworkingTests.cs:2244`), are live on main. - -This pass rebuilt that scheduler as a prototype. It is the per-cache turnstile -with same-thread trampolining at `79f4639`, and it reproduces the deletion: - -- Caching tests: 278 of 279 pass, and `ObserverWritingTheSameCacheDoesNotWaitOnOtherDeliveries` - fails. -- The networking suite hangs, and Yggdrasil's idle watchdog killed it at 900 s. - The blame-hang run that names the hung test is recorded below. - -The reason is structural, not an implementation slip. Once a writer waits for -another thread's delivery, any lock that an observer takes and a writer holds -becomes a deadlock: - -- total cross-thread order; -- a writer delivering before it returns; -- no writer waiting on another thread. - -Pick two. The branch's drainer chose order plus no-wait, and lost -before-return (F3 and F4). The turnstile chose order plus before-return, and -lost no-wait (the `bcae483` deadlock). - -**So this map keeps order as data (the `4562340` ruling) and moves the one -order-sensitive consumer, the CultNet mutation log, to the place order is -decided: under the cache gate.** - -- Every writer keeps delivering its own changes, on its own thread, before it - returns, exactly as main does. F3 is satisfied by not regressing it. -- The log becomes a **journal** written in the admitting hold, in Sequence - order. -- The reorder buffer and drainer die, and no scheduler replaces them. This - departs from Soul's stated direction on purpose, and **Q-P1** puts it to the - operator. - -## Probe evidence - -All of this ran on Yggdrasil via `ygg-verify.sh`, from scratch commits in a -throwaway worktree that no branch holds. - -- Probe file: `tests/GameCult.Caching.Tests/PublicationProbeTests.cs` in scratch commit `79f4639`. The worktree has been removed. The commit is unreferenced in the local object store, where gc can collect it; it also survives on the Yggdrasil mirror as `refs/verify/79f4639f8f5b95db7ce16f244a081c1ec101a468`. -- `9c5abf5` is the probes on main. `79f4639` is the same probes plus the - turnstile prototype in `CultCache.cs`. - -| # | Probe | main `65311c9` | Turnstile prototype `79f4639` | -|---|---|---|---| -| Q1 | A batch `{ok, boom}` where boom's `[CultName]` getter throws | `TargetInvocationException`. `_sequence` goes from 0 to 1, because ok was minted. **Both ok and boom are in memory**, and `GetByName("ok")` finds ok. **Nothing is published**, and the next write gets Sequence 2. F1 is worse than stated: memory is corrupt and unpublished. In a store-backed cache, `land` (`:2325`) already ran, so the store holds it too. | No stall, but memory is still corrupt. | -| Q2 | Two `Watch` observers, the first throws | With the default R3 handler, the second observer sees 2 of 2 and the writer sees nothing. **With a rethrowing handler, the second observer sees 0 of 2 and every writer gets the exception.** The comment at `CultCache.cs:2374`, "OnNext does not throw", is false under fail-fast. | With its own observer array and a per-observer catch, the second observer sees 2 of 2 and the writer gets the exception afterwards. | -| Q3 | Writer A's observer blocks on `a`, then B writes `b` | The recorder sees `b(2)` before `a(1)`. There is no cross-thread order, by design since `4562340`. | Sees `a` then `b`, because B waited for A. | -| Q4 | An observer on `x` writes `y` | `y(2)` before `x(1)`: nested, depth-first, and the nested write returns after `y` is published. | `x` then `y`, and the nested write returns before `y` is published. | -| Q5 | `OnUpdate` on Upsert and on Commit | 0 fires, so loads only. `Watch` sees 2. | Unchanged. | -| Q6 | 8 threads × 1000 writes, plus reentrant writes | 67 ms, 2645 of 8800 cross-thread inversions, and 0 writes returned undelivered. | 516 ms, 0 inversions, 0 undelivered. | -| Q7 | Soul's P2 shape: a handler waits 1 s for another thread's write | Observed in time. | Not observed in time. | -| Suites | Caching, Networking and Mesh | (green on main) | Caching fails `ObserverWritingTheSameCacheDoesNotWaitOnOtherDeliveries`, and Networking **hangs** until the 900 s idle kill. Rerun with `--blame-hang-timeout 90s`: 286 passed, then the test host hung and was dumped. The blame sequence file was not extracted, so **the hung test is not named**. It is consistent with, but not proven to be, `SubscriptionDemandHandlerWritingCacheDuringDeliveryDoesNotDeadlock`, whose own comment says "disposal would hang too". | - -## Imagination pass 4: Cut 4 re-taken on the landed journal - -Cut 3 landed at `ae8576d`. Its Soul left two questions that Cut 4 had to settle before relying on the -journal: (a) what a throwing journal means for the log, and (b) whether a journal needs the change's origin. -Both have one coherent answer. The one fork, Q-P5, was about who hears of a log failure; the operator ruled it A (2026-09-29). - -### Probe evidence (pass 4) - -- Probe file: `Pub4ProbeTests.cs` (Networking tests). It was run on Yggdrasil from scratch commits: - - `0d7397d`: main plus the probes; - - `6ec2f73`: the same, merged with the branch `28248eb`; - - `376cd74`: main plus probe C. -- The commits survive on the Yggdrasil mirror. The scratch worktree is gone. -- The probes report facts and assert nothing. `FlakyLogStore` is an in-memory `ICultNetShardMutationLogStore` - that can refuse `Append` or run a hook inside `GetCompactedThrough`. - -| # | Probe | main `3bf1c0c` | branch `28248eb` (queue) | -|---|---|---|---| -| A1 | Primary with a durable log. Put 1, Put 2 (its `Append` throws), Put 3. A replica pulls, then retries. | Writer gets `IOException`. The cache holds 1, 2 and 3, but **2 is never published** (2 of 3). Memory log `[1,2,3]`, durable `[1,3]`. The replica pull throws "log has a gap. Expected 2, received 3", and so does **every retry**: the replica is stuck for good. | **Writer sees nothing**: R3 swallowed the drainer's exception. 2 is not published. The replica is stuck in the same way. | -| A2 | The same failure at the tail, then the primary restarts over the same cache and log store. | The replica applied 1. After restart, note 3 is **minted sequence 2**. The replica takes it, reports applied 2, and holds `1,3` against the primary's `1,2,3`: **silent divergence**, a reused sequence. | Same. | -| A3 | A replica whose log `Append` throws once. | The pull throws and the cursor stays at 0. The retry converges (`1,2`), but the memory log is `[1,1,2]`: a duplicate, because memory is written before disk and kept as a `List`. | The pull "succeeds": the exception was swallowed and the cursor went to 2. The durable log is `[2]`, so **entry 1 is lost**, and a chained replica sees a gap. | -| B1 | Primary with a file store. Another writer puts `pulled` into the file, the primary runs `PullAll`, and a replica pulls the log. | `pulled` is published but **not logged**. The replica gets nothing. | Logged. The replica converges on `pulled`. | -| B2 | A store attached after the database exists. | Nothing is logged. | All three hydrated records are logged. | -| S | `CreateShardSnapshotResponse` with a write landing between its document read and its sequence read (hooked in `GetCompactedThrough`). | The snapshot holds `[1]` at log sequence 2. The replica applies it and pulls, and still lacks 2: **divergence**. | Same. | -| C | Compact through 2, restart, then Put 3. | Note 3 is **minted sequence 1**, and `GetLatestMutationLogSequence` returns 1, below the floor of 2. | (not run; the code is unchanged) | - -What the probes establish: -- A1, A2, S and C are pre-existing defects on main. Cut 4 inherits them and must not build on them: the - resync path it relies on for (a) is itself broken by S and C. -- On a replica, the pull loop already retries. The cursor advances only after an entry applies - (`CultNetDatabase.cs:1038-1083`), so a replica needs no new mechanism. It needs only to keep the exception - reaching that loop, which the branch's queue broke (A3). -- Loads on a primary must be logged, or replicas diverge (B1). - -### (a) A journal that cannot log a committed change: one answer - -The facts: -- The log store is a second durable store written after the cache's store. Without an atomic commit across - the two, the log can lag the store. It must never lead: a replica would then apply a change the primary - refused. -- So lag is unavoidable, and it has to be detectable and repaired. -- The protocol already has a repair, and nothing else needs to be invented. - - "History the primary cannot serve" is `compacted_history`: `CultNetDatabaseServer.cs:189-201` answers - `ResyncRequired`. - - `CultNetShardReplication.cs:199-214` then snapshot-resyncs. - -**Rule: a primary that cannot log a committed change burns that change's sequence and compacts through it.** - -- In the database journal, on a primary, for each change that is not `NoLog`: - 1. Mint `S`. - 2. Build the entry: the wire message from the door, or `ToLogEntryMessage`. - 3. `Append` durably, **then** record it in memory. Disk goes first, so memory never serves what disk lacks. -- If step 2 or 3 throws: - - record nothing; - - raise the database's in-memory floor for the shard to `S`; - - try `store.CompactThrough(shard, S)`; - - still set `_lastWriteSequence` to `S`, because the row was written at `S`; - - carry on with the rest of the admission; - - throw `CultNetShardLogException` once at the end of the journal call (Q-P5 A). -- Every replica behind `S` is then told `compacted_history` and resyncs by snapshot. The sequence gap at `S` - is never served, because the floor covers it. -- This **replaces** the old §4 step 3 claim, "a serialization failure then mints nothing, so the log can never - hold a gap". Minting nothing hides a replication gap behind a dense sequence. That is exactly A2's silent - divergence. -- **Replica:** there is no floor. The journal's exception reaches `ApplyShardLogResponseAsync` and the cursor - does not advance. The next pull re-applies the entry: a fresh instance, so the door matches again, and the - entry is re-recorded under the primary's sequence. The branch's absent-key direct log follows the same - disk-first order. -- **Required fixes** that the rule depends on, all in Cut 4: - - `GetCompactedMutationLogSequence` (`CultNetDatabase.cs:597-602`) returns - `max(store floor, in-memory floor)`. - - `InitializeLogSequencesFromStore` (`:1363-1395`) resumes at - `max(highest retained, store.GetCompactedThrough(shard)) + 1`. This is probe C. - - `GetLatestMutationLogSequence` (`:607-616`) never reports below the floor. - - `CreateShardSnapshotResponse` (`:624-670`) reads `GetLatestMutationLogSequence` **before** `SelectAll`, on - both returns, `:645` and `:668`. The documents then reflect at least that sequence, and replaying later - entries converges: they are whole-document puts and deletes, applied in order. This is probe S. - - `RecordMutationLogEntry` (`:1331-1352`) writes disk first. The in-memory log becomes - `SortedList` per shard, replacing by sequence as the durable store does. This fixes A3's - duplicate. -- **Residual, recorded rather than forked.** Suppose the store refuses both `Append` and `CompactThrough`, and - then the process restarts. - - The durable log does not know about the hole, so A2's tail reuse can recur. - - Fixing that needs a durable write per mint, a sequence reservation, which doubles log I/O under the gate. - - The thrown exception names both failures, so the outage is loud. - - Refusing later writes ("fail closed") is not coherent. The database can refuse only its own doors, while - bare cache writes are journaled regardless: that would be split authority. - -### (b) A pulled or loaded change on a primary: no origin needed - -- On a primary the log is the shard's **state history**, whoever wrote the state. B1 shows that leaving loads - out of the log leaves replicas permanently diverged. -- The only origins that change what is logged are already carried by the door table, keyed by instance - identity and matched by shape. They are: - - `Replica` (log the primary's entry); - - `NoLog` (prediction, snapshot resync); - - `Put`/`Delete` (the wire message); - - `Predicts`/`Authoritative`. -- A load or pull has no door, so on a primary it is logged like any unattributed commit. On a replica it logs - nothing, like any local write. That is what the branch does, and B1 converges under it. -- Cost: - - B2: a store attached **after** the database logs its hydration. - - `CultNetHost` opens the cache before building the database (`CultNetLocal.cs:146-152`), so production - hydration is not journaled. - - A re-pull admits only the records that changed. In B1 the seed was not re-logged. -- `AddJournal` keeps its signature. If a future consumer (audit, say) needs "load or commit", the fact goes on - `CultCacheDocumentChange` as an additive property, as `Sequence` did. The cache already knows it: `Admit`'s - `source != null` at `CultCache.cs:2420`. It never needs a new `AddJournal` shape. -- This is recorded, not forked: no consumer needs it today. - -### The two recorded hazards, settled for Cut 4 - -- **Q-P2 typed-exception hazard.** Cut 4 makes it frequent. Every cache write on a primary with a durable log - now does log I/O inside its admission. - - AetheriaEve opts into durable logs (`Aetheria.State/AetheriaStateNode.cs:144`). - - Its `AetheriaHangarCommandJournal.ValidateAsync` writes an envelope (`Program.cs:6509`) inside the `catch - (InvalidOperationException)` at `Program.cs:3722`. - - A log failure surfacing as `InvalidOperationException` would therefore produce a "denied" receipt for a - committed envelope. - - Q-P5 A (ruled): the writer gets a typed `CultNetShardLogException` that **does not derive from - `InvalidOperationException`**. -- **Journal deadlock (the Cut 3 note).** The database journal waits only on `_logGate` and on the log store's - own lock. - - Lock order: cache gate, then `_logGate`, then the log store's lock. - - Invariant: **no code holding `_logGate` calls the cache, and no log store calls the cache or waits on a - thread that does.** - - Readers that take `_logGate` read only log state: `GetMutationLog`, `LastWriteSequence`, `CurrentAsOf`. - Readers already inside a cache read, such as the selection evaluator's `ordinalOf`, nest `_logGate` under - the cache gate, which is the same order. - - The store rule goes into the `ICultNetShardMutationLogStore` XML doc (`CultNetShardMutationLogStorage.cs:13-34`), - because a user store runs under the cache's gate. - - A log store that writes the cache already throws, through Cut 3's guard. Cut 4 pins it with a test. - -## Authority map - -- **Owner.** `CultCache`. The hold that mints a Sequence range also: - 1. journals the range under the gate, in Sequence order (new); - 2. publishes the range to every observer, isolated, on the minting writer's - thread, after it releases the gate and before it returns (main's model, - now isolated). - - Nothing waits on another call's delivery. -- **Inputs.** - - The changes returned by `Apply` (`CultCache.cs:2707`), the single mutation - site. - - The pre-mint projection of names and indexes (Cut 1). - - The journal list, the observer array and `OnUpdate`. -- **Outputs.** - - Journal calls: one per admission, under the gate, in Sequence order. - - `Watch` / `WatchRecord` notifications that carry `Sequence`. - - `OnUpdate` for loads. - - Observer and journal exceptions, rethrown to the writer. -- **Derived state.** - - `Sequence` is order as data. - - CultNet's primary log sequence is minted in the journal, so log order is - cache order. - - A replica's log sequence is copied from the primary entry. - - The database change kind (`Predicted`, `Reconciled`, `Added`, `Updated`, - `Removed`) is decided in the journal. - - `CultNetDatabaseChange.Sequence` (new) is copied from the cache change. - - Wire projections drop stale by it (Cut 6). -- **Forbidden writers.** - - Nothing re-sequences or schedules cache changes. The branch's `_parked`, - `_ready`, `_nextSequence`, `_draining`, `PendingChange` and the drain body - of `OnCacheChange` die, and so do the turnstile, `bcae483` and the - prototype. - - No R3 `Subject` fans out cache changes (Q2). - - `Apply` and `Index` run no user code. - - Doors never read or write prediction state: the branch's `HasPrediction` - and `_predictionGate` die. - - The database's Watch observer never logs; only the journal logs. - - A journal never enters the cache. -- **Shared paths.** Every path goes `Held` → `Admit` → `Resolve` → **Project** - → `land` → `Apply` → **journal** → leave gate → **publish**: - - loads: `AddBackingStore` `:1909`, `Loaded` `:1940`, `PullAll*` `:1959` and - `:3052`; - - `Commit` / `TryCommit` (`Land`, `:2272`); - - `UpsertAsync`, `UpsertVariantAsync`, `FlattenAsync` and `Remove` - (`:2004-2056`, `Write` `:2252`); - - a variant dependent's re-resolution (`VariantPlan.Dependents`, in the same - `Apply`); - - direct calls on an attached store (`:2924`); - - `Dispose` (`:2142`); - - the database doors, replica apply and snapshot resync, which only write - the cache and hand context to the journal. - - The single exception is the replica's absent-key delete, which has no cache - change. It logs directly (§4). -- **Deletion line.** - - In the cache: `Subject _changes` (`:1809`), the `_changes.OnNext` - call and its false comment (`:2374-2375`), `_changes.Dispose()` - (`:2154`), and the accessor calls in `Index` (`:2798-2804`). - - In the database, on the salvaged branch: the reorder buffer and drainer, - `_predictionGate` and `HasPrediction`, the logging in `Deliver`, and the - `Subject _changes` fan-out. - -## The design, question by question - -### 1. Validation before minting: a refused change mints nothing - -- **Where.** Add **Project** to `Admit` (`:2313`), between `Resolve` (`:2324`) - and `land` (`:2325`). -- **What.** Over `plan.Admitted ∪ plan.Dependents`, it evaluates once per - record: `NameAccessor(document)` and every `IndexAccessors[alias](document)`. - It keeps `(Name, (Alias, Value)[])` per key on the plan. -- **A throwing getter refuses the whole admission.** It raises an - `InvalidOperationException` that names the key, the member and the unwrapped - message; today the caller sees a bare `TargetInvocationException`. The - refusal comes before `land`, so the admission writes no store, touches no - memory and mints nothing. -- **Readers take the projection, not the document.** - - `Index` (`:2793-2806`). - - `RefuseVariantIndexSharing` (`:2659-2660`). - - The variant-name rule in `ResolveOne` (`:2616`). Its ancestor read at - `:2621` reads held documents, pre-land, and may stay. - - `Resolve` currently runs the refusal rules before any projection exists. - Hands makes Project the first pass over the resolved plan and moves both - rules after it, so rules read the projection and only the projection reads - documents. -- **Apply becomes user-code-free.** It then does only dictionary and - `ConditionalWeakTable` work on precomputed data. -- **Loads refuse too.** A store whose record's getter throws fails to open, - loudly. That is the rule "hydration failure on open is loud" (composition doc - `:88-92`). Today it half-indexes silently. - -### 2. Observer isolation - -- **Replace the `Subject` with the cache's own observer array**, - copy-on-write under a small lock. - - `Watch` (`:1887`) becomes `Observable.Create(register)` followed - by the existing `Where` and `Select`. - - `Dispose` calls `OnCompleted` on each observer, which is what - `Subject.Dispose` did. -- **Publish loops change → observer, and wraps each `OnNext` in its own - try/catch.** - - R3's `Observer` already catches handler exceptions (`OnErrorResume`, then - the unhandled handler). So an exception reaches the cache only when fail-fast - was asked for: a rethrowing `ObservableSystem` handler, or a custom observer. - - Escaped exceptions join the `OnUpdate` failures. They are rethrown to the - writer after every observer has received every change of the hold. That is - the existing `OnUpdate` policy (composition doc `:77-82`). - - The observer stays subscribed (**Q-P2**). The commit stands either way. -- **Prototype.** At `79f4639` (Q2) this took about 15 lines. Hands keeps that - part and drops the turnstile around it. - -### 3. Delivery thread, order and reentrancy - -- **Unchanged from main, on purpose.** Each outermost hold publishes exactly its - own changes, on its thread, after it leaves the gate and before it returns - (composition doc `:59-65`, `Held` `:2339`). - - A write from inside a handler is its own outermost hold. It delivers - depth-first before returning, as Q4 shows on main. - - There is no cross-thread order. Every change carries `Sequence`, and - latest-state consumers drop stale changes by it (doc `:68-73`, and the Mesh - mirrors at `CultMesh.cs:1534-1540`). -- **Why this is not a regression of the ruling.** The ruling asks for - exactly-once, not for a total delivery order. - - Exactly-once in the cache comes from the single mint site plus isolation - plus Cut 1 (§1-2). - - Order is needed by exactly one consumer, the shard log. It gets that order - from the journal (§4), not from delivery. -- **The journal is the new mechanism.** - - Signature: `IDisposable CultCache.AddJournal(Action>>)`. - Its name and shape are **Q-P3**. - - It is called in `Admit` right after `Apply` (`:2328-2329`), under the gate, - once per admission, with that admission's changes in Sequence order. - Journals run in registration order. - - A journal that enters the cache, meaning any hold on this cache while a - journal runs, throws `InvalidOperationException`. It is guarded by a flag - checked in `Held`'s `Monitor.IsEntered` branch (`:2341`). This is the - store rule ("a store call must not wait for a write to its own cache"), - enforced. - - Journal exceptions follow the observer policy: the admission stands, it is - still published, and the exception is rethrown to the writer after - publication. - - Adding or removing a journal takes the gate, so registration is atomic with - respect to admissions. -- **Lock order.** Cache gate, then journal-internal leaf locks (the database's - `_logGate`). Observers still run outside the gate, so the `bcae483` cycle - (an observer needing `_lifecycleGate` while a gate holder writes the cache) - cannot form. No journal takes `_lifecycleGate`, and no writer waits on a - delivery. -- **Soul's P2 passes.** A handler waiting on another thread's write sees it, - because nothing orders deliveries (Q7 on main). - -### 4. What CultNetDatabase keeps - -The database is rebuilt on the journal. It has no queue. - -- **Journal (under the cache gate, per admitted change, in Sequence order):** - 1. `TakeDoor(change)`, with the shape rule salvaged from the branch - (`:1219-1234`). A put door matches a change whose new document is its - instance and whose previous document is not. A removal door matches a - change whose previous document is its instance and which has no new one. - - The consumption now happens inside the door's own hold, before any - observer runs. So an observer's later write to the door's key or - instance can never wear the context (the `f3343c8` defect), and - unconditional `Dispose`-removal stays correct. - 2. Predictions. A `Predicts` door adds the prediction. On an `Authoritative` - door (`ApplyPutAsync`, replica put), if a prediction exists for the key, - the kind is `Reconciled` and the prediction is removed. - - The gate serializes this, so `_predictionGate` and `HasPrediction` are - deleted (F5). - - Soul's P6 cannot happen: the prediction is recorded before - `PutPredictedAsync` returns. - 3. Primacy. - - On a shard primary, where the door is not `NoLog`: mint, build, append disk-first and record, with a failed - append burning the sequence and compacting through it. See "(a) A journal that cannot log a committed - change" in Imagination pass 4; the earlier claim that a serialization failure mints nothing is withdrawn. - - On a replica, record the primary's entry from the `Replica` door, - under its own sequence. - - For a local write on a replica, log nothing. - 4. Stash `(cache Sequence → CultNetDatabaseChange)` under `_logGate`, for the - publisher. -- **Watch observer (after the gate, on the writer's thread, before it - returns):** it removes the stash entry for `change.Sequence` and publishes it. - - A change with no stash was admitted before the database existed and is - ignored. - - Register the observer first and the journal second, in the constructor, so - a stash can never be orphaned. -- **Log-before-publish** is structural: the journal runs before the gate opens. -- **The replica's absent-key delete (F6)** logs directly under `_logGate`. It - is in order because every earlier entry of the same pull loop was journaled - inside its own hold, before that `UpsertAsync`/`Remove` returned. This holds - even when a pull runs inside a handler, since nested holds journal - synchronously. -- **The in-memory log is keyed and ordered by sequence.** It becomes a - `SortedList` per shard, to match the durable store - (`CultNetShardMutationLogStorage.cs:55-64, 75-89`: that store replaces by - sequence and orders by sequence). -- **Kept from the branch:** - - the door table keyed by instance identity, and the shape rule; - - "only a primary mints; replicas publish"; - - log-before-publish; - - the snapshot resync "logs nothing" rule. Its removal door (branch `:733`) - must set `Removal = true`, or the shape rule never matches it. -- **Database fan-out isolation.** The database's `Subject _changes` - (main `:487`) has the Q2 defect one layer up: the subscription server's - per-peer handlers sit on it. Replace it with the same isolated - observer-array pattern as §2 (about 20 lines). Its exceptions reach the - writer through the cache's own per-observer catch. -- **`CultNetDatabaseChange` gains `long Sequence`**, the cache change's - Sequence, as an optional constructor argument, exactly as - `CultCacheDocumentChange` did (composition doc `:57-58`). Without it, - in-process latest-state consumers cannot drop stale changes. -- **Gone:** F3 (no deferred delivery), F4 (no drainer), F7 (no queue to - strand) and F8 (no guard). - -### 5. Backpressure and memory bounds - -- **No buffer exists.** A writer delivers its own changes, and they are held - only in its `mine` list for the length of its own call. -- **The journal stash** holds at most the changes of holds between their - journal and their publication. That is one hold per writing thread, and each - entry is removed by the same thread that added it. -- **A slow observer slows only the writer whose change it is handling.** That - is main's behaviour. It does not slow other writers, and it does not grow - memory. This replaces the branch's unbounded drainer backlog (F4, Soul P5). -- **The journal runs under the gate, so a slow journal slows every writer.** - - The database journal does in-memory work plus one durable - `mutationLogStore.Append` per logged change. `Append` rewrites the shard - file (`CultNetShardMutationLogStorage.cs:83-89`). - - That is I/O under the gate, which the locking doctrine already allows for - stores ("A store doing I/O on behalf of its cache ... holds the gate", - composition doc `:98-101`). It is still a new cost, so Cut 4's - verification measures commit latency with a file log store. - - The whole-file rewrite is a pre-existing monolith. It is recorded as a - follow-up, not fixed here. - -### 6. Cross-runtime impact - -The Eyes survey was run at `65311c9`. - -- **`cultcache-rs`, `cultcache-ts` and `cultcache-py` have no publication - surface:** no watch, no listener and no Sequence. - - Rust: `lib.rs:1970-1975, 2213-2420`. - - TypeScript: `cult-cache.ts:164-181`, "Observer delivery is not scheduled - here". - - Python: `cache.py:30-45`, which refuses reentrant mutation. -- **`cultnet-rs`, `cultnet-ts` and `cultnet-py` have no CultNetDatabase - equivalent and no cache watcher.** The only server-side shard log is the - Python interop test peer (`interop_peer.py:565, 583`), which mints - `len(log)+1` under its own lock, inline with the write. That is already the - journal's shape. -- **Wire parity is unaffected.** - - Cache `Sequence` never goes on the wire (composition doc `:47-49`). - - `CultNetShardLogEntryMessage` does not change. - - `CultNetDatabaseChangeRawMessage` (`CultNetSchemaMessages.cs:1016`) carries - no sequence, and this map adds none: stale protection for wire - subscriptions is server-side (Cut 6). - - No vector in `tests/vectors/` encodes publication order. -- **No other runtime must change.** -- **Follow-up.** `cultmesh-py`'s `CultMeshDatabase` watch (`node.py:421-505, - 1059-1065`) has F2 (a throwing callback skips the rest and reaches the - writer), and it has no Sequence. When Python grows cache publication, it - takes this contract. - -## Cuts - -Every cut is on CultLib, branch `hands/cultcache-publication` from `main` -`65311c9`, in a worktree Self creates. Cuts 1-3 touch only the cache and land -first. Cuts 4-6 depend on Cut 3. Heavy verification runs on Yggdrasil. - -**The negative checks that stay green in every cut** are the `4562340` tests: - -- `ObserverWritingTheSameCacheDoesNotWaitOnOtherDeliveries`; -- `SubscriptionDemandHandlerWritingCacheDuringDeliveryDoesNotDeadlock`; -- `SequenceIncreasesInAdmissionOrder`; -- `WatchRecordIgnoresStaleSequence`. - -They are the proof that no scheduler has come back. - -### Cut 1. Project before mint (cache, behaviour) - -- **First.** Commit Q1 as a failing test named for the rule. -- **Deletes first.** - - Accessor calls in `Index` (`:2798-2804`). - - Direct accessor reads in `RefuseVariantIndexSharing` (`:2659-2660`) and - `ResolveOne` (`:2616`). -- **Adds.** - - `Project` in `Admit` (`:2324-2325`). - - A per-key projection on `VariantPlan` (`:2456`). - - The early returns in `Resolve` (`:2477-2478`, `:2530-2534`) still pass - through `Project`, because it is called from `Admit`. -- **Authority.** Project owns "this admission's name and index values", and - the rules and `Index` read them. `Apply` runs no user code. -- **Verification.** - - Tests: - - **A refused getter mints nothing and changes nothing.** `GetWithSequence` - is unchanged, both keys are absent, the name lookup misses, nothing is - published, and the next write is previous+1. - - **Store-backed batch:** the store file is byte-identical, and a reopen - holds neither key. - - **A load whose getter throws** refuses the open and leaves the file - byte-identical. - - **Once per landed record:** a counting getter runs exactly once per - landed record, including a variant dependent re-resolved by a base edit. - - **The refusal names** the key and the member. - - Soul P4. - - Negative grep: `rg -n "NameAccessor\?\.Invoke|IndexAccessors" src/GameCult.Caching/CultCache.cs` - has no hit in `Apply`, `Index` or `Unindex`. `:315` is store-side and - legitimate. - - Stryker.NET on the diff. -- **Ledger.** About −15 and +45. - -### Cut 2. Observer isolation (cache, behaviour) - -- **Deletes first.** - - `Subject _changes` (`:1809`). - - `_changes.OnNext` and the false comment (`:2374-2375`). - - `_changes.Dispose()` (`:2154`). -- **Adds.** - - The observer array and `Observable.Create` in `Watch` (`:1887-1897`). - - The per-observer catch in `Publish` (`:2369`), with escapes joining - `failures`. - - `OnCompleted` on `Dispose`. -- **Docs.** Composition doc `:77-82`: escaped observer exceptions follow the - `OnUpdate` policy. -- **Verification.** - - Tests: - - **Q2 with a rethrowing handler:** the second observer receives every - change. The writer gets the escaped exception after delivery, and the - thrower is still subscribed (per Q-P2). - - **Subscription order:** subscribing and unsubscribing during a delivery - leaves every other observer's stream complete. - - **Dispose** completes observers. - - Soul P3. - - The four `4562340` tests stay green. - - Stryker on the diff, especially removing the catch and breaking out of - the loop on the first failure. -- **Ledger.** About −5 and +30. - -### Cut 3. The journal (cache, behaviour) - -- **Adds.** - - `AddJournal` (Q-P3), with registration under the gate. - - The invocation in `Admit` after `Apply` (`:2328`). - - The no-reentry guard in `Held` (`:2341`). - - Exceptions routed like observer failures. -- **Docs.** A composition-doc paragraph in "Store composition" and in - "Locking": journals run under the gate, in Sequence order, and must not - enter the cache or wait for anything that needs it. -- **Verification.** - - Tests: - - **Order:** 8 threads × 1000 writes. The journal sees contiguous, - strictly increasing Sequences, and each call's changes arrive together. - - **Timing:** the journal runs before any observer of the same change, and - after `Apply` (`Get` inside the journal sees the new document). - - **Reentry:** a journal that writes the cache throws, and the admission - stands. - - **Refusal:** a refused admission journals nothing. - - **Dependents:** a variant dependent is journaled in the same call as its - base edit. - - **Failure:** a throwing journal still lets the change publish, and the - writer gets the exception. - - The `4562340` tests stay green. - - Stryker on the diff. -- **Ledger.** About +50. - -### Cut 4. Salvage the branch and rebuild CultNetDatabase on the journal (networking) - -- **4a (history).** `git merge origin/hands/cultnet-publish-commits` into the cut branch from main - `3bf1c0c`. - - It is clean: the probe merge `6ec2f73` auto-merged `NetworkingTests.cs` and the composition doc, then - built and ran. - - The merge brings the tests. The queue dies in 4b. - - Self may squash-salvage instead, with the same content. -- **4b (subtraction first).** Delete at branch `28248eb` `CultNetDatabase.cs`: - - `_parked`, `_ready`, `_nextSequence` and `_draining` (`:502-505`); - - `_predictionGate` (`:506-507`); - - the Watch subscription and handshake (`:529-531`); - - `OnCacheChange` (`:1080-1135`); - - `PendingChange` (`:1265-1275`); - - `HasPrediction` (`:1209-1213`) and its calls (`:916`, `:1574`); - - the logging and prediction bookkeeping in `Deliver` (`:1137-1201`). - - Main's `PublishCacheUpdate` / `OnUpdate +=` (`:505`, `:1157`, `:1161-1191`) is already gone on the branch. - Hands confirms it is absent after the merge. -- **4c (the journal).** Register the Watch observer first and the journal second (`AddJournal`), in the - constructor. Per admission, under the cache gate, per change in Sequence order: - 1. `TakeDoor(change)`, keeping the branch's shape rule (`:1219-1234`). - 2. Resolve the shard and kind. Predictions: a `Predicts` door adds its key. An `Authoritative` door - (`ApplyPutAsync`, replica put) holding a prediction for the key makes the kind `Reconciled` and removes - the key. - 3. Log, per §(a): - - a replica door records the primary's entry, disk first; - - a primary change that is not `NoLog` mints, builds, appends and records, with failure going to the - floor; - - anything else logs nothing. - 4. Stash `(cache Sequence → CultNetDatabaseChange)` under `_logGate`. - 5. If step 3 failed, throw once at the end of the call, after all changes are handled (Q-P5). -- **4c, publication.** The Watch observer removes the stash entry for `change.Sequence` and publishes it. A - missing stash means the change was admitted before this database existed, so it is ignored. `Dispose` - removes the journal and the observer and clears the stash. -- **4d (the §(a) fixes).** - - The floor: `GetCompactedMutationLogSequence`, `GetLatestMutationLogSequence`, and resume in - `InitializeLogSequencesFromStore`. - - Disk-first `RecordMutationLogEntry`. - - A `SortedList` per shard. - - The snapshot reads its sequence first (`:660` moves below `:668`'s read). - - `_logGate` around `_lastWriteSequence`/`_nextLogSequences` readers (`:1302`, `:1314`, `:1325`). -- **Door changes.** - - Flags: `Predicts` and `Authoritative`. - - The snapshot removal door (branch `:733`) sets `Removal = true`. - - The replica absent-key delete logs directly and publishes nothing (branch `:1612-1621`). - - Doors neither log nor publish. They register context, write the cache, and dispose the registration. -- **Verification.** - - Every salvaged test passes: `CultNetPublishesCommitsTests` (13) and `CultNetPublicationOrderTests` (S1, - S1b, S2, S3, S4, S6, S7, log-before-publish, in-place re-upsert). - - Soul pass 3's P1-P7 are committed and passing. - - The pass 4 probes become tests named for the rule: - - **A1:** a refused primary `Append` publishes the change. The writer gets `CultNetShardLogException`, - which names the shard and `S`. A replica pull answers `compacted_history`, and a snapshot resync - converges. - - **A2:** the same at the tail with a restart: the replica converges after resync, and no sequence is - reused. The store's `CompactThrough` succeeded. - - **A3:** a refused replica `Append` leaves the cursor unchanged. The retry converges, and the memory log - holds `[1,2]`. - - **B1:** a pull on a primary is logged, and the replica converges. - - **S:** a snapshot racing a write converges. - - **C:** after compacting through 2 and restarting, the next mint is 3. - - New tests: - - a reentrant `database.PutAsync` from inside a database handler is logged with its context and published - once; - - a reentrant `ApplyShardLogResponseAsync` from inside a handler keeps the replica log in primary order; - - a log store whose `Append` writes the cache fails with Cut 3's reentry guard, wrapped, and the admission - stands. - - Commit latency with `CultNetFileShardMutationLogStore`, main against Cut 4. Also measure a `CultMesh` node - with `EnableDurableShardLogs`, where every bookkeeping write is now logged. Report it; do not gate on it. - - Negative grep: `rg -n "_parked|_ready|_draining|_nextSequence|_predictionGate|HasPrediction|PublishCacheUpdate" src/GameCult.Networking` - returns nothing. - - Review check: no `_cache.` call inside a `lock (_logGate)` block. - - The `4562340` tests stay green. - - Test runs use `--blame-hang-timeout 2m`. - - Stryker on the diff: dropping the floor raise, memory-before-disk, and the snapshot read order must each - kill a test. -- **Docs.** - - Composition doc `:50-53`: replace the "streams derive from `OnUpdate`" sentence. CultNet derives from - `Watch` plus one journal, and the log is written in cache order. - - A new paragraph: a primary that cannot log a change compacts through it. - - The log-store rule under Locking. -- **Blockers.** None. Q-P5 is ruled A. -- **Ledger.** Against the branch, about −130 and +95. The extra over the old estimate is the floor, the - disk-first order, the `SortedList`, the snapshot order, and the exception type. - -### Cut 5. Database fan-out isolation and Sequence (networking, behaviour) - -- **Deletes first.** The database's `Subject _changes` (main `:485`, branch `:487`) and its - `Dispose` (`:1158`). -- **Adds.** - - The isolated observer array, the same pattern as the cache's `Register`/`Publish` - (`CultCache.cs:1929-1944`, `:2470-2503`), behind `Watch`, `WatchAllChanges` and the rest (`:1089-1145`). - - `CultNetDatabaseChange.Sequence` (`:319-371`), as an optional constructor argument. The journal's stash - sets it from the cache change. A change with no cache change behind it carries 0. -- **Docs.** The binary-signature note, as the composition doc gave for `CultCacheDocumentChange` (`:57-58`). -- **Verification.** - - With a rethrowing handler and one throwing database subscriber, the other subscriber and a live - subscription-server peer receive every change. The writer gets the exception after delivery (Q-P2). - - The disposed-database test. - - `Sequence` equals the cache change's. -- **Blockers.** Cut 4. -- **Ledger.** About −10 and +35. - -### Cut 6. Stale protection on wire projections (networking, behaviour; Q-P4 A) - -- **The rule.** A projection applies a change to a key only if its `Sequence` is above what the projection - last applied for that key. A snapshot or reconcile applies everything at or below the cache sequence it read - **before** reading documents. - - That read is `Cache.GetWithSequence().Sequence`, the branch's idiom (branch `:531`). No new API - is needed. -- **Subscription server** (`CultNetDatabaseSubscriptionServer.cs`): - - `SubscriptionProjectionState` (`:630`) gains `long Floor` and `Dictionary Applied`. - - The single-row fast path in `Watch` (`:296-340`) reads the change's `Sequence` (reflection, like `Key`). - Under `_lifecycleGate` it drops the change if `Sequence <= max(Floor, Applied[key])`. Otherwise it applies - the change and records it. Removals are included. - - `Reconcile` (`:347`) and the subscribe snapshot (`:168-181`) read `seq0` before `CreateProjectedSnapshot` - (`:402`), set `Floor = seq0`, and clear `Applied`. - - This is sound: every change applied earlier was applied under the same gate, after its admission, so - its `Sequence` is at most `seq0`. - - Hop and unauthorized paths already reconcile from current state, and they set the floor too. -- **`CultNetDatabaseServer.CreateSubscription`** (`:501-513`): - - A per-subscription `(Floor, Applied)` under a per-subscription lock, held across check, record and send. - - `HandleSubscribeAsync`'s snapshot (`:362-369`) takes `seq0` first and sets the floor. -- **Verification.** - - Two threads write one key, with a blocking cache observer that forces the inverted delivery (Q3 shape). - On both servers, the peer's last state for the key equals the cache's. - - A removal overtaken by an older upsert leaves the key absent at the peer. - - The negative check: without the drop, both tests fail. -- **Blockers.** Cut 5, which provides `Sequence` on database changes. -- **Ledger.** About +45. - -### Salvage from `hands/cultnet-publish-commits` (revised) - -- **Keep:** - - both test files; - - the `NetworkingTests.cs` edits; - - the door table and the shape rule; - - "replicas never mint"; - - log-before-publish; - - "the snapshot logs nothing"; - - "loads and pulls on a primary are logged" (B1); - - the composition-doc paragraph, rewritten to name the journal. -- **Drop:** - - the reorder buffer and the drainer; - - `_predictionGate`; - - logging from the observer; - - the swallowed exception path (A1 and A3 on the branch). - -## Subtraction ledger (estimate) - -| Cut | Removed | Added | Other | -|---|---|---|---| -| 1 | ~15 | ~45 | none | -| 2 | ~5 | ~30 | the cache no longer uses R3 `Subject` | -| 3 | 0 | ~50 | one public method (Q-P3) | -| 4 | ~130 vs branch | ~95 | the merge brings +1109/-243, of which about 780 are tests; the floor, disk-first order, `SortedList`, snapshot order and `CultNetShardLogException` are the extra over the first estimate | -| 5 | ~10 | ~35 | the database `Subject` goes, and one public property | -| 6 | 0 | ~45 | none | - -- **Source, net against main:** about +245. -- **Source against the branch:** no scheduler anywhere. -- The budget is pressure, not a metric. - -## Operator questions - -- Q-P1..Q-P4 are ruled (see Rulings). Their option analysis is in the map's git history. - -- **Q-P5 A (ruled 2026-09-29): a primary that cannot log a committed change throws a typed - `CultNetShardLogException` naming the shard and the burned sequence, after publication, not derived from - `InvalidOperationException`.** - - The commit stands, the change is published, and replicas behind it snapshot-resync (Imagination pass 4 (a)). - - The writer hears of it. AetheriaEve `Program.cs:3722` cannot mistake it for a denial. - -Recorded, not forked: -- (b): no origin on the journal. Loads and pulls are logged on primaries. -- (a)'s restart residual when the store refuses both writes. -- The replica keeps retry-by-cursor. -- A throwing getter refuses loads too. -- Reentrant writes keep main's depth-first delivery. Order is data. -- Journal I/O under the gate follows the store precedent. - -## Follow-ups outside this campaign - -- **`cultmesh-py` watch.** It has no isolation and no Sequence - (`node.py:1059-1065`). -- **Durable log whole-file rewrite.** `CultNetShardMutationLogStorage.cs:83-89` - rewrites the whole file per `Append`. It is a monolith, and under the gate - its cost is now every writer's. -- **Mesh database-backed handles.** `CultMesh.cs:2362` and `:3396` can drop - stale changes once `CultNetDatabaseChange.Sequence` exists. -- **Skill scar.** The Eureka SKILL.md already says "a ticket system that - serialized delivery was built, deadlocked, and was deleted". The Soul pass 3 - direction re-proposed it anyway. The Soul brief template should tell Soul to - check `git log -S` for a proposed mechanism before recommending it. -- **A chained replica after a snapshot.** A replica that snapshot-resyncs has no log entries below the snapshot - sequence. It should raise its own floor to that sequence, so a replica chained on it resyncs instead of seeing - a gap (`ApplyShardSnapshotResponseAsync` `:675-736`). It predates this campaign. -- **AetheriaEve `Program.cs:3722`.** It reads a committed write's `InvalidOperationException` as a denial. Under - Q-P5 A, Cut 4's log failures cannot reach it. Observer and `OnUpdate` exceptions still can, so the Cuts 1-2 - recording stands.- **Cut 4 Soul, recorded 2026-09-30 (Self), not fixed in Cut 4:** - - **File log store is not crash-safe (hard prerequisite).** `CultNetFileShardMutationLogStore.Append` and - `CompactThrough` use `File.WriteAllBytes` (truncate, rewrite, no temp+rename, no fsync). A failure mid-write - truncates the log; every later append burns a sequence and a restart cannot construct the database. It also - rewrites the whole file per append, which Cut 4 now does under the cache gate (2.2 ms per write at 100 - entries, 33 ms at 950, a 2.49 s stall). An atomic, append-only store must land before any live daemon - enables durable shard logs. Today only AetheriaEve's offline tools do; the live Aetheria daemon passes - `enableDurableShardLogs: false`. - - **A slow log append blocks cache readers** (`CultCache.Get` takes the gate). Accepted with a note in the - store's XML doc. - - **Crash between the store write and the log append** leaves the log lagging the store, and nothing detects - it; a restarted primary reuses that sequence (A2's divergence reached by a plain kill). The spec called this - lag detectable; for a crash it is not. -- **Cut 4 final Soul (4d), recorded 2026-09-30 (Self), not fixed in Cut 4:** - - **F2, read cost.** `CultNetDatabase.Serves` (`:1980-1989`) runs per row in `GetAll`/`GetByName`/`GetByIndex` for every - layout except a single owns-everything shard: a reflection `GetTrackedKey`, a gate lock and a shard re-scan per row. - `database.GetAll` measured 24.8x `cache.GetAll` on 20,000 rows under a key-prefixed shard. Fix: filter by key inside - the cache enumeration (the `rowFilter` path already has keys) and hoist the owns-everything check. - - **F4, dispose drain edges.** An observer that removed its stash entry before the drain can publish after `Dispose` - returns (dropped); a throwing `_cacheJournal.Dispose()` skips the drain. Neither double-publishes or deadlocks. - - **F5, refusal naming.** A write whose schema is owned but whose key is outside the shard's prefix also answers - `unowned_schema` with details `{field:"schemaId"}`; the peer cannot tell a key refusal from a schema refusal. - - **Pre-existing, separate task.** Python emits error code `unsupported_schema_version` - (`cultnet-py/.../interop_peer.py:415`, `cultmesh-py/.../server.py:161`), which is not in the error-code enum; TS and - Rust refuse the whole message. diff --git a/docs/cultcache-union-parity-map.md b/docs/cultcache-union-parity-map.md deleted file mode 100644 index 0adf2bc7..00000000 --- a/docs/cultcache-union-parity-map.md +++ /dev/null @@ -1,276 +0,0 @@ -# CultCache Union Parity: Map - -Campaign `cultlib-gaps`, follow-up `cultlib-gaps:follow_up:union-parity-and-unknown-arms` (from -`thing2:follow_up:cultcache-union-parity`), under operator ruling `thing2:ruling:contract-decode-tolerance` -("CultCache refuses unknown union arms in every runtime, the C# reference included"). This file holds body facts, -the model page and rationale; the cut specs and the question are documents in the mind and cite this file by -section and fact number. - -Pinned base: `origin/main` at `aaf0d7f6` (2026-10-10). Imagination pass `imagination-cl-union-parity`, session -`self-2026-10-10c-eureka`. Probes live under the session scratchpad, `imagination-cl-union-parity/` (`cs` payload -probe, `cs2` store probe, `rs` payload probe, `py` store walkers, `il` decompiled MessagePack-CSharp). None of it is -committed. Earlier evidence is not repeated here: Eve `docs/thing2-map.md` P12-P13 (the cross-runtime probe) and -`docs/research/cultcache-union-decode-tolerance-prior-art.md` (prior art). - -## Cut order - -1. `union-refusal-cs`: the C# reference refuses an unknown union arm on read and a subtype the union does not name - on write. Ruled; nothing blocks it. -2. `union-golden`: the recursive-union golden and the arm refusal goldens in `tests/vectors/union-parity/`, - written by the C# reference and held by its tests. -3. `union-derive-rs` and `union-codec-ts`, in either order or together: cultcache-rs and cultcache-ts gain a - union (and, in TS, a slot record) codec that writes the reference shape and decodes the golden byte-identically. - `union-codec-py` follows the same golden for cultcache-py. -4. `slot-tolerance` (C# reference), then `slot-readonly-parity` (Rust, TypeScript, Python): a record carrying a - slot past its reader's declared slots, at any depth, is read-only (ruling - `cultlib-gaps:ruling:extra-trailing-slots`; the refinement is settled by section S). Both change a slot rule the - cuts in step 3 build, so they wait for 1-3 rather than reopening them. -5. `union-parity-release`: changelogs and tags, Breaking where `docs/semver-policy.md` says so. - -Thing2's `cut-contract-rs` waits on step 3 (Rust) only: its first step pins cultcache-rs at the commit that lands -`union-derive-rs` and re-runs P12 or the `union-golden` vector both ways. - -Why this order: the C# reference is the wire authority, so its refusal and its golden come first and the other -runtimes are held to bytes C# wrote, as `document-variants-c1` was (`docs/runtime-parity-scope.md`). Arms are -ruled and slots are not, so the slot rule is its own cut rather than a blocked step inside every runtime's cut. - -## Model page (step 0b) - -| Kind | What names it | Over time | Who decides | -|---|---|---|---| -| Union arm | An integer key, `[Union(k, typeof(Arm))]` on the abstract base (C#), assigned by the union's author. The wire carries `[k, armSlots]`; the arm's type name never travels. `nil` is a null reference, not an arm. | **Added:** a key never used before. **Retired:** the attribute is removed or commented out and the key is never reused (Aetheria `Behaviors.cs:160,173`; Aetheria-legacy `Behaviors.cs:37-38`). **Renamed type:** free, the key is the identity. **Unknown to a reader** (a newer writer's arm, or a retired arm in an old store): refused, naming the union and the key (ruling). | The union's author assigns keys. The C# reference defines the shape; every runtime keeps parity with it (doctrine, `runtime-parity-scope.md`). | -| Arm subtype on write | The value's runtime type must be one the union names. | A subtype the union does not name is today written as `nil` (U4). After cut 1 it is refused. | The union's author, by naming the arm. | -| Arm slots, record slots | `[Key(n)]` integers, base-class keys included (an arm is a flat array). Gaps are written `nil`. | **Added:** appended at the next free key. **Retired:** kept as a gap, never reused (Aetheria `ItemInstance.cs:35`, `EntitySerializer.cs` key 5). **Missing in an older store:** the reader's default (C# field initializer; Rust and Python need a declared default). **Extra past the reader's last key, at any depth:** the record is read and is read-only; every write or removal of it is refused, and it is persisted from its original bytes (ruling, S). | The type's author. The slot rule is CultCache's (`src/GameCult.Caching/Contracts/cultcache-schema-compatibility.md`). | -| Serde-enum member (Rust) | serde's external tag: the variant **name** (`{"Name": fields}`, a unit variant the bare string). | Persisted already by Rust consumers (section C). They keep their bytes: the union derive is opt-in and serde enums are untouched. | The Rust consumer. Not a cross-runtime shape. | - -## U. Mechanism facts (C# reference, Rust, TS) - -- **U1. The miss branch is `Skip` then `null`, in both union formatters MessagePack-CSharp 3.1.7 can hand out.** - `DynamicUnionResolver.BuildDeserialize` (decompiled from `MessagePack.dll` 3.1.7 net9.0 with ilspycmd): after - `ReadArrayHeader() == 2` (else `InvalidOperationException "Invalid Union data was detected"`) and `ReadInt32`, a - non-zero-start key set is mapped through `keyToJumpMap.TryGetValue`, a miss sets the index to `-1`, the `switch` - default calls `reader.Skip()`, and the result local stays `null`. The source generator's `UnionTemplate` - (`MessagePackAnalyzer` 3.1.7, `MessagePack.SourceGenerator.dll`) emits the same: `default: reader.Skip(); break;` - with `result = null`. Its serializer writes `nil` when `typeToKeyAndJumpMap` has no entry for `value.GetType()`. -- **U2. The C# reference decodes an unknown arm to null and does not re-encode to its bytes.** Probe `cs` - (payload built by hand with `MessagePackWriter`, decoded with `CultDocumentMessagePackSerialization.OptionsFor`): - unknown key 9 in a union field gives `Root=NULL`, in a list `Items=[TextNode,NULL]`; re-encode equal: False in - both. The formatter the reference composite hands out for the union is `MessagePack.Formatters.NodeFormatter1` - (DynamicUnionResolver's emitted type; the probe assembly carries no generated resolver). -- **U3. Missing and extra trailing slots, C# payload level.** Same probe: a payload one slot short decodes with - the field initializer (`Added=42`); a payload one slot long decodes with the extra slot skipped. Neither - re-encodes to its bytes. -- **U4. The reference writes an unnamed subtype as nil.** Same probe: `Root = new RogueNode()` (a subclass the - union does not list) serializes to `94 a2 64 32 c0 90 2a`: the root slot is `nil`, and it reads back `Root=NULL`. - Silent loss on the write side, the mirror of U2. -- **U5. Refusal can live at the CultCache layer; no MessagePack-CSharp fork.** Same probe, `strict` options: a - resolver placed ahead of `StandardResolver` returns, for any abstract or interface type with `[Union]`s, a - formatter that peeks (`CreatePeekReader`) the `[key, ...]` header, throws - `MessagePackSerializationException("union Node has no arm 9")` for a key the union does not list, refuses to - serialize an unnamed subtype, and otherwise delegates to the formatter `StandardResolver` would have handed out. - Baseline round-trips byte-identical; both unknown-arm cases and U4 are refused; slot behaviour is unchanged. - Every C# decode path reaches the composite through `CultDocumentMessagePackSerialization.OptionsFor` - (`CultCacheMessagePack.CreateCodec`, `DirectoryMessagePackBackingStore.cs:345`, `CultMesh.cs:2779,3493,3499`, - `CultMeshPrimitives.cs:1158,1230,2357`), so one resolver covers the cache, the directory store and CultMesh. - Consumer resolvers named by `[CultCacheFormatterResolver]` sit ahead of `CultDocumentResolver` today - (`CultDocumentMessagePackSerialization.cs:58-62`); the guard goes first and delegates to the rest of the - composite, so a consumer formatter still encodes the arm while the key check still runs. -- **U6. A top-level extra slot is dropped on write-back.** Probe `cs2`: a C#-written store, mutated as a newer - writer would (catalog member slot 2 added, payload slot 2 `"newer writer data"`), is pulled, the record edited - and flushed. The read succeeds, and the written payload is `['n1', 'edited by the older build']`: the newer - writer's slot is gone. (The schema id was left unchanged, so the migration report said `Kind=Exact`; with a - changed id the documented drift path reports `IgnoredExtraSlots`, `CultCache.cs:840-924`, but writes back the - same way.) -- **U7. Rust today.** Probe `rs` (`cultcache-rs` at `aaf0d7f6`, payloads built with `rmpv`, decoded with - `rmp_serde::from_slice`): a serde enum's unknown variant is refused (`unknown variant 'Exploded'`); the C# arm - shape `[0, [...]]` is refused (`expected variant identifier`); a non-nil value in a gap slot is skipped; a missing - trailing slot is refused (`missing field 'added'`) unless the field is `#[cultcache(default)]`; an extra trailing - slot is skipped (`cultcache-rs-derive/src/lib.rs`, the `IgnoredAny` loop after the slot loop). The derive - accepts named structs only (`lib.rs:51-67`) and writes an empty member list into the catalog - (`src/lib.rs:2706`). -- **U8. TypeScript today.** No typed codec: with no `formatter` a document encodes as a MessagePack **map** of the - zod-parsed object and decodes raw (`cult-cache.ts:679-692`; `@msgpack/msgpack` `encode({id:'d',version:7})` is - `82 a2 69 64 ...`, a fixmap, where the reference writes an array); positional slots exist only in hand-written - formatters (`test/cult-cache.test.ts:1263-1310`). P13 measured that a hand codec matches whichever encoding its - author chose. -- **U9. Python today.** `define_database_entry_type` (`packages/cultcache-py/src/cultcache_py/documents.py:185-276`) - is a slot codec: gaps written `nil`, extra slots ignored, a missing slot defaulted or refused. No union codec. -- **U10. The written contracts.** `cultcache-schema-compatibility.md:75-91` classifies "persisted slot is missing - locally and can be ignored" as soft-migratable drift, reported as `IgnoredExtraSlots`; - `cultcache-persistence-format.md:215-218` says a store reader "never skips a slot it does not understand" for - record envelope slots, and every runtime refuses `extra-slot-full-payload.msgpack` - (`tests/vectors/document-variants-c0`). `docs/persisted-record-encoding.md` says consumers verify canonicality - by re-encoding and comparing bytes. The two contracts disagree about payload slots; the question below is - about that disagreement. -- **U11. Fixture home.** `tests/vectors//`: committed bytes every runtime's tests read - (`document-variants-c0` by Python `generate.py`, `document-variants-c1` written by C#), consumed by - `tests/GameCult.Caching.Tests/PreCut2StoreFormatTests.cs`, `packages/cultcache-rs/src/lib.rs`, - `packages/cultcache-ts/test/cult-cache.test.ts` and `packages/cultcache-py/tests/test_cultcache.py`. The CultNet - precedent for a reference-written vector is `CULTNET_WRITE_VECTORS=1` (`docs/cultnet-error-contract-cut.md:170`). - -## S. Slot read-only probe (any depth) - -Imagination pass `imagination-cl-slot-readonly` (session `self-2026-10-10c-eureka`), under ruling -`cultlib-gaps:ruling:extra-trailing-slots` ("b, and probe the any-depth refinement"). Probes live under the session -scratchpad, `imagination-cl-slot-readonly/` (`cs` C# synthetic, `aeth` C# on Aetheria's game database, `rs`, `py`, -`ts`, `il` decompiled MessagePack-CSharp 3.1.7). None is committed. The ruling's test: every runtime's decoder -carries a "slot skipped" mark to the record cheaply, on the one decode path, with no second pass and no per-type -consumer code. - -- **S1. Where C# skips, and why a resolver sees it.** - `DynamicObjectTypeBuilder.BuildDeserializeInternalDeserializeLoopIntKey` emits the slot loop's `switch` default as - a direct `MessagePackReader.Skip()` call; the source generator's `FormatterTemplate` writes - `default: reader.Skip(); break;`. `MessagePackReader` is a struct, and neither path raises an event or reads an - option, so the skip itself cannot be observed without a fork. Both fetch every member formatter from - `options.Resolver` (the generated code's `formatterResolver = options.Resolver`), and the union formatters fetch arm - formatters the same way (U1). A resolver ahead of the composite is therefore handed every nested object, list - element and union arm, and can read each one's array header before delegating. -- **S2. The mark arrives in C#.** Probe `cs`: a guard resolver returns, for each concrete int-keyed - `[MessagePackObject]` type, a formatter that reads the array count (from `NextCode` for a fixarray, a peek for - array16 and array32), compares it with the highest `[Key]` plus one (base keys included, MessagePack's member - visibility rule), notes a skip into a `[ThreadStatic]` scope the decode's caller opened, and delegates to the - formatter the rest of the composite hands out. An extra slot at depth 0 (record), depth 1 (nested object), depth 2 - (object in an object), in a union arm and in a list element each arrives as one mark naming the type and both - counts; the clean payload gives none. The guard needs `CompositeResolver.Create` around it so formatters are - cached (uncached, it was 40 times slower). -- **S3. C# cost.** Aetheria `GameData/Aetheria.cc` (12.1 MB; 237 of 238 records decodable with Aetheria.Shared's - types; decoded with `OptionsFor` that assembly; best of 9, three rounds): plain 165-209 ms, a second plain composite - (A/A) 174-193 ms, guarded 179-196 ms. That is 3.7-8.9% over the best plain run, inside the A/A spread. Worst case, - synthetic tiny objects (120,000 records, 23.1 MB, about 24 objects each): plain 618-637 ms with A/A within 4%, - guarded 704-705 ms: 11-19%, about 30 ns per decoded object. -- **S4. A live case in Aetheria.** The same probe, run with the AetherDb release binaries (built 2026-09-30) against - today's `Aetheria.cc`, marks 25 records: `WeaponItemData` whose `BehaviorData` arms (`AutoWeaponData`, - `ChargedWeaponData` and others) carry 34 slots where that build declares 21 or 33. The extra slot is - `WeaponData.Tracking` (key 33, Aetheria `8cd71ed6`, 2026-10-07): inside a union arm, inside a list. Today that tool - reads these records and drops `Tracking` from all 25 at its next landing (S5). Refusing nested extra slots would - stop it opening `Aetheria.cc` at all; read-only lets it open the store and refuses writes to those 25. -- **S5. A C# flush re-encodes every held record, not only the edited one.** `PushAll` and an unconditional - `CommitBatch` write `ToPersistedRecord(entry, SerializePayload)` for every entry (`CultCache.cs:3191-3201`, `3355`, - `3384`), under the local descriptor's schema id and catalog entry. So U6's loss reaches every held record with - unread slots at the next flush of anything. Rust (holds payload bytes and decodes on `get`, `lib.rs:2280-2293`), - Python (holds envelopes and decodes at load, `cache.py:257-285`) and TypeScript (holds payload bytes) carry an - untouched record's bytes. In C#, read-only therefore also means persisted from the original record (bytes, schema - id, catalog entry), never from the decoded document. -- **S6. Rust.** Probe `rs`: the derive's slot loop, with the trailing `IgnoredAny` loop counting into a - `thread_local`, marks depth 1, depth 2 and a list element. Depth 0 is the `DatabaseEntry` derive's own trailing - loop (`cultcache-rs-derive/src/lib.rs:258`), the same edit. A plain serde struct nested in a record already refuses - an extra element (`array had incorrect length, expected 2`), so only derived slot types skip. Cost (120,000 - records, 21.4 MB): inside the A/A spread (A/A from -3% to +9%; marked against plain from -14% to +13% over six - runs). The added code is one branch per object, never taken on a clean payload. Rust decodes on `get`, so whether - a held record is writable is answered by decoding its held bytes through the same derive, on the write path only. -- **S7. Python and TypeScript.** Probes `py` and `ts`: a slot codec tree passing a context argument (the shape - `union-codec-py` and `union-codec-ts` build) marks all five positions. Python (40,000 records, 11.1 MB, msgpack - unpack included): +14% against an A/A spread of 8%. TypeScript (120,000 decoded records, codec walk only; no - msgpack in the scratch copy): +20% against an A/A spread of 18%. The check is one length comparison per object. -- **S8. Kotlin has no library slot codec.** `CultDocumentCodec.decode` is written per type by the consumer - (`packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt:31-36`), and the package's own Eve - decoders skip extras by hand at 8 sites (`repeat((count - N).coerceAtLeast(0)) { reader.skip() }` in - `eve/EveDocuments.kt`). No slot rule, refusal or read-only, can be held by the library there until it owns slot - decoding. That is a follow-up, not a per-runtime rule. -- **S9. CultMesh decode paths** (`CultMesh.cs:2779,3493,3499`, `CultMeshPrimitives.cs:1158,1230,2357`) go through - `OptionsFor`, so through the guard, with no scope open: unchanged. Whether a Mesh replica that re-publishes a - decoded document drops slots is a follow-up. -- **S10. The refinement is in.** Every runtime with a library slot decoder (C#, Rust, Python, and the TypeScript - codec being built) carries the mark to the record on its one decode path, with no second pass and no consumer - code. The cost on Aetheria's real store is inside the A/A noise (S3); the worst synthetic case is 11-19% in C#. - A nested extra slot makes the record read-only; it is not refused. - -## A. Aetheria (C#, the only consumer persisting `[Union]`s) - -Aetheria consumes the reference through Unity packages pinned by tag (`Packages/manifest.json:55-57`: -`caching-unity-v1.4.0`, `cultlib-unity-v1.0.60`), so a CultLib change reaches it only when it bumps the pin. -Its only consumer resolver is `MathResolver` (`AssemblyInfo.cs:4`), which supplies no union formatter. - -- **A1. Unions inside persisted documents** (Aetheria `aac2cf91`, `Assets/Scripts/ServerShared`): - `BehaviorData` (`Behaviors/Behaviors.cs:147-191`, keys 0-11, 15, 16, 18, 20-24, 28, 31-40; 12 and 26 retired, - 14, 17, 19, 25, 27, 29, 30 commented out) in `List Behaviors` of the item data documents - (`ItemData.cs:346,368`); `WeaponData` (`Behaviors/Weapon.cs:15-18`); `EntityPack` (`EntitySerializer.cs:172-173`) - in `aetheria.savedzone` contents and its own `Children`; `ItemInstance` and `CraftedItemInstance` - (`ItemInstance.cs:18-31`, a union whose arms are also a union) in entity cargo and docking bays - (`EntitySerializer.cs:186-187`); `Provenance` (`Provenance.cs:96-98`) in `aetheria.provenanceledger` - (`Provenance.cs:11-15`, `Lot.Origin`); `SavedActionBarBinding` (`SavedGame.cs:221-223`) in `aetheria.savedgame`; - the input layout rows and keys (`InputLayout.cs:29-50`) in `aetheria.inputlayout`. `Brush` - (`Environment.cs:73`) was not traced to a persisted document. -- **A2. `GameData/Aetheria.cc` carries no unknown arm.** Walker `py/store_unions.py` over the git-tracked game - database (12.7 MB, `cultcache.store.v1`, 238 records, 13 catalog entries): `Behaviors` arm keys - {0:3, 1:2, 2:10, 3:5, 4:2, 5:2, 6:3, 8:7, 9:23, 11:2, 16:4, 23:7, 24:5, 31:1, 32:1, 34:1, 35:2, 37:4, 38:10, 39:2, - 40:1}; none retired or commented out; no `nil` element. -- **A3. The run save carries no unknown arm, and does carry missing trailing slots.** Walker `py/run_unions.py` - over `GameData/run.cc` (2026-09-30): `EntityPack` arms 0 and 1 (3 each), `ItemInstance` arm 2 (12), - `Provenance` arm 0 (64), `SavedActionBarBinding` 9 `nil` (empty bar slots). The `EntityPack` arms carry 21 slots - (orbital) and 20 (ship) against today's 22: the `Boss` slot (key 21, added 2026-10-07 in `db4617d8`) is missing, - so today's Aetheria reads this save only because a missing trailing slot defaults. `py/gaps.py`: no non-nil - retired slot (ItemInstance 2, 9, 10; EntityPack 5). `GameData/stale-2026-09-22/run.cc` is the same shape; - `player.cc` holds only `aetheria.playersettings`. `py/slots.py`: every top-level record matches its own store's - catalog exactly. -- **A4. What changes for Aetheria.** After it adopts a CultLib with cut 1, its current stores load unchanged - (A2, A3). A store written later by a build that has added an arm is refused by a build that lacks it, naming the - union and key, where today the arm silently becomes `null` (a gear item quietly loses a behaviour, a lot loses - its provenance) and the next save writes the loss back. Builds already pinned to 1.0.60 keep the null path; a - shipped binary cannot change. Aetheria-legacy does not use CultCache and has no store. -- **A5. Other C# stores.** `%LOCALAPPDATA%Low/GameCult/Aetheria/aetheria-unity.cc` (2026-08-08, 1.2 KB) is a - `cultcache.store.v2.directory-indexed` header from an older layout, not a union carrier. - -## C. Rust, TypeScript and other consumers - -Eyes audit for this pass (session `self-2026-10-10c-eureka`), `git grep` at each repo's `origin/HEAD`, Rust reach -by a lexical script (it can over-count; it does not under-count named fields). Aetheria and CultLib's tests excluded. - -- **C1. Rust: no `DatabaseEntry` record crosses runtimes as a union, and none uses the reference arm shape.** - Records that reach serde enums, each keeping its bytes because the derive is opt-in: - Huginn `epiphany.pipeline.resolution.v2` (`ResolutionOutcome`, external tag, `eureka-pipeline/src/lib.rs:746`, - live on Yggdrasil); Idunn `idunn.deployment_transaction` and `idunn.admitted_generation` (v4 and legacy forms; - internally tagged `#[serde(tag = ..., deny_unknown_fields)]` enums in `control_plane.rs`, `deployment_plan.rs`, - and two `#[serde(untagged)]` enums kept so older transactions decode, `drivers.rs:259,387`; live at - `/var/lib/gamecult/idunn/control.cc`); CodexConnector `gamecult.codex.replay_record.v1` (`CodexReplayState`, - `lib.rs:1017`); Epiphany's Atlas, model-request, persona and receipt records (internal, adjacent, external and - untagged representations; `.cc` files under `F:\Projects\.epiphany-runtime\` and on Yggdrasil). Unit-only serde - enums (a bare string) are widespread in Idunn, Huginn (`Faculty`, the pipeline's unit enums), CodexConnector and - Epiphany. No enum reaches any record in Odin, Muninn, Ghostlight, Huginn `mind-body`, or cultnet-rs and - cultmesh-rs production records. None of these is read by another runtime as a union today, so none is affected - by the arm refusal; the derive changes nothing for them. -- **C2. TypeScript: no consumer encodes a tagged union.** The only hand formatters are StreamPixels - `apps/service/src/realtime/overlay-state-documents.ts:190,232,277` (positional arrays, no union). Bifrost, - Heimdall, Hermodr, Odin scripts, Stonks, Vili, VoidBot (vendored `cultcache-ts`) and weksa have none. -- **C3. C# outside Aetheria: StreamPixels' overlay declares unions; its tracked store holds none of them.** - `apps/overlay-unity/Assets/Scripts/Assembly-CSharp/` (`8d40541`): `ActivationCondition` (10 arms), - `BattleEffect` (2), `StatusEffect` (4), `ItemInstance` (3), `EquippableItemInstance` (2), reachable from - `streampixels.status`, `streampixels.action_item`, `streampixels.skill` and gear documents. Walker - `py/sp_catalog.py` over `apps/overlay-unity/Data/catalog.cc` (`cultcache.store.v1`, 20 records): only - `outfit`, `skin_color`, `hair_style`, `emote` and `hair_color` records, and no `[int, array]` pair at any depth. - Its only consumer resolver is `MathResolver` (`Catalog/CatalogAssembly.cs:6`). CultLib's own - `GameCult.Networking` `Message` union (`Messages.cs:10`) is a CultNet wire message, decoded with - `MessageSerialization.Options` (`MessageSerialization.cs:7`, `DefaultOptions`), outside `OptionsFor`: the arm - guard does not reach it (follow-up). -- **C4. Python and Kotlin: no union-shaped record.** repixelizer uses `define_database_entry_type` with flat - slots; `cultmesh-kotlin` documents are `data class`es with no sealed type. - -So the stores the arm refusal can affect today are Aetheria's (A2-A4, none carrying an unknown arm) and -StreamPixels' overlay catalog (C3, carrying no arm). Every other runtime's persisted enums are serde shapes that -the opt-in derive leaves alone. - -## Rationale - -- **Why a guard formatter, not a fork or a re-implementation.** U5 shows a guard that only checks the key and the - subtype and delegates the encoding is enough. It keeps MessagePack-CSharp's union encoding as the one encoder, - costs one small file, and covers every path that already goes through `OptionsFor`. Forking the generated - template or vendoring `DynamicUnionResolver` would put a second encoder in CultLib. -- **Why the Rust derive is opt-in.** Serde enums already persisted by Rust consumers keep their bytes - (`docs/persisted-record-encoding.md`); a changed default would make every such store unreadable or - non-canonical. A new derive with explicit arm keys is how a Rust type says "this crosses runtimes". -- **Why arms use newtype variants over slot structs.** A C# arm is a subclass whose slots include the base class's - keys. A Rust newtype variant over a struct with keyed slots is the same thing, and it needs the slot code the - `DatabaseEntry` derive already has, factored so both derives share one slot generator. -- **Why the slot rule is a separate, asked cut.** The ruling settles arms and asks for extra trailing slots to be - "settled against the same re-encode rule". Two written contracts disagree (U10), and the current behaviour drops - data silently (U6), so the choice is the operator's and it should change every runtime at once. -- **The recommendation on extra slots was refusal; the ruling chose read-only, and S settles its depth.** An extra trailing slot is the slot-level twin of an unknown - arm: data from a newer writer that the reader's types do not describe. The operator ruled refusal for arms - knowing it costs an older reader the newer record; the same reasoning gives refusal for slots, and record - envelope slots are already refused in every runtime (U10). The alternative with precedent is - `variants:ruling:undeclared-read-only` (a record a type can read but does not declare loads read-only): it would - let an older reader see a newer record without overwriting it, but only where a catalog shows the extra slot - (top level), while most evolution here is nested (A3's `Boss` slot sits inside a union arm). -- **Missing trailing slots stay tolerated.** The reader knows a missing slot and its default, so it carries no - bytes it does not understand, and Aetheria's live run save depends on it (A3). A store whose guard compares - re-encoded bytes (Idunn's) refuses such a record by its own stricter rule, which is that guard's purpose. diff --git a/docs/cultlib-gaps-map.md b/docs/cultlib-gaps-map.md deleted file mode 100644 index 1dcfa8a8..00000000 --- a/docs/cultlib-gaps-map.md +++ /dev/null @@ -1,218 +0,0 @@ -# CultLib Gaps: Map - -Campaign `cultlib-gaps` (target: `docs/cultlib-gaps-target.md`). This file holds body facts, probes and -rationale for the cuts the mind's `cut_spec`s name; the specs cite it by section and fact number. - -Pinned base: `origin/main` at `6bdc23c9` (2026-10-10). Imagination pass `imagination-cl-gaps-cultmath`, session -`self-2026-10-10-ag`. Probes live under the session scratchpad, `imagination-cl-gaps-cultmath/` (`probe1` traced -copy of the solver and the warm/cold sweep, `suite` a scratch copy of `packages/cultmath` with the candidate fix, -`probe2` the sweep against that copy, `probe3` the overload probe). None of it is committed. - -## Cut order - -1. `bls-release-stop`: BoundedLeastSquares stops on a release only when the release is not real. -2. `bls-input-field`: a validation helper names the invalid input (follow-up `bls-invalid-input-field`). Blocked on - question `cultlib-gaps:question:bls-input-error-shape`. -3. `cultmath-release-0-4-1`: release `org.gamecult.cultmath` with cuts 1 and 2. Version follows question - `cultlib-gaps:question:bls-fix-release-lane`. -4. `cultmath-rotation-algebra`: quaternion algebra, swing-twist and joint clamps (ruling - `aetheria-release:ruling:solver-in-gamecult-animation`). Ships in the CultMath release that the first - GameCult.Animation release pins; that release is mapped with GameCult.Animation. - -## B. BoundedLeastSquares stopping - -Finding `aetheria-release:finding:cut-thrust-allocator-core.s1.solver-converged-early` (Soul, Medium): a cold start -reports `Converged` at a non-optimal point, so Aetheria's thrust allocator (tolerance 1e-12) answers differently -warm and cold, by up to .078 throttle. - -### Body facts - -- **B1. One runtime ships the solver.** `BoundedLeastSquares` exists only in - `packages/cultmath/src/CultMath/BoundedLeastSquares.cs` (C#, netstandard2.1 and net8.0). The type doc says there is - no HLSL mirror; grep over `packages/*` finds no Rust, TypeScript, Python or Kotlin sibling, and no other CultLib - project calls it. Its consumer outside CultLib is Aetheria's `ThrustAllocator`. -- **B2. The defect reproduces against CultMath at base, outside Aetheria.** `probe1` rebuilds Soul's allocator - matrix (Soul's `ProbeAllocator2`, constants H=100, Wy=1000, W=.3, kappa=10, rho=.1, EMax=2) for hull - `Synthetic(8, 7005)` and the 8th intent of `System.Random(5)`, (-0.8505, 0.6739, 0.5587): 15 rows, 12 columns. - Real `BoundedLeastSquares.Solve` at tolerance 1e-12 from x = 0: `Converged`, 13 iterations, cost 36.0313737, - x7 = 1. Re-solving from that answer: 1 iteration, cost 36.0312608, x7 = 0.9222145, which is also the warm answer. - The same literals (dumped with `"R"` floats, `probe1 dump`) reproduce it at tolerance 1e-9 and 1e-12, and not at - the default 1e-6, where the cold solve stops at iteration 10 inside the tolerance and the re-solve takes 0 - iterations. -- **B2a. The W5 problem as literals** (`probe1 dump`, float `"R"` round trip; m = 15, n = 12, row-major; the - regression fixture for `bls-release-stop`). Nonzero entries of A: - - row 0: a[0,2] = 100f, a[0,8] = -100f, a[0,9] = 100f - - row 1: 13.882518f, 20.86695f, 0, 14.8965845f, 12.38046f, 22.115599f, -13.706654f, 15.85789f, 0, 0, -100f, 100f - - row 2: -187.72859f, 239.31168f, 158.87828f, -270.31165f, 235.38467f, -14.704258f, 121.61232f, 244.81305f, 0, 0, - 0, 0 - - rows 3-6: a[3+k, 8+k] = 0.3f (k = 0..3); rows 7-14: a[7+i, i] = 0.1f (i = 0..7) - - b = {0, 67.385445f, 558.70917f, -3f, -3f, -3f, -3f, 0 x 8}; lo = 0; hi = 1f for columns 0-7, 2f for 8-11. - At base, tolerance 1e-12 from x = 0: `Converged`, 13 iterations, x[7] = 1, cost 36.031373704487095; a re-solve - from that answer: 1 iteration, x[7] = 0.92221445f, cost 36.031260771352414. -- **B3. The stopping rule that fires is the progress rule, after a release** (`BoundedLeastSquares.cs:273-278`). A - traced copy of the solver, bit-equal to the real one on this problem, shows the last two passes: - - iteration 12: full step lands; column 2 sits at its lower bound with gradient -0.00205 (violation 2.05e-3, - tolerance 1.5e-7); the solver releases it and records fMark = f. - - iteration 13: the re-solve moves x2 from 0 to 2.05e-7. The cost falls by about 2.1e-10, and the stall band - `1e-15 * fScale` is 2.11e-10, so `f >= fMark - band` holds and the solver reports `Converged`. Column 7 is then at - its upper bound with gradient +0.00145, ten thousand times the tolerance; releasing it is worth 1.1e-4 of cost. -- **B4. Why the progress rule cannot judge a release.** Near a minimiser, a cost difference resolves only about the - square root of what a gradient comparison resolves: a real step of size dx against gradient g lowers the cost by - about g*dx, while the cost itself is a sum of terms of size fScale. Here g*dx (2e-10) sat exactly at the cost's - rounding band. The gradient comparison is far from its own rounding: for column 7, the bound on the double - gradient's rounding error, `(n+1) * eps * (|A^T b|_7 + sum_k |(A^T A)_7k x_k|)` (Higham's inner-product bound, - gamma_(n+1)), is 9.3e-10, and the violation is 1.56e6 times that. -- **B5. What the progress rule is for** (commit 43035bc8, and the tests at `BoundedLeastSquaresTests.cs:774-942`). - It stops two kinds of pass that can never reach the tolerance: a free-set re-solve whose residual is rounding on a - near-singular free set, and a release whose violation is itself rounding (kktTol at or below the noise, including - kktTol = 0 when the box point nearest the origin is stationary). Deleting it outright breaks both: with a noise - gate on every test and no progress rule, 8 of 66 BLS tests fail (`wide`, `integer-tie`, `collinear`, `cond` spin to - the cap; `NearSingularFreeSetsConfirmOnceAndStop` sees 0 confirmations). Exempting releases from the progress rule - with no noise gate fails one: `StalledPassesConvergeInsteadOfSpinningToTheCap("plain")` seed 141, b = 0, - kktTol = 0, cycles release 3 (violation 1.7e-18) / stationarity miss / block on 3 until the cap. -- **B6. The candidate fix, measured.** In a scratch copy of the package (`suite`, diff `suite/clean.diff`, 44 lines): - (a) a bound column is a release candidate only if its violation exceeds both kktTol and the rounding bound of B4; - (b) the progress rule judges only passes that release nothing; a pass that releases sets fMark to +Inf, so a - release is never measured against a cost recorded before it. Results: - - all 66 tests in `BoundedLeastSquaresTests` pass, including `DefaultSolvesAreBitIdenticalToTheirGoldenBits` and - every stall and noise-floor test; the same holds with the bound's factor at 1, 16 and 256 in place of n+1; - - the W5 problem: cold `Converged` in 14 iterations at the warm answer (x7 = 0.92221, cost 36.03126077); - - 400 synthetic hulls x 60 random intents (24,000 calls, warm and cold) at tolerance 1e-12: every call `Converged`, - max iterations 45, warm and cold agree within 6e-8 on every call (the original: one call off by .078 in the first - 2,400). At the default tolerance warm and cold still differ, by more than .1 in 10,273 of 24,000 calls: that is - the documented resolution of 1e-6 times the gradient scale, pinned by - `AnAllocatorShapedProblemIsStartIndependentAtATightTolerance` (spread >= 0.5), and not this cut's subject. -- **B7. Released columns the factor drops.** With the fix, 266 releases in the suite land on a column that - `SolveFreeSet` marks dependent (p = 0). The next pass is then a stationarity miss with no release, and the - progress rule stops it, as before. No release in the suite or the 24,000 allocator calls produced a step that moves - the released column outward. A Lawson-Hanson style rejection guard (re-bind the column, try the next candidate) - was prototyped and is not needed by any measured case; it is not in the cut. - -### Prior art, and which one the solver follows - -- The solver is a primal active-set method on the normal equations: solve the free set, step to the first bound - crossed, release the most violated bound only after a full step lands. That is the outer/inner loop of - Lawson-Hanson NNLS (1974) generalised to two-sided bounds, which is the shape of Stark-Parker BVLS (1995) and of - scipy's `lsq_linear(method='bvls')`. It differs in factorisation (Cholesky of `A^T A`, not QR of `A`) and in - stopping. -- Lawson-Hanson stop on the dual test only (netlib `NNLS`, label 350: `IF (WMAX .le. ZERO)`), and guard roundoff - per candidate: a column whose new norm is negligible against rounding (`DIFF(UNORM+...)`) or whose new - coefficient is not positive (`ZTEST .gt. ZERO`) is rejected with `W(J)=ZERO` and the next candidate tried. There is - no cost-based stop. -- scipy's BVLS (`scipy/optimize/_lsq/bvls.py`, main) measures KKT exactly as CultMath's status doc states - (`g * on_bound` for bound variables, `|g|` for free ones, max over components) and has two stops: optimality below - `tol` (status 1) and a relative cost change below `tol` (status 2), reported as different statuses. -- CultMath reported its cost stop as `Converged`, which its status doc defines as "the KKT conditions hold". The fix - follows Lawson-Hanson: a release is judged on the gradient against its rounding (the role of their `DIFF` test), - and the cost stop is kept only where no gradient test can decide (a free-set residual at rounding level), which is - where scipy's status 2 also lives. - -### Rejected alternatives - -- Remove the progress rule and stop on the gradient alone: B5, 8 failures. -- Report the cost stop as a new status (scipy's status 2): the W5 answer would still be wrong, just labelled, and a - new enum member is a breaking change for callers that switch on the status. -- Measure progress from the step (the exact model decrease `t(1-t/2)|L^-1 g|^2`) instead of differencing the cost: - exact, but a noise-level gradient still yields a tiny positive decrease, so it needs the same noise threshold, on a - quantity further from the KKT test than the gradient itself. - -## I. Naming the invalid input - -Follow-up `cultlib-gaps:follow_up:bls-invalid-input-field` (from Soul finding -`cut-bls-kkt-tolerance.s1.invalid-input-names-no-field`): every validation failure returns the same `InvalidInput`. - -- **I1.** Validation today is three sites in `Solve`: tolerance (`:147-148`), bounds (`:149-151`), and finiteness of - A and b folded into the `A^T b` build (`:153-161`), which cannot tell A from b. -- **I2.** Precedent: LAPACK reports a bad argument as `INFO = -i`, naming the argument and never its value. .NET - throws `ArgumentException` with a parameter name, which the solver's no-throw, zero-allocation contract rules out. -- Recommended shape (question `bls-input-error-shape`, option `validate-helper`): a public - `BoundedLeastSquares.Validate(m, n, a, b, lo, hi, kktRelativeTolerance)` returning a new enum - `BoundedLeastSquaresInput { Valid, InvalidTolerance, InvalidBounds, NonFiniteMatrix, NonFiniteTarget }`, the first - failure in that order. `Solve` calls it and returns `InvalidInput` for anything but `Valid`, so validation has - one owner and the folded finiteness check in the `A^T b` loop is deleted. Additive: `InvalidInput` and every - existing result stay. - -## R. Release 0.4.1 - -- **R1.** `org.gamecult.cultmath` is at 0.4.0 (`package.json:4`, `CultMath.csproj:13`, tag - `cultmath-unity-v0.4.0`). `scripts/check-changelog-semver.mjs:97-101`: in 0.y.z a minor bump is the breaking lane; - additions and fixes take the patch lane (0.2.4 added `erf` as a patch). -- **R2.** Cut 1 changes results only where the old solver stopped after a release whose violation was above both the - caller's tolerance and the gradient's rounding, that is, where it reported `Converged` in breach of its status doc. - The default path's golden bits are unchanged (B6). The 0.4.0 precedent (ruling `cultmath-0-4-0-breaking-r2`) - declared the snoise tie fix Breaking because two valid functions gave different values; here the old value broke - the documented contract. Question `bls-fix-release-lane` asks which lane; the recommendation is `fixed-patch` - (0.4.1, `### Fixed`). -- The release procedure is the 0.4.0 cut's (`cultlib-gaps:cut_spec:cut-cultmath-release.r1`): Windows-only DLL rebuild - on Starfire, tests on Yggdrasil, public-surface diff, Unity import smoke, Soul before the tag. - -## Q. Rotation algebra - -Ruling `aetheria-release:ruling:solver-in-gamecult-animation`: CultMath gains quaternion algebra, swing-twist and -joint clamps; the aim-chain solve lives in a new package GameCult.Animation. The interface the consumer needs is the -Aetheria map's section "The rig's interface to GameCult.Animation and CultMath" (Aetheria `origin/master` -`30d02719`, `docs/aetheria-release-map.md:7559-7601`). - -### Body facts - -- **Q1. What exists.** `quaternion` (`src/CultMath/quaternion.cs`, 95 lines): public float fields x, y, z, w; - `identity`; `LookRotation(float3 forward, float3 up)`; implicit conversions to and from `float4`; scalar `==`. - `math.normalize(quaternion)` (`math.cs:225-235`) returns identity below length 1e-20. No mul, rotate, conjugate, - inverse, axis-angle, slerp, swing-twist or clamp exists. `math` is a partial class (`math.cs`, - `math.Interval.cs`, `math.Affine.cs`, `math.Phacelle.cs`); `math.rotate(float2, float)` exists (`math.cs:240`). -- **Q2. Serialization.** `GameCult.Caching.MessagePack` serialises `quaternion` as the float array [x, y, z, w] - (`CultMathResolver.cs:170-171`) and as an xyzw object in JSON (`CultMathJson.cs:468`). No other runtime - (`cultcache-rs`, `-ts`, `-py`) has a quaternion type. The cut adds static functions only: no field, layout or - formatter changes, so no wire change and no cross-runtime fixture. -- **Q3. Runtimes.** The algebra is C#-only, like `LookRotation`: shaders carry rotations as `float4` (the type's doc), - the mirror tests map shader functions to C# and never the reverse (`HlslSourceCompatibilityTests.cs:114-117`), and - the native core (`native/cultmath-core`) is a Voronoi tone helper. The Unity bridge already converts `quaternion` - (`UnityConversions.cs:16,23`); it needs no change. -- **Q4. An overload trap, probed.** `quaternion` converts implicitly from `float4`, and CultMath has no - `mul(float4, float4)`. `probe3` declares `mul(quaternion, quaternion)` beside scalar and matrix `mul` overloads and - calls it with two `float4`: it compiles and returns the quaternion product. HLSL's `mul(vector, vector)` is the - inner product, and Unity.Mathematics 1.3.3 (the copy in Aetheria's PackageCache) defines `mul(float4 a, float4 b)` - as such (`matrix.gen.cs:129`), so the same call there is a dot product. The cut therefore adds HLSL's vector - `mul(float2|3|4, float2|3|4)` (dot) beside the quaternion `mul`, so a `float4` pair keeps its shader meaning. -- **Q5. Unity.Mathematics as reference, not template.** Its signatures for `mul`, `rotate`, `conjugate`, `inverse`, - `AxisAngle` and `slerp` (`quaternion.cs:99,493,502,630,651,678`) are the consumer's stated convention ("`mul(a, b)` - applies `b` first"). CultMath's design rule is to state semantics in code and not copy Unity.Mathematics - (`docs/design.md:465-469`), so the formulas are written from the definitions below. - -### Semantics the cut lands - -Quaternions are Hamilton, stored xyzw, unit for rotation; angles are radians, right-handed about the axis. - -- `math.mul(quaternion a, quaternion b)`: the Hamilton product; `rotate(mul(a, b), v) == rotate(a, rotate(b, v))`. -- `math.rotate(quaternion q, float3 v)`: `t = 2 cross(q.xyz, v); v + q.w t + cross(q.xyz, t)`; q assumed unit. -- `math.conjugate(q)`: (-x, -y, -z, w). `math.inverse(q)`: `conjugate(q) / dot(q, q)`, no guard (zero in, non-finite - out, as HLSL division). -- `quaternion.AxisAngle(float3 unitAxis, float radians)`: (axis sin(r/2), cos(r/2)); the axis is not normalised. -- `math.slerp(a, b, t)`: shortest arc (negate b when `dot(a, b) < 0`); normalised lerp when the quaternions are - nearly parallel; t is not clamped. -- `math.swing_twist(q, unitTwistAxis, out swing, out twist)`: twist is q's projection onto the axis, normalised - (identity when that projection vanishes, a half-turn swing); `swing = mul(q, conjugate(twist))`, so - `q == mul(swing, twist)` (twist applied first). -- `math.clamp_twist(twist, unitAxis, min, max)`: angle `2 atan2(dot(twist.xyz, axis), twist.w)` wrapped to (-pi, pi]; - inside [min, max] the input is returned unchanged, otherwise `AxisAngle(axis, clamp(angle, min, max))`. -- `math.clamp_hinge(q, unitAxis, min, max)`: `clamp_twist` of q's twist about the axis; the swing is discarded. -- `math.clamp_cone(swing, unitAxis, maxAngle)`: the angle between `rotate(swing, axis)` and `axis`; inside the cone - the input is returned unchanged, otherwise the rotation by `maxAngle` about `normalize(cross(axis, - rotate(swing, axis)))` (at a half turn, where that cross product vanishes, about the swing's own axis). -- Preconditions (`min <= max`, unit axes) are documented, not checked, as everywhere in `math`. - -### What GameCult.Animation will need from this cut (not mapped here) - -- From cut 4: `mul`, `rotate`, `AxisAngle` for `AimChain.Pose` and `EffectorDirection`; `conjugate` or `inverse` for - frame changes; `swing_twist` and the clamps if its joints ever carry cone or twist limits (the presenter's per-axis - boxes do not). -- From cut 1: start-independent `BoundedLeastSquares` at a tight tolerance. `AimChainSolver.Solve` is warm-started - from `current`; without cut 1 its answer would depend on the previous frame exactly as the allocator's did. -- A CultMath release that carries cut 4, which `org.gamecult.animation`'s `package.json` pins. That release is - mapped with GameCult.Animation, so one Soul-verified release pair ships both. - -## Observed, not owned by these cuts - -- At the default tolerance the solver's answer on allocator-shaped problems depends on the start by up to the whole - box (B6). That is documented and pinned (`AnAllocatorShapedProblemIsStartIndependentAtATightTolerance`); a - consumer that needs one answer passes a tight tolerance, as Aetheria does. diff --git a/docs/cultlib-gaps-target.md b/docs/cultlib-gaps-target.md deleted file mode 100644 index bace5db8..00000000 --- a/docs/cultlib-gaps-target.md +++ /dev/null @@ -1,32 +0,0 @@ -# CultLib Gaps: Target - -Date: 2026-10-09. Campaign `cultlib-gaps` in the Eureka mind. - -## Why - -Consumers of CultLib keep finding capabilities a reasonable consumer of a general -library would expect and that CultLib lacks. Doctrine says a gap is filled in its -owner, never worked around in the consumer. This campaign is the standing home for -those gaps, so each one lands in CultLib as a small cut instead of a local helper in -whichever project hit it. - -Known gaps at opening (each a follow-up in the mind, owned by the consumer campaign -that found it): - -- CultMath `BoundedLeastSquares.Solve` has a fixed KKT tolerance (1e-6); Aetheria's - thrust allocator needs a tighter one (`aetheria-release:follow_up:cultmath-bls-kkt-tolerance`). -- `cultcache-rs` has no decimal type, its snapshot reads follow symlinks, and its - single-file store stages files with the process umask and no mode option - (`eureka-body:follow_up:cultcache-rs-decimal-and-nofollow`). - -## Invariants - -- `owner-fills-gap`: a capability a consumer needs from CultLib is added to CultLib, with the consumer adopting it; no consumer-local copy survives the cut that adds it. -- `defaults-unchanged`: a new option defaults to today's behaviour; existing callers and stored bytes do not change. -- `wire-parity`: a CultCache wire change keeps byte parity across runtimes against the C# reference, with a cross-runtime fixture. -- `semver-measured`: a public API change bumps the package version by measured semver and ships as a tagged release consumers can pin. - -## Not in scope - -- Growing CultCache into a general database (memory `cultcache-scope-restraint`). -- Any consumer's adoption code beyond the pin bump; that stays in the consumer's campaign. diff --git a/docs/cultmath-interval-ground-cut-glsl-lowering.r2.spec.json b/docs/cultmath-interval-ground-cut-glsl-lowering.r2.spec.json deleted file mode 100644 index 4416b4c2..00000000 --- a/docs/cultmath-interval-ground-cut-glsl-lowering.r2.spec.json +++ /dev/null @@ -1,201 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "glsl-lowering", - "revision": 2, - "title": "GLSL lowering r2: Phacelle as its own MPL-2.0 file so CultMath.glsl is MIT, notices corrected, iv_exp in the fixture, fixture regenerated, glslang and dxc run", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-glsl-lowering", - "base": "3ac7250a", - "depends_on": [ - "interval-ops" - ], - "first": [ - "Follow-up on cut report cultmath-tapes:cut_report:cut-glsl-lowering.h1 (range c9bd003b..5ae207e8, no verdict yet; worktree F:\\Projects\\CultLib-glsl). Rulings in force: operator-split-phacelle, operator-compiler-downloads, self-exp-measure-in-site. Map: docs/cultmath-interval-ground-cut.md, 'Pass 3'. First commit: MERGE 3ac7250a (interval-ops r3's head, which Soul s2 found holds for everything this cut lowers) into hands/cultmath-glsl-lowering. Do not rebase: the branch is pushed, and the git rules forbid force-pushing a shared branch. Probed by Imagination in a scratch clone: the merge conflicts only in packages/cultmath/README.md. Resolve it by keeping r3's Intervals bullet (iv_frustum_ball, its rounding bound, the envelope), then r1's GLSL bullet, so the GLSL bullet sits at :48-53. design.md and HlslSourceCompatibilityTests.cs merge clean.", - "Second commit: regeneration alone (CULTMATH_WRITE_GLSL=1). Probed on the merge: CultMath.glsl gains 15 lines (cultmath_iv_frustum_ball with the r3 widening); the fixture does not change until this revision adds its families; GlslMirrorTests 4/4 and HlslSourceCompatibilityTests green (16 tests). Soul's range is 3ac7250a..HEAD, which carries r1's four commits through the merge, so the whole lowering gets its first verdict. Runs in parallel with interval-ops r4: r4 changes no src, HLSL or README, only NoiseBoundTests.cs and design.md's saving section (:475-512 at 3ac7250a, :533-570 after this merge), disjoint from this cut's :136-193. Do not merge r4's head into this branch.", - "The split (operator-split-phacelle). Transformation step 1 becomes: each #include is inlined in place, except an include whose file is under its own licence, which is lowered on its own into its own output file. The list of such includes is one table in GlslLowering, SeparateFiles = { \"CultMath.Phacelle.hlsl\" -> \"CultMath.Phacelle.glsl\" }, with the reason beside the entry (file-level MPL-2.0). That is an enumerated rule of the lowering, documented as step 1 in design.md; it is not a per-function special case, and nothing else is keyed by name. Lower(root) returns the two texts; Lower(string) stays for the inlined body if that is simpler, but there is one resolver (ReadShaderSource, generalised to accept the include predicate), never a second.", - "shaders/CultMath.glsl: the provenance line says it is generated from CultMath.hlsl and CultMath.Interval.hlsl, MIT, and that cultmath_phacelle is in CultMath.Phacelle.glsl, to be concatenated after this file by consumers that call it. The dropped include line leaves nothing behind. shaders/CultMath.Phacelle.glsl: its own provenance line (generated from CultMath.Phacelle.hlsl, MPL-2.0, requires CultMath.glsl before it), the MPL-2.0 header and attribution exactly as the HLSL carries them, the CultPhasor struct and cultmath_phacelle, guard CULTMATH_PHACELLE_GLSL. Both files pinned by CommittedGlslEqualsLowering; CULTMATH_WRITE_GLSL=1 writes both.", - "Pin tests over both files: NoHlslOnlyTokensSurvive runs on each; EveryPublicFunctionIsLowered takes the union of both files' definitions against the HLSL (minus texture samplers) and additionally asserts cultmath_phacelle and CultPhasor appear only in the Phacelle file; a new PhacelleFileCompilesOnlyAfterTheLibrary is not needed, the compile check below proves it.", - "The fixture (self-exp-measure-in-site). The site measures WebGL2 exp against the fixture, so iv_exp joins it; its C# bits come from the platform exp and differ by OS, so its entry carries tolerance \"ulp-bounded, platform exp\" and names the OS that generated it. GoldenFixtureMatchesCSharp parses the committed JSON (System.Text.Json, BCL) and compares family by family: text-equal for every family except those whose tolerance names the platform, which compare case by case within 1 ulp and print the maximum observed. One fixture, one writer, one tolerance field already in the format; no second fixture. The phacelle family stays in the fixture; the site's parity harness concatenates both GLSL files for that run (the site ships only CultMath.glsl), say so in design.md.", - "Notices: packages/cultmath/THIRD-PARTY-NOTICES.md :35-43 lists the MPL-2.0 files as math.Phacelle.cs, CultPhasor.cs, CultMath.Phacelle.hlsl with its Unity copy, and shaders/CultMath.Phacelle.glsl; CultMath.glsl is MIT and says so in its header. The package licence expressions (MIT AND MPL-2.0) do not change: the NuGet still ships the HLSL include. README :36-37 and :48-53 (after the merge) name both GLSL files and when a consumer needs the second. design.md :136-192: step 1 rewritten, the second file, the wrapper runs, the fixture's platform tolerance. Unity ships neither GLSL file.", - "Compile checks on Starfire (operator-compiler-downloads), one job each, detached with a log, polled in the foreground: tools/get-glslang.ps1 (16.6.0, the pinned SHA already in the script; if the published digest differs, stop and report, do not edit the pin to match); tools/compile-glsl.ps1 gains a -Phacelle switch and runs twice: the MIT-only wrapper over CultMath.glsl calling every function in it, and the full wrapper over both files calling every function including cultmath_phacelle. Negative controls, both must fail: -Body 'float x = lerp(0.0, 1.0, 0.5);' and the MIT-only wrapper with -Body calling cultmath_phacelle (proves Phacelle is not in CultMath.glsl). Then tools/get-dxc.ps1 and dxc -T lib_6_3 -HV 2021 on both HLSL copies, exit 0. The browser-pane WebGL2 probe of r1 is repeated on the two-file wrapper.", - "Carried from r1 and still out of scope, name them in the report: the fixture's ulp bounds on WebGL2 are measured by the site cut; Stryker is not re-run unless packages/cultmath/src changes in 3ac7250a..HEAD (it should not; the lowering lives in tests; interval-ops r3's Stryker evidence, Soul s2, stands). Deviations r1 reported that stand: the anchored token regex; the iv_exp absence is now resolved by this revision; the HLSL edits (damp splat, pcg3d order) stay." - ], - "deletes": [ - { - "path": "packages/cultmath/shaders/CultMath.glsl", - "lines": 100, - "note": "the inlined Phacelle block (:510-612 at 5ae207e8: MPL header, CultPhasor, cultmath_phacelle) leaves this file; it is regenerated, not edited." - }, - { - "path": "packages/cultmath/THIRD-PARTY-NOTICES.md", - "lines": 3, - "note": ":39-41 the sentence making CultMath.glsl MPL-2.0 as a whole." - } - ], - "keeps_moves": [ - "Transformation steps 2-9 and their order: unchanged; the cast scanner, saturate lowering, the guard and provenance mechanism stay.", - "Both tracked CultMath.hlsl copies stay one blob; no HLSL edit is expected in this revision (a dialect gap found by the two-file compile is fixed in the HLSL in the common subset, bit-identical, listed in the report).", - "HlslSourceCompatibilityTests' mirror and FindCultMathRoot: the resolver generalises in place; no second include resolver.", - "tests/CultMath.Tests/fixtures/glsl-parity.json: the same file, regenerated; families keep their order so the diff shows only the two additions." - ], - "adds": [ - "packages/cultmath/shaders/CultMath.Phacelle.glsl: generated, MPL-2.0, guard CULTMATH_PHACELLE_GLSL.", - "GlslLowering: the SeparateFiles table and the two-text Lower; GlslMirrorTests: the second file in CommittedGlslEqualsLowering, NoHlslOnlyTokensSurvive and EveryPublicFunctionIsLowered; GoldenFixtureMatchesCSharp's per-family comparison with the platform tolerance.", - "fixture families: cultmath_iv_frustum_ball (exact) and cultmath_iv_exp (ulp-bounded, platform exp).", - "tools/compile-glsl.ps1: -Phacelle switch (appends CultMath.Phacelle.glsl after the library and includes cultmath_phacelle in the calls).", - "design.md and README: the two files, the concatenation order, the fixture tolerance." - ], - "file_changes": [ - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/GlslLowering.cs", - "line": 24 - }, - "change": "Lower takes the root (or the resolver's two texts) and returns both outputs; SeparateFiles table with the MPL reason; ProvenanceLine per file." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs", - "line": 320 - }, - "change": "ReadShaderSource accepts a predicate (or returns the separated include's text beside the inlined body); the C# mirror keeps inlining everything." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/GlslMirrorTests.cs", - "line": 30 - }, - "change": "CommittedGlslEqualsLowering over both files; :45 NoHlslOnlyTokensSurvive over both; :54 EveryPublicFunctionIsLowered union plus the phacelle-only-in-its-file assertion; :64 GoldenFixtureMatchesCSharp per family with the platform tolerance." - }, - { - "location": { - "path": "packages/cultmath/tools/compile-glsl.ps1", - "line": 1 - }, - "change": "-Phacelle switch; the library text is CultMath.glsl, plus CultMath.Phacelle.glsl when set; the call list covers whichever functions are present." - }, - { - "location": { - "path": "packages/cultmath/THIRD-PARTY-NOTICES.md", - "line": 35 - }, - "change": "MPL-2.0 file list: the two C# files, the HLSL include and its Unity copy, shaders/CultMath.Phacelle.glsl. CultMath.glsl is MIT." - }, - { - "location": { - "path": "packages/cultmath/README.md", - "line": 48 - }, - "change": "both GLSL files; a consumer concatenates CultMath.Phacelle.glsl after CultMath.glsl only when it calls cultmath_phacelle." - }, - { - "location": { - "path": "packages/cultmath/docs/design.md", - "line": 150 - }, - "change": "step 1 rewritten for the separated include; :182-192 the two wrapper runs and the fixture's platform tolerance; the site's parity run concatenates both files." - } - ], - "authority_map": { - "owner": "GlslLowering owns the HLSL -> GLSL transformation and now emits two derived files, one per licence; both are pinned by GlslMirrorTests and never edited. The fixture stays owned by GoldenFixtureMatchesCSharp with one tolerance field per family. THIRD-PARTY-NOTICES.md states which files are MPL-2.0 and is the one place that does.", - "inputs": [ - "shaders/CultMath.hlsl, CultMath.Interval.hlsl and CultMath.Phacelle.hlsl text at the merged head (3ac7250a merged into the branch)", - "C# math for the fixture values, including the platform exp for iv_exp" - ], - "outputs": [ - "shaders/CultMath.glsl (MIT) and shaders/CultMath.Phacelle.glsl (MPL-2.0)", - "tests/CultMath.Tests/fixtures/glsl-parity.json with cultmath_iv_frustum_ball and cultmath_iv_exp families" - ], - "derived_state": [ - "both GLSL files are derived; a hand edit to either fails CommittedGlslEqualsLowering", - "the fixture is derived from C#; the iv_exp family is derived from the generating platform's exp and compared within 1 ulp, every other family bit for bit" - ], - "forbidden_writers": [ - "no per-function special case in the lowering; the only name-keyed rule is the SeparateFiles table, one entry, licence-justified", - "no second include resolver, no PowerShell or JS copy of the transformation", - "no GLSL in the Unity package; no precision statement in either library file", - "no edit to the pinned glslang or dxc hashes to make a download pass" - ], - "shared_paths": [ - "the same dotnet test run pins the C# mirror, both GLSL files and the fixture", - "compile-glsl.ps1 is the one wrapper writer for the MIT-only run, the two-file run and both negative controls" - ], - "deletion_line": "The Phacelle block leaves CultMath.glsl by regeneration and the MPL sentence leaves the notices before the new file is added. Net: one more generated file and one switch; what it buys is an MIT CultMath.glsl the site can vendor without carrying MPL text, and the compile checks r1 could not run." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests green on the merged branch; paste counts; GlslMirrorTests 4/4 with the per-family fixture line printed", - "Starfire: tools/get-glslang.ps1 installs 16.6.0 with the pinned SHA matching; tools/compile-glsl.ps1 exits 0 on the MIT-only wrapper and on -Phacelle; both negative controls fail with the error quoted", - "Starfire: tools/get-dxc.ps1 then dxc -T lib_6_3 -HV 2021 on both HLSL copies, exit 0; FXC cs_5_0 still green", - "Browser pane WebGL2: the two-file wrapper compiles with an empty log" - ], - "tests": [ - { - "name": "GlslMirrorTests.CommittedGlslEqualsLowering", - "pins": "CultMath.glsl and CultMath.Phacelle.glsl are exactly the lowering of the committed HLSL; the regeneration path is the same code." - }, - { - "name": "GlslMirrorTests.EveryPublicFunctionIsLowered", - "pins": "the union of both files equals the HLSL's cultmath_* set minus texture samplers; cultmath_phacelle and CultPhasor live only in the Phacelle file." - }, - { - "name": "GlslMirrorTests.NoHlslOnlyTokensSurvive", - "pins": "no HLSL-only token in either file." - }, - { - "name": "GlslMirrorTests.GoldenFixtureMatchesCSharp", - "pins": "every family is C#'s current output bit for bit, except iv_exp within 1 ulp of the platform exp; iv_frustum_ball is present and exact." - }, - { - "name": "HlslSourceCompatibilityTests.EveryMirrorFunctionMatchesCSharpMath (existing)", - "pins": "no HLSL edit in this range changed a bit." - } - ], - "negative": [ - { - "pattern": "Mozilla|MPL|Johansen|CultPhasor|cultmath_phacelle\\(", - "scope": "packages/cultmath/shaders/CultMath.glsl: 0 matches; the header's file-name pointer to CultMath.Phacelle.glsl is the only mention of Phacelle." - }, - { - "pattern": "^CultPhasor cultmath_phacelle\\(", - "scope": "packages/cultmath/shaders/CultMath.Phacelle.glsl: exactly 1 match." - }, - { - "pattern": "CultMath\\.glsl|Phacelle\\.glsl", - "scope": "packages/cultmath/unity/**: 0 matches." - }, - { - "pattern": "\\b(float|u?int|bool)[234]\\b|\\blerp\\(|\\bfrac\\(|\\bsaturate\\(|\\brsqrt\\(|\\basuint\\(|\\basfloat\\(|static const|#include|precision (high|medium|low)p", - "scope": "both GLSL files: 0 matches (the anchored regex r1 settled on)." - }, - { - "pattern": "CultMath\\.glsl", - "scope": "packages/cultmath/THIRD-PARTY-NOTICES.md: 0 matches in the MPL-2.0 file list; CultMath.Phacelle.glsl appears there once." - }, - { - "pattern": "git diff 3ac7250a..HEAD -- packages/cultmath/src", - "scope": "empty; the lowering and the fixture live in tests, so interval-ops r3's Stryker evidence (verdict s2) stands for this range." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 320, - "lines_removed": 130, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [ - "GLSL ES 3.00 library file (generated, MPL-2.0): shaders/CultMath.Phacelle.glsl" - ], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "cultmath-tapes:ruling:operator-split-phacelle", - "cultmath-tapes:ruling:operator-compiler-downloads", - "cultmath-tapes:ruling:self-exp-measure-in-site", - "cultmath-tapes:ruling:operator-campaign-home" - ], - "questions": [] -} diff --git a/docs/cultmath-interval-ground-cut-glsl-lowering.spec.json b/docs/cultmath-interval-ground-cut-glsl-lowering.spec.json deleted file mode 100644 index 1f52e24c..00000000 --- a/docs/cultmath-interval-ground-cut-glsl-lowering.spec.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "glsl-lowering", - "revision": 1, - "title": "GLSL lowering: shaders/CultMath.glsl is generated from CultMath.hlsl by one enumerated textual transformation, pinned by a test, compiled by glslang, with a committed golden fixture for WebGL2 parity", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-glsl-lowering", - "base": "c49c76ee", - "depends_on": [], - "first": [ - "Map: docs/cultmath-interval-ground-cut.md, sections 'Where the interval math lives' (route C) and 'The authority map'. Model: the HLSL -> C# mirror in tests/CultMath.Tests/HlslSourceCompatibilityTests.cs (wrapper at :348) and its complete transformation list in packages/cultmath/docs/design.md:92-134. The GLSL lowering follows the same discipline: a complete, enumerated list; anything outside it fails the test rather than being patched around.", - "Read how HlslSourceCompatibilityTests resolves #include \"CultMath.Phacelle.hlsl\" (CultMath.hlsl:506); the GLSL lowering inlines the included file at that line, because GLSL has no #include.", - "Target dialect: GLSL ES 3.00 (#version 300 es), WebGL2. No implicit int/uint -> float conversion; step(vec4, float) and max(vec4, float) differ (max(genType, float) exists, step(genType, float) does not); C-style casts do not exist; lerp/frac/saturate/rsqrt/asuint are mix/fract/clamp(x,0.0,1.0)/inversesqrt/floatBitsToUint; floatN/intN are vecN/ivecN; static const is const. Mixed-signedness shifts are allowed.", - "Where the lowered text does not compile, fix the HLSL into the common subset with a legal, bit-identical HLSL edit (e.g. CultMath.hlsl:114 and :200 step(h, 0.0) -> step(h, float4(0.0, 0.0, 0.0, 0.0)); :471-473 and :502 (float)((uint)hash.x >> 8) before the float multiply). The HLSL -> C# mirror test and the FXC/dxc compiles keep those edits honest. Never special-case the lowering for one function.", - "Casts need a balanced-paren scanner, not a regex: (int)((state >> 28) + 4) at CultMath.hlsl:396 is the case that breaks a regex.", - "Dropped, as the C# mirror drops them: include guards (replaced by CULTMATH_GLSL guards), and the Texture2D/SamplerState functions at CultMath.hlsl:535-573. The GLSL declares no precision; the host shader does (precision highp float; precision highp int; the pcg hashes need 32-bit int).", - "Regeneration: the pin test writes shaders/CultMath.glsl when the environment variable CULTMATH_WRITE_GLSL=1 is set, then asserts equality. No new project, no PowerShell copy of the transformation.", - "Golden fixture: tests export 256 seeded points per function family (snoise float3/float2, snoise_grad, fbm_grad 4 octaves, ridged_grad, cellular, pcg3d/pcg4d, iv_* if present on main by then) with outputs as float32 bit patterns in hex, to tests/CultMath.Tests/fixtures/glsl-parity.json. JSON is tolerated here: the consumer is a browser-pane WebGL2 readback, a xenos boundary. The site cut evaluates it.", - "glslang: tools/get-glslang.ps1 fetches a pinned glslangValidator release the way tools/get-dxc.ps1 does; tools/compile-glsl.ps1 compiles a #version 300 es fragment wrapper that includes shaders/CultMath.glsl and calls every public function once. Run on Starfire, one job, detached with a log, polled in the foreground.", - "Verification on Yggdrasil: dotnet test from packages/cultmath/tests/CultMath.Tests; Stryker --since:c49c76ee from a plain clone (not a linked worktree: Stryker resolves --since paths against the main checkout). Never run verification as a background shell task." - ], - "deletes": [], - "keeps_moves": [ - "Both tracked CultMath.hlsl copies (packages/cultmath/shaders and unity/org.gamecult.cultmath/Shaders) stay one blob; the common-subset edits land in both.", - "The C# mirror test, the FXC probe and dxc -T lib_6_3 -HV 2021 all still pass on the edited HLSL; the Unity package does not ship the GLSL file.", - "design.md's HLSL -> C# transformation list (92-134) is unchanged; the GLSL list is a new sibling section." - ], - "adds": [ - "tests/CultMath.Tests/GlslLowering.cs: the HLSL -> GLSL ES 3.00 transformation, one static function string -> string, with the list as named steps in order: inline includes; drop guards and texture functions; type names; static const; casts via the balanced scanner; intrinsic renames (lerp, frac, saturate, rsqrt, asuint/asfloat); float literal passthrough; guards CULTMATH_GLSL added; a provenance header line naming the source file and that the file is generated.", - "tests/CultMath.Tests/GlslMirrorTests.cs: CommittedGlslEqualsLowering (writes when CULTMATH_WRITE_GLSL=1, prints a unified diff on failure); NoHlslOnlyTokensSurvive (regex over the output for float[234]\\(|int[234]\\(|lerp\\(|frac\\(|saturate\\(|static const|\\((float|int|uint)\\)|Texture2D|SamplerState -> 0 matches); EveryPublicFunctionIsLowered (the set of cultmath_* function names in the HLSL minus the texture ones equals the set in the GLSL); GoldenFixtureMatchesCSharp (regenerates the fixture in memory from C# and asserts equality with the committed file).", - "shaders/CultMath.glsl: the committed generated artifact.", - "tests/CultMath.Tests/fixtures/glsl-parity.json: the golden fixture (seed, points, per-function expected bit patterns, tolerance class per function: exact for integer-hash paths, ulp-bounded for transcendental).", - "tools/get-glslang.ps1 and tools/compile-glsl.ps1, mirroring get-dxc.ps1 / compile-hlsl-spirv.ps1 in shape.", - "packages/cultmath/docs/design.md: a section 'GLSL Target: Source Transformations' after :134 with the complete list, the common-subset rule for HLSL, the regeneration command, and that the GLSL is a derived file never edited by hand.", - "packages/cultmath/README.md: one paragraph that CultMath.glsl exists, what dialect it is, and how a WebGL consumer includes it (string concatenation before its own #version-led source; declare highp)." - ], - "file_changes": [ - { - "location": { "path": "packages/cultmath/shaders/CultMath.hlsl", "line": 114 }, - "change": "step(h, 0.0) -> step(h, float4(0.0, 0.0, 0.0, 0.0)); same at :200. Bit-identical in HLSL and C#." - }, - { - "location": { "path": "packages/cultmath/shaders/CultMath.hlsl", "line": 470 }, - "change": "jitter components and the id at :502: an explicit (float) cast around the shifted uint before the float multiply, so the lowered text has no uint*float." - }, - { - "location": { "path": "packages/cultmath/shaders/CultMath.Phacelle.hlsl", "line": 1 }, - "change": "whatever common-subset edits the glslang compile demands; each one bit-identical, each one listed in the cut report." - }, - { - "location": { "path": "packages/cultmath/docs/design.md", "line": 134 }, - "change": "new section: GLSL Target: Source Transformations." - } - ], - "authority_map": { - "owner": "GlslLowering (tests/CultMath.Tests) owns the HLSL -> GLSL transformation; shaders/CultMath.glsl is its derived output, pinned by GlslMirrorTests. CultMath.hlsl stays the one hand-written shader source.", - "inputs": [ - "shaders/CultMath.hlsl and shaders/CultMath.Phacelle.hlsl text", - "C# math for the golden fixture values" - ], - "outputs": [ - "shaders/CultMath.glsl (GLSL ES 3.00 library, every public cultmath_* function except texture samplers)", - "tests/CultMath.Tests/fixtures/glsl-parity.json" - ], - "derived_state": [ - "CultMath.glsl is derived; a hand edit fails CommittedGlslEqualsLowering", - "the fixture is derived from C#; a stale fixture fails GoldenFixtureMatchesCSharp" - ], - "forbidden_writers": [ - "no per-function special case in the lowering; a dialect gap is fixed in the HLSL in the common subset", - "no second transformation implementation (no PowerShell or JS copy of the rules)", - "no GLSL in the Unity package; no precision statement in the library file" - ], - "shared_paths": [ - "both tracked CultMath.hlsl copies receive the same edits; the existing one-blob rule covers them", - "the same dotnet test run pins the C# mirror, the GLSL pin and the fixture" - ], - "deletion_line": "Nothing is deleted in CultLib. The liability bought is one generated file, one test file, one fixture and two tool scripts; what it retires is every future hand copy of CultMath noise in a GLSL consumer, starting with the site." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests green; paste counts", - "Yggdrasil: dotnet stryker --since:c49c76ee from a plain clone; triage every survivor by name", - "Starfire: tools/compile-glsl.ps1 exits 0 on the wrapper over shaders/CultMath.glsl; a negative-control wrapper with one lerp( call must fail (records that the compile check sees errors)", - "Starfire: FXC cs_5_0 and dxc -T lib_6_3 -HV 2021 still compile both HLSL copies after the common-subset edits" - ], - "tests": [ - { - "name": "GlslMirrorTests.CommittedGlslEqualsLowering", - "pins": "the committed GLSL is exactly the lowering of the committed HLSL; the regeneration path is the same code." - }, - { - "name": "GlslMirrorTests.NoHlslOnlyTokensSurvive", - "pins": "the list is complete: no HLSL-only token survives in the output." - }, - { - "name": "GlslMirrorTests.EveryPublicFunctionIsLowered", - "pins": "no function is silently dropped except the texture samplers." - }, - { - "name": "GlslMirrorTests.GoldenFixtureMatchesCSharp", - "pins": "the fixture the site will read on WebGL2 is C#'s current truth." - }, - { - "name": "HlslSourceCompatibilityTests.EveryMirrorFunctionMatchesCSharpMath (existing)", - "pins": "the common-subset edits changed no bit of any HLSL function." - } - ], - "negative": [ - { - "pattern": "lerp\\(|frac\\(|saturate\\(|float[234]\\(|int[234]\\(|static const|\\((float|int|uint)\\)|Texture2D|SamplerState|#include", - "scope": "packages/cultmath/shaders/CultMath.glsl: 0 matches." - }, - { - "pattern": "precision (high|medium|low)p", - "scope": "packages/cultmath/shaders/CultMath.glsl: 0 matches (the host declares precision)." - }, - { - "pattern": "CultMath\\.glsl", - "scope": "packages/cultmath/unity/**: 0 matches; the Unity package does not ship the GLSL." - }, - { - "pattern": "git diff c49c76ee..HEAD -- packages/cultmath/shaders/CultMath.hlsl | grep '^[-+]' | grep -v '^[-+][-+]'", - "scope": "every changed HLSL line is listed in the cut report with the reason (dialect gap it closes); none changes a value, proven by the mirror test and the existing goldens." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 1100, - "lines_removed": 8, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": ["GLSL ES 3.00 library file (generated)", "glsl-parity.json fixture"], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [], - "questions": [] -} diff --git a/docs/cultmath-interval-ground-cut-interval-ops.r2.spec.json b/docs/cultmath-interval-ground-cut-interval-ops.r2.spec.json deleted file mode 100644 index 7792e114..00000000 --- a/docs/cultmath-interval-ground-cut-interval-ops.r2.spec.json +++ /dev/null @@ -1,219 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "interval-ops", - "revision": 2, - "title": "Interval ops r2: envelope-then-noise fields, scenarios with authored empty space including the void, the tile march on cell ranges, iv_frustum_ball, wasted probes removed, dxc run", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-interval-ops", - "base": "c9bd003b", - "depends_on": [], - "first": [ - "Follow-up on cut report cultmath-tapes:cut_report:cut-interval-ops.h1 (head c9bd003b, worktree F:\\Projects\\CultLib-iv). Rulings in force: operator-tile-amortized-march (the bound stays; one probe per screen tile), operator-compiler-downloads. The operator's challenge, verbatim in the map's Pass 3 section: r1 measured a uniform noise slab with no empty space to skip, the worst case for intervals, and the density that matters is an analytic envelope (a pre-distortion SDF) modulated by noise, where the envelope's interval is tight and proves whole ray lengths empty in one probe. Map: docs/cultmath-interval-ground-cut.md, 'Pass 3'. r1's ops and bounds stay; this revision touches math.Interval.cs, CultMath.Interval.hlsl (both tracked copies), NoiseBoundTests.cs, design.md and README only.", - "The field, from Aetheria (Volumetric.cginc:165-221 and :91-102; Zone.cs:369-397 GetHeight, :426 PowerPulse; Settings.asset). SDF s(p) = p.y + h(p.xz), h >= 0 the well map: h = PowerPulse(|p.xz| / (2R), 2) * 64 (the zone bowl) + sum over wells of PowerPulse(|p.xz - c_b| / r_b, 16) * d_b, with PowerPulse(x, e) = (1 - 4x^2)^e for x in [0, 1/2] and 0 beyond, r_b = 500 M^0.25, d_b = 30 M^0.175 (Aetheria's GravityRadius/GravityDepth curves). Noise only where s < S: fade(s) = 1 - smoothstep(0.75 S, S, s); displaced height s' = s + A fade(s) n(p) with n the warped two-phase coverage noise plus half the detail octave (r1's field shape); density = max(0, (F - s') / B) (Aetheria's floor: FloorOffset F = -20, FloorBlend B = 10; the patch band and the 1e-9 fill are left out). Above the safety distance density is exactly 0, and so is the noise cost: Aetheria's dense march gates the noise pointwise (`if (dist < _SafetyDistance)`); the test's dense march does the same.", - "The composed bound over a tile's frustum slice [z0, z1], Envelope over the slice's exact box, not the ball: with slopes m in [m_c - s, m_c + s] per axis and z in [z0, z1], y = iv_mul([z0, z1], m_y) and x = iv_mul([z0, z1], m_x) (plus the tile's translation o); h's interval over the xz box is the sum over bowls of [pulse(far), pulse(near)], near and far the least and greatest distance from the box to the bowl's centre (pulse is monotone decreasing in distance, so each term is exact; the only slack is the sum). iv_s = iv_add(y, iv_h); iv_fade = the ordered endpoints of fade over iv_s (monotone); iv_n = iv_snoise_ball(ball.xyz * F0, ball.w * F0) with ball = iv_frustum_ball(..., warp = D); iv_s' = iv_add(iv_s, iv_scale(iv_mul(iv_fade, iv_n), A)); the slice is provably empty iff iv_s'.lo >= F. When iv_fade.hi == 0 the noise term is identically zero and iv_snoise_ball is not evaluated: the envelope alone proves the slice empty at no snoise cost. That short-circuit is what tiles compound.", - "Where the warp lives in the bound. Aetheria warps only the noise argument (triNoise3d(pos + fl * ...)); the surface height is read at the unwarped xz and the displacement is applied to y afterwards. So the envelope is evaluated on the pre-distortion SDF over the unwarped slice (no D), and only the noise ball is enlarged by D (iv_frustum_ball's warp argument). A warp applied to the envelope's argument would be unsound without enlarging the box by D; the field is defined so that it is not. The test EnvelopeBoundEnclosesDensity pins this: 2,000 seeded slices x 64 warped points, the composed bound encloses density(p) with no tolerance (every op is monotone or already widened in r1; if a seeded case fails at an endpoint, widen in the implementation, never the test).", - "iv_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warp) -> float4(centre, radius), in C# and both HLSL copies, is the one new CultMath function: the noise ball of a tile over a depth segment. Camera: pinhole at the origin looking +z, focal length f pixels; a pixel's ray is p(z') = (m z', z'); a tile's slopes lie in m_c + [-N/(2f), N/(2f)]^2 (full footprint, so sub-pixel jitter is covered), s = N / (sqrt(2) f). Centre c = (m_c z_m, z_m), z_m = (z0 + z1) / 2; radius r = ((z1 - z0) / 2) |(m_c, 1)| + z1 s + warp. Proof: a point of slope m_c + e (|e| <= s) at depth z' is c + (z' - z_m)(m_c, 1) + z'(e, 0), the terms bounded by the two radius terms, and the warp moves it by at most D (WarpedPointsStayEnclosed). The slice is a convex polytope, so every point between rays is enclosed too. The two vectors are never parallel, so the inequality is strict and float32 cannot cross it.", - "(Tile ball, continued.) Test TileBallEnclosesEveryRaySegment: 2,000 seeded tiles (N in {1, 4, 8, 16}, f in [500, 3000], |m_c| <= 1.1, segments across each scenario's z range), 64 points each with sub-pixel offsets, both depth ends and a flow of length <= warp; no tolerance. Hand mutations that must die, listed in the file header: z0 for z1 in the lateral term; |m_c| for |(m_c, 1)|; the warp dropped. A moving camera needs nothing more: every frame's pre-pass evaluates iv_frustum_ball from that frame's camera and never carries a ball, a mask or a probe result across frames; the only cross-frame state is the TAA history, which is colour, not a soundness input. The test says so by drawing each tile's camera independently.", - "Implementation review of r1's march (NoiseBoundTests.cs:344-376), each item fixed here: (1) every probe was charged one snoise per ray; the tile shares it (ruling). (2) Coarse probes were attempted where the ball could never prove emptiness: iv_snoise_ball's hi is n(c) + L r clamped to 1, so a probe with L r F0 >= 1 + cutoff is a guaranteed failure; at r1's StepMax = 2 that is L r F0 = 3.7, so every coarse probe was a wasted evaluation (the 0.74x row). r2 attempts a noise probe only when L * radius * F0 < 1 - (the cutoff the probe needs), otherwise the level is 'maybe' at no cost. (3) Growth was capped at StepMax = 8 Step0, so a ray through clear space paid Depth / StepMax probes; r2 grows to the remaining range (the hierarchy is over cell-index ranges, halving on maybe, doubling on skip, capped only by the grid's end).", - "(Review, continued.) (4) The dense sample evaluated the detail octave even where occupancy was 0; r2's dense sample evaluates coverage first and the detail only when the envelope and coverage leave density > 0, as Aetheria's `if (dist < _SafetyDistance)` does; the dense baseline gets cheaper and the comparison honest. (5) The finest-level probe before integrating a cell stays: amortized over the tile it costs 1/N^2 and can skip 3 snoise per ray. (6) The step never regrew after a dense cell until a skip; with (3) it regrows from the next skip, which is enough.", - "The march, on cell ranges. The dense grid is a scenario-owned list of cell boundaries z_0 < ... < z_J (uniform for the slab scenarios; Aetheria's quadratic spacing z_j = near + (j/J)^2 (far - near), J = 256, for the Aetheria-like ones, from CloudShader.shader:116). MarchTile takes a range [j0, j1): the envelope probe over the slice (z_j0, z_j1); if empty, skip and double the next range; else if the noise probe is affordable (item 2) and proves empty, skip; else if the range is more than one cell, halve; else the cell is dense. It runs to the grid's end once per tile (a pre-pass does not know any ray's transmittance) and yields the dense cells; each of the N^2 rays integrates exactly those cells in order with the dense march's own Integrate and early-out at 0.02. Counted separately: snoise evaluations and envelope evaluations (pointwise in the dense march; interval probes in the tile march), per ray with probes divided by N^2.", - "The cost model, printed and reasoned about in snoise units: a pointwise envelope evaluation or an envelope probe costs e = 0.2 (a handful of pulses or a height-map fetch against ~150 flops of snoise; stated as an estimate, both counts printed so any weight can be applied). Per scenario the test prints: dense snoise and envelope per ray, tile snoise and envelope probes per ray, the combined cost ratio, and the probe-free ceiling (dense cost over the cost of the dense cells alone). The 2x contract is on the combined cost at N = 8 for scenarios (a) and (c); (b) and (d) are printed as the worst cases and not asserted.", - "Scenarios (IV-REPORT lines, each with 64 tiles at N in {1, 4, 8, 16}, warp in {0, D}): (a) height fog: h = 0, camera at y = S + 30, rays with slope m_y in [0, 0.5] (level and up), Aetheria's grid, expected near-total skip (0 snoise either way; the envelope count carries the ratio). (b) inside the fog: h = 0, camera at y = F - 10, rays level, expected near 1x: every ray saturates within a few cells and the pre-pass still probes the whole grid. (c) Aetheria-like: the zone bowl R = 2000 and four wells of mass {100, 1000, 10000, 1000} at seeded positions inside R, camera at a seeded xz in the bowl at y = max(0, S + 10 - h(camera)), rays gazing across with m_y in [-0.25, 0.1], Aetheria's units (noise scale 414 so F0 = 1/414, D = 15 * 8 / 2 = 60, A = 20 with snoise in [-1, 1]), Aetheria's grid. (d) the uniform slab: r1's field and parameters, kept as the reported worst case. The headline is (e) at N = 8, 200 tiles, printed with both its numbers; (a) and (c) are asserted.", - "(e) the void, the shipped scene (rulings operator-ground-void-brush, operator-void-true-cavity; site-ground r3): a cloud volume everywhere, carved by one negative pseudo-Gaussian sphere, parametrised by the hollow radius Rh (density exactly 0 inside) and the ramp width S (density rises to full over [Rh, Rh + S]); the brush (1 - (d / Rc)^2)^e with CARVE gives Rh = Rc sqrt(1 - CARVE^(-1/e)) and S from the exponent, so (Rh, S) are the authored knobs and (Rc, e) derived. Noise displaces the wall only: fade(d) = smoothstep(Rh - S, Rh, d); d' = d + A fade(d) n(warp(p)), A = 20, F0 = 0.01 (wavelengths 100 and 25), D = 10; K = 1/30 (optical depth 1 per 30 units of full density), termination at T < 0.02. Shipped point: Rh = 198, S = 50, the sun on the hollow's bottom, the camera 120 behind it along the orbit tangent and 45 above it (186 from the centre, 'low'). Rays over the whole frustum (vertical FOV 60, f = 935, so theta_px = 1/f). Every ray crosses empty interior and ends in a wall.", - "Footprint LOD (the operator's challenge, map 'Footprint LOD'): theta_px = 2 tan(fov/2) / H; the footprint at distance z is z theta_px. Step: Delta(z) = max(k z theta_px, min(S / 4, lambda_fine(z) / 2)), k = 4: never finer than four footprints, otherwise the finer of the two content limits (four samples across the ramp, two per wavelength of the finest live octave). Octaves: octave i of wavelength lambda_i carries weight w_i(z) = 1 - smoothstep(lambda_i / (2m), lambda_i / m, z theta_px), m = 4: one smooth blend per octave, no popping; TAA hides per-frame sparsity. The weights are part of the field, so the bound encloses the truncated field exactly: the noise interval over a slice is the sum over octaves of iv_mul([w_i(z1), w_i(z0)], iv_snoise_ball(c F_i, r F_i)), w_i monotone in z. At the shipped parameters (wavelengths 100 and 25, z <= 2 Rc) every weight is 1 in the frustum and the content limits set the step; the footprint bites when S < 4 k z theta_px.", - "(e) runs three marches per tile and prints them: the fixed-step reference (Delta_fixed = min(10, S / 4) everywhere, the pointwise envelope gate, the baseline a march that does not know where the wall is must pay); the masked fixed-step march (the same cells, so transmittance agrees exactly: the soundness pin, as (a)-(d)); and the masked LOD march, the shipped one (steps from Delta(z) inside the unmasked range only, octave weights applied), whose transmittance must be within 0.02 of the reference (printed; an approximation by design, not a soundness claim). Printed per configuration: steps per pixel and snoise per pixel for all three, the combined cost ratio reference / LOD, probes per tile. The grid for (e): Rh in {100, 200, 400, 1000} x camera offset in {centred, mid (0.5 Rh), low (0.94 Rh, the shipped)} x S in {10, 50, 150}, 32 tiles each at N = 8; the shipped point with 200 tiles.", - "Predictions to confirm or refute, N = 8, combined cost: (a) above 50x. (b) 0.8-1.0x. (c) 2-4x: clear cells collapse to a few probes per tile, fog cells cost the same on both sides; the noise ball proves nothing at Aetheria's scale (L r F0 >= 1.6), so item 2 keeps it unevaluated and the saving is the envelope's. (d) 1.3-1.5x: the ceiling at L = 10.099261. (e), from Imagination's model (scratchpad cavity_model.py): the LOD march needs about 6 steps and 12 snoise per pixel at every grid point with S <= 50 (the content limits S / 4 and the detail half-wavelength 12.5 set the step, not the footprint); S = 150 needs 14 steps and 36 snoise. Against the fixed-step reference at the shipped point: steps 35 to 6 (5-8x fewer), combined cost 1.7x, snoise alone 1.25x; cost 3.2x at S = 10, 1.4x at S = 150, 2.5x at Rh = 1000; camera offset barely matters. (e)'s contract is steps per pixel (Q8 retired). If (a) or (c) misses 2x, skip naming saving-2x-scenarios. Never tune the fields, the grids or e.", - "Stryker on Yggdrasil from a plain clone: --since:c9bd003b -m math.Interval.cs; report timeouts separately from kills (a timeout is not a demonstrated kill); if the saving test is what times mutants out, exclude it from Stryker's test selection (a measurement, not a pin) rather than raising the timeout. Compile checks on Starfire, one job, detached with a log, polled in the foreground: FXC cs_5_0 over every cultmath_iv_* including the new function, both tracked copies; then tools/get-dxc.ps1 (pinned, ruling operator-compiler-downloads) and dxc -T lib_6_3 -HV 2021 on both copies. Carried from r1 and still out of scope, name them in the report: the Unity CultMath.dll is not rebuilt; the Unity HLSL copies stay one blob with packages/cultmath/shaders; public asfloat(uint) stays. Branch from c9bd003b; if main moved by docs only, say so as r1 did." - ], - "deletes": [ - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 33, - "note": ":344-376 MarchIntervals, the per-ray adaptive march with its StepMax cap and unconditional probes, replaced by MarchTile on cell ranges." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 10, - "note": ":401-408 the doc comment naming the r1 fork and :424-425 the Assert.Skip naming it; the fork is answered. A skip survives only on a shortfall in (a) or (c), naming saving-2x-scenarios." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 12, - "note": ":319-330 Density: the unconditional three-snoise sample is replaced by the envelope-gated sample (coverage first, detail only when density can be nonzero)." - }, - { - "path": "packages/cultmath/docs/design.md", - "lines": 15, - "note": ":423-437 the saving paragraph with r1's numbers (0.93x, 1.83x, 0.74x), replaced by the scenario paragraph with r2's printed numbers." - } - ], - "keeps_moves": [ - "Every iv_* op, both ball bounds, SNOISE_LIPSCHITZ and its provenance tests: untouched. The ruling keeps the bound; only the field model, the march and its test change.", - "SavingField's noise shape (F0 0.35 in the slab, the warped two-phase coverage, the detail octave, period 4) and (d)'s parameters: kept, as the worst case; scenario (d) must reproduce r1's dense count where the detail gating does not bite (print it).", - "MarchDense and Integrate: unchanged except that Density is envelope-gated; the dense grid becomes the scenario's boundary list.", - "IntervalTests, WarpedPointsStayEnclosed, TightnessReport, MeasureLipschitz, LipschitzConstantPinsSampledGradients: unchanged.", - "HlslSourceCompatibilityTests: no change expected; the new function must find its C# twin through the existing mirror." - ], - "adds": [ - "packages/cultmath/src/CultMath/math.Interval.cs: iv_frustum_ball after iv_fbm_ball, doc comment carrying the derivation and that the caller scales by F0 and adds its translation.", - "packages/cultmath/shaders/CultMath.Interval.hlsl: cultmath_iv_frustum_ball, same text in both tracked copies.", - "tests/CultMath.Tests/NoiseBoundTests.cs: Scenario (grid, wells, camera, ray slopes, units), SavingField with the envelope (PowerPulse wells, fade, floor), EnvelopeBound (the composed interval, test-side; iv_* ops only), MarchTile, MarchLod (footprint step and octave weights, the shipped march), the per-tile Run; TileBallEnclosesEveryRaySegment; EnvelopeBoundEnclosesDensity; IntervalSkipHalvesEvaluations prints the scenario x N x warp grid and asserts (a) and (c) at N = 8.", - "packages/cultmath/docs/design.md, 'Intervals': the frustum-ball paragraph after :401; the envelope-then-noise paragraph (how a consumer composes the bound, the short-circuit, where the warp lives); the rewritten saving paragraph with the four scenarios and the headline.", - "packages/cultmath/README.md :38-43: iv_frustum_ball named; one sentence that the bounds compose with an analytic envelope." - ], - "file_changes": [ - { - "location": { - "path": "packages/cultmath/src/CultMath/math.Interval.cs", - "line": 152 - }, - "change": "after iv_fbm_ball: public static float4 iv_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warp)." - }, - { - "location": { - "path": "packages/cultmath/shaders/CultMath.Interval.hlsl", - "line": 91 - }, - "change": "after cultmath_iv_fbm_ball: float4 cultmath_iv_frustum_ball(...); both tracked copies." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 294 - }, - "change": "SavingField becomes envelope-then-noise over a Scenario; Density is envelope-gated; MarchTile replaces MarchIntervals; Run draws tiles and N^2 rays each, counting snoise and envelope evaluations separately." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 409 - }, - "change": "IntervalSkipHalvesEvaluations: scenarios (a)-(e), N in {1, 4, 8, 16}, warp in {0, D}; the (e) grid Rh x offset x S with three marches; assert >= 2x combined cost for (a) and (c) and >= 2x fewer steps per pixel for (e) at the shipped point, else Skip naming saving-2x-scenarios." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 89 - }, - "change": "TileBallEnclosesEveryRaySegment and EnvelopeBoundEnclosesDensity beside WarpedPointsStayEnclosed." - }, - { - "location": { - "path": "packages/cultmath/docs/design.md", - "line": 401 - }, - "change": "the frustum-ball and envelope-composition paragraphs; :423-437 the saving paragraph rewritten with r2's printed numbers only." - }, - { - "location": { - "path": "packages/cultmath/README.md", - "line": 38 - }, - "change": "iv_frustum_ball named; the envelope composition in one sentence." - } - ], - "authority_map": { - "owner": "CultMath owns the interval ops, the noise bounds and now the frustum ball; a consumer (the test's SavingField, the site's pre-pass, Aetheria's march) owns its envelope and composes the bound from iv_* ops. The saving test owns the proving-ground numbers per scenario; the site's browser measurement owns the shipped gain. The bound (SNOISE_LIPSCHITZ, iv_snoise_ball) is unchanged.", - "inputs": [ - "the r1 interval surface, unchanged", - "a tile's geometry (centre slope, depth segment, footprint per depth, warp bound) and a scenario's grid, wells, camera and units; Aetheria's shapes and settings as read from its checkout, cited by file:line in the test" - ], - "outputs": [ - "iv_frustum_ball / cultmath_iv_frustum_ball: a ball enclosing every point of every ray of the tile over the segment, warped", - "printed numbers per scenario: dense and tile snoise and envelope counts per ray, combined cost ratio, probe-free ceiling, at N in {1, 4, 8, 16}" - ], - "derived_state": [ - "the tile ball and the envelope box are derived from the tile's geometry; no radius is read from a texture, a uniform or a tuned constant", - "whether a noise probe is attempted is derived from L, the radius and the cutoff (item 2), never from a mode flag", - "the probe-free ceiling is derived from the same run; it states what no amortization can beat" - ], - "forbidden_writers": [ - "no change to SNOISE_LIPSCHITZ, iv_snoise_ball, the noise shape or e; the scenarios may not be tuned toward 2x", - "no per-ray probe in the tile march; no early-out of the pre-pass on any ray's transmittance", - "no warp on the envelope's argument; the warp enlarges the noise ball only", - "no new CultMath function for the envelope: PowerPulse, the box and the composition are consumer-side, built from iv_* ops", - "no tape, prune, affine or choice token in the interval files; no number in design.md or a comment that the committed test did not print in this run" - ], - "shared_paths": [ - "the dense march and the tile march integrate the same cells of the same grid with the same Integrate; the transmittance check is the proof that nothing provably empty was there", - "the one composed bound (EnvelopeBound) serves the enclosure test and the march; no second composition", - "the existing mirror test covers the new HLSL function; the Unity copy stays one blob" - ], - "deletion_line": "r1's per-ray march, its unconditional probes, its growth cap and the unconditional three-snoise dense sample go first; the tile march on cell ranges and the gated sample are written in their place. Nothing in src is deleted. The liability added is one geometry function and two tests plus the scenario model; it buys the tile-march soundness invariant in three runtimes and a saving number measured where there is empty space to find." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests green (MeasureLipschitz/MeasureMonotonicity excluded by trait); paste counts and every IV-REPORT line", - "Yggdrasil: dotnet stryker --since:c9bd003b -m math.Interval.cs from a plain clone; 0 survivors; timeouts listed separately from kills", - "Starfire: FXC cs_5_0 kernel over every cultmath_iv_* including cultmath_iv_frustum_ball, both HLSL copies", - "Starfire: tools/get-dxc.ps1 then dxc -T lib_6_3 -HV 2021 on both HLSL copies, exit 0" - ], - "tests": [ - { - "name": "NoiseBoundTests.TileBallEnclosesEveryRaySegment", - "pins": "every sample point of every ray of an N x N tile over a depth segment, sub-pixel jitter and warp included, lies inside iv_frustum_ball." - }, - { - "name": "NoiseBoundTests.EnvelopeBoundEnclosesDensity", - "pins": "the composed bound (envelope box, fade, noise ball enlarged by the warp) encloses density at every warped point of 2,000 slices, no tolerance; intervals-enclose holds for the composition the site and Aetheria will use." - }, - { - "name": "NoiseBoundTests.IntervalSkipHalvesEvaluations", - "pins": "scenarios (a) and (c) at N = 8 cost at most half the dense combined cost with transmittance within 1e-3; (e) at the shipped point: the masked LOD march takes at most half the fixed-step reference's steps per pixel, the masked fixed-step march agrees exactly, the LOD march within 0.02; the (e) grid and every scenario, N and warp printed with both counts and the ceiling." - }, - { - "name": "IntervalTests.EveryOpEnclosesItsPoints (existing)", - "pins": "r1's enclosure for every op still holds." - }, - { - "name": "HlslSourceCompatibilityTests.EveryMirrorFunctionMatchesCSharpMath (existing)", - "pins": "cultmath_iv_frustum_ball matches iv_frustum_ball bit for bit." - } - ], - "negative": [ - { - "pattern": "tape|prune|affine|choice", - "scope": "math.Interval.cs and CultMath.Interval.hlsl: 0 matches (case-insensitive)." - }, - { - "pattern": "snoise_grad|fbm_grad", - "scope": "math.Interval.cs and CultMath.Interval.hlsl: 0 matches." - }, - { - "pattern": "PowerPulse|pulse|envelope|Scenario", - "scope": "math.Interval.cs and CultMath.Interval.hlsl: 0 matches; the envelope is consumer-side." - }, - { - "pattern": "Assert\\.Skip", - "scope": "NoiseBoundTests.cs: at most one, in IntervalSkipHalvesEvaluations, naming saving-2x-scenarios; 0 if (a), (c) and (e) meet their contracts." - }, - { - "pattern": "10\\.099261|0\\.35f", - "scope": "git diff c9bd003b..HEAD -- packages/cultmath/src: the constant is not touched; the slab's F0 stays in (d)." - }, - { - "pattern": "git diff --name-only c9bd003b..HEAD", - "scope": "only packages/cultmath/**; both tracked CultMath.Interval.hlsl copies change together." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 420, - "lines_removed": 80, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "cultmath-tapes:ruling:operator-tile-amortized-march", - "cultmath-tapes:ruling:operator-ground-void-brush", - "cultmath-tapes:ruling:operator-void-true-cavity", - "cultmath-tapes:ruling:operator-compiler-downloads", - "cultmath-tapes:ruling:operator-campaign-home" - ], - "questions": [] -} diff --git a/docs/cultmath-interval-ground-cut-interval-ops.r3.spec.json b/docs/cultmath-interval-ground-cut-interval-ops.r3.spec.json deleted file mode 100644 index d008f90f..00000000 --- a/docs/cultmath-interval-ground-cut-interval-ops.r3.spec.json +++ /dev/null @@ -1,268 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "interval-ops", - "revision": 3, - "title": "Interval ops r3: the frustum ball widened by its derived float32 bound, the analytic constant-density body, one shipped void, (c) held to its ceiling, LOD weights exercised, Stryker kills demonstrated", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-interval-ops", - "base": "43183276", - "depends_on": [], - "first": [ - "Follow-up on cut report cultmath-tapes:cut_report:cut-interval-ops.h2 (head 43183276, worktree F:\\Projects\\CultLib-iv) and Soul's verdict cultmath-tapes:verdict:cut-interval-ops.s1 with its five findings, each resolved below in order. New rulings in force: operator-wells-contract-vs-ceiling ((c)'s contract is at least 90% of the probe-free ceiling, not 2x) and operator-analytic-wall-body (where the envelope interval proves the density constant, one closed-form Beer-Lambert step). Map: docs/cultmath-interval-ground-cut.md, 'Pass 4'. r2's ops, field models, tile march and scenarios stand; this revision touches math.Interval.cs, both tracked CultMath.Interval.hlsl copies, NoiseBoundTests.cs, SnoiseBall tests in the same file, design.md and README only. Nothing new in src beyond the radius widening.", - "Finding 1, frustum-ball-float-crossing (Medium). The ball is widened, in C# and both HLSL copies: radius += (|c.x| + |c.y| + |c.z| + radius) * 2^-20 (the literal 9.5367431640625e-7, exact in float32), after the r2 radius. Derivation, u = 2^-24: the centre c = (m_c z_m, z_m) carries at most two roundings per component (z_m = fl(z0 + z1) * 0.5, then the product), so |c_float - c_exact| <= 2u |c|_1; the radius carries at most seven first-order roundings (z1 - z0; the axis sqrt at 3u; the product; z1 * footprint; the sum; + warp), so r_exact <= r_float (1 + 7u); the widening's own addition rounds once more. 2^-20 = 16u covers 8u (|c|_1 + r) twice over. fma contraction removes roundings and only tightens, so dxc's HLSL and any driver's GLSL stay covered. The sentence 'the two vectors are never parallel, so the inequality is strict and float32 cannot cross it' leaves math.Interval.cs:179-180, the HLSL and design.md:412; the rule and its derivation take its place.", - "(Finding 1, continued.) TileBallEnclosesEveryRaySegment gains Soul's extreme families beside the r2 domain, 2,000 cases each, 8 footprint corners at both depth ends with the flow pointed outward along the corner's direction from the centre, the distance computed in double from the float ball and the float ray (point (m z, z) formed in double from the float m and z), no tolerance: z0 == z1; thin (z1 - z0 = 1e-6 z1); |m_c| up to 1000; far (z up to 1e7); z0 = 0 with z1 down to 1e-3; f down to 1; warp up to 1e6. The derivation pin becomes two-sided: r_exact <= ball.w <= r_exact + 2^-19 (r_exact + |c|_1), r_exact in double, so a ball that forgets the widening fails and a ball that grows past the rule fails. The hand mutations of r2 stay; a fourth, the widening dropped, must fail the degenerate family alone. WarpedPointsStayEnclosed is unchanged.", - "Finding 2, aetheria-far-plane-miscited (Low). FogField's grid becomes Quadratic(0.3, 2048, 256), cited as the Main Camera (Aetheria d3075eb0 Assets/Scenes/ARPG.unity:31777 m_Name Main Camera, :31830 far clip plane 2048; VolumeCloudRenderer.cs:36 RequireComponent(Camera)); the comment at NoiseBoundTests.cs:594 no longer names the Tint camera's 1000. Soul re-measured (c) at far 2048: 1.39-1.51x at warp D, 2.46-2.74x at warp 0, ceiling within 1-2% of the ratio; the verdict on (c) does not move. Print every (a)-(c) row again at 2048.", - "Finding 3, shipped-void-two-scenes (Medium). ONE shipped void, authored as (Rh, S) per the map's own rule, everything else derived; the map, the site-ground r3 spec and the test agree on it: Rh = 198, S = 50, so Rc = Rh + S = 248 and e = -ln CARVE / ln(1 - (Rh / Rc)^2) = 0.40 (CARVE 1.5); fade band [Rh - S, Rh], A = 20, F0 = 0.01, D = 10, K = 1/30. This is the scene r2 measured (2.21x) and the Footprint-LOD rule's; the map's site section (Rc 640, e 4, a 442-wide ramp) was the other scene and is superseded. The honest choice changes the look (a 50-wide noisy wall with a kinked outer edge, not a soft pseudo-Gaussian wall), so it is Q9 in the map, a fork for the operator with (a) recommended. Hands codes (a); another ruling moves only the shipped constants and the site section. VoidField's doc comment derives (Rc, e) from (Rh, S) and names it the one shipped void.", - "Finding 4, lod-weights-never-exercised (Low). VoidField takes a focal length. One configuration reaches the weights: '(e) LOD far' Rh = 4000, S = 50, camera low, f = 467 (1080 rows at a 98 degree vertical FOV): theta = 1/467, so the fine weight (wavelength 25) is below 1 past z = 1460 and 0 past 2920, the coarse weight (100) below 1 past 5840, and the grid (|camera - c_v| + Rc + 6/K, about 7990) reaches both; 4 z theta exceeds 12.5 past z = 1460, so LodStep is footprint-set there too. It joins EnvelopeBoundEnclosesDensity's field list (the truncated check is no longer vacuous) and the saving test prints it, not asserted. Hand mutation that must fail the truncated check on it: w(z0) for w(z1) in WeightBound.", - "(Finding 4, continued: the deviation.) Recorded in the test's doc and design.md: the bound takes each octave weight over [w(z1), 1], not the spec's [w(z1), w(z0)], because one Bound serves the full field (w = 1) and the truncated one (w in [w(z1), w(z0)], w decreasing in z). [w(z1), 1] contains both, iv_mul is monotone in its interval argument, so the composed interval is a superset of either field's and encloses both. The slack is only in far tiles whose step the footprint already sets.", - "Finding 5, stryker-timeout-survivor (Low). Mutant 2525 (iv_sqr a.x >= 0 to a.x > 0) is equivalent: at a.x == 0 both branches return the same ends ((0, h) either way, (0, 0) when a.y == 0); the report says so by its diff, since numbers are per run. New enclosure cases kill the mirror-only survivors semantically: SnoiseBallEnclosesPoints and FbmBallEnclosesPoints draw radii LogUniform(1e-3, 1e3), so L / r in iv_snoise_ball (too tight once r > 1: at r = 100 the mutant's bound is 0.2 wide while snoise over the ball spans [-1, 1]) dies to an enclosure test, not only to the HLSL mirror. The mutants Soul listed as mirror-only (iv_scale s >= 0 to s > 0; the two iv_abs mutants) are hand-run and each either named equivalent with the one-line argument (signed zero or a boundary both branches map alike) or killed by one added point case in IntervalTests.", - "(Finding 5, continued.) Stryker runs again as r2 did, --since:43183276; every timeout in math.Interval.cs is hand-run (patch from the mutation report, dotnet test minus IntervalSkipHalvesEvaluations) and the report lists killed, survived and equivalent by diff. The report claims only demonstrated kills; a timeout is not a kill.", - "The analytic body (ruling operator-analytic-wall-body), consumer-side in the test and the site, no new CultMath function. When it applies: the Scenario's Bound over the remaining range [z, z_end] of the grid, gated, is a point interval with positive value: the envelope with the free noise interval [-1.5, 1.5] (coverage in [-1, 1] plus half the detail) proves fade = 1 and d_lo + A (fade n)_lo >= Rc, so every point of every ray of the tile over the rest of the grid has density exactly K for any noise value; or, generically, lo == hi > 0 from whichever path the bound took. Only then does the march integrate T *= exp(-K ext (z_end - z) |dir|) in one step and terminate (the grid end is past opacity by construction). For (a)-(d) no Bound is a positive point (the fog's density varies with s'), so the step never applies there, and the test asserts bodyStart = -1 for every (a)-(d) tile.", - "(Analytic body, continued.) MarchTile returns (dense cells, bodyStart, bodyDensity). As r2 on cell ranges; when a single cell is found not provably empty and its own gated bound is a positive point (the cell is provably constant), one more probe over [grid[j], grid[^1]]: if that is a positive point too, bodyStart = j, bodyDensity = its value, and every remaining cell is appended dense without probing (adding cells is always sound; it also drops the body's probes). The mask's meaning is unchanged, so the masked fixed-step march's exact agreement with the reference stands as the soundness pin. MarchLod: inside unmasked runs as r2; on reaching a cell >= bodyStart it takes the one analytic step over [z, grid end], counts one step, and stops.", - "(Analytic body, the grid end.) Every void configuration's grid ends at |camera - c_v| + Rc + 6/K (was 5/K): the body starts at d >= Rc + A 1.5 = Rc + 30 plus box slack, so 6/K leaves at least 4.9 of optical depth, T <= 0.0075 < 0.02, and 'unfinished rays 0' still prints. This is the grid end, not the field; the reference stops by opacity and its count does not move.", - "(Analytic body, the pin.) New test AnalyticBodyMatchesFineMarch over the (e) grid, the shipped void and the LOD-far configuration, 2,000 seeded tiles at N in {1, 4, 8, 16}: (1) wherever MarchTile reports bodyStart b: the Bound over [grid[b], grid end] is a positive point; the full and the truncated Density at 64 random (pixel, sub-pixel, cell >= b, depth in cell) points equal bodyDensity exactly, no tolerance; (2) the analytic factor exp(-bodyDensity ext L) over the body equals the fixed-step product of the body cells' Integrate factors (no early-out, same cells) within 1e-4 relative; (3) for every (a)-(d) tile bodyStart = -1. Hand mutation that must fail (1): in VoidField.Compose, CarveRadius for HollowRadius in the lo test (the body claimed from the ramp). The site's mirror of this (site-ground r3): the pre-pass writes the body-start cell in the texel's fourth word, the main pass takes the same one step; its browser check is the dense-reference agreement already in that spec.", - "Contracts after r3, asserted at N = 8 in IntervalSkipHalvesEvaluations, else one Assert.Skip naming saving-2x-scenarios with every shortfall: (a) at least 2x combined cost (the lower of warp 0 and D), measured 16384x. (c) at least 0.90 of its probe-free ceiling (Ratio / Ceiling, the lower of warp 0 and D), measured 0.99 at warp D and 0.96 at warp 0 in r2; the ruling's reading is that the ceiling is what intervals control and the fog band's cost is the field's. (e) at least 2x fewer LOD steps per pixel than the fixed-step reference at the ONE shipped void (200 tiles), the masked fixed-step march agreeing exactly and the LOD march within 0.02 of the reference. (b), (d) and the (e) grid incl. LOD-far: printed, not asserted. Nothing is tuned toward any contract: the fields, the grids (beyond the stated 6/K end), e = 0.2 and the seeds stay.", - "Predictions to confirm or refute (Imagination's rule from r2's printed rows: the LOD steps that evaluated noise are about snoise / 2.8 plus two pre-band steps; the rest were constant-body steps, which the analytic step makes one). Shipped void: steps per pixel 36.34 (ref) to about 12.5 (was 16.45), 2.6-3.3x fewer; snoise per pixel about 26.6, unchanged; combined cost about 1.38x (was 1.34x); envelope probes per tile about 50 (was 59.1). Grid, low camera, ref/LOD steps: S = 10 about 5-6x at Rh 100-400 and 11x at Rh 1000 (was 2.1-3.4x and 6.8x); S = 50 about 2.5x, 2.8x, 3.5x, 5.2x for Rh 100, 200, 400, 1000 (was 1.8, 2.2, 2.9, 4.5); S = 150 unchanged (rays end inside the 150-wide ramp before the body is proven). Rh 1000 centred S 10: about 30x (was 12.4x). LOD-far: printed, none predicted. If the shipped point lands under 2.6x, say which assumption failed: the pre-band's 0-snoise steps, or a body start later than Rc + 30 by box slack.", - "Compile and mutation checks as r2: Yggdrasil dotnet test (counts and every IV-REPORT line pasted); Stryker --since:43183276 -m math.Interval.cs from a plain clone with every timeout hand-run as in Finding 5; Starfire FXC cs_5_0 over every cultmath_iv_* on both HLSL copies and tools/get-dxc.ps1 then dxc -T lib_6_3 -HV 2021 on both, exit 0 (Soul could not re-run these for r2; they are re-run here because the HLSL changes). Carried and still out of scope, named in the report: the Unity CultMath.dll is not rebuilt; the Unity HLSL copies stay one blob with packages/cultmath/shaders; public asfloat(uint) stays. Main moved by docs only since 43183276's base (Imagination passes 3-3d and 4); say so. glsl-lowering r2 rebases onto this revision's head, not r2's (its fixture family for cultmath_iv_frustum_ball changes with the widening); its spec now says so." - ], - "deletes": [ - { - "path": "packages/cultmath/src/CultMath/math.Interval.cs", - "lines": 2, - "note": ":179-180 the sentence 'The two vectors are never parallel, so the triangle inequality is strict' and its float32 claim; replaced by the widening rule and its derivation." - }, - { - "path": "packages/cultmath/docs/design.md", - "lines": 1, - "note": ":412 'the two vectors are never parallel, so the bound is strict'; replaced by the rule." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 1, - "note": ":594 the Tint camera citation (ARPG.unity:635-636, far 1000); replaced by the Main Camera's :31830, far 2048." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 3, - "note": ":1181-1194 the 2x test on ratios[c] and the skip message's wording; replaced by the 0.90-of-ceiling test and a message naming each shortfall." - }, - { - "path": "packages/cultmath/docs/design.md", - "lines": 12, - "note": ":461-497 the r2 numbers (1.41x, 16.45, 2.21x, the (c) shortfall paragraph); replaced by r3's printed numbers and the three contracts." - } - ], - "keeps_moves": [ - "Every iv_* op, iv_snoise_ball, iv_fbm_ball, SNOISE_LIPSCHITZ and its provenance tests: untouched. iv_frustum_ball's centre and the r2 radius terms: untouched; only the widening term is appended.", - "FogField, SlabField, WarpedNoise, Compose, the gated probe (BestBall), MarchTile's range hierarchy, the masked fixed-step march and Run: kept; MarchTile gains the body return and MarchLod the one analytic step.", - "VoidField's field, Density, Bound, Weight, WeightBound and LodStep: kept; the constructor gains the focal length and the grid end moves to 6/K; the shipped point stays Shipped() = (198, 50, shipped camera).", - "TileBallEnclosesEveryRaySegment's r2 domain, EnvelopeBoundEnclosesDensity, IntervalTests, TightnessReport, MeasureLipschitz, LipschitzConstantPinsSampledGradients: kept; the first two gain cases.", - "HlslSourceCompatibilityTests: the mirror count stays 53; cultmath_iv_frustum_ball's new text must match the C# bit for bit." - ], - "adds": [ - "math.Interval.cs and both CultMath.Interval.hlsl: the widening line in iv_frustum_ball / cultmath_iv_frustum_ball, and the rule in the doc comment.", - "NoiseBoundTests.cs: the extreme families and the two-sided derivation pin in TileBallEnclosesEveryRaySegment; VoidField focal parameter and the LOD-far configuration; MarchTile's (bodyStart, bodyDensity); MarchLod's analytic step; AnalyticBodyMatchesFineMarch; the (c) ceiling contract; radii to 1e3 in the two ball tests; the WeightBound deviation in the doc comment; the shipped-void derivation in VoidField's doc comment.", - "IntervalTests.cs: at most three point cases for the mirror-only mutants that are not equivalent (Finding 5).", - "design.md 'Intervals': the widening rule and derivation; the analytic-body paragraph (condition, pre-pass word, one step, the pin); the WeightBound deviation; r3's printed numbers under the three contracts; the one shipped void with (Rc, e) derived.", - "README.md :41: one clause that iv_frustum_ball's radius carries its float32 rounding bound." - ], - "file_changes": [ - { - "location": { - "path": "packages/cultmath/src/CultMath/math.Interval.cs", - "line": 183 - }, - "change": "iv_frustum_ball: after the r2 radius, radius += (abs(cx) + abs(cy) + abs(zm) + radius) * 9.5367431640625e-7f; doc comment :168-182 states the rule and derivation in place of the strictness sentence." - }, - { - "location": { - "path": "packages/cultmath/shaders/CultMath.Interval.hlsl", - "line": 110 - }, - "change": "cultmath_iv_frustum_ball: the same widening line; both tracked copies (packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl identical blob)." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 128 - }, - "change": "TileBallEnclosesEveryRaySegment: the seven extreme families, outward flow at corners, double distance, the two-sided pin; the file header lists the fourth hand mutation (widening dropped) and the WeightBound and Compose mutations." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 58 - }, - "change": "SnoiseBallEnclosesPoints and FbmBallEnclosesPoints: radius LogUniform(1e-3, 1e3)." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 594 - }, - "change": "FogField: Grid = Quadratic(0.3, 2048, 256), Main Camera citation." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 829 - }, - "change": "VoidField: focal parameter (default 935); LodFar() = (4000, 50, low, f 467); grid end reach + Rc + 6/K; doc comment with the (Rh, S) -> (Rc, e) derivation, the one shipped void, the [w(z1), 1] deviation." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1009 - }, - "change": "MarchTile returns (cells, bodyStart, bodyDensity) with the one confirming probe; MarchLod takes the analytic step at bodyStart; Run and RunStats carry it; ReportVoid prints body steps." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1160 - }, - "change": "IntervalSkipHalvesEvaluations: (c) asserted as Ratio >= 0.90 Ceiling; the LOD-far row printed; the (e) grid printed with the analytic body; AnalyticBodyMatchesFineMarch added beside it." - }, - { - "location": { - "path": "packages/cultmath/docs/design.md", - "line": 403 - }, - "change": ":403-430 the frustum-ball paragraph gains the widening rule; :412 strictness sentence deleted; :461-497 the saving section rewritten with r3's printed numbers, the three contracts, the analytic body and the shipped void." - }, - { - "location": { - "path": "packages/cultmath/README.md", - "line": 41 - }, - "change": "iv_frustum_ball: 'its radius carries its own float32 rounding bound'." - } - ], - "authority_map": { - "owner": "CultMath owns the interval ops, the noise bounds and the frustum ball, whose enclosure promise now covers its own float32 rounding (the widening is part of the function, not of any consumer). The consumer (the test's Scenario, the site's pre-pass) owns the envelope, the composed bound, the body proof and the Beer-Lambert step. The saving test owns the proving-ground numbers; the operator owns the shipped void (Q9) and the contracts (the two rulings).", - "inputs": [ - "the r2 surface unchanged; a tile's geometry and warp; a scenario's grid, wells, camera, focal length and units, Aetheria's Main Camera far plane 2048 cited by line", - "the one shipped void as (Rh, S) = (198, 50); every other void constant derived from it" - ], - "outputs": [ - "iv_frustum_ball / cultmath_iv_frustum_ball: a float32 ball that encloses every exact point of every ray of the tile over the segment, warped, under float32 evaluation of the ball itself", - "per tile: the dense cells and, when the envelope proves the rest constant, the body-start cell and its density; printed numbers per scenario including the body steps" - ], - "derived_state": [ - "the widening is derived from the computed centre and radius (2^-20 of |c|_1 + r), never a tuned epsilon; a consumer adds nothing for the ball's own rounding and remains responsible for its world transform", - "(Rc, e) are derived from (Rh, S): Rc = Rh + S, e = -ln CARVE / ln(1 - (Rh/Rc)^2); no void constant is authored twice", - "the body start is derived from the same Bound the mask is derived from, by one more probe; the main pass reads it, never decides it", - "the (c) contract value is derived from the run (0.90 of its own ceiling); no absolute target is written for (c)" - ], - "forbidden_writers": [ - "no change to SNOISE_LIPSCHITZ, iv_snoise_ball, iv_fbm_ball, the noise shape, e = 0.2, the seeds or any field toward a contract; the grid end moves to 6/K for termination only", - "no analytic step from a pointwise density or from the noise ball alone: only a point-interval Bound over the whole remaining range proves the body", - "no early-out of the pre-pass on transmittance; no probe in the main pass (the body-start cell is read, its constant is one pointwise envelope value)", - "no second shipped void anywhere: the map's site section, the site-ground spec and VoidField.Shipped() name (198, 50) and derive the rest; no number in a doc or comment that the committed test did not print in this run", - "no new CultMath function; PowerPulse, the box, the composition and the Beer-Lambert step stay consumer-side; no tape, prune, affine or choice token in the interval files" - ], - "shared_paths": [ - "the masked fixed-step march still integrates exactly the dense march's cells (the soundness pin); only MarchLod takes the analytic step, and AnalyticBodyMatchesFineMarch ties that step to the fixed-step product over the same cells", - "one Bound serves the enclosure tests, the mask, the body proof and the gated probe; no second composition and no second constancy test", - "the widening lives once in C# and is mirrored bit for bit into both HLSL copies by the existing mirror test; GLSL follows by the lowering (glsl-lowering r2 rebases onto this head)" - ], - "deletion_line": "The false strictness claim leaves the C# doc, the HLSL and design.md before the widening is written; the Tint camera citation leaves before the Main Camera's is written; the (c) 2x assertion and the second shipped void leave before the ceiling contract and the one void are written. Net in src: one line and a doc comment. In tests: one new pin test, seven case families, one configuration, the body return; what they buy is intervals-enclose holding for the ball's own float32 evaluation, the analytic body the ruling asked for with its soundness pinned, LOD weights actually exercised, and a mutation report that claims only what it demonstrated." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests green (MeasureLipschitz/MeasureMonotonicity excluded by trait); paste counts and every IV-REPORT line, (a)-(d) at far 2048, the (e) grid with body steps, LOD-far, the shipped headline", - "Yggdrasil: dotnet stryker --since:43183276 -m math.Interval.cs from a plain clone; every timeout hand-run; killed, survived and equivalent listed by diff; 0 undemonstrated", - "Starfire: FXC cs_5_0 kernel over every cultmath_iv_* including cultmath_iv_frustum_ball, both HLSL copies, exit 0", - "Starfire: tools/get-dxc.ps1 (pinned) then dxc -T lib_6_3 -HV 2021 on both HLSL copies, exit 0, no diagnostics" - ], - "tests": [ - { - "name": "NoiseBoundTests.TileBallEnclosesEveryRaySegment", - "pins": "every exact point of every ray of the tile, corners at both depth ends with an outward flow, lies inside the float32 ball, in the r2 domain and in the seven extreme families, distance in double, no tolerance; the radius is the derivation plus at most 2^-19 (r + |c|_1) and at least the derivation." - }, - { - "name": "NoiseBoundTests.EnvelopeBoundEnclosesDensity", - "pins": "the composed bound encloses the full and the footprint-truncated density at every warped point of 2,000 slices, including the LOD-far configuration where octave weights are strictly between 0 and 1 and at 0." - }, - { - "name": "NoiseBoundTests.AnalyticBodyMatchesFineMarch", - "pins": "a body start is reported only where the Bound over the whole remaining range is a positive point and every sampled density there equals it exactly; the analytic factor equals the fixed-step product within 1e-4 relative; no (a)-(d) tile reports a body." - }, - { - "name": "NoiseBoundTests.IntervalSkipHalvesEvaluations", - "pins": "(a) at least 2x combined cost; (c) at least 0.90 of its probe-free ceiling; (e) at the one shipped void at least 2x fewer LOD steps per pixel, the masked fixed-step march exact, the LOD march within 0.02; every row printed including body steps; one Skip naming saving-2x-scenarios on any shortfall." - }, - { - "name": "NoiseBoundTests.SnoiseBallEnclosesPoints and FbmBallEnclosesPoints", - "pins": "the ball bounds enclose their functions for radii up to 1e3, so a bound tightened for r > 1 (L / r) dies to an enclosure test." - }, - { - "name": "IntervalTests.EveryOpEnclosesItsPoints (existing, plus point cases)", - "pins": "r1's enclosure for every op still holds; any non-equivalent mirror-only mutant from Finding 5 has a point case that kills it." - }, - { - "name": "HlslSourceCompatibilityTests.EveryMirrorFunctionMatchesCSharpMath (existing)", - "pins": "the widened cultmath_iv_frustum_ball matches iv_frustum_ball bit for bit; 53 functions compared." - } - ], - "negative": [ - { - "pattern": "never parallel|cannot cross|strict", - "scope": "math.Interval.cs iv_frustum_ball doc comment, CultMath.Interval.hlsl, design.md 'Intervals' frustum-ball paragraph: 0 matches." - }, - { - "pattern": "635-636|far 1000|Tint", - "scope": "NoiseBoundTests.cs: 0 matches; ':31830' and '2048' appear in FogField's citation." - }, - { - "pattern": "Rc = 640|e = 4\\b|Rc ~ 220|e ~ 0\\.6|about 220|about 0\\.6", - "scope": "NoiseBoundTests.cs and design.md: 0 matches; the shipped void is derived from (198, 50) as Rc = 248, e = 0.40." - }, - { - "pattern": "tape|prune|affine|choice|PowerPulse|pulse|envelope|Scenario|body|Beer", - "scope": "math.Interval.cs and CultMath.Interval.hlsl: 0 matches (case-insensitive); the analytic body is consumer-side." - }, - { - "pattern": "Assert\\.Skip", - "scope": "NoiseBoundTests.cs: at most one, in IntervalSkipHalvesEvaluations, naming saving-2x-scenarios; 0 if (a), (c) and (e) meet their contracts." - }, - { - "pattern": "10\\.099261|0\\.35f", - "scope": "git diff 43183276..HEAD -- packages/cultmath/src: the constant is not touched; the slab's F0 stays in (d)." - }, - { - "pattern": "git diff --name-only 43183276..HEAD", - "scope": "only packages/cultmath/**; both tracked CultMath.Interval.hlsl copies change together and stay one blob." - }, - { - "pattern": "git diff 43183276..HEAD -- packages/cultmath/src | grep '^[-+]' | grep -v '^[-+][-+]' | grep -v '///' | wc -l", - "scope": "at most 4 changed code lines in src: the widening line in iv_frustum_ball and nothing else." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 260, - "lines_removed": 40, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "cultmath-tapes:ruling:operator-wells-contract-vs-ceiling", - "cultmath-tapes:ruling:operator-analytic-wall-body", - "cultmath-tapes:ruling:operator-tile-amortized-march", - "cultmath-tapes:ruling:operator-measure-with-empty-space", - "cultmath-tapes:ruling:operator-footprint-lod-march", - "cultmath-tapes:ruling:operator-ground-void-brush", - "cultmath-tapes:ruling:operator-void-true-cavity", - "cultmath-tapes:ruling:operator-compiler-downloads", - "cultmath-tapes:ruling:operator-campaign-home" - ], - "questions": [ - "Q9 in the map: the one shipped void. (a, recommended) Rh 198, S 50, derived Rc 248, e 0.40, the scene r2 measured; (b) the site section's Rc 640, e 4; (c) Rh 198, S 100. Hands codes (a)." - ] -} diff --git a/docs/cultmath-interval-ground-cut-interval-ops.r4.spec.json b/docs/cultmath-interval-ground-cut-interval-ops.r4.spec.json deleted file mode 100644 index 8ee7fc2b..00000000 --- a/docs/cultmath-interval-ground-cut-interval-ops.r4.spec.json +++ /dev/null @@ -1,292 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "interval-ops", - "revision": 4, - "title": "Interval ops r4: LOD agreement against a converged march at the body start, BodyDepth pinned, (c) against an oracle ceiling, WeightBound pinned, design.md from r4's own run", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-interval-ops", - "base": "3ac7250a", - "depends_on": [], - "first": [ - "Follow-up on verdict cultmath-tapes:verdict:cut-interval-ops.s2 (range 43183276..3ac7250a, worktree F:\\Projects\\CultLib-iv), four findings, one item each below. Touches packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs and packages/cultmath/docs/design.md only: no src, no HLSL, no README. Question cultmath-tapes:question:wells-ceiling-oracle decides only (c)'s assertion lines (item 9). Self dispatches with its ruling in the brief. Line numbers are at 3ac7250a. Every probe number quoted here is from Imagination's scratch probe at 3ac7250a, with the test's own seeds, tiles and N = 8. It is never committed; r4's run reprints its own numbers.", - "Finding lod-agreement-blind-past-body (High), measured. Comparing with the 10-unit fixed-step march cannot pin LodStep. At the shipped void, the LOD march's T at the body start differs from it by up to 0.300 of max(T, 0.02). LodStep doubled differs by 0.309. Both are unconverged midpoint quadratures of a ramp with 25-unit detail. A converged march separates them: h = 0.5, which agrees with h = 1 to 0.0065. Relative optical-depth error per ray, max at the headline: fixed-step 0.061, LOD 0.086, LodStep x2 0.177, LodStep x0.5 0.036. With the pre-body integration dropped, T is wrong by 26.5x max(T, 0.02). So the LOD march is 1.4x less accurate than the dense march before the body. Report it; it is not tuned.", - "The agreement rule. MarchLod gains `float cutoff`; Run's costed march passes 0.02, as now. It returns (Transmittance, AtBody). AtBody is T when z first reaches the body start, before the body step, or the final T when there is no body. New helper ConvergedDepth(field, tile, slope, stop, h, lod) returns the optical depth in double, by midpoint quadrature at step h. It runs over EVERY grid cell before `stop`, never the mask's, so it trusts no pre-pass, using the field's Density.", - "(Agreement, continued.) In Run with lod, per ray, with stop = bodyStart, or the cell count (grid.Length - 1) when there is none:\n- tauConv = ConvergedDepth(..., stop, 0.5, lod: true).\n- tauLod = -ln(max(AtBody, 1e-30)) from a second MarchLod at cutoff 0.\n- tauRef = -ln of the product of Integrate over cells < stop, lod: false, with no early-out.\nRunStats keeps MaxLodDepthError and MaxRefDepthError, each max |tau - tauConv| / max(tauConv, 1e-3). The converged march and the cutoff-0 march count into a throwaway Counts and no steps, so cost rows do not move.", - "The (e) agreement contract replaces 'LOD within 0.02 at the end': at the shipped headline, MaxLodDepthError <= 2 x MaxRefDepthError. The footprint march may be at most twice as wrong as the dense march it is measured against. This mirrors the 2x step contract and is Imagination's default; Self may put it to the operator. Measured 0.086 <= 0.122. LodStep x2 and the dropped pre-body integration fail it. The end-of-ray assertion :1455 is deleted. End-of-ray |dT| stays printed. Every (e) row and LOD-far prints both errors and their ratio, which is printed and not asserted. LOD-far's tauRef carries the deliberate octave truncation, so its ratio is not comparable.", - "BodyFactor becomes BodyDepth (:1198-1201). It returns the optical depth Density x ext x (grid end - z) x |dir| as a float. MarchLod multiplies by exp(-BodyDepth(...)). AnalyticBodyMatchesFineMarch part (2) deletes its own tau and analytic (:1375-1377). It compares BodyDepth(field, tile, ray, grid[b], lod: true, counts) with the double sum over body cells of -ln(Integrate(cell, lod: true)), within 1e-4 relative. Probe: in the T domain the comparison underflows at LOD-far (float exp of about -256 is 0, relative error 1); in the depth domain it does not. With |dir| dropped, the depth error is |dir| - 1, at least 0.00145 at the shipped camera, so the mutant dies on every tile.", - "Finding wells-ceiling-contract-vacuous (Medium), measured at N = 8. Warp 0: ratio 2.744x, mask ceiling 2.855x (0.961), oracle ceiling 7.263x (0.378), oracle-empty cells skipped 0.952, skip-nothing pre-pass 0.136. Warp D: 1.391x, 1.401x (0.993), 7.165x (0.194), 0.842, 0.139. At warp D about 80% of the masked cost lies in cells where every ray's sample is 0, so design.md's 'where the rays need them' is false. The ruling's reason needs a ceiling the pre-pass cannot move. Hence the question.", - "Measurement, whatever the ruling. Run draws a tile's N^2 slopes first, then marches. The random stream reorders, so every IV-REPORT row reprints. The oracle mask is the cells whose Density at mid-depth is > 0 for at least one of those slopes, evaluated into a throwaway Counts. The oracle march runs each ray over the oracle cells only, with the same Integrate and early-out, costed into a new RunStats.Oracle. Assert its T equals the dense march's exactly (probe max |dT| 0). RunStats.Ceiling (:1259-1260) goes. In its place: OracleCeiling = Dense.Cost / Oracle.Cost; Efficiency = Oracle.Cost / (Masked.Cost + Probes.Cost); ProbeOverhead = Masked.Cost / (Masked.Cost + Probes.Cost); CullFraction = oracle-empty cells the mask skips / oracle-empty cells. Report prints all four.", - "(c)'s assertion, at N = 8, the lower of warp 0 and D, per the ruling on wells-ceiling-oracle. :1437 records the chosen value. For the cull floor, Assert.True fails rather than skips.\n- oracle-target-cull-floor (recommended): hard CullFraction >= 0.5, plus Efficiency >= 0.90 in the shortfall list.\n- oracle-target-only: the shortfall alone.\n- cull-fraction: CullFraction >= 0.90 in the shortfall list.\n- overhead-plus-floor: ProbeOverhead >= 0.90 in the shortfall list, plus the hard floor.\nThe contracts line names the measured quantity. Note: under options 1 and 2 the test skips today, naming saving-2x-scenarios with (c)'s shortfall; (a) and (e) are still evaluated and listed.", - "Finding weightbound-mutation-survives (Low). VoidField gains public (float2 Coarse, float2 Fine) WeightBounds(float z0, float z1) beside Weights(z) (:992). WeightBound (:1035) stays private and is what WeightBounds calls. New Fact WeightBoundEnclosesOneSignedNoise on LodFar, 2,000 cases: z0 ~ U(1460, 0.95 x grid end), z1 ~ U(z0, grid end), 16 depths in [z0, z1] including both ends. Each octave weight lies in its bound. For the one-signed noise interval n = [0.25, 1] and n_s in {0.25, U(0.25, 1), 1}, w(z) n_s lies in iv_mul(bound, n). Probe: the spec's mutant [w(z0), 1] misses w(z1) x 0.25 in 2000 of 2000 fine-octave cases on (1460, 2920). The header (:14-20) moves that mutant to this test.", - "Finding design-saving-section-stale (Medium). Rewrite design.md :475-512 from r4's final run, where every figure appears in an IV-REPORT line the report pastes. Delete :422-423's '6e-4 at the shipped scales' sentence, which no test prints. Contents:\n- the tile march and its marches;\n- (a)-(d) at far 2048, with (c)'s oracle ceiling, efficiency, cull fraction and probe overhead;\n- (e) at the shipped void, Rh 198, S 50, Rc = Rh + S, e = -ln 1.5 / ln(1 - (Rh/Rc)^2): steps, snoise, cost, body tiles, the two depth errors;\n- the analytic body (condition, one probe, one step, the pin);\n- the WeightBound [w(z1), 1] deviation and why it encloses;\n- the contracts as asserted, (c) in the ruling's words.\n'The test skips' appears only if this run skips. No r2 or r3 number survives.", - "Site-ground's dense-reference browser check has the same blind spot (its converged mean luminance is compared after the walls' bodies). It is follow-up cultmath-tapes:follow_up:site-ground-dense-check-blind-past-body, owned by the next site-ground spec. Not this cut.", - "Mutation evidence, cheap by design. src is untouched, so Stryker has nothing in scope and is not run; the negative check proves the premise. Run ONE tools/mutation-table.sh job on Yggdrasil against the final head, test filter FullyQualifiedName~NoiseBoundTests, with these rows:\n- MarchLod `transmittance *= Integrate(field, tile, slope, z, next, lod: true, counts);` -> `transmittance *= 1.0f;` must fail IntervalSkipHalvesEvaluations;\n- LodStep's return wrapped in `2.0f * (...)`: same test;\n- BodyDepth without its sqrt factor: AnalyticBodyMatchesFineMarch;\n- WeightBound `).x, 1.0f)` -> `).y, 1.0f)`: WeightBoundEnclosesOneSignedNoise;\n- MarchTile `if (bound.y <= 0.0f)` -> `if (bound.y <= 0.0f && !field.Name.Contains(\"wells\"))`: IntervalSkipHalvesEvaluations, under the floor options; a survivor under oracle-target-only, by that option's design;\n- Compose `CarveRadius` -> `HollowRadius` in the lo test: AnalyticBodyMatchesFineMarch (carried).\nNo per-mutant hand loops, no Starfire jobs.", - "Budget: under 200k Hands tokens. Read NoiseBoundTests.cs :480-1469 and design.md :344-515 once; no other file. Verification is one full CultMath.Tests run on Yggdrasil after the code commits (paste counts and every IV-REPORT line), the mutation-table job, and one fix round. If the headline agreement fails at r4's own numbers, do not move the factor or the step: report the measured errors as a fork." - ], - "deletes": [ - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 1, - "note": ":1455 the end-of-ray assertion 'the footprint-aware march differs from the reference by'; blind past the body (finding lod-agreement-blind-past-body)." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 4, - "note": ":1198-1201 BodyFactor and its comment; replaced by BodyDepth, the one owner of the body's optical depth." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 3, - "note": ":1375-1377 the test's own tau, its exp and the T-domain comparison; replaced by BodyDepth against the cells' summed depth." - }, - { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "lines": 2, - "note": ":1259-1260 RunStats.Ceiling and 'What no amortization can beat'; the mask-derived ceiling stops being a contract owner." - }, - { - "path": "packages/cultmath/docs/design.md", - "lines": 38, - "note": ":475-512 the saving section with r2's rows (1.41x, 16.45, 2.21x, 1.34x) and '(c) does not, so the test skips'." - }, - { - "path": "packages/cultmath/docs/design.md", - "lines": 2, - "note": ":422-423 'At the shipped scales (|c|_1 near 600, r near 5) it adds 6e-4.'; printed by no test." - } - ], - "keeps_moves": [ - "packages/cultmath/src, both CultMath.Interval.hlsl copies, README.md and every other test file: untouched.", - "Fields, grids (6/K end), seeds, e = 0.2, LodStep, Density, Bound, Compose, MarchTile, Integrate, the masked fixed-step march's exactness asserts, the (a) and (e) step contracts and the Skip mechanism: unchanged.", - "TileBallEnclosesEveryRaySegment, EnvelopeBoundEnclosesDensity, the Lipschitz tests, TightnessReport, IntervalTests, HlslSourceCompatibilityTests: unchanged.", - "AnalyticBodyMatchesFineMarch parts (1) and (3): unchanged; part (2) changes domain and owner only.", - "design.md :344-474 (Intervals up to the saving section, with the r3 frustum-ball paragraph minus the 6e-4 sentence) and every other section: unchanged." - ], - "adds": [ - "NoiseBoundTests.cs: BodyDepth; MarchLod's cutoff and (Transmittance, AtBody) return; ConvergedDepth; Run's slope-first draw, oracle mask, oracle march and the cutoff-0 agreement march; RunStats Oracle, OracleCeiling, Efficiency, ProbeOverhead, CullFraction, MaxOracleDifference, MaxLodDepthError, MaxRefDepthError; Report and ReportVoid fields; the (e) depth contract; (c)'s assertion per the ruling.", - "NoiseBoundTests.cs: VoidField.WeightBounds(z0, z1); Fact WeightBoundEnclosesOneSignedNoise; the header's mutation list updated.", - "design.md: the saving section rewritten from r4's run." - ], - "file_changes": [ - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 14, - "end_line": 20 - }, - "change": "Header mutation list: w(z0) for w(z1) now fails WeightBoundEnclosesOneSignedNoise. Add: the dropped pre-body integration and LodStep x2 fail IntervalSkipHalvesEvaluations's depth agreement; BodyDepth without |dir| fails AnalyticBodyMatchesFineMarch." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 992 - }, - "change": "Beside Weights(z): public (float2 Coarse, float2 Fine) WeightBounds(float z0, float z1) => (WeightBound(CoarseWavelength, z0, z1), WeightBound(FineWavelength, z0, z1))." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1198, - "end_line": 1201 - }, - "change": "BodyFactor -> BodyDepth(Scenario field, Tile tile, float2 slope, float z, bool lod, Counts counts): the float optical depth Density x Extinction x (Grid[^1] - z) x sqrt(m.x^2 + m.y^2 + 1), with no exp." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1205, - "end_line": 1235 - }, - "change": "MarchLod(..., float cutoff, ref long steps, ref long bodySteps) returns (float Transmittance, float AtBody). Both loop guards use cutoff. At z >= body: AtBody = transmittance, then transmittance *= exp(-BodyDepth(...)), steps++, bodySteps++, return. Without a body, AtBody = final T." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1236 - }, - "change": "New ConvergedDepth(Scenario field, Tile tile, float2 slope, int stop, float h, bool lod): sum over cells c < stop of ceil(len / h) midpoint samples, Density(field, tile, slope, z, lod, throwaway) x Extinction x dz x |dir| in double. Every cell, not the mask's." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1237, - "end_line": 1265 - }, - "change": "RunStats:\n- Counts Oracle; OracleEmpty and OracleEmptySkipped; MaxOracleDifference; MaxLodDepthError; MaxRefDepthError.\n- OracleCeiling, Efficiency, ProbeOverhead and CullFraction as the spec's 'first' defines them.\n- Ceiling deleted.\nRatio and LodRatio are unchanged." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1270, - "end_line": 1305 - }, - "change": "Run, per tile:\n- MarchTile.\n- Draw N^2 slopes.\n- Oracle mask over all cells (mid-depth Density > 0 for any slope; throwaway Counts); count oracle-empty cells and those the mask skips.\n- Per ray: dense, masked and oracle marches (oracle into stats.Oracle; MaxOracleDifference).\n- With lod: the costed MarchLod (cutoff 0.02), then a cutoff-0 MarchLod and ConvergedDepth at h 0.5 into throwaway Counts, and tauRef with no early-out; update both depth errors." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1307, - "end_line": 1318 - }, - "change": "Report prints oracle ceiling, efficiency, cull fraction (with counts), probe overhead and max oracle |dT| in place of 'ceiling'. ReportVoid adds the depth errors of LOD and fixed-step against the converged march and their ratio; the end-of-ray |dT| stays." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1332 - }, - "change": "AnalyticBodyMatchesFineMarch part (2): depth = BodyDepth(field, tile, ray, grid[b], lod: true, counts); sum = the double sum over c in [b, last) of -Math.Log(Integrate(field, tile, ray, grid[c], grid[c + 1], lod: true, counts)); assert |depth - sum| <= 1e-4 x sum, naming field, b and both values. The doc comment says so." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1430, - "end_line": 1440 - }, - "change": "(a)-(d) loop: Assert MaxOracleDifference == 0 beside the existing <= 1e-3. :1437 records the ruling's (c) quantity (Efficiency, CullFraction or ProbeOverhead), the lower of warp 0 and D at N = 8, and the CullFraction floor value when the ruling has one." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1453, - "end_line": 1466 - }, - "change": "Headline:\n- MaxDifference == 0 stays.\n- :1455 is replaced by Assert MaxLodDepthError <= 2 x MaxRefDepthError, with both values in the message.\n- Under a floor option: Assert CullFraction >= 0.5 for (c) at both warps (hard).\n- Shortfalls: (c) per the ruling.\n- The contracts line names the quantity and prints the (e) depth errors." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 1402, - "end_line": 1414 - }, - "change": "IntervalSkipHalvesEvaluations doc comment:\n- the (e) agreement is the converged depth, 2x the fixed-step's;\n- (c) per the ruling, citing it;\n- the oracle is defined;\n- 'within 0.02' leaves." - }, - { - "location": { - "path": "packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs", - "line": 304 - }, - "change": "After EnvelopeBoundEnclosesDensity: Fact WeightBoundEnclosesOneSignedNoise, as item 10 of 'first'. Its message names z0, z1, z, the octave, the weight and the bound." - }, - { - "location": { - "path": "packages/cultmath/docs/design.md", - "line": 475, - "end_line": 512 - }, - "change": "The saving section is rewritten from r4's IV-REPORT lines (contents in item 11 of 'first'). The next paragraph, 'Consumers: ...' at :514, is kept." - }, - { - "location": { - "path": "packages/cultmath/docs/design.md", - "line": 422, - "end_line": 423 - }, - "change": "Delete the sentence 'At the shipped scales (|c|_1 near 600, r near 5) it adds 6e-4.' Leave the rest of the paragraph." - } - ], - "authority_map": { - "owner": "The saving test owns the proving-ground numbers and their oracles. The converged march (h = 0.5) is the accuracy oracle before the body. The oracle mask (cells some ray of the tile samples nonzero) is (c)'s ceiling oracle. BodyDepth is the one owner of the body's optical depth, in the march and in its pin. CultMath src is untouched. The operator owns the contracts: the rulings and the answer to wells-ceiling-oracle.", - "inputs": [ - "the r3 fields, grids, seeds, tiles and marches at 3ac7250a", - "the ruling answering cultmath-tapes:question:wells-ceiling-oracle" - ], - "outputs": [ - "IV-REPORT rows: the LOD and fixed-step depth errors against the converged march; (c)'s oracle ceiling, efficiency, cull fraction and probe overhead", - "design.md's saving section, every figure from those rows" - ], - "derived_state": [ - "(c)'s ceiling is no longer derived from the pre-pass's own mask; it is derived from the oracle mask, which the pre-pass cannot move.", - "Dense/Masked is no longer a contract owner; Masked/(Masked+Probes) is printed as probe overhead (an owner only under overhead-plus-floor).", - "The fixed-step march is no longer the LOD march's accuracy oracle; it is a peer measured against the converged march, and its error sets the LOD's allowance (2x).", - "End-of-ray |dT| is display-only.", - "The body's optical depth is derived once, by BodyDepth; the test no longer re-derives it." - ], - "forbidden_writers": [ - "no assertion compares the LOD march with the fixed-step march directly, or after the body", - "AnalyticBodyMatchesFineMarch does not compute the body's depth itself; it calls BodyDepth", - "neither the oracle mask nor ConvergedDepth reads MarchTile's output", - "no change to src, the HLSL, the fields, grids, LodStep, seeds, the 0.2 weight or the 2x factor toward a contract", - "no figure in design.md that this run's IV-REPORT lines do not print" - ], - "shared_paths": [ - "MarchLod is one function for the costed march (cutoff 0.02) and the agreement march (cutoff 0)", - "one Run computes dense, masked, oracle, LOD and converged for every scenario; the headline and the grid print the same fields", - "the site's mirror of the march inherits the same check through follow-up site-ground-dense-check-blind-past-body" - ], - "deletion_line": "The end-of-ray LOD assertion, BodyFactor, the test's own tau, RunStats.Ceiling, the (c) Ratio/Ceiling special case, design.md's r2 rows and the unprinted 6e-4 sentence all leave before their replacements are written. Net: about +170 / -60 in tests and docs, nothing in src. What that buys: (e) can now fail on a wrong pre-body march, the body depth can fail on a wrong |dir|, (c) can fail on a pre-pass that proves nothing, and the WeightBound mutant dies." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests -c Release green or skipped only by saving-2x-scenarios as the ruling implies (MeasureLipschitz/MeasureMonotonicity excluded by trait); paste counts and every IV-REPORT line", - "Yggdrasil: one tools/mutation-table.sh job at the final head with the six rows in 'first' item 13; the table pasted; every row CAUGHT by the named test except the wells row under oracle-target-only", - "No Stryker run and no Starfire job: no src or HLSL change in 3ac7250a..HEAD (negative check)" - ], - "tests": [ - { - "name": "NoiseBoundTests.IntervalSkipHalvesEvaluations", - "pins": "At the shipped void the footprint march's optical depth at the body start is within 2x the fixed-step march's error of a converged march; the oracle march equals the dense march exactly; (c) is asserted per the ruling against a ceiling the pre-pass cannot move; (a) and (e) step contracts as before." - }, - { - "name": "NoiseBoundTests.AnalyticBodyMatchesFineMarch", - "pins": "BodyDepth, the depth MarchLod uses, equals the summed fixed-step depth of the body cells within 1e-4 relative, in the depth domain (no underflow), so a body depth without |dir| fails on every tile; parts (1) and (3) unchanged." - }, - { - "name": "NoiseBoundTests.WeightBoundEnclosesOneSignedNoise", - "pins": "Each octave weight at every sampled depth in [z0, z1] lies in WeightBounds(z0, z1), and w(z) n lies in iv_mul(bound, n) for a one-signed n, so a lower end above w(z1) fails." - }, - { - "name": "NoiseBoundTests (rest) and CultMath.Tests (rest)", - "pins": "unchanged and green." - } - ], - "negative": [ - { - "pattern": "git diff --name-only 3ac7250a..HEAD", - "scope": "exactly NoiseBoundTests.cs and design.md under packages/cultmath." - }, - { - "pattern": "git diff 3ac7250a..HEAD -- packages/cultmath/src packages/cultmath/shaders packages/cultmath/unity", - "scope": "empty." - }, - { - "pattern": "BodyFactor|Ceiling =>|\\.Ceiling\\b|MaxLodDifference <= ", - "scope": "NoiseBoundTests.cs: 0 matches." - }, - { - "pattern": "Math\\.Exp\\(-\\(double\\)tau\\)|var tau = density", - "scope": "NoiseBoundTests.cs: 0 matches (the test does not re-derive the body)." - }, - { - "pattern": "1\\.41x|16\\.45|2\\.21x|1\\.34x|6e-4|does not, so the test skips|where the rays need them", - "scope": "packages/cultmath/docs/design.md: 0 matches." - }, - { - "pattern": "Assert\\.Skip", - "scope": "NoiseBoundTests.cs: at most one, in IntervalSkipHalvesEvaluations, naming saving-2x-scenarios." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 170, - "lines_removed": 60, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "cultmath-tapes:ruling:operator-wells-contract-vs-ceiling", - "cultmath-tapes:ruling:operator-analytic-wall-body", - "cultmath-tapes:ruling:operator-footprint-lod-march", - "cultmath-tapes:ruling:operator-measure-with-empty-space", - "cultmath-tapes:ruling:operator-tile-amortized-march", - "cultmath-tapes:ruling:operator-shipped-void" - ], - "questions": [ - "cultmath-tapes:question:wells-ceiling-oracle" - ] -} diff --git a/docs/cultmath-interval-ground-cut-interval-ops.spec.json b/docs/cultmath-interval-ground-cut-interval-ops.spec.json deleted file mode 100644 index 83a82b31..00000000 --- a/docs/cultmath-interval-ground-cut-interval-ops.spec.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "interval-ops", - "revision": 1, - "title": "Interval ops: cultmath_iv_* over float2(lo, hi) in C# and HLSL with enclosure tests, a committed Lipschitz constant for snoise, and ball bounds for snoise and fbm", - "repo": "GameCult/CultLib", - "branch": "hands/cultmath-interval-ops", - "base": "c49c76ee", - "depends_on": [], - "first": [ - "Map: docs/cultmath-interval-ground-cut.md, sections 'Ownership', 'Interval culling along the ray' and 'The proving-ground contract'. Parked target: docs/cultmath-tape-target.md, sketch step 1 (:59-64) and 'Open before unparking' (:106-115). This cut is step 1 and nothing after it: no tape, no pruning, no min/max choice tracking, no affine arithmetic (map D1).", - "Common rules from the Asura cut map (Asura docs/cut-map.md, 'Common rules for every addition', :453-489): C# in packages/cultmath/src/CultMath as a partial of math (the Phacelle pattern: math.Phacelle.cs beside math.cs), HLSL in a new shaders/CultMath.Interval.hlsl included from CultMath.hlsl the way CultMath.Phacelle.hlsl is (:506), names prefixed cultmath_, both tracked HLSL copies one blob, bodies inside design.md's transformation list (:92-134), THIRD-PARTY-NOTICES untouched (nothing is ported; Fidget's ideas are used, not its code).", - "Representation: an interval is float2(lo, hi), lo <= hi, both finite. The empty interval does not exist; a caller that needs 'provably empty' tests hi < cutoff. Point intervals are iv_point(x) = float2(x, x).", - "Op set, each with the C# twin the mirror test demands: iv_point, iv_add, iv_sub, iv_neg, iv_mul, iv_scale(iv, float), iv_abs, iv_min, iv_max, iv_sqr, iv_sqrt (lo clamped at 0), iv_exp, iv_clamp(iv, float, float), iv_saturate, iv_smoothstep(float e0, float e1, iv) (monotone: endpoints), iv_lerp(iv, iv, float t). No others until a consumer names one.", - "Noise bounds: CULTMATH_SNOISE_LIPSCHITZ (static const float, provenance in the comment: measured max |snoise_grad| over 1e6 seeded points plus 1e4 gradient-ascent refinements, times 1.10; the test that measures it is committed as a slow, explicitly-run test and the constant is pinned by a fast test). iv_snoise_ball(float3 c, float r) = [snoise(c) - L r, snoise(c) + L r] intersected with [-1, 1]. iv_fbm_ball(c, r, octaves, lacunarity, gain) = the octave sum of iv_snoise_ball(c * f_i, r * f_i) scaled by a_i, octaves clamped to [0, 16] like fbm_grad.", - "Write the enclosure property first, as the shared harness: for each op, 10,000 seeded random intervals (widths from 1e-4 to 10, centres in [-20, 20]) and 16 points inside each; assert f(x) in op(I) with no tolerance (the bound is computed in the same float32 arithmetic; where rounding could exclude an endpoint, widen the op by one ulp in the implementation, not the test, and say so in design.md). For the ball bounds: 2,000 balls, r in [1e-3, 2], 64 points inside each.", - "The saving test: a representative coverage field (one snoise octave at F0 = 0.35, cutoff 0.25) and 1,000 seeded rays through a slab of depth 12; march once at the dense step and once with the adaptive interval march from the map (Δ0, ΔMAX = 8 Δ0, ΔDENSE = Δ0/2, grow on skip, halve on maybe); count snoise evaluations; assert the integrated transmittance agrees within 1e-3 and the evaluation count is at least 2x lower. Print both counts and the ratio; the cut report quotes them.", - "The warp enclosure test (the site's march rests on it): for 2,000 seeded (centre c, radius r, warp bound D) triples and random flow vectors with |flow| <= D, every warped point c' = x + flow (x in the ball of radius r) lies in the ball of radius r + D, and snoise(c') lies in iv_snoise_ball(c, r + D). This is a property of the existing bound, not a new function; it is written as a named test so the domain-warp use is pinned and documented in design.md.", - "The saving test's field is domain-warped: coverage = sum over two phases of snoise(p + flow * (phase_k - 0.5) * PERIOD) with a bounded flow, matching the map's field shape, so the interval radius includes D.", - "Tightness: a committed test prints the mean width ratio (interval width / true range over the 64 points) for iv_snoise_ball at r = 0.05, 0.25, 1.0 and for iv_fbm_ball at 4 octaves. No assertion beyond finiteness; the number is for the report and for a later affine cut to beat.", - "Verification on Yggdrasil: dotnet test from packages/cultmath/tests/CultMath.Tests; Stryker --since:c49c76ee from a plain clone. Starfire: FXC cs_5_0 kernel calling every iv_* function and both ball bounds; dxc -T lib_6_3 -HV 2021. Detached with a log, polled in the foreground; never a background shell task. Numbers in comments or docs come from committed tests only.", - "If glsl-lowering has merged to main before this branch does, rebase and regenerate shaders/CultMath.glsl (CULTMATH_WRITE_GLSL=1) so the pin test is green on the merge; if not, the lowering cut regenerates after this one. Either order works because the GLSL is derived." - ], - "deletes": [], - "keeps_moves": [ - "snoise, snoise_grad, fbm_grad, ridged_grad, cellular, phacelle: untouched. The bounds call snoise (value) only; snoise_grad is used by the Lipschitz measurement test, not by any bound (map D2).", - "design.md's invariant 8 section (136-) is unchanged; intervals are not value-and-gradient primitives and do not claim the float4(grad, value) layout.", - "HlslMirrorTests' ban on erosion kernels stands; nothing named interval touches it." - ], - "adds": [ - "packages/cultmath/src/CultMath/math.Interval.cs: public static partial class math with iv_point, iv_add, iv_sub, iv_neg, iv_mul, iv_scale, iv_abs, iv_min, iv_max, iv_sqr, iv_sqrt, iv_exp, iv_clamp, iv_saturate, iv_smoothstep, iv_lerp, iv_snoise_ball, iv_fbm_ball, and the constant SNOISE_LIPSCHITZ; each with a doc comment stating the enclosure it guarantees and the ulp widening where one is needed.", - "packages/cultmath/shaders/CultMath.Interval.hlsl: the HLSL mirrors with the same names prefixed cultmath_, and CULTMATH_SNOISE_LIPSCHITZ as static const; included from CultMath.hlsl after the Phacelle include (:506). Both tracked HLSL copies.", - "tests/CultMath.Tests/IntervalTests.cs: the enclosure harness over every op; iv_mul sign cases (all four quadrant combinations and a zero-straddling factor); iv_sqrt with lo < 0; iv_abs straddling zero gives [0, max(|lo|,|hi|)]; iv_smoothstep monotonicity; iv_min/iv_max against the pointwise min/max; a mutant that shrinks any bound by one ulp dies (hand-mutation list in the file header for the float arithmetic Stryker cannot reach, as in 2a-ii-a).", - "tests/CultMath.Tests/NoiseBoundTests.cs: iv_snoise_ball and iv_fbm_ball enclosure; LipschitzConstantPinsSampledGradients (fast, 1e5 points); MeasureLipschitz (slow, explicit trait, prints the max and the refined max); TightnessReport; the saving test (InvalSkipHalvesEvaluations) with its printed counts.", - "packages/cultmath/docs/design.md: a section 'Intervals' after the invariant 8 section: representation, the op list, the ulp-widening rule, the Lipschitz provenance and margin, what the ball bounds guarantee and what they do not (nothing about tapes), and that the site's ground shader and Aetheria's nebula raymarch are the consumers.", - "packages/cultmath/README.md: one paragraph under the noise entry naming the interval family and its purpose (empty-space culling with a proof)." - ], - "file_changes": [ - { - "location": { "path": "packages/cultmath/shaders/CultMath.hlsl", "line": 506 }, - "change": "add #include \"CultMath.Interval.hlsl\" after the Phacelle include; both tracked copies." - }, - { - "location": { "path": "packages/cultmath/src/CultMath/math.cs", "line": 602 }, - "change": "no change to snoise; a comment pointer from snoise to SNOISE_LIPSCHITZ in math.Interval.cs so the next kernel change knows the constant must be re-measured." - }, - { - "location": { "path": "packages/cultmath/docs/design.md", "line": 136 }, - "change": "new 'Intervals' section after invariant 8." - }, - { - "location": { "path": "packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs", "line": 348 }, - "change": "none expected; confirm the mirror resolves the second #include and that every cultmath_iv_* finds its C# twin (a mirror without a twin fails Assert.Contains MirrorOnly)." - } - ], - "authority_map": { - "owner": "CultMath owns interval arithmetic and the noise bounds in C# and HLSL (and GLSL by derivation). The Lipschitz constant is owned by the committed measurement test; the kernel of snoise owns its value.", - "inputs": [ - "the existing snoise(float3) value function; snoise_grad for the measurement test only", - "seeded random points and intervals in tests" - ], - "outputs": [ - "cultmath_iv_* and the two ball bounds, each enclosing its function over its input region", - "three printed numbers for the report: the Lipschitz max, the tightness ratios, the evaluation saving" - ], - "derived_state": [ - "CULTMATH_SNOISE_LIPSCHITZ is derived from the snoise kernel; a kernel change must re-run MeasureLipschitz and re-pin", - "shaders/CultMath.glsl (if the lowering has landed) is derived and regenerated, never edited" - ], - "forbidden_writers": [ - "no interval op without the enclosure test and a C# twin", - "no bound that reads snoise_grad; no value-only/gradient twin of any iv_* function", - "no tape, bytecode, pruning, choice flag or affine form in this cut; names containing tape, prune or affine do not appear", - "no number in a comment or design.md that a committed test did not print" - ], - "shared_paths": [ - "the same IntervalTests enclosure harness runs every op; a new op is one entry in its table", - "the existing HLSL mirror test covers every HLSL interval function with no new comparison path" - ], - "deletion_line": "Nothing is deleted. The liability is one C# file, one HLSL file, two test files and a doc section; it buys the invariant intervals-enclose for every GPU consumer, and it is step 1 of the parked tapes campaign landed in advance." - }, - "verification": { - "builds": [ - "Yggdrasil: dotnet test packages/cultmath/tests/CultMath.Tests green (MeasureLipschitz excluded by trait); paste counts", - "Yggdrasil: dotnet stryker --since:c49c76ee from a plain clone; 0 survivors in math.Interval.cs except listed equivalents; hand mutations for float3 arithmetic listed and killed", - "Starfire: FXC cs_5_0 kernel over every new function; dxc -T lib_6_3 -HV 2021 on both HLSL copies" - ], - "tests": [ - { - "name": "IntervalTests.EveryOpEnclosesItsPoints", - "pins": "intervals-enclose for every op, no tolerance." - }, - { - "name": "NoiseBoundTests.SnoiseBallEnclosesPoints / FbmBallEnclosesPoints", - "pins": "the ball bounds enclose snoise and fbm over 2,000 balls x 64 points." - }, - { - "name": "NoiseBoundTests.WarpedPointsStayEnclosed", - "pins": "a domain warp bounded by D is enclosed by enlarging the ball radius by D; the site's interval march is sound." - }, - { - "name": "NoiseBoundTests.LipschitzConstantPinsSampledGradients", - "pins": "no sampled |snoise_grad| exceeds the constant; a constant lowered by 1% fails." - }, - { - "name": "NoiseBoundTests.IntervalSkipHalvesEvaluations", - "pins": "the adaptive march needs <= half the evaluations of the dense march for the same transmittance within 1e-3." - }, - { - "name": "HlslSourceCompatibilityTests.EveryMirrorFunctionMatchesCSharpMath (existing)", - "pins": "every cultmath_iv_* and both bounds match C# bit for bit." - } - ], - "negative": [ - { - "pattern": "tape|prune|affine|choice", - "scope": "packages/cultmath/src/CultMath/math.Interval.cs and shaders/CultMath.Interval.hlsl: 0 matches (case-insensitive)." - }, - { - "pattern": "snoise_grad|fbm_grad", - "scope": "math.Interval.cs and CultMath.Interval.hlsl: 0 matches; the bounds use values only." - }, - { - "pattern": "spherical_erosion|AdvancedErosionFilter", - "scope": "packages/cultmath: 0 matches (HlslMirrorTests' standing rule)." - }, - { - "pattern": "git diff --name-only c49c76ee..HEAD", - "scope": "only packages/cultmath/** (and shaders/CultMath.glsl if regenerated); no other package or src tree." - } - ], - "operator": [] - }, - "estimate": { - "lines_added": 900, - "lines_removed": 0, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [], - "questions": [] -} diff --git a/docs/cultmath-interval-ground-cut-site-ground.r3.spec.json b/docs/cultmath-interval-ground-cut-site-ground.r3.spec.json deleted file mode 100644 index 83558f7b..00000000 --- a/docs/cultmath-interval-ground-cut-site-ground.r3.spec.json +++ /dev/null @@ -1,246 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "site-ground", - "revision": 3, - "title": "Site ground r3: A cloud volume carved by one negative pseudo-Gaussian sphere, a sun at the hollow's bottom lights the walls and orbits, the camera follows low inside; pre-pass, camera-aware TAA", - "repo": "GameCult/gamecult-site", - "branch": "main", - "base": "535d170", - "depends_on": [ - "site-masthead:cut_spec:wash-home-only.r1", - "cultmath-tapes:cut_spec:glsl-lowering.r2", - "cultmath-tapes:cut_spec:interval-ops.r3" - ], - "first": [ - "Map: F:/Projects/CultLib/docs/cultmath-interval-ground-cut.md, 'Pass 3' (the void scene, the composed bound, the pre-pass, the budget), then 'The shader design' for what pass 3 does not restate (sampled wash, palette input, pausing, contrast). Rulings in force: cultmath-tapes:ruling:operator-ground-void-brush (the scene), operator-tile-amortized-march (the march), site-masthead:ruling:operator-chromeless-column; wash-home-only's authority map. Re-pin base to main after wash-home-only lands. Stardust and DoF stay the next cut; leave the named composite slot. r2's token, readback, controller, vendoring, parity and fallback items stand unless this revision names them.", - "The original, read once (Aetheria at e6181c11, 2021-03-13, Assets/Scenes/Main Menu.unity; Prefabs/RPG/Planets/Sun.prefab; Materials/Brushes/Gravity Well.mat, Main Menu Sun Fog Tint.mat, Main Menu Ambient Fog Tint.mat, Sector Boundary Fog.mat; Materials/Fog Marching Main Menu.mat; Shaders/Raymarching/VolumeRender.shader at that commit; Shaders/Brushes/PowerBrush.shader). What survives, in the original's units: the brush is PowerBrush (1 - x^2)^16 with depth 40 over radius 256 (half depth at r = 52, pseudo-Gaussian sigma about 45), the sun's own gravity-well child; a wide boundary bowl (depth 75, power 0.25, radius 1500) is flat across the scene and acts as a constant 75; floor offset -16.46, floor blend 39.6, so the fog top is at y = -91 outside the void and dips to -131 at the sun; the sun sphere (radius 12.5) sits at y = -130, the bottom of the void.", - "What survives (continued): the sun is a child of 'Center', which rotates 5 degrees per second about y (72 s period), at orbit radius 175; the camera is a Cinemachine vcam following the sun (framing transposer, distance 150, damping 10, handheld noise amplitude 1 at frequency 0.25) and looking at 'Look Target' (0, -130, 0), the orbit centre at the sun's depth; the saved camera sits at y = -27, 64 above the fog top. The lighting was authored, not marched: the sun's 'Fog Tint' brush (1 - x^2)^3, depth 2, radius 128, colour (1, 0.4, 0.1) orange, painted into the tint map, times a scene-wide ambient tint (0.18, 0.59, 1) blue, depth 0.01. Stardust: 256^2 particles, spacing 2, floor -60, ceiling 0, height exponent 800 / (ceiling + wellDepth) so particles climb higher where the well is deeper (the void fills with stardust). Noise: strength 150, frequency 0.01, safety 50. Not surviving: the 2021 d() details, the tint map's runtime contents, the video.", - "The field (ruling operator-void-true-cavity: a spherical hollow inside a cloud volume that surrounds it on every side, not the 2021 bowl). Units are the original's. Outer volume: an unbounded uniform fill, chosen over a shell because every ray then ends in a wall and the march terminates by opacity, never by a far plane; Z1 = |camera - c_v| + Rc + 6/K (614 at the shipped point) bounds the pre-pass range and is past opacity for every ray, so the analytic body step below always terminates. The carve is the pseudo-Gaussian brush g(d) = (1 - (d / Rc)^2)^e, d = |p - c_v|, density = K max(0, 1 - CARVE g(d')), authored by two knobs: the hollow radius Rh (density exactly 0 inside; Rh = Rc sqrt(1 - CARVE^(-1/e))) and the ramp width S (density full at Rh + S; set by the exponent: e = 4 gives S = 1.3 Rh, e = 0.25 gives S = 0.12 Rh).", - "Shipped (Q9 in the map, option (a) pending the operator): Rh = 198, S = 50, so Rc = Rh + S = 248 and e = -ln CARVE / ln(1 - (Rh / Rc)^2) = 0.40; CARVE = 1.5, K = 1/30: a wall is opaque within about 150 units of full density. The ramp and the noise fade band are both S wide; nothing void-shaped is authored twice (interval-ops r3, finding shipped-void-two-scenes). Noise displaces the wall only: fade(d) = smoothstep(Rh - S, Rh, d), d' = d + A fade(d) n(warp(p)), A = 20, F0 = 0.01.", - "Scene motion. The sun orbits the origin at radius 175 in xz with period 72 s (5 degrees per second, the original's Center pivot). The cavity centre is c_v = sun + (0, Rh - 12.5, 0): the sun sphere (radius 12.5) rests on the hollow's bottom and the hollow moves with it. The camera follows the sun 120 behind it along the orbit's tangent and 45 above it, so it sits 186 from c_v, 12 inside the hollow (the handheld drift is 2 units, two low-frequency snoise on time), low in the cavity, looking at the sun's position plus (0, 60, 0) so the lit lower wall and the dark upper wall share the frame. The 2021 follow distance 150 and height 25 do not fit a hollow a camera can stand in; 120 and 45 are the re-derivation, and the report says so. worldAt(t) in ground.js is the one owner of sun, cavity and camera, uploaded as uniforms; the shaders never integrate motion.", - "The flow field, authored around the void: flow(xz) = SWIRL * tangent(xz - sun.xz) * (1 - (r / Rw)^2)^2 + GLOBAL * (snoise(xz Ff + o1), snoise(xz Ff + o2)) (the swirl is largest mid-slope and zero at the rim and the centre; the global term is r2's). The flow texture is a world-space window of side 4 Rw centred on the sun, quarter of the canvas resolution, re-rendered every frame; warp, hue, motion vectors and (next cut) the stardust read it, so D4 holds with a moving scene. D = FLOW_MAX * PERIOD / 2 as before, with FLOW_MAX the authored maximum of the swirl plus the global amplitude.", - "The march (tile pre-pass, interval-ops r2's design). Pre-pass at W/8 x H/8: per tile, the loop over the slab's cell ranges (uniform cells, StepDense = min(10, S / 4) = 10, 62 cells to Z1 = 614 along +view depth; the mask has 96 bits): the envelope probe first (exact box: y and xz ranges by cultmath_iv_mul of the depth and slope intervals, d's interval is the box's least and greatest distance to c_v, exact; g, fade and the carve are monotone in it), then the noise ball (cultmath_iv_frustum_ball with D, cultmath_iv_snoise_ball) only when fade.hi > 0 and L r F0 leaves room to prove anything; writes the 96-bit mask of cells not proven empty to an RGBA32UI texel's first three words, and in the fourth word the body-start cell: the first cell whose own bound is a positive point and whose slice to Z1 is one too (the envelope with the free noise interval proves density exactly K for the rest of the range), 0xFFFFFFFF when none (interval-ops r3, ruling operator-analytic-wall-body).", - "(March, continued.) Main pass: texelFetch the mask, then march the unmasked range with the footprint step Delta(z) and the octave weights (next item), the per-frame sample count capped by the budget S_budget and the start jittered so TAA completes what one frame does not; masked cells are skipped exactly; at the body-start cell take one analytic Beer-Lambert step, T *= exp(-K (Z1 - z) |dir|) with K the field's pointwise envelope value there (no probe in the main pass), and stop; integrate transmittance and the depth-weighted mean distance, apply the light. Every tile's interior cells retire in a few envelope probes and its wall cells are marked; there are no sky tiles. Behind a fully transmissive pixel the resolve shows --gamecult-nebula-base; by construction only an unfinished ray (budget exhausted before the wall, measured, must be under 1%) reaches it.", - "Footprint LOD (the operator's challenge, map 'Footprint LOD'): theta_px = 2 tan(fov/2) / H; the footprint at distance z is z theta_px. Step: Delta(z) = max(k z theta_px, min(S / 4, lambda_fine(z) / 2)), k = 4: never finer than four footprints, otherwise the finer of the two content limits (four samples across the ramp, two per wavelength of the finest live octave). Octaves: octave i of wavelength lambda_i carries weight w_i(z) = 1 - smoothstep(lambda_i / (2m), lambda_i / m, z theta_px), m = 4: one smooth blend per octave, no popping; TAA hides per-frame sparsity. The weights are part of the field, so the bound encloses the truncated field exactly: the noise interval over a slice is the sum over octaves of iv_mul([w_i(z1), w_i(z0)], iv_snoise_ball(c F_i, r F_i)), w_i monotone in z. At the shipped parameters (wavelengths 100 and 25, z <= 2 Rc) every weight is 1 in the frustum and the content limits set the step; the footprint bites when S < 4 k z theta_px.", - "Where the scene sits and what to turn (Imagination's model, scratchpad cavity_model.py; the test and the browser confirm): interval-ops r2 measured the shipped point at 16.45 LOD steps and 26.6 snoise per pixel against 36.3 fixed steps (2.21x); r3's analytic body is predicted to bring the steps to about 12.5 (2.6-3.3x), snoise unchanged; the wall's step is set by S / 4 and the detail half-wavelength, not by distance; the browser confirms or refutes. Cheaper without losing the mood, in order: (1) a lower per-frame S_budget, which LOD and the mask make nearly lossless (S_budget = 4 converges in about three frames at the walls); (2) a thinner ramp S (S = 10 is 3.2x on cost but reads as a surface; 25-50 keeps the fog); (3) a longer detail wavelength or no detail octave near the far wall (the 12.5-unit half-wavelength is the floor for S >= 50); (4) a larger hollow (Rh = 1000: 2.5x) costs nothing per pixel and changes the composition. Camera offset barely matters at these scales.", - "Lighting, the cheapest version that keeps it moody (the original's own mechanism, made 3D): at each sample, light = SUN_COLOUR * (1 - (d / Rl)^2)^3 for d = |p - sun| < Rl, Rl = Rh = 198 (the original's 128 scaled with the hollow), plus AMBIENT * ambientTint; colour = density * (light + ambient) * hue(flow). No light march: zero extra snoise, one length and one pow per sample. The lower wall within Rl of the sun glows and the upper wall stays dark because the pulse is zero beyond Rl, which is the moody split; the sun inside the hollow is occluded by nothing, so the sun itself is a small additive disc drawn in the resolve at its projected position, occluded by the accumulated transmittance along its ray. Not in this cut, measured before it is ever added: one envelope-only transmittance sample toward the sun per primary sample (self-shadowing by the bowl's geometry), about +25% march cost; it is desktop-only if ever.", - "TAA with a moving camera. ground.js uploads this frame's and the previous frame's view-projection. For each pixel the resolve reconstructs the world point at the march's depth-weighted mean distance (written by the main pass into a second history channel, R16F), moves it back by the field motion (p + flow(p) * dt: the pattern moves at -flow), projects it with the previous VP and fetches history at that uv. The same 3x3 min/max clamp, alpha = max(1/frames, 1/32), out-of-bounds alpha 1; history reset on resize, first frame and budget step. Transmittance, colour and the depth channel are all reprojected by the one motion vector. ?ground=debug-mv shows |mv| with the camera moving and the flow frozen, and with the flow moving and the camera frozen, so both terms are seen separately.", - "Stardust distribution and the sun disc are the next cut (site-stardust), authored to the void: particles spawned in the bowl's volume with the original's height rule (more headroom where the well is deeper), lit by the same pulse, moving with the swirl. This cut leaves the composite slot and the depth history they need.", - "Fit with the tokens. Inputs: --gamecult-nebula-0 (orange 255 138 42) is SUN_COLOUR; --gamecult-nebula-2 (sky 89 183 255) is the ambient tint; --gamecult-nebula-1 (violet 109 96 255) is the cloud hue's second pole; --gamecult-nebula-base the sky. Outputs from the 8x8 readback as r2, with one change: --gamecult-light-0-at is written from the sun's projected screen position (quantised to 1%, at most 2 Hz), so the CSS wash's main light follows the sun while the shader runs; --gamecult-light-0 and -a come from the texel there; lights 1 and 2 keep their seed positions and sample their colours. When the canvas is absent the seeds paint a still of the same composition (the seed light-0-at is the sun's mean screen position).", - "Prove in the browser pane, in addition to r2's list: with ?ground=debug the pre-pass's mean probes per tile and the fraction of cells masked, and the mean snoise per pixel and the fraction of samples placed in the wall ramp against a dense-reference frame (?ground=dense: no pre-pass, S samples over the whole slab; the two converged frames' mean luminance agree within 1/255; the masked frame's per-frame variance at the walls is lower, printed); the camera reprojection test above; the orbit (after 36 s the sun's screen position has moved half an orbit and the TAA shows no smear at the walls); the contrast clamp with the lit cavity (max luminance <= 0.035 still holds; the sun disc is exempt only inside its own radius, which the clamp test masks and reports)." - ], - "deletes": [ - { - "path": "site/quartz/styles/custom.scss", - "lines": 6, - "note": "ritual body block 119-124: its own background goes; its seeds live under :root:has(body[data-slug]) (r2)." - }, - { - "path": "site/quartz/styles/custom.scss", - "lines": 9, - "note": "body 10-27: the literal colours and stops become token references (r2)." - } - ], - "keeps_moves": [ - "r2's tokens, sampled wash, controller, vendoring (now two files: the site vendors CultMath.glsl only, MIT; the parity run concatenates CultMath.Phacelle.glsl for the phacelle family), parity flags, fallbacks and the contrast clamp: unchanged except where this revision names them.", - "--gamecult-wash and the index override from wash-home-only: untouched.", - ".page::before, the tour/Pitch VN ground, the Thing deck's .hero-bg, the masthead, the engine: untouched.", - "The CSS wash stays the ground when the canvas is absent, not yet drawn, or removed by the controller." - ], - "adds": [ - "site/quartz/components/GameCultGround.tsx: as r2.", - "site/quartz/static/ground/ground.js (~500 lines): r2's passes plus worldAt(t) (sun, void, camera), the two view-projections, the pre-pass, the mask texture, the depth history, the sun-disc composite and the light-0-at writer.", - "site/quartz/static/ground/flow.frag.glsl (world-space window, swirl plus global), prepass.frag.glsl (the tile loop, mask and body-start out), cloud.frag.glsl (masked sampling, light, depth out), taa.frag.glsl (camera plus flow reprojection), downsample.frag.glsl.", - "site/quartz/static/ground/CultMath.glsl and glsl-parity.json, vendored from CultLib at interval-ops r3's head or later (cultmath_iv_frustum_ball with its float32 widening present).", - "scripts/ground/check-cultmath-glsl.ps1: the vendoring drift check.", - "custom.scss and docs/brand-design-language.md: as r2, with the void composition named in the brand doc's ground paragraph." - ], - "file_changes": [ - { - "location": { - "path": "site/quartz/styles/custom.scss", - "line": 4, - "end_line": 8 - }, - "change": ":root block: the fifteen ground seeds and --gamecult-ground-mean; light-0-at seeded at the sun's mean screen position." - }, - { - "location": { - "path": "site/quartz/styles/custom.scss", - "line": 10, - "end_line": 31 - }, - "change": "body: four nebula input tokens; radials and the linear gradient reference the ground tokens (r2)." - }, - { - "location": { - "path": "site/quartz/styles/custom.scss", - "line": 103, - "end_line": 124 - }, - "change": "ritual block: background declaration deleted; :root:has(body[data-slug]) carries its seeds and nebula inputs (r2)." - }, - { - "location": { - "path": "site/quartz.layout.ts", - "line": 19 - }, - "change": "header: [GameCultThemeLock(), GameCultGround(), GameCultMasthead()]." - }, - { - "location": { - "path": "docs/brand-design-language.md", - "line": 69, - "end_line": 84 - }, - "change": "wash section rewritten: the void scene, the sampled wash, the seeds, the nebula inputs and what each drives." - } - ], - "authority_map": { - "owner": "The shader owns the ground. ground.js owns worldAt(t) (sun, void, camera), the flow texture, the pre-pass mask, the march, the TAA, the readback and the sampled tokens; custom.scss owns the four nebula inputs, --gamecult-wash and the seeds; CultLib owns every noise and interval function; the composed bound in prepass.frag.glsl is built from cultmath_iv_* only.", - "inputs": [ - "the four nebula tokens and --gamecult-wash (computed on body)", - "prefers-reduced-motion, visibilityState, canvas size, devicePixelRatio, elapsed time", - "measured GPU frame time (timer query, fence, or rAF cadence)", - "the shader's own 8x8 readback and the sun's projected position", - "the vendored CultMath.glsl at its pinned CultLib commit" - ], - "outputs": [ - "one opaque moving canvas under the page, luminance <= 0.035 outside the sun disc", - "the fifteen ground tokens and --gamecult-ground-mean on :root inline, at most 2 Hz; light-0-at follows the sun", - "debug, dense-reference and parity readbacks (console, flag only)" - ], - "derived_state": [ - "sun, void and camera positions are derived from time by worldAt(t); nothing integrates motion frame to frame", - "the tile mask is derived each frame from that frame's camera and the field; it is never carried across frames", - "the flow texture is the one owner of motion: warp, hue, motion vectors and the stardust read it", - "the TAA history (colour, transmittance, depth) is a cache reprojected by camera and flow; reset on resize, first frame and budget step", - "the ground tokens are derived from the readback while the shader runs; the seeds are the fallback; the shader never reads them", - "S and dpr are derived from measurement within the session; the sessionStorage token set is a cache" - ], - "forbidden_writers": [ - "no colour, alpha, position or radius literal in ground.js or any GLSL file; the scene's dimensions (H0, Dw, Rw, F, S, Rl, orbit radius, period, camera offset) are named constants in one place in ground.js, uploaded as uniforms", - "no sample placed in a masked cell; no probe in the main pass; no early-out of the pre-pass on transmittance", - "no light march in this cut; the light is the analytic pulse", - "no read of the ground output tokens by the shader or ground.js except the seed read before the first readback", - "no userAgent, platform or maxTouchPoints; no class or attribute set on body or html; no second wash token; no second flow evaluation; no noise or interval function defined in the site's GLSL", - "no synchronous readPixels to client memory; one requestAnimationFrame scheduler; localStorage never" - ], - "shared_paths": [ - "every page paints one canvas and one token set; the ritual essays differ only in seeds and inputs", - "slow device, hidden tab, reduced motion, missing WebGL2 and missing half-float all pass through the one controller", - "the 8x8 readback and the sun projection are the only paths from the shader to CSS", - "the pre-pass and the main pass read the same uniforms from the same worldAt(t); the dense-reference mode differs only by skipping the mask" - ], - "deletion_line": "As r2: the ritual block's own background and the body literals go in the same commit the tokens are declared. Nothing else in the engine or content changes. Against pass 2's design this revision removes the static camera and the everywhere-clouds field; it adds one pre-pass, one mask texture, one depth history channel and the scene function." - }, - "verification": { - "builds": [ - "Deploy Quartz green on the landing commit: gh run list -R GameCult/gamecult-site -w \"Deploy Quartz\" -L 1", - "scripts/ground/check-cultmath-glsl.ps1 exits 0 against a CultLib checkout at the pinned commit", - "the built stylesheet contains rgb(var(--gamecult-light-0) / calc(var(--gamecult-light-0-a) * var(--gamecult-wash))) verbatim and the ritual :root:has rule" - ], - "tests": [ - { - "name": "browser pane, /?ground=debug: max relative luminance over the canvas outside the sun disc after 32 frames <= 0.035", - "pins": "text contrast with the lit cavity." - }, - { - "name": "browser pane, /?ground=debug vs /?ground=dense: converged mean luminance within 1/255; steps and snoise per pixel printed for both, debug at most half of dense's steps; mask fraction printed", - "pins": "the mask culls only provably empty cells; the shipped march takes at most half the fixed-step steps; the saving on the shipped scene is a number." - }, - { - "name": "browser pane, /?ground=debug-mv: |mv| non-zero with the camera moving and flow frozen, and with flow moving and camera frozen; zero under reduced motion", - "pins": "both reprojection terms are live and separable." - }, - { - "name": "browser pane, / for 40 s: the sun's screen position moves about half an orbit; no history smear at the walls (3x3 clamp); light-0-at on :root follows within 2 s", - "pins": "the moving scene converges and the CSS wash follows the sun." - }, - { - "name": "browser pane, /?ground=parity: every fixture family within its tolerance class on WebGL2, cultmath_iv_frustum_ball exact; numbers and GPU string in the report", - "pins": "GLSL = C# on a device, including the tile ball." - }, - { - "name": "browser pane, /?ground=parity-wash and a ritual essay: canvas vs CSS seed wash within 2/255 at 16 points with density 0 and the sun disc off", - "pins": "the seeds and the shader's base agree." - }, - { - "name": "reduced motion, hidden tab, WebGL2 disabled, sessionStorage cleared: as r2", - "pins": "every fallback goes through the controller." - }, - { - "name": "git diff base..head --stat: custom.scss, quartz.layout.ts, docs/brand-design-language.md, the new component, static/ground/*, scripts/ground/* only", - "pins": "no engine, content or masthead change." - } - ], - "negative": [ - { - "pattern": "#[0-9a-fA-F]{6}\\b|rgba?\\(|\\b(255|138|109|183)\\b", - "scope": "site/quartz/static/ground/*.js and *.glsl: 0 matches." - }, - { - "pattern": "gamecult-ground-|gamecult-light-", - "scope": "site/quartz/static/ground/*.glsl: 0 matches; in ground.js only inside the token writer and the seed read." - }, - { - "pattern": "userAgent|navigator\\.platform|maxTouchPoints|localStorage|setInterval|classList|setAttribute\\(", - "scope": "site/quartz/static/ground/ground.js: 0 matches." - }, - { - "pattern": "cultmath_iv_", - "scope": "cloud.frag.glsl, taa.frag.glsl, flow.frag.glsl: 0 matches; the bound lives only in prepass.frag.glsl." - }, - { - "pattern": "float cultmath_|vec4 cultmath_|float snoise|hash\\(", - "scope": "every site .frag.glsl: 0 matches; cultmath_* is defined only in the vendored CultMath.glsl." - }, - { - "pattern": "Mozilla|MPL|cultmath_phacelle", - "scope": "site/quartz/static/ground/CultMath.glsl: 0 matches; the site vendors the MIT file." - }, - { - "pattern": "radial-gradient\\([^)]*rgba?\\([0-9]", - "scope": "site/quartz/styles/custom.scss, body rule and ritual block: 0 matches." - }, - { - "pattern": "gamecult-titlebar|gamecult-nav-link|sidebar|composite|GameCult-Quartz", - "scope": "git diff base..head changed lines: 0 matches." - } - ], - "operator": [ - "open / on the desktop and on the phone; say whether the hollow, the sun's orbit and the camera's height read as the old main menu's mood (uniforms: A, SWIRL, Rl, CARVE, the camera offset)", - "on the phone with ?ground=debug, read the logged GPU ms per pass and the controller's final S/dpr; say whether it got warm after five minutes", - "say whether the analytic light is moody enough or the self-shadowing sample (desktop only) should be tried", - "navigate / -> /Blog -> back; say whether the ground is continuous (Q5)" - ] - }, - "estimate": { - "lines_added": 1250, - "lines_removed": 15, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [ - "GLSL ES 3.00 shader files in static/ground", - "vendored glsl-parity.json", - "one sessionStorage key holding the last sampled token set", - "an RGBA32UI tile-mask texture and an R16F depth history (GPU-side only)" - ], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "cultmath-tapes:ruling:operator-ground-void-brush", - "cultmath-tapes:ruling:operator-void-true-cavity", - "cultmath-tapes:ruling:operator-tile-amortized-march", - "cultmath-tapes:ruling:operator-analytic-wall-body", - "cultmath-tapes:ruling:operator-split-phacelle", - "site-masthead:ruling:operator-chromeless-column" - ], - "questions": [ - "Q4 in the map: palette input tokens (a, recommended)", - "Q5 in the map: carry the last sampled wash across page loads (a, recommended)", - "Q9 in the map: the one shipped void (a, recommended: Rh 198, S 50, Rc 248, e 0.40); ruled in interval-ops r3's fork, this spec follows it" - ] -} diff --git a/docs/cultmath-interval-ground-cut-site-ground.spec.json b/docs/cultmath-interval-ground-cut-site-ground.spec.json deleted file mode 100644 index a19f2b3e..00000000 --- a/docs/cultmath-interval-ground-cut-site-ground.spec.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "site-ground", - "revision": 2, - "title": "Site ground: a per-pixel WebGL2 nebula under every page, flow-warped, interval-culled, TAA-reprojected, budget-controlled by measurement; the CSS wash is sampled from the result, seeds fall back", - "repo": "GameCult/gamecult-site", - "branch": "main", - "base": "535d170", - "depends_on": [ - "site-masthead:cut_spec:wash-home-only.r1", - "cultmath-tapes:cut_spec:glsl-lowering.r1", - "cultmath-tapes:cut_spec:interval-ops.r1" - ], - "first": [ - "Map: F:/Projects/CultLib/docs/cultmath-interval-ground-cut.md, 'The shader design' (field, culling with the warp, TAA motion-aware, sampled wash, palette input), 'Budget', D4-D8, Q4 and Q5. Rulings in force: site-masthead:ruling:operator-chromeless-column; wash-home-only's authority map (no second wash token, no class toggled by script, no page rule setting a radial alpha). Re-pin base to main after wash-home-only lands; line numbers below are from 535d170; re-read by selector. Stardust and DoF are the next cut: leave the resolve pass with a named, empty composite slot for them (a uniform-gated branch is not needed; a comment and a function stub are).", - "Aetheria reference, read once, copy nothing: Volumetric.cginc:165-221 (two-phase flow-map warp, tri2 cross-fade), :130-135 (globalFlow); Raymarching/CloudShader.shader:83-104 (integration) and :261-314 (what not to do: gamma 0.5 clip, fixed 0.05 blend, packed depth, the density2 bug at :311).", - "Engine facts to confirm before writing: how GameCult-Quartz bundles a component's afterDOMLoaded and whether a dynamic import() of /static/ground/ground.js is allowed, else emit a module script tag; site/quartz/static/** served at /static/**; enableSPA false (quartz.config.ts:15). Local build: scripts/quartz/quartz.ps1 dev.", - "Tokens. Inputs (Q4 a), on body in custom.scss beside --gamecult-wash: --gamecult-nebula-0/1/2 (\"255 138 42\", \"109 96 255\", \"89 183 255\") and --gamecult-nebula-base (#07111a). Outputs with seeds, on :root: --gamecult-ground-0/1/2 (#03070d #07111a #09141f), and for N in 0..2 --gamecult-light-N (rgb triple), -a (0.18/0.16/0.14), -at (\"78% 14%\"/\"18% 10%\"/\"52% 0%\"), -r (18%/24%/28%), plus --gamecult-ground-mean (#07111a). The body background becomes radial-gradient(circle at var(--gamecult-light-0-at), rgb(var(--gamecult-light-0) / calc(var(--gamecult-light-0-a) * var(--gamecult-wash))), transparent var(--gamecult-light-0-r)) x3 over linear-gradient(180deg, var(--gamecult-ground-0) 0%, var(--gamecult-ground-1) 44%, var(--gamecult-ground-2) 100%).", - "Ritual essays: their seeds go under :root:has(body[data-slug=\"Blog/...\"]) for the three slugs (yellow 255 178 30 .15 at 78% 8% 24rem; cobalt 49 88 255 .22 at 18% 4% 30rem; violet 91 54 184 .19 at 44% 20% 34rem; stops #030414 0%, #070b24 42%, #040514 100%; nebula inputs likewise overridden to yellow/cobalt/violet and base #050614). The ritual block's own background declaration is deleted; it inherits body's.", - "ground.js owns: WebGL2 context on #gamecult-ground (alpha:false, antialias:false, powerPreference 'low-power'); capability check (WebGL2, EXT_color_buffer_half_float or float); input token read via getComputedStyle(document.body) -> uniforms; the flow texture pass (quarter res, RG16F, two snoise per texel, once per frame); the march pass; the TAA resolve with reprojection; the 8x8 downsample and the async PBO readback; the token writer on document.documentElement.style; the scheduler (30 fps cadence, visibilityState pause, reduced-motion freeze and stop at 32 frames); the budget controller; the debug flag (?ground=debug) and parity flags.", - "Sampled wash: after the resolve, draw the final frame into an 8x8 RGBA8 target; gl.readPixels into a PIXEL_PACK_BUFFER; gl.fenceSync; on later frames poll getSyncParameter(SYNC_STATUS) and only when SIGNALED call getBufferSubData. Never readPixels to client memory directly (that stalls). At most 2 Hz. Compute the token values as the map states (row means for the stops; light colour and excess at the seed light's centre texel; the mean for --gamecult-ground-mean) and write them with setProperty on :root only when a value moved by more than 1/255. Q5 (a): keep the last written set in sessionStorage under one key and apply it on load before the first frame; it is a cache, and a missing or malformed entry means the seeds.", - "Budget controller, one function, one state machine: GPU time per frame by EXT_disjoint_timer_query_webgl2 when present, else a fenceSync after the resolve polled to completion, else rAF cadence. Over a 60-frame window: if the median exceeds the budget (4.0 ms), step down: S 16 -> 8 -> 4, then dpr -> 1 (Q2), then remove the canvas (the seeds paint). Never step up within a session. A median rising 50% over 5 minutes also steps down. No storage of the verdict, no userAgent, no maxTouchPoints.", - "cloud.frag.glsl: #version 300 es; precision highp float; precision highp int; the vendored CultMath.glsl is concatenated by ground.js before this file's body. The field, warp, interval march (ball radius F0 * (Δ/2 + D) with D = FLOW_MAX * PERIOD / 2) and integration exactly as the map's pseudocode; hue from the flow texture's channels mixed over the three nebula inputs; uniforms: resolution, time, dt, frame, jitter, S, intensity, nebula colours, base, Z0/Z1, F0, CUTOFF, K, PERIOD, FLOW_MAX. flow.frag.glsl: the two low-frequency snoise. taa.frag.glsl: motion vector from the flow texture (mv = project(-flow * dt)), history fetched at uv - mv, 3x3 min/max clamp, alpha = max(1/frames, 1/32), out-of-bounds alpha 1; writes new history and the screen (luminance clamp 0.035) via drawBuffers or two draws.", - "Vendoring (D3): site/quartz/static/ground/CultMath.glsl byte-equal to CultLib shaders/CultMath.glsl at the commit named in its first line. scripts/ground/check-cultmath-glsl.ps1 diffs it against git show :packages/cultmath/shaders/CultMath.glsl from a CultLib checkout and exits non-zero on drift.", - "Parity on the device: with ?ground=parity, ground.js evaluates the vendored fixture (CultLib tests/CultMath.Tests/fixtures/glsl-parity.json) one pixel per point, reads back float bit patterns, and reports per function the max ulp distance and the count outside its tolerance class. With ?ground=parity-wash, density and stardust are forced to 0 and the flow frozen; the canvas must equal the CSS seed wash within 2/255 at 16 points on / and on a ritual essay (this pins that the seed values and the shader's base agree at zero density, which is what the fallback promises).", - "Prove in the browser pane: max relative luminance after 32 frames on / at intensity 1 (<= 0.035); the parity-wash probe; the debug readback (mean evals per pixel, unfinished-ray fraction < 1%); the token writer (after 2 s on /, :root's inline style carries all fifteen tokens and --gamecult-ground-mean, each within the expected range, and getComputedStyle(body).backgroundImage resolves to the sampled values); the motion test (with ?ground=debug-mv the resolve writes |mv| into red: non-zero where flow is non-zero, zero under reduced motion); GPU ms per pass with the timer query at the pane's desktop size and at the mobile preset's pixel count. Phone GPU time is operator verification." - ], - "deletes": [ - { - "path": "site/quartz/styles/custom.scss", - "lines": 6, - "note": "ritual body block 119-124: its own background (three radials and the linear gradient) goes; its seeds live under :root:has(body[data-slug]) and it inherits body's ground." - }, - { - "path": "site/quartz/styles/custom.scss", - "lines": 9, - "note": "body 10-27: the six literal colours and three literal stops leave as literals (rewritten as token references in the same lines; counted 9 removed, 9 added)." - } - ], - "keeps_moves": [ - "--gamecult-wash and the index override from wash-home-only: untouched; the shader reads it as intensity and the CSS wash still multiplies by it.", - ".page::before (the grid overlay), the tour/Pitch VN ground, the Thing deck's .hero-bg, the masthead, the engine: untouched.", - "The CSS wash stays the ground when the canvas is absent, not yet drawn, or removed by the controller; it renders the sampled tokens when there are any and the seeds otherwise.", - "docs/brand-design-language.md 'The ground is a wash, not a flat fill' (69-84): rewritten: the ground is the shader; the CSS wash is sampled from it; the seeds are today's literal wash; the four nebula inputs are where the palette is tuned." - ], - "adds": [ - "site/quartz/components/GameCultGround.tsx: renders , mounts /static/ground/ground.js after DOM load; in sharedPageComponents.header after GameCultThemeLock (quartz.layout.ts:19). Its beforeDOMLoaded script applies the sessionStorage token cache to :root if present (Q5 a), so the first paint matches the last sample.", - "site/quartz/static/ground/ground.js (~400 lines, no dependencies, no build step): context, tokens in and out, flow/march/resolve/downsample passes, PBO readback, scheduler, controller, debug and parity modes, a named composite slot for the stardust cut.", - "site/quartz/static/ground/flow.frag.glsl, cloud.frag.glsl, taa.frag.glsl, downsample.frag.glsl; a shared 3-vertex full-screen vertex shader inline in ground.js.", - "site/quartz/static/ground/CultMath.glsl and glsl-parity.json, vendored from CultLib with the pin in the header.", - "scripts/ground/check-cultmath-glsl.ps1: the vendoring drift check.", - "custom.scss: the four nebula input tokens on body; the fifteen ground seeds plus --gamecult-ground-mean on :root with the ritual overrides under :root:has(body[data-slug]); #gamecult-ground { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }.", - "docs/brand-design-language.md: the wash section rewritten as above; one paragraph on the ground shader: what it reads (inputs), what it writes (outputs), what it may not hold, and the fallback." - ], - "file_changes": [ - { - "location": { "path": "site/quartz/styles/custom.scss", "line": 4, "end_line": 8 }, - "change": ":root block: the fifteen ground seeds and --gamecult-ground-mean declared beside color-scheme." - }, - { - "location": { "path": "site/quartz/styles/custom.scss", "line": 10, "end_line": 31 }, - "change": "body: four nebula input tokens declared; radials and the linear gradient reference the ground tokens; alphas keep the wash-home-only calc." - }, - { - "location": { "path": "site/quartz/styles/custom.scss", "line": 103, "end_line": 124 }, - "change": "ritual block: background declaration deleted; a :root:has(body[data-slug]) rule carries its seeds and nebula inputs." - }, - { - "location": { "path": "site/quartz.layout.ts", "line": 19 }, - "change": "header: [GameCultThemeLock(), GameCultGround(), GameCultMasthead()]." - }, - { - "location": { "path": "docs/brand-design-language.md", "line": 69, "end_line": 84 }, - "change": "wash section rewritten: shader-owned ground, sampled wash, seeds, nebula inputs." - } - ], - "authority_map": { - "owner": "The shader owns the ground. custom.scss owns the four nebula inputs, --gamecult-wash and the seed values; ground.js owns the flow texture, the march, the TAA, the readback and the sampled ground tokens on :root; CultLib owns every noise and interval function the field calls.", - "inputs": [ - "the four nebula tokens and --gamecult-wash (computed on body)", - "prefers-reduced-motion, visibilityState, canvas size, devicePixelRatio, elapsed time", - "measured GPU frame time (timer query, fence, or rAF cadence)", - "the shader's own 8x8 readback", - "the vendored CultMath.glsl at its pinned CultLib commit" - ], - "outputs": [ - "one opaque moving canvas under the page, luminance <= 0.035", - "the fifteen ground tokens and --gamecult-ground-mean on :root inline, at most 2 Hz", - "debug and parity readbacks (console, flag only)" - ], - "derived_state": [ - "the ground tokens are derived from the shader's result while it runs; the seeds are the fallback; the CSS wash renders whichever is in force; the shader never reads them", - "the flow texture is the one owner of motion: warp, hue, motion vectors (and the stardust, next cut) read it", - "the TAA history is a cache, reprojected by the flow; reset on resize, first frame and budget step", - "S and dpr are derived from measurement within the session; never stored", - "the sessionStorage token set is a cache of the last sample; absent or malformed means seeds", - "CultMath.glsl in the site is derived from CultLib at the pinned commit" - ], - "forbidden_writers": [ - "no colour, alpha, position or radius literal in ground.js or any GLSL file", - "no read of --gamecult-ground-* or --gamecult-light-* by the shader or by ground.js, except the seed read before the first readback", - "no navigator.userAgent, platform, maxTouchPoints, or any device-name branch", - "no class or attribute set on body or html by ground.js; token writes are setProperty on :root only", - "no second wash token; no page rule setting a radial alpha; no second flow evaluation outside flow.frag.glsl", - "no noise or interval function defined in the site's GLSL; only cultmath_* calls", - "no synchronous readPixels to client memory; no setInterval; one requestAnimationFrame scheduler; localStorage never" - ], - "shared_paths": [ - "home, every content page and the ritual essays paint one canvas and one token set, in CSS and in the shader", - "slow device, hidden tab, reduced motion, missing WebGL2 and missing half-float all pass through the one controller", - "the 8x8 readback is the only path from the shader to CSS; the beforeDOMLoaded cache apply and the live writer set the same tokens the same way", - "the same Deploy Quartz workflow; static files ship with the overlay" - ], - "deletion_line": "The ritual block's own background and the nine body literals go in the same commit the tokens are declared. The canvas, four shaders, ground.js and the vendored library are the whole addition; nothing else in the engine or the content changes." - }, - "verification": { - "builds": [ - "Deploy Quartz green on the landing commit: gh run list -R GameCult/gamecult-site -w \"Deploy Quartz\" -L 1", - "scripts/ground/check-cultmath-glsl.ps1 exits 0 against a CultLib checkout at the pinned commit", - "the built stylesheet contains rgb(var(--gamecult-light-0) / calc(var(--gamecult-light-0-a) * var(--gamecult-wash))) verbatim and a :root:has(body[data-slug=\"Blog/small-ritual-of-reach\"]) rule" - ], - "tests": [ - { - "name": "browser pane, /?ground=debug: max relative luminance over the canvas after 32 frames <= 0.035", - "pins": "text contrast: body text keeps >= 7:1 on every ground pixel." - }, - { - "name": "browser pane, /?ground=parity-wash and a ritual essay: canvas vs CSS seed wash within 2/255 at 16 points with density 0 and flow frozen", - "pins": "the seeds and the shader's base agree; the fallback promise holds." - }, - { - "name": "browser pane, / after 2 s: :root inline style carries the sixteen tokens; body's computed backgroundImage resolves to the sampled values; a read 1 s later differs only where the frame changed", - "pins": "the CSS wash is sampled from the shader, at most 2 Hz, without a stall (no readPixels-to-client in the profiler)." - }, - { - "name": "browser pane, /?ground=parity: every fixture function within its tolerance class on WebGL2; numbers and GPU string in the report", - "pins": "GLSL = C# on a device; the proving ground's third runtime." - }, - { - "name": "browser pane, /?ground=debug at desktop and the mobile preset: mean evals per pixel, unfinished rays < 1%, GPU ms per pass; ?ground=debug-mv shows motion where flow is non-zero", - "pins": "the step budget, the interval saving with the warp, and the reprojection on the shipped field." - }, - { - "name": "reduced motion emulated: frames stop at 32, mv is 0, time frozen; hidden tab: no frames; WebGL2 disabled: no canvas in the DOM and the seed wash paints; sessionStorage cleared: seeds paint first", - "pins": "every fallback goes through the controller and lands on the same CSS ground." - }, - { - "name": "git diff base..head --stat: custom.scss, quartz.layout.ts, docs/brand-design-language.md, the new component, static/ground/*, scripts/ground/* only", - "pins": "no engine, content or masthead change." - } - ], - "negative": [ - { - "pattern": "#[0-9a-fA-F]{6}\\b|rgba?\\(|\\b(255|138|109|183)\\b", - "scope": "site/quartz/static/ground/*.js and *.glsl: 0 matches." - }, - { - "pattern": "gamecult-ground-|gamecult-light-", - "scope": "site/quartz/static/ground/*.glsl: 0 matches; in ground.js only inside the token writer and the seed read, never in a uniform upload." - }, - { - "pattern": "userAgent|navigator\\.platform|maxTouchPoints|localStorage|setInterval|classList|setAttribute\\(", - "scope": "site/quartz/static/ground/ground.js: 0 matches." - }, - { - "pattern": "readPixels\\([^)]*(Uint8Array|Float32Array|Uint16Array)", - "scope": "ground.js: 0 matches outside the parity and debug readbacks, which are flag-gated and named." - }, - { - "pattern": "float cultmath_|vec4 cultmath_|float snoise|hash\\(", - "scope": "flow/cloud/taa/downsample.frag.glsl: 0 matches; cultmath_* is defined only in the vendored CultMath.glsl." - }, - { - "pattern": "radial-gradient\\([^)]*rgba?\\([0-9]", - "scope": "site/quartz/styles/custom.scss, body rule and ritual block: 0 matches." - }, - { - "pattern": "gamecult-titlebar|gamecult-nav-link|sidebar|composite|GameCult-Quartz", - "scope": "git diff base..head changed lines: 0 matches." - } - ], - "operator": [ - "open / on the desktop and on the phone; say whether the nebula's motion and intensity are right (uniforms: PERIOD, FLOW_MAX, intensity)", - "on the phone with ?ground=debug, read the logged GPU ms and the controller's final S/dpr; say whether it got warm after five minutes", - "navigate / -> /Blog -> back; say whether the ground is continuous or shows a seed flash (Q5)", - "open a ritual essay and confirm its ground still reads as its own paper" - ] - }, - "estimate": { - "lines_added": 980, - "lines_removed": 15, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": ["GLSL ES 3.00 shader files in static/ground", "vendored glsl-parity.json", "one sessionStorage key holding the last sampled token set"], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "site-masthead:ruling:operator-chromeless-column" - ], - "questions": [ - "Q4 in the map: palette input tokens (a, recommended)", - "Q5 in the map: carry the last sampled wash across page loads (a, recommended)" - ] -} diff --git a/docs/cultmath-interval-ground-cut-site-stardust.spec.json b/docs/cultmath-interval-ground-cut-site-stardust.spec.json deleted file mode 100644 index cc8dc5ff..00000000 --- a/docs/cultmath-interval-ground-cut-site-stardust.spec.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "campaign": "cultmath-tapes", - "cut": "site-stardust", - "revision": 1, - "title": "Site stardust: stateless particles advected by the ground's flow texture, rendered to a half-res layer, blurred by the clouds' accumulated opacity (raymarch-driven DoF), composited behind the nebula", - "repo": "GameCult/gamecult-site", - "branch": "main", - "base": "535d170", - "depends_on": [ - "cultmath-tapes:cut_spec:site-ground.r2" - ], - "first": [ - "Map: F:/Projects/CultLib/docs/cultmath-interval-ground-cut.md, 'Stardust', 'Depth of field driven by the raymarch', 'Budget', D4, D9, D10. Re-pin base to main after site-ground lands. The composite slot site-ground left in the resolve is where this cut plugs in; do not restructure the resolve.", - "Aetheria reference, read once, copy nothing: Compute/Stardust/Stardust.compute:118-147 (grid cell -> hashed spawn, lifetime = frac(time/period + hash), position -= flow * lifetime * period, size = parabola(lifetime, 2), colour from a hue ramp x nebula tint); Stardust.shader:49-86 (billboard from quadPoints by SV_VertexID/SV_InstanceID, powerPulse falloff, distance exponents); CustomDoF/DepthOfField.hlsl:29-32 (CoC read from a raymarch output), :150-201 (disk gather weighted by CoC), :217-242 (combine). The web version is far smaller: no distance exponents (the slab is thin), no shadow pass, no near/far split.", - "Particles are stateless: no buffers are updated. One static 6-vertex quad VBO; drawArraysInstanced with count N; the vertex shader derives everything from gl_InstanceID, time and the flow texture (vertex texture fetch is standard in WebGL2): cell = (id mod G, id / G) over the slab mid-plane; hashes via cultmath_pcg3d (the vendored CultMath.glsl is concatenated before the vertex source too) for spawn jitter, lifetime offset, size and brightness; lifetime = fract(t / PERIOD_P + offset); position = spawn - flow(spawn uv) * lifetime * PERIOD_P; size = base * parabola(lifetime, 2); colour = hue at the screen position (from the flow texture's channels, the same mix as the clouds) * brightness. Reduced motion freezes t as site-ground does.", - "Stardust layer: half-resolution RGBA16F target, cleared each frame, additive blend, powerPulse falloff in the fragment shader; N = 16384 desktop, 4096 phone; the controller scales N with S (N halves when S halves) and the layer follows dpr.", - "DoF: in the resolve's composite slot, read opacity = 1 - T from the reprojected, clamped history (not the current frame) and gather the stardust layer with an 8-tap Poisson disk of radius RMAX * opacity in layer texels (RMAX ~ 12 px at dpr 1, scaled by dpr); weight taps by a soft disk; composite out = ground + clouds + stardust_blurred * T, then the luminance clamp. All stardust is behind the whole cloud layer (D9).", - "Debug flags: ?ground=debug-stardust writes the stardust layer alone; ?ground=debug-coc writes opacity into red. Prove in the browser pane: the stardust and the clouds move together (with ?ground=debug-mv from site-ground and the particle velocity written in green under ?ground=debug-stardust-v, the two directions agree within 5 degrees at 64 sampled pixels where |flow| is above a threshold); luminance clamp still holds after the composite; GPU ms per pass (stardust layer, gather) with the timer query at desktop and at the mobile preset's pixel count; the full-stack total against the budget table; the unfinished-ray fraction unchanged by this cut.", - "Budget contract (map, 'Budget'): the stardust layer plus the gather cost no more than a quarter of the march at the same S; if the measurement says otherwise, the gather drops to 4 taps before N drops, and the report says which. Stardust is never cut before the clouds' S on the ladder." - ], - "deletes": [], - "keeps_moves": [ - "site-ground's flow texture, march, TAA, readback and token writer: untouched; the stardust reads the flow texture and the hue mix the same way the clouds do.", - "The sampled wash now includes the stardust in its 8x8 readback by construction (it samples the final frame); nothing changes in the writer.", - "The budget controller gains one scaled quantity (N) and no new state; the ladder order is unchanged." - ], - "adds": [ - "site/quartz/static/ground/stardust.vert.glsl and stardust.frag.glsl: the instanced billboard and the powerPulse sprite.", - "ground.js: the stardust pass (one VBO, one program, drawArraysInstanced), the half-res layer, N in the controller, the gather in the resolve's composite slot, the two debug flags.", - "taa.frag.glsl: the composite slot filled: opacity from history, the 8-tap gather, out = ground + clouds + stardust_blurred * T.", - "docs/brand-design-language.md: two sentences under the ground shader paragraph: the stardust and the DoF, and that they read the same flow and hue as the nebula." - ], - "file_changes": [ - { - "location": { "path": "site/quartz/static/ground/ground.js", "line": 1 }, - "change": "stardust pass, layer, N scaling, gather hookup, debug flags; line numbers are site-ground's and are re-read by function name." - }, - { - "location": { "path": "site/quartz/static/ground/taa.frag.glsl", "line": 1 }, - "change": "the named composite slot becomes the opacity-weighted gather and the final composite." - }, - { - "location": { "path": "docs/brand-design-language.md", "line": 69 }, - "change": "two sentences on stardust and DoF under the ground shader paragraph (post site-ground numbering)." - } - ], - "authority_map": { - "owner": "ground.js owns the stardust pass and the DoF gather; the flow texture (site-ground) owns the particles' motion; the TAA history owns the opacity the DoF reads; the nebula input tokens own the particles' hue through the same mix as the clouds.", - "inputs": [ - "the flow texture and the hue mix (site-ground)", - "the reprojected, clamped history's transmittance", - "time, N and dpr from the controller; gl_InstanceID" - ], - "outputs": [ - "a half-res stardust layer per frame", - "the composite with stardust blurred by cloud opacity behind the nebula, still under the luminance clamp" - ], - "derived_state": [ - "every particle's position, lifetime, size and colour are derived from gl_InstanceID, time and the flow texture each frame; nothing is stored or updated", - "N is derived from S by the controller; the layer size from dpr", - "the blur radius is derived from the accumulated opacity; there is no second CoC source" - ], - "forbidden_writers": [ - "no particle buffer update, transform feedback or CPU-side particle state", - "no second flow function or hue mix; the vertex shader samples the flow texture", - "no colour literal; no per-depth transmittance; no second march", - "no new controller state beyond N; the ladder order is not changed", - "no change to the readback or the token writer" - ], - "shared_paths": [ - "clouds and stardust read one flow texture and one hue mix, so they move and colour as one", - "the one resolve pass composites ground, clouds and stardust and applies the one luminance clamp", - "the one controller scales S, N and dpr together" - ], - "deletion_line": "Nothing is deleted. The addition is two small shaders, one pass and one gather; it buys the stardust and the DoF the operator named, and it must prove it fits the same budget." - }, - "verification": { - "builds": [ - "Deploy Quartz green on the landing commit", - "scripts/ground/check-cultmath-glsl.ps1 still exits 0" - ], - "tests": [ - { - "name": "browser pane, /?ground=debug-stardust-v with ?ground=debug-mv: particle velocity and cloud motion vectors agree within 5 degrees at 64 sampled pixels where |flow| exceeds the threshold", - "pins": "one flow: the stardust and the nebula move as one." - }, - { - "name": "browser pane, /?ground=debug-coc: opacity is 0 where the clouds are empty and rises inside them; the stardust gather radius follows it (a visible blur under a dense cloud, sharp in a gap)", - "pins": "the raymarch drives the DoF, as in Aetheria's hack." - }, - { - "name": "browser pane, /?ground=debug: max relative luminance after 32 frames <= 0.035 with stardust on", - "pins": "the clamp holds after the composite." - }, - { - "name": "browser pane, timer query at desktop and at the mobile preset: stardust layer + gather <= 25% of the march at the same S; full-stack totals quoted against the budget table", - "pins": "the stardust fits the same budget or the report says what gave." - }, - { - "name": "reduced motion: particles frozen, frames stop at 32; hidden tab: no frames", - "pins": "the stardust obeys the one controller." - } - ], - "negative": [ - { - "pattern": "bufferSubData|transformFeedback|TRANSFORM_FEEDBACK|new Float32Array\\((N|count|particles)", - "scope": "ground.js stardust section: 0 matches; particles are stateless." - }, - { - "pattern": "#[0-9a-fA-F]{6}\\b|rgba?\\(", - "scope": "stardust.vert.glsl, stardust.frag.glsl, ground.js: 0 matches." - }, - { - "pattern": "snoise\\(|float cultmath_", - "scope": "stardust.vert.glsl and stardust.frag.glsl: 0 matches; the flow and hue come from the texture, not from a second evaluation." - }, - { - "pattern": "readPixels|setProperty", - "scope": "git diff base..head changed lines in ground.js: 0 matches; the readback and the token writer are not touched." - } - ], - "operator": [ - "open / on the desktop and on the phone; say whether the stardust sells the motion and whether the blur under the clouds reads like the video (RMAX, N, PERIOD_P are the dials)", - "on the phone with ?ground=debug, read the full-stack GPU ms and the final S/N/dpr; say whether it got warm" - ] - }, - "estimate": { - "lines_added": 320, - "lines_removed": 4, - "dependencies_added": [], - "dependencies_removed": [], - "formats_added": [], - "formats_removed": [], - "targets_added": [], - "targets_removed": [] - }, - "rulings": [ - "site-masthead:ruling:operator-chromeless-column" - ], - "questions": [] -} diff --git a/docs/cultmath-interval-ground-cut.md b/docs/cultmath-interval-ground-cut.md deleted file mode 100644 index ddb1a1e6..00000000 --- a/docs/cultmath-interval-ground-cut.md +++ /dev/null @@ -1,1624 +0,0 @@ -# CultMath intervals and the gamecult.org ground: cut map - -Status, 2026-10-04: interval-ops, glsl-lowering, snoise-tie (48aadda0) and affine-forms with -affine-shaders (156782da) are on main; the as-built record is the last section. Figures quoted in -Passes 1-5 at SNOISE_LIPSCHITZ 10.099261 predate the tie fix (now 7.9640074) and are conservative; -design.md carries the current measurements. Map history: Imagination pass 4, 2026-10-03. Pass 1's Q1–Q3 are answered (below); -the Self opened the `cultmath-tapes` campaign from pass 2; pass 3 revises the -two CultLib cuts after their first Hands reports and the operator's challenge -to the march, and changes the site field to envelope-then-noise; pass 4 -(section "Pass 4") revises `interval-ops` to r3 after its second Hands report -and Soul's verdict, and names the one shipped void (Q9). Pass 5 (section "Pass 5") maps -affine forms against CultLib `main` at `a7966142`. Where a later pass and -an earlier section disagree, the later pass wins. Where this map and the Body -disagree, the Body wins and this map is stale. - -Pinned HEADs (every `file:line` below is against these): - -| Repo | Ref | SHA | -| --- | --- | --- | -| CultLib | `main` | `c49c76ee` (CultMath 0.3.0 merged at `614fd445`) | -| gamecult-site | `main` | `535d170` (before `wash-home-only` lands) | -| Aetheria | local checkout | read only; `Volumetric.cginc`, `Raymarching/CloudShader.shader`, `Compute/Stardust/Stardust.{compute,shader,cs}`, `CustomDoF/DepthOfField.hlsl`, `Zone Display/VolumeCloudRenderer.cs` | - -## The operator's words - -1. "Can we replace the site's background with a fancy yet unobtrusive and - inexpensive shader thing? It's odd that my main site wouldn't have that, - considering my specialization. Would it be too much to have some optimized - subset of Aetheria's volumetric clouds shader in there?" -2. After the Self proposed a quarter-resolution, 8–16 step, static-on-phones - design: "map it as a cut that includes the GPU interval arithmetic we're - borrowing from Fidget for a planned Asura campaign. I'd like this shader to - be the proving ground for that - with the right math we can absolutely run - this fullscreen on mobile, per pixel as long as the sample count is low and - we're accumulating samples with TAA (Aetheria's TAA is honestly - embarrassing and it still handles smooth 1080p clouds on my tired old - 1070)" -3. On pass 1's Q3 (ground tokens as the shader's input): "I like that, but the - background should be nice and dynamic and we should sample the wash from - the result instead. Is there any point sending you video? I don't think - your vision model has anything in it to encode motion. Anyway, this video - really blew people away, with its combination of the clouds, the flowing - stardust and my hacked DoF shader where I replaced the circle of confusion - calculation with an output from the raymarching shader, I think it was - final transmittance? Doesn't matter, looks great to have the clouds blur - what's behind them. This does remind me we're totally gonna need that - stardust too, it really sells the motion of the nebulae" - -Rulings from pass 1: **Q1** new campaign `cultmath-tapes`. **Q2** the slow -ladder is samples, then resolution, then the CSS wash. **Q3** answered outside -the options: the shader owns the ground and it moves; the CSS wash is sampled -from the shader's result; the ground tokens are seed and fallback only, never -the shader's input; stardust and the raymarch-driven DoF are in scope. - -## Ownership - -### Where the interval math lives - -**CultLib, `packages/cultmath`.** This is the parked campaign's own first step -(`docs/cultmath-tape-target.md`, sketch step 1: "CultMath `interval` in C# and -HLSL with parity tests ... It stands alone, and is the first cut to take even -if the rest stays parked"). The "planned Asura campaign" in the operator's -words is that document; its first named consumer is Aetheria's volumetric -raymarching, and Asura itself does not need intervals -(`cultmath-tape-target.md:103`). - -The site speaks WebGL2 GLSL ES 3.00. Three routes were weighed: - -| Route | What | Why not | -| --- | --- | --- | -| A | Hand-port the needed functions to GLSL inside gamecult-site | A second noise authority with no parity test; the exact thing Aetheria's `GPU Noise` copies are (follow-up `aetheria-snoise-pin-bump`). | -| B | `dxc -spirv` then SPIRV-Cross to GLSL ES, using the existing `tools/compile-hlsl-spirv.ps1` chain | SPIRV-Cross emits one whole shader with mangled names; there is no library a site shader can call `cultmath_snoise` from. | -| C | **A textual lowering HLSL → GLSL in CultLib with a complete, enumerated transformation list, the discipline of the HLSL → C# mirror (`packages/cultmath/docs/design.md:92-134`)** | Chosen. | - -Under C, `shaders/CultMath.glsl` is a committed generated artifact, like -`Swizzles.g.cs`. One implementation of the lowering lives in the test project; -a test pins the committed file equal to the lowering of `CultMath.hlsl` and -regenerates it when asked. GLSL's stricter typing is not patched in the -lowering: the HLSL is written in the common subset (legal, bit-identical) and -glslang compiles the lowered text in CultLib's tooling. Parity runs in two -legs, each with one owner: HLSL ⇔ C# by the existing bit-for-bit mirror; -GLSL ⇔ C# by a committed golden fixture evaluated on WebGL2 in the browser -pane and read back. CultLib has no GPU harness (follow-up -`gpu-snoise-parity`); the browser pane is one. The site vendors -`CultMath.glsl` with the CultLib commit in its header. - -### Campaign - -`cultmath-tapes` (Q1), repos `GameCult/CultLib` and `GameCult/gamecult-site`, -target doc `docs/cultmath-tape-target.md` unparked for step 1 only. The site -cuts cite `site-masthead:ruling:operator-chromeless-column` and depend on -`wash-home-only` landing first, because they rewrite the same lines. - -### Owner, consumers, invariant - -- Owner: CultMath owns interval arithmetic and the noise bounds in C# and HLSL, - GLSL derived. The site owns its field, flow, march, TAA, stardust, DoF and - budget controller. `custom.scss` owns the brand palette the shader reads - (four nebula tokens) and the seed values of the ground tokens. `ground.js` - owns the sampled ground tokens while it runs. -- Consumers: the site ground now; Aetheria's nebula raymarch at its CultMath - pin bump; the tapes campaign's HLSL interpreter later. -- Protected invariant, **`intervals-enclose`**: every interval function returns - a `[lo, hi]` containing `f(x)` for every `x` in its input region, in C#, HLSL - and GLSL alike. A consumer that skips a region because `hi < cutoff` has - skipped nothing that was there. The domain warp does not weaken it: a warped - point lies in the ball enlarged by the warp bound, and a test says so. - -## The authority map (all four cuts) - -- Owner: `packages/cultmath` for `iv_*` and the ball bounds; `GlslLowering` - (test project) for `shaders/CultMath.glsl`; `custom.scss` for the four - nebula input tokens, `--gamecult-wash`, and the seed values of the fifteen - ground tokens; `ground.js` for the flow texture, scheduling, budget, TAA, - the stardust and DoF passes, and the sampled ground tokens; the site GLSL - files for the field, the particles and the resolve. -- Inputs: CultMath reads nothing new. The lowering reads the two HLSL files. - `ground.js` reads the nebula tokens, `--gamecult-wash`, - `prefers-reduced-motion`, `visibilityState`, canvas size, device pixel - ratio, the measured GPU frame time and its own 8×8 readback. The field - reads uniforms and the flow texture only. -- Outputs: `CultMath.glsl`; the interval functions; one canvas under the - page; the fifteen ground tokens written on `:root` from the readback; a - debug log behind a flag. -- Derived state: the ground tokens are derived from the shader's result while - it runs and are seed values otherwise; the CSS wash renders them; nothing - reads them back into the shader. The flow texture is the one owner of - motion: the warp, the TAA motion vectors and the stardust all read it. - `CultMath.glsl` is derived from `CultMath.hlsl`. The TAA history is a cache. - `S`, `dpr` and the particle count are derived from measurement within the - session. -- Forbidden writers: no colour literal in `ground.js` or any GLSL; the shader - never reads a ground token; `ground.js` never reads the ground tokens except - to seed before its first readback; no user-agent, platform or touch-point - sniffing; no class on `body` or `html` by script; no second wash token; no - second flow function (particles and clouds read one texture); no GLSL edited - by hand; no `iv_*` without a C# twin; no noise defined in the site. -- Shared paths: every page's ground, the ritual essays included, is one - canvas and one token set, in CSS and in the shader. Every reduced budget - (slow device, hidden tab, reduced motion, missing WebGL2 or half-float) goes - through the one controller. The 8×8 readback is the one path from the - shader to CSS. -- Deletion line: in the site, the six literal radial colours and three - literal stops become token references and the ritual block's own ground - goes, in the same commit the tokens are declared. In CultLib nothing is - deleted. The subtraction this buys is upstream: Aetheria's - `Assets/Plugins/GPU Noise/*.cginc` at its pin bump, and the tapes campaign's - step 1 already landed. - -## The shader design - -### What Aetheria contributes, and what the web version keeps - -| Aetheria | Mechanism | Web subset | -| --- | --- | --- | -| `Volumetric.cginc:165-221` density | fill + coverage, domain-warped by `flow()` in two half-period phases cross-faded with `tri2` (a flow map; the advection never accumulates) | kept, one coverage octave and one detail octave, CultMath noise | -| `Volumetric.cginc:130-135` `globalFlow` | `Tri3D(p/scale − scroll) · amplitude` | replaced by two `snoise` at low frequency, rendered once per frame into a quarter-res flow texture | -| `CloudShader.shader:83-104` | transmittance integration | kept | -| `CloudShader.shader:261-314` TAA | reprojection by `_PrevVP`, γ=0.5 variance clip, fixed 5% blend, packed depth, the `density2` bug at `:311` | not kept; see TAA | -| `Stardust.compute:118-147` | stateless particles: grid cell hashed to a spawn point, `position −= flow · lifetime · period`, size `parabola(lifetime, 2)`, colour from a hue ramp × nebula tint | kept as an instanced vertex shader reading the flow texture; `gl_InstanceID` is the cell | -| `DepthOfField.hlsl:29-32` `FragCoC` | the CoC is read straight from a global `_DoFBlurTex` (its writer is not in this checkout; the operator recalls final transmittance), then the bokeh gather `FragBlur` `:150-201` | a gather on the stardust layer with radius ∝ cloud opacity at that pixel | - -### Density field (site-owned, `cloud.frag.glsl`) - -Pass 3 wraps this field in an envelope (a nebula floor with authored wells and -clear sky above it); `coverage` below becomes the noise that displaces the -floor, as in Aetheria. The flow, the phases and the hue stand. - -```text -camera at the origin, looking +z, static; the slab z in [Z0, Z1] fills the view -flow(uv) = A · (snoise(q·Ff + o1), snoise(q·Ff + o2), 0) q = slab mid-plane point; quarter-res texture, once per frame -phase_k(t) = fract(t / PERIOD + k/2), w_k = tri2(phase_k) k = 0,1 -warp_k(p) = p + flow · (phase_k − 0.5) · PERIOD -coverage(p) = Σ_k w_k · snoise(warp_k(p) · F0) two snoise -occupancy = max(0, coverage − CUTOFF) · K -detail(p) = 1 − |snoise(p · 4F0 + 17)| one snoise; the dune envelope -density = occupancy · mix(0.6, 1.0, detail) -hue(uv) = mix of the three nebula colours by flow.xy / A free: the flow texture's own channels -colour = hue · intensity -``` - -Three `snoise` per dense sample, one per empty probe. The pattern moves at -velocity `−flow` everywhere, because both phases advance at the same rate; -the cross-fade only changes content. That is what makes the motion vectors -below exact. - -### Interval culling along the ray, with the warp - -Pass 3 supersedes this section's march: the probe is per screen tile in a -pre-pass, the field has an analytic envelope the probe tests first, and the -loop below becomes the pre-pass's loop over cell ranges. The ball and the warp -enlargement stand. - -`cultmath_iv_snoise_ball(c, r)` returns `[n(c) − L r, n(c) + L r] ∩ [−1, 1]` -with `L` the committed Lipschitz constant. Over a segment `[t, t+Δ]` the -unwarped ball is centred at `t + Δ/2` with radius `Δ/2`; the warp displaces -any point by at most `D = |flow|max · PERIOD / 2`, so the ball `(c, Δ/2 + D)` -contains both phases' warped points, and one evaluation bounds the whole -coverage term. The march is adaptive subdivision, Fidget's region test on a -1-D region: - -```text -Δ = Δ0; t = Z0/dir.z + jitter · Δ0 -while t < t_exit and evals < S: - iv = iv_snoise_ball(p(t + Δ/2) · F0, F0 · (Δ/2 + D)) 1 eval - if iv.hi < CUTOFF: t += Δ; Δ = min(2Δ, ΔMAX) provably empty: skip, grow - elif Δ > ΔDENSE: Δ = Δ / 2 maybe dense: refine - else: integrate density(p(t + Δ/2)) over Δ; t += Δ 3 evals - if transmittance < 0.02: break -if t < t_exit: integrate one coarse sample over the rest the budget ran out; measured, must be rare -``` - -`iv.hi < CUTOFF` is the interval proof that the `0` branch of -`max(0, coverage − CUTOFF)` wins on the whole segment: Fidget's `min`/`max` -pruning at its smallest, applied by hand to a two-clause expression. Tape and -automatic pruning stay parked; this proves the arithmetic they rest on. - -### Step budget - -`S` counts `snoise` evaluations per pixel per frame. `S = 16` desktop, `8` -phone, `4` floor; the controller sets it from measurement. A debug mode writes -`evals / S` and an unfinished flag into the colour. Contract: under 1% of rays -unfinished at the chosen `S` on the shipped field. - -### TAA, motion-aware - -The camera is static but the field moves, so history is reprojected by the -known motion, which the flow texture owns: - -- Motion vector: `mv = project(−flow(uv) · dt)` in pixels; history is fetched - at `uv − mv`. Exact for the pattern between cross-fades (see above); the - cross-fade and the detail term are handled by rejection. -- Jitter: Halton(2,3) frame offset on the ray start plus interleaved gradient - noise per pixel, rotated per frame. -- Accumulation: `α = max(1/frames, 1/32)` on colour and transmittance. -- Rejection: a 3×3 min/max box of the current frame clamps the reprojected - history (AABB clamp, not variance clipping); out-of-bounds fetches take - `α = 1`. -- Reset on resize, on the first frame and on a budget step. -- Buffers: two RGBA16F history targets at canvas size (8-bit stalls - convergence at `α = 1/32` on a ground this dark); missing half-float falls - back to the CSS wash through the controller. - -### Stardust (cut `site-stardust`) - -Stateless, as Aetheria's: instance `i` is a cell of an `N×N` grid over the -slab's mid-plane, hashed by `cultmath_pcg3d` to a spawn point and a lifetime -offset; `lifetime = fract(t/PERIOD_P + offset)`; position = spawn − flow(uv -of spawn) · lifetime · PERIOD_P, read from the flow texture in the vertex -shader; size = `parabola(lifetime, 2)` × a hashed size; colour = the nebula -hue at its screen position × a hashed brightness. Rendered as instanced -billboards (one 6-vertex quad, `gl_InstanceID`) with additive blending into a -half-resolution RGBA16F stardust layer, with the `powerPulse` falloff of -`Stardust.shader:74-78`. Count: 16,384 desktop, 4,096 phone, controller-scaled -with `S`. The particles and the clouds move as one because they read the same -texture; there is no second flow. - -### Depth of field driven by the raymarch (cut `site-stardust`) - -Aetheria's hack: the CoC is a raymarch output, so clouds blur what is behind -them. Web version: in the resolve pass, the stardust layer is gathered with an -8-tap Poisson disk whose radius is `RMAX · opacity(uv)`, where -`opacity = 1 − T` is the TAA-accumulated cloud transmittance at that pixel -(the stable, converged value, which is why it is read from history and not -from the current frame). Composite: `ground + clouds + stardust_blurred · T`. -All stardust is treated as behind the whole cloud layer; a per-depth -transmittance would cost a second march and is not in scope. - -### Sampled wash: the CSS reads the shader - -After the resolve, a tiny pass downsamples the final frame to 8×8 (RGBA8). -`ground.js` reads it back asynchronously: `readPixels` into a -`PIXEL_PACK_BUFFER`, a `fenceSync`, then `getBufferSubData` on a later frame -once the fence has signalled. Never a synchronous readback. At most twice a -second, and only written when a value moved by more than 1/255: - -- `--gamecult-ground-0/1/2`: the mean of rows 0–1, 3–4 and 6–7. -- `--gamecult-light-N`, `-a`: the colour at the seed light's centre texel, - split into the hue (normalised) and the excess over the ground stop there. -- `--gamecult-light-N-at`, `-r`: the seed values; positions are not fitted. -- `--gamecult-ground-mean`: the 8×8 mean, for any tinted UI. - -These are written to `:root`'s inline style, so they beat the stylesheet's -seed declarations. The seeds live on `:root` in `custom.scss` (today's -literal wash), with the ritual essays' seeds under -`:root:has(body[data-slug="Blog/..."])`. The body background and the ritual -ground read the tokens. When WebGL2 is absent or the controller removes the -canvas, the seeds are what paints. Across page loads the last sample may be -carried as a cache (Q5). - -### Palette input - -The shader reads four input tokens from `custom.scss`, which is where the -brand says colour is defined: `--gamecult-nebula-0/1/2` (today orange -`255 138 42`, violet `109 96 255`, sky `89 183 255`) and -`--gamecult-nebula-base` (`#07111a`), plus `--gamecult-wash` as intensity. -Inputs and outputs are different tokens, so there is no cycle (Q4). - -### Resolution and the slow ladder (Q2) - -Full device pixels. The controller's ladder: `S` 16 → 8 → 4, then `dpr → 1` -(the stardust layer and DoF follow the canvas), then the CSS wash. Never a -step up within a session. - -### Pausing and fallbacks - -- `visibilityState !== "visible"`: no frames; on return, history is kept and - the motion vector uses the real elapsed `dt`, clamped to one frame. -- `prefers-reduced-motion: reduce`: time is frozen (phase, flow and particle - lifetimes fixed), render until 32 accumulated frames, stop; resize - re-renders. The clouds and stardust are there, still. -- No WebGL2, context lost, no half-float: canvas removed; the seeds paint. -- Too slow: measured; see below. -- The canvas is `position: fixed; inset: 0; z-index: -1; pointer-events: - none; aria-hidden`. The root background paints first, so the canvas covers - the CSS wash only once drawn. - -### Text contrast - -The resolve clamps relative luminance at 0.035 (about today's orange hotspot, -`#07111a` + `rgba(255,138,42,.18)` ≈ `(53, 42, 34)`, luminance 0.025), after -stardust and DoF are composited. Body text `#b7c7d9` (0.55) keeps ≥ 7:1 on any -ground pixel. A readback test asserts the max after 32 frames on `/`. - -## Budget and how it is measured - -| Device | Pixels | GPU per frame at 30 fps | Proxy | -| --- | --- | --- | --- | -| Desktop, GTX 1070 class, 2560×1440 | 3.7 M | ≤ 2.0 ms | 6% GPU duty | -| Laptop iGPU, Iris Xe, 1920×1080 at dpr 1.25 | 3.2 M | ≤ 3.5 ms | 10% duty | -| Mid-range phone, Pixel 6a / Galaxy A54 class, 1080×2400 | 2.6 M | ≤ 4.0 ms | ≤ 12% duty; no upward drift of the median over 5 minutes | - -Cost model for the full stack on the phone (one `snoise` ≈ 150 flops, ~1 -TFLOP available; estimates, replaced by measurement): - -| Pass | Work | ms | -| --- | --- | --- | -| Flow texture, quarter res | 160 k texels × 2 snoise | 0.05 | -| Tile pre-pass (pass 3), 1/64 res, `N = 8` | 40 k tiles × ≈ 30 probes in the cavity (interior retired in a few, the wall's ≈ 15 cells at 1.5 probes each), envelope-only because the noise ball cannot prove anything at this scale; ≈ 0.1 snoise-equivalents per pixel; worst case ≤ 192 probes per tile | 0.1 (≤ 0.8) | -| March at `S = 8` | 2.6 M × 8 snoise per frame, every pixel marches a wall; LOD and the mask decide where the frame's samples land, not how many (the controller does) | 3.3 | -| TAA resolve + DoF gather | ~19 texel reads per pixel, plus the depth-history fetch and one matrix multiply for the camera reprojection | 1.1 | -| Sun self-shadowing sample (named, not taken) | one envelope-only transmittance sample per primary sample, ≈ +25% of the march | +0.8, not on the phone | -| Stardust layer, half res, 4,096 particles | fill-bound, small | 0.2 | -| 8×8 downsample + PBO readback at 2 Hz | tiny | 0.05 | -| **Total at `S = 8`, the cavity (pass 3)** | | **≈ 4.8** | -| Total at `S = 6` / `S = 4` | | ≈ 3.9 / 3.1 | - -Said plainly: LOD does not change the per-frame cost, which the controller -fixes by `S`; it changes how much a frame's samples are worth. At `S = 8` the -cavity does not fit the 4 ms phone budget on the estimate (≈ 4.8); `S = 6` -sits at the line and `S = 4` is under it. What gives is `S`, and with the -mask and LOD that is nearly free: a converged wall needs about 12 snoise per -pixel in total, so `S = 4` converges in about three frames through the TAA -instead of thirty, and `S = 8` in two. Then `dpr`, as before. What gives, in order, is the -sample count, then the resolution; the stardust and the DoF are never dropped -before the clouds' samples; the self-shadowing sample is not taken on any -device until measured. On desktop at `S = 16` the stack is ≈ 1.9 ms. - -Measurement, in this order, all in `ground.js` behind a debug flag and used by -the controller: `EXT_disjoint_timer_query_webgl2` where present (Chrome -desktop) per pass; else a `fenceSync` after the resolve, polled (universal on -WebGL2, phones and Safari included; the queue of a background page is -otherwise empty); else `requestAnimationFrame` cadence. Hands proves it in the -browser pane: desktop numbers with the timer query, the phone's pixel count -from the mobile preset, the phone's GPU time from the operator's phone. - -## The proving-ground contract (what the tapes campaign inherits) - -1. **Enclosure tests in C#** (and HLSL by the mirror): every `iv_*` op over - random intervals and points; `iv_snoise_ball`/`iv_fbm_ball` over 2,000 - balls × 64 points. A mutant that shrinks any bound dies. -2. **The warp is enclosed**: for random flows bounded by `D`, every point - `warp_k(p)` over the segment lies in the enlarged ball and `snoise` of it - lies in `iv_snoise_ball(c, r + D)`. This is the test the site's march rests - on. -3. **The Lipschitz constant has provenance**: the max of `|snoise_grad|` over - 10⁶ points refined by gradient ascent, × 1.10, measured by a committed - test and pinned by another. Empirical with a margin, not a proof; the - enclosure tests are the defence. -4. **Tightness is a number**: mean interval width over true range, printed - by a committed test, for a later affine cut to beat. -5. **The saving is a number** (amended in pass 3): a C# test marches tiles of - rays through four scenarios, an envelope-then-noise field with authored - empty space among them, with the dense march and with the tile-amortized - interval march, and asserts ≥ 2× lower combined cost at equal - transmittance on the authored scenarios; the uniform slab is printed as - the worst case. The shipped field's evals per pixel and unfinished - fraction come from the browser. -6. **Three runtimes agree**: the GLSL golden fixture passes on WebGL2, with - tolerance class and device named in the report. - -Not proved here, said plainly: tape evaluation, automatic pruning, `min`/`max` -choice tracking, affine arithmetic. Those unpark with steps 2–4. - -## Cut order - -```text -glsl-lowering (CultLib) ─┐ -interval-ops (CultLib) ─┴─> site-ground (clouds, flow, TAA, sampled wash) ─> site-stardust (particles, DoF) - ^ after site-masthead wash-home-only -``` - -Four cuts. The two CultLib cuts are as in pass 1, except `interval-ops` gains -the warp enclosure test. `site-ground` grew (flow texture, reprojection, the -readback and token restructure); `site-stardust` is split out because its -Soul vocabulary is different (particle statistics, blur quality, the composite) -and because the ground must be measured on its own before the stardust is -charged against the same budget. No CultMath release is in the sequence; the -site consumes a commit. - -Specs: `docs/cultmath-interval-ground-cut-glsl-lowering.spec.json`, -`docs/cultmath-interval-ground-cut-interval-ops.spec.json`, -`docs/cultmath-interval-ground-cut-site-ground.spec.json`, -`docs/cultmath-interval-ground-cut-site-stardust.spec.json`. Revision 2 of -the two CultLib cuts (pass 3): -`docs/cultmath-interval-ground-cut-interval-ops.r2.spec.json`, -`docs/cultmath-interval-ground-cut-glsl-lowering.r2.spec.json`. Revision 3 of -`interval-ops` (pass 4): `docs/cultmath-interval-ground-cut-interval-ops.r3.spec.json`; -`glsl-lowering` r2 and `site-ground` r3 now depend on it. - -## Standing design decisions (means; Self may overrule) - -- D1. Intervals are `float2(lo, hi)`. Affine arithmetic is not taken; the - tightness number says whether it is ever worth it. -- D2. No `iv_*` function has a value-only or gradient twin; the bounds take - the point value only. -- D3. The site vendors `CultMath.glsl` by CultLib commit, SHA in the header, a - drift check in the site cut. -- D4. The flow texture is the one owner of motion. Warp, motion vectors, hue - and particles read it; nothing evaluates flow a second way. -- D5. Routes are page loads (`enableSPA: false`, `quartz.config.ts:15`); if - SPA is ever enabled, `ground.js` listens for Quartz's `nav` event and - re-reads the input tokens. -- D6. The budget verdict is session-only; a stored verdict would outlive a - driver update. -- D7. Inputs and outputs are different tokens: four nebula inputs, fifteen - ground outputs with seeds. The shader never reads an output; CSS never reads - an input except through the shader's result. -- D8. The ground tokens are written on `:root` inline, so the seed in the - stylesheet loses to the sample without a class or a second rule. -- D9. The DoF blurs all stardust by the final opacity; per-depth transmittance - is out of scope. -- D10. Stardust and DoF land after the ground has been measured alone, so the - report can say what each costs. - -## Pass 3: the envelope, the scenarios, the tile pre-pass, the split Phacelle - -Pinned: CultLib `main` `d0ea37f8`; `hands/cultmath-interval-ops` at -`c9bd003b` (report `cut-interval-ops.h1`); `hands/cultmath-glsl-lowering` at -`5ae207e8` (report `cut-glsl-lowering.h1`, branched from interval-ops). -Rulings: `operator-tile-amortized-march`, `operator-split-phacelle`, -`operator-compiler-downloads`, `self-exp-measure-in-site`, -`operator-ground-void-brush` (answers Q6; the void scene below). - -### The operator's words - -On the march: "I'm skeptical about the interval march, both in implementation -and measurement. Are we testing it in scenarios where we're actually giving -it empty space to skip? Surely if the pre distortion SDF represents a clear -sky with the camera above the fog and aimed up, the interval math can quickly -tell us not to bother marching very far, no? In Aetheria the levels are -authored to place deep gravity wells for the player to gaze across, with -dynamic action spaced around the well, and finding the empty space there is -the whole point of using intervals, no?" - -He is right. r1's saving test marched one `snoise` octave against a cutoff -through a slab with coverage everywhere: the worst case for intervals, and -0.93x said nothing about real scenes. - -### What r1 measured, and what was wrong in the march - -| Finding (`NoiseBoundTests.cs:344-376` at `c9bd003b`) | Effect | r2 | -| --- | --- | --- | -| Every probe charged one `snoise` per ray | a failed probe cost a third of a dense sample | one probe per tile (the ruling) | -| Coarse probes attempted where the ball could never prove emptiness: `hi = n(c) + L r` clamps to 1, so `L r F0 ≥ 1 + cutoff` is a guaranteed failure; at `StepMax = 2`, `L r F0 = 3.7` | every coarse probe wasted; the 0.74x row | a noise probe is attempted only when `L r F0` leaves room to prove `hi < cutoff`; otherwise the level is "maybe" for free | -| Growth capped at `StepMax = 8 Step0` | clear space cost `Depth / StepMax` probes | ranges double to the grid's end | -| The dense sample evaluated the detail octave even at zero occupancy | the baseline was dearer than a sane shader | coverage first, detail only when density can be nonzero (Aetheria's `if (dist < _SafetyDistance)`) | -| The finest-level probe before each dense cell | fine; amortized it is `1/N²` for a chance at 3 snoise | kept | -| No field structure | nothing to skip | envelope-then-noise, below | - -### The field, from Aetheria - -`Volumetric.cginc:165-221` with `:91-102`, `Zone.cs:369-397` -(`GetHeight`), `Zone.cs:426` (`PowerPulse`), `Settings.asset` -(`DefaultEnvironment`, `PlanetSettings`): - -```text -s(p) = p.y + h(p.xz) the pre-distortion SDF; h ≥ 0 the well map -h(xz) = PowerPulse(|xz| / 2R, 2) · 64 + Σ_b PowerPulse(|xz − c_b| / r_b, 16) · d_b -PowerPulse(x, e) = (1 − 4x²)^e on [0, ½], 0 beyond; r_b = 500 M^0.25, d_b = 30 M^0.175 -fade(s) = 1 − smoothstep(0.75 S, S, s) S = SafetyDistance 30: no noise above it -s'(p) = s + A · fade(s) · n(warp(p)) n = the two-phase warped coverage + ½ detail -density = max(0, (F − s') / B) F = FloorOffset −20, B = FloorBlend 10 -``` - -Above the safety distance the density is exactly 0 and the noise is never -evaluated, by the dense march too. The warp applies to the noise argument -only; the height is read at the unwarped `xz` (Aetheria reads -`_NebulaSurfaceHeight` at `pos.xz` and warps inside `triNoise3d`). - -### The composed bound (invariant `intervals-enclose`, kept) - -Over a tile's frustum slice `[z0, z1]`, every step an existing `iv_*` op: - -- Envelope over the slice's exact box, not the ball: `y = iv_mul([z0, z1], - m_y)`, `x = iv_mul([z0, z1], m_x)` with the tile's slope intervals; - `iv_h` = Σ over bowls of `[pulse(far), pulse(near)]`, `near`/`far` the - least and greatest distance from the box to the bowl centre (monotone, so - exact per bowl). `iv_s = iv_add(y, iv_h)`; `iv_fade` its ordered endpoints. -- Noise over the ball: `iv_n = iv_snoise_ball(ball.xyz · F0, ball.w · F0)`, - `ball = iv_frustum_ball(m_c, z0, z1, N / (√2 f), D)`: centre on the tile's - central ray at mid-depth, radius `(Δ/2)·|(m_c, 1)| + z1·N/(√2 f) + D`. - The warp enlarges only this radius; the envelope's box takes none. -- `iv_s' = iv_add(iv_s, iv_scale(iv_mul(iv_fade, iv_n), A))`; the slice is - provably empty iff `iv_s'.lo ≥ F`. When `iv_fade.hi = 0` the noise term is - identically zero and `iv_snoise_ball` is not called: the envelope proves - the slice empty at no `snoise` cost. This is why tiles compound: one - envelope probe per tile can retire a whole ray length. - -Two tests pin it: `TileBallEnclosesEveryRaySegment` (every ray's points, -sub-pixel jitter and warp included, inside the ball) and -`EnvelopeBoundEnclosesDensity` (the composed bound encloses `density` at -warped points of 2,000 slices, no tolerance). - -### Scenarios and predictions (combined cost, `e = 0.2` snoise per envelope evaluation, `N = 8`) - -| Scenario | Setup | Prediction | -| --- | --- | --- | -| (a) height fog | `h = 0`, camera at `y = S + 30`, rays level and up | > 50x: dense pays 256 envelope evaluations per ray; the tile about ten probes shared by 64 rays; 0 snoise either way | -| (b) inside the fog | `h = 0`, camera at `y = F − 10`, rays level | 0.8–1.0x: every ray saturates in a few cells; the pre-pass still probes the whole grid | -| (c) Aetheria-like | zone bowl `R = 2000` + four wells (masses 100, 1000, 10000, 1000), camera above the fog in the bowl, rays gazing across (`m_y ∈ [−0.25, 0.1]`), Aetheria's units and 256-sample quadratic grid | 2–4x: the clear cells before the fog surface collapse to a few probes per tile; the fog cells cost the same on both sides. The noise ball proves nothing at Aetheria's scale (`L r F0 ≥ 1.6` at the finest cell with `D = 60`), so it is not evaluated; the saving is the envelope's | -| (d) uniform slab | r1's field, kept as the worst case | 1.3–1.5x: the ceiling at `L = 10.099261` with the cheaper baseline | -| (e) the void, the shipped scene | the true cavity, hollow radius `Rh = 198`, ramp `S = 50`, camera 186 from the centre, low; every ray crosses interior and ends in a wall; three marches (fixed-step reference, masked fixed-step, masked LOD) | **steps per pixel ≈ 35 → 6 (5–8x fewer), combined cost 1.7x, snoise alone 1.25x**, from the model below. The noise ball proves nothing (`L r F0 ≥ 1.5`); the interior is retired by the envelope, the ramp is sampled at the content limit | - -The 2x contract on combined cost is asserted on (a) and (c) at `N = 8`; (b) -and (d) are printed. (e) is the headline: its contract is steps per pixel -(below), and it prints cost and snoise beside it. - -### Footprint LOD, and the cavity cost as a function - -The operator's words: "Surely this depends on the size of the cavity and the -camera placement, no? The slope of the wall's density gradient offset -determines the region we have to sample in. How much we actually sample that -region depends on how close it is to the camera. A 10-wide gradient 1,000 -units away only needs one raymarching step worth of detail, right?" - -Right. Pass 3b costed every wall at a fixed step. The march is now -footprint-aware, in the site and in the saving test: - -- `θ_px = 2 tan(fov/2) / H`; the footprint at distance `z` is `z θ_px`. -- Step `Δ(z) = max(k z θ_px, min(S/4, λ_fine(z)/2))`, `k = 4`: never finer - than four footprints, otherwise the finer of the two content limits (four - samples across the ramp, two per wavelength of the finest live octave). -- Octave `i` of wavelength `λ_i` carries weight `w_i(z) = 1 − - smoothstep(λ_i/2m, λ_i/m, z θ_px)`, `m = 4`: one smooth blend per octave, - no popping; TAA hides the per-frame sparsity. -- The weights are part of the field, so the bound encloses the truncated - field exactly: the noise interval over a slice is `Σ_i iv_mul([w_i(z1), - w_i(z0)], iv_snoise_ball(c F_i, r F_i))`, `w_i` monotone in `z`. - `intervals-enclose` holds for what the shader evaluates. -- The pre-pass says where each ray's ramp begins; LOD says how finely to - sample it once there. They compound. The reference a march that does not - know where the wall is must pay is the fixed step `min(10, S/4)` everywhere. - -The cavity is parametrised by the hollow radius `Rh` and the ramp width `S`; -the brush `(1 − (d/Rc)²)^e` with `CARVE` gives `Rh = Rc √(1 − CARVE^(−1/e))` -and `S` from the exponent (`e = 4` gives `S ≈ 1.3 Rh`, `e = 0.25` gives -`S ≈ 0.12 Rh`), so `(Rh, S)` are the knobs and `(Rc, e)` derived. Shipped: -`Rh = 198`, `S = 50`, so `Rc = Rh + S = 248` and `e = −ln CARVE / ln(1 − -(Rh/Rc)²) = 0.40`, `K = 1/30` (pass 4 corrects this line's `e ≈ 0.6, Rc ≈ -220`, which did not satisfy the formula; Q9 holds the look question). - -Imagination's model (scratchpad `cavity_model.py`; the test confirms or -refutes), 1080p, `N = 8`, per pixel for a converged frame; "ref" is the -fixed-step reference's steps: - -| `Rh` | camera | `S = 10` steps / snoise / cost ratio | `S = 50` | `S = 150` | -| --- | --- | --- | --- | --- | -| 100 | low | 6 / 12 / 2.6x | 6 / 12 / 1.6x | 14 / 36 / 1.3x | -| 200 | low (**shipped**, ref ≈ 35 steps) | 6 / 12 / 3.2x | **6 / 12 / 1.7x** | 14 / 36 / 1.4x | -| 400 | low | 6 / 12 / 4.0x | 6 / 12 / 1.9x | 14 / 36 / 1.5x | -| 1000 | low | 5 / 9 / 8.2x | 6 / 12 / 2.5x | 14 / 36 / 1.7x | -| 1000 | centred | 4.3 / 7 / 12.9x | 6 / 12 / 2.9x | 14 / 36 / 1.8x | - -Centred and mid offsets differ from low by under 10% at every point. What -the table says: within the frustum the footprint is under 4 units, so the -step is set by the content limits (`S/4`, and the detail octave's 12.5-unit -half-wavelength), not by distance; the "10-wide gradient 1,000 units away" -row is where the footprint finally bites (4.3 steps, 7 snoise). The sample -count is nearly flat in `Rh` and camera offset and rises with `S` only once -the detail wavelength, not the ramp, sets the step. What makes the shipped -scene cheaper without losing the mood, in order: a lower per-frame sample -budget, which LOD and the mask make nearly lossless (`S_budget = 4` converges -in about three frames at the walls); a thinner ramp (`S = 10` is 3.2x on cost -but reads as a surface; 25–50 keeps the fog); a longer detail wavelength or -no detail octave at the far wall; a larger hollow, which changes the -composition and costs nothing per pixel. - -**Q8 retired.** At the shipped point the shipped march takes 5–8x fewer steps -than the fixed-step reference and 1.7x less combined cost; the contract for -(e) is the number that scales with GPU time, steps per pixel: ≥ 2x fewer than -the fixed-step reference at the shipped parameters, with snoise per pixel and -combined cost printed beside it and promised nothing. The test asserts that; -the browser measures it (`?ground=debug` against `?ground=dense`). A shortfall skips the assertion naming `saving-2x-scenarios`; the -fields, grids and `e` are not tuned. The honest summary: at a Lipschitz bound -near 10 the noise ball is weak everywhere; what intervals buy on these fields -is the envelope's empty space, found exactly, and the tiles make finding it -nearly free. - -### The site ground: the void (ruling `operator-ground-void-brush`) - -The operator's words: "There was an old main menu visual with a purely -authored field, first thing I did all the way back when the shader was new. I -believe it was a single negative pseudo gaussian spherical brush creating a -void in the clouds, with a sun gently nestled at the bottom lighting the -cavity and orbiting along a track with the camera following low, very moody, -gives us lots of options for authoring the flow field and stardust -distribution" - -**The original, found.** Aetheria `e6181c11` ("Main Menu", 2021-03-13): -`Assets/Scenes/Main Menu.unity`, the `Sun` prefab instance under a `Center` -pivot, `Materials/Brushes/Gravity Well.mat` and -`Main Menu Sun Fog Tint.mat`, `Fog Marching Main Menu.mat` on -`VolumeRender.shader` of that commit. What survives, in its units: - -| Element | Original value | -| --- | --- | -| The brush | `PowerBrush` `(1 − x²)^16`, depth 40, radius 256 (half depth at r = 52; a Gaussian of σ ≈ 45); the sun's own gravity-well child. A boundary bowl (depth 75, power 0.25, radius 1500) is flat across the scene: a constant 75 | -| The floor | offset −16.46, blend 39.6: the fog top is `y = −91` outside the void, `−131` at the sun | -| The sun | sphere radius 12.5 at `y = −130`: the bottom of the void | -| The orbit | `Center` rotates 5°/s about y (72 s period); the sun at radius 175 | -| The camera | Cinemachine vcam following the sun (framing transposer, distance 150, damping 10, handheld noise amplitude 1 at 0.25 Hz), looking at `Look Target` `(0, −130, 0)`, the orbit centre at the sun's depth; saved at `y = −27` | -| The light | authored, not marched: the sun's tint brush `(1 − x²)^3`, depth 2, radius 128, orange `(1, .4, .1)`, plus a scene-wide blue ambient tint `(0.18, 0.59, 1)` × 0.01 | -| Stardust | 256² particles, spacing 2, floor −60, ceiling 0, height exponent `800 / (ceiling + wellDepth)`: more headroom where the well is deeper, so the void fills with stardust | -| Noise | strength 150, frequency 0.01, safety 50 | - -Not surviving: the 2021 `d()` displacement details (the 2021-05-30 "Volumetric -Redux" rewrote it), the tint map's runtime contents, the video. The 2021 -brush was radial in `xz` and carved a bowl in a cloud floor; the operator -ruled (Q7, `operator-void-true-cavity`) that the site's void is a true 3D -hollow inside a cloud volume that surrounds it on every side, including -above. Everything else recovered carries over. - -**The site scene** (`site-ground` r3; the brush parameters in this paragraph, -`Rc = 640`, `e = 4`, are superseded by pass 4's one shipped void, `Rh = 198`, -`S = 50`, `Rc = 248`, `e = 0.40`, pending Q9): the original's units. Outer volume: an -unbounded uniform fill (chosen over a shell: every ray then ends in a wall -and the march terminates by opacity, never by a far plane; `Z1 = 2 Rc` bounds -the pre-pass range only). The carve: `d = |p − c_v|`, `g(d) = (1 − -(d/Rc)²)^4` for `d < Rc`, `Rc = 640`, `CARVE = 1.5`; `density = K · max(0, -1 − CARVE · g(d'))`, exactly 0 inside the hollow radius `Rh = Rc √(1 − -CARVE^(−1/4)) = 198`, half at `0.49 Rc`, full at `Rc`; `K = 1/30`, so a wall -is opaque within ≈ 150 units of entry. Noise displaces the wall only: -`fade(d) = smoothstep(Rh − S, Rh, d)`, `S = 50`, `d' = d + A · fade · n`, -`A = 20`, `F0 = 0.01`. Its bound over a tile's slice: `d`'s interval is the -box's least and greatest distance to `c_v` (exact); `g`, `fade` and the carve -are monotone in it; the slice is provably empty iff `d_hi + A · fade(d_hi) · -n_hi ≤ Rh`, and deep inside (`fade = 0`) no noise is evaluated. `Rc` grew -from the brush's 256 because a 3D hollow must hold the camera. - -The sun orbits the origin at radius 175, period 72 s; the cavity centre is -`c_v = sun + (0, Rh − 12.5, 0)`, so the sun sphere rests on the hollow's -bottom and the hollow moves with it. The camera follows 120 behind the sun -along the tangent and 45 above it: 186 from `c_v`, 12 inside the hollow, low, -looking at `sun + (0, 60, 0)` so the lit lower wall and the dark upper wall -share the frame. The 2021 follow distance 150 and height 25 do not fit a -hollow a camera can stand in; 120 and 45 are the re-derivation. There is no -sky: behind a fully transmissive pixel the resolve shows the base token, and -only an unfinished ray (budget exhausted before the wall, measured, under 1%) -reaches it. `worldAt(t)` in `ground.js` is the one -owner of sun, cavity and camera; nothing integrates motion. The flow is authored -around the void: a swirl `SWIRL · tangent · (1 − (r/Rw)²)²` (largest -mid-slope, zero at rim and centre) plus the global noise flow, rendered into a -world-space window of side `4 Rw` around the sun, so warp, hue, motion vectors -and the stardust read one texture (D4). The stardust (next cut) spawns in the -bowl with the original's height rule and is lit by the same pulse. - -**Lighting, cheapest moody version:** the original's mechanism made 3D. At a -sample, `light = SUN · (1 − (d/Rl)²)^3` for `d = |p − sun| < Rl = Rh = 198` -(the original's 128 scaled with the hollow), plus the blue ambient; `colour = -density · (light + ambient) · hue(flow)`. Zero extra `snoise`; the lower wall -within `Rl` of the sun glows and the upper wall stays dark because the pulse -is zero beyond `Rl`, which is the moody split; the sun inside the hollow is -occluded by nothing, so it is a small additive disc in the resolve, occluded -only by the accumulated transmittance along its ray. A self-shadowing step (one envelope-only -transmittance sample toward the sun per primary sample, no noise, ≈ +25% on -the march) is named, not taken: desktop-only if measurement ever allows. - -**TAA with a moving camera:** the main pass writes the depth-weighted mean -march distance to an `R16F` history channel; the resolve reconstructs the -world point at that depth, moves it back by the field motion (`p + flow·dt`), -projects it with the previous frame's view-projection and fetches history -there. Same 3×3 clamp, same `α`, same resets. Colour, transmittance and depth -are reprojected by the one motion vector. - -**Fit with the tokens:** `--gamecult-nebula-0` (orange) is the sun's colour, -`--gamecult-nebula-2` (sky) the ambient, `--gamecult-nebula-1` the cloud hue's -second pole, the base the sky. Outputs as pass 2, with one change: -`--gamecult-light-0-at` is written from the sun's projected position, so the -CSS wash's main light follows the sun; its seed is the sun's mean screen -position, so the fallback is a still of the same composition. - -**Soundness with a moving camera:** each frame's pre-pass evaluates -`iv_frustum_ball` from that frame's camera; no ball, mask or probe result is -carried across frames. The only cross-frame state is the TAA history, which -is colour, not a soundness input. The saving test draws each tile's camera -independently and says so. - -The march: a **low-resolution pre-pass** at `W/8 × H/8` runs the tile loop -over the slab's cell ranges (the envelope first, the noise ball only when the -envelope leaves `fade.hi > 0` and `L r F0` leaves room) and writes a per-tile -skip mask of the dense cells not proven empty into an `RGBA32UI` texel (128 -bits; 96 cells at the slab's fine step). The main pass reads one texel -(`texelFetch`) and places its `S` samples in unmasked cells only, stratified -over the unmasked length; masked cells contribute exactly zero, so this is -exact importance sampling, not an approximation. The fragment cannot share a -probe across pixels (derivatives reach a 2×2 quad at best), so the pre-pass -is the cheaper and the only sound option in WebGL2. Cost at `N = 8` is in the -budget table: ≤ 144 probes per tile worst case (nothing skipped, hierarchy -descended everywhere), mostly envelope-only, ≈ 0.4–2 snoise-equivalents per -pixel; `N = 16` quarters it but makes the ball's lateral term equal the fine -half-length at the slab's far plane. **Predicted `N = 8`.** The site's own -ratio is measured in the browser against a dense reference with the same -envelope gate (the proving-ground contract's second half). - -### The split Phacelle and the compile checks (glsl-lowering r2) - -Pass 4: the glsl branch rebases onto interval-ops **r3**'s head, because r3 -changes `cultmath_iv_frustum_ball`'s radius and the fixture family with it. - -- Transformation step 1 gains one licence-keyed entry: an include under its - own licence is lowered into its own file. `CultMath.glsl` (MIT: `CultMath.hlsl` - + `CultMath.Interval.hlsl`) and `CultMath.Phacelle.glsl` (MPL-2.0, - concatenated after it only by consumers that call `cultmath_phacelle`; the - site does not). Both pinned; `THIRD-PARTY-NOTICES.md` lists the MPL files - and no longer calls `CultMath.glsl` MPL. -- `iv_exp` joins the fixture with a platform tolerance (1 ulp, the generating - OS named), because `self-exp-measure-in-site` has the site measure WebGL2 - `exp` against it. The fixture is regenerated for `cultmath_iv_frustum_ball`. -- glslang 16.6.0 and dxc are downloaded pinned and run: the MIT-only wrapper, - the two-file wrapper, a `lerp(` negative control, and a `cultmath_phacelle` - call against the MIT-only wrapper that must fail (proves the split). -- The glsl branch rebases onto interval-ops r2's head; its first commit is the - regeneration alone. - -Carried, still out of scope: the Unity `CultMath.dll` rebuild (no release in -the sequence); the fixture's ulp bounds on WebGL2 (site cut); Stryker's -timeouts are reported as timeouts, not kills. - -## Pass 4: Soul's five findings, the analytic body, the one shipped void - -Pinned: CultLib `main` `780d8cfa` (docs only since `d0ea37f8`); -`hands/cultmath-interval-ops` at `43183276` (report `cut-interval-ops.h2`, -verdict `cut-interval-ops.s1`, worktree `F:\Projects\CultLib-iv`). Rulings new -in this pass: `operator-wells-contract-vs-ceiling` ((c) is held to at least 90% -of its probe-free ceiling, not 2x: the ceiling is what intervals control; the -fog band's cost belongs to the field) and `operator-analytic-wall-body` (where -the envelope interval proves the density constant, one closed-form -Beer-Lambert step instead of sampling at the content limits). Spec: -`docs/cultmath-interval-ground-cut-interval-ops.r3.spec.json`. - -### What r2 measured - -| Scenario | r2 result | Pass 3 prediction | -| --- | --- | --- | -| (a) height fog | 16384x | > 50x | -| (b) inside the fog | 0.99x | 0.8–1.0x | -| (c) Aetheria wells | 1.41x at warp D (3.32x at warp 0); probe-free ceiling 1.42x (3.46x) | 2–4x | -| (d) uniform slab | 1.23x | 1.3–1.5x | -| (e) void, shipped | steps per pixel 36.34 → 16.45 (2.21x fewer), cost 1.34x, snoise 26.6 | 35 → 6 (5–8x), cost 1.7x | - -Two things the pass 3 model got wrong, both now owned by r3: the footprint -step kept its content limits (`S/4`, the detail half-wavelength 12.5) inside -the wall's constant-density body, which the model had costed at two steps; and -the noise band does not end at `Rc`: with `A = 20` and the free noise interval -`[−1.5, 1.5]`, the density is provably `K` only from `d ≥ Rc + 30`. The ruling -answers the first; the second is content and stays. - -### Soul's findings and what r3 does with each - -| Finding | Severity | r3 | -| --- | --- | --- | -| `frustum-ball-float-crossing` | Medium | the radius is widened by a derived float32 bound (below); seven extreme families join the enclosure test; the strictness sentence leaves the C#, the HLSL and `design.md` | -| `aetheria-far-plane-miscited` | Low | `far = 2048`, the Main Camera's (`ARPG.unity:31777`, `:31830`); the Tint camera's 1000 was the wrong camera | -| `shipped-void-two-scenes` | Medium | one shipped void, `(Rh, S) = (198, 50)`, `(Rc, e) = (248, 0.40)` derived; the map, the site-ground spec and the test agree; the look question is Q9 | -| `lod-weights-never-exercised` | Low | configuration "LOD far" (`Rh = 4000`, `S = 50`, low camera, `f = 467`) reaches weights in `(0, 1)` and at 0; the `[w(z1), 1]` bound is recorded as a deviation with its soundness argument | -| `stryker-timeout-survivor` | Low | 2525 named equivalent; ball radii to `1e3` so `L/r` dies to an enclosure test; every timeout hand-run; the report claims only demonstrated kills | - -### The float widening rule (finding 1) - -`iv_frustum_ball` returns a float32 ball; its promise is that every exact -point `(m z, z)` of every ray of the tile, `m` in the footprint, `z ∈ [z0, -z1]`, moved by at most the warp, lies inside it. Soul showed the r2 ball misses -such points by up to `5.7e-4 r` when `z0 == z1`, `3.3e-4 r` at `z ≈ 1e7` and -19% of `r` at `|m_c| ≈ 1000`: the triangle inequality is an equality on the -degenerate slice and the centre's own rounding crosses it. The rule, in C# and -both HLSL copies, after the r2 radius: - -```text -radius += (|c.x| + |c.y| + |c.z| + radius) · 2^-20 (9.5367431640625e-7, exact) -``` - -Derivation with `u = 2^-24`: the centre `c = (m_c z_m, z_m)` carries at most -two roundings per component (`z_m = fl(z0 + z1) · 0.5`, then the product), so -`|c_float − c_exact| ≤ 2u |c|₁`; the radius carries at most seven first-order -roundings (`z1 − z0`; the axis `sqrt(mx² + my² + 1)` at `3u`; the product; `z1 -· footprint`; the sum; `+ warp`), so `r_exact ≤ r_float (1 + 7u)`; the -widening's own addition rounds once more. `2^-20 = 16u` covers `8u (|c|₁ + r)` -twice over. fma contraction removes roundings and only tightens, so dxc's HLSL -and any driver's GLSL are covered by the same bound. Cost at the shipped -scales: `|c|₁ ≈ 600`, `r ≈ 5` → `6e-4` units, 0.01% of the radius. The -enclosure test computes distances in double from the float ball and the float -ray, no tolerance, over the r2 domain and the extreme families (`z0 == z1`; -`z1 − z0 = 1e-6 z1`; `|m_c| ≤ 1000`; `z ≤ 1e7`; `z0 = 0, z1 ≥ 1e-3`; `f ≥ 1`; -warp to `1e6`), corners at both depth ends with the flow pointed outward. The -derivation pin becomes two-sided (`r_exact ≤ ball.w ≤ r_exact + 2^-19 (r_exact -+ |c|₁)`), so a ball that forgets the widening fails and one that grows past -the rule fails. The caller's world transform and its own point rounding remain -the caller's; the function says so in its doc instead of a false proof. - -### The one shipped void (finding 3) and Q9 - -The map held two voids: the Footprint-LOD section's `(Rh, S) = (198, 50)` -(with an `e ≈ 0.6, Rc ≈ 220` that did not satisfy its own formula) and the site -section's `Rc = 640, e = 4` (a 442-wide ramp with a 50-wide fade band). Hands -implemented the first with the arithmetic corrected (`Rc = Rh + S = 248`, `e = -0.40`) and measured 2.21x; Soul measured the second at 1.93x. Under the -analytic body the second gains nothing: across a 442-wide ramp the optical -depth exceeds 4 before the density is provably constant, so rays end inside the -ramp and the body is never proven. The map's own rule says `(Rh, S)` are the -knobs, so the honest choice is the first; it changes the look relative to the -site section, hence Q9 (below). For `CARVE = 1.5` the ramp width is tied to the -exponent (`S/Rh = 1/√(1 − 1.5^(−1/e)) − 1`: `e = 0.4 → 0.25`, `e = 0.7 → -0.5`, `e = 1 → 0.73`, `e = 4 → 2.2`), so "pseudo-Gaussian" and "narrow" cannot -both be had without a third knob, and a narrow wall at `e = 4` needs -`CARVE ≈ 58`, which is a hard wall again. The ramp width is the look-cost knob. - -### The analytic body (ruling `operator-analytic-wall-body`) - -Consumer-side, no new CultMath function; the saving test and the site mirror -each other. - -- **When it applies.** The consumer's `Bound` over the whole remaining range - `[z, z_end]`, gated, is a point interval with positive value: for the void, - the envelope with the free noise interval `[−1.5, 1.5]` proves `fade = 1` - and `d_lo + A · (fade n)_lo ≥ Rc`, so every point of every ray of the tile - over the rest of the grid has density exactly `K` for any noise value. For - (a)–(d) no bound is a positive point (the fog's density varies with `s'`), - so the step never applies there, and the test asserts it. -- **Pre-pass.** `MarchTile` returns `(dense cells, bodyStart, bodyDensity)`: - when a single cell is not provably empty and its own bound is a positive - point, one more probe over `[z_j, z_end]`; if that is a positive point too, - `bodyStart = j` and every remaining cell is appended dense without probing - (always sound; it also drops the body's probes). The site writes the cell in - the mask texel's fourth word, `0xFFFFFFFF` when none. -- **Main pass.** Unmasked cells before `bodyStart` as before; at `bodyStart`, - `T *= exp(−K · (z_end − z) · |dir|)`, one step, stop. The grid end for every - void configuration becomes `|camera − c_v| + Rc + 6/K` (was `5/K`): the - body starts at `d ≥ Rc + 30` plus box slack, so `6/K` leaves at least 4.9 of - optical depth and `T ≤ 0.0075`. No probe in the main pass: the constant is - the field's pointwise envelope value at that cell. -- **Pin.** `AnalyticBodyMatchesFineMarch`: wherever a body is reported, the - bound over the rest of the grid is a positive point and the full and the - truncated density at 64 sampled points of the body equal it exactly; the - analytic factor equals the fixed-step product over the same cells within - `1e-4` relative; no (a)–(d) tile reports a body. The masked fixed-step march - stays the mask's soundness pin (exact agreement with the reference); only - the LOD march takes the step. Hand mutation that must fail: in - `VoidField.Compose`, `CarveRadius → HollowRadius` in the lo test. - -### Footprint LOD, exercised (finding 4) - -At `f = 935` every octave weight is 1 inside every r2 grid (the fine weight -drops below 1 past `z = 2922`; the largest grid ends at 2240). `VoidField` -takes a focal length, and one configuration reaches the weights: `Rh = 4000`, -`S = 50`, low camera, `f = 467` (a 98° vertical FOV at 1080 rows): fine weight -below 1 past 1460 and 0 past 2920, coarse below 1 past 5840, grid to ≈ 7990; -the footprint term `4 z θ` also exceeds 12.5 past 1460, so `LodStep` is -footprint-set there. It joins the enclosure test's field list and is printed by -the saving test, not asserted. Deviation recorded: the bound takes each weight -over `[w(z1), 1]`, not `[w(z1), w(z0)]`, because one `Bound` serves the full -field (`w = 1`) and the truncated one (`w ∈ [w(z1), w(z0)]`); `[w(z1), 1]` -contains both and `iv_mul` is monotone in its interval argument, so the -composed interval encloses both fields; the slack is only in far tiles whose -step the footprint already sets. Hand mutation that must fail the truncated -check there: `w(z0)` for `w(z1)`. - -### Contracts after r3 (asserted at `N = 8`) - -- (a): at least 2x combined cost. Measured 16384x. -- (c): at least 0.90 of its probe-free ceiling (`Ratio / Ceiling`, the lower - of warp 0 and D). Measured 0.99 at warp D, 0.96 at warp 0. -- (e): at least 2x fewer LOD steps per pixel than the fixed-step reference at - the one shipped void; the masked march exact; the LOD march within 0.02. -- (b), (d), the (e) grid and LOD-far: printed only. - -### Predictions (Imagination's rule, not a measurement) - -From r2's printed rows: the LOD steps that evaluated noise are about -`snoise / 2.8` plus two pre-band steps; the rest were constant-body steps, -which the analytic step makes one. Ref/LOD steps: - -| `Rh`, camera | `S = 10` r2 → r3 | `S = 50` r2 → r3 | `S = 150` r2 → r3 | -| --- | --- | --- | --- | -| 100, low | 2.1 → 5.3x | 1.8 → 2.5x | 1.6 → 1.6x | -| 200, low | 2.7 → 5.8x | 2.2 → 2.8x | 1.8 → 1.8x | -| 400, low | 3.4 → 6.2x | 2.9 → 3.5x | 2.2 → 2.2x | -| 1000, low | 6.8 → 10.9x | 4.5 → 5.2x | 3.3 → 3.3x | -| 1000, centred | 12.4 → 30x | | | -| **shipped** (198, low, 50) | | **2.21 → ≈ 2.9x (12.5 steps), cost 1.34 → 1.38x, snoise 26.6 unchanged** | | - -At `S = 150` rays end inside the ramp before the body is proven, so nothing -changes there. If the shipped point lands under 2.6x, the report says which -assumption failed: the pre-band's 0-snoise steps, or a body start later than -`Rc + 30` by box slack. - -### Authority map delta (against pass 3's) - -- `iv_frustum_ball` is now the owner of its own float32 rounding: the - widening is part of the function. Consumers add nothing for it and remain - owners of their world transform. -- The body proof is derived from the same `Bound` the mask is derived from, by - one more probe; the main pass reads it and never decides it. The Beer-Lambert - step is the consumer's integration, not a CultMath function. -- `(Rc, e)` are no longer authored; they are derived from `(Rh, S)`. The site - section's `Rc = 640, e = 4` is no longer an owner of the look (Q9 pending). -- (c)'s contract is derived from its own run (0.90 of the ceiling); no absolute - target is written for (c). -- Deletion line: the false strictness sentence, the Tint camera citation, the - (c) 2x assertion and the second shipped void leave before their replacements - are written. Net in `src`: one line and a doc comment. - -### Dependent specs - -`glsl-lowering` r2 now depends on `interval-ops` r3 and rebases onto its head -(the fixture family for `cultmath_iv_frustum_ball` changes with the widening). -`site-ground` r3 now depends on `interval-ops` r3; its field item carries the -one shipped void with `(Rc, e)` derived, its pre-pass writes the body-start -cell in the texel's fourth word, its main pass takes the one analytic step, -and `Z1 = |camera − c_v| + Rc + 6/K` (614 at the shipped point, 62 cells of -10; the mask has 96 bits). Both files are edited in place on `main`; the -mind's copies need re-admission by Self. - -## Questions - -**Q9. The one shipped void** (pass 4; finding `shipped-void-two-scenes`). -Authored as `(Rh, S)` with `(Rc, e)` derived; `CARVE = 1.5`, `A = 20`, -`F0 = 0.01`, `K = 1/30`, the camera as site-ground r3. -- (a) `Rh = 198`, `S = 50` → `Rc = 248`, `e = 0.40`. The scene r2 measured - (2.21x; predicted ≈ 2.9x with the analytic body). A 50-wide noisy wall whose - outer edge has a kink (`e < 1`), softened by the ±20 noise displacement and - the TAA. **Recommended**: the map's own rule, the measured scene and the - ruling's analytic body all point at it. -- (b) `Rc = 640`, `e = 4` (`Rh = 198`, a 442-wide pseudo-Gaussian ramp, fade - band 50): the site section's soft wall. Measured 1.93x; the body is never - proven, so the analytic step never fires; the (e) contract fails unless it - is dropped to printed or the detail octave is removed where the ramp is - wide, both of which are the operator's to decide. -- (c) `Rh = 198`, `S = 100` → `Rc = 298`, `e = 0.70`: the compromise, a - softer 100-wide wall; predicted ≈ 2.4x; not in the r2 grid, so unmeasured. - -Hands codes (a); another ruling moves only the shipped constants here, in the -r3 spec and in the site-ground spec. - -**Q6. The site ground's envelope look.** Answered outside the options by -`cultmath-tapes:ruling:operator-ground-void-brush`: the old main menu's void -(pass 3, "The site ground: the void"). - -**Q7. What "spherical" means for the brush.** Ruled -`cultmath-tapes:ruling:operator-void-true-cavity`: a true 3D hollow inside a -cloud volume that surrounds it on every side, including above; not the 2021 -bowl. - -**Q8. `cavity-contract`.** Retired in pass 3d (see "Footprint LOD"): the -contract for (e) is steps per pixel against the fixed-step reference at the -shipped parameters, ≥ 2x fewer, predicted 5–8x; cost and snoise are printed -beside it and promised nothing. - -Specs for pass 3: `docs/cultmath-interval-ground-cut-site-ground.r3.spec.json` -beside the two CultLib r2 specs. - -**Q4. Where the shader's palette input comes from.** -- (a) Four new input tokens in `custom.scss` (`--gamecult-nebula-0/1/2`, - `--gamecult-nebula-base`), seeded with today's wash colours. - **Recommended.** The nebula palette can be tuned without moving the UI - accent, and the brand doc's rule (colour is defined in `custom.scss`) holds. -- (b) Reuse `--secondary` and `--tertiary` from `quartz.config.ts` and promote - the violet to a config token. Fewer tokens; ties the nebula to the UI accent - for good. - -**Q5. Carrying the last sampled wash across page loads.** -- (a) `ground.js` keeps the last written token set in `sessionStorage` and - applies it before the first paint on the next page; the seeds apply when - nothing is stored. A cache, never authority. **Recommended.** Without it, - every navigation shows the seed wash for the first frames, then the shader. -- (b) No storage; the seed paints first on every page. Simpler; a visible - shift on every navigation. - -## Unsettled - -- The Lipschitz constant is empirical with a margin; a per-cell polynomial - proof is possible and not in this cut. -- `_DoFBlurTex`'s writer is not in the Aetheria checkout; the web DoF takes the - operator's recollection (final transmittance) as the driver. If stills of - the video arrive, Hands can match the blur radius against them, but the - mechanism does not depend on it. -- The ritual ground's radii are `rem` lengths and its first gradient stop is - unpositioned (`custom.scss:124`); Hands normalises it when tokenising. -- Whether GameCult-Quartz's bundler permits a dynamic `import()` from a - component's `afterDOMLoaded` or needs a script tag; one line either way. -- `:root:has(body[data-slug])` for the ritual seeds: supported in every - current browser; a browser without `:has` gets the default seeds, which is - acceptable for a fallback of a fallback. - -## Pass 5: affine forms (ruling `affine-forms-unparked`) - -Imagination pass 5, 2026-10-03. It maps the affine-arithmetic piece of the -tape target, unparked on its own by ruling -`cultmath-tapes:ruling:affine-forms-unparked`. It answers follow-up -`cultmath-tapes:follow_up:wells-oracle-shortfall-affine-forms`. No tape, -pruning or interpreter is built; tape steps 2-5 stay parked under -`tape-target-unparks-when-asura-stable`. Pinned head: CultLib `main` at -`a7966142`. Every `file:line` in this section is against that commit. - -### What was measured (body facts) - -The probe is a renamed copy of `NoiseBoundTests.cs` with five more bounds for -`FogField`. It lives on the local branch `scratch/imagination-affine-probe` -(`5fa8e9ce`). That branch was never pushed to origin and is not for merging. -It was run on Yggdrasil through the ygg-verify stopgap (`dotnet/sdk:10.0`, -about 3 minutes). It re-runs `Run(FogField.Wells(w), 8, 64, 0x5A7E + 8)`, so -the tiles, rays and seeds are those of the landed (c) row at `N = 8`. V0 -reproduces the landed figures exactly (0.378 and 0.194). - -Constants the probe needed, each sampled over 2e5 seeded points with a 1.25 -margin (probe grade, not provenance): -- the Frobenius norm of the Hessian of `snoise(float3)`, max 55.15, so - `M = 68.94`; -- the gradient length of `snoise(float2)`, max 7.35, so `L2 = 9.19`; -- for comparison, the mean `|snoise_grad|` is 2.59, against `L = 10.10`. - -The bounds: -- **V0**: the landed bound. -- **V1**: V0 with the detail octave's ball no longer enlarged by the warp. The - detail reads the unwarped point (`NoiseBoundTests.cs:860`, `Noise.Detail(p, ...)` of the unwarped `p`), yet `Bound` - hands it `ball.w`, which carries `D` (`:875`, `:890`). -- **V2**: V1 with the warp centred. Each phase's coverage ball is centred at - `c + flow(c) shift_k`, with radius `r + |shift_k| rho`, where - `rho = FlowAmplitude L2 FlowFrequency r sqrt 2` bounds how far the flow moves - over the ball. This is the mean-value form of the warp: interval arithmetic - only, no affine noise. -- **V3**: V2 with the centred form of the noise, - `n(c) +- min(L R, |g(c)| R + M R^2 / 2)` from one `snoise_grad`. -- **V4**: V3 with a reduced affine form. Three shared symbols (depth `t`, - slopes `u` and `v`) carry the envelope's plane term and every noise term's - linear part, and one error symbol takes the rest. It applies where the fade - is the point 1, and is intersected with V3. -- **V5**: V4 with one shared symbol, depth `t`, plus one error symbol: - Gamito's `t0 + t1 e1 + t2 e2`. - -A gradient evaluation is counted as 2 snoise, an estimate. V3 to V5 gate a -probe on the best result any centre value and gradient could give. - -Range ceiling. A cell is range-nonempty if the density is positive at any of -5 x 5 slopes over the tile's slope square (corners included) times 9 depths -over the cell, or if it is in the oracle mask. Its efficiency is the oracle -march's cost over the cost of marching the range mask, with probes free. The -sampling can miss nonzero points, so this figure is an upper estimate. No -sound enclosure can beat it. - -| (c), `N = 8` | efficiency (oracle) | cost ratio | dense cells/ray | probe overhead | cull | -| --- | --- | --- | --- | --- | --- | -| warp 0, V0 landed interval | 0.378 | 2.74x | 12.40 | 0.961 | 0.952 | -| warp 0, V2 centred interval | 0.368 | 2.67x | 12.40 | 0.937 | 0.952 | -| warp 0, V3 centred noise | 0.466 | 3.38x | 8.67 | 0.868 | 0.974 | -| warp 0, V5 affine, one symbol | **0.511** | **3.71x** | 7.81 | 0.859 | 0.979 | -| warp 0, V4 affine, three symbols | 0.534 | 3.88x | 7.37 | 0.853 | 0.981 | -| warp 0, range ceiling | 0.859 | | | | 0.995 | -| warp 60, V0 landed interval | 0.194 | 1.39x | 31.55 | 0.993 | 0.842 | -| warp 60, V1 detail unwarped | 0.205 | 1.47x | 27.74 | 0.963 | 0.864 | -| warp 60, V2 centred interval | 0.347 | 2.49x | 13.71 | 0.938 | 0.945 | -| warp 60, V3 centred noise | 0.441 | 3.16x | 9.52 | 0.870 | 0.969 | -| warp 60, V5 affine, one symbol | **0.477** | **3.42x** | 8.71 | 0.864 | 0.974 | -| warp 60, V4 affine, three symbols | 0.502 | 3.60x | 8.16 | 0.856 | 0.977 | -| warp 60, range ceiling | 0.854 | | | | 0.995 | - -Every variant's transmittance equals the dense march's (max |dT| 0). No -variant's pre-pass proved a cell empty where any of the 225 samples per cell -was nonzero (0 enclosure violations). - -What this establishes: - -1. **The oracle cannot be reached by any sound bound.** The oracle mask - samples one depth per ray. A bound must cover the whole slice of the tile, - so the best any exact enclosure could do is about 0.86 of the oracle. That - matches the 0.57-0.85 that conservative visibility methods reach against - exact sets (`docs/research/culling-efficiency-oracle-prior-art.md`). An - oracle target of 0.90 is unreachable by construction. -2. **The warp diagnosis was half right.** At warp `D` most of the gap is the - warp enlarging the radius by its maximum (V0 to V2: 0.194 to 0.347). That - is fixed by evaluating the flow at the ball's centre and enlarging the - radius only by how far the flow can move across the ball. It takes no - affine noise, and it costs one more snoise per probe, for the second phase - ball. The detail octave's spurious warp (V1) is worth little on its own. -3. **Affine noise buys the rest:** the centred form, then the shared depth - symbol. Against the centred interval, affine with one symbol closes about a fifth - of the oracle gap at warp 0 and at warp `D` (efficiency 0.368 to 0.511 and - 0.347 to 0.477). Its combined cost ratio is 1.39x and 1.37x the centred - interval's, and 1.35x and 2.46x the landed interval's. It reaches 0.59 and - 0.56 of the range ceiling. -4. **Three symbols buy about 5% over one** (0.534 against 0.511, 0.502 - against 0.477). One symbol fits a `float3`. Three need a struct or a - `float4` plus a `float`, and the HLSL mirror's harness compares struct - returns but has no struct parameters (`packages/cultmath/docs/design.md:126-135`). -5. **The probe overhead falls** from 0.96 to 0.86 under every centred or - affine bound. Each probe costs a gradient and proves more, so the total - cost still drops by 1.35x to 2.46x. Today's (c) assertion, overhead at - least 0.90 (`NoiseBoundTests.cs:1558`, `:1588`), would reject the cheaper - march. That is question `affine-wells-contract`. - -### The model - -An affine form is a transient value, not a persistent kind. The persistent -things this pass adds or changes: - -| Thing | Identity | Lifecycle | Authority | -| --- | --- | --- | --- | -| `SNOISE_HESSIAN` (C#), `CULTMATH_SNOISE_HESSIAN` (HLSL, lowered to GLSL) | The constant's name; one value in `math.Affine.cs`, mirrored | Measured once by `NoiseBoundTests.MeasureHessian` (slow, explicit), as `SNOISE_LIPSCHITZ` is. It is re-measured and re-pinned whenever the `snoise` kernel changes. | `MeasureHessian` sets it; `HessianConstantPinsSampledCurvature` pins it; no consumer carries its own | -| `af_*` families in `fixtures/glsl-parity.json` | Family signature string, appended after the last existing family | Regenerated only by `CULTMATH_WRITE_GLSL=1`; earlier cases stay byte-identical | `GlslMirrorTests` generator | -| The (c) contracts | `IntervalSkipHalvesEvaluations` assertions | Changed only by a ruling | Operator (question `affine-wells-contract`) | -| `SNOISE2_LIPSCHITZ` (C#), mirrored in HLSL | The constant's name in `math.Interval.cs`, beside `SNOISE_LIPSCHITZ`, with an `iv_snoise_ball(float2, float)` overload | Measured by `MeasureLipschitz2` (slow, explicit) and pinned, as `L` is | CultMath. The (c) field's flow is `snoise(float2)`, and a bound on a CultMath function belongs to CultMath, not to a test-local helper. A consumer's own flow, such as the site's texture, keeps its own variation bound | - -### Representation - -**A reduced affine form with one shared symbol: `float3(x0, a, e)`, meaning -`x0 + a·ε + e·δ`.** Here `ε ∈ [-1, 1]` is shared by every form over the same -region, and `δ ∈ [-1, 1]` is a private error, with `e ≥ 0`. -- This is Messine's AF1 as Gamito and Maddock use it for gradient noise, - `t0 + t1 e1 + t2 e2`. -- Sharp and Jacobson's measurements show that this fixed-symbol form is the - fast one on GPUs: 1.0x against 8.4x for full affine. -- It fits one `float3` register, as an interval fits a `float2`. It needs no - struct parameter, so the mirror, lowering and fixture machinery take it - unchanged. -- V4 against V5 prices the two extra symbols at about 5% efficiency. - -For a tile probe `ε` is the depth parameter: `z = z_m + h ε` with -`h = (z1 - z0) / 2`. The footprint goes into the error. For a single ray it is -Gamito's form exactly. - -A point in space is not a new type. It is the three arguments -`(centre: float3, axis: float3, radius: float)`, the set -`{centre + axis ε + w : |w| ≤ radius}`. `af_snoise` and `af_fbm` take a point -in that form, and `af_frustum_axis` and `af_frustum_ball` produce one for a -tile slice. - -Ops, named by the (c) consumer, plus `af_mul` because affine arithmetic is -defined by its product, as `iv_mul` is for intervals: -- `af_point`, `af_symbol(x0, a)`, `af_from_iv`, `af_range` (the bridge to - `iv_*`); -- `af_add`, `af_sub`, `af_neg`, `af_scale`, `af_add_iv`, `af_mul`; -- `af_snoise`, `af_fbm`; -- `af_frustum_axis`, `af_frustum_ball`. - -No others until a consumer names one, which is the rule `design.md` already -states for intervals. - -The interval side gains `SNOISE2_LIPSCHITZ` and the overload -`iv_snoise_ball(float2, float)`. The (c) field's flow is `snoise(float2)`, and -centring the warp needs a bound on it, which belongs to its owner. - -`af_snoise(centre, axis, radius)` makes one `snoise_grad` call. With -`R = |axis| + radius`, it returns the narrower of two sound forms: -- the Lipschitz form `(n, 0, L R)`; -- the centred form `(n, g · axis, |g| radius + M R² / 2)`. - -`e` absorbs the op's own float rounding and an allowance for a GPU's gradient -error. The allowance is derived in the doc comment and measured on WebGL2 by -the fixture's enclosure check, as `iv_frustum_ball`'s is. - -The warp stays the consumer's, so CultMath owns no flow. The rule, stated in -`design.md` and tested for the (c) field: a warp whose value at the centre is -known, and whose variation over the ball is at most `ρ`, is enclosed by moving -the centre by `w(c)` and adding `ρ` to the radius. Interval balls benefit from -it too (V2). - -### Authority map - -- **Owner.** `src/CultMath/math.Affine.cs` owns affine-form semantics on the - CPU. `shaders/CultMath.Affine.hlsl` mirrors it bit for bit, and is the shader - semantic authority. `shaders/CultMath.glsl` is derived from the HLSL. -- **Inputs.** - - `snoise_grad`, whose `.w` is bit-equal to `snoise`; - - `SNOISE_LIPSCHITZ`; - - `SNOISE_HESSIAN`; - - the caller's forms and points. -- **Outputs.** `float3` forms, and `float2` intervals through `af_range`. -- **Derived state.** - - The GLSL text is generated by `GlslLowering`, unchanged. - - The fixture families are generated. - - The (c) efficiency rows are printed measurements, not state. -- **Forbidden writers.** - - A consumer linearising noise itself: the probe's V4 and V5 did this by - hand, and Hands must call `af_snoise`. - - A second curvature constant anywhere. - - Hand-edited `CultMath.glsl`. - - An affine or interval evaluator over `CultMath.Expr` (the parked tape's, - see collisions below). - - A flow or envelope function in CultMath. Consumers compose those, as for - intervals. -- **Shared paths.** The test field's `FogField`, the site ground and - Aetheria's nebula all reach affine noise through `af_snoise` or `af_fbm`, - and a tile slice through `af_frustum_*`. -- **Deletion line.** - - In `FogField.Bound` (`NoiseBoundTests.cs:875`), the warp-enlarged ball is - replaced by the centred warp, and the detail ball stops carrying the warp - (`:890`). - - The (c) probe-overhead assertion (`:1558`, `:1588`) is replaced as the - ruling on `affine-wells-contract` says. - - `design.md`'s "What they do not: ... affine forms" (`:584-587`) and "That - gap belongs to the tape target's affine forms" (`:623-624`) are rewritten. - - The tape target's open item on representation is closed. - -### Cut order - -1. **`affine-forms`, the one she can see.** - - It adds C# `math.Affine.cs` and `AffineTests`, plus `SNOISE_HESSIAN`'s - provenance. - - The (c) field gains the centred warp and the affine bound. - - (c) is re-measured with three bound rows on the same tiles: landed - interval, centred interval, affine. The range ceiling is printed beside - the oracle. - - An explicit, env-gated test writes a cull-map PNG of one (c) frame: dense - cells per ray for each bound, and the transmittance. Self publishes it. - - `design.md` is updated. - - It is blocked on `affine-wells-contract` only for the assertion's shape. -2. **`affine-shaders`.** - - It adds `CultMath.Affine.hlsl` and its Unity copy and `.meta`, the - include, and the regenerated `CultMath.glsl`. - - Fixture families are appended, with an enclosure check for `af_snoise` - and `af_frustum_ball`. - - The dxc and glslang compiles and the WebGL2 golden-fixture run happen on - Starfire. - - Both cuts share the branch `hands/cultmath-affine-forms` and merge - together after cut 2's Soul pass. Main never carries a C#-only `af_*`, so - three-runtimes-agree holds at every merged commit. - -Writing the C# before the HLSL inverts the usual order, because HLSL is the -semantic authority. The cost is small: the ops are plain arithmetic in the -common subset. Cut 2 changes the C# if the HLSL dialect forces something, -never the reverse. - -### Verification venue - -Heavy work runs on Yggdrasil through the stopgap: `dotnet test`, Stryker scoped -to `math.Affine.cs`, the (c) re-measure and the cull-map render. Starfire runs -only the Windows and GPU legs, one job at a time: -- `dxc -T lib_6_3 -HV 2021` on `CultMath.hlsl`; -- `glslangValidator` 16.6.0 on the lowered GLSL (ruling - `operator-compiler-downloads`); -- the WebGL2 golden-fixture run on the GTX 1070, under ANGLE D3D11 in a - browser. It is seeded from the glsl-lowering Soul pass's `gpu.js` - (follow-up `glsl-browser-parity-run`). - -### Collisions - -- **`cycles-converters` r1** edits the same seams: - - the include list (`CultMath.hlsl:509-510`); - - `HlslMirrorTests.cs:64-67`; - - `build-unity-package.ps1:82-87`; - - the fixture's family list. - - Whichever merges second rebases, regenerates `CultMath.glsl` and the fixture - (`CULTMATH_WRITE_GLSL=1`), and appends its families after the first's. - Nothing semantic collides. -- **`expr-ir` r1 and question `material-ir-in-cultmath`.** No file collides, - and neither cut waits on the other. - - Under `cultmath-ir-now`, the parked tape's step 2 will add interval and - affine evaluators over `ExprGraph`, and those will call `iv_*` and `af_*` - as op semantics. That is one more reason the affine ops are plain value - functions over `float3`, with no struct state. - - Under `aetheria-local`, nothing here changes. - - The `expr-ir` spec's negative check forbids `Interval(Evaluator)?` under - `Expr`. Self may add `Affine` to it at its next revision. -- **`site-ground` r3** (not dispatched): the void (e) and the site's flow - texture are not measured here. Follow-up `site-ground-affine-and-centred-warp` - carries both. Centring the warp in the site needs a bound on the flow - texture's variation, and the texture stays the one motion owner (it is - sampled at the centre, never re-derived). - -### Pass 5b: the deep well (ruling `wells-scale-order-of-magnitude`) - -The operator's words: "There should be a well pushing down with both a radius -and depth an order of magnitude larger than the span of the bit that's -expensive to sample, the fog gradient, otherwise there's no meaningful skipping -being measured". - -**Her diagnosis holds.** The expensive band is the stretch of the -pre-distortion height `s` where only the noise decides whether there is -density. -- `FogField` has `F = -20` and `A = 20`, and the noise reaches ±1.5. With the - fade at 1, a slice is provably empty only where `s >= F + 1.5 A = 10`. -- It is dense whatever the noise does where `s < F - 1.5 A = -50`. -- So the band is `G = 60` units. - -Today's (c) wells, from `NoiseBoundTests.cs:753-776`: -- **Depths** are `d = 30 M^0.175`: 67, 101, 150 and 101. That is 1.1 to 2.5 - times `G`. -- **Half-depth radii** are about `0.103 x 500 M^0.25` for a `PowerPulse` - exponent of 16: 163, 290, 515 and 290. That is 2.7 to 8.6 times `G`. -- **The zone bowl** is 64 deep, 1.07 times `G`. - -No well is ten times `G` deep. The camera sits just above the band -(`y = max(0, S + 10 - h)`) and grazes it, so most of the measured cost is the -band itself, and little of it is empty space. - -**The probe.** The probe added a field, `(c') deep well`, on the scratch -branch at `bf0148b8`: -- the zone bowl plus one well at its centre, with depth 600 and half-depth - radius 600 (`PowerPulse` exponent 2, scale 2220), so each is `10 G`; -- the camera's xz within 300 of the centre, at `y = F - h / 2`, halfway - between the sunken fog surface and the rim; -- slopes as (c), `m_y` in [-0.25, 0.1]. - -A level ray crosses about 600 units of empty well before the wall, and the -band there is about 73 units along the ray. The run used the same run -parameters, seeds and constants as Pass 5, on Yggdrasil. - -| `N = 8` | efficiency vs oracle | cost ratio | dense cells/ray | probe overhead | cull | -| --- | --- | --- | --- | --- | --- | -| deep well, warp 0, landed interval | 0.591 | 3.10x | 4.14 | 0.943 | 0.986 | -| deep well, warp 0, centred interval | 0.579 | 3.04x | 4.14 | 0.924 | 0.986 | -| deep well, warp 0, affine (one symbol) | **0.662** | **3.47x** | 3.27 | 0.879 | 0.993 | -| deep well, warp 0, range ceiling | 0.859 | (oracle ceiling 5.24x) | | | 0.997 | -| deep well, warp 60, landed interval | 0.462 | 2.45x | 6.58 | 0.970 | 0.967 | -| deep well, warp 60, centred interval | 0.555 | 2.95x | 4.34 | 0.926 | 0.984 | -| deep well, warp 60, affine (one symbol) | **0.644** | **3.42x** | 3.33 | 0.880 | 0.992 | -| deep well, warp 60, range ceiling | 0.848 | (oracle ceiling 5.31x) | | | 0.996 | - -There were no enclosure violations, and transmittance equals the dense march -in every row. - -What changes: -- Where the empty space is real, the interval march already skips most of it. - It reaches 0.59 at warp 0, and 0.46, or 0.56 with the warp centred, at warp - `D`. -- Affine's gain over the centred interval shrinks to 1.14x and 1.16x in - combined cost, against 1.39x and 1.37x on the band-dominated wells. -- Against the landed interval it is 1.12x and 1.40x. -- Affine reaches 0.77 and 0.76 of the range ceiling. What it wins is in the - wall's band, which is where the shallow wells spend everything. -- Probe overhead is 0.88 in both rows, still under the 0.90 rule. - -Decision for the cut (`affine-forms` r2): **(c) becomes the deep well, which -carries the contract.** The four mass-derived wells are kept as a printed row, -`(c-band)`. They are not the skipping measurement the ruling asks for, but they -are Aetheria's own geometry and the band-dominated case, where affine gains -most. Dropping them would hide where affine pays. The cull-map image renders a -deep-well camera at warp `D`. - -The contract question is re-asked against these numbers as -`cultmath-tapes:question:affine-wells-contract-r2`. The first question was -withdrawn in its favour, and `affine-forms` r2 supersedes r1. - -## Pass 6: the snoise diagonal tie (finding `snoise-diagonal-tie-discontinuity`) - -Soul's affine pass found that `snoise(float3)` and `snoise_grad` jump by up to -0.72 where the three components of `x0` compare equal -(`cultmath-tapes:finding:cut-affine-forms.s1.snoise-diagonal-tie-discontinuity`). -The defect predates every cut in this campaign. It came with the Ashima kernel -and survived the 0.3.0 kernel change. The cut is -`cultmath-tapes:cut_spec:cut-snoise-tie.r1`. - -### Mechanism (probed) - -`g = step(x0.yzx, x0.xyz)` makes three pairwise comparisons, all non-strict: x -wins its tie with y, y wins its tie with z, and z wins its tie with x. That is a -cycle, not an order. When all three components are equal, `g = (1,1,1)`, so -`i1 = (0,0,0)` and `i2 = (1,1,1)`, and the four corners are not a simplex. - -- Corner 1 is then the origin vertex again, with the offset `x0 + 1/6`. Near a - lattice vertex that offset is short (`|x1|^2 = 1/12`), so the origin's - gradient is counted a second time. -- The tie set is the union of the lattice diagonals `v + s(1,1,1)`. It has - measure zero in space, but consumers sample it. Every point `(t, t, t)` lies - on it exactly in float32, for every `t`, because the three components are - computed identically. So does the origin: `snoise(0,0,0)` returns -0.4358730, - where the correct value is 0. `HlslSemanticsTests.cs:447` pins the wrong - value as golden. A consumer that samples `snoise(float3(t))` or - `cultmath_snoise(t.xxx)` reads a different function along the whole line. -- With the 0.5 kernel, a lattice vertex outside the four summed corners never - contributes on a face, because its squared distance from the face is at - least 0.5. So any total order of the three comparisons gives the same exact - value on every tie. The fix only has to make the comparisons an order; which - order it picks does not matter. - -### Prior art - -- Gustavson's reference C, `simplexnoise1234.c`, picks the 3D simplex with an - if-chain on `x0>=y0`, `y0>=z0` and `x0>=z0` and their complements. Ties go x - over y, y over z and x over z: a total order. -- Gustavson and McEwan's later `psrdnoise3.glsl` (JCGT 2022) replaces Ashima's - line with `step(f0.xyx, f0.yzz)` and a re-pairing. Its comment says ties - resolve "in priority order": also a total order, z over y over x. -- Upstream `webgl-noise` `noise3D.glsl` still has the cyclic `step`. Soul found - no fix in its issues or its git history (`log -S` on the line). - -**The fix** makes one comparison strict, z against x: -`g = (step(x0.y, x0.x), step(x0.z, x0.y), 1 - step(x0.z, x0.x))`. Ties then go -x over y, y over z and x over z, which is exactly `simplexnoise1234`'s order. -The probe's double-precision reference uses that if-chain verbatim, and the -patched float kernel agrees with it to within float noise. - -Other total orders are equivalent mutants: one strict compare placed on x, or -two strict compares. Only two spellings are degenerate, all-strict and today's -all-non-strict, and the cut's test kills both. - -### What the probes measured - -Both jobs ran on Yggdrasil, on main `a7966142` and on the affine head -`4ae986a5`. Each patched C# and both HLSL copies in the container, and -regenerated GLSL and the fixture. - -| Probe | Old rule | Strict-z rule | -| --- | --- | --- | -| Random points, \|p\| <= 4, 256, 4096 (1e6 each): old and new bit-equal | | 1e6 of 1e6 at every scale | -| Random points, \|p\| <= 65536 (1e6) | | 23 differ, each on an exact z = x tie, at ulp level | -| Lattice-diagonal points and their +-2 ulp neighbourhoods, \|I\| <= 8, 64, 512, 4096 (500k each, about 10.5k exact triple ties each): max \|f32 - ref64\| | 0.772, 0.768, 0.775, 0.774 | 2.9e-6, 2.2e-5, 1.8e-4, 1.6e-3 (float32 at that magnitude) | -| Pairwise faces x0 = (a,a,b) and permutations (108k), \|I\| <= 8 / 512 | 2.5e-6 / 1.3e-4 | the same | -| Jump inside a 1e-4 ball at Soul's five witnesses | 0.21 to 0.72 | 0.0016 to 0.0018 (smooth bound 7.6 x 2 sqrt3 x 1e-4 = 0.0026) | -| Soul's vertex scan, worst jump, \|L\| <= 8, 32, 128 | 0.72, 0.65, 0.65 | 3.7e-4, 1.5e-3, 5.7e-3; 0 of 400 beyond the smooth bound at every scale | -| `af_snoise` around the old Lipschitz spike (2000 forms x 21 points) | 926 misses, worst 38 e | 0 misses, worst -0.72 e | -| `MeasureLipschitz` (seed 0x11B5) | refined 9.181147, L = 10.099261 | refined 7.2400064, x 1.10 = **7.9640074**, witness (229.92526, 73.37927, -66.14595) | -| `MeasureHessian` (affine head) | 50.954895, giving 56.050385 | unchanged, same witness | -| `snoise_grad(p).w == snoise(p)` in a 1e-4 ball about the old witness | | 0 mismatches | - -The full suite passes once four things change together: the tie fix, `L` -re-pinned, the witness moved, and the origin golden set to 0. It passes -288 of 288 on main and 300 of 300 on the affine head. - -With only the tie fix and nothing re-pinned, exactly two tests fail: - -- `LipschitzConstantPinsSampledGradients`, the ratio pin, failing as - designed; -- the origin golden. - -`HlslSourceCompatibilityTests` passes. Its special values include all-equal -triples, so it pins the HLSL tie rule bit for bit against C#. - -Fixture bytes: - -- The tie fix alone changes no fixture case. The 256 random points per family - never land on a tie. -- Re-pinning `L` changes 41 cases, all in `iv_snoise_ball(vec3)` and - `iv_fbm_ball`. These are the cases whose bound is not clamped to `[-1, 1]`. -- Every other family is byte-identical. -- `CultMath.glsl` changes 3 lines: the two tie lines and the constant. - -### What follows - -- **`SNOISE_LIPSCHITZ` narrows by 21%,** from 10.099261 to 7.9640074. Every - Lipschitz-form bound narrows with it: `iv_snoise_ball`, `iv_fbm_ball`, the - Lipschitz form inside `af_snoise`, and the march's skipping. - - The (c) rows in Passes 5 and 5b were measured at the old `L`. They are - conservative, not wrong. The affine branch re-measures them after it - merges main. - - `SNOISE_HESSIAN` does not move. -- **Release.** `math.snoise` returns different values on the tie set, which - includes the origin and every `(t, t, t)`, points ordinary consumers sample. - - The precedent is `asura:ruling:qn1-snoise-upstream`: a public snoise value - change ships as a minor bump while the package is below 1.0, filed under - Breaking. So the next `cultmath-unity` release after this cut is 0.4.0, - not 0.3.x. - - The intervals and `L` were never released (`cultmath-unity-v0.3.0` - predates `math.Interval.cs`), so re-pinning `L` is not a release change. - - The release is not part of this cut. Follow-up - `cultmath-tapes:follow_up:snoise-tie-release` carries it, together with - Aetheria's pin bump to that release. -- **Consumers.** - - gamecult-site vendors no CultMath GLSL yet, because `site-ground` has not - landed. It gets the fixed GLSL when it does. - - Aetheria pins 0.2.4, the old 0.6 kernel, which has the same cyclic `step` - line. Its pin bump (`asura:follow_up:aetheria-snoise-pin-bump`) should - target the release that carries this cut. - - No other runtime under `packages/` (Rust, TS, Python) carries snoise. - -### Merge order - -1. `snoise-tie` branches from main `a7966142` as - `hands/cultmath-snoise-tie`. It gets its own Soul gate and merges to main - first: it is small, independent, and fixes a defect in released code. Its - two fixture families go after `phacelle`. -2. `hands/cultmath-affine-forms` then merges main with a merge commit. It never - rebases, because the branch is shared. The job's edits to - `math.Interval.cs`, `NoiseBoundTests.cs` and `design.md` applied cleanly to - the affine head. The affine fix batch's (c) re-measure and the affine Soul - pass run on the merged tree, so they see the new `L`. -3. `affine-shaders` is revised to r2, which supersedes r1. It depends on - `snoise-tie` and starts from the merged tree, so its `af_*` families are - appended after the tie families, and its device enclosure checks run on the - fixed `cultmath_snoise_grad`. Nothing else in it changes. - -## As built: the affine and tie cuts on main (Modeling, 2026-10-04) - -Body map against CultLib `main` at `14568bf9`, after `48aadda0` (snoise tie) -and `156782da` (affine forms, merged as `hands/cultmath-affine-forms`). It -records what the Body is, not what Passes 5, 5b and 6 intended. Where it -disagrees with those passes, this section wins; where it disagrees with the -Body, the Body wins. Cut reports live in the eureka-state mind under -`cultmath-tapes`: `cut-snoise-tie.h2`, `cut-affine-forms.h1-h3`, -`cut-affine-shaders.h1-h3`. - -### Pieces and owners - -Paths are under `packages/cultmath/`. - -| Piece | Path | Owner | Role | -| --- | --- | --- | --- | -| Snoise kernel | `src/CultMath/math.cs` (`snoise`, `snoise_grad`) | library, C# | Ties in `x0` break in Gustavson order (x over y, y over z, x over z), a total order. Mirrored in `shaders/CultMath.hlsl` and the Unity copy. | -| Lipschitz constant | `math.Interval.cs` `SNOISE_LIPSCHITZ = 7.9640074f`; `CultMath.Interval.hlsl`; generated GLSL | library | Derived from the kernel by `NoiseBoundTests.MeasureLipschitz` (seed 0x11B5): refined 7.2400064 x 1.10. A kernel change re-pins it. | -| Hessian constant | `math.Affine.cs` `SNOISE_HESSIAN = 56.050385f` | library | Unchanged by the tie cut. Provenance in `design.md` "Affine forms". | -| Affine ops | `math.Affine.cs`: `af_point`, `af_symbol`, `af_from_iv`, `af_range`, `af_add`, `af_sub`, `af_neg`, `af_scale`, `af_add_iv`, `af_mul`, `af_snoise`, `af_fbm`, `af_frustum_axis`, `af_frustum_ball`; plus 2D `iv_snoise_ball(float2, float)` in `math.Interval.cs` | library, C# | Plain value functions over `float3` (centre, coefficient of the one shared symbol, radius of the independent remainder). No struct state, no `Expr` coupling. | -| Affine HLSL | `shaders/CultMath.Affine.hlsl`, byte-identical `unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl` | library | `cultmath_`-prefixed bit-for-bit mirror of `math.Affine.cs`. | -| GLSL | `shaders/CultMath.glsl` (and `CultMath.Phacelle.glsl`) | derived | Generated by `GlslLowering` (test project) from the HLSL files. | -| Fixture | `tests/CultMath.Tests/fixtures/glsl-parity.json` | derived | Generated by `GlslMirrorTests.GoldenFixtureMatchesCSharp`. Families: the earlier ones, the tie families (after `phacelle`), `iv_snoise_ball` for vec3 and vec2, every `af_*`, and small-reach `af_snoise` and `af_fbm` families that exercise the centred branch. | -| Test harness | `tests/CultMath.Tests/AffineTests.cs`, `NoiseBoundTests.cs`, `GlslMirrorTests.cs`, `HlslMirrorTests.cs`, `NoiseGradTests.cs` | test project | `FogField` (with `DeepWell`, `Wells`, `InsideFog`, `AetheriaWarp`), `NoiseArg`, `AffineSlice`, `BoundMode` and the gates live here, not in the library. They stand in for the site ground and Aetheria. | -| Explicit measurements | `NoiseBoundTests` `[Fact(Explicit = true)]` facts: the (c) rows and `DeepWellCullMap` (PNG into the directory named by `CULTMATH_WRITE_CULLMAP`) | test project | Printed measurements, not state. Their numbers are copied into `design.md` by hand. | - -### Inputs and outputs - -- `af_snoise(centre, axis, radius)` takes the noise argument as a centre, the - direction of the one shared symbol and a ball radius. It reads `snoise_grad` - (`.w` equals `snoise` bitwise), `SNOISE_LIPSCHITZ` and `SNOISE_HESSIAN`, and - returns a `float3` form: the Lipschitz form or the centred Taylor form, - whichever is narrower (`design.md` "Affine forms"). `af_fbm` composes it per - octave. `af_range` turns a form into a `float2` interval and finds a NaN - endpoint by bit pattern, because dxc's fast-math compare folds `x != x`. -- `af_frustum_axis` and `af_frustum_ball` build the symbol and ball for a tile - slice of the view frustum. A consumer rotates and translates the centre into - world space and scales by its frequencies. -- Interval consumers keep `iv_*`; the two representations meet at `af_from_iv` - and `af_range`. - -### Derived state and forbidden writers - -- `CultMath.glsl`, `CultMath.Phacelle.glsl` and `glsl-parity.json` are never - hand-edited. The only writer is `CULTMATH_WRITE_GLSL=1 dotnet test --filter - GlslMirrorTests` from `packages/cultmath/tests/CultMath.Tests`. The tests - compare committed text with the lowering and committed families with C#'s - current output, so a hand edit fails them. -- `unity/.../Shaders/CultMath*.hlsl` is a copy. - `HlslMirrorTests.UnityPackageShaderIsIdenticalToTheCanonicalShader` pins byte - identity per file (`Interval` and `Affine` among them). Edit `shaders/` only. -- `SNOISE_LIPSCHITZ` is written in three places (C#, Interval HLSL, generated - GLSL) and re-pinned only by running `MeasureLipschitz`. `SNOISE_HESSIAN` has - one definition in C# and one in `CultMath.Affine.hlsl`. -- Forbidden: a consumer linearising noise itself, a second curvature constant, - an evaluator over `CultMath.Expr`, a flow or envelope function in CultMath. -- Shared paths a cut touches: the include list in `CultMath.hlsl`, - `HlslMirrorTests` InlineData, `scripts/build-unity-package.ps1`'s file list, - and the fixture's family list. A cut that adds families appends after the - previous cut's and regenerates. - -### The mirror chain - -C# (`math.cs`, `math.Interval.cs`, `math.Affine.cs`) -> HLSL (`shaders/`, Unity -copy byte-identical) -> GLSL ES 3.00 (generated by `GlslLowering`) -> fixture -(generated from C#). A change starts in C#; the HLSL follows bit for bit; the -GLSL and fixture are regenerated. `HlslMirrorTests` sweeps C# against the HLSL -semantics on the CPU, including `af_snoise`'s centred branch on both sides of -the choice. The tie fix landed in C#, `CultMath.hlsl`, the Unity copy and the -regenerated GLSL in one merge. - -### Verification layer - -- Yggdrasil (CPU, through the stopgap): `dotnet test` of `CultMath.Tests` - (mirror, GLSL golden-fixture comparison, `AffineTests`, the `NoiseBoundTests` - gates, `NoiseGradTests.SnoiseIsContinuousOnTheSimplexDiagonal`), Stryker - scoped to `math.Affine.cs`, and the explicit (c) and deep-well re-measures. -- Starfire (Windows and GPU, one job at a time): `tools/compile-glsl.ps1` - (glslangValidator), the dxc `lib_6_3 -HV 2021` compile of the HLSL, and the - WebGL2 golden-fixture run on the GTX 1070 under ANGLE D3D11. The device run - checks `af_snoise`, `af_fbm` and `af_frustum_ball` for enclosure against the - device's own noise (`design.md`, GLSL target). The device runner is not in the - repository. Follow-up `affine-device-runner-seed` carries it; until it lands - the device leg is a Starfire-local procedure, not a repeatable test, and - `glsl-browser-parity-run` stays open. - -### Release state - -- `unity/org.gamecult.cultmath/package.json` is 0.3.0 and `CHANGELOG.md` has no - unreleased section. The snoise value change on the tie set (the origin and - every `(t, t, t)`) is Breaking by the `qn1-snoise-upstream` precedent, so the - next release is 0.4.0. Follow-up `snoise-tie-release` carries the version - bump, the changelog entry (Breaking: snoise; Added: `iv_*`, `af_*`, the two - HLSL files and the GLSL library) and Aetheria's pin bump. -- Aetheria pins 0.2.4 (the 0.6 kernel with the cyclic `step`). gamecult-site - vendors no CultMath GLSL yet. -- `SNOISE_LIPSCHITZ` and the intervals were never released, so re-pinning `L` - is not itself a release event. - -### Stale docs and state found (not edited) - -- This file's header status line says "pass 4" and pins `c49c76ee`; Pass 5's - pin is `a7966142`. Neither is the as-built head. -- The (d) row near line 529 ("ceiling at `L = 10.099261`") and Pass 5's "`L = - 10.10`" (near line 1037) are measurements at the old `L`, now 7.9640074. Pass 6 - says they are conservative; the numbers are not re-printed. -- Pass 5 "Cut order" reads as future work and Pass 6 "Merge order" lists the - merge as pending. Both merged. Pass 5's deletion line cites - `NoiseBoundTests.cs` line numbers that have moved. -- `docs/cultmath-tape-target.md`: the header "Status: **parked**" (line 3) and - "The operator parked (c)" (line 54) say nothing of affine; only the "Open - before unparking" item (lines 109-112) records that affine forms were - unparked, and nothing records them as built. The interval-or-affine - representation question is closed: both exist. Tape steps 2-5 remain parked. -- `docs/cultmath-interval-ground-cut-interval-ops*.spec.json` (r1-r3) pin - `SNOISE_LIPSCHITZ` "untouched" and cite 10.099261 as provenance. They are spec - history, superseded by the constant in `math.Interval.cs`. -- `unity/org.gamecult.cultmath/CHANGELOG.md` has no entry for the tie change, - intervals or affine forms. -- The `0.77` in `packages/cultmath/docs/design.md:376` and `NoiseGradTests.cs:195` - is the upstream tie jump and is accurate; it is a different 0.77 from the - range-ceiling ratio at line 1347 of this file. diff --git a/docs/cultmath-tape-target.md b/docs/cultmath-tape-target.md deleted file mode 100644 index 6b8810fb..00000000 --- a/docs/cultmath-tape-target.md +++ /dev/null @@ -1,119 +0,0 @@ -# CultMath tapes: interval-pruned field evaluation on CPU and GPU - -Status: steps 2-5 (tape, pruning, HLSL interpreter, meshing) are **parked** -(2026-10-02; ruling tape-target-unparks-when-asura-stable). The affine-forms -piece was unparked on 2026-10-03 (ruling affine-forms-unparked) and is on main -(156782da), alongside step 1's intervals; its map and as-built record are in -`docs/cultmath-interval-ground-cut.md`. This note records the direction for the -parked steps so they can be picked up without re-deriving it. - -## Intent - -Evaluate large implicit fields, meaning deeply nested CSG trees of brushes with -thousands of nodes, cheaply enough to mesh at many levels of detail and to -raymarch. The operator's words (2026-10-02): "I would love to design a space -station out of a grammar of nested brushes, and have the ability to -automatically mesh it at multiple levels of detail so I can get arbitrarily -close to its tiny details without melting my GPU." - -GameCult has no deep CSG trees today because nothing could evaluate them -cheaply. The capability comes first, and the content follows. - -## Prior art - -[Fidget](https://www.mattkeeter.com/projects/fidget/) by Matt Keeter -(MPL-2.0, Rust, v0.5.1 on 2026-09-27; repo `mkeeter/fidget`). -- It compiles an expression to a register-allocated bytecode tape. -- It evaluates that tape as points, SIMD batches, intervals, and forward-mode - gradients. -- The central trick is interval evaluation over a region. When it proves that - one operand of a `min` or `max` always wins, the tape for that region is - rewritten without the other branch. In the project's example, the tape - shrinks from 254 clauses to about 20 at pixel level. -- `fidget-jit` targets x86-64 and AArch64. -- `fidget-wgpu` has a WGSL tape interpreter, interval ops and tape - simplification on the GPU (`interval_ops.wgsl`, `tape_interpreter.wgsl`, - `tape_simplify.wgsl`). -- `fidget-mesh` implements Manifold Dual Contouring. It is known to be weak on - thin features. -- Halfspace is the IDE codesigned with `fidget-wgpu` (Rust, egui and wgpu, - MPL-2.0). - -## Chosen shape (option c) - -The ideas are ported into CultLib and owned here. Fidget is not a dependency. -Unity renders HLSL on its own graphics backend, so `fidget-wgpu` cannot run -inside it. - -Three options were weighed on 2026-10-02: - -| Option | What it is | Trade | -|---|---|---| -| a | Fidget as a Rust native plugin in Unity | Fastest demo; costs per-platform native builds, an FFI boundary, and an upstream that warns of breaking changes | -| b | Offline bake with a Rust tool; ship meshes | Simplest; the baked depth caps how close a viewer can get | -| c | CultLib owns tape, interval and pruning in C# and HLSL | Most coherent end state; the largest code liability we would own | - -The operator parked (c). An (a) spike to validate authoring and LOD behaviour -before owning code was suggested but not ruled. - -Sketch, to be replaced by the target pass: - -1. **CultMath `interval`** in C# and HLSL with parity tests: - - arithmetic, `min`/`max`, `smin`, `sqrt`, `clamp` and `smoothstep`; - - interval or Lipschitz bounds for every CultMath noise primitive. - - This step needs no tape. It stands alone, and is the first cut to take even - if the rest stays parked. -2. **Tape**: an expression graph lowered to bytecode, with point, interval and - gradient evaluators in C#. Gradients reuse CultMath's analytic-gradient - primitives, which Asura cut 2a built. -3. **Pruning**: per-region tape simplification driven by interval results. -4. **HLSL interpreter** for the same bytecode, with interval ops and pruning. - Fidget's MPL-2.0 WGSL is the reference. MPL code keeps its own MPL-headed - files, as Phacelle does. -5. **Meshing**: an octree of chunks with seams stitched between LOD levels. - - The default is surface nets (GameCult.Geometry, Asura Cut 2) plus - Asura's tile pass: Newton refinement onto `f = 0`, then crease snapping - from field gradients (Asura Cut 6c). - - The operator's lean (2026-10-02) is that gradient work beats dual - contouring here. Thin authored bevels can be shaded by their analytic - normals, and the refined positions can be iterated further. - - Dual contouring is not planned. The tile pass on station brushes is its - test. - -## Truth and lowerings - -The field is data: a typed CultCache document holding the expanded tree. A -generator, such as a brush grammar, expands into that document, and everything -downstream caches it. The CPU evaluator, the HLSL interpreter, the mesher and -collision are all lowerings of that one document. This is how "one -implementation of the field" survives having both CPU and GPU evaluators. -Asura's invariant 2 had to forbid CPU evaluation because its field is HLSL -source. - -## Known consumers - -- **Aetheria volumetric raymarching** (clouds, nebulae). Step 1 alone gives it - empty-space skipping. Coverage and shape terms carry the culling, because - detail octaves only bound to ±amplitude. - - Prerequisite: Aetheria's shaders must use CultMath noise, not their own - copies. That is already owed at Aetheria's CultMath pin bump (see the Asura - cut map, snoise release follow-ups). -- **Space stations from a brush grammar**, meshed in LOD chunks around the - camera. This is a separate project with its own target. This campaign - supplies its evaluator. -- Asura does not need this campaign. Its field is noise-dominated, and its - `A_max` shell and band-limiting already give the cheap culling. - -## Open before unparking - -- Run the (a) spike first, or go straight to (c)? -- Pick the interval representation (plain intervals or affine arithmetic) and - the noise bound strategy. - Affine forms for noise and warp were unparked on 2026-10-03 (ruling - `cultmath-tapes:ruling:affine-forms-unparked`): one shared symbol, mapped in - `docs/cultmath-interval-ground-cut.md`, "Pass 5". -- Choose the bytecode register model for the HLSL interpreter, given GPU - register pressure. -- Decide whether the brush-grammar station project lives in Aetheria or in - its own repo. diff --git a/docs/cultnet-error-contract-cut.md b/docs/cultnet-error-contract-cut.md deleted file mode 100644 index ca43b5fe..00000000 --- a/docs/cultnet-error-contract-cut.md +++ /dev/null @@ -1,663 +0,0 @@ -# CultNet error contract: cut map - -Status: cut map, not started. Imagination pass 1, 2026-09-30, against CultLib `main` at `8fc74c70`. -This document owns the means. There is no separate target doc: section 1 holds the ends until the -operator rules on section 3. After that, Self moves the rulings and invariants into -`contracts/cultnet/cultnet-distributed-database.md` ("Error Codes") and the schema's own description. - -Open: operator questions Q1-Q8 (section 3). No cut is dispatched until Q1, Q2, Q3 and Q8 are ruled. Q4-Q7 -change only single emit sites and can be ruled during Cut 1. - -Depends on: `hands/cultmesh-put-serve-bound` merging first. It introduces `document_unservable` in Python -(`fd394d54`), a codeless unservable refusal in cultmesh-ts (`0eb7434a`) and `CultMeshRudpRejectionReason` in -cultmesh-rs (`c9cdad12`, `85288a5a`). The cuts below convert those sites. Their anchors are by commit, not by -line, because the branch is not on main. - -Found by the put-serve Hands (batch 3, `38000efa`, 2026-09-30); they belong to this map's cuts: -- **Python codes outside the closed code list.** Python refuses with `document_unservable`, - `malformed_document_put` and `snapshot_*_exceeded`. None of these are in the closed `cultnet.error.v0` code - list, and Rust and TS peers refuse to decode an unknown code. -- **Two error-map shapes.** TS sends a two-key error map that its own peers cannot parse. Rust sends the five-key - contract shape. The two agree only at the message level. -- **The session after a refusal.** TS and Python keep the session open after a refusal; Rust sends a goodbye and - ends it. -- **New Rust refusal frame.** The put-serve branch adds a Rust refusal frame, `cultnet.error.v0` carrying the - reason text with no code and no details, sent before the goodbye and acknowledging nothing. Cut 1 gives it a - code. -- Found by the put-serve Soul (merge verdict, 2026-09-30): - - A store `OSError(ENOSPC)` in Python is refused as `malformed_document_put`, with the text "Raw put document could - not be stored." That is a server fault reported as the peer's fault. - - Over RUDP, Python's `document_unservable` details add `fragmentCount` and `maxFragmentCount`, and send - `maxSnapshotBytes: null` when it is unbounded. The map specifies `{responseBytes, maxSnapshotBytes}`. - - `response_unqueueable` (Python, P3) is a new code outside the closed list. - - A TS peer cannot tell "stored, receipt lost" from "refused" (put-serve Soul F4, pass 3). - -Map branch: `main`. - ---- - -## 0. What the Body does today (probed) - -Every claim in this table was established by running code. The C#, Rust and TypeScript probes ran on -Yggdrasil through `ygg-verify.sh` at `8fc74c70`. The Python bytes came from `msgpack.packb` on the exact -dicts `cultmesh_py/server.py:573-589` and `cultmesh-ts/src/index.ts:5921-5926` build. The six probe inputs: - -| Input | Bytes from | -|---|---| -| `cs_cursor_stale` | Rust `tests/error_message.rs` captured C# hex (`cursor_stale`, details `{asOf:1,current:2}`) | -| `cs_routing` | C# `new CultNetErrorMessage { Error, RoutingHint = { Reason="not_primary", Shard=... } }` serialized with `CultNetSchemaMessageSerialization` | -| `cs_codeless` | C# `new CultNetErrorMessage { Error = "boom" }` | -| `cs_unknown_code` | C# with `Code = "document_unservable"`, empty `CultNetErrorDetails` | -| `py_snapshot_byte_limit` | the Python `_error_response` shape: `messageId`, `code: "snapshot_byte_limit_exceeded"`, `details {responseBytes, maxSnapshotBytes}` | -| `ts_two_key` | the cultmesh-ts shape `{schemaVersion, error}` | - -Decoded by: - -| Input | C# `CultNetSchemaMessageSerialization.Deserialize` | Rust `decode_cultnet_message_from_slice` | TS `parseCultNetMessage` | -|---|---|---|---| -| `cs_cursor_stale` | ok | ok, typed | ok | -| `cs_routing` | ok | ok, **routingHint dropped** (`code: None, details: None`) | ok (untyped passthrough) | -| `cs_codeless` | ok | ok | ok | -| `cs_unknown_code` | ok (free string) | **Err: "not a recognized cultnet.error.v0 code"** | **throws: /code must be one of the allowed values** | -| `py_snapshot_byte_limit` | ok, but **details silently become an all-null object** (`responseBytes`, `maxSnapshotBytes` lost), `messageId` dropped | **Err: not a recognized code** | **throws** (missing routingHint, extra messageId, code enum, details keys) | -| `ts_two_key` | ok | ok | **throws: missing routingHint, code, details** — TypeScript cannot parse the errors TypeScript sends | - -Captured C# bytes for the two shapes Rust's vector file does not hold (for Hands' reuse): - -- `cs_codeless`: `85AD736368656D6156657273696F6EB063756C746E65742E6572726F722E7630A56572726F72A4626F6F6DAB726F7574696E6748696E74C0A4636F6465C0A764657461696C73C0` -- `cs_routing`: see the probe; the shard descriptor writes ten keys, nil included. - -Other findings, from reading source at `8fc74c70`: - -1. **The interop CI lane has been red for 40 consecutive `main` runs.** It fails at "Verify CultNet schema - contracts stayed consolidated" (`.github/workflows/cultnet-interop.yml:67-90`). That step forbids every - `*.schema.json` outside `contracts/cultnet/`, and R-AB deliberately vendors 22 copies into - `packages/cultnet-rs/contracts/cultnet/`. Those copies are held byte-equal by - `packages/cultnet-rs/tests/schema_discovery_contracts.rs:74-99`. Nothing after that step (every - cross-runtime interop test) has run on main in that time. Run `36714768445` is the latest. -2. **The schema contradicts itself.** `contracts/cultnet/cultnet.error.schema.json:29` says the code is - "Additive: a v0 peer that does not know this field ignores it" and, in the same sentence, "a closed - enum: Rust and TypeScript refuse". The closed-enum text came from Soul pass 4d (`3f942a57`). It - described what the code did; no operator ruled it. `docs/` holds no ruling on unknown codes. -3. **Emitters that break the schema:** - - cultmesh-ts sends `{schemaVersion, error}` only, at `packages/cultmesh-ts/src/index.ts:5875-5878`, - `5885-5888`, `5913-5916` and `5922-5925`, and on the branch at `0eb7434a`. - - cultmesh-py `_error_response` (`packages/cultmesh-py/src/cultmesh_py/server.py:573-589`) adds a - top-level `messageId`, omits `routingHint`, omits `code` and `details` rather than sending nil, and - sends eight out-of-enum codes: `unsupported_schema_version` (`:161`), `malformed_document_put` - (`:358`), `unregistered_document_put` (`:365`), `malformed_document_delete` (`:386`), - `unregistered_document_delete` (`:393`), `snapshot_document_limit_exceeded` (`:558`), - `snapshot_byte_limit_exceeded` (`:567`) and `simulation_observations_disabled` (`:596`). The branch - adds a ninth, `document_unservable` (`fd394d54`). - - `packages/cultnet-py/src/cultnet_py/interop_peer.py:409-417` also sends `unsupported_schema_version`. - R-2 (`docs/cultnet-selection-cut.md:2046-2053`) required that code, but it never entered the schema - enum. -4. **A second schema authority.** `packages/cultnet-py/src/cultnet_py/schema_catalog.py:17`, `:272` and - `:357-362` publish a hand-built `cultnet.error.v0` descriptor under the canonical `$id`. It has a - different shape: `messageId`, `code` as any string, `details` open, and only `schemaVersion` and `error` - required. The same file does this for every wire message (about 350 lines). This is recorded as - follow-up F-1, not cut here. -5. **Silent refusals.** cultmesh-rs's RUDP document server returns every rejection to the local caller only - (`packages/cultmesh-rs/src/rudp_document_server.rs:470-590`, `CultMeshRudpApplicationRejection`). The - peer gets nothing and times out. On the branch this includes the new `DocumentUnservable`. -6. **Receivers drop the code.** - - Every C# receiver turns an error into `new IOException(error.Error)` or - `new InvalidOperationException(error.Error)`, so a caller cannot branch on the code. The sites: - `src/GameCult.Mesh/CultMeshBodySessions.cs:310`, `CultMeshContentSessions.cs:178/256-260`, - `CultMeshPeerExchange.cs:430/466`, `CultMeshSnapshots.cs:91/107/222-226/743` and - `CultMeshVerseDiscovery.cs:273`, plus `src/GameCult.Networking/CultNetShardReplication.cs:440/574`. - - Rust reads `Error { error, .. }` at `packages/cultmesh-rs/src/lib.rs:823`. - - TS types `CultNetErrorMessage` as `{schemaVersion, error}` only (`packages/cultnet-ts/src/contracts.ts:167-170`). - - Kotlin has no error type. A request that gets an error back fails a - `require(response.schemaVersion == ...)` (`packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt:1278`, - `:1334`), and the peer's text is lost. -7. **No correlation.** Only Python echoes `messageId`. - - `cultmesh-browser` rejects an error only when exactly one operation is pending - (`packages/cultmesh-browser/src/index.ts:724-731`); otherwise the error is dropped and the operation - times out. - - C# `CultMeshContentSessions.OnError` (`:256-260`) fails every pending request on any error. -8. **The reference is inconsistent with itself.** `src/GameCult.Networking/CultNetDatabaseServer.cs:560` - refuses a variant change with a codeless error. The subscription server refuses the same condition with - `ForVariantUnsupported` (`CultNetDatabaseSubscriptionServer.cs:211/333/366`). -9. **routingHint is never consumed.** No receiver in any runtime reads it. C# builds it at - `CultNetDatabaseServer.cs:638-650`, and Rust's decode discards it. -10. **Consumer audit** (read-only, all of `F:\Projects` except CultLib; no git in Aetheria): - - Outside CultLib, nothing sets `code`, `details` or `routingHint`, and nothing branches on a code. - - Emitters: - - Huginn: `crates/huginn-daemon/src/serve.rs:288/307/312`, Rust struct literals - `Error { error, code: None, details: None }`, pinned at cultnet-rs `8fc74c70`. - - AetheriaEve: `Aetheria.State.Daemon/Program.cs:1737/1778`, C# object initializers. - - Decoders read `.error` only: Gjallar `Program.cs:574`, Mimir - `MimirOdinMoveProofEvidenceRingProvider.cs:80`, Hermodr `hermodr-daemon.cjs:1380` (hand-rolled), - AetheriaEve's smoke test (text match against its own emit text), and Huginn's tests (text match). - - Stale vendored TS: - - `StreamPixels/vendor/CultLib` carries the current closed schema, so any change here breaks its - TS error decode until it is re-vendored. - - `Heimdall/vendor/CultLib` carries a pre-R-X schema with `additionalProperties:false` and no - `routingHint`, so it already refuses every error C# sends today. - - Odin, Idunn, Muninn, Ghostlight and voidbot: zero hits. - -## 1. Ends - -- **One schema.** `contracts/cultnet/cultnet.error.schema.json` is the only authority on the shape and on the - code registry. C# embeds it (`GameCult.Networking.csproj:19`), TS mirrors it at build time, and Rust - vendors a copy held byte-equal by test. Nothing else publishes a `cultnet.error.v0` shape (F-1 covers - Python). -- **Every runtime emits only schema-valid errors.** This is proven per emit path against the schema, and - byte-equal to the C# reference for every registry code. -- **Every runtime decodes every error it can receive into a typed value.** A known code becomes its typed - variant with its typed details. An unknown code, if Q1 says so, becomes a typed "other" that keeps the - code string and the raw details. No well-formed error is ever refused, and no field is silently dropped - (routingHint, messageId). -- **Code and details have one owner.** The details a message carries are decided by its code. The types in - every runtime make "cursor_stale with a field" unrepresentable. No free-standing code string plus a - grab-bag details object. -- **A refusal is an answer, not a silence** (R-2 precedent, and Q4). A server that refuses a peer's request, - and can still send, sends a coded error that correlates to the request. -- **The public surface is complete in every runtime**, per the consumer-expectation doctrine: - - a typed error value; - - a constructor per registry code; - - a typed exception or error that request APIs raise when the peer refuses, carrying the typed value. - -## 2. Identity, lifecycle and authority - -| Kind | What names it | Lifecycle | Who decides | -|---|---|---|---| -| Error message | `schemaVersion: cultnet.error.v0`; correlated to its request by `messageId` (Q3) | Sent once, in reply to one request or subscription. Never persisted. | The server that refused. | -| Error code | A snake_case string in the schema's registry (`$defs/knownCode`) | Added by one coordinated change: schema, C# constructor, a C#-written vector, and a typed variant in every runtime. Never renamed and never reused. A retired code stays in the registry marked retired, so an old reader still decodes it. | The operator rules meaning; Self keeps the registry. | -| Details for a code | The code | Frozen with the code. Adding a key to an existing code's details is a new code (or a v1), never an in-place edit (see Q2). | Same as the code. | -| Unknown code, at a reader | The raw string | Preserved as typed `Other`. The reader acts on the `error` text and the absence of a known code. | The reader (Q1). | -| Vector file | `contracts/cultnet/interop/error-vectors.cs-written.json` | Regenerated only by the C# writer test under `CULTNET_WRITE_VECTORS=1` and committed. Every other runtime judges it read-only. | C#, the reference. | -| routingHint | Shard authority refusal | Sent with a null code (unchanged). Typed in every decoder. | CultNetDatabaseServer's authority path. | - -## 3. Operator questions - -**Rulings (operator, 2026-09-30):** "Q1: B / Q2: B / Q3: A / Q8: A". -- **Q1:** closed for emitters, open for readers. An unknown code decodes to a typed `Other`. -- **Q2:** per-code details. -- **Q3:** a nullable top-level `messageId`. -- **Q8:** v0 is corrected in place, with the semver bumps the policy requires. -- Q4-Q7 are still open. -- Cut 1 waits for `hands/cultmesh-put-serve-bound` to merge. - -### Q1. What does a reader do with an error code it does not know? - -Today Rust and TypeScript refuse the whole message. The probes above show the result: the peer's error text -is lost and the caller sees "not a recognized code". In cultmesh-rs's snapshot client the `?` at `lib.rs:812-815` -even turns a peer refusal into a local decode failure. So under a closed enum every new code breaks every -reader that has not upgraded. By `docs/semver-policy.md:86-91` that makes each new code a breaking wire -change, and nine codes are already in flight. - -- **A. Closed enum (today).** Readers refuse unknown codes. Every code addition is a coordinated, - semver-major wire change across all runtimes and consumers. -- **B. Closed for emitters, open for readers.** The schema keeps the registry, and every runtime's emit - constructors can produce only registry codes (tests prove each emit path valid against the schema). - Readers decode an unrecognized code (matching `^[a-z][a-z0-9_]*$`) into a typed `Other { code, details }`. - A new code is an additive, minor change: old readers still surface the text and know "an error I cannot - classify". This is how gRPC status codes and protobuf open enums behave. -- **C. Fully open.** No registry; any string, emit and decode. - -**Recommended: B.** A refusal must never fail to arrive because it is more specific than the reader -expected. B keeps the registry as the single meaning authority. C loses the meaning authority, and A makes -the error channel the most brittle message in CultNet. - -Depends on this: schema `code` shape, every decoder, the doc text at `cultnet-distributed-database.md:107-115`. - -### Q2. How are details shaped on the wire? - -Today C# writes all four detail keys (`field`, `value`, `asOf`, `current`), nil included, because -`CultNetErrorDetails` (`CultNetSchemaMessages.cs:592-603`) is a MessagePack map-mode object. The codes in -flight need new keys: `responseBytes`, `maxSnapshotBytes`, `documentCount`, `maxSnapshotDocuments` and -`schemaVersion`. - -- **A. One shared details record; grow it.** Every detail key of every code sits on one record, written as - nil when unused. Each new key changes the bytes of every existing error that has details, so all of the - C# vectors must be recaptured on every addition. It also breaks every strict reader: TS Ajv, and - StreamPixels' vendored schema, have `additionalProperties:false`. And the type cannot tie a key to its - code. -- **B. Per-code details.** `details` carries exactly the keys its code defines. A defined-but-optional key - is present as nil; another code's keys are absent. Keys are named for their meaning, which retires the - `field: "schemaId"` / `field: "subscriptionId"` indirection that exists only because the record is - shared. Adding a code never changes an existing code's bytes. In every runtime, code and details are - fused into one tagged type: - - Rust: an enum with data. - - C#: sealed subclasses, with a custom formatter for `CultNetErrorMessage`. There is precedent in - `src/GameCult.Mesh/CultMeshRouteRecordFormatter.cs`. - - TS: a discriminated union. - - Kotlin: a sealed class. - - Python: constructors per code over a frozen dataclass. - - The churn is one time. The five existing C# cases with details change bytes, and all eight Rust hex - cases move into the shared vector file anyway (Cut 1). -- **C. Opaque string map.** Untyped; no runtime can offer a typed accessor. - -**Recommended: B.** A is the churn the brief warned of, and it recurs on every future code. B pays it once, -at the moment every vector is being recaptured regardless. - -Depends on this: the schema's `details`, the C# model and formatter, `encode_error_details` -(`packages/cultnet-rs/src/contracts.rs:1339-1366`), and every decoder. - -### Q3. Does an error carry the `messageId` of the request it refuses? - -Python already sends `messageId` (`server.py:583`); the schema forbids it. Without it: - -- `cultmesh-browser` drops an error whenever two operations are pending (`index.ts:724-731`); -- C# content sessions fail every pending request on any error (`CultMeshContentSessions.cs:256-260`). - -Adding a top-level key changes the bytes of every C# error. That happens once, in the same recapture as Q2. - -- **A.** Add a nullable top-level `messageId`. A reply to a request echoes the request's id, and an error - with no request (a subscription push, an unsolicited refusal) sends nil. Receivers correlate by it and - fall back to their current behavior when it is nil. -- **B.** No correlation. Python deletes the field. - -**Recommended: A.** Correlation is a capability any multiplexing client needs, and one runtime already -depends on it. - -### Q4. Do servers send `document_unservable` (and every other refusal they can) to the peer? - -Self ruled that "unservable" must be distinguishable as a typed code in every runtime. On the branch: -Python sends it coded, TypeScript sends it codeless, and Rust tells only its local caller, so the Rust -peer times out. The same Rust silence covers every other document-server rejection: a sink refusal, a -failed snapshot source, too many snapshot documents, and a snapshot response that is too large. - -- **A.** Every refusal of a peer's request that the server can still send is answered with a coded error - carrying the request's `messageId`, and is also reported locally (Rust's `ApplicationRejected` stays as - the local report). The refusals that cannot be answered are the ones where the answer itself cannot be - queued: Rust `PayloadBudgetFull` and `ResponseQueueFailed`. Those stay local-only, and the doc says so. -- **B.** Local-only in Rust; peer replies only where a runtime already sends them. - -**Recommended: A.** R-2 already ruled that a silence is worse than a missing feature -(`docs/cultnet-selection-cut.md:2049-2053`), and the operator's ruling that CultMesh "refuses" puts only -means something to the party that sent the put. - -### Q5. Does Python's `unregistered_document_put` / `unregistered_document_delete` become `unowned_schema`? - -Python sends these when the node has no registered document type for the record's schemaId -(`cultmesh_py/node.py:653-666`). C# `unowned_schema` means "no shard owns this schema and key" -(`CultNetSchemaMessages.cs:537-544`). To a peer both mean "this server will not take that schema here; route -elsewhere". The put and delete variants duplicate what the peer already knows (it sent the message). - -- **A.** Both collapse into `unowned_schema { schemaId }`. The registry text broadens to "this server - stores no document for that schema (and key)". -- **B.** Join as a separate `schema_unregistered { schemaId }`. -- **C.** Join both codes as they are. - -**Recommended: A.** It is one meaning at the peer, and there is one action to take. - -### Q6. Does Python's `malformed_document_put` / `malformed_document_delete` become one `message_invalid { field }`? - -These are sent when the request lacks a required field (`server.py:355-359`, `383-387`). C# has the same -condition, codeless, at `CultNetDatabaseServer.cs:373/415` and `CultNetDatabaseSubscriptionServer.cs:148` -("requires a subscriptionId or messageId"). - -- **A.** One `message_invalid { field }`, naming the missing or ill-typed field. It is used by Python's four - sites and C#'s three. -- **B.** Join both per-message codes and leave C# codeless. - -**Recommended: A.** The per-message suffix repeats the request's own schemaVersion, and C# gains a code for -free. - -### Q7. Does `simulation_observations_disabled` become `unsupported_schema_version`? - -Python sends it when the observation hub is off (`server.py:593-598`), with -`details { schemaVersion: "cultnet.simulation_observation.v0" }`, which is exactly the -`unsupported_schema_version` shape. cultmesh-ts's "no cache for snapshot requests" and "no operation -handler" refusals (`index.ts:5875`, `5913`) mean the same thing: this server does not serve that message. - -- **A.** Collapse. `unsupported_schema_version` means "this server does not serve messages of this - schemaVersion: unknown, a newer version, or not enabled here". The three TS sites and Huginn's "answers - only X, Y, Z" adopt it. -- **B.** Keep a separate `feature_disabled`-style code. - -**Recommended: A.** A peer cannot act differently on "not enabled" and "not known". Python's -`verify.py:335` check follows the rename. - -### Q8. Is this a correction of `cultnet.error.v0` in place, or a new `cultnet.error.v1`? - -Under Q2-B and Q3-A, strict v0 readers (TS Ajv and vendored copies) refuse the new bytes. Tolerant readers -(C#, Rust, Python) keep working, because the probes show they ignore unknown keys and treat a missing key -as null. - -- **A. In place.** The v0 contract has never been decodable across all five runtimes (section 0). No - consumer outside CultLib reads code or details (finding 10). Every publishing package takes the semver - bump its policy requires: - - `org.gamecult.cultlib` major, because the public `CultNetErrorDetails` properties change; - - `cultnet-py` and `cultmesh-py` major, because emitted codes change; - - Rust pins move deliberately. - - StreamPixels and Heimdall re-vendor. -- **B. v1.** Add `cultnet.error.v1`, keep v0 emit for peers that did not advertise v1 in hello, and run - two error encoders in every runtime until v0 retires. - -**Recommended: A.** B builds a version-negotiation path for a message nobody outside CultLib parses beyond -`.error`. The one thing every old reader does need, the `error` text, survives A in every tolerant runtime. - -## 4. The registry (as recommended; rewrite on each ruling) - -| Code | Meaning | Details (per Q2-B; `?` = present-as-nil when absent) | Emitted by after this map | -|---|---|---|---| -| `selection_invalid` | A selection field failed the door. | `{ field, value? }` | C#, Rust (selection) | -| `cursor_stale` | The cursor predates the server's retained history. | `{ asOf, current }` | C#, Rust | -| `cursor_invalid` | The cursor could not be parsed. | none (details nil) | C#, Rust | -| `reference_outside_target` | A hop reference left the declared target. | none | C#, Rust | -| `variant_unsupported` | The selection selects a document variant CultNet does not carry. | `{ subscriptionId? }` | C# (incl. `DatabaseServer.cs:560`) | -| `unowned_schema` | This server stores no document for that schema (and key). | `{ schemaId }` | C#, Python (Q5) | -| `unsupported_schema_version` | This server does not serve messages of this schemaVersion. | `{ schemaVersion }` | Python, TS, Huginn (Q7) | -| `message_invalid` | The request lacks a required field or has an ill-typed one. | `{ field }` | C#, Python (Q6) | -| `snapshot_document_limit_exceeded` | The snapshot answer would exceed the document bound. | `{ documentCount, maxSnapshotDocuments }` | Python, Rust (Q4) | -| `snapshot_byte_limit_exceeded` | The snapshot answer would exceed the byte bound. | `{ responseBytes, maxSnapshotBytes }` | Python, Rust (Q4) | -| `document_unservable` | A put was refused because no snapshot could ever return the stored document under the byte bound. | `{ responseBytes, maxSnapshotBytes }` | Python, TS, Rust (Q4) | - -A null code is legal and means "unclassified". Examples: an exception message from a failed snapshot -source, an authority refusal carrying `routingHint`, and "not authorized" -(`CultNetDatabaseSubscriptionServer.cs:165`). This map does not invent codes for those. - -`snapshot_byte_limit_exceeded` and `document_unservable` have identical details. That is deliberate, and it -is the fixture trap named in the verification rules. - ---- - -## 5. Cuts - -All cuts are made on one campaign branch, `hands/error-contract`, from `main` after -`hands/cultmesh-put-serve-bound` merges. The branch merges to `main` once, after Cut 5's Soul pass. The -reason: Cut 1 changes C# bytes, and Rust's static hex cases would stay green against the stale bytes -(finding: `tests/error_message.rs` pins constants, not the reference). A partial merge would ship a -wire split while every suite passed. Each cut gets its own worktree, created by Self. Heavy verification -runs through `ygg-verify.sh`, never on Starfire. - -### Cut 0. Unblock the interop lane - -- **Repo/branch:** CultLib, `hands/interop-guard` from `main`, merged alone ahead of the campaign. It - does not depend on the rulings. -- **Deletes first:** nothing. -- **Per-file changes:** `.github/workflows/cultnet-interop.yml:72`. The `$stray` filter also accepts - `^packages/cultnet-rs/contracts/cultnet/`, with a comment naming R-AB and - `packages/cultnet-rs/tests/schema_discovery_contracts.rs:74-99` as the equality guard. The namespace - check is unchanged. -- **Authority map:** no ownership change. The canonical owner stays `contracts/cultnet/`, and the Rust - mirror is derived from it, with drift judged by the Rust test. -- **Verification:** - - Push the branch and run the workflow. Report every step that goes red after the guard. None of those - steps has run on main for 40 runs, so expect more red, and treat each failure as its own finding; - do not fix it in this cut. - - Negative: edit one byte of a vendored copy locally and check that the Rust equality test fails. - Reach it on Yggdrasil with `cd packages/cultnet-rs && cargo test --test schema_discovery_contracts`. -- **Ledger:** +3 lines. - -### Cut 1. The contract and the C# reference - -- **Repo/branch:** CultLib `hands/error-contract`, worktree named by Self. -- **First:** capture the current C# bytes for all eight factory cases, plus `cs_codeless` and `cs_routing`, - into the Hands report. This is the before-image a Soul pass compares against. -- **Deletes first:** - - `CultNetErrorDetails` (`src/GameCult.Networking/CultNetSchemaMessages.cs:588-603`, 16 lines) as a - shared record. - - The `field`/`value`/`asOf`/`current` property block and the `[MessagePackObject]`/`[Key]` attributes - on `CultNetErrorMessage` (`:497-521`). Its serialization moves to one formatter. - - `SoulP4dProbeTests.Wire_UnownedSchemaBytes` (`tests/GameCult.Networking.Tests/SoulP4dProbeTests.cs:191-199`). - It is an `[Explicit]` hex printer, superseded by the vector writer. - - The closed-enum paragraph at `contracts/cultnet/cultnet-distributed-database.md:107-115` and - the `code`/`details` descriptions in the schema (`:28-42`). -- **Adds:** - - **Schema** (`contracts/cultnet/cultnet.error.schema.json`, rewritten; the Rust mirror is re-copied - byte-equal): - - Top level: `schemaVersion`, `error` and `routingHint` as today, plus `messageId: string|null` (Q3) - and `code`. All five are required, present-as-nil (R-X is unchanged at the top level). - - `$defs/knownCode` is the registry enum from section 4. - - `code` is `null`, or a string matching `^[a-z][a-z0-9_]*$` (Q1-B). - - `details` is decided by a top-level `oneOf`, one branch per known code, each fixing `code` by - `const` and `details` by exact `properties`/`required`/`additionalProperties:false`. Two more - branches: a null code with null details, and an unknown code (`not: {$ref knownCode}`) with details - `object|null`, open. - - Use `oneOf`/`not`/`const` only. `tests/GameCult.Networking.Tests/MiniJsonSchemaValidator.cs:30-35` - implements those and **not** `if`/`then`/`allOf`, and it refuses unimplemented keywords. TS - compiles with Ajv2020 (`packages/cultnet-ts/src/contracts.ts:1,674`), which handles both. - - **C# model** (`GameCult.Networking`): - - `CultNetErrorMessage { SchemaVersion, Error, MessageId?, RoutingHint?, Refusal? }`, where - `Code => Refusal?.Code` is derived and not settable. - - `abstract CultNetRefusal { string Code }`, with one sealed subclass per registry code carrying its - typed details (`CultNetCursorStaleRefusal(ulong AsOf, ulong Current)` and so on), plus - `CultNetUnknownRefusal(string Code, IReadOnlyDictionary? Details)` for Q1-B. - - `CultNetErrorCodes`: string constants, one per registry code. - - `CultNetErrorMessageFormatter : IMessagePackFormatter`. It writes the five - top-level keys in order (schemaVersion, error, messageId, routingHint, code, details), and details - as exactly the refusal's keys. It reads by key name, tolerates unknown keys at both levels, and - maps an unknown code to `CultNetUnknownRefusal`. Register it through `[MessagePackFormatter]` on - the type, the way `CultMeshRouteRecordFormatter` is wired. - - Factories: keep `ForSelectionInvalid`, `ForCursor`, `ForReferenceOutsideTarget`, - `ForVariantUnsupported` and `ForUnownedSchema` as thin constructors over the refusal types, and add - one per new code. Each takes an optional `messageId`. - - `CultNetPeerErrorException : IOException`, carrying the `CultNetErrorMessage`. - - **Vector writer:** `ErrorVectorTests.WriteErrorVectors`, gated on `CULTNET_WRITE_VECTORS=1` like - `SelectionParityVectorTests.cs:460-552`. It writes `contracts/cultnet/interop/error-vectors.cs-written.json`: - one entry per registry code (both optional-key states where a key is optional), `cs_codeless`, - `cs_routing`, one unknown code with open details, and one error with `messageId` set. Each entry - holds `{ name, messagePackBase64, expected: { error, messageId, code, details, routingHint } }`, - where `expected` is a JSON projection every runtime compares its typed decode against. -- **Per-file changes** (`8fc74c70`): - - `CultNetDatabaseServer.cs:560`: `ForVariantUnsupported(refusal.Message, subscriptionId)`. - - `CultNetDatabaseServer.cs:373`, `:415` and `CultNetDatabaseSubscriptionServer.cs:148` become - `message_invalid { field: "subscriptionId" }` (Q6-A). - - Every `SendCultNet(CultNetErrorMessage...)` that answers a request passes the request's `MessageId`. - - Each receiver listed in finding 6 throws `new CultNetPeerErrorException(error)` instead of - wrapping `error.Error`. `CultMeshContentSessions.OnError` (`:256-260`) fails only the pending entry - whose id matches `error.MessageId`, and falls back to all entries only when the id is nil. - - `CultNetSchemaContractTests.cs:165-214`: the per-factory tests are replaced by one test that validates - every vector's decoded JSON against the schema with `MiniJsonSchemaValidator`, and one test that - serializes each registry factory and asserts byte equality with its committed vector. - - Rewrite `contracts/cultnet/cultnet-distributed-database.md` "Error Codes" to the registry, and state - the Q1 and Q2 rules. -- **Authority map:** - - Owner: the schema's registry owns code meaning and detail shape. `CultNetErrorMessageFormatter` owns - C# bytes. The refusal subclass owns the code-to-details binding. - - Inputs: the refusal instance, messageId, routingHint. - - Outputs: bytes, and `cs-written.json` for the other runtimes. - - Derived state: `CultNetErrorMessage.Code` becomes derived; the refusal decides it. - - Forbidden writers: any `Code = "..."` assignment (it cannot compile); `[Key]` attribute serialization - of the message; hand-typed hex anywhere. - - Shared paths: every server send uses the factories; every receiver uses `CultNetPeerErrorException`. - - Deletion line: `CultNetErrorDetails` and the settable `Code`. -- **Verification** (`dotnet` image): - - Builds: `tests/GameCult.Networking.Tests`, `tests/GameCult.Mesh.Tests`. - - `ErrorVectorTests` with `CULTNET_WRITE_VECTORS=1`, then without, and check that the committed file - reproduces byte-for-byte. - - Tests and the rules they pin: - - vector round trip: bytes, decode, bytes are equal for every entry; - - a registry factory is byte-equal to its vector; - - every vector validates against the schema; - - an unknown code decodes to `CultNetUnknownRefusal` with its raw details intact; - - a Python-shaped error (`py_snapshot_byte_limit` above, with the Q2/Q3 shape) decodes typed with - `responseBytes` and `maxSnapshotBytes` intact. Today's C# silently empties those. - - content-session correlation: two pending requests, an error for the second, and the first still - completes. - - Mutation: Stryker.NET on the formatter and factories. The survivors that must die: - - swapping two known codes whose details are identical (`snapshot_byte_limit_exceeded` and - `document_unservable`); - - padding a nil key into details; - - dropping `messageId` on encode; - - mapping an unknown code to null. - - Negative greps (checked at HEAD, where they hit the sites being cut): - - `git grep -nE 'new (IOException|InvalidOperationException)\(error\.Error\)' -- src` must return 0 - (9 hits at HEAD). - - `git grep -nE 'Field = "(schemaId|subscriptionId)"' -- src` must return 0 (2 at HEAD). - - Operator: none. -- **Ledger:** about -60 C# (the details record, the settable code, the probe printer, and the per-factory - schema tests), +250 (the formatter, the refusal types, the vector writer). The schema grows by about 90 - JSON lines. The net is positive, bought by Q1/Q2 typing in the reference. - -### Cut 2. Rust: cultnet-rs and cultmesh-rs - -- **Deletes first:** - - `CultNetErrorCode` and `CultNetErrorDetails` as separate types (`packages/cultnet-rs/src/contracts.rs:252-310`, - 59 lines); - - `require_error_details` (`:1121-1146`); - - `encode_error_details` (`:1339-1366`); - - the eight hex `Case`s and the header comment in `packages/cultnet-rs/tests/error_message.rs:1-160`. - That file is rewritten to read the vector file. - - Keep `require_legacy_optional_u64` (`:1149`). Check with `git grep` for other callers first; at HEAD, - only the error details use it. -- **Adds:** - - `CultNetMessage::Error { error: String, message_id: Option, routing_hint: Option, refusal: Option }`. - - `enum CultNetRefusal`, with one variant per registry code and its typed fields, plus - `Other { code: String, details: Option }`. - - `CultNetRefusal::code(&self) -> &str`. - - A constructor `CultNetMessage::error(text)` and builder-style `with_refusal` / `with_message_id`, so - consumers stop writing struct literals. Huginn has three. - - Decode reads every top-level key by name and routes unknown codes to `Other` (Q1-B). - - Encode writes the Cut 1 key order. - - `CultNetShardRoutingHint` is typed, reusing the crate's existing shard descriptor type. -- **Per-file changes:** - - `packages/cultnet-rs/src/contracts.rs:361-368` (variant), `:1097-1115` (decode), `:1300-1336` (encode). - - `packages/cultnet-rs/src/selection.rs:1210-1255`: the four refusals build `CultNetRefusal` variants. - - `packages/cultnet-rs/src/content.rs:316`: uses `CultNetMessage::error`. - - `packages/cultmesh-rs/src/lib.rs:812-827`: a peer error becomes a typed error carrying the refusal, - instead of `anyhow!` text. Name it `CultMeshPeerError`, next to the crate's existing error types. - - `packages/cultmesh-rs/src/rudp_document_server.rs` (Q4-A): each `CultMeshRudpRejectionReason` that - can be answered sends the matching coded error, correlated by the request's message id, before - returning `ApplicationRejected`. `PayloadBudgetFull` and `ResponseQueueFailed` stay local. -- **Authority map:** - - Owner: `CultNetRefusal` owns code and details. The schema owns the registry. - - Forbidden writers: string codes (`from_wire_str` survives only inside decode); struct literals of - details. - - Shared paths: selection refusals, document-server refusals and content errors all go through the one - encoder. -- **Verification** (`rust` image, `cd packages/cultnet-rs` then `cd ../cultmesh-rs`): - - `cargo test --workspace`. - - `tests/error_message.rs` pins: every vector decodes to `expected`; encoding the decoded value - reproduces the vector's bytes; the unknown-code vector decodes to `Other`; the routing vector keeps - `routing_hint`. - - cultmesh-rs: a put over the bound makes the peer receive `document_unservable` with the request's - message id, and details equal to the computed size and the bound. Run it at two bounds so that a - constant or an offset in `maxSnapshotBytes` dies. - - A peer that sends a Python-shaped `snapshot_byte_limit_exceeded` produces a `CultMeshPeerError`, not - a decode failure. - - Mutation: `cargo mutants --in-diff` on the cut's diff. Triage every survivor by name. - - Negative: `git grep -n 'CultNetErrorDetails' -- packages` must return 0. -- **Consumer note:** Huginn's `serve.rs:288/307/312` and its tests stop compiling at the next pin bump. - The migration is mechanical (`CultNetMessage::error(...)`), and `:312` adopts `unsupported_schema_version` - (Q7). Self routes it as a Huginn change; it is not part of this branch. - -### Cut 3. TypeScript: cultnet-ts, cultmesh-ts and cultmesh-browser - -- **Deletes first:** - - the two-field `CultNetErrorMessage` interface (`packages/cultnet-ts/src/contracts.ts:167-170`); - - the four literal error constructions in `packages/cultmesh-ts/src/index.ts:5875-5878`, `5885-5888`, - `5913-5916` and `5922-5925`, and the branch's codeless unservable site (`0eb7434a`); - - `rejectCorrelated`'s single-pending heuristic (`packages/cultmesh-browser/src/index.ts:724-731`). -- **Adds:** - - `CultNetErrorMessage` with every field. - - `type CultNetRefusal` as a discriminated union on `code`, with an `{ code: string; details: Record | null; known: false }` arm. - - `createCultNetError(text, { messageId, refusal })` as the only constructor. - - `class CultNetPeerError extends Error { message: CultNetErrorMessage }`. - - `parseCultNetMessage` keeps Ajv validation against the canonical schema; it now accepts every schema - branch, including unknown codes. -- **Per-file changes:** - - cultmesh-ts: the three "does not serve this" sites (`5875`, `5913`, `5922`) send - `unsupported_schema_version` (Q7-A); the snapshot catch (`5885`) sends a null code; the unservable site - sends `document_unservable` with details. - - cultmesh-ts `6527-6529` throws `CultNetPeerError`. - - cultmesh-browser `163`, `584` and `690`: correlate by `messageId`, falling back to today's behavior only - for a nil id. - - `packages/cultnet-ts/src/idunn-odin-presence-publisher.ts:118-120` throws `CultNetPeerError`. - - The legacy `gamecult.networking.v0` path (`contracts.ts:840-844`, `:899-900`) is unchanged. That is a - separate legacy contract. -- **Verification** (`kotlin` image, which carries Node 24; `npm install`, then build cultcache-ts before - cultnet-ts): - - A new `test/error-vectors.test.ts` pins that every vector parses and deep-equals `expected`, and that - `encode(createCultNetError(...))` is byte-equal to each registry vector. - - The cultmesh-ts document-server tests assert that each refusal parses with TypeScript's own - `parseCultNetMessage`. That is the probe's `ts_two_key` failure, pinned. - - Browser: two pending operations, an error for the second, and the first still resolves. - - Mutation: StrykerJS on the diff. - - Negative: `git grep -nE 'schemaVersion: "cultnet\.error\.v0",' -- packages/cultmesh-ts/src packages/cultmesh-browser/src` - must return 0. Exclude `cultnet-ts/src/schema-discovery.ts:302` (a descriptor) and - `contracts.ts:842` (legacy decode); both are legitimate hits for the unscoped pattern. - -### Cut 4. Python: cultnet-py and cultmesh-py - -- **Deletes first:** - - `_error_response` (`packages/cultmesh-py/src/cultmesh_py/server.py:573-589`); - - `unsupported_schema_version_error` (`packages/cultnet-py/src/cultnet_py/interop_peer.py:409-417`); - - every string literal code in `server.py` (lines in finding 3). -- **Adds:** - - `cultnet_py/errors.py`, holding: - - `CultNetErrorCode(StrEnum)`, the registry; - - a frozen `CultNetError` dataclass (`error`, `message_id`, `routing_hint`, `code: CultNetErrorCode | str | None`, - `details: Mapping | None`); - - one constructor function per code, taking exactly that code's keys; - - `to_wire()`, which writes the five top-level keys in the Cut 1 order, nil included; - - `parse_cultnet_error(dict)`. - - `CultNetPeerError` (`client.py:46-50`) keeps `.response` and gains `.error: CultNetError`. -- **Per-file changes:** - - Sites `server.py:158-163`, `355-394`, `555-569` and `593-598` and the branch's `document_unservable` - site use the constructors, with the Q5-A/Q6-A/Q7-A codes. - - `interop_peer.py` uses the constructor. - - `verify.py:335` reads `error.error.code`. - - Tests `packages/cultmesh-py/tests/test_cultmesh.py:2088`, `3791`, `4323` and `4363-4371`, and - `packages/cultnet-py/tests/test_cultnet.py:2342`, follow the renames. -- **Verification** (the image the campaign already uses for Python; state it in the report): - - A vector test pins that every vector parses to `expected` and that each constructor's `msgpack.packb` - is byte-equal to its vector. - - Mutation: mutmut on `errors.py` and the changed server sites. - - Negative: `git grep -nE '"schemaVersion": "cultnet\.error\.v0"' -- packages/cultnet-py/src packages/cultmesh-py/src` - returns only `errors.py`. -- **Not here:** F-1 (`schema_catalog.py` publishes its own shapes). - -### Cut 5. Kotlin: cultmesh-kotlin - -- **Adds:** - - A `CultNetErrorMessage` data class and a `sealed class CultNetRefusal` (known codes plus `Other`), - with a `CultNetMessage.asError(): CultNetErrorMessage?` view. - - `class CultNetPeerException(val error: CultNetErrorMessage) : IOException`. - - At `CultMesh.kt:1278` and `:1334`, and at every `receiveSchemaMessage` consumer that expects a - response, an error response throws `CultNetPeerException` before the `require`. -- **Verification** (`kotlin` image, `pwsh -File build.ps1`): - - A vector test pins that every vector decodes to `expected`. - - Kotlin emits no errors today, so encode parity applies only if a Kotlin server path is added. Say - so in the report; do not invent one. - - There is no mutation tool. Behavioural tests cover it: an error reply to a schema-catalog request - raises `CultNetPeerException` carrying the code. - -### Cut 6. Merge, release, consumers - -- Soul runs over the whole branch before the merge: - - rerun every vector suite; - - decode each runtime's live emissions with every other runtime. The interop lane from Cut 0 is the - harness; add an error round to `tests/GameCult.Networking.InteropPeer` and - `packages/cultnet-ts/test/interop` if Soul finds a runtime pair unreached. -- Release per `docs/semver-policy.md`, with a Soul pass before tags: - - `org.gamecult.cultlib` major, and the tracked Unity DLLs rebuilt, since they embed the schema; - - `cultnet-py` and `cultmesh-py` major. -- Consumers, routed by Self as separate repo changes: - - Huginn: pin bump plus Cut 2's note. - - StreamPixels and Heimdall: re-vendor. Heimdall is already broken by R-X. - - AetheriaEve, Gjallar and Mimir compile against the live CultLib path and read only `.Error`, so they - need no change. That is inferred from the audit; the next build of each confirms it. - - Hermodr: none. - -## 6. Subtraction ledger - -| Cut | Removed (estimate) | Added (estimate) | Formats / targets | -|---|---|---|---| -| 0 | 0 | 3 | none | -| 1 | ~60 C#, schema text | ~250 C#, ~90 schema | + `error-vectors.cs-written.json`; - `[Explicit]` hex printer | -| 2 | ~150 (types, two helpers, 160-line hex test) | ~200 | hex constants gone; vectors read from file | -| 3 | ~40 | ~120 | none | -| 4 | ~40 | ~120 (`errors.py`) | 8 ad-hoc codes → registry | -| 5 | 0 | ~80 | none | - -The net is positive, by roughly 500 lines, across five runtimes. It buys typed decode where there was -none (Kotlin, TS and Python), a correlation capability, and one vector file in place of hand-copied hex. -The pressure point: if Cut 1's formatter passes 150 lines, report it rather than trimming typing. - -## 7. Follow-ups outside this map - -- **F-1.** `packages/cultnet-py/src/cultnet_py/schema_catalog.py` publishes about 350 lines of hand-built - schemas under canonical `$id`s. Python should package and serve `contracts/cultnet/*.schema.json`, the - way Rust vendors them. It is a separate cut, because it covers every message, not errors. It can wait - because the catalog is advisory: no runtime validates a peer's message against a published descriptor. -- **F-2.** Codes for the remaining codeless refusals (authorization, failed snapshot sources, routing). - Wait for a consumer that branches on them. -- **F-3.** Whatever the Cut 0 lane reveals once its later steps run again. diff --git a/docs/cultnet-rudp-ack-cut.md b/docs/cultnet-rudp-ack-cut.md deleted file mode 100644 index 1b519484..00000000 --- a/docs/cultnet-rudp-ack-cut.md +++ /dev/null @@ -1,1637 +0,0 @@ -# CultNet RUDP: Acknowledged means delivered, one watermark owns ordered delivery, and a write belongs to its session - -**PIVOT, 2026-09-30 (operator): RUDP is retired in favour of QUIC.** Operator: "RUDP really ballooned into -maintaining a robust custom transport across runtimes, when it started as just 'hey, let's do LiteNetLib but -better'. Is there any point maintaining it when we have QUIC?" and then "Yeah, pivot to QUIC adoption, I ain't -gonna let sunk costs take the wheel." -- **Landed 2026-09-30: Cut D, merged at `2f06ef84`** (Soul passes 1-4, batch 5 closing pass 4). It fixes live crashes: a spoofed datagram crashing Node, a malformed frame - killing Python's server, C# stale peers corrupting sessions. -- **Parked, not built:** Cut F, Cut 2 (held on F), Cut 4, Cut K and K1 (including the Kotlin resend-loop gap), Cut 7 - and the receipts port. Nothing of theirs exists to tag, so this map is their record. -- Defects found in RUDP from here on are fixed only if they are live crashes or data loss, until the QUIC campaign - sets RUDP's retirement. -- **Data-loss item from Odin Soul S-5 (2026-09-30).** At Odin's pin `3bf1c0ce`, cultnet-rs records a reliable - packet as received when it arrives, and `create_ack` reports it while ordered delivery still holds an earlier - packet. - - Probe: two pipelined puts, with the first datagram dropped. The second put was ACKed but not on disk. If the - first never arrives, the ACKed second put is never delivered. - - Sessions that carry a single put are safe. - - **Checked (Odin Q5 Imagination, probe P1 at `e4e2a0b9`): still open after ack Cuts 1-1c.** A held, undelivered - put is ACKed, so the pin bump does not close it, and it is a data-loss fix under the pivot rule. Related, P2: a - Pong ACKs a put received before the Ping; P3: a reliable reply created after a put ACKs it. The Odin writer-thread - cut (C5) adds `acknowledgement_withheld` to the document server; the transport fix belongs in cultnet-rs. -- The "CultNet over QUIC" campaign is new, so it opens as a typed Eureka campaign in the Huginn-backed session, not - as a prose map here. - -Status: cut map, Imagination pass 3, 2026-09-30. Pass 3 maps the four rulings below, re-maps Cuts 1c and -4, and adds Cut F (FORWARD-TSN), Cuts 6a-6c (receipts), Cut 7 (expiry, if Q-A8), Cut K (Kotlin), Cut 2c (the -C# fragment bound) and Cut D (a failed send to one peer stays that peer's loss). The text of Cuts 1, 1b, 2 -and 3 is pass 2's; Hands are executing Cuts 1 and 1b (`hands/ack-cut1`) and Cut 2 (`hands/ack-cut2`) from -it. One thing moves for them: Cut 2 merges only together with Cut F (the Cut 2 Soul finding below). - -**Rulings (operator, 2026-09-30).** -- **Q-A1 (a):** Delivered is derived at the sender from a correct receiver's cumulative watermark. The - acknowledgement wire does not change. (Cut F adds one notice to the wire; it carries abandonment, not - delivery.) -- **Q-A2:** "I think this is telling us we don't actually need both received and delivered." - - There is one public meaning: Acknowledged means delivered. - - Receipts go Pending, then Acknowledged (delivered), or Invalidated. No public Received state exists. - - Retransmission still stops on each packet's own ack, so resending stays bounded. - - Flush waits for Acknowledged. -- **Scope added from the stray-packet Soul passes 3 and 4:** session generation. One rule: a write belongs - to the session it was issued in. Mapped as **Cut 1b** (the ending rule) and **Cut 1c** (how a new - generation is recognised), separate from Cut 1 (§8 says why). -- **Q-A3 B:** FORWARD-TSN (RFC 3758) now. On expiry the sender sends an abandonment notice, Ack-typed with - flag `0x10` so old peers ignore it. New receivers treat the sequence as received with no frame and - acknowledge it. The notice's resend has its own bound. A new wire cut in every receiver, before Cut 4. - Mapped as **Cut F** (§6). The recommendation was A; the operator chose B. (Supersedes pass 2's Cut 4 - expiry half, which assumed A.) -- **Q-A4 A:** port per-send receipts (Pending, Acknowledged, Invalidated, and a wait for Acknowledged) to C#, - TypeScript, Python and Kotlin in this campaign, after Cut 4. Mapped as **Cuts 6a-6c** and **K4** (§9). - The recommendation was B. -- **Q-A5 A:** Kotlin is in, as trailing **Cut K**, verified on a Kotlin image added to Yggdrasil first - (Cut K0). -- **Q-A6 A:** the Connect's sequence identifies the session; the default initial sequence becomes random in - [1, 2^31), as TCP's ISN. No wire change; the public default changes. Cut 1c is no longer blocked on a - question. -- **Cut 2 Soul finding (2026-09-30):** Cut 2's never-evict rule refuses a session whose sender expires - fragmented reliable frames (the default Rust `media` channel). Pass 3 absorbs it: Cut F's receiver drops - every incomplete fragment set a notice covers; Cut 2 merges only together with Cut F; C# gets the bound - it never had (Cut 2c). What a receiver does with a sender that never sends notices is **Q-A9**. -- **Ruled after pass 3 (operator, 2026-09-30), each the recommendation:** - - **Q-A7 A:** a notice names one sequence, not a cumulative point. - - **Q-A8 A:** C#, TypeScript, Python and Kotlin gain reliable expiry (Cut 7, K5). - - **Q-A9 B:** a capability bit on Connect and Accept; Cut 2's never-evict rule applies only to peers - that advertise it, and other peers keep pre-Cut-2 eviction. - Cut F is unblocked once Cuts 1 and 3 merge; the text below mapped these answers already. - -- **Body.** CultLib `main` at `e9469cb3`. Every transport file is byte-identical to `3bf1c0c` there - (`git diff 3bf1c0c e9469cb3 -- src packages` is empty), so every `file:line` below is against both unless - it names another revision. - - Odin `origin/main` (`5c37860`) pins `3bf1c0ce` (`crates/odin-core/Cargo.toml:14-17`). A stale local - checkout at `379b826` still shows `a8aeddac`; read Odin's pin from `origin/main`. - - Pass 3 probes: `3e2c7efb` (FN) and `c6f1012c` (CAP) on the Yggdrasil mirror `probe3` (§ Probe - evidence, pass 3). -- **Base of every cut.** `main` at `e9469cb3` or later. -- **Scope.** The RUDP session and socket transports in all five runtimes: C# - `src/GameCult.Networking/CultNetTransport.cs`, Rust `packages/cultnet-rs/src/rudp.rs` (plus - `packages/cultmesh-rs`), TypeScript `packages/cultnet-ts/src/rudp.ts` (plus the two hand-rolled - publishers and `cultmesh-ts`'s document server), Python `packages/cultnet-py/src/cultnet_py/transport.py` - (plus `cultmesh-py`'s server), and Kotlin - `packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt` (Cut K). -- **Wire.** One addition, in Cut F: an Ack packet with flag bit 4 (`0x10`) is an abandonment notice for the - sequence in its sequence field. Every current decoder ignores the bit and every current session ignores - an Ack's sequence field (P7, re-probed as FN in pass 3 in all five runtimes). If Q-A9 is B, the same bit - on Connect and Accept advertises support (probe CAP: old peers ignore it there too). Nothing else changes - on the wire. Cut 1c changes the default initial sequence, which is a value, not a format. - - -## The ends (operator, 2026-09-30) - -- A frame the peer has buffered but not delivered must not look delivered. Today an ordered frame that - arrives behind a gap is held and acknowledged; if the session ends it is lost, and the sender saw - "Acknowledged". -- Resending stays bounded. The sender stops retransmitting a packet when the peer acknowledges that packet, - exactly as today. Delivery-only acknowledgement was rejected: "I don't like the possibility of unbounded - resending on an unresponsive peer application. TCP sounds like it has the right idea." -- One public meaning: **Acknowledged means delivered** to the peer's application boundary (§2). Unordered - reliable frames are delivered on receipt. Receipts go Pending, then Acknowledged, or Invalidated. -- A write belongs to the session it was issued in. When that session ends, a write not yet Acknowledged is - Invalidated. It is never carried into, retransmitted in, or acknowledged by a later session. - - -## The finding that shapes this map - -Self's first proposal put a second acknowledgement on the wire: a per-channel "delivered through N" -watermark beside the received ack. Probing the receivers changed the picture in two ways. - -**1. The ordered receivers are broken in every runtime, and the break is bigger than the session-end case.** -A held frame is not only lost at session end. In a live session it can be stranded forever, or dropped, -while the sender sees it acknowledged. The per-channel `next` pointer (`CultNetTransport.cs:918`, -`rudp.rs:196`, `rudp.ts:160`, `transport.py:424`, `CultMesh.kt:2643`) has been patched twice (`436654de` -added the first-use initialisation, `4335ab10` added the skip over other channels' sequences) and is still -wrong: - -- **P1: a gap filled by another channel strands the ordered channel.** Ordered `o1`, reliable `u` on - another channel (lost), `o2`, `o3`. When `u` arrives, only `u`'s channel is drained. `o2` and `o3` are - never delivered, and the sender's pending set is empty. The same holds with two ordered channels (P1b). -- **P6: a channel first used after other traffic loses frames.** `C1`, `C2` on a new channel, then `X` on - another. `X` arrives, then `C2`, then `C1`. The channel initialises its `next` from - `min(highest+1, frame)`, so `C2` is delivered first and `C1` is **dropped as old** - (`frame.sequence < next`). It was acknowledged. -- Both reproduce at `3bf1c0c` in C#, Rust, TS and Python (pass 2), and did at `d85877a7`, Odin's old pin - `a8aeddac` and Muninn's pin `c2a9a6e5` (pass 1). - -**2. Once the receiver is correct, "delivered" is not new information.** A conforming receiver holds an -ordered frame for exactly one reason: some reliable sequence below it has not arrived. When the last -missing sequence arrives, the same `Receive` call drains the held frames, before the acknowledgement is -built. So: - -> An ordered frame is delivered exactly when every reliable sequence up to its last one has been -> acknowledged. - -The sender already knows that. It is the sender's own **acknowledged-through** watermark: one below the -lowest sequence that is still pending, queued or abandoned. TCP's cumulative ACK means the same thing, -"every byte below N is in the receive buffer", and it sits beside SACK. Here the sender can compute the -cumulative value itself, because every sequence is acknowledged individually and removed from its pending -set. The operator ruled this (Q-A1 a), and then ruled that the per-packet ack is not a public meaning at -all (Q-A2): it only stops retransmission. - -The derivation is sound only if nothing the receiver acknowledged is later dropped while the session -lives, and nothing one session acknowledges is credited to another. The probes found these places where -that fails: - -| # | Where an acknowledged frame is lost, or credited to the wrong session | Runtimes | Fixed by | -|---|---|---|---| -| P1, P1b | A cross-channel gap strands the ordered channel | all five | Cut 1 | -| P6 | Late channel initialisation drops the earlier frame | all five | Cut 1 | -| P5 | A reliable fragment set is evicted after its fragments were acknowledged | Rust, TS, Python (C# and Kotlin have no eviction) | Cut 2 | -| P8 | A retransmit more than 4,096 sequences behind the receiver's highest counts as a duplicate: acknowledged and dropped | all five | Cut 3 (the sender never lets its span reach it) | -| G2 | After `connect()` again on the same transport, a new server session's frames are duplicates of the old one's sequences: acknowledged and dropped | C#, Rust, TS, Python | Cut 1c | -| G3 | A write left owed when a session ends is retransmitted into the next session and delivered there, and in Rust its receipt reads `Acknowledged` | Rust (local `disconnect()`, timeout); C#, TS, Python (every ending) | Cut 1b | - -And places where the sender loses track, or is locked out, without the receiver's help: - -| # | Sender-side lie or lockout | Runtime | Fixed by | -|---|---|---|---| -| G1 | A restarted client on the same endpoint and Connect payload gets an Ack, never an Accept, and stays unconnected | Rust hub, C# listener and C# server mode, TS and Python server mode (Rust server mode resets on every Connect instead) | Cut 1c | -| G1b | C# and Python server-mode transports drop a Connect from any endpoint but the first, so a client that restarts on a new port is locked out for good | C#, Python | Cut 1c | -| P2 | An expired reliable packet leaves a permanent hole. Ordered frames after it are held forever, and `flush_reliable` succeeds (outstanding 0) | Rust (the only runtime with reliable expiry) | Cut F (FORWARD-TSN, Q-A3 B); Cut 4 reports it honestly where a receiver never acknowledges the notice | -| P9 | A receipt for an expiring send reads `Acknowledged` once the packet expires unacknowledged | Rust | Cut 4 | -| P10 | `send_reliable` with a full window queues the frame, then returns an error ("receipts require a non-empty reliable packet set"), so a caller that retries sends it twice | Rust | Cut 4 | - -And two faults found by Soul passes during pass 3: - -| # | Fault | Where | Fixed by | -|---|---|---|---| -| D1 | One peer whose datagrams cannot be sent fails every poll for every peer: the first failed `send_to` aborts `maintain` and `poll_once` (Odin Soul pass) | cultmesh-rs document server, Rust hub, C# listener; the cultmesh-py server's thread dies | Cut D (§10) | -| F2 | After Cut 2, a sender with reliable expiry pins one reliable fragment set per lossy frame, and the 65th refuses the session (Cut 2 Soul pass, default Rust `media`) | Rust, TS, Python receivers with Cut 2 | Cut F releases the sets; Cut 2 merges with it; Q-A9 for senders without notices | - - -## Probe evidence - -Everything ran on Yggdrasil through `ygg-verify.sh`, from local-only probe branches in throwaway -worktrees. Each probe commit survives on the Yggdrasil mirror as `refs/verify/`. - -Pass 1 (base `d85877a7` and the pins; mirror `CultLib-imag-ack`): - -- `de2bdfe8`, `09318d13`, `03eac6ff`: Rust session and socket probes (`packages/cultnet-rs/tests/probe_ack.rs`). -- `b70a69ca`, `2320a4e5`, `7fe5d726`: the C#, TS and Python probes (`ProbeAckTests.cs`, - `probe-ack.test.ts`, `probe_ack.py`). -- `f0e7136c`: the Rust probes at Odin's old pin `a8aeddac`. `bf8fc826`: all four at Muninn's pin `c2a9a6e5`. -- `db7d2886`: **the prototype**, the Rust receiver rebuilt on one watermark plus sender-derived receipt - states (about +130/−125 in `rudp.rs`). Its `Received`/`Delivered` receipt states are superseded by Q-A2; - its receiver is what Cut 1 builds. - -Pass 2 (base `3bf1c0c`; mirror `CultLib-imag-ack2`): - -- `a383e27d`, then `1519a20a` (the C# server-mode G1 probe acknowledges the Accept before the restart, so - it tests a restart and not a lost Accept): the pass-1 probe files restored unchanged, plus - `packages/cultnet-rs/tests/probe_gen.rs`, `packages/cultnet-ts/test/probe-gen.test.ts`, - `packages/cultnet-py/tests/probe_gen.py` and `tests/GameCult.Networking.Tests/ProbeGenTests.cs`. -- Rust and C# G1 run over real loopback UDP (hub, listener, server-mode transport), with the restarted - client bound to the first client's exact address. Python G1 runs over UDP against the server-mode - transport. TS G1 calls `acceptConnect` on the connected session, which is what the socket transport does - for a same-endpoint Connect (`rudp.ts:1034-1049` calls it without a reset, and `rudp.ts:249-251` answers - it as a repeat). G2 and G3 are session-level: the socket transports' `connect()` is `create_connect` and - nothing else (`rudp.rs:1874-1883`, `CultNetTransport.cs:1836-1846`, `rudp.ts:891-897`, - `transport.py:994-998`). - -| # | Probe | Pass 1 (`d85877a7`, pins) | Pass 2 (`3bf1c0c`) | Prototype `db7d2886` | -|---|---|---|---|---| -| P1 | `o1`, reliable `u` lost, `o2`, `o3`; then `u`, then `o3` | Delivered `[o1, u]`; `o2`, `o3` never; sender pending `[]`. Rust, C#, TS, Python; same at both pins | Same, all four | `[o1, u, o2, o3]` | -| P1b | `A1`, `B1` (second ordered channel) lost, `A2`, `A3` | `[A1, B1]`, all four | Same, all four | `[A1, B1, A2, A3]` | -| P6 | `C1`, `C2` on a new channel, then `X`; arrival `X`, `C2`, `C1` | `[C2]`; `C1` dropped. All four | Same, all four | `[C1, C2, X]` | -| P2 | Rust: reliable media with expiry 1 ms, lost; then `s1`, `s2` on `schema` | Nothing delivered. Sender outstanding 0, expired 1, no resends | Same | Unchanged (held behind the hole). Cut 4 makes the sender say so | -| P3 | `s1` lost, `s2` arrives and is acknowledged | `s2` not delivered, but acknowledged: sender pending `[s1]` only | Same | Receipt for `s2` stays short of delivered until `s1` arrives | -| P4 | Rust: `s0` delivered, `s1` lost, then a 5 MiB ordered frame in 60 kB fragments | `RUDP ordered hold buffer is full`: the session is refused. With no gap, delivered | Same | The prototype held every ordered frame, so a 5 MiB frame was refused **even with no gap**: hold only what is not yet deliverable (Cut 1) | -| P5 | 3-fragment reliable frame, 2 fragments acked; 70 lossy fragment sets; last fragment arrives | Rust, TS, Python: never delivered, sender pending `[]` | Same, Rust, TS, Python | Unchanged (Cut 2) | -| P7 | An Ack with flag bit `0x10`, a nonzero sequence field, or a 5-byte payload | Decoded and applied in Rust, C#, TS, Python | Same, all four | n/a | -| P8 | Reliable `g` lost while 4,200+ later sequences are sent and acked; then `g` arrives | `g` not delivered, and acknowledged. All four | Same, all four | Unchanged (Cut 3) | -| P9 | Rust socket: `send_reliable("media")` with expiry 1 ms, never read | `Pending`, then `Acknowledged` | Same | `Pending` | -| P10 | Rust socket: 40 `schema` sends, then `send_reliable` | Error "receipts require a non-empty reliable packet set", after the frame was queued | Same (the probe's `?` fails on that error) | Not addressed (Cut 4) | -| G1 | Client A connects, sends one ordered frame (acknowledging the Accept), and exits. Client B, a fresh session with the same initial sequence, binds A's exact address and sends the same Connect payload five times | n/a | **Locked out.** Rust hub (payload `"svc"` and empty): 5 Acks, 0 Accepts, B unconnected, the hub still holds A's generation. C# listener: same, no `PeerDisconnected`. C# server mode: 5 Acks. Python server mode: 5 Acks. TS session: the answer is an Ack. Rust server mode (control): B gets an Accept and its frame is delivered, because it resets on every Connect | Not probed | -| G1b | C# and Python server mode: a third client on a new port sends a Connect | n/a | No reply; the datagram is counted dropped | Not probed | -| G2 | Client connects to server 1 (initial sequence 1) and receives `old1..3`. Server 1 is gone; the client connects again on the same session to server 2 (initial sequence 1), which sends `new1`, `new2` | n/a | **`new1`, `new2` never delivered, and acknowledged** (server 2's pending set empties). C#, Rust, TS, Python | Not probed | -| G3 | Client sends one ordered write that is lost; the session ends; the client connects to a new server; the client's resends run | n/a | Owed after the end, and **delivered in the next session**: C#, TS, Python on peer Disconnect, local disconnect and timeout; Rust on local disconnect and timeout. Rust on peer Disconnect: owed 0, nothing delivered (`5f1e883d`) | Not probed | -| G3R | Rust socket: `send_reliable`, the write is lost, `disconnect()`, `connect()` on the same transport to a new peer | n/a | Receipt `Pending` after the disconnect; the write is delivered to the new peer; **receipt `Acknowledged`** (the Soul R1 shape) | Not probed | - -Pass 3 (base `e9469cb3`, transport files identical to `3bf1c0c`; mirror `probe3`, commits `3e2c7efb` for FN -and `c6f1012c` for CAP): - -- `packages/cultnet-rs/tests/probe_fn.rs`, `packages/cultnet-ts/test/probe-fn.test.ts`, - `packages/cultnet-py/tests/probe_fn.py`, `tests/GameCult.Networking.Tests/ProbeFnTests.cs` and - `packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/ProbeFn.kt`. -- Images: `eureka-verify-rust`, `mcr.microsoft.com/dotnet/sdk:10.0`, `node:24`, `python:3.12`, and for - Kotlin `eclipse-temurin:21-jdk` with `kotlin-compiler-2.2.21.zip` fetched in the job (the recipe Cut K0 - bakes into an image). - -| # | Probe | Result at `e9469cb3`, all five runtimes | -|---|---|---| -| FN | Sender `a` sends ordered `o1`, `o2`, `o3`; `o2` is lost, so the receiver `b` holds `o3`. `b` sends reliable `x`, which `a` receives. `a` then sends the Cut F notice exactly as specified: `create_ack()` encoded, flag byte `\|= 0x10`, sequence field = `o2`'s sequence. `b` decodes and receives it; then `o2` arrives late | **Old receivers ignore the notice and apply its acks.** It decodes as an Ack; `b`'s pending `[501]` (`x`) empties, so the header's acks were applied; nothing is delivered; `reply` is empty; `b` stays connected; `o2` is **not** marked received (not in `b`'s ack or mask). The late `o2` then delivers `[o2, o3]`: the hole was untouched. Identical in Rust, C#, TypeScript, Python and Kotlin | -| FN-T | Transport path (code, not run) | Every socket transport acks only a reliable, Accept or Data packet, or (TS, Python, Kotlin) one whose receive delivered a frame (`rudp.rs:2152-2155`, `:1713-1715`, `CultNetTransport.cs:2281-2283`, `:2787-2788`, `rudp.ts:1089-1091`, `transport.py:1086-1088`, K:3243-3245). An old receiver delivers nothing on a notice (FN), so the notice draws no reply datagram and is not counted dropped. Every transport already forwards a session's `reply` (`rudp.rs:2135-2137`, `:1708`, `CultNetTransport.cs:2277-2278`, `:2748-2749`, `rudp.ts:1067-1068`, `transport.py:1070-1071`, K:3229, `rudp_document_server.rs:334-336`, `cultmesh-ts/src/index.ts:5828-5830`, `operation-service.ts:186`, `cultmesh-py/.../server.py:246-247`), which is how a new receiver answers a notice | -| CAP | Q-A9 B's capability bit on old peers: `a`'s Connect and `b`'s Accept are each encoded, given flag bit 4, and decoded before delivery; then `a` sends one ordered frame (`probe_cap.rs`, `probe-cap.test.ts`, `probe_cap.py`, `ProbeCapTests.cs`, `ProbeCap.kt`) | **Old peers ignore the bit on the handshake.** Both sides connect, the frame is delivered, and the Connect is acknowledged (the sender's pending holds only the data frame). Identical in all five runtimes | -| K-img | Kotlin self-tests on Linux | `kotlinc-jvm 2.2.21` on OpenJDK 21.0.12 compiles `CultMesh.kt` plus a probe file, and `java -cp out.jar:kotlin-stdlib.jar org.gamecult.cultmesh.CultMeshKt` (the self-tests, K:3349-3373) exits 0 | - -**Suites on the prototype `db7d2886`** (pass 1; baseline `03eac6ff` was all green): - -- `cultnet-rs`: 110 + 4 + 24 pass; `tests/cultnet.rs` 51 pass and 2 fail. Both failures are test shape, - not mechanism: - - `rudp_session_suppresses_duplicates_and_delivers_reliable_ordered_payloads_in_sequence` - (`tests/cultnet.rs:1000`) hands the receiver an Accept with sequence 91 from a sender whose data starts - at 1. That handshake is impossible. Under a watermark seeded by the Accept, every data sequence is - "already below" it. The test must use a consistent handshake. - - `rudp_ordered_channel_tracking_is_bounded` (`:2655`) sends 256 ordered channels with no gap. The - prototype keeps state only for channels with held frames, so nothing is refused. The bound becomes - "channels with held frames", and the test must hold frames behind a gap. -- `cultmesh-rs` did not compile only because the prototype added a status variant. Under Q-A2 the status - enum keeps its three variants, so that break does not recur. - -**Wire compatibility (P7).** Every decoder ignores flag bits 4-7 and byte 35. Every session ignores an -Ack's sequence field and payload (`CultNetTransport.cs:1177`, `rudp.rs:578-592`, `rudp.ts:397`, -`transport.py:612`, `CultMesh.kt:2738`). Every decoder rejects an unknown packet type -(`CultNetTransport.cs` `Enum.IsDefined`, `rudp.rs` `packet_type_from_code`, `rudp.ts:1313`, -`transport.py:1212`, `CultMesh.kt` `fromCode`) and an unknown version byte. So: - -- An additive field fits in an Ack: flag bit 4 set, the value in the Ack's unused sequence field, zero - extra bytes. Old peers apply the ack and ignore the rest. Q-A1 ruled out a watermark there; Cut F puts - the FORWARD-TSN notice there (Q-A3 B), and pass 3's FN probe confirms the old-peer behaviour in all five - runtimes. -- A new packet type or a version bump is not additive: old peers refuse the datagram and count it dropped. -- Cut F's notice needs no negotiation to be safe: it reads as a plain ack to every current peer. Q-A9 asks - whether to advertise support anyway, for the receiver's sake (§6). - - -## Authority map - -- **Owner of ordered delivery (receiver): the session's contiguous received-through watermark `R`.** - - Every reliable sequence up to `R` has been received since the peer state was last reset. - - A held ordered frame whose first sequence is at most `R + 1` is delivered, in sequence order, in the - same call that advanced `R`. - - `R` is seeded by the handshake. `AcceptConnect` seeds it with the Connect's sequence, and receiving - the Accept seeds it with the Accept's sequence. A session connected without a handshake (Rust - `assume_connected`, `rudp.rs:243`, test-only today) seeds it from its first reliable packet. - - It advances in `RememberReceived` and resets with the rest of the peer state (`ResetPeerState`). -- **Owner of retransmission (sender): the pending and queued sets**, as today. A sequence leaves them when - an ack names it. Retransmission stops there. This is not a public meaning. -- **Owner of abandonment (sender, Cut F): the abandoned set.** An expired sequence is announced by notices - until an ack names it or 16 sends pass; then it is stranded (`first_stranded`). The receiver's `Abandon` - branch is the only path that marks a sequence received without its packet, and it drops every incomplete - fragment set the sequence falls in. -- **Owner of Acknowledged (sender): the acknowledged-through watermark `A`**, one below the lowest sequence - that is pending, queued, awaiting its abandonment notice's ack, or stranded in the current generation. An ordered send is Acknowledged when `A` - reaches its last sequence. A reliable unordered send is Acknowledged when every one of its sequences is - acked. -- **Owner of the session boundary: the session's generation.** One primitive ends a generation: the - session stops being connected, every write not yet Acknowledged is Invalidated and dropped from pending - and queued, and the generation counter advances. Every ending path calls it: a peer's Disconnect, a - local disconnect, a timeout and a refused packet (Cut 1b), and from Cut 1c a client's `connect()` on a - session that already had a peer, and a server accepting a Connect that does not repeat the current one. - - What was learned from the peer (`R`, the received set, held frames) is forgotten only where both sides - start fresh: a refusal (as today) and, from Cut 1c, a non-repeated handshake. Forgetting it at a - one-sided ending (a timeout the peer did not see) would let the peer's retransmits be delivered twice. -- **Owner of "is this Connect a repeat": the session**, from the Connect's sequence (Cut 1c; Q-A6). -- **Inputs.** Received sequences and handshake packets (receiver); acks, expiry and ending events - (sender). Nothing else. -- **Outputs.** Delivered frames, in order (receiver). Receipt status and flush completion (sender). -- **Derived, not owners.** - - The per-channel `next` map is **deleted**, not demoted: `_orderedNextSequenceByChannel` - (`CultNetTransport.cs:918`), `ordered_next_sequence_by_channel` (`rudp.rs:196`), - `#orderedNextSequenceByChannel` (`rudp.ts:160`), `_ordered_next_sequence_by_channel` - (`transport.py:424`), `orderedNextSequenceByChannel` (`CultMesh.kt:2643`). - - `expectedSequenceIfUninitialized` and its equivalents are deleted (`CultNetTransport.cs:1151`, - `rudp.rs:540`, `rudp.ts:375`, `transport.py:595`, `CultMesh.kt:2728`). - - `PendingOrderedFrame.NextSequence` is deleted (`rudp.rs:160-163` and equivalents). - - `OutstandingReliablePacketCount` stays, and means "not yet acked in this generation". It is a - retransmission count, not a delivery claim. - - Rust `session_scope: Uuid` (`rudp.rs:135`, `:179`, `:206`, rotated at `:345` and `:601`) is no longer an - owner. It is replaced by the generation (Cut 1b) and then by receipts resolved at their source - (Cut 4). - - TS `#generation`, `#endedGeneration` and `#endGeneration` in the socket transport (`rudp.ts:830-831`, - `:937-940`) are no longer owners; the session's generation replaces them. - - `DisconnectReason` / `disconnect_reason` / `#endedReason` are report-only: why the last generation - ended. They no longer gate flush. -- **Forbidden writers.** - - No path delivers an ordered frame except the drain after `R` advances. - - No receive path drops a frame whose sequence it acknowledged while the generation lives. - - No sender path reports Acknowledged except through `A` (or the unordered rule). - - No ending path leaves a write owed. No path retransmits a write, or sends a notice, into a generation - after the one it was issued in. - - No path marks a sequence received without a packet, except the `Abandon` branch (Cut F). - - No per-peer send failure ends a poll, a loop, a thread or another peer's session (Cut D). - - No transport decides whether a Connect repeats: not by payload (Rust hub `rudp.rs:1637-1647`, C# - listener `CultNetTransport.cs:2670-2688`), not by `Connected` (C# `:2226-2236`, Python - `transport.py:1047-1053`, TS `rudp.ts:249-251`, `:1031-1049`), not by server key or payload - (cultmesh-rs document server `rudp_document_server.rs:413-427`, cultmesh-ts document server - `index.ts:5794-5802`), and not by resetting on every Connect (Rust server mode `rudp.rs:2105-2116`, - cultmesh-py server `server.py:225-240`). -- **Shared paths.** Accept, reliable data, fragments, duplicates and retransmits all advance `R` through - `RememberReceived` and then call the drain. Direct sends, fragmented sends, queued promotion and resends - all feed the pending and queued sets that `A` reads. Every ending path goes through the one generation - primitive. -- **Deletion line.** `DeliverOrdered`, `DrainOrdered` and `SkipReceivedNonChannelSequences` and their - equivalents go before the drain is added: `CultNetTransport.cs:1628-1700`, `rudp.rs:1138-1246`, - `rudp.ts:737-800`, `transport.py:868-920`, `CultMesh.kt:2939-2978`. The transport-level repeat decisions - above go before the session's is added. - - -## The design, question by question - -### 1. Where Acknowledged comes from (Q-A1 a, ruled) - -- Derived at the sender from `A` (§ The finding). No wire change. -- **Why it is sound after Cuts 1-3.** A conforming receiver: - - drops nothing it acknowledged while the session lives (P1, P6: Cut 1; P5: Cut 2; P8: made unreachable - by Cut 3); - - holds an ordered frame only while a sequence below it is missing (Cut 1); - - drains held frames in the call that fills the last gap, before it acknowledges (Cut 1). - - So every sequence up to `s` acked means `s` was delivered. -- **And after Cuts 1b and 1c,** an ack can only be credited to the generation that issued the write - (G3, G2). -- **Mixed versions.** A new sender with an old receiver can be wrong only when that receiver strands a - frame (P1, P6). That needs reliable traffic on more than one channel of one session. The C#, TS, Python - and Kotlin socket transports send reliably only on `schema` (`CultNetTransport.cs:2372-2376`, - `rudp.ts:1254-1262`), so they cannot trigger it. Rust sends reliable `media`/`audio` too - (`rudp.rs:2523-2562` `channel_send_options`). The pass-1 Eyes survey found no live session that mixes - those with `schema`: Muninn's media session carries no `schema` traffic, and neither does Sleipnir's HID - stream. The old receiver loses such frames today in any case. Bumping the pin is the fix. -- **Every Odin-bound publisher's receiver is Odin.** Acknowledged means delivered for Idunn health, - presence and catalog publishing only once Odin pins a CultLib with Cuts 1-3. - -### 2. What "delivered to the application" means - -- **Delivered means the frame left the session's hold and was handed to the transport's application - boundary.** That boundary is: - - C#: enqueued in the socket transport's `_deliveredFrames` (read by `TryReceiveOnce`), or returned in - `CultNetRudpReceiveResult.Delivered` from a bare session; - - Rust: pushed to `delivered_frames` (`rudp.rs:2147`) or the hub's `pending_events`, or handed to the - document server's sink (`cultmesh-rs/src/rudp_document_server.rs:343-360`), which acknowledges only - after the sink accepted; - - TS: the `"frame"` event was emitted (`rudp.ts:1076-1082`); - - Python and Kotlin: the delivered queue. -- **It is not "consumed".** The operator rejected application-driven acknowledgement, and TCP's cumulative - ACK has the same boundary: in the receive buffer, readable, not read. -- A listener or sink that throws or rejects has still been delivered to. The handler-rejection paths from - the stray-packet work end the session, which is the application's answer, not the transport's. - -### 3. The public API (Q-A2, ruled: one meaning) - -- **Rust receipts** (the only runtime that has them today; §9 ports them to the other four): - - `CultNetRudpReliableSendStatus` keeps its three variants, `Pending`, `Acknowledged`, `Invalidated` - (`rudp.rs:146-150`). No variant is added, removed or renamed. `Acknowledged` changes meaning from - "every packet was acked" to "delivered". - - The visible difference: an ordered send behind a missing sequence reads `Pending` until the gap - fills (P3), where today it reads `Acknowledged`. - - Every external caller already means delivered, so none changes code: `cultmesh-rs/src/lib.rs:832` - and `:892`, `tests/rudp_stray_packets.rs:309`, `cultmesh-rs/tests/rudp_document_server.rs:408,415`, - CodexConnector `src/idunn_health.rs:727-745`, Ghostlight - `crates/ghostlight-dungeon/src/idunn_health.rs:1126-1145`. - - **A receipt is resolved once, by its session.** It becomes `Acknowledged` when `A` passes its last - sequence (ordered) or when all its sequences are acked (unordered). It becomes `Invalidated` when its - generation ends first. After that it never changes. - - Mechanism: the receipt carries its sequences, whether it was ordered, and a shared status cell - (`Arc`). The session keeps the unresolved cells, at most one per outstanding send, and - writes each once. `reliable_send_status(&receipt)` (`rudp.rs:1931-1936`) reads the cell; its - signature does not change. - - This deletes the session scope (`rudp.rs:135`, `:179`, `:206`, `:283-285`, `:291-293`, `:345`, - `:601`) and needs no history of ended generations. Today a delivered write reads `Invalidated` after - any reset, because the scope rotates (`rudp.rs:291-293`). The pass-1 design needed a frozen snapshot - of one ended epoch and still misreported older ones. - - `PartialEq` on the receipt compares its sequences, which are unique within a session object because - issued sequences survive resets. - - `send_reliable` receipts cover queued packets (P10). The receipt lists every sequence the send - assigned, not only the ones admitted to the wire (`send_many`, `rudp.rs:456-528`, returns only the - admitted ones; `non_expiring_reliable_receipt`, `:305-318`, refuses an empty set). - - `send_reliable` refuses a channel with reliable expiry (P9). The comment at `rudp.rs:1915-1916` says - this lineage has no expiry, which is false since `bac5be88`. Restore the guard it describes. - - New: `CultNetRudpSocketTransportConnection::wait_acknowledged(&receipt, timeout) -> Result<()>`. It is - the ack wait: it pumps receive and resends like `flush_reliable` and returns when the receipt is - `Acknowledged`. It fails at once when the receipt is `Invalidated`, naming the end reason. It replaces - the hand-rolled loops at `cultmesh-rs/src/lib.rs:806-838` and `:870-900`; CodexConnector and - Ghostlight may adopt it at their next bump, and their existing polling stays correct without it. -- **Flush: one wait, and it means every send of this generation is Acknowledged.** - - A flush belongs to the generation it started in. It fails when that generation ends, whatever comes - after. Rust binds it to the scope today (`rudp.rs:2001-2014`) and TS to its transport generation - (`rudp.ts:911-935`). C# (`CultNetTransport.cs:1914-1931`) and Python (`transport.py:1101-1124`) check - only the disconnect reason, which the next Connect clears (`CultNetTransport.cs:1843`, `:2235`; - `transport.py:997`, `:1054`). Once Cut 1b drops owed writes at every ending, "outstanding is 0" after a - reconnect would read as success, so every runtime binds flush to the session's generation in Cut 1b. - - When every sent sequence is acked, `A` is the highest sequence sent, so every send is Acknowledged. - Under Cut F an abandoned sequence is resolved by its notice's ack, so flush waits for that too. The - only exception is a stranded sequence (a notice the receiver never acknowledged). There - `flush_reliable` (`rudp.rs:1992-2040`) fails at once when an ordered send follows it: that send can - never be Acknowledged, and today flush reports success (P2). - - C# `FlushReliable`, TS `flush`, Python `flush_reliable` and Kotlin `flushReliable` - (`CultMesh.kt:3186`) keep their success condition. Their contract text becomes "every reliable frame - sent in this session has been delivered to the peer's application". These runtimes have no expiry - unless Q-A8 gives them some (Cut 7). -- **Defaults.** Plain flush. No parameter. No second flush. -- **Compatibility.** No signature changes in any runtime except additions (`wait_acknowledged`; TS - `connectAndWait`, §4; the receipts of §9, where C# and Kotlin `SendSchema*` return a receipt instead of - nothing, which is source-compatible). The Rust enum is unchanged. No downstream caller has to change code at its next - bump. - -### 4. Consumers, each assigned - -Surveyed across `F:\Projects` in pass 1; the rows that moved are re-checked at the revision named. Every -consumer that waits wants delivered, which is now just Acknowledged. - -| Consumer | What it waits on today | Change | -|---|---|---| -| `cultmesh-rs/src/lib.rs:781-838` `request_raw_snapshot_from_rudp_catalog` (Idunn `src/drivers.rs:5527` uses it) | a hand-rolled loop until `Acknowledged`, then the response | Cut 4: `wait_acknowledged` | -| `cultmesh-rs/src/lib.rs:870-900` `publish_cultnet_message_to_rudp_catalog` (Odin `odin-daemon`) | a hand-rolled loop until `Acknowledged`, then disconnect. The doc at `:869` claims "application admission" | Cut 4: `wait_acknowledged`; the doc says delivered to the document server's sink (`rudp_document_server.rs:343-372`) | -| `cultmesh-rs/src/lib.rs:918-938` `publish_cultnet_messages_to_rudp_catalog` (Ghostlight `mesh.rs:323`) | `flush_reliable`, then drop. **Several ordered frames, then close** | None; flush now means it | -| `cultmesh-ts/src/index.ts:6070-6098` `publishRudpDocumentOnce` (Heimdall, StreamPixels, Stonks, weksa, Bifrost, VoidBot, Hermodr) | `peer.flush` (`cultnet-ts/src/peer.ts:109-110`), then close | None. Cut 5 moves its connect-and-wait helper (`index.ts:6603-6650`) into cultnet-ts | -| `cultnet-ts/src/idunn-odin-presence-publisher.ts:89-215` `publishDocument`, behind `createIdunnRuntimePresencePublisher`. **StreamPixels' service runs this**: `apps/service/scripts/idunn-entry.mjs` runs `deployment/idunn/runtime-presence.mjs`, which calls `createIdunnRuntimePresencePublisher` (`:46`) from its vendored CultLib `542ddd3` (StreamPixels `a49f7d8`; pass 2's `30ee8b9` is stale), where it lives under its older name `cultnet-ts/src/idunn-runtime-authority.ts:206` | a hand-rolled session loop (`:186-208`) until `outstandingReliablePacketCount === 0`. It does resend (`:205`). It drops `readyToSend` (`:198`), so promoted queued packets wait for the resend timer. It pins `initialSequence: 1` (`:103`) and never sends a Disconnect, so Odin's hub keeps each publish's peer until it times out (each publish binds a new port, so each is a new peer) | Cut 5: the socket transport, `connectAndWait`, `send("schema")`, `flush`, `close` (which sends the Disconnect, `rudp.ts:956-969`) | -| `cultnet-ts/src/signed-daemon-health.ts:104-162` `publishSignedDaemonHealth` (Hermodr, Odin `idunn-rudp.cjs`) | a hand-rolled loop: sends the packets `sendMany` admitted, waits up to 500 ms for the **first** Ack packet of any content (`:146-153`), swallows the timeout, closes. Resends run inside that wait (`:303`) but promoted queued packets are never sent | Cut 5, as above. Today a write not acked within 500 ms, or any payload over 32 packets, is reported published | -| `cultnet-ts/src/operation-service.ts` | the operation response | none (the response is the proof) | -| C# `FlushReliable` callers: Gjallar `Program.cs:3055-3080` (two ordered frames, flush, dispose) | flush | None | -| Heimdall `src/idunn-rudp-health.ts:55-87` (vendored CultLib `b6b1d9c`, Heimdall `d5acc94`) | the first Ack packet | Heimdall's own cut at its bump: call cultnet-ts's publisher after Cut 5 | -| CodexConnector `idunn_health.rs:727-745`, Ghostlight `idunn_health.rs:1126-1145` | `Acknowledged` | None required. Optional `wait_acknowledged` at their next bump | -| Muninn `main.rs:9446-9458`, Sleipnir `main.rs:880-904` | nothing (send and drop) | Follow-up: fire-and-forget health can be silently lost | -| Kotlin `flushReliable` | no callers | Contract text only | - -### 5. The hold buffer and the 4 MiB cap - -- **It belongs here**, because the held frame is exactly the state this map names. -- **Mechanism (P4).** Rust caps held ordered frames at 1,024 frames and 4 MiB (`rudp.rs:47-48`, checked - at `:1181-1187`). A refusal ends the session. The default payload limit is 16 MiB (`rudp.rs:33`). With - one lost packet under a large ordered transfer, a legal 5 MiB frame is refused and kills the session. - - The sender's window counts pending packets, not span or bytes (`rudp.rs:910-942`). While one packet - stays lost, acked packets keep freeing slots, so the held data behind the gap grows without limit. -- **Fix: a sender-side flow window, TCP's receive window without a wire field** (Cut 3). A reliable - packet is admitted to the wire only while: - - its sequence is at most 1,023 above the lowest unacked sequence; and - - the payload bytes of sequences above the lowest unacked one stay within 4 MiB, with at least one - packet always admissible. - - Otherwise it waits in the existing queue. -- **What this buys:** - - a conforming sender never makes a Rust receiver hold more than 4 MiB, so the cap stops refusing legal - traffic; - - a conforming sender never gets 1,024 sequences ahead of the receiver's highest, so the Rust far-ahead - refusal (`rudp.rs:46`, checked at `:626-630`) never drops its packets; - - a conforming sender never leaves a sequence 4,096 behind the receiver's highest, so P8 cannot happen. - The receive-history window stays 4,096 in every runtime (`CultNetTransport.cs:884`, `rudp.rs:35`, - `rudp.ts:20`, `transport.py:404`, `CultMesh.kt:2625`). -- **What is kept.** The cap and the far-ahead refusal stay. They protect against hostile peers. -- **Rejected:** raising the cap to the payload limit or above (16-64 MiB per hostile session instead of - 4); lowering the ordered payload limit to 4 MiB (an API regression for large snapshots). -- **Cost.** Normal flow never has a span beyond the 32-packet window, so the new limits bind only while a - packet is lost. -- **Old senders** (the pinned and vendored ones) can still trip the Rust cap until they bump. -- **Not in scope.** C#, TS, Python and Kotlin receivers have no hold cap. Follow-up. - -### 6. Reliable expiry and FORWARD-TSN (P2; Q-A3 B, ruled) - -- **The hole.** Only Rust has reliable expiry (`rudp.rs:39`, `:898-908`; the Python README's claim of - expiry at `packages/cultnet-py/README.md:103-111` is false, `transport.py` has none). An expired packet's - sequence never reaches the receiver, `R` stops below it, and every ordered frame after it on the session - is held until the session ends. -- **Who expires.** Every Rust `media` sender that does not opt into lossy delivery: the profile's media - delivery defaults to Reliable (`channel_delivery`, `rudp.rs:2515-2521`) and its expiry to 75 ms - (`rudp.rs:39`, set on the client and hub transports at `:1303` and through the profile at `:1548-1549`). - Media frames fragment. Muninn's reliable `audio` also expires; `hands/media-fec-cut3` deletes that profile - entry and moves Muninn's media to lossy delivery, but the default stays reliable-with-expiry for every - other caller. - -**What RFC 3758 does, and what this map keeps.** - -- The sender treats an abandoned chunk as "finally acked and no longer outstanding" (§3.5 A2) and advances - an `Advanced.Peer.Ack.Point` over consecutive abandoned TSNs. When that point passes the peer's - cumulative ack it sends FORWARD TSN (C1-C3), and tries again whenever T3-rtx expires (A5). -- FORWARD TSN carries a **New Cumulative TSN** plus (stream, stream sequence) pairs. The receiver "MUST - consider any missing TSNs earlier than or equal to this value as received" (§3.2), advances its - cumulative point, releases the listed streams' reordering queues, and acks "as if a DATA chunk had been - received" (§3.6). A FORWARD TSN at or behind its cumulative point is out of date, changes nothing, and - still draws a SACK. -- PR-SCTP is negotiated: an endpoint that did not see Forward-TSN-Supported in the peer's INIT must never - send FORWARD TSN (§3.1, §3.3). - -**How CultNet adapts it.** - -- **The notice names one sequence, not a cumulative point.** SCTP's SACK is cumulative, so a cumulative - FORWARD TSN is confirmed by the next SACK. CultNet's ack is not: it names the highest received sequence - plus a 32-bit mask, or one exact older sequence (`create_ack_for_received`, `rudp.rs:751-758`). A - cumulative notice could not be confirmed by that ack, which would mean a second wire field. So each - abandoned sequence gets its own notice, and the receiver answers it with the ack a reliable data packet - with that sequence would draw. That ack removes the sequence from the sender's abandoned set exactly as it - removes a data packet from pending. **Q-A7** puts the cumulative alternative to the operator. -- **No stream pairs.** One watermark `R` owns ordered delivery for every channel (Cut 1), so advancing `R` - and draining releases every channel's held frames. There is nothing per channel to name. -- **Negotiation: only if Q-A9 is B.** The ruling puts the notice in an Ack so an old peer reads it as an - ack (FN), and bounds the resend: an old receiver never acks the notice, and the sender stops after a - fixed number of sends. The Cut 2 Soul finding adds a reason to negotiate after all (Q-A9): a *receiver* - needs to know whether its peer will ever send notices. If Q-A9 is B, the sender also sends notices only - to a peer that advertised the bit (RFC 3758 §3.3), and an old receiver's sequence is stranded at once - instead of after the bound. The abandoned sequence is then *stranded*: the Cut 4 honest - report applies to it (ordered sends after it stay Pending, become Invalidated at the end, and flush fails - fast). That is the behaviour ruling A would have given everywhere; under B only old receivers get it. - -**Wire.** Packet type `4` (ack), flag bit 4 (`0x10`, "abandon"), and no other flag bit. Sequence field: the -abandoned sequence. Ack and ack mask: the sender's current ack state, so the notice is also a genuine ack. -Channel `control`, fragment fields `0`, empty payload. Decoders map type 4 with bit 4 to a new packet type, -**`Abandon`** (Rust `CultNetRudpPacketType::Abandon`, C# `CultNetRudpPacketType.Abandon`, TS `"abandon"`, -Python `CultNetRudpPacketType.ABANDON`, Kotlin `CultNetRudpPacketType.Abandon`), and the encoder maps it -back. Bit 4 on any other type is ignored, as today. No public packet struct gains a field, and no -downstream repo constructs packets or matches the type exhaustively (surveyed: Muninn tests compare -`== Data`; Mimir `CultMeshMedia` compares `Connect` and `Accept`). - -**Golden** (added beside the existing fixture in every runtime and in `docs/cultnet-transport-parity.md` -after the canonical fixture, `:505-517`): - -```text -packetType=abandon (wire: type 4, flags 0x10) -connectionId=0x01020304 -sequence=0x0000002a -ack=0x00000029 -ackMask=0x80000001 -channelId=control -payload=(empty) -hex=434e52300004102b010203040000002a0000002980000001000000000000000000000700636f6e74726f6c -``` - -**Sender (Rust now; any runtime that gains expiry under Q-A8).** - -- An expired packet, pending or queued, leaves the pending and queued sets as today and enters an - **abandoned set**: sequence, sends so far, last sent. It is due at once. -- `due_resends` emits a fresh notice for each due entry (built from the current ack state, not stored), - once per resend delay. After `RUDP_ABANDON_NOTICE_SENDS = 16` sends without an ack the entry leaves the set - and the session records the lowest such sequence as **`first_stranded`**. Sixteen sends at the default - 250 ms is four seconds. At 50% loss in each direction a round trip fails with probability 3/4, and all - sixteen with about 1%; at 20% each way, about 10^-7. The bound is for deaf receivers, not bad links, and - a new receiver that misses every notice degrades to the honest report, never to a lie. -- Any ack naming the sequence removes it from the abandoned set. That ack means the receiver holds the - sequence, from the original packet arriving late or from the notice; either way it is no longer a hole. -- Notices take no send-window slot and no payload bytes. For Cut 3's span rule, an abandoned sequence with - an outstanding notice counts as unacked (the receiver's `R` is held below it); a stranded one does not - (an old receiver has no `R` to hold, and counting it would stop the session after 1,023 more sequences). -- `outstanding_reliable_packet_count` counts abandoned entries, so a flush waits for their notices. -- The session-ending primitive (Cut 1b) and `reset_peer_state` clear the abandoned set and - `first_stranded`: they belong to the generation. - -**Receiver (all five runtimes).** - -- `receive` handles `Abandon` after applying its acks, as RFC 3758 §3.6 does: - - outside `[highest − 4,095, highest + 1,024]`: far-ahead is ignored without remembering (as Rust data - is, `rudp.rs:626-641`), far-behind is a duplicate; - - every incomplete fragment set whose sequence span contains the sequence is dropped (a set's span is - `sequence − fragment_index` for any fragment it holds, for `fragment_count` sequences), whether or not - the sequence was received: that frame can never complete; - - if the sequence was not received, it is remembered through `RememberReceived`, which advances `R` - (Cut 1), and held frames up to `R + 1` drain into `delivered`; - - `reply` is `create_ack_for_received(sequence)`, whether or not anything changed (the out-of-date case - still acks). -- Transports send the reply as they already do, and skip their own ack for an `Abandon` packet - (`rudp.ts:1089`, `transport.py:1087`, K:3243 would otherwise ack it a second time when the drain - delivered). - -**Interaction with the other cuts.** - -- **Cut 1 (`R`).** The notice is the only receive path besides data and Accept that calls - `RememberReceived`; it shares the drain. A late original of an abandoned packet is then a duplicate: acked - and dropped, as PR-SCTP drops it. -- **Cut 1b (ending).** An abandoned entry is a write of its generation; the ending primitive drops it. No - notice is ever sent into a later generation. -- **Cut 1c (generations).** A stale notice from an earlier generation of the same sender carries a - sequence below the new generation's Connect (issued sequences survive resets), so it is a duplicate. A - stale notice from a dead process on the same endpoint and connection id could mark a sequence of the new - process's session, exactly as a stale data packet can be delivered into it today; the random initial - sequence makes both land inside the 5,120-sequence acceptance range with probability about 2^-18. -- **Cut 2 (fragment eviction), from the Cut 2 Soul pass.** Cut 2 never evicts a reliable fragment set and - refuses the session when every pending set is reliable. Its claim that a conforming sender cannot reach - the 64-set bound is **false for an expiring sender**: fragment 0 arrives and is acked, the deadline drops - the rest, and the set is pinned for the session. Soul reproduced the refusal on the 65th lossy default - `media` frame (`soul_probe_expiring_reliable_frames_kill_receiver`, `packages/cultnet-rs/tests/cultnet.rs:3192` - at probe `3be97b34`). Before Cut 2, eviction kept that session alive. - - **With a Cut F sender** the notice for each dropped fragment lands inside the set's span and the - receiver drops the set: the rule above, explicitly "every incomplete set whose span covers a notified - sequence". Dead sets then live one round trip, not the session. - - **With a sender that never sends notices** (every build before Cut F) the receiver cannot tell an - expiring set from a set whose missing fragment is still coming. **Q-A9** decides what the receiver does - then; its recommendation is PR-SCTP's own answer, a capability bit on Connect and Accept (RFC 3758 - §3.1, Forward-TSN-Supported): Cut 2's never-evict rule applies to a peer that advertised it, and the - pre-Cut-2 stalest-set eviction stays for a peer that did not. - - So Cut 2 does not merge alone: it merges together with Cut F, which carries the capability and the - gate (§ Sequencing). -- **Cut 4.** Reads `first_stranded` where pass 2 read `first_abandoned`, and counts outstanding notices as - not yet Acknowledged. - -### 7. Interaction with the merged stray-packet work - -The ack cuts build on these behaviours and do not alter them: - -- A refusing session ends, and its goodbye is built after the reset (`EndRefused` - `CultNetTransport.cs:1315-1319`, `end_refused_session` `rudp.rs:364-367`). The refused sequence is never - acked, so a refusal never becomes a false Acknowledged. -- Issued sequences survive a reset in every runtime (`rudp.rs:341-343`, `CultNetTransport.cs:1292-1308`, - `rudp.ts:214-227`, `transport.py:458-471`). Cut 1c relies on it: a client's second Connect always - carries a new sequence. -- One Accept per generation, and a repeated Connect answered with the Accept still owed, or an Ack. Cut 1c - keeps the answer and moves the decision of what repeats into the session. -- An ended session fails its flush. Cut 1b generalises the TS and Rust binding to the generation into all - four runtimes. -- `5f1e883d` made a peer's Disconnect end Rust receipts (`rudp.rs:596-615`) and removed the - transport-level Pending→Invalidated override. Cut 1b makes the other ending paths agree with it. -- The TS operation service's expiry and handler rejection are above the transport and do not change. - -### 8. Session generation: why it is two cuts, and how a new one is recognised - -- **Why not inside Cut 1.** Cut 1 is a receiver change with a deletion line: one watermark replaces five - per-channel state machines. Its falsifiers are P1, P1b and P6. The generation work touches the ending - paths, the handshake, flush and receipts, and its falsifiers are G1-G3. Both touch `ResetPeerState` and - the Accept path, which is a merge cost, not a shared owner. Keeping them apart lets Soul falsify each - against its own probes. -- **Why two cuts.** The ending rule (Cut 1b) is ruled and needs no mechanism choice: every ending path - drops what it owed. How a new generation is recognised (Cut 1c) needs one (Q-A6). The two are separable - because 1b does not forget peer state: the peer may not know the session ended, and forgetting what was - received would let its retransmits be delivered twice. - **Correction (Cut 1/1b Soul, 2026-09-30): they are separable as specs, not as merges.** 1b drops owed - writes, which leaves holes the sender will never fill; the receiver keeps `R` across the ending, so if the - next handshake does not reset it, every later ordered frame is held and acked, and flush succeeds while - nothing is delivered. Only 1c's reset on a non-repeated handshake removes that. **1b merges only together - with 1c.** Soul also found `R` seeded by the first reliable packet rather than the handshake; ruled: - `R` is seeded only by the handshake, and reliable data before the Accept is neither acked nor delivered. -- **What must hold after both.** A write is Acknowledged or Invalidated within the generation it was - issued in. A restarted client is admitted. A new server session's frames are delivered after a - reconnect. A retransmitted Connect is still a repeat. -- **Recognising a new generation (Cut 1c, Q-A6 A, ruled).** The Connect's sequence identifies the - generation, and the initial sequence is random by default, as TCP's initial sequence number is - (RFC 9293 §3.4.1, RFC 6528). - - A Connect repeats exactly when it carries the sequence of the Connect that started the current - generation. Its retransmits do; a client's second `connect()` cannot, because issued sequences - survive resets; a restarted process almost never does, because it drew a fresh random initial - sequence. - - A stale duplicate of the accepted Connect, delayed in the network, still repeats: same sequence. - - Anything else ends the current generation and starts a new one, at both ends: the client forgets peer - state when it sends a Connect on a session that had a peer, and the server when it accepts a Connect - that does not repeat. - - A client honours an Accept only while its Connect is pending, and only if the Accept's ack field names - that Connect. A stale Accept from an earlier generation cannot seed `R`. - - The initial sequence is drawn from [1, 2^31), which leaves at least 2^31 sequences before the - exhaustion error (`rudp.rs:944-962`) in every runtime. An explicit `initial_sequence` still works, for - tests. - - The Connect payload stays application evidence (the provider layer's `clientSessionId`, - `cultnet-rs/src/provider_session.rs:70-79`), carried to the application as today. It no longer decides - anything in the transport. - -### 9. Receipts in C#, TypeScript, Python and Kotlin (Q-A4 A, ruled) - -- **One design, ported.** Cut 4 builds it in Rust: a receipt carries the sequences its send assigned, - whether it was ordered, and a status cell the session writes once. The session keeps the unresolved - receipts and resolves them after every ack it applies (Acknowledged: ordered when `A` reaches its last - sequence, unordered when every sequence is acked) and in the ending primitive (Invalidated). The four - ports copy that shape; none invents a second one. -- **What every runtime has to change first** (the receipts survey, `e9469cb3`): - - `SendMany`/`sendMany`/`send_many` returns only the packets admitted to the 32-packet window - (`CultNetTransport.cs:1439-1465`, `rudp.ts:586-592`, `transport.py:776-786`, K:2856-2862). A receipt - must be built from every sequence the send *assigned*, queued ones included, which is Rust's P10. - - `ApplyAcknowledgements` only deletes from the pending map (`CultNetTransport.cs:1503-1516`, - `rudp.ts:610-617`, `transport.py:803-807`, K:2882-2889). Resolution hooks in after it. - - Invalidation needs the ending primitive. C#, TS and Python get it in Cut 1b; Kotlin in K2. -- **Where the receipt lives.** On the single-peer socket transport connection, as in Rust - (`CultNetRudpSocketTransportConnection::send_reliable`, `rudp.rs:1903-1930`). The Rust hub has no - receipts, so neither do the C# listener (`CultNetRudpSocketTransportServer`, `:2487`), `cultmesh-ts`'s - document server or `cultmesh-py`'s server. Hub receipts are a follow-up for all five together. -- **Public API, per runtime.** Every runtime's RUDP surface is synchronous-with-timeout except TypeScript's, - which is Promise-and-event. Each port matches its own runtime: - -| | Send | Receipt | Status | Wait | -|---|---|---|---|---| -| Rust (Cut 4) | `send_reliable(&mut self, channel, payload) -> Result` | `packet_sequences()` | `reliable_send_status(&receipt) -> CultNetRudpReliableSendStatus` | `wait_acknowledged(&receipt, timeout) -> Result<()>` | -| C# (6a) | `CultNetRudpSendReceipt SendReliable(string channelId, byte[] payload)`; `SendSchema(...)` and `SendSchemaMessage(...)` return the receipt instead of `void` (source-compatible) | sealed class, `IReadOnlyList PacketSequences` | `receipt.Status` (`CultNetRudpSendStatus { Pending, Acknowledged, Invalidated }`), read without the transport | `void WaitAcknowledged(CultNetRudpSendReceipt receipt, TimeSpan? timeout = null)`, the `FlushReliable` loop (`:1914-1955`); throws `InvalidOperationException` naming the end reason when Invalidated, `TimeoutException` at the deadline | -| TypeScript (6b) | `sendReliable(channelId: string, payload: Uint8Array): CultNetRudpSendReceipt`. `send` keeps `void`, because the transport interface declares it (`transport.ts:132-142`) | `readonly packetSequences: readonly number[]` | `receipt.status: "pending" \| "acknowledged" \| "invalidated"` (string union, as packet types are) | `waitAcknowledged(receipt, timeoutMs = 30_000): Promise`, polling like `flush` (`rudp.ts:911-935`); rejects with the end reason when invalidated | -| Python (6c) | `send_reliable(self, channel_id: str, payload: bytes) -> CultNetRudpSendReceipt` | frozen-looking object, `packet_sequences: tuple[int, ...]` | `receipt.status` (`CultNetRudpSendStatus` enum: `PENDING`, `ACKNOWLEDGED`, `INVALIDATED`) | `wait_acknowledged(self, receipt, timeout_seconds: float = 30.0) -> None`, the `flush_reliable` loop (`:1101-1131`); raises `ConnectionError` when invalidated, `TimeoutError` at the deadline | -| Kotlin (K4) | `fun sendReliable(channelId: String, payload: ByteArray): CultNetRudpSendReceipt`; `sendSchema`/`sendSchemaMessage` return it | `val packetSequences: List` | `receipt.status` (`enum class CultNetRudpSendStatus { Pending, Acknowledged, Invalidated }`), `@Volatile` | `fun waitAcknowledged(receipt, timeoutMs: Long = 30_000, pollIntervalMs: Long = 5)`, the `flushReliable` loop (K:3186-3205); throws `IOException` when invalidated, `SocketTimeoutException` at the deadline | - - - The status is on the receipt, not a transport query, in the four ports: a C#, TS, Python or Kotlin - caller reading `receipt.Status` is the idiom there, and it is what Rust's cell already is underneath. - Rust keeps `reliable_send_status` because its signature is public and used (Cut 4, Unchanged). - - `SendReliable` refuses a channel whose send options are not reliable (as Rust's `send_reliable` does, - `rudp.rs:1903-1930`). If Q-A8 brings expiry to a runtime, it refuses an expiring channel too, as Rust's - does after Cut 4 (P9). - - A receipt from an ended session is Invalidated and stays so; `WaitAcknowledged` on it fails at once. -- **Thread safety.** C# resolves under `_pendingReliableGate` (`:915`) and publishes the status with a - volatile write; Kotlin marks the field `@Volatile`; TS and Python are single-threaded per transport. -- **Docs.** Each runtime's README RUDP section gains the three states and the wait - (`src/GameCult.Networking/README.md`, `packages/cultnet-ts/README.md:24-25`, - `packages/cultnet-py/README.md:103-111`, `packages/cultmesh-kotlin/README.md:229-305`), and the parity - doc's flush paragraph (`docs/cultnet-transport-parity.md:260-273`) names receipts in all five. - -### 10. A failed send to one peer is that peer's lost datagram (Cut D; from the Odin Soul pass) - -- **Finding.** `CultMeshRudpDocumentServer::poll_once` begins with `self.maintain()?` - (`cultmesh-rs/src/rudp_document_server.rs:264`). `maintain` sends every peer's due resends and returns on - the first failed `send_to` (`:392-398`, through `send_packet` `:628-632`). Every per-peer send in - `poll_once` does the same: the reply (`:334-336`), the Accept (`:451`), a snapshot response (`:586-588`), - the goodbye (`:597-604`) and the ack (`:366-373`). - - So one peer whose datagrams cannot be sent fails every poll for every peer. Its resends come due every - 50 ms (`:158`); a poll loop that pauses longer than that between attempts never gets past `maintain` - again while the peer lives, and a peer that keeps sending never idles out (`:384-388`). - - Odin `origin/main` (`crates/odin-daemon/src/main.rs:661-675`) propagates any `poll_once` error, so - today the daemon exits on the first one; the Odin Soul pass reports a branch that retries every 100 ms - and exits after 30 s of failures. Either way one bad peer takes Odin down. - - The same socket is **non-blocking** (`:230`), so `send_to` also fails with `WouldBlock` when the send - buffer is full: a burst of snapshot responses to one peer can fail a poll for everyone with no bad peer - at all. -- **Rule: a send failure is a lost datagram, attributed to its peer.** It is counted and the poll goes on. - RUDP already recovers lost datagrams: the reliable packet stays pending and is resent; an unreliable one - was allowed to be lost. The peer's session ends by the rules that already end sessions: idle timeout, - maximum lifetime, a refusal or a Disconnect. This is TCP's treatment of ICMP unreachables as soft errors - (RFC 1122 §4.2.3.9): report them, do not abort the connection on them. - - Only failures that are not about one peer stay errors: `recv_from` failing with anything but - `WouldBlock` or `ConnectionReset` (Windows reports an earlier ICMP port-unreachable on the *next* - receive; the socket transport already treats it as nothing, `rudp.rs:2059-2066`, the document server does - not, `:266-272`), and encode failures, which are the server's own bug. - - Rejected: ending the peer's session on its first failed send. `WouldBlock` is transient and not the - peer's fault; ending on it would drop healthy peers under load. -- **Same shape elsewhere** (multi-peer servers only; a single-peer transport's failed send is already only - that peer's): - -| Server | Where one peer's failed send stops the others | Change | -|---|---|---| -| cultmesh-rs document server | as above | Cut D | -| Rust hub `CultNetRudpServerHub` | `poll_resends` returns on the first failure (`rudp.rs:1762-1777`); the receive path's sends to one peer abort `receive_event_once` (`:1644`, `:1673`, `:1708`, `:1711`, `:1714`, `:1759`, through `send_packet` `:1799-1804`) | Cut D | -| C# `CultNetRudpSocketTransportServer` (and `RudpCultNetSchemaServer` over it) | `PollResends` walks every peer and the first `SocketException` from `SendTo` (`CultNetTransport.cs:2829-2834`) escapes the loop (`:2796-2805`); `TryReceiveOnce`'s sends are unguarded except the refusal goodbye (`:2687`, `:2704`, `:2749-2750`, `:2788`; guarded `:2739-2745`) | Cut D | -| cultmesh-py server | worse: an `OSError` from `sendto` (`server.py:302-307`) in `_poll_rudp_resends` (`:277-285`) or the receive path escapes `_rudp_loop` (`:203-…`, which catches only `recvfrom`'s errors), and the RUDP thread dies for every peer | Cut D | -| cultmesh-ts document server | none. **Corrected 2026-09-30:** Node does not report send failures on the socket's `error` event. With a callback they go to the callback; without one, libuv drops them silently (Node 24). Only port 0 throws synchronously. Cut D routes every send through `sendRudpDatagram`. | none | -| Kotlin interop server | none that matters: a catch-all logs and continues (K:4025), and it is interop-only | none (Cut K1 reviews it) | - - -## Cuts - -Every cut is on CultLib, on its own branch (`hands/ack-cut`) from `main` at `e9469cb3` or later, in a -worktree Self creates. Heavy verification runs on Yggdrasil. Each cut starts by committing its probes as failing -tests named for the rule, in every runtime it touches. The pass-1 and pass-2 probe files -(`refs/verify/1519a20a` on the `CultLib-imag-ack2` mirror) are the starting point; they print, so each -must become an asserting test. - -Kotlin: every numbered cut below is mapped for C#, Rust, TS and Python. Cut K (Q-A5 A) brings Kotlin to -the same state on a Yggdrasil Kotlin image, in steps K0-K5. - -**Negative checks that stay green in every cut:** - -- the cross-runtime reorder, drop and fragment proofs in the TS interop harness - (`docs/cultnet-transport-parity.md:227-248`); -- the stray-packet tests (`packages/cultnet-rs/tests/rudp_stray_packets.rs`, and their C#, TS and Python - equivalents), except the ones each cut names as encoding the old rule; -- the codec fixture vectors: the existing fixture's bytes never change. Cut F adds one fixture. - -### Cut 1. One watermark owns ordered delivery (receiver) — in flight (`hands/ack-cut1`) - -- **First.** Failing tests P1, P1b and P6 in each runtime. -- **Deletes first:** - - the per-channel `next` map and its resets: `CultNetTransport.cs:918`, `:1305`; `rudp.rs:196`, `:223`, - `:354`; `rudp.ts:160`, `:223`; `transport.py:424`, `:468`; `CultMesh.kt:2643`; - - `expectedSequenceIfUninitialized`: `CultNetTransport.cs:1151-1153`, `rudp.rs:540-543` (used at - `:679`), `rudp.ts:375-377` (used at `:450`), `transport.py:595-599`, `CultMesh.kt:2728`; - - `DeliverOrdered`, `DrainOrdered` and `SkipReceivedNonChannelSequences`: `CultNetTransport.cs:1628-1700`, - `rudp.rs:1138-1246`, `rudp.ts:737-800`, `transport.py:868-920`, `CultMesh.kt:2939-2978`; - - `PendingOrderedFrame.NextSequence` (`rudp.rs:160-163` and equivalents). -- **Adds:** - - `R`, seeded in `AcceptConnect` (`CultNetTransport.cs:1012`, `rudp.rs:383`, `rudp.ts:242`, - `transport.py:485`, `CultMesh.kt:2667`) and on Accept receipt (`CultNetTransport.cs:1155`, - `rudp.rs:544`, `rudp.ts:379`, `transport.py:601`, `CultMesh.kt:2730`); - - `R` advances in `RememberReceived` (`CultNetTransport.cs:1518`, `rudp.rs:973`, `rudp.ts:619`, - `transport.py:809`, `CultMesh.kt:2891`) and resets in `ResetPeerState`; - - a reassembled ordered frame is delivered at once when its first sequence is at most `R + 1` and its - channel holds nothing below it. Otherwise it is held. The caps apply only to what is held: the - prototype held everything and so refused a 5 MiB frame with no gap; - - after every reliable receipt (data, fragment, duplicate, Accept), drain every channel's held frames - whose first sequence is at most `R + 1`, in sequence order; - - Rust only: the 64-channel cap (`rudp.rs:42`) counts channels with held frames. -- **Tests changed:** `packages/cultnet-rs/tests/cultnet.rs:1000` (consistent handshake) and `:2655` - (hold frames behind a gap). The equivalents in the other runtimes are whatever the change breaks. Each - must be read before it is edited, because a test that encodes `min(highest+1, frame)` encodes P6. -- **Verification:** - - P1, P1b and P6 pass in every runtime; - - the full suites: `cargo test` in `cultnet-rs` and `cultmesh-rs`, `dotnet test - tests/GameCult.Networking.Tests`, `npm test` in `cultnet-ts`, the Python suite; - - the TS interop harness across runtimes; - - negative grep: `rg -n "orderedNextSequence|ordered_next_sequence|expectedSequenceIfUninitialized|expected_sequence_if_uninitialized|SkipReceivedNonChannel|skip_received_non_channel" src packages` - returns nothing; - - mutation testing on the diff: cargo-mutants, Stryker.NET, StrykerJS, and mutmut for Python. -- **Ledger.** Per runtime about −70 and +40. Across four, about −280 and +160. - -### Cut 1b. A write belongs to the session it was issued in: every ending drops what it owed — in flight (`hands/ack-cut1`) - -- **First.** Failing tests G3 (each ending path: peer Disconnect, local disconnect, timeout, refusal) in - C#, TS and Python, and local disconnect and timeout in Rust; G3R in Rust; and in every runtime, a flush - started before a timeout or disconnect fails even after a later `connect()` succeeds. -- **The owner.** Each session gets a generation counter and one private primitive that ends the current - generation: not connected; pending and queued dropped; generation advanced. In Rust it also invalidates - the generation's receipts (by the scope today; Cut 4 moves that into the receipts). It does not touch - what was received from the peer (§8). -- **Deletes first:** - - Rust: the inline clearing in the Disconnect branch (`rudp.rs:596-615`) and the scope rotation in - `reset_peer_state` (`:345`), both replaced by the primitive; the receipt doc that says local endings - carry writes (`rudp.rs:128-133`); the flush's scope capture (`:2001-2014`), replaced by the generation; - - TS: the transport's `#generation`, `#endedGeneration`, `#endGeneration` (`rudp.ts:826-831`, - `:937-940`) and their uses in `connect` (`:895`), `flush` (`:913-920`), `checkTimeout` (`:949`), - `#endRefusedSession` (`:976`), the server Connect path (`:1037-1046`) and the disconnect result - (`:1084`). `#endedReason` stays, as the report of why; - - C# and Python: flush's reliance on the disconnect reason (`CultNetTransport.cs:1924-1929`, - `transport.py:1110-1116`). The reason stays, as a report. -- **Adds:** - - the primitive, called from every ending path: - - peer Disconnect: `CultNetTransport.cs:1190-1199`, `rudp.rs:596-615`, `rudp.ts:406-414`, - `transport.py:619-625`; - - local disconnect: `CreateDisconnect` `CultNetTransport.cs:1324-1328`, `create_disconnect` - `rudp.rs:771-781`, `createDisconnect` `rudp.ts:508-515`, `create_disconnect` `transport.py:695-697`; - - timeout, when it fires: `CultNetTransport.cs:1333-1348`, `rudp.rs:783-796`, `rudp.ts:517-526`, - `transport.py:699-706`; - - refusal, through `ResetPeerState` (`CultNetTransport.cs:1292-1308`, `rudp.rs:344-358`, - `rudp.ts:214-227`, `transport.py:458-471`); - - a read-only generation on each session, which each transport's flush captures at start and fails on - when it changes (`CultNetTransport.cs:1914-1945`, `rudp.rs:1992-2040`, `rudp.ts:911-935`, - `transport.py:1101-1124`). -- **Hubs.** The Rust hub and the C# listener already discard a peer's session at its end, so its owed - writes die with it. No change. -- **Tests changed:** `tests/rudp_stray_packets.rs:638-690` keeps passing unchanged (peer Disconnect already - obeys the rule). Tests that expect a write to survive a local disconnect or timeout encode the old rule; - read each before editing. -- **Verification:** - - G3 in every runtime: after every ending path, owed 0 and nothing delivered to the next session; - - G3R: the receipt reads `Invalidated` after `disconnect()`, and stays so after reconnecting; - - the flush test above in every runtime; - - negative: `rg -n "endedGeneration|#endGeneration" packages/cultnet-ts/src` returns nothing; a TS - reconnect from inside a `disconnect` listener still cannot make an ended flush succeed (the case the - TS generation pair was written for, `rudp.ts:826-829`); - - mutation testing on the diff. -- **Ledger.** About −40 and +45 across four runtimes. TS is net negative. - -### Cut 1c. A Connect's sequence says whether it repeats — ready after Cut 1b (Q-A6 A, ruled) - -Pass 3 changes against pass 2: the ruling; three more servers that decide repeats themselves (the -cultmesh-rs and cultmesh-ts document servers and the cultmesh-py server); the second C# default of 100; -the exact default mechanism; the full caller survey; `cultmesh-rs/src/lib.rs:1409` removed from the -production list (it is inside `#[cfg(test)]`, which starts at `:1140`). - -- **Repo/branch:** CultLib `hands/ack-cut1c` from `main` after Cut 1b merges. It uses the ending primitive. -- **First.** Failing tests: - - G1: a restarted client on the same address, connection id and payload is admitted and its frames - delivered, against the Rust hub, the C# listener, server mode in every runtime, the cultmesh-rs - document server (same `(addr, connection_id)` key), the cultmesh-ts document server (same payload) and - the TS operation service; - - G1b: C# and Python server mode admit a Connect from a new endpoint; - - G2: after `connect()` on the same session, a new server session's frames are delivered; - - a stale Accept (its ack field does not name the pending Connect) is ignored; - - the cultmesh-py server and Rust server mode: a *retransmitted* Connect after data has flowed does not - reset the session (today both reset on every Connect). -- **Deletes first:** - - the transport-level repeat decisions: Rust server mode's reset on every Connect (`rudp.rs:2105-2116`); - the Rust hub's payload comparison (`rudp.rs:1637-1647`); C# server mode's `_session.Connected` branch - (`CultNetTransport.cs:2226-2236`); the C# listener's payload comparison (`:2670-2688`); TS's - `movedEndpoint`/`repeated` computation (`rudp.ts:1011-1049`) and the session's `connected` shortcut - (`rudp.ts:249-251`); Python's `connected` branch (`transport.py:1047-1053`); - - **new in pass 3:** the cultmesh-rs document server's "same key is a repeat" arm - (`cultmesh-rs/src/rudp_document_server.rs:413-427`, and its comment at `:414-415` that asks a fresh - client to choose a fresh id); the cultmesh-ts document server's `connectPayload` comparison and field - (`cultmesh-ts/src/index.ts:5794-5802`, `:5806`); the cultmesh-py server's replace-on-every-Connect - (`cultmesh-py/src/cultmesh_py/server.py:225-240`); - - C# and Python server mode's refusal of a Connect from a new endpoint (`CultNetTransport.cs:2212-2216`, - `transport.py:1042-1044`), for Connect packets only. -- **Adds:** - - the session records the sequence of the Connect that started its generation. A Connect repeats exactly - when the session is connected and the Connect carries that sequence. `AcceptConnect` answers a repeat - as `AnswerRepeatedConnect` does today, and otherwise ends the generation, resets peer state and accepts - (`CultNetTransport.cs:1012-1059`, `rudp.rs:383-435`, `rudp.ts:242-290`, `transport.py:485-525`). - `AnswerRepeatedConnect` stops being public; a public predicate `ConnectRepeats(packet)` / - `connect_repeats` / `connectRepeats` serves servers that keep one session per peer and must report the - old one ended (the Rust hub `rudp.rs:1648-1690`, the C# listener `:2690-2710`, the cultmesh-rs document - server). Servers that only call `AcceptConnect` (TS operation service `operation-service.ts:167-175`, - cultmesh-ts document server, cultmesh-py server, server-mode transports) need nothing else: the session - decides; - - `CreateConnect` on a session that has had a peer ends the generation and resets peer state first - (`CultNetTransport.cs:1001-1010`, `rudp.rs:369-381`, `rudp.ts:229-240`, `transport.py:473-483`); - - on Accept receipt, the session honours it only while its Connect is pending and only if the Accept's - ack field names that Connect (`CultNetTransport.cs:1155-1160`, `rudp.rs:544-557`, `rudp.ts:379-390`, - `transport.py:601-604`); - - **the default initial sequence is drawn from a CSPRNG in [1, 2^31)** wherever a default is produced. - The option types do not change (`u32`/`uint`/`number`/`int`), so every explicit value keeps working and - no caller changes code. One private helper per runtime: - - Rust: `rand::random_range(1..1u32 << 31)` (`rand` 0.9 is already a dependency, - `packages/cultnet-rs/Cargo.toml`), in `CultNetRudpSessionOptions::default` (`rudp.rs:108`), - `CultNetRudpSocketTransportOptions::client()` (`:1310`) and `::server()` (`:1329`), - `CultNetRudpServerHubOptions::new()` (`:1377`), and `CultMeshRudpSocketOptions::default` - (`cultnet-rs/src/cultmesh.rs:259`); - - C#: `RandomNumberGenerator.GetInt32(1, int.MaxValue)` as the property initializer at - `CultNetTransport.cs:773`, `:850`, **`:2404` (the listener's 100)**, **`CultNetRudpSchemaServer.cs:48` - (a second 100)** and `src/GameCult.Mesh/CultMesh.cs:547`; - - TypeScript: `crypto.getRandomValues` in the session constructor's `options.initialSequence ?? …` - (`rudp.ts:172`); `cultmesh-ts`'s optional `initialSequence` (`index.ts:4336`) already falls through to it; - - Python: `secrets.randbelow(2**31 - 1) + 1` as a `default_factory` at `transport.py:298`, `:323`, and - as the default of `client.py:396` and `cultmesh-py/src/cultmesh_py/facade.py:160`, `:194` (keyword - defaults become `None` meaning "draw one", since a Python default is evaluated once); - - Kotlin: in Cut K2; - - CultLib's own production pins take the default: `cultmesh-rs/src/lib.rs:964` (client), - `cultmesh-rs/src/rudp_document_server.rs:432` (server). The two TS publishers - (`signed-daemon-health.ts:116`, `idunn-odin-presence-publisher.ts:103`) lose theirs in whichever of - Cut 5 or Cut 1c lands second. Interop peers, the parity tool and tests keep explicit values on purpose. -- **Tests changed** (they encode payload identity or a fixed default): - - `packages/cultnet-rs/tests/rudp_server_hub.rs:171-240` calls `connect()` again with the same payload - and expects no replacement; under this rule that is a new generation. Its retransmit half stays covered - by `rudp_stray_packets.rs:487`; - - `tests/GameCult.Networking.Tests/NetworkingTests.cs:1507` (replace a peer by payload) passes but must - say it relies on distinct sequences; `:700` asserts `PendingReliableSequences == {100}` against the - listener's default; - - asserts that may rely on a default Connect sequence of 1 (read each; pin `1` in the test if it does not - already): `cultnet-rs/tests/cultnet.rs:574`, `:820`, `:851-852`; `cultnet-ts/test/cultnet.test.ts:472`, - `:576`, `:592-593`, `:1536`; `cultnet-py/tests/test_cultnet.py:596`, `:764`, `:779-780`; - - `cultnet-ts/test/cultnet.test.ts:2225` (another endpoint replaces the peer) stays. -- **Verification:** - - G1 (every server above), G1b, G2, the stale Accept and the retransmitted-Connect tests; - - the retransmit tests stay green: `rudp_stray_packets.rs:487`, `:511`, `NetworkingTests.cs:1483`, - `cultnet.test.ts:2119`, `:2134`, `test_cultnet.py:1134`; - - a test per runtime that two default-constructed sessions draw different initial sequences in [1, 2^31); - - negative grep: `rg -n "SequenceEqual\(connectPayload\)|connect_payload == packet.payload|movedEndpoint|byteArraysEqual\(record.connectPayload" src packages` - returns nothing; - - mutation testing on the diff. -- **Ledger.** About −90 and +85 across four runtimes and the three servers. Two CultLib production pins go. - -**Pin-bump notes: callers outside CultLib that pin an initial sequence** (survey, 2026-09-30). A pinned -value keeps a deterministic Connect sequence. It matters on a **client that can restart on the same -endpoint and connection id** (the G1 lockout survives there); on a server or a one-shot client that binds a -fresh port per run it only forgoes the stale-packet protection. Recommendation at each repo's bump: delete -the value. - -| Repo@rev | Site | Value | Role | Consumes CultLib by | -|---|---|---|---|---| -| Muninn@`bd69598` | `crates/muninn-daemon/src/main.rs:5975`; `crates/sleipnir-daemon/src/main.rs:2223` | 1 | client (restart risk) | Cargo pin `c2a9a6e5` | -| Muninn@`bd69598` | `muninn-daemon/src/main.rs:780`, `:5426`; `sleipnir-daemon/src/main.rs:2265` | 1 | server-mode transports | same | -| Gjallar@`6a92976` | `src/Gjallar/Program.cs:431`, `:2955`, `:3027` | 1 | clients (restart risk) | sibling `../CultLib` | -| Mimir@`d88f2e6` | `src/Mimir.EveBrowserReference/Program.cs:682`, `src/Mimir.EveDashboard/Program.cs:801` | 1 | clients (restart risk) | sibling ProjectReference | -| Mimir@`d88f2e6` | `src/Mimir.CultMeshMedia/Program.cs:485` | `peers.Count + 1` | hand-rolled per-peer relay; its Connect handling (`:365`) is its own repeat decision | same | -| weksa@`d16cff5` | `scripts/weksa-rudp-command.cjs:88` (per-peer server loop), `:192` (client); `scripts/idunn-rudp-health.cjs:43` | 1 | server loop and clients | sibling CultLib | -| Bifrost@`42728a6` | `tools/persona-discord-rudp.mjs:9` | 100 | server-mode transport | sibling CultLib | -| Heimdall@`e8e2832` | `src/idunn-rudp-health.ts:65` | 1 | one-shot health client (replaced at its bump, § Sequencing) | submodule `b6b1d9c` | -| Stonks@`981c484`, Vili@`8773c15`, VoidBot@`46d891b` | `src/idunn-rudp.cjs:43`, `scripts/idunn-rudp.cjs:33`, `scripts/publish-idunn-rudp-health.cjs:64` | 1 | one-shot health clients | `file:../CultLib` / sibling path | - -- None in Odin `origin/main` (`5c37860`; Sleipnir now lives in Muninn), Idunn, Hermodr, CodexConnector, - Ghostlight, Huginn or Epiphany. StreamPixels' own code has none; its vendored CultLib (`542ddd3`, at - StreamPixels `a49f7d8`) carries CultLib's own old defaults and pins, which a bump replaces. -- Sibling-path consumers (Gjallar, Mimir, Stonks, Vili, VoidBot, weksa, Bifrost) take the random default - as soon as the local CultLib checkout moves; their pinned sites do not change behaviour until edited. - -### Cut 2. A reliable fragment set is never evicted (receiver: Rust, TS, Python) — in flight (`hands/ack-cut2`); merges with Cut F - -- **First.** Failing test P5 in each of the three. -- **Change:** - - eviction picks the stalest set that holds no reliable fragment (`rudp.rs:1027-1047`, - `rudp.ts:679-692`, `transport.py:836-842`); - - if every pending set holds reliable fragments, the packet is refused and the session ends, as every - other refusal does; - - ~~a conforming sender cannot reach that bound~~ (false for an expiring sender; see the pass 3 - correction below): its window keeps at most 32 reliable packets in flight, and the bound is 64 sets. -- **Verification:** P5 delivers the reliable frame. `d3bc6e66`'s test (lossy fragment sets keep being - evicted) stays green. `fragment_sets_evicted` still counts evictions. -- **Ledger.** About −3 and +12 per runtime. -- **Pass 3 correction (from the Cut 2 Soul pass on `hands/ack-cut2` `c5026aa1`).** The third bullet above - is false for an expiring sender: the default Rust `media` channel expires reliable packets after 75 ms, - a frame's first fragment is delivered and acked, the rest are dropped by the deadline, and the set is - pinned; Soul's `soul_probe_expiring_reliable_frames_kill_receiver` (`packages/cultnet-rs/tests/cultnet.rs:3192` - at `3be97b34`) refuses the session on the 65th such frame, where eviction used to keep it alive. - - **What changes for the branch in flight:** nothing in its code. Its rule is right for every sender that - does not expire. What changes is when it merges: **Cut 2 merges only together with Cut F**, which - releases dead sets through notices and (Q-A9 B) keeps pre-Cut-2 eviction for a peer that never sends - notices. Soul's probe becomes Cut F's regression test. - - C# (`CultNetTransport.cs:921`) and Kotlin (K:2645) have no fragment-set bound at all. **Cut 2c** brings - C# to the same bound; Kotlin gets it in K1 and the gated rule in K3. - -### Cut 2c. C# gets the fragment-set bound (with Cut 2's rule) — merges with Cuts 2 and F - -- **Why in this campaign.** Rust, TS and Python bound pending fragment sets at 64 (`d3bc6e66` lineage; - `rudp.rs:328-340`, `rudp.ts:167`, `transport.py:430`); C# keeps `_fragmentBuffers` - (`CultNetTransport.cs:921`) unbounded, so a hostile peer grows it without limit and the parity doc cannot - call C# conforming. A runtime missing a sibling's protection is a gap to fill. -- **Repo/branch:** CultLib `hands/ack-cut2c`, from `main`; merges together with Cuts 2 and F (the gate - lives in F). -- **First.** C# ports of `d3bc6e66`'s lossy-set test and Cut 2's P5 test. -- **Adds:** `MaxPendingFragmentSets` (default 64, a setter as Rust's `set_max_pending_fragment_sets`, - `rudp.rs:328-340`), a per-set last-touched ordinal, eviction of the stalest set in `Reassemble` - (`:1556`), `FragmentSetsEvicted` beside `OutstandingReliablePacketCount` (`:993`), and Cut 2's rule (a - reliable set is not evicted; if every set is reliable the session is refused through `EndRefused`), - gated as in Cut F. -- **Verification:** the two tests; `GameCult.Networking.Tests` green; Stryker.NET on the diff. -- **Ledger.** About +45 and 0. - -### Cut 3. The sender's flow window: 1,023 sequences and 4 MiB above the lowest unacked — ready (merge after Cut 1) - -- **First.** Failing tests P8 (all runtimes) and P4 (Rust receiver, with a sender from each runtime). -- **Change.** Admission (`AdmitReliablePackets` / `PromoteQueuedReliable` at - `CultNetTransport.cs:1439-1490`, `rudp.rs:910-942`, `rudp.ts:586-600`, `transport.py:776-796`, - `CultMesh.kt:2856-2872`) admits a packet only while: - - the window has a slot (as today); - - its sequence is at most the lowest unacked sequence plus 1,023; - - the admitted payload bytes above the lowest unacked sequence stay within 4 MiB. - - The first packet is always admissible. Expired packets (Rust) do not count as unacked here: they are - gone from the wire. (Cut F refines this: an abandoned sequence counts while its notice is outstanding, - and stops counting once acknowledged or stranded.) -- **Contract.** `docs/cultnet-transport-parity.md` (after `:263`) states the receive window: a receiver - must hold 1,023 sequences and 4 MiB beyond its contiguous watermark, and a conforming sender never - exceeds that. -- **Verification:** - - P8: `g` is delivered; - - P4: the 5 MiB frame is delivered after the gap fills, and the session is never refused; - - the existing large-snapshot tests (`c398bad1`) and the fragment interop stay green; - - the Rust benchmark or media probe shows no throughput change on a lossless link. -- **Ledger.** About +25 per runtime, and nothing removed. - -### Cut D. A failed send to one peer is that peer's lost datagram (Rust document server and hub, C# listener, cultmesh-py server) — ready - -Design in §10. Independent of every other cut; it touches send sites, not session logic. - -- **Repo/branch:** CultLib `hands/ack-cutD` from `main` at `e9469cb3` or later. Merge cost only with Cut 1c - in the Rust hub's and C# listener's Connect arms. -- **First.** Failing tests, one per server, each with two peers where every send to peer X fails: - - cultmesh-rs document server: `poll_once` never returns `Err`; peer Y connects, publishes, is acked and - gets a snapshot response; `maintain` returns `Ok`; the failure count rises; X's session ends by idle - timeout, not by the failure. Also: `recv_from` returning `ConnectionReset` is `Idle`; - - Rust hub: `poll_resends` and `receive_event_once` return `Ok` and keep serving Y; - - C# listener: `PollResends` reaches Y after X throws; `TryReceiveOnce` serves Y; - - cultmesh-py server: the RUDP thread survives an `OSError` from `sendto` and keeps serving Y. - - **The failure seam.** The Rust servers own a `UdpSocket` directly, and a loopback peer's address - cannot be made to fail on demand. Add the narrowest seam at the one send function: a - `#[cfg(test)]` set of addresses whose sends fail with a synthetic `io::Error` in `send_packet` - (`rudp_document_server.rs:628-632`, `rudp.rs:1799-1804`), and the same as an internal test hook in C# - `SendPacket` (`CultNetTransport.cs:2829-2834`). Python patches `socket.sendto` in the test. A socket - port trait would be the full dependency-injection answer; it is not bought here, because the only - consumer is this test. -- **Changes:** - - cultmesh-rs `rudp_document_server.rs`: `send_packet` (`:628-632`) keeps encode errors as errors and turns - a `send_to` failure into a counted loss; every per-peer call site drops its `?` on the send - (`:335`, `:373`, `:397`, `:451`, `:587`, `:603`); a `send_failures()` accessor beside `packets_dropped()` - (`:246-248`); `recv_from` treats `ConnectionReset` like `WouldBlock` (`:266-272`), as the socket - transport does (`cultnet-rs/src/rudp.rs:2059-2066`); - - cultnet-rs hub: `send_packet` (`rudp.rs:1799-1804`) likewise, counted in `CultNetTransportStats` - as a new `send_failures` field; `poll_resends` (`:1762-1777`) and the receive path (`:1644`, `:1673`, - `:1708`, `:1711`, `:1714`, `:1759`) stop propagating it; - - C# `CultNetRudpSocketTransportServer`: `SendPacket` (`:2829-2834`) catches `SocketException`, counts it - in `CultNetTransportStats.SendFailures`, and returns; `PollResends` (`:2796-2805`) and `TryReceiveOnce`'s - sends (`:2687`, `:2704`, `:2749-2750`, `:2788`) need no other change; the refusal goodbye's own catch - (`:2739-2745`) becomes redundant and goes; - - cultmesh-py `server.py`: `_send_rudp_packet` (`:302-307`) catches `OSError` and counts it. -- **Not changed:** single-peer socket transports (a failed send already concerns only their one peer, and - their callers, flush among them, get the error); `cultmesh-ts`'s document server. (Corrected 2026-09-30: Node reports send failures only to a send - callback, never on the socket's `error` event; see the table above.) -- **Authority map:** - - Owner: each peer's session owns its peer's fate (idle timeout, lifetime, refusal, Disconnect). A send - failure is an input to nothing but a counter. - - Forbidden writers: no per-peer send failure ends a poll, a loop, a thread or another peer's session. -- **Verification:** - - the four tests; the full `cultmesh-rs`, `cultnet-rs`, `GameCult.Networking.Tests` and `cultmesh-py` - suites; - - negative: `rg -n "send_packet\(.*\)\?;" packages/cultmesh-rs/src/rudp_document_server.rs` returns - nothing (the pattern matches only a propagated send; encode errors propagate inside `send_packet`); - - operator: an Odin build on this CultLib keeps serving presence while one peer's address is - unroutable. -- **Ledger.** About −15 and +40 (the counters, the seams); tests about +120. - -### Cut F. Abandonment notices (FORWARD-TSN, RFC 3758): every receiver honours one, Rust sends one — blocked on Cuts 1 and 3, on Q-A7 and Q-A9; merges together with Cut 2 - -Design in §6. Mapped for the recommended answers to Q-A7 (one sequence per notice) and Q-A9 (a capability -bit gates Cut 2's rule). - -- **Repo/branch:** CultLib `hands/ack-cutF` from `hands/ack-cut2` rebased on `main` after Cuts 1 and 3 - merge. Cut 1 gives the receiver `R` and the drain the notice feeds; Cut 2 is the fragment code the notice - drops sets from and the rule the capability gates; Cut 3 is the admission rule the notice amends. Cut 2 - and Cut F merge to `main` together (the Cut 2 Soul finding: Cut 2 alone refuses sessions with expiring - senders). Kotlin's half is Cut K3. -- **First.** Failing tests, in C#, Rust, TypeScript and Python: - - the golden: `Abandon` encodes to the §6 bytes and decodes back, beside the existing fixture - (`packages/cultnet-rs/tests/cultnet.rs:319`, `packages/cultnet-ts/test/cultnet.test.ts:311`, - `packages/cultnet-py/tests/test_cultnet.py:409`, `tests/GameCult.Networking.Tests/NetworkingTests.cs:366`); - - a type-4 packet with bit 4 decodes as `Abandon`; bit 4 on a Data packet is still ignored; - - receiver: a notice for a hole advances `R`, drains the held ordered frames behind it, and replies with - the ack for that sequence (FN, inverted: `[o3]` delivered by the notice, `o2` marked received); - - receiver: a notice for a received sequence changes nothing and still replies; - - receiver: a notice inside an incomplete fragment set's span drops the set; - - receiver: a notice more than 1,024 above the highest received is ignored with no reply; - - receiver: the late original after its notice is a duplicate: acked, not delivered; - - Rust sender: an expired pending or queued packet produces a notice at once and then once per resend - delay; an ack naming the sequence stops it; after 16 unacknowledged sends it stops and records - `first_stranded`; every ending clears both; - - Rust end to end (P2 inverted): reliable `media` with expiry is lost, then ordered `s1`, `s2` on - `schema`; after the notice both are delivered and `flush_reliable` succeeds; - - Rust, Cut 3's window: an outstanding notice holds the lowest-unacked point; a stranded sequence does not. - - **the Cut 2 regression**, from Soul's `soul_probe_expiring_reliable_frames_kill_receiver` - (`packages/cultnet-rs/tests/cultnet.rs:3192` at `3be97b34`): 100 default `media` frames, each losing - every fragment but the first. With a Cut F sender the receiver's pending sets return to zero after the - notices and the session lives; with a stand-in sender that never advertises the capability nor sends - notices (Q-A9 B), the receiver evicts the stalest set as before Cut 2 and the session lives; with a - capable peer that stops sending notices, the 65th pinned set still refuses (Cut 2's rule holds where it - is true); - - (Q-A9 B) a Connect or Accept with flag bit 4 records the peer as capable; one without does not; an old - peer's accept of a flagged Connect works (the pass 3 CAP probe, kept as a test). -- **Deletes first:** - - Rust: the plain drop in `purge_expired_reliable` (`rudp.rs:898-908`; the `retain` calls become a move - into the abandoned set; the expired counter stays); - - the doc on `reliable_expire_after_ms` (`rudp.rs:121-124`), which says the packet is dropped; - - `packages/cultnet-py/README.md:103-111`'s claim that the Python session has reliable expiry. It has - none; the claim is false today. -- **Adds, receiver (C#, Rust, TS, Python):** - - the `Abandon` packet type and its codec mapping: Rust enum `rudp.rs:51-59`, `encode_flags` - `:2466-2475`, `packet_type_to_code` `:2477`, `decode_rudp_packet` `:2448-2455`, `packet_type_from_code` - `:2571`; C# `CultNetRudpPacketType` (`CultNetTransport.cs:509`) and `CultNetRudpPacketCodec` `EncodeFlags` `CultNetTransport.cs:697`, - `Decode` `:676-690` (its `Enum.IsDefined` check runs on the wire byte, which stays 4); TS union - `rudp.ts:26` and the codec at `:1264-1320`; Python enum `transport.py:250`, code table `:342`, codec - `:1175-1240`; - - the `Abandon` branch in `receive`, after acks are applied and beside the Ack/Pong branch - (`rudp.rs:578-592`, `CultNetTransport.cs:1177-1187`, `rudp.ts:397`, `transport.py:612`): the range - check, the fragment-set drop over the fragment buffers (`rudp.rs:1001-1114`, `CultNetTransport.cs:1556`, - `rudp.ts:643`, `transport.py:825`), `RememberReceived` and the Cut 1 drain, and - `reply = create_ack_for_received(sequence)` (`rudp.rs:751-758`, `CultNetTransport.cs:1273-1279`, - `rudp.ts:492-497`, `transport.py:685`); - - transports skip their own ack for an `Abandon` packet where a delivering receive would draw one: - `rudp.ts:1089`, `transport.py:1087` (Rust and C# ack only reliable, Accept or Data and need nothing). -- **Adds, capability (Q-A9 B; all four runtimes):** - - `Connect` and `Accept` carry flag bit 4; the session records whether its peer's handshake packet had - it, and resets that with peer state. `create_connect` (`rudp.rs:369-381`, `CultNetTransport.cs:1001-1010`, - `rudp.ts:229-240`, `transport.py:473-483`) and `accept_connect` (`rudp.rs:383-411`, - `CultNetTransport.cs:1012-1059`, `rudp.ts:242-290`, `transport.py:485-525`) set it; the codec keeps bit 4 - on those types (today every decoder drops it); - - the fragment-set bound (Cut 2's eviction, `rudp.rs:1027-1047`, `rudp.ts:679-692`, `transport.py:836-842` - as Cut 2 leaves them) applies the never-evict rule to a capable peer and the pre-Cut-2 stalest-set - eviction to one that is not; - - the sender sends notices only to a capable peer; for another, an expired sequence is stranded at once. -- **Adds, sender (Rust):** - - `RUDP_ABANDON_NOTICE_SENDS = 16` beside `DEFAULT_MEDIA_RELIABLE_EXPIRE_AFTER_MS` (`rudp.rs:39`); - - the abandoned set and `first_stranded` on the session (fields beside `pending_reliable`, - `queued_reliable`, `rudp.rs:193-195`); - - `purge_expired_reliable` moves expired pending and queued sequences into the set; - - `due_resends` (`:797-807`) emits due notices after due packets and retires entries at the bound; - - `apply_acknowledgements` (`:964-971`) removes named sequences from the set; - - `outstanding_reliable_packet_count` (`:270-272`) counts the set; - - the ending primitive (Cut 1b) and `reset_peer_state` (`:344-358`) clear both; - - Cut 3's lowest-unacked point (in `admit_reliable_packets` / `promote_queued_reliable`, `:910-942` as - Cut 3 leaves them) includes the set and excludes `first_stranded`. -- **Docs.** `docs/cultnet-transport-parity.md`: the packet-type and flags rows of the header table - (`:486-487`) gain "`4` with flag bit 4 = abandon"; the golden goes after the canonical fixture - (`:505-517`); the bounded-send paragraph (`:260-273`) gains the notice rule and its resend bound. -- **Authority map:** - - Owner: the sender session's abandoned set decides which sequences are announced and for how long; the - receiver session decides what a notice changes. - - Inputs: expiry (sender); a decoded `Abandon` packet in the current generation (receiver). - - Outputs: notices (sender); a remembered sequence, drained frames and one ack (receiver). - - Derived: `first_stranded` is derived from the set's retirements and read by Cut 4; the expired counter - is report-only. - - Forbidden writers: nothing marks a sequence received without a packet except the `Abandon` branch; no - notice outlives its generation; no transport interprets bit 4. - - Shared paths: data, fragments, duplicates, Accept and notices all advance `R` through - `RememberReceived` and the one drain. - - Deletion line: the plain drop in `purge_expired_reliable` goes before the set is added. -- **Verification:** - - the tests above in four runtimes; - - FN re-run against the new build as a **negative** check: an old-receiver stand-in (a session that drops - `Abandon` packets) never acks, and the Rust sender strands the sequence after 16 sends; - - the TS interop harness gains one lane: a Rust peer sends reliable `media` with expiry whose first - packet the bridge drops, then ordered `schema` frames; the TypeScript receiver delivers the `schema` - frames (`packages/cultnet-ts/test/interop/cultnet-interop.test.ts`, beside the drop lanes); - - negative grep: `rg -n "first_abandoned" packages src` returns nothing (pass 2's name must not appear); - - mutation testing on the diff. -- **Ledger.** Receiver about +40 per runtime (four); Rust sender about +60 and −6; the golden about +25 - per runtime; docs +15 and −8 (the false Python claim). - -### Cut 4. Rust receipts: Acknowledged means delivered, resolved once; honest stranding and queueing — blocked on Cuts 1, 1b and F - -Re-mapped in pass 3 for Q-A3 B. Pass 2's `first_abandoned` (every expiry leaves a permanent hole) is -replaced by Cut F's `first_stranded` (only a notice the receiver never acknowledged leaves one). The rest is -pass 2's cut. - -- **Repo/branch:** CultLib `hands/ack-cut4` from `main` after Cuts 1, 1b and F merge. -- **First.** Failing tests: - - P3: the receipt for `s2` reads `Pending` until `s1` arrives, then `Acknowledged`; - - P9 (`send_reliable` on an expiring channel is refused) and P10 (a window-full `send_reliable` returns a - receipt covering its queued packets, and the frame is sent once); - - a receipt `Acknowledged` before any ending stays `Acknowledged` after the ending and after a reconnect; - a `Pending` one becomes `Invalidated`; - - **P2 with a new receiver:** reliable `media` with expiry is lost, then ordered `s1`, `s2`; their - receipts read `Pending` while the notice is outstanding and `Acknowledged` once it is acked; - `flush_reliable` succeeds; - - **P2 with a deaf receiver** (a stand-in session that drops `Abandon` packets): after 16 notice sends the - receipts for `s1` and `s2` stay `Pending`, `flush_reliable` fails at once naming the stranded sequence, - and the ending makes them `Invalidated`. -- **Deletes first:** - - the session scope (`rudp.rs:135`, `:179`, `:206`, `:283-285`, the check at `:291-293`, and what Cut 1b - left of the rotations); - - the stale comment and the half guard at `rudp.rs:1915-1920`; - - the hand-rolled status loops at `cultmesh-rs/src/lib.rs:806-838` and `:870-900`. -- **Adds:** - - the receipt's status cell and ordered flag; the session's unresolved-receipt list, resolved once - (Acknowledged through `A`, Invalidated by the ending primitive); - - `acked_through` (`A`): one below the lowest sequence that is pending, queued, in Cut F's abandoned set, - or `first_stranded`; - - the receipt covers queued sequences: `send_many` (`:456`) reports every sequence it assigned; - - `send_reliable` (`:1903-1930`) refuses a channel with expiry; - - `wait_acknowledged`; - - `flush_reliable` fails fast when an ordered send follows `first_stranded`, and otherwise waits while - notices are outstanding (Cut F counts them in `outstanding_reliable_packet_count`). -- **Unchanged:** `CultNetRudpReliableSendStatus` (`:146-150`), `reliable_send_status`'s signature - (`:1931`), and every caller of `Acknowledged`: `tests/rudp_stray_packets.rs:309`, - `cultmesh-rs/tests/rudp_document_server.rs:408,415`, CodexConnector, Ghostlight. -- **Changes:** `cultmesh-rs/src/lib.rs:832` and `:892` become `wait_acknowledged`; the doc at `:869` says - delivered to the document server's sink. -- **Verification:** - - the new tests pass; - - `rg -n "session_scope|first_abandoned" packages/cultnet-rs` has no hit; - - both suites are green; - - cargo-mutants on the diff. -- **Ledger.** About −90 (two loops of about 30 each, the scope) and +85 (of which `wait_acknowledged` is - about 35). Five lines smaller than pass 2: the abandoned bookkeeping moved to Cut F. - -### Cut 5. CultLib-internal TS publishers and the contract text (TS, docs) — blocked on Cut 3, and on Cut 1b in TS - -- **Changes:** - - `idunn-odin-presence-publisher.ts:89-215` and `signed-daemon-health.ts:104-162` (with its helpers - `:244-252`, `:273-389`, except the exported `parseEndpoint` `:254-271`) send through - `CultNetRudpSocketTransportConnection`: `connectAndWait`, `send("schema")`, `flush`, `close`. Their - hand-rolled session loops are deleted. The presence publisher keeps rejecting a `cultnet.error.v0` - response, from the transport's `frame` events during the flush. - - `connectAndWait(payload, timeoutMs)` on the TS socket transport, matching C# `ConnectAndWait` - (`CultNetTransport.cs:1859-1880`). It is `cultmesh-ts/src/index.ts:6603-6650` `waitForRudpConnected` moved - down; `createRudpPeer` (`index.ts:6220-6245`) uses it and the cultmesh-ts copy is deleted. - - Flush contract text in all runtimes: "every reliable frame sent in this session has been delivered to - the peer's application". - - `docs/cultnet-transport-parity.md:236-240` (the control-packet guard paragraph) is replaced by the - watermark rule, and `:261-272` gains: Acknowledged means delivered; a write belongs to the session it - was issued in; how a repeated Connect is recognised (after Cut 1c); the receive window (after Cut 3). -- **Verification:** - - `runtime-presence-health.test.ts` and `signed-daemon-health.test.ts` stay green; - - a new test drops the first datagram and still publishes; - - a new test publishes a payload over 32 packets whole; - - a new test shows the publisher's peer receives a Disconnect. -- **Ledger.** About −270 and +50. - -### Cuts 6a, 6b, 6c. Receipts in C#, TypeScript and Python — blocked on Cut 4, and on Cut 1b in each runtime - -Design and public API in §9. One cut per runtime, in parallel worktrees, so Soul can falsify each alone. -Kotlin's is Cut K4. - -- **Repo/branch:** CultLib `hands/ack-cut6a` (C#), `hands/ack-cut6b` (TS), `hands/ack-cut6c` (Python), each - from `main` after Cut 4 merges. Cut 4 is the reference; Cut 1b supplies each runtime's ending primitive. -- **First.** Failing tests, in each runtime: - - an ordered receipt reads Pending while a sequence below it is missing, then Acknowledged (P3); - - a send made while the window is full returns a receipt that covers its queued packets and becomes - Acknowledged; the frame is sent once (P10's shape); - - an Acknowledged receipt stays Acknowledged after the session ends and after a reconnect; a Pending one - becomes Invalidated and stays so; - - the wait returns on Acknowledged, fails at once on Invalidated with the end reason, and times out; - - `SendReliable` on an unreliable channel is refused. -- **Deletes first:** nothing. These runtimes have no receipt code to replace. -- **Adds, per runtime:** - - C# (6a): `CultNetRudpSendReceipt`, `CultNetRudpSendStatus`; in `CultNetRudpSession`, a send path that - records every sequence `SendMany` assigns (`:1075-1140`, before `AdmitReliablePackets` `:1439-1465` - splits them), the unresolved list, resolution after `ApplyAcknowledgements` (`:1503-1516`) and in the - Cut 1b primitive, and `A` over `_pendingReliable` and `_queuedReliable`; on the socket transport, - `SendReliable`, `WaitAcknowledged` (the `FlushReliable` loop, `:1914-1955`), and `SendSchema` - (`:1960`, `:1968`) and `SendSchemaMessage` (`:1976`) returning the receipt; - - TS (6b): `CultNetRudpSendReceipt`, the status union; session changes at `sendMany` (`rudp.ts:304-368`), - `#admitReliablePackets` (`:586-592`), `#applyAcknowledgements` (`:610-617`); transport - `sendReliable` and `waitAcknowledged` beside `send` (`:899-909`) and `flush` (`:911-935`); exported from - the package index; - - Python (6c): `CultNetRudpSendReceipt`, `CultNetRudpSendStatus`; session changes at `send_many` - (`transport.py:538-588`), `_admit_reliable_packets` (`:776-786`), `_apply_acknowledgements` - (`:803-807`); transport `send_reliable` and `wait_acknowledged` beside `send` (`:1000-1009`) and - `flush_reliable` (`:1101-1131`); exported from `cultnet_py`; - - README sections per §9, and the parity doc's flush paragraph. -- **Authority map:** the session owns each receipt's status and writes it once; the transport reads it. - Forbidden writers: no transport, flush or timer writes a status; no receipt resolves from a packet's own - ack when it is ordered (only through `A`). -- **Verification:** the tests above; each runtime's full suite; the Cut 4 behaviour table held side by side - with Rust's (same inputs, same states); negative: in each runtime, the only assignment to the status is - in the session's resolve and end paths (`rg` for the status field outside those two functions returns - nothing); mutation testing on each diff (Stryker.NET, StrykerJS, mutmut). -- **Ledger.** About +90 per runtime, nothing removed; tests about +80 per runtime. - -### Cut 7. Reliable expiry in C#, TypeScript and Python — blocked on Q-A8 and Cut F - -Mapped only for Q-A8's recommended answer A. Each runtime gains Rust's send option (a per-send reliable -expiry, and the profile's `media_reliable_expire_after_ms`, `rudp.rs:2492-2508`) and Cut F's sender half -(the abandoned set, notices at the resend delay, the 16-send bound, `first_stranded`), and its receipts -(Cut 6) refuse an expiring channel. Kotlin's is K5. About +70 per runtime. If Q-A8 is B, this cut is not -built and the parity doc records Rust as the only runtime with partial reliability. - -### Cut K. Kotlin catches up (Q-A5 A, ruled) — K0 ready now; K1-K5 trail the four-runtime cuts - -`CultMesh.kt` (6,332 lines, the only RUDP file) has none of the `3bf1c0c` stray-packet hardening, the P1 -and P6 receiver, no reset path and no repeated-Connect answer. K is split so each step is falsifiable on its -own; the anchors below are `e9469cb3`, where `CultMesh.kt` is identical to `3bf1c0c`. Tests follow the -file's existing pattern (private self-test functions called from `main`, K:3349-3373); moving them out of -the production source is a follow-up. - -**K0. The Kotlin verify image and a Linux build path — ready now.** -- **Stopgap tooling** (`C:\Users\Meta\.claude\skills\eureka\tools\stopgap\`, owned by Self, not a CultLib - commit; it dies with `ygg-verify.sh`): - - `kotlin.Dockerfile`: `FROM eclipse-temurin:21-jdk`; `apt-get install unzip curl`; fetch - `https://github.com/JetBrains/kotlin/releases/download/v2.2.21/kotlin-compiler-2.2.21.zip` (the - version CI pins, `.github/workflows/cultnet-interop.yml:20`) into `/opt/kotlinc`; `ENV - KOTLIN_HOME=/opt/kotlinc PATH=/opt/kotlinc/bin:$PATH`; Node 24 copied from the `node:24` image - (`COPY --from=node:24 /usr/local /usr/local`) for the interop lane; PowerShell 7 (`pwsh`, Microsoft's - Debian package) for `build.ps1`. Pass 3's probe proved the JDK-plus-compiler half: the self-tests exit 0 - (K-img). - - `ygg-verify.sh`: a `kotlin` image alias tagged by that Dockerfile's hash, and the remote build step - generalised from `eureka-verify-rust:*` to `eureka-verify-:*` built from `.Dockerfile` - (today it builds and copies only `rust.Dockerfile`). Edit it by writing a temp file and renaming it over - the old one (the script's own rake). -- **CultLib:** - - `packages/cultmesh-kotlin/build.ps1` becomes portable PowerShell 7: `kotlinc` or `kotlinc.bat` by - platform, `[IO.Path]::PathSeparator` for the classpath, `java` or `java.exe`. One build script stays the - one owner of the Kotlin build; no `build.sh` beside it. - - The interop harness calls `pwsh` off Windows instead of `powershell` - (`packages/cultnet-ts/test/interop/cultnet-interop.test.ts:2799-2809`); it already picks `java` off - Windows (`:31-36`). - - `docs/cultnet-transport-parity.md` says, beside the runtime table (`:35`) and the RUDP claims - (`:205-273`), that Kotlin lacks the `3bf1c0c` hardening and the ack cuts until Cut K lands, so nobody - reads it as conforming meanwhile. -- **Verification:** `ygg-verify.sh kotlin 'cd packages/cultmesh-kotlin && pwsh -File build.ps1'` - runs the self-tests green; the interop lane - (`node --test --test-name-pattern "TypeScript and Kotlin|Kotlin and TypeScript"`) runs green on the same - image; CI on `windows-latest` stays green with the same script. - -**K1. Stray-packet parity** (the `3bf1c0c` behaviours the other four have, each with its test ported from -the C# or TS equivalent): -- a malformed, foreign-id or refused datagram is dropped and counted, never thrown out of `receiveOnce` - (K:3223, K:3228, K:2724, K:2567), with a `packetsDropped` stat (`CultNetTransportStats`, K:774); -- the connection id is checked before the endpoint is claimed, and in server mode only a Connect claims it - (K:3217-3222); -- `resetPeerState` and `endRefusedSession`: the refusing session resets, builds its goodbye after the - reset, and a server forgets its endpoint; a refused packet's sequence is remembered only after - reassembly accepts it (today K:2758 remembers before `reassemble` can throw, K:2915-2922); -- `answerRepeatedConnect`: a repeated Connect queues nothing and is answered with the owed Accept or an Ack - (today every Connect makes a new tracked Accept, K:2667-2676, K:3224-3226, K:4005-4006); -- a Connect from another endpoint replaces the peer in server mode (today ignored, K:3220-3221); -- a peer's Disconnect drops owed writes (K:2745-2748); `connect` clears a stale disconnect reason (K:3106); -- `initialSequence` of `0xFFFFFFFF` is refused at construction (K:2631) and sequence exhaustion is checked - before allocation (K:2841, K:2698-2711); -- the decoder's negative declared length (K:3306-3317) is an ordinary malformed drop; -- the fragment-set bound of 64 (K:2645, K:2911-2937 has none): the stalest set is evicted. Cut 2's - never-evict rule and its capability gate come in K3 with Cut F, as in the other runtimes. - -**K2. Cuts 1, 1b and 1c.** -- Cut 1: delete `orderedNextSequenceByChannel` (K:2643), `expectedSequenceIfUninitialized` (K:2728), - `deliverOrdered`/`drainOrdered`/`skipReceivedNonChannelSequences` (K:2939-2978); seed `R` in - `acceptConnect` (K:2667) and on Accept (K:2730); advance in `rememberReceived` (K:2891). -- Cut 1b: the ending primitive from a peer's Disconnect (K:2745), `createDisconnect` (K:2809), - `checkTimeout` (K:2814-2819) and K1's refusal; `flushReliable` (K:3186-3205) binds to the generation. -- Cut 1c: random defaults at K:2600, K:2996, K:3078 and the server's 100 at K:3016 - (`java.security.SecureRandom`); the session's repeat decision replaces server mode's - every-Connect `acceptConnect` (K:3224-3226) and the interop server's (K:4005); `createConnect` (K:2660) - and the Accept check (K:2730). - -**K3. Cuts 2, 3 and F.** Admission at K:2856-2872 gains the flow window; Cut 2's reliable-set rule behind -the Q-A9 capability; the `Abandon` type and receiver branch (K:2556-2567, K:2738, K:3296-3325), the golden beside `rudpPacketCodecUsesDeterministicReliableOrderedFixture` -(K:5236), and the transport skips its own ack for `Abandon` (K:3243-3245). - -**K4. Receipts** (§9): `sendReliable`, `CultNetRudpSendReceipt`, `CultNetRudpSendStatus`, `waitAcknowledged`, -at `sendMany` (K:2685-2719), `admitReliablePackets` (K:2856-2862), `applyAcknowledgements` (K:2882-2889) -and the transport (K:3132-3205). - -**K5. Reliable expiry and the notice sender** — only if Q-A8 is A (as Cut 7). - -- **Verification, each step:** the Kotlin image's self-tests and interop lane; the step's ported tests; - a negative grep per step (K2: `rg -n "orderedNextSequenceByChannel|expectedSequenceIfUninitialized" - packages/cultmesh-kotlin` returns nothing). -- **Ledger.** K1 about +180 and −40; K2 about −70 and +90; K3 about +80; K4 about +90; K5 about +70. - - -## Subtraction ledger (estimate) - -| Cut | Removed | Added | Other | -|---|---|---|---| -| 1 | ~280 | ~160 | four per-channel state machines become one watermark | -| 1b | ~40 | ~45 | one ending primitive; TS's transport generation pair goes | -| 1c | ~90 | ~85 | seven transport- and server-level repeat decisions become one session predicate; two CultLib production pins go | -| 2 | ~10 | ~35 | none; merges with Cut F | -| 2c | 0 | ~45 | C# gains the fragment-set bound the other runtimes have | -| 3 | 0 | ~100 | a documented receive-window contract | -| D | ~15 | ~40 | one failure counter in three servers; a test seam at each send function | -| F | ~15 | ~350 | **wire: one packet type (`Abandon` = Ack + flag bit 4) and one golden in every runtime; with Q-A9 B, the same bit on Connect and Accept**; the false Python expiry claim goes | -| 4 | ~90 | ~85 | one public method (`wait_acknowledged`); the session scope goes; no enum change | -| 5 | ~270 | ~50 | two hand-rolled RUDP loops and cultmesh-ts's connect wait go | -| 6a-6c | 0 | ~270 | public receipt API in three runtimes (Q-A4 A) | -| 7 | 0 | ~210 | only if Q-A8 is A: partial reliability in three runtimes | -| K0-K5 | ~110 | ~510 | Kotlin reaches parity; one verify image; `build.ps1` portable | - -- **Source, net, four runtimes without Cut 7:** about +325. Pass 2 was about −195; the rulings bought - FORWARD-TSN with its capability gate (about +335 net) and receipts in three runtimes (about +270); Cut D - adds about +25 and Cut 2c about +45. Tests are extra: - about 4 × 25 rule tests. -- **Kotlin:** about +400 net, most of it the `3bf1c0c` hardening the other four already carry. -- **Wire:** one additive packet type, ignored by every current peer (FN). -- **Downstream:** no caller has to change code at its next bump. Callers that pin `initial_sequence` keep - a deterministic Connect sequence until they drop the value (Cut 1c, pin-bump notes). - - -## Operator questions - -Each question stands alone. - -**Ruled (2026-09-30), recorded so they are not re-asked:** - -- **Q-A1. Where does delivered come from?** (a): derived at the sender from the cumulative watermark. -- **Q-A2. One flush, or a "received" flush beside it?** One meaning: Acknowledged means delivered. -- **Q-A3. Reliable expiry next to ordered traffic (P2)?** B: FORWARD-TSN now (Cut F). The recommendation - was A (report honestly, document "don't mix"). -- **Q-A4. Receipts in C#, TypeScript, Python and Kotlin?** A: port them in this campaign, after Cut 4 - (Cuts 6a-6c, K4). The recommendation was B (record a parity gap). -- **Q-A5. Is Kotlin in the campaign?** A: yes, as trailing Cut K on a Yggdrasil Kotlin image (K0). -- **Q-A6. How does a session recognise a new generation?** A: the Connect's sequence identifies it; the - default initial sequence is random in [1, 2^31) (Cut 1c). - -**Open:** - -- **Q-A7. Does an abandonment notice name one sequence, or a new cumulative point? (new in pass 3)** - RFC 3758's FORWARD TSN carries a *New Cumulative TSN*: "every missing sequence up to here counts as - received". SCTP can do that because its SACK is cumulative too, so the next SACK confirms it. CultNet's - ack is not cumulative: it names the highest received sequence plus the 32 below it, or one exact older - sequence. So the two shapes cost different things: - - **A. One sequence per notice.** The receiver answers exactly as it would answer a data packet with - that sequence, and that ack stops the sender's notice as it stops a retransmit. No new ack field. The - cost is one small notice per abandoned packet per resend: an expired 20-fragment frame sends 20 - notices, again every resend delay until acked. - - **B. A cumulative point.** One notice covers every abandoned sequence up to it. But nothing on the - wire can confirm it: an ack naming the point might mean the original of that one packet arrived late, - while lower holes are still open. So B needs a second addition, a confirmation Ack (another flag bit) - carrying the receiver's watermark, which puts a cumulative watermark on the wire after all, the thing - Q-A1 kept off it. - - **Recommended: A.** It keeps the wire change to one flag, reuses the ack path unchanged, and the extra - notices only flow while packets are expiring, which is a lossy moment on one session. - - **Blocks:** Cut F (and K3). Nothing else. - -- **Q-A8. Should C#, TypeScript, Python and Kotlin gain reliable expiry? (new in pass 3)** Rust is the only - runtime that can send a reliable packet that gives up after a deadline (partial reliability, for live - media). Cut F teaches every runtime to *receive* the notice, because any of them can talk to a Rust - sender; only Rust can *send* one. A reasonable consumer of the C# or TS library can expect the same send - option. Today the profile field that configures it (`media_reliable_expire_after_ms`, - `rudp.rs:2492-2508`) exists only in Rust and cultmesh-rs. - - **A. Yes, in this campaign** (Cut 7 for C#, TS, Python; K5 for Kotlin): the send option, the profile - field's behaviour and Cut F's sender half. About +70 per runtime. - - **B. Not now.** The parity doc records Rust as the only runtime with partial reliability. - - **Recommended: A.** CultLib is judged by what a reasonable consumer expects (operator, 2026-09-30), and - after Cut F the sender half is small and already specified. It is independent of every other cut, so it - can go last. - - **Blocks:** Cut 7 and K5 only. - -- **Q-A9. What does a receiver do with fragment sets from a sender that never sends abandonment - notices? (new in pass 3, from the Cut 2 Soul pass)** Cut 2 stops evicting reliable fragment sets, because - evicting one whose fragments were acknowledged loses a frame the sender saw acknowledged (P5). But a - sender with reliable expiry, which is every default Rust `media` sender, abandons the rest of a frame - after its first fragment was acknowledged, so the set can never complete; after 64 of them Cut 2 refuses - the session. Cut F's notices release those sets, but only a Cut F sender sends notices, and the receiver - cannot tell an old expiring sender's dead set from a live set still waiting for a retransmit. - - **A. No fallback; bump both ends together.** Cut 2's rule applies to every peer. Any session between a - Cut 2 receiver and a pre-F expiring sender dies after 64 lossy frames, so every such pair (Muninn's - media, Mimir's relay, browsers on vendored CultLib) must move in the same deploy. - - **B. A capability bit, as PR-SCTP negotiates (recommended).** Connect and Accept carry flag bit 4 - ("I send and honour abandonment notices", RFC 3758 §3.1 Forward-TSN-Supported). Old peers ignore it on - those packets (probe CAP, all five runtimes). Cut 2's never-evict rule applies to a peer that advertised - it; a peer that did not keeps today's stalest-set eviction, with today's P5 risk, which only its own - upgrade removes. The sender also stops sending notices to peers that cannot use them. Cost: one flag on - two packet types and one remembered bit per session. - - **C. Age-based release.** A reliable set untouched for some multiple of the resend delay is released - for every peer. It keeps sessions alive without a wire change, but it releases a live set whose missing - fragment is merely slow, which is the P5 lie Cut 2 exists to remove, now on a timer. - - **Recommended: B.** It is the literature's answer, it makes Cut 2's rule hold exactly where its premise - holds, and mixed versions keep working without coordinated deploys. - - **Blocks:** Cut F's capability half and therefore the merge of Cuts 2, 2c and F. Q-A7 is independent. - -**Not forks, recorded so they are not re-asked:** - -- `Acknowledged` keeps its name and now means delivered. No variant is added or removed. -- Delivered means handed to the transport's application boundary, not consumed. -- The 4 MiB cap stays; the receiver's 4,096 receive history stays. -- A receipt is resolved once. -- Session generation is its own two cuts, not part of Cut 1 (§8). -- The notice's resend bound is 16 sends at the resend delay (§6). It is a constant, not an option. -- Receipts live on the single-peer socket transport in every runtime, as in Rust; hub receipts are a - follow-up for all five together. -- A failed send to one peer is that datagram lost (Cut D, RFC 1122's soft errors); it does not end the - peer's session. - - -## Sequencing and blockers - -1. **Done.** `hands/rudp-stray-packets` merged at `3bf1c0c`. Odin `origin/main` pins `3bf1c0ce`. -2. **In flight** (pass 2 text, unchanged by pass 3): Cuts 1 and 1b on `hands/ack-cut1`, Cut 2 on - `hands/ack-cut2`. No ruling forces a change to their specs: - - Q-A3 B adds the abandoned set, but Cut F adds it and hooks it into Cut 1b's primitive; 1b need not know. - - Q-A4 A needs an ending primitive in C#, TS and Python, which 1b already builds. - - Q-A6 is Cut 1c's. - - **Cut 2's merge moves** (the Cut 2 Soul finding): its code stays as specified, but it refuses sessions - with expiring senders unless Cut F releases their dead sets, so it merges only together with Cut F - (and Cut 2c). Its spec's "a conforming sender cannot reach that bound" is corrected in place. -3. **Ready now:** Cut 3 (merge after Cut 1, as pass 2 said); **Cut D** (independent); **K0** (tooling and - `build.ps1`; independent). -4. **Cut 1c** after Cut 1b merges. -5. **Cut F** built on `hands/ack-cut2` after Cuts 1 and 3 merge, once Q-A7 and Q-A9 are ruled. **Cuts 2, - 2c and F merge to `main` together.** -6. **Cut 4** after Cuts 1, 1b and F. -7. **Cuts 6a, 6b, 6c** after Cut 4, in parallel. -8. **Cut 5** after Cut 3 and Cut 1b in TS, as pass 2 said. It may use 6b's `waitAcknowledged` if 6b lands - first; it does not need it (flush suffices). -9. **Cut 7** after Cut F, once Q-A8 is ruled A. -10. **Cut K** after K0: K1 anytime; K2 after Cuts 1, 1b, 1c; K3 after Cuts 3 and F; K4 after Cut 4 - (and Cuts 6 as the parity reference); K5 after Cut 7. -11. **Pin bumps:** - - **Odin** after Cuts 1, 1b and 3 (it is the receiver for every Idunn publisher, so this bump makes - their Acknowledged mean delivered) and Cut D (it is the document server's only production host). Cuts - 2 and F come together at whichever bump follows their merge. - - **Muninn** (and any consumer of the default reliable `media` channel) takes Cuts 2 and F together. - Under Q-A9 B its ends may move separately; under A they must move in one deploy. Its client and - Sleipnir pins of `initial_sequence: 1` should go at that bump (Cut 1c notes). - - **CodexConnector** and **Ghostlight** need no code change; they may adopt `wait_acknowledged` after - Cut 4. -12. **Vendored TS bumps after Cut 5** (they pick up honest flushes, the TS window and the rewritten - publishers at once): - - **StreamPixels** vendors CultLib `542ddd3` (StreamPixels `a49f7d8`; pass 2's `30ee8b9` is stale). - Its service runs `createIdunnRuntimePresencePublisher`, which that revision carries under its older - name (`cultnet-ts/src/idunn-runtime-authority.ts`, pin at `:333`). - - **Heimdall** vendors `b6b1d9c` and hand-rolls its publisher (`src/idunn-rudp-health.ts:55-87`, - `initialSequence: 1` at `:65`). At its bump it calls cultnet-ts's publisher instead. -13. **Parallel campaigns:** `hands/media-fec-cut3` touches `rudp.rs` only in the imports, the `audio` - profile entry and the `"media" | "audio"` send arm; no overlap with Cuts 1-4, D or F beyond a rebase. - Once it lands, reliable expiry is only `media` in Reliable mode. CultCache publication Cut 4 is - unrelated in either direction. - - -## Follow-ups outside this campaign - -- **Hold caps in C#, TS, Python and Kotlin.** Their ordered hold buffers and per-channel maps are unbounded - against a hostile peer. Rust has caps. The far-ahead refusal on data is Rust-only too. -- **The document server's per-session payload budget never shrinks** (`rudp_document_server.rs:321`, - `:584`). -- **Fire-and-forget health.** Muninn `main.rs:9446`, Sleipnir `main.rs:880-904` and Heimdall's first-ack - wait can lose a health record silently. -- **Receipts on hubs** (Rust hub, C# listener, cultmesh-ts and cultmesh-py servers) in all five runtimes - together; and a peer-level `send`-and-wait in TS's `CultNetPeer` (`peer.ts:98-110`). -- **Kotlin self-tests live in the production source** (`CultMesh.kt` K:5236-5633, run from `main`). Move - them to a test source set once the Kotlin image exists. -- **Callers outside CultLib that pin `initial_sequence`** (Cut 1c's table): drop the value at each bump. -- **Mimir `CultMeshMedia`** hand-rolls a per-peer relay with its own Connect handling (`Program.cs:365`, - `:485`); it should call the session's repeat predicate after its CultLib moves. -- **`CultNetTransportStats` parity.** Cut D adds `send_failures` in Rust and C#; Kotlin has no - `packetsDropped` until K1. Record the stats shape in the parity doc once both land. -- **The P4 probe at the old pins** predates its fix; rerun `09318d13`'s P4 against a pinned sender if - old-sender evidence is needed. - -**Follow-up (media FEC Cut 3 Hands, 2026-09-30):** `channel_send_options` in `rudp.rs` has no test for the -`"schema"` and `"latest"` channel arms. Deleting either falls to the default and every test stays green. Pin their send -flags on the wire the way the media arm is now pinned (raw peer socket), in whichever cut next touches channel -profiles. - -**Rulings after the Cut 1/1b/1c Soul pass (Self, 2026-09-30):** -- **Stale data after a reconnect.** A reliable sequence at or before the generation's seeded `R` (serial arithmetic - within the receive window) is a duplicate: acknowledged, not delivered. This is what §6/§8 already promised. -- **Stale Connect (RFC 5961's challenge ACK).** A Connect whose sequence precedes the current generation's Connect - within the receive window is stale: it is answered with an Ack naming the current generation and does not reset. - A client whose Connect gets no Accept before its connect attempt times out starts a fresh attempt with a newly - drawn initial sequence, so a restarted client whose random sequence lands in that window still connects. -- **Server mode.** A Connect from a different endpoint is never a repeat; the session predicate stays sequence-only. - (Hands' deviation 5 was rejected: pinned clients restarting on a new port were locked out.) -- **The random default belongs to the session.** A session draws its own initial sequence when none is set, so one - options object reused across sessions or reconnects never repeats a sequence. -- **Connect attempts (Self, 2026-09-30, after the Cut 1c fix-batch Soul pass).** While a Connect awaits its Accept, only an - Accept the client honours retires it; an Ack never does (an Ack naming the pending Connect had wedged the client for - good). A fresh attempt after the connect-attempt timeout uses exactly the abandoned sequence + (receive window − 1), - not a random draw: that keeps a late copy of the abandoned Connect inside the new one's stale window while escaping the - server's stale window (unless the server sits exactly there, in which case the next attempt escapes). Only a client's - first Connect draws randomly. -- **Recorded divergence (not this campaign's to fix yet).** Only Rust has a receiver receive-ahead window (1,024). TS, - C# and Python acknowledge a far-ahead reliable frame by name and hold it behind an ordered gap indefinitely, so a - stranded ordered channel is silent loss there and "still owed" in Rust. Map a receive window for the three runtimes. -- **Residuals after the final Cut 1c Soul pass (recorded 2026-09-30, low, not fixed):** - - A late copy of a Connect from two or more attempts back (reordered > ~3 s) still restarts the server; the +window−1 - rule keeps only the immediately previous attempt stale. Rust then times out and reconnects; TS/C#/Python hit the - receive-window divergence above (silent loss behind the gap). - - A client pinning `initial_sequence` that restarts while its old data is still in flight after the restarted Connect - can be matched to the old session's resent Accept (byte-identical; the client cannot tell). Pinning forfeits restart - detection; the random default closes it. Document on the option. - - Repeated failed attempts walk the sequence up 4095 per 3 s and clamp at `u32::MAX−1` after ~18-27 days on one session; - make exhaustion a hard error the caller sees (the clamp removal mutant survives). -- **Cuts 3 and D Soul pass (Self, 2026-09-30).** Cut 3: the 4 MiB bound counts every byte sent above the lowest - unacknowledged sequence, acked or not (the spec's wording; the first implementation counted only pending packets). - Cut D: a send failure is either permanent (the datagram can never be sent as built, e.g. `EMSGSIZE`) or transient; - a permanent failure is returned from a caller-directed send and, inside a poll, ends only that peer's session with a - typed reason; transient failures stay counted losses. Windows `ConnectionResetError` on receive is idle, never fatal, - in every server. Cut D's negative grep `send_packet(...)?;` is obsolete: the `?` now propagates encode errors only. -- **Cut 3 merged at `1210fdc7` (2026-09-30).** - - Batch 2 fixed Rust `send`, which checked the window before purging expired packets. It also added a - new-generation test in all four runtimes. - - Soul pass on batch 2: nothing found. 18 mutants were killed. Interop was 27/27, run in `ack1d-interop:2`, - whose Linux wrappers let the Windows-only Kotlin build run. - - Residual: `packages/cultmesh-rs/Cargo.lock` is stale. - - Also recorded: `packages/cultmesh-kotlin/build.ps1` is Windows-only, so Kotlin interop runs off Windows only - through an image with wrappers. - - P2 (the expiry hole) stays with Cut F. -- **Cut D batch 2, Soul pass 2: fix first.** - - cultnet-ts emits transient send failures as `"error"`, which crashes processes with no listener. Section 10's - claim that "Node reports send failures on the socket's error event" is false on Node 24 without a callback: - they are dropped silently. - - C# stale peer objects write into the replacing session. - - cultmesh-py dies on a non-ValueError per-peer failure. - - Six guards are unpinned. - - Batch 3 is in Hands. - - **K1 gains:** Kotlin's idle resend loop (`CultMesh.kt:4033-4036`) is one `try`, so one peer's permanent failure - stops resends for every later peer. That is in addition to a refused packet not ending that peer's session. -- **Recorded (liveness, not fixed):** a lowest reliable packet lost forever stalls the sender 1,023 sequences ahead - while the peer stays alive; session timeout doesn't end it. TCP ends such a connection after a retransmission - limit (R2). Decide with Cut F (abandonment) whether a reliable packet outstanding past a bound ends the session. diff --git a/docs/cultnet-selection-cut.md b/docs/cultnet-selection-cut.md deleted file mode 100644 index 1f64b2bf..00000000 --- a/docs/cultnet-selection-cut.md +++ /dev/null @@ -1,3574 +0,0 @@ -# CultNet typed selection: cut map - -Date: 2026-09-17. Imagination output. Intended path: `F:\Projects\CultLib\docs\cultnet-selection-cut.md`. -No code in this document has been written; nothing here is committed by -Imagination. This is its own campaign with its own map; it does not touch -`docs/typescript-quic-realtime-cut.md` or any code in that tree. - -**Progress, 2026-09-22.** Cut 1 is running (Hands, Sonnet) on the branch -`cultnet/selection-cut1`. It will not merge to `main` until Soul has passed it. - -- **Commit 0, `e420410`:** the cache's public read surface. Twelve tests, six - mutation entries, all killed. -- **Commit 1, `17d10e0`:** `CultNetSelection` and its evaluator, the three v1 - messages, and the three §1 selector engines deleted. v0 now lowers into a - selection. Test results: Networking 162/162, Mesh 252/253 (one skip that was - already there), Caching 188/188. Nine networking mutation entries, all killed. -- **Mutation harness:** `scripts/mutate-dotnet.ps1` is a shared dotnet/NUnit - harness and works for any NUnit project in this repository. -- **Not run through mutations yet:** S1, S2, S6, S9–S15, S17, S20 and S23. A - test pins each one, but none has a mutation entry. - -Two things were found that this map did not name: - -- **`CultNetDocumentBinding` can carry a schema id that differs from its - descriptor's.** The deleted engines checked for this; the evaluator reads - only the descriptor and cannot see it. The fix is at the call sites - (`WithBindingSchemaAlias`, `ExpandSchemaBindingAliases`), so the evaluator - stays independent of the registry. -- **A fourth copy of schema matching, at `CultNetDatabase.cs:1707`**, which - serves `CreateShardSnapshotResponse`. §1 counted three engines; there are four. - **Self's ruling, 2026-09-22: it collapses into the evaluator in commit 2.** - Leaving it would make the claim of one evaluator false. It is a deletion and - takes a mutation entry like the others. - -**Q-J was not implemented, and the map is the reason.** Commits 0 and 1 -shipped `number` as `double?` (`CultNetSelection.cs:71`), `CompareNumber` as -IEEE comparison (`CultNetSelectionEvaluator.cs:103-113`), a JSON schema that -says `"type": "number"`, and a cache `NumberOf` that returns `double`. The -operator had already ruled decimal strings, and §16 recorded it, but §2 and -D8 still specified float64, and nothing specified the canonical form or the -comparison that the ruling explicitly required. Hands built what §2 said. The -Rust Hands caught the conflict before writing a line and stopped, correctly. -**Self swept §2, D8 and the §7 table on 2026-09-22**, and §2 "Numbers" now -specifies the form. The Q-J fix lands on the branch before the Rust runtime, -as its own commits. Commit 1 is not wire-final until it does. - -**Commit 2 landed** (Sonnet) in five parts: -- `0787608` deletes `_projectRecord`. Its two tests now drive a real change of - identity instead of a projection. It also collapses the fourth matcher. -- `c5b03cb` collapses the CultMesh alias checks. -- `4167cc4` adds the fourth matcher's mutation entry. -- `5ba48f0` finishes the Mesh collapse. `CultMeshSnapshotRequestOptions` and - `CultMeshPeerSnapshotDocumentOptions` become records that carry one - `Selection`, and their clones collapse to `with`. `CleanSnapshotFilter` and - the triple rule give way to two owners, `ResolveDefaultSelection` and - `OverlaySelection`. `CultMeshHotBodySubscription` carries one `Selection`. - The four-tier read fallback becomes one read anchored on the record key, - with the two tiers that could return the wrong key's record deleted. -- `4c33a62` adds the Mesh entries: three reverts killed and two loosenings - **survived**. The survivals are fixture gaps, since no test passes an empty - non-null `recordKeys` or a record key with different casing. They go to the - fix batch. - -Mesh is net **−83** against §11's estimate of about −326. The shortfall has -four parts: -- about −41 is the payload-sniff fallback, which was kept; -- `IsSameCultDocumentSchema` stays, because it already delegates entirely and - inlining it would duplicate the resolution at four sites; -- `CultMeshClient`'s three subscription sites still call the v0 - `SubscribeAsync`, which this cut does not retype. They move with Cut 2, - the watch cut; -- the read keeps two tiers, because a test enforces that. - -This is an honest miss. - -**Two corrections to Hands' report.** First, the payload-sniff fallback was -**not "ruled kept by the operator"**. Hands kept it in `c5b03cb` as a -discrepancy, and Soul is judging whether it is a second selection decision or -a decode capability. Second, Hands reports that one Networking test crashes the -test host on a disposed-socket race in `CultNetRudpSchemaServer`/`CultNetTransport` -and calls it pre-existing. Networking was 162/162 at `17d10e0`, so that claim -must be checked against `17d10e0` and `main` before anyone believes it. It goes -to Soul by name. - -**Q-J fix landed** at `e5348d3` (commit 2f, C#). The Rust runtime is next. - -**Soul on commit 2, 2026-09-22** (Opus, pinned at `4c33a62`). **Commit 2 does -not pass.** - -- **S2-1, medium, predates the range.** The crash is real, and Hands was right - that it is older than this commit. It is a disposed-socket race: the ack - `SendTo` at `CultNetTransport.cs:2549/2593` runs on a test's background poll - thread. About 18 tests start `IsBackground` poll threads, and only one of - them (`:1885`) joins its thread before the server disposes. Crash rates: - - | Checkout | Suite | Crashes | - |---|---|---| - | `17d10e0` | full | 1 of 6 | - | `17d10e0` | subscription subset | 5 of 12 | - | `main` | subscription subset | 1 of 12 | - - "162/162" was luck. A second defect sits in the harness: - `mutate-dotnet.ps1:43/61`, under `$ErrorActionPreference='Stop'` on - PowerShell 5.1, throws the whole run away when a host crash writes to - stderr, where it should record the mutant as NO VERDICT. -- **S2-2, high: the rewritten reconcile tests lost what the old ones proved.** - With `_projectRecord` gone, a source key always equals its record key, and - the delete-then-put now arrives through the live `Watch` path, so - `Reconcile()` has nothing left to do. - - Two mutants that `17d10e0` killed now survive: dropping Reconcile's - identity branch (`:261`), and returning early from Reconcile. - - Dropping the add loop (`:274`) and dropping the live identity branch - (`:340`) survive both before and after the rewrite. - - The `RecordKey` comparisons at `:261` and `:340`, and the throw at - `:311`, are now **dead code**. -- **S2-3, high: the fourth matcher was collapsed into the alias matcher, not - into the evaluator.** `CreateShardSnapshotResponse` - (`CultNetDatabase.cs:633-670`) still loops on its own. - - A probe sent `{schemas:[], keys:[]}` to both paths: the shard path - returned 0 rows, `CreateRawSnapshotResponse` returned 2. - - The binding-alias expansion does not run on the shard path either. That - part is plausible, not probed. - - §2 says an empty list is **refused at the door**. The evaluator reads `[]` - as "no filter" (`CultNetSelectionEvaluator.cs:84`) and the shard path - reads it as "nothing". Neither follows the map. -- **S2-4, medium-high: the Mesh one-pass read returns the wrong schema's - record.** At `CultMesh.cs:2730-2750`, the first candidate at the key that - passes the exact match, the alias match or a trial decode wins. With - `[MeshOther, MeshNote]` at one key, a MeshNote read returned MeshOther. - Before `5ba48f0`, the exact schema was searched first. -- **S2-5, medium: Mesh has two decode rules that disagree.** The read accepts - a record by trial decode. `DecodeSnapshotDocuments` rejects the same record - by payload sniff. `RawSnapshotPayloadMatchesSchema` is a real decode - capability, since both of its tests are keys-only. **It is not a second - selection decision.** It is, though, a second copy of the registry's - resolver (`CultNetDocumentRegistry.TryResolveDescriptorByPayloadSchema` / - `TryReadSchemaVersion` / `InferSchemaName`, `:596-670`). -- **S2-6, high: the public `CultMeshSnapshotRequestOptions.Selection` honours - only `Schemas` and `Keys`.** Mesh sends v0 only. A request with a limit, a - field predicate and a header projection went out as `schemas=null - keys=null`, and two full rows came back. A caller's `Selection` also skips - the old cleaning, so `Keys=[""]` now returns nothing where it used to return - everything. -- **S2-7, low, predates the range: selection meaning is decided in two more - places.** `ResolveDefaultSelection` (`:835`) checks the raw `Count` before - cleaning, so `[" "]` selects everything. `ResolveDefaultSelection` reads - null as "no filter", and `OverlaySelection` (`:840`) reads it as "inherit". -- **S2-8, low.** Both options types changed from `class` to `record`, which - gives them value equality and is acceptable. - `CultMeshHotBodySubscription.Selection` exposes mutable arrays on a contract - that was immutable. The prebuilt Unity `GameCult.Mesh.dll` carries the old - API: a release-time follow-up, rebuilt at the next release cut. -- **S2-9 and S2-10:** a miscount in the entries header. For the two Mesh - survivors, Soul's fixtures kill both. -- **Held:** Mesh 3 killed and 2 survived, as reported. Networking 10 of 10 - killed. Every restore verified by hash. The alias-matcher routing is right. - `IsSameCultDocumentSchema` delegates. - -**Self's rulings, 2026-09-22, for the commit 2 fix batch:** - -- **Empty lists and blank keys are refused at the one door, as §2 already - says.** `CultNetSelection.Validate` refuses `keys: []`, `schemas: []`, and - any key or schema that is empty or whitespace, with `selection_invalid`. - `null` means no filter, everywhere. The evaluator never sees `[]`. v0 - lowering carries over v0's old cleaning: an empty v0 list, or one made only - of blanks, lowers to `null`. That is a v0 compatibility rule the lowering - owns, not a meaning the evaluator carries. `ResolveDefaultSelection` and - `OverlaySelection` stop deciding what null means. They build a - `CultNetSelection` and let the door decide. Overlay means "the caller's - selection replaces the default wholesale". -- **The shard snapshot answers through the evaluator**, binding aliases - included, with no loop of its own. -- **Mesh keeps sending v0 in this cut.** §9 says v0-only peers refuse v1, and - FU-v0 retires v0 later. So `CultMeshSnapshotRequestOptions` refuses, loudly - and typed at construction or send, any `Selection` term v0 cannot carry: - `fields`, `cites`, `cited`, `limit`, `cursor`, `descending`, `projection` - other than the default. **Refused, never silently dropped.** Mesh sending v1 - is a follow-up, **FU-Mesh-v1**, triggered by the first Mesh caller that - needs a term beyond schemas and keys, most likely the Huginn consumer or - Cut 2. -- **The Mesh read searches the exact schema first,** then the alias match, - then a foreign id decoded by payload. It uses **one** decode rule shared - with `DecodeSnapshotDocuments`, and that rule is the registry's resolver. - The Mesh copy in `CultMeshSnapshots.cs` is deleted in favour of - `CultNetDocumentRegistry`'s. -- **The dead identity code is deleted, not tested around.** `:261`, `:340` - and `:311` can no longer fire. Reconcile gets a test for what it still owns - after the deletion: flipping `authorizeRecord` per key while the request - stays authorized, and the add loop. Both surviving mutants must die. -- **Test hygiene belongs to this batch, because a flaky M0 is not a - control.** Every test that starts a background poll thread joins it before - its server is disposed. `mutate-dotnet.ps1` records a host crash as NO - VERDICT and carries on. -- **Also owed by Cut 1 and not yet done: R-2.** Python replies - `unsupported_schema_version` to v1 (§9, `interop_peer.py:360-387`, - `cultmesh_py/server.py:341`), with one test per site. - -**Rust commit 3 landed** at `b090ca9`. Its parity vectors wait on the fix -batch below. - -**The commit 2 fix batch landed** (Sonnet), `568e8e3` and `021e3f1`: - -- **Door and lowering.** The door refuses blank and whitespace entries, and - `CultNetV0SelectionLowering` owns the v0 cleaning. -- **Shard snapshot.** It answers through the evaluator - (`NET-D4-ShardMembership-Revert`), with a fixture for exclusion outside the - shard's prefix. -- **Mesh v0 terms.** `CultMeshSnapshotRequestOptions` refuses any term v0 cannot - carry, and `HotBodySubscription.Selection` returns a copy. -- **Mesh read order.** The read goes exact, then alias, then payload, under one - decode rule, and the Mesh copy of the resolver is deleted. The shared rule - is `CultNetDocumentRegistry.TryReadSchemaVersion`, now public, matched against - the caller's own descriptor. `TryResolveDescriptorByPayloadSchema` is - ambiguous when two CLR types alias one schema id, which the foreign-id - fixture does on purpose. -- **Dead code and test hygiene.** The dead identity code in Reconcile is - deleted, and the poll threads are joined. -- **Harness.** `mutate-dotnet.ps1` records a host crash as NO VERDICT. -- **R-2.** The Python v0 peer refuses v1. - -Tests: Networking 195/195 over ten consecutive runs, with no crash. Mesh -253/254 with one skip that was already there. Caching 192/192. cultnet-py -54/54. Mutation entries 22/22 killed across the fix-batch, Mesh and Networking -files, and both Mesh survivors now die. Delta: Mesh −3, Networking +62. - -**Open for Soul:** - -- It is unclear whether the door now refuses `[]`, as ruled, or only blank - entries. The report names blank entries only. -- Seven `cultmesh-py` daemon tests fail on `ModuleNotFoundError: cultcache_py` - in a spawned child process. Hands calls this pre-existing; `main` must - confirm it. -- The anchor-matching fragility of `mutate-dotnet.ps1` (separator spelling) is - recorded, not fixed. - -**Commit 4 landed** (Sonnet) at `00f4c02`, completing Cut 1's execution. -- **Parity vectors (S12):** `contracts/cultnet/interop/selection-vectors.{cs,rs}-written.json`, - 8 vectors each, read in both directions. Six are evaluated selections. Two - are door refusals: `schemas: []`, and a blank key. -- **Door:** `keys: []` and `schemas: []` **are** refused (`CultNetSelection.cs:326/328`), - as ruled. -- **Tests:** cultnet-rs 111 → 174, cultcache-rs 64 (unchanged), Networking - 196 + 1 skip, Caching 192, Mesh 252/253. -- **Mutation entries**, all killed: - - Rust 23/23; - - Caching 10/10, including 4 Q-J; - - Networking 15/15, including 5 Q-J. - - S6 first survived. Its fixture now carries two references to the same - target under different roles. S9–S15 and S17 do not apply to Rust - (Rust has no subscription client). -- **Open for Soul, highest first:** - - **No `cites` vectors cross the runtimes.** Hands says C#'s - `MatchesCitation` compares `Citation.Target.SchemaId` against the real - SHA-256 schema id with no alias fallback, so "this fixture pair cannot - agree". That is either a fixture limit or **a wire-parity gap in the - hop**, and parity is this cut's invariant. Soul settles which. - - **Size:** `selection.rs` is 1,407 lines and `contracts.rs` +595, about - 2,000 in all against §14's roughly 430. - - Hands calls S20 "structurally vacuous" and S23 without a surface in Rust. - Both are claims, not yet reached, and need checking. -- **A flaky test, recorded as a follow-up.** - `reactive_document_coalesces_direct_same_schema_alias_member_writes` - (`packages/cultnet-rs/tests/cultnet.rs`) fails under the harness's - invocation of the full binary and passes in isolation. The v0-lowering entry's - command was narrowed around it. It is not this cut's code. Its owner is the - reactive-document path. - -**Two pre-merge additions from the Huginn read-side map, 2026-09-22.** They -join the next selection fix batch, whatever the final Soul pass adds. - -- **P-1:** Rust's `Evaluation` gains `matched`. Rust cannot fill the page's - `matched` today. -- **P-2:** derive `Eq` on the selection wire types, because Huginn's request - derives it. - -**Load-bearing for Huginn:** `Cursor::parse` is public and exposes `as_of`. -The organ answers a cursor's page at the cursor's own `asOf`. If a finding -makes `parse` private, expose `cursor_as_of` instead. - -**Soul's whole-cut pass, 2026-09-22** (Opus, at `00f4c02`). **Cut 1 does not -merge.** The notes are in the session scratchpad at `soul-ss4-notes.md`. - -- **High, confirmed:** - - **The C# reference never answers v1.** No v1 listener is registered - (`CultNetDatabaseServer.cs:49-55`, `Server.cs:562-571`). - `CreateSelectionResponse` and `LastWriteSequence` have no callers. §7's - server handling, D6's subscription v1 and S9 were never built. Hands - reported none of it missing. - - **`cited` returns the wrong edges in both runtimes.** Edges are filtered by - whether the *citer* is on the page, but under `cited` the page rows are the - *cited* rows. `exists:true` gives no edges. `exists:false` gives edges into - rows that are not on the page. The committed vector pins the wrong answer. - - **The C# door accepts `"5\n"`.** .NET's `$` matches before a final - newline. Rust and the schema refuse it. -- **Parity broken on caller inputs:** - - **Float rendering at ties.** 394 `f32` and 48 `f64` values out of 200k - render differently, because .NET rounds half to even and Rust does not. - A shortest form is a stand-in for the value in any case: an `f32` of 3e20 - is stored as 300000006012263202816, bits `0x61821ab1`. (Corrected - 2026-09-22. Soul's report and this map first gave 300000002010536247296. - The Rust Hands and an independent Python `Decimal` check both give - ...6012263202816.) - - **`schemas`.** C# matches through the alias matcher and Rust matches exact - ids. `["leaf_a"]` gives 8 rows against 0. - - **Tiebreak.** C# compares UTF-16 code units and Rust compares UTF-8 - bytes, so astral keys sort in opposite orders. - - **`cited` edge order.** It comes from a Rust `HashMap` and is - nondeterministic. - - **`any_of` on a numeric alias.** C# goes through a culture-dependent - `ToString()`. -- **The door is advisory.** Both `select` implementations are public and never - validate. Rust's `matches` only `debug_assert`s the hop, so a release build - ignores `cites` and `cited`. Mesh `EnsureV0Compatible` lets `Keys=[]` and - `[""]` through, and v0 lowering turns them into "every key". -- **Not what the map specifies:** - - `Matched` counts the page, which breaks C5. - - v0 and shard snapshots re-evaluate the whole cache on every page, which is - O(N²/200), and cannot detect a write between pages. - - Cursor digests collide: `["a|b"]` digests the same as `["a","b"]`. - - S20 has no C# test. Two S20 mutants survive 196/196. Rust `select` - ignores `projection`, so the rule has no owner there. Nothing tests - `SelectPage` or `CreateSelectionResponse`. -- **The Networking host still crashes**, 2 in 11 runs. The flaky `HasConsumers` - assertion (`NetworkingTests.cs:1720`) predates this cut. Joins sit outside - `finally` in about 18 tests, so a failed assertion becomes a host crash. The - "10 runs, no crash" claim did not reproduce. -- **Low:** - - The JSON schema disagrees with the runtimes on `limit` bounds and on - `minItems`. - - Python R-2 refuses only v1, so v2 and later are still dropped. - - `TryReadSchemaVersion` is a public sniff heuristic, and two Mesh sites - repeat the same line around it. - - Rust v0 dedups before `reject_duplicates`, so that function is dead. - - `mutate-dotnet.ps1` throws on `\` against `/` in paths. -- **Deletions Soul named:** - - `contracts.rs:1206-1541`, about 335 lines of hand codecs that the serde - derives already round-trip, verified both ways; - - `expand_scientific_notation`, about 46 lines, dead: 400k renders produced - no exponent; - - `reject_duplicates`; - - `RawDocumentHeader::from_document`, which has no callers; - - C#'s `WithBindingSchemaAlias`/`ExpandSchemaBindingAliases` duplicate, - about 60 lines, and a shared lower-and-page loop, about 20 lines. -- **Settled:** `cites` is a fixture limit, not a parity gap. With real SHA-256 - ids, 40 selections agree byte for byte. The seven `cultmesh-py` failures - are environmental: with `PYTHONPATH` set, 78/78 pass. The flaky Rust test - waits 30×5 ms for a flusher, which is too short under contention, and it is - not this cut's. -- **Held:** - - Every mutation suite killed everything. - - Door refusals are byte-identical apart from `"5\n"`. - - The Q-J comparator agrees with Python `Decimal`. - - No float sits on either comparison path. - - Negation, limit clamping and v0 dedup are at parity. - - Mesh reads in the order exact, then alias, then payload. - - Mesh is actually 253/254. - -**Self's rulings for the Cut 1 fix batch, 2026-09-22:** - -- **R-A. Serving v1 is part of this cut.** Both C# servers register v1 - listeners. The snapshot answers through `CreateSelectionResponse` in - last-write order, and the subscription server answers v1 as D6 and §7 say, - with S9 tested. A v1 request that is not served is a defect, not a - follow-up. -- **R-B. Hop edges follow the hop's direction.** Under `cites`, the edges are - the ones *from* page rows. Under `cited`, they are the ones *into* page - rows. Every edge touches a page row. The order is deterministic: the - page-row order, then `(from, role, to)` in code-point order. Regenerate the - vectors. -- **R-C. Every string comparison in the vocabulary uses Unicode code-point - order.** In Rust that is UTF-8 byte order. C# compares by code point, not - by UTF-16 unit. This covers the tiebreak, edge order and anything else - ordered. -- **R-D. A floating-point member renders as its exact decimal expansion, - in canonical form, and not as a shortest form.** Every finite `f32` and - `f64` is an exact dyadic rational and has a finite decimal expansion. That - expansion is the stored value, it is the same in both runtimes by - construction, and it matches the reason for Q-J. Implement it from - mantissa and exponent, with `BigInteger` in C# and a small bignum in Rust. - Add no new dependency unless the expansion cannot be written in about 60 - lines. `decimal` and the integers are unchanged. **Flagged for the - operator's review:** this is Self's reading of Q-J, and it changes what - `ge "3e20"` means for an `f32` of 3e20. **Accepted by the operator, - 2026-09-22** ("I accept your recommendations"). -- **R-E. There is one schema-identity rule in both runtimes.** Rust gets the - alias matcher (the owner is `cultnet-rs`, ported from - `CultNetSchemaAliasMatching`). `schemas`, `cites.target.schemaId` and the - binding id emitted on records all go through it. A `cites` target that - matches no schema is refused at the door, never answered with an empty page. - `ToRawRecord` and `ToEdge` emit the same id. -- **R-F. The door is inside `select`.** `select` validates first, in both - runtimes, and returns the typed refusal. A public entry point that skips - validation does not exist. Rust's hop handling is not a `debug_assert`. - Mesh's `EnsureV0Compatible` runs the door first. -- **R-G. `matched` is the total number of matches, not the page count** (C5). - Rust's `Evaluation` carries it (P-1). A single evaluation answers v0 and - shard paging, taken as one snapshot. -- **R-H. Cursor digests use length-prefixed encoding** for every string and - list, in both runtimes. -- **R-I. The projection has an owner in both runtimes.** `cultnet-rs` gets - `select_page`, which produces `SelectionPage` under `projection`, with - `matched` and edges. C# `SelectPage` and `CreateSelectionResponse` get - tests, and so does S20. Page bytes are compared across the runtimes in the - parity vectors. -- **R-J. `any_of` on a numeric alias** compares the canonical rendering. -- **R-K. Test hygiene is finished, not claimed.** Every poll-thread join - moves into `finally`, and the `HasConsumers` race gets a deterministic - wait. The fix is proven by 20 consecutive full runs. -- **R-L. The contract follows the runtimes.** The schema gains - `minItems: 1` on `schemas` and `keys`, and `limit` is documented as - clamped. Python refuses every `cultnet.*.vN` with N > 0. - `TryReadSchemaVersion` goes back to internal, behind a registry method that - takes the descriptor. `mutate-dotnet.ps1` normalises path separators. -- **R-M. Soul's named deletions all land.** P-2 (`Eq`) lands too. - -**The C# half of the fix batch landed** (Sonnet), `7903853`..`3d32c67`. - -What changed: -- **R-A:** v1 is served by both servers, and D6 reconcile routing is in place. -- **R-C:** `CultNetCodePointComparer` gives code-point order. -- **R-D:** floats render as their exact decimal expansion, computed with - `BigInteger`. -- **R-E:** cites go through the alias matcher, and the wire id is one - `WireSchemaId`. -- **R-F:** the door is unconditional inside `Select`. -- **R-G:** `Matched` is the total, computed once through `EvaluateAll` and - `SelectAll`. -- **R-H:** the cursor digest is length-prefixed. -- **R-J:** numeric `any_of` compares the canonical form. -- **R-M:** `WithBindingSchemaAlias` and the duplicated paging loop are deleted. -- **R-I:** tests kill both S20 mutants. One real bug was fixed in the - process: `ToEdge` serialised a plain-typed payload as a document. -- **R-K:** every join is in `finally`. `HasConsumers` now waits for the - condition. -- **R-L:** the schema carries `minItems`. Python refuses every vN>0 (only - one site exists). The harness normalises path separators. -- **Vectors:** `cs-written.json` is regenerated and gains the float-tie, - cites-by-alias, astral-order and projection cases. - -Tests: Networking 201/202, where the one failure is the stale Rust vector -until the Rust half lands. Caching 192. Mesh 253/254. Python 54, 78 and 34. In -20 full runs there was no crash, but one run had an unexplained failure. - -**Not done, sent to a second Hands:** mutation entries for the fix-batch -rules (there are only regression tests), S9, and a diagnosis of the 1-in-20 -failure over 30 runs. - -**The Rust half of the fix batch landed** (Sonnet), `8b114ed`..`a088435`: -- 36/36 entries killed. -- Three real bugs were found while it ran, among them a v0 fast path that - had inherited the door's "empty matches all". -- The `contracts.rs` hand codecs are gone (−362/+35). -- The Rust Hands corrected `f32` 3e20 to `300000006012263202816`. - -**Shared parity fixture** (Sonnet), `3317ddd` and `defb9a1`. Both runtimes now -build their vectors from -`contracts/cultnet/interop/selection-vectors.fixture.json`, which uses real -SHA-256 ids. A test bug is fixed: both readers had compared the page size with -`matched`. Of 15 vectors in each direction, the following agree byte for byte: -exact ids, float tie, astral order, header and document projection, -`cites`/`cited`, and the refusals. **Two real parity defects:** -- **Two incompatible alias rules.** C#'s `CultNetSchemaAliasMatching.Matches` - (`CultNetDatabase.cs:74-87`) strips `.vN` and compares against the - descriptor's `SchemaName`. Rust's `schema_alias::matches` - (`selection.rs:452-459`) strips `.vN` and compares against the *hash*. No - alias resolves in both. -- **C# does not refuse an unresolved `cites.target`** (`CultNetSelection.cs:361-391`), - which R-E requires. Rust does refuse it. - -**Self's ruling, 2026-09-22: the C# reference's alias rule is the rule.** -CultLib keeps wire parity against the C# reference. An alias is a schema -*name* with a `.vN` suffix, resolved against the descriptor's name. A -hash-shaped alias is not a wire form. Rust ports the name rule, which means -its `RowSet` must expose each schema's name, and it deletes the hash-stripping -matcher. C# refuses an unresolved `cites.target` at the door. Each vector that -fails today becomes a vector both runtimes must pass. - -**The Rust alias port landed** (Sonnet). Rust's `schema_alias::matches` is -now `(candidate, schema_id, schema_name)`, and it matches the C# reference row -for row: exact id, bare name, `.vN` on the name, case-sensitive, the last -`.v` marker wins, and `.v` with no digits is taken literally. The C# table was -produced by running the reference source. The hash-stripping overload is -deleted. `SchemaVersion` and `CompatibleSchemaIds` are not ported, because no -Rust call site needs them; that is a stated reduction. Rust entries are 40/40 -killed. The whole suite had never run under `-Repo` before, and its commands -now carry `--manifest-path`. - -| Reader | Vectors from | Pass | -|---|---|---| -| Rust | `cs-written` | 15/15 | -| C# | `rs-written` | 14/16 | - -The two C# failures both come from the pending C# door refusal of an -unmatched `cites.target`, which sits with the matrix Hands. - -**The early Soul pass (commits 0–1, pinned at `17d10e0`) reported late, on -2026-09-22.** It was interrupted three times by API errors. Much of what it -found is already covered by R-A to R-M. These findings are **new, and still -open against the current branch:** - -- **F2, high: typed refusals never reach the wire.** `CultNetErrorMessage` - (`CultNetSchemaMessages.cs:~498-512`) has no `code` and no `details`. Nothing - maps the selection or cursor exceptions to an error. This means - `selection_invalid`, `cursor_stale`, `cursor_invalid` and - `reference_outside_target` exist only in-process. -- **F6, high: the cursor can be forged.** The digest is an unkeyed SHA-256 - that anyone can recompute, so any caller can mint a cursor. A record key - containing the U+241F delimiter makes a server's own cursor fail to parse. -- **F7, high: authorization sees two different ids.** On the snapshot path, - the authorizer receives the binding's wire id. On the live path it receives - the descriptor id (`CultNetDatabaseSubscriptionServer.cs:~309` against - `:~451`). A row delivered by the snapshot can therefore be refused on its - first live change, or leak through a denylist. No test pins the live id. -- **F8, medium: `LastWriteSequence` is not the order a snapshot reflects.** - - Replica apply paths (`CultNetDatabase.cs:~1416`, `:~1459`) never set it. - - Nothing rebuilds it after a restart. - - Sequences are per shard, but `asOf` is a single `ulong`. -- **F11, medium: v0 lowering changed what v0 answers.** A snapshot with - `recordKeys: []` used to answer empty, and now answers every row. v0 rows - now come back in schema-and-key order instead of the requested key order. -- **F12, medium: the committed schemas do not describe the bytes C# writes.** - - Headers `$ref` a record schema that requires `payload`. - - MessagePack-CSharp writes both `headers` and `documents`, one of them - nil, so every C# page fails the `oneOf`. - - `fieldPredicate` does not forbid `values` and `number` together. -- **F14, low, now reachable because v1 is served: field predicates on a - Removed change throw.** `TryGetIndexValue(null)`, at - `CultNetDatabaseServer.cs:~375`. -- **F15, low: `cites` skips the out-of-target check** for edges that do not - point at the requested key. `EnsureWithinDeclaredTarget` also returns early - when `TargetType` is null. -- **Surviving mutants:** - - S1-Loose (reachable becomes all descriptors); - - S2-AllOf; - - S17-FirstLeaf; - - Door-NoValidate, since fixed by R-F; - - S5-DigestNoFields; - - Auth-LiveSchemaId, which is F7; - - QL-OutOfTargetCites, which is F15. - - S4 has no entry. A clone at `C:\ss1` was left behind: the Soul pass could - not remove it. - -**Self's rulings for fix batch 3, 2026-09-22.** Batch 3 goes to Hands once the -C# matrix Hands and the Rust alias port have landed, so that no two C# Hands -edit `src/` at the same time. - -- **R-N, F2: refusals are wire messages.** `cultnet.error.v0` gains `code` and - `details`. That is an additive field, so the version is unchanged, and v0 - peers ignore it. Every selection and cursor refusal, and - `reference_outside_target`, maps to its code in both servers and in Rust. - Tests decode the bytes a peer actually receives. -- **R-O, F6: cursors are keyed.** The digest becomes an HMAC under a key the - answering server holds. The key is random per process, so a cursor does not - survive a restart and answers `cursor_invalid`. That is acceptable, because - cursors are short-lived and §2 already calls them "minted by the answering - server". The cursor body uses length-prefixed fields, not a delimiter. Rust - does the same, since Huginn mints cursors. -- **R-P, F7: one id reaches the authorizer, and it is the wire id**, on the - snapshot, live and reconcile paths alike. A test pins the id each path - passes. -- **R-Q, F8:** every path that commits a row, whether local or a replica - apply, sets the last-write sequence. It is rebuilt from the mutation log at - startup. A multi-shard selection's `asOf` is defined, or refused: a - selection that spans shards is answered only when every row comes from one - shard's log. Otherwise it is refused with `cursor_stale`/`selection_invalid` - as appropriate, and the choice is documented in §2. A single shard is the - case today. -- **R-R, F11: v0 lowering preserves v0's pre-cut answers exactly.** v0 is a - frozen contract for the TS, Python and Kotlin peers. **This corrects the - earlier ruling in the commit 2 fix batch**, which lowered an empty v0 list - to "no filter". Where the pre-cut v0 server answered empty for - `recordKeys: []`, it still answers empty. Where pre-cut v0 kept the - requested key order, it still does. The pre-cut behaviour comes from the - code at `b3d9cf7`, and tests prove it by running the same requests against - both. -- **R-S, F12: the schemas describe the bytes.** Add a header schema, make the - page shape match what MessagePack-CSharp writes (nil keys included), and - make `fieldPredicate` exclusive. A test decodes real C# bytes against the - schemas. -- **R-T, F14 and F15:** removed changes are evaluated without reading a - document. A removal matches through the selection's keys and schemas - alone, and field predicates count as unknown. `cites` checks every edge - against its declared target. -- **R-U: every surviving mutant from the early pass becomes an entry, and it - must die.** That covers S1-Loose, S2-AllOf, S17-FirstLeaf, - S5-DigestNoFields, Auth-LiveSchemaId, QL-OutOfTargetCites and an S4 entry. - -**Fix batch 3 is landing in pieces, 2026-09-22.** - -- **The harness is retired** (operator ruling). The branch's `mutate-dotnet.ps1`, - the four `*.entries.ps1` and the Rust entries file are deleted. Tests pin - behaviour, and Soul runs Stryker.NET and cargo-mutants on the diff. -- **C#, first pass** (`8d7bee9..f366791`): R-R (v0 lowering answers exactly - what pre-cut v0 answered, key order included) and the cites-refusal vectors. - C# now reads 16 of 16 Rust vectors. It stopped there, so R-N, R-O, R-P, R-Q, - R-S, R-T and R-U were left. - - **R-R meets R-F:** the raw v0 wire answers an explicit empty list with an - empty page, while Mesh's `EnsureV0Compatible` refuses that list before - sending. Both layers keep their own ruling, which is right. -- **Rust** (`5cf31d1..c606eb3`): R-O (keyed cursor), R-T, R-R, and the entries - file deleted. - - **The cursor API for Huginn:** `Cursor::parse` stays public and key-free - and still exposes `as_of`. Only digest verification needs the process key, - so no second helper was needed. - - Rust reads 17 of 17 C# vectors. - - **R-N is pending in Rust by design.** An earlier guess at the wire shape - was backed out; Rust matches C#'s field names byte for byte once they land. -- **C# pass A is in Hands:** R-N, R-P, R-T. **Pass B follows:** R-O, R-Q, R-S, - R-U. -- **C# pass A landed** (`66b5e60`, `e8a3dec`): R-N, R-P and R-T. - - **R-N's wire shape:** `CultNetErrorMessage` gains `code` and `details`. - `CultNetErrorDetails` carries `field`, `value`, `asOf` and `current`. The - codes are `selection_invalid`, `cursor_stale`, `cursor_invalid` and - `reference_outside_target`. The schema gains both fields additively. - - Two catch sites that previously let the exception escape now answer the - peer. - - **R-P:** the live fast path authorized on the descriptor id and now uses - the wire id, so all three paths agree. - - **R-T:** a removal skips field predicates instead of dereferencing a null - document. `cites` no longer early-returns on a null target, and **the root - cause was in CultCache**: a many-reference declared without an explicit - attribute left its target type null, even though the element type was - statically known, so the out-of-target check silently skipped. - - Networking 223 pass and 2 skip; Mesh 255. - - **The Caching claim was wrong.** There is one failure, not three, and it - is identical at the branch head, at `b3d9cf7` and on `main`. It expects a - write to a read-only directory to fail, which cannot happen in a container - running as root. **Environmental.** -- **Rust R-N landed** (`eff62e5`): 213 tests pass. Parity is pinned by - **captured C# bytes** for all four codes, taken from a probe run on the - dotnet image. - - **An encoding trap the vectors would not have caught:** MessagePack C# - always writes all five declared keys in declaration order, nil included, - while Rust's generic path sorts keys alphabetically. Rust now builds that - map by hand. **A key added or reordered in either error type must be - mirrored there.** - - **A defect in C#, sent to pass B:** `ForReferenceOutsideTarget` prefixes a - message that already carries its own prefix, so a peer reads - `reference_outside_target: reference_outside_target: …`. - - The parity-vector machinery carries no concept of an error message, so - R-N's parity lives in its own byte-level test. That is the right home. -- **C# pass B landed** (`a4cf54f`..`52082ec`): R-O, R-Q, R-S and R-U, plus the - doubled `reference_outside_target` prefix. - - Networking 238 pass and 2 skip; Mesh 255. - - **Hand probes: six of seven killed.** S1-Loose, S2-AllOf, S17, S5-DigestNoFields, - Auth-LiveSchemaId and S4 all die. - - **QL-OutOfTargetCites is a genuine gap.** Since pass A fixed - `CultCache.ResolveReferenceTarget`, the fixture's many-reference gets an - inferred target type, so the guard never fires for it. `TargetType` is now - null only for a scalar reference typed as the bare `ICultRecordRef`, and - no fixture reaches that shape. **Open for Soul:** is that shape - registerable at all? If it is, pin it. If it is not, the null branch is - dead and goes. - - **Two fixes found while writing the tests:** - - the cursor's length prefix counted UTF-16 chars, so an astral key did - not round-trip; - - `MiniJsonSchemaValidator` had no `not`, so the exclusivity test found - nothing. - - **`cultnet.raw-document-record.schema.json` was missing `schemaName`, - `schemaVersion` and `schemaContentHash` entirely.** Any real C# page would - have failed it on `additionalProperties: false` before R-S's own bugs even - mattered. - - **Self's correction: cursors need no cross-runtime byte parity.** The - brief for pass B said Rust and C# must encode a cursor identically, on the - premise that one runtime parses another's cursor. **That premise is - wrong.** A cursor is opaque, minted by the answering server and echoed - back by the caller, and the digests cannot verify across processes because - each server holds its own key. Both encodings are length-prefixed - five-field bodies with an HMAC-SHA256 digest, and they differ in base64 - flavour and separators. That is correct and stays. Rust's own doc said so - first. - - **Settled by Soul:** three Caching failures, identical at `b3d9cf7` and - `52082ec`. All three expect a write to a read-only directory to fail, and - the container is root. **Environmental.** Pass B's count was right. - -**Soul's whole-cut pass, 2026-09-22** (Opus, at `52082ec`). **Cut 1 may not -merge.** - -- **Held:** Networking 238 and 2 skips, Mesh 255, cultnet-rs 213. R-Q holds - (both replica applies, the startup rebuild, and a shard-spanning refusal). - R-O holds against a stranger and across a restart, and the astral key - round-trips. R-H's digest covers every selection term. R-R holds and is - honest. R-A holds. R-F's door is inside `EvaluateAll`, which every path - reaches. The canonical-number door is anchored `\A..\z`. -- **S-1, high: the hop indexes rows by record key alone.** `byKey` - (`CultNetSelectionEvaluator.cs:176-178`) and Rust's `HashMap<&str, &R>` - (`selection.rs:1457`) both keep the last row at a key. CultCache keys are - unique **per schema**, and the Mesh tests already put two schemas at one - key. With rows in one order the selection refuses valid data as - `reference_outside_target`; in the other order it succeeds. Under `cited` - the index is a set of bare keys, so a row of one schema counts as cited - because something cites another schema at the same key. -- **S-2, high: R-T's `cites` half did not land in C#.** C# filters edges by - the citation's key (`:355`) **before** `EnsureWithinDeclaredTarget` (`:359`); - Rust checks first. A many-reference declared to one leaf but holding an edge - into another is refused by Rust and accepted by C#. -- **S-3, high: a selection with both hops loses its `cites` edges in Rust.** - `selection.rs:1541` computes one direction for every edge; C# anchors each - edge by its own hop. No vector covers both hops. -- **S-4, high: the error message fails its own schema.** Nothing decodes real - `CultNetErrorMessage` bytes against `cultnet.error.schema.json`. - `routingHint` is undeclared under `additionalProperties: false`, and nil - `details.asOf`, `details.current`, `code` and `details` all fail their - declared types. The header schema shows the nullable pattern was understood - and simply not applied here. -- **S-5, medium: Stryker leaves 85 survivors** over the cut's two core files: - 396 mutants, 310 killed, 85 survived, **75 with no coverage at all**, score - 66%. The old "every entry killed" was an artifact of a hand-picked list. -- **S-6, medium: the cursor is malleable in its own position.** The digest - covers the selection but not the body's `asOf`, `ordinal`, `schemaId` or - `recordKey`. A caller holding one valid cursor can rewrite its position and - reuse the digest. -- **S-7, medium: R-I's claim is false.** The vectors compare ids, `matched`, - `hasNext` and edges. They never compare page bytes, `asOf`, `next`, or a - refusal's code, and `rs-written.json` carries no projection vector at all. -- **S-8, low: the out-of-target null branch is dead.** D11 refuses a bare - `ICultRecordRef` in both scalar and many form, so every surviving shape has - a non-null target. -- **S-9, low: `asOf` is the maximum across all shards**, so a single-shard - page advertises another shard's number, and an unrelated write invalidates - a live cursor. -- **S-10, low: `MiniJsonSchemaValidator` silently ignores** `minimum`, - `maximum`, `maxLength`, `maxItems`, `anyOf`, `allOf`, `if/then/else`, - `uniqueItems` and `format`. The committed schemas use `minimum` 34 times, - including `limit`'s bound. Its `pattern` also runs through .NET `Regex`, - whose `$` accepts a trailing newline. -- **S-11, low:** the v1 subscribe refuses a hop before running the door and - always names field `cites`. -- **S-12, low:** the fixture's prose still calls the alias vectors a - cross-runtime defect, which the alias port fixed. Rust's port also drops - `SchemaVersion` and `CompatibleSchemaIds`, so R-E is two rules agreeing on a - subset. -- **Where the evidence lives.** The pass ran against `52082ec`. Its nine hand - probes — eight C# and the Rust both-hops probe that proved S-3 on a matched - pair — are on branch `soul-probe` in the scratch clone `C:\ss5` - (`e0fd672..107ff5f`), **unpushed**. Nothing reached origin and the pinned - checkout at `F:\Projects\CultLib` was never touched. Notes are at - `scratchpad/soul-sel-final-notes.md`. Probes are scratch by doctrine and are - meant to be thrown away; this pointer exists because S-1 through S-3 were - proven there and fix batch 4's tests have to reproduce them independently. If - `C:\ss5` is gone, the probes are gone with it, and that is acceptable — the - findings are recorded here, which is the durable copy. -- **Soul's own corrections, same pass.** It first reported a wedged - `cargo mutants` job on Yggdrasil and asked for it to be killed. Checking the - box rather than its log, the work directory was already gone: what it had - lost was its detached ssh's output. Self had by then killed the process, - which was Soul's own run, so nothing else was affected. **The shape is worth - keeping: a log is not the machine, and Self acted before confirming the - process was actually stalled.** -- **The Stryker triage is owed, after four attempts, none of them Stryker's - fault.** The `dotnet/sdk:10.0` image has no `python3`; the JSON reporter threw - on `CreateDirectory`; two runs with a different output path ran about fifty - minutes without finishing, against three minutes for the mutation phase that - did complete. The completed run stands, and the command is in Soul's notes: - `dotnet-stryker --project GameCult.Networking.csproj --mutate "**/CultNetSelection*.cs" --reporter json --reporter progress --concurrency 4`. - **Read the HTML report Stryker writes beside the JSON**, rather than parsing - JSON in the container. -- **The triage landed on the fifth attempt, 2026-09-22, and it sharpens S-5 - rather than softening it.** Most of the 85 are message-string mutations and - are not worth chasing; roughly a dozen are real, and they sit on the rules - this cut exists to enforce: - - `CultNetSelection.cs:439`, `Any()` → `All()` survived. §2's "a comparison - on an alias any reachable schema declares non-numeric is refused" degrades - to "refused only if every reachable schema declares it non-numeric". No - fixture has an alias numeric on one reachable leaf and a string on - another — the exact case the rule exists for. - - `CultNetSelection.cs:387`, `||` → `&&` survived. A `cites.target` with a - schemaId and a blank recordKey, or the reverse, stops being refused. - - `member.IndexAlias ?? member.MemberName` → `member.MemberName` survived at - all four sites (`CultNetSelectionEvaluator.cs:352,384,404` and - `CultNetSelection.cs:445`). §2's role-naming rule for the hop is untested - everywhere it is implemented. - - `CultNetSelectionEvaluator.cs:203,204`, `ThenBy` ↔ `ThenByDescending` - survived on both paths: the `(ordinal, schemaId, recordKey)` tiebreak is - pinned by nothing. - - `CultNetSelectionEvaluator.cs:290-297`, five order flips in `EdgesFor`, all - survived. **R-B's "page-row order, then `(from, role, to)` in code-point - order" has no test pinning a single component**, though R-B exists because - that ordering was wrong once already. - - `CultNetSelectionEvaluator.cs:590-605` has no coverage at all: - `ComputeDigest`'s `cites` and `cited` branches, plus the number-presence - flag at `:584-585`. R-H's collision-freedom rests on a reading, not a test. - - `:673,678` survived: `Cursor.Parse`'s length-prefix bounds checks, on - attacker-supplied base64. `:307,322` survived: cursor positioning under - `descending`, and `ComparePosition`'s schema-vs-key tiebreak. `:710,715,729` - survived: the code-point comparator's surrogate path, despite R-C having a - vector for it. - - **Equivalent, not to be chased:** `Selection.cs:103` `<=`, `:118` `>=`, - `:121` `dot <= 0` are guarded upstream and unreachable for canonical input; - `:103,107` turn `sign * x` into `sign / x` with `x` in {-1,1}; `:109` - Max→Min is a no-op because `PadRight` to a shorter length does nothing; - `:80` is a `RegexOptions` flag; `Evaluator:272` is equivalent because - `full.Edges` is empty without a hop. -- **Soul withdrew a finding of its own in the same pass.** It had reported that - C#'s cursor digest does not sort its lists while Rust's does, offered as a - low-severity intra-runtime difference. `CultNetSelectionEvaluator.cs:637` - sorts by code point, same as Rust. The remark belongs in no fix list. -- **cargo-mutants cannot run on `cultnet-rs` at all.** `schema_discovery.rs` - uses `include_str!("../../../contracts/…")`, which escapes the package, so - the tool's copied tree fails its baseline build. **There is no mutation - evidence for the Rust half**, and the package's own source shape is why. - -**Self's rulings for fix batch 4, 2026-09-22:** - -- **R-V (S-1). A row's identity is `(schemaId, recordKey)`, never the key - alone.** Both runtimes index rows and incoming edges by the pair. `RecordRef` - already carries both. Tests: two schemas at one key, in both row orders, - give the same answer; `cited` does not match a row of another schema at the - same key. -- **R-W (S-2 and S-3). The hop behaves identically in both runtimes.** The - target check runs **before** any key filtering, and each edge is anchored by - its own hop, so a selection carrying both `cites` and `cited` returns both - sets. C# adopts Rust's ordering for the first; Rust adopts C#'s per-edge - anchoring for the second. Vectors cover both. -- **R-X (S-4 and S-10). A message that fails its own schema is a defect.** - `cultnet.error.schema.json` declares `routingHint` and every nullable field - the way the header schema does. A test decodes real bytes for every code. - `MiniJsonSchemaValidator` **refuses a schema containing a keyword it does - not implement**, rather than ignoring it, and implements `minimum`, - `maximum`, `maxLength` and `maxItems`. Its `pattern` anchors so a trailing - newline cannot pass. -- **R-Y (S-6).** The cursor's HMAC covers the body as well as the selection, - so the position cannot be rewritten. Test: a rewritten ordinal or key is - refused. -- **R-Z (S-7).** The vectors compare **page bytes**, plus `asOf`, `next` and a - refusal's code, and carry a header-projection and a document-projection - vector on both sides. Where a field is legitimately per-server, such as a - cursor, the vector states that and compares the rest. -- **R-AA (S-5).** Triage all 85 survivors by name. The 75 uncovered mutants - mean whole regions have no test; write behavioural tests for them. A - survivor that is genuinely equivalent gets a one-line reason in the report. - **The triage half is done** (see the list under S-5, 2026-09-22). What is - owed is a behavioural test for each named live survivor: the alias - disagreement across reachable schemas, the half-blank `cites.target`, the - four index-alias role sites, the row tiebreak, `EdgesFor`'s ordering, - `ComputeDigest`'s hop branches, `Cursor.Parse`'s bounds, descending cursor - positioning, and the surrogate comparator. The equivalent mutants are - recorded and are not to be chased. -- **R-AB. Make `cultnet-rs` self-contained enough to mutate.** Replace the - escaping `include_str!` with a build script that stages the contracts into - `OUT_DIR`, or another route that keeps every source path inside the package. - Prove it by running cargo-mutants on the crate. -- **S-8:** delete the dead branch. -- **S-9:** `asOf` is the watermark of the shards the selection actually - covers. -- **S-11:** run the door first, and name the field that is actually set. -- **S-12:** correct the fixture's prose, and state Rust's alias reduction - where R-E is described. - -**Fix batch 4, C# half, landed** (Sonnet) on `cultnet/selection-cut1`, -`52082ec..b7d77b7`: - -- `e99bf46` — R-V, R-W, S-8, R-Y: row identity is `(schemaId, recordKey)`; the - cursor's HMAC covers its own body. -- `b3a8f6d` — S-9, S-11: `asOf` is scoped to the shards the selection covers; - the v1 subscribe door runs before the hop refusal. -- `b7d77b7` — R-X, S-4, S-10: the error schema matches the wire; the validator - refuses keywords it does not implement. - -Counts on Yggdrasil: Networking 247 pass / 2 skip (was 238, so +9 tests), Mesh -255 pass. Caching's three failures are the read-only-directory tests that -cannot fail under the stopgap's root container — unproven, not passing. - -**R-V proven in both row orders.** Before the fix, a narrow reference declared -to `SelLeafA` resolving a key shared with a `SelLeafB` row depended on -insertion order: one order refused a valid reference as `reference_outside_target`, -the other silently resolved to the wrong schema's row for `cited` membership. -After it, both orders resolve through the leaf set and `cited` never matches -the other schema's row at that key. - -**What R-X's new refusal exposed.** Twelve uses of unimplemented keywords -across three committed schemas, none reached by any existing test: -`cultnet.database-change-raw.schema.json` uses `allOf` and `if`/`then`/`else`; -both `cultmesh.verse-catalog-*.schema.json` use `uniqueItems` six times and -`anyOf` once. **Those three schemas are now formally unvalidatable** until -either the keywords are implemented or the schemas are rewritten. Nothing -broke, because nothing ran them through the validator — which is the finding. - -**Two gaps Hands named rather than papered over:** - -- **S-11 has no dedicated regression test.** `HandleSubscribeV1Async` is - private and reachable only through a live LiteNetLib round trip. Fixed by - inspection, covered only by the suite passing. Owed. -- The three unvalidatable schemas above need a decision: implement the - keywords, or rewrite them. - -**Ledger correction.** Commits 0 and 1 came in at about twice the §14 -estimate: - -| Package | Actual (net) | §14 estimate | -|---|---|---| -| Caching | +297 | about +150 | -| Networking | +851 | about +400 | -| contracts | 163 | about 200 | - -The two new Networking files alone are 714 lines, against about 360. The hop's -incoming index, the cursor's digest and mint, and the per-field door messages -all cost more than the prose assumed. The binding-alias fix was not in the -ledger at all. The estimate was wrong; the scope did not grow. The deletions -in commits 2 to 4 (Mesh collapse, `_projectRecord`, the Rust -`snapshot_query.rs`) are still to be counted against the total. - -Status: cut map for two cuts. **Cut 1: the selection vocabulary in the C# -reference runtime and the Rust runtime** (sections 1-17), with the -follow-on runtime cuts and the Huginn consumer cut named and not mapped. -**Cut 2: watching a selection** (section 18), mapped to the same standard, -landing after Cut 1 and depending on it. Cut 1 goes to Hands without -waiting on anything in Cut 2. - -**Rulings this map is written under (operator, 2026-09-17):** - -- The vocabulary lands in CultLib at the CultNet layer, not in Huginn. It - fills a hole: the query side of the substrate was never dropped by - decision, only never asked for. `contracts/cultnet/cultnet-distributed-database.md:10-11` - names RethinkDB changefeeds with "point, table/schema, and **filtered - watches**" as prior art to keep; schema and key allowlists were built, - filtered selection never was. -- The first cut covers the C# reference (`src\GameCult.Networking`) and - Rust (`packages\cultnet-rs`, what Huginn consumes). TypeScript, Python and - Kotlin follow when they have a caller. -- Deletes first: the two untyped stand-ins are replaced, not sat beside. -- The CultMesh subtraction audit is a required part of the map, with real - line counts, and an honest miss beats a padded ledger. -- Nothing on the wire is serde-untagged (rule of this cut; evidence below). - -**What survives unchanged from the Huginn-targeted specification** -(`scratchpad/cut10b-read-side-spec.md`, D1-D4): the five capabilities, the -chosen representation and the rejected ones with their reasons, the order and -snapshot cursor, the role-typed hop, the one negation, and the bound. What -changes: owner, repo, the value model of a field predicate (strings, because -the cache's indexes are strings), the parity obligation, and the subtraction. - -## Pins - -| Repo | Branch | HEAD | State | -|---|---|---|---| -| CultLib | `main` | `51fb449` | dirty in `native/GameCult.Mesh.Quic.Native/*` and `scripts/mutate-cultmesh.mjs` from the live QUIC campaign; **not touched**. Every `file:line` below is against `51fb449`. | -| Huginn | `eureka/memory-organ` | `25a841d` | the consumer; its cut is named in section 12 and mapped in the Epiphany campaign map. | -| Epiphany leaf | `5cda0886` | — | untouched. | - -Baselines: `src/GameCult.Networking` 14,848 lines; `src/GameCult.Mesh` -21,720 lines; `tests/GameCult.Networking.Tests/NetworkingTests.cs` 141 -`[Test]`s; `packages/cultnet-rs` 111 `#[test]`s; `cultnet-rs` depends on -`serde`, `rmp-serde 1.3`, `rmpv`, `serde_json`, `cultcache-rs` and no -`schemars` (`packages/cultnet-rs/Cargo.toml:14-31`). - -## 1. Body facts, each by source read - -**The reference's read side today.** - -- `CultNetDatabase` (`src/GameCult.Networking/CultNetDatabase.cs`): change - kinds `:15-45`; `Watch` `:1052`, `WatchAllChanges` `:1063`, - `WatchRecord` `:1072`; `GetAll` `:776`; per-shard mutation log with - sequence (`:465-466`, `:528-590`, `:631` a snapshot carries - `ShardLogSequence`). `CultNetSchemaAliasMatching` `:47-97` is the one - schema-alias matcher, `internal static`. -- **Three separate selector engines evaluate the same two allowlists:** - `CultNetDocumentRegistry.CreateRawSnapshotResponse` `:263-349` (snapshot, - over `cache.AllEntries` by reflection at `:325-342`) with its own - `MatchesRequestedSchema` `:505-524`; `CultNetDatabaseServer.CreateChangeMessage` - `:347-384` with `Matches`/`MatchesSchema`/`InferSchemaName` `:401-468` - (the LiteNetLib path, the one production construction site, - `CultNetLocal.cs:154`); `CultNetDatabaseSubscriptionServer.CreateChangeCore` - `:442-485` with `MatchesRequestedSchema` `:493-500` (the RUDP path). Two - of them carry an identical reflection copy of `CreateRawRecord` - (`CultNetDatabaseServer.cs:386-399`, `CultNetDatabaseSubscriptionServer.cs:502-515`). -- **The two stand-ins.** `CultNetDatabaseSubscribeMessage` - (`CultNetSchemaMessages.cs:788-826`): `schemaIds` `:805`, `recordKeys` - `:809`, `includeSnapshot` `:813`, then `consumerRuntimeId`, `bodyIds`, - `supportedBodyTransports` (body-plane demand, not selection). The same - pair on `CultNetSnapshotRequestMessage` `:737-741`, - `CultNetShardCatalogRequestMessage` `:949-953` (shard routing, stays), and - `CultNetSchemaCatalogRequestMessage` `:1591` (catalog, stays). - `_projectRecord` on the subscription server (`:27`, `:44`, `:50`, - `:239-240`, `:314`): **no production caller constructs the subscription - server at all** — `grep "new CultNetDatabaseSubscriptionServer"` over - `src/` is empty; it is built only in tests (`NetworkingTests.cs:1596-1605` - passes `projectRecord`). Projection is authority that exists in the - reference and reaches no wire and no caller. -- **The cache already owns addressing.** `CultIndexAttribute` - (`src/GameCult.Caching/CultDocumentContracts.cs:34`, `Alias` `:41`) names - a member as an index; the cache's index values are **strings by - construction** (`CultCache.cs:1084` `Getter = document => getValue(document)?.ToString()`; - `GetByIndex(string alias, string value)` `:1503-1509`). - `CultReferenceAttribute` (`:45`, `TargetType` `:53`, `Many` `:55`) names a - member as a reference; the descriptor records `IsReference`, `IsMany`, - `TargetSchemaName` (`CultCache.cs:1069-1080`). So a field predicate's key - is an index alias and a hop's role is a reference member, both declared - by the document's owner. -- **The declarations are public; the values are not.** `ToCatalogEntry()` - (`CultCache.cs:151-176`) is public and carries every member's `Slot`, - `MemberName`, `TypeName`, `IsReference`, `IsMany`, `TargetSchemaName`, - `IsName`, `IndexAlias`. But `CultDocumentDescriptor.Members` (`:149`) and - `IndexAccessors` (`:148`) are **`internal`**, and `GameCult.Caching` - declares no `InternalsVisibleTo` for `GameCult.Networking` (the only - `InternalsVisibleTo` in `src/` outside the vendored Unity tree is - `GameCult.Caching.MessagePack` → `GameCult.Caching.Tests`). That is why - `CreateRawSnapshotResponse` reaches for reflection at - `CultNetDocumentRegistry.cs:325-342`. **An evaluator outside the cache - assembly cannot read a declared index's value today**, by any means the - cache offers. The earlier claim in this map that no cache change is - needed for addressing was wrong: addressing is declared publicly and - *readable* only inside the cache. Section 6 carries the read surface as - an add; sections 7 and 14 carry its cost. -- **Schemas are hand-written JSON** in `contracts/cultnet/*.schema.json`, - listed by file name in `CultNetSchemaRegistry.cs:360-385`; TypeScript - compiles them with Ajv and refuses unknown fields - (`cultnet.database-subscribe.schema.json` has `additionalProperties: false`); - Python lists required fields per version by hand - (`packages/cultnet-py/src/cultnet_py/schema_catalog.py:283`, `:407`); Rust - types are a serde enum tagged on `schemaVersion` - (`packages/cultnet-rs/src/contracts.rs:252`) with hand validation - (`require_optional_string_vec`, `:548-594`). C# encodes with - MessagePack-CSharp string keys (`[Key("name")]`), i.e. named maps; Rust - encodes with `rmp_serde::to_vec_named`. -- **Runtime coverage of the subscribe message today.** C# server ×2, C# - client (`CultNetDatabaseSubscriptionClient.cs:138-151`); TypeScript - contract only (`packages/cultnet-ts/src/contracts.ts:237-247`, no server - fanout, interop tests send it at `test/interop/cultnet-interop.test.ts:719,798`); - Python server ×2 (`cultnet_py/interop_peer.py:390-401` with - `DatabaseSubscription.matches` `:110-125`, and - `cultmesh_py/server.py:315-331` with `_subscription_matches_document` - `:449-470`, `_schema_matches_request` `:699-716`, and a third copy in - `cultmesh_py/node.py:1322-1345`); **Rust: none** — `cultnet-rs` has - `SnapshotRequest` with the two allowlists (`contracts.rs:314-321`) and no - `DatabaseSubscribe` variant; Kotlin: none (a snapshot-request builder, - `CultMesh.kt:2111`, and a `require(schemaVersion == "…snapshot_request.v0")` - at `:2195`). -- **How each runtime treats a message it does not know**, which is the - wire-parity fact section 9 rests on: C# throws - (`CultNetSchemaMessageSerialization.cs:85` `_ => throw`); TypeScript - `parseCultNetMessage` (`contracts.ts:728-744`) looks the version up in its - Ajv validators and throws when absent; Kotlin `require`s the exact version - (`CultMesh.kt:2195-2196`); Rust's tagged enum fails to deserialize on an - unknown tag; **Python returns `[]`** (`interop_peer.py:360-387` falls off - the chain; `cultmesh_py/server.py:341` delegates to `handle_message`) — a - silent drop, no reply, and for a *known* version with unknown fields - Python reads only the fields it expects (`message.get(...)`), so it would - answer a selector it did not understand with the wrong rows. -- **Every committed write has a shard-log sequence** — assumed from - `CultNetDatabase.cs:465` (`_nextLogSequences`) and the invariant "raw - snapshot/put/delete messages must pass through `CultNetDatabase`" - (`cultnet-distributed-database.md:115-116`); **Hands confirms** that a - local `PutAsync` outside any shard also takes a sequence, because the - order in section 3 rests on it. If it does not, the row's ordinal is its - `storedAt` and the cursor refuses on any advance (section 3 says what - that costs). - -**The Aetheria catalog as a hostile example, verified at -`F:\Projects\Aetheria\Assets\Scripts\ServerShared`:** - -- **Inheritance.** `ItemData.cs:272` `abstract class ItemData` (`Name` - `:275`, `Mass` `:284`), `:313` `abstract class CraftedItemData : ItemData` - (which re-declares `Name` at `:327`, hiding the base's), and only the - leaves carry `[CultDocument]`: `SimpleCommodityData` `:300`, - `CompoundCommodityData` `:330`, `GearData` `:449`, and more. The cache's - `DiscoverMembers` (`CultCache.cs:838-875`) walks `current.BaseType`, so a - leaf's descriptor carries every inherited member with its attributes - (`GetCustomAttribute` reads the member's own attribute wherever it is - declared). Inherited addressing therefore already resolves per leaf. - **Corrected on a second read:** duplicate *slots* are refused - (`:931-935`), and a **hiding member is already refused too** — `:937-943` - groups keyed members by `Member.Name` and rejects any name carried at two - different slots (`HiddenMemberMessage`), while a hiding member re-using - one slot is caught by the duplicate-slot rule. So `CraftedItemData`'s - `Name` at `ItemData.cs:327` hiding `:275` is **not registrable in - CultCache as it stands**, however the aliases fall; that is a finding for - the Aetheria campaign, not a hole here. What is *not* refused by name is - two members with **different names** carrying the **same index alias** - (base `[CultIndex("mass")] Mass`, leaf `[CultIndex("mass")] Weight`). - That does not collide silently either: the alias map is built by - `ToDictionary` at `:462-468`, which throws `ArgumentException("An item - with the same key has already been added")` — a real refusal, from the - wrong owner, naming neither schema nor member nor alias. D10 is therefore - a **renaming of an existing refusal**, not a new rule, and is smaller - than it first looked. -- **A reference to an abstract target.** `FactionProduct.cs:24` - `CultRecordRef Design`. `PersistedMember.FromMember` - (`CultCache.cs:1069-1071`) takes the target type and reads - `CultDocumentAttribute` from it — an abstract base has none, so - **`TargetSchemaName` is `null` today for exactly this reference**. The - registry can compute the leaf set by assignability (it already does for - index lookups, `:1506`, and store routing, `:1828`) but records nothing. -- **A dictionary reference with a value.** `ItemData.cs:333-334` - `[CultReference(typeof(PersonalityAttribute), many: true)] Dictionary, float> DemandProfile`. - The descriptor records `IsMany` (`:1080`) and nothing else: **no code in - the cache enumerates a many-reference's targets**, and the only accessor - is `Getter = document => getValue(document)?.ToString()` (`:1082`), which - on a dictionary yields the CLR type name. The edge and its payload are - declared and unreadable. -- **Numbers.** `PersistedMember.MemberType` (`:1053`) knows the member is a - `float`, and the catalog persists it as `TypeName` (`:38`, `:192`, - compared by `CompareSchemaShapes` `:605-629`), so **a member's numeric - type is already declared and persisted**; what is missing is a typed - accessor beside the string one. Adding an accessor is a runtime change - with no catalog-shape or hash change, because `TypeName` is already in - the canonical shape. - -**The cache's index maps are unique indexes, and the evaluator must not use -them.** `Index(stored)` (`CultCache.cs:1849-1862`) writes -`MapOf(_indexes, (type, alias))[value] = key` — **one key per value, last -writer wins**. Two rows of one type sharing an index value do not collide -loudly; the second silently displaces the first in the map. `GetByIndex` -(`:1502-1508`) reads that map and `Single` (`:1838-1848`) throws only -when *several types* assignable to `T` each contribute a key, never for two -rows of one type. So `GetByIndex` answers "the row that most recently -claimed this value", not "the rows with this value". - -The consequence for this cut is a rule, not a caveat: **the evaluator -evaluates every predicate per row, through the accessor, and never through -`_indexes` or `GetByIndex`.** The declared alias is an *addressing* name — -the cache's own lookup map is a different, lossier thing that happens to be -built from the same declaration. A "use the index, it is already there" -optimisation would turn `kind any_of [weapon]` into a one-row answer. S23 -pins it, `WatchByIndex` already has the bug (section 18), and the -unique-index behaviour itself is left exactly as it is: it is the cache's -own contract for a single-record lookup and this cut does not renegotiate -it. - -**A fourth selector engine, in Rust, that this map's first draft missed.** -`packages/cultnet-rs/src/snapshot_query.rs` (339 lines, `pub use` at -`lib.rs:29`) already serves and asks snapshot requests: - -- `serve_read_only_raw_snapshot` `:64-130` is an engine — it walks the - source's records, refuses a duplicate identity and an unregistered - schema, applies a `CultNetReadOnlySnapshotPolicy` allowlist of - `(schema_id, record_key)` pairs, then filters by the request's - `schema_ids` and `record_keys` (`:112-125`). The policy is - **authorization** and stays; `:112-125` is the fifth copy of the same two - allowlists and goes, as the C# three do. -- `CultNetRawSnapshotQuery` `:158-285` is the client side, and it exposes - the sharpest limit of the two-allowlist model: `request()` `:195-217` - turns a set of exact `(schema, key)` pairs into the **cross product** of - their schemas and their keys, and `accept_response` `:219-284` then - *errors* on any record the cross product dragged in - (`"snapshot response contains unexpected record"`). Asking for `(A,x)` - and `(B,y)` asks for four and refuses two. **v1 does not fix this**: - `schemas × keys` is still a cross product (section 13, Q-M). What v1 does - change is that `accept_response`'s check is a *declared expectation*, not - a re-filter of a page the server got right, and section 8's forbidden - writer is worded to keep that distinction honest. - -**The CultMesh audit** (Explore pass over `src/GameCult.Mesh` and -`CultNetDocumentRegistry.cs`, 92 sites classified) is in section 11 with its -numbers. - -## 2. The vocabulary, exactly - -One shape, `cultnet.selection.v1`, carried by two request messages at a new -version and answered by one page message. Field names are the wire -spelling; C# and Rust type names follow each runtime's convention. - -``` -Selection { - schemas: string[]? // kinds: schema ids or aliases, matched by CultNetSchemaAliasMatching; absent = every schema - keys: string[]? // record-key allowlist; absent = every key - fields: FieldPredicate[]? // conjunction; each is any-of over one declared index alias - cites: Citation? // rows whose declared reference `role` (or any reference) names `target` - cited: Incoming? // rows that some row does / does not name in `role` - projection: "header" | "document" // default "header" - descending: bool // default false; the one order, reversed - limit: uint32? // clamped 1..=200 - cursor: string? // opaque; minted by the answering server -} -FieldPredicate { // one operator per predicate, named by `op`; no union, no untagged - index: string // a declared index alias, reachable on some schema the selection can reach, else refused - op: "any_of" | "lt" | "le" | "ge" | "gt" - values: string[]? // present iff op = any_of; non-empty - number: string? // present iff op is a comparison; a canonical decimal (Q-J, below); the alias must be declared numeric on every reachable schema that declares it -} -Citation { target: RecordRef, role: string? } // target validated as a reference the row owner recognises -Incoming { role: string, exists: bool } -RecordRef { schemaId: string, recordKey: string } - -SelectionPage { // cultnet.snapshot_response_raw.v1 carries this - matched: uint32 - asOf: uint64 // the snapshot the page is exact for - next: string? // absent on the last page - headers: RawDocumentHeader[]? | documents: RawDocumentRecord[]? // exactly one present, by projection - edges: Edge[]? // present iff the selection has `cites` or `cited`: the edges the hop traversed - shardId?, shardEpoch?, shardLogSequence? // as v0 carries them -} -Edge { - from: RecordRef // the citing row - role: string - to: RecordRef // the cited row, its schema resolved to the leaf actually stored - payloadEncoding: "messagepack"?, payload: bytes? // the value attached to the edge (a dictionary's value), typed by the member's declared value type; present under `document`, absent under `header` -} -RawDocumentHeader = RawDocumentRecord minus payload, payloadEncoding -``` - -Messages: `cultnet.snapshot_request.v1 { messageId, selection, shardId?, shardEpoch? }`; -`cultnet.database_subscribe.v1 { messageId, subscriptionId, selection, includeSnapshot, consumerRuntimeId?, bodyIds?, supportedBodyTransports? }`; -`cultnet.snapshot_response_raw.v1` as above. `database_change_raw.v0` and -`database_unsubscribe.v0` are unchanged: a change is a change. - -**Rules, each one owner:** - -- **Order** is `(ordinal, schemaId, recordKey)` ascending, or the reverse - under `descending`. `ordinal` is the sequence of the commit that last - wrote the row (the shard-log sequence in the reference; the receipt - sequence in Huginn). The row owner supplies it; the vocabulary never reads - a clock. -- **Snapshot.** A page is exact as of `asOf`. A cursor carries `asOf`, the - last `(ordinal, schemaId, recordKey)`, and a digest of the selection with - `cursor` and `limit` cleared. A server that can present rows as of the - cursor's `asOf` answers the next page over that snapshot; **a server that - cannot refuses** `cultnet.error.v0 { code: "cursor_stale", details: { asOf, current } }`. - The reference refuses when the shard log has advanced (rows mutate, and a - replay is not this cut's); Huginn never refuses (append-only, one - writer). One contract, two honest servers. A cursor that does not decode, - or whose digest is not this selection's, is `cursor_invalid`. -- **Fields** are predicates over one declared index each, conjoined across - predicates: `any_of` over string values, or one of four comparisons - (`lt`, `le`, `ge`, `gt`) against one number over a declared numeric - member. A row of a schema that does not declare the index never matches - it. An `index` no reachable schema declares, an empty `values`, a - comparison on an alias any reachable schema declares non-numeric, an - empty `keys` or `schemas` list, and a `role` no schema declares are - refused typed at the door (`selection_invalid { field, value }`), never - answered as an empty page. `any_of` values are strings because the - cache's indexes are strings (`CultCache.cs:1084`). Comparison numbers are - **canonical decimal strings** under the operator's Q-J ruling. The rule is - specified in full in the **Numbers** item below. No range operator (two - predicates on one alias make a range), no `ne`, and no nesting. -- **Numbers (Q-J; Self's specification, 2026-09-22, which the ruling asked - for and this map had not yet written).** - - *Canonical form.* A number on the wire matches - `^-?(0|[1-9][0-9]*)(\.[0-9]*[1-9])?$`, and `-0` is excluded. That fixes - one spelling per value. It forbids leading zeros, trailing fractional - zeros, a bare trailing point, an explicit `+`, exponent notation, - negative zero, whitespace, and culture separators. - - *Non-canonical spellings are refused.* Any other spelling is refused at - the door with `selection_invalid { field: "number", value }`. It is never - normalised. The reasons: the cursor digest and the parity vectors need - one byte form per value, and a lenient parser differs between runtimes - at exactly these edges. The ruling says "a non-canonical spelling of an - equal value must not change an answer". That holds because such a - spelling never reaches the evaluator. It gets a typed refusal, not a - different page. - - *Row side.* The cache renders a numeric member as its exact canonical - decimal: - - An integer type renders as its exact decimal. There is no 2^53 limit. - - `decimal` renders with its trailing zeros stripped. - - `float` and `double` render in the runtime's established shortest - round-trip form (`"R"` in .NET, the standard shortest form in Rust), - rewritten from exponent notation to positional digits. Parity pins - this. - - A NaN or infinite member matches no comparison. - - *Comparison.* Both operands are canonical, so they are compared - numerically by sign, then by the integer part's length, then by the - integer digits, then by the fraction digits padded on the right. It is - one small pure function per runtime, with no numeric parse and no - precision limit. - - *Mutants that must die:* - - a lexicographic comparison ("10" < "9"); - - a comparison that ignores sign; - - a comparison that ignores the integer part's length; - - a door that accepts `+1`, `1.0`, `01`, `1e3` or `-0`; - - a row rendering through float64 (a `long` member of 2^53+1 must - compare greater than `"9007199254740992"`). - - Refusing a non-canonical number at the door, rather than normalising it, - was Self's reading of the ruling. **The operator accepted it on - 2026-09-22.** -- **Inheritance.** A schema is a leaf: only a type with `[CultDocument]` - has a schema name, and `schemas` names leaves. A predicate on an alias - applies to every reachable leaf whose descriptor carries a member with - that alias, inherited or own — the cache already discovers inherited - members per leaf, so "gear or commodities with `mass` over 10" is - `schemas: [geardata, simplecommoditydata], fields: [{index: mass, op: gt, number: 10}]` - with `mass` declared once on the abstract base. Two leaves that each - declare a member with the same alias independently are two members; the - predicate reads each leaf's own. One leaf that resolves the same alias to - two members (a base member and a hiding re-declaration both carrying the - alias) is refused at registration (D10). A numeric comparison on an alias - that is numeric on one reachable leaf and a string on another is refused - at the door, because the row owner cannot compare a string. -- **The hop** reads edges the row owner declares: in the reference, members - with `CultReferenceAttribute` (role = the member's index alias or name); - a one-reference yields one edge, a many-reference yields one edge per - element, and a dictionary keyed by references yields one edge per key - **with the value as the edge's payload**. In Rust, `Row::references()` - yields `(role, target, payload)`. **A reference's target is a set of - leaves**: the declared target type's own schema if it is a leaf, else - every registered leaf assignable to it (`CraftedItemData` → - `compoundcommoditydata`, `consumableitemdata`, …). The hop follows an - edge into any row whose schema is in that set. **A stored edge naming a - row whose schema is outside the set refuses the selection** - (`reference_outside_target { from, role, to }`), not skips it: an edge the - declaration forbids is corrupt data and a read does not paper over it. - The citer's status, fields and authorization are not consulted by the - hop; one hop, no second. -- **Edges in the answer.** A selection with `cites` or `cited` returns, beside - the rows, the edges the hop traversed, each with its payload under - `document` projection and without it under `header`. A weighted reference - and a bill of materials are the same shape: follow the edge, return the - payload, filter the rows. **Filtering on the payload as part of the - traversal is not expressible** (section 13): that is a join condition. -- **Projection.** `header` is the record without its payload; `document` is - the record. The consumer decides what a header *means* for typed rows - (Huginn's typed summary is its header; the substrate carries whichever - type the page was instantiated with). -- **Not on the wire:** the admission window (`admittedAfter/Before`) of - Huginn's Cut 9 — `descending` plus the cursor answer "the latest"; a date - window is a range, and ranges are out (R-3). - -**The bound, carried forward in force, with one widening the operator -ruled.** Closed key set (declared aliases), a closed operator set (any-of -and four comparisons, one per predicate, no nesting), no path language, no -expression terms, no OR, one negation, one hop with its edges returned, no -depth field, no sort field, no text, no predicate on an edge's payload in -the traversal. Section 13 lists what is deliberately impossible. The -capability set is now: **C1** typed predicates over declared members, -string any-of and numeric comparison; **C2** projection; **C3** order and -cursor; **C4** one hop, both directions, returning typed edge payloads; -**C5** existence and count without bodies. - -**Nothing on the wire is serde-untagged — rule, with evidence.** Probe -`scratchpad/untagged-probe/` (result in `untagged-probe-result.txt`), run -2026-09-17 against `rmp-serde 1.3.1` / `rmp 0.8.15` / `serde 1.0.229` (the -versions Huginn's lockfile resolves; `cultnet-rs` pins `rmp-serde 1.3`): -every `#[serde(untagged)]` enum with struct variants **fails to round-trip -under positional MessagePack** (`data did not match any variant of untagged -enum`) and passes only under named maps; externally tagged shapes pass under -both. The reference encodes named maps and so does Rust today, so an -untagged shape would work by accident of an undocumented encoding choice. -`grep untagged packages/cultnet-rs/src packages/cultcache-rs/src` is empty -at `51fb449`; this cut keeps it empty and pins it (section 10). - -## 3. Decisions, with the reasons - -**D1. Strings for field values, not typed enums.** In the Huginn-targeted -design a predicate was `Option>`, closed at compile -time. The substrate cannot know a consumer's enums, and the cache's own index -model is string-valued; so the wire carries strings and the row owner -refuses a value outside its enum at the door. The loss is compile-time -closure; what is kept is runtime closure with a typed refusal, which is the -same guarantee to a caller. - -**D2. Declared aliases, not a field-path language.** `index` and `role` are -names the document's owner declared with `CultIndexAttribute` and -`CultReferenceAttribute`; an undeclared name is refused. A dot-path over the -payload would be the string language the bound excludes, and the cache -already has the declaration mechanism. - -**D3. A new message version, not new fields on v0.** Section 1's fact: -Python reads only the fields it knows and would answer a v0 selector it -did not understand with the wrong rows. A v1 version string makes every -runtime not in this cut refuse or drop by its own dispatch rather than -mis-answer. The cost is that v0 stays answerable by the reference until the -follow-ups land (R-1, a scheduled deletion with a named trigger). - -**D4. One evaluator in the reference, three engines deleted.** `Select` -over `(descriptor, key, document)` rows from the cache replaces -`CreateRawSnapshotResponse`'s loop, `CultNetDatabaseServer.CreateChangeMessage`'s -`Matches`, and `CultNetDatabaseSubscriptionServer.CreateChangeCore`. -`CultNetSchemaAliasMatching` (`CultNetDatabase.cs:47-97`) becomes the one -alias matcher and goes `public`; the four Mesh copies and two Networking -copies go. - -**D5. Projection becomes a wire value; `_projectRecord` dies.** The -delegate ran after authorization and reached no caller. `projection` on the -selection is the same authority as a value; `_authorizeRequest` and -`_authorizeRecord` stay, because authorization is not selection. - -**D6. Subscriptions evaluate the selection on the snapshot and on every -change, and hop-bearing selections reconcile.** `cites`/`cited` are -set-dependent: a change to row B can change whether row A matches. The -subscription server already owns a diff-against-delivered reconcile -(`Reconcile` `:251-292`, `DeliveredBySourceRecordKey`); a hop-bearing -subscription runs it on every change instead of the per-change fast path. -That is the mechanism by which "watch a question" falls out, and this cut -does **not** add a local `CultNetDatabase.Watch(Selection)`; section 11 -records what that later cut would collapse; it is Cut 2, section 18 (R-5). - -**D7. The Rust runtime carries the evaluator, not only the types.** Huginn -evaluates selections over its own rows; if `select` lived only in C#, Rust -consumers would each write one. `packages/cultnet-rs/src/selection.rs` -holds the types, the cursor, and `select` over a `Row` trait, with no -subscription client in this cut (Huginn does not subscribe). - -**D8. Numbers are addressable through the type the cache already declares; -the cache gains accessors, not attributes.** A comparison needs a numeric -value the string getter cannot give. `CultCache.cs:1053` holds the CLR -`MemberType` and the catalog already persists `TypeName` in the canonical -shape, so numeric-ness is declared; what is added is runtime: on each -member, `ValueOf(document) -> object?` and `NumberOf(document) -> string?` (the exact canonical decimal, Q-J; was `double?` before 2026-09-22) -(non-null exactly for the closed set of CLR numeric types), and the public -member entry exposes `IsNumeric` derived from `TypeName`. No new attribute, -no catalog-shape change, no schema hash moves, no migration. Rust mirrors -it as `Row::number(index)` and `RowSet::is_numeric(schema, index)`; the -consumer decides from its own types. - -**Verified by source read, because everything downstream rests on it:** -`CultDocumentMemberDescriptor.TypeName` is set at `CultCache.cs:474` from -`CultSchemaTypeNames.FromType(member.MemberType)`, which renders a CLR full -name (`System.Single`, `System.Nullable`, -`System.Collections.Generic.Dictionary, -System.Single>`); `ToCatalogEntry()` `:168` copies it into -`CultSchemaMemberCatalogEntry.TypeName` `:42`; `CompareSchemaShapes` -compares it inside `CanonicalSchemaMember` `:605-629`. Numeric-ness is -declared and persisted today, and the claim holds. - -**Two corrections to the estimate.** First, `IsNumeric` has two possible -authorities — the CLR `MemberType` in hand and the `TypeName` string read -back from a stored catalog. They must agree, or a schema validates one way -locally and another way against a persisted catalog. **The CLR set is the -authority** (a closed set: the eight integer types, `float`, `double`, -`decimal`, and `Nullable` over any of them); the string set is generated -from it by `CultSchemaTypeNames.FromType`, never hand-written. S22 pins -that. - -Second, and larger: the accessor is not the only thing missing. Per section -1, `IndexAccessors` and `Members` are `internal` and `GameCult.Networking` -is not a friend assembly, so the evaluator cannot read *any* declared -value — string or number — without the reflection the map is deleting. The -cache add is therefore a **public read surface over declared members**, of -which the numeric accessor is one method: -`TryGetIndexValue(object document, string alias, out string? value)`, -`TryGetIndexNumber(object document, string alias, out string canonicalDecimal)` -(**revised 2026-09-22 under Q-J**: `NumberOf` returns the member's exact -canonical decimal string, never `double`; see §2 "Numbers"; commit 0 shipped -`double` and is corrected in the Q-J fix), `ReferencesOf` (D11), and a public member view carrying `IndexAlias`, -`IsReference`, `IsMany`, `IsNumeric` and the target **`Type`** (D9 needs -the type, not the name). Section 14 carries the revised cost. - -**D9. A reference's target set is resolved by the registry at evaluation, -not persisted.** Persisting `TargetSchemaNames` would change the canonical -member shape and every stored catalog's hash for such schemas. Resolving at -evaluation by assignability over registered leaves (`:1506`, `:1828` do -this today) costs nothing and is correct as of the registry in hand. The -catalog's `TargetSchemaName` stays what it is (`null` for an abstract -target) and is not read by the hop. - -The resolution needs a **`Type`**, and `CultDocumentMemberDescriptor` -carries only `TargetSchemaName`, a string that is `null` in exactly the -case that matters. So the public member view exposes the target `Type` -(held already on `PersistedMember.MemberType` / the attribute's -`TargetType`, `CultCache.cs:1069-1070`), and the leaf set is -`AllDescriptors` (public, `:254-255`) filtered by -`target.IsAssignableFrom(d.DocumentType)` — the same predicate -`GetByIndex` uses at `:1506` and store routing at `:1828`. It must be -computed **against the registry at evaluation, not at descriptor build**: -`BuildDescriptor` runs per type as it is registered, and a leaf registered -later would be missing from a set frozen early. A cached set keyed by -target type is legitimate only if it is invalidated by `Refresh()` -(`:257-265`) and by `RegisterDescriptor` (`:381-410`); simplest is not to -cache it. - -**D10. The duplicate-alias refusal is renamed, not invented.** The Aetheria -hiding case turned out to be refused already (section 1: `HiddenMemberMessage` -at `CultCache.cs:937-943`), and two differently-named members sharing one -alias already throw — from `ToDictionary` at `:462-468`, as an -`ArgumentException` that names neither the schema, nor the members, nor the -alias. D10 is to replace that with a rejection in `DiscoverMembers`' -`rejections` list, in the shape of its neighbours: one grouping over -`IndexAlias` beside the two at `:931-943`, one message beside -`DuplicateSlotMessage` / `HiddenMemberMessage`. The behaviour barely -changes; what changes is that the refusal can be read. Nothing in the -selection depends on it — a colliding catalog never registers either way — -so it is in this cut only because the cut is already in this file and the -message is four lines. - -**D11. Many-references are enumerated by the cache, with payloads.** On each -reference member, `ReferencesOf(document) -> IEnumerable<(CultRecordKey target, object? payload)>`: -a `CultRecordRef` yields one; an `IEnumerable>` yields -each with no payload; an `IDictionary, V>` yields each key -with its value. Anything else declared `many` is refused at registration -(`unsupported_reference_shape`), so a declaration the cache cannot walk is -never silently walked as nothing. - -The enumeration reads `ICultRecordRef.Key` (`CultDocumentContracts.cs:92-95`), -which every `CultRecordRef` implements (`:97-99`), so it needs no -generic dispatch. Two shape rules fall out of `ResolveReferenceTarget` -(`CultCache.cs:1100-1113`) and belong in the same refusal: a member -declared `many` whose element type is not a `CultRecordRef<>` and whose -attribute names no `TargetType` has **no resolvable target at all** -(`IsReference` is true only because the attribute exists, and -`TargetSchemaName` is `null` for a reason that is not inheritance); and a -`many` member that is neither `IEnumerable>` nor -`IDictionary, V>` cannot be walked. Both are -`unsupported_reference_shape` at registration. A `many: false` member whose -type is not `CultRecordRef` is the same fault and takes the same -refusal. - -**Agreement with our own abandoned prior art** (`ThreadEpiphanyGraphQuery`, -Epiphany `5c62a650`, deleted with its host `5f6f2441`): direction and edge -kind as data, schema derived — agreed; differs as before (predicate not -subgraph read; roles are declared names not free strings; one negation -added; no depth field). - -**Rejected, unchanged in reason:** Qdrant's `Filter` (open dot-path keys, -polymorphic values, OR/threshold/recursion advertised then refused, the -untagged hazard; Cut 11 lowers `FieldPredicate` to `must`/`match.any` in ~30 -lines on the daemon side); ReQL term trees; Firestore `CompositeFilter`; -Mongo/ES magic-key documents; every string-parsed evaluator surveyed. - -## 4. Deletes first - -| Path:lines (at `51fb449`) | Lines | What | -|---|---:|---| -| `src/GameCult.Networking/CultNetDatabaseServer.cs:347-468` | 122 | `CreateChangeMessage`, `CreateRawDocumentRecord`, `Matches`, `MatchesSchema`, `InferSchemaName` — the LiteNetLib selector engine; the handler calls the shared evaluator and the shared raw-record projection | -| `src/GameCult.Networking/CultNetDatabaseSubscriptionServer.cs:424-515` | 92 | `CreateAuthorizedChange`, `CreateChange`, `CreateChangeCore`, `ResolveWireSchemaId`, `MatchesRequestedSchema`, `CreateRawRecord` — the RUDP selector engine | -| `CultNetDatabaseSubscriptionServer.cs:27, :44, :50, :239-240, :314` | 6 | `_projectRecord`, its parameter and its two call sites | -| `CultNetDatabaseSubscriptionServer.cs:294-322` | 29 | `CreateProjectedSnapshot` body: becomes evaluate + authorize + project (~12 lines stay) | -| `src/GameCult.Networking/CultNetDocumentRegistry.cs:263-349` | 87 | `CreateRawSnapshotResponse`: the loop and its reflection over `cache.AllEntries` (`:325-342`); the raw-record construction (`:297-311`) survives as `ToRawRecord` | -| `CultNetDocumentRegistry.cs:505-524` | 20 | `MatchesRequestedSchema`, a copy of `CultNetSchemaAliasMatching.Matches(candidate, descriptor)` | -| `CultNetDocumentRegistry.cs:247-258` | 12 | `CreateSnapshotRequest` (v0 builder); v1 takes a `Selection` | -| **Networking total** | **368** | | -| `src/GameCult.Mesh/CultMeshSnapshots.cs:638-661, 750-773, 889-911` | 71 | three verbatim clones of the selector-carrying options; one `with` copy over a record type remains | -| `src/GameCult.Mesh/CultMesh.cs:2721-2748, 1941-1969` | 57 | the fourth and fifth copies (`ToSnapshotRequestOptions`, `WithPublicationBindingOptions`) | -| `CultMeshSnapshots.cs:973-983` | 11 | `CleanSnapshotFilter`: normalisation is the selection's own validation | -| `CultMeshSnapshots.cs:1000-1009, 1033-1047, 1078-1088` | 36 | the client-side re-filter of a snapshot by schema and `InferSchemaName`; the server's v1 answer is exact, decode stays | -| `CultMesh.cs:2750-2800` | 51 | `ReadDocumentFromSnapshotResponse`'s four-tier fallback (which returns a record with the wrong key when only the schema matches) and `TryDecodeSnapshotDocument`; replaced by one exact read (~10 stay) | -| `CultMesh.cs:3474-3497` | 24 | `IsSameCultDocumentSchema`: `CultNetSchemaAliasMatching`, now public | -| `CultMeshSnapshots.cs:625-636` and the rule at `:198`, `CultMesh.cs:2716` | ~15 | the "no schema filter when keys are given" rule, three times; one place | -| `CultMeshClient.cs:574-604, 830-860, 932-962` selector construction | ~25 net | `{recordKeys, schemaIds}` literals become `Selection` literals; the retry loops stay | -| `CultMeshBodyDemand.cs:177-221` | ~15 net | `CultMeshHotBodySubscription` builds two allowlists; builds one `Selection` | -| `CultMesh.cs:2701-2719, 2838-2858, 2875-2915` | ~20 net | selector construction for peer snapshots and body subscriptions | -| `CultMeshSnapshots.cs:139-201, 434-516, 611-623` overlay logic | ~40 net | overlaying caller `schemaIds`/`recordKeys` onto defaults, four times | -| **Mesh total** | **≈ 365 gross, ≈ 331 net** | see section 11 for what does not go | -| `packages/cultnet-rs/src/snapshot_query.rs:100-130` | ~31 | the fifth selector engine: the `requested_schemas` / `requested_keys` sets and the two `is_some_and` filters inside `serve_read_only_raw_snapshot` become one `select` over a lowered v0 selection. The duplicate-identity and unregistered-schema refusals (`:90-110`) and the whole `CultNetReadOnlySnapshotPolicy` (`:132-157`, authorization) stay | -| `src/GameCult.Caching/CultCache.cs` | **0** | the cache deletes nothing. The string `Getter`/`GetterNullable` pair (`:1081-1082`) stays: it is what `any_of` compares and what the index maps are built from (`:1858`). The numeric accessor is beside it, not instead of it | -| `tests/GameCult.Networking.Tests/NetworkingTests.cs`: `CultNetDatabaseServer_Creates_Filtered_SnapshotResponse` `:3124`, `…_ForCompatibleSchemaAlias` `:3158`, `CultNetDatabaseServer_Creates_Filtered_SubscriptionChange` `:5547`, `…_ForSchemaAlias` `:5601`, `DatabaseSubscription_FiltersLiveChangesByWireSchemaBinding` `:2256`, `…ByRequestedSchemaAlias` `:2310`, and the `projectRecord` lambda in `…AuthorizesRequestAndFiltersSnapshotAndLiveRecords` `:1601-1605` | ~250 | rewritten over v1 selections against the one evaluator (section 10); the rules they pin survive | - -**Not deleted in this cut, by ruling (R-1), and scheduled for deletion on FU-v0's trigger:** the v0 message classes and -their three schema files, the v0 arms in `CultNetSchemaMessageSerialization`, -and the v0 handling in the two servers — kept as a **lowering**: a v0 -request lowers to `Selection { schemas: schemaIds, keys: recordKeys, projection: document }` -and is answered through the same evaluator, so v0 has no engine of its own. -They die with the last runtime follow-up. - -## 5. Keeps and moves - -- `CultNetSchemaAliasMatching` (`CultNetDatabase.cs:47-97`), `internal` → - `public`, the one alias matcher for every runtime-side match. -- `_authorizeRequest`, `_authorizeRecord`, `Reconcile`, `Watch`, - `ApplyProjectedChange`, `PublishDemand`, `DemandChanged` and the body-plane - fields of the subscribe message: authorization, reconciliation and demand - are not selection. -- `CultNetDocumentRegistry`'s raw-record construction (`:297-311`) as - `ToRawRecord(descriptor, binding, key, document, options)`; the payload - schema resolution (`:452-503`) untouched. -- The v0 messages, schemas and arms as a lowering (above). -- `CultMeshSnapshotRequestOptions` as a record `{ Selection, ShardId, ShardEpoch, …transport knobs }`. -- Every (B)-class site of the audit (section 11): transport racing, - authority, freshness, body routing, provider-session validation. -- The interop lanes and CI witness (`.github/workflows/cultnet-interop.yml`) - green throughout, because v0 still answers. - -## 6. Adds - -| Add | Owner | Live consumer | Protected invariant | What it replaces | -|---|---|---|---|---| -| `src/GameCult.Caching/CultCache.cs`: a **public read surface over declared members** — `CultDocumentDescriptor.DeclaredMembers` (a public view: `MemberName`, `Slot`, `IndexAlias`, `IsName`, `IsReference`, `IsMany`, `IsNumeric`, `TargetType`), `TryGetIndexValue(document, alias, out string?)`, `TryGetIndexNumber(document, alias, out string canonicalDecimal)` (Q-J, revised 2026-09-22), `ReferencesOf(document, member)` (D11), `ResolveTargetLeaves(targetType)` over `AllDescriptors` (D9) | `GameCult.Caching` | the evaluator; `CultNetDocumentRegistry`; later any runtime-side reader | **the cache owns addressing and its values**; a reader outside the assembly reads declarations and values through one surface instead of reflecting over documents | the reflection loop at `CultNetDocumentRegistry.cs:325-342`, and the absence that forced it | -| `CultCache.cs` registration refusals: one alias-collision rejection beside `:931-943` (D10), one `unsupported_reference_shape` rejection for a `many`/reference member the cache cannot walk (D11) | `GameCult.Caching` | every registering catalog | a declaration the cache cannot read is refused when it is declared, not answered as nothing when it is read | an `ArgumentException` from `ToDictionary` `:462-468` that names nothing; a silent unwalkable reference | -| `contracts/cultnet/cultnet.selection.schema.json` (`$id`, referenced by `$ref`), `cultnet.snapshot-request.v1.schema.json`, `cultnet.database-subscribe.v1.schema.json`, `cultnet.snapshot-response-raw.v1.schema.json`; registry entries in `CultNetSchemaRegistry.cs` | CultLib contracts | C#, Rust; TS/Py/Kotlin follow-ups | one published shape of a selection, hand-written like its siblings, pinned by vectors in both runtimes | `schemaIds`/`recordKeys`/`includeSnapshot` as the wire's only selection | -| `src/GameCult.Networking/CultNetSelection.cs`: `CultNetSelection`, `CultNetFieldPredicate`, `CultNetCitation`, `CultNetIncoming`, `CultNetSelectionProjection`, `CultNetRecordRef`, `CultNetRawDocumentHeader`, `CultNetSelectionPage`, **`CultNetEdge`** (`From`, `Role`, `To`, `PayloadEncoding?`, `Payload?`), **`CultNetSelectionOperator`** (`AnyOf`, `Lt`, `Le`, `Ge`, `Gt`, serialised as the `op` string, never as a union); `Validate(IReadOnlyList)` — declared aliases and roles, non-empty lists, exactly one of `values`/`number` per `op`, and every reachable leaf declaring a compared alias declares it numeric | `GameCult.Networking` | the three message classes, the evaluator, Mesh | a selection is typed data with one validation | `_projectRecord`, the allowlist pair | -| `src/GameCult.Networking/CultNetSelectionEvaluator.cs`: `Select(cache, descriptors, selection, ordinals, asOf)` → ordered, hopped, cursored, projected page; `Matches(selection, descriptor, key, document)` for a single change; the cursor mint/parse with `cursor_stale` / `cursor_invalid` | `GameCult.Networking` | `CultNetDocumentRegistry` (snapshot), both servers (changes), `Reconcile` | one evaluator; order, snapshot and hop have one owner | the three engines (section 4) | -| `CultNetDatabase.LastWriteSequence(schemaId, key)` (a per-key ordinal kept on apply, ~20 lines) | `CultNetDatabase` | the evaluator's order and cursor | a row's ordinal is its last commit's sequence | `storedAt` as the only time | -| v1 message classes beside the v0 ones; the v0→`Selection` lowering (one function) | `GameCult.Networking` | both servers | v0 has no engine of its own | — | -| `packages/cultnet-rs/src/selection.rs`: the types (`Serialize`, `Deserialize`, no `untagged`; `SelectionOperator` an **externally tagged / string** enum, `Edge { from, role, to, payload_encoding, payload }`), `Row` trait (`id`, `ordinal`, `values(index) -> &[String]`, **`number(index) -> Option`**, **`references() -> Vec<(role, RecordRef, Option>)>`**), `RowSet` trait (`declared_indexes`, `declared_roles`, **`is_numeric(schema, index)`**, **`target_leaves(role)`**), `Malformed`, `select`, cursor mint/parse, `LIMIT_MAX` | `cultnet-rs` | Huginn (section 12), later Rust services | the same evaluator semantics as the reference, pinned by vectors both ways | Huginn's own `select.rs` from the earlier design | -| `snapshot_query.rs`: `serve_read_only_raw_snapshot` calls `select` over a lowered v0 selection; the policy check stays where it is | `cultnet-rs` | its existing callers and tests | the fifth engine has no rule of its own | the filter at `:112-125` | -| `contracts.rs`: `SnapshotRequestV1`, `DatabaseSubscribeV1`, `SnapshotResponseRawV1` variants | `cultnet-rs` | Huginn's daemon | the wire spelling equals the reference's | — | -| `contracts/cultnet/selection-vectors.cs-written.json` and `selection-vectors.rs-written.json`: a fixture row set (`cultnet.interop-selection-row` document type; declared indexes `kind`, `severity`, `tags[]` and **`mass` (numeric, declared on the abstract middle type, not on the leaves)**; references `parent`, `related[]` and **`components` (a dictionary keyed by reference with a float payload)** and **`design` (declared target = the abstract middle, resolving to two leaves)**; **two leaf schemas under one abstract middle**, so inheritance, the abstract target, the dictionary edge and the comparison are all exercised by the fixture rather than argued about in prose), **twenty-eight** selections, and each selection's expected page as ordered ids + `matched` + `next` presence + **the expected `edges` with their payload bytes**. The fixture must also carry, because tests depend on it and a loosening that cannot fail is the fixture's defect: a row whose `mass` **equals** a compared number exactly (S16), **three** rows sharing one index value (S23), one edge pointing outside its declared target (S18), two dictionary entries with **different** payload bytes (S19), and a nullable numeric member and a `decimal` one (S22). **Expected to grow** (R-4): it is chosen for coverage now, not pinned as final, and adding rows or selections to it is a normal change | tests, both runtimes | `NetworkingTests`, `cultnet-rs/tests/selection.rs` | **vectors written by the reference decode and evaluate identically in Rust, and vectors written by Rust decode and evaluate identically in the reference** | a within-runtime round trip, which pins nothing about parity | -| `contracts/cultnet/interop/cultnet.interop-selection-row.schema.json` | contracts | the vectors | — | — | -| `docs/cultnet-selection-cut.md` (this file), a paragraph in `contracts/cultnet/cultnet-distributed-database.md` under "Implemented", and the runtime table row in `docs/runtime-parity-scope.md` | docs | — | describe the live system | — | - -No dependency in either runtime (`schemars` is **not** added to -`cultnet-rs`: the schema is hand-written JSON like every CultNet schema, and -Huginn's derived schema for its own request embeds `Selection` through a -`#[schemars(schema_with)]` field attribute in Huginn. The attribute returns a -`$ref` to this cut's published selection schema `$id`. It does not go through -the substrate. (Corrected 2026-09-22: a hand-written `impl JsonSchema` for a -foreign type fails to compile with `E0117`, the orphan rule. The read-side -Imagination probed it.) — -see section 12). No new package, binary, transport, or store format. -**`packages/cultcache-rs` is untouched**: the C# cache change buys the -evaluator a read surface it does not have, and in Rust the row owner -already supplies exactly that through `Row`/`RowSet`. The asymmetry is -real and intended — the reference reads documents the cache owns, Rust -reads rows the consumer owns — and it is the reason the parity obligation -is on the *vectors* and not on the two implementations' shapes. - -## 7. Per-file changes (code that exists, anchored; new code by name and rule) - -**`src/GameCult.Networking/CultNetSchemaMessages.cs`**: after `:826`, the -three v1 classes; `CultNetSchemaVersions` (`:77`, `:93` and the -`SnapshotResponseRaw` constant) gains `SnapshotRequestV1`, -`DatabaseSubscribeV1`, `SnapshotResponseRawV1`. v0 classes untouched. - -**`CultNetSchemaMessageSerialization.cs:9-85`**: three arms before the -`_ => throw`. - -**`CultNetSchemaRegistry.cs:360-385`**: four `SchemaResourceSpec` entries. - -**`CultNetDatabase.cs`**: `:47` `internal static class` → `public static -class`; a `Dictionary<(string, string), long>` maintained where a mutation -is appended to the shard log (Hands anchors on the append site; section 1's -assumption is confirmed there) and `LastWriteSequence`; `:1052-1075` untouched. - -**`CultNetDocumentRegistry.cs`**: `:247-258` → `CreateSnapshotRequest(messageId, CultNetSelection)`; -`:263-349` → `CreateRawSnapshotResponse(cache, messageId, selection, ordinals, asOf, options)` -calling the evaluator and `ToRawRecord`; `:505-524` deleted. - -**`CultNetDatabaseServer.cs`**: `:276-316` handles v0 (lowered) and v1; -`:332-345` `CreateSubscription` calls `evaluator.Matches(selection, change)` -then `ToRawRecord`; `:347-468` deleted. - -**`CultNetDatabaseSubscriptionServer.cs`**: `:27, :44, :50` `_projectRecord` -deleted; `:112-167` handles v0 (lowered) and v1, and answers a -`snapshot_response_raw.v1` page with `matched`/`asOf`/`next`; `:218-249` -`Watch`: a selection with `cites`/`cited` runs `Reconcile` on every change, -otherwise `Matches` on the changed row; `:294-322` evaluate + authorize + -project; `:424-515` deleted. Module doc `:14-18` rewritten: projection is a -value on the request. - -**`src/GameCult.Caching/CultCache.cs`** (the only cache file this cut -touches): - -- `:112-150` `CultDocumentDescriptor`'s constructor and fields: `Members` - `:149` and `IndexAccessors` `:148` stay `internal`; a **public** - `DeclaredMembers` view and the three value accessors are added beside - them. Do not widen `Members` itself — `CultDocumentMemberDescriptor` is a - mutable internal DTO whose shape `ToCatalogEntry` `:151-176` depends on, - and publishing a mutable descriptor list makes the catalog's shape a - public contract by accident. The public view is a readonly struct or - sealed record built from it. -- `:445-490` `BuildDescriptor`: the alias `ToDictionary` at `:462-468` is - the site of the D10 refusal's *symptom*; the refusal itself belongs in - `DiscoverMembers` so it lands in `rejections` with its neighbours. -- `:838-946` `DiscoverMembers`: two new groupings beside the two at - `:931-943` — one over `IndexAlias` (D10), one over reference shape - (D11) — and two message helpers beside `DuplicateSlotMessage` / - `HiddenMemberMessage`. Nothing in the existing walk changes. -- `:1050-1114` `PersistedMember`: `Getter`/`GetterNullable` `:1081-1082` - untouched; `NumberOf` (non-null exactly for the closed CLR numeric set, - `Nullable` unwrapped) and `ReferencesOf` added beside them; - `MemberType` `:1052` and the attribute's `TargetType` surface through the - public view as the target `Type`. -- `:254-255` `AllDescriptors` is the input to `ResolveTargetLeaves`; the - set is computed per call, not cached, because `Refresh()` `:257-265` and - `RegisterDescriptor` `:381-410` can both add a leaf after any given - descriptor was built. -- `CultSchemaTypeNames.FromType` (`CultSchemaTypeNames.cs:9-31`) is - `internal` and generates the `TypeName` strings; the `IsNumeric` string - set is generated from the CLR set through it, never written by hand - (S22). - -**`packages/cultnet-rs/src/snapshot_query.rs`**: `:100-130` the two -allowlist sets and their filters become one `select` over the lowered -selection; `:64-99` and `:132-157` untouched; `:158-285` -`CultNetRawSnapshotQuery` untouched in this cut and named in Q-M. - -**`CultNetSelection.cs`**, **`CultNetSelectionEvaluator.cs`** (new): as -section 6. Rules that must die under their own mutation are in section 10. - -**`src/GameCult.Mesh/CultMeshSnapshots.cs`**: `:16-62` the options record -carries `Selection`; `:139-201`, `:434-516`, `:611-636` overlay through one -`WithSelection`; `:638-661`, `:750-773`, `:889-911` deleted; `:973-983`, -`:1000-1009`, `:1033-1047`, `:1078-1088` deleted. -**`CultMesh.cs`**: `:1941-1969`, `:2721-2748`, `:2750-2800` (one exact read -remains), `:3474-3497` deleted; `:2701-2719`, `:2838-2858`, `:2875-2915` -build a `Selection`. -**`CultMeshClient.cs:574-604, 830-860, 932-962`**, **`CultMeshBodyDemand.cs:177-221`**: -`Selection` literals. - -**`packages/cultnet-rs/src/selection.rs`** (new), **`contracts.rs:314-331`** -region gains the three v1 variants, **`lib.rs`** re-exports. **`tests/selection.rs`** -(new): the vectors both directions, the evaluator, the cursor, the -refusals, the untagged grep. - -**`tests/GameCult.Networking.Tests/NetworkingTests.cs`**: the seven tests in -section 4 rewritten; new tests in section 10; the vector writer under -`CULTNET_WRITE_VECTORS=1` following `scripts/write-cultmesh-realtime-frame-vectors.mjs` -and the C#-written pattern the QUIC campaign established (`docs/typescript-quic-realtime-cut.md:15-21`). - -## 8. Authority map - -- **Owner.** CultNet's database organ, `src/GameCult.Networking`, as the - reference: `CultNetSelection` owns the shape and its validation; - `CultNetSelectionEvaluator` owns matching, the hop, the order, the - snapshot and the cursor; `CultNetSchemaAliasMatching` owns schema - identity; `CultNetDatabase` owns a row's ordinal. **The cache owns - addressing and every value of it**: which names are indexes, which - members are references, whether a member is numeric, what leaves a - reference may target, what a row's value at an alias is, and what edges - and payloads a row carries — through `CultIndexAttribute` and - `CultReferenceAttribute`, the persisted `TypeName`, and the public read - surface of section 6. The vocabulary reads those declarations and adds - none: no new attribute, no persisted field, no schema-hash movement, and - no opinion in the evaluator about what a CLR type means. **The evaluator - never reflects over a document**; if it needs something the cache does - not expose, the cache gains a method, not the evaluator a `GetProperty`. `packages/cultnet-rs` - is the Rust spelling of the same owner, at wire parity, with the row - owner supplying what the cache supplies in C# (`Row`, `RowSet`). -- **Inputs.** The cache's rows and descriptors, the shard log's sequences, - the selection, the peer's authorization answers. Not inputs: a clock, - a payload path, a transport. -- **Outputs.** Pages (`headers` or `documents`, `matched`, `asOf`, `next`), - per-change match decisions, typed refusals (`selection_invalid`, - `cursor_stale`, `cursor_invalid`) as `cultnet.error.v0` with a code, the - form the reference already uses for routing errors. -- **Derived state.** The page, the order, the incoming-edge index per - evaluation, the cursor. **Demotions:** `schemaIds`/`recordKeys` are no - longer a selection language; they are a lowering of v0 into one. - `_projectRecord` is no longer an authority; projection is a request - value. `CreateRawSnapshotResponse`, `CreateChangeMessage` and - `CreateChangeCore` are no longer engines; they call one. - `IsSameCultDocumentSchema`, the Mesh `InferSchemaName` and the registry's - `MatchesRequestedSchema` are no longer owners of schema identity. -- **Forbidden writers.** Neither server may match a record by a rule of its - own; **`serve_read_only_raw_snapshot` may not filter by schema or key** - (its policy is authorization and stays; its allowlist filter goes); Mesh - may not re-filter a page the server answered — a caller *may* verify a - page against expectations it declared before the request - (`CultNetRawSnapshotQuery::accept_response`, which errors rather than - quietly dropping, and so cannot hide a server that answered wrongly), but - no caller may narrow a page and call the narrowed result the answer; - nothing may mint a - cursor a caller could construct; nothing may answer a page over a - different `asOf` than its cursor's; the evaluator may not read a payload - by path, only declared indexes and references, **and may not reflect over - a document at all**; **the evaluator may not read the cache's `_indexes` - map or call `GetByIndex`** — those answer a unique-index lookup, not a - predicate (section 1, S23); no rule may consult an edge's payload while - traversing (section 13); nothing outside `GameCult.Caching` may decide - whether a member is numeric or what leaves a target resolves to; no type - on the wire is `untagged`; the Rust `select` may not diverge from the - reference on any vector. -- **Shared paths.** The evaluator under snapshot, change, and reconcile; - `CultNetSchemaAliasMatching` under every schema match in both assemblies; - `ToRawRecord` under snapshot and change; the v0 lowering under both - servers. -- **Deletion line.** Commit 0: the cache's public read surface and its two - registration refusals, with S17-S22 green and `GameCult.Networking` - untouched — the cache change is independently true and lands first, so - that if the rest of the cut is cut, the substrate is not left with half a - surface. Commit 1: the shape, the evaluator and the v1 - messages beside v0, with the three engines rewired and deleted and the - seven tests rewritten — green. Commit 2: `_projectRecord` and the - Mesh collapse. Commit 3: Rust. Commit 4: vectors both ways and entries. - Nothing lands with two engines alive. -- **Where the line to CultMesh falls.** Mesh is a client that builds - selections and reads pages; it evaluates nothing. Where Mesh watches a - cache locally by name or index (audit sites #2, #4-9, #16-21), it keeps - its own loops until `CultNetDatabase.Watch(Selection)` exists, which is Cut 2 (section 18). - -## 9. Parity: what this cut covers, and what the other runtimes do - -**In this cut:** the C# reference (both servers, the client, the registry) -and Rust (`cultnet-rs`: types, evaluator, cursor; no subscription client, -because no Rust caller subscribes). Parity is pinned by vectors in both -directions (section 10), not by a round trip inside one runtime. - -**Runtimes not in this cut, stated answer per runtime, by source read:** - -| Runtime | On v0 (unchanged) | On a v1 request it receives | On a v1 page it receives | -|---|---|---|---| -| TypeScript | unaffected; the reference still answers v0 | **refuses**: `parseCultNetMessage` finds no validator for the version and throws (`contracts.ts:728-744`) | refuses the same way | -| Kotlin | unaffected (client only) | **refuses**: `require(schemaVersion == …v0)` throws (`CultMesh.kt:2195`) | n/a as a server; a Kotlin client sends v0 and gets v0 | -| Python | unaffected | **silently drops, no reply**: `handle_server_message` returns `[]` for an unknown version (`interop_peer.py:387`), so a caller times out rather than reading a refusal; **it cannot answer with wrong rows**, because v1 is a version it does not dispatch, which is why D3 chose a version over new fields | as above | -| Rust | in this cut | in this cut | in this cut | - -The one runtime that mis-answers today is none: nothing sends v1 to a -runtime that does not speak it until its follow-up lands, and a stray v1 is -refused (TS, Kotlin, C#) or dropped (Python). **Python's drop is fixed in -this cut, not in its follow-up** (R-2): after this cut the table's Python -row reads "refuses with `unsupported_schema_version`", and every runtime on -the wire answers an unknown version with something a caller can read. The -build budget gains one Python test run for it. - -**Follow-ups, recorded with triggers:** - -- **FU-TS.** `cultnet-ts`: the three v1 contracts, Ajv registration, a - `Selection` type; `cultmesh-ts` builders. Trigger: the first TypeScript - caller that needs a filtered snapshot or subscription (the browser Eve - runtime, when it reads pipeline state). Until then TS refuses v1 loudly. -- **FU-Py.** Its first line is **not** a follow-up: by R-2, `cultnet-py` - and `cultmesh-py` reply `cultnet.error.v0 - { code: "unsupported_schema_version" }` for an unknown version **in this - cut** (five lines at `interop_peer.py:360-387` and the delegating path at - `cultmesh_py/server.py:341`, with one test per site that a v1 message - produces a refusal and not an empty list). The rest of FU-Py is the v1 - contracts, and the **three** copies of the selector match - (`interop_peer.py:110-125`, `cultmesh_py/server.py:449-470`, - `cultmesh_py/node.py:1322-1345`) collapsed into one evaluator. Trigger: - the first Python peer asked a v1 question, or the interop lane gaining a - v1 case. -- **FU-Kt.** `cultmesh-kotlin`: v1 snapshot request builder and page - reader. Trigger: an Android/JVM client reading filtered state. -- **FU-v0.** Retire v0's classes, schemas and lowering once FU-TS, FU-Py, - FU-Kt have landed and the interop lanes send v1. Trigger: the last of the - three. -- **Not a follow-up any more:** `CultNetDatabase.Watch(Selection)` is - **Cut 2**, mapped in section 18 with its own deletes, authority map, - verification and numbers. It lands after this cut. The audit's ≈ 240 - local-watch lines are counted there, and the real figure turned out - larger than the audit's estimate (≈ −378 in Mesh, section 18.3), because - the audit did not count the nine `Collection*` overloads as selection. - -`docs/runtime-parity-scope.md`'s table gains, per runtime, "typed selection -v1: C# and Rust claimed; TS, Python, Kotlin not claimed (refuse / refuse / -drop)". The claim is written where the parity claims live, not here alone. - -## 10. Verification - -**Builds.** `dotnet build` of `GameCult.Caching`, `GameCult.Networking`, -`GameCult.Mesh` and their test projects — the cache is now in the build -budget, and it is the assembly the rest of CultLib depends on, so -`dotnet test tests/GameCult.Caching.Tests` is the gate on commit 0 and runs -on every later commit; `cargo test -p cultnet-rs`; the TypeScript workspace -untouched but `npm run test --workspace packages/cultnet-ts` run once to -prove the interop lane still passes on v0. Host = target = workstation for -C# and Rust; no native code. Nothing cleaned. - -**Tests, each named for the rule it pins, with the mutation that kills it — -a loosening where one exists.** - -| # | Test (C# unless marked) | Pins | Revert kills | Loosening kills | -|---|---|---|---|---| -| S1 | `Selection_RefusesUndeclaredIndexRoleAndEmptyLists` | D2, door refusals typed | validation dropped (empty page) | `index` checked against *any* schema's aliases rather than the reachable ones (a predicate on an alias only an excluded schema declares matches nothing silently) | -| S2 | `Evaluator_ConjoinsAnyOfPredicatesOverDeclaredIndexes` | fields | an arm dropped | any-of treated as all-of | -| S3 | `Evaluator_OrdersByLastWriteSequenceThenIdentityAndReverses` | order, `descending` | sort by `storedAt` | `descending` ignored | -| S4 | `Evaluator_PagesExactlyOnceAndTheLastPageSaysSo` | cursor walk | `next` always present | position `>=` (last item repeats) | -| S5 | `Evaluator_RefusesAStaleCursorAfterTheShardLogAdvances` | `cursor_stale` typed | advance ignored (a page over a moved set) | digest check dropped (a cursor accepted under another selection) | -| S6 | `Evaluator_HopsOneEdgeByDeclaredReferenceAndRole` | hop, roles from `CultReferenceAttribute`, `Many` | role ignored | a second hop followed | -| S7 | `Evaluator_NegatedIncomingEdgeIsTheOnlyNegation` | `cited { exists: false }` | `exists` ignored | citer's status consulted (an unauthorized citer's edge dropped) | -| S8 | `Evaluator_HeaderProjectionCarriesNoPayload` | projection | payload carried | `payloadEncoding` carried without payload | -| S9 | `Subscription_EvaluatesSelectionOnSnapshotAndEveryChange_AndReconcilesHopBearingOnes` (rewrite of `:1587`) | D6 | a change matched by v0 allowlists | a hop-bearing subscription taking the per-change fast path (a change to the citer not reconciled) | -| S10 | `V0Request_LowersToASelectionAndHasNoEngineOfItsOwn` (rewrites of `:3124`, `:3158`, `:5547`, `:5601`, `:2256`, `:2310`) | D3/D4 | v0 matched by its own loop | alias matching inlined again in one server | -| S11 | `SchemaAliasMatching_IsTheOneMatcherInBothAssemblies` (grep-shaped, negative) | D4 | — | — | -| S12 | `SelectionVectors_WrittenByTheReference_DecodeAndEvaluateIdenticallyInRust` (Rust reads `selection-vectors.cs-written.json`) and `SelectionVectors_WrittenByRust_DecodeAndEvaluateIdenticallyInTheReference` (C# reads `selection-vectors.rs-written.json`) | **parity** | any semantic drift on either side | a vector whose expected ids are compared as a set (order lost) — the vectors carry ordered ids and `next` presence | -| S13 (Rust) | `selection_is_never_untagged` (grep over `packages/cultnet-rs/src` for `untagged`, empty) and `selection_round_trips_named_and_positional` (both encodings) | the encoding rule | an `untagged` shape added | — | -| S14 (Rust) | `select_over_a_toy_row_set_matches_orders_hops_pages_and_refuses` | D7, no CultCache knowledge in the evaluator | as S1-S8 | as S1-S8 | -| S15 | `Mesh_ReadsASnapshotPageWithoutReFilteringIt` (Mesh tests) | the client trusts the page | the four-tier fallback restored | schema re-filter restored | -| S16 | `Evaluator_ComparesNumbersAtTheBoundaryForEachOfTheFourOperators` | D8's operators; one operator per predicate; two predicates make a range | the comparison ignored (every row matches) | `le` evaluated as `lt` (and `ge` as `gt`) — **kills only if the fixture carries a row whose `mass` equals the compared number exactly**; the fixture must, and if it does not, that is the fixture's defect, not licence to mutate something easier | -| S17 | `Evaluator_AppliesAnInheritedAliasToEveryReachableLeaf` | the inheritance rule; the cache's `BaseType` walk reaching the evaluator | the walk stopped at the leaf (`CultCache.cs:847`) — kills S17 and S12 together | "reachable" narrowed from *every* leaf matching `schemas` to the first descriptor consulted, so a two-leaf selection on an alias declared only on the abstract middle answers with one leaf's rows and no refusal — **requires the fixture to declare `mass` only on the middle and to carry rows of both leaves** | -| S18 | `Evaluator_ResolvesAnAbstractTargetToItsLeavesAndRefusesAnEdgeOutsideThem` | D9; the typed `reference_outside_target` | the target set taken as `{TargetSchemaName}`, which is `null` for an abstract target, so the hop follows nothing | the out-of-target edge **skipped** instead of refused — the option section 3 rejected, and the mutant that proves the rejection is load-bearing; **requires the fixture to carry one edge pointing at a schema outside the declared target** | -| S19 | `Cache_EnumeratesADictionaryReferenceAsEdgesCarryingItsValues` (cache tests) | D11 | `ReferencesOf` yields nothing for a dictionary — today's behaviour, restored | the keys enumerated and the **values dropped** (`payload` null), which is the shape a careless `IEnumerable` implementation would have; **requires two dictionary entries with different payload bytes**, or the assertion passes on shape alone | -| S20 | `Evaluator_ReturnsTraversedEdgesOnlyForHoppingSelections_AndNoPayloadUnderHeader` | the `edges` rule | `edges` never emitted | payload carried under `header`; and, separately, `edges` emitted for a selection with neither `cites` nor `cited` — a widening rather than a loosening, and killed by the same test | -| S21 | `Cache_RefusesADuplicateIndexAliasAndAnUnwalkableReferenceByName` (cache tests) | D10, D11's shape rule | the rejections removed — **kills only if the test asserts the message names the schema, the two members and the alias**, since without them `ToDictionary` still throws an `ArgumentException` and a shallow `Assert.Throws` passes either way. That is the entire content of D10 | the alias grouping keyed by `MemberName` instead of `IndexAlias`, which refuses nothing the existing `HiddenMemberMessage` (`:937-943`) did not already refuse | -| S23 | `Evaluator_MatchesEveryRowSharingAnIndexValue_NotTheCacheIndexWinner` | the evaluator reads values per row, never `_indexes` / `GetByIndex` | the predicate answered from `GetByIndex`, so an `any_of` over a value **three** fixture rows share answers with one | the per-row read kept but short-circuited after the first match when `matched` is all the caller asked for — a plausible optimisation that makes `matched` a boolean in disguise; **requires three rows sharing one index value**, which the fixture must carry | -| S22 | `Cache_DerivesIsNumericFromTheClrSetAndTheTypeNameSetAgrees` (cache tests) | D8's two authorities agreeing | `IsNumeric` true for every member, so a comparison on a string alias validates and compares `ToString()` lexically | the `TypeName`-string set hand-written and missing `System.Nullable` or `System.Decimal`, so a member is numeric against the live descriptor and non-numeric against the same schema read back from a persisted catalog — **requires the fixture to declare a nullable numeric member and a `decimal` one** | - -**On the parity vectors and the four findings.** S12 is not a new test but -a widened one: the fixture of section 6 carries the abstract middle, the -two leaves, the inherited numeric alias, the dictionary reference with -float payloads and the abstract-target reference, and the vector set -includes at least one selection per finding — a comparison on the -inherited alias, a hop into the abstract target, a hop over the dictionary -returning payloads, and the same hop under `header`. Both directions: -**vectors written by the reference are evaluated in Rust, and vectors -written by Rust are evaluated by the reference**. A round trip inside one -runtime pins nothing and is not counted. The Rust side's fixture rows -implement `Row` over the same declared values, so the vectors test the -*semantics* both ways while each runtime keeps its own source of rows. - -**Negative greps:** `rg -n "GetProperty|GetField|GetCustomAttribute" src/GameCult.Networking` -empty (the evaluator reflects over nothing); -`rg -n "untagged" packages/cultnet-rs/src packages/cultcache-rs/src` -empty; `rg -n "InferSchemaName" src/GameCult.Mesh` empty and -`src/GameCult.Networking` only in `CultNetSchemaAliasMatching` and the -registry's payload-schema resolution; `rg -n "MatchesRequestedSchema|MatchesSchema\(" src` -empty; `rg -n "_projectRecord|projectRecord" src` empty; -`rg -n "SchemaIds = .*RecordKeys = " src/GameCult.Mesh` empty (no -allowlist pair assembled by hand); `rg -n "CloneSnapshot(Facade)?RequestOptions" src` at most one. - -**Mutations.** `tools`-style entries in `scripts/mutate-cultmesh.mjs`'s -format with three new targets, `caching` (killer `dotnet test -tests/GameCult.Caching.Tests`, carrying S19, S21 and S22), `networking` -(killer `dotnet test tests/GameCult.Networking.Tests`) and `rust` (killer -`cargo test -p cultnet-rs`), -one entry per rule above with revert and loosening; the runner's -byte-rewrite/verified-restore discipline applies unchanged. The runner is -the QUIC campaign's file and is dirty in the tree; **this campaign adds its -entries in its own file** (`scripts/mutate-cultnet-selection.mjs` or an -entries module the runner imports) and does not edit the QUIC campaign's -targets — Self decides the exact split at landing. - -## 11. The CultMesh subtraction audit, with real numbers - -Method: an Explore pass classified 92 sites in `src/GameCult.Mesh` and -`CultNetDocumentRegistry.cs` as (A) mechanical selection/projection over -schema ids, keys or fields, or (B) a domain rule (authority, freshness, -transport, session). (A) totalled **1,158 lines**, (B) **429**. **(A) is not -a reduction figure**; it is what *could* be expressed as a selection. What -collapses is what has a replacement in this cut. - -| Category | Sites (audit #) | Lines now | After | Net | -|---|---|---:|---:|---:| -| Selector-carrying options cloned five times | #11, #3, #74, #75, #77 | 128 | ~30 (`with` on a record) | **−98** | -| "No schema filter when keys are given" rule, three times | #65, #73, #10 | ~16 | ~4 | −12 | -| `CleanSnapshotFilter` | #79 | 11 | 0 | −11 | -| Client-side re-filter of a snapshot by schema, plus `InferSchemaName` | #80 (part), #81, #82 | ~51 | ~10 (decode only) | −41 | -| Four-tier read fallback + decode gate | #12, #13 | 50 | ~10 | −40 | -| `IsSameCultDocumentSchema` | #22 | 24 | 0 (public matcher) | −24 | -| Selector literals in client bindings | #32, #34, #35 | 93 | ~68 | −25 | -| Hot-body subscription allowlists | #25 | 45 | ~30 | −15 | -| Peer snapshot / body subscribe selector construction | #10, #14, #15 | 81 | ~61 | −20 | -| Snapshot facade overlay logic | #64, #66-70, #72 | ~110 | ~70 | −40 | -| **Collapses in this cut** | | | | **≈ −326** | -| Local cache/database watches by name and index and their predicates | #2, #4-9, #16-21 | ≈ 240 | ≈ 240 | 0 in this cut; **≈ −378 in Cut 2** (section 18.3 — larger than this audit estimated, because the nine `Collection*` overloads at `CultMesh.cs:2278-2480` were not classified as selection and are) | -| Handle catalogs by type/schema, surface catalog, operation payload | #41-49 | 233 | 233 | 0 — these index *handles*, not records | -| Verse discovery selection and reshaping | #36, #38 (part), #39, #40, #83, #85 | ~110 | ~110 | 0 — over Verse observations, not documents | -| Single-file catalog membership | #58-62 | 81 | 81 | 0 — file-format membership | -| Provider session wire decode gate | #50 | 12 | 12 | 0 | -| (B) sites | 24 sites | 429 | 429 | 0 by definition | - -**Plain statement.** `src/GameCult.Mesh` shrinks by about **326 lines of -21,720 (1.5%)** in this cut, and a further **≈ 378 in Cut 2** — the two -together are about 3.2% of the assembly, and Cut 2 is where the audit's -expectation of a real reduction is met. About 590 of the -audit's (A) lines stay because they select handles, Verse observations or -file-catalog entries, not database records. The operator's expectation of a -net reduction in CultMesh holds, modestly; it does not hold for CultLib as a -whole in this cut, because the Rust runtime is new capability (section 14). -If the expectation was a large reduction, this audit says it is not there -without the watch cut, and it is not there at all for the catalogs and -discovery. - -## 12. Huginn: the consumer cut, and what moved - -**Moves to CultLib (this map):** `Selection`, `Citation`, `Incoming`, -`Projection`, `Page`, the cursor, `select`, the `Row`/`RowSet` traits, the -untagged rule and its probe, the cap, the order rule and the snapshot -contract. Huginn's earlier `select.rs` is never written. - -**Stays with the organ (a smaller, later cut in the Epiphany campaign map, -against a `cultnet-rs` dependency Huginn already has):** - -- `impl Row for PipelineDocumentView`: `ordinal = admission.sequence` - (Q-B A, still recommended; under Q-B B Huginn refuses `cursor_stale` on - advance exactly as the reference does, which is now a legitimate second - option), `values(index)` for the declared aliases `campaign`, `repo`, - `cut`, `kinds`→(schema), `in_force`, `faculty`, `severity`, `confidence`, - `origin`, `authority`, `claim_outcome`, `outcome`; `references()` from - `docs::citations` with the fifteen roles; `RowSet::declared_*` as the - organ's closed lists, so an unknown alias or a value outside an enum - refuses typed. -- `docs::citations`, `CitationRole`, `ResolutionOutcomeKind`, the summary - as the organ's header, the `as_of` restriction of the image to receipts, - the semantic refusal, the ref validation of `cites.target` through the - leaf, and the deletion of `open_items`/`history` with the relation table - unchanged (`history(Subject)` = `kinds: [resolution], cites { target, role: subject }`; - the open lists = five selections). -- **Deleted from the organ's wire (R-3, ruled, not proposed):** - `PipelineQuery`; **`admitted_after` and `admitted_before`**, which existed - only to approximate an order and are replaced by `descending` plus the - cursor — they are a delete in the Huginn cut's own deletes-first table, - with their query-builder call sites, their schema fields and the tests - that pin them, not a deprecation; and `QUERY_LIMIT_MAX`. Huginn's `Query { instance, selection }` carries - the substrate's type; its published request schema embeds `Selection` - through a `#[schemars(schema_with)]` attribute that returns a `$ref` to the - published selection schema. A hand-written impl fails with `E0117` - (corrected 2026-09-22), and the substrate publishes JSON, not `schemars`. It - is pinned by the - existing byte-for-byte test. -- Cut 11's lowering to Qdrant and the after-index application of the hop, - as before. - -The Huginn cut is ordered **after** this cut's commit 3 (Rust) and before -Cut 11 and Cut 13, as 10b was. - -## 13. Deliberately not possible, and why - -OR across predicates (ask twice); negation beyond `cited { exists: false }`; -a predicate on the far end of the hop; a second hop; ranges, dates, text, -paths, sort fields, counts beyond `matched`; a page not tied to `asOf`; -selection across shards or minds; a cursor the caller constructs. Each for -the reason the earlier specification gave, unchanged. - -Named individually, because each has an obvious-looking one-line -implementation and a caller who will ask for it: - -| Not expressible | The obvious ask | Why it is the door | -|---|---|---| -| **A predicate on an edge's payload during traversal** — "components whose quantity is over 4", "demand profile entries weighted above 0.5" | one `if` inside the hop loop, over a payload the evaluator is already holding | **It is a join condition.** The moment a predicate can read a value that belongs to neither the row nor the selection, the evaluator is combining two sources under a condition, and everything that follows is a query planner: which side to drive from, whether to build the incoming-edge index before or after filtering, how `matched` counts a row whose only surviving edge was filtered, what the cursor means when the page is a join result, and whether the payload's type is comparable at all when its declared type differs per leaf. None of that is answerable in a bounded vocabulary. **The caller follows the edge, receives the payload in `edges`, and filters the result** — one extra step for the caller, an entire category of machinery this organ never grows | -| **A set of exact `(schema, key)` pairs** | `keys` already exists; let an entry name its schema | `schemas` × `keys` is a cross product and stays one. `CultNetRawSnapshotQuery` (section 1) shows the cost honestly: it over-requests and verifies. The fix is either a second list shape or a pair type on the wire, and both are the beginning of a term language. A caller who needs exact pairs asks once per schema, or accepts the cross product and verifies against what it declared. Recorded as Q-M, recommendation A: state the limit | -| **A predicate that depends on how many edges a row has** — "hulls with more than three components" | `cited` already counts to one | `exists: true/false` is a boolean, and a threshold is a range over a derived aggregate. Aggregation is a second evaluator with its own ordering and paging semantics | -| **`edges` without rows, or rows the hop excluded** | a `projection: "edges"` | the page's rows are the answer and the edges explain it; an edge-only page is a different question (a graph read) and would need its own order, cursor and bound | - -## 14. Subtraction ledger (estimate) - -| | Removed | Added | -|---|---:|---:| -| `src/GameCult.Caching` | 0 | **~150**: the public member view ~40, `TryGetIndexValue` / `TryGetIndexNumber` + the CLR numeric set ~35, `ReferencesOf` over the three shapes ~40, `ResolveTargetLeaves` ~10, two rejections with their messages ~20 | -| `src/GameCult.Networking` | 368 | ~400 (`CultNetSelection` + `CultNetEdge` + the operator 170, evaluator + cursor + the incoming-edge index 190, ordinals 20, v1 classes and lowering ~40 minus shared) | -| `src/GameCult.Mesh` | ≈ 365 gross | ≈ 40 (one `WithSelection`, one exact read) | -| `packages/cultnet-rs/src` | ~31 (`snapshot_query.rs`'s filter) | ~430 (`selection.rs` 390 with edges and numbers, `contracts.rs` 40) | -| `packages/cultnet-py`, `cultmesh-py` | 0 | ~5 (the `unsupported_schema_version` reply, ruled into this cut) | -| `contracts/cultnet` | 0 | 4 schema files (~200 lines JSON), 1 interop row schema, 2 vector files (generated) | -| tests, C# | ~250 rewritten | ~600 (S1-S12, S15-S18, S20 in Networking; S19, S21, S22 in Caching; the vector writer) | -| tests, Rust | 0 | ~340 (S12-S14 with the edge and number vectors) | -| entries | 0 | ~38 entries across three targets | -| docs | — | this map; two paragraphs | -| **net source outside tests** | | **≈ +32 in C# Networking, +150 in C# Caching, +399 in Rust; ≈ +585 across the repo** | - -**The estimate moved, and in the wrong direction.** The committed version of -this ledger said ≈ +370 and ≈ −18 in C#. Both were wrong, for one reason: -the map assumed the cache needed no change, and the cache needs about 150 -lines of new public surface before the evaluator can read a single declared -value from outside the assembly (section 1). The honest figure is ≈ +585. -What the repo buys for it is unchanged in kind and larger in size: one -evaluator where **five** stood (three in C#, one in Mesh's re-filter, one -in Rust), a read surface where the substrate's own consumers were -reflecting over documents, edges and their payloads where a declared -reference was unreadable, numeric comparison over a type the catalog has -persisted all along, and a Rust runtime with the capability at all. Nothing -here is a reason to shrink the cut; it is a reason not to claim the cut -shrinks the repo. - -The repo grows by about 370 source lines for: a typed selection with a -derived-by-vector schema where two allowlists were the only language; -projection as a value where it was a delegate no caller reached; an exact -snapshot cursor where paging did not exist; one evaluator where three -engines and six schema matchers stood; a Rust runtime that did not have the -capability at all. CultMesh proper shrinks ≈ 326. The liability retired is -not in the line count: five copies of one options record, four spellings -of schema identity, a client that re-filtered what the server answered and -a read that could return the wrong key. - -## 15. Build budget - -C#: **three** assemblies and three test projects (`GameCult.Caching` joins -the budget; it is a dependency of the other two, so touching it rebuilds -them), debug, workstation. Rust: -`cultnet-rs` lib + tests, warm target dir, +0 to +60 paths. Nothing cleaned. -No native, no TypeScript build beyond one interop-lane run. - -## 16. Operator questions, one batch - -**Ruled 2026-09-17 and no longer questions.** Four of the batch are -settled; they are recorded here as rulings and carried in the sections -they govern. - -- **R-1 (was Q-F). v0 retires on a named trigger, not "eventually."** The - reference keeps answering v0 by lowering it into a `Selection`, with no - engine of its own. That lowering is a **scheduled deletion**: it is - deleted when FU-TS, FU-Py and FU-Kt have all landed and the interop lanes - send v1, and that is FU-v0's trigger in section 9. A shim with no - deletion date is a permanent shim; this one has a date written as a - condition, and the condition is checkable by grep over the three - runtimes' contract files. Section 4's "not deleted in this cut" row and - section 5's keeps both point here. -- **R-2 (was the second half of Q-F). Python's silent drop is fixed in this - cut.** Every other runtime refuses a message it does not understand; - Python returns `[]` (`interop_peer.py:387`) and the caller reads a hang - rather than a rejection. The five lines that reply `cultnet.error.v0 - { code: "unsupported_schema_version" }` land here, ahead of FU-Py's own - trigger, because a silence is a worse failure than a missing feature. - Carried in section 9's FU-Py entry and section 14's ledger. -- **R-3 (was Q-G). `descending` is the order; the time windows go.** - `admittedAfter` / `admittedBefore` existed to approximate an order the - vocabulary now states outright, and two filters standing in for an order - are worse than the order. They are deleted from Huginn's wire in the - consumer cut (section 12), not kept as an organ-side alias any-of. "The - latest N" is `descending, limit: N`. -- **R-4 (was Q-I). The fixture is chosen for coverage and expected to - grow.** The vector row type is the dedicated - `cultnet.interop-selection-row` family of section 6, shaped to *exercise* - the four hostile findings rather than describe them: shared fields on an - abstract middle with two leaves under it, a reference whose declared - target is that middle, and a many-reference carrying a payload. It is - **not pinned as final** — the fixture is expected to gain rows and - selections as the vocabulary meets more catalogs, and a change to it is a - normal change, not a contract break. What is pinned is the parity - obligation over whatever the fixture holds: both directions, ordered ids, - `matched`, `next` presence, and the edges with their payloads. -- **R-5 (was Q-H). Watching a selection is its own cut, mapped in section - 18 of this document**, after this one and depending on it. Nothing of it - is smuggled into the selection cut and nothing here is designed around it - speculatively; the seam already drawn — one selector type serving both a - query and a subscription — is all this cut owes it. - -**Still open:** - -- **Q-A. Leaf `Short` titles for question and ruling** (Huginn/Epiphany). - Unchanged: **A, not now** (recommended); B, a leaf follow-up before Cut 13; - C, a text projection (Cut 11's question). Depends: the organ's header row - for those two kinds. -- **Q-B. Huginn's receipt ordinal.** **A, record it** (recommended; exact - order, no `cursor_stale` on an append-only mind); **B, do not**: Huginn - refuses `cursor_stale` on advance like the reference does — now a - legitimate option under one contract, costing a re-walk on a busy mind - and id-order ties within a second. Depends: Huginn's consumer cut only. -- **Q-C. Delete `open_items` and `history`.** **A, delete** (recommended); - B, thin presets in Huginn; C, wire operations (refused). Depends: Cut 13's - tool list. -- **Q-D. The representation.** **A, declared-alias any-of over strings in a - new v1 selection** (recommended; D1, D2); B, Qdrant's `Filter` (rejected, - section 3); C, typed enums on the wire (impossible in the substrate: it - cannot know a consumer's enums; the organ keeps the typed refusal at its - door). Depends: everything in sections 2-10. -- **Q-E.** Withdrawn: the seam question is answered by the placement ruling. -- **Q-J. Number encoding on the wire. RULED B, decimal strings, - 2026-09-17.** The operator: floats are fragile, and strings are the most - reliable way to store a number. **Self's recommendation of A was argued - backwards and the map said so wrongly.** B was framed as "a second value - encoding beside `any_of`'s strings"; it is the opposite. Every value in this - vocabulary is already a string, so decimal strings keep the wire to **one** - value encoding, and it is float64 that would add a second. What B really - costs is a comparison rule, and that is where the danger sits: a decimal - string compared lexicographically answers that ten is less than nine. So - the cut must specify a canonical decimal form and a numeric comparison, - and pin both with mutants — a lexicographic comparison must die, and a - non-canonical spelling of an equal value must not change an answer. Name - the edge cases the canonical form settles: leading and trailing zeros, an - explicit plus, exponent notation, and negative zero. No exactness limit - needs stating, because there is no longer one. - - *Superseded, kept as history:* **A, IEEE float64, with the 2^53 - limit stated in the schema and in this map** (recommended: one encoding, - no parse rule per runtime, and no catalog in hand declares an integer - member wide enough to lose). **B**, decimal strings — exact, but a second - value encoding beside `any_of`'s strings and a per-runtime parse rule, - and two ways to spell a number is how a vocabulary starts growing terms. - **C**, add `integer: int64` beside `number` now, sharing `op` — additive - and untagged-free, and can be added later without breaking A, which is - why adding it now is premature. Depends: the schema files and both - runtimes' predicate types. -- **Q-K. Family names for abstract bases on the wire. PARKED, 2026-09-17, - and Self's reason was wrong.** The operator: this was possible when - CultCache was a single file, so it is odd that it is hard now; not - load bearing either way. That is correct. In-process a family is one - assignability check, because the runtime holds the hierarchy. Over the - wire there is no type system, only schema names, and an abstract type - carries no `[CultDocument]` so it never gets one. **The hardness is not - modelling, it is that nothing publishes the hierarchy where a remote - caller can see it.** The honest cost is therefore a catalog addition, - each leaf's entry naming its base chain, after which a family is the - leaves whose chain contains the name asked for. Small work — but it moves - the catalog's shape, and this cut's whole claim to being cheap is that it - moves neither the catalog's shape nor its hashes. So it is **deferred to a - cut that is already touching the catalog**, not deferred because there is - nothing to name. - - **Trigger named, 2026-09-17: the source-generator campaign needs it first.** - The operator's position is that any project using CultNet wants the types it - touches native, and that where the hierarchy is not being declared in - parallel by hand, a generator should build it. That generator runs against - **published schemas**, with C# authoring and the schema as the contract, - which is what the reference-runtime rule already says. - - The obstacle is the same missing fact. `CultCache.cs:847,887,966` walks the - base types while collecting members and then discards the hierarchy, and - `ToCatalogEntry` (`:152-177`) publishes a schema id, the canonical schema, - the compatible ids and a flat member list carrying slot, name, type, - reference-ness, many-ness, target and alias. **Nothing records what a type - inherits from.** So a generator fed published schemas alone emits one flat - class per leaf with the inherited members copied into each — exactly the - hierarchy the operator wants built for them, and unbuildable from what is - published today. - - So the base chain in the catalog is a **prerequisite of the generator - campaign**, and family names fall out of it for free once it exists. Until - then a family expands at the call site into its leaf schema names, which the - generator can emit as a constant, costing the protocol nothing. The honest - limit of call-site expansion, to be stated wherever it lands: it is - closed-world per compilation, so a leaf declared where the caller does not - compile leaves the list silently short, and an open-world caller must ask the - catalog at run time instead. - - The generator is **its own campaign, mapped after this cut lands** (operator, - 2026-09-17: "definitely later"), because its value is emitting against a - shape that is settled and this cut is what settles it. It is also where the - query sugar comes from: typed per-kind builders make filtering a document by - another kind's field a compile error rather than an empty page. **No source - generator exists in CultLib today** — no Roslyn generator anywhere in the - repository, and `src/GameCult.Caching/emitted/` is empty. - - Superseded reasoning, kept as history: - an abstract type has no `[CultDocument]`, no schema name - and no catalog entry, so there is nothing to name; a caller who wants - "every crafted item" enumerates the leaves from the schema catalog it - already reads. **B**, a `[CultDocumentFamily]` declaration plus a catalog - concept plus a matching rule in every runtime, in a later cut. Note this - is only about the `schemas` list: the *hop* already resolves an abstract - target to its leaves (D9), so the hostile example works under A. -- **Q-L. Refusing an out-of-target reference at write time. RULED A, - 2026-09-17**, with the follow-up upgraded from optional to intended. The - operator: notice on read for now, but on write eventually; today this is - left to consumers to enforce, as Aetheria's Database Tools did and as - CultCache Studio is expected to, and it is easy to insert garbage at the - source level which a cheap check would prevent. - - **Two things make the follow-up worth more than "nice to have."** First, - enforcement living in consumers is duplicated authority by construction: - every tool that writes records re-implements the same check, and a tool - that forgets is indistinguishable from one that does not, until a read - refuses. Second, the check really is cheap — the declaration already names - the target (`TargetSchemaName` on the member catalog entry), and the write - path already has the record in hand. - - **What Self could establish about the consumer story, 2026-09-17:** it - rests on less than it sounds. There is no CultCache Studio repository - under `F:\Projects`, and no project file by that name anywhere; every - reference to it is forward-looking, in Aetheria's migration documents, - where it is described as absorbing that project's Database Tools. Aetheria's - actual data tooling today is the `tools/AetherDb` console project. So the - enforcement being relied on is one tool, in one project, for one catalog, - and there is no second implementation to be inconsistent with yet — which is - the cheapest moment to move the rule to its owner rather than the most - expensive. - - Original options: **A, follow-up (FU-Ref)** (recommended): this cut refuses it at read - (`reference_outside_target`, S18), which is where the corruption is - noticed; refusing at write touches the cache's put path and every - runtime's apply path and is a change of a different size. **B**, in this - cut. Under A, the read-side refusal is the only thing standing between a - corrupt edge and a wrong answer, which is why it refuses instead of - skipping. -- **Q-M. The `(schema, key)` cross product. RULED A, 2026-09-17**, in the - operator's words: once per schema. The cross product stays, the limit is - stated, and a caller needing exact pairs asks once per schema. No third - addressing list and no rule for combining three of them. - Original options: **A, state the limit** - (recommended): `schemas` × `keys` stays a cross product; a caller needing - exact pairs asks once per schema or verifies what it declared, as - `CultNetRawSnapshotQuery` already does. **B**, allow a `refs: - RecordRef[]` list beside `keys` — expressible without a term language and - genuinely useful, at the cost of a third addressing list and a rule for - how three lists combine. **C**, let a `keys` entry carry a schema — a - path language in miniature, refused. Depends: section 13's table and - `snapshot_query.rs`'s client. - -**Q-A, Q-B and Q-C are no longer open.** The operator ruled all three on -2026-09-17 and they are recorded in the Huginn campaign's map, -`F:\Projects\Epiphany\notes\eureka-pipeline-state-cut.md`: receipt ordinals -yes; `open_items` and `history` deleted rather than kept as presets; and the -leaf gains titles on `question` and `ruling`, riding the same store version -bump as the ordinal so there is one migration rather than two. They are named -below only because work here still depends on them. - -What depends on each: S1-S8 on Q-D A; S5 on the shard-log assumption -(section 1) and on Q-B for Huginn; S9 on D6; S16 and the schema files on -Q-J; S18 on Q-L A; the Huginn cut on Q-B and Q-C. Settled by R-1 to R-5: -S10, S12, the fixture, FU-v0's trigger, FU-Py's five lines, Huginn's -window deletion, and the watch cut's existence. - -## 17. What was probed, read, and not settled - -**Probed:** the untagged round trip (section 2). **Read:** every line -anchored above; the CultMesh audit's 92 sites by an Explore pass whose -classification I checked at the sites that carry the ledger (the five -clones, the four matchers, the fallback, the two engines). **Not run:** -`dotnet` or `cargo` on CultLib — the tree is dirty from the QUIC campaign -and no claim here depends on a build; Hands takes the baselines named in -Pins. **Not settled:** whether every committed write has a shard-log -sequence (section 1, Hands confirms at the append site); the exact split of -mutation entries against the QUIC campaign's runner (section 10, Self at -landing); whether MessagePack-CSharp needs a union attribute for the -page's `headers | documents` (it does not if both are optional arrays with -exactly one present, which is the spelling chosen so no union is needed — -Hands confirms the schema says "exactly one" with `oneOf` over `required`). - -**Read on the second pass, and what it changed.** Each of these was read at -the source, and three of them contradicted something this map or its -predecessor's notes asserted: - -| Read | Held | Changed | -|---|---|---| -| `CultCache.cs:474`, `:151-176`, `:598-629`, `CultSchemaTypeNames.cs:9-31` | **Yes.** A member's type name is derived from the CLR type, persisted in the catalog entry and compared inside the canonical shape. Numeric addressing needs no new declaration, no hash movement and no migration — the load-bearing claim of this whole widening | — | -| `CultCache.cs:112-150` | — | **No.** `Members` and `IndexAccessors` are `internal` with no friend assembly, so the evaluator cannot read a declared value from outside `GameCult.Caching` at all. "No cache change is needed for addressing" was false; the cache add is ~150 lines, not ~60, and the ledger moved from ≈ +370 to ≈ +585 | -| `CultCache.cs:931-943`, `:462-468` | — | **No.** A hiding member is already refused (`HiddenMemberMessage`), and a duplicate alias already throws from `ToDictionary`. D10 shrank from "a missing refusal" to "a refusal that names nothing", and its test only means anything if it asserts the message | -| `packages/cultnet-rs/src/snapshot_query.rs` | — | **No.** Rust has a fifth selector engine (`serve_read_only_raw_snapshot:112-125`) that "Rust: none" concealed, and its client (`:195-217`) shows the cross-product limit that v1 does not fix (Q-M) | -| `CultDocumentContracts.cs:92-99`, `CultCache.cs:1100-1113`, `:1495-1509`, `:1818-1838`, `:254-265` | **Yes.** `ICultRecordRef` is the enumerable handle D11 needs; assignability is already how the cache resolves a base type to concrete documents (D9); `AllDescriptors` is public | — | - -**Still not settled, and who settles it:** - -- Whether every committed write takes a shard-log sequence (unchanged; - Hands, at the append site). -- Whether `CultDocumentDescriptor`'s public member view can be a readonly - struct without forcing an allocation per row per predicate in the - evaluator's inner loop. Nothing here depends on the answer being fast, - but a `Select`-per-row over a fresh list would be a silly cost to build - in; Hands measures if a fixture of a few thousand rows is slow, and not - before. -- The exact split of mutation entries against the QUIC campaign's runner - (unchanged; Self at landing). -- Whether `serve_read_only_raw_snapshot`'s existing tests survive the - lowering unchanged; they should, since the behaviour is identical, but - they were not read line by line. -- Q-J, Q-K, Q-L, Q-M: the operator. - -**Not probed, and deliberately:** nothing was built or run against CultLib. -The tree is hosting a live QUIC campaign, and no claim in this map needs a -build to be true — every one of them is a source read, and the three that -were wrong were wrong because the first pass did not read far enough, not -because a build would have caught them. - ---- - -# Cut 2: watching a selection - -Ruled 2026-09-17 (R-5): the operator wants this and wants it soon, so it is -mapped here rather than left as a follow-up trigger. It is **its own cut**, -landing after Cut 1 and depending on it. Nothing below is smuggled into Cut -1, and Cut 1 is not shaped around it: the seam Cut 1 draws — one selector -type serving a query and a subscription alike — is the whole of what Cut 1 -owes this one. Cut 1 can go to Hands without waiting for a ruling on -anything here. - -Same discipline as Cut 1: facts by source read, deletes first, an authority -map, verification with a mutation per rule including a loosening, and a -subtraction estimate with real numbers. - -## 18.1 Body facts - -**The local watch surface today** (`src/GameCult.Networking/CultNetDatabase.cs`): - -- `Watch()` `:1051-1057` filters the change stream by CLR type; - `WatchAllChanges()` `:1063-1067`; `WatchRecord(key)` `:1072-1075`; - `WatchGlobal()` `:1080-1083`; `WatchByName(name)` `:1088-1094`; - `WatchByIndex(alias, value)` `:1100-1107`. -- **`WatchByName` and `WatchByIndex` do not do what they are named.** Both - read the cache's *current single winner* for the lookup and compare it to - the change's document by `ReferenceEquals`. Combined with section 1's - finding that the cache's index maps hold **one key per value**, this - means `WatchByIndex("kind", "cannon")` observes changes to - whichever single `Weapon` most recently claimed `cannon`, not to the - weapons whose kind is `cannon`. It also re-runs the lookup *at change - time*, so a change that clears the value is evaluated against the state - after the clear. The same two lines exist again in CultMesh as - `MatchesName` / `MatchesIndex` (`CultMesh.cs:3312-3333`). -- The rule is set-dependent even without a hop, and nothing tracks - membership: there is no "was in the set, now is not" anywhere in the - local path. `Reconcile` (`CultNetDatabaseSubscriptionServer.cs:251-292`) - is the only membership tracker in the reference and it belongs to a - server, over a delivered set, per peer. - -**The CultMesh collection surface** (`src/GameCult.Mesh/CultMesh.cs`): nine -`Collection*` overloads at `:2278-2480` — three shapes (all / by name / by -index) by three sources (`CultCache` `:2278`, `:2302`, `:2331`; -`CultNetDatabase` `:2362`, `:2386`, `:2413`; `CultMeshNode` `:2442`, -`:2456`, `:2471`, which delegate to the database trio in three lines each). -`CollectionByIndex` over a cache resolves its contents as -`Optional(cache.GetByIndex(alias, value))` — a "collection" of -**at most one row**, whose live feed then filters by `MatchesIndex`. Three -shapes exist because the shape *is* the query language; a selection -replaces the shape axis entirely and leaves the source axis alone. - -**What Cut 1 leaves in place for this cut:** `CultNetSelection` and its -validation, `CultNetSelectionEvaluator.Matches(selection, descriptor, key, -document)` for a single row, the cache's public read surface, and D6's rule -that a hop-bearing selection is set-dependent and must reconcile rather -than decide per change. - -## 18.2 The shape - -``` -CultNetDatabase.Watch(CultNetSelection selection) - -> Observable - -CultNetSelectionChange { - kind: Entered | Left | Updated // membership, not storage - schemaId, recordKey - document: object? // present on Entered/Updated under `document` projection - previous: object? // present on Left/Updated - cause: Self | Edge // this row changed, or a row it cites / is cited by did -} -``` - -**Rules, each one owner:** - -- **Membership, not mutation.** The stream reports a row entering the - selection, leaving it, or changing while inside it. A write to a row that - was outside and stays outside emits nothing. A write that changes a value - the selection filters on emits `Entered` or `Left`, **not** `Updated` — - which is precisely what `WatchByIndex` cannot express today. -- **`cause: Edge`** is how a hop-bearing selection stays honest: when a - change to row B moves row A in or out, the subscriber is told about A, - with the cause marked, and never about B unless B is itself in the set. -- **No order, no cursor, no `asOf`, no `limit`.** A live feed is not a - page. A selection carrying `limit`, `cursor` or `descending` is **refused - at the door** (`selection_invalid { field }`) rather than silently - ignored: "the latest ten, live" is a different question with a different - answer (it needs an eviction rule), and this cut does not answer it. - `projection` is honoured; `schemas`, `keys`, `fields`, `cites` and - `cited` are honoured. -- **The initial set is not a snapshot message.** `Watch` is local and - in-process; it emits `Entered` for every row already matching, at - subscribe time, under the cache's lock, before any live change. There is - no `asOf` because there is no wire and no second reader. -- **A hop-bearing selection recomputes; a plain one decides per row.** - Without `cites`/`cited`, membership is `Matches(selection, row)` and - costs one row's read. With a hop, a change anywhere can move anything, so - the watch re-evaluates the selection over the cache and diffs against the - membership set it holds. That is O(rows) per change and it is stated - plainly rather than hidden (Q-N). - -## 18.3 Deletes first - -| Path:lines | Lines | What | -|---|---:|---| -| `CultNetDatabase.cs:1080-1107` | 28 | `WatchGlobal`, `WatchByName`, `WatchByIndex` — the three that encode a query in a method name, two of them wrongly. `WatchGlobal` lowers to `keys: ["global:{schemaId}"]`, the other two to a `fields` predicate | -| `CultMesh.cs:3312-3333` | 22 | `MatchesName`, `MatchesIndex` — the same `ReferenceEquals`-against-the-winner rule, second copy | -| `CultMesh.cs:2278-2480` | 203 | the nine `Collection*` overloads; **after: three**, one per source (`CultCache`, `CultNetDatabase`, `CultMeshNode`), each taking a `CultNetSelection`, about 75 lines | -| `CultMeshSnapshots.cs` and `CultMesh.cs` local-watch predicates, audit sites #2, #4-9, #16-21 | ~240 | the remaining local watch loops and their inline predicates, about 40 after | -| **Total** | **~493** | **~115 after; net about −378** | - -`Watch()`, `WatchAllChanges()` and `WatchRecord(key)` **stay**, as -Cut 1's v0 lowering stays: a CLR-type filter and a single-key watch are -conveniences that lower to a selection and have no rule of their own. If -they grow a rule again, W6 catches it. - -## 18.4 Adds and authority - -| Add | Owner | Live consumer | Protected invariant | Replaces | -|---|---|---|---|---| -| `CultNetSelectionWatch` in `GameCult.Networking` (~130 lines): the membership set, the per-change decision, the hop recompute, `CultNetSelectionChange` | `CultNetDatabase` | Mesh's three `Collection` overloads; any local consumer that watches a question | membership is tracked in one place, and a row that leaves the set is reported leaving | `WatchByName` / `WatchByIndex` / `MatchesName` / `MatchesIndex`, four spellings of one wrong rule | -| `CultNetDatabase.Watch(CultNetSelection)` (~15 lines) | `CultNetDatabase` | the above | one entry point | three named-query methods | -| Rust: **nothing in this cut** | — | — | — | no Rust caller watches locally; when one does, it gets the same shape over `Row`/`RowSet` | - -- **Owner.** `CultNetSelectionWatch` owns membership and only membership. - `CultNetSelectionEvaluator.Matches` owns whether a row is in the set — - the watch never re-implements a predicate. `CultNetDatabase` owns the - change stream. The cache owns values, as in Cut 1. -- **Inputs.** The change stream, the cache's rows through the public read - surface, the validated selection. Not inputs: a clock, a transport, the - shard log's sequences (there is no order here), a peer's authorization. -- **Outputs.** `Entered` / `Left` / `Updated` with a cause, and one typed - refusal for a selection carrying page-shaped fields. -- **Derived state.** The membership set, and the incoming-edge index when - the selection hops. **Demotions:** `Watch` and `WatchRecord` are no - longer queries, they are lowerings; Mesh's collection *shape* is no - longer a language, it is a `Selection`; `MatchesIndex` is not an owner of - anything. -- **Forbidden writers.** Nothing outside `CultNetSelectionWatch` may decide - membership; no watch path may call `GetByIndex` or `GetByName` to decide - whether a change is interesting (that is the bug being deleted, in both - its copies); Mesh may not filter a feed the watch answered; the watch may - not emit `Updated` for a row that crossed the predicate boundary; the - watch may not accept `limit`, `cursor` or `descending`. -- **Shared paths.** `Matches` under both the query and the watch — a row - that a page would return and a row the watch reports entering are decided - by the same function, or the two truths drift. The subscription server's - `Reconcile` keeps its own per-peer delivered set (it answers a different - question: what this peer has been told) and **does not** become the local - membership tracker. -- **Deletion line.** Commit 1: `CultNetSelectionWatch` and - `Watch(Selection)`, with the three named-query methods deleted and their - tests rewritten. Commit 2: Mesh's nine overloads collapsed to three, both - matchers deleted. Nothing lands with `WatchByIndex` alive beside it. - -## 18.5 Verification - -| # | Test | Pins | Revert kills | Loosening kills | -|---|---|---|---|---| -| W1 | `Watch_ReportsARowLeavingWhenItsFilteredValueChanges` | membership, not mutation — the bug being deleted | `Left` never emitted (today's behaviour restored: the change is simply not delivered) | `Updated` emitted instead of `Left`, so a subscriber holding a list keeps a row that no longer matches | -| W2 | `Watch_ReportsEveryRowSharingAnIndexValue_NotTheCacheIndexWinner` | the deletion of the `ReferenceEquals`-against-the-winner rule | `MatchesIndex` restored | membership decided by the winner *plus* the changed row, which passes a two-row fixture and fails a three-row one — **the fixture must carry three rows sharing the value** | -| W3 | `Watch_EmitsTheInitialSetBeforeAnyLiveChange` | the subscribe-time set | no initial emission | the initial set emitted *after* the subscription goes live, so a write racing the subscribe is delivered twice or not at all — needs a test that writes between subscribe and first emission | -| W4 | `Watch_ReportsAnEdgeCausedEntryWhenTheCiterChanges` | `cause: Edge`, D6 locally | a hop-bearing watch decided per changed row (the citee never moves) | the citee reported with `cause: Self`, which loses the subscriber's ability to tell a row's own change from a set change | -| W5 | `Watch_RefusesAPageShapedSelection` | no order, cursor or limit on a feed | the refusal dropped and the fields ignored | `limit` refused but `descending` ignored — one field's worth of silent ignoring, which is how a "harmless" ignored field becomes a bug report | -| W6 | `Watch_AndSelect_AgreeOnMembershipForTheSameSelection` (property-shaped: for each fixture selection, the set the watch holds equals the ids a page returns) | the shared `Matches` | the watch given its own predicate | the watch's copy agreeing on the plain selections and differing on the hop-bearing ones — kills only if the fixture's selections include hops, which section 6's fixture does | -| W7 | `Mesh_CollectionTakesASelectionAndFiltersNothingItself` (Mesh tests) | the collapse | an overload restored | the three surviving overloads re-filtering the feed after the watch answered | - -**Negative greps:** `rg -n "WatchByIndex|WatchByName|MatchesIndex|MatchesName" src` -empty; `rg -n "GetByIndex|GetByName" src/GameCult.Mesh src/GameCult.Networking` -empty; `rg -n "CollectionByIndex|CollectionByName" src` empty. - -**Mutations.** Entries in this campaign's own file, target `networking` -(killer `dotnet test tests/GameCult.Networking.Tests`) plus the Mesh tests -for W7, one per rule above with its revert and its loosening. - -## 18.6 Subtraction estimate - -| | Removed | Added | -|---|---:|---:| -| `src/GameCult.Networking` | 28 | ~145 | -| `src/GameCult.Mesh` | ~465 | ~115 | -| tests | ~80 rewritten | ~260 (W1-W7) | -| **net source outside tests** | | **about −233** | - -This is the cut where CultMesh actually shrinks: about −350 in -`CultMesh.cs` and the snapshot facade against about +117 in the database -organ. It is also the cut that deletes a wrong answer rather than a -duplicate one — four spellings of "watch the row that currently wins a -unique-index lookup", replaced by one membership tracker over the selection -the caller actually asked about. Cut 1 pays about +585 for the vocabulary; -Cut 2 spends it. - -## 18.7 Operator questions for this cut - -- **Q-N. The hop-bearing watch's recompute.** **A, recompute and diff on - every change** (recommended: obviously correct, O(rows) per change, and - the local caches this runs over hold thousands of rows, not millions). - **B**, maintain an incremental incoming-edge index invalidated per write - — faster, and a second piece of derived state that can disagree with the - cache. Take B only with a measured reason. -- **Q-O. Does `WatchRecord` survive?** **A, yes, as a lowering** - (recommended; it is one key and no rule). **B**, delete it too and make - every caller say `keys: [k]` — cleaner, noisier at its call sites. -- **Q-P. Ordering on a feed, later.** Out of this cut by the rules above. - If "the latest N, live" is wanted, it is a third cut with an eviction - rule, not a field added here. - -**R-AA landed, 2026-09-22** (Sonnet), `b7d77b7..99e366a` on -`cultnet/selection-cut1`. One new test file, 27 tests, 707 lines. **No -production code touched.** Score **66% → 77.62%**: killed 345→371, survived -85→57, no-coverage 75→50, over the same 428-mutant set both passes. Suite -green on Yggdrasil, 271 passed / 2 skipped. - -Every one of the nine named survivor groups is killed, with two corrections to -the triage that matter more than the score. - -- **`EdgesFor`: three of five killed. STRUCK 2026-09-23 — what stood here was - wrong.** It claimed that within one hop direction `(From, Role)` determines - a unique declared edge value, so no legal selection could make two edges - share anchor, From and Role while `To` differs, and recorded `To.SchemaId` - and `To.Key` as equivalent "so nobody pays for them a third time". **A - selection carrying both hops mixes their edges into one bucket**, and Soul - built the counterexample: a row self-referencing through the role it uses to - cite a peer. `To.Key` is now killed in both runtimes; `To.SchemaId` is - settled under R-BA. The text is struck rather than edited because it was - read as a live instruction for two passes. -- **A sixth mutant in the same method that nobody had named**: - `OrderBy(pageRowIndex)`, which is R-B's *primary* key, ahead of - `(from, role, to)`. It survived the first pass and is now killed by a test - that forces page order and `(from, role, to)` order to disagree. The rule - R-B exists to protect had its first component unguarded, and the triage had - not caught that either. -- **The digest needed a golden value, not a comparison.** Beyond the named - branch mutants, about nineteen finer-grained ones survived — deleting - individual `AppendString` calls. A same-versus-different digest test - structurally cannot catch these: a mutant that swaps which case gets which - flag still produces two *different* digests, merely mislabelled. Hands - reconstructed a golden HMAC independently from the method's doc comments - rather than from its private helpers, which is the right way to build one, - and it killed all but three residual coincidences. - -**Line drift: every rule had moved 30–90 lines** from Soul's `52082ec` -numbers, none to a different method. Locate by name, not by number, and do not -trust the numbers in this section either. - -**Four things found along the way, flagged rather than silently fixed.** Two -are test gaps; two look like real defects: - -- `ReadLengthPrefixedFields`, `length <= 0`: a legitimately zero-length field - would be wrongly refused. -- `ReferenceMembers`'s `!member.IsReference` guard: a data member could be - treated as citeable. -- `FindCursorPosition`'s loop bound: an out-of-bounds read when paging past - the last row with a cursor exactly at the end. -- `ComputeDigest`'s `else`-branch appends survive only because the golden - test has both `Cites` and `Cited` non-null; a second golden with both absent - closes them. - -**Self's rulings, 2026-09-22:** - -- **R-AC. STRUCK 2026-09-23. It said the two `EdgesFor` `To` mutants were - equivalent and "recorded, not to be chased".** That instruction was false - and was obeyed for two passes. Soul's counterexample kills `To.Key` in both - runtimes; `To.SchemaId` is settled under R-BA. **The sentence it closed with - — a survivor correctly identified beats a test written to move a number — - is still true, and is exactly why a survivor must be identified by a - construction attempt rather than by an argument.** -- **R-AD. The three suspected defects above get behaviour tests first**, since - a test that fails today is the only thing that proves they are defects - rather than readings. The out-of-bounds read in `FindCursorPosition` is the - one to check first: it is reachable from an attacker-supplied cursor. -- **R-AE. A second golden digest with both hops absent**, closing the three - residual mutants rather than leaving them as folklore. - -**Fix batch 4, Rust half, landed** (Sonnet), `cultnet/selection-cut1` now at -`d7f73af`, rebased onto the C# side's `99e366a`. Six commits: `c91e937` -(R-V and Rust's half of R-W), `97627dd` (R-Y), `4bfd989` and `94c32ac` -(R-AB), `8005586` (S-12, prose), `d7f73af` (a vendored-schema resync). - -**217 Rust tests green** on Yggdrasil, and re-confirmed locally with -`contracts/` entirely hidden, which simulates cargo-mutants' isolated copy. -**Mutants scoped to the diff: 23 tested, 23 caught, 0 missed.** Nothing to -triage. - -**S-2 is C#-only** — Rust already checked the declared target before filtering -by key, so the divergence was one-sided and the C# commits close it. No Rust -change was needed and none was made. S-1 and S-3 are closed by R-V and R-W. - -**R-AB worked, and it took two fixes rather than one.** The named escape was -`schema_discovery.rs`'s `include_str!("../../../contracts/…")`. Vendoring -byte-identical copies under `packages/cultnet-rs/contracts/` fixed that and -left the crate still unmutable: `tests/selection.rs`'s fixture loader read the -same canonical tree three levels up, and 37 of 45 tests panicked under the -isolated copy. The first full-crate run failed its unmutated baseline for -exactly that reason. Vendoring the fixture too, plus a skip-when-absent guard -on the test that reads C#'s own `cs-written.json` output — which cannot be -vendored, being the other runtime's product rather than a checked-in input — -made the crate mutable for the first time. - -**The vendoring is duplicate authority, and it drifted within hours.** The -rebase onto the C# side's landed R-X changed `cultnet.error.schema.json`, and -the vendored copy did not see it. **Hands' own drift test caught it** and the -copy was re-synced at `d7f73af`. - -That is worth stating plainly rather than filing as a win. Twenty-two schemas -now exist twice, and the guard against the copies diverging is a test rather -than a structure. The cleaner shape — a build script staging the canonical -contracts into `OUT_DIR` — **fails for the same reason the `include_str!` -did**: cargo-mutants copies the package tree, so a `build.rs` reaching three -levels up is just as unreachable. Publishing the contracts as their own crate -would fix it properly and is out of this cut's scope. **So the duplicate is -accepted for now, on the record, with the drift test as its named guard.** It -goes in the follow-ups, not the win column. - -**Hands burned an unscoped full-crate mutants run** — 2,329 mutants and a -timeout cascade across files the cut never touched — before rescoping to the -diff. It reported that unprompted and discarded the output. The ruling did say -"the cut's diff"; the run cost most of a night on a shared host. - -## Soul, the merge gate, 2026-09-23 - -Opus, against `d7f73af`. Counts re-run by Soul itself: Networking 269 passed / -2 skipped, Mesh 255, cultnet-rs **224** across 12 targets. (R-AA reported -"271 passed" — that is 269 + 2 skipped. The Rust half reported 217; the -measured figure is 224. Both green, one overstated.) - -**Verdict: Cut 1 may not merge.** Three reasons, any one sufficient. - -### SM-1, high. S-1 is not closed. One ruling became two different rules. - -`CultNetSelectionEvaluator.cs:358-386` resolves a reference's target by -**record key plus the declared leaf set** — its own comment says "a -reference's stored target is a bare record key, the wire carries no schema for -it". `packages/cultnet-rs/src/selection.rs:1765` and `:1817` resolve it by an -exact `by_key.get(&(target.schema_id, target.record_key))` on the -`RecordRef`'s own schema id. R-V said both runtimes index rows **and incoming -edges** by the pair. C# indexes rows by the pair and edges by the key; Rust -indexes both by the pair. - -Probed at the evaluator in both runtimes, same logical rows: - -| Shape | C# | Rust | -|---|---|---| -| Only row at key `k` is out-of-target; narrow ref declared to leaf_a points at `k` | **REFUSED** `reference_outside_target` | **ACCEPTED**, empty page | -| Two rows at key `k`; ref declared to leaf_a, stored target names leaf_b | **ACCEPTED**, resolves the leaf_a row, emits an edge | **REFUSED** `reference_outside_target` | - -**They give opposite answers on the exact shared-key shape R-V was written -for.** A consumer paging the same data through the two runtimes gets a -refusal from one and rows from the other. Parity is this cut's invariant. - -**No vector covers it:** the shared fixture has zero duplicate record keys -across its ten rows, exactly one reference, and that reference's role targets -both leaves — so `reference_outside_target` is never reached cross-runtime at -all. R-V's narrower promise does hold: within each runtime, both row orders -agree. - -### SM-2, high. Both runtimes take a hostile cursor into an unhandled fault, on mirror-image cases. - -- **C#.** `ReadLengthPrefixedFields` (`CultNetSelectionEvaluator.cs:750-751`) - tests `pos + length > bytes.Length` in `int`. A prefix of `2147483647` - overflows, the guard passes, and `Encoding.UTF8.GetString` throws - `ArgumentOutOfRangeException`. `HandleSnapshotRequestV1Async` catches only - the three typed selection exceptions and `CultNetRudpSchemaServer.DispatchAsync` - has no catch at all, so **an untyped exception reaches the server's poll - loop**. The peer gets no answer. -- **Rust.** `read_length_prefixed_fields` (`selection.rs:2044-2046`) parses the - prefix as `usize` and computes `pos + len`; `18446744073709551615` - overflows. Probed: **panic.** - -Rust refuses the `int::MAX` case typed; C# refuses the `usize::MAX` case -typed. **Each runtime has exactly the hole the other closed** — which is what -happens when a rule is hardened twice independently and neither run fed it -garbage. R-N's whole point was that every cursor refusal reaches the wire as -`cursor_invalid`. - -### SM-3, high. R-Z did not land, and nobody said so — including me. - -R-Z required the vectors to compare **page bytes**, plus `asOf`, `next` and a -refusal's **code**, with projection vectors on both sides. -`git diff --stat 52082ec..d7f73af` touches neither -`SelectionParityVectorTests.cs` nor either vector file's vectors. The reader -still compares row ids, `matched`, `hasNext` and edge fields, and -`expectedRefusalField` — **never the code**. There is no page-bytes field in -either JSON. `rs-written.json` still carries no projection vector, which is -S-7's original wording verbatim. The C#-side projection vectors run through -`Select`, which ignores `Projection`, so the comment claiming "page bytes -under each projection" describes something the test does not do. - -**R-Z is absent from the batch's work and from its open list.** Self recorded -the batch as closing its rulings without checking that one, which is the -tracking failure that let it pass silently. - -### SM-4, medium. Two ordering rules are pinned by their mutants, not their behaviour. - -Twelve non-revert mutations, each changing a rule a different way from the -Stryker mutant its R-AA test was written against. Nine died. Three survived: - -- **`EdgesFor`'s secondary key.** Permuting `Role` ahead of `From.Key` - (`:307-311`), keeping every component, passes 269/269. R-AA's test kills the - *primary* key's deletion; the **composition** of the rest is unpinned, and - the fixture's single reference pins nothing either. -- **The row tiebreak.** Swapping `SchemaId` and `Key.Value` in the ascending - tiebreak (`:214`) passes 269/269. The fixture does have one tied ordinal, - but both rows are leaf_a, so **the schemaId component of - `(ordinal, schemaId, recordKey)` is exercised by nothing** — not in unit - tests, not in vectors. Rust's `order_rows` uses the same three components, - so a silent permutation on either side goes unnoticed. -- **`!member.IsReference`** (`:456`) is a redundant second copy of the guard - in `CultCache.ResolveReferences`/`ReferencesOf`, which already returns empty - for a data member. **Equivalent mutant, and duplicate authority** — not a - defect, but not innocent either. - -### SM-5, medium. The Rust half of the vocabulary has 59 live mutants and nobody has looked. - -The diff-scoped run ("23 tested, 23 caught, 0 missed") measures only the lines -batch 4 changed. Soul ran cargo-mutants over the whole of `selection.rs`: -**351 mutants, 274 caught, 59 missed, 14 unviable, 4 timeouts, 36 minutes.** - -- **`canonical_number`: about 35 missed plus all four timeouts.** `is_canonical` - — the Q-J door — has **every branch mutation surviving**. `decompose`, - `pad_right`, `canonicalize_decimal_digits`, `big_mul_small` and - `big_to_most_significant_first` can each be replaced with `String::new()` or - `"xyzzy"` and the suite stays green. **This is R-D, a byte-for-byte wire - parity rule.** -- `validate`: 4 missed, including a deleted `!` and `||` → `&&` — the door R-F - put inside `select`. -- `matches_schema_keys_fields`: 3 missed, including two deleted `!` and an - `==` → `!=` — which rows match. -- `schema_alias::matches`: `==` → `!=` — R-E's one identity rule. - -**S-5 blocked this cut at 66% on the C# side and produced R-AA. The Rust side -of the same rules has never been measured. The asymmetry is the finding.** - -### Settled, not defects - -- **`FindCursorPosition`'s loop bound is not a defect.** It bounds at - `i < ordered.Count`. Probed in both runtimes: paging to the exact end and - replaying the last cursor gives an empty page, `next = null`, no exception, - no panic. The Stryker survivor was a coverage gap. **R-AD's headline - suspicion was wrong**, and settling it was worth the pass. -- **`length <= 0` does not exist** in either runtime, and a zero-length field - parses fine in both. The real bug in that function is SM-2's overflow. -- **S-2 held, and Hands' "C#-only" claim is true** — Soul checked rather than - accepted it. Both Rust call sites run `ensure_within_declared_target` before - any role or key filtering, with a test pinning it. -- **S-3 held.** A both-hops selection returns all its `cites` edges in both - runtimes, each anchored by its own hop, identically. -- **S-12 is half done.** The fixture's prose was fixed; - `SelectionParityVectorTests.cs:200-208` still calls the name-alias case a - "Confirmed cross-runtime defect" that the alias port already fixed. Low, but - it is a falsehood in a file a future reader will trust. - -### Promises that held - -S-4 (real `CultNetErrorMessage` bytes validated against the schema for all -four codes), S-6 (a spliced digest and a reused cursor under a changed -selection both refused), S-9, S-10, S-11 (the hop refusal is gone and the hop -is served; still no dedicated regression test). **R-AB's guard is real**: all -23 vendored files are byte-identical right now, the hand list matches every -`include_str!` 22/22, and flipping one byte makes the drift test fail by name. -**R-AA's tests are mostly behavioural**: nine of twelve hand mutations died, -including the digest under a double-append rather than a deletion, the -comparator forced back to UTF-16 units, both role-naming sites under inverted -precedence, and cursor positioning made inclusive. - -**Caching's three failures remain unproven, not passing** — the stopgap's -container runs as root and the tests need a write to a read-only directory to -fail. Soul declined to call them environmental on its own authority. - -### What Soul could not run - -- **No page-byte parity comparison exists to run.** C#'s page is a - `CultNetSnapshotResponseRawV1Message` envelope; Rust's is a bare - `SelectionPage`. **There is no common wire type**, so R-Z as written needs a - shape decision before it can be implemented at all. -- No fresh Stryker run on the C# side; twelve hand mutations instead, which is - what the brief asked for. The Rust figure is Soul's own measurement. -- Only `selection.rs` was mutated in Rust; `contracts.rs`, `schema_discovery.rs` - and the rest of the crate are unmeasured. - -### The rig, handed over - -`C:\Users\Meta\eureka-soul-probes\cultnet-selection-cut1\` — deliberately -outside the repo and outside the session scratchpad, **so it does not -evaporate the way the Idunn rig did**. `README.md` says where each file drops -in and what it proves: `SoulProbeTests.cs`, `soul_probe.rs`, -`soul-mutants.sh` and twelve precomputed mutated files (the dotnet image has -neither python3 nor perl to patch with). - -## Self's rulings for fix batch 5, 2026-09-23 - -- **R-AF (SM-1). One rule, and the wire decides which.** Hands establishes - empirically what a stored reference actually carries — a bare record key, or - a key and a schema id. **If the wire carries no schema, C#'s rule is right - and Rust adopts it. If it carries both, Rust's is right and C# adopts it.** - I am not choosing by taste between two implementations when the Body already - knows the answer; what I am ruling is that the answer is one rule, derived - from the wire, in both runtimes. **A parity vector must cover the shared-key - shape in both directions** — its absence is why this survived four passes. -- **R-AG (SM-2). Every malformed cursor becomes `cursor_invalid` on the - wire, in both runtimes, and nothing else escapes.** Use checked arithmetic - on both sides. C#'s dispatch path gains a catch so an untyped exception - cannot reach the poll loop. **Feed each runtime the other's proven - overflow**, plus a small set of deliberately hostile cursors, and pin them. - The shape of this bug — each runtime holding exactly the hole the other - closed — means neither side's tests are evidence about the other. -- **R-AH (SM-3). R-Z needs its shape settled before it can be built.** The - envelope types differ, so **the vectors compare the canonical MessagePack - bytes of the page payload** — rows, edges, `asOf`, `next` — which both - runtimes can produce, rather than the transport envelope, which only one - has. Refusals compare the **code**. Projection vectors exist on both sides, - and `Select` must actually honour `Projection` or the vector is a lie. - **Flag for operator review**: this is my ruling on a wire-shape question, - and if the payload's canonical form is meant to be something else, it should - be corrected before the vectors harden around it. -- **R-AI (SM-5). Measure the Rust vocabulary and triage it.** Run - cargo-mutants across `selection.rs` and the rest of the crate's selection - path, and close survivors by behaviour. **`canonical_number` first**: R-D is - a byte-for-byte parity rule whose door currently survives every branch - mutation, which means the canonical decimal form is pinned by nothing in - Rust. Equivalents get a one-line reason. -- **R-AJ (SM-4). Pin the ordering compositions, in both runtimes and in the - vectors**: `EdgesFor`'s secondary key ordering, and the schemaId component - of the row tiebreak, which needs a fixture with a tied ordinal across two - schemas — the current fixture's tie is within one leaf. -- **R-AK. Delete the evaluator's redundant `!member.IsReference` guard.** - `CultCache` owns that decision and already enforces it. Duplicate authority - is the defect even when the duplicate is harmless today. -- **S-12's remainder:** correct the comment that still calls a fixed defect - confirmed. - -### Fix batch 5 landed, 2026-09-23 - -Sonnet, five commits on `sel-fix5`. C# Networking **274 passed / 2 skipped** -(was 269/2), Mesh 255, Rust 50/50 with `cargo-mutants --in-diff` reporting 26 -tested, 21 caught, 5 unviable, **0 missed**. - -**R-AF: the wire carries no schema, so C#'s rule was the right one.** -Established by probe, not by reading either comment: a real `Design` reference -field serialized through `MessagePackSerializer` dumps as `A4-61-2D-65-71` — a -bare five-byte msgpack string, `"a-eq"`. The whole document is -`["citer-1","a-eq"]`. No schema id anywhere. `CultRecordRefFormatter.Serialize` -confirms it: `writer.Write(value.Key.Value)`, unconditionally, for every -`CultRecordRef` in the codebase. - -**Rust adopted C#'s rule.** `Row::references()` returns a bare -`target_record_key`; `by_key` is grouped by record key alone; a new -`resolve_reference_target` mirrors `TryResolveReferenceTarget` exactly — -search every row sharing the key, return the first inside the declared leaf -set, refuse deterministically by schema id if none is. `RecordRef` survives -only where the wire genuinely carries both, which is the `Citation.target` -query filter. - -**The vector that was missing now exists.** The fixture gained a -`citer_narrow` schema with a real SHA-256 id and rows for **both** shapes from -Soul's table: a lone out-of-target row, which refuses, and a shared key with -one in-target and one out-of-target row, which accepts and resolves the -in-target one **regardless of row order**. Plus a new `expectedEvaluationRefusal` -vector field — narrower than R-AH's job, just which typed refusal fires. - -**A second real defect, found while landing R-AF.** Rust's `matches_citation` -resolved and target-checked **every** declared reference on a row before -filtering by the citation's requested role; C# filters by role first. Rust's -role filter moved ahead of resolution to match. One existing Rust test was -therefore pinning behaviour C# does not have, and was rewritten to mirror C#'s -real shape. **This was a live divergence nobody had named** — neither Soul nor -any ruling. - -**R-AG.** C#'s `pos + length` overflowed in unchecked `int`; fixed by -promoting to `long`. Rust's `pos + len` overflowed in `usize`; fixed with -`checked_add`. `CultNetRudpSchemaServer.DispatchAsync` gained a backstop catch -so no untyped exception reaches the poll loop. **Each runtime was fed the -other's proven overflow**, plus three further hostile shapes, four new tests a -side, each confirmed to fail without the fix. - -**R-AJ, and the finding inside it: the existing row-tiebreak test was -degenerate.** Hands hand-reverted the tiebreak and swapped it, and the test -**still passed 100%** — purely by accident of which of `SelLeafA`/`SelLeafB`'s -real hash ids happened to sort first. It was rewritten to assign keys relative -to the schema ids discovered at runtime, then re-probed and now fails -correctly. The same shape was added in Rust, with a shared-fixture vector -carrying a tied ordinal **across two schemas** — the original fixture only -ever tied rows of the same schema. `EdgesFor`'s secondary key got the same -treatment. - -**R-AK.** Verified before deleting: `CultCache.ReferencesOf` already searches -only its own reference members for a role match, and index aliases are unique -per descriptor, so a data member's role string cannot collide with a reference -member's. The redundant guard is gone. - -**S-12** is closed; the stale "confirmed cross-runtime defect" comment is -corrected against source. - -**Not done, and named rather than buried:** - -- **No diff-scoped Stryker run.** `--since` crashed on `GitInfoProvider` in - the detached-clone container, so Hands fell back to whole-file globs: 312 - tested, 262 killed, **47 survived**, 3 timeouts, untriaged between the - changed lines and the large pre-existing bulk of both files. Every rule - Hands touched was separately confirmed by hand. **The tooling failure was - worked around, not root-caused**, which means the next pass inherits it. -- **The RUDP dispatch backstop has no dedicated integration test.** It would - need a fuller server harness. Flagged, not built. - -### R-AI landed, 2026-09-23 — `canonical_number` measured and closed - -Sonnet, four commits rebased cleanly onto `sel-fix5`, pushed as -`sel-fix5-rsmut` at `fc51e9a`; 50/50 Rust tests pass against the rebased tree. -**None of it touches the edge-resolution path** — the whole diff is insertions -inside `canonical_number`'s own nested `mod tests`, with zero hits for -`references`, `by_key`, `matches_citation`, `resolve_reference_target` or -`RecordRef`, so nothing was measured against code batch 5 has since rewritten. - -**126 mutants: 89 caught / 29 missed / 7 timeout / 1 unviable → 114 caught / -4 missed / 6 timeout / 2 unviable.** - -`is_canonical` — the Q-J door, where **every branch mutation had been -surviving** — is closed by direct grammar tests that had never been called -before; the function was only ever reachable indirectly through a handful of -`validate_field` spellings. `compare`, `decompose`, `pad_right`, -`canonicalize_decimal_digits`, `big_mul_small`, `big_to_most_significant_first`, -`big_from_u64` and `exact_decimal_from_mantissa` each got direct tests, every -one confirmed red under its own mutation by a real re-run rather than by -inference. - -**Another test that passed by luck.** `render_f32`'s sign-bit mutant survived -Hands' first negative-value tests because **1.0 and 2.0 happen to have bit 0 -matching their real sign bit**. Adding `-1.0` and `-2.0` killed it. Same shape -as the degenerate row-tiebreak test in batch 5: a fixture whose values -coincidentally satisfy the assertion. - -**Four survivors, all judged equivalent by hand-tracing rather than assumed:** -two in `is_canonical` (a leading-zero guard that is a pure early exit, since -anything it would catch is caught later by the dot check; and an increment -skipping a digit the caller already validated, which the following loop -re-consumes either way), and `|` → `^` in both `render_f64` and `render_f32`, -where the fraction is masked to exactly 52 or 23 bits so the implicit leading -bit is never set and the two operators are bit-identical. - -**Six timeouts are inherent infinite loops under mutation, not test gaps** — a -`+=` → `*=` on a loop's own increment, two on `big_from_u64`'s loop bound, and -two exponent-sign corruptions that wrap a negative `i32` into a near-`usize::MAX` -bound. Any test reaching those lines hangs regardless of what it asserts; the -timeout is cargo-mutants' signal for "behaviour changed", it simply cannot -classify a hang as caught. - -### **`-j4` is not reliable for verdicts on this image, and that is retroactive** - -The identical commit gave **different missed and timeout sets across three -separate `-j4` runs** — `render_f64`'s L284 alone flipped between missed and -caught with no code change — while every `-j1` run reproduced the same 4 -missed / 6 timeout. The likely cause is the shared `CARGO_TARGET_DIR` under -concurrent mutant builds, which is the same class as this pipeline's existing -shared-target scar. - -**This makes every concurrent mutation figure in this campaign provisional**, -including Stryker runs made with `--concurrency 4` and any cargo-mutants -result above `-j1`. It does not invalidate them — a killed mutant that was -genuinely killed stays killed — but a *survivor* list from a concurrent run -cannot be trusted as complete or as accurate. Where a survivor list drove a -ruling, the ruling stands on the hand-confirmed evidence beside it, not on the -count. - -### Honest scheduling account - -Six real runs launched, **two duplicated and killed** — one caught by Hands, -one Self had to flag. Effective slot time on real measurement runs was about -**47 minutes**, spread across **just over five hours of wall-clock**, most of -it back-and-forth: duplicate cleanup, the `-j4` flakiness detour, and the -rebase. Hands reported this unprompted and in detail, which is the only reason -the `-j4` finding exists at all. - -### Unmeasured, and named - -`contracts.rs` (about 100 mutants) and `schema_discovery.rs` (about 50) were -**not run against `sel-fix5` at all**. One partial run, killed mid-flight, -showed several `MISSED` across `contracts.rs`'s `validate_*` family — -`decode_cultnet_message_from_slice`, `validate_message`, -`validate_mutation_contract`, `validate_schema_descriptor`, -`validate_document_record`, `validate_raw_document_record`, -`validate_shard_descriptor`. **That is real signal on the door family, not a -count.** At `-j1`, 150 mutants is a several-hour commitment. - -**Self's decision: queue it, do not run it now.** The merge gate needs a Soul -pass on batch 5 first, and the selection cut cannot merge on a mutation sweep -of an adjacent file. Recorded as a follow-up with the partial signal attached -so the next pass starts from it rather than rediscovering it. - -## Soul, the merge gate again, 2026-09-23 - -Opus, against `fc51e9a`. Counts re-measured: C# Networking 274 / 2 skipped, -Mesh 255. **Rust is 254 tests across 11 targets**, not the 50 reported — -that figure was `tests/selection.rs` alone, one target of eleven. - -**Verdict: Cut 1 may not merge.** Two reasons, either sufficient. - -### SM-6, CONFIRMED, high. R-AK deleted a load-bearing guard, and wrote a false premise into the source to justify it. - -This one is mine. I ruled the `!member.IsReference` guard was duplicate -authority and ordered it deleted. Hands verified and got it wrong, then left -a comment claiming "index aliases are unique per descriptor, so a data -member's role string can never coincide with a reference member's." - -**Source contradicts that.** D10 (`CultCache.cs:1085-1097`) groups only -members whose `ResolveIndexAlias` is non-null — alias against alias. A plain -data member with no alias contributes its `MemberName` to the same role -namespace and is checked against nobody. - -Probed: a document with a data member `Owner` and a reference member aliased -`Owner` **registers fine**, and then every hop path throws -`ArgumentNullException: Value cannot be null (Parameter 'targetType')`. -`ReferenceMembers` now yields the data member, `ReferencesOf` matches it to -the *reference* member's edges by role string, `member.TargetType!` is null, -and `ResolveTargetLeaves` throws. Before the deletion the guard skipped that -member and the selection returned one edge. - -**Restoring the guard leaves 274/274 green — the suite has no opinion either -way.** Any schema shaped that way makes every `cites`/`cited` selection over -it fault, the peer gets no typed refusal, and **the batch's own new dispatch -backstop swallows it with no log.** - -### CONFIRMED, medium. The dispatch backstop is untested and answers nothing. - -`catch (Exception) when (false)` — so the backstop never matches — survives -274/274. `HandleSnapshotRequestV1Async` catches only the three typed selection -exceptions, unlike its siblings `HandleShardLogRequestAsync` and -`HandlePutAsync`, which catch `Exception` and answer a `CultNetErrorMessage`. -**The snapshot path is the one handler where an untyped fault becomes -silence.** R-AG's invariant was that malformed input reaches the wire typed -and nothing else escapes; a silently dropped dispatch is not that. It is a -compensator, and it is already hiding SM-6. - -### SM-4, CONFIRMED, medium. R-AJ closed about half of it, and Rust got the thin half. - -| mutation | C# | Rust | -|---|---|---| -| drop edge-sort `To.SchemaId` | survives | survives | -| drop `To.Key` | survives | survives | -| drop `From.SchemaId` | killed | **survives** | -| drop `Role` | killed | **survives** | -| drop row-order `recordKey` | killed | **survives** | -| swap row-order schema/key *(control)* | killed | killed | - -**The controls dying means the rewritten tests are not degenerate in the old -way** — R-AJ's headline fix is real. But the new Rust edge test puts both -edges on the same `from.schema_id` and never reads `to`, so it pins exactly -one thing: `from.record_key` before `role`. **Dropping `role` entirely — the -component it was written for — survives.** - -### CONFIRMED, medium. Shared-key resolution is order-dependent and unpinned in both runtimes. - -Iterating candidates reversed (C#) and preferring the last in-target candidate -(Rust) both survive. Nothing pins "the first row in the caller's order wins" -when **two in-target** rows share a key; R-AF's new vector covers one-in and -one-out only. Both runtimes agree in source today, and that agreement assumes -both are handed rows in the same order, which nothing between a C# cache and a -Rust row owner guarantees. - -### PLAUSIBLE. `RowSet::target_leaves(role)` takes no schema - -(`selection.rs:1333`), where C# resolves the target set from the declaring -member's own `TargetType`. Two schemas legitimately declaring one role name -with different targets **cannot be expressed in Rust at all**. Low-medium. - -### PLAUSIBLE, low. A `+` prefix in a cursor length field - -parses in Rust (`str::parse::`) and is refused in C# -(`NumberStyles.None`). Gated behind the HMAC, so unreachable without forging -it. Read from source, not probed. - -### Promises that held - -**R-AF's wire fact is confirmed, and harder than the probe claimed.** It is -not one serialization — **the type has nowhere to put a schema id.** -`CultRecordRef` has exactly one field, `ICultRecordRef` exposes only `Key`, -the formatter writes only the key, and all three declared reference shapes -yield `CultRecordKey`. A document carrying scalar, many-list and -many-dictionary references at once encodes with no schema id anywhere. **No -other formatter, version or nesting can introduce one without changing the -type.** C#'s rule was right, Rust adopting it is correct, and it is not wrong -in the other direction. - -**Both runtimes now agree at the evaluator on every shape the previous verdict -split them on** — seven matched probes built independently in each runtime, -identical answers, including the shared-key matrix in either row order. **The -role-filter reordering, which no ruling covered and only Hands had checked, -agrees with C#.** - -**R-AG is behaviourally pinned**: moving the cast inside the parens — still -wrapping, still looking like a fix — kills a test. Dropping the redundant -`length < 0` survives and is genuinely equivalent. - -### R-AH: right scope, under-specified, still unbuilt - -**Comparing the payload rather than the envelope is the right call** — the C# -message carries a non-deterministic `messageId` and three shard fields Rust -has no concept of, while the shared six are in the same declaration order on -both sides with camelCase keys already. - -**But "the canonical MessagePack bytes" is not a specification.** The same -page encodes as 285 bytes compact and 402 named, and **the compact form emits -a 4-element array for a 6-field struct** because `skip_serializing_if` drops -absent optionals positionally — it is not decodable. The ruling must also fix -map encoding with camelCase keys, declared field order, and whether an absent -optional is **omitted** (Rust today) or **nil** (C# today). Those differ right -now, and the same rule has to reach `Edge`, `RawDocumentHeader` and -`SelectionDocumentRecord`. - -**The structural reason it keeps slipping: C# has no page type at the -evaluator layer.** `Select` returns rows, and `Projection` appears once in the -evaluator, inside the cursor digest. Either `Select` gains projection, or the -harness builds the page outside it and the vectors start testing -`CultNetDocumentRegistry` too. **Nobody has chosen, and my ruling did not.** - -At `fc51e9a`: `pageBytes|payloadBytes|canonicalBytes` is **0 hits** in both -vector files, `rs-written.json` still carries no projection vector, and door -refusals still compare a field and never a code. - -**Can parity be claimed without it? No — not byte parity.** What exists is -semantic parity over an agreed field subset. **Even the selection bytes differ -between the two written files for the same vector** — C# writes nine fields -with nils, Rust omits absent ones — so there is no byte-level agreement -anywhere in this cut. - -### What Soul could not run - -No Stryker run; the 47 survivors stay untriaged, and **two of Soul's own -confirmed survivors are on lines batch 5 changed**, so that list is not empty -of real signal. The `--since`/`GitInfoProvider` crash is still not -root-caused. `contracts.rs` and `schema_discovery.rs` unmeasured. The R-AH -harness unbuilt, pending the shape decision. Caching's three failures still -unproven. **One run was lost to CRLF and still exited 0** — fixed in the -stopgap at Eureka `b12016a`, with a verdict sentinel so a job that never ran -cannot report success. - -## Self's rulings for fix batch 6, 2026-09-23 - -- **R-AL (SM-6). Restore the guard, and fix the owner.** The guard is not - duplicate authority — filtering members by kind is the evaluator's own job, - and I was wrong to call it a duplicate. Restore it, delete the false comment, - and add the probed shape as a test that fails without it. **Separately, D10 - is the owner of role-namespace uniqueness and currently admits the - collision**: make registration refuse a data member whose name collides with - a reference member's alias. Both, with tests. **Standing: a "redundant" - deletion must be probed at the shape that would break it, not argued from a - property nobody checked.** This is the second time a redundancy ruling of - mine was wrong; the first was caught by Hands, this one was not. -- **R-AM. The snapshot handler answers like its siblings** — catch - `Exception`, return a `CultNetErrorMessage`. **The dispatch backstop logs**, - always. A backstop that swallows silently is a compensator, and this one hid - a high-severity regression for a whole batch. -- **R-AN. Finish R-AJ in Rust.** Its edge test pins one component of a - four-component rule. Every component of both orderings dies under its own - mutation, in both runtimes. -- **R-AO. Pin shared-key resolution order** — two **in-target** rows sharing a - key — in both runtimes and in a vector. "The first row in the caller's order - wins" is currently a coincidence of source, not a rule. -- **R-AP (R-AH). Decide the shape, then build it.** The payload, as a - **map with camelCase keys**, fields in declared order, and **absent - optionals written as nil** rather than omitted — C#'s current behaviour, - because a decodable fixed-shape encoding is worth more than brevity, and - because omission is what makes the compact form undecodable. The same rule - reaches `Edge`, `RawDocumentHeader` and `SelectionDocumentRecord`. - **`Select` gains projection**, so the thing the vectors test is the thing - that decides; the harness must not assemble a page the evaluator never - produces. -- **R-AQ. Until R-AP lands, this cut claims semantic parity over a named - field subset, not byte parity** — and the map says so in those words. - Soul is right that byte parity cannot be claimed today, and it is better to - name the smaller claim than to let the larger one stand unearned. - **Flagged for the operator**: wire parity is this campaign's stated - invariant, so if semantic parity is not enough for Cut 1 to merge, R-AP - becomes a blocker rather than a follow-up. - -### Fix batch 6 landed, 2026-09-23, verified locally and not on Yggdrasil - -Sonnet, six commits on `sel-fix6` (pushed by Self after review). C# Networking -**279 passed / 2 skipped** (was 274), Mesh 255, Caching 193 unchanged. Rust -**259 across 12 targets** (was 254/11). +650 / −47 across 13 files, no new -targets, packages or dependencies. - -**The verification gap comes first, because it is Self's.** The brief said -"use `ygg-verify.sh`" without its path, where every earlier brief gave the -full path. Hands searched, could not find it, and **verified the whole batch -locally on the workstation** — the exact work the load budget forbids there. -It reported the gap plainly rather than claiming the bar was met, and **left -the branch unpushed on purpose** so the work would not look merge-ready. Both -were the right calls. Recorded as a scar at Eureka `301df32`; **this batch -still owes its Yggdrasil run**, and Soul's pass will provide it. - -- **R-AL.** The guard is restored and the false comment deleted. **The real - fix went to the owner**: D10b in `CultCache.DiscoverMembers` now groups - **every** member by its reference-role namespace (`IndexAlias ?? MemberName`), - not only aliased ones, and refuses registration when a data member's bare - name collides with a reference member's alias. Registration of the probed - shape now throws. Since D10b closes the only production door, the guard - itself is pinned by a test that **builds the colliding descriptor through - reflection to bypass the registry deliberately** — and removing the guard - makes it yield both members and fail. -- **R-AM.** `HandleSnapshotRequestV1Async` now catches `Exception` and answers - a `CultNetErrorMessage`, like its two siblings. The dispatch backstop logs, - always. **Writing the test found a second defect**: the backstop logged - `DynamicInvoke`'s `TargetInvocationException` wrapper — "Exception has been - thrown by the target of an invocation" — rather than the real fault, so it - now unwraps. The first run failed on the wrapper text, which is precisely - the bug that half of R-AM exists to fix. -- **R-AN.** Two isolating Rust tests added; the previous one tied `From` and - `To` across both edges, so dropping `role` survived. - **The `To.SchemaId`/`To.Key` equivalence argument recorded here was FALSE, - and is deleted rather than amended.** It claimed that within a page-position - bucket no construction gives two edges with tied `From` and `Role` and - differing `To`. Soul built the counterexample and ran it in both runtimes: - **a selection carrying both hops mixes their edges into one bucket**, so a - row that self-references through the same role it uses to cite a peer yields - a `cites` edge (`to` = the queried peer) and a `cited` edge (`to` = itself), - tied on `From` and `Role`, differing on `To`. A self-referencing role is a - parent or peer link — ordinary, not exotic. **This is the second - justification-from-an-unchecked-property in three batches**, and R-AL's - standing rule applies to it. - -- **R-AO.** Shared-key order pinned in both runtimes, both row orders, plus a - vector case regenerated into both written files. -- **R-AP, half built and half stopped, correctly.** The encoding is decided - and **C# already did it** — `[MessagePackObject]`/`[Key("name")]` writes a - camelCase map with nil for absent optionals by default. The gap was entirely - Rust-side: `skip_serializing_if = "Option::is_none"` on four types omitted - keys under `to_vec_named`. Removed from all four, `#[serde(default)]` kept - for decode. **Byte-identical now, against real C# MessagePack 3.1.7 hex**: - `RawDocumentHeader` and `Edge`, each broken once by hand to confirm the - assertions are not vacuous. **The byte counts recorded here were wrong** — - 86 and 99 — and are corrected to **228 and 246**, measured on Yggdrasil - against MessagePack C# 3.1.7. The committed hex constants matched the real - bytes exactly all along; only this prose was wrong. - - **"`Select` gains projection" was not built**, and Hands stopped and said - why rather than reporting the ruling closed. Header and document projection - is owned by `CultNetDocumentRegistry.SelectPage`/`SelectAll`, a different - class from the evaluator, which knows only generic rows and descriptors and - has no legitimate route to a schema's wire-binding override. Moving that - ownership is buildable — thread a caller-supplied serializer, as - `ordinalOf`/`shardIdOf` already are — but changes both signatures, every - caller, and the vector harness itself. - -**R-AQ, restated honestly.** The claim has moved from "semantic parity, byte -parity absent" to **"nested wire-type byte parity confirmed and vector-tested; -whole-message byte parity still blocked on unbuilt page-assembly ownership."** -No vector yet exercises the real message output byte for byte. - -### Self's rulings - -- **R-AR. The page-assembly ownership question is its own cut, not a - follow-up.** It changes two public signatures, every caller and the harness, - which is a cut's worth of work and exactly the kind of thing that has - slipped five passes by being carried as a loose end. **Cut 1 does not wait - for it.** -- **R-AS. Cut 1's honest claim is nested wire-type byte parity plus semantic - parity over the named field subset.** The map says that in those words, and - the target document is reconciled to it. **Flagged for the operator:** if - whole-message byte parity is required before this cut merges, R-AR becomes a - blocker and Cut 1 stays open; if it can be its own cut, Cut 1 can close on - the claim above once Soul clears it. - -## Soul, the merge gate, third pass, 2026-09-23 - -Opus. **Every run went to Yggdrasil**, supplying the run batch 6 owed. -Reproduced: C# Networking 279 / 2 skipped, Mesh 255, Rust 259 across 12 -binaries. **Caching is 190 passed / 3 failed** — the three assert a write is -*refused*, which root in a container cannot produce. **Unproven, not -passing**, and Soul declined to call them environmental on its own authority. - -**Verdict: Cut 1 may not merge.** - -### SM-7, CONFIRMED, high. R-AN did not land, and its justification is false. - -Three named survivors are still alive: - -| mutation | Rust | C# | -|---|---|---| -| drop both `to.schemaId` and `to.recordKey` from the edge comparator | **survives** | **survives** | -| drop `recordKey` from the **row** comparator | **survives** | killed | - -The row survivor is the fourth line of SM-4's own table from the previous -gate, and **batch 6 added no Rust row-order test at all**. - -**Soul built the counterexample and ran it in both runtimes.** The false -argument reasoned about each hop separately; a selection carrying **both** -hops mixes their edges into one `Vec`. A row that self-references through the -same role it uses to cite a peer produces a `cites` edge (`to` = the queried -peer) and a `cited` edge (`to` = itself) in the **same page-position bucket**, -tied on `From` and `Role`, differing on `To`. Rust's fixture `peer` role and a -C# `[CultReference(typeof(Self), many: true)]` both express it. Reversing the -`to.recordKey` comparison is killed **only** by Soul's probe, so the branch is -live and decides real output. **A self-referencing role is a parent or peer -link — ordinary.** - -Both runtimes agree today only because the comparator text is duplicated — -the "coincidence of source, not a rule" that SM-4 raised and R-AN was written -to close. - -### SM-8, CONFIRMED, medium. The cut's parity claim has no home. - -Section 9 says the claim is written into `docs/runtime-parity-scope.md`, "not -here alone". **That file contains zero mentions of typed selection**, and -never did — not even the earlier overstated wording. R-AS said the target -document "is reconciled to it". It is not. - -### SM-9, CONFIRMED, low. The map's byte counts are wrong; the constants are right. - -Serialized on Yggdrasil against MessagePack C# 3.1.7: `CultNetRawDocumentHeader` -is **228 bytes**, `CultNetEdge` is **246 bytes**. The committed hex in -`selection_wire_parity.rs` matches **exactly**. The landing note recorded 86 -and 99. **The thing Self asked Soul to distrust was sound; the prose beside it -was not.** - -### Promises that held - -**R-AL is complete, including inheritance.** Seven shapes built through -`Reflection.Emit` and pushed at the real registry, all refused: data name -against reference alias, reference name against reference alias, alias against -alias, data *alias* against reference *name*, implicit many-reference through -`List>`, and **across inheritance**, where the message names -both declaring types. The one shape that still registers is two *data* members -colliding with no reference present — **not a hole**, because the index -namespace is looked up by exact `IndexAlias` and never by the name fallback; -only the reference namespace uses `IndexAlias ?? MemberName`. -`PersistedMember.IsReferenceCandidate` is a character-exact mirror of -`FromMember`'s `isReference`, so D10b cannot disagree with the descriptor it -guards. Narrowing D10b dies; weakening the restored guard dies. - -**R-AM reaches the wire, not just the log.** Real loopback UDP through -LiteNetLib with the production transport: the null-`Selection` fault arrives at -the client and decodes as `CultNetErrorMessage` with the real message. -Mutating the handler to log but answer nothing dies. - -**R-AO's vector genuinely discriminates.** Under last-wins the resolved schema -stops matching the citation's declared target and the page empties, so the -vector has real power rather than merely existing. - -**R-AP's bytes are right, and more of them than claimed.** -`SelectionDocumentRecord` is byte-identical at 269 bytes, and — the one that -matters — **the whole `cultnet.snapshot_response_raw.v1` envelope is -byte-identical at 376 bytes**, Rust's encoder against C#'s message. Nothing -broke on decode. - -### Observations, not defects - -`SelectionPage` has **no C# counterpart to be byte-identical to**; byte parity -is undefined for it. The new generic catch sends raw .NET exception text to an -unauthenticated peer — **exactly what R-AM ordered, and what the siblings do**, -so consistent rather than wrong, but worth its own ruling one day. D10b is -stricter than the restored guard needs: a data member aliased `Owner` beside a -reference member named `Owner` used to register and worked, and is now -refused — defensible, but a breaking registration change with no note. - -### Soul on the wording, and Self's correction - -Soul agrees **R-AR is its own cut**. It does not agree with how I described -the residual gap, and it is right on both counts: - -- **"Nested wire-type byte parity" overstates it.** The branch proves two - types, each at exactly one value with **every optional absent**. Nothing in - the batch touches a header with `tags` populated or an edge with a - `payload` — precisely where `string[]` versus `Vec` and `byte[]` - versus `serde_bytes` could diverge. The correct words are **"byte parity for - `RawDocumentHeader` and `Edge` at an all-optionals-absent value"**. -- **"Blocked on unbuilt page-assembly ownership" is the wrong word, and the - expensive one.** It ran two independent things together: the two *encoders* - producing identical bytes for the same page value, and the two *evaluators* - producing the same page value from the same rows. The second is what the - vectors already compare. **The first needs no ownership move at all — Soul - wrote it this afternoon and it passes at 376 bytes.** What R-AR buys is a - single test driving rows to bytes in one call rather than two halves meeting - on paper. **Calling it blocked made the cheapest available evidence look - expensive, which is how it slipped six passes while sitting there for the - taking.** - -### The rig - -`C:\Users\Meta\eureka-soul-probes\cultnet-selection-cut1-fix6\`, beside batch -5's: three C# probe classes, a Rust wire probe, the counterexample patch, -three mutation drivers, seven precomputed C# mutants, and a README carrying -the full mutation table and the two `ygg-verify.sh` rakes (now in the -script's own header, Eureka `db1c84d`). - -### What Soul could not run - -No Stryker; the C# survivor list stays untriaged. No cargo-mutants sweep — -thirteen hand-built non-revert mutations instead, all at `-j1`. -`contracts.rs` and `schema_discovery.rs` unmeasured, with batch 5's partial -`validate_*` signal still hanging. The `--since`/`GitInfoProvider` crash still -not root-caused. **Soul proved the `to` comparator branch is reachable; it did -not prove the two runtimes would disagree on it, only that nothing stops -them.** - -## Self's rulings for fix batch 7, 2026-09-23 - -- **R-AT (SM-7). Every component of both orderings dies under its own - mutation, in both runtimes** — including `to.schemaId` and `to.recordKey`, - which now have **a known construction to test against**, and Rust's row - comparator `record_key`, which SM-4 named a pass ago and batch 6 never - touched. Take Soul's counterexample from the rig rather than rebuilding it. -- **R-AU. The false equivalence argument is deleted from the map**, done - above, not amended. Standing rule reaffirmed: **an argument that a branch is - unreachable is a claim to falsify, not a reason to skip a test.** -- **R-AV (SM-8). `docs/runtime-parity-scope.md` carries the typed-selection - row**, in the corrected words. A claim whose named home does not mention it - is not recorded. -- **R-AW (SM-9). Correct the byte counts to 228 and 246.** -- **R-AX. Land the whole-message parity vector.** Soul already has it green at - 376 bytes. **This is not blocked and never was** — my wording made it look - so. Land it as a vector on both sides, and add a header with `tags` and an - edge with a `payload`, since those are the shapes where the collection and - byte-array mappings could diverge and the all-absent value proves nothing - about them. -- **R-AY. Cut 1's claim, in these words**: byte parity for the - `snapshot_response_raw.v1` envelope and its nested record types, verified at - populated and absent optional values, plus semantic parity over the named - field subset. **R-AR remains its own cut** and buys a single rows-to-bytes - path, not the claim itself. -- **D10b's strictness gets a note** in the registration error and the map: a - shape that used to register and work is now refused. - -### Fix batch 7 landed, 2026-09-23 - -Sonnet, seven commits on `sel-fix7`, **all verified on Yggdrasil**, one slot -at a time across thirteen sequential jobs with no concurrent verdicts. C# -Networking **280 passed** (was 279 / 2 skipped), Mesh 255 unchanged, Rust -**264 across 12 binaries** (was 259). Caching stays 190 / 3, the three still -unprovable under a root container and deliberately not "fixed". - -**No production logic changed** except one error message and its comment. -Everything else is tests and docs. - -- **R-AT.** All three surviving comparator components now die, in both - runtimes, at `-j1`: dropping both `to` components, reversing - `to.record_key`, and dropping `record_key` from Rust's row comparator. - - **And Hands found that Soul's own construction did not actually kill the - "drop both" mutant.** Taken verbatim from the rig, it survives in *both* - runtimes — not because the branch is unreachable, but because `select`'s - push order happens to match alphabetical sort for that naming, and **the two - runtimes push in opposite orders** (Rust emits `cited` before `cites`, C# the - reverse). Rust needed the self-citer's key to sort *after* the target's, - C# needed the reverse. **A third fixture passing by coincidence**, found - while executing rather than by a later pass. Each runtime now carries its - own naming with the reasoning written into the test. -- **R-AV.** `docs/runtime-parity-scope.md` gains the typed-selection row in - R-AY's words, naming the four files that carry the byte and semantic - vectors and calling out R-AR as separate and still open. **The claim now has - the home the map said it had.** -- **R-AW.** Verified, not assumed: the committed hex constants are **228 and - 246 bytes**, matching a real MessagePack C# 3.1.7 run. The map's prose is - corrected above; the constants were right all along. -- **R-AX. The whole-message vector landed, byte-identical at 376 bytes**, and - the thin evidence is no longer thin: - - `RawDocumentHeader` with `tags = ["alpha","beta"]`: **239 bytes**, - identical — `string[]` and `Vec` agree. - - `Edge` with `payload = [1,2,3]` and `payload_encoding = "messagepack"`: - **261 bytes**, identical — `byte[]` and `serde_bytes` agree. - - **No divergence.** That was a real risk named in the ruling and it did not - materialise. -- **D10b's breaking change is noted** in the error message and its owning - comment: a data member aliased `Owner` beside a reference member named - `Owner` used to register silently and fault at resolution; it is now refused - at the door with no compatibility path. - -**Every condition Soul set for merging is now met.** A final gate pass -follows. - -## Soul, the merge gate, fourth pass, 2026-09-23 - -Opus. Four sequential Yggdrasil jobs, one slot, Rust at `-j1`. Merge to -`origin/main` is conflict-free; main's 42 divergent commits touch no file this -cut touches. - -### **Verdict: Cut 1 may merge.** - -**Baselines, with one correction.** Rust 264 across 12 binaries, Mesh 255, -Caching 190 / 3 — all as reported. **C# Networking is 283 passed / 2 skipped, -not the 280 reported.** Under-reported this time rather than over; the count -still went into the record wrong. - -### The five conditions - -1. **Met for everything that decides output, not met on the letter.** Killed - in both runtimes: dropping both `to` components, dropping `to.record_key` - alone, reversing it, dropping `record_key` from the row comparator, plus - `from.record_key` and `role` in Rust. **The batch's new fixtures are the - killers and they are not coincidental** — Soul attacked them with - single-component variants and they held. - - **But `to.schemaId` survives both dropping and reversing, in both - runtimes.** Hands never claimed it dies alone; **R-AT did, and R-AT was - mine.** Soul could not construct a selection where it decides anything — - under D10b a role resolves to one declared target type and reference - resolution yields at most one row per (role, key) — but says plainly that - is a claim, not a proof, **and the same shape of argument that has been - wrong twice here.** Hence the follow-up is "construct a killer **or delete - the component**", not "record it as equivalent". -2. **Partially met, and the miss is mine.** The false argument is gone where - batch 6 restated it and **still stands, unstruck, at its original site** — - the `EdgesFor` paragraph and ruling **R-AC** ("Recorded, not to be chased"). - Those read as live instructions. I deleted the copy and left the original, - which is the same sweep failure this map has recorded before. -3. **Met.** `runtime-parity-scope.md` carries the row in R-AY's words, naming - four files that all exist. -4. **Met**, and the constants were right all along. -5. **Met, and genuinely two-sided.** The three constants are byte-identical - strings in both files; each runtime serializes and asserts independently, - so **neither reads the other's answer**. All three C# tests pass and **all - three fail when Soul flipped one hex digit** of the expected constant. 239, - 261 and 376 are real MessagePack C# 3.1.7 output. - -### SM-10, CONFIRMED. The 246-byte all-absent `Edge` vector is Rust-only. - -The 228-byte all-absent header is nested inside the 376-byte envelope, so C# -regenerates it. **The edge has no such cover.** A C# edge encoder that resumed -omitting a null `payload`/`payloadEncoding` would still pass the 261-byte -populated vector, and **nothing on the C# side would fail** — which is exactly -what R-AP existed to kill. It leaves `runtime-parity-scope.md`'s "verified at -populated and absent optional values" true for three cells of four. - -**Five lines of C# closes it.** - -### Self's decision: close four items, then merge - -Soul named this the follow-up it "would put a name on". A known hole that a -five-line test closes is not a follow-up — merging over it would be shipping -the exact asymmetry the cut exists to prevent, with a note promising to come -back. **Batch 8 closes items 1 to 4, then the cut merges.** - -- **R-AZ (SM-10).** Mirror the 246-byte all-absent `Edge` constant into - `SelectionWireParityTests.cs`, so both runtimes assert all four cells. -- **R-BA.** Settle `to.schemaId`: **construct a killer, or delete the - component from both comparators.** A component no input can distinguish is - not free — it is a line the next reader must reason about, and the reasoning - has been wrong twice. -- **R-BB.** Correct the landing note to 283 passed / 2 skipped. -- **R-BC.** Strike R-AC and the `EdgesFor` equivalence paragraph **at their - original site**, not with a note beside them. - -**Not blocking, recorded as genuine follow-ups**, none a known defect in the -cut's behaviour and all outside the selection surface: the C# Stryker survivor -list untriaged; `contracts.rs` and `schema_discovery.rs` unmeasured with batch -5's partial `validate_*` signal hanging; the `--since`/`GitInfoProvider` crash -unrooted; Caching's three, which **need a non-root container to prove and must -not be "fixed"**. - -Rig: `C:\Users\Meta\eureka-soul-probes\cultnet-selection-cut1-fix7\`. - -### Fix batch 8 landed, 2026-09-23 — the pre-merge batch - -Sonnet, two commits on `sel-fix8` (`cda28fa`, `492dd0e`), verified on -Yggdrasil at `-j1`. C# Networking **284 passed / 2 skipped** (283 baseline -plus the one new test), Rust **264 across 12 binaries**, unchanged — the -deletion is behaviour-neutral. - -- **R-AZ.** The 246-byte all-absent `Edge` vector is mirrored into - `SelectionWireParityTests.cs`, so both runtimes now assert all four cells. - **Proven non-vacuous**: flipping byte 0 of the constant fails exactly that - test and nothing else, on a throwaway commit that was never pushed. -- **R-BA. Deleted, not constructed — and the argument is stronger than the one - the ruling carried.** Hands traced both resolvers: each resolves a reference - purely from `(citer's schema, role, recordKey)` against the evaluation's own - fixed candidate index, with no edge- or caller-specific input steering which - candidate wins — Rust's `target_leaves(role)` does not even take a schema. - So once `From`, `Role` and `To.RecordKey` tie in the comparator, **the - resolved row including its schema is forced identical by construction**. - - That does not depend on schema-authoring discipline the way my D10b argument - did; it depends only on the resolution function being a pure function of - already-tied inputs. **It is a structural proof rather than a semantic - claim**, which is the distinction that has bitten this cut twice. Hands - checked it against the live counterexample too — the self-citing row breaks - `to.record_key`, not `to.schema_id`. - - The tiebreak is gone from both comparators, with its stale documentation in - a third file. No test relied on it. - -**All four of Soul's pre-merge items are closed**, three by this batch and -R-BC by Self, which struck the false equivalence argument at both original -sites rather than annotating it. diff --git a/docs/cultnet-transport-parity.md b/docs/cultnet-transport-parity.md index 17fc6964..d0779196 100644 --- a/docs/cultnet-transport-parity.md +++ b/docs/cultnet-transport-parity.md @@ -271,15 +271,6 @@ Current progress: flush where the runtime supports one, so callers that require confirmed transport delivery do not substitute a fixed sleep. TCP-framed profiles do not publish the field because they do not own the RUDP pending-reliable queue. -- The receive window is a contract, not a discovery. A receiver must hold 1,023 - sequences and 4 MiB of payload beyond its contiguous received watermark, and - a conforming sender never exceeds either. The sender's flow window enforces - it without a wire field: a reliable packet is admitted only while its - sequence is at most 1,023 above the lowest unacked sequence and the payload - above that sequence stays within 4 MiB. The first packet is always - admissible, so a payload larger than 4 MiB goes out alone, and packets wait - in the FIFO in order, so a small packet never overtakes a large one. C#, - Rust, TypeScript, and Python enforce it; Kotlin does not yet. - TypeScript, C#, Rust, Python, and Kotlin now share a portable `cultnet.reconnect_policy.v0` document and deterministic exponential delay helper, and RUDP transport profiles advertise that policy under diff --git a/docs/document-variants-cut.md b/docs/document-variants-cut.md deleted file mode 100644 index ab0238e5..00000000 --- a/docs/document-variants-cut.md +++ /dev/null @@ -1,1487 +0,0 @@ -# CultCache document variants: cut map (draft) - -Date 2026-09-29. Imagination output for `docs/document-variants-target.md` (branch -`codex/document-variants`). Body read at `origin/main` `268e0ef`. This map owns means only; -the target owns ends and rulings 1-7. Nothing here is decided that the batch in section 4 -asks the operator to decide. - -## 1. Probe facts (run, not inferred) - -Probe: scratch clone `scratchpad/variant-probe` (commit `7b6de8e`, probe files only), run on -Yggdrasil via `ygg-verify.sh` with images `dotnet`, `rust`, `python:3.12-slim`, `node:22`. -Each runtime's current reader wrote a normal store, the bytes were altered four ways, and -the store was reopened. Output in `scratchpad/probe-out/*.txt`. - -| Altered store | C# | Python | TypeScript | Rust | -| --- | --- | --- | --- | --- | -| A. v1 header, record gains slot 4, payload empty | refuses, "read past end of stream" | refuses, "incomplete input" | refuses, "Offset outside DataView" | refuses (strict tuple), misleading legacy-envelope message | -| B. v1, slot 4 plus a full payload | **loads the payload silently** | **loads silently** | **loads silently** | refuses | -| C. header `cultcache.store.v2` | **ignores the header**; refused only by the empty payload | refuses, misleading "legacy envelopes" message | refuses | refuses | -| D. payload holds the delta as a sparse array | **loads `Name=''`, `Max=99`** | **loads `name=None`** | refuses | loads; `get` of that key fails | - -Consequences: -- The **empty payload is the only tripwire every shipped reader trips**, pinned builds - included (Aetheria pins `caching-unity-v1.4.0`). A variant record's payload must be empty, - and the delta must live outside it. -- A payload-as-delta encoding is ruled out: C# and Python misread it silently. -- C# never checks `formatVersion` (`CultDocumentMessagePackSerialization.DeserializeSnapshot` - defaults a missing one to v1). C#, Python and TypeScript skip extra record slots silently. - These are latent defects today and become misreads when the format grows. -- Every refusal is loud but none of them names the record. The target requires named refusals, - so current readers need a small fix (C0). - -Other Body facts that shape the map: -- **CultNet has no member-path grammar.** `docs/cultnet-selection-cut.md` D2: "Declared - aliases, not a field-path language". It reaches top-level declared `index`/`role` aliases - only (`CultDocumentMemberView`). Nothing exists to reuse. See section 3. -- **The schema catalog describes top-level members only.** A nested type (`BehaviorData`, - `PerformanceStat`, `HardpointData`) appears only as a CLR type name. Soft drift and hard - rejection cannot see below slot level. -- **Resolution needs a codec, and the core has none.** `GameCult.Caching` holds objects. The - MessagePack codec lives in `GameCult.Caching.MessagePack`. `CultInspectorModel` already - takes the codec as two injected functions (`CultCacheMessagePack.CreateInspectorModel`). -- **Same concrete type implies same home store.** `Home(type)` routes by type, so ruling 3 - ("same store") falls out of ruling 6. No separate check is needed. -- **The name index shadows silently.** `Index()` does `MapOf(_names, type)[name] = key`, so a - second record with the same name overwrites the entry. A variant that inherits its base's - name would make `GetByName` return one of the two, depending on apply order. -- **Studio edits by whole-document upsert.** `CultInspectorEdit.Commit` calls - `UpsertAsync(type, copy, key)`, and `Duplicate` clones through the codec. -- **Raw readers bypass the cache.** In CultLib: `CultMesh.ReadSingleFileDocument` - (`CultMeshSingleFileDocuments.cs:112`), plus its legacy snapshot decoder. In consumers: - AetheriaEve `AetheriaRuntimeCatalogStore` (directory-store pages). -- **Kotlin reads no store files.** It sees CultNet raw snapshots only. - -## 2. Model page (step 0b) - -| Kind | Named by | Over time | Decided by | -| --- | --- | --- | --- | -| Variant record | its own `CultRecordKey`, minted like any record; same `schemaId` as its type | created, re-overridden, rebased, removed; never converted to or from a plain record implicitly (Q1) | author through Studio or the variant write API; the cache validates | -| Base reference | the base's key, in the record's variant slot | changed only by an explicit rebase; a base cannot be deleted while it has variants, unless the same batch rebases or removes them | author; the cache refuses a cycle, a missing base, a different concrete type, a global type | -| Override entry | `(op, path, id, value)`; op is Set, Insert or Remove | added by editing; removed by clearing; survives base edits while its path resolves | author; the cache refuses entries a base edit strands (Q2); an entry whose member left the type soft-drifts with a warning (Q4 c) | -| Member path | a sequence of `(slot, elementId)` steps; `slot` is the MessagePack `[Key]`; `elementId` is `""` unless the step enters an object-list element | a type change can invalidate it | the type's owner (slot authority); ids by the element's creator | -| Element id | a `[CultElementId]` string member on an object-list element type; `""` means unset | minted by the cache on write when unset; copied unchanged into variants; a moved element is a new element | cache mints it; it is never retargeted | -| Resolved view | `CultStoredDocument.Document` for a variant key | recomputed inside the hold that admits the variant, or any base on its chain | the cache only; never persisted, never written back (Q1) | -| Index and name entries | as today, from the resolved view | a dependent's entries are dropped and re-added in the same `Apply` as its base change | the cache; a variant must override the `[CultName]` member (rule R6) | -| Watches | as today; each re-resolved dependent emits `Updated` with its own `Sequence` | published in the same hold as the base change | the cache | -| Compare-exchange | `(schemaId, storedAt)` of the stored delta (ruling 2) | a base change does not stamp its variants | the cache; the resolved view is not an identity | -| Persisted format version | store header `formatVersion` | `cultcache.store.v2` when the store holds at least one variant; `v1` otherwise (Q5) | the writing store, from content | -| Single-file store file | the path; one MessagePack array `[header, catalog, records]` | replaced whole and atomically; refused when unreadable; see "Store authorities" | each runtime's one reader decides what is a store; the writer derives the header from it | -| Store lock and staging files | `.lock`; a unique temp beside the store | the lock is taken by C# and Rust writers (CultMesh included, through `ReplaceDurable`); staging is removed on a failed write | the store, never CultMesh or a consumer | -| Variant slot on the wire (CultNet) | **empty cell**: no CultNet message carries a delta today | C5 | ruling 4 decides deltas; the message shape is C5's design | -| Dictionary entries, scalar lists, arrays | **empty cell**: no stable identity exists | whole-member Set only (Q7) | Q7 | -| Template (non-item) bases | **empty cell**: parked by ruling 6 | none | not in these cuts | - -## 3. Where the Body contradicts the target - -1. **"A member path in CultNet's grammar"** (ruling 1 and fork 1 text) has nothing to reuse. - CultNet selection deliberately has no path language. This map specifies a minimal slot - path (section 2) owned by `GameCult.Caching`. If CultNet ever needs paths, it can adopt - this one. Nothing is shared today, and nothing is invented twice. -2. **"Overrides are subject to the same soft drift rules as full records"** conflicts with - the ends list: "Loading refuses an override naming a member that does not exist on the - type". Under soft drift, a persisted slot missing locally is ignored with a warning, so - the two rules disagree for a dropped member. Below top level, the catalog has no shape to - drift against at all. See Q4. -3. **"Deletes first"** has little to delete: the feature is additive. The honest deletions - are the silent extra-slot skips and C#'s ignored header. C0 puts them first. - -## 4. Operator questions (one batch) - -**Operator rulings, 2026-09-29, each asked on its own:** - -- **Q1: (a)**, a plain `Upsert` at a variant's key is refused loudly. -- **Q2: (a)**, a base edit removing an overridden element is refused unless the same batch - resolves it. Operator's reading: "the very existence of that element in the child collection - must become the new override state... you can't change the parent without also changing the - child... that's the resolve part of (a)." -- **Q3: ids everywhere, not opt-in.** Operator: "Opt-in sounds nice but consider the UX. We're - planting a footgun if we don't require ids everywhere." Rollout: **required, minted on load**. - The C# registry requires an id member on object-list element types. A store written before ids - existed loads, and ids are minted once on its first write (C2's rewrite). Other runtimes carry - the id as an ordinary member and enforce the rule when they gain variants. Each consumer's type - edit is a sweep in its own repo after C2. -- **Q4: (c) soft drift everywhere. This reverses the recommendation and supersedes the target's - end "loading refuses ... an override naming a member that does not exist on the type".** - Operator: "Soft drift everywhere aligns with the vision... the rationale for adopting - migrationless changes is still valid for variants. Any member dropped in a type change is a - design change, the reason for it to apply to the parent also applies to the variant." A - dangling override, at any depth, is ignored with a warning naming the variant and the member, - and the variant inherits the base value. The other broken-variant refusals (a base cycle, a - missing base, an incompatible base type) stand. -- **Q5: (a)**, the v2 header is written only when the store holds a variant. -- **Q6: yes**, the directory store and CultNet refuse variants loudly until their own cuts. -- **Q7: yes**, object-list elements are addressable by id, and dictionaries, scalar lists and - arrays are replaced whole. The operator asked first whether design roles and quality levels - use dictionaries. They do not: `CraftedItemData.Roles` is a `List` and - `FactionProduct.Roles` is a `List` (Aetheria `ItemData.cs:316`, - `FactionProduct.cs:30`). A market-segment product becomes a variant overriding one - `ProductRole` by id. - -*The questions as asked:* - -**Q1. A plain `Upsert` of a whole document at a variant's key.** It happens when Studio's -current edit commits, when AetherDb migrations do `batch.Upsert(type, doc, key)`, and on a -CultNet remote write. -- (a) Refuse it loudly. A variant changes only through the variant API. Flattening is an - explicit, separate operation. -- (b) Diff the document against the base and store the difference. Ids make the diff - deterministic, but a value set equal to the base stops being an override without anyone - saying so. -- (c) Flatten silently (today's behaviour by default). -- **Recommend (a).** Affects C1's write path, C3's edit commit, and every AetherDb migration - (each skips variants or uses the variant API). - -**Q2. A base edit that removes an element some variant overrides.** -- (a) Refuse the commit unless the same batch clears or retargets those overrides. Studio - offers keep, retarget or clear at edit time, and "keep" means the base edit is not - committed. The store never holds a conflict, and loading refuses one. -- (b) Persist the conflict. The override goes inert, readers get the resolved document - without it, and Studio lists it. -- **Recommend (a).** Option (b) makes a reader's resolved document silently differ from what - the author wrote. Affects C2's validation, C3's rebase UI, and migrations that remove - behaviours. - -**Q3. Scope of "ids everywhere".** -- (a) Every object-list element in every registered document type, in all 28 consumers. The - registry refuses a type whose element types lack an id. -- (b) Only document types that opt in with `[CultVariants]`. For those, the registry requires - `[CultElementId]` on every object element type reachable through their lists, including - union bases. -- **Recommend (b).** Option (a) breaks 28 registries for a feature that one consumer uses. - Affects C2 and Aetheria's adoption cut. A `BehaviorData` id needs a base slot above the - subclasses' highest key (32), which adds about 30 nil bytes per behaviour unless Aetheria - renumbers. - -**Q4. Schema drift under overrides** (contradiction 2). -- (a) Refuse loading when an override names a member missing at any depth, or holds a value - that will not decode into the member's current type. Record this as a stated exception to - soft drift in `cultcache-schema-compatibility.md`. -- (b) Top-level overrides follow catalog soft drift (ignore with a warning); nested ones are - refused. -- **Recommend (a).** It follows the target's ends and is one rule. The cost: after a type - change drops an overridden member, the catalog must be rewritten before the new build opens - it. - -**Q5. Format version.** -- (a) Write `cultcache.store.v2` only when the store holds a variant. Stores without variants - stay byte-identical `v1` for every consumer. -- (b) Always write v2 after the upgrade. -- **Recommend (a).** The empty payload remains the tripwire for pinned old C#, which ignores - the header. Affects C0 and C1. - -**Q6. Slice scope.** Should the directory store and CultNet refuse variants loudly until -their own cuts? The directory store's only consumer is AetheriaEve's raw reader. CultNet -must carry deltas (ruling 4), and no message can yet. -- **Recommend yes.** It is two refusals. Otherwise C1 must design CultNet messages first. - Affects C1's size and the order of C5. - -**Q7. What is addressable below a member.** The proposal: object-list elements by id only. -Dictionary entries, scalar lists and arrays are replaced whole. -- **Recommend yes.** Aetheria's cases (`Hardpoints` whole; `Behaviors[id]...Max`) fit. Keyed - dictionary addressing can be added later without a format change. Affects C2. - -## 5. Cuts, in order - -All cuts are in `F:\Projects\CultLib`. Rebase `codex/document-variants` (docs only) onto -`origin/main`. Each cut is one Hands pass on that branch and merges to main after its Soul -pass. Probes show that a C1 writer can merge safely before other runtimes change, because -every reader refuses it. Verification uses `ygg-verify.sh /f/Projects/CultLib ''`. -The command strings below are the ``. Keep the job's exit status last. - -Overlap: BP-1 (`cultmesh/rust-content-plane`) edits `docs/runtime-parity-scope.md`, which -C0 also edits. Rebase after BP-1 merges. `codex/fix-node24-ajv-esm` has no diff against main. - -### C0. Tripwires: every reader refuses what C1 will write, and names the record - -Deletes: -- The silent extra-slot skip in the C# record decoder - (`CultDocumentMessagePackSerialization.ReadPersistedRecord`'s trailing `Skip` loop) and - its copy in `CultMeshSingleFileDocuments.ReadLegacyPersistedRecord`. -- The `?? "cultcache.store.v1"` defaulting of the header. -- Python `raw_record[:4]` slicing. -- The TypeScript and Python fallthrough to the legacy envelope decoder when the header is a - `cultcache.store.*` string they do not know. - -Adds, one rule in each runtime: a snapshot whose header is not `v1`, or whose record has more -than 4 slots, is refused with a message that names the version or the record key, and says -the store needs a runtime that resolves variants. C# accepts `v1` only, until C1 adds `v2`. - -Keeps: every v1 byte and every v1 test. - -Verification (rule: "unknown header or extra record slot is refused by name"). Each runtime -gets one test, and each test's negative is fixture B from section 1 (full payload plus slot -4) loading: -- `dotnet`: `dotnet test tests/GameCult.Caching.Tests --filter FullyQualifiedName~PreCut2StoreFormat` -- `node:22`: `npm install --no-audit --no-fund && cd packages/cultcache-ts && npm test` -- `python:3.12-slim`: `pip install -q msgpack -e packages/cultcache-py && python -m unittest discover packages/cultcache-py/tests` -- `rust`: `cd packages/cultcache-rs && cargo test` (message only; Rust already refuses) - -Subtraction: about −20 lines of skip and fallthrough; +4 small refusals and 4 tests. Build: -the 4 cache packages only. - -### C1. C# core: variant records, top-level Set overrides, resolution in the admitting hold - -Adds: -- **`CultPersistedRecord.Variant`**, record slot 4: `[baseKey, overrides[]]`. Payload slot 3 - is empty for a variant. An override is `[op, path[], id, value]`. - - Owner: `GameCult.Caching`. - - Consumer: both file stores and Studio. - - Invariant: an old reader refuses rather than misreads (section 1). - - Why no existing owner serves: the payload cannot hold the delta (probe D). -- **`CultStoredDocument.Variant`** (base key and overrides; null for plain records). - `Document` stays the resolved view. -- **A codec port on `CultCache`**: the `(serialize, deserialize)` pair `CultInspectorModel` - already takes, lifted. - - Owner: `GameCult.Caching.MessagePack`, supplied by `CultCacheMessagePack.Create`. - - Consumers: resolution and the inspector model. - - Invariant: one codec per cache; clones and override values use the store's encoding. - - `CultInspectorModel`'s constructor takes the port instead of its own pair, so there is one - pair, not two. - - A cache without a codec refuses variant writes. -- **Write API** on `CultCacheBatch`, with single-call equivalents: `UpsertVariant(key, baseKey, - overrides)`, `Flatten(key)` (Q1a), `Remove` unchanged. Rebase is `UpsertVariant` with a new - base. -- **`Validate` resolves** every admitted variant and every dependent of an admitted or - evicted base, in base-first order, against the post-batch set. It refuses, naming keys: - a cycle; a missing base; a different concrete type; a global type; an evicted base with - surviving variants; a variant whose resolved `[CultName]` equals its base's (R6); a plain - `Upsert` at a variant key (Q1a). **Not refused (Q4 c, operator 2026-09-29):** an override - naming a slot the type no longer has, or holding a value that no longer decodes into the - member's type, soft-drifts exactly as the same member would on a plain record under - `cultcache-schema-compatibility.md`. It is ignored with a warning naming the variant and - the member, and the variant inherits the base value. One rule, the existing soft-drift - path, never a variant-specific one. -- **`Apply` re-resolves dependents** in the same hold. Each emits `Updated` and is re-indexed. - A base change stamps no dependent `storedAt`. -- **Header**: the store writes `v2` iff it holds a variant (Q5a) and reads `v1` and `v2`. -- **Refusals** (Q6): `DirectoryMessagePackBackingStore` push and commit of a variant; - `CultNetDocumentRegistry` row building for a variant; `CultMesh.ReadSingleFileDocument` of - a variant key. -- **Contracts**: the variant record section in `cultcache-persistence-format.md`; one - sentence in `cultcache-schema-compatibility.md` saying overrides soft-drift like members - (Q4 c, no exception); a "variants: C# resolves; others refuse" row in - `runtime-parity-scope.md`. - -Authority map: -- Owner: `CultCache.Validate`/`Apply` owns the resolved view. -- Inputs: stored deltas, base records, the codec. -- Outputs: the resolved `Document`, index entries, changes. -- Demoted: the resolved `Document` is no longer a writable owner for a variant key (Q1a). - `storedAt` is the delta's identity only. -- Forbidden writers: store `Loaded` callbacks never resolve; Studio never writes a resolved - document to a variant key; CultNet never emits a variant row. -- Shared paths: a load (`Admit` with a source), a single write, a batch and a remove all pass - the same `Validate` and `Apply`. There is no second resolution path. - -Verification. New `VariantTests.cs`; each rule gets a positive and a named negative: -- a load with a variant resolves; -- a base edit updates the variant's `Get`, `GetByName` and `GetByIndex`, and `Watch` sees both - changes inside one publication, with no gap in `Sequence` between them. Negative: a - subscriber observing the base change must already read the new variant. -- `Expect` on the variant survives a base change; -- each refusal case, and the refusal message names both keys; -- the header is `v1` without variants and `v2` with them; -- a read-only store resolves; -- a variant round-trips byte-identically through flush. - -Cross-runtime vectors: the Caching interop peer gains `write-variant --file`. A test in -`packages/cultcache-ts/test/cult-cache.test.ts` asserts that TypeScript refuses that file by -name; Python and Rust tests read the same fixture from `contracts/cultcache/variant-store.cc`. - -Command, `dotnet`: -`dotnet test tests/GameCult.Caching.Tests && dotnet test tests/GameCult.Networking.Tests --filter FullyQualifiedName~Registry`, -then the C0 commands for `node:22`, `python` and `rust` against the new fixture. - -Subtraction: the inspector's own codec pair collapses into the port; otherwise net additive, -estimated +350 to 450 lines of core and +400 of tests. Build: the Caching and MessagePack -projects, Caching.Tests, the Networking test filter, the interop peer. - -**C1 status, 2026-09-29 (Self).** C1 landed on `hands/variants-c1` (`136adce`). Soul (Opus) found it -not closeable, and a fix batch is in Hands: -- **F1:** CultNet's live-change paths leak variants as plain records, which breaks Q6. -- **F3:** an undecodable override soft-drifted where a plain record refuses to load. -- **F4:** invalid overrides were accepted at write. -- **F2:** an inherited unique index value shadows the base, and the winner depends on order. - -**Self's readings and defaults, not new operator rulings:** -- **Q4 (c) read literally:** an override follows the plain-record outcome. A missing slot - soft-drifts; a value that no longer decodes refuses loudly, as a plain record does. -- **Invalid overrides are refused at write.** Drift covers type changes after the fact, not - bad writes. -- **F2 extends R6 to indexes.** A commit that leaves a variant sharing an indexed value - with another record is refused. -- **One override per slot.** - -**Open for the operator:** plain records with duplicate unique-index values are silently -overwritten today. That predates variants. Fixing it could refuse existing stores. - -**C2a status, 2026-09-30.** Hands pushed `hands/variants-c2a` at `640ad9a`. -- Element ids are 12 hex characters. Writes mint them at random. Load mints them deterministically. - Derived ids use `[CultElementId(nameof(Member))]`. -- The CDN chunk ref's id is its offset. The witness types carry ids, and the ids cross C#, TS, Python and - Rust. - -Soul held it. Fixes are in Hands: -- ids are never minted inside variant overrides; -- interface unions are never minted; -- a null derived source leaves an empty id; -- load minting is culture-dependent; -- the minted-on-load list goes stale; -- a refused batch leaves minted ids behind; -- the id format is unchecked; -- late union-slot reuse passes registration. - -**C2a rulings (operator, 2026-09-30):** -- **Old readers are tripwired.** A store that holds element ids carries a marker that every pre-C2a reader - refuses under C0's unknown-header rule. An old C# reader can therefore never silently strip nested ids. - MessagePack's generated formatters skip unknown slots inside elements. -- **Duplicate element ids refuse at load,** naming the record, the list and the id. This matches the - duplicate-index ruling. -- **C2b precondition (Soul F7).** Whether a pre-id element keeps its load-time id depends on the write path. - C2b must refuse an override that targets a record whose ids exist only in memory, or mint on open. - -**C2a Soul pass 2 (`e85b201b`), 2026-09-30: hold.** The tripwire only works against unreleased readers. -Every published release (`cultlib-unity-v1.0.60`, `caching-unity-v1.4.0`, `cultcache-ts-v0.14.0`, -`cultcache-py-v0.3.0`) predates C0. The 1.0.60 C# reader loads a v3 store, and its next write is v1 with the ids -stripped (probe). Other findings: -- F2: the same element object twice in one list commits, then the store refuses to load. -- F3: CultMesh single-file writes bypass the marker. -- F4: TS `pushAll` writes the header without reading it first. - -**C2a rulings, 2026-09-30 (operator):** -- **Rollout order closes the released-reader hole.** Ship a CultLib release that refuses v3, move every C# - reader of a store onto it, then let a C2a writer touch that store. There is no format change for this. - This supersedes the claim above that old readers are tripwired: that claim holds only for post-C0 readers. -- **Mark by content.** A store is written as v3 (v5 for directory stores) only when a record actually holds an - element id. An existing v3 header on disk stays. -- Fix batch 3 in Hands: F2, marking by content in every runtime, F3 routed through the cache's header - decision and load checks, F4. - -**C2a Soul pass 3 (`9ed61dd2`), 2026-09-30: fix first.** -- A flattened record's `HoldsIds` goes stale when its base changes in the same batch. -- A conditional commit onto disk ignores content. -- Rust `push_all` clobbers headers it cannot read. -- TS keeps a stale header after the file goes away. -- Self's claim that "rollout order makes the raw-writer hole benign" was wrong. The reader that strips ids - from a v1 store is a post-C0, pre-C2a build. That is exactly the reader the v3 marker targets, and rollout - order does not keep it away. - -**Ruling, 2026-09-30 (operator): C0 is released only together with C2a.** The first CultLib release that -refuses v3 also contains C2a, so no released reader strips ids. C0 and C1 are never released on their own. -Raw and cross-runtime writers that cannot see ids stay sticky-only. Fix batch 4 is in Hands. - -**C2a F2 ruled (operator, 2026-09-30, accepting Self's recommendation B): records nobody claims are carried -untouched.** A store may hold records under a schema id that no local type owns or lists as compatible, for -example after a rename that declared nothing. -- Both store kinds carry those records byte for byte under their own id. The catalog lists them as foreign - records. -- Writes to other records proceed. -- A write that would overwrite or relabel an unclaimed record is refused with a typed schema conflict. -- The single-file store's whole-view write stops relabelling such records onto local types. The directory - store stops refusing every commit while it holds one. -- Why: batches 8-9 showed that the danger is rewriting a record under a new identity (F1, F6), not an - undeclared old id. Batch 10's owner-beats-lister rule makes declaring an old id cheap anyway. -- Self's first lean, "refuse loudly" (A), is superseded. - -**C2a batches 9-10 (Soul pass on `fdb8a60a`, 2026-09-30): hold.** -- **F6, A-B-A lost update on the single-file store.** Ruled by Self: any write that changes a record's bytes or - schema id mints a later `storedAt`. -- **F8, batch 9 over-refused.** An owner beats a lister, so v1 and v2 coexist. -- **F9.** Compatible ids compare as a set. -- **F10.** Typed refusal errors in TS and Python. -- Batch 10 is in Hands. -- **F7 ruled (operator, 2026-09-30): retire `AsSchemaAlias`.** "Schema aliasing sounds like a really bad idea, I - support retiring it." - - C# refuses a second type for one schema, as TS, Python and Rust already do. There is one type per schema in - every runtime. - - The API, its registry path (`IsExactWireAlias`) and the tests that exercised it (7 Mesh, 2 Caching) are - deleted or rewritten. - - No consumer called it. - -**Operator rulings, 2026-09-30:** -- **Duplicate unique-index values do not load** ("Duplicate indices should not load"). This covers - plain records too, so R6-for-indexes becomes one general rule: - - a commit that would leave two records holding one indexed value is refused; - - a store holding duplicates refuses to load, and the refusal names both keys and the index. - - The variant-specific rule `RefuseVariantIndexSharing` collapses into this rule. - - Before it ships, every real store is scanned, so no store stops loading by surprise. - - **Scan result (Eyes, 2026-09-30):** `[CultIndex]` had been recycled as a grouping and - selection-filter declaration: `Category`, `Kind`, `HardpointType`, `ShardId`, and others in - CultMesh, Geometry and docs. AetheriaEve's `aetheria-world.cc` (taxidermy) is the only store - holding duplicates. The only single-result lookups in real code are unique: - `PlayerData.PlayerId` and `Email` in `Server.cs`. The operator: "Pretty sure indexes are - supposed to be unique, it was not my decision to recycle that mechanism for grouping - purposes" and "Grouping was a desirable feature from my old DatabaseListView that didn't - quite make it into the initial CultCache Studio port". - - **Resolution (Self, from those answers):** `[CultIndex]` means unique. Grouping belongs to - the Studio record-grouping campaign's own attribute (`docs/studio-grouping-cut.md` on - `codex/studio-grouping`, attribute-based per the 2026-09-17 ruling). CultNet selection - filters any declared member by its catalog name, so no index is needed for filtering. The - grouping-only `[CultIndex]` declarations are deleted. This is one CultLib cut, queued - behind C2a because both edit `CultCache.cs`. - - The TS/Python last-writer-wins parity gap closes by the same rule when those runtimes - adopt it. -- **CultNet invisibility is a defect** ("looks like a defect to me"): `cache.Commit` and - `cache.UpsertAsync` on a database's cache must publish to subscribers and to the mutation - log (`CultCache.Publish`'s `if (!loaded) continue;`). -- **Hop subscriptions keep refusing variants** until CultNet carries deltas (C5): "keep refusing, - I guess, CultNet will have deltas by the time we're done here anyway". - -### C2. C# element identity and nested paths (Set, Insert, Remove) - -Adds: -- **`[CultElementId]`** (a string member). **Ids everywhere, not opt-in (Q3, operator - 2026-09-29): there is no `[CultVariants]` attribute.** The C# registry requires an id member - on every object element type reachable through a list in any registered document type, - union bases included, and refuses a type that lacks one. -- **Minting**: on write, the cache mints ids for unset ids in every type, and refuses a - duplicate id within one list. A store written before ids existed loads, and its ids are - minted on its first write (minted on load, per the operator's rollout ruling). -- **Path steps below top level.** -- **Insert** anchored after an id, where `""` means the head. An inserted run sits - immediately after its anchor and before base elements added there later. -- **Remove** by id. -- **Canonical order**: removes, then inserts in list order, then sets by path. -- **Q2a refusal**: a base commit that orphans an override is refused. -- **Q7**: whole-member Set for dictionaries, scalar lists and arrays. -- **`CultCache.MintElementIds()`**: the one-shot rewrite for existing stores (ruling 1). It - upserts every record that has an unset id through the normal path. -- **The consumer sweep (Q3 rollout).** About 28 consumers carry list-element types, and each - needs an id member before it can take the CultLib that requires one. C2 ships the - requirement. Self schedules the per-repo sweep, one small type edit per consumer, before - those consumers bump. C2 lists the element types it finds per consumer, as data for that - sweep. - -Keeps: the C1 format unchanged. C2 fills path shapes that C1 refused. - -Verification: -- Two look-alike elements (two of one union subtype) get different overrides, and a base - insert before them retargets nothing. -- Rebase re-applies overrides by id. A missing id is refused, and the message names the - variant, path and id. -- A Set on a removed element is refused. -- Minting is idempotent. -- A registered type with an id-less list element type is refused, naming the type and member. -- A store written before ids loads, and its ids are minted exactly once on first write - (idempotent). -- A C#-written nested-override fixture joins `contracts/cultcache/`. - -Command: `dotnet test tests/GameCult.Caching.Tests`. - -Estimate +300 lines and +350 of tests. Build: as C1, without Networking. - -### C3. Studio: edit the delta - -Adds, in `CultInspectorModel` (engine-free; the lowering stays a renderer): -- For a variant edit, each member path is marked inherited or overridden. -- `Commit` writes `UpsertVariant` with overrides equal to the prior overrides plus a - structural diff by id. It is deterministic because ids exist. -- An explicit "override" pins a value equal to its base's. -- `ClearOverride(path)`. -- `CreateVariant(record)` next to `Duplicate`; it prompts for a name (R6). -- `Rebase(record, base)` returns a conflict list for Q2a before commit. - -Lowering, in `CultCacheStudioWindow`/`Drawers`: an overridden marker and a revert control per -member, a base link, and variant creation and rebase controls. - -Verification: -- `CultInspectorModelTests`: the diff produces exactly the touched paths; clear removes one - entry; the pin survives an equal value; rebase conflicts are listed. -- Negative: a Studio commit never calls a plain `Upsert` at a variant key. - -Only the operator can check these in Unity against a copy of `Aetheria.cc`: -- the markers read correctly; -- clearing reverts the value live; -- a hull variant replaces `Hardpoints`; -- a laser variant changes one behaviour's `PerformanceStat.Max`; -- a base edit shows in the open variant. - -Then tag `caching-unity-v1.5.0`. **This is the point where Aetheria is unblocked.** - -Estimate +250 model, +150 lowering, +250 tests. Build: Caching.Tests. The Unity package is -checked by the operator in the editor. - -### C4. Aetheria adoption (Aetheria repo, its own cut, after the release) - -- Bump the package to `v1.5.0`. -- Add `[CultElementId]` to every list-element type Aetheria's documents carry (ids everywhere, Q3). There is no per-type opt-in. -- Add `[CultElementId]` to `BehaviorData` (base) and `HardpointData`. -- Run `MintElementIds` once over `GameData/Aetheria.cc`. -- AetherDb migrations skip variants or use the variant API (Q1a). -- Re-author the families listed in section 6. - -### C5. CultNet deltas (C# reference) - -Adds a new raw-record message version that carries the variant slot, following selection D3: -a v1 message string, so peers not in this cut refuse through their own dispatch. The C1 -refusal in `CultNetDocumentRegistry` is deleted. Scheduled when a CultNet consumer needs -variants; none does today. - -### Parked: TypeScript, Python and Rust resolution - -Each runtime gets its own cut when a consumer that reads a variant-bearing store exists -(ruling 5). None does. `Aetheria.cc` is read by C# only. - -## 6. First payoff in `Aetheria.cc` - -Scan of the live file (206 records, `v1`): records of one schema whose leaves differ by at -most 20 percent, name excluded. This is a heuristic; the operator confirms the real families. - -| Type | Records | Families that collapse | Records becoming variants | -| --- | --- | --- | --- | -| geardata | 32 | Refinery / Assembly Line / Deep Ore / Surface Ore / Shipyard (1 to 3 leaves differ); Small / Medium / Large Drive; RevvITup 2.0 / deep space burnout / Talaria; Skiron / Iapyx; Arctica / cold like my heart | 10 | -| weaponitemdata | 18 | ChargeBlast SG / ChargeBlast+- (14 of 253 leaves differ); pswarm / scorched void policy; Earp / 6k Shooter; Spectra / ColdFire | 4 | -| hulldata | 5 | Longinus / LonginusX (only `Behaviors`, `Hardpoints` and two cosmetic members differ) | 1 | - -That is 15 of 55 equipment records. In most of these families the difference lies inside -`Behaviors`, so element-level overrides (C2) are what pay. Top-level overrides alone would -still copy each behaviour list. - -## 7. Consumers - -There are 28 projects: C# 13, Rust 9, TypeScript 10, Python 1, Kotlin 0 (Explore survey; -dependency-level for most, read in detail for Aetheria and AetheriaEve). -- **See variants:** Aetheria through C# `Get`, `GetByName` and `CultRecordRef` (resolved - documents only), CultCache Studio (deltas), and AetherDb tools (must honour Q1). -- **Must stay oblivious or refuse:** every other consumer. No other project reads - `Aetheria.cc`. Raw readers refuse through the empty payload plus C0/C1: `CultMesh` - single-file reads, AetheriaEve's directory-page reader (the directory store refuses - variants, Q6), and Mimir (writer only). - -## Schema identity across runtimes (Imagination, 2026-09-30) - -**RULINGS (operator, 2026-09-30).** -- **C1: agreed** ("Agreed on schema identity"). C# puts the declared version string on the wire as the schema id. - F-ID.1 follows Self's recommendation: the id is `.v`, not the bare schemaName. -- **F-ID.2: AetheriaEve is not a consumer.** Operator: "AetheriaEve is purely archaeological, I would recommend - archiving it purely as evidence of what happens when you try to build a game with hyperfocused agents and with - CultLib under construction. We might try again at some point, but it won't look anything like AetheriaEve." C1 - deletes the fallbacks that exist only for AetheriaEve's readers. It does not migrate those readers. -- **F-ID.3: stored C# hash ids.** Operator: "I have no idea". Self's default is to defer C2. C1 changes nothing on - disk. C# keeps reading its own `sha256` ids. F2 already makes other runtimes keep C# records byte-for-byte. C2 - gets mapped only when a cross-runtime store read of a C# store is actually needed. -- C1 is mapped (section "C1 cut: one schema id on the wire", below). **Operator, 2026-09-30: "Yes to both, defaults - are fine".** The per-binding wire-id override is deleted. A declared compatible id resolves on the wire, and the - owner beats a lister. All six defaults stand. Stonks is fixed in Stonks before C1 merges. Order: F2 Soul, then the - put-serve merge, then c2a merges main, then C1.0-C1.5. - -Probed at CultLib `hands/variants-c2a` 92d9e138. The probe ran on Yggdrasil in `ack1d-interop:2` from a scratch branch, which has since been deleted. Sources: `scratchpad/schema-identity-probe/`. Full output: `scratchpad/probe2.log` (store round trip, section 1), plus a wire rerun shown inline below. Every probe used one declared schema: the interop note, name `cultcache.interop-note`, version `cultcache.interop_note.v1`, with six members. - -### 1. How each runtime derives a schema id (probed) - -| Runtime | Id it stamps | Derived from | Carries name / version / content hash? | -|---|---|---|---| -| C# | `sha256:eafe3e…b249` | `sha256("name\|version\|slot:Member:ClrType:value/ref:target:one/many\|…")`. Recomputing it by hand gives the same id. | Store catalog: name, version, `contentHash = sha256(canonical JSON)`, canonical JSON, members. Wire: `schemaName`, `schemaVersion`, `schemaContentHash` are all filled. | -| TS | `cultcache.interop-note` | `definition.schemaId ?? schemaName ?? type`. There is no hash. With no declared version, the version defaults to `.v1`. | contentHash is whatever the author declares. The interop test declares the id string itself. | -| Python | `cultcache.interop-note` | `schema_id or type`. There is no hash. contentHash defaults to the id. | Same as TS. | -| Rust | `cultcache.interop-note` | `#[cultcache(type=…)]`. There is no hash. `schema = "CultCacheInteropNote"` never reaches the catalog. | The catalog entry it writes is fabricated: version `".v1"` (`cultcache.interop-note.v1`, not the declared `…_note.v1`), `members: []`, `contentHash = type`. | -| Kotlin (CultMesh only; it has no store) | `cultcache.interop_note.v1` | `codec.schemaVersion` | Nothing else. | - -On the C# fingerprint: -- **The id stays the same** when only the CLR class or namespace changes (V1). -- **The id changes** when a member is renamed (V2), a slot is appended (V3), `string[]` becomes `List` (V4), the version string changes (V5), or a slot is removed (V6). -- **V2 and V4 produce identical wire bytes.** MessagePack slot arrays carry neither member names nor CLR collection types. So the fingerprint witnesses the C# declaration, not the wire layout. - -The C# registry already refuses two CLR types for one `(name, version)` in a process. The probe crashed on exactly that when V6 and the base type shared an assembly. Inside C#, `(name, version)` is already the ownership key, and the hash adds nothing to ownership. - -### 2. Wire parity for identity does not hold (probed) - -No two runtimes agree, and C# is the only one that hashes. The CultNet interop harness is the parity witness in CI. It never exercises the C# default: `tests/GameCult.Networking.InteropPeer/Program.cs:77,201,1183-1196` binds every type with `ForDocument(schemaId: )`. - -What reads what today: - -- **Stores (`.cc`). C#, Rust, TS and Python all read each other's notes.** It works only because each reader, when the id is unknown, falls back to the embedded catalog's **schemaName**: C# `CultCache.cs:653` `BySchemaName`, TS `cult-cache.ts:827`, Rust `resolve_registered_type` `lib.rs:2754`. Round trip, C# → X → C#: - - Each writer stamps its own record with its own id. - - **A C# rewrite restamps every other runtime's record to `sha256:…`** and drops their catalog entries. - - **A Rust write destroys the C# catalog entry for the id it read.** The entry becomes name=`cultcache.interop-note`, version=`sha256:…eafe….v1`, contentHash=`sha256:…eafe…`, canonical JSON with `schemaName: "sha256:…"`, `members: []`. The C# record bytes survive, but their description is lost. That breaks F2 ("never relabels…") at the catalog level, and it is a defect whatever this fork decides. - - TS and Python kept the C# catalog entry intact. -- **Wire (CultNet raw record carrying a C# `sha256` id):** - -| Reader | `sha256:…` | `cultcache.interop-note` (name) | `cultcache.interop_note.v1` (version) | -|---|---|---|---| -| TS `CultNetDocumentRegistry.applyRawDocumentPut` (probed) | refused | ok | refused | -| Kotlin `CultCache.putRaw` (probed) | refused | ok (documentType) | ok | -| C# `CultNetDocumentRegistry.DeserializeRawDocument` (probed) | ok | ok | ok, **and `gamecult.unknown.v1` → `Note` too** | -| Python `cultnet_py` `resolve_document_for_raw_record` (read only) | only if declared | ok | ok, plus payload sniffing | -| Rust `pull_rudp_catalog_snapshot` (read only, per the Eyes sweep) | dropped silently | — | strips `.vN` and matches the type | - -C# accepts any id because `TryResolveDescriptorBySchemaAlias` and `TryResolveDescriptorByPayloadSchema` (`CultNetDocumentRegistry.cs:755-830`) read slot 0 of the payload as a schema version. Python does the same (`replication.py:160-196`). **Shape routing and aliasing are still live in C# and Python CultNet on c2a**, and so is C# request matching `CultNetSchemaAliasMatching` (`CultNetDatabase.cs:52-89`). F7 has not reached them. - -- **The C# wire id is readable only when the binding is overridden.** The probe showed `ForDocument(schemaId: "cultcache.interop-note")` emits that id with the same payload, name, version and contentHash. `CultMesh.CreateCultNetDocumentRegistry` (`src/GameCult.Mesh/CultMeshDocumentRegistries.cs:69`) never overrides it, so every C# CultMesh host publishes `sha256` ids. - -### 3. Live cross-runtime paths that depend on the fallback - -This section comes from the Eyes sweep. I spot-checked the Hermodr lines, the Odin rule and `CultMeshDocumentRegistries.cs`; the rest I only read. Every one of these paths is **TS reader → C# host (the Aetheria daemon in `F:\Projects\AetheriaEve`)**. - -| # | Consumer | Asks for | Works via | Under C1 | -|---|---|---|---|---| -| 1 | `EveElectron/src/cultmesh-provider-client.mjs:129-143`, started by `AetheriaEve/Aetheria.Rts.Web/Electron/main.ts:65` | `gamecult.eve.provider_advertisement.v1`, `…surface.v1`, `gamecult.fields.*.v1`, `…command_receipt.v1`, `gamecult.cultmesh.cdn.asset_blob.v1` | cultmesh-ts HELD `firstRecordAtKey` | Exact match. The exception is `cdn.asset_blob.v1`: **no writer anywhere declares it**, so that read needs a declaration. | -| 1b | same file, lines 94-108 (command put) | `gamecult.eve.command_invocation.v1` | C# inbound alias (g), probably | Exact match | -| 2 | `AetheriaEve/Aetheria.Rts.Web/Electron/aetheria-cultmesh.ts:138-147, 345-406` (only the verify-stage7* scripts use it) | `gamecult.aetheria.*.v1`, `gamecult.fields.*.v1` | first-record fallback | Exact match | -| 3 | `Hermodr/src/hermodr-daemon.cjs:1335-1363` | provider state, surfaces, CDN | Its own `|| candidates[0]` / `|| documents[0]`, plus C# request alias (f) | Exact match. Delete both fallbacks. | -| 4 | `AetheriaEve/scripts/aetheria-browser-provider-witness.ts:49-60` (a witness, not product code) | eve schemas | cultmesh-browser `recordMatchesSchema` name/version arms | Exact match | -| 5 | `aetheria-cultmesh.ts:408-411`, local `.cc` read | same ids | none: probably already broken (unverified) | still a store-path question | - -**Paths that already work without a fallback, because everyone hand-stamps `.vN`:** -- The Aetheria daemon and Gjallar hand-stamp `.v1` puts to Odin: `Program.cs:4574-4830` and `Gjallar/Program.cs:3040-3080`. -- Odin **refuses any id without `.vN`**: `Odin/crates/odin-daemon/src/main.rs:1310-1326`. -- Rust hosts bind `.vN` through `cultmesh_documents!`: Ghostlight, Epiphany, Muninn. -- Kotlin uses its schemaVersion. -- The Eve C# declaration itself reads `[CultDocument("gamecult.eve.provider_advertisement", SchemaId)]` with `const SchemaId = "gamecult.eve.provider_advertisement.v1"`. Authors already treat the version string as the id. - -Scope flag: every broken consumer lives in `AetheriaEve`, which the CultCache campaign ruled "taxidermy". The operator should confirm those paths are live consumers of this campaign before any cut is shaped for them. - -Stored data: -- `Aetheria/GameData/Aetheria.cc`, `run.cc` and `player.cc` hold 21 C# schemas under `sha256` ids. The Eyes sweep found only C# readers. -- The versions there are the bare string `"1"`: `[CultDocument("aetheria.faction", "1")]`. So a version string is not globally unique across the estate. -- TS stores (Bifrost, VoidBot, weksa, Stonks) are TS-only and hold readable ids. -- Odin's Rust store holds `.vN` ids. - -### 4. What the C# fingerprint protects - -A C#-to-C# store read. A record whose declaration drifted misses the exact id and falls to the persisted-catalog comparison: `CompatibleDrift`, or refused as incompatible (`CultCache.cs:900-936`). - -Across runtimes it protects nothing today: -- The other runtimes do not compute it. -- Their content hashes are placeholder strings. -- The C# wire receiver accepts any id through payload sniffing (probed). -- The hash reacts to renames and CLR collection spellings, which do not change wire bytes (probed V2, V4). - -### Fork F-ID: what names a schema across runtimes - -**(A) Every runtime computes the C# semantic fingerprint; readers name schemas by definition.** -- Every non-C# runtime has to emit C# type spellings: `System.String[]` versus `System.Collections.Generic.List`. -- Rust has to start declaring members and versions at all. -- String-named readers can no longer name a schema. Eve Electron and Hermodr read ids from provider advertisements. -- Odin refuses the ids outright (`.vN` rule). -- Every TS, Python and Rust store holds readable ids. Under no-relabel those records become permanently held unless each runtime lists its old ids. -- Gain: a layout witness that is still over-sensitive (V2 and V4 change the id with no wire change). -- Stored data: Aetheria is untouched; every non-C# store is orphaned. -- Not recommended. - -**(B) Readers match the declared `(schemaName, schemaVersion)` pair the envelope carries.** -- The C# wire already carries both. Store catalogs carry both. -- Two identity strings stay in play: the id for storage, the pair for lookup. That is a split owner. -- `sha256` ids still reach Odin, which refuses them. -- The version alone is ambiguous (Aetheria's `"1"`), so every reader API has to take a pair instead of the one string readers pass today. -- Rust writes a fabricated version, so pair matching against a Rust host fails until Rust declares versions. -- Layout protection is only as good as a contentHash comparison, and no runtime but C# computes a real one. -- Stored data: unchanged, and nothing is relabelled. Resolution becomes pair matching against the catalog, which is a formalised form of today's schemaName fallback. - -**(C) C# puts the readable id on the wire, and the id is the declared version string `.v`.** - -This is what Odin enforces, Rust and Kotlin use, and Eve and Gjallar already hand-stamp. -- C1, wire only: - - `ForDocument` and `CultMesh.CreateCultNetDocumentRegistry` default the binding id to `descriptor.SchemaVersion`. - - Registering a wire binding whose version lacks `.vN` is refused. Aetheria's `"1"` types are not on the wire today. - - Then delete the HELD first-record fallback (cultmesh-ts), Hermodr's two fallbacks, the name and version arms of cultmesh-browser `recordMatchesSchema`, C# `TryResolveDescriptorBySchemaAlias`, payload sniffing and `CultNetSchemaAliasMatching`, and the Python CultNet alias map and sniffing. That finishes F7 on the wire. -- C2, the store as well, as a later cut: C# stamps new writes with the version id and resolves an old `sha256` record by the type's own **computed** former fingerprint. That is a derivation, not an alias. Where a version string changes (Aetheria's `"1"` → `aetheria.faction.v1`), the old id goes into the existing `CompatibleSchemaIds`. -- The fingerprint is demoted to `schemaContentHash`, which the wire already carries. It stays a C#-to-C# drift witness and does not decide identity. -- Costs: - - C#: the default in two files, plus deleting the alias and sniffing paths. - - TS, Hermodr and Python: deletions only. - - Rust and Kotlin: none. - - Mixed-version C# peers: an old host sends `sha256` and a new receiver without sniffing refuses it, so C# peers upgrade together. - - Eve Electron `cdn.asset_blob.v1`: needs a declaring writer. -- Stored data: C1 changes nothing on disk. Under C2, Aetheria's catalogs are read unchanged and records are restamped only when C# rewrites records it understands, which F2 allows. TS, Rust and Odin stores are untouched. - -**Recommendation: C1 now; decide C2 separately.** C1 is the only option where one string names a schema on every runtime and at Odin, where every reader already asks for that string, and where the work is almost entirely deletion. It makes the F7 retirement possible on the wire, because readers no longer need a fallback to find their records. Aetheria's `.cc` files are untouched. B keeps the split and A breaks every readable-id store. Separately from F-ID, the Rust catalog-destruction defect (§2) and the live C# and Python CultNet aliasing should be admitted as findings or follow-ups whatever is ruled. - -**Sub-questions for the operator:** -- F-ID.1: Is the id the version string (`.vN`, as Odin, Rust, Kotlin and Eve do), or `schemaName`, which CultLib's own TS and Python tests use and which is also TS's default? -- F-ID.2: Are the AetheriaEve consumers live for this campaign? -- F-ID.3: Should C2 (store identity) be mapped now, or deferred until a non-C# reader of a C# store exists? - -### Probed versus read - -- **Probed:** - - All C# ids and variants, and the hand-recomputed fingerprint. - - The TS and Python default ids. - - Rust's id and catalog entry, from store bytes. - - Kotlin's id and its accept/refuse behaviour. - - Store round trips C#→Rust/Python/TS→C#, with bytes, including the C# restamp and the Rust catalog destruction. - - C# wire record bytes, default and overridden. - - C# CultNet accepting any id. - - TS CultNet exact-id behaviour. -- **Read only:** - - Python CultNet aliasing and sniffing, and Rust `pull_rudp_catalog_snapshot` dropping unknown records. - - C# request alias matching (f). - - Every consumer path in §3, from the Eyes sweep. I spot-checked Hermodr 1335-1363, Odin 1310-1326, `CultMeshDocumentRegistries.cs:69` and the Eve declaration. - - Path 1b/2b's dependence on (g). - - Path 5 being broken. - - The Aetheria `.cc` catalogs were decoded from the files, with no git. - -## C1 cut: one schema id on the wire - -Imagination, 2026-09-30. This maps the operator's C1 ruling. On the wire, a document's schema id is its declared -version string, `.v`. Every runtime stamps it and every runtime resolves it exactly. A wire binding whose -version lacks `.v` is refused. The AetheriaEve readers are archaeology, and C2 (store identity) is deferred. - -**Anchors.** Line numbers are against CultLib `hands/variants-c2a` at `976b57f1`. That commit is F2 in progress, the -Rust catalog lay-back. I read it from a `git archive` snapshot and did not touch the worktree. Where main -(`4a7fa1d6`, code as of `daedfdd6`) or `hands/cultmesh-put-serve-bound` (`fa34b685`) differs in a file C1 edits, it is -said at the spot. Each anchor also names its symbol, so it can be found again after c2a merges main (see Sequencing). - -### 0. Probe facts - -These are new and were run, not inferred. The sources are in `scratchpad/c1-probe/`. They ran on Yggdrasil in -`ack1d-interop:2` from the scratch ref `refs/scratch/c1probe`, a detached commit on `976b57f1` that is deleted after -this pass. Output is in `scratchpad/c1-probe3.log`. The run was commit `43677b97ac`. - -- **P-VER: a C# version change does not orphan stored records.** The probe used two builds of one type, - `probe.faction`, declared first with version `"1"` and then with `"probe.faction.v1"`, plus a sibling - `probe.ship "1"`. The same members. - - The id changes: `sha256:64eb…` becomes `sha256:0603…`. - - The new build reads the old store through the catalog's schema name (`Claimant`, `CultCache.cs:697`) and reports - `CompatibleDrift` with warnings `compatible_schema_id_drift` and `content_hash_drift`. The record decodes. - - **Opening and flushing without edits leaves the file byte-identical** (1529 bytes, old id). - - **Upserting restamps** that record and its catalog entry to the new id. The untouched sibling keeps its own. - - The old build then reads the rewritten store the same way. - - So a version-string change is a restamp on the next write, not an orphan. This holds only while one local type owns - the schema name. Two local versions of one name make the fallback ambiguous and it throws (`CultCache.cs:697-705`). - - C1 does not need this. It is recorded for C2. -- **P-WIRE: what C1 changes on the C# wire.** - - Binding both types by their version string: with `"1"` twice, c2a's `Register` refuses the second binding - (`CultSchemaConflictException … schema id "1"`). With `probe.faction.v1` and `"1"`, it accepts both. - - The default wire id is still sha256 in both builds. - - With an unbound registry, `DeserializeRawDocument` returned `Faction` for `"1"`, `probe.faction` (the name) and - `probe.faction.v7` (a version nobody declared). Only `some.other.v1` was refused. - - So today a C# receiver resolves a version it has never seen by stripping `.vN` and matching the name. That is the - path C1.0 deletes, and the negative check in §8 pins its death. - -Earlier facts this map rests on, from the §1-§4 probes above: C# hashes the version into the id (V5). The C# wire -id is sha256 unless the binding overrides it. C# CultNet accepts any id through sniffing. TS refuses a version id. -Kotlin stamps its version. - -### 1. What the consumer sweep settles - -This comes from three Eyes-class sweeps over F:\Projects. I read the rows marked (R); the rest were confirmed by the -sweeping agent reading the files. - -- **Aetheria's `"1"` versions never reach the wire.** Aetheria has no CultNet or CultMesh code. `Aetheria.Shared.csproj` - references only the caching assemblies. So C1's refusal never fires for its 24 declarations, and **nothing in - Aetheria changes, on disk or in source.** -- The other C# `"1"` declarations are in StreamPixels `apps/overlay-unity` (24). They are client-only and never bound: - frame ids map to types by hand (`OverlayFrameDocuments.cs:98-116`). -- Every C# type that is bound in any repo already declares `.vN`: AetheriaEve 61, AquaSynth 28, Mimir 37, Brokkr, - Eve, Gjallar, Ymir, Delvehold. **No repo outside CultLib passes `ForDocument(schemaId:)`.** -- **Live C# hosts with default (sha256) bindings:** - - AquaSynth, `AquaSynthCultNetDaemon.cs:431-449`, 19 bindings. Its peers are C# (`AquaDaemonClient.cs`). - - Mimir: `EveDashboard/Program.cs:877-886`, read by Eve Android, which ignores schema ids - (`MainActivity.kt:618-625`); and `CultMeshMedia/Program.cs:277`, C#. - - Delvehold: no server. - - All of these are C#-to-C# or id-blind. They change id together when they rebuild on C1, so no shim is needed. -- **The C# publishers to Odin bypass bindings.** AetheriaEve `Program.cs:4574-4831` and Gjallar `Program.cs:3045,3069` - build their ids by hand and serialize payloads directly. C1 does not change them. Odin's rule is at - `Odin/crates/odin-daemon/src/main.rs:1311-1326` (R). -- **Every Rust wire binding in every repo already binds `.vN`** through `cultmesh_documents!` or - `for_entry_with_schema_id` with `.vN` constants: Odin, Muninn, Ghostlight, Epiphany, Ratatoskr, Huginn. No consumer - uses bare `for_entry::()`. -- **The AetheriaEve readers are archaeology:** - - EveElectron's only code consumer is AetheriaEve (`Aetheria.Rts.Web/package.json:30`). - - Hermodr was parked on 2026-09-30: `gamecult-ops/inventory.md:631-634`, `runbooks/odin-yggdrasil.md:35-48`, and - `scripts/idunn/idunn-deployment-targets.ps1:36-46` (status "archived"). - - cultmesh-browser has two consumers. One is the AetheriaEve witness. The other is CultLib's own sample - `samples/eve-browser-network/browser/main.ts:8`. - - **So C1 edits neither Hermodr nor EveElectron.** Both are archived, so C1 deletes the CultLib fallbacks that exist - only for them and does not migrate them. -- **Non-C# consumers that change id under C1:** - - **Stonks is the only one that breaks.** `F:\Projects\Stonks\src\stonks-daemon.cjs:152-195` declares - `schemaVersion: "v1"` on six definitions, one of them `provider_advertisement` published to Odin at `:303`. Under - C1 its TS registration is refused. Stonks loads `../CultLib` from disk, so it breaks on the first restart after C1 - reaches that checkout. The fix is in Stonks: set each `schemaVersion` to its current `schemaId`. That is six lines, - and they land before C1 is merged to main. - - Bifrost `tools/agent-transport.mjs:62-66`: the id is hyphenated (`…update-request.v0`) and the version has - underscores (`…update_request.v0`). The wire id changes to the version. The snapshot and apply sides are the same - tool on one pinned CultLib (`f67f5122`), so they change together. Its store keeps the hyphenated id. - - Brokkr Python `surfaces/blender/brokkr_bridge/blender_target.py:630-637` declares eight type-only definitions whose - type already ends in `.v0`. The Python default version would make the wire id `….v0.v1`. The fix is in Brokkr: - declare `schema_version=`. No live reader was found, so this is hygiene, not a break. - - repixelizer: `verse_state.py:139-230` declares version ≠ id. Its wire id moves to the `.v0` version, which Odin - accepts. - - Everything else already has id == version: VoidBot, Vili, weksa, Heimdall, StreamPixels, Bifrost's other tools, - Hermodr. - - VoidBot's persona stores use a vendored cultcache-ts and are untouched. -- **Raw health puts are out of C1's reach.** Vili, Stonks, weksa, Bifrost and repixelizer send hand-built - `idunn.daemon_health` with no version, and Bifrost sends `idunn.signed_daemon_health`. These never register a - binding. No receiving binding was found in Idunn or Odin main. That is Soul's consumer check, not a C1 edit. - -**Q3, settled:** no declaration in any repo has to change to satisfy the refusal on a binding that actually exists. -Aetheria and the StreamPixels overlay are the `"1"` repos, and neither binds. Stonks's `"v1"` is TS; it is fixed in -Stonks and touches no store. Stonks's store keeps the ids it holds today, because TS stores under `schemaId`. So -**no declaration change touches disk.** Whether a future change of Aetheria's version string would orphan its records -is the P-VER probe in §0. It is recorded for C2 and not needed by C1. - -**Q4, settled:** C1 changes no store record in any runtime. The store id and the wire id become two derivations: -- C#: sha256 on disk, version on the wire. -- TS: `schemaId ?? schemaName ?? type` on disk, version on the wire. -- Python: `schema_id or type` on disk, version on the wire. -- Rust: the store id and apply-path stamping are unchanged (see C1.4). -- Kotlin: version for both, as today. - -Four places where one variable serves both today must be split. Each has its cut below: -- TS `replication.ts:363-368`, `schemaIdForEnvelope`, which serves the stored id. -- Python `cultmesh_py/node.py:767` and `interop_peer.py:1085`. -- The C# durable shard log, `CultNetShardMutationLogStorage.cs:75-88`. It persists wire-form entries, and so it is the - one C# store that holds wire ids. -- Rust `pull_rudp_catalog_snapshot`, `cultmesh-rs/src/lib.rs:742`. - -### 2. Authority map - -- **Owner.** The declaration's version string is the only wire identity: - - C# `CultDocumentAttribute.SchemaVersion` → `CultDocumentDescriptor.SchemaVersion`; - - TS `definition.schemaVersion`, defaulting to `${schemaName}.v1`, through `schemaIdentityOf(...).schemaVersion`; - - Python `schema_version`, defaulting to `f"{schema_name}.v1"`; - - Rust: the version given to `cultmesh_documents!` or `for_entry_with_schema_id`; - - Kotlin `codec.schemaVersion`. -- **One derivation per runtime:** - - C#: `CultNetDocumentRegistry.WireSchemaId(descriptor)` returns `descriptor.SchemaVersion`. It is the single place - `.vN` is checked, and it is also called eagerly from `Register`. - - TS: `wireSchemaIdOf(definition)` in cultnet-ts. - - Python: `wire_schema_id(definition)` in cultnet_py. - - Rust: `CultNetDocumentBinding::schema_id`, which is already the version. - - Kotlin: `codec.schemaVersion`. -- **Inputs:** the declaration only. Never a payload, a schema name, an inferred name, a record's position in a - response, or a stored record's id. -- **Outputs:** every schema id that crosses a process boundary: - - raw records, puts and deletes; - - snapshot and selection responses, headers, edges and cursors; - - database change messages and shard-log entries; - - snapshot, subscribe and selection filters, and the shard catalog; - - the document-payload schema catalog; - - CultMesh projection-source and state-binding records. -- **Resolution.** A wire id resolves to the binding that owns it (exact). Otherwise it resolves to the one binding that - *declares* it compatible (`CompatibleSchemaIds`, owner beats lister), which is the rule stores already use. **OQ-C1.2 - decides whether declared compatibility applies on the wire.** Anything else is refused. -- **Derived state after C1:** - - C# `descriptor.SchemaId` (sha256) is **store-only**. It keys CultCache, `_predictedDocuments`, - `_lastWriteSequence`, and in-process dictionaries. - - TS and Python `schemaId` are **store-only**. - - `CultNetDocumentBinding.SchemaId` is **derived** (the version). It is no longer an owner. - - `schemaName` is **metadata only**, never matched. - - Payload slot 0 or `schemaVersion` is **data only**, never read for routing. - - `schemaContentHash` is a **C#-to-C# drift witness**, carried and never matched. -- **Forbidden writers, all deleted:** - - C#: `CultNetSchemaAliasMatching`, `TryResolveDescriptorBySchemaAlias`, `TryResolveDescriptorByPayloadSchema`, - `PayloadMatchesSchema`, `TryReadSchemaVersion`, both `InferSchemaName`, `ResolvePayloadSchemaCandidates`, - `ExpandSchemaBindingAliases`, the `ForDocument(schemaId:)` override (OQ-C1.1), the CultMesh `aliased` and - `byPayload` branches, and the descriptor-name and version keys in the C# and TS mesh catalogs; - - TS: `firstRecordAtKey`, cultmesh-browser's name and version arms, `shard-catalog.ts` `inferSchemaName`, and - `inferCultMeshSchemaName` / `bySchemaNameVersion`; - - Python: the name and version keys in `schema_document_map`, `_infer_schema_version_from_payload`, and every - `_infer_schema_name`; - - Rust: `strip_schema_version_suffix` and `selection::schema_alias`; - - Kotlin: `codecs[schemaId]`, the documentType fallback. -- **Shared paths.** Put, delete, snapshot (v0, v1, raw), selection, subscription, database change, shard log (live and - replayed from disk), shard catalog, schema catalog, and CultMesh peer reads all take the id from the one derivation. - A served stored record is stamped by the derivation, never by its stored id. - -### 3. Deletes first (C1.0, subtraction) - -C1.0 deletes every inference path and makes each comparison exact against the existing wire id: the binding id, or -sha256 for an unbound type. C#-to-C# peers keep working. Only readers that relied on a fallback stop resolving, and -those are the AetheriaEve readers, which are archaeology. C1.0 adds no behaviour; C1.1 flips the id. - -**C#, `src/GameCult.Networking`:** -- `CultNetDatabase.cs:47-104`: delete the whole `CultNetSchemaAliasMatching` class (58 lines, public). - - Replace every caller with an exact `string.Equals` against the registry's wire id for the descriptor. - - Callers: `:143, :150` (`ClientAuthorityScope.Matches`); `:252, :260` (`Shard.Matches`); `:1757` (shard-catalog - filter). - - `Shard.Matches(string)` and `ClientAuthorityScope.Matches(string)` compare a configured id with the wire id. - - `EnsureClientAuthority(string)` at `:1640-1652` has no callers; delete it. -- `CultNetDocumentRegistry.cs`: - - Delete `:779-799` `TryResolveDescriptorBySchemaAlias`, `:813-830` `TryResolveDescriptorByPayloadSchema` (public), - `:832-842` `ResolvePayloadSchemaCandidates`, `:852-854` `PayloadMatchesSchema` (public), `:865-898` - `TryReadSchemaVersion`, `:900-910` `InferSchemaName`, and `:538-578` `ExpandSchemaBindingAliases` with its comment. - About 175 lines in all, doc comments included. - - `ResolveDescriptorForRawDocument` (`:755-765`) and `ResolveDescriptorForSchemaId` (`:767-777`) collapse into one - exact lookup. It uses `_bindingsBySchemaId`, or, for a registry with no bindings, the one descriptor whose wire id - equals the id. A miss throws `InvalidOperationException` naming the id. - - Call sites stay on the one method: `CultNetDatabase.cs:717, 947, 998, 1234, 1455`, - `CultNetDatabaseSubscriptionClient.cs:254`, and `CultNetDocumentRegistry.cs:691, 713`. -- `CultNetDocumentRegistry.cs:407, 507`: drop the `ExpandSchemaBindingAliases` calls. `CultNetDatabaseServer.cs:566-567` - and `CultNetDatabaseSubscriptionServer.cs:559-560` pass the selection unchanged. -- `CultNetSelection.cs:393, 453` and `CultNetSelectionEvaluator.cs:88, 422`: exact comparison against the wire id. - - The evaluator reads only descriptors, so C1.0 gives it the registry's `WireSchemaId` as a `Func`. - - After C1.1 the id is `descriptor.SchemaVersion`, and the parameter collapses to that (see C1.1). - - `CultNetSelection.cs:178` doc: "schema ids", not "or aliases". - -**C#, `src/GameCult.Mesh`:** -- `CultMesh.cs:2724-2774` `ReadDocumentFromSnapshotResponse`: delete the `aliased` and `byPayload` branches - (`:2744-2745, 2754-2757`). Pick `exact` or throw. Rewrite the comment block at `:2724-2733`. -- `CultMesh.cs:3441-3464` `IsSameCultDocumentSchema`: the id is local (a `CultNetDatabaseChange` sha256). Replace with - `schemaId == descriptor.SchemaId`, or `storedDescriptor.SchemaId == descriptor.SchemaId`. Delete the comment - claiming "every … decision goes through" the matcher. -- `CultMeshSnapshots.cs:982-985` `DecodeSnapshotDocuments`: keep only `canDeserializeWithBinding`, or - `record.SchemaId == wire id of TDocument`. -- `CultMeshDocumentRegistries.cs:64-71`: the `GroupBy(SchemaId)…Reverse()` loop is left over from aliasing. With c2a's - `Register` refusal, collapse it to one `Register` per distinct type. -- `CultMeshPrimitives.cs` ~`1806-1860` and ~`1996-2050`, the C# `CultMeshDocumentCatalog` and - `CultMeshCollectionCatalog`: drop the schema-version and schema-name keys. A lookup by schema answers by the handle's - type only. **A lookup that more than one handle answers is refused, naming their document ids.** This is the "typed - catalog lookup returns the last handle added" defect, and TS has the same fix below. - -**TS:** -- `cultmesh-ts/src/index.ts:6297-6328` `requestCultNetRawSnapshotDocument`: delete the HELD comment, the - `firstRecordAtKey` option, and `?? atKey[0]`. Delete the caller's `firstRecordAtKey:` at `:2691`. -- `cultmesh-ts/src/index.ts:6175-6191` `normalizeCultMeshDocumentSchema`: drop the `inferCultMeshSchemaName` arm and the - version-from-id arm, and delete `inferCultMeshSchemaName` at `:6228-6238`. -- `cultmesh-ts` catalogs: `CultMeshDocumentCatalog` `:1462-1519` and `CultMeshCollectionCatalog` `:1688-1731`. - - Delete `#bySchemaNameVersion`, `cultMeshSchemaNameVersionKey` (`:6220-6226`), and its arm in - `cultMeshRefuseSecondCatalogType` (`:6197-6218`). - - `tryDocument` and `tryCollection` answer by type or by wire id. When `#byType` holds several handles for one type - (`add` at `:1482` overwrites, so today the last one wins), the lookup is refused with the handles' document ids. - That needs `#byType: Map`. -- `cultmesh-browser/src/index.ts:770-774` `recordMatchesSchema`: exact `record.schemaId === requestedSchema`. Callers - are `:704, :721`. After C1.2, CultLib's `samples/eve-browser-network` asks by version. -- `cultnet-ts/src/shard-catalog.ts:103-130`: `schemaIdsMatch` becomes `===`. Delete `inferSchemaName`. - -**Python:** -- `cultnet_py/replication.py:21-30` `schema_document_map`: key by wire id and compatible ids only; drop `schema_name` and - `schema_version` keys that differ from the wire id. -- `replication.py:158-194`: `resolve_document_for_raw_record` becomes `dict` lookup or `KeyError`. Delete - `_infer_schema_version_from_payload` and `_infer_schema_name`. -- `cultnet_py/shard_catalog.py:143-154`: exact. -- `cultmesh_py/node.py:1311-1343`: `_schema_matches_request` and `_document_matches_schema_id` become exact; delete - `_infer_schema_name`. -- `cultmesh_py/server.py:687-721`: the map copy and request filter become exact; delete `_infer_schema_name`. -- Keep `_documents_alias` / `_resolve_document_alias` (`node.py:1188-1243`). They compare local definitions, not wire - ids (follow-up F-C1-PYALIAS). - -**Rust:** -- `cultmesh-rs/src/lib.rs:750-773`: delete `strip_schema_version_suffix`. `registered_document_type_for_schema` becomes - `binding_by_schema_id(..).map(|b| b.document_type.clone())` and nothing else. Delete the `documents.binding(schema_id)` - type-name arm. -- `cultnet-rs/src/selection.rs:709-851`: delete `schema_alias`, tests included. Its uses at `:1432, 1487, 1651, 2112` - become exact comparisons against the row's binding id. -- `cultnet-rs/src/snapshot_query.rs:160-181` `RawSnapshotRow`: stop defaulting `schema_name` to the id; it reaches - `schema_alias` from `serve_read_only_raw_snapshot` (`:129`). - -**Kotlin:** `cultmesh-kotlin/.../CultMesh.kt:154-155` `codecForSchema`: drop `?: codecs[schemaId]`. That also fixes -`deleteBySchema` at `:170-171`. - -**Not edited, archaeology:** Hermodr `hermodr-daemon.cjs:1335-1363`, EveElectron, and AetheriaEve's own readers. - -**Tests deleted or inverted in C1.0.** Each rule that dies keeps a test that proves it is dead. -- C#: - - `NetworkingTests.cs:3177` (a selection by version matches through the alias): invert to not-found before C1.1. - - `NetworkingTests.cs:4022` (foreign id by sniffing): invert to refused. - - `NetworkingTests.cs:4109, 4140, 4276, 4317, 4366` (shard and scope configured by version): configure by the wire id. - - `CultNetSelectionFixBatchTests.cs:121, 158` (name alias): invert. - - `CultMeshStreamingTests.cs:2638-2708, 3062, 3105` (payload fallback): invert to refused or skipped. -- TS: - - `cultmesh.test.ts:3061-3074, 3244-3249` (HELD): invert to not-found. - - `cultmesh.test.ts:1170-1196, 1241-1286`: catalog by version against a sha256 handle. - - `cultnet.test.ts:1064-1068` (shard by name). - - `cultmesh-browser.test.ts:139, 452, 530, 536, 692-697`. -- Python: - - `test_cultnet.py:1685-1726, 2059-2063`. - - `test_cultmesh.py:291-339, 343-379` (drop the name case). - - `test_cultmesh.py:4150-4302` (sniffing and deletes by version against a sha256 id). -- Rust: `tests/selection.rs:2134, 2151, 2179, 2193, 2216-2219`. - -### 4. C1.1: the C# wire id is the version - -This is a behaviour cut on `src/GameCult.Networking` and `src/GameCult.Mesh`, plus the shared selection fixture with -Rust. - -**The store id and the wire id stay separate.** `descriptor.SchemaId` (sha256) keeps keying CultCache and every -in-process dictionary. The wire id is `descriptor.SchemaVersion`. Once the override is deleted (OQ-C1.1), the wire id -derives from the descriptor alone, with no registry. That is what lets the selection evaluator, the mesh and the -database compute it without a binding. - -**How a C# reader maps `.vN` to its descriptor:** -- `_bindingsBySchemaId` is keyed by `binding.SchemaId`, which now equals `SchemaVersion`. -- An unbound registry looks the version up among its descriptors. -- C# already refuses two types for one `(name, version)` in a registry (`CultCache.cs` `RegisterDescriptor`, "One type - owns a schema"), and c2a's `Register` refuses two types for one binding id. So an exact version lookup has at most one - answer. -- Two types sharing version `"1"` cannot both be bound, because `"1"` is refused first. - -File changes: -- `CultNetDocumentRegistry.cs:76-135` `ForDocument` and `ForDocument(Type…)`: delete the `schemaId` parameter - (OQ-C1.1). The binding id is `descriptor.SchemaVersion`. -- `CultNetDocumentBinding`: the internal constructor at `:44` takes the id from the descriptor. -- `CultNetDocumentRegistry.cs:173` `Register`: before c2a's conflict check, refuse a binding whose id fails - `^.+\.v[0-9]+$`. Throw `CultSchemaConflictException` or `ArgumentException`, naming the type, the declared version, - and the rule. The refusal happens at registration, never at first send. -- `CultNetDocumentRegistry.cs:675-676` `WireSchemaId`: becomes `descriptor.SchemaVersion`, checked by the same rule, so - an unbound `"1"` type is refused when it is first emitted. Every emitter below calls it. -- `CultNetDocumentRegistry.cs:616-645` `ToRawRecord`: the synthesized binding at `:621-626` uses `WireSchemaId`, not - `descriptor.SchemaId`. -- `CultNetDocumentRegistry.cs:217-228` `CreateDocumentDeleteMessage(string schemaId…)`: add - `CreateDocumentDeleteMessage(messageId, CultRecordHandle)`, which derives the wire id. Keep the string overload, - documented as "the wire id". -- `CultNetDatabase.cs` emitters: publish the wire id wherever a `CultNetDatabaseChange.SchemaId` leaves the process. - - `CultNetDatabaseServer.cs:555/581` (removal change) sends `WireSchemaId(descriptor)`, not `change.SchemaId`. The - change record keeps the sha256 locally. - - `CultNetDatabase.cs:1554` `ToLogEntryMessage` `Delete.SchemaId` becomes the wire id. - - `CultNetDatabase.cs:1512` `ApplyCommittedDelete` resolves the incoming delete id through the one exact lookup, not - `GetRequiredBySchemaId`. - - Error text at `:1664, :1725` names the wire id. -- **Durable shard log** (`CultNetShardMutationLogStorage.cs:60-88`, `CultNetDatabase.cs:586-591, 1385-1409`): - - It persists store ids. `Append` rewrites each entry's `schemaId` (put document and delete) to - `descriptor.SchemaId`. - - `GetMutationLogMessages` restamps with `WireSchemaId` on the way out. - - `KeyOf` (`:1399-1409`, the restart rebuild of `_lastWriteSequence`) reads store ids and so agrees with the live - writes at `:1294, 1486, 1531`. That also fixes the rebuild disagreement that exists today when a binding overrides - the id. - - **Existing log files hold sha256 for default bindings, which is the store id, so nothing on disk changes.** Only - logs written through an override hold a foreign id, and only the interop peer used one. No repo outside CultLib uses - `CultNetFileShardMutationLogStore` (grep over F:\Projects). -- Request filters that send the sha256 today switch to `WireSchemaId`: - - `CultNetDatabaseSubscriptionClient.cs:70-71`; - - `CultMeshClient.cs:602, 843, 944`; - - `CultMesh.cs:2696` (`RequestPeerSnapshotAsync`) and `:2038`; - - `CultMeshSnapshots.cs:874` `ResolveDefaultSelection`. -- **Shard catalog and config:** `CultNetShardDescriptor.SchemaIds` and `CultNetClientAuthorityScope.SchemaIds` are wire - ids. They are documented so, and matched exactly (C1.0). -- CultMesh projection sources and binding records (`CultMesh.cs:1521, 1602, 1972, 2032, 2273, 2300, 2331, 2357, 2384, - 2413`; `CultMeshSnapshots.cs:530, 555`) cross the wire as `CultMeshStateBindingRecord [Key(3)]` - (`CultMeshPrimitives.cs:3334`). Stamp them with the version. - - The collection and feed ids built from them (`CultMesh.cs:2298, 2329, 2382, 2411, 3266`) move to the version too. - - The cultmesh-ts type of the same shape then agrees. -- **Selection order and cursor** (`CultNetSelectionEvaluator.cs:213-214, 318, 345, 586, 593`): tie-break and cursor on - the wire id, as Rust does on its binding id. - - This changes a wire-visible order: the parity vector R-AJ flips (`leaf_a.v1 < leaf_b.v1`, where the sha256 order - was `b1f2… < ff35…`). - - Cursors minted before the upgrade stop resuming. That is acceptable, because cursors are per session. -- **Shared fixture, landed in this cut with the Rust side:** - - `contracts/cultnet/interop/selection-vectors.fixture.json`: `schemaId` becomes the version. Delete `nameAlias` and - `hashAlias`. - - Regenerate `selection-vectors.cs-written.json` and `selection-vectors.rs-written.json`. - - `SelectionParityVectorTests.cs:112-117, 156-159` assert the fixture ids equal the declared versions. Delete the - alias cases at `:235, :238, :329`; keep the refusal of an unknown id at `:325`. - - Rust `cultnet-rs/tests/selection.rs:1561-1690, 1849` (vector writer): drop the alias rows; order by the version. -- **Left alone:** `global:{descriptor.SchemaId}` record keys (`CultCache.cs:2473`, `CultNetDatabase.cs:1120`). They are - a record key, not a schema id, and changing them changes store keys. See F-C1-GLOBALKEY. -- **Schema catalog:** `CultNetSchemaRegistry` holds JSON-Schema contracts keyed by `$id` URL, and no production C# host - answers a catalog request (`Server.cs:565` is an allowlist only). The only document-payload registrations are the - interop peer's, which C1.5 changes. Nothing to cut here. - -### 5. C1.2: TypeScript - -Runtime packages `cultcache-ts`, `cultnet-ts`, `cultmesh-ts` and `cultmesh-browser`. - -- `cultcache-ts/src/document.ts:82-91` `schemaIdentityOf` stays the store identity, unchanged. -- **cultnet-ts owns the wire:** `export function wireSchemaIdOf(definition)` returns - `schemaIdentityOf(definition).schemaVersion`. The store keeps a definition with no declared version valid; only a - wire registration refuses it. -- `cultnet-ts/src/replication.ts:52-80` `register`: - - refuse a version failing `/\.v\d+$/` with `SchemaConflictError` or `TypeError`, naming the type; - - key `#owners` by `wireSchemaIdOf`; - - `#listers` keep the declared compatible ids (OQ-C1.2). - - The conflict check at `:59-71` also compares wire ids. -- Outgoing ids: `schemaIdForBinding` (`:349-351`) splits in two. - - Outgoing messages (`:123, :178, :287` put echo) use `wireSchemaIdOf`. - - `applyRawDocumentPutMessage` (`:280-290`) keeps storing under the store id, `schemaIdentityOf(...).schemaId`. - That is the leak point: today the same function feeds both. -- **Serving** (`:196-260`, `:363-368` `schemaIdForEnvelope`, `:336-345` `#createRawDocumentRecord`): - - A served record carries `wireSchemaIdOf(binding)`, never `envelope.schemaId`. - - A record stored under a compatible id holds that version's bytes. It is decoded and re-encoded through the owning - definition before it is served under the owner's id. This matches C#, which serializes from the decoded document - (`CultNetDocumentRegistry.cs:640`). - - `answersTo` (`:354-361`) matches the requested id against the binding's wire id (and its compatible ids if - OQ-C1.2 is yes). - - Tests `cultnet.test.ts:1627-1664` (the wire id equals the store id), `:1703-1708` (served under the stored id) and - `:1713-1744` (a version id does not resolve) are inverted. -- `cultnet-ts/src/shard-catalog.ts`: exact after C1.0; shard ids are wire ids. -- **cultmesh-ts:** - - `cultMeshSchemaFromDefinition` (`index.ts:6168-6173`): `schemaId` for peer reads is `wireSchemaIdOf`. - - `syncDocumentFromPeerSnapshot` (`:3995-4019`) and `cultMeshDocumentFromPeerSnapshot` (`:2668-2710`) ask by wire id. - - `resolveCultMeshStoreDocumentRecord` / `cultMeshAcceptedSchemaIds` (`:6243-6256`) are store-local and stay on - `schemaIdentityOf`. - - The receipt filter at `:5976` compares `receiptBinding.definition.schemaId`, which is `undefined` when not - declared. Compare with `wireSchemaIdOf`. -- Put-serve overlap (not on c2a): `hands/cultmesh-put-serve-bound` adds `#rawPutEnvelope` and - `createRawSnapshotResponseForPut` to this file, on main's shape resolution (`preserveIncomingSchemaId`). After the - merge, the put-sizing response must be built by the same serving path, so it carries the wire id. -- `cultmesh-browser`: exact after C1.0. `samples/eve-browser-network` declares or asks by version. -- **Consumer action, not in CultLib:** Stonks `stonks-daemon.cjs:152-195` sets `schemaVersion` to the full id. It - lands in Stonks before C1 merges to main. - -### 6. C1.3: Python - -- `cultcache_py/documents.py:105-143` `catalog_entry` stays the store identity. Add `wire_schema_id(definition)` in - cultnet_py, returning `schema_version`. -- Registration in `cultnet_py` and `cultmesh_py` refuses a version failing `\.v\d+$`. -- Outgoing ids use `wire_schema_id`: - - `cultmesh_py/node.py:577` (put), `:641` (delete), `:824-827` (sync); - - `client.py:430` (subscribe); - - `node.py:767, 776` (snapshot, never the stored id; a compatible-id record is re-encoded as in TS); - - `server.py:617-633` (catalog). - - `server.py:416, 444` echo a record that has already been resolved exactly, so it carries a wire id. -- Applied records keep being stored under the local store id: `replication.py:42, 84`, `node.py:664-670`. -- Inverted tests: `test_cultmesh.py:4116-4148` (a version request is served under the sha256 id) and `:4215-4258` - (echo of a foreign id). -- `interop_peer.py:1085` serves the stored id; that moves in C1.5. - -### 7. C1.4: Rust mesh and Kotlin - -- **Rust.** The wire id is already the version on every consumer binding. - - `for_entry::()` (`cultnet-rs/src/replication.rs:44-47`) has no consumer. It binds `T::TYPE`, which fails the - refusal unless it ends in `.vN`. Refuse it at `register` like any other id without a version. Keep the constructor, - so a type whose TYPE is `x.v1` still works. - - `for_entry_with_schema_id(id, version)` (`:50-64`): refuse `id != version` or a missing `.vN`. That is one id, and - `cultmesh_documents!` already passes the same string twice. - - `register` (`replication.rs`) applies the rule. - - The apply path keeps stamping `binding.schema_id` (`:400`). That is what Odin, Muninn and the rest store today, so - nothing on disk changes. - - `pull_rudp_catalog_snapshot` (`cultmesh-rs/src/lib.rs:714-747`) stamps the resolved binding's id. It is exact after - C1.0, so no foreign id is written. - - Rust's mixed store ids (typed put stamps `T::TYPE` at `cultcache-rs/src/lib.rs:2362`; apply stamps the version) are - left as they are. That is C2's question, F-C1-RUSTSTOREID. -- **Kotlin.** - - `register` (`CultMesh.kt:79-93`) refuses a `schemaVersion` failing `\.v\d+$`. - - The interop codecs at `CultMesh.kt:3872-3880, 4317-4322, 4351-4354, 3779-3789` put the contract URL in - `schemaVersion`. They become `cultnet.interop_note.v0` and the capability `*.v0` versions. Kotlin's own suite - (`CultMesh.kt` self-checks) moves with them. - -### 7b. C1.5: the interop harness tests the default binding - -The parity witness hid the mismatch because every peer names the note by its JSON-Schema `$id` URL. C1.5 removes the -overrides so each runtime's default binding meets the others. - -- C# `tests/GameCult.Networking.InteropPeer/Program.cs`: - - `:77-80, :201-204`: `ForDocument(payloadSerializer:…, payloadDeserializer:…)` with no id. The - id is `cultnet.interop_note.v0`. - - `:1183-1196`: four capability bindings with no id; their versions are `*.v0` (`:1560-1572`). - - Delete the `*SchemaId` URL constants. - - `LoadSchemaRegistration` (`:1116-1137`): the catalog registration's `SchemaId` becomes `InteropSchemaVersion`. The - JSON `$id` stays inside `SchemaJson`. - - The catalog server at `:682-714` stops copying `SchemaId` into `SchemaVersion`. -- TS `packages/cultnet-ts/test/interop/cultnet-interop-shared.ts:10-19, 289-306` and `cultnet-interop-peer.ts:123, - 135, 896-930`: definitions declare `schemaVersion` and no `schemaId` override. The note id constant is at - `cultnet-interop.test.ts:43`. -- Python `cultnet_py/interop_peer.py:59-68, 869-884, 936-981, 1085, 1149`. -- Rust `cultnet-rs/examples/cultnet_interop_peer.rs:56-67, 1227-1261`: `for_entry_with_schema_id` with the version - only. -- Kotlin: C1.4. -- The Python cultmesh scripts inside `cultnet-interop.test.ts:3872-4060` declare `schema_version` only. -- **The added negative lane** is one scenario in `cultnet-interop.test.ts`. A C# host serves a note from a - **CultMesh-created registry** (`CultMesh.CreateCultNetDocumentRegistry`, the production path). A TS reader: - - asks by `cultnet.interop_note.v0` and gets it; - - asks by `cultnet.interop-note` (the name) and gets not-found; - - asks by the sha256 id and gets not-found. -- CI: `.github/workflows/cultnet-interop.yml:141-163` already runs every pair lane. The new scenario joins the - `TypeScript and C#` pattern. - -### 8. Verification - -Each rule gets a behavioural test that fails when the rule breaks, plus the ecosystem mutation tool on the cut's -diff: Stryker.NET, StrykerJS, mutmut, cargo-mutants. Kotlin has no tool, so its rules are defended by scenario. - -**Positive, across runtimes, with default bindings** (C1.5 lanes, run on Yggdrasil in `ack1d-interop:2`): -- A C# host with a CultMesh-created registry publishes a note, and TS, Rust, Python and Kotlin each read it. Each asks - only by `cultnet.interop_note.v0`. -- Then each non-C# host publishes, and C# reads. -- The wire bytes carry `schemaId = cultnet.interop_note.v0`. Assert the decoded `CultNetRawDocumentRecord`, not a log - line. - -**Negative checks:** -- **No fallback.** In each runtime, a record at the requested key under another id is not returned (TS, C#, browser), - and a payload whose slot 0 names a registered version but whose id is foreign is refused (C#, Python). - - Mutant: restore `?? atKey[0]`, or restore the `byPayload` or `aliased` branch. It must die. -- **Unknown id refused.** - - C# `DeserializeRawDocument` with `gamecult.unknown.v1` throws. Today it returns `Note` (probed). - - TS, Python, Rust and Kotlin `applyRawDocumentPut` with an unknown id throw. -- **No name match.** Asking by `schemaName` finds nothing, in every runtime and in the selection evaluator (C# and - Rust). Mutant: add `|| candidate == descriptor.SchemaName`. -- **Refusal.** - - Registering a C# binding for a `[CultDocument("x", "1")]` type throws at `Register` and names the type. - - An unbound `"1"` type in a registry with no bindings throws at first emission. - - TS, Python, Rust and Kotlin refuse `"v1"` and `"1"`, and accept `x.v0` and `x.v12`. - - Mutants that must die: `\.v\d*$` (accepts `x.v`), `.v` anywhere, and `\d+$` alone (accepts `"1"`). -- **The wire id is derived from the declaration, not a constant.** Two types with different versions each emit their - own. A mutant that returns `SchemaName + ".v1"` must die, so use a fixture whose version is not `.v1`: the - interop note's name is `cultnet.interop-note` and its version is `cultnet.interop_note.v0`. -- **The store id is untouched.** - - A C# store written before C1 is read after it. `dump.py` shows record ids unchanged after a C1 host reads and - serves. - - A TS store with `schemaId: "p1.shared"` keeps that id after a raw put arrives under `p1.shared.v1`. - - Mutant: store under the wire id. It must die. -- **The served id is not the stored id.** A TS or Python record stored under a compatible id is served under the - owner's wire id, with bytes that decode as the owner. Mutant: serve `envelope.schemaId`. -- **Durable log.** - - A C# database with `CultNetFileShardMutationLogStore` writes, restarts, and replays to a replica. The replayed - entries carry the version, and `LastWriteSequence` after the restart equals the value before it. - - A log file written before C1 (sha256 entries) replays under the version. -- **Selection.** The parity vectors agree C#↔Rust with version ids. The tie-break vector R-AJ orders by version. -- **Catalog lookup.** A catalog with two handles of one type refuses a by-schema lookup and names both document ids - (C# and TS). Mutant: return the first or last handle. - -**Builds.** These are the focused set, with no workspace-wide build: -- `dotnet test` on `GameCult.Networking.Tests` and `GameCult.Mesh.Tests`; -- `npm test` in `cultnet-ts`, `cultmesh-ts` and `cultmesh-browser`; -- `pytest` in `cultnet-py` and `cultmesh-py`; -- `cargo test -p cultnet-rs -p cultmesh-rs`; -- the Kotlin self-check; -- the interop lanes. -All of them run on Yggdrasil through `ygg-verify.sh`. - -**Negative greps**, which must return nothing in `src/` and `packages/*/src`: -- `CultNetSchemaAliasMatching|InferSchemaName|inferSchemaName|_infer_schema_name|infer_schema_name` -- `strip_schema_version_suffix|schema_alias|PayloadMatchesSchema|TryReadSchemaVersion|firstRecordAtKey` -- `bySchemaNameVersion|ExpandSchemaBindingAliases` -- in `CultNetDocumentRegistry.cs`: `schemaId:` as a `ForDocument` parameter. - -**Live consumer checks**, after release and before any consumer bumps: -- **Stonks** has its six versions fixed. `idunn` shows Odin holding Stonks' `provider_advertisement` after a Stonks - restart on C1. -- **AquaSynth** daemon and clients rebuilt together; the Dings host round-trips. -- **Mimir** EveDashboard is visible in Eve Android. -- **Bifrost** agent-transport snapshot and apply round-trip. -- **Odin** still ingests from Heimdall, VoidBot, weksa and StreamPixels. Those ids do not change. -- **Grep** Idunn and Odin for a receiving binding of `idunn.daemon_health` with no version. If one exists, it is - refused at startup under C1.4. It was not found in main. - -### 9. Sequencing - -1. **F2 finishes first.** C1 and F2 touch different layers: - - F2 is store-side: `CultCache.cs` `Claimant`, the single-file and directory stores, and the Rust catalog lay-back. - - C1 is wire-side. - - They overlap in three places: - - `cultnet-ts/src/replication.ts`. F2 and batch 10 built owner-beats-lister and the `#listers` refusal (F9, F10) - there, and C1.2 re-keys `#owners` by wire id. The lister rule is kept, with OQ-C1.2 deciding its wire reach. - - `cultnet-ts/test/cultnet.test.ts:1346-1394, 1627-1744`. C1.2 inverts tests F2's batches wrote. - - `cultnet_py/replication.py` `schema_document_map`. - - C1 does not relabel any stored record and adds no store write, so F2's rule ("never relabels … a write over it is - refused") is not in play. F2's test `976b57f1` ("each runtime's writes leave another runtime's records and catalog - entries unchanged") must stay green through C1. - - Hands on F2 should not be interrupted. C1 starts after F2's Soul pass holds. -2. **Then put-serve merges to main** (`hands/cultmesh-put-serve-bound`, based on `b04d03b6`). - - It edits `cultnet-ts/src/replication.ts` on main's resolution. Main still has `preserveIncomingSchemaId` and - payload-shape resolution, which c2a deleted in `0ee98e8c`. - - It also edits `cultmesh-ts/src/index.ts`, `cultmesh_py/server.py` and `node.py`, and `cultmesh-rs`. -3. **Then c2a merges main.** This is the conflict to resolve before C1, whatever C1 is: - - c2a's exact resolution plus put-serve's `createRawSnapshotResponseForPut`; - - main's R1 changes to `CultNetDocumentRegistry.cs` (`rowFilter`) against c2a's `Register` refusal. - - C1 re-anchors on that merge commit. Every anchor above names its symbol for that reason. -4. **C1 cuts, in order, on the variants branch** (or `hands/variants-c1id` cut from it): - - C1.0 C# subtraction; - - C1.0 TS, Python, Rust and Kotlin subtraction, one cut per runtime or together, since they are deletions only; - - C1.1 C# wire id with the shared selection fixture and Rust selection order; - - C1.2 TS; - - C1.3 Python; - - C1.4 Rust and Kotlin; - - C1.5 harness. - - The interop lane is red between C1.1 and C1.5 on the branch. Soul measures at C1.5. - - Stonks' fix lands before the variants branch merges to main. -5. **Release.** C1 is wire-breaking between C# peers of different releases, because an old host sends sha256 and a new - receiver refuses it. It rides the C0/C2a release that the 2026-09-30 ruling already gates. The release note names: - C# peers upgrade together, the refusal of versions without `.vN`, and Stonks. - -### 10. Ledger estimate - -| Cut | Deleted (src) | Added (src) | Tests | Notes | -|---|---|---|---|---| -| C1.0 C# | ~290: alias class 58; registry block ~175; mesh branches ~35; expand ~40 | ~40 exact lookups | ~15 tests inverted, ~6 deleted | public API removed: `CultNetSchemaAliasMatching`, `TryResolveDescriptorByPayloadSchema`, `PayloadMatchesSchema` | -| C1.0 TS/Py/Rust/Kt | ~230: selection `schema_alias` ~140 with tests; Python infer/sniff ~45; TS infer/HELD/catalog keys ~45 | ~20 | ~25 tests deleted or inverted | | -| C1.1 C# | ~30 (override parameter, sha256 fallbacks) | ~80 (refusal, log restamp, emitters) | ~20 changed; fixture and vectors regenerated | wire-visible order change | -| C1.2 TS | ~15 | ~50 (`wireSchemaIdOf`, refusal, serve re-encode) | ~10 | | -| C1.3 Py | ~10 | ~40 | ~8 | | -| C1.4 Rs/Kt | ~5 | ~25 | ~6 | | -| C1.5 harness | ~60 URL constants and overrides | ~40 negative lane | — | | -| **Net** | **~-640 / +295 src**, about **-345** | | | Nothing on disk changes. Two public C# methods and one public C# class are gone. | - -### 11. Operator questions - -**OQ-C1.1: delete the per-binding wire-id override?** -- The overrides are C# `ForDocument(schemaId:)`, Rust's free first argument of `for_entry_with_schema_id`, and the - implicit TS and Python `schemaId`-on-the-wire. -- A. Delete. The declared version is the one wire id, and it derives from the descriptor alone, so the selection - evaluator, the durable log and the mesh need no registry to compute it. No repo outside CultLib passes the override; - only CultLib's interop peer and two conflict tests do. -- B. Keep it, but refuse ids without `.vN`. A second declaration of identity survives beside the version, and every - descriptor-only site (evaluator order, cursor, log, projections) needs the registry again. That is today's - `WireSchemaId` split. -- **Recommendation: A.** It removes a public parameter, which the CultLib consumer rule asks to be put to you rather - than cut silently. What a reasonable consumer loses is the ability to put an id on the wire that its declaration - does not state. That is the thing C1 rules out. -- C1.1's shape depends on the answer. - -**OQ-C1.2: does declared compatibility (`CompatibleSchemaIds`) resolve on the wire?** -- A. Yes, with the same rule the stores use: owner beats lister, and two listers with no owner are refused. A v2 type - that declares `x.v1` compatible accepts a v1 peer's records, so mixed-version peers work when an author declares it. - It is declared, never inferred. c2a's TS and Python registries already do this. Served records always go out under - the owner's wire id, re-encoded (§5). -- B. No, wire resolution is the owner only. Compatible ids become store-only. It is simpler, and a version bump is a - hard break between peers. -- **Recommendation: A.** It is the rule the operator ruled for stores (owner beats lister), applied to one more layer. - It is not aliasing, because nothing is guessed. -- C1.0's Python map, C1.2's `#listers`, and the C# lookup depend on the answer. - -**Defaulted, not asked. Veto if wrong:** -- TS and Python keep their default version `${name}.v1` when none is declared. -- A served record stored under a compatible id is re-encoded through its owner, as C# does. -- `global:{sha256}` record keys stay. -- Rust's apply path keeps stamping the binding id. -- A catalog lookup by schema that more than one handle answers is refused. -- Stonks is fixed in Stonks. - -### 12. Follow-ups (no cut owns them) - -- **F-C1-GLOBALKEY:** `global:{descriptor.SchemaId}` keys (`CultCache.cs:2473`, `CultNetDatabase.cs:1120`) carry the - sha256 across the wire as a record key. This is for C2. -- **F-C1-RUSTSTOREID:** Rust stores hold `T::TYPE` for typed puts and the version for replicated puts. Its catalog - fabricates version `.v1` (`cultcache-rs/src/lib.rs:2694-2708`) even where `cultmesh_documents!` declares another - one. The derive cannot declare a version (`cultcache-rs-derive/src/lib.rs:24-33`), which is a gap beside the other - runtimes. This is for C2. -- **F-C1-PYALIAS:** Python cultmesh `_documents_alias` compares two local definitions by name and version. It is - redundant under one-type-per-schema, but local. -- **F-C1-HEALTHID:** Bifrost sends `idunn.signed_daemon_health` without `.v1` - (`persona-feedback-idunn-health.cjs:41`), where every other sender uses `.v1`. It is pre-existing and unrelated to - C1. -- **F-C1-AEVE-CONST:** the AetheriaEve daemon compares wire ids with version constants (`Program.cs:1591`) and so never - matched under sha256. It is archaeology; record only. - -## F2 forks (operator, 2026-10-01) - -These came from the C2a F2 Hands at `a771e71b`. - -- **Fork A: RULED, forbid slot reuse.** Operator: "Forbid slot reuse. This is expected behavior for any MessagePack or - protobuf veterans." - - A whole-view write keeps laying back records the type does not own. - - Registration refuses a type that puts a different member in a slot the stored catalog shows was used before. - This follows protobuf's reserved field numbers. - - `VariantTests.AFlushShedsAnOverrideOfADroppedSlotSoALaterTypeReusingTheSlotDoesNotResurrectIt` is rewritten to pin - the refusal instead. -- **Fork B: DEFERRED, foreign records in TS, Python and Rust.** Operator: "Foreign records in other runtimes can wait, - I suppose, though I don't love leaving parity on the table." - - Today those runtimes refuse to open a store that holds a record they cannot claim. That is safe, but it is not - parity with C#. - - Carrying foreign records needs their whole-store writers taught first: TS `pushAll` via CultMesh `flush`, and Rust - `put_prepared_batch` → `push_all`. - - Recorded as the next parity cut, not dropped. - -## Soul: cultcache-ts push identity (`hands/cultcache-ts-push-identity` `1d6e1364..a00bb01f`, 2026-10-01) - -Verdict: **hold, not merged.** Recorded under drain mode; no fix dispatched. - -- **Held:** the Stonks duplicate is fixed; the suites on a merge with main are green (cultcache-ts 54/54 with four-runtime interop, cultnet-ts 198/198, cultmesh-ts 128 passing). -- **F1 (CONFIRMED, high):** `isSameRecord` (`single-file-messagepack-backing-store.ts:284-286`) still matches on the stored label. When one definition's type equals another's schemaName, a put or delete for one destroys the other's record at the same key, globals included. The branch's own test "an envelope with no catalog entry replaces a record stored under another schema id that carries its label" pins this hole. The coherent cut: the cache resolver hands the store the persisted identity (key plus schemaId), and the store compares only that. -- **F2 (CONFIRMED, high):** Python (`stores.py:54-67, 105-119`) has the same duplicate bug. A second `put_global` makes the store unloadable. -- **F3 (CONFIRMED, medium):** Rust `entry_id` is `(type, key)`, which duplicates records written by another runtime. Rust also writes its TYPE into the catalog schemaName slot, a parity defect. -- **F4:** mutant MA (legacy global labelled by schema name) survives; the rule needs a committed test. -- **F5 (PLAUSIBLE, high after c2a):** c2a's compatible-owned ids plus clause 1 let a non-owner's write delete the owner's record. c2a's `encodeSnapshot` `${type}::${key}` is a second identity authority. -- Probes survive as unreachable commit `1c7744e2` (ts, rs, py); recover them before gc. - -## Soul: C2a F2 keep unknown records (`hands/variants-c2a` `92d9e138..a771e71b`, 2026-10-01) - -Verdict: **hold, not merged.** Recorded under drain mode; no fix dispatched. The core promise holds: a C# write neither destroys nor relabels a record it doesn't claim. Checked on the real `Aetheria.cc` (206 records): 0 record or entry differences after a commit and a flush. - -- **F1 (CONFIRMED, medium):** C# decodes and re-encodes laid-back catalog entries (`CultDocumentMessagePackSerialization.cs:501,567`, `CultCache.cs:3847-3851`). Unknown entry and member fields are dropped, and nil and int widths are normalized. Fix: carry the raw entry bytes. -- **F2 (CONFIRMED, medium):** laying back a loaded foreign record reverts a newer write by its owner and moves storedAt backwards (`CultCache.cs:3831-3836`, breaks F6). Fix: lay back only while the file still holds the loaded `(id, storedAt)`. -- **F3 (CONFIRMED, medium):** one refused flush blocks every later write to other records. The directory store stays stuck until restart (`CultCache.cs:3827-3831`, `DirectoryMessagePackBackingStore.cs:249-253`). Breaks "writes to other records proceed". -- **F4 (low):** a laid-back record marks the v3 header without holding ids (`CultCache.cs:3731`). -- **F5 (plausible, low):** an in-place change to a laid-back document is dropped silently. -- **F6:** mutants H2 (`CultCache.cs:3850`) and R2 (`lib.rs:2663`) survive. -- **The main merge is its own Hands cut.** - - 8 files conflict, including about 74 KB in `lib.rs`. - - Main refuses a zero-byte store; c2a reads it as an empty v1 store. - - Main's `CultMeshStreamingTests.cs:919` uses `MeshNoteAliasDocument`, which c2a deleted. - - The rough merge fails in Caching, Mesh (compile), TS and Python. -- `ADeterministicIdIsTheSameUnderEveryCulture…` fails at the base too: the image is globalization-invariant. - -## Store authorities (Modeling, body at `hands/variants-c2a` `705ab669`, 2026-10-03) - -Source: cuts `merge-r1` (closed, reports h2-h6) and `mesh-single-file-reader` (closed, report h1). Every `file:line` -is at `705ab669`; re-find by symbol when the branch moves. This section supersedes the Body facts in section 1 -about raw readers (the Mesh legacy snapshot decoder and `ReadLegacyPersistedRecord` no longer exist) and the -merge notes in the C2a Soul sections below. C#, Rust, TypeScript and Python each have one single-file reader, and -CultMesh reaches CultCache's reader, lock and replace through one internal entry. - -Abbreviations: **CS** `src/GameCult.Caching/CultCache.cs` (`SingleFileBackingStore` :3627-4140), **CSM** -`src/GameCult.Caching.MessagePack/CultDocumentMessagePackSerialization.cs`, **MESH** -`src/GameCult.Mesh/CultMeshSingleFileDocuments.cs`, **RS** `packages/cultcache-rs/src/lib.rs`, **TS** -`packages/cultcache-ts/src/single-file-messagepack-backing-store.ts`, **PY** -`packages/cultcache-py/src/cultcache_py/stores.py`, **AUTH** `packages/cultnet-ts/src/idunn-runtime-authority.ts`. - -The one door per runtime, and who walks through it: - -| Runtime | The reader | Callers that must use it | -| --- | --- | --- | -| C# | `SingleFileBackingStore.ReadSnapshot` CS:3997 over `ReadDisk` CS:4026 | `PullAllCore` CS:3665, `PushAll` CS:3768, `CommitBatchCore` CS:3799, `ReadDurable` CS:4014, `ReplaceDurable` CS:4016; MESH:164, :195, :245 | -| Rust | `read_store_unlocked` RS:935 (header by `store_header` RS:389) | `read_all_unlocked` RS:924 (`pull_all` RS:1243 and the read-only snapshot), `write_all_unlocked` RS:983, soft `push_all` RS:1268 | -| TypeScript | `readSingleFileStore` TS:153 (bytes by `readStoreBytes` TS:174), exported from `packages/cultcache-ts/src/index.ts:4` | the store's `#readDisk` TS:108 (`pullAll`, `push`, `delete`, `pushAll`); AUTH:321 `readAuthorityRecord` | -| Python | `pull_all` decode path PY:123-140 (`_read_store` PY:265, `_decode_snapshot` PY:296) | `push`, `push_all`, `delete` call `pull_all` (PY:142-152) | - -### A. Header decision (what the file is, and what header a write carries) - -- **Owner.** Read side: the reader in the table above. C#: `CSM.DeserializeSnapshot` :188 (whole-array proof :245-269), then `RequireSingleFileFormat` :273, reached through `SingleFileMessagePackBackingStore.DeserializeSnapshot` CSM:592. Rust: `store_header` RS:389 is the only classifier of leading bytes (it returns `first` and the whole-array proof separately), then `readable_store_format` RS:2890 and `decode_store_file` RS:2901. TS: `decodeStoreFile` TS:423. Python: `_decode_snapshot` PY:296. Write side: the header is derived from what the reader just saw. C#: `HeaderFor` CS:3439, fed by `disk?.FormatVersion` in `PushAll` and `CommitBatchCore`, and by `existing?.FormatVersion` from MESH:247. Rust: `encode_store_snapshot` RS:2793, fed by the `DiskStore` read in `write_all_unlocked` RS:992. TS: `#format`, set by the pre-write read (TS:48-52, :86-100) and used by `encodeSnapshot` TS:136. Python: `_format`, set in `pull_all`, used by `_encode_snapshot` PY:245. -- **Inputs.** The bytes at the path. **Outputs.** The decoded store with header and catalog; or a typed refusal (`CultStoreUnreadableException` in C#; `CultCacheStoreUnreadable{path, kind}` in Rust, kind `Undecodable` or `UnsupportedFormat`; `StoreUnreadableError` in TS and Python). A refusal names a header only as `cultcache.store.v`. -- **Derived state.** The write header is never decided by the writer: it is the reader's verdict (header read, whole-store flag, whether ids or variants are held). A rewrite of a file that cannot be read cannot happen, because the reader throws first. -- **Forbidden writers.** A second header classifier. Deleted: Rust `leading_header`, `read_array_header`, `read_string`; cultnet-ts's own decode of the store header; the TS async `readStore`; Rust `StoreUnreadableError` (negative grep `StoreUnreadableError` in `packages/cultcache-rs`: no match); Python `_decode_v1_snapshot`. -- **Shared paths.** cultnet-ts reaches the header decision only through `readSingleFileStore` (AUTH:4, :321) and checks only record count, schema id and type. cultnet-ts therefore declares cultcache-ts `^0.15.0`, the first release that exports it. -- **Cut line.** `merge-r1` h3 (Rust) and h4 (TS, cultnet-ts); spec `cut-merge-r1.r3` authority map. -- **Pinned by.** `tests/vectors/document-variants-c2a/readability/manifest.txt`, walked by `StoreReadabilityTests.OpenReadsExactlyTheFilesTheVectorsSayItReads` (C#), `CultMeshSingleFileReadabilityTests.AWriteReplacesAFileExactlyWhenItReads` (Mesh), `a_file_is_replaced_exactly_when_it_reads` (RS:5132), "SingleFileMessagePackBackingStore replaces a file exactly when it reads" (TS test :2321) and `test_single_file_replaces_a_file_exactly_when_it_reads` (Python). AUTH cases: `packages/cultnet-ts/test/idunn-runtime-authority.test.ts`. Declared divergences in the manifest: `legacy-envelopes.bin` (C# refuses; the others read and replace it) and `variant-slot-v3.bin` (C# reads; the others refuse). -- **Known gaps.** `variants:follow_up:c0-bad-canonical-in-manifest` (`current-catalog-bad-canonical.msgpack` is not in the manifest; TS reads it, Rust refuses). `variants:follow_up:legacy-vectors-all-runtimes` (the three `legacy-catalog-*` c0 vectors have a verdict only in C# tests; all four runtimes refuse them, probed). `variants:follow_up:range-check-in-ci` (`npm run test:pack:ts` builds every admitted tag and checks exports, but `.github/workflows/publish-packages.yml` does not run it). - -### B. Existence and links (what "nothing at the path" means) - -- **Owner.** C#: `ReadDisk` CS:4026 decides absence from the path's attributes (`-1`), with `PathIsALink` CS:4057. Rust: `is_absent` RS:3049, inside `read_store_unlocked` RS:936-945. TS: `readStoreBytes` TS:174 (the read and the lstat must both find nothing; the lstat is a test seam). Python: `_read_store` PY:265. -- **Inputs.** The path's attributes and the read result. **Outputs.** Absent (an empty, unmarked store), or bytes, or an I/O error. Only nothing at the path is absent. A link whose target is gone is an I/O error in all four runtimes (C#: `IOException` for a file link and for a Windows directory junction, CS:4040-4048; Rust: `io::Error`; TS: an error with code `ENOENT`; Python: `FileNotFoundError` re-raised). -- **Derived state.** Mesh's `FileNotFoundException` is derived from the store reader's `null` (MESH:164, :195); Mesh no longer owns absence. -- **Forbidden writers.** `File.Exists` or any existence gate in MESH (negative grep `File\.(Exists|ReadAllBytes|Delete|Move|WriteAllBytes)|HasOlderCatalogLayout|ReadLegacySchemaCatalogEntry|WriteFileAtomically|ReadSingleFileSnapshot` over MESH: no match); a zero-length-means-absent shortcut; a writer's own read. -- **Shared paths.** Open, flush, commit, `ReadDurable`, `ReplaceDurable`. Rust `pull_all` RS:1243 also checks `is_absent` on the store and on the lock path before it takes the shared lock; that skips lock creation only, and the verdict stays with the reader. -- **Cut line.** `merge-r1` h2 (C#) and h4/h6 (TS `readStoreBytes`); `mesh-single-file-reader` h1. -- **Pinned by.** C#: `StoreReadabilityTests` `ADanglingFileLinkIsAnIoErrorOnOpenNotAnEmptyStore` :208, `ADanglingDirectoryLinkIsAnIoErrorOnOpenNotAnEmptyStore` :185, and the commit variants :196, :219. Mesh: `ADanglingLinkIsAnIoErrorOnTypedWriteRawWriteAndReadNeverAMissingFile` :107 and `OnlyNothingAtThePathIsAMissingFile` :134 (`CultMeshSingleFileStoreTests.cs`). Rust: `a_dangling_symlink_at_the_store_path_is_an_error_and_nothing_is_written` RS:5832. TS: "readStoreBytes reports nothing at the path only when the lstat finds nothing too". -- **Known gaps.** The writer side still tolerates a dangling link: Rust `write_all_unlocked` RS:992-996 and TS `pushAll` TS:94-100 replace it on a whole-store write (`variants:follow_up:writer-dangling-link-tolerance`, owner `c2a-write-set`). What a replace does to a live link is `variants:follow_up:store-replace-cut` item 2. Windows junction behavior was proven at `42f05f66` and `b1ff2dcb`, not at the final head. - -### C. Zero-byte file - -- **Owner.** None separate: a zero-byte file is bytes the one reader cannot decode. C#: `ReadDisk` returns the bytes and `CSM.DeserializeSnapshot` refuses them (the `Length: > 0` shortcut is deleted). Rust: the `store_header` whole-array proof fails, `Undecodable`. TS: `readSingleFileStore` TS:158 wraps the decode error in `StoreUnreadableError`. Python: the `unpackb` failure is wrapped at PY:139-140. -- **Inputs/outputs.** Zero bytes in; a typed unreadable refusal out; every writer leaves the file as it was. -- **Derived state.** None. **Forbidden writers.** Any `length === 0`, `is_empty` or `Length > 0` branch before decode (negative greps in spec `cut-merge-r1.r3`: `Length: > 0 } bytes` in CS, `data.length === 0` in TS). -- **Shared paths.** Open, flush, commit, soft flush, Mesh typed and raw write, AUTH. -- **Cut line.** `merge-r1` h1-h3; ruling `variants:ruling:merge-r1-precedence`. -- **Pinned by.** Manifest row `zero-byte.bin` (refuses x4) in every walk above; Mesh `AReadOfAZeroByteFileIsRefusedAsUnreadableNotAsAMissingRecord` and `AZeroByteFileIsRefusedOnTypedAndRawWriteAndLeftAlone` (`CultMeshSingleFileStoreTests.cs:175`); the AUTH zero-byte case. -- **Known gaps.** None open. - -### D. Directory at the path - -- **Owner.** C#: the explicit clause in `ReadDisk` CS:4034-4035 (a directory that is not a link is an `IOException`; a directory link falls to the catch at CS:4045). Rust: `fs::read` fails with a non-`NotFound` error, kept as `io::Error` (RS:940-944). TS: `readFileSync` throws `EISDIR`. Python: `Path.read_bytes` raises an `OSError`. -- **Outputs.** An I/O error, never an empty store; the directory is untouched and the refusal text does not echo the path. -- **Forbidden writers.** Treating a directory as absent, or creating a store over it. -- **Shared paths.** Open, commit, Mesh read and write. -- **Cut line.** `mesh-single-file-reader` h1 (the C# clause). Rust, TS and Python were correct by construction of their reads. -- **Pinned by.** C#: `ADirectoryAtTheStorePathIsAnIoErrorOnOpenAndOnCommitNotAnEmptyStore` (`StoreReadabilityTests.cs:236`). Mesh: `ADirectoryAtThePathIsAnIoErrorOnReadAndWriteAndIsLeftAlone` (:149). Rust: `a_write_over_a_directory_stops_at_the_read_and_leaves_no_staging_file` RS:5726. -- **Known gaps.** TS and Python have no test for a directory at the store path. No follow-up is registered; the natural home is `write-set-vectors` with the other readability pins. - -### E. Lock - -- **Owner.** C#: `AcquireLock` CS:4082 (`.lock`, `FileShare.None`, 30 s wait), taken by `PushAll` CS:3766, `CommitBatchCore` CS:3795 and `ReplaceDurable` CS:4018, so Mesh writes wait for it. Rust: `with_exclusive_lock` RS:1038 and `with_shared_lock` RS:1031 (`fs2` flock on `.lock`, `open_lock_file` RS:1162), taken by `pull_all` and `push_all`. TS: no cross-process lock; a per-store promise queue (`#enqueue`) only. Python: `threading.RLock` PY:119, in-process only. -- **Inputs/outputs.** A read-modify-write request; the lock is held across the read and the replace for every writer that merges. -- **Derived state.** A writer's header and merge base come from a read taken inside the lock (C# `PushAll`, `CommitBatchCore`, `ReplaceDurable`; Rust `write_all_unlocked`). TS and Python take them from a read outside any cross-process lock. -- **Forbidden writers.** Any Mesh write outside `AcquireLock` (the former `File.Delete` plus `File.Move` writer and its fixed `path + ".tmp"` are deleted). C# readers on open take no file lock (`ReadSnapshot`), and Rust's read-only snapshot takes none by design. -- **Shared paths.** The C# store and the Mesh single-file helpers; the Rust store. -- **Cut line.** `mesh-single-file-reader` h1. -- **Pinned by.** Mesh `AMeshWriteWaitsForTheStoreLock` (`CultMeshSingleFileStoreTests.cs:187`, deterministic) and `ConcurrentMeshWritersNeverErrorAndLeaveAReadableFile` (:261); mutant m3 (`ReplaceDurable` without `AcquireLock`) killed. -- **Known gaps.** TS and Python have no cross-process lock; the mesh spec cites ruling `variants:ruling:write-lock-python-now-ts-later`, and no follow-up in this record carries the remaining TS work. `variants:follow_up:store-replace-cut` item 3: no test that `ReplaceDurable` reads under the lock. Prior art: `docs/research/cross-process-file-locking-prior-art.md`. - -### F. Replace (staging and atomic swap) - -- **Owner.** C#: `WriteSnapshotAtomically` CS:4104 (unique temp `.{name}.{guid}.tmp`, `WriteThrough`, then `File.Replace`, or `File.Move` when nothing is there), called from `WriteSnapshot` CS:4062 and `ReplaceDurable` CS:4016. Rust: `replace_unlocked` RS:1010, `stage_and_replace` RS:3011, `replace_file_atomically` (unix `rename` RS:3095; Windows `MoveFileExW` with retry RS:3106), then `sync_parent_directory` RS:3198; outcomes `Rejected`, `NotReplaced`, `ReplacedNotDurable`. TS: `#writeAll` TS:124-141 and `renameWithRetry` TS:198 (unique temp, no fsync). Python: `_replace_all` PY:154-159 (fixed `.tmp`, `Path.replace`, no fsync). -- **Inputs/outputs.** Encoded bytes in; the destination holds the old bytes or the new bytes, and a failed write removes its staging file (Rust pins the rename-failure path). -- **Derived state.** None. -- **Forbidden writers.** A second replace in a runtime. MESH's `WriteFileAtomically` is deleted; Mesh reaches the replace only through `ReplaceDurable`. -- **Shared paths.** C# cache flush, commit and Mesh writes; Rust `write_all_unlocked`. -- **Cut line.** `mesh-single-file-reader` h1 (C#). Rust's replace predates the campaign; `merge-r1` h3 added its rename fault seam. -- **Pinned by.** Rust `a_write_whose_rename_fails_is_not_replaced_and_leaves_no_staging_file` (seam `WriteStep::Rename` RS:3212). Mesh `ACacheOpeningDuringMeshWritesNeverSeesAnEmptyStore` (:212, Linux only; it skips Windows). -- **Known gaps.** `variants:follow_up:store-replace-cut`: (1) the Windows primitive, decided by open question `variants:question:windows-store-replace-primitive` (probe: `File.Replace` gave 1,722 empty opens in 17,313 under Mesh writers; `MoveFileExW` and POSIX rename gave none; `docs/research/windows-store-replace-prior-art.md`); (2) what a replace does to a live symlink (Mesh pins parity with a cache commit, `AMeshWriteOverALiveLinkLeavesWhatACacheCommitLeaves` :287); (3) a read-under-lock test; (4) a live directory link misreported as unreachable. Python's fixed temp name lets two processes share one staging file (research doc above). Rust's Windows replace loop and its rename fault line are unmutated (h3, undone). - -### G. Soft write decision (a soft flush writes only where nothing is) - -- **Owner.** The one reader decides; the writer does not. TS: `pushAll` TS:79-104 (absent writes; a readable store is left byte for byte; an unreadable one is refused; a dangling link is refused when soft). Rust: the soft branch of `push_all` RS:1268-1280 (`!read_store_unlocked()?.absent` returns). C#: none; `CultMesh`'s `FlushAsync(bool soft)` accepts the flag and drops it (`src/GameCult.Mesh/CultMesh.cs:433-436`). Python: no soft flush. cultmesh-ts passes the flag (`packages/cultmesh-ts/src/index.ts:4073`). -- **Inputs/outputs.** A flush with `soft`; no write for a readable store, a write for an absent one, the reader's refusal otherwise. -- **Derived state.** None. **Forbidden writers.** A soft check that reads the file its own way (TS `readStore` once returned zero bytes as present; deleted in h4). -- **Shared paths.** TS `pushAll` and Rust `push_all` only. -- **Cut line.** `merge-r1` h4 (TS) and h6 (Rust). -- **Pinned by.** The manifest walks run a soft flush over every vector in TS (the `softPushAll` operation, TS test :2336) and Rust (`soft_push_all`, RS:5149), each with an absent and a dangling-link case; `a_soft_push_all_writes_where_nothing_is_and_refuses_a_dangling_link` RS:6019. -- **Known gaps.** C# and Python have no soft decision, and the C# Mesh flag is dead; no follow-up is registered (h6 `undone` names it). `writer-dangling-link-tolerance` applies to the non-soft branch. - -### What no cut owns yet - -`c2a-write-set` replaces `ReplaceDurable` with `ApplyWriteSet` (comment at CS:4012-4013) and decides `writer-dangling-link-tolerance`. `write-set-vectors` owns `c0-bad-canonical-in-manifest` and `legacy-vectors-all-runtimes`. `merge-main` owns `range-check-in-ci`. Imagination owns `store-replace-cut`. diff --git a/docs/document-variants-target.md b/docs/document-variants-target.md deleted file mode 100644 index 0e62ece1..00000000 --- a/docs/document-variants-target.md +++ /dev/null @@ -1,153 +0,0 @@ -# CultCache Document Variants: Target - -Date: 2026-09-17 - -Status: target, before any substrate map or cut map. This document owns the ends. -A cut map, written after an Imagination pass over the Body, will own the means. -Branch: `codex/document-variants`. - -## Why - -A CultCache record today is always complete. To make a bigger laser from a -laser, an author copies the record and re-specifies every stat. For a ship hull -with several hardpoint layouts, every layout is a full copy of the hull. When -the base changes, each copy has to be found and edited by hand, and copies drift -apart silently. - -The first consumer is Aetheria's catalog (`F:\Projects\Aetheria\GameData\Aetheria.cc`), -edited in CultCache Studio: - -- **Hull variants:** one hull with several hardpoint layout options. A variant - replaces the whole `HullData.Hardpoints` member. -- **Item variants:** a bigger laser. A variant changes stats nested inside the - design's behavior list, for example one behavior's `PerformanceStat.Max`. - -## Rulings (operator, 2026-09-17) - -- **This is a CultCache feature, not an Aetheria mechanism.** Operator: "Yes, this - is absolutely a CultCache feature, write it up in CultLib". -- **A variant is stored as a delta from its base and resolved by the cache.** A - record stores a reference to its base plus a sparse set of overrides. The - cache resolves it; readers see complete documents. The operator chose this - over two alternatives. Authoring-only variants in Studio over flattened stored - copies leave a derived cache pretending to be data. Per-type variant records - in each consumer rebuild the feature bespoke for every type. - -## Ends - -- **Readers see complete documents.** `Get`, `GetAll`, lookups by name and by - index, watches and snapshots return resolved documents. No consumer outside - the cache and its authoring tools handles a delta. -- **A base change reaches its variants.** Editing a base changes every variant - that does not override the edited value. Watches, indexes and name lookups - observe that change on the variants too, in the same commit that changed the - base. -- **A variant is a record.** It has its own key and name, and references to it - behave like references to any record. In Aetheria a lot's design and a - product's design can name a variant directly. -- **Studio edits the delta.** It shows which values a variant inherits and which - it overrides, and it can clear an override so the base value applies again. -- **Loading refuses a broken variant loudly and names the records.** Cases: - - a cycle of bases; - - a base that does not exist; - - a base whose type the variant's type cannot inherit from; - - ~~an override naming a member that does not exist on the type~~ **superseded 2026-09-29 - (operator, variants Q4 c): a dangling override soft-drifts like any dropped member, ignored - with a warning; see `document-variants-cut.md` section 4.** - - Deleting a base that still has variants is refused. - -## Invariants that must survive - -- **Wire parity** for the persisted format (`src/GameCult.Caching/Contracts/cultcache-persistence-format.md`, - `docs/persisted-record-encoding.md`). Every runtime that reads a store holding - variants resolves them identically, or refuses the store loudly. Which - runtimes resolve is decided in the map, against - `docs/runtime-parity-scope.md`; none may misread silently. -- **One home store per type**, and atomic single-store commit - (`cultcache-store-composition.md`). A base change and the resulting variant - changes are one commit, not a repair that runs afterwards. -- **Schema compatibility** (`cultcache-schema-compatibility.md`): overrides are - subject to the same semantic identity, soft drift and hard rejection rules as - full records. -- **Compare-exchange** (`Expect`, `ExpectUnchanged`) keeps a single meaning for - variants. The map settles whether it tests the stored delta or the resolved - document; it must not mean both. - -## Fork rulings (operator, 2026-09-17) - -- **1, granularity: stable element identity, ids everywhere** (operator, 2026-09-17: "ids - everywhere"). - - Every object element in a list carries a stable id, minted when the element is created. - This is the approach of sequence CRDTs (RGA, YATA/Yjs, Automerge, Fugue). - - Matching algorithms (Myers, diff3, GumTree) are heuristics. They fail on look-alike - elements such as two `EnergyDraw` behaviors, which is why identity is minted, not - inferred. - - An override addresses an element id plus a member path in CultNet's grammar. An - insertion is a new element anchored after an existing id; a removal names the - removed id. Index addressing is out. - - Rebasing is deterministic. An override whose element id exists in the new base - re-applies. One whose element is missing is an explicit conflict that Studio shows, - to keep, retarget or clear; it is never silently retargeted. - - Existing stores get ids minted once, by a rewrite. -- **2, where resolution lives: at load, kept in memory** (operator: "agreed"). Resolution - computes a variant's complete document from its base chain and its overrides. - - The cache holds both the stored delta and the resolved document. - - A base edit re-resolves its variants inside the same commit, so watches and indexes - observe the change atomically. - - Compare-exchange (`Expect`) tests the stored delta. The resolved document is derived. -- **3, cross-store bases: no.** A variant and its base live in the same store. - *Future direction (operator, 2026-09-30, from Aetheria moddable ships):* "we'll want cross-store variant - support eventually; modders should be able to add variants of existing items without modifying the - original". Ruling 3 holds for this campaign. A mod store layering variants over a shipped catalog is the - named future consumer that would reopen it. Until then, no consumer builds its own cross-store resolver: - Aetheria's compose step stays out of resolution. -- **4, CultNet: deltas.** -- **5, runtimes: C# first.** TypeScript, Python, Rust and Kotlin refuse a store - or snapshot containing variants, loudly, until each implements resolution. -- **6, type change: the same concrete type only** (operator: "agreed"). - - An override can only name members the base type has, and rebasing requires the same - type. - - A variant whose type differs from its base's is refused loudly. - - Subtype variants are parked until real content needs a template base. A record - flagged as a template, not a real item, may be the smaller feature. -- **7, clearing and rebasing.** - - Clearing an override removes that member from the variant's stored delta. A member - that is not overridden is not stored. - - Rebasing (changing a variant's base) is supported. Operator: "rebasing is a nice - tool to have, things can get annoying otherwise". - -## Open forks, for the Imagination pass to map and the operator to rule - -1. **Override granularity.** - - Top-level members are enough for hardpoint layouts. - - A bigger laser needs overrides inside list elements. Addressing list - elements by index is fragile: an insertion into the base silently retargets - every variant's overrides. - - Candidates: stable element identity (for example a behavior's type within its - design); replacing whole list elements only; or addressing paths. - - CultNet's selection work already resolves member paths per leaf type, - inherited members included (`docs/cultnet-selection-cut.md`). A variant's - delta addressing should reuse that grammar, not invent a second one. -2. **Where resolution lives:** at load in the cache core, lazily on read, or as a - materialized view the cache maintains. This affects memory, watch cost, and - the compare-exchange meaning. -3. **Base and variant across stores.** Can a variant in one store name a base in - another (a run-store variant of a catalog record)? This interacts with - one-home-store routing and read-only stores. -4. **CultNet.** Do variants travel as deltas, or resolved? A subscriber that - receives only resolved documents needs no resolver; one that edits needs - deltas. -5. **Runtime scope.** Which of C#, TypeScript, Python, Rust and Kotlin resolve, - and which refuse a store containing variants. -6. **Type change.** May a variant's type be a subtype of its base's type, - adding members, or must the two types match? -7. **Clearing and reparenting.** What clearing an override writes, and whether - a variant can change its base. - -## Not in scope - -- Scaling or formula variants ("every stat times 1.5"). An override states a - value. Generated authoring can compute values. -- Any Aetheria catalog content. Aetheria adopts the feature after a release, as - its own cut. diff --git a/docs/mutation-testing.md b/docs/mutation-testing.md deleted file mode 100644 index 8db67be5..00000000 --- a/docs/mutation-testing.md +++ /dev/null @@ -1,159 +0,0 @@ -# Mutation Testing - -CultLib measures its C# test suites with Stryker.NET, pinned as a repo-local -tool in `dotnet-tools.json`. Coverage is added project by project; a project -with no `stryker-config.json` next to its test project has not been scoped -yet (see "Follow-ups" below for what's outstanding). - -## Running it - -Restore the tool once per checkout: - -```powershell -dotnet tool restore -``` - -Run a full mutation pass from a covered test project's directory, for -example CultMath: - -```powershell -cd packages/cultmath/tests/CultMath.Tests -dotnet stryker -t mtp -``` - -`-t mtp` selects Stryker's Microsoft.Testing.Platform runner. It is required -for test projects on `xunit.v3` (CultMath.Tests is one): Stryker's default -`vstest` runner's coverage capture does not work against xunit.v3's native -test host and the run stalls retrying test sessions indefinitely. Projects -still on `xunit` v2 with `xunit.runner.visualstudio` can use the default -`vstest` runner. - -For a single cut, scope the run to what changed instead of the whole -project: - -```powershell -dotnet stryker -t mtp --since: -``` - -Use a full commit SHA for `--since`, not an abbreviation: `git rev-parse -` first, then pass the full result. Stryker resolves `--since` -through the same git plumbing a short SHA can resolve ambiguously (or fail to -resolve at all) depending on the checkout's object database, and a -misresolved base silently changes what "since" means instead of erroring. - -In a container, also set `git config --global --add safe.directory '*'` -before running Stryker (or any other command that shells out to `git` -against this checkout) - git refuses to operate on a repository owned by a -different user by default, which is the common case for a bind-mounted -checkout in a container. - -Reports land in `StrykerOutput/` next to the test project (git-ignored). -Open the `reports/mutation-report.html` file for a browsable view, or read -`reports/mutation-report.json` for a scriptable one. - -## Triage rules - -The mutation score is not a gate (`break` threshold is 0). Every surviving -mutant is a finding about the tests, not a build failure, and gets triaged -into one of: - -- **missing behavioural test** — name the test that should exist and what - branch, edge case, or component it would exercise. -- **degenerate fixture** — the code path is exercised, but the fixture's - values make two different mutants produce the same observable result (a - zero component that erases a `+`/`-` distinction, an already-normalized - input that erases a `*`/`/` distinction, all-equal or all-same-sign inputs - that erase a boundary or `&&`/`||` distinction). Fix the fixture, don't - invent a new one that only kills that one mutant. -- **equivalent** — the mutant cannot change behaviour. Float-threshold - boundary flips (`>` to `>=`) are equivalent by default. A reasoned - equivalence claim (for example, `>>` and `>>>` on an already-unsigned - operand) needs its one-line reason recorded, not assumed. - -Do not write a hand-rolled mutation suite or anchor test as a substitute. -Where the tool can't reach (native/shader/editor code), the defence is a -behavioural test at the layer the rule is decided, not a committed mutation -harness. - -## Known tool caveat - -Stryker 5.0.0's `mtp` runner is documented as preview. Its per-test coverage -capture was found to report false "Survived" verdicts specifically for -mutations inside `static readonly` field initializers that a test does -cover (confirmed by hand-mutating `bool3.@false` and `bool4.@true` and -running the full suite directly with `dotnet test`, both of which fail -against the mutation that Stryker reported as surviving). Treat a survivor -inside a `static readonly` field initializer as unproven until confirmed -with a direct `dotnet test` run against the same mutation; do not triage it -as a missing test without that check. - -A survivor that looks like it must be covered is unproven until confirmed -with a direct `dotnet test` run against the same hand-applied mutation - but -confirm what the mutant actually is before drawing a tooling conclusion from -it. An earlier pass here reported three survivors in -`CultGeometrySurfaceNets.TryGetOtherEndpoint`'s per-axis `if (x + 1 >= -sizeX) return false;` guards and initially triaged them as a `vstest` -coverage false-survivor (the same shape as the `mtp`/`static readonly` -caveat above). That triage was wrong: the actual mutant Stryker reports -there is `return false` -> `return true` inside the guard, which is -equivalent, not a coverage miss. Returning `true` from -`TryGetOtherEndpoint` still leaves the out `other` coordinate equal to the -current coordinate (see the method: `other` is cloned from `coord` and only -one component is incremented when the method returns `true`), so the caller -compares a sample against itself, the inside/outside flags always match, -and the crossing is skipped exactly as it would have been had the method -correctly returned `false`. No test can distinguish the two branches because -there is nothing to distinguish - it is a legitimate equivalent mutant, not -evidence of a `vstest` false survivor. - -`CultGeometrySurfaceNets.Extract`'s `if (inside == (OrientationSign[axis] < -0))` (the sole authority for quad winding after the geometric cross-product -fallback was deleted) has three mutants on that line: `==` -> `!=`, and `< 0` -negated to `> 0` or widened to `<= 0`. The first two, `inside != (OrientationSign[axis] -< 0)` and `OrientationSign[axis] > 0`, are both reported `Killed`. The third, -`OrientationSign[axis] <= 0`, survives, but it is an equivalent mutant, not a -coverage gap: `OrientationSign` is the fixed table `{ 1, -1, 1 }` and never -holds `0`, so `< 0` and `<= 0` agree on every value the table can actually -produce. There is nothing for a test to distinguish, the same shape as the -`TryGetOtherEndpoint` equivalent mutant above. - -No `vstest` coverage-based false survivor has actually been confirmed for -GameCult.Geometry. Every survivor triaged here so far has turned out to be a -genuine equivalent mutant once hand-mutated and checked directly against -`dotnet test`; treat any survivor that looks like it must obviously be -covered as unproven until confirmed the same way, but do not cite this -project as precedent for the `vstest` caveat itself - that caveat is -`mtp`-runner-specific and documented above for `static readonly` field -initializers, and GameCult.Geometry has never actually hit it. - -## Follow-ups - -CultMath.Tests and GameCult.Geometry.Tests are the only projects currently -scoped. GameCult.Geometry's `stryker-config.json` has no `test-runner` -entry: the project is NUnit 4 with `NUnit3TestAdapter` and -`Microsoft.NET.Test.Sdk`, so Stryker's default `vstest` runner applies -directly (no `mtp` workaround needed, unlike CultMath.Tests's xunit.v3 -suite). - -GameCult.Geometry has only ever been run `--since:`-scoped to the cut that -added surface nets; a full-project baseline (running mutation against all of -`CultGeometryIsoSurface`, `CultGeometryDocuments`, and -`CultGeometryPrimitives`, not just the diff) is a recorded follow-up, not -something either cut did. - -That first `--since` pass did not actually stay diff-scoped: adding -`stryker-config.json` itself in the same cut that first used it made Stryker -log "391 mutants will be tested because: Non-CSharp files in test project -were changed" and mutate the whole `mutate` glob (all four existing -GameCult.Geometry source files), not just the new surface-nets files. A cut -that changes a non-C# file inside the test project (a fixture, this config -file, anything under `Fixtures/`) loses `--since` line-level scoping for that -run; a future cut whose diff is C#-only, against a base commit that already -has `stryker-config.json`, should scope correctly. - -`GameCult.Caching`, `GameCult.Mesh` (+ `.Quic`, `.Quic.Native`), -`GameCult.Networking` (+ `.WebSockets`), and the non-.NET runtimes -(`cultcache-rs/py/ts`, `cultmesh-*`, `cultnet-*`) each still need their own -`stryker-config.json` (or ecosystem-equivalent tool: `cargo-mutants` for -Rust, `StrykerJS` for TypeScript, `mutmut` for Python) and a baseline pass. -None of that is wired into CI yet. diff --git a/docs/nuget-packaging.md b/docs/nuget-packaging.md index ed8746bb..afc94570 100644 --- a/docs/nuget-packaging.md +++ b/docs/nuget-packaging.md @@ -1,8 +1,5 @@ # NuGet Packaging -See `docs/semver-policy.md` for what a version bump on these packages is -required to mean and how a release is checked against that before it ships. - CultLib publishes the managed dependency graph as separate packages. The leaf package is `GameCult.Mesh`; its NuGet dependencies preserve the CultMesh, CultNet, and CultCache ownership boundaries. @@ -11,12 +8,9 @@ CultNet, and CultCache ownership boundaries. powershell -ExecutionPolicy Bypass -File .\scripts\pack-nuget.ps1 ``` -The command packs `GameCult.Mesh`, `GameCult.Networking.WebSockets`, and every -project they reach through `ProjectReference` (including `GameCult.Math`, which -carries its own version) into a local feed under `artifacts/nuget`. It verifies -that each of those packages exists at the identity MSBuild reports for it, then -restores and runs a clean .NET consumer using only -`PackageReference Include="GameCult.Mesh"`. +The command creates a local feed under `artifacts/nuget`, verifies that every +internal dependency package exists at the same version, then restores and runs +a clean .NET consumer using only `PackageReference Include="GameCult.Mesh"`. The Unity distribution remains `org.gamecult.cultlib`, built by `scripts/build-unity-package.ps1`, because Unity consumes the managed assembly @@ -25,5 +19,5 @@ closure through UPM rather than NuGet restore. Install the Unity package from the immutable release tag: ```text -https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.57 +https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.46 ``` diff --git a/docs/research/analytic-integration-feasibility.md b/docs/research/analytic-integration-feasibility.md deleted file mode 100644 index de74e5da..00000000 --- a/docs/research/analytic-integration-feasibility.md +++ /dev/null @@ -1,286 +0,0 @@ -# Analytic noise integration along warped rays: feasibility probe - -Campaign `cultmath-tapes`, Imagination probe, 2026-10-03. This is a measurement, -not a spec. The tape target stays parked under ruling -`cultmath-tapes:ruling:tape-target-unparks-when-asura-stable`. - -**Verdict.** Exact integration of the noise does not beat sampling for optical -depth on either shipped field. -- The exact line integral of CultMath `snoise` is cheap and correct. Affine warp - spans are long, at 100 to 300 world units. -- The exact noise integral is not the optical depth, because both densities are - nonlinear in the noise. - - The void's wall profile is `pow(·, 0.40)` with two clamps. - - Aetheria's fog is clamped at zero and goes opaque within a few world units. -- Given the *exact* span mean of the noise for free, the resulting transmittance - is still 3.6x worse than the shipped march on the void and 22x worse on the - wells. -- Exact integration wins only on the linear functional `∫ n dt` of octaves the - march undersamples. That gain does not survive the density's nonlinearity. -- Aetheria's triangle noise is integrable exactly as piecewise linear, but costs - 3x to 22x the march, and its shipped form does not meet the preconditions. - -## Scenarios and method - -- **Void:** the shipped void (`NoiseBoundTests.VoidField.Shipped()` at - `hands/cultmath-interval-ops` 2c8585bd). - - Rh 198, S 50, Rc 248, K 1/30, A 20, F0 0.01 (cells of 100 and 25 world), warp - D 10. - - The shipped orbiting camera, N = 8 tiles at f = 935, one jittered pixel ray per - tile. -- **Wells:** the test's Aetheria wells at warp D = 60 (`FogField.Wells(60)`). - - F0 1/414.2167, A 20, B 10, extinction 0.5, flow frequency 1/512, period 8. - - Like the test, this uses the snoise field shape (r1's), not Aetheria's own - triangle noise. Triangle noise is measured separately below, on the same rays. -- **Rays:** 200 per scenario, and 120 for the triangle basis. - - The wells give 147 rays with an active interval; the rest look up and miss - the fog. - - The active interval is where the envelope leaves the density to the noise. - It is cut where the true optical depth reaches 6. - - Active length per ray: void median 140 world (p10 114, p90 193); wells median - 268 (p10 137, p90 623). -- **March steps:** the void's march step (LodStep, 12.5 in z) is a median 14.9 - world along the ray. The wells' quadratic grid gives a median of 9.1 in the - active region. -- **Warp:** `w(p) = flow(p) · shift`, so the affine error scales exactly with - `|shift|`. - - Spans are grown at the worst phase shift, Period / 2. A span is therefore - valid at every frame's phase, for any camera that crosses the same world - segment. - - Each span is anchored at p0 with J·d from a central difference. It grows in - 1-unit (void) or 2-unit (wells) steps until `|w − (w0 + J·d·Δ)| > τ`. -- **Exact simplex integral:** CultMath `snoise(float3)` has kernel radius² 0.5, - so its support never leaves the incident simplices. - - Along a line it is therefore a sum over the lattice points within √0.5 of the - line. Each point contributes `∫ (0.5 − |x|²)⁴ (g·x) dt` on its chord, a - closed-form degree-9 polynomial. - - Validation: - - The lattice sum matches `snoise` within 2e-4 (float32 rounding at - coordinates near 300). - - The segment integral matches a 5e-4-step quadrature within 2.5e-5 per - unit length. -- **Run:** probe code was in a scratch clone (probe-clone@91c8cbf1, never merged) - and ran on Yggdrasil through the verify stopgap, in a dotnet 10 container with - 4 CPUs. Timings are single-threaded C# on that host and are relative. - -## 1. Affine-valid span length (ray length, world units) - -| τ (× coverage cell) | Void p10 / median / p90 | Wells p10 / median / p90 | -|---|---|---| -| 0.05 | 94 / 129 / 211 | 71 / 103 / 169 | -| 0.10 | 141 / 197 / 324 | 108 / 151 / 253 | -| 0.25 | 263 / 420 / 1244 | 184 / 275 / 715 | -| 0.05 × detail cell | 44 / 63 / 97 | 34 / 47 / 75 | - -- One affine span at τ = 0.1 covers about 13 void march steps and about 16 wells - march steps. -- The void shell is shorter than one span. The tiled spans are clipped by the - active interval, at a median of 27 world and 2 spans per ray. -- On the wells, the tiled spans run a median of 128 world, with 2 per ray (p90 4). -- The tangent anchor is the worst affine choice. A secant or Chebyshev fit over - the span cuts the error bound by 2x to 8x, so the spans could be about 1.4x to - 2.8x longer at the same τ. That was not measured. - -## 2. Simplex cells per span, per octave - -Octave `xm` is the coverage octave's frequency times m, warped like the coverage -octave. The shipped detail octave is x4 and is *unwarped* in both fields, so it -needs no affine span at all. - -Counts are for τ = 0.1 tiled spans with both warp phases, given as the median and -then the p90. The rows are simplex cells crossed, then lattice points touched, -which is the exact work. - -| Octave | Void cells | Void lattice points | Wells cells | Wells lattice points | -|---|---|---|---|---| -| x1 | 6 / 16 | 10 / 16 | 4 / 8 | 8 / 10 | -| x2 | 8 / 27 | 10 / 26 | 8 / 12 | 10 / 14 | -| x4 | 13 / 52 | 14 / 44 | 12 / 20 | 14 / 20 | -| x8 | 20 / 100 | 20 / 80 | 22 / 38 | 22 / 34 | -| x16 | 40 / 201 | 35 / 154 | 44 / 72 | 38 / 60 | -| x32 | 75 / 396 | 62 / 302 | 86 / 144 | 70 / 112 | -| x64 | 151 / 793 | 118 / 592 | 172 / 287 | 132 / 218 | - -- On the same spans, the march takes a median of 2 samples per span on the void - (p90 10) and 12 on the wells (p90 25). -- A straight line touches 3.44 lattice points per noise unit. - -## 3. Cost: exact against the march - -- **Measured cost.** - - One snoise is 530 to 610 ns in C# on this host. - - One lattice-point integral (hash, gradient, closed-form polynomial) is - 85 ns, or 0.16 snoise. - - With this probe's naive box-scan enumeration it is 1.24 snoise. That is an - upper bound; a simplex walk visits only crossed cells. -- **How the table counts.** Exact is lattice points × 0.16 + 1 snoise per span - for the Jacobian. March is 1 snoise per sample. Both sides carry the two warp - phases. -- **Tolerance.** τ is 0.1 × *that octave's own* cell, so the affine error is - comparable across octaves. -- **Columns.** The two error columns are RMS errors of the active-length mean - of one warped octave. The last error column is what replacing the octave by its - expectation of 0 costs. - -| Octave | Void exact/march cost | Void err exact / march / expectation | Wells exact/march cost | Wells err exact / march / expectation | -|---|---|---|---|---| -| x1 | 0.36 | 1.1e-2 / 1.6e-3 / 0.21 | 0.11 | 1.9e-2 / 9e-5 / 0.29 | -| x2 | 0.46 | 1.0e-2 / 4.7e-3 / 0.13 | 0.15 | 1.5e-2 / 2e-4 / 0.21 | -| x4 | 0.68 | 9.0e-3 / 4.0e-2 / 0.10 | 0.23 | 1.1e-2 / 5e-4 / 0.18 | -| x8 | **1.03** | 5.8e-3 / 8.0e-2 / 0.067 | 0.36 | 7.2e-3 / 1.1e-3 / 0.10 | -| x16 | 1.64 | 4.0e-3 / 9.0e-2 / 0.050 | 0.56 | 6.4e-3 / 9.4e-3 / 0.088 | -| x32 | 2.89 | 2.8e-3 / 0.105 / 0.036 | 0.87 | 4.7e-3 / 3.3e-2 / 0.057 | -| x64 | 5.26 | 2.0e-3 / 0.095 / 0.025 | **1.44** | 3.2e-3 / 5.3e-2 / 0.040 | - -- **Where exact stops paying on cost:** - - At the measured kernel cost: x8 on the void and between x32 and x64 on the - wells. - - At the brief's model of one snoise per cell crossed: about x1 to x2 on the - void and x8 on the wells, from the per-span table in the probe log. -- **Exact against the march on accuracy:** - - At the shipped step the march is *more* accurate for octaves it oversamples: - void x1 to x2, wells x1 to x8. The exact path's error floor is the affine warp - error, about 1e-2 at τ = 0.1 per cell, and it scales with τ. - - Exact is more accurate at about 0.7x the cost where the march undersamples: - void x4 to x8, wells x16 to x32. - - Above about x16 on the void, the undersampled march is worse than simply - using the expectation (0.095 against 0.025 at x64). That is a band-limiting - result, which the footprint octave weights already exploit. It is not an - exact-integration result. - -## 4. High-octave variance over a span - -- **Span-mean statistics.** Over straight lines of noise length ℓ, the std of - the snoise span mean, against a point std of 0.358, is: - - 0.234 at ℓ = 1; - - 0.170 at ℓ = 2; - - 0.121 at ℓ = 4; - - 0.087 at ℓ = 8; - - 0.061 at ℓ = 16; - - 0.031 at ℓ = 64. - - This is about ℓ^-0.5: the high octaves average out like a random field, not - like a periodic one. -- **Detail octave replaced by its expectation of 0,** on τ = 0.1 spans, measured - as |ΔOD| per span: - - Void: median 0.000 and p90 0.091. Relative to the span's OD (OD > 0.01) the - median is 2.5% and the p90 is 7.6%. The mean detail displacement is a median - 1.0 world (p90 3.6) against the ramp width S = 50. - - Wells: median 0.11 and p90 5.7 optical depths. The relative median is 72%. -- **Why the wells are so bad.** Normalised to the clamp, the density moves - A·fade/B = 2 per unit of noise, and with extinction 0.5 that is 1 optical depth - per world unit per unit of noise. The mean detail displacement of 1.5 world - (p90 3.8) is 15% to 38% of the floor blend B = 10. The wells' optical depth is - set by where the clamp boundary lies, and that is exactly what the expectation - erases. -- So the expectation is adequate for the void's detail octave and is not - adequate for the wells. - -## 5. The clamp and other nonlinearity - -- **Void.** 50.0% of τ = 0.1 spans cross a regime boundary: 0 (d' ≤ Rh), the - wall ramp, or K (d' ≥ Rc). 45.6% of the active length lies in the ramp, where - the density is `K max(0, 1 − 1.5 (1 − (d'/Rc)²)^0.40)`. That is not a - polynomial in n, so exact ∫n does not give ∫ρ there. Outside the ramp the - density is constant and needs no noise. -- **Wells.** 42.3% of spans cross the clamp. Only 9.8% of the active length is - unclamped, so most of the length where the noise "matters" is length where the - noise only decides whether the density is zero. -- **The decisive check: transmittance error.** This is the sup over the ray of - |T_est − T_true|, with the truth taken on a 0.5- or 1-unit grid. - - | Estimator | Void median / p90 | Wells median / p90 | - |---|---|---| - | Shipped march | 0.020 / 0.038 | 0.033 / 0.155 | - | March at 4x density | 0.006 / 0.009 | 0.030 / 0.049 | - | Density of the *exact* span-mean n (τ = 0.1 spans) | 0.072 / 0.125 | 0.719 / 0.997 | - - The last row is an upper bound on what any exact-mean method can deliver - without also modelling the distribution inside the span. It is the - Heitz-style correction the survey describes. It loses to the march on both - fields. - -## Triangle basis (operator's addition) - -The triangle noise is `triNoise3d` in Aetheria `Assets/Shaders/Volumetric.cginc` -(origin/master f1dee184). -- `tri(x) = |frac(x) − 0.5|`. -- It runs two Nimitz-style iterations. Each iterates `p += tri3(bp·2)`, scales - `bp` by 1.8 and `p` by 1.2, and adds `tri(p.z + tri(p.x + tri(p.y)))/z`. -- It makes 18 tri calls per evaluation. - -As shipped, `density()` uses it as follows: -- `pow(triNoise3d(·), exponent)`, with Noise.Exponent −0.25 multiplied by a - slope `flatness` read from a texture (NOISE_SLOPE is on). -- Two phases, warped by `globalFlow`, which is - `Tri3D = cross(normalize(tri3(P)), normalize(tri3(1.618P))) × 15`. -- The fine octave at ×8 is evaluated at a `pos` whose y the coarse octave has - already displaced. -- Amplitude −36.17. - -Self's reading, tested: - -- **"The warped ray is an exact polyline."** This holds for the warp *inside* - `triNoise3d`. It does not hold for Aetheria's flow: `normalize` and `cross` - make the flow piecewise rational. With the normalize dropped, the cross product - of two piecewise-linear vectors is piecewise quadratic. tri composed with a - piecewise polynomial stays piecewise polynomial of the same degree, with - breakpoints at quadratic roots, so that variant is still closed-form. - Counted along the real flow at the worst shift, the kinks run 15% to 30% above - the straight-ray counts, but the pieces between them are curved. -- **"The clamp roots are linear."** This holds only if the exponent is 1. With - −0.25·flatness, each piece is `(a + bt)^e`. One such piece has a closed-form - integral, but the clamp's root on a sum of two powered phases plus the - smoothstep fade has none. -- **"Whole periods give the exact mean."** This holds for one triangle wave at - whole periods, where the mean is exactly 0.25. It fails for the composed form, - which has no period along a general line; the scales 2, 1.8 and 1.2 and the - nested warp are incommensurate. - - Measured on lines, the span-mean std of `triNoise3d` is 0.029 at ℓ = 1, - 0.010 at ℓ = 8 and 0.0042 at ℓ = 64, against a point std of 0.083. That is - about ℓ^-0.47, the same random-field decay as simplex. - - Its bias against the global mean of 0.1995 is within ±0.0015, so the - expectation is unbiased. It is not exact. -- **The cost decides it.** The exact piecewise-linear walk is verified, matching - a 1e-4 quadrature within 3.4e-8. But the nest has 77.7 linear pieces per noise - unit of straight line, against 3.44 lattice points for simplex. - - One piece costs 1.38 point evaluations with a derivative carried. - - At Aetheria's scale, on the wells rays, the pieces per world unit and the - exact cost relative to the march are: - - | Octave | Pieces per world unit | Exact cost / march | - |---|---|---| - | x1 | 0.20 | 2.8x | - | x2 | 0.38 | 5.5x | - | x4 | 0.76 | 11x | - | x8 (shipped fine) | 1.5 | 22x | - | x64 | 12 | 176x | - - - On the void rays it is 4.1x at x1 and 29x at x8. - - At the same time the march's RMS error on the span mean is already small: - 2.4e-3 at x1 and 1.7e-2 at x8. - -## Per-basis verdict - -| Basis | Exact line integral | Under the shipped warp | Optical depth | Verdict | -|---|---|---|---|---| -| Simplex (CultMath `snoise`) | Closed form, 0.16 snoise per lattice point, 3.44 points per noise unit; validated | Affine spans of 100 to 300 world at τ = 0.1 cell; error floor about 1e-2 | Not delivered: the void's pow profile and the wells' clamp make ρ nonlinear in n; the exact-mean transmittance loses 3.6x and 22x | **Viable kernel, wrong target.** Pays only if the density were affine in n over the span, or as a control variate for a march (survey §4, Kettunen 2021) | -| Triangle (`triNoise3d`) | Closed form per linear piece; validated | Not piecewise linear under Aetheria's normalized-cross flow or the −0.25 power; made linear by exponent 1 and a non-normalized flow | Same nonlinearity, plus 78 pieces per noise unit | **Loses.** 3x to 22x the march even where its preconditions hold | -| Gabor kernels (survey §1.2, not probed) | Closed form for any affine-transformed kernel (complex erf, at most 16 terms) | The affine warp spans above transfer directly, with each span a whitening transform | Same density-nonlinearity limit | **Candidate smooth basis for large structure**, to be measured only if the density is first made linear in the noise over a span | - -## What would change the verdict - -- **A density that is affine in the noise inside a span.** For example, the - void's ramp replaced by a linear ramp in d', with clamp crossings bracketed by - the interval bound. Exact simplex integration would then deliver optical depth - directly in the 54% of void length that is outside the ramp's clamps. As - measured, that 54% is constant density and needs no noise at all. -- **Exact integration as a control variate,** not a replacement. The exact mean - is cheap and unbiased for ∫n, and the march corrects the nonlinear residual. - That is the Kettunen construction. It was not measured here. -- **Wider skipping.** The operator's first idea, skipping space outside the warp - range, is already what the interval envelope does, and the probe's active - intervals are its output. - - On the void the noise matters over only about 140 world per ray. - - On the wells, opacity ends the ray within a few world units of entering the - unclamped region. diff --git a/docs/research/analytic-noise-integration-prior-art.md b/docs/research/analytic-noise-integration-prior-art.md deleted file mode 100644 index 44810215..00000000 --- a/docs/research/analytic-noise-integration-prior-art.md +++ /dev/null @@ -1,425 +0,0 @@ -# Analytic Noise Integration Along Warped Rays: Prior Art Survey - -This is the facts file for an idea the operator raised on 2026-10-03: - -> "I would be happy if we could just skip the space we know has no meaningful structure -> because it's outside of the noise warp range. But what you said about affine arithmetic -> makes me wonder if we can somehow, even within the distorted domain, figure out a series -> of optimal (in terms of extracting structure over multiple frames) spans for which we can -> analytically integrate the noise gradients over those ray segments." - -Self's sketch, as given to this pass: - -- Simplex noise along a straight ray is piecewise polynomial in t, so its line integral - is closed-form per crossed cell. -- A domain warp p + w(p) is nearly affine over a short span, with an affine-arithmetic - error bound, so within that span the warped ray is a straight line in noise space. -- Low octaves are integrated exactly. High octaves are replaced by their expectation, - with a variance bound. -- Clamped density max(0, n - c) is integrated by root-finding per piece. -- Spans are cached and refined across frames. - -Eyes pass, 2026-10-03. This file gives facts and evidence pointers only. It makes no -recommendation. - -Verification marks: - -- **[fetched]** The claim was read in the cited source's full text during this pass. - PDFs were converted with `pdftotext -layout`. -- **[search]** The claim came from a search-result summary or abstract, not a full read. -- **[derivation]** The claim is elementary mathematics worked out in this pass from a - fetched definition. It is not a claim made by any cited source. -- **[not found]** The pass searched for this kind of work and found nothing. - -## 0. Premises of the sketch, checked against definitions - -- **[fetched] + [derivation]** Simplex noise kernel degree. Gustavson, *Simplex noise - demystified* (2005), gives the 3D reference code. Each of the four simplex corners - contributes `t^4 * dot(g, d)` with `t = 0.6 - |d|^2`, and the contribution is zero - when `t < 0`. On a straight ray `d` is affine in the ray parameter, so `|d|^2` is - quadratic and each corner term is a polynomial of degree 8 + 1 = 9. The pieces have - two kinds of breakpoint: the simplex faces the ray crosses (where the corner set - changes), and the entry and exit of each corner's support sphere (`|d|^2 = 0.6`). - Both kinds are roots of polynomials of degree 2 or lower in the ray parameter, so the - breakpoints are closed-form. With the 0.6 radius, the support extends past the - simplex, and the reference code truncates it at the simplex boundary. The resulting - small discontinuity across faces is a known property of that constant. It does not - change the piecewise-polynomial structure. -- **[derivation]** Classic Perlin noise (Perlin 2002 quintic fade `6t^5 - 15t^4 + 10t^3`, - read in Gustavson's text **[fetched]**) is, within one lattice cube along a straight - ray, a polynomial of degree 3 x 5 + 1 = 16. Its breakpoints are the cube faces. -- **[fetched]** Piece count grows with frequency. Balint (CESCG 2019, section 2) - states that many noise functions are piecewise integrable, but the number of pieces - is linear in the noise frequency. Their cost is therefore similar to numerical - integration. Balint designed cosine noise to escape this limit (section 1.1 below). -- **[derivation]** For the clamp `max(0, n - c)` on a degree-9 or degree-16 piece, - the roots of `n - c` are needed. Polynomials of degree 5 or more have no general - closed-form roots (Abel-Ruffini), so the clamp needs numerical root isolation per - piece, for example Sturm sequences, Descartes' rule or Bernstein-basis subdivision. - The integral between the isolated roots is closed-form. - -## 1. Closed-form line integrals of noise, and analytic optical depth - -### 1.1 Cosine noise: Balint, *Closed Form Transmittance in Heterogeneous Media Using Cosine Noise*, CESCG 2019 (non-peer-reviewed) - -- **[fetched]** It computes noise defined as an offset plus a sum of cosines of - `x . S_i`. The paper uses 24 quasirandom vectors S_i, with Sobol directions on the - sphere and lengths in [0.8, 1.2], to look roughly like Perlin noise. Fractal octaves - are further cosine sets. Its line integral is a sum of sines, so the optical depth - over any segment is exact. The paper says this takes two noise samples, one at each - segment end. It also gives closed-form distance sampling, by inverting the integral - with binary search. -- **[fetched]** Cost: two noise-sized evaluations per segment, independent of octave - count. Table 1 reports transmittance evaluation at 179 ms closed-form against - 1250 ms for delta tracking, about 7x faster. A real-time demo with 16 samples ran - at 80 fps at 675 x 1200 (RTX 2080 Ti). -- **[fetched]** Error: exact, with no error term, for the bare sum. The limits are - stated in section 6. Multiplying by a shape function, or composing with a shaping - function, generally destroys the elementary antiderivative. The workarounds - recover exactness only piecewise: constant multipliers between bounding isosurfaces, - or a cubic polynomial interpolant of the multiplier along the ray, since the product - of a polynomial and cosines has an elementary antiderivative. Negative densities from - a low offset are handled by clamping samples and integrals, which is not an exact - `max(0, .)` integral. Domain warp is not discussed. - -### 1.2 Gabor kernels: Condor, Hermann, Yurtsever, Didyk, *Gabor Fields: Orientation-Selective Level-of-Detail for Volume Rendering*, ACM TOG 45(4) art. 62, 2026 (arXiv 2602.05081) - -- **[fetched]** It computes closed-form definite line integrals of anisotropic 3D Gabor - kernels along an arbitrary ray segment (eq. 9). Each kernel is whitened into its - canonical space with a ZCA matrix, so any covariance, that is any affine-transformed - kernel, uses the same formula. The segment integral is the real part of a - complex-erf (Faddeeva) difference. -- **[fetched]** Cost: the complex erf is evaluated by a truncated Taylor series with - early exit, capped at 16 terms. Segments shorter than 1e-4 in whitened units fall back - to a single midpoint evaluation. Kernels are spatially clamped with an adaptive extent - that shrinks with frequency (eq. 15). The paper also renders procedural clouds as - Gaussians modulated by Gabor noise. -- **[fetched]** Error: each segment integral is exact apart from the erf truncation. - Orientation-selective masking of kernels whose line integral is near zero trades a - small error, or variance under stochastic selection, for speed. The paper reports - about 1.78x to 1.96x speedups. Per segment the density-integral estimator is - unbiased, but transmittance is biased by Jensen's inequality. Eq. 19 gives the - second-order bias as `0.5 * Var(tau) * exp(-E[tau])`. - -### 1.3 Analytically integrable media, older - -- **[search]** Iser, *Real-time Light Transport in Analytically Integrable - Quasi-heterogeneous Media*, CESCG 2018. Balint cites it **[fetched]** as using only - exponential and spherical density functions. -- **[fetched via Gabor Fields related work]** The closed-form Gaussian-primitive - transmittance line (Knoll et al. 2021; Condor et al. 2025, *Don't Splat your - Gaussians*) is the base that Gabor Fields extends. - -### 1.4 Piecewise-polynomial segment integration in scientific volume rendering - -- **[fetched]** Engel, Kraus, Ertl, *High-Quality Pre-Integrated Volume Rendering Using - Hardware-Accelerated Pixel Shading*, Graphics Hardware 2001. The scalar field along - the ray is assumed piecewise linear between samples. The volume rendering integral of - each linear segment, through an arbitrary nonlinear transfer function, is then one - lookup in a table indexed by front scalar, back scalar and segment length. Cost: one - texture lookup per segment, plus recomputing the table when the transfer function - changes. Error: exact for the piecewise-linear model. The model error is the - scalar field's deviation from linear between samples. -- **[search]** Williams, Max, Stein, *A High Accuracy Volume Renderer for Unstructured - Data*, IEEE TVCG 4(1), 1998. Exact integration through tetrahedra with linearly - varying scalar and piecewise-linear transfer functions. - -### 1.5 Polynomial noise along a ray - -- **[not found]** No published closed-form segment integral of Perlin or simplex noise - was found, as a method or a code library. Balint's remark in section 0 is the only - published statement found on the piecewise approach, and it dismisses it on cost - grounds. - -## 2. Noise designed for analytic filtering or integration - -- **[fetched]** Lagae, Lefebvre, Drettakis, Dutré, *Procedural Noise using Sparse Gabor - Convolution*, ACM TOG 28(3), 2009. It computes a sparse-convolution noise of Poisson - impulses with Gabor kernels. Each kernel is a Gaussian in frequency, so filtering with - a Gaussian pixel filter multiplies Gaussians, which gives an analytically filtered - kernel. Cost: the paper typically uses 100 impulses per kernel, or 25 to 50 at lower - densities. Table 2 (GTX 280) reports, at 20 impulses per cell, 290 fps for 2D noise, - 111 fps for unfiltered surface noise and 50 fps for filtered surface noise. Error: - the filtering is exact for a Gaussian filter. The noise statistics converge with - impulse density. -- **[fetched]** Lagae, Drettakis, *Filtering Solid Gabor Noise*, ACM TOG 30(4), 2011. It - slices solid Gabor noise, filters each slice of each Gabor kernel, and gets a - generalisation of the projection-slice theorem. It also states that wavelet noise - integrates solid noise perpendicular to the surface. That is a line integral of noise - along the normal, done in the basis. -- **[search]** Cook, DeRose, *Wavelet Noise*, ACM TOG 24(3), 2005. A quadratic B-spline - noise band, which is almost band-limited, built from a precomputed coefficient tile. - Its 3D-to-surface projection integrates the noise along the normal. The original PDF - was not retrievable in this pass. Pixar and ACM both returned HTML. -- **[fetched, survey]** Lagae et al., *A Survey of Procedural Noise Functions*, CGF 2010. - - Lewis's sparse convolution noise has a power spectrum equal to the kernel's, - scaled. - - Frequency clamping (Norton, Rockwood, Skolmoski 1982) cancels bands above the filter - rate. It works only for narrowly band-pass noise, and Perlin noise is only weakly - band-pass. - - Nonlinear functions of noise, such as thresholds and colour maps, are not filtered - by filtering the noise. That is unsolved in general. - - Heidrich, Slusallek, Seidel 1998 (below) computes an area average of a procedural - shader with an error bound, using affine arithmetic. - - Perlin noise's amplitude distribution is visibly non-Gaussian, because it is zero at - every lattice point and has few gradients. The other noises surveyed are - approximately Gaussian. -- **[fetched, via the survey above]** "Filtering procedural textures" lineage: - - Rhoades et al. 1992 filters the colour table over `[N - e, N + e]`. - - Hart et al. 1999 sets `e` from the local noise gradient. - - Lagae 2009 sets the range from the analytically known loss of variance. - -## 3. Affine arithmetic, reduced AA, Taylor models, and bounds on warps - -### 3.1 Gamito and Maddock - -- **[fetched]** Gamito, Maddock, *Ray Casting Implicit Fractal Surfaces with Reduced - Affine Arithmetic*, The Visual Computer 23:155-165, 2007. The full method is read in - Gamito's PhD thesis (Sheffield), sections 5.3 to 5.4. - - **Computes:** a root of `g(t) = 0` along a ray, by subdividing intervals of t. Each - interval is tested with an inclusion `G(T)` computed in reduced AA (Messine's AF1). - The form is `t0 + t1 e1 + t2 e2`: e1 is the shared ray-parameter symbol, and e2 - absorbs every new nonlinearity by condensation after each operation. - - **Noise in RAA:** gradient-noise kernels lose no correlation under RAA, because the - three multiplications are local to one kernel and the cubic Hermite fade is done by - a single Chebyshev affine approximation. The same holds for sparse convolution - noise. Cellular noise loses accuracy, because `min` needs cancellation between - condensed terms, and the F2 and F3 kernels were not implementable. - - **Interval optimisation:** the parallelogram `g1/t1` slope plus or minus `g2` - shrinks `[ta, tb]` before subdividing (eq. 5.27). - - **Cost:** Table 5.2, gradient-noise hypertexture, average evaluations per ray and - time: - - | Method | Evaluations per ray | Time | - |---|---|---| - | IA | 116.57 | 7m35s | - | Standard AA | 61.69 | 40m41s | - | RAA | 61.69 | 6m43s | - | RAA + interval optimisation | 46.39 | 5m04s | - - RAA costs three numbers per quantity against two for IA. Standard AA is tight - but slow because its error-symbol lists grow. - - **Error bound:** conservative inclusion, as proven for AA by Comba and Stolfi 1993. - Rounding error is ignored. -- **[fetched]** Gamito thesis, chapter 9, *Surface Deformation with Flow Mapping*. - - Domain deformation `f(d(x))` with `d` defined by streamlines, that is by an ODE. - This is the case closest to a domain warp in this survey. - - Gamito states that a robust and tight AA estimate of the deformed ray `s(t)` was not - obtainable through the numerical ODE solution, so robustness was given up. - - The replacement test uses Lipschitz unbounding spheres at `s(ta)` and `s(tb)`. A - span is skipped if `|s(tb) - s(ta)| < min(ra, rb)` (eq. 9.23). A sharp turn of the - deformed ray between the endpoints can make this test wrong. - - He names truncated Taylor-series range estimation (Nedialkov et al. 2004) as the - possible fix, at higher cost and complexity. - -### 3.2 Other affine and interval arithmetic sources - -- **[fetched, bibliographic]** Comba, Stolfi, *Affine Arithmetic and its Applications to - Computer Graphics*, SIBGRAPI 1993. de Figueiredo, Stolfi, *Affine Arithmetic: Concepts - and Applications*, Numerical Algorithms 37, 2004. Gamito cites both. AA keeps - first-order correlations through shared noise symbols. Each nonaffine operation adds - one symbol, whose coefficient bounds the linearisation error. Chebyshev or min-range - affine approximations give that coefficient for unary functions. -- **[search]** Knoll, Hijazi, Kensler, Schott, Hansen, Hagen, *Fast Ray Tracing of - Arbitrary Implicit Surfaces with Interval and Affine Arithmetic*, CGF 28(1), 2009. - Inclusion-preserving reduced AA, SIMD CPU at interactive rates, and a stackless GPU - version. -- **[fetched, abstract]** Fryazinov, Pasko, Comninos, *Fast Reliable Ray-tracing of - Procedurally Defined Implicit Surfaces Using Revised Affine Arithmetic*, Bournemouth - TR-NCCA-2009-04. Revised AA, which also keeps one accumulated error symbol, is - reported fastest among the IA and AA variants compared, including on pseudo-random - procedural objects. -- **[fetched]** Sharp, Jacobson, *Spelunking the Deep: Guaranteed Queries on General - Neural Implicit Surfaces via Range Analysis*, ACM TOG 41(4), 2022. This is AA through - long compositions of nonlinear layers, which is structurally like noise composed with - a warp. Table 1 compares the variants. Time is relative to one scalar evaluation, - length is the 1D region that can be certified, and raycast time is relative to the - best method: - - | Variant | Time | Length | Raycast time | - |---|---|---|---| - | Interval | 2.4x | 0.011 | 34.3x | - | Affine-full | 95.3x | 0.821 | 8.4x | - | Affine-fixed (no new symbols kept, extra error condensed into one) | 4.7x | 0.306 | 1.0x | - - The paper uses affine-fixed for ray casting and affine-full for 3D queries. -- **[fetched, survey quote of abstract]** Heidrich, Slusallek, Seidel, *Sampling of - Procedural Shaders using Affine Arithmetic*, ACM TOG 17(3):158-176, 1998. It computes - the average of a procedural shader over a finite area, with an AA error bound. -- **[fetched, project page]** Keeter, *Massively Parallel Rendering of Complex - Closed-Form Implicit Surfaces*, ACM TOG 39(4), 2020. Interval arithmetic over a - shallow, high-branching tile hierarchy does two things: it skips empty tiles, and it - prunes the expression tape per tile. One benchmark drops the expression size by about - two orders of magnitude. It requires only C0 continuity, so warps and blends that break - Lipschitz continuity are allowed. - -### 3.3 Lipschitz bounds through warps - -- **[fetched]** Galin, Guérin, Paris, Peytavie, *Segment Tracing Using Local Lipschitz - Bounds*, CGF 39(2), 2020. It computes a local Lipschitz bound over a ray segment - instead of a global one. Section 4.4 covers warps `f o w^-1`, and bounds the gradient - by the product of the field gradient bound over the transformed segment and the - Jacobian norm bound over the segment. Cost: fewer field queries than sphere tracing, - with no acceleration structure. Error: conservative, if the local bounds are - conservative. -- **[fetched]** Seyb, Jacobson, Nowrouzezahrai, Jarosz, *Non-linear Sphere Tracing for - Rendering Deformed Signed Distance Fields*, ACM TOG 38(6), 2019. - - **Computes:** the ray in deformed space as a curve in undeformed space, by - integrating an ODE whose derivative is the inverse-deformation Jacobian times the ray - direction. An initial value comes from rasterising a deformed hull mesh. - - **Error control:** step requirements for the curve are separated from those for the - SDF. Adaptive Runge-Kutta (RKF45 and DP54 evaluated) is used far from the surface, - and forward Euler near it, against an error tolerance. - - **Scope:** surfaces only. There is no density integration. -- **[fetched]** Moinet, Neyret, *Fast Sphere Tracing of Procedural Volumetric Noise for - Very Large and Detailed Scenes*, CGF 2025 (Eurographics), HAL hal-05046040. - - **Computes:** sphere tracing of FBM density fields, using first- and second-order - (2-Lipschitz) forward inclusion functions. The FBM partial sums act as a nested - bounding volume hierarchy: the remaining octaves are bounded by their amplitude sum - `s(i+1, n)`, so evaluation stops early once a point is provably outside. - - **Cost:** up to 12x faster than classical sphere tracing on opaque or constant-density - scenes. Only up to 1.8x on non-constant density, and that gain comes from empty-space - skipping alone. One example frame: 16 ms against 110 ms naive at 1024 x 1024 on a - 4080 Ti. - - **Stated limits:** FBM used as a domain warp is not supported, nor are nonlinear - transforms of FBM. The paper names analytic estimation of the contribution of - sub-pixel detail as an open problem. - -### 3.4 Taylor models - -- **[search]** Berz, Makino, *Verified Integration of ODEs and Flows Using Differential - Algebraic Methods on High-Order Taylor Models*, Reliable Computing 4, 1998. Makino, - Berz, *Taylor Models and Other Validated Functional Inclusion Methods*, IJPAM 2003. - - **Computes:** a Taylor model is a polynomial of order n plus an interval remainder - bound, which encloses any function given as code over a box. The sharpness of the - remainder scales with the box width to the power n + 1. The method also gives - verified ODE flows. - - **Verified integration:** Berz and Makino also published *New Methods for - High-Dimensional Verified Quadrature* (Reliable Computing 1999). There the integral - of the polynomial part is exact, and the remainder bound times the domain measure - bounds the error. - - First-order AA is the n = 1 case in spirit: an affine part plus a bounded remainder. - -### 3.5 Affine bound on a warp over a span - -- **[derivation]** Over a segment of half-length r, the best affine approximation - (Chebyshev) of a C2 coordinate function has sup error at most `r^2 / 4` times the - maximum of its second derivative along the segment. Linear interpolation of the - endpoints has `r^2 / 2` times that maximum. The noise error caused by a displacement - error of size `delta` is at most `L_noise * delta`. This is the same chain-rule - structure Galin uses in section 4.4. - -## 4. Statistical or expected-value treatment of high-frequency detail - -- **[fetched]** Heitz, Nowrouzezahrai, Poulin, Neyret, *Filtering Color Mapped Textures - and Surfaces*, I3D 2013. It computes the filtered value of a colour map applied to a - procedural function as ``. The noise's footprint distribution is - replaced by a Gaussian with the footprint's mean and variance. This equals the colour - map convolved with `N(0, sigma^2)` and evaluated at the mean, which is precomputed into - a 2D table indexed by (mu, sigma). Cost: one lookup after mu and sigma are computed. - Error: exact when the driving function's footprint distribution is Gaussian. For a - specific noise instance it converges as the footprint grows, and the paper states this - limit. -- **[derivation]** For `X ~ N(mu, sigma^2)`, `E[max(0, X - c)] = (mu - c) Phi(z) + - sigma phi(z)` with `z = (mu - c) / sigma`. This is the rectified-Gaussian mean, and the - scalar instance of the Heitz 2013 construction for the map `max(0, . - c)`. The - survey's fetched finding that Perlin noise is non-Gaussian bears on how accurate it is. -- **[search]** Olano, Baker, *LEAN Mapping*, I3D 2010. Dupuy et al., *LEADR Mapping*, ACM - TOG 32(6), 2013. They store the first and second moments of slopes in mipmaps. Linear - filtering of the moments gives a Gaussian or Beckmann slope distribution per - footprint. Cost: two extra texture channels and linear filtering. Error: the Gaussian - assumption. -- **[fetched]** Gabor Fields (1.2): band and orientation masking of high-frequency - kernels, with the Jensen bias of transmittance `~ 0.5 Var(tau) exp(-E[tau])`. -- **[search]** Vicini, Jakob, Kaplanyan, *A Non-exponential Transmittance Model for - Volumetric Scene Representations*, ACM TOG 40(4), 2021. Bitterli et al., *A Radiative - Transfer Framework for Non-exponential Media*, ACM TOG 37(6), 2018. Jarabo, Aliaga, - Gutierrez 2018, arXiv 1805.02651. Unresolved, correlated sub-voxel density makes - transmittance non-exponential. Positive correlation gives slower decay than exponential. -- **[search]** Kettunen, d'Eon, Pantaleoni, Novák, *An Unbiased Ray-Marching - Transmittance Estimator*, ACM TOG 40(4), 2021. A power-series estimator built around a - control variate. The control variate is a ray-marched mean-density estimate, and rare - higher-order terms remove the bias. It is relevant as the known way to make a - deterministic or expected-value optical depth unbiased. -- **[fetched]** Schneider, *The Real-time Volumetric Cloudscapes of Horizon: Zero Dawn*, - SIGGRAPH 2015 Advances course. The high-detail noise is applied only as erosion where - the low-detail sample is non-zero. Rays take cheap large steps until the low-detail - isosurface is hit, step back once, and then take full samples. After several zero - samples they return to cheap stepping. This is an octave-level skip heuristic with no - bound. Moinet (3.3) is the bounded version for FBM. - -## 5. Temporal reuse of per-pixel or per-tile raymarch structure - -- **[fetched]** Schneider 2015 (above). The full raymarch cost about 20 ms. Each frame - renders 1 of 16 pixels per 4 x 4 block into a quarter-resolution buffer, and - reprojects the previous frame. Where reprojection fails, for example at screen edges, - a low-resolution buffer is substituted. The paper reports 10x or more faster, with a - target of about 2 ms on PS4. -- **[search]** Klein, Strengert, Stegmaier, Ertl, *Exploiting Frame-to-Frame Coherence - for Accelerating High-Quality Volume Raycasting on Graphics Hardware*, IEEE - Visualization 2005. First-hit depths of the previous frame are reprojected by point - splatting to estimate per-pixel ray start points. About 2x on typical datasets. -- **[search]** Yagel, Shi, *Accelerating Volume Animation by Space-Leaping*, IEEE - Visualization 1993. A C-buffer of first non-transparent voxel coordinates, updated - across frames. Gudmundsson, Randén 1990 introduced inter-frame empty-space skipping. -- **[search]** Scherzer et al., *Temporal Coherence Methods in Real-Time Rendering*, - CGF 2012 STAR (Eurographics 2011). Reprojection caches, with depth-tolerance validity - tests for disocclusion. -- **[search]** Hillaire, *Physically Based Sky, Atmosphere and Cloud Rendering in - Frostbite*, SIGGRAPH 2016 course. Temporal reprojection for volumetric clouds. Details - were not read in this pass. -- **[fetched]** Gamito thesis, chapter 7: progressive refinement rendering of - Lipschitz-bounded and AA-bounded surfaces. It refines across passes within one image, - not across animated frames. -- **[not found]** No source was found that caches per-ray span partitions, affine - forms or certified intervals across frames and refines them. - -## 6. Warp linearisation combined with exact segment integration - -- **[not found]** No source was found that combines piecewise affine linearisation of a - domain warp, with an error bound, and exact closed-form integration of noise over the - resulting segments. -- Nearest pieces, each covering part of the combination: - - | Source | What it covers | What it leaves out | - |---|---|---| - | Gamito ch. 9 | Bounding a deformed ray | No integral. AA gave up on the ODE warp | - | Seyb 2019 | ODE curved ray with adaptive error control | Surfaces only | - | Galin 2020 | Jacobian-norm local bounds through warps | Surfaces, not integration | - | Keeter 2020 | Interval pruning that tolerates warps | Surfaces | - | Gabor Fields 2026 | Closed form for any affine-transformed Gabor kernel along a segment | No warp | - | Balint 2019 | Closed form for cosine noise | Composition and warps break it | - | Pre-integration (Engel 2001) | Exact per-segment integral | Under a piecewise-linear model of the scalar | - | Moinet 2025 | Bounded FBM octave skipping | Excludes FBM used as a domain warp | - -- **[search]** Rezk-Salama et al., *Fast Volumetric Deformation on General Purpose - Hardware*, Graphics Hardware 2001. Fetched text: piecewise-trilinear deformation - patches with adaptive subdivision, rendered by object-aligned slicing. The - approximate inverse is `x + O(delta^2)`. A search summary describes the deformed rays - as polylines, but the fetched text uses slicing, not per-ray exact integration. - -## Sources - -- Balint 2019: https://www.cl.cam.ac.uk/~rkm38/pdfs/balint2019cosine_noise.pdf -- Condor et al. 2026, Gabor Fields: https://arxiv.org/pdf/2602.05081 -- Gamito PhD thesis: https://staffwww.dcs.shef.ac.uk/people/S.Maddock/phd_theses/gamito/thesis_small.pdf -- Gamito, Maddock 2007: https://link.springer.com/article/10.1007/s00371-006-0090-7 -- Lagae et al. 2009, Gabor noise: https://www-sop.inria.fr/reves/Basilic/2009/LLDD09/LLDD09PNSGC_paper.pdf -- Lagae, Drettakis 2011: https://inria.hal.science/inria-00606907/file/paper_0049_preprint.pdf -- Lagae et al. 2010 survey: https://www-sop.inria.fr/reves/Basilic/2010/LLCDDELPZ10/LLCDDELPZ10STARPNF.pdf -- Heitz et al. 2013: https://inria.hal.science/hal-00765799 -- Sharp, Jacobson 2022: https://arxiv.org/pdf/2202.02444 -- Seyb et al. 2019: https://cs.dartmouth.edu/~wjarosz/publications/seyb19nonlinear.html -- Galin et al. 2020: https://hal.science/hal-02507361 -- Moinet, Neyret 2025: https://inria.hal.science/hal-05046040 -- Keeter 2020: https://www.mattkeeter.com/research/mpr/ -- Fryazinov et al. 2009: https://eprints.bournemouth.ac.uk/11708/1/TR-NCCA-2009-04.pdf -- Knoll et al. 2009: https://onlinelibrary.wiley.com/doi/10.1111/j.1467-8659.2008.01189.x -- Berz, Makino 1998: https://link.springer.com/article/10.1023/A:1024467732637 -- Engel et al. 2001: https://www3.cs.stonybrook.edu/~mueller/teaching/cse616/engel.pdf -- Gustavson 2005: https://cgvr.cs.uni-bremen.de/teaching/cg_literatur/simplexnoise.pdf -- Schneider 2015: https://advances.realtimerendering.com/s2015/ -- Kettunen et al. 2021: https://jannovak.info/publications/URM/URM.pdf -- Vicini et al. 2021: https://dvicini.github.io/non-exponential-representation/ -- Rezk-Salama et al. 2001: https://www3.cs.stonybrook.edu/~mueller/teaching/cse616/p17-rezk-salama.pdf -- Klein et al. 2005: https://www.researchgate.net/publication/4188150 diff --git a/docs/research/cross-process-file-locking-prior-art.md b/docs/research/cross-process-file-locking-prior-art.md deleted file mode 100644 index 298e1722..00000000 --- a/docs/research/cross-process-file-locking-prior-art.md +++ /dev/null @@ -1,158 +0,0 @@ -# Cross-process file locking and atomic replace: prior art - -Facts only. Gathered 2026-10-02 for fork `variants:question:ts-python-write-lock`. No conclusions, no recommendation. - -Provenance legend: **[src]** read from CultLib source this pass; **[primary]** vendor/spec/upstream doc or source fetched this pass (the fetch tool summarises pages through a small model, so quoted phrasing is paraphrase-grade unless shown in quotes); **[secondary]** search-result snippet or third-party issue, weak; **[UNVERIFIED]** not confirmed by any source read, or derived by inference only. Nothing here was tested by running code on Windows or Linux. - -Dates caveat: the doc-site fetches reported release dates for `fs2 0.4.3` ("September 9, 2026") and `fs4 1.1.0` ("September 23, 2026"). The fs2 date is implausible against my memory of that crate (long stable, last release years earlier); treat crate dates as **[UNVERIFIED]**. - ---- - -## 0. What CultLib does today (source, this checkout) - -| Runtime | Lock | Temp name | Replace | Pointer | -|---|---|---|---|---| -| C# | Sidecar `.lock`, `new FileStream(lockPath, OpenOrCreate, ReadWrite, FileShare.None, bufferSize 1)`. On `IOException`: if `wait` is false return null, else sleep 10 ms and retry for up to 30 s, after which the exception propagates. | `.{name}.{Guid:N}.tmp`, `FileMode.CreateNew`, `FileShare.None`, `WriteThrough`, `Flush(true)` | `File.Replace(temp, path, null)` if target exists, else `File.Move` | `F:\Projects\CultLib\src\GameCult.Caching\CultCache.cs` lines ~3475-3530 | -| Rust | Sidecar `.lock` (`.lock` appended to full file name), opened `create/read/write/truncate(false)` (std default share mode), then `fs2::FileExt::lock_exclusive` / `lock_shared` / `try_lock_exclusive` (WouldBlock => `None`). Unlock explicit, then drop. | `{name}.{uuid v4}.tmp`; staged file `sync_all` then closed | Unix: `fs::rename`. Windows: `MoveFileExW(MOVEFILE_REPLACE_EXISTING \| MOVEFILE_WRITE_THROUGH)` retried 25 times, 20 ms apart, on ERROR_ACCESS_DENIED(5)/SHARING_VIOLATION(32)/LOCK_VIOLATION(33). Comment cites a Muninn crash on 2026-09-11. | `F:\Projects\CultLib\packages\cultcache-rs\src\lib.rs` ~925-945, 1040-1084, 2870-3030; `Cargo.toml`: `fs2 = "0.4"`, edition 2024 | -| TypeScript | None. In-process promise queue only (`next`/`result` chain). | `${file}.tmp-${pid}-${Date.now()}-${random}` (unique per writer) | `fs/promises.rename`, retried 10 times with 10 ms doubling on EPERM/EBUSY/EACCES; temp removed on error. No fsync of temp. | `F:\Projects\CultLib\packages\cultcache-ts\src\single-file-messagepack-backing-store.ts` ~143-205 | -| Python | None. `threading.RLock` per store object (in-process only). | Fixed `path.with_suffix(suffix + ".tmp")`, i.e. `store.cc.tmp`, shared by all writers | `Path.replace` (`os.replace`); no fsync | `F:\Projects\CultLib\packages\cultcache-py\src\cultcache_py\stores.py` lines 70-82, 121-126 | - -Both C# and Rust name the lock `.lock`. The same-name sidecar is the only thing the two currently share. Both also hold the lock around read-modify-write of the snapshot **[src]**. A lock file is never deleted by either (no stale-file problem; the lock is the kernel object, not the file's existence) **[src, inferred from absence of delete]**. - -Note re the fork text: C# does use a lock (stated in the C# code comment: "excludes other handles in this process and in others alike"). - ---- - -## 1. Language and OS primitives - -### 1.1 .NET `FileStream` / `FileShare` - -- **Windows**: `FileShare` maps to the `dwShareMode` of `CreateFile`. `FileShare.None` = share mode 0: "Any request to open the file (by this process or another process) will fail until the file is closed." **[primary]** https://learn.microsoft.com/en-us/dotnet/api/system.io.fileshare . Win32 side: dwShareMode 0 "cannot be opened again, either by the application that opened it or by another application, until its handle has been closed"; failure is ERROR_SHARING_VIOLATION. **[primary]** https://learn.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files . Share modes are checked at **open** time and are not byte-range locks; they do not call `LockFileEx` **[inferred]**. -- **Unix**: .NET emulates `FileShare` with advisory `flock(2)`. Source (`SafeFileHandle.Unix.cs`, runtime main): `lockOperation = (share == FileShare.None) ? LOCK_EX : LOCK_SH`, called as `FLock(handle, lockOperation | LOCK_NB)`; on `EWOULDBLOCK` an `IOException` is thrown; handle close issues `LOCK_UN`. **[primary]** https://raw.githubusercontent.com/dotnet/runtime/main/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs - - So non-`None` opens take a **shared** flock; `None` takes an **exclusive** flock; non-blocking in all cases. A plain read with `FileShare.ReadWrite | Delete` still takes `LOCK_SH`, which would conflict with a writer holding `LOCK_EX` on the same file (only relevant if the same file is opened both ways). **[inferred from source above]** - - Disable switch: env `DOTNET_SYSTEM_IO_DISABLEFILELOCKING`; locking is off by default on Browser/WASI and iOS/tvOS (not Mac Catalyst). **[primary]** - - Because it is advisory flock, it excludes only other openers that also take flock (other .NET processes, or any program calling flock on that file). It does not stop a process that merely `open()`s and writes. **[inferred]** - - Since which .NET version: **[UNVERIFIED]**. I believe the flock-based FileShare emulation has existed since .NET Core 1.x/2.x, and .NET 6 rewrote FileStream into strategies while keeping it, but no source read this pass dates it. - - Windows `FileShare.Delete` is meaningful; the Unix code does not differentiate it. **[primary]** -- `File.Replace(src, dst, backup)` -> Win32 `ReplaceFile`; throws if volumes differ. **[primary]** https://learn.microsoft.com/en-us/dotnet/api/system.io.file.replace . Unix mapping to `rename` **[UNVERIFIED]**. - -### 1.2 Rust - -- `std::fs::File::lock`, `lock_shared`, `try_lock`, `try_lock_shared`, `unlock`: stable since **Rust 1.89.0**. **[primary]** https://doc.rust-lang.org/std/fs/struct.File.html - - Unix/WASI: `flock` (`LOCK_EX`, `LOCK_SH`, `+LOCK_NB`, `LOCK_UN`). Windows: `LockFileEx` (flags `LOCKFILE_EXCLUSIVE_LOCK`, `LOCKFILE_FAIL_IMMEDIATELY`) and `UnlockFile`. - - Docs: lock "may be advisory or mandatory", platform-dependent; on Windows the file must be opened for write (or read+append) for an exclusive lock; re-locking the same handle or a clone is unspecified, possibly deadlock; locks released when the file and all duplicated handles close; "this may change in the future". -- `fs2` 0.4.x (what CultCache Rust uses): Unix `flock(2)`; Windows `LockFileEx` (source `src/windows.rs`: `lock_shared` passes 0, `lock_exclusive` passes `LOCKFILE_EXCLUSIVE_LOCK`, try variants add `LOCKFILE_FAIL_IMMEDIATELY`; `unlock` uses `UnlockFile`). Docs: "advisory"; do not lock one `File` concurrently; duplicated files need great care. **[primary]** https://docs.rs/fs2/latest/fs2/trait.FileExt.html , https://raw.githubusercontent.com/danburkert/fs2-rs/master/src/windows.rs . An earlier summary of the fs2 docs page said "LockFile" for Windows; the source file says `LockFileEx`. Maintenance status of fs2: **[UNVERIFIED]**. -- `fs4`: fork of fs2 adding async, rustix instead of libc; docs say `flock`/`fcntl` on Unix, `LockFileEx` on Windows. Whether std's `File::lock` is mentioned or deprecates it: not stated on the page read. **[primary]** https://docs.rs/fs4/latest/fs4/ . Which Unix call it picks by default (flock vs fcntl): **[UNVERIFIED]**. -- Windows default share mode of Rust `OpenOptions`: `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`; `share_mode(0)` makes exclusive. **[primary]** https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html -- `std::fs::rename`: Unix `rename(2)`; Windows 10 1607+ `MoveFileExW(MOVEFILE_REPLACE_EXISTING)` or `SetFileInformationByHandle(FileRenameInfoEx)` (POSIX semantics); earlier, MoveFileExW only. "may change in future". **[primary]** https://doc.rust-lang.org/std/fs/fn.rename.html . (CultCache Rust bypasses std rename on Windows and calls MoveFileExW itself, per 0.) - -### 1.3 Node - -- No built-in advisory file lock in `node:fs`; **[UNVERIFIED]** by a direct docs read this pass, but nothing in the packages read contradicts it. Options seen: - - `proper-lockfile`: "mkdir strategy" - creates `.lock` as a **directory**; works across local and network FS; stale detection by lock dir **mtime** (default `stale` 10 s, min 5 s; mtime refreshed every `update` = stale/2, min 1 s); `onCompromised` callback when refresh fails or is late; avoids `O_EXCL` because "O_EXCL is broken on NFS" (their README); contrasts with `lockfile` package which uses ctime for staleness, unsuitable for long-running holders. **[primary]** https://raw.githubusercontent.com/moxystudio/node-proper-lockfile/master/README.md - - `lockfile` (npm), `fs-ext` (native `flock`/`fcntl` bindings): not fetched. **[UNVERIFIED]** -- Libuv rename on Windows uses `MoveFileExW(MOVEFILE_REPLACE_EXISTING)`; reports say it fails with EPERM while any handle holds the destination open, and refuses a READONLY destination; some runtimes (Bun PR) fall back to POSIX-semantic replace. **[secondary]** search snippets: https://github.com/oven-sh/bun/pull/43997 , https://github.com/joyent/libuv/issues/283 . Not read from libuv source: **[UNVERIFIED]**. -- `npm/write-file-atomic`: temp name = `filename + "." + murmurhex(__filename, process.pid, ++invocations)` (plus worker thread id); same-process writes to one file queued and serialised; fsync on by default; no cross-process lock mentioned. **[primary]** https://raw.githubusercontent.com/npm/write-file-atomic/main/README.md - -### 1.4 Python - -- `fcntl.flock()` wraps `flock(2)`; docs: "On some systems, this function is emulated using fcntl()". `fcntl.lockf()` is "essentially a wrapper around the fcntl() locking calls". Unix only. "On at least some systems, LOCK_EX can only be used if the file descriptor refers to a file opened for writing." The page does not state whether flock and lockf interact. **[primary]** https://docs.python.org/3/library/fcntl.html -- `msvcrt.locking(fd, mode, nbytes)`: locks `nbytes` from the current file position (may extend past EOF); `LK_LOCK`/`LK_RLCK` retry once per second, 10 attempts, then `OSError`; `LK_NBLCK` fails immediately; regions cannot overlap; adjacent regions not merged. Underlying Win32 call not stated in docs. **[primary]** https://docs.python.org/3/library/msvcrt.html . (The CRT `_locking` is documented elsewhere as `LockFile`-based; **[UNVERIFIED]** here.) -- `filelock` (tox-dev): `FileLock` alias = `UnixFileLock` (`fcntl.flock`, described as kernel-enforced and released on crash) on Unix; `WindowsFileLock` described as `LockFileEx` byte-range locking on Windows (older versions used `msvcrt.locking`; version not checked, **[UNVERIFIED]**); `SoftFileLock` is a "cooperative file-existence marker", with same-host PID inspection and reclaim from dead processes; docs recommend verifying shared-filesystem semantics before deploying soft locks; no statement on cross-type exclusion. **[primary]** https://py-filelock.readthedocs.io/en/latest/index.html -- `portalocker`: README fetch 404; its primitives are **[UNVERIFIED]** (not read). -- `os.replace` on Windows semantics (MoveFileEx REPLACE_EXISTING): **[UNVERIFIED]**, not fetched. - -### 1.5 Interoperability matrix (flock / fcntl / LockFileEx / share modes) - -| Question | Finding | Source | -|---|---|---| -| Linux, local FS: does `flock` exclude `fcntl` (POSIX byte-range) locks? | No. man flock(2): on Linux "there is no interaction between the types of lock placed by flock() and fcntl(2)" (local filesystems). | **[primary]** https://man7.org/linux/man-pages/man2/flock.2.html | -| Linux over NFS (since 2.6.12) | flock is emulated as whole-file fcntl byte-range locks, so flock and fcntl **do** interact there. | same | -| Linux over CIFS (since 5.5) | flock emulated with SMB byte-range locks; flock and fcntl interact; and the lock becomes **mandatory**: I/O from other descriptors on a locked file fails with EACCES. | same | -| Duplicate fds / fork | A lock belongs to the open file description; shared by dup/fork; persists until `LOCK_UN` or **all** duplicates close. Independent `open()`s in the same process conflict with each other under flock. | same | -| Does a Rust `flock` (std or fs2) exclude a .NET-on-Unix `FileShare.None` open? | Both are `flock(LOCK_EX)` on the same inode; by the sources above they should conflict (.NET's non-blocking attempt gets EWOULDBLOCK -> IOException -> CultCache C# retries). **Not tested.** | **[inferred]**; **[UNVERIFIED]** empirically | -| Same, but .NET `FileShare.ReadWrite` opener (shared flock) vs Rust `lock_exclusive` | Conflicts (LOCK_SH vs LOCK_EX), so a reader opening the lock file with any FileShare would block/fail against a Rust holder. CultCache does not open the lock file for reading. | **[inferred]** | -| Windows: does a share-mode-0 open (.NET `FileShare.None`) exclude a Rust `LockFileEx` locker? | Order A: .NET holds the file with share mode 0. Rust's `OpenOptions::open` (share mode default RWD) then fails at `CreateFile` with ERROR_SHARING_VIOLATION, before it can lock. In `open_lock_file` that is a `with_context` error, **not a wait/retry** (looked at the source). Order B: Rust holds a handle (RWD) and `LockFileEx`; .NET `CreateFile` with share mode 0 conflicts with the existing open handle's access -> ERROR_SHARING_VIOLATION -> `IOException` -> C# retries up to 30 s. So mutual exclusion holds in both orders, but in order A Rust errors instead of waiting. | **[inferred]** from MS CreateFile share-mode table + Rust OpenOptionsExt default; **[UNVERIFIED]** empirically | -| Windows: is `LockFileEx` mandatory? | Exclusive region lock "denies all other processes both read and write access to the specified region"; shared lock denies writes; locks are not honoured through mapped views. If a process dies or closes the handle the OS releases the locks, but "the time it takes ... depends upon available system resources" (MS recommends explicit unlock). Handle needs GENERIC_READ or GENERIC_WRITE. | **[primary]** https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex | -| Windows: second handle in same process | "If the locking process opens the file a second time, it cannot access the specified region through this second handle until it unlocks the region." | same | -| Rust-on-Windows `LockFileEx` vs Python `msvcrt.locking` (same region?) | `LockFileEx` regions conflict if they overlap; fs2 locks which byte range (offset 0, len u32::MAX..?) : **[UNVERIFIED]**; msvcrt.locking locks `nbytes` from the current position (so depends on `lseek`); whether CRT `_locking` uses LockFile/LockFileEx and which range would need to match: **[UNVERIFIED]**. | -| Python Unix `flock` vs Rust/.NET flock | Same kernel primitive on Linux/macOS (Python's flock "may be emulated using fcntl on some systems", so platform-dependent). Python `lockf` is fcntl: independent from flock on local Linux FS. | **[primary]** python docs + man page | -| macOS flock vs fcntl | **[UNVERIFIED]** (not fetched). | -| POSIX fcntl lock semantics | Per-process: `close()` of **any** fd for the file by the process drops all of that process's fcntl locks (SQLite doc 2.2 below). flock locks are per open-file-description and do not have that hazard. | **[primary]** SQLite howtocorrupt; flock(2) | -| Python `fcntl.flock` on Windows | Module is Unix only (docs). | **[primary]** | - ---- - -## 2. Lockfile protocols in established software - -### git -- Lockfile API: lock for `foo` is `foo.lock`, created with `O_CREAT|O_EXCL`; writer writes new content into it; `commit_lock_file()` renames it over `foo`; `rollback_lock_file()` removes it; writers exclude each other; readers never block and see either old or new content (relies on atomic rename); cleanup of outstanding lockfiles is registered with `atexit` and signal handlers. **[primary]** https://git-scm.com/docs/api-lockfile -- `lockfile.c`: retry with quadratic backoff for at least `timeout_ms`; PID file registered as a tempfile for signal/atexit cleanup; failure message says another git process may be running "or the lock file may be stale" and tells the user to remove it manually. **[primary]** https://raw.githubusercontent.com/git/git/master/lockfile.c -- Consequences recorded in the docs: a hard kill (SIGKILL, power loss) leaves a `.lock` file and later writers fail until it is removed; git does not time-based-reclaim index.lock **[inferred from message text, not stated; UNVERIFIED]**. Note the git design makes the lock file **the temp file** (lock name = staging name); CultCache's current design has a separate sidecar lock plus uniquely named temp. - -### SQLite (see also section 4) -- Unix default VFS: POSIX advisory locks via `fcntl()`; Windows VFS: `LockFile`/`LockFileEx`/`UnlockFile`. Five states UNLOCKED/SHARED/RESERVED/PENDING/EXCLUSIVE. **[primary]** https://www.sqlite.org/lockingv3.html (byte-range layout not stated on that page). -- Built-in unix VFS variants: `unix` (POSIX advisory), `unix-dotfile` (dot-file locking), `unix-excl` (holds exclusive lock, WAL index in heap), `unix-none` (no locking), `unix-namedsem` (VxWorks). "Except for 'unix' and 'unix-excl', the various Unix VFSes all use incompatible locking implementations"; processes using different VFSes on one DB "may not see each others locks ... resulting in database corruption". **[primary]** https://www.sqlite.org/vfs.html . (`unix-flock` / `unix-afp` / `unix-nfs` appear in SQLite's source as separate io-method variants; not listed on that page: **[UNVERIFIED]**.) - -### LMDB -- Uses a separate `lock.mdb` file for the reader table and writer mutex. Header warnings: stale reader slots from aborted programs make the DB grow quickly (`mdb_reader_check`); stale writer lock clears automatically on Windows, BSD with SysV semaphores, and Linux with robust POSIX mutexes, otherwise all DB users must be closed; "Do not have open an LMDB database twice in the same process at the same time. Not even from a plain open() call - close()ing it breaks flock() advisory locking."; "Do not use LMDB databases on remote filesystems, even between processes on the same host. This breaks flock() on some OSes"; `MDB_NOLOCK` disables locking entirely. **[primary]** https://raw.githubusercontent.com/LMDB/lmdb/mdb.master/libraries/liblmdb/lmdb.h -- Note: that warning is about `flock` and `close()`, which contradicts the usual statement that only fcntl locks have the close() hazard; the source of the discrepancy (older Linux/BSD semantics, or the emulated flock on some OS) is **[UNVERIFIED]**. - -### Cargo / npm / pip / Gradle -- Cargo: package-cache and build-dir lock using an OS file lock, prints "Blocking waiting for file lock"; source fetch (`src/cargo/util/flock.rs`) 404; details (flock/fs4/std, handling of filesystems without locking) **[UNVERIFIED]**. -- Gradle: `DefaultFileLockManager` holds cross-process locks on cache/daemon-registry files; reports of builds hanging on locks left by crashed or killed daemons. **[secondary]** web search snippets only (https://discuss.gradle.org/t/gradle-daemon-keeps-locking-intermediate-files-preventing-builds/38004 , https://www.javathinking.com/blog/gradle-build-is-hanging-without-failure-defaultfilelockmanager-acquiring-and-releasing-lock-on-daemon-addresses-registry/ ); Gradle's own docs on lock protocol not read. **[UNVERIFIED]** -- npm: `write-file-atomic` has no cross-process lock (above); npm's cache (cacache) locking: **[UNVERIFIED]**, not fetched. -- pip: **[UNVERIFIED]**, not fetched. - -### Windows rename retry (Postgres) -- `pgrename()` on Windows calls `MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)` and retries on ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION, ERROR_LOCK_VIOLATION: up to 100 retries, 0.1 s apart (~10 s). Comment: other applications may have the file open without sharing flags; LOCK_VIOLATION seen from some anti-virus software; bounded because the caller may hold locks affecting other backends. **[primary]** https://raw.githubusercontent.com/postgres/postgres/master/src/port/dirmod.c . CultCache Rust uses the same error set with 25 x 20 ms (0.5 s); TS retries EPERM/EBUSY/EACCES 10 times with doubling from 10 ms (about 10 s worst case) **[src]**. - ---- - -## 3. Temp-file naming and rename atomicity - -- Unique temp names per writer: C# GUID, Rust uuid v4, TS pid+time+random **[src]**; npm write-file-atomic pid + counter hash **[primary]**; Python CultCache fixed `.tmp` **[src]**. Rust additionally has a startup cleanup that deletes only temps matching `..tmp` (tests at `lib.rs` ~3420, 4667-4689 distinguish `not-a-uuid.tmp`, bare `.tmp`, neighbour stores) **[src]**. Note the naming differs between runtimes: C# `.{name}.{guid:N}.tmp` (leading dot, no dashes) vs Rust `{name}.{uuid-with-dashes}.tmp` vs TS `{name}.tmp-...`; whether the Rust stale-temp sweeper recognises C#/TS temps: it matches the Rust format only (per the test names) **[src, partial reading]**. -- Fixed temp name consequence (inferred, not tested): two processes writing `store.cc.tmp` concurrently share one file: interleaved `write_bytes` (truncate-and-write) can yield a mixed or truncated file that one process then renames into place, and the other process's `replace` can fail with source-not-found. **[inferred]** -- POSIX `rename()`: if `new` exists it "shall be removed and old renamed to new"; the rationale requires the action to be atomic; a directory entry named `new` stays visible to other threads throughout and refers to either old or new file; on failure other than I/O errors `new` is unaffected; spec does not define crash durability. **[primary]** https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html -- Directory fsync: the usual pattern is write temp, fsync temp, rename, then fsync the parent directory so the rename survives power loss; many projects have filed bugs for omitting the directory fsync. **[secondary]** search snippets (e.g. https://github.com/npm/write-file-atomic/issues/64 titled "Rename atomicity is not enough"; https://0xkiire.com/crash-consistency-fsync-rename/). Linux ext4 `auto_da_alloc` replace-via-rename heuristic: **[UNVERIFIED]**, not fetched. Whether CultCache Rust/C# fsync the parent directory on Unix: **[UNVERIFIED]** (not seen in the excerpts read; Rust does `sync_all` on the temp, C# `Flush(true)` + `WriteThrough`; TS and Python do neither). -- Windows `MoveFileExW`: - - `MOVEFILE_REPLACE_EXISTING` replaces the destination if ACLs allow; errors if destination is an existing directory; `MOVEFILE_WRITE_THROUGH` waits for the move to be flushed (documented as guaranteeing flush of a copy+delete move). Same-volume rename is a metadata operation. The doc page does not use the word "atomic" and does not describe behavior when the destination is open by another handle. **[primary]** https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexw - - Open-handle failure: reported from libuv/Bun and Postgres as ERROR_ACCESS_DENIED / SHARING_VIOLATION / LOCK_VIOLATION when another process has the destination open without FILE_SHARE_DELETE, or an anti-virus scan holds it. **[primary]** Postgres comment; **[secondary]** libuv/Bun. - - Rust's std rename (1.0+ Windows 10 1607) may use `FileRenameInfoEx` with POSIX semantics, which can replace an open destination; CultCache Rust calls `MoveFileExW` directly instead **[src; primary for std]**. -- Windows `ReplaceFileW` (used by .NET `File.Replace`): replaced file opened with GENERIC_READ|DELETE|SYNCHRONIZE and share mode `READ|WRITE|DELETE`; replacement file opened with **no sharing mode specified**; preserves creation time, short name, object id, DACLs, encryption, compression, named streams; resulting file has the replacement's file ID; all files must be on the same volume; documented failure states leave the system in partially-moved states: ERROR_UNABLE_TO_REMOVE_REPLACED (1175; names unchanged), ERROR_UNABLE_TO_MOVE_REPLACEMENT (1176; with no backup, the replaced file "no longer exists" and the replacement exists under its original name), ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 (1177). `REPLACEFILE_WRITE_THROUGH` "not supported". The page makes no statement that ReplaceFile is atomic; it describes it as combining steps. **[primary]** https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-replacefilew - - So on Windows, C# (`File.Replace`) and Rust/TS/Python (MoveFileEx or equivalent) use different primitives with different failure windows. **[inferred from the two pages]** -- .NET `File.Move` with overwrite on Windows/Unix: **[UNVERIFIED]** (CultCache C# uses `File.Move(temp, path)` only when the target does not exist; there is a window in which another writer creates the target between the `File.Exists` check and the move; the lock covers it when taken **[src, inferred]**). - ---- - -## 4. Known failures and warnings - -SQLite "How To Corrupt An SQLite Database File" (https://www.sqlite.org/howtocorrupt.html) **[primary]**: -- 2.1 Filesystems with broken or missing lock implementations (network filesystems, NFS) can corrupt when multiple processes access. -- 2.2 POSIX advisory locks are cancelled by `close()`: `close()` on any descriptor for the file by any thread in the process releases the process's locks on that file; example: thread B opens, reads and closes the DB file for a backup and thread A's locks vanish silently. SQLite works around it with a mutex-protected global list of open files, which fails if two copies of SQLite are linked into one app (2.3; a commercial product shipped this bug with infrequent corruption on Linux/Mac). WAL multi-process defenses added in 3.51.0 (2025-11-04). -- 2.4 Two processes using different locking protocols (e.g. POSIX advisory vs dot-file) cannot see each other's locks; all connections must use the same protocol. -- 2.5 Unlinking or renaming the DB file while in use: processes end up with different physical files sharing one journal; SQLite warns (since 3.7.17) when the file is unlinked while open. -- 2.6 Multiple links (hard/symbolic links): same hazard; resolved by canonicalising symlinks since 3.10.0. -- 2.7 Carrying a connection across `fork()`: all locking mechanisms fail with unpredictable results. -- 1.3/1.4 Hot journal deleted, moved or mispaired with database. -- The SQLite VFS page: incompatible unix VFS locking => corruption (section 2 above). - -Other recorded failure modes: -- Windows `LockFileEx` locks are released by the OS on process death but with a lag (MS doc). **[primary]** -- CIFS flock becomes mandatory (man flock(2)). **[primary]** -- Lock file left behind: git (cleanup via atexit/signal; a hard kill leaves `.lock`, message tells operator to remove) **[primary]**; Gradle hangs after killed daemons **[secondary]**; `proper-lockfile` and `filelock.SoftFileLock` provide mtime / PID-based stale reclaim as a mitigation **[primary]**. -- Lock protocols that are compatible only when everyone uses the same one: SQLite (above); `filelock` docs do not state cross-type exclusion between `UnixFileLock`/`SoftFileLock`. **[primary]** -- Lost-update by missing cross-process lock around read-modify-write: `write-file-atomic` documents only same-process serialisation; no source read this pass reports a concrete lost-update bug in it. A search-based report of corrupted/missing "settings.json" on Windows from a failed atomic write exists as an unvetted issue (https://github.com/BarganConstantin/ccdeck/issues/772, **[secondary]**, read-only destination). Reports specific to cross-language writers of one file, other than SQLite's different-VFS warning: not found this pass. **[UNVERIFIED]** -- Lock file deleted by one participant while others hold or wait on it (different inode afterward): general hazard of delete-on-unlock lock files, not sourced this pass beyond SQLite 2.5 (unlink of a live file); **[UNVERIFIED]** as a named issue for flock sidecars. - ---- - -## 5. Open items not resolved by reading (candidates for an empirical check; nothing done) - -1. Do the C# `FileShare.None` lock and Rust `fs2::lock_exclusive` actually exclude each other on Windows (both open orders) and on Linux? Only inferred above. -2. Does fs2 on Windows lock the same byte range as std 1.89 `File::lock` and as Python `msvcrt.locking`/`filelock`? Unread. -3. macOS behavior of flock vs fcntl and of .NET FileShare there. Unread. -4. .NET release that introduced Unix FileShare-via-flock. Unread. -5. Whether any runtime fsyncs the parent directory after rename on Unix. Unread. -6. Cargo, npm, pip, Gradle lock protocol primary sources. Unread. -7. `portalocker`, `fs-ext`, `lockfile`, `proper-lockfile` behavior under Windows share modes. Unread. diff --git a/docs/research/culling-efficiency-oracle-prior-art.md b/docs/research/culling-efficiency-oracle-prior-art.md deleted file mode 100644 index cf0d8077..00000000 --- a/docs/research/culling-efficiency-oracle-prior-art.md +++ /dev/null @@ -1,305 +0,0 @@ -# Culling Efficiency Against an Oracle: Prior Art Survey - -This is the facts file for Eureka question `cultmath-tapes:question:wells-ceiling-oracle`, -which interprets ruling `cultmath-tapes:ruling:operator-wells-contract-vs-ceiling`. That -ruling holds scenario (c) to "at least 90% of the probe-free ceiling (the cost of the -dense cells alone)". The question asks what "ceiling" means: - -- (a) the pre-pass's own mask, under which a pre-pass that skips nothing scores 0.98; -- (b) an oracle mask, the cells where at least one ray samples nonzero density. - -Under (b), Imagination measured 0.38 at warp 0 and 0.19 at warp D. - -This survey covers how published work measures culling or skipping efficiency against -ground truth, and what efficiency figures conservative bounds reach. Eyes pass, -2026-10-03. It gives facts and evidence pointers only, with no recommendation. - -Verification marks: - -- **[fetched]** The claim was read in the cited source's full text during this pass. - PDFs were converted with `pdftotext -layout`. -- **[search]** The claim came from a search-result summary, not a full read. -- **[not found]** The source was read, and the named kind of measurement is absent from it. - -Reference kinds used below: - -- **oracle**: an exact or ground-truth answer computed independently of the method, - such as the exact visible set or the set of truly non-empty cells. -- **self**: the method's own result, or a baseline that does no culling. -- **peer**: another approximate method. - -## 1. Visibility culling: conservative versus exact visible set - -### 1.1 Survey vocabulary - -- **[fetched]** Cohen-Or, Chrysanthou, Silva, Durand, *A Survey of Visibility for - Walkthrough Applications* (IEEE TVCG 2003). Section 2 lists "Tightness of - approximation" as a review criterion. It notes that few papers report the ratio - between the size of the potentially visible set and the size of the visible set, - and asks later work to report it. Most surveyed techniques are conservative, which - means they overestimate the visible set. - https://www.cs.tau.ac.il/~dcor/online_papers/papers/visibility-survey-ieee.pdf -- **[fetched]** Bittner, *Hierarchical Techniques for Visibility Computations* (PhD - thesis, CTU Prague, 2002), chapter 2, equations 2.1 to 2.4. It defines a quality - measure against the exact PVS `S_E`: - - relative overestimation `Q_o = |S_A \ S_E| / |S_E|`; - - relative underestimation `Q_u = |S_E \ S_A| / |S_E|`; - - the expected quality, which is the expectation of these over inputs. - - The same text appears in Bittner and Wonka, *Visibility in Computer Graphics* - (section 4.3). - https://dcgi.fel.cvut.cz/home/bittner/publications/diss_noimages.pdf - http://www.casa.ucl.ac.uk/mike-michigan-april1/mike's%20stuff/attach/bittner_wonka.pdf -- **[fetched]** Nirenstein, Blake, Gain, *Exact From-Region Visibility Culling* (EGWR - 2002), introduction and Table 1. The paper classifies algorithms as exact, - conservative, aggressive or approximate. Conservative methods "incur a false - visibility error". The paper states: - - exact visibility "provides a benchmark for comparing other approaches"; - - the percentage of polygons culled is "a very crude and imperfect metric", because - it ignores the type, distribution and magnitude of visibility error. - - Reported results (Table 2) are culling fractions of the whole scene: 99.45% for the - town and 99.12% for the forest. No conservative method is measured against the - exact set in this paper **[not found]**. A search summary attributed a 95.5% figure - for extended projection to this paper, but that figure is not in the full text. - https://people.cs.uct.ac.za/~jgain/wp-content/papercite-data/pdf/nirenstein2002.pdf - -### 1.2 Measured conservative-versus-exact ratios - -- **[fetched]** Bittner, Wonka, Wimmer, *Fast Exact From-Region Visibility in Urban - Scenes* (EGSR 2005), section 6. The exact 2.5D algorithm is used as the oracle, and - the paper simulates conservative methods against it: - - **Section 6.2, one penumbra wedge per occluder.** The conservative PVS was more - than 47% larger than the exact PVS for 2 m view cells and more than 76% larger - for 4 m view cells. As exact/conservative ratios these are ≤ 0.68 and ≤ 0.57. - - **Section 6.3, object-space discretization** (Wonka et al.'s method, a 1400×1400 - grid, Vienna). The PVS overestimate averaged 17%, a ratio of about 0.85. - - **Section 6.3, Table 4, line-space discretization** (Leyvand et al.). PVS sizes by - grid resolution, with the exact PVS last: - - | Scene | 512 | 1024 | 2048 | 16384 | exact | - |---------|--------|--------|--------|-------|-------| - | Vienna | 633 | 535 | 489 | 455 | 235 | - | Atlanta | 50,744 | 25,751 | 10,082 | 2,656 | 1,152 | - - The ratios exact/conservative below are computed from that table, not quoted from - the paper: - - Vienna: 0.37, 0.44, 0.48, 0.52; - - Atlanta: 0.023, 0.045, 0.11, 0.43. - - The paper says the overestimation comes from conservative shrinking and from gaps - "between formerly connected occluders". - - https://peterwonka.net/Publications/pdfs/2005.EGSR.Bittner.FastExactFromRegionVisibility.pdf - -### 1.3 Run-time occlusion culling against an ideal renderer - -- **[fetched]** Mattausch, Bittner, Wimmer, *CHC++: Coherent Hierarchical Culling - Revisited* (Eurographics 2008), section 7 (Figure 7) and the conclusion. The - reference algorithm "OPT" renders only the visible nodes of the hierarchy and - issues no queries. It was implemented by recording visibility with an exact - stop-and-wait pass, so it is an oracle at node granularity that is independent of - the method under test. CHC++ is reported to be "for most cases within a few percent - of the 'ideal' method". - - Caveat: occlusion queries are exact per-node tests, not conservative range bounds. - The gap to OPT measures query overhead and latency, not bound looseness. - - The paper also separates out the "optimal" algorithm defined by Guthe et al. - (NOHC-OPT), and shows CHC++ "clearly below" that optimum. That earlier optimum was a - cost-model optimum, not an oracle. - https://dcgi.fel.cvut.cz/home/bittner/publications/chc++.pdf -- **[fetched]** Zhang et al., *Visibility Culling using Hierarchical Occlusion Maps* - (SIGGRAPH 1997). It reports "% culling" of the total model, and frame time - normalized to rendering without HOM. Both are **self** references. No comparison - with the exact visible set **[not found]**. - https://www.cs.princeton.edu/courses/archive/spr01/cs598b/papers/zhang97.pdf -- **[search]** Wonka et al., *Guided Visibility Sampling* (SIGGRAPH 2006). This is - an aggressive, sampling-based PVS method. Its Table 2 reports error as false pixels - on a 1000×1000 screen, together with PVS size. Section 4.5 compares it to Bittner's - exact algorithm on one scene, because exact solvers do not run on the larger test - scenes. The text was extracted in this pass, but not read in full. - https://peterwonka.net/Publications/pdfs/2006.SG.Wonka.GuidedVisibilitySampling.final.pdf - -## 2. Empty-space skipping in volume rendering - -- **[fetched]** Li, Mueller, Kaufman, *Empty Space Skipping and Occlusion Clipping for - Texture-based Volume Rendering* (IEEE Vis 2003): - - **Section 5, Table 1.** Empty-space skipping is measured as a frame-rate speedup - over no skipping, 2.8× on average. This is a **self** reference. - - **Section 5, Table 2.** It reports the percentage of non-empty voxels skipped - through occlusion, 48% to 64% with a 56.2% average. The denominator is all - non-empty voxels, not the truly occluded voxels. The authors write that "there - are still many occluded voxels that have not been skipped" and call the number - "smaller than we have expected". The truly occluded set is not computed - **[not found]**. - - **Section 5.** Overhead is reported separately. The opacity map and clipping cost - about 10% of the empty-space-skipping render time, measured with a mode that pays - the overhead but skips nothing ("ESS+M"). - - https://www3.cs.stonybrook.edu/~mueller/papers/OcclusionClipping.pdf -- **[fetched]** Zellmann, *Comparing Hierarchical Data Structures for Sparse Volume - Rendering with Empty Space Skipping* (arXiv 1912.09596, 2019). It reports frame - rates and build times, and compares only against naive ray marching and simple - macrocell grids, as the paper itself states. No step count or sample count against - an ideal traversal **[not found]**. - https://arxiv.org/abs/1912.09596 -- **[search]** Hadwiger et al., *SparseLeap* (IEEE TVCG 24(1), 2018). It builds - per-pixel lists of ray segments by rasterizing occupancy geometry. The full text - was not retrieved (the repository returned HTML), so it is unknown whether it - reports skip efficiency against the true empty space. - https://vccvisualization.org/research/sparseleap/ -- **[search]** Deakin and Knackstedt, *Efficient ray casting of volumetric images using - distance maps for empty space skipping* (Computational Visual Media 6(1), 2020). The - full text was not retrieved. - -## 3. Interval and affine arithmetic for implicits, noise and SDF marching - -- **[fetched]** Keeter, *Massively Parallel Rendering of Complex Closed-Form Implicit - Surfaces* (SIGGRAPH 2020): - - **Section 3, Interval arithmetic.** Ambiguous regions "either contain the shape's - boundary or are a false positive (due to interval arithmetic's conservative - behavior)". The false-positive share is not measured **[not found]**. - - **Section 2.1, Figure 5.** Reported efficiency is against **self** and peer - baselines: a brute-force per-pixel interpreter (about 58 ms/MP) and a compiled - kernel (about 3 ms/MP). - - **Section 3.2, Figure 6.** Tape length is reduced 17× in 64² tiles and 216× in 8² - subtiles, from 6056 clauses to means of 356 and 28. - - **Section 5, Figures 9 and 10.** Heatmaps of work per pixel show extra work at - model edges, where interval evaluation "can't skip entire regions". The text says - many smooth blends lead "to less useful interval evaluation results". - - **Section 6.** It names reduced affine arithmetic as a way "to more tightly bound - intervals". - - https://www.mattkeeter.com/research/mpr/keeter_mpr20.pdf -- **[fetched]** Keeter, *Gradients are the new intervals* (blog, 2025-05-14). It - compares interval evaluation with gradient-based pseudo-intervals by tape length - (120.2 against 121.5 clauses) and by render time. These are peer references. There - are no tile-classification counts and no ground truth **[not found]**. - https://www.mattkeeter.com/blog/2025-05-14-gradients/ -- **[fetched]** Heidrich, Slusallek, Seidel, *Sampling Procedural Shaders Using Affine - Arithmetic* (ACM TOG 17(3), 1998): - - **What "error" measures.** Error is the width of the computed range per pixel. It - is not compared with the true range from dense sampling **[not found]**. The - tightness against the true variation is argued qualitatively, from shader cross - sections. - - **Section 3.2.** Noise over an affine form that spans several lattice cells falls - back to interval arithmetic, and a span of more than two cells returns the full - noise range [0, 1]. For turbulence (blue marble), 81% of pixels lie within 5% - error and 59% within 1%. The eroded shader, with high-frequency noise, gets 77% - and 53%. - - **Section 4.** Against AA, interval arithmetic gave errors "up to 50 percent where - affine arithmetic produces errors below 1/256" (wood shader, Figures 6 and 7). - - https://vccimaging.org/Publications/Heidrich1998SPS/Heidrich1998SPS.pdf -- **[fetched]** Gamito and Maddock, *Ray casting implicit fractal surfaces with reduced - affine arithmetic* (The Visual Computer 23(3), 2007). Section 5, Tables 1 to 3, use - a sphere hypertextured with three octaves of noise. The accuracy proxy is the - average number of interval evaluations per ray, a **peer** comparison with no oracle - count. The rows below are reconstructed from a mangled text layout, and the - reconstruction agrees with the paper's prose. - - | Noise | IA evals/ray | IA time | Standard AA evals/ray | Reduced AA evals/ray | Reduced AA + interval optimisation, evals/ray | Its time | - |------------------------|--------------|-----------|-----------------------|----------------------|-----------------------------------------------|-----------| - | Perlin gradient | 78.40 | 8m27.5s | 34.60 | 34.60 | 20.81 | 3m43.2s | - | Lewis sparse convolution | 48.44 | 26m31.0s | 23.25 | 23.25 | 13.46 | 6m29.3s | - | Worley cellular | 45.70 | 25m54.7s | 32.56 | 43.78 | 21.29 | 14m25.9s | - - The text cites "the excessive conservativeness of IA estimates", and says IA - compensates by being fast. - https://eprints.whiterose.ac.uk/id/eprint/3762/1/gamito_newraycastvisual.pdf -- **[fetched]** Knoll, Hijazi, Kensler, Schott, Hansen, Hagen, *Fast Ray Tracing of - Arbitrary Implicit Surfaces with Interval and Affine Arithmetic* (CGF 28(1), 2009). - Section 6.1.1 and Tables 1 and 2 report frames per second for IA against reduced - AA: - - RAA is "generally 1.5 to 2× faster", and "3 to 4 times faster" for functions - "with high bound overestimation"; - - IA is faster for superquadrics. - - These are **peer** references, with no oracle count of wasted subdivisions - **[not found]**. - https://sci.utah.edu/~knolla/cgrtia.pdf -- **[fetched]** Sharp and Jacobson, *Spelunking the Deep: Guaranteed Queries on General - Neural Implicit Surfaces via Range Analysis* (SIGGRAPH 2022), section 3.4 and Table 1. - Tightness is measured as "the typical size of a region which can be bounded away - from the zero": - - | Method | 1D length | 3D volume | Ray-cast time (relative to the fastest) | - |---------------|-----------|-----------------|-----------------------------------------| - | interval | 0.011 | < 0.001 × 10⁻³ | 34.3× | - | affine (full) | 0.821 | 3.499 × 10⁻³ | 8.4× | - | affine (fixed)| 0.306 | 0.267 × 10⁻³ | 1.0× | - - The prose says interval arithmetic "yields extremely pessimistic bounds". These are - **peer** references, with no oracle region size **[not found]**. - https://arxiv.org/abs/2202.02444 -- **[fetched]** Mitchell, *Robust Ray Intersection with Interval Arithmetic* (Graphics - Interface 1990). It reports root-finding timings for its method and for peer - root finders. No pruning-against-oracle measure **[not found]**. - http://graphicsinterface.org/wp-content/uploads/gi1990-8.pdf -- Duff, *Interval Arithmetic and Recursive Subdivision for Implicit Functions and - Constructive Solid Geometry* (SIGGRAPH 1992), and Snyder, *Interval Analysis for - Computer Graphics* (SIGGRAPH 1992), were not retrieved in this pass. - https://doi.org/10.1145/142920.134027 - -## 4. Conservative rasterization and tile classification - -- **[fetched]** Hasselgren, Akenine-Möller, Ohlsson, *Conservative Rasterization* - (GPU Gems 2, chapter 42): - - **Section 42.1.** It defines overestimated rasterization as every pixel whose cell - intersects the polygon, and underestimated rasterization as every pixel whose - cell lies wholly inside it. - - **Section 42.5.** Overdraw is discussed qualitatively: it depends on triangle - acuity and resolution. Figure 42-7 compares the two proposed algorithms only. No - count of excess fragments against the exact overlap set **[not found]**. - - https://developer.nvidia.com/gpugems/gpugems2/part-v-image-oriented-computing/chapter-42-conservative-rasterization -- **[search]** Antochi, Juurlink, Vassiliadis, Liuha, *Scene management models and - overlap tests for tile-based rendering* (DSD 2004), and the companion *Efficient - tile-aware bounding-box overlap test*. In a search summary, the bounding-box - triangle-to-tile test "can generate up to 30% false positives" on common workloads, - measured against exact overlap. The full text could not be retrieved (the TU Delft - host refused the connection, and CiteSeerX returned HTML). - https://citeseerx.ist.psu.edu/document?doi=5c78f05f185b9513bf930588dd2a4ae334090620 - -## 5. Summary of reference kinds and reported figures - -| Source | Reference | Figure reported | -|--------|-----------|-----------------| -| Bittner et al. 2005, §6.2 | oracle (exact PVS) | conservative PVS +47% / +76% (ratio ≤ 0.68 / ≤ 0.57) | -| Bittner et al. 2005, §6.3 | oracle | object discretization +17% (≈ 0.85); line-space 0.023–0.52 by scene and resolution | -| Bittner thesis, ch. 2 | oracle | defines `Q_o`, `Q_u` relative to `|S_E|` | -| Cohen-Or et al. 2003 | — | notes the PVS/visible-set ratio is rarely reported | -| Nirenstein et al. 2002 | oracle (its own exact) | percent culled; calls that metric crude | -| CHC++ 2008 | oracle (OPT, node level) | within a few percent of OPT (exact queries, not bounds) | -| HOM 1997 | self | % of model culled, normalized frame time | -| Li, Mueller, Kaufman 2003 | self / all non-empty | 2.8× speedup; 56% of non-empty voxels skipped; overhead ≈ 10% reported separately | -| Zellmann 2019 | self | fps against no skipping | -| Keeter 2020 | self (brute force, compiled) | 17× / 216× tape reduction; false-positive share not measured | -| Heidrich et al. 1998 | none (range width) | IA error up to 50% where AA < 1/256 | -| Gamito, Maddock 2007 | peer | IA 2.1–3.8× more evaluations per ray than reduced AA + optimisation on noise | -| Knoll et al. 2009 | peer | RAA 1.5–4× faster than IA | -| Sharp, Jacobson 2022 | peer | IA provable region about 75× smaller in 1D than full AA | -| GPU Gems 2, ch. 42 | peer | qualitative overdraw | -| Antochi et al. 2004 [search] | oracle (exact overlap) | bounding box up to 30% false positives | - -On the interval side (section 3), none of the sources read in this pass reports a -pruning or culling fraction against an oracle mask, such as the truly empty cells or -the truly non-ambiguous tiles. They report only against self or peer baselines. The -oracle-referenced ratios found are all on the visibility side (sections 1.2 and 1.3), -and the one from rasterization (section 4) is search-only. No published figure was -found for interval-arithmetic culling of noise or warped-noise fields as a fraction of -an oracle. - -## 6. Local context (from the eureka mind, not re-measured) - -- **Question** `cultmath-tapes:question:wells-ceiling-oracle` (admitted 2026-10-03, - Imagination). At 3ac7250a it gives: - - warp 0: oracle efficiency 0.38, mask ceiling 0.96, cull fraction 0.95; - - warp D = 60: oracle efficiency 0.19, mask ceiling 0.99, cull fraction 0.84; - - a pre-pass that skips nothing: 0.14 against the oracle. -- **Finding** `cultmath-tapes:finding:cut-interval-ops.s2.wells-ceiling-contract-vacuous` - (Soul, confirmed by mutation). The mask-referenced (c) check reports 0.98 with the - wells skip disabled. Locations are in - `packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs`: lines 1257–1260, 1437 - and 1461. diff --git a/docs/research/cultcache-union-decode-tolerance-prior-art.md b/docs/research/cultcache-union-decode-tolerance-prior-art.md deleted file mode 100644 index fe3fe618..00000000 --- a/docs/research/cultcache-union-decode-tolerance-prior-art.md +++ /dev/null @@ -1,75 +0,0 @@ -# Union and record decode tolerance: prior art and CultCache's stance - -Fork: thing2:question:contract-decode-tolerance. Follow-up: thing2:follow_up:cultcache-union-parity. -Eyes pass, 2026-10-10, session self-2026-10-10c-eureka. Facts only; no recommendation. -Tags: [fetched] read this session; [local] read in the repo this session; [background] prior knowledge, not refetched; [not found] the fetched page did not say. - -## 1. Established systems - -### Protocol Buffers -- Unknown fields: proto3 "preserve[s] unknown fields and include[s] them during parsing and in the serialized output", matching proto2. Lost on JSON serialization and on field-by-field copy into a new message; CopyFrom/MergeFrom avoid the loss. (protobuf.dev/programming-guides/proto3/, "Unknown Fields") [fetched]. The version proto3 started preserving (3.5) [background]. -- Unknown oneof case: no distinct state. The page warns a NOT_SET result is ambiguous: the oneof may be unset, or set to a field from a newer schema [fetched]. A oneof member the reader lacks is an ordinary unknown field, so it sits in the unknown-field set and is re-emitted [background]. -- Unknown enum values: "unrecognized enum values will be preserved in the message" (raw int in open-enum languages, accessor in Java) and re-serialized [fetched]. - -### Cap'n Proto -- Union: a separate tag says which member is set. Adding a member to a union is safe because "existing programs should already know to check the union's tag"; they "may or may not behave reasonably when the tag has a value they don't recognize". Moving an existing field into a new union can show an old reader "a garbage value or throw an exception" (capnproto.org/language.html, "Unions", "Evolving Your Protocol") [fetched]. -- which() on an unknown discriminant: [not found] in the fetched language and encoding pages. C++ generated which() returns the tag as an enum and the reader is expected to switch with a default [background]. -- Preservation: [not found] on the fetched pages; structs "can be traversed (e.g., copied) without knowing their type" (encoding.html, Structs) [fetched]. Copy preservation of unknown data is [background]. - -### Avro (schema resolution; reader schema and writer schema both required) -- Both unions: reader takes its first branch matching the writer's selected branch; "if none match, an error is signalled". Writer union, reader non-union: the selected writer branch must match, else error (Avro spec, Schema Resolution) [fetched; also quoted from the 1.11.1 spec in docs/research/read-only-record-signal-prior-art.md:176-178]. -- Record, writer has an extra field: "the writer's value for that field is ignored". Reader field missing from the writer: reader's default if it has one; no default is an error [fetched]. -- Enum, writer symbol absent in reader: reader's declared default if any, else error [fetched]. -- Preservation: none. Extra fields are dropped by resolution [fetched]. - -### FlatBuffers -- Union evolution: appending a member is safe ("CodeV1 will not recognize the another_a"); inserting in the middle without an explicit discriminant misreads members; inserting with an explicit discriminant is safe (flatbuffers.dev/evolution/) [fetched]. -- What an old reader sees for an unknown union type, and re-serialization preservation: [not found] on that page. Generated readers expose a type byte plus a union table pointer; an unknown type value falls outside the generated enum [background]. - -### Thrift -- Unknown fields and unknown union field ids: [not found] in thrift-rpc.md. Protocol readers skip unrecognized field ids and drop the data; an unknown union id leaves the union empty, and a union with no field set can fail validation [background]. - -### MessagePack-CSharp [Union] -- README Union section says only "Unique union keys are required"; it states no behaviour for an unknown key and no option for it [fetched, first 100k chars of the README]. -- Missing keys: members initialize to default (README, Object Serialization) [fetched]. Extra array elements for [Key(int)] and unknown string keys: README silent; it shows a manual formatter that loops and skips extras [fetched]. -- Generated and dynamic union formatters skip the payload and yield null when the key is absent from the union's key map [background]. The estate's own measurement agrees: unknown arm key decodes to null, no error (question document, "Measured in the C# reference... MessagePack-CSharp 3.1.7") [local, via eureka-state view]. The vendored copy at F:\Projects\CultPong\Assets\Scripts\MessagePack\Resolvers\DynamicUnionResolver.cs does a key-map TryGetValue at :347 (type-map TryGetValue at :206); the miss branch was not read. -- No configurable unknown-union behaviour found in the README; whether a newer version adds one [not found]. - -### serde -- enum-representations page says nothing on unknown variant names, #[serde(other)] or deny_unknown_fields [fetched]. serde_derive de.rs was fetched but the identifier/enum_ modules holding unknown_variant were not in the excerpt [not found]. -- [background] default: an unknown variant is an error ("unknown variant `X`, expected one of ..."); #[serde(other)] on a unit variant makes the identifier decoder return it for any unknown name (units only, payload discarded); unknown struct fields are ignored unless #[serde(deny_unknown_fields)]; a missing field is an error unless #[serde(default)] or Option. - -### Bincode / postcard -- [background] Both are non-self-describing: an enum is a variant index (bincode u32, postcard varint) followed by fields in order; an out-of-range index is a decode error; there are no field tags, so an extra or missing slot is detectable only by running out of or leaving bytes. Evolution is by schema versioning outside the format. Not fetched. - -## 2. Preservation across an older reader, and the failure each answers -| System | Unknown data survives re-encode? | Failure answered | -|---|---|---| -| Protobuf | yes: unknown fields (hence unknown oneof cases) and unknown enum ints, in binary APIs only [fetched] | old intermediary re-serializing a newer message (purpose: background) | -| Cap'n Proto | page silent; reader sees a tag it may not know and must handle it [fetched] | in-place access; append-only evolution | -| Avro | no: extra field dropped, or error on no branch / no default [fetched] | writer schema travels with data, so resolution is exact and loud | -| FlatBuffers | page silent [fetched] | append-only evolution, explicit discriminants | -| Thrift | no (skipped) [background] | forward tolerance for old readers | -| MessagePack-CSharp | no: arm becomes null (measured), extra slot skipped | not documented | -| serde | no; error by default [background] | type safety; leniency is opt-in | -| Bincode/postcard | n/a [background] | compactness; no evolution in the format | -| Unity SerializeReference, DataContract ExtensionData | yes: bytes retained and recoverable (docs/research/read-only-record-signal-prior-art.md:182-205) [local] | data loss from missing types | - -## 3. CultCache's own stance (F:\Projects\CultLib) -- docs/persisted-record-encoding.md:1-19: persisted records are verified by re-encoding what was decoded and comparing bytes; a record that reads but re-encodes differently is refused, on live data at startup or next read. Three Idunn guards cited at :10-14. [local] A tolerated extra trailing slot or a null-collapsed arm would not re-encode to the stored bytes; whether those guards would run on such records was not tested. -- No evolution/compatibility doc: `ls docs | grep persist|evol|compat|schema|version` returns only persisted-record-encoding.md. docs/document-variants-cut.md:327-333 covers union-slot reuse at registration ("late union-slot reuse passes registration"; "interface unions are never minted") [local, grep lines only]. -- Reference union handling: src/GameCult.Caching/CultInspectorModel.cs:768-774 classifies an abstract/interface type by its [UnionAttribute]s ordered by key and refuses a type with none ("declares no [Union] subtypes", :772); also :120. This is the inspector's shape classifier; decode is MessagePack-CSharp's. No other use of UnionAttribute in src/GameCult.Caching. [local] -- Trailing-slot tolerance: packages/cultcache-ts/test/cult-cache.test.ts:1176-1195, "CultCache interop reader accepts missing compatible trailing slots and rejects mismatched slots": a legacy-payload store with fewer slots reads with `tags: []`; a mismatched-type payload rejects with /Expected string/u. Missing trailing slots are tested; extra trailing slots are not. [local] -- TS decode: packages/cultcache-ts/src/cult-cache.ts:679-692 wraps a formatter as `schema.parse(decode(payload))`, so TS strictness is whatever the zod schema says; no TS union codec (follow-up text). [local] -- Rust: packages/cultcache-rs/src/*.rs has no unknown-arm or extra-slot handling found by grep; "unknown" hits are store-header tests (:4889-4890 refuses an unknown header by name; :5009-5019 unknown-header.msgpack, variant-v2.msgpack). Rust enum arms persist as serde external tags (follow-up text). [local] -- Consumers persisting unions: Aetheria (F:\Projects\Aetheria) has `[Union]` abstract classes in Assets/Scripts/ServerShared: Provenance.cs:96-98 (keys 0-2), ItemInstance.cs:18-21 (keys 0-3) and :29-31, Environment.cs:73. The assembly registers CultCache documents (AssemblyInfo.cs:3-4; Galaxy.cs, ItemData.cs, AetheriaStores.cs reference CultCache); ItemInstance is held in entity item lists (Entity.cs:2003). An older build reading a store with a newer arm key would take the C# null-arm path, if these types sit inside persisted CultCache documents; that persistence path was not traced. Aetheria-legacy has more unions (Behaviors.cs:29-38, Item.cs:43-63, Contract.cs:10-11); commented-out keys 8, 9 at Behaviors.cs:37-38 show arms retired in place. [local] -- Ghostlight and Huginn: not searched for [Union] (the grep matched only Aetheria). Follow-up text: "No live record crosses runtimes as a union today" [local, view]. Same-runtime older-build-reads-newer-store: unverified. -- The question document records the C# measurement: extra trailing slot skipped and equal; missing trailing slot leaves member default; unknown arm null, for a Node in a list and for an Outcome; Rust and TS union decoders with explicit keys refuse by construction; Rust extra-slot behaviour unmeasured [local, view]. - -## 4. Operator's stated value, and how each option relates (inferred) -Verbatim, operator-rapport.md:50: "nobody should have to carry bytes they don't understand ... CultCache's whole promise is that a cache's contents are self-identifying via the upfront catalog." Context: pushing back on storing retired slots as metadata (:49). [local] -- Preserve-unknown (protobuf, Unity): the older reader carries bytes the catalog does not describe. Opposite to the stated value. -- Drop silently (Avro extra fields, MessagePack slot skipping, Thrift skip): nobody carries the bytes, but the loss is silent and a re-encode no longer equals the stored bytes (persisted-record-encoding.md:4-6). -- Null the arm (current C# union behaviour): the unknown arm becomes a value the catalog does not describe either; the record decodes as if valid. -- Refuse (Avro no-branch, serde default, Rust/TS explicit-key decoders, store-header refusal): the reader declares it cannot understand the bytes; consistent with self-identifying content because undescribed content is not accepted. -- Tolerate trailing slots but refuse unknown arms (fork option 1): the catalog-described slot list governs required members; slots beyond it are skipped, which is the drop-silently pattern for slots and the refuse pattern for arms. diff --git a/docs/research/foreign-records-prior-art.md b/docs/research/foreign-records-prior-art.md deleted file mode 100644 index 4238bb6e..00000000 --- a/docs/research/foreign-records-prior-art.md +++ /dev/null @@ -1,462 +0,0 @@ -# Foreign Records: Prior Art Survey - -Facts file for the single-file "foreign records" fork (lay-back versus refusing -whole-view writes while holding records the writer does not own). Eyes pass, -2026-10-02. Facts and evidence pointers only; no recommendation. - -Verification marks: - -- **[fetched]** the claim was read on the cited page during this pass. -- **[search]** the claim came from a search-result summary of the cited page, - not a full read. -- **[memory]** recalled from the cited source, not re-read in this pass. - Treat it as unverified. - -## 0. Our design, for comparison - -Source: `src/GameCult.Caching/Contracts/cultcache-persistence-format.md` (main, 614fd445). - -- Store is `[header, catalog, records]`; the catalog "must embed a catalog entry - for every schema referenced by the records it contains" (Embedded Schema Catalog). -- The stated purpose of the catalog is to let another implementation "decide - whether it can: read directly, soft-migrate with warnings, or refuse the data - honestly". -- Soft migration lists "persisted schema has extra slots the local reader can - safely ignore or preserve" and the warning "field preserved but not surfaced - natively". That is slot-level preservation inside a record the reader owns. The - contract does not mention records under schema ids the reader does not own; - the lay-back ruling lives elsewhere (grep of `src/**/*.md` for "foreign" or - "lay-back" found nothing). -- Concurrency: "A plain flush and an unconditional commit are last-writer-wins - ... a single file is replaced by the writer's whole view." "Conditional commit - is the only safe multi-process write." C# and Rust implement conditional - commit; TypeScript and Python do not yet (Transaction Visibility). - -Granularity note used throughout: most systems below handle unknown *fields -inside a record whose type the writer knows*. Our fork is about unknown *whole -records* (schema ids) inside a container the writer rewrites. Each entry says -which granularity it covers. - -## 1. Serialization formats - -### 1.1 Protocol Buffers: unknown-field preservation - -- **What it does.** Unknown fields are "well-formed protocol buffer serialized - data representing fields that the parser does not recognize". Proto3 messages - "preserve unknown fields and include them during parsing and in the serialized - output, which matches proto2 behavior." [fetched] https://protobuf.dev/programming-guides/proto3/ (Unknown Fields) -- **Where preservation fails, per the docs.** Serializing to JSON; iterating - fields to populate a new message. Mitigation given: use binary, use - `CopyFrom()`/`MergeFrom()`. TextFormat prints unknown fields by number but - cannot parse them back. [fetched] same page. -- **History.** Proto3 shipped dropping unknown fields. v3.5.0 release notes: - "Unknown fields are now preserved in proto3 for most of the language - implementations for proto3 by default." C++ and Python offer - `DiscardUnknownFields()`, Java a `DiscardUnknownFieldsParser`, for callers who - relied on dropping. The release notes give no rationale. [fetched] - https://github.com/protocolbuffers/protobuf/releases/tag/v3.5.0 -- **Why it was restored.** No official rationale document was found. The - user-facing request is issue #272 (2015-04-07): "I know that unknown fields - have been removed from proto3, but I am trying to get an explanation about why - this change was made". The thread body was not readable in this pass. [fetched, - partial] https://github.com/protocolbuffers/protobuf/issues/272. Secondary - accounts attribute the reversal to pass-through and read-modify-write - intermediaries in uncoordinated upgrades. [search] - https://github.com/scalapb/ScalaPB/issues/406, https://kmcd.dev/posts/protobuf-unknown-fields/. - **The primary reasoning is unverified.** -- **Cost and regret.** Go: preservation through `XXX_unrecognized []byte` - broke users who compared proto3 messages with `==` or used them as map keys. - [search] https://groups.google.com/d/msg/golang-nuts/F5xFHTfwRnY/sPv5nTVXBQAJ. - JSON round trips still drop unknown fields; there is an open request to keep - them. [search] https://github.com/golang/protobuf/issues/1390. A secondary - source flags preserved unknown fields as a way to smuggle unvalidated payloads - past validation at trust boundaries. [fetched] https://kmcd.dev/posts/protobuf-unknown-fields/ -- **Granularity.** Field level, inside a message the reader's code knows. - Protobuf does not preserve unknown *message types*; the closest is - `google.protobuf.Any` (type URL plus bytes), which carries an opaque typed - payload as a declared field. [memory] -- **Differs from us.** There is no in-band schema. Unknown bytes are - uninterpretable without the newer `.proto`, and only tag and wire type are - self-describing. There is no container rewrite or multi-process store - concern; protobuf is a message codec. - -### 1.2 Protobuf field-number reuse - -- **Rule.** "Field numbers should never be reused. Never take a field number out - of the reserved list for reuse with a new field definition." Listed - consequences: "Developer time lost to debugging, A parse/merge error (best case - scenario), Leaked PII/SPII, Data corruption." Syntax: `reserved 2, 15, 9 to 11;` - and `reserved "foo", "bar";`. [fetched] https://protobuf.dev/programming-guides/proto3/ -- Best practices: "Never re-use a tag number. It messes up deserialization." - Reserve deleted numbers. "Almost never change the type of a field." Renaming - breaks JSON and text format because they key on names. [fetched] - https://protobuf.dev/best-practices/dos-donts/ -- Kleppmann (2012): "you must never reuse the tag number for another field in - future, because you may still have data stored that uses that tag for the field - you deleted". [fetched] https://martin.kleppmann.com/2012/12/05/schema-evolution-in-avro-protocol-buffers-thrift.html -- **Named public incidents:** none found in this pass. The docs' consequence - list is the strongest primary evidence; blog posts repeat it. **Unverified.** -- **Differs from us.** Our `schemaId` is a content hash of the canonical slot - schema, so changing slot meaning changes the id. The reuse hazard moves from - "number collides" to "a record under an old id is carried, or reinterpreted, - after an undeclared rename". - -### 1.3 Avro and schema registries - -- **Resolution.** The reader needs the writer's schema. Fields in the writer - schema but not the reader's are ignored. Reader fields missing from the writer - take the reader default, or raise an error when there is no default. Aliases - map renames. [fetched] https://avro.apache.org/docs/1.11.1/specification/ (Schema Resolution) -- **Object Container Files** carry the schema once in the header (`avro.schema`, - required). One file has one writer schema. [fetched] same page. -- **Kleppmann (2012):** Avro needs "the exact same version of the schema as the - writer of the data", so you either "annotate each record with its schema - version" or use "a schema registry". [fetched] blog above. -- **Confluent wire format:** byte 0 is the magic byte (0), bytes 1 to 4 are the - big-endian schema id; the deserializer fetches the writer schema by id. - [fetched] https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/index.html -- **Compatibility modes:** BACKWARD (the default), FORWARD, FULL, their - `_TRANSITIVE` forms, and NONE. BACKWARD is the default "so that you can rewind - consumers to the beginning of the topic". Upgrade order follows the mode: - consumers first for BACKWARD, producers first for FORWARD. [fetched] - https://docs.confluent.io/platform/current/schema-registry/fundamentals/schema-evolution.html -- **Failure mode.** Resolution projects writer data onto the reader schema, so - writer-only fields are gone from the decoded object. A read-modify-write by an - older reader loses them unless the application keeps the writer record. - [inference from the spec; no Avro doc states it as a warning] -- **Differs from us.** Kafka records are immutable log entries, so consumers - never rewrite the producer's records. A container file is written once by one - writer. Neither case has whole-file rewrite by several processes. - -### 1.4 Thrift - -- Generated readers switch on field id and call - `TProtocolUtil.skip(iprot, schemeField.type)` in the default case: unknown - fields are skipped. [search; generated-code pattern] Kleppmann (2012) says the - same of protobuf and Thrift: the parser "can figure out how many bytes it needs - to skip". [fetched] -- **Conflict.** "Thrift: The Missing Guide" says unknown fields "are not - discarded, and if the message is later serialized, the unknown fields are - serialized along with it". That text reads as copied from protobuf docs. - [fetched] https://diwakergupta.github.io/thrift-missing-guide/. Apache Thrift's - generated Java skips without retaining. **Retention is unverified and likely - false for stock Apache Thrift.** -- Rules: never change numeric tags; new fields optional; prefix removed fields - `OBSOLETE_`. [fetched] Missing Guide. - -### 1.5 Cap'n Proto - -- Field ordinals are append-only: "as long as each new member's number is larger - than all previous members"; "You cannot change a field, method, or enumerant's - number." [fetched] https://capnproto.org/language.html -- Unknown fields survive a copy: "If you copy the struct from one message to - another (e.g. by calling a set() method on a parent object), the extra fields - will be preserved." Caveat: "copying a struct value from another message into - an element of a list will truncate the value". [fetched] https://capnproto.org/cxx.html -- The wire format carries just enough structure (struct or list, sizes) to copy - an object recursively without its schema. [search] - https://capnproto.org/encoding.html. Preservation is a property of the encoding, - not of a per-type rule. -- **Differs from us.** The copy is opaque; nothing is reinterpreted. There is no - catalog and no store. - -### 1.6 FlatBuffers - -- Add new fields at the end; never remove one, mark it `deprecated` instead (no - accessors are generated); explicit `id` attributes relax ordering. Old readers - ignore unknown fields. [search] https://flatbuffers.dev/evolution/ -- The object API (unpack, mutate, pack) builds a fresh buffer from native - fields. Whether unknown fields survive that round trip: **not verified in - this pass** [memory: they do not]. -- Known defect: C++ object API with deprecated fields generated non-compiling - code. [search] https://github.com/google/flatbuffers/issues/5186 - -### 1.7 Microsoft Bond - -- `bonded` defers deserialization and holds a reference to the serialized - form. "Using bonded allows the intermediary to aggregate responses, - preserving their full content, even though schema of Response is not known - when the aggregator is built." Transcoding through a bonded value preserves - fields not in `T`. [fetched] https://microsoft.github.io/bond/manual/bond_cpp.html -- Untagged protocols (Simple Binary) "serialize only data and thus require that - consumers know the payload schema via some out-of-band mechanism"; Bond also - has runtime schemas (`SchemaDef`) for that. [fetched; SchemaDef from memory] -- Changing ordinals is a breaking change. [fetched] -- **Note.** Bond's preservation is an explicit opt-in wrapper type at the - declared pass-through point, not default retention of everything. - -### 1.8 MessagePack-based schema systems - -- MessagePack itself has no schema. MessagePack-CSharp (`[Key(n)]` int keys, the - basis of our slot layout) has no documented unknown-key or extension-data - retention for typed objects. A search found no such feature and no issue - requesting it. **Unverified absence.** - https://github.com/MessagePack-CSharp/MessagePack-CSharp -- Comparable opt-in field-level retention in other ecosystems: - Newtonsoft.Json and System.Text.Json `[JsonExtensionData]` capture unmapped - properties into a dictionary and write them back; serde `#[serde(flatten)]` into - a map does the same, and is incompatible with `deny_unknown_fields`. [search] - https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft, - https://serde.rs/attr-flatten.html. All are field level and opt in per type. -- **FIDL (Fuchsia), RFC-0033:** messages with unknown fields "MUST be validated - and parsed successfully"; the default is `flexible` (unknown values allowed and - exposed), and the `strict` keyword makes unknown fields invalid. Unknown - handles must be closed by default. The RFC frames strictness as a security tool - for protocols where misinterpreting new data is dangerous. [fetched] - https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0033_handling_unknown_fields_strictness - -## 2. Embedded stores and document databases - -### 2.1 SQLite - -- **Unknown tables.** The writer modifies pages through the B-tree and rollback - or WAL journal. Tables a program never touches are never rewritten, so there is - no rule about them. [memory; consistent with the file format doc] -- **Unknown schema syntax.** A library older than 3.31.0 opening a schema with - generated columns "will perceive the generated column syntax as an error and - will report that the database schema is corrupt". Older versions can read and - write newer files "as long as the database schema does not contain features - ... not understood by the earlier version". [search] https://sqlite.org/gencol.html. - The whole database is refused, not just the table. -- **File format versions.** Write version > 2: "the database file must be treated - as read-only". Read version > 2: "that database cannot be read or written". - [fetched] https://www.sqlite.org/fileformat2.html (offsets 18 and 19). This is - a format-level read-only fallback for content the library cannot safely write. -- **Schema change across connections.** The schema cookie (offset 40) is bumped - on every schema change. A prepared statement checks it and reprepares or fails - with `SQLITE_SCHEMA`. [fetched] same page. -- `user_version` (offset 60) and `application_id` (offset 68) are application - owned; SQLite does not use them. [fetched] -- **Whole-file rewrite.** SQLite's own comparison: custom and wrapped - pile-of-files formats "usually require a rewrite of the entire document in - order to change a single byte", and application concurrency logic for them is - "a notorious bug-magnet". [fetched] https://www.sqlite.org/appfileformat.html -- **Differs from us.** The schema is SQL text in `sqlite_schema`, not a typed - slot catalog. Writes are partial and in place, and there is one implementation - rather than five. - -### 2.2 LMDB - -- Opaque byte keys and values, no schema; named sub-databases. Copy-on-write - B+tree with MVCC. One writer at a time, serialized by a mutex in the lock file; - readers do not block the writer and the writer does not block readers; - several processes may open one environment. [search; lmdb.tech/doc was not - reachable over TLS in this pass] https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database, - https://lmdb.readthedocs.io/ -- `MDB_INCOMPATIBLE`: an operation does not match a database's flags (for - example dupsort), or "the database type changed". [search] -- **Differs from us.** There are no types, so "foreign" is not a concept; - untouched keys are never rewritten. - -### 2.3 Core Data (Apple) - -- **Model mismatch is refused.** "The model used to open the store is - incompatible with the one used to create the store" (Cocoa error 134100) - unless a migration runs: lightweight (inferred mapping, using - `NSMigratePersistentStoresAutomaticallyOption` and - `NSInferMappingModelAutomaticallyOption`) or custom/staged. [search] - https://developer.apple.com/forums/thread/100639 -- Store metadata holds per-entity version hashes (`NSStoreModelVersionHashes`). - `isConfiguration(withName:compatibleWithStoreMetadata:)` compares them with - the model. [search] - https://developer.apple.com/documentation/coredata/nsmanagedobjectmodel/isconfiguration(withname:compatiblewithstoremetadata:) -- **Atomic stores (XML, binary) are the closest analogue to our single file.** - They keep the whole object graph in memory and save the whole file: "the old - file is not deleted until the new one has been successfully written." - [fetched] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreData/PersistentStoreFeatures.html. - Combined with the refusal above, an atomic store is never rewritten by a model - that does not cover every entity in it. The page says nothing on multi-process - access to atomic stores. [fetched: absence] -- **Differs from us.** Single runtime, entity-hash catalog in metadata, a - migration-or-refuse gate at open. No foreign entity is ever carried. - -### 2.4 Realm - -- Opening with a changed schema requires a higher `schemaVersion`, plus a - `migrationBlock` where needed; otherwise "Migration is required". Added and - removed properties are applied to the on-disk schema automatically on - migration. [search] https://github.com/realm/realm-js/issues/4752, - https://realm.netlify.app/docs/swift/latest/ -- A changelog entry allows opening old frozen versions "with a schema that - contains additional classes, but not additional properties". [search] - https://github.com/realm/realm-core/releases?page=5 -- Whether a Realm opened with a class *subset* keeps the other tables untouched: - **not verified** [memory: the tables are kept, since Realm writes in place by - table and does not rewrite the whole file]. -- Realm file-format upgrades are one-way. [memory] - -### 2.5 CouchDB and PouchDB - -- `PUT /{db}/{docid}` writes a new revision of the whole document; there is no - field merge, and omitted fields are gone in the new revision. A missing or - stale `_rev` returns `409 Conflict`: "specified revision is not latest for - target document". The revision may be given in the body, as `rev`, or in - `If-Match`. [fetched] https://docs.couchdb.org/en/stable/api/document/common.html -- Under replication, conflicting revisions are all kept; one deterministic - winner is chosen and the others are marked `_conflicts`; CouchDB does not merge. - [search] https://docs.couchdb.org/en/stable/replication/conflicts.html -- There is no schema; unknown fields survive only if the client writes them - back. Document-mapper layers drop them: Mongoose's `strict` option "ensures - that values passed to our model constructor that were not specified in our - schema do not get saved to the db", and is "enabled by default". [fetched] - https://mongoosejs.com/docs/guide.html (MongoDB, cited as the same pattern). -- **RxDB** (on PouchDB or other storage): any schema `version` > 0 requires - `migrationStrategies` for each step; a strategy returning `null` deletes the - document; writes during a running migration fail with `COL25`; in multi-tab - setups "exactly one tab is running a migration of a collection". [fetched] - https://rxdb.info/migration-schema.html. Opening storage written by a newer - RxDB major is refused ("Cannot open database state with newer RxDB version"). - [search] https://github.com/pubkey/rxdb/issues/5836 -- **Differs from us.** The per-document `_rev` gives optimistic concurrency at - record granularity, and documents are never rewritten as a side effect of - writing another. - -### 2.6 IndexedDB - -- No field schema: values are structured clones, stored by value. Schema is - object stores and indexes, versioned by an integer. [fetched] https://www.w3.org/TR/IndexedDB/ -- Opening with a higher version fires `upgradeneeded` inside a versionchange - transaction. Opening with a *lower* version than the stored one fails with - `VersionError`: "An attempt was made to open a database using a lower version - than the existing version." Older code is refused outright. [fetched] same spec. -- Other open connections receive `versionchange`; if they stay open the upgrader - gets `blocked`. [fetched] same spec and - https://developer.mozilla.org/en-US/docs/Web/API/IDBOpenDBRequest/blocked_event -- **Differs from us.** The browser engine is the single writer implementation - and the schema has one integer owner per database. - -### 2.7 Whole-file rewrite while preserving unknown content - -Systems found that rewrite a container while keeping parts they do not -understand: - -- **Automerge binary format.** Programs that edit documents must "maintain all - columns, even those that they don't understand the meaning of" and write null - into unknown columns for new rows. Implementations "must preserve operations - containing actions they don't support". Unknown value type codes: "MUST read and - store the type code and `length` bytes". Changes are SHA-256 hashed over their - binary form, so byte preservation is required for hash integrity. [fetched] - https://automerge.org/automerge-binary-format-spec/. The unit carried is an - immutable, content-addressed change; nothing preserved is ever re-decided by - the carrier. -- **Core Data atomic stores** rewrite the whole file but refuse to open under an - incompatible model (2.3), so they never carry unknown entities. -- No system was found that rewrites a whole mutable file while carrying - mutable records of unknown types that other writers may change concurrently. - **Absence of evidence, not a verified negative.** - -## 3. Literature - -- **Kleppmann, *Designing Data-Intensive Applications* (1st ed., O'Reilly 2017), - ch. 4 "Encoding and Evolution", section "Dataflow Through Databases".** [memory, - not re-read] The section says an older version of code may read, update and - write back a record written by newer code, and newer fields can be lost unless - the old code keeps unknown fields. Figure 4-7 shows this. The section contains - the line "data outlives code" [search; confirmed in secondary notes - https://gist.github.com/bcherny/b870a60d1650973df7e400c8603ac76d]. It also says - rewriting data into a new schema is possible but expensive, so most databases - avoid it. **The exact wording is unverified.** -- **Scherzinger, Klettke, Störl, "Managing Schema Evolution in NoSQL Data - Stores", DBPL 2013.** Contrasts eager migration with *lazy* migration (migrate - on read or touch) for schema-less stores whose data grows heterogeneous. - [search] https://arxiv.org/abs/1308.0514 -- **Ringlstetter, Scherzinger, Bissyandé, "Data model evolution using - object-NoSQL mappers: folklore or state-of-the-art?", BIGDSE@ICSE 2016, - pp. 33-36.** Mapper evolution annotations (rename, remove, transform on load) - are used on GitHub, but mostly for tasks other than evolving the data model. - [search] https://dblp.org/rec/conf/icse/RinglstetterSB16.html -- **Scherzinger and Sidortschuck, "An Empirical Study on the Design and Evolution - of NoSQL Database Schemas", ER 2020.** [search, not read] - https://arxiv.org/pdf/2003.00054 -- **Bancilhon and Spyratos, "Update semantics of relational views", ACM TODS - 6(4), 1981, pp. 557-575.** A view update is translated by holding a chosen - *complement* constant; a complete set of view updates has a translator iff it - is translatable under constant complement. [search] - https://dl.acm.org/doi/10.1145/319628.319634. Mapping (this survey's framing, - not the paper's): a writer's owned records are a view of the store, the foreign - records are the complement, and lay-back is constant-complement translation. -- **Foster, Greenwald, Moore, Pierce, Schmitt, "Combinators for bidirectional tree - transformations", POPL 2005 / TOPLAS 2007.** A lens is `get: S -> V` and - `put: V x S -> S`. Laws: GetPut, `put(get(s), s) = s`; PutGet, - `get(put(v, s)) = v`; PutPut is the stronger optional law. `put` takes the - source `s` as an argument, so the complement is restored from whatever `s` is - supplied. [search for the paper; the law statements are from memory, and one - search summary had GetPut and PutGet swapped] - https://www.cis.upenn.edu/~bcpierce/papers/lenses-toplas-final.pdf -- **Litt, van Hardenberg, Henry, "Project Cambria" (Ink & Switch, Oct 2020).** - Bidirectional lenses between schema versions, arranged as a graph. In - Cambria-Automerge every write is tagged with its writer's schema and translated - at read time, so "old changes can be evolved using lenses that didn't even - exist at the time of the original change". Lenses travel inside the document. - Stated limits: lossy conversions (scalar to array), one-way changes - (split/merge), no external lookups, untested performance. "There are limits to - interoperability." [fetched] https://www.inkandswitch.com/cambria/ -- **Local-first and CRDT, Automerge:** see 2.7. Unknown ops, columns and value - types from newer peers are preserved byte for byte and are immutable once - written. [fetched] - -## 4. Concurrency facts for whole-file rewrite - -- **Last-writer-wins on whole replace** loses a concurrent writer's changes - unless the write is conditional. Our contract already says this (section 0). -- **HTTP optimistic concurrency.** RFC 9110 §13.1.1 If-Match exists to prevent - the "lost update" problem; a failed precondition returns 412 Precondition - Failed (§15.5.13). [memory; the page fetch truncated before those sections] - https://www.rfc-editor.org/rfc/rfc9110.html#section-13.1.1 -- **Per-record CAS:** CouchDB `_rev`, 409 (2.5). -- **Git ref update:** `git update-ref ` stores the new value - "after verifying that the current value of the matches ". - Transactions lock every ref (`.lock` files) at `prepare`; "If all s can be - locked with matching s simultaneously, all modifications are - performed. Otherwise, no modifications are performed." [fetched] - https://git-scm.com/docs/git-update-ref. The pattern: take an exclusive lock - file, compare the old value under the lock, write, rename into place. -- **SQLite** serializes writers by file lock (rollback) or WAL write lock; - schema-cookie checks catch schema drift between prepare and run (2.1). -- **LMDB:** single writer mutex across processes, MVCC readers (2.2). -- **IndexedDB:** schema change is an exclusive versionchange transaction that - waits on other connections (2.6). -- **RxDB:** one migrating tab, writes refused during migration (2.5). -- **Crash consistency of temp-plus-rename.** Pillai et al., "All File Systems Are - Not Created Equal: On the Complexity of Crafting Crash-Consistent - Applications", OSDI 2014. The ALICE tool found 60 crash vulnerabilities across - 11 widely used applications; persistence properties, including how rename - orders against data writes, vary across six Linux file systems. [search] - https://research.cs.wisc.edu/adsl/Publications/alice-osdi14.pdf. Whether - `fsync` of the temp file and its directory is needed for durability of the - rename: [memory: yes on Linux ext4 and others]. Windows `MoveFileEx` with - `MOVEFILE_REPLACE_EXISTING` and `ReplaceFile` atomicity guarantees: **not - verified in this pass.** - -## 5. Cross-cutting facts, as observed (not conclusions) - -- Every system found that preserves unknown data does so at *field* level - inside a record whose type the code owns (protobuf, Cap'n Proto, Bond opt-in, - JSON extension data, serde flatten), or as *immutable content-addressed* - units (Automerge changes). -- Systems that hold several record types in one store either rewrite only what - they touch (SQLite, LMDB, Realm [unverified], CouchDB, IndexedDB), or rewrite - the whole file and refuse a model that does not cover the file (Core Data - atomic stores). -- Systems where older code meets a newer schema at open time do one of: - refuse to open (IndexedDB `VersionError`, Core Data 134100, RxDB newer-major, - SQLite unknown schema syntax), go read-only (SQLite write version > 2), or - require a migration before any write (Realm, RxDB, Core Data). -- Protobuf moved from dropping to preserving (3.5). Its documented residual - losses are in conversion paths (JSON, field-by-field copy), and Go's - preservation broke message comparability. -- FIDL made preserve-and-expose the default and added `strict` as an opt-in - refusal, justified on security grounds. - -## Not verified in this pass - -- Primary rationale for restoring proto3 unknown fields in 3.5. -- Any named incident caused by protobuf field-number reuse. -- Stock Apache Thrift retention of unknown fields (the Missing Guide says yes, - the generated-code pattern says skip). -- FlatBuffers object-API round trip of unknown fields. -- MessagePack-CSharp unknown-key retention (absence). -- Realm behaviour opening with a class subset. -- Exact DDIA wording and figure number. -- LMDB primary docs (TLS failure); RFC 9110 section text. -- Windows rename and replace atomicity semantics. diff --git a/docs/research/integration-native-noise-domain.md b/docs/research/integration-native-noise-domain.md deleted file mode 100644 index 0dcdfae1..00000000 --- a/docs/research/integration-native-noise-domain.md +++ /dev/null @@ -1,291 +0,0 @@ -# An integration-native volumetric noise domain: probe - -Campaign `cultmath-tapes`, Imagination probe, 2026-10-03, under ruling -`cultmath-tapes:ruling:integration-native-noise-domain`. This is research under the -parked tape target. It has no spec, no shipped-field change and no committed code. - -It follows `analytic-integration-feasibility.md`, which found that exact noise -integrals are cheap but that the shipped densities are nonlinear in the noise. The -question here is the reverse one. Suppose a domain is designed so that span -integration holds by construction. Does it buy more visual detail per unit cost -than the shipped fields? - -On the operator's instruction (relayed by Self), the reference is physical, not -Aetheria's tuned compositing: -- transmittance is Beer–Lambert, `T = exp(-τ)`; -- the images use single scattering with Henyey–Greenstein `g = 0.6` and albedo 1; -- both fields are integrated the same way. - -The shipped look is a comparison, not a target. - -## Verdict - -**On the void, yes, by a wide margin. On the wells, modestly.** At or below the -shipped march's cost, the integration-native field carries much more resolvable -detail, and it is exact. The catches: -- The look changes character. The default cascade reads as fibres or brush strokes, - not as soft cloud. -- The cost is traversal, not integration. -- The field cannot be ray-marched at all. Every consumer, shadow rays included, - must use the exact path. - -Headline numbers, 512 x 256, single-threaded C# on Yggdrasil: - -| Void, transmittance image | Cost per pixel | vs shipped march | msf (grad²/var) | Power above 1/8 cycle/px | Pixels with \|∇T\| > 0.05 | -|---|---|---|---|---|---| -| Shipped field, converged reference (595 samples) | n/a | n/a | 0.0111 | 0.20% | 0.00% | -| Shipped march (11.4 samples) | 28.9 µs (44 snoise3) | 1.00x | 0.0178 | 0.71% | 0.00% | -| Integration-native, 2 levels, exact | 13.9 µs | **0.48x** | **0.0755** | **2.95%** | 41.9% | -| Integration-native, 3 levels, exact | 35.7 µs | 1.24x | 0.125 | 9.15% | 54.7% | -| Integration-native, 6 levels (LOD stops at 4 to 5), exact | 74.2 µs | 2.57x | 0.159 | 12.5% | 60.9% | - -- **Mean density is matched.** - - The integration-native field places mass from the shipped field's noise-averaged - density. - - Mean window optical depth is 1.62 to 1.74 against the shipped 1.81. - - Mean T is 0.25 to 0.40 against 0.17. The difference comes from intermittency: - the image std is 0.29 against 0.05, at a near-equal mean. -- **msf is normalised by variance.** It measures spatial frequency, not contrast. -- **Single-scattering images, void.** The images are 256 x 128 with a point light at - the sun, and both are tonemapped with the same exposure. The shipped image's msf - is 0.0023, with 0.22% of power above 1/8. The integration-native image's msf is - 0.101, with 16.9% of power above 1/8. -- **Wells.** - - Transmittance is a near-opaque silhouette for both fields: equal msf (0.011), - so it carries no signal. - - Single scattering at 6 levels (1.20x the march cost): - - msf is 0.073 against 0.069; - - power above 1/8 is 10.1% against 7.0%; - - the edge fraction is 16.7% against 9.5%. - - At 4 levels the cost is 0.77x the march. - -**Exactness.** Against a converged march of the same field at 0.02 world: -- The relative τ error is a median 3e-5 and a maximum of 1.0e-4 on the void, and a - median 1e-5 and a maximum of 1.0e-4 on the wells. -- The binned gather against brute force over all roots differs by at most 1.3e-15. -- The shipped march against its own converged reference: |ΔT| is a median 0.0055 - (p90 0.013) on the void and a median 0.0006 (max 0.83 on grazing rays) on the - wells. - -**The detail is only reachable by integration.** -- Marching the same integration-native field at the shipped step gives a void |ΔT| - median of 0.14, a p90 of 0.48 and a maximum of 0.83. -- A field this detailed is beyond the march at its step. That is the operator's - premise, measured: the shipped fields' softness fits the regime that renders them. - -## The primitive set - -The primitive set has one design rule: nonlinearity lives in kernel placement, and -linearity lives in the integration. The density is a sum of nonnegative, -compact-support kernels. Everything nonlinear is evaluated once per kernel, at its -centre, and never per sample. That covers envelopes, clamps, `pow` profiles, the -flow warp and placement. - -### Bases (closed-form line integral over a segment) - -| Primitive | Why it integrates | Cost per span (measured unless marked) | -|---|---|---| -| Compact polynomial ellipsoid kernel, `(1 − u)^k` with `u = \|A⁻¹(x − μ)\|²` | On a line, u is quadratic in t, so the kernel is a polynomial of degree 2k between the two roots of `u = 1`, which are closed form. Same algebra as the simplex lattice integral in the first probe | k = 0: 5.5 to 7.4 ns; k = 1: 8 to 9.5 ns; k = 2: 11.7 ns. About 0.01 to 0.02 snoise3 (snoise3 is 610 to 650 ns in C#) | -| Truncated Gaussian ellipsoid, `exp(−κu)` on `u ≤ 1` | `exp` of a quadratic is a Gaussian in t, giving an erf difference. Truncation only clips the limits | 32 to 36 ns with A&S 7.1.26 erf (error ≤ 1.5e-7), about 0.05 snoise3 | -| k = 0 ellipsoid (constant density) | Chord length; this is EVER's primitive (Mai et al. 2024 [memory]) | 5.5 ns | -| Gabor kernel (Gaussian × cosine) | Complex erf, any affine transform (Gabor Fields 2026, eq. 9 [fetched in the prior-art file]) | Not probed. Up to 16 Taylor terms [paper] | -| Cosine sum (Balint 2019) | Integral is a sum of sines | Not probed. Two noise-sized evaluations per segment [paper]. Signed, so it needs an offset; low contrast | -| Simplex lattice (CultMath `snoise`) | First probe: degree 9 per lattice point | 0.16 snoise3 per point, 3.44 points per noise unit. Signed: only usable where density is affine in it | - -### Warps - -| Warp | Why it stays exact | Cost | -|---|---|---| -| Per-kernel affine warp: centre moved by `f(μ)·s`, shape by `(I + J·s)` | An affine image of an ellipsoid is an ellipsoid, so the ray stays straight and the kernel stays closed form. The warp *defines* the field, so there is no approximation error. It is evaluated once per root per frame (7 flow evaluations with the Jacobian) | Frame build 39 ms (void, 2540 roots) and 57 ms (wells, 16947 roots), or 19 and 27 ns per 1080p pixel amortised | -| Children inherit the parent's affine frame | The cascade has descendants that are exact affine images, so the warp is evaluated only at the roots | One 3x3 product per child, from a table | -| Not allowed | A per-point warp `x + w(x)` inside a span: the warped ray curves, which was the first probe's problem | n/a | - -### Transfer and placement - -| Rule | Status | -|---|---| -| Any function of the kernel centre: the shipped clamp, `pow`, the smoothstep fade, the noise-averaged density `E_n[ρ(x, n)]` from 16 empirical noise quantiles, through a 1D LUT over d (void) or s (wells) | Exact by construction, at one lookup per kernel | -| Affine transfer of the sum (`a + b Σ K_i`) | Exact | -| Any 1D function of an *affine* coordinate, `∫ f(a + bt) dt = ΔF / b` (pre-integration, Engel 2001) | Exact [derivation, not probed]: height fog `exp(−y/h)` and ramps in y | -| Polynomial or exp of a *quadric* coordinate; an indicator or clamp of a quadric (chord through roots) | Exact [derivation, not probed]: spherical shells and paraboloid bowls as envelopes | -| Product of the sum with a polynomial envelope in t | Exact, polynomial times polynomial [derivation, not probed] | -| Forbidden inside a span: `f(Σ K_i)` for nonlinear f, `max`/`min` of fields, a clamp of a signed sum, or noise displacing an envelope's argument | These are exactly what broke the first probe | - -### Composition: the mass-conserving multiplicative cascade - -- **Roots** sit on a jittered grid: spacing H0 = 30 world on the void and 40 on the - wells, one root per cell. - - Mass is `P(μ)·H0³`, so the mean density equals the shipped noise-averaged - density. - - The ellipsoid is elongated along the flow direction projected on the shell or - fog layer (aspect 1.3 to 2.4), with ±0.6 rad of jitter, and flattened along the - normal (×0.5 void, ×0.4 wells). - - There are two copies per root, at the shipped two-phase shifts with weights w0 - and 1 − w0. Time animation is therefore the shipped crossfade, exact under - summation. -- **Children.** Each node keeps 25% of its mass and gives 75% to Nc = 5 children. - - Child weights are `u²·P(child)/P(parent)`, normalised. The `u²` makes the cascade - intermittent; the P ratio sharpens it toward the envelope. - - A child is scale 0.4, with aspect up to 1.6 and ±0.6 rad of rotation. - - Children sit along the parent's major axis: offset 0.6 along it, 0.21 across. - - All of this comes from a 256-entry table indexed by hash. A descendant bound of - 1.77 times the ellipsoid holds the subtree, so the parent is a BVH node. -- **LOD.** A node is a leaf when its children would be smaller than 0.5 × the pixel - footprint at that depth. It then keeps its full mass. Because the cascade conserves - mass, truncation is a mean-preserving prefilter: the expectation step of the first - probe, exact here instead of approximate. -- **Gather.** - - Roots are binned by their subtree AABB into a hash grid of H0 cells. - - The ray walks the grid with Amanatides–Woo DDA and mailboxing, clipped to the - shipped active windows, so both fields integrate the same span. - - It exits early once Στ ≥ 7, which is valid because every term is nonnegative. - -## "Juice" under these constraints - -| Effect | Mechanism here | Measured or prior art | -|---|---|---| -| Filaments, wisps | Anisotropic children chained along the parent's major axis, which follows the flow | Visible in `void-T-IN-L6.png` as streaks along the flow. Gabor Fields uses anisotropic Gabor kernels for orientation-selective detail [fetched] | -| Sharp edges | Low-order kernels: k = 1 is the default, k = 0 gives hard ellipsoids | k = 0 (`L6-hard`) changes msf by −9% on the void. Edges come from kernel boundaries, not clamps | -| Voids | Regions with no kernel mass are exactly zero and are skipped by the gather at no cost | Structural | -| Turbulent intermittency | Random multiplicative cascade, the p-model of turbulent dissipation (Meneveau & Sreenivasan 1987 [memory]); clustered kernels, as in a Neyman–Scott process [memory] | Image std 0.29 against 0.05 at near-equal mean OD | -| Flow and animation | Per-kernel warp at the shipped flow and phases. Alternatives are Lagrangian advection of kernel centres with lifetimes (advected textures, Neyret 2003 [memory]) and Gabor phase for oscillatory detail (flow noise, Perlin & Neyret 2001 [memory]) | Only the two-phase crossfade was measured | -| Fine detail riding on structure | Children exist only inside parents, so detail appears only where matter is. This is Schneider's erosion idea (2015 [fetched]) without the per-sample clamp | Structural | - -Wavelet turbulence (Kim et al. 2008 [memory]) and curl noise (Bridson 2007 [memory]) -were not used. A per-point warp is ruled out above. Curl noise could orient kernels, -evaluated per kernel, at no cost to exactness. - -## Measurements - -**Setup.** -- Probe source: scratch clone `probe-clone@5ec9f529`, - `packages/cultmath/probe/DomainProbe/Program.cs`, never merged. -- Run on Yggdrasil through the verify stopgap: dotnet 10 container, 4 CPUs, tiered - JIT off. -- Full log: Self's scratchpad, `dom-full1.log`. -- The scenes are those of the first probe, with fixed cameras: - - Void: the shipped orbiting camera at time 20, at the 1920-wide f = 935 field of - view, rendered at 512 x 256. - - Wells: warp D = 60, camera at xz (1200, 0) looking at the central well, slopes - x ±1 and y from −0.85 to 0.15. -- The window is the shipped field's active intervals. Every method integrates the - same window. - -**Cost.** -- Single-threaded C#, best of three passes over the same 2048 random pixels. -- The host is shared, and absolute timings moved by up to 2x between the smoke run - and the full run; Flow went from 125 to 660 ns. Ratios within one run are the - reliable numbers. -- Flow is 47% of a shipped sample in this run, so a flow-cached march would cost - about 15 µs on the void and 31 µs on the wells. - -| Config (void) | Cost vs march | Roots visited / nodes tested / kernels integrated per pixel | Kernels per level | -|---|---|---|---| -| L1 | 0.12x | 43 / 8 / 8 | 8 | -| L2 | 0.48x | 59 / 25 / 20 | 8, 12 | -| L3 | 1.24x | 74 / 42 / 28 | 8, 12, 8 | -| L4 | 1.81x | 82 / 60 / 35 | 8, 12, 8, 7 | -| L6 (default) | 2.57x | 93 / 86 / 36 | 8, 12, 8, 7, 1, 0 | -| L6, no child placement | 1.79x | 93 / 91 / 39 | same metrics as L6 | -| L6, no LOD | 2.95x | 93 / 103 / 49 | 8, 12, 8, 7, 7, 7 | - -| Config (wells) | Cost vs march | Kernels integrated per pixel | -|---|---|---| -| L1 | 0.04x | 5 | -| L2 | 0.23x | 11 | -| L3 | 0.49x | 16 | -| L4 | 0.77x | 20 | -| L6 | 1.20x | 25 | -| L6, no child placement | 0.62x | 27 | - -**Where the time goes.** -- The integrals are about 36 kernels × 10 ns, or 0.4 µs of a 74 µs pixel. -- The rest is traversal: - - roots visited but missed: 93 visited for 8 hits, because AABBs of elongated - rotated ellipsoids are loose; - - child generation; - - placement lookups. The wells' placement costs a 5-bowl `Sdf`, and dropping - child placement halves the wells cost with identical metrics. - -**Aliasing.** One sample per pixel against four on the default void field: |ΔT| has -an RMS of 0.015 (p90 0.022). At 4 spp the msf is 0.146 against 0.159. So about 92% -of the measured detail is resolved structure, not sparkle. Exact along the ray is -not the same thing as antialiased across the pixel; the LOD rule is the prefilter. - -**Variants, void L6 (msf / power above 1/8).** -- k = 1 default: 0.159 / 12.5%. -- Hard k = 0: 0.145 / 11.0%. -- Gaussian (erf): 0.174 / 14.2%, at 0.89x the polynomial cost here. The erf kernel is - 3x the polynomial kernel in isolation, but the kernel is not where the time goes. - -## Images - -All images are in Self's session scratchpad, -`C:\Users\Meta\AppData\Local\Temp\claude\F--Projects-CultLib\b7e842a1-2045-474e-a51b-240d832b770b\scratchpad\integration-domain-images\`: - -- **Transmittance, 512 x 256.** Shown as `sqrt(1 − T)`, white for opaque. - - `void-T-shipped-ref.png`, `void-T-shipped-march.png`. - - `void-T-IN-L1.png`, `void-T-IN-L3.png`, `void-T-IN-L6.png`, - `void-T-IN-L6-hard.png`, `void-T-IN-L6-gauss.png`. - - The wells equivalents, which are silhouettes and uninformative. -- **Single scattering, 256 x 128.** - - Method: HG g = 0.6 and albedo 1. The point light is at the void's sun with 1/r² - falloff; the wells use a directional sun with a sky background. - - Each view sample takes a shadow ray: a 2-world march for the shipped field, an - exact traversal for the integration-native field. - - Tonemap: `1 − exp(−1.5 L / p99(shipped))`, then gamma 2.2, the same exposure for - both fields. - - `void-SS-shipped.png`, `void-SS-IN-L6.png`, `wells-SS-shipped.png`, - `wells-SS-IN-L6.png`. - -What they show: -- The shipped void is a soft, low-contrast haze. -- The integration-native void is dense flow-aligned streaks with deep gaps, like - hair or brush strokes. -- The shipped wells are smooth rolling dunes. The integration-native wells are - layered pancakes with streaked detail. - -## The catches - -1. **The character is a design parameter, and this probe picked one.** - - High anisotropy, axis-chained children and an intermittent `u²` split give - fibres. - - A cloudier look would need rounder children, wider offsets and less - intermittency. That trades away some measured detail and was not swept. - - The detail metrics measure spatial frequency, not taste. The operator has to - look at the images. -2. **The cost is a BVH, not arithmetic.** - - Integration is nearly free. Traversal, child generation and placement dominate. - - Tighter root bounds (OBB tests before AABB bins), cheaper placement and fewer - children are obvious levers, but none was measured. - - On a GPU, variable-length kernel lists per ray diverge. 3DGRT (Moënne-Loccoz et - al. 2024 [memory]) puts the same problem on hardware ray tracing. - - CPU C# ratios do not transfer to the GPU, where snoise is relatively cheaper. -3. **It is all or nothing.** - - This field cannot be marched. At the shipped step, |ΔT| is a median 0.14. - - Shadow rays, light probes and any sampler consumer need the exact traversal too. - The single-scattering pass here cost an exact shadow traversal per view sample: - 257 s for both void SS images together, against 54 s for the whole 512 x 256 - shipped transmittance set. - - Lighting has no closed form. The in-scatter integral is still quadrature. What - the domain makes exact is every optical depth inside it. A per-kernel lighting - cache would amortise shadows, but that is a different shading model (splat-like), - and so a product fork. -4. **Exact along the ray, not across the pixel.** The LOD truncation is the - prefilter. 8% of the measured detail at 1 spp is aliasing. -5. **The wells gain little** because the shipped wells fog is near-opaque. Its look - is the surface silhouette, and that is set at root scale. The domain pays most - where the medium is semi-transparent, as in the void. -6. **Timing noise.** Absolute costs vary up to 2x between runs on the shared host. - The cost ratios above are within one run. - -## What would change the verdict - -- A sweep toward a cloud-like character: round children, Nc = 8, wider offsets, - Gaussian kernels. It should be judged on the single-scattering images against the - same cost. -- Tight root culling: an exact ellipsoid-versus-bin test, or roots stored by - oriented bound. If roots visited fall from 93 to near the 8 hits, the void L3 cost - would fall well under the march. -- A GPU port of one level-limited configuration, to replace the C# ratios with - shader timings. diff --git a/docs/research/inverse-procedural-modelling-prior-art.md b/docs/research/inverse-procedural-modelling-prior-art.md deleted file mode 100644 index 15a26567..00000000 --- a/docs/research/inverse-procedural-modelling-prior-art.md +++ /dev/null @@ -1,151 +0,0 @@ -# Inverse procedural modelling: describing messy meshes as programs - -Eyes pass, 2026-10-10. Operator: "What if the model had some trash geo and its goal is to describe it parametrically?" Context: Tripo hard-surface hulls; CultMath intervals and affine forms on main, tape/brush grammar parked (docs/cultmath-tape-target.md); the earlier GameCult/VibeGeometry attempt (2026-05). Facts only; tags mark FETCHED, SEARCH (search summary only) and KNOWLEDGE (unverified). - -# Eyes facts: inverse procedural modelling (mesh -> parametric program) -Date 2026-10-10. Tags: FETCHED (page/file read this session), SEARCH (search-result digest only), KNOWLEDGE (unverified recall). -Search digests come from a small model; SEARCH numbers are not paper-verified. - -## 0. What exists in GameCult -- FETCHED F:\Projects\CultLib\docs\cultmath-tape-target.md: steps 2-5 (tape, pruning, HLSL interpreter, meshing) PARKED (2026-10-02, - ruling tape-target-unparks-when-asura-stable). Step 1 intervals + affine forms are on main (docs/cultmath-interval-ground-cut.md). - The "grammar of nested brushes" is operator intent only (quote 2026-10-02: space station from "a grammar of nested brushes"); - doc says the station project is "a separate project with its own target". Chosen shape (c): port Fidget ideas into CultLib (Fidget = - MPL-2.0 Rust, v0.5.1). Meshing plan: surface nets + Asura tile pass (Newton refinement onto f=0, crease snapping from field gradients); - "Thin authored bevels can be shaded by their analytic normals". Tape gradients "reuse CultMath's analytic-gradient primitives". -- FETCHED grep CultLib\docs for brush/tape: "brush" hits in cultmath-interval-ground-cut.md are Aetheria noise/gravity-well field brushes - (PowerBrush (1-x^2)^16 etc.), not CSG brushes. No CSG brush grammar or tape code exists in CultLib; only the parked doc. -- FETCHED (voidbot) separate repo GameCult/GameCult.Geometry.Csg ("CultGeometry CSG", Rust; local F:\Projects\GameCult.Geometry.Csg). - Mesh-based convex plane-splitting CSG (not SDF), RealtimeCSG-shaped API: ordered Additive/Subtractive/Intersecting brush streams, boxes, - oriented boxes, CylinderZ/DomeCapZ/FloretArm, dirty-frontier, OBJ output, plus domain-tree/selected-cut LOD schemas (src/cult_geometry). - Doc text: "agents should revise intent by moving, adding, or renaming brushes, not by poking triangles"; "brush list is the durable - design surface. The mesh is a cache." - -## 0b. The earlier "vibe geometry" attempt -- FETCHED voidbot gamecult-site GameCult/Projects/VibeGeometry.md: repo GameCult/VibeGeometry, started 2026-05-04, last public push - 2026-05-07; "agent-authored Blender scene generation: geometry nodes, Python builders, semantic graph contracts, render evidence, and - the ongoing war against decorative node spaghetti". Org ledger: "Started as architecture and persistence scaffolding, then dived almost - immediately into CSG grammar, parity fixtures, native bridge probing, mesh generation, and performance work." -- FETCHED local git F:\Projects\VibeGeometry-cultgeometry-rename (93 commits). Commit 09bff8c (2026-05-29, "Focus VibeGeometry on vg-csg") - deleted the scene-generation tree; recoverable at 09bff8c^: docs/research/procedural-doctrine.md (~1000-line "spatial reasoning - playbook"), dream-machine-grammar.md, geonodes-translation-corpus.md, ircss-french-houses-* (translations of Blender node graphs into - Geometry Script Python), builds/{aetheria-bloom-habitat, lucent-tether-habitat, dream-machine-level, industrial-maintenance-loop}.md, - notes/architecture-rationale.md, a "reusable procedural helper library" (aa4d49d). The DSL was Blender Python via Geometry Script - (fork F:\Projects\geometry-script; upstream PR carson-katri/geometry-script#69 linked by Metacrat 2026-05-04) emitting geometry-node - graphs, plus the Rust brush DSL (LevelDsl: solid_box, cut_box, solid_oriented_box, dome_cap_z, floret_arm). -- FETCHED notes/architecture-rationale.md @09bff8c^, section "Core Failure": "The central failure mode is local plausibility without global - coherence. An agent can write plausible Blender Python, create a large node graph, and still lose the visual machine ... the script - runs, the graph exists, the render has objects in it, and somehow the target has been replaced by decorative procedural fog". - "Seductive proxies": valid Python, non-empty renders, high node counts, pretty materials, parameter sliders. - procedural-doctrine.md: "Ornament in the wrong frame is not detail. It is a confident lie". Commit titles record frame errors: - "Correct Bloom terrace slum orientation", "Correct Lucent dome spin-gravity frame", "Move Lucent ray florets outside dome". -- FETCHED VibeGeometry README: "failed experiments are useful without being allowed to hold a steering wheel"; old mission "deleted - from the live tree"; live mission narrowed to runtime CSG (domain tree -> LOD CSG -> selected cut -> triangles). -- NOT FOUND: no indexed operator or agent statement that models "weren't good enough at spatial reasoning to use the DSL". voidbot - search_history (Discord) returned only unrelated hits. The repo docs above are the only failure statements in project words - (coherence and frame errors; the phrase "spatial reasoning" appears only in the playbook title and its body). - -## 1. Inverse CSG / shape-program synthesis -Most train or test on DeepCAD / ShapeNet / ABC / Infinigen; none retrieved was evaluated on noisy AI-generated hard-surface meshes. -- InverseCSG (Du et al., SIGGRAPH Asia 2018, MIT). SEARCH: mesh/point samples -> CSG program; geometric processing (RANSAC-style primitive - detection) turns the mixed discrete/continuous problem into a purely discrete one; careful point samples guide a discrete search; - divide-and-conquer segmentation; program synthesis (solver) per segment. Claims >100 primitive parts, compact programs, beats prior - methods on compactness/runtime. D2CSG authors (SEARCH) criticise it: RANSAC needs tuning, noisy initial primitives, long search. - Project page inversecsg.csail.mit.edu lists code; licence not checked. -- CSGNet (Sharma 2018): KNOWLEDGE only; supervised, voxel/2D -> CSG sequence. -- UCSG-Net (Kania, NeurIPS 2020). SEARCH: unsupervised; predicts box/sphere params; differentiable indicator on SDF; several CSG layers with - soft operator choice; structure and params learned jointly by gradient descent; autoencoding scope (2D/3D), no mesh-to-program at test - for unseen exotic shapes beyond the trained net. -- CAPRI-Net (CVPR 2022). SEARCH: axis-aligned quadric primitives, fixed 3-layer assembly; ABC point-cloud Chamfer 0.09 vs UCSG 1.43; ~5.3 vs - 12.92 convex shapes. D2CSG (2023), CSG-Stump (2021): SEARCH, unsupervised compact trees. SECAD-Net (CVPR 2023): SEARCH, sketch-extrude, - editable; CD 2.94/4.20 (ABC/Fusion) vs UCSG 3.14/4.45. -- Point2CAD (Liu et al.): SEARCH only that a repo exists (jofcodeusal/point2cad mirror, Docker toshas/point2cad); method not retrieved. - Point2Cyl (CVPR 2022): SEARCH, supervised net to extrusion cylinders. DeepCAD (Wu 2021): KNOWLEDGE, ~178k sketch-extrude sequences. -- ShapeAssembly (Jones 2020, TOG): SEARCH; programs of cuboid proxies attached to each other with free parameters; extraction from PartNet. - ShapeMOD (2021): SEARCH; discovers macros across a corpus minimising calls and free parameters. Repos/licences not found by search - (KNOWLEDGE: github rkjones4/ShapeAssembly exists; unverified). -- CAD-Recode (Rukhovich et al., ICCV 2025, arXiv 2412.14042). FETCHED abstract: point cloud -> CadQuery Python (sketch-extrude); point-cloud - projector + small pretrained LLM decoder; trained on 1M procedurally generated CAD sequences; eval DeepCAD, Fusion360, CC3D (real scans); - output usable by off-the-shelf LLMs for editing and QA. SEARCH (unverified): Qwen 0.5B/1.5B decoders; DeepCAD mean CD 3.43 -> 0.30, IoU - 77.6 -> 92.0 vs CAD-SIGNet; test time: 10 sampled candidates executed, min-Chamfer kept. Code github.com/filaPro/cad-recode (SEARCH); - HF dataset filapro/cad-recode is CC-BY-NC-4.0 (SEARCH); repo licence unchecked. Structure by autoregressive decoding, params as literal - tokens, re-ranking by Chamfer. Abstract says nothing on fillets/chamfers. -- MeshCoder (Dai et al., NeurIPS 2025, arXiv 2508.14879). FETCHED: 16,384-point cloud -> triplane tokenizer -> Llama-3.2-1B (LoRA) -> - Blender Python. API: cube/cylinder/UV-sphere/cone/torus, Translation (sweep 2D section along 3D trajectory), Bridge Loop, Boolean - (union/intersect/diff), Array, Fill Grid, Spoon, Fork. Data: ~10M part-code pairs, ~1M object-code pairs, 41 categories (Infinigen - Indoor). Table 2 averages CD x1e-2 / IoU%: Shape2Prog 6.00/45.0, PLAD 1.87/67.6, MeshCoder 0.06/86.75. Worst: Fork 58.9 IoU, CeilingLight - 65.8, Array parts 78.9. Limits: human-made objects only; geometry only; training objects kept only if every part CD < 5e-3. LLM does not - edit; edits are manual param changes; GPT-4o used only for QA on the code. Output is part-segmented. Licence not stated in paper. -- CADCodeVerify (Alrashedy, ICLR 2025, arXiv 2410.05340). SEARCH: text prompt -> CadQuery (GPT-4); VLM writes/answers validation questions - about renders and refines; CADPrompt benchmark (200 objects); GPT-4 point-cloud distance -7.30%, compile rate +5.5% (v2; v1 said 5.0% - success). Target is a prompt, not a mesh. -- Newer render-loop agents (SEARCH): SEIG "Thinking in Blender" (arXiv 2606.02580): single reference image -> staged Blender code (geometry, - materials, composition, lighting), VLM generator + verifier per stage; FETCHED abstract gives no numbers, no code link. LL3M (2508.08228): - text -> Blender with critic reading renders. ShapeCraft (2510.17603): renders bbox/part/global views as feedback. SceneCraft (2403.01248): - render-critique-revise. Not found by search: "3D-Premise", "LLMto3D", Img2CAD/Text2CAD specifics. - -## 2. Classical primitive fitting as a front end -- Efficient RANSAC (Schnabel/Wahl/Klein, CGF 2007): SEARCH/FETCHED page text: planes, spheres, cylinders, cones, tori in unorganised clouds; - multi-million-point sets "within less than a minute". CGAL Shape Detection implements it plus Region Growing (Lafarge&Mallet). CGAL is - dual GPL/LGPL + commercial; the Shape Detection package's own licence NOT confirmed (digest guessed GPL). -- GlobFit (Li/Wu/Chrysanthou/Sharf/Cohen-Or/Mitra, SIGGRAPH 2011): SEARCH; starts from RANSAC primitives, discovers global relations - (orientation, placement, equality; symmetry) and enforces them by constrained optimisation; assumes man-made, repeated, globally aligned - parts. Code: archived code.google.com/archive/p/globfit, "research use only" wording. -- Mitra 2006 symmetry detection, SPFN (2019): KNOWLEDGE/SEARCH only. ParSeNet (2020): SEARCH; B-spline patch decomposition, beats RANSAC - and SPFN baselines. No repos/licences retrieved. -- What fits supply as data: exact primitive parameters with inlier sets and residuals, segment labels, relation graph (GlobFit). - InverseCSG uses the primitives to make the problem discrete. Recorded weakness: noisy primitives, parameter tuning (SEARCH). - -## 3. Differentiable fitting of SDF/CSG programs -- UCSG-Net (above): soft operator selection; structure learned jointly. -- Fuzzy Boolean differentiable CSG (dgp.toronto.edu/~hsuehtil/pdf/fuzzyBoolean.pdf): SEARCH; gradient descent over boolean and primitive - parameters; notes prior work pre-fixes tree structure and operators and optimises only primitive params; replaces min/max with a unified - fuzzy operator so the operation type is optimised. Costs listed: analytic SDF per primitive type, per-iteration SDF evaluation, image - losses need differentiable sphere tracing. -- DiffCSG (arXiv 2409.01421): SEARCH; differentiable rasterisation of mesh CSG, image-space gradients to primitive params; image-guided - editing, not mesh fitting. -- ResFit, Residual Primitive Fitting with SuperFrusta (arXiv 2512.09201): SEARCH; one analytic SDF primitive with 8 params (dilation, taper, - bulge, onion hollowing, profile roundness, axial scaling); alternates global shape analysis and local primitive optimisation; code "to be - open-sourced upon acceptance". -- Evolutionary mesh -> CSG abstraction (SEARCH; authors not retrieved): fast, coarse. Sigmoid-over-SDF soft occupancy with alternating - add-primitive / joint-refine loop (SEARCH, primitive-scene paper). -- Not found: a published gradient fit of an SDF program with bevel/round parameters to a messy hard-surface mesh. -- Handling of discrete structure across sources: soft selection (UCSG, CSG-Stump, fuzzy Boolean); pre-fixed structure (InverseCSG after - RANSAC; CAPRI-Net fixed layers); greedy add/prune (ResFit); neural token decoding (CAD-Recode, MeshCoder). - -## 4. LLM spatial reasoning in 3D code generation -- BlenderGym (Gu et al., CVPR 2025, arXiv 2504.01786). FETCHED: 245 start-goal Blender scene pairs, five tasks (placement, lighting, - procedural material, blend shape, procedural geometry); the VLM sees start and goal and edits Blender code (target-matching setting). - Table 1 best-VLM vs human: geometry Chamfer 1.120 (GPT-4-Turbo) vs 0.334; geometry photometric loss 6.747 vs 1.269; placement CD 8.324 vs - 1.532; blend shape CD 0.904 vs 0.399. Paper: VLMs "particularly poorly in procedural material and geometry editing"; all open-source - models except MiniCPM failed to produce executable code on >75% of geometry instances. Verifier agreement with humans: human 0.79, - Claude 3.5 Sonnet 0.66, random 0.5. Scaling a small verifier (InternVL2-8B, k 1 -> 64 over 32 candidates) beat unscaled GPT-4o and - Claude 3.5 on blend shape. Low compute: less verification share (0.33); high compute: more (0.62-0.73). Models are 2024-25 era. Code - licence not in retrieved text. -- BenchCAD (arXiv 2605.10865): SEARCH; 17,900 CadQuery programs, 106 part families; frontier models recover coarse outer geometry but fail - faithful parametric programs; sweeps/lofts/twist-extrudes replaced by sketch-extrude; single-literal errors (5.6 vs 5.85) at IoU >= 0.9. - BenchCAD-Edit: text instruction sets the upper bound; the image is "at best a clarifier and at worst a distractor" for thinking models. -- Text2CAD-Bench (2605.18430): SEARCH; execution failures even at easy level; sweep/loft/shell widely fail; executing != correct. -- Text-to-B-Rep paper (2603.11831): SEARCH; spatial misalignment of primitives, omitted fillets, geometry contradicting described layout; - authors blame weak precise 3D spatial reasoning. -- "Foundation Models for Automatic CAD Generation" (2607.05573): SEARCH, single source; numeric analytic feedback peaked at round 1; VLM - critique of renders kept improving in rounds 2-3 for DeepSeek/Qwen; VLM critics struggle on rotationally symmetric geometry. -- Multi-view conditioning beat single-view and sketch on Chamfer/F-score in a B-Rep paper (SEARCH, not CadQuery). -- Target vs description: BlenderGym gives a target and still shows a large human gap; CAD-Recode and MeshCoder avoid prompting by training - point-cloud encoders; no controlled prompted-LLM study of target-vs-description was found. -- MindCube spatial study (SEARCH): errors 20% final reasoning step, 13% 3D reconstruction, 6% generated programs. - -## 5. Hard-surface specifics -- SDF rounding (Quilez distfunctions, SEARCH): sdRoundBox = box SDF minus r, an iso-offset so the shape grows by r. Polynomial smin with k - as blend band; Quilez marks smin as "bound" not exact. Chamfer/fillet operators not retrieved; KNOWLEDGE: hg_sdf (Mercury) has - fOpUnionChamfer / fOpUnionRound / fOpUnionStairs (unverified here). -- MeshCoder (FETCHED): no fillet/chamfer primitive; booleans, sweeps, bridge-loop, arrays only. -- BenchCAD / text-to-B-Rep (SEARCH): omitted fillets/refinement features named as failure; sweeps/lofts degrade to extrudes. -- CAD-Recode/DeepCAD data are sketch-extrude (SEARCH/KNOWLEDGE); fillet/chamfer not covered in what was retrieved. -- InverseCSG output: boolean of primitives, no blends (KNOWLEDGE). CAPRI-Net quadrics: smooth surface in one primitive (SEARCH). ResFit - primitive has a profile-roundness parameter (SEARCH). - -## Gaps -- Operator/agent words on why VibeGeometry failed: not indexed (see 0b). -- Not read at body level: CAD-Recode fillet handling, InverseCSG experiments, GlobFit relation list, SEIG numbers, ResFit results. -- Licences unverified: InverseCSG, ShapeAssembly, CAD-Recode repo, MeshCoder, GlobFit, CGAL Shape Detection, Point2CAD. diff --git a/docs/research/read-only-record-signal-prior-art.md b/docs/research/read-only-record-signal-prior-art.md deleted file mode 100644 index 5a2dc3c3..00000000 --- a/docs/research/read-only-record-signal-prior-art.md +++ /dev/null @@ -1,310 +0,0 @@ -# Read-Only Record Signal: Prior Art Survey - -Facts file for Eureka question `variants:question:read-only-record-signal`: how a -developer learns that a held record is read-only before a write is refused. Its -options are (a) no new API, (b) a live query such as -`CultCache.IsWritable(key)`, and (c) a list beside `ForeignRecords`. Eyes pass, -2026-10-03. Facts and evidence pointers only; no recommendation. - -Verification marks: - -- **[fetched]** the claim was read on the cited page or source during this pass. -- **[search]** the claim came from a search-result summary of the cited page, - not a full read. -- **[memory]** recalled from the cited source, not re-read in this pass. - Treat it as unverified. - -Signal shapes used below: - -- **property**: a flag or state on the loaded object itself. -- **query**: a call on the store, session or registry that answers at call time. -- **list**: an enumeration of affected items, captured or computed. -- **type**: the read-only status is a distinct static type. -- **exception only**: nothing to ask; the write is the first signal. - -## 0. Our design, for comparison - -Source: branch `hands/variants-c2a` (head e9a66876), `src/GameCult.Caching/CultCache.cs`. - -- `CultDocumentRegistry.Declares(string schemaId)` (line 738) is `internal`. Its - comment: "The one answer to whether a cache may write, relabel or remove a - record stored under this id ... Read live, so a type registered later that - declares the id claims its records at their next write." [fetched] -- `GetRequired()` (line 631) registers lazily, so the set of declared ids can - grow after load. [fetched] -- The backing store already exposes `ForeignRecords` (line 3421), an - `IReadOnlyList` "the last load found and carries untouched", - set at load (`SetForeignRecords`, line 3599). `CultForeignRecord` (line 162) - carries `Key`, `SchemaId`, `SchemaName`, `StoredAt`. [fetched] -- The store also has a store-level `public bool IsReadOnly { get; }` (line 3419), - fixed at construction. [fetched] -- Main (162bd1fc) exposes `LastSchemaMigrationReports` (CultCache.cs:3136), whose - entries carry no record key (per the question text). [fetched for the - property; the no-key claim is the question's] - -## 1. ORMs - -### EF Core: no-tracking queries and keyless entity types - -- Signal shape: **query** on the context, plus a **model** query. - `context.Entry(e).State` returns an `EntityState`; `Detached` means "not being - tracked by the DbContext", and its "Action on SaveChanges" is none. - ([Change Tracking](https://learn.microsoft.com/en-us/ef/core/change-tracking/), "Entity states" table) [fetched] -- No-tracking results (`AsNoTracking`, or `QueryTrackingBehavior.NoTracking` on - the context) are plain instances; changes to them are not persisted by - `SaveChanges`. ([Tracking vs. No-Tracking](https://learn.microsoft.com/en-us/ef/core/querying/tracking), "No-tracking queries") [fetched] -- Keyless entity types "are never tracked for changes in the DbContext and - therefore are never inserted, updated or deleted"; their mapped object is - "treated as a read-only query source". - ([Keyless Entity Types](https://learn.microsoft.com/en-us/ef/core/modeling/keyless-entity-types), "characteristics", "Mapping to database objects") [fetched] -- Attempting to `Attach`/`Update` a keyless instance throws - `InvalidOperationException` with `CoreStrings.KeylessTypeTracked`: "Unable to - track an instance of type '{type}' because it does not have a primary key." - ([CoreStrings.KeylessTypeTracked](https://learn.microsoft.com/en-gb/dotnet/api/microsoft.entityframeworkcore.diagnostics.corestrings.keylesstypetracked?view=efcore-8.0)) [search] -- The model answers keylessness: `IReadOnlyEntityType.IsKeyless` / - `FindPrimaryKey() == null`. [memory] -- Pitfall: modifying a no-tracking instance and calling `SaveChanges` is silent; - nothing is written and nothing is thrown. `ChangeTracker.HasChanges()` returns - false (Change Tracking page, closing tip). [fetched] - -### Hibernate: @Immutable and read-only entities - -- Signal shape: **query** on the session. `Session.isReadOnly(Object - entityOrProxy)`: "Is the specified entity or proxy read-only?"; - `isDefaultReadOnly()` for the session default; `setReadOnly(Object, boolean)` - flips one entity. ([Session javadoc 6.4](https://docs.hibernate.org/orm/6.4/javadocs/org/hibernate/Session.html)) [fetched] -- Read-only can be set per session (`setDefaultReadOnly`), per query - (`Query.setReadOnly(true)`, before execution) or per entity. - ([Hibernate 4.3 manual ch. 12, 12.1.2-12.1.3](https://docs.hibernate.org/orm/4.3/manual/en-US/html/ch12.html)) [fetched] -- Write behaviour: changes to read-only entities are ignored at flush, no - exception ("Hibernate will not update simple properties or updatable - single-ended associations"); "A read-only entity can be deleted." (ch. 12.1) [fetched] -- `@Immutable`: "Changes made in memory to the state of an immutable entity are - never synchronized to the database. The changes are ignored, with no exception - thrown." Immutable collections, by contrast, throw `HibernateException` on add - or remove. ([@Immutable javadoc 6.2](https://docs.hibernate.org/orm/6.2/javadocs/org/hibernate/annotations/Immutable.html)) [fetched] -- Bulk HQL updates of immutable entities: setting - `hibernate.query.immutable_entity_update_query_handling_mode` chooses `warning` - (default) or `exception`. ([QuerySettings 6.6](https://docs.hibernate.org/orm/6.6/javadocs/org/hibernate/cfg/QuerySettings.html)) [search] -- Pitfall: the default for entity changes is silent loss; the read-only state is - per session, so the same row is writable in another session. - -### ActiveRecord: readonly? - -- Signal shape: **property** on the record. `readonly?` "returns true if the - record is marked as read-only"; `readonly!` marks it. - ([ActiveRecord::Core](https://api.rubyonrails.org/classes/ActiveRecord/Core.html)) [fetched] -- Relation-level: `User.readonly` marks every loaded record; - `users.first.save # => ActiveRecord::ReadOnlyRecord: User is marked as readonly`. - ([QueryMethods#readonly](https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html)) [fetched] -- Write behaviour: save, update or destroy raise `ActiveRecord::ReadOnlyRecord`. [fetched] -- The flag is set when the record is loaded and lives on the in-memory object; it - is not re-derived from the database or the model at write time. [memory] - -## 2. Document stores and embedded databases - -### Realm (Kotlin SDK): frozen objects - -- Signal shape: **property** functions on the object. - `BaseRealmObject.isFrozen()`: "A frozen object is tied to a specific version of - the data in the realm and fields retrieved from this object instance will not - update"; also `isManaged()` and `isValid()` ("the Realm is open and the - underlying object has not been deleted"). - ([BaseRealmObjectExt.kt L41-71](https://github.com/realm/realm-kotlin/blob/main/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/ext/BaseRealmObjectExt.kt)) [fetched] -- Recovery path: `MutableRealm.findLatest(obj)` returns a live, writable copy - inside a write block, or `null` "if the object has been deleted". - ([MutableRealm.kt L50-56](https://github.com/realm/realm-kotlin/blob/main/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/MutableRealm.kt)) [fetched] -- Write behaviour: writing to a frozen object throws. Early SDKs threw a generic - "Wrong transactional state ..." message; issue #297 asked for "Frozen objects - cannot be modified" plus a pointer to `findLatest`. - ([realm-kotlin#297](https://github.com/realm/realm-kotlin/issues/297)) [fetched] -- Pitfall: `isFrozen()` is stable for a given instance, but `isValid()` is live - and can flip when another writer deletes the object. - -### Couchbase Lite - -- Signal shape: **type**. "By default, a document is immutable when it is read - from the database. Use the Document.ToMutable() to create an updatable - instance." `Document` versus `MutableDocument` makes the distinction static. - ([Couchbase Lite C# Documents](https://docs.couchbase.com/couchbase-lite/current/csharp/document.html), "Mutability") [fetched] -- Write conflicts with other writers are handled at save by concurrency control - (last-write-wins or fail-on-conflict) or a conflict handler. [memory] - -### LiteDB - -- Signal shape: **store-level option** only. Connection string `ReadOnly` - ("Open datafile in read-only mode"). No per-document read-only state found. - ([LiteDB connection string](https://www.litedb.org/docs/connection-string/)) [fetched] - -### SQLite - -- Signal shape: **store query**. `sqlite3_db_readonly(D,N)` "returns 1 if the - database N of connection D is read-only, 0 if it is read/write, or -1 if N is - not the name of a database". ([sqlite3_db_readonly](https://www.sqlite.org/c3ref/db_readonly.html)) [fetched] -- `sqlite3_stmt_readonly()` answers whether a prepared statement writes. [memory] - -### Core Data - -- Signal shape: **store property** plus an open option. - `NSPersistentStore.isReadOnly`: "A Boolean value that indicates whether the - persistent store is read-only" (get/set); - `NSReadOnlyPersistentStoreOption`: "A flag that indicates whether a store is - treated as read-only", default false. - ([isReadOnly](https://developer.apple.com/documentation/coredata/nspersistentstore/isreadonly), - [NSReadOnlyPersistentStoreOption](https://developer.apple.com/documentation/coredata/nsreadonlypersistentstoreoption)) [fetched] -- Granularity: store, not object. An object's store is reachable through its - `objectID.persistentStore`. [memory] - -## 3. Serializers and schema evolution: unknown or foreign data - -### Protocol Buffers - -- Unknown fields: "Proto3 messages preserve unknown fields and include them - during parsing and in the serialized output." They are lost on JSON - serialization or when copying field by field into a new message. - ([proto3 guide, Unknown Fields](https://protobuf.dev/programming-guides/proto3/)) [fetched] -- Signal shape for unknown fields: **property/list** on the message, - `getUnknownFields()` returning an `UnknownFieldSet` (Java). [memory] -- `Any` with a foreign type: **query** `any.is(Foo.class)` returns a boolean; - `unpack(Class)` throws `InvalidProtocolBufferException`. - ([Any javadoc](https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html)) [fetched] -- Granularity: fields inside a known message, or one embedded payload; no - ownership or write-permission concept. - -### Apache Avro - -- Writer fields absent from the reader schema are dropped: "the writer's value - for that field is ignored". A union branch the reader lacks: "if none match, an - error is signalled". ([Avro 1.11.1 spec, Schema Resolution](https://avro.apache.org/docs/1.11.1/specification/)) [fetched] -- Signal shape: **exception only** for unresolvable data; nothing marks a record - as carrying dropped fields. - -### Unity SerializeReference: missing types (closest found to CultCache) - -- A host asset holds managed references whose recorded type (assembly, - namespace, class) is not in the current project. -- Signal shape: **query** returning a bool and a **list**. - `SerializationUtility.HasManagedReferencesWithMissingTypes(Object obj)`: "returns - true if one or more managed references is missing its type." - `GetManagedReferencesWithMissingTypes` returns the - `ManagedReferenceMissingType` entries: `assemblyName`, `className`, - `namespaceName`, `referenceId`, `serializedData`. - ([HasManagedReferencesWithMissingTypes](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/SerializationUtility.HasManagedReferencesWithMissingTypes.html), - [ManagedReferenceMissingType](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/ManagedReferenceMissingType.html)) [fetched] -- Behaviour: the field stays null, the persisted state is retained on resave, and - if the type returns later, "the state of the Managed Reference object can be - recovered". `ClearManagedReferenceWithMissingType` removes one deliberately. - ([GetManagedReferencesWithMissingTypes](https://docs.unity3d.com/ScriptReference/SerializationUtility.GetManagedReferencesWithMissingTypes.html)) [search] -- Both calls are made on demand against a host object; the docs do not say the - list is cached at load. A sibling `PrefabUtility.HasManagedReferencesWithMissingTypes` - exists for prefab instances. [search] - -### .NET DataContractSerializer: IExtensibleDataObject - -- Unknown members round-trip through an opaque `ExtensionDataObject` property on - the object. It cannot be inspected, so it is a carrier, not a signal. [memory] - -## 4. File systems and object stores - -### POSIX access(2) and TOCTOU - -- Signal shape: **query** on the path. `access(path, W_OK)` fails with `EROFS` on - a read-only file system. The check uses the real UID/GID, "rather than the - effective IDs as is done when actually attempting an operation". - ([access(2)](https://man7.org/linux/man-pages/man2/access.2.html)) [fetched] -- Pitfall: checking before `open(2)` "creates a security hole" because the state - can change between check and use (access(2) NOTES). [fetched] -- Python's `os.access` docs repeat the warning and show the EAFP alternative: try - the `open` and catch `PermissionError`. - ([os.access](https://docs.python.org/3/library/os.html#os.access)) [fetched] -- CWE-367 defines TOCTOU as checking "the state of a resource before using that - resource, but the resource's state can change between the check and the use". - Mitigations listed: drop the check, make check and use atomic, lock before the - check, recheck after use, shrink the window. - ([CWE-367](https://cwe.mitre.org/data/definitions/367.html)) [fetched] - -### Amazon S3 Object Lock - -- Signal shape: **metadata on the object version**, read with HEAD/GET. - `HeadObject` returns `x-amz-object-lock-mode` (`GOVERNANCE | COMPLIANCE`), - `x-amz-object-lock-retain-until-date` and `x-amz-object-lock-legal-hold`, - "only returned if the requester has the `s3:GetObjectRetention` permission" - (legal hold: `s3:GetObjectLegalHold`). Dedicated calls exist as well - (`GetObjectRetention`, `GetObjectLegalHold`). - ([HeadObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html)) [fetched] -- Write behaviour: a versioned DELETE of a locked version returns `403 Access - Denied`; a simple DELETE succeeds and adds a delete marker. A PUT to the same - key succeeds and creates a new version; the old version stays locked. Governance - mode can be bypassed with `s3:BypassGovernanceRetention` plus the - `x-amz-bypass-governance-retention:true` header. - ([Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html), "How deletes work", "Retention modes") [fetched] -- Pitfalls: the signal depends on read permission (absent header does not mean - unlocked); legal holds can be "freely placed and removed" by anyone with - `s3:PutObjectLegalHold`, so the answer can change between HEAD and DELETE; under - variable retention the retain-until date "moves forward as time passes" while an - event hold is on. (Object Lock page, "Legal holds", "Retain-until-date behavior") [fetched] - -### Git LFS lockable files - -- Ownership signal enforced through the file system: files marked lockable "are - made read-only in the working copy when not locked by the current user" - (`lfs.setlockablereadonly`, default true). - ([git-lfs-config](https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-config.adoc), L448-455) [fetched] -- The authoritative check is server-side at push: Git LFS "verifies that pushes - don't alter files locked by others". - ([git-lfs-lock](https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-lock.adoc)) [fetched] -- Pitfall: the read-only bit reflects lock state as of the last checkout or lock - command; `chmod` defeats it locally, and the push check decides. [memory for the - staleness; the push check is fetched] - -## 5. Collections (the type-system version of the same question) - -- .NET `ICollection.IsReadOnly`: a **property**. Read-only here "does not - indicate whether individual elements of the collection can be modified"; an - array cast to `ICollection` reports true while its elements stay writable. - Mutators throw `NotSupportedException`. - ([ICollection.IsReadOnly](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.icollection-1.isreadonly)) [fetched; the exception is memory] -- Java `Collection`: **exception only**. Mutators are "optional operations" that - throw `UnsupportedOperationException`; the interface has no query for - modifiability. ([Collection, Java 21](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Collection.html)) [fetched] - -## 6. Summary table - -| System | Granularity | Signal shape | Write when read-only | Can the answer go stale? | -|---|---|---|---|---| -| EF Core no-tracking | entity instance | query (`Entry(e).State`) | silent no-op | yes, attach/detach changes it | -| EF Core keyless | entity type | model query (`IsKeyless`) [memory] | throws on attach/update | no (model is fixed after build) | -| Hibernate read-only | entity in session | query (`Session.isReadOnly(e)`) | ignored at flush; delete allowed | per session; settable | -| Hibernate @Immutable | entity type | annotation | ignored, no exception; bulk HQL warns or throws | no | -| ActiveRecord | record | property (`readonly?`) | raises `ReadOnlyRecord` | set at load, not re-derived [memory] | -| Realm frozen | object version | property (`isFrozen()`, `isValid()`) | throws; `findLatest` for a writable copy | `isValid` is live | -| Couchbase Lite | document | type (`Document` vs `MutableDocument`) | n/a, no mutators | no | -| LiteDB, SQLite, Core Data | store or database | option plus store query/property | refused by the store | rarely | -| protobuf unknown fields / Any | field / payload | property list [memory] / `is()` query | preserved / unpack throws | no | -| Avro | field / union branch | exception only | field dropped / error | no | -| Unity missing types | managed reference in a host | query (bool) plus list (key, type name, data) | data preserved; recoverable when type returns | answered on demand | -| POSIX access(2) | path | query | open fails | yes, TOCTOU (documented) | -| S3 Object Lock | object version | metadata via HEAD/GET | versioned delete 403; PUT makes a new version | yes, holds and event holds change | -| Git LFS lockable | file | file-system read-only bit | push refused by server | yes, as of last checkout | -| .NET ICollection | collection | property | `NotSupportedException` | no | -| Java Collection | collection | exception only | `UnsupportedOperationException` | n/a | - -Patterns observed, stated as facts across the sources above: - -- Every system that offers an advance signal still has the write path decide: - EF Core, Realm, ActiveRecord, S3, Git LFS and POSIX all refuse or ignore at the - write regardless of what a check said. -- Where the read-only state can change after it was observed (POSIX permissions, - S3 holds, Git LFS locks, EF Core attach/detach), the documentation either warns - of TOCTOU (POSIX, Python, CWE-367) or places the authoritative check at the - write (S3, Git LFS push). -- Silent-ignore write behaviour (Hibernate entities, EF Core no-tracking) is the - case where the advance signal is the only signal; Hibernate added an opt-in - exception mode for bulk updates. -- The closest analog to records under an unregistered schema id (Unity missing - types) exposes both an on-demand bool query and an on-demand list carrying the - reference id and the recorded type name, and recovers the data when the type - returns. -- Store-level read-only (LiteDB, SQLite, Core Data, and CultCache's own - `CacheBackingStore.IsReadOnly`) is a property or query on the store, not on the - record. diff --git a/docs/research/windows-store-replace-prior-art.md b/docs/research/windows-store-replace-prior-art.md deleted file mode 100644 index f55c8ab1..00000000 --- a/docs/research/windows-store-replace-prior-art.md +++ /dev/null @@ -1,73 +0,0 @@ -# Windows store replace: prior art and probe (2026-10-03) - -This research backs `variants:question:windows-store-replace-primitive`. It came from an Imagination pass during the variants campaign. The probe source and raw results lived in that session's scratchpad (`win-replace/probe/Replacers/Replacers.cs`, `result-net10.txt`, `result-mono.txt`). - -## Problem - -On Windows, CultCache C# replaces a single-file store with `File.Replace`, which calls Win32 `ReplaceFile`. While that replace runs, a lock-free reader can find nothing at the path, and the store opens as empty. Under the h1 cut's probe on Starfire, 1,722 of 17,313 opens came back empty. On Linux, which replaces with `rename`, 0 of 6,252 did. - -## Probe - -The probe copies the C# write path: -- `.lock` opened with `FileShare.None`; -- a GUID temp file written with WriteThrough and `Flush(true)`; -- the replace itself. - -It copies the read path too: an attribute check, then an open with `ReadWrite|Delete`. A writer thread and a tight reader loop share one process. The store sits on NTFS (C:) with Defender real-time protection on. A hash check found no torn reads. - -### Empty-store opens per primitive - -| Primitive | .NET 10 (2,000 writes) | Unity Mono 6.13 (1,000 writes) | Notes | -|---|---|---|---| -| `File.Replace` (`ReplaceFile`) | 46,336 / 244,197 (19%) | 15,915 / 48,298 (33%) | Readers also hit sharing violations: 2,157 on .NET, 5 on Mono | -| `MoveFileExW(REPLACE_EXISTING\|WRITE_THROUGH)` | 0 / 417,115 | 0 / 39,094 | 1,145 of 2,000 first writer attempts failed with error 5 (access denied); all landed after retries; 2x slower | -| `SetFileInformationByHandle(FileRenameInfoEx, REPLACE_IF_EXISTS\|POSIX_SEMANTICS)` | 0 / 9,756 | 0 / 5,282 | 0 errors, fastest (7.2 s). The reader sampled sparsely, about 5 opens per write against 120-200 for the others | -| Reader waits on `.lock` when the path is empty | 50 / 12,660, all recovered | 37 / 2,275, all recovered | Reader waits up to 1,584 ms (mean 371 ms) | - -### A reader holding the store open during one replace, no retry - -| Holder's share mode | `File.Replace` | `MoveFileExW` | POSIX rename | -|---|---|---|---| -| `ReadWrite\|Delete` (C# readers, Rust std, libuv) | ok | error 5 | ok | -| `ReadWrite` (CRT and Python `open`) | error 32 | error 5 | error 32 | -| `Read` | error 32 | error 5 | error 32 | - -When a replace succeeded, the holder kept reading the old bytes, and a new open got the new bytes. - -## Primary sources - -- **ReplaceFileW.** It renames the original aside and then moves the replacement in, which is the empty window. It opens the replacement with no sharing, and it makes no atomicity claim. https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-replacefilew -- **FILE_RENAME_INFORMATION.** Under classic semantics, a rename fails if the target exists and has open handles; that is `MoveFileExW`'s error 5. POSIX semantics replaces a target that has open handles, and is available from Windows 10 1607. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_rename_information - -## What established software does on Windows - -| Software | Replace primitive on Windows | -|---|---| -| .NET `File.Replace` | `ReplaceFile` | -| .NET `File.Move(overwrite)` | `MoveFileExW(COPY_ALLOWED\|REPLACE_EXISTING)`; not in netstandard2.1 | -| Rust std `rename` | `MoveFileExW`, then POSIX rename if that returns access denied | -| git-for-windows `mingw_rename` | POSIX rename first, then `MoveFileExW`, then clears read-only and retries | -| Python `os.replace`, libuv (Node) | `MoveFileExW(REPLACE_EXISTING)` (Python from bug-tracker history) | -| Postgres | `MoveFileEx` with 100 retries, 100 ms apart, on errors 5, 32 and 33 (antivirus named) | -| SQLite, LMDB | Never rename the database. SQLite writes in place under a journal or WAL, and retries I/O on lock errors. LMDB uses copy-on-write pages and a meta-page switch, so readers take no locks | -| Mono `File.Replace` | `ReplaceFileW` | -| IL2CPP (Unity 6000.4.2f1) | `os/Win32/File.cpp:263` calls `ReplaceFileW`, so built players have the same window | - -C# is the only CultCache runtime that uses `ReplaceFile`, and the only one with the empty window. CultCache Rust calls `MoveFileExW` directly. - -## Portability of a P/Invoke path - -- **netstandard2.1:** builds clean with the three kernel32 calls. A runtime OS check is enough; no platform split is needed. -- **Unity Mono:** ran under the Editor's `mono.exe`. -- **IL2CPP:** not run. Its Win32 loader hardcodes `CreateFileW`, `MoveFileExW` and `SetFileInformationByHandle`. -- **GDK (`IL2CPP_TARGET_WINDOWS_GAMES`):** that loader table is absent, so behaviour is unverified. Catch `DllNotFoundException` and `EntryPointNotFoundException`, and fall back. -- **FAT, exFAT and possibly SMB:** probably lack POSIX rename (unverified), so the `MoveFileExW` fallback is needed there. -- **What leaving `ReplaceFile` drops:** creation time, DACL, object id and alternate streams. CultCache uses none of them. - -## Caveats - -- The POSIX-rename reader was sparse. 0 of 9,756 is still strong: about 1,850 empty opens would be expected at `File.Replace`'s rate. -- All runs were in one process. -- Mono reported `arch=X86`; the rename succeeded, so the struct layout was right. - -What would change the conclusion: a cross-process rerun at h1's reader density that shows a window under POSIX rename, or an IL2CPP or GDK player where the P/Invoke does not resolve. diff --git a/docs/runtime-parity-scope.md b/docs/runtime-parity-scope.md index 2c6f2211..44715c7c 100644 --- a/docs/runtime-parity-scope.md +++ b/docs/runtime-parity-scope.md @@ -13,11 +13,6 @@ Cross-runtime parity has three layers: - Wire parity: shared CultCache file/state contracts, schema-v0 MessagePack documents, transport profiles, and RUDP packets must cross runtime boundaries without translation folklore. - Every store reader refuses, by name, a header or record slot it does not - understand (vectors: `tests/vectors/document-variants-c0`). - Document variants: C# resolves them (`cultcache.store.v2`); every other runtime, - CultMesh single-file reads, the directory store and CultNet refuse a variant by name - (vector written by C#: `tests/vectors/document-variants-c1`). - Feature parity: each runtime must expose the CultCache/CultNet/CultMesh surfaces needed for its intended role, with unsupported production-server ownership called out plainly. @@ -67,34 +62,6 @@ to speak CultNet or participate in CultMesh. shared transport port and expand RUDP adoption beyond the core proof. - `packages/cultmesh-kotlin/README.md` records Kotlin's runtime role and ergonomic surface, including the explicit non-claim around C# SoA storage. -- CultNet typed selection (`cultnet.snapshot_response_raw.v1`, C#/Rust only; - docs/cultnet-selection-cut.md, R-AY): byte parity for the - `snapshot_response_raw.v1` envelope and its nested record types, verified at - populated and absent optional values, plus semantic parity over the named - field subset. `packages/cultnet-rs/tests/selection_wire_parity.rs` and - `tests/GameCult.Networking.Tests/SelectionWireParityTests.cs` carry the byte - vectors; `packages/cultnet-rs/tests/selection.rs`'s - `write_selection_vectors_for_the_reference` and - `tests/GameCult.Networking.Tests/SelectionParityVectorTests.cs` carry the - semantic ones. A single rows-to-bytes path driving both halves in one call - remains its own cut (R-AR) and is not part of this claim. -- CultMesh content plane (`cultmesh.content_chunk_request.v1` and `.response.v1` - plus the CDN manifest, C#/Rust only): byte parity in both directions (manifest metadata keeps its wire key order and a - duplicate key is refused, as the reference refuses it), and the reference's answer - to a chunk request, including its failure spellings: every bad request is - answered `found: false`, never refused at decode. - `packages/cultnet-rs/tests/content.rs` and - `tests/GameCult.Mesh.Tests/CultMeshContentVectorTests.cs` judge - `contracts/cultmesh/content-vectors.cs-written.json` and - `content-vectors.rs-written.json`. Rust carries these chunks only on the - session the client already holds (see `src/GameCult.Mesh/docs/transport-planes.md`); - it has no authenticated content connector, so it claims no TCP+TLS or QUIC - content path. - Recorded limits: a caller that passes `max_bytes = u64::MAX` to `fetch_content` gets an unbounded - body, because the reference refuses artifacts over `int.MaxValue` bytes and Rust bounds them only by the - caller's cap. - `normalize_hash` matches the `sha256:` prefix ASCII-case-insensitively while C# `OrdinalIgnoreCase` may - also match non-ASCII forms (for example `ſha256:`); unprobed, and it affects hostile input only. ## Expansion Work Outside The Current Parity Claim diff --git a/docs/semver-policy.md b/docs/semver-policy.md deleted file mode 100644 index 45da987b..00000000 --- a/docs/semver-policy.md +++ /dev/null @@ -1,400 +0,0 @@ -# Semantic Versioning Policy - -Operator ruling, 2026-09-17: **semantic versioning is policy** for every -package CultLib publishes, strictly. A release that removes or changes public -surface incompatibly is a major bump, full stop — not a judgment call left to -the person cutting the release. - -This document says what "breaking" means for each kind of surface this repo -actually ships, and how a release is checked against it. See -`docs/nuget-packaging.md` for how the managed/Unity packaging mechanics work; -this document is the versioning contract those mechanics must satisfy. - -## The scar - -`org.gamecult.cultlib` 1.0.60 removed `CultInspectorAssetPath` — public API — -and shipped as a patch bump. Its own changelog entry is titled "Breaking"; the -version number said otherwise. A reviewer relying on the number alone would -have missed it. This is recorded as history, not fixed by renumbering: `1.0.60` -stays `1.0.60`. This policy, and the check below, exist so the next one is -caught before it ships instead of written up afterward. - -## Packages in scope - -| Package | Kind | Published by | -| --- | --- | --- | -| `org.gamecult.cultlib` | Unity UPM | `scripts/build-unity-package.ps1`, consumed by git tag | -| `org.gamecult.caching.unity` | Unity UPM | tagged directly (no build script; see "Coverage gaps") | -| `org.gamecult.cultmath` | Unity UPM | `packages/cultmath/scripts/build-unity-package.ps1`, consumed by git tag | -| `@gamecult/cultcache-ts` | npm | `.github/workflows/publish-packages.yml` | -| `cultcache-py` | PyPI | `.github/workflows/publish-packages.yml` | -| `cultnet-py` | PyPI | `.github/workflows/publish-packages.yml` | -| `cultmesh-py` | PyPI | `.github/workflows/publish-packages.yml` | - -Each package's tag prefix, changelog path and, for the packages that ship -assemblies, the directory of tracked DLLs are declared in -`scripts/release-packages.mjs`, the one copy. The check reads them by package -name; no release script or workflow passes one. - -Rust crates are consumed as pinned git revisions (see `publish-packages.yml`'s -own header comment) and are out of scope for tagged-release semver policing; -a `Cargo.toml` version still exists and should follow this policy by -convention, but nothing in this repo checks it mechanically today. - -Releases are tags named `-v`, with the prefix declared in -`scripts/release-packages.mjs`. The check refuses a declaration in which two -packages share a prefix or an entry lacks a string prefix or changelog. - -## What counts as breaking - -Semver's ordinary rule — additive is minor or patch, anything a consumer's -existing code or data can no longer rely on is major — applies per surface as -follows. - -### Managed public API (`org.gamecult.cultlib`, NuGet packages, `cultmath`) - -Breaking: removing or renaming a public type/member, changing a public -member's signature or observable behavior in an incompatible way, tightening -a public contract (new required parameter, narrowed accepted input), -or moving a type across assemblies/namespaces without a compatible forwarder. - -Not breaking: adding a new public member, type, or overload; widening an -accepted type; deprecating (marking obsolete) without removing. - -### Unity package inspector attributes (`org.gamecult.cultlib`, -`org.gamecult.caching.unity`) - -These ship as ordinary public API by the rule above, but get their own -callout because they are easy to mistake for "just editor tooling": an -attribute class, its constructor shape, and the serialized value shape it -reads/writes are all public surface a consumer's `[CultInspectorX(...)]` -usage and serialized scene/prefab data depend on. Removing or renaming an -attribute, or changing what it expects a annotated member's persisted value to -look like (as `CultInspectorAssetPath` to `CultInspectorAssetGuid` did in -1.0.60) is breaking. - -### Persisted wire format / store compatibility (CultCache) - -Governed by `src/GameCult.Caching/Contracts/cultcache-schema-compatibility.md` -and `cultcache-persistence-format.md` — read those for the authoritative -rules. In semver terms: anything those documents classify as **hard -rejection** (type change, reference/value change, one-vs-many change, target -schema change, name/index lookup semantics change, a persisted schema with no -compatible local candidate) is breaking for any package that reads or writes -the format. Anything classified as **soft-migratable drift** (compatible -schema id drift, an ignorable missing slot, a defaultable missing slot) is not -breaking on its own, but changing what counts as soft-migratable — loosening -or tightening the drift rules themselves — is breaking for whichever package -owns that classification logic. - -### CultNet protocol surface - -Breaking: a wire-incompatible change to a CultNet message, frame, or -handshake shape; removing or repurposing a message type or field that another -runtime's implementation depends on; changing routing, authority, or trust -semantics such that a peer built against the previous protocol version -misbehaves rather than cleanly failing. Additive, backward-compatible framing -changes (a new optional field a receiver may ignore) are not breaking. - -### Native bridge exported functions (`GameCult.Mesh.Quic.Native`) - -Breaking: removing or changing the signature/ABI of a `CULTMESH_API` -(`extern "C"`) exported function, or changing an exported function's -behavior such that the existing managed P/Invoke caller (`GameCult.Mesh.Quic.Native`'s -C# side) or Rust caller (`cultmath-core`'s equivalent `#[no_mangle] extern "C"` -surface) no longer gets what it asked for. Swapping the underlying TLS/QUIC -implementation (as 1.0.60 did, Schannel to OpenSSL MsQuic) is not breaking -*by itself* as long as the exported v1 functions keep their signatures and -behavior — 1.0.60's actual breaking change was the inspector attribute -removal, not the bridge swap, and its changelog correctly filed the bridge -swap under "Changed" rather than "Breaking". - -## Pre-1.0 packages - -A package at `0.y.z` (currently `org.gamecult.cultmath`, at `0.4.x`) uses the -standard pre-1.0 convention: `MAJOR` stays `0` during initial development, so -`MINOR` carries what `MAJOR` means once the package reaches `1.0.0`. Concretely: - -- a breaking change bumps `MINOR` (and resets `PATCH` to `0`); -- a non-breaking change bumps `PATCH`. - -Leaving `0.y.z` for `1.0.0` is a deliberate, separate decision (the API is now -considered stable), not something the checker infers on its own. - -## What a release changelog entry must contain - -Every published package keeps a `CHANGELOG.md` beside its manifest -(`unity/org.gamecult.cultlib/CHANGELOG.md` and -`src/GameCult.Unity/Assets/Caching/CHANGELOG.md` are the existing precedent). -Each release adds a `## []` section (the check also reads -`## `, and either form followed by Keep a Changelog's -` - YYYY-MM-DD` date, such as `## [0.4.0] - 2026-10-03`) containing: - -- a category subsection per change (`### Added`, `### Changed`, `### Fixed`, - etc., following Keep a Changelog style); -- **`### Breaking`** — this exact heading, this exact spelling — for any - change that meets the "what counts as breaking" rules above. This heading - is not decorative: the CI check below greps for it by name. -- enough detail that a consumer can tell what to change, in the style of the - 1.0.60 entry (name the removed/changed symbol and its replacement). - -A version with no changelog entry at all fails the check below, the same as -a mislabelled one — an undocumented release is not a smaller sin than a -mislabelled one. - -### First release of a package - -A package with no `CHANGELOG.md` yet cannot release: the check refuses with -"changelog not found". Its first release writes the file at the declared path, -`packages//CHANGELOG.md`, with one section for the version being -released. That version must still be exactly the next one after the package's -nearest ancestor tag. As of 2026-10-03 the valid next versions are: - -- `cultcache-ts`, after `cultcache-ts-v0.14.0`: `0.14.1`, `0.15.0` or `1.0.0`; -- `cultcache-py`, after `cultcache-py-v0.3.0`: `0.3.1`, `0.4.0` or `1.0.0`; -- `cultnet-py` and `cultmesh-py`, which have no tags: `0.1.0`, their manifest - version, as a first release. Run it from a clone with the tags fetched, or - the check cannot tell a first release from a missing record. - -On `0.y.z` a `### Breaking` section needs at least a minor bump. - -## Enforcement - -`scripts/check-changelog-semver.mjs` is the mechanical check. Given a -package name and the version being released, it reads the package's -declaration from `scripts/release-packages.mjs` in `--cwd` (an unknown package -or a missing declaration refuses), and: - -1. derives the release record from `git tag -l` in `--cwd`. A same-prefix tag - is one that starts `-v`; one that is not - `-vMAJOR.MINOR.PATCH` refuses, naming the tag, and is never - skipped. The previous release is the newest same-prefix tag strictly older - than the version being released, by version order, that is also an ancestor - of the commit being checked: a backport tagged later on another branch is - not part of that history, so it never moves a rebuild's predecessor. A tag - equal to the version does not exempt - it and does not count as a previous release: there is no "already - published" skip, so a rebuild or a CI re-run at a tagged version is - measured against that version's predecessor, exactly as at release, and - gets the same verdict. With no older tag, a newer one refuses (the version - is older than every release), and a repository that holds no tag other than - the version's own refuses, because a first release cannot be told from a - missing record. Older tags of which none is an ancestor leave the - predecessor unknown and refuse. Otherwise it is a first release, which no - caller declares. A package that declares an assemblies directory is a first - release only when no tag in the repository, under any prefix, tracks a - managed assembly under that directory: such a tag means the package has - shipped, so the declared prefix is wrong and the check refuses, naming the - tag and the assembly. A tag snapshots the whole tree of this monorepo, so a - tag tracking a package's directory proves nothing; only a managed assembly in - the declared directory does. This is read from git, never from the changelog's - prose. The version's own tag does not count, so a first release can be - rebuilt. Only the declared directory counts: a package whose directory moved - after its releases has none of its old path's tags counted, so its release - under a misspelled prefix reads as new, and the move itself is caught only - under the right prefix, where the declared directory holds no managed assembly - at the previous tag. A package that declares no assemblies directory (the - Python and TypeScript packages and the Caching Unity package) has no such - proof: with no tag of its own prefix it is a first release. The suite test - that pins every declared prefix guards it: each prefix is declared once, each - workflow tag trigger must be a declared prefix, and each such package's prefix - must be a workflow trigger or, for the Caching Unity package the workflow does - not build, the prefix of tags that hold its own manifest at the tag's own - version, so a typo or a copied prefix fails the suite. Nothing releases - without the suite passing; see below for how each release path runs it. - Releases run from a full clone with every tag (`fetch-depth: 0` in CI), the - recorded `partial-tags-first-release`. - Tags that cannot be read (a `--cwd` that is not a git repository, or a tag - whose tree cannot be listed) refuse; -2. requires a `## []` changelog entry to exist at all; -3. classifies the version bump (major/minor/patch) against the previous - version, refusing anything that is not exactly the next version in some - lane — a skip, a reversal, or a repeat are all refused, not just wrong - bump sizes; -4. when the release script supplies built assemblies (below), treats the - release as breaking if the public API measurably lost or changed a member - against the previous tag, whether or not the changelog says so; a - measured break with no `### Breaking` section is refused, naming the - count, the first diagnostics, and the heading that must declare them; -5. if the release is breaking (a `### Breaking` section, a measured break, or - both), requires the bump to be at least major (or, pre-1.0, at least - minor); a `### Breaking` section with nothing measured is valid, because - behavioural breaks are invisible to a signature comparison; -6. fails loudly, naming the package, the previous and new version, and (when - relevant) the changelog heading or the measured diagnostics that - triggered the requirement. - -Additions are never a rule: adding a public member is not breaking (see -above), and the check neither refuses nor demands a bump for one. - -### Measured input - -A package whose declaration names an `assemblies` directory is measured, and -the release must hand over one `--api-built ` per assembly it built (plus -`--api-refs ` for directories that hold the built assemblies' -dependencies). A package with no such directory takes no `--api-built`, and one -that has it cannot omit it. The measured set is every managed assembly tracked -under that directory, at any depth, at the previous tag, read as git blobs (no -worktree, no network, unaffected by what the working tree tracks now) and keyed -by file name. A DLL is managed when its PE header carries a CLI header; a -native DLL has none and is not measured, and a tracked `.dll` that is not a PE -image refuses. Two managed assemblies with one name refuse. The checker -compares each built assembly with its namesake using -`Microsoft.DotNet.ApiCompat.Tool`; each `CPnnnn` diagnostic is one measured -break. Every managed assembly the previous tag tracked that the build no -longer hands over is itself a measured break, whatever its name or place, so a -release script passes every assembly it ships. A built assembly with no -namesake at the tag is an addition and is not examined. - -Measuring nothing is a refusal, never a pass. The check refuses, naming what -is missing, when the previous tag tracks no managed assembly under the -declared directory (a wrong or moved directory, or a tag that predates it); -when git cannot read the tracked assemblies; and when the tool fails to -measure (not installed, an unreadable assembly, a crash: a non-zero exit with -no diagnostic line). A first release measures nothing. - -The tool and the `NETStandard.Library.Ref` 2.1.0 reference assemblies are -pinned in `scripts/api-gate/` (`.config/dotnet-tools.json` and -`ApiRefs.csproj`) and restored there by the check itself, so a release does -not depend on any other tool in the repository's manifest. NuGet is needed -until both are cached under `scripts/api-gate`. Both sides of every -comparison resolve netstandard types through those reference assemblies, and the -new side also through the built DLL's own directory and every `--api-refs` -directory. No suppression file is kept: a suppression would be a second, silent -declaration of a break, so a break is declared only under `### Breaking`. - -A passing measured run prints that unmeasured changes still need declaring. - -#### Unmeasured changes - -ApiCompat does not report these changes to a public member, and the check -therefore passes them. Each is a breaking change under the rules above and is -declared under `### Breaking`, as behavioural breaks are: - -- a member gaining or losing `static`; -- a parameter gaining or losing `ref`, `out` or `in`; -- a `const` field's value changing; -- an enum member's underlying value changing; -- a field gaining or losing `readonly`; -- a default parameter value changing. - -The release scripts run the check once the assemblies under judgement exist, -after the build and before anything is copied into the package. - -Run it directly: `node scripts/check-changelog-semver.mjs --package ---version [--cwd ] [--api-built ... [--api-refs ...]]`. -Any other option is a usage error (exit 2). Its own tests live in -`scripts/check-changelog-semver.test.mjs` (`node --test -scripts/check-changelog-semver.test.mjs`). - -It is wired into: - -- `.github/workflows/publish-packages.yml`, through - `scripts/release-after-suite.mjs`, for `cultcache-ts`, `cultcache-py`, - `cultnet-py`, and `cultmesh-py`, with `fetch-depth: 0` so the checkout holds - the tags; -- `scripts/build-unity-package.ps1`, for `org.gamecult.cultlib`; -- `packages/cultmath/scripts/build-unity-package.ps1`, for - `org.gamecult.cultmath`; -- `scripts/verify-caching-unity-release.ps1`, for `org.gamecult.caching.unity`. - -Each of those runs the check's own tests before it releases. The Unity release -scripts run them before they call the check, and the tests pin that order. In -`publish-packages.yml` the release step runs `scripts/release-after-suite.mjs` -with the run's git ref. From one process it checks that a tag ref is the -package's declared prefix and manifest version, runs these tests, runs this -check for the tagged version, runs the package's own tests (`npm test`, or the -Python package's unit tests), and only then the release action: `npm publish` -for `cultcache-ts`, which it refuses on any ref but a release tag, and for the -Python packages the sdist and wheel build, whose output is all the PyPI upload -step uploads. The checks run with the known test-runner and token variables -removed (`NODE_OPTIONS`, `NODE_TEST_CONTEXT`, any other `NODE_TEST_*` variable, -and `NODE_AUTH_TOKEN`), so none of those can make the tests run nothing and -pass, and only the release action receives the token. That list names known -variables; it does not prove that no other inherited variable can affect a -check. The npm Publish step and the Python sdist and wheel build step start the -guard under `env -u NODE_OPTIONS`, so a `NODE_OPTIONS` preload set in the -workflow's or job's `env:` cannot run code inside the guard before its first -line. -The gate is that call, not a step condition, so no `if:` or `continue-on-error` -can release what a check refused. The tests compare each job's release steps -with their expected text exactly, less the steps' `if:` lines. Removing the call -is still possible, but only as a visible edit to those steps and to the tests. - -The guard and that pin stop accidental workflow edits. They do not stop a -deliberate one: an extra step that publishes, a workflow-level `defaults:` or -`env:`, or a fake `node` on `$GITHUB_PATH` all pass them. Deliberate edits are -review's job, as ruled in `suite-gate-structural-not-parsed`, and the pin -does not try to parse the workflow for them. For the same reason it has no ban -on `shell` or `defaults`: such a ban defends only against a deliberate edit, -and it also refused harmless settings such as `defaults.run.working-directory`. -A step-level `shell:` on a release step still fails the exact comparison. -A recommendation for the operator, not something this repository can set: the -Python job already runs in the `pypi` GitHub environment, as PyPI trusted -publishing expects. Putting the npm job in an environment with required -reviewers would make every npm release wait for a person's approval. That is a -GitHub settings change. - -`org.gamecult.cultlib` compiles CultMath from source and ships beside -`org.gamecult.cultmath`, so its build refuses unless it declares exactly the -CultMath package's version and every `CultMath.dll` it built equals the one -that package tracks, byte for byte. Any CultMath source change therefore means: -release `org.gamecult.cultmath`, declare its new version in -`org.gamecult.cultlib`, then release `org.gamecult.cultlib`. The bytes also -depend on the checkout and the toolchain. `.gitattributes` pins CultMath -source to CRLF on every checkout, because the tracked DLL was built from CRLF -source and line endings reach the DLL through the pdb's document checksums; a -clone checked out before that rule may still hold LF files (`git ls-files ---eol packages/cultmath/src` shows `w/lf`) until they are checked out again. -The build needs a git checkout, and refuses up front without `.git`: the repo -root maps to `/_/` through git, so an archive or source zip would write its -own path into the DLL. No `global.json` pins the .NET SDK, so the same refusal -at unchanged source and CRLF checkout means this SDK or host differs from the -one that built the tracked DLL. - -### Coverage gaps - -`publish-packages.yml` only triggers on `cultcache-ts-v*`, `cultcache-py-v*`, -`cultnet-py-v*`, and `cultmesh-py-v*` tag pushes — it does not build or gate -the Unity UPM packages at all; those are consumed directly by git tag -(`unity/org.gamecult.cultlib`, `packages/cultmath/unity/org.gamecult.cultmath`, -`src/GameCult.Unity/Assets/Caching`), so a workflow trigger on their tags -cannot be added to that file without also giving it a reason to check out and -build Unity content it currently has no job for. The check is instead wired -into the scripts that already run at Unity-package release time: -`build-unity-package.ps1` and `packages/cultmath/scripts/build-unity-package.ps1` -already verify version consistency between the built assembly and -`package.json`, so the semver check runs alongside that as one more release -gate. `org.gamecult.caching.unity` has no build script at all today — it is -pure C# source tagged directly with no compile step — so -`scripts/verify-caching-unity-release.ps1` exists solely to run this check -before that package is tagged; it is not a build script and does not become -one. - -None of this is enforced by a git hook or branch protection rule: it runs -when someone remembers to run the Unity release scripts, the same way the -existing assembly-version check does. A tag pushed by hand without running -the release script bypasses both checks equally; closing that gap is a CI -trigger on tag push for the Unity packages, not something this change adds. - -What stays unmeasured: behaviour behind an unchanged signature, wire formats, -native exports of the QUIC bridge, and the Caching Unity package's source -(it has no assembly). Those rest on the `### Breaking` declaration. - -Rust crates (consumed as pinned git revisions, not tagged releases in the -usual sense) and the CultNet protocol surface itself (no automated wire -compatibility test currently gates a release) are policy by convention only — -described above, not mechanically checked. Extending the checker to a Rust -crate's `Cargo.toml`/`CHANGELOG.md` or to an automated CultNet interop -compatibility gate is future work, not part of this change. - -`@gamecult/cultcache-ts`, `cultcache-py`, `cultnet-py`, and `cultmesh-py` -currently have **no `CHANGELOG.md` file at all**; the check refuses their next -tagged release ("changelog not found at ") until each -package's file exists. A release with no changelog is not a smaller problem -than a mislabelled one. The next release of each creates its file: -`packages/cultcache-ts/CHANGELOG.md` arrives with the document-variants work -(`hands/variants-c2a`), and whoever cuts the next release of `cultcache-py`, -`cultnet-py` or `cultmesh-py` creates that package's file. Backfilling -changelog content for past releases would mean inventing release-note prose -for history nobody here knows first-hand, so the gap stays named. diff --git a/docs/studio-grouping-cut.md b/docs/studio-grouping-cut.md deleted file mode 100644 index 770d0698..00000000 --- a/docs/studio-grouping-cut.md +++ /dev/null @@ -1,432 +0,0 @@ -# Studio Record Grouping And Reference Drag-Drop Cut - -First mapped 2026-09-17 (Imagination) against CultLib `122c217`. **Refreshed 2026-09-29 -(Imagination) against CultLib `main` `feeced8` and Aetheria `codex/fire-control-12` `4b594e11`.** -Every `file:line` below is against those revisions unless marked. Hands re-reads an anchor -before editing it; `main` keeps moving. - -**Rulings.** Q1 **B** (a class attribute on the model; argument order is nesting order; -2026-09-17). Q2 **A** (occupied values only). Q3 **A** (list only, not the ref picker). -Q4 **A** (no record search). Q5 **overtaken**: one release from `main`, together with -document-variants C3 (`docs/document-variants-cut.md`), taking whatever native-plugin drift -`main` carries. Q6 **A** (flat row by resolved value, C3's variant marker; 2026-09-30). Q7 **B** (legacy parity -minus manufacturer, plus `FactionProductData` by `Manufacturer` then `Design`, plus -`WeaponItemData` by `WeaponType`; 2026-09-30). - -## Target - -### Ends - -1. **Declared record grouping.** `[CultInspectorGroupBy(nameof(A), nameof(B))]` on a document - class makes Studio's record list for that type a foldout tree, nested in argument order. A - declaration on a base type groups every derived type listed under it. -2. **Create in a group.** Every group node offers `Create`. The new record gets every grouped - member on the path to that node set to that node's value, so it lands in that node. -3. **Reference drag and drop.** A record row dragged from Studio's list onto any - `CultRecordRef` value the inspector draws (member, list element, dictionary key or value) - is accepted exactly when the ref's picker would offer that record. - -Recovered from the legacy "Database Tools" window (Aetheria `d3db1730`, -`Assets/Scripts/CultCache/Editor/DatabaseView.cs`, `AetheriaDatabaseView.cs`, -`Inspectors/DatabaseLinkInspector.cs`). Selector lambdas are rejected (operator, 2026-09-17). - -**The attribute is not `[CultIndex]`.** `[CultIndex]` means unique (operator, 2026-09-30; -`CultDocumentContracts.cs:34`). Grouping is `CultInspectorGroupByAttribute`, in -`CultInspectorAttributes.cs`, read only by `CultInspectorModel`. It changes no schema id, -catalog entry, index, or store byte. The index cut's deletion of grouping-only `[CultIndex]` -declarations (CultMesh, Geometry) adds no `[CultInspectorGroupBy]` in their place: those are -service stores, not Studio-authored catalogs. - -### Invariants - -- **I1. The model owns grouping.** `CultInspectorModel` alone decides which members group a - listed type and in what order, which declarations are invalid (and the notice), the tree's - partition, node identity, order and labels, and the object create-in-group makes. Studio - lowers the tree; it never reads the attribute, calls `SetValue` for a preset, or computes a - group label. -- **I2. The leaves partition the candidates.** Across all leaves the tree holds exactly - `RecordCandidates(CultRecordRef, records)`, each record once, in candidate order - inside a leaf. Grouping never hides a record, including one whose grouped value is unset, - dangling, or an undefined enum value. -- **I3. The listed type owns the tree's shape.** Grouping comes from the type selected in the - type pane, never from each record's runtime type. -- **I4. Node identity is value identity, not the label.** A ref groups by key, an enum by its - underlying value, other kinds by the value's invariant string. Foldout state keys on node id. -- **I5. Create-in-group round-trips.** Upsert what `CreateInGroup(listed, node)` returns, - regroup: the new record lies in a node with the same id. -- **I6. One candidate rule.** `IsRecordCandidate(refType, record)` is the only test for "this - record may be this ref's value". `RecordCandidates` filters through it; drop acceptance calls it. -- **I7. One ref label.** The model owns `None` and `Missing `; the picker and group labels - both use it. -- **I8. Invalid declarations never break the window.** They give a flat list plus the model's - notice, never a throw in `OnGUI`. -- **I9. A drop honours the picker's gates.** Refused in a disabled (read-only) scope, when the - payload came from another model, and when the key equals the current key. A dictionary-key - drop still passes `ReplaceKey` (`CultCacheStudioDrawers.cs:303-309`). -- **I10 (new). Grouping reads what readers read.** A variant record groups, labels, and is a - drop candidate by its resolved `Document` (`CultCache.cs:369-371`), never its delta. - -### Non-goals - -No sibling-runtime port (TS `cult-cache-inspector.ts` is a byte dumper; Rust and Python have -no inspector). No runtime CultUI panel. No search (Q4), no picker grouping (Q3), no -drop-to-append on list headers, no legacy `New ` naming. - -## Body findings - -Kept from 2026-09-17, re-anchored: - -- **F3.** Legacy grouping matched the exact type; grouping derived records under a base - declaration is new. -- **F4.** Legacy create-in-group was dead (`DatabaseView.cs:70-75` throws); legacy foldouts - keyed on the label hash. -- **F5.** `member.GetCustomAttributes(true)` ignores `inherit` for a `PropertyInfo`, so a base - `[M] abstract P` is not seen on the override. Sites: `CultInspectorModel.cs:36` (now the only - metadata site: `MetadataOf` caches it per member, `:341-351`) and `:209` - (`CultInspectorDrawerClaims.Resolve`). Fix: `Attribute.GetCustomAttributes(member, true)`. -- **F6.** Studio `Add` creates only the listed type (`CultCacheStudioWindow.cs:340-346`, - `CreateElement(type, type)`), disabled when the model cannot create it (`:141`). So - create-in-group never makes a derived type, and an abstract listed type offers no `Create`. -- **F7.** Studio search filters the type pane only (`:112-120`). -- **F8.** Foldouts are in-memory (`CultCacheStudioDrawers.cs:33`); `OnDisable` closes the store - (`:48-51`), domain reload included. The only `EditorPrefs` key is `LastPathKey` (`:13`). -- **F9.** No drawer claims `CultRecordRef<>`, so every ref reaches `DrawRecordRef` - (`CultCacheStudioDrawers.cs:254-280`). -- **F10.** The Studio editor sources compile outside Unity (netstandard2.1, C# 9, against - Unity 6000.3.24f1 `Editor\Data\Managed\UnityEngine\*.dll` without the `UnityEditor.dll` - facade, plus the built `GameCult.Caching*` and tracked `MessagePack*.dll`). The 09-17 - scratch project is gone; Hands rebuilds it in its own scratch from this recipe. -- **F11.** The record row reads its click in `GUILayout.Toggle` (`:184`); a drag start must be - handled on a reserved rect before the toggle draws (IMGUI convention, not probed). - -New since the map: - -- **F12. Variants (C1, `6ffe17a`).** `CultInspectorModel(registry, CultCodec)` - (`CultInspectorModel.cs:302-306`); Studio still calls `CultCacheMessagePack.CreateInspectorModel(registry)` - (`CultCacheMessagePack.cs:33-34`, unchanged). `CultStoredDocument.Variant` is the delta - (`CultCache.cs:374`); `Document` is the resolved view. A top-level override is a - `Set` whose path is one step at the member's slot (`CultVariants.cs:72-73`), so "is this - grouped member overridden on this variant" is computable from the member's `Slot`. -- **F13. Every Studio commit to a variant key is refused until C3.** `CultInspectorEdit.Commit` - is a plain `UpsertAsync` (`CultInspectorModel.cs:266-282`); Q1a refuses a plain write at a - variant key (`CultCache.cs:2494-2496`). A drop into a variant's inspector therefore reports - that refusal until C3 lands. The release waits for C3, so no shipped Studio shows it, but - the operator click-through must run after C3. -- **F14. Studio `Duplicate` of a variant makes a flattened plain copy** - (`CultCacheStudioWindow.cs:349-353` clones the resolved `Document`). Not this campaign's - defect; C3's `CreateVariant` sits beside it. -- **F15. Element ids (C2a, `hands/variants-c2a`, WIP `df74f8c`).** No grouping interaction: - grouped members are top-level scalars and refs; ids live on list elements. Drops write a ref - into the edit document; ids are untouched and minted on write for new elements; C3's diff - keys overrides on them. Two consequences: - - After C2a, registration refuses a document type whose object-list element lacks a - `[CultElementId]` (`CultCache.cs` descriptor build, WIP). Cut 1's new fixtures carry no - object lists. - - C2a does not hide or lock the id member, so Studio shows it as an editable string. - Hand-editing one retargets overrides. That belongs to C3 (make `[CultElementId]` members - read-only in the model), not here; flagged for Self. -- **F16. The 1.0.60/1.4.0 release shipped** (`0155ba8`, tags on `45c2f40`) and - `codex/asset-guid-attribute` is merged. It already carried the 302,080-byte native bridge, - so the 09-17 Q5 drift is spent. Native source has moved since (`git diff --stat 45c2f40 main - -- native/`: 5 files, +840/-118), so this release rebuilds the bridge again. The v1 exports - the managed side imports (`src/GameCult.Mesh.Quic.Native/*.cs:263-276`) remain at - `cultmesh_quic_native.cpp:1405-1465`. -- **F17. Aetheria's schema moved.** `ItemData.Manufacturer` is gone (slot 3 retired, - `ItemData.cs:281-282`). The manufacturer relation now lives on `FactionProductData` - (`FactionProduct.cs:27`, `CultRecordRef Manufacturer`; `:24`, - `CultRecordRef Design`). Aetheria pins `cultlib-unity-v1.0.60` / - `caching-unity-v1.4.0` / `cultmath-unity-v0.2.4` (`Packages/manifest.json:54-56`), - `CultLibRevision` `45c2f40` and a separate `CultMathRevision` `6d5e209` - (`Directory.Build.props:6,10`). -- **F18. After C2a, Aetheria cannot take the new CultLib without its element-id sweep** - (`List`, `List`, `List`, `List`, - `List`, `List`, among others). So the Aetheria re-pin belongs to - variants C4, and this campaign's Cut 4 shrinks to annotations and tests on top of it. - -## Identity and authority - -| Thing | Owner | Lifecycle | Persisted | -|---|---|---|---| -| `[CultInspectorGroupBy]` | consumer source | compile time; nearest declaration wins; no arguments opts out | source only | -| `CultInspectorGrouping` (resolved) | model | cached per listed type like `_shapes` (`CultInspectorModel.cs:296`) | no | -| `CultInspectorRecordGroup` tree, node ids, labels | model | rebuilt each `OnGUI`, as `RecordCandidates` is (`CultCacheStudioWindow.cs:167`) | no | -| Group foldouts (node id → bool) | window | window memory; cleared by `CloseStore` (`:318-327`) | no | -| Drag payload `{ Model, Key }` under `"GameCult.CultCacheStudio.Record"` | Studio list (source) | one drag | no | -| Drop acceptance | `IsRecordCandidate` plus I9 gates | per `DragUpdated`/`DragPerform` | no | -| Created-in-group object | model makes; `CultCache` admits via `UpsertAsync`, as `Add` | new plain record | store, on `Save` | - -## Forks - -Q1-Q5 are ruled (header). Two remain. - -### Q6. RULED A (2026-09-30). How does the grouped list show a variant? (blocks nothing in Cuts 1-2; shapes C3's row lowering) - -Mechanical defaults, not asked: a variant groups by its resolved values (I10), so a variant -that inherits its base's `HullType` sits in the base's node and moves when the base changes; -create-in-group always makes a plain record; C3's `CreateVariant` needs no preset because the -variant inherits its base's group; a variant is a valid drag payload. - -- **A. Flat by resolved value.** A variant is an ordinary row in its resolved group. C3 adds a - row marker ("variant of Longinus"). Which of its grouped values are overridden shows in the - inspector through C3's per-member marker, not in the tree. -- **B. Nested under the base.** Inside a leaf, a variant row sits indented under its base's row - when both share the leaf; otherwise it stands alone with the marker. -- **C. A's rows plus an inherited/overridden glyph on the row** for the grouped members. -- **Recommendation: A.** I2 stays one rule, the tree has one shape, and the base link already - lives in C3's inspector. B makes the tree's shape depend on two relations, and splits - whenever a variant overrides a grouped value. C duplicates C3's inspector marker. - -### Q7. RULED B (2026-09-30). Which Aetheria types group, and by what? - -Candidates on `codex/fire-control-12` (enums unless noted; `[Flags]` enums excluded): - -| Type | Member | Anchor | Note | -|---|---|---|---| -| `SimpleCommodityData` | `Category` (`SimpleCommodityCategory`) | `ItemData.cs:310` | legacy parity | -| `CompoundCommodityData` | `Category` (`CompoundCommodityCategory`) | `ItemData.cs:338` | legacy parity | -| `GearData` | `Hardpoint` (`HardpointType`) | `ItemData.cs:454` | legacy parity; `WeaponItemData` inherits when listed under `GearData` | -| `WeaponItemData` | `WeaponType`; or `WeaponCaliber`, `WeaponRange` | `ItemData.cs:485`, `:482`, `:479` | re-declaration, applies when listing weapons | -| `HullData` | `HullType` | `ItemData.cs:519` | legacy parity | -| `FactionProductData` | `Manufacturer` (ref `Faction`), then `Design` (ref `CraftedItemData`) | `FactionProduct.cs:27`, `:24` | where "by manufacturer" now lives | -| `Loadout` | `Hull` (ref `HullData`) | `Loadout.cs:17` | optional | - -`ConsumableItemData`, `CargoBayData`, `DockingBayData`, `Faction`, `PersonalityAttribute` -have no groupable member worth a level. - -- **A. Legacy parity minus manufacturer:** commodities by `Category`, `GearData` by - `Hardpoint`, `HullData` by `HullType`. -- **B. A, plus `FactionProductData` by `Manufacturer` then `Design`, plus `WeaponItemData` by - `WeaponType`.** -- **C. B with `FactionProductData` by `Design` then `Manufacturer`** (the market-segment view: - who makes this design). -- **D. B plus `Loadout` by `Hull`.** -- **Recommendation: B.** It recovers everything the legacy window grouped, puts the - manufacturer view where the manufacturer now is, and gives the weapon list its own axis. - C is the better view if the operator authors products per design rather than per faction. - Product record counts are unprobed; Cut 4's Hands reports them. - -## Defaults (recorded, not asked) - -- **Labels:** enum `Enum.GetName`, else the number; ref `RecordLabel` of the candidate with that - key (for `Faction`, `Name`, not legacy `ShortName`); unset ref `None`; dangling `Missing `; - string its value or `(empty)`; integer invariant string; bool `False`/`True`. -- **Order within a level:** enums by underlying value; refs `None` first, then label - (`OrdinalIgnoreCase`, then key), `Missing` last; strings `OrdinalIgnoreCase` then ordinal; - integers numeric; `false` before `true`. -- **Groupable kinds:** String, Integer, Bool, Enum (not `[Flags]`), RecordRef. Refused with a - notice and a flat list: any other kind (Float included), a `[Flags]` enum, `Hidden`, - `IsReadOnly`, a name that is not an inspector member of the listed type, a name given twice. -- **Global types are never grouped.** -- **Foldouts:** window memory, collapsed by default, cleared by `CloseStore`. Create-in-group, - `Add` and `Duplicate` expand the path to the new selection. No `EditorPrefs`/`SessionState`. -- **Create into a `Missing ` node** presets the dangling key (keeps I5). -- **A drop of the current key is rejected** (no no-op commit). -- **Variants:** see Q6's defaults and I10. - -## Sequence with document variants - -| Cut | Files | Overlaps grouping? | -|---|---|---| -| Variants C2a (element ids, in flight) | `CultCache.cs`, new `CultElementIds.cs`, Mesh/Geometry documents, `ElementIdTests.cs` | no | -| Index cut (`[CultIndex]` means unique; queued behind C2a) | `CultCache.cs`, Mesh/Geometry | no | -| Variants C2b (nested paths; inferred from the brief, not yet written in the variants map) | `CultCache.cs`, `CultVariants.cs` | no | -| **Grouping Cuts 1-2** | `CultInspectorModel.cs`, `CultInspectorAttributes.cs`, `CultInspectorModelTests.cs`, `CultCacheStudioWindow.cs`, `CultCacheStudioDrawers.cs`, Studio README | — | -| Variants C3 (Studio edits the delta) | `CultInspectorModel.cs` (edit, commit, diff, `CreateVariant`, `Rebase`), window (variant controls beside `Duplicate`, row marker), drawers (per-member marker and revert), `CultInspectorModelTests.cs` | **yes: all five grouping files** | - -**Order:** grouping Cuts 1-2 now, in parallel with C2a, the index cut and C2b (no shared -files). Grouping merges to `main` before C3's Hands starts; C3 needs C2b anyway. C3 then -rebases onto grouping and lowers its row marker inside the grouped row drawing that Cut 2 -writes. Then **one release (Cut 3)**, then one Aetheria pass (variants C4 plus Cut 4). - -Where they touch: `DrawRecords` rows (`CultCacheStudioWindow.cs:180-185`; grouping rewrites, -C3 marks); the toolbar (`:142-157`; C3 adds variant buttons beside `Duplicate`, grouping -leaves it alone); `DrawRecordRef` (grouping adds the drop target; C3 marks at the member -level in `DrawValue`, not inside it); `CultInspectorModel.cs` (disjoint methods); -`CultInspectorModelTests.cs` (disjoint fixtures; name grouping fixtures `Group*`). - -**One release commit:** Cut 3 below is the single release for both campaigns. The variants -map's C3 line "Then tag `caching-unity-v1.5.0`" should point here instead of owning a second -release step (proposal for Self). - -## Cuts - -Hands for Cuts 1-2: branch `hands/studio-grouping` in a fresh worktree off `origin/main` -(Self picks the path, e.g. `C:/wsNN-grouping`). `F:\Projects\CultLib-studio-grouping` holds the -superseded docs-only `codex/studio-grouping`; do not reuse it. Do not touch the main checkout. -Mutation testing is Stryker.NET on the cut's diff; there are no hand-applied mutations. - -### Cut 1. CultLib model: declaration, tree, candidate and label authority (~150k tokens) - -- **Delete and collapse first:** - - `CultInspectorModel.cs:519`: the inline `target.IsInstanceOfType(record.Document) && - record.Key.Value.Length > 0` in `RecordCandidates` (`:514-522`) moves into - `IsRecordCandidate`; `RecordCandidates` filters through it (I6). - - `:36` and `:209`: `member.GetCustomAttributes(true)` → `Attribute.GetCustomAttributes(member, true)` (F5). -- **Add in `CultInspectorAttributes.cs`**, before `CultInspectorDrawerAttribute` (`:81-86`): - `CultInspectorGroupByAttribute(params string[] members)`, `AttributeUsage(Class, - Inherited = true, AllowMultiple = false)`, property `Members`, with a comment in the file's - style stating nesting, nearest-wins and opt-out. -- **Add in `CultInspectorModel.cs`** (or a sibling `CultInspectorGrouping.cs`, same namespace; - one file while it stays under ~800 lines; it is 645 now): - - `CultInspectorGrouping { Type ListedType; IReadOnlyList Members; string? Notice }` - (members empty when `Notice` is set). - - `CultInspectorRecordGroup { string Id; string Label; int Depth; IReadOnlyList Values; - IReadOnlyList Children; IReadOnlyList Records; int Count }`. - - `GroupingOf(Type listed)`, cached like `ShapeOf` (`:324-333`): names resolve against - `MembersOf(listed)` (`:335-339`); validation per Defaults. - - `GroupRecords(Type listed, IEnumerable records)`: partitions - `RecordCandidates(CultRecordRef)` by value identity, reading each record's - `Document` (resolved, I10). - - `CreateInGroup(Type listed, CultInspectorRecordGroup group, out string? notice)`: - `CreateElement(listed, listed, out notice)` (`:387-398`), then `SetValue` each level; refs - via `CreateRecordRef` (`:524-529`). `ArgumentException` for a node not of `listed`'s current - grouping. - - `IsRecordCandidate(Type refType, CultStoredDocument record)`. - - `RecordRefLabel(Type refType, object? value, IEnumerable records)`: `None`, - `RecordLabel` (`:315-319`), or `Missing `. -- **Tests** in `tests/GameCult.Caching.Tests/CultInspectorModelTests.cs` (476 lines; fixtures - `:299-476`). New fixtures `GroupBase` (abstract) / `GroupLeaf : GroupBase` `[CultDocument]`, - a re-declaring type and an opting-out type; members: enum declared out of alphabetical - order, `CultRecordRef`, string, float, `[Flags]` enum, hidden int, read-only int. - No object lists (F15). Behaviours, one test each: - 1. levels nest in declared order, not slot order; - 2. a `GroupLeaf` listed under `GroupBase` groups by the base declaration (I3); - 3. nearest declaration wins; an empty declaration opts out; - 4. leaves partition the candidates over unset refs, dangling refs and undefined enum values (I2); - 5. two refs sharing one `[CultName]` give two nodes; `None` first; `Missing k` last (I4, I7); - 6. enum nodes order by value; - 7. create at depth 2, upsert into a temp single-file `CultCache`, regroup: same node id (I5); - 8. each invalid declaration (unknown, float, `[Flags]`, hidden, read-only, duplicate) gives a - notice and a flat tree, no throw (I8); - 9. `IsRecordCandidate` accepts a subtype, refuses a sibling and an empty key, and - `RecordCandidates` equals the records it accepts (I6); - 10. a base abstract property's `[CultInspectorLabel]` reaches the override's metadata (F5); - 11. **a variant groups by its resolved value**: base with `Enum=A`, variant overriding it to - `B` via `UpsertVariantAsync` and `Override`, regroup: the variant is in `B`; change the - base to `C` with the variant not overriding it, regroup: it follows to `C` (I10). -- **Verify (Yggdrasil):** - `ygg-verify.sh /f/Projects/CultLib dotnet 'dotnet test tests/GameCult.Caching.Tests -c Release'`, - then - `ygg-verify.sh /f/Projects/CultLib dotnet 'dotnet tool install -g dotnet-stryker && export PATH="$PATH:$HOME/.dotnet/tools" && cd tests/GameCult.Caching.Tests && dotnet stryker --project GameCult.Caching.csproj --since: > /tmp/s.log 2>&1; rc=$?; tail -60 /tmp/s.log; exit $rc'`. - Survivors triaged by name in the report. -- **Ledger:** model ~+170, attributes ~+15, tests ~+230; one predicate collapsed. - -### Cut 2. CultLib Studio: lower the tree, create in group, drag source, drop target (~150k tokens) - -- **Delete first:** - - `CultCacheStudioDrawers.cs:266` inline `"Missing " + key : "None"` → - `Model.RecordRefLabel(type, value, Records)` for `names[0]` when `index == 0`. - - `CultCacheStudioWindow.cs:180-185` flat `foreach` → tree drawing. -- **Window** (`CultCacheStudioWindow.cs`): - - fields (`:13-30`): `Dictionary _groupFoldouts` (ordinal), `const string RecordDragKey`; - `CloseStore` (`:318-327`) clears them. - - `DrawRecords` (`:135-189`): `GroupingOf(_selectedType)`; a `Notice` shows a warning - `HelpBox`. Draw `GroupRecords(_selectedType, _records)` recursively: foldout `Label (Count)` - indented by `Depth`; an expanded node draws children, leaf rows, then a `Create` mini - button under `Add`'s gate (`:141-146`). The root is not a foldout; `Add` stays root create. - - row: reserve the rect with `GUILayoutUtility.GetRect`, handle `MouseDrag` there first - (`PrepareStartDrag`, `SetGenericData(RecordDragKey, new CultCacheStudioRecordDrag(_model, key))`, - empty `objectReferences`, `StartDrag(label)`, `Use()`), then `GUI.Toggle(rect, ...)` (F11). - Keep the existing `` suffix logic (`:182-183`) in one place for C3 to extend. - - `AddInGroup(node)` mirrors `Add` (`:340-346`) through `Run` (`:369`); selects the key and - expands the node's id prefixes. `Add`/`Duplicate` reveal the new record's path (a - `_revealKey` resolved next frame is acceptable). -- **Drawers** (`CultCacheStudioDrawers.cs`): `internal sealed class CultCacheStudioRecordDrag - { Model; Key }`. In `DrawRecordRef` (`:254-280`), capture the `HorizontalScope` rect; on - `DragUpdated`/`DragPerform` inside it with our payload: `Copy` when `GUI.enabled`, same - `Model`, key differs, record in `Records`, and `IsRecordCandidate`; else `Rejected`. Leave - foreign drags alone. On perform: `AcceptDrag`, `next = key`, `GUI.changed = true`, `Use()`; - return through the existing `:279`. -- **README** (`src/GameCult.Unity/Assets/Caching/README.md`): grouping, create in group and - drag-to-reference after the paragraph at `:30-34`; the grouping API, `IsRecordCandidate`, - `RecordRefLabel` under `## Inspection Model` (`:39`). -- **Verify:** - - Cut 1's Yggdrasil test command still passes. - - Negative greps (each empty): - `rg -n "IsInstanceOfType" src/GameCult.Unity/Assets/Caching/Editor | rg -v "assetType.IsInstanceOfType"` (I6; `:215` is the asset-GUID sub-asset check, not candidacy); - `rg -n "\"Missing \"" src/GameCult.Unity/Assets/Caching/Editor` (I7; the union drawer's - `"None"` at `:393` is not a ref label, so grep `Missing` only); - `rg -n "SetValue|GetCustomAttribute|CultInspectorGroupBy" src/GameCult.Unity/Assets/Caching/Editor/CultCacheStudioWindow.cs` (I1); - `rg -n "EditorPrefs" src/GameCult.Unity/Assets/Caching/Editor` shows only `LastPathKey`. - - **Starfire, one job, editor closed:** the F10 compile gate, `dotnet build` of a scratch - netstandard2.1 project over the worktree's `Assets/Caching/Editor/*.cs`. 0 errors. -- **Ledger:** window ~+80, drawers ~+30, README ~+20; two inline decisions deleted. - -### Cut 3. Joint release: cultlib Unity 1.0.61, Studio 1.5.0 (after grouping and variants C3 merge) - -- **Base:** `main` with grouping Cuts 1-2 and variants C1-C3 merged; a clean worktree. -- **Files:** `unity/org.gamecult.cultlib/package.json:4` `1.0.60` → `1.0.61`; - `src/GameCult.Unity/Assets/Caching/package.json:4` `1.4.0` → `1.5.0` and `:13` dependency - `1.0.61`; `CHANGELOG.md` entries in both packages (grouping, create in group, drag to - reference; variant editing from C3); plugins via - `powershell -File scripts\build-unity-package.ps1 -UpdateTemplate` (Windows: MSVC and the - pinned MsQuic digests; its version check is at `:168-170`). -- **Tags:** `cultlib-unity-v1.0.61`, `caching-unity-v1.5.0`; no `cultmath-unity` tag. -- **Verify (Starfire, one job at a time):** - - byte check: rerun the script; `git status --porcelain unity/` is empty; - - expected diff: `GameCult.Caching.dll/.pdb` changes, and `gamecult_mesh_quic_native.dll` - changes (F16); `msquic.dll` should not (same pinned digest). Anything else stops the release; - - API present: reflect over the tracked `GameCult.Caching.dll` for - `CultInspectorGroupByAttribute`, `GroupRecords`, `CreateInGroup`, `IsRecordCandidate`, - `RecordRefLabel`, and C3's `CreateVariant`; - - native ABI: `dumpbin /exports` lists `cultmesh_quic_open`, `_state`, `_poll`, `_error`, `_close`; - - `git ls-remote --tags origin` lists both tags. - -### Cut 4. Aetheria: grouping annotations (inside variants C4's pass; blocked on Q7) - -- **Where:** the Aetheria branch and worktree Self opens for variants C4. Never - `F:\Projects\Aetheria`'s working tree. C4 owns the pin bump (`Directory.Build.props:6`, and - `Packages/manifest.json:54-55` to `#caching-unity-v1.5.0` / `#cultlib-unity-v1.0.61`; - `:56` cultmath unchanged; `packages-lock.json` follows) and the element-id sweep (F18). This - cut adds only: - - Q7's `[CultInspectorGroupBy(...)]` class attributes (recommendation B: five declarations); - - `tests/Aetheria.Shared.Tests/StudioGroupingTests.cs` (xUnit): `GroupingOf` over - `CultCacheMessagePack.CreateInspectorModel(registry)` names exactly the declared members - per annotated type with no notice; `GroupingOf(typeof(WeaponItemData))` follows Q7; every - registered document type's `GroupingOf` has a null notice. -- **Verify:** - - headless (Starfire, one job; the revision check needs `CultLibRoot` clean at the release - SHA and `CultMathRoot` clean at `6d5e209`): - `dotnet test tests\Aetheria.Shared.Tests -p:CultLibRoot= -p:CultMathRoot=`; - - Unity 6000.3.24f1 batchmode compile, editor closed: - `-batchmode -nographics -quit -projectPath -logFile `; 0 errors, - both new tags resolved. -- **Operator only, in Aetheria's Studio against a copy of `GameData/Aetheria.cc`:** - - each annotated type shows the declared levels; `GearData` includes `` rows; - - create in a node: the record lands there and is selected; - - drag a `Faction` onto a `FactionProductData.Manufacturer`: accepted; drag a gear record onto - it: rejected; - - drag a `PersonalityAttribute` onto a `DemandProfile` key that already exists: refused - through the notice; - - read-only open: every drop rejected; - - a variant (once C4 authors one, e.g. `LonginusX`) sits in its resolved `HullType` node, - and a drop into its inspector writes an override (C3), not a refusal; - - close without edits: store bytes unchanged. - -## Subtraction ledger - -Added: one attribute, two model types, five model methods, ~11 CultLib and ~3 Aetheria tests, -~110 Studio lines, five annotations. Collapsed: the candidate predicate (now one method, reused -by drop), the ref label strings, the property-inheritance miss (F5). Not added: selectors, -registries, `EditorPrefs` keys, runtime ports, packages, targets, daemons, a second release. -Build footprint: `GameCult.Caching` and its tests (Yggdrasil); the F10 compile gate, the -package script (all tracked plugins including the native bridge) and Aetheria's headless and -batchmode checks (Starfire; Windows is the target for the editor plugin and win-x64 bridge). - -## What the 2026-09-17 map had wrong as of `feeced8` - -- Cut 4 grouped `GearData` by `Manufacturer`; `ItemData.Manufacturer` no longer exists (F17). -- Q5's native-plugin drift was spent by the 1.0.60 release (F16); the Cut 3 "rebase onto - `codex/asset-guid-attribute`" note is obsolete (merged). -- Cut 4 re-pinned Aetheria on its own; after C2a it cannot, without the id sweep (F18). -- Aetheria branch `codex/cultcache-cutover`, props `:5`, manifest `:53-55`, cultmath `v0.2.3`: now - `codex/fire-control-12`, `:6`, `:54-56`, `v0.2.4` with a separate CultMath pin. -- Negative greps for `IsInstanceOfType` and `"None"` would fail on unrelated lines (`:215`, `:393`). -- Hand-applied mutations per test are retired; Stryker.NET on the diff replaces them. -- Moved anchors: `RecordCandidates` `:512-520`→`:514-522`; `_shapes` `:298`→`:296`; `RecordLabel` - `:313-317`→`:315-319`; `CreateElement` `:385-396`→`:387-398`; drawer attribute `:80`→`:81-86`; - `DrawRecordRef` `:195-221`→`:254-280`, label `:207`→`:266`; `ReplaceKey` routing - `:243-251`→`:303-309`; test fixtures `:380-459`→`:299-476`; README `:36-39`→`:30-39`; build-script - version check `:150-155`→`:168-170`. -- Worktree `F:\Projects\CultLib-studio-grouping` is now the superseded docs branch; Hands uses a - fresh one. diff --git a/docs/typescript-quic-realtime-cut.md b/docs/typescript-quic-realtime-cut.md deleted file mode 100644 index ebef2893..00000000 --- a/docs/typescript-quic-realtime-cut.md +++ /dev/null @@ -1,2771 +0,0 @@ -# TypeScript QUIC Realtime Plane Cut Map - -Date: 2026-09-16 - -Status: Imagination output for the target in -`docs/typescript-quic-realtime-target.md` (operator-accepted 2026-09-16). No -code in this document has been written. Nothing here is committed by -Imagination; the root agent commits. Q5, Q6 and Q7 were ruled the same day -(section 13, Rulings); Q5 was then re-ruled from A to C: no registry in this -campaign, registry publication parked for a later pass by choice. Cut 6, -section 5.4, the binary-resolution and dependency lines of Cut 4, and Cut 7's -ledger are remapped under C (landed 2026-09-16, same day). Q8 is ruled: -the built binaries are committed to the tree (section 11.2). No operator -question is open. **Cut 1 landed** at `e234a64` (shared verifier, tests, -C#-written vectors), `66286b9` (browser copy deleted, −143 net) and -`062a5c6` (mutation runner; twelve killed, one equivalent), then three -Soul passes and three fix batches; **closed 2026-09-16**, three residuals -landed at `c64a2da`, `6c933d0`, `fe2555d`. - -**Cut 2 landed** at `6cbc73f` (the codec, 178 lines; C#-written and -TypeScript-written frame vectors, each decoded by the other side, the C# -test reading both with the reference alone) and `ae29910` (37 entries as a -third runner target; 72 of 72 across the three targets killed, one -equivalent named). Closed 2026-09-16 after Soul's pass and one fix batch. -Hands' discrepancies, kept: the -65,535-byte identity and 64 MiB payload ceilings recorded as a build rule -plus the digest of the whole encoding rather than half a megabyte of -literal text; the Body has five refusal messages where the spec listed six -(negative length and length-sum mismatch share one); three refusals added -that C#'s type system gives free, among them **a real divergence found by -the test: `TextDecoder` deletes a leading U+FEFF where -`Encoding.UTF8.GetString` keeps it, and U+FEFF is not .NET whitespace, so -such an identity passes `Validate` and reaches the wire**, closed with -`ignoreBOM`; C# sums lengths under `checked` and TS covers the overflow -with its length refusal, unreachable from either encoder. Residual 1's -exact-equality verification could not hold as written: applying the -pre-check leaves eleven stricter-than-C# spellings, all the safe direction, -pinned by name, because exact agreement needs .NET's registered-scheme -table. The no-control-byte test caught a literal U+001F the Write tool put -into its own introducing comment. - -Two items for Self's ruling, both taken: **`npm run test:ts` and `build:ts` -have been broken since `8cb3b72`** (the scoped rename; Hands first -attributed it to `8dd5a45`, which only bumped a version, and Soul -corrected it) because `scripts/run-typescript-workspaces.mjs:9` names the -old unscoped `cultcache-ts`; one-word fix, lands in Cut 2's fix batch. -**The runner is `scripts/mutate-cultmesh.mjs`** since `65f2b66`'s batch -(renamed from `mutate-cultmesh-authority.mjs` once it carried a codec -target); every reference below that names the old path is history. - -**Soul's pass on Cut 2** (Fable; probes `probe-cs/`, `parity.mjs`, -`symmetric.mjs` and others in the session scratchpad) held byte parity in -both directions over its own thirty-nine encode specs and thirty -hand-built byte strings: identical digests, identical refusal messages, -identical U+FFFD counts on invalid UTF-8, the byte-order mark round trip, -all four digest ceilings regenerated from their build rules on both sides, -the five decode refusals in the same order, and every symmetric two-site -mutant dead. **Cut 2 does not close as promised**, on three small findings -in the fix batch: - -- **The mutant Hands called equivalent is not.** A 37-byte frame whose - identity lengths cancel a negative payload length sums to exactly 37 and - decodes to blank identities where C# refuses. The clause is right; nothing - defended it. Medium. -- **The decoded payload aliases the frame when the input is a Node - `Buffer`**, because `Buffer.prototype.slice` is a view; the test used only - a `Uint8Array`. The same trap the repo recorded for `verifyP256`. Medium - for the bridge, nil today. -- **Neither half of the frame parity runs in CI**; a C# codec change leaves - everything green. The Cut 1 scar, repeated. Medium. - -Recorded, not defects: the reference encoder writes delivery values its -own decoder refuses (a cast on the enum), where TypeScript refuses at -encode, the stricter side; an overflow near `int.MaxValue` is reachable -from hostile bytes and refused on both sides with different words; the -runner's sentinel detects only the last mutant by design, and the sidecar -repair names the mutation a dead run was inside. - -**The Cut 2 fix batch landed** (Opus) at `65f2b66` (the aggregate scripts -reach every workspace again; breakage confirmed at `8cb3b72`), `9a4c939` -(the payload copy is `new Uint8Array(bytes.subarray(…))`, because Soul's -prescribed `Uint8Array.prototype.slice.call` returns a `Buffer` from a -`Buffer` through `@@species` and fails Soul's own assertion; three crafted -negative-length frames refused; the false equivalence note gone), -`6ed0ff7` (both halves of the frame parity in CI on both OSes) and -`7a0749b` (the eleven stricter spellings named for what they are: three -backslash, two missing-authority, four host repairs, two `URL` throws; the -same slip in `isProtectedEndpoint`'s own comment fixed). 75 of 75 -mutations killed across three targets. Gap, not a workaround: `npm run -test:ts` still cannot go green on the workstation because one -`cultcache-ts` test spawns `python`, the Store alias stub here; `py -3` -has msgpack; pre-existing since `8cb3b72` and outside every cut. - -**Cut 3 landed** (Opus) at `6a091ef` (the bridge: 440 → 1,168 lines of -C++, a two-role event-queue C ABI v2 with twelve exports, the five v1 -exports kept as a Windows-only Unity shim) and `23dc093` (CMake for both -platforms, `scripts/build-quic-native.sh`, README). Host and target: -win32-x64 built and smoked on the workstation (MSVC 14.44, CMake 4.3.2); -linux-x64 built and smoked in the workstation's Docker `debian:13`, which -is the development loop and **not release-grade**; its release build is -Cut 6's Actions job. Fifteen-check FFI smoke 15 of 15 on both; the v1 gate -3 passed, 1 skipped by design; ten native mutations killed under two green -controls; exports 17 on Windows and exactly 12 on Linux with hidden -visibility; the deb digest and header sizes match the probe ledger; -manifests with SHA-256s beside every binary. Two bugs the old shape never -exercised, found by hanging tests and now mutation-pinned: the v1 -certificate pin must be attached before `ConnectionStart` (the handshake -reaches the certificate event on a worker thread at once on loopback), and -teardown must close connection handles itself because `RegistrationClose` -blocks until every child is closed. Spec discrepancies kept: `ntdll` on the -Windows link list; the deb carries no licence text, so the script copies -the committed MIT text; the deb ships no unversioned `.so` symlink, so the -script creates one; four Linux runtime libraries are load-bearing and now -in the README. Soul in flight. - -**Q9, the one fork Cut 3 hit, ruled A on 2026-09-16 (detail below).** The -pinned Windows MsQuic is the Schannel flavour, and Schannel does not -implement `QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12`: `ConfigurationLoadCredential` -returns `QUIC_STATUS_NOT_SUPPORTED`, so the provider role cannot open a -listener on Windows under it. The identical bridge DLL passes the full -smoke beside the OpenSSL 2.5.9 `msquic.dll` (SHA-256 `FEE9A664…`, -4,181,856 bytes). Linux is unaffected: Microsoft ships only the OpenSSL -build for Debian. -- **A. Pin OpenSSL on Windows.** One credential type on both platforms, - provider role works, ABI unchanged. Costs: the package URL and digest in - `build-quic-native.ps1`; the committed Windows `msquic.dll` grows from - 537 KB to 4.18 MB, so Q8's tree price becomes about 11.6 MB; the Unity - plugin's `msquic.dll` diverges until the operator's unscheduled rebuild. - The v1 client path works under either flavour. -- **B. Keep Schannel and convert PKCS12 to a certificate context via - `PFXImportCertStore`.** Keeps the pin and the Unity DLL; puts about - forty lines of Windows crypto in the shared provider path, breaking - "runtime-neutral" and the cut's own negative grep. -- **C. Providers Linux-only.** Cheapest; kills the Windows FFI smoke the - cut requires and the Windows provider lanes Cuts 4 and 5 need. -**Recommended: A. Ruled A, 2026-09-16** ("A"). The Windows pin moves to -`Microsoft.Native.Quic.MsQuic.OpenSSL` 2.5.9 in `build-quic-native.ps1` -with its digest; Q8's committed tree price is restated at about 11.6 MB; -the Unity plugin's `msquic.dll` stays Schannel until the operator's -rebuild, recorded in section 15, and the v1 client path is verified under -both flavours. The spec's "one credential type for Schannel and OpenSSL" -sentence in section 8 is withdrawn: the header declares the type and only -the OpenSSL provider implements it. *(Digest correction, Soul: `FEE9A664…` -is the NuGet zip, 19,179,817 bytes; the DLL is `c17c6581…`, 4,181,856 -bytes. Hands' report and this map's first record had the zip's digest on -the DLL.)* - -**Soul's pass on Cut 3** (Fable; `soul3-*` in the session scratchpad, -including a C consumer of the ABI that is not koffi and an ASan build of -the bridge) held the Cut 2 fixes entire, the export counts, the greps, the -clean-container Linux rebuild byte-identical to the manifest, the four -load-bearing Linux runtime libraries, the stress at 16,384 frames with -zero lost or reordered on both targets, both hang mutations dying by -timeout, and both of Q9's load-bearing claims (Schannel refuses the PKCS12 -credential with not-supported; the identical bridge passes 15 of 15 beside -the OpenSSL DLL; the v1 gate passes beside either). **Cut 3 does not -close.** Found, in a fix batch (Opus): - -- **A use-after-free between the host thread and MsQuic's worker** (high): - the id lookups drop the lock and return a raw pointer, the worker frees - the object on shutdown-complete, and the host's next send dereferences - it. One in three release runs crashes on each target under an ordinary - peer-driven stream teardown; three of three under ASan. The fix is an - object kept alive across the call, not a guard. -- **Event 7 is not one per frame send**: the kind-byte send completes as - its own event with nothing to tell it apart, six events for five frames. -- **The initiator of a shutdown never learns its connection is gone**: - MsQuic gives it only shutdown-complete, which the bridge swallows. -- **Return codes invert by platform**: `QUIC_STATUS` is a negative HRESULT - on Windows and a positive errno on POSIX, so a Linux host checking for a - negative code misses every failure; the README promised negative. -- **`runtime_close` wakes a blocked poller into freed memory**; the wake - makes the pattern look supported. Close must quiesce. -- **No host-facing header**: the struct layout and the twelve signatures - live in the `.cpp` and the spec; Soul wrote its C consumer from the spec. -- Smaller: an unbounded per-connection trace string from the v1 - diagnostics; a listener config failure leaving a dead handle in the map; - a stream emplaced after start; a partial listener open leaving an entry; - a null-payload poll consuming the event; the DLL importing the VC - runtime with the README silent. - -The Q9 pin change and the manifest's stale commit line ride in the same -batch. - -**The Cut 3 fix batch landed** (Opus; its commits are signed Opus 5, which -is what ran) at `9a01321` (`include/cultmesh_quic_native.h`, 305 lines: -the event struct with offsets static-asserted, every export, the id and -return-code conventions, the lifetime and threading rules; the koffi smoke -and Soul's C consumer are checked against it), `47aa7b6` (objects kept -alive across the call that names them: one `shared_ptr` per map entry, a -lookup returns a reference the caller holds for the whole MsQuic call, the -worker drops only the map's reference, the handle closes exactly once in -the destructor under the exchange guard, a stream owns its connection so -close order is structural; `runtime_close` marks closing, wakes pollers, -waits for `active_calls == 0`, and refuses any later call), `8c41896` (the -ABI gaps: one event 7 per frame send with `Canceled` distinct; event 4 -uniform at completion for every path, the initiator included, published -after the id stops resolving; return codes mapped negative on every -platform with `cultmesh_quic_last_status` for the raw status, thirteen v2 -exports now; a null payload with capacity refused; a stream in the map -before start; failed listeners leaving nothing) and `c729dff` (the OpenSSL -pin with both digests, `/MT` so the DLL imports no CRT, manifests with a -real commit line). Host and target: win32-x64 on the workstation, 20 of 20 -smoke checks, the C consumer's seq, cancel, stress (16,384 frames, zero -lost or reordered), race 400×20 with zero crashes, closerace 20×512, the v1 -gate 3 passed 1 skipped, 18 exports; linux-x64 in the workstation's Docker -`debian:13`, development loop only, the same set plus ASan clean on every -mode, 13 exports. 22 of 23 mutations killed under two green controls. -**L3 survived**: deleting the quiesce wait cannot be caught, because the -wake happens under the lock and every poller drains before teardown; right -by construction and by reading, unfalsifiable by this harness. Soul rules -whether that stands or a dev-only probe asserts the invariant. Open after -the batch: the Unity plugin's `msquic.dll` is still Schannel until the -package build runs; the Schannel dependency cache is orphaned; the v1 -return-code values changed while the zero-versus-nonzero contract held. -Bridge 302,080 bytes / `f4c5f644…` (win32-x64, static CRT), 108,128 / -`61d5b96e…` (linux-x64). - -**Soul's second pass on the fix batch** (Fable; `soul3b-*` in the session -scratchpad, its C consumer extended with close, re-entry and completion-race -scenarios, ThreadSanitizer and AddressSanitizer on linux-x64 in the -workstation's Docker `debian:13`). Held: the lifetime model, race 400×20 with -zero crashes on both targets and ASan clean on every mode; 16,384 of 16,384 -frames under stress with none lost or reordered; one completion event per -frame with cancellation distinct; the completion event uniform at the end of -every connection, with its mutant killed on both targets; negative return -codes everywhere; the null-payload refusal; the header compiling clean as -both C and C++ under maximum warnings on two compilers with no padding and -no implicit conversion; no C runtime import; the OpenSSL pin re-downloaded -and both digests equal; the version-one gate green beside either flavour of -the library. **The cut does not close at `c729dff`.** Findings: - -- **The quiesce is one line short, and it is a use-after-free.** `~CallScope` - decrements the call count under the lock, releases it, and only then - notifies. The closer's predicate is already true, so if that last poller is - preempted in between, the runtime is destroyed and the notify lands on a - freed condition variable. ThreadSanitizer caught it on the **unmutated** - bridge, so the previous batch's model was right in shape and wrong by one - line. Confirmed, medium, and the blocker. -- **The header oversells the return code.** It is portably negative, not - portably meaningful: the same failure is −12032 on Windows and −1126 on - Linux, and the Windows mask collides two distinct statuses onto −1002. The - sign is the contract; the magnitude is diagnostic. Low, wording. -- **The previous batch's own README claims a rebuild reproduces the committed - Unity plugin.** It does not: that plugin is the older Schannel build at - 40,448 bytes with a C runtime import, against 302,080 bytes without one - today. Low, and exactly the stale-artifact trap. The current build does - reproduce itself. -- **A Windows status sign-extends in diagnostics**, printing sixteen hex - digits. Trivial. - -**L3 is ruled: it becomes killable, it is not accepted as unfalsifiable.** -Soul established the survival was a harness limit rather than a proof of -correctness. Under AddressSanitizer with pollers blocked mid-copy of large -frames, deleting the quiesce wait hit use-after-free four times in -forty-eight attempts, while the release scenario never observed it. So a -dev-only assertion now aborts when the call count is non-zero after the -quiesce block, which fires deterministically with enough blocked pollers and -makes the mutation die by the existing scenario; the sanitizer run stays as -the second check. That assertion does not cover the defect above, where the -count has already reached zero. **Two mutations are honest only on the -sanitizer target:** the pop-then-copy one and the closed-handle one survive -on Windows release and kill three times of three under AddressSanitizer, so -the entries table must say which target each is honest on. A mutation whose -kill depends on the target is not killed until it runs there. - -**The second fix batch landed** (Opus) at `a4753f4` (the notify moves inside -the gate), `dc9e12c` (a Windows status stops sign-extending in diagnostics), -`53d5929` (the header says the return code is portably negative, not portably -meaningful), `19d8d5c` (the readme says the committed Unity plugin is the -older build), `f4186e7` (a committed scenario runner for the runtime -lifetime) and `180917d` (four native entries, each naming the target it is -honest on). - -**The discovery that outweighed the fix: there was no committed native -harness at all.** Every native mutation kill this cut had reported came from -consumers and scenarios that lived in agent scratchpads and no longer exist. -The runner at the previous head carried three package targets and nothing -touching the bridge, and two entries could not even be re-marked because -their definitions were gone. Hands built what the brief had assumed already -existed. - -**Soul's third pass, 2026-09-17** (Fable). Held: the lifetime fix on both -targets, the reverted notify killed three of three by the thread sanitizer -and invisible to the address sanitizer, so its target marking is right; the -assertion killing the deleted wait deterministically on both targets and -absent from both shipped libraries and a fresh release build; two fresh -release builds byte-identical to the committed artifact; the return-code -numbers recomputed from the pinned headers; byte-exact restore on both hosts. -**Cut 3 still does not close**, and the reason is that the harness defending -the fix is weaker than the fix: - -- **The committed Linux path does not run as committed.** The sanitizer - configuration dies before the scenario starts, on the kernel's - address-space randomisation, and the runner swallows the child's standard - error, so a future agent sees a red control and no diagnosis. Soul reached - four of four kills only by disabling randomisation and relaxing the - container's seccomp profile, neither of which any committed file mentions. - The image came from a definition that is not in the repository, and the - documented development recipe cannot run the runner at all, since it - installs the C++ toolchain but not the JavaScript runtime. High for the - claim that the Linux kills are rerunnable. -- **The scenario does not test the rule it exists for.** Deleting the call - guard from the polling entry point, so host calls are not counted at all, - survived nine runs of nine across every configuration. The harness pins the - order of the count and the notify, not that anything is counted. -- **The scenario passes vacuously when nothing parks.** Inverting the timeout - comparison makes every poller return before the close begins, and the - scenario is green on all six configurations. -- **The bounded-wait loosening is pinned by a constant, not by the rule.** At - one millisecond it dies with as few as two calls outstanding; at fifty - milliseconds it survives on both targets. A bounded wait is the wrong - contract at any bound. -- **A skipped entry exits zero** with no closing summary, so a gate reads a - host that killed nothing as green. -- **The header contradicts itself**, forbidding a call that begins after - close starts and separately promising such a poll is refused, when that - refusal path reads freed memory after teardown. - -**Two rules are defended by nothing committed**: popping before copying, and -a handle closed under a live call. Both were previously reported killed on -the sanitizer target only, and neither has a definition left. The third fix -batch is told to give each a real entry or to say plainly that the rule is -undefended, because an honest gap beats a fabricated kill. - -**The third fix batch landed** at `62e53df` (the development seam and a -hold-then-close scenario), `e4e09a0` (four entries, the bounded wait at 50 ms, -an exit status on skips, the child's stderr on a red control, re-execution -with randomisation disabled), `12c8bfc` (the header's self-contradiction) and -`4407098` (the committed container, the Ninja generator, the README recipe -with the seccomp requirement). - -**Soul's fourth pass, 2026-09-17** (Fable, banked mid-pass when that model ran -out, resumed on Opus from the bank; the handoff paid for itself by carrying a -live harness process, a dirty tree and two leads the successor opened with). -**The verdict splits, so it is given twice.** - -*The infrastructure question is now yes.* The committed container built with no -cache, then the literal README run line, gives eight killed, none surviving, -none skipped, exit zero on Linux; Windows gives six killed, two honestly -skipped, and a real exit code. A stranger can rerun both targets today. The -seccomp requirement is genuinely load-bearing and the randomisation -re-execution genuinely runs. The development seam is absent from a release -build: thirteen production symbols, no debug symbols, no assertion strings, -and every executable section byte-identical between pre- and post-change -release builds. The predecessor's harness had already exited, restoring the -tree byte-exactly, so the restore path holds. - -*The rules question is still no.* Three of the four rules in the native table -are pinned. The fourth is not, and the cause is structural rather than a bad -constant: - -- **F1, confirmed, high: the hold sits after the wait whose duration is the - rule**, so every timeout mutant lands in a blind spot by construction. - A hard-coded 100 ms survives Windows and Linux with assertions, and dies - under the thread sanitizer only because its slowdown trips an unrelated - condition. **A hard-coded 2000 ms survives the entire matrix on both - targets.** A host asking for five seconds silently gets two and every - consumer's poll loop spins at two and a half times the rate it asked for, - forever. The committed one-millisecond entry dies only because one is less - than the scenario's fifty-millisecond settle: constant pinning constant. -- **F2, confirmed, high: the pop-before-copy gap was wrong about itself.** - A client opening to a closed loopback port reaches that path in about a - millisecond with no listener, credential or connection, because the failure - path always publishes a non-empty reason; fifteen lines. Moving the pop - before the copy then crashes an ordinary optimised build twice out of two, - while both committed scenarios stay green on that same binary. -- **F3, confirmed, medium: the refusal during a close has no entry** and - survives being neutered, though the header promises it. A call entering - behind the closer increments the in-flight count behind the wait, which can - then never reach zero. -- F4, low: the seam misdescribes itself, claiming the held call touches - nothing afterwards when its scope destructor takes the gate, decrements and - notifies. The safety comes from the assertion, not the hold. -- F5, low: the bounded wait at 600 ms survives, the same shape as F1 and - honestly labelled as a limit by Hands. -- Also: "the close wakes every blocked poll" **is** defended by committed code - but has no entry, so the table understates coverage in one place while - overstating it in another. - -**Two scars from the pass itself.** An export made with `git archive` carried -1,459 inserted carriage returns, poisoning any byte comparison built on it; -raw blobs verified against the worktree hash are the only safe source. And the -51 bytes that differ between pre- and post-change release builds are accounted -for: 48 are four copies of the reproducibility content hash, and the last -three sit in exception metadata outside every executable section and **could -not be fully accounted for**, which Soul said rather than rounding away. The -same source rebuilt at the same path twice differs by zero bytes; built -elsewhere it differs by 69, so the figure is only meaningful at a shared path. - -**One undocumented step remains** in an otherwise clean path: the README -hardcodes the container mount, so a newcomer on another checkout must edit the -line. - -**The fourth fix batch landed** at `25d7de2` (the container mount taken from -the running checkout rather than one machine's path) and `a937a0b` (the -scenarios, the seam correction and the new entries). - -**Hands rejected Self's diagnosis and gave a better one.** Self had said the -blind spot was that the hold sat after the wait whose duration was the rule. -The real cause is that **no committed scenario ever let a timeout finish a -poll**: both ended their waits with a close, so the timeout governed nothing -either could observe. The fix is therefore a scenario rather than a seam -recording. `polltimeout` polls an idle runtime and measures elapsed against -what was asked, **at two values with non-overlapping bands** — 200 ms in -[180,500] and 900 ms in [880,1200] — because one value cannot tell a bridge -honouring the host's timeout from one waiting on a constant that happens to -equal it, and no constant lies in both bands. No new export, no header change, -and it works in the shipped shape. - -All three constants now die by that scenario: 100 ms, 600 ms and 2000 ms. The -600 ms case survives both older scenarios and dies to the new one, which is -the demonstration of what the old ones could not see; Hands kept it as a hand -check rather than carrying a third constant in the table. - -Also landed: Soul's closed-port probe committed as `payloadfit`, reaching the -two-phase poll in about a millisecond, where the pop-before-copy mutant -segfaults an optimised Windows build with no sanitizer, five runs of five; an -entry for the refusal of a call racing a close; an entry for the wake, which -the table had been silently failing to claim; and the seam's self-description -corrected, since a held call does leave its scope, which takes the gate, -decrements and notifies. Release shape unchanged on both targets, with no -debug exports and no assertion strings. - -**Tables now: Linux 18 killed, none surviving, none skipped, exit 0. Windows -16 killed, none surviving, two honestly skipped, exit 2.** Controls green on -both. - -**A declared equivalence, handed to Soul rather than substituted.** Changing -the close's wake-all to a wake-one survives, and Hands argues it is equivalent -rather than uncovered, because the first poller out calls wake-all under the -gate from its own scope destructor. It recorded the equivalence beside the -entry and shipped the queue-conditional wake as the loosening instead. This -campaign's fourth encounter with that defect shape, and the first where the -answer was an argued equivalence rather than a swap. - -Named limits: the 600 ms mutant lives only in the report; `payloadfit` and -`polltimeout` run only in the assertion configuration, so the pop-before-copy -kill rests on an unsanitized crash and an exit code rather than an -address-sanitizer configuration the harness still lacks. **Soul's fifth pass, 2026-09-17** (Opus). Both targets reproduced end to end -from a fresh clone at a different path. **Cut 3 still does not close, and for -the same underlying reason in a third costume: the scenario proves the wait is -not a constant, not that it is the host's.** - -- **F1, confirmed, high: an expression defeats the two-band argument.** No - constant sits in both bands, which is true and is not the rule. Any mapping - that is identity at 200 and 900 passes for free, and the late tolerance is a - flat 300 ms. Three mutants, each run through all five Windows scenarios, all - **survived all five**: clamping the wait to at most a second, adding 150 ms, - and scaling by six fifths. **The clamp is the one that matters**, because its - failure is verbatim the bug this batch claims to fix — a host asking for five - seconds gets one, forever, with nothing reporting it — and "cap the wait so - shutdown gets noticed" is the most ordinary spelling that line will ever be - given. The close is cheap: raise the long probe above any plausible ceiling, - which kills the clamp and the scale, and make the tolerance proportional - rather than flat, which kills the offset. -- **F2, confirmed, medium: a Windows clone cannot run the documented Linux - path at all.** `.gitattributes:2` is `* text=auto` with no rule for shell - scripts, so a default Windows clone writes the build script with carriage - returns and the container dies in under a second complaining about the - interpreter line. Soul hit it from a clean clone before anything else ran. - The mount fix works; this is a second, independent blocker on the same - documented path, and it fires for the likeliest newcomer. One line repairs - it. -- **F3, confirmed, low: the only non-comment source change in the range is - pinned by nothing.** Reverting the hold's new guard survived all five - scenarios, because the timeout scenario never arms the hold and the other two - never let a timeout expire, so nothing is ever in both states at once. The - seam folds away in release, so nothing shipped is at risk; it is the - recurring shape again. - -**The declared equivalence holds, and its stated reason was the weaker half.** -Narrowing the close's wake to one waiter is genuinely equivalent, reproduced. -But the equivalence rests on two premises together: the closing flag is set -permanently under the gate before the notify and appears in every waiter's -predicate, so after a close begins no poller can block at all; and each exiting -call's own destructor takes the gate, decrements and wakes everyone, cascading. -Soul then narrowed **both** wakes, which also survived and **is not equivalent -by any argument**, since a notify consumed by the closer stalls the chain. It -passes on wait-queue ordering alone. The premises belong beside the entry so -the claim is checkable rather than assertable. - -**Held:** Linux 18 killed and Windows 16 with two honest skips, both -reproduced; 600 ms dying to the new scenario and surviving the older two; -the closed-port probe reaching the two-phase poll and both pop-before-copy -entries dying on both targets; the release shape clean on both, with the new -local folding away. **The red-control path proved itself unasked** — a run -from a deep temporary path failed MSBuild's file tracker, and the harness -reported a red control with the child's output rather than banking eighteen -kills it had not earned. - -**Two record corrections.** The source digest quoted in the previous report is -checkout-dependent, because line-ending conversion changes it; Soul's clone -restored to a different one. It is not a portable identity. And the Windows -harness needs a short checkout path or the control fails on the file tracker, -which belongs where a newcomer meets it. **Fifth fix batch in Hands.** - -**The fifth fix batch landed** (Opus), `ca6c0f5..244154e`. F2: `*.sh text -eol=lf` in `.gitattributes` (`ca6c0f5`); the container line no longer picks a -shell's continuation, the Dockerfile's recipe mounts the running checkout, and -the win32-x64 short-path requirement is stated where a newcomer meets it -(`c177533`). F1: the long probe is 5000 ms and the late tolerance is -`60 + timeout/8` rather than a flat 300, which kills the clamp and the scale on -both checks and the offset on the short one; the clamp is its own entry. Stated -limit, in source beside the tolerance: **a scaling smaller than an eighth -survives** (`c682619`). F3: `holdtimeout` puts a call in both states; the -revert and the reordered-conditions loosening both die there at about 800 ms -and on nothing else (`5ab4c62`). The single-waiter equivalence now states both -premises beside the entry, and narrowing both wakes is recorded as **not yet -reached**, with why a scenario cannot force it while the first premise holds -(`b985f07`). The restore digest is printed as a restore check, not an identity -(`244154e`). Hands' numbers: win32-x64 19 killed, 2 honest skips; linux-x64 21 -killed. **Soul's sixth pass dispatched 2026-09-22** (Opus). - -**Soul's sixth pass, 2026-09-22** (Opus). Hands' table reproduced exactly from -fresh `autocrlf=true` clones: win32-x64 19 killed, 2 skips; linux-x64 21 -killed; controls green. **Cut 3 still does not close.** Every scenario so far -has a single-threaded host. - -- **N1, confirmed, medium: the wait's predicate is pinned by nothing.** Dropping - it (`wait_for(lock, ms(t)) == no_timeout`, `cultmesh_quic_native.cpp:1179-1180`) - survived the whole matrix on both targets. At the bridge, a second host thread - calling `cultmesh_quic_last_error` every 20 ms made an idle `poll(1000)` return - after 0 and 20 ms, where the real bridge stays 1000. Every `CallScope` - destructor wakes all waiters (`:286`), so a host with a poll thread and a send - thread spins at the rate of its other calls. The rule "a poll with nothing to - deliver stays for its timeout" is pinned only for a host with one thread. -- **N2, confirmed, low-medium: the stated limit understates what survives.** - Survived on both targets: `min(t,5000)`, `min(t,4990)`, `t*11/10`, `t+70`. - `max(t,220)` survived on Linux and died on Windows. `max(t,250)` and `t+80` - die only on `holdtimeout`'s 150 ms probe, by margins of 22 and 2 ms, so those - kills depend on timing. "5000 is above any plausible ceiling" is wrong, - because 5000 is itself a round ceiling, and no probe can see a floor under - about 60 ms. Either add a small-timeout probe and a probe above 5000, or state - the full limit: offsets to about 75 ms, floors to about 220 ms, and clamps at - or above about 4980 ms. -- **N3, confirmed, low-medium: the LF fix does not reach an existing clone.** - A clone made at `367c9bc` and moved to `244154e` keeps the CRLF script, since - the blob did not change. Its status is clean and it still dies on `bash\r`. - Nothing tells an existing clone to check its `*.sh` out again. -- **N4, confirmed, low (development seam): no hold mutant is a function of the - input.** `(woken || timeout_ms > 1000) && HELD` survived on both targets. - Both of Hands' hold entries only rearrange the guard's syntax. - -**Held:** F2 from a fresh clone, covering every file the container runs or -parses. F3's revert and its loosening, with only `holdtimeout` failing under the -revert. The clamp entry. Both equivalence premises, checked against source, with -"narrow both wakes" recorded as not yet reached. Restores verified by hash -against `checkout-index`. Sidecar repair after a mid-mutation `taskkill`. -`polltimeout` and `holdtimeout` stayed green for five rounds under 16 burners on -8 CPUs. **Not run:** a forced red control, and Windows under a CPU burner. -**All four go to Hands as the sixth fix batch.** - -**The sixth fix batch landed** (Opus), `b3d9cf7..ff72f16`. Details: - -- **N3 (`b3d9cf7`):** the README gives an existing clone a one-line repair beside - the container path. It is `git rm --cached -q scripts/build-quic-native.sh; - git checkout HEAD -- scripts/build-quic-native.sh`. A plain checkout keeps the - CR. The line was verified on clones made at `367c9bc` from Git Bash and from - PowerShell 5.1. -- **N2 (`37967e8`):** the timeout probes are 15, 200 and 7300 ms. The 15 ms - probe takes the fastest of ten tries, and every try is still checked for an - early return. There are new entries for a round clamp, a floor and an - offset. The limits measured on both targets are now written in source: - - `t+25` survives and `t+40` dies; - - `max(t,40)` survives and `max(t,50)` dies; - - `t*106/100` survives and `t*108/100` dies; - - `min(t,7285)` survives and `min(t,7275)` dies; - - any shortening up to 20 ms survives. - - The "above any plausible ceiling" claim is deleted. -- **N1 (`4ffa4c9`):** `pollbusy` runs a second host thread that calls into the - bridge while a poll is idle. Three entries sit on it: the revert, "reads - what woke it", and "each wake restarts the whole timeout". All three die on - `pollbusy` on both targets. -- **N4 (`ff72f16`):** `holdtimeout` makes a second held poll at 1300 ms. The - input-derived hold mutant dies there and nowhere else. -- **Recorded as not yet reached:** the loosening that checks only `closing`. - It breaks "an arriving event ends the wait early", a promise no scenario - measures. - -Hands' numbers: - -| Target | Killed | Survived | Skipped | Control | -|---|---|---|---|---| -| win32-x64 | 26 | 0 | 2 | green | -| linux-x64 | 28 | 0 | 0 | green | - -Under 16 burners on 8 CPUs, 15 of 15 rounds passed on each target. The worst -single poll was 15 ms late on Windows and 41 ms on Linux. - -**The batch added one mechanism nobody specified. Self accepted it, 2026-09-22.** -On Windows the timed scenarios raise their own process priority. Without that, -Windows under load put polls up to 127 ms late. The unmodified bridge then -failed even the pre-batch tolerance: the 150 ms hold probe came back 100–115 ms -late against 78 ms allowed. The only alternative was a flat allowance of about -150 ms, which would readmit the offsets and floors this batch exists to kill. -The priority change is test-fixture only, needs no admin rights, and changes -nothing in the bridge. Accepted, and handed to Soul to attack. -**Soul's seventh pass dispatched** (Opus). - -**Soul's seventh pass, 2026-09-22** (Opus). Reproduced from a fresh clone: - -| Target | Killed | Survived | Skipped | Control | -|---|---|---|---|---| -| win32-x64 | 26 | 0 | 2 | green | -| linux-x64 | 28 | 0 | 0 | green | - -Exit 2 on win32 is by design: it means entries were skipped -(`mutate-cultmesh.mjs:1192`). A forced red control was reported red, and the -harness ran nothing after it. Restores matched `checkout-index` by hash. N3 -holds from both shells. **The priority raise is sound.** It is scoped to the -process, which exits after each scenario, and it cannot hide a lock held -across a sleep, because every thread in the process is raised equally. -**Cut 3 still does not close.** - -- **S1, medium: N1 is not closed.** Two predicate mutants survive the full - matrix on both targets: - - **K1**, `|| ++wakes > 64`. Under a thread calling in a yield loop, an idle - `poll(1000)` returns after 0–5 ms. - - **K2**, `|| !runtime->error.empty()`. After one refused call, every later - idle poll returns at 0 ms. - - `pollbusy` covers one call kind, at one pace, on a runtime with no error - recorded. -- **S2, medium: the 15 ms probe has no early check.** The check is - `elapsed < 15 - 20`, which cannot fail. Both `t<50 ? 0 : t` and `t/16*16` - survive. -- **S3, low-medium: more derived waits survive.** Rounding up to a 40 ms - quantum survives. So does any fault that only shows after a runtime's 12th - poll, because no scenario polls a runtime more than 12 times. -- **S4, low: two stated boundaries depend on timing on Windows.** `t+25` died - in one of two repetitions. `min(t,7275)` survived in one of two. -- **S5, low:** the hold guard `timeout_ms > 1500` survives. The stated limit - should put the ceiling at 1300. - -**Self's ruling, 2026-09-22: change the method, not the probes.** This rule has -now taken seven passes. Each fix batch pinned the functions the previous Soul -named, and the next Soul found another function that equals the identity at -every probe point. A rule about the arithmetic of a derived wait cannot -converge under wall-clock observation from outside, because there is always -another function that matches at the probes. The skill already says it: put -the observation where the rule is decided. - -- **The wait.** A dev-only seam, of the same kind as the existing hold seam - and folded away in release, records the timeout the bridge actually hands to - its condition wait on every poll. A scenario asserts that it equals the - host's argument **exactly**: - - over a spread of values: 0, 1, 15, 16, 39, 40, 999, 1000, 1001, 7300, - `INT32_MAX`, and the bridge's documented maximum if it has one; - - on polls well past the 12th on a single runtime. - - Every clamp, floor, round, scale, offset and later-poll mutant then dies by - equality, deterministically, on every host, with no timing tolerance. The - wall-clock scenarios stay as proof that the recorded wait is actually waited, - with **generous** margins. The wide boundary table goes: those limits existed - only because the observation was indirect. Stated limits that are no longer - true are deleted, not kept as history in source. -- **The predicate.** A `pollhammer` scenario runs one host thread that calls - every entry point which touches the gate, in a yield loop, while another - thread holds an idle poll. It runs once on a clean runtime and once after a - refused call has recorded an error. The poll must stay for its timeout, - within a generous margin. K1, K2 and a "returns on any wake" revert must die - there. -- **The seam itself** gets a revert entry and a loosening entry: a seam that - records the argument instead of the computed wait must die. The release shape - must still fold it away. - -To Hands (Sonnet) as the seventh fix batch. - -**The seventh fix batch landed** (Sonnet), `66830e9` and `b8fad13`. - -What was added: - -- **`waitseam`** checks the wait by equality. A dev-only seam, gated like the - hold seam and folded away in release, records the timeout the bridge hands - its condition wait. The scenario asserts it equals the host's argument for - 0 to `INT32_MAX` and over 40 polls on a single runtime. For - `timeout_ms <= 0` the bridge never reaches the wait, so the scenario asserts - the seam was left untouched. That is also what kills the loosening "records - unconditionally". The bridge documents no maximum below `INT32_MAX`. -- **`pollhammer`** covers the predicate. It runs every gate-touching entry - point in a yield loop, both on a clean runtime and after a recorded error. - -What was removed: - -- the fastest-of-ten mechanism; -- the tight tolerances, replaced by one generous 800 ms margin; -- the stated-limits table; -- **the Windows priority raise.** - -Which scenario kills which mutant: - -- K1, K2 and the "returns on any wake" revert die on `pollhammer`. -- Every derived wait from passes 5 to 7 dies on `waitseam`. That includes the - quantum rounds, the small-timeout zero, doubling after the 12th poll, - `t+25` and `min(t,7275)`. All of them are now deterministic. -- S5's `>1500` hold guard dies on `holdtimeout`, with a probe at 1600 ms. -- The seam's revert and loosening die on `waitseam`. - -Harness results, with restores matching `checkout-index`: - -| Target | Killed | Survived | Skipped | Control | -|---|---|---|---|---| -| win32-x64 | 39 | 0 | 2 | green | -| linux-x64 | 41 | 0 | 0 | green | - -Stress: 5 rounds with 16 burners on each target, all green. Worst overshoot -was 325 ms on Windows and 26 ms on Linux. - -**Scar:** the stress cleanup used `taskkill /IM node.exe /T`. That killed every -Node process on the shared host. The rule now in the Eureka skill is to kill -by PID. **Soul's eighth pass dispatched** (Opus). - -**Soul's eighth pass, 2026-09-22** (Opus). Hands' numbers reproduced: 39 killed -on Windows and 41 on Linux. Restores matched `checkout-index`. A forced red -control was reported red. The seam records the same evaluation that the wait -receives, and it folds out of release: there are no debug exports, and the -release macro is plain `(timeout_ms)`. The wall-clock layer is not vacuous. It -kills every shortening, and on `pollhammer` it kills K1, K2 and Soul's new P2 -and P3. **Cut 3 still does not close.** The method moved the gaps outward. - -- **F1, medium: nothing runs the timeout rule against the release build.** - The only configuration without asserts runs `closerace` alone, and no CI - builds the bridge. The seam macro creates a release-only site at `:108`. - Mutant R1 changes the `#else` to `((timeout_ms)/10)` and survives by - construction. Run against the release build, `polltimeout`, `pollbusy` and - `pollhammer` each kill it. -- **F2, medium: the seam records the integer, not the duration handed to - `wait_for`** (`:1201-1202`). Each of these survives on both targets: - - `ms(RECORD(t)) + 600ms`; - - `max(ms(RECORD(t)), 500ms)`, which turns a 15 ms realtime poll into - 500 ms; - - a 1/909 duration ratio. - - Only lengthening survives, since the timed layer's early tolerance kills - any shortening. -- **F3, medium: the predicate is covered only on a runtime with no live - objects.** `|| !runtime->connections.empty()` survives on both targets. With - one open connection, an idle `poll(1000)` returns in 0 ms, so any host with a - connection busy-spins. -- **F4, low-medium: a zero-timeout poll is never timed.** `sleep_for(500ms)` - on `timeout_ms == 0` survives, as does a 300 ms spin. A game loop that polls - with 0 every frame would stall. No negative timeout is probed, and -1 would - collide with the seam's sentinel value. -- **F5, plausible, low:** `closerace` goes red under load on Windows in 4 of 5 - rounds. It is starved of CPU, not the bridge. It fails loud, but it makes - the control flaky. -- **F6, low:** stale prose: the 1300 ms history at `mutate-cultmesh.mjs:763`, - a scenario list missing `pollhammer`, and a header §7 intro that still says - "quiesce only". - -**Self's rulings, 2026-09-22:** - -1. **F1.** The harness gains a plain **release** configuration on both - targets. It runs `polltimeout`, `pollbusy`, `pollhammer` and the new - zero-timeout check against the release library, and R1 goes in as an - entry. The release build is the thing that ships, so a rule the release - build never runs is not pinned. -2. **F2.** The seam wraps **the whole argument to `wait_for`**, meaning the - duration expression. It records that duration's count, and `waitseam` - asserts it equals `milliseconds(host argument)`. W1, W2 and W3 go in as - entries. -3. **F3.** `pollhammer` also runs against a runtime that holds live objects: - an open connection to an unroutable address, plus a listener and a stream - where the fixture can make them. P1 goes in as an entry. -4. **F4.** Any `timeout_ms <= 0` returns within a small bound, timed with a - generous margin. A negative timeout is probed. The seam's sentinel moves to - a value that cannot collide, or becomes a separate "recorded" flag. Z1 and - Z2 go in as entries. -5. **F5.** `closerace`'s fixture gets whatever it needs to survive - starvation, such as barriers or longer windows, without weakening what it - checks. Prove it with 5 rounds under 16 burners on Windows. -6. **F6.** Fix the prose. - -**Superseded the same day, 2026-09-22, by the operator's retirement of the -mutation harness.** The operator's words: *"The manual mutation testing turned -out to be a terrible idea, lots of guarding the shape of the code instead of -the behavior. Better to have nothing than a harness that punishes -refactoring."* `scripts/mutate-cultmesh.mjs` and every committed suite are -deleted, with no fallback. Four of the six rulings above named harness entries -(R1, W1–W3, P1, Z1, Z2); those clauses are dead text. What each ruling -protected is not: - -1. **F1 stands as behaviour.** The scenarios gain a **release** configuration - on both targets, run against the release library. The release build is the - thing that ships, so a rule the release build never runs is not pinned. - Without the harness there is no R1 entry; the release path is proven by the - scenarios themselves going red when the seam's `#else` shortens the wait, - which Soul checks by hand on a scratch copy. -2. **F2 stands.** The seam wraps the whole argument to `wait_for` — the - duration expression — and `waitseam` asserts it equals - `milliseconds(host argument)`. The assertion is the pin; W1–W3 are Soul's - hand probes, not committed entries. -3. **F3 stands.** `pollhammer` also runs against a runtime holding live - objects: an open connection to an unroutable address, plus a listener and a - stream where the fixture can make them. -4. **F4 stands.** Any `timeout_ms <= 0` returns within a small bound, timed - with a generous margin. A negative timeout is probed. The seam's sentinel - moves to a value that cannot collide, or becomes a separate recorded flag. -5. **F5 stands**, and its 5 rounds under 16 burners run **on Yggdrasil**. The - burners that motivated this ruling are what froze the operator's - workstation on 2026-09-22; no CPU burner runs on Starfire again. -6. **F6 widens.** The prose fix now includes removing every reference to the - deleted harness, not only the stale 1300 ms history and the scenario list. - -**There is no mutation evidence for the bridge and there will not be one -committed.** It is C++, and no ecosystem mutation tool is wired here. The -bridge's rules are pinned by behavioural scenarios at the layer that decides -them; a mutant is a thing Soul tries by hand on a scratch copy and throws away. - -**The eighth fix batch landed** (Sonnet) at `5646ff7`, before the retirement, -and the harness deletion followed at `796433f`. Both are on -`hands/cultmath-erf`, not yet on `main`. What landed: - -- the seam wraps the whole duration handed to `wait_for`, and its "unset" - sentinel became a separate `debug_wait_recorded` flag, so a recorded `-1` - cannot read as nothing recorded; -- `pollhammer` runs against a runtime holding a live connection to an - unroutable address (RFC 5737 TEST-NET-1), a stream on it, and a real - never-connected listener; -- a `zerotimeout` scenario pins that `timeout_ms <= 0` returns within 50 ms, - probing 0, -1 and `INT32_MIN`; -- `closerace`'s settle waits for `debug_peak_calls` to reach the poller count - instead of sleeping a guessed duration; -- `kGenerousLateToleranceMs` narrows from 800 ms to 400 ms, so the wall-clock - layer catches arithmetic applied outside the seam's own argument — - `waitseam`'s equality check structurally cannot see that. - -The release configuration and the seven mutation entries (R1, W1–W3, P1, -Z1–Z2) landed **inside the harness**, and went out with it two commits later. -The scenario runner and every seam survived untouched: the README and the dev -Dockerfile now document building with `-DCULTMESH_QUIC_BUILD_TESTS=ON --DCULTMESH_QUIC_DEBUG_ASSERTS=ON` and running each scenario as a direct -argument to the binary. **The release configuration is therefore owed again as -a plain build, not as a harness target**, and R1's substance — that the -release macro is unexercised — is a Soul hand probe now. - -**The Linux leg ran on Yggdrasil, 2026-09-22** (Sonnet), against -`hands/cultmath-erf` HEAD, in an image built from the committed -`scripts/quic-native-linux-dev.Dockerfile` (pinned `debian:13`, tagged by -content hash `cultlib-quic-native-dev:13d7fbd109fc`). No repo change was -needed and none was made. - -- **Asserts build, all ten scenarios pass**, 20 rounds each: `closerace`, - `holdclose`, `holdtimeout`, `polltimeout`, `pollbusy`, `pollhammer`, - `zerotimeout`, `payloadfit`, `latecall`, `waitseam` (11 probes, 40 repeated - polls on one runtime). -- **Release build, asserts off, all four required scenarios pass**: - `polltimeout`, `pollbusy`, `pollhammer`, `zerotimeout`. -- Worst overshoot anywhere was 4 ms, against `kGenerousLateToleranceMs` of - 400 ms. **F1 is closed on Linux**: the build that ships now runs the timeout - rule. - -**A defect in the README's own worked example, found by running it.** The -example builds the test binary and runs it directly, and every scenario dies -with `libmsquic.so.2: cannot open shared object file`. Both the bridge and the -test executable carry `INSTALL_RPATH "$ORIGIN"` and expect the MsQuic runtime -beside them in `bin/`, but nothing puts it there for a test build — only -`build-quic-native.sh`'s packaged output directory gets that copy. Hands -worked around it with a `cp` after each build and correctly did not treat it -as a bridge defect. **This is the documented path, written in `796433f` when -the harness was deleted, and it has never worked.** A documented path that -fails on first use is worse than no documentation: it was published in the -same commit that removed the working one. - -**The README's worked example was broken twice, and fixed at `5533c34`** -(Sonnet, on `hands/cultmath-erf`). - -- The loader failure above, fixed in its owner: a `POST_BUILD` step on the - test target copies `libmsquic.so.2` beside the built binaries. CMake already - receives `MSQUIC_LIB_DIR` as a required argument on Linux, so no new input, - option or script was invented — the knowledge it already had now acts - instead of sitting in prose. The `$ORIGIN` rpath is untouched. -- **A second, independent break that fires first.** The example passed - `-DMSQUIC_INCLUDE_DIR` and `-DMSQUIC_LIB_DIR` as relative paths. CMake - resolves a relative cache path against the `CMakeLists.txt` that consumes - it, not the directory `cmake` ran in, so the build failed on a missing - `msquic.h` **before the loader problem was ever reachable**. Fixed to - absolute paths with a paragraph saying why. - -So the documented path failed at its first command, not its last. It was -published in `796433f` — the commit that deleted the working path — and -nobody ran it. **The check that would have caught this is running the -documentation, which is what found it now.** Verified on Yggdrasil by -executing the README's command block literally, with no extra step: -`polltimeout` and `pollbusy` both pass, 20 rounds each. - -Structural delta: one `add_custom_command`, four lines, in the test target's -build graph. No new files, scripts, options or targets. - -**The Windows leg ran, 2026-09-22** (Sonnet), and found the same class of -defect as Linux in a far worse form. Committed at `f3aae70`. - -**The scenarios were passing against the wrong MsQuic.** The bridge imports -`msquic.dll` by name. Neither `build-quic-native.ps1` nor CMake ever copied -the pinned library beside the test binary in the build tree — only into the -packaged output directory, which a test build never produces. Linux failed -loudly here (`cannot open shared object file`). **Windows did not fail at -all**: DLL search fell through to `PATH` and loaded an unrelated `msquic.dll` -from the Windows Performance Toolkit — 529,480 bytes, SHA `B2B7FD2D…` — -instead of the pinned `Microsoft.Native.Quic.MsQuic.OpenSSL` 2.5.9 build at -4,181,856 bytes, SHA `C17C6581…`. Every asserts scenario passed on the first -run against that binary with nothing indicating anything was wrong. - -This is the doctrine's own trap: a stale asset impersonating logic, and the -green result was the thing hiding it. Fixed by mirroring `5533c34`'s Linux -`POST_BUILD` copy on the Windows side, taking `msquic.dll` from -`MSQUIC_ROOT/bin/x64`. Both test build directories now carry the pinned -library at the right size and SHA, and every result below is from a rerun -after the fix. - -**Open question, not yet answered: how far back does this reach?** Every -earlier Windows scenario and mutation number in this campaign was produced on -this machine, and the copy has never existed. If the harness did not place the -pinned DLL itself, then Windows figures recorded in earlier passes — including -the 39-killed count — were measured against whatever `msquic.dll` happened to -be on `PATH`. **Nothing here re-proves those numbers.** They should be treated -as unconfirmed until someone checks whether the deleted harness copied the -library, and re-runs them if it did not. - -**Asserts build** (`Debug`, tests on, asserts on), nine scenarios, all pass: -`polltimeout` (worst overshoot 31 ms), `pollbusy` (17 ms), `pollhammer`, -`zerotimeout` (3 probes), `payloadfit`, `holdclose` (20×256 pollers), -`latecall`, `holdtimeout` (63 ms), `waitseam` (11 probes, 40 repeated polls). -Every overshoot is far inside the 400 ms tolerance and nothing was weakened. - -**Release build** (asserts off): `polltimeout` (20 ms), `pollbusy` (24 ms), -`pollhammer`, `zerotimeout`, and `payloadfit` as a bonus — all pass. **F1 is -now closed on both platforms.** `holdclose` refuses to run there with -*"needs the development seam"*, which is useful evidence in itself: it proves -the release build's asserts are genuinely compiled out rather than merely -untested. - -`closerace` was **not run**. It is the sixteen-burner stress, which stays an -operator fork. - -**A documentation gap, not a wrong instruction.** The README's Windows section -documents only the plain library build and carries no worked test-build -recipe, where the Linux section has one. Hands followed the brief's flags -because nothing better existed. That gap is why the missing DLL copy went -unnoticed for so long: there was no documented Windows path to run, and so -nobody ran one. - -### Cut 3 closed, 2026-09-23 - -StreamPixels is the priority now, and this is the first cut on its path. -The operator named it the week's goal: *"We needed to get to the StreamPixels -cut this week. We need that TO EAT."* - -- **Windows release configuration** (Sonnet, `quic-cut3-winrel`, no repo - change). This is a plain release build, asserts off, of the four required - scenarios, 20 rounds each: all pass, worst overshoot 16 ms against 400 ms. - The `msquic.dll` beside the binary is 4,181,856 bytes, SHA-256 `C17C6581…`, - which matches `build-quic-native.ps1`'s pin for the OpenSSL 2.5.9 runtime, - so the silent wrong-DLL load did not happen again. **F1 is closed on both - platforms.** Documentation gap: the README has no Windows test-build - CMake line; Hands mirrored the Linux one. -- **F5, operator fork ruled:** *"Feel free to set Starfire on fire, I'll step - away. If I know it's coming, it's not so bad."* Load on Starfire is allowed - when the operator is told first and nothing else runs alongside it. - - **Linux** (Yggdrasil, 16 burners on a 4-CPU cap, asserts on, `cc71f17`): - `closerace` 5 rounds of `20x256`, all pass. Earlier text in this map - records `20×512`; these rounds ran the binary's default size. - - **Windows, first run** (Starfire, 16 burners on 8 logical CPUs, asserts - on): **5 of 5 fail**, every one with *"256 of 256 pollers returned before - the close began, so they were never in the race"*. **This was not a - bridge defect. The fixture contradicted itself.** Under the debug seam, - the settle waited up to 30 s for every poller to be counted inside, while - each poller's wait timed out after `kPollTimeoutMs` = 5 s. Under - starvation, the early pollers left before the late ones were counted. The - bridge neither crashed nor asserted. - - **Fixture fix** `44ab376` (Sonnet): the settle budget is named, and - `kPollTimeoutMs` is derived as that budget plus 5 s in both - configurations. A deadline that expires now reports *"fixture could not - settle"* instead of blaming the pollers. The new message was reached only - by forcing the branch; under load on either platform, the counted - deadline never expired naturally. `HoldCloseOnce`, `LateCallOnce` and - `HoldTimeoutOnce` share the settle idiom but not the defect, because their - pollers are held at a barrier and cannot time out during it. - - **Windows rerun at `44ab376`:** `closerace 20x256: ok` in all 5 rounds - under 16 burners. A direct run confirmed exit code 0, because the runner - script lost the exit codes (`Start-Process -NoNewWindow` with redirected - output). The Linux rerun at the same commit: all ten scenarios pass, and - `closerace` passes 5 of 5 under 16 burners. **F5 is closed on both - platforms.** -- **Recorded, not blocking:** whether Windows numbers from before today were - measured against the pinned MsQuic stays unconfirmed. Today's were. - -Cut 3's work lives on `hands/cultmath-erf` plus `quic-cut3-winrel`, and -neither is merged to `main`. Cut 4 branches from `cc71f17`. - -### Cut 4, 2026-09-23: landed, gated, fix batch 1, confirming pass running - -**Landed** (Sonnet, 12 commits, `cc71f17..c57b613` on `quic-cut4`): the koffi -binding, consumer, session manager and trust. It reported 109/109 on Yggdrasil. -The interop lane was reported as an operator fork (EHOSTUNREACH). **Scars from -this landing:** -- A test helper leaked a runtime handle. It left a verify job idle at 0% CPU - for 25 minutes, and the agent waiting on it never woke. Self found the hang - with a SIGUSR2 diagnostic report: the event loop was idle with only - unreferenced handles. The fix at the owner: `ygg-verify.sh` gained a watchdog - (Eureka `9359e9c`). The first watchdog leaked the slot lock to its own - `sleep` child and held two slots for an hour; fixed at `dbe594e`. -- The agent ran past 550k tokens of context and was retired for a fresh one. - Its cut came in at +2,061 lines against an estimate of about 1,300. - -**Soul gate (Opus): Cut 5 may not build on this.** Confirmed by executed probes: -- A malformed frame from a peer killed the whole process (an unhandled - rejection in the pump). C# faults only that connection. -- `release()` was a use-after-free: it closed the runtime while a - `nextEvent.async` call was queued but not started. Exit 134 under - thread-pool saturation with `MALLOC_PERTURB_`. -- A peer shutdown leaked a runtime reference, and pending receives hung - forever. -- The session manager never went offline on transport death (C# - `InvalidateRealtimeSession`), and had no disposed guard or single-flight. -- The race waited on `allSettled`, so one dead route cost about 10 s. C# - returns the first success. -- `streamKinds` and the receive queue grew without bound, with no latest-only - coalescing as in C#'s inbox. -- The types said `bigint` while koffi struct members returned `number`, so - the canceled-send check was dead code. -- Eight spec rules had no killing test (M2–M4, M6–M10), and M1 was killed - only by a hang. - -**The interop "fork" was not a network problem.** Self's IPv6 hypothesis was -refuted: IPv6 was enabled and `--network host` failed identically. The probe's -first explanation, that an AF_INET socket ignores v4-mapped traffic, was also -wrong: ECONNREFUSED meant nothing was listening. The executed cause: -- the harness spawns peers with `stdio: ["ignore", ...]`, and the C# serve loop - stops on stdin EOF, so the listener tore itself down at once; -- the serve mode broadcast without waiting for a client; -- .NET in the image could not find `libmsquic`. - -**Fix batch 1** (fresh Sonnet, `c57b613..8e32bff`): -- 125/125 pass. **The C# managed provider to TS consumer lane passes**, - separate processes, on Linux. -- Kills are confirmed for reverted fixes 1 and 3–6. **Not proven by - execution:** the `release()` ordering fix (checked by reading only) and - kills for Soul's M2–M10. -- **The cut grew by about +906 net instead of shrinking.** Hands declined the - subtraction item on its own authority, arguing that `NativeBindings` is the - only static typing over koffi. `realtime-quic.ts` is 849 lines, against an - estimate of about 650 across Cuts 4 and 5 combined. -- Fix 7 coerces u64 struct members from `number`, which is lossy above 2^53. - -A confirming Soul pass (Opus) is rerunning the crash reproductions and M1–M10, -checking the 2^53 exposure, and judging the subtraction. **Cut 5 started in -parallel** on `quic-cut5` from `8e32bff`, to save wall-clock time. If Soul -finds defects, Cut 5 rebases onto their fixes. - -### Cut 4 confirmed, fix batch 2, Cut 5 landed, retention (StreamPixels Cut C), 2026-09-23 - -- **Cut 4 confirming Soul pass (Opus):** the core fixes hold under abuse. - - The `release()` use-after-free survives 300 cycles with the thread pool - saturated and `MALLOC_PERTURB_`. The old order dumps core. - - Malformed frames fault only their own connection. - - Racing and coalescing match C#. - - koffi returns `bigint` above 2^53, so there is no precision loss. - - It found that a throwing `onDisposed` handler killed the process or - leaked a ref, and that several fixes had no killing test. -- **Cut 5 landed** (Sonnet, `8e32bff..fd2a701`): the TS provider. **All four - lanes pass on Windows, including TS provider to the C# native connector, - the Unity overlay's path.** Linux: 3 lanes pass and 1 skips (Windows-only). -- **Fix batch 2** (Sonnet, `fd2a701..275010a`): - - Handler isolation, a use-after-free regression test (reverted order - crashes), 18 mutations killed, two further leaks fixed, and the root - lockfile fixed (`npm ci` works; this unblocked the StreamPixels deploy). - 146/146 on both hosts. - - **Scar:** this agent ran to about 800k tokens over 2.6 h because Self - packed ten items, subtraction, two hosts and a late addition into one - brief. Fix batches are split per file from here on. - - Subtraction missed: net +39 against Soul's −130..−150 estimate. The - `NativeBindings` collapse moved code rather than deleting it. -- **Retention** (StreamPixels Cut C, operator OQ1 = A; Sonnet, - `275010a..8cf89a7` on `quic-retention`): the provider retains the newest - latest-only frame per `(channel, body)` and seeds each new peer before it - joins, in TS (+12 lines) and C# (+36, seeding under the same lock as the - add). A late-joining C# native connector receives the retained frame on - Windows. Both runtimes' mutations are killed. - -**Soul gate on Cut 5 plus fix batch 2 (Opus): do not merge toward -StreamPixels.** Executed probes found: -1. **Critical: every provider peer is evicted at `handshakeTimeoutMs`.** A - handler swap meant CONNECTED was never recorded. No test lived past 10 s. -2. **Critical: `koffi.alloc` is never freed.** About 53 B per native call, - about 36 MB a day idle, and gigabytes a day under load. -3. **High for StreamPixels:** no chain-validated no-pin connect path exists in - the C# native connector or the bridge. The operator therefore ruled a - **pinned, long-lived self-signed certificate** (StreamPixels map, section - 7), so no bridge change is needed. -4. **High: client frames pile up unboundedly** in the provider's - `readyFrames`. C#'s inbox coalesces. -5. **Medium:** one invalid frame evicts every peer while `broadcast` reports - success. -6. **Medium:** `advertisedEndpoint` cannot describe a public host. -7. **Low:** `receive(abortedSignal)` never settles. -8. **Plausible:** the consumer-side native event queue is unbounded when - Unity stops polling. -9. **Hygiene:** under M2 the provider test file hangs for 234 s. - -Held: stalled peers never block latest-only `broadcast` (about 2 µs per -call), per-peer memory is bounded by the key count, 20k churn cycles return to -baseline apart from the koffi leak, eviction racing with dispose is clean, and -wire parity at maximum sizes is byte-identical. Lane 2's golden check is not -tautological. - -In the mutation matrix, Hands' 18 are killed. Surviving provider mutants: P3 -(send-failure eviction), P4 and P8 (two claimed fixes with no killing test), -P10b (`onFault` isolation), and the dispose and resurrection guards. - -**Fixes in flight, split per file:** -- **3a** (`realtime-quic.ts`, on `quic-retention`): synchronous accept via - `retain()`, which deletes the async-accept window and its guards and fixes - finding 1 structurally; encode once in `broadcast`; an `advertisedHost` - option; `receive(aborted)`; tests for P3, P8 and P10b; hygiene. -- **3c** (`realtime-quic-native.ts`, on `quic-koffi-leak`): allocate once, free - on close, and a steady-state RSS test. -- **3b** follows 3a: one inbox shaped like C#'s `CultMeshRealtimeInbox` across - the transport, provider fan-in and outbox, fixing finding 4. - -**Cut 1 Soul findings, 2026-09-16.** Held: every test count, both negative -greps, all twelve mutations rerun and killed, the control catching a -truncated write, the equivalent mutant confirmed (Node 24 WebCrypto refuses -every non-64-byte P1363 signature tried, across forty keys), the separator -byte matching C#, and the TypeScript-signs-C#-verifies direction proven by -a probe over adversarial inputs, which nothing in the repo yet pins. Found: - -- **The mutation runner leaves the last mutant compiled in `dist/`**, which - is git-ignored, and the browser tests then pass against it. A stale asset - impersonating logic, the doctrine's own trap. Medium. -- **The C# half of the vector check never runs in CI.** The only `dotnet - test` of that project is filtered to one lease test; a C# transcript - change would leave the committed vector self-consistent and nothing red. - Medium. -- **`verifyP256` fails closed on Node `Buffer` inputs**: `.slice().buffer` - on a pooled buffer is the whole pool. Internal callers allocate their own - bytes, so it is safe today and wrong for the Cut 4 consumer. Medium. -- **The `protocolIds` sort is untested**: the vector's ids were written - sorted, so removing the sort survives. Low-medium. -- **Four edge divergences from the C# rules**: an empty signature is - "unsigned" in C# and "invalid" in TypeScript; C#'s loopback set is wider - (`127.0.0.2`, and the TypeScript test pinned the narrower answer); root - lookup and validity window check in opposite orders; duplicate root key - ids throw in C# and take-first in TypeScript. All aligned to C# in the fix - batch. -- **The negative grep pins names, not structure**: a local shim under - another name passed every browser test and both greps. A guard-strength - note, recorded. -- **A killed runner leaves the mutant in the tree**; a sidecar restore is - added, as Epiphany's harness has. -- **`cultmesh-ts` resolves modules with `moduleResolution: "Node"`**, which - ignores `exports`, so `cultnet-ts/authority` is unresolvable from that - package until Cut 4 changes it; the root re-export covers it today. - -**The Cut 1 fix batch landed** at `c2ffc32` (`verifyP256` copies its bytes; -empty or whitespace signature is unsigned; root lookup before the validity -window; duplicate root key ids refuse at first use; the loopback set is -C#'s, probed through the public policy: `127.0.0.0/8` in any spelling -`URL` normalises, `::1`, the IPv4-mapped `::ffff:7f00:1`, `localhost`, -`loopback`; `localhost.`, `0.0.0.0`, `::` and `::ffff:127.0.0.2` are not), -`1590145` (`scripts/sign-cultmesh-authority-vectors.mjs` writes -`contracts/cultmesh/authority-route-vectors.ts-signed.json` over adversarial -inputs and a C# test verifies it; a one-character change to the committed -signature fails that test), `cf1203a` (`cultmesh-portability.yml` runs -`dotnet test --filter AuthorityProof` on both OSes on every push; the -interop workflow was Windows-only and main-only) and `0e4f479` (the runner -rebuilds `dist/` after the final restore and asserts a sentinel from the -restored source; a sidecar of the original bytes is written first and -repaired from at the next start). Twenty mutations, twenty killed. Tests -74, 17, 10; closure smoke four tarballs. - -Scars from the batch: **the runner's two multi-line anchors matched nothing -on a CRLF checkout** (the tree is `autocrlf=true`, HEAD is LF, the anchors -were `\n`), so the runner would have thrown at those entries; the earlier -"killed" claims for the transcript-order and nonce mutations came from an -LF-on-disk state. Anchors are now normalised to the file's EOL. Fixes 1 and -2 share one commit because Hands had made both before committing. -**Still open after the batch:** the browser client's local-development -short-circuit at `packages/cultmesh-browser/src/index.ts:915` tests -`!route.certificate` where the shared verifier now treats an empty -signature as unsigned, so such a route passes the verifier and is then -asked for a provider proof, where C# would not ask. **Landed** at `a801e0a`: -`isUnsignedCertificate` is exported from the shared module and used by the -verifier and the browser's session check, with a browser test for the -blank-signature loopback route, the signed loopback route that still needs -a proof, and the blank-signature remote refused in both modes. Twenty-one -mutations, twenty-one killed. Tests 74, 18, 10. - -**Second Soul pass, 2026-09-16.** Held: byte copy, root before window, duplicate -root ids refusing on the unsigned path in either insertion order, the sort -pinned, the U+001F separator on both sides, 33 of 39 field tampers failing the -C# test with the survivors explained, the runner repairing itself after a -SIGKILL and leaving `dist/` free of every mutant string, all 21 anchors -matching once on both LF and CRLF copies, and every test and grep. Cut 1 -closes on its stated invariants. Four edge divergences from the C# rules -remain, with one guard gap, to be fixed before Cut 4 makes a non-C# signer -real (in Hands): - -- **`isLoopbackEndpoint` is not `Uri.IsLoopback`**: 15 of 90 probed - endpoints disagree. Seven are reachable and TS-wider (a trailing dot on - the host, `ws:` without `//`, a backslash separator, fullwidth characters, - a tab), because `URL` normalises what C# refuses; eight are C#-wider and - unreachable in the browser (zone ids the `URL` parser throws on, - `file:`/`mailto:` schemes the filter drops). The doc comment claimed - equivalence. Low: local-development only. -- **`trim()` is not `char.IsWhiteSpace`** at U+0085 (C# whitespace, TS not) - and U+FEFF (TS trims, C# does not), so a signature of either is - "unsigned" on one side and "signed" on the other; both are carriable on - the rendezvous wire. Low, fail-open only where an absent certificate is - already accepted. -- **C# cleans the route before the transcript and TS transcribes raw**: - duplicate or padded protocol ids, padded generation and padded key ids - verify in C# and refuse in TS, and an absent protocol list gets a default - in TS and `""` in C#. Latent while every signer is C#; live at the first - TS signer. Low-medium. -- **Two C# refusals collapse into one TS message** (not base64; not P1363). - Low. -- **A local `=== ""` shim beside the shared call in the browser survives - every test**, because no browser test uses a whitespace signature; the - name grep is silent by construction. Low-medium. -- **No workflow runs the `cultnet-ts` tests on Linux**, and the interop - workflow is Windows-only and main-only; on a `codex/**` push only the C# - half of the vector check runs. Low. -- Recorded, not a defect: the TS-signed vector is not reproducible - byte-for-byte (random `k`); the C# test pins that the committed bytes - verify under current rules, and the TS test pins that the committed file - verifies under the current module. - -**The edge-alignment batch landed** (Opus) at `e67e695` (C#'s whitespace -set through three named helpers; the two signature refusals split to C#'s -texts), `c4c2330` (route fields cleaned before the transcript as the C# -constructors clean them: trim, drop blanks, distinct, sort; generation and -key ids trimmed; a null or empty protocol list transcribes as `""`, and the -TS default that wrote bytes the reference never writes is gone; `verseId` -deliberately raw, because `CanonicalRoute` passes it raw), `803ee12` (a -raw-endpoint pre-check refusing the spellings WHATWG `URL` repairs and -`System.Uri` does not; loopback disagreements 15 → 6, all six documented -unreachable), `dfe582e` (the browser's local reading of "unsigned" killed -by a whitespace-signature session test; the runner mutates the browser -target too, with per-target sidecar, control, sentinel and post-restore -assertion) and `0dfef0e` (the TypeScript authority tests in CI on both -operating systems). Soul's probes rerun: 88 endpoints, zero reachable -disagreements; 34 code points, zero; five signature shapes, byte-identical -messages; fifteen field tampers, zero mismatches against C#'s answers. -Tests 77, 18, 79, 10; closure smoke four tarballs; 33 shared and one -browser mutation killed. - -Two scars from the batch, both recorded because they are the kind a -postmortem should carry: **the runner's sidecar bit twice**, a throw inside -the mutation loop leaving it behind so the next run "repaired" from stale -bytes and silently reverted two fixes Hands had just made (the sidecar is -now removed in the `finally` immediately after the verified restore); and -**a literal NUL byte was committed inside a regex** at `803ee12`, which made -git classify the file as binary, stop normalising its line endings, and -diff the whole file as a rewrite, escaped at `dfe582e`. Residuals named, -not guessed at: `isProtectedEndpoint` did not get the pre-check and no -probe covers protected-scheme spellings; a negative priority throws in C# -and transcribes in TS, unreachable while only C# signs; two browser -mutations survive because the verifier refuses those routes first. - -**Third Soul pass, closing.** Held: all 34 whitespace code points in the -browser path too, with C#'s `VerifySessionProof` answer as the -expectation; the three signature refusals byte-identical; cleaning parity -in both directions with fresh keys (nine of nine each way, a padded -`verseId` refused cross-wise, C# confirmed not to trim it); 88 loopback -spellings with only the documented unreachable disagreements; the runner's -control writing through the same path as its mutations; CI's job, matrix, -triggers and setup order as promised; every suite, the closure smoke, both -greps. **Cut 1 is closed; Cut 2 may start.** Three residuals go with Cut 2's -Hands pass: - -- **`isProtectedEndpoint` lacks the raw-shape pre-check** that - `isLoopbackEndpoint` got, so eleven spellings C# refuses as unparseable - are accepted and dialled after repair by `URL`. A trusted signer would - have to emit a malformed endpoint, so security holds and the parity - invariant does not. Five lines. Low-medium. -- **A literal U+001F byte sits in the separator string** in source and - twice in the tests, where C# spells it ``; git does not treat it as - binary, but any editor that strips C0 controls changes every signature - with no visible diff. The NUL scar one rank lower. -- **The sidecar footgun is narrowed, not removed**: a SIGKILL still leaves - it, and an edit made before the next run is overwritten by the repair. - Repair must refuse when the file matches neither the sidecar nor the - mutant. - -Two corrections to this map's own record of the batch: **the NUL scar was -overstated**, since the byte sat past git's binary sniff and no whole-file -rewrite exists in history, only the normalisation path saw it and the blob -was LF-only anyway; and **CI was not green throughout the batch**, two of -its commits failing an unrelated Eve checkpoint job before the authority -steps existed, green from `0dfef0e`. - -Seen by Hands, recorded for section 15: `packages/cultnet-ts/src/generated/swarm-contracts.generated.ts` -is rewritten with LF by every build while the tree is `autocrlf=true`, so -it shows modified with zero content diff after any build; the generator's -line endings and the repo's normalisation disagree, and every pass discards -the churn by hand. - -Anchor: repo `F:\Projects\CultLib`, branch `main`, HEAD -`8d8ad568aa280bac34bf123503a9e38c175eb558`. The three commits since the -original anchor `f2cd2eb4` (`bf9f6f7`, `3c29fc9`, `8d8ad56`) touch only this -document `(probe: git log --stat)`, so every `file:line` below, read against -`f2cd2eb4`, is still exact at `8d8ad568`. If HEAD moves, re-anchor before -cutting. - -How to read this document: section 1 prices the largest liability first, as -the target requires, because if that price had turned out to dominate the -campaign, the cut order below would have been wrong. Section 2 is the probe -ledger; every mechanism claim in this map carries `(probe)` when it was -established by running something, or `(source read)` when it was established -by reading a file at a named line. Nothing is claimed from a package name or a -README. Section 3 is the consumer audit. Section 4 names rejected options and -why. Section 5 is the authority map for every ownership change. Sections 6-12 -are the cuts. Section 13 holds the operator questions; section 14 the -subtraction estimate; section 15 what could not be assigned. - -Two corrections to the target, recorded here rather than silently absorbed: - -- The target cites `src/GameCult.Mesh.Quic/CultMeshRealtimeTransports.cs`. - That file is `src/GameCult.Mesh.Quic/CultMeshQuicRealtimeTransport.cs` - (674 lines). `CultMeshRealtimeTransports.cs` exists, but in - `src/GameCult.Mesh/`, and holds the transport-neutral contracts - (`CultMeshRealtimeDelivery` at :8-13, `CultMeshRealtimeFrame` at :19-44, - `ICultMeshRealtimeTransport` at :46-52, - `ICultMeshRealtimeTransportConnector` at :55-63) `(source read)`. -- This map's first issue attributed the phrase "shipped through a registry" - to the target. The target contains no such phrase and no word "registry" - `(probe: rg)`; the reading was the map's, and it is withdrawn. What is - true: today only `@gamecult/cultcache-ts` has a registry publish job - (`.github/workflows/publish-packages.yml:20-24`, `:40-76`); `cultnet-ts`, - `cultmesh-ts` and `cultmesh-browser` have none, and every external consumer - reaches them by `file:` path (section 3). Q5 was ruled C on that Body: no - registry in this campaign, publication parked. - -## 1. The largest liability, priced first - -The target's biggest new surface is CultLib owning native MsQuic bindings for -Node on two platforms. The price depends on three things: what Node itself -offers, what the repo already owns, and how a native artifact reaches a -consumer host without a toolchain. Each was probed. - -### 1.1 What Node offers - -- Node `v24.15.0` on Starfire has no `node:quic`, with or without - `--experimental-quic` (`ERR_UNKNOWN_BUILTIN_MODULE`), and its internal - binding table has no `quic` entry (`No such binding: quic` under - `--expose-internals`). `process.versions` reports `openssl 3.5.5`, no - `ngtcp2`, no `nghttp3`, `napi 10` `(probe)`. Yggdrasil runs Node `24.14.1` - from NodeSource (`F:\Projects\gamecult-ops\inventory.md:660`) `(source read)`, - so the same absence holds on the deploy host. -- Conclusion: there is no first-party QUIC in this Node line. Anything that - works is native. - -### 1.2 What the repo already owns - -- `native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp` (440 lines) is a - CultLib-owned C ABI over MsQuic: `cultmesh_quic_open/state/poll/error/close` - (`:309-440`). It negotiates ALPN `cultmesh-state-v1` (`:32`, `:341-344`), - uses deferred certificate validation and answers the pin decision through - `ConnectionCertificateValidationComplete` (`:239-263`), reassembles the - 1-byte-kind plus 4-byte-LE-length QUIC stream framing (`:123-157`), and - queues whole encoded frames for a polling host (`:400-418`). It is Windows - desktop only by construction: ``, ``, `` - (`:1-3`), `CryptHashCertificate2` for the pin (`:184-200`), - `__declspec` exports (`:18-22`), and the CMake build refuses non-Windows - (`CMakeLists.txt:4-6`) `(source read)`. -- The bridge is consumed by the Unity connector through `DllImport` of library - name `gamecult_mesh_quic_native` - (`src/GameCult.Mesh.Quic.Native/CultMeshNativeQuicRealtimeTransport.cs:259-277`), - which polls every 2 ms by default (`:14`, `:167-203`) `(source read)`. The - built DLL and `msquic.dll` 2.5.9 are committed at - `unity/org.gamecult.cultlib/Runtime/Plugins/x86_64/` (last rebuilt in - `a0813c6`, 2026-09-14) `(probe: git log)`. -- The Windows build is scripted and pinned: `scripts/build-quic-native.ps1` - downloads `Microsoft.Native.Quic.MsQuic.Schannel` `2.5.9` by URL, checks its - SHA-256 (`:13-14`, `:27-41`), and builds with CMake `-A x64` (`:48-52`). - The last build on this machine used Visual Studio 17 2022 Build Tools, MSVC - 14.44 (`artifacts/quic-native-build/x64/Release/CMakeCache.txt`) `(probe)`. - `cl.exe` is not on PATH but Build Tools are installed, so the existing - script works here as-is. -- `tests/GameCult.Mesh.Quic.Native.Tests/GameCult.Mesh.Quic.Native.Tests.csproj:20-29` - builds that bridge before the test build and copies it beside the test - output `(source read)`. `scripts/build-unity-package.ps1:80-82`, `:143-147` - builds it again for the Unity package `(source read)`. - -Conclusion: CultLib already owns the MsQuic body for one platform, one role -(client), and one host (Unity). The cost of the target is extending that body -to a second role (provider), a second platform (Linux x64), and a second host -(Node), not creating a body from nothing. - -### 1.3 How Node loads it - -The decisive probe: from Node 24.15.0, with `koffi@3.3.0` installed into the -scratchpad, `koffi.load` loaded the committed `msquic.dll` then -`gamecult_mesh_quic_native.dll`, bound the five v1 exports by C prototype, -called `cultmesh_quic_open("127.0.0.1", 9, <64 zero hex>)` which returned `0` -with a non-null handle, observed `cultmesh_quic_state` move from `Connecting` -to `Failed` after 34 ms, read the bridge's structured error string through -`cultmesh_quic_error` ("shut down by the transport (status=0xFFFFFFFF800704D0, -error=0x1, msquic=F:\...\msquic.dll, events=event=1)"), got `-2` from -`cultmesh_quic_poll` on a failed client, and closed cleanly `(probe: -scratchpad/koffi-probe/probe.js)`. MsQuic ran its worker threads inside the -Node process and the poll model crossed the boundary without any callback -into JS. - -What that proves and what it does not: - -- Proves: the existing CultLib C ABI is directly loadable and drivable from - the Node line in question with no addon build, no Node headers, no MSVC at - install time, and no per-Node-version artifact. The `.async` call form - exists on bound functions (`typeof state.async === "function"`), which is - the mechanism for a blocking wait off the JS thread `(probe)`. -- Does not prove: a QUIC handshake succeeded (port 9 was intentionally dead); - that the provider role works (the bridge has none); that Linux works (the - bridge is Windows-only). Those are cut deliverables, not probe results. - -koffi facts used by the design, from its shipped documentation, not from -memory: JS callbacks always run on the main thread and calls from other -threads are queued to it, with an explicit deadlock warning if the main thread -blocks on a secondary thread (`node_modules/koffi/doc/callbacks.md:166-176`); -asynchronous calls run on a worker pool sized to the core count with a default -cap of 256 queued calls (`doc/misc.md:26`, `:37`); prebuilt binaries ship for -Windows x64 and Linux/glibc x64 among others, Node >= 16, no compiler needed -(`doc/index.md:17-38`) `(source read)`. Package weight: 1,713,562 bytes -unpacked, 87 files, MIT `(probe: npm view)`. The design below uses no JS -callbacks at all; the only crossing is one blocking `next_event` wait per -runtime issued through `.async`, so the deadlock class in `callbacks.md:176` -cannot occur. - -### 1.4 How it reaches Linux - -- `libmsquic` is published by Microsoft for Debian 13 (trixie) at - `packages.microsoft.com/debian/13/prod`, versions including `2.5.9` - (`pool/main/libm/libmsquic/libmsquic_2.5.9_amd64.deb`, 2,906,420 bytes, - SHA-256 `1baa61ade0b7b4a99f6dcb6b00d9aedb12b5566d00918a325be7425e878e51ba`, - `Depends: libssl3t64, libnuma1, libxdp1, libnl-route-3-200`) `(probe)`. - Yggdrasil is Debian 13 (`gamecult-ops/inventory.md:356`) `(source read)`. - The same `2.5.9` pinned for Windows exists for the deploy host. -- The NuGet packages carry Windows binaries only: `Microsoft.Native.Quic.MsQuic.OpenSSL` - 2.5.9 contains `bin/{x64,x86,arm64}/msquic.dll`, `lib/*/msquic.lib`, - and headers `msquic.h`, `msquicp.h`, `msquic_winuser.h`; no `.so`, no - `msquic_posix.h` `(probe: nupkg listing)`. The Linux build needs - `msquic.h`, `msquic_posix.h`, `quic_sal_stub.h` from the msquic source - tree at tag `v2.5.9`; all three are fetchable at - `raw.githubusercontent.com/microsoft/msquic/v2.5.9/src/inc/` (HTTP 200, - 79,280 / 17,909 / 4,731 bytes) `(probe)`. GitHub releases `v2.5.9` carry only - `*_test.zip` bundles; `v2.5.11`, `v2.6.1` carry no assets `(probe)`, so the - deb is the only distribution-grade Linux runtime for this version. -- Build host for Linux: Docker Desktop on Starfire runs a `linux/amd64` engine - `(probe: docker version)`, so a `debian:13` container is a Linux build host - for the development loop. The release artifact must come from a Linux host - the deploy path trusts: Yggdrasil itself, or a CI runner. Q6. -- Windows toolchain: MSVC Build Tools 2022 present; CMake 4.3.2; also a MinGW - gcc from StrawberryPerl on PATH `(probe)`. The map keeps MSVC for Windows - because the committed Unity DLL is built with MSVC `/Brepro` for - reproducibility (`CMakeLists.txt:17-19`) `(source read)`; mixing toolchains - for one DLL is a liability with no capability behind it. - -### 1.5 Price verdict - -The binding does not dominate the campaign. The C body exists; the Node load -path is proven with one 1.7 MB MIT dependency and zero addon tooling; the -Linux runtime is a pinned distro package on the exact target OS; the Windows -build is already scripted. The real cost is the C++ rewrite from a -client-only, Windows-only, per-client poll bridge to a runtime-neutral, -two-role event bridge (section 8), estimated at roughly 1,000 lines of C++ -replacing 440, plus a Linux build script and CI job. That is one cut, not the -campaign. - -What would have changed this verdict: if the bridge had needed JS callbacks -from MsQuic worker threads (it does not; the wait/event model avoids them), or -if `libmsquic` had not been available for Debian 13 at the pinned version (it -is), or if the FFI load had failed on Node 24 (it did not). - -## 2. Probe ledger - -| # | Claim | Method | Evidence | -| --- | --- | --- | --- | -| P1 | Node 24.15.0 has no `node:quic` and no internal quic binding | probe | `require('node:quic')` -> `ERR_UNKNOWN_BUILTIN_MODULE` with and without `--experimental-quic`; `--expose-internals` -> `No such binding: quic`; `process.versions.ngtcp2 === undefined` | -| P2 | The committed CultLib MsQuic bridge loads and runs from Node 24 via koffi | probe | `scratchpad/koffi-probe/probe.js`: open rc 0, state 2 after 34 ms, structured error string, poll -2, clean close | -| P3 | koffi ships Windows x64 and Linux glibc x64 prebuilds, needs no compiler, Node >= 16 | source read | `koffi/doc/index.md:17-38` | -| P4 | koffi async calls run on a worker pool; JS callbacks only on the main thread | source read | `koffi/doc/misc.md:26,37`; `koffi/doc/callbacks.md:166-176` | -| P5 | koffi is 1.7 MB unpacked, MIT | probe | `npm view koffi dist.unpackedSize dist.fileCount`; `package.json:27` | -| P6 | MSVC Build Tools 2022 (14.44) and CMake 4.3.2 are present; the last bridge build used them | probe | `artifacts/quic-native-build/x64/Release/CMakeCache.txt`; `cmake --version` | -| P7 | `libmsquic 2.5.9` exists for Debian 13 amd64 with its SHA-256 and dependency set | probe | `packages.microsoft.com/debian/13/prod/dists/trixie/main/binary-amd64/Packages` | -| P8 | Yggdrasil is Debian 13 with Node 24.14.1 from NodeSource | source read | `gamecult-ops/inventory.md:356`, `:660` | -| P9 | MsQuic NuGet OpenSSL 2.5.9 carries no Linux binary or posix header | probe | nupkg listing | -| P10 | MsQuic POSIX headers are fetchable at tag v2.5.9 | probe | HTTP 200 for `msquic.h`, `msquic_posix.h`, `quic_sal_stub.h`, `msquic_winuser.h` | -| P11 | The pinned `msquic.h` has `QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12`, deferred/indicated certificate flags, `QUIC_SEND_FLAG_FIN`, `QUIC_STREAM_EVENT_SEND_COMPLETE`, API version 2 | source read | `artifacts/dependencies/msquic-schannel-2.5.9/package/build/native/include/msquic.h:123,132-133,142,246,394-398,1290,1530,1850` | -| P12 | Docker Desktop on Starfire runs a linux/amd64 engine | probe | `docker version --format '{{.Server.Os}}/{{.Server.Arch}}'` -> `linux/amd64` | -| P13 | `openssl` 3.5.5 CLI is available on Starfire (mingw) | probe | `which openssl` | -| P14 | npm names `cultmesh-ts`, `cultnet-ts`, `cultmesh-browser`, `@gamecult/cultmesh-ts`, `@gamecult/cultnet-ts`, `@gamecult/cultmesh-quic-native` are all unclaimed | probe | `npm view version` returned nothing for each | -| P15 | Only `@gamecult/cultcache-ts` and the three Python packages have publish jobs | source read | `.github/workflows/publish-packages.yml:20-24,40-76` | -| P16 | Every external TS consumer uses `file:` paths; none uses a registry version | probe (Explore agent over `F:\Projects`) | section 3 | -| P17 | The StreamPixels deploy path extracts a CultLib tarball beside the app and runs `pnpm install --frozen-lockfile` and `pnpm build` on Yggdrasil | source read | `gamecult-ops/scripts/deploy-streampixels-preview.sh:21,95-103` | -| P18 | The Unity native connector refuses any endpoint without a 64-hex `cert-sha256` pin | source read | `CultMeshNativeQuicRealtimeTransport.cs:103-105` | -| P19 | C# `IsProtected` accepts `wss`, `https`, or any scheme containing `quic`; the browser verifier accepts only `wss` | source read | `CultMeshAuthorityProof.cs:156-162`; `cultmesh-browser/src/index.ts:965` | -| P20 | C# and browser canonical route transcripts are field-for-field identical | source read | `CultMeshAuthorityProof.cs:275-292` vs `cultmesh-browser/src/index.ts:979-996` | - -## 3. Consumer audit - -Method: every `package.json` under `F:\Projects` (excluding `node_modules`, -`dist`, `dist-test`, `.git`, `bin`, `obj`, `Library`, `Temp`, and CultLib -itself and its worktree copies) checked for the four package names, plus a -grep of every `*.ts/*.tsx/*.mts/*.cts/*.js/*.mjs/*.cjs` import or require of -them, with symbols read from the import lines. Vendored copies inside -`Heimdall/vendor/CultLib`, `VoidBot/vendor/cultcache-ts`, and -`gamecult-ops/.artifacts/*` were classified as library-internal, not -consumers. - -Result: - -| Package | Repos | Source files | Symbols actually imported (union) | -| --- | ---: | ---: | --- | -| `cultnet-ts` | 11 (StreamPixels, Heimdall, AetheriaEve, AetheriaEve-cultlib-admission, VoidBot, Stonks, Vili, weksa, Sai, EvePlugins, Bifrost) | 28 | `CultNetRudpSession`, `decodeRudpPacket`, `encodeRudpPacket`, `encodeCultNetMessageForWire`, `parseCultNetMessage`, `invokeCultNetOperation`, `startCultNetOperationServer`, `defineCultNetDocumentBinding`, `CultNetDocumentRegistry`, runtime-presence helpers, and message/packet types | -| `cultnet-ts/contracts` | 0 | 0 | one esbuild alias only (`AetheriaEve-cultlib-admission/scripts/verify-aetheria-browser-provider.mjs:48`); `cultmesh-browser` is its only importer and is inside CultLib | -| `cultmesh-ts` | 7 (StreamPixels, Heimdall, AetheriaEve and its worktree, Stonks, weksa, Odin and its worktree) | 10 | `CultMesh`, `cultMeshRectFromBounds`, `cultMeshViewportRequest`, and types (`CultMeshRudpEndpoint`, `CultMeshDocumentCatalog`, `CultMeshViewportRequest`, diagnostics types) | -| `@gamecult/cultcache-ts` | 1 (Heimdall) | 5 | `SingleFileMessagePackBackingStore`, `defineDocumentType`, `CultCacheEnvelope` | -| `cultcache-ts` (old unscoped name) | 8 | 16 | `CultCache`, `SingleFileMessagePackBackingStore`, `defineDocumentRegistry`, `defineDocumentType`, `/inspection` | -| `cultmesh-browser` | 1 (AetheriaEve and its worktree) | 1 | `CultMeshBrowserClient`, `CultMeshBrowserOdinRendezvous`, `decodeCultNetPayload` | - -StreamPixels specifically: `apps/service/package.json:25-27` declares -`cultcache-ts`, `cultmesh-ts`, `cultnet-ts` as `file:../../../CultLib/packages/`; -`apps/service/src/verse-state.ts:4-6` imports `defineDocumentType`, -`CultMesh`, `defineCultNetDocumentBinding`; `apps/service/src/idunn-rudp-health.ts:2-7` -imports `encodeCultNetMessageForWire`, `encodeRudpPacket`, and two types. -Nothing else in StreamPixels imports these packages. No TS/JS file anywhere -under `F:\Projects` references `cultmesh-state+quic` or `CultMeshRealtime`. - -Sizing consequences: - -- Nothing this migration adds has a consumer yet. The QUIC surface is new - API; no existing export is reshaped, so no external repo changes are - required by the CultLib cuts. StreamPixels adoption is consumer work after - release (target, "Not in this migration"). -- The `verifyAuthorityRoute` family in `cultmesh-browser` is module-private - (not exported at `cultmesh-browser/src/index.ts:955`, `:979`, `:998`, - `:1012`, `:1028`), so moving it (Q2) changes no external import. The three - symbols AetheriaEve imports stay. -- `cultnet-ts/contracts` has no external consumer; adding a sibling subpath - export for the shared verifier follows an existing, internally consumed - pattern rather than inventing a new one. -- The `cultcache-ts` naming split (8 repos on the old unscoped name, Heimdall - on `@gamecult/`) is pre-existing and not touched here, but it is the - precedent Q5 has to reckon with. - -## 4. Rejected options - -- **Node built-in QUIC.** Absent in Node 24 (P1). Not a choice. -- **`@matrixai/quic` 2.0.9.** A Rust/quiche-based QUIC stack with its own - stream, certificate and event semantics `(probe: npm view description)`. - Rejected because the target requires the bytes on the wire, the ALPN, the - stream-kind byte, the deferred certificate pin decision, and the close/abort - codes to match `GameCult.Mesh.Quic` and the Unity MsQuic connector; two QUIC - stacks would have to be proven equivalent at every one of those points, and - CultLib would own neither. Semantically wrong for this campaign, not merely - unfashionable. -- **`@fails-components/webtransport` 1.6.8.** libquiche behind a WebTransport - (HTTP/3) session model `(probe)`. Wrong layer: the realtime plane is raw - QUIC with ALPN `cultmesh-state-v1`, not HTTP/3. -- **`node-quic` 0.1.3.** A wrapper around an abandoned pure-JS QUIC `(probe)`. - Not TLS 1.3 MsQuic; rejected on the same grounds. -- **A Node-API addon (node-addon-api + node-gyp/cmake-js) wrapping MsQuic - directly.** Viable, but it creates a second C++ owner of MsQuic callback - semantics beside the Unity bridge, requires Node headers and MSVC on every - Windows build host and a Node-ABI artifact per platform, and buys nothing the - C ABI plus FFI does not (P2). Rejected as duplicate authority. If koffi were - ever removed, the cheapest replacement is a thin N-API shim over the same C - ABI, not a second MsQuic body. -- **A separate .NET provider process or a WebSocket shortcut.** Already ruled - out by the operator (target, line 15-17). -- **JS callbacks from MsQuic worker threads.** koffi supports them by queuing - to the main thread (P4), but it turns every MsQuic event into a - cross-thread hop and opens the documented deadlock class. Rejected in favour - of the event-queue/wait model the existing bridge already uses. -- **Building the Windows DLL with the MinGW gcc on PATH.** Present (P6) but the - committed Unity artifact is MSVC `/Brepro`; two toolchains for one DLL is a - reproducibility liability. Rejected. -- **Building the Linux artifact on Starfire and shipping it.** Cross-building - is explicitly forbidden by the target; a Docker `debian:13` container on - Starfire is a Linux host and is fine for the development loop, but the - release artifact comes from the builder the operator names in Q6. -- **Keeping `cert-sha256` verification in C.** The v2 ABI hands the DER - certificate to the host and waits for the decision, which is the "caller - hook" the target demands and removes the Windows-only - `CryptHashCertificate2` from the portable path. The v1 entrypoint keeps its - in-C pin check only as the Unity compatibility shim (section 8). - -## 5. Authority maps - -### 5.1 Native MsQuic bridge (`native/GameCult.Mesh.Quic.Native`) - -- Owner: `cultmesh_quic_native.cpp` owns MsQuic registration, configuration, - listener, connection and stream handles, TLS credential loading, the - 1-byte-kind + 4-byte-LE-length stream framing, and a single event queue per - runtime. -- Inputs: host/port, PKCS12 bytes and password for providers, the host's - certificate decision for clients, encoded frame bytes to send. -- Outputs: events (`listener_new_connection`, `connection_connected`, - `connection_certificate_received` with DER payload, `connection_shutdown` - with code/status/text, `stream_started` with kind, `stream_frame` with the - whole encoded frame, `stream_send_complete`, `stream_shutdown`); the bound - listener port; structured error text. -- Derived state: none that the host reads as truth. Connection counts, remote - addresses and MsQuic status codes are diagnostics. -- Forbidden writers: the bridge never decodes a CultMesh frame, never decides - delivery semantics, never coalesces, never accepts a certificate on its own - in the v2 path, never reconnects. The v1 shim is the only place a pin is - compared in C, for the Unity contract only. -- Shared paths: the Unity managed connector (v1 exports) and the Node binding - (v2 exports) use the same library, the same MsQuic runtime, the same - framing code. -- Deletion line: the per-client `Client` struct with its own registration - (`:51-63`, `:316-393`), Windows-only includes and export macros (`:1-3`, - `:18-22`), `CertificateMatchesPin` as the sole trust path (`:184-200`). - -### 5.2 TypeScript QUIC realtime plane (`packages/cultmesh-ts`) - -- Owner: `src/realtime-quic.ts` owns provider and consumer semantics: which - stream kind carries which delivery mode, the per-peer keyed coalescing - outbox for `LatestOnly`, the single ordered stream for `ReliableOrdered`, - `Unreliable` failing closed, the generation filter on receive, and the - certificate pin decision on the consumer. -- Inputs: bridge events; `CultMeshRealtimeFrame` objects from application - code; an advertised `CultMeshTransportCandidate`-shaped route from the - session manager; the consumer's trust policy. -- Outputs: encoded frames to the bridge; decoded frames to the application; - the advertised endpoint string for a provider (with `cert-sha256`). -- Derived state: connection health, connected peer count, stream ids. -- Forbidden writers: application code never opens a stream, picks an - endpoint, or writes a reconnect loop (target). `src/realtime-wire.ts` never - touches a socket. `src/realtime-quic-native.ts` (the koffi binding) never - interprets frame bytes. -- Shared paths: provider broadcast and consumer send both go through - `sendFrame` on the same transport object; the coalescing outbox is the only - path for `LatestOnly` on a provider, whether the caller is a test, a tick, or - a reconnect. -- Deletion line: none inside `cultmesh-ts` (there is no prior QUIC code); the - RUDP provider transport at `src/provider-rudp-transport.ts` is untouched. - -### 5.3 Shared TypeScript route verification (Q2) - -- Owner after the cut: `packages/cultnet-ts/src/cultmesh-authority.ts`, - published as subpath `cultnet-ts/authority`. It is the only TypeScript - implementation of: Odin root lookup, validity window, canonical route - transcript, canonical session transcript, P-256/P1363 verification, - loopback detection, and the protected-scheme rule. -- Inputs: a route view (Verse, authority runtime, endpoint, protocol ids, - priority, generation, certificate), a trust policy (`mode`, `odinRoots`, - `now`), a session-open request and an accepted message. -- Outputs: resolution or a thrown `Error` whose message is the C# reference's - for the same refusal. *(First written as "the same message texts the - browser package emits today (its tests pin them)"; Soul found the browser - tests pin two messages only, and the channel-protection text was false for - QUIC. Corrected 2026-09-16.)* -- Derived state: none. -- Forbidden writers: `cultmesh-browser` must not retain or regrow - `verifyAuthorityRoute`, `canonicalRoute`, `canonicalSession`, - `canonicalFields`, `verifyP256`, or `isLoopbackEndpoint`; `cultmesh-ts` must - not implement any of them; neither transport package may depend on the - other. Negative greps in section 6 pin this. -- Shared paths: the browser WebSocket client and the Node QUIC consumer verify - the same route bytes through the same function. -- Deletion line: `cultmesh-browser/src/index.ts:955-1072` and `:797-808`. -- Behavioural note, not a silent change: the protected-scheme rule becomes the - C# rule (`wss`, `https`, scheme containing `quic`; - `CultMeshAuthorityProof.cs:156-162`) instead of `wss`-only - (`cultmesh-browser/src/index.ts:965`). The browser client still refuses - non-`ws(s)` route endpoints at `:537-540`, so browser behaviour is - unchanged; the shared module simply stops being wrong for QUIC routes. - -### 5.4 Build and packaging - -- Owner: `scripts/build-quic-native.ps1` (Windows x64) and the new - `scripts/build-quic-native.sh` (Linux x64) own producing the bridge - artifact; the new `.github/workflows/quic-native.yml` owns producing the - release-grade artifact for both platforms (Q6 A) and attaching it to a - GitHub Release; the committed tree `packages/cultmesh-ts/native/` owns - delivery to consumers (Q5 C): whatever carries the package directory (a - `git archive`, an `npm pack` tarball, a pnpm `file:` copy) carries the - binaries with it, and `packages/cultmesh-ts/native/MANIFEST.txt` plus - `SHA256SUMS` own provenance (MsQuic version, build host, digest per file). -- Inputs: pinned MsQuic 2.5.9 (Schannel NuGet on Windows; `libmsquic` deb on - Linux) with SHA-256 checks; the bridge source; the pinned `debian:13` image - digest for the Linux builder. -- Outputs: `gamecult_mesh_quic_native.dll` + `msquic.dll` (win32-x64), - `libgamecult_mesh_quic_native.so` + `libmsquic.so.2` (linux-x64), the MsQuic - license, and the two provenance files. -- Derived state: `artifacts/` (git-ignored, `.gitignore:66`) is the - development-loop build output and never delivery; the Unity plugin copies at - `unity/org.gamecult.cultlib/Runtime/Plugins/x86_64/` remain the Unity - package's own body (section 8, operator-only rebuild), not a source for - Node. -- Forbidden writers: no `postinstall` compile or download step in any - package; a consumer host never needs CMake, a compiler, or registry access - for the binding; no workflow commits binaries to `main` (the operator - commits from a Release asset whose digest the manifest records, Q8); - `realtime-quic-native.ts` never searches `node_modules` for a platform - package. -- Deletion line: the platform packages - `packages/cultmesh-quic-native/{win32-x64,linux-x64}` and - `optionalDependencies` from the ruling-A map are never created; the Windows - script is kept and the Unity package script keeps calling it. -- Parked seam (registry publication, later pass): the same `quic-native.yml` - artifacts are the payload a publish job would wrap; the reattachment point - is a `cultmesh-ts` job shaped like `publish-packages.yml:39-78` that depends - on the two build jobs, plus `optionalDependencies` in - `packages/cultmesh-ts/package.json` and a `node_modules` branch in the - resolver. None of that exists under C. - -## 6. Cut 1 (subtraction): one TypeScript route verifier - -Purpose: land Q2 before any QUIC code exists, so the Node consumer has one -owner to call and the browser package has nothing left to grow. - -Deletes (exact): - -- `packages/cultmesh-browser/src/index.ts:955-977` `verifyAuthorityRoute` - (23 lines), `:979-996` `canonicalRoute` (18), `:998-1010` `canonicalSession` - (13), `:1012-1026` `canonicalFields` (15), `:1028-1058` `verifyP256` (31), - `:1065-1072` `isLoopbackEndpoint` (8), `:797-803` `bytesToBase64` (7), - `:805-808` `base64ToBytes` (4). Total 119 lines deleted from the browser - package. `randomNonce` (`:1060-1063`) stays: it is browser-client behaviour, - not verification. - -Keeps and moves: - -- The deleted bodies move verbatim into - `packages/cultnet-ts/src/cultmesh-authority.ts` as exported functions, with - one edit: the protected-scheme test in `verifyAuthorityRoute` becomes - `isProtectedEndpoint(endpoint)` implementing the C# rule (P19). Types - `CultMeshBrowserIdentity`, `CultMeshBrowserRoute`, - `CultMeshBrowserP256PublicKey`, `CultMeshBrowserRouteCertificate`, - `CultMeshBrowserAuthorityTrustMode`, `CultMeshBrowserAuthorityTrustPolicy` - (`cultmesh-browser/src/index.ts:19-53`) move too, renamed without the - `Browser` infix (`CultMeshAuthorityIdentity`, `CultMeshAuthorityRouteView`, - `CultMeshP256PublicKey`, `CultMeshAuthorityRouteCertificate`, - `CultMeshAuthorityTrustMode`, `CultMeshAuthorityTrustPolicy`). - `cultmesh-browser` re-exports them under the old names as type aliases. -- `validateSessionAcceptance` (`:926-953`) stays in the browser package; it - compares WebSocket handshake fields. Its crypto lines (`:944-951`) are - replaced by a call to the new `verifyProviderSessionProof(request, endpoint, - providerKey, signature)` exported from the shared module. - -Adds: - -- `packages/cultnet-ts/src/cultmesh-authority.ts` (about 190 lines: the moved - 119 plus types and `isProtectedEndpoint`). Browser-safe by construction: it - may use only `globalThis.crypto.subtle`, `TextEncoder`, `atob`, `btoa`, - `URL`, `DataView`, `Uint8Array`. No `node:` import. -- `packages/cultnet-ts/package.json:7-18` gains an `"./authority"` export - beside `"./contracts"` (`:12-16`), same three-key shape. -- `packages/cultnet-ts/src/index.ts` re-exports the module's public names. -- `packages/cultnet-ts/test/cultmesh-authority.test.ts` (about 150 lines): - signs a route with `node:crypto` `generateKeyPairSync("ec", { namedCurve: - "P-256" })` and verifies through the shared module; one negative per rule - (expired, unsigned remote, wrong Odin root, mutated endpoint, wrong signature - length); and asserts `isProtectedEndpoint` accepts `wss://`, `https://`, - `cultmesh-state+quic://` and rejects `ws://`, `cultnet+tcp://`. -- A cross-runtime vector: `tests/GameCult.Mesh.Tests/CultMeshAuthorityProofTests.cs` - gains a test that calls `CultMeshAuthorityProof.CreateSignedRoute` - (`src/GameCult.Mesh/CultMeshAuthorityProof.cs:221`) with a fixed test key - and writes `contracts/cultmesh/authority-route-vectors.json` (route fields, - Odin public key, signature) when `CULTMESH_WRITE_VECTORS=1`, and otherwise - asserts the committed file still verifies. The TS test verifies the same - file through the shared module. This is a shared-vector check, not - cross-process interop; it proves the transcript bytes, which is what Q2 - needs. - -Per-file changes: - -- `packages/cultmesh-browser/src/index.ts:1-17` add - `import { verifyAuthorityRoute, verifyProviderSessionProof, isLoopbackEndpoint, type ... } from "cultnet-ts/authority";` - (the package already imports `cultnet-ts/contracts` at `:2-17`, so - resolution is proven). `:536` and `:914` call the imported function - unchanged. `:944-951` call `verifyProviderSessionProof`. `:961` and `:965` - are gone with the function. -- `packages/cultmesh-browser/tsconfig.json` unchanged (`moduleResolution: - "Bundler"` already resolves the `exports` map). - -Verification: - -- `npm run test --workspace packages/cultnet-ts` (build + unit; pins the - shared verifier and the vector file). -- `npm run test --workspace packages/cultmesh-browser` (all 17 existing tests - at `test/cultmesh-browser.test.ts:29-472` must pass unchanged; they pin the - error strings and the refusal order, including "rejects a mutated or expired - signed route before opening a provider socket" at `:239-258`). -- `dotnet test tests/GameCult.Mesh.Tests --filter FullyQualifiedName~AuthorityProof` - (vector generation/verification; focused, one project). -- `node scripts/test-typescript-package-closure.mjs` (the packed - `cultmesh-browser` tarball must resolve `cultnet-ts/authority` from the - registry-shaped install at `scripts/test-typescript-package-closure.mjs:63-72`). -- Negative greps (must return nothing): - `rg -n "crypto\.subtle\.(verify|importKey)|function (verifyAuthorityRoute|canonicalRoute|canonicalSession|canonicalFields|verifyP256|isLoopbackEndpoint|isProtectedEndpoint|isUnsignedCertificate)" packages/cultmesh-browser/src packages/cultmesh-ts/src` - and `rg -n "cultmesh-browser" packages/cultmesh-ts/package.json packages/cultnet-ts/package.json`. - *(The name list grew by two after the fix batch: `isProtectedEndpoint`, - written fresh as the C# rule, and `isUnsignedCertificate`, the shared - reading of "unsigned" the browser's session check now uses. Soul noted - the grep pins names, not structure; a shim under another name passes it.)* -- Operator-only: none. - -## 7. Cut 2 (behaviour, pure TypeScript): the realtime frame codec - -Purpose: byte parity with `CultMeshRealtimeWireProtocol` before any transport -exists, proven in both directions with shared vectors. - -Deletes: none. - -Adds: - -- `packages/cultmesh-ts/src/realtime-wire.ts` (about 130 lines). Exports - `CULTMESH_REALTIME_ALPN = "cultmesh-state-v1"`, - `CULTMESH_REALTIME_CONNECTION_CLOSE_CODE = 0x43554c54n`, - `CULTMESH_REALTIME_STREAM_ABORT_CODE = 0x53544154n`, - `CULTMESH_REALTIME_RELIABLE_STREAM = 1`, `CULTMESH_REALTIME_LATEST_ONLY_STREAM = 2`, - `CULTMESH_REALTIME_MAX_PAYLOAD_BYTES = 64 * 1024 * 1024`, - `CULTMESH_REALTIME_MAX_ENCODED_FRAME_BYTES` (= max payload + 37 + 3 * 65535, - matching `CultMeshRealtimeWireProtocol.cs:20`), type - `CultMeshRealtimeDelivery = "reliable-ordered" | "latest-only" | "unreliable"` - with wire bytes 0/1/2 in that order (`CultMeshRealtimeTransports.cs:8-13`), - interface `CultMeshRealtimeFrame { channelId; schemaId; bodyId; - producerEpoch: bigint; sequence: bigint; delivery; payload: Uint8Array }`, - `encodeRealtimeFrame(frame): Uint8Array`, `decodeRealtimeFrame(bytes): - CultMeshRealtimeFrame`. Layout exactly `CultMeshRealtimeWireProtocol.cs:37-54` - (magic `0x31545343` LE u32, delivery u8, epoch i64 LE, sequence i64 LE, - three u16 LE lengths, payload i32 LE, header size i32 LE = 37, version u16 - LE = 1, then UTF-8 identities, then payload). Decode rejections match - `:60-76` one for one: truncated header, wrong magic, unsupported version or - header size, delivery out of range, negative payload length, length sum - mismatch. Epoch and sequence are `bigint` because i64 exceeds the safe - integer range; validation mirrors `CultMeshRealtimeTransports.cs:29-39` - (non-empty identities, non-negative epoch/sequence). -- `contracts/cultmesh/realtime-frame-vectors.json`: written by a new C# test - `tests/GameCult.Mesh.Tests/CultMeshRealtimeWireProtocolTests.cs` under - `CULTMESH_WRITE_VECTORS=1` and otherwise asserted against. Cases: one frame - per delivery mode with small payload; empty payload; identities at exactly - 65,535 UTF-8 bytes (multi-byte characters included so byte length and - character length differ); epoch and sequence at `long.MaxValue`; and a - 64 MiB-payload case recorded as `{ sha256OfEncoding, encodedLength }` rather - than bytes. Malformed cases: wrong magic, version 2, header size 36, - delivery 3, payload length -1, length sum off by one, each with the C# - exception message. There is no existing C# test for this codec - (`rg CultMeshRealtimeWireProtocol tests` returns nothing `(probe)`), so this - is also the first direct C# codec test. -- `packages/cultmesh-ts/test/realtime-wire.test.ts` (about 120 lines): every - vector decodes to the recorded fields and re-encodes to the recorded bytes; - every malformed vector throws; the 64 MiB case is built in-process and its - SHA-256 compared; TypeScript-produced bytes for the same fields equal the - C#-produced bytes (this direction is what "TypeScript encodings decode in - C#" means when the vector file is the medium; the cross-process direction is - cut 5). -- `packages/cultmesh-ts/src/index.ts:37-40` gains `export * from "./realtime-wire";`. - -Verification: - -- `dotnet test tests/GameCult.Mesh.Tests --filter FullyQualifiedName~RealtimeWireProtocol`. -- `npm run test --workspace packages/cultmesh-ts`. -- Negative grep: `rg -n "0x31545343|cultmesh-state-v1" packages --glob '!**/dist*/**'` - must hit only `realtime-wire.ts` and its test in TypeScript (one codec). -- Operator-only: none. - -## 8. Cut 3 (native, subtraction then behaviour): the runtime-neutral bridge - -Purpose: one MsQuic body for Unity and Node, two roles, two platforms, no -callbacks across the host boundary. - -Deletes first (in `native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp`): - -- `:1-3` Windows includes; `:18-22` `__declspec` macros; `:51-63` per-client - `Client` with its own `api/registration/configuration`; `:184-200` - `CertificateMatchesPin` as the trust path; `:288-305` `CloseHandles`; - `:309-393` `cultmesh_quic_open` as the primary API. About 200 of 440 lines - are removed or rewritten; the framing consumer (`:123-157`), stream callback - (`:159-182`), trace/error helpers (`:65-86`, `:202-221`) are kept in spirit - and re-homed on the runtime. -- `CMakeLists.txt:4-6` (Windows-only fatal) and `:7-9` (`MSQUIC_ROOT` - mandatory) are replaced by a platform branch. - -Adds (C ABI v2, all `extern "C"`, exported with a portable macro -`CULTMESH_API` that is `__declspec(dllexport)` on MSVC and -`__attribute__((visibility("default")))` elsewhere): - -``` -int32_t cultmesh_quic_runtime_open(const char* app_name, void** out_runtime); -void cultmesh_quic_runtime_close(void* runtime); -int32_t cultmesh_quic_listener_open(void* runtime, const char* host, uint16_t port, - const uint8_t* pkcs12, int32_t pkcs12_len, const char* password, - uint64_t* out_listener_id, uint16_t* out_bound_port); -void cultmesh_quic_listener_close(void* runtime, uint64_t listener_id); -int32_t cultmesh_quic_connection_open(void* runtime, const char* host, uint16_t port, - uint64_t* out_connection_id); -int32_t cultmesh_quic_connection_certificate_complete(void* runtime, uint64_t connection_id, - int32_t accept); -void cultmesh_quic_connection_shutdown(void* runtime, uint64_t connection_id, uint64_t code); -int32_t cultmesh_quic_stream_open(void* runtime, uint64_t connection_id, uint8_t kind, - uint64_t* out_stream_id); -int32_t cultmesh_quic_stream_send_frame(void* runtime, uint64_t stream_id, - const uint8_t* encoded_frame, int32_t length, int32_t fin); -void cultmesh_quic_stream_shutdown(void* runtime, uint64_t stream_id, uint64_t code); -int32_t cultmesh_quic_next_event(void* runtime, int32_t timeout_ms, - cultmesh_quic_event* out_event, uint8_t* payload, int32_t payload_capacity, - int32_t* out_required); -int32_t cultmesh_quic_last_error(void* runtime, char* destination, int32_t capacity); -``` - -- `cultmesh_quic_event` is a fixed 64-byte struct: `uint32 type; uint32 - stream_kind; uint64 listener_id; uint64 connection_id; uint64 stream_id; - uint64 code; int32 status; int32 payload_length; uint8 reserved[16]`. - Types: 1 `listener_new_connection`, 2 `connection_connected`, 3 - `connection_certificate_received` (payload = DER), 4 `connection_shutdown` - (payload = UTF-8 reason), 5 `stream_started` (inbound, `stream_kind` set - from the first byte), 6 `stream_frame` (payload = one whole encoded frame, - length prefix stripped), 7 `stream_send_complete`, 8 `stream_shutdown`, 9 - `listener_stopped`. `next_event` returns 0 on timeout, 1 with the event - filled and payload copied, 2 when `payload_capacity` is too small (event - stays at the head; `out_required` set), negative on error. This is the v1 - two-phase poll convention (`:400-418`) applied to a queue of typed events. -- Client connections use `QUIC_CREDENTIAL_TYPE_NONE` with - `INDICATE_CERTIFICATE_RECEIVED | DEFER_CERTIFICATE_VALIDATION | - USE_PORTABLE_CERTIFICATES` (already at `:358-364`), return - `QUIC_STATUS_PENDING` from the certificate event, enqueue event 3, and call - `ConnectionCertificateValidationComplete` only when the host calls - `certificate_complete` (P11: `msquic.h:132-133,142,1290`). Timeout: the - bridge sets a 10 s handshake idle; if the host never answers, MsQuic's - handshake timeout closes the connection and event 4 is emitted. -- Listeners load `QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12` - (`msquic.h:123,394-398`), one credential type for Schannel and OpenSSL; the - provider's advertised pin is the SHA-256 of the DER certificate computed on - the TypeScript side from the same PKCS12 with `node:crypto` (no hashing in - C). -- Settings mirror the C# server/connector: `PeerUnidiStreamCount 1024` - (`CultMeshQuicRealtimeTransport.cs:77`, `:202`), idle timeout 30 s and - keep-alive 5 s as in the existing bridge (`:335-338`). -- `stream_send_frame` copies the bytes, prepends the 4-byte LE length, calls - `StreamSend` (with `QUIC_SEND_FLAG_FIN` when `fin`), and emits event 7 on - `QUIC_STREAM_EVENT_SEND_COMPLETE`. `stream_open` writes the kind byte as the - first send. Framing therefore lives in C on both directions, exactly where - the v1 bridge already keeps it (`:123-157`), and `CultMeshQuicRealtimeProtocol` - keeps it in C# (`CultMeshQuicRealtimeTransport.cs:635-655`). -- The v1 exports `cultmesh_quic_open/state/poll/error/close` are kept, Windows - only (`#ifdef _WIN32`), implemented on top of a private runtime with the pin - check retained from `:184-200`. External contract protected: the Unity - package `DllImport` at `CultMeshNativeQuicRealtimeTransport.cs:259-277` and - `CanConnect`'s Windows gate at `:39-41`. They delegate; they decide nothing - new. -- `CMakeLists.txt`: Windows branch unchanged in effect (MSVC, `/Brepro`, - `MSQUIC_ROOT` from the NuGet layout, links `msquic crypt32 bcrypt`); Linux - branch links `msquic` from `MSQUIC_LIB_DIR` (the extracted deb's - `usr/lib/x86_64-linux-gnu`) with headers from `MSQUIC_INCLUDE_DIR`, `-fvisibility=hidden`, - output `libgamecult_mesh_quic_native.so`, `RPATH $ORIGIN` so the sibling - `libmsquic.so.2` resolves. -- `scripts/build-quic-native.sh` (about 70 lines): fetches - `libmsquic_2.5.9_amd64.deb` from the packages.microsoft.com pool URL in P7, - verifies its SHA-256, extracts with `dpkg-deb -x`, fetches the three headers - at tag `v2.5.9` (P10) and verifies their SHA-256 (record the hashes at first - run into the script, the same way `build-quic-native.ps1:14` pins the - NuGet), configures CMake with Ninja, and copies `libgamecult_mesh_quic_native.so`, - `libmsquic.so.2`, and the MsQuic LICENSE into `artifacts/quic-native/linux-x64`. -- `native/GameCult.Mesh.Quic.Native/README.md` rewritten to describe both - roles, both platforms, the v1/v2 split, and the "no host callbacks" rule. - -Per-file changes outside `native/`: - -- `scripts/build-quic-native.ps1:54-58` output path becomes - `artifacts/quic-native/win32-x64` by default (parameter default at `:4`); - callers `build-unity-package.ps1:80-82` and the Native.Tests csproj `:20-22` - pass explicit `-OutputDirectory` today, so they are unaffected. -- No change to `src/GameCult.Mesh.Quic.Native/*.cs`. The Unity managed - connector keeps polling v1. - -Verification: - -- Windows: `powershell -File scripts/build-quic-native.ps1` then - `dotnet test tests/GameCult.Mesh.Quic.Native.Tests` (the csproj rebuilds the - bridge itself at `:20-22`; all four tests at - `CultMeshNativeQuicRealtimeTransportTests.cs:15-141` must pass, including the - wrong-pin refusal at `:79-99` and the departed-client test at `:101-141`). - This is the regression gate for the v1 shim. -- Windows FFI smoke, before any TypeScript transport exists: - `scratchpad`-style script (to be committed as - `packages/cultmesh-ts/test/realtime-quic-native.test.ts` in cut 4) that - opens a runtime, a listener with a PKCS12 generated by `openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 ... | openssl pkcs12 -export` - (P13), a client connection to it, answers event 3 with accept, sees event 2 - on both sides, opens a latest-only stream, sends one frame with `fin`, and - reads event 6 on the server side with the identical bytes. -- Linux, development loop: build the committed image - `scripts/quic-native-linux-dev.Dockerfile`, pinned to the same `debian:13` - digest as the release workflow, and follow the recipe in the bridge's own - README. The image carries the compiler, Ninja, Node, `setarch` and the - library's runtime dependencies, and the sanitizer configurations need the - container's default seccomp profile relaxed so randomisation can be - disabled. The README and the Dockerfile header own that recipe; this map - does not restate it. This is a Linux build on a Linux host; it is not the - release artifact (Q6). *(The earlier one-line `docker run` recipe here - installed no JavaScript runtime and could not run the mutation runner at - all, and said nothing about randomisation or seccomp, which is how the - Linux path came to be red for everyone but the agent that had found the - flags by hand.)* -- Build economy: the only builds are the native CMake target and - `tests/GameCult.Mesh.Quic.Native.Tests` (which pulls `GameCult.Mesh.Quic`, - `GameCult.Mesh.Quic.Native`, `GameCult.Mesh`, `GameCult.Networking`, - `GameCult.Caching` by project reference). Before the first `dotnet build`, - take `Get-ChildItem -Recurse F:\Projects\CultLib\bin,F:\Projects\CultLib\obj,F:\Projects\CultLib\artifacts | Select FullName,Length` - to a scratch file and diff afterwards; restore or delete anything outside - those five projects' outputs. -- Negative greps: `rg -n "CryptHashCertificate2|wincrypt" native/` must hit - only inside the `#ifdef _WIN32` v1 block; `rg -n "windows.h" native/` only - inside `#ifdef _WIN32`. -- Operator-only: rebuilding and re-committing the Unity plugin DLL - (`unity/org.gamecult.cultlib/Runtime/Plugins/x86_64/gamecult_mesh_quic_native.dll`) - and cutting a Unity package version through `scripts/build-unity-package.ps1` - is a release action; the map does not schedule it. Until it happens, Unity - keeps the old DLL, which is fine because v1 exports are unchanged. - -## 9. Cut 4 (behaviour): Node binding, consumer, session manager, trust - -Purpose: a TypeScript consumer that connects by advertised candidate, verifies -the Odin route through the cut-1 module, pins the TLS certificate, and -receives frames from the C# managed provider in a separate process. - -Deletes: none. - -Adds: - -- `packages/cultmesh-ts/src/realtime-quic-native.ts` (about 260 lines): the - koffi binding. Resolves the binary directory as `CULTMESH_QUIC_NATIVE_DIR` - when set (the development loop and CI point it at - `artifacts/quic-native/` straight from a build), otherwise - `path.join(__dirname, "..", "native", `${process.platform}-${process.arch}`)`, - the committed tree cut 6 lands (Q5 C; `__dirname` is `dist/` at runtime, so - the path holds in the repo, in an `npm pack` tarball, and in a pnpm `file:` - copy alike). No `node_modules` lookup, no platform package, no registry. - When neither directory holds `msquic` and the bridge, throw one error naming - both paths tried and the env var; until cut 6 lands, that is the error every - caller outside the test suite gets. Loads `msquic` first, then the bridge, by absolute path - (the probe showed the dependent library must be resolvable before the - bridge loads). Declares the twelve v2 prototypes. Exposes - `CultMeshQuicNativeRuntime` with a single event pump: a loop that awaits - `nextEvent.async(runtime, 250, ...)` and dispatches typed events to - registered listeners/connections by id. One pump per process-wide runtime; - reference-counted open/close. No koffi callbacks anywhere. -- `packages/cultmesh-ts/src/realtime-quic.ts` (about 650 lines across cuts 4 - and 5). Cut 4 lands: `CultMeshQuicRealtimeTransport` (implements - `sendFrame`, `receiveFrame`, `dispose`, `transportId = "msquic-realtime"`, - `endpoint`; the `isVerifiedFor(verseId, authorityRuntimeId, protocolId, - routeGeneration)` check mirroring `CultMeshQuicRealtimeTransport.cs:352-361`), - `CultMeshQuicRealtimeConnector` (`connectorId`, `priority`, `canConnect(candidate)`, - `connect(candidate, target, signal)`), and the receive path: stream kind - vs frame delivery consistency (`:519-524`), and the per-`(channel, body)` - generation filter that drops older `(producerEpoch, sequence)` (`:538-560`). - Certificate decision on event 3: caller `validateProviderCertificate(target, - der)` if supplied, else SHA-256 of DER equals the endpoint's `cert-sha256` - (`:111-119`, case-insensitive hex); otherwise reject. Endpoint parsing: - scheme `cultmesh-state+quic`, host, port, optional pin (`:98-109`). -- `CultMeshQuicRealtimeSessionManager` in the same file: takes an - `ICultMeshRealtimeLookupSource`-shaped port `{ resolve(target): Promise }`, - a trust policy from `cultnet-ts/authority`, and connectors. Binds - candidates from `authorityRoutes` whose `protocolIds` include - `cultmesh.realtime_state.v1` (`CultMeshSessions.cs:77`) and whose - `authorityRuntimeId` matches; verifies each with `verifyAuthorityRoute` - before any connector is asked; orders by connector priority then route - priority; races at most `maxRacedCandidates` per tier (`:833-880`); requires - `isVerifiedFor` after connect (`:885-896`); keys sessions by - `verseId + "\u001f" + authorityRuntimeId` (`:46`); marks offline on transport - failure. Ships with `CultMeshStaticRealtimeLookupSource` (an array of - `CultMeshVerseDescriptorMessage` from `cultnet-ts/contracts:350-369`). No - Odin WebSocket rendezvous in Node in this migration (Q7). -- `CultMesh` facade (`packages/cultmesh-ts/src/index.ts:4700`) gains statics - beside the RUDP ones at `:6008-6186`: `parseQuicRealtimeEndpoint`, - `createQuicRealtimeConnector(options)`, `createQuicRealtimeSessionManager(options)`, - and in cut 5 `createQuicRealtimeProvider(options)`. -- `packages/cultmesh-ts/package.json:44-48` gains `"koffi": "3.3.0"` (exact). - No `optionalDependencies`: under Q5 C the binaries are files of this - package, not packages of their own. `koffi` is required lazily inside - `realtime-quic-native.ts` so consumers that never touch QUIC (AetheriaEve - Electron, Odin, Stonks, weksa) load nothing native. `koffi` itself is a - registry dependency like `@msgpack/msgpack` (`:45`); every consumer host - already installs from the registry (`deploy-streampixels-preview.sh:102`), - so this adds no new kind of fetch. -- `packages/cultmesh-ts/test/realtime-quic-native.test.ts` (about 150 lines): - the cut-3 FFI smoke, now against the runtime class. -- `packages/cultmesh-ts/test/realtime-quic-consumer.test.ts` (about 250 - lines): TypeScript consumer against a TypeScript listener opened through - the raw runtime (no provider semantics yet): connect with correct pin; - refuse wrong pin (`cert-sha256` of 64 zeros, mirroring - `CultMeshNativeQuicRealtimeTransportTests.cs:79-99`); refuse missing - certificate when no validator; caller validator observed with the target - identity; generation filter drops a late older generation (mirrors - `CultMeshQuicRealtimeTransportTests.cs:111-140`). -- Trust negatives, each a separate test with its own mutation, in the same - file, through the session manager with a static lookup source and a signed - route built with `node:crypto`: (a) expired certificate (`now` past - `expiresAt`); (b) unsigned remote route (certificate absent, mode - `authenticated-remote`); (c) wrong Odin root (trust has a different - `keyId`); (d) `cert-sha256` pin mismatch (route verifies, TLS pin fails, so - the connector rejects before `isVerifiedFor`); (e) replayed nonce. On the - QUIC plane there is no `session_open` nonce exchange; the route's - freshness is its generation plus the TLS handshake. The replay test - therefore mutates `generation` on the connected transport's target and - asserts `isVerifiedFor` fails and the session manager disposes the - transport (`CultMeshSessions.cs:885-896`). If the operator wants a nonce on - QUIC, that is a protocol addition on both runtimes and belongs to a later - pipeline; this map does not invent it. -- Interop lane, C# managed provider to TypeScript consumer, separate - processes: `tests/GameCult.Networking.InteropPeer/Program.cs:27-49` gains - mode `quic-realtime-serve` (`--port`, `--frames N`, `--delivery - latest-only|reliable-ordered`, `--interval-ms`): creates a self-signed - certificate exactly as `CultMeshQuicRealtimeTransportTests.cs:203-228`, - starts `CultMeshQuicRealtimeServer`, prints one JSON line - `{ endpoint: "cultmesh-state+quic://127.0.0.1:?cert-sha256=" }` - to stdout, then broadcasts `N` frames with increasing sequence and exits - after the last `send_complete` or on stdin close. - `GameCult.Networking.InteropPeer.csproj:9-11` gains a `ProjectReference` to - `src/GameCult.Mesh.Quic/GameCult.Mesh.Quic.csproj`. - `packages/cultnet-ts/test/interop/cultnet-interop.test.ts` gains - `test("CultMesh QUIC realtime: C# managed provider and TypeScript consumer", ...)` - using `spawnServeProcess` (`:2491`) for the C# peer and `runJsonCommand` - (`:2557`) for a new TypeScript peer script - `packages/cultmesh-ts/test/interop/cultmesh-quic-peer.ts` (`dial --endpoint - --expect N`) that prints the received frames as JSON (fields plus payload - hex). The harness drives processes; it does not import `cultmesh-ts` - (dependency direction: `cultmesh-ts` depends on `cultnet-ts`, so the reverse - import is forbidden). The peer script path follows the `tsPeerScript` - pattern at `:41`. - -Verification: - -- `npm run test --workspace packages/cultmesh-ts` with - `CULTMESH_QUIC_NATIVE_DIR=artifacts/quic-native/win32-x64`. -- `npm run test:interop --workspace packages/cultnet-ts` filtered with - `--test-name-pattern "QUIC realtime"`; it builds the C# interop peer through - the existing `csharpInteropPeerBuild` path (`:45-58`, `:71`). -- Negative greps: `rg -n "new Function|koffi\.register|\.async\(" packages/cultmesh-ts/src` - must show `.async(` only on `nextEvent` in `realtime-quic-native.ts` and no - `koffi.register` (no callbacks); - `rg -n "verifyP256|canonicalRoute" packages/cultmesh-ts/src` must return - nothing. -- Operator-only: none. - -## 10. Cut 5 (behaviour): TypeScript provider and the coalescing outbox - -Purpose: the StreamPixels role. A TypeScript listener that broadcasts with an -explicit delivery mode and cannot be backpressured by a slow consumer, proven -against both C# connectors in separate processes. - -Deletes: none. - -Adds (in `packages/cultmesh-ts/src/realtime-quic.ts`): - -- `CultMeshQuicRealtimeProvider.listen({ host, port, serverCertificate: - { pkcs12, password }, handshakeTimeoutMs })`: opens a listener, computes - `advertisedEndpoint` (`cultmesh-state+quic://:?cert-sha256=`, - uppercase, because the Unity connector requires the pin, P18), accepts - connections into a peer set, exposes `connectionCount`, `broadcast(frame)`, - `receive()` for client-originated frames, `dispose()`. -- Delivery semantics, mirroring `CultMeshQuicRealtimeTransport.cs`: - `reliable-ordered` opens one unidirectional stream of kind 1 per peer on - first use and serialises writes behind a per-peer promise chain; `broadcast` - resolves when every peer's `send_complete` arrives or the peer is evicted - (`:216-235`, `:237-255`). `latest-only` enqueues into a per-peer keyed - outbox (`Map<"channel\u001fbody", frame>` plus a ready queue) and returns - synchronously (`:363-367`, `:572-618`); each peer's pump opens a fresh kind-2 - stream per frame, sends with `fin`, and only dequeues the next frame after - `send_complete`, so a stalled peer accumulates at most one pending frame per - `(channel, body)` and never blocks `broadcast`. `unreliable` throws - `NotSupported` with the same sentence as `:373-375` adjusted for the - runtime. -- Peer eviction on send failure or `connection_shutdown`; no reconnect logic - on the provider. - -Interop lanes (all separate processes; all in -`packages/cultnet-ts/test/interop/cultnet-interop.test.ts`): - -- TypeScript provider to C# native connector (the Unity one): the harness - starts `cultmesh-quic-peer.ts serve --frames 5 --delivery latest-only`, - reads its advertised endpoint from stdout, then runs - `dotnet test tests/GameCult.Mesh.Quic.Native.Tests --filter FullyQualifiedName~NativeConnectorReceivesFromExternalManagedProvider` - with `CULTMESH_NATIVE_EXTERNAL_ENDPOINT=` (the existing test at - `CultMeshNativeQuicRealtimeTransportTests.cs:15-33` is reused unchanged: it - already asserts a frame arrives with non-empty schema, body and payload). - Rename the test to `NativeConnectorReceivesFromExternalProvider` since the - provider is no longer necessarily managed; the env var name stays. -- TypeScript provider to C# managed connector: add - `ManagedConnectorReceivesFromExternalProvider` to - `tests/GameCult.Mesh.Quic.Tests/CultMeshQuicRealtimeTransportTests.cs`, - gated by the same `CULTMESH_NATIVE_EXTERNAL_ENDPOINT`, using - `CultMeshQuicRealtimeTransportConnector` with the pin from the endpoint - (`:111-119`) and no validator, asserting frame fields and payload bytes - equal what the TypeScript peer prints. The harness runs it the same way. -- `LatestOnly` under a stalled consumer: `cultmesh-quic-peer.ts serve - --frames 200 --delivery latest-only --interval-ms 1` while the harness dials - twice with the TypeScript consumer, pauses one consumer's pump for 500 ms - (a test hook on the runtime that stops calling `next_event`), and asserts: - the provider's 200 `broadcast` calls complete within a bounded time - regardless of the pause; the healthy consumer reaches sequence 199; the - paused consumer, once resumed, converges on 199 with fewer than 200 frames - received. This is the TypeScript form of - `CultMeshNativeQuicRealtimeTransportTests.cs:101-141` plus the convergence - assertion from `CultMeshQuicRealtimeTransportTests.cs:111-140`. -- Golden bytes across processes: the C# managed connector lane above prints - the received frame's re-encoding (via `CultMeshRealtimeWireProtocol.EncodeFrame`) - as hex; the harness compares it with the TypeScript peer's `encodeRealtimeFrame` - output for the same frame. That closes "TypeScript encodings decode in C#" - by process, not by shared file. - -Verification: - -- `npm run test --workspace packages/cultmesh-ts` (provider unit tests with - the TypeScript consumer in-process but separate connections: reliable - ordering in both directions mirrors `CultMeshQuicRealtimeTransportTests.cs:71-110`; - latest-only coalescing; unreliable fails closed). -- `npm run test:interop --workspace packages/cultnet-ts --test-name-pattern "QUIC realtime"`. -- `dotnet test tests/GameCult.Mesh.Quic.Tests` and - `dotnet test tests/GameCult.Mesh.Quic.Native.Tests` without the env var - (the new tests `Assert.Ignore`, the existing ones still pass). -- Negative greps: `rg -n "setInterval|setTimeout" packages/cultmesh-ts/src/realtime-quic.ts` - must show no polling of the bridge (the pump is the only wait); - `rg -n "reconnect" packages/cultmesh-ts/src/realtime-quic.ts` must return - nothing on the provider side. -- Operator-only: none. - -## 11. Cut 6 (packaging and release, remapped under Q5 C) - -Purpose: a consumer host with no toolchain and no registry access for the -binding gets it by receiving the `cultmesh-ts` package directory, which is how -every consumer already receives the package (P16, P17). Registry publication -is parked, not ruled out; the seam it reattaches to is named at the end of -this section. - -### 11.1 Body facts this cut stands on - -- The deploy tarball is a `git archive`. The Idunn actuator on Starfire runs - `git -C CultLib archive --format=tar --output= origin/main packages/cultnet-ts packages/cultcache-ts` - (`F:\Projects\Odin\scripts\deploy-yggdrasil-streampixels.ps1:59`), uploads - it by `sftp` (`:127`), and `deploy-streampixels-preview.sh:95-99` extracts it - into `/srv/streampixels/CultLib` after deleting only those two package - directories (`:97`) `(source read)`. Two consequences: only committed files - ride (a `git archive` cannot carry untracked or ignored files), and - `packages/cultmesh-ts` is not in the archive today at all, although - StreamPixels declares it (`apps/service/package.json:26`). Adding it to the - archive list and to `:97` is deploy work in Odin and gamecult-ops, outside - this campaign (section 16); the Yggdrasil smoke below therefore ships its - own archive of the same shape rather than waiting on that change. -- pnpm materialises a `file:` directory dependency as a copy of the - package's `files` entries only: with `pnpm 10.33.0`, `node_modules/cultmesh-ts` - held `README.md`, `dist`, `package.json` and nothing else (no `src`, no - `test`) `(probe: scratch consumer with file: overrides)`. `files` is the - gate, so `native` must be listed in it. -- The MsQuic binaries the koffi probe loaded (P2) are the Unity plugin copies - at `unity/org.gamecult.cultlib/Runtime/Plugins/x86_64/` (`probe.js:4-7`), - committed in plain git (`git ls-files`; `.gitattributes` is `* text=auto` - only, no LFS), `gamecult_mesh_quic_native.dll` 40,448 bytes and - `msquic.dll` 536,928 bytes `(probe)`. Committing binaries beside the code - that loads them is therefore existing practice in this repo, not a new one. -- The Linux runtime is one file: `libmsquic.so.2 -> libmsquic.so.2.5.9`, - 7,375,872 bytes, inside the pinned deb (P7); the deb also carries - `libmsquic.lttng.so.2.5.9` and `datapath_raw_xdp_kern.o`, neither needed - `(probe: dpkg-deb -c in debian:13)`. The repo pack is 31.68 MiB today - `(probe: git count-objects)`. -- `debian:13` resolved to digest - `sha256:f324c7ff54321e8d9c588493a20244965938ce0aa50bbd1022d38010e9ffc4b1` - on 2026-09-16 and carries `g++ 4:14.2.0-1` `(probe: docker pull; apt-cache - policy)`. The builder is pinned by that digest, not by the moving tag. -- `GameCult/CultLib` is public `(probe: gh repo view)` and already carries two - GitHub Releases with binary assets, `cultlib-unity-v1.0.3` - (`org.gamecult.cultlib-1.0.3.tgz`) and `gamecult-geometry-v0.1.0` (a crate - and nupkgs) `(probe: gh release view)`; nothing in `scripts/`, `docs/` or - `.github/` creates them, so they were cut by hand `(source read: rg)`. - Release assets on a public repo download with plain `curl`, no token. -- The npm registry is reachable from Starfire: `npm ping` answers `PONG`, - `npm view koffi` is HTTP 200, and `npm view @gamecult/cultcache-ts` is a - 404 because it was never published `(probe)`. This confirms the corrected - premise in section 13: C is deferral, not necessity. -- `.gitignore` ignores `artifacts/` (`:66`) and `node_modules`; it has no rule - for `*.so` or `*.dll` `(source read)`, so nothing blocks the commit path. -- The root `package-lock.json` is committed `(probe: git ls-files)`, so - `npm ci` is the real install path (as `publish-packages.yml:55` uses it); - `cultnet-interop.yml:95` uses `npm install --no-package-lock` instead, a - pre-existing inconsistency this cut does not touch. - -### 11.2 Q8, the fork C surfaces (operator decision, recommended option first) - -Where do the built binaries live so that the `git archive` above carries -them to the host? - -- **Option 1, commit them.** `packages/cultmesh-ts/native/{win32-x64,linux-x64}/` - hold the four binaries, committed by the operator from the Release assets - the workflow attaches, with `MANIFEST.txt` and `SHA256SUMS` beside them. - Price: about 8.0 MB in the tree (7,375,872 + 536,928 + 40,448 + the bridge - `.so`, on the order of 60 KB); pack growth roughly the compressed size, - about 3 MB, and that only when the MsQuic pin moves, because - `libmsquic.so.2` and `msquic.dll` are copies of Microsoft's files and - change with the pin, not with the bridge. A bridge rebuild adds tens of KB. - A CI job checks `sha256sum -c SHA256SUMS` on every push, so the manifest - and the bytes cannot drift. Deploy path change required: none beyond the - `packages/cultmesh-ts` archive-list fix already owed. Human step: download, - verify, commit (operator-only, section 11.7). -- **Option 2, fetch them.** `native//` is git-ignored; the tree - commits only `MANIFEST.txt`, `SHA256SUMS` and a `scripts/fetch-quic-native.mjs` - (about 80 lines) that downloads the Release assets and verifies digests. - Price: zero binary bytes in git, but every carrier of the package directory - becomes incomplete until the fetch runs: a fresh clone, every worktree, - Heimdall's vendored copy, `npm pack` (a tarball without binaries looks - valid), and the actuator, which must run the fetch and then `tar --append` - the ignored files after `git archive` (cross-repo edit in Odin), or the - deploy script must fetch from GitHub on Yggdrasil at deploy time (cross-repo - edit in gamecult-ops, plus GitHub egress the StreamPixels path does not - have today). It is the "tarball with a `.so` in it by hand" failure the - original Q5 text warned about, moved one step left. - -**Recommended: Option 1.** The tarball is a `git archive`, so committed is the -only state that rides it without a second mechanism; the repo already commits -the same `msquic.dll` for Unity; and the growth is bounded by the MsQuic pin, -not by bridge iteration. Everything below is written for Option 1; Option 2 -changes only 11.4's manifest paragraph, the closure smoke, and the operator -steps, and is not mapped further unless chosen. - -**Ruled 2026-09-16: Option 1.** Operator: "Commit them, yeah." Option 2 is -history. - -### 11.3 Deletes - -None in the tree. The ruling-A surfaces (`packages/cultmesh-quic-native/*`, -`optionalDependencies`, `cultnet-ts`/`cultmesh-ts` publish jobs, new tag -prefixes in `publish-packages.yml:20-24`) are never created; that is the -subtraction, and it is an estimate change, not a diff (section 11.8). - -The existing `@gamecult/cultcache-ts` publish job -(`.github/workflows/publish-packages.yml:39-78`) stays. It is out of this -campaign's scope: it publishes a package this migration does not touch, its -only consumer today reaches it by `file:` (`F:\Projects\Heimdall\package.json:22` -`(source read)`), and it is the shape the parked registry pass will copy for -`cultnet-ts` and `cultmesh-ts`. Whether it should run before then is a -question for that pass. - -### 11.4 Keeps and moves - -- `scripts/build-quic-native.ps1` and the Unity plugin binaries are untouched - (5.4 deletion line). `scripts/build-quic-native.sh` is the cut-3 script, - unchanged here. -- The MsQuic license text already committed at - `unity/org.gamecult.cultlib/Third Party Notices/MSQUIC-LICENSE.txt` is - copied, not referenced, to `packages/cultmesh-ts/native/MSQUIC-LICENSE.txt`, - because the package directory must be self-contained once copied out of the - repo (11.1, pnpm). Same MIT text for both platforms. - -### 11.5 Adds - -- `packages/cultmesh-ts/native/win32-x64/gamecult_mesh_quic_native.dll`, - `packages/cultmesh-ts/native/win32-x64/msquic.dll`, - `packages/cultmesh-ts/native/linux-x64/libgamecult_mesh_quic_native.so`, - `packages/cultmesh-ts/native/linux-x64/libmsquic.so.2` (the real file, not - the symlink; `RPATH $ORIGIN` from cut 3 resolves it beside the bridge). - Directory names are exactly `${process.platform}-${process.arch}` so the - cut-4 resolver needs no table. -- `packages/cultmesh-ts/native/SHA256SUMS`: `sha256sum` format, one line per - binary, relative paths, generated by the workflow and committed verbatim. -- `packages/cultmesh-ts/native/MANIFEST.txt` (about 20 lines, `key=value`): - `msquic.version=2.5.9`; `msquic.windows.source` = the NuGet URL at - `build-quic-native.ps1:30` with its SHA-256 from `:14`; - `msquic.linux.source` = the deb pool URL from P7 with its SHA-256; - `bridge.commit` = the CultLib commit the bridge was built from; - `build.workflow_run` = the Actions run URL; `build.release` = the Release - tag; `build.win32-x64.host` = runner image plus MSVC version as printed by - the job; `build.linux-x64.host` = `ubuntu-latest` plus the `debian:13` - digest plus `g++` version as printed; and the date. Every value is copied - from the run log by the operator, then the CI check below keeps the file - and the bytes agreeing. The binding never reads this file; it exists for - readers and for the digest check. -- `.github/workflows/quic-native.yml` (about 120 lines), four jobs: - - `build-win32-x64` on `windows-latest`: checkout, run - `scripts/build-quic-native.ps1 -OutputDirectory artifacts/quic-native/win32-x64`, - print `cl.exe` version and `Get-FileHash` of both files, upload - `actions/upload-artifact` named `quic-native-win32-x64`. - - `build-linux-x64` on `ubuntu-latest` with - `container: debian:13@sha256:f324c7ff54321e8d9c588493a20244965938ce0aa50bbd1022d38010e9ffc4b1` - (Q6 A; the digest is the pin, the tag is the label): `apt-get install -y - cmake ninja-build g++ curl ca-certificates dpkg`, run - `scripts/build-quic-native.sh`, print `g++ --version` and `sha256sum`, - upload `quic-native-linux-x64`. No Node in this job; loading is proven by - the interop job below, on the same image. - - `release`, `needs` both, `if: startsWith(github.ref, 'refs/tags/cultmesh-quic-native-v')`, - `permissions: contents: write`: download both artifacts, write - `SHA256SUMS` and a draft `MANIFEST.txt` with every value the jobs printed, - and run `gh release create "$GITHUB_REF_NAME" --verify-tag` with the two - per-platform `.tar.gz` files, `SHA256SUMS` and `MANIFEST.txt` as assets - (`GH_TOKEN: ${{ github.token }}`; `gh` is preinstalled on hosted runners, - no third-party release action). The release notes are the manifest. - - `verify-committed` on `push` and `pull_request`, `ubuntu-latest`, one - step: `cd packages/cultmesh-ts/native && sha256sum -c SHA256SUMS`. This is - the check that the tree's bytes are the bytes the manifest names. - - Triggers: `push` to `main` and `pull_request` run `verify-committed` - only; `workflow_dispatch` runs the two builds (dry run, uploads - artifacts, no release); a `cultmesh-quic-native-v*` tag runs all four. - Only `release` has write permission. -- `packages/cultmesh-ts/package.json:14-16`: `"files": ["dist", "native"]`. - No version bump: under C nothing keys on the version; provenance keys on - the commit in `MANIFEST.txt`. -- `packages/cultmesh-ts/src/realtime-quic-native.ts` (cut 4): the runtime - class gains a readonly `nativeDirectory` (the absolute directory it loaded - from). Diagnostic only; the closure smoke asserts on it. -- `scripts/test-typescript-package-closure.mjs`: - - `:39-41`: for `cultmesh-ts`, assert the packed file list contains all - four binaries, `native/SHA256SUMS`, `native/MANIFEST.txt` and - `native/MSQUIC-LICENSE.txt`, on every host (the tarball carries both - platforms; the host only decides which loads). - - `:59-70`: the runtime smoke adds - `assert.equal(typeof mesh.CultMesh.createQuicRealtimeConnector, "function")`, - the same for `createQuicRealtimeProvider`, then opens a - `CultMeshQuicNativeRuntime`, asserts - `runtime.nativeDirectory` ends with `node_modules/cultmesh-ts/native/` - (path separators normalised), and closes it. The child at `:70` runs with - `CULTMESH_QUIC_NATIVE_DIR` deleted from its env so the default path is the - one exercised. The point: the binaries load from the installed copy of the - package, not from a repo path or a registry. -- `.github/workflows/cultnet-interop.yml`: - - After the C# RUDP step (`:127-128`): a step building the Windows bridge - (`scripts/build-quic-native.ps1 -OutputDirectory artifacts/quic-native/win32-x64`) - and a step running the `QUIC realtime` lanes with - `CULTMESH_QUIC_NATIVE_DIR` set to that directory, so CI proves the lanes - against a fresh build, then a second run of - `node scripts/test-typescript-package-closure.mjs` proves the committed - Windows binaries load without the env var. - - A second job `interop-quic-linux` on `ubuntu-latest` with the same pinned - `debian:13` container: `apt-get install` the build tools plus `libicu` - (dotnet's runtime need), `actions/setup-dotnet@v4` 10.0.x and - `actions/setup-node@v4` 24 (both work inside a container), build the - bridge with `scripts/build-quic-native.sh`, `npm ci`, run only the - TypeScript-provider-to-managed-connector and TypeScript-to-TypeScript - lanes (section 15: the native-connector lane is Windows by design), then - the closure script without the env var. The container is not optional: - the artifact is linked against Debian 13's glibc 2.41 and `ubuntu-latest` - (24.04) carries glibc 2.39 `(probe: ldd --version in both images)`, so a - symbol version the bridge or `libmsquic` references can be absent on the - bare runner; run the lanes on the image the artifact targets rather than - discover that per symbol. -- `README.md` of `packages/cultmesh-ts` gains a "QUIC Realtime Plane" section - after "RUDP Helpers" (`README.md:332`) with provider and consumer examples - matching the C# README (`src/GameCult.Mesh.Quic/README.md:13-62`), and a - "Native binaries" paragraph: where they live, that a `file:` dependency or - an `npm pack` tarball carries them, the `CULTMESH_QUIC_NATIVE_DIR` - override, the two provenance files, Windows x64 and Linux x64 (Debian 13 - glibc) only, and the four `libmsquic` runtime dependencies (P7) a Linux host - must already have. - -### 11.6 Per-file changes - -- `packages/cultmesh-ts/package.json:14-16`, `files` gains `"native"`. -- `packages/cultmesh-ts/src/realtime-quic-native.ts` (cut 4 file), one - readonly field `nativeDirectory` set at load. -- `scripts/test-typescript-package-closure.mjs:39-41`, `:59-70` as above; - `:9` unchanged (no new packages). -- `.github/workflows/cultnet-interop.yml`, two steps after `:128`, one job - after `:140`. -- `.github/workflows/quic-native.yml`, new. -- `.github/workflows/publish-packages.yml`, unchanged. -- `packages/cultmesh-ts/native/` (seven files), new, four of them binary and - operator-committed (11.7). -- `packages/cultmesh-ts/README.md`, one section after `:332`. - -### 11.7 Verification - -- `node scripts/test-typescript-package-closure.mjs` on Windows, with - `CULTMESH_QUIC_NATIVE_DIR` unset in the shell. Pins: the tarball carries - both platforms and the provenance files; the installed copy loads its own - binaries. -- `cd packages/cultmesh-ts/native && sha256sum -c SHA256SUMS` (Git Bash on - Windows). Pins: committed bytes equal the manifest. -- `git check-ignore -v packages/cultmesh-ts/native/linux-x64/libmsquic.so.2` - must exit 1 (not ignored), and - `git ls-files packages/cultmesh-ts/native | wc -l` must print 7. Pins: the - binaries are tracked, so a `git archive` carries them. -- `npm pack packages/cultmesh-ts --dry-run --json | node -p "JSON.parse(require('fs').readFileSync(0,'utf8'))[0].files.map(f=>f.path).filter(p=>p.startsWith('native/')).join('\n')"` - must list seven `native/` paths; the closure script already asserts this, - this is the one-liner for a reader. -- `workflow_dispatch` of `quic-native.yml`: both build jobs green, artifacts - present, no release created. A tag push `cultmesh-quic-native-v` - creates the Release with four assets. Pins: Q6 A, the builder is a Linux - host on the deploy OS and the artifact has a public, digest-named home. -- Negative greps (must return nothing): - `rg -n "optionalDependencies|cultmesh-quic-native-(win32|linux)|@gamecult/cultmesh-quic-native" packages scripts .github --glob '!**/node_modules/**' --glob '!**/dist*/**'` - (no platform packages exist); - `rg -n "node_modules|require\.resolve" packages/cultmesh-ts/src/realtime-quic-native.ts` - (the resolver never searches for a package); - `rg -n "\"(pre|post)install\"" packages/*/package.json` (no install-time - compile or download); - `rg -n "NPM_TOKEN|npm publish|registry-url" .github/workflows/quic-native.yml` - (the native workflow publishes to no registry). -- Operator-only, in order: - 1. After the tag build, download the Release assets, compare every digest - with the run log and with `SHA256SUMS`, place the binaries under - `packages/cultmesh-ts/native//`, fill `MANIFEST.txt` from the - log, commit. This is the only path bytes take into the tree; no workflow - writes to `main`. - 2. Yggdrasil smoke, which installs from what C ships (the archived tree) - and nothing else. On Starfire, at the commit from step 1: - `git -C F:\Projects\CultLib archive --format=tar --output=$env:TEMP\cultlib-quic-smoke.tar ` - (the actuator's own mechanism, `deploy-yggdrasil-streampixels.ps1:51,59`, - whole tree), then `sftp` it to `gamecultadmin@yggdrasil.gamecult.org:/home/gamecultadmin/`. - On Yggdrasil: - `mkdir -p /tmp/cultmesh-quic-smoke && tar -xf ~/cultlib-quic-smoke.tar -C /tmp/cultmesh-quic-smoke && cd /tmp/cultmesh-quic-smoke`; - `(cd packages/cultmesh-ts/native && sha256sum -c SHA256SUMS)` (the bytes - that arrived are the bytes the manifest names); - `ldd packages/cultmesh-ts/native/linux-x64/libmsquic.so.2 | grep "not found"` - must print nothing. If it prints, the missing ones are among - `libnuma1`, `libxdp1`, `libnl-route-3-200` (P7; `libssl3t64` is base): - under C nothing installs them because the deb itself is never installed - on the host, so `sudo apt-get install` them once and record it in - `gamecult-ops/inventory.md` beside the Node line (`:660`). Then - `npm ci` (registry access from Yggdrasil is the deploy path's own - assumption, `deploy-streampixels-preview.sh:102`) and - `node scripts/test-typescript-package-closure.mjs` with the env var - unset: this is the same smoke CI runs, now on Node 24.14.1 (P8) on the - deploy host, loading `node_modules/cultmesh-ts/native/linux-x64`. - Then the handshake: `npm run test --workspace packages/cultmesh-ts` - (builds `dist-test` and runs the cut-4/5 suites on the host), then a - throwaway PKCS12 - (`openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -subj /CN=127.0.0.1 -days 2 -keyout k.pem -out c.pem && openssl pkcs12 -export -inkey k.pem -in c.pem -passout pass:smoke -out smoke.p12`), - `node packages/cultmesh-ts/dist-test/test/interop/cultmesh-quic-peer.js serve --frames 5 --delivery latest-only --pkcs12 smoke.p12 --password smoke` - in one shell (it prints the advertised endpoint), and - `node packages/cultmesh-ts/dist-test/test/interop/cultmesh-quic-peer.js dial --endpoint --expect 5` - in a second, which must print five frames. If cut 5 landed `serve` with - a generated certificate instead of `--pkcs12/--password` flags, add the - flags in this cut; the smoke needs a certificate it can name. Finish - with `rm -rf /tmp/cultmesh-quic-smoke ~/cultlib-quic-smoke.tar`. This is - the only place the Linux artifact is proven on the deploy host, and only - the operator holds the key. - 3. Nothing here touches `/srv/streampixels`; StreamPixels adoption - (archive list, `:97`, its stale lockfile) is consumer work (section 15, - section 16). - -### 11.8 Subtraction estimate delta against section 14 - -Row 6 of the table read `0 removed, 60 (manifests) + 130 (workflow) + 30 -(closure) + 60 (README) = +280` with `+2 optional platform packages` and `+3 -publish jobs` in the dependencies line. Under C: - -- Removed: 0 (the `cultcache-ts` job stays, 11.3). -- Added text: about 120 (`quic-native.yml`) + 40 (interop workflow) + 30 - (closure) + 70 (README) + 25 (`MANIFEST.txt`, `SHA256SUMS`) + 1 - (`package.json`) = about +285, the same order as before; the 60 lines of - platform-package manifests are gone and the release/verify jobs take their - place. -- Added binary: four files, about 8.0 MB in the tree under Option 1, 0 under - Option 2. Section 14 has no column for this; it is the real price of C and - is stated here so it is not hidden in a line count. -- Dependencies line becomes: +0 optional platform packages (was +2); +0 - publish jobs (was +3); +1 workflow file with four jobs (two builds, one - release, one digest check) and +1 job in the interop workflow (was "+1 CI - job"). Runtime dependency unchanged: `koffi` only. -- Campaign total: about +3,900 source lines, unchanged; plus 8.0 MB of - committed binaries. - -### 11.9 Parked seam: registry publication (later pass) - -Not in this campaign, by the operator's choice (section 13). When it is -picked up, it reattaches here without remapping the rest: - -- `publish-packages.yml` gains `cultnet-ts` and `cultmesh-ts` jobs shaped like - `:39-78`, tag prefixes at `:20-24`, dispatch options at `:30-33`; the - `cultmesh-ts` job `needs` the two `quic-native.yml` build jobs (or the - workflow is merged) and publishes the artifacts they already produce as - `@gamecult/cultmesh-quic-native-{win32-x64,linux-x64}` platform packages. -- `packages/cultmesh-ts/package.json` gains `optionalDependencies` on those - two names; `realtime-quic-native.ts` gains a third resolution branch after - the env var and before the committed `native/` directory, or the committed - directory is retired in the same pass. -- Naming (unscoped `cultnet-ts`/`cultmesh-ts` versus `@gamecult/*`) is the - original Q5 A/B fork, still open for that pass; P14 recorded all names - unclaimed on 2026-09-16. -- Its Body precondition is an `NPM_TOKEN` repository secret minted on - npmjs.com, which the operator can now reach (section 13). - -## 12. Cut 7 (documentation and ledgers) - -- `docs/runtime-parity-scope.md:38` TypeScript row: add "CultMesh QUIC - realtime provider and consumer over CultLib-owned MsQuic bindings (Windows - x64, Linux x64), byte-parity with C#, cross-process interop lanes" to - "Claimed parity"; add "QUIC datagrams (`Unreliable`), browser QUIC" to "Not - claimed". -- `src/GameCult.Mesh/docs/transport-planes.md:35-46`: name the TypeScript - provider/consumer beside the .NET and Unity bodies; `:122-125`: state that - `CULTMESH_NATIVE_EXTERNAL_ENDPOINT` now accepts any provider and is driven - by the TypeScript interop harness. -- `docs/cultnet-transport-parity.md`: no change. It maps RUDP/TCP/LiteNetLib - ownership; the realtime plane is a CultMesh plane, not a CultNet transport - profile, and pretending otherwise would put QUIC into a document whose cut - line says "Do not put UDP packet mechanics into CultMesh" the other way - round. -- `docs/parked-features.md`: one entry, "Node Odin WebSocket rendezvous", - pointing at `cultmesh-browser/src/index.ts:84-191` as the browser owner and - the `ICultMeshRealtimeLookupSource` port as the seam (Q7). -- `docs/typescript-quic-realtime-target.md:5-7`: status line updated to point - at this map. -- Under Q5 C, the delivery story every document tells is the one in section - 11: the binding ships inside `packages/cultmesh-ts/native/`, provenance - lives in `MANIFEST.txt` and `SHA256SUMS`, and consumers keep `file:` paths. - `native/GameCult.Mesh.Quic.Native/README.md` (cut 3) and - `packages/cultmesh-ts/README.md` (cut 6) both point at `MANIFEST.txt` as the - provenance owner rather than restating versions or digests. The parity row - above says "bindings shipped in the `cultmesh-ts` package tree", not - "published". Registry publication is described in exactly one place, as - parked: section 11.9 of this map. - -Verification: `rg -n "CultMeshRealtimeTransports.cs" docs src/GameCult.Mesh/docs` -returns only correct paths; -`rg -n -i "registry|npm publish|platform package|optionalDependencies" packages/cultmesh-ts/README.md native/GameCult.Mesh.Quic.Native/README.md docs/runtime-parity-scope.md src/GameCult.Mesh/docs/transport-planes.md` -returns nothing (the only permitted mentions are this map's sections 11.9 and -13 and the target's history). - -## 13. Operator questions - -The four rulings in the target (Q1-Q4) are closed and not reopened. These are -the forks the probes surfaced. - -- **Q5. Registry names.** The binding cannot ship as prebuilt platform - packages without `cultmesh-ts` itself being on a registry, and today every - consumer uses `file:` paths and only `@gamecult/cultcache-ts` is published - (P15, P16). All candidate names are unclaimed (P14). A: publish `cultnet-ts` - and `cultmesh-ts` under their existing unscoped names (no import changes in - any of the 11 consuming repos) and put only the new native platform packages - under `@gamecult/cultmesh-quic-native-{win32-x64,linux-x64}`. B: scope - everything as `@gamecult/*` now and take the import rename across consumers - as a separate consumer task. C: no registry; ship the binaries inside the - CultLib tarball the deploy script already extracts on Yggdrasil - (`deploy-streampixels-preview.sh:95-99`), keeping `file:` consumption. - **Recommended: A.** It reshapes nothing consumers use, matches the - `cultcache-ts` precedent of scoping only what is new, and gives StreamPixels - a versioned artifact instead of a tarball with a `.so` in it. C is the - cheapest but leaves the deploy path owning a native binary by hand, which is - the failure the target's "shipped through a registry" phrase was written to - avoid. -- **Q6. Linux release builder.** A: GitHub Actions `ubuntu-latest` with - `container: debian:13` (same OS as Yggdrasil, P8), artifact published by the - workflow, verified on Yggdrasil by the operator smoke in cut 6. B: build on - Yggdrasil in the deploy script (installs CMake and g++ on a live public - host; every deploy compiles). C: build on Starfire's Docker `debian:13` - engine (P12) and publish from the workstation. **Recommended: A.** It is a - Linux host, it is reproducible from a tag, and it keeps compilers off - Yggdrasil. C is kept for the development loop only. -- **Q7. Node-side Odin rendezvous.** The TypeScript consumer needs a route - source. The browser package has an Odin WebSocket rendezvous - (`cultmesh-browser/src/index.ts:84-191`); Node 24 has a global `WebSocket`, - so it would run, but `cultmesh-ts` may not depend on `cultmesh-browser` - (Q2's spirit), and the first consumer of the Node QUIC path is the interop - harness, not a product. A: ship the lookup-source port plus a static source - now, park the Node Odin rendezvous with a note. B: move the Odin rendezvous - into `cultnet-ts` beside the verifier in this migration so Node and browser - share it. **Recommended: A.** B is the right end state but is a second - ownership move in one pipeline; it should follow once a Node consumer that - discovers through Odin exists. - -Not asked, because the target already decided them: datagrams stay out (Q4); -no TLS on TCP planes (Q1); Windows x64 and Linux x64 only (Q3); the verifier -moves to a shared browser-safe module (Q2, section 6 names the module). - -### Rulings, 2026-09-16 - -The operator took all three recommendations the same day the map was written. -Each is now a standing ruling; the options above are history. - -- **Q5 ruled A, then re-ruled C the same day.** A had `cultnet-ts` and - `cultmesh-ts` publishing under their unscoped names with only the two native - platform packages scoped. The re-ruling was first stated as necessity ("we - don't even have npm access and cannot get it because our entire subnet is - blocked"); the operator corrected that Body fact the same day after - reaching npm signup: "apparently that was true yesterday." The registry is - reachable from Starfire (`npm ping` answers, section 11.1 `(probe)`), and an - `NPM_TOKEN` can be minted. **C still stands for this campaign, by choice: - no registry.** In the operator's words, registry publication is "still for - a later pass". Consumers keep `file:` paths. The native binaries ship inside - the `cultmesh-ts` package tree that the deploy path's `git archive` carries, - and Q6's Actions build attaches both platform artifacts to a GitHub Release - instead of publishing packages. Registry publication of `cultnet-ts`, - `cultmesh-ts` and the native binaries is parked, not ruled out; section 11.9 - names the seam it reattaches to, and the original A/B naming fork stays - open for that pass. Cut 6 is remapped under C (section 11); section 5.4, - Cut 4's binary resolution and dependency lines, and Cut 7's ledger follow - it. The one fork C surfaces, whether the binaries are committed or fetched - from the Release, is Q8 in section 11.2. -- **Q8 ruled Option 1.** The four native binaries are committed at - `packages/cultmesh-ts/native//` with their manifest and digests, - so they ride the `git archive` the deploy path already builds. Operator's - words: "Commit them, yeah." -- **Q6 ruled A.** The Linux release artifact is built by GitHub Actions on - `ubuntu-latest` inside `container: debian:13`, published by the workflow, - and verified by the operator smoke on Yggdrasil in cut 6. The Docker - `debian:13` engine on the workstation is the development loop only; nothing - it produces is a release artifact. No compiler is installed on Yggdrasil. -- **Q7 ruled A.** Cut 4 ships the `ICultMeshRealtimeLookupSource` port and a - static source. The Node Odin WebSocket rendezvous is parked with a note in - cut 7's ledger; it moves into `cultnet-ts` beside the verifier in a later - pipeline, once a Node consumer that discovers through Odin exists. - -## 14. Subtraction estimate - -Both sides of the number, by cut, in source lines (tests included, generated -`dist*` excluded, vector JSON excluded): - -| Cut | Removed or replaced | Added | Net | -| --- | ---: | ---: | ---: | -| 1 trust module | 119 (browser) | 190 (module) + 150 (tests) + 40 (C# vector test) | +261 | -| 2 codec | 0 | 130 + 120 (TS test) + 120 (C# test) | +370 | -| 3 bridge | ~200 rewritten of 440 C++; 24 CMake | ~1,000 C++ (replacing 440), 60 CMake, 70 sh, 40 README | +~700 net C++/build | -| 4 consumer | 0 | 260 (binding) + 400 (consumer/session manager) + 400 (tests) + 200 (C# interop mode) + 150 (harness) + 120 (peer script) | +1,530 | -| 5 provider | 0 | 250 (provider) + 300 (tests) + 150 (harness) + 40 (C# tests) | +740 | -| 6 packaging | 0 | 60 (package manifests) + 130 (workflow) + 30 (closure smoke) + 60 (README) | +280 | -| 7 docs | ~10 | ~40 | +30 | -| Total | ~350 | ~4,260 | about +3,900 | - -Dependencies: +1 runtime dependency on `cultmesh-ts` (`koffi`, 1.7 MB, MIT, -loaded lazily); +0 optional platform packages; +0 build-time Node -dependencies (no node-gyp, no node-addon-api, no cmake-js). Targets: +0 .NET -projects (the C# interop peer gains one project reference); +1 CMake platform -branch; +1 shell build script; +1 workflow file with four jobs; +1 job in -the interop workflow; and, under Q8 option 1, about 8.0 MB of committed -binaries. *(This line first read "+2 optional platform packages; +3 publish -jobs; +1 CI job" under ruling A; section 11.8 carries the delta.)* - -Why the number is positive and still acceptable: the target orders a new -capability (a QUIC realtime plane in a runtime that has none), and every line -above either is that capability, proves it against the C# reference, or ships -it. The subtraction that was available (one verifier instead of two, one -MsQuic body instead of two, one framing implementation per language instead -of one per host) is taken in cuts 1 and 3. Anything that would have shrunk -the number further (a third-party QUIC stack, a callback-driven addon, a -tarball with a `.so`) was rejected in section 4 for reasons that are not -about line count. - -## 15. Not assignable to a cut - -- **The Unity package release** carrying the rebuilt bridge DLL. The v1 ABI - is preserved, so no cut requires it, but the committed DLL will lag the - source until the operator runs `scripts/build-unity-package.ps1` and - commits. Recorded here so nobody reads the stale DLL as evidence the - rewrite did not happen. -- **StreamPixels certificate provisioning** (which PKCS12, where it lives on - Yggdrasil, how its pin reaches the Odin route). Consumer work by the target. -- **A nonce on the QUIC plane.** The target lists "a replayed nonce" among - trust negatives, but the QUIC plane has no nonce exchange in C# either - (`CultMeshQuicRealtimeTransport.cs` opens no session message; trust is the - Odin route plus the TLS pin, `transport-planes.md:71-73`). Cut 4 tests the - replay class that does exist (route generation). Adding a nonce is a - cross-runtime protocol change and needs its own target. -- **Linux coverage of the C# native connector.** `CanConnect` is Windows-only - (`CultMeshNativeQuicRealtimeTransport.cs:40`); the Linux interop job in cut 6 - therefore runs the TypeScript-provider-to-managed-connector lane and the - TypeScript-to-TypeScript lanes only. The native-connector lane is Windows - by design, matching where Unity runs. -- **The `cultcache-ts` naming split** across consumers (section 3). Out of - scope. Q5 C touches no package name and publishes nothing, so it makes the - split neither better nor worse; the split becomes the parked registry - pass's problem (section 11.9), where the A/B naming fork is still open. - One consequence to carry there: StreamPixels' lockfile resolves - `cultmesh-ts`'s cache dependency as unscoped `cultcache-ts` - (`F:\Projects\StreamPixels\pnpm-lock.yaml:2561-2564` `(source read)`) while - `packages/cultmesh-ts/package.json:46` now names `@gamecult/cultcache-ts`, - so a `pnpm install --frozen-lockfile` against the current tree would refuse - before any QUIC code is reached. Consumer work, recorded so the Yggdrasil - smoke in section 11.7 is not mistaken for StreamPixels adoption. - -## 16. Reminder of what a wrong cut looks like - -If a cut touches `src/GameCult.Mesh/CultMeshTcp*.cs`, adds TLS to the TCP -schema or content connectors, adds WebTransport to `cultmesh-browser`, adds -QUIC to `cultnet-py`, `cultnet-rs`, or `cultmesh-kotlin`, or edits anything -under `F:\Projects\StreamPixels`, it has left the target's "Not in this -migration" list and is wrong. Stop and re-read this map. diff --git a/docs/typescript-quic-realtime-target.md b/docs/typescript-quic-realtime-target.md deleted file mode 100644 index 751d5277..00000000 --- a/docs/typescript-quic-realtime-target.md +++ /dev/null @@ -1,160 +0,0 @@ -# TypeScript QUIC Realtime Plane Target - -Date: 2026-09-16 - -Status: target accepted by the operator (2026-09-16), ready for Eureka. No cut -map exists yet. When the pipeline starts, Imagination maps the cut into -`docs/typescript-quic-realtime-cut.md` against `main` at `a0813c6` or later. - -The TypeScript runtime gains the CultMesh QUIC realtime state plane that the C# -runtime already has: a provider that serves frames and a consumer that receives -them, byte-compatible with `GameCult.Mesh.Quic` and the native MsQuic connector -the Unity package ships. This document states the end state and the invariants -that constrain getting there. - -Operator ruling, 2026-09-16, on providing QUIC for a Node service: "Option 2 all -the way, this is what CultLib is supposed to be, we're not half assing it." A -separate .NET provider process and a WebSocket shortcut were both rejected. - -## Why now - -The first consumer is StreamPixels. Its service (Node 24, TypeScript, on -Yggdrasil) must publish realtime state to a Unity overlay running on a -streamer's machine. The overlay is a receive-only client using the Unity -package's `CultMeshNativeQuicRealtimeTransportConnector`. Today no TypeScript -path exists: - -- Node v24.15.0 has no `node:quic`, with or without `--experimental-quic`. -- `packages/cultmesh-ts` and `packages/cultnet-ts` contain no QUIC code. -- `GameCult.Mesh.Quic` (.NET 10, `System.Net.Quic`) is the only QUIC provider. -- The C# TCP control and content connectors are plaintext and restricted to - loopback (`src/GameCult.Mesh/docs/transport-planes.md`, "Security and release - gate"), so they cannot carry the overlay's remote session either. - -## This touches the foundation - -- **Wire parity is an invariant.** The C# codec is the reference: - `src/GameCult.Mesh/CultMeshRealtimeWireProtocol.cs`. The TypeScript runtime - must produce and accept identical bytes: - - ALPN `cultmesh-state-v1`; connection close code `0x43554c54`, stream abort - code `0x53544154`; reliable stream type `1`, latest-only stream type `2`. - - Frame: magic `0x31545343`, then a 37-byte little-endian fixed header - (delivery byte, producer epoch i64, sequence i64, channel/schema/body id - lengths u16, payload length i32, header size i32 = 37, wire version u16 = - 1), then UTF-8 channel id, schema id, body id, then payload. - - Limits: payload at most 64 MiB; each identity at most 65,535 UTF-8 bytes; - decode rejects wrong magic, unknown version, out-of-range delivery, and any - length that does not sum exactly. -- **Delivery semantics are an invariant** - (`src/GameCult.Mesh.Quic/README.md`, `CultMeshRealtimeTransports.cs`): - - `ReliableOrdered`: one persistent ordered stream; broadcast is - completion-bearing. - - `LatestOnly`: independent streams; at most one pending frame per - `(channel, body)`, replaced by a newer `(producer epoch, sequence)` - generation; a keyed coalescing outbox per physical peer, so a slow or - departed consumer never backpressures the producer. - - `Unreliable`: fails closed until datagrams are exposed, matching the managed - C# adapter. -- **Trust is an invariant.** No remote session comes online without the chain - in `transport-planes.md`: an Odin-signed `CultMeshRouteCertificate` (Verse, - authority runtime, protocol set, endpoint, generation, validity, provider - P-256 key) checked against consumer-pinned Odin roots, TLS 1.3, and the - endpoint certificate bound to that route, including the - `cultmesh-state+quic://host:port?cert-sha256=` pin. - Signatures are ECDSA P-256 over SHA-256 with P1363 `r || s` encoding and the - length-prefixed canonical transcript. Unsigned traffic exists only under an - explicit `LocalDevelopment` policy on loopback. -- **One implementation of TypeScript route verification.** `cultmesh-browser` - already verifies Odin route certificates and provider nonce possession with - WebCrypto (`packages/cultmesh-browser/src/index.ts`, `verifyAuthorityRoute`, - `canonicalRoute`, `canonicalSession`, `verifyP256`). The Node QUIC path must - reuse that owner, not grow a second verifier. -- **The realtime plane carries state frames only.** Schemas, commands, - receipts, manifests, and immutable content do not travel through it - (`ICultMeshRealtimeTransport` doc comment). RUDP is never installed - implicitly in its place. -- **Existing consumers survive.** The StreamPixels service already imports - `cultcache-ts`, `cultnet-ts`, and `cultmesh-ts` (`verse-state.ts`, - `idunn-rudp-health.ts`) for Odin advertisement and Idunn health over RUDP. - Imagination audits every other TypeScript consumer across `F:\Projects` - before sizing the cut. - -## Target state - -- `cultmesh-ts` exposes a QUIC realtime provider and a QUIC realtime consumer - with the same ergonomic shape as the C# `CultMeshQuicRealtimeServer` - (listen, broadcast with an explicit delivery mode) and - `ICultMeshRealtimeTransportConnector` (connect by advertised candidate, - receive frames), under the branded `CultMesh` entrypoint. -- QUIC comes from native MsQuic bindings owned by CultLib, not from a Node - polyfill or a third-party QUIC stack with different semantics. How the binding - is built and shipped is the means (Imagination probes it); what it must - deliver is TLS 1.3, ALPN, independent unidirectional or bidirectional streams, - certificate validation with a caller hook, and clean close and abort codes. -- Frame encoding and decoding exist once in TypeScript and are tested against - bytes produced by the C# codec. -- Application code never picks endpoints, ranks routes, or writes reconnect - loops; `CultMeshSessionManager`-equivalent route selection owns that, as in C#. -- The build produces binaries for the hosts that run them: Windows x64 for - local development, and Linux x64 for Yggdrasil, built on Linux or the deploy - path's builder, not cross-compiled on Starfire. - -## Not in this migration - -One foundation per pipeline. These are separate, named pipelines or consumer -work: - -- **TypeScript content plane** (a provider in `cultmesh-ts`, a verifying HTTPS - reader in `cultmesh-browser`) for exported character artifacts. HTTPS content - transport and single-host trust on Yggdrasil were already ruled. -- **Authenticated remote control plane** (TLS on the TCP schema and content - connectors). See Q1. -- **Browser QUIC** (WebTransport). Browsers keep the verified WebSocket path. -- **Python, Rust, and Kotlin QUIC.** The parity scope is role-scoped; this - migration claims TypeScript and C# only. -- **StreamPixels integration** (service publication, overlay subscription, and - the catalog and scene-intent schemas) is consumer work in StreamPixels after a - released `cultmesh-ts` exists. - -## Verification the cut must reach - -- Golden frame bytes from the C# codec decode in TypeScript, and TypeScript - encodings decode in C#, for every delivery mode and at the length limits. - Malformed inputs are rejected identically. -- Separate processes, both directions: a TypeScript provider to the C# native - connector (the one Unity uses) and to the managed connector, and a C# managed - provider to the TypeScript consumer. Extend the existing parity harnesses - (`CULTMESH_NATIVE_EXTERNAL_ENDPOINT`, `packages/cultnet-ts/test/interop`) rather - than adding a parallel one. -- `LatestOnly` coalescing: a stalled consumer does not delay the producer, and - the consumer converges on the terminal generation. -- Trust negatives: an expired or unsigned route, the wrong Odin root, a - mismatched `cert-sha256` pin, and a replayed nonce are each refused, with a - mutation per rule. -- The Linux x64 binary runs on the Yggdrasil deploy path, verified on that host. - -## Rulings (operator, 2026-09-16) - -The operator accepted every recommendation below ("You got it"). Each question -is kept with its options as the record of what was decided against. - -- **Q1. Which remote plane carries the overlay's non-frame data?** The realtime - plane forbids schemas, commands, and content, and the TCP planes are - loopback-only. A: publish her character, the subathon window, and scene - intents as QUIC state frames with their CultCache schema id and payload, and - ship the costume catalog as a versioned immutable artifact on the HTTPS - content plane; the overlay sends no commands, so it needs no remote control - plane. B: add TLS to the TCP schema and content connectors as its own - pipeline first. **Recommended: A.** It needs no new plane for M1, matches a - receive-only client, and leaves TLS TCP to the first consumer that sends - commands. -- **Q2. Where does shared TypeScript route verification live?** It is inside - `cultmesh-browser` today, and `cultmesh-ts` is Node-only. A: move it to a - browser-safe shared module that both import (for example beside - `cultnet-ts/contracts`). B: have `cultmesh-ts` depend on `cultmesh-browser`. - **Recommended: A**, so neither transport package owns the other's trust. -- **Q3. Which platforms must the native binding support at release?** - **Recommended: Windows x64 and Linux x64 only**, the two hosts that run it - today. -- **Q4. Are QUIC datagrams (`Unreliable`) in scope?** **Recommended: no.** Fail - closed like the managed C# adapter; no consumer needs them. diff --git a/dotnet-tools.json b/dotnet-tools.json deleted file mode 100644 index 6da5949f..00000000 --- a/dotnet-tools.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-stryker": { - "version": "5.0.0", - "commands": [ - "dotnet-stryker" - ], - "rollForward": false - } - } -} diff --git a/native/GameCult.Mesh.Quic.Native/CMakeLists.txt b/native/GameCult.Mesh.Quic.Native/CMakeLists.txt index c3dfc304..2850951d 100644 --- a/native/GameCult.Mesh.Quic.Native/CMakeLists.txt +++ b/native/GameCult.Mesh.Quic.Native/CMakeLists.txt @@ -1,118 +1,20 @@ cmake_minimum_required(VERSION 3.24) project(gamecult_mesh_quic_native LANGUAGES CXX) -# Two platforms, one source. Windows takes MsQuic from the pinned OpenSSL NuGet -# layout (MSQUIC_ROOT); Linux takes it from the extracted libmsquic deb, whose -# headers and library land in unrelated places, so they are named separately. -if(NOT WIN32 AND NOT (CMAKE_SYSTEM_NAME STREQUAL "Linux")) - message(FATAL_ERROR "The CultMesh native QUIC bridge supports Windows x64 and Linux x64") +if(NOT WIN32) + message(FATAL_ERROR "The current CultMesh native QUIC connector supports Windows desktop only") +endif() +if(NOT DEFINED MSQUIC_ROOT) + message(FATAL_ERROR "MSQUIC_ROOT must point at the extracted Microsoft.Native.Quic.MsQuic.Schannel package build/native directory") endif() add_library(gamecult_mesh_quic_native SHARED cultmesh_quic_native.cpp) target_compile_features(gamecult_mesh_quic_native PRIVATE cxx_std_20) -# include/cultmesh_quic_native.h is the host-facing contract, not an internal -# detail: the bridge includes it, and so does any consumer that can. -target_include_directories(gamecult_mesh_quic_native PUBLIC include) - -if(WIN32) - if(NOT DEFINED MSQUIC_ROOT) - message(FATAL_ERROR "MSQUIC_ROOT must point at the extracted Microsoft.Native.Quic.MsQuic.OpenSSL package build/native directory") - endif() - # Static CRT. A Node or Unity host without the Visual C++ redistributable - # installed cannot load a DLL that imports vcruntime140.dll, and the failure - # arrives as "the specified module could not be found" with nothing naming the - # missing runtime. The bridge carries its own instead. - set_property(TARGET gamecult_mesh_quic_native PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") - target_compile_definitions(gamecult_mesh_quic_native PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) - target_include_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_ROOT}/include") - target_link_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_ROOT}/lib/x64") - # crypt32 and bcrypt belong to the v1 shim alone: CryptHashCertificate2 - # compares the Unity pin. Nothing in the v2 path needs them. ntdll carries - # RtlIpv4/6StringToAddressEx, which msquic_winuser.h's inline QuicAddrFromString - # calls to parse the listener host; the Linux header parses it in-tree instead. - target_link_libraries(gamecult_mesh_quic_native PRIVATE msquic crypt32 bcrypt ntdll) - # The DLL is committed beside its source, so a rebuild must reproduce it: /Brepro drops the link timestamps. - target_compile_options(gamecult_mesh_quic_native PRIVATE /Brepro) - target_link_options(gamecult_mesh_quic_native PRIVATE /Brepro) -else() - if(NOT DEFINED MSQUIC_INCLUDE_DIR OR NOT DEFINED MSQUIC_LIB_DIR) - message(FATAL_ERROR "MSQUIC_INCLUDE_DIR and MSQUIC_LIB_DIR must point at the msquic v2.5.9 headers and the extracted libmsquic library directory") - endif() - target_include_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_INCLUDE_DIR}") - target_link_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_LIB_DIR}") - target_link_libraries(gamecult_mesh_quic_native PRIVATE msquic pthread) - # Only the CULTMESH_API exports leave the .so; everything else stays internal. - target_compile_options(gamecult_mesh_quic_native PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden) - # libmsquic.so.2 ships beside the bridge rather than being installed - # system-wide, so the loader is pointed at the bridge's own directory. - set_target_properties(gamecult_mesh_quic_native PROPERTIES - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "$ORIGIN") -endif() +target_compile_definitions(gamecult_mesh_quic_native PRIVATE GAMECULT_MESH_QUIC_NATIVE_EXPORTS WIN32_LEAN_AND_MEAN NOMINMAX) +target_include_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_ROOT}/include") +target_link_directories(gamecult_mesh_quic_native PRIVATE "${MSQUIC_ROOT}/lib/x64") +target_link_libraries(gamecult_mesh_quic_native PRIVATE msquic crypt32 bcrypt) set_target_properties(gamecult_mesh_quic_native PROPERTIES OUTPUT_NAME "gamecult_mesh_quic_native" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -# The runtime-lifetime scenarios. Off by default: the shipped artifact is the -# library alone, and a delivery build has no business producing an executable. -# CULTMESH_QUIC_DEBUG_ASSERTS goes with them, never into a shipped binary — it -# makes the bridge state the quiesce invariant instead of leaving it to whatever -# a sanitizer happens to catch. -option(CULTMESH_QUIC_BUILD_TESTS "Build the runtime-lifetime scenario runner" OFF) -option(CULTMESH_QUIC_DEBUG_ASSERTS "Abort the bridge on a violated internal invariant" OFF) - -if(CULTMESH_QUIC_DEBUG_ASSERTS) - target_compile_definitions(gamecult_mesh_quic_native PRIVATE CULTMESH_QUIC_DEBUG_ASSERTS) -endif() - -if(CULTMESH_QUIC_BUILD_TESTS) - add_executable(cultmesh_quic_native_tests tests/cultmesh_quic_native_tests.cpp) - target_compile_features(cultmesh_quic_native_tests PRIVATE cxx_std_20) - # The header only. The scenarios drive the bridge as a host does, so they get - # no more of it than a host has. - target_link_libraries(cultmesh_quic_native_tests PRIVATE gamecult_mesh_quic_native) - # The scenarios see the development seam (section 7 of the header) exactly when - # the library has one, so `holdclose` compiles out of the same builds the - # bridge's own assertions compile out of. - if(CULTMESH_QUIC_DEBUG_ASSERTS) - target_compile_definitions(cultmesh_quic_native_tests PRIVATE CULTMESH_QUIC_DEBUG_ASSERTS) - endif() - set_target_properties(cultmesh_quic_native_tests PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - if(WIN32) - # gamecult_mesh_quic_native.dll imports msquic.dll, and the scenario - # runner loads it from its own directory (or PATH) at process start, not - # from MSQUIC_ROOT. build-quic-native.ps1's packaged output gets a copy - # from its own recipe; a test build has no packaging step, so without this - # the loader falls through to whatever msquic.dll happens to already be on - # PATH — silently running the scenarios against an unpinned, wrong-version - # MsQuic instead of failing to start. CMake already knows MSQUIC_ROOT, so - # it places the pinned DLL itself instead of leaving the reader to guess - # why a scenario passed against the wrong binary. - add_custom_command(TARGET cultmesh_quic_native_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${MSQUIC_ROOT}/bin/x64/msquic.dll" - "$/msquic.dll") - else() - target_link_libraries(cultmesh_quic_native_tests PRIVATE pthread) - # The linker resolves the bridge's own NEEDED libmsquic.so.2 while linking - # this executable, and the runtime copy only lands beside the binaries after - # the build; point it at the extracted package instead. - target_link_options(cultmesh_quic_native_tests PRIVATE "-Wl,-rpath-link,${MSQUIC_LIB_DIR}") - set_target_properties(cultmesh_quic_native_tests PROPERTIES - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "$ORIGIN") - # Both binaries carry INSTALL_RPATH "$ORIGIN" and expect libmsquic.so.2 - # beside them at load time. build-quic-native.sh's packaged output gets - # that copy from its own recipe; a test build has no packaging step, so - # the runner would otherwise die at once with "cannot open shared object - # file". CMake already knows where MSQUIC_LIB_DIR is, so it places the - # file itself instead of leaving the reader to run an extra cp by hand. - add_custom_command(TARGET cultmesh_quic_native_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${MSQUIC_LIB_DIR}/libmsquic.so.2" - "$/libmsquic.so.2") - endif() -endif() + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") diff --git a/native/GameCult.Mesh.Quic.Native/README.md b/native/GameCult.Mesh.Quic.Native/README.md index ae5d78d2..875ebb3b 100644 --- a/native/GameCult.Mesh.Quic.Native/README.md +++ b/native/GameCult.Mesh.Quic.Native/README.md @@ -1,168 +1,10 @@ # GameCult.Mesh.Quic.Native -One MsQuic body for every CultMesh host that is not .NET: two roles (provider -and consumer), two platforms (Windows x64 and Linux x64), and no callbacks -across the host boundary. +This Windows desktop bridge keeps MsQuic's callback-heavy C API below the +managed runtime boundary. It accepts a discovery-authorized SHA-256 certificate +pin, negotiates `cultmesh-state-v1`, and emits complete CultMesh realtime frame +payloads. It owns transport only; frame meaning remains in `GameCult.Mesh`. -The bridge owns MsQuic registration, configuration, listener, connection and -stream handles, TLS credential loading, the `cultmesh-state-v1` ALPN, the -1-byte-kind plus 4-byte-LE-length QUIC stream framing, and one event queue per -runtime. It owns transport and nothing else: it never decodes a CultMesh frame, -never decides delivery semantics, never coalesces, never reconnects, and in the -v2 path never decides whether to trust a certificate. Frame meaning stays in -`GameCult.Mesh` and in the TypeScript codec; trust stays with the host. - -## No host callbacks - -Every crossing is the host calling in, including the one blocking wait. MsQuic's -worker threads only ever push onto the queue and wake that wait, so no host -runtime is called from a thread it does not own. That is what lets one binary -serve a Node process through FFI and a Unity player through P/Invoke without -either one's threading rules leaking into the other. - -It is also why nothing here includes a Node header, a Unity header, or a -JavaScript engine: the bridge does not know what is on the other side. - -## Two ABIs - -**v2** is the runtime-neutral queue API, and the one new hosts should use. It is -stated once, in [`include/cultmesh_quic_native.h`](include/cultmesh_quic_native.h): -the 64-byte event struct with its field order and asserted offsets, the thirteen -exports with their signatures, the id and return-code conventions, the object -lifetime rules and the threading rules. That file is the contract. This README -does not restate it, and where the two ever disagree the header is right. - -A host that can include it should. A host that cannot — koffi, Unity's -P/Invoke — declares the same thing in its own FFI and is checked against the -header by a test rather than by eye. - -Two things worth reading before writing a host, because they are easy to get -wrong from the outside: - -- **Return codes are negative on a bad call, on every platform.** `-1` is a bad - call, `-2` a rejected argument, `<= -1000` a MsQuic refusal. `QUIC_STATUS` - itself is not portable — a negative HRESULT on Windows, a positive errno on - POSIX — so it never reaches a host; `cultmesh_quic_last_status` hands over the - raw value for diagnostics and nothing else. -- **`cultmesh_quic_runtime_close` quiesces.** It marks the runtime closing, wakes - every blocked `cultmesh_quic_next_event`, and waits for every in-flight call to - return before it frees anything. No host call may begin after it starts. - -A client connection defers certificate validation: the bridge indicates the -certificate, emits event 3 carrying the DER, and answers MsQuic only when the -host calls `cultmesh_quic_connection_certificate_complete`. If the host never -answers, MsQuic's 10-second handshake timeout closes the connection and event 4 -reports it. Providers load their certificate as PKCS12; the advertised -`cert-sha256` pin is computed by the host from that same PKCS12, not here. - -**v1** is the five exports the shipped Unity package imports by name -(`cultmesh_quic_open`, `_state`, `_poll`, `_error`, `_close`). They are Windows -only, matching `CultMeshNativeQuicRealtimeTransport.CanConnect`, and are -implemented on top of a private v2 runtime holding one connection. They decide -nothing the v2 path does not, with one exception: a v1 connection carries a -SHA-256 pin that is compared here, in C, because that is the contract the -managed connector was built against. A v2 connection never carries one. - -## Building - -Windows x64, from the repo root: - - powershell -File scripts/build-quic-native.ps1 - -MsQuic comes from `Microsoft.Native.Quic.MsQuic.OpenSSL` 2.5.9, pinned twice: the -NuGet zip by digest and size, and the `msquic.dll` inside it by digest and size, -because the archive is what the download is checked against and the DLL is what -actually ships beside the bridge. The OpenSSL flavour rather than Schannel -because Schannel's MsQuic refuses `QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12`, -which is the only credential type a provider has on both platforms. - -The build uses MSVC with `/Brepro` so that a build reproduces itself: the link -timestamps are dropped, and building the same source twice gives the same bytes. -It links the CRT statically (`/MT`), because a Node or Unity host without the -Visual C++ redistributable cannot load a DLL that imports `vcruntime140.dll`, -and the failure it reports names no missing runtime; the bridge carries its own. - -The committed Unity plugin -(`unity/org.gamecult.cultlib/Runtime/Plugins/x86_64/gamecult_mesh_quic_native.dll`) -is this build: 302,080 bytes, `/MT`, OpenSSL MsQuic, no CRT import. It replaced -an older 40,448-byte build — before `/MT` and before the move off Schannel, -still importing `VCRUNTIME140.dll` and `MSVCP140.dll` — at the CultLib 1.0.60 / -Studio 1.4.0 release. - -Linux x64, on a Debian 13 host: - - scripts/build-quic-native.sh - -MsQuic comes from Microsoft's Debian 13 pool as a pinned `.deb`, and the POSIX -headers from the msquic source tree at the matching tag; all four downloads are -verified by SHA-256. The bridge is linked with `-fvisibility=hidden` so only the -v2 exports leave the `.so`, and with `RPATH $ORIGIN` so the `libmsquic.so.2` -shipped beside it resolves without being installed system-wide. - -A Linux host still needs MsQuic's own runtime dependencies present: -`libssl3t64`, `libnuma1`, `libxdp1`, `libnl-route-3-200`. - -The development loop for it is one committed image, -[`scripts/quic-native-linux-dev.Dockerfile`](../../scripts/quic-native-linux-dev.Dockerfile), -pinned to the same `debian:13` digest the release workflow builds in. It carries -the toolchain, MsQuic's runtime dependencies, and `setarch`, because a -sanitizer build of the runtime-lifetime scenarios needs `personality(ADDR_NO_RANDOMIZE)` -and a container that cannot ask for that cannot run them: - - docker build -t cultlib-quic-native-dev -f scripts/quic-native-linux-dev.Dockerfile scripts - docker run --rm --security-opt seccomp=unconfined -v "${PWD}:/src" -w /src cultlib-quic-native-dev bash -lc " - scripts/build-quic-native.sh - cmake -S native/GameCult.Mesh.Quic.Native -B artifacts/quic-native-tests/linux-x64 -G Ninja \ - -DCMAKE_BUILD_TYPE=Release -DCULTMESH_QUIC_BUILD_TESTS=ON -DCULTMESH_QUIC_DEBUG_ASSERTS=ON \ - -DMSQUIC_INCLUDE_DIR=\$(pwd)/artifacts/dependencies/msquic-linux-2.5.9/include \ - -DMSQUIC_LIB_DIR=\$(pwd)/artifacts/dependencies/msquic-linux-2.5.9/package/usr/lib/x86_64-linux-gnu - cmake --build artifacts/quic-native-tests/linux-x64 - for scenario in closerace holdclose holdtimeout polltimeout pollbusy pollhammer zerotimeout payloadfit latecall waitseam; do - setarch -R artifacts/quic-native-tests/linux-x64/bin/cultmesh_quic_native_tests \"\${scenario}\" || exit 1 - done - " - -Both lines are run from the repository root, and the mount is that root wherever -it is: `${PWD}` in PowerShell, `$(pwd)` in a POSIX shell. `MSQUIC_INCLUDE_DIR` -and `MSQUIC_LIB_DIR` need `$(pwd)` too, even though the `cmake` invocation -itself already runs from `/src`: CMake resolves a relative path passed as a -cache variable against the CMakeLists.txt that consumes it -(`native/GameCult.Mesh.Quic.Native`), not against the directory `cmake` was -invoked from, so a bare `artifacts/...` here looks for the dependency one level -too deep and fails the compile before it reaches the loader. The test target's -own build now copies `libmsquic.so.2` from `MSQUIC_LIB_DIR` beside the built -binaries, so nothing else here needs the packaged output directory `scripts/build-quic-native.sh` -produces. `CULTMESH_QUIC_BUILD_TESTS` -is off in the shipped configuration (see the CMakeLists.txt option comment); it -turns on the scenario runner `tests/cultmesh_quic_native_tests.cpp` compiles into, -and `CULTMESH_QUIC_DEBUG_ASSERTS` turns on both the bridge's internal invariant -assertions and the four scenarios (`holdclose`, `latecall`, `holdtimeout`, -`waitseam`) that need the development seam in section 7 of the header. Each -scenario name is a positional argument to the built binary; run them individually -to bisect a failure, or all ten as shown to cover the runtime-lifetime rules. - -A Windows clone made before `.gitattributes` kept shell scripts at LF still has -`scripts/build-quic-native.sh` with carriage returns, and pulling does not fix -it: the script's content did not change, so git neither rewrites it nor reports -it modified. The container then dies at once on the interpreter `bash\r`. From -the repository root, in either shell, this checks the script out again under the -current attributes: - - git rm --cached -q scripts/build-quic-native.sh; git checkout HEAD -- scripts/build-quic-native.sh - -`--security-opt seccomp=unconfined` is load-bearing, not caution. A -ThreadSanitizer configuration needs the process's address space where it expects -it, so a TSan run must be re-executed under `setarch -R`, which asks the kernel -for `personality(ADDR_NO_RANDOMIZE)`. Docker's default seccomp profile denies -that call. Without it ThreadSanitizer dies before `main` with "unexpected memory -mapping" — a configuration that never starts, not a scenario that passed. - -A win32-x64 build of the scenario runner needs the checkout somewhere short — -near a drive root rather than under a deep temporary directory. MSVC builds the -bridge and its scenario runner through MSBuild, whose file tracker gives out on -long paths, and the build then fails outright rather than naming the path as the -cause. - -Where an artifact was built is part of what it is. The Linux binary is linked -against Debian 13's glibc, so a build from anywhere else is a different artifact -whatever the file name says. +The build consumes Microsoft's pinned +`Microsoft.Native.Quic.MsQuic.Schannel` package. It does not contain +Aetheria-specific code. diff --git a/native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp b/native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp index 5964de43..bbb6e193 100644 --- a/native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp +++ b/native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp @@ -1,116 +1,24 @@ -// The CultMesh MsQuic bridge: one MsQuic body, two roles, two platforms. -// -// This file owns MsQuic registration, configuration, listener, connection and -// stream handles, TLS credential loading, the 1-byte-kind plus 4-byte-LE-length -// QUIC stream framing, and a single event queue per runtime. It owns transport -// only. It never decodes a CultMesh frame, never decides delivery semantics, -// never coalesces, never reconnects, and in the v2 path never accepts a -// certificate on its own: the host answers, through -// `cultmesh_quic_connection_certificate_complete`. -// -// No host callbacks. Every crossing is the host calling in, including the one -// blocking wait (`cultmesh_quic_next_event`). MsQuic's worker threads only ever -// push onto the queue and wake that wait, so the bridge is runtime-neutral: it -// includes no Node headers, no Unity headers, and nothing platform-specific -// outside the `_WIN32` block at the bottom of this file. -// -// Two ABIs live here. v2 is the queue API above, for any host. v1 is the five -// exports the Unity managed connector already imports by name -// (`CultMeshNativeQuicRealtimeTransport.cs`, `NativeMethods`), kept Windows-only -// and implemented on top of a private v2 runtime. v1 is the only place a -// certificate pin is compared in C, because that is the contract Unity was -// shipped with; it delegates everything else and decides nothing new. - -// The host-facing contract lives in include/cultmesh_quic_native.h and is -// included here so this file cannot drift from it: the event layout, the -// exports, the return codes, the lifetime rules and the threading rules are -// stated there once and asserted at compile time. -#define CULTMESH_QUIC_BUILD 1 -#include - +#include +#include +#include #include -#include #include #include -#include #include #include -#include -#include #include #include #include #include #include #include -#include -#include #include -#define CULTMESH_API extern "C" CULTMESH_QUIC_API - -// Development builds only, and never in a shipped binary: after -// `cultmesh_quic_runtime_close` has quiesced, no host call may still be inside -// the library. The wait is what makes that true, and its absence is otherwise -// visible only as a use-after-free a sanitizer catches by luck — a poller has to -// be preempted in the right window. With pollers blocked, this states the -// invariant directly, so a build without the wait dies on the first close rather -// than on the run that happens to be unlucky. -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) -#define CULTMESH_QUIC_ASSERT_QUIESCED(count) \ - do { \ - const int cultmesh_quic_remaining = (count); \ - if (cultmesh_quic_remaining != 0) { \ - std::fprintf(stderr, \ - "cultmesh_quic_runtime_close: %d host call(s) still inside the " \ - "library after the quiesce\n", cultmesh_quic_remaining); \ - std::fflush(stderr); \ - std::abort(); \ - } \ - } while (false) +#if defined(GAMECULT_MESH_QUIC_NATIVE_EXPORTS) +#define CULTMESH_API extern "C" __declspec(dllexport) #else -#define CULTMESH_QUIC_ASSERT_QUIESCED(count) ((void)0) -#endif - -// Development builds only, and never in a shipped binary: the seam the scenario -// runner drives the quiesce through. A scenario that only sleeps and hopes its -// pollers are inside the library cannot tell a bridge that counts host calls -// from one that does not, so the bridge says so itself: -// -// - PEAK raises the high-water mark of calls counted inside, so a scenario can -// assert that the calls it launched were counted rather than assumed. -// - AT_CLOSE records how many were counted when the close began its wait, which -// is the number the wait exists for. -// - HELD parks a call inside the library until the scenario releases it, so the -// close races calls that are genuinely there for as long as the scenario -// wants them there, instead of for as long as the schedule happens to give. -// It returns true when it parked, and a held call makes no further call of -// its own; what it does still do is leave its CallScope, which takes the gate, -// decrements the count and notifies. That is the ordinary exit every export -// makes, and it is the bridge's wait — not the hold — that keeps the runtime -// alive underneath it. -// - RECORD_WAIT wraps the whole duration handed to the condition wait in -// `cultmesh_quic_next_event`, in place, as a pass-through: it stores that -// duration's count and returns the duration unchanged, so a mutation to -// what is actually waited on changes what this reports rather than the two -// ever being able to diverge. It wraps `timeout_ms` after conversion to -// `std::chrono::milliseconds`, not before — Self's ruling of 2026-09-22, -// after arithmetic applied to the converted duration survived a seam that -// only recorded the raw integer underneath it. A scenario reads it and -// asserts equality against the timeout it asked for, deterministically and -// with no timing tolerance, in place of inferring the same fact from how -// long a call took to return. -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) -#define CULTMESH_QUIC_DEBUG_PEAK(count) DebugRaisePeak(count) -#define CULTMESH_QUIC_DEBUG_AT_CLOSE(count) DebugRecordCallsAtClose(count) -#define CULTMESH_QUIC_DEBUG_HELD(lock) DebugHoldCall(lock) -#define CULTMESH_QUIC_DEBUG_RECORD_WAIT(duration) DebugRecordWait(duration) -#else -#define CULTMESH_QUIC_DEBUG_PEAK(count) ((void)0) -#define CULTMESH_QUIC_DEBUG_AT_CLOSE(count) ((void)0) -#define CULTMESH_QUIC_DEBUG_HELD(lock) (false) -#define CULTMESH_QUIC_DEBUG_RECORD_WAIT(duration) (duration) +#define CULTMESH_API extern "C" __declspec(dllimport) #endif namespace { @@ -118,1168 +26,11 @@ namespace { constexpr uint32_t kApiVersion = 2; constexpr uint64_t kConnectionCloseCode = 0x43554c54; constexpr uint64_t kStreamAbortCode = 0x53544154; -constexpr uint8_t kReliableStream = CULTMESH_QUIC_STREAM_RELIABLE; -constexpr uint8_t kLatestOnlyStream = CULTMESH_QUIC_STREAM_LATEST_ONLY; +constexpr uint8_t kReliableStream = 1; +constexpr uint8_t kLatestOnlyStream = 2; constexpr uint32_t kMaximumEncodedFrameBytes = (64u * 1024u * 1024u) + 37u + (3u * 65535u); constexpr char kAlpn[] = "cultmesh-state-v1"; -// Mirrors the C# server and connector: CultMeshQuicRealtimeTransport.cs:77,:202 -// for the stream ceiling, and the idle/keep-alive pair the v1 bridge already -// used (:335-338). -constexpr uint32_t kIdleTimeoutMs = 30000; -constexpr uint32_t kKeepAliveIntervalMs = 5000; -constexpr uint16_t kPeerUnidiStreamCount = 1024; -// If the host never answers the certificate event, this is what closes the -// connection instead of leaking it: MsQuic's own handshake timeout fires and -// the shutdown arrives as event 4. -constexpr uint32_t kHandshakeIdleTimeoutMs = 10000; - -// Short names for the header's event codes; the header is the contract. -constexpr uint32_t kEventListenerNewConnection = CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION; -constexpr uint32_t kEventConnectionConnected = CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED; -constexpr uint32_t kEventConnectionCertificateReceived = CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED; -constexpr uint32_t kEventConnectionShutdown = CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN; -constexpr uint32_t kEventStreamStarted = CULTMESH_QUIC_EVENT_STREAM_STARTED; -constexpr uint32_t kEventStreamFrame = CULTMESH_QUIC_EVENT_STREAM_FRAME; -constexpr uint32_t kEventStreamSendComplete = CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE; -constexpr uint32_t kEventStreamShutdown = CULTMESH_QUIC_EVENT_STREAM_SHUTDOWN; -constexpr uint32_t kEventListenerStopped = CULTMESH_QUIC_EVENT_LISTENER_STOPPED; - -struct Runtime; -struct Connection; - -struct QueuedEvent { - cultmesh_quic_event header{}; - std::vector payload; -}; - -// Objects are shared-owned, and that is the whole lifetime model. The runtime's -// maps hold one reference each; an export that names an id takes its own -// reference under the lock and holds it for the entire MsQuic call. MsQuic's -// worker, on shutdown-complete, drops the map's reference only. The handle -// follows the object: it is closed exactly once, in the destructor, by whichever -// holder drops last, under a one-shot exchange guard. See section 4 of -// include/cultmesh_quic_native.h, which is where this is promised to hosts. - -struct Stream { - Runtime* runtime = nullptr; - // Shared, not raw: this is what keeps a connection's handle open for as long - // as any of its streams still exist, so stream handles always close first. - std::shared_ptr owner; - HQUIC handle = nullptr; - uint64_t id = 0; - uint8_t kind = 0; - bool inbound = false; - bool has_kind = false; - std::atomic handle_closed{false}; - // Inbound reassembly only. MsQuic delivers stream bytes in arbitrary - // chunks, so the length prefix and the frame it introduces can arrive in - // separate receives. - std::vector buffered; - - ~Stream(); -}; - -struct Connection : std::enable_shared_from_this { - Runtime* runtime = nullptr; - HQUIC handle = nullptr; - uint64_t id = 0; - uint64_t listener_id = 0; - bool inbound = false; - // Written by the host thread in `cultmesh_quic_connection_shutdown`, read on - // an MsQuic worker when the shutdown completes: the code the host passed is - // what its own event 4 has to carry. - std::atomic closing{false}; - std::atomic shutdown_code{0}; - // Why it ended, recorded by whichever initiated-by callback saw it and read - // by shutdown-complete, which is the single emitter of event 4. Both run on - // this connection's own worker, serialized. - std::string shutdown_reason; - int32_t shutdown_status = 0; - // Set when MsQuic is closing the handle itself (an app close already in - // progress), so the destructor's one-shot close stands down. - std::atomic handle_closed{false}; - // v1 only. A connection carrying a pin has its certificate answered in C - // against that pin; a v2 connection never sets this and is always answered - // by the host. Nothing outside the `_WIN32` block below ever sets it. - bool has_pin = false; - std::array pin{}; - // v1 diagnostics: the MsQuic event sequence, which the v1 error string - // reports and nothing in v2 reads. - std::string trace; - - ~Connection(); -}; - -struct Listener { - Runtime* runtime = nullptr; - HQUIC handle = nullptr; - HQUIC configuration = nullptr; - uint64_t id = 0; - std::atomic handle_closed{false}; - - ~Listener(); -}; - -struct Runtime { - const QUIC_API_TABLE* api = nullptr; - HQUIC registration = nullptr; - // One client configuration serves every outbound connection: the ALPN, - // settings and credential flags are identical for all of them. - HQUIC client_configuration = nullptr; - - std::mutex gate; - std::condition_variable signal; - std::deque events; - std::unordered_map> listeners; - std::unordered_map> connections; - std::unordered_map> streams; - uint64_t next_id = 1; - std::string error; - // The raw platform status behind the last MsQuic refusal, kept because the - // portable return code deliberately throws its bits away. - int32_t last_status = 0; - bool closing = false; - // Host calls currently inside the library. `cultmesh_quic_runtime_close` - // waits for this to reach zero before it touches a handle. - int active_calls = 0; -}; - -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) -// The development seam behind the three CULTMESH_QUIC_DEBUG_ macros. None of it -// is compiled into a shipped library. -std::atomic debug_peak_calls{0}; -std::atomic debug_calls_at_close{-1}; -std::mutex debug_hold_gate; -std::condition_variable debug_hold_signal; -bool debug_hold_armed = false; -std::atomic debug_last_wait_ms{-1}; -// Separate from the value above on purpose: once the seam records the whole -// duration (not just a millisecond count already known to be positive), a -// mutation could in principle make a wait get recorded at exactly -1, and an -// int32_t alone cannot tell that apart from "nothing recorded yet". This flag -// is the "recorded" bit; the getter below is the only thing that still hands -// out -1 for the unset case. -std::atomic debug_wait_recorded{false}; - -void DebugRaisePeak(int count) { - int peak = debug_peak_calls.load(std::memory_order_relaxed); - while (count > peak && !debug_peak_calls.compare_exchange_weak(peak, count)) { - } -} - -void DebugRecordCallsAtClose(int count) { debug_calls_at_close.store(count); } - -// Parks the calling host thread inside the library until the scenario releases -// it. The runtime gate is dropped first, so nothing else is blocked behind the -// held call, and it is never retaken: the call is still counted, because its -// CallScope is still alive, and that is the whole point. -bool DebugHoldCall(std::unique_lock& lock) { - std::unique_lock hold(debug_hold_gate); - if (!debug_hold_armed) return false; - lock.unlock(); - debug_hold_signal.wait(hold, [] { return !debug_hold_armed; }); - return true; -} - -// A pass-through: it stores the duration's count and returns the duration -// unmodified, so wrapping it around the whole expression handed to the -// condition wait makes the two impossible to desync by construction. Whatever -// that expression evaluates to — the plain converted argument today, or a -// derivation a future change or a mutation introduces inside this call — is -// what gets recorded, because it is the same evaluation. Anything applied -// outside this call, after it returns, is what the wall-clock scenarios exist -// to catch instead; see their generous-tolerance comment. -std::chrono::milliseconds DebugRecordWait(std::chrono::milliseconds duration) { - debug_last_wait_ms.store(static_cast(duration.count())); - debug_wait_recorded.store(true); - return duration; -} -#endif - -// Every host-facing export enters through this. It refuses once -// `cultmesh_quic_runtime_close` has started, and otherwise holds the runtime -// open for the length of the call. -class CallScope { -public: - explicit CallScope(Runtime* runtime) : runtime_(runtime) { - if (runtime_ == nullptr) return; - std::lock_guard lock(runtime_->gate); - if (runtime_->closing) return; - ++runtime_->active_calls; - CULTMESH_QUIC_DEBUG_PEAK(runtime_->active_calls); - entered_ = true; - } - // The notify stays under `gate`, and that is the whole point of it. Released - // first, the closer's predicate is already true, so it can return from its - // wait, run the teardown and destroy the runtime — condition variable - // included — before this thread reaches the notify. Holding the lock across - // both means the closer cannot leave `signal.wait` until this scope has let - // go, so the condition variable is still alive when it is signalled. - ~CallScope() { - if (!entered_) return; - std::lock_guard lock(runtime_->gate); - --runtime_->active_calls; - runtime_->signal.notify_all(); - } - CallScope(const CallScope&) = delete; - CallScope& operator=(const CallScope&) = delete; - bool entered() const { return entered_; } - -private: - Runtime* runtime_ = nullptr; - bool entered_ = false; -}; - -Stream::~Stream() { - if (handle != nullptr && runtime != nullptr && runtime->api != nullptr && - !handle_closed.exchange(true)) - runtime->api->StreamClose(handle); -} - -Connection::~Connection() { - if (handle != nullptr && runtime != nullptr && runtime->api != nullptr && - !handle_closed.exchange(true)) - runtime->api->ConnectionClose(handle); -} - -Listener::~Listener() { - if (runtime == nullptr || runtime->api == nullptr) return; - if (handle != nullptr && !handle_closed.exchange(true)) runtime->api->ListenerClose(handle); - if (configuration != nullptr) runtime->api->ConfigurationClose(configuration); -} - -// Every send buffer outlives its `StreamSend` call: MsQuic reads the bytes -// asynchronously and only releases them at SEND_COMPLETE, where this is freed. -struct SendRequest { - QUIC_BUFFER buffer{}; - std::vector bytes; - // Which send this was. The bridge writes the stream's kind byte itself, and - // that completion is not the host's to hear about; event 7 is one per - // `cultmesh_quic_stream_send_frame` and nothing else. - bool is_frame = false; -}; - -// A `QUIC_STATUS` reaches this through `uint32_t`, never straight to `uint64_t`: -// it is a signed HRESULT on Windows, and widening it signed printed every -// Windows failure as `0xFFFFFFFF80072B18`. The status is 32 bits on both -// platforms and is read as 32 bits here. -std::string Hex(uint64_t value) { - std::ostringstream text; - text << "0x" << std::hex << std::uppercase << value; - return text.str(); -} - -void SetError(Runtime* runtime, const std::string& message) { - if (runtime == nullptr) return; - std::lock_guard lock(runtime->gate); - runtime->error = message; -} - -// `QUIC_STATUS` never reaches a host. It is a negative HRESULT on Windows and a -// positive errno on POSIX, so a host that checked for a negative value saw every -// Linux failure as success. One negative space on both platforms instead; the -// raw bits go to `cultmesh_quic_last_status`. See section 3 of the header. -int32_t MsQuicCode(QUIC_STATUS status) { - return CULTMESH_QUIC_RESULT_MSQUIC_BASE - - static_cast(static_cast(status) & 0xffffu); -} - -int32_t Refuse(Runtime* runtime, QUIC_STATUS status, const std::string& message) { - if (runtime != nullptr) { - std::lock_guard lock(runtime->gate); - runtime->error = message; - runtime->last_status = static_cast(status); - } - return MsQuicCode(status); -} - -// The only way anything reaches the host. Callers must not hold `gate`. -void Publish(Runtime* runtime, const cultmesh_quic_event& header, const uint8_t* payload, size_t payload_length) { - QueuedEvent queued; - queued.header = header; - queued.header.payload_length = static_cast(payload_length); - if (payload != nullptr && payload_length > 0) - queued.payload.assign(payload, payload + payload_length); - { - std::lock_guard lock(runtime->gate); - if (runtime->closing) return; - runtime->events.push_back(std::move(queued)); - } - runtime->signal.notify_all(); -} - -void PublishSimple(Runtime* runtime, uint32_t type, uint64_t listener_id, uint64_t connection_id, - uint64_t stream_id, uint64_t code, int32_t status, uint32_t stream_kind = 0) { - cultmesh_quic_event header{}; - header.type = type; - header.stream_kind = stream_kind; - header.listener_id = listener_id; - header.connection_id = connection_id; - header.stream_id = stream_id; - header.code = code; - header.status = status; - Publish(runtime, header, nullptr, 0); -} - -// v1 diagnostics only, and bounded. A v2 connection has no reader for this, and -// a long-lived one appended to it once per MsQuic event for as long as it lived. -constexpr size_t kMaximumTraceBytes = 512; - -void AppendTrace(Connection* connection, const std::string& event) { - if (connection == nullptr || !connection->has_pin) return; - std::lock_guard lock(connection->runtime->gate); - if (connection->trace.size() >= kMaximumTraceBytes) return; - if (!connection->trace.empty()) connection->trace += ","; - connection->trace += event; -} - -uint32_t ReadUInt32LittleEndian(const uint8_t* value) { - return static_cast(value[0]) | - (static_cast(value[1]) << 8) | - (static_cast(value[2]) << 16) | - (static_cast(value[3]) << 24); -} - -void WriteUInt32LittleEndian(uint8_t* destination, uint32_t value) { - destination[0] = static_cast(value & 0xff); - destination[1] = static_cast((value >> 8) & 0xff); - destination[2] = static_cast((value >> 16) & 0xff); - destination[3] = static_cast((value >> 24) & 0xff); -} - -uint64_t NextId(Runtime* runtime) { - std::lock_guard lock(runtime->gate); - return runtime->next_id++; -} - -// The three lookups. Each returns a reference the caller owns for as long as it -// holds it, taken under the lock, so nothing the caller then names can be freed -// under it. A raw pointer here was the use-after-free. -std::shared_ptr FindConnection(Runtime* runtime, uint64_t id) { - std::lock_guard lock(runtime->gate); - const auto found = runtime->connections.find(id); - return found == runtime->connections.end() ? nullptr : found->second; -} - -std::shared_ptr FindStream(Runtime* runtime, uint64_t id) { - std::lock_guard lock(runtime->gate); - const auto found = runtime->streams.find(id); - return found == runtime->streams.end() ? nullptr : found->second; -} - -// Takes the object out of its map and returns it, so the caller's reference — -// and any destructor it ends up running — lives outside the lock. -template -auto Detach(std::mutex& gate, Map& map, uint64_t id) { - typename Map::mapped_type detached; - std::lock_guard lock(gate); - const auto found = map.find(id); - if (found == map.end()) return detached; - detached = std::move(found->second); - map.erase(found); - return detached; -} - -void ShutdownConnectionForProtocolFault(const std::shared_ptr& connection, const std::string& message) { - if (connection == nullptr) return; - SetError(connection->runtime, message); - if (connection->runtime->api != nullptr && connection->handle != nullptr) - connection->runtime->api->ConnectionShutdown( - connection->handle, QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, kStreamAbortCode); -} - -// Reassembles whole encoded frames out of the stream byte sequence and -// publishes one event 6 per frame, length prefix stripped. The first byte of an -// inbound stream is its kind, which becomes event 5. -bool ConsumeFrames(Stream* stream) { - Runtime* runtime = stream->runtime; - auto& bytes = stream->buffered; - if (!stream->has_kind) { - if (bytes.empty()) return true; - stream->kind = bytes.front(); - bytes.erase(bytes.begin()); - stream->has_kind = true; - if (stream->kind != kReliableStream && stream->kind != kLatestOnlyStream) { - ShutdownConnectionForProtocolFault(stream->owner, "CultMesh QUIC stream kind is invalid."); - return false; - } - PublishSimple(runtime, kEventStreamStarted, stream->owner->listener_id, stream->owner->id, - stream->id, 0, 0, stream->kind); - } - - while (bytes.size() >= sizeof(uint32_t)) { - const uint32_t length = ReadUInt32LittleEndian(bytes.data()); - if (length == 0 || length > kMaximumEncodedFrameBytes) { - ShutdownConnectionForProtocolFault(stream->owner, "CultMesh QUIC frame length is invalid."); - return false; - } - const size_t framed_length = sizeof(uint32_t) + static_cast(length); - if (bytes.size() < framed_length) return true; - - cultmesh_quic_event header{}; - header.type = kEventStreamFrame; - header.stream_kind = stream->kind; - header.listener_id = stream->owner->listener_id; - header.connection_id = stream->owner->id; - header.stream_id = stream->id; - Publish(runtime, header, bytes.data() + sizeof(uint32_t), length); - - bytes.erase(bytes.begin(), bytes.begin() + static_cast(framed_length)); - } - return true; -} - -// Drops the map's reference and nothing else. If the map was the last holder the -// object dies here, outside the lock, and its destructor closes the handle; if a -// host call is still inside, the object outlives this by exactly that long. -void DestroyStream(Runtime* runtime, uint64_t stream_id) { - [[maybe_unused]] const auto detached = Detach(runtime->gate, runtime->streams, stream_id); -} - -QUIC_STATUS QUIC_API StreamCallback(HQUIC, void* context, QUIC_STREAM_EVENT* event) { - auto* stream = static_cast(context); - Runtime* runtime = stream->runtime; - switch (event->Type) { - case QUIC_STREAM_EVENT_RECEIVE: - for (uint32_t index = 0; index < event->RECEIVE.BufferCount; ++index) { - const auto& buffer = event->RECEIVE.Buffers[index]; - stream->buffered.insert(stream->buffered.end(), buffer.Buffer, buffer.Buffer + buffer.Length); - } - ConsumeFrames(stream); - break; - case QUIC_STREAM_EVENT_SEND_COMPLETE: { - // Which send finished is the client context's job to say. Without it the - // bridge's own kind byte completed as an anonymous event 7 and the host - // counted six completions for five frames. - auto* request = static_cast(event->SEND_COMPLETE.ClientContext); - const bool is_frame = request != nullptr && request->is_frame; - delete request; - if (is_frame) - PublishSimple(runtime, kEventStreamSendComplete, stream->owner->listener_id, stream->owner->id, - stream->id, - event->SEND_COMPLETE.Canceled - ? CULTMESH_QUIC_SEND_CANCELED - : CULTMESH_QUIC_SEND_COMPLETED, - 0, stream->kind); - break; - } - case QUIC_STREAM_EVENT_PEER_SEND_SHUTDOWN: - if (!stream->buffered.empty()) - ShutdownConnectionForProtocolFault(stream->owner, "CultMesh QUIC stream ended with a truncated frame."); - break; - case QUIC_STREAM_EVENT_SHUTDOWN_COMPLETE: { - // Everything this event reports is read before the map's reference goes, - // because that reference may be the last one and `stream` may not - // survive `DestroyStream`. - const uint64_t stream_id = stream->id; - const uint64_t connection_id = stream->owner->id; - const uint64_t listener_id = stream->owner->listener_id; - const uint32_t kind = stream->kind; - // An app close already in progress means MsQuic closes this handle - // itself; anything else leaves it to the last holder's destructor. - if (event->SHUTDOWN_COMPLETE.AppCloseInProgress) stream->handle_closed.store(true); - DestroyStream(runtime, stream_id); - PublishSimple(runtime, kEventStreamShutdown, listener_id, connection_id, stream_id, 0, 0, kind); - break; - } - default: - break; - } - return QUIC_STATUS_SUCCESS; -} - -void DestroyConnection(Runtime* runtime, uint64_t connection_id) { - // Declared first so it dies last: whatever order these drop in, a stream - // holds its connection, so every stream handle closes before the connection - // handle does. - std::shared_ptr connection; - std::vector> streams; - { - std::lock_guard lock(runtime->gate); - for (auto it = runtime->streams.begin(); it != runtime->streams.end();) { - if (it->second->owner != nullptr && it->second->owner->id == connection_id) { - streams.push_back(std::move(it->second)); - it = runtime->streams.erase(it); - } else { - ++it; - } - } - const auto found = runtime->connections.find(connection_id); - if (found != runtime->connections.end()) { - connection = std::move(found->second); - runtime->connections.erase(found); - } - } -} - -#if defined(_WIN32) -// Declared here, defined in the v1 block at the bottom: the pin comparison is -// the one piece of the certificate path that is Windows-only and v1-only. -bool CertificateMatchesPin(Connection* connection, QUIC_CERTIFICATE* certificate); -#endif - -QUIC_STATUS QUIC_API ConnectionCallback(HQUIC handle, void* context, QUIC_CONNECTION_EVENT* event) { - auto* connection = static_cast(context); - Runtime* runtime = connection->runtime; - AppendTrace(connection, "event=" + std::to_string(static_cast(event->Type))); - switch (event->Type) { - case QUIC_CONNECTION_EVENT_CONNECTED: - PublishSimple(runtime, kEventConnectionConnected, connection->listener_id, connection->id, 0, 0, 0); - break; - case QUIC_CONNECTION_EVENT_PEER_STREAM_STARTED: { - auto stream = std::make_shared(); - stream->runtime = runtime; - stream->owner = connection->shared_from_this(); - stream->handle = event->PEER_STREAM_STARTED.Stream; - stream->inbound = true; - stream->id = NextId(runtime); - Stream* raw = stream.get(); - { - std::lock_guard lock(runtime->gate); - runtime->streams.emplace(raw->id, std::move(stream)); - } - runtime->api->SetCallbackHandler( - event->PEER_STREAM_STARTED.Stream, reinterpret_cast(StreamCallback), raw); - break; - } - case QUIC_CONNECTION_EVENT_PEER_CERTIFICATE_RECEIVED: { - const auto* encoded = reinterpret_cast(event->PEER_CERTIFICATE_RECEIVED.Certificate); - AppendTrace(connection, "certificate-status=" + - Hex(static_cast(event->PEER_CERTIFICATE_RECEIVED.DeferredStatus))); -#if defined(_WIN32) - if (connection->has_pin) { - // The v1 contract: the pin decision is made here, in C, and the host - // is never asked. Only `cultmesh_quic_open` sets `has_pin`. - const bool matches = CertificateMatchesPin( - connection, event->PEER_CERTIFICATE_RECEIVED.Certificate); - if (!matches) - SetError(runtime, - "CultMesh QUIC provider certificate does not match the advertised SHA-256 pin."); - const auto completion = runtime->api->ConnectionCertificateValidationComplete( - handle, - matches ? static_cast(1) : static_cast(0), - matches ? QUIC_TLS_ALERT_CODE_SUCCESS : QUIC_TLS_ALERT_CODE_BAD_CERTIFICATE); - if (QUIC_FAILED(completion)) { - SetError(runtime, "CultMesh QUIC certificate validation completion failed (status=" + - Hex(static_cast(completion)) + ")."); - return completion; - } - return QUIC_STATUS_PENDING; - } -#endif - // v2: the DER goes to the host and the handshake waits. Nothing here - // decides trust. If the host never answers, MsQuic's handshake timeout - // closes the connection and event 4 reports it. - cultmesh_quic_event header{}; - header.type = kEventConnectionCertificateReceived; - header.listener_id = connection->listener_id; - header.connection_id = connection->id; - header.status = static_cast(event->PEER_CERTIFICATE_RECEIVED.DeferredStatus); - const uint8_t* der = (encoded != nullptr) ? encoded->Buffer : nullptr; - const size_t der_length = (encoded != nullptr) ? encoded->Length : 0; - Publish(runtime, header, der, der_length); - return QUIC_STATUS_PENDING; - } - // The two initiated-by events say why a connection is ending, not that it - // has ended; the object and its id are still live here. They record the - // reason and the code, and shutdown-complete below is the one place event 4 - // is emitted, once per connection id, after the id has stopped resolving. - // All three of these run on the connection's own MsQuic worker, serialized, - // which is what lets these fields be plain members. - case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_TRANSPORT: - connection->shutdown_reason = "CultMesh QUIC connection was shut down by the transport (status=" + - Hex(static_cast(event->SHUTDOWN_INITIATED_BY_TRANSPORT.Status)) + ", error=" + - Hex(event->SHUTDOWN_INITIATED_BY_TRANSPORT.ErrorCode) + ")."; - connection->shutdown_code.store(event->SHUTDOWN_INITIATED_BY_TRANSPORT.ErrorCode); - connection->shutdown_status = static_cast(event->SHUTDOWN_INITIATED_BY_TRANSPORT.Status); - break; - case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_PEER: - connection->shutdown_reason = "CultMesh QUIC connection was shut down by the peer."; - connection->shutdown_code.store(event->SHUTDOWN_INITIATED_BY_PEER.ErrorCode); - break; - case QUIC_CONNECTION_EVENT_SHUTDOWN_COMPLETE: { - const uint64_t connection_id = connection->id; - if (event->SHUTDOWN_COMPLETE.AppCloseInProgress) connection->handle_closed.store(true); - // A host that ended the connection itself gets nothing else from MsQuic - // — no initiated-by-peer, no initiated-by-transport — so without this - // its own connection id simply stopped existing and the end of a - // connection was observable only from the other side. - cultmesh_quic_event header{}; - header.type = kEventConnectionShutdown; - header.listener_id = connection->listener_id; - header.connection_id = connection_id; - header.code = connection->shutdown_code.load(); - header.status = connection->shutdown_status; - const std::string reason = connection->shutdown_reason.empty() - ? std::string("CultMesh QUIC connection was shut down by the host.") - : connection->shutdown_reason; - DestroyConnection(runtime, connection_id); - Publish(runtime, header, reinterpret_cast(reason.data()), reason.size()); - break; - } - default: - break; - } - return QUIC_STATUS_SUCCESS; -} - -QUIC_STATUS QUIC_API ListenerCallback(HQUIC, void* context, QUIC_LISTENER_EVENT* event) { - auto* listener = static_cast(context); - Runtime* runtime = listener->runtime; - switch (event->Type) { - case QUIC_LISTENER_EVENT_NEW_CONNECTION: { - auto connection = std::make_shared(); - connection->runtime = runtime; - connection->handle = event->NEW_CONNECTION.Connection; - connection->inbound = true; - connection->listener_id = listener->id; - connection->id = NextId(runtime); - Connection* raw = connection.get(); - { - std::lock_guard lock(runtime->gate); - runtime->connections.emplace(raw->id, std::move(connection)); - } - runtime->api->SetCallbackHandler( - event->NEW_CONNECTION.Connection, reinterpret_cast(ConnectionCallback), raw); - const auto status = runtime->api->ConnectionSetConfiguration( - event->NEW_CONNECTION.Connection, listener->configuration); - if (QUIC_FAILED(status)) { - SetError(runtime, "CultMesh QUIC inbound connection configuration failed (status=" + - Hex(static_cast(status)) + ")."); - // Returning a failure here is MsQuic's signal to reject and close - // this connection itself, so the entry made a moment ago has to go - // with it rather than sitting in the map naming a dead handle. - raw->handle_closed.store(true); - DestroyConnection(runtime, raw->id); - return status; - } - PublishSimple(runtime, kEventListenerNewConnection, listener->id, raw->id, 0, 0, 0); - break; - } - case QUIC_LISTENER_EVENT_STOP_COMPLETE: - PublishSimple(runtime, kEventListenerStopped, listener->id, 0, 0, 0, 0); - break; - default: - break; - } - return QUIC_STATUS_SUCCESS; -} - -void FillSettings(QUIC_SETTINGS& settings) { - settings.IdleTimeoutMs = kIdleTimeoutMs; - settings.IsSet.IdleTimeoutMs = 1; - settings.KeepAliveIntervalMs = kKeepAliveIntervalMs; - settings.IsSet.KeepAliveIntervalMs = 1; - settings.PeerUnidiStreamCount = kPeerUnidiStreamCount; - settings.IsSet.PeerUnidiStreamCount = 1; - settings.HandshakeIdleTimeoutMs = kHandshakeIdleTimeoutMs; - settings.IsSet.HandshakeIdleTimeoutMs = 1; -} - -QUIC_BUFFER AlpnBuffer() { - return QUIC_BUFFER{ - static_cast(sizeof(kAlpn) - 1), - reinterpret_cast(const_cast(kAlpn)) - }; -} - -// Opened once per runtime, on first outbound connection. -QUIC_STATUS EnsureClientConfiguration(Runtime* runtime) { - if (runtime->client_configuration != nullptr) return QUIC_STATUS_SUCCESS; - - QUIC_SETTINGS settings{}; - FillSettings(settings); - QUIC_BUFFER alpn = AlpnBuffer(); - HQUIC configuration = nullptr; - auto status = runtime->api->ConfigurationOpen( - runtime->registration, &alpn, 1, &settings, sizeof(settings), nullptr, &configuration); - if (QUIC_FAILED(status)) return status; - - QUIC_CREDENTIAL_CONFIG credentials{}; - credentials.Type = QUIC_CREDENTIAL_TYPE_NONE; - credentials.Flags = static_cast( - QUIC_CREDENTIAL_FLAG_CLIENT | - QUIC_CREDENTIAL_FLAG_INDICATE_CERTIFICATE_RECEIVED | - QUIC_CREDENTIAL_FLAG_DEFER_CERTIFICATE_VALIDATION | - QUIC_CREDENTIAL_FLAG_USE_PORTABLE_CERTIFICATES); - status = runtime->api->ConfigurationLoadCredential(configuration, &credentials); - if (QUIC_FAILED(status)) { - runtime->api->ConfigurationClose(configuration); - return status; - } - runtime->client_configuration = configuration; - return QUIC_STATUS_SUCCESS; -} - -// `pin` is the v1 shim's and nothing else passes it. It must be attached before -// `ConnectionStart`, not after it returns: the handshake runs on an MsQuic -// worker thread and reaches the certificate event immediately on loopback, so a -// pin applied afterwards loses the race, the connection takes the v2 path, and -// the handshake stalls waiting for an answer from a host that was never told to -// give one. -int32_t OpenConnection(Runtime* runtime, const char* host, uint16_t port, uint64_t* out_connection_id, - const std::array* pin) { - if (runtime == nullptr || host == nullptr || *host == '\0' || port == 0 || out_connection_id == nullptr) - return -1; - *out_connection_id = 0; - - auto status = EnsureClientConfiguration(runtime); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC client configuration failed (status=" + - Hex(static_cast(status)) + ")."); - } - - auto connection = std::make_shared(); - connection->runtime = runtime; - connection->id = NextId(runtime); - if (pin != nullptr) { - connection->has_pin = true; - connection->pin = *pin; - } - Connection* raw = connection.get(); - - status = runtime->api->ConnectionOpen(runtime->registration, ConnectionCallback, raw, &raw->handle); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC connection open failed (status=" + - Hex(static_cast(status)) + ")."); - } - { - std::lock_guard lock(runtime->gate); - runtime->connections.emplace(raw->id, connection); - } - - status = runtime->api->ConnectionStart( - raw->handle, runtime->client_configuration, QUIC_ADDRESS_FAMILY_UNSPEC, host, port); - if (QUIC_FAILED(status)) { - // The map's reference goes and this local one goes with the scope; the - // handle is closed by whichever of the two drops last, exactly once. - DestroyConnection(runtime, raw->id); - return Refuse(runtime, status, "CultMesh QUIC connection start failed (status=" + - Hex(static_cast(status)) + ")."); - } - - *out_connection_id = raw->id; - return 0; -} - -} // namespace - -// --------------------------------------------------------------------------- -// C ABI v2: the runtime-neutral bridge. -// --------------------------------------------------------------------------- - -CULTMESH_API int32_t cultmesh_quic_runtime_open(const char* app_name, void** out_runtime) { - if (out_runtime == nullptr) return -1; - *out_runtime = nullptr; - auto runtime = std::make_unique(); - - // No runtime yet to hang `last_status` on, so these two refusals lose the - // raw bits. Everything after this point keeps them. - auto status = MsQuicOpenVersion(kApiVersion, reinterpret_cast(&runtime->api)); - if (QUIC_FAILED(status)) return MsQuicCode(status); - - const QUIC_REGISTRATION_CONFIG registration_config = { - (app_name != nullptr && *app_name != '\0') ? app_name : "GameCult.Mesh.Quic.Native", - QUIC_EXECUTION_PROFILE_TYPE_REAL_TIME - }; - status = runtime->api->RegistrationOpen(®istration_config, &runtime->registration); - if (QUIC_FAILED(status)) { - MsQuicClose(runtime->api); - return MsQuicCode(status); - } - - *out_runtime = runtime.release(); - return 0; -} - -CULTMESH_API void cultmesh_quic_runtime_close(void* handle) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return; - - // Quiesce before anything is closed or freed. Marking the runtime closing - // refuses every call that has not started; waking the pollers gets the - // blocked ones out of `next_event`; waiting for `active_calls` to reach zero - // is what makes the teardown below safe at all. A wake without the wait is - // how a poller returns into freed memory, so the wait is the contract, not - // the wake. Objects are taken out of the maps here and released after the - // lock, so their destructors run on this thread and close their handles. - std::vector> streams; - std::vector> connections; - std::vector> listeners; - { - std::unique_lock lock(runtime->gate); - if (runtime->closing) return; - runtime->closing = true; - runtime->signal.notify_all(); - CULTMESH_QUIC_DEBUG_AT_CLOSE(runtime->active_calls); - runtime->signal.wait(lock, [runtime] { return runtime->active_calls == 0; }); - CULTMESH_QUIC_ASSERT_QUIESCED(runtime->active_calls); - for (auto& entry : runtime->streams) streams.push_back(std::move(entry.second)); - for (auto& entry : runtime->connections) connections.push_back(std::move(entry.second)); - for (auto& entry : runtime->listeners) listeners.push_back(std::move(entry.second)); - runtime->streams.clear(); - runtime->connections.clear(); - runtime->listeners.clear(); - } - - // Bottom-up, and by the app's own hand. `RegistrationClose` blocks until - // every child handle the app opened has been closed *by the app*, and a - // silent shutdown delivers no shutdown events at all, so leaning on the - // callbacks to do the closing deadlocks the caller forever. - streams.clear(); - for (auto& connection : connections) - if (connection->handle != nullptr && !connection->handle_closed.load()) - runtime->api->ConnectionShutdown( - connection->handle, QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT, kConnectionCloseCode); - connections.clear(); - listeners.clear(); - if (runtime->client_configuration != nullptr) { - runtime->api->ConfigurationClose(runtime->client_configuration); - runtime->client_configuration = nullptr; - } - - // No callback can be running past this point. - if (runtime->registration != nullptr) { - runtime->api->RegistrationClose(runtime->registration); - runtime->registration = nullptr; - } - if (runtime->api != nullptr) { - MsQuicClose(runtime->api); - runtime->api = nullptr; - } - delete runtime; -} - -CULTMESH_API int32_t cultmesh_quic_listener_open( - void* handle, const char* host, uint16_t port, - const uint8_t* pkcs12, int32_t pkcs12_len, const char* password, - uint64_t* out_listener_id, uint16_t* out_bound_port) { - auto* runtime = static_cast(handle); - if (runtime == nullptr || pkcs12 == nullptr || pkcs12_len <= 0 || out_listener_id == nullptr) - return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - *out_listener_id = 0; - if (out_bound_port != nullptr) *out_bound_port = 0; - - // Held here until the listener is fully started. Every failure path below - // simply returns: the destructor closes whatever was opened, and a partial - // open therefore leaves neither a handle nor a map entry behind. - auto listener = std::make_shared(); - listener->runtime = runtime; - listener->id = NextId(runtime); - - QUIC_SETTINGS settings{}; - FillSettings(settings); - QUIC_BUFFER alpn = AlpnBuffer(); - auto status = runtime->api->ConfigurationOpen( - runtime->registration, &alpn, 1, &settings, sizeof(settings), nullptr, &listener->configuration); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC listener configuration failed (status=" + - Hex(static_cast(status)) + ")."); - } - - // PKCS12 is the one credential type Schannel and OpenSSL both take, which - // is why the provider ships a PKCS12 rather than a platform store handle. - QUIC_CERTIFICATE_PKCS12 pkcs12_certificate{}; - pkcs12_certificate.Asn1Blob = pkcs12; - pkcs12_certificate.Asn1BlobLength = static_cast(pkcs12_len); - pkcs12_certificate.PrivateKeyPassword = (password != nullptr && *password != '\0') ? password : nullptr; - - QUIC_CREDENTIAL_CONFIG credentials{}; - credentials.Type = QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12; - credentials.CertificatePkcs12 = &pkcs12_certificate; - credentials.Flags = QUIC_CREDENTIAL_FLAG_NONE; - status = runtime->api->ConfigurationLoadCredential(listener->configuration, &credentials); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC listener certificate could not be loaded (status=" + - Hex(static_cast(status)) + ")."); - } - - Listener* raw = listener.get(); - status = runtime->api->ListenerOpen(runtime->registration, ListenerCallback, raw, &raw->handle); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC listener open failed (status=" + - Hex(static_cast(status)) + ")."); - } - - QUIC_ADDR address{}; - QuicAddrSetFamily(&address, QUIC_ADDRESS_FAMILY_UNSPEC); - QuicAddrSetPort(&address, port); - if (host != nullptr && *host != '\0' && !QuicAddrFromString(host, port, &address)) { - SetError(runtime, "CultMesh QUIC listener host is not an IP address."); - return -2; - } - - // In the map before it starts accepting, because the callback that accepts - // an inbound connection reads the listener through it. - { - std::lock_guard lock(runtime->gate); - runtime->listeners.emplace(raw->id, listener); - } - - QUIC_BUFFER listener_alpn = AlpnBuffer(); - status = runtime->api->ListenerStart(raw->handle, &listener_alpn, 1, &address); - if (QUIC_FAILED(status)) { - Detach(runtime->gate, runtime->listeners, raw->id); - return Refuse(runtime, status, "CultMesh QUIC listener start failed (status=" + - Hex(static_cast(status)) + ")."); - } - - // Port 0 means "pick one"; the host needs the chosen port to advertise it. - QUIC_ADDR bound{}; - uint32_t bound_size = sizeof(bound); - status = runtime->api->GetParam(raw->handle, QUIC_PARAM_LISTENER_LOCAL_ADDRESS, &bound_size, &bound); - if (QUIC_FAILED(status)) { - Detach(runtime->gate, runtime->listeners, raw->id); - return Refuse(runtime, status, "CultMesh QUIC listener address could not be read (status=" + - Hex(static_cast(status)) + ")."); - } - if (out_bound_port != nullptr) *out_bound_port = QuicAddrGetPort(&bound); - *out_listener_id = raw->id; - return 0; -} - -CULTMESH_API void cultmesh_quic_listener_close(void* handle, uint64_t listener_id) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return; - CallScope scope(runtime); - if (!scope.entered()) return; - // Taken out of the map, then released here: ~Listener closes the handle - // (which is what produces event 9) and its configuration, exactly once. - [[maybe_unused]] const auto detached = Detach(runtime->gate, runtime->listeners, listener_id); -} - -CULTMESH_API int32_t cultmesh_quic_connection_open( - void* handle, const char* host, uint16_t port, uint64_t* out_connection_id) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - return OpenConnection(runtime, host, port, out_connection_id, nullptr); -} - -CULTMESH_API int32_t cultmesh_quic_connection_certificate_complete( - void* handle, uint64_t connection_id, int32_t accept) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - const auto connection = FindConnection(runtime, connection_id); - if (connection == nullptr) return -1; - const auto status = runtime->api->ConnectionCertificateValidationComplete( - connection->handle, - accept != 0 ? static_cast(1) : static_cast(0), - accept != 0 ? QUIC_TLS_ALERT_CODE_SUCCESS : QUIC_TLS_ALERT_CODE_BAD_CERTIFICATE); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC certificate validation completion failed (status=" + - Hex(static_cast(status)) + ")."); - } - return 0; -} - -CULTMESH_API void cultmesh_quic_connection_shutdown(void* handle, uint64_t connection_id, uint64_t code) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return; - CallScope scope(runtime); - if (!scope.entered()) return; - const auto connection = FindConnection(runtime, connection_id); - if (connection == nullptr || connection->closing.exchange(true)) return; - // Kept for the shutdown-complete callback: this is the code the initiator's - // own event 4 carries, matching the one the peer sees. - connection->shutdown_code.store(code); - if (connection->handle != nullptr) - runtime->api->ConnectionShutdown(connection->handle, QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, code); -} - -CULTMESH_API int32_t cultmesh_quic_stream_open( - void* handle, uint64_t connection_id, uint8_t kind, uint64_t* out_stream_id) { - auto* runtime = static_cast(handle); - if (runtime == nullptr || out_stream_id == nullptr) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - *out_stream_id = 0; - if (kind != kReliableStream && kind != kLatestOnlyStream) return -2; - const auto connection = FindConnection(runtime, connection_id); - if (connection == nullptr) return -1; - - auto stream = std::make_shared(); - stream->runtime = runtime; - stream->owner = connection; - stream->kind = kind; - stream->has_kind = true; - stream->id = NextId(runtime); - Stream* raw = stream.get(); - - auto status = runtime->api->StreamOpen( - connection->handle, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL, - StreamCallback, raw, &raw->handle); - if (QUIC_FAILED(status)) { - return Refuse(runtime, status, "CultMesh QUIC stream open failed (status=" + - Hex(static_cast(status)) + ")."); - } - // In the map before it starts. `StreamStart` can reach shutdown-complete on - // an MsQuic worker before it returns here, and that callback has to find the - // stream to report it and to drop the map's reference. - { - std::lock_guard lock(runtime->gate); - runtime->streams.emplace(raw->id, stream); - } - status = runtime->api->StreamStart(raw->handle, QUIC_STREAM_START_FLAG_IMMEDIATE); - if (QUIC_FAILED(status)) { - DestroyStream(runtime, raw->id); - return Refuse(runtime, status, "CultMesh QUIC stream start failed (status=" + - Hex(static_cast(status)) + ")."); - } - - // The kind byte is the first thing on the stream, which is what the peer's - // reassembly reads before any length prefix. - auto* request = new SendRequest(); - request->bytes.assign(1, kind); - request->buffer.Buffer = request->bytes.data(); - request->buffer.Length = 1; - status = runtime->api->StreamSend(raw->handle, &request->buffer, 1, QUIC_SEND_FLAG_NONE, request); - if (QUIC_FAILED(status)) { - delete request; - return Refuse(runtime, status, "CultMesh QUIC stream kind could not be sent (status=" + - Hex(static_cast(status)) + ")."); - } - - *out_stream_id = raw->id; - return 0; -} - -CULTMESH_API int32_t cultmesh_quic_stream_send_frame( - void* handle, uint64_t stream_id, const uint8_t* encoded_frame, int32_t length, int32_t fin) { - auto* runtime = static_cast(handle); - if (runtime == nullptr || encoded_frame == nullptr || length <= 0) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - if (static_cast(length) > kMaximumEncodedFrameBytes) return -2; - // The reference is held for the whole `StreamSend` below, so the worker - // cannot free the stream or close its handle underneath this call. - const auto stream = FindStream(runtime, stream_id); - if (stream == nullptr || stream->handle == nullptr) return -1; - - // The bytes are copied because MsQuic reads them after this returns; the - // 4-byte LE length prefix is the QUIC stream framing, and it is added here - // so that framing lives in one place for both directions. - auto* request = new SendRequest(); - request->is_frame = true; - request->bytes.resize(sizeof(uint32_t) + static_cast(length)); - WriteUInt32LittleEndian(request->bytes.data(), static_cast(length)); - std::memcpy(request->bytes.data() + sizeof(uint32_t), encoded_frame, static_cast(length)); - request->buffer.Buffer = request->bytes.data(); - request->buffer.Length = static_cast(request->bytes.size()); - - const auto flags = (fin != 0) ? QUIC_SEND_FLAG_FIN : QUIC_SEND_FLAG_NONE; - const auto status = runtime->api->StreamSend(stream->handle, &request->buffer, 1, flags, request); - if (QUIC_FAILED(status)) { - delete request; - return Refuse(runtime, status, "CultMesh QUIC frame send failed (status=" + - Hex(static_cast(status)) + ")."); - } - return 0; -} - -CULTMESH_API void cultmesh_quic_stream_shutdown(void* handle, uint64_t stream_id, uint64_t code) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return; - CallScope scope(runtime); - if (!scope.entered()) return; - const auto stream = FindStream(runtime, stream_id); - if (stream == nullptr || stream->handle == nullptr) return; - runtime->api->StreamShutdown(stream->handle, QUIC_STREAM_SHUTDOWN_FLAG_ABORT, code); -} - -// The one blocking crossing; see section 6 of the header for its returns. The -// call scope is what `cultmesh_quic_runtime_close` waits on: a poller blocked -// here is woken by `closing` and counted out before anything is freed. -CULTMESH_API int32_t cultmesh_quic_next_event( - void* handle, int32_t timeout_ms, cultmesh_quic_event* out_event, - uint8_t* payload, int32_t payload_capacity, int32_t* out_required) { - auto* runtime = static_cast(handle); - if (runtime == nullptr || out_event == nullptr || out_required == nullptr || payload_capacity < 0) - return -1; - // A null buffer with a non-zero capacity is a lie about the buffer. Taking - // it meant the event was consumed and its payload silently dropped. - if (payload == nullptr && payload_capacity > 0) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - *out_required = 0; - - std::unique_lock lock(runtime->gate); - if (runtime->events.empty() && timeout_ms > 0) { - // The host's timeout bounds the wait; an event or the close ends it - // sooner, and `woken` is which of the two happened. RECORD_WAIT wraps - // this exact argument; see the development seam note near its macros. - const bool woken = runtime->signal.wait_for( - lock, CULTMESH_QUIC_DEBUG_RECORD_WAIT(std::chrono::milliseconds(timeout_ms)), - [runtime] { return !runtime->events.empty() || runtime->closing; }); - // Development builds only; a no-op unless a scenario has armed the hold. - // A held call returns the same 0 an empty queue would have, and makes no - // further call of its own. Only a woken call is held: one whose own - // timeout expired is on its way out, and parking it would let a scenario - // report a call the bridge kept when what kept it was the fixture. - if (woken && CULTMESH_QUIC_DEBUG_HELD(lock)) return 0; - } - if (runtime->events.empty()) return 0; - - const QueuedEvent& queued = runtime->events.front(); - const auto required = static_cast(queued.payload.size()); - if (required > payload_capacity) { - *out_required = required; - return 2; - } - *out_event = queued.header; - if (required > 0 && payload != nullptr) - std::memcpy(payload, queued.payload.data(), static_cast(required)); - *out_required = required; - runtime->events.pop_front(); - return 1; -} - -CULTMESH_API int32_t cultmesh_quic_last_error(void* handle, char* destination, int32_t capacity) { - auto* runtime = static_cast(handle); - if (runtime == nullptr || destination == nullptr || capacity <= 0) return -1; - CallScope scope(runtime); - if (!scope.entered()) return -1; - std::lock_guard lock(runtime->gate); - const size_t count = (std::min)(runtime->error.size(), static_cast(capacity - 1)); - std::memcpy(destination, runtime->error.data(), count); - destination[count] = '\0'; - return static_cast(count); -} - -CULTMESH_API int32_t cultmesh_quic_last_status(void* handle) { - auto* runtime = static_cast(handle); - if (runtime == nullptr) return 0; - CallScope scope(runtime); - if (!scope.entered()) return 0; - std::lock_guard lock(runtime->gate); - return runtime->last_status; -} - -// --------------------------------------------------------------------------- -// C ABI v1: the Unity shim. Windows only, by the same construction as its only -// caller (`CultMeshNativeQuicRealtimeTransport.CanConnect` is Windows-gated). -// -// These five exports are the contract the shipped Unity package imports by -// name. They are preserved byte for byte in signature and behaviour, and they -// decide nothing the v2 path does not: a v1 client is a private runtime with one -// connection. The single exception is the pin, which v1 compares here in C -// because that is what the managed connector was built against. -// --------------------------------------------------------------------------- - -#if defined(_WIN32) - -#include -#include -#include - -namespace { - enum class ClientState : int32_t { Connecting = 0, Connected = 1, @@ -1287,33 +38,50 @@ enum class ClientState : int32_t { Closed = 3, }; -struct V1Client { - Runtime* runtime = nullptr; - uint64_t connection_id = 0; - ClientState state = ClientState::Connecting; - std::deque> frames; - std::string error; - bool closing = false; - // The managed connector polls `state` and `poll` from its own loop and may - // read `error` from the caller's thread, so the drain and everything it - // mutates sit behind one lock. Held only around `Pump` and the fields; it is - // always taken before the runtime's, never after. - std::mutex gate; +struct Client; + +struct StreamContext { + explicit StreamContext(Client* client) : owner(client) {} + Client* owner; + std::vector buffered; + uint8_t kind = 0; + bool has_kind = false; }; -std::string LoadedMsQuicPath() { - const auto module = GetModuleHandleW(L"msquic.dll"); - if (module == nullptr) return "unresolved"; - std::array path{}; - const auto length = GetModuleFileNameW(module, path.data(), static_cast(path.size())); - if (length == 0 || length >= path.size()) return "unresolved"; - const auto required = WideCharToMultiByte( - CP_UTF8, 0, path.data(), static_cast(length), nullptr, 0, nullptr, nullptr); - if (required <= 0) return "unresolved"; - std::string utf8(static_cast(required), '\0'); - WideCharToMultiByte( - CP_UTF8, 0, path.data(), static_cast(length), utf8.data(), required, nullptr, nullptr); - return utf8; +struct Client { + const QUIC_API_TABLE* api = nullptr; + HQUIC registration = nullptr; + HQUIC configuration = nullptr; + HQUIC connection = nullptr; + std::array certificate_pin{}; + std::atomic state{ClientState::Connecting}; + std::atomic closing{false}; + std::mutex gate; + std::deque> received; + std::string error; + std::string trace; +}; + +void AppendTrace(Client* client, const std::string& event) { + if (client == nullptr || client->state.load() == ClientState::Connected) return; + std::lock_guard lock(client->gate); + if (!client->trace.empty()) client->trace += ","; + client->trace += event; +} + +std::string TraceSnapshot(Client* client) { + if (client == nullptr) return "none"; + std::lock_guard lock(client->gate); + return client->trace.empty() ? "none" : client->trace; +} + +void SetFailure(Client* client, const std::string& message) { + if (client == nullptr || client->closing.load()) return; + { + std::lock_guard lock(client->gate); + if (client->error.empty()) client->error = message; + } + client->state.store(ClientState::Failed); } bool ParseHexNibble(char value, uint8_t& nibble) { @@ -1336,90 +104,287 @@ bool ParsePin(const char* value, std::array& pin) { return true; } -// Drains the runtime's event queue into the v1 client's own shape: frames for -// `poll`, a state for `state`, an error string for `error`. This is where the -// v1 contract is reconstructed from v2 events, and the only place it is. -void Pump(V1Client* client) { - cultmesh_quic_event header{}; - std::vector payload; - for (;;) { - int32_t required = 0; - auto result = cultmesh_quic_next_event( - client->runtime, 0, &header, - payload.empty() ? nullptr : payload.data(), - static_cast(payload.size()), &required); - if (result == 2) { - payload.resize(static_cast(required)); - continue; - } - if (result != 1) break; - - switch (header.type) { - case kEventConnectionConnected: - if (client->state == ClientState::Connecting) client->state = ClientState::Connected; - break; - case kEventStreamFrame: - client->frames.emplace_back(payload.begin(), payload.begin() + header.payload_length); - break; - case kEventConnectionShutdown: - if (client->closing) { - client->state = ClientState::Closed; - } else if (client->state != ClientState::Failed) { - client->state = ClientState::Failed; - if (client->error.empty()) { - char runtime_error[1024]{}; - cultmesh_quic_last_error(client->runtime, runtime_error, sizeof(runtime_error)); - // The pin refusal is the runtime's, and the managed - // connector matches on its wording; anything else is the - // transport's own reason plus where msquic came from. - client->error = runtime_error[0] != '\0' - ? std::string(runtime_error) - : std::string(reinterpret_cast(payload.data()), - static_cast(header.payload_length)); - client->error += " (msquic=" + LoadedMsQuicPath() + ")"; - } - } - break; - default: - break; - } - } +uint32_t ReadUInt32LittleEndian(const uint8_t* value) { + return static_cast(value[0]) | + (static_cast(value[1]) << 8) | + (static_cast(value[2]) << 16) | + (static_cast(value[3]) << 24); } -bool CertificateMatchesPin(Connection* connection, QUIC_CERTIFICATE* certificate) { +void FailStream(StreamContext* stream, const char* message) { + SetFailure(stream->owner, message); + if (stream->owner != nullptr && stream->owner->api != nullptr && stream->owner->connection != nullptr) + stream->owner->api->ConnectionShutdown( + stream->owner->connection, + QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT, + kStreamAbortCode); +} + +bool ConsumeFrames(StreamContext* stream) { + auto& bytes = stream->buffered; + if (!stream->has_kind) { + if (bytes.empty()) return true; + stream->kind = bytes.front(); + bytes.erase(bytes.begin()); + stream->has_kind = true; + if (stream->kind != kReliableStream && stream->kind != kLatestOnlyStream) { + FailStream(stream, "CultMesh QUIC stream kind is invalid."); + return false; + } + } + + while (bytes.size() >= sizeof(uint32_t)) { + const uint32_t length = ReadUInt32LittleEndian(bytes.data()); + if (length == 0 || length > kMaximumEncodedFrameBytes) { + FailStream(stream, "CultMesh QUIC frame length is invalid."); + return false; + } + const size_t framed_length = sizeof(uint32_t) + static_cast(length); + if (bytes.size() < framed_length) return true; + std::vector frame(length); + std::memcpy(frame.data(), bytes.data() + sizeof(uint32_t), length); + { + std::lock_guard lock(stream->owner->gate); + stream->owner->received.emplace_back(std::move(frame)); + } + bytes.erase(bytes.begin(), bytes.begin() + static_cast(framed_length)); + if (stream->kind == kLatestOnlyStream && !bytes.empty()) { + FailStream(stream, "CultMesh latest-only QUIC stream carried multiple frames."); + return false; + } + } + return true; +} + +QUIC_STATUS QUIC_API StreamCallback(HQUIC stream_handle, void* context, QUIC_STREAM_EVENT* event) { + auto* stream = static_cast(context); + switch (event->Type) { + case QUIC_STREAM_EVENT_RECEIVE: + for (uint32_t index = 0; index < event->RECEIVE.BufferCount; ++index) { + const auto& buffer = event->RECEIVE.Buffers[index]; + stream->buffered.insert(stream->buffered.end(), buffer.Buffer, buffer.Buffer + buffer.Length); + } + ConsumeFrames(stream); + break; + case QUIC_STREAM_EVENT_PEER_SEND_SHUTDOWN: + if (!stream->buffered.empty()) + FailStream(stream, "CultMesh QUIC stream ended with a truncated frame."); + break; + case QUIC_STREAM_EVENT_SHUTDOWN_COMPLETE: + if (!event->SHUTDOWN_COMPLETE.AppCloseInProgress) + stream->owner->api->StreamClose(stream_handle); + delete stream; + break; + default: + break; + } + return QUIC_STATUS_SUCCESS; +} + +bool CertificateMatchesPin(Client* client, QUIC_CERTIFICATE* certificate) { if (certificate == nullptr) return false; const auto* encoded = reinterpret_cast(certificate); if (encoded->Buffer == nullptr || encoded->Length == 0) return false; BYTE digest[32]{}; DWORD digest_length = sizeof(digest); if (!CryptHashCertificate2( - BCRYPT_SHA256_ALGORITHM, 0, nullptr, - encoded->Buffer, encoded->Length, digest, &digest_length) || - digest_length != sizeof(digest)) + BCRYPT_SHA256_ALGORITHM, + 0, + nullptr, + encoded->Buffer, + encoded->Length, + digest, + &digest_length) || digest_length != sizeof(digest)) return false; - return std::memcmp(digest, connection->pin.data(), sizeof(digest)) == 0; + return std::memcmp(digest, client->certificate_pin.data(), sizeof(digest)) == 0; +} + +std::string Hex(uint64_t value) { + std::ostringstream text; + text << "0x" << std::hex << std::uppercase << value; + return text.str(); +} + +std::string LoadedMsQuicPath() { + const auto module = GetModuleHandleW(L"msquic.dll"); + if (module == nullptr) return "unresolved"; + std::array path{}; + const auto length = GetModuleFileNameW(module, path.data(), static_cast(path.size())); + if (length == 0 || length >= path.size()) return "unresolved"; + const auto required = WideCharToMultiByte( + CP_UTF8, 0, path.data(), static_cast(length), nullptr, 0, nullptr, nullptr); + if (required <= 0) return "unresolved"; + std::string utf8(static_cast(required), '\0'); + WideCharToMultiByte( + CP_UTF8, 0, path.data(), static_cast(length), utf8.data(), required, nullptr, nullptr); + return utf8; +} + +QUIC_STATUS QUIC_API ConnectionCallback(HQUIC connection, void* context, QUIC_CONNECTION_EVENT* event) { + auto* client = static_cast(context); + AppendTrace(client, "event=" + std::to_string(static_cast(event->Type))); + switch (event->Type) { + case QUIC_CONNECTION_EVENT_CONNECTED: + client->state.store(ClientState::Connected); + break; + case QUIC_CONNECTION_EVENT_PEER_STREAM_STARTED: { + auto* stream = new (std::nothrow) StreamContext(client); + if (stream == nullptr) return QUIC_STATUS_OUT_OF_MEMORY; + client->api->SetCallbackHandler( + event->PEER_STREAM_STARTED.Stream, + reinterpret_cast(StreamCallback), + stream); + break; + } + case QUIC_CONNECTION_EVENT_PEER_CERTIFICATE_RECEIVED: + { + AppendTrace( + client, + "certificate-status=" + + Hex(static_cast(event->PEER_CERTIFICATE_RECEIVED.DeferredStatus))); + const auto matches = CertificateMatchesPin( + client, + event->PEER_CERTIFICATE_RECEIVED.Certificate); + if (!matches) { + SetFailure(client, "CultMesh QUIC provider certificate does not match the advertised SHA-256 pin."); + } + const auto completion = client->api->ConnectionCertificateValidationComplete( + connection, + matches ? TRUE : FALSE, + matches ? QUIC_TLS_ALERT_CODE_SUCCESS : QUIC_TLS_ALERT_CODE_BAD_CERTIFICATE); + if (QUIC_FAILED(completion)) { + SetFailure( + client, + "CultMesh QUIC certificate validation completion failed (status=" + + Hex(static_cast(completion)) + ")."); + return completion; + } + return QUIC_STATUS_PENDING; + } + case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_TRANSPORT: + if (!client->closing.load()) { + SetFailure( + client, + "CultMesh QUIC connection was shut down by the transport " + "(status=" + Hex(static_cast(event->SHUTDOWN_INITIATED_BY_TRANSPORT.Status)) + + ", error=" + Hex(event->SHUTDOWN_INITIATED_BY_TRANSPORT.ErrorCode) + + ", msquic=" + LoadedMsQuicPath() + + ", events=" + TraceSnapshot(client) + ")."); + } + break; + case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_PEER: + if (!client->closing.load()) + SetFailure(client, "CultMesh QUIC connection was shut down by the provider."); + break; + case QUIC_CONNECTION_EVENT_SHUTDOWN_COMPLETE: + if (client->closing.load()) client->state.store(ClientState::Closed); + break; + default: + break; + } + return QUIC_STATUS_SUCCESS; +} + +void CloseHandles(Client* client) { + if (client->connection != nullptr) { + client->api->ConnectionClose(client->connection); + client->connection = nullptr; + } + if (client->configuration != nullptr) { + client->api->ConfigurationClose(client->configuration); + client->configuration = nullptr; + } + if (client->registration != nullptr) { + client->api->RegistrationClose(client->registration); + client->registration = nullptr; + } + if (client->api != nullptr) { + MsQuicClose(client->api); + client->api = nullptr; + } } } // namespace CULTMESH_API int32_t cultmesh_quic_open( - const char* host, uint16_t port, const char* certificate_sha256, V1Client** result) { + const char* host, + uint16_t port, + const char* certificate_sha256, + Client** result) { if (host == nullptr || *host == '\0' || port == 0 || result == nullptr) return -1; *result = nullptr; + auto client = std::make_unique(); + if (!ParsePin(certificate_sha256, client->certificate_pin)) return -2; - std::array pin{}; - if (!ParsePin(certificate_sha256, pin)) return -2; + QUIC_STATUS status = MsQuicOpenVersion( + kApiVersion, + reinterpret_cast(&client->api)); + if (QUIC_FAILED(status)) return status; - auto client = std::make_unique(); - void* runtime_handle = nullptr; - const auto opened = cultmesh_quic_runtime_open("GameCult.Mesh.Quic.Native", &runtime_handle); - if (opened != 0) return opened; - client->runtime = static_cast(runtime_handle); + const QUIC_REGISTRATION_CONFIG registration_config = { + "GameCult.Mesh.Quic.Native", + QUIC_EXECUTION_PROFILE_TYPE_REAL_TIME + }; + status = client->api->RegistrationOpen(®istration_config, &client->registration); + if (QUIC_FAILED(status)) { + CloseHandles(client.get()); + return status; + } - // The pin goes in before the connection starts; see OpenConnection. - const auto status = OpenConnection(client->runtime, host, port, &client->connection_id, &pin); - if (status != 0) { - cultmesh_quic_runtime_close(client->runtime); + QUIC_SETTINGS settings{}; + settings.IdleTimeoutMs = 30000; + settings.IsSet.IdleTimeoutMs = TRUE; + settings.KeepAliveIntervalMs = 5000; + settings.IsSet.KeepAliveIntervalMs = TRUE; + settings.PeerUnidiStreamCount = 1024; + settings.IsSet.PeerUnidiStreamCount = TRUE; + const QUIC_BUFFER alpn = { + static_cast(sizeof(kAlpn) - 1), + reinterpret_cast(const_cast(kAlpn)) + }; + status = client->api->ConfigurationOpen( + client->registration, + &alpn, + 1, + &settings, + sizeof(settings), + nullptr, + &client->configuration); + if (QUIC_FAILED(status)) { + CloseHandles(client.get()); + return status; + } + + QUIC_CREDENTIAL_CONFIG credentials{}; + credentials.Type = QUIC_CREDENTIAL_TYPE_NONE; + credentials.Flags = static_cast( + QUIC_CREDENTIAL_FLAG_CLIENT | + QUIC_CREDENTIAL_FLAG_INDICATE_CERTIFICATE_RECEIVED | + QUIC_CREDENTIAL_FLAG_DEFER_CERTIFICATE_VALIDATION | + QUIC_CREDENTIAL_FLAG_USE_PORTABLE_CERTIFICATES); + status = client->api->ConfigurationLoadCredential(client->configuration, &credentials); + if (QUIC_FAILED(status)) { + CloseHandles(client.get()); + return status; + } + + status = client->api->ConnectionOpen( + client->registration, + ConnectionCallback, + client.get(), + &client->connection); + if (QUIC_FAILED(status)) { + CloseHandles(client.get()); + return status; + } + status = client->api->ConnectionStart( + client->connection, + client->configuration, + QUIC_ADDRESS_FAMILY_UNSPEC, + host, + port); + if (QUIC_FAILED(status)) { + CloseHandles(client.get()); return status; } @@ -1427,87 +392,49 @@ CULTMESH_API int32_t cultmesh_quic_open( return 0; } -CULTMESH_API int32_t cultmesh_quic_state(V1Client* client) { +CULTMESH_API int32_t cultmesh_quic_state(Client* client) { if (client == nullptr) return static_cast(ClientState::Failed); - std::lock_guard lock(client->gate); - Pump(client); - return static_cast(client->state); + return static_cast(client->state.load()); } CULTMESH_API int32_t cultmesh_quic_poll( - V1Client* client, uint8_t* destination, int32_t destination_length, int32_t* required_length) { + Client* client, + uint8_t* destination, + int32_t destination_length, + int32_t* required_length) { if (client == nullptr || required_length == nullptr || destination_length < 0) return -1; std::lock_guard lock(client->gate); - Pump(client); - if (client->frames.empty()) { + if (client->received.empty()) { *required_length = 0; - return client->state == ClientState::Failed ? -2 : 0; + return client->state.load() == ClientState::Failed ? -2 : 0; } - const auto& frame = client->frames.front(); + const auto& frame = client->received.front(); if (frame.size() > static_cast(INT32_MAX)) return -3; *required_length = static_cast(frame.size()); if (destination == nullptr || destination_length < *required_length) return 2; std::memcpy(destination, frame.data(), frame.size()); - client->frames.pop_front(); + client->received.pop_front(); return 1; } -CULTMESH_API int32_t cultmesh_quic_error(V1Client* client, char* destination, int32_t destination_length) { +CULTMESH_API int32_t cultmesh_quic_error( + Client* client, + char* destination, + int32_t destination_length) { if (client == nullptr || destination == nullptr || destination_length <= 0) return -1; std::lock_guard lock(client->gate); - Pump(client); const size_t count = (std::min)(client->error.size(), static_cast(destination_length - 1)); std::memcpy(destination, client->error.data(), count); destination[count] = '\0'; return static_cast(count); } -CULTMESH_API void cultmesh_quic_close(V1Client* client) { +CULTMESH_API void cultmesh_quic_close(Client* client) { if (client == nullptr) return; - { - std::lock_guard lock(client->gate); - client->closing = true; - } - // `runtime_close` already shuts the connection down silently with the same - // CULT close code and then closes the handle, which is what v1 did before - // it delegated. Shutting it down here as well would only race that. - cultmesh_quic_runtime_close(client->runtime); - client->state = ClientState::Closed; + client->closing.store(true); + if (client->connection != nullptr && client->api != nullptr) + client->api->ConnectionShutdown(client->connection, QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT, kConnectionCloseCode); + CloseHandles(client); + client->state.store(ClientState::Closed); delete client; } - -#endif // _WIN32 - -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) -// The development seam's three exports. They exist only in a build configured -// with CULTMESH_QUIC_DEBUG_ASSERTS; a shipped library exports neither these nor -// the counters behind them. See section 7 of the header. -CULTMESH_API void cultmesh_quic_debug_hold_calls(int32_t hold) { - if (hold != 0) { - debug_peak_calls.store(0); - debug_calls_at_close.store(-1); - } - { - std::lock_guard lock(debug_hold_gate); - debug_hold_armed = hold != 0; - } - debug_hold_signal.notify_all(); -} - -CULTMESH_API int32_t cultmesh_quic_debug_peak_calls(void) { - return debug_peak_calls.load(); -} - -CULTMESH_API int32_t cultmesh_quic_debug_calls_at_close(void) { - return debug_calls_at_close.load(); -} - -CULTMESH_API int32_t cultmesh_quic_debug_last_wait_ms(void) { - return debug_wait_recorded.load() ? debug_last_wait_ms.load() : -1; -} - -CULTMESH_API void cultmesh_quic_debug_reset_last_wait_ms(void) { - debug_wait_recorded.store(false); - debug_last_wait_ms.store(-1); -} -#endif diff --git a/native/GameCult.Mesh.Quic.Native/include/cultmesh_quic_native.h b/native/GameCult.Mesh.Quic.Native/include/cultmesh_quic_native.h deleted file mode 100644 index 758ecb8a..00000000 --- a/native/GameCult.Mesh.Quic.Native/include/cultmesh_quic_native.h +++ /dev/null @@ -1,371 +0,0 @@ -/* GameCult.Mesh.Quic.Native — C ABI v2, the runtime-neutral CultMesh QUIC bridge. - * - * This header is the contract. It is the single place the event layout, the - * exports, the id and return-code conventions, the object lifetime rules and the - * threading rules are stated; `cultmesh_quic_native.cpp` includes it, the README - * points at it, and a host that cannot include it (koffi, P/Invoke) declares the - * same thing in its own FFI and is checked against this file by a test. - * - * It is C. It includes nothing of MsQuic, nothing of Node, nothing of Unity, and - * nothing platform-specific: a host binds these twelve queue exports plus - * `cultmesh_quic_last_status` and needs no other build input. - * - * The v1 Unity exports (`cultmesh_quic_open`, `_state`, `_poll`, `_error`, - * `_close`) are deliberately not here. They are a Windows-only shim for a - * shipped managed connector, not a contract offered to new hosts. - */ - -#ifndef CULTMESH_QUIC_NATIVE_H -#define CULTMESH_QUIC_NATIVE_H - -#include -#include - -#if defined(__cplusplus) -#define CULTMESH_QUIC_STATIC_ASSERT(condition, message) static_assert(condition, message) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define CULTMESH_QUIC_STATIC_ASSERT(condition, message) _Static_assert(condition, message) -#else -#define CULTMESH_QUIC_STATIC_ASSERT(condition, message) -#endif - -/* `CULTMESH_QUIC_BUILD` is defined by the bridge's own translation unit and by - * nothing else. A consumer gets plain declarations and links by name, which is - * what every host here does: all three load the library at runtime. */ -#if defined(CULTMESH_QUIC_BUILD) -# if defined(_WIN32) -# define CULTMESH_QUIC_API __declspec(dllexport) -# else -# define CULTMESH_QUIC_API __attribute__((visibility("default"))) -# endif -#else -# define CULTMESH_QUIC_API -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -/* --------------------------------------------------------------------------- - * 1. The event - * - * Exactly 64 bytes, no implicit padding, field order below is the ABI. A host - * that reorders a field reads a different struct; the offsets are asserted here - * so a compiler that pads differently fails the build rather than the wire. - * --------------------------------------------------------------------------- */ - -struct cultmesh_quic_event { - uint32_t type; /* offset 0 — one of the cultmesh_quic_event_type values */ - uint32_t stream_kind; /* offset 4 — 1 reliable, 2 latest-only; 0 when not a stream event */ - uint64_t listener_id; /* offset 8 — 0 for an outbound connection */ - uint64_t connection_id; /* offset 16 */ - uint64_t stream_id; /* offset 24 */ - uint64_t code; /* offset 32 — meaning depends on `type`; see below */ - int32_t status; /* offset 40 — the raw platform QUIC status, diagnostics only */ - int32_t payload_length; /* offset 44 — bytes written into the caller's payload buffer */ - uint8_t reserved[16]; /* offset 48 — zero today; do not read meaning into it */ -}; - -CULTMESH_QUIC_STATIC_ASSERT(sizeof(struct cultmesh_quic_event) == 64, - "the event struct is a 64-byte ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, type) == 0, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, stream_kind) == 4, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, listener_id) == 8, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, connection_id) == 16, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, stream_id) == 24, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, code) == 32, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, status) == 40, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, payload_length) == 44, - "event field offsets are an ABI contract"); -CULTMESH_QUIC_STATIC_ASSERT(offsetof(struct cultmesh_quic_event, reserved) == 48, - "event field offsets are an ABI contract"); - -enum cultmesh_quic_event_type { - /* A listener accepted an inbound connection. `listener_id`, `connection_id`. */ - CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION = 1, - /* The handshake completed. `connection_id`. */ - CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED = 2, - /* Payload: the peer's DER certificate. The handshake is blocked until the - * host answers with `cultmesh_quic_connection_certificate_complete`. */ - CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED = 3, - /* The connection is gone, whoever ended it, and its id no longer resolves. - * Payload: a UTF-8 reason. `code` is the QUIC application error code — the - * peer's when the peer ended it, and the code the host passed to - * `cultmesh_quic_connection_shutdown` when the host did. Emitted exactly - * once per connection id, including for the initiator of a local shutdown: - * every connection id's end is observable from the host that owns it. */ - CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN = 4, - /* An inbound stream's first byte named its kind. `stream_id`, `stream_kind`. */ - CULTMESH_QUIC_EVENT_STREAM_STARTED = 5, - /* Payload: one whole encoded frame, the 4-byte length prefix stripped. */ - CULTMESH_QUIC_EVENT_STREAM_FRAME = 6, - /* One per `cultmesh_quic_stream_send_frame` call that returned 0, and never - * for the bridge's own kind byte. `code` is a cultmesh_quic_send_result. */ - CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE = 7, - /* The stream is gone. `stream_id`, `stream_kind`. */ - CULTMESH_QUIC_EVENT_STREAM_SHUTDOWN = 8, - /* The listener stopped. `listener_id`. */ - CULTMESH_QUIC_EVENT_LISTENER_STOPPED = 9 -}; - -/* The `code` of event 7. A canceled send is a send MsQuic released without - * putting on the wire — the stream was aborted or the connection ended under it. - * It is reported, not silently dropped. */ -enum cultmesh_quic_send_result { - CULTMESH_QUIC_SEND_COMPLETED = 0, - CULTMESH_QUIC_SEND_CANCELED = 1 -}; - -/* The first byte of every CultMesh QUIC stream. */ -enum cultmesh_quic_stream_kind { - CULTMESH_QUIC_STREAM_RELIABLE = 1, - CULTMESH_QUIC_STREAM_LATEST_ONLY = 2 -}; - -/* --------------------------------------------------------------------------- - * 2. Ids - * - * Listeners, connections and streams are named by `uint64_t` ids drawn from one - * per-runtime counter that starts at 1 and never repeats. 0 is never a valid id - * and is what an out parameter holds when a call fails. An id is the only thing - * a host ever holds: there is no host-visible pointer to a connection or stream, - * so a host cannot outlive an object it is naming. An id whose object is gone is - * a bad call (-1), not undefined behaviour. - * --------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------------- - * 3. Return codes — negative on a bad call, on every platform - * - * Every int32_t-returning export returns: - * - * 0 the call succeeded - * 1, 2 `cultmesh_quic_next_event` only; see its comment - * -1 a bad call: a null handle, a null out parameter, - * or an id whose object is gone - * -2 an argument the bridge rejects on its own terms: - * an unknown stream kind, an oversized frame, a - * listener host that is not an IP literal - * <= -1000 MsQuic refused. The bridge code is - * -(1000 + (raw_status & 0xffff)); the raw - * platform status is available from - * `cultmesh_quic_last_status` and a sentence about - * it from `cultmesh_quic_last_error`. - * - * This mapping exists because `QUIC_STATUS` itself is not portable: it is a - * negative HRESULT on Windows and a positive errno on POSIX, so a host that - * checked for a negative value saw every Linux failure as success. - * - * What the mapping makes portable is the sign, and only the sign. A failure is - * negative everywhere, and that is what a host may branch on. The magnitude of a - * <= -1000 code is diagnostic and platform-specific: the same MsQuic failure - * carries different numbers on different platforms (a TLS error is -12032 on - * win32-x64 and -1126 on linux-x64; an ALPN already in use is -1009 against - * -1091), and the 16-bit mask can give two distinct statuses the same code - * (`QUIC_STATUS_USER_CANCELED` and `QUIC_STATUS_FILE_NOT_FOUND` are both -1002 - * on Windows). Switching on a particular code is therefore not portable and not - * a reliable identification of the failure. Report it, log it, and read - * `cultmesh_quic_last_status` and `cultmesh_quic_last_error` beside it. - * --------------------------------------------------------------------------- */ - -#define CULTMESH_QUIC_RESULT_BAD_CALL (-1) -#define CULTMESH_QUIC_RESULT_BAD_ARGUMENT (-2) -#define CULTMESH_QUIC_RESULT_MSQUIC_BASE (-1000) - -/* --------------------------------------------------------------------------- - * 4. Object lifetime — resolved from an id, kept alive across the call - * - * The bridge's objects are shared-owned. The runtime's maps hold one reference - * each; an export that names an id takes its own reference under the lock and - * holds it for the whole MsQuic call, so an object cannot be freed under a host - * thread that is using it. MsQuic's worker, on shutdown-complete, removes the - * map entry and drops the map's reference only — it never frees an object a host - * call is inside. - * - * The MsQuic handle follows the object: it is closed exactly once, by whichever - * holder drops the last reference (or by `cultmesh_quic_runtime_close`), under a - * one-shot exchange guard. A handle is therefore valid for as long as any holder - * has a reference to its object, which is the property the host thread needs. A - * stream holds a reference to its connection, so stream handles are always - * closed before the connection handle they belong to. - * - * `cultmesh_quic_runtime_close` quiesces before it tears anything down. It marks - * the runtime closing, wakes every blocked `cultmesh_quic_next_event`, and waits - * for every in-flight export to return before it closes a handle or frees a - * byte. No host call may begin after `cultmesh_quic_runtime_close` starts. That - * ordering is the host's, and it is a prohibition rather than a race the bridge - * arbitrates: once the close returns, the handle names freed memory, and a call - * made with it has nothing left to refuse it. A call that races the start of the - * close, while it is still running, is refused with -1 and touches nothing; that - * narrows one mis-ordering and does not make the prohibition optional. - * --------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------------- - * 5. Threading - * - * There are no host callbacks. Every crossing is the host calling in. - * - * - MsQuic's worker threads run inside this library only. They push events onto - * the runtime's queue and wake the one blocking wait. No host code is ever - * called from a thread the host does not own. - * - `cultmesh_quic_next_event` is called from host threads, one or many. It is - * the only blocking export. Concurrent callers each get a distinct event. - * - Every other export may be called from any host thread at any time, except - * during or after `cultmesh_quic_runtime_close`. - * - `cultmesh_quic_runtime_close` is called once, from one thread, and - * quiesces as described above. - * --------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------------- - * 6. The exports - * --------------------------------------------------------------------------- */ - -/* Opens a runtime: one MsQuic registration, one event queue. `app_name` may be - * null. `*out_runtime` is the opaque handle every other export takes. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_runtime_open( - const char* app_name, void** out_runtime); - -/* Quiesces, tears down and frees the runtime. Safe to call with null. After it - * returns, the handle is dead; see section 4 for the ordering rule. */ -CULTMESH_QUIC_API void cultmesh_quic_runtime_close(void* runtime); - -/* Opens a provider listener on `host`:`port` with a PKCS12 credential. `host` - * may be null or empty for any address, otherwise it must be an IP literal. - * `port` 0 binds an ephemeral port, which `*out_bound_port` reports. A failure - * leaves no listener behind and no id allocated to the host. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_listener_open( - void* runtime, const char* host, uint16_t port, - const uint8_t* pkcs12, int32_t pkcs12_length, const char* password, - uint64_t* out_listener_id, uint16_t* out_bound_port); - -/* Stops and closes a listener. Its accepted connections are not affected. - * Emits event 9. Unknown ids are ignored. */ -CULTMESH_QUIC_API void cultmesh_quic_listener_close( - void* runtime, uint64_t listener_id); - -/* Starts an outbound connection. Certificate validation is deferred: the host - * gets event 3 and must answer. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_connection_open( - void* runtime, const char* host, uint16_t port, uint64_t* out_connection_id); - -/* Answers event 3. `accept` non-zero continues the handshake; zero fails it with - * a bad-certificate alert. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_connection_certificate_complete( - void* runtime, uint64_t connection_id, int32_t accept); - -/* Ends a connection with a QUIC application error code. The initiator gets its - * own event 4 carrying `code`, as the peer does. Unknown ids are ignored. */ -CULTMESH_QUIC_API void cultmesh_quic_connection_shutdown( - void* runtime, uint64_t connection_id, uint64_t code); - -/* Opens an outbound unidirectional stream and puts `kind` on the wire as its - * first byte. That byte is the bridge's own and never produces an event 7. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_stream_open( - void* runtime, uint64_t connection_id, uint8_t kind, uint64_t* out_stream_id); - -/* Queues one whole encoded frame, length-prefixed by the bridge. A call that - * returns 0 produces exactly one event 7 later, completed or canceled. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_stream_send_frame( - void* runtime, uint64_t stream_id, - const uint8_t* encoded_frame, int32_t length, int32_t fin); - -/* Aborts a stream with a QUIC application error code. Unknown ids are ignored. */ -CULTMESH_QUIC_API void cultmesh_quic_stream_shutdown( - void* runtime, uint64_t stream_id, uint64_t code); - -/* The one blocking crossing. - * - * 0 nothing within `timeout_ms`. A poller already blocked here when - * `cultmesh_quic_runtime_close` starts is woken and returns 0. A poll that - * begins after the close starts is forbidden by section 4, and is not a - * case this return code covers. - * 1 `*out_event` filled and up to `payload_capacity` payload bytes copied; - * `*out_required` is the payload size - * 2 `payload_capacity` is too small. Nothing is consumed and nothing is - * written to `*out_event`; `*out_required` is the size to allocate. Ask - * again with a big enough buffer and the same event is delivered. - * -1 a bad call, including a null `payload` with a non-zero - * `payload_capacity`, which is a lie about the buffer and is refused - * rather than treated as a discard. - * - * `payload` may be null when `payload_capacity` is 0: that is the two-phase - * poll's first ask. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_next_event( - void* runtime, int32_t timeout_ms, struct cultmesh_quic_event* out_event, - uint8_t* payload, int32_t payload_capacity, int32_t* out_required); - -/* The last error sentence, NUL-terminated, truncated to `capacity`. Returns the - * number of bytes written, or -1 on a bad call. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_last_error( - void* runtime, char* destination, int32_t capacity); - -/* The raw platform `QUIC_STATUS` behind the last <= -1000 return, as its own - * bits: a negative HRESULT on Windows, a positive errno on POSIX. Diagnostics - * only; what is portable about the return code is its sign, not its value. 0 - * when nothing has failed. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_last_status(void* runtime); - -/* --------------------------------------------------------------------------- - * 7. The development seam - * - * Present only in a library configured with `CULTMESH_QUIC_DEBUG_ASSERTS`, which - * a shipped build never is. It exists for the runtime-lifetime scenarios: the - * quiesce is a promise about host calls that are inside the library, and the - * wait scenarios need the same kind of promise about the exact duration the - * bridge hands its own condition wait. A scenario that can only sleep and hope - * cannot tell a bridge that counts and waits correctly from one that does not. - * - * It is process-wide, not per-runtime, because the numbers outlive the runtime - * they describe: `cultmesh_quic_runtime_close` frees the runtime, and the count - * it waited on is read afterwards. The scenarios open one runtime at a time. - * --------------------------------------------------------------------------- */ -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) - -/* Non-zero arms the hold and resets both counters: every call that reaches the - * blocking wait in `cultmesh_quic_next_event` parks inside the library instead - * of returning. Zero releases every held call and disarms it. A held call - * returns 0 and touches the runtime no further. */ -CULTMESH_QUIC_API void cultmesh_quic_debug_hold_calls(int32_t hold); - -/* The high-water mark of host calls counted inside the library since the hold - * was armed. Zero means no call was ever counted. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_debug_peak_calls(void); - -/* How many host calls were counted inside the library when the last - * `cultmesh_quic_runtime_close` began its wait, or -1 if no close has begun one - * since the hold was armed. This is the number the wait exists for. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_debug_calls_at_close(void); - -/* The whole duration, in milliseconds, most recently handed to the condition - * wait inside `cultmesh_quic_next_event`, recorded at the point the wait is - * entered rather than observed from outside. A poll whose queue is not empty, - * or whose `timeout_ms` is not greater than zero, never enters that wait and - * leaves this unchanged. -1 until the first such wait, or after - * `cultmesh_quic_debug_reset_last_wait_ms` — tracked by a separate internal - * flag, not by -1 being stored here, so a wait that ever recorded exactly -1 - * itself could not be confused with nothing having been recorded. - * - * This exists because a wall-clock probe cannot tell the host's timeout from - * any function of it that is the identity at the probe's own value — a floor, - * a round, a clamp, a later-poll fault, there is always another one that - * matches. This reads what the bridge actually handed its wait instead of - * inferring it from how long a call took. */ -CULTMESH_QUIC_API int32_t cultmesh_quic_debug_last_wait_ms(void); - -/* Resets the value `cultmesh_quic_debug_last_wait_ms` reports to -1, without - * touching the hold or the two call counters above. */ -CULTMESH_QUIC_API void cultmesh_quic_debug_reset_last_wait_ms(void); - -#endif /* CULTMESH_QUIC_DEBUG_ASSERTS */ - -#if defined(__cplusplus) -} -#endif - -#endif /* CULTMESH_QUIC_NATIVE_H */ diff --git a/native/GameCult.Mesh.Quic.Native/tests/cultmesh_quic_native_tests.cpp b/native/GameCult.Mesh.Quic.Native/tests/cultmesh_quic_native_tests.cpp deleted file mode 100644 index e42b6d25..00000000 --- a/native/GameCult.Mesh.Quic.Native/tests/cultmesh_quic_native_tests.cpp +++ /dev/null @@ -1,1305 +0,0 @@ -// Scenario runner for the bridge's runtime lifetime rules. -// -// This is the one part of the bridge a host cannot check by reading: whether -// `cultmesh_quic_runtime_close` is safe against host threads that are inside the -// library when it starts. Everything here drives that path and nothing else. It -// opens a runtime, parks pollers in `cultmesh_quic_next_event`, closes the -// runtime underneath them, and asserts what the header promises: every parked -// poller returns, and none of them touches the runtime after it is gone. -// -// It consumes the bridge through include/cultmesh_quic_native.h — the same -// contract a host has — and nothing else. No MsQuic header, no internals. -// -// The failures it exists to catch are not visible in the return values, because -// a use-after-free is not an error code. Two things make them visible instead: -// a sanitizer build (ThreadSanitizer for the notify/destroy race, AddressSanitizer -// for the freed-runtime dereference), and `CULTMESH_QUIC_DEBUG_ASSERTS`, which -// makes the bridge state the quiesce invariant itself rather than leaving it to -// be caught by an unlucky thread schedule. -// -// cultmesh_quic_native_tests closerace [iterations] [pollers] -// cultmesh_quic_native_tests holdclose [iterations] [pollers] -// cultmesh_quic_native_tests polltimeout [iterations] -// cultmesh_quic_native_tests pollbusy [iterations] -// cultmesh_quic_native_tests latecall [iterations] -// cultmesh_quic_native_tests holdtimeout [iterations] -// cultmesh_quic_native_tests waitseam [iterations] -// cultmesh_quic_native_tests pollhammer [iterations] -// cultmesh_quic_native_tests zerotimeout [iterations] -// cultmesh_quic_native_tests payloadfit [iterations] -// -// `closerace` hunts the race: many pollers, many iterations, and whatever the -// schedule gives. `holdclose` takes the guessing out of it — the bridge's -// development seam (section 7 of the header) holds the pollers inside the -// library until this scenario releases them, and reports how many host calls the -// bridge actually counted, so the scenario asserts the quiesce instead of -// assuming its own fixture worked. It needs CULTMESH_QUIC_DEBUG_ASSERTS. -// -// In both of those the wait is ended by the close, so the host's timeout governs -// nothing either of them can see, and a bridge waiting on a constant of its own -// passes both. `polltimeout` is the one that lets the timeout govern the return -// and measures it, and `pollbusy` measures it again with the host's other thread -// calling in throughout, which wakes the wait. `latecall` covers the other half -// of section 4: a call that races the start of a close is refused rather than -// counted behind its wait. -// `holdtimeout` covers the seam's own rule, which nothing else is in a position -// to see: the hold parks a call the wait woke and not one whose own timeout -// expired, so the quiesce the hold scenarios assert is the bridge's doing and -// not the fixture's. -// -// Self's ruling of 2026-09-22, after seven Soul passes against `polltimeout`, -// `pollbusy` and `holdtimeout` alone: a wall-clock probe cannot tell the host's -// timeout from any function of it that is the identity at the probe's own -// value, because there is always another function that matches. `waitseam` -// puts the observation where the rule is decided instead of where its effect -// eventually shows: it reads `cultmesh_quic_debug_last_wait_ms`, the bridge's -// own account of what it handed its condition wait, and asserts equality -// against the host's argument, deterministically, with no timing tolerance. -// `polltimeout`, `pollbusy` and `holdtimeout` stay only as generous-margin -// proof that the recorded wait is really waited and not merely recorded. -// `pollhammer` covers the wait's predicate the same way `pollbusy` used to try -// to: one thread hammers every gate-touching entry point that cannot itself -// queue an event, in a yield loop, while another holds a single idle poll, and -// the poll must still stay for its timeout. -// -// Exit code 0 means every assertion held. Anything else, including a sanitizer -// abort or the bridge's own assertion, is a failure. Under ThreadSanitizer run -// it with `TSAN_OPTIONS=halt_on_error=1`, or a reported race leaves the exit -// code to the last thing that set it. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - -// `CloseRaceOnce`'s own settle budget, named here — ahead of `kPollTimeoutMs` -// below — so the poll timeout can be derived from it instead of drifting apart -// as a second freestanding number. Under CPU starvation the settle can spend -// this whole budget waiting for every poller to be counted inside the library -// before the close begins; a poll timeout shorter than that lets the first -// pollers time out for real while the fixture is still waiting on the last -// ones, which is exactly the failure this scenario exists to catch, not the -// one it is supposed to be running. -constexpr int32_t kCloseRaceCountedDeadlineMs = 30000; // asserts-on: cap on the peak_calls wait -constexpr int32_t kCloseRaceAssertsSettleMs = 50; // asserts-on: fixed remainder after counted -constexpr int32_t kCloseRaceNoSeamSettleMs = 500; // no-seam #else: fixed settle window -constexpr int32_t kCloseRaceSettleBudgetMs = - (kCloseRaceCountedDeadlineMs + kCloseRaceAssertsSettleMs) > kCloseRaceNoSeamSettleMs - ? (kCloseRaceCountedDeadlineMs + kCloseRaceAssertsSettleMs) - : kCloseRaceNoSeamSettleMs; - -// Long enough that a poller is still parked when the close begins, in every -// configuration, even when the settle above burns its whole budget. The close -// is what ends the wait; this timeout only bounds the scenario if the close -// never arrives, which is itself the failure, so a long poll timeout costs -// nothing on a passing run. The flat 5 s margin is headroom above the settle -// budget, not a second guess at it. -constexpr int32_t kPollTimeoutMs = kCloseRaceSettleBudgetMs + 5000; - -// A poller asks for a payload buffer, so the close races a `next_event` that has -// somewhere to copy into rather than one that can only ever return 0. -constexpr int32_t kPayloadCapacity = 4096; - -int Fail(const std::string& message) { - std::fprintf(stderr, "FAILED: %s\n", message.c_str()); - return 1; -} - -// One iteration: `pollers` threads parked in `next_event`, then a close under -// them. Returns an empty string when every promise held. -// -// Each poller makes exactly one blocking call and does not call again. Section 5 -// of the header puts the ordering on the host — no call may *begin* during a -// close — so a scenario that kept re-entering would be testing a shape the -// bridge declines to support, and its report would be the harness's own fault. -// A call already inside the library is the case the quiesce exists for, and that -// is the one run here. -std::string CloseRaceOnce(int pollers) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - // Counts threads about to enter the blocking call. The close waits for all of - // them, so the race is run with the pollers actually inside rather than with - // threads that have not started yet. - std::atomic entering{0}; - std::atomic returned{0}; - std::atomic undefined_return{0}; - std::atomic timed_out{0}; - // Set just before the close, and read by each poller as it returns. A poller - // that is already out by then was never in the race, and a scenario full of - // those passes without testing anything: this is what catches a bridge whose - // blocking crossing has stopped blocking. - std::atomic closing_started{false}; - std::atomic left_before_the_close{0}; - -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) - // Reset before any poller thread exists, so nothing here can race a - // `CallScope` that has already been counted: `cultmesh_quic_next_event` - // raises `debug_peak_calls` the moment its `CallScope` is constructed, at - // the very top of the call, and a reset performed even microseconds after - // that construction would zero a count no further call is coming to raise - // again, stranding the settle loop below at "not yet" until its deadline. - cultmesh_quic_debug_hold_calls(1); - cultmesh_quic_debug_hold_calls(0); -#endif - - std::vector threads; - threads.reserve(static_cast(pollers)); - for (int index = 0; index < pollers; ++index) { - threads.emplace_back([runtime, &entering, &returned, &undefined_return, &timed_out, - &closing_started, &left_before_the_close] { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - - entering.fetch_add(1); - const auto started = std::chrono::steady_clock::now(); - // Parked here when the close arrives. `closing` wakes the wait; the - // call scope this thread holds is what the close must count out - // before it frees anything. - const int32_t result = cultmesh_quic_next_event( - runtime, kPollTimeoutMs, &event, payload.data(), kPayloadCapacity, &required); - const auto elapsed = std::chrono::duration_cast( - std::chrono::steady_clock::now() - started).count(); - - if (result != 0 && result != 1 && result != 2) undefined_return.fetch_add(1); - // The close is what ends this wait. Sitting out the whole timeout - // instead means the wake never reached it. - if (elapsed >= kPollTimeoutMs / 2) timed_out.fetch_add(1); - if (!closing_started.load()) left_before_the_close.fetch_add(1); - returned.fetch_add(1); - }); - } - - while (entering.load() < pollers) std::this_thread::yield(); -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) - // A fixed settle races CPU starvation: under enough contending threads a - // poller that has only incremented `entering` can sit preempted for far - // longer than any sleep this scenario could afford, so the close would - // begin before it ever reached the blocking wait — not the race this - // scenario exists to run, just a fixture that gave up too soon. Where the - // development seam is compiled in, this reads the bridge's own count - // instead of guessing at a duration: the settle ends only once every - // poller is actually counted inside, however long the scheduler took. - const auto counted_deadline = std::chrono::steady_clock::now() + - std::chrono::milliseconds(kCloseRaceCountedDeadlineMs); - while (cultmesh_quic_debug_peak_calls() < pollers && - std::chrono::steady_clock::now() < counted_deadline) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - - // The fixture's own settle can fail to reach every poller inside the - // deadline above, distinct from the race this scenario exists to run. - // Proceeding to the close anyway would then produce the pollers' own - // failure message — "N of M pollers returned before the close began" — - // which blames the pollers for a race the fixture never set up. Report - // this plainly instead, and unstick the parked pollers before returning so - // this iteration does not just sit out `kPollTimeoutMs`. - const int32_t counted = cultmesh_quic_debug_peak_calls(); - if (counted < pollers) { - closing_started.store(true); - cultmesh_quic_runtime_close(runtime); - for (auto& thread : threads) thread.join(); - return "fixture could not settle: " + std::to_string(counted) + " of " + - std::to_string(pollers) + " pollers counted inside after " + - std::to_string(kCloseRaceCountedDeadlineMs) + " ms"; - } - - // `active_calls` — what `peak_calls` reflects — is raised the moment a - // poller's `CallScope` is constructed, at the top of - // `cultmesh_quic_next_event`, not when it reaches the condition wait a few - // statements later. Counted-inside is the expensive part to wait for under - // starvation (getting the scheduler to run a thread at all); a short fixed - // settle covers the cheap remainder (a lock acquisition and an empty-queue - // check) once every poller is already scheduled and running. - std::this_thread::sleep_for(std::chrono::milliseconds(kCloseRaceAssertsSettleMs)); -#else - // No seam in this configuration (the sanitizer build deliberately ships - // without one), so the settle falls back to a longer fixed window rather - // than the 50 ms that starved under 16 contending burners. It is still a - // window, not a guarantee — the honest limit of a config with no way to - // ask the bridge what it has actually counted. - std::this_thread::sleep_for(std::chrono::milliseconds(kCloseRaceNoSeamSettleMs)); -#endif - - closing_started.store(true); - cultmesh_quic_runtime_close(runtime); - for (auto& thread : threads) thread.join(); - - if (left_before_the_close.load() != 0) - return std::to_string(left_before_the_close.load()) + " of " + std::to_string(pollers) + - " pollers returned before the close began, so they were never in the race"; - if (undefined_return.load() != 0) - return std::to_string(undefined_return.load()) + " poller(s) saw a return the header does not define"; - if (timed_out.load() != 0) - return std::to_string(timed_out.load()) + " of " + std::to_string(pollers) + - " pollers sat out the timeout instead of being woken by the close"; - if (returned.load() != pollers) - return std::to_string(returned.load()) + " of " + std::to_string(pollers) + " pollers returned"; - return {}; -} - -// The three timeouts `polltimeout` asks for: a spread, not a hunt for any -// particular derivation. `waitseam` is what proves the bridge hands its -// condition wait the host's own argument, exactly, at every value that matters -// — these three exist only to prove that value is then really waited on, so -// the spread just needs to be a short one, an ordinary one and a long one. -constexpr int32_t kShortestPollMs = 15; -constexpr int32_t kShortPollMs = 200; -constexpr int32_t kLongPollMs = 7300; - -// How much sooner than the timeout a poll may return. A wait may be late; it may -// not be early, because returning early is exactly what waiting on a shorter -// duration looks like. This is scheduler granularity, not slack. -constexpr int kEarlyToleranceMs = 20; - -// How much later than the timeout a poll may return. Generous on purpose: these -// scenarios are no longer where a clamp, a floor, a round or a scale is caught -// — `waitseam` catches those by equality, with no clock involved — so this only -// has to catch a wait that is wrong by a lot: a constant of the bridge's own, a -// wait that never happens, a hold that parks a call its own timeout already -// ended, or the W1-W3 family Self's ruling of 2026-09-22 added, which apply -// their arithmetic to the duration `wait_for` actually receives *after* the -// seam has already recorded it and so cannot be caught by `waitseam`'s -// equality check at all. 400 ms sits above the worst overshoot a 16-burner -// stress pass measured on a loaded win32 host (180 ms; 27 ms on linux) and -// below every one of W1-W3's smallest offsets (485 ms), so one flat margin -// still serves every probe this file times without going blind to the family -// it was widened for. -constexpr int kGenerousLateToleranceMs = 400; - -struct TimedPoll { - int32_t result; - long long elapsed_ms; -}; - -TimedPoll PollFor(void* runtime, int32_t timeout_ms) { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - const auto started = std::chrono::steady_clock::now(); - const int32_t result = cultmesh_quic_next_event( - runtime, timeout_ms, &event, payload.data(), kPayloadCapacity, &required); - const auto elapsed = std::chrono::duration_cast( - std::chrono::steady_clock::now() - started).count(); - return {result, elapsed}; -} - -// The host's timeout, and the only thing it is: how long a poll with nothing to -// deliver stays inside the library. Nothing else here checks it — `closerace` -// and `holdclose` both end their waits with a close, so in both of them the -// bridge could wait on any duration at all and every assertion would still hold. -// A runtime with no listener and no connection has nothing to deliver, so the -// timeout is what ends this poll, and the elapsed time is what it waited on. -// The bands every timed poll is held to, and the worst overshoot seen, which is -// printed so a tolerance can be checked against a machine under load rather than -// trusted. -struct Overshoot { - long long worst_ms = LLONG_MIN; - void Record(const TimedPoll& poll, int32_t timeout_ms) { - worst_ms = (std::max)(worst_ms, poll.elapsed_ms - timeout_ms); - } -}; - -std::string CheckTimedPoll(const TimedPoll& poll, int32_t timeout_ms, int late_tolerance_ms) { - const std::string asked = "a poll asking for " + std::to_string(timeout_ms) + " ms "; - if (poll.result != 0) - return asked + "returned " + std::to_string(poll.result) + ", not the 0 an idle runtime owes it"; - if (poll.elapsed_ms < timeout_ms - kEarlyToleranceMs) - return asked + "returned after " + std::to_string(poll.elapsed_ms) + - " ms: the wait ended on some shorter duration than the one it was given"; - if (poll.elapsed_ms > static_cast(timeout_ms) + late_tolerance_ms) - return asked + "returned after " + std::to_string(poll.elapsed_ms) + - " ms: the wait ended on some longer duration than the one it was given"; - return {}; -} - -constexpr std::array kTimedProbesMs{kShortestPollMs, kShortPollMs, kLongPollMs}; - -std::string PollTimeoutOnce(std::array& overshoot) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - std::string failure; - for (size_t probe = 0; probe < kTimedProbesMs.size() && failure.empty(); ++probe) { - const TimedPoll poll = PollFor(runtime, kTimedProbesMs[probe]); - overshoot[probe].Record(poll, kTimedProbesMs[probe]); - failure = CheckTimedPoll(poll, kTimedProbesMs[probe], kGenerousLateToleranceMs); - } - - cultmesh_quic_runtime_close(runtime); - return failure; -} - -int PollTimeout(int iterations) { - std::array overshoot{}; - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = PollTimeoutOnce(overshoot); - if (!failure.empty()) - return Fail("polltimeout iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("polltimeout %dx: ok (worst overshoot %lld ms at %d, %lld ms at %d, %lld ms at %d)\n", - iterations, overshoot[0].worst_ms, kTimedProbesMs[0], overshoot[1].worst_ms, kTimedProbesMs[1], - overshoot[2].worst_ms, kTimedProbesMs[2]); - return 0; -} - -// How long `pollbusy`'s poll asks for, and how often the host's other thread -// calls into the library while it waits. -constexpr int32_t kBusyPollMs = 1000; -constexpr int kBusyCallEveryMs = 20; - -// The same rule as `polltimeout` — a poll with nothing to deliver stays for its -// timeout — for a host with more than one thread, which is every real host: one -// thread polls, another sends, shuts streams down, reads the last error. -// -// Every host call leaves through a scope that wakes every waiter on the -// runtime's condition variable, because that is how the close learns a call has -// left. So a poll is woken each time any other thread makes any call, and what -// keeps it inside is the wait's predicate: nothing queued and no close means -// wait again, for the rest of the time the host asked for. With one host thread -// nothing else ever calls during the wait, and the predicate could be deleted -// with every other scenario still green. -// -// The other thread keeps calling for twice the poll's timeout and then stops, -// so a wait that restarts its whole timeout on every wake is seen as late -// rather than hanging the scenario. -std::string PollBusyOnce(Overshoot& overshoot) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - std::atomic calls{0}; - std::atomic refused{0}; - std::thread other([runtime, &calls, &refused] { - const auto until = std::chrono::steady_clock::now() + std::chrono::milliseconds(2 * kBusyPollMs); - std::array message{}; - while (std::chrono::steady_clock::now() < until) { - if (cultmesh_quic_last_error(runtime, message.data(), static_cast(message.size())) < 0) - refused.fetch_add(1); - calls.fetch_add(1); - std::this_thread::sleep_for(std::chrono::milliseconds(kBusyCallEveryMs)); - } - }); - - const TimedPoll poll = PollFor(runtime, kBusyPollMs); - const int calls_during = calls.load(); - other.join(); - cultmesh_quic_runtime_close(runtime); - - overshoot.Record(poll, kBusyPollMs); - if (refused.load() != 0) - return std::to_string(refused.load()) + " call(s) from the host's other thread were refused " - "by a runtime that was not closing"; - // The timing first: a poll that left on the first wake returns before the - // other thread has had time to make many calls, and that is the bridge - // failing, not the fixture. - const std::string failure = CheckTimedPoll(poll, kBusyPollMs, kGenerousLateToleranceMs); - if (!failure.empty()) return failure + ", while the host's other thread was calling in"; - // A poll that passed with fewer calls than this was never woken, and passed - // because the fixture did nothing rather than because the bridge held. - if (calls_during < 3) - return "the host's other thread made " + std::to_string(calls_during) + - " call(s) during the poll, so nothing woke it"; - return {}; -} - -int PollBusy(int iterations) { - Overshoot overshoot{}; - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = PollBusyOnce(overshoot); - if (!failure.empty()) - return Fail("pollbusy iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("pollbusy %dx: ok (worst overshoot %lld ms at %d)\n", iterations, overshoot.worst_ms, - kBusyPollMs); - return 0; -} - -// Nothing listens on the discard port, so a connection to it fails and the -// bridge says why. That reason is the payload this scenario needs, and reaching -// it takes no listener, no credential and no established connection. -constexpr uint16_t kClosedPort = 9; - -// How long the failure is given to arrive. The loopback refusal is immediate; -// if the refusal is swallowed instead, MsQuic's own handshake timeout ends the -// connection at 10 seconds and event 4 still arrives, so this only bounds a -// bridge that reports nothing at all. -constexpr int kEventDeadlineMs = 20000; - -// The bridge writes its own reason sentences and every one of them starts here. -// Checking the bytes, and not only the length, is what separates a payload -// copied out of the queued event from one copied out of an event that was popped -// first: the second reads freed memory, which does not spell this. -constexpr char kReasonPrefix[] = "CultMesh QUIC connection"; - -// The two-phase poll, which is the shape every host uses to size its buffer: -// ask with nothing, be told what it needs, ask again. What makes it work is that -// the refusal consumes nothing — the event is still queued, payload and all, -// after a return of 2 — and that the copy happens before the event is popped. -// Both are section 6 of the header, and nothing committed reached either. -std::string PayloadFitOnce() { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - std::string failure; - uint64_t connection_id = 0; - const int32_t connecting = - cultmesh_quic_connection_open(runtime, "127.0.0.1", kClosedPort, &connection_id); - if (connecting != 0) { - cultmesh_quic_runtime_close(runtime); - return "cultmesh_quic_connection_open returned " + std::to_string(connecting); - } - - // An out parameter the bridge must not write on a refusal, filled with - // something the bridge never writes so that a write is visible. - cultmesh_quic_event poisoned{}; - std::memset(&poisoned, 0xab, sizeof(poisoned)); - cultmesh_quic_event event = poisoned; - int32_t required = 0; - int32_t result = 0; - - // Ask with no room at all until the event carrying the failure reason - // arrives. An event with no payload fits in nothing, so it is delivered and - // polled past rather than mistaken for this one. - const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(kEventDeadlineMs); - for (;;) { - event = poisoned; - required = 0; - result = cultmesh_quic_next_event(runtime, 250, &event, nullptr, 0, &required); - if (result == 2 && required > 0) break; - if (result < 0) { - failure = "cultmesh_quic_next_event returned " + std::to_string(result); - break; - } - if (std::chrono::steady_clock::now() >= deadline) { - failure = "no event carrying a payload arrived within " + - std::to_string(kEventDeadlineMs) + " ms of a connection to a closed port"; - break; - } - } - - if (failure.empty() && std::memcmp(&event, &poisoned, sizeof(event)) != 0) - failure = "the refusal wrote to *out_event, which the header says it leaves alone"; - - // Again, with the same empty buffer: a refusal that consumed the event - // leaves nothing to find the second time. - if (failure.empty()) { - cultmesh_quic_event again = poisoned; - int32_t required_again = 0; - const int32_t second = cultmesh_quic_next_event(runtime, 0, &again, nullptr, 0, &required_again); - if (second != 2 || required_again != required) - failure = "the second ask returned " + std::to_string(second) + " needing " + - std::to_string(required_again) + ", not the 2 needing " + std::to_string(required) + - " the first one did: the refusal consumed the event"; - } - - // And with room, which is where the copy happens. The tail beyond the - // payload is written too, so a copy that ran past what it was told to write - // is visible. - if (failure.empty()) { - constexpr uint8_t kTail = 0x5a; - std::vector payload(static_cast(required) + 16, kTail); - cultmesh_quic_event delivered = poisoned; - int32_t required_delivered = 0; - const int32_t third = cultmesh_quic_next_event( - runtime, 0, &delivered, payload.data(), static_cast(payload.size()), - &required_delivered); - const std::string reason(reinterpret_cast(payload.data()), - static_cast(required)); - if (third != 1 || required_delivered != required) - failure = "the ask with room returned " + std::to_string(third) + " needing " + - std::to_string(required_delivered) + ", not the 1 needing " + - std::to_string(required) + " the refusal promised"; - else if (delivered.type != CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN || - delivered.connection_id != connection_id || - delivered.payload_length != required) - failure = "the delivered event was type " + std::to_string(delivered.type) + - " on connection " + std::to_string(delivered.connection_id) + " carrying " + - std::to_string(delivered.payload_length) + " byte(s), not the failed connection's own"; - else if (reason.rfind(kReasonPrefix, 0) != 0) - failure = "the payload delivered was '" + reason + "', not a reason this bridge writes"; - else if (payload[static_cast(required)] != kTail) - failure = "the copy wrote past the " + std::to_string(required) + " bytes it reported"; - } - - // Consumed now, and only now. - if (failure.empty()) { - cultmesh_quic_event emptied = poisoned; - int32_t required_emptied = 0; - const int32_t fourth = - cultmesh_quic_next_event(runtime, 0, &emptied, nullptr, 0, &required_emptied); - if (fourth != 0) - failure = "the event was still queued after being delivered: a further ask returned " + - std::to_string(fourth); - } - - cultmesh_quic_runtime_close(runtime); - return failure; -} - -int PayloadFit(int iterations) { - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = PayloadFitOnce(); - if (!failure.empty()) - return Fail("payloadfit iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("payloadfit %dx: ok\n", iterations); - return 0; -} - -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) - -// How long a poll that does not block is given to prove it by returning, after -// the calls have been counted and before the close begins. A bridge whose -// blocking wait no longer blocks has emptied itself of host calls by the time -// the close starts, and `calls_at_close` then says 0. -constexpr int kSettleMs = 100; - -// How long the close is required to stay inside `cultmesh_quic_runtime_close` -// while the pollers are held. The held calls are what it is waiting for, and -// nothing releases them until this elapses, so a close that returns first gave -// up on a call that was still inside. This bounds what the scenario can see: a -// close that waits for longer than this and then gives up is not distinguished -// from one that waits properly, which is the honest limit of the check. -constexpr int kHeldWindowMs = 500; - -// How long the pollers are given to be counted inside the library before the -// close begins. Reaching `pollers` is the normal path; the deadline only stops -// a bridge that never counts them from hanging the scenario. -constexpr int kCountedDeadlineMs = 2000; - -// One iteration of the quiesce itself, with the guesswork taken out: the pollers -// are held inside the library by the bridge's own development seam until this -// scenario lets them go, and the bridge says how many calls it counted rather -// than the scenario assuming the schedule put them there. -// -// Three promises, and a mutation that breaks any one of them is seen here: -// - the calls are counted (`peak`), so a blocking crossing outside a call scope -// is not merely uncounted-but-lucky, it reads as zero; -// - they were still counted when the close began its wait (`calls_at_close`), -// so a poll that stopped blocking cannot leave the scenario testing an empty -// library; -// - the close did not return while they were held, so a wait that gives up -// after any interval shorter than the hold is not a wait. -std::string HoldCloseOnce(int pollers) { - cultmesh_quic_debug_hold_calls(1); - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) { - cultmesh_quic_debug_hold_calls(0); - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - } - - std::atomic returned{0}; - std::atomic undefined_return{0}; - std::vector threads; - threads.reserve(static_cast(pollers)); - for (int index = 0; index < pollers; ++index) { - threads.emplace_back([runtime, &returned, &undefined_return] { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - const int32_t result = cultmesh_quic_next_event( - runtime, kPollTimeoutMs, &event, payload.data(), kPayloadCapacity, &required); - if (result != 0 && result != 1 && result != 2) undefined_return.fetch_add(1); - returned.fetch_add(1); - }); - } - - const auto counted_deadline = - std::chrono::steady_clock::now() + std::chrono::milliseconds(kCountedDeadlineMs); - while (cultmesh_quic_debug_peak_calls() < pollers && - std::chrono::steady_clock::now() < counted_deadline) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - std::this_thread::sleep_for(std::chrono::milliseconds(kSettleMs)); - - std::atomic closed{false}; - std::thread closer([runtime, &closed] { - cultmesh_quic_runtime_close(runtime); - closed.store(true); - }); - const auto held_until = - std::chrono::steady_clock::now() + std::chrono::milliseconds(kHeldWindowMs); - while (!closed.load() && std::chrono::steady_clock::now() < held_until) - std::this_thread::sleep_for(std::chrono::milliseconds(5)); - - const bool closed_while_held = closed.load(); - const int32_t peak = cultmesh_quic_debug_peak_calls(); - const int32_t at_close = cultmesh_quic_debug_calls_at_close(); - - cultmesh_quic_debug_hold_calls(0); - closer.join(); - for (auto& thread : threads) thread.join(); - - if (peak != pollers) - return "the library's peak count of host calls inside it was " + std::to_string(peak) + ", not " + - std::to_string(pollers) + ": either the blocking crossing is not inside a call scope, or it " + - "did not block long enough for the pollers to be inside it together"; - if (at_close != pollers) - return "the close began its wait with " + std::to_string(at_close) + - " host call(s) counted inside, not " + std::to_string(pollers) + - "; the pollers were not inside the library when the close started"; - if (closed_while_held) - return "the close returned while " + std::to_string(pollers) + - " host call(s) were still held inside the library"; - if (undefined_return.load() != 0) - return std::to_string(undefined_return.load()) + " poller(s) saw a return the header does not define"; - if (returned.load() != pollers) - return std::to_string(returned.load()) + " of " + std::to_string(pollers) + " pollers returned"; - return {}; -} - -// One iteration of the other half of section 4: a call made while a close is -// running is refused, and is not counted behind the close's wait. -// -// The prohibition is the host's — no call may begin after the close starts — and -// the bridge does not make it optional. What it does do is refuse the call that -// races the start, and that refusal is load-bearing rather than courteous: a -// call admitted after the closer has begun increments the in-flight count behind -// a wait that has already read it, and the wait can then be left waiting on a -// count that reaches zero only when the late caller happens to leave. -// -// The seam is what makes the window wide enough to aim at: a held poller keeps -// the close inside its wait for as long as this scenario wants it there. -std::string LateCallOnce() { - cultmesh_quic_debug_hold_calls(1); - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) { - cultmesh_quic_debug_hold_calls(0); - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - } - - std::thread poller([runtime] { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - cultmesh_quic_next_event( - runtime, kPollTimeoutMs, &event, payload.data(), kPayloadCapacity, &required); - }); - - const auto counted_deadline = - std::chrono::steady_clock::now() + std::chrono::milliseconds(kCountedDeadlineMs); - while (cultmesh_quic_debug_peak_calls() < 1 && - std::chrono::steady_clock::now() < counted_deadline) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - std::this_thread::sleep_for(std::chrono::milliseconds(kSettleMs)); - - std::thread closer([runtime] { cultmesh_quic_runtime_close(runtime); }); - // The close has begun its wait once it has read the count, and the held - // poller is what keeps it there. - const auto started_deadline = - std::chrono::steady_clock::now() + std::chrono::milliseconds(kCountedDeadlineMs); - while (cultmesh_quic_debug_calls_at_close() < 0 && - std::chrono::steady_clock::now() < started_deadline) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - const int32_t at_close = cultmesh_quic_debug_calls_at_close(); - - // Two calls, from a thread of their own so that a bridge which admits them - // cannot park this one: one that does not block, and then the blocking - // crossing. That order, because a bridge that admits the blocking one parks - // it inside the library until the hold is released, and a call made after - // that would be racing the teardown rather than the wait. - std::atomic late_poll{0}; - std::atomic late_error{0}; - std::thread late([runtime, &late_poll, &late_error] { - std::array message{}; - late_error.store(cultmesh_quic_last_error(runtime, message.data(), - static_cast(message.size()))); - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - late_poll.store(cultmesh_quic_next_event( - runtime, kPollTimeoutMs, &event, payload.data(), kPayloadCapacity, &required)); - }); - - std::this_thread::sleep_for(std::chrono::milliseconds(kSettleMs)); - cultmesh_quic_debug_hold_calls(0); - late.join(); - closer.join(); - poller.join(); - - if (at_close < 1) - return "the close did not begin its wait with the poller counted inside, so nothing held it " - "open for a call to race"; - if (late_poll.load() != -1) - return "cultmesh_quic_next_event returned " + std::to_string(late_poll.load()) + - " to a call made during the close, not the -1 that refuses it"; - if (late_error.load() != -1) - return "cultmesh_quic_last_error returned " + std::to_string(late_error.load()) + - " to a call made during the close, not the -1 that refuses it"; - return {}; -} - -// How long `holdtimeout`'s two polls ask for, and how long the hold stays armed -// under them. The gap between each poll and the hold is the whole measurement: -// a poll the hold parks leaves when the hold is released, so its elapsed time -// lands at the last number instead of its own. -// -// Two polls, a short one and a long one, because a guard that tests the timeout -// instead of the wake — park it unless it was long — is identity on any single -// value on one side of its threshold. The long one sits above 1500, the stated -// ceiling on how long the hold guard may treat a long wait as surely worth -// parking; the hold stays armed well past it so a guard that parks anyway is -// held for the rest of the arming instead of leaving on its own timeout, which -// is the overshoot this scenario's late tolerance is wide enough to see. -constexpr int32_t kHeldTimeoutPollMs = 150; -constexpr int32_t kHeldLongTimeoutPollMs = 1600; -constexpr int kHoldArmedMs = 3000; - -// The seam's own rule, and the only scenario that can see it: the hold parks a -// call the wait woke, and not one whose own timeout expired. -// -// Everything else that arms the hold parks a woken call, so the guard governs -// nothing either of them observes — the timeout scenario never arms the hold, -// and the hold scenarios never let a timeout expire, so nothing was ever in -// both states at once and the guard could be deleted with every scenario still -// green. This puts calls in both states: the hold is armed, and the runtime is -// idle, so each wait ends on its timeout and the call is on its way out. -// -// It matters because a scenario that parked such a call would then report the -// bridge keeping a host call inside the library when what kept it was the -// fixture — the quiesce numbers `holdclose` asserts would be the seam's, not -// the bridge's. -std::string HoldTimeoutOnce(std::array& overshoot) { - cultmesh_quic_debug_hold_calls(1); - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) { - cultmesh_quic_debug_hold_calls(0); - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - } - - // Each on a thread of its own, because a parked call does not come back until - // the release below and this thread is what releases it. - constexpr std::array timeouts{kHeldTimeoutPollMs, kHeldLongTimeoutPollMs}; - std::array polls{}; - std::array pollers; - for (size_t index = 0; index < timeouts.size(); ++index) - pollers[index] = std::thread([runtime, &polls, &timeouts, index] { - polls[index] = PollFor(runtime, timeouts[index]); - }); - - std::this_thread::sleep_for(std::chrono::milliseconds(kHoldArmedMs)); - cultmesh_quic_debug_hold_calls(0); - for (auto& poller : pollers) poller.join(); - cultmesh_quic_runtime_close(runtime); - - for (size_t index = 0; index < timeouts.size(); ++index) { - const TimedPoll& poll = polls[index]; - const int32_t timeout_ms = timeouts[index]; - overshoot[index].Record(poll, timeout_ms); - if (poll.result != 0) - return "a poll ended by its own timeout returned " + std::to_string(poll.result) + - ", not the 0 an idle runtime owes it"; - if (poll.elapsed_ms < timeout_ms - kEarlyToleranceMs) - return "a poll asking for " + std::to_string(timeout_ms) + " ms returned after " + - std::to_string(poll.elapsed_ms) + " ms, so the fixture never let its timeout run out"; - if (poll.elapsed_ms > timeout_ms + kGenerousLateToleranceMs) - return "a poll asking for " + std::to_string(timeout_ms) + " ms returned after " + - std::to_string(poll.elapsed_ms) + " ms: the hold parked a call its own timeout had " - "already ended, and it left when the hold did"; - } - return {}; -} - -int HoldTimeout(int iterations) { - std::array overshoot{}; - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = HoldTimeoutOnce(overshoot); - if (!failure.empty()) - return Fail("holdtimeout iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("holdtimeout %dx: ok (worst overshoot %lld ms at %d, %lld ms at %d)\n", iterations, - overshoot[0].worst_ms, kHeldTimeoutPollMs, overshoot[1].worst_ms, kHeldLongTimeoutPollMs); - return 0; -} - -int LateCall(int iterations) { - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = LateCallOnce(); - if (!failure.empty()) - return Fail("latecall iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("latecall %dx: ok\n", iterations); - return 0; -} - -int HoldClose(int iterations, int pollers) { - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = HoldCloseOnce(pollers); - if (!failure.empty()) - return Fail("holdclose iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("holdclose %dx%d: ok\n", iterations, pollers); - return 0; -} - -// The values `waitseam` asks for: the smallest, the seam's own sentinel-versus- -// zero boundary, one on either side of a 16 ms quantum and of a 40 ms one, the -// ordinary `pollbusy` timeout and its neighbours, `polltimeout`'s long probe, -// and INT32_MAX. Nothing in section 6 of the header states a maximum on -// `timeout_ms` narrower than what `int32_t` itself holds, so INT32_MAX is the -// ceiling this checks and nothing wider is claimed. -constexpr std::array kWaitSeamProbesMs{ - 0, 1, 15, 16, 39, 40, 999, 1000, 1001, 7300, INT32_MAX}; - -// How long a probe's own poller thread is given to reach the wait before this -// gives up on it and fails with the probe named, rather than hanging. -constexpr int kWaitSeamDeadlineMs = 2000; - -// One probe: ask a fresh, otherwise-idle runtime for `timeout_ms` and read -// `cultmesh_quic_debug_last_wait_ms` — the bridge's own account of what it -// handed its condition wait — instead of measuring how long the call took. -// Every clamp, floor, round, scale, offset and later-poll mapping Soul's seven -// passes found is the identity at some wall-clock probe; none of them is the -// identity here unless it is also the identity at every value below, because -// this reads the argument itself rather than inferring it from elapsed time. -// -// `timeout_ms <= 0` never reaches the wait at all — `cultmesh_quic_next_event` -// returns at once when the queue is empty — so there is nothing for the seam to -// record, and the honest check is the converse: it must still say nothing, -// which is exactly what a seam that recorded the raw argument on every call, -// instead of only the value it actually handed its wait, would get wrong. -std::string WaitSeamProbeOnce(int32_t timeout_ms) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - cultmesh_quic_debug_reset_last_wait_ms(); - - std::string failure; - if (timeout_ms <= 0) { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - const int32_t result = cultmesh_quic_next_event( - runtime, timeout_ms, &event, payload.data(), kPayloadCapacity, &required); - const int32_t recorded = cultmesh_quic_debug_last_wait_ms(); - if (result != 0) - failure = "a poll asking for " + std::to_string(timeout_ms) + " ms returned " + - std::to_string(result) + ", not the 0 an idle runtime owes it"; - else if (recorded != -1) - failure = "a poll asking for " + std::to_string(timeout_ms) + " ms recorded " + - std::to_string(recorded) + " ms on the wait seam, though the bridge's own guard " - "never enters a wait for a timeout that is not greater than zero"; - cultmesh_quic_runtime_close(runtime); - return failure; - } - - // A real wait, on a thread of its own: a probe at INT32_MAX has to be - // released by the close, not waited out. - std::thread poller([runtime, timeout_ms] { - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - cultmesh_quic_next_event(runtime, timeout_ms, &event, payload.data(), kPayloadCapacity, &required); - }); - - const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(kWaitSeamDeadlineMs); - int32_t recorded = cultmesh_quic_debug_last_wait_ms(); - while (recorded == -1 && std::chrono::steady_clock::now() < deadline) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - recorded = cultmesh_quic_debug_last_wait_ms(); - } - - cultmesh_quic_runtime_close(runtime); - poller.join(); - - if (recorded != timeout_ms) - failure = "a poll asking for " + std::to_string(timeout_ms) + " ms recorded " + - std::to_string(recorded) + " ms on the wait seam: the bridge handed its condition " - "wait something other than the host's own argument"; - return failure; -} - -// Past the twelfth poll on one runtime: no scenario before this one ever asked -// a runtime for a thirteenth, so a wait that only changes shape after twelve -// had nowhere to be seen. Forty short waits on a runtime that stays open for -// all of them, each checked by equality. -constexpr int32_t kWaitSeamRepeatedMs = 5; -constexpr int kWaitSeamRepeatedPolls = 40; - -std::string WaitSeamRepeatedOnce() { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - std::string failure; - for (int poll = 0; poll < kWaitSeamRepeatedPolls && failure.empty(); ++poll) { - cultmesh_quic_debug_reset_last_wait_ms(); - std::vector payload(static_cast(kPayloadCapacity)); - cultmesh_quic_event event{}; - int32_t required = 0; - cultmesh_quic_next_event( - runtime, kWaitSeamRepeatedMs, &event, payload.data(), kPayloadCapacity, &required); - const int32_t recorded = cultmesh_quic_debug_last_wait_ms(); - if (recorded != kWaitSeamRepeatedMs) - failure = "poll " + std::to_string(poll + 1) + " of " + - std::to_string(kWaitSeamRepeatedPolls) + " on one runtime recorded " + - std::to_string(recorded) + " ms, not " + std::to_string(kWaitSeamRepeatedMs); - } - cultmesh_quic_runtime_close(runtime); - return failure; -} - -int WaitSeam(int iterations) { - for (int iteration = 0; iteration < iterations; ++iteration) { - for (int32_t probe : kWaitSeamProbesMs) { - const std::string failure = WaitSeamProbeOnce(probe); - if (!failure.empty()) - return Fail("waitseam iteration " + std::to_string(iteration) + " probe " + - std::to_string(probe) + ": " + failure); - } - const std::string repeated = WaitSeamRepeatedOnce(); - if (!repeated.empty()) - return Fail("waitseam iteration " + std::to_string(iteration) + ": " + repeated); - } - std::printf("waitseam %dx: ok (%zu probes, %d repeated polls on one runtime)\n", - iterations, kWaitSeamProbesMs.size(), kWaitSeamRepeatedPolls); - return 0; -} - -#endif // CULTMESH_QUIC_DEBUG_ASSERTS - -// How long `pollhammer`'s idle poll asks for. One host thread hammers every -// gate-touching entry point that cannot itself queue an event, in a yield -// loop, while another holds this one poll idle; each hammered call's -// `CallScope` destructor notifies every waiter on the runtime's condition -// variable (cultmesh_quic_native.cpp:286), so the idle poll is woken many times -// over for every timeout it is given here. That is exactly the shape a wake -// count or an error-state predicate exploits, and exactly what a revert that -// returns on any wake at all fails immediately. -// -// `cultmesh_quic_connection_open`, `cultmesh_quic_listener_open` and -// `cultmesh_quic_stream_open` touch the same gate but can each queue a real -// event on this runtime, and a genuine event is allowed to end the idle poll -// early — hammering with those would make an early return ambiguous between -// the fault this scenario hunts and a real delivery, so they are left out. The -// refused `listener_open` below is a setup step run once, not part of the -// loop, and it leaves no listener behind. -constexpr int32_t kHammerPollMs = 1000; - -// A self-signed ECDSA P-256 PKCS12, generated once with OpenSSL and embedded so -// this scenario needs no crypto library of its own and no network fetch: -// openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \ -// -keyout key.pem -out cert.pem -days 3650 -nodes -subj "/CN=cultmesh-quic-native-tests" -// openssl pkcs12 -export -out test.p12 -inkey key.pem -in cert.pem -passout pass: -// Used only to give pollhammer's live-objects run a listener that can actually -// load a credential; nothing ever connects to it, so it never accepts and never -// queues an event this scenario would have to tell apart from a bug. -constexpr std::array kSelfSignedPkcs12{{ - 0x30, 0x82, 0x04, 0x3c, 0x02, 0x01, 0x03, 0x30, 0x82, 0x03, 0xf2, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, - 0x03, 0xe3, 0x04, 0x82, 0x03, 0xdf, 0x30, 0x82, 0x03, 0xdb, 0x30, 0x82, - 0x02, 0x8a, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, - 0x06, 0xa0, 0x82, 0x02, 0x7b, 0x30, 0x82, 0x02, 0x77, 0x02, 0x01, 0x00, - 0x30, 0x82, 0x02, 0x70, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x07, 0x01, 0x30, 0x5f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, - 0x0d, 0x01, 0x05, 0x0d, 0x30, 0x52, 0x30, 0x31, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c, 0x30, 0x24, 0x04, 0x10, 0x48, - 0xdf, 0x04, 0x5a, 0x31, 0x34, 0x6d, 0xe0, 0x7c, 0xde, 0x3c, 0xa2, 0xde, - 0xf2, 0x8d, 0x20, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0c, 0x06, 0x08, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x09, 0x05, 0x00, 0x30, 0x1d, 0x06, - 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x2a, 0x04, 0x10, - 0x44, 0x04, 0xd9, 0x9b, 0x99, 0x3a, 0xcb, 0x89, 0xc0, 0xcb, 0x53, 0xe3, - 0xe3, 0x5b, 0xb4, 0x48, 0x80, 0x82, 0x02, 0x00, 0x92, 0xcc, 0x04, 0xcf, - 0x7d, 0x58, 0xec, 0x68, 0x1a, 0x1b, 0xd5, 0x3b, 0x17, 0x57, 0x22, 0xd5, - 0x45, 0x00, 0xff, 0x05, 0x0f, 0x0d, 0x18, 0x8b, 0x72, 0x5b, 0xcc, 0xd9, - 0x87, 0xf4, 0x99, 0x44, 0x7c, 0xd6, 0xc3, 0x02, 0x2a, 0xaf, 0xd9, 0x10, - 0x14, 0xd3, 0x9f, 0x1a, 0x2c, 0x7b, 0x4f, 0xe6, 0x0b, 0x1d, 0x7f, 0xb9, - 0xf4, 0x01, 0x5c, 0x4b, 0xd5, 0xa1, 0x57, 0xb0, 0x3d, 0xe0, 0xbc, 0x70, - 0x72, 0xe0, 0xe9, 0xb8, 0x9a, 0xde, 0x68, 0xfe, 0x7c, 0xc7, 0xca, 0xcc, - 0x61, 0x32, 0x88, 0x72, 0xdd, 0x97, 0x28, 0x7b, 0x5b, 0x0d, 0x30, 0xf5, - 0xa2, 0xd1, 0xe8, 0x89, 0xd4, 0x1d, 0x88, 0x28, 0xd2, 0xc3, 0x02, 0x93, - 0xa1, 0x27, 0xfb, 0x4a, 0xe7, 0xdc, 0xac, 0xf3, 0x0d, 0xa9, 0xd3, 0x14, - 0x37, 0x71, 0xb7, 0xe5, 0xaf, 0xdb, 0xb6, 0xda, 0x42, 0xb7, 0x24, 0x7a, - 0x94, 0xad, 0x73, 0x79, 0xde, 0x21, 0xb9, 0x13, 0x63, 0x98, 0x33, 0x62, - 0x4a, 0x36, 0xb8, 0x6d, 0x14, 0x8b, 0x84, 0xf0, 0x8e, 0x55, 0xcc, 0x95, - 0x14, 0x54, 0xcc, 0x68, 0x4b, 0x09, 0x24, 0xb4, 0x79, 0x49, 0x05, 0xc7, - 0x0e, 0xfe, 0xed, 0x23, 0x8c, 0x87, 0xc6, 0xc3, 0x76, 0x25, 0xd9, 0xd6, - 0xae, 0x5a, 0xf4, 0x86, 0x74, 0xb8, 0x44, 0x22, 0xe8, 0xfc, 0xa5, 0xc2, - 0x25, 0xbd, 0x84, 0xfd, 0x92, 0x96, 0xe2, 0x66, 0xa9, 0xb0, 0x1f, 0xd3, - 0x8d, 0xf7, 0x1c, 0xce, 0xed, 0x09, 0x11, 0x61, 0xec, 0x2d, 0xa4, 0x9d, - 0xb9, 0xdb, 0xd4, 0x2e, 0xa4, 0xff, 0xe6, 0x09, 0x8e, 0x9a, 0x0b, 0xdf, - 0x30, 0xf4, 0xea, 0xe6, 0x09, 0x2d, 0x16, 0xec, 0x5d, 0xb6, 0x39, 0xda, - 0xd4, 0x43, 0x41, 0x95, 0xc8, 0x32, 0xd2, 0xac, 0x17, 0x58, 0x05, 0x7e, - 0x10, 0x24, 0xae, 0xd6, 0x58, 0x80, 0x0a, 0x29, 0xcb, 0x4b, 0x78, 0x62, - 0xbe, 0xf6, 0x6c, 0x7d, 0x44, 0x07, 0x7b, 0xfb, 0xd9, 0xb6, 0x74, 0x75, - 0x9f, 0xe6, 0xb4, 0xc3, 0x54, 0x53, 0x46, 0xdb, 0xf2, 0xa1, 0x47, 0xb8, - 0xf1, 0xff, 0x01, 0xba, 0xde, 0xf9, 0xca, 0xd6, 0xc0, 0x38, 0x40, 0xd0, - 0x86, 0x72, 0xc8, 0xcf, 0xdd, 0xd6, 0xf6, 0x36, 0xe0, 0xf3, 0x2e, 0x95, - 0x23, 0xdb, 0x99, 0x72, 0x1c, 0xa6, 0xa0, 0xf7, 0x17, 0x93, 0x1e, 0x20, - 0x6c, 0x75, 0x25, 0x0e, 0x1c, 0xab, 0xa4, 0xce, 0x35, 0xd4, 0xf4, 0xc6, - 0x63, 0x89, 0x0d, 0xa9, 0x91, 0x0b, 0x7e, 0xce, 0x7d, 0x4d, 0x5e, 0xbf, - 0xfd, 0xa9, 0xbd, 0xb6, 0x1e, 0x2b, 0x08, 0x5d, 0x7a, 0xdd, 0x61, 0xdf, - 0x24, 0xe0, 0xff, 0x4b, 0xeb, 0xa2, 0xeb, 0xb6, 0x2f, 0x2c, 0xbf, 0x9b, - 0x5f, 0x6a, 0x1a, 0x33, 0xae, 0x02, 0x6d, 0xbf, 0x8e, 0x6f, 0xeb, 0xda, - 0x17, 0x88, 0x79, 0xf8, 0xe0, 0x1c, 0x1d, 0x64, 0x7c, 0xc3, 0xc2, 0xc1, - 0xce, 0x12, 0x67, 0x74, 0xbc, 0xef, 0x9f, 0x2f, 0x35, 0xef, 0x40, 0x24, - 0xc1, 0x5f, 0x82, 0xc9, 0x00, 0x2c, 0xbf, 0x2b, 0xbf, 0x64, 0x39, 0x63, - 0x0c, 0xcd, 0x6f, 0xe5, 0x18, 0xfa, 0xeb, 0x02, 0x61, 0xc3, 0x22, 0xb0, - 0xfd, 0xfb, 0x9d, 0x32, 0xbb, 0x2f, 0xd8, 0x9d, 0x63, 0x8d, 0x9e, 0xb1, - 0x5a, 0x7d, 0xc3, 0xe5, 0xcc, 0xae, 0xe4, 0x71, 0x0d, 0x7b, 0xa9, 0x80, - 0xbd, 0xef, 0x86, 0x12, 0x13, 0x42, 0xf8, 0x14, 0xcb, 0xa9, 0xfd, 0x86, - 0xea, 0xd5, 0x81, 0x54, 0x87, 0xbc, 0x66, 0x24, 0xfd, 0x12, 0xf5, 0x6b, - 0xf4, 0x45, 0x7e, 0x41, 0x8e, 0x00, 0xf3, 0x63, 0xc7, 0x24, 0xc5, 0xa1, - 0xfd, 0x70, 0xbc, 0xfa, 0x26, 0xa0, 0x07, 0xc2, 0x97, 0xb1, 0xe0, 0x42, - 0x5a, 0x2b, 0x65, 0xec, 0xda, 0x45, 0x79, 0xe5, 0x18, 0xf2, 0xce, 0x8e, - 0xc3, 0xe3, 0x74, 0x6d, 0x30, 0x82, 0x01, 0x49, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x01, 0x3a, 0x04, - 0x82, 0x01, 0x36, 0x30, 0x82, 0x01, 0x32, 0x30, 0x82, 0x01, 0x2e, 0x06, - 0x0b, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x0c, 0x0a, 0x01, 0x02, - 0xa0, 0x81, 0xf7, 0x30, 0x81, 0xf4, 0x30, 0x5f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0d, 0x30, 0x52, 0x30, 0x31, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c, 0x30, 0x24, - 0x04, 0x10, 0xd8, 0x91, 0xb9, 0x92, 0x3a, 0x1e, 0x6b, 0xa2, 0x57, 0x44, - 0x16, 0x3a, 0xea, 0x36, 0x8d, 0x60, 0x02, 0x02, 0x08, 0x00, 0x30, 0x0c, - 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x09, 0x05, 0x00, - 0x30, 0x1d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, - 0x2a, 0x04, 0x10, 0x35, 0x48, 0x03, 0x23, 0x6a, 0x3d, 0x5f, 0x96, 0xb7, - 0xfb, 0xb1, 0xcb, 0xdc, 0x0c, 0x1f, 0x79, 0x04, 0x81, 0x90, 0x4d, 0x36, - 0x5b, 0x1e, 0xc1, 0xc1, 0xa3, 0xfa, 0x85, 0xe6, 0x58, 0x89, 0x5d, 0xbe, - 0x17, 0xb4, 0x90, 0x96, 0x2d, 0x3d, 0x32, 0xe2, 0x73, 0x6c, 0x2c, 0xfd, - 0x7b, 0xe4, 0x9c, 0x82, 0x3c, 0xe4, 0x7a, 0x58, 0x45, 0xdd, 0xcd, 0x00, - 0xa2, 0x52, 0xf9, 0x98, 0xd4, 0x0f, 0x64, 0x0b, 0x58, 0x27, 0xfe, 0xfc, - 0xfd, 0x60, 0x3f, 0x7e, 0x6f, 0x73, 0x73, 0xda, 0x16, 0x34, 0x83, 0x38, - 0x89, 0x3d, 0xbe, 0xde, 0x0a, 0x47, 0x7b, 0xcd, 0xc1, 0x88, 0x72, 0x38, - 0x95, 0xb5, 0x54, 0xfa, 0x2a, 0x84, 0x2b, 0xcd, 0x98, 0xe3, 0x20, 0xd2, - 0xac, 0xd8, 0xf5, 0xa8, 0xd2, 0xef, 0x1f, 0x99, 0x88, 0x16, 0x6f, 0xf2, - 0x08, 0xe9, 0x28, 0xc8, 0x7a, 0x02, 0x57, 0x5c, 0x1c, 0x94, 0x0f, 0x57, - 0xfc, 0x0e, 0x85, 0x63, 0xc5, 0x44, 0x45, 0x4f, 0xc6, 0x35, 0x52, 0x3d, - 0xd4, 0xe2, 0x22, 0x6f, 0x72, 0xde, 0x55, 0xad, 0x20, 0x84, 0x91, 0x14, - 0x7e, 0x5f, 0x98, 0x2a, 0x5e, 0x2b, 0xf4, 0xc5, 0x10, 0x1b, 0x31, 0x25, - 0x30, 0x23, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, - 0x15, 0x31, 0x16, 0x04, 0x14, 0xbd, 0x8a, 0x08, 0x3c, 0x66, 0xf7, 0x9d, - 0xa0, 0x25, 0x8b, 0x33, 0xac, 0xc2, 0x5e, 0xdc, 0x76, 0xd4, 0x33, 0x1a, - 0xd6, 0x30, 0x41, 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, - 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20, 0x4e, 0x6f, - 0x75, 0x90, 0x57, 0xb4, 0x39, 0x1e, 0xc3, 0x97, 0x50, 0x5e, 0x4d, 0xf2, - 0xa8, 0xf9, 0x0e, 0xcd, 0x7f, 0x57, 0x31, 0xae, 0xf2, 0x87, 0x0a, 0x55, - 0xb0, 0xbc, 0xd6, 0x11, 0x83, 0xc3, 0x04, 0x08, 0x52, 0x79, 0xb1, 0x83, - 0xe6, 0xe4, 0x6e, 0x4d, 0x02, 0x02, 0x08, 0x00, -}}; - -std::string PollHammerOnce(bool with_recorded_error, bool with_live_objects) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - if (with_recorded_error) { - // Not a certificate at all: PKCS12 parsing fails before any network - // I/O, so this is refused synchronously and leaves no listener behind, - // and `runtime->error` is non-empty for the rest of this runtime's life. - const uint8_t junk[] = {0x00, 0x01, 0x02, 0x03}; - uint64_t listener_id = 0; - uint16_t bound_port = 0; - const int32_t result = cultmesh_quic_listener_open( - runtime, nullptr, 0, junk, static_cast(sizeof(junk)), "", &listener_id, &bound_port); - if (result >= 0) { - cultmesh_quic_runtime_close(runtime); - return "cultmesh_quic_listener_open accepted a junk PKCS12 credential"; - } - } - - // Self's ruling of 2026-09-22, F3: the predicate covered by the hammer set - // above is only ever exercised on a runtime with nothing live in it. An - // unroutable address (RFC 5737 TEST-NET-1) gets a connection into - // `runtime->connections` at once — `cultmesh_quic_connection_open` inserts - // it before the handshake starts — and that handshake then never completes - // inside this scenario's poll window, so it queues no event of its own. A - // best-effort stream rides the same connection. The listener is real (a - // credential MsQuic actually loads) but nothing ever connects to it, so it - // never accepts and never queues an event either: every object here is - // live in the runtime's maps without ever waking the idle poll on its own. - uint64_t live_connection_id = 0; - uint64_t live_stream_id = 0; - uint64_t live_listener_id = 0; - if (with_live_objects) { - const int32_t connecting = - cultmesh_quic_connection_open(runtime, "192.0.2.1", 9, &live_connection_id); - if (connecting != 0) { - cultmesh_quic_runtime_close(runtime); - return "cultmesh_quic_connection_open (live-objects setup) returned " + - std::to_string(connecting); - } - // Best-effort: whether this succeeds is not the point of the - // scenario, and P1's predicate names `connections`, not `streams`. - cultmesh_quic_stream_open( - runtime, live_connection_id, CULTMESH_QUIC_STREAM_RELIABLE, &live_stream_id); - uint16_t bound_port = 0; - cultmesh_quic_listener_open(runtime, "127.0.0.1", 0, kSelfSignedPkcs12.data(), - static_cast(kSelfSignedPkcs12.size()), "", &live_listener_id, &bound_port); - } - - std::atomic hammering{true}; - std::thread hammer([runtime, &hammering] { - constexpr uint64_t kBogusId = 0xffffffffffffffffull; - const uint8_t frame[] = {0x00}; - std::array message{}; - while (hammering.load(std::memory_order_relaxed)) { - cultmesh_quic_last_error(runtime, message.data(), static_cast(message.size())); - cultmesh_quic_last_status(runtime); - cultmesh_quic_connection_shutdown(runtime, kBogusId, 0); - cultmesh_quic_stream_shutdown(runtime, kBogusId, 0); - cultmesh_quic_stream_send_frame(runtime, kBogusId, frame, 1, 0); - cultmesh_quic_connection_certificate_complete(runtime, kBogusId, 0); - cultmesh_quic_listener_close(runtime, kBogusId); - std::this_thread::yield(); - } - }); - - const TimedPoll poll = PollFor(runtime, kHammerPollMs); - hammering.store(false, std::memory_order_relaxed); - hammer.join(); - if (live_listener_id != 0) cultmesh_quic_listener_close(runtime, live_listener_id); - if (live_connection_id != 0) cultmesh_quic_connection_shutdown(runtime, live_connection_id, 0); - (void)live_stream_id; - cultmesh_quic_runtime_close(runtime); - - if (poll.result != 0) - return "the idle poll returned " + std::to_string(poll.result) + - ", not the 0 an idle runtime owes it"; - if (poll.elapsed_ms < kHammerPollMs - kEarlyToleranceMs) - return "the idle poll returned after " + std::to_string(poll.elapsed_ms) + - " ms while another thread hammered the gate, ending its wait early"; - if (poll.elapsed_ms > static_cast(kHammerPollMs) + kGenerousLateToleranceMs) - return "the idle poll returned after " + std::to_string(poll.elapsed_ms) + - " ms: well past its own timeout"; - return {}; -} - -int PollHammer(int iterations) { - for (int iteration = 0; iteration < iterations; ++iteration) { - std::string failure = PollHammerOnce(false, false); - if (!failure.empty()) - return Fail("pollhammer iteration " + std::to_string(iteration) + " (clean runtime): " + failure); - failure = PollHammerOnce(true, false); - if (!failure.empty()) - return Fail("pollhammer iteration " + std::to_string(iteration) + - " (after a refused call recorded an error): " + failure); - failure = PollHammerOnce(false, true); - if (!failure.empty()) - return Fail("pollhammer iteration " + std::to_string(iteration) + - " (with a live connection, stream and listener): " + failure); - } - std::printf("pollhammer %dx: ok\n", iterations); - return 0; -} - -// Self's ruling of 2026-09-22, F4: any `timeout_ms <= 0` has to return within a -// small, generously-margined bound, and a negative timeout has to be probed -// too — the bridge's own guard (`timeout_ms > 0`) already treats zero and -// negative alike, so 0, -1 and INT32_MIN all take the same fast path and none -// of them may collide with the seam's own "nothing recorded" sentinel. -constexpr std::array kZeroTimeoutProbesMs{0, -1, INT32_MIN}; - -// Generous next to `kEarlyToleranceMs`/`kGenerousLateToleranceMs` because a -// non-positive timeout never enters the condition wait at all, so this is -// bounding a runtime lock acquisition and an empty-queue check, not a -// scheduler wakeup — the margin only has to be well clear of a mistake that -// makes this path sleep or spin, not of ordinary jitter. -constexpr int kZeroTimeoutBoundMs = 50; - -std::string ZeroTimeoutOnce(int32_t timeout_ms) { - void* runtime = nullptr; - const int32_t opened = cultmesh_quic_runtime_open("cultmesh-quic-native-tests", &runtime); - if (opened != 0 || runtime == nullptr) - return "cultmesh_quic_runtime_open returned " + std::to_string(opened); - - const TimedPoll poll = PollFor(runtime, timeout_ms); - cultmesh_quic_runtime_close(runtime); - - if (poll.result != 0) - return "a poll asking for " + std::to_string(timeout_ms) + " ms returned " + - std::to_string(poll.result) + ", not the 0 an idle runtime owes it"; - if (poll.elapsed_ms > kZeroTimeoutBoundMs) - return "a poll asking for " + std::to_string(timeout_ms) + " ms returned after " + - std::to_string(poll.elapsed_ms) + " ms: a non-positive timeout must return within " + - std::to_string(kZeroTimeoutBoundMs) + " ms, not stall or spin"; - return {}; -} - -int ZeroTimeout(int iterations) { - for (int iteration = 0; iteration < iterations; ++iteration) { - for (int32_t probe : kZeroTimeoutProbesMs) { - const std::string failure = ZeroTimeoutOnce(probe); - if (!failure.empty()) - return Fail("zerotimeout iteration " + std::to_string(iteration) + " probe " + - std::to_string(probe) + ": " + failure); - } - } - std::printf("zerotimeout %dx: ok (%zu probes)\n", iterations, kZeroTimeoutProbesMs.size()); - return 0; -} - -int CloseRace(int iterations, int pollers) { - for (int iteration = 0; iteration < iterations; ++iteration) { - const std::string failure = CloseRaceOnce(pollers); - if (!failure.empty()) - return Fail("closerace iteration " + std::to_string(iteration) + ": " + failure); - } - std::printf("closerace %dx%d: ok\n", iterations, pollers); - return 0; -} - -} // namespace - -int main(int argc, char** argv) { - if (argc < 2) { - std::fprintf(stderr, - "usage: %s closerace|holdclose|holdtimeout|polltimeout|pollbusy|pollhammer|zerotimeout|" - "payloadfit|latecall|waitseam [iterations] [pollers]\n", - argv[0]); - return 2; - } - const std::string scenario = argv[1]; - const int iterations = argc > 2 ? std::atoi(argv[2]) : 20; - const int pollers = argc > 3 ? std::atoi(argv[3]) : 256; - if (iterations <= 0 || pollers <= 0) { - std::fprintf(stderr, "%s needs a positive iteration and poller count\n", scenario.c_str()); - return 2; - } - if (scenario == "closerace") return CloseRace(iterations, pollers); - if (scenario == "polltimeout") return PollTimeout(iterations); - if (scenario == "pollbusy") return PollBusy(iterations); - if (scenario == "pollhammer") return PollHammer(iterations); - if (scenario == "zerotimeout") return ZeroTimeout(iterations); - if (scenario == "payloadfit") return PayloadFit(iterations); - if (scenario == "holdclose" || scenario == "latecall" || scenario == "holdtimeout" || - scenario == "waitseam") { -#if defined(CULTMESH_QUIC_DEBUG_ASSERTS) - if (scenario == "latecall") return LateCall(iterations); - if (scenario == "holdtimeout") return HoldTimeout(iterations); - if (scenario == "waitseam") return WaitSeam(iterations); - return HoldClose(iterations, pollers); -#else - std::fprintf(stderr, - "%s needs the development seam: configure with " - "-DCULTMESH_QUIC_DEBUG_ASSERTS=ON\n", scenario.c_str()); - return 2; -#endif - } - std::fprintf(stderr, "unknown scenario '%s'\n", scenario.c_str()); - return 2; -} diff --git a/package-lock.json b/package-lock.json index 5c0a5591..f027ecd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -489,326 +489,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@koromix/koffi-android-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-android-arm64/-/koffi-android-arm64-3.3.0.tgz", - "integrity": "sha512-lHXE2mq+uG6CVeX1iepn2ATcAWMZPagr+J0ICYge7wTMDYc5pPRQMq0Rr/16775i6QlUqQqpk8c5Gu66+u3gGA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-android-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-android-x64/-/koffi-android-x64-3.3.0.tgz", - "integrity": "sha512-7EeVK/KS9XNbOsUfy0B3uuSjPQZenjJ35y9QSi6R6eK4Fv0oGvREQaBzIJRJwonxp7sJfGObnwnQTnKTVK2DWA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-darwin-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-darwin-arm64/-/koffi-darwin-arm64-3.3.0.tgz", - "integrity": "sha512-2R9bihYmYFyRP98wRG2m5WQVKMONf7DoPJI8RkGCOUB2afOXJEVXFepiSKxBZGPml8i1USwAxMUwkzbJ5uMG1A==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-darwin-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-darwin-x64/-/koffi-darwin-x64-3.3.0.tgz", - "integrity": "sha512-OecYCQfzhUx+XyAtatIHlk0jIz87wKNjtYvwlwgMwgaGQwO/TxFeReNo+s3167Rh1a9c8rUIOjq1jfzAPBxbKA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-freebsd-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-freebsd-arm64/-/koffi-freebsd-arm64-3.3.0.tgz", - "integrity": "sha512-6ytHzV1DuyxTP5LtFmQ3imBk71j/F/Nb0Hcwhjcn35esnknm5rQbgRl6tNRldrkGnM4GIAJpsagooUBh1xAzYg==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-freebsd-ia32": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-freebsd-ia32/-/koffi-freebsd-ia32-3.3.0.tgz", - "integrity": "sha512-hINo5z1Iz2u3Rx3oHfzcmi5A03gYAoYf4nCJJYaY0bb5IuGdIC7noQTyyI9YxfyTJgoqw3wKFWWYtvsAmEo9Hw==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-freebsd-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-freebsd-x64/-/koffi-freebsd-x64-3.3.0.tgz", - "integrity": "sha512-7XQYAZh828nW6+y3IdyUNdo2VbVHL5ZC8Qb+yqHrlDjTjVXSyGYZJHAyJZ5c7eSTTKBhtIMTX238rIsdexxrog==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-arm": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-arm/-/koffi-linux-arm-3.3.0.tgz", - "integrity": "sha512-NbahRKKKFkHoFN/ZpLY+w4F6eYSqV4KMN40PmjZ1xQjG/XjYb6PIYgE41c7/acAPxOYqujrcaI3B4BAgWYm5/A==", - "cpu": [ - "arm" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-arm64/-/koffi-linux-arm64-3.3.0.tgz", - "integrity": "sha512-Eo/+wGeawGICzJkUlkzi/KerAJ6U1L/Hf7cnJKH7aGgCOY5RRnjUqXs/eL+UDpRcFHzGeUn+Fq+8q2VxYxvAfw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-ia32": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-ia32/-/koffi-linux-ia32-3.3.0.tgz", - "integrity": "sha512-u9tKuj42RFWJU8ZgZqcBhkFCkIZE/SE6oR1ljpukttJUhOVuaf/lmsWxyOxiVu3U8T1gtD658FlLgrbMVIn6aQ==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-loong64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-loong64/-/koffi-linux-loong64-3.3.0.tgz", - "integrity": "sha512-2hKlNZ6OXkTUp6fcueZcP0sQ6yhpdfANg9/mWxDKzT1o8qIj4qJD7UcZLCcRIC8JXiP8JQwZBtlPuyXIqofDQg==", - "cpu": [ - "loong64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-ppc64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-ppc64/-/koffi-linux-ppc64-3.3.0.tgz", - "integrity": "sha512-bIVAoHgzyRN7xs529BK7rF3BbZUTJgIr0t/wvBvAgaIpreKsdZ/QWxhedKRbTN7ljlDHkPZFmu5XcCjb/vqUag==", - "cpu": [ - "ppc64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-riscv64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-riscv64/-/koffi-linux-riscv64-3.3.0.tgz", - "integrity": "sha512-2niYAe+TBXbvf7yog/aiHiDUrKQn+RkMSH5x3ZYo65OQyII1CY3Jk2kP3Pe735gq0LzIYJsDuGMW+02ighSadQ==", - "cpu": [ - "riscv64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-linux-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-linux-x64/-/koffi-linux-x64-3.3.0.tgz", - "integrity": "sha512-apU8ZMOrOh1eqMP/Pp0sDZ/WY6A4r6JWph26h63VM9nZ+5KCTYuPgojfoLPNvrfI/bn1PY3+bpXKRhZHI3gxbQ==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-openbsd-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-openbsd-arm64/-/koffi-openbsd-arm64-3.3.0.tgz", - "integrity": "sha512-iTyHMCSSs+X579sWJv7XVFMp9gOfROI8IUEwp09YxJpGvmiSoipI0J7kytFuFq6dyuwO0Ymy4JdlmKnCM0qkxg==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-openbsd-ia32": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-openbsd-ia32/-/koffi-openbsd-ia32-3.3.0.tgz", - "integrity": "sha512-xCvMV+4VNHjTxgVPEsBzU0k8dlA7aoFO5QjRF9lVU/NzGhUedlYvFgaF6IWsGOoWEaNt9hgP4KK/wxMbm9v8EQ==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-openbsd-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-openbsd-x64/-/koffi-openbsd-x64-3.3.0.tgz", - "integrity": "sha512-xItIwx1elM8k1pTudEfuV/1U2gQ06+rFfxCVXrZkyWYYGTzmA5To00f8garJFR+E9gbjQJbn8QDFvWMI+i2sMA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-win32-arm64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-win32-arm64/-/koffi-win32-arm64-3.3.0.tgz", - "integrity": "sha512-fD41LgKBx5i1YlJDuds4tRHAaG5vV55tvagzJwKFDR/5BDeaFvH9QFMUMDoNl2LkmVyeug0dIElHr/oxejh3IA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-win32-ia32": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-win32-ia32/-/koffi-win32-ia32-3.3.0.tgz", - "integrity": "sha512-BfDbDVEuQwPZOvWXawc3JT/7i9cN7QHYotgo014jjXb9pNv46Ykhb0RRglkcHg+SdytW/7pxYn18YwcQP6LLvQ==", - "cpu": [ - "ia32" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, - "node_modules/@koromix/koffi-win32-x64": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@koromix/koffi-win32-x64/-/koffi-win32-x64-3.3.0.tgz", - "integrity": "sha512-D+ORp73rTmvGVfq01+4uBmgVZqrPqU9N9xCZCfexaCDlVk0WQsaqid1dGsi6eScJuHt4Cp8s1i5/4CsecxFTKQ==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "funding": { - "url": "https://liberapay.com/Koromix" - } - }, "node_modules/@msgpack/msgpack": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-3.1.3.tgz", @@ -1035,38 +715,6 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "license": "MIT" }, - "node_modules/koffi": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/koffi/-/koffi-3.3.0.tgz", - "integrity": "sha512-UeyQtptuPeCP0BqKD+Q8ftTQhIUBHO7bXyK9DVIaW9hJSg0BrICm4K5N8Qtn7zKk20sb5vpnES9KBqVksM2kpQ==", - "hasInstallScript": true, - "license": "MIT", - "funding": { - "url": "https://liberapay.com/Koromix" - }, - "optionalDependencies": { - "@koromix/koffi-android-arm64": "3.3.0", - "@koromix/koffi-android-x64": "3.3.0", - "@koromix/koffi-darwin-arm64": "3.3.0", - "@koromix/koffi-darwin-x64": "3.3.0", - "@koromix/koffi-freebsd-arm64": "3.3.0", - "@koromix/koffi-freebsd-ia32": "3.3.0", - "@koromix/koffi-freebsd-x64": "3.3.0", - "@koromix/koffi-linux-arm": "3.3.0", - "@koromix/koffi-linux-arm64": "3.3.0", - "@koromix/koffi-linux-ia32": "3.3.0", - "@koromix/koffi-linux-loong64": "3.3.0", - "@koromix/koffi-linux-ppc64": "3.3.0", - "@koromix/koffi-linux-riscv64": "3.3.0", - "@koromix/koffi-linux-x64": "3.3.0", - "@koromix/koffi-openbsd-arm64": "3.3.0", - "@koromix/koffi-openbsd-ia32": "3.3.0", - "@koromix/koffi-openbsd-x64": "3.3.0", - "@koromix/koffi-win32-arm64": "3.3.0", - "@koromix/koffi-win32-ia32": "3.3.0", - "@koromix/koffi-win32-x64": "3.3.0" - } - }, "node_modules/lodash": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", @@ -1219,8 +867,7 @@ "dependencies": { "@gamecult/cultcache-ts": "^0.14.0", "@msgpack/msgpack": "^3.1.2", - "cultnet-ts": "^0.2.0", - "koffi": "3.3.0" + "cultnet-ts": "^0.2.0" }, "devDependencies": { "@types/node": "^24.0.0", diff --git a/packages/cultcache-py/src/cultcache_py/__init__.py b/packages/cultcache-py/src/cultcache_py/__init__.py index ad00a74b..07721ef4 100644 --- a/packages/cultcache-py/src/cultcache_py/__init__.py +++ b/packages/cultcache-py/src/cultcache_py/__init__.py @@ -4,14 +4,10 @@ from .cache import CultCache, CultCacheBuilder from .documents import ( DatabaseEntryField, DocumentDefinition, - SlotCodec, - UnionArm, database_entry_field, define_database_entry_type, define_document_registry, define_document_type, - define_record_codec, - define_union, ) from .stores import JsonLinesBackingStore, SingleFileMessagePackBackingStore @@ -26,12 +22,8 @@ __all__ = [ "DocumentDefinition", "JsonLinesBackingStore", "SingleFileMessagePackBackingStore", - "SlotCodec", - "UnionArm", "database_entry_field", "define_database_entry_type", "define_document_registry", "define_document_type", - "define_record_codec", - "define_union", ] diff --git a/packages/cultcache-py/src/cultcache_py/documents.py b/packages/cultcache-py/src/cultcache_py/documents.py index 18edd704..e8511249 100644 --- a/packages/cultcache-py/src/cultcache_py/documents.py +++ b/packages/cultcache-py/src/cultcache_py/documents.py @@ -2,7 +2,7 @@ import json from dataclasses import MISSING, dataclass, field -from typing import Any, Callable, Generic, Iterable, Mapping, TypeVar +from typing import Any, Callable, Generic, Iterable, TypeVar from .backing_store import CultCacheSchemaCatalogEntry, CultCacheSchemaCatalogMember @@ -58,46 +58,17 @@ def _messagepack_payload_decoder(payload: bytes) -> Any: return msgpack.unpackb(payload, raw=False) -@dataclass(frozen=True) -class SlotCodec: - """Encodes and decodes the value of one slot: a nested record or a union.""" - - encode: Callable[[Any], Any] - decode: Callable[[Any], Any] - - @dataclass(frozen=True) class DatabaseEntryField: name: str key: int default: Any = MISSING - codec: SlotCodec | Callable[[], SlotCodec] | None = None - many: bool = False -def database_entry_field( - name: str, - key: int, - *, - default: Any = MISSING, - codec: SlotCodec | Callable[[], SlotCodec] | None = None, - many: bool = False, -) -> DatabaseEntryField: - """A slot. `codec` makes the slot a nested record or union (a zero-argument callable - returning the codec lets a union refer to itself); `many` makes it a list of them.""" +def database_entry_field(name: str, key: int, *, default: Any = MISSING) -> DatabaseEntryField: if key < 0: raise ValueError("DatabaseEntry field keys must be non-negative integers") - if many and codec is None: - raise ValueError("A many DatabaseEntry field requires a codec") - return DatabaseEntryField(name=name, key=key, default=default, codec=codec, many=many) - - -@dataclass(frozen=True) -class UnionArm: - """A decoded union value: the arm's declared name and its decoded record (None for a unit arm).""" - - name: str - value: Any = None + return DatabaseEntryField(name=name, key=key, default=default) @dataclass(frozen=True) @@ -234,7 +205,14 @@ def define_database_entry_type( and newly added fields can use higher keys without rewriting older payloads. """ - normalized = _normalize_fields(type, fields) + normalized = [_normalize_database_entry_field(field) for field in fields] + if not normalized: + raise ValueError("DatabaseEntry document types require at least one field") + keys = [field.key for field in normalized] + if len(keys) != len(set(keys)): + raise ValueError(f"DatabaseEntry document type {type!r} has duplicate field keys") + normalized.sort(key=lambda field: field.key) + max_key = max(keys) member_name_lookup = name if isinstance(name, str) else None index_lookup = indexes or {} members = tuple( @@ -251,12 +229,36 @@ def define_database_entry_type( for field in normalized ) - record = _record_codec(type, normalized, cls) + def encode(value: Any) -> list[Any]: + slots = [None] * (max_key + 1) + for field in normalized: + slots[field.key] = extract_value(value, field.name) + return slots + + def decode(raw: Any) -> Any: + if not isinstance(raw, list): + raise ValueError(f"DatabaseEntry document type {type!r} expected a MessagePack array") + values: dict[str, Any] = {} + for field in normalized: + if field.key < len(raw): + value = raw[field.key] + elif field.default is not MISSING: + value = field.default() if callable(field.default) else field.default + else: + raise ValueError( + f"DatabaseEntry document type {type!r} is missing required slot {field.key}" + ) + if value is None and field.default is not MISSING: + value = field.default() if callable(field.default) else field.default + values[field.name] = value + if cls is None: + return values + return cls(**values) return define_document_type( type, - encode=record.encode, - decode=record.decode, + encode=encode, + decode=decode, validate=validate, global_document=global_document, name=name, @@ -273,60 +275,6 @@ def define_database_entry_type( ) -def define_record_codec( - name: str, - fields: Iterable[DatabaseEntryField | tuple[str, int] | tuple[str, int, Any]], - *, - cls: type[Any] | None = None, -) -> SlotCodec: - """A nested record: the same slot array as a document payload, usable as a field's codec or a union arm.""" - return _record_codec(name, _normalize_fields(name, fields), cls) - - -def define_union( - name: str, - arms: Mapping[int, tuple[str, SlotCodec | Callable[[], SlotCodec] | None]], -) -> SlotCodec: - """A union: nil, or `[armKey, [armSlots...]]`. Each arm is `(arm name, record codec)`; a unit arm has - no codec and is written `[armKey, []]`. A key the union does not declare is refused, never carried.""" - by_key = dict(arms) - by_name = {arm_name: (key, codec) for key, (arm_name, codec) in by_key.items()} - if not by_key: - raise ValueError(f"Union {name!r} requires at least one arm") - if len(by_name) != len(by_key): - raise ValueError(f"Union {name!r} has duplicate arm names") - if any(not _is_key(key) or not _INT32_MIN <= key <= _INT32_MAX for key in by_key): - raise ValueError(f"Union {name!r} arm keys must be integers within Int32") - - def encode(value: Any) -> Any: - if value is None: - return None - if not isinstance(value, UnionArm) or value.name not in by_name: - raise ValueError(f"Union {name!r} was given a value that is not one of its arms") - key, codec = by_name[value.name] - if codec is None: - if value.value is not None: - raise ValueError(f"Union {name!r} arm {key} is a unit arm and carries no value") - return [key, []] - return [key, _resolve(codec).encode(value.value)] - - def decode(raw: Any) -> Any: - if raw is None: - return None - if not isinstance(raw, list) or len(raw) != 2 or not isinstance(raw[1], list): - raise ValueError(f"Union {name!r} value is malformed: expected [armKey, [armSlots]]") - key = raw[0] - if not _is_key(key): - raise ValueError(f"Union {name!r} value is malformed: the arm key is not an integer") - if key not in by_key: - declared = ", ".join(str(declared_key) for declared_key in sorted(by_key)) - raise ValueError(f"Union {name!r} does not declare arm key {key} (declared: {declared})") - arm_name, codec = by_key[key] - return UnionArm(arm_name, None if codec is None else _resolve(codec).decode(raw[1])) - - return SlotCodec(encode=encode, decode=decode) - - def define_document_registry(*documents: DocumentDefinition[Any]) -> tuple[DocumentDefinition[Any], ...]: return tuple(documents) @@ -339,81 +287,6 @@ def extract_value(value: Any, extractor: str | Extractor[Any]) -> str | int | fl return getattr(value, extractor, None) -_INT32_MIN = -(2**31) -_INT32_MAX = 2**31 - 1 - - -def _is_key(value: Any) -> bool: - return isinstance(value, int) and not isinstance(value, bool) - - -def _resolve(codec: SlotCodec | Callable[[], SlotCodec]) -> SlotCodec: - return codec if isinstance(codec, SlotCodec) else codec() - - -def _normalize_fields( - type: str, - fields: Iterable[DatabaseEntryField | tuple[str, int] | tuple[str, int, Any]], -) -> list[DatabaseEntryField]: - normalized = [_normalize_database_entry_field(field) for field in fields] - if not normalized: - raise ValueError("DatabaseEntry document types require at least one field") - keys = [field.key for field in normalized] - if len(keys) != len(set(keys)): - raise ValueError(f"DatabaseEntry document type {type!r} has duplicate field keys") - return sorted(normalized, key=lambda field: field.key) - - -def _record_codec(type: str, normalized: list[DatabaseEntryField], cls: type[Any] | None) -> SlotCodec: - max_key = normalized[-1].key - - def encode_slot(field: DatabaseEntryField, value: Any) -> Any: - if field.codec is None or value is None: - return value - codec = _resolve(field.codec) - if field.many: - return [None if item is None else codec.encode(item) for item in value] - return codec.encode(value) - - def decode_slot(field: DatabaseEntryField, value: Any) -> Any: - if field.codec is None or value is None: - return value - codec = _resolve(field.codec) - if field.many: - if not isinstance(value, list): - raise ValueError(f"DatabaseEntry document type {type!r} slot {field.key} expected a MessagePack array") - return [None if item is None else codec.decode(item) for item in value] - return codec.decode(value) - - def encode(value: Any) -> list[Any]: - slots = [None] * (max_key + 1) - for field in normalized: - slots[field.key] = encode_slot(field, extract_value(value, field.name)) - return slots - - def decode(raw: Any) -> Any: - if not isinstance(raw, list): - raise ValueError(f"DatabaseEntry document type {type!r} expected a MessagePack array") - values: dict[str, Any] = {} - for field in normalized: - if field.key < len(raw): - value = decode_slot(field, raw[field.key]) - elif field.default is MISSING: - raise ValueError( - f"DatabaseEntry document type {type!r} is missing required slot {field.key}" - ) - else: - value = None - if value is None and field.default is not MISSING: - value = field.default() if callable(field.default) else field.default - values[field.name] = value - if cls is None: - return values - return cls(**values) - - return SlotCodec(encode=encode, decode=decode) - - def _normalize_database_entry_field( field: DatabaseEntryField | tuple[str, int] | tuple[str, int, Any], ) -> DatabaseEntryField: diff --git a/packages/cultcache-py/src/cultcache_py/stores.py b/packages/cultcache-py/src/cultcache_py/stores.py index 704a3851..697882e0 100644 --- a/packages/cultcache-py/src/cultcache_py/stores.py +++ b/packages/cultcache-py/src/cultcache_py/stores.py @@ -5,7 +5,7 @@ import json import os import threading from pathlib import Path -from typing import Any, Callable, TypeVar +from typing import Any from .backing_store import ( CultCacheEnvelope, @@ -14,9 +14,6 @@ from .backing_store import ( ) STORE_FORMAT_VERSION = "cultcache.store.v1" -_STORE_FORMAT_PREFIX = "cultcache.store." -_PERSISTED_RECORD_SLOTS = 4 -_Contents = TypeVar("_Contents") class JsonLinesBackingStore: @@ -26,11 +23,10 @@ class JsonLinesBackingStore: def pull_all(self) -> list[CultCacheEnvelope]: with self._lock: - text = _read_store(self.path, lambda path: path.read_text(encoding="utf-8")) - if text is None: + if not self.path.exists(): return [] envelopes: list[CultCacheEnvelope] = [] - for line_number, line in enumerate(text.splitlines(), start=1): + for line_number, line in enumerate(self.path.read_text(encoding="utf-8").splitlines(), start=1): if not line.strip(): continue raw = json.loads(line) @@ -90,9 +86,10 @@ class SingleFileMessagePackBackingStore: def pull_all(self) -> list[CultCacheEnvelope]: msgpack = self._msgpack() with self._lock: - # An empty file is not a store (no writer leaves one), so it is decoded and refused. - data = _read_store(self.path, Path.read_bytes) - if data is None: + if not self.path.exists(): + return [] + data = self.path.read_bytes() + if not data: return [] decoded = msgpack.unpackb(data, raw=False) snapshot = _decode_v1_snapshot(decoded) @@ -155,46 +152,8 @@ def _encode_v1_snapshot(envelopes: list[CultCacheEnvelope]) -> list[Any]: return [STORE_FORMAT_VERSION, catalog, records] -def _read_store(path: Path, read: Callable[[Path], _Contents]) -> _Contents | None: - """Reads a store file, or returns None when nothing is at its path. - - Only nothing is absent. A dangling symbolic link is something: reading it as - empty would let the writer replace the link and move the store off its volume. - Any other failure to reach the file stays an OSError. - """ - try: - return read(path) - except FileNotFoundError: - if path.is_symlink(): - raise - return None - - -def _describe_identity(value: Any) -> str: - """A record key or schema id as a refusal may show it: a string is an identity and is - named; anything else is described by its type, since the value is the store's.""" - if isinstance(value, str): - return repr(value) - return f"<{type(value).__name__}>" - - -def _describe_header(header: str) -> str: - """Echoes a header only in the shape cultcache.store.v; the bytes are the store's.""" - version = header[len(_STORE_FORMAT_PREFIX) + 1:] if header.startswith(_STORE_FORMAT_PREFIX + "v") else "" - if version.isascii() and version.isdigit(): - return repr(header) - return f"an unrecognised {_STORE_FORMAT_PREFIX}* header of {len(header.encode('utf-8'))} bytes" - - def _decode_v1_snapshot(decoded: Any) -> list[CultCacheEnvelope] | None: - if not isinstance(decoded, list) or not decoded: - return None - if isinstance(decoded[0], str) and decoded[0].startswith(_STORE_FORMAT_PREFIX) and decoded[0] != STORE_FORMAT_VERSION: - raise ValueError( - f"CultCache store format {_describe_header(decoded[0])} is not one this runtime reads; " - f"it reads {STORE_FORMAT_VERSION!r} only" - ) - if decoded[0] != STORE_FORMAT_VERSION: + if not isinstance(decoded, list) or not decoded or decoded[0] != STORE_FORMAT_VERSION: return None if len(decoded) < 3 or not isinstance(decoded[1], list) or not isinstance(decoded[2], list): raise ValueError("CultCache v1 snapshot must contain a schema catalog and record array") @@ -210,13 +169,7 @@ def _decode_v1_snapshot(decoded: Any) -> list[CultCacheEnvelope] | None: for raw_record in decoded[2]: if not isinstance(raw_record, list) or len(raw_record) < 4: raise ValueError("CultCache persisted records must be MessagePack arrays") - if len(raw_record) > _PERSISTED_RECORD_SLOTS: - raise ValueError( - f"CultCache record {_describe_identity(raw_record[0])} (schema {_describe_identity(raw_record[1])}) " - f"has {len(raw_record)} slots, more than " - f"the {_PERSISTED_RECORD_SLOTS} of a {STORE_FORMAT_VERSION} record, so this is not a valid store" - ) - key, schema_id, stored_at, payload = raw_record + key, schema_id, stored_at, payload = raw_record[:4] if not isinstance(key, str) or not key: raise ValueError("CultCache persisted records must declare a key") if not isinstance(schema_id, str) or not schema_id: diff --git a/packages/cultcache-py/tests/test_cultcache.py b/packages/cultcache-py/tests/test_cultcache.py index 6e85f833..ac81cc6d 100644 --- a/packages/cultcache-py/tests/test_cultcache.py +++ b/packages/cultcache-py/tests/test_cultcache.py @@ -1,6 +1,5 @@ from __future__ import annotations -import os import tempfile import threading import unittest @@ -803,168 +802,5 @@ class CultCacheTests(unittest.TestCase): self.assertEqual(cache.get_required_envelope(document, "item:one").key, "item:one") - # Shared refusal vectors: tests/vectors/document-variants-c0, read by every runtime's tests. - _VECTORS = Path(__file__).resolve().parents[3] / "tests" / "vectors" / "document-variants-c0" - _ITEM_SCHEMA_ID = "sha256:88d3fdf0a927acf3b163940d8f8c7fe62b3316542ce771a67ec8bc038f594788" - - def _pull_vector(self, name: str) -> list[CultCacheEnvelope]: - with tempfile.TemporaryDirectory() as tmp: - store_path = Path(tmp) / "store.msgpack" - store_path.write_bytes((self._VECTORS / name).read_bytes()) - return SingleFileMessagePackBackingStore(store_path).pull_all() - - def test_single_file_refuses_unknown_header_by_name(self) -> None: - with self.assertRaises(ValueError) as caught: - self._pull_vector("unknown-header.msgpack") - self.assertIn("cultcache.store.v9", str(caught.exception)) - - def test_single_file_refuses_extra_record_slot_naming_the_record(self) -> None: - with self.assertRaises(ValueError) as caught: - self._pull_vector("extra-slot-full-payload.msgpack") - self.assertIn("item:anvil", str(caught.exception)) - self.assertIn(self._ITEM_SCHEMA_ID, str(caught.exception)) - - def test_single_file_refuses_variant_store_by_version_or_record(self) -> None: - with self.assertRaises(ValueError) as caught: - self._pull_vector("variant-v2.msgpack") - message = str(caught.exception) - self.assertTrue("cultcache.store.v2" in message or "item:anvil-big" in message, message) - - def test_single_file_refuses_the_csharp_written_variant_store_by_version_or_record(self) -> None: - with self.assertRaises(ValueError) as caught: - self._pull_vector("../document-variants-c1/variant-store.msgpack") - message = str(caught.exception) - self.assertTrue("cultcache.store.v2" in message or "laser-big" in message, message) - - def test_v1_store_written_at_the_base_commit_still_reads_byte_for_byte(self) -> None: - envelopes = self._pull_vector("v1-base.msgpack") - self.assertEqual([(e.key, e.type) for e in envelopes], [("alpha", "vectors.item"), ("beta", "vectors.item")]) - self.assertEqual(envelopes[0].payload, b"\x92\xa5alpha\x01") - self.assertEqual(envelopes[1].payload, b"\x92\xa4beta\x02") - - def test_single_file_refusals_say_what_was_found_without_blaming_variants(self) -> None: - with self.assertRaises(ValueError) as unsupported: - self._pull_vector("unknown-header.msgpack") - self.assertIn("not one this runtime reads", str(unsupported.exception)) - self.assertNotIn("variant", str(unsupported.exception)) - with self.assertRaises(ValueError) as invalid: - self._pull_vector("extra-slot-full-payload.msgpack") - self.assertIn("not a valid store", str(invalid.exception)) - self.assertNotIn("variant", str(invalid.exception)) - - def test_single_file_only_a_missing_store_reads_as_empty(self) -> None: - with tempfile.TemporaryDirectory() as tmp: - self.assertEqual(SingleFileMessagePackBackingStore(Path(tmp) / "store.cc").pull_all(), []) - - # An existing empty file is not a store: no CultCache writer leaves one. - empty = Path(tmp) / "empty.cc" - empty.write_bytes(b"") - with self.assertRaises(ValueError): - SingleFileMessagePackBackingStore(empty).pull_all() - self.assertEqual(empty.read_bytes(), b"") - - # An empty array is the legacy envelope array with no envelopes: no header, no format claimed. - legacy_empty = Path(tmp) / "legacy-empty.cc" - legacy_empty.write_bytes(b"\x90") - self.assertEqual(SingleFileMessagePackBackingStore(legacy_empty).pull_all(), []) - - def test_single_file_refusals_never_echo_a_value_from_the_store(self) -> None: - import msgpack # type: ignore - - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "store.cc" - cases = [ - (["cultcache.store.v12", [], []], True), - (["cultcache.store.SECRET-HEADER", [], []], False), - (["cultcache.store.v12SECRET", [], []], False), - (["cultcache.store.v", [], []], False), - (["cultcache.store.v1", ["SECRET-CATALOG-TEXT"], []], None), - ] - for value, echoed in cases: - path.write_bytes(msgpack.packb(value, use_bin_type=True)) - with self.assertRaises(ValueError) as caught: - SingleFileMessagePackBackingStore(path).pull_all() - message = str(caught.exception) - if echoed: - self.assertIn(repr(value[0]), message) - else: - self.assertNotIn("SECRET", message) - if echoed is False: - self.assertNotIn(repr(value[0]), message) - self.assertIn(f"of {len(value[0])} bytes", message) - - def test_single_file_record_refusal_names_only_a_string_key(self) -> None: - import msgpack # type: ignore - - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "store.cc" - for key, schema in ((["SECRET-IN-LIST"], "s"), (b"SECRET-BYTES", "s"), ("k", {"SECRET": 1})): - path.write_bytes(msgpack.packb( - ["cultcache.store.v1", [], [[key, schema, "t", b"\x90", "extra"]]], use_bin_type=True)) - with self.assertRaises(ValueError) as caught: - SingleFileMessagePackBackingStore(path).pull_all() - self.assertNotIn("SECRET", str(caught.exception)) - self.assertIn("not a valid store", str(caught.exception)) - - # What a write does through a symbolic link today. R3 decides whether a write resolves - # the link or refuses it; this pins the current behaviour so that change is deliberate. - @unittest.skipIf(os.name != "posix", "symbolic links need POSIX here") - def test_r3_decides_resolve_or_refuse_a_push_through_a_live_link_replaces_the_link(self) -> None: - with tempfile.TemporaryDirectory() as tmp: - volume = Path(tmp) / "volume" - volume.mkdir() - target = volume / "store.cc" - envelope = CultCacheEnvelope(key="a", type="t", payload=b"\x90", stored_at="2026-09-30T00:00:00Z") - SingleFileMessagePackBackingStore(target).push(envelope) - before = target.read_bytes() - link = Path(tmp) / "store.cc" - link.symlink_to(target) - SingleFileMessagePackBackingStore(link).push(replace(envelope, key="b")) - self.assertFalse(link.is_symlink()) - self.assertTrue(link.is_file()) - self.assertEqual(target.read_bytes(), before) - - @unittest.skipIf(os.name != "posix", "symbolic links need POSIX here") - def test_a_dangling_symlink_at_a_store_path_is_an_os_error_and_nothing_is_written(self) -> None: - for store_type in (SingleFileMessagePackBackingStore, JsonLinesBackingStore): - with tempfile.TemporaryDirectory() as tmp: - volume = Path(tmp) / "volume" - volume.mkdir() - path = Path(tmp) / "store.cc" - path.symlink_to(volume / "store.cc") - store = store_type(path) - with self.assertRaises(FileNotFoundError): - store.pull_all() - with self.assertRaises(FileNotFoundError): - store.push(CultCacheEnvelope(key="k", type="t", payload=b"\x90", stored_at="2026-09-30T00:00:00Z")) - self.assertTrue(path.is_symlink()) - self.assertEqual(list(volume.iterdir()), []) - - @unittest.skipIf(os.name != "posix", "symlink loops and file-as-parent errors are POSIX errno cases") - def test_json_lines_store_that_cannot_be_reached_is_an_os_error(self) -> None: - with tempfile.TemporaryDirectory() as tmp: - self.assertEqual(JsonLinesBackingStore(Path(tmp) / "missing.jsonl").pull_all(), []) - loop = Path(tmp) / "loop.jsonl" - loop.symlink_to(loop) - parent = Path(tmp) / "body" - parent.write_bytes(b"not a directory") - for path in (loop, parent / "store.jsonl"): - with self.assertRaises(OSError) as caught: - JsonLinesBackingStore(path).pull_all() - self.assertNotIsInstance(caught.exception, FileNotFoundError) - - @unittest.skipIf(os.name != "posix", "symlink loops and file-as-parent errors are POSIX errno cases") - def test_single_file_store_that_cannot_be_reached_is_an_os_error(self) -> None: - with tempfile.TemporaryDirectory() as tmp: - loop = Path(tmp) / "loop.cc" - loop.symlink_to(loop) - parent = Path(tmp) / "body" - parent.write_bytes(b"not a directory") - for path in (loop, parent / "store.cc"): - with self.assertRaises(OSError) as caught: - SingleFileMessagePackBackingStore(path).pull_all() - self.assertNotIsInstance(caught.exception, FileNotFoundError) - - if __name__ == "__main__": unittest.main() diff --git a/packages/cultcache-py/tests/test_union_parity.py b/packages/cultcache-py/tests/test_union_parity.py deleted file mode 100644 index 1d4387de..00000000 --- a/packages/cultcache-py/tests/test_union_parity.py +++ /dev/null @@ -1,392 +0,0 @@ -from __future__ import annotations - -import dataclasses -import shutil -import tempfile -import unittest -from pathlib import Path - -import msgpack - -from cultcache_py import ( - CultCache, - DatabaseEntryField, - SingleFileMessagePackBackingStore, - UnionArm, - database_entry_field, - define_database_entry_type, - define_record_codec, - define_union, -) - -VECTORS = Path(__file__).resolve().parents[3] / "tests" / "vectors" / "union-parity" - -composition = define_record_codec( - "Composition", [("name", 0), database_entry_field("body", 1, codec=lambda: node)] -) -box = define_record_codec("Box", [("id", 0), database_entry_field("children", 1, codec=lambda: node, many=True)]) -text = define_record_codec("Text", [("id", 0), ("content", 1)]) -use = define_record_codec( - "Use", - [ - ("id", 0), - database_entry_field("composition", 1, codec=composition), - database_entry_field("slots", 2, codec=lambda: node, many=True), - ], -) -image = define_record_codec("Image", [("id", 0), ("uri", 1), ("alt", 3)]) -node = define_union("Node", {0: ("Box", box), 1: ("Text", text), 2: ("Use", use), 5: ("Image", image)}) -outcome = define_union( - "Outcome", - { - 0: ("Pending", define_record_codec("Pending", [("message", 0)])), - 1: ("Completed", define_record_codec("Completed", [("source_version", 0)])), - 2: ("Denied", None), - }, -) -tool = define_record_codec("Tool", [("name", 0), ("uses", 1)]) -part = define_record_codec("Part", [("name", 0), ("count", 1)]) -gem = define_record_codec("Gem", [("name", 0)]) -item = define_union("Item", {0: ("Gem", gem), 1: ("Tool", tool), 2: ("Part", part)}) -crafted = define_union("CraftedItem", {0: ("Tool", tool), 1: ("Part", part)}) - -surface_document = define_database_entry_type( - "tests.union_surface", - [ - ("id", 0), - ("version", 1), - database_entry_field("root", 2, codec=node), - database_entry_field("outcomes", 3, codec=outcome, many=True), - database_entry_field("part", 4, codec=item), - database_entry_field("crafted", 5, codec=crafted), - database_entry_field("missing", 6, codec=node), - ], -) - - -def _surface_value() -> dict: - return { - "id": "surface", - "version": 3, - "root": UnionArm( - "Box", - { - "id": "root", - "children": [ - UnionArm("Text", {"id": "t1", "content": "hello"}), - UnionArm( - "Use", - { - "id": "u1", - "composition": { - "name": "comp", - "body": UnionArm( - "Box", - { - "id": "inner", - "children": [ - UnionArm("Text", {"id": "deep", "content": "x"}), - UnionArm("Image", {"id": "img", "uri": "uri://a", "alt": "alt"}), - ], - }, - ), - }, - "slots": [ - UnionArm("Text", {"id": "s1", "content": "slot"}), - None, - UnionArm("Box", {"id": "b2", "children": []}), - ], - }, - ), - UnionArm("Image", {"id": "i2", "uri": "uri://b", "alt": ""}), - ], - }, - ), - "outcomes": [ - UnionArm("Pending", {"message": "wait"}), - UnionArm("Completed", {"source_version": 7}), - UnionArm("Denied"), - ], - "part": UnionArm("Tool", {"name": "hammer", "uses": 12}), - "crafted": UnionArm("Part", {"name": "gear", "count": 4}), - "missing": None, - } - - -def _vector(name: str) -> bytes: - return (VECTORS / name).read_bytes() - - -class UnionSurfaceVectorTests(unittest.TestCase): - def test_surface_payload_decodes_to_the_value_and_re_encodes_byte_identical(self) -> None: - payload = _vector("union-surface.msgpack") - decoded = surface_document.decode_payload(payload) - self.assertEqual(decoded, _surface_value()) - self.assertEqual(surface_document.encode_payload(decoded), payload) - - def test_the_csharp_written_store_reads_and_the_cache_rewrites_the_same_payload(self) -> None: - with tempfile.TemporaryDirectory() as tmp: - path = Path(tmp) / "union-surface.cc" - shutil.copyfile(VECTORS / "union-surface.cc", path) - cache = ( - CultCache.builder() - .register_document_type(surface_document) - .add_generic_store(SingleFileMessagePackBackingStore(path)) - .build() - ) - cache.pull_all_backing_stores() - self.assertEqual(cache.get(surface_document, "surface"), _surface_value()) - fresh = Path(tmp) / "fresh.cc" - writer = ( - CultCache.builder() - .register_document_type(surface_document) - .add_generic_store(SingleFileMessagePackBackingStore(fresh)) - .build() - ) - writer.pull_all_backing_stores() - writer.put(surface_document, "surface", _surface_value()) - [envelope] = SingleFileMessagePackBackingStore(fresh).pull_all() - self.assertEqual(envelope.payload, _vector("union-surface.msgpack")) - - def test_the_missing_slot_is_a_node_and_agrees_with_the_csharp_written_root(self) -> None: - payload = _vector("union-surface.msgpack") - slots = msgpack.unpackb(payload, raw=False) - slots[6] = slots[2] - decoded = surface_document.decode_payload(msgpack.packb(slots, use_bin_type=True)) - self.assertEqual(decoded["missing"], _surface_value()["root"]) - self.assertEqual(surface_document.encode_payload(decoded), msgpack.packb(slots, use_bin_type=True)) - with self.assertRaises(ValueError): - surface_document.encode_payload({**_surface_value(), "missing": UnionArm("Part", {"name": "gear", "count": 4})}) - - def test_the_store_vector_payload_equals_the_surface_payload(self) -> None: - [envelope] = SingleFileMessagePackBackingStore(VECTORS / "union-surface.cc").pull_all() - self.assertEqual(envelope.payload, _vector("union-surface.msgpack")) - - def test_every_outcome_in_the_manifest_is_held(self) -> None: - outcomes = msgpack.unpackb(_vector("outcomes.msgpack"), raw=False) - self.assertEqual(len(outcomes), 9) - refused = read_only = 0 - for file, outcome_kind, union, key, detail in outcomes: - payload = _vector(file) - if outcome_kind == "refused": - refused += 1 - with self.assertRaises(ValueError, msg=file) as caught: - surface_document.decode_payload(payload) - message = str(caught.exception) - self.assertIn(union, message, file) - if detail == "unknown-arm": - self.assertIn(f"arm key {key} ", message, file) - else: - self.assertEqual(detail, "arity") - self.assertIn("malformed", message, file) - else: - read_only += 1 - self.assertEqual(outcome_kind, "read-only", file) - self.assertEqual(surface_document.decode_payload(payload), _surface_value(), file) - self.assertEqual((refused, read_only), (5, 4)) - - -class UnionCodecRuleTests(unittest.TestCase): - CANARY = "canary-7f3a91" - - def test_nil_union_is_nil_both_ways(self) -> None: - self.assertIsNone(node.encode(None)) - self.assertIsNone(node.decode(None)) - - def test_unit_arm_is_written_with_empty_slots_and_reads_back(self) -> None: - self.assertEqual(outcome.encode(UnionArm("Denied")), [2, []]) - self.assertEqual(outcome.decode([2, []]), UnionArm("Denied", None)) - - def test_unit_arm_refuses_a_value_to_carry(self) -> None: - with self.assertRaises(ValueError) as caught: - outcome.encode(UnionArm("Denied", {"message": self.CANARY})) - self.assertEqual(str(caught.exception), "Union 'Outcome' arm 2 is a unit arm and carries no value") - - def test_arm_keys_are_written_as_declared(self) -> None: - self.assertEqual(node.encode(UnionArm("Image", {"id": "a", "uri": "b", "alt": "c"})), [5, ["a", "b", None, "c"]]) - self.assertEqual(node.encode(UnionArm("Text", {"id": "a", "content": "b"})), [1, ["a", "b"]]) - - def test_encode_refuses_an_arm_the_union_does_not_declare_without_echoing_it(self) -> None: - with self.assertRaises(ValueError) as caught: - crafted.encode(UnionArm("Gem", {"name": self.CANARY})) - self.assertEqual( - str(caught.exception), "Union 'CraftedItem' was given a value that is not one of its arms" - ) - with self.assertRaises(ValueError): - node.encode({"id": "a"}) - - def test_unknown_key_names_the_union_the_key_and_the_declared_keys_never_the_payload(self) -> None: - with self.assertRaises(ValueError) as caught: - node.decode([4, [self.CANARY]]) - message = str(caught.exception) - self.assertEqual(message, "Union 'Node' does not declare arm key 4 (declared: 0, 1, 2, 5)") - - def test_a_malformed_union_value_is_refused_without_echoing_it(self) -> None: - for raw in ( - [1], - [1, ["a"], "extra"], - [1, self.CANARY], - self.CANARY, - {"k": self.CANARY}, - [self.CANARY, []], - [True, []], - [1.0, []], - ): - with self.subTest(raw=type(raw).__name__): - with self.assertRaises(ValueError) as caught: - node.decode(raw) - message = str(caught.exception) - self.assertTrue(message.startswith("Union 'Node' value is malformed: "), message) - self.assertNotIn(self.CANARY, message) - - def test_extra_trailing_arm_slots_are_read(self) -> None: - self.assertEqual( - node.decode([1, ["a", "b", "extra"]]), - UnionArm("Text", {"id": "a", "content": "b"}), - ) - - def test_many_slot_requires_a_list_and_keeps_nil_elements(self) -> None: - slots = [UnionArm("Text", {"id": "a", "content": "b"}), None] - encoded = use.encode({"id": "u", "composition": None, "slots": slots}) - self.assertEqual(encoded, ["u", None, [[1, ["a", "b"]], None]]) - self.assertEqual(use.decode(encoded)["slots"], slots) - with self.assertRaises(ValueError) as caught: - use.decode(["u", None, self.CANARY]) - self.assertEqual(str(caught.exception), "DatabaseEntry document type 'Use' slot 2 expected a MessagePack array") - - def test_a_list_of_nested_records_keeps_a_nil_element_as_csharp_writes_it(self) -> None: - row = define_record_codec("Row", [("id", 0), database_entry_field("cells", 1, codec=text, many=True)]) - cells = [None, {"id": "c", "content": "x"}, None] - encoded = row.encode({"id": "r", "cells": cells}) - self.assertEqual(encoded, ["r", [None, ["c", "x"], None]]) - self.assertEqual(row.decode(encoded), {"id": "r", "cells": cells}) - - def test_a_unit_arm_with_extra_slots_is_read_past(self) -> None: - self.assertEqual(outcome.decode([2, ["extra"]]), UnionArm("Denied")) - - def test_union_arms_are_immutable_hashable_values(self) -> None: - arm = UnionArm("Denied") - with self.assertRaises(dataclasses.FrozenInstanceError): - arm.name = "Pending" # type: ignore[misc] - self.assertEqual(len({UnionArm("Denied"), UnionArm("Denied"), UnionArm("Pending", "wait")}), 2) - - def test_a_nested_record_with_a_missing_required_slot_is_refused(self) -> None: - with self.assertRaises(ValueError) as caught: - node.decode([1, ["only-id"]]) - self.assertEqual(str(caught.exception), "DatabaseEntry document type 'Text' is missing required slot 1") - - def test_definition_rules(self) -> None: - cases = [ - ("Empty", {}, "Union 'Empty' requires at least one arm"), - ("Dup", {0: ("A", None), 1: ("A", None)}, "Union 'Dup' has duplicate arm names"), - ("Wide", {2**31: ("A", None)}, "Union 'Wide' arm keys must be integers within Int32"), - ("Narrow", {-(2**31) - 1: ("A", None)}, "Union 'Narrow' arm keys must be integers within Int32"), - ("Flag", {True: ("A", None), "x": ("B", None)}, "Union 'Flag' arm keys must be integers within Int32"), - ] - for union_name, arms, expected in cases: - with self.subTest(union=union_name): - with self.assertRaises(ValueError) as caught: - define_union(union_name, arms) - self.assertEqual(str(caught.exception), expected) - edge = define_union("Edge", {-(2**31): ("Low", None), -1: ("Negative", None), 2**31 - 1: ("High", None)}) - for arm_name, key in (("Low", -(2**31)), ("Negative", -1), ("High", 2**31 - 1)): - self.assertEqual(edge.encode(UnionArm(arm_name)), [key, []]) - self.assertEqual(edge.decode([key, []]), UnionArm(arm_name)) - with self.assertRaises(ValueError) as caught: - database_entry_field("loose", 1, many=True) - self.assertEqual(str(caught.exception), "A many DatabaseEntry field requires a codec") - database_entry_field("fine", 1, codec=node, many=True) - - -class RecordCodecTests(unittest.TestCase): - def test_defaults_fill_a_missing_or_nil_slot_and_a_callable_default_is_called(self) -> None: - record = define_record_codec( - "Defaulted", - [("id", 0), ("label", 1, "none"), ("tags", 2, list), ("plain", 3, 0)], - ) - self.assertEqual(record.decode(["a"]), {"id": "a", "label": "none", "tags": [], "plain": 0}) - self.assertEqual( - record.decode(["a", None, None, None]), {"id": "a", "label": "none", "tags": [], "plain": 0} - ) - self.assertEqual(record.decode(["a", "x", ["t"], 5]), {"id": "a", "label": "x", "tags": ["t"], "plain": 5}) - - def test_a_document_type_names_its_members_and_marks_the_name_and_index_slots(self) -> None: - document = define_database_entry_type( - "tests.members", - [("id", 0), ("source_version", 1), ("owner", 2)], - name="id", - indexes={"by_owner": "owner"}, - ) - members = {member.slot: member for member in document.members} - self.assertEqual( - [members[slot].member_name for slot in (0, 1, 2)], ["Id", "SourceVersion", "Owner"] - ) - self.assertEqual([members[slot].is_name for slot in (0, 1, 2)], [True, False, False]) - self.assertEqual([members[slot].index_alias for slot in (0, 1, 2)], [None, None, "by_owner"]) - - def test_a_document_without_a_string_name_marks_no_member_as_the_name(self) -> None: - document = define_database_entry_type("tests.named", [("id", 0)], name=lambda value: value["id"]) - self.assertFalse(document.members[0].is_name) - - def test_a_record_that_is_not_an_array_is_refused_naming_the_type_only(self) -> None: - for refuse in (lambda r: r.decode({"id": "canary-7f3a91"}), lambda r: r.decode("canary-7f3a91")): - record = define_record_codec("Plain", [("id", 0)]) - with self.assertRaises(ValueError) as caught: - refuse(record) - self.assertEqual(str(caught.exception), "DatabaseEntry document type 'Plain' expected a MessagePack array") - self.assertNotIn("canary-7f3a91", str(caught.exception)) - - def test_field_tuples_of_the_wrong_length_are_refused(self) -> None: - for fields in ([("id",)], [("id", 0, 1, 2)]): - with self.assertRaises(ValueError) as caught: - define_record_codec("Bad", fields) - self.assertEqual( - str(caught.exception), "DatabaseEntry field tuples must be (name, key) or (name, key, default)" - ) - self.assertEqual(define_record_codec("Pair", [("id", 0)]).decode(["a"]), {"id": "a"}) - self.assertEqual(define_record_codec("Triple", [("id", 1, "d")]).decode([None]), {"id": "d"}) - - def test_duplicate_and_empty_field_lists_are_refused_naming_the_type(self) -> None: - with self.assertRaises(ValueError) as caught: - define_record_codec("Twice", [("a", 0), ("b", 0)]) - self.assertEqual(str(caught.exception), "DatabaseEntry document type 'Twice' has duplicate field keys") - with self.assertRaises(ValueError) as empty: - define_record_codec("Nothing", []) - self.assertEqual(str(empty.exception), "DatabaseEntry document types require at least one field") - - def test_a_plain_field_helper_makes_a_required_slot_with_no_codec(self) -> None: - plain = define_record_codec("Plain", [database_entry_field("id", 0), database_entry_field("label", 1)]) - self.assertEqual(plain.decode(plain.encode({"id": "a", "label": "b"})), {"id": "a", "label": "b"}) - with self.assertRaises(ValueError) as caught: - plain.decode(["a"]) - self.assertEqual(str(caught.exception), "DatabaseEntry document type 'Plain' is missing required slot 1") - field = database_entry_field("id", 0) - self.assertIsNone(field.codec) - self.assertFalse(field.many) - - def test_a_directly_constructed_field_requires_a_default_and_is_plain_and_single(self) -> None: - with self.assertRaises(TypeError): - DatabaseEntryField(name="id", key=0) # type: ignore[call-arg] - field = DatabaseEntryField(name="id", key=0, default=dataclasses.MISSING) - self.assertIsNone(field.codec) - self.assertIs(field.many, False) - - def test_slot_codecs_and_fields_are_immutable(self) -> None: - with self.assertRaises(dataclasses.FrozenInstanceError): - node.encode = None # type: ignore[misc] - with self.assertRaises(dataclasses.FrozenInstanceError): - database_entry_field("id", 0).key = 1 # type: ignore[misc] - - def test_a_negative_slot_key_is_refused_but_zero_is_not(self) -> None: - database_entry_field("zero", 0) - with self.assertRaises(ValueError) as caught: - database_entry_field("negative", -1) - self.assertEqual(str(caught.exception), "DatabaseEntry field keys must be non-negative integers") - - def test_slot_order_follows_keys_not_declaration_order(self) -> None: - record = define_record_codec("Ordered", [("b", 2), ("a", 0)]) - self.assertEqual(record.encode({"a": "x", "b": "y"}), ["x", None, "y"]) - - -if __name__ == "__main__": - unittest.main() diff --git a/packages/cultcache-rs/README.md b/packages/cultcache-rs/README.md index 6841791f..1ad01eb0 100644 --- a/packages/cultcache-rs/README.md +++ b/packages/cultcache-rs/README.md @@ -293,61 +293,6 @@ writes. That protects ordinary multi-process access to the same file. It is still not a multi-master replication protocol, and it is not a substitute for a coordinator when higher-level write ordering matters. -A write that fails part way, for example on a full disk, removes its staging -file and leaves the store as it was. A read that fails tells you why through -the error chain: - -```rust -use cultcache_rs::{CacheBackingStore, CultCacheStoreUnreadable, CultCacheStoreUnreadableKind, SingleFileMessagePackBackingStore}; - -let store = SingleFileMessagePackBackingStore::new("cache.cc"); -if let Err(error) = store.pull_all() { - match error.downcast_ref::().map(|unreadable| unreadable.kind) { - // The bytes were read and are not a store: truncated, garbled, or invalid. - Some(CultCacheStoreUnreadableKind::Undecodable) => {} - // The header names a format this runtime does not read, such as a newer one. - Some(CultCacheStoreUnreadableKind::UnsupportedFormat) => {} - // The bytes could not be read at all: a std::io::Error is in the chain. - _ => {} - } -} -``` - -An I/O failure never carries `CultCacheStoreUnreadable`, and the chain under -`CultCacheStoreUnreadable` never holds a `std::io::Error`. - -Only a store file that does not exist (`std::io::ErrorKind::NotFound`) reads as -an empty store. Any other failure to reach it, such as a symlink loop, a file -where a parent directory should be, or a missing permission, is an I/O error. -A store file that exists and holds zero bytes is `Undecodable`: no CultCache -writer leaves one. A symbolic link whose target is gone is not a missing store: -reading it is an I/O error, so a read-then-write (`push`, `delete`, the exchanges) -fails before writing. Writes do not yet follow links: a write through a live link, -and a `push_all` through a dangling one, replace the link with a regular file and -leave its target alone. A refusal names no -value read from the file; it names a record only by its key and schema id, and -a header only when it has the shape `cultcache.store.v`. - -A write that fails says what it left on disk: - -```rust -use cultcache_rs::{CultCacheStoreWriteFailed, CultCacheStoreWriteFailedKind}; - -fn outcome(error: &anyhow::Error) { - match error.downcast_ref::().map(|failed| failed.kind) { - // The entries cannot be stored; retrying them fails the same way. - Some(CultCacheStoreWriteFailedKind::Rejected) => {} - // Staging, fsync or rename failed: the store file holds what it held before, - // and a retry may succeed once the fault (a full disk, say) clears. - Some(CultCacheStoreWriteFailedKind::NotReplaced) => {} - // The rename landed and the directory sync failed: the new snapshot is in - // place but may not survive a crash. - Some(CultCacheStoreWriteFailedKind::ReplacedNotDurable) => {} - _ => {} - } -} -``` - ## Near-Term Ergonomic Improvements 1. **Derive macro** diff --git a/packages/cultcache-rs/src/lib.rs b/packages/cultcache-rs/src/lib.rs index 71bf8fca..ed9cae32 100644 --- a/packages/cultcache-rs/src/lib.rs +++ b/packages/cultcache-rs/src/lib.rs @@ -271,7 +271,7 @@ struct PersistedSchemaCatalogMember( Option, ); -#[derive(Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] struct PersistedRecord( String, String, @@ -279,192 +279,6 @@ struct PersistedRecord( #[serde(with = "serde_bytes")] Vec, ); -impl<'de> serde::Deserialize<'de> for PersistedRecord { - /// Reads the four v1 slots and refuses a fifth, naming the record. No runtime reads a - /// v1 store holding such a record, so the store is not a valid one. - fn deserialize>(deserializer: D) -> std::result::Result { - use serde::de::{Error, IgnoredAny, SeqAccess, Visitor}; - - struct RecordVisitor; - impl<'de> Visitor<'de> for RecordVisitor { - type Value = PersistedRecord; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("a CultCache persisted record of 4 slots") - } - - fn visit_seq>(self, mut seq: A) -> std::result::Result { - let key: String = seq.next_element()?.ok_or_else(|| A::Error::invalid_length(0, &self))?; - let schema_id: String = seq.next_element()?.ok_or_else(|| A::Error::invalid_length(1, &self))?; - let stored_at: String = seq.next_element()?.ok_or_else(|| A::Error::invalid_length(2, &self))?; - let payload: serde_bytes::ByteBuf = - seq.next_element()?.ok_or_else(|| A::Error::invalid_length(3, &self))?; - if seq.next_element::()?.is_some() { - return Err(A::Error::custom(format!( - "{RECORD_REFUSAL}{key:?} (schema {schema_id:?}) has more than the 4 slots of a {STORE_FORMAT_V1} record, so this is not a valid store" - ))); - } - Ok(PersistedRecord(key, schema_id, stored_at, payload.into_vec())) - } - } - - deserializer.deserialize_seq(RecordVisitor) - } -} - -const STORE_FORMAT_V1: &str = "cultcache.store.v1"; - -/// Opens every refusal CultCache raises about one persisted record. The decoder's own -/// messages can quote the bytes; these name only the record's key and schema id. -const RECORD_REFUSAL: &str = "CultCache record "; - -/// A store header as a refusal may show it: echoed when it has the shape -/// `cultcache.store.v`, and otherwise described only by its length, since the -/// bytes are the store's and an error text must not carry them. -fn describe_header(header: &str) -> String { - let known_shape = header - .strip_prefix("cultcache.store.v") - .is_some_and(|version| !version.is_empty() && version.bytes().all(|byte| byte.is_ascii_digit())); - if known_shape { - format!("{header:?}") - } else { - format!("an unrecognised cultcache.store.* header of {} bytes", header.len()) - } -} - -/// What a failed decode tells the operator: CultCache's own context and record -/// refusals, and for a decoder failure only its kind, never a value from the bytes. -fn describe_undecodable(error: &anyhow::Error) -> String { - let mut parts = Vec::new(); - for cause in error.chain() { - if let Some(decode) = cause.downcast_ref::() { - parts.push(describe_decode_error(decode)); - break; - } - parts.push(cause.to_string()); - } - parts.join(": ") -} - -/// A decoder failure as an error that keeps only its kind. Every decode of stored bytes -/// goes through this or [`describe_undecodable`], so no error text quotes a stored value. -fn opaque_decode_error(error: rmp_serde::decode::Error) -> anyhow::Error { - anyhow!(describe_decode_error(&error)) -} - -fn describe_decode_error(error: &rmp_serde::decode::Error) -> String { - use rmp_serde::decode::Error; - match error { - Error::InvalidMarkerRead(_) | Error::InvalidDataRead(_) => "the bytes end before the store does", - Error::TypeMismatch(_) => "a value has a MessagePack type the store format does not allow", - Error::OutOfRange => "a number is out of range for its slot", - Error::LengthMismatch(_) => "an array has a length the store format does not allow", - Error::Utf8Error(_) => "a string is not valid UTF-8", - Error::DepthLimitExceeded => "values are nested deeper than the decoder allows", - Error::Syntax(message) | Error::Uncategorized(message) if message.starts_with(RECORD_REFUSAL) => { - return message.clone(); - } - Error::Syntax(_) | Error::Uncategorized(_) => "a value does not fit the store format", - } - .to_string() -} - -/// The store header string, or `None` when the bytes do not open with an array whose -/// first slot is a string (the legacy envelope array starts with a map). Only the -/// leading bytes are read, so a store cut short after its header still names its format. -fn store_header(bytes: &[u8]) -> Option { - let mut offset = 0usize; - if read_array_header(bytes, &mut offset)? == 0 { - return None; - } - read_string(bytes, &mut offset) -} - -/// A single-file store whose bytes were read and not accepted. It sits in the error -/// chain of every such read, so a consumer tells it apart with -/// `error.downcast_ref::()`. A failure to read the bytes -/// at all stays a [`std::io::Error`] in the chain and never carries this type; the -/// chain under this type never holds an `io::Error`, so the two never overlap. -#[derive(Clone, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub struct CultCacheStoreUnreadable { - pub path: PathBuf, - pub kind: CultCacheStoreUnreadableKind, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub enum CultCacheStoreUnreadableKind { - /// The bytes are not a store this runtime's format accepts: truncated, garbled, - /// or a record the format does not allow. - Undecodable, - /// The header names a store format this runtime does not read, such as one - /// written by a newer runtime. The rest of the file was not judged. - UnsupportedFormat, -} - -impl std::fmt::Display for CultCacheStoreUnreadable { - fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - match self.kind { - CultCacheStoreUnreadableKind::Undecodable => { - write!(formatter, "CultCache store {} is not decodable", self.path.display()) - } - CultCacheStoreUnreadableKind::UnsupportedFormat => write!( - formatter, - "CultCache store {} is in a format this runtime does not read", - self.path.display() - ), - } - } -} - -impl std::error::Error for CultCacheStoreUnreadable {} - -/// A write to a single-file store that failed, and what it left on disk. It sits in the -/// error chain of every such failure, above the cause, so a consumer tells the outcomes -/// apart with `error.downcast_ref::()`. -#[derive(Clone, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub struct CultCacheStoreWriteFailed { - pub path: PathBuf, - pub kind: CultCacheStoreWriteFailedKind, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub enum CultCacheStoreWriteFailedKind { - /// The entries cannot be stored as a snapshot, for example two document types - /// claim one schema id. Nothing was written, and retrying the same entries fails - /// the same way: this is a refusal, not an I/O failure. - Rejected, - /// The write failed before the store file was replaced (creating, writing or - /// syncing the staging file, or renaming it): the file holds what it held before. - NotReplaced, - /// The store file was replaced, then syncing its directory failed: the new - /// snapshot is in place but may not survive a crash. - ReplacedNotDurable, -} - -impl std::fmt::Display for CultCacheStoreWriteFailed { - fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - match self.kind { - CultCacheStoreWriteFailedKind::Rejected => { - write!(formatter, "CultCache store {} refused a snapshot it cannot store", self.path.display()) - } - CultCacheStoreWriteFailedKind::NotReplaced => { - write!(formatter, "CultCache store {} was not replaced", self.path.display()) - } - CultCacheStoreWriteFailedKind::ReplacedNotDurable => write!( - formatter, - "CultCache store {} was replaced, but the replacement is not yet durable", - self.path.display() - ), - } - } -} - -impl std::error::Error for CultCacheStoreWriteFailed {} - #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct PushAllOptions { pub soft: bool, @@ -541,12 +355,10 @@ impl SingleFileMessagePackBackingStore { /// either file. Writers using the sibling lock cannot replace the snapshot /// until `action` returns. /// - /// Releasing the lock is RAII cleanup, under the same policy as every lock in - /// this crate (see `release_lock`): a release failure cannot rewrite the - /// completed action's result. This path alone also offers an observer for that - /// failure, [`Self::with_read_only_shared_snapshot_and_unlock_diagnostic`], - /// because a provider crossing may need to report it; the locked read and write - /// paths discard it. + /// Releasing the lock is RAII cleanup. A release failure therefore cannot + /// rewrite the completed action's result; consumers that need to observe + /// that cleanup failure can use + /// [`Self::with_read_only_shared_snapshot_and_unlock_diagnostic`]. pub fn with_read_only_shared_snapshot( &self, action: impl FnOnce(Vec) -> Result, @@ -838,44 +650,17 @@ impl SingleFileMessagePackBackingStore { } fn read_all_unlocked(&self) -> Result> { - // Only a store that is not there is empty. A file that is there and empty is - // not a store (no writer leaves one), and any other failure to reach the file, - // such as a symlink loop, a file where a directory should be, or no permission, - // stays an io::Error: reading it as empty would let a writer replace a store it - // never saw. - // A dangling symbolic link is something at the path, not nothing: reading it as - // empty would let the writer rename a file over the link and move the store off - // the volume the link pointed to. - let bytes = match fs::read(&self.path) { - Ok(bytes) => bytes, - Err(error) if error.kind() == std::io::ErrorKind::NotFound && is_absent(&self.path)? => { - return Ok(Vec::new()); - } - Err(error) => { - return Err(anyhow::Error::new(error) - .context(format!("failed to read {}", self.path.display()))); - } - }; - let unreadable = |kind, detail: anyhow::Error| { - // The detail is rebuilt as text that names no value read from the bytes. The - // decoder reports a short read as an io::Error, and dropping it keeps an - // io::Error in the chain meaning only that the file itself could not be read. - anyhow!(describe_undecodable(&detail)).context(CultCacheStoreUnreadable { - path: self.path.clone(), - kind, - }) - }; - match store_header(&bytes) { - Some(header) if header == STORE_FORMAT_V1 => decode_store_snapshot(&bytes) - .map_err(|error| unreadable(CultCacheStoreUnreadableKind::Undecodable, error)), - Some(header) if header.starts_with("cultcache.store.") => Err(unreadable( - CultCacheStoreUnreadableKind::UnsupportedFormat, - anyhow!("its header is {}; this runtime reads {STORE_FORMAT_V1:?} only", describe_header(&header)), - )), - _ => rmp_serde::from_slice(&bytes) - .context("failed to decode legacy CultCache envelope array") - .map_err(|error| unreadable(CultCacheStoreUnreadableKind::Undecodable, error)), + if !self.path.exists() { + return Ok(Vec::new()); } + let bytes = fs::read(&self.path) + .with_context(|| format!("failed to read {}", self.path.display()))?; + if bytes.is_empty() { + return Ok(Vec::new()); + } + decode_store_snapshot(&bytes) + .or_else(|_| rmp_serde::from_slice(&bytes)) + .with_context(|| format!("failed to decode MessagePack {}", self.path.display())) } /// Reads one filesystem snapshot without creating or opening the sibling @@ -891,39 +676,29 @@ impl SingleFileMessagePackBackingStore { } fn write_all_unlocked(&self, entries: &[CultCacheEnvelope]) -> Result<()> { - let failed = |kind| CultCacheStoreWriteFailed { - path: self.path.clone(), - kind, - }; - let bytes = encode_store_snapshot(entries) - .and_then(|snapshot| rmp_serde::to_vec(&snapshot).context("failed to encode MessagePack")) - .map_err(|error| error.context(failed(CultCacheStoreWriteFailedKind::Rejected)))?; - self.replace_unlocked(&bytes) - .map_err(|error| error.context(failed(CultCacheStoreWriteFailedKind::NotReplaced)))?; - sync_parent_directory(&self.path) - .map_err(|error| error.context(failed(CultCacheStoreWriteFailedKind::ReplacedNotDurable))) - } - - /// Everything up to and including the rename over the store file. On failure the - /// store file is as it was. - fn replace_unlocked(&self, bytes: &[u8]) -> Result<()> { if let Some(parent) = self.path.parent() { fs::create_dir_all(parent) .with_context(|| format!("failed to create {}", parent.display()))?; } remove_abandoned_staging_files(&self.path)?; + let bytes = rmp_serde::to_vec(&encode_store_snapshot(entries)?) + .context("failed to encode MessagePack")?; let tmp_path = temporary_path_for(&self.path); - let staged = OpenOptions::new() + let mut staged = OpenOptions::new() .create_new(true) .write(true) .open(&tmp_path) .with_context(|| format!("failed to create {}", tmp_path.display()))?; - // From here the staging file is this write's to remove: a write that fails - // for lack of space must not keep holding the space it failed on. - if let Err(error) = stage_and_replace(staged, &tmp_path, bytes, &self.path) { - let _ = fs::remove_file(&tmp_path); - return Err(error); - } + use std::io::Write; + staged + .write_all(&bytes) + .with_context(|| format!("failed to write {}", tmp_path.display()))?; + staged + .sync_all() + .with_context(|| format!("failed to sync {}", tmp_path.display()))?; + drop(staged); + replace_file_atomically(&tmp_path, &self.path)?; + sync_parent_directory(&self.path)?; Ok(()) } @@ -931,14 +706,20 @@ impl SingleFileMessagePackBackingStore { let lock = self.open_lock_file()?; fs2::FileExt::lock_shared(&lock) .with_context(|| format!("failed to lock {}", self.lock_path().display()))?; - release_lock(lock, action()) + let result = action(); + fs2::FileExt::unlock(&lock) + .with_context(|| format!("failed to unlock {}", self.lock_path().display()))?; + result } fn with_exclusive_lock(&self, action: impl FnOnce() -> Result) -> Result { let lock = self.open_lock_file()?; fs2::FileExt::lock_exclusive(&lock) .with_context(|| format!("failed to lock {}", self.lock_path().display()))?; - release_lock(lock, action()) + let result = action(); + fs2::FileExt::unlock(&lock) + .with_context(|| format!("failed to unlock {}", self.lock_path().display()))?; + result } /// Replaces the named entries only if each still matches its expectation. @@ -1055,7 +836,10 @@ impl SingleFileMessagePackBackingStore { .with_context(|| format!("failed to lock {}", self.lock_path().display())); } } - release_lock(lock, action()).map(Some) + let result = action(); + fs2::FileExt::unlock(&lock) + .with_context(|| format!("failed to unlock {}", self.lock_path().display()))?; + result.map(Some) } fn open_lock_file(&self) -> Result { @@ -1140,7 +924,7 @@ fn unique_batch_ids( impl CacheBackingStore for SingleFileMessagePackBackingStore { fn pull_all(&self) -> Result> { - if is_absent(&self.path)? && is_absent(&self.lock_path())? { + if !self.path.exists() && !self.lock_path().exists() { return Ok(Vec::new()); } self.with_shared_lock(|| self.read_all_unlocked()) @@ -1245,7 +1029,10 @@ impl RedbMessagePackBackingStore { .with_context(|| format!("failed to open {}", lock_path.display()))?; fs2::FileExt::lock_exclusive(&lock) .with_context(|| format!("failed to lock {}", lock_path.display()))?; - release_lock(lock, self.open_database().and_then(|database| action(&database))) + let result = self.open_database().and_then(|database| action(&database)); + fs2::FileExt::unlock(&lock) + .with_context(|| format!("failed to unlock {}", lock_path.display()))?; + result } fn lock_path(&self) -> PathBuf { @@ -2025,9 +1812,7 @@ fn read_redb_entry( table .get(key.as_slice())? .map(|value| { - rmp_serde::from_slice(value.value()) - .map_err(opaque_decode_error) - .context("failed to decode redb CultCache envelope") + rmp_serde::from_slice(value.value()).context("failed to decode redb CultCache envelope") }) .transpose() } @@ -2049,9 +1834,7 @@ fn read_all_redb( .iter()? .map(|row| { let (_, value) = row?; - rmp_serde::from_slice(value.value()) - .map_err(opaque_decode_error) - .context("failed to decode redb CultCache envelope") + rmp_serde::from_slice(value.value()).context("failed to decode redb CultCache envelope") }) .collect::>>()?; entries.sort_by_key(entry_id); @@ -2282,7 +2065,7 @@ impl CultCache { let Some(entry) = self.entries.get(&entry_id_parts(T::TYPE, key)) else { return Ok(None); }; - let payload = rmp_serde::from_slice(&entry.payload).map_err(opaque_decode_error).with_context(|| { + let payload = rmp_serde::from_slice(&entry.payload).with_context(|| { format!( "failed to decode CultCache entry {:?} at key {:?} as {}", T::TYPE, @@ -2315,7 +2098,7 @@ impl CultCache { if entry.r#type != T::TYPE { continue; } - values.push(rmp_serde::from_slice(&entry.payload).map_err(opaque_decode_error).with_context(|| { + values.push(rmp_serde::from_slice(&entry.payload).with_context(|| { format!( "failed to decode CultCache entry {:?} at key {:?} as {}", T::TYPE, @@ -2336,7 +2119,7 @@ impl CultCache { } values.push(( entry.key.clone(), - rmp_serde::from_slice(&entry.payload).map_err(opaque_decode_error).with_context(|| { + rmp_serde::from_slice(&entry.payload).with_context(|| { format!( "failed to decode CultCache entry {:?} at key {:?} as {}", T::TYPE, @@ -2418,7 +2201,7 @@ impl CultCache { key: String, payload: Vec, ) -> Result<(CultCacheEnvelope, T)> { - let parsed: T = rmp_serde::from_slice(&payload).map_err(opaque_decode_error).with_context(|| { + let parsed: T = rmp_serde::from_slice(&payload).with_context(|| { format!( "failed to validate CultCache entry {:?} at key {:?} as {}", T::TYPE, @@ -2554,7 +2337,7 @@ impl CultCache { )); } - rmp_serde::from_slice(&entry.payload).map_err(opaque_decode_error).with_context(|| { + rmp_serde::from_slice(&entry.payload).with_context(|| { format!( "failed to validate CultCache envelope {:?} at key {:?} as {}", T::TYPE, @@ -2728,16 +2511,18 @@ fn encode_store_snapshot(entries: &[CultCacheEnvelope]) -> Result Result> { let snapshot: PersistedStoreSnapshot = rmp_serde::from_slice(bytes).context("failed to decode CultCache v1 snapshot")?; + if snapshot.0 != "cultcache.store.v1" { + return Err(anyhow!("unsupported CultCache snapshot {}", snapshot.0)); + } let catalog = snapshot .1 @@ -2875,47 +2660,6 @@ fn temporary_path_for(path: &Path) -> PathBuf { path.with_file_name(file_name) } -/// Writes and syncs the staged snapshot, closes it, and renames it over `destination`. -fn stage_and_replace(mut staged: File, staged_path: &Path, bytes: &[u8], destination: &Path) -> Result<()> { - use std::io::Write; - staged - .write_all(bytes) - .with_context(|| format!("failed to write {}", staged_path.display()))?; - injected_write_fault(WriteStep::StagingSync) - .and_then(|()| staged.sync_all()) - .with_context(|| format!("failed to sync {}", staged_path.display()))?; - drop(staged); - replace_file_atomically(staged_path, destination) -} - -/// Releases a lock taken around `result`'s action and returns that result. -/// -/// The policy for every lock in this crate: an unlock failure never replaces the action's -/// result, so a write that landed is reported as landed. The failure is discarded here -/// because these paths have no observer; the read-only snapshot, whose API offers one, -/// hands it to [`SingleFileMessagePackBackingStore::with_read_only_shared_snapshot_and_unlock_diagnostic`]. -/// -/// Dropping `lock` closes this descriptor, which releases the lock only when no other -/// descriptor shares its open file description. A child forked without exec holds such a -/// duplicate, and the lock then stays held until the child closes it or exits. -fn release_lock(lock: File, result: Result) -> Result { - let _unlock_failure_released_by_close = - injected_write_fault(WriteStep::Unlock).and_then(|()| fs2::FileExt::unlock(&lock)); - drop(lock); - result -} - -/// True only when nothing is at `path`; a symbolic link, dangling or not, is something. -/// A path that cannot be inspected (a file where a directory should be, no permission) -/// is an error, never absent. -fn is_absent(path: &Path) -> Result { - match fs::symlink_metadata(path) { - Ok(_) => Ok(false), - Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(true), - Err(error) => Err(anyhow::Error::new(error).context(format!("failed to inspect {}", path.display()))), - } -} - fn remove_abandoned_staging_files(destination: &Path) -> Result<()> { let Some(parent) = destination.parent() else { return Ok(()); @@ -3059,41 +2803,11 @@ fn sync_parent_directory(path: &Path) -> Result<()> { let Some(parent) = path.parent() else { return Ok(()); }; - injected_write_fault(WriteStep::DirectorySync) - .and_then(|()| File::open(parent)) + File::open(parent) .and_then(|directory| directory.sync_all()) .with_context(|| format!("failed to sync {}", parent.display())) } -/// The steps no test can make fail for real: fsync and unlock do not fail on a healthy -/// filesystem. Tests arm one step on their own thread; builds outside tests never fail here. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[allow(dead_code)] -enum WriteStep { - StagingSync, - DirectorySync, - Unlock, -} - -#[cfg(test)] -thread_local! { - static INJECTED_WRITE_FAULT: std::cell::Cell> = const { std::cell::Cell::new(None) }; -} - -#[cfg(test)] -fn injected_write_fault(step: WriteStep) -> std::io::Result<()> { - if INJECTED_WRITE_FAULT.with(|fault| fault.get()) == Some(step) { - return Err(std::io::Error::other("injected write fault")); - } - Ok(()) -} - -#[cfg(not(test))] -#[inline(always)] -fn injected_write_fault(_step: WriteStep) -> std::io::Result<()> { - Ok(()) -} - #[cfg(windows)] fn sync_parent_directory(_path: &Path) -> Result<()> { // MoveFileExW with MOVEFILE_WRITE_THROUGH owns publication durability. @@ -3212,8 +2926,6 @@ mod tests { store.push(&released)?; let writer_path = store_path.clone(); - let gate_path = store_path.clone(); - let gate_released = released.clone(); let (started_tx, started_rx) = mpsc::channel(); let (finished_tx, finished_rx) = mpsc::channel(); store.with_read_only_shared_snapshot(|captured| { @@ -3228,21 +2940,15 @@ mod tests { writer.push(&engaged).unwrap(); finished_tx.send(()).unwrap(); }); - started_rx.recv_timeout(Duration::from_secs(30))?; + started_rx.recv_timeout(Duration::from_secs(1))?; assert!( finished_rx .recv_timeout(Duration::from_millis(100)) .is_err() ); - // The writer is still waiting on the gate: the file on disk is untouched. - assert_eq!( - SingleFileMessagePackBackingStore::new(&gate_path).pull_all_read_only_snapshot()?, - vec![gate_released.clone()] - ); Ok(()) })?; - // The writer fsyncs twice once the gate opens; under IO pressure that is slow. - finished_rx.recv_timeout(Duration::from_secs(60))?; + finished_rx.recv_timeout(Duration::from_secs(1))?; assert_eq!(store.pull_all()?[0].payload, b"engaged"); Ok(()) } @@ -4867,715 +4573,4 @@ mod tests { assert_eq!(store.pull_all_read_only_snapshot()?, vec![admitted]); Ok(()) } - - // Shared refusal vectors: tests/vectors/document-variants-c0, read by every runtime's tests. - const ITEM_SCHEMA_ID: &str = "sha256:88d3fdf0a927acf3b163940d8f8c7fe62b3316542ce771a67ec8bc038f594788"; - - fn pull_vector(name: &str) -> Result> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.msgpack"); - let vector = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../../tests/vectors/document-variants-c0") - .join(name); - std::fs::copy(vector, &path)?; - SingleFileMessagePackBackingStore::new(&path).pull_all() - } - - fn refusal(name: &str) -> String { - format!("{:#}", pull_vector(name).unwrap_err()) - } - - #[test] - fn single_file_refuses_unknown_header_by_name() { - assert!(refusal("unknown-header.msgpack").contains("cultcache.store.v9")); - } - - #[test] - fn single_file_refuses_extra_record_slot_naming_the_record() { - let message = refusal("extra-slot-full-payload.msgpack"); - assert!(message.contains("item:anvil"), "{message}"); - assert!(message.contains(ITEM_SCHEMA_ID), "{message}"); - } - - #[test] - fn single_file_refuses_variant_store_by_version_or_record() { - let message = refusal("variant-v2.msgpack"); - assert!( - message.contains("cultcache.store.v2") || message.contains("item:anvil-big"), - "{message}" - ); - } - - // The store the C# runtime wrote through its own variant API (tests/vectors/document-variants-c1). - #[test] - fn single_file_refuses_the_csharp_written_variant_store_by_version_or_record() { - let message = refusal("../document-variants-c1/variant-store.msgpack"); - assert!( - message.contains("cultcache.store.v2") || message.contains("laser-big"), - "{message}" - ); - } - - #[test] - fn v1_store_written_at_the_base_commit_still_reads_byte_for_byte() -> Result<()> { - let envelopes = pull_vector("v1-base.msgpack")?; - let rows: Vec<_> = envelopes.iter().map(|e| (e.key.as_str(), e.r#type.as_str())).collect(); - assert_eq!(rows, vec![("alpha", "vectors.item"), ("beta", "vectors.item")]); - assert_eq!(envelopes[0].payload, b"\x92\xa5alpha\x01"); - assert_eq!(envelopes[1].payload, b"\x92\xa4beta\x02"); - Ok(()) - } - - // Store read and write faults: what a consumer can tell apart, and what a failed - // write leaves on disk. - - fn unreadable_kind(error: &anyhow::Error) -> Option { - error - .downcast_ref::() - .map(|unreadable| unreadable.kind) - } - - fn io_error_in(error: &anyhow::Error) -> Option<&std::io::Error> { - error.chain().find_map(|cause| cause.downcast_ref::()) - } - - /// A store of three records written by this runtime, returned with its bytes. - fn written_store(path: &Path) -> Result<(SingleFileMessagePackBackingStore, Vec)> { - let store = SingleFileMessagePackBackingStore::new(path); - let records = vec![ - snapshot_envelope("alpha", &[1; 64]), - snapshot_envelope("beta", &[2; 64]), - snapshot_envelope("gamma", &[3; 64]), - ]; - assert!(store.compare_exchange_snapshot(&[], &records)?); - let bytes = fs::read(path)?; - Ok((store, bytes)) - } - - #[test] - fn a_truncated_store_is_undecodable_on_every_read_and_is_left_as_it_was() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (store, bytes) = written_store(&path)?; - let truncated = &bytes[..bytes.len() / 2]; - fs::write(&path, truncated)?; - - let failures = [ - store.pull_all().unwrap_err(), - store.pull_all_read_only_snapshot().unwrap_err(), - store - .compare_exchange_snapshot(&[], &[snapshot_envelope("delta", b"4")]) - .unwrap_err(), - ]; - for error in &failures { - assert_eq!(unreadable_kind(error), Some(CultCacheStoreUnreadableKind::Undecodable), "{error:#}"); - assert_eq!(error.downcast_ref::().unwrap().path, path); - assert!(error.to_string().contains(&path.display().to_string()), "{error}"); - assert!(io_error_in(error).is_none(), "{error:#}"); - } - assert_eq!(fs::read(&path)?, truncated); - Ok(()) - } - - #[test] - fn bytes_that_are_not_a_store_are_undecodable() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - // The last opens like a store, with a string where the header goes, but only a - // `cultcache.store.*` header claims a format this runtime might not read. - for bytes in [ - &b"not a store at all"[..], - &[0x92, 0xa3, b'a', b'b'][..], - &[0xc1][..], - &[0x92, 0xa2, b'a', b'b', 0x90][..], - &[0x93, 0xb0, b'c', b'u', b'l', b't', b'c', b'a', b'c', b'h', b'e', b'.', b's', b't', b'o', b'r', b'e', b'X', 0x90, 0x90][..], - ] { - fs::write(&path, bytes)?; - let error = store.pull_all().unwrap_err(); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::Undecodable), "{bytes:?}: {error:#}"); - } - Ok(()) - } - - #[test] - fn a_v1_store_holding_a_record_v1_does_not_allow_is_undecodable() { - let error = pull_vector("extra-slot-full-payload.msgpack").unwrap_err(); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::Undecodable), "{error:#}"); - } - - #[test] - fn a_store_in_a_format_this_runtime_does_not_read_is_unsupported_even_when_cut_short() -> Result<()> { - for name in ["unknown-header.msgpack", "variant-v2.msgpack", "../document-variants-c1/variant-store.msgpack"] { - let error = pull_vector(name).unwrap_err(); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::UnsupportedFormat), "{name}: {error:#}"); - } - - // The header is all this runtime judges: a newer store cut short is still a - // newer store, not a damaged one this runtime could replace. - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.msgpack"); - let vector = fs::read( - Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/vectors/document-variants-c0/unknown-header.msgpack"), - )?; - let truncated = &vector[..vector.len() / 2]; - fs::write(&path, truncated)?; - let store = SingleFileMessagePackBackingStore::new(&path); - for error in [store.pull_all().unwrap_err(), store.pull_all_read_only_snapshot().unwrap_err()] { - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::UnsupportedFormat), "{error:#}"); - assert!(format!("{error:#}").contains("cultcache.store.v9"), "{error:#}"); - assert!(io_error_in(&error).is_none(), "{error:#}"); - } - assert_eq!(fs::read(&path)?, truncated); - Ok(()) - } - - #[test] - fn a_store_that_cannot_be_read_is_an_io_error_and_never_unreadable() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - fs::create_dir(&path)?; - let store = SingleFileMessagePackBackingStore::new(&path); - for error in [store.pull_all().unwrap_err(), store.pull_all_read_only_snapshot().unwrap_err()] { - assert!(io_error_in(&error).is_some(), "{error:#}"); - assert_eq!(unreadable_kind(&error), None, "{error:#}"); - } - Ok(()) - } - - /// Runs one write in a child process whose file-size limit is far below the - /// snapshot, with SIGXFSZ ignored so the write fails with EFBIG instead of - /// killing the child: a real mid-write failure after the staging file exists, - /// reached without permissions (the verification container runs as root). - #[cfg(unix)] - #[test] - fn a_write_that_fails_part_way_leaves_no_staging_file_and_keeps_the_store() -> Result<()> { - const CHILD_STORE: &str = "CULTCACHE_RS_FILE_SIZE_LIMITED_STORE"; - if let Ok(path) = std::env::var(CHILD_STORE) { - let mut store = SingleFileMessagePackBackingStore::new(path); - let error = store - .push(&snapshot_envelope("large", &vec![7; 1 << 20])) - .unwrap_err(); - let io = io_error_in(&error).expect("a size-limited write fails with an io::Error"); - assert_eq!(io.kind(), std::io::ErrorKind::FileTooLarge, "{error:#}"); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::NotReplaced), "{error:#}"); - assert_eq!(unreadable_kind(&error), None, "{error:#}"); - return Ok(()); - } - - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (store, before) = written_store(&path)?; - let child = std::process::Command::new("sh") - .arg("-c") - .arg("trap '' XFSZ; ulimit -f 64; exec \"$0\" --exact --test-threads=1 --quiet tests::a_write_that_fails_part_way_leaves_no_staging_file_and_keeps_the_store") - .arg(std::env::current_exe()?) - .env(CHILD_STORE, &path) - .output()?; - assert!( - child.status.success(), - "the size-limited child did not fail its write as expected: {} -{}{}", - child.status, - String::from_utf8_lossy(&child.stdout), - String::from_utf8_lossy(&child.stderr) - ); - - let staging: Vec<_> = fs::read_dir(temp.path())? - .map(|entry| entry.map(|entry| entry.file_name().to_string_lossy().into_owned())) - .collect::>>()? - .into_iter() - .filter(|name| name.starts_with("store.cc.") && name.ends_with(".tmp")) - .collect(); - assert_eq!(staging, Vec::::new()); - assert_eq!(fs::read(&path)?, before); - assert_eq!(store.pull_all()?.len(), 3); - Ok(()) - } - - /// Every read of a single-file store: the locked pull, the lock-free provider - /// snapshot, and the exchange a writer reads through. - fn every_read(store: &SingleFileMessagePackBackingStore) -> [Result>; 3] { - [ - store.pull_all(), - store.pull_all_read_only_snapshot(), - store - .compare_exchange_snapshot(&[], &[snapshot_envelope("delta", b"4")]) - .map(|_| Vec::new()), - ] - } - - fn assert_io_failure_on_every_read(store: &SingleFileMessagePackBackingStore) { - for result in every_read(store) { - let error = result.expect_err("a store that cannot be reached must not read as empty"); - let io = io_error_in(&error).expect("the failure to reach the store is an io::Error"); - assert_ne!(io.kind(), std::io::ErrorKind::NotFound, "{error:#}"); - assert_eq!(unreadable_kind(&error), None, "{error:#}"); - } - } - - #[test] - fn only_a_missing_store_reads_as_empty() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - assert!(store.pull_all()?.is_empty()); - assert!(store.pull_all_read_only_snapshot()?.is_empty()); - assert!(store.compare_exchange_snapshot(&[], &[snapshot_envelope("delta", b"4")])?); - - // A store whose lock file is gone is still a store, not an absent one. - fs::remove_file(store.lock_path())?; - assert_eq!(store.pull_all()?, vec![snapshot_envelope("delta", b"4")]); - Ok(()) - } - - #[cfg(unix)] - #[test] - fn a_store_behind_a_symlink_loop_is_an_io_error_on_every_read() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - std::os::unix::fs::symlink(&path, &path)?; - assert_io_failure_on_every_read(&SingleFileMessagePackBackingStore::new(&path)); - assert!(fs::symlink_metadata(&path)?.file_type().is_symlink()); - Ok(()) - } - - #[cfg(unix)] - #[test] - fn a_store_under_a_file_instead_of_a_directory_is_an_io_error_on_every_read() -> Result<()> { - let temp = tempfile::tempdir()?; - let parent = temp.path().join("body"); - fs::write(&parent, b"not a directory")?; - assert_io_failure_on_every_read(&SingleFileMessagePackBackingStore::new(parent.join("store.cc"))); - assert_eq!(fs::read(&parent)?, b"not a directory"); - Ok(()) - } - - #[test] - fn an_existing_empty_file_is_undecodable_and_is_left_as_it_was() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - fs::write(&path, b"")?; - let store = SingleFileMessagePackBackingStore::new(&path); - for result in every_read(&store) { - let error = result.expect_err("no CultCache writer leaves an empty file, so it is not a store"); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::Undecodable), "{error:#}"); - assert!(io_error_in(&error).is_none(), "{error:#}"); - } - assert_eq!(fs::read(&path)?, b""); - - // An empty array is the legacy envelope array with no envelopes: it has no - // header, so it claims no format, and it is an empty store. - fs::write(&path, [0x90])?; - assert!(store.pull_all()?.is_empty()); - assert!(store.pull_all_read_only_snapshot()?.is_empty()); - Ok(()) - } - - #[test] - fn a_newer_store_is_named_once_its_header_string_is_complete() -> Result<()> { - let vector = fs::read( - Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/vectors/document-variants-c0/unknown-header.msgpack"), - )?; - // One byte of array header, one of string header, then the 18-byte header string. - let header = "cultcache.store.v9"; - let header_end = 2 + header.len(); - assert_eq!(header_end, 20); - assert_eq!(&vector[2..header_end], header.as_bytes()); - - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - for length in 1..=vector.len() { - fs::write(&path, &vector[..length])?; - let error = store.pull_all().unwrap_err(); - let expected = if length < header_end { - CultCacheStoreUnreadableKind::Undecodable - } else { - CultCacheStoreUnreadableKind::UnsupportedFormat - }; - assert_eq!(unreadable_kind(&error), Some(expected), "cut to {length}: {error:#}"); - } - Ok(()) - } - - #[test] - fn refusals_say_what_was_found_without_blaming_variants() { - let unsupported = format!("{:#}", pull_vector("unknown-header.msgpack").unwrap_err()); - assert!(unsupported.contains("\"cultcache.store.v9\""), "{unsupported}"); - assert!(unsupported.contains("does not read"), "{unsupported}"); - assert!(!unsupported.contains("variant"), "{unsupported}"); - - // The C# reference refuses the same bytes: a v1 store with a longer record is - // not a store any runtime reads, so no upgrade is suggested. - let invalid = format!("{:#}", pull_vector("extra-slot-full-payload.msgpack").unwrap_err()); - assert!(invalid.contains("not a valid store"), "{invalid}"); - assert!(!invalid.contains("variant"), "{invalid}"); - assert!(!invalid.contains("runtime that"), "{invalid}"); - } - - /// The store path is a directory, so the staging file is written and synced and - /// then cannot be renamed over it: a failure after the write, reached without - /// permissions. - #[test] - fn a_write_that_fails_at_the_rename_leaves_no_staging_file() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - fs::create_dir(&path)?; - fs::write(path.join("kept"), b"kept")?; - let mut store = SingleFileMessagePackBackingStore::new(&path); - - let error = store - .push_all(&[snapshot_envelope("alpha", b"1")], PushAllOptions::default()) - .unwrap_err(); - assert!(format!("{error:#}").contains("failed to atomically replace"), "{error:#}"); - - let staging: Vec<_> = fs::read_dir(temp.path())? - .map(|entry| entry.map(|entry| entry.file_name().to_string_lossy().into_owned())) - .collect::>>()? - .into_iter() - .filter(|name| name.starts_with("store.cc.") && name.ends_with(".tmp")) - .collect(); - assert_eq!(staging, Vec::::new()); - assert_eq!(fs::read(path.join("kept"))?, b"kept"); - Ok(()) - } - - /// MessagePack bytes of a fixstr, for store fixtures built by hand. - fn fixstr(text: &str) -> Vec { - assert!(text.len() < 32); - let mut bytes = vec![0xa0 | text.len() as u8]; - bytes.extend_from_slice(text.as_bytes()); - bytes - } - - #[test] - fn a_refusal_never_echoes_a_value_from_the_store() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - - // A v1 store whose catalog holds a string where an entry goes, and a legacy - // envelope array holding a string where an envelope goes: the decoder's own - // message would quote both strings. - let mut v1 = vec![0x93]; - v1.extend(fixstr(STORE_FORMAT_V1)); - v1.push(0x91); - v1.extend(fixstr("SECRET-CATALOG-TEXT")); - v1.push(0x90); - let mut legacy = vec![0x91]; - legacy.extend(fixstr("SECRET-LEGACY-TEXT")); - for bytes in [v1, legacy] { - fs::write(&path, &bytes)?; - for result in every_read(&store) { - let error = result.unwrap_err(); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::Undecodable), "{error:#}"); - assert!(!format!("{error:#}").contains("SECRET"), "{error:#}"); - assert!(!format!("{error:?}").contains("SECRET"), "{error:?}"); - } - } - Ok(()) - } - - #[test] - fn a_header_is_echoed_only_in_the_known_shape() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - for (header, echoed) in [ - ("cultcache.store.v12", true), - ("cultcache.store.SECRET-HEADER", false), - ("cultcache.store.v12SECRET", false), - ("cultcache.store.v", false), - ] { - let mut bytes = vec![0x93]; - bytes.extend(fixstr(header)); - bytes.extend([0x90, 0x90]); - fs::write(&path, &bytes)?; - let error = store.pull_all().unwrap_err(); - let text = format!("{error:#}"); - assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::UnsupportedFormat), "{text}"); - if echoed { - assert!(text.contains(&format!("\"{header}\"")), "{text}"); - } else { - assert!(!text.contains(&format!("\"{header}\"")), "{text}"); - assert!(!text.contains("SECRET"), "{text}"); - assert!(text.contains(&format!("of {} bytes", header.len())), "{text}"); - } - } - Ok(()) - } - - /// Nothing at the store path is an empty store; a symbolic link whose target is - /// gone is something, and a writer must not rename a file over it. - #[cfg(unix)] - #[test] - fn a_dangling_symlink_at_the_store_path_is_an_error_and_nothing_is_written() -> Result<()> { - let temp = tempfile::tempdir()?; - let volume = temp.path().join("volume"); - fs::create_dir(&volume)?; - let target = volume.join("store.cc"); - let path = temp.path().join("store.cc"); - std::os::unix::fs::symlink(&target, &path)?; - let store = SingleFileMessagePackBackingStore::new(&path); - for result in every_read(&store) { - let error = result.expect_err("a dangling link must not read as an empty store"); - assert!(io_error_in(&error).is_some(), "{error:#}"); - assert_eq!(unreadable_kind(&error), None, "{error:#}"); - } - assert!(fs::symlink_metadata(&path)?.file_type().is_symlink()); - assert!(!target.exists()); - assert_eq!(fs::read_dir(&volume)?.count(), 0); - Ok(()) - } - - fn write_failure_kind(error: &anyhow::Error) -> Option { - error - .downcast_ref::() - .map(|failed| failed.kind) - } - - /// Runs `write` with `step` made to fail on this thread. - fn with_write_fault(step: WriteStep, write: impl FnOnce() -> T) -> T { - INJECTED_WRITE_FAULT.with(|fault| fault.set(Some(step))); - let result = write(); - INJECTED_WRITE_FAULT.with(|fault| fault.set(None)); - result - } - - #[test] - fn a_write_that_fails_before_the_rename_is_not_replaced_and_the_store_is_intact() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (store, before) = written_store(&path)?; - let error = with_write_fault(WriteStep::StagingSync, || { - store.compare_exchange_snapshot(&store.pull_all().unwrap(), &[snapshot_envelope("delta", b"4")]) - }) - .unwrap_err(); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::NotReplaced), "{error:#}"); - assert!(io_error_in(&error).is_some(), "{error:#}"); - assert!(error.to_string().contains(&format!("{} was not replaced", path.display())), "{error}"); - assert_eq!(fs::read(&path)?, before); - assert_eq!(fs::read_dir(temp.path())?.count(), 2, "only the store and its lock remain"); - - // The rename fails when the store path is a directory. - let blocked = temp.path().join("blocked.cc"); - fs::create_dir(&blocked)?; - let mut blocked_store = SingleFileMessagePackBackingStore::new(&blocked); - let error = blocked_store - .push_all(&[snapshot_envelope("alpha", b"1")], PushAllOptions::default()) - .unwrap_err(); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::NotReplaced), "{error:#}"); - assert!(fs::metadata(&blocked)?.is_dir()); - Ok(()) - } - - #[cfg(unix)] - #[test] - fn a_write_whose_directory_sync_fails_is_replaced_but_not_durable() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (store, _) = written_store(&path)?; - let replacement = vec![snapshot_envelope("delta", b"4")]; - let error = with_write_fault(WriteStep::DirectorySync, || { - store.compare_exchange_snapshot(&store.pull_all().unwrap(), &replacement) - }) - .unwrap_err(); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::ReplacedNotDurable), "{error:#}"); - assert!(error.to_string().contains(&format!("{} was replaced, but the replacement is not yet durable", path.display())), "{error}"); - assert!(io_error_in(&error).is_some(), "{error:#}"); - assert_eq!(store.pull_all()?, replacement); - Ok(()) - } - - #[test] - fn a_write_failure_names_no_value_from_the_snapshot() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let store = SingleFileMessagePackBackingStore::new(&path); - let error = with_write_fault(WriteStep::StagingSync, || { - store.compare_exchange_snapshot(&[], &[snapshot_envelope("SECRET-KEY", b"SECRET-PAYLOAD")]) - }) - .unwrap_err(); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::NotReplaced), "{error:#}"); - assert!(!format!("{error:#}").contains("SECRET"), "{error:#}"); - Ok(()) - } - - #[test] - fn a_write_that_landed_is_reported_as_landed_when_the_unlock_after_it_fails() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (mut store, _) = written_store(&path)?; - let replacement = vec![snapshot_envelope("delta", b"4")]; - let exchanged = with_write_fault(WriteStep::Unlock, || { - store.compare_exchange_snapshot(&store.pull_all().unwrap(), &replacement) - })?; - assert!(exchanged); - assert_eq!(store.pull_all()?, replacement); - - let pushed = snapshot_envelope("epsilon", b"5"); - with_write_fault(WriteStep::Unlock, || store.push(&pushed))?; - assert!(with_write_fault(WriteStep::Unlock, || store.pull_all())?.contains(&pushed)); - - // The lock was released: another writer takes it at once. - assert!(matches!( - store.try_compare_exchange_snapshot(&store.pull_all()?, &replacement)?, - TryCompareExchangeSnapshotOutcome::Exchanged - )); - - // The keyed store releases its lock the same way. - let mut keyed = RedbMessagePackBackingStore::new(temp.path().join("keyed.redb"))?; - with_write_fault(WriteStep::Unlock, || keyed.push(&pushed))?; - assert_eq!(keyed.pull_all()?, vec![pushed]); - Ok(()) - } - - // What a write does through a symbolic link today. R3 decides whether a write - // resolves the link or refuses it; until then these pin the current behaviour so the - // change is deliberate. Reads refuse a dangling link (see the test above). - #[cfg(unix)] - #[test] - fn r3_decides_resolve_or_refuse_a_push_through_a_live_link_replaces_the_link() -> Result<()> { - let temp = tempfile::tempdir()?; - let volume = temp.path().join("volume"); - fs::create_dir(&volume)?; - let target = volume.join("store.cc"); - SingleFileMessagePackBackingStore::new(&target).push(&snapshot_envelope("a", b"1"))?; - let before = fs::read(&target)?; - let link = temp.path().join("store.cc"); - std::os::unix::fs::symlink(&target, &link)?; - - SingleFileMessagePackBackingStore::new(&link).push(&snapshot_envelope("b", b"2"))?; - assert!(fs::symlink_metadata(&link)?.file_type().is_file(), "the link was replaced by a regular file"); - assert_eq!(fs::read(&target)?, before, "the store the link pointed to is unchanged"); - Ok(()) - } - - #[cfg(unix)] - #[test] - fn r3_decides_resolve_or_refuse_a_push_all_through_a_dangling_link_replaces_the_link() -> Result<()> { - let temp = tempfile::tempdir()?; - let volume = temp.path().join("volume"); - fs::create_dir(&volume)?; - let link = temp.path().join("store.cc"); - std::os::unix::fs::symlink(volume.join("store.cc"), &link)?; - - SingleFileMessagePackBackingStore::new(&link).push_all(&[snapshot_envelope("a", b"1")], PushAllOptions::default())?; - assert!(fs::symlink_metadata(&link)?.file_type().is_file(), "the link was replaced by a regular file"); - assert_eq!(fs::read_dir(&volume)?.count(), 0, "nothing reached the link's volume"); - Ok(()) - } - - #[test] - fn a_keyed_store_refusal_never_echoes_a_stored_value() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("keyed.redb"); - let envelope = snapshot_envelope("k", b"1"); - RedbMessagePackBackingStore::new(&path)?.push(&envelope)?; - { - let database = redb::Database::create(&path)?; - let write = database.begin_write()?; - { - let mut table = write.open_table(REDB_ENVELOPES)?; - let keys: Vec> = table - .iter()? - .map(|row| row.map(|(key, _)| key.value().to_vec())) - .collect::>()?; - let mut value = vec![0xab]; - value.extend_from_slice(b"SECRET-REDB"); - for key in keys { - table.insert(key.as_slice(), value.as_slice())?; - } - } - write.commit()?; - } - let store = RedbMessagePackBackingStore::new(&path)?; - for error in [store.pull_all().unwrap_err(), store.compare_and_swap_entry(&envelope, snapshot_envelope("k", b"2")).unwrap_err()] { - assert!(format!("{error:#}").contains("failed to decode redb CultCache envelope"), "{error:#}"); - assert!(!format!("{error:#}").contains("SECRET"), "{error:#}"); - } - Ok(()) - } - - #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - enum Choice { - Only, - } - - #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - struct SkippedChoice { - #[serde(default, skip_serializing_if = "Option::is_none")] - choice: Option, - text: String, - } - - #[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] - #[cultcache(type = "skipped-choice")] - struct ChoiceNote { - #[cultcache(key = 0)] - value: SkippedChoice, - } - - #[test] - fn a_document_decode_refusal_names_the_entry_and_never_a_stored_value() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - // A compact SkippedChoice with no choice is [text], so decoding it reads the text - // where the enum goes, and serde's own message would quote it as an unknown variant. - let secret = ChoiceNote { - value: SkippedChoice { - choice: None, - text: "SECRET-CHOICE".into(), - }, - }; - let mut payload = vec![0x91, 0x91, 0xad]; - payload.extend_from_slice(b"SECRET-CHOICE"); - let malformed = CultCacheEnvelope { - key: "k".into(), - r#type: ::TYPE.into(), - payload, - stored_at: "2026-09-30T00:00:00Z".into(), - schema_id: None, - }; - SingleFileMessagePackBackingStore::new(&path).push(&malformed)?; - let mut cache = CultCache::new(); - cache.register_entry_type::()?; - cache.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&path))?; - cache.pull_all_backing_stores()?; - - let refusals = [ - ("get", cache.get::("k").unwrap_err()), - ("get_all", cache.get_all::().unwrap_err()), - ("get_all_with_keys", cache.get_all_with_keys::().unwrap_err()), - ("put_envelope", cache.put_envelope::(malformed.clone()).unwrap_err()), - ("prepare_entry", cache.prepare_entry("compact", &secret).unwrap_err()), - ]; - for (path, error) in refusals { - let text = format!("{error:#}"); - assert!(!text.contains("SECRET"), "{path}: {text}"); - assert!(text.contains("CultCache"), "{path}: {text}"); - } - Ok(()) - } - - #[test] - fn a_snapshot_the_store_cannot_hold_is_rejected_before_any_write() -> Result<()> { - let temp = tempfile::tempdir()?; - let path = temp.path().join("store.cc"); - let (store, before) = written_store(&path)?; - let mut first = snapshot_envelope("x", b"1"); - first.schema_id = Some("shared".into()); - let mut second = snapshot_envelope("y", b"2"); - second.r#type = "other".into(); - second.schema_id = Some("shared".into()); - let error = store - .compare_exchange_snapshot(&store.pull_all()?, &[first, second]) - .unwrap_err(); - assert_eq!(write_failure_kind(&error), Some(CultCacheStoreWriteFailedKind::Rejected), "{error:#}"); - assert!(error.to_string().contains("refused a snapshot it cannot store"), "{error}"); - assert!(io_error_in(&error).is_none(), "{error:#}"); - assert_eq!(fs::read(&path)?, before); - Ok(()) - } } diff --git a/packages/cultcache-ts/package.json b/packages/cultcache-ts/package.json index c708bfc9..67f8d5ed 100644 --- a/packages/cultcache-ts/package.json +++ b/packages/cultcache-ts/package.json @@ -45,7 +45,7 @@ }, "homepage": "https://github.com/GameCult/CultLib/tree/main/packages/cultcache-ts#readme", "engines": { - "node": ">=20" + "node": ">=18" }, "dependencies": { "@msgpack/msgpack": "^3.1.3", diff --git a/packages/cultcache-ts/src/cult-cache-inspector.ts b/packages/cultcache-ts/src/cult-cache-inspector.ts index 54e75700..1301fe47 100644 --- a/packages/cultcache-ts/src/cult-cache-inspector.ts +++ b/packages/cultcache-ts/src/cult-cache-inspector.ts @@ -1,7 +1,5 @@ import { decode } from "@msgpack/msgpack"; -import { STORE_FORMAT_VERSION, isV1Snapshot, requireV1RecordSlots } from "./store-format"; - export interface CultCacheInspection { filePath: string; fileSizeBytes: number; @@ -41,6 +39,8 @@ export interface InspectedRecord { payloadDecodeError?: string; } +const STORE_FORMAT_VERSION = "cultcache.store.v1"; + export function inspectCultCacheBytes( filePath: string, bytes: Uint8Array, @@ -197,7 +197,6 @@ function decodeV1Record(value: unknown, catalogBySchemaId: Map { return typeof value === "object" && value !== null; } diff --git a/packages/cultcache-ts/src/single-file-messagepack-backing-store.ts b/packages/cultcache-ts/src/single-file-messagepack-backing-store.ts index b7df1454..4d2bb4f9 100644 --- a/packages/cultcache-ts/src/single-file-messagepack-backing-store.ts +++ b/packages/cultcache-ts/src/single-file-messagepack-backing-store.ts @@ -1,10 +1,9 @@ -import { lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises"; +import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises"; import { dirname, resolve } from "node:path"; import { decode, encode } from "@msgpack/msgpack"; import { z } from "zod"; -import { STORE_FORMAT_VERSION, isV1Snapshot, requireV1RecordSlots } from "./store-format"; import type { CacheBackingStore, CultCacheEnvelope, @@ -13,6 +12,8 @@ import type { PushAllOptions, } from "./types"; +const STORE_FORMAT_VERSION = "cultcache.store.v1"; + const envelopeSchema = z.object({ key: z.string().min(1), type: z.string().min(1), @@ -41,57 +42,64 @@ export class SingleFileMessagePackBackingStore implements CacheBackingStore { } async pullAll(): Promise { - // An empty file is not a store, since no CultCache writer leaves one, so it is - // decoded and refused. Only a read that finds nothing at the path is an empty store. - const data = await readStore(this.filePath); - if (data === undefined) { - return []; - } - - const decoded = decode(data); - const snapshot = decodeSnapshot(decoded); - if (snapshot) { - return snapshot.records.map((record) => { - const catalogEntry = resolveCatalogEntryForRecord(record, snapshot.catalogBySchemaId); - if (!catalogEntry) { - throw new Error(`CultCache persisted record "${record.key}" references missing schema id "${record.schemaId}".`); - } - - return { - key: record.key, - type: catalogEntry.schemaName, - schemaId: record.schemaId, - catalogEntry, - payload: record.payload, - storedAt: record.storedAt, - }; - }); - } - - const legacy = decodeLegacyEnvelopeArray(decoded); - if (legacy) { - let repairedLegacyPayload = false; - const normalized = legacy.map((entry) => { - const payload = normalizePayload(entry.payload); - if (payload !== entry.payload) { - repairedLegacyPayload = true; - } - - return { - ...entry, - payload, - }; - }); - const parsed = envelopeArraySchema.parse(normalized) as CultCacheEnvelope[]; - - if (repairedLegacyPayload) { - await this.#writeAll(parsed); + try { + const data = await readFile(this.filePath); + if (data.length === 0) { + return []; } - return parsed; - } + const decoded = decode(data); + const snapshot = decodeSnapshot(decoded); + if (snapshot) { + return snapshot.records.map((record) => { + const catalogEntry = resolveCatalogEntryForRecord(record, snapshot.catalogBySchemaId); + if (!catalogEntry) { + throw new Error(`CultCache persisted record "${record.key}" references missing schema id "${record.schemaId}".`); + } - throw new Error(`CultCache file ${this.filePath} is not a recognized CultCache MessagePack store.`); + return { + key: record.key, + type: catalogEntry.schemaName, + schemaId: record.schemaId, + catalogEntry, + payload: record.payload, + storedAt: record.storedAt, + }; + }); + } + + const legacy = decodeLegacyEnvelopeArray(decoded); + if (legacy) { + let repairedLegacyPayload = false; + const normalized = legacy.map((entry) => { + const payload = normalizePayload(entry.payload); + if (payload !== entry.payload) { + repairedLegacyPayload = true; + } + + return { + ...entry, + payload, + }; + }); + const parsed = envelopeArraySchema.parse(normalized) as CultCacheEnvelope[]; + + if (repairedLegacyPayload) { + await this.#writeAll(parsed); + } + + return parsed; + } + + throw new Error(`CultCache file ${this.filePath} is not a recognized CultCache MessagePack store.`); + } catch (error) { + const code = (error as NodeJS.ErrnoException).code; + if (code === "ENOENT") { + return []; + } + + throw error; + } } async push(entry: CultCacheEnvelope): Promise { @@ -117,8 +125,16 @@ export class SingleFileMessagePackBackingStore implements CacheBackingStore { async pushAll(entries: CultCacheEnvelope[], options: PushAllOptions = {}): Promise { await this.#enqueue(async () => { - if (options.soft && (await readStore(this.filePath)) !== undefined) { - return; + if (options.soft) { + try { + await readFile(this.filePath); + return; + } catch (error) { + const code = (error as NodeJS.ErrnoException).code; + if (code !== "ENOENT") { + throw error; + } + } } await this.#writeAll(entries); @@ -158,33 +174,6 @@ export class SingleFileMessagePackBackingStore implements CacheBackingStore { } } -/** - * Reads a store file, or returns undefined when nothing is at its path. A dangling symbolic - * link is something: reading it as empty would let the writer rename a file over the link - * and move the store off its volume. Any other failure to reach the file is thrown. - */ -async function readStore(path: string): Promise { - try { - return await readFile(path); - } catch (error) { - if ((error as NodeJS.ErrnoException).code !== "ENOENT") { - throw error; - } - } - - try { - await lstat(path); - } catch (error) { - if ((error as NodeJS.ErrnoException).code === "ENOENT") { - return undefined; - } - - throw error; - } - - throw Object.assign(new Error(`CultCache store ${path} is a symbolic link whose target does not exist.`), { code: "ENOENT" }); -} - async function renameWithRetry(source: string, destination: string): Promise { let delayMs = 10; let lastError: unknown; @@ -296,7 +285,7 @@ function encodeCatalogMember(member: CultCacheSchemaCatalogMember): unknown[] { } function decodeSnapshot(decoded: unknown): DecodedSnapshot | undefined { - if (!isV1Snapshot(decoded)) { + if (!Array.isArray(decoded) || decoded.length === 0 || decoded[0] !== STORE_FORMAT_VERSION) { return undefined; } @@ -447,7 +436,6 @@ function decodeRecord(value: unknown): PersistedRecord { throw new Error("CultCache persisted records must be MessagePack arrays."); } - requireV1RecordSlots(value); const [key = "", schemaId = "", storedAt = "", payload = new Uint8Array()] = value; if (!isNonEmptyString(key) || !isNonEmptyString(schemaId) || !isNonEmptyString(storedAt)) { throw new Error("CultCache persisted records must declare key, schemaId, and storedAt."); diff --git a/packages/cultcache-ts/src/store-format.ts b/packages/cultcache-ts/src/store-format.ts deleted file mode 100644 index 4f579505..00000000 --- a/packages/cultcache-ts/src/store-format.ts +++ /dev/null @@ -1,61 +0,0 @@ -export const STORE_FORMAT_VERSION = "cultcache.store.v1"; - -const STORE_FORMAT_PREFIX = "cultcache.store."; -const PERSISTED_RECORD_SLOTS = 4; - -/** - * True for a v1 snapshot, false for anything that is not a CultCache store header (the legacy - * envelope array). Any other `cultcache.store.*` header is refused by name. - */ -export function isV1Snapshot(decoded: unknown): decoded is unknown[] { - if (!Array.isArray(decoded) || typeof decoded[0] !== "string" || !decoded[0].startsWith(STORE_FORMAT_PREFIX)) { - return false; - } - - if (decoded[0] !== STORE_FORMAT_VERSION) { - throw new Error( - `CultCache store format ${describeHeader(decoded[0])} is not one this runtime reads; it reads "${STORE_FORMAT_VERSION}" only.`, - ); - } - - return true; -} - -/** - * A store header as a refusal may show it: echoed in the shape `cultcache.store.v`, - * and otherwise described only by its length, since the bytes are the store's. - */ -function describeHeader(header: string): string { - return /^cultcache\.store\.v[0-9]+$/u.test(header) - ? `"${header}"` - : `an unrecognised ${STORE_FORMAT_PREFIX}* header of ${new TextEncoder().encode(header).length} bytes`; -} - -/** - * A record key or schema id as a refusal may show it: a string is an identity and is named; - * anything else is described by its type, since the value is the store's. - */ -function describeIdentity(value: unknown): string { - if (typeof value === "string") { - return `"${value}"`; - } - - const kind = Array.isArray(value) - ? "array" - : value instanceof Uint8Array - ? "bytes" - : value === null - ? "nil" - : typeof value; - return `<${kind}>`; -} - -/** Refuses a persisted record with more slots than v1 defines, naming its key and schema id. */ -export function requireV1RecordSlots(record: unknown[]): void { - if (record.length > PERSISTED_RECORD_SLOTS) { - throw new Error( - `CultCache record ${describeIdentity(record[0])} (schema ${describeIdentity(record[1])}) has ${record.length} slots, more than ` + - `the ${PERSISTED_RECORD_SLOTS} of a ${STORE_FORMAT_VERSION} record, so this is not a valid store.`, - ); - } -} diff --git a/packages/cultcache-ts/test/cult-cache.test.ts b/packages/cultcache-ts/test/cult-cache.test.ts index b7c51cc1..5932b2f8 100644 --- a/packages/cultcache-ts/test/cult-cache.test.ts +++ b/packages/cultcache-ts/test/cult-cache.test.ts @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import { exec, execFile } from "node:child_process"; import { EventEmitter } from "node:events"; import { existsSync } from "node:fs"; -import { access, lstat, mkdir, mkdtemp, readdir, readFile, symlink, writeFile } from "node:fs/promises"; +import { access, mkdtemp, readFile, writeFile } from "node:fs/promises"; import { homedir, tmpdir } from "node:os"; import { dirname, join, resolve, delimiter } from "node:path"; import { test } from "node:test"; @@ -1413,178 +1413,3 @@ async function runJsonCommand( return JSON.parse(trimmed.split(/\r?\n/).at(-1) as string); } - -// Shared refusal vectors: tests/vectors/document-variants-c0, read by every runtime's tests. -const variantVectors = resolve(cultLibRoot, "tests", "vectors", "document-variants-c0"); -const itemSchemaId = "sha256:88d3fdf0a927acf3b163940d8f8c7fe62b3316542ce771a67ec8bc038f594788"; - -async function pullVector(name: string): Promise { - const dir = await mkdtemp(join(tmpdir(), "cultcache-vector-")); - const file = join(dir, "store.msgpack"); - await writeFile(file, await readFile(join(variantVectors, name))); - return new SingleFileMessagePackBackingStore(file).pullAll(); -} - -test("SingleFileMessagePackBackingStore refuses an unknown store header by name", async () => { - await assert.rejects(() => pullVector("unknown-header.msgpack"), /cultcache\.store\.v9/u); -}); - -test("SingleFileMessagePackBackingStore refuses an extra record slot naming the record", async () => { - await assert.rejects( - () => pullVector("extra-slot-full-payload.msgpack"), - (error: Error) => error.message.includes("item:anvil") && error.message.includes(itemSchemaId), - ); -}); - -test("SingleFileMessagePackBackingStore refuses a variant store by version or record", async () => { - await assert.rejects( - () => pullVector("variant-v2.msgpack"), - (error: Error) => error.message.includes("cultcache.store.v2") || error.message.includes("item:anvil-big"), - ); -}); - -test("SingleFileMessagePackBackingStore refuses the C#-written variant store by version or record", async () => { - await assert.rejects( - () => pullVector("../document-variants-c1/variant-store.msgpack"), - (error: Error) => error.message.includes("cultcache.store.v2") || error.message.includes("laser-big"), - ); -}); - -test("SingleFileMessagePackBackingStore refusals say what was found without blaming variants", async () => { - await assert.rejects( - () => pullVector("unknown-header.msgpack"), - (error: Error) => error.message.includes("not one this runtime reads") && !error.message.includes("variant"), - ); - await assert.rejects( - () => pullVector("extra-slot-full-payload.msgpack"), - (error: Error) => error.message.includes("not a valid store") && !error.message.includes("variant"), - ); -}); - -test("SingleFileMessagePackBackingStore reads only a missing store as empty", async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-absent-")); - assert.deepEqual(await new SingleFileMessagePackBackingStore(join(dir, "store.cc")).pullAll(), []); - - // An existing empty file is not a store: no CultCache writer leaves one. - const empty = join(dir, "empty.cc"); - await writeFile(empty, new Uint8Array()); - await assert.rejects(() => new SingleFileMessagePackBackingStore(empty).pullAll()); - assert.equal((await readFile(empty)).length, 0); - - // An empty array is the legacy envelope array with no envelopes: no header, no format claimed. - const legacyEmpty = join(dir, "legacy-empty.cc"); - await writeFile(legacyEmpty, Uint8Array.of(0x90)); - assert.deepEqual(await new SingleFileMessagePackBackingStore(legacyEmpty).pullAll(), []); -}); - -test("SingleFileMessagePackBackingStore reports a store it cannot reach as an I/O error", { skip: process.platform === "win32" }, async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-unreachable-")); - const loop = join(dir, "loop.cc"); - await symlink(loop, loop); - const parent = join(dir, "body"); - await writeFile(parent, "not a directory"); - for (const [path, code] of [[loop, "ELOOP"], [join(parent, "store.cc"), "ENOTDIR"]] as const) { - await assert.rejects( - () => new SingleFileMessagePackBackingStore(path).pullAll(), - (error: NodeJS.ErrnoException) => error.code === code, - ); - } -}); - -test("SingleFileMessagePackBackingStore refusals never echo a value from the store", async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-canary-")); - const file = join(dir, "store.cc"); - const cases: Array<[unknown[], boolean | undefined]> = [ - [["cultcache.store.v12", [], []], true], - [["cultcache.store.SECRET-HEADER", [], []], false], - [["cultcache.store.v12SECRET", [], []], false], - [["cultcache.store.v", [], []], false], - [["cultcache.store.v1", ["SECRET-CATALOG-TEXT"], []], undefined], - ]; - for (const [value, echoed] of cases) { - await writeFile(file, encode(value)); - const header = value[0] as string; - await assert.rejects( - () => new SingleFileMessagePackBackingStore(file).pullAll(), - (error: Error) => { - if (echoed) { - return error.message.includes(`"${header}"`); - } - return !error.message.includes("SECRET") - && (echoed === undefined || (!error.message.includes(`"${header}"`) && error.message.includes(`of ${header.length} bytes`))); - }, - ); - } -}); - -test("SingleFileMessagePackBackingStore refuses a dangling symlink at its path and writes nothing", { skip: process.platform === "win32" }, async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-dangling-")); - const volume = join(dir, "volume"); - await mkdir(volume); - const file = join(dir, "store.cc"); - await symlink(join(volume, "store.cc"), file); - const store = new SingleFileMessagePackBackingStore(file); - const envelope = { key: "k", type: "t", payload: Uint8Array.of(0x90), storedAt: "2026-09-30T00:00:00Z" }; - await assert.rejects(() => store.pullAll(), (error: NodeJS.ErrnoException) => error.code === "ENOENT"); - await assert.rejects(() => store.push(envelope), (error: NodeJS.ErrnoException) => error.code === "ENOENT"); - await assert.rejects(() => store.pushAll([envelope], { soft: true }), (error: NodeJS.ErrnoException) => error.code === "ENOENT"); - assert.ok((await lstat(file)).isSymbolicLink()); - assert.deepEqual(await readdir(volume), []); -}); - -test("SingleFileMessagePackBackingStore record refusal names only a string key", async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-record-key-")); - const file = join(dir, "store.cc"); - const secret = new TextEncoder().encode("SECRET-BYTES"); - for (const [key, schema] of [[["SECRET-IN-ARRAY"], "s"], [secret, "s"], ["k", { SECRET: 1 }]] as const) { - await writeFile(file, encode(["cultcache.store.v1", [], [[key, schema, "t", Uint8Array.of(0x90), "extra"]]])); - await assert.rejects( - () => new SingleFileMessagePackBackingStore(file).pullAll(), - (error: Error) => !error.message.includes("SECRET") && !error.message.includes("83,69,67") && error.message.includes("not a valid store"), - ); - } -}); - -// What a write does through a symbolic link today. R3 decides whether a write resolves the link -// or refuses it; these pin the current behaviour so that change is deliberate. -test("R3 decides resolve-or-refuse: a push through a live link replaces the link", { skip: process.platform === "win32" }, async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-live-link-")); - const volume = join(dir, "volume"); - await mkdir(volume); - const target = join(volume, "store.cc"); - const envelope = { key: "a", type: "t", payload: Uint8Array.of(0x90), storedAt: "2026-09-30T00:00:00Z" }; - await new SingleFileMessagePackBackingStore(target).push(envelope); - const before = await readFile(target); - const link = join(dir, "store.cc"); - await symlink(target, link); - await new SingleFileMessagePackBackingStore(link).push({ ...envelope, key: "b" }); - assert.ok((await lstat(link)).isFile()); - assert.deepEqual(await readFile(target), before); -}); - -test("R3 decides resolve-or-refuse: a pushAll through a dangling link replaces the link", { skip: process.platform === "win32" }, async () => { - const dir = await mkdtemp(join(tmpdir(), "cultcache-dangling-push-all-")); - const volume = join(dir, "volume"); - await mkdir(volume); - const link = join(dir, "store.cc"); - await symlink(join(volume, "store.cc"), link); - await new SingleFileMessagePackBackingStore(link).pushAll([{ key: "a", type: "t", payload: Uint8Array.of(0x90), storedAt: "2026-09-30T00:00:00Z" }]); - assert.ok((await lstat(link)).isFile()); - assert.deepEqual(await readdir(volume), []); -}); - -test("CultCache inspector refuses the same vectors by name", async () => { - const inspect = async (name: string) => inspectCultCacheBytes(name, await readFile(join(variantVectors, name))); - await assert.rejects(() => inspect("unknown-header.msgpack"), /cultcache\.store\.v9/u); - await assert.rejects( - () => inspect("extra-slot-full-payload.msgpack"), - (error: Error) => error.message.includes("item:anvil") && error.message.includes(itemSchemaId), - ); -}); - -test("a v1 store written at the base commit still reads byte for byte", async () => { - const envelopes = await pullVector("v1-base.msgpack"); - assert.deepEqual(envelopes.map((entry) => [entry.key, entry.type]), [["alpha", "vectors.item"], ["beta", "vectors.item"]]); - assert.deepEqual([...envelopes[0]!.payload], [0x92, 0xa5, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x01]); - assert.deepEqual([...envelopes[1]!.payload], [0x92, 0xa4, 0x62, 0x65, 0x74, 0x61, 0x02]); -}); diff --git a/packages/cultmath/README.md b/packages/cultmath/README.md index e0dd7179..0be46738 100644 --- a/packages/cultmath/README.md +++ b/packages/cultmath/README.md @@ -26,44 +26,13 @@ shader semantics. acceleration and semi-implicit Euler integration - `math` intrinsics: `radians`, `degrees`, `abs`, `floor`, `ceil`, `frac`, `min`, `max`, `clamp`, `saturate`, `lerp`, `step`, `smoothstep`, `dot`, - `cross`, `length`, `distance`, `normalize`, `reflect`, `csum`, `erf`, - `erfinv` (scalar only), exponential + `cross`, `length`, `distance`, `normalize`, `reflect`, `csum`, exponential `decay`/`damp`, intercept/segment helpers, Catmull-Rom, Bezier curves, and deterministic value-noise primitives - `shaders/CultMath.hlsl`, a canonical HLSL mirror include for shader-side parity. HLSL already owns `float2`, `float3`, and `float4`; the include - exposes `cultmath_*` functions for shared semantics HLSL does not provide. - It includes `shaders/CultMath.Phacelle.hlsl` (MPL-2.0) and - `shaders/CultMath.Interval.hlsl` and `shaders/CultMath.Affine.hlsl` from the same - directory, so ship all four. -- interval arithmetic for culling empty space: `iv_*` functions - over `float2(lo, hi)` (`iv_add`, `iv_mul`, `iv_exp`, `iv_smoothstep`, ...) - and `iv_snoise_ball`/`iv_fbm_ball`, which bound `snoise` and `fbm_grad` over a - ball, and `iv_frustum_ball`, the ball around a screen tile's rays over a depth - segment, so one probe serves the whole tile (its radius carries its own - float32 rounding bound). The arithmetic functions return an interval built to - contain the function's value over their operand intervals, so a raymarch - can skip a segment whose `hi` is below its cutoff; `cultmath_iv_*` in HLSL. - The noise functions rest on empirical constants with a margin, not a proof: - `iv_snoise_ball(float3)` on `SNOISE_LIPSCHITZ` (`iv_fbm_ball` through it), - `iv_snoise_ball(float2)` on `SNOISE2_LIPSCHITZ`, and `af_snoise` on - `SNOISE_HESSIAN` and `SNOISE_LIPSCHITZ` (`af_fbm` through it); the enclosure - tests sample them. `iv_frustum_ball` and `af_frustum_ball` read no noise - constant: the ball is geometry plus a rounding widening, and the noise call - it feeds carries the constant. - The bounds compose with a consumer's own analytic envelope (a height fog, a - carved sphere): its interval over the segment proves empty space in one probe, - and the noise ball is consulted only near the surface. See `docs/design.md`, - "Intervals". -- `shaders/CultMath.glsl` (MIT), the same `cultmath_*` library in GLSL ES 3.00 - for WebGL2, generated from `CultMath.hlsl` (never edited by hand), and - `shaders/CultMath.Phacelle.glsl` (MPL-2.0), generated from - `CultMath.Phacelle.hlsl`, which holds `cultmath_phacelle` alone. GLSL has no - `#include`: a WebGL consumer concatenates `CultMath.glsl` after its own - `#version 300 es` line and `precision highp float; precision highp int;` - (the library declares no precision, and its hashes need 32-bit integers), - then `CultMath.Phacelle.glsl` only if it calls `cultmath_phacelle`, then its - own shader source. + exposes `cultmath_*` functions for shared semantics, including CultMath's + safe `normalize` contract. - `Voronoi.SampleTones`, a C# batch surface that calls the Rust `cultmath-core` native kernel when `cultmath_core` is available and falls back to the managed parity path otherwise. @@ -90,7 +59,7 @@ float grain = math.value_noise_bicubic(math.float2(12.0f, 3.5f)); ```hlsl #include "CultMath.hlsl" -float3 normal = normalize(float3(0.25, 1.0, -0.1)); +float3 normal = cultmath_normalize(float3(0.25, 1.0, -0.1)); float rim = cultmath_saturate(1.0 - dot(normal, float3(0.0, 0.0, -1.0))); float glow = cultmath_smoothstep(0.2, 1.0, rim); float grain = cultmath_value_noise_bicubic(float2(12.0, 3.5)); @@ -129,12 +98,6 @@ The repository root is not a Unity package. Build the tracked package with assembly and rejects stale binaries, missing metadata, unexpected assemblies, or leaked C# source. -Before tagging `cultmath-unity-v*`, run the import and dispatch smoke on a Windows machine with a GPU, -alone: `packages/cultmath/scripts/unity-smoke/run-unity-smoke.ps1 -UnityExe `. It -builds a scratch project outside the repository that references the package by a `file:` path, -dispatches a compute shader that includes `CultMath.Interval.hlsl` and `CultMath.Affine.hlsl`, requires -a deliberately broken control shader to be rejected, and deletes the project afterwards. - ## Shader Tooling CultMath keeps portable DXC outside git under `packages/cultmath/.tools/`: diff --git a/packages/cultmath/THIRD-PARTY-NOTICES.md b/packages/cultmath/THIRD-PARTY-NOTICES.md index b0d2f4c1..06ebb6c3 100644 --- a/packages/cultmath/THIRD-PARTY-NOTICES.md +++ b/packages/cultmath/THIRD-PARTY-NOTICES.md @@ -6,40 +6,6 @@ simplex-noise functions by Ian McEwan and Ashima Arts, as distributed by Stefan Gustavson's `webgl-noise` project and Unity Mathematics. -`math.snoise(float3)` and `cultmath_snoise(float3)` follow `src/noise3D.glsl` and -`math.snoise(float2)` follows `src/noise2D.glsl` of stegu/webgl-noise at commit -`22434e04d7753f7e949e8d724ab3da2864c17a0f` (the simplex-boundary fix is -`21d9fe23d7`, scale `ff3b5d34ea`, permutation `a3e6d57095`). Modified from upstream: -the 3D corner tie order follows Gustavson's `simplexnoise1234`, because the -upstream `step` compares are cyclic where the offset's components are equal. - -`math.snoise_grad`/`cultmath_snoise_grad` (and the `fbm_grad`/`ridged_grad` -octave sums built on them) follow the analytic-gradient differentiation from -the same project's `src/noise3Dgrad.glsl`, with the same kernel radius, -permutation and scale as `snoise(float3)`. - - Copyright 2011 Ashima Arts. - Upstream: - License: MIT. - -## Phacelle Noise - -`math.phacelle` and `cultmath_phacelle` follow Rune Skovbo Johansen's Phacelle -noise (Shadertoy `t3dyWl`; erosion filter `wXcfWn`; blog, March 2026), read -from the C# port `PhacelleNoise` in `lpmitchell/AdvancedTerrainErosion` -(`AdvancedTerrainErosion.cs`, converted to burstable C# by Luke Mitchell, -2026). The cell weight, the phase blend and the normalization follow it. The -3D-cell generalisation, the caller-supplied stripe wave vector, the exact -gradient and the exact pruning are new here. - -- Copyright (c) 2025 Rune Skovbo Johansen. -- Upstream: -- License: MPL-2.0 (). MPL-2.0 is file-level, so it - covers exactly the files that carry the port and nothing else: - `src/CultMath/math.Phacelle.cs`, `src/CultMath/CultPhasor.cs`, - `shaders/CultMath.Phacelle.hlsl` and the Unity copy of that include, and - `shaders/CultMath.Phacelle.glsl`, which is generated from that include. Each - carries the MPL-2.0 header and this attribution. The rest of CultMath, the - generated GLSL library included, is MIT, so the `GameCult.Math` NuGet - package and the `org.gamecult.cultmath` Unity package both declare - `MIT AND MPL-2.0` and ship this file. diff --git a/packages/cultmath/docs/design.md b/packages/cultmath/docs/design.md index a3c1519f..de09ee26 100644 --- a/packages/cultmath/docs/design.md +++ b/packages/cultmath/docs/design.md @@ -52,26 +52,7 @@ That makes these HLSL rules, not options: operand returns the other (so `saturate(NaN)` is 0), `clamp(x, a, b)` is `min(max(x, a), b)`, and `saturate(x)` is `min(1, max(0, x))`, which maps -0 to +0; `any`/`all` accept numeric vectors (a component is true when it is - not 0); `min`, `max`, and `abs` on int vectors return int vectors; int - `clamp` is `IMin(IMax(x, a), b)`, so inverted bounds return `b`. -- Same-size vector conversions (`intN(floatN)`, `floatN(intN)`, `boolN(floatN)`, - `boolN(intN)`, `floatN(boolN)`, `intN(boolN)`) exist as constructors and - `math` functions and follow dxc: float to int is `fptosi`, truncating toward - zero; numeric to bool is `!= 0` (`fcmp une`, so NaN is true); bool to numeric - is 0 or 1. DXIL leaves float-to-int undefined for NaN and out-of-range values, - and so does C#; CultMath does not pin them. -- `normalize(x)` is `x * Rsqrt(Dot(x, x))`, which is how dxc lowers it, and - DXIL.rst defines `Rsqrt` as `1 / sqrt(src)`. A zero vector therefore - normalizes to NaN (`0 * inf`), and a NaN component makes every component NaN. - (The special-value table under `Rsqrt` in DXIL.rst is a copy of the `Round` - table and contradicts that definition, so CultMath follows the definition.) - `length` and `distance` are `Sqrt` of the summed squares, so a zero vector - gives 0. Callers that can meet zero-length vectors guard them before calling - `normalize`. -- dxc demotes double `frac`, `exp`, `lerp`, and `floor` to float. CultMath's - double overloads keep double precision instead: `frac(double)` is - `x - floor(x)` in double. That is a deliberate divergence for CPU simulation - time, which shaders do not carry. + not 0); `min`, `max`, and `abs` on int vectors return int vectors. dxc marks float arithmetic and compares `fast` (no NaNs) unless a value is `precise`, so drivers may optimize NaN handling away and NaN results on real @@ -83,7 +64,9 @@ GPU. Because `min`, `max`, and `saturate` return the non-NaN operand, some functions turn NaN or infinity into numbers: `smoothstep(a, a, a)` is 0; infinite inputs to `smoothstep` and the intercept helpers give numbers; the bezier, `smoothstep01`, and `smootherstep` functions return finite values for -NaN input. Callers that must detect bad data should check `isnan` before calling these +NaN input; and `normalize((NaN, 2.41))` is `(NaN, 2.41e20)`, because the NaN +length is clamped to the epsilon and the other component is divided by it. +Callers that must detect bad data should check `isnan` before calling these functions. Deferred until a consumer needs them: `float4x4`, `transpose`, `determinant`, @@ -100,10 +83,7 @@ needs anything else, the test fails: no CultMath analog. 3. File-scope `static const` becomes `const`. 4. Floating literals gain `f` (`0.5` becomes `0.5f`). -5. Struct fields gain `public`. HLSL struct members have no access-modifier - concept; a C# struct's fields default to `private`, which would hide them - from the mirror test's reflection-based field comparison. -6. The file body is wrapped in a class, since C# has no free functions; HLSL +5. The file body is wrapped in a class, since C# has no free functions; HLSL functions become private instance methods. HLSL constructs that stay outside the target and must not appear in the mirror: @@ -123,347 +103,9 @@ compiled under `using static CultMath.math;`, so its intrinsics are C# `math` itself: the test proves the composition in the text, not the intrinsic rules, which only `HlslSemanticsTests` pins. -The comparison also allows exactly one struct return shape: a mirror function -whose HLSL return type is a plain struct of `float`/`floatN`/`int`/`intN` -fields is compared to its C# counterpart field by field, recursing into each -field's own components, down to bit-for-bit scalars, matching each leaf's -declaration path (field names, not just position) and declared type as well -as its value. `CultCellular` (`math.cs`, `cellular`) and `CultPhasor` -(`math.Phacelle.cs`, `phacelle`) are its consumers. A struct return with a mismatched, reordered-by-name, or -retyped field does not get a second comparison path or a shape of its own; -it fails the same walk that already handles a bare vector return. - -### GLSL Target: Source Transformations - -`shaders/CultMath.glsl` is a GLSL ES 3.00 (WebGL2) library generated from -`shaders/CultMath.hlsl` by `GlslLowering` (in the test project), and -`shaders/CultMath.Phacelle.glsl` is generated beside it from -`shaders/CultMath.Phacelle.hlsl`. Both are derived files: never edit them by -hand. Regenerate them, and the golden fixture -`tests/CultMath.Tests/fixtures/glsl-parity.json`, with: - -```powershell -$env:CULTMATH_WRITE_GLSL = "1"; dotnet test packages/cultmath/tests/CultMath.Tests --filter GlslMirrorTests -``` - -`GlslMirrorTests.CommittedGlslEqualsLowering` fails on any difference between -either committed file and the lowering of the committed HLSL. These -transformations, in order, are the complete list: - -1. Each `#include "name"` is replaced in place by the included file, by the - same resolver the C# mirror uses; GLSL has no `#include`. The exception is - an include under a file-level licence of its own, listed in one table, - `GlslLowering.SeparateFiles`: its line is dropped and the file is lowered on - its own, by the same steps, into its own output. The table has one entry, - `CultMath.Phacelle.hlsl` to `CultMath.Phacelle.glsl`, because Phacelle is - MPL-2.0 and MPL-2.0 is file-level: kept separate, it leaves - `CultMath.glsl` MIT. Nothing else in the lowering is keyed by name. -2. Include guards are dropped, and so are the functions taking - `Texture2D`/`SamplerState`; the host shader samples its own textures. -3. Type names: `floatN`, `intN`, `uintN` and `boolN` become `vecN`, `ivecN`, - `uvecN` and `bvecN`. -4. File-scope `static const` becomes `const`. -5. C-style casts `(float)x`, `(int)x` and `(uint)x` become `float(x)`, `int(x)` - and `uint(x)`. The operand is found by a balanced-bracket scanner: - `(int)((state >> 28) + 4u)` nests parentheses. -6. Intrinsics are renamed: `lerp` to `mix`, `frac` to `fract`, `rsqrt` to - `inversesqrt`, `asuint` to `floatBitsToUint`, `asfloat` to - `uintBitsToFloat`, and `saturate(x)` becomes `clamp(x, 0.0, 1.0)`. -7. Float literals pass through unchanged. -8. Each output is wrapped in a guard named for its file: `CULTMATH_GLSL`, - `CULTMATH_PHACELLE_GLSL`. -9. The first line names the file as generated, its sources and its licence, - and says how to regenerate it; `CultMath.glsl`'s also says which - functions live in the separate file. - -GLSL ES 3.00 is stricter than HLSL: no implicit conversions between int, uint -and float, no C-style casts, and no `step(genType, float)` overload. Those gaps -are closed in the HLSL, never in the lowering: the HLSL is written in the subset -both languages share, with edits that are legal HLSL and compute the same bits -(`step(h, float4(0.0, 0.0, 0.0, 0.0))` rather than `step(h, 0.0)`, `+ 4u` where -a uint is added, `(float)((uint)hash.x >> 8)` before a float multiply). The C# -mirror and the FXC and dxc compiles keep those edits honest. A body that needs a -transformation outside the list fails `GlslMirrorTests.NoHlslOnlyTokensSurvive` -rather than gaining a special case. - -The library declares no precision. The host shader does, and it must be -`precision highp float; precision highp int;`: the PCG hashes need 32-bit -integers. `tools/compile-glsl.ps1` writes such a wrapper (its own `#version -300 es` line, the precision, the library by string concatenation, and one call -of every public function) and compiles it with glslang, which -`tools/get-glslang.ps1` fetches pinned. It runs twice: over `CultMath.glsl` -alone, and with `-Phacelle` over `CultMath.glsl` followed by -`CultMath.Phacelle.glsl`, the order a consumer that calls `cultmath_phacelle` -concatenates them in. Two negative controls must fail: `-Body` with an HLSL -token (`float x = lerp(0.0, 1.0, 0.5);`), and `-Body` calling -`cultmath_phacelle` without `-Phacelle`, which proves the MIT file does not -carry it. The Unity package ships neither GLSL file. - -Parity runs in two legs, each with one owner: HLSL against C# by the mirror -test, bit for bit; GLSL against C# by the golden fixture, which records 256 -seeded cases per function family as float32 bit patterns, evaluated by the -consumer on WebGL2 and read back. The families `pcg3d` and `pcg4d` are marked -exact; the float families are ulp-bounded, the bound measured on the device. - -`iv_frustum_ball` is ulp-bounded, not exact: it calls `sqrt`, which GLSL ES -3.00 does not require to be correctly rounded, and WebGL2 compilers may -reassociate. On a GTX 1070 under ANGLE's D3D11 backend its radius differs from -C# by up to 2 ulp in 43 of 256 cases, sometimes smaller. What the march needs -is enclosure, and what culling needs is a ball no wider than its rounding -widening, so the family's fixture entry carries a `check` the consumer applies -to every case: from the case's arguments `(mx, my, z0, z1, fp, warp)`, compute -in double `zm = (z0 + z1) / 2`, the centre `c = (mx zm, my zm, zm)`, its -`|c|_1 = |mx zm| + |my zm| + |zm|`, the radius -`r = (z1 - z0) / 2 sqrt(mx^2 + my^2 + 1) + z1 fp + warp` and -`d = |GPU centre - c|`, and require -`r + d <= GPU radius <= r + d + 2^-19 (r + |c|_1)`. The lower side is -enclosure; the upper side is the bound `NoiseBoundTests` pins in C#, so a -lowering that inflates the ball fails too. Only those two bounds fail the -check; the largest ulp distance is reported as for any ulp-bounded family. -`GoldenFixtureMatchesCSharp` applies the same check to C#'s own results. - -Every `af_*` function is an ulp-bounded family, and `af_snoise`, `af_fbm` and `af_frustum_ball` also carry a two-sided `check` -of their own, applied the same way: the device's own `snoise` or fBm at 75 sampled points of the case's set must lie in the device's -form with no tolerance (a device whose gradient error exceeds the allowance fails), its width must not pass the Lipschitz form's -allowance, and the device's `af_frustum_ball` radius must enclose the sampled ray points and stay within its rounding widening. -The reference is the device's own noise, which is right for culling soundness but would pass a device whose noise is wrong -everywhere, so two appended families (`af_snoise` and `af_fbm`, 256 cases each) add the centre leg: the fixture's own `x0` -(C#'s value at the centre) must lie in the device form's `[x0 - e, x0 + e]`, for every `af_snoise` and `af_fbm` family. They -also draw reach `|axis| + radius` from 1e-6 to 1e-3, the short slices near a camera, where the float32 allowance is most of `e`: -the main families' reach is at least about 1e-3, where the second-order remainder is far larger and a device that drops the -allowance still passes. `GoldenFixtureMatchesCSharp` requires each of the two to hold cases that fail on C#'s own results once -the allowance is removed. - -`GoldenFixtureMatchesCSharp` evaluates C# on the committed fixture's own -arguments. Arguments are drawn only when the fixture is regenerated -(`CULTMATH_WRITE_GLSL=1`), because the draw itself calls `MathF.Pow`, whose -bits differ by OS. `iv_exp` and `phacelle` take their C# results from the -platform's `exp`, `sin` and `cos`, which also differ by OS, so their entries -name the platform that generated them and the test compares them case by case -against the running platform, printing the largest distance. `iv_exp` -("ulp-bounded, platform exp") must agree within one ulp. `phacelle` -("ulp-bounded, platform exp, sin, cos; across platforms |diff| <= 2^-20 -max(|v|, 1)") must agree within `2^-20 max(|v|, 1)` per component, `v` being -the fixture's value: its sums of `exp`, `sin` and `cos` cancel near zero, where -ulps mean nothing, and Windows differs from the Linux fixture by up to -`3.6e-7 max(|v|, 1)`. Every other family is compared as text. `phacelle` is in -`CultMath.Phacelle.glsl`, so the evaluator concatenates -`CultMath.Phacelle.glsl` after `CultMath.glsl` for that family, with -normalization 0.5. The site does not vendor the MPL file and skips the family. -Its evaluator is the cultmath-tapes follow-up `glsl-browser-parity-run`, owned -by the next CultMath parity cut: a repeatable CultLib WebGL2 run of every -fixture family, `phacelle` included. Until it lands, the one GLSL evaluation of -`phacelle` is a single probe (GTX 1070, ANGLE D3D11: within `3.1e-6 max(|v|, 1)` -of C#). Asura's `gpu-snoise-parity` is a different check, an FXC and Unity -readback of `snoise`, and evaluates no GLSL. - -## Invariant 8: Value-and-Gradient Primitives - -A primitive tagged invariant 8 returns its value and analytic gradient -together, laid out as `float4(gradient.xyz, value.w)`, with no value-only twin -(a value-only form would be a second path with no consumer). `smin_grad` and -`cellular` are the first primitives in this family: - -- `smin_grad(float4 a, float4 b, float k)` is Inigo Quilez's quadratic-polynomial - smooth minimum ("smooth minimum", - ), carried to value-and-gradient - form. Its blend factor `h` is affine in `b.w - a.w`, so differentiating the - value with respect to position, the terms carrying `dh/dp` cancel exactly; - the surviving gradient is `lerp(∇b, ∇a, h)`, the same `h` the value uses. - This is the analytic gradient, not an approximation, and it is continuous - across the `|a.w - b.w| = k` seam where `h` saturates to 0 or 1. -- `cellular(float3 p)` is Worley's cellular texture basis function ("A - Cellular Texture Basis Function", SIGGRAPH 1996), searched over the - jittered 5×5×5 neighbourhood of feature points selected by `pcg3d` (never - the sin-based `hash`), with cells whose position-only lower bound already - exceeds the running F2 skipped before their hash is even computed. It - returns `CultCellular { nearest, edge, id }`: `nearest` is `(∇F1, F1)`, - `edge` is `(∇F2 - ∇F1, F2 - F1)`, and `id` is the nearest cell's `pcg4d` - hash (over the cell coordinate alone, never the `pcg3d` hash that produced - its jitter) mapped to `[0, 1)`. `∇F1` and `∇F2` are each undefined exactly - at their own feature point (`F1 = 0` or `F2 = 0`); `cellular` follows the - repo's existing degenerate-normal convention - (`GameCult.Geometry.CultGeometryIsoSurface.EmitOrientedTriangle`, which - guards a zero-length normal and returns the zero vector instead of the NaN - a bare `normalize` gives there) and returns the zero vector rather than NaN - for either. `F1 = 0` is ordinary (`p` sits on a feature point); `F2 = 0` - needs two distinct cells' `pcg3d`-jittered feature points to land on the - same float32 value in every component, which is unreachable at ordinary - magnitudes but confirmed reachable (see "Precision domain" below). The - identity of the nearest and second-nearest feature point changes - discontinuously across the `F1 = F2` set (a genuine kink, not a numerical - artifact), so `∇F1` and `∇F2` are only continuous away from that set. - - The 5×5×5 radius is exact, not merely safer than the classic 3×3×3 radius: - for a query at position `u` inside its own cell (`u` in `[0, 1)^3` per - component) and a candidate feature at integer cell offset `d` with jitter - `j` in `[0, 1)^3`, the per-axis displacement `(u_i - j_i) - d_i` is always - strictly greater in magnitude than `max(0, |d_i| - 1)`, because - `u_i - j_i` is always strictly inside `(-1, 1)`. So any cell with `|d_i| >= - 3` on some axis is strictly farther than 2 from the query. Two real, - always-present candidates bound `F1` and `F2`: the query's own cell, whose - distance is always strictly less than `sqrt(3)` (every axis strictly under - 1); and the near-side neighbour on whichever single axis has `u_i` closest - to a cell boundary. Let `m = min(u_i, 1 - u_i)` on that chosen axis, so - `m` is in `[0, 1/2]` by construction. Stepping one cell towards that - nearer boundary puts the query within `1 + m` of the far face on the - offset axis and within `1 - m` of the near face on each of the other two - axes, so that neighbour's squared distance is at most - `(1 + m)^2 + 2*(1 - m)^2 = 3 - 2m + 3m^2 <= 3` for every `m` in `[0, 1/2]` - (3 at `m = 0`, dipping to a minimum of `8/3 ~= 2.667` at `m = 1/3`, then - rising back to 2.75 at `m = 1/2`), and strictly below 3 because - the jitter never reaches exactly 0 or 1. `F2` is at most the larger of - these two real candidates (any two real candidates upper-bound the - 2nd-smallest value over the full infinite candidate set), so `F1 < - sqrt(3)` and `F2 < sqrt(3)` always, comfortably under the radius-2 - exclusion distance of 2, with margin `2 - sqrt(3) ~= 0.268` (Soul's - adversarial check, cut 2a-i: the worst realizable in-box `F2` is exactly - `sqrt(3)`, reached only in the unattainable limit at a cell corner). 3×3×3's - matching argument only reaches radius 1, whose excluded cells start at - distance 1, short of the `sqrt(3)` ceiling — the gap its measured failures - (9 of 400,000 points in `[-50, 50]^3`, worst error 0.088) live in. - - An earlier version of this proof picked the near-side neighbour on a fixed - axis instead of whichever axis sits closest to its own boundary, and that - version is wrong (Soul, cut 2a-i): `u = (0.5, 0, 0)` with the x-neighbour's - jittered feature at `(-1, 1 - 2^-24, 1 - 2^-24)` gives a distance of about - 2.06, outside the radius-2 exclusion the proof needs — `u.x = 0.5` is the - point on the cell farthest from any boundary, so `x` was the wrong axis to - fix there. Choosing the axis by proximity to its own boundary is what keeps - `m <= 1/2` and the bound at `sqrt(3)`. - - `CellularAndSminGradTests` pins both the prune's bit-identical equivalence - to an unpruned 5×5×5 reference and the search's exact agreement with an - independent 7×7×7 brute-force oracle. - - Precision domain: `cellular`'s exactness above is a statement about the - search radius, not about float32. Past `|p|` of roughly `2^23`, adjacent - integer cells stop being distinguishable from their neighbours at float32 - precision in some directions, and distinct cells' jittered features can - round onto the same value, making `F1 = F2` ties (and, per-component, - `F2 = 0`) increasingly common from about `1e6` and confirmed at `2^24` - (measured: 4096 of 4096 sampled integer points at `2^24` hit this before - the guard above). `cellular` stays finite there; it does not stay accurate - in the sense of matching the idealized real-valued Worley field. - - The lower-bound prune's bit-identity to the unpruned 5×5×5 search also has - a domain: it holds for `|p| < 2^25`. Above that, `cell + d` (an integer - cell coordinate plus a small integer offset) starts to round in float32, - so a pruned cell's own recomputed offset can land on a different neighbour - than the unpruned loop visits at that same nominal `(dx, dy, dz)`, and the - two search paths diverge (Soul, cut 2a-i: measured 180 of 1,100,000 points - differ at `|p| ~= 3.4e7`). This is a float32-precision limit on the prune's - equivalence proof, not a bug in the prune itself: below `2^25` the two - paths are proven bit-identical (`PrunedSearchIsBitIdenticalToTheUnprunedFiveCubedSearch`, - which samples `[-50, 50]^3`, is comfortably inside that domain). - -- `snoise(float3)` follows webgl-noise `src/noise3D.glsl` as of - stegu/webgl-noise `22434e04d7`: kernel radius squared `0.5`, output scale - `105`, permutation `mod289((34x+10)x)`. Upstream's `21d9fe23d7` (2020-10-14, - "an age-old bug that caused slight discontinuities along simplex - boundaries") moved the radius from `0.6` to `0.5`; at `0.6` a lattice vertex - outside the four summed corners can lie inside the kernel, leaving a value - jump at the cell boundary (3.1e-3 over the committed probe's 400 lines). `ff3b5d34ea` set the scale - to `105` and `a3e6d57095` (2021-06-30) the permutation; the 2D `snoise` shares - that permutation helper, so its values changed too, while its own kernel - (`0.5`) and scale (`130`) already matched upstream. - `NoiseGradTests.SnoiseAndItsGradientAreContinuousAcrossSimplexCellBoundaries` - pins the continuity. Ties in the offset `x0` resolve in Gustavson's - `simplexnoise1234` order (x over y, y over z, x over z), a total order, so the - four corners are always a simplex. Upstream's `step` compares are cyclic: where - the three components are equal, which is every input whose differences `y - x` - and `z - x` are whole numbers (every integer point, the origin and every - `(t, t, t)` among them), the corners repeat the origin vertex and the value - jumps by about 0.77 near the origin and up to 1.56 at magnitudes of 64 and - above. `SnoiseTieScopeTests` pins the set against the 0.3.0 values. `NoiseGradTests.SnoiseIsContinuousOnTheSimplexDiagonal` pins the order. -- `snoise_grad(float3 p)` carries `snoise(float3)` to value-and-gradient form, - following the differentiation in webgl-noise `src/noise3Dgrad.glsl` (Ashima - Arts / Ian McEwan, MIT), which uses the same radius, permutation and scale as - `snoise(float3)`: per corner, `m0 = max(0.5 - dot(x,x), 0)`, so - `d(m0^4 * dot(p,x))/dx = -8*m0^3*dot(p,x)*x + m0^4*p`, summed over the four - corners and scaled by the same constant as the value, so `.w` is exactly - `snoise(float3)`. `fbm_grad` and - `ridged_grad` are octave sums of `snoise_grad`: each octave samples at - `p * frequency`, so by the chain rule its gradient scales by that same - frequency, and both amplitude (`gain`) and frequency (`lacunarity`) compound - per octave rather than applying once to the whole sum. `ridged_grad` folds - each octave about zero (`Σ aᵢ(1 − |nᵢ|)`, gradient `−Σ aᵢfᵢ sign(nᵢ)∇nᵢ`, - Musgrave's ridged multifractal, *Texturing and Modeling* ch. 16); the crease - at `nᵢ = 0` is deliberate (the operator's dune term, 2026-09-25), not a bug. - Both clamp `octaves` to `[0, 16]`: `HlslSourceCompatibilityTests`'s bit-parity - oracle drives every mirrored `int` parameter across the full int32 range, - which is the right domain for `pcg3d`/`pcg4d`'s O(1) hash inputs but would - turn an unclamped octave count into a multi-billion-iteration loop for these - two mirrors. -- `phacelle(float3 p, float3 side, float offset, float normalization)` is Rune - Skovbo Johansen's Phacelle noise ("phase + cell": a stripe pattern built by - blending one cosine/sine wave per jittered cell), generalised to 3D cells. It - returns `CultPhasor { cos, sin }`, each `(∇, value)`. `side` is the stripe - wave vector, whose length is 2π times the stripe frequency; in 3D the - perpendicular to the flow is not unique, so the caller chooses it (on a unit - sphere, `cross(p̂, flow)`). `offset` is the phase in cycles. It visits 4×4×4 - cells with `pcg3d`-hashed jitter in `[-0.5, 0.5)`, weights each wave by - `max(0, exp(-2d²) - 0.01111)`, and normalizes the blended phasor as upstream - does (length 1 where the raw length is at least `1 - normalization`, scaled - by `1 / (1 - normalization)` below). The gradient is exact, weight - derivatives and normalization included, rather than upstream's - `∇cos ≈ -sin·side`, which ignores the weight gradient. It is discontinuous - where the raw length crosses the normalization threshold and where a cell's - weight leaves its support (d² = 2.24995, distance 1.49998); the value is - continuous at both. At the support edge `∇w` jumps from `-4·0.01111·v` to 0, - a per-cell jump of length `0.0444·|v|` (0.0667 at `|v| = 1.5`); measured over - random points, the output gradient jumps by a median 1.5% of its length and - at most about 27%. `normalization` is meant to lie in `[0, 1]`: 1 or more - saturates (every output is stretched to length 1), a negative value scales - every output down by `1 / (1 - normalization)`, and the normalized gradient - scales as `1 / |I|` for the blended phasor `I`, so it grows where the blend - nearly cancels. The total weight `W` is positive for every `pcg3d` input (the - smallest found by hill-climbing is 0.056); `W = 0`, and a NaN output, needs - adversarial jitter no hash yields. - Cells whose per-axis lower bound `Σ max(0, |local - g| - 0.5)²` is at least - 2.25 lie outside the support and have weight exactly 0, so they are skipped, - which changes no output bit. Cells whose bound sits just under 2.25 can still - carry a nonzero weight, so the cut cannot be lowered; `PhacelleTests` pins - the cut with points next to such cells, against an internal overload with the - prune disabled, and the HLSL mirror test pins it on the shader side. The prune - keeps about 45 of the 64 cells on average (a saving of about 30%); about 14 - have a nonzero weight. The port sits in its own MPL-2.0 files - (`math.Phacelle.cs`, `CultPhasor.cs`, `CultMath.Phacelle.hlsl`); see - `THIRD-PARTY-NOTICES.md`. No 2D variant exists; nothing consumes one. - -Integer hashing uses the PCG hashes from Jarzynski and Olano, "Hash Functions -for GPU Rendering" (JCGT 9(3), 2020): `pcg(uint)` is O'Neill's RXS-M-XS 32/32 -permutation over one LCG step, and `pcg3d`/`pcg4d` are the paper's (3 → 3) and -(4 → 4) hashes. They use only uint multiply, add, xor, and shifts. dxc wraps -uint multiply and add modulo 2^32 exactly as C# unchecked arithmetic does, so -they are integer-exact in HLSL and on the CPU, GPU included, unlike the -`sin`-based `hash`. CultMath has no uint vectors, so `pcg3d(int3)` and -`pcg4d(int4)` carry uint bit patterns in int components. The `float2`/`float3`/`float4` -overloads hash the IEEE-754 bits (`asuint`), so -0 and 0 hash differently; they -exist for callers that already hold a hash key as float bits, and `pcg3d(float2)` -holds z at 0, which is the paper's route for (2 → N) inputs. Seeds and other -scalar uses take one output component. - -`cellular`'s jitter and id always hash the integer cell coordinate directly -(`pcg3d(int3(neighbor))`, `pcg4d(int4(int3(cellId), 0))`), never a cell -coordinate's float32 bit pattern. Hashing the bit pattern of an -integer-valued float is not the same permutation as hashing the integer: two -adjacent cells' bit patterns share more structure (both have the same -exponent and a mantissa that differs by one increment) than two adjacent -integers do going into `pcg3d`'s own mixing, and that residual structure -survived into the jitter. Hashing the integer cell coordinate directly is -exact and runtime-independent, and it is the HLSL mirror's own hash, so C# -and shader agree bit-for-bit. What pins this is the oracle and mirror tests, -not a uniformity measurement: reverting to hashing the float bits (or the -sin-based hash) is caught by `ProductionSearchMatchesTheBruteForceOracleExactly`, -`EveryMirrorFunctionMatchesCSharpMath`, `F1NeverExceedsF2`, and the other -tests that key off the integer-hash fixtures (cut 2a-i). `CellularAndSminGradTests` -(`JitterAndIdPassAChiSquareUniformityTest`) checks the uniformity of the hash -as `cellular` uses it: the jitter marginals and the id pass a chi-square test -at a stated significance against `pcg3d(int3(...))`. - Where HLSL is silent, CultMath keeps its own decisions and does not defer to -Unity.Mathematics: `hash` returns float, and `Random` is CultMath's own xorshift32. Engine-shaped +Unity.Mathematics: `normalize` is safe (divides by `max(length, 1e-20)`), +`hash` returns float, and `Random` is CultMath's own xorshift32. Engine-shaped helpers that HLSL lacks (`float2x2.Rotate`, `float3x3.Euler`, `quaternion`, `snoise`) enter only when a consumer needs them, with their semantics stated in code. @@ -472,368 +114,6 @@ Known C# friction: under `using static CultMath.math;` the constructor functions (`float3(...)`, `float3x3(...)`) hide the type names in member access, so static members need a qualified type (`CultMath.float3x3.Euler(...)`). -## Intervals - -`math.Interval.cs` and `shaders/CultMath.Interval.hlsl` (included from -`CultMath.hlsl` after the Phacelle include) carry interval arithmetic for -culling empty space with a proof. Their invariant, **intervals-enclose**: every -interval function returns a `[lo, hi]` that contains `f(x)` for every `x` in -its input region, where `f(x)` is the same function evaluated pointwise in -float32. A consumer that skips a region because `hi < cutoff` has skipped -nothing that was there. - -Representation: an interval is `float2(lo, hi)` with `lo <= hi`, both finite. -There is no empty interval; a caller that needs "provably empty" tests -`hi < cutoff`. `iv_point(x)` is `float2(x, x)`. - -Ops: `iv_point`, `iv_add`, `iv_sub`, `iv_neg`, `iv_mul` (the least and greatest -of the four corner products), `iv_scale(iv, float)`, `iv_abs` and `iv_sqr` -(an interval straddling zero starts at 0), `iv_min`, `iv_max`, `iv_sqrt` -(`lo` clamped at 0), `iv_exp`, `iv_clamp(iv, float, float)`, `iv_saturate`, -`iv_smoothstep(float, float, iv)` (its ordered endpoints) and -`iv_lerp(iv, iv, float)`. No others until a consumer names one. Each has an -HLSL mirror named `cultmath_iv_*`, compared bit for bit by -`HlslSourceCompatibilityTests`. - -The ulp-widening rule. Each bound is computed with the pointwise function's -own float32 operations. IEEE round-to-nearest is monotone, so an op that is -monotone on its region encloses its float32 evaluation exactly, with no -widening; that covers every op above except two, which widen by exactly one -ulp, in the implementation and never in the test: - -- `iv_exp`: `exp` is not required to be correctly rounded, so a libm need not - be monotone. .NET's `MathF.Exp` on Linux steps down 0 times over every float - in [-87, 88.7] (`IntervalTests.MeasureMonotonicity`), so on that CPU the - widening is a margin; it is there for other libms and GPUs. -- `iv_smoothstep`: `t * t * (3 - 2t)` in float32 steps down 337,095 times over - the floats in [0, 1], each time by at most 1 ulp (`MeasureMonotonicity`). - Since `t = saturate((x - minimum) / (maximum - minimum))` is itself monotone - in `x`, that covers every `smoothstep`. - -`iv_lerp` is the natural interval extension of `x + (y - x) * amount`, which is -how `lerp` evaluates; every step is monotone, so it encloses with no widening -for any `amount`, and it is tight only when `a` is a point, because `x` appears -twice. - -`IntervalTests` runs every op over 10,000 seeded intervals (centres in -[-20, 20], widths log-uniform in [1e-4, 10], every eighth a point) and 16 -points inside each, endpoints and zero included, with no tolerance; and for -every op it raises `lo` and lowers `hi` by one ulp and requires the harness to -catch each. A new op is one entry in that table. - -Noise bounds. `iv_snoise_ball(c, r)` is `[n - L r, n + L r]` intersected with -`[-1, 1]`, where `n = snoise(c)` and `L = SNOISE_LIPSCHITZ`: one `snoise`, value -only. No interval function reads `snoise_grad`, and none has a value-only or -gradient twin. `iv_fbm_ball(c, r, octaves, lacunarity, gain)` is the octave sum -of `iv_snoise_ball(c * f_i, r * |f_i|)` scaled by `a_i`, compounding frequency -and amplitude exactly as `fbm_grad` does, octaves clamped to [0, 16]. A domain -warp that moves a point by at most `D` is enclosed by the radius `r + D` -(`NoiseBoundTests.WarpedPointsStayEnclosed`); this is what the gamecult.org -ground's march rests on. - -`iv_frustum_ball(m_c, z0, z1, footprintPerDepth, warp)` is the ball one probe -serves a whole screen tile with. In a pinhole camera frame looking down `+z`, -where the ray of slope `m` is the points `(m z, z)`, it encloses every point of -every ray whose slope lies within `footprintPerDepth` of `m_c` (`N / (sqrt(2) f)` -for an `N x N` tile at focal length `f` pixels: the full pixel footprint, so -sub-pixel jitter is covered), over depths `[z0, z1]`, each point moved by a warp -of length at most `warp`. The centre is `(m_c z_m, z_m)`, `z_m` the mid-depth; -the radius is `((z1 - z0) / 2) |(m_c, 1)| + z1 footprintPerDepth + warp`. A point -of slope `m_c + e` at depth `z` is the centre plus `(z - z_m)(m_c, 1)` plus -`z (e, 0)`. The returned ball is float32, and on a degenerate (`z0 == z1`), -thin or far segment the rounding of the centre alone exceeds the gap the -triangle inequality leaves, so the radius is widened by -`(|c|_1 + radius) 2^-20`. With `u = 2^-24`, each centre component carries at most -two roundings (`z_m`, then the product), so the float centre is within -`2u |c|_1` of the exact one; the radius carries at most seven (`z1 - z0`, the -axis length at `3u`, the product, `z1 footprintPerDepth`, the sum, `+ warp`), so -the exact radius is at most `(1 + 7u)` times the float one; the widening rounds -once more. `2^-20 = 16u` covers `8u (|c|_1 + radius)` twice over, and fma -contraction only removes roundings. The axis count assumes a correctly rounded -`sqrt`, which IEEE gives C#. GLSL ES 3.00 does not: it inherits `sqrt`'s -precision from `inversesqrt`, and D3D-backed compilers may reassociate. So the -bound is proven for C# and HLSL on IEEE hardware, and on GLSL it is measured: -on a GTX 1070 under ANGLE's D3D11 backend the fixture's 256 cases keep a -minimum relative slack of `1.98e-6` (about `33u`), the same as C#'s. The -fixture's enclosure check is what measures it on each device. The caller rotates and translates the centre into world space and scales -centre and radius by its noise frequency; the rounding of that transform is the -caller's. `NoiseBoundTests.TileBallEnclosesEveryRaySegment` checks 2,000 seeded -tiles x 64 points of the r2 domain and 2,000 tiles x 8 corner points of each of -seven extreme families (`z0 == z1`, `z1 - z0 = 1e-6 z1`, `|m_c|` to 1000, `z` to -`1e7`, `z0 = 0` with `z1` to `1e-3`, `f` down to 1, warp to `1e6`), corner flows -full-length and outward, distances in double, with no tolerance. It pins the ball -to the derivation both ways (`r <= ball.w <= r + 2^-19 (r + |c|_1)`), so a ball -that forgets the widening fails and one grown past it fails too. A moving camera needs nothing -more: each frame's probes use that frame's camera, and no ball, mask or probe -result is carried from one frame to the next. - -The noise ball alone proves little: at `L` near 10 it bounds `snoise` to a width -of `2 L r`, which covers all of `[-1, 1]` once `L r` reaches 1. Empty space -becomes provable through an analytic envelope. The consumer's density is a -pre-distortion SDF (a height fog, a well map, a carved sphere) that noise -displaces only near its surface, and the consumer composes the bound from `iv_*` -ops. The envelope is taken over the slice's exact box (`iv_mul` of the depth -range by each slope range, then the SDF's own monotone pieces), together with its -fade. The noise is `iv_snoise_ball` over `iv_frustum_ball`, scaled by the noise -frequency. The warp moves only the noise argument, so it enlarges the ball and -the envelope's box takes none of it. Where the fade's upper end is 0 the noise -term is identically 0 and no `snoise` is evaluated. Where the envelope already -proves the slice empty with the noise at its full range, the ball is not -evaluated either. A probe is worth attempting only when the best result any -centre value could give would prove the slice, and a ball with `L r >= 2` is -`[-1, 1]` whatever `snoise(c)` is, so it costs nothing. CultMath owns none of the -envelope: the interval files have no envelope function, and each consumer composes -its own. `NoiseBoundTests.EnvelopeBoundEnclosesDensity` checks that composition, -the one the site and Aetheria use, over 2,000 seeded slices x 64 warped points -with no tolerance. - -`L` has provenance, not a proof. `NoiseBoundTests.MeasureLipschitz` (slow, -explicit) takes the largest `|snoise_grad|` over 1e6 seeded points in -[-256, 256]^3 (7.1933103), refines the 1e4 largest by gradient ascent -(7.2400064), and multiplies by 1.10: `L = 7.9640074`. It also reaches -`|snoise| = 0.9718335` by the same ascent on the value, which is what lets the -bound intersect with `[-1, 1]`. `LipschitzConstantPinsSampledGradients` -checks 1e5 more seeded points against `L` and climbs again from the start -`MeasureLipschitz` prints as its witness, failing if `L` is not 1.10 times that -maximum to within half a percent, so a 1% move of `L` fails. The enclosure tests -over 2,000 balls x 64 points are the defence. A change to the `snoise` kernel -must re-run `MeasureLipschitz` and re-pin `L` and the witness. - -What the ball bounds guarantee: enclosure of `snoise` and `fbm_grad(...).w` over -the ball, in float32. What they do not: anything about tapes, pruning or choice tracking. Correlation -between the operands of one expression is what "Affine forms" below adds. -How loose the ball bounds are is a number: -`NoiseBoundTests.TightnessReport` prints the mean interval width over the -sampled range: 5.08 for `iv_snoise_ball` at `r = 0.05`, 1.96 at 0.25 and 1.28 -at 1.0; 6.64 and 2.82 for 4-octave `iv_fbm_ball` at 0.05 and 0.25. - -The saving is measured where there is empty space to find. -`NoiseBoundTests.IntervalSkipHalvesEvaluations` draws screen tiles, each with -its own camera, and runs one pre-pass per tile over the dense grid's cell ranges: -it starts with the whole grid, skips and doubles a range it proves empty, halves -one it cannot, and runs to the grid's end. It then draws the tile's `N^2` ray -slopes, one per pixel, jittered inside it. Each ray is marched three times with -the same integrator and the same early-out at transmittance 0.02: over every -cell (dense), over the tile's unproven cells (the tile march), and over the -oracle mask, the cells whose mid-depth density is nonzero for at least one of -the tile's rays. The tile march and the oracle march integrate the dense march's -nonzero cells, so their transmittance agrees with it exactly in every -configuration. The oracle is a ceiling the pre-pass cannot move: dense cost over -oracle cost. Against it the test prints the efficiency (oracle cost over the -tile march's cost with its probes) and the cull fraction (the oracle-empty cells -the pre-pass proves empty). The probe overhead is the tile march's cost over that -cost plus the probes'. Cost is counted in `snoise` evaluations, with an envelope -evaluation or probe weighted 0.2. That weight is an estimate, and both counts are -printed. The flow is not counted. At `N = 8`, in Aetheria's units on its -256-cell quadratic grid out to the Main Camera's far plane, 2048: - -- (a) Height fog, camera above the safety band, rays level and up: the whole - grid is one envelope probe per tile, against 256 envelope evaluations per ray, - 16384x. Every cell is oracle-empty and the pre-pass proves them all. -- (b) Inside the fog: 1.16x, and 1.11x with the warp. Most cells are fog, and - the pre-pass probes each one. -- (c) The deep well (ruling `wells-scale-order-of-magnitude`): the zone bowl - plus one well at its centre, `PowerPulse` exponent 2, scale 2220, depth 600. - The band `G = 60` is where only the noise decides density (`s` within - `F -+ 1.5 A` with the fade at 1); depth and half-depth radius are each - `10 G`. The camera's `xz` is uniform within 300 of the centre, at - `y = F - h(xz) / 2`, so it looks across the bowl from inside it. Both rows run - on the same seeds. With no warp, the centred interval takes 3.20x (oracle - ceiling 5.24x, efficiency 0.611, cull fraction 0.988, probe overhead 0.940) - and the affine bound 3.57x (efficiency 0.682, cull 0.993, overhead 0.905). With - the warp `D = 60`: 3.12x (ceiling 5.31x, efficiency 0.588, cull 0.987, overhead - 0.929) against 3.46x (efficiency 0.651, cull 0.993, overhead 0.880), so affine - is 1.12x and 1.11x cheaper. The range mask (the oracle cells plus every cell - where any of 5 x 5 slopes x 9 depths has density above zero) gives a range - ceiling of 0.859 (0.848 with the warp), the cost a bound that proves exactly - the range-empty cells would reach against the oracle's; the efficiencies - against it are 0.794 and 0.712 (warp 0), 0.768 and 0.694 (warp `D`). -- (c-band) The shallow wells, four mass-derived wells in the zone bowl with - the camera gazing across, whose geometry is band-dominated, printed only. - Centred interval 3.01x (efficiency 0.414, cull 0.960, overhead 0.958), affine - 3.95x (0.544, 0.980, 0.901); with the warp 2.75x (0.383, 0.954, 0.944) against - 3.54x (0.494, 0.976, 0.865). -- (d) r1's uniform slab, which has no envelope: 1.38x with the warp 0.05, and - 1.67x with no warp. -- (e) The void at the shipped point (ruling `operator-shipped-void`): `Rh = 198`, - `S = 50`, `Rc = Rh + S = 248`, `e = -ln 1.5 / ln(1 - (Rh / Rc)^2)`, the - shipped camera, 200 tiles. The fixed-step reference takes 36.34 steps per - pixel. The same cells masked by the pre-pass take 20.08, with identical - transmittance. The footprint-aware march takes 13.50: 2.69x fewer. `snoise` - per pixel goes from 32.98 to 26.70, and combined cost from 40.25 to 29.54 with - the probes, 1.36x. Every one of the 200 tiles proves a body. Before the body - both marches are measured against a converged one (midpoint quadrature at - `h = 0.5` over every cell, trusting no pre-pass): the relative optical-depth - error at the body start is at most 0.0608 for the fixed-step march and 0.08639 - for the footprint march, 1.42x. Over the grid of hollow radius, camera offset - and ramp width the steps ratio runs from 1.59x (`Rh = 100`, low, `S = 150`) to - 27.45x (`Rh = 1000`, centred, `S = 10`), the cost ratio from 1.26x to 3.89x, - and the depth-error ratio from 0.85 to 4.72 (`Rh = 200`, centred, `S = 150`, - where the errors are 0.01504 and 0.003188). LOD-far takes 14.19x fewer steps; - its depth errors, 0.2849 and 0.205, are not comparable, because its - fixed-step reference keeps the octaves the footprint march truncates. - -The analytic body (ruling `operator-analytic-wall-body`). When a single dense -cell's own bound is a positive point, the pre-pass spends one more probe over -the rest of the grid. If that bound is a positive point too, every point of -every ray of the tile from there on has exactly that density, so the footprint -march takes one closed-form step, `exp(-BodyDepth)`, from the body start to the -grid's end and stops. `BodyDepth` is density x extinction x length x `|dir|`. -`NoiseBoundTests.AnalyticBodyMatchesFineMarch` pins it: the bound, the mask and -the pointwise densities agree exactly at the body, and `BodyDepth` equals the -summed fixed-step depth of the body cells within 1e-4 relative. The comparison -is in the depth domain, so LOD-far's deep bodies do not underflow. - -The footprint-truncated void weights its octaves by `w_i(z)`, decreasing in `z`. -Its bound takes each weight over `[w_i(z1), 1]` rather than -`[w_i(z1), w_i(z0)]`, because one bound serves both the full field (`w = 1`) and -the truncated one. `[w_i(z1), 1]` contains both, and `iv_mul` is monotone in its -interval argument, so the composed interval encloses both fields. -`NoiseBoundTests.WeightBoundEnclosesOneSignedNoise` checks it on LOD-far over -2,000 segments: each weight lies in its bound, and `w(z) n` lies in -`iv_mul(bound, n)` for a one-signed `n`. A lower end of `w(z0)` fails it. - -The contracts, at `N = 8`, the lower of warp 0 and `D`: - -- (a) at least 2x combined cost; -- (c) on the deep well (rulings `affine-wells-contract-cheaper-than-interval` - and `wells-overhead-plus-floor`): the affine bound's combined cost ratio is - above the centred interval's at warp 0 and at warp `D`; and, hard, the - pre-pass proves at least half of the oracle-empty cells empty under both - bounds, so a pre-pass that skips nothing fails. The probe overhead, the - efficiencies against the oracle and the range ceiling, the ceilings and the - cull fraction are printed, not asserted; (c-band) is printed only; -- (e) at the shipped void: the masked fixed-step march agrees with the reference - exactly; the footprint march's optical depth at the body start is off the - converged march's by at most twice the fixed-step march's error; and it takes - at most half the reference's steps per pixel. - -This run meets every contract: (a) 16384x, (c) affine 3.57x and 3.46x against -the centred interval's 3.20x and 3.12x, with a cull fraction of 0.987 at the -lowest, (e) 2.69x fewer steps and a depth error 1.42x the fixed-step march's. -The fields, the grids, the 0.2 envelope weight and the 2.0 gradient weight are -not tuned toward the contracts. An affine probe is one `snoise_grad`, counted at -2.0 `snoise` evaluations (an estimate, printed beside the count). - -Consumers: the gamecult.org ground shader (through the GLSL lowering) and -Aetheria's nebula raymarch at its CultMath pin bump. - -## Affine forms - -`math.Affine.cs` carries reduced affine forms with one shared symbol: a -`float3(x0, a, e)` is the set `x0 + a eps + e delta` with `eps` and `delta` in -`[-1, 1]` and `e >= 0` (Messine's AF1, as Gamito and Maddock use it for gradient -noise, in one register as an interval is a `float2`). `eps` is shared by every -form over one region (for a screen-tile slice, the depth parameter, `z = z_m + -h eps`), so `af_sub(x, x)` has `a = 0`; `delta` is private to the form, and -every term that cannot be tracked is condensed into `e`. A slice is a -`float4(centre, radius)` with a `float3` axis. No op takes a compound type, a -reference parameter or a swizzle write, so each mirrors into the HLSL common -subset. - -The ops: `af_point`, `af_symbol`, `af_from_iv`, `af_range` (the bridge back to -`iv_*`), `af_add`, `af_sub`, `af_neg`, `af_scale`, `af_add_iv`, `af_mul` (the -product `|a_x a_y|` and the cross-error terms condensed into `e`, so there is -no `af_sqr`), `af_snoise` and `af_fbm`, and the slice pair `af_frustum_axis` and -`af_frustum_ball`. - -Rounding. Every op returns a form whose set at each `eps` contains the float32 -value of its function at every point of its operands' sets at that `eps`. Each -op folds its own float32 rounding into `e` as `S 2^-20`, `S` the sum of the -magnitudes its roundings are relative to (named in the op's comment): at most -`8u S` is needed with `u = 2^-24`, and the factor of two over that is the -allowance for a device whose `+` and `*` are faithful rather than correctly -rounded. `AffineTests.EveryOpEnclosesItsPoints` evaluates the form's set in -double and the function in float32 with no tolerance. Products and `af_from_iv` also -add `2^-126`, the most an underflow to a subnormal can lose (`TinyOperandsEncloseTheirPoints`). -`af_from_iv` halves its endpoints before it sums and differences them, and `af_range` -scales its terms before it sums them, so endpoints near the float maximum do not overflow -in the middle of the op; a form that overflows anyway gives `af_range` infinite endpoints, -never NaN (`FromIntervalAndRangeHoldAtTheExtremes`). `af_range` finds a NaN endpoint by its bit pattern, because -`lo == lo` is a compare dxc marks `fast` and deletes under its default flags. `AbsorptionsArePinned` and -`SnoiseFormCarriesItsDocumentedWidth` pin each absorption and `af_snoise`'s float32 allowance both -ways: the enclosure tests alone cannot see them on a CPU, where float32 is exact. - -`af_snoise(centre, axis, radius)` encloses `snoise` over `centre + axis eps + w`, -`|w| <= radius`, from one `snoise_grad`. It returns the narrower of the -Lipschitz form `(n, 0, L R)` and the centred form `(n, g . axis, |g| radius + -M R^2 / 2)` (`R = |axis| + radius`, `L = SNOISE_LIPSCHITZ`, `M = -SNOISE_HESSIAN`), so its total width is never more than the Lipschitz form's. -The centred form is Taylor's theorem, which is why it beats the ball when the -radius is small and the axis carries the variation. `af_fbm` compounds octaves -as `iv_fbm_ball` does. The float32 evaluation allowance is derived in -`af_snoise`'s comment. - -`SNOISE_HESSIAN = 56.050385` is 1.10 times the refined maximum of the spectral -norm of the Hessian of `snoise(float3)`, measured by -`NoiseBoundTests.MeasureHessian` over 1e6 seeded points (central differences of -`snoise_grad`) and refined by ascent from the 1e4 largest: sampled 50.1366, -refined 50.9549, witness (-245.19885, -53.01323, -91.47363). -`HessianConstantPinsSampledCurvature` fails on a 1% move. -`SNOISE2_LIPSCHITZ = 8.117002` is the same for the gradient of `snoise(float2)` -(`MeasureLipschitz2`: sampled 7.2575, refined 7.3791, witness (-67.12454, --129.53296), `|snoise2|` at most 0.99964), and it backs `iv_snoise_ball(float2, -float)`. Both are empirical with a margin, not proofs. A random ball cannot see a -curvature constant 20% low, so `SNOISE_HESSIAN` is defended by -`HessianConstantPinsSampledCurvature` and `SnoiseFormEnclosesTheCurvatureWitness` -(`af_snoise` at the point where the curvature is realised, along 4,000 directions: a -constant of 40 misses there). The margin over the function itself: a scan of the whole -289^3 hash period found a realised maximum of 50.58, and bounding each corner's gradient -independently over every hash configuration gives 52.22, so 56.05 sits 7% above the -configuration bound. A change to the kernels must re-run the measurements. - -The slice. `af_frustum_ball(centreSlope, z0, z1, footprintPerDepth, -warpVariation)` returns the centre `(m_c z_m, z_m)` and a radius `z1 -footprintPerDepth + warpVariation`, with `af_frustum_axis` the axis `(m_c, 1) h`: -every ray point at depth `z` is `centre + axis eps(z) + w`. Its derivation -and the clamp residual are in the comment. The caller rotates, translates and -scales the slice into the noise's frame, and owns the rounding of that. - -The centred warp. A flow-warped sample reads `snoise` at `p + flow(p) shift`. The -caller does not enlarge the ball by the whole displacement `|flow| shift`; it -moves the centre by the flow at the centre, `c + flow(c) shift`, and widens the -radius by the flow's variation across the ball, `r + |shift| rho` with `rho = -FlowAmplitude (SNOISE2_LIPSCHITZ FlowFrequency r + a) sqrt 2` (the clamp to the unit -disc is nonexpansive), where `a = 2^-14 + L2 2^-20 (|q|_1 + r FlowFrequency)` is the -float32 allowance of the flow's two `snoise(float2)` reads (the point `q` plus its offset rounds at the -magnitude of `q`, and a float32 flow at two points of a ball differs by more than the exact -function can). CultMath owns neither the flow nor the envelope: the warp's -centre and variation are the caller's, and a consumer adds them to the slice's -`warpVariation` or to the form's radius. With two phases that cross-fade, each -phase takes its own centre; one ball serves when the phases' centres coincide -(warp 0). `NoiseBoundTests.CentredWarpStaysEnclosed` checks 2,000 balls, radius 1e-3 to -500, and fails when `rho` is dropped or halved; `AffineWarpStaysEnclosed` checks -3,000 tile slices of `FogField.Slice`, which returns the final `af_snoise` arguments -(each phase's moved centre and grown radius, the detail's unwarped set, the shared axis), -so the affine bound wires nothing itself: the reach over which the flow is varied is -`|axis| + radius`, each phase carries its own growth, and the gate reads each argument's -reach. It fails when the reach is the ball's radius or the larger of the two, a phase's -growth is dropped or taken from the other phase, the axis or the detail radius is scaled, -or `rho` is halved. `AffineCompositionTightensItsRanges` sees the shared-symbol -composition itself: the bound is exactly the intersection of the affine arithmetic's piece -and the interval composition over the forms' ranges, and the affine piece is the narrower -of the two in at least 35% of the open slices (the piece alone is wider in total). - -The deep well is the representative Aetheria case: the camera inside a sun's -bowl, looking across. `DeepWellIsTenBandsDeepAndWide` computes the band `G` from -`FogField`'s own floor offset, amplitude and noise range (60) and requires the -depth (633 at the centre against the rim) and the half-depth radius to be at -least `10 G`, every drawn camera sitting inside the well below the rim; a well of -depth 150 fails. The shallow wells stay as the printed shallow-well, band-dominated row (c-band). - -The test field's affine bound takes depth as `af_symbol(z_m, h)`, builds `s` -affine in it with the height interval, the footprint and the slope-depth -product in `e` through `af_add_iv`, takes the noise through `af_frustum_*` and -`af_snoise` per phase and for the detail octave, fades by `af_from_iv` and -`af_mul`, reads the range with `af_range`, and intersects with the centred -interval's bound (both sound). `FogField.Bound` makes no direct `snoise` call. -The cull-map render (`DeepWellCullMap`, explicit) writes a PNG when -`CULTMATH_WRITE_CULLMAP` names a directory: one deep-well camera at warp `D`, -960 x 540 in 8 x 8 tiles, with panels for dense cells per ray under the centred -interval, under the affine bound and under the oracle mask (one logarithmic -scale) and the transmittance. Its run: 4.23, 3.60 and 2.02 cells per ray on -average, 44 the most, mean transmittance 0.278. - ## Rules - Keep type names HLSL-shaped: `float2`, `float3`, `float4`, `float3x3`, and `math`. diff --git a/packages/cultmath/scripts/build-unity-package.ps1 b/packages/cultmath/scripts/build-unity-package.ps1 index f232d6eb..b64e9446 100644 --- a/packages/cultmath/scripts/build-unity-package.ps1 +++ b/packages/cultmath/scripts/build-unity-package.ps1 @@ -41,27 +41,6 @@ foreach ($path in @($freshAssembly, $freshSymbols)) { } } -# docs/semver-policy.md (CultLib root, two levels up from this script): refuse a release whose version -# does not tell the truth. The check measures the freshly built CultMath.dll's public API against the -# DLL the previous cultmath-unity tag tracked (read from git), so it runs once the build exists. -# cultmath is pre-1.0 (0.y.z): a break must be at least a minor bump. $repoRoot above is this package's -# own root (packages\cultmath), not CultLib's; the shared checker script lives one level above that. -$cultLibRoot = Split-Path -Parent (Split-Path -Parent $repoRoot) -$cultmathVersion = (Get-Content -LiteralPath (Join-Path $templateRoot "package.json") -Raw | ConvertFrom-Json).version -# The suite pins the checker's rules and the declared tag prefixes, so it runs first. -& node --test (Join-Path $cultLibRoot "scripts\check-changelog-semver.test.mjs") -if ($LASTEXITCODE -ne 0) { - throw "The release check suite failed (scripts/check-changelog-semver.test.mjs); not releasing." -} -& node (Join-Path $cultLibRoot "scripts\check-changelog-semver.mjs") ` - --package "org.gamecult.cultmath" ` - --version $cultmathVersion ` - --cwd $cultLibRoot ` - --api-built $freshAssembly -if ($LASTEXITCODE -ne 0) { - throw "CultMath Unity package failed the semver policy check (see docs/semver-policy.md)." -} - $requiredTemplateFiles = @( "LICENSE.md", "LICENSE.md.meta", @@ -80,13 +59,7 @@ $requiredTemplateFiles = @( "Runtime\UnityBridge\UnityConversions.cs", "Runtime\UnityBridge\UnityConversions.cs.meta", "Shaders\CultMath.hlsl", - "Shaders\CultMath.hlsl.meta", - "Shaders\CultMath.Phacelle.hlsl", - "Shaders\CultMath.Phacelle.hlsl.meta", - "Shaders\CultMath.Interval.hlsl", - "Shaders\CultMath.Interval.hlsl.meta", - "Shaders\CultMath.Affine.hlsl", - "Shaders\CultMath.Affine.hlsl.meta" + "Shaders\CultMath.hlsl.meta" ) foreach ($relativePath in $requiredTemplateFiles) { if (-not (Test-Path -LiteralPath (Join-Path $templateRoot $relativePath) -PathType Leaf)) { diff --git a/packages/cultmath/scripts/unity-smoke/Broken.compute b/packages/cultmath/scripts/unity-smoke/Broken.compute deleted file mode 100644 index 2d7b11c1..00000000 --- a/packages/cultmath/scripts/unity-smoke/Broken.compute +++ /dev/null @@ -1,11 +0,0 @@ -#pragma kernel CSMain -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.hlsl" -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl" -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl" -RWStructuredBuffer Out; -[numthreads(1,1,1)] void CSMain(uint3 id : SV_DispatchThreadID) -{ - float2 r = cultmath_iv_add_missing(float2(1, 2), float2(3, 5)); - float2 a = cultmath_af_range(cultmath_af_add(cultmath_af_point(3), cultmath_af_point(5))); - Out[0] = float4(r, a); -} diff --git a/packages/cultmath/scripts/unity-smoke/CultMath.Smoke.Tests.asmdef b/packages/cultmath/scripts/unity-smoke/CultMath.Smoke.Tests.asmdef deleted file mode 100644 index 9017551b..00000000 --- a/packages/cultmath/scripts/unity-smoke/CultMath.Smoke.Tests.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "CultMath.Smoke.Tests", - "rootNamespace": "", - "references": [ "UnityEngine.TestRunner", "UnityEditor.TestRunner" ], - "includePlatforms": [ "Editor" ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ "nunit.framework.dll", "CultMath.dll" ], - "autoReferenced": false, - "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], - "noEngineReferences": false -} diff --git a/packages/cultmath/scripts/unity-smoke/Good.compute b/packages/cultmath/scripts/unity-smoke/Good.compute deleted file mode 100644 index 0235c23e..00000000 --- a/packages/cultmath/scripts/unity-smoke/Good.compute +++ /dev/null @@ -1,11 +0,0 @@ -#pragma kernel CSMain -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.hlsl" -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl" -#include "Packages/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl" -RWStructuredBuffer Out; -[numthreads(1,1,1)] void CSMain(uint3 id : SV_DispatchThreadID) -{ - float2 r = cultmath_iv_add(float2(1, 2), float2(3, 5)); - float2 a = cultmath_af_range(cultmath_af_add(cultmath_af_point(3), cultmath_af_point(5))); - Out[0] = float4(r, a); -} diff --git a/packages/cultmath/scripts/unity-smoke/SmokeTests.cs b/packages/cultmath/scripts/unity-smoke/SmokeTests.cs deleted file mode 100644 index 91777785..00000000 --- a/packages/cultmath/scripts/unity-smoke/SmokeTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using CultMath; -using NUnit.Framework; -using UnityEditor; -using UnityEngine; -using UnityEngine.TestTools; - -public class SmokeTests -{ - // Compiles by FindKernel and dispatches on the device; false when the shader does not compile or the output is wrong. - static bool CompilesAndRuns(string path) - { - var cs = AssetDatabase.LoadAssetAtPath(path); - Assert.IsNotNull(cs, path); - int k; - try { k = cs.FindKernel("CSMain"); } catch (Exception e) { Debug.Log("SMOKE " + path + " FindKernel threw: " + e.Message); return false; } - if (!cs.HasKernel("CSMain") || !cs.IsSupported(k)) { Debug.Log("SMOKE " + path + " kernel unusable"); return false; } - var buf = new ComputeBuffer(1, 16); - try - { - cs.SetBuffer(k, "Out", buf); - cs.Dispatch(k, 1, 1, 1); - var o = new Vector4[1]; buf.GetData(o); - Debug.Log($"SMOKE {path} out=({o[0].x},{o[0].y},{o[0].z},{o[0].w}) gpu={SystemInfo.graphicsDeviceType}"); - return o[0].x == 4f && o[0].y == 7f && o[0].z <= 8f && o[0].w >= 8f && o[0].w - o[0].z < 1e-3f; - } - finally { buf.Release(); } - } - - [Test] public void CSharpIntervalAndAffineWork() - { - var r = math.iv_add(new float2(1, 2), new float2(3, 5)); - Assert.AreEqual(4f, r.x); Assert.AreEqual(7f, r.y); - Assert.AreEqual(0f, math.snoise(new float3(0, 0, 0))); - } - - [Test] public void RealShaderCompilesAndDispatches() { Assert.IsTrue(CompilesAndRuns("Assets/Shaders/Good.compute")); } - - [Test] public void BrokenShaderIsDetected() - { - LogAssert.ignoreFailingMessages = true; - Assert.IsFalse(CompilesAndRuns("Assets/Shaders/Broken.compute")); - } -} diff --git a/packages/cultmath/scripts/unity-smoke/run-unity-smoke.ps1 b/packages/cultmath/scripts/unity-smoke/run-unity-smoke.ps1 deleted file mode 100644 index 641459e6..00000000 --- a/packages/cultmath/scripts/unity-smoke/run-unity-smoke.ps1 +++ /dev/null @@ -1,94 +0,0 @@ -<# -.SYNOPSIS - The release smoke for the tracked org.gamecult.cultmath Unity package: imports it into a - scratch project, compiles and dispatches a compute shader that includes the package's - CultMath.Interval.hlsl and CultMath.Affine.hlsl on a real graphics device, and proves a - deliberately broken shader is rejected. - -.DESCRIPTION - Run it on a Windows machine with a GPU, alone, before tagging cultmath-unity-v*. The scratch - project is built outside the repository under -WorkRoot, references the package by a file: path, - and is deleted afterwards (-Keep leaves it). Exit 0 only when Unity exited 0, this run wrote the - results file (earlier ones are deleted before launch), and all three tests of SmokeTests.cs - passed: the C# calls, the real shader dispatched with the right output, and the broken control - shader detected. - - Never add -nographics. Without a device nothing compiles, and - ShaderUtil.GetComputeShaderMessageCount reports 0 messages for a compute shader that calls an - undeclared function until FindKernel or Dispatch compiles it, so a message-count check passes a - broken shader. SmokeTests.cs compiles by FindKernel, dispatches, and reads the output back. - - For a long run start it detached and poll the log, for example: - Start-Process powershell -WindowStyle Hidden -ArgumentList '-File', '', '-UnityExe', '', '-WorkRoot', '' - The script writes unity.pid and unity.log under the scratch root's logs folder (kept after the run). - -.PARAMETER UnityExe - Path to Unity.exe of the editor to test with (the cut that released 0.4.0 used 6000.3.24f1). -.PARAMETER WorkRoot - Directory outside the repository for the scratch project and logs. Default: a new folder under TEMP. -.PARAMETER Keep - Keep the scratch project instead of deleting it. -#> -param( - [Parameter(Mandatory)] [string] $UnityExe, - [string] $WorkRoot = (Join-Path $env:TEMP ("cultmath-unity-smoke-" + [guid]::NewGuid().ToString('N').Substring(0, 8))), - [switch] $Keep -) -$ErrorActionPreference = 'Stop' -if (-not (Test-Path -LiteralPath $UnityExe -PathType Leaf)) { throw "UnityExe not found: $UnityExe" } - -$smoke = $PSScriptRoot -$package = (Resolve-Path (Join-Path $smoke '..\..\unity\org.gamecult.cultmath')).Path -$repoRoot = (git -C $smoke rev-parse --show-toplevel).Trim() -$work = [IO.Path]::GetFullPath($WorkRoot) -if ($work.StartsWith([IO.Path]::GetFullPath($repoRoot), [StringComparison]::OrdinalIgnoreCase)) { - throw "WorkRoot must be outside the repository: $work" -} -$project = Join-Path $work 'project' -$logs = Join-Path $work 'logs' -New-Item -ItemType Directory -Force -Path $logs | Out-Null -foreach ($d in 'Packages', 'Assets\Shaders', 'Assets\Tests') { New-Item -ItemType Directory -Force -Path (Join-Path $project $d) | Out-Null } - -Copy-Item -LiteralPath (Join-Path $smoke 'Good.compute'), (Join-Path $smoke 'Broken.compute') -Destination (Join-Path $project 'Assets\Shaders') -Copy-Item -LiteralPath (Join-Path $smoke 'SmokeTests.cs'), (Join-Path $smoke 'CultMath.Smoke.Tests.asmdef') -Destination (Join-Path $project 'Assets\Tests') - -$packageUri = 'file:' + $package.Replace([string][char]92, '/') -$manifest = [ordered]@{ - dependencies = [ordered]@{ - 'com.unity.test-framework' = '1.6.0' - 'org.gamecult.cultmath' = $packageUri - } -} -[IO.File]::WriteAllText((Join-Path $project 'Packages\manifest.json'), ($manifest | ConvertTo-Json -Depth 4), (New-Object Text.UTF8Encoding($false))) - -$log = Join-Path $logs 'unity.log' -$results = Join-Path $logs 'results.xml' -# A kept logs folder may hold an earlier run's evidence: nothing from a previous run may decide this one. -foreach ($stale in $log, $results, (Join-Path $logs 'unity.pid')) { Remove-Item -LiteralPath $stale -Force -ErrorAction SilentlyContinue } -if (Test-Path -LiteralPath $results) { throw "could not clear the previous results file: $results" } -$unityArgs = @('-batchmode', '-projectPath', $project, '-runTests', '-testPlatform', 'EditMode', - '-testResults', $results, '-logFile', $log) -$launched = Get-Date -$p = Start-Process -PassThru -FilePath $UnityExe -ArgumentList $unityArgs -WindowStyle Hidden -$p.Id | Out-File (Join-Path $logs 'unity.pid') -Encoding ascii -"unity pid=$($p.Id) log=$log" -$p.WaitForExit() -"unity exit=$($p.ExitCode)" - -# Pass needs all of: Unity exited 0; a results file written by this run; the real shader test passed and -# the broken control test passed (it asserts that the broken shader is rejected). -$ok = $false -if ($p.ExitCode -ne 0) { "unity exited non-zero: $($p.ExitCode)" } -elseif (-not (Test-Path -LiteralPath $results)) { 'no results file from this run' } -elseif ((Get-Item -LiteralPath $results).LastWriteTime -lt $launched) { 'results file predates this run' } -else { - $cases = @(([xml](Get-Content -LiteralPath $results -Raw)).SelectNodes('//test-case')) - $cases | ForEach-Object { "{0} {1}" -f $_.result, $_.name } - $want = 'CSharpIntervalAndAffineWork', 'RealShaderCompilesAndDispatches', 'BrokenShaderIsDetected' - $passed = @($cases | Where-Object { $_.result -eq 'Passed' } | ForEach-Object { ($_.name -split '\.')[-1] }) - $ok = (@($want | Where-Object { $passed -contains $_ }).Count -eq $want.Count) -} -Get-Content -LiteralPath $log -ErrorAction SilentlyContinue | Select-String -CaseSensitive -Pattern '^SMOKE ' | ForEach-Object { $_.Line } - -if (-not $Keep) { Remove-Item -LiteralPath $project -Recurse -Force } -if ($ok) { 'SMOKE PASSED'; exit 0 } else { 'SMOKE FAILED'; exit 1 } diff --git a/packages/cultmath/shaders/CultMath.Affine.hlsl b/packages/cultmath/shaders/CultMath.Affine.hlsl deleted file mode 100644 index f165148b..00000000 --- a/packages/cultmath/shaders/CultMath.Affine.hlsl +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef CULTMATH_AFFINE_HLSL -#define CULTMATH_AFFINE_HLSL - -// Reduced affine forms with one shared symbol over float3(x0, a, e): the set { x0 + a eps + e delta : -// delta in [-1, 1] } at the region's shared eps in [-1, 1], e >= 0. Every cultmath_af_* function mirrors -// math.Affine.cs bit for bit; see that file and docs/design.md ("Affine forms") for each op's enclosure -// and the float32 rounding allowance it folds into e. Included by CultMath.hlsl after -// CultMath.Interval.hlsl, whose CULTMATH_SNOISE_LIPSCHITZ it shares, and after its own -// definition of cultmath_snoise_grad. - -// An upper bound on the spectral norm of the Hessian of cultmath_snoise(float3); provenance in -// math.Affine.cs (SNOISE_HESSIAN). -static const float CULTMATH_SNOISE_HESSIAN = 56.050385; - -float3 cultmath_af_point(float value) { return float3(value, 0.0, 0.0); } -float3 cultmath_af_symbol(float x0, float a) { return float3(x0, a, 0.0); } - -float3 cultmath_af_from_iv(float2 interval) -{ - float x0 = interval.x * 0.5 + interval.y * 0.5; - float e = interval.y * 0.5 - interval.x * 0.5; - return float3(x0, 0.0, e + (abs(x0) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// An endpoint that would be NaN is the infinity on its side. NaN is found by its bit pattern: dxc marks -// compares fast, so a test that needs NaN to make `lo == lo` false is deleted under its default flags. -float2 cultmath_af_range(float3 x) -{ - float r = abs(x.y) + x.z; - float w = abs(x.x) * 9.5367431640625e-7 + r * 9.5367431640625e-7; - float lo = x.x - r - w; - float hi = x.x + r + w; - return float2((asuint(lo) & 0x7fffffffu) > 0x7f800000u ? asfloat(0xff800000u) : lo, - (asuint(hi) & 0x7fffffffu) > 0x7f800000u ? asfloat(0x7f800000u) : hi); -} - -float3 cultmath_af_add(float3 x, float3 y) -{ - float x0 = x.x + y.x; - float a = x.y + y.y; - float e = x.z + y.z; - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -float3 cultmath_af_sub(float3 x, float3 y) -{ - float x0 = x.x - y.x; - float a = x.y - y.y; - float e = x.z + y.z; - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -float3 cultmath_af_neg(float3 x) { return float3(-x.x, -x.y, x.z); } - -float3 cultmath_af_scale(float3 x, float s) -{ - float x0 = x.x * s; - float a = x.y * s; - float e = x.z * abs(s); - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -float3 cultmath_af_add_iv(float3 x, float2 interval) { return cultmath_af_add(x, cultmath_af_from_iv(interval)); } - -float3 cultmath_af_mul(float3 x, float3 y) -{ - float x0 = x.x * y.x; - float p = x.x * y.y; - float q = y.x * x.y; - float a = p + q; - float e = abs(x.x) * y.z + abs(y.x) * x.z + (abs(x.y) + x.z) * (abs(y.y) + y.z); - return float3(x0, a, e + (abs(x0) + abs(p) + abs(q) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// The narrower of the Lipschitz form and the centred (Taylor) form over every p = centre + axis eps + w, -// |w| <= radius, from one cultmath_snoise_grad at the centre; the allowance for the float32 evaluation is -// in math.Affine.cs. -float3 cultmath_af_snoise(float3 centre, float3 axis, float radius) -{ - float4 g = cultmath_snoise_grad(centre); - float3 gradient = float3(g.x, g.y, g.z); - float reach = length(axis) + radius; - float lipschitz = CULTMATH_SNOISE_LIPSCHITZ * reach; - float a = dot(gradient, axis); - float remainder = length(gradient) * radius + 0.5 * CULTMATH_SNOISE_HESSIAN * reach * reach; - float allowance = 6.103515625e-5 + 2.44140625e-4 * reach - + CULTMATH_SNOISE_LIPSCHITZ * 9.5367431640625e-7 * (abs(centre.x) + abs(centre.y) + abs(centre.z) + reach); - bool centred = abs(a) + remainder < lipschitz; - float slope = centred ? a : 0.0; - float e = (centred ? remainder : lipschitz) + allowance; - return float3(g.w, slope, e + (abs(g.w) + abs(slope) + e) * 9.5367431640625e-7); -} - -// Octave sum of cultmath_af_snoise, compounding frequency and amplitude as the value-and-gradient fBm does. -float3 cultmath_af_fbm(float3 centre, float3 axis, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float3 sum = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_af_add(sum, cultmath_af_scale(cultmath_af_snoise(centre * frequency, axis * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// The axis of a screen tile's slice over the depth segment [z0, z1]; camera frame of -// cultmath_iv_frustum_ball. -float3 cultmath_af_frustum_axis(float2 centreSlope, float z0, float z1) -{ - float h = (z1 - z0) * 0.5; - return float3(centreSlope.x * h, centreSlope.y * h, h); -} - -// The affine slice of a screen tile over [z0, z1]: centre xyz, radius w. Derivation in math.Affine.cs. -float4 cultmath_af_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warpVariation) -{ - float zm = (z0 + z1) * 0.5; - float h = (z1 - z0) * 0.5; - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float spread = (abs(centreSlope.x) + abs(centreSlope.y) + 1.0) * h; - float radius = z1 * footprintPerDepth + warpVariation; - radius += (abs(cx) + abs(cy) + abs(zm) + spread + radius) * 9.5367431640625e-7; - return float4(cx, cy, zm, radius); -} - -#endif diff --git a/packages/cultmath/shaders/CultMath.Affine.hlsl.meta b/packages/cultmath/shaders/CultMath.Affine.hlsl.meta deleted file mode 100644 index 81cc7925..00000000 --- a/packages/cultmath/shaders/CultMath.Affine.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 26f28fce38e14eed8b9b5dbd758e4ffc -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/shaders/CultMath.Interval.hlsl b/packages/cultmath/shaders/CultMath.Interval.hlsl deleted file mode 100644 index bc084ace..00000000 --- a/packages/cultmath/shaders/CultMath.Interval.hlsl +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef CULTMATH_INTERVAL_HLSL -#define CULTMATH_INTERVAL_HLSL - -// Interval arithmetic over float2(lo, hi), lo <= hi, both finite. Every cultmath_iv_* function returns -// an interval containing f(x) for every x in its input intervals, mirroring math.Interval.cs bit for -// bit; see that file and docs/design.md ("Intervals") for each op's enclosure and its ulp widening. -// Included by CultMath.hlsl after its own definitions of cultmath_smoothstep and cultmath_snoise. - -// Lipschitz constant of cultmath_snoise(float3); provenance in math.Interval.cs (SNOISE_LIPSCHITZ). -static const float CULTMATH_SNOISE_LIPSCHITZ = 7.9640074; - -// Lipschitz constant of cultmath_snoise(float2); provenance in math.Interval.cs (SNOISE2_LIPSCHITZ). -static const float CULTMATH_SNOISE2_LIPSCHITZ = 8.117002; - -float2 cultmath_iv_point(float value) { return float2(value, value); } -float2 cultmath_iv_add(float2 a, float2 b) { return float2(a.x + b.x, a.y + b.y); } -float2 cultmath_iv_sub(float2 a, float2 b) { return float2(a.x - b.y, a.y - b.x); } -float2 cultmath_iv_neg(float2 a) { return float2(-a.y, -a.x); } - -float2 cultmath_iv_mul(float2 a, float2 b) -{ - float p0 = a.x * b.x; - float p1 = a.x * b.y; - float p2 = a.y * b.x; - float p3 = a.y * b.y; - return float2(min(min(p0, p1), min(p2, p3)), max(max(p0, p1), max(p2, p3))); -} - -float2 cultmath_iv_scale(float2 a, float s) { return s >= 0.0 ? float2(a.x * s, a.y * s) : float2(a.y * s, a.x * s); } - -float2 cultmath_iv_abs(float2 a) -{ - if (a.x >= 0.0) - return a; - if (a.y <= 0.0) - return float2(-a.y, -a.x); - return float2(0.0, max(-a.x, a.y)); -} - -float2 cultmath_iv_min(float2 a, float2 b) { return float2(min(a.x, b.x), min(a.y, b.y)); } -float2 cultmath_iv_max(float2 a, float2 b) { return float2(max(a.x, b.x), max(a.y, b.y)); } - -float2 cultmath_iv_sqr(float2 a) -{ - float l = a.x * a.x; - float h = a.y * a.y; - if (a.x >= 0.0) - return float2(l, h); - if (a.y <= 0.0) - return float2(h, l); - return float2(0.0, max(l, h)); -} - -float2 cultmath_iv_sqrt(float2 a) { return float2(sqrt(max(a.x, 0.0)), sqrt(max(a.y, 0.0))); } - -// Widened by one ulp on each side: exp is not required to be correctly rounded. -float2 cultmath_iv_exp(float2 a) -{ - float lo = exp(a.x); - float hi = exp(a.y); - return float2(lo > 0.0 ? asfloat(asuint(lo) - 1u) : 0.0, asfloat(asuint(hi) + 1u)); -} - -float2 cultmath_iv_clamp(float2 a, float minimum, float maximum) -{ - return float2(cultmath_clamp(a.x, minimum, maximum), cultmath_clamp(a.y, minimum, maximum)); -} - -float2 cultmath_iv_saturate(float2 a) { return float2(cultmath_saturate(a.x), cultmath_saturate(a.y)); } - -// The endpoints, ordered, widened by one ulp inside [0, 1]: the float32 evaluation of smoothstep is -// monotone only to within one ulp. -float2 cultmath_iv_smoothstep(float minimum, float maximum, float2 a) -{ - float s0 = cultmath_smoothstep(minimum, maximum, a.x); - float s1 = cultmath_smoothstep(minimum, maximum, a.y); - float lo = min(s0, s1); - float hi = max(s0, s1); - return float2(lo > 0.0 ? asfloat(asuint(lo) - 1u) : 0.0, hi < 1.0 ? asfloat(asuint(hi) + 1u) : 1.0); -} - -// The natural interval extension of x + (y - x) * amount, which is how cultmath_lerp evaluates. -float2 cultmath_iv_lerp(float2 a, float2 b, float amount) { return cultmath_iv_add(a, cultmath_iv_scale(cultmath_iv_sub(b, a), amount)); } - -// [n - L r, n + L r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -float2 cultmath_iv_snoise_ball(float3 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE_LIPSCHITZ * radius; - return float2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// The 2D overload: [n - L2 r, n + L2 r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -float2 cultmath_iv_snoise_ball(float2 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE2_LIPSCHITZ * radius; - return float2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// Octave sum of cultmath_iv_snoise_ball, compounding frequency and amplitude as the value-and-gradient fBm does. -float2 cultmath_iv_fbm_ball(float3 centre, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float2 sum = float2(0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_iv_add(sum, cultmath_iv_scale(cultmath_iv_snoise_ball(centre * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// A ball (xyz centre, w radius) enclosing every point of every ray of a screen tile over the depth segment -// [z0, z1], warped by at most warp. Camera frame: pinhole at the origin looking down +z, ray (m z, z). -// footprintPerDepth = N / (sqrt(2) f) for an N x N tile at focal length f. The radius is widened by -// (|c|_1 + radius) 2^-20, which covers the ball's own float32 rounding. Derivation in math.Interval.cs. -float4 cultmath_iv_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warp) -{ - float zm = (z0 + z1) * 0.5; - float axis = sqrt(centreSlope.x * centreSlope.x + centreSlope.y * centreSlope.y + 1.0); - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float radius = (z1 - z0) * 0.5 * axis + z1 * footprintPerDepth + warp; - radius += (abs(cx) + abs(cy) + abs(zm) + radius) * 9.5367431640625e-7; - return float4(cx, cy, zm, radius); -} - -#endif diff --git a/packages/cultmath/shaders/CultMath.Interval.hlsl.meta b/packages/cultmath/shaders/CultMath.Interval.hlsl.meta deleted file mode 100644 index a22ec627..00000000 --- a/packages/cultmath/shaders/CultMath.Interval.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4d8a899561654ac990cab0bf48658cc1 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/shaders/CultMath.Phacelle.glsl b/packages/cultmath/shaders/CultMath.Phacelle.glsl deleted file mode 100644 index 11405fa2..00000000 --- a/packages/cultmath/shaders/CultMath.Phacelle.glsl +++ /dev/null @@ -1,99 +0,0 @@ -// Generated from shaders/CultMath.Phacelle.hlsl by GlslLowering (packages/cultmath/tests/CultMath.Tests/GlslLowering.cs). Do not edit; regenerate with CULTMATH_WRITE_GLSL=1 dotnet test --filter GlslMirrorTests. MPL-2.0; requires CultMath.glsl before it. -#ifndef CULTMATH_PHACELLE_GLSL -#define CULTMATH_PHACELLE_GLSL -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Phacelle noise. Copyright (c) 2025 Rune Skovbo Johansen (Shadertoy t3dyWl; MPL-2.0), read from the -// C# port PhacelleNoise in lpmitchell/AdvancedTerrainErosion, converted to burstable C# by Luke -// Mitchell (2026). Modified by GameCult: 3D cells, a caller-supplied stripe wave vector, an exact -// gradient and exact pruning. This file is an MPL-2.0 file; CultMath.hlsl, which includes it after -// its own definitions of CULTMATH_TAU and cultmath_pcg3d, is MIT (see THIRD-PARTY-NOTICES.md). - -// Invariant 8's struct return shape for cultmath_phacelle, compared field by field and bit for bit -// against CultMath.CultPhasor, same field order. -struct CultPhasor -{ - vec4 cos; - vec4 sin; -}; - -// Johansen's Phacelle noise on 3D cells. See math.phacelle's comment (math.Phacelle.cs) for the stripe wave -// vector, the weight, the normalization, the exact gradient and why the prune is exact. Mirrors -// the C# body operation for operation; the C#-only internal overload that switches the prune off -// has no shader twin. -CultPhasor cultmath_phacelle(vec3 p, vec3 side, float offset, float normalization) -{ - vec3 cell = floor(p); - vec3 local = p - cell; - float phaseOffset = offset * CULTMATH_TAU; - float sumW = 0.0; - float sumCos = 0.0; - float sumSin = 0.0; - vec3 gradW = vec3(0.0, 0.0, 0.0); - vec3 gradCos = vec3(0.0, 0.0, 0.0); - vec3 gradSin = vec3(0.0, 0.0, 0.0); - - for (int dz = -1; dz <= 2; dz++) - { - float gz = max(0.0, abs(local.z - float(dz)) - 0.5); - for (int dy = -1; dy <= 2; dy++) - { - float gy = max(0.0, abs(local.y - float(dy)) - 0.5); - for (int dx = -1; dx <= 2; dx++) - { - float gx = max(0.0, abs(local.x - float(dx)) - 0.5); - if (gx * gx + gy * gy + gz * gz >= 2.25) - continue; - - vec3 gridStep = vec3(dx, dy, dz); - ivec3 hash = cultmath_pcg3d(ivec3(cell + gridStep)); - vec3 jitter = vec3( - float(uint(hash.x) >> 8) * (1.0 / 16777216.0) - 0.5, - float(uint(hash.y) >> 8) * (1.0 / 16777216.0) - 0.5, - float(uint(hash.z) >> 8) * (1.0 / 16777216.0) - 0.5); - vec3 v = local - gridStep - jitter; - float falloff = exp(-2.0 * dot(v, v)); - float w = max(0.0, falloff - 0.01111); - vec3 dw = w > 0.0 ? (-4.0 * falloff) * v : vec3(0.0, 0.0, 0.0); - float phase = dot(v, side) + phaseOffset; - float c = cos(phase); - float s = sin(phase); - - sumW += w; - sumCos += w * c; - sumSin += w * s; - gradW += dw; - gradCos += dw * c - (w * s) * side; - gradSin += dw * s + (w * c) * side; - } - } - } - - float invW = 1.0 / sumW; - float rawCos = sumCos * invW; - float rawSin = sumSin * invW; - vec3 gradRawCos = (gradCos - rawCos * gradW) * invW; - vec3 gradRawSin = (gradSin - rawSin * gradW) * invW; - float rawLength = sqrt(rawCos * rawCos + rawSin * rawSin); - float floorLength = 1.0 - normalization; - - CultPhasor result; - if (rawLength > floorLength) - { - float outCos = rawCos / rawLength; - float outSin = rawSin / rawLength; - vec3 gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength; - result.cos = vec4((gradRawCos - outCos * gradLength) / rawLength, outCos); - result.sin = vec4((gradRawSin - outSin * gradLength) / rawLength, outSin); - } - else - { - result.cos = vec4(gradRawCos / floorLength, rawCos / floorLength); - result.sin = vec4(gradRawSin / floorLength, rawSin / floorLength); - } - - return result; -} - -#endif diff --git a/packages/cultmath/shaders/CultMath.Phacelle.hlsl b/packages/cultmath/shaders/CultMath.Phacelle.hlsl deleted file mode 100644 index c95aafc6..00000000 --- a/packages/cultmath/shaders/CultMath.Phacelle.hlsl +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef CULTMATH_PHACELLE_HLSL -#define CULTMATH_PHACELLE_HLSL - -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Phacelle noise. Copyright (c) 2025 Rune Skovbo Johansen (Shadertoy t3dyWl; MPL-2.0), read from the -// C# port PhacelleNoise in lpmitchell/AdvancedTerrainErosion, converted to burstable C# by Luke -// Mitchell (2026). Modified by GameCult: 3D cells, a caller-supplied stripe wave vector, an exact -// gradient and exact pruning. This file is an MPL-2.0 file; CultMath.hlsl, which includes it after -// its own definitions of CULTMATH_TAU and cultmath_pcg3d, is MIT (see THIRD-PARTY-NOTICES.md). - -// Invariant 8's struct return shape for cultmath_phacelle, compared field by field and bit for bit -// against CultMath.CultPhasor, same field order. -struct CultPhasor -{ - float4 cos; - float4 sin; -}; - -// Johansen's Phacelle noise on 3D cells. See math.phacelle's comment (math.Phacelle.cs) for the stripe wave -// vector, the weight, the normalization, the exact gradient and why the prune is exact. Mirrors -// the C# body operation for operation; the C#-only internal overload that switches the prune off -// has no shader twin. -CultPhasor cultmath_phacelle(float3 p, float3 side, float offset, float normalization) -{ - float3 cell = floor(p); - float3 local = p - cell; - float phaseOffset = offset * CULTMATH_TAU; - float sumW = 0.0; - float sumCos = 0.0; - float sumSin = 0.0; - float3 gradW = float3(0.0, 0.0, 0.0); - float3 gradCos = float3(0.0, 0.0, 0.0); - float3 gradSin = float3(0.0, 0.0, 0.0); - - for (int dz = -1; dz <= 2; dz++) - { - float gz = max(0.0, abs(local.z - (float)dz) - 0.5); - for (int dy = -1; dy <= 2; dy++) - { - float gy = max(0.0, abs(local.y - (float)dy) - 0.5); - for (int dx = -1; dx <= 2; dx++) - { - float gx = max(0.0, abs(local.x - (float)dx) - 0.5); - if (gx * gx + gy * gy + gz * gz >= 2.25) - continue; - - float3 gridStep = float3(dx, dy, dz); - int3 hash = cultmath_pcg3d(int3(cell + gridStep)); - float3 jitter = float3( - (float)((uint)hash.x >> 8) * (1.0 / 16777216.0) - 0.5, - (float)((uint)hash.y >> 8) * (1.0 / 16777216.0) - 0.5, - (float)((uint)hash.z >> 8) * (1.0 / 16777216.0) - 0.5); - float3 v = local - gridStep - jitter; - float falloff = exp(-2.0 * dot(v, v)); - float w = max(0.0, falloff - 0.01111); - float3 dw = w > 0.0 ? (-4.0 * falloff) * v : float3(0.0, 0.0, 0.0); - float phase = dot(v, side) + phaseOffset; - float c = cos(phase); - float s = sin(phase); - - sumW += w; - sumCos += w * c; - sumSin += w * s; - gradW += dw; - gradCos += dw * c - (w * s) * side; - gradSin += dw * s + (w * c) * side; - } - } - } - - float invW = 1.0 / sumW; - float rawCos = sumCos * invW; - float rawSin = sumSin * invW; - float3 gradRawCos = (gradCos - rawCos * gradW) * invW; - float3 gradRawSin = (gradSin - rawSin * gradW) * invW; - float rawLength = sqrt(rawCos * rawCos + rawSin * rawSin); - float floorLength = 1.0 - normalization; - - CultPhasor result; - if (rawLength > floorLength) - { - float outCos = rawCos / rawLength; - float outSin = rawSin / rawLength; - float3 gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength; - result.cos = float4((gradRawCos - outCos * gradLength) / rawLength, outCos); - result.sin = float4((gradRawSin - outSin * gradLength) / rawLength, outSin); - } - else - { - result.cos = float4(gradRawCos / floorLength, rawCos / floorLength); - result.sin = float4(gradRawSin / floorLength, rawSin / floorLength); - } - - return result; -} - -#endif diff --git a/packages/cultmath/shaders/CultMath.Phacelle.hlsl.meta b/packages/cultmath/shaders/CultMath.Phacelle.hlsl.meta deleted file mode 100644 index 69308465..00000000 --- a/packages/cultmath/shaders/CultMath.Phacelle.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e07a3b95c1d84f2aa6b83d4c5f19a0d7 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/shaders/CultMath.glsl b/packages/cultmath/shaders/CultMath.glsl deleted file mode 100644 index d89ff8a3..00000000 --- a/packages/cultmath/shaders/CultMath.glsl +++ /dev/null @@ -1,805 +0,0 @@ -// Generated from shaders/CultMath.hlsl and CultMath.Interval.hlsl and CultMath.Affine.hlsl by GlslLowering (packages/cultmath/tests/CultMath.Tests/GlslLowering.cs). Do not edit; regenerate with CULTMATH_WRITE_GLSL=1 dotnet test --filter GlslMirrorTests. MIT. cultmath_phacelle is in CultMath.Phacelle.glsl, to be concatenated after this file by consumers that call it. -#ifndef CULTMATH_GLSL -#define CULTMATH_GLSL -// CultMath HLSL mirror. -// -// HLSL already owns the vec2/vec3/vec4 type names and most primitive -// intrinsics. This include names the CultMath semantic surface explicitly so -// shader code, C# wrappers, and Rust/native parity fixtures can share the same -// small vocabulary without local helper drift. - -const float CULTMATH_PI = 3.14159265358979323846; -const float CULTMATH_TAU = 6.28318530717958647692; -const float CULTMATH_HALF_PI = 1.57079632679489661923; - -float cultmath_radians(float degrees_value) { return degrees_value * (CULTMATH_PI / 180.0); } -float cultmath_degrees(float radians_value) { return radians_value * (180.0 / CULTMATH_PI); } - -float cultmath_frac(float value) { return value - floor(value); } -vec2 cultmath_frac(vec2 value) { return value - floor(value); } -vec3 cultmath_frac(vec3 value) { return value - floor(value); } -vec4 cultmath_frac(vec4 value) { return value - floor(value); } - -float cultmath_clamp(float value, float minimum, float maximum) { return min(max(value, minimum), maximum); } -vec2 cultmath_clamp(vec2 value, vec2 minimum, vec2 maximum) { return min(max(value, minimum), maximum); } -vec3 cultmath_clamp(vec3 value, vec3 minimum, vec3 maximum) { return min(max(value, minimum), maximum); } -vec4 cultmath_clamp(vec4 value, vec4 minimum, vec4 maximum) { return min(max(value, minimum), maximum); } - -// DXIL Saturate is FMin(1, FMax(0, x)); dxc lowers min/max to the same FMin/FMax, NaN rules included. -float cultmath_saturate(float value) { return min(1.0, max(0.0, value)); } -vec2 cultmath_saturate(vec2 value) { return min(vec2(1.0, 1.0), max(vec2(0.0, 0.0), value)); } -vec3 cultmath_saturate(vec3 value) { return min(vec3(1.0, 1.0, 1.0), max(vec3(0.0, 0.0, 0.0), value)); } -vec4 cultmath_saturate(vec4 value) { return min(vec4(1.0, 1.0, 1.0, 1.0), max(vec4(0.0, 0.0, 0.0, 0.0), value)); } - -float cultmath_lerp(float start, float end, float amount) { return start + (end - start) * amount; } -vec2 cultmath_lerp(vec2 start, vec2 end, vec2 amount) { return start + (end - start) * amount; } -vec3 cultmath_lerp(vec3 start, vec3 end, vec3 amount) { return start + (end - start) * amount; } -vec4 cultmath_lerp(vec4 start, vec4 end, vec4 amount) { return start + (end - start) * amount; } - -float cultmath_step(float edge, float value) { return value < edge ? 0.0 : 1.0; } -vec2 cultmath_step(vec2 edge, vec2 value) { return vec2(cultmath_step(edge.x, value.x), cultmath_step(edge.y, value.y)); } -vec3 cultmath_step(vec3 edge, vec3 value) { return vec3(cultmath_step(edge.x, value.x), cultmath_step(edge.y, value.y), cultmath_step(edge.z, value.z)); } -vec4 cultmath_step(vec4 edge, vec4 value) { return vec4(cultmath_step(edge.x, value.x), cultmath_step(edge.y, value.y), cultmath_step(edge.z, value.z), cultmath_step(edge.w, value.w)); } - -float cultmath_smoothstep(float minimum, float maximum, float value) -{ - float t = cultmath_saturate((value - minimum) / (maximum - minimum)); - return t * t * (3.0 - 2.0 * t); -} - -vec2 cultmath_smoothstep(vec2 minimum, vec2 maximum, vec2 value) -{ - vec2 t = cultmath_saturate((value - minimum) / (maximum - minimum)); - return t * t * (vec2(3.0, 3.0) - vec2(2.0, 2.0) * t); -} - -vec3 cultmath_smoothstep(vec3 minimum, vec3 maximum, vec3 value) -{ - vec3 t = cultmath_saturate((value - minimum) / (maximum - minimum)); - return t * t * (vec3(3.0, 3.0, 3.0) - vec3(2.0, 2.0, 2.0) * t); -} - -vec4 cultmath_smoothstep(vec4 minimum, vec4 maximum, vec4 value) -{ - vec4 t = cultmath_saturate((value - minimum) / (maximum - minimum)); - return t * t * (vec4(3.0, 3.0, 3.0, 3.0) - vec4(2.0, 2.0, 2.0, 2.0) * t); -} - -float cultmath_smoothstep01(float value) { return cultmath_smoothstep(0.0, 1.0, value); } - -float cultmath_smootherstep(float value) -{ - value = cultmath_saturate(value); - return value * value * value * (value * (value * 6.0 - 15.0) + 10.0); -} - -vec2 cultmath_snoise_mod289(vec2 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } -vec3 cultmath_snoise_mod289(vec3 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } -vec4 cultmath_snoise_mod289(vec4 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } -vec3 cultmath_snoise_permute(vec3 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } -vec4 cultmath_snoise_permute(vec4 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } - -// Ashima Arts / Ian McEwan 3D simplex noise (MIT), same float32 evaluation -// order as the C# math.snoise(vec3) mirror. Ties resolve in simplexnoise1234's -// total order; see math.snoise. -float cultmath_snoise(vec3 value) -{ - vec2 c = vec2(1.0 / 6.0, 1.0 / 3.0); - vec3 i = floor(value + dot(value, c.yyy)); - vec3 x0 = value - i + dot(i, c.xxx); - vec3 g = vec3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); - vec3 l = 1.0 - g; - vec3 i1 = min(g.xyz, l.zxy); - vec3 i2 = max(g.xyz, l.zxy); - vec3 x1 = x0 - i1 + c.xxx; - vec3 x2 = x0 - i2 + c.yyy; - vec3 x3 = x0 - 0.5; - - i = cultmath_snoise_mod289(i); - vec4 p = cultmath_snoise_permute(cultmath_snoise_permute(cultmath_snoise_permute( - i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0)); - - const float n_ = 0.142857142857; - vec3 ns = vec3(2.0 * n_, 0.5 * n_ - 1.0, n_); - vec4 j = p - 49.0 * floor(p * ns.z * ns.z); - vec4 x_ = floor(j * ns.z); - vec4 y_ = floor(j - 7.0 * x_); - vec4 x = x_ * ns.x + ns.yyyy; - vec4 y = y_ * ns.x + ns.yyyy; - vec4 h = 1.0 - abs(x) - abs(y); - - vec4 b0 = vec4(x.xy, y.xy); - vec4 b1 = vec4(x.zw, y.zw); - vec4 s0 = floor(b0) * 2.0 + 1.0; - vec4 s1 = floor(b1) * 2.0 + 1.0; - vec4 sh = -step(h, vec4(0.0, 0.0, 0.0, 0.0)); - vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; - vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; - - vec3 p0 = vec3(a0.xy, h.x); - vec3 p1 = vec3(a0.zw, h.y); - vec3 p2 = vec3(a1.xy, h.z); - vec3 p3 = vec3(a1.zw, h.w); - vec4 norm = 1.79284291400159 - 0.85373472095314 * vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - vec4 m = max(0.5 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); - m = m * m; - return 105.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); -} - -float cultmath_snoise(vec2 value) -{ - vec4 c = vec4( - 0.211324865405187, - 0.366025403784439, - -0.577350269189626, - 0.024390243902439); - vec2 i = floor(value + dot(value, c.yy)); - vec2 x0 = value - i + dot(i, c.xx); - vec2 i1 = x0.x > x0.y ? vec2(1.0, 0.0) : vec2(0.0, 1.0); - vec4 x12 = vec4(x0.x + c.x - i1.x, x0.y + c.x - i1.y, x0.x + c.z, x0.y + c.z); - - i = cultmath_snoise_mod289(i); - vec3 p = cultmath_snoise_permute( - cultmath_snoise_permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0)); - vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0); - m *= m; - m *= m; - - vec3 x = 2.0 * fract(p * c.w) - 1.0; - vec3 h = abs(x) - 0.5; - vec3 ox = floor(x + 0.5); - vec3 a0 = x - ox; - m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h); - - vec3 g = vec3( - a0.x * x0.x + h.x * x0.y, - a0.y * x12.x + h.y * x12.y, - a0.z * x12.z + h.z * x12.w); - return 130.0 * dot(m, g); -} - -// Analytic gradient of cultmath_snoise(vec3) (invariant 8), following webgl-noise -// src/noise3Dgrad.glsl (Ashima Arts / McEwan, MIT); same kernel, permutation and scale as -// cultmath_snoise(vec3) (stegu/webgl-noise 22434e04d7). See the C# math.snoise_grad comment for the -// derivation. Every local up through p0..p3 and x0..x3 is cultmath_snoise(vec3)'s own derivation -// verbatim. -vec4 cultmath_snoise_grad(vec3 value) -{ - vec2 c = vec2(1.0 / 6.0, 1.0 / 3.0); - vec3 i = floor(value + dot(value, c.yyy)); - vec3 x0 = value - i + dot(i, c.xxx); - vec3 g = vec3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); - vec3 l = 1.0 - g; - vec3 i1 = min(g.xyz, l.zxy); - vec3 i2 = max(g.xyz, l.zxy); - vec3 x1 = x0 - i1 + c.xxx; - vec3 x2 = x0 - i2 + c.yyy; - vec3 x3 = x0 - 0.5; - - i = cultmath_snoise_mod289(i); - vec4 p = cultmath_snoise_permute(cultmath_snoise_permute(cultmath_snoise_permute( - i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0)); - - const float n_ = 0.142857142857; - vec3 ns = vec3(2.0 * n_, 0.5 * n_ - 1.0, n_); - vec4 j = p - 49.0 * floor(p * ns.z * ns.z); - vec4 x_ = floor(j * ns.z); - vec4 y_ = floor(j - 7.0 * x_); - vec4 x = x_ * ns.x + ns.yyyy; - vec4 y = y_ * ns.x + ns.yyyy; - vec4 h = 1.0 - abs(x) - abs(y); - - vec4 b0 = vec4(x.xy, y.xy); - vec4 b1 = vec4(x.zw, y.zw); - vec4 s0 = floor(b0) * 2.0 + 1.0; - vec4 s1 = floor(b1) * 2.0 + 1.0; - vec4 sh = -step(h, vec4(0.0, 0.0, 0.0, 0.0)); - vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; - vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; - - vec3 p0 = vec3(a0.xy, h.x); - vec3 p1 = vec3(a0.zw, h.y); - vec3 p2 = vec3(a1.xy, h.z); - vec3 p3 = vec3(a1.zw, h.w); - vec4 norm = 1.79284291400159 - 0.85373472095314 * vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - vec4 m0 = max(0.5 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); - vec4 m2 = m0 * m0; - vec4 m3 = m2 * m0; - vec4 m4 = m2 * m2; - - vec4 px = vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)); - float value2 = 105.0 * dot(m4, px); - vec3 grad = -8.0 * m3.x * x0 * px.x + m4.x * p0 - + -8.0 * m3.y * x1 * px.y + m4.y * p1 - + -8.0 * m3.z * x2 * px.z + m4.z * p2 - + -8.0 * m3.w * x3 * px.w + m4.w * p3; - grad *= 105.0; - - return vec4(grad, value2); -} - -// Octave sum of cultmath_snoise_grad (invariant 8); see the C# math.fbm_grad comment for the -// per-octave frequency/amplitude derivation and why octaves is clamped. -vec4 cultmath_fbm_grad(vec3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - vec3 gradient = vec3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - vec4 n = cultmath_snoise_grad(p * frequency); - value += amplitude * n.w; - gradient += amplitude * frequency * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return vec4(gradient, value); -} - -// Ridged multifractal noise (Musgrave, Texturing and Modeling, ch. 16); see the C# math.ridged_grad -// comment for the fold/sign derivation, the deliberate crease at n = 0, and why octaves is clamped. -vec4 cultmath_ridged_grad(vec3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - vec3 gradient = vec3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - vec4 n = cultmath_snoise_grad(p * frequency); - float s = sign(n.w); - value += amplitude * (1.0 - abs(n.w)); - gradient += -amplitude * frequency * s * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return vec4(gradient, value); -} - -float cultmath_lengthsq(vec2 value) { return dot(value, value); } -float cultmath_lengthsq(vec3 value) { return dot(value, value); } -float cultmath_lengthsq(vec4 value) { return dot(value, value); } - -float cultmath_distance(vec2 left, vec2 right) { return length(left - right); } -float cultmath_distance(vec3 left, vec3 right) { return length(left - right); } -float cultmath_distance(vec4 left, vec4 right) { return length(left - right); } - -vec2 cultmath_reflect(vec2 incident, vec2 normal_value) -{ - return incident - 2.0 * dot(normal_value, incident) * normal_value; -} - -vec3 cultmath_reflect(vec3 incident, vec3 normal_value) -{ - return incident - 2.0 * dot(normal_value, incident) * normal_value; -} - -vec2 cultmath_rotate(vec2 value, float radians_value) -{ - float s = sin(radians_value); - float c = cos(radians_value); - return vec2(value.x * c - value.y * s, value.x * s + value.y * c); -} - -vec2 cultmath_rotate_degrees(vec2 value, float degrees_value) -{ - return cultmath_rotate(value, cultmath_radians(degrees_value)); -} - -float cultmath_csum(vec2 value) { return value.x + value.y; } -float cultmath_csum(vec3 value) { return value.x + value.y + value.z; } -float cultmath_csum(vec4 value) { return value.x + value.y + value.z + value.w; } - -float cultmath_decay(float source, float lambda_value, float dt) { return source * exp(-lambda_value * dt); } -vec2 cultmath_decay(vec2 source, float lambda_value, float dt) { return source * exp(-lambda_value * dt); } -vec3 cultmath_decay(vec3 source, float lambda_value, float dt) { return source * exp(-lambda_value * dt); } -vec4 cultmath_decay(vec4 source, float lambda_value, float dt) { return source * exp(-lambda_value * dt); } - -float cultmath_damp(float start, float end, float lambda_value, float dt) -{ - return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); -} - -vec2 cultmath_damp(vec2 start, vec2 end, float lambda_value, float dt) -{ - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, vec2(amount, amount)); -} - -vec3 cultmath_damp(vec3 start, vec3 end, float lambda_value, float dt) -{ - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, vec3(amount, amount, amount)); -} - -vec4 cultmath_damp(vec4 start, vec4 end, float lambda_value, float dt) -{ - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, vec4(amount, amount, amount, amount)); -} - -float cultmath_catmullrom(float p0, float p1, float p2, float p3, float t) -{ - float t2 = t * t; - float t3 = t2 * t; - return 0.5 * ((2.0 * p1) + (p2 - p0) * t + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); -} - -vec2 cultmath_catmullrom(vec2 p0, vec2 p1, vec2 p2, vec2 p3, float t) -{ - float t2 = t * t; - float t3 = t2 * t; - return 0.5 * ((2.0 * p1) + (p2 - p0) * t + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); -} - -vec3 cultmath_catmullrom(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t) -{ - float t2 = t * t; - float t3 = t2 * t; - return 0.5 * ((2.0 * p1) + (p2 - p0) * t + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); -} - -vec4 cultmath_catmullrom(vec4 p0, vec4 p1, vec4 p2, vec4 p3, float t) -{ - float t2 = t * t; - float t3 = t2 * t; - return 0.5 * ((2.0 * p1) + (p2 - p0) * t + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); -} - -float cultmath_quadratic_bezier(float p0, float p1, float p2, float t) -{ - t = cultmath_saturate(t); - float inv = 1.0 - t; - return inv * inv * p0 + 2.0 * inv * t * p1 + t * t * p2; -} - -vec3 cultmath_quadratic_bezier(vec3 p0, vec3 p1, vec3 p2, float t) -{ - t = cultmath_saturate(t); - float inv = 1.0 - t; - return inv * inv * p0 + 2.0 * inv * t * p1 + t * t * p2; -} - -float cultmath_cubic_bezier(float p0, float p1, float p2, float p3, float t) -{ - t = cultmath_saturate(t); - float inv = 1.0 - t; - return inv * inv * inv * p0 + 3.0 * inv * inv * t * p1 + 3.0 * inv * t * t * p2 + t * t * t * p3; -} - -vec3 cultmath_cubic_bezier(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t) -{ - t = cultmath_saturate(t); - float inv = 1.0 - t; - return inv * inv * inv * p0 + 3.0 * inv * inv * t * p1 + 3.0 * inv * t * t * p2 + t * t * t * p3; -} - -float cultmath_hash(float value) { return cultmath_frac(sin(value) * 43758.5453); } -float cultmath_hash(vec2 value) { return cultmath_hash(dot(value, vec2(127.1, 311.7))); } -float cultmath_hash(vec3 value) { return cultmath_hash(dot(value, vec3(127.1, 311.7, 74.7))); } - -// PCG hashes (Jarzynski and Olano, JCGT 2020), written over scalar uints so CultMath's ivec3/ivec4 carry the bits. -uint cultmath_pcg(uint value) -{ - uint state = value * 747796405u + 2891336453u; - uint word = ((state >> int((state >> 28) + 4u)) ^ state) * 277803737u; - return (word >> 22) ^ word; -} - -ivec3 cultmath_pcg3d(ivec3 value) -{ - uint x = uint(value.x) * 1664525u + 1013904223u, y = uint(value.y) * 1664525u + 1013904223u, z = uint(value.z) * 1664525u + 1013904223u; - x += y * z; y += z * x; z += x * y; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; - x += y * z; y += z * x; z += x * y; - return ivec3(int(x), int(y), int(z)); -} - -ivec3 cultmath_pcg3d(vec3 value) { return cultmath_pcg3d(ivec3(int(floatBitsToUint(value.x)), int(floatBitsToUint(value.y)), int(floatBitsToUint(value.z)))); } -ivec3 cultmath_pcg3d(vec2 value) { return cultmath_pcg3d(vec3(value, 0.0)); } - -ivec4 cultmath_pcg4d(ivec4 value) -{ - uint x = uint(value.x) * 1664525u + 1013904223u, y = uint(value.y) * 1664525u + 1013904223u; - uint z = uint(value.z) * 1664525u + 1013904223u, w = uint(value.w) * 1664525u + 1013904223u; - x += y * w; y += z * x; z += x * y; w += y * z; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; w ^= w >> 16; - x += y * w; y += z * x; z += x * y; w += y * z; - return ivec4(int(x), int(y), int(z), int(w)); -} - -ivec4 cultmath_pcg4d(vec4 value) { return cultmath_pcg4d(ivec4(int(floatBitsToUint(value.x)), int(floatBitsToUint(value.y)), int(floatBitsToUint(value.z)), int(floatBitsToUint(value.w)))); } - -// Inigo Quilez, "smooth minimum": quadratic-polynomial smin carried to value-and-gradient form. See -// math.smin_grad's comment (math.cs) for why the gradient blend is exact, not an approximation. -vec4 cultmath_smin_grad(vec4 a, vec4 b, float k) -{ - float h = clamp(0.5 + 0.5 * (b.w - a.w) / k, 0.0, 1.0); - float value = mix(b.w, a.w, h) - k * h * (1.0 - h); - vec3 gradient = mix(b.xyz, a.xyz, h); - return vec4(gradient, value); -} - -// Invariant 8's one struct return shape (design.md, "HLSL Target: Source Transformations"): -// compared field by field and bit for bit against CultMath.CultCellular, same field order. -struct CultCellular -{ - vec4 nearest; - vec4 edge; - float id; -}; - -// Worley, "A Cellular Texture Basis Function" (SIGGRAPH 1996). See math.cellular's comment -// (math.cs) for the hashing, gradient, search-radius exactness proof, id source and -// degenerate-point conventions this mirrors exactly, including the 5x5x5 lower-bound prune. -CultCellular cultmath_cellular(vec3 p) -{ - vec3 cell = floor(p); - float f1 = 1.0e30; - float f2 = 1.0e30; - vec3 c1 = vec3(0.0, 0.0, 0.0); - vec3 c2 = vec3(0.0, 0.0, 0.0); - vec3 cellId = vec3(0.0, 0.0, 0.0); - - for (int dz = -2; dz <= 2; dz++) - { - float lz = max(0.0, abs(float(dz)) - 1.0); - for (int dy = -2; dy <= 2; dy++) - { - float ly = max(0.0, abs(float(dy)) - 1.0); - for (int dx = -2; dx <= 2; dx++) - { - float lx = max(0.0, abs(float(dx)) - 1.0); - float lowerBound = sqrt(lx * lx + ly * ly + lz * lz); - if (lowerBound >= f2) - continue; - - vec3 neighbor = cell + vec3(dx, dy, dz); - ivec3 hash = cultmath_pcg3d(ivec3(neighbor)); - vec3 jitter = vec3( - float(uint(hash.x) >> 8) * (1.0 / 16777216.0), - float(uint(hash.y) >> 8) * (1.0 / 16777216.0), - float(uint(hash.z) >> 8) * (1.0 / 16777216.0)); - vec3 feature = neighbor + jitter; - float d = cultmath_distance(p, feature); - - if (d < f1) - { - f2 = f1; c2 = c1; - f1 = d; c1 = feature; cellId = neighbor; - } - else if (d < f2) - { - f2 = d; c2 = feature; - } - } - } - } - - // F1 = 0 and F2 = 0 share the same degenerate-gradient guard; see math.cellular's comment - // (math.cs) for why F2 = 0 is reachable past roughly |p| = 2^23. - vec3 grad1 = f1 > 0.0 ? (p - c1) / f1 : vec3(0.0, 0.0, 0.0); - vec3 grad2 = f2 > 0.0 ? (p - c2) / f2 : vec3(0.0, 0.0, 0.0); - - // id comes from pcg4d over the winning cell's integer coordinate alone (same int-hashing rule - // as the jitter above), never from the pcg3d hash that produced its jitter (F4). - ivec4 idHash = cultmath_pcg4d(ivec4(ivec3(cellId), 0)); - - CultCellular result; - result.nearest = vec4(grad1, f1); - result.edge = vec4(grad2 - grad1, f2 - f1); - result.id = float(uint(idHash.w) >> 8) * (1.0 / 16777216.0); - return result; -} - - - - -// Interval arithmetic over vec2(lo, hi), lo <= hi, both finite. Every cultmath_iv_* function returns -// an interval containing f(x) for every x in its input intervals, mirroring math.Interval.cs bit for -// bit; see that file and docs/design.md ("Intervals") for each op's enclosure and its ulp widening. -// Included by CultMath.hlsl after its own definitions of cultmath_smoothstep and cultmath_snoise. - -// Lipschitz constant of cultmath_snoise(vec3); provenance in math.Interval.cs (SNOISE_LIPSCHITZ). -const float CULTMATH_SNOISE_LIPSCHITZ = 7.9640074; - -// Lipschitz constant of cultmath_snoise(vec2); provenance in math.Interval.cs (SNOISE2_LIPSCHITZ). -const float CULTMATH_SNOISE2_LIPSCHITZ = 8.117002; - -vec2 cultmath_iv_point(float value) { return vec2(value, value); } -vec2 cultmath_iv_add(vec2 a, vec2 b) { return vec2(a.x + b.x, a.y + b.y); } -vec2 cultmath_iv_sub(vec2 a, vec2 b) { return vec2(a.x - b.y, a.y - b.x); } -vec2 cultmath_iv_neg(vec2 a) { return vec2(-a.y, -a.x); } - -vec2 cultmath_iv_mul(vec2 a, vec2 b) -{ - float p0 = a.x * b.x; - float p1 = a.x * b.y; - float p2 = a.y * b.x; - float p3 = a.y * b.y; - return vec2(min(min(p0, p1), min(p2, p3)), max(max(p0, p1), max(p2, p3))); -} - -vec2 cultmath_iv_scale(vec2 a, float s) { return s >= 0.0 ? vec2(a.x * s, a.y * s) : vec2(a.y * s, a.x * s); } - -vec2 cultmath_iv_abs(vec2 a) -{ - if (a.x >= 0.0) - return a; - if (a.y <= 0.0) - return vec2(-a.y, -a.x); - return vec2(0.0, max(-a.x, a.y)); -} - -vec2 cultmath_iv_min(vec2 a, vec2 b) { return vec2(min(a.x, b.x), min(a.y, b.y)); } -vec2 cultmath_iv_max(vec2 a, vec2 b) { return vec2(max(a.x, b.x), max(a.y, b.y)); } - -vec2 cultmath_iv_sqr(vec2 a) -{ - float l = a.x * a.x; - float h = a.y * a.y; - if (a.x >= 0.0) - return vec2(l, h); - if (a.y <= 0.0) - return vec2(h, l); - return vec2(0.0, max(l, h)); -} - -vec2 cultmath_iv_sqrt(vec2 a) { return vec2(sqrt(max(a.x, 0.0)), sqrt(max(a.y, 0.0))); } - -// Widened by one ulp on each side: exp is not required to be correctly rounded. -vec2 cultmath_iv_exp(vec2 a) -{ - float lo = exp(a.x); - float hi = exp(a.y); - return vec2(lo > 0.0 ? uintBitsToFloat(floatBitsToUint(lo) - 1u) : 0.0, uintBitsToFloat(floatBitsToUint(hi) + 1u)); -} - -vec2 cultmath_iv_clamp(vec2 a, float minimum, float maximum) -{ - return vec2(cultmath_clamp(a.x, minimum, maximum), cultmath_clamp(a.y, minimum, maximum)); -} - -vec2 cultmath_iv_saturate(vec2 a) { return vec2(cultmath_saturate(a.x), cultmath_saturate(a.y)); } - -// The endpoints, ordered, widened by one ulp inside [0, 1]: the float32 evaluation of smoothstep is -// monotone only to within one ulp. -vec2 cultmath_iv_smoothstep(float minimum, float maximum, vec2 a) -{ - float s0 = cultmath_smoothstep(minimum, maximum, a.x); - float s1 = cultmath_smoothstep(minimum, maximum, a.y); - float lo = min(s0, s1); - float hi = max(s0, s1); - return vec2(lo > 0.0 ? uintBitsToFloat(floatBitsToUint(lo) - 1u) : 0.0, hi < 1.0 ? uintBitsToFloat(floatBitsToUint(hi) + 1u) : 1.0); -} - -// The natural interval extension of x + (y - x) * amount, which is how cultmath_lerp evaluates. -vec2 cultmath_iv_lerp(vec2 a, vec2 b, float amount) { return cultmath_iv_add(a, cultmath_iv_scale(cultmath_iv_sub(b, a), amount)); } - -// [n - L r, n + L r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -vec2 cultmath_iv_snoise_ball(vec3 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE_LIPSCHITZ * radius; - return vec2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// The 2D overload: [n - L2 r, n + L2 r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -vec2 cultmath_iv_snoise_ball(vec2 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE2_LIPSCHITZ * radius; - return vec2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// Octave sum of cultmath_iv_snoise_ball, compounding frequency and amplitude as the value-and-gradient fBm does. -vec2 cultmath_iv_fbm_ball(vec3 centre, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - vec2 sum = vec2(0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_iv_add(sum, cultmath_iv_scale(cultmath_iv_snoise_ball(centre * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// A ball (xyz centre, w radius) enclosing every point of every ray of a screen tile over the depth segment -// [z0, z1], warped by at most warp. Camera frame: pinhole at the origin looking down +z, ray (m z, z). -// footprintPerDepth = N / (sqrt(2) f) for an N x N tile at focal length f. The radius is widened by -// (|c|_1 + radius) 2^-20, which covers the ball's own float32 rounding. Derivation in math.Interval.cs. -vec4 cultmath_iv_frustum_ball(vec2 centreSlope, float z0, float z1, float footprintPerDepth, float warp) -{ - float zm = (z0 + z1) * 0.5; - float axis = sqrt(centreSlope.x * centreSlope.x + centreSlope.y * centreSlope.y + 1.0); - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float radius = (z1 - z0) * 0.5 * axis + z1 * footprintPerDepth + warp; - radius += (abs(cx) + abs(cy) + abs(zm) + radius) * 9.5367431640625e-7; - return vec4(cx, cy, zm, radius); -} - - - - - - -// Reduced affine forms with one shared symbol over vec3(x0, a, e): the set { x0 + a eps + e delta : -// delta in [-1, 1] } at the region's shared eps in [-1, 1], e >= 0. Every cultmath_af_* function mirrors -// math.Affine.cs bit for bit; see that file and docs/design.md ("Affine forms") for each op's enclosure -// and the float32 rounding allowance it folds into e. Included by CultMath.hlsl after -// CultMath.Interval.hlsl, whose CULTMATH_SNOISE_LIPSCHITZ it shares, and after its own -// definition of cultmath_snoise_grad. - -// An upper bound on the spectral norm of the Hessian of cultmath_snoise(vec3); provenance in -// math.Affine.cs (SNOISE_HESSIAN). -const float CULTMATH_SNOISE_HESSIAN = 56.050385; - -vec3 cultmath_af_point(float value) { return vec3(value, 0.0, 0.0); } -vec3 cultmath_af_symbol(float x0, float a) { return vec3(x0, a, 0.0); } - -vec3 cultmath_af_from_iv(vec2 interval) -{ - float x0 = interval.x * 0.5 + interval.y * 0.5; - float e = interval.y * 0.5 - interval.x * 0.5; - return vec3(x0, 0.0, e + (abs(x0) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// An endpoint that would be NaN is the infinity on its side. NaN is found by its bit pattern: dxc marks -// compares fast, so a test that needs NaN to make `lo == lo` false is deleted under its default flags. -vec2 cultmath_af_range(vec3 x) -{ - float r = abs(x.y) + x.z; - float w = abs(x.x) * 9.5367431640625e-7 + r * 9.5367431640625e-7; - float lo = x.x - r - w; - float hi = x.x + r + w; - return vec2((floatBitsToUint(lo) & 0x7fffffffu) > 0x7f800000u ? uintBitsToFloat(0xff800000u) : lo, - (floatBitsToUint(hi) & 0x7fffffffu) > 0x7f800000u ? uintBitsToFloat(0x7f800000u) : hi); -} - -vec3 cultmath_af_add(vec3 x, vec3 y) -{ - float x0 = x.x + y.x; - float a = x.y + y.y; - float e = x.z + y.z; - return vec3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -vec3 cultmath_af_sub(vec3 x, vec3 y) -{ - float x0 = x.x - y.x; - float a = x.y - y.y; - float e = x.z + y.z; - return vec3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -vec3 cultmath_af_neg(vec3 x) { return vec3(-x.x, -x.y, x.z); } - -vec3 cultmath_af_scale(vec3 x, float s) -{ - float x0 = x.x * s; - float a = x.y * s; - float e = x.z * abs(s); - return vec3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -vec3 cultmath_af_add_iv(vec3 x, vec2 interval) { return cultmath_af_add(x, cultmath_af_from_iv(interval)); } - -vec3 cultmath_af_mul(vec3 x, vec3 y) -{ - float x0 = x.x * y.x; - float p = x.x * y.y; - float q = y.x * x.y; - float a = p + q; - float e = abs(x.x) * y.z + abs(y.x) * x.z + (abs(x.y) + x.z) * (abs(y.y) + y.z); - return vec3(x0, a, e + (abs(x0) + abs(p) + abs(q) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// The narrower of the Lipschitz form and the centred (Taylor) form over every p = centre + axis eps + w, -// |w| <= radius, from one cultmath_snoise_grad at the centre; the allowance for the float32 evaluation is -// in math.Affine.cs. -vec3 cultmath_af_snoise(vec3 centre, vec3 axis, float radius) -{ - vec4 g = cultmath_snoise_grad(centre); - vec3 gradient = vec3(g.x, g.y, g.z); - float reach = length(axis) + radius; - float lipschitz = CULTMATH_SNOISE_LIPSCHITZ * reach; - float a = dot(gradient, axis); - float remainder = length(gradient) * radius + 0.5 * CULTMATH_SNOISE_HESSIAN * reach * reach; - float allowance = 6.103515625e-5 + 2.44140625e-4 * reach - + CULTMATH_SNOISE_LIPSCHITZ * 9.5367431640625e-7 * (abs(centre.x) + abs(centre.y) + abs(centre.z) + reach); - bool centred = abs(a) + remainder < lipschitz; - float slope = centred ? a : 0.0; - float e = (centred ? remainder : lipschitz) + allowance; - return vec3(g.w, slope, e + (abs(g.w) + abs(slope) + e) * 9.5367431640625e-7); -} - -// Octave sum of cultmath_af_snoise, compounding frequency and amplitude as the value-and-gradient fBm does. -vec3 cultmath_af_fbm(vec3 centre, vec3 axis, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - vec3 sum = vec3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_af_add(sum, cultmath_af_scale(cultmath_af_snoise(centre * frequency, axis * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// The axis of a screen tile's slice over the depth segment [z0, z1]; camera frame of -// cultmath_iv_frustum_ball. -vec3 cultmath_af_frustum_axis(vec2 centreSlope, float z0, float z1) -{ - float h = (z1 - z0) * 0.5; - return vec3(centreSlope.x * h, centreSlope.y * h, h); -} - -// The affine slice of a screen tile over [z0, z1]: centre xyz, radius w. Derivation in math.Affine.cs. -vec4 cultmath_af_frustum_ball(vec2 centreSlope, float z0, float z1, float footprintPerDepth, float warpVariation) -{ - float zm = (z0 + z1) * 0.5; - float h = (z1 - z0) * 0.5; - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float spread = (abs(centreSlope.x) + abs(centreSlope.y) + 1.0) * h; - float radius = z1 * footprintPerDepth + warpVariation; - radius += (abs(cx) + abs(cy) + abs(zm) + spread + radius) * 9.5367431640625e-7; - return vec4(cx, cy, zm, radius); -} - - - - -float cultmath_value_noise(vec2 position) -{ - vec2 cell = floor(position); - vec2 local = cultmath_frac(position); - vec2 u = local * local * (vec2(3.0, 3.0) - vec2(2.0, 2.0) * local); - - float a = cultmath_hash(cell); - float b = cultmath_hash(cell + vec2(1.0, 0.0)); - float c = cultmath_hash(cell + vec2(0.0, 1.0)); - float d = cultmath_hash(cell + vec2(1.0, 1.0)); - - return cultmath_lerp(cultmath_lerp(a, b, u.x), cultmath_lerp(c, d, u.x), u.y); -} - -float cultmath_value_noise_bicubic(vec2 position) -{ - vec2 cell = floor(position); - vec2 local = cultmath_frac(position); - - float y0 = cultmath_catmullrom(cultmath_hash(cell + vec2(-1.0, -1.0)), cultmath_hash(cell + vec2(0.0, -1.0)), cultmath_hash(cell + vec2(1.0, -1.0)), cultmath_hash(cell + vec2(2.0, -1.0)), local.x); - float y1 = cultmath_catmullrom(cultmath_hash(cell + vec2(-1.0, 0.0)), cultmath_hash(cell + vec2(0.0, 0.0)), cultmath_hash(cell + vec2(1.0, 0.0)), cultmath_hash(cell + vec2(2.0, 0.0)), local.x); - float y2 = cultmath_catmullrom(cultmath_hash(cell + vec2(-1.0, 1.0)), cultmath_hash(cell + vec2(0.0, 1.0)), cultmath_hash(cell + vec2(1.0, 1.0)), cultmath_hash(cell + vec2(2.0, 1.0)), local.x); - float y3 = cultmath_catmullrom(cultmath_hash(cell + vec2(-1.0, 2.0)), cultmath_hash(cell + vec2(0.0, 2.0)), cultmath_hash(cell + vec2(1.0, 2.0)), cultmath_hash(cell + vec2(2.0, 2.0)), local.x); - - return cultmath_catmullrom(y0, y1, y2, y3, local.y); -} - -#endif diff --git a/packages/cultmath/shaders/CultMath.hlsl b/packages/cultmath/shaders/CultMath.hlsl index 6856a000..365705f5 100644 --- a/packages/cultmath/shaders/CultMath.hlsl +++ b/packages/cultmath/shaders/CultMath.hlsl @@ -11,6 +11,7 @@ static const float CULTMATH_PI = 3.14159265358979323846; static const float CULTMATH_TAU = 6.28318530717958647692; static const float CULTMATH_HALF_PI = 1.57079632679489661923; +static const float CULTMATH_NORMALIZE_EPSILON = 1.0e-20; float cultmath_radians(float degrees_value) { return degrees_value * (CULTMATH_PI / 180.0); } float cultmath_degrees(float radians_value) { return radians_value * (180.0 / CULTMATH_PI); } @@ -76,18 +77,17 @@ float cultmath_smootherstep(float value) float2 cultmath_snoise_mod289(float2 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } float3 cultmath_snoise_mod289(float3 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } float4 cultmath_snoise_mod289(float4 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } -float3 cultmath_snoise_permute(float3 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } -float4 cultmath_snoise_permute(float4 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } +float3 cultmath_snoise_permute(float3 value) { return cultmath_snoise_mod289(((value * 34.0) + 1.0) * value); } +float4 cultmath_snoise_permute(float4 value) { return cultmath_snoise_mod289(((value * 34.0) + 1.0) * value); } // Ashima Arts / Ian McEwan 3D simplex noise (MIT), same float32 evaluation -// order as the C# math.snoise(float3) mirror. Ties resolve in simplexnoise1234's -// total order; see math.snoise. +// order as the C# math.snoise(float3) mirror. float cultmath_snoise(float3 value) { float2 c = float2(1.0 / 6.0, 1.0 / 3.0); float3 i = floor(value + dot(value, c.yyy)); float3 x0 = value - i + dot(i, c.xxx); - float3 g = float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); + float3 g = step(x0.yzx, x0.xyz); float3 l = 1.0 - g; float3 i1 = min(g.xyz, l.zxy); float3 i2 = max(g.xyz, l.zxy); @@ -112,7 +112,7 @@ float cultmath_snoise(float3 value) float4 b1 = float4(x.zw, y.zw); float4 s0 = floor(b0) * 2.0 + 1.0; float4 s1 = floor(b1) * 2.0 + 1.0; - float4 sh = -step(h, float4(0.0, 0.0, 0.0, 0.0)); + float4 sh = -step(h, 0.0); float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; @@ -126,9 +126,9 @@ float cultmath_snoise(float3 value) p2 *= norm.z; p3 *= norm.w; - float4 m = max(0.5 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); + float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); m = m * m; - return 105.0 * dot(m * m, float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); + return 42.0 * dot(m * m, float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); } float cultmath_snoise(float2 value) @@ -163,114 +163,6 @@ float cultmath_snoise(float2 value) return 130.0 * dot(m, g); } -// Analytic gradient of cultmath_snoise(float3) (invariant 8), following webgl-noise -// src/noise3Dgrad.glsl (Ashima Arts / McEwan, MIT); same kernel, permutation and scale as -// cultmath_snoise(float3) (stegu/webgl-noise 22434e04d7). See the C# math.snoise_grad comment for the -// derivation. Every local up through p0..p3 and x0..x3 is cultmath_snoise(float3)'s own derivation -// verbatim. -float4 cultmath_snoise_grad(float3 value) -{ - float2 c = float2(1.0 / 6.0, 1.0 / 3.0); - float3 i = floor(value + dot(value, c.yyy)); - float3 x0 = value - i + dot(i, c.xxx); - float3 g = float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); - float3 l = 1.0 - g; - float3 i1 = min(g.xyz, l.zxy); - float3 i2 = max(g.xyz, l.zxy); - float3 x1 = x0 - i1 + c.xxx; - float3 x2 = x0 - i2 + c.yyy; - float3 x3 = x0 - 0.5; - - i = cultmath_snoise_mod289(i); - float4 p = cultmath_snoise_permute(cultmath_snoise_permute(cultmath_snoise_permute( - i.z + float4(0.0, i1.z, i2.z, 1.0)) + i.y + float4(0.0, i1.y, i2.y, 1.0)) + i.x + float4(0.0, i1.x, i2.x, 1.0)); - - const float n_ = 0.142857142857; - float3 ns = float3(2.0 * n_, 0.5 * n_ - 1.0, n_); - float4 j = p - 49.0 * floor(p * ns.z * ns.z); - float4 x_ = floor(j * ns.z); - float4 y_ = floor(j - 7.0 * x_); - float4 x = x_ * ns.x + ns.yyyy; - float4 y = y_ * ns.x + ns.yyyy; - float4 h = 1.0 - abs(x) - abs(y); - - float4 b0 = float4(x.xy, y.xy); - float4 b1 = float4(x.zw, y.zw); - float4 s0 = floor(b0) * 2.0 + 1.0; - float4 s1 = floor(b1) * 2.0 + 1.0; - float4 sh = -step(h, float4(0.0, 0.0, 0.0, 0.0)); - float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; - float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; - - float3 p0 = float3(a0.xy, h.x); - float3 p1 = float3(a0.zw, h.y); - float3 p2 = float3(a1.xy, h.z); - float3 p3 = float3(a1.zw, h.w); - float4 norm = 1.79284291400159 - 0.85373472095314 * float4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - float4 m0 = max(0.5 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); - float4 m2 = m0 * m0; - float4 m3 = m2 * m0; - float4 m4 = m2 * m2; - - float4 px = float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)); - float value2 = 105.0 * dot(m4, px); - float3 grad = -8.0 * m3.x * x0 * px.x + m4.x * p0 - + -8.0 * m3.y * x1 * px.y + m4.y * p1 - + -8.0 * m3.z * x2 * px.z + m4.z * p2 - + -8.0 * m3.w * x3 * px.w + m4.w * p3; - grad *= 105.0; - - return float4(grad, value2); -} - -// Octave sum of cultmath_snoise_grad (invariant 8); see the C# math.fbm_grad comment for the -// per-octave frequency/amplitude derivation and why octaves is clamped. -float4 cultmath_fbm_grad(float3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - float3 gradient = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - float4 n = cultmath_snoise_grad(p * frequency); - value += amplitude * n.w; - gradient += amplitude * frequency * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return float4(gradient, value); -} - -// Ridged multifractal noise (Musgrave, Texturing and Modeling, ch. 16); see the C# math.ridged_grad -// comment for the fold/sign derivation, the deliberate crease at n = 0, and why octaves is clamped. -float4 cultmath_ridged_grad(float3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - float3 gradient = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - float4 n = cultmath_snoise_grad(p * frequency); - float s = sign(n.w); - value += amplitude * (1.0 - abs(n.w)); - gradient += -amplitude * frequency * s * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return float4(gradient, value); -} - float cultmath_lengthsq(float2 value) { return dot(value, value); } float cultmath_lengthsq(float3 value) { return dot(value, value); } float cultmath_lengthsq(float4 value) { return dot(value, value); } @@ -279,6 +171,10 @@ float cultmath_distance(float2 left, float2 right) { return length(left - right) float cultmath_distance(float3 left, float3 right) { return length(left - right); } float cultmath_distance(float4 left, float4 right) { return length(left - right); } +float2 cultmath_normalize(float2 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } +float3 cultmath_normalize(float3 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } +float4 cultmath_normalize(float4 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } + float2 cultmath_reflect(float2 incident, float2 normal_value) { return incident - 2.0 * dot(normal_value, incident) * normal_value; @@ -317,20 +213,17 @@ float cultmath_damp(float start, float end, float lambda_value, float dt) float2 cultmath_damp(float2 start, float2 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float2(amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float3 cultmath_damp(float3 start, float3 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float3(amount, amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float4 cultmath_damp(float4 start, float4 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float4(amount, amount, amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float cultmath_catmullrom(float p0, float p1, float p2, float p3, float t) @@ -393,124 +286,6 @@ float cultmath_hash(float value) { return cultmath_frac(sin(value) * 43758.5453) float cultmath_hash(float2 value) { return cultmath_hash(dot(value, float2(127.1, 311.7))); } float cultmath_hash(float3 value) { return cultmath_hash(dot(value, float3(127.1, 311.7, 74.7))); } -// PCG hashes (Jarzynski and Olano, JCGT 2020), written over scalar uints so CultMath's int3/int4 carry the bits. -uint cultmath_pcg(uint value) -{ - uint state = value * 747796405u + 2891336453u; - uint word = ((state >> (int)((state >> 28) + 4u)) ^ state) * 277803737u; - return (word >> 22) ^ word; -} - -int3 cultmath_pcg3d(int3 value) -{ - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u, z = (uint)value.z * 1664525u + 1013904223u; - x += y * z; y += z * x; z += x * y; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; - x += y * z; y += z * x; z += x * y; - return int3((int)x, (int)y, (int)z); -} - -int3 cultmath_pcg3d(float3 value) { return cultmath_pcg3d(int3((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z))); } -int3 cultmath_pcg3d(float2 value) { return cultmath_pcg3d(float3(value, 0.0)); } - -int4 cultmath_pcg4d(int4 value) -{ - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u; - uint z = (uint)value.z * 1664525u + 1013904223u, w = (uint)value.w * 1664525u + 1013904223u; - x += y * w; y += z * x; z += x * y; w += y * z; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; w ^= w >> 16; - x += y * w; y += z * x; z += x * y; w += y * z; - return int4((int)x, (int)y, (int)z, (int)w); -} - -int4 cultmath_pcg4d(float4 value) { return cultmath_pcg4d(int4((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z), (int)asuint(value.w))); } - -// Inigo Quilez, "smooth minimum": quadratic-polynomial smin carried to value-and-gradient form. See -// math.smin_grad's comment (math.cs) for why the gradient blend is exact, not an approximation. -float4 cultmath_smin_grad(float4 a, float4 b, float k) -{ - float h = saturate(0.5 + 0.5 * (b.w - a.w) / k); - float value = lerp(b.w, a.w, h) - k * h * (1.0 - h); - float3 gradient = lerp(b.xyz, a.xyz, h); - return float4(gradient, value); -} - -// Invariant 8's one struct return shape (design.md, "HLSL Target: Source Transformations"): -// compared field by field and bit for bit against CultMath.CultCellular, same field order. -struct CultCellular -{ - float4 nearest; - float4 edge; - float id; -}; - -// Worley, "A Cellular Texture Basis Function" (SIGGRAPH 1996). See math.cellular's comment -// (math.cs) for the hashing, gradient, search-radius exactness proof, id source and -// degenerate-point conventions this mirrors exactly, including the 5x5x5 lower-bound prune. -CultCellular cultmath_cellular(float3 p) -{ - float3 cell = floor(p); - float f1 = 1.0e30; - float f2 = 1.0e30; - float3 c1 = float3(0.0, 0.0, 0.0); - float3 c2 = float3(0.0, 0.0, 0.0); - float3 cellId = float3(0.0, 0.0, 0.0); - - for (int dz = -2; dz <= 2; dz++) - { - float lz = max(0.0, abs((float)dz) - 1.0); - for (int dy = -2; dy <= 2; dy++) - { - float ly = max(0.0, abs((float)dy) - 1.0); - for (int dx = -2; dx <= 2; dx++) - { - float lx = max(0.0, abs((float)dx) - 1.0); - float lowerBound = sqrt(lx * lx + ly * ly + lz * lz); - if (lowerBound >= f2) - continue; - - float3 neighbor = cell + float3(dx, dy, dz); - int3 hash = cultmath_pcg3d(int3(neighbor)); - float3 jitter = float3( - (float)((uint)hash.x >> 8) * (1.0 / 16777216.0), - (float)((uint)hash.y >> 8) * (1.0 / 16777216.0), - (float)((uint)hash.z >> 8) * (1.0 / 16777216.0)); - float3 feature = neighbor + jitter; - float d = cultmath_distance(p, feature); - - if (d < f1) - { - f2 = f1; c2 = c1; - f1 = d; c1 = feature; cellId = neighbor; - } - else if (d < f2) - { - f2 = d; c2 = feature; - } - } - } - } - - // F1 = 0 and F2 = 0 share the same degenerate-gradient guard; see math.cellular's comment - // (math.cs) for why F2 = 0 is reachable past roughly |p| = 2^23. - float3 grad1 = f1 > 0.0 ? (p - c1) / f1 : float3(0.0, 0.0, 0.0); - float3 grad2 = f2 > 0.0 ? (p - c2) / f2 : float3(0.0, 0.0, 0.0); - - // id comes from pcg4d over the winning cell's integer coordinate alone (same int-hashing rule - // as the jitter above), never from the pcg3d hash that produced its jitter (F4). - int4 idHash = cultmath_pcg4d(int4(int3(cellId), 0)); - - CultCellular result; - result.nearest = float4(grad1, f1); - result.edge = float4(grad2 - grad1, f2 - f1); - result.id = (float)((uint)idHash.w >> 8) * (1.0 / 16777216.0); - return result; -} - -#include "CultMath.Phacelle.hlsl" -#include "CultMath.Interval.hlsl" -#include "CultMath.Affine.hlsl" - float cultmath_value_noise(float2 position) { float2 cell = floor(position); diff --git a/packages/cultmath/src/CultMath/BoundedLeastSquares.cs b/packages/cultmath/src/CultMath/BoundedLeastSquares.cs deleted file mode 100644 index 2d31620e..00000000 --- a/packages/cultmath/src/CultMath/BoundedLeastSquares.cs +++ /dev/null @@ -1,395 +0,0 @@ -using System.Runtime.InteropServices; - -namespace CultMath; - -/// Outcome of a solve. -public enum BoundedLeastSquaresStatus -{ - /// The KKT conditions hold: every free variable has zero gradient and every bound has a gradient pointing into it. - Converged, - - /// The iteration cap was reached. x holds the last feasible iterate, which is never worse than the clamped start. - IterationLimit, - - /// The input broke the contract; nothing was solved and x is exactly as passed. - InvalidInput, -} - -/// -/// Dense bounded least squares: min ||A x - b||^2 subject to lo <= x <= hi, for small problems -/// (tens of rows and columns). C#-only, like the intercept helpers in ; there is no HLSL mirror. -/// -/// -/// Primal active set. Each iteration solves the free variables by Cholesky on the normal equations, takes the -/// step to the first bound it would cross, and, once a full step lands, releases the bound with the most -/// violated gradient sign. Free columns that are linearly dependent on earlier free columns (a zero column, a -/// duplicate) get a zero step instead of a failed pivot, so a singular free set never throws. -/// -/// Precision. A, b and x are float at the API; everything else, including the working iterate, the -/// gradient and the KKT test, is double, carved from the caller's workspace. x is converted in at the start -/// and back out at the end, so a returned float x is the nearest float to the double solution and always -/// inside the box. -/// -/// -/// Stopping. KKT termination uses a tolerance of (1e-6) times the problem's -/// gradient scale (the largest gradient component at the box point nearest the origin), so scaling A, b or the -/// bounds, and the choice of warm start, do not change it. A caller whose rows span many decades of weight can pass -/// a smaller kktRelativeTolerance, which changes only this tolerance: the rounding bound and progress rule -/// below and the pivot threshold are fixed. A bound is released only when its violation exceeds both the tolerance -/// and the rounding bound of its double gradient, so a tolerance below the noise cannot cycle on a release. The -/// tolerance is otherwise only a resolution: once a stationarity miss that releases nothing has been followed by a -/// pass that lowers the cost by no more than rounding, the solver reports -/// , so a free set whose residual is rounding costs one confirming -/// iteration rather than the iteration cap. A pass that releases a bound is never judged by the cost. -/// -/// -/// Near-singular problems. The normal equations square the condition number, so the cost gap grows with cond(A) -/// (measured: below 1e-6 of |b|^2 through cond(A) 3e5, about 2e-5 at 1e6; the gap is relative to |b|^2), independent of the absolute scale of A. -/// The solver owns optimality up to that range. Columns whose pivot falls below 1e-12 of their own diagonal (cond(A) -/// beyond roughly 1e6) are treated as dependent and not moved, so the answer there is one optimum among many, not the -/// minimum-norm one. Callers beyond that range, or that need the minimum-norm answer, add a small ridge row to -/// A and b; that stays the caller's policy. -/// -/// The solver allocates nothing and is deterministic. -/// -/// Input contract: kktRelativeTolerance must be finite and greater than zero; a and b must be finite; lo and hi must not be NaN and need -/// lo <= hi. Infinite bounds are allowed and mean unbounded on that side (lo = -Inf, -/// hi = +Inf); lo = +Inf or hi = -Inf is invalid. Any violation returns -/// without throwing, with iterations 0 and -/// x exactly as passed. A NaN or infinite warm start is legal: it is clamped into the box (an infinite -/// result on an unbounded side becomes 0 clamped to the box). Spans shorter than the stated dimensions are a -/// caller bug and throw . -/// -/// -public static class BoundedLeastSquares -{ - /// Default iteration cap for Solve. - public const int DefaultMaxIterations = 100; - - /// Default KKT tolerance, relative to the gradient scale; see Stopping in the type remarks. - public const double DefaultKktRelativeTolerance = 1e-6; - - private const double PivotRelativeTolerance = 1e-12; - private const double StallRelativeTolerance = 1e-15; - - /// Floats of caller-supplied workspace needed for columns. - public static int WorkspaceLength(int n) => 2 * (2 * n * n + 6 * n) + 3 * n; - - /// - /// Minimises ||A x - b||^2 subject to lo <= x <= hi. is the warm start - /// on entry (clamped to the box first) and the result on exit. - /// - /// Rows of . - /// Columns of , and length of , and . - /// Row-major m * n matrix. - /// Length m target. - /// Lower bounds; each must be <= hi; -Inf means unbounded below. - /// Upper bounds; +Inf means unbounded above. - /// Warm start in, solution out. - /// At least floats; contents on entry are ignored. - /// Active-set iterations used. - /// Iteration cap. - public static BoundedLeastSquaresStatus Solve( - int m, int n, - ReadOnlySpan a, ReadOnlySpan b, - ReadOnlySpan lo, ReadOnlySpan hi, - Span x, Span workspace, - out int iterations, - int maxIterations = DefaultMaxIterations) - => Solve(m, n, a, b, lo, hi, x, workspace, out iterations, DefaultKktRelativeTolerance, maxIterations); - - /// - /// Minimises ||A x - b||^2 subject to lo <= x <= hi. is the warm start - /// on entry (clamped to the box first) and the result on exit. is the - /// stationarity resolution relative to the gradient scale defined under Stopping; the overload without it passes - /// and gives the same result. - /// - /// Rows of . - /// Columns of , and length of , and . - /// Row-major m * n matrix. - /// Length m target. - /// Lower bounds; each must be <= hi; -Inf means unbounded below. - /// Upper bounds; +Inf means unbounded above. - /// Warm start in, solution out. - /// At least floats; contents on entry are ignored. - /// Active-set iterations used. - /// Finite and greater than zero, else . Tighten it when rows span many decades of weight; releases below the gradient's rounding bound are not taken, and free-set residuals at rounding level end on the progress rule. - /// Iteration cap. - public static BoundedLeastSquaresStatus Solve( - int m, int n, - ReadOnlySpan a, ReadOnlySpan b, - ReadOnlySpan lo, ReadOnlySpan hi, - Span x, Span workspace, - out int iterations, - double kktRelativeTolerance, - int maxIterations = DefaultMaxIterations) - { - if (m < 0 || n < 0 || a.Length < m * n || b.Length < m || lo.Length < n || hi.Length < n - || x.Length < n || workspace.Length < WorkspaceLength(n)) - throw new ArgumentException("BoundedLeastSquares: span shorter than the stated dimensions."); - - // Double-precision vectors and matrices first, then the integer flags, all carved from the caller's floats. - var doubleCount = 2 * n * n + 6 * n; - var dbl = MemoryMarshal.Cast(workspace.Slice(0, 2 * doubleCount)); - var ata = Take(ref dbl, n * n); - var chol = Take(ref dbl, n * n); - var atb = Take(ref dbl, n); - var g = Take(ref dbl, n); - var p = Take(ref dbl, n); - var y = Take(ref dbl, n); - var rhs = Take(ref dbl, n); - var xd = Take(ref dbl, n); - // One flag per column: 0 free, -1 at lo, +1 at hi. Free-list and dependency flags follow. - var ints = MemoryMarshal.Cast(workspace.Slice(2 * doubleCount, 3 * n)); - var state = Take(ref ints, n); - var freeIndex = Take(ref ints, n); - var dependent = Take(ref ints, n); - - iterations = 0; - if (!(kktRelativeTolerance > 0.0) || double.IsPositiveInfinity(kktRelativeTolerance)) - return BoundedLeastSquaresStatus.InvalidInput; - for (var j = 0; j < n; j++) - if (!(lo[j] <= hi[j]) || float.IsPositiveInfinity(lo[j]) || float.IsNegativeInfinity(hi[j])) - return BoundedLeastSquaresStatus.InvalidInput; - - // A float is never large enough to overflow a double product or a sum of tens of them, so a non-finite - // A^T b entry is exactly a non-finite entry of A or b (NaN and infinity never cancel to a finite value). - for (var j = 0; j < n; j++) - { - var sb = 0.0; - for (var r = 0; r < m; r++) - sb += (double)a[r * n + j] * b[r]; - if (!double.IsFinite(sb)) - return BoundedLeastSquaresStatus.InvalidInput; - atb[j] = sb; - for (var k = 0; k <= j; k++) - { - var sa = 0.0; - for (var r = 0; r < m; r++) - sa += (double)a[r * n + j] * a[r * n + k]; - ata[j * n + k] = sa; - ata[k * n + j] = sa; - } - } - - // From here x is written. A warm start that is NaN is moved to the lower bound, and an infinite result - // (an unbounded side) restarts from 0 clamped to the box. The working iterate lives in double; x is only - // the API's float view of it. - for (var j = 0; j < n; j++) - { - var l = lo[j]; - var h = hi[j]; - var v = float.IsNaN(x[j]) ? l : Math.Clamp(x[j], l, h); - if (float.IsInfinity(v)) - v = Math.Clamp(0f, l, h); - x[j] = v; - xd[j] = v; - state[j] = v == l ? -1 : (v == h ? 1 : 0); - } - - // The tolerance's scale is the gradient magnitude at the box point nearest the origin (the origin itself - // when it is inside the box, where the gradient is -A^T b). It depends on A, b and the bounds, never on the - // warm start, so a far start cannot be judged converged by its own steepness, and b = 0 with a box that - // excludes the origin still gets a real scale. It is zero only when that point is already stationary, and - // then the progress rule below does the stopping. - var gScale = 0.0; - for (var j = 0; j < n; j++) - { - var s = -atb[j]; - for (var k = 0; k < n; k++) - s += ata[j * n + k] * Math.Clamp(0.0, lo[k], hi[k]); - gScale = Math.Max(gScale, Math.Abs(s)); - } - var kktTol = kktRelativeTolerance * gScale; - - // Cost at the last point from which the solver continued past a stationarity miss with no release; a - // release resets it. A stationarity miss that ends without lowering it has nothing left to gain: the - // tolerance is a resolution, not the stopping rule, and a noise floor above it must not spin to the cap. - var fMark = double.PositiveInfinity; - var status = BoundedLeastSquaresStatus.IterationLimit; - while (true) - { - Gradient(ata, atb, xd, g, n); - - var freeCount = 0; - for (var j = 0; j < n; j++) - if (state[j] == 0) - freeIndex[freeCount++] = j; - SolveFreeSet(ata, chol, g, p, y, rhs, freeIndex.Slice(0, freeCount), dependent, n); - - var t = 1.0; - var block = -1; - for (var i = 0; i < freeCount; i++) - { - var j = freeIndex[i]; - var pj = p[j]; - if (pj == 0.0) continue; - var tj = pj > 0.0 ? (hi[j] - xd[j]) / pj : (lo[j] - xd[j]) / pj; - if (tj < t) - { - t = tj; - block = j; - } - } - - if (block >= 0) - { - if (iterations >= maxIterations) { status = BoundedLeastSquaresStatus.IterationLimit; break; } - iterations++; - for (var i = 0; i < freeCount; i++) - { - var j = freeIndex[i]; - xd[j] = Math.Clamp(xd[j] + t * p[j], lo[j], hi[j]); - } - if (p[block] > 0.0) { xd[block] = hi[block]; state[block] = 1; } - else { xd[block] = lo[block]; state[block] = -1; } - continue; - } - - for (var i = 0; i < freeCount; i++) - { - var j = freeIndex[i]; - xd[j] = Math.Clamp(xd[j] + p[j], lo[j], hi[j]); - } - Gradient(ata, atb, xd, g, n); - - // Stationarity of the free set is part of KKT: a Newton step on a near-singular free set can leave a residual gradient. - var freeViolated = false; - for (var i = 0; i < freeCount; i++) - if (Math.Abs(g[freeIndex[i]]) > kktTol) - freeViolated = true; - - var release = -1; - var worst = kktTol; - for (var j = 0; j < n; j++) - { - if (lo[j] == hi[j]) continue; - // A bound at lo wants a positive gradient and one at hi a negative one; a free column has state 0. - var violation = state[j] * g[j]; - if (violation > worst && violation > ReleaseNoise(ata, atb, xd, j, n)) - { - worst = violation; - release = j; - } - } - if (release < 0 && !freeViolated) { status = BoundedLeastSquaresStatus.Converged; break; } - - if (release < 0) - { - var f = Objective(xd, g, atb, n, out var fScale); - if (f >= fMark - StallRelativeTolerance * fScale) { status = BoundedLeastSquaresStatus.Converged; break; } - fMark = f; - } - else - fMark = double.PositiveInfinity; - if (iterations >= maxIterations) { status = BoundedLeastSquaresStatus.IterationLimit; break; } - iterations++; - // A stationarity miss re-solves the same free set from the improved point. - if (release >= 0) state[release] = 0; - } - - for (var j = 0; j < n; j++) - x[j] = (float)xd[j]; - return status; - } - - private static Span Take(ref Span pool, int length) - { - var head = pool.Slice(0, length); - pool = pool.Slice(length); - return head; - } - - // 0.5 x^T A^T A x - x^T A^T b (the cost up to a constant), from the gradient at x; scale is the magnitude of - // the terms summed, which is what the rounding error of the sum is proportional to. - private static double Objective(ReadOnlySpan x, ReadOnlySpan g, ReadOnlySpan atb, int n, out double scale) - { - var f = 0.0; - scale = 0.0; - for (var j = 0; j < n; j++) - { - f += 0.5 * x[j] * (g[j] - atb[j]); - scale += 0.5 * Math.Abs(x[j]) * (Math.Abs(g[j]) + Math.Abs(atb[j])); - } - return f; - } - - // Rounding bound of the double gradient component j: gamma_(n+1) (Higham, inner products) times the magnitude of its terms. - private static double ReleaseNoise(ReadOnlySpan ata, ReadOnlySpan atb, ReadOnlySpan x, int j, int n) - { - var s = Math.Abs(atb[j]); - for (var k = 0; k < n; k++) s += Math.Abs(ata[j * n + k] * x[k]); - return (n + 1) * 2.220446049250313e-16 * s; - } - - private static void Gradient(ReadOnlySpan ata, ReadOnlySpan atb, ReadOnlySpan x, Span g, int n) - { - for (var j = 0; j < n; j++) - { - var s = -atb[j]; - for (var k = 0; k < n; k++) - s += ata[j * n + k] * x[k]; - g[j] = s; - } - } - - // Newton step over the free set: solves (A^T A)_FF p_F = -g_F by Cholesky. A free column whose pivot collapses - // (dependent on earlier free columns) is dropped from the factor and gets p = 0. No refinement step: Cholesky is - // backward stable, so the residual, which is the gradient the KKT test reads, is already at rounding level, and - // refining in the same precision does not improve the forward error. - private static void SolveFreeSet( - ReadOnlySpan ata, Span l, ReadOnlySpan g, Span p, Span y, - Span rhs, ReadOnlySpan free, Span dependent, int n) - { - var k = free.Length; - for (var i = 0; i < k; i++) - { - var fi = free[i]; - var d = ata[fi * n + fi]; - for (var c = 0; c < i; c++) - d -= l[i * n + c] * l[i * n + c]; - if (d <= PivotRelativeTolerance * ata[fi * n + fi]) - { - dependent[i] = 1; - for (var c = 0; c < i; c++) l[i * n + c] = 0.0; - l[i * n + i] = 1.0; - for (var r = i + 1; r < k; r++) l[r * n + i] = 0.0; - continue; - } - dependent[i] = 0; - var lii = Math.Sqrt(d); - l[i * n + i] = lii; - for (var r = i + 1; r < k; r++) - { - var s = ata[free[r] * n + fi]; - for (var c = 0; c < i; c++) - s -= l[r * n + c] * l[i * n + c]; - l[r * n + i] = s / lii; - } - } - - for (var i = 0; i < k; i++) - rhs[i] = dependent[i] != 0 ? 0.0 : -g[free[i]]; - Substitute(l, rhs, y, p, free, n); - } - - // Solves L L^T out = rhs; rhs is indexed by free-list position, out by column. - private static void Substitute(ReadOnlySpan l, ReadOnlySpan rhs, Span y, Span outByColumn, ReadOnlySpan free, int n) - { - var k = free.Length; - for (var i = 0; i < k; i++) - { - var s = rhs[i]; - for (var c = 0; c < i; c++) - s -= l[i * n + c] * y[c]; - y[i] = s / l[i * n + i]; - } - for (var i = k - 1; i >= 0; i--) - { - var s = y[i]; - for (var r = i + 1; r < k; r++) - s -= l[r * n + i] * outByColumn[free[r]]; - outByColumn[free[i]] = s / l[i * n + i]; - } - } -} diff --git a/packages/cultmath/src/CultMath/BoundedLeastSquares.cs.meta b/packages/cultmath/src/CultMath/BoundedLeastSquares.cs.meta deleted file mode 100644 index fb5bd819..00000000 --- a/packages/cultmath/src/CultMath/BoundedLeastSquares.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 4ba991e1b6c54e099bc7ea16541734c5 diff --git a/packages/cultmath/src/CultMath/CultCellular.cs b/packages/cultmath/src/CultMath/CultCellular.cs deleted file mode 100644 index f856236c..00000000 --- a/packages/cultmath/src/CultMath/CultCellular.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace CultMath; - -/// -/// The value-and-gradient result of (invariant 8's one struct -/// return shape). Every field follows the same float4(gradient.xyz, value.w) layout as a -/// bare value-and-gradient return. -/// -public struct CultCellular -{ - /// (∇F1, F1): the gradient and distance to the nearest feature point. - public float4 nearest; - - /// (∇F2 - ∇F1, F2 - F1): for lineae along cell borders. - public float4 edge; - - /// The nearest cell's pcg4d hash, mapped to [0, 1); independent of the pcg3d hash that - /// produced that cell's jitter. - public float id; - - public CultCellular(float4 nearest, float4 edge, float id) - { - this.nearest = nearest; - this.edge = edge; - this.id = id; - } -} diff --git a/packages/cultmath/src/CultMath/CultCellular.cs.meta b/packages/cultmath/src/CultMath/CultCellular.cs.meta deleted file mode 100644 index 8c9ed1ae..00000000 --- a/packages/cultmath/src/CultMath/CultCellular.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 76be9498b63e410891715b3ec965caf8 diff --git a/packages/cultmath/src/CultMath/CultMath.csproj b/packages/cultmath/src/CultMath/CultMath.csproj index cbf89929..7c567105 100644 --- a/packages/cultmath/src/CultMath/CultMath.csproj +++ b/packages/cultmath/src/CultMath/CultMath.csproj @@ -8,9 +8,7 @@ CultMath CultMath GameCult.Math - - MIT AND MPL-2.0 - 0.4.0 + 0.2.0 Clean-room C# math shaped for HLSL-style renderer code. GameCult README.md @@ -23,10 +21,6 @@ - - - - diff --git a/packages/cultmath/src/CultMath/CultPhasor.cs b/packages/cultmath/src/CultMath/CultPhasor.cs deleted file mode 100644 index fbc1f9d7..00000000 --- a/packages/cultmath/src/CultMath/CultPhasor.cs +++ /dev/null @@ -1,27 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// The result type of math.phacelle (math.Phacelle.cs), Rune Skovbo Johansen's Phacelle noise -// (Copyright (c) 2025, MPL-2.0; see THIRD-PARTY-NOTICES.md). - -namespace CultMath; - -/// -/// The value-and-gradient result of -/// (invariant 8's struct return shape). Both fields use the float4(gradient.xyz, value.w) -/// layout of a bare value-and-gradient return. -/// -public struct CultPhasor -{ - /// (∇cos, cos): the normalized cosine wave and its gradient. - public float4 cos; - - /// (∇sin, sin): the normalized sine wave and its gradient. - public float4 sin; - - public CultPhasor(float4 cos, float4 sin) - { - this.cos = cos; - this.sin = sin; - } -} diff --git a/packages/cultmath/src/CultMath/CultPhasor.cs.meta b/packages/cultmath/src/CultMath/CultPhasor.cs.meta deleted file mode 100644 index d586aa3f..00000000 --- a/packages/cultmath/src/CultMath/CultPhasor.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 807ae2c8a758cf31896da12f1e5047bd diff --git a/packages/cultmath/src/CultMath/Swizzles.g.cs b/packages/cultmath/src/CultMath/Swizzles.g.cs index db1c56bd..ce84bbc4 100644 --- a/packages/cultmath/src/CultMath/Swizzles.g.cs +++ b/packages/cultmath/src/CultMath/Swizzles.g.cs @@ -7,8 +7,6 @@ namespace CultMath; public partial struct float2 { public float2(float2 xy) : this(xy.x, xy.y) { } - public float2(int2 value) : this(value.x, value.y) { } - public float2(bool2 value) : this(value.x ? 1.0f : 0.0f, value.y ? 1.0f : 0.0f) { } public float r { readonly get => x; set => x = value; } public float g { readonly get => y; set => y = value; } public readonly float2 xx => new(x, x); @@ -74,8 +72,6 @@ public partial struct float3 public float3(float x, float2 yz) : this(x, yz.x, yz.y) { } public float3(float2 xy, float z) : this(xy.x, xy.y, z) { } public float3(float3 xyz) : this(xyz.x, xyz.y, xyz.z) { } - public float3(int3 value) : this(value.x, value.y, value.z) { } - public float3(bool3 value) : this(value.x ? 1.0f : 0.0f, value.y ? 1.0f : 0.0f, value.z ? 1.0f : 0.0f) { } public float r { readonly get => x; set => x = value; } public float g { readonly get => y; set => y = value; } public float b { readonly get => z; set => z = value; } @@ -324,8 +320,6 @@ public partial struct float4 public float4(float2 xy, float2 zw) : this(xy.x, xy.y, zw.x, zw.y) { } public float4(float3 xyz, float w) : this(xyz.x, xyz.y, xyz.z, w) { } public float4(float4 xyzw) : this(xyzw.x, xyzw.y, xyzw.z, xyzw.w) { } - public float4(int4 value) : this(value.x, value.y, value.z, value.w) { } - public float4(bool4 value) : this(value.x ? 1.0f : 0.0f, value.y ? 1.0f : 0.0f, value.z ? 1.0f : 0.0f, value.w ? 1.0f : 0.0f) { } public float r { readonly get => x; set => x = value; } public float g { readonly get => y; set => y = value; } public float b { readonly get => z; set => z = value; } @@ -1007,8 +1001,6 @@ public partial struct float4 public partial struct int2 { public int2(int2 xy) : this(xy.x, xy.y) { } - public int2(float2 value) : this((int)value.x, (int)value.y) { } - public int2(bool2 value) : this(value.x ? 1 : 0, value.y ? 1 : 0) { } public int r { readonly get => x; set => x = value; } public int g { readonly get => y; set => y = value; } public readonly int2 xx => new(x, x); @@ -1074,8 +1066,6 @@ public partial struct int3 public int3(int x, int2 yz) : this(x, yz.x, yz.y) { } public int3(int2 xy, int z) : this(xy.x, xy.y, z) { } public int3(int3 xyz) : this(xyz.x, xyz.y, xyz.z) { } - public int3(float3 value) : this((int)value.x, (int)value.y, (int)value.z) { } - public int3(bool3 value) : this(value.x ? 1 : 0, value.y ? 1 : 0, value.z ? 1 : 0) { } public int r { readonly get => x; set => x = value; } public int g { readonly get => y; set => y = value; } public int b { readonly get => z; set => z = value; } @@ -1324,8 +1314,6 @@ public partial struct int4 public int4(int2 xy, int2 zw) : this(xy.x, xy.y, zw.x, zw.y) { } public int4(int3 xyz, int w) : this(xyz.x, xyz.y, xyz.z, w) { } public int4(int4 xyzw) : this(xyzw.x, xyzw.y, xyzw.z, xyzw.w) { } - public int4(float4 value) : this((int)value.x, (int)value.y, (int)value.z, (int)value.w) { } - public int4(bool4 value) : this(value.x ? 1 : 0, value.y ? 1 : 0, value.z ? 1 : 0, value.w ? 1 : 0) { } public int r { readonly get => x; set => x = value; } public int g { readonly get => y; set => y = value; } public int b { readonly get => z; set => z = value; } @@ -2007,8 +1995,6 @@ public partial struct int4 public partial struct bool2 { public bool2(bool2 xy) : this(xy.x, xy.y) { } - public bool2(float2 value) : this(value.x != 0.0f, value.y != 0.0f) { } - public bool2(int2 value) : this(value.x != 0, value.y != 0) { } public bool r { readonly get => x; set => x = value; } public bool g { readonly get => y; set => y = value; } public readonly bool2 xx => new(x, x); @@ -2074,8 +2060,6 @@ public partial struct bool3 public bool3(bool x, bool2 yz) : this(x, yz.x, yz.y) { } public bool3(bool2 xy, bool z) : this(xy.x, xy.y, z) { } public bool3(bool3 xyz) : this(xyz.x, xyz.y, xyz.z) { } - public bool3(float3 value) : this(value.x != 0.0f, value.y != 0.0f, value.z != 0.0f) { } - public bool3(int3 value) : this(value.x != 0, value.y != 0, value.z != 0) { } public bool r { readonly get => x; set => x = value; } public bool g { readonly get => y; set => y = value; } public bool b { readonly get => z; set => z = value; } @@ -2324,8 +2308,6 @@ public partial struct bool4 public bool4(bool2 xy, bool2 zw) : this(xy.x, xy.y, zw.x, zw.y) { } public bool4(bool3 xyz, bool w) : this(xyz.x, xyz.y, xyz.z, w) { } public bool4(bool4 xyzw) : this(xyzw.x, xyzw.y, xyzw.z, xyzw.w) { } - public bool4(float4 value) : this(value.x != 0.0f, value.y != 0.0f, value.z != 0.0f, value.w != 0.0f) { } - public bool4(int4 value) : this(value.x != 0, value.y != 0, value.z != 0, value.w != 0) { } public bool r { readonly get => x; set => x = value; } public bool g { readonly get => y; set => y = value; } public bool b { readonly get => z; set => z = value; } @@ -3120,15 +3102,9 @@ public partial struct double3 public static partial class math { public static float2 float2(float2 xy) => new(xy); - public static float2 float2(int2 value) => new(value); - public static float2 float2(bool2 value) => new(value); - public static float2 float2(int value) => new(value, value); public static float3 float3(float x, float2 yz) => new(x, yz); public static float3 float3(float2 xy, float z) => new(xy, z); public static float3 float3(float3 xyz) => new(xyz); - public static float3 float3(int3 value) => new(value); - public static float3 float3(bool3 value) => new(value); - public static float3 float3(int value) => new(value, value, value); public static float4 float4(float x, float y, float2 zw) => new(x, y, zw); public static float4 float4(float x, float2 yz, float w) => new(x, yz, w); public static float4 float4(float x, float3 yzw) => new(x, yzw); @@ -3136,17 +3112,10 @@ public static partial class math public static float4 float4(float2 xy, float2 zw) => new(xy, zw); public static float4 float4(float3 xyz, float w) => new(xyz, w); public static float4 float4(float4 xyzw) => new(xyzw); - public static float4 float4(int4 value) => new(value); - public static float4 float4(bool4 value) => new(value); - public static float4 float4(int value) => new(value, value, value, value); public static int2 int2(int2 xy) => new(xy); - public static int2 int2(float2 value) => new(value); - public static int2 int2(bool2 value) => new(value); public static int3 int3(int x, int2 yz) => new(x, yz); public static int3 int3(int2 xy, int z) => new(xy, z); public static int3 int3(int3 xyz) => new(xyz); - public static int3 int3(float3 value) => new(value); - public static int3 int3(bool3 value) => new(value); public static int4 int4(int x, int y, int2 zw) => new(x, y, zw); public static int4 int4(int x, int2 yz, int w) => new(x, yz, w); public static int4 int4(int x, int3 yzw) => new(x, yzw); @@ -3154,16 +3123,10 @@ public static partial class math public static int4 int4(int2 xy, int2 zw) => new(xy, zw); public static int4 int4(int3 xyz, int w) => new(xyz, w); public static int4 int4(int4 xyzw) => new(xyzw); - public static int4 int4(float4 value) => new(value); - public static int4 int4(bool4 value) => new(value); public static bool2 bool2(bool2 xy) => new(xy); - public static bool2 bool2(float2 value) => new(value); - public static bool2 bool2(int2 value) => new(value); public static bool3 bool3(bool x, bool2 yz) => new(x, yz); public static bool3 bool3(bool2 xy, bool z) => new(xy, z); public static bool3 bool3(bool3 xyz) => new(xyz); - public static bool3 bool3(float3 value) => new(value); - public static bool3 bool3(int3 value) => new(value); public static bool4 bool4(bool x, bool y, bool2 zw) => new(x, y, zw); public static bool4 bool4(bool x, bool2 yz, bool w) => new(x, yz, w); public static bool4 bool4(bool x, bool3 yzw) => new(x, yzw); @@ -3171,6 +3134,4 @@ public static partial class math public static bool4 bool4(bool2 xy, bool2 zw) => new(xy, zw); public static bool4 bool4(bool3 xyz, bool w) => new(xyz, w); public static bool4 bool4(bool4 xyzw) => new(xyzw); - public static bool4 bool4(float4 value) => new(value); - public static bool4 bool4(int4 value) => new(value); } diff --git a/packages/cultmath/src/CultMath/math.Affine.cs b/packages/cultmath/src/CultMath/math.Affine.cs deleted file mode 100644 index 3c00e397..00000000 --- a/packages/cultmath/src/CultMath/math.Affine.cs +++ /dev/null @@ -1,241 +0,0 @@ -namespace CultMath; - -public static partial class math -{ - // Reduced affine forms with one shared symbol (design.md, "Affine forms"): float3(x0, a, e) is the - // set { x0 + a eps + e delta : delta in [-1, 1] } at the region's shared eps in [-1, 1], with - // e >= 0. Every form over one region shares that eps (for a screen-tile slice, the depth - // parameter), and delta is private to the form. This is Messine's AF1 as Gamito and Maddock use it - // for gradient noise (t0 + t1 e1 + t2 e2), in one register, as an interval is a float2. - // - // Every af_* op returns a form whose set, at each eps, contains f evaluated pointwise in float32 at - // every point of its operands' sets at that same eps. Rounding rule: each op folds its own float32 - // rounding into e as (S) 2^-20, where S is the sum of the magnitudes the op's roundings are - // relative to (named in each comment). With u = 2^-24, every op below needs at most 8u S (its - // component roundings, the pointwise result's own rounding, and the roundings of computing e), so - // 2^-20 = 16u covers it twice over; the factor of two is the allowance for a device whose + and * - // are faithful (within one ulp) rather than correctly rounded, and fma contraction only removes - // roundings. Products also add 2^-126, the most any underflow to a subnormal can lose. The - // enclosure tests evaluate the form's set in double and f in float32 with no tolerance - // (AffineTests.EveryOpEnclosesItsPoints). No op takes a compound type or a reference parameter: each is a - // plain function of float values, so it mirrors into the HLSL common subset. - - // An upper bound on the spectral norm of the Hessian of snoise(float3). Provenance: - // NoiseBoundTests.MeasureHessian (slow, explicit) takes the largest Hessian norm (central - // differences of snoise_grad, largest absolute eigenvalue) over 1e6 seeded points, refines the 1e4 - // largest by ascent, and multiplies the refined maximum by 1.10; - // NoiseBoundTests.HessianConstantPinsSampledCurvature pins this value against a fast re-measure and - // the ascent from MeasureHessian's witness. Empirical with a margin, not a proof. Random balls - // cannot see a constant 20% low, so the defence is those two curvature tests plus - // NoiseBoundTests.SnoiseFormEnclosesTheCurvatureWitness, where af_snoise misses at the point the - // curvature is realised if the constant is under it. The margin over the function: a scan of the - // whole 289^3 hash period found a realised maximum of 50.58, and bounding each corner's gradient - // independently over every hash configuration gives 52.22 (Soul pass s1). A change to the snoise - // kernel must re-run MeasureHessian and re-pin it. - public const float SNOISE_HESSIAN = 56.050385f; - - /// The point form (x, 0, 0): the value x at every eps. Exact. - public static float3 af_point(float value) => new(value, 0.0f, 0.0f); - - /// - /// The shared symbol itself, (x0, a, 0): the value x0 + a eps. It is how a region's parameter enters - /// (for a tile slice, depth z = z_m + h eps), so it is exact by definition: eps is defined through it. - /// - public static float3 af_symbol(float x0, float a) => new(x0, a, 0.0f); - - /// - /// Every value of the interval [lo, hi], uncorrelated with eps: (lo / 2 + hi / 2, 0, hi / 2 - lo / 2), - /// the halves taken before the sum and the difference so that endpoints near the float maximum do not - /// overflow in them. Rounding: x0 and e each round once, and a value of the interval is within e of x0 - /// only up to those; S = |x0| + e. Halving a subnormal endpoint loses at most 2^-150, and the sum and - /// difference of subnormals are exact, so 2^-126 covers the underflow (the e of an interval spanning - /// one subnormal step would otherwise round to 0). |x0| + e is at most the larger endpoint - /// in magnitude, so it does not overflow. If e + its absorption exceeds the float maximum it is - /// infinity, which still encloses. - /// - public static float3 af_from_iv(float2 interval) - { - var x0 = interval.x * 0.5f + interval.y * 0.5f; - var e = interval.y * 0.5f - interval.x * 0.5f; - return new float3(x0, 0.0f, e + (abs(x0) + e) * 9.5367431640625e-7f + 1.17549435e-38f); - } - - /// - /// The interval of every value of the form over every eps: x0 -+ (|a| + e), the bridge to iv_*. The - /// endpoints round inward by at most u (|x0| + |a| + e) each, so each is moved outward by - /// (|x0| + |a| + e) 2^-20, formed term by term so that the sum never passes the float maximum before it - /// is scaled. A form with an infinite component (an overflowed op) gives infinite - /// endpoints, and an endpoint that would be NaN (infinity minus infinity, or a NaN component) is - /// the infinity on its side, so the result is never NaN and still encloses. NaN is found by its bit - /// pattern, not by lo == lo, which a compiler that assumes no NaNs (dxc's default) deletes. - /// - public static float2 af_range(float3 x) - { - var r = abs(x.y) + x.z; - var w = abs(x.x) * 9.5367431640625e-7f + r * 9.5367431640625e-7f; - var lo = x.x - r - w; - var hi = x.x + r + w; - return new float2((asuint(lo) & 0x7fffffffu) > 0x7f800000u ? float.NegativeInfinity : lo, - (asuint(hi) & 0x7fffffffu) > 0x7f800000u ? float.PositiveInfinity : hi); - } - - /// - /// Encloses x + y: (x0 + y0, a_x + a_y, e_x + e_y). The shared symbol keeps the two forms - /// correlated, so af_sub(x, x) has a = 0. Rounding: S = |x0| + |a| + e of the result. - /// - public static float3 af_add(float3 x, float3 y) - { - var x0 = x.x + y.x; - var a = x.y + y.y; - var e = x.z + y.z; - return new float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7f); - } - - /// Encloses x - y: (x0 - y0, a_x - a_y, e_x + e_y). Rounding as af_add. - public static float3 af_sub(float3 x, float3 y) - { - var x0 = x.x - y.x; - var a = x.y - y.y; - var e = x.z + y.z; - return new float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7f); - } - - /// Encloses -x: (-x0, -a, e). Exact. - public static float3 af_neg(float3 x) => new(-x.x, -x.y, x.z); - - /// - /// Encloses x * s: (x0 s, a s, e |s|). Rounding: S = |x0| + |a| + e of the result, plus 2^-126 - /// for underflow. - /// - public static float3 af_scale(float3 x, float s) - { - var x0 = x.x * s; - var a = x.y * s; - var e = x.z * abs(s); - return new float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7f + 1.17549435e-38f); - } - - /// Encloses x + v for v in the interval, uncorrelated with eps: af_add(x, af_from_iv(interval)). - public static float3 af_add_iv(float3 x, float2 interval) => af_add(x, af_from_iv(interval)); - - /// - /// Encloses x * y, AF1's product: (x0 y0, x0 a_y + y0 a_x, |x0| e_y + |y0| e_x + (|a_x| + e_x)(|a_y| + e_y)). - /// The last term condenses the eps^2 term a_x a_y and every cross term with an error symbol into e, - /// so a form multiplied by itself is wider than its square: there is no af_sqr until a consumer - /// names one. Rounding: a can cancel, so S = |x0| + |x0 a_y| + |y0 a_x| + e, plus 2^-126 for - /// underflow. - /// - public static float3 af_mul(float3 x, float3 y) - { - var x0 = x.x * y.x; - var p = x.x * y.y; - var q = y.x * x.y; - var a = p + q; - var e = abs(x.x) * y.z + abs(y.x) * x.z + (abs(x.y) + x.z) * (abs(y.y) + y.z); - return new float3(x0, a, e + (abs(x0) + abs(p) + abs(q) + e) * 9.5367431640625e-7f + 1.17549435e-38f); - } - - /// - /// Encloses snoise(p) for every p = centre + axis eps + w with |w| <= radius, from one snoise_grad at - /// the centre (value n, gradient g). With R = |axis| + radius it returns the narrower of two sound - /// forms: the Lipschitz form (n, 0, L R), L = SNOISE_LIPSCHITZ, and the centred form - /// (n, g . axis, |g| radius + M R^2 / 2), M = SNOISE_HESSIAN. The centred form is Taylor's theorem: - /// snoise(c + d) = n + g . d + r with |r| <= M |d|^2 / 2, d = axis eps + w, g . w <= |g| radius. - /// radius must be at least 0. - /// - /// Both forms carry an allowance for the float32 evaluation of snoise, which is not the exact - /// function: 2^-14 + 2^-12 R + L 2^-20 (|centre|_1 + R). The skew and the corner offsets round the - /// input point by at most about 2u |p|_1 before any kernel term is formed (the hashing is exact on - /// integers below 2^24), so a float32 snoise of p is the exact one at a point within 2u |p|_1, which - /// moves the value by at most L 2u |p|_1; for both p and the centre, with the caller's scaling of the - /// point by a frequency (one rounding) and a factor of two for a GPU, 16u = 2^-20. The kernel's - /// absolute rounding is at most 105 x four corners x terms of magnitude below 0.5^4 x 1.8 over about - /// 30 operations, under 2^-15, doubled to 2^-14; the gradient's error times |d| <= R is under 2^-13 R, - /// doubled to 2^-12 R. AffineTests.SnoiseFormEnclosesBall checks the result with no tolerance on the - /// CPU, and the fixture's enclosure check measures it on a GPU. Rounding of the form itself: S = - /// |n| + |a| + e. The Lipschitz form is chosen when its half-width L R is at most the centred form's - /// |a| + |g| radius + M R^2 / 2, so the total width is never more than the Lipschitz form's. - /// - public static float3 af_snoise(float3 centre, float3 axis, float radius) - { - var g = snoise_grad(centre); - var gradient = new float3(g.x, g.y, g.z); - var reach = length(axis) + radius; - var lipschitz = SNOISE_LIPSCHITZ * reach; - var a = dot(gradient, axis); - var remainder = length(gradient) * radius + 0.5f * SNOISE_HESSIAN * reach * reach; - var allowance = 6.103515625e-5f + 2.44140625e-4f * reach - + SNOISE_LIPSCHITZ * 9.5367431640625e-7f * (abs(centre.x) + abs(centre.y) + abs(centre.z) + reach); - var centred = abs(a) + remainder < lipschitz; - var slope = centred ? a : 0.0f; - var e = (centred ? remainder : lipschitz) + allowance; - return new float3(g.w, slope, e + (abs(g.w) + abs(slope) + e) * 9.5367431640625e-7f); - } - - /// - /// Encloses the fBm value, sum of a_i snoise(p f_i) over the octaves, for every p = centre + axis eps - /// + w with |w| <= radius: the octave sum of af_snoise(centre f_i, axis f_i, radius |f_i|) scaled by - /// a_i, with frequency f_i and amplitude a_i compounded exactly as fbm_grad compounds them (its .w is - /// what AffineTests.SnoiseFormEnclosesBall encloses). The rounding of p f_i, inside fbm_grad, and of - /// the scaled centre and axis here, moves each point by at most 3u (|centre f_i|_1 + R f_i), inside - /// af_snoise's allowance for its input point. octaves is clamped to [0, 16] as there. - /// - public static float3 af_fbm(float3 centre, float3 axis, float radius, int octaves, float lacunarity, float gain) - { - octaves = clamp(octaves, 0, 16); - var amplitude = 1.0f; - var frequency = 1.0f; - var sum = new float3(0.0f, 0.0f, 0.0f); - for (var i = 0; i < octaves; i++) - { - sum = af_add(sum, af_scale(af_snoise(centre * frequency, axis * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; - } - - /// - /// The axis of a screen tile's slice over the depth segment [z0, z1], for af_frustum_ball's centre: - /// (m_c, 1) h with h = (z1 - z0) / 2, in the camera frame of iv_frustum_ball (a pinhole at the - /// origin looking down +z, the ray of slope m the points (m z, z)). Its z component is h itself, the - /// symbol's coefficient for depth: z = z_m + h eps. Its rounding is af_frustum_ball's. - /// - public static float3 af_frustum_axis(float2 centreSlope, float z0, float z1) - { - var h = (z1 - z0) * 0.5f; - return new float3(centreSlope.x * h, centreSlope.y * h, h); - } - - /// - /// The affine slice of a screen tile over [z0, z1]: a centre (xyz) and radius (w) such that every point - /// of every ray of the tile at depth z in [z0, z1] is centre + axis eps(z) + w', |w'| <= radius, with - /// axis = af_frustum_axis(centreSlope, z0, z1), z_m = (z0 + z1) / 2, h = (z1 - z0) / 2 (both float32, - /// as computed here) and eps(z) = clamp((z - z_m) / h, -1, 1) (0 where h is 0). The centre is - /// (m_c z_m, z_m) and the radius z1 footprintPerDepth + warpVariation, where footprintPerDepth is - /// iv_frustum_ball's and warpVariation is what the caller's warp can add once its value at the centre - /// is applied to the centre (design.md, "Affine forms", the centred warp). Derivation: a point of - /// slope m_c + e (|e| <= footprintPerDepth) at depth z is (m_c z_m, z_m) + (m_c, 1)(z - z_m) + - /// (e z, 0), and (m_c, 1)(z - z_m) = axis eps(z) + (m_c, 1) r(z), where the clamp residual - /// |r(z)| = |z - z_m - h eps(z)| is at most u (|z_m| + h), one rounding each of z_m and h. A caller - /// taking depth as af_symbol(z_m, h) adds the same residual, 2^-23 (|z_m| + h) covers it, to that - /// form's e. Rounding: the centre's products and the axis's products round once each (u |c|_1 and - /// u |axis|_1 against |eps| <= 1), the residual is at most u (|c|_1 + |axis|_1) since - /// |(m_c, 1)| <= |m_c|_1 + 1, and the radius rounds at most four times; 2^-20 (|c|_1 + |axis|_1 + - /// radius) covers it twice over (AffineTests.FrustumSliceEnclosesEveryRayPoint, extreme families - /// included). The caller rotates and translates the centre into world space, rotates the axis, and - /// scales all three by its noise frequency; the rounding of that transform is the caller's. - /// - public static float4 af_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warpVariation) - { - var zm = (z0 + z1) * 0.5f; - var h = (z1 - z0) * 0.5f; - var cx = centreSlope.x * zm; - var cy = centreSlope.y * zm; - var spread = (abs(centreSlope.x) + abs(centreSlope.y) + 1.0f) * h; - var radius = z1 * footprintPerDepth + warpVariation; - radius += (abs(cx) + abs(cy) + abs(zm) + spread + radius) * 9.5367431640625e-7f; - return new float4(cx, cy, zm, radius); - } -} diff --git a/packages/cultmath/src/CultMath/math.Affine.cs.meta b/packages/cultmath/src/CultMath/math.Affine.cs.meta deleted file mode 100644 index 34ba0047..00000000 --- a/packages/cultmath/src/CultMath/math.Affine.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 86b87ffb6c8a4d72b067a64f9f8a06ce diff --git a/packages/cultmath/src/CultMath/math.Interval.cs b/packages/cultmath/src/CultMath/math.Interval.cs deleted file mode 100644 index 5d0a6da4..00000000 --- a/packages/cultmath/src/CultMath/math.Interval.cs +++ /dev/null @@ -1,223 +0,0 @@ -namespace CultMath; - -public static partial class math -{ - // Interval arithmetic over float2(lo, hi), lo <= hi, both finite (design.md, "Intervals"). Every - // iv_* function returns an interval that contains f(x) for every x in its input intervals, where - // f(x) is the same function evaluated pointwise in float32, mirrored by cultmath_iv_* in - // shaders/CultMath.Interval.hlsl. Each bound is computed with the pointwise function's own float32 - // operations; because IEEE round-to-nearest is monotone, an op that is monotone on its region - // encloses its float32 evaluation with no widening. Where float32 evaluation is not monotone, or - // the libm is not required to be, the bound is widened by exactly one ulp, and the doc comment - // says so. There is no empty interval: a caller that needs "provably empty" tests hi < cutoff. - - // Lipschitz constant of snoise(float3) in its input: an upper bound on the length of its analytic - // gradient. Provenance: NoiseBoundTests.MeasureLipschitz (slow, explicit) takes the largest gradient - // length over 1e6 seeded points, refines the 1e4 largest by gradient ascent, and multiplies the - // refined maximum by 1.10; NoiseBoundTests.LipschitzConstantPinsSampledGradients pins this value - // against a fast re-measure and the ascent from MeasureLipschitz's witness. - // Empirical with a margin, not a proof; the enclosure tests are the defence. A change to the - // snoise kernel must re-run MeasureLipschitz and re-pin this constant. - public const float SNOISE_LIPSCHITZ = 7.9640074f; - - // Lipschitz constant of snoise(float2) in its input, with SNOISE_LIPSCHITZ's provenance rule: - // NoiseBoundTests.MeasureLipschitz2 (slow, explicit) takes the largest gradient length (central - // differences over exact float steps) over 1e6 seeded points, refines the 1e4 largest by ascent and - // multiplies by 1.10; NoiseBoundTests.Lipschitz2ConstantPins pins it against a fast re-measure and - // the ascent from MeasureLipschitz2's witness. A change to the 2D snoise kernel must re-run - // MeasureLipschitz2 and re-pin this constant. - public const float SNOISE2_LIPSCHITZ = 8.117002f; - - /// The point interval [x, x]. - public static float2 iv_point(float value) => new(value, value); - - /// Encloses x + y for x in a, y in b. Monotone: no widening. - public static float2 iv_add(float2 a, float2 b) => new(a.x + b.x, a.y + b.y); - - /// Encloses x - y for x in a, y in b. Monotone: no widening. - public static float2 iv_sub(float2 a, float2 b) => new(a.x - b.y, a.y - b.x); - - /// Encloses -x for x in a. Exact. - public static float2 iv_neg(float2 a) => new(-a.y, -a.x); - - /// - /// Encloses x * y for x in a, y in b: the least and greatest of the four corner products. The - /// product is monotone in each factor for a fixed sign of the other, so no widening. - /// - public static float2 iv_mul(float2 a, float2 b) - { - var p0 = a.x * b.x; - var p1 = a.x * b.y; - var p2 = a.y * b.x; - var p3 = a.y * b.y; - return new(min(min(p0, p1), min(p2, p3)), max(max(p0, p1), max(p2, p3))); - } - - /// Encloses x * s for x in a. Monotone: no widening. - public static float2 iv_scale(float2 a, float s) => s >= 0.0f ? new(a.x * s, a.y * s) : new(a.y * s, a.x * s); - - /// Encloses abs(x) for x in a; an interval straddling zero gives [0, max(-lo, hi)]. Exact. - public static float2 iv_abs(float2 a) - { - if (a.x >= 0.0f) - return a; - if (a.y <= 0.0f) - return new(-a.y, -a.x); - return new(0.0f, max(-a.x, a.y)); - } - - /// Encloses min(x, y) for x in a, y in b. Monotone: no widening. - public static float2 iv_min(float2 a, float2 b) => new(min(a.x, b.x), min(a.y, b.y)); - - /// Encloses max(x, y) for x in a, y in b. Monotone: no widening. - public static float2 iv_max(float2 a, float2 b) => new(max(a.x, b.x), max(a.y, b.y)); - - /// - /// Encloses x * x for x in a; an interval straddling zero gives [0, max(lo * lo, hi * hi)]. Tighter - /// than iv_mul(a, a), which cannot know both factors are the same x. Monotone on each side of zero: - /// no widening. - /// - public static float2 iv_sqr(float2 a) - { - var l = a.x * a.x; - var h = a.y * a.y; - if (a.x >= 0.0f) - return new(l, h); - if (a.y <= 0.0f) - return new(h, l); - return new(0.0f, max(l, h)); - } - - /// - /// Encloses sqrt(x) for x in a with x >= 0 (sqrt's domain): lo is clamped at 0, so [-4, 9] gives [0, 3] - /// and an interval wholly below zero gives [0, 0]. sqrt is correctly rounded, hence monotone: no - /// widening. - /// - public static float2 iv_sqrt(float2 a) => new(sqrt(max(a.x, 0.0f)), sqrt(max(a.y, 0.0f))); - - /// - /// Encloses exp(x) for x in a. Widened by one ulp on each side, because exp is not required to be - /// correctly rounded, so a libm need not be monotone. Where exp(hi) overflows to infinity, hi is NaN, - /// which a cull test hi < cutoff reads as "not provably below", the safe side. - /// - public static float2 iv_exp(float2 a) - { - var lo = exp(a.x); - var hi = exp(a.y); - return new(lo > 0.0f ? asfloat(asuint(lo) - 1u) : 0.0f, asfloat(asuint(hi) + 1u)); - } - - /// Encloses clamp(x, minimum, maximum) for x in a. Monotone: no widening. - public static float2 iv_clamp(float2 a, float minimum, float maximum) => - new(clamp(a.x, minimum, maximum), clamp(a.y, minimum, maximum)); - - /// Encloses saturate(x) for x in a. Monotone: no widening. - public static float2 iv_saturate(float2 a) => new(saturate(a.x), saturate(a.y)); - - /// - /// Encloses smoothstep(minimum, maximum, x) for x in a. smoothstep is monotone in x (increasing when - /// minimum < maximum, decreasing when minimum > maximum), so the bound is its value at the two - /// endpoints, ordered. Its float32 evaluation t * t * (3 - 2t) is not monotone, by at most one ulp - /// (IntervalTests.MeasureMonotonicity), so the bound is widened by one ulp inside [0, 1]. - /// - public static float2 iv_smoothstep(float minimum, float maximum, float2 a) - { - var s0 = smoothstep(minimum, maximum, a.x); - var s1 = smoothstep(minimum, maximum, a.y); - var lo = min(s0, s1); - var hi = max(s0, s1); - return new(lo > 0.0f ? asfloat(asuint(lo) - 1u) : 0.0f, hi < 1.0f ? asfloat(asuint(hi) + 1u) : 1.0f); - } - - /// - /// Encloses lerp(x, y, amount) = x + (y - x) * amount for x in a, y in b, by evaluating that expression - /// with iv_sub, iv_scale and iv_add. Each step is monotone, so the result encloses the float32 lerp - /// with no widening, for any amount. It is the natural interval extension: x appears twice, so for - /// non-point a the width is (width(a) + width(b)) * |amount| + width(a), wider than the true range. - /// - public static float2 iv_lerp(float2 a, float2 b, float amount) => iv_add(a, iv_scale(iv_sub(b, a), amount)); - - /// - /// Encloses snoise(x) for every x within distance radius of centre: [n - L r, n + L r] intersected - /// with [-1, 1], where n = snoise(centre) and L = SNOISE_LIPSCHITZ. radius must be at least 0. One - /// snoise evaluation, value only. A domain warp that moves x by at most D is enclosed by passing - /// radius + D (NoiseBoundTests.WarpedPointsStayEnclosed). - /// - public static float2 iv_snoise_ball(float3 centre, float radius) - { - var n = snoise(centre); - var e = SNOISE_LIPSCHITZ * radius; - return new(max(n - e, -1.0f), min(n + e, 1.0f)); - } - - /// - /// Encloses snoise(x) for every 2D x within distance radius of centre: [n - L2 r, n + L2 r] intersected - /// with [-1, 1], n = snoise(centre), L2 = SNOISE2_LIPSCHITZ. radius must be at least 0. One snoise - /// evaluation, value only. Like iv_snoise_ball(float3) it is exact for the point it is handed and - /// carries no allowance for the float32 evaluation: a consumer whose 2D flow is evaluated at points - /// it rounds itself (a shifted, scaled or projected point) adds 2^-14 + L2 2^-20 (|centre|_1 + radius) - /// to the width, the convention af_snoise carries for the 3D point - /// (NoiseBoundTests.FlowVariationCarriesItsAllowance, CentredWarpStaysEnclosed). - /// - public static float2 iv_snoise_ball(float2 centre, float radius) - { - var n = snoise(centre); - var e = SNOISE2_LIPSCHITZ * radius; - return new(max(n - e, -1.0f), min(n + e, 1.0f)); - } - - /// - /// Encloses the fBm value, sum of a_i * snoise(x * f_i) over the octaves, for every x within distance - /// radius of centre: the octave sum of iv_snoise_ball(centre * f_i, radius * |f_i|) scaled by a_i, - /// with frequency f_i and amplitude a_i compounded exactly as the value-and-gradient fBm compounds - /// them (its .w is what NoiseBoundTests.FbmBallEnclosesPoints encloses). octaves is clamped to [0, 16] - /// as there. - /// - public static float2 iv_fbm_ball(float3 centre, float radius, int octaves, float lacunarity, float gain) - { - octaves = clamp(octaves, 0, 16); - var amplitude = 1.0f; - var frequency = 1.0f; - var sum = new float2(0.0f, 0.0f); - for (var i = 0; i < octaves; i++) - { - sum = iv_add(sum, iv_scale(iv_snoise_ball(centre * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; - } - - /// - /// A ball (xyz centre, w radius) enclosing every point of every ray of a screen tile over the depth - /// segment [z0, z1], each point then moved by a warp of length at most warp: the ball to hand - /// iv_snoise_ball (scaled by the noise frequency) when one probe serves the whole tile. Camera frame: - /// a pinhole at the origin looking down +z, where the ray of slope m is the points (m z, z). - /// centreSlope is the tile's central slope m_c; footprintPerDepth is the largest distance of any - /// ray's slope from m_c, N / (sqrt(2) f) for an N x N pixel tile at focal length f pixels (the full - /// pixel footprint, so sub-pixel jitter is covered). The centre is (m_c z_m, z_m), z_m = (z0 + z1) / 2; - /// the radius is ((z1 - z0) / 2) |(m_c, 1)| + z1 footprintPerDepth + warp. Derivation: a point of slope - /// m_c + e (|e| <= footprintPerDepth) at depth z is c + (z - z_m)(m_c, 1) + z (e, 0); the first term is - /// at most the first radius term, the second at most the second, and the warp adds at most warp. - /// The ball also carries its own float32 rounding: the radius is widened by (|c|_1 + radius) 2^-20. - /// With u = 2^-24, each centre component carries at most two roundings (z_m, then the product), so the - /// float centre is within 2u |c|_1 of the exact one; the radius carries at most seven, so the exact - /// radius is at most (1 + 7u) times the float one; the widening rounds once more. 2^-20 = 16u covers - /// 8u (|c|_1 + radius) twice over, and fma contraction only removes roundings. So every exact point of - /// every ray, at any depth and slope, lies in the returned float ball - /// (NoiseBoundTests.TileBallEnclosesEveryRaySegment, degenerate and far segments included). The caller - /// rotates and translates the centre into world space (the radius is unchanged) and scales both by its - /// noise frequency; the rounding of that transform is the caller's. - /// - public static float4 iv_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warp) - { - var zm = (z0 + z1) * 0.5f; - var axis = sqrt(centreSlope.x * centreSlope.x + centreSlope.y * centreSlope.y + 1.0f); - var cx = centreSlope.x * zm; - var cy = centreSlope.y * zm; - var radius = (z1 - z0) * 0.5f * axis + z1 * footprintPerDepth + warp; - radius += (abs(cx) + abs(cy) + abs(zm) + radius) * 9.5367431640625e-7f; - return new float4(cx, cy, zm, radius); - } -} diff --git a/packages/cultmath/src/CultMath/math.Interval.cs.meta b/packages/cultmath/src/CultMath/math.Interval.cs.meta deleted file mode 100644 index eb3b76d1..00000000 --- a/packages/cultmath/src/CultMath/math.Interval.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 3eb757caae684b388921e28e3c87ba3a diff --git a/packages/cultmath/src/CultMath/math.Phacelle.cs b/packages/cultmath/src/CultMath/math.Phacelle.cs deleted file mode 100644 index 25689737..00000000 --- a/packages/cultmath/src/CultMath/math.Phacelle.cs +++ /dev/null @@ -1,127 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Phacelle noise. Copyright (c) 2025 Rune Skovbo Johansen (Shadertoy t3dyWl; MPL-2.0), read from the -// C# port PhacelleNoise in lpmitchell/AdvancedTerrainErosion, converted to burstable C# by Luke -// Mitchell (2026). Modified by GameCult: 3D cells, a caller-supplied stripe wave vector, an exact -// gradient and exact pruning. This file and CultPhasor.cs are the MPL-2.0 files of CultMath; the -// rest of the package is MIT (see THIRD-PARTY-NOTICES.md). - -namespace CultMath; - -public static partial class math -{ - // Johansen's Phacelle noise (phase + cell), generalised to 3D cells with a caller-supplied - // stripe wave vector. Each of the 4x4x4 cells around p carries one jittered feature point - // (jitter in [-0.5, 0.5) per axis, from pcg3d over the integer cell coordinate, the same - // integer-hashing rule as cellular) and one cosine/sine wave that runs along `side` (the wave - // vector: its length is 2*pi times the stripe frequency, and the caller chooses which - // perpendicular it is; on a unit sphere that is cross(p_hat, flow)). The waves are blended with - // the bell weight max(0, exp(-2 d^2) - 0.01111) (exactly 0 at distance 1.5, the nearest a - // feature outside the 4x4x4 block can be in 2D, which is what keeps cell-grid lines out), and - // the blended phasor is normalized: its length is stretched to 1 wherever the raw length is at - // least 1 - normalization, and scaled by 1 / (1 - normalization) below that. `offset` is the - // phase in cycles (1 is a full turn). Value and normalization follow Johansen's - // PhacelleNoise as ported in lpmitchell/AdvancedTerrainErosion. - // - // `normalization` is meant to lie in [0, 1]. At 0 the output is the raw blend (a phasor of - // length at most 1); at 1 the floor is 0 and every output is stretched to length 1. Values of - // 1 or more saturate at that (the floor is never above the raw length), and a negative value - // scales every output down by 1 / (1 - normalization) < 1. The normalized gradient scales as - // 1 / |I| where I is the blended phasor (below), so it grows wherever the blend nearly - // cancels; a normalization near 1 lets that happen at every point. - // - // The gradient is exact: it carries the weight derivative (grad w = -4 v exp(-2 |v|^2) where - // w > 0) and the normalization, not upstream's convention grad(cos) ~ -sin * side, which - // ignores the weight gradient (Asura probe: 16.8 deg off at the median, 97.8 at the 95th - // percentile; the exact form is 0.00 and 0.03). With P = sum(w * (cos, sin)) and W = sum(w), - // I = P / W has grad I = (grad P - I * grad W) / W; above the threshold the output is I / |I| - // with gradient (grad I - out * grad|I|) / |I|, below it grad I / (1 - normalization). The - // value is continuous at both seams below; the gradient is not. - // * Where |I| crosses the threshold, the gradient jumps between the two branches. - // * Where a cell's weight leaves its support (d^2 = ln(1 / 0.01111) / 2 = 2.24995, distance - // 1.49998), grad w jumps from -4 * 0.01111 * v to 0: a per-cell jump of length - // 0.0444 * |v|, 0.0667 at |v| = 1.5. Measured over random points, the resulting jump in - // the output gradient is a median 1.5% of its length and at most about 27%. - // - // W is the sum of 64 weights and is positive for every input pcg3d produces (the smallest - // W found by hill-climbing the hash-driven cell contents is 0.056). It is 0, and the output - // NaN, only if all 64 weights vanish, which takes adversarial jitter no hash yields. - // - // Pruning is exact: per axis, |local - g| - 0.5 (floored at 0) lower-bounds |v| for any jitter, - // so a cell whose summed square is at least 2.25 lies outside the support (2.24995 < 2.25) and - // has weight exactly 0: it contributes nothing to any sum. Cells whose bound sits just under - // 2.25 can still have a nonzero weight, so the cut cannot be lowered. On average the prune - // keeps about 45 of the 64 cells (a saving of about 30%); only about 14 have a nonzero weight. - // Only the internal overload can switch the prune off; PhacelleTests uses it to pin bit equality. - public static CultPhasor phacelle(float3 p, float3 side, float offset, float normalization) => - phacelle(p, side, offset, normalization, true); - - internal static CultPhasor phacelle(float3 p, float3 side, float offset, float normalization, bool prune) - { - var cell = floor(p); - var local = p - cell; - var phaseOffset = offset * TAU; - var sumW = 0.0f; - var sumCos = 0.0f; - var sumSin = 0.0f; - var gradW = new float3(0.0f, 0.0f, 0.0f); - var gradCos = new float3(0.0f, 0.0f, 0.0f); - var gradSin = new float3(0.0f, 0.0f, 0.0f); - - for (var dz = -1; dz <= 2; dz++) - { - var gz = max(0.0f, abs(local.z - (float)dz) - 0.5f); - for (var dy = -1; dy <= 2; dy++) - { - var gy = max(0.0f, abs(local.y - (float)dy) - 0.5f); - for (var dx = -1; dx <= 2; dx++) - { - var gx = max(0.0f, abs(local.x - (float)dx) - 0.5f); - if (prune && gx * gx + gy * gy + gz * gz >= 2.25f) - continue; - - var gridStep = new float3(dx, dy, dz); - var hash = pcg3d(int3(cell + gridStep)); - var jitter = new float3(cellular_unit(hash.x) - 0.5f, cellular_unit(hash.y) - 0.5f, cellular_unit(hash.z) - 0.5f); - var v = local - gridStep - jitter; - var falloff = exp(-2.0f * dot(v, v)); - var w = max(0.0f, falloff - 0.01111f); - var dw = w > 0.0f ? (-4.0f * falloff) * v : new float3(0.0f, 0.0f, 0.0f); - var phase = dot(v, side) + phaseOffset; - var c = cos(phase); - var s = sin(phase); - - sumW += w; - sumCos += w * c; - sumSin += w * s; - gradW += dw; - gradCos += dw * c - (w * s) * side; - gradSin += dw * s + (w * c) * side; - } - } - } - - var invW = 1.0f / sumW; - var rawCos = sumCos * invW; - var rawSin = sumSin * invW; - var gradRawCos = (gradCos - rawCos * gradW) * invW; - var gradRawSin = (gradSin - rawSin * gradW) * invW; - var rawLength = sqrt(rawCos * rawCos + rawSin * rawSin); - var floorLength = 1.0f - normalization; - - if (rawLength > floorLength) - { - var outCos = rawCos / rawLength; - var outSin = rawSin / rawLength; - var gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength; - return new CultPhasor( - new float4((gradRawCos - outCos * gradLength) / rawLength, outCos), - new float4((gradRawSin - outSin * gradLength) / rawLength, outSin)); - } - - return new CultPhasor( - new float4(gradRawCos / floorLength, rawCos / floorLength), - new float4(gradRawSin / floorLength, rawSin / floorLength)); - } -} diff --git a/packages/cultmath/src/CultMath/math.Phacelle.cs.meta b/packages/cultmath/src/CultMath/math.Phacelle.cs.meta deleted file mode 100644 index 898abc4c..00000000 --- a/packages/cultmath/src/CultMath/math.Phacelle.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 2c9d4e6b1a8f47d3b05e7a3c9d1f8e26 diff --git a/packages/cultmath/src/CultMath/math.cs b/packages/cultmath/src/CultMath/math.cs index a5a30a09..ca74857f 100644 --- a/packages/cultmath/src/CultMath/math.cs +++ b/packages/cultmath/src/CultMath/math.cs @@ -1,10 +1,5 @@ using System; -// Cut 2a-i fix batch 1: cellular_unit's [0,1) mapping bug (F7) is only reachable from cellular's -// private call sites; this lets CultMath.Tests probe it directly instead of hunting for a hash -// input that happens to land on the bit pattern under test. -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("CultMath.Tests")] - namespace CultMath; public static partial class math @@ -110,9 +105,6 @@ public static partial class math public static float2 frac(float2 value) => value - floor(value); public static float3 frac(float3 value) => value - floor(value); public static float4 frac(float4 value) => value - floor(value); - // dxc has no double Frc: it demotes to float, as it does for exp and lerp. CultMath's double - // overloads keep double precision instead, so frac(double) is x - floor(x) in double. - public static double frac(double value) => value - Math.Floor(value); // dxc lowers float min/max/clamp to DXIL FMin/FMax (saturate to Saturate, defined as FMin(1, FMax(0, x))). // DXIL.rst: FMin(a, b) is a < b ? a : b, FMax(a, b) is a >= b ? a : b, and a NaN operand returns the other. @@ -138,11 +130,6 @@ public static partial class math public static float2 clamp(float2 value, float2 minimum, float2 maximum) => min(max(value, minimum), maximum); public static float3 clamp(float3 value, float3 minimum, float3 maximum) => min(max(value, minimum), maximum); public static float4 clamp(float4 value, float4 minimum, float4 maximum) => min(max(value, minimum), maximum); - // dxc lowers int clamp to IMin(IMax(x, a), b): inverted bounds return b rather than throwing like Math.Clamp. - public static int clamp(int value, int minimum, int maximum) => min(max(value, minimum), maximum); - public static int2 clamp(int2 value, int2 minimum, int2 maximum) => min(max(value, minimum), maximum); - public static int3 clamp(int3 value, int3 minimum, int3 maximum) => min(max(value, minimum), maximum); - public static int4 clamp(int4 value, int4 minimum, int4 maximum) => min(max(value, minimum), maximum); // DXIL Saturate is FMin(1, FMax(0, x)); that operand order, unlike clamp(x, 0, 1), maps -0 to +0. public static float saturate(float value) => min(1.0f, max(0.0f, value)); @@ -218,10 +205,9 @@ public static partial class math public static float distance(float3 left, float3 right) => length(left - right); public static float distance(float4 left, float4 right) => length(left - right); - // dxc lowers normalize(x) to x * Rsqrt(Dot(x, x)), and DXIL Rsqrt is 1 / sqrt(src): a zero vector is 0 * inf = NaN. - public static float2 normalize(float2 value) => value * (1.0f / MathF.Sqrt(dot(value, value))); - public static float3 normalize(float3 value) => value * (1.0f / MathF.Sqrt(dot(value, value))); - public static float4 normalize(float4 value) => value * (1.0f / MathF.Sqrt(dot(value, value))); + public static float2 normalize(float2 value) => value / max(length(value), 1.0e-20f); + public static float3 normalize(float3 value) => value / max(length(value), 1.0e-20f); + public static float4 normalize(float4 value) => value / max(length(value), 1.0e-20f); public static quaternion normalize(quaternion value) { var length = MathF.Sqrt(value.x * value.x + value.y * value.y + value.z * value.z + value.w * value.w); @@ -387,44 +373,6 @@ public static partial class math public static float hash(float2 value) => hash(dot(value, new float2(127.1f, 311.7f))); public static float hash(float3 value) => hash(dot(value, new float3(127.1f, 311.7f, 74.7f))); - public static uint asuint(float value) => (uint)BitConverter.SingleToInt32Bits(value); - public static float asfloat(uint value) => BitConverter.Int32BitsToSingle((int)value); - - // PCG hashes from Jarzynski and Olano, "Hash Functions for GPU Rendering" (JCGT 9(3), 2020). Integer-only, so - // dxc and C# agree bit for bit. pcg3d/pcg4d carry uint bit patterns in int3/int4; float overloads hash IEEE bits. - public static uint pcg(uint value) - { - var state = value * 747796405u + 2891336453u; - var word = ((state >> (int)((state >> 28) + 4)) ^ state) * 277803737u; - return (word >> 22) ^ word; - } - - public static int3 pcg3d(int3 value) - { - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u, z = (uint)value.z * 1664525u + 1013904223u; - x += y * z; y += z * x; z += x * y; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; - x += y * z; y += z * x; z += x * y; - return new int3((int)x, (int)y, (int)z); - } - - // The paper hashes 2 -> N inputs through pcg3d with the unused component held constant. - public static int3 pcg3d(float2 value) => pcg3d(new float3(value, 0.0f)); - public static int3 pcg3d(float3 value) => pcg3d(new int3((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z))); - - public static int4 pcg4d(int4 value) - { - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u; - uint z = (uint)value.z * 1664525u + 1013904223u, w = (uint)value.w * 1664525u + 1013904223u; - x += y * w; y += z * x; z += x * y; w += y * z; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; w ^= w >> 16; - x += y * w; y += z * x; z += x * y; w += y * z; - return new int4((int)x, (int)y, (int)z, (int)w); - } - - public static int4 pcg4d(float4 value) => - pcg4d(new int4((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z), (int)asuint(value.w))); - public static float log(float value) => MathF.Log(value); public static float2 log(float2 value) => new(log(value.x), log(value.y)); public static float3 log(float3 value) => new(log(value.x), log(value.y), log(value.z)); @@ -527,91 +475,15 @@ public static partial class math a._m20 * b._m01 + a._m21 * b._m11 + a._m22 * b._m21, a._m20 * b._m02 + a._m21 * b._m12 + a._m22 * b._m22); - // Abramowitz & Stegun 7.1.26, a single-precision rational/exponential fit with a stated - // max absolute error of 1.5e-7. erf is odd, so only x >= 0 is fit and the sign is restored. - // Measured against an independent reference: worst absolute error 6.621e-7, inside the - // 2e-6 bar this package's tests pin. - public static float erf(float value) - { - const float p = 0.3275911f; - const float a1 = 0.254829592f; - const float a2 = -0.284496736f; - const float a3 = 1.421413741f; - const float a4 = -1.453152027f; - const float a5 = 1.061405429f; - - var s = sign(value); - var x = abs(value); - var t = 1.0f / (1.0f + p * x); - var poly = ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t; - var result = 1.0f - poly * exp(-x * x); - return s * result; - } - - // Giles, "Approximating the erfinv function" (GPU Computing Gems, 2010): a single-precision - // minimax polynomial in two ranges of w = -ln((1-x)(1+x)), central and tail. - // Domain is [-1, 1]. Outside it, including +-infinity, the result is NaN (there is no real - // inverse). At the edges the mathematical limit is infinite: erfinv(1) = +infinity and - // erfinv(-1) = -infinity. The unguarded polynomial hits log(0) = -infinity at those edges and - // the tail branch's leading coefficient is negative, so it delivers the wrong sign; guard the - // edges explicitly instead of trusting the fit through the singularity. - // Measured against an independent reference: worst absolute error 5.066e-7, and the - // erf(erfinv(y)) round trip 6.109e-7 worst case, both inside the 2e-6 bar this package's - // tests pin. - public static float erfinv(float value) - { - if (value >= 1.0f) return value > 1.0f ? float.NaN : float.PositiveInfinity; - if (value <= -1.0f) return value < -1.0f ? float.NaN : float.NegativeInfinity; - - var w = -log((1.0f - value) * (1.0f + value)); - float p; - if (w < 5.0f) - { - w -= 2.5f; - p = 2.81022636e-08f; - p = 3.43273939e-07f + p * w; - p = -3.5233877e-06f + p * w; - p = -4.39150654e-06f + p * w; - p = 0.00021858087f + p * w; - p = -0.00125372503f + p * w; - p = -0.00417768164f + p * w; - p = 0.246640727f + p * w; - p = 1.50140941f + p * w; - } - else - { - w = sqrt(w) - 3.0f; - p = -0.000200214257f; - p = 0.000100950558f + p * w; - p = 0.00134934322f + p * w; - p = -0.00367342844f + p * w; - p = 0.00573950773f + p * w; - p = -0.0076224613f + p * w; - p = 0.00943887047f + p * w; - p = 1.00167406f + p * w; - p = 2.83297682f + p * w; - } - - return p * value; - } - // Ashima Arts / Ian McEwan 3D simplex noise (MIT), mirrored by cultmath_snoise(float3) - // in shaders/CultMath.hlsl with the same float32 evaluation order. Follows stegu/webgl-noise - // src/noise3D.glsl at 22434e04d7 (kernel radius^2 0.5, scale 105, permute (34x+10)x); see - // THIRD-PARTY-NOTICES.md. Continuous across simplex-cell boundaries - // (NoiseGradTests.SnoiseAndItsGradientAreContinuousAcrossSimplexCellBoundaries). Ties in x0 resolve - // in Gustavson's simplexnoise1234 order (x over y, y over z, x over z), a total order, so the four - // corners are always a simplex; upstream's step is cyclic and degenerates where x0's components are - // equal (NoiseGradTests.SnoiseIsContinuousOnTheSimplexDiagonal). - // SNOISE_LIPSCHITZ (math.Interval.cs) is measured from this kernel: a change here must re-run - // NoiseBoundTests.MeasureLipschitz and re-pin it. + // in shaders/CultMath.hlsl with the same float32 evaluation order. public static float snoise(float3 value) { const float cx = 1.0f / 6.0f; const float cy = 1.0f / 3.0f; var i = floor(value + dot(value, new float3(cy, cy, cy))); var x0 = value - i + dot(i, new float3(cx, cx, cx)); - var g = new float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0f - step(x0.z, x0.x)); + var g = step(new float3(x0.y, x0.z, x0.x), x0); var l = 1.0f - g; var lzxy = new float3(l.z, l.x, l.y); var i1 = min(g, lzxy); @@ -651,9 +523,9 @@ public static partial class math p2 *= norm.z; p3 *= norm.w; - var m = max(0.5f - new float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0f); + var m = max(0.6f - new float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0f); m = m * m; - return 105.0f * dot(m * m, new float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); + return 42.0f * dot(m * m, new float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); } // Ashima Arts / Ian McEwan 2D simplex noise, kept component-explicit so @@ -699,280 +571,8 @@ public static partial class math private static float2 snoise_mod289(float2 value) => value - floor(value * (1.0f / 289.0f)) * 289.0f; private static float3 snoise_mod289(float3 value) => value - floor(value * (1.0f / 289.0f)) * 289.0f; private static float4 snoise_mod289(float4 value) => value - floor(value * (1.0f / 289.0f)) * 289.0f; - private static float3 snoise_permute(float3 value) => snoise_mod289(((value * 34.0f) + 10.0f) * value); - private static float4 snoise_permute(float4 value) => snoise_mod289(((value * 34.0f) + 10.0f) * value); - - // Analytic gradient of snoise(float3) (invariant 8), following the differentiation in - // webgl-noise src/noise3Dgrad.glsl (Ashima Arts / McEwan, MIT), which uses the same kernel - // radius^2 0.5, permutation (34x+10)x and scale 105 as snoise(float3) (stegu/webgl-noise - // 22434e04d7). Every local up through p0..p3 and x0..x3 below is snoise(float3)'s own derivation - // verbatim, so .w is that same field (NoiseGradTests.SnoiseGradValueIsBitEqualToSnoise pins the - // two bit-equal over a random sweep). Per corner, m0 = max(0.5 - dot(x,x), 0), so dm0/dx = -2x, - // and d(m0^4 * dot(p,x))/dx = 4*m0^3*(-2x)*dot(p,x) + m0^4*p = -8*m0^3*dot(p,x)*x + m0^4*p (p is - // that corner's own gradient constant, independent of x); summed over the four corners and - // scaled by the same 105 as the value. - public static float4 snoise_grad(float3 value) - { - const float cx = 1.0f / 6.0f; - const float cy = 1.0f / 3.0f; - var i = floor(value + dot(value, new float3(cy, cy, cy))); - var x0 = value - i + dot(i, new float3(cx, cx, cx)); - var g = new float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0f - step(x0.z, x0.x)); - var l = 1.0f - g; - var lzxy = new float3(l.z, l.x, l.y); - var i1 = min(g, lzxy); - var i2 = max(g, lzxy); - var x1 = x0 - i1 + cx; - var x2 = x0 - i2 + cy; - var x3 = x0 - 0.5f; - - i = snoise_mod289(i); - var p = snoise_permute(snoise_permute(snoise_permute( - i.z + new float4(0.0f, i1.z, i2.z, 1.0f)) + i.y + new float4(0.0f, i1.y, i2.y, 1.0f)) + i.x + new float4(0.0f, i1.x, i2.x, 1.0f)); - - const float n = 0.142857142857f; - var ns = new float3(2.0f * n, 0.5f * n - 1.0f, n); - var j = p - 49.0f * floor(p * ns.z * ns.z); - var xs = floor(j * ns.z); - var ys = floor(j - 7.0f * xs); - var x = xs * ns.x + ns.y; - var y = ys * ns.x + ns.y; - var h = 1.0f - abs(x) - abs(y); - - var b0 = new float4(x.x, x.y, y.x, y.y); - var b1 = new float4(x.z, x.w, y.z, y.w); - var s0 = floor(b0) * 2.0f + 1.0f; - var s1 = floor(b1) * 2.0f + 1.0f; - var sh = -step(h, 0.0f); - var a0 = new float4(b0.x, b0.z, b0.y, b0.w) + new float4(s0.x, s0.z, s0.y, s0.w) * new float4(sh.x, sh.x, sh.y, sh.y); - var a1 = new float4(b1.x, b1.z, b1.y, b1.w) + new float4(s1.x, s1.z, s1.y, s1.w) * new float4(sh.z, sh.z, sh.w, sh.w); - - var p0 = new float3(a0.x, a0.y, h.x); - var p1 = new float3(a0.z, a0.w, h.y); - var p2 = new float3(a1.x, a1.y, h.z); - var p3 = new float3(a1.z, a1.w, h.w); - var norm = 1.79284291400159f - 0.85373472095314f * new float4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - var m0 = max(0.5f - new float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0f); - var m2 = m0 * m0; - var m3 = m2 * m0; - var m4 = m2 * m2; - - var px = new float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)); - var value2 = 105.0f * dot(m4, px); - var grad = -8.0f * m3.x * x0 * px.x + m4.x * p0 - + -8.0f * m3.y * x1 * px.y + m4.y * p1 - + -8.0f * m3.z * x2 * px.z + m4.z * p2 - + -8.0f * m3.w * x3 * px.w + m4.w * p3; - grad *= 105.0f; - - return new float4(grad, value2); - } - - // Octave sum of snoise_grad (invariant 8). Each octave samples snoise_grad at p scaled by the - // running frequency, so by the chain rule its gradient scales by that same frequency - // (d/dp[n(f*p)] = f * grad_n(f*p)); amplitude and frequency both compound per octave (gain, - // lacunarity respectively), not applied once for the whole sum, so with 1 octave this is exactly - // snoise_grad (NoiseGradTests.FbmGradWithOneOctaveEqualsSnoiseGrad). octaves is clamped to - // [0, 16]: HlslSourceCompatibilityTests' bit-parity oracle drives every mirrored int parameter - // across the full int32 range, which is the right domain for pcg3d/pcg4d's O(1) hash inputs but - // would turn an unclamped octave count into a multi-billion-iteration loop for this mirror. - public static float4 fbm_grad(float3 p, int octaves, float lacunarity, float gain) - { - octaves = clamp(octaves, 0, 16); - var amplitude = 1.0f; - var frequency = 1.0f; - var value = 0.0f; - var gradient = new float3(0.0f, 0.0f, 0.0f); - for (var i = 0; i < octaves; i++) - { - var n = snoise_grad(p * frequency); - value += amplitude * n.w; - gradient += amplitude * frequency * new float3(n.x, n.y, n.z); - frequency *= lacunarity; - amplitude *= gain; - } - - return new float4(gradient, value); - } - - // Ridged multifractal noise (Musgrave, Texturing and Modeling, ch. 16; the operator's dune term, - // 2026-09-25): each octave folds snoise_grad about zero, value = Sum a_i*(1 - |n_i|), gradient = - // -Sum a_i*f_i*sign(n_i)*grad(n_i), the same per-octave frequency scaling as fbm_grad's chain - // rule plus the fold's sign flip (d|n|/dp = sign(n)*dn/dp). The crease at n_i = 0 is real and - // deliberate, not a bug: NoiseGradTests excludes a band around it, the same way cellular excludes - // its F1 = F2 seam. sign follows this codebase's HLSL-matching convention (design.md: sign - // returns int, 0 at exactly 0), so the crease itself contributes no gradient rather than an - // arbitrary one. Same octave clamp as fbm_grad, for the same bit-parity-oracle reason. - public static float4 ridged_grad(float3 p, int octaves, float lacunarity, float gain) - { - octaves = clamp(octaves, 0, 16); - var amplitude = 1.0f; - var frequency = 1.0f; - var value = 0.0f; - var gradient = new float3(0.0f, 0.0f, 0.0f); - for (var i = 0; i < octaves; i++) - { - var n = snoise_grad(p * frequency); - var s = (float)sign(n.w); - value += amplitude * (1.0f - abs(n.w)); - gradient += -amplitude * frequency * s * new float3(n.x, n.y, n.z); - frequency *= lacunarity; - amplitude *= gain; - } - - return new float4(gradient, value); - } - - // Inigo Quilez, "smooth minimum" (https://iquilezles.org/articles/smin/): the quadratic-polynomial - // smin, carried to value-and-gradient form (invariant 8). h is affine in (b.w - a.w) inside the - // smoothing band, so differentiating value = lerp(b.w, a.w, h) - k*h*(1-h) with respect to - // position, the terms carrying dh/dp cancel exactly (dh/dp * [(a.w-b.w) - k + 2*k*h] and the - // bracket is identically zero given how h is built from a.w-b.w). What is left is exactly - // lerp(∇b, ∇a, h): the gradient blend is not an approximation, it is the analytic gradient. - // Outside the band (|a.w - b.w| >= k), h saturates to 0 or 1 and this is exactly min(a, b) with - // that input's own gradient, continuously (h and the correction term both reach the boundary at - // the same value from the smooth side, so there is no kink to exclude here the way cellular's - // F1 = F2 seam needs one). - public static float4 smin_grad(float4 a, float4 b, float k) - { - var h = saturate(0.5f + 0.5f * (b.w - a.w) / k); - var value = lerp(b.w, a.w, h) - k * h * (1.0f - h); - var gradient = lerp(new float3(b.x, b.y, b.z), new float3(a.x, a.y, a.z), h); - return new float4(gradient, value); - } - - // Worley, "A Cellular Texture Basis Function" (SIGGRAPH 1996): F1/F2 and their analytic - // gradients, searched over the jittered neighbourhood of feature points. Feature points are - // selected with pcg3d over each neighbour's integer cell coordinate (design.md, "Integer - // hashing"), never the float32 bit pattern of that coordinate and never the sin-based hash. - // Hashing the integer cell coordinate directly is exact and runtime-independent, and it is what - // the HLSL mirror does, so C# and shader stay bit-for-bit aligned. What pins this is the oracle - // and mirror tests, not a uniformity measurement: reverting to hashing the float32 bit pattern - // (or the sin-based hash) is caught by ProductionSearchMatchesTheBruteForceOracleExactly, - // EveryMirrorFunctionMatchesCSharpMath, F1NeverExceedsF2, and the other tests that key off the - // integer-hash fixtures. The - // gradient of a distance field, del|p - c|, is the unit vector (p - c)/|p - c|; that is undefined exactly at - // a feature point (F1 = 0 or F2 = 0), so cellular follows the repo's existing degenerate-normal - // convention (GameCult.Geometry.CultGeometryIsoSurface.EmitOrientedTriangle: guard the zero-length - // case and return the zero vector instead of the NaN a bare normalize would produce there). - // - // The search radius is 2 cells on every axis (5x5x5), not the classic 1-cell (3x3x3) radius, - // because 3x3x3 is not exact: measured 9 of 400,000 points in [-50,50]^3 land on the wrong F2 - // (worst error 0.088), and past |p| of about 2^23 the float32 jitter can put two distinct cells' - // features on the same value, which 3x3x3 has no chance of noticing either way. 5x5x5 is exact, - // not merely safer, by the following argument: - // - // Let u = p - cell be the query's position inside its own cell (u in [0,1)^3 per component), and - // let a candidate feature at integer cell offset d = (dx, dy, dz) sit at d + j for some jitter j - // in [0,1)^3. Per axis, the displacement from p to that feature is (u_i - j_i) - d_i; since - // u_i - j_i is always strictly inside (-1, 1) regardless of the actual u_i and j_i values, - // |displacement_i| is always strictly greater than max(0, |d_i| - 1). So every cell with |d_i| >= - // 3 on some axis is strictly farther than 2 from p (that axis alone already gives max(0, 3-1) = - // 2). Now bound F1 and F2 from above using two real, always-present candidates: the query's own - // cell (d = 0), whose distance is always strictly less than sqrt(3) (every axis strictly under - // 1); and the near-side neighbour on whichever single axis's u_i sits closest to a cell - // boundary. Let m = min(u_i, 1 - u_i) on that chosen axis (m is in [0, 1/2] by construction, - // since it is the smaller of the two). Stepping one cell towards that nearer boundary puts the - // query within (1 + m) of the far face on the offset axis and within (1 - m) of the near face on - // each of the other two axes, so that neighbour's squared distance is at most - // (1 + m)^2 + 2*(1 - m)^2 = 3 - 2m + 3m^2, which is <= 3 for every m in [0, 1/2] (3 at m = 0, - // dipping to a minimum of 8/3 ~= 2.667 at m = 1/3, then rising back to 2.75 at m = 1/2), and - // strictly below 3 because the jitter never reaches exactly 0 or - // 1 (u_i - j_i stays strictly inside (-1, 1), so this bound, like the own-cell one, is never - // tight). F2 is at most the larger of these two real candidates (adding candidates to a set can - // only lower or hold its 2nd-smallest value), so F1 < sqrt(3) and F2 < sqrt(3) always: roughly - // 1.732 < 2, margin 2 - sqrt(3) ~= 0.268 (Soul's adversarial check, cut 2a-i: the worst - // realizable in-box F2 is exactly sqrt(3), reached only in the unattainable limit at a cell - // corner). Every cell outside the 5x5x5 block is farther than 2, hence farther than either F1 or - // F2, so the true global F1 and F2 are always inside it. (The matching argument for 3x3x3 only - // reaches radius 1, whose excluded cells start at distance > 1, which is less than the 1.732 - // ceiling — the gap 3x3x3's failures live in.) - // - // An earlier version of this proof picked the near-side neighbour on a fixed axis rather than - // whichever axis sits closest to its boundary, and that version is wrong (Soul, cut 2a-i): - // u = (0.5, 0, 0) with the x-neighbour's jittered feature at (-1, 1 - 2^-24, 1 - 2^-24) gives a - // distance of about 2.06, outside the radius-2 exclusion the proof needs. Choosing the axis by - // proximity to its own boundary is what keeps m <= 1/2 and the bound at sqrt(3); x was the wrong - // axis to fix there because u.x = 0.5 is the point on the whole cube farthest from any boundary. - // - // The loop below still visits every one of the 125 cells in a fixed order, but skips the - // pcg3d/jitter/distance work for a cell whose distance cannot possibly beat the current f2: that - // per-cell lower bound (the max(0, |d_i| - 1) term above, combined across axes) depends only on - // the integer offset, never on p or the hash, so pruning a cell the unpruned loop would also - // have rejected changes no output bit (CellularExactSearchTests pins the pruned/unpruned - // equivalence and the exactness against a 7x7x7 brute-force oracle). - public static CultCellular cellular(float3 p) - { - var cell = floor(p); - var f1 = 1.0e30f; - var f2 = 1.0e30f; - var c1 = new float3(0.0f, 0.0f, 0.0f); - var c2 = new float3(0.0f, 0.0f, 0.0f); - var cellId = new float3(0.0f, 0.0f, 0.0f); - - for (var dz = -2; dz <= 2; dz++) - { - var lz = max(0.0f, abs((float)dz) - 1.0f); - for (var dy = -2; dy <= 2; dy++) - { - var ly = max(0.0f, abs((float)dy) - 1.0f); - for (var dx = -2; dx <= 2; dx++) - { - var lx = max(0.0f, abs((float)dx) - 1.0f); - var lowerBound = sqrt(lx * lx + ly * ly + lz * lz); - if (lowerBound >= f2) - continue; - - var neighbor = cell + new float3(dx, dy, dz); - var hash = pcg3d(int3(neighbor)); - var jitter = new float3(cellular_unit(hash.x), cellular_unit(hash.y), cellular_unit(hash.z)); - var feature = neighbor + jitter; - var d = distance(p, feature); - - if (d < f1) - { - f2 = f1; c2 = c1; - f1 = d; c1 = feature; cellId = neighbor; - } - else if (d < f2) - { - f2 = d; c2 = feature; - } - } - } - } - - // F1 = 0 is reachable (p sits exactly on a feature point). F2 = 0 needs two distinct cells' - // pcg3d-jittered features to land on the same float32 value in every component: unreachable - // at ordinary magnitudes, but confirmed reachable past roughly |p| = 2^23 (design.md, - // "Precision domain"), so both share the same degenerate-gradient guard. - var grad1 = f1 > 0.0f ? (p - c1) / f1 : new float3(0.0f, 0.0f, 0.0f); - var grad2 = f2 > 0.0f ? (p - c2) / f2 : new float3(0.0f, 0.0f, 0.0f); - - // id comes from pcg4d over the winning cell's integer coordinate alone (same int-hashing - // rule as the jitter above), never from the pcg3d hash that produced its jitter: sharing a - // hash between id and jitter would make id a deterministic function of the jitter it is - // supposed to be independent from, correlated across every cell (F4). - var idHash = pcg4d(new int4(int3(cellId), 0)); - - return new CultCellular( - new float4(grad1, f1), - new float4(grad2 - grad1, f2 - f1), - cellular_unit(idHash.w)); - } - - // Maps a hash component's uint bit pattern to [0, 1) using the top 24 bits, so the result is - // always strictly less than 1: a plain divide-by-2^32 rounds 0xFFFFFF80..0xFFFFFFFF up to - // exactly 1.0f in float32, outside the documented range. (uint >> 8) has at most 24 significant - // bits, which float32's 24-bit mantissa represents exactly, and the division is by an exact power - // of two, so both the shift-and-convert and the divide are the same IEEE-754 round-to-nearest on - // dxc and C#, bit-exact on both sides. - internal static float cellular_unit(int bits) => ((uint)bits >> 8) * (1.0f / 16777216.0f); + private static float3 snoise_permute(float3 value) => snoise_mod289(((value * 34.0f) + 1.0f) * value); + private static float4 snoise_permute(float4 value) => snoise_mod289(((value * 34.0f) + 1.0f) * value); public static float value_noise(float2 position) { diff --git a/packages/cultmath/tests/CultMath.Tests/AffineTests.cs b/packages/cultmath/tests/CultMath.Tests/AffineTests.cs deleted file mode 100644 index 51bcacc5..00000000 --- a/packages/cultmath/tests/CultMath.Tests/AffineTests.cs +++ /dev/null @@ -1,699 +0,0 @@ -using CultMath; -using Xunit; -using static CultMath.math; - -namespace CultMath.Tests; - -/// -/// The affine forms of math.Affine.cs (design.md, "Affine forms"). A form (x0, a, e) is the set -/// x0 + a eps + e delta at the region's shared eps; every check evaluates that set in double and the -/// pointwise function in float32, with no tolerance. Operand values are float32 values drawn inside -/// their operands' sets at one shared eps, endpoints (eps and delta at -1 and 1) included. -/// -public sealed class AffineTests -{ - private readonly ITestOutputHelper output; - - public AffineTests(ITestOutputHelper output) => this.output = output; - - private static float Uniform(System.Random random, float lo, float hi) => lo + (hi - lo) * random.NextSingle(); - - private static float LogUniform(System.Random random, float lo, float hi) => - MathF.Exp(Uniform(random, MathF.Log(lo), MathF.Log(hi))); - - private static float Signed(System.Random random, float magnitude) => random.Next(2) == 0 ? -magnitude : magnitude; - - // Whether value lies in the form's set at eps, in double. - private static bool InForm(float3 form, float eps, double value) => - Math.Abs(value - (form.x + (double)form.y * eps)) <= form.z; - - // A form with its centre in [-20, 20] and |a| and e log-uniform over [1e-5, 20]; one in eight has - // a = 0 and one in eight e = 0. - private static float3 DrawForm(System.Random random) - { - var x0 = Uniform(random, -20.0f, 20.0f); - var a = random.Next(8) == 0 ? 0.0f : Signed(random, LogUniform(random, 1.0e-5f, 20.0f)); - var e = random.Next(8) == 0 ? 0.0f : LogUniform(random, 1.0e-5f, 20.0f); - return new float3(x0, a, e); - } - - private static float2 DrawInterval(System.Random random) - { - var lo = Uniform(random, -20.0f, 20.0f); - return new float2(lo, lo + (random.Next(8) == 0 ? 0.0f : LogUniform(random, 1.0e-5f, 40.0f))); - } - - // The tiny family: magnitudes from 1e-21 to 1e-17, products near and under 2^-126 = 1.2e-38, where a - // float32 result rounds to a subnormal and the absorption S 2^-20 is smaller than that loss. - private static float3 DrawTiny(System.Random random) => - new(random.Next(8) == 0 ? 0.0f : Signed(random, LogUniform(random, 1.0e-21f, 1.0e-17f)), - random.Next(4) == 0 ? 0.0f : Signed(random, LogUniform(random, 1.0e-21f, 1.0e-17f)), - random.Next(4) == 0 ? 0.0f : LogUniform(random, 1.0e-21f, 1.0e-17f)); - - private static float2 DrawTinyInterval(System.Random random) - { - var lo = Signed(random, LogUniform(random, 1.0e-21f, 1.0e-17f)); - return new float2(lo, lo + (random.Next(8) == 0 ? 0.0f : LogUniform(random, 1.0e-21f, 1.0e-17f))); - } - - // A float32 value in the form's set at eps, delta at an endpoint when asked; NaN when rounding leaves - // no float of the set near the drawn point (a set narrower than an ulp). - private static float Member(System.Random random, float3 form, float eps, bool endpoint) - { - var centre = form.x + (double)form.y * eps; - var delta = endpoint ? (random.Next(2) == 0 ? -1.0 : 1.0) : Uniform(random, -1.0f, 1.0f); - var value = (float)(centre + form.z * delta); - for (var k = 0; k < 4 && !InForm(form, eps, value); k++) - value = value > centre ? MathF.BitDecrement(value) : MathF.BitIncrement(value); - return InForm(form, eps, value) ? value : float.NaN; - } - - private static float MemberOf(System.Random random, float2 interval, bool endpoint) => - endpoint ? (random.Next(2) == 0 ? interval.x : interval.y) : Math.Clamp(Uniform(random, interval.x, interval.y), interval.x, interval.y); - - private readonly record struct Operands(float3 X, float3 Y, float2 Iv, float S); - - private readonly record struct Values(float X, float Y, float V, float S); - - // One op under the harness: Build gives the result's membership test (eps, value) from the operand - // forms, F the pointwise float32 function of operand values. - private sealed record Op(string Name, Func> Build, Func F); - - private static Func Form(float3 form) => (eps, value) => InForm(form, eps, value); - - private static Func Range(float2 range) => (_, value) => value >= range.x && value <= range.y; - - private static readonly Op[] Ops = - { - new("af_point", o => Form(af_point(o.X.x)), v => v.S), - new("af_symbol", o => Form(af_symbol(o.X.x, o.X.y)), v => v.S), - new("af_from_iv", o => Form(af_from_iv(o.Iv)), v => v.V), - new("af_range", o => Range(af_range(o.X)), v => v.X), - new("af_add", o => Form(af_add(o.X, o.Y)), v => v.X + v.Y), - new("af_sub", o => Form(af_sub(o.X, o.Y)), v => v.X - v.Y), - new("af_neg", o => Form(af_neg(o.X)), v => -v.X), - new("af_scale", o => Form(af_scale(o.X, o.S)), v => v.X * v.S), - new("af_add_iv", o => Form(af_add_iv(o.X, o.Iv)), v => v.X + v.V), - new("af_mul", o => Form(af_mul(o.X, o.Y)), v => v.X * v.Y), - }; - - // Runs one op over `forms` seeded operand draws x 16 (eps, delta) draws; returns the misses and up to - // four witnesses. The first four draws per form put eps at an endpoint, the first eight delta. - // af_point and af_symbol are checked on their defining value: the point x0 itself, and x0 + a eps in - // double (the symbol defines eps, so it has no float32 evaluation to enclose). - private static (int Misses, List Witness) Harness(Op op, int seed, int forms = 10_000, Func? draw = null, bool tiny = false) - { - draw ??= tiny ? DrawTiny : DrawForm; - var random = new System.Random(seed); - var misses = 0; - var witness = new List(); - for (var t = 0; t < forms; t++) - { - var operands = new Operands(draw(random), draw(random), tiny ? DrawTinyInterval(random) : DrawInterval(random), - random.Next(8) == 0 ? 0.0f : tiny ? Signed(random, LogUniform(random, 1.0e-32f, 1.0e-19f)) : Uniform(random, -4.0f, 4.0f)); - var contains = op.Build(operands); - for (var d = 0; d < 16; d++) - { - var eps = d < 4 ? (d % 2 == 0 ? -1.0f : 1.0f) : Uniform(random, -1.0f, 1.0f); - var endpoint = d < 8; - var x = Member(random, operands.X, eps, endpoint); - var y = Member(random, operands.Y, eps, endpoint); - if (float.IsNaN(x) || float.IsNaN(y)) - continue; - var v = MemberOf(random, operands.Iv, endpoint); - double f = op.Name switch - { - "af_point" => operands.X.x, - "af_symbol" => operands.X.x + (double)operands.X.y * eps, - _ => op.F(new Values(x, y, v, operands.S)), - }; - if (!contains(eps, f)) - { - misses++; - if (witness.Count < 4) - witness.Add($"{op.Name}: X {operands.X}, Y {operands.Y}, iv {operands.Iv}, s {operands.S:R}; eps {eps:R}, values ({x:R}, {y:R}, {v:R}) give {f:R}"); - } - } - } - - return (misses, witness); - } - - [Fact] - public void EveryOpEnclosesItsPoints() - { - var failures = new List(); - foreach (var op in Ops) - { - var (misses, witness) = Harness(op, 0xAF00); - if (misses > 0) - failures.Add($"{op.Name}: {misses} misses" + Environment.NewLine + string.Join(Environment.NewLine, witness)); - } - - Assert.True(failures.Count == 0, string.Join(Environment.NewLine, failures)); - } - - private static float3 Shrink(float3 form) => new(form.x, form.y, form.z > 0.0f ? MathF.BitDecrement(form.z) : 0.0f); - - // Each op with its rounding absorption removed: the propagated error alone, computed in float32. - private static readonly Op[] Unabsorbed = - { - new("af_from_iv", o => Form(new float3((o.Iv.x + o.Iv.y) * 0.5f, 0.0f, (o.Iv.y - o.Iv.x) * 0.5f)), v => v.V), - new("af_range", o => Range(new float2(o.X.x - (MathF.Abs(o.X.y) + o.X.z), o.X.x + (MathF.Abs(o.X.y) + o.X.z))), v => v.X), - new("af_add", o => Form(new float3(o.X.x + o.Y.x, o.X.y + o.Y.y, o.X.z + o.Y.z)), v => v.X + v.Y), - new("af_sub", o => Form(new float3(o.X.x - o.Y.x, o.X.y - o.Y.y, o.X.z + o.Y.z)), v => v.X - v.Y), - new("af_scale", o => Form(new float3(o.X.x * o.S, o.X.y * o.S, o.X.z * MathF.Abs(o.S))), v => v.X * v.S), - new("af_add_iv", o => Form(new float3(o.X.x + (o.Iv.x + o.Iv.y) * 0.5f, o.X.y, o.X.z + (o.Iv.y - o.Iv.x) * 0.5f)), v => v.X + v.V), - new("af_mul", o => Form(new float3(o.X.x * o.Y.x, o.X.x * o.Y.y + o.Y.x * o.X.y, - MathF.Abs(o.X.x) * o.Y.z + MathF.Abs(o.Y.x) * o.X.z + (MathF.Abs(o.X.y) + o.X.z) * (MathF.Abs(o.Y.y) + o.Y.z))), v => v.X * v.Y), - }; - - // One-ulp mutants that survive, each with the reason. A rounding absorption bounds the worst case - // over every operand value, and 2^-20 S is 16u S, at least eight ulps of the larger of |x0|, |a| and - // e; one ulp less of e leaves the rest of that margin, which no sampled rounding can cross. - private static readonly Dictionary OneUlpSurvivors = new() - { - ["af_from_iv"] = "the absorption (|x0| + e) 2^-20 is at least eight ulps of e over the one rounding of x0 and e it covers", - ["af_range"] = "each endpoint moves outward by (|x0| + |a| + e) 2^-20, eight ulps past the one rounding it covers", - ["af_add"] = "the absorption 2^-20 S is eight ulps of S's largest term past the three roundings it covers", - ["af_sub"] = "as af_add", - ["af_scale"] = "as af_add", - ["af_add_iv"] = "two absorptions, af_from_iv's and af_add's", - ["af_mul"] = "the absorption 2^-20 (|x0| + |x0 a_y| + |y0 a_x| + e) is eight ulps past the products it covers", - }; - - /// - /// The rounding absorptions are load-bearing: with each op's absorption removed (Unabsorbed), the - /// harness finds a miss for every op. Each op's e shrunk by one ulp is run too; it survives for every - /// op, because the absorption is a worst-case bound many ulps wide, and each survivor is named with - /// its reason in OneUlpSurvivors. A one-ulp mutant that starts failing, or one that is not named, - /// fails this test, so the list cannot go stale. - /// - [Fact] - public void EveryRoundingTermIsCaught() - { - var problems = new List(); - foreach (var mutant in Unabsorbed) - { - var (misses, _) = Harness(mutant, 0xAF01); - output.WriteLine($"AF-REPORT {mutant.Name} without absorption: {misses} misses"); - if (misses == 0) - problems.Add($"{mutant.Name}: removing the rounding absorption is not caught"); - } - - foreach (var op in Ops.Where(o => o.Name is not ("af_point" or "af_symbol" or "af_neg"))) - { - var shrunk = op.Name == "af_range" - ? op with { Build = o => { var r = af_range(o.X); return Range(new float2(MathF.BitIncrement(r.x), MathF.BitDecrement(r.y))); } } - : op with { Build = o => Form(Shrink(BuildForm(op.Name, o))) }; - var (misses, _) = Harness(shrunk, 0xAF02); - output.WriteLine($"AF-REPORT {op.Name} with e one ulp short: {misses} misses"); - var named = OneUlpSurvivors.ContainsKey(op.Name); - if (misses == 0 && !named) - problems.Add($"{op.Name}: e one ulp short survives and is not named"); - if (misses > 0 && named) - problems.Add($"{op.Name}: e one ulp short is now caught; remove it from OneUlpSurvivors"); - } - - Assert.True(problems.Count == 0, string.Join(Environment.NewLine, problems)); - } - - private static float3 BuildForm(string name, Operands o) => name switch - { - "af_from_iv" => af_from_iv(o.Iv), - "af_add" => af_add(o.X, o.Y), - "af_sub" => af_sub(o.X, o.Y), - "af_scale" => af_scale(o.X, o.S), - "af_add_iv" => af_add_iv(o.X, o.Iv), - "af_mul" => af_mul(o.X, o.Y), - _ => throw new ArgumentException(name), - }; - - /// - /// The shared symbol correlates: for x = af_symbol(x0, a), af_sub(x, x) and af_add(x, af_neg(x)) have - /// a = 0 and e at most their own rounding, and af_sub(af_scale(x, 2), af_add(x, x)) has a = 0. A - /// mutant of af_add, af_sub or af_scale that condensed a into e would leave e of order |a|. - /// - [Fact] - public void SharedSymbolCorrelates() - { - var random = new System.Random(0xAF03); - for (var t = 0; t < 10_000; t++) - { - var x = af_symbol(Uniform(random, -20.0f, 20.0f), Signed(random, LogUniform(random, 1.0e-5f, 20.0f))); - foreach (var (name, form) in new[] - { - ("af_sub(x, x)", af_sub(x, x)), - ("af_add(x, af_neg(x))", af_add(x, af_neg(x))), - ("af_sub(af_scale(x, 2), af_add(x, x))", af_sub(af_scale(x, 2.0f), af_add(x, x))), - }) - { - var rounding = (MathF.Abs(x.x) + MathF.Abs(x.y)) * 1.0e-5f; - Assert.True(form.y == 0.0f && form.z <= rounding, $"{name} for x = {x} is {form}: a must be 0 and e at most {rounding:R}"); - } - } - } - - // Forms whose range straddles zero (|x0| below |a| + e) or is one-signed (|x0| above it). - private static float3 DrawSigned(System.Random random, bool straddle) - { - var a = Signed(random, LogUniform(random, 1.0e-3f, 10.0f)); - var e = LogUniform(random, 1.0e-3f, 10.0f); - var reach = MathF.Abs(a) + e; - return new float3(Signed(random, straddle ? Uniform(random, 0.0f, 0.9f * reach) : reach * Uniform(random, 1.1f, 4.0f)), a, e); - } - - /// - /// af_mul encloses the product over forms that straddle zero and forms that are one-signed, every - /// sign combination. The eps^2 term a_x a_y is what the condensed e carries for eps at +-1: a mutant - /// dropping |a_x a_y| from e misses there. - /// - [Fact] - public void MulEnclosesEverySignCase() - { - var mul = Ops.Single(o => o.Name == "af_mul"); - var dropped = mul with - { - Build = o => - { - var r = af_mul(o.X, o.Y); - return Form(new float3(r.x, r.y, r.z - MathF.Abs(o.X.y * o.Y.y))); - }, - }; - foreach (var (sx, sy) in new[] { (true, true), (true, false), (false, true), (false, false) }) - { - var seed = 0xAF04 + (sx ? 1 : 0) + (sy ? 2 : 0); - var flip = 0; - float3 Draw(System.Random r) => DrawSigned(r, (flip++ % 2 == 0) ? sx : sy); - var (misses, witness) = Harness(mul, seed, 5_000, Draw); - Assert.True(misses == 0, $"af_mul, straddling ({sx}, {sy}): {misses} misses" + Environment.NewLine + string.Join(Environment.NewLine, witness)); - flip = 0; - var (caught, _) = Harness(dropped, seed, 5_000, Draw); - Assert.True(caught > 0, $"af_mul without |a_x a_y|, straddling ({sx}, {sy}), is not caught"); - } - } - - // af_snoise's float32 allowance, as its doc comment states it, for the width comparison below. - private static double Allowance(float3 centre, double reach) => - Math.ScaleB(1.0, -14) + Math.ScaleB(reach, -12) - + SNOISE_LIPSCHITZ * Math.ScaleB(Math.Abs(centre.x) + Math.Abs(centre.y) + Math.Abs(centre.z) + reach, -20); - - private static float3 UnitVector(System.Random random) - { - float3 v; - do - { - v = new float3(Uniform(random, -1.0f, 1.0f), Uniform(random, -1.0f, 1.0f), Uniform(random, -1.0f, 1.0f)); - } - while (dot(v, v) > 1.0f || dot(v, v) < 1.0e-4f); - - return normalize(v); - } - - // A float32 point of the set centre + axis eps + w, |w| <= radius, checked in double; the first eight - // w are on the surface. Where the float32 sum rounds a point out of the set, w is pulled in by the - // overshoot and 2^-21 (|centre|_1 + |axis|_1) and the sum retried; a point that still rounds out is - // reported as null and skipped. - private static float3? PointOf(System.Random random, float3 centre, float3 axis, float radius, float eps, int index) - { - var w = UnitVector(random) * (index < 8 ? radius : radius * MathF.Cbrt(random.NextSingle())); - for (var k = 0; k < 6; k++) - { - var p = centre + axis * eps + w; - var (dx, dy, dz) = (p.x - (centre.x + (double)axis.x * eps), p.y - (centre.y + (double)axis.y * eps), p.z - (centre.z + (double)axis.z * eps)); - var distance = Math.Sqrt(dx * dx + dy * dy + dz * dz); - if (distance <= radius) - return p; - w *= (float)(Math.Max(0.0, 2.0 * radius - distance - Math.ScaleB(Math.Abs(centre.x) + Math.Abs(centre.y) + Math.Abs(centre.z) + Math.Abs(axis.x) + Math.Abs(axis.y) + Math.Abs(axis.z), -21)) / radius); - } - - return null; - } - - /// - /// af_snoise and af_fbm over 2,000 (centre, axis, radius) each: centres in [-20, 20]^3, radius - /// log-uniform in [1e-4, 2], |axis| uniform in [0, 2] (an eighth exactly 0). 64 points - /// centre + axis eps + w per case, eps at -1 and 1 for the first eight; snoise (fbm_grad(...).w) in - /// float32 lies in the form at eps, no tolerance. Dropping the M R^2 / 2 remainder from a centred - /// form misses. af_snoise's total width is never more than the Lipschitz form's, L R plus the - /// allowance. - /// - [Fact] - public void SnoiseFormEnclosesBall() - { - var random = new System.Random(0xAF10); - var (misses, remainderMisses, skipped, centredCases) = (0, 0, 0, 0); - var witness = new List(); - for (var b = 0; b < 4000; b++) - { - var fbm = b >= 2000; - var centre = new float3(Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f)); - var axis = random.Next(8) == 0 ? new float3(0.0f, 0.0f, 0.0f) : UnitVector(random) * Uniform(random, 0.0f, 2.0f); - var radius = LogUniform(random, 1.0e-4f, 2.0f); - var (octaves, lacunarity, gain) = (random.Next(0, 7), Uniform(random, 1.5f, 2.5f), Uniform(random, 0.3f, 0.7f)); - var form = fbm ? af_fbm(centre, axis, radius, octaves, lacunarity, gain) : af_snoise(centre, axis, radius); - var reach = (double)length(axis) + radius; - var remainder = 0.5 * SNOISE_HESSIAN * reach * reach; - var mutant = new float3(form.x, form.y, (float)(form.z - remainder)); - if (!fbm) - { - var lipschitz = (SNOISE_LIPSCHITZ * reach + Allowance(centre, reach) + Math.ScaleB(Math.Abs(form.x), -20)) * (1.0 + Math.ScaleB(1.0, -18)); - Assert.True(Math.Abs(form.y) + form.z <= lipschitz, $"af_snoise({centre}, {axis}, {radius:R}) = {form} is wider than the Lipschitz form's half-width {lipschitz:R}"); - centredCases += form.y != 0.0f ? 1 : 0; - } - - for (var i = 0; i < 64; i++) - { - var eps = i < 8 ? (i % 2 == 0 ? -1.0f : 1.0f) : Uniform(random, -1.0f, 1.0f); - var p = PointOf(random, centre, axis, radius, eps, i); - if (p is not { } point) - { - skipped++; - continue; - } - - var value = fbm ? fbm_grad(point, octaves, lacunarity, gain).w : snoise(point); - if (!InForm(form, eps, value)) - { - misses++; - if (witness.Count < 4) - witness.Add($"{(fbm ? $"af_fbm(..., {octaves}, {lacunarity:R}, {gain:R})" : "af_snoise")}({centre}, {axis}, {radius:R}) = {form} misses {value:R} at eps {eps:R}, {point}"); - } - - if (!fbm && form.y != 0.0f && !InForm(mutant, eps, value)) - remainderMisses++; - } - } - - output.WriteLine($"AF-REPORT af_snoise/af_fbm enclosure: {misses} misses, {skipped} points skipped (rounded out of the set), {centredCases} of 2000 af_snoise cases centred, {remainderMisses} misses with the remainder dropped"); - Assert.True(misses == 0, string.Join(Environment.NewLine, witness)); - Assert.True(skipped < 64 * 4000 / 100, $"{skipped} points rounded out of their sets"); - Assert.True(remainderMisses > 0, "dropping M R^2 / 2 from the centred form is not caught"); - } - - /// - /// At radius 1e-3 and |axis| = 1e-3, af_snoise takes the centred form in every one of 2,000 seeded - /// cases (a is nonzero), and its mean total width is under half of the Lipschitz form's 2 L R. A - /// mutant that always returns the Lipschitz form has a = 0. - /// - [Fact] - public void SnoiseChoosesTheCentredFormWhereNarrower() - { - var random = new System.Random(0xAF11); - var sum = 0.0; - for (var b = 0; b < 2000; b++) - { - var centre = new float3(Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f)); - var axis = UnitVector(random) * 1.0e-3f; - var form = af_snoise(centre, axis, 1.0e-3f); - var lipschitz = 2.0 * SNOISE_LIPSCHITZ * 2.0e-3; - var width = 2.0 * (Math.Abs(form.y) + form.z); - Assert.True(form.y != 0.0f && width < lipschitz, $"af_snoise({centre}, {axis}, 1e-3) = {form}: not the centred form, or no narrower than 2 L R = {lipschitz:R}"); - sum += width / lipschitz; - } - - output.WriteLine($"AF-REPORT af_snoise at radius 1e-3: mean width over 2 L R {sum / 2000:F3}"); - Assert.True(sum / 2000 < 0.5, $"mean width over 2 L R is {sum / 2000:F3}, not under half"); - } - - /// - /// af_frustum_ball and af_frustum_axis over iv_frustum_ball's families (NoiseBoundTests.DrawBallCase: - /// the r2 domain and the degenerate, thin, wide-slope, far, from-the-camera, tiny-focal and huge-warp - /// extremes), 2,000 tiles each, warp passed as the warp variation: every exact ray point (m z, z), - /// formed in double from the float32 slope and depth at the footprint's corners at both depth ends - /// (and 56 more for the r2 domain), moved by a full-length outward flow of length warp, is within - /// radius of centre + axis eps(z), eps(z) = clamp((z - z_m) / h, -1, 1) with z_m and h the centre's z - /// and the axis's z (0 when h is 0). The radius is pinned to the derivation both ways: - /// r <= w <= r + 2^-19 (r + |c|_1 + |axis|_1), r = z1 footprintPerDepth + warp in double. - /// - [Fact] - public void FrustumSliceEnclosesEveryRayPoint() - { - var random = new System.Random(0xAF12); - string[] families = { "r2 domain", "degenerate", "thin", "wide slope", "far", "from the camera", "tiny focal", "huge warp" }; - var failures = new Dictionary(); - var witness = new List(); - foreach (var family in families) - { - failures[family] = 0; - for (var t = 0; t < 2000; t++) - { - var (n, focal, slope, z0, z1, warp) = NoiseBoundTests.DrawBallCase(random, family); - var half = n / (2.0f * focal); - var footprint = n / (MathF.Sqrt(2.0f) * focal); - var axis = af_frustum_axis(slope, z0, z1); - var ball = af_frustum_ball(slope, z0, z1, footprint, warp); - var (cx, cy, cz, w) = ((double)ball.x, (double)ball.y, (double)ball.z, (double)ball.w); - var r = z1 * (double)footprint + warp; - var c1 = Math.Abs(cx) + Math.Abs(cy) + Math.Abs(cz); - var a1 = Math.Abs((double)axis.x) + Math.Abs((double)axis.y) + Math.Abs((double)axis.z); - if (!(r <= w && w <= r + Math.ScaleB(r + c1 + a1, -19))) - { - failures[family]++; - if (witness.Count < 8) - witness.Add($"{family} pin: af_frustum_ball({slope}, {z0:R}, {z1:R}, {footprint:R}, {warp:R}) = {ball}, derivation {r:R}"); - } - - // The axis is (m_c, 1) h exactly, and the radius carries the documented widening, the - // rounding of the centre, the axis (spread) and the radius at 2^-20 each, to 15% (the - // radius rounds too). - var h = (z1 - z0) * 0.5f; - var spread = ((double)Math.Abs(slope.x) + Math.Abs(slope.y) + 1.0) * h; - var widening = Math.ScaleB(c1 + spread + r, -20); - if (!(axis.z == h && axis.x == slope.x * h && axis.y == slope.y * h && Math.Abs(w - r - widening) <= 0.15 * widening + Math.ScaleB(w, -22))) - { - failures[family]++; - if (witness.Count < 8) - witness.Add($"{family} axis or widening: af_frustum_ball({slope}, {z0:R}, {z1:R}, {footprint:R}, {warp:R}) = {ball}, axis {axis}, widening {w - r:R} against {widening:R}"); - } - - for (var i = 0; i < (family == "r2 domain" ? 64 : 8); i++) - { - var offset = i < 8 - ? new float2((i & 1) == 0 ? -half : half, (i & 2) == 0 ? -half : half) - : new float2(Uniform(random, -half, half), Uniform(random, -half, half)); - var z = i < 8 ? ((i & 4) == 0 ? z0 : z1) : Uniform(random, z0, z1); - var m = slope + offset; - var eps = axis.z == 0.0f ? 0.0 : Math.Clamp((z - cz) / axis.z, -1.0, 1.0); - var (qx, qy, qz) = (cx + axis.x * eps, cy + axis.y * eps, cz + axis.z * eps); - var (dx, dy, dz) = (m.x * (double)z - qx, m.y * (double)z - qy, z - qz); - var away = Math.Sqrt(dx * dx + dy * dy + dz * dz); - var distance = away + warp; - if (!(distance <= w)) - { - failures[family]++; - if (witness.Count < 8) - witness.Add($"{family}: af_frustum_ball({slope}, {z0:R}, {z1:R}, {footprint:R}, {warp:R}) = {ball}, axis {axis} misses slope {m}, depth {z:R} by {(distance - w) / w:R} r"); - } - } - } - } - - Assert.True(failures.Values.Sum() == 0, string.Join(", ", families.Select(f => $"{f} {failures[f]}")) + Environment.NewLine + string.Join(Environment.NewLine, witness)); - } - - /// - /// Underflow. Operands of magnitude 1e-21 to 1e-17 put products near and under 2^-126, where float32 - /// rounds to a subnormal and the relative absorption S 2^-20 is smaller than the loss: every op - /// still encloses, no tolerance. af_mul and af_scale carry the 2^-126 term; a mutant that subtracts - /// it misses here. - /// - [Fact] - public void TinyOperandsEncloseTheirPoints() - { - var failures = new List(); - foreach (var op in Ops) - { - var (misses, witness) = Harness(op, 0xAF05, 10_000, tiny: true); - if (misses > 0) - failures.Add($"{op.Name}: {misses} misses" + Environment.NewLine + string.Join(Environment.NewLine, witness)); - } - - Assert.True(failures.Count == 0, string.Join(Environment.NewLine, failures)); - } - - private const float MinNormal = 1.17549435e-38f; - - private static bool Near(double observed, double expected, double relative = 1.0e-5) => - Math.Abs(observed - expected) <= relative * Math.Abs(expected); - - /// - /// The rounding absorption of each op, pinned both ways. With no propagated error in e, af_add, - /// af_sub, af_scale, af_mul and af_from_iv return an e equal to their documented absorption (and - /// 2^-126 where documented) to a part in 1e5 of its double value, and af_range moves each endpoint - /// outward by (|x0| + |a| + e) 2^-20 to 30% (the endpoints round once). A factor, a sign or an - /// operator changed in any of them fails here; the one-ulp changes of the worst-case absorption are - /// the OneUlpSurvivors set EveryRoundingTermIsCaught names. - /// - [Fact] - public void AbsorptionsArePinned() - { - var u20 = Math.ScaleB(1.0, -20); - var random = new System.Random(0xAF06); - for (var t = 0; t < 2_000; t++) - { - var (x0, y0) = (Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f)); - var (ax, ay) = (Signed(random, LogUniform(random, 1.0e-3f, 20.0f)), Signed(random, LogUniform(random, 1.0e-3f, 20.0f))); - var scale = Signed(random, LogUniform(random, 1.0e-2f, 4.0f)); - var x = new float3(x0, ax, 0.0f); - var y = new float3(y0, ay, 0.0f); - - var sum = af_add(x, y); - Assert.True(Near(sum.z, (Math.Abs((double)sum.x) + Math.Abs((double)sum.y)) * u20), $"af_add({x}, {y}) = {sum}: e is not (|x0| + |a|) 2^-20"); - var difference = af_sub(x, y); - Assert.True(Near(difference.z, (Math.Abs((double)difference.x) + Math.Abs((double)difference.y)) * u20), $"af_sub({x}, {y}) = {difference}: e is not (|x0| + |a|) 2^-20"); - var scaled = af_scale(x, scale); - Assert.True(Near(scaled.z, (Math.Abs((double)scaled.x) + Math.Abs((double)scaled.y)) * u20 + MinNormal), $"af_scale({x}, {scale:R}) = {scaled}: e is not (|x0| + |a|) 2^-20 + 2^-126"); - - // a_x = 0 leaves the product's propagated error 0 and its a = x0 a_y. - var px = new float3(x0, 0.0f, 0.0f); - var product = af_mul(px, y); - var terms = Math.Abs((double)product.x) + Math.Abs((double)x0 * ay); - Assert.True(Near(product.z, terms * u20 + MinNormal), $"af_mul({px}, {y}) = {product}: e is not (|x0 y0| + |x0 a_y|) 2^-20 + 2^-126"); - - var iv = DrawInterval(random); - var form = af_from_iv(iv); - var (mid, half) = (((double)iv.x + iv.y) / 2.0, ((double)iv.y - iv.x) / 2.0); - var expected = half + (Math.Abs(mid) + half) * u20 + MinNormal; - Assert.True(Math.Abs(form.z - expected) <= 1.0e-5 * (Math.Abs(mid) + half) * u20 + 1.0e-6 * half + 1.0e-12 * expected, - $"af_from_iv({iv}) = {form}: e is not half-width + (|mid| + half-width) 2^-20 + 2^-126 = {expected:R}"); - - var wide = new float3(Uniform(random, -20.0f, 20.0f), Signed(random, LogUniform(random, 1.0e-3f, 20.0f)), LogUniform(random, 1.0e-3f, 20.0f)); - var range = af_range(wide); - var reach = Math.Abs((double)wide.y) + wide.z; - var absorption = (Math.Abs((double)wide.x) + reach) * u20; - var outward = ((double)range.y - range.x) / 2.0 - reach; - Assert.True(Math.Abs(outward - absorption) <= 0.3 * absorption, $"af_range({wide}) = {range}: endpoints are {outward:R} past x0 -+ (|a| + e), not (|x0| + |a| + e) 2^-20 = {absorption:R}"); - } - } - - /// - /// af_from_iv and af_range at the float32 extremes. Subnormal endpoints (including [0, the least - /// subnormal], whose halved width underflows to 0) and endpoints near the float maximum (where lo + - /// hi, hi - lo or the absorption would overflow) give a form whose set holds both endpoints and the - /// midpoint, and an af_range that holds them with no NaN endpoint. A form with an infinite or NaN - /// component, as an overflowed op returns, gives an af_range with no NaN endpoint. - /// - [Fact] - public void FromIntervalAndRangeHoldAtTheExtremes() - { - var least = BitConverter.Int32BitsToSingle(1); - var max = float.MaxValue; - var random = new System.Random(0xAF07); - var specials = new[] { 0.0f, least, 2 * least, 100 * least, MinNormal - least, MinNormal, 3.0f * MinNormal, 1.0e-30f, 1.0f, 1.0e20f, 1.0e30f, max / 4, max / 2, max * 0.75f, max }; - var misses = new List(); - void Check(float lo, float hi) - { - var form = af_from_iv(new float2(lo, hi)); - var range = af_range(form); - if (float.IsNaN(form.x) || float.IsNaN(form.z) || float.IsNaN(range.x) || float.IsNaN(range.y)) - misses.Add($"af_from_iv([{lo:R}, {hi:R}]) = {form}, af_range = {range}: NaN"); - foreach (var value in new[] { lo, hi, (float)(((double)lo + hi) / 2.0) }) - { - if (!InForm(form, 0.0f, value)) - misses.Add($"af_from_iv([{lo:R}, {hi:R}]) = {form} misses {value:R}"); - if (!(range.x <= value && value <= range.y)) - misses.Add($"af_range(af_from_iv([{lo:R}, {hi:R}])) = {range} misses {value:R}"); - } - - // Tight where the answer is representable: an endpoint is no farther than 2^-18 (|lo| + |hi|) - // from the interval's, unless that bound passes the float maximum, where infinity is the answer. - var slack = Math.ScaleB(Math.Abs((double)lo) + Math.Abs((double)hi), -18) + 1.0e-37; - if ((double)lo - slack > -(double)max && range.x < (double)lo - slack) - misses.Add($"af_range(af_from_iv([{lo:R}, {hi:R}])).x = {range.x:R}, more than 2^-18 (|lo| + |hi|) under lo"); - if ((double)hi + slack < (double)max && range.y > (double)hi + slack) - misses.Add($"af_range(af_from_iv([{lo:R}, {hi:R}])).y = {range.y:R}, more than 2^-18 (|lo| + |hi|) over hi"); - } - - foreach (var a in specials) - foreach (var b in specials) - { - Check(-a, b); - Check(-Math.Max(a, b), -Math.Min(a, b)); - Check(Math.Min(a, b), Math.Max(a, b)); - } - - for (var t = 0; t < 200_000; t++) - { - var sign = random.Next(2) == 0 ? 1 : -1; - var lo = sign * BitConverter.Int32BitsToSingle(random.Next(0, random.Next(2) == 0 ? 1 << 20 : 0x00800000)); - var width = BitConverter.Int32BitsToSingle(random.Next(0, random.Next(2) == 0 ? 1 << 12 : 1 << 22)); - Check(lo, lo + width); - } - - var odd = new[] { float.PositiveInfinity, float.NegativeInfinity, float.NaN, 0.0f, 1.0f, max }; - foreach (var x0 in odd) - foreach (var a in odd) - foreach (var e in odd) - { - var range = af_range(new float3(x0, a, e)); - // The range encloses x0 -+ (|a| + e) wherever that is a number, and is the whole line on the - // side where it is not (infinity minus infinity, a NaN component): the infinity on that side. - var spread = Math.Abs((double)a) + e; - var enclosesLow = double.IsNaN(x0 - spread) ? range.x == float.NegativeInfinity : range.x <= x0 - spread; - var enclosesHigh = double.IsNaN(x0 + spread) ? range.y == float.PositiveInfinity : range.y >= x0 + spread; - if (!enclosesLow || !enclosesHigh) - misses.Add($"af_range(({x0}, {a}, {e})) = {range}"); - } - - Assert.True(misses.Count == 0, $"{misses.Count} misses:" + Environment.NewLine + string.Join(Environment.NewLine, misses.Take(8))); - } - - /// - /// af_snoise's width, pinned both ways. Over 6,000 seeded (centre, axis, radius) with reach R from 1e-3 - /// to 3 (centres in [-20, 20]^3, a third out to [-1000, 1000]^3, a third of the axes and a third of the - /// radii 0), the form is the documented rule evaluated in double from snoise_grad: x0 = n; the centred - /// form when |g . axis| + |g| radius + M R^2 / 2 is under L R (checked away from that boundary), else - /// the Lipschitz form; e = that half-width + the float32 allowance (2^-14 + 2^-12 R + L 2^-20 (|centre|_1 + R)) - /// plus the form's own rounding absorption (|n| + |a| + e) 2^-20; each of x0, a and e within a part in - /// 1e6 of it. The enclosure tests pass on an allowance or an absorption of any size on the CPU, where - /// float32 is exact; this is the test that sees them. - /// - [Fact] - public void SnoiseFormCarriesItsDocumentedWidth() - { - var u20 = Math.ScaleB(1.0, -20); - double lipschitz = SNOISE_LIPSCHITZ, hessian = SNOISE_HESSIAN; - var random = new System.Random(0xAF13); - var (centred, wide) = (0, 0); - for (var t = 0; t < 6_000; t++) - { - var spread = t % 3 == 2 ? 1000.0f : 20.0f; - var centre = new float3(Uniform(random, -spread, spread), Uniform(random, -spread, spread), Uniform(random, -spread, spread)); - var axis = random.Next(3) == 0 ? new float3(0.0f, 0.0f, 0.0f) : UnitVector(random) * LogUniform(random, 1.0e-3f, 3.0f); - var radius = random.Next(3) == 0 ? 0.0f : LogUniform(random, 1.0e-3f, 3.0f); - var g = snoise_grad(centre); - var reach = (double)length(axis) + radius; - var lip = lipschitz * reach; - var a = (double)g.x * axis.x + (double)g.y * axis.y + (double)g.z * axis.z; - var remainder = Math.Sqrt((double)g.x * g.x + (double)g.y * g.y + (double)g.z * g.z) * radius + 0.5 * hessian * reach * reach; - var allowance = Math.ScaleB(1.0, -14) + Math.ScaleB(reach, -12) - + lipschitz * u20 * (Math.Abs((double)centre.x) + Math.Abs((double)centre.y) + Math.Abs((double)centre.z) + reach); - - double Width(bool useCentred, out double slope) - { - slope = useCentred ? a : 0.0; - var e = (useCentred ? remainder : lip) + allowance; - return e + (Math.Abs((double)g.w) + Math.Abs(slope) + e) * u20; - } - - var zCentred = Width(true, out var slopeCentred); - var zLipschitz = Width(false, out _); - var form = af_snoise(centre, axis, radius); - var observedCentred = Math.Abs(form.z - zCentred) <= Math.Abs(form.z - zLipschitz); - var expectedCentred = Math.Abs(a) + remainder < lip; - if (Math.Abs(Math.Abs(a) + remainder - lip) > 1.0e-3 * lip) - Assert.True(observedCentred == expectedCentred || zCentred == zLipschitz, $"af_snoise({centre}, {axis}, {radius:R}) = {form} took the {(observedCentred ? "centred" : "Lipschitz")} form; the rule takes the {(expectedCentred ? "centred" : "Lipschitz")} one (|a| + remainder = {Math.Abs(a) + remainder:R}, L R = {lip:R})"); - var z = observedCentred ? zCentred : zLipschitz; - var slope = observedCentred ? slopeCentred : 0.0; - Assert.True(form.x == g.w, $"af_snoise({centre}, {axis}, {radius:R}).x0 = {form.x:R}, snoise = {g.w:R}"); - Assert.True(Math.Abs(form.y - slope) <= 1.0e-5 * Math.Abs((double)length(new float3(g.x, g.y, g.z)) * length(axis)) + 1.0e-12, $"af_snoise({centre}, {axis}, {radius:R}).a = {form.y:R}, g . axis = {slope:R}"); - Assert.True(Math.Abs(form.z - z) <= 1.0e-6 * z, $"af_snoise({centre}, {axis}, {radius:R}) = {form}: e is {form.z:R}, the documented rule gives {z:R}"); - centred += observedCentred ? 1 : 0; - wide += !observedCentred ? 1 : 0; - } - - output.WriteLine($"AF-REPORT af_snoise width: {centred} centred cases, {wide} Lipschitz cases"); - Assert.True(centred > 1000 && wide > 1000, $"the cases do not exercise both forms: {centred} centred, {wide} Lipschitz"); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/BatchMathTests.cs b/packages/cultmath/tests/CultMath.Tests/BatchMathTests.cs deleted file mode 100644 index 62280c74..00000000 --- a/packages/cultmath/tests/CultMath.Tests/BatchMathTests.cs +++ /dev/null @@ -1,427 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -// Stryker's mtp baseline on hands/adopt-stryker found BatchMath undefended in three ways: -// both existing tests used 2-3 particles while LaneCount >= 4, so the vector body never ran -// and only the scalar tail executed; both held y at 0 for every particle, so every y-axis -// mutation was invisible; and the guard branches (early return, negative deltaTime, length -// mismatch) were never exercised. These tests read LaneCount at runtime, use -// LaneCount * 3 + 1 particles (a non-empty vector body AND a non-empty remainder), give every -// particle distinct nonzero x and y, and pin results against a scalar reference computed here -// rather than by calling the code under test. -public sealed class BatchMathTests -{ - private const float Tolerance = 1e-4f; - - [Fact] - public void RadialFalloffMatchesScalarReferenceAcrossVectorBodyAndRemainder() - { - var lanes = BatchMath.LaneCount; - var count = lanes * 3 + 1; - Assert.True(count > lanes, "fixture must exceed one lane to exercise the vector body"); - Assert.True((count % lanes) != 0, "fixture must leave a non-empty scalar remainder"); - - var px = new float[count]; - var py = new float[count]; - var ax = new float[count]; - var ay = new float[count]; - // Distinct, asymmetric per-particle values: x and y follow different formulas so an - // x/y swap mutation is observable, and no particle sits at the falloff center. - for (var i = 0; i < count; i++) - { - px[i] = i * 1.3f - 4.0f; - py[i] = i * -0.7f + 2.5f; - } - - const float centerX = 3.0f; - const float centerY = -1.0f; - const float strength = 5.0f; - // Chosen so some particles fall inside the radius and some fall outside it, exercising - // both the ConditionalSelect(inRange, ...) vector path and the scalar "continue". - const float radius = 6.0f; - - // The scalar remainder is exactly one particle (index count-1). The generator above puts - // it far outside the radius, which would leave any y-axis mutation in the scalar tail's - // "in range" arithmetic unobserved (the only remainder particle never reaches it). Pin it - // inside the radius with a nonzero, non-degenerate y offset instead. - px[count - 1] = centerX + 2.0f; - py[count - 1] = centerY + 1.5f; - - BatchMath.AddRadialFalloffAcceleration2D(px, py, centerX, centerY, strength, radius, ax, ay); - - var insideCount = 0; - var outsideCount = 0; - for (var i = 0; i < count; i++) - { - var dx = centerX - px[i]; - var dy = centerY - py[i]; - var distanceSquared = Math.Max(dx * dx + dy * dy, 1.0e-8f); - var distance = MathF.Sqrt(distanceSquared); - - if (distance > radius) - { - outsideCount++; - Assert.Equal(0.0f, ax[i], Tolerance); - Assert.Equal(0.0f, ay[i], Tolerance); - continue; - } - - insideCount++; - var falloff = Math.Max(0.0f, 1.0f - distance / radius); - var magnitude = strength * falloff; - var expectedAx = dx / distance * magnitude; - var expectedAy = dy / distance * magnitude; - Assert.Equal(expectedAx, ax[i], Tolerance); - Assert.Equal(expectedAy, ay[i], Tolerance); - } - - Assert.True(insideCount > 0, "fixture must include particles inside the radius"); - Assert.True(outsideCount > 0, "fixture must include particles outside the radius"); - } - - [Fact] - public void RadialFalloffAccumulatesOntoExistingAcceleration() - { - // Guards against a mutation that assigns instead of accumulating: seed a nonzero - // acceleration and confirm the falloff contribution is added to it, not overwritten. - var px = new[] { 0.0f }; - var py = new[] { 0.0f }; - var ax = new[] { 10.0f }; - var ay = new[] { -20.0f }; - - BatchMath.AddRadialFalloffAcceleration2D(px, py, 1.0f, 0.0f, 4.0f, 8.0f, ax, ay); - - var dx = 1.0f - 0.0f; - var dy = 0.0f - 0.0f; - var distance = MathF.Sqrt(dx * dx + dy * dy); - var falloff = Math.Max(0.0f, 1.0f - distance / 8.0f); - var magnitude = 4.0f * falloff; - Assert.Equal(10.0f + dx / distance * magnitude, ax[0], Tolerance); - Assert.Equal(-20.0f + dy / distance * magnitude, ay[0], Tolerance); - } - - [Fact] - public void RadialFalloffValidatesEqualSpanLengths() - { - var px = new float[3]; - var py = new float[2]; - var ax = new float[3]; - var ay = new float[3]; - - Assert.Throws(() => - BatchMath.AddRadialFalloffAcceleration2D(px, py, 0.0f, 0.0f, 1.0f, 1.0f, ax, ay)); - } - - [Fact] - public void RadialFalloffIsNoOpWhenRadiusIsNonPositive() - { - var px = new[] { 1.0f, 2.0f }; - var py = new[] { 3.0f, -4.0f }; - var ax = new[] { 5.0f, 6.0f }; - var ay = new[] { 7.0f, 8.0f }; - - BatchMath.AddRadialFalloffAcceleration2D(px, py, 0.0f, 0.0f, 9.0f, 0.0f, ax, ay); - - Assert.Equal(new[] { 5.0f, 6.0f }, ax); - Assert.Equal(new[] { 7.0f, 8.0f }, ay); - } - - [Fact] - public void RadialFalloffIsNoOpWhenStrengthIsZero() - { - var px = new[] { 1.0f, 2.0f }; - var py = new[] { 3.0f, -4.0f }; - var ax = new[] { 5.0f, 6.0f }; - var ay = new[] { 7.0f, 8.0f }; - - BatchMath.AddRadialFalloffAcceleration2D(px, py, 0.0f, 0.0f, 0.0f, 10.0f, ax, ay); - - Assert.Equal(new[] { 5.0f, 6.0f }, ax); - Assert.Equal(new[] { 7.0f, 8.0f }, ay); - } - - [Fact] - public void RadialFalloffIsNoOpWhenSpansAreEmpty() - { - var px = Array.Empty(); - var py = Array.Empty(); - var ax = Array.Empty(); - var ay = Array.Empty(); - - // Must not throw for a valid but degenerate zero-length batch. - BatchMath.AddRadialFalloffAcceleration2D(px, py, 0.0f, 0.0f, 1.0f, 1.0f, ax, ay); - - Assert.Empty(ax); - Assert.Empty(ay); - } - - [Fact] - public void EulerIntegrationMatchesScalarReferenceAcrossVectorBodyAndRemainder() - { - var lanes = BatchMath.LaneCount; - var count = lanes * 3 + 1; - Assert.True((count % lanes) != 0, "fixture must leave a non-empty scalar remainder"); - - const float deltaTime = 0.25f; - var dynamicMask = new float[count]; - var px = new float[count]; - var py = new float[count]; - var vx = new float[count]; - var vy = new float[count]; - var ax = new float[count]; - var ay = new float[count]; - - for (var i = 0; i < count; i++) - { - // Every third particle is frozen (mask 0) so the mask branch is exercised across - // both the vector body and the remainder, not only at the array's edges. - dynamicMask[i] = i % 3 == 0 ? 0.0f : 1.0f; - px[i] = i * 0.4f - 1.0f; - py[i] = i * -0.6f + 3.0f; - vx[i] = i * 0.2f + 1.0f; - vy[i] = i * -0.3f - 2.0f; - ax[i] = i * 0.5f - 2.5f; - ay[i] = i * -0.9f + 1.5f; - } - - // The scalar remainder is exactly one particle (index count-1). The mask pattern above - // would leave it frozen for lane counts divisible by 3, which masks every y-axis (and - // x-axis) mutation in the scalar tail's arithmetic to zero regardless of the mutation. - // Force it dynamic so the remainder actually exercises the scalar tail's math. - dynamicMask[count - 1] = 1.0f; - - // Independent copies for the scalar reference; the arrays under test are mutated in place. - var expectedPx = (float[])px.Clone(); - var expectedPy = (float[])py.Clone(); - var expectedVx = (float[])vx.Clone(); - var expectedVy = (float[])vy.Clone(); - - BatchMath.IntegrateSemiImplicitEuler2D(deltaTime, dynamicMask, px, py, vx, vy, ax, ay); - - var anyFrozen = false; - var anyMoving = false; - for (var i = 0; i < count; i++) - { - var mask = dynamicMask[i]; - expectedVx[i] += ax[i] * deltaTime * mask; - expectedVy[i] += ay[i] * deltaTime * mask; - expectedPx[i] += expectedVx[i] * deltaTime * mask; - expectedPy[i] += expectedVy[i] * deltaTime * mask; - - if (mask == 0.0f) anyFrozen = true; else anyMoving = true; - - Assert.Equal(expectedVx[i], vx[i], Tolerance); - Assert.Equal(expectedVy[i], vy[i], Tolerance); - Assert.Equal(expectedPx[i], px[i], Tolerance); - Assert.Equal(expectedPy[i], py[i], Tolerance); - } - - Assert.True(anyFrozen, "fixture must include masked-off (frozen) particles"); - Assert.True(anyMoving, "fixture must include dynamic particles"); - } - - [Fact] - public void EulerIntegrationRejectsNonPositiveDeltaTime() - { - var dynamicMask = new[] { 1.0f }; - var px = new[] { 0.0f }; - var py = new[] { 0.0f }; - var vx = new[] { 0.0f }; - var vy = new[] { 0.0f }; - var ax = new[] { 0.0f }; - var ay = new[] { 0.0f }; - - Assert.Throws(() => - BatchMath.IntegrateSemiImplicitEuler2D(0.0f, dynamicMask, px, py, vx, vy, ax, ay)); - Assert.Throws(() => - BatchMath.IntegrateSemiImplicitEuler2D(-1.0f, dynamicMask, px, py, vx, vy, ax, ay)); - } - - [Fact] - public void EulerIntegrationValidatesEqualSpanLengths() - { - var dynamicMask = new float[3]; - var px = new float[3]; - var py = new float[3]; - var vx = new float[2]; - var vy = new float[3]; - var ax = new float[3]; - var ay = new float[3]; - - Assert.Throws(() => - BatchMath.IntegrateSemiImplicitEuler2D(0.5f, dynamicMask, px, py, vx, vy, ax, ay)); - } - - [Fact] - public void Float2RadialFalloffMatchesScalarReferenceWithNonzeroYAndOutOfRangeParticles() - { - var count = 5; - var positions = new float2[count]; - for (var i = 0; i < count; i++) - { - positions[i] = new float2(i * 1.1f - 2.0f, i * -0.8f + 1.0f); - } - - var center = new float2(1.5f, -0.5f); - const float strength = 3.0f; - const float radius = 3.0f; - var acceleration = new float2[count]; - - BatchMath.AddRadialFalloffAcceleration2D(positions, center, strength, radius, acceleration); - - var insideCount = 0; - var outsideCount = 0; - for (var i = 0; i < count; i++) - { - var delta = center - positions[i]; - var distanceSquared = Math.Max(delta.x * delta.x + delta.y * delta.y, 1.0e-8f); - var distance = MathF.Sqrt(distanceSquared); - - if (distance > radius) - { - outsideCount++; - Assert.Equal(0.0f, acceleration[i].x, Tolerance); - Assert.Equal(0.0f, acceleration[i].y, Tolerance); - continue; - } - - insideCount++; - var falloff = Math.Max(0.0f, 1.0f - distance / radius); - var expected = delta / distance * (strength * falloff); - Assert.Equal(expected.x, acceleration[i].x, Tolerance); - Assert.Equal(expected.y, acceleration[i].y, Tolerance); - } - - Assert.True(insideCount > 0, "fixture must include particles inside the radius"); - Assert.True(outsideCount > 0, "fixture must include particles outside the radius"); - } - - [Fact] - public void Float2RadialFalloffAccumulatesOntoExistingAcceleration() - { - // Guards against a mutation that assigns instead of accumulating (BatchMath.cs:115): - // seed a nonzero, per-element-distinct acceleration and confirm the falloff - // contribution is added to it, not overwritten. An out-of-range particle must be left - // exactly at its seed value, not reset to zero. - var count = 5; - var positions = new float2[count]; - var seedAcceleration = new float2[count]; - for (var i = 0; i < count; i++) - { - positions[i] = new float2(i * 1.1f - 2.0f, i * -0.8f + 1.0f); - seedAcceleration[i] = new float2(i * 2.3f + 4.0f, i * -1.7f - 6.0f); - } - - var center = new float2(1.5f, -0.5f); - const float strength = 3.0f; - const float radius = 3.0f; - var acceleration = (float2[])seedAcceleration.Clone(); - - BatchMath.AddRadialFalloffAcceleration2D(positions, center, strength, radius, acceleration); - - var insideCount = 0; - var outsideCount = 0; - for (var i = 0; i < count; i++) - { - var delta = center - positions[i]; - var distanceSquared = Math.Max(delta.x * delta.x + delta.y * delta.y, 1.0e-8f); - var distance = MathF.Sqrt(distanceSquared); - - if (distance > radius) - { - outsideCount++; - Assert.Equal(seedAcceleration[i].x, acceleration[i].x, Tolerance); - Assert.Equal(seedAcceleration[i].y, acceleration[i].y, Tolerance); - continue; - } - - insideCount++; - var falloff = Math.Max(0.0f, 1.0f - distance / radius); - var contribution = delta / distance * (strength * falloff); - Assert.Equal(seedAcceleration[i].x + contribution.x, acceleration[i].x, Tolerance); - Assert.Equal(seedAcceleration[i].y + contribution.y, acceleration[i].y, Tolerance); - } - - Assert.True(insideCount > 0, "fixture must include particles inside the radius"); - Assert.True(outsideCount > 0, "fixture must include particles outside the radius"); - } - - [Fact] - public void Float2EulerIntegrationMatchesScalarReferenceWithNonzeroYAndMask() - { - const float deltaTime = 0.2f; - var dynamicMask = new[] { 1.0f, 0.0f, 1.0f }; - var position = new[] { new float2(0.0f, 0.0f), new float2(1.0f, 1.0f), new float2(-2.0f, 3.0f) }; - var velocity = new[] { new float2(1.0f, -1.0f), new float2(2.0f, 2.0f), new float2(-1.0f, 0.5f) }; - var acceleration = new[] { new float2(0.5f, 1.5f), new float2(3.0f, -3.0f), new float2(2.0f, -0.5f) }; - - var expectedPosition = (float2[])position.Clone(); - var expectedVelocity = (float2[])velocity.Clone(); - - BatchMath.IntegrateSemiImplicitEuler2D(deltaTime, dynamicMask, position, velocity, acceleration); - - for (var i = 0; i < position.Length; i++) - { - var mask = dynamicMask[i]; - expectedVelocity[i] += acceleration[i] * deltaTime * mask; - expectedPosition[i] += expectedVelocity[i] * deltaTime * mask; - - Assert.Equal(expectedVelocity[i].x, velocity[i].x, Tolerance); - Assert.Equal(expectedVelocity[i].y, velocity[i].y, Tolerance); - Assert.Equal(expectedPosition[i].x, position[i].x, Tolerance); - Assert.Equal(expectedPosition[i].y, position[i].y, Tolerance); - } - } - - [Fact] - public void Float2EulerIntegrationRejectsNonPositiveDeltaTime() - { - var dynamicMask = new[] { 1.0f }; - var position = new[] { float2.zero }; - var velocity = new[] { float2.zero }; - var acceleration = new[] { float2.zero }; - - Assert.Throws(() => - BatchMath.IntegrateSemiImplicitEuler2D(0.0f, dynamicMask, position, velocity, acceleration)); - } - - [Fact] - public void Float2EulerIntegrationValidatesEqualSpanLengths() - { - var dynamicMask = new float[3]; - var position = new float2[3]; - var velocity = new float2[2]; - var acceleration = new float2[3]; - - Assert.Throws(() => - BatchMath.IntegrateSemiImplicitEuler2D(0.5f, dynamicMask, position, velocity, acceleration)); - } - - [Fact] - public void Float2RadialFalloffValidatesEqualSpanLengths() - { - var positions = new float2[3]; - var acceleration = new float2[2]; - - Assert.Throws(() => - BatchMath.AddRadialFalloffAcceleration2D(positions, float2.zero, 1.0f, 1.0f, acceleration)); - } - - [Fact] - public void Float2RadialFalloffIsNoOpWhenRadiusIsNonPositiveOrStrengthIsZero() - { - var positions = new[] { new float2(1.0f, 3.0f), new float2(2.0f, -4.0f) }; - var acceleration = new[] { new float2(5.0f, 7.0f), new float2(6.0f, 8.0f) }; - - BatchMath.AddRadialFalloffAcceleration2D(positions, float2.zero, 9.0f, 0.0f, acceleration); - Assert.Equal(new float2(5.0f, 7.0f), acceleration[0]); - Assert.Equal(new float2(6.0f, 8.0f), acceleration[1]); - - BatchMath.AddRadialFalloffAcceleration2D(positions, float2.zero, 0.0f, 10.0f, acceleration); - Assert.Equal(new float2(5.0f, 7.0f), acceleration[0]); - Assert.Equal(new float2(6.0f, 8.0f), acceleration[1]); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs b/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs deleted file mode 100644 index 63bc913e..00000000 --- a/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs +++ /dev/null @@ -1,1556 +0,0 @@ -using System.Collections.Generic; -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -// Fixtures are deliberately non-degenerate: A is non-square and non-identity, and b is outside A's range, -// so the unconstrained optimum has a real residual and the box actually bites. -public sealed class BoundedLeastSquaresTests -{ - private static double Cost(int m, int n, float[] a, float[] b, float[] x) - { - var c = 0.0; - for (var r = 0; r < m; r++) - { - var s = -(double)b[r]; - for (var j = 0; j < n; j++) s += (double)a[r * n + j] * x[j]; - c += s * s; - } - return c; - } - - // Gradient of 0.5*||Ax-b||^2, in double. - private static double[] Gradient(int m, int n, float[] a, float[] b, float[] x) - { - var g = new double[n]; - for (var r = 0; r < m; r++) - { - var s = -(double)b[r]; - for (var j = 0; j < n; j++) s += (double)a[r * n + j] * x[j]; - for (var j = 0; j < n; j++) g[j] += a[r * n + j] * s; - } - return g; - } - - private static double AtbScale(int m, int n, float[] a, float[] b) - { - var mx = 0.0; - for (var j = 0; j < n; j++) - { - var s = 0.0; - for (var r = 0; r < m; r++) s += (double)a[r * n + j] * b[r]; - mx = Math.Max(mx, Math.Abs(s)); - } - return 1 + mx; - } - - // Asserts feasibility and the KKT sign rule: free columns have ~zero gradient, columns at lo have - // gradient >= 0, columns at hi have gradient <= 0. - private static void AssertKkt(int m, int n, float[] a, float[] b, float[] lo, float[] hi, float[] x) - { - var g = Gradient(m, n, a, b, x); - var tol = 1e-3 * AtbScale(m, n, a, b); - for (var j = 0; j < n; j++) - { - Assert.True(x[j] >= lo[j] && x[j] <= hi[j], $"column {j} outside its box: {x[j]}"); - if (lo[j] == hi[j]) continue; - if (x[j] == lo[j]) Assert.True(g[j] >= -tol, $"column {j} at lo with gradient {g[j]}"); - else if (x[j] == hi[j]) Assert.True(g[j] <= tol, $"column {j} at hi with gradient {g[j]}"); - else Assert.True(Math.Abs(g[j]) <= tol, $"column {j} free with gradient {g[j]}"); - } - } - - // Accelerated projected gradient (FISTA) with step 1/L, L bounded by the Frobenius norm squared of A. - // Independent of the solver's active-set logic; run to a fixed point. - private static double ReferenceCost(int m, int n, float[] a, float[] b, float[] lo, float[] hi) - { - var frob = 0.0; - foreach (var v in a) frob += (double)v * v; - var step = 1.0 / Math.Max(frob, 1e-12); - var x = new double[n]; - var y = new double[n]; - var xf = new float[n]; - for (var j = 0; j < n; j++) x[j] = y[j] = Math.Clamp(0.0, lo[j], hi[j]); - var t = 1.0; - for (var it = 0; it < 100000; it++) - { - for (var j = 0; j < n; j++) xf[j] = (float)y[j]; - var g = Gradient(m, n, a, b, xf); - var moved = 0.0; - var tNext = (1.0 + Math.Sqrt(1.0 + 4.0 * t * t)) / 2.0; - for (var j = 0; j < n; j++) - { - var next = Math.Clamp(y[j] - step * g[j], lo[j], hi[j]); - moved = Math.Max(moved, Math.Abs(next - x[j])); - y[j] = next + (t - 1.0) / tNext * (next - x[j]); - x[j] = next; - } - t = tNext; - if (moved < 1e-10) break; - } - for (var j = 0; j < n; j++) xf[j] = (float)x[j]; - return Cost(m, n, a, b, xf); - } - - private static BoundedLeastSquaresStatus Solve(int m, int n, float[] a, float[] b, float[] lo, float[] hi, float[] x, - out int iterations, int maxIterations = BoundedLeastSquares.DefaultMaxIterations) - => BoundedLeastSquares.Solve(m, n, a, b, lo, hi, x, new float[BoundedLeastSquares.WorkspaceLength(n)], out iterations, maxIterations); - - private static float[] Fill(float value, int n) - { - var v = new float[n]; - Array.Fill(v, value); - return v; - } - - private static double[] NormalEquationSolution(int m, int n, float[] a, float[] b) - { - var mat = new double[n, n + 1]; - for (var i = 0; i < n; i++) - { - for (var j = 0; j < n; j++) - for (var r = 0; r < m; r++) mat[i, j] += (double)a[r * n + i] * a[r * n + j]; - for (var r = 0; r < m; r++) mat[i, n] += (double)a[r * n + i] * b[r]; - } - for (var c = 0; c < n; c++) - { - var piv = mat[c, c]; - for (var j = 0; j <= n; j++) mat[c, j] /= piv; - for (var i = 0; i < n; i++) - { - if (i == c) continue; - var f = mat[i, c]; - for (var j = 0; j <= n; j++) mat[i, j] -= f * mat[c, j]; - } - } - var x = new double[n]; - for (var i = 0; i < n; i++) x[i] = mat[i, n]; - return x; - } - - private static (int m, int n, float[] a, float[] b, float[] lo, float[] hi) RandomProblem(uint seed) - { - var rng = new CultMath.Random(seed * 7919u); - var n = rng.NextInt(2, 17); - var m = rng.NextInt(n, 25); - var a = new float[m * n]; - var b = new float[m]; - for (var i = 0; i < a.Length; i++) a[i] = rng.NextFloat(-1f, 1f); - for (var i = 0; i < m; i++) b[i] = rng.NextFloat(-3f, 3f); - var lo = new float[n]; - var hi = new float[n]; - for (var j = 0; j < n; j++) - { - switch (rng.NextInt(3)) - { - case 0: lo[j] = -1f; hi[j] = 1f; break; - case 1: lo[j] = 0f; hi[j] = 1f; break; - default: lo[j] = -0.25f; hi[j] = 0.1f; break; - } - } - return (m, n, a, b, lo, hi); - } - - private static readonly float[] A54 = - { - 1.0f, 0.3f, -0.2f, - 0.2f, 1.1f, 0.4f, - -0.5f, 0.6f, 0.9f, - 0.7f, -0.4f, 0.5f, - 0.1f, 0.8f, -0.6f, - }; - - private static readonly float[] B5 = { 0.9f, -0.4f, 1.3f, 0.2f, -0.7f }; - - [Fact] - public void InteriorOptimumEqualsNormalEquations() - { - const int m = 5, n = 3; - var x = new float[n]; - var status = Solve(m, n, A54, B5, Fill(-100f, n), Fill(100f, n), x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - - var expected = NormalEquationSolution(m, n, A54, B5); - for (var i = 0; i < n; i++) Assert.Equal(expected[i], x[i], 1e-4); - } - - [Fact] - public void KktHoldsOnRandomBoxedProblems() - { - var anyActive = false; - for (uint seed = 1; seed <= 150; seed++) - { - var (m, n, a, b, lo, hi) = RandomProblem(seed); - var x = new float[n]; - var status = Solve(m, n, a, b, lo, hi, x, out _); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"seed {seed} ({m}x{n}) hit the cap"); - AssertKkt(m, n, a, b, lo, hi, x); - for (var j = 0; j < n; j++) anyActive |= x[j] == lo[j] || x[j] == hi[j]; - - var cs = Cost(m, n, a, b, x); - var cr = ReferenceCost(m, n, a, b, lo, hi); - Assert.True(Math.Abs(cs - cr) <= 1e-4 * cr + 1e-6, $"seed {seed} ({m}x{n}): solver cost {cs}, reference {cr}"); - } - Assert.True(anyActive); - } - - [Fact] - public void AllBoundsActive() - { - const int m = 4, n = 3; - var a = new[] { 1.0f, 0.2f, 0.1f, 0.1f, 1.0f, 0.3f, -0.2f, 0.2f, 1.0f, 0.5f, 0.5f, 0.4f }; - var b = new[] { 10f, -10f, 10f, 1f }; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - var x = new float[n]; - var status = Solve(m, n, a, b, lo, hi, x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(new[] { 1f, -1f, 1f }, x); - Assert.Equal(3, iterations); - AssertKkt(m, n, a, b, lo, hi, x); - } - - [Fact] - public void ZeroColumn() - { - const int m = 5, n = 3; - var a = (float[])A54.Clone(); - for (var r = 0; r < m; r++) a[r * n + 1] = 0f; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - var x = new float[n]; - var status = Solve(m, n, a, B5, lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - AssertKkt(m, n, a, B5, lo, hi, x); - var cs = Cost(m, n, a, B5, x); - var cr = ReferenceCost(m, n, a, B5, lo, hi); - Assert.True(Math.Abs(cs - cr) <= 1e-4 * cr + 1e-6); - } - - [Fact] - public void DuplicateColumns() - { - const int m = 5, n = 3; - var a = (float[])A54.Clone(); - for (var r = 0; r < m; r++) a[r * n + 2] = a[r * n + 0]; - var lo = Fill(-1f, n); - var hi = new[] { 0.3f, 1f, 0.3f }; - var x = new float[n]; - var status = Solve(m, n, a, B5, lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - AssertKkt(m, n, a, B5, lo, hi, x); - var cs = Cost(m, n, a, B5, x); - var cr = ReferenceCost(m, n, a, B5, lo, hi); - Assert.True(Math.Abs(cs - cr) <= 1e-4 * cr + 1e-6); - } - - [Fact] - public void WarmStartMatchesColdStart() - { - const int m = 5, n = 3; - var lo = new[] { -0.2f, -1f, 0f }; - var hi = new[] { 0.5f, 0.3f, 1f }; - var cold = new float[n]; - Solve(m, n, A54, B5, lo, hi, cold, out _); - AssertKkt(m, n, A54, B5, lo, hi, cold); - - var starts = new[] { new[] { 0.5f, -1f, 1f }, new[] { 9f, 9f, -9f }, new[] { 0.1f, 0.1f, 0.5f }, (float[])cold.Clone() }; - foreach (var start in starts) - { - var status = Solve(m, n, A54, B5, lo, hi, start, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - for (var j = 0; j < n; j++) Assert.Equal(cold[j], start[j], 1e-4); - if (ReferenceEquals(start, starts[^1])) Assert.Equal(0, iterations); - } - } - - [Fact] - public void AsymmetricBounds() - { - const int m = 5, n = 3; - var lo = new[] { -1f, 0f, -1f }; - var hi = new[] { 1f, 1f, 1f }; - // Column 1 wants to go negative (b has a strong component against it) but its floor is 0. - var b = new[] { 0.2f, -2.5f, 0.4f, -1.5f, -2.0f }; - var x = new float[n]; - var status = Solve(m, n, A54, b, lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - AssertKkt(m, n, A54, b, lo, hi, x); - Assert.Equal(0f, x[1]); - Assert.True(x[0] < 0f || x[2] < 0f, "a symmetric-bounds column should use its negative side"); - var cs = Cost(m, n, A54, b, x); - var cr = ReferenceCost(m, n, A54, b, lo, hi); - Assert.True(Math.Abs(cs - cr) <= 1e-4 * cr + 1e-6); - } - - [Fact] - public void IterationCapReturnsFeasibleIterateAndLimitStatus() - { - const int m = 4, n = 3; - var a = new[] { 1.0f, 0.2f, 0.1f, 0.1f, 1.0f, 0.3f, -0.2f, 0.2f, 1.0f, 0.5f, 0.5f, 0.4f }; - var b = new[] { 10f, -10f, 10f, 1f }; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - var x = new float[n]; - var start = Cost(m, n, a, b, x); - var status = Solve(m, n, a, b, lo, hi, x, out var iterations, maxIterations: 1); - Assert.Equal(BoundedLeastSquaresStatus.IterationLimit, status); - Assert.Equal(1, iterations); - for (var j = 0; j < n; j++) Assert.InRange(x[j], lo[j], hi[j]); - Assert.True(Cost(m, n, a, b, x) < start); - - var zero = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.IterationLimit, Solve(m, n, a, b, lo, hi, zero, out iterations, maxIterations: 0)); - Assert.Equal(0, iterations); - Assert.Equal(new float[n], zero); - } - - [Fact] - public void StartOutsideTheBoxIsClampedFirst() - { - const int m = 5, n = 3; - var lo = Fill(-0.1f, n); - var hi = Fill(0.1f, n); - var x = new[] { 50f, -50f, float.NaN }; - Solve(m, n, A54, B5, lo, hi, x, out _, maxIterations: 0); - Assert.Equal(new[] { 0.1f, -0.1f, -0.1f }, x); - } - - [Fact] - public void FixedColumnStaysPutEvenWhenItsGradientWantsOut() - { - const int m = 5, n = 3; - var lo = new[] { -100f, -1f, -100f }; - var hi = new[] { 100f, -1f, 100f }; - var x = new float[n]; - var status = Solve(m, n, A54, B5, lo, hi, x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(-1f, x[1]); - Assert.True(Gradient(m, n, A54, B5, x)[1] < -1e-3, "fixture must pull the fixed column inward"); - Assert.Equal(0, iterations); - AssertKkt(m, n, A54, B5, lo, hi, x); - } - - [Fact] - public void WarmCallAllocatesNothing() - { - const int m = 5, n = 3; - var lo = new[] { -0.2f, -1f, 0f }; - var hi = new[] { 0.5f, 0.3f, 1f }; - var x = new float[n]; - var workspace = new float[BoundedLeastSquares.WorkspaceLength(n)]; - BoundedLeastSquares.Solve(m, n, A54, B5, lo, hi, x, workspace, out _); - - var before = GC.GetAllocatedBytesForCurrentThread(); - var status = BoundedLeastSquares.Solve(m, n, A54, B5, lo, hi, x, workspace, out _); - var after = GC.GetAllocatedBytesForCurrentThread(); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0L, after - before); - } - - [Fact] - public void LargeInteriorOptimumEqualsNormalEquations() - { - const int m = 24, n = 16; - var rng = new CultMath.Random(4242u); - var a = new float[m * n]; - var b = new float[m]; - for (var i = 0; i < a.Length; i++) a[i] = rng.NextFloat(-1f, 1f); - for (var i = 0; i < m; i++) b[i] = rng.NextFloat(-3f, 3f); - var x = new float[n]; - var status = Solve(m, n, a, b, Fill(-1000f, n), Fill(1000f, n), x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0, iterations); - var expected = NormalEquationSolution(m, n, a, b); - for (var i = 0; i < n; i++) Assert.Equal(expected[i], x[i], 1e-3); - } - - [Fact] - public void ScaledAndNearDuplicateColumnsAreOptimal() - { - const int m = 5, n = 3; - foreach (var noise in new[] { 0f, 1e-5f }) - { - var a = (float[])A54.Clone(); - for (var r = 0; r < m; r++) a[r * n + 2] = 0.37f * a[r * n + 0] + noise * (r - 2); - var lo = Fill(-1f, n); - var hi = new[] { 0.6f, 1f, 0.6f }; - var x = new float[n]; - var status = Solve(m, n, a, B5, lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - AssertKkt(m, n, a, B5, lo, hi, x); - var cs = Cost(m, n, a, B5, x); - var cr = ReferenceCost(m, n, a, B5, lo, hi); - Assert.True(Math.Abs(cs - cr) <= 1e-4 * cr + 1e-6, $"noise {noise}: solver cost {cs}, reference {cr}"); - } - } - - [Fact] - public void WorkspaceContentsOnEntryAreIgnored() - { - const int m = 5, n = 3; - var zeroCol = (float[])A54.Clone(); - for (var r = 0; r < m; r++) zeroCol[r * n + 1] = 0f; - var dupCol = (float[])A54.Clone(); - for (var r = 0; r < m; r++) dupCol[r * n + 2] = dupCol[r * n + 0]; - foreach (var a in new[] { A54, zeroCol, dupCol }) - { - var lo = new[] { -1f, -1f, -1f }; - var hi = new[] { 0.3f, 1f, 0.3f }; - var clean = new float[n]; - Solve(m, n, a, B5, lo, hi, clean, out var cleanIterations); - foreach (var junk in new[] { float.NaN, 7f, -1e30f }) - { - var workspace = new float[BoundedLeastSquares.WorkspaceLength(n)]; - Array.Fill(workspace, junk); - var x = new float[n]; - BoundedLeastSquares.Solve(m, n, a, B5, lo, hi, x, workspace, out var iterations); - Assert.Equal(clean, x); - Assert.Equal(cleanIterations, iterations); - } - } - } - - // Junk in the workspace, including NaN doubles, must not reach any decision: random boxed problems (which release - // bounds and use the tolerance) give bit-identical x and the same iteration count. - [Fact] - public void WorkspaceJunkNeverReachesTheSolveOnRandomProblems() - { - for (uint seed = 1; seed <= 25; seed++) - { - var (m, n, a, b, lo, hi) = RandomProblem(seed); - var clean = new float[n]; - Solve(m, n, a, b, lo, hi, clean, out var cleanIterations); - foreach (var junk in new[] { float.NaN, 7f, -1e30f }) - { - var workspace = new float[BoundedLeastSquares.WorkspaceLength(n)]; - Array.Fill(workspace, junk); - var x = new float[n]; - BoundedLeastSquares.Solve(m, n, a, b, lo, hi, x, workspace, out var iterations); - Assert.Equal(cleanIterations, iterations); - for (var j = 0; j < n; j++) - Assert.Equal(BitConverter.SingleToInt32Bits(clean[j]), BitConverter.SingleToInt32Bits(x[j])); - } - } - } - - [Fact] - public void WarmStartAtAVertexTakesNoIterations() - { - const int m = 4, n = 3; - var a = new[] { 1.0f, 0.2f, 0.1f, 0.1f, 1.0f, 0.3f, -0.2f, 0.2f, 1.0f, 0.5f, 0.5f, 0.4f }; - var b = new[] { 10f, -10f, 10f, 1f }; - var x = new[] { 1f, -1f, 1f }; - var status = Solve(m, n, a, b, Fill(-1f, n), Fill(1f, n), x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0, iterations); - Assert.Equal(new[] { 1f, -1f, 1f }, x); - } - - [Fact] - public void IterationCountFollowsTheCapExactly() - { - var sawRelease = false; - for (uint seed = 1; seed <= 40; seed++) - { - var (m, n, a, b, lo, hi) = RandomProblem(seed); - var full = new float[n]; - Solve(m, n, a, b, lo, hi, full, out var needed); - var previousCost = double.MaxValue; - for (var cap = 0; cap <= needed; cap++) - { - var x = new float[n]; - var status = Solve(m, n, a, b, lo, hi, x, out var iterations, cap); - Assert.Equal(cap, iterations); - Assert.Equal(cap < needed ? BoundedLeastSquaresStatus.IterationLimit : BoundedLeastSquaresStatus.Converged, status); - for (var j = 0; j < n; j++) Assert.InRange(x[j], lo[j], hi[j]); - var cost = Cost(m, n, a, b, x); - Assert.True(cost <= previousCost * (1 + 1e-6) + 1e-9, $"seed {seed} cap {cap}: cost rose from {previousCost} to {cost}"); - previousCost = cost; - } - sawRelease |= needed > n; - } - Assert.True(sawRelease, "no random problem needed more iterations than columns, so no bound was ever released"); - } - - [Fact] - public void EachShortSpanIsRejected() - { - const int m = 5, n = 3; - var ws = new float[BoundedLeastSquares.WorkspaceLength(n)]; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - void Expect(Action call) => Assert.Contains("BoundedLeastSquares", Assert.Throws(call).Message); - Expect(() => BoundedLeastSquares.Solve(m, n, new float[m * n - 1], B5, lo, hi, new float[n], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, n, A54, new float[m - 1], lo, hi, new float[n], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, n, A54, B5, new float[n - 1], hi, new float[n], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, n, A54, B5, lo, new float[n - 1], new float[n], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, n, A54, B5, lo, hi, new float[n - 1], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, n, A54, B5, lo, hi, new float[n], new float[ws.Length - 1], out _)); - Expect(() => BoundedLeastSquares.Solve(-1, n, A54, B5, lo, hi, new float[n], ws, out _)); - Expect(() => BoundedLeastSquares.Solve(m, -1, A54, B5, lo, hi, new float[n], ws, out _)); - // Exactly sized spans, and empty problems, are accepted. - BoundedLeastSquares.Solve(m, n, A54, B5, lo, hi, new float[n], ws, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, BoundedLeastSquares.Solve(0, 0, default, default, default, default, default, default, out _)); - Assert.Equal(BoundedLeastSquaresStatus.Converged, BoundedLeastSquares.Solve(0, n, default, default, lo, hi, new float[n], ws, out _)); - } - - // Well-conditioned enough (m = n + 6) that x is comparable across scales. - private static (int m, int n, float[] a, float[] b, float[] lo, float[] hi) ScaleProblem(uint seed) - { - var rng = new CultMath.Random(seed * 104729u); - var n = rng.NextInt(3, 11); - var m = n + 6; - var a = new float[m * n]; - var b = new float[m]; - for (var i = 0; i < a.Length; i++) a[i] = rng.NextFloat(-1f, 1f); - for (var i = 0; i < m; i++) b[i] = rng.NextFloat(-3f, 3f); - var lo = new float[n]; - var hi = new float[n]; - for (var j = 0; j < n; j++) - { - lo[j] = rng.NextFloat(-0.6f, -0.05f); - hi[j] = rng.NextFloat(0.05f, 0.6f); - } - return (m, n, a, b, lo, hi); - } - - private static float[] Scaled(float[] v, float k) - { - var r = new float[v.Length]; - for (var i = 0; i < v.Length; i++) r[i] = v[i] * k; - return r; - } - - [Fact] - public void SolutionIsScaleFree() - { - var sawActive = false; - for (uint seed = 1; seed <= 40; seed++) - { - var (m, n, a, b, lo, hi) = ScaleProblem(seed); - var x = (float[])lo.Clone(); - Assert.Equal(BoundedLeastSquaresStatus.Converged, Solve(m, n, a, b, lo, hi, x, out _)); - AssertKkt(m, n, a, b, lo, hi, x); - for (var j = 0; j < n; j++) sawActive |= x[j] == lo[j] || x[j] == hi[j]; - - foreach (var k in new[] { 1e-6f, 1e3f, 1e6f }) - { - // b and the bounds scaled: x scales with them. - var xb = Scaled(lo, k); - var status = Solve(m, n, a, Scaled(b, k), Scaled(lo, k), Scaled(hi, k), xb, out _); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"seed {seed} k {k}: {status}"); - for (var j = 0; j < n; j++) - Assert.True(Math.Abs(xb[j] - x[j] * k) <= 1e-3 * Math.Abs(k) * (1 + Math.Abs(x[j])), $"seed {seed} b*{k} col {j}: {xb[j]} vs {x[j] * k}"); - - // A scaled: x scales inversely, so the bounds stay put and only b is scaled with A to keep the same box. - var xa = (float[])lo.Clone(); - var lo2 = Scaled(lo, 1f / k); - var hi2 = Scaled(hi, 1f / k); - for (var j = 0; j < n; j++) xa[j] = lo2[j]; - status = Solve(m, n, Scaled(a, k), b, lo2, hi2, xa, out _); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"seed {seed} A*{k}: {status}"); - for (var j = 0; j < n; j++) - Assert.True(Math.Abs(xa[j] - x[j] / k) <= 1e-3 * Math.Abs(1 / k) * (1 + Math.Abs(x[j])), $"seed {seed} A*{k} col {j}: {xa[j]} vs {x[j] / k}"); - } - } - Assert.True(sawActive); - } - - [Fact] - public void NonFiniteOrInvertedInputIsRejectedAndLeavesXUntouched() - { - const int m = 5, n = 3; - var nan = float.NaN; - var inf = float.PositiveInfinity; - var cases = new (string name, Action corrupt)[] - { - ("A NaN", (a, b, lo, hi) => a[4] = nan), - ("A +Inf", (a, b, lo, hi) => a[7] = inf), - ("A -Inf", (a, b, lo, hi) => a[1] = -inf), - ("b NaN", (a, b, lo, hi) => b[2] = nan), - ("b +Inf", (a, b, lo, hi) => b[0] = inf), - ("lo NaN", (a, b, lo, hi) => lo[1] = nan), - ("hi NaN", (a, b, lo, hi) => hi[2] = nan), - ("lo > hi", (a, b, lo, hi) => { lo[1] = 0.5f; hi[1] = 0.25f; }), - ("lo = +Inf", (a, b, lo, hi) => { lo[0] = inf; hi[0] = inf; }), - ("hi = -Inf", (a, b, lo, hi) => { lo[0] = -inf; hi[0] = -inf; }), - }; - foreach (var (name, corrupt) in cases) - { - var a = (float[])A54.Clone(); - var b = (float[])B5.Clone(); - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - corrupt(a, b, lo, hi); - foreach (var start in new[] { new[] { 0.5f, -3f, 9f }, new[] { nan, 0f, 0f } }) - { - var x = (float[])start.Clone(); - var status = Solve(m, n, a, b, lo, hi, x, out var iterations); - Assert.True(status == BoundedLeastSquaresStatus.InvalidInput, $"{name}: {status}"); - Assert.Equal(0, iterations); - for (var j = 0; j < n; j++) - Assert.Equal(BitConverter.SingleToInt32Bits(start[j]), BitConverter.SingleToInt32Bits(x[j])); - } - } - } - - [Fact] - public void InfiniteBoundsMeanUnbounded() - { - const int m = 5, n = 3; - var inf = float.PositiveInfinity; - var x = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.Converged, Solve(m, n, A54, B5, Fill(-inf, n), Fill(inf, n), x, out _)); - var expected = NormalEquationSolution(m, n, A54, B5); - for (var j = 0; j < n; j++) Assert.Equal(expected[j], x[j], 1e-4); - - // One-sided, with an infinite warm start: the start is clamped to a finite point first. - var y = new[] { -inf, inf, float.NaN }; - var lo = new[] { -inf, 0.2f, -inf }; - var hi = new[] { inf, inf, 0.1f }; - Assert.Equal(BoundedLeastSquaresStatus.Converged, Solve(m, n, A54, B5, lo, hi, y, out _)); - AssertKkt(m, n, A54, B5, lo, hi, y); - Assert.All(y, v => Assert.True(float.IsFinite(v))); - } - - // Exact reference: every assignment of each column to {lo, hi, free}, free set solved in double. - private static double ExactBoxedCost(int m, int n, float[] a, float[] b, float[] lo, float[] hi, double pivotTol = 1e-9, double ridge = 0.0) - { - var maxDiag = 0.0; - for (var j = 0; j < n; j++) - { - var d = 0.0; - for (var r = 0; r < m; r++) d += (double)a[r * n + j] * a[r * n + j]; - maxDiag = Math.Max(maxDiag, d); - } - var best = double.MaxValue; - var total = 1; - for (var j = 0; j < n; j++) total *= 3; - var x = new double[n]; - for (var code = 0; code < total; code++) - { - var c = code; - var free = new System.Collections.Generic.List(); - for (var j = 0; j < n; j++) - { - var d = c % 3; c /= 3; - if (d == 0) x[j] = lo[j]; else if (d == 1) x[j] = hi[j]; else free.Add(j); - } - var k = free.Count; - if (k > 0) - { - var mat = new double[k, k + 1]; - for (var i = 0; i < k; i++) - { - for (var l = 0; l < k; l++) - for (var r = 0; r < m; r++) mat[i, l] += (double)a[r * n + free[i]] * a[r * n + free[l]]; - for (var r = 0; r < m; r++) - { - var fixedPart = 0.0; - for (var j = 0; j < n; j++) if (!free.Contains(j)) fixedPart += (double)a[r * n + j] * x[j]; - mat[i, k] += (double)a[r * n + free[i]] * (b[r] - fixedPart); - } - } - for (var i = 0; i < k; i++) mat[i, i] += ridge * maxDiag; - var ok = true; - for (var col = 0; col < k && ok; col++) - { - var piv = col; - for (var r = col + 1; r < k; r++) if (Math.Abs(mat[r, col]) > Math.Abs(mat[piv, col])) piv = r; - if (Math.Abs(mat[piv, col]) < pivotTol) { ok = false; break; } - for (var l = 0; l <= k; l++) (mat[col, l], mat[piv, l]) = (mat[piv, l], mat[col, l]); - for (var r = 0; r < k; r++) - { - if (r == col) continue; - var f = mat[r, col] / mat[col, col]; - for (var l = col; l <= k; l++) mat[r, l] -= f * mat[col, l]; - } - } - if (!ok) continue; - for (var i = 0; i < k; i++) - { - x[free[i]] = mat[i, k] / mat[i, i]; - if (x[free[i]] < lo[free[i]] - 1e-12 || x[free[i]] > hi[free[i]] + 1e-12) ok = false; - } - if (!ok) continue; - } - var cost = 0.0; - for (var r = 0; r < m; r++) - { - var s = -(double)b[r]; - for (var j = 0; j < n; j++) s += (double)a[r * n + j] * x[j]; - cost += s * s; - } - best = Math.Min(best, cost); - } - return best; - } - - // m < n with columns that are nearly parallel (condition number of A around 1e2), b outside the reachable set. - // The absolute scale of A must not matter: the KKT tolerance is relative, and the working iterate is double, so a - // 1e6 A with untouched bounds reaches the same optimum to the same allowance. - [Theory] - [InlineData(1f)] - [InlineData(1e6f)] - public void NearCollinearColumnsReachTheExactOptimum(float scale) - { - const int m = 2, n = 7; - for (var family = 0; family < 4; family++) - { - for (uint seed = 1; seed <= 120; seed++) - { - var rng = new CultMath.Random(seed * 15485863u + (uint)family * 977u); - var a = new float[m * n]; - for (var j = 0; j < n; j++) - { - switch (family) - { - case 0: a[j] = rng.NextFloat(0.5f, 1f); a[n + j] = 0.01f * rng.NextFloat(-1f, 1f); break; - case 1: a[j] = 1f + 0.02f * rng.NextFloat(-1f, 1f); a[n + j] = 0.01f * rng.NextFloat(-1f, 1f); break; - case 2: a[j] = rng.NextFloat(-1f, 1f); a[n + j] = 0.01f * a[j] + 0.01f * rng.NextFloat(-1f, 1f); break; - default: a[j] = rng.NextFloat(0.5f, 1f); a[n + j] = a[j] * 0.9f + 0.01f * rng.NextFloat(-1f, 1f); break; - } - } - for (var i = 0; i < a.Length; i++) a[i] *= scale; - var b = new[] { rng.NextFloat(-8f, 8f), rng.NextFloat(-8f, 8f) }; - var lo = new float[n]; - var hi = new float[n]; - for (var j = 0; j < n; j++) { lo[j] = rng.NextFloat() < 0.5f ? -1f : 0f; hi[j] = 1f; } - var x = new float[n]; - var status = Solve(m, n, a, b, lo, hi, x, out _); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"family {family} seed {seed}: {status}"); - var gap = Cost(m, n, a, b, x) - ExactBoxedCost(m, n, a, b, lo, hi); - var allowed = 1e-5 * (b[0] * b[0] + b[1] * b[1]); - Assert.True(gap <= allowed, $"family {family} seed {seed}: cost {gap} above the exact optimum (allowed {allowed})"); - } - } - } - - // A = U diag(s) V^T with s geometric from 1 down to 1/cond, so cond(A) is the requested value (float rounding of A - // perturbs it slightly). m x n with m >= n; b is generic, so it has a real residual when m > n. - private static (float[] a, float[] b) ConditionedProblem(int m, int n, double cond, uint seed, double aScale = 1.0, bool bAlongSmallestSingularVector = false) - { - var rng = new CultMath.Random(seed * 2654435761u + 17u); - double[][] Orthonormal(int dim, int count) - { - var q = new double[count][]; - for (var k = 0; k < count; k++) - { - var v = new double[dim]; - for (var i = 0; i < dim; i++) v[i] = rng.NextFloat(-1f, 1f); - for (var pass = 0; pass < 2; pass++) - for (var l = 0; l < k; l++) - { - var dot = 0.0; - for (var i = 0; i < dim; i++) dot += v[i] * q[l][i]; - for (var i = 0; i < dim; i++) v[i] -= dot * q[l][i]; - } - var norm = 0.0; - for (var i = 0; i < dim; i++) norm += v[i] * v[i]; - norm = Math.Sqrt(norm); - for (var i = 0; i < dim; i++) v[i] /= norm; - q[k] = v; - } - return q; - } - var u = Orthonormal(m, n); - var w = Orthonormal(n, n); - var a = new float[m * n]; - for (var k = 0; k < n; k++) - { - var s = aScale * Math.Pow(cond, -(double)k / Math.Max(1, n - 1)); - for (var r = 0; r < m; r++) - for (var c = 0; c < n; c++) - a[r * n + c] += (float)(u[k][r] * s * w[k][c]); - } - var b = new float[m]; - for (var i = 0; i < m; i++) b[i] = bAlongSmallestSingularVector ? (float)u[n - 1][i] : rng.NextFloat(-3f, 3f); - return (a, b); - } - - // A pass can end with the KKT test still failing and the cost exactly where it was: a dependent free column keeps a - // gradient above the tolerance, or a bound release lands on a column the factor drops. The solver must call that - // converged; if the stall rule mis-reads the cost scale or the progress, it spins to the iteration cap instead. - // Each kind is a fixed-seed batch of small boxed problems with warm starts on and off the bounds and pinned columns: - // rank-deficient (duplicate and zero columns), nearly collinear (1e-2 to 1e-5), integer-tied, wide, cond(A) 1e5 to - // 3e5, and "weak", where b lies along the weakest singular direction of a cond(A) 1e6 to 1e7 matrix so the gradient - // tolerance sits below the rounding noise with interior columns nonzero. Every kind must converge; all but "weak" - // (past the documented condition range) must also land within the documented cost gap, relative to |b|^2, of an - // exact enumeration of the active sets (a 1e-15 ridge keeps singular free sets solvable). - [Theory] - [InlineData("plain", 300)] - [InlineData("rankdef", 300)] - [InlineData("collinear", 300)] - [InlineData("integer-tie", 300)] - [InlineData("wide", 300)] - [InlineData("cond", 300)] - [InlineData("weak", 6000)] - public void StalledPassesConvergeInsteadOfSpinningToTheCap(string kind, int seeds) - { - var failures = new System.Collections.Generic.List(); - for (uint seed = 1; seed <= seeds; seed++) - { - var rng = new CultMath.Random(seed * 2246822519u + (uint)kind.Length * 3266489917u); - double Gauss() => Math.Sqrt(-2.0 * Math.Log(1.0 - rng.NextFloat() * 0.999999)) * Math.Cos(2.0 * Math.PI * rng.NextFloat()); - var n = rng.NextInt(2, 8); - var m = rng.NextInt(2, 12); - if (kind == "wide") m = Math.Max(1, n - rng.NextInt(1, 4)); - if (kind == "cond" || kind == "weak") m = n + rng.NextInt(0, 5); - float[] a; - float[] bWeak = null; - if (kind == "weak") - { - (a, bWeak) = ConditionedProblem(m, n, Math.Pow(10.0, 6.0 + rng.NextFloat()), seed, 1.0, true); - } - else if (kind == "cond") - { - a = ConditionedProblem(m, n, Math.Pow(10.0, 5.0 + 0.5 * rng.NextFloat()), seed).a; - } - else - { - a = new float[m * n]; - for (var i = 0; i < m; i++) - { - var row = new double[n]; - for (var j = 0; j < n; j++) row[j] = kind == "integer-tie" ? rng.NextInt(-2, 3) : Gauss(); - for (var j = 1; j < n; j++) - { - if (kind == "rankdef" && j % 3 == 1) row[j] = row[j - 1]; - if (kind == "rankdef" && j % 3 == 2) row[j] = 0.0; - if (kind == "collinear" && j % 2 == 1) row[j] = row[j - 1] + Math.Pow(10.0, -rng.NextInt(2, 6)) * Gauss(); - } - for (var j = 0; j < n; j++) a[i * n + j] = (float)row[j]; - } - } - var lo = new float[n]; - var hi = new float[n]; - var x = new float[n]; - var xt = new double[n]; - for (var j = 0; j < n; j++) - { - var w = Math.Pow(10.0, rng.NextInt(-2, 2)); - lo[j] = (float)(-w * rng.NextFloat()); - hi[j] = (float)(w * rng.NextFloat()); - if (rng.NextInt(6) == 0) hi[j] = lo[j]; - else if (rng.NextInt(8) == 0) lo[j] = hi[j] = 0f; - else if (rng.NextInt(8) == 0) { lo[j] = (float)(0.5 + rng.NextFloat()); hi[j] = lo[j] + 0.5f; } - if (kind == "weak") { var c = (float)Math.Pow(10.0, rng.NextInt(3, 9)); lo[j] = rng.NextInt(2) == 0 ? -c : 0f; hi[j] = c; } - if (kind == "integer-tie") { lo[j] = -1f; hi[j] = rng.NextInt(4) == 0 ? -1f : 1f; } - x[j] = rng.NextInt(3) == 0 ? lo[j] : rng.NextInt(2) == 0 ? hi[j] : lo[j] + (hi[j] - lo[j]) * rng.NextFloat(); - xt[j] = (lo[j] + hi[j]) / 2.0 + (hi[j] - lo[j]) * 3.0 * (rng.NextFloat() - 0.5); - } - var noise = Math.Pow(10.0, rng.NextInt(-2, 4)); - var mode = rng.NextInt(4); - var b = new float[m]; - for (var i = 0; i < m; i++) - { - var s = 0.0; - for (var j = 0; j < n; j++) s += (double)a[i * n + j] * xt[j]; - b[i] = bWeak != null ? bWeak[i] : mode == 0 ? 0f : (float)(s + noise * Gauss() * (mode == 3 ? 1.0 : 0.01)); - } - var status = Solve(m, n, a, b, lo, hi, x, out var iterations); - if (status != BoundedLeastSquaresStatus.Converged) - { - failures.Add($"seed {seed}: {status} after {iterations}"); - continue; - } - if (kind == "weak") continue; - var bb = 0.0; - foreach (var v in b) bb += (double)v * v; - if (bb == 0.0) bb = 1.0; - var gap = Cost(m, n, a, b, x) - ExactBoxedCost(m, n, a, b, lo, hi, 1e-300, 1e-15); - if (gap > 1e-5 * bb) failures.Add($"seed {seed}: cost gap {gap / bb:E2} of |b|^2"); - } - Assert.True(failures.Count == 0, $"{kind}: {failures.Count} of {seeds} failed; first: {string.Join("; ", failures.GetRange(0, Math.Min(3, failures.Count)))}"); - } - - // Unsaturated allocator-shaped ticks: 24 columns, every column free at the optimum. The solve is one Newton step; - // at most one more may confirm it. Before the working iterate moved to double, the float gradient's noise floor - // exceeded the tolerance from cond ~1e3 and the solver spun to the 100-iteration cap on optimal points. - [Theory] - [InlineData(1e2)] - [InlineData(1e3)] - [InlineData(1e4)] - public void UnsaturatedIllConditionedProblemsConvergeInAtMostTwoIterations(double cond) - { - const int m = 28, n = 24; - for (uint seed = 1; seed <= 30; seed++) - { - var (a, b) = ConditionedProblem(m, n, cond, seed); - var x = new float[n]; - var status = Solve(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), x, out var iterations); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"cond {cond} seed {seed}: {status} after {iterations}"); - Assert.True(iterations <= 2, $"cond {cond} seed {seed}: {iterations} iterations"); - var bb = 0.0; - foreach (var v in b) bb += (double)v * v; - var expected = NormalEquationSolution(m, n, a, b); - var xs = new float[n]; - for (var j = 0; j < n; j++) xs[j] = (float)expected[j]; - Assert.True(Cost(m, n, a, b, x) - Cost(m, n, a, b, xs) <= 1e-6 * bb, $"cond {cond} seed {seed}: cost above the exact optimum"); - } - } - - // Near the pivot cutoff (cond(A) ~ 3e7, cond(A^T A) ~ 1e15) a Newton step leaves a free gradient above the - // tolerance on some problems. Those take one confirming iteration and stop because it lowers nothing; the rest - // are stationary at once. Never the cap, and never spinning. - [Fact] - public void NearSingularFreeSetsConfirmOnceAndStop() - { - const int m = 28, n = 24; - var confirmed = 0; - for (uint seed = 1; seed <= 60; seed++) - { - var (a, b) = ConditionedProblem(m, n, 3e7, seed); - var x = new float[n]; - var status = Solve(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), x, out var iterations); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"seed {seed}: {status}"); - Assert.True(iterations <= 3, $"seed {seed}: {iterations} iterations"); - if (iterations > 0) confirmed++; - } - Assert.InRange(confirmed, 1, 20); - } - - // b along the smallest left singular vector makes the optimum lie along the weakest direction: |A^T b| is tiny, so - // the tolerance (1e-6 of it) sits below the rounding noise of the gradient (~1e-16 |A^T A| |x|) for cond(A) >= 1e6. - // The tolerance is then unreachable, and the solver must stop on the progress rule, after the handful of Newton - // passes that still lower the cost, never at the 100-iteration cap. - [Theory] - [InlineData(1e6)] - [InlineData(1e7)] - public void ToleranceBelowTheNoiseFloorStopsOnProgressNotOnTheCap(double cond) - { - const int m = 28, n = 24; - var confirmed = 0; - for (uint seed = 1; seed <= 30; seed++) - { - var (a, b) = ConditionedProblem(m, n, cond, seed, 1.0, bAlongSmallestSingularVector: true); - var x = new float[n]; - var status = Solve(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), x, out var iterations); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"cond {cond} seed {seed}: {status} after {iterations}"); - Assert.True(iterations <= 6, $"cond {cond} seed {seed}: {iterations} iterations"); - if (iterations >= 1) confirmed++; - } - Assert.True(confirmed >= 15, $"cond {cond}: only {confirmed} of 30 reached the tolerance floor"); - } - - // Scale-freeness was only claimed for scaling A, b and the bounds together; A alone at 1e6 with the bounds left - // alone must also converge, and as fast. - [Theory] - [InlineData(1e2)] - [InlineData(1e4)] - public void LargeAWithUnscaledBoundsConvergesInAtMostTwoIterations(double cond) - { - const int m = 28, n = 24; - for (uint seed = 1; seed <= 30; seed++) - { - var (a, b) = ConditionedProblem(m, n, cond, seed, 1e6); - var x = new float[n]; - var status = Solve(m, n, a, b, Fill(-1e3f, n), Fill(1e3f, n), x, out var iterations); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"cond {cond} seed {seed}: {status} after {iterations}"); - Assert.True(iterations <= 2, $"cond {cond} seed {seed}: {iterations} iterations"); - } - } - - // b = 0 must not borrow its tolerance from the start point: a far start's own gradient is enormous, so that - // scale judged it converged after one iteration at cost 5001. The optimum here is ~1e-9. - [Fact] - public void ZeroTargetFromAFarStartIsNotJudgedConvergedByItsOwnSteepness() - { - var a = new[] { 1f, 1f, 1f, 1.0001f }; - var b = new float[2]; - var lo = new[] { 0.5f, -1e6f }; - var hi = new[] { 1e6f, 1e6f }; - var x = new[] { 1e6f, 1e6f }; - var status = Solve(2, 2, a, b, lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - AssertKkt(2, 2, a, b, lo, hi, x); - Assert.True(Cost(2, 2, a, b, x) < 1e-6, $"cost {Cost(2, 2, a, b, x)}"); - Assert.True(x[0] >= 0.5f); - - // The origin inside the box: the answer is the origin, from any start. - var lo2 = new[] { -1e6f, -1e6f }; - var y = new[] { 1e6f, -1e6f }; - Assert.Equal(BoundedLeastSquaresStatus.Converged, Solve(2, 2, a, b, lo2, hi, y, out _)); - Assert.True(Cost(2, 2, a, b, y) < 1e-9, $"cost {Cost(2, 2, a, b, y)}"); - } - - // The tolerance scale is the gradient at the box point nearest the origin. Here that point is 1000 and the - // wanted release is a gradient of about 6e-5 against a 1000-scale problem: only a scale taken from the box point - // (about 6e-5, tolerance 6e-11) releases it; a scale taken from A^T b (about 1000, tolerance 1e-3) would not. - // Run with the excluded column in each position so the scale must come from the right entry. - [Fact] - public void ToleranceScaleIsTheGradientAtTheBoxPointNearestTheOrigin() - { - var a = new[] { 1f, 0f, 0f, 1f }; - foreach (var excluded in new[] { 0, 1 }) - { - var b = new float[2]; - var lo = new[] { -1e6f, -1e6f }; - var hi = new[] { 1e6f, 1e6f }; - b[excluded] = 1000.0001f; - lo[excluded] = 1000f; - hi[excluded] = 2000f; - var x = new float[2]; - x[excluded] = 1000f; - var status = Solve(2, 2, a, b, lo, hi, x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.True(iterations >= 1, $"column {excluded}: no release"); - Assert.Equal(b[excluded], x[excluded]); - Assert.Equal(0f, x[1 - excluded]); - } - } - - // b = 0 with the origin in the box and the start at the origin: the gradient is exactly zero and so is the - // tolerance. Nothing is violated, so the solve is over without an iteration. - [Fact] - public void ZeroTargetAtTheOriginTakesNoIterations() - { - const int m = 5, n = 3; - var x = new float[n]; - var status = Solve(m, n, A54, new float[m], Fill(-1f, n), Fill(1f, n), x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0, iterations); - Assert.Equal(new float[n], x); - } - - // One column, A = [1], with b beyond the box: the first Newton step would cross a bound, so with a cap of 0 the - // solver returns the clamped start untouched. That makes the clamp itself the thing under test, for every - // combination of a finite, infinite or NaN start with finite and infinite bounds. - [Fact] - public void WarmStartClampIsExact() - { - var inf = float.PositiveInfinity; - var cases = new (float lo, float hi, float start, float expected)[] - { - (-1f, 1f, 0.25f, 0.25f), - (-1f, 1f, 5f, 1f), - (-1f, 1f, -5f, -1f), - (-1f, 1f, float.NaN, -1f), - (0.5f, 2f, inf, 2f), - (0.5f, 2f, -inf, 0.5f), - (0.2f, inf, inf, 0.2f), - (0.2f, inf, -inf, 0.2f), - (0.2f, inf, float.NaN, 0.2f), - (-inf, -2f, -inf, -2f), - (-inf, -2f, 3f, -2f), - (-inf, 3f, float.NaN, 0f), - (-inf, 3f, -inf, 0f), - (-2f, inf, float.NaN, -2f), - (-inf, -2f, float.NaN, -2f), - (-inf, 3f, 1f, 1f), - }; - foreach (var (l, h, start, expected) in cases) - { - // b beyond the box on the side the start is not on the bound of, so the step crosses a bound (or the - // start already sits on one). - var b = new[] { float.IsInfinity(h) ? l - 10f : h + 10f }; - if (float.IsInfinity(l) && float.IsInfinity(h)) b[0] = 0f; - var x = new[] { start }; - Solve(1, 1, new[] { 1f }, b, new[] { l }, new[] { h }, x, out var iterations, maxIterations: 0); - Assert.Equal(0, iterations); - Assert.True(x[0] == expected, $"box [{l}, {h}] start {start}: {x[0]}, expected {expected}"); - } - } - - // A duplicate column that is free and interior gets no step: the columns share one gradient, and moving both - // along it would overshoot. - [Fact] - public void FreeDuplicateColumnGetsNoStep() - { - const int m = 5, n = 3; - var a = (float[])A54.Clone(); - for (var r = 0; r < m; r++) a[r * n + 2] = a[r * n + 0]; - var x = new float[n]; - var status = Solve(m, n, a, B5, Fill(-100f, n), Fill(100f, n), x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0, iterations); - Assert.Equal(0f, x[2]); - var reduced = new float[m * 2]; - for (var r = 0; r < m; r++) { reduced[r * 2] = a[r * n]; reduced[r * 2 + 1] = a[r * n + 1]; } - var xr = NormalEquationSolution(m, 2, reduced, B5); - Assert.Equal(xr[0], x[0], 1e-4); - Assert.Equal(xr[1], x[1], 1e-4); - } - - // Columns 1000x apart in scale and exactly parallel: the pivot tolerance is relative to the column's own - // diagonal, so it catches the duplicate at any absolute scale. - [Theory] - [InlineData(1e3f)] - [InlineData(1e-3f)] - public void ParallelColumnsAreDependentAtAnyAbsoluteScale(float scale) - { - const int m = 5, n = 3; - var a = (float[])A54.Clone(); - for (var r = 0; r < m; r++) a[r * n + 2] = 0.37f * a[r * n + 0]; - for (var i = 0; i < a.Length; i++) a[i] *= scale; - var lo = Fill(-1000f / scale, n); - var hi = Fill(1000f / scale, n); - var x = new float[n]; - var status = Solve(m, n, a, B5, lo, hi, x, out var iterations); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.True(iterations <= 2, $"{iterations} iterations"); - var reduced = new float[m * 2]; - for (var r = 0; r < m; r++) { reduced[r * 2] = a[r * n]; reduced[r * 2 + 1] = a[r * n + 1]; } - var xr = NormalEquationSolution(m, 2, reduced, B5); - var xs = new float[n]; - xs[0] = (float)xr[0]; - xs[1] = (float)xr[1]; - var bb = 0.0; - foreach (var v in B5) bb += (double)v * v; - Assert.True(Cost(m, n, a, B5, x) - Cost(m, n, a, B5, xs) <= 1e-6 * bb, "cost above the reduced optimum"); - } - - // No path allocates: not the first InvalidInput, not a cap hit, not a solve that releases bounds. Each path is - // measured on its first call and again after, so a one-time runtime cost shows up as a difference between the two - // rather than as a solver allocation. - [Fact] - public void EveryPathAllocatesNothing() - { - const int m = 4, n = 3; - var a = new[] { 1.0f, 0.2f, 0.1f, 0.1f, 1.0f, 0.3f, -0.2f, 0.2f, 1.0f, 0.5f, 0.5f, 0.4f }; - var b = new[] { 10f, -10f, 10f, 1f }; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - var workspace = new float[BoundedLeastSquares.WorkspaceLength(n)]; - var x = new float[n]; - var bad = (float[])a.Clone(); - bad[4] = float.NaN; - - var paths = new (string name, float[] a, int cap, BoundedLeastSquaresStatus expected)[] - { - ("invalid", bad, 100, BoundedLeastSquaresStatus.InvalidInput), - ("converged", a, 100, BoundedLeastSquaresStatus.Converged), - ("limit", a, 1, BoundedLeastSquaresStatus.IterationLimit), - }; - foreach (var (name, matrix, cap, expected) in paths) - { - var bytes = new long[2]; - for (var call = 0; call < 2; call++) - { - Array.Clear(x); - var before = GC.GetAllocatedBytesForCurrentThread(); - var status = BoundedLeastSquares.Solve(m, n, matrix, b, lo, hi, x, workspace, out _, cap); - bytes[call] = GC.GetAllocatedBytesForCurrentThread() - before; - Assert.Equal(expected, status); - } - Assert.True(bytes[0] == 0 && bytes[1] == 0, $"{name}: first call {bytes[0]} B, second {bytes[1]} B"); - } - } - - // The allocator problem of the Aetheria thrust allocator: four throttles u in [0,1] and four slack pairs - // e+x e-x e+y e-y in [0,2]. Rows: x and y translation, yaw, four slack pulls, four throttle regularisers. Duel columns. - private static readonly float[] DuelX = { 0f, 0f, 29.08f, -21.80f }; - private static readonly float[] DuelY = { 53.94f, 61.19f, 0f, 0f }; - private static readonly float[] DuelYaw = { 49.24f, -55.86f, 166.26f, -124.63f }; - - private static (int m, int n, float[] a, float[] b, float[] lo, float[] hi) DuelProblem(float ix, float iy, float iz) - { - const int m = 11, n = 8; - const float h = 100f, wy = 1000f, w = 0.3f, kappa = 10f, rho = 0.1f; - var a = new float[m * n]; - var b = new float[m]; - var rows = new[] { DuelX, DuelY, DuelYaw }; - var intent = new[] { ix, iy, iz }; - for (var r = 0; r < 3; r++) - { - var pos = 0f; - var neg = 0f; - foreach (var v in rows[r]) { if (v > 0f) pos += v; else neg -= v; } - var s = Math.Max(pos, neg); - var d = intent[r] * (intent[r] >= 0f ? pos : neg); - var weight = r == 2 ? wy : h; - for (var k = 0; k < 4; k++) a[r * n + k] = weight * rows[r][k] / s; - if (r < 2) - { - a[r * n + 4 + 2 * r] = -weight; - a[r * n + 5 + 2 * r] = weight; - } - b[r] = weight * d / s; - } - for (var k = 0; k < 4; k++) - { - a[(3 + k) * n + 4 + k] = w; - b[3 + k] = -w * kappa; - a[(7 + k) * n + k] = rho; - } - var lo = new float[n]; - var hi = new float[n]; - for (var j = 0; j < n; j++) hi[j] = j < 4 ? 1f : 2f; - return (m, n, a, b, lo, hi); - } - - private static string Bits(BoundedLeastSquaresStatus status, int iterations, float[] x) - { - var sb = new System.Text.StringBuilder().Append(status).Append(' ').Append(iterations); - foreach (var v in x) sb.Append(' ').Append(BitConverter.SingleToInt32Bits(v).ToString("x8")); - return sb.ToString(); - } - - // The before/after pin of the cut that added a tolerance argument: literals recorded by running the pre-cut solver. - [Fact] - public void DefaultSolvesAreBitIdenticalToTheirGoldenBits() - { - List Run(bool passTheDefault) - { - var cases = new List(); - BoundedLeastSquaresStatus Go(int m, int n, float[] a, float[] b, float[] lo, float[] hi, float[] x, out int it) - => passTheDefault - ? SolveAt(m, n, a, b, lo, hi, x, out it, BoundedLeastSquares.DefaultKktRelativeTolerance) - : Solve(m, n, a, b, lo, hi, x, out it); - { - const int m = 5, n = 3; - var x = new float[n]; - var status = Go(m, n, A54, B5, Fill(-1f, n), Fill(1f, n), x, out var it); - cases.Add(Bits(status, it, x)); - } - foreach (var seed in new uint[] { 3, 11, 29 }) - { - var (m, n, a, b, lo, hi) = RandomProblem(seed); - var x = new float[n]; - var status = Go(m, n, a, b, lo, hi, x, out var it); - cases.Add(Bits(status, it, x)); - } - { - var (m, n, a, b, lo, hi) = DuelProblem(0f, 0.5f, 0.25f); - var x = new float[n]; - var status = Go(m, n, a, b, lo, hi, x, out var it); - cases.Add(Bits(status, it, x)); - } - return cases; - } - var golden = new[] - { - "Converged 0 3e8cfe03 bdd096e8 3f65616f", - "Converged 7 3f800000 00000000 be800000 bdb5b48d 00000000 3f800000 bf3f85df 3dca36f5 3dd187b0 3dcccccd 3f469416 3ea87652 3f4e1a2a", - "Converged 2 be800000 be2481b8 bf1f1f78 3eb37f7c 3ec24a46 bdbe3cf6 3dcccccd", - "Converged 3 00000000 3d0d206f 3dcccccd 3f800000 3ef2bfd6 3ebe0bf2 bf600698 bf800000 3f528e24 bddf446c 3c173499 00000000", - "Converged 5 3f800000 00000000 3ce45d43 00000000 3ce39ffe 00000000 00000000 3d0098ef", - }; - Assert.Equal(string.Join("\n", golden), string.Join("\n", Run(false))); - Assert.Equal(string.Join("\n", golden), string.Join("\n", Run(true))); - } - - private static BoundedLeastSquaresStatus SolveAt(int m, int n, float[] a, float[] b, float[] lo, float[] hi, float[] x, - out int iterations, double kktRelativeTolerance, int maxIterations = BoundedLeastSquares.DefaultMaxIterations) - => BoundedLeastSquares.Solve(m, n, a, b, lo, hi, x, new float[BoundedLeastSquares.WorkspaceLength(n)], out iterations, - kktRelativeTolerance, maxIterations); - - private static float[] Start(int n, float throttles) - { - var x = new float[n]; - for (var k = 0; k < 4; k++) x[k] = throttles; - return x; - } - - [Fact] - public void TheDefaultToleranceConstantIsOneEMinusSix() - { - Assert.Equal(1e-6, BoundedLeastSquares.DefaultKktRelativeTolerance); - for (uint seed = 1; seed <= 50; seed++) - { - var (m, n, a, b, lo, hi) = RandomProblem(seed); - var omitted = new float[n]; - var passed = new float[n]; - var s1 = Solve(m, n, a, b, lo, hi, omitted, out var i1); - var s2 = SolveAt(m, n, a, b, lo, hi, passed, out var i2, BoundedLeastSquares.DefaultKktRelativeTolerance); - Assert.Equal(Bits(s1, i1, omitted), Bits(s2, i2, passed)); - } - } - - // Row 0 is heavy (gradient scale 1e4); row 1 carries a light term whose gradient w^2 = 9e-6 sits under 1e-6 of - // that scale, so the default calls x0 stationary at 0 although cost falls by 90 when x0 rises to 1. - private static readonly float[] HeavyA = { 10f, 100f, 0.003f, 0f }; - private static readonly float[] HeavyB = { 100f, 0.003f }; - - [Fact] - public void ALightTermUnderAHeavyRowIsResolvedOnlyByATightEnoughTolerance() - { - const int m = 2, n = 2; - var lo = new float[n]; - var hi = Fill(1f, n); - foreach (var tol in new[] { BoundedLeastSquares.DefaultKktRelativeTolerance, 1e-9 }) - { - var x = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, HeavyA, HeavyB, lo, hi, x, out _, tol)); - Assert.Equal(0f, x[0]); - } - var tight = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, HeavyA, HeavyB, lo, hi, tight, out _, 1e-12)); - Assert.Equal(1f, tight[0], 1e-5); - Assert.Equal(0.9f, tight[1], 1e-5); - } - - [Fact] - public void ATightToleranceDoesNotDependOnTheStart() - { - const int m = 2, n = 2; - var lo = new float[n]; - var hi = Fill(1f, n); - foreach (var (s0, s1) in new[] { (0f, 0f), (1f, 0f), (0.5f, 0.5f), (1f, 1f) }) - { - var x = new[] { s0, s1 }; - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, HeavyA, HeavyB, lo, hi, x, out _, 1e-12)); - Assert.Equal(1f, x[0], 1e-5); - Assert.Equal(0.9f, x[1], 1e-5); - } - var cold = new float[n]; - var warm = new[] { 1f, 0f }; - Solve(m, n, HeavyA, HeavyB, lo, hi, cold, out _); - Solve(m, n, HeavyA, HeavyB, lo, hi, warm, out _); - Assert.Equal(0f, cold[0]); - Assert.Equal(1f, warm[0]); - } - - [Theory] - [InlineData(0f, 0.5f, 0.25f)] - [InlineData(-1f, 0f, 0.25f)] - public void AnAllocatorShapedProblemIsStartIndependentAtATightTolerance(float ix, float iy, float iz) - { - var (m, n, a, b, lo, hi) = DuelProblem(ix, iy, iz); - var cold = Start(n, 0f); - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, a, b, lo, hi, cold, out var coldIterations, 1e-12)); - Assert.True(coldIterations <= 20, $"cold {coldIterations} iterations"); - foreach (var throttles in new[] { 1f, 0.5f }) - { - var x = Start(n, throttles); - var status = SolveAt(m, n, a, b, lo, hi, x, out var iterations, 1e-12); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.True(iterations <= 20, $"start {throttles}: {iterations} iterations"); - for (var k = 0; k < 4; k++) Assert.Equal(cold[k], x[k], 1e-4); - } - - var defaultCold = Start(n, 0f); - var defaultOnes = Start(n, 1f); - Solve(m, n, a, b, lo, hi, defaultCold, out _); - Solve(m, n, a, b, lo, hi, defaultOnes, out _); - var spread = 0.0; - for (var k = 0; k < 4; k++) spread = Math.Max(spread, Math.Abs(defaultOnes[k] - defaultCold[k])); - Assert.True(spread >= 0.5, $"default tolerance: starts differ by only {spread}"); - } - - // Soul's W5 (finding aetheria-release:finding:cut-thrust-allocator-core.s1.solver-converged-early): an allocator - // matrix (3 force rows, 4 slack pulls, 8 ridge rows; 8 throttles in [0,1], 4 slacks in [0,2]). From x = 0 the - // last release lowered the cost by less than the stall band while throttle 7 still sat at its upper bound - // with a gradient ten thousand times the tolerance, and the solver reported Converged there. - [Theory] - [InlineData(1e-12)] - [InlineData(1e-9)] - public void TheStopAfterAReleaseIsOnTheGradientNotTheCost(double tolerance) - { - const int m = 15, n = 12; - var a = new float[m * n]; - a[0 * n + 2] = 100f; a[0 * n + 8] = -100f; a[0 * n + 9] = 100f; - var row1 = new[] { 13.882518f, 20.86695f, 0f, 14.8965845f, 12.38046f, 22.115599f, -13.706654f, 15.85789f, 0f, 0f, -100f, 100f }; - var row2 = new[] { -187.72859f, 239.31168f, 158.87828f, -270.31165f, 235.38467f, -14.704258f, 121.61232f, 244.81305f }; - for (var j = 0; j < n; j++) a[1 * n + j] = row1[j]; - for (var j = 0; j < row2.Length; j++) a[2 * n + j] = row2[j]; - for (var k = 0; k < 4; k++) a[(3 + k) * n + 8 + k] = 0.3f; - for (var i = 0; i < 8; i++) a[(7 + i) * n + i] = 0.1f; - var b = new float[m]; - b[1] = 67.385445f; b[2] = 558.70917f; - for (var k = 0; k < 4; k++) b[3 + k] = -3f; - var lo = new float[n]; - var hi = new float[n]; - for (var j = 0; j < n; j++) hi[j] = j < 8 ? 1f : 2f; - - var cold = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, a, b, lo, hi, cold, out _, tolerance)); - Assert.Equal(0.92221445f, cold[7], 1e-4); - - var again = (float[])cold.Clone(); - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, a, b, lo, hi, again, out var iterations, tolerance)); - Assert.Equal(0, iterations); - for (var j = 0; j < n; j++) Assert.Equal(cold[j], again[j], 1e-6); - } - - // b = 0 with the origin inside the box: the optimum is any x with Ax = 0, the gradient scale is 0 and so is the tolerance, and - // every gradient component the solve leaves behind is rounding. Releasing on such a violation cycles release / - // stationarity miss / re-bind until the iteration cap (the plain-batch problem at seed 141 in miniature). - [Fact] - public void ANoiseLevelViolationIsNeverReleased() - { - const int m = 2, n = 6; - var a = new[] - { - 1.0213068f, 0.97530603f, -0.5673449f, -0.64136946f, -0.07432885f, -0.35571396f, - 0.4326824f, 1.1969734f, -0.1343108f, -0.23431005f, -1.4009786f, 0.10656489f, - }; - var b = new float[m]; - var lo = new[] { -0.44782114f, 0f, -0.008422324f, -0.03878026f, 0f, -6.6434336f }; - var hi = new[] { 0.0448007f, 0f, 0.005942123f, 0.0785512f, 0f, 0.23079813f }; - var x = new[] { -0.28347927f, 0f, 0.0051532285f, -0.03878026f, 0f, 0.23079813f }; - Assert.Equal(BoundedLeastSquaresStatus.Converged, Solve(m, n, a, b, lo, hi, x, out var iterations)); - Assert.True(iterations <= 4, $"{iterations} iterations"); - for (var i = 0; i < m; i++) - { - var r = 0.0; - for (var j = 0; j < n; j++) r += a[i * n + j] * x[j]; - Assert.Equal(0.0, r, 1e-5); - } - } - - [Fact] - public void AnInvalidToleranceIsRejectedAndLeavesXUntouched() - { - const int m = 5, n = 3; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - foreach (var tol in new[] { 0.0, -1e-6, double.NaN, double.PositiveInfinity, double.NegativeInfinity, double.MinValue }) - { - var x = new[] { 0.25f, -0.5f, 2f }; - var before = (float[])x.Clone(); - var status = SolveAt(m, n, A54, B5, lo, hi, x, out var iterations, tol); - Assert.True(status == BoundedLeastSquaresStatus.InvalidInput, $"tolerance {tol}: {status}"); - Assert.Equal(0, iterations); - for (var j = 0; j < n; j++) - Assert.Equal(BitConverter.SingleToInt32Bits(before[j]), BitConverter.SingleToInt32Bits(x[j])); - } - var tiny = new float[n]; - Assert.Equal(BoundedLeastSquaresStatus.Converged, SolveAt(m, n, A54, B5, lo, hi, tiny, out _, double.Epsilon)); - } - - [Theory] - [InlineData(1e6, 1e-12)] - [InlineData(1e6, 1e-30)] - [InlineData(1e7, 1e-12)] - [InlineData(1e7, 1e-30)] - public void ATightToleranceStopsOnProgressNotOnTheCap(double cond, double tol) - { - const int m = 28, n = 24; - var worst = 0; - for (uint seed = 1; seed <= 30; seed++) - { - var (a, b) = ConditionedProblem(m, n, cond, seed, 1.0, bAlongSmallestSingularVector: true); - var x = new float[n]; - var status = SolveAt(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), x, out var iterations, tol); - Assert.True(status == BoundedLeastSquaresStatus.Converged, $"cond {cond} tol {tol} seed {seed}: {status} after {iterations}"); - worst = Math.Max(worst, iterations); - } - Assert.True(worst <= 30, $"cond {cond} tol {tol}: {worst} iterations"); - } - - [Fact] - public void TheTolerancePathAllocatesNothing() - { - const int m = 4, n = 3; - var a = new[] { 1.0f, 0.2f, 0.1f, 0.1f, 1.0f, 0.3f, -0.2f, 0.2f, 1.0f, 0.5f, 0.5f, 0.4f }; - var b = new[] { 10f, -10f, 10f, 1f }; - var lo = Fill(-1f, n); - var hi = Fill(1f, n); - var workspace = new float[BoundedLeastSquares.WorkspaceLength(n)]; - var x = new float[n]; - var paths = new (string name, double tol, BoundedLeastSquaresStatus expected)[] - { - ("tight", 1e-12, BoundedLeastSquaresStatus.Converged), - ("invalid", double.NaN, BoundedLeastSquaresStatus.InvalidInput), - }; - foreach (var (name, tol, expected) in paths) - { - var bytes = new long[2]; - for (var call = 0; call < 2; call++) - { - Array.Clear(x); - var before = GC.GetAllocatedBytesForCurrentThread(); - var status = BoundedLeastSquares.Solve(m, n, a, b, lo, hi, x, workspace, out _, tol); - bytes[call] = GC.GetAllocatedBytesForCurrentThread() - before; - Assert.Equal(expected, status); - } - Assert.True(bytes[0] == 0 && bytes[1] == 0, $"{name}: first call {bytes[0]} B, second {bytes[1]} B"); - } - } - - [Fact] - public void TheOriginalSolveSignatureStillExists() - { - var original = typeof(BoundedLeastSquares).GetMethod(nameof(BoundedLeastSquares.Solve), new[] - { - typeof(int), typeof(int), - typeof(ReadOnlySpan), typeof(ReadOnlySpan), typeof(ReadOnlySpan), typeof(ReadOnlySpan), - typeof(Span), typeof(Span), - typeof(int).MakeByRefType(), typeof(int), - }); - Assert.NotNull(original); - } - - // The heavy-row shape with a free light weight w: at (x0, x1) = (0, 1) the gradient of x0 is w^2 against a - // gradient scale of 1e4, so x0's release flips where the caller's tolerance crosses the relative gradient - // computed here from the inputs alone. - private static float[] ShapeA(float w) => new[] { 10f, 100f, w, 0f }; - private static float[] ShapeB(float w) => new[] { 100f, w }; - - private static double ShapeRelativeGradient(float w) - { - var a = ShapeA(w); - var b = ShapeB(w); - double atb0 = (double)a[0] * b[0] + (double)a[2] * b[1]; - double atb1 = (double)a[1] * b[0] + (double)a[3] * b[1]; - var gScale = Math.Max(Math.Abs(atb0), Math.Abs(atb1)); - double ata01 = (double)a[0] * a[1] + (double)a[2] * a[3]; - return Math.Abs(ata01 - atb0) / gScale; - } - - private static float ShapeX0(float w, double? tolerance) - { - var x = new float[2]; - var lo = new float[2]; - var hi = Fill(1f, 2); - var status = tolerance is { } t - ? SolveAt(2, 2, ShapeA(w), ShapeB(w), lo, hi, x, out _, t) - : Solve(2, 2, ShapeA(w), ShapeB(w), lo, hi, x, out _); - Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - return x[0]; - } - - // Weights put the relative gradient at about 1e-5 (above the default tolerance) and 9e-10, 9e-12, 9e-14 (below it). - [Theory] - [InlineData(0.316f)] - [InlineData(0.03f)] - [InlineData(0.003f)] - [InlineData(0.0003f)] - public void TheReleaseFlipsAtTheCallersToleranceTimesTheGradientScale(float w) - { - var rel = ShapeRelativeGradient(w); - Assert.True(ShapeX0(w, rel * 1.05) == 0f, $"w {w} rel {rel:R}: above the threshold x0 stays at 0"); - var below = ShapeX0(w, rel * 0.95); - Assert.True(Math.Abs(below - 1f) < 1e-4, $"w {w} rel {rel:R}: below the threshold x0 is {below}"); - } - - // A relative gradient 10% either side of 1e-6: the solve that omits the tolerance releases the one above and - // not the one below, and equals the solve that passes the default, so the forwarded default is 1e-6 and no - // other value within 10%. - [Theory] - [InlineData(0.104881f, 1f)] - [InlineData(0.094868f, 0f)] - public void TheOmittedToleranceReleasesAtOneEMinusSixAndNowhereNear(float w, float expectedX0) - { - var rel = ShapeRelativeGradient(w); - Assert.InRange(rel, 0.9e-6 * 0.99, 1.1e-6 * 1.01); - Assert.Equal(expectedX0, ShapeX0(w, null), 1e-4); - Assert.Equal(expectedX0, ShapeX0(w, BoundedLeastSquares.DefaultKktRelativeTolerance), 1e-4); - } - - // The box is wide enough that no bound is ever released, so any difference between the default and a tight - // tolerance is decided by the stationarity test of the free set alone. - [Fact] - public void AllFreeConditionedProblemsHonourTheToleranceAtTheFreeSetTest() - { - const int m = 28, n = 24; - int differ = 0, total = 0; - foreach (var cond in new[] { 1e2, 1e3, 1e4, 1e5, 1e6 }) - foreach (var along in new[] { true, false }) - for (uint seed = 1; seed <= 30; seed++) - { - var (a, b) = ConditionedProblem(m, n, cond, seed, 1.0, bAlongSmallestSingularVector: along); - var byDefault = new float[n]; - var tight = new float[n]; - var s1 = Solve(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), byDefault, out var i1); - var s2 = SolveAt(m, n, a, b, Fill(-1e9f, n), Fill(1e9f, n), tight, out var i2, 1e-12); - total++; - if (Bits(s1, i1, byDefault) != Bits(s2, i2, tight)) differ++; - } - Assert.True(differ >= total / 10, $"only {differ} of {total} all-free solves changed between the default and 1e-12"); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/CellularAndSminGradTests.cs b/packages/cultmath/tests/CultMath.Tests/CellularAndSminGradTests.cs deleted file mode 100644 index 465f6961..00000000 --- a/packages/cultmath/tests/CultMath.Tests/CellularAndSminGradTests.cs +++ /dev/null @@ -1,686 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -public sealed class CellularAndSminGradTests -{ - // Central-difference tolerances for smin_grad and cellular (F5), sized separately: the two - // functions have different curvature, so the same eps does not carry the same truncation - // error, and an earlier shared 3e-4 tolerance was fragile against both (Soul, cut 2a-i: measured - // max error smin 2.74e-4, cellular nearest 1.25e-4, cellular edge 1.88e-4 on a small sample — - // and re-measured here at 5.3e-4, 2.0e-4, 2.6e-4 on a larger one — against that 3e-4 tolerance, - // sometimes under 1.1x headroom, not the "~6e-5 noise" an earlier version of this comment - // claimed). Each tolerance below is set from its own measured worst case with real headroom. - - // smin_grad's value is exactly quadratic in position within a smoothing band (math.cs comment on - // smin_grad: h is affine in b.w - a.w, which is itself affine in position, so value(q) has zero - // third derivative there): central differences have no truncation error from curvature, only - // float32 rounding noise, so a larger eps directly dilutes that noise with no accuracy cost. - // Measured max error at eps=0.01f over 10,000 samples: 4.37e-5 (up from eps=0.001f's 5.3e-4, - // confirming the noise is eps-limited, not curvature-limited); this tolerance keeps about 5.7x - // headroom over that. A uniform-scale mutant on the returned gradient (a 1.01x M9/M16-style - // mutant applied here) still dies down to a 1.0005x scale (0.05%); it survives at 1.0002x. - private const float SminGradientTolerance = 2.5e-4f; - - // cellular's F1/F2 are Euclidean distance fields: real curvature away from a feature point means - // central differences DO carry O(eps^2) truncation error, so (unlike smin_grad) a larger eps - // makes things worse, not better; a sweep at eps in {0.0002f, 0.0003f, 0.0005f, 0.0007f, 0.001f} - // over 8,000 samples found the committed eps=0.0005f already close to the sweet spot. Measured - // max error at that eps: nearest 2.04e-4, edge 2.57e-4; this tolerance keeps just over 5x - // headroom over the larger of the two. M9 (grad1 * 1.01) and M16 (grad2 * 1.01) both still die - // down to a 1.002x scale (0.2%); both survive at 1.001x. - private const float CellularGradientTolerance = 1.3e-3f; - - // ---- smin_grad ---- - - [Fact] - public void SminValueNeverExceedsTheOrdinaryMinimum() - { - var random = new System.Random(0xACE1); - for (var i = 0; i < 256; i++) - { - var a = new float4(RandomUnit(random), RandomScalar(random)); - var b = new float4(RandomUnit(random), RandomScalar(random)); - var k = 0.05f + random.NextSingle() * 5.0f; - - var result = math.smin_grad(a, b, k); - - Assert.True(result.w <= math.min(a.w, b.w) + 1.0e-4f, $"a.w={a.w} b.w={b.w} k={k} smin={result.w}"); - } - } - - [Fact] - public void SminMatchesTheHardMinimumAndItsGradientOutsideTheBand() - { - var random = new System.Random(0xACE2); - for (var i = 0; i < 64; i++) - { - var gradA = RandomUnit(random); - var gradB = RandomUnit(random); - var k = 0.1f + random.NextSingle() * 2.0f; - - // Push b comfortably above a, past the smoothing band, so a is the ordinary minimum. - var aw = random.NextSingle() * 10.0f - 5.0f; - var bw = aw + k * (1.5f + random.NextSingle()); - var a = new float4(gradA, aw); - var b = new float4(gradB, bw); - - var lower = math.smin_grad(a, b, k); - Assert.Equal(aw, lower.w, precision: 4); - Assert.Equal(gradA.x, lower.x, precision: 4); - Assert.Equal(gradA.y, lower.y, precision: 4); - Assert.Equal(gradA.z, lower.z, precision: 4); - - // Argument order must not matter: b below a is symmetric. - var higher = math.smin_grad(b, a, k); - Assert.Equal(aw, higher.w, precision: 4); - Assert.Equal(gradA.x, higher.x, precision: 4); - Assert.Equal(gradA.y, higher.y, precision: 4); - Assert.Equal(gradA.z, higher.z, precision: 4); - } - } - - [Fact] - public void SminGradientMatchesCentralDifferencesOfItsOwnValue() - { - var random = new System.Random(0xACE3); - var tested = 0; - while (tested < 200) - { - var cf = RandomUnit(random); - var cg = RandomUnit(random); - var offF = random.NextSingle() * 4.0f - 2.0f; - var offG = random.NextSingle() * 4.0f - 2.0f; - var k = 0.2f + random.NextSingle() * 2.0f; - var p = new float3(random.NextSingle() * 4.0f - 2.0f, random.NextSingle() * 4.0f - 2.0f, random.NextSingle() * 4.0f - 2.0f); - - float F(float3 q) => math.dot(q, cf) + offF; - float G(float3 q) => math.dot(q, cg) + offG; - float Smin(float3 q) => math.smin_grad(new float4(cf, F(q)), new float4(cg, G(q)), k).w; - - // Stay clear of the |a.w - b.w| = k seam: central differences straddling a kink would - // disagree with either side's analytic gradient (the same reason cellular excludes a - // band around its own F1 = F2 set). The band has an absolute floor, not just a - // fraction of k: eps grew to 0.01f below (SminGradientTolerance's comment), and a - // fraction-of-k-only band could be narrower than the diff can shift by eps*|cf-cg| - // (up to about 0.035 here) when k is small, letting p +/- eps step across the seam even - // though p itself was clear of it. - var diff = F(p) - G(p); - if (Math.Abs(Math.Abs(diff) - k) < Math.Max(0.05f * k, 0.05f)) - continue; - - tested++; - var analytic = math.smin_grad(new float4(cf, F(p)), new float4(cg, G(p)), k); - - // eps=0.01f, not 0.001f: smin is exactly quadratic within a band (no truncation error - // from curvature; see SminGradientTolerance's comment), so the larger eps only dilutes - // float32 rounding noise, at no accuracy cost, while still comfortably inside the band - // exclusion above. - const float eps = 0.01f; - var numeric = new float3( - (Smin(p + new float3(eps, 0.0f, 0.0f)) - Smin(p - new float3(eps, 0.0f, 0.0f))) / (2.0f * eps), - (Smin(p + new float3(0.0f, eps, 0.0f)) - Smin(p - new float3(0.0f, eps, 0.0f))) / (2.0f * eps), - (Smin(p + new float3(0.0f, 0.0f, eps)) - Smin(p - new float3(0.0f, 0.0f, eps))) / (2.0f * eps)); - - AssertWithinTolerance(numeric.x, analytic.x, SminGradientTolerance); - AssertWithinTolerance(numeric.y, analytic.y, SminGradientTolerance); - AssertWithinTolerance(numeric.z, analytic.z, SminGradientTolerance); - } - } - - [Fact] - public void SminGradientIsNotAConstantBlendOrTheSwappedFactor() - { - // Falsifies two named mutants directly: blending the gradient with a constant 0.5 instead of - // h, or with (1 - h) instead of h. Here a is comfortably the minimum (h saturates to 1 in the - // correct formula), so the correct gradient is exactly a's, unmixed. A constant-0.5 blend or a - // swapped (1 - h) blend both pull in b's gradient, which differs from a's here. - var a = new float4(1.0f, 0.0f, 0.0f, -3.0f); - var b = new float4(0.0f, 1.0f, 0.0f, 5.0f); - - var result = math.smin_grad(a, b, 0.25f); - - Assert.Equal(1.0f, result.x, precision: 5); - Assert.Equal(0.0f, result.y, precision: 5); - Assert.Equal(0.0f, result.z, precision: 5); - Assert.Equal(-3.0f, result.w, precision: 5); - } - - // ---- cellular ---- - - [Fact] - public void F1NeverExceedsF2() - { - var random = new System.Random(0xCE11); - for (var i = 0; i < 256; i++) - { - var p = new float3(random.NextSingle() * 20.0f - 10.0f, random.NextSingle() * 20.0f - 10.0f, random.NextSingle() * 20.0f - 10.0f); - var result = math.cellular(p); - Assert.True(result.edge.w >= -1.0e-4f, $"F2 - F1 = {result.edge.w} at {p.x},{p.y},{p.z}"); - - // Both returned .w values, checked against the independent 7x7x7 brute-force oracle (F1, - // F6), not a value the test derived some other way. - var (f1, f2) = FindF1F2(p); - Assert.Equal(f1, result.nearest.w, precision: 3); - Assert.Equal(f2 - f1, result.edge.w, precision: 3); - } - } - - [Fact] - public void NearestFeatureWinsEvenWhenItIsInTheLastVisitedNeighbourCell() - { - // math.cellular's own search order visits neighbour offsets with dz outermost and dx - // innermost over a 5x5x5 block (F6), and it also prunes cells whose position-only lower - // bound already exceeds the running F2. Offsets with any |component| = 2 are not provably - // unreachable as F1: their minimum possible distance is 1 (e.g. (2, 0, 0), whose lower bound - // per the exactness proof in math.cs is max(0, 2-1) = 1), well inside the query's own cell's - // sqrt(3) ceiling, so a |component| = 2 offset winning F1 is rare rather than impossible - // (Soul, cut 2a-i: measured 3 F1 wins in 2,000,000 samples). It is still rare enough that the - // 3x3x3 corners remain the practically-reachable "last" cases for this test. (dx, dy, dz) - // = (1, 1, 1) is the last of those the fixed iteration order visits, and if pruning or search - // order were broken, this is the offset most likely to be skipped. Rather than hand-picking a - // hash value, search random points for one whose true nearest feature (by independent brute - // force over the same 5x5x5 block) happens to live in exactly that cell, at a comfortable - // margin from the F1 = F2 seam, then check math.cellular agrees. - var random = new System.Random(0xCE14); - var lastOffset = new float3(1.0f, 1.0f, 1.0f); - for (var attempt = 0; attempt < 5000; attempt++) - { - var p = new float3(random.NextSingle() * 8.0f - 4.0f, random.NextSingle() * 8.0f - 4.0f, random.NextSingle() * 8.0f - 4.0f); - var (offset, f1, f2) = FindNearestOffset(p); - if (!offset.Equals(lastOffset) || f1 < 0.05f || f2 - f1 < 0.05f) - continue; - - var cell = new float3(MathF.Floor(p.x), MathF.Floor(p.y), MathF.Floor(p.z)); - var feature = FeaturePoint(cell + lastOffset); - var expectedGradient = (p - feature) / f1; - - var result = math.cellular(p); - Assert.Equal(f1, result.nearest.w, precision: 4); - Assert.Equal(expectedGradient.x, result.nearest.x, precision: 4); - Assert.Equal(expectedGradient.y, result.nearest.y, precision: 4); - Assert.Equal(expectedGradient.z, result.nearest.z, precision: 4); - return; - } - - Assert.Fail("did not find a random point whose nearest feature lives in the last-visited neighbour cell"); - } - - [Fact] - public void NearestGradientIsFiniteZeroAtAFeaturePointInsteadOfNaN() - { - var feature = FeaturePoint(new float3(4.0f, -2.0f, 9.0f)); - var result = math.cellular(feature); - - Assert.Equal(0.0f, result.nearest.w, precision: 4); - Assert.True(float.IsFinite(result.nearest.x) && float.IsFinite(result.nearest.y) && float.IsFinite(result.nearest.z)); - Assert.Equal(0.0f, result.nearest.x, precision: 5); - Assert.Equal(0.0f, result.nearest.y, precision: 5); - Assert.Equal(0.0f, result.nearest.z, precision: 5); - } - - [Fact] - public void GradientMatchesCentralDifferencesAwayFromTheF1EqualsF2Seam() - { - var random = new System.Random(0xCE12); - var tested = 0; - var attempts = 0; - while (tested < 120 && attempts < 20000) - { - attempts++; - var p = new float3(random.NextSingle() * 6.0f - 3.0f, random.NextSingle() * 6.0f - 3.0f, random.NextSingle() * 6.0f - 3.0f); - var (f1, f2, f3) = FindF1F2F3(p); - - // Exclude a band around the F1 = F2 set: the identity of the nearest and second-nearest - // feature swap there, a genuine kink in F1 and F2 alike, not something central differences - // can approximate. Also exclude a band around F2 = F3: edge (F2 - F1) kinks there too, - // since the second-nearest feature's identity swaps (Soul, cut 2a-i: an unfiltered sample - // hit a 0.78 edge error this way). Also skip the exact feature point itself (F1 = 0), - // covered separately. - if (f2 - f1 < 0.05f || f1 < 0.01f || f3 - f2 < 0.05f) - continue; - - tested++; - var result = math.cellular(p); - - // eps=0.0005f: unlike smin_grad, cellular's F1/F2 are Euclidean distance fields with real - // curvature, so central differences carry O(eps^2) truncation error and a larger eps is - // worse, not better (see CellularGradientTolerance's comment for the measured sweep). - const float eps = 0.0005f; - - // Differentiate cellular's own returned .w values (F1): calling cellular again at p +/- - // eps and reading result.nearest.w / result.edge.w, not a duplicate FindF1F2 search. A - // mutant that corrupts only the returned gradient, leaving the returned value alone, - // would survive a check built on an independent value oracle; it cannot survive this one. - float NearestValueAt(float3 q) => math.cellular(q).nearest.w; - float EdgeValueAt(float3 q) => math.cellular(q).edge.w; - - AssertGradientMatchesCentralDifference(NearestValueAt, p, eps, result.nearest, CellularGradientTolerance); - AssertGradientMatchesCentralDifference(EdgeValueAt, p, eps, result.edge, CellularGradientTolerance); - } - - Assert.True(tested >= 100, $"only {tested} of {attempts} random points landed away from the F1=F2 band"); - } - - [Fact] - public void IdIsConstantAcrossAFeaturesWholeRegionAndVariesBetweenCells() - { - var random = new System.Random(0xCE13); - var baseCell = new float3(2.0f, 2.0f, 2.0f); - var feature = FeaturePoint(baseCell); - var idAtFeature = math.cellular(feature).id; - - for (var i = 0; i < 32; i++) - { - // Small offsets that stay inside the same Voronoi region (well short of any neighbour). - var jitter = new float3(random.NextSingle() * 0.2f - 0.1f, random.NextSingle() * 0.2f - 0.1f, random.NextSingle() * 0.2f - 0.1f); - var nearby = feature + jitter; - if (!FindNearestCell(nearby).Equals(baseCell)) - continue; - - Assert.Equal(idAtFeature, math.cellular(nearby).id, precision: 6); - } - - var otherCellId = math.cellular(FeaturePoint(baseCell + new float3(5.0f, 0.0f, 0.0f))).id; - Assert.NotEqual(idAtFeature, otherCellId); - } - - [Fact] - public void IdIsNotCorrelatedWithAnyJitterComponent() - { - // F4: id must come from hash bits the jitter never uses. A mutant that takes id from - // hash.x (or hash.y) makes id literally equal to that jitter component, which this catches - // as a correlation near 1.0, far past the 0.05 threshold. n = 20000 keeps sampling noise - // (measured under 0.01 at this n) well clear of that threshold. - const int n = 20000; - var random = new System.Random(0xCE15); - var ids = new double[n]; - var jitterX = new double[n]; - var jitterY = new double[n]; - var jitterZ = new double[n]; - - for (var i = 0; i < n; i++) - { - var cell = new float3(random.Next(-2000, 2000), random.Next(-2000, 2000), random.Next(-2000, 2000)); - var hash = math.pcg3d(math.int3(cell)); - var jitter = new float3(Unit(hash.x), Unit(hash.y), Unit(hash.z)); - - ids[i] = math.cellular(cell + jitter).id; - jitterX[i] = jitter.x; - jitterY[i] = jitter.y; - jitterZ[i] = jitter.z; - } - - Assert.True(Math.Abs(Correlation(ids, jitterX)) < 0.05, "id correlates with jitter.x"); - Assert.True(Math.Abs(Correlation(ids, jitterY)) < 0.05, "id correlates with jitter.y"); - Assert.True(Math.Abs(Correlation(ids, jitterZ)) < 0.05, "id correlates with jitter.z"); - } - - [Fact] - public void JitterAndIdPassAChiSquareUniformityTest() - { - // F4/jitter uniformity: cellular hashes the winning cell's INTEGER coordinate (design.md, - // "Integer hashing"), never that coordinate's float32 bit pattern. Hashing the bit pattern of - // an integer-valued float shares more structure between adjacent cells (same exponent, a - // mantissa one increment apart) than the integers themselves do going into pcg3d's own - // mixing, and that structure survived into the jitter: Soul measured jitter.x's marginal - // chi-square statistic at 203.8 over 1,000,000 cells this way (15 degrees of freedom; - // critical value 37.7 at alpha = 0.001), soundly rejecting uniformity. 16 equal-width bins - // over [0, 1) give those same 15 degrees of freedom for jitter.x/y/z and id alike. - const int n = 200_000; - const int bins = 16; - const double criticalValue = 37.7; // chi-square, 15 df, alpha = 0.001 - - var jitterXCounts = new int[bins]; - var jitterYCounts = new int[bins]; - var jitterZCounts = new int[bins]; - var idCounts = new int[bins]; - var random = new System.Random(0xCE19); - - for (var i = 0; i < n; i++) - { - var cell = new float3(random.Next(-100000, 100000), random.Next(-100000, 100000), random.Next(-100000, 100000)); - var hash = math.pcg3d(math.int3(cell)); - jitterXCounts[Bin(Unit(hash.x), bins)]++; - jitterYCounts[Bin(Unit(hash.y), bins)]++; - jitterZCounts[Bin(Unit(hash.z), bins)]++; - - var idHash = math.pcg4d(new int4(math.int3(cell), 0)); - idCounts[Bin(Unit(idHash.w), bins)]++; - } - - var expected = (double)n / bins; - AssertUniform(jitterXCounts, expected, criticalValue, "jitter.x"); - AssertUniform(jitterYCounts, expected, criticalValue, "jitter.y"); - AssertUniform(jitterZCounts, expected, criticalValue, "jitter.z"); - AssertUniform(idCounts, expected, criticalValue, "id"); - } - - private static int Bin(float value, int binCount) => Math.Clamp((int)(value * binCount), 0, binCount - 1); - - private static void AssertUniform(int[] counts, double expected, double criticalValue, string name) - { - var chiSquare = 0.0; - foreach (var count in counts) - { - var delta = count - expected; - chiSquare += delta * delta / expected; - } - - Assert.True(chiSquare < criticalValue, $"{name} chi-square {chiSquare:G6} exceeds critical value {criticalValue} ({counts.Length - 1} df)"); - } - - [Fact] - public void NoNaNAtIntegerPointsNear2To24() - { - // F3: past |p| of about 2^23, distinct cells' jittered features can round to the same - // float32 value, making F2 = 0 reachable. Soul measured 4096 of 4096 integer points at 2^24 - // producing NaN before the guard; this pins the fix over the same sample. - const float scale = 16777216.0f; // 2^24 - for (var ix = 0; ix < 16; ix++) - for (var iy = 0; iy < 16; iy++) - for (var iz = 0; iz < 16; iz++) - { - var p = new float3(scale + ix, scale + iy, scale + iz); - var result = math.cellular(p); - - Assert.True( - float.IsFinite(result.nearest.x) && float.IsFinite(result.nearest.y) && - float.IsFinite(result.nearest.z) && float.IsFinite(result.nearest.w), - $"nearest not finite at {p.x},{p.y},{p.z}: {result.nearest.x},{result.nearest.y},{result.nearest.z},{result.nearest.w}"); - Assert.True( - float.IsFinite(result.edge.x) && float.IsFinite(result.edge.y) && - float.IsFinite(result.edge.z) && float.IsFinite(result.edge.w), - $"edge not finite at {p.x},{p.y},{p.z}: {result.edge.x},{result.edge.y},{result.edge.z},{result.edge.w}"); - Assert.True(float.IsFinite(result.id), $"id not finite at {p.x},{p.y},{p.z}"); - } - } - - [Fact] - public void CellularUnitMapsAllOnesBitsBelowOne() - { - // F7: cellular_unit(0xFFFFFFFF) must land in [0, 1), not round up to exactly 1.0f. - var mapped = math.cellular_unit(-1); // -1's bit pattern is 0xFFFFFFFF. - Assert.True(mapped >= 0.0f && mapped < 1.0f, $"cellular_unit(0xFFFFFFFF) = {mapped}"); - } - - [Fact] - public void ProductionSearchMatchesTheBruteForceOracleExactly() - { - // F6, part 2: the production 5x5x5 search must equal the independent 7x7x7 oracle exactly - // (to the oracle's own float32 precision), over a large seeded sweep in the domain Soul - // measured ([-50, 50]^3, where 3x3x3 missed 9 of 400,000 points). - var random = new System.Random(0xCE16); - for (var i = 0; i < 20000; i++) - { - var p = new float3(random.NextSingle() * 100.0f - 50.0f, random.NextSingle() * 100.0f - 50.0f, random.NextSingle() * 100.0f - 50.0f); - var result = math.cellular(p); - var (f1, f2) = FindF1F2(p); - - Assert.Equal(f1, result.nearest.w, precision: 4); - Assert.Equal(f2 - f1, result.edge.w, precision: 4); - } - } - - [Fact] - public void SearchReachesEveryAxisAlignedRadiusTwoSlice() - { - // F6, part 2 (Soul finding): a single-slice loop-bound mutant on one axis (e.g. dz < 2 - // instead of dz <= 2, silently dropping the +2 layer on that axis alone) still passed the - // random 20,000-point sweeps above. That is not those sweeps being weak; it is the - // exactness proof's own margin (F1, F2 always < sqrt(3), a radius-2 cell's lower bound is - // max(0, 2-1) = 1, not "exactly 2" as an earlier version of this comment claimed) making a - // genuine win from any single |offset component| = 2 cell rare over uniformly random points - // (Soul, cut 2a-i: measured about 1 hit in 28,000 samples, not the "zero in 3,000,000" an - // earlier version of this comment claimed). - // Hunting for one by choosing candidate query POINTS is the wrong end of the search; this - // instead scans candidate integer CELLS and, for each, builds the query point most likely to - // realize that cell's neighbour as the winner: the closest point of the query cell's own unit - // cube to the target neighbour's actual jittered feature. That construction finds a real - // example for every one of the six axis-aligned radius-2 offsets within a couple thousand - // candidate cells, deterministically (pcg3d has no randomness to get lucky or unlucky with). - foreach (var offset in AxisAlignedRadiusTwoOffsets) - { - var p = FindPointRealizingOffset(offset); - var (f1, f2) = FindF1F2(p); // independent 7x7x7 oracle - var result = math.cellular(p); - Assert.Equal(f1, result.nearest.w, precision: 3); - Assert.Equal(f2 - f1, result.edge.w, precision: 3); - } - } - - // The six axis-aligned radius-2 offsets (F6, part 2): shared by - // SearchReachesEveryAxisAlignedRadiusTwoSlice and, via FindPointRealizingOffset, by - // HlslSourceCompatibilityTests' mirror-comparison inputs, so both pin the same construction. - internal static readonly float3[] AxisAlignedRadiusTwoOffsets = - { - new(2.0f, 0.0f, 0.0f), new(-2.0f, 0.0f, 0.0f), - new(0.0f, 2.0f, 0.0f), new(0.0f, -2.0f, 0.0f), - new(0.0f, 0.0f, 2.0f), new(0.0f, 0.0f, -2.0f), - }; - - // Hunting for a query point where a radius-2 offset wins F1 or F2 by choosing candidate query - // POINTS is the wrong end of the search (Soul, cut 2a-i: about 1 hit in 28,000 uniformly random - // points); this instead scans candidate integer CELLS and, for each, builds the query point most - // likely to realize that cell's neighbour as the winner: the closest point of the query cell's - // own unit cube to the target neighbour's actual jittered feature. That construction finds a - // real example for every one of the six axis-aligned radius-2 offsets within a couple thousand - // candidate cells, deterministically (pcg3d has no randomness to get lucky or unlucky with). - internal static float3 FindPointRealizingOffset(float3 offset) - { - for (var qz = -80; qz <= 80; qz++) - for (var qy = -80; qy <= 80; qy++) - for (var qx = -80; qx <= 80; qx++) - { - var q = new float3(qx, qy, qz); - var targetFeature = FeaturePoint(q + offset); - var p = new float3( - Math.Clamp(targetFeature.x, q.x, q.x + 0.999f), - Math.Clamp(targetFeature.y, q.y, q.y + 0.999f), - Math.Clamp(targetFeature.z, q.z, q.z + 0.999f)); - - var (f1, f2) = FindF1F2(p); // independent 7x7x7 oracle - var d = math.distance(p, targetFeature); - if (MathF.Abs(d - f1) > 1.0e-4f && MathF.Abs(d - f2) > 1.0e-4f) - continue; // this cell didn't realize the target offset as F1 or F2; try another. - - return p; - } - - throw new InvalidOperationException($"could not construct a query point where offset {offset.x},{offset.y},{offset.z} ever wins F1 or F2"); - } - - [Fact] - public void PrunedSearchIsBitIdenticalToTheUnprunedFiveCubedSearchBelowTwoToTheTwentyFifth() - { - // F6, part 2: the lower-bound prune inside math.cellular's loop must never change the - // result. Compares against an independent, unpruned 5x5x5 reference that visits every cell - // in the same fixed order, over a large seeded sweep in [-50, 50]^3. - // - // This bit-identity has a domain: it holds for |p| < 2^25 (design.md, "Precision domain"). - // Above that, cell + offset starts to round in float32, so the pruned loop's recomputed - // neighbour and the unpruned loop's neighbour at the same nominal (dx, dy, dz) can land on - // different actual cells, and the two searches diverge (Soul, cut 2a-i: 180 of 1,100,000 - // points differ at |p| ~= 3.4e7). [-50, 50]^3 is comfortably inside the proven domain. - var random = new System.Random(0xCE18); - for (var i = 0; i < 20000; i++) - { - var p = new float3(random.NextSingle() * 100.0f - 50.0f, random.NextSingle() * 100.0f - 50.0f, random.NextSingle() * 100.0f - 50.0f); - var pruned = math.cellular(p); - var unpruned = UnprunedCellular5x5x5(p); - - Assert.Equal(unpruned.nearest.x, pruned.nearest.x); - Assert.Equal(unpruned.nearest.y, pruned.nearest.y); - Assert.Equal(unpruned.nearest.z, pruned.nearest.z); - Assert.Equal(unpruned.nearest.w, pruned.nearest.w); - Assert.Equal(unpruned.edge.x, pruned.edge.x); - Assert.Equal(unpruned.edge.y, pruned.edge.y); - Assert.Equal(unpruned.edge.z, pruned.edge.z); - Assert.Equal(unpruned.edge.w, pruned.edge.w); - Assert.Equal(unpruned.id, pruned.id); - } - } - - // Independent of math.cellular's own pruning: visits every cell of the 5x5x5 block, in the same - // fixed order, unconditionally. - private static CultCellular UnprunedCellular5x5x5(float3 p) - { - var cell = new float3(MathF.Floor(p.x), MathF.Floor(p.y), MathF.Floor(p.z)); - var f1 = 1.0e30f; - var f2 = 1.0e30f; - var c1 = float3.zero; - var c2 = float3.zero; - var cellId = float3.zero; - - for (var dz = -2; dz <= 2; dz++) - for (var dy = -2; dy <= 2; dy++) - for (var dx = -2; dx <= 2; dx++) - { - var neighbor = cell + new float3(dx, dy, dz); - var feature = FeaturePoint(neighbor); - var d = math.distance(p, feature); - if (d < f1) { f2 = f1; c2 = c1; f1 = d; c1 = feature; cellId = neighbor; } - else if (d < f2) { f2 = d; c2 = feature; } - } - - var grad1 = f1 > 0.0f ? (p - c1) / f1 : float3.zero; - var grad2 = f2 > 0.0f ? (p - c2) / f2 : float3.zero; - var idHash = math.pcg4d(new int4(math.int3(cellId), 0)); - return new CultCellular(new float4(grad1, f1), new float4(grad2 - grad1, f2 - f1), Unit(idHash.w)); - } - - private static double Correlation(double[] a, double[] b) - { - var n = a.Length; - var meanA = 0.0; - var meanB = 0.0; - for (var i = 0; i < n; i++) { meanA += a[i]; meanB += b[i]; } - meanA /= n; - meanB /= n; - - var cov = 0.0; - var varA = 0.0; - var varB = 0.0; - for (var i = 0; i < n; i++) - { - var da = a[i] - meanA; - var db = b[i] - meanB; - cov += da * db; - varA += da * da; - varB += db * db; - } - - return cov / Math.Sqrt(varA * varB); - } - - // ---- shared fixtures: an independent brute-force Worley search over the same public pcg3d - // hash cellular itself is documented to use (design.md, "Integer hashing"), so these tests do - // not anchor to cellular's own control flow or iteration order. FindF1F2 searches 7x7x7 (radius - // 3), strictly wider than production's own proven-sufficient 5x5x5 (F6), so it is a true - // independent oracle rather than a second copy of the algorithm under test. ---- - - internal static float3 FeaturePoint(float3 cell) - { - var hash = math.pcg3d(math.int3(cell)); - var jitter = new float3(Unit(hash.x), Unit(hash.y), Unit(hash.z)); - return cell + jitter; - } - - // Mirrors math.cellular_unit's top-24-bit [0, 1) mapping (F7) exactly, so this fixture never - // drifts from production's own jitter/id mapping. - private static float Unit(int bits) => ((uint)bits >> 8) * (1.0f / 16777216.0f); - - private static (float f1, float f2) FindF1F2(float3 p) - { - var (f1, f2, _) = FindF1F2F3(p); - return (f1, f2); - } - - // Same independent 7x7x7 oracle as FindF1F2, plus the third-nearest distance. Central-difference - // tests need this: excluding only the F1=F2 gap is not enough, because a small F2=F3 gap is also - // a kink (the identity of the second-nearest feature swaps there), and hitting one produces a - // large, curvature-driven finite-difference error unrelated to eps or float noise (Soul, cut - // 2a-i: an unfiltered large sample hit an edge error of 0.78 this way, versus ~2e-4 once F2=F3 - // is also excluded). - private static (float f1, float f2, float f3) FindF1F2F3(float3 p) - { - var cell = new float3(MathF.Floor(p.x), MathF.Floor(p.y), MathF.Floor(p.z)); - var f1 = float.PositiveInfinity; - var f2 = float.PositiveInfinity; - var f3 = float.PositiveInfinity; - for (var dz = -3; dz <= 3; dz++) - for (var dy = -3; dy <= 3; dy++) - for (var dx = -3; dx <= 3; dx++) - { - var d = math.distance(p, FeaturePoint(cell + new float3(dx, dy, dz))); - if (d < f1) { f3 = f2; f2 = f1; f1 = d; } - else if (d < f2) { f3 = f2; f2 = d; } - else if (d < f3) { f3 = d; } - } - - return (f1, f2, f3); - } - - private static (float3 offset, float f1, float f2) FindNearestOffset(float3 p) - { - var cell = new float3(MathF.Floor(p.x), MathF.Floor(p.y), MathF.Floor(p.z)); - var f1 = float.PositiveInfinity; - var f2 = float.PositiveInfinity; - var bestOffset = float3.zero; - for (var dz = -2; dz <= 2; dz++) - for (var dy = -2; dy <= 2; dy++) - for (var dx = -2; dx <= 2; dx++) - { - var offset = new float3(dx, dy, dz); - var d = math.distance(p, FeaturePoint(cell + offset)); - if (d < f1) { f2 = f1; f1 = d; bestOffset = offset; } - else if (d < f2) { f2 = d; } - } - - return (bestOffset, f1, f2); - } - - private static float3 FindNearestCell(float3 p) - { - var cell = new float3(MathF.Floor(p.x), MathF.Floor(p.y), MathF.Floor(p.z)); - var best = float.PositiveInfinity; - var bestCell = cell; - for (var dz = -1; dz <= 1; dz++) - for (var dy = -1; dy <= 1; dy++) - for (var dx = -1; dx <= 1; dx++) - { - var neighbour = cell + new float3(dx, dy, dz); - var d = math.distance(p, FeaturePoint(neighbour)); - if (d < best) { best = d; bestCell = neighbour; } - } - - return bestCell; - } - - private static void AssertGradientMatchesCentralDifference(Func scalarField, float3 p, float eps, float4 valueAndGradient, float tolerance) - { - var numeric = new float3( - (scalarField(p + new float3(eps, 0.0f, 0.0f)) - scalarField(p - new float3(eps, 0.0f, 0.0f))) / (2.0f * eps), - (scalarField(p + new float3(0.0f, eps, 0.0f)) - scalarField(p - new float3(0.0f, eps, 0.0f))) / (2.0f * eps), - (scalarField(p + new float3(0.0f, 0.0f, eps)) - scalarField(p - new float3(0.0f, 0.0f, eps))) / (2.0f * eps)); - - AssertWithinTolerance(numeric.x, valueAndGradient.x, tolerance); - AssertWithinTolerance(numeric.y, valueAndGradient.y, tolerance); - AssertWithinTolerance(numeric.z, valueAndGradient.z, tolerance); - } - - // A fixed decimal-place Assert.Equal snaps two numbers that agree to within a few times 1e-5 to - // different rounded digits whenever their true difference straddles a rounding boundary (seen: - // 0.824987829 vs 0.825006127, agreeing to 2e-5, rounding to 0.82 and 0.83). An absolute-tolerance - // check states the actual claim (central differences agree with the analytic gradient within the - // finite-difference step's own truncation error) without that artifact. - private static void AssertWithinTolerance(float expected, float actual, float tolerance) => - Assert.True(MathF.Abs(expected - actual) <= tolerance, $"expected {expected}, actual {actual}, tolerance {tolerance}"); - - private static float3 RandomUnit(System.Random random) => - new(random.NextSingle() * 2.0f - 1.0f, random.NextSingle() * 2.0f - 1.0f, random.NextSingle() * 2.0f - 1.0f); - - private static float RandomScalar(System.Random random) => random.NextSingle() * 20.0f - 10.0f; -} diff --git a/packages/cultmath/tests/CultMath.Tests/FirstOrderInterceptTests.cs b/packages/cultmath/tests/CultMath.Tests/FirstOrderInterceptTests.cs deleted file mode 100644 index a211d266..00000000 --- a/packages/cultmath/tests/CultMath.Tests/FirstOrderInterceptTests.cs +++ /dev/null @@ -1,182 +0,0 @@ -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -// math.first_order_intercept_time / first_order_intercept had one happy-path test before this -// (MathTests.FirstOrderInterceptSolvesSimpleClosingTarget). Stryker's baseline on -// hands/adopt-stryker found L264 (zero relative velocity), L270 (the a-approx-zero linear -// fallback), L280/L283 (the quadratic determinant and its roots) and L285 (the t1>0 branch) -// all undefended by fixtures that never varied relative velocity, never went linear, never -// lacked a solution, and never used off-axis/off-origin shooter and target state. -// -// For the closing cases (a genuine positive root exists), the assertion is behavioural: the -// returned aim point, fired at shotSpeed from a moving shooter, and the target's own motion -// must put the shot and the target at the same place at the returned time. That is verified by -// computing both positions independently in the test from math.first_order_intercept's own -// contract (targetPosition + time * targetRelativeVelocity is the aim point; the shot's actual -// world position folds in the shooter's velocity), not by re-deriving a second copy of the -// production formula. -// -// For the no-solution branches, there is no physical coincidence to check (the fallback is not -// a root of the intercept equation), so the assertion instead pins the contract read directly -// from the source at math.cs:264-298: velocitySquared < 0.001 => 0; determinant < 0 => 0; -// determinant > 0 with both roots <= 0 => 0 (via max(t2, 0)). -public sealed class FirstOrderInterceptTests -{ - private const int Precision = 4; - - [Fact] - public void ZeroRelativeVelocityReturnsZeroTime() - { - // Target and shooter share a velocity: targetRelativeVelocity is exactly zero, well - // under the 0.001 lengthsq guard, regardless of either party's absolute speed. - var time = math.first_order_intercept_time( - shotSpeed: 50.0f, - targetRelativePosition: new float3(12.0f, -7.0f, 3.0f), - targetRelativeVelocity: float3.zero); - - Assert.Equal(0.0f, time); - - var aimPoint = math.first_order_intercept( - shooterPosition: new float3(1.0f, 2.0f, 3.0f), - shooterVelocity: new float3(4.0f, 4.0f, 4.0f), - shotSpeed: 50.0f, - targetPosition: new float3(13.0f, -5.0f, 6.0f), - targetVelocity: new float3(4.0f, 4.0f, 4.0f)); - - // Contract: with time 0, the aim point is exactly the target's current position. - Assert.Equal(13.0f, aimPoint.x, Precision); - Assert.Equal(-5.0f, aimPoint.y, Precision); - Assert.Equal(6.0f, aimPoint.z, Precision); - } - - [Fact] - public void LinearFallbackWhenRelativeSpeedMatchesShotSpeedProducesPhysicalIntercept() - { - // velocitySquared == shotSpeed*shotSpeed makes a == 0 (|a| < 0.001), forcing the - // linear branch: time = -lengthsq(pos) / (2 * dot(vel, pos)), clamped to >= 0. - var shooterPosition = new float3(2.0f, -3.0f, 1.0f); - var shooterVelocity = new float3(1.0f, 0.5f, -0.5f); - var targetRelativePosition = new float3(10.0f, 0.0f, 0.0f); - var targetRelativeVelocity = new float3(-2.0f, 0.0f, 0.0f); - const float shotSpeed = 2.0f; // |targetRelativeVelocity| == 2 == shotSpeed => a == 0 - - var time = math.first_order_intercept_time(shotSpeed, targetRelativePosition, targetRelativeVelocity); - - // -100 / (2 * -20) = 2.5, computed independently of the production formula's code path. - Assert.Equal(2.5f, time, Precision); - - var targetPosition = shooterPosition + targetRelativePosition; - var targetVelocity = shooterVelocity + targetRelativeVelocity; - - var aimPoint = math.first_order_intercept(shooterPosition, shooterVelocity, shotSpeed, targetPosition, targetVelocity); - AssertShotAndTargetCoincideAtTime(shooterPosition, shooterVelocity, shotSpeed, aimPoint, targetPosition, targetVelocity, time); - } - - [Fact] - public void NegativeDeterminantReturnsZeroWhenTargetOutrunsTheProjectile() - { - // Target moving fast and mostly sideways, with a slow shot, so no real root of the - // intercept quadratic exists. b = 2*dot(vel, pos) is deliberately nonzero (-40): if it - // were 0, a mutant that drops the "determinant < 0" branch entirely and falls through to - // `max(-b / (2a), 0)` would coincidentally also compute 0 and this test would not - // distinguish the two. - var time = math.first_order_intercept_time( - shotSpeed: 1.0f, - targetRelativePosition: new float3(10.0f, 0.0f, 0.0f), - targetRelativeVelocity: new float3(-2.0f, 30.0f, 0.0f)); - - Assert.Equal(0.0f, time); - } - - [Fact] - public void BothQuadraticRootsPositiveReturnsTheEarlierOne() - { - // velocitySquared > shotSpeed*shotSpeed (a > 0): the target is relatively faster than - // the shot, but closing almost head-on, so both quadratic roots are real and positive - // (lengthsq(pos) >= 0 forces same-signed roots whenever a > 0). This is the only shape - // that reaches the `t1 > 0` branch's `t2 > 0 ? min(t1, t2) : t1` line at all; every other - // fixture in this file keeps t1 <= 0. - var shooterPosition = new float3(4.0f, -2.0f, 1.0f); - var shooterVelocity = new float3(0.5f, -0.5f, 0.0f); - var shotSpeed = 5.0f; - var targetRelativePosition = new float3(10.0f, 0.0f, 0.0f); - var targetRelativeVelocity = new float3(-20.0f, 0.0f, 0.0f); - - var time = math.first_order_intercept_time(shotSpeed, targetRelativePosition, targetRelativeVelocity); - - // a = 400 - 25 = 375, b = -400, c = 100, determinant = 10000, root = 100: - // t1 = (400 + 100) / 750 = 0.6667, t2 = (400 - 100) / 750 = 0.4. Both positive; the - // earlier one (0.4) is the physically correct intercept time. - Assert.Equal(0.4f, time, Precision); - - var targetPosition = shooterPosition + targetRelativePosition; - var targetVelocity = shooterVelocity + targetRelativeVelocity; - var aimPoint = math.first_order_intercept(shooterPosition, shooterVelocity, shotSpeed, targetPosition, targetVelocity); - AssertShotAndTargetCoincideAtTime(shooterPosition, shooterVelocity, shotSpeed, aimPoint, targetPosition, targetVelocity, time); - } - - [Fact] - public void RecedingTargetWithBothRootsNonPositiveReturnsZero() - { - // Target moving directly away from the shooter, faster than a slow shot: a real - // determinant exists but both quadratic roots are negative, so t1 > 0 is false and the - // function falls through to max(t2, 0) == 0. - var time = math.first_order_intercept_time( - shotSpeed: 1.0f, - targetRelativePosition: new float3(10.0f, 0.0f, 0.0f), - targetRelativeVelocity: new float3(5.0f, 0.0f, 0.0f)); - - Assert.Equal(0.0f, time); - } - - [Fact] - public void ClosingCaseWithOffOriginOffAxisPositionsProducesPhysicallyConsistentIntercept() - { - // Neither shooter nor target sits at the origin, no vector is axis-aligned, and both - // parties are moving. This is the fixture shape ("degenerate fixtures are how these - // survived") the earlier single test never exercised. - var shooterPosition = new float3(2.0f, 3.0f, -1.0f); - var shooterVelocity = new float3(1.0f, -1.0f, 0.5f); - var shotSpeed = 10.0f; - var targetPosition = new float3(15.0f, 8.0f, 4.0f); - var targetVelocity = new float3(-3.0f, 2.0f, 1.0f); - - var targetRelativePosition = targetPosition - shooterPosition; - var targetRelativeVelocity = targetVelocity - shooterVelocity; - var time = math.first_order_intercept_time(shotSpeed, targetRelativePosition, targetRelativeVelocity); - - Assert.True(time > 0.0f, "fixture must produce a genuine closing solution"); - - var aimPoint = math.first_order_intercept(shooterPosition, shooterVelocity, shotSpeed, targetPosition, targetVelocity); - AssertShotAndTargetCoincideAtTime(shooterPosition, shooterVelocity, shotSpeed, aimPoint, targetPosition, targetVelocity, time); - } - - /// - /// Fires from , inheriting - /// and adding toward , and asserts the - /// shot's world position at coincides with the target's own actual - /// motion ( + time * ). - /// This is the behavioural contract first_order_intercept exists to serve: aim here, and the - /// target will be there when the shot arrives. - /// - private static void AssertShotAndTargetCoincideAtTime( - float3 shooterPosition, - float3 shooterVelocity, - float shotSpeed, - float3 aimPoint, - float3 targetPosition, - float3 targetVelocity, - float time) - { - var direction = math.normalize(aimPoint - shooterPosition); - var shotVelocity = shooterVelocity + shotSpeed * direction; - var shotPositionAtTime = shooterPosition + time * shotVelocity; - var targetPositionAtTime = targetPosition + time * targetVelocity; - - Assert.Equal(targetPositionAtTime.x, shotPositionAtTime.x, Precision); - Assert.Equal(targetPositionAtTime.y, shotPositionAtTime.y, Precision); - Assert.Equal(targetPositionAtTime.z, shotPositionAtTime.z, Precision); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/GlslLowering.cs b/packages/cultmath/tests/CultMath.Tests/GlslLowering.cs deleted file mode 100644 index eff40196..00000000 --- a/packages/cultmath/tests/CultMath.Tests/GlslLowering.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System.Text; -using System.Text.RegularExpressions; - -namespace CultMath.Tests; - -/// -/// The HLSL to GLSL ES 3.00 transformation that produces shaders/CultMath.glsl, and one file per -/// entry, from shaders/CultMath.hlsl and its includes. The steps below, -/// in order, are the complete list documented in docs/design.md (GLSL Target: Source Transformations). -/// A dialect gap outside the list is fixed in the HLSL, in the subset both languages share, never by a -/// special case here; GlslMirrorTests fails on any HLSL-only token that survives. -/// -internal static class GlslLowering -{ - /// - /// Includes under a file-level licence of their own: each is lowered into its own output file instead - /// of being inlined, so CultMath.glsl stays MIT. This table is the lowering's only rule keyed by name. - /// - internal static readonly IReadOnlyDictionary SeparateFiles = - new Dictionary - { - // Phacelle is a port of MPL-2.0 code, and MPL-2.0 covers the files that carry it. - ["CultMath.Phacelle.hlsl"] = ("CultMath.Phacelle.glsl", "MPL-2.0"), - }; - - private const string Regenerate = - "by GlslLowering (packages/cultmath/tests/CultMath.Tests/GlslLowering.cs). Do not edit; regenerate with " + - "CULTMATH_WRITE_GLSL=1 dotnet test --filter GlslMirrorTests."; - - /// - /// The lowered files as (name under shaders/, text): CultMath.glsl first, then one per - /// entry, which requires CultMath.glsl before it. - /// - internal static IReadOnlyList<(string File, string Text)> Lower(string cultMathRoot) - { - // 1. Each #include is inlined in place by the C# mirror's own resolver, except a SeparateFiles - // include, which leaves nothing behind and is lowered into its own file. - var inlined = new List(); - var library = HlslSourceCompatibilityTests.ReadShaderSource(cultMathRoot, name => - { - if (SeparateFiles.ContainsKey(name)) - return false; - inlined.Add(name); - return true; - }); - - var outputs = new List<(string File, string Text)>(); - var pointers = new List(); - foreach (var (hlsl, (glsl, licence)) in SeparateFiles) - { - var text = LowerText( - File.ReadAllText(Path.Combine(cultMathRoot, "shaders", hlsl)), - $"// Generated from shaders/{hlsl} {Regenerate} {licence}; requires CultMath.glsl before it.", - glsl); - var functions = Regex.Matches(text, @"(?m)^\w+\s+(cultmath_\w+)\s*\(").Select(m => m.Groups[1].Value); - pointers.Add($" {string.Join(", ", functions)} is in {glsl}, to be concatenated after this file by consumers that call it."); - outputs.Add((glsl, text)); - } - - var includes = string.Concat(inlined.Select(name => " and " + name)); - outputs.Insert(0, ("CultMath.glsl", LowerText( - library, $"// Generated from shaders/CultMath.hlsl{includes} {Regenerate} MIT.{string.Concat(pointers)}", "CultMath.glsl"))); - return outputs; - } - - private static string LowerText(string hlsl, string provenance, string file) - { - var source = hlsl.ReplaceLineEndings("\n"); - - // 2. Include guards are dropped, and so are the functions taking Texture2D/SamplerState, exactly - // as the C# mirror drops them; the host shader samples its own textures. - source = Regex.Replace(source, @"(?m)^[ \t]*#(ifndef|define|endif)\b.*$", string.Empty); - source = Regex.Replace(source, @"(?ms)^\w+ \w+\([^)]*\b(Texture2D|SamplerState)\b[^)]*\)\s*\{.*?^\}[ \t]*$", string.Empty); - - // 3. Type names: floatN, intN, uintN and boolN become vecN, ivecN, uvecN and bvecN. - source = LowerTypeNames(source); - - // 4. File-scope `static const` becomes `const`. - source = Regex.Replace(source, @"(?m)^static const ", "const "); - - // 5. C-style casts (float)x, (int)x and (uint)x become constructor calls float(x), int(x) and - // uint(x). The operand is found by a balanced scanner, not a regex: (int)((state >> 28) + 4u) - // nests parentheses. - source = LowerCasts(source); - - // 6. Intrinsic renames: lerp -> mix, frac -> fract, rsqrt -> inversesqrt, asuint -> - // floatBitsToUint, asfloat -> uintBitsToFloat, and saturate(x) -> clamp(x, 0.0, 1.0). - // Identifier boundaries keep cultmath_lerp and the rest of the cultmath_ names intact. - source = Regex.Replace(source, @"\blerp\(", "mix("); - source = Regex.Replace(source, @"\bfrac\(", "fract("); - source = Regex.Replace(source, @"\brsqrt\(", "inversesqrt("); - source = Regex.Replace(source, @"\basuint\(", "floatBitsToUint("); - source = Regex.Replace(source, @"\basfloat\(", "uintBitsToFloat("); - source = LowerSaturate(source); - - // 7. Float literals pass through: HLSL's unsuffixed 0.5 and 1.0e30 are GLSL literals already. - - // 8. The guard named for the file (CultMath.glsl -> CULTMATH_GLSL), and 9. the provenance line. - var guard = file.ToUpperInvariant().Replace('.', '_'); - return provenance + "\n#ifndef " + guard + "\n#define " + guard + "\n" + source.Trim('\n') + "\n\n#endif\n"; - } - - /// Step 3 alone; GlslMirrorTests maps the HLSL signatures with it to compare overloads. - internal static string LowerTypeNames(string source) - { - source = Regex.Replace(source, @"\bfloat([234])\b", "vec$1"); - source = Regex.Replace(source, @"\bint([234])\b", "ivec$1"); - source = Regex.Replace(source, @"\buint([234])\b", "uvec$1"); - return Regex.Replace(source, @"\bbool([234])\b", "bvec$1"); - } - - private static readonly Regex Cast = new(@"\((float|int|uint)\)"); - - private static string LowerCasts(string source) - { - for (var match = Cast.Match(source); match.Success; match = Cast.Match(source)) - { - var start = match.Index + match.Length; - var end = OperandEnd(source, start); - // A parenthesized operand lends its own parentheses to the constructor call. - var operand = source[start] == '(' && Balanced(source, start) == end ? source[(start + 1)..(end - 1)] : source[start..end]; - source = source[..match.Index] + match.Groups[1].Value + "(" + operand + ")" + source[end..]; - } - - return source; - } - - // The cast operand: a parenthesized group, or an identifier or number followed by any member - // accesses, calls and indexing. Anything else is outside the list and throws. - private static int OperandEnd(string source, int index) - { - if (index < source.Length && source[index] == '(') - return Balanced(source, index); - var token = Regex.Match(source[index..], @"^[A-Za-z_0-9]+"); - if (!token.Success) - throw new InvalidOperationException($"cast operand outside the lowering list at: {source.Substring(index, Math.Min(40, source.Length - index))}"); - index += token.Length; - while (index < source.Length) - { - if (source[index] == '(' || source[index] == '[') - index = Balanced(source, index); - else if (source[index] == '.' && index + 1 < source.Length && (char.IsLetter(source[index + 1]) || source[index + 1] == '_')) - index += 1 + Regex.Match(source[(index + 1)..], @"^[A-Za-z_0-9]+").Length; - else - break; - } - - return index; - } - - // The index one past the bracket that closes the one at `open`. - private static int Balanced(string source, int open) - { - var depth = 0; - for (var i = open; i < source.Length; i++) - { - if (source[i] is '(' or '[') - depth++; - else if (source[i] is ')' or ']' && --depth == 0) - return i + 1; - } - - throw new InvalidOperationException($"unbalanced bracket at {open}"); - } - - private static string LowerSaturate(string source) - { - var saturate = new Regex(@"\bsaturate\("); - for (var match = saturate.Match(source); match.Success; match = saturate.Match(source)) - { - var open = match.Index + match.Length - 1; - var close = Balanced(source, open); - var argument = source[(open + 1)..(close - 1)]; - source = source[..match.Index] + "clamp(" + argument + ", 0.0, 1.0)" + source[close..]; - } - - return source; - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/GlslMirrorTests.cs b/packages/cultmath/tests/CultMath.Tests/GlslMirrorTests.cs deleted file mode 100644 index f0f61622..00000000 --- a/packages/cultmath/tests/CultMath.Tests/GlslMirrorTests.cs +++ /dev/null @@ -1,678 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using System.Text.Json.Nodes; -using System.Text.RegularExpressions; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -/// -/// shaders/CultMath.glsl and shaders/CultMath.Phacelle.glsl are derived: each is exactly its -/// output from the committed HLSL, no HLSL-only token survives the -/// lowering, no public function is dropped except the texture samplers, the MPL-2.0 Phacelle code lives -/// only in its own file, and the golden fixture a WebGL2 consumer evaluates is C#'s current output. With -/// CULTMATH_WRITE_GLSL=1 set, the first and last tests write the committed files before comparing, which -/// is the one regeneration path. -/// -public sealed class GlslMirrorTests -{ - private readonly ITestOutputHelper output; - - public GlslMirrorTests(ITestOutputHelper output) => this.output = output; - - private static bool Write => Environment.GetEnvironmentVariable("CULTMATH_WRITE_GLSL") == "1"; - - private static string Root => HlslSourceCompatibilityTests.FindCultMathRoot(); - - private static string FixturePath => Path.Combine(Root, "tests", "CultMath.Tests", "fixtures", "glsl-parity.json"); - - private static string Hlsl => HlslSourceCompatibilityTests.ReadShaderSource(Root).ReplaceLineEndings("\n"); - - private static IReadOnlyList<(string File, string Text)> Lowered => GlslLowering.Lower(Root); - - [Fact] - public void CommittedGlslEqualsLowering() - { - foreach (var (file, expected) in Lowered) - { - var path = Path.Combine(Root, "shaders", file); - if (Write) - File.WriteAllText(path, expected); - var committed = File.ReadAllText(path).ReplaceLineEndings("\n"); - Assert.True(committed == expected, $"shaders/{file} is not the lowering of the committed HLSL (regenerate with CULTMATH_WRITE_GLSL=1):\n" + UnifiedDiff(committed, expected)); - } - } - - // Identifier boundaries: cultmath_lerp is a CultMath function, lerp( is HLSL. - private static readonly Regex HlslOnly = new( - @"\b(float|u?int|bool)[234]\b|\blerp\(|\bfrac\(|\bsaturate\(|\brsqrt\(|\basuint\(|\basfloat\(|static const|\((float|int|uint)\)|Texture2D|SamplerState|#include|precision (high|medium|low)p"); - - [Fact] - public void NoHlslOnlyTokensSurvive() - { - foreach (var (file, text) in Lowered) - { - var survivors = HlslOnly.Matches(text).Select(m => m.Value).Distinct().ToArray(); - Assert.True(survivors.Length == 0, $"HLSL-only tokens in {file}: " + string.Join(", ", survivors)); - } - } - - private static readonly Regex Definition = new(@"(?m)^\w+\s+(cultmath_\w+)\s*\(([^)]*)\)"); - - // A definition's signature, its name and parameter types, so an overload counts on its own: - // "cultmath_pcg3d(vec2)". HLSL type names are mapped by the lowering's own step 3. - private static string Signature(Match definition) => - definition.Groups[1].Value + "(" + string.Join(", ", definition.Groups[2].Value - .Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries) - .Select(parameter => GlslLowering.LowerTypeNames(string.Join(' ', Regex.Split(parameter, @"\s+")[..^1])))) + ")"; - - [Fact] - public void EveryPublicFunctionIsLowered() - { - var lowered = Lowered; - var hlsl = Definition.Matches(Hlsl).Where(m => !Regex.IsMatch(m.Groups[2].Value, @"\b(Texture2D|SamplerState)\b")) - .Select(Signature).ToHashSet(); - var glsl = lowered.SelectMany(output => Definition.Matches(output.Text)).Select(Signature).ToHashSet(); - Assert.Contains("cultmath_pcg3d(vec2)", glsl); - Assert.True(hlsl.SetEquals(glsl), "HLSL only: " + string.Join(", ", hlsl.Except(glsl)) + "; GLSL only: " + string.Join(", ", glsl.Except(hlsl))); - - // The MPL-2.0 code is in its own file and nowhere in the MIT library. - var library = lowered.Single(output => output.File == "CultMath.glsl").Text; - var phacelle = lowered.Single(output => output.File == "CultMath.Phacelle.glsl").Text; - foreach (var token in new[] { "cultmath_phacelle(", "CultPhasor" }) - { - Assert.DoesNotContain(token, library); - Assert.Contains(token, phacelle); - } - } - - // The two-file contract a consumer relies on when it concatenates CultMath.Phacelle.glsl after - // CultMath.glsl: distinct guards (a shared one would hide the second file's body), each provenance - // line naming its file's licence, and the MIT file pointing at the one that holds cultmath_phacelle. - [Fact] - public void TwoFileHeaderContract() - { - var lowered = Lowered; - var guards = lowered.Select(output => Regex.Match(output.Text, @"^[^\n]*\n#ifndef (\w+)\n#define \1\n").Groups[1].Value).ToArray(); - Assert.All(guards, guard => Assert.NotEqual(string.Empty, guard)); - Assert.Equal(guards.Length, guards.Distinct().Count()); - - var library = lowered.Single(output => output.File == "CultMath.glsl").Text.Split('\n')[0]; - var phacelle = lowered.Single(output => output.File == "CultMath.Phacelle.glsl").Text.Split('\n')[0]; - Assert.Contains(" MIT.", library); - Assert.DoesNotContain("MPL", library); - Assert.Contains("cultmath_phacelle is in CultMath.Phacelle.glsl", library); - Assert.Contains(" MPL-2.0;", phacelle); - Assert.DoesNotContain("MIT", phacelle); - } - - [Fact] - public void GoldenFixtureMatchesCSharp() - { - // Arguments are drawn only here, when regenerating: Interval draws widths through MathF.Pow, whose - // bits differ by OS. Checking evaluates C# on the committed fixture's own arguments. - if (Write) - { - var random = new System.Random(Seed); - Directory.CreateDirectory(Path.GetDirectoryName(FixturePath)!); - File.WriteAllText(FixturePath, GoldenFixture((f, _) => Families[f].Arguments(random))); - } - - var committed = JsonNode.Parse(File.ReadAllText(FixturePath))!.AsObject(); - var committedFamilies = committed["functions"]!.AsArray(); - Assert.Equal(Families.Length, committedFamilies.Count); - for (var f = 0; f < Families.Length; f++) - Assert.True(committedFamilies[f]!["cases"]!.AsArray().Count == Points, $"{Families[f].Glsl}: the fixture does not hold {Points} cases"); - var current = JsonNode.Parse(GoldenFixture((f, p) => - Arguments(Resolve(Families[f].Glsl), ((string)committedFamilies[f]!["cases"]![p]!).Split(" -> ")[0])))!.AsObject(); - var currentFamilies = current["functions"]!.AsArray(); - - // Family by family: every family is compared as text, except those whose C# bits come from the - // platform's libm, which are compared case by case within their family's platform bound. A family - // with a check must also pass it on C#'s own results, so the rule the WebGL2 consumer applies holds - // for the reference. - for (var f = 0; f < Families.Length; f++) - { - var want = currentFamilies[f]!.AsObject(); - var have = committedFamilies[f]!.AsObject(); - var name = (string)want["glsl"]!; - Assert.Equal(name, (string?)have["glsl"]); - Assert.Equal((string)want["tolerance"]!, (string?)have["tolerance"]); - Assert.Equal((string?)want["check"], (string?)have["check"]); - switch (Families[f].Platform) - { - case Platform.Ulp: - var ulps = MaxDistance(have["cases"]!.AsArray(), want["cases"]!.AsArray(), (x, y) => Math.Abs((long)Ordered(x) - Ordered(y))); - output.WriteLine($"{name}: within {ulps} ulp of this platform's libm ({RuntimeInformation.OSDescription}); fixture generated on {have["platform"]}"); - Assert.True(ulps <= 1, $"{name}: {ulps} ulp from this platform's result, more than 1"); - break; - case Platform.Scaled: - var scaled = MaxDistance(have["cases"]!.AsArray(), want["cases"]!.AsArray(), (x, y) => - { - double v = BitConverter.Int32BitsToSingle(x), w = BitConverter.Int32BitsToSingle(y); - return x == y ? 0.0 : Math.Abs(v - w) / Math.Max(Math.Abs(v), 1.0); - }); - output.WriteLine($"{name}: |diff| / max(|v|, 1) at most {scaled:R} from this platform's libm ({RuntimeInformation.OSDescription}); fixture generated on {have["platform"]}"); - Assert.True(scaled <= ScaledPlatformBound, $"{name}: {scaled:R} max(|v|, 1) from this platform's result, more than 2^-20"); - break; - default: - Assert.True(JsonNode.DeepEquals(want, have), $"fixtures/glsl-parity.json family {name} is not C#'s current output (regenerate with CULTMATH_WRITE_GLSL=1)"); - break; - } - - if (want["check"] is not null) - output.WriteLine($"{name}: {Families[f].Verify!(want["cases"]!.AsArray())}"); - } - - committed.Remove("functions"); - current.Remove("functions"); - Assert.True(JsonNode.DeepEquals(current, committed), "fixtures/glsl-parity.json header is not the generator's (regenerate with CULTMATH_WRITE_GLSL=1)"); - } - - // The largest distance, component by component, between two families' results (committed first). - private static double MaxDistance(JsonArray committed, JsonArray current, Func distance) - { - var max = 0.0; - for (var c = 0; c < current.Count; c++) - { - var haveBits = ((string)committed[c]!).Split(" -> ")[1].Split(' ').Select(h => (int)Convert.ToUInt32(h, 16)).ToArray(); - var wantBits = ((string)current[c]!).Split(" -> ")[1].Split(' ').Select(h => (int)Convert.ToUInt32(h, 16)).ToArray(); - Assert.Equal(wantBits.Length, haveBits.Length); - max = Math.Max(max, haveBits.Zip(wantBits, distance).Max()); - } - - return max; - } - - // FrustumBall applied to C#'s own results: every case's ball encloses the exact one and is no wider - // than its rounding widening allows. - private static string AssertFrustumBall(JsonArray cases) - { - double low = double.PositiveInfinity, high = double.PositiveInfinity; - foreach (var entry in cases) - { - var sides = ((string)entry!).Split(" -> "); - var a = Floats(sides[0]); - var b = Floats(sides[1]); - double mx = a[0], my = a[1], z0 = a[2], z1 = a[3], footprint = a[4], warp = a[5]; - var zm = (z0 + z1) / 2.0; - var radius = (z1 - z0) / 2.0 * Math.Sqrt(mx * mx + my * my + 1.0) + z1 * footprint + warp; - double dx = b[0] - mx * zm, dy = b[1] - my * zm, dz = b[2] - zm; - var reach = radius + Math.Sqrt(dx * dx + dy * dy + dz * dz); - var c1 = Math.Abs(mx * zm) + Math.Abs(my * zm) + Math.Abs(zm); - Assert.True(b[3] >= reach, $"iv_frustum_ball case {entry}: radius short of the exact ball by {reach - b[3]}"); - Assert.True(b[3] <= reach + Math.ScaleB(radius + c1, -19), $"iv_frustum_ball case {entry}: radius past the exact ball by {b[3] - reach}, more than 2^-19 (r + |c|_1)"); - low = Math.Min(low, (b[3] - reach) / radius); - high = Math.Min(high, (reach + Math.ScaleB(radius + c1, -19) - b[3]) / Math.ScaleB(radius + c1, -19)); - } - return $"least slack: {low:E3} of r above the exact ball, {high:F3} of 2^-19 (r + |c|_1) below its widening"; - } - - private static readonly double[] CheckEps = { -1.0, -0.5, 0.0, 0.5, 1.0 }; - - // The origin, the six axis directions and the eight cube corners, normalised. - private static readonly (double X, double Y, double Z)[] CheckDirections = CheckDirectionList().ToArray(); - - private static IEnumerable<(double X, double Y, double Z)> CheckDirectionList() - { - yield return (0.0, 0.0, 0.0); - foreach (var s in new[] { -1.0, 1.0 }) - { - yield return (s, 0.0, 0.0); - yield return (0.0, s, 0.0); - yield return (0.0, 0.0, s); - } - - var corner = 1.0 / Math.Sqrt(3.0); - foreach (var sx in new[] { -corner, corner }) - foreach (var sy in new[] { -corner, corner }) - foreach (var sz in new[] { -corner, corner }) - yield return (sx, sy, sz); - } - - // SampledForm applied to C#'s own results, with C#'s own snoise or fBm as the reference value. A form - // must enclose its reference at every sample, and be no wider than the Lipschitz form's allowance. - // allowance is the part of e that is the float32 allowance; a family that allowanceDecides must have a - // sample that falls outside the form once it is removed, so the family can tell a device whose error - // passes the allowance from one that does not. - private static string AssertSampledForm(JsonArray cases, string name, Func reference, Func widthBound, - Func allowance, bool allowanceDecides) - { - double least = double.PositiveInfinity, leastRelative = double.PositiveInfinity, tightest = double.PositiveInfinity; - var decided = 0; - foreach (var entry in cases) - { - var sides = ((string)entry!).Split(" -> "); - var tokens = sides[0].Split(' '); - double[] a = Floats(string.Join(' ', tokens.Take(7))), form = Floats(sides[1]); - double x0 = form[0], slope = form[1], e = form[2]; - var withoutAllowance = e - allowance(tokens, a); - var allowanceNeeded = false; - foreach (var eps in CheckEps) - foreach (var d in CheckDirections) - { - var p = new float3((float)(a[0] + a[3] * eps + a[6] * d.X), (float)(a[1] + a[4] * eps + a[6] * d.Y), (float)(a[2] + a[5] * eps + a[6] * d.Z)); - double value = reference(tokens, p), middle = x0 + slope * eps; - var inside = Math.Min(value - (middle - e), middle + e - value); - Assert.True(inside >= 0.0, $"{name} case {entry}: the reference {value:R} at eps {eps} and direction {d} is outside the form's range [{middle - e:R}, {middle + e:R}] by {-inside:R}"); - least = Math.Min(least, inside); - leastRelative = Math.Min(leastRelative, inside / e); - allowanceNeeded |= Math.Abs(value - middle) > withoutAllowance; - } - - if (allowanceNeeded) - decided++; - - var bound = widthBound(tokens, a); - Assert.True(Math.Abs(slope) + e <= bound + Math.ScaleB(1.0 + bound, -16), $"{name} case {entry}: the width {Math.Abs(slope) + e:R} is past B + 2^-16 (1 + B) = {bound + Math.ScaleB(1.0 + bound, -16):R}"); - tightest = Math.Min(tightest, (bound + Math.ScaleB(1.0 + bound, -16) - Math.Abs(slope) - e) / bound); - } - - Assert.True(!allowanceDecides || decided > 0, $"{name}: no sample falls outside the form once the float32 allowance is removed, so the family cannot fail a device whose error passes it"); - return $"least enclosure slack {least:E3} ({leastRelative:E3} of e), least tightness slack {tightest:E3} of B, {decided} of {cases.Count} cases need the allowance"; - } - - // The float32 allowance of one octave of af_snoise: 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R). - private static double SnoiseAllowance(double centre1, double reach) => - Math.ScaleB(1.0, -14) + Math.ScaleB(reach, -12) + math.SNOISE_LIPSCHITZ * Math.ScaleB(centre1 + reach, -20); - - // The Lipschitz form's width bound for one octave of the sampled-form check. - private static double SnoiseWidthBound(double centre1, double reach) => math.SNOISE_LIPSCHITZ * reach + SnoiseAllowance(centre1, reach); - - private static double Length3(double[] a, int first) => Math.Sqrt(a[first] * a[first] + a[first + 1] * a[first + 1] + a[first + 2] * a[first + 2]); - - private static double SnoiseOctave(Func octave, double[] a, double frequency) => - octave((Math.Abs(a[0]) + Math.Abs(a[1]) + Math.Abs(a[2])) * frequency, (Length3(a, 3) + a[6]) * frequency); - - // The amplitude-weighted sum of a per-octave quantity over the fBm's octaves. - private static double FbmOctaves(string[] t, double[] a, Func octave) - { - var (octaves, lacunarity, gain) = ((int)Convert.ToUInt32(t[7], 16), Floats(t[8])[0], Floats(t[9])[0]); - double sum = 0.0, amplitude = 1.0, frequency = 1.0; - for (var i = 0; i < Math.Clamp(octaves, 0, 16); i++) - { - sum += amplitude * SnoiseOctave(octave, a, frequency); - amplitude *= gain; - frequency *= lacunarity; - } - - return sum; - } - - private static string AssertSnoiseForm(JsonArray cases, bool allowanceDecides = false) => - AssertSampledForm(cases, "af_snoise", (_, p) => math.snoise(p), - (_, a) => SnoiseOctave(SnoiseWidthBound, a, 1.0), (_, a) => SnoiseOctave(SnoiseAllowance, a, 1.0), allowanceDecides); - - private static string AssertFbmForm(JsonArray cases, bool allowanceDecides = false) => - AssertSampledForm(cases, "af_fbm", - (t, p) => math.fbm_grad(p, (int)Convert.ToUInt32(t[7], 16), (float)Floats(t[8])[0], (float)Floats(t[9])[0]).w, - (t, a) => FbmOctaves(t, a, SnoiseWidthBound), (t, a) => FbmOctaves(t, a, SnoiseAllowance), allowanceDecides); - - // AffineFrustumBall applied to C#'s own results. - private static string AssertAffineFrustumBall(JsonArray cases) - { - double enclosure = double.PositiveInfinity, lower = double.PositiveInfinity, upper = double.PositiveInfinity; - var diagonal = new[] { (0.0, 0.0), (1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0), (Math.Sqrt(0.5), Math.Sqrt(0.5)), (Math.Sqrt(0.5), -Math.Sqrt(0.5)), (-Math.Sqrt(0.5), Math.Sqrt(0.5)), (-Math.Sqrt(0.5), -Math.Sqrt(0.5)) }; - foreach (var entry in cases) - { - var sides = ((string)entry!).Split(" -> "); - var a = Floats(sides[0]); - var b = Floats(sides[1]); - double mx = a[0], my = a[1], z0 = a[2], z1 = a[3], fp = a[4], warp = a[5]; - double zm = (z0 + z1) / 2.0, h = (z1 - z0) / 2.0; - var r0 = z1 * fp + warp; - var c1 = Math.Abs(mx * zm) + Math.Abs(my * zm) + Math.Abs(zm); - var spread = (Math.Abs(mx) + Math.Abs(my) + 1.0) * h; - double dx = b[0] - mx * zm, dy = b[1] - my * zm, dz = b[2] - zm; - var d = Math.Sqrt(dx * dx + dy * dy + dz * dz); - foreach (var z in new[] { z0, (3.0 * z0 + z1) / 4.0, zm, (z0 + 3.0 * z1) / 4.0, z1 }) - { - var eps = h > 0.0 ? Math.Clamp((z - zm) / h, -1.0, 1.0) : 0.0; - foreach (var (ex, ey) in diagonal) - { - double px = (mx + fp * ex) * z - (b[0] + mx * h * eps), py = (my + fp * ey) * z - (b[1] + my * h * eps), pz = z - (b[2] + h * eps); - var slack = b[3] - (Math.Sqrt(px * px + py * py + pz * pz) + warp); - Assert.True(slack >= 0.0, $"af_frustum_ball case {entry}: the ray point at depth {z:R} and offset ({ex}, {ey}) is outside the ball by {-slack:R}"); - enclosure = Math.Min(enclosure, slack / b[3]); - } - } - - Assert.True(b[3] >= r0 + d, $"af_frustum_ball case {entry}: radius short of R0 + d by {r0 + d - b[3]}"); - Assert.True(b[3] <= r0 + d + Math.ScaleB(r0 + c1 + spread, -19), $"af_frustum_ball case {entry}: radius past R0 + d by {b[3] - r0 - d}, more than 2^-19 (R0 + |c0|_1 + spread)"); - lower = Math.Min(lower, (b[3] - r0 - d) / r0); - upper = Math.Min(upper, (r0 + d + Math.ScaleB(r0 + c1 + spread, -19) - b[3]) / Math.ScaleB(r0 + c1 + spread, -19)); - } - - return $"least enclosure slack {enclosure:E3} of the radius, least slack above R0 + d {lower:E3} of R0, below its widening {upper:F3} of 2^-19 (R0 + |c0|_1 + spread)"; - } - - // A committed case's arguments, decoded into the C# method's parameter types in Hex's field order. - private static object[] Arguments(MethodInfo method, string hex) - { - var scalars = new Queue(hex.Split(' ').Select(h => Convert.ToUInt32(h, 16))); - var arguments = method.GetParameters().Select(parameter => FromScalars(parameter.ParameterType, scalars)).ToArray(); - Assert.Empty(scalars); - return arguments; - } - - private static object FromScalars(Type type, Queue scalars) - { - if (type == typeof(float)) - return BitConverter.Int32BitsToSingle((int)scalars.Dequeue()); - if (type == typeof(int)) - return (int)scalars.Dequeue(); - if (type == typeof(uint)) - return scalars.Dequeue(); - var value = Activator.CreateInstance(type)!; - foreach (var field in type.GetFields().Where(f => !f.IsStatic)) - field.SetValue(value, FromScalars(field.FieldType, scalars)); - return value; - } - - private static double[] Floats(string hex) => - hex.Split(' ').Select(h => (double)BitConverter.Int32BitsToSingle((int)Convert.ToUInt32(h, 16))).ToArray(); - - // A float32 bit pattern as an integer whose order and differences are the floats' order and ulps. - private static int Ordered(int bits) => bits < 0 ? int.MinValue - bits : bits; - - // ---- The golden fixture ---- - - private const int Seed = 20261002; - private const int Points = 256; - - // How GoldenFixtureMatchesCSharp compares a family whose C# bits come from the platform's libm (exp, - // sin, cos) and so differ by OS; such an entry records the platform that generated it. Every other - // family is compared as text. - private enum Platform { None, Ulp, Scaled } - - // Platform.Scaled: |diff| <= 2^-20 max(|v|, 1) per component. Ulps mean nothing near zero, where - // phacelle's sums of exp, sin and cos cancel; Windows differs from Linux by up to 3.6e-7 of it. - private const double ScaledPlatformBound = 9.5367431640625e-7; - - private sealed record Family(string Glsl, string Tolerance, Func Arguments, string? Check = null, Platform Platform = Platform.None, Func? Verify = null); - - private static float Uniform(System.Random r, float lo, float hi) => lo + (hi - lo) * r.NextSingle(); - private static float3 Point3(System.Random r) => new(Uniform(r, -50.0f, 50.0f), Uniform(r, -50.0f, 50.0f), Uniform(r, -50.0f, 50.0f)); - - // A point on the simplex tie set, where snoise's x0 has equal components (NoiseGradTests.SnoiseIsContinuousOnTheSimplexDiagonal): - // seven of eight draws lie on a lattice diagonal v + s (1, 1, 1), v = L - sum(L) / 6 for an integer L, and one of eight on - // the line (t, t, t). A device that runs a different tie rule reads a different function here. - private static float3 TiePoint3(System.Random r) - { - if (r.Next(8) == 0) - { - var t = Uniform(r, -50.0f, 50.0f); - return new float3(t, t, t); - } - - var lx = r.Next(-64, 65); - var ly = r.Next(-64, 65); - var lz = r.Next(-64, 65); - var shift = (lx + ly + lz) / 6.0f; - var s = r.NextSingle(); - return new float3(lx - shift + s, ly - shift + s, lz - shift + s); - } - private static int Bits(System.Random r) => r.Next(int.MinValue, int.MaxValue); - - private static float2 Interval(System.Random r) - { - var centre = Uniform(r, -20.0f, 20.0f); - var width = MathF.Pow(10.0f, Uniform(r, -4.0f, 1.0f)); - return new float2(centre - width * 0.5f, centre + width * 0.5f); - } - - // iv_frustum_ball's sqrt is not correctly rounded on WebGL2 and its compilers may reassociate, so its - // bits are not portable; what the march needs is enclosure, and what culling needs is a ball no wider - // than its rounding widening. The consumer checks both in double from each case's arguments. It is - // written into the family's fixture entry, where the consumer reads it. - private const string FrustumBall = - "enclosure and tightness: from the arguments (mx, my, z0, z1, fp, warp) compute in double zm = (z0 + z1) / 2, " + - "c = (mx zm, my zm, zm), |c|_1 = |mx zm| + |my zm| + |zm|, r = (z1 - z0) / 2 sqrt(mx^2 + my^2 + 1) + z1 fp + warp " + - "and d = |GPU centre - c| (Euclidean); every case must have r + d <= GPU radius <= r + d + 2^-19 (r + |c|_1). " + - "Report the largest ulp distance per component as for any ulp-bounded family; only the two bounds fail the check."; - - // An affine form (x0, a, e): e >= 0, spanning the widths a probe's forms take. - private static float3 Form(System.Random r) => new(Uniform(r, -20.0f, 20.0f), Uniform(r, -5.0f, 5.0f), MathF.Pow(10.0f, Uniform(r, -4.0f, 1.0f))); - - // A slice's axis and radius in noise space, log-uniform from 1e-3 to 0.5: below about 0.15 the - // centred form of af_snoise wins, above it the Lipschitz form does, so both are drawn. - private static float3 Axis3(System.Random r) - { - var scale = MathF.Pow(10.0f, Uniform(r, -3.0f, -0.3f)); - return new float3(Uniform(r, -1.0f, 1.0f) * scale, Uniform(r, -1.0f, 1.0f) * scale, Uniform(r, -1.0f, 1.0f) * scale); - } - - private static float BallRadius(System.Random r) => MathF.Pow(10.0f, Uniform(r, -3.0f, -0.3f)); - - // A slice of reach 1e-6 to 1e-3, the short slices and small footprints near a camera, where the float32 - // allowance is most of the form's width: the centre in [-50, 50] or [-1, 1], an axis of random direction - // (zero in one case of four) and a radius, each log-uniform in 1e-6 to 1e-3. - private static object[] SmallReachSlice(System.Random r) - { - var span = r.Next(2) == 0 ? 50.0f : 1.0f; - var centre = new float3(Uniform(r, -span, span), Uniform(r, -span, span), Uniform(r, -span, span)); - var axis = new float3(0.0f, 0.0f, 0.0f); - if (r.Next(4) != 0) - { - var direction = math.normalize(new float3(Uniform(r, -1.0f, 1.0f), Uniform(r, -1.0f, 1.0f), Uniform(r, -1.0f, 1.0f))); - axis = direction * MathF.Pow(10.0f, Uniform(r, -6.0f, -3.0f)); - } - - return new object[] { centre, axis, MathF.Pow(10.0f, Uniform(r, -6.0f, -3.0f)) }; - } - - private const string SampledForm = - "the arguments are (cx, cy, cz, ax, ay, az, radius, ...) and the result is the form (x0, a, e). Enclosure: for eps in " + - "{-1, -0.5, 0, 0.5, 1} and d in {0, +-ex, +-ey, +-ez, (+-1, +-1, +-1) / sqrt(3)} (15 directions), form the point " + - "p = c + axis eps + radius d in double and round it to float32; the device's own reference value at p must lie in " + - "[x0 + a eps - e, x0 + a eps + e] with no tolerance, so a device whose gradient error exceeds the allowance fails. " + - "Tightness: with L = 7.9640074 and, for each octave (one for af_snoise), R = |axis| + radius, " + - "B = L R + 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R), the width |a| + e must be at most B + 2^-16 (1 + B). " + - "Report the least slack of each side, absolutely and as a fraction of e; only the two bounds fail the check. "; - - private const string SnoiseForm = SampledForm + "The reference value is cultmath_snoise(p)."; - - private const string FbmForm = SampledForm + - "The reference value is cultmath_fbm_grad(p, octaves, lacunarity, gain).w, and B is the sum over octaves i of gain^i B_i, " + - "where B_i is B for the centre lacunarity^i c, the axis lacunarity^i axis and the radius lacunarity^i radius."; - - // The two small-reach families add the centre leg to every af_snoise and af_fbm family. The device's - // reference value is its own noise, so a device whose noise is wrong everywhere encloses its own wrong - // values; C#'s value at the centre, the form's own x0 in the fixture, is the independent reading. - private const string CentreLeg = - " Centre leg, for every cultmath_af_snoise and cultmath_af_fbm family of this fixture, the earlier ones included: " + - "the fixture's own x0 in the result (C#'s value at the centre) must lie in [x0 - e, x0 + e] of the GPU's form, with " + - "no tolerance, so a device whose noise differs from C#'s by more than its e fails."; - - private const string SmallReach = - " These cases have reach |axis| + radius of 1e-6 to 1e-3, where the float32 allowance is most of e and the second order " + - "remainder is not; the enclosure above fails a device whose gradient error exceeds the allowance."; - - private const string SnoiseSmallForm = SnoiseForm + SmallReach + CentreLeg; - - private const string FbmSmallForm = FbmForm + SmallReach + CentreLeg; - - private const string AffineFrustumBall = - "enclosure and tightness: from the arguments (mx, my, z0, z1, fp, warpVariation) compute in double zm = (z0 + z1) / 2, " + - "h = (z1 - z0) / 2, axis = (mx h, my h, h), c0 = (mx zm, my zm, zm), |c0|_1 = |mx zm| + |my zm| + |zm|, R0 = z1 fp + warpVariation, " + - "spread = (|mx| + |my| + 1) h and d = |GPU centre - c0|. Enclosure: for z in {z0, (3 z0 + z1) / 4, zm, (z0 + 3 z1) / 4, z1}, " + - "eps = clamp((z - zm) / h, -1, 1) and the nine footprint offsets e in {(0, 0), (+-1, 0), (0, +-1), (+-1, +-1) / sqrt(2)}, " + - "the point P = ((mx + fp e.x) z, (my + fp e.y) z, z) satisfies |P - (GPU centre + axis eps)| + warpVariation <= GPU radius. " + - "Tightness: R0 + d <= GPU radius <= R0 + d + 2^-19 (R0 + |c0|_1 + spread). " + - "Report the least slack of each side; only the bounds fail the check."; - - // A Phacelle stripe wave vector: each component in [-6, 6], about one stripe per cell. - private static float3 Side(System.Random r) => new(Uniform(r, -6.0f, 6.0f), Uniform(r, -6.0f, 6.0f), Uniform(r, -6.0f, 6.0f)); - - // Every family the site's WebGL2 readback evaluates, in a fixed order. A new family is appended, so the - // seeded stream and every earlier family's cases stay as they were. pcg3d and pcg4d are "exact"; the - // float families are ulp-bounded, with the bound measured on the device by the consumer, and - // iv_frustum_ball also carries an enclosure check. phacelle is in CultMath.Phacelle.glsl, so its - // evaluator concatenates that file after CultMath.glsl; the site, which does not vendor it, skips it. - private static readonly Family[] Families = - { - new("float cultmath_snoise(vec3)", "ulp-bounded", r => new object[] { Point3(r) }), - new("float cultmath_snoise(vec2)", "ulp-bounded", r => new object[] { new float2(Uniform(r, -50.0f, 50.0f), Uniform(r, -50.0f, 50.0f)) }), - new("vec4 cultmath_snoise_grad(vec3)", "ulp-bounded", r => new object[] { Point3(r) }), - new("vec4 cultmath_fbm_grad(vec3, int, float, float)", "ulp-bounded", r => new object[] { Point3(r), 4, 2.0f, 0.5f }), - new("vec4 cultmath_ridged_grad(vec3, int, float, float)", "ulp-bounded", r => new object[] { Point3(r), 4, 2.0f, 0.5f }), - new("CultCellular cultmath_cellular(vec3)", "ulp-bounded", r => new object[] { Point3(r) }), - new("ivec3 cultmath_pcg3d(ivec3)", "exact", r => new object[] { new int3(Bits(r), Bits(r), Bits(r)) }), - new("ivec4 cultmath_pcg4d(ivec4)", "exact", r => new object[] { new int4(Bits(r), Bits(r), Bits(r), Bits(r)) }), - new("vec2 cultmath_iv_point(float)", "ulp-bounded", r => new object[] { Uniform(r, -20.0f, 20.0f) }), - new("vec2 cultmath_iv_add(vec2, vec2)", "ulp-bounded", r => new object[] { Interval(r), Interval(r) }), - new("vec2 cultmath_iv_sub(vec2, vec2)", "ulp-bounded", r => new object[] { Interval(r), Interval(r) }), - new("vec2 cultmath_iv_neg(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_iv_mul(vec2, vec2)", "ulp-bounded", r => new object[] { Interval(r), Interval(r) }), - new("vec2 cultmath_iv_scale(vec2, float)", "ulp-bounded", r => new object[] { Interval(r), Uniform(r, -4.0f, 4.0f) }), - new("vec2 cultmath_iv_abs(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_iv_min(vec2, vec2)", "ulp-bounded", r => new object[] { Interval(r), Interval(r) }), - new("vec2 cultmath_iv_max(vec2, vec2)", "ulp-bounded", r => new object[] { Interval(r), Interval(r) }), - new("vec2 cultmath_iv_sqr(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_iv_sqrt(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_iv_clamp(vec2, float, float)", "ulp-bounded", r => new object[] { Interval(r), Uniform(r, -25.0f, 0.0f), Uniform(r, 0.0f, 25.0f) }), - new("vec2 cultmath_iv_saturate(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_iv_smoothstep(float, float, vec2)", "ulp-bounded", r => new object[] { Uniform(r, -25.0f, 0.0f), Uniform(r, 0.0f, 25.0f), Interval(r) }), - new("vec2 cultmath_iv_lerp(vec2, vec2, float)", "ulp-bounded", r => new object[] { Interval(r), Interval(r), Uniform(r, 0.0f, 1.0f) }), - new("vec2 cultmath_iv_snoise_ball(vec3, float)", "ulp-bounded", r => new object[] { Point3(r), Uniform(r, 0.001f, 2.0f) }), - new("vec2 cultmath_iv_fbm_ball(vec3, float, int, float, float)", "ulp-bounded", r => new object[] { Point3(r), Uniform(r, 0.001f, 2.0f), 4, 2.0f, 0.5f }), - new("vec4 cultmath_iv_frustum_ball(vec2, float, float, float, float)", "ulp-bounded", r => - { - var slope = new float2(Uniform(r, -1.0f, 1.0f), Uniform(r, -1.0f, 1.0f)); - var z0 = Uniform(r, 0.1f, 100.0f); - return new object[] { slope, z0, z0 + Uniform(r, 0.01f, 50.0f), Uniform(r, 0.0001f, 0.05f), Uniform(r, 0.0f, 2.0f) }; - }, FrustumBall, Verify: AssertFrustumBall), - new("vec2 cultmath_iv_exp(vec2)", "ulp-bounded, platform exp", r => new object[] { Interval(r) }, Platform: Platform.Ulp), - new("CultPhasor cultmath_phacelle(vec3, vec3, float, float)", "ulp-bounded, platform exp, sin, cos; across platforms |diff| <= 2^-20 max(|v|, 1)", - r => new object[] { Point3(r), Side(r), Uniform(r, 0.0f, 1.0f), 0.5f }, Platform: Platform.Scaled), - new("float cultmath_snoise(vec3)", "ulp-bounded, on the simplex tie set", r => new object[] { TiePoint3(r) }), - new("vec4 cultmath_snoise_grad(vec3)", "ulp-bounded, on the simplex tie set", r => new object[] { TiePoint3(r) }), - new("vec3 cultmath_af_point(float)", "ulp-bounded", r => new object[] { Uniform(r, -20.0f, 20.0f) }), - new("vec3 cultmath_af_symbol(float, float)", "ulp-bounded", r => new object[] { Uniform(r, -20.0f, 20.0f), Uniform(r, -5.0f, 5.0f) }), - new("vec3 cultmath_af_from_iv(vec2)", "ulp-bounded", r => new object[] { Interval(r) }), - new("vec2 cultmath_af_range(vec3)", "ulp-bounded", r => new object[] { Form(r) }), - new("vec3 cultmath_af_add(vec3, vec3)", "ulp-bounded", r => new object[] { Form(r), Form(r) }), - new("vec3 cultmath_af_sub(vec3, vec3)", "ulp-bounded", r => new object[] { Form(r), Form(r) }), - new("vec3 cultmath_af_neg(vec3)", "ulp-bounded", r => new object[] { Form(r) }), - new("vec3 cultmath_af_scale(vec3, float)", "ulp-bounded", r => new object[] { Form(r), Uniform(r, -4.0f, 4.0f) }), - new("vec3 cultmath_af_add_iv(vec3, vec2)", "ulp-bounded", r => new object[] { Form(r), Interval(r) }), - new("vec3 cultmath_af_mul(vec3, vec3)", "ulp-bounded", r => new object[] { Form(r), Form(r) }), - new("vec3 cultmath_af_snoise(vec3, vec3, float)", "ulp-bounded", r => new object[] { Point3(r), Axis3(r), BallRadius(r) }, SnoiseForm, Verify: cases => AssertSnoiseForm(cases)), - new("vec3 cultmath_af_fbm(vec3, vec3, float, int, float, float)", "ulp-bounded", r => new object[] { Point3(r), Axis3(r), BallRadius(r), 4, 2.0f, 0.5f }, FbmForm, Verify: cases => AssertFbmForm(cases)), - new("vec3 cultmath_af_frustum_axis(vec2, float, float)", "ulp-bounded", r => - { - var z0 = Uniform(r, 0.1f, 100.0f); - return new object[] { new float2(Uniform(r, -1.0f, 1.0f), Uniform(r, -1.0f, 1.0f)), z0, z0 + Uniform(r, 0.01f, 50.0f) }; - }), - new("vec4 cultmath_af_frustum_ball(vec2, float, float, float, float)", "ulp-bounded", r => - { - var slope = new float2(Uniform(r, -1.0f, 1.0f), Uniform(r, -1.0f, 1.0f)); - var z0 = Uniform(r, 0.1f, 100.0f); - return new object[] { slope, z0, z0 + Uniform(r, 0.01f, 50.0f), Uniform(r, 0.0001f, 0.05f), Uniform(r, 0.0f, 2.0f) }; - }, AffineFrustumBall, Verify: AssertAffineFrustumBall), - new("vec2 cultmath_iv_snoise_ball(vec2, float)", "ulp-bounded", r => new object[] { new float2(Uniform(r, -50.0f, 50.0f), Uniform(r, -50.0f, 50.0f)), Uniform(r, 0.001f, 2.0f) }), - new("vec3 cultmath_af_snoise(vec3, vec3, float)", "ulp-bounded, reach 1e-6 to 1e-3", SmallReachSlice, SnoiseSmallForm, Verify: cases => AssertSnoiseForm(cases, allowanceDecides: true)), - new("vec3 cultmath_af_fbm(vec3, vec3, float, int, float, float)", "ulp-bounded, reach 1e-6 to 1e-3", r => SmallReachSlice(r).Concat(new object[] { 4, 2.0f, 0.5f }).ToArray(), FbmSmallForm, Verify: cases => AssertFbmForm(cases, allowanceDecides: true)), - }; - - // The fixture text, each case's arguments given by family and point index. - private static string GoldenFixture(Func arguments) - { - var json = new StringBuilder(); - json.Append("{\n"); - json.Append(" \"generator\": \"GlslMirrorTests.GoldenFixtureMatchesCSharp (packages/cultmath/tests/CultMath.Tests); regenerate with CULTMATH_WRITE_GLSL=1\",\n"); - json.Append($" \"seed\": {Seed},\n"); - json.Append($" \"points\": {Points},\n"); - json.Append(" \"encoding\": \"each case is 'arguments -> result', every scalar a float32 or 32-bit integer bit pattern in hex, vectors and structs flattened in field order\",\n"); - json.Append(" \"functions\": [\n"); - for (var f = 0; f < Families.Length; f++) - { - var family = Families[f]; - var method = Resolve(family.Glsl); - json.Append(" {\n"); - json.Append($" \"glsl\": \"{family.Glsl}\",\n"); - json.Append($" \"tolerance\": \"{family.Tolerance}\",\n"); - if (family.Check is not null) - json.Append($" \"check\": \"{family.Check}\",\n"); - if (family.Platform != Platform.None) - json.Append($" \"platform\": \"{RuntimeInformation.OSDescription}; {RuntimeInformation.FrameworkDescription}\",\n"); - json.Append(" \"cases\": [\n"); - for (var p = 0; p < Points; p++) - { - var values = arguments(f, p); - var result = method.Invoke(null, values)!; - json.Append(" \"").Append(Hex(values)).Append(" -> ").Append(Hex(new[] { result })).Append('"'); - json.Append(p + 1 < Points ? ",\n" : "\n"); - } - - json.Append(" ]\n"); - json.Append(f + 1 < Families.Length ? " },\n" : " }\n"); - } - - json.Append(" ]\n}\n"); - return json.ToString(); - } - - private static readonly Dictionary GlslTypes = new() - { - ["float"] = typeof(float), ["int"] = typeof(int), ["vec2"] = typeof(float2), ["vec3"] = typeof(float3), - ["vec4"] = typeof(float4), ["ivec3"] = typeof(int3), ["ivec4"] = typeof(int4), - }; - - // The C# math method a GLSL signature names: cultmath_ dropped, parameter types mapped. - private static MethodInfo Resolve(string glsl) - { - var match = Regex.Match(glsl, @"^\w+ cultmath_(\w+)\(([^)]*)\)$"); - var types = match.Groups[2].Value.Split(", ").Select(t => GlslTypes[t]).ToArray(); - return typeof(math).GetMethod(match.Groups[1].Value, BindingFlags.Public | BindingFlags.Static, null, types, null) - ?? throw new InvalidOperationException("no C# math counterpart for " + glsl); - } - - private static string Hex(IEnumerable values) => string.Join(" ", values.SelectMany(Scalars).Select(v => v switch - { - float f => BitConverter.SingleToInt32Bits(f).ToString("x8"), - int i => i.ToString("x8"), - uint u => u.ToString("x8"), - _ => throw new InvalidOperationException(v.GetType().Name), - })); - - private static IEnumerable Scalars(object value) => value is float or int or uint - ? new[] { value } - : value.GetType().GetFields().Where(f => !f.IsStatic).SelectMany(f => Scalars(f.GetValue(value)!)); - - // ---- A small unified diff for the failure message ---- - - private static string UnifiedDiff(string before, string after) - { - var a = before.Split('\n'); - var b = after.Split('\n'); - if ((long)a.Length * b.Length > 4_000_000) - { - var first = Enumerable.Range(0, Math.Min(a.Length, b.Length)).FirstOrDefault(i => a[i] != b[i], Math.Min(a.Length, b.Length)); - return $"@@ first difference at line {first + 1} @@\n-{(first < a.Length ? a[first] : "")}\n+{(first < b.Length ? b[first] : "")}"; - } - - var lcs = new int[a.Length + 1, b.Length + 1]; - for (var i = a.Length - 1; i >= 0; i--) - for (var j = b.Length - 1; j >= 0; j--) - lcs[i, j] = a[i] == b[j] ? lcs[i + 1, j + 1] + 1 : Math.Max(lcs[i + 1, j], lcs[i, j + 1]); - - var lines = new List { "--- committed", "+++ lowering" }; - int x = 0, y = 0; - while (x < a.Length || y < b.Length) - { - if (x < a.Length && y < b.Length && a[x] == b[y]) { x++; y++; continue; } - lines.Add($"@@ -{x + 1} +{y + 1} @@"); - while (x < a.Length && (y >= b.Length || lcs[x + 1, y] >= lcs[x, y + 1]) && !(y < b.Length && a[x] == b[y])) - lines.Add("-" + a[x++]); - while (y < b.Length && (x >= a.Length || a[x] != b[y])) - lines.Add("+" + b[y++]); - if (lines.Count > 200) - break; - } - - return string.Join("\n", lines.Take(200)); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/HlslMirrorTests.cs b/packages/cultmath/tests/CultMath.Tests/HlslMirrorTests.cs index 00a2e90a..445ad255 100644 --- a/packages/cultmath/tests/CultMath.Tests/HlslMirrorTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/HlslMirrorTests.cs @@ -7,7 +7,7 @@ public sealed class HlslMirrorTests [Fact] public void HlslMirrorDoesNotPublishGeometryKernels() { - var source = HlslSourceCompatibilityTests.ReadShaderSource(GetCultMathRoot()); + var source = File.ReadAllText(Path.Combine(GetCultMathRoot(), "shaders", "CultMath.hlsl")); Assert.DoesNotContain("AdvancedErosionFilter.hlsl", source); Assert.DoesNotContain("Planetary.hlsl", source); Assert.DoesNotContain("spherical_erosion", source); @@ -17,7 +17,7 @@ public sealed class HlslMirrorTests [Fact] public void HlslMirrorPublishesCultMathPrimitives() { - var include = HlslSourceCompatibilityTests.ReadShaderSource(GetCultMathRoot()); + var include = File.ReadAllText(Path.Combine(GetCultMathRoot(), "shaders", "CultMath.hlsl")); var requiredSymbols = new[] { "cultmath_radians", @@ -31,6 +31,7 @@ public sealed class HlslMirrorTests "cultmath_smootherstep", "cultmath_lengthsq", "cultmath_distance", + "cultmath_normalize", "cultmath_reflect", "cultmath_rotate", "cultmath_csum", @@ -40,17 +41,12 @@ public sealed class HlslMirrorTests "cultmath_quadratic_bezier", "cultmath_cubic_bezier", "cultmath_hash", - "cultmath_pcg(uint", - "cultmath_pcg3d(int3", - "cultmath_pcg4d(int4", "cultmath_value_noise", "cultmath_snoise(float2", "cultmath_snoise(float3", "cultmath_value_noise_bicubic", "cultmath_value_noise_texture", "cultmath_value_noise_texture_bicubic", - "cultmath_smin_grad", - "cultmath_cellular", }; foreach (var symbol in requiredSymbols) @@ -58,21 +54,8 @@ public sealed class HlslMirrorTests Assert.Contains(symbol, include); } - // HLSL's normalize intrinsic is the contract; a mirror copy would only restate it. - Assert.DoesNotContain("cultmath_normalize", include); - } - - [Theory] - [InlineData("CultMath.hlsl")] - [InlineData("CultMath.Phacelle.hlsl")] - [InlineData("CultMath.Interval.hlsl")] - [InlineData("CultMath.Affine.hlsl")] - public void UnityPackageShaderIsIdenticalToTheCanonicalShader(string name) - { - var root = GetCultMathRoot(); - Assert.Equal( - File.ReadAllText(Path.Combine(root, "shaders", name)).ReplaceLineEndings("\n"), - File.ReadAllText(Path.Combine(root, "unity", "org.gamecult.cultmath", "Shaders", name)).ReplaceLineEndings("\n")); + Assert.Contains("CULTMATH_NORMALIZE_EPSILON", include); + Assert.Contains("max(length(value), CULTMATH_NORMALIZE_EPSILON)", include); } private static string GetCultMathRoot() diff --git a/packages/cultmath/tests/CultMath.Tests/HlslSemanticsTests.cs b/packages/cultmath/tests/CultMath.Tests/HlslSemanticsTests.cs index 27a79234..7b845ea7 100644 --- a/packages/cultmath/tests/CultMath.Tests/HlslSemanticsTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/HlslSemanticsTests.cs @@ -187,33 +187,6 @@ public sealed class HlslSemanticsTests Assert.Equal(DoubleBits(-0.0), DoubleBits(math.max(-0.0, 0.0))); Assert.Equal(DoubleBits(0.0), DoubleBits(math.min(-0.0, 0.0))); - // dxc: normalize(x) is x * Rsqrt(Dot(x, x)); length and distance are Sqrt of the summed squares. - static bool AllNaN(float4 value) => - float.IsNaN(value.x) && float.IsNaN(value.y) && float.IsNaN(value.z) && float.IsNaN(value.w); - var n2 = math.normalize(float2.zero); - Assert.True(float.IsNaN(n2.x) && float.IsNaN(n2.y)); - var n3 = math.normalize(float3.zero); - Assert.True(float.IsNaN(n3.x) && float.IsNaN(n3.y) && float.IsNaN(n3.z)); - Assert.True(AllNaN(math.normalize(float4.zero))); - var nanX = math.normalize(new float2(float.NaN, 2.41f)); - Assert.True(float.IsNaN(nanX.x) && float.IsNaN(nanX.y)); - Assert.True(AllNaN(math.normalize(new float4(1.0f, float.NaN, 2.41f, 1.0f)))); - var skew = new float3(0.25f, 1.0f, -0.1f); - var inverseLength = 1.0f / MathF.Sqrt(skew.x * skew.x + skew.y * skew.y + skew.z * skew.z); - var normalized = math.normalize(skew); - Assert.Equal(Bits(skew.x * inverseLength), Bits(normalized.x)); - Assert.Equal(Bits(skew.y * inverseLength), Bits(normalized.y)); - Assert.Equal(Bits(skew.z * inverseLength), Bits(normalized.z)); - Assert.Equal(Bits(0.0f), Bits(math.length(float2.zero))); - Assert.Equal(Bits(0.0f), Bits(math.length(float3.zero))); - Assert.Equal(Bits(0.0f), Bits(math.length(float4.zero))); - Assert.Equal(Bits(0.0f), Bits(math.distance(new float3(1.0f, 2.0f, 3.0f), new float3(1.0f, 2.0f, 3.0f)))); - - // asuint(float) reinterprets the IEEE-754 bits. - Assert.Equal(0x80000000u, math.asuint(-0.0f)); - Assert.Equal(0x3FC00000u, math.asuint(1.5f)); - Assert.Equal(0x7FC00000u, math.asuint(BitConverter.Int32BitsToSingle(0x7FC00000))); - Assert.Equal(0, math.sign(float.NaN)); Assert.Equal(-1, math.sign(-0.5f)); Assert.Equal(new int3(-1, 0, 1), math.sign(new float3(-2.0f, 0.0f, 4.0f))); @@ -338,43 +311,6 @@ public sealed class HlslSemanticsTests Assert.Equal(new int4(5, 5, 5, 5), math.int4(5)); } - [Fact] - public void VectorConversionsFollowDxc() - { - // fptosi truncates toward zero; NaN and out-of-range inputs are undefined in DXIL and not pinned. - Assert.Equal(new int2(-1, 2), math.int2(new float2(-1.7f, 2.9f))); - Assert.Equal(new int3(0, 0, 3), new int3(new float3(-0.5f, 0.5f, 3.99f))); - Assert.Equal(new float4(1.0f, -2.0f, 3.0f, 0.0f), math.float4(new int4(1, -2, 3, 0))); - // Numeric to bool is `!= 0` (fcmp une for float, so NaN is true); bool to numeric is 0 or 1. - Assert.Equal(new bool2(true, false), math.bool2(new float2(float.NaN, -0.0f))); - Assert.Equal(new bool3(false, true, true), math.bool3(new int3(0, 5, -1))); - Assert.Equal(new float2(1.0f, 0.0f), math.float2(new bool2(true, false))); - Assert.Equal(new int4(0, 1, 1, 0), math.int4(new bool4(false, true, true, false))); - // intN(intN) is exact; it must not promote through float and lose 2^24 + 1. - Assert.Equal(new int2(16777217, -16777217), math.int2(new int2(16777217, -16777217))); - float2 splat = math.float2(0); - Assert.Equal(float2.zero, splat); - } - - [Fact] - public void FracAndIntegerClampFollowHlsl() - { - // frac(double) keeps double precision; a float frac of 1e9 + 0.25 would return 0. - Assert.Equal(0.25, math.frac(1.0e9 + 0.25)); - Assert.Equal(0.75, math.frac(-0.25)); - Assert.Equal(0.5f, math.frac(2.5f)); - - // IMin(IMax(x, a), b): the result stays int, and inverted bounds return b. - int clamped = math.clamp(7, -1, 3); - Assert.Equal(3, clamped); - Assert.Equal(-1, math.clamp(-5, -1, 3)); - Assert.Equal(0, math.clamp(1, 3, 0)); - Assert.Equal(new int2(0, 3), math.clamp(new int2(-4, 9), 0, 3)); - Assert.Equal(new int3(1, 2, 3), math.clamp(new int3(1, 2, 3), new int3(0, 0, 0), new int3(5, 5, 5))); - Assert.Equal(new int4(2, 2, 4, 4), math.clamp(new int4(1, 2, 5, 4), new int4(2), new int4(4))); - Assert.Equal(1.0f, math.clamp(2.0f, -1, 1)); - } - [Fact] public void MatrixMulFollowsHlslRowMajorConvention() { @@ -444,12 +380,11 @@ public sealed class HlslSemanticsTests } [Theory] - [InlineData(0.0f, 0.0f, 0.0f, 0.0f)] - [InlineData(1.25f, 1.25f, 1.25f, -0.245501652f)] - [InlineData(0.25f, -0.5f, 1.75f, 0.0492948629f)] - [InlineData(12.25f, -4.5f, 3.125f, 0.443114728f)] - [InlineData(-7.3f, 2.9f, 101.4f, -0.10221792f)] - public void Snoise3MatchesGoldenValues(float x, float y, float z, float expected) + [InlineData(0.0f, 0.0f, 0.0f, -0.41219875f)] + [InlineData(0.25f, -0.5f, 1.75f, 0.5250269f)] + [InlineData(12.25f, -4.5f, 3.125f, 0.008141451f)] + [InlineData(-7.3f, 2.9f, 101.4f, 0.578015f)] + public void Snoise3MatchesUnityMathematicsReference(float x, float y, float z, float expected) { Assert.Equal(expected, math.snoise(new float3(x, y, z)), precision: 5); } diff --git a/packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs b/packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs index cba99817..ca4584c7 100644 --- a/packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/HlslSourceCompatibilityTests.cs @@ -25,18 +25,6 @@ public sealed class HlslSourceCompatibilityTests Assert.NotNull(ShaderFunction(shader, "cultmath_snoise", typeof(float3))); Assert.NotNull(ShaderFunction(shader, "cultmath_snoise", typeof(float2))); Assert.NotNull(ShaderFunction(shader, "cultmath_value_noise_bicubic", typeof(float2))); - Assert.NotNull(ShaderFunction(shader, "cultmath_smin_grad", typeof(float4), typeof(float4), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_cellular", typeof(float3))); - Assert.NotNull(ShaderFunction(shader, "cultmath_snoise_grad", typeof(float3))); - Assert.NotNull(ShaderFunction(shader, "cultmath_fbm_grad", typeof(float3), typeof(int), typeof(float), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_ridged_grad", typeof(float3), typeof(int), typeof(float), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_phacelle", typeof(float3), typeof(float3), typeof(float), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_iv_snoise_ball", typeof(float3), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_iv_fbm_ball", typeof(float3), typeof(float), typeof(int), typeof(float), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_iv_snoise_ball", typeof(float2), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_af_snoise", typeof(float3), typeof(float3), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_af_fbm", typeof(float3), typeof(float3), typeof(float), typeof(int), typeof(float), typeof(float))); - Assert.NotNull(ShaderFunction(shader, "cultmath_af_frustum_ball", typeof(float2), typeof(float), typeof(float), typeof(float), typeof(float))); } // HLSL functions carry no access modifier, so they compile as private instance methods. @@ -74,41 +62,6 @@ public sealed class HlslSourceCompatibilityTests for (var k = 0; k < 64; k++) { var values = Enumerable.Range(0, 32).Select(_ => Next()).ToArray(); cases.Add(i => values[i]); } for (var k = 0; k < 16; k++) { var values = Enumerable.Range(0, 32).Select(_ => Next()).ToArray(); cases.Add(i => values[i & ~1]); } - // Points aimed squarely at cellular's HLSL mirror (F6/F3 Soul findings): the generic random - // and special-value cases above pass ~92 inputs through cultmath_cellular and never happen to - // hit a point where a radius-2 cell wins (about 3.5e-5 of points, Soul measured) or an - // integer point at or past 2^23, so an HLSL mutant of the search radius, the prune, or the - // removed F2=0 guard can survive this test even though it changes cellular's real output. - void AddPointCase(float3 point) - { - var values = new[] { point.x, point.y, point.z }; - cases.Add(i => i < values.Length ? values[i] : 0.0f); - } - - // The six constructed points from CellularAndSminGradTests.SearchReachesEveryAxisAlignedRadiusTwoSlice: - // each one realizes a different axis-aligned radius-2 offset as F1 or F2, which is exactly - // the case an `if (lowerBound >= f2)` prune written as `>= f1`, or a search radius narrowed on - // one axis (`dz < 2`, `dx` starting at -1), changes. - foreach (var offset in CellularAndSminGradTests.AxisAlignedRadiusTwoOffsets) - AddPointCase(CellularAndSminGradTests.FindPointRealizingOffset(offset)); - - // Integer points at 2^24, several, both signs: past |p| ~= 2^23 distinct cells' jittered - // features can round onto the same float32 value (design.md, "Precision domain"), making - // F2 = 0 reachable and exercising the grad2 = f2 > 0 ? ... : zero guard this test would - // otherwise never touch. - const float twoTo24 = 16777216.0f; - AddPointCase(new float3(twoTo24, twoTo24, twoTo24)); - AddPointCase(new float3(-twoTo24, -twoTo24, -twoTo24)); - AddPointCase(new float3(twoTo24 + 3.0f, -twoTo24 + 5.0f, twoTo24 - 7.0f)); - AddPointCase(new float3(-twoTo24 + 11.0f, twoTo24 - 13.0f, -twoTo24 + 17.0f)); - - // One exact F1 = F2 tie point: the midpoint of two adjacent cells' feature points is - // bit-exact-equidistant from both by construction (negating a vector does not change its - // length, and p - a = -(p - b) here by symmetry), without needing to search for one. - var tieMidpoint = (CellularAndSminGradTests.FeaturePoint(new float3(0.0f, 0.0f, 0.0f)) - + CellularAndSminGradTests.FeaturePoint(new float3(1.0f, 0.0f, 0.0f))) * 0.5f; - AddPointCase(tieMidpoint); - var mismatches = new List(); var compared = new HashSet(); foreach (var mirror in shaderType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(m => m.Name.StartsWith("cultmath_"))) @@ -125,287 +78,26 @@ public sealed class HlslSourceCompatibilityTests foreach (var input in cases) { var slot = 0; - var args = types.Select(t => Scalars.Contains(t) ? Scalar(t, input(slot++)) - : Activator.CreateInstance(t, Components(t).Select(f => Scalar(f.FieldType, input(slot++))).ToArray())!).ToArray(); - var expected = Values(counterpart.Invoke(null, args)!); - var actual = Values(mirror.Invoke(shader, args)!); - if (!BitwiseEqual(expected, actual)) + var args = types.Select(t => t == typeof(float) ? (object)input(slot++) + : Activator.CreateInstance(t, Enumerable.Range(0, Components(t)).Select(_ => (object)input(slot++)).ToArray())!).ToArray(); + var expected = Floats(counterpart.Invoke(null, args)!); + var actual = Floats(mirror.Invoke(shader, args)!); + if (expected.Length != actual.Length || expected.Zip(actual).Any(p => !(float.IsNaN(p.First) && float.IsNaN(p.Second)) + && BitConverter.SingleToInt32Bits(p.First) != BitConverter.SingleToInt32Bits(p.Second))) { - mismatches.Add($"{mirror.Name}({string.Join(", ", args.Select(a => string.Join(" ", Values(a).Select(v => v.Value))))}): C# {string.Join(" ", expected.Select(v => v.Value))}, mirror {string.Join(" ", actual.Select(v => v.Value))}"); + mismatches.Add($"{mirror.Name}({string.Join(", ", args.Select(a => string.Join(" ", Floats(a))))}): C# {string.Join(" ", expected)}, mirror {string.Join(" ", actual)}"); } } } Assert.True(mismatches.Count == 0, $"{mismatches.Count} mismatches:{Environment.NewLine}{string.Join(Environment.NewLine, mismatches.Take(12))}"); - Assert.Equal(67, compared.Count); + Assert.Equal(26, compared.Count); } - /// - /// The generic comparison above passes about a hundred inputs through cultmath_phacelle, and - /// its prune only changes an output for the rare cell whose weight is nonzero but whose lower - /// bound sits just under the 2.25 cut (Soul's F6 lesson for cellular): a mirror whose cut is 2.0 - /// survives a hundred inputs. A dense sweep of realistic arguments closes that gap. - /// - [Fact] - public void PhacelleMirrorMatchesCSharpBitForBitAcrossADenseSweep() - { - var (assembly, errors) = CompileShaderMirror(); - Assert.True(assembly is not null, string.Join(Environment.NewLine, errors)); - var shaderType = assembly!.GetType("CultMathHlsl.HlslShader")!; - var shader = Activator.CreateInstance(shaderType); - var mirror = ShaderFunction(shaderType, "cultmath_phacelle", typeof(float3), typeof(float3), typeof(float), typeof(float))!; + private static int Components(Type t) => t.GetFields().Count(f => f.FieldType == typeof(float) && !f.IsStatic); - var random = new System.Random(0x5EED2); - float Next(float extent) => (random.NextSingle() * 2.0f - 1.0f) * extent; - for (var i = 0; i < 20000; i++) - { - var p = new float3(Next(50.0f), Next(50.0f), Next(50.0f)); - var side = new float3(Next(9.0f), Next(9.0f), Next(9.0f)); - var offset = random.NextSingle(); - var normalization = random.NextSingle(); - var expected = Values(phacelle(p, side, offset, normalization)); - var actual = Values(mirror.Invoke(shader, new object[] { p, side, offset, normalization })!); - Assert.True(BitwiseEqual(expected, actual), $"mirror differs from C# at p = {p}, side = {side}"); - } - } - - /// - /// The generic comparison draws centre, axis and radius from [-100, 100], where the reach is far past the - /// 0.15 or so below which cultmath_af_snoise's centred form is the narrower one, so an HLSL edit - /// of the choice between the centred and the Lipschitz form (a threshold, a reordered sum) survives it. - /// This sweep draws realistic slices (axis and radius log-uniform in 1e-3 to 0.5, the reach of a tile - /// near a camera), which land on both sides of the choice and next to it, for cultmath_af_snoise - /// and cultmath_af_fbm. - /// - [Fact] - public void AffineSnoiseMirrorMatchesCSharpBitForBitOnBothSidesOfItsBranch() - { - var (assembly, errors) = CompileShaderMirror(); - Assert.True(assembly is not null, string.Join(Environment.NewLine, errors)); - var shaderType = assembly!.GetType("CultMathHlsl.HlslShader")!; - var shader = Activator.CreateInstance(shaderType); - var snoiseMirror = ShaderFunction(shaderType, "cultmath_af_snoise", typeof(float3), typeof(float3), typeof(float))!; - var fbmMirror = ShaderFunction(shaderType, "cultmath_af_fbm", typeof(float3), typeof(float3), typeof(float), typeof(int), typeof(float), typeof(float))!; - - var random = new System.Random(0x5EED3); - float Next(float extent) => (random.NextSingle() * 2.0f - 1.0f) * extent; - float Reach() => 1.0e-3f * MathF.Pow(500.0f, random.NextSingle()); - int centred = 0, lipschitz = 0; - for (var i = 0; i < 20000; i++) - { - var centre = new float3(Next(50.0f), Next(50.0f), Next(50.0f)); - var axis = normalize(new float3(Next(1.0f), Next(1.0f), Next(1.0f))) * Reach(); - var radius = Reach(); - var expected = af_snoise(centre, axis, radius); - var actual = Values(snoiseMirror.Invoke(shader, new object[] { centre, axis, radius })!); - Assert.True(BitwiseEqual(Values(expected), actual), $"cultmath_af_snoise differs from C# at centre = {centre}, axis = {axis}, radius = {radius}"); - if (expected.y != 0.0f) - centred++; - else - lipschitz++; - - if (i % 8 == 0) - { - var fbmExpected = Values(af_fbm(centre, axis, radius, 4, 2.0f, 0.5f)); - var fbmActual = Values(fbmMirror.Invoke(shader, new object[] { centre, axis, radius, 4, 2.0f, 0.5f })!); - Assert.True(BitwiseEqual(fbmExpected, fbmActual), $"cultmath_af_fbm differs from C# at centre = {centre}, axis = {axis}, radius = {radius}"); - } - } - - Assert.True(centred > 2000 && lipschitz > 2000, $"the sweep meets one branch too rarely: centred {centred}, Lipschitz {lipschitz} of 20000"); - } - - /// - /// The generic comparison stops at 1e7, so an HLSL edit of cultmath_af_range's NaN test that - /// misreads the finite values near the float maximum (or an overflowed endpoint) survives it. Forms - /// from zero to the float maximum, infinite and NaN components, both signs, in every slot: the mirror - /// returns C#'s bits, and neither endpoint is ever NaN. - /// - [Fact] - public void AffineRangeMirrorMatchesCSharpBitForBitAtTheFloatExtremes() - { - var (assembly, errors) = CompileShaderMirror(); - Assert.True(assembly is not null, string.Join(Environment.NewLine, errors)); - var shaderType = assembly!.GetType("CultMathHlsl.HlslShader")!; - var shader = Activator.CreateInstance(shaderType); - var mirror = ShaderFunction(shaderType, "cultmath_af_range", typeof(float3))!; - - var magnitudes = new[] { 0.0f, 1.0f, 1.0e30f, 1.0e38f, float.MaxValue / 2.0f, float.MaxValue, float.PositiveInfinity, float.NaN }; - var values = magnitudes.Concat(magnitudes.Where(m => !float.IsNaN(m)).Select(m => -m)).ToArray(); - foreach (var x0 in values) - foreach (var a in values) - foreach (var e in values) - { - var form = new float3(x0, a, e); - var expected = af_range(form); - var actual = Values(mirror.Invoke(shader, new object[] { form })!); - Assert.True(BitwiseEqual(Values(expected), actual), $"cultmath_af_range differs from C# at {form}"); - Assert.False(float.IsNaN(expected.x) || float.IsNaN(expected.y), $"af_range({form}) is {expected}, a NaN endpoint"); - } - } - - /// - /// The dense sweep almost never meets a cell whose box bound is just under the 2.25 cut and whose - /// weight is still nonzero: a mirror cut of 2.245, 2.24 or 2.2 survives it. These points sit next - /// to such cells (), so the mirror must match C# bit for - /// bit, and must match the unpruned C# sum (the shader has no prune switch, so that is the - /// independent statement that the cut is exact). - /// - [Fact] - public void PhacelleMirrorMatchesCSharpBitForBitNextToCellsJustInsideTheCut() - { - var (assembly, errors) = CompileShaderMirror(); - Assert.True(assembly is not null, string.Join(Environment.NewLine, errors)); - var shaderType = assembly!.GetType("CultMathHlsl.HlslShader")!; - var shader = Activator.CreateInstance(shaderType); - var mirror = ShaderFunction(shaderType, "cultmath_phacelle", typeof(float3), typeof(float3), typeof(float), typeof(float))!; - - foreach (var p in PhacelleTests.PruneCutPoints) - { - Assert.True(PhacelleTests.HasCellJustInsideTheCut(p), $"no cell just inside the cut at {p}"); - var actual = Values(mirror.Invoke(shader, new object[] { p, PhacelleTests.PruneCutSide, PhacelleTests.PruneCutOffset, PhacelleTests.PruneCutNormalization })!); - var pruned = Values(phacelle(p, PhacelleTests.PruneCutSide, PhacelleTests.PruneCutOffset, PhacelleTests.PruneCutNormalization)); - var unpruned = Values(phacelle(p, PhacelleTests.PruneCutSide, PhacelleTests.PruneCutOffset, PhacelleTests.PruneCutNormalization, false)); - Assert.True(BitwiseEqual(pruned, actual), $"mirror differs from C# at p = {p}"); - Assert.True(BitwiseEqual(unpruned, actual), $"mirror differs from the unpruned C# sum at p = {p}"); - } - } - - /// - /// A hand-built pair of structs standing in for a mirror struct return and its C# counterpart - /// (invariant 8's one struct return shape, e.g. ): same field shape, - /// different concrete type, exactly like the real mirror comparison. Proves the field-by-field, - /// bit-for-bit walk actually rejects a struct whose field differs; without this, the walk could - /// have been comparing lengths only, or skipping the nested vector's own components. - /// - private struct StructMirrorProbeExpected { public float4 first; public float second; } - private struct StructMirrorProbeActual { public float4 first; public float second; } - - [Fact] - public void StructReturnComparisonRejectsAMismatchedField() - { - var expected = new StructMirrorProbeExpected { first = new float4(1.0f, 2.0f, 3.0f, 4.0f), second = 5.0f }; - var matching = new StructMirrorProbeActual { first = new float4(1.0f, 2.0f, 3.0f, 4.0f), second = 5.0f }; - var mismatchedLeaf = new StructMirrorProbeActual { first = new float4(1.0f, 2.0f, 3.0f, 4.0f), second = 5.5f }; - var mismatchedNestedComponent = new StructMirrorProbeActual { first = new float4(1.0f, 2.0f, -3.0f, 4.0f), second = 5.0f }; - - Assert.True(BitwiseEqual(Values(expected), Values(matching))); - Assert.False(BitwiseEqual(Values(expected), Values(mismatchedLeaf))); - Assert.False(BitwiseEqual(Values(expected), Values(mismatchedNestedComponent))); - } - - /// - /// Struct shapes standing in for CultCellular's own field order (nearest; edge; id), used - /// to falsify two named mutants (F2): H2 declares the mirror struct with its first two fields - /// swapped (edge; nearest; id) and swaps the assignments to match, so every leaf VALUE - /// still lands in the same POSITION as the correct struct; only the field NAME at each position - /// differs. H3 renames and retypes every field (id becomes an int carrying the same bits) while - /// keeping the original position order, so only NAME and TYPE differ, never position. - /// - private struct NearestEdgeIdExpected { public float4 nearest; public float4 edge; public float id; } - private struct EdgeNearestIdSwappedNames { public float4 edge; public float4 nearest; public float id; } - private struct RenamedAndRetypedFields { public float4 a; public float4 b; public int c; } - - [Fact] - public void StructReturnComparisonRejectsFieldsSwappedByNameEvenWhenValuesAlign() - { - // H2: the mutant struct's field ORDER is (edge, nearest, id), and its assignments are - // swapped to match, so declaration-position values are identical to the correct struct's. - // Only checking names (not just position) can tell these apart. - var expected = new NearestEdgeIdExpected - { - nearest = new float4(1.0f, 2.0f, 3.0f, 4.0f), - edge = new float4(5.0f, 6.0f, 7.0f, 8.0f), - id = 9.0f, - }; - var swapped = new EdgeNearestIdSwappedNames - { - edge = new float4(1.0f, 2.0f, 3.0f, 4.0f), // holds what should be "nearest"'s value. - nearest = new float4(5.0f, 6.0f, 7.0f, 8.0f), // holds what should be "edge"'s value. - id = 9.0f, - }; - - Assert.False(BitwiseEqual(Values(expected), Values(swapped))); - } - - [Fact] - public void StructReturnComparisonRejectsRenamedAndRetypedFields() - { - // H3: field order matches the correct struct exactly, but every field is renamed, and id is - // retyped from float to int carrying the same bit pattern the correct id would round to. - var expected = new NearestEdgeIdExpected - { - nearest = new float4(1.0f, 2.0f, 3.0f, 4.0f), - edge = new float4(5.0f, 6.0f, 7.0f, 8.0f), - id = 9.0f, - }; - var renamed = new RenamedAndRetypedFields - { - a = new float4(1.0f, 2.0f, 3.0f, 4.0f), - b = new float4(5.0f, 6.0f, 7.0f, 8.0f), - c = BitConverter.SingleToInt32Bits(9.0f), - }; - - Assert.False(BitwiseEqual(Values(expected), Values(renamed))); - } - - // Integer arguments take the bit pattern of the float input, so specials become 0, 0x80000000, NaN bits, ... - private static readonly Type[] Scalars = { typeof(float), typeof(int), typeof(uint) }; - - private static object Scalar(Type t, float f) => t == typeof(float) ? f - : t == typeof(int) ? BitConverter.SingleToInt32Bits(f) : (object)(uint)BitConverter.SingleToInt32Bits(f); - - // Scoped to scalar-typed fields: this only ever builds function ARGUMENTS (float2/3/4, int2/3/4, ...), - // never a struct-of-struct return, so it must not recurse. - private static FieldInfo[] Components(Type t) => t.GetFields().Where(f => !f.IsStatic && Scalars.Contains(f.FieldType)).ToArray(); - - /// - /// One flattened scalar leaf of a (possibly nested) return value: its declaration path (field - /// names joined by '.'), its declared type, and its value. Carrying path and type, not just the - /// value, is what lets the struct-return comparison reject a field that was renamed or retyped - /// but landed in the same position (F2): a positional-only comparison cannot tell "edge" holding - /// nearest's value apart from "nearest" holding it. - /// - private readonly record struct Leaf(string Path, Type Type, object Value); - - /// - /// Flattens a return value to its scalar leaves, recursing through struct fields of any type - /// (invariant 8's one struct return shape, e.g. 's float4/float4/float - /// fields) so a struct return is compared field by field, down to bit-for-bit scalars, exactly - /// like a bare vector return already is. Each leaf keeps the field name (and its ancestors') and - /// declared type it was read from. - /// - private static Leaf[] Values(object value, string path = "") => Scalars.Contains(value.GetType()) - ? new[] { new Leaf(path, value.GetType(), value) } - : value.GetType().GetFields().Where(f => !f.IsStatic) - .SelectMany(f => Values(f.GetValue(value)!, path.Length == 0 ? f.Name : path + "." + f.Name)) - .ToArray(); - - // Compares leaves by NAME and TYPE as well as value, in declaration order, so a mirror struct - // whose fields are reordered, renamed, or retyped relative to its C# counterpart fails here even - // when the flattened values happen to line up positionally (F2's H2/H3 mutants). - private static bool BitwiseEqual(Leaf[] expected, Leaf[] actual) => - expected.Length == actual.Length && expected.Zip(actual).All(p => - p.First.Path == p.Second.Path && p.First.Type == p.Second.Type && - (p.First.Value is float a && p.Second.Value is float b - ? (float.IsNaN(a) && float.IsNaN(b)) || BitConverter.SingleToInt32Bits(a) == BitConverter.SingleToInt32Bits(b) - : p.First.Value.Equals(p.Second.Value))); - - /// - /// The text of CultMath.hlsl with each #include "name" replaced in place by the - /// included file from the same directory, as the shader compiler would resolve it. Only the - /// package's own includes exist, so a missing file is an error rather than a skip. An include for - /// which returns false is dropped with its line instead (the GLSL - /// lowering's separately licensed files); the C# mirror inlines every one. - /// - internal static string ReadShaderSource(string cultMathRoot, Func? inline = null) - { - var shaders = Path.Combine(cultMathRoot, "shaders"); - return Regex.Replace(File.ReadAllText(Path.Combine(shaders, "CultMath.hlsl")), @"(?m)^#include ""([^""]+)""[ \t]*\r?$(\n?)", - match => inline is null || inline(match.Groups[1].Value) - ? File.ReadAllText(Path.Combine(shaders, match.Groups[1].Value)) + match.Groups[2].Value - : string.Empty); - } + private static float[] Floats(object value) => value is float f ? new[] { f } + : value.GetType().GetFields().Where(field => field.FieldType == typeof(float) && !field.IsStatic).Select(field => (float)field.GetValue(value)!).ToArray(); /// The documented HLSL-to-C# transformations, and nothing else. internal static string TransformHlslToCSharp(string hlsl) @@ -423,19 +115,13 @@ public sealed class HlslSourceCompatibilityTests // 4. Floating literals gain the `f` suffix; an unsuffixed C# literal is a double. source = Regex.Replace(source, @"(? - m.Groups[1].Value + Regex.Replace(m.Groups[2].Value, @"(?m)^(\s*)(\w+\s+\w+;)", "$1public $2") + m.Groups[3].Value); - - // 6. The file body is wrapped in a class; C# has no free functions. + // 5. The file body is wrapped in a class; C# has no free functions. return "using CultMath;\nusing static CultMath.math;\nnamespace CultMathHlsl;\npublic class HlslShader\n{\n" + source + "\n}\n"; } private static (Assembly? Assembly, IReadOnlyList Errors) CompileShaderMirror() { - var hlsl = ReadShaderSource(FindCultMathRoot()); + var hlsl = File.ReadAllText(Path.Combine(FindCultMathRoot(), "shaders", "CultMath.hlsl")); var tree = CSharpSyntaxTree.ParseText(TransformHlslToCSharp(hlsl)); var references = ((string)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")!) .Split(Path.PathSeparator) @@ -457,7 +143,7 @@ public sealed class HlslSourceCompatibilityTests return (result.Success ? Assembly.Load(stream.ToArray()) : null, errors); } - internal static string FindCultMathRoot() + private static string FindCultMathRoot() { var directory = new DirectoryInfo(AppContext.BaseDirectory); while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "packages", "cultmath", "shaders", "CultMath.hlsl"))) diff --git a/packages/cultmath/tests/CultMath.Tests/IntervalTests.cs b/packages/cultmath/tests/CultMath.Tests/IntervalTests.cs deleted file mode 100644 index 4f165eab..00000000 --- a/packages/cultmath/tests/CultMath.Tests/IntervalTests.cs +++ /dev/null @@ -1,312 +0,0 @@ -using CultMath; -using Xunit; -using static CultMath.math; - -namespace CultMath.Tests; - -/// -/// intervals-enclose for every iv_* op (design.md, "Intervals"): for each op, intervals with seeded random -/// centres and widths and the points inside them; f(x), evaluated pointwise in float32 by the same C# math -/// the op mirrors, must lie in op(I) with no tolerance. -/// -/// Stryker mutates operators, not float bounds, so the mutants that matter most here are written by hand -/// and run by : for every op, the lo bound raised by one ulp and the -/// hi bound lowered by one ulp must each fail the harness. Two pairs are equivalent mutants on this CPU and -/// are not in that list: -/// - iv_exp's one-ulp widening, both sides: MathF.Exp is monotone over every float on the Linux runtime -/// (MeasureMonotonicity prints 0 violations), so removing the widening encloses here. It is kept because -/// exp is not required to be correctly rounded, and another libm or a GPU need not be monotone. -/// - iv_smoothstep's one-ulp widening: the generic harness never meets one of smoothstep's 1-ulp -/// non-monotone steps; constructs one on -/// each side and kills both mutants. -/// -public sealed class IntervalTests -{ - private readonly ITestOutputHelper output; - - public IntervalTests(ITestOutputHelper output) => this.output = output; - - private const int IntervalCount = 10000; - private const int PointsPerInterval = 16; - - // One row of the shared harness: how many interval arguments the op takes, how to draw its scalar - // arguments, the op itself and the pointwise function it encloses. A new op is one entry here. - internal sealed record Op( - string Name, - int Intervals, - Func Scalars, - Func Bound, - Func Pointwise, - bool NonNegativeDomain = false); - - private static float[] None(System.Random random) => Array.Empty(); - - private static float Uniform(System.Random random, float lo, float hi) => lo + (hi - lo) * random.NextSingle(); - - internal static readonly Op[] Ops = - { - new("iv_point", 0, r => new[] { Uniform(r, -20.0f, 20.0f) }, (i, s) => iv_point(s[0]), (x, s) => s[0]), - new("iv_add", 2, None, (i, s) => iv_add(i[0], i[1]), (x, s) => x[0] + x[1]), - new("iv_sub", 2, None, (i, s) => iv_sub(i[0], i[1]), (x, s) => x[0] - x[1]), - new("iv_neg", 1, None, (i, s) => iv_neg(i[0]), (x, s) => -x[0]), - new("iv_mul", 2, None, (i, s) => iv_mul(i[0], i[1]), (x, s) => x[0] * x[1]), - new("iv_scale", 1, r => new[] { Uniform(r, -4.0f, 4.0f) }, (i, s) => iv_scale(i[0], s[0]), (x, s) => x[0] * s[0]), - new("iv_abs", 1, None, (i, s) => iv_abs(i[0]), (x, s) => abs(x[0])), - new("iv_min", 2, None, (i, s) => iv_min(i[0], i[1]), (x, s) => min(x[0], x[1])), - new("iv_max", 2, None, (i, s) => iv_max(i[0], i[1]), (x, s) => max(x[0], x[1])), - new("iv_sqr", 1, None, (i, s) => iv_sqr(i[0]), (x, s) => x[0] * x[0]), - new("iv_sqrt", 1, None, (i, s) => iv_sqrt(i[0]), (x, s) => sqrt(x[0]), NonNegativeDomain: true), - new("iv_exp", 1, None, (i, s) => iv_exp(i[0]), (x, s) => exp(x[0])), - new("iv_clamp", 1, r => new[] { Uniform(r, -25.0f, 25.0f), Uniform(r, -25.0f, 25.0f) }, - (i, s) => iv_clamp(i[0], s[0], s[1]), (x, s) => clamp(x[0], s[0], s[1])), - new("iv_saturate", 1, None, (i, s) => iv_saturate(i[0]), (x, s) => saturate(x[0])), - new("iv_smoothstep", 1, r => new[] { Uniform(r, -25.0f, 25.0f), Uniform(r, -25.0f, 25.0f) }, - (i, s) => iv_smoothstep(s[0], s[1], i[0]), (x, s) => smoothstep(s[0], s[1], x[0])), - new("iv_lerp", 2, r => new[] { Uniform(r, -0.5f, 1.5f) }, (i, s) => iv_lerp(i[0], i[1], s[0]), (x, s) => lerp(x[0], x[1], s[0])), - }; - - // Centres in [-20, 20], widths log-uniform in [1e-4, 10]. Every eighth interval is a point - // interval: a bound that is only reached when an argument is a point (iv_lerp's, where x appears - // twice) is still reached, so a one-ulp shrink of it is still caught. - private static float2 RandomInterval(System.Random random, int index) - { - var centre = Uniform(random, -20.0f, 20.0f); - if (index % 8 == 7) - return iv_point(centre); - var width = MathF.Pow(10.0f, Uniform(random, -4.0f, 1.0f)); - return new float2(centre - width * 0.5f, centre + width * 0.5f); - } - - // The points inside one argument: both endpoints, zero when the interval holds it, and the rest - // uniform. Endpoints and zero are where a tight bound is reached. - private static float[] PointsInside(System.Random random, float2 interval, bool nonNegative) - { - var lo = nonNegative ? max(interval.x, 0.0f) : interval.x; - var hi = nonNegative ? max(interval.y, 0.0f) : interval.y; - var points = new float[PointsPerInterval]; - points[0] = lo; - points[1] = hi; - var next = 2; - if (lo < 0.0f && hi > 0.0f) - points[next++] = 0.0f; - for (; next < points.Length; next++) - points[next] = min(max(lo + (hi - lo) * random.NextSingle(), lo), hi); - return points; - } - - /// Runs one op over the seeded set; returns the violations, at most a few, described. - internal static List Violations(Op op, Func? mutate = null, int seed = 0x1A7E) - { - var random = new System.Random(seed); - var violations = new List(); - var count = 0; - for (var k = 0; k < IntervalCount; k++) - { - var intervals = new float2[op.Intervals]; - for (var a = 0; a < op.Intervals; a++) - intervals[a] = RandomInterval(random, k + a); - var scalars = op.Scalars(random); - var bound = op.Bound(intervals, scalars); - if (mutate is not null) - bound = mutate(bound); - - var points = intervals.Select(i => PointsInside(random, i, op.NonNegativeDomain)).ToArray(); - for (var p = 0; p < PointsPerInterval; p++) - { - // Binary ops visit the four endpoint corners first (p = 0..3), then pair points by index. - var x = new float[op.Intervals]; - for (var a = 0; a < op.Intervals; a++) - x[a] = op.Intervals == 2 && p < 4 ? points[a][a == 0 ? p & 1 : p >> 1] : points[a][p]; - var value = op.Pointwise(x, scalars); - if (!(value >= bound.x && value <= bound.y)) - { - if (count++ < 4) - violations.Add($"{op.Name}({string.Join(", ", intervals)}; {string.Join(", ", scalars)}) = {bound}, f({string.Join(", ", x)}) = {value:R}"); - } - } - } - - if (count > violations.Count) - violations.Add($"... {count} violations in all"); - return violations; - } - - [Fact] - public void EveryOpEnclosesItsPoints() - { - var failures = Ops.SelectMany(op => Violations(op)).ToList(); - Assert.True(failures.Count == 0, string.Join(Environment.NewLine, failures)); - } - - internal static float NextUp(float v) => v == 0.0f ? asfloat(1u) : asfloat(v > 0.0f ? asuint(v) + 1u : asuint(v) - 1u); - private static float NextDown(float v) => -NextUp(-v); - - /// - /// The hand-mutation list: every op's lo raised by one ulp, and its hi lowered by one ulp, must each - /// fail the harness. The two equivalent pairs are named in the class comment. - /// - [Fact] - public void EveryOneUlpShrinkIsCaught() - { - var survivors = new List(); - foreach (var op in Ops.Where(o => o.Name is not "iv_exp" and not "iv_smoothstep")) - { - if (Violations(op, b => new float2(NextUp(b.x), b.y)).Count == 0) - survivors.Add(op.Name + " lo + 1 ulp"); - if (Violations(op, b => new float2(b.x, NextDown(b.y))).Count == 0) - survivors.Add(op.Name + " hi - 1 ulp"); - } - - Assert.True(survivors.Count == 0, "surviving one-ulp shrinks: " + string.Join(", ", survivors)); - } - - [Fact] - public void MulCoversEverySignCase() - { - // Both positive, both negative, mixed both ways, and a factor straddling zero on either side. - Assert.Equal(new float2(2.0f, 12.0f), iv_mul(new float2(1.0f, 3.0f), new float2(2.0f, 4.0f))); - Assert.Equal(new float2(2.0f, 12.0f), iv_mul(new float2(-3.0f, -1.0f), new float2(-4.0f, -2.0f))); - Assert.Equal(new float2(-12.0f, -2.0f), iv_mul(new float2(1.0f, 3.0f), new float2(-4.0f, -2.0f))); - Assert.Equal(new float2(-12.0f, -2.0f), iv_mul(new float2(-3.0f, -1.0f), new float2(2.0f, 4.0f))); - Assert.Equal(new float2(-8.0f, 12.0f), iv_mul(new float2(-2.0f, 3.0f), new float2(2.0f, 4.0f))); - Assert.Equal(new float2(-12.0f, 8.0f), iv_mul(new float2(-2.0f, 3.0f), new float2(-4.0f, -2.0f))); - Assert.Equal(new float2(-15.0f, 12.0f), iv_mul(new float2(-2.0f, 3.0f), new float2(-5.0f, 4.0f))); - } - - [Fact] - public void SqrtClampsANegativeLoAtZero() - { - Assert.Equal(new float2(0.0f, 3.0f), iv_sqrt(new float2(-4.0f, 9.0f))); - Assert.Equal(new float2(0.0f, 0.0f), iv_sqrt(new float2(-4.0f, -1.0f))); - Assert.Equal(new float2(2.0f, 3.0f), iv_sqrt(new float2(4.0f, 9.0f))); - } - - [Fact] - public void AbsAndSqrStraddlingZeroStartAtZero() - { - Assert.Equal(new float2(0.0f, 3.0f), iv_abs(new float2(-3.0f, 2.0f))); - Assert.Equal(new float2(0.0f, 5.0f), iv_abs(new float2(-2.0f, 5.0f))); - Assert.Equal(new float2(2.0f, 5.0f), iv_abs(new float2(-5.0f, -2.0f))); - Assert.Equal(new float2(0.0f, 9.0f), iv_sqr(new float2(-3.0f, 2.0f))); - Assert.Equal(new float2(4.0f, 25.0f), iv_sqr(new float2(-5.0f, -2.0f))); - } - - [Fact] - public void MinAndMaxAreThePointwiseMinAndMaxOfTheEnds() - { - var a = new float2(-1.0f, 4.0f); - var b = new float2(2.0f, 3.0f); - Assert.Equal(new float2(-1.0f, 3.0f), iv_min(a, b)); - Assert.Equal(new float2(2.0f, 4.0f), iv_max(a, b)); - } - - [Fact] - public void SmoothstepBoundsAreItsOrderedEndpointsWidenedByOneUlp() - { - var rising = iv_smoothstep(0.0f, 1.0f, new float2(0.25f, 0.5f)); - Assert.Equal(NextDown(smoothstep(0.0f, 1.0f, 0.25f)), rising.x); - Assert.Equal(NextUp(smoothstep(0.0f, 1.0f, 0.5f)), rising.y); - - // minimum > maximum: smoothstep falls, so the endpoints swap. - var falling = iv_smoothstep(1.0f, 0.0f, new float2(0.25f, 0.5f)); - Assert.Equal(NextDown(smoothstep(1.0f, 0.0f, 0.5f)), falling.x); - Assert.Equal(NextUp(smoothstep(1.0f, 0.0f, 0.25f)), falling.y); - - // The widening never leaves [0, 1]. - Assert.Equal(new float2(0.0f, 1.0f), iv_smoothstep(0.0f, 1.0f, new float2(-2.0f, 3.0f))); - } - - /// - /// smoothstep's float32 evaluation steps down by one ulp in places (MeasureMonotonicity). Three - /// consecutive floats t0 < t1 < t2 with f(t1) below both neighbours put f(t1) outside the ordered - /// endpoints of [t0, t2]; three with f(t1) above both put it outside on the other side. The widened - /// bound encloses both; without the widening it does not. - /// - [Fact] - public void SmoothstepWideningCoversItsFloatNonMonotonicity() - { - float F(float t) => smoothstep(0.0f, 1.0f, t); - float2? dip = null, peak = null; - for (var t = 1.0e-4f; t < 0.01f && (dip is null || peak is null); t = NextUp(t)) - { - var t1 = NextUp(t); - var t2 = NextUp(t1); - if (dip is null && F(t1) < F(t) && F(t1) < F(t2)) - dip = new float2(t, t2); - if (peak is null && F(t1) > F(t) && F(t1) > F(t2)) - peak = new float2(t, t2); - } - - Assert.NotNull(dip); - Assert.NotNull(peak); - foreach (var (interval, low) in new[] { (dip!.Value, true), (peak!.Value, false) }) - { - var mid = F(NextUp(interval.x)); - var unwidened = new float2(min(F(interval.x), F(interval.y)), max(F(interval.x), F(interval.y))); - Assert.False(mid >= unwidened.x && mid <= unwidened.y, $"the {(low ? "dip" : "peak")} at {interval} is inside the endpoints"); - var bound = iv_smoothstep(0.0f, 1.0f, interval); - Assert.True(mid >= bound.x && mid <= bound.y, $"iv_smoothstep{interval} = {bound} misses {mid:R}"); - } - } - - [Fact] - public void LerpIsTheNaturalExtensionAndTightForPointArguments() - { - Assert.Equal(new float2(lerp(1.0f, 3.0f, 0.25f), lerp(1.0f, 7.0f, 0.25f)), iv_lerp(iv_point(1.0f), new float2(3.0f, 7.0f), 0.25f)); - Assert.Equal(new float2(-1.0f + (2.0f - 1.0f) * 0.5f, 1.0f + (4.0f + 1.0f) * 0.5f), iv_lerp(new float2(-1.0f, 1.0f), new float2(2.0f, 4.0f), 0.5f)); - } - - [Fact] - public void ExpIsWidenedByOneUlpOnEachSide() - { - var bound = iv_exp(new float2(-1.0f, 2.0f)); - Assert.Equal(NextDown(exp(-1.0f)), bound.x); - Assert.Equal(NextUp(exp(2.0f)), bound.y); - Assert.Equal(0.0f, iv_exp(new float2(-200.0f, 0.0f)).x); - } - - /// - /// The monotonicity the widening rules rest on, measured over every float: exp over [-87, 88.7], the - /// range where it neither underflows to a subnormal nor overflows, and smoothstep(0, 1, t) over [0, 1], - /// which covers every smoothstep because t = saturate((x - minimum) / (maximum - minimum)) is itself - /// monotone in x. Prints the number of steps down and the largest, in ulps. Slow: about a minute. - /// - [Fact(Explicit = true)] - [Trait("Category", "Slow")] - public void MeasureMonotonicity() - { - long expDown = 0, expWorst = 0; - var previous = exp(-87.0f); - for (var x = NextUp(-87.0f); x <= 88.7f; x = NextUp(x)) - { - var e = exp(x); - if (e < previous) - { - expDown++; - expWorst = Math.Max(expWorst, (long)asuint(previous) - asuint(e)); - } - - previous = e; - } - - long smoothDown = 0, smoothWorst = 0; - var runningMax = 0.0f; - for (var bits = 0u; bits <= asuint(1.0f); bits++) - { - var s = smoothstep(0.0f, 1.0f, asfloat(bits)); - if (s < runningMax) - { - smoothDown++; - smoothWorst = Math.Max(smoothWorst, (long)asuint(runningMax) - asuint(s)); - } - else - { - runningMax = s; - } - } - - output.WriteLine($"IV-REPORT monotonicity: exp steps down {expDown} times, worst {expWorst} ulp; smoothstep steps down {smoothDown} times, worst {smoothWorst} ulp"); - Assert.True(expWorst <= 1, $"exp steps down by {expWorst} ulp; one ulp of widening is not enough"); - Assert.True(smoothWorst <= 1, $"smoothstep steps down by {smoothWorst} ulp; one ulp of widening is not enough"); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/MathTests.cs b/packages/cultmath/tests/CultMath.Tests/MathTests.cs index 3dc374bf..de1bf996 100644 --- a/packages/cultmath/tests/CultMath.Tests/MathTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/MathTests.cs @@ -12,41 +12,6 @@ public sealed class MathTests Assert.Equal(0.75f, math.frac(-1.25f)); } - // Expected values come from a Python transcription of the paper's pcg3d/pcg4d (JCGT 9(3) 2020, p. 32) and - // O'Neill's pcg_output_rxs_m_xs_32_32 with PCG_DEFAULT_MULTIPLIER_32/INCREMENT_32, independent of this code. - [Fact] - public void PcgHashesMatchReferenceTranscription() - { - static int3 U3(uint x, uint y, uint z) => new((int)x, (int)y, (int)z); - static int4 U4(uint x, uint y, uint z, uint w) => new((int)x, (int)y, (int)z, (int)w); - - Assert.Equal(0x07BB2FE2u, math.pcg(0u)); - Assert.Equal(0xA8BEEA3Cu, math.pcg(1u)); - Assert.Equal(0x995312E1u, math.pcg(0x12345678u)); - Assert.Equal(0xE62A4902u, math.pcg(0xFFFFFFFFu)); - Assert.Equal(U3(0x9BAFD7C6u, 0xA8E88A6Bu, 0x3F15482Cu), math.pcg3d(new int3(0, 0, 0))); - Assert.Equal(U3(0xFA9F79A6u, 0x48F2F44Cu, 0x596F5AB1u), math.pcg3d(new int3(1, 2, 3))); - Assert.Equal(U3(0x67DCF282u, 0x49E87E17u, 0x10018917u), math.pcg3d(U3(0xFFFFFFFFu, 0x80000000u, 0x7FFFFFFFu))); - Assert.Equal(U4(0x0F02F829u, 0x2D568769u, 0x32B0C43Bu, 0xD32548EAu), math.pcg4d(new int4(0, 0, 0, 0))); - Assert.Equal(U4(0x3622CD16u, 0xF11471D8u, 0xE1109B3Fu, 0x02B94C2Fu), math.pcg4d(new int4(1, 2, 3, 4))); - Assert.Equal(U4(0x72180037u, 0x81D493E6u, 0xD9BA7226u, 0x14C9ABA7u), math.pcg4d(U4(0xFFFFFFFFu, 0x80000000u, 0x7FFFFFFFu, 0xDEADBEEFu))); - Assert.Equal(U3(0xA7B40FEEu, 0x9B70DFC0u, 0x3106C2C5u), math.pcg3d(new float3(1.5f, -2.25f, 1e7f))); - Assert.Equal(U3(0x5A09E5C6u, 0x53EC0DABu, 0x4BE4A1ECu), math.pcg3d(new float2(3.0f, 4.0f))); - Assert.Equal(U4(0x1849E380u, 0xF199DEE0u, 0x6C6B4934u, 0x34AF16DFu), - math.pcg4d(new float4(-0.0f, BitConverter.Int32BitsToSingle(0x7FC00000), 0.5f, 1e-7f))); - } - - [Fact] - public void Pcg3dSeparatesAPositionGrid() - { - // A single 32-bit component is subject to birthday collisions (x has one here); the full output is distinct. - var hashes = new HashSet(); - for (var i = 0; i < 100; i++) - for (var j = 0; j < 100; j++) - hashes.Add(math.pcg3d(new float2(i * 0.5f - 25.0f, j * 0.5f - 25.0f))); - Assert.Equal(10000, hashes.Count); - } - [Fact] public void VectorOperationsAreComponentWise() { @@ -307,10 +272,10 @@ public sealed class MathTests [Theory] [InlineData(0.0f, 0.0f, 0.0f)] - [InlineData(0.25f, -0.5f, 0.225074813f)] - [InlineData(12.25f, -4.5f, -0.388599217f)] - [InlineData(536.5106f, 536.5106f, 0.538390875f)] - public void SimplexNoiseMatchesGoldenValues(float x, float y, float expected) + [InlineData(0.25f, -0.5f, -0.425866783f)] + [InlineData(12.25f, -4.5f, 0.258312f)] + [InlineData(536.5106f, 536.5106f, -0.6901103f)] + public void SimplexNoiseMatchesUnityMathematics(float x, float y, float expected) { Assert.Equal(expected, math.snoise(new float2(x, y)), precision: 6); } @@ -367,160 +332,4 @@ public sealed class MathTests Assert.Equal(0.0f, px[1], precision: 5); Assert.Equal(0.0f, py[1], precision: 5); } - - // Tabulated to 16 significant figures (Abramowitz & Stegun table 7.1 lineage / standard erf tables). - [Theory] - [InlineData(0.0f, 0.0)] - [InlineData(0.5f, 0.5204998778130465)] - [InlineData(-0.5f, -0.5204998778130465)] - [InlineData(1.0f, 0.8427007929497149)] - [InlineData(-1.0f, -0.8427007929497149)] - [InlineData(2.0f, 0.9953222650189527)] - [InlineData(-2.0f, -0.9953222650189527)] - [InlineData(3.0f, 0.9999779095030014)] - [InlineData(-3.0f, -0.9999779095030014)] - public void ErfMatchesReferenceValues(float x, double expected) - { - Assert.True( - Math.Abs(math.erf(x) - expected) <= 2e-6, - $"erf({x}) = {math.erf(x)}, expected {expected}"); - } - - [Fact] - public void ErfIsOdd() - { - for (var i = -30; i <= 30; i++) - { - var x = i / 10.0f; - Assert.Equal(-math.erf(x), math.erf(-x)); - } - } - - [Fact] - public void ErfApproachesItsLimitsOfPlusMinusOne() - { - Assert.Equal(1.0f, math.erf(6.0f)); - Assert.Equal(1.0f, math.erf(20.0f)); - Assert.Equal(-1.0f, math.erf(-6.0f)); - Assert.Equal(-1.0f, math.erf(-20.0f)); - } - - [Fact] - public void ErfinvInvertsErf() - { - for (var i = -999; i <= 999; i++) - { - var y = i / 1000.0f; - var x = math.erfinv(y); - var roundTrip = math.erf(x); - Assert.True( - MathF.Abs(roundTrip - y) < 1e-5f, - $"erf(erfinv({y})) = {roundTrip}"); - } - } - - // Reference values from bisecting the platform's double-precision erf (Python's math.erf, - // glibc-backed), not this package's own erf, to 200 iterations over [-6, 6] -- effectively - // exact at float precision. This is what ErfinvInvertsErf cannot be: a check against this - // package's own erf only proves the two functions agree with each other, not that either is - // numerically correct. Soul measured the round-trip test alone to be blind to a coefficient - // change that degraded erfinv's worst error 300-400x (5.0e-7 to 2.0e-4). - [Theory] - // Expected values are computed for the actual float32-rounded input (e.g. the literal - // 0.999f is really 0.9990000128746033 as a double), not the decimal literal, because - // erfinv's derivative diverges near +-1: at y = 0.999f that rounding alone moves the - // true answer by ~2.6e-6, larger than the test's own error bar, if ignored. - [InlineData(0.0f, 0.0)] - [InlineData(0.1f, 0.08885599182530649)] - [InlineData(-0.1f, -0.08885599182530649)] - [InlineData(0.3f, 0.2724627261055238)] - [InlineData(-0.3f, -0.2724627261055238)] - [InlineData(0.5f, 0.4769362762044699)] - [InlineData(-0.5f, -0.4769362762044699)] - [InlineData(0.7f, 0.7328690598827587)] - [InlineData(-0.7f, -0.732869059882759)] - [InlineData(0.9f, 1.1630870719457724)] - [InlineData(-0.9f, -1.1630870719457729)] - [InlineData(0.95f, 1.3859037522360764)] - [InlineData(-0.95f, -1.3859037522360773)] - [InlineData(0.99f, 1.8213866009002766)] - [InlineData(-0.99f, -1.8213866009002793)] - [InlineData(0.999f, 2.3267563267961435)] - [InlineData(-0.999f, -2.3267563267961657)] - [InlineData(0.9999f, 2.751035437903192)] - [InlineData(-0.9999f, -2.751035437903383)] - public void ErfinvMatchesReferenceValues(float y, double expected) - { - Assert.True( - Math.Abs(math.erfinv(y) - expected) <= 2e-6, - $"erfinv({y}) = {math.erfinv(y)}, expected {expected}"); - } - - [Fact] - public void ErfinvAtDomainEdgesAndBeyond() - { - // Domain is [-1, 1]. The edges are the correctly-signed infinite limits; anything - // outside, including +-infinity itself, has no real inverse and is NaN. - Assert.Equal(float.PositiveInfinity, math.erfinv(1.0f)); - Assert.Equal(float.NegativeInfinity, math.erfinv(-1.0f)); - Assert.True(float.IsNaN(math.erfinv(1.0001f))); - Assert.True(float.IsNaN(math.erfinv(-1.0001f))); - Assert.True(float.IsNaN(math.erfinv(2.0f))); - Assert.True(float.IsNaN(math.erfinv(-2.0f))); - Assert.True(float.IsNaN(math.erfinv(float.PositiveInfinity))); - Assert.True(float.IsNaN(math.erfinv(float.NegativeInfinity))); - Assert.True(float.IsNaN(math.erfinv(float.NaN))); - } - - // The deleted ErfinvIsMonotonicallyIncreasing asserted a property erfinv does not have: - // Soul measured 9662 backward steps scanning every representable float32 in [0, 0.999999], - // first at y = 0.00022214651, worst drop 5.960464e-8 (one ULP at that scale) -- invisible - // only because that fixture stepped by 0.001. erf has the same shape: 100 backward steps - // over [0, 4.5], worst drop 1.192093e-7. Pin what is actually true: monotone to within a - // tolerance comfortably above that measured noise floor. - [Fact] - public void ErfinvIsMonotonicWithinFloatingPointTolerance() - { - const float tolerance = 1e-6f; - var previous = float.NegativeInfinity; - for (var i = -999; i <= 999; i++) - { - var y = i / 1000.0f; - var x = math.erfinv(y); - Assert.True( - x >= previous - tolerance, - $"erfinv({y}) = {x} dropped more than {tolerance} below previous value {previous}"); - previous = x; - } - } - - // One property the consumer needs, not the whole of correctness: fire control turns - // adjacent erf values into a cell's probability mass, so a backward step in erf would - // show up as a negative mass. An erf that returned a constant would pass this and is - // caught by ErfMatchesReferenceValues instead. - // Soul checked these geometries clean: 16/64/256/1024/4096 cells over - // +-4 sigma, plus a tight 1 sigma spread and a very tight 0.25 sigma spread. - [Theory] - [InlineData(16, 4f)] - [InlineData(64, 4f)] - [InlineData(256, 4f)] - [InlineData(1024, 4f)] - [InlineData(4096, 4f)] - [InlineData(256, 1f)] - [InlineData(64, 0.25f)] - public void ErfCellMassesStayNonNegativeAcrossRealisticGeometries(int cells, float sigmaRange) - { - var lo = -sigmaRange; - var hi = sigmaRange; - var step = (hi - lo) / cells; - var previous = math.erf(lo / MathF.Sqrt(2f)); - for (var i = 1; i <= cells; i++) - { - var edge = lo + step * i; - var current = math.erf(edge / MathF.Sqrt(2f)); - var mass = current - previous; - Assert.True(mass >= 0f, $"cell {i} of {cells} over +-{sigmaRange} sigma has negative mass {mass}"); - previous = current; - } - } } diff --git a/packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs b/packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs deleted file mode 100644 index 78a3b795..00000000 --- a/packages/cultmath/tests/CultMath.Tests/NoiseBoundTests.cs +++ /dev/null @@ -1,2642 +0,0 @@ -using CultMath; -using Xunit; -using static CultMath.math; - -namespace CultMath.Tests; - -/// -/// The noise bounds (design.md, "Intervals" and "Affine forms"): iv_snoise_ball and iv_fbm_ball enclose -/// their functions over a ball, a domain warp bounded by D is enclosed by enlarging the radius by D, or -/// by the centred warp, SNOISE_LIPSCHITZ, SNOISE2_LIPSCHITZ and SNOISE_HESSIAN have measured provenance, iv_frustum_ball encloses a screen tile's rays over a depth segment, the bound -/// composed from an analytic envelope and the noise ball encloses the density, and a tile march over -/// fields with authored empty space is measured against a dense one for the same transmittance. Lines -/// starting IV-REPORT carry the numbers the cut report quotes. -/// -/// Hand mutations of iv_frustum_ball that TileBallEnclosesEveryRaySegment must kill: z0 for z1 in the -/// lateral term (z0 * footprintPerDepth); |m_c| for |(m_c, 1)| in the depth term; the warp dropped; the -/// rounding widening dropped (which the degenerate family's enclosure check alone must catch). Hand -/// mutations of the test's own fields and marches: w(z0) for w(z1) in VoidField.WeightBound must fail -/// WeightBoundEnclosesOneSignedNoise; CarveRadius for HollowRadius in the lo test of VoidField.Compose -/// and BodyDepth without |dir| must fail AnalyticBodyMatchesFineMarch; the footprint march's pre-body -/// integration dropped, or LodStep doubled, must fail IntervalSkipHalvesEvaluations's depth agreement. -/// -public sealed class NoiseBoundTests -{ - private readonly ITestOutputHelper output; - - public NoiseBoundTests(ITestOutputHelper output) => this.output = output; - - private static float Uniform(System.Random random, float lo, float hi) => lo + (hi - lo) * random.NextSingle(); - - private static float LogUniform(System.Random random, float lo, float hi) => - MathF.Exp(Uniform(random, MathF.Log(lo), MathF.Log(hi))); - - private static float3 UnitVector(System.Random random) - { - float3 v; - do - { - v = new float3(Uniform(random, -1.0f, 1.0f), Uniform(random, -1.0f, 1.0f), Uniform(random, -1.0f, 1.0f)); - } - while (dot(v, v) > 1.0f || dot(v, v) < 1.0e-4f); - - return normalize(v); - } - - // The first eight points of a ball are on its surface, where the bound is closest to binding; the - // rest are uniform in its volume. - private static float3 PointInBall(System.Random random, float3 centre, float radius, int index) => - centre + UnitVector(random) * (index < 8 ? radius : radius * MathF.Cbrt(random.NextSingle())); - - private static float3 RandomCentre(System.Random random) => - new(Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f)); - - private static bool Inside(float value, float2 bound) => value >= bound.x && value <= bound.y; - - [Fact] - public void SnoiseBallEnclosesPoints() - { - var random = new System.Random(0xBA11); - for (var b = 0; b < 2000; b++) - { - var centre = RandomCentre(random); - var radius = LogUniform(random, 1.0e-3f, 1.0e3f); - var bound = iv_snoise_ball(centre, radius); - for (var i = 0; i < 64; i++) - { - var x = PointInBall(random, centre, radius, i); - Assert.True(Inside(snoise(x), bound), $"iv_snoise_ball({centre}, {radius:R}) = {bound} misses snoise({x}) = {snoise(x):R}"); - } - } - } - - [Fact] - public void FbmBallEnclosesPoints() - { - var random = new System.Random(0xFB11); - for (var b = 0; b < 2000; b++) - { - var centre = RandomCentre(random); - var radius = LogUniform(random, 1.0e-3f, 1.0e3f); - var octaves = random.Next(0, 7); - var lacunarity = Uniform(random, 1.5f, 2.5f); - var gain = Uniform(random, 0.3f, 0.7f); - var bound = iv_fbm_ball(centre, radius, octaves, lacunarity, gain); - for (var i = 0; i < 64; i++) - { - var x = PointInBall(random, centre, radius, i); - var value = fbm_grad(x, octaves, lacunarity, gain).w; - Assert.True(Inside(value, bound), $"iv_fbm_ball({centre}, {radius:R}, {octaves}, {lacunarity:R}, {gain:R}) = {bound} misses {value:R} at {x}"); - } - } - } - - /// - /// The site's march rests on this: a point x in the ball (c, r), displaced by a flow of length at most - /// D, lies in the ball (c, r + D), so snoise of the warped point lies in iv_snoise_ball(c, r + D). The - /// geometric check allows one part in 1e5 for the rounding of x + flow. - /// - [Fact] - public void WarpedPointsStayEnclosed() - { - var random = new System.Random(0x3A4B); - for (var b = 0; b < 2000; b++) - { - var centre = RandomCentre(random); - var radius = LogUniform(random, 1.0e-3f, 2.0f); - var warp = Uniform(random, 0.0f, 1.0f); - var bound = iv_snoise_ball(centre, radius + warp); - for (var i = 0; i < 64; i++) - { - var x = PointInBall(random, centre, radius, i); - var flow = UnitVector(random) * (warp * MathF.Sqrt(random.NextSingle())); - var warped = x + flow; - Assert.True(length(warped - centre) <= (radius + warp) * (1.0f + 1.0e-5f), $"warped point {warped} leaves the ball ({centre}, {radius + warp:R})"); - Assert.True(Inside(snoise(warped), bound), $"iv_snoise_ball({centre}, {radius + warp:R}) = {bound} misses snoise({warped}) = {snoise(warped):R}"); - } - } - } - - // ---- The tile ball and the composed bound ---- - - // One tile case of TileBallEnclosesEveryRaySegment: the r2 domain, or one of the extreme families - // where float32 rounding of the centre is largest against the radius (Soul's verdict s1). - internal static (int N, float Focal, float2 Slope, float Z0, float Z1, float Warp) DrawBallCase(System.Random random, string family) - { - int[] sizes = { 1, 4, 8, 16 }; - float[] depths = { 12.0f, 1000.0f, 2400.0f }; - var n = sizes[random.Next(sizes.Length)]; - var focal = Uniform(random, 500.0f, 3000.0f); - var slope = new float2(Uniform(random, -0.77f, 0.77f), Uniform(random, -0.77f, 0.77f)); - var depth = depths[random.Next(depths.Length)]; - var z0 = random.Next(4) == 0 ? 0.0f : Uniform(random, 0.0f, depth * 0.9f); - var z1 = z0 + LogUniform(random, 1.0e-3f * depth, depth - z0); - var warp = random.Next(4) == 0 ? 0.0f : LogUniform(random, 1.0e-3f, 60.0f); - float Signed(float magnitude) => random.Next(2) == 0 ? -magnitude : magnitude; - switch (family) - { - case "degenerate": - z0 = z1 = LogUniform(random, 1.0e-3f * depth, depth); - break; - case "thin": - z0 = z1 - 1.0e-6f * z1; - break; - case "wide slope": - slope = new float2(Signed(LogUniform(random, 1.0e-3f, 707.0f)), Signed(LogUniform(random, 1.0e-3f, 707.0f))); - break; - case "far": - z1 = LogUniform(random, 1.0e4f, 1.0e7f); - z0 = z1 - z1 * LogUniform(random, 1.0e-6f, 1.0f); - break; - case "from the camera": - z0 = 0.0f; - z1 = LogUniform(random, 1.0e-3f, 1.0f); - break; - case "tiny focal": - focal = LogUniform(random, 1.0f, 500.0f); - break; - case "huge warp": - warp = LogUniform(random, 60.0f, 1.0e6f); - break; - } - - return (n, focal, slope, z0, z1, warp); - } - - /// - /// iv_frustum_ball encloses every exact point of every ray of an N x N tile over a depth segment, - /// sub-pixel jitter included, each point then moved by a flow of length at most warp, with no - /// tolerance: the distance is taken in double from the float32 ball to the point (m z, z) formed in - /// double from the float32 slope and depth. 2,000 seeded tiles of the r2 domain (N in {1, 4, 8, 16}, - /// f in [500, 3000], |m_c| up to 1.1, segments over the slab's, the fog's and the void's depth ranges, - /// a quarter starting at the camera) x 64 points, and 2,000 tiles of each extreme family (z0 == z1; - /// z1 - z0 = 1e-6 z1; |m_c| up to 1000; z up to 1e7; z0 = 0, z1 down to 1e-3; f down to 1; warp up to - /// 1e6) x the 8 points at the footprint's corners at both depth ends. Every corner point's flow is - /// full-length and points outward from the ball's centre. It also pins the ball to the derivation in - /// double, both ways: the centre within 2^-22 |c|_1, and r <= ball.w <= r + 2^-19 (r + |c|_1), so a - /// ball that forgets its rounding widening fails and one that grows past it fails. Misses and pin - /// failures are counted per family and reported together. Each tile's camera is drawn on its own, as a - /// moving camera's frames are: no ball, mask or probe result is carried from one to the next. - /// - [Fact] - public void TileBallEnclosesEveryRaySegment() - { - var random = new System.Random(0x711E); - string[] families = { "r2 domain", "degenerate", "thin", "wide slope", "far", "from the camera", "tiny focal", "huge warp" }; - var misses = new Dictionary(); - var pins = new Dictionary(); - var witness = new List(); - foreach (var family in families) - { - misses[family] = 0; - pins[family] = 0; - for (var t = 0; t < 2000; t++) - { - var (n, focal, slope, z0, z1, warp) = DrawBallCase(random, family); - var half = n / (2.0f * focal); - var footprint = n / (MathF.Sqrt(2.0f) * focal); - var ball = iv_frustum_ball(slope, z0, z1, footprint, warp); - var (cx, cy, cz, w) = ((double)ball.x, (double)ball.y, (double)ball.z, (double)ball.w); - - var zm = (z0 + (double)z1) / 2.0; - var (ex, ey) = (slope.x * zm, slope.y * zm); - var c1 = Math.Abs(ex) + Math.Abs(ey) + Math.Abs(zm); - var radius = (z1 - (double)z0) / 2.0 * Math.Sqrt((double)slope.x * slope.x + (double)slope.y * slope.y + 1.0) + z1 * (double)footprint + warp; - var centreOff = Math.Abs(cx - ex) + Math.Abs(cy - ey) + Math.Abs(cz - zm); - if (!(centreOff <= Math.ScaleB(c1, -22) && radius <= w && w <= radius + Math.ScaleB(radius + c1, -19))) - { - pins[family]++; - if (witness.Count < 8) - witness.Add($"{family} pin: iv_frustum_ball({slope}, {z0:R}, {z1:R}, {footprint:R}, {warp:R}) = {ball}; derivation centre ({ex:R}, {ey:R}, {zm:R}), radius {radius:R}"); - } - - for (var i = 0; i < (family == "r2 domain" ? 64 : 8); i++) - { - var offset = i < 8 - ? new float2((i & 1) == 0 ? -half : half, (i & 2) == 0 ? -half : half) - : new float2(Uniform(random, -half, half), Uniform(random, -half, half)); - var z = i < 8 ? ((i & 4) == 0 ? z0 : z1) : Uniform(random, z0, z1); - var m = slope + offset; - var (px, py, pz) = (m.x * (double)z, m.y * (double)z, (double)z); - double fx, fy, fz; - if (i < 8) - { - // Outward: along the corner's direction from the centre, full length. - var (dx, dy, dz) = (px - cx, py - cy, pz - cz); - var away = Math.Sqrt(dx * dx + dy * dy + dz * dz); - (fx, fy, fz) = away > 0.0 ? (dx / away * warp, dy / away * warp, dz / away * warp) : (warp, 0.0, 0.0); - } - else - { - var flow = UnitVector(random) * (warp * MathF.Sqrt(random.NextSingle())); - (fx, fy, fz) = (flow.x, flow.y, flow.z); - } - - var (qx, qy, qz) = (px + fx - cx, py + fy - cy, pz + fz - cz); - var distance = Math.Sqrt(qx * qx + qy * qy + qz * qz); - if (!(distance <= w)) - { - misses[family]++; - if (witness.Count < 8) - witness.Add($"{family}: iv_frustum_ball({slope}, {z0:R}, {z1:R}, {footprint:R}, {warp:R}) = {ball} misses slope {m}, depth {z:R} by {(distance - w) / w:R} r"); - } - } - } - } - - Assert.True(misses.Values.Sum() + pins.Values.Sum() == 0, - "misses " + string.Join(", ", families.Select(f => $"{f} {misses[f]}")) + "; pin failures " + string.Join(", ", families.Select(f => $"{f} {pins[f]}")) - + Environment.NewLine + string.Join(Environment.NewLine, witness)); - } - - /// - /// intervals-enclose for the composition the site and Aetheria use: over 2,000 seeded tile slices - /// (the deep well, the shallow wells and inside the fog, each under the centred-warp interval bound - /// and the affine bound; the void at every grid point, the shipped void and LOD-far; N in - /// {1, 4, 8, 16}; a camera drawn per tile) the bound composed from the envelope over the slice's box, - /// its fade, and the noise enclosure encloses the density at 64 points of the slice, each sampled - /// through the field's own warp, with no tolerance. The void's footprint-truncated density (octave weights) is checked - /// against the same bound; a quarter of the slices are LOD-far's, where the weights are strictly - /// between 0 and 1 and at 0, and the test asserts it sampled both. - /// - [Fact] - public void EnvelopeBoundEnclosesDensity() - { - var random = new System.Random(0xE7B0); - int[] sizes = { 1, 4, 8, 16 }; - var fog = new List(); - foreach (var mode in new[] { BoundMode.Interval, BoundMode.Affine }) - { - fog.Add(FogField.DeepWell(FogField.AetheriaWarp, mode)); - fog.Add(FogField.Wells(FogField.AetheriaWarp, mode)); - fog.Add(FogField.InsideFog(FogField.AetheriaWarp, mode)); - } - - var fields = new List(); - foreach (var rh in VoidField.HollowRadii) - foreach (var offset in VoidField.CameraOffsets) - foreach (var ramp in VoidField.Ramps) - fields.Add(new VoidField(rh, ramp, offset.Fraction, offset.Name)); - fields.Add(VoidField.Shipped()); - fields.Add(VoidField.LodFar()); - var counts = new Counts(); - var (partial, zero) = (0, 0); - for (var t = 0; t < 2000; t++) - { - var field = t % 2 == 0 ? fog[(t / 2) % fog.Count] : t % 4 == 1 ? fields[^1] : fields[random.Next(fields.Count)]; - var tile = field.DrawTile(random, sizes[random.Next(sizes.Length)]); - var near = field.Grid[0]; - var far = field.Grid[^1]; - var z0 = Uniform(random, near, far * 0.9f); - var z1 = z0 + LogUniform(random, 1.0e-3f * far, far - z0); - var bound = field.Bound(tile, z0, z1, gated: false, counts); - for (var i = 0; i < 64; i++) - { - var m = tile.PixelSlope(random.Next(tile.N), random.Next(tile.N), random.NextSingle(), random.NextSingle()); - var z = i < 2 ? (i == 0 ? z0 : z1) : Uniform(random, z0, z1); - var density = field.Density(tile, m, z, lod: false, counts); - Assert.True(Inside(density, bound), $"{field.Name}: bound {bound} over [{z0:R}, {z1:R}] misses density {density:R} at slope {m}, depth {z:R}"); - if (field is VoidField voidField) - { - var (wc, wd) = voidField.Weights(z); - partial += (wc > 0.0f && wc < 1.0f) || (wd > 0.0f && wd < 1.0f) ? 1 : 0; - zero += wd == 0.0f ? 1 : 0; - var truncated = field.Density(tile, m, z, lod: true, counts); - Assert.True(Inside(truncated, bound), $"{field.Name}: bound {bound} misses the truncated density {truncated:R} at slope {m}, depth {z:R}"); - } - } - } - - // The truncated check is not vacuous: some samples carry an octave weight strictly inside (0, 1) - // and some a fine weight of 0 (LOD-far reaches both). - Assert.True(partial > 0 && zero > 0, $"octave weights in (0, 1) at {partial} samples and fine weight 0 at {zero}"); - } - - /// - /// VoidField's octave weight bound over [z0, z1] encloses each octave's weight at every depth of the - /// segment, and, for a one-signed noise interval n = [0.25, 1], the weighted noise w(z) n_s lies in - /// iv_mul(bound, n). 2,000 LOD-far segments with z0 ~ U(1460, 0.95 grid end), z1 ~ U(z0, grid end), - /// 16 depths each including both ends. A bound whose lower end is w(z0) misses w(z1) 0.25 wherever the - /// weight falls across the segment. - /// - [Fact] - public void WeightBoundEnclosesOneSignedNoise() - { - var field = VoidField.LodFar(); - var random = new System.Random(0x3B0D); - var end = field.Grid[^1]; - var n = new float2(0.25f, 1.0f); - for (var i = 0; i < 2000; i++) - { - var z0 = Uniform(random, 1460.0f, 0.95f * end); - var z1 = Uniform(random, z0, end); - var (coarseBound, fineBound) = field.WeightBounds(z0, z1); - for (var s = 0; s < 16; s++) - { - var z = s == 0 ? z0 : s == 15 ? z1 : Uniform(random, z0, z1); - var (coarse, fine) = field.Weights(z); - foreach (var (octave, w, bound) in new[] { ("coarse", coarse, coarseBound), ("fine", fine, fineBound) }) - { - Assert.True(Inside(w, bound), $"{octave} weight {w:R} at depth {z:R} lies outside its bound {bound} over [{z0:R}, {z1:R}]"); - var weighted = iv_mul(bound, n); - foreach (var ns in new[] { 0.25f, Uniform(random, 0.25f, 1.0f), 1.0f }) - Assert.True(Inside(w * ns, weighted), $"{octave} weight {w:R} x noise {ns:R} at depth {z:R} lies outside iv_mul({bound}, {n}) = {weighted} over [{z0:R}, {z1:R}]"); - } - } - } - } - - // ---- The Lipschitz constant ---- - - private static float GradientNorm(float3 p) - { - var g = snoise_grad(p); - return MathF.Sqrt(g.x * g.x + g.y * g.y + g.z * g.z); - } - - // Hill-climbs |snoise_grad| from p: the ascent direction is the central difference of |grad|, the - // step grows on success and halves on failure. Returns the largest |grad| it reached. - private static float AscendGradientNorm(float3 p) - { - const float h = 1.0e-3f; - var step = 1.0e-2f; - var best = GradientNorm(p); - for (var k = 0; k < 200 && step > 1.0e-6f; k++) - { - var d = new float3( - GradientNorm(p + new float3(h, 0.0f, 0.0f)) - GradientNorm(p - new float3(h, 0.0f, 0.0f)), - GradientNorm(p + new float3(0.0f, h, 0.0f)) - GradientNorm(p - new float3(0.0f, h, 0.0f)), - GradientNorm(p + new float3(0.0f, 0.0f, h)) - GradientNorm(p - new float3(0.0f, 0.0f, h))); - if (dot(d, d) == 0.0f) - break; - var q = p + normalize(d) * step; - var value = GradientNorm(q); - if (value > best) - { - p = q; - best = value; - step *= 1.5f; - } - else - { - step *= 0.5f; - } - } - - return best; - } - - // Same climb on |snoise|, along the value's own analytic gradient. - private static float AscendAbsValue(float3 p) - { - var step = 1.0e-2f; - var best = MathF.Abs(snoise(p)); - for (var k = 0; k < 200 && step > 1.0e-6f; k++) - { - var g = snoise_grad(p); - var d = new float3(g.x, g.y, g.z) * (g.w < 0.0f ? -1.0f : 1.0f); - if (dot(d, d) == 0.0f) - break; - var q = p + normalize(d) * step; - var value = MathF.Abs(snoise(q)); - if (value > best) - { - p = q; - best = value; - step *= 1.5f; - } - else - { - step *= 0.5f; - } - } - - return best; - } - - // The largest |snoise_grad| over `samples` seeded points in [-256, 256]^3, the largest after refining - // the `refine` largest of them by ascent, and the start whose ascent reached it (the witness). - private static (float Sampled, float Refined, float3 Witness) MeasureGradient(int seed, int samples, int refine) - { - var random = new System.Random(seed); - var points = new float3[samples]; - var norms = new float[samples]; - for (var i = 0; i < samples; i++) - { - points[i] = new float3(Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f)); - norms[i] = GradientNorm(points[i]); - } - - var order = Enumerable.Range(0, samples).OrderByDescending(i => norms[i]).Take(Math.Max(refine, 1)).ToArray(); - var refined = norms[order[0]]; - var witness = points[order[0]]; - foreach (var i in order.Take(refine)) - { - var value = AscendGradientNorm(points[i]); - if (value > refined) - { - refined = value; - witness = points[i]; - } - } - - return (norms[order[0]], refined, witness); - } - - /// - /// The provenance of SNOISE_LIPSCHITZ: the largest |snoise_grad| over 1e6 seeded points, the 1e4 - /// largest refined by gradient ascent, times 1.10. Prints the start whose ascent reached the maximum, - /// which LipschitzConstantPinsSampledGradients climbs from again. Also prints the largest |snoise| - /// reached the same way, which is what lets iv_snoise_ball intersect with [-1, 1]. Slow; run - /// explicitly after any change to the snoise kernel and re-pin the constant and the witness. - /// - [Fact(Explicit = true)] - [Trait("Category", "Slow")] - public void MeasureLipschitz() - { - var (sampled, refined, witness) = MeasureGradient(0x11B5, 1_000_000, 10_000); - var random = new System.Random(0xAB5); - var valueStarts = Enumerable.Range(0, 10_000) - .Select(_ => new float3(Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f))); - var maxValue = valueStarts.Max(AscendAbsValue); - output.WriteLine($"IV-REPORT lipschitz: max |snoise_grad| sampled {sampled:R}, refined {refined:R}, x 1.10 = {refined * 1.10f:R}, witness ({witness.x:R}, {witness.y:R}, {witness.z:R}); max |snoise| refined {maxValue:R}"); - Assert.True(refined <= SNOISE_LIPSCHITZ, $"measured {refined:R} exceeds SNOISE_LIPSCHITZ {SNOISE_LIPSCHITZ:R}"); - Assert.True(maxValue < 1.0f, $"|snoise| reaches {maxValue:R}; iv_snoise_ball may not intersect with [-1, 1]"); - } - - // The start MeasureLipschitz printed as its witness. - private static readonly float3 LipschitzWitness = new(229.92526f, 73.37927f, -66.14595f); - - /// - /// Pins SNOISE_LIPSCHITZ: no |snoise_grad| over 1e5 seeded points exceeds it, and the ascent from - /// MeasureLipschitz's witness reaches a maximum that, times 1.10, is the constant to within half a - /// percent, so a constant lowered (or raised) by 1% fails here. - /// - [Fact] - public void LipschitzConstantPinsSampledGradients() - { - var (sampled, _, _) = MeasureGradient(0x11B6, 100_000, 0); - Assert.True(sampled <= SNOISE_LIPSCHITZ, $"|snoise_grad| reaches {sampled:R}, above SNOISE_LIPSCHITZ {SNOISE_LIPSCHITZ:R}"); - var refined = AscendGradientNorm(LipschitzWitness); - Assert.True(refined <= SNOISE_LIPSCHITZ, $"|snoise_grad| reaches {refined:R}, above SNOISE_LIPSCHITZ {SNOISE_LIPSCHITZ:R}"); - var ratio = SNOISE_LIPSCHITZ / (1.10f * refined); - Assert.True(MathF.Abs(ratio - 1.0f) <= 0.005f, $"SNOISE_LIPSCHITZ is {ratio:R} times 1.10 x the re-measured {refined:R}; re-run MeasureLipschitz and re-pin"); - } - - // ---- The curvature and 2D Lipschitz constants (math.Affine.cs, math.Interval.cs) ---- - - // Central differences over exact float32 steps: the step actually taken is (p + h) - p in float32, so - // the quotient is not skewed by the rounding of p + h far from the origin. - private static double Step(float x, float h, out double back) { back = x - (double)(x - h); return (x + h) - (double)x; } - - // The spectral norm (largest absolute eigenvalue) of the symmetrised Hessian of snoise(float3) at p, - // from central differences of snoise_grad at h = 1e-3. - private static double HessianNorm(float3 p) - { - const float h = 1.0e-3f; - var m = new double[3, 3]; - for (var a = 0; a < 3; a++) - { - var e = new float3(a == 0 ? h : 0.0f, a == 1 ? h : 0.0f, a == 2 ? h : 0.0f); - var forward = Step(a == 0 ? p.x : a == 1 ? p.y : p.z, h, out var back); - var gp = snoise_grad(p + e); - var gm = snoise_grad(p - e); - m[0, a] = (gp.x - (double)gm.x) / (forward + back); - m[1, a] = (gp.y - (double)gm.y) / (forward + back); - m[2, a] = (gp.z - (double)gm.z) / (forward + back); - } - - var (a00, a11, a22) = (m[0, 0], m[1, 1], m[2, 2]); - var (a01, a02, a12) = ((m[0, 1] + m[1, 0]) / 2, (m[0, 2] + m[2, 0]) / 2, (m[1, 2] + m[2, 1]) / 2); - var p1 = a01 * a01 + a02 * a02 + a12 * a12; - if (p1 == 0.0) - return Math.Max(Math.Abs(a00), Math.Max(Math.Abs(a11), Math.Abs(a22))); - var q = (a00 + a11 + a22) / 3; - var p2 = (a00 - q) * (a00 - q) + (a11 - q) * (a11 - q) + (a22 - q) * (a22 - q) + 2 * p1; - var s = Math.Sqrt(p2 / 6); - var (b00, b11, b22, b01, b02, b12) = ((a00 - q) / s, (a11 - q) / s, (a22 - q) / s, a01 / s, a02 / s, a12 / s); - var r = Math.Clamp((b00 * (b11 * b22 - b12 * b12) - b01 * (b01 * b22 - b12 * b02) + b02 * (b01 * b12 - b11 * b02)) / 2, -1.0, 1.0); - var phi = Math.Acos(r) / 3; - var largest = q + 2 * s * Math.Cos(phi); - var smallest = q + 2 * s * Math.Cos(phi + 2 * Math.PI / 3); - return Math.Max(Math.Abs(largest), Math.Abs(smallest)); - } - - // The gradient length of snoise(float2) at p, from central differences at h = 1e-3. - private static double Gradient2Norm(float2 p) - { - const float h = 1.0e-3f; - var fx = Step(p.x, h, out var bx); - var fy = Step(p.y, h, out var by); - var gx = (snoise(p + new float2(h, 0.0f)) - (double)snoise(p - new float2(h, 0.0f))) / (fx + bx); - var gy = (snoise(p + new float2(0.0f, h)) - (double)snoise(p - new float2(0.0f, h))) / (fy + by); - return Math.Sqrt(gx * gx + gy * gy); - } - - // Hill-climbs f from p as AscendGradientNorm does: the ascent direction is f's central difference, - // the step grows on success and halves on failure. Returns the largest value reached. - private static double Ascend(Func f, float3 p) => AscendPoint(f, p).Best; - - private static (double Best, float3 At) AscendPoint(Func f, float3 p) - { - const float h = 1.0e-3f; - var step = 1.0e-2f; - var best = f(p); - for (var k = 0; k < 200 && step > 1.0e-6f; k++) - { - var d = new float3( - (float)(f(p + new float3(h, 0.0f, 0.0f)) - f(p - new float3(h, 0.0f, 0.0f))), - (float)(f(p + new float3(0.0f, h, 0.0f)) - f(p - new float3(0.0f, h, 0.0f))), - (float)(f(p + new float3(0.0f, 0.0f, h)) - f(p - new float3(0.0f, 0.0f, h)))); - if (dot(d, d) == 0.0f) - break; - var q = p + normalize(d) * step; - var value = f(q); - if (value > best) - { - p = q; - best = value; - step *= 1.5f; - } - else - { - step *= 0.5f; - } - } - - return (best, p); - } - - private static double Ascend2(Func f, float2 p) => Ascend(q => f(new float2(q.x, q.y)), new float3(p.x, p.y, 0.0f)); - - // The largest f over `samples` seeded points of [-256, 256]^dims, the largest after refining the - // `refine` largest by ascent, and the start whose ascent reached it (the witness). - private static (double Sampled, double Refined, float3 Witness) MeasureMax(Func f, bool planar, int seed, int samples, int refine) - { - var random = new System.Random(seed); - var points = new float3[samples]; - var values = new double[samples]; - for (var i = 0; i < samples; i++) - { - points[i] = new float3(Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f), planar ? 0.0f : Uniform(random, -256.0f, 256.0f)); - values[i] = f(points[i]); - } - - var order = Enumerable.Range(0, samples).OrderByDescending(i => values[i]).Take(Math.Max(refine, 1)).ToArray(); - var refined = values[order[0]]; - var witness = points[order[0]]; - foreach (var i in order.Take(refine)) - { - var value = planar ? Ascend2(q => f(new float3(q.x, q.y, 0.0f)), new float2(points[i].x, points[i].y)) : Ascend(f, points[i]); - if (value > refined) - { - refined = value; - witness = points[i]; - } - } - - return (values[order[0]], refined, witness); - } - - private static double Gradient2At(float3 p) => Gradient2Norm(new float2(p.x, p.y)); - - /// - /// The provenance of SNOISE_HESSIAN: the largest spectral norm of snoise's Hessian (HessianNorm) over - /// 1e6 seeded points of [-256, 256]^3, the 1e4 largest refined by ascent, times 1.10. Prints the - /// start whose ascent reached the maximum, which HessianConstantPinsSampledCurvature climbs from - /// again. Slow; run explicitly after any change to the snoise kernel and re-pin the constant and the - /// witness. - /// - [Fact(Explicit = true)] - [Trait("Category", "Slow")] - public void MeasureHessian() - { - var (sampled, refined, witness) = MeasureMax(HessianNorm, false, 0x4E55, 1_000_000, 10_000); - output.WriteLine($"IV-REPORT hessian: max |H| sampled {sampled:R}, refined {refined:R}, x 1.10 = {(float)(refined * 1.10):R}, witness ({witness.x:R}, {witness.y:R}, {witness.z:R})"); - Assert.True(refined <= SNOISE_HESSIAN, $"measured {refined:R} exceeds SNOISE_HESSIAN {SNOISE_HESSIAN:R}"); - } - - // The start MeasureHessian printed as its witness. - private static readonly float3 HessianWitness = new(-245.19885f, -53.01323f, -91.47363f); - - /// - /// Pins SNOISE_HESSIAN: no Hessian norm over 1e5 seeded points exceeds it, and the ascent from - /// MeasureHessian's witness reaches a maximum that, times 1.10, is the constant to within half a - /// percent, so a constant moved by 1% fails here. - /// - [Fact] - public void HessianConstantPinsSampledCurvature() - { - var (sampled, _, _) = MeasureMax(HessianNorm, false, 0x4E56, 100_000, 0); - Assert.True(sampled <= SNOISE_HESSIAN, $"the Hessian norm reaches {sampled:R}, above SNOISE_HESSIAN {SNOISE_HESSIAN:R}"); - var refined = Ascend(HessianNorm, HessianWitness); - Assert.True(refined <= SNOISE_HESSIAN, $"the Hessian norm reaches {refined:R}, above SNOISE_HESSIAN {SNOISE_HESSIAN:R}"); - var ratio = SNOISE_HESSIAN / (1.10 * refined); - Assert.True(Math.Abs(ratio - 1.0) <= 0.005, $"SNOISE_HESSIAN is {ratio:R} times 1.10 x the re-measured {refined:R}; re-run MeasureHessian and re-pin"); - } - - /// - /// SNOISE_HESSIAN where the curvature is realised. At the point the ascent from MeasureHessian's witness - /// reaches, the absolute second difference of snoise along 4,000 seeded directions u at step 0.05 has a - /// largest value within 10% of SNOISE_HESSIAN / 1.10 (the realised curvature is there, so the check - /// has teeth), and af_snoise(witness, r u, 0) encloses snoise(witness + eps r u) at eps in - /// {-1, -1/2, 0, 1/2, 1} for r in {0.1, 0.3} and every one of those directions, no tolerance: a constant - /// under the realised curvature (40 against about 50.6) misses on the directions near the top - /// eigenvector. The enclosure tests on random balls cannot see a constant 20% low; this and - /// HessianConstantPinsSampledCurvature are its defence. - /// - [Fact] - public void SnoiseFormEnclosesTheCurvatureWitness() - { - var (_, witness) = AscendPoint(HessianNorm, HessianWitness); - var random = new System.Random(0xCA7E); - var directions = Enumerable.Range(0, 4000).Select(_ => UnitVector(random)).ToArray(); - const float step = 0.05f; - var centreValue = snoise(witness); - var realised = directions.Max(u => Math.Abs(snoise(witness + u * step) + (double)snoise(witness - u * step) - 2.0 * centreValue) / ((double)step * step)); - output.WriteLine($"IV-REPORT curvature witness ({witness.x:R}, {witness.y:R}, {witness.z:R}): largest second difference {realised:R} against SNOISE_HESSIAN {SNOISE_HESSIAN:R}"); - Assert.True(realised >= 0.9 * SNOISE_HESSIAN / 1.10, $"the largest second difference at the witness is {realised:R}, under 0.9 SNOISE_HESSIAN / 1.10 = {0.9 * SNOISE_HESSIAN / 1.10:R}: the check has no teeth, or the constant moved"); - foreach (var u in directions) - foreach (var r in new[] { 0.1f, 0.3f }) - { - var form = af_snoise(witness, u * r, 0.0f); - foreach (var eps in new[] { -1.0f, -0.5f, 0.0f, 0.5f, 1.0f }) - { - var value = snoise(witness + u * (r * eps)); - Assert.True(Math.Abs(value - (form.x + (double)form.y * eps)) <= form.z, $"af_snoise(witness, {u * r}, 0) = {form} misses snoise = {value:R} at eps {eps:R}, direction {u}"); - } - } - } - - /// - /// The provenance of SNOISE2_LIPSCHITZ: the largest gradient length of snoise(float2) (Gradient2Norm) - /// over 1e6 seeded points of [-256, 256]^2, the 1e4 largest refined by ascent, times 1.10; and the - /// largest |snoise(float2)| reached by ascent from 1e4 starts, which is what lets iv_snoise_ball(float2) - /// intersect with [-1, 1]. Slow; run explicitly after any change to the 2D kernel and re-pin. - /// - [Fact(Explicit = true)] - [Trait("Category", "Slow")] - public void MeasureLipschitz2() - { - var (sampled, refined, witness) = MeasureMax(Gradient2At, true, 0x2D15, 1_000_000, 10_000); - var random = new System.Random(0x2D16); - var maxValue = Enumerable.Range(0, 10_000) - .Select(_ => new float2(Uniform(random, -256.0f, 256.0f), Uniform(random, -256.0f, 256.0f))) - .Max(p => Ascend2(q => Math.Abs(snoise(q)), p)); - output.WriteLine($"IV-REPORT lipschitz2: max |grad snoise2| sampled {sampled:R}, refined {refined:R}, x 1.10 = {(float)(refined * 1.10):R}, witness ({witness.x:R}, {witness.y:R}); max |snoise2| refined {maxValue:R}"); - Assert.True(refined <= SNOISE2_LIPSCHITZ, $"measured {refined:R} exceeds SNOISE2_LIPSCHITZ {SNOISE2_LIPSCHITZ:R}"); - Assert.True(maxValue < 1.0, $"|snoise2| reaches {maxValue:R}; iv_snoise_ball(float2) may not intersect with [-1, 1]"); - } - - // The start MeasureLipschitz2 printed as its witness. - private static readonly float2 Lipschitz2Witness = new(-67.12454f, -129.53296f); - - /// - /// Pins SNOISE2_LIPSCHITZ as LipschitzConstantPinsSampledGradients pins SNOISE_LIPSCHITZ: 1e5 seeded - /// points under it, and the ascent from MeasureLipschitz2's witness within half a percent of it / 1.10. - /// - [Fact] - public void Lipschitz2ConstantPins() - { - var (sampled, _, _) = MeasureMax(Gradient2At, true, 0x2D17, 100_000, 0); - Assert.True(sampled <= SNOISE2_LIPSCHITZ, $"|grad snoise2| reaches {sampled:R}, above SNOISE2_LIPSCHITZ {SNOISE2_LIPSCHITZ:R}"); - var refined = Ascend2(Gradient2Norm, Lipschitz2Witness); - Assert.True(refined <= SNOISE2_LIPSCHITZ, $"|grad snoise2| reaches {refined:R}, above SNOISE2_LIPSCHITZ {SNOISE2_LIPSCHITZ:R}"); - var ratio = SNOISE2_LIPSCHITZ / (1.10 * refined); - Assert.True(Math.Abs(ratio - 1.0) <= 0.005, $"SNOISE2_LIPSCHITZ is {ratio:R} times 1.10 x the re-measured {refined:R}; re-run MeasureLipschitz2 and re-pin"); - } - - /// - /// iv_snoise_ball(float2) encloses snoise(float2) over 2,000 seeded discs of radius log-uniform in - /// [1e-3, 1e3] x 64 points (the first eight on the rim), no tolerance. - /// - [Fact] - public void Snoise2BallEnclosesPoints() - { - var random = new System.Random(0xBA12); - for (var b = 0; b < 2000; b++) - { - var centre = new float2(Uniform(random, -20.0f, 20.0f), Uniform(random, -20.0f, 20.0f)); - var radius = LogUniform(random, 1.0e-3f, 1.0e3f); - var bound = iv_snoise_ball(centre, radius); - for (var i = 0; i < 64; i++) - { - var angle = Uniform(random, 0.0f, 2.0f * MathF.PI); - var x = centre + new float2(MathF.Cos(angle), MathF.Sin(angle)) * (i < 8 ? radius : radius * MathF.Sqrt(random.NextSingle())); - Assert.True(Inside(snoise(x), bound), $"iv_snoise_ball({centre}, {radius:R}) = {bound} misses snoise({x}) = {snoise(x):R}"); - } - } - } - - /// - /// The centred warp (design.md, "Affine forms"): over 2,000 seeded balls of the deep well's flow (warp - /// D = 60, period 8, flow frequency 1/512; centres in [-2000, 2000]^3, radius log-uniform in [1e-3, 500], - /// a time per ball) x 64 points, each phase's warped point p + flow(p) shift_k lies in the ball - /// (c + flow(c) shift_k, r + |shift_k| rho), r the radius widened by (|c|_1 + r) 2^-20 as iv_frustum_ball - /// widens its ball (the float32 point p is inside only up to that, which matters below a radius of 1), - /// geometry allowing one part in 1e5 for the rounding of the warped point, as WarpedPointsStayEnclosed does, and snoise of it, at the coverage frequency, lies - /// in iv_snoise_ball of that ball with no tolerance. Dropping rho fails: some warped points lie - /// farther than r from the moved centre. - /// - [Fact] - public void CentredWarpStaysEnclosed() - { - var noise = new WarpedNoise { F0 = 1.0f / FogField.NoiseScale, Warp = FogField.AetheriaWarp }; - var random = new System.Random(0xCE17); - var beyond = 0; - for (var b = 0; b < 2000; b++) - { - var centre = new float3(Uniform(random, -2000.0f, 2000.0f), Uniform(random, -2000.0f, 2000.0f), Uniform(random, -2000.0f, 2000.0f)); - var radius = LogUniform(random, 1.0e-3f, 500.0f); - var reach = radius + (abs(centre.x) + abs(centre.y) + abs(centre.z) + radius) * 9.5367431640625e-7f; - var time = Uniform(random, 0.0f, 100.0f); - var (_, shift0, shift1) = noise.Phases(time); - var (c0, g0, c1, g1) = noise.CentredWarp(centre, reach, time); - for (var i = 0; i < 64; i++) - { - var p = PointInBall(random, centre, radius, i); - var flow = noise.Flow(p); - foreach (var (shift, moved, grow) in new[] { (shift0, c0, g0), (shift1, c1, g1) }) - { - var warped = p + flow * shift; - var distance = length(warped - moved); - Assert.True(distance <= (reach + grow) * (1.0f + 1.0e-5f), $"warped point {warped} leaves the centred ball ({moved}, {reach + grow:R})"); - beyond += distance > radius ? 1 : 0; - var bound = iv_snoise_ball(moved * noise.F0, (reach + grow) * noise.F0); - var value = snoise(warped * noise.F0); - Assert.True(Inside(value, bound), $"iv_snoise_ball over the centred ball ({moved}, {reach + grow:R}) = {bound} misses snoise = {value:R} at {warped}"); - } - } - } - - output.WriteLine($"IV-REPORT centred warp: {beyond} of {2000 * 64 * 2} warped points lie beyond r from the moved centre"); - Assert.True(beyond > 0, "no warped point needs rho: the check cannot tell a centred warp without it"); - } - - /// - /// FlowVariation's width, pinned both ways: over 2,000 seeded balls (centres in [-2000, 2000]^3, radius - /// log-uniform in [1e-3, 500]) it equals min(sqrt(u^2 + v^2), 2) A, A = FlowAmplitude, with each of u and v - /// the reach of iv_snoise_ball(float2) at the flow plane's argument (plus its offset) plus the float32 - /// allowance 2^-14 + L2 2^-20 (|q|_1 + r FlowFrequency), to 0.3% (the float32 sum n + e rounds at 6e-8, against an allowance of 6e-5). The enclosure test sees the - /// allowance only where a float32 flow differs from the exact one by more than the bound's slack, which - /// on the CPU is rare (CentredWarpStaysEnclosed); this is the test that sees it. - /// - [Fact] - public void FlowVariationCarriesItsAllowance() - { - var noise = new WarpedNoise { F0 = 1.0f / FogField.NoiseScale, Warp = FogField.AetheriaWarp }; - var amplitude = noise.Warp * 2.0 / noise.Period; - var random = new System.Random(0xF10E); - double Reach(float2 q, double r) - { - var n = snoise(q); - var e = SNOISE2_LIPSCHITZ * r; - return Math.Max(Math.Min(e, 1.0 - n), Math.Min(e, n + 1.0)); - } - - for (var b = 0; b < 2000; b++) - { - var centre = new float3(Uniform(random, -2000.0f, 2000.0f), Uniform(random, -2000.0f, 2000.0f), Uniform(random, -2000.0f, 2000.0f)); - var radius = LogUniform(random, 1.0e-3f, 500.0f); - var rq = (double)radius * noise.FlowFrequency; - double Component(float2 offset) - { - var q = new float2(centre.x, centre.z) * noise.FlowFrequency + offset; - return Reach(q, rq) + Math.ScaleB(1.0, -14) + SNOISE2_LIPSCHITZ * Math.ScaleB(Math.Abs((double)q.x) + Math.Abs((double)q.y) + rq, -20); - } - - var (u, v) = (Component(new float2(17.0f, 3.0f)), Component(new float2(-5.0f, 41.0f))); - var expected = Math.Min(Math.Sqrt(u * u + v * v), 2.0) * amplitude; - var observed = noise.FlowVariation(centre, radius); - Assert.True(Math.Abs(observed - expected) <= 3.0e-3 * expected, $"FlowVariation({centre}, {radius:R}) = {observed:R}, the documented rule gives {expected:R}"); - } - } - - /// - /// The centred warp over an affine slice (FogField.Slice, the owner AffineBound reads): over 3,000 - /// seeded tile slices (the deep well, the shallow wells and inside the fog; N in {1, 4, 8, 16}; a - /// slice of length log-uniform in [0.5, 1500] from a drawn depth, so the axis is from far under to far - /// over the ball's radius) x 64 rays each (the first two at the slice's ends), each phase's warped ray - /// point p + flow(p) shift_k lies within radius + growth_k of moved_k + axis eps(z), eps(z) = - /// clamp((z - z_m) / h, -1, 1), no tolerance but one part in 1e5 for the rounding of the warped point. - /// The check sees each term of the slice: a reach of the ball's radius instead of |axis| + radius, a - /// phase's growth dropped, or rho halved leaves rays outside; the report counts the rays that need - /// each phase's growth, and the test asserts both phases have some. - /// - [Fact] - public void AffineWarpStaysEnclosed() - { - var random = new System.Random(0xAF77); - int[] sizes = { 1, 4, 8, 16 }; - var fields = new[] - { - FogField.DeepWell(FogField.AetheriaWarp, BoundMode.Affine), FogField.Wells(FogField.AetheriaWarp, BoundMode.Affine), FogField.InsideFog(FogField.AetheriaWarp, BoundMode.Affine), - }; - var needing = new[] { 0, 0 }; - for (var t = 0; t < 3000; t++) - { - var field = fields[t % fields.Length]; - var tile = field.DrawTile(random, sizes[random.Next(sizes.Length)]); - var z0 = Uniform(random, field.Grid[0], field.Grid[^1] * 0.9f); - var z1 = MathF.Min(z0 + LogUniform(random, 0.5f, 1500.0f), field.Grid[^1]); - var slice = field.Slice(tile, z0, z1); - var (_, shift0, shift1) = field.Noise.Phases(tile.Time); - var (zm, h) = (slice.Ball.z, slice.AxisCamera.z); - - // The arguments are built from the centred warp of the slice's own centre and reach, the detail - // from the unwarped set: no phase takes another's growth, nor the detail a warp. - var (moved0, grow0, moved1, grow1) = field.Noise.CentredWarp(slice.Centre, slice.Reach, tile.Time); - var (coverageFrequency, detailFrequency) = (field.Noise.F0, 4.0f * field.Noise.F0); - var expected = new[] - { - (slice.Coverage0, moved0 * coverageFrequency, (slice.Ball.w + grow0) * coverageFrequency), - (slice.Coverage1, moved1 * coverageFrequency, (slice.Ball.w + grow1) * coverageFrequency), - (slice.Detail, slice.Centre * detailFrequency + 17.0f, slice.Ball.w * detailFrequency), - }; - foreach (var (arg, centre, radius) in expected) - { - Assert.True(length(arg.Centre - centre) <= 1.0e-6f * (1.0f + length(centre)) && Math.Abs(arg.Radius - radius) <= 1.0e-6f * radius, $"{field.Name}: argument ({arg.Centre}, {arg.Radius:R}) is not the documented ({centre}, {radius:R})"); - } - - var reachRule = length(slice.Coverage0.Axis) / coverageFrequency + slice.Ball.w; - Assert.True(Math.Abs(slice.Reach - reachRule) <= 1.0e-5f * reachRule, $"{field.Name}: the reach {slice.Reach:R} is not |axis| + radius = {reachRule:R}"); - var axisTolerance = 1.0e-6f * length(slice.Coverage0.Axis); - Assert.True(length(slice.Coverage1.Axis - slice.Coverage0.Axis) <= axisTolerance && length(slice.Detail.Axis - slice.Coverage0.Axis * (detailFrequency / coverageFrequency)) <= 4.0f * axisTolerance, $"{field.Name}: the arguments do not share one axis"); - - for (var i = 0; i < 64; i++) - { - var m = tile.PixelSlope(random.Next(tile.N), random.Next(tile.N), random.NextSingle(), random.NextSingle()); - var z = i < 2 ? (i == 0 ? z0 : z1) : Uniform(random, z0, z1); - var p = tile.World(new float3(m.x * z, m.y * z, z)); - var flow = field.Noise.Flow(p); - var eps = h == 0.0f ? 0.0f : clamp((z - zm) / h, -1.0f, 1.0f); - var phases = new[] { (shift0, slice.Coverage0, coverageFrequency), (shift1, slice.Coverage1, coverageFrequency) }; - for (var k = 0; k < 2; k++) - { - var (shift, arg, frequency) = phases[k]; - var point = (p + flow * shift) * frequency; - var distance = length(point - (arg.Centre + arg.Axis * eps)); - Assert.True(distance <= arg.Radius * (1.0f + 1.0e-5f) + 1.0e-6f * length(point), $"{field.Name}: phase {k} warped ray point at depth {z:R} is {distance:R} from the argument's centre + axis eps, outside radius {arg.Radius:R} (reach {slice.Reach:R}, slice [{z0:R}, {z1:R}])"); - needing[k] += distance > slice.Ball.w * frequency ? 1 : 0; - } - - var detail = p * detailFrequency + 17.0f; - var detailDistance = length(detail - (slice.Detail.Centre + slice.Detail.Axis * eps)); - Assert.True(detailDistance <= slice.Detail.Radius * (1.0f + 1.0e-5f) + 1.0e-6f * length(detail), $"{field.Name}: the detail ray point at depth {z:R} is {detailDistance:R} from the argument's centre + axis eps, outside radius {slice.Detail.Radius:R} (slice [{z0:R}, {z1:R}])"); - } - } - - output.WriteLine($"IV-REPORT affine warp: rays beyond the unwarped radius, phase 0 {needing[0]}, phase 1 {needing[1]}"); - Assert.True(needing[0] > 0 && needing[1] > 0, $"no ray needs phase growth ({needing[0]}, {needing[1]}): the check cannot tell a slice without it"); - } - - /// - /// The affine composition earns its place: over seeded slices of the deep well and the shallow wells - /// (warp 0 and the Aetheria warp, N = 8, slices of length log-uniform in [0.5, 100] from a drawn - /// depth), AffineBound is exactly the intersection of its two sound pieces (the affine arithmetic's - /// own, and the interval composition over the forms' ranges), and where the interval piece does not - /// already prove the slice empty the affine piece is the narrower of the two in at least 35% of - /// them and the intersection is narrower than the interval piece in total width by at least 0.5% - /// (measured: 43% and 1.1%). The affine piece alone is wider in total (the shared symbol pays where the forms are - /// correlated and loses to the clipped ranges where they are not), so it is the intersection's gain - /// that measures it. The cost contract (IntervalSkipHalvesEvaluations) sees only the sum, in which - /// af_snoise's Hessian forms already beat iv_snoise_ball; this is the test that sees af_add, af_mul and - /// af_range, the shared symbol, break. - /// - [Fact] - public void AffineCompositionTightensItsRanges() - { - var random = new System.Random(0xAC0F); - var (open, wins, intersectionWidth, intervalWidth) = (0, 0, 0.0, 0.0); - foreach (var warp in new[] { 0.0f, FogField.AetheriaWarp }) - foreach (var field in new[] { FogField.DeepWell(warp, BoundMode.Affine), FogField.Wells(warp, BoundMode.Affine) }) - for (var t = 0; t < 1500; t++) - { - var tile = field.DrawTile(random, 8); - var z0 = Uniform(random, field.Grid[0], field.Grid[^1] * 0.9f); - var z1 = MathF.Min(z0 + LogUniform(random, 0.5f, 100.0f), field.Grid[^1]); - var (affine, interval) = field.AffinePieces(tile, z0, z1, new Counts()); - var bound = field.Bound(tile, z0, z1, false, new Counts()); - Assert.True(bound.x == max(affine.x, interval.x) && bound.y == min(affine.y, interval.y), $"{field.Name}: Bound {bound} is not the intersection of the affine piece {affine} and the interval piece {interval}"); - if (!(interval.y > 0.0f)) - continue; - open++; - wins += affine.y - affine.x < interval.y - interval.x ? 1 : 0; - intersectionWidth += bound.y - bound.x; - intervalWidth += interval.y - interval.x; - } - - output.WriteLine($"IV-REPORT affine composition: {open} open slices, affine narrower in {wins} ({(double)wins / open:F3}), intersection width {intersectionWidth:F1} against the interval piece's {intervalWidth:F1} ({intersectionWidth / intervalWidth:F3})"); - Assert.True(open > 0, "no slice is open"); - Assert.True(wins >= 0.35 * open, $"the affine piece is narrower than the interval piece in {wins} of {open} open slices, under 35%"); - Assert.True(intersectionWidth <= 0.995 * intervalWidth, $"the intersection's width {intersectionWidth:F1} is not under 0.995 of the interval piece's {intervalWidth:F1}"); - } - - /// - /// The gate only ever gives up what the probes could not have delivered. Gated, a slice the best - /// conceivable probe cannot prove empty returns the envelope; so a slice the ungated bound proves - /// empty (its upper density 0) must be proved empty gated too. A gate that errs toward giving up - /// (the reach inflated, a gradient or Hessian term overstated) loosens the bound exactly there and - /// costs only culling, which no enclosure test sees; a gate that errs the other way only costs probes, - /// which the cost contract (IntervalSkipHalvesEvaluations) sees. Over seeded slices of both wells and the fog interior at - /// warp 0 and the Aetheria warp, N = 8, in both modes, no slice the ungated bound proves empty is - /// left open by the gated one, and at least 200 are proved empty. - /// - [Fact] - public void GateNeverGivesUpAProvableCull() - { - var random = new System.Random(0x6A7E); - var (proved, lost) = (0, new List()); - foreach (var mode in new[] { BoundMode.Interval, BoundMode.Affine }) - foreach (var warp in new[] { 0.0f, FogField.AetheriaWarp }) - foreach (var field in new[] { FogField.DeepWell(warp, mode), FogField.Wells(warp, mode), FogField.InsideFog(warp, mode) }) - for (var t = 0; t < 1500; t++) - { - var tile = field.DrawTile(random, 8); - var z0 = Uniform(random, field.Grid[0], field.Grid[^1] * 0.9f); - var z1 = MathF.Min(z0 + LogUniform(random, 0.5f, 100.0f), field.Grid[^1]); - if (field.Bound(tile, z0, z1, false, new Counts()).y > 0.0f) - continue; - proved++; - var gated = field.Bound(tile, z0, z1, true, new Counts()); - if (gated.y > 0.0f) - lost.Add($"{field.Name} {mode} warp {warp}: slice [{z0:R}, {z1:R}] is proved empty ungated but the gate leaves it at {gated}"); - } - - output.WriteLine($"IV-REPORT gate: {proved} slices proved empty ungated, {lost.Count} left open by the gate"); - Assert.True(proved >= 200, $"only {proved} slices are proved empty ungated: the check cannot tell a gate that loses them"); - Assert.True(lost.Count == 0, $"{lost.Count} provable culls given up by the gate, first: {lost.FirstOrDefault()}"); - } - - // Why a field is not ten bands deep and wide, or null. The band G is the span of s where only the - // noise decides density: s in [F + A lo, F + A hi] for the free noise range [lo, hi], with the fade at 1. - private static string? TenBandsShortfall(FogField field, int cameras) - { - var band = FogField.Amplitude * (FogField.FreeNoise.y - FogField.FreeNoise.x); - var well = field.Bowls[^1]; - var rim = well.Scale / 2.0f; - float At(float r) => field.HeightAt(well.Centre + new float2(r, 0.0f)); - var depth = At(0.0f) - At(rim); - var half = (At(0.0f) + At(rim)) / 2.0f; - float lo = 0.0f, hi = rim; - for (var k = 0; k < 60; k++) - { - var mid = (lo + hi) / 2.0f; - if (At(mid) > half) - lo = mid; - else - hi = mid; - } - - var problems = new List(); - if (depth < 10.0f * band) - problems.Add($"depth {depth:R} is under 10 G = {10.0f * band:R}"); - if (lo < 10.0f * band) - problems.Add($"half-depth radius {lo:R} is under 10 G = {10.0f * band:R}"); - var random = new System.Random(0xD33B); - for (var c = 0; c < cameras; c++) - { - var origin = field.DrawTile(random, 8).Origin; - var xz = new float2(origin.x, origin.z); - var s = origin.y + field.HeightAt(xz); - if (!(length(xz - well.Centre) < lo && origin.y < FogField.FloorOffset - At(rim) && s >= FogField.FloorOffset + FogField.Amplitude * FogField.FreeNoise.y)) - { - problems.Add($"camera {origin} is not inside the well, below the rim's fog surface, in empty air"); - break; - } - } - - return problems.Count == 0 ? null : $"{field.Name}: G = {band:R}; " + string.Join("; ", problems); - } - - /// - /// Ruling wells-scale-order-of-magnitude: the band G is computed from FogField's FloorOffset, Amplitude - /// and free noise range (60). The deep well's depth, h(centre) - h(rim), and its half-depth radius, - /// found by bisection on the well map, are each at least 10 G, and each of 1,000 drawn cameras sits - /// inside that radius, below the rim's fog surface and in empty air (s above the band). A well of depth - /// 150 fails the same check. - /// - [Fact] - public void DeepWellIsTenBandsDeepAndWide() - { - var deep = FogField.DeepWell(FogField.AetheriaWarp, BoundMode.Interval); - Assert.Null(TenBandsShortfall(deep, 1000)); - Assert.NotNull(TenBandsShortfall(FogField.DeepWell(FogField.AetheriaWarp, BoundMode.Interval, depth: 150.0f), 1000)); - var band = FogField.Amplitude * (FogField.FreeNoise.y - FogField.FreeNoise.x); - output.WriteLine($"IV-REPORT deep well: G = {band:R}, depth {deep.HeightAt(new float2(0.0f, 0.0f)) - deep.HeightAt(new float2(FogField.DeepWellScale / 2.0f, 0.0f)):R}"); - } - - // ---- The cull map ---- - - // An approximation of viridis at nine anchors, interpolated linearly, for t in [0, 1]. - private static readonly (byte R, byte G, byte B)[] Viridis = - { - (68, 1, 84), (72, 40, 120), (62, 74, 137), (49, 104, 142), (38, 130, 142), (31, 158, 137), (53, 183, 121), (110, 206, 88), (253, 231, 37), - }; - - private static (byte, byte, byte) Colour(double t) - { - t = Math.Clamp(t, 0.0, 1.0) * (Viridis.Length - 1); - var i = Math.Min((int)t, Viridis.Length - 2); - var f = t - i; - byte Mix(byte a, byte b) => (byte)Math.Round(a + (b - a) * f); - return (Mix(Viridis[i].R, Viridis[i + 1].R), Mix(Viridis[i].G, Viridis[i + 1].G), Mix(Viridis[i].B, Viridis[i + 1].B)); - } - - private static uint[] CrcTable() => Enumerable.Range(0, 256).Select(n => - { - var c = (uint)n; - for (var k = 0; k < 8; k++) - c = (c & 1) != 0 ? 0xEDB88320u ^ (c >> 1) : c >> 1; - return c; - }).ToArray(); - - // A minimal 8-bit RGB PNG: one IDAT of zlib-compressed rows, filter 0. - private static void WritePng(string path, int width, int height, byte[] rgb) - { - var table = CrcTable(); - using var file = File.Create(path); - void Chunk(string type, byte[] data) - { - var name = System.Text.Encoding.ASCII.GetBytes(type); - var length = new[] { (byte)(data.Length >> 24), (byte)(data.Length >> 16), (byte)(data.Length >> 8), (byte)data.Length }; - file.Write(length); - file.Write(name); - file.Write(data); - var crc = 0xFFFFFFFFu; - foreach (var b in name.Concat(data)) - crc = table[(crc ^ b) & 0xFF] ^ (crc >> 8); - crc ^= 0xFFFFFFFFu; - file.Write(new[] { (byte)(crc >> 24), (byte)(crc >> 16), (byte)(crc >> 8), (byte)crc }); - } - - file.Write(new byte[] { 137, 80, 78, 71, 13, 10, 26, 10 }); - Chunk("IHDR", new byte[] { (byte)(width >> 24), (byte)(width >> 16), (byte)(width >> 8), (byte)width, (byte)(height >> 24), (byte)(height >> 16), (byte)(height >> 8), (byte)height, 8, 2, 0, 0, 0 }); - using var packed = new MemoryStream(); - using (var z = new System.IO.Compression.ZLibStream(packed, System.IO.Compression.CompressionLevel.Optimal, leaveOpen: true)) - { - for (var y = 0; y < height; y++) - { - z.WriteByte(0); - z.Write(rgb, y * width * 3, width * 3); - } - } - - Chunk("IDAT", packed.ToArray()); - Chunk("IEND", Array.Empty()); - } - - /// - /// The cull map of one deep-well frame at warp D, for the operator: a camera inside the well at xz - /// (0, -200), y = F - h / 2, looking along +z across the well, 960 x 540 pixels at a 60 degree vertical - /// field of view, in 8 x 8 tiles (the last row of tiles half off the frame). Each tile runs the - /// pre-pass under the centred-warp interval bound and under the affine bound; each pixel's ray (through - /// the pixel's centre) is marched densely for its transmittance and over each tile mask and the oracle - /// mask (the cells some ray of the tile samples nonzero), with the early-out at 0.02. The PNG is - /// 1920 x 1080 in four panels: top left the cells per ray the interval march integrates, top right the - /// affine march's, bottom left the oracle march's (all three on one viridis scale, logarithmic, - /// log(1 + n) / log(1 + the largest count)), bottom right the transmittance (black opaque, white clear). It is written only when - /// CULTMATH_WRITE_CULLMAP names a directory; the mean cells per ray are printed either way. - /// - [Fact(Explicit = true)] - [Trait("Category", "Slow")] - public void DeepWellCullMap() - { - const int width = 960, height = 540, size = 8; - var interval = FogField.DeepWell(FogField.AetheriaWarp, BoundMode.Interval); - var affine = FogField.DeepWell(FogField.AetheriaWarp, BoundMode.Affine); - var focal = height / 2.0f / MathF.Tan(MathF.PI / 6.0f); - var xz = new float2(0.0f, -200.0f); - var origin = new float3(xz.x, FogField.FloorOffset - 0.5f * interval.HeightAt(xz), xz.y); - var grid = interval.Grid; - var (cellsInterval, cellsAffine, cellsOracle) = (new int[width * height], new int[width * height], new int[width * height]); - var transmittance = new float[width * height]; - var (tilesX, tilesY) = (width / size, (height + size - 1) / size); - var probes = new Counts[tilesX * tilesY]; - var clock = System.Diagnostics.Stopwatch.StartNew(); - Parallel.For(0, tilesX * tilesY, index => - { - var (tx, ty) = (index % tilesX, index / tilesX); - var slope = new float2((tx * size + size / 2.0f - width / 2.0f) / focal, (height / 2.0f - (ty * size + size / 2.0f)) / focal); - var tile = interval.TileAt(origin, 0.0f, slope, size, focal, 3.0f); - probes[index] = new Counts(); - var (maskInterval, _, _) = MarchTile(interval, tile, probes[index]); - var (maskAffine, _, _) = MarchTile(affine, tile, new Counts()); - var scratch = new Counts(); - var rays = new List<(int Pixel, float2 Slope)>(); - for (var j = 0; j < size; j++) - for (var i = 0; i < size; i++) - { - var (px, py) = (tx * size + i, ty * size + (size - 1 - j)); - rays.Add((py < height ? py * width + px : -1, tile.PixelSlope(i, j, 0.5f, 0.5f))); - } - - var oracle = Enumerable.Range(0, grid.Length - 1).Where(c => rays.Any(r => interval.Density(tile, r.Slope, (grid[c] + grid[c + 1]) * 0.5f, false, scratch) > 0.0f)).ToList(); - foreach (var (pixel, ray) in rays) - { - if (pixel < 0) - continue; - int Steps(List mask) - { - var t = 1.0f; - var k = 0; - for (; k < mask.Count && t >= 0.02f; k++) - t *= Integrate(interval, tile, ray, grid[mask[k]], grid[mask[k] + 1], lod: false, scratch); - return k; - } - - var dense = 1.0f; - for (var c = 0; c < grid.Length - 1 && dense >= 0.02f; c++) - dense *= Integrate(interval, tile, ray, grid[c], grid[c + 1], lod: false, scratch); - transmittance[pixel] = dense; - cellsInterval[pixel] = Steps(maskInterval); - cellsAffine[pixel] = Steps(maskAffine); - cellsOracle[pixel] = Steps(oracle); - } - }); - - var most = Math.Max(cellsInterval.Max(), Math.Max(cellsAffine.Max(), cellsOracle.Max())); - output.WriteLine($"IV-REPORT cull map (deep well, warp {FogField.AetheriaWarp:R}, {width}x{height}, {size}x{size} tiles, {clock.Elapsed.TotalSeconds:F0} s): cells per ray interval {cellsInterval.Average():F2}, affine {cellsAffine.Average():F2}, oracle {cellsOracle.Average():F2}; " - + $"largest {most}; interval probes per tile env {probes.Average(p => p.Envelope):F1} snoise {probes.Average(p => p.Snoise):F2}; mean transmittance {transmittance.Average():F3}"); - var directory = Environment.GetEnvironmentVariable("CULTMATH_WRITE_CULLMAP"); - if (string.IsNullOrEmpty(directory)) - return; - var rgb = new byte[2 * width * 2 * height * 3]; - void Put(int x, int y, (byte R, byte G, byte B) c) - { - var o = (y * 2 * width + x) * 3; - (rgb[o], rgb[o + 1], rgb[o + 2]) = c; - } - - for (var y = 0; y < height; y++) - for (var x = 0; x < width; x++) - { - var p = y * width + x; - Put(x, y, Colour(Math.Log(1.0 + cellsInterval[p]) / Math.Log(1.0 + most))); - Put(width + x, y, Colour(Math.Log(1.0 + cellsAffine[p]) / Math.Log(1.0 + most))); - Put(x, height + y, Colour(Math.Log(1.0 + cellsOracle[p]) / Math.Log(1.0 + most))); - var grey = (byte)Math.Round(255.0 * transmittance[p]); - Put(width + x, height + y, (grey, grey, grey)); - } - - for (var k = 0; k < 2 * width; k++) - for (var d = -1; d <= 0; d++) - Put(k, height + d, (255, 255, 255)); - for (var k = 0; k < 2 * height; k++) - for (var d = -1; d <= 0; d++) - Put(width + d, k, (255, 255, 255)); - Directory.CreateDirectory(directory); - var path = Path.Combine(directory, "deep-well-cull-map.png"); - WritePng(path, 2 * width, 2 * height, rgb); - output.WriteLine($"IV-REPORT cull map written to {path}"); - } - - /// - /// Mean of interval width over the true range (max - min of the 64 sampled values) per ball: how - /// loose the Lipschitz bound is, for a later affine cut to beat. Asserts only finiteness. - /// - [Fact] - public void TightnessReport() - { - double Ratio(Func bound, Func f, float radius, int seed) - { - var random = new System.Random(seed); - var sum = 0.0; - for (var b = 0; b < 2000; b++) - { - var centre = RandomCentre(random); - var interval = bound(centre, radius); - float lo = float.MaxValue, hi = float.MinValue; - for (var i = 0; i < 64; i++) - { - var v = f(PointInBall(random, centre, radius, i)); - lo = MathF.Min(lo, v); - hi = MathF.Max(hi, v); - } - - sum += (interval.y - interval.x) / (double)(hi - lo); - } - - return sum / 2000; - } - - var snoiseRatios = new[] { 0.05f, 0.25f, 1.0f }.Select(r => (r, Ratio(iv_snoise_ball, snoise, r, 0x7167))).ToArray(); - var fbmRatios = new[] { 0.05f, 0.25f }.Select(r => (r, Ratio((c, rr) => iv_fbm_ball(c, rr, 4, 2.0f, 0.5f), x => fbm_grad(x, 4, 2.0f, 0.5f).w, r, 0x7168))).ToArray(); - output.WriteLine("IV-REPORT tightness (mean width / sampled range): " + - string.Join(", ", snoiseRatios.Select(t => $"snoise r={t.r:R} {t.Item2:F2}")) + "; " + - string.Join(", ", fbmRatios.Select(t => $"fbm4 r={t.r:R} {t.Item2:F2}"))); - Assert.All(snoiseRatios.Concat(fbmRatios), t => Assert.True(double.IsFinite(t.Item2))); - } - - - // ---- The saving: envelope-then-noise fields, marched over screen tiles ---- - - // Combined cost in snoise units: one envelope evaluation, pointwise or as an interval probe, costs this - // much. An estimate (a handful of pulses or one height-map fetch against ~150 flops of snoise); both - // counts are printed, so any other weight can be applied to them. - internal const double EnvelopeCost = 0.2; - - // One snoise_grad evaluation (af_snoise's one call) costs this much in snoise units: the value and - // three gradient components over the same corners. An estimate, printed beside the count as the - // envelope weight is, and not tuned toward any contract. - internal const double GradCost = 2.0; - - internal sealed class Counts - { - public long Snoise; - public long Envelope; - public long Grad; - - public double Cost => Snoise + EnvelopeCost * Envelope + GradCost * Grad; - } - - /// - /// One screen tile of one frame: a pinhole camera (origin and orthonormal basis; camera space looks - /// down +z and the ray of slope m is the points (m z, z)), the tile's central slope, its size N, the - /// focal length in pixels and the frame time. Every tile draws its own camera, so a probe result is - /// never carried to another frame. - /// - internal class Tile - { - public float3 Origin; - public float3 Right = new(1.0f, 0.0f, 0.0f); - public float3 Up = new(0.0f, 1.0f, 0.0f); - public float3 Forward = new(0.0f, 0.0f, 1.0f); - public float2 Slope; - public int N; - public float Focal; - public float Time; - - public float Half => N / (2.0f * Focal); - public float Footprint => N / (MathF.Sqrt(2.0f) * Focal); - public float2 SlopesX => new(Slope.x - Half, Slope.x + Half); - public float2 SlopesY => new(Slope.y - Half, Slope.y + Half); - - // Pixel (i, j) of the tile at sub-pixel offset (u, v) in [0, 1): its slope lies in SlopesX x SlopesY - // in float32, because (i + u) / f - N / (2f) is at most N / f - N / (2f) = N / (2f) exactly. - public float2 PixelSlope(int i, int j, float u, float v) => - Slope + new float2((i + u) / Focal - Half, (j + v) / Focal - Half); - - public float3 World(float3 c) => Origin + Right * c.x + Up * c.y + Forward * c.z; - - public float3 Camera(float3 w) - { - var d = w - Origin; - return new float3(dot(d, Right), dot(d, Up), dot(d, Forward)); - } - - public void Look(float3 forward) - { - Forward = normalize(forward); - Right = normalize(cross(new float3(0.0f, 1.0f, 0.0f), Forward)); - Up = cross(Forward, Right); - } - } - - /// - /// A field with an analytic envelope and the dense grid it is marched on. Density is the pointwise - /// field, envelope-gated (noise only where the envelope leaves the density undecided), counted. Bound - /// is the one composition of the envelope's interval over a tile slice's box and the noise ball over the - /// slice's iv_frustum_ball: an interval enclosing Density at every point of every ray of the tile in the - /// slice. A slice is provably empty iff Bound(...).y <= 0. gated is the march's form: it returns the - /// envelope's verdict without snoise when the envelope alone proves the slice empty, and attempts the - /// noise ball only when the best outcome any centre value could give would prove it; ungated, the ball - /// is always evaluated. - /// - /// FogField's bound: the centred-warp interval composition, or the affine one (design.md, "Affine forms"). - internal enum BoundMode - { - Interval, - Affine, - } - - internal abstract class Scenario - { - public required string Name { get; init; } - public float[] Grid { get; protected init; } = Array.Empty(); - public float Focal { get; init; } = 935.0f; // 1080 rows at a 60 degree vertical field of view - public float Extinction { get; init; } = 1.0f; - - public abstract Tile DrawTile(System.Random random, int n); - - public abstract float Density(Tile tile, float2 slope, float z, bool lod, Counts counts); - - public abstract float2 Bound(Tile tile, float z0, float z1, bool gated, Counts counts); - - // Cell boundaries near + (j / J)^2 (far - near): Aetheria's quadratic sample spacing - // (Assets/Shaders/Raymarching/CloudShader.shader:116). - protected static float[] Quadratic(float near, float far, int cells) => - Enumerable.Range(0, cells + 1).Select(j => near + (float)j / cells * ((float)j / cells) * (far - near)).ToArray(); - - protected static float[] Cells(float step, float end) => - Enumerable.Range(0, (int)MathF.Ceiling(end / step) + 1).Select(j => j * step).ToArray(); - } - - // iv_snoise_ball, with the snoise skipped where L r >= 2: there the bound is [-1, 1] whatever snoise(c) - // is (|snoise| < 1), so the result is the same and costs nothing. - private static float2 NoiseBall(float3 centre, float radius, Counts counts) - { - if (SNOISE_LIPSCHITZ * radius >= 2.0f) - return new float2(-1.0f, 1.0f); - counts.Snoise++; - return iv_snoise_ball(centre, radius); - } - - // The best interval any centre value could give a ball of this radius, toward low or high values; the - // gate on whether a probe can prove anything. snoise(c) > -1, so a real ball's hi is at least -1 + L r, - // and likewise its lo is at most 1 - L r. - private static float2 BestBall(float radius, bool low) - { - var e = SNOISE_LIPSCHITZ * radius; - if (e >= 2.0f) - return new float2(-1.0f, 1.0f); - return low ? new float2(-1.0f, min(-1.0f + e, 1.0f)) : new float2(max(1.0f - e, -1.0f), 1.0f); - } - - // Least and greatest distance along one axis from a box to a point, exact in float32: a coordinate in - // [lo, hi] is at least `near` and at most `far` from c, and squares, sums and sqrt are monotone. - private static (float Near, float Far) AxisDistance(float2 range, float c) => - (c < range.x ? range.x - c : c > range.y ? c - range.y : 0.0f, max(abs(range.x - c), abs(range.y - c))); - - /// - /// The noise of the fog and the void (r1's field shape): coverage is two snoise of the warped point, - /// cross-faded over two half-period phases; n = coverage + detail / 2, the detail one snoise at four - /// times the frequency. The flow is a unit-bounded 2D field times FlowAmplitude, so a phase moves a point - /// by at most Warp = FlowAmplitude * Period / 2. The flow is not counted: the site reads it from a - /// texture and Aetheria from its flow map. - /// - internal sealed class WarpedNoise - { - public required float F0 { get; init; } - public required float Warp { get; init; } - public float Period { get; init; } = 8.0f; - public float FlowFrequency { get; init; } = 1.0f / 512.0f; - public bool FlowInXY { get; init; } - - private float FlowAmplitude => Warp * 2.0f / Period; - - public float3 Flow(float3 p) - { - var q = (FlowInXY ? new float2(p.x, p.y) : new float2(p.x, p.z)) * FlowFrequency; - var v = new float2(snoise(q + new float2(17.0f, 3.0f)), snoise(q + new float2(-5.0f, 41.0f))); - v = v / max(1.0f, length(v)) * FlowAmplitude; - return FlowInXY ? new float3(v.x, v.y, 0.0f) : new float3(v.x, 0.0f, v.y); - } - - public (float W0, float Shift0, float Shift1) Phases(float time) - { - var phase0 = frac(time / Period); - var phase1 = frac(time / Period + 0.5f); - return (1.0f - abs(2.0f * phase0 - 1.0f), (phase0 - 0.5f) * Period, (phase1 - 0.5f) * Period); - } - - public float Coverage(float3 p, float time, Counts counts) - { - var (w0, shift0, shift1) = Phases(time); - var flow = Flow(p); - counts.Snoise += 2; - return w0 * snoise((p + flow * shift0) * F0) + (1.0f - w0) * snoise((p + flow * shift1) * F0); - } - - public float Detail(float3 p, Counts counts) - { - counts.Snoise++; - return snoise(p * (4.0f * F0) + 17.0f); - } - - // The cross-fade of the two phases' noise enclosures, term by term with the frame's own weights. - // A field whose ball carries the whole warp passes the same enclosure for both phases. - public float2 CoverageBound(float2 phase0, float2 phase1, float time) - { - var w0 = Phases(time).W0; - return iv_add(iv_scale(phase0, w0), iv_scale(phase1, 1.0f - w0)); - } - - /// - /// How far the flow can move across a ball of radius r about c: each flow component is snoise(float2) - /// of the point projected to the flow plane and scaled by FlowFrequency, which varies over the ball by - /// at most iv_snoise_ball(float2)'s reach from its centre value, plus Deviation's float32 allowance; the - /// projection and the clamp to the unit disc are nonexpansive, and two unit-disc vectors differ by at - /// most 2. - /// - public float FlowVariation(float3 centre, float radius) - { - var q = (FlowInXY ? new float2(centre.x, centre.y) : new float2(centre.x, centre.z)) * FlowFrequency; - var u = Deviation(q + new float2(17.0f, 3.0f), radius * FlowFrequency); - var v = Deviation(q + new float2(-5.0f, 41.0f), radius * FlowFrequency); - return min(sqrt(u * u + v * v), 2.0f) * FlowAmplitude; - } - - // How far snoise(float2) can differ from its value at q over radius, in float32: the ball's reach plus - // the allowance of af_snoise's convention for the 2D value, 2^-14 + L2 2^-20 (|q|_1 + r). The point - // q + offset rounds at the magnitude of q + offset (a unit in the last place of 20 is 2^-19), so the - // flow at two points of a ball differs by more than the exact function can, and the iv_snoise_ball - // bound, which is exact for the point it is given, does not carry that. - private static float Deviation(float2 q, float radius) - { - var n = snoise(q); - var ball = iv_snoise_ball(q, radius); - var allowance = 6.103515625e-5f + SNOISE2_LIPSCHITZ * 9.5367431640625e-7f * (abs(q.x) + abs(q.y) + radius); - return max(ball.y - n, n - ball.x) + allowance; - } - - /// - /// The centred warp (design.md, "Affine forms"): phase k moves a point p of a set within reach of c - /// to p + flow(p) shift_k, which lies within |shift_k| rho of (p - c) + c + flow(c) shift_k, rho = - /// FlowVariation(c, reach). So phase k's noise argument is the set moved by flow(c) shift_k and - /// grown by |shift_k| rho, instead of grown by the whole warp. At warp 0 both phases are the set. - /// - public (float3 Centre0, float Grow0, float3 Centre1, float Grow1) CentredWarp(float3 centre, float reach, float time) - { - var (_, shift0, shift1) = Phases(time); - var flow = Flow(centre); - var rho = FlowVariation(centre, reach); - return (centre + flow * shift0, abs(shift0) * rho, centre + flow * shift1, abs(shift1) * rho); - } - - public float2 CoverageBall(float3 centre, float radius, Counts counts) => NoiseBall(centre * F0, radius * F0, counts); - - public float2 DetailBall(float3 centre, float radius, Counts counts) => NoiseBall(centre * (4.0f * F0) + 17.0f, radius * (4.0f * F0), counts); - - public float CoverageRadius(float radius) => radius * F0; - - public float DetailRadius(float radius) => radius * (4.0f * F0); - } - - /// - /// Aetheria's nebula (Assets/Shaders/Volumetric.cginc:165-221, cloudDensity :91-102) over its zone - /// height map (Assets/Scripts/ServerShared/Zone.cs:369-397 GetHeight, :426 PowerPulse), in its units - /// (Assets/Resources/Settings.asset: ZoneDepth :97-98, DefaultEnvironment :386-411). The pre-distortion - /// SDF is s(p) = p.y + h(p.xz), h >= 0 the well map: the zone bowl PowerPulse(|xz| / 2R, 2) * 64 plus, - /// per well, PowerPulse(|xz - c_b| / r_b, 16) * d_b, with r_b = 500 M^0.25, d_b = 30 M^0.175 and - /// PowerPulse(x, e) = (1 - 4x^2)^e on [0, 1/2], 0 beyond. Noise displaces only below the safety distance: - /// fade = 1 - smoothstep(0.75 S, S, s), s' = s + A fade n(warp(p)), density = max(0, (F - s') / B); the - /// patch band and the 1e-9 fill are left out. The warp moves only the noise argument; the height is read - /// at the unwarped xz, as Aetheria reads _NebulaSurfaceHeight at pos.xz. Envelope coordinates are the - /// tile's camera frame (the camera yaws about y, so horizontal distances are the world's). Extinction - /// 0.5 is the environment's (Settings.asset:397, applied at CloudShader.shader:91). - /// - internal sealed class FogField : Scenario - { - public const float Safety = 30.0f; // SafetyDistance, Settings.asset:399 - public const float FloorOffset = -20.0f; // :393 - public const float FloorBlend = 10.0f; // :394 - public const float Amplitude = 20.0f; - public const float NoiseScale = 414.2167f; // :409 - public const float AetheriaWarp = 60.0f; // Flow GlobalAmplitude 15 x Period 8 / 2, :402-405 - public const float ZoneRadius = 2000.0f; - internal static readonly float2 FreeNoise = new(-1.5f, 1.5f); - - public required WarpedNoise Noise { get; init; } - public required BoundMode Mode { get; init; } - public (float2 Centre, float Scale, float Exponent, float Depth)[] Bowls { get; init; } = Array.Empty<(float2, float, float, float)>(); - public required Func CameraAt { get; init; } - public required float2 SlopesY { get; init; } - - public FogField() - { - // Near 0.3 and far 2048: the ARPG scene's Main Camera, which carries the cloud march - // (Aetheria d3075eb0 Assets/Scenes/ARPG.unity:31777 m_Name, :31830 far clip plane; - // Assets/Scripts/Zone Display/VolumeCloudRenderer.cs:36 RequireComponent(Camera)). - Grid = Quadratic(0.3f, 2048.0f, 256); - Extinction = 0.5f; - } - - private static WarpedNoise AetheriaNoise(float warp) => new() { F0 = 1.0f / NoiseScale, Warp = warp }; - - private static string Named(string name, BoundMode mode) => $"{name} [{(mode == BoundMode.Affine ? "affine" : "interval")}]"; - - /// (a) Height fog: no wells, the camera above the safety band at y = S + 30, rays level and up. - public static FogField HeightFog(float warp, BoundMode mode) => new() - { - Name = Named("(a) height fog", mode), Mode = mode, Noise = AetheriaNoise(warp), SlopesY = new float2(0.0f, 0.5f), - CameraAt = (random, _) => new float3(Uniform(random, -1000.0f, 1000.0f), Safety + 30.0f, Uniform(random, -1000.0f, 1000.0f)), - }; - - /// (b) Inside the fog: no wells, the camera at y = F - 10, rays level. - public static FogField InsideFog(float warp, BoundMode mode) => new() - { - Name = Named("(b) inside the fog", mode), Mode = mode, Noise = AetheriaNoise(warp), SlopesY = new float2(-0.05f, 0.05f), - CameraAt = (random, _) => new float3(Uniform(random, -1000.0f, 1000.0f), FloorOffset - 10.0f, Uniform(random, -1000.0f, 1000.0f)), - }; - - // The deep well's geometry (ruling wells-scale-order-of-magnitude): one PowerPulse well of exponent - // 2, scale 2220 and depth 600 at the zone's centre, so its depth and half-depth radius are each - // about 600, ten times the band (DeepWellIsTenBandsDeepAndWide measures both). - public const float DeepWellScale = 2220.0f; - public const float DeepWellDepth = 600.0f; - public const float DeepWellCameraRadius = 300.0f; - - /// - /// (c) The deep well, the case Aetheria plays in: there the camera is always in some gravity well, - /// gazing across a bowl a sun's gravity carves (ruling wells-scale-order-of-magnitude). The zone bowl - /// R = 2000 plus one well at its centre, PowerPulse exponent 2, scale 2220, depth 600, so the well's - /// depth and half-depth radius are each about ten times G = 3 A = 60, the band of s where only the - /// noise decides density (s in [F - 1.5 A, F + 1.5 A] with the fade at 1). The camera's xz is uniform - /// within 300 of the centre, at y = F - h(xz) / 2, halfway between the sunken fog surface and the - /// rim's, in empty air; slopes and yaw as the shallow wells, m_y in [-0.25, 0.1]. A level ray crosses - /// hundreds of units of empty well before the far wall's band. - /// - public static FogField DeepWell(float warp, BoundMode mode, float depth = DeepWellDepth) => new() - { - Name = Named("(c) deep well", mode), Mode = mode, Noise = AetheriaNoise(warp), SlopesY = new float2(-0.25f, 0.1f), - Bowls = new (float2, float, float, float)[] { (new float2(0.0f, 0.0f), 2.0f * ZoneRadius, 2.0f, 64.0f), (new float2(0.0f, 0.0f), DeepWellScale, 2.0f, depth) }, - CameraAt = (r, field) => - { - var angle = Uniform(r, 0.0f, 2.0f * MathF.PI); - var radius = DeepWellCameraRadius * MathF.Sqrt(r.NextSingle()); - var xz = new float2(radius * MathF.Cos(angle), radius * MathF.Sin(angle)); - return new float3(xz.x, FloorOffset - 0.5f * field.HeightAt(xz), xz.y); - }, - }; - - /// - /// (c-band) Shallow wells, the band-dominated row, printed only: the zone bowl R = 2000 (64 deep) and - /// four wells of mass 100, 1000, 10000 and 1000 at seeded positions inside it, 30 M^0.175 deep (67 to - /// 150, 1.1 to 2.5 times G) and 500 M^0.25 wide at exponent 16; the camera at a seeded xz in the bowl, - /// just above the noise band at y = max(0, S + 10 - h), gazing across with m_y in [-0.25, 0.1]. Most - /// of its cost is the band itself, which is where affine noise gains most. - /// - public static FogField Wells(float warp, BoundMode mode) - { - var random = new System.Random(0xA37E); - var bowls = new List<(float2, float, float, float)> { (new float2(0.0f, 0.0f), 2.0f * ZoneRadius, 2.0f, 64.0f) }; - foreach (var mass in new[] { 100.0f, 1000.0f, 10000.0f, 1000.0f }) - { - var angle = Uniform(random, 0.0f, 2.0f * MathF.PI); - var radius = ZoneRadius * MathF.Sqrt(random.NextSingle()); - bowls.Add((new float2(radius * MathF.Cos(angle), radius * MathF.Sin(angle)), 500.0f * MathF.Pow(mass, 0.25f), 16.0f, 30.0f * MathF.Pow(mass, 0.175f))); - } - - return new FogField - { - Name = Named("(c-band) shallow wells", mode), Mode = mode, Noise = AetheriaNoise(warp), Bowls = bowls.ToArray(), SlopesY = new float2(-0.25f, 0.1f), - CameraAt = (r, field) => - { - var angle = Uniform(r, 0.0f, 2.0f * MathF.PI); - var radius = ZoneRadius * MathF.Sqrt(r.NextSingle()); - var xz = new float2(radius * MathF.Cos(angle), radius * MathF.Sin(angle)); - return new float3(xz.x, max(0.0f, Safety + 10.0f - field.HeightAt(xz)), xz.y); - }, - }; - } - - private sealed class FogTile : Tile - { - public float2[] Centres = Array.Empty(); // bowl centres in the camera's (x, z) - } - - public override Tile DrawTile(System.Random random, int n) - { - var origin = CameraAt(random, this); - var yaw = Uniform(random, 0.0f, 2.0f * MathF.PI); - var time = Uniform(random, 0.0f, 100.0f); - var slope = new float2(Uniform(random, -1.0f, 1.0f), Uniform(random, SlopesY.x, SlopesY.y)); - return TileAt(origin, yaw, slope, n, Focal, time); - } - - /// The tile of a camera at origin, yawed about y (0 looks along +z), at the given slope, size, focal length and time. - public Tile TileAt(float3 origin, float yaw, float2 slope, int n, float focal, float time) - { - var tile = new FogTile { Origin = origin, N = n, Focal = focal, Time = time, Slope = slope }; - tile.Look(new float3(MathF.Sin(yaw), 0.0f, MathF.Cos(yaw))); - tile.Centres = Bowls.Select(b => - { - var c = tile.Camera(new float3(b.Centre.x, origin.y, b.Centre.y)); - return new float2(c.x, c.z); - }).ToArray(); - return tile; - } - - private static float Pulse(float distance, float scale, float exponent) - { - var x = distance / scale; - var t = 1.0f - 4.0f * x * x; - return t <= 0.0f ? 0.0f : pow(t, exponent); - } - - // h at the camera-frame point (x, z), bowl centres in the same frame. - private float Height(float2[] centres, float x, float z) - { - var h = 0.0f; - for (var b = 0; b < Bowls.Length; b++) - { - var dx = x - centres[b].x; - var dz = z - centres[b].y; - h += Pulse(sqrt(dx * dx + dz * dz), Bowls[b].Scale, Bowls[b].Exponent) * Bowls[b].Depth; - } - - return h; - } - - /// The well map h at the world point (x, z). - public float HeightAt(float2 xz) => Height(Bowls.Select(b => b.Centre).ToArray(), xz.x, xz.y); - - // Each bowl's term over the box is [pulse(far), pulse(near)], pulse decreasing in distance; pow is - // not required to be correctly rounded, so both ends are widened by one ulp. - private float2 HeightBound(float2[] centres, float2 x, float2 z) - { - var h = iv_point(0.0f); - for (var b = 0; b < Bowls.Length; b++) - { - var (nx, fx) = AxisDistance(x, centres[b].x); - var (nz, fz) = AxisDistance(z, centres[b].y); - var near = Pulse(sqrt(nx * nx + nz * nz), Bowls[b].Scale, Bowls[b].Exponent); - var far = Pulse(sqrt(fx * fx + fz * fz), Bowls[b].Scale, Bowls[b].Exponent); - var pulse = new float2(far > 0.0f ? MathF.BitDecrement(far) : 0.0f, near > 0.0f ? MathF.BitIncrement(near) : 0.0f); - h = iv_add(h, iv_scale(pulse, Bowls[b].Depth)); - } - - return h; - } - - private static float2 Compose(float2 s, float2 fade, float2 n) - { - var displaced = iv_add(s, iv_scale(iv_mul(fade, n), Amplitude)); - return new float2(max(0.0f, (FloorOffset - displaced.y) / FloorBlend), max(0.0f, (FloorOffset - displaced.x) / FloorBlend)); - } - - public override float Density(Tile t, float2 slope, float z, bool lod, Counts counts) - { - var tile = (FogTile)t; - var x = slope.x * z; - var y = slope.y * z; - counts.Envelope++; - var s = tile.Origin.y + y + Height(tile.Centres, x, z); - var fade = 1.0f - smoothstep(0.75f * Safety, Safety, s); - if (Compose(iv_point(s), iv_point(fade), FreeNoise).y <= 0.0f) - return 0.0f; - var p = tile.World(new float3(x, y, z)); - var coverage = Noise.Coverage(p, tile.Time, counts); - if (Compose(iv_point(s), iv_point(fade), iv_add(iv_point(coverage), iv_scale(new float2(-1.0f, 1.0f), 0.5f))).y <= 0.0f) - return 0.0f; - var n = coverage + Noise.Detail(p, counts) * 0.5f; - return max(0.0f, (FloorOffset - (s + fade * n * Amplitude)) / FloorBlend); - } - - /// - /// The envelope first: the height and slope intervals over the slice's box, the fade, and the noise - /// at its free range. Where that already proves the slice empty the envelope is the answer; - /// otherwise Mode's bound, which (gated) returns the envelope when the best any probe could give - /// would not prove the slice either. - /// - public override float2 Bound(Tile t, float z0, float z1, bool gated, Counts counts) - { - var tile = (FogTile)t; - var frame = FrameOf(tile, z0, z1, counts); - if (gated && frame.Envelope.y <= 0.0f) - return frame.Envelope; - return Mode == BoundMode.Affine - ? AffineBound(tile, z0, z1, frame, gated, counts) - : IntervalBound(tile, z0, z1, frame.S, frame.Fade, frame.Envelope, gated, counts); - } - - // The height interval, the density level s over the slice's box, its fade and the envelope. - private readonly record struct Frame(float2 Height, float2 S, float2 Fade, float2 Envelope); - - private Frame FrameOf(FogTile tile, float z0, float z1, Counts counts) - { - var depth = new float2(z0, z1); - counts.Envelope++; - var height = HeightBound(tile.Centres, iv_mul(depth, tile.SlopesX), depth); - var s = iv_add(iv_add(iv_point(tile.Origin.y), iv_mul(depth, tile.SlopesY)), height); - var fade = iv_sub(iv_point(1.0f), iv_smoothstep(0.75f * Safety, Safety, s)); - return new Frame(height, s, fade, Compose(s, fade, FreeNoise)); - } - - /// - /// The two sound bounds AffineBound intersects, ungated: the affine arithmetic's own (the shared - /// symbol through af_add, af_mul and af_range), and the interval composition over the same forms' - /// ranges (NoiseBoundTests.AffineCompositionTightensItsRanges). - /// - internal (float2 Affine, float2 Interval) AffinePieces(Tile t, float z0, float z1, Counts counts) - { - var tile = (FogTile)t; - return AffinePieces(tile, z0, z1, FrameOf(tile, z0, z1, counts), counts); - } - - private static bool Same(float3 a, float3 b, float ga, float gb) => all(a == b) && ga == gb; - - /// - /// The centred-warp interval bound. The slice's ball is iv_frustum_ball with no warp; each phase's - /// coverage ball is that ball moved by the flow at its centre and grown by what the flow can vary - /// across it (WarpedNoise.CentredWarp), one ball when the phases coincide (warp 0). The detail octave - /// reads the unwarped point, so its ball is the unwarped one. - /// - private float2 IntervalBound(FogTile tile, float z0, float z1, float2 s, float2 fade, float2 envelope, bool gated, Counts counts) - { - var ball = iv_frustum_ball(tile.Slope, z0, z1, tile.Footprint, 0.0f); - var centre = tile.World(new float3(ball.x, ball.y, ball.z)); - var (c0, g0, c1, g1) = Noise.CentredWarp(centre, ball.w, tile.Time); - if (gated) - { - var provable = false; - foreach (var low in new[] { true, false }) - { - var coverage = Noise.CoverageBound(BestBall(Noise.CoverageRadius(ball.w + g0), low), BestBall(Noise.CoverageRadius(ball.w + g1), low), tile.Time); - provable |= Compose(s, fade, iv_add(coverage, iv_scale(BestBall(Noise.DetailRadius(ball.w), low), 0.5f))).y <= 0.0f; - } - - if (!provable) - return envelope; - } - - var n0 = Noise.CoverageBall(c0, ball.w + g0, counts); - var n1 = Same(c0, c1, g0, g1) ? n0 : Noise.CoverageBall(c1, ball.w + g1, counts); - var noise = iv_add(Noise.CoverageBound(n0, n1, tile.Time), iv_scale(Noise.DetailBall(centre, ball.w, counts), 0.5f)); - return Compose(s, fade, noise); - } - - /// - /// The affine slice of a tile over [z0, z1] in the world frame, with the centred warp applied: the - /// camera-frame axis and ball (af_frustum_axis, af_frustum_ball with no warp), the ball's world - /// centre, the world axis, and the reach R = |axis| + radius of the whole set from that centre (the - /// distance the flow is varied over). It returns the final af_snoise arguments, so a consumer has no - /// term left to wire: each phase's coverage argument is the set moved by the flow at its centre - /// (WarpedNoise.CentredWarp over R) and grown by what the flow can vary across it, and the detail - /// argument is the unwarped set. The rays at depth z lie within an argument's radius of its centre - /// + axis eps(z), eps(z) = clamp((z - z_m) / h, -1, 1) (NoiseBoundTests.AffineWarpStaysEnclosed). - /// - internal AffineSlice Slice(Tile t, float z0, float z1) - { - var tile = (FogTile)t; - var axisCamera = af_frustum_axis(tile.Slope, z0, z1); - var ball = af_frustum_ball(tile.Slope, z0, z1, tile.Footprint, 0.0f); - var centre = tile.World(new float3(ball.x, ball.y, ball.z)); - var axis = tile.Right * axisCamera.x + tile.Up * axisCamera.y + tile.Forward * axisCamera.z; - var reach = length(axis) + ball.w; - var (c0, g0, c1, g1) = Noise.CentredWarp(centre, reach, tile.Time); - var coverageFrequency = Noise.F0; - var detailFrequency = 4.0f * Noise.F0; - return new AffineSlice( - axisCamera, ball, centre, reach, - new NoiseArg(c0 * coverageFrequency, axis * coverageFrequency, (ball.w + g0) * coverageFrequency), - new NoiseArg(c1 * coverageFrequency, axis * coverageFrequency, (ball.w + g1) * coverageFrequency), - new NoiseArg(centre * detailFrequency + 17.0f, axis * detailFrequency, ball.w * detailFrequency)); - } - - /// One af_snoise argument in noise space: the centre, the axis along eps, and the radius. - internal readonly record struct NoiseArg(float3 Centre, float3 Axis, float Radius) - { - /// The distance of the whole set from its centre: the gate's reach. - public float Reach => length(Axis) + Radius; - - public float3 Snoise() => af_snoise(Centre, Axis, Radius); - } - - internal readonly record struct AffineSlice(float3 AxisCamera, float4 Ball, float3 Centre, float Reach, NoiseArg Coverage0, NoiseArg Coverage1, NoiseArg Detail); - - // The best interval any centre value and gradient could give af_snoise over a set of reach R (the - // gradient 0, the value at the far end), toward low or high values: the affine gate. - private static float2 BestForm(float reach, bool low) - { - var e = min(SNOISE_LIPSCHITZ * reach, 0.5f * SNOISE_HESSIAN * reach * reach); - if (e >= 2.0f) - return new float2(-1.0f, 1.0f); - return low ? new float2(-1.0f, min(-1.0f + e, 1.0f)) : new float2(max(1.0f - e, -1.0f), 1.0f); - } - - private static float2 Clip(float2 range) => new(max(range.x, -1.0f), min(range.y, 1.0f)); - - /// - /// The affine bound, one shared symbol: depth z = z_m + h eps over the slice (af_frustum_axis and - /// af_frustum_ball give the noise argument the same eps). s = O_y + m_c,y z + (m_y - m_c,y) z + h(xz) - /// is affine in eps, with the lateral slope-depth term (at most Half z1, plus the rounding of the - /// pointwise m_y z) and the height interval in e. Each phase's coverage and the unwarped detail are - /// af_snoise over the slice moved and grown by the centred warp, the fade enters as af_from_iv, and - /// s' = s + A fade n is ranged by af_range. The result is intersected with the interval composition - /// over the same forms' ranges, each clipped to [-1, 1] (both sound, no further evaluation). The gate - /// is BestForm's. - /// - private float2 AffineBound(FogTile tile, float z0, float z1, Frame frame, bool gated, Counts counts) - { - if (gated) - { - var slice = Slice(tile, z0, z1); - var (s, fade) = (frame.S, frame.Fade); - var provable = false; - foreach (var low in new[] { true, false }) - { - var coverage = Noise.CoverageBound(BestForm(slice.Coverage0.Reach, low), BestForm(slice.Coverage1.Reach, low), tile.Time); - provable |= Compose(s, fade, iv_add(coverage, iv_scale(BestForm(slice.Detail.Reach, low), 0.5f))).y <= 0.0f; - } - - if (!provable) - return frame.Envelope; - } - - var (affine, interval) = AffinePieces(tile, z0, z1, frame, counts); - return new float2(max(affine.x, interval.x), min(affine.y, interval.y)); - } - - private (float2 Affine, float2 Interval) AffinePieces(FogTile tile, float z0, float z1, Frame frame, Counts counts) - { - var slice = Slice(tile, z0, z1); - var (ball, axisCamera) = (slice.Ball, slice.AxisCamera); - var (height, s, fade) = (frame.Height, frame.S, frame.Fade); - var shared = slice.Coverage0 == slice.Coverage1; - counts.Grad += shared ? 2 : 3; - var n0 = slice.Coverage0.Snoise(); - var n1 = shared ? n0 : slice.Coverage1.Snoise(); - var nd = slice.Detail.Snoise(); - var w0 = Noise.Phases(tile.Time).W0; - var noise = af_add(af_add(af_scale(n0, w0), af_scale(n1, 1.0f - w0)), af_scale(nd, 0.5f)); - - // The clamp residual of z = z_m + h eps(z), 2^-23 (|z_m| + h) (af_frustum_ball). - var residual = (abs(ball.z) + axisCamera.z) * 1.1920928955078125e-7f; - var depth = af_add_iv(af_symbol(ball.z, axisCamera.z), new float2(-residual, residual)); - var lateral = tile.Half * z1 + (abs(tile.Slope.y) + tile.Half) * z1 * 2.384185791015625e-7f; - var level = af_add_iv(af_add_iv(af_add(af_point(tile.Origin.y), af_scale(depth, tile.Slope.y)), new float2(-lateral, lateral)), height); - var displaced = af_range(af_add(level, af_scale(af_mul(af_from_iv(fade), noise), Amplitude))); - var affine = new float2(max(0.0f, (FloorOffset - displaced.y) / FloorBlend), max(0.0f, (FloorOffset - displaced.x) / FloorBlend)); - var interval = Compose(s, fade, iv_add(Noise.CoverageBound(Clip(af_range(n0)), Clip(af_range(n1)), tile.Time), iv_scale(Clip(af_range(nd)), 0.5f))); - return (affine, interval); - } - } - - /// - /// (d) r1's uniform slab, kept as the worst case: the map's warped coverage field (F0 0.35, cutoff 0.25, - /// depth 12, period 4, extinction 2, flow in xy at 0.15, warp 0.05) with no envelope, so every cell is a - /// noise question. The dense sample evaluates the coverage first and the detail only where the coverage - /// passes the cutoff; ungated it would cost three snoise, as r1 counted. - /// - internal sealed class SlabField : Scenario - { - public const float F0 = 0.35f; - public const float Cutoff = 0.25f; - public const float Depth = 12.0f; - public const float SlabExtinction = 2.0f; - public const float SlabWarp = 0.05f; - - public required WarpedNoise Noise { get; init; } - - public SlabField() => Grid = Cells(0.125f, Depth); - - public static SlabField Create(float warp) => new() - { - Name = "(d) uniform slab", Noise = new WarpedNoise { F0 = F0, Warp = warp, Period = 4.0f, FlowFrequency = 0.15f, FlowInXY = true }, - }; - - public override Tile DrawTile(System.Random random, int n) => new() - { - Origin = new float3(Uniform(random, -50.0f, 50.0f), Uniform(random, -50.0f, 50.0f), 0.0f), - Slope = new float2(Uniform(random, -0.5f, 0.5f), Uniform(random, -0.5f, 0.5f)), - N = n, Focal = Focal, Time = Uniform(random, 0.0f, 100.0f), - }; - - public override float Density(Tile tile, float2 slope, float z, bool lod, Counts counts) - { - var p = tile.World(new float3(slope.x * z, slope.y * z, z)); - var coverage = Noise.Coverage(p, tile.Time, counts); - if (coverage <= Cutoff) - return 0.0f; - counts.Snoise++; - var detail = 1.0f - abs(snoise(p * (4.0f * F0) + 17.0f)); - return max(0.0f, coverage - Cutoff) * SlabExtinction * lerp(0.6f, 1.0f, detail); - } - - public override float2 Bound(Tile tile, float z0, float z1, bool gated, Counts counts) - { - var maybe = new float2(0.0f, float.MaxValue); - var ball = iv_frustum_ball(tile.Slope, z0, z1, tile.Footprint, Noise.Warp); - if (gated && Noise.CoverageBound(BestBall(Noise.CoverageRadius(ball.w), low: true), BestBall(Noise.CoverageRadius(ball.w), low: true), tile.Time).y > Cutoff) - return maybe; - var coverageBall = Noise.CoverageBall(tile.World(new float3(ball.x, ball.y, ball.z)), ball.w, counts); - var coverage = Noise.CoverageBound(coverageBall, coverageBall, tile.Time); - return coverage.y <= Cutoff ? new float2(0.0f, 0.0f) : maybe; - } - } - - /// - /// (e) The void: a cloud volume everywhere, carved by one negative pseudo-Gaussian sphere. Authored - /// knobs: hollow radius Rh (density exactly 0 inside) and ramp width S (the density rises to full over - /// [Rh, Rh + S]); everything else is derived from them. The brush (1 - (d / Rc)^2)^e with CARVE = 1.5 - /// reaches full at Rc, so Rc = Rh + S, and Rh = Rc sqrt(1 - CARVE^(-1/e)) gives - /// e = -ln CARVE / ln(1 - (Rh / Rc)^2): density = K max(0, 1 - CARVE (1 - (d' / Rc)^2)^e), exactly 0 for - /// d' <= Rh and K for d' >= Rc, K = 1/30. The noise displaces the wall: fade = - /// smoothstep(Rh - S, Rh, d), d' = d + A fade n(warp(p)), A = 20, F0 = 0.01 (wavelengths 100 and 25), - /// warp D = 10. The sun orbits the origin at radius 175 with period 72 s and rests on the hollow's - /// bottom (c_v = sun + (0, Rh - 12.5, 0)); the camera looks at sun + (0, 60, 0) and, shipped, sits 120 - /// behind the sun along the orbit tangent and 45 above it. - /// - /// The one shipped void (ruling operator-shipped-void) is Shipped(): (Rh, S) = (198, 50), so Rc = 248 - /// and e = -ln 1.5 / ln(1 - (198 / 248)^2), which the constructor derives; no other void is shipped. - /// - /// The footprint-truncated field (lod) weights octave i by w_i(z) = 1 - smoothstep(l_i / 2m, l_i / m, - /// z theta), m = 4, theta = 1 / f. Deviation from the spec's [w_i(z1), w_i(z0)]: the bound takes each - /// weight over [w_i(z1), 1], because one Bound serves the full field (w = 1) and the truncated one - /// (w in [w_i(z1), w_i(z0)], w decreasing in z); [w_i(z1), 1] contains both and iv_mul is monotone in - /// its interval argument, so the composed interval encloses both fields. The slack is only in far - /// tiles, whose step the footprint already sets. At f = 935 every weight is 1 inside every grid; - /// LodFar() (f = 467) reaches weights in (0, 1) and at 0. - /// - /// The dense grid is the fixed-step reference's: cells of min(10, S / 4) out to - /// |camera - c_v| + Rc + 6 / K. The density is provably K only from d >= Rc + A 1.5 (the free noise - /// interval), so 6 / K leaves at least 4.9 of optical depth past it and every ray goes opaque before - /// the grid ends. - /// - internal sealed class VoidField : Scenario - { - public const float Carve = 1.5f; - public const float Amplitude = 20.0f; - public const float K = 1.0f / 30.0f; - public const float StepFootprints = 4.0f; // k - public const float OctaveFootprints = 4.0f; // m - private static readonly float2 FreeNoise = new(-1.5f, 1.5f); - - public static readonly float[] HollowRadii = { 100.0f, 200.0f, 400.0f, 1000.0f }; - public static readonly float[] Ramps = { 10.0f, 50.0f, 150.0f }; - public static readonly (string Name, float Fraction)[] CameraOffsets = { ("centred", 0.0f), ("mid", 0.5f), ("low", 0.94f) }; - - public readonly float HollowRadius; - public readonly float Ramp; - public readonly float CarveRadius; - public readonly float Exponent; - public readonly float RampStart; - public readonly float FixedStep; - public readonly float CameraFraction; // negative: the shipped camera - public readonly WarpedNoise Noise = new() { F0 = 0.01f, Warp = 10.0f }; - - private float CoarseWavelength => 1.0f / Noise.F0; - private float FineWavelength => 1.0f / (4.0f * Noise.F0); - private float Theta => 1.0f / Focal; - - [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public VoidField(float hollowRadius, float ramp, float cameraFraction, string camera, float focal = 935.0f) - { - Focal = focal; - HollowRadius = hollowRadius; - Ramp = ramp; - CarveRadius = hollowRadius + ramp; - Exponent = (float)(-Math.Log(Carve) / Math.Log(1.0 - (double)hollowRadius / CarveRadius * hollowRadius / CarveRadius)); - RampStart = hollowRadius - ramp; - FixedStep = min(10.0f, ramp / 4.0f); - CameraFraction = cameraFraction; - Name = $"(e) void Rh={hollowRadius:R} camera={camera} S={ramp:R}" + (focal == 935.0f ? "" : $" f={focal:R}"); - var reach = cameraFraction < 0.0f ? length(new float2(120.0f, 45.0f - (hollowRadius - 12.5f))) : cameraFraction * hollowRadius; - Grid = Cells(FixedStep, reach + CarveRadius + 6.0f / K); - } - - public static VoidField Shipped() => new(198.0f, 50.0f, -1.0f, "shipped"); - - /// - /// The configuration that reaches the octave weights: Rh = 4000, S = 50, the low camera, f = 467 - /// (1080 rows at a 98 degree vertical field of view). The fine weight is below 1 past z = 1460 and 0 - /// past 2920, the coarse below 1 past 5840, and the grid reaches about 7990. Printed, not asserted. - /// - public static VoidField LodFar() => new(4000.0f, 50.0f, 0.94f, "low", 467.0f); - - /// The coarse and fine octave weights at depth z (1 for the full field). - public (float Coarse, float Fine) Weights(float z) => (Weight(CoarseWavelength, z * Theta), Weight(FineWavelength, z * Theta)); - - /// The coarse and fine octave weight bounds Bound uses over [z0, z1]. - public (float2 Coarse, float2 Fine) WeightBounds(float z0, float z1) => (WeightBound(CoarseWavelength, z0, z1), WeightBound(FineWavelength, z0, z1)); - - private sealed class VoidTile : Tile - { - public float3 Cavity; // c_v in the camera frame - } - - public override Tile DrawTile(System.Random random, int n) - { - var time = Uniform(random, 0.0f, 72.0f); - var angle = 2.0f * MathF.PI * time / 72.0f; - var sun = new float3(175.0f * MathF.Cos(angle), 0.0f, 175.0f * MathF.Sin(angle)); - var tangent = new float3(-MathF.Sin(angle), 0.0f, MathF.Cos(angle)); - var cavity = sun + new float3(0.0f, HollowRadius - 12.5f, 0.0f); - var target = sun + new float3(0.0f, 60.0f, 0.0f); - float3 origin; - float3 forward; - if (CameraFraction < 0.0f) - { - origin = sun - tangent * 120.0f + new float3(0.0f, 45.0f, 0.0f); - forward = target - origin; - } - else - { - // The shipped camera's direction from the centre, at a fraction of this hollow's radius; - // centred, it looks along the orbit, slightly down. - origin = cavity + normalize(tangent * -120.0f + new float3(0.0f, 45.0f - (198.0f - 12.5f), 0.0f)) * (CameraFraction * HollowRadius); - forward = CameraFraction == 0.0f ? tangent * -1.0f + new float3(0.0f, -0.2f, 0.0f) : target - origin; - } - - var tile = new VoidTile - { - Origin = origin, N = n, Focal = Focal, Time = time, - Slope = new float2((random.Next(1920 / n) * n + n * 0.5f - 960.0f) / Focal, (random.Next(1080 / n) * n + n * 0.5f - 540.0f) / Focal), - }; - tile.Look(forward); - tile.Cavity = tile.Camera(cavity); - return tile; - } - - private static float Weight(float wavelength, float footprint) => - 1.0f - smoothstep(wavelength / (2.0f * OctaveFootprints), wavelength / OctaveFootprints, footprint); - - private float2 WeightBound(float wavelength, float z0, float z1) => - new(iv_sub(iv_point(1.0f), iv_smoothstep(wavelength / (2.0f * OctaveFootprints), wavelength / OctaveFootprints, new float2(z0 * Theta, z1 * Theta))).x, 1.0f); - - /// The footprint step: max(k z theta, min(S / 4, half the finest live wavelength)). - public float LodStep(float z) - { - var footprint = z * Theta; - var fine = Weight(FineWavelength, footprint) > 0.0f ? FineWavelength : Weight(CoarseWavelength, footprint) > 0.0f ? CoarseWavelength : float.PositiveInfinity; - return max(StepFootprints * footprint, min(Ramp / 4.0f, fine / 2.0f)); - } - - private float Profile(float displaced) - { - if (displaced <= HollowRadius) - return 0.0f; - var x = displaced / CarveRadius; - var g = displaced < CarveRadius ? pow(max(0.0f, 1.0f - x * x), Exponent) : 0.0f; - return K * max(0.0f, 1.0f - Carve * g); - } - - private float2 Compose(float2 d, float2 fade, float2 n) - { - var displaced = iv_add(d, iv_scale(iv_mul(fade, n), Amplitude)); - return new float2(displaced.x >= CarveRadius ? K : 0.0f, displaced.y <= HollowRadius ? 0.0f : K); - } - - public override float Density(Tile t, float2 slope, float z, bool lod, Counts counts) - { - var tile = (VoidTile)t; - var x = slope.x * z; - var y = slope.y * z; - counts.Envelope++; - var dx = x - tile.Cavity.x; - var dy = y - tile.Cavity.y; - var dz = z - tile.Cavity.z; - var d = sqrt(dx * dx + dy * dy + dz * dz); - var fade = smoothstep(RampStart, HollowRadius, d); - var free = Compose(iv_point(d), iv_point(fade), FreeNoise); - if (free.x == free.y) - return free.x; - var p = tile.World(new float3(x, y, z)); - var wc = lod ? Weight(CoarseWavelength, z * Theta) : 1.0f; - var wd = lod ? Weight(FineWavelength, z * Theta) : 1.0f; - var coverage = wc > 0.0f ? Noise.Coverage(p, tile.Time, counts) * wc : 0.0f; - var partial = Compose(iv_point(d), iv_point(fade), iv_add(iv_point(coverage), iv_scale(new float2(-wd, wd), 0.5f))); - if (partial.x == partial.y) - return partial.x; - var detail = wd > 0.0f ? Noise.Detail(p, counts) * 0.5f * wd : 0.0f; - return Profile(d + fade * (coverage + detail) * Amplitude); - } - - /// - /// The field with no envelope gate: both noise terms always evaluated, the profile applied to the - /// displaced distance. Density's shortcuts go through Compose; this does not, so it is the value a - /// wrong Compose cannot also corrupt. Not counted. - /// - public float Exact(Tile t, float2 slope, float z, bool lod) - { - var tile = (VoidTile)t; - var counts = new Counts(); - var (x, y) = (slope.x * z, slope.y * z); - var (dx, dy, dz) = (x - tile.Cavity.x, y - tile.Cavity.y, z - tile.Cavity.z); - var d = sqrt(dx * dx + dy * dy + dz * dz); - var fade = smoothstep(RampStart, HollowRadius, d); - var p = tile.World(new float3(x, y, z)); - var wc = lod ? Weight(CoarseWavelength, z * Theta) : 1.0f; - var wd = lod ? Weight(FineWavelength, z * Theta) : 1.0f; - var n = Noise.Coverage(p, tile.Time, counts) * wc + Noise.Detail(p, counts) * 0.5f * wd; - return Profile(d + fade * n * Amplitude); - } - - public override float2 Bound(Tile t, float z0, float z1, bool gated, Counts counts) - { - var tile = (VoidTile)t; - var depth = new float2(z0, z1); - counts.Envelope++; - var (nx, fx) = AxisDistance(iv_mul(depth, tile.SlopesX), tile.Cavity.x); - var (ny, fy) = AxisDistance(iv_mul(depth, tile.SlopesY), tile.Cavity.y); - var (nz, fz) = AxisDistance(depth, tile.Cavity.z); - var d = new float2(sqrt(nx * nx + ny * ny + nz * nz), sqrt(fx * fx + fy * fy + fz * fz)); - var fade = iv_smoothstep(RampStart, HollowRadius, d); - var envelope = Compose(d, fade, FreeNoise); - if (gated && envelope.y <= 0.0f) - return envelope; - var ball = iv_frustum_ball(tile.Slope, z0, z1, tile.Footprint, Noise.Warp); - var wc = WeightBound(CoarseWavelength, z0, z1); - var wd = WeightBound(FineWavelength, z0, z1); - if (gated) - { - var provable = false; - foreach (var low in new[] { true, false }) - { - var best = iv_add(iv_mul(Noise.CoverageBound(BestBall(Noise.CoverageRadius(ball.w), low), BestBall(Noise.CoverageRadius(ball.w), low), tile.Time), wc), iv_mul(iv_scale(BestBall(Noise.DetailRadius(ball.w), low), 0.5f), wd)); - provable |= Compose(d, fade, best).y <= 0.0f; - } - - if (!provable) - return envelope; - } - - var centre = tile.World(new float3(ball.x, ball.y, ball.z)); - var coverage = Noise.CoverageBall(centre, ball.w, counts); - var noise = iv_add(iv_mul(Noise.CoverageBound(coverage, coverage, tile.Time), wc), iv_mul(iv_scale(Noise.DetailBall(centre, ball.w, counts), 0.5f), wd)); - return Compose(d, fade, noise); - } - } - - // One cell's transmittance: the density at the cell's mid-depth, over the ray's length through it. - private static float Integrate(Scenario field, Tile tile, float2 slope, float z0, float z1, bool lod, Counts counts) => - exp(-(field.Density(tile, slope, (z0 + z1) * 0.5f, lod, counts) * field.Extinction) * ((z1 - z0) * sqrt(slope.x * slope.x + slope.y * slope.y + 1.0f))); - - /// - /// The tile pre-pass on cell-index ranges: probe the slice of the range; provably empty skips it and - /// doubles the next range; otherwise a range of more than one cell halves, and a single cell is dense. - /// It starts with the whole grid, runs to the grid's end (a pre-pass knows no ray's transmittance) and - /// yields the dense cells in order. Its probes are counted once per tile. - /// - /// The body (ruling operator-analytic-wall-body): when a single dense cell's own bound is a positive - /// point (the cell is provably constant), one more probe over [grid[j], grid end]; if that is a - /// positive point too, every point of every ray of the tile over the rest of the grid has exactly that - /// density, so BodyStart = j, BodyDensity = its value, and every remaining cell is appended dense - /// without probing (adding cells is always sound, so the mask keeps its meaning). BodyStart is -1 when - /// no body is proven. - /// - private static (List Dense, int BodyStart, float BodyDensity) MarchTile(Scenario field, Tile tile, Counts probes) - { - var grid = field.Grid; - var cells = grid.Length - 1; - var dense = new List(); - var j = 0; - var span = cells; - while (j < cells) - { - var end = Math.Min(j + span, cells); - var bound = field.Bound(tile, grid[j], grid[end], gated: true, probes); - if (bound.y <= 0.0f) - { - j = end; - span = Math.Min(span * 2, cells); - } - else if (end - j > 1) - { - span = (end - j + 1) / 2; - } - else - { - if (bound.x == bound.y && bound.x > 0.0f) - { - var rest = field.Bound(tile, grid[j], grid[cells], gated: true, probes); - if (rest.x == rest.y && rest.x > 0.0f) - { - dense.AddRange(Enumerable.Range(j, cells - j)); - return (dense, j, rest.x); - } - } - - dense.Add(j); - j++; - } - } - - return (dense, -1, 0.0f); - } - - // The body's optical depth from z to the grid's end, at the density the field's pointwise envelope gives - // at z (one envelope evaluation; no probe in the main pass). MarchLod takes exp(-BodyDepth) as one step. - private static float BodyDepth(Scenario field, Tile tile, float2 slope, float z, bool lod, Counts counts) => - field.Density(tile, slope, z, lod, counts) * field.Extinction * ((field.Grid[^1] - z) * sqrt(slope.x * slope.x + slope.y * slope.y + 1.0f)); - - // The footprint-aware march, the void's shipped one: steps of LodStep(z) inside the unmasked runs only, - // octave weights applied, early-out below cutoff; at the body's start, one analytic step to the grid's - // end, and stop. AtBody is the transmittance when the march reaches the body's start, before that step, - // or the final transmittance when there is no body. - private static (float Transmittance, float AtBody) MarchLod(VoidField field, Tile tile, float2 slope, List cells, int bodyStart, float cutoff, Counts counts, ref long steps, ref long bodySteps) - { - var grid = field.Grid; - var body = bodyStart >= 0 ? grid[bodyStart] : float.PositiveInfinity; - var transmittance = 1.0f; - var k = 0; - while (k < cells.Count && transmittance >= cutoff) - { - var z = grid[cells[k]]; - var end = cells[k] + 1; - for (k++; k < cells.Count && cells[k] == end; k++) - end++; - while (z < grid[end] && transmittance >= cutoff) - { - if (z >= body) - { - var atBody = transmittance; - transmittance *= exp(-BodyDepth(field, tile, slope, z, lod: true, counts)); - steps++; - bodySteps++; - return (transmittance, atBody); - } - - var next = min(min(z + field.LodStep(z), grid[end]), z < body ? body : grid[end]); - transmittance *= Integrate(field, tile, slope, z, next, lod: true, counts); - steps++; - z = next; - } - } - - return (transmittance, transmittance); - } - - // The accuracy oracle before the body: the optical depth over every grid cell below `stop` (never the - // mask's, so it trusts no pre-pass), by midpoint quadrature at step h, accumulated in double. Not counted. - private static double ConvergedDepth(Scenario field, Tile tile, float2 slope, int stop, float h, bool lod) - { - var grid = field.Grid; - var counts = new Counts(); - var dir = Math.Sqrt(slope.x * (double)slope.x + slope.y * (double)slope.y + 1.0); - var tau = 0.0; - for (var c = 0; c < stop; c++) - { - var samples = Math.Max(1, (int)Math.Ceiling((grid[c + 1] - grid[c]) / h)); - var dz = (grid[c + 1] - grid[c]) / (double)samples; - for (var s = 0; s < samples; s++) - tau += field.Density(tile, slope, (float)(grid[c] + (s + 0.5) * dz), lod, counts) * (double)field.Extinction * dz * dir; - } - - return tau; - } - - internal sealed class RunStats - { - public readonly Counts Dense = new(); - public readonly Counts Masked = new(); - public readonly Counts Probes = new(); - public readonly Counts Lod = new(); - public readonly Counts Oracle = new(); - public readonly Counts Range = new(); - public long Rays; - public long Tiles; - public long DenseSteps; - public long MaskedSteps; - public long LodSteps; - public long BodySteps; - public long BodyTiles; - public long Unfinished; - public float MaxDifference; - public float MaxLodDifference; - public float MaxOracleDifference; - public long OracleEmpty; - public long OracleEmptySkipped; - public long RangeEmpty; - public long RangeEmptySkipped; - public long RangeViolations; - public bool Ranged; - public double MaxLodDepthError; - public double MaxRefDepthError; - - public double PerRay(double value) => value / Rays; - - // Dense cost over the tile march's: each ray's own dense cells plus the tile's probes, shared. - public double Ratio => Dense.Cost / (Masked.Cost + Probes.Cost); - - public double LodRatio => Dense.Cost / (Lod.Cost + Probes.Cost); - - // The oracle mask (the cells some ray of the tile samples nonzero) is a ceiling no pre-pass can move. - public double OracleCeiling => Dense.Cost / Oracle.Cost; - - public double Efficiency => Oracle.Cost / (Masked.Cost + Probes.Cost); - - // The tile march over the tile march plus its probes: what the probes cost, not what they cull. - public double ProbeOverhead => Masked.Cost / (Masked.Cost + Probes.Cost); - - // The oracle-empty cells the pre-pass proves empty; a pre-pass that skips nothing scores 0. - public double CullFraction => (double)OracleEmptySkipped / OracleEmpty; - - // The range ceiling: the oracle march's cost over the range mask's, with probes free. The range - // mask is what an exact enclosure of each cell over the tile's whole slice could prove, so no sound - // bound can reach the oracle, only this; it is sampled, so it is an upper estimate. - public double RangeCeiling => Oracle.Cost / Range.Cost; - - // The tile march's efficiency against the range ceiling: the range mask's cost over the tile - // march's with its probes. - public double RangeEfficiency => Range.Cost / (Masked.Cost + Probes.Cost); - - public double RangeCull => (double)RangeEmptySkipped / RangeEmpty; - } - - /// - /// Draws `tiles` tiles, runs the pre-pass once per tile, draws the tile's N^2 ray slopes (one per pixel, - /// jittered inside it), builds the oracle mask (the cells whose mid-depth density is nonzero for at least - /// one of those slopes), and marches each ray densely over every cell, masked over the tile's dense cells - /// and over the oracle cells, all with the early-out at 0.02 and the same Integrate. With lod, the - /// footprint-aware march as well, and the agreement at the body start (or the grid's end): the optical - /// depth of a cutoff-0 footprint march and of the fixed-step cells, each against ConvergedDepth at - /// h = 0.5. The oracle mask and the agreement marches count into throwaway Counts, the oracle march into - /// its own, so the cost rows do not move. With range, the range mask as well: the oracle mask plus - /// every cell where the density is positive at any of 5 x 5 slopes over the tile's slope square - /// (corners included) x 9 depths over the cell; each ray is marched over it into Range, and a cell of - /// it the pre-pass skipped is counted as a range violation (a sampled point a bound failed to enclose). - /// - private static RunStats Run(Scenario field, int n, int tiles, int seed, bool lod = false, bool range = false) - { - var random = new System.Random(seed); - var stats = new RunStats { Ranged = range }; - var scratch = new Counts(); - var grid = field.Grid; - for (var t = 0; t < tiles; t++) - { - var tile = field.DrawTile(random, n); - var (cells, bodyStart, _) = MarchTile(field, tile, stats.Probes); - Assert.True(field is VoidField || bodyStart < 0, $"{field.Name}: a body reported at cell {bodyStart}; only the void's density can be provably constant"); - stats.Tiles++; - stats.BodyTiles += bodyStart >= 0 ? 1 : 0; - var slopes = new List(); - for (var j = 0; j < n; j++) - for (var i = 0; i < n; i++) - slopes.Add(tile.PixelSlope(i, j, random.NextSingle(), random.NextSingle())); - var inMask = new HashSet(cells); - var oracle = new List(); - for (var c = 0; c < grid.Length - 1; c++) - { - var mid = (grid[c] + grid[c + 1]) * 0.5f; - if (slopes.Any(s => field.Density(tile, s, mid, false, scratch) > 0.0f)) - { - oracle.Add(c); - } - else - { - stats.OracleEmpty++; - stats.OracleEmptySkipped += inMask.Contains(c) ? 0 : 1; - } - } - - var ranged = new List(); - if (range) - { - var inOracle = new HashSet(oracle); - for (var c = 0; c < grid.Length - 1; c++) - { - var sampled = inOracle.Contains(c); - for (var a = 0; a < 5 && !sampled; a++) - for (var b = 0; b < 5 && !sampled; b++) - for (var k = 0; k < 9 && !sampled; k++) - { - var slope = new float2(tile.SlopesX.x + (tile.SlopesX.y - tile.SlopesX.x) * a / 4.0f, tile.SlopesY.x + (tile.SlopesY.y - tile.SlopesY.x) * b / 4.0f); - sampled = field.Density(tile, slope, grid[c] + (grid[c + 1] - grid[c]) * k / 8.0f, false, scratch) > 0.0f; - } - - if (sampled) - { - ranged.Add(c); - stats.RangeViolations += inMask.Contains(c) ? 0 : 1; - } - else - { - stats.RangeEmpty++; - stats.RangeEmptySkipped += inMask.Contains(c) ? 0 : 1; - } - } - } - - var stop = bodyStart >= 0 ? bodyStart : grid.Length - 1; - foreach (var slope in slopes) - { - var dense = 1.0f; - for (var c = 0; c < grid.Length - 1 && dense >= 0.02f; c++, stats.DenseSteps++) - dense *= Integrate(field, tile, slope, grid[c], grid[c + 1], lod: false, stats.Dense); - var masked = 1.0f; - for (var c = 0; c < cells.Count && masked >= 0.02f; c++, stats.MaskedSteps++) - masked *= Integrate(field, tile, slope, grid[cells[c]], grid[cells[c] + 1], lod: false, stats.Masked); - var exact = 1.0f; - for (var c = 0; c < oracle.Count && exact >= 0.02f; c++) - exact *= Integrate(field, tile, slope, grid[oracle[c]], grid[oracle[c] + 1], lod: false, stats.Oracle); - var rangedT = 1.0f; - for (var c = 0; c < ranged.Count && rangedT >= 0.02f; c++) - rangedT *= Integrate(field, tile, slope, grid[ranged[c]], grid[ranged[c] + 1], lod: false, stats.Range); - stats.Rays++; - stats.MaxDifference = MathF.Max(stats.MaxDifference, MathF.Abs(dense - masked)); - stats.MaxOracleDifference = MathF.Max(stats.MaxOracleDifference, MathF.Abs(dense - exact)); - if (dense >= 0.02f) - stats.Unfinished++; - if (lod) - { - var (marched, _) = MarchLod((VoidField)field, tile, slope, cells, bodyStart, 0.02f, stats.Lod, ref stats.LodSteps, ref stats.BodySteps); - stats.MaxLodDifference = MathF.Max(stats.MaxLodDifference, MathF.Abs(dense - marched)); - long ignoredSteps = 0, ignoredBody = 0; - var (_, atBody) = MarchLod((VoidField)field, tile, slope, cells, bodyStart, 0.0f, scratch, ref ignoredSteps, ref ignoredBody); - var reference = 1.0; - for (var c = 0; c < stop; c++) - reference *= Integrate(field, tile, slope, grid[c], grid[c + 1], lod: false, scratch); - var tauConv = ConvergedDepth(field, tile, slope, stop, 0.5f, lod: true); - var tauLod = -Math.Log(Math.Max(atBody, 1.0e-30f)); - var tauRef = -Math.Log(Math.Max(reference, 1.0e-300)); - var scale = Math.Max(tauConv, 1.0e-3); - stats.MaxLodDepthError = Math.Max(stats.MaxLodDepthError, Math.Abs(tauLod - tauConv) / scale); - stats.MaxRefDepthError = Math.Max(stats.MaxRefDepthError, Math.Abs(tauRef - tauConv) / scale); - } - } - } - - return stats; - } - - private void Report(string label, RunStats s) => output.WriteLine( - $"IV-REPORT {label}: dense snoise/ray {s.PerRay(s.Dense.Snoise):F2} env/ray {s.PerRay(s.Dense.Envelope):F2} (samples/ray {s.PerRay(s.DenseSteps):F2}); " - + $"tile snoise/ray {s.PerRay(s.Masked.Snoise + (double)s.Probes.Snoise):F2} env/ray {s.PerRay(s.Masked.Envelope + (double)s.Probes.Envelope):F2} grad/ray {s.PerRay(s.Probes.Grad):F2} " - + $"(probes/tile env {(double)s.Probes.Envelope / s.Tiles:F1} snoise {(double)s.Probes.Snoise / s.Tiles:F2} grad {(double)s.Probes.Grad / s.Tiles:F2}; dense cells/ray {s.PerRay(s.MaskedSteps):F2}); " - + $"cost ratio {s.Ratio:F2}x, oracle ceiling {s.OracleCeiling:F2}x, efficiency {s.Efficiency:F3}, cull fraction {s.CullFraction:F3} ({s.OracleEmptySkipped}/{s.OracleEmpty}), " - + $"probe overhead {s.ProbeOverhead:F3}; max |dT| {s.MaxDifference:R}, oracle {s.MaxOracleDifference:R}; unfinished rays {s.Unfinished}" - + (s.Ranged - ? $"; range ceiling {s.RangeCeiling:F3} (oracle cost over the range mask's), efficiency against it {s.RangeEfficiency:F3}, range cull {s.RangeCull:F3} ({s.RangeEmptySkipped}/{s.RangeEmpty}), range violations {s.RangeViolations}" - : "")); - - private void ReportVoid(string label, RunStats s) => output.WriteLine( - $"IV-REPORT {label}: steps/px ref {s.PerRay(s.DenseSteps):F2}, masked {s.PerRay(s.MaskedSteps):F2}, LOD {s.PerRay(s.LodSteps):F2} ({(double)s.DenseSteps / s.LodSteps:F2}x fewer); " - + $"snoise/px ref {s.PerRay(s.Dense.Snoise):F2}, masked {s.PerRay(s.Masked.Snoise):F2}, LOD {s.PerRay(s.Lod.Snoise):F2}; " - + $"cost/px ref {s.PerRay(s.Dense.Cost):F2}, masked {s.PerRay(s.Masked.Cost + s.Probes.Cost):F2}, LOD {s.PerRay(s.Lod.Cost + s.Probes.Cost):F2} incl. probes (ref/LOD {s.LodRatio:F2}x, ref/masked {s.Ratio:F2}x); " - + $"probes/tile env {(double)s.Probes.Envelope / s.Tiles:F1} snoise {(double)s.Probes.Snoise / s.Tiles:F2}; body tiles {s.BodyTiles}/{s.Tiles}, analytic steps/px {s.PerRay(s.BodySteps):F2}; " - + $"depth error at the body start vs converged: LOD {s.MaxLodDepthError:G4}, fixed-step {s.MaxRefDepthError:G4} (ratio {s.MaxLodDepthError / s.MaxRefDepthError:F2}); " - + $"end-of-ray max |dT| masked {s.MaxDifference:R}, LOD {s.MaxLodDifference:R}; unfinished rays {s.Unfinished}"); - - /// - /// The analytic body's soundness pin (ruling operator-analytic-wall-body). Over 2,000 seeded tiles of - /// the (e) grid, the shipped void and LOD-far at N in {1, 4, 8, 16}, wherever the pre-pass reports a - /// body start b: (1) the gated bound over [grid[b], grid end] is a positive point equal to the reported - /// density, every cell from b to the end is in the mask, and at 64 random (pixel, sub-pixel, cell >= b, - /// depth in cell) points the full and the truncated Density and the ungated Exact field all equal it - /// exactly, no tolerance; (2) BodyDepth, the optical depth MarchLod's one closed-form step uses, equals - /// the summed fixed-step depth -ln Integrate of the body cells (no early-out, same cells) within 1e-4 - /// relative, compared in the depth domain so LOD-far's deep bodies do not underflow. (3) No tile of (a)-(d), at either warp, reports a body: their bounds are never a positive - /// point. - /// - [Fact] - public void AnalyticBodyMatchesFineMarch() - { - var random = new System.Random(0xB0D1); - int[] sizes = { 1, 4, 8, 16 }; - var voids = new List(); - foreach (var rh in VoidField.HollowRadii) - foreach (var offset in VoidField.CameraOffsets) - foreach (var ramp in VoidField.Ramps) - voids.Add(new VoidField(rh, ramp, offset.Fraction, offset.Name)); - voids.Add(VoidField.Shipped()); - voids.Add(VoidField.LodFar()); - var counts = new Counts(); - var bodies = new Dictionary(); - for (var t = 0; t < 2000; t++) - { - var field = t % 4 == 0 ? voids[^2] : t % 4 == 1 ? voids[^1] : voids[random.Next(voids.Count)]; - var tile = field.DrawTile(random, sizes[random.Next(sizes.Length)]); - var (cells, b, density) = MarchTile(field, tile, counts); - if (b < 0) - continue; - bodies[field.Name] = bodies.GetValueOrDefault(field.Name) + 1; - var grid = field.Grid; - var last = grid.Length - 1; - var rest = field.Bound(tile, grid[b], grid[last], gated: true, counts); - Assert.True(rest.x == rest.y && rest.x > 0.0f && rest.x == density, $"{field.Name}: body at cell {b} with density {density:R}, but the bound over the rest is {rest}"); - Assert.Equal(Enumerable.Range(b, last - b), cells.Skip(cells.Count - (last - b))); - for (var i = 0; i < 64; i++) - { - var slope = tile.PixelSlope(random.Next(tile.N), random.Next(tile.N), random.NextSingle(), random.NextSingle()); - var c = random.Next(b, last); - var z = Uniform(random, grid[c], grid[c + 1]); - foreach (var lod in new[] { false, true }) - { - var pointwise = field.Density(tile, slope, z, lod, counts); - var exact = field.Exact(tile, slope, z, lod); - Assert.True(pointwise == density && exact == density, $"{field.Name}: body from cell {b} claims {density:R}; at slope {slope}, depth {z:R} (cell {c}, lod {lod}) Density is {pointwise:R} and the ungated field {exact:R}"); - } - } - - var ray = tile.PixelSlope(random.Next(tile.N), random.Next(tile.N), random.NextSingle(), random.NextSingle()); - var depth = BodyDepth(field, tile, ray, grid[b], lod: true, counts); - var sum = 0.0; - for (var c = b; c < last; c++) - sum += -Math.Log(Integrate(field, tile, ray, grid[c], grid[c + 1], lod: true, counts)); - Assert.True(Math.Abs(depth - sum) <= 1.0e-4 * sum, $"{field.Name}: the body's depth from cell {b}, BodyDepth {depth:R}, differs from the fixed-step cells' summed depth {sum:R} over cells {b}..{last}"); - } - - output.WriteLine("IV-REPORT analytic body: tiles with a body " + string.Join(", ", bodies.OrderBy(kv => kv.Key).Select(kv => $"{kv.Key} {kv.Value}"))); - Assert.True(bodies.ContainsKey(VoidField.Shipped().Name) && bodies.ContainsKey(VoidField.LodFar().Name), "no body proven at the shipped void or at LOD-far"); - - var scenarios = new (float Warp, Func Make)[] - { - (FogField.AetheriaWarp, w => FogField.HeightFog(w, BoundMode.Interval)), (FogField.AetheriaWarp, w => FogField.InsideFog(w, BoundMode.Interval)), - (FogField.AetheriaWarp, w => FogField.DeepWell(w, BoundMode.Interval)), (FogField.AetheriaWarp, w => FogField.DeepWell(w, BoundMode.Affine)), - (FogField.AetheriaWarp, w => FogField.Wells(w, BoundMode.Interval)), (FogField.AetheriaWarp, w => FogField.Wells(w, BoundMode.Affine)), - (SlabField.SlabWarp, SlabField.Create), - }; - foreach (var (warp, make) in scenarios) - foreach (var w in new[] { 0.0f, warp }) - { - var field = make(w); - for (var t = 0; t < 250; t++) - { - var (_, b, _) = MarchTile(field, field.DrawTile(random, sizes[random.Next(sizes.Length)]), counts); - Assert.True(b < 0, $"{field.Name} warp {w:R}: a body reported at cell {b}"); - } - } - } - - /// - /// The proving ground (docs/cultmath-interval-ground-cut.md, "Pass 3", "Pass 4" and "Pass 5b"). - /// Scenarios (a) height fog and (b) inside the fog under the centred-warp interval bound, (c) the deep - /// well and (c-band) the shallow wells each under the centred-warp interval bound and the affine bound - /// on the same seeds, and (d) r1's uniform slab, each over 64 tiles at N in {1, 4, 8, 16} and warp in - /// {0, D}; (c) and (c-band) also print the range ceiling at N = 8, and no range-mask cell is skipped: the tile march integrates exactly the dense march's - /// cells, so the transmittance agrees within 1e-3 (a difference would be a skipped cell that was not - /// empty), the oracle march (each ray over the oracle mask: the cells whose mid-depth density is nonzero - /// for at least one of the tile's rays) agrees with the dense march exactly, and no (a)-(d) tile reports - /// a body. (e) the void: the grid over hollow radius, camera offset and ramp width (32 tiles at N = 8), - /// LOD-far (32 tiles) and the one shipped void (200 tiles), three marches each, the footprint-aware one - /// taking the analytic body step. Contracts at N = 8: (a) at least 2x combined cost, the lower of warp - /// 0 and D; (c) (ruling affine-wells-contract-cheaper-than-interval) on the deep well the affine - /// bound's combined cost ratio exceeds the centred interval's at warp 0 and at warp D, and, hard - /// (ruling wells-overhead-plus-floor), the pre-pass proves at least half of the oracle-empty cells - /// empty under both bounds at both warps; probe overhead, the efficiency against the oracle and against - /// the range ceiling, the ceilings and the cull fraction are printed, not asserted; (c-band) is - /// printed only; (e) at the shipped void the masked fixed-step march agrees with the reference exactly, the - /// footprint-aware march's optical depth at the body start is off a converged march (h = 0.5, every - /// cell) by at most twice the fixed-step march's error, and it takes at most half the reference's - /// steps per pixel. A broken (c) contract fails the test; a shortfall of the (a) or (e) saving skips - /// naming saving-2x-scenarios and every such shortfall. The fields, the grids and the envelope cost are - /// not tuned toward either. - /// - [Fact] - public void IntervalSkipHalvesEvaluations() - { - var atEight = new Dictionary<(string Key, float Warp), RunStats>(); - var scenarios = new (string Key, float Warp, Func Make)[] - { - ("a", FogField.AetheriaWarp, w => FogField.HeightFog(w, BoundMode.Interval)), - ("b", FogField.AetheriaWarp, w => FogField.InsideFog(w, BoundMode.Interval)), - ("c interval", FogField.AetheriaWarp, w => FogField.DeepWell(w, BoundMode.Interval)), - ("c affine", FogField.AetheriaWarp, w => FogField.DeepWell(w, BoundMode.Affine)), - ("c-band interval", FogField.AetheriaWarp, w => FogField.Wells(w, BoundMode.Interval)), - ("c-band affine", FogField.AetheriaWarp, w => FogField.Wells(w, BoundMode.Affine)), - ("d", SlabField.SlabWarp, SlabField.Create), - }; - foreach (var (key, warp, make) in scenarios) - foreach (var n in new[] { 1, 4, 8, 16 }) - foreach (var w in new[] { 0.0f, warp }) - { - var field = make(w); - var stats = Run(field, n, 64, 0x5A7E + n, range: n == 8 && key.StartsWith('c')); - Report($"{field.Name} N={n} warp={w:R}", stats); - Assert.True(stats.RangeViolations == 0, $"{field.Name} N={n} warp={w:R}: the pre-pass skipped {stats.RangeViolations} cells where a sampled density is positive"); - Assert.True(stats.MaxDifference <= 1.0e-3f, $"{field.Name} N={n} warp={w:R}: transmittance differs by {stats.MaxDifference:R}"); - Assert.True(stats.MaxOracleDifference == 0.0f, $"{field.Name} N={n} warp={w:R}: the oracle march differs from the dense march by {stats.MaxOracleDifference:R}"); - if (key == "d") - output.WriteLine($"IV-REPORT (d) N={n} warp={w:R}: ungated dense snoise/ray {3.0 * stats.PerRay(stats.DenseSteps):F2} (three per dense sample, as r1 counted)"); - if (n == 8) - atEight[(key, w)] = stats; - } - - var warps = new[] { 0.0f, FogField.AetheriaWarp }; - var costA = warps.Min(w => atEight[("a", w)].Ratio); - var cullFloor = double.MaxValue; - var gains = new List(); - var shortfalls = new List(); - var broken = new List(); - foreach (var w in warps) - { - var interval = atEight[("c interval", w)]; - var affine = atEight[("c affine", w)]; - foreach (var (mode, stats) in new[] { ("interval", interval), ("affine", affine) }) - { - Assert.True(stats.CullFraction >= 0.5, $"(c) {mode} warp={w:R}: the pre-pass proves {stats.CullFraction:F3} of the oracle-empty cells empty, under the 0.5 floor (ruling wells-overhead-plus-floor)"); - cullFloor = Math.Min(cullFloor, stats.CullFraction); - } - - var band = (atEight[("c-band interval", w)], atEight[("c-band affine", w)]); - gains.Add($"warp {w:R}: (c) affine {affine.Ratio:F2}x against centred interval {interval.Ratio:F2}x ({affine.Ratio / interval.Ratio:F2}x), probe overhead {affine.ProbeOverhead:F3} and {interval.ProbeOverhead:F3}, " - + $"efficiency {affine.Efficiency:F3} and {interval.Efficiency:F3} against the oracle, {affine.RangeEfficiency:F3} and {interval.RangeEfficiency:F3} against the range ceiling {affine.RangeCeiling:F3}; " - + $"(c-band) {band.Item2.Ratio:F2}x against {band.Item1.Ratio:F2}x ({band.Item2.Ratio / band.Item1.Ratio:F2}x)"); - if (!(affine.Ratio > interval.Ratio)) - broken.Add($"(c) warp {w:R}: affine {affine.Ratio:F2}x is not cheaper than the centred interval's {interval.Ratio:F2}x"); - } - - foreach (var rh in VoidField.HollowRadii) - foreach (var offset in VoidField.CameraOffsets) - foreach (var ramp in VoidField.Ramps) - { - var field = new VoidField(rh, ramp, offset.Fraction, offset.Name); - ReportVoid($"{field.Name} N=8", Run(field, 8, 32, 0x701D, lod: true)); - } - - var lodFar = VoidField.LodFar(); - ReportVoid($"{lodFar.Name} N=8 (LOD far)", Run(lodFar, 8, 32, 0x701D, lod: true)); - - var shipped = VoidField.Shipped(); - var headline = Run(shipped, 8, 200, 0x5417, lod: true); - ReportVoid($"{shipped.Name} N=8 (headline, 200 tiles)", headline); - Assert.True(headline.MaxDifference == 0.0f, $"the masked fixed-step march differs from the reference by {headline.MaxDifference:R}"); - Assert.True(headline.MaxLodDepthError <= 2.0 * headline.MaxRefDepthError, $"at the body start the footprint-aware march's optical depth is off the converged march's by {headline.MaxLodDepthError:G6} relative, more than twice the fixed-step march's {headline.MaxRefDepthError:G6}"); - var steps = (double)headline.DenseSteps / headline.LodSteps; - - if (costA < 2.0) - shortfalls.Add($"(a) saves {costA:F2}x combined cost, under 2x"); - if (steps < 2.0) - shortfalls.Add($"(e) takes {steps:F2}x fewer steps per pixel at the shipped void, under 2x"); - output.WriteLine($"IV-REPORT contracts at N=8: (a) {costA:F2}x cost (lower of warp 0 and D, at least 2x); (c) affine cheaper than the centred interval at both warps, cull fraction {cullFloor:F3} (at least 0.5 under both bounds, hard); " - + $"(e) {steps:F2}x fewer steps/px, depth error at the body start LOD {headline.MaxLodDepthError:G4} vs fixed-step {headline.MaxRefDepthError:G4} (at most 2x)"); - foreach (var line in gains) - output.WriteLine($"IV-REPORT (c) at N=8, {line}"); - Assert.True(broken.Count == 0, "ruling affine-wells-contract-cheaper-than-interval: " + string.Join("; ", broken)); - if (shortfalls.Count > 0) - Assert.Skip("saving-2x-scenarios: " + string.Join("; ", shortfalls)); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/NoiseGradTests.cs b/packages/cultmath/tests/CultMath.Tests/NoiseGradTests.cs deleted file mode 100644 index 3fe922f9..00000000 --- a/packages/cultmath/tests/CultMath.Tests/NoiseGradTests.cs +++ /dev/null @@ -1,439 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -public sealed class NoiseGradTests -{ - // ---- Invariant-8 property harness (shared by snoise_grad, fbm_grad, ridged_grad) ---- - // - // Each test compares a function's analytic gradient with central differences of its own .w at - // random points in [-3, 3]^3. eps trades curvature error (eps too large) against float32 - // rounding noise (eps too small). snoise is continuous across simplex-cell boundaries (the - // continuity test below), so no point needs excluding for a seam; ridged_grad excludes a band - // around its own deliberate crease. Each tolerance is at least 5x the largest error the harness - // itself produces at its seed. - private const float PropertyEps = 0.0001f; - private const float SnoiseGradTolerance = 0.03f; - private const float FbmGradTolerance = 0.05f; - private const float RidgedGradTolerance = 0.05f; - - [Fact] - public void SnoiseGradGradientMatchesCentralDifferencesOfItsOwnValue() - { - var random = new System.Random(0xA11CE); - var tested = 0; - var attempts = 0; - while (tested < 200 && attempts < 20000) - { - attempts++; - var p = RandomPoint(random); - var g = math.snoise_grad(p); - float F(float3 q) => math.snoise_grad(q).w; - var fine = CentralDifference(F, p, PropertyEps); - - tested++; - AssertGradientWithinTolerance(fine, g, SnoiseGradTolerance); - } - - Assert.True(tested >= 150, $"only {tested} of {attempts} points were usable"); - } - - [Fact] - public void FbmGradGradientMatchesCentralDifferencesOfItsOwnValue() - { - const int octaves = 4; - const float lacunarity = 2.0f; - const float gain = 0.5f; - var random = new System.Random(0xA11CF); - var tested = 0; - var attempts = 0; - while (tested < 200 && attempts < 40000) - { - attempts++; - var p = RandomPoint(random); - var g = math.fbm_grad(p, octaves, lacunarity, gain); - float F(float3 q) => math.fbm_grad(q, octaves, lacunarity, gain).w; - var fine = CentralDifference(F, p, PropertyEps); - - tested++; - AssertGradientWithinTolerance(fine, g, FbmGradTolerance); - } - - Assert.True(tested >= 150, $"only {tested} of {attempts} points were usable"); - } - - [Fact] - public void RidgedGradGradientMatchesCentralDifferencesExcludingAnyOctavesZeroBand() - { - // ridged_grad's own crease (any octave's n_i = 0) is a real, deliberate discontinuity - // (design.md, "the operator's dune term"), not a numerical artifact: exclude a band around it - // for every octave, the same way cellular excludes its F1 = F2 seam. - const float zeroBand = 0.1f; - const int octaves = 3; - const float lacunarity = 2.0f; - const float gain = 0.5f; - var random = new System.Random(0xA11D0); - var tested = 0; - var attempts = 0; - while (tested < 200 && attempts < 80000) - { - attempts++; - var p = RandomPoint(random); - if (AnyOctaveNearZero(p, octaves, lacunarity, zeroBand)) - continue; - - var g = math.ridged_grad(p, octaves, lacunarity, gain); - float F(float3 q) => math.ridged_grad(q, octaves, lacunarity, gain).w; - var fine = CentralDifference(F, p, PropertyEps); - - tested++; - AssertGradientWithinTolerance(fine, g, RidgedGradTolerance); - } - - Assert.True(tested >= 150, $"only {tested} of {attempts} points were outside the zero band"); - } - - private static bool AnyOctaveNearZero(float3 p, int octaves, float lacunarity, float band) - { - var frequency = 1.0f; - for (var i = 0; i < octaves; i++) - { - if (MathF.Abs(math.snoise_grad(p * frequency).w) < band) - return true; - frequency *= lacunarity; - } - - return false; - } - - private static float3 RandomPoint(System.Random random) => new( - random.NextSingle() * 6.0f - 3.0f, random.NextSingle() * 6.0f - 3.0f, random.NextSingle() * 6.0f - 3.0f); - - private static float3 CentralDifference(Func f, float3 p, float eps) => new( - (f(p + new float3(eps, 0.0f, 0.0f)) - f(p - new float3(eps, 0.0f, 0.0f))) / (2.0f * eps), - (f(p + new float3(0.0f, eps, 0.0f)) - f(p - new float3(0.0f, eps, 0.0f))) / (2.0f * eps), - (f(p + new float3(0.0f, 0.0f, eps)) - f(p - new float3(0.0f, 0.0f, eps))) / (2.0f * eps)); - - private static void AssertGradientWithinTolerance(float3 numeric, float4 analytic, float tolerance) - { - AssertWithinTolerance(numeric.x, analytic.x, tolerance); - AssertWithinTolerance(numeric.y, analytic.y, tolerance); - AssertWithinTolerance(numeric.z, analytic.z, tolerance); - } - - private static void AssertWithinTolerance(float expected, float actual, float tolerance) => - Assert.True(MathF.Abs(expected - actual) <= tolerance, $"expected {expected}, actual {actual}, tolerance {tolerance}"); - - // ---- snoise is continuous across simplex-cell boundaries ---- - - // The simplex corner set (i, i1, i2) summed by snoise(float3), derived the same way snoise does. - private static (float3 i, float3 i1, float3 i2) SimplexCell(float3 p) - { - var i = math.floor(p + math.dot(p, new float3(1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 3.0f))); - var x0 = p - i + math.dot(i, new float3(1.0f / 6.0f, 1.0f / 6.0f, 1.0f / 6.0f)); - var g = new float3(math.step(x0.y, x0.x), math.step(x0.z, x0.y), 1.0f - math.step(x0.z, x0.x)); - var l = 1.0f - g; - var lzxy = new float3(l.z, l.x, l.y); - return (i, math.min(g, lzxy), math.max(g, lzxy)); - } - - [Fact] - public void SnoiseAndItsGradientAreContinuousAcrossSimplexCellBoundaries() - { - // March random lines in steps of 1e-3 until the corner set changes, bisect the crossing to - // float precision, and compare the two sides. With a kernel radius^2 above 0.5 a lattice - // vertex outside the four summed corners can lie inside the kernel, which leaves a value - // jump at the boundary (stegu/webgl-noise fixed it in 21d9fe23d7); at 0.5 the jump is float - // noise. A value jump below 1e-5 and a gradient jump below 1e-4 is float noise on both sides. - const int lines = 400; - const int maxSteps = 20000; - const float dt = 1.0e-3f; - var random = new System.Random(0x5EA4); - var crossings = 0; - var maxValueJump = 0.0f; - var maxGradientJump = 0.0f; - for (var line = 0; line < lines; line++) - { - var origin = RandomPoint(random); - var direction = math.normalize(new float3( - random.NextSingle() - 0.5f, random.NextSingle() - 0.5f, random.NextSingle() - 0.5f)); - var start = SimplexCell(origin); - var t = 0.0f; - var found = false; - for (var step = 0; step < maxSteps && !found; step++) - { - t += dt; - found = !SimplexCell(origin + direction * t).Equals(start); - } - - Assert.True(found, $"line {line} never left its simplex cell in {maxSteps} steps"); - - double lo = t - dt; - double hi = t; - for (var bisect = 0; bisect < 60; bisect++) - { - var mid = 0.5 * (lo + hi); - if (SimplexCell(origin + direction * (float)mid).Equals(start)) lo = mid; else hi = mid; - } - - var a = math.snoise_grad(origin + direction * (float)lo); - var b = math.snoise_grad(origin + direction * (float)hi); - crossings++; - maxValueJump = MathF.Max(maxValueJump, MathF.Abs(a.w - b.w)); - maxGradientJump = MathF.Max(maxGradientJump, MathF.Max(MathF.Abs(a.x - b.x), MathF.Max(MathF.Abs(a.y - b.y), MathF.Abs(a.z - b.z)))); - } - - Assert.Equal(lines, crossings); - Assert.True(maxValueJump < 1.0e-5f, $"value jump {maxValueJump} across a simplex boundary"); - Assert.True(maxGradientJump < 1.0e-4f, $"gradient jump {maxGradientJump} across a simplex boundary"); - } - - // The simplex diagonals are where x0's three components compare equal. The tie rule must be a total - // order there (math.snoise): with a cyclic or all-strict compare the four corners stop being a - // simplex and the value jumps wherever x0 has three equal components (inputs whose differences y - x and - // z - x are whole numbers, the line (t, t, t) among them): about 0.77 near the origin, up to 1.56 at - // magnitudes of 64 and above. SnoiseTieScopeTests pins the set against the 0.3.0 values. - [Fact] - public void SnoiseIsContinuousOnTheSimplexDiagonal() - { - const int vertices = 160; - const int perVertex = 8; - var random = new System.Random(0x71E5); - var points = new System.Collections.Generic.List(); - for (var k = 0; k < 400; k++) - { - var t = (float)(random.NextDouble() * 128.0 - 64.0); - points.Add(new float3(t, t, t)); - } - - points.Add(new float3(0.0f, 0.0f, 0.0f)); - for (var k = 0; k < vertices; k++) - { - var lx = random.Next(-64, 65); - var ly = random.Next(-64, 65); - var lz = random.Next(-64, 65); - var shift = (lx + ly + lz) / 6.0f; - var v = new float3(lx - shift, ly - shift, lz - shift); - for (var j = 0; j < perVertex; j++) - { - var s = j == 0 ? 0.0f : random.NextSingle(); - points.Add(new float3(v.x + s, v.y + s, v.z + s)); - } - } - - foreach (var p in points) - { - var value = math.snoise(p); - for (var axis = 0; axis < 3; axis++) - { - for (var direction = -1; direction <= 1; direction += 2) - { - var q = p; - for (var ulp = 1; ulp <= 2; ulp++) - { - var component = axis == 0 ? q.x : axis == 1 ? q.y : q.z; - component = direction < 0 ? MathF.BitDecrement(component) : MathF.BitIncrement(component); - q = axis == 0 ? new float3(component, q.y, q.z) : axis == 1 ? new float3(q.x, component, q.z) : new float3(q.x, q.y, component); - var jump = MathF.Abs(math.snoise(q) - value); - Assert.True(jump <= 1.0e-4f, $"snoise jumps {jump} within {ulp} ulp of {p}"); - } - } - } - - var grad = math.snoise_grad(p); - Assert.Equal(BitConverter.SingleToInt32Bits(value), BitConverter.SingleToInt32Bits(grad.w)); - var slope = math.length(new float3(grad.x, grad.y, grad.z)); - Assert.True(slope <= math.SNOISE_LIPSCHITZ, $"|snoise_grad| {slope} exceeds SNOISE_LIPSCHITZ at {p}"); - } - } - - // ---- snoise_grad.w vs snoise ---- - - [Fact] - public void SnoiseGradValueIsBitEqualToSnoise() - { - // Both compute 105 * dot(m4, px) via the exact same operation order (math.cs comment on - // snoise_grad), so this asserts bit equality over 5,000 random points in [-100, 100]^3. - var random = new System.Random(0x50F2); - for (var i = 0; i < 5000; i++) - { - var p = new float3( - random.NextSingle() * 200.0f - 100.0f, random.NextSingle() * 200.0f - 100.0f, random.NextSingle() * 200.0f - 100.0f); - var expected = math.snoise(p); - var actual = math.snoise_grad(p).w; - Assert.Equal(BitConverter.SingleToInt32Bits(expected), BitConverter.SingleToInt32Bits(actual)); - } - } - - // ---- fbm_grad / ridged_grad: per-octave gain and lacunarity ---- - - [Fact] - public void FbmGradWithOneOctaveEqualsSnoiseGrad() - { - var random = new System.Random(0xF6B10); - for (var i = 0; i < 64; i++) - { - var p = RandomPoint(random); - var lacunarity = 1.0f + random.NextSingle() * 3.0f; - var gain = 0.1f + random.NextSingle() * 0.8f; - - var expected = math.snoise_grad(p); - var actual = math.fbm_grad(p, 1, lacunarity, gain); - - Assert.Equal(expected.x, actual.x); - Assert.Equal(expected.y, actual.y); - Assert.Equal(expected.z, actual.z); - Assert.Equal(expected.w, actual.w); - } - } - - [Fact] - public void FbmGradCompoundsGainAndLacunarityPerOctaveNotOnce() - { - // Falsifies two mutant shapes at once: applying gain/lacunarity once for the whole sum - // instead of compounding per octave, and swapping which argument drives amplitude versus - // frequency. lacunarity != gain and both != 1 so a swap changes the result, and 3 octaves - // gives amplitude/frequency three distinct compounded values (1, gain, gain^2 and - // 1, lacunarity, lacunarity^2) so "applied once" mutants cannot coincidentally match. - // The expected value is built by the same incremental multiply chain fbm_grad itself uses - // (frequency *= lacunarity, amplitude *= gain, one step at a time, not lacunarity*lacunarity - // or MathF.Pow), so this asserts bit-exact equality rather than needing a tolerance. - const float lacunarity = 2.5f; - const float gain = 0.6f; - var random = new System.Random(0xF6B11); - for (var i = 0; i < 32; i++) - { - var p = RandomPoint(random); - - var frequency = 1.0f; - var amplitude = 1.0f; - var n0 = math.snoise_grad(p * frequency); - var expectedValue = amplitude * n0.w; - var expectedGradient = amplitude * frequency * new float3(n0.x, n0.y, n0.z); - frequency *= lacunarity; - amplitude *= gain; - - var n1 = math.snoise_grad(p * frequency); - expectedValue += amplitude * n1.w; - expectedGradient += amplitude * frequency * new float3(n1.x, n1.y, n1.z); - frequency *= lacunarity; - amplitude *= gain; - - var n2 = math.snoise_grad(p * frequency); - expectedValue += amplitude * n2.w; - expectedGradient += amplitude * frequency * new float3(n2.x, n2.y, n2.z); - - var actual = math.fbm_grad(p, 3, lacunarity, gain); - - Assert.Equal(expectedValue, actual.w); - Assert.Equal(expectedGradient.x, actual.x); - Assert.Equal(expectedGradient.y, actual.y); - Assert.Equal(expectedGradient.z, actual.z); - } - } - - [Fact] - public void RidgedGradCompoundsGainAndLacunarityPerOctaveNotOnce() - { - // Same construction as FbmGradCompoundsGainAndLacunarityPerOctaveNotOnce, folded: value is - // Sum a_i*(1-|n_i|), gradient is -Sum a_i*f_i*sign(n_i)*grad(n_i) (math.cs comment on - // ridged_grad). p is offset away from the origin and re-tried on a near-zero octave so no - // octave's n_i lands in the fold's own zero band, which would make the closed form's sign() - // ambiguous between runs. - const float lacunarity = 2.5f; - const float gain = 0.6f; - var random = new System.Random(0xF6B12); - var tested = 0; - var attempts = 0; - while (tested < 32 && attempts < 4000) - { - attempts++; - var p = RandomPoint(random); - if (AnyOctaveNearZero(p, 3, lacunarity, 0.1f)) - continue; - tested++; - - var frequency = 1.0f; - var amplitude = 1.0f; - var n0 = math.snoise_grad(p * frequency); - var s0 = (float)MathF.Sign(n0.w); - var expectedValue = amplitude * (1.0f - MathF.Abs(n0.w)); - var expectedGradient = -amplitude * frequency * s0 * new float3(n0.x, n0.y, n0.z); - frequency *= lacunarity; - amplitude *= gain; - - var n1 = math.snoise_grad(p * frequency); - var s1 = (float)MathF.Sign(n1.w); - expectedValue += amplitude * (1.0f - MathF.Abs(n1.w)); - expectedGradient += -amplitude * frequency * s1 * new float3(n1.x, n1.y, n1.z); - frequency *= lacunarity; - amplitude *= gain; - - var n2 = math.snoise_grad(p * frequency); - var s2 = (float)MathF.Sign(n2.w); - expectedValue += amplitude * (1.0f - MathF.Abs(n2.w)); - expectedGradient += -amplitude * frequency * s2 * new float3(n2.x, n2.y, n2.z); - - var actual = math.ridged_grad(p, 3, lacunarity, gain); - - Assert.Equal(expectedValue, actual.w); - Assert.Equal(expectedGradient.x, actual.x); - Assert.Equal(expectedGradient.y, actual.y); - Assert.Equal(expectedGradient.z, actual.z); - } - - Assert.True(tested == 32, $"only {tested} of {attempts} points were outside the zero band"); - } - - // ---- ridged_grad's deliberate crease at n = 0 ---- - - [Fact] - public void RidgedGradOneSidedGradientsAcrossAZeroCrossingDifferInSign() - { - // 1 octave: ridged_grad(p) = 1 - |snoise(p)|, gradient = -sign(snoise(p)) * grad(snoise)(p). - // Bisect along a fixed direction from a random start point to find a tight straddle of a - // snoise zero crossing, then check the two ridged_grad gradients just either side of it point - // in near-opposite directions (their dot product is negative): the crease is real, not a - // numerical accident (design.md, "the operator's dune term"). - var random = new System.Random(0xC2E55); - for (var attempt = 0; attempt < 200; attempt++) - { - var origin = RandomPoint(random); - var direction = new float3(random.NextSingle() - 0.5f, random.NextSingle() - 0.5f, random.NextSingle() - 0.5f); - if (math.length(direction) < 1.0e-3f) - continue; - - float NoiseAt(float t) => math.snoise(origin + direction * t); - - var lo = -3.0f; - var hi = 3.0f; - if (Math.Sign(NoiseAt(lo)) == Math.Sign(NoiseAt(hi))) - continue; - - for (var step = 0; step < 40; step++) - { - var mid = (lo + hi) * 0.5f; - if (Math.Sign(NoiseAt(lo)) == Math.Sign(NoiseAt(mid))) lo = mid; else hi = mid; - } - - // lo and hi now straddle the crossing within about 3 * 2^-40 of parameter t; step off by - // a small margin either side so each sample is cleanly on one side, not exactly on it. - const float margin = 1.0e-4f; - var minusSide = origin + direction * (lo - margin); - var plusSide = origin + direction * (hi + margin); - if (MathF.Sign(NoiseAt(lo - margin)) == MathF.Sign(NoiseAt(hi + margin))) - continue; // margin stepped back across the crossing; try another direction. - - var gradMinus = math.ridged_grad(minusSide, 1, 2.0f, 0.5f); - var gradPlus = math.ridged_grad(plusSide, 1, 2.0f, 0.5f); - var dot = gradMinus.x * gradPlus.x + gradMinus.y * gradPlus.y + gradMinus.z * gradPlus.z; - - Assert.True(dot < 0.0f, $"one-sided gradients did not differ in sign: minus=({gradMinus.x},{gradMinus.y},{gradMinus.z}) plus=({gradPlus.x},{gradPlus.y},{gradPlus.z}) dot={dot}"); - return; - } - - Assert.Fail("did not find a snoise zero crossing to straddle"); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs b/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs deleted file mode 100644 index b64f70b1..00000000 --- a/packages/cultmath/tests/CultMath.Tests/PhacelleTests.cs +++ /dev/null @@ -1,340 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -public sealed class PhacelleTests -{ - // Every tolerance below is at least 5x the largest error the same test measures at its seed. - private const float GradientEps = 1.0e-3f; - private const float GradientTolerance = 5.0e-3f; - private const double ValueTolerance = 1.6e-5; - private const double ThresholdBand = 0.02; - - private static float3 RandomPoint(System.Random random, float extent = 3.0f) => new( - (random.NextSingle() * 2.0f - 1.0f) * extent, (random.NextSingle() * 2.0f - 1.0f) * extent, (random.NextSingle() * 2.0f - 1.0f) * extent); - - // A wave vector of length 2*pi times a stripe frequency in [0.5, 1.5], in a random direction. - private static float3 RandomSide(System.Random random) - { - float3 direction; - do - { - direction = new float3(random.NextSingle() - 0.5f, random.NextSingle() - 0.5f, random.NextSingle() - 0.5f); - } - while (math.length(direction) < 0.1f); - - return math.normalize(direction) * (math.TAU * (0.5f + random.NextSingle())); - } - - // ---- An independent double-precision evaluation: all 64 cells, no prune, no gradient. ---- - // - // It shares only the hash (pcg3d over the integer cell coordinate, top 24 bits) and the constants - // the function is specified by: weight max(0, exp(-2 d^2) - 0.01111), jitter in [-0.5, 0.5). - - private readonly record struct Reference(double Cos, double Sin, double RawLength, double SupportEdgeGap); - - private static Reference Evaluate(float3 p, float3 side, float offset, float normalization) - { - double fx = Math.Floor(p.x), fy = Math.Floor(p.y), fz = Math.Floor(p.z); - double lx = p.x - fx, ly = p.y - fy, lz = p.z - fz; - double sumW = 0.0, sumCos = 0.0, sumSin = 0.0, edgeGap = double.MaxValue; - var supportRadius = Math.Sqrt(Math.Log(1.0 / 0.01111) / 2.0); - for (var dz = -1; dz <= 2; dz++) - for (var dy = -1; dy <= 2; dy++) - for (var dx = -1; dx <= 2; dx++) - { - var hash = math.pcg3d(new int3((int)fx + dx, (int)fy + dy, (int)fz + dz)); - double vx = lx - dx - (math.cellular_unit(hash.x) - 0.5); - double vy = ly - dy - (math.cellular_unit(hash.y) - 0.5); - double vz = lz - dz - (math.cellular_unit(hash.z) - 0.5); - var d2 = vx * vx + vy * vy + vz * vz; - edgeGap = Math.Min(edgeGap, Math.Abs(Math.Sqrt(d2) - supportRadius)); - var w = Math.Max(0.0, Math.Exp(-2.0 * d2) - 0.01111); - var phase = vx * side.x + vy * side.y + vz * side.z + (double)offset * math.TAU; - sumW += w; - sumCos += w * Math.Cos(phase); - sumSin += w * Math.Sin(phase); - } - - double rawCos = sumCos / sumW, rawSin = sumSin / sumW; - var raw = Math.Sqrt(rawCos * rawCos + rawSin * rawSin); - var length = Math.Max(1.0 - normalization, raw); - return new Reference(rawCos / length, rawSin / length, raw, edgeGap); - } - - private static float3 CentralDifference(Func f, float3 p, float eps) => new( - (f(p + new float3(eps, 0.0f, 0.0f)) - f(p - new float3(eps, 0.0f, 0.0f))) / (2.0f * eps), - (f(p + new float3(0.0f, eps, 0.0f)) - f(p - new float3(0.0f, eps, 0.0f))) / (2.0f * eps), - (f(p + new float3(0.0f, 0.0f, eps)) - f(p - new float3(0.0f, 0.0f, eps))) / (2.0f * eps)); - - private static float MaxComponentError(float3 numeric, float4 analytic) => MathF.Max( - MathF.Abs(numeric.x - analytic.x), MathF.Max(MathF.Abs(numeric.y - analytic.y), MathF.Abs(numeric.z - analytic.z))); - - // ---- Value: the function is Johansen's, on 3D cells ---- - - [Theory] - [InlineData(0.0f)] - [InlineData(0.5f)] - [InlineData(0.9f)] - [InlineData(1.0f)] - public void ValueMatchesTheIndependentReferenceAndNormalizesAboveTheThreshold(float normalization) - { - var random = new System.Random(0x7ACE1 + (int)(normalization * 10.0f)); - var maxError = 0.0; - var above = 0; - var below = 0; - for (var i = 0; i < 3000; i++) - { - var p = RandomPoint(random, 40.0f); - var side = RandomSide(random); - var offset = random.NextSingle(); - var actual = math.phacelle(p, side, offset, normalization); - var expected = Evaluate(p, side, offset, normalization); - - maxError = Math.Max(maxError, Math.Max(Math.Abs(actual.cos.w - expected.Cos), Math.Abs(actual.sin.w - expected.Sin))); - if (expected.RawLength >= 1.0 - normalization + ThresholdBand) - { - // The output magnitude is 1 wherever the raw magnitude reaches 1 - normalization. - above++; - var magnitude = Math.Sqrt((double)actual.cos.w * actual.cos.w + (double)actual.sin.w * actual.sin.w); - Assert.True(Math.Abs(magnitude - 1.0) < ValueTolerance, $"magnitude {magnitude} above the threshold at {p}"); - } - else if (expected.RawLength <= 1.0 - normalization - ThresholdBand) - { - below++; - } - } - - Assert.True(maxError < ValueTolerance, $"max value error against the reference {maxError}"); - if (normalization > 0.0f) - Assert.True(above >= 500, $"only {above} points above the threshold"); - if (normalization is > 0.0f and < 1.0f) - Assert.True(below >= 50, $"only {below} points below the threshold"); - } - - [Fact] - public void ValueIsPeriodicInOffsetAndAQuarterCycleRotatesCosIntoSin() - { - // offset is in cycles: a quarter turn maps cos to -sin and sin to cos, and a whole turn is the - // identity. The weights and the normalization do not depend on the phase, so this is exact - // up to float rounding. - var random = new System.Random(0x7ACE2); - for (var i = 0; i < 200; i++) - { - var p = RandomPoint(random); - var side = RandomSide(random); - var offset = random.NextSingle(); - var basePhasor = math.phacelle(p, side, offset, 0.5f); - var quarter = math.phacelle(p, side, offset + 0.25f, 0.5f); - var whole = math.phacelle(p, side, offset + 1.0f, 0.5f); - - Assert.True(MathF.Abs(quarter.cos.w + basePhasor.sin.w) < 2.0e-5f); - Assert.True(MathF.Abs(quarter.sin.w - basePhasor.cos.w) < 2.0e-5f); - Assert.True(MathF.Abs(whole.cos.w - basePhasor.cos.w) < 2.0e-5f); - Assert.True(MathF.Abs(whole.sin.w - basePhasor.sin.w) < 2.0e-5f); - } - } - - // ---- Invariant 8: the gradient is exact ---- - - [Fact] - public void GradientOfCosAndSinMatchesCentralDifferencesOnBothSidesOfTheNormalizationThreshold() - { - // Above the threshold the output is I / |I|; below it, I / (1 - normalization). The gradient - // is discontinuous where |I| crosses the threshold, and at the edge of each cell's weight support - // (distance 1.49998, where max(0, ...) starts: a jump of 4 d 0.01111 in grad w), so a band - // around each is excluded (by the - // reference's raw length, since the output alone cannot say how close it is). - const float normalization = 0.5f; - var random = new System.Random(0x7ACE3); - var above = 0; - var below = 0; - var maxError = 0.0f; - for (var attempts = 0; attempts < 20000 && (above < 150 || below < 150); attempts++) - { - var p = RandomPoint(random); - var side = RandomSide(random); - var offset = random.NextSingle(); - var reference = Evaluate(p, side, offset, normalization); - var distance = reference.RawLength - (1.0 - normalization); - if (Math.Abs(distance) < ThresholdBand || reference.SupportEdgeGap < 3.0 * GradientEps) - continue; - if (distance > 0.0 ? above >= 150 : below >= 150) - continue; - if (distance > 0.0) above++; else below++; - - var analytic = math.phacelle(p, side, offset, normalization); - var numericCos = CentralDifference(q => math.phacelle(q, side, offset, normalization).cos.w, p, GradientEps); - var numericSin = CentralDifference(q => math.phacelle(q, side, offset, normalization).sin.w, p, GradientEps); - maxError = MathF.Max(maxError, MathF.Max(MaxComponentError(numericCos, analytic.cos), MaxComponentError(numericSin, analytic.sin))); - } - - Assert.True(above >= 150 && below >= 150, $"{above} points above and {below} below the threshold"); - Assert.True(maxError < GradientTolerance, $"max gradient error against central differences {maxError}"); - } - - // ---- Stripes run along the flow ---- - - [Fact] - public void OnTheUnitSphereStripesRunAlongTheFlow() - { - // side = cross(p_hat, flow) * 2*pi is tangent to the sphere and perpendicular to the flow, so the - // cosine should change across the stripes (along side) and hardly at all along them (along - // flow). Asura's probe measured 0.212 for this ratio, against 0.202 for the planar upstream. - const float radiusInCells = 10.0f; - var random = new System.Random(0x7ACE4); - var reference = math.normalize(new float3(0.3f, 0.5f, 0.8f)); - var alongFlow = 0.0; - var acrossFlow = 0.0; - var used = 0; - while (used < 2000) - { - var hat = math.normalize(new float3(random.NextSingle() - 0.5f, random.NextSingle() - 0.5f, random.NextSingle() - 0.5f)); - var tangent = reference - hat * math.dot(hat, reference); - if (math.length(tangent) < 0.2f) - continue; - - var flow = math.normalize(tangent); - var sideDirection = math.cross(hat, flow); - var phasor = math.phacelle(hat * radiusInCells, sideDirection * math.TAU, 0.25f, 0.5f); - var gradient = new float3(phasor.cos.x, phasor.cos.y, phasor.cos.z); - alongFlow += Math.Abs(math.dot(gradient, flow)); - acrossFlow += Math.Abs(math.dot(gradient, sideDirection)); - used++; - } - - var ratio = alongFlow / acrossFlow; - Assert.True(ratio <= 0.25, $"mean|d cos/d flow| / mean|d cos/d side| = {ratio}"); - } - - // ---- Continuity ---- - - [Fact] - public void ValueStepDifferenceShrinksTenfoldPerTenfoldStepIncludingAcrossCellPlanes() - { - // Pairs straddle an integer plane on each axis (where the 4x4x4 window moves by one cell and a - // weight that did not vanish at the window edge would jump) and also start at random points. - // Lipschitz continuity means the largest difference over a step scales with the step. - var random = new System.Random(0x7ACE5); - var steps = new[] { 1.0e-3f, 1.0e-4f, 1.0e-5f }; - var maxDifference = new float[steps.Length]; - for (var i = 0; i < 3000; i++) - { - var p = RandomPoint(random); - var side = RandomSide(random); - var offset = random.NextSingle(); - var axis = i % 3; - if (i % 2 == 0) - p = SetAxis(p, axis, MathF.Round(GetAxis(p, axis))); - for (var k = 0; k < steps.Length; k++) - { - var low = math.phacelle(SetAxis(p, axis, GetAxis(p, axis) - steps[k] * 0.5f), side, offset, 0.5f); - var high = math.phacelle(SetAxis(p, axis, GetAxis(p, axis) + steps[k] * 0.5f), side, offset, 0.5f); - maxDifference[k] = MathF.Max(maxDifference[k], MathF.Max(MathF.Abs(low.cos.w - high.cos.w), MathF.Abs(low.sin.w - high.sin.w))); - } - } - - Assert.True(maxDifference[1] * 8.0f <= maxDifference[0], $"1e-3: {maxDifference[0]}, 1e-4: {maxDifference[1]}"); - Assert.True(maxDifference[2] * 8.0f <= maxDifference[1], $"1e-4: {maxDifference[1]}, 1e-5: {maxDifference[2]}"); - } - - private static float GetAxis(float3 v, int axis) => axis == 0 ? v.x : axis == 1 ? v.y : v.z; - - private static float3 SetAxis(float3 v, int axis, float value) => - axis == 0 ? new float3(value, v.y, v.z) : axis == 1 ? new float3(v.x, value, v.z) : new float3(v.x, v.y, value); - - // ---- Exact pruning ---- - - [Fact] - public void PrunedOutputIsBitEqualToTheUnprunedSum() - { - var random = new System.Random(0x7ACE6); - for (var i = 0; i < 20000; i++) - { - var p = RandomPoint(random, 50.0f); - var side = RandomSide(random); - var offset = random.NextSingle(); - var normalization = random.NextSingle(); - var pruned = math.phacelle(p, side, offset, normalization); - var unpruned = math.phacelle(p, side, offset, normalization, false); - - AssertBitEqual(unpruned.cos, pruned.cos); - AssertBitEqual(unpruned.sin, pruned.sin); - } - } - - // Points next to a cell whose jitter sits at the far corner of its cube: the cell's box bound is - // just under the 2.25 cut (2.2451 to 2.25) while its real distance is still under the support - // radius (d^2 < 2.24995), so its weight is small but nonzero and a prune that cuts even slightly - // low (2.245, 2.24, 2.2) drops a contribution and changes output bits. Random points meet such - // a cell about once in 10^4 evaluations, which is why the random sweep above let those cuts - // through. Each was found once by an offline search (cells K in [-12, 12]^3 whose jitter on one - // axis lies within 0.0008 of the cube face; p is the feature moved 1.4996 out along that axis, - // so |p - feature| = 1.4996 and the bound is about 1.4988). The witness check below re-derives - // that property from the hash, so a change to pcg3d fails loudly instead of degenerating. - // Shared with the HLSL mirror test. - internal static readonly float3[] PruneCutPoints = - { - new(1.77850008f, -2.16020727f, -0.9991166f), - new(1.09346282f, -2.37882328f, -3.00082445f), - new(-6.39144945f, -3.99953747f, -0.610023975f), - new(-0.99940908f, 4.16302729f, 4.07277536f), - new(3.99912024f, 7.21890545f, 1.09053993f), - new(5.43959713f, 1.99937367f, -6.14929914f), - }; - - internal static readonly float3 PruneCutSide = new(2.1f, -3.7f, 1.3f); - internal const float PruneCutOffset = 0.3f; - internal const float PruneCutNormalization = 0.5f; - - // True when some cell of the 4x4x4 window has a box bound in [2.2451, 2.25) and a positive weight. - internal static bool HasCellJustInsideTheCut(float3 p) - { - double fx = Math.Floor(p.x), fy = Math.Floor(p.y), fz = Math.Floor(p.z); - double lx = p.x - fx, ly = p.y - fy, lz = p.z - fz; - for (var dz = -1; dz <= 2; dz++) - for (var dy = -1; dy <= 2; dy++) - for (var dx = -1; dx <= 2; dx++) - { - var gx = Math.Max(0.0, Math.Abs(lx - dx) - 0.5); - var gy = Math.Max(0.0, Math.Abs(ly - dy) - 0.5); - var gz = Math.Max(0.0, Math.Abs(lz - dz) - 0.5); - var bound = gx * gx + gy * gy + gz * gz; - if (bound < 2.2451 || bound >= 2.25) - continue; - - var hash = math.pcg3d(new int3((int)fx + dx, (int)fy + dy, (int)fz + dz)); - double vx = lx - dx - (math.cellular_unit(hash.x) - 0.5); - double vy = ly - dy - (math.cellular_unit(hash.y) - 0.5); - double vz = lz - dz - (math.cellular_unit(hash.z) - 0.5); - if (Math.Exp(-2.0 * (vx * vx + vy * vy + vz * vz)) > 0.01111) - return true; - } - - return false; - } - - [Fact] - public void PrunedOutputIsBitEqualToTheUnprunedSumNextToCellsJustInsideTheCut() - { - foreach (var p in PruneCutPoints) - { - Assert.True(HasCellJustInsideTheCut(p), $"no cell just inside the cut at {p}: the fixture no longer exercises the prune"); - var pruned = math.phacelle(p, PruneCutSide, PruneCutOffset, PruneCutNormalization); - var unpruned = math.phacelle(p, PruneCutSide, PruneCutOffset, PruneCutNormalization, false); - - AssertBitEqual(unpruned.cos, pruned.cos); - AssertBitEqual(unpruned.sin, pruned.sin); - } - } - - private static void AssertBitEqual(float4 expected, float4 actual) - { - Assert.Equal(BitConverter.SingleToInt32Bits(expected.x), BitConverter.SingleToInt32Bits(actual.x)); - Assert.Equal(BitConverter.SingleToInt32Bits(expected.y), BitConverter.SingleToInt32Bits(actual.y)); - Assert.Equal(BitConverter.SingleToInt32Bits(expected.z), BitConverter.SingleToInt32Bits(actual.z)); - Assert.Equal(BitConverter.SingleToInt32Bits(expected.w), BitConverter.SingleToInt32Bits(actual.w)); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/SnoiseTieScopeTests.cs b/packages/cultmath/tests/CultMath.Tests/SnoiseTieScopeTests.cs deleted file mode 100644 index 8bf7c895..00000000 --- a/packages/cultmath/tests/CultMath.Tests/SnoiseTieScopeTests.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -// The 0.4.0 tie rule (math.snoise(float3), math.snoise_grad) changes values exactly where the cell -// offset x0 has three equal components, which is every input whose coordinate differences y - x and -// z - x are whole numbers (every integer point, and the whole (1, 1, 1) line through each). Off that -// set and its float32 band (below) the results are bit-identical to 0.3.0. The goldens below were computed by the -// cultmath-unity-v0.3.0 tag's CultMath.dll (Runtime/Plugins), not by this code. Float32 rounding -// decides whether a given integer-difference input ties, because x0 is computed in float32: an -// input whose differences round onto whole numbers can tie too and move, within a few float32 -// ulps of the largest coordinate (a probe found up to about two; the band widens with the magnitude), and some inputs on -// the set keep their value (about 3% of random integer points). Every input below ties and moves -// all five outputs (value and the four gradient words). -// TieSetNow pins what this code returns on the same inputs, so that each of the two tie-rule sites -// (the step in snoise, the step in snoise_grad) is pinned on its own. -public sealed class SnoiseTieScopeTests -{ - // (input, snoise bits, snoise_grad x y z w bits) from 0.3.0, each on the tie set and moved by the new rule. - private static readonly (float3 P, uint Value, uint[] Grad)[] TieSet = - { - (new float3(8f, -9f, 1f), 0xBDD82D0D, new uint[] { 0x3FA7D14B, 0x40A68968, 0xC0EE5B16, 0xBDD82D0D }), - (new float3(-15f, 1f, -3f), 0xBF29AEDB, new uint[] { 0x3ECABF0C, 0x40482713, 0x3F444FED, 0xBF29AEDB }), - (new float3(9f, -14f, 7f), 0x3F3F28F4, new uint[] { 0x3F5FB228, 0x3F471A21, 0x40454A1F, 0x3F3F28F4 }), - (new float3(15f, 8f, 17f), 0xBDEE4FE2, new uint[] { 0x3F1F3C06, 0x3FFA0CCF, 0xC00C8395, 0xBDEE4FE2 }), - (new float3(3f, -12f, 10f), 0xBF3A1373, new uint[] { 0x3FC00B62, 0x3E28F20F, 0x403F02DA, 0xBF3A1373 }), - (new float3(2f, -8f, 15f), 0x3F180CA2, new uint[] { 0x3F567351, 0xC0340E87, 0x40E74458, 0x3F180CA2 }), - (new float3(-6.1645937f, -6.1645937f, -6.1645937f), 0xBF1C7CA6, new uint[] { 0xC04341A7, 0xBFE7241A, 0x3EE7511A, 0xBF1C7CA6 }), - (new float3(22.580343f, 22.580343f, 22.580343f), 0x3F5D9075, new uint[] { 0x400096F0, 0xC0590215, 0x3FAAC79D, 0x3F5D9075 }), - (new float3(-25.630196f, -25.630196f, -25.630196f), 0x3F4C7BDB, new uint[] { 0xBFCE54B7, 0x3FCD63EC, 0x403492AC, 0x3F4C7BDB }), - (new float3(-26.818033f, -26.818033f, -26.818033f), 0x3DE34495, new uint[] { 0xBEF368D6, 0xBFD14FED, 0x3FE503E7, 0x3DE34495 }), - (new float3(8.4097805f, -2.5902195f, -0.5902195f), 0xBF85F631, new uint[] { 0xBFE0D093, 0x3F8E6022, 0x3ECA4F57, 0xBF85F631 }), - (new float3(8.618587f, 1.6185865f, 0.61858654f), 0xBE8FB513, new uint[] { 0xC02F9DDD, 0x4063CEA5, 0xBDF0BFBB, 0xBE8FB513 }), - (new float3(-13.692368f, -9.692368f, -20.692368f), 0xBF28A1E3, new uint[] { 0xC012A224, 0xC0187F57, 0xBF57F2CB, 0xBF28A1E3 }), - (new float3(9.495648f, 11.495648f, 15.495648f), 0x3E4FC9B5, new uint[] { 0x3EA26E55, 0x403CE620, 0xBF46F425, 0x3E4FC9B5 }), - (new float3(-12.66157f, -19.66157f, -9.66157f), 0xBF179BF9, new uint[] { 0x3FD03786, 0x403A1C1E, 0xBEAD7581, 0xBF179BF9 }), - (new float3(-8.801376f, -1.8013763f, -19.801376f), 0xBE82F2EE, new uint[] { 0xC0DCFC55, 0x405501DB, 0x401E6CF8, 0xBE82F2EE }), - }; - - // The values this code returns on TieSet's inputs, in the same order (the value, then the four - // snoise_grad components). - private static readonly (uint Value, uint[] Grad)[] TieSetNow = - { - (0xB37C25C6, new uint[] { 0x3F281943, 0x40521F92, 0xC0A8193D, 0xB37C25C6 }), - (0xBF214750, new uint[] { 0xBD931F34, 0x40260272, 0x3E94E53D, 0xBF214750 }), - (0x3F35B75A, new uint[] { 0x3EAD85CB, 0x3E78AB7B, 0x401F83B4, 0x3F35B75A }), - (0xBDE33E78, new uint[] { 0x3F0705E4, 0x3FE9CB38, 0xC00DE5C4, 0xBDE33E78 }), - (0xBF30DF87, new uint[] { 0x3F76B426, 0xBEAE857A, 0x401A3325, 0xBF30DF87 }), - (0x00000000, new uint[] { 0x3FEC7798, 0xBF1DA4FF, 0x40C50E50, 0x00000000 }), - (0xBF13F436, new uint[] { 0xC0219F00, 0xBFA829D9, 0x3F629666, 0xBF13F436 }), - (0x3F0C1A1C, new uint[] { 0x404F76CC, 0xBFA6560B, 0x402B2291, 0x3F0C1A1C }), - (0x3F2E5150, new uint[] { 0xC01F3830, 0x3F007F73, 0x3FD11DF1, 0x3F2E5150 }), - (0x3DDE3B0E, new uint[] { 0xBED7A81C, 0xBFC89166, 0x3FE7E3CC, 0x3DDE3B0E }), - (0xBF23BB4A, new uint[] { 0xC057D547, 0xBF7B66AE, 0xBFCA313F, 0xBF23BB4A }), - (0xBE68D15B, new uint[] { 0xC0391D00, 0x40366C69, 0xBEFFC8AD, 0xBE68D15B }), - (0xBF2659BE, new uint[] { 0xC0048291, 0xC00A5FC3, 0xBF21B992, 0xBF2659BE }), - (0x3E4630E4, new uint[] { 0x3E35FE51, 0x40306ACC, 0xBF655794, 0x3E4630E4 }), - (0xBF117B1D, new uint[] { 0x3F9D6F53, 0x401F35B7, 0xBF31BAFE, 0xBF117B1D }), - (0xBDA5A39E, new uint[] { 0xC0B4E453, 0x3FF84A5D, 0x3FA74D5F, 0xBDA5A39E }), - }; - - // The same, off the tie set: coordinate differences that are not whole numbers. - private static readonly (float3 P, uint Value, uint[] Grad)[] OffSet = - { - (new float3(-3.7841978f, -12.899288f, 1.5972604f), 0x3EA04649, new uint[] { 0xBF74444B, 0x3F87A8A7, 0xC021229C, 0x3EA04649 }), - (new float3(8.898657f, 12.611845f, 4.790286f), 0xBEC97F79, new uint[] { 0xBD25992C, 0xC02EF328, 0xBF17ECAB, 0xBEC97F79 }), - (new float3(0.7057237f, 11.097378f, 13.493794f), 0xBE00B70D, new uint[] { 0xBEDBFFF7, 0xBFDA79F7, 0xBF07EA57, 0xBE00B70D }), - (new float3(-15.702414f, 3.5919724f, -7.0502086f), 0xBDC6607C, new uint[] { 0xBF113459, 0x3EB74352, 0xBF4D2C56, 0xBDC6607C }), - (new float3(-13.623555f, -10.574037f, -15.697628f), 0x3E823717, new uint[] { 0xBF4926AE, 0x4076E757, 0x40710AFC, 0x3E823717 }), - (new float3(-10.028356f, 5.4002185f, -13.579105f), 0x3EF1651D, new uint[] { 0x3FF0CA03, 0xC004B90C, 0xBFAF91DA, 0x3EF1651D }), - (new float3(12.788626f, 14.914132f, -0.39256755f), 0x3DB39ABE, new uint[] { 0xC06D6427, 0xBF941974, 0x3E8B556D, 0x3DB39ABE }), - (new float3(-2.4998372f, 10.696207f, 15.391607f), 0xBF0D1821, new uint[] { 0x3FAB00CF, 0x4044DAE4, 0x3F1E2E21, 0xBF0D1821 }), - (new float3(10.437524f, -3.4692447f, 15.652484f), 0x3EFCC588, new uint[] { 0xC083735E, 0x3FA4A10F, 0xBE7D19D2, 0x3EFCC588 }), - (new float3(-4.4040494f, 14.969201f, -2.2152362f), 0xBD4192BF, new uint[] { 0xBF3F69AE, 0xBF843396, 0xBFF88079, 0xBD4192BF }), - (new float3(2.7095387f, 13.3163395f, -0.28273603f), 0x3EF0704A, new uint[] { 0xBF75C892, 0x3F0C95B0, 0x3F7401B5, 0x3EF0704A }), - (new float3(-10.564334f, -5.6527104f, -6.6908674f), 0x3EA35AEA, new uint[] { 0xC05CB149, 0x3F928B08, 0x3EB68FCB, 0x3EA35AEA }), - (new float3(-13.572381f, -2.2560256f, -12.702176f), 0x3D2013BE, new uint[] { 0xC0236256, 0x3D02D65C, 0x3DB57CBC, 0x3D2013BE }), - (new float3(0.11813756f, -7.2100754f, 7.144552f), 0xBF244AB4, new uint[] { 0xBF6B4A5E, 0xBFFC1BFA, 0xBE868270, 0xBF244AB4 }), - (new float3(9.668022f, -0.32686335f, 2.333893f), 0xBDE9567A, new uint[] { 0x3F359CBB, 0x3F2B104D, 0x3FEFAB81, 0xBDE9567A }), - (new float3(-6.9417686f, -6.2886133f, -13.874224f), 0x3CC28786, new uint[] { 0xC0291AB6, 0x3E57B89E, 0xBE884AF7, 0x3CC28786 }), - (new float3(9.9228945f, 13.366786f, 1.9626095f), 0x3DDCC7CA, new uint[] { 0xBFA57791, 0x40277CF0, 0xBF816FCF, 0x3DDCC7CA }), - (new float3(1.3210233f, -5.5900016f, 9.691286f), 0x3D140957, new uint[] { 0x4003DBED, 0x3E35DCDD, 0xBF9CFAAE, 0x3D140957 }), - (new float3(2.5023124f, 14.715639f, -7.5954947f), 0x3EB522F9, new uint[] { 0x3FB54F05, 0x4003D90A, 0x3F4CCE6D, 0x3EB522F9 }), - (new float3(2.2056534f, 14.461132f, 0.081089176f), 0xBE0FBF83, new uint[] { 0xBF2E2FDB, 0x4014B7C5, 0x3F8C8EC2, 0xBE0FBF83 }), - (new float3(5.137802f, -10.890227f, 12.128177f), 0xBEAEF52F, new uint[] { 0xBFBC5CA4, 0xBFD159C2, 0x402EBCD4, 0xBEAEF52F }), - (new float3(-0.290969f, -2.4119518f, 6.2756324f), 0x3EE30F7E, new uint[] { 0x3E94AD2B, 0x3F8DCBA0, 0x4055B8BB, 0x3EE30F7E }), - (new float3(9.232528f, 12.940779f, 11.078674f), 0x3E380DF3, new uint[] { 0x3F8B7DBE, 0x3F1596ED, 0xC0527328, 0x3E380DF3 }), - (new float3(6.9932394f, -12.455975f, -8.343756f), 0x3E929F5A, new uint[] { 0x3E5564B6, 0x3FF1BE81, 0xBF77638A, 0x3E929F5A }), - (new float3(15.123071f, 12.623071f, 20.12307f), 0x3E9527A3, new uint[] { 0x3D084582, 0xC07DE925, 0xBECA2112, 0x3E9527A3 }), - (new float3(8.46288f, 11.96288f, 4.46288f), 0x3E8C0F92, new uint[] { 0x3FD2DFD3, 0x3FB49817, 0x3F023648, 0x3E8C0F92 }), - (new float3(-2.9422863f, -1.4422863f, -12.9422865f), 0xBEBAEE39, new uint[] { 0x3FECB31B, 0xBFD33138, 0x3F9A17A8, 0xBEBAEE39 }), - (new float3(13.526707f, 15.026707f, 2.5267067f), 0x3EF22701, new uint[] { 0x3F1D389B, 0x3FCABBBE, 0xBF66EE93, 0x3EF22701 }), - (new float3(11.822154f, 1.322154f, 13.822154f), 0x3E85ACC7, new uint[] { 0x3FA7C0C7, 0xC067C262, 0x3FF35925, 0x3E85ACC7 }), - (new float3(6.025978f, 8.525978f, 3.025978f), 0x3E9964B0, new uint[] { 0xBEE7F346, 0x3F1918E9, 0x3EF3DA8A, 0x3E9964B0 }), - (new float3(-15.095373f, -14.595373f, -16.095373f), 0xBE6EF82D, new uint[] { 0xC01F9511, 0x3FEDB679, 0xBFDA5058, 0xBE6EF82D }), - (new float3(3.2167344f, 12.716734f, -6.7832656f), 0x3EA3C041, new uint[] { 0xBFFA5E11, 0xBF41778D, 0xBFCFD96A, 0x3EA3C041 }), - (new float3(12.25f, -0.25f, -3.25f), 0x3EB8C88C, new uint[] { 0xBFA0E2A2, 0x40101407, 0x402D2F5B, 0x3EB8C88C }), - (new float3(-9f, -13.25f, 10f), 0x3F032C5D, new uint[] { 0x3F9FFBCB, 0x3E6ED505, 0x401D75F4, 0x3F032C5D }), - (new float3(-5.75f, 2.25f, 13.75f), 0x3E62496B, new uint[] { 0x3FC789CA, 0x3EE63ACD, 0xBEE57812, 0x3E62496B }), - (new float3(-12.5f, 10f, -5.25f), 0x3EEA194F, new uint[] { 0x3F182206, 0xC0282BDE, 0xBFA51540, 0x3EEA194F }), - (new float3(13.5f, -11f, -3f), 0x3E6B5E9A, new uint[] { 0xBF2F5213, 0x3FE97BC2, 0x3F072FB4, 0x3E6B5E9A }), - (new float3(-2.75f, 7.75f, 3.5f), 0x3E91F33E, new uint[] { 0x3E2546E0, 0xBF63D038, 0xBFC3C500, 0x3E91F33E }), - (new float3(10.5f, 4f, -3.75f), 0x3EBCDE1F, new uint[] { 0xBFDC4426, 0x400DCD14, 0x3F7CACF6, 0x3EBCDE1F }), - (new float3(-12.75f, -13f, -6f), 0x3D5F6FB0, new uint[] { 0xBFBF0ED8, 0xC0109EED, 0xC007C568, 0x3D5F6FB0 }), - (new float3(-0.069121994f, 0.76107657f, 0.41525742f), 0x3DA72363, new uint[] { 0x3E5DF1FF, 0x3F7E17BE, 0x3FA89CB3, 0x3DA72363 }), - (new float3(1.0466753f, -0.51170796f, 0.21126905f), 0xBDD1FE81, new uint[] { 0x3DFD066D, 0x3E5E0061, 0x3FDBADAF, 0xBDD1FE81 }), - (new float3(0.30550694f, 1.6808131f, -0.76585627f), 0x3F0F3AB5, new uint[] { 0x3FF9EAC8, 0xC001ADBF, 0x3FD97B97, 0x3F0F3AB5 }), - (new float3(-0.8827523f, 0.12493165f, -1.8058014f), 0x3EC3BE7E, new uint[] { 0xC02395D6, 0x3F00EEB9, 0x3F976926, 0x3EC3BE7E }), - }; - - private static bool OnTieSet(float3 p) - { - var a = (double)p.y - p.x; - var b = (double)p.z - p.x; - return a == Math.Floor(a) && b == Math.Floor(b); - } - - // Each output is asserted on its own: a tie rule reverted at one site must fail here by itself, - // whatever the other site returns. A given input moves some outputs and not others, so each - // output must differ from 0.3.0 on at least one tie-set input. - [Fact] - public void EachOutputDiffersFromZeroPointThreeSomewhereOnTheTieSet() - { - Assert.NotEmpty(TieSet); - var moved = new bool[5]; - foreach (var (p, value, grad) in TieSet) - { - Assert.True(OnTieSet(p)); - var g = math.snoise_grad(p); - moved[0] |= BitConverter.SingleToUInt32Bits(math.snoise(p)) != value; - moved[1] |= BitConverter.SingleToUInt32Bits(g.x) != grad[0]; - moved[2] |= BitConverter.SingleToUInt32Bits(g.y) != grad[1]; - moved[3] |= BitConverter.SingleToUInt32Bits(g.z) != grad[2]; - moved[4] |= BitConverter.SingleToUInt32Bits(g.w) != grad[3]; - } - Assert.True(moved[0], "snoise(float3) still reads its 0.3.0 value on the tie set"); - Assert.True(moved[1], "snoise_grad.x still reads its 0.3.0 value on the tie set"); - Assert.True(moved[2], "snoise_grad.y still reads its 0.3.0 value on the tie set"); - Assert.True(moved[3], "snoise_grad.z still reads its 0.3.0 value on the tie set"); - Assert.True(moved[4], "snoise_grad.w still reads its 0.3.0 value on the tie set"); - } - - [Fact] - public void TieSetInputsReturnTheirZeroPointFourGoldens() - { - Assert.Equal(TieSet.Length, TieSetNow.Length); - for (var k = 0; k < TieSet.Length; k++) - { - var p = TieSet[k].P; - var (value, grad) = TieSetNow[k]; - var g = math.snoise_grad(p); - Assert.Equal(value, BitConverter.SingleToUInt32Bits(math.snoise(p))); - Assert.Equal(grad[0], BitConverter.SingleToUInt32Bits(g.x)); - Assert.Equal(grad[1], BitConverter.SingleToUInt32Bits(g.y)); - Assert.Equal(grad[2], BitConverter.SingleToUInt32Bits(g.z)); - Assert.Equal(grad[3], BitConverter.SingleToUInt32Bits(g.w)); - } - } - - [Fact] - public void InputsOffTheTieSetKeepTheirZeroPointThreeBits() - { - Assert.NotEmpty(OffSet); - foreach (var (p, value, grad) in OffSet) - { - Assert.False(OnTieSet(p)); - var g = math.snoise_grad(p); - Assert.Equal(value, BitConverter.SingleToUInt32Bits(math.snoise(p))); - Assert.Equal(grad[0], BitConverter.SingleToUInt32Bits(g.x)); - Assert.Equal(grad[1], BitConverter.SingleToUInt32Bits(g.y)); - Assert.Equal(grad[2], BitConverter.SingleToUInt32Bits(g.z)); - Assert.Equal(grad[3], BitConverter.SingleToUInt32Bits(g.w)); - } - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs b/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs deleted file mode 100644 index 9335784d..00000000 --- a/packages/cultmath/tests/CultMath.Tests/VectorEqualityTests.cs +++ /dev/null @@ -1,583 +0,0 @@ -using System; -using CultMath; -using Xunit; - -namespace CultMath.Tests; - -// Hand-verified on hands/adopt-stryker: weakening float3.Equals from `&&` to `||` passes the -// whole existing suite. The same shape of Equals/GetHashCode, ==/!=, and /<=/>= exists (with -// no shared base type) across float2/3/4, double2/3, int2/3/4, bool2/3/4, quaternion, -// float2x2 and float3x3. These tests are data-driven per component position rather than one -// method per type: each type supplies a base value and, per component index, a value that -// differs at exactly that index and agrees everywhere else, plus (for the four ordered numeric -// families) a left/right pair whose relational result differs per component. bool2/3/4 and -// quaternion have no ordering operators and are not included in the comparison-operator cases. -// float2x2/float3x3 have no == / != operators (Equals and GetHashCode only) and are covered -// separately, at row granularity. -public sealed class VectorEqualityTests -{ - // ---- shared, type-agnostic assertions ------------------------------------------------- - - private static void AssertEqualsAndHashCodeContract(T a, T b, bool expectedEqual, string label) - where T : IEquatable - { - Assert.True(a.Equals(b) == expectedEqual, $"{label}: a.Equals(b) expected {expectedEqual}"); - Assert.True(b.Equals(a) == expectedEqual, $"{label}: b.Equals(a) expected {expectedEqual} (symmetry)"); - if (expectedEqual) - { - Assert.True(a.GetHashCode() == b.GetHashCode(), $"{label}: equal values must share a hash code"); - } - } - - private static void AssertElementwiseEqualityOperators( - TLeft a, - TRight b, - int count, - Func expectedEqualAt, - Func eq, - Func neq, - Func at, - string label) - { - var eqResult = eq(a, b); - var neqResult = neq(a, b); - for (var i = 0; i < count; i++) - { - var expectedEqual = expectedEqualAt(i); - Assert.True(at(eqResult, i) == expectedEqual, $"{label}: == component {i} expected {expectedEqual}"); - Assert.True(at(neqResult, i) == !expectedEqual, $"{label}: != component {i} expected {!expectedEqual}"); - } - } - - private static void AssertElementwiseComparisonOperators( - TLeft left, - TRight right, - double[] leftVals, - double[] rightVals, - Func lt, - Func gt, - Func le, - Func ge, - Func at, - string label) - { - var ltResult = lt(left, right); - var gtResult = gt(left, right); - var leResult = le(left, right); - var geResult = ge(left, right); - for (var i = 0; i < leftVals.Length; i++) - { - var less = leftVals[i] < rightVals[i]; - var greater = leftVals[i] > rightVals[i]; - Assert.True(at(ltResult, i) == less, $"{label}: < component {i} (left={leftVals[i]}, right={rightVals[i]})"); - Assert.True(at(gtResult, i) == greater, $"{label}: > component {i} (left={leftVals[i]}, right={rightVals[i]})"); - Assert.True(at(leResult, i) == !greater, $"{label}: <= component {i} (left={leftVals[i]}, right={rightVals[i]})"); - Assert.True(at(geResult, i) == !less, $"{label}: >= component {i} (left={leftVals[i]}, right={rightVals[i]})"); - } - } - - // ---- float2 ----------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - public void Float2EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new float2(3.0f, -7.0f); - var b = a; - b[index] += 5.0f; - - AssertEqualsAndHashCodeContract(a, a, true, "float2 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"float2 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 2, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float2 vector==vector"); - - // Scalar overloads: a scalar equal to exactly one component, on both operand sides. - var scalar = a[index]; - AssertElementwiseEqualityOperators( - a, scalar, 2, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float2 vector==scalar"); - AssertElementwiseEqualityOperators( - scalar, a, 2, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float2 scalar==vector"); - } - - [Fact] - public void Float2ComparisonOperatorsDifferPerComponent() - { - var left = new float2(1.0f, 5.0f); - var right = new float2(2.0f, 3.0f); - var leftVals = new double[] { 1.0, 5.0 }; - var rightVals = new double[] { 2.0, 3.0 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 vector-vector"); - - const float scalar = 2.0f; - AssertElementwiseComparisonOperators( - left, scalar, leftVals, new double[] { scalar, scalar }, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 vector-scalar"); - AssertElementwiseComparisonOperators( - scalar, left, new double[] { scalar, scalar }, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 scalar-vector"); - - // A value compared against an exact copy of itself: every component ties. This is the - // complementary fixture to the no-tie one above. A tie is where < and <= (or > and >=) - // actually disagree, so it catches a strict/non-strict boundary swap (e.g. < mutated to - // <=) that a fixture with no equal components cannot: unlike a threshold compared against - // an arbitrary float, an exact self-tie is neither rare nor equivalent here, since these - // are general-purpose comparison operators (bounds/containment checks compare against - // literal endpoints routinely, as CultMath's own touching-edges rect test does). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 tied vector-vector"); - - // The scalar overloads need their own tie: a uniform vector against a scalar equal to - // every component, so every component of the vector-scalar and scalar-vector overloads - // ties too (the vector-vector tie above does not cover them). - var uniform = new float2(4.0f, 4.0f); - var uniformVals = new double[] { 4.0, 4.0 }; - AssertElementwiseComparisonOperators( - uniform, 4.0f, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 tied vector-scalar"); - AssertElementwiseComparisonOperators( - 4.0f, uniform, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float2 tied scalar-vector"); - } - - // ---- float3 ----------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - public void Float3EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new float3(3.0f, -7.0f, 4.5f); - var b = a; - b[index] += 5.0f; - - AssertEqualsAndHashCodeContract(a, a, true, "float3 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"float3 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 3, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float3 vector==vector"); - - var scalar = a[index]; - AssertElementwiseEqualityOperators( - a, scalar, 3, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float3 vector==scalar"); - AssertElementwiseEqualityOperators( - scalar, a, 3, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float3 scalar==vector"); - } - - [Fact] - public void Float3ComparisonOperatorsDifferPerComponent() - { - // No component is tied: a tie makes strict < and strict > agree (both false), which - // would hide a direction-flip mutation (< swapped for >) at that component. - var left = new float3(1.0f, 5.0f, 7.0f); - var right = new float3(2.0f, 3.0f, 4.0f); - var leftVals = new double[] { 1.0, 5.0, 7.0 }; - var rightVals = new double[] { 2.0, 3.0, 4.0 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 vector-vector"); - - const float scalar = 4.0f; - AssertElementwiseComparisonOperators( - left, scalar, leftVals, new double[] { scalar, scalar, scalar }, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 vector-scalar"); - AssertElementwiseComparisonOperators( - scalar, left, new double[] { scalar, scalar, scalar }, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 scalar-vector"); - - // Tied against itself (see the float2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 tied vector-vector"); - - // The scalar overloads need their own tie (see the float2 uniform-vector comment above). - var uniform = new float3(4.0f, 4.0f, 4.0f); - var uniformVals = new double[] { 4.0, 4.0, 4.0 }; - AssertElementwiseComparisonOperators( - uniform, 4.0f, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 tied vector-scalar"); - AssertElementwiseComparisonOperators( - 4.0f, uniform, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float3 tied scalar-vector"); - } - - // ---- float4 ----------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - public void Float4EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new float4(3.0f, -7.0f, 4.5f, 9.0f); - var b = a; - b[index] += 5.0f; - - AssertEqualsAndHashCodeContract(a, a, true, "float4 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"float4 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 4, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float4 vector==vector"); - - var scalar = a[index]; - AssertElementwiseEqualityOperators( - a, scalar, 4, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float4 vector==scalar"); - AssertElementwiseEqualityOperators( - scalar, a, 4, i => a[i] == scalar, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "float4 scalar==vector"); - } - - [Fact] - public void Float4ComparisonOperatorsDifferPerComponent() - { - // No component is tied (see the float3 comment above for why a tie hides a - // direction-flip mutation at that component). - var left = new float4(1.0f, 5.0f, 7.0f, 2.0f); - var right = new float4(2.0f, 3.0f, 4.0f, 9.0f); - var leftVals = new double[] { 1.0, 5.0, 7.0, 2.0 }; - var rightVals = new double[] { 2.0, 3.0, 4.0, 9.0 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 vector-vector"); - - const float scalar = 4.0f; - AssertElementwiseComparisonOperators( - left, scalar, leftVals, new double[] { scalar, scalar, scalar, scalar }, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 vector-scalar"); - AssertElementwiseComparisonOperators( - scalar, left, new double[] { scalar, scalar, scalar, scalar }, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 scalar-vector"); - - // Tied against itself (see the float2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 tied vector-vector"); - - // The scalar overloads need their own tie (see the float2 uniform-vector comment above). - var uniform = new float4(4.0f, 4.0f, 4.0f, 4.0f); - var uniformVals = new double[] { 4.0, 4.0, 4.0, 4.0 }; - AssertElementwiseComparisonOperators( - uniform, 4.0f, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 tied vector-scalar"); - AssertElementwiseComparisonOperators( - 4.0f, uniform, uniformVals, uniformVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "float4 tied scalar-vector"); - } - - // ---- double2 ---------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - public void Double2EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new double2(3.0, -7.0); - var b = a; - b[index] += 5.0; - - AssertEqualsAndHashCodeContract(a, a, true, "double2 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"double2 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 2, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "double2 =="); - } - - [Fact] - public void Double2ComparisonOperatorsDifferPerComponent() - { - var left = new double2(1.0, 5.0); - var right = new double2(2.0, 3.0); - var leftVals = new double[] { 1.0, 5.0 }; - var rightVals = new double[] { 2.0, 3.0 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double2 vector-vector"); - - // Tied against itself (see the float2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double2 tied vector-vector"); - } - - // ---- double3 ---------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - public void Double3EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new double3(3.0, -7.0, 4.5); - var b = a; - b[index] += 5.0; - - AssertEqualsAndHashCodeContract(a, a, true, "double3 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"double3 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 3, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "double3 =="); - } - - [Fact] - public void Double3ComparisonOperatorsDifferPerComponent() - { - // No component is tied (see the float3 comment above). - var left = new double3(1.0, 5.0, 7.0); - var right = new double3(2.0, 3.0, 4.0); - var leftVals = new double[] { 1.0, 5.0, 7.0 }; - var rightVals = new double[] { 2.0, 3.0, 4.0 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double3 vector-vector"); - - // Tied against itself (see the float2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "double3 tied vector-vector"); - } - - // ---- int2 ------------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - public void Int2EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new int2(3, -7); - var b = a; - b[index] += 5; - - AssertEqualsAndHashCodeContract(a, a, true, "int2 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"int2 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 2, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "int2 =="); - } - - [Fact] - public void Int2ComparisonOperatorsDifferPerComponent() - { - var left = new int2(1, 5); - var right = new int2(2, 3); - var leftVals = new double[] { 1, 5 }; - var rightVals = new double[] { 2, 3 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int2 vector-vector"); - - // Tied against itself (see the float2 tied-fixture comment above); integers make an - // exact tie the routine case, not the rare one. - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int2 tied vector-vector"); - } - - // ---- int3 ------------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - public void Int3EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new int3(3, -7, 4); - var b = a; - b[index] += 5; - - AssertEqualsAndHashCodeContract(a, a, true, "int3 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"int3 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 3, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "int3 =="); - } - - [Fact] - public void Int3ComparisonOperatorsDifferPerComponent() - { - // No component is tied (see the float3 comment above). - var left = new int3(1, 5, 7); - var right = new int3(2, 3, 4); - var leftVals = new double[] { 1, 5, 7 }; - var rightVals = new double[] { 2, 3, 4 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int3 vector-vector"); - - // Tied against itself (see the int2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int3 tied vector-vector"); - } - - // ---- int4 ------------------------------------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - public void Int4EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new int4(3, -7, 4, 9); - var b = a; - b[index] += 5; - - AssertEqualsAndHashCodeContract(a, a, true, "int4 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"int4 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 4, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "int4 =="); - } - - [Fact] - public void Int4ComparisonOperatorsDifferPerComponent() - { - // No component is tied (see the float3 comment above). - var left = new int4(1, 5, 7, 2); - var right = new int4(2, 3, 4, 9); - var leftVals = new double[] { 1, 5, 7, 2 }; - var rightVals = new double[] { 2, 3, 4, 9 }; - - AssertElementwiseComparisonOperators( - left, right, leftVals, rightVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int4 vector-vector"); - - // Tied against itself (see the int2 tied-fixture comment above). - AssertElementwiseComparisonOperators( - left, left, leftVals, leftVals, - (x, y) => x < y, (x, y) => x > y, (x, y) => x <= y, (x, y) => x >= y, (v, i) => v[i], "int4 tied vector-vector"); - } - - // ---- bool2/3/4 (no ordering operators) --------------------------------------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - public void Bool2EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new bool2(true, false); - var b = a; - b[index] = !b[index]; - - AssertEqualsAndHashCodeContract(a, a, true, "bool2 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"bool2 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 2, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "bool2 =="); - } - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - public void Bool3EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new bool3(true, false, true); - var b = a; - b[index] = !b[index]; - - AssertEqualsAndHashCodeContract(a, a, true, "bool3 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"bool3 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 3, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "bool3 =="); - } - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - public void Bool4EqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new bool4(true, false, true, false); - var b = a; - b[index] = !b[index]; - - AssertEqualsAndHashCodeContract(a, a, true, "bool4 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"bool4 differing at {index}"); - AssertElementwiseEqualityOperators( - a, b, 4, i => i != index, (x, y) => x == y, (x, y) => x != y, (v, i) => v[i], "bool4 =="); - } - - [Fact] - public void BoolVectorFalseAndTrueConstantsHaveEveryComponentSet() - { - // bool2.@false/@true and bool4.@false/bool3.@true have no other consumer in this suite - // (bool3.@false and bool4.@true are read by HlslSemanticsTests), so a wrong component in - // their field initializers would otherwise go unnoticed. - Assert.Equal(new bool2(false, false), bool2.@false); - Assert.Equal(new bool2(true, true), bool2.@true); - Assert.Equal(new bool3(false, false, false), bool3.@false); - Assert.Equal(new bool3(true, true, true), bool3.@true); - Assert.Equal(new bool4(false, false, false, false), bool4.@false); - Assert.Equal(new bool4(true, true, true, true), bool4.@true); - } - - // ---- quaternion (== and != return a plain bool, not a component vector) ----------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - public void QuaternionEqualsHashCodeAndOperatorsDetectSingleComponentDifference(int index) - { - var a = new quaternion(1.0f, 2.0f, 3.0f, 4.0f); - float4 asFloat4 = a; - asFloat4[index] += 5.0f; - quaternion b = asFloat4; - - AssertEqualsAndHashCodeContract(a, a, true, "quaternion self"); - AssertEqualsAndHashCodeContract(a, b, false, $"quaternion differing at {index}"); - - // quaternion's == / != are scalar bool, defined in terms of Equals: confirm they - // actually delegate rather than reimplementing (and weakening) the comparison. - var aCopy = new quaternion(a.x, a.y, a.z, a.w); - Assert.Equal(a.Equals(aCopy), a == aCopy); - Assert.Equal(!a.Equals(aCopy), a != aCopy); - Assert.Equal(a.Equals(b), a == b); - Assert.Equal(!a.Equals(b), a != b); - } - - // ---- float2x2 / float3x3 (Equals/GetHashCode only, row granularity) --------------------- - - [Theory] - [InlineData(0)] - [InlineData(1)] - public void Float2x2EqualsAndHashCodeDetectSingleRowDifference(int row) - { - var row0 = new float2(1.0f, 2.0f); - var row1 = new float2(3.0f, 4.0f); - var a = new float2x2(row0, row1); - - var differingRow0 = row == 0 ? row0 + new float2(10.0f, 0.0f) : row0; - var differingRow1 = row == 1 ? row1 + new float2(0.0f, 10.0f) : row1; - var b = new float2x2(differingRow0, differingRow1); - - AssertEqualsAndHashCodeContract(a, a, true, "float2x2 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"float2x2 differing at row {row}"); - } - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - public void Float3x3EqualsAndHashCodeDetectSingleRowDifference(int row) - { - var row0 = new float3(1.0f, 2.0f, 3.0f); - var row1 = new float3(4.0f, 5.0f, 6.0f); - var row2 = new float3(7.0f, 8.0f, 9.0f); - var a = new float3x3(row0, row1, row2); - - var differingRow0 = row == 0 ? row0 + new float3(10.0f, 0.0f, 0.0f) : row0; - var differingRow1 = row == 1 ? row1 + new float3(0.0f, 10.0f, 0.0f) : row1; - var differingRow2 = row == 2 ? row2 + new float3(0.0f, 0.0f, 10.0f) : row2; - var b = new float3x3(differingRow0, differingRow1, differingRow2); - - AssertEqualsAndHashCodeContract(a, a, true, "float3x3 self"); - AssertEqualsAndHashCodeContract(a, b, false, $"float3x3 differing at row {row}"); - } -} diff --git a/packages/cultmath/tests/CultMath.Tests/fixtures/glsl-parity.json b/packages/cultmath/tests/CultMath.Tests/fixtures/glsl-parity.json deleted file mode 100644 index 2a81ae8e..00000000 --- a/packages/cultmath/tests/CultMath.Tests/fixtures/glsl-parity.json +++ /dev/null @@ -1,12330 +0,0 @@ -{ - "generator": "GlslMirrorTests.GoldenFixtureMatchesCSharp (packages/cultmath/tests/CultMath.Tests); regenerate with CULTMATH_WRITE_GLSL=1", - "seed": 20261002, - "points": 256, - "encoding": "each case is 'arguments -> result', every scalar a float32 or 32-bit integer bit pattern in hex, vectors and structs flattened in field order", - "functions": [ - { - "glsl": "float cultmath_snoise(vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "c22f3f7f c241f026 42086d0e -> 3dc3bd61", - "c1eeb062 4191e9f8 41d64d04 -> 3e64f99c", - "40a655e0 c2139bac c1a6578d -> bf33f2f0", - "c247c91e 4244cbbc c11bf440 -> bd94807e", - "422464e0 40031be0 c16a63b4 -> bf03f8bf", - "c20850d4 42014d2a 41214454 -> bf253813", - "4203a578 c1e6e5c0 c230f931 -> 3cb3484b", - "c204e06e 4209e452 4113c120 -> bd526702", - "417aabb0 41e621a8 4107cc30 -> be069d04", - "41ee9a64 4131eed0 c16156a0 -> 3f16616a", - "c20c7df7 4124d148 41e464c4 -> 3e265e07", - "42309e74 c0d5b1f8 c118c484 -> bdbe1f67", - "423fbf28 c1a46420 4134cc04 -> beaaad1a", - "c1b93680 41163fc4 c235e117 -> bf0d1bf5", - "401b4390 c1911e9f c21e8891 -> bc24123d", - "c19c6a0a c0263960 c1fcc4a4 -> bcc0935f", - "41081530 c21add9e 41e81abc -> be4f9154", - "400bae30 c15f8b3c 420fe162 -> be88fbc4", - "41ee68d4 421da0f0 c203d478 -> 3c936ddf", - "c1c90676 408fe720 421de426 -> bebdf28e", - "c1fd9913 41cafb14 3ffd1420 -> 3ef38d65", - "422d29e2 420cb4da c131a258 -> 3e205d5a", - "413b423c 423bc66c c2251802 -> 3e5b5f8e", - "42339834 c2000ffb 4037f3a0 -> bf26310c", - "42431e16 40c205b8 413bf4b8 -> bf304da7", - "c243181a 4165ad60 40273a10 -> 3dd06d33", - "bf90e4e0 c16c8038 c195172a -> bcdb1b7b", - "c11eaa88 c1e57032 be26ae00 -> bf18743d", - "40dce7d0 414b1c94 c1cdd1be -> 3ebd3149", - "422a5100 c20e95f6 407a8d00 -> 3cb43550", - "c1d4b951 41b884c4 41c7a21c -> bd8d01af", - "41ae9db4 c225ceb7 42081266 -> 3ce24194", - "402364a0 4112295c c0544290 -> bd354345", - "41abc00c 4195f4d8 3eeafe80 -> 3efe97fd", - "c2214a50 4159b460 422d325c -> 3f1850f1", - "c1bee3b6 4059ccd0 41efb8f0 -> be9d1ff1", - "c1ce379b 41e49908 c1c794d2 -> bcef933c", - "4166dfa0 41d007d8 c1f5c61d -> 3e3d4f85", - "4101beec 41e1bc34 4081ad10 -> 3f281a82", - "c23f70b2 c159cc60 c1dc2499 -> 3e768a7a", - "c20d7fb7 4198ff20 42025c64 -> bd8aa5e9", - "4099f970 41abe9b8 c0a292e8 -> 3d69b9d6", - "41df5c5c c1b8618a c01f0910 -> bb368569", - "41ddd590 bfa9cc80 c2331efe -> bdd74923", - "c2304836 41db31a8 4183cb0c -> 3e5e637a", - "41f73cdc c19cc0a5 40f6d678 -> 3dd3615a", - "40d137a8 c199e256 c222d5a8 -> 3d3af417", - "c0b62ac0 4192d99c c16389e8 -> bf0f7369", - "c1a9198b 410fadc4 423c3e78 -> 3e7e9da4", - "40b5a0d0 c21120e1 c19d599f -> be566e46", - "c1a04678 3ed37d80 c1da0522 -> bee19a4a", - "c1ce63b9 40dafde0 42467adc -> bea14422", - "418ef334 409bb418 4228783c -> 3e7a446e", - "bfcf68a0 bfe40120 c1bc64da -> 3f150f10", - "c18c65ec c0606960 c1a0ca32 -> 3efec306", - "c1f156d8 41080074 42426b16 -> 3d39d23c", - "403376c0 41d9a298 c00c1950 -> be16c8bd", - "42395ad2 c08cbd30 c23181ec -> bec4aeca", - "c2133ca4 41a28b44 c244ed3d -> 3cae78f7", - "c04c1230 c1c0681a c215f694 -> bf15377b", - "c0090d50 c1de0bdb c2130fe4 -> 3ed331dc", - "c20343c1 c00f1fc0 42410aa2 -> bdbb4889", - "4201e394 41fdd34c c1eb8dce -> 3e149ec6", - "4186d554 c213db2c 41cc5254 -> 3e321ce0", - "41798a50 c2275dc6 42022ede -> 3d1ad50c", - "42035cc6 c2189262 c1e1193b -> 3d9529f7", - "c2307d61 c223e15a c24614ac -> bf05d482", - "4241d360 c23c8351 c157c8b4 -> 3cce7384", - "420214c4 c182fc1e c234c15e -> 3e8e9010", - "c20380a5 c21bf538 42121a1a -> be848e89", - "42436818 c1e78a85 c1a8aadf -> 3ecf0ef4", - "41ecdda0 c245ea71 c1c03436 -> 3debbc6e", - "c2132289 c20aef35 4242eb66 -> 3e3971fe", - "c192df75 c14a3bfc 41d62cec -> bf234d0f", - "41e063fc 420fccc2 4162b1e0 -> be2cf959", - "41b22a84 c19a0f80 c148e780 -> 3ee88a9c", - "c1d76194 c19d32d2 41076010 -> 3ec66de4", - "41e73ec0 c1110f04 c20452b3 -> 3d22da8e", - "c217e1e8 bf190d00 c1f50539 -> bef2d374", - "41d5c494 c1756218 c20f73ed -> 3e62c125", - "422dcc00 417590e8 41a5bdbc -> 3e97d5a9", - "c17f8404 41900520 4227ea18 -> 3f4ed95a", - "c0581670 420ff3c4 c2297356 -> 3e1d42d8", - "40d247c8 419cfe9c 423a5cd2 -> bea571f0", - "c1d6f008 41c1e4b0 41ad5b4c -> 3dc3100e", - "c1d25644 c1ecbd3d c2045013 -> bf1148ef", - "41b2c2b4 c21f007e c23c764f -> 3ec43235", - "418af104 42303024 41f54860 -> 3dbea278", - "c1af7bd4 c1f06e8d 41f0fd00 -> 3ee84840", - "c21802bc 418ca170 3f8f3880 -> be2581c7", - "c22d977f c1581348 41f4d2a4 -> 3f143b1f", - "420a5f54 c13ceeec 41b01990 -> 3b575500", - "c22fc869 c0bf6810 c20035ce -> 3f3d8497", - "41b184c4 c1c2d2af c0a7dc28 -> 3e87a525", - "c1a18d16 41840c7c 412b9d20 -> 3efdab43", - "413decc8 40b8bb20 418593c8 -> bf0054c1", - "c09802c8 4219493a c1a80b2c -> bea2a0b0", - "c23e3289 c2367f12 c1ccb010 -> 3f3112f1", - "c21afd9e c1bf5904 41aa6824 -> bebdd8e1", - "42203aae c2302317 bff8c520 -> be1d86e6", - "c2189468 c175faac c1fcb9e7 -> bf1e0747", - "40d09738 bcfc4800 c186f7c0 -> be61a0b7", - "c2080c7f c1375d60 c15f47b0 -> 3e2e23fd", - "4246a0de c20162b9 41d31cc8 -> bf372c50", - "4243e5bc c2476107 420a68da -> bec8db55", - "410214dc c14703cc c1b3ac31 -> bdcf84e8", - "c1f08630 41818dc8 4162c558 -> bf26bdaa", - "c2124b66 4185fb38 41ea0efc -> be556ab9", - "c1df014c c23764f5 c18f0b80 -> bee4e6d0", - "40c60ac8 41bab9e4 c2178f38 -> 3eec0065", - "c245274b c2080317 c13f27ac -> bf230ddf", - "419f20b4 41255b28 42241554 -> bbe18975", - "c1bd3d23 41ba4d1c c205da3a -> bed2487a", - "c1b339ad c083c280 c2031144 -> 3e279977", - "c19ac85c c08d09a8 41a557e4 -> 3dd624a3", - "4026c060 c23a1844 c2371e0a -> 3def8300", - "c1230388 4047d2b0 421a1472 -> be0369ab", - "c0c7aea8 41a0fb8c c123a7ec -> be62f324", - "42078882 4241b700 418f0770 -> 3f02a2cb", - "c12d91c8 c179b1cc c085d498 -> bb99d007", - "c243f620 411cc8a0 41732ed8 -> beb86cad", - "c1d08568 4243c828 c2415fa2 -> 3da788fb", - "c13a9ec8 c1a75540 c122df40 -> be0be87f", - "422e5386 c191b872 416461f8 -> 3da00b8a", - "c21bfbde 422959be c1ed8199 -> bda65fc5", - "c043d660 420318c8 c1e6c25d -> be8915af", - "c225a474 419c26a8 c2454cb1 -> 3f489f5e", - "c1b0cf6c c2067dc5 c1ee4073 -> bdd8fe5d", - "c1d34754 40de7448 c08406e8 -> be4347b6", - "42412010 421007da 413e7f28 -> bebd5e17", - "c1d6dccb 4214c5e0 c131b3f8 -> bf632789", - "41a5c0b4 c1bb4d6d 42105588 -> bd3c7d7e", - "40023050 c22d217a c05695d0 -> 3ec3b678", - "41981728 c20eec48 41c324b8 -> bd4c1408", - "41666718 c0714680 c1e54d38 -> be80eca2", - "c1ce081a c189f3ec 41de480c -> 3dda780c", - "c1f4525d c150e864 c20961c8 -> 3dbbbb45", - "c051b190 c19b7ffc 416e00e0 -> 3f2c3f71", - "c09b6f18 41b8e32c c0d28090 -> 3e1034e0", - "c0a0a080 c2469f0a c1001984 -> 3f031311", - "40b909d0 c11f1f08 c0dd93c8 -> bf1a07b5", - "41df50cc 41a383d8 c0ad10c8 -> 3e309c9a", - "c1c4f507 c11b70e0 417c01d8 -> 3e39459c", - "c17c5954 42339f94 41d07484 -> 3d5dc230", - "41c41060 c126c024 40a7fcd8 -> bed28bbc", - "c1bdbe19 4157fa10 41a12d44 -> 3ca546f1", - "42438662 42456064 c1ce6f00 -> bebdf519", - "4190b638 41e6927c bf6f8380 -> beeb58a5", - "c06fe6e0 41d35964 40d42ef0 -> 3df90763", - "41c02594 c1c36388 405e7b30 -> bdcb29db", - "c0ead328 c22bc8eb c22e8270 -> becb5b60", - "c23562fc c21315a6 41c1b6f4 -> 3f23e147", - "c1957657 4211f160 41ce5358 -> 3ed499af", - "41d5f6fc 42437676 4229e240 -> 3f2ecabf", - "c217dc6e 420ced26 c0fecd68 -> 3dea1f49", - "c1267028 41b1b970 4223f00a -> 3e25100e", - "c2217f62 c1f91dad c2218cee -> 3eb9c032", - "41ba3294 c079a720 c243ff6d -> 3f4798d8", - "c200cee2 4216c61e 4133bbfc -> 3e9eaf39", - "42300b96 c192b25a 42301538 -> 3e5f5cb7", - "4217d808 3fae5680 c20d2a73 -> 3e14d2fa", - "c216e73e 42264410 42176880 -> bdf27620", - "419d7964 419ed658 c1bd34c4 -> be1d1c2c", - "41f84840 4233dc20 41d81a4c -> be10b521", - "42316cf8 c1deea37 c2461614 -> bc9bea4d", - "c1923382 40c1bc48 422e5c18 -> 3e84ca45", - "c22be462 c22d6263 c2373005 -> be1d3fcb", - "417a5750 416648b0 c22d22ee -> bdace4f1", - "c0c45af0 419b18a0 412f4620 -> beccadca", - "c2328304 42136be6 c1c3b78a -> 3e0f493a", - "c2141386 c14b1b04 409a5468 -> 3cb81859", - "41fe28e4 421b2376 c01fc3c0 -> be7f8af9", - "41de1968 42470ad0 422ea916 -> 3dc1cc72", - "4085eea0 419f4e88 c23e8e74 -> 3e661e77", - "416a29b0 c1ab4706 c1d0d5ec -> bed8d156", - "c18b3426 41e758a4 c1d04aae -> 3e17f846", - "c245e958 42104ae0 c192e2d7 -> be27faaa", - "418d25d0 4213eff8 c1c7ed94 -> bd45b2b6", - "421f4540 c1dd7b97 4213e088 -> 3d448b06", - "c2280786 41934840 c1de9080 -> 3db85c7b", - "c1b8d212 4164fed0 4203ff46 -> 3f050672", - "c244be9e 41906f4c 40f51708 -> be6e773a", - "c1de7ad1 c215a77b c1853122 -> 3ec665f6", - "403e6280 407d98b0 40c965d0 -> be52d108", - "4247b302 4035dca0 c15426a0 -> 3f30ba22", - "c240a192 c243f49a c1632948 -> bd1e9e17", - "42034808 c21af14b 4221dffe -> 3eaab8a1", - "c1502484 c23499ab c244defa -> 3eadb8c5", - "422f95a6 c0953368 3ea4a380 -> be87ed8a", - "c1a17d52 4227cf32 4183c280 -> be6a6a26", - "41288cec 419e2874 c195329f -> 3cc2f024", - "41abe2ac c1b5b247 c2319871 -> bf434d3f", - "c1f51b74 415d2430 41289360 -> 3c4db14a", - "4181e454 c21e5cab 4182a79c -> 3ee59531", - "4222733a c01cf810 c18f1d56 -> bd03bc6b", - "41cac3b8 418dbfcc c17db74c -> be3da819", - "421912de 4217e6d0 c1e59262 -> bf2789f9", - "3f955b60 c1c69f1b 40e4ab58 -> be5011f2", - "c192507a 421fa01a 41176584 -> be8ee03b", - "4200de40 c22c5444 c1da43db -> be33f83b", - "c22aa668 42298142 c1eaed5d -> 3dd35a8b", - "41870c5c 4229c2ec 4208c552 -> bd80259c", - "c1c873ed c1ac7ca9 c1c39226 -> 3cfe207b", - "c196e26c 4201ec28 c14cf694 -> be9d809f", - "41ca21ac c205aa22 c24494a0 -> 3e2577fc", - "c1cee7a3 c067c5b0 40e9aea8 -> 3daaebc9", - "41955f60 c1fb9868 41dcf35c -> 3dbe0a21", - "c20748e6 c107461c c238179d -> be07ba0d", - "c09aac70 c222879e c0ace1c0 -> 3e5f2fc2", - "41c1a28c c12399b4 c149e4f0 -> be9676e1", - "c0771d10 c14dafe8 40dcea80 -> bdf24cc3", - "c142e4f0 410e6244 c1ffbbd7 -> bf700ceb", - "c089ac18 c1d225e9 40a36ca0 -> 3eb80f2f", - "c0053fc0 3ecde880 c12b8718 -> 3eed151c", - "c225a4c0 40e420a0 c2320558 -> 3e425f48", - "42087474 41cf3408 c225a56c -> 3e5609fe", - "40c95050 c229b46c c0cf1c60 -> bddf812a", - "c23f5c75 c211d171 421977f0 -> 3f5929d9", - "c09cdcd8 4224a27e 3f54b180 -> b9d5e094", - "c2055f12 c1e24888 42044a8a -> bedd9fbe", - "c12679dc 3f3d3140 421aa818 -> beaf9a4c", - "4218b028 420c009c c0953ef0 -> bf3767c9", - "41f24a18 c148d7b8 40f5ea68 -> 3ddbc89d", - "4203494c 41e38364 c1dad2ce -> bf50e8ed", - "c23f37be c1e9f8a5 41912ff4 -> bd1fbf7e", - "c13a9230 c229a426 4209aa66 -> 3eee46a1", - "4241edba 4130d7f8 c1844344 -> 3dc93e47", - "c15fdb30 c20058c6 c18e6402 -> 3f4178ab", - "422f6a50 c0c0aae8 c1d33512 -> 3ec9729a", - "41944ac0 422ae260 418dec28 -> 3e1554d9", - "41899e9c c1a7ace4 c23feeb0 -> bd993dcd", - "41b04614 c226b585 4246a70c -> 3c3cd44f", - "3f1d8880 c1eca9d2 41b106f0 -> beea0162", - "41228a1c c238b097 c138c03c -> bdcd7eac", - "3f675180 41bbc17c c1a6ec3c -> be18a787", - "c1e8f44b 4247db4a 422b2ae2 -> 3deb7931", - "c1ee4015 c22cf70f 420646a4 -> 3c5f9f1c", - "418350c4 c1fe9997 412a96f8 -> 3ddbd2b8", - "bec9ea00 c239a7ab c18964ec -> bec175c3", - "40ced0c8 423145da c10fa820 -> 3ec9e0e7", - "c1e21aa9 c2190054 c0a8c268 -> be69f384", - "421fc73a c2098602 bf19f700 -> 3e7d371d", - "c1eaf56d c19eb58f c21646ce -> 3dc16373", - "4193e1dc 4216e552 4214b0c2 -> 3daefa73", - "c216d912 c13ad330 40e734a0 -> bf1cee17", - "42340e6c 420c6bec c0b1cc28 -> 3eeadd22", - "c23bbbe3 41b7c8e8 c0bf8530 -> bd953604", - "c1998ad6 bfd752c0 420fd96e -> 3eb6b020", - "4208af6e c244d914 c21c89a6 -> 3eb65277", - "c10a51bc c1dc9247 c2350dda -> 3e6f462d", - "4186b300 42309c08 c1bf3583 -> be260dfe", - "c1972500 c1394094 42284fbc -> bef0df4a", - "422ee83e 412f5834 40fb3600 -> 3f16fa11", - "41ede37c c246ff6f 419e6c20 -> be8961d3", - "41f2e360 3fdde0c0 c1f7b8c3 -> 3d118acb", - "423995e2 40840ba0 41eed000 -> bede1533" - ] - }, - { - "glsl": "float cultmath_snoise(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c23a40d6 4092ee00 -> 3ecf1315", - "c1fc2730 42198710 -> bd00e19e", - "40595fc0 c1e53d38 -> be186764", - "423c069e 4223b816 -> 3f23739c", - "4156e904 410c3910 -> bebe7508", - "c230e835 c20cacee -> bb67bb5f", - "c13778d8 41ea3370 -> 3eba9904", - "c22911a4 c22938f4 -> 3e9f5ae5", - "c2416893 422e494a -> beaba2d8", - "41312e14 41f972d8 -> 3f4031e0", - "42479b5a 41725b60 -> 3f118d48", - "c242d9d3 c1ced440 -> bec4f21a", - "42125fba c1d55b43 -> bf1458c2", - "41b5c7c8 41c1b290 -> 3e98bad3", - "3ee47300 423a5664 -> 3f579d68", - "41876ba0 4217198c -> 3ef8dadf", - "c055a870 c197e34b -> beb1da3b", - "c1414e64 418eb238 -> 3e97fa39", - "421105be 41e3a4e4 -> 3ef4ae49", - "c113e7d0 c234fc26 -> 3f174bfd", - "c17e6478 c02083b0 -> 3ea4a4ba", - "c1aad508 c1709810 -> bf312920", - "40a5f208 c0df6288 -> bf19d55e", - "c10cc02c c1e8324e -> 3e4f6230", - "41411ed0 41b55548 -> 3e16b891", - "3daf3200 c1c44b56 -> be11ec0a", - "c16ad68c 41b7900c -> 3ea8dbb1", - "41ef994c c13b5eb8 -> 3e7e8521", - "40537930 42315688 -> 3f36d7fa", - "c240d8aa c19f78c5 -> 3f200ead", - "bfb05000 c1d9a553 -> be56e19f", - "c118433c 4186c7bc -> bea269de", - "42275874 c20001c2 -> baca3050", - "41915b30 c229ec90 -> bc7e25c3", - "c10a4abc c121ab00 -> bf1b4e85", - "c1e47d65 c1d67609 -> bf3ba9de", - "403433d0 40ca3d58 -> 3ec85501", - "c03ad740 401a3960 -> 3ecf425e", - "c157fa90 41829864 -> 3ecccb28", - "4197af3c c0cd9fa8 -> 3e5566f6", - "4200826a 3fdfa160 -> bd24f929", - "c2176e6d 41de3c80 -> 3f25752c", - "c0601350 c1089214 -> 3e434b48", - "401cf300 41bdbae8 -> bf00dd52", - "3f883680 42468414 -> 3f0be9f2", - "c20dde77 4227af36 -> 3f4195d7", - "41d55638 c21d3d91 -> 3c7097ef", - "40c432d0 c21ac675 -> bcd9e766", - "c22bf76d 413cc678 -> be93a671", - "c0dbf3c8 c14cfff4 -> be926a38", - "41c6cc2c c18286f8 -> bf0dba64", - "41ecf310 c1de9b16 -> 3f23e003", - "3f9d2ac0 c1b8dac4 -> bed1e9e5", - "41b52e2c 41e80568 -> bf21f444", - "c1c1150e c1b3addf -> bef6ed6c", - "c240d909 4213eb62 -> bf5dcf5a", - "c1c5022e 41036d2c -> 3d87f9ee", - "c003ecd0 423b8076 -> 3f2ffe30", - "c21d643c 414b43c0 -> 3e8b1660", - "c1ed35da 3ebe7d00 -> 3ec0a748", - "4178bc38 4231d024 -> bd056a43", - "40ce8de0 c1045b10 -> bf0c1e05", - "c1c51893 c1a3dbd1 -> 3e46996d", - "c05e6210 c0fbf988 -> 3f2a90e7", - "c2473eb0 c1639bfc -> bea66771", - "c09327f0 41c59f7c -> bf3be812", - "c1d66aac c191d0c9 -> 3dfb1150", - "4195cbe8 bfc74340 -> 3f2c9e6a", - "41b10708 421fdf1e -> bf679a28", - "c1bb962b c1f327a6 -> 3d8b9a0c", - "419688c8 41bb98f8 -> 3d67ed41", - "c0098050 c1d3cebb -> 3eb105cf", - "423f5d1e c1b393b3 -> 3f2d236c", - "41846098 c1fc605c -> 3e6cc5bf", - "414c04f0 41141794 -> beb85357", - "c2456239 c0b642e0 -> 3d9831b5", - "c108cdd4 422b048e -> be2458ee", - "41ad21e8 41f32be4 -> 3df830bf", - "41d9d590 c141bed4 -> 3eb8d354", - "423b3ebe c1e25182 -> 3ee49774", - "41f2f180 c19bd36e -> 3f396f40", - "41e682c4 42205c78 -> 3f4fba2c", - "42008e10 c1b7518e -> 3ce9a76d", - "415c82e0 422e674e -> 3e9c4579", - "421df556 4245fb4c -> 3df5320a", - "c1ca061c c1ea86b5 -> bf3c39a3", - "c15d8fec c245071a -> bebf97b8", - "41fc7130 42286292 -> be894a35", - "c0597d60 c1888dcc -> bf6f1644", - "c0c39f10 423f3d90 -> 3e4ae246", - "414f872c c1af6be6 -> bf5a368f", - "41eaff28 c1111250 -> 3e187bcf", - "c16e1318 c2439ca1 -> 3f05d625", - "c185f99a c19c73c7 -> bf29b3a8", - "41221a9c 42195002 -> bf1d43b6", - "41a9b63c c17c3320 -> 3f302997", - "422ca05e c234a254 -> bccd6744", - "c12c3248 c13b4798 -> be411a10", - "42328b1a 40f85c10 -> beaca107", - "c109d5b0 41a60bc8 -> bc4b6545", - "415c55bc 41b79200 -> 3ee032ce", - "c1a84b07 415417bc -> be813be1", - "c177dc34 41efc244 -> bf23b34f", - "c2276462 c114b16c -> 3ef6f9cc", - "c21b3409 41ec5cc4 -> 3eafad51", - "c181a470 c0b67290 -> 3ea8acb2", - "4230042c 4244012e -> be33cc5a", - "410bd5d4 4012eb20 -> 3e38e6af", - "3f92d6a0 c141e824 -> bcca46ae", - "409f09e8 41f85560 -> beff379d", - "422f5406 c1854ac8 -> bef6232a", - "c1843eb4 c2435aad -> be6bdad4", - "c1adbfa2 422209ba -> 3ee4dae7", - "c1b3c775 c195834d -> 3ecec9a7", - "413815e0 c0d7ac20 -> bf04b4ba", - "423dd778 421b5ca8 -> 3f365159", - "42262e86 41b90c74 -> bdd85d24", - "c17f5f78 422018ca -> 3f01f866", - "42446f90 c207865b -> bf288195", - "c22e4d87 40a4d0c8 -> bf488e4a", - "422bc7c0 422a2f8e -> bf24cfd7", - "c1f60bb4 41f4b08c -> bef0f54b", - "409111d8 c1b8ad20 -> 3f2fef6f", - "c11c43d4 42309f32 -> bdb7abbc", - "c0797c90 4213c4bc -> 3f2153a0", - "42149764 40d82920 -> 3f3c0210", - "c23cd5bb 41257f8c -> bf1d720c", - "41d763bc c19c8a59 -> 3ee81d7c", - "c1285e98 c1b195ad -> bbe505bf", - "c1706904 c0c00640 -> 3f3dbb4b", - "401c4dc0 41d6ba88 -> bedb1c02", - "41e99c5c 418f82f4 -> bf262d83", - "420056ea c0a17700 -> 3f17b0fa", - "40303290 c1e90419 -> bf1ecec2", - "416f6438 4195b954 -> 3f267c7d", - "404bf220 c16f8bc0 -> bf025a95", - "c1945905 42474724 -> 3e6ddd5c", - "421862f0 c242db87 -> 3e8cf21a", - "c20f9f8b 40388600 -> bf48b7fa", - "c057ce90 c2428941 -> befdfefc", - "3e8d5780 c18505d6 -> bdceedeb", - "420cd622 41c48178 -> bf13d89d", - "40c398c0 c114b6ac -> bf383e28", - "42103262 c19662bb -> 3e2632af", - "4238d45a c23992b2 -> 3e70e2aa", - "3f0c1c00 41aa74cc -> bf3d538b", - "41f927cc 4146cd04 -> 3ee49a39", - "c23d2ac3 c2079584 -> bf743bfe", - "c2129e9f 3fa71580 -> 3f165a80", - "4242015c c221aee5 -> bf14b7be", - "41c14c90 c1f51dd1 -> 3e803abf", - "c1a673b6 41db171c -> 3ed25651", - "c181f4cc 4007a550 -> 3f244144", - "c1c59cb5 c23c1ce0 -> 3f3e27a6", - "41b1f9e8 41cd1acc -> bf2cc582", - "c206a5a2 42125ffa -> 3f1cd2e7", - "41f96424 c1832200 -> 3ea41e15", - "422ee488 c1f77072 -> 3eb62be5", - "42268722 c235728f -> 3f22e8ce", - "c218b19d c109edb0 -> bf175de1", - "410e7af4 c1e396f6 -> 3dccf526", - "c1caacce 4135aefc -> 3ed93df5", - "c1fea78c 41ff0978 -> 3f1fc63b", - "407892b0 4198407c -> 3eefde77", - "423c71e8 41aff0e4 -> bf24a2d0", - "4217c318 414c9f28 -> beb4e35e", - "408c3828 c14f3810 -> 3c4c7c54", - "c1b65f13 c198acd0 -> 3e811444", - "c2374910 c228b56b -> 3ea4c230", - "c1131378 c238073d -> 3f4b6b51", - "c20a5f50 42044f42 -> 3ebbbc7b", - "410f46bc c1eb7217 -> bf13bd7a", - "421512ee 415f41d4 -> 3e18f640", - "42208854 c01db1a0 -> 3f148866", - "41959d70 42068d76 -> be4960d2", - "c1cc394c c2252c10 -> 3e871fa1", - "c12856dc 40e3e640 -> 3f058470", - "3f2c9780 40271c30 -> bd6c52ba", - "4232c77e 418eb4cc -> beacb0ec", - "41137d4c 3ff01c00 -> bf517658", - "4240f12a 40c88b40 -> 3f231185", - "c2308ec8 c246fb80 -> 3ed11cb1", - "4216ca4e 40632950 -> 3f337bd2", - "c18e4e12 c0bbff58 -> bf368e3f", - "c22e6177 414cebc4 -> 3eee0400", - "c20c6f29 42073c8c -> 3ee84c2d", - "415d4940 c228aa60 -> bf1870d9", - "c1c03839 41ce9ef4 -> bf0d7e6d", - "41498b58 c2379d5c -> bef8f48c", - "41c0b19c 4086de20 -> bf3795bc", - "4226fc66 c22e9bbb -> 3f17fb29", - "c246ae7b c2121b8e -> 3ec697fc", - "c01eae70 41e9de50 -> 3f48f065", - "c1d58500 423d0a3c -> 3ee1cbb3", - "42117f9e 41c4bd68 -> bf590c72", - "c15c7798 c15a8dd8 -> bee2db5d", - "bfb297e0 421bba42 -> 3ef3c3ca", - "c230f866 41123d24 -> 3f2fca18", - "41d9bc18 410b34b8 -> 3efe6978", - "c18906b2 c1823f4a -> bf2c8121", - "c1921103 c07f7c00 -> 3ec56140", - "c10de68c c2306c39 -> bf215d6b", - "4195f93c c11564cc -> be8a0d21", - "c0a3f2f8 c192d6ac -> bf010f75", - "c196ce38 41c6c5c4 -> 3f0ec591", - "42200eee 422264da -> be38b652", - "422f0196 c233fc71 -> bdac16c1", - "412211e4 42278ce6 -> 3f32fd53", - "40bdff20 42298cc4 -> 3f3e88f7", - "402ef670 c22624da -> 3e7cf7a1", - "c19e15d6 c170c514 -> 3df4b1c8", - "40f803b0 c1918055 -> be85acca", - "c1bb4e51 41e4689c -> bf2b4784", - "c16cbad0 41c73018 -> bea9b72b", - "c23fb1fa 4186a938 -> 3e8b1460", - "42427170 c2386a59 -> 3f47ce00", - "41a9cbfc c11a1e2c -> 3eaec4b6", - "c1dc3775 c0885ed0 -> bf2e98ec", - "417377a0 4231bdbe -> 3e885bcc", - "c0a8c160 c22c91b4 -> bec2d17d", - "c17a49e0 4226a8d6 -> 3f11cdbc", - "4180e2b0 c219e344 -> 3baa372b", - "420a4fc6 c08c1600 -> bf388e6c", - "c0ed2868 c0ccc270 -> 3f480896", - "c1a9946d c210854b -> bf28d264", - "c23b309c 420b5146 -> be85a38f", - "c2302239 c1ccbcff -> bf1a2a1d", - "c23a14ba 423b28c4 -> 3f3a2b5c", - "421907ca c222b979 -> 3ef316e0", - "41ea75e0 4220c852 -> bf2f7c3f", - "c2322a80 419fd328 -> 3f15c168", - "c1a372b8 41651120 -> 3b2c91af", - "41d1e2e4 42107946 -> 3e57580f", - "c1f50248 40589210 -> beff7102", - "42021f4a c20e6fac -> be909220", - "c1baa207 41380898 -> bee5bd3e", - "c015b0f0 c083f728 -> beb11933", - "41c0db3c c136cf08 -> 3f1cda6b", - "4196bac4 c071c460 -> beba750d", - "c030ff10 41f7b730 -> bf333c46", - "c1609a98 4226699a -> bf205072", - "c079dbe0 4218d350 -> 3f0a3f18", - "415a14dc c210dfd6 -> 3e9c1475", - "423fb7e0 c04bb830 -> 3f278e04", - "c151cb44 c1c288fd -> bd938f0b", - "40ef62e8 40bcbb08 -> 3ea5c06c", - "c20b7d33 4090fc10 -> 3e77ff64", - "c2426734 41660fd0 -> 3ef7e0bb", - "414188cc c240d2f0 -> 3f163b0c", - "c16b52d8 4241d680 -> be816f9c", - "c1be0338 421cd1d2 -> 3f01d8c5", - "413121a0 c20e5a8a -> bebcd718", - "4214cbb8 c104cb08 -> bdf89065", - "c14d4eac 412172b0 -> 3f11920c", - "3e99f180 416e7c20 -> 3e5dc77d", - "c1b0693d c0fedf88 -> be74dc4d" - ] - }, - { - "glsl": "vec4 cultmath_snoise_grad(vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "414159e0 42415f5a 408777c0 -> bfc283b9 be845996 403c134a be8fa30e", - "c210941b c1d0f15a c10a32b4 -> 3f8879d3 3ece0782 bf9417e9 bebaf6fe", - "c24540ef 41474524 4218c166 -> c0107e33 3e84b23d 406156ad 3f0b904e", - "41b474bc c206040e 40db1e48 -> c016cdbe bec9f4a3 3fd31714 bd97fc37", - "40dd1fb8 41a62f38 c0680a60 -> bf828288 bff020bd 3f9b4203 be2d525b", - "422c856e c0b0bd88 c2211654 -> bfda3a71 401f2363 3e76bccd 3db9aee8", - "41d3d418 418860a4 c21c4790 -> 3b9b54a6 3f81f2e0 3f0d7a69 be140daf", - "bf9cce40 4096e998 c04f8780 -> c0932f88 be352dd4 40167f4e 3e3816a2", - "c19bbd9b c1928668 c243f868 -> 3fc18357 3fb40f7a bffa5af4 3ed5aaed", - "c1e0900d 41d4e7a8 c1429330 -> bfc158ef be6ec42b 40010051 3cfcb479", - "423a109a 41afdc50 423ef01e -> 3fe14a57 be713f9b beef1416 3dd80d87", - "c20a37b2 422f40e8 c204dc8c -> c082494a 3eec8b30 3f249f22 bed26a45", - "c246cf75 42162ce8 c1180d84 -> c058de17 bf0800da be546d56 3d8ac329", - "c1ea2240 c2439201 41b6b404 -> 3d52317f 3f0295b0 3f4f70c3 bd564a82", - "c21eeae5 406c4060 41b5abbc -> bf0901c3 bf96028e 3fa4a150 be05284b", - "c2371b61 40f00c00 c2064be4 -> bf2b1b45 3faeab20 3ebe6a94 be405e66", - "42354de4 c0bec8c0 c2098ba3 -> 3f2fba6b bf172ae3 3f75dfed bdfb6b3b", - "c116d724 4219b4fc 412e6c40 -> bfb8d25d 3f2c6b78 3fe6d2b8 be16ed51", - "c19728c2 c212c315 c0cbeed0 -> 40250a36 4000c857 bfa85cef 3eac45a4", - "c22a1890 42054ab2 4228ca88 -> 3e9ddf01 bf93cc09 3fd4e524 3db4dc74", - "c11a5114 41e60e2c 420f5d74 -> 3f174946 3fa8b399 bf92e39b 3e95810f", - "3eb31900 41d05388 c0af91b0 -> 3f7c81d1 bf85b173 401ec50e beed210e", - "4111cea8 c108915c 41d7ad68 -> bfbf7bf1 3ef1ae29 bf756b8c 3e949501", - "c1a34834 422b54e4 40dddb40 -> 40235187 3fcb8828 3ed54e6a 3ed87052", - "4199da18 40b7d958 417f0950 -> 3d58466a 3faebacd 4005fea3 3e858257", - "c13e8644 c137ee34 c243e6d2 -> 3e42b9dd 3f72d579 3ff98eee 3ed176ca", - "41c06350 c1bd86d9 41c17698 -> bc0ff503 3f2e4d68 bfdb4ae1 3c9075a7", - "420a537c c1bb2bd5 c18b6626 -> 3f7b76ff 4027fb29 3fe09427 3e48de70", - "c1de3251 40be3320 4206392c -> bef709cb bf9a1c46 4084aecc bd77fb34", - "c152abc0 42095cb0 41f407fc -> 3f9e219c c059ff5a bfa632a4 bef43ef9", - "41b9429c 422b491c c2371dcb -> bf8b7b56 40433d3b bf187932 3f210296", - "bfd9bce0 41f30648 c1dd3231 -> be343aae 400809d6 bfc72cb5 3eab8e8d", - "4213fc8e 411ebba4 41dd3480 -> 3e2b7294 3f309ea7 404f1e48 3f34fe70", - "c1ae6fd6 c09c7850 c207da2a -> 408217df bf55e8a7 402ed8cd be958d33", - "c1288a60 417bc7f8 3f9a40a0 -> bf6f4f5c bdbf8ba4 3ea55906 be16b50f", - "410ae3d4 41aaba54 c18a8c5c -> 3f305906 bfee6f69 bffce034 bcde502b", - "4233d8ba 422c0d30 41c670ec -> bf16828f bfc2f289 bf296ead 3d757478", - "c0ecb840 c1849472 40e070f8 -> bf3804f0 bf3550ef bf7efd4e bea09a41", - "c1ffe18b 40b8c200 4009d010 -> 3f484c46 3fe7800e bceda50c 3f413ab2", - "40510880 c1af014b c1ef393d -> 3ff4f8f3 3f7b07b6 c07b1101 3f14b5f2", - "412f5280 c1ddc2cc 40e3f7e0 -> 3edbcd7d 3e8cd07b be20f13f 3f6074e1", - "4239d2b8 40cdd4b8 c247f439 -> 400191e3 3f26632a bf23af81 be421986", - "402d9340 c1e88a19 41caf00c -> 3e73881e 402a1ba1 bf55a3d0 bd83dbd5", - "c0cd2498 3f8c3c40 41e4ab14 -> 3ff6282b bfab9663 3fc5afac bece0e18", - "c1d50226 c084b360 41f9973c -> beb2ba88 3eeed41f bd15acf3 3dfa3092", - "410255d8 c09c4f60 412de060 -> 3eae8566 bfd439b3 401e1069 3f1b61c2", - "41faf5cc 4158b78c 420a6938 -> c06fe526 3c77d226 bff6e217 3f14977d", - "3f5fd640 c1020eac 42254f7e -> 3eadff8c 3f5558c1 c02415c8 be5546d2", - "c231347a c19b8f54 41164d50 -> bf9edad8 be1e19ea 3f3c79e4 3d96ebc5", - "c032beb0 c19dba46 c1cb2a35 -> bef2d54a 3efdfd31 bf41aeae bd125578", - "41a193cc c18227f6 c191a0e2 -> 3fe43304 bfad607f 3c777eae be5c3d7d", - "40f1b700 4189e6ec c1d95b48 -> bfdd3e0f bf57165d 3e45b39a bebcddab", - "410e9b6c c0dfaa70 c222c89a -> 3dde43d8 bf8983dc 4048012f bf1cc4fa", - "3f98c7c0 c230203f 3ed11c00 -> 401a5ff0 3f46a1c1 bea5aba7 3e7a5165", - "40ea0e60 3fafa9c0 c10152c8 -> bf532996 bf4935c8 3e5954b0 3d46f9fe", - "4238e2ee c1f62bea 42164c32 -> c015d71d bf8b6378 3f0b1daf bf244bc4", - "41ce8504 411de714 c21d5dd4 -> 401ab373 40427d6e 4053def7 3e86bfd7", - "422524ea 41af2b44 416945e0 -> bf8b3068 3ecb8d8b 3f5d0f4a 3e319045", - "c1681758 c21faaba 41f3448c -> 3f27ca21 3f5a3319 3f88901e bd90ba75", - "417cbdf0 42230730 c1c0fb7c -> bfc982b5 bea41ee2 3f777a2a bf175517", - "c1161e34 c231fae2 42229816 -> 40669423 bfbcc43b bff0f466 3eb7f79a", - "3f434840 41bb2310 c2028a23 -> 3f02ee61 bf5c946e 3f000033 bc3c6771", - "c04da050 417d2038 41e4ec3c -> 3f0c1928 bfb1d1d6 badeed24 3e376d00", - "4105e508 4244ee9c c23f949e -> 40514768 3fee4ac2 3f91a293 beadde13", - "3fc81620 c19e96ad 40f27108 -> c018615c bf1ebcfa bbdb23f6 bdc9a83c", - "c17ce400 422e3d8e 4221ff06 -> 3fc043b9 c00652a3 3ef0a249 3f22cb31", - "bf16f3c0 c2221768 c21ab1b5 -> be1e1f1d bf90905f bfaf28d2 3f5777ef", - "41ae8e44 41ab2328 41a35234 -> 3fa2b9e1 c02935f0 bf86a238 be9de484", - "c2103746 41e749f8 413d5990 -> bedac8bc 3fb79194 3f8ded5b 3ea8c971", - "4189bc30 c1df8694 40e4f178 -> c0b13b97 bfdf75d3 bcc21274 bdf1ab56", - "c0f27f50 422c7760 40103820 -> 401da2a5 3fa4cb55 3e083317 3f1e4a46", - "4205b524 c21db235 c246255d -> 3f8d57e4 40953f97 c003698b 3ee03cfb", - "411c2884 c22dcb56 41dfd78c -> 3f23da60 3feff431 3f9635dd 3ee92d6e", - "c1cb951e bf10c380 405a1fe0 -> 40854c0e bf2999e7 405a5ae7 bd902530", - "c22429ec c20236c0 412a2ca0 -> 3f3a9b15 bff5bb46 bd742c53 be426c7a", - "c225c936 c1246f1c c1047c24 -> bffd2ac8 3fba2e4f bf215851 be7a279b", - "c22bfcaa c242ccd6 c205e848 -> 3fa805bd 3f190f2d bee663cc 3c32b823", - "421fa340 c20674b5 41fa3d30 -> 3fb8bf85 3f69f9bf 3fb74b93 3eb448aa", - "c20dcc09 419662a0 c17e31d4 -> 3feefb73 be760b44 bfa09912 3ed02814", - "c1ee2207 c152ee64 4231ec8c -> bf5ac1f9 3f8e5c3f bf718e8a bea8c4b3", - "40b0fbc0 41ec8fc8 c0c7a548 -> 400c7cc9 3eaca3ca bf83cf3b 3f09403f", - "c1e45020 c20836d4 c22f88c3 -> 3f155b19 3f7f688c 3e837ead 3db4af2d", - "be181f00 4191171c c1f33243 -> bfb1e348 bee4ab12 3ee99335 bcc9b722", - "40e39be8 41c379bc 421408e4 -> c0129945 bfa385f1 3eb0cdf6 3e903312", - "c215ecc1 c1c92280 4120ae98 -> 3f387a9f bee2edfd c04f1782 3e4bcc8c", - "40fd6268 414dc438 407c8530 -> 3f8b5645 403c8626 c06f15d6 bec0ba65", - "c220e20f c2326e10 c12cfcf8 -> 3e49b7d6 bf2fa2f0 3fb32f1e 3ba8f4b5", - "c1ef1527 41236b04 c1e9ece7 -> bf39afba bd9e8231 bf5117c9 3e270cc1", - "c115e624 4020cd70 41d5d828 -> 40098dca bf54b134 be2be60d bf3dbf28", - "41a7c9d4 41970258 c1038e18 -> bff26007 bfbcf90d c0006cc8 3ea257c0", - "4182ce30 c127936c 419de084 -> 3ef19329 404957ce bf28d945 3e892bf8", - "4205ff3a 41982bf0 419eea1c -> c07b8e83 3e71b89b 3feb920e be23fde4", - "c221695a 4215fe24 c241ffec -> bf46ad68 3e927925 400f90d8 3ea60fdd", - "40909f58 410b3ba0 41acb158 -> 404142ee bf943be6 4015c62f 3e4cf8b5", - "c1df0bce bde05000 c1b9136a -> 3f7075f8 404c61cb bf355f18 bf241576", - "c1a3e258 41db2004 42261c8a -> 401a1ab1 3e9e4d2b 3f498f65 3ea392fb", - "c1e61a1c 40d43d50 c2303fbc -> 3ffa1e37 bf2dfcc4 bf0c4c43 beca6d33", - "41f15670 c21e2ef4 c1949b13 -> c024821d c0348ebf bf175522 3eb9e398", - "40a95e58 c16957d0 c1f525bb -> be3d44a1 40a783b5 3f6129cc 3f0a60ef", - "c1d7fc6a 41f6a2f0 4156f158 -> bf739ff0 c03db8f4 3f444889 be980d0b", - "c1a4e9ad 41e705f0 42450a5e -> 3d96a193 bede4c17 3e79b65f 3dbf999d", - "41de94c8 42230c66 c171791c -> 400c4bed bf73d276 beb025c2 3e966348", - "c202e75e c1a7d7f5 40bac640 -> 3fbe908e c00d59b1 3d97eb87 be8dd7f6", - "4220b698 bfdd4b20 41cae5d4 -> 402e193b 403bab19 40145e1a 3e9d4751", - "401c8400 40a85030 c053cf80 -> c00d6511 3f0406eb bfa0e107 3ea6dca3", - "418cd02c 423ffb54 c21eb517 -> 3fd19adc bfbf0b56 bec2bf59 bed3e44c", - "422f9340 c21b885d 41c8f9ac -> bfa37f4b c0658cf0 3f87a9d0 bf0007f8", - "420ccf88 be870480 c217067d -> 3fd9cee2 c0182ec6 3f37c956 be917347", - "c1628f24 4210bbe2 c1a76bcd -> bd9ec9b4 c0271ded bf806815 3ebb0c17", - "c13b08d0 c1ae5923 c1832828 -> bf97398a bf9acb13 3fdef325 bee35ff2", - "3f01fb00 421294dc c22d5355 -> c02f31e5 bf99dcc5 bfd5f970 bdbfcebd", - "c13ef108 c1c6ee7c 41ee97e0 -> bf16d21f 3fb68ee7 3f880f1d 3e89bb7d", - "41b29c98 c0b68260 41120dcc -> 3f0991d7 402d79bb bfa3fc52 3f2966b6", - "4227d492 c21709ce bfd080a0 -> 3fed784f 3feabe67 3eb6c37f 3e5e96c9", - "c164f0f4 c197874c c2268dfc -> bfba921e 3e1a7e54 3e915d8e bdbd116f", - "c19b654c c1b23a11 40a63830 -> be8777ce bfb9af02 3db46577 3ea4e2cc", - "420aef6e 4216c3b6 c1494520 -> bff4feaa bf82d787 bf762bc2 bd97be00", - "c223ddc6 c1a722ed 419db3ac -> 3f70210d bfd79ec7 bf5ce4f2 bee15fe9", - "42193f80 c0ba22f8 c1a6de00 -> bcae8fa7 c0981f7b 400337e7 be581b10", - "421410dc c1004748 c235af7c -> bf38eea2 bf28f1e8 3e5420fb 3d8eb8dd", - "c230a860 41e7b5a8 c244bf69 -> bf8e742e 3f53f80b bd091802 3cacd62f", - "c1de2649 c1254554 413a032c -> 3f8e922d 3f08ee11 3f92994a 3f0df07b", - "41958c7c c20e7b7e c19efd7a -> 40659eef bfee266a be8c3cff bd2e1380", - "4186ee2c 423519c8 406cb9f0 -> bfb35807 3f8acc36 bfb14a90 be6f15fd", - "3f98eec0 c2404150 42438170 -> be7048c3 40263431 400e60fd 3f1cccbf", - "c1b9fe4a befa1d80 c1fa94c6 -> bf33da87 bfd3f1ec 3fe0ceff be4091fd", - "c2387880 c232f124 410763ac -> 3f9544ee 3f82a5e1 bfaa8afe 3eeb6446", - "41bf0628 4064e5e0 c117c120 -> 3e70a4ed bfab5c60 bbd75e06 be374825", - "4238bd34 c1086938 40f13298 -> bfc65ba7 3e324395 3f4d2cab be0d74d1", - "c150b4ac be7bc200 41f79a44 -> bf02591f 3f55cb71 bf51eacb 3f4ff1b5", - "3f2ebc00 420d3d70 c23ebe7a -> 3ed94950 3ff0bfd9 4006df48 bc4002bd", - "40919770 42107cf0 c185c946 -> bf45ed78 3f089f0d 3f6ada58 3da7fb52", - "c01c49c0 c2122918 42258dae -> 3f18286f c00c347a 400e7c5e 3e1396e3", - "c050ec80 413e1c70 c212a18a -> 3e74aea4 bd8f99c0 3f11f548 bd935070", - "c1c7747b c20087a8 4229a9ee -> 3f89cf03 bf900216 3f2a6393 be407b47", - "4206e318 40fad620 c1b6a04d -> 3fb5b484 bf79334e c048ba80 3f076475", - "41a6b0cc 4138fa90 4232afda -> 3f8ed92c bdcd7cf6 3ff2d297 be51a014", - "c21e249d 4204895c c15482b8 -> bf841e29 3f06a507 3e4caa07 bd8acfa5", - "c0788670 c19056e7 c1c4e710 -> 3cd40656 3fdfead4 3eb1905e 3e3c397c", - "4124c378 c1bfa0b0 4240c8f8 -> 3f3ea9f9 401813a8 bf5d2d82 3f09f7b1", - "c237a587 c192192c 416a0110 -> bfcebb53 3f5b9304 3f85ed97 3d5a4754", - "bf52f780 c20743da c22023a9 -> c0221ace 3fe97faf bee8675d 3ee17fb1", - "3fb14320 423a9488 c208be42 -> 3fd8e677 bffb507e bf8306ea 3ef9ee71", - "41799850 41e98af0 c15f2c88 -> 3f1b9192 bef1738f 3f2c5ca8 3e2a00e4", - "c1b5b024 40e4b240 c0d3c1f8 -> 3f55e43a bfed427d c0518a31 3eed406d", - "c09c2c60 bf9855e0 c164a7e8 -> 3fd50a46 4014e14d bdd49bd6 be20fd21", - "bff346c0 c21625e5 42068aee -> be0a1934 bf81618c be3f2534 3ca38f3d", - "c19d130f 4180f4dc 4218c59a -> 40646f24 3d3d355a 3f67f4e1 3dc31f63", - "42111d48 c11c81c8 c23f4bec -> c089257e bf6c67d6 3ddaace5 bf343571", - "417988d0 c22644ab 40854320 -> c00d2156 3fa63b43 3f11408e 3ee3fa65", - "c228711b 42150a86 4215a740 -> 401a5809 bfa1f183 bfd42d5c 3f0a14b8", - "422cc4b6 c0eb4a00 c19ed89d -> 3faae513 bf6bf90d 3fff4360 ba8d8790", - "bfa439a0 41cf2344 c24143cf -> c0726886 bf252abd 4013f97f 3e382fb3", - "4201cd98 c18d4e00 413318ec -> c07dff8b 3ef096a7 bffa2938 bee48c3f", - "c21a91e4 c2330dae 4201792e -> bf8352bd 3ec3e236 400d6b8e bf1f7860", - "4109ebf4 4204b376 c1c019d7 -> c01defd0 3f946655 bf5e0790 bdc07aea", - "422d5792 c24402db 4204973c -> 3ed4bb96 3feda904 bebdfe0e bd5c78c1", - "421eb672 c21734ec c211aa74 -> bfb4331d 40232753 bfbee30c 3f11ff1d", - "c20dc1f6 41bdc804 4179e3e8 -> 4031cee1 3f1e6914 c093f528 bd4a5482", - "41d37554 414e5b6c 41cfb934 -> 3fdd44f5 c00ace3c bfc08f03 bebe4b05", - "c228d7bd 420f27e4 4218d934 -> 4022d58d 4027d1db bf5b6c23 bdccb8c2", - "413a6568 40f6b978 4227baf2 -> 3e0028fa 401383b4 3f098e0a bf2c94af", - "bfae4c40 c17e7320 c20e0078 -> 3f17b522 400b4547 3e6d9ccd 3e960947", - "c2130bf1 42399c40 41b75760 -> bfae4657 c0140d5a 3f77e814 3efaf448", - "c17f98ac 417a60d0 41f10238 -> 3e6be0e2 402e3727 3f95e312 3e6d89d4", - "c1dc7699 c1f7ef46 412e2078 -> c03687b6 bea297c4 be44197a bcee6ac3", - "c230b394 c1b2bb6c 40e160c8 -> bf463fcb bfb06e27 c01c8d55 3f15b483", - "41d18200 41b21548 c22a41d0 -> bfb80001 c010c997 3fc5eb99 be94ba54", - "41a82254 c1fe4f1b 41c87ee4 -> bfa6ed64 c0818a1f 3faa639b bea40371", - "41bea368 41e50d58 41976580 -> 3f988779 bfef83f0 3f5a2684 be612566", - "41686ae0 41b24714 c2140539 -> 401600ef 3fccd158 bfc74a6b bec49159", - "c1c240cf 41c54aa8 c05cee50 -> 3f475fd3 401083ed 404339fa 3eef74bc", - "41b7da10 be959f00 c01e4dd0 -> be13c854 bf61f81b 3e775b3b 3e1e20a1", - "4221be3c c22012a2 bf6bf0c0 -> 3ee970ce bfd01465 bfba3bc5 be50922c", - "c21a0c73 41f0c704 c2359f1c -> bea776fe 3c0c88f4 3e85a75a be32dfd6", - "c21f1474 40b4e4f0 c05cd200 -> 3f2e09cd c02786a5 bf22626c 3ece3eee", - "c184571e 42287956 4096dd28 -> bf6c398e 3f1d23a7 bdda2e92 be11eff4", - "c2350f24 41a4dc7c c16c2dc0 -> bf74bc16 bfb1db27 3cd5969c bce7a58f", - "c1f89eff c193317a c211e2bf -> bfa0287b c0339645 bd55d7c2 bcf3e3bf", - "41f63608 42228830 c128050c -> c066fd26 bf228785 bfb64f83 bef9024c", - "c2048480 41c677d8 40aee468 -> 3d064c84 3f931331 c000d264 bef1b5cb", - "c08d99b8 bfa4d520 c1cf0e90 -> 3f433248 bee215da bf30ea69 be15e77a", - "411ec3a0 c226c5c4 4223f2e0 -> 400d76b8 3f4defe0 bf6d082f bdb7fe0a", - "c1836000 bf0a1580 419a6734 -> 3f4a8479 c02542e7 3f6b5dfa 3eb4388d", - "c2129304 c20a71cf c2014b14 -> beaf8e77 bfac9147 beb6d833 bf59d902", - "c2282424 416b35c8 4228a722 -> 3fd63f53 3e1a4690 bfe787bd 3eca8b19", - "c23ca2b4 412c9678 4148ef54 -> c03abc3d 3f4a6506 bf2861db be7fd8fd", - "c1abe6dc c11a0af8 42120d54 -> c007c724 bd887b1e 402713d5 beacdfd4", - "c20f28e6 411ca76c c2414ab4 -> c09831c3 3f50bc2b bedc3060 3bfb86d7", - "41de0c70 c22cd0e8 c0de0f80 -> c01b1c82 c011e19c bfbec372 3e8439ef", - "c187d84a 4228d206 41113248 -> bfd1e61e c005a113 c034d69e 3dd061fc", - "c227e39a 41bc8578 c16d3a30 -> 3fc6237b c0785ab6 beb8cba2 3edc0bca", - "422e73b0 417e9b10 c194ebad -> bf96ff03 40936de7 bf9fc6ab be2c14bb", - "41f3d058 3e9d5180 c029d9e0 -> c05cfcf4 bf2ab396 3fa4a91f bda5a7b3", - "40b1fff8 42478470 c0eaf2a0 -> bd45ef52 3f1eefd2 c01f8bf5 bed52b76", - "420da80a 422583e0 40a70068 -> bfbd942c 3fd1bbe3 bf4ba357 be92b03d", - "c201c05c c21c2b5c 418733a4 -> 3e834769 3d25edbb be90233d bd4b59f3", - "c1e513c3 41df7b70 c1a13adc -> c05425c8 bec9f9a9 3f2c74cc bb0b65da", - "41d785d0 42196eee c1790560 -> bf309829 3f669d40 3f3d2c30 3ecb081c", - "41979e6c c19514a3 421baf7c -> 3deaf415 c05a8a48 3fc9e67d 3f16e51f", - "c1dc792a 4200aab0 c241f4dc -> bf2ea52a c0152911 3fc6835a bf0018eb", - "c004b310 c245c3db 40e82d28 -> 3f525312 3fa1ef90 c030695a 3ca519ae", - "c21f18f7 c232af6a c102d228 -> c007b7fd c021c5cb 3f3db6ea 3e99c1f9", - "42020378 c20e97d4 424326ae -> 3f6b78a7 3fe44f18 3f74c6be 3e8fd014", - "412c73e0 c1dd15c1 c21e1505 -> 3fe57c38 bfffa749 bfa81379 bef0f96c", - "c20b268e 41b79924 c1181cb8 -> 3f757848 bfcbf14f 3e91cfcb be2c879b", - "c0c4a2b0 c1a9a1de 41934bf4 -> 3fbe57a4 3f052a41 bfa5368e 3ec2997d", - "c062ac00 41231a4c 42375a74 -> 3c367fab bfe88ccd 3f2b96fe bdc31a50", - "41d14880 c2196244 c20eebb2 -> bea1570e c032c2cd 3f18c3db bd6e1fb4", - "c1a62c01 c1974d04 420cd3cc -> 3f70f552 3fe13609 3f73d0b5 3f4cff68", - "c2450d34 c1cab70e c1773ba8 -> 4018e354 bd78a440 3e03a9c5 3cb119b3", - "c0f12a90 41009304 41911fe4 -> bf5b58dc bf4640b5 bfc688cf 3ea7a478", - "c0854610 c22974d0 4245484c -> 3e3077e9 3f31e415 c01e0c93 3d0c5036", - "420d9c06 41c98200 4210334c -> c01e9b27 c00aecd6 bfe178f1 3e834164", - "c2126b6a c16f0f50 423a6c78 -> bfd1dda5 3f90688e bf74eec7 be2fa65e", - "4190e648 41296498 40b244c8 -> 4019d62f 3ea83805 bf484717 3d7ad9d8", - "c1f510d2 413ba5d8 c20a5da4 -> c011b409 3f469f11 c03b340f bef15a1e", - "422fc5d6 c1c738e6 c23db963 -> 4008589d 3f928d65 bf84bf7c bc917e33", - "c1ebecfd 41cfdc58 c1e037c5 -> bf56e7d9 3f9ef23e 400db2c9 be11c87e", - "c2314f50 41ae2120 421b9e68 -> bec21f10 402ba7f7 bfce4123 3f03dbfb", - "c0e07550 41f7fa10 41c1ee2c -> 3fa7688a 403a4f30 3e57b11d 3ec3aab5", - "40d3bd48 41fe2158 421ec3b4 -> 3f8140ed bfe830f5 c00a0f6c bf01ec49", - "4163d668 c1fd7b6a 41654178 -> 4029e64e bffa80e9 3ea36a47 bedd8786", - "c0f527b8 419b0468 41750588 -> 3d308fcc 3f908c35 c0188609 3a154349", - "c10d3de8 41073e88 4066e110 -> 3f1d114e bd0abdfe bd65f7de 3d3b7008", - "420172b0 c1877eae c1c6eb30 -> 3febd92c 403c361c 3fdd8095 bdf37743", - "4244edfc c227cee4 3f8892e0 -> 40110031 402be3f2 3f9d7aba bf10410d", - "410b2edc c2208d97 419ae014 -> 3f2751b9 bcd409df 3fd00bbc 3e02b423", - "419e62e4 c22cd30a 424640ea -> 3f9033cf 3f5e12b2 400c80c0 bd940c94", - "c1902b10 c1e05da8 42003696 -> 3fe9f31e bff392a5 be9dbe8e 3e97fd56", - "c07542c0 c11d65c8 c162157c -> 40361a04 bee37bff bc8c13a7 be2cae62", - "c21e561c c0f2aa80 4230c3f8 -> 3ff1e95f 3ff9f80d 3fc893ea bf04a2c5", - "c218c3cc 40d8e770 4052b7f0 -> 3e7d152a becf5933 3e217f54 be528e2d", - "c22c573b c2388276 c0f74928 -> c0083499 bfc08315 3ea66f58 beef5f06", - "4224f83a 41d8391c 42296742 -> bfa0be54 c03a8416 bfd76290 3b4dba24", - "3dc1f200 40315510 418527d4 -> 40312d8b bf0d0627 be8840d2 be6f6e0a", - "bf84ee80 c13da4b8 c0e293f8 -> bfe9a2f0 c00f5e87 bf376603 3f2bf86f", - "423b59b4 c22e3d4b 415b7dcc -> bd653f3d bfc313d5 3f0ec0f2 bd20ee18", - "c14298b8 420925a0 41a91540 -> 3fc24ca8 be5ee1a1 bf4c0c80 bcf439b0", - "c23478f1 42134638 41c7c76c -> c004cdb2 bfd8abbe bfc79eb6 3eecc8a9", - "422082c8 c18de9c0 4239711e -> 4087fc41 be9a8f3b 3f75ae02 bd578ea4", - "420119ca 4238af36 c1a648b2 -> bf6f10c7 bf032662 3f58764a 3f13db72", - "c1a4727c c199f2bb c207db0e -> bf92fb18 bf0d338c 3fc20459 be189e53", - "4116a864 41a46cf8 41d24778 -> 40537644 bf8689fe 3f1b924c be83d5e0", - "41aebdd4 42294536 c2374c6e -> 3f48c164 3f5d1a92 bf1acd52 3cb6ca3f", - "c224d244 418ba6f8 c189544a -> 3f01a79e 4025e094 be855fca 3f231e68", - "41d81190 c1f25f11 4080bd30 -> be4671b2 3e505614 c0027cb9 3f3d3887", - "c188a5fe 420411ec 42073a5a -> 3cb7dc4d bf3843cc 3f00b5de 3e0ce4f1", - "c12ddbb0 bf2b7880 c1823850 -> bfe66676 bfb425d6 4099ea3e be2f28b9", - "41b13658 41b4a024 41021440 -> bfa049a6 bf457a08 3f91f402 3dd6eeb9", - "c1d78d50 c22c4adb 419fad6c -> be8e2e35 403de25d bfc61038 3e4b02cb", - "41e28f94 c204da03 41ace4d4 -> bef1b49d 3ef66226 40055b7e be927dc1", - "c082d220 c2242190 41f6dab0 -> bfbc80c3 c0302d91 3ea48a34 bf507c23", - "41522e64 c1eacb91 c1dfe2a4 -> 3fefc663 bf02049f 3d6e40f4 be9cfa75", - "3f1bbe00 421e2e74 418cc0ac -> c082200e bfb1d733 3f35c55f 3f1530ab", - "4185138c c1c80a66 c20f8281 -> 3be36ee6 3fcb2d90 3f7b2eef be6b7425" - ] - }, - { - "glsl": "vec4 cultmath_fbm_grad(vec3, int, float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "4118af88 c1a7a7d3 c204addd 00000004 40000000 3f000000 -> 40719fd8 c07c5fe4 40cdafd8 3f2fa97f", - "c13b2cec c1b10373 4188eb80 00000004 40000000 3f000000 -> c01b8792 bcca1a40 3fd8c305 bd01dff0", - "c1e867dd 40e6ae40 bf41b2c0 00000004 40000000 3f000000 -> 40859093 3eb645e8 4031bcaf 3ea94661", - "c215c93b c0db7a50 c04a2e90 00000004 40000000 3f000000 -> bfad7980 be6570c0 3fbfbd6c bed152fa", - "4235f7ce 40e95cb0 4102da44 00000004 40000000 3f000000 -> c0b970ba 3ff679c7 bed54bba be34e22b", - "40fcff18 c15a3cf8 415a055c 00000004 40000000 3f000000 -> 408001b9 c054681a 4098ddce bdc95e37", - "c22eb2fa 422e1720 41cc3e74 00000004 40000000 3f000000 -> 3f4a6a40 40eb7d01 40958799 bf098676", - "c18b7db0 414e2000 4107d430 00000004 40000000 3f000000 -> c015b428 3f3a147f be15d2b4 bf60e2f6", - "3ffd1060 c21082d2 42443640 00000004 40000000 3f000000 -> c02316e0 3f9445ee c088cfa2 bde5275e", - "c18fee12 42013e08 422de378 00000004 40000000 3f000000 -> c0146f0b 402fff82 bf4e169a 3de5674c", - "c20725fc 41b3fe9c c1cd515d 00000004 40000000 3f000000 -> 401d5ef0 c0950cf2 c0b3a0ff 3e061897", - "c1f3334c c21590b5 c0cee030 00000004 40000000 3f000000 -> 40575831 3f977e8d 3f319cc0 bf4be29d", - "c10b344c 420b0494 41e86dbc 00000004 40000000 3f000000 -> 3fad611c 3f0cc06c 3f9f42e2 3efe2f4d", - "c23c9f0a 40ebddc0 411940d8 00000004 40000000 3f000000 -> 3f5aa199 404a04d3 3faa1910 bd181aaa", - "c1dd0d96 c1852212 417d36f0 00000004 40000000 3f000000 -> 3f362bba c08e754b 40447734 3f54611d", - "c17fbefc 418d2798 4155ba88 00000004 40000000 3f000000 -> 4049ff74 bf7e64e8 3ffa7bfa bee55145", - "415d6078 422acf16 404bdb20 00000004 40000000 3f000000 -> bef92570 3e8f33e8 c028dc0e bd67db19", - "c2382102 4124f300 c19438a7 00000004 40000000 3f000000 -> c0cba0f4 4058eaea 3f8cf5bb be9ab9f0", - "c13686e8 c1b82a8d 4181482c 00000004 40000000 3f000000 -> 3ffc488a bff26e29 c0c807bc be3c13ba", - "41057454 42114c42 c20ffee7 00000004 40000000 3f000000 -> c05a9513 405bc594 c0c71330 bf179132", - "41907f00 421bc31a 41c72f7c 00000004 40000000 3f000000 -> c0198ed4 bf4fe6b4 3f03b184 3ee43c08", - "40b8ade0 42395cc0 41a522d0 00000004 40000000 3f000000 -> c0191031 bfbd0bfa c022aec8 3eb86305", - "c1dbf475 41cf22e8 c0aa1db0 00000004 40000000 3f000000 -> 3f824dbc bfab9a6e 3ef38818 3e112a02", - "c20d6d69 c205930b 3fcd85e0 00000004 40000000 3f000000 -> c0ccf921 befcdf1c 3fe48bf5 bfa0173d", - "420a4a7a c23a13ef c15d925c 00000004 40000000 3f000000 -> c0a64506 c05d8974 3f542ee4 3e7cb472", - "c20830fc c21f380d c1a3cdf0 00000004 40000000 3f000000 -> 40d96645 c083e0a4 c00a384b 3ee43020", - "422aa752 c20027be c07169e0 00000004 40000000 3f000000 -> bf8db6a2 c00a9202 bf4bd594 3e8c0d4a", - "c164e18c 419161b8 421e6ef2 00000004 40000000 3f000000 -> 4045d2d2 4020c085 3f91bbea bf27128c", - "c11b68e8 c21704fa c2173d71 00000004 40000000 3f000000 -> c0b56c28 3f0cc1ba 4006c15f befe5ee4", - "422b73a4 41f81028 420e8492 00000004 40000000 3f000000 -> bf5efd39 c088c3ed c09604bc 3c8844c8", - "41daffc8 4203d5d8 4241b850 00000004 40000000 3f000000 -> bfaeb305 40389ec0 bee2f008 bf15cfc6", - "4170d710 c1737a2c 4193713c 00000004 40000000 3f000000 -> 3f1c63f0 4088ed85 c10a832a 3eabd2c1", - "420ab876 4184c6f0 c14fb724 00000004 40000000 3f000000 -> 3ff916f8 bf217280 bfc3449c be7284eb", - "4234bc54 c219f585 42270256 00000004 40000000 3f000000 -> 4015fb41 3f8d22dd bf59552f bdb58c62", - "c1fa9b4f bf4e9e80 41d0c444 00000004 40000000 3f000000 -> c00a4e41 3fa1e8ce 400c3336 bf6f4af1", - "c241ae7d c1f4d6f7 40da8578 00000004 40000000 3f000000 -> c074a8c0 bf9f1082 40aec20b 3e1c7918", - "42354844 c1dae17d c204dd3a 00000004 40000000 3f000000 -> 40104aac c058e102 bfcf37b1 bc3268c5", - "c155d3c4 417ad710 4192e800 00000004 40000000 3f000000 -> 403a735f 410fd4ce 3f8004d2 3d50b7b5", - "418e2f6c c18d103a c1e9db81 00000004 40000000 3f000000 -> c031fc7f 3de98220 bffca1b8 3ed3ed1e", - "420d28cc c20a100a 420861ba 00000004 40000000 3f000000 -> bf531198 406c96dd 40715ee6 bf20476d", - "41073b5c c1a2dbc0 42338960 00000004 40000000 3f000000 -> c02b8f27 3ffcd0a1 3fc9b653 3e835d9a", - "4110dee4 c14bb530 c182d1c6 00000004 40000000 3f000000 -> bf4124fe 3f41071a c07329bd bea20819", - "404b3de0 c1f3d697 41959538 00000004 40000000 3f000000 -> 3f985ae2 c028883f bfe02eff 3b34e866", - "418dc594 c195d2e4 c0ccdc28 00000004 40000000 3f000000 -> bd1f17f0 3f88da62 40b16212 3e9ca913", - "422a06d2 423deafc c22e3239 00000004 40000000 3f000000 -> 4121709c c0eeac6c 4073671a beb4dfd8", - "408f3858 c203eabb c1f82957 00000004 40000000 3f000000 -> bf97e4e3 4093030d 3fe68ad0 bed459b5", - "c211f32f c134aef0 422b6680 00000004 40000000 3f000000 -> c06487b8 3fdde56d bfa77694 bd428a4c", - "40ab8f00 423e2b62 4105e34c 00000004 40000000 3f000000 -> bf148e84 c079808f bf8a8428 3e947796", - "4196c398 c1142cac c202dfec 00000004 40000000 3f000000 -> be05e115 40458a24 bf635592 3e226587", - "c19f775d 423d1e0e c23e566f 00000004 40000000 3f000000 -> 40311fcc bdbbfd90 bff9b814 3d447710", - "c0159a20 42458fa8 3f8e7040 00000004 40000000 3f000000 -> 3f8707c5 403c40fc bf4bc9b4 bddd2048", - "403b07d0 c1544a0c 41fef0b4 00000004 40000000 3f000000 -> bf80aab8 40b921c2 c010f34d bd798ac6", - "423b78f6 4119ea7c c2184d2d 00000004 40000000 3f000000 -> c0a59b02 c0ef19bc 40f0cbd8 3ca26a67", - "c0f1a7e0 bfcc4b60 42477fd0 00000004 40000000 3f000000 -> becf2ea8 40aba947 40061982 be03aca2", - "42188614 c1b3350f 422578b4 00000004 40000000 3f000000 -> c0248df3 3f858698 407fc064 bd267fcd", - "41b97c94 c0bbde10 41919590 00000004 40000000 3f000000 -> 401bf2ed be8c5c28 40ce6776 3db6ee9b", - "413e98e0 c212cf55 c20a9d62 00000004 40000000 3f000000 -> 3c594580 bfab178a 3f97391c be0d5cdc", - "c240d915 41ae37f8 41d63764 00000004 40000000 3f000000 -> 40a66ca2 3fb56885 c0e68c9c 3f0fa1e5", - "4224fb3a c23ba309 c18f3282 00000004 40000000 3f000000 -> c02a3e25 bf83ed6a 40e192f4 3f448b2c", - "c157bdc4 4220d5ec 423a1de0 00000004 40000000 3f000000 -> 3f12f798 3ff2757a beec9920 3eb5740d", - "c20688f6 c1d720e7 c1de12b5 00000004 40000000 3f000000 -> c00550d9 bfc4e2e8 3e302f80 be11fe5f", - "41824214 c1ef8727 c190f237 00000004 40000000 3f000000 -> 3f1208ae 40bc4f34 c0136b24 be0f09b9", - "4229f0fa c126a6b0 412bf604 00000004 40000000 3f000000 -> 3fe53206 c06c7c11 40512de1 bd819439", - "c1cb5527 40f370a8 40ecd528 00000004 40000000 3f000000 -> c05a007e bfe6997f c01ab8eb bee9ecdb", - "c22bc77e 41a88398 4221369e 00000004 40000000 3f000000 -> 400c2720 40709041 c0831561 3eb2edea", - "422be6b2 4189d79c 419f8bd0 00000004 40000000 3f000000 -> 3fea4c43 bff08da0 c0126644 bd97f793", - "4188003c 4236a380 423a7096 00000004 40000000 3f000000 -> c097df29 bd918c20 3ddd7cb0 3e80f152", - "bf6aacc0 41913c34 4207ed64 00000004 40000000 3f000000 -> c0f11604 c008214a bfc3aac2 bedf0ed1", - "421446f2 c0840460 c1b318a5 00000004 40000000 3f000000 -> bfd5acf0 3f5386f8 404a6ee5 3e8ebf6f", - "41c2afa0 413ad50c c182def4 00000004 40000000 3f000000 -> c0f0d5d1 be9a5674 40259f0c bf50948b", - "be6e6500 4125a1a4 419b4964 00000004 40000000 3f000000 -> 408a4fcb c0330540 3fdbc6ac bf0b3479", - "c20a6b0c c1bf580a c1c5a3cf 00000004 40000000 3f000000 -> 4063aacf 406c45ee 3fb4ff38 be30a380", - "41dd1258 c1e135ef c229d6f4 00000004 40000000 3f000000 -> 40aa19e7 40252554 406e4605 bef8862b", - "4117c738 41f59aa4 c235d216 00000004 40000000 3f000000 -> 40792732 c093c2de bde5ac90 bcbc9178", - "c22a32ba c14abcd0 40b614b0 00000004 40000000 3f000000 -> bcaa7340 3e7d263c c0116fe7 3ee9bc36", - "40fe3fc8 4232ee6a c24525d1 00000004 40000000 3f000000 -> 3ed5dba0 40a0e22a bfaea6bc 3e79646d", - "4211e514 42411488 c1623b58 00000004 40000000 3f000000 -> bdebd870 40036744 bff748ea 3ed3cd9b", - "4142835c 419c20e0 4232326e 00000004 40000000 3f000000 -> bf49dbe0 c0f16006 403ba02d beb48569", - "4247ad48 418a4378 409e8b98 00000004 40000000 3f000000 -> c09c8565 403f1cfc 3f47585a 3eb1fad0", - "c13bdafc 41e9b430 41c179f0 00000004 40000000 3f000000 -> 408c5074 bff2ab84 3fe5d98d 3f399d55", - "c236ecc8 c1fecdac 41df4220 00000004 40000000 3f000000 -> 40a2a0b9 bfd0031b 3f5ee21d 3da40a50", - "c1b72609 41c687a0 423d05ac 00000004 40000000 3f000000 -> 401ffa1b 3ff68ae8 40076b12 bc565c2d", - "4217f5f4 4226a38e c0a09170 00000004 40000000 3f000000 -> bfa1aba6 bfb0626a 3ffafcc5 bf70bf4b", - "41702210 c20aa279 c093c9d8 00000004 40000000 3f000000 -> c08a7d8a 3fc712fc 3f957e9e bed44ebc", - "41467370 c229f1b1 c20c29d2 00000004 40000000 3f000000 -> 4062f490 40926930 40464493 3da4bef8", - "422842ae c105dfe0 c1996566 00000004 40000000 3f000000 -> 40641dfe c0eac1d5 3f9309d4 3c9df665", - "c1adaa63 c1a7020c 3f922120 00000004 40000000 3f000000 -> c065905e 3ffcf8f8 405acb78 3ecc9fbf", - "c1b8cd04 421772ba 415682f0 00000004 40000000 3f000000 -> c0181362 c0222401 c02217b9 bedf4af3", - "423f1f5c 421670c4 422357f8 00000004 40000000 3f000000 -> 4040179a 407cbe5f 40850bf7 be50a995", - "41c6e488 c20a1855 410cc8f8 00000004 40000000 3f000000 -> bffa6904 3f80ff5d bf286047 be83b6f7", - "41a2b94c c12a0058 c0eba878 00000004 40000000 3f000000 -> 3e4b1a20 3faf29e9 404b1e70 bdc697bc", - "c18527da 40a6f4b8 4148d0a0 00000004 40000000 3f000000 -> 3e923cdc 3f5e3d25 3f3bc88c 3ea96d78", - "c1bae64d 41f2c094 414833ec 00000004 40000000 3f000000 -> c049d728 c094acf9 3cef2c80 3d9718b8", - "4106f3a8 419fa40c c23bb524 00000004 40000000 3f000000 -> 40483521 bfe30e30 4080fd1b 3ebba8b2", - "40b762f0 c1e446e2 4203b700 00000004 40000000 3f000000 -> 3eebe2aa c02b325f 3e84f150 bea886e6", - "4221ea64 424703fa 41400884 00000004 40000000 3f000000 -> 401150f8 4083b896 be9d66eb 3f3a54bf", - "41ecb880 c2289564 c1c2cc97 00000004 40000000 3f000000 -> bfe46297 405d6788 3eedbb08 bed882e1", - "c1cef7b4 c220218d 3db63a00 00000004 40000000 3f000000 -> 40fd2bac 3e0ca780 3f7771d1 3ef9d618", - "c1d7a821 41daf374 c19db323 00000004 40000000 3f000000 -> bf9f56cd c0831915 3ea59424 bf5f2e51", - "c20dffac c1a564c1 4214d30c 00000004 40000000 3f000000 -> 40d8c056 bfdc0d32 beb1ab6f 3f067dac", - "c22e524c c2137c51 41d177c4 00000004 40000000 3f000000 -> c09570bb be7df6d2 400752ef bf794d32", - "4210bb94 4232abe0 41cfbb38 00000004 40000000 3f000000 -> 3edd5df2 4054651d 402357c4 3e096c9e", - "c23d042c c1a79e70 4012fb90 00000004 40000000 3f000000 -> c057f93d 400fbf1a 406dec40 bf0fd047", - "401a2060 4176d750 41349ef8 00000004 40000000 3f000000 -> 3e23dec8 c0f30289 c07d520c bf5ea7b8", - "419280a4 419edbc8 4112b3d0 00000004 40000000 3f000000 -> 3fb94478 3f6d196c 3f448ca4 3f5faac2", - "bff73a40 41a95a44 41832c58 00000004 40000000 3f000000 -> bfa31237 40738afe bf4a891f 3ecb4754", - "41f3d378 c22acb09 42176cc8 00000004 40000000 3f000000 -> bfa7056c 3fe9ca0e 402301ba 3e85738c", - "c1a95451 42351606 c22982f0 00000004 40000000 3f000000 -> bec2c500 c0872c75 bf4502d6 3ea90351", - "c186ceec c0727800 c1a4bd12 00000004 40000000 3f000000 -> 3fa09c8e bec3cad8 403aced1 3c23b2ac", - "422a2fd2 c21ebfdc 41dec9bc 00000004 40000000 3f000000 -> 408d6b8b c07de6c2 bf9f8508 3e27372e", - "c18de48e c217737a 3f825560 00000004 40000000 3f000000 -> 3df86140 beee4704 4019613e bf6aa720", - "41ca73dc 4000f350 40da72b8 00000004 40000000 3f000000 -> bfa23ed8 bfb4d6a0 3f4b1ff0 3dc2ea29", - "c1b8e20e 419c6190 c1b99ea1 00000004 40000000 3f000000 -> 3f42df94 bfffbde1 c0acc4da bf791707", - "c22c269c 4216ee90 41a5a664 00000004 40000000 3f000000 -> c09495f8 c0a093ee 4021f048 bf0d898a", - "c2212d97 c1b68b8d c0f259c0 00000004 40000000 3f000000 -> c1086ae0 40227204 3e101cc0 3f26dfd4", - "4165c7e0 40ba1ea0 c11e3dc8 00000004 40000000 3f000000 -> 4055a127 40c79e3c 4010cb96 be70886c", - "4223ae2a 41c7cb84 c22f3368 00000004 40000000 3f000000 -> 3f23d258 3fc98b31 bfc15f9e 3e3ceece", - "415e410c c17fa5a0 c1dfceb0 00000004 40000000 3f000000 -> 408b5b1c bf87241a c10e7c50 bf0aa12e", - "42456644 41dcafbc c2009256 00000004 40000000 3f000000 -> 3ee56a40 c0802eec 40d7c7b8 3e6b2318", - "41947da4 404230a0 bfc59420 00000004 40000000 3f000000 -> c02bcd9b 3fda51c4 c04533a8 3f105222", - "c05c3d90 c21f33ff c1fa1eb7 00000004 40000000 3f000000 -> 4080f89a c0131e9c bf8704d9 3f0321ee", - "41c395b4 c1eed768 405294e0 00000004 40000000 3f000000 -> 4021195f 40136d49 407cf0e8 3e9569ae", - "c21eeaee 422c0664 c200a150 00000004 40000000 3f000000 -> 4027d8f9 c052a417 40317586 3e5fa84d", - "c23ea162 c1e69196 c24183a8 00000004 40000000 3f000000 -> c07f15e9 3e5a4752 bf9d635e bf35cda9", - "c1266a0c 41bc20b0 c1f37332 00000004 40000000 3f000000 -> 3f3c07b8 3f8bce9e be546960 be83a783", - "c203666a c1f6f922 4190b794 00000004 40000000 3f000000 -> c09e31c2 401e601c 40148c9e bd234feb", - "41732120 41964d28 422194ac 00000004 40000000 3f000000 -> 3fd443c6 4013fac6 c0cf88d2 3eafa404", - "421d30e8 c2417e56 c16a9674 00000004 40000000 3f000000 -> 3e207870 402e1318 c00d31a9 bdbb0dbd", - "41ad3088 4192faec 41e0ebdc 00000004 40000000 3f000000 -> 3f922eb6 3f9a38ae 3fac4a2e bbbc0d90", - "c1a80bfa 41cfa758 41c36eb0 00000004 40000000 3f000000 -> bfce4a7c 4080b78e c04161ca 3ce6003a", - "c1307d54 41054098 c205f240 00000004 40000000 3f000000 -> bff180c4 c0af54af bd916c58 beabd2f7", - "41e2baa0 412674f0 41dc451c 00000004 40000000 3f000000 -> 40c23a6f 4072fac8 40687514 3df21c59", - "3ffc51c0 c16be1c8 c22bda12 00000004 40000000 3f000000 -> 3f8d4fa0 408b8418 bf15e9b8 bda2a365", - "421c8b7a 4082e720 414cf5c0 00000004 40000000 3f000000 -> 40038344 40199cee c09343dc be50a682", - "c1dddc44 421a4f8a 4072e8c0 00000004 40000000 3f000000 -> be80b60e 40af223a 40866d74 3da6dd9b", - "c235afc0 c1cdaa74 412818fc 00000004 40000000 3f000000 -> 406a31c9 3e280ee4 c038d282 3e31ecc8", - "c23e2dbf 4200ccac 410751b8 00000004 40000000 3f000000 -> bedd0c22 c0566b1a c044be14 3f36da3d", - "be6e2000 c23a8975 4208fc78 00000004 40000000 3f000000 -> 3fbf3ea1 3fcc295e c01dcf8a 3e248dba", - "4100facc 40e859f0 c225b5a9 00000004 40000000 3f000000 -> c09b43aa bfcf26fc 40a4a82e bed50e15", - "42059642 c23ccd6a 3fe2daa0 00000004 40000000 3f000000 -> 409ecc87 c070c2b5 bd979e78 3e90e3eb", - "41c966c0 41fa3620 c203cd47 00000004 40000000 3f000000 -> c04fb496 c0dc085c 3fe7be9e be7649f2", - "c0d2c548 4155f7c8 414d9c3c 00000004 40000000 3f000000 -> c1037971 40057e85 3ef3d382 3e5a0b50", - "420c6e9a 413420b0 c2138ce4 00000004 40000000 3f000000 -> c088a555 3f5ed7fb c025d9ca bec3445f", - "c0fee140 4172dc20 42077be0 00000004 40000000 3f000000 -> c021f18c 4013ccda c01f2bfa bf2c27bb", - "4130d774 41d0799c c20d3652 00000004 40000000 3f000000 -> 403fb850 bf1ead25 40477b20 bd8ce43c", - "c1b35188 41883e14 c213cde1 00000004 40000000 3f000000 -> c0a3199c 3d79f2c0 bf329bd6 3f382e76", - "41fc57ac 41889008 c0bd6a80 00000004 40000000 3f000000 -> 3f0d807b bff37964 c0ae0530 3e779051", - "c2019051 c1bbb07c 422f06fe 00000004 40000000 3f000000 -> 40b6f230 3ee5d398 3d6b0f40 bd9ba618", - "c2081d16 421ccecc 409eccd8 00000004 40000000 3f000000 -> c0979f13 c037a524 c028cc27 3e8feb70", - "c18ddd70 c1edc2c5 c23b6e02 00000004 40000000 3f000000 -> 3fd4e086 40de25a2 3f854129 3e4097d0", - "4197b070 41949898 c18c560e 00000004 40000000 3f000000 -> 40612ddd c0467a52 c0404484 3ef09f0f", - "40a878c0 c21027e7 41b683ac 00000004 40000000 3f000000 -> 40a022a6 bf86d1dc 3f2af90d bda3f56e", - "c087aa50 41e6d50c c1c65cd0 00000004 40000000 3f000000 -> c0043118 c06cd194 bfa0d8af bebaf532", - "4223c77e c1f43cb1 41508a68 00000004 40000000 3f000000 -> 3f27aa97 4091fdc5 40d51226 be6232bf", - "c026cdd0 4126b9a4 c203ea5a 00000004 40000000 3f000000 -> c0b119e0 bfff0bec c01360e1 3e184e49", - "41c4b118 421adc04 c1b58c87 00000004 40000000 3f000000 -> c08f8809 40d1e891 3f815966 be4dfe38", - "419c6594 c19c3114 4220ec34 00000004 40000000 3f000000 -> c06320e9 bfdb9466 bf9a82e2 bf4cd386", - "42361838 c2409595 c16455bc 00000004 40000000 3f000000 -> c0badf42 4005d3ae bf435e81 bef68548", - "c2293bdb 40f21d88 40979a70 00000004 40000000 3f000000 -> 403fe7e4 bf81f5fa 40039980 3e08ef6b", - "c1d5a888 c1b47727 41c15e50 00000004 40000000 3f000000 -> bfd43abe 3fec4ef2 c031176c bd31abe2", - "c228728c 4035d520 c11059c4 00000004 40000000 3f000000 -> 3fd7ee39 3f831058 c02d1fab 3ee650cb", - "c2201ee2 41b89740 423a6abc 00000004 40000000 3f000000 -> 403d69b3 c08612f1 403f262a 3f1290cc", - "3fb4dd00 c230d93c 414192d4 00000004 40000000 3f000000 -> 3c14ba00 c075ecbc bf8f546e 3d92d95c", - "c101e0a0 41fe990c 4218b482 00000004 40000000 3f000000 -> 3ccb6f48 3f8fa07c 3fc8cfd7 3e2a60f3", - "42176086 42226458 c0199a30 00000004 40000000 3f000000 -> 406aa4ce c0493499 3eee6fec 3ee6b58f", - "41f8602c 41a1b918 4180f2b0 00000004 40000000 3f000000 -> 3fe65f43 c0b297b5 bfab0600 beaa4684", - "41d5e2b0 c109d68c c2460d38 00000004 40000000 3f000000 -> beb176f8 c08cee13 bf33b73c 3f02f41b", - "c1b2c043 414b79f8 421f3726 00000004 40000000 3f000000 -> c0b10ba4 bed816e0 409e291c becb6389", - "c2145a36 41bb8000 4185c3c4 00000004 40000000 3f000000 -> bf9c4a61 bf2cecb8 bf215406 3f2b55a3", - "423aea68 c01b50d0 40cca340 00000004 40000000 3f000000 -> 40d1c5ba bc8bd440 bff7a192 be93d41c", - "c1ff62f2 c1dc420b 3fb4c340 00000004 40000000 3f000000 -> c05caeb4 bf714bba bfe86cef 3e8d2a58", - "3f844e20 42043a0a 418508ac 00000004 40000000 3f000000 -> 40b9cd6a bfa66f2a bf2b8808 bf2f85ca", - "c1df8de9 c14937e8 421562c8 00000004 40000000 3f000000 -> c04577be bfbdc990 be0e7480 be390a5e", - "c1ecaa2c c1d69cb4 4203b540 00000004 40000000 3f000000 -> bd8086f0 402d4cf1 40114111 3cd02bb0", - "41735420 c1b2aa1c bfaca200 00000004 40000000 3f000000 -> 40afc6f1 4042d6d0 bf5bc13c bcb18eb4", - "c23fc850 c229484f c21af9ee 00000004 40000000 3f000000 -> c0110866 c0673a80 c06605aa 3de96683", - "42188434 c1bad7e1 42156724 00000004 40000000 3f000000 -> 4089ed3d c0a1cd06 bf9c87bb 3ea51fbd", - "421a79f6 c05c59c0 42103a10 00000004 40000000 3f000000 -> c08d49aa c0081df1 40162dc1 3e242417", - "41bd78bc 41f1db28 42207ed4 00000004 40000000 3f000000 -> bf74a815 3f8ed3be c0b4708a 3e9b6922", - "3f964d00 423c3b52 42468ba2 00000004 40000000 3f000000 -> 4084ec2f 400962c6 c078e719 3e8efeec", - "c1a0ee4a 4095e3f8 41036f44 00000004 40000000 3f000000 -> 40951681 3facc3de c01a73fa 3ea4a62e", - "c2312fb3 c1d18d5e 4115b62c 00000004 40000000 3f000000 -> 3e9b3fd8 4092bc05 3f67cfee bed83eac", - "c153c65c c15307a4 c229d5b1 00000004 40000000 3f000000 -> c05b2e8f 3d14509d 4059cb35 3e0bd33d", - "41f7c40c 410fdc2c c189aaf4 00000004 40000000 3f000000 -> 401e1cec 3f47793e 408bc51a 3df1cd75", - "41e62d24 40ca3370 c1fe4e93 00000004 40000000 3f000000 -> 3f092620 3f9af46e bf83e916 3d5df26b", - "c201c276 41472b60 c16f31d0 00000004 40000000 3f000000 -> 3f199dcc c01b605d 4074a84b bf04f648", - "c10d8f24 c21c91e6 417c2140 00000004 40000000 3f000000 -> 3e603160 bf8310ba be8dce40 3e2c8dca", - "40aede78 c22599cc c1e89238 00000004 40000000 3f000000 -> bf9b9db4 bf87d807 c08652a2 3f2899f3", - "41985a88 c1a456dd 41cf492c 00000004 40000000 3f000000 -> 4018b10b c0a7234a c0850444 bd1780f6", - "4175b028 41dacc24 c23cb38b 00000004 40000000 3f000000 -> 3ff2d00c c09b821a 3fd0031d be344ac8", - "41d40b04 41a70d48 c11a2534 00000004 40000000 3f000000 -> 4014cfe2 c0a0d4b6 3f83ecfe 3f0d149c", - "4216d728 42222210 4193ea4c 00000004 40000000 3f000000 -> 3f147d1a 3fe2c653 bffc01ff 3ecce6b2", - "c1ca4d25 411812e8 c2388e5f 00000004 40000000 3f000000 -> bfe54d34 bfd10a02 c08496d4 bec6f5b3", - "421d2d66 4174a518 41a6f334 00000004 40000000 3f000000 -> 3d53b84e 41049f07 401eb644 be2c7b49", - "c239243c c22b5dd3 418d3a0c 00000004 40000000 3f000000 -> 40aaab74 bfe3daff 4043c14e 3f22cc5a", - "4091e4f8 c2209c9b 4220f3f6 00000004 40000000 3f000000 -> bf33433a 3ede4d68 c08c9ff0 beffef54", - "418ec2b4 40c3f6a8 c200dd43 00000004 40000000 3f000000 -> c0391a89 c02bf3a8 3eb633d0 3effb8a9", - "40a25a40 c21fe9cf 4210cd38 00000004 40000000 3f000000 -> 402c05b2 401a67d1 409094a2 3f043015", - "c180f95c 41c35a18 c07a9b40 00000004 40000000 3f000000 -> 4081f4b7 c0898981 bc144700 3c8b2442", - "c14b6c48 c15573d8 423164c0 00000004 40000000 3f000000 -> 400d50e0 bf9840c1 bf04d676 3e182abb", - "4205c8f4 41ab44c0 41176014 00000004 40000000 3f000000 -> c0d46cda 3ee91cec 400000d5 3ed223a7", - "c2352227 c236237c 42187066 00000004 40000000 3f000000 -> 3dfa72e0 408786de c01963ad 3e281f58", - "4229b3d4 42243f6a 417c9180 00000004 40000000 3f000000 -> 3ed3ac88 3f65e74a c088cb9a be25b176", - "be8e3780 422b641c c23c39e3 00000004 40000000 3f000000 -> 40ccb3fe bf608f7a bf491d78 3ed627dd", - "c1967c2a 3fedda40 c08dd968 00000004 40000000 3f000000 -> 3f0a0c28 400c1864 4092bfe0 bbf7da04", - "42338eb4 3fe00140 c2423bf9 00000004 40000000 3f000000 -> bf9c146b 401fc01b bfd8cadf 3f170f38", - "40519df0 c20e0f5c c1f31da6 00000004 40000000 3f000000 -> 3fec542a bf0c20d2 406c2877 be70629b", - "420eb0a2 423e0ab0 c1e63187 00000004 40000000 3f000000 -> 40809f5c 40d0ae85 402d1f5f 3e0eeaba", - "420c29b8 c1e48b8a 412dc1c8 00000004 40000000 3f000000 -> 409d73d8 40600ced bef043be bef5127b", - "40854bd0 40753d60 c2078afd 00000004 40000000 3f000000 -> 3f9b76c0 4089fee0 bff00e5d 3e8251c3", - "c1dcc24b 4215b480 c1d93c9f 00000004 40000000 3f000000 -> c091b658 c0489ffa c08eae54 be816009", - "c221f31f c2309b90 422f86e8 00000004 40000000 3f000000 -> bfb1d0ea bf6b3701 40bd4849 bdea4120", - "c21a5e6a 4243fdea c23d3a57 00000004 40000000 3f000000 -> 3f74d39c c005729b c054bf5b 3e3aef87", - "41ec593c 4142232c c1f9b809 00000004 40000000 3f000000 -> 3fe5b186 c115e50b 3f2a623c be56dffc", - "c1cc60d3 c1ff046f 41546ae8 00000004 40000000 3f000000 -> c0883b9f 40625177 40d60bb2 3e707c27", - "c20ca360 c1d0ed46 41029d80 00000004 40000000 3f000000 -> c01f4530 400da160 40c948b0 bdd47c44", - "c115de6c c1302d8c c1daa5fd 00000004 40000000 3f000000 -> c003a8ae 40d9ac3a bdfab11c bed9f7f6", - "c0ab6dd8 42080b0e c1de9b34 00000004 40000000 3f000000 -> c082200c 40adcdff 4055275c be1b98b2", - "41c5e724 423f1854 41bf2f60 00000004 40000000 3f000000 -> c013c6df 3ead47b8 3fe8c572 3ea75881", - "c13c3ce0 c1f297be 4204224a 00000004 40000000 3f000000 -> 3fff5bb4 3f1285ea 4030ff34 bf23b822", - "c1b60019 c13bd698 c14c51b0 00000004 40000000 3f000000 -> bfb2f3c4 4080030c bfa66262 3e929c10", - "bea85200 c1b57692 c2325064 00000004 40000000 3f000000 -> bf0bbdb0 bf6e1ac8 c081bcf8 bf0b93f6", - "41f0c8d8 c1e295ec c07f59e0 00000004 40000000 3f000000 -> 3fa8bfb2 c08b97c8 c04a7a67 be928f60", - "3fd7bd80 4205ed1e 40302210 00000004 40000000 3f000000 -> 3ff41792 401f7496 bef7901c 3f00837e", - "4242fe5e 41bdda80 40167d80 00000004 40000000 3f000000 -> c037d40c bf0d7aa3 bf1de4ac 3da10a69", - "c244b2cf 4133842c 41eb19cc 00000004 40000000 3f000000 -> 4073414c be1574b8 c0514736 3d8c033e", - "40fe6410 41a19a30 423e30de 00000004 40000000 3f000000 -> 40b3f9ce 4083b144 be829ff0 3da460fd", - "c23d36ed c211deec c20ca0c8 00000004 40000000 3f000000 -> bf702828 c00bf16e 40d7e71e bf39c340", - "422dc802 41de192c c23a568f 00000004 40000000 3f000000 -> bfc7a19e be334c43 40878c4f be8eb25a", - "c24550b5 c1739ac4 c227b3e4 00000004 40000000 3f000000 -> 406f8c94 3f34e80d 3e10d310 be90d1aa", - "c1f02190 41b9619c 41ea9394 00000004 40000000 3f000000 -> 403b8a2c 40d7221e c044e2b5 3f32b625", - "c1f2b93f 4012caa0 c1d1031c 00000004 40000000 3f000000 -> c0c7f01d bf9b4342 c048dc28 3e3fb926", - "41fc70d0 41c64074 42233912 00000004 40000000 3f000000 -> c01b8cf3 4050a541 c0bbd73b beb25108", - "40fb58f0 c1741f30 c23f2bad 00000004 40000000 3f000000 -> bfbde2a8 3fffd822 3ffa69cd 3eda8773", - "c2176302 421bca7a 40b03be8 00000004 40000000 3f000000 -> c0b97938 bf85f834 3ef97358 3e0b9f76", - "419f55c4 c08360c0 c21ee232 00000004 40000000 3f000000 -> 3f3ff0a2 bfacf4e4 4010d3cc bf401e32", - "419e951c 41bf4cc0 c15722dc 00000004 40000000 3f000000 -> bf1844a6 3e19d438 c0d63b7e be58a62f", - "42320ac8 41f2488c bf063d80 00000004 40000000 3f000000 -> 3fc535c8 c013338f be2cce18 bd85f6e0", - "420df16c c1cb923f c1ca2d76 00000004 40000000 3f000000 -> 408ac5b3 3e8441f8 40fa4668 3d388ede", - "c1dce748 40c73ad8 bee3ef00 00000004 40000000 3f000000 -> 40691798 c0115d22 3f9fbde7 3f01b603", - "c23ff9d6 41eb6a44 42139bbc 00000004 40000000 3f000000 -> 3fa35b05 40e4786f 401dc9f3 bc7c8764", - "c14106ec c1926299 c21ec3ae 00000004 40000000 3f000000 -> 3f9189b1 3f9c4443 3fcefd9e 3e2e873b", - "41bb70b0 41e8b5f8 c1e47ed3 00000004 40000000 3f000000 -> 3f44b784 3f6606ec 4040bb28 bf143734", - "c1ac2d32 c1f5d66c 4211c0d0 00000004 40000000 3f000000 -> c01d338a 3beeb6e0 402dc61c bdf16ca6", - "421a53d6 c2479e9c c168ac70 00000004 40000000 3f000000 -> bff5c5ac 3ff97e63 400fbbd0 3e7890cd", - "42355c8a 42222c16 c1cb52cb 00000004 40000000 3f000000 -> 40d19544 bee3ab6c 3fe68be6 3f3f7bfe", - "41155eec c1d3c5c0 c1910ea5 00000004 40000000 3f000000 -> 406cc4f8 bdd55d70 c01937b2 3f0543f8", - "422c8ba4 c1993686 412dcbb4 00000004 40000000 3f000000 -> 400236fd 3eef459a c0b888c2 3e1da049", - "41ac29a8 c1c43721 422b8c88 00000004 40000000 3f000000 -> c0b0d76a bf875f46 4013d804 bf351afb", - "c1a13a80 c17d382c c1b2146c 00000004 40000000 3f000000 -> 40718e96 bf89f056 4089f4ae 3e36dac0", - "4244952e 4112b02c c1fb8e40 00000004 40000000 3f000000 -> 3f7f446e c084c4f2 bf4f8925 bd0afe96", - "c10bfc40 40bb27a0 40aa1898 00000004 40000000 3f000000 -> bfd3e954 408df202 bf52cec0 3f442fdb", - "c20ac768 41c1bd70 40e7de30 00000004 40000000 3f000000 -> c07fd71b 400312d1 3fb19826 bf7d548b", - "c099a6a0 4239f28a 418671d4 00000004 40000000 3f000000 -> 4010b748 3f00e024 c00f0a1d 3f0a8f0f", - "421b5d38 c10a7b64 40948cb8 00000004 40000000 3f000000 -> 3f8cc813 3fa8381e 3e3cc348 be8b92b0", - "3decf000 c230490e 41f185c4 00000004 40000000 3f000000 -> 3fb30742 bf5d0c18 409c2600 bf38454b" - ] - }, - { - "glsl": "vec4 cultmath_ridged_grad(vec3, int, float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "c20feddb 422094e2 c17fd4d4 00000004 40000000 3f000000 -> 404718ec c0643e2f bf9650f4 3f49a955", - "c2476d55 4150d284 c18a6b8c 00000004 40000000 3f000000 -> 4036f044 40bbbe95 be16d928 3f505676", - "c201408c c2248579 bfb5f360 00000004 40000000 3f000000 -> bf69961b 3dfc4800 bf0881ab 3fcbcabc", - "c1bfae64 418352e4 c22f15bc 00000004 40000000 3f000000 -> bfa88d6e 4011ec01 bfcf15a7 3fb08f7f", - "c2025036 c0cd5348 c0a2b7c0 00000004 40000000 3f000000 -> c0c99f9c c04edc46 c0328d31 3fbc9b67", - "422ecace c1a5578d 4121a2fc 00000004 40000000 3f000000 -> be8f06bf c0457f62 bfdcdf9e 3fc3a10a", - "418f0fe0 c02ad1b0 c0b81c78 00000004 40000000 3f000000 -> 3d94c500 3e0eef46 c035b2e9 3f950bbe", - "41f123a4 41f047e4 c206b2a2 00000004 40000000 3f000000 -> 403a55fa 3ffee79a 4008a70b 3fa2e591", - "418ab5a8 c20f7372 c1b7aad3 00000004 40000000 3f000000 -> 40ecff51 c0a0f518 c0aa61ce 3f83e537", - "4170ff08 c236d194 421e0396 00000004 40000000 3f000000 -> 40e0b8bc bf8ea3ef bf00df14 3fcde1b3", - "c22f1eaa c1e4c34b c1f3a505 00000004 40000000 3f000000 -> 4099b400 3fd94a14 bf2cc80e 3fdd0053", - "c2153659 c208af65 c0bf1760 00000004 40000000 3f000000 -> bfc0c20c 3f456c08 3fff02fa 3f9663f0", - "422eeb00 42440282 4238776a 00000004 40000000 3f000000 -> bf37f62a be699d48 c0c193ae 3fae5c01", - "420f6ea6 c1d37d06 c0415930 00000004 40000000 3f000000 -> 400b8dd0 bf143882 3fa59342 3f937a03", - "c22d0d53 421d0fcc c228caba 00000004 40000000 3f000000 -> bfd7c7c0 c0a12c92 4085e67b 3fc86583", - "3f823060 c1b1c93c 4039cf30 00000004 40000000 3f000000 -> bf54efeb be3a4000 3e9d2b2c 3f654e39", - "c1e0e03b 4234926a c217f313 00000004 40000000 3f000000 -> bfdb47cd c0fb14b1 40b1acc1 3f9180e8", - "423228d8 4200ee8a 41099038 00000004 40000000 3f000000 -> 4015e1c2 3fb5645c bf18329e 3f8aa71e", - "c160e640 c180ff5a c21f8f11 00000004 40000000 3f000000 -> 3f074f29 c04e1852 c02e7c0a 3f88a0ba", - "c2014292 c1899054 bf8afda0 00000004 40000000 3f000000 -> 3f689c00 c0c2c63b 402c2b28 3f860b87", - "c231605c 4027fb00 c235b3e4 00000004 40000000 3f000000 -> 3f89275a c083eae0 40931276 3f89845d", - "4111333c c1f17111 c09fa740 00000004 40000000 3f000000 -> 3f5e3f0a 4052c2fc 4068b892 3f7ecae8", - "4212bcc6 c23519dc c1b1f607 00000004 40000000 3f000000 -> 408e1689 bfdc786e 3f9a9a59 3fa72295", - "c244740d 4247dfce c19d5c92 00000004 40000000 3f000000 -> 4025f679 c01936ce 3f8330b0 3fa5ce9b", - "415fc554 4200194a c1d1dd30 00000004 40000000 3f000000 -> c026c4e8 bf9e1df0 3eb207ac 3fcae4d7", - "423d1204 41bb3e4c 42231428 00000004 40000000 3f000000 -> c0281b72 400d7152 402cff7c 3fa7ac79", - "c225e7e9 c206b6ae 4211712c 00000004 40000000 3f000000 -> bf92e953 3f277f22 4083e796 3fb961e7", - "41c11b48 c0da80f8 c2236400 00000004 40000000 3f000000 -> 402ad6aa c043cc0a bf9535c3 3f97ad98", - "41dbed50 c2194782 c12d40b8 00000004 40000000 3f000000 -> 409f28fe bebd0560 c07dbf2d 3fbcb519", - "412f25c0 41d6066c 41ffa090 00000004 40000000 3f000000 -> bfd0312e c0471400 40e19e88 3fbbbece", - "c180a7b4 41d05b24 41819558 00000004 40000000 3f000000 -> 3fd9cf27 4037754c c01d9cfc 3fdaa9ff", - "c0330a90 41f19e04 41a7839c 00000004 40000000 3f000000 -> 3f9f3593 3f839573 c0462cb1 3fb44252", - "c0f30d80 c015a220 419b90a4 00000004 40000000 3f000000 -> bfc32a9c 3f5c1c60 3e6727e4 3faaf18f", - "414ca8b8 416552f0 c1d79583 00000004 40000000 3f000000 -> c07f94c1 3f6fff3e bf362df9 3f905ad5", - "c1c6d013 c1e7f822 4234b29c 00000004 40000000 3f000000 -> bfae8952 c0e66e2f 3fbbff6b 3fcc2c90", - "41fd766c c19b90fa c2472ac1 00000004 40000000 3f000000 -> 3fd08c2e bf758741 c04febad 3f9c59ac", - "c172b568 c1352e50 412784b8 00000004 40000000 3f000000 -> bf4c7bb2 bfef6c50 406ff99c 3facb390", - "c1f54671 c2235aa9 c206117c 00000004 40000000 3f000000 -> 3fa61001 4067a97e 3e2d1d38 3fa11eec", - "4148db9c c193dc00 c2223031 00000004 40000000 3f000000 -> bf5ac728 bedcb004 40d45cd1 3fa66da4", - "4235b01a 41fcac4c c2277106 00000004 40000000 3f000000 -> 3ffa198d 3f530e12 3efd5c66 3fc7e25c", - "c230a4ba c1c21953 c1b03a24 00000004 40000000 3f000000 -> c07f73a0 bebd8fa8 40578c76 3f866630", - "c0865a58 4187bf9c c1d09b87 00000004 40000000 3f000000 -> 40150a7e 40c3d334 40874532 3f9e2388", - "41621c30 c204de02 c240b5b8 00000004 40000000 3f000000 -> c0178777 bf1edcf6 4043f35e 3fb56dfc", - "4034f9b0 409b9d98 c1c20d74 00000004 40000000 3f000000 -> beacc3dc beef40de 403377a0 3fde5282", - "c1e56857 c08890c8 3ffe92c0 00000004 40000000 3f000000 -> bd4606e8 40124c7e c0b5dbad 3fc7f12f", - "4154efb8 bf814a40 c1dea81b 00000004 40000000 3f000000 -> 4091a7fd 4000cb47 bf2d4a6c 3f757079", - "c210169d 42373b74 41f901f4 00000004 40000000 3f000000 -> c087d3c3 bfc05e52 3fe5db41 3fb065a4", - "c13095b4 c1bf126b c13ec4dc 00000004 40000000 3f000000 -> 3fa4585d 40765fac c041f50f 3f8a6684", - "c1e421ce c20db0a2 41871074 00000004 40000000 3f000000 -> 3fa5540e c02b37aa 3f8a9822 3fb50d57", - "be91ec00 420a9872 bfa85fc0 00000004 40000000 3f000000 -> 41035970 c0a9ff5a bf10f894 3faa5bb4", - "4137c7f8 c0411ca0 41809f70 00000004 40000000 3f000000 -> bfa7bdec 3efe5840 408527d9 3fae2fc8", - "4134e568 40de7748 c1367a6c 00000004 40000000 3f000000 -> c0375c9d 40d98758 bfbe174a 3fe36717", - "42345252 41eac680 40812108 00000004 40000000 3f000000 -> bf42a664 40403bb4 402b7992 3fb285c3", - "41aa00c4 c201cbd6 c210ea7a 00000004 40000000 3f000000 -> c108423e 409d2501 405da022 3fbfac94", - "42418af8 4200030a 420740b8 00000004 40000000 3f000000 -> 3f1512e8 3efcc177 c0841891 3f9e99de", - "c1746060 424010f4 4156ddbc 00000004 40000000 3f000000 -> 402cb948 40862a1e c04cb3bd 3fa6800d", - "4167e7b8 4244faf8 42021c52 00000004 40000000 3f000000 -> c070e14a c09aa2c5 405e44f5 3fcc4b73", - "421523de 41fb8d70 420f1ab2 00000004 40000000 3f000000 -> be0f5f60 40716df4 40442d51 3fcb48f7", - "c1b7e402 41870164 42467c8c 00000004 40000000 3f000000 -> 40165fda 3f4afd8e 409d1224 3f819d7e", - "421f9424 c1cd74c8 40190700 00000004 40000000 3f000000 -> 3f9b7740 3f7af71e 3d9b4f20 3fa30367", - "40e15010 c20e551d c18eece6 00000004 40000000 3f000000 -> c012b794 c02188c5 c0312198 3f9f4bae", - "4048d450 42255d9c c2287a82 00000004 40000000 3f000000 -> c00677e6 404f85aa c05ed7dd 3f81cea8", - "411aa634 412049e8 421b1efe 00000004 40000000 3f000000 -> 3fbaa3b5 bfc1536d c04afeec 3fb91f60", - "c2126ccf 4191d338 419d24d8 00000004 40000000 3f000000 -> 3f230048 be9b267a bf9233bc 3fcc9142", - "41910fa0 c0e8b7f0 41e20e90 00000004 40000000 3f000000 -> be1ff9e0 bfa91b4f bf7f6d92 3fbb3c25", - "418ad6e8 c116c190 c0bc6200 00000004 40000000 3f000000 -> c068af50 3ff8faa7 3fa74cec 3f6bb446", - "40887080 42130730 c205c194 00000004 40000000 3f000000 -> bff6edd2 3eac4f2f beb08e0a 3fa53ee8", - "c23a2f34 420ce23a 420d9d7a 00000004 40000000 3f000000 -> bfe88805 40611a7e 40327597 3f6f5d56", - "41814160 41c19c40 41789df8 00000004 40000000 3f000000 -> beeacfe6 bec90980 be61a874 3fb67f6a", - "41f26a10 c17b5298 42204e36 00000004 40000000 3f000000 -> 409f72c6 4096f7e7 c08b05ed 3f9612d0", - "c1306c98 c23341d3 40a0ed28 00000004 40000000 3f000000 -> bf45fcf4 c075d2be c03249e7 3f8068b4", - "c2416c4e c20f29a1 c23b76b8 00000004 40000000 3f000000 -> 40f28842 c0010de6 c11a2a18 3fcf2c02", - "41fd17f0 c0981270 4222a56e 00000004 40000000 3f000000 -> bf634538 bfb9709e 3e94035f 3f81cb1b", - "41cf7678 41c87cb4 c1400620 00000004 40000000 3f000000 -> c079b4d6 c081efef 40861e3e 3fbe0176", - "41c530e4 3f8cd7a0 c197dd4a 00000004 40000000 3f000000 -> 400f6ebc 40127d4d 40341a19 3f98391d", - "c214761b c1f6c7e9 c1348928 00000004 40000000 3f000000 -> c006c4ef 3e4ae17c 3e61ff20 3fb79df2", - "c229ec96 411a8a28 c1bd9dd4 00000004 40000000 3f000000 -> 400f3009 407b7304 3f402e36 3fcdbce0", - "40b04660 c165e7b4 c1470650 00000004 40000000 3f000000 -> 3e807de4 3fa9d7c8 409a2d42 3f7fbda7", - "c162b7f0 40659360 c1a66eaf 00000004 40000000 3f000000 -> c034b0a0 c0cb209a 402f3794 3fe36f7c", - "c0513ec0 4213ec94 c2037084 00000004 40000000 3f000000 -> c0899395 bf27cf00 c06ced67 3fa3131a", - "c0f51000 41eae90c c1c231c0 00000004 40000000 3f000000 -> c054f570 c110db3d 406033d1 3fbd26a1", - "4242d0c8 41c35cb0 4150adc0 00000004 40000000 3f000000 -> 3f84aedc 3e650d3c c09331a5 3fcc8410", - "c20d8b38 4183e83c c1abdaba 00000004 40000000 3f000000 -> c01bde11 c0950623 be09f2dc 3f78ca20", - "41c8fc00 420edf7c 423551ec 00000004 40000000 3f000000 -> be57da00 bf24b5a0 3f256480 3fc8a2f7", - "405ce520 41e2a5ac c219372a 00000004 40000000 3f000000 -> be396680 bc12f480 3fbd776a 3f8f2e62", - "41e47fe8 c1a98f4a c17e120c 00000004 40000000 3f000000 -> c08e6163 bc0c2580 3f972113 3fe1231f", - "408c60f8 40516cb0 40a190b0 00000004 40000000 3f000000 -> c00fbb8a bf90645c 3ef93224 3fc410d8", - "c1b96c6f 41b6433c 41c511a4 00000004 40000000 3f000000 -> be9d6b70 c04794a9 c09b0317 3f7aaa5f", - "415c7488 4205dc0e 419c7034 00000004 40000000 3f000000 -> c0325f7a c026bba6 3fdd0186 3fa0e373", - "c20220c6 417d06b8 4129f4a4 00000004 40000000 3f000000 -> bfb272b0 c0cfae24 4026fe10 3fd7d982", - "41bf8140 c1718068 41044474 00000004 40000000 3f000000 -> c01ff306 4079577c 3ffac84f 3fcf7f07", - "41bc2be4 c183458a 4236c9d4 00000004 40000000 3f000000 -> 407f5667 c02a0918 405a6f47 3fd3ed5d", - "c216e8a8 41cf8f50 41d570cc 00000004 40000000 3f000000 -> 4061a11c c0257d94 bfe91c78 3f97de98", - "418fcbd4 4241151e 402a7ec0 00000004 40000000 3f000000 -> 40798616 3feeafa4 c0f3b71c 3fbbae09", - "c21f34ed c18cd52e 41bf861c 00000004 40000000 3f000000 -> 3fb3376a 40151f99 bf47b93c 3fa958b0", - "c19841ab c23fc586 40e999e8 00000004 40000000 3f000000 -> c0b238b7 403115ca bfc89626 3fe73142", - "c1c114d5 40e89088 c1c9be4a 00000004 40000000 3f000000 -> 3f9d36f6 3f3c0756 c086c39a 3fa08cc1", - "42344d2c 42295ff6 c182546e 00000004 40000000 3f000000 -> bef84538 405630bc 40810f6f 3fca794e", - "41417598 c209ebc9 c22dad16 00000004 40000000 3f000000 -> 4026c61a c04c0876 bf5f5e1a 3fa7e84b", - "3f8bca00 c1713164 4223d24a 00000004 40000000 3f000000 -> 3fa9fad1 4041700a 409e8c65 3fc53010", - "422df356 423c958e c2454d90 00000004 40000000 3f000000 -> c0848916 c0206c5a 40b8fa10 3f96edbc", - "418f2af4 c243429e 3f4fe580 00000004 40000000 3f000000 -> 40a08673 40a4471e bff21aa8 3fd7296a", - "c14efcc8 41ef70c0 c0a85330 00000004 40000000 3f000000 -> 3f0ee1da c106970c 408125c8 3f498874", - "c20800ff 41825134 40370b10 00000004 40000000 3f000000 -> bf5bd4b5 3fe28ceb 3f2597a8 3fbcbf89", - "40ee18b0 4211a634 40a00d70 00000004 40000000 3f000000 -> 3e83bfc8 c0310f18 40176286 3f978736", - "c23e75d7 c205814a c119cf30 00000004 40000000 3f000000 -> c0473355 c056a1ce 4064108d 3fbb74f9", - "c2453a3e c1898414 41fb4328 00000004 40000000 3f000000 -> 3d585610 402186a4 c05c3380 3fbc1e63", - "c216fb24 422669a4 c225d062 00000004 40000000 3f000000 -> bfd8d0d6 bff55e2c 3ff9a560 3f097b86", - "c1628ec8 41e6e6e8 c0ee0080 00000004 40000000 3f000000 -> bf04423e 40414a20 406644b0 3f91e19c", - "c1cb8959 c21a4774 c1ff6df7 00000004 40000000 3f000000 -> 4053413f bec832b8 3f634b48 3f9441a9", - "421c76ec 4132e424 c10faff4 00000004 40000000 3f000000 -> c059cadc 41138eb0 4078f83e 3fde8a3d", - "420ee61c 41c3e528 c2438072 00000004 40000000 3f000000 -> beec4010 c0bb8377 bf329fda 3fa1717d", - "3ffeafa0 c0f65338 c1964ff2 00000004 40000000 3f000000 -> 400ccb20 3e2c1609 410233c6 3fdb0fb2", - "c1d6f911 422f9e5c c1defbce 00000004 40000000 3f000000 -> bece9af0 c09e7b39 c021a726 3fc43845", - "c215c25c c220896c 4223e976 00000004 40000000 3f000000 -> c04952bf 40cd48cd 3fb5f1d0 3fdcec2b", - "41af6054 c145d7ac c230463e 00000004 40000000 3f000000 -> 40878b96 bf02479f 4068b6c0 3f70887e", - "41e5a838 411b4cf4 42439582 00000004 40000000 3f000000 -> 3f8b39f0 c013059e be3a9f58 3f726e62", - "41818d6c 3ecc4680 c23f8a50 00000004 40000000 3f000000 -> 3fb36ddf 3fc85612 c090d437 3fb12797", - "c221cf4a 41f9dcf4 c231d415 00000004 40000000 3f000000 -> 3f46aa72 c0046a62 3fb509ca 3fd615f4", - "422882d4 c18f8da8 c1dd6c24 00000004 40000000 3f000000 -> c054dc8e 3f18670e 3d977020 3f5fbe2a", - "c2270059 c215fa85 4193ffa8 00000004 40000000 3f000000 -> 3fde0722 c0b0acd4 40a49729 3fa13fda", - "c1baa6d5 c1b8efd3 c233906f 00000004 40000000 3f000000 -> 3fd8dcda c0896764 3f74a1b2 3fc53d99", - "c218a350 41adb9f4 c2184c61 00000004 40000000 3f000000 -> c0a7a1c5 4016b630 bd6b67ac 3f8e7b1d", - "40782200 3eca5680 41c29238 00000004 40000000 3f000000 -> 3f89d28c bf8bfc9a c0629459 3f8b7e84", - "c2234bd4 41dc8498 c1318198 00000004 40000000 3f000000 -> 408e16f4 403bd988 4069407e 3fa16196", - "41147dec 4246c738 41fde620 00000004 40000000 3f000000 -> 3eb8bf67 40426c4e c08916db 3f8cae9c", - "c201b9d8 415eb090 c10c5a84 00000004 40000000 3f000000 -> bfa835de c0234294 404cb694 3fcae572", - "c155e74c c084c640 3fdca9e0 00000004 40000000 3f000000 -> bdc47f08 40acc577 bf865357 3f9cef46", - "c1f698fa c1d89f96 c21cdf84 00000004 40000000 3f000000 -> 3ed9f67a 3f709720 3f2ef514 3fbc7774", - "c13186b8 41d16acc 422d041c 00000004 40000000 3f000000 -> c0ece2d3 beaaec34 c00199b0 3fc1517f", - "423653a2 411dcaa8 c21f0392 00000004 40000000 3f000000 -> bfe1b397 400511b8 c0889788 3fcbf134", - "c22471e7 c20c7c2f 41fb31c8 00000004 40000000 3f000000 -> 3fac0ee0 4003d654 c111646e 3f8410e2", - "40682440 420f910e 4203ee7e 00000004 40000000 3f000000 -> 3fa283e0 be110a88 bee4a9f4 3f87efaf", - "420f79e6 41214de4 417eb468 00000004 40000000 3f000000 -> c04d004a c0143860 c0b147ec 3f9f6110", - "42300624 c1c95c0a c222c16f 00000004 40000000 3f000000 -> bfb1e66c c0e232c9 3ffb5663 3f87444d", - "c1cb6736 40e09448 41b6ac84 00000004 40000000 3f000000 -> 3ea7e8c8 bf87de0a 408f09b8 3fcdd90b", - "41535860 3e889d80 41fc4e80 00000004 40000000 3f000000 -> c031d92e 406c5e3a 3ddb1c70 3f9f518a", - "c1d18e48 41c47958 41911a10 00000004 40000000 3f000000 -> 3f1e5351 400e7fc0 407b2e0b 3fcbd01e", - "41f8c11c 41acf2f4 41853c84 00000004 40000000 3f000000 -> 4008064d 4082d813 40611dbd 3f997aac", - "c204e57a c22a06ee c238281e 00000004 40000000 3f000000 -> 40837ddd c06b0d11 c084d72c 3fc0c0a7", - "42314f16 41b77cbc 42362792 00000004 40000000 3f000000 -> bf9a3613 3f7ed181 4017d6b4 3fb80a43", - "c1faa0f8 4104b9f4 42222204 00000004 40000000 3f000000 -> 408f71b5 bf8e6382 40cb9e7f 3fb3290c", - "416132b8 c246d9ed 414af9e8 00000004 40000000 3f000000 -> 3f4f455d c0652f3c bf4d8ee2 3fba415c", - "40f035b0 c23162c9 c210c9d6 00000004 40000000 3f000000 -> 40037148 3fe84fa2 c00decfc 3fdebf79", - "42430492 c192677b c238a755 00000004 40000000 3f000000 -> 3f40faa2 c082f128 3eca101e 3fa7a972", - "41ca7884 c0ebffb0 c1e7d585 00000004 40000000 3f000000 -> bf8173ac c0488fb2 c0896110 3fc9cb66", - "c0f2ca10 4232671e 417e76b0 00000004 40000000 3f000000 -> 408e3848 40798524 bfd62564 3fb09df2", - "c140d718 41cd9078 c1c0b7a7 00000004 40000000 3f000000 -> bf5b652d 40844dea c0ca92dd 3fd31542", - "c2192326 41ae358c 420d35fc 00000004 40000000 3f000000 -> 3f266f23 c10e78ba bf0b419c 3fac3c1c", - "c0fc84d0 c1b1a4ec c0d7ad40 00000004 40000000 3f000000 -> be729f70 c00b8dfa 3fc6699e 3f6b8564", - "c20d0560 c1526108 41e32ff8 00000004 40000000 3f000000 -> bff58a71 c0305c9f c023b168 3facf8a8", - "41e82d38 42262ad0 4214951c 00000004 40000000 3f000000 -> 403231bc 40c29f8d 40028a36 3f8f7fa2", - "41a30b14 41caad3c 418446fc 00000004 40000000 3f000000 -> bfa3e2b2 3ff651af 4093b872 3fa8a3b0", - "c1f9c6e4 4127fedc 40d763b0 00000004 40000000 3f000000 -> 40b00b87 3e041649 3f8686d8 3f9b96f6", - "c21f6838 c23130a0 c0ac5fe0 00000004 40000000 3f000000 -> bf55e6d8 bf9b0a89 c031f3a2 3f9ac39f", - "418de230 c1c79769 c0e47cb0 00000004 40000000 3f000000 -> bf47071e bee77bc0 409f82f5 3f96e4aa", - "4164d170 c230dbb4 c1a80d23 00000004 40000000 3f000000 -> c07fcdef bfa363a6 403e2046 3facaa86", - "c08bb7d8 41c2e790 c2146e0b 00000004 40000000 3f000000 -> bf6cd0fe c014f588 4091cec9 3fa5edee", - "c13f1728 40cc26d8 423cf622 00000004 40000000 3f000000 -> c0bf8394 bee1acae c025e1db 3fce40ca", - "419d06cc c22c2d56 421213b8 00000004 40000000 3f000000 -> c0b842a2 bf681908 4030d86e 3f86f760", - "c23313fb c1e0456f 41b3f114 00000004 40000000 3f000000 -> 4004a9e6 bff28b87 c07d4cd2 3fd19a53", - "c1f497bb c0e79f48 41966af4 00000004 40000000 3f000000 -> bfc24331 c079fd6a bda58890 3fb3fd5a", - "c1698748 c1f22418 c11d7a38 00000004 40000000 3f000000 -> 40947279 3f1fc022 bf0c1f5c 3fbfb825", - "c2053c71 c2344946 418a52d8 00000004 40000000 3f000000 -> 402dd345 40432d49 c0a8ce5c 3fc775f2", - "408f8df0 c1d2eba1 c17e6264 00000004 40000000 3f000000 -> 40609113 406e766e c10e6be1 3fae3df9", - "c2234ecb c1b19b1a 419ff1b4 00000004 40000000 3f000000 -> c08e0e07 bf31f46d 3e0fd0cc 3fcc4ba1", - "41fa6054 c0c0a1e8 c0519850 00000004 40000000 3f000000 -> be072c78 404c49c5 40a932d6 3fc7d95b", - "c0f1d360 41de7614 c1dfed85 00000004 40000000 3f000000 -> bfd21281 bee67500 c082cf3e 3fc9c76a", - "c20eef17 4198e334 4147cfd4 00000004 40000000 3f000000 -> 3f9daa7a c015c4f4 40976286 3fc7fa83", - "41781820 c1108e68 c16d6828 00000004 40000000 3f000000 -> c064c192 3f98f042 bfb26640 3fdf1bc0", - "421f9efa c244fddd 419307ec 00000004 40000000 3f000000 -> 3f2a7504 bfeaae34 c0e03af5 3f9f02a2", - "41f01f90 c211cf77 c1377648 00000004 40000000 3f000000 -> c04d3265 c058cdaf c084b1d2 3fa93cbb", - "4208f3ec 4222e3a6 414f0d28 00000004 40000000 3f000000 -> 3f7c1a16 40764999 bfed2054 3fbc9f41", - "41ce7d14 c18d5a2e c232b9a9 00000004 40000000 3f000000 -> c0d19af6 c0ebb958 bf3d57e6 3fc08039", - "c23d3108 c018f340 c244926e 00000004 40000000 3f000000 -> 402c348c 401f2984 3fe0eaf2 3fb84158", - "413b4010 42249746 3f3a6640 00000004 40000000 3f000000 -> bcce7980 3f686e30 c0918ed7 3fb83acb", - "41e65518 c1a8edfc c1ab5b30 00000004 40000000 3f000000 -> bfd7dd24 4014db7c bcace5e0 3f7ce58c", - "c1b60570 4219533c 414f9b9c 00000004 40000000 3f000000 -> bf8a2a46 405af386 3ec1639c 3f742a6f", - "c1234b14 414c99c4 c0baee10 00000004 40000000 3f000000 -> c03d1a07 bf06433a 3fc7ba56 3fad8cd9", - "3ef7a580 c2335cc6 41bd34f8 00000004 40000000 3f000000 -> c0b4b824 40a971af bf1bdce0 3fca65d6", - "c22ebe7b 419f3050 41e6231c 00000004 40000000 3f000000 -> bf914dbd c09aa6a8 c0865c7f 3fcaf898", - "c2340484 c1b9b6d4 c2374b69 00000004 40000000 3f000000 -> c0234901 bf0309f0 3f8af55a 3fc7c656", - "4243a576 41c3c3f0 c21fa65a 00000004 40000000 3f000000 -> 3f2f2580 4045cd32 4086f1a8 3f87d35d", - "423644fa c1c88572 c14ec4c8 00000004 40000000 3f000000 -> c02e79c4 3f810a2a 3f72f558 3fb9651c", - "c22bca6f c2320e61 c2196725 00000004 40000000 3f000000 -> bfbc99be bff3090c 3fbafd7c 3fbdd46e", - "c1097f70 c1242590 c19e6b83 00000004 40000000 3f000000 -> 4005ebcf bfce8a17 be855304 3fca1427", - "c1e6c8a8 40240e50 41dfb4ac 00000004 40000000 3f000000 -> 3ff42693 c0844240 402bbd40 3fc03a3b", - "c218f5a5 4212db7a c217ac9c 00000004 40000000 3f000000 -> 3fcaf2b9 bf05bd9f 4006a2e4 3facf540", - "c22dac72 414a86c8 c2165119 00000004 40000000 3f000000 -> c030ff8e 4092ab66 3fb56e01 3fb02cce", - "c23262f2 c11c75d0 3f428600 00000004 40000000 3f000000 -> be889c30 c04779fd 40a37392 3fc71f35", - "42318032 c181f6bc 420e406c 00000004 40000000 3f000000 -> bf20a374 3fcdf12e c0806b68 3f66b710", - "421d28cc 419bfa0c 4146eb04 00000004 40000000 3f000000 -> bfe54590 bf2d24d6 bf14ce88 3fd3af41", - "c1bb966e 423ed37c c1e96792 00000004 40000000 3f000000 -> c050c02e bfd03225 3f3ca737 3f9c7c8d", - "423ab8fa 414caa38 c2054ab2 00000004 40000000 3f000000 -> 3f6c93fc c0a2ae2e c01c7c31 3f87062f", - "c115c030 4204e594 c2383446 00000004 40000000 3f000000 -> bf33278e 3f8b0668 c089e371 3fd8438c", - "4226039a c1ee7091 4203619c 00000004 40000000 3f000000 -> bf9b0298 bf2b7178 bfe8f93f 3fdb4c00", - "3fa9c160 42418d18 c1d7a057 00000004 40000000 3f000000 -> bf92b816 bfa70052 bf002f7c 3f9cb250", - "c2102800 c1a558c1 40262550 00000004 40000000 3f000000 -> 3f9ca51e bf48e824 40146c9d 3fbb5c5f", - "4236c028 4232372a 4204bcae 00000004 40000000 3f000000 -> bf810cac c00e2997 3feebead 3faaa108", - "41857c54 4241a7f0 41620b90 00000004 40000000 3f000000 -> 40401c84 3fa34a2e 4025a531 3fbd1459", - "422705b0 422e0868 c17c0250 00000004 40000000 3f000000 -> c06fe9ab 405fe58b c051a3d3 3fc8491f", - "41153e38 c2433b37 4224b8a6 00000004 40000000 3f000000 -> 403f8abe c00a45dd 3fc2c342 3f95fafd", - "3fc1cc40 c200f33d c1602d98 00000004 40000000 3f000000 -> 3f4a4420 c00e2496 be108b4a 3f8b3b26", - "bf4879c0 c20c94a4 c0fee6f8 00000004 40000000 3f000000 -> bfabb014 3f884cd2 4044a390 3fb485c3", - "c22281f9 c1cc3a9e 421f1658 00000004 40000000 3f000000 -> 400279a0 c05ed5de bf9d8534 3fcc0e75", - "41349418 41a8f4d0 c23a0a1a 00000004 40000000 3f000000 -> 40b6f5ed c061e89c bfffe8ba 3fc31808", - "c2277856 c20bb00c c0f13030 00000004 40000000 3f000000 -> 4047704b 4052d716 406d090b 3fbaff23", - "c1a3656d 40827810 c102aa2c 00000004 40000000 3f000000 -> 3fc0103f c06765ea c0194596 3fbfc04d", - "c1b24b7a 41f35060 c2364efe 00000004 40000000 3f000000 -> c08cceb2 c057c390 bf5381e4 3f068a0a", - "c18843d4 422e68a6 41c78bb8 00000004 40000000 3f000000 -> 3fe133cc 406ec9f8 3d177640 3fb65a26", - "41e9fc28 411dda78 42452b8c 00000004 40000000 3f000000 -> c0cc4987 4011c4cc c011bf86 3fb1e8b0", - "40d64a98 c2344cb5 419a444c 00000004 40000000 3f000000 -> bfa10904 3ef72b24 bf8cc006 3fbc031a", - "4201b5e2 41fa80cc 420020cc 00000004 40000000 3f000000 -> 40faff46 c032144b 3d951890 3fb7d03c", - "c214ecea c1202b24 c23e450c 00000004 40000000 3f000000 -> c0671420 bff998e2 3f28cba8 3fcb860e", - "c0492fd0 c23f900d 420621bc 00000004 40000000 3f000000 -> 3fbe4293 40753ba2 bf55f460 3fba397d", - "41f81968 c235a608 c2348f12 00000004 40000000 3f000000 -> be17535e c0319bad bf9119d1 3f4ebb5c", - "414d2ff4 c179937c c1d4867b 00000004 40000000 3f000000 -> 40b5d676 c0588518 bf9e8d3f 3f91eb4e", - "41ed8d90 4108da04 420557fa 00000004 40000000 3f000000 -> 406cde2b c02f2929 404b7aad 3f9f3c84", - "c1e2ae2a 4142e198 c1291a6c 00000004 40000000 3f000000 -> 40f831a9 bf912122 c050000f 3fcb142e", - "4229a9f8 c1931569 c1e9c6d0 00000004 40000000 3f000000 -> 40924fcc c042d9a5 bf6361ec 3f7c7320", - "421307a2 c1fb9f67 c1ceb7c6 00000004 40000000 3f000000 -> c0328769 c07c5aed 3fe85ece 3fbe731b", - "4130baf8 419fc00c 409fa5e0 00000004 40000000 3f000000 -> c0e2b87a 400333c6 c0deb02b 3fbdb37a", - "c0e84350 402b4b40 c1f3a133 00000004 40000000 3f000000 -> c0c088da 3faa1f96 409c3b2d 3f604c91", - "c1ec179c 41e6de48 421f3a02 00000004 40000000 3f000000 -> 3e8c9ac0 409291e2 bfe46acc 3f7e1fce", - "c1e455ca 42357494 41c8b578 00000004 40000000 3f000000 -> 3fdd36c3 bf225174 40158a26 3fcf425c", - "c11f83e8 4202e048 3ffbe200 00000004 40000000 3f000000 -> 404f4ab4 3fcc27c8 bf89e7a5 3f71b1b3", - "4104cee8 c0532700 41ce9c70 00000004 40000000 3f000000 -> c02120e6 c0f3d537 bf8a7c5c 3fa7e3c8", - "42464014 41a12434 41133614 00000004 40000000 3f000000 -> c0ef075a 3e7314ac bfe23d9d 3faae50b", - "3fc12320 4246374c c242bfe2 00000004 40000000 3f000000 -> bfe26f74 bce73d60 3ebecfd4 3fd379dc", - "c2082c6f c16f7e64 c0e828e0 00000004 40000000 3f000000 -> 40282e88 408777a7 40936413 3f92c1dd", - "c1a12e80 42200bec be9a7280 00000004 40000000 3f000000 -> 40c0bd28 407b36e0 c0106d75 3fa8e4d2", - "413410cc c1bfe91a c1e4762b 00000004 40000000 3f000000 -> 4025e1ca 402f0953 c05d8ad1 3fd286d2", - "41e22db0 420f3e46 c18ee028 00000004 40000000 3f000000 -> c0bb09e8 3fc8a343 bfd4bc8b 3fc1880b", - "c1aba603 c13bab88 3ff4a860 00000004 40000000 3f000000 -> 4026c90c 40755e65 400b8715 3fd42020", - "420d4188 c0f541a8 40b15fe8 00000004 40000000 3f000000 -> 403dd933 3f7468a2 3e47a3a8 3fa4ca6a", - "c182fa80 4103c6b0 415307b0 00000004 40000000 3f000000 -> 4044c306 4075c81d c0abf918 3fbd36dc", - "c22702c2 41fd13cc 41ebb040 00000004 40000000 3f000000 -> bff992d1 bfe7f14f c047dea6 3fbf7bb1", - "4215da56 c17e2708 420ba7bc 00000004 40000000 3f000000 -> bfe700e8 be13d052 4015eb4f 3fce8c04", - "c0a18d08 4214c78e bfcc39a0 00000004 40000000 3f000000 -> bf176118 c07c2786 3fc22330 3fc2e6b2", - "416f5a60 c221da5b 41a35174 00000004 40000000 3f000000 -> 40df6862 bf7de1ce c0b8631f 3fa8ad06", - "406b49e0 c1b9b7f8 c2016bb2 00000004 40000000 3f000000 -> bf2bd234 be25dca0 bfcaf460 3f50dd37", - "41d66904 42228b72 421b6338 00000004 40000000 3f000000 -> 403461cb 4091c421 40574824 3fd78b1a", - "c11e4460 412343a0 419ad244 00000004 40000000 3f000000 -> c0419d36 3f69bcac 403ce78d 3f9a3ad2", - "40695d20 413c20b8 423ba202 00000004 40000000 3f000000 -> c0765c02 bf62eada c0005575 3fad8c53", - "c1f161bb c1a1f28c c226478e 00000004 40000000 3f000000 -> be1f6090 3e69d870 40483bd1 3fb6d51c", - "c1d0ae14 c20f0174 c1b18b63 00000004 40000000 3f000000 -> 3f8b9082 bef81e2c bfde3c5c 3f8ff454", - "c2395e77 c20079a7 c10ae984 00000004 40000000 3f000000 -> be83aac0 bea813c8 3eba41fa 3fe46018", - "c13e0738 c22929ae 40596810 00000004 40000000 3f000000 -> bfdba32e c0923ebb 3f4cfd58 3fbd7121", - "41548b14 c0f38cb0 40bcad78 00000004 40000000 3f000000 -> 3efe8f04 40003dfc c0d01e92 3f9dadf2", - "416c8d80 c206ca2c c132f070 00000004 40000000 3f000000 -> 40857097 4086fb64 3e0bb9c0 3fb837b8", - "41b84d70 c212bfbf 41d23140 00000004 40000000 3f000000 -> c00293cd 3eced468 3f8e9433 3fcfbc48", - "413b9cc8 41c6f0c4 c21a0ee6 00000004 40000000 3f000000 -> c0810aa9 3f9cbb44 40b2931b 3fc26783", - "c17bbc2c c225f2fa 3fd98b40 00000004 40000000 3f000000 -> 40aa14e4 40517f5c 40208d86 3fb2d3f1", - "4185918c 422e13da 424020c6 00000004 40000000 3f000000 -> bf2ad675 c0a6ff98 406ea093 3f82f9ae", - "422f58ca 40933b68 c1f0fc90 00000004 40000000 3f000000 -> 3ee9e5e4 3fbeddc9 bf8e5abf 3f8005fe", - "4202361e 418d1664 c236907d 00000004 40000000 3f000000 -> bff278d5 40806ca4 3ffdd53e 3f9953b4" - ] - }, - { - "glsl": "CultCellular cultmath_cellular(vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "41d3de94 c1e7b52f 41b79204 -> 3e314244 3ef597a3 bf5c3642 3f757ae0 bd81641f bfb3fdd7 3f9c2abc 3ce7f740 3ed72af6", - "c1eb3838 4134d438 42269f4c -> bf319c63 3d2a24e2 bf380ecf 3ee2808e be4dc6dc 3e0146a8 3f9100a5 3f004a00 3eb754c2", - "c1a739ca c209c994 c1f7649c -> 3f64fb87 3e181e95 3ed7eec6 3eeb93f9 bedeb74e bf3e4cf1 bf8a69ee 3d5836a8 3f7f2564", - "4163f730 c211ee42 bfe05f00 -> 3f0e3ea6 bf10a76a bf1c222e 3ece71c4 3da9a5b0 bdf94ac8 3e866772 3ebf84ae 3e82f232", - "c18864ec 41ca9710 c0c32760 -> bf2f9248 bebaeaee bf212bcc 3f543d38 3f97f1a9 3ebddb7c 3fbf57c3 3cb9ff60 3e88e6e2", - "c19bb584 41f4de34 bfc70260 -> 3f5a0da7 3e98c7a7 bedc7bf2 3f06db14 beebb173 3e88d07f 3f9407b7 3e3ae904 3f5be013", - "c1eaed3d 41019fbc 409c72c8 -> 3eb6f1ac bf0fd222 3f3f024c 3f3b0d3f beb0d25d bea5cd0e bf9aed45 3e594768 3f47ee8e", - "423bc758 421e9802 c2310e79 -> 3e85e4c6 be5cb2b1 bf70da39 3e886bf5 3e9115c2 be074899 3e360a88 3ef025f9 3e7ad68c", - "41d0dbec c1509cf0 c1cd1aff -> 3c4d565b be319e99 3f7c1959 3f3eabef bf37def2 3f1c6050 bfc56490 3d00e830 3f7885d9", - "c0d6d930 c0b6d4c0 4046ee60 -> 3eb3ed6a 3e92c309 bf642966 3f27f941 be064387 3e31c2b4 3fe02a12 3b79b000 3f5a48b5", - "c183d66e 41f5d950 41c60670 -> 3f132f6d 3e74a012 bf4854ac 3f462f4c be522012 bf015141 3fd61b5e 3d22ffd0 3e020528", - "3fc4c580 42193416 4235106c -> 3dfb082e be6c99a4 bf77169b 3f01ab95 be446f75 3dbc695c 3ff9fd7c 3b705800 3e82d7de", - "417deb88 401c2d40 4000b340 -> 3f347f2d 3f338d8f 3dd64fa7 3efbd69a bfbed462 be7c9af0 3ea11675 3db7ec40 3f7d6d79", - "420a7954 c18af7d0 411507d4 -> 3f5a8925 be64af66 bef0e957 3ea809f5 bfa94f86 bef6843b bd7c81a8 3ebe8afb 3ea6591e", - "4229a368 41a02650 4233fb48 -> 3e14c2a2 3f75b1af be762a21 3f5667c5 bdc0f380 bfe8be54 be8a1dec 3d2b5550 3f0139db", - "c23a30ae c182098a c1fe6f5f -> bf7ccdc5 3c4ee3a7 3e20c9af 3e9b22d9 3fd2edf8 bf0abade bf309120 3ef81a03 3e40bb6c", - "40842d90 4154ce34 41bff0a4 -> 3eed729e 3f3bcf86 befe4e2f 3f4573da becfd657 3e850122 3f187c70 3db3e038 3f14a8d4", - "41ab7398 413eb2f0 c221dcbd -> 3f08761d bf542d92 3e2e1dde 3ee33147 bfb63922 3fa38e31 be78e03b 3d9f67e4 3f06486c", - "bf07b580 41ec4fe4 c194e532 -> 3f54d41c 3f090e19 3e18a039 3ee033ac bfe286f9 bf1c0e7f 3e41022f 3ec58d96 3dab4668", - "4189aef4 c0b05090 c1cd476e -> 3f210e54 3e40e71c bf410ec2 3f0fab11 bfbe4873 3ea21f58 3f5a4810 3dc7f910 3d9bb8d0", - "418a5998 420f3e40 41aa2208 -> 3eb2e919 3f6c7ac2 be208f05 3f3d4934 bcb97f30 be66f89c 3f4b3496 3e30f084 3e0f9c6c", - "417f7b30 c19a2dfa c189b5d2 -> 3f57634b 3de8163b 3f074958 3ee43994 beb8670c 3db53425 bfb0d600 3ec6aa84 3f08faad", - "41bbf3a0 41fb4ebc 42141772 -> bd414e31 3eb451bb 3f6f4b14 3f5a318d 3e0cbb33 bead2a57 bff71ca3 3cccf560 3f26dad9", - "bfaeab00 416aa968 c1aea773 -> bf0237df 3cd17cde 3f5c4f46 3ed7189a bebe658c 3e22b9d7 bed9137c 3dd3e1f0 3f2778e1", - "4239bcba c15fbfcc c1c43850 -> 3f353c78 3f3212f2 3dfa526c 3eb7d9ea be9bbf70 bfc6c8c4 3e49a08e 3e803122 3eb577dc", - "42364c66 c235dc10 c1f2f650 -> 3ea7f9ec 3e06ec09 bf6f7772 3ec331ba bf525f36 beadb1fc 3dba2568 3ecae102 3e1cad40", - "c21d09c1 41b53d48 c23b2277 -> bdc30b22 bf3f83e3 bf281e1a 3f26dd88 be4ae32b 3fc889a0 3e26d186 3db339c0 3e163378", - "c22f55d0 421c9f28 41f7e3b8 -> bf150a41 3f054b9d bf1fdc50 3f5632fa be8d1988 bd7d3f70 3f5b2baf 3cb00160 3ec73376", - "41e8ed24 41416bf8 c1f9802c -> bc17c03c 3f62a3e6 3eee07b2 3f1a3337 3f357c8f bf1fb22a bf909d0f 3c7ee6c0 3e84cf06", - "41737fd0 c23fbafe c224f3db -> be991ef1 bf650646 3ea9f7d1 3ecd2b02 3fa62483 3f5b0e72 be9d1770 3ee61f26 3f092173", - "415e0c10 4242a368 c228331b -> bf36aa62 3ebc02a2 3f18bfce 3f35c7ab 3faf2c38 3daf5244 3c072780 3e1a7388 3f40a45e", - "c1b2a22a c202b376 c04ba280 -> bf164455 3f36bad8 3ec39bbf 3f001d88 3f2f4dac bfa3059d bf9a392e 3eda938c 3e9e86fc", - "421830f0 c1bc76c9 c12b5768 -> bef6b801 3cb1b0e0 3f603fc1 3ed93b2c 3f9b7afb be0ad3e4 bfc5fd86 3dbce740 3f3754ac", - "414358c4 c1a054fc 40153de0 -> bf092bc0 bf0add9f 3f25a3ba 3f672f0d 3d8d98fc 3fa9f79a bf86dcf2 3d93b168 3ee7204c", - "c1969e44 c23204f7 42428932 -> be93c075 3d415e0e 3f74cf8b 3f1692cf bd5de438 3e153c20 bff016a1 3d389240 3ee65932", - "c0859f98 41c7fa24 c1c0c6a1 -> 3eac3cc8 3f62d84f 3ea33aa3 3ef81a2f bebc4767 bfdbd254 3e71e34a 3e6c1972 3f242b60", - "42083f6c 40794c50 41c80800 -> 3eb5fcc9 bf4a3178 beffec17 3ed12844 bf73c102 3fc160d5 3e17078c 3eb07348 3e4c5050", - "c218f770 40cf09d8 41aeae94 -> 3d8fb200 be9b6205 bf734399 3e775b52 3f2400fa 3c43ab20 3fcb917d 3f16e4a8 3f4258c2", - "c1e70281 41320a6c 423a9f18 -> 3e80567b 3f211c3c bf3c5027 3e81b85b 3f232624 befc8013 3f966302 3f193778 3f501626", - "42211f2a 4213683a 41951c08 -> bf291d1f 3f25cf7d 3ec25abb 3f2523ec 3fc113ea bf053e62 3e0a721a 3cd7d500 3e375c80", - "c2101ad3 c226e625 41eac4b8 -> 3f6e0ca8 be1c3f84 beab60d4 3ee4059f bfdb4118 3e84675b be8e68a6 3ea00acf 3f198225", - "41e21698 420b07a4 41800de8 -> 3e303564 3ec96bb1 3f6732de 3f3c3e2b 3f2e394c be7a24a7 bece012a 3e9004ae 3d15e5c0", - "c1ee413f 41961b9c c1fa78f9 -> 3f2f3070 bf287b59 3ea0bb22 3f092994 bfcc70fa 3ee3c61c 3d0c1bb0 3cb16240 3ec111d6", - "41e53c00 c229e48b 41e0bea8 -> 3f4a530d 3f178e89 3e218f8e 3f1ca33e bf6bb3b0 bfc6143e bed84f90 3da074b8 3f04a2b1", - "41f2b564 bfbbfe40 c0e9b6f8 -> bdd8be7d bf2c42fa bf3b6ca5 3e9cf594 3f8bc3b4 3f0e4d24 3f1d2f18 3f281bd2 3ed2fb68", - "3f626b00 41c7f2a4 4206a420 -> 3f43bfc6 bed31c46 3efd95d8 3eefb7d7 bf30be0a 3fb45f78 bf060968 3f01610e 3f4b1e78", - "420168aa c185aaf6 42145dec -> bf7a95bf be1ba749 3e0c3997 3f02cc06 3f3edb12 bf133ce8 3f02383c 3e99d906 3f629c09", - "422ba33a 41f94110 bfe9f860 -> bf7024ad 3e9726a6 be39b644 3f6b9e65 3fa182f6 bf504c76 bf1c2f04 3b7f7000 3ecacd44", - "c181efb6 4007a760 c0f9eea8 -> bf202e23 3f446dad 3e0fe604 3ec0d2cc 3f8da9fe bf6f610c 3f384fac 3eac8c66 3f451c49", - "c15e2994 c22dcfd5 40c64f78 -> bdc008b9 bf118853 bf513ca5 3f3df35f bf2ed3a8 bd737fe0 3f5def8d 3e421000 3f717ea2", - "3e26c100 423f11c6 c1268e78 -> bf1b9ed7 be1b5fcc 3f4785e7 3e9d69dc 3f9a766e bef45d2c be913d5f 3e8af708 3f7cabc3", - "41a53844 bfe1df80 c1e288b1 -> 3d084a06 befdc654 3f5e2d8d 3dba6d5a bd8c220c 3fa43e54 bfbdd960 3ec53cec 3f72281c", - "41b7e304 403a5910 c1ea1936 -> beaf970a 3f6f9fc7 3da1a712 3ee4bcc6 3f868585 bfae4723 3ef829ae 3e9aeb42 3f719645", - "c18afb84 c1c326a6 c22f10bc -> bd558ac2 3f18b0fa bf4d0b63 3ef2e4c6 3f0c1857 bf9b3588 3fb4eed8 3eb34a48 3e5d8678", - "c22b26d4 c2325e95 c0686b00 -> bf500699 3e4993c5 3f0c6f17 3ec17453 3e6b1374 3ef04e8c bdab1b08 3ed2df51 3f789f87", - "423ba4ae c194a445 c2283ed2 -> be4a2740 3e85fd1a bf71dac6 3f236ba7 3f92fc74 bec62be5 3f9d2461 3e84baae 3f06137b", - "c1a6e3ae 41a1ea28 42108948 -> 3e89acd0 bf6311ec 3ec036ec 3eb97af1 3d3ce870 3f2cfdc1 bfa67d40 3f052d90 3f183004", - "c2140509 c2284980 4063db40 -> 3f65b8c9 3e80a5e7 beb9c17e 3eef0237 bf2bb5e6 bf7b3550 be905d80 3e94c2c5 3f349712", - "41fc6030 c1e77c1c c1b70d5d -> 3e4aba11 3ee85edb 3f5e6a31 3f1292f8 be0994c4 3e1418fa bfd56dfe 3d2cfc10 3e95f736", - "c1969bc1 c0afe6c0 c18ae5a2 -> 3e529c28 bf167abc 3f484c86 3f1f0a59 bf63c385 3f8411fe bfae3b86 3d168800 3d8a9e10", - "c1d1766f 420869c6 4143768c -> 3f558579 3f00cd9c 3e67aaf4 3f102aeb bfaa1b7b 3e33e638 bf44ca81 3e615a4c 3d570d30", - "4147e650 c1ac1181 c220f652 -> 3d4d1338 beab1157 3f70f28c 3f1846a4 3f5d67ae 3e35e3d3 bf11b498 3ea0275c 3eb76474", - "c137f438 c2214170 c246d0f6 -> 3da5ad83 3f0da90b bf54399b 3ec7a586 3e2bb9dc bf239efe 3fe59b62 3d68d208 3e68c048", - "c1e7e50c 41df3054 c1df587d -> be43549c 3f3e31a5 bf243fad 3f255bb3 bd812740 bf948e6c be6c6138 3d4bc750 3e9dc7bc", - "414ec2f0 be8cca80 c2294228 -> bf52c00b be4bd1c4 bf081a51 3e9529ba 3f0153f4 bdd4984c bebbc684 3e3c4e9e 3eaefb50", - "41f6dd50 420eca10 41cdfe3c -> 3e264558 3f49ff05 3f17ad1b 3f40525c bf1f014b bfd69f44 bf21d07c 3cfcc3c0 3e2760bc", - "c240c913 c1527220 c1ea66d1 -> bf77d75c be800f6b bc52e278 3f319d1b 3ff77824 3efbe344 3de5a0ca 3db60fd8 3f55ce3b", - "c17bfc0c c22c188e c15b13a0 -> bf4d067c 3e176d3f bf148d20 3f19c1ed 3fc1cd50 bd8c589c bdedef08 3cea9400 3f2d32f6", - "41a08150 c14d50dc 421f5b46 -> bf6624ce 3edefcca 3d3ca10c 3f455c62 3fd1ecff bf7c4e11 3ead97ce 3d642650 3ea5a4e6", - "42101eae 421c6c08 c1b6a1dc -> 3eb281f0 3f612321 3ea5ed7d 3ea98441 3e6e027c bfd014c0 3a521200 3f1d7ed6 3ef56e3a", - "42324256 c1030278 c2265d97 -> bf45a02e 3ef15cfb 3eda5237 3ee137fb be61d1a8 bee09adc bf0b4f0f 3dbf101c 3e475734", - "42186636 c224c28a c107f464 -> bedea61f 3ee26133 3f48d35b 3f17faac 3faedec5 bda90fb0 bf57a28d 3e818020 3f44da1f", - "c0bf72f8 c0a90340 41d75458 -> 3f55f9d2 bf073510 be1953be 3f378c7a bfbea82a 3f4abd9e 3f5beaca 3e68ac30 3f27fe63", - "c1564174 410686ec c1e22166 -> bf24fcb4 3f3cd825 3e4e0828 3f239123 3f8f2c8b bf0a2016 bf879104 3c133b00 3ead7cd8", - "c2296ddb c2277f51 42295ce8 -> bf56d1f3 3f0a6940 bd73013c 3f0f1781 3f91187c bfb38bd5 beb4dbc0 3e566b40 3f73123f", - "4160d618 3d947600 41034050 -> 3f5c3ccf 3ebfdd45 beb0f507 3e3cc1f0 bf0db192 bf798f74 3f8acc3b 3dc529dc 3f404110", - "c0840120 c2453e8e c16a2074 -> 3eb4cb9d 3f2609a5 bf2c9d4c 3f5581dc bf376206 bfca04f0 3f1cf39e 3cb73ca0 3e8b6564", - "3faf4640 c1a5099a c2296051 -> be8d5bbb 3f1103f0 bf46c613 3ef2807a 3f7235ce bf87e236 3faa2e42 3de5a8c0 3f2c12c2", - "c2183f68 421e43cc 41d904a8 -> 3f1cb952 3f3617b3 beb0d0b8 3f198932 bf9e8866 bec643a2 beba31e4 3e584070 3d1e67a0", - "c1c0bae9 4229b8ec 42254b76 -> bf6e14e2 3e97cc4c 3e5e70f6 3f330a60 3fe4766c bf483f97 becc9de0 3ea4283c 3dedc1d0", - "c1f0a334 401e4450 c1eb5af1 -> 3f2a8da8 bf3c548f bdfa5835 3e8b3b6b bfb5ae38 3ea167b8 bec4782f 3e0edebc 3ee5c8ae", - "41b8fff0 c1bc69ba c15e9cdc -> bf7b43ae 3d896881 be379df4 3f0531c2 3ff023c1 be17a68c be853558 3e5053b4 3e46a980", - "c2114ea8 41c6950c c1115c2c -> 3d7ba4e3 3f7f4fcb bd239f1c 3cf21ea7 3eca2b99 bff15f5c bc272a90 3f575d73 3ddeeba8", - "418175e0 c1528be8 c1105624 -> 3f4ca097 3d08b1a1 3f1997b2 3f37cc2d bf32dc30 3ecf8c91 bfbf184e 3e03a5fc 3cbcb120", - "424354f2 41731d28 41e3837c -> bf661ca2 be80af76 beb7c9e0 3f0244ee 3f4a96aa 3f98557c 3d018590 3da45048 3f46ec45", - "4243dd4a c1bb2250 424366c2 -> 3f3791f1 3f31a52d 3d85ea34 3f17e709 3e5759c8 bf25da3d bedf941c 3e826cbc 3f06e1c1", - "c0c10e90 c22ff4e0 4214618e -> bdd014eb 3f6bfa9f bebf8e40 3f0c98a1 bf1f6ee0 bf06ff2f 3f708451 3d97b178 3ee22b14", - "c192e99b c11d84bc 4219aa98 -> 3ebc20fb 3f12ef43 bf3b584b 3f4e02ab bb668980 bfb7e85e 3f8a9581 3e07e970 3f0dc38e", - "42273730 c0d9bee0 c2163bd1 -> be25b83d 3db70fc9 3f7b963c 3eedeb7a beccb8dc bf079472 bfd77573 3e8b8b76 3e3cff7c", - "c244fd46 41d14b3c c1f60cab -> be659d21 bf417882 bf1d82fc 3f02742f bf104806 3f8dd61c 3f8f6a0c 3da5e900 3f73fd77", - "41660250 c1ff21d5 40126aa0 -> beb07456 be023f1b bf6e19a7 3f3b7c9e be9a743a 3f56799d 3f9aa57e 3e346638 3e11d6c0", - "420e5eb6 c2053ec4 c230428a -> 3d6a3b56 3f008501 3f5ceacd 3f095e43 3eb4ea12 3d295e80 bfcc3002 3e8bbfaa 3f0c019c", - "c243633b c177b74c 41fd6b18 -> bf733f61 bd1b92cc 3e9e6493 3eb48839 3ef0d753 bf51de34 bdffdbb4 3eba3a43 3ef4a980", - "40c82100 3ec21780 41c9ff68 -> 3e325e32 bf3a3351 3f29eea4 3f03600d 3e8e2f51 3f2db679 3e686304 3e0d2250 3e5c1e4c", - "c202d8e0 41ed89d8 415d91b0 -> 3f38fc61 3c925255 bf30e7a4 3f0472ae bf9f5a3a bdd3bb0f 3fc50d6f 3e482a00 3f2afd18", - "42318d6c 40225410 4162cfa8 -> 3f30ad2d beebad72 bf0ef3de 3e858786 bf748676 bdd8a618 3fab63c6 3ea454e2 3f7e613b", - "c1a6441e c2141cb2 414f53d0 -> bde20fac 3f7a3041 3e392e0f 3ef75044 3e0e3532 bf20b421 bf8f0479 3dfbb728 3f54f591", - "41e23720 41ff88b8 4211adcc -> bf50246d 3f006055 be976c8f 3f49686c 3fa3d5f6 bf6e34ca bef47c5b 3c3bdcc0 3f75ce00", - "c2371619 42192334 c216ba8d -> bd8a0d6a beb5f932 bf6ea983 3f3673d5 3ecb19e6 3f9b6294 3fa9a4ff 3d5dabc0 3e9dc762", - "c18eb01e 41fa9190 420502fe -> bf61f1f9 beef908e 3d3b3ef6 3f2fc4d2 3f26a7a0 3d9c7750 3f584774 3e84af50 3d8d6088", - "c1d2d6cc c2145162 4242a4e8 -> bec7be28 bf677da6 be31b4a0 3f1254fa bdb47744 3fe41e51 3e19a34b 3d2a4540 3eed377c", - "c1e2a16a c240c5a2 c1fa241e -> 3f2eb528 3e45c941 3f347783 3ec5e68f bf3fe37d bf6cf31f bce0ade0 3ed3fc5d 3f523b37", - "421ac3cc c21309c4 bfbf3e40 -> bf265cdd 3ebf3104 bf2978ef 3f1a89ef 3f0e8d36 bfaea716 3f41f9f3 3da0c458 3e7771b8", - "41b40890 423f4084 42285caa -> 3f5ce620 3e348326 bef28349 3f2322bd bfbb6b34 3e6c2918 be5b1c02 3e1bb040 3f4793b3", - "c2034eca 4216da0e 40b43790 -> 3f4a258c bf165a01 be35dcda 3f4c920e bf92425d 3d0761c0 3f6e6ea8 3dbe3348 3f66e42c", - "c2189e28 c20e9bed 41276798 -> 3e601a04 bf714808 3e815012 3f074e00 bf6f32a5 3f766652 bf736c67 3e604484 3e8b01a6", - "c1cb73a8 423da9c2 4222a2e4 -> bf191fb6 bf4cd801 bd351b26 3f0e9183 3f9f1086 3f96f519 3f354785 3eb1a096 3f621288", - "bfddf760 41ac4990 41530940 -> 3f783428 bd60799c be746daa 3de6f056 3c0473c0 be09919a 3ea9505c 3f081c17 3dca6060", - "40c925b0 42106502 c15d5520 -> 3ef5f639 bf5c6448 3e2b8ae0 3e8fd48c bf972c17 3eaf8d58 3ea572bd 3e5a1fd8 3da6bb48", - "417de378 41fae9a0 c1acc3ee -> 3f74f880 be5fb276 3e43ded2 3eb7ac27 bf396b88 3ee88606 3f409686 3e707a56 3f216c90", - "422e7802 4197e9a8 404c9650 -> bf35a27a bddcb381 bf3247b0 3ec88aeb 3f9e0eae 3f3aca48 3deccd50 3de8d694 3f423b18", - "4241b28c c18b20f4 c148a9bc -> 3e29d0ee 3f6068d2 3ee74adf 3f311ef9 3e189a3c bfe874bd bea215d5 3c8bbbe0 3f28546f", - "41d4b598 423677d4 41df151c -> beb4887c be5c5c55 bf692329 3edc89d8 bed9b7e2 3f57d1ea 3f620140 3d8bef24 3f0b1ae0", - "c09c4c30 c2313661 c12b43f0 -> bf6c3ad6 3eb5ce08 be194502 3f01475d 3f1490ba be8d4a6c 3f8afe16 3e2ee420 3f64dfec", - "c2095224 40d6cd40 c20b5d37 -> 3eee8392 3eb15259 bf507432 3f0435d6 bd9e3d80 bf7b31f8 3fbdb354 3e18be70 3f14b959", - "41a6f090 4131a96c 4230ea50 -> bf1e8982 bec5a9e5 bf2f06c3 3ec4531d 3ea3eec4 3f2c2acc be67f1c8 3e844c9f 3f273541", - "c199b24a 4229880e 41bf7e40 -> bd87f60d 3e03ead1 3f7d4c1d 3ef05ce0 bf00224e 3f1f2175 bfaa24c9 3eaa3ae8 3f03055b", - "3fed7180 c2299e3b 42079f06 -> bf0260cf bea07f30 3f4d2d64 3f01cb39 3fa661a5 be28de64 bed69d23 3e8f0d4c 3ea9625a", - "422a601c 41cb08a8 c109d8ac -> 3f69af1e 3d2006c9 bed01cde 3f42648f bfa2e66e 3f46ea1b 3f5bd5ba 3c0cb680 3f28ac89", - "c16875a0 41762a50 c2092aa4 -> 3f2afe95 3eef2fc9 3f144e0b 3ea82d5f bf4cb37a 3e813021 3dd22038 3edaa281 3f0d1858", - "4202433a c1d96a20 c190fd27 -> bea74d6b be4546e4 3f6cde03 3efbfb17 3e88f873 bf32b138 bef2f021 3e1cba8e 3f101cea", - "c1ef2ff7 41e7188c c1a9689f -> 3f6d3698 3ebed780 3d4ad69a 3e8e7554 bf6ccf60 bfae232e 3ddaa785 3ed60f4e 3ee3a63c", - "c131b2e8 c1fa02ad 40a35440 -> 3f08debc 3f0d3fbc 3f23dd1e 3f1ea8a0 bf9e8824 bfa036ad bf42df0d 3dfe5be8 3f1a49c5", - "c1fe9d3e c16be3d0 c1fa2784 -> 3e5350a2 3f726180 3e7ce041 3f01eadd bf140fe4 bfbfe4f6 3eff81b4 3dd07d98 3f79ac76", - "42024f5a 41eb9f64 4226e024 -> 3e1f9cc1 3f299601 3f3b932d 3f1178a2 3e322d63 3e4d91c8 bf8eb578 3e23aafc 3ec66f04", - "3fae7bc0 c18b3b2e c20cb4e0 -> bf21e897 3e648112 3f3de3db 3f148f45 3f9c3cb0 be42c5e3 3d87d580 3e479124 3d9d40f8", - "bffc0f00 420dac6e c1c80ab0 -> bde6ae51 bf0e95e1 bf52a6b5 3e91a55f bf22761e 3f995cd8 3f7f5eac 3ef98c27 3f297cdb", - "c100fe5c c16eb7f8 421becc2 -> 3d07796d bcea1180 3f7fc15e 3ebd42ce bf3977d1 3f05e12d bfc34f22 3dbb78a0 3e2c285c", - "408ef738 c103ce28 41364c3c -> bf753dbd be526f98 be4cf0ff 3f0d69e2 3f52575c bef51064 bf042fc8 3d8df7d8 3f37a3c4", - "419a54bc c230ad8f 40e75988 -> bf0fef56 be201065 bf4fe35a 3f2df493 3fb55966 bdb1dae0 3fa2b04c 3dd32478 3f3512f2", - "42384bba c10e1f2c c19e257e -> bf3823e3 3f2fb13f 3ddca153 3f18f06f 3f05f16a bf97dea5 bf737ef1 3d3ea6e0 3ec0dc74", - "4142d4c8 4148cd08 42037eae -> beeeaf2f bf15e29a 3f29c9aa 3f143261 bd8a7d54 bdd7f1c8 bf934bb4 3df80da0 3e9df6cc", - "c22a5268 423645d8 41de9ac4 -> 3efb3ce9 bdb6a1c9 bf5de395 3f0ee372 bf191435 3f3aa8ce 3fd05664 3e807664 3ce2cc00", - "42115718 c19035fb c0f4a278 -> bd2895d4 bdfcb7ae 3f7dd32b 3f159f22 bf52997d 3f1b4df9 bf595d16 3d01db60 3f100061", - "c12e00e0 c2158a86 40e40810 -> 3f1bdd19 bf0b2a90 bf13e725 3f30f93c bee76cd2 bec1e392 3f6e526c 3e716e74 3f751430", - "40a69720 419a3868 c1aedbd9 -> 3ca6aff5 bf0eb670 bf547765 3f3a60ff 3eebedf7 3eeff857 bd2ccb00 3e57cde8 3f6bcb27", - "4228bee2 c10c4f0c c0e6f0a8 -> bf3334e9 3f1a543d 3ec3feb3 3f01d49e 3f357117 bf8b8dc0 3efb0bbd 3e8f7528 3f537bc2", - "c1bb8295 4215c312 41efbc4c -> 3f2f7c7a 3f1850c9 3ed6da94 3eb00d61 bfbd8100 bd7ed5a0 be04b470 3e76d6de 3f01b028", - "4222dab2 c115f4c0 4216f8ec -> 3e33b105 be6626bd bf755f2f 3f045683 3f2e64f6 3f1719a1 3fa94651 3e3ab620 3e744a98", - "c0e35aa0 417a2470 c14e00c0 -> 3f39100f 3f0e0eb7 bed2c8ac 3eff71b2 bfa707c4 3e56a71c 3f304eba 3e6f9b28 3f50fc57", - "418b7140 419cd1cc c21453c8 -> 3deda972 3f37246f 3f30630d 3f2e8227 3ed473de be8711dd bfb3f8b7 3e5a1b08 3f6b161e", - "423f7f56 c1df34b4 42308ed8 -> 3f232845 3e812e06 bf3a65a2 3ed09bc7 bf896a9e 3f213a5c 3f67e756 3eab7a93 3f547c4a", - "4219fefe c1eccbb1 c204638f -> 3f5f66c4 bee80732 3e3a451c 3f10ded1 bfbbf9e0 be6d2734 bf19f602 3abbae00 3e9a7db4", - "c2249e8a c0c1cdc8 c14f8db8 -> 3ee4687d be5af4a8 3f5e7ab9 3ed5179b bd9bfdd0 bddffd5c bfdebb30 3e60136e 3f511ab4", - "c150090c 413b21bc 405c76c0 -> 3e300e52 3f60e4df 3ee43920 3f363c72 3da325b4 bfddbf56 bf66bc8b 3e0b495c 3f726a40", - "42028ef8 c23cbf5f c1dc46ef -> bf5f3ece 3e00df54 bef2272c 3ed691a2 3ea347a2 be9752c8 3fa4efec 3e9a4fd0 3ee2581c", - "c1912886 42450c04 41b3e084 -> bf5dc098 beb6837b 3eb34428 3ea1d2d5 3fc3899c bdb63244 bf741bca 3e357ea4 3eb935ec", - "c185fe06 41d8d6fc 416998d0 -> 3f7cc2d0 3d765719 3e163ea1 3f60956e bfab5ade 3f341c61 3eca2a68 3ddd8db0 3e3c2210", - "c20e36ba 419c1a0c 406b5250 -> bf7e96af 3da38e72 3d8b2cda 3f05ff1f 3fde3ac6 bdfd5687 3f19f2cc 3da4ce90 3ef3d4be", - "3e878d80 41abb4fc c1e09f1e -> bf59a2be bf05dc12 bd7e2250 3f537a9d 3fdfd518 3e999f78 3ee1584c 3d1a2730 3f354efd", - "423485c2 416863b0 c1a0868b -> bec98c97 bef2cb4d 3f499a07 3ef7aaa6 3f7f5e7a 3f5e8384 bfbd6aff 3d8a0df8 3ef85c50", - "c114c9b4 c1f8c312 4145f070 -> 3f45d35c 3d888529 3f2195d4 3f113596 bf84f7c2 3e232168 3e9c9fbc 3e153c58 3d51e500", - "c1a48110 c10bfe38 42220fd4 -> bf0db45d bf551bad bccc45b5 3ef5ca21 3f994062 3fba4392 3ef079be 3cd67e30 3ec0dad0", - "414fc8b4 4185a7cc bf8fbe80 -> 3eb07a32 3f25a0a3 bf2e1e81 3f1718bb 3e9f4792 bf8d24a4 3fa41ab4 3e92db9e 3f386de8", - "c21b0a5e 42055d6c 423d25f6 -> bd1ed136 bf738535 be9ca811 3f2a1512 bf0d70da 3eaef89e 3f558582 3e433b6c 3f373da4", - "c230faa8 421e40f8 c1c20abd -> 3e36ed62 3f6ac210 3eb692cb 3ec029ef 3ea490a3 bfc94f95 bf6c18ec 3e31ca0a 3f4a1140", - "c1bbd290 c227b444 c142f740 -> 3cdd68b8 bf78e352 be6e16e0 3f23842f 3f48c9ab 3f79cfdd 3f512a53 3c901d20 3f390339", - "41747190 c21bd712 4182fa30 -> 3f1b87d8 bf0ab798 3f14ac63 3ef7c8e7 bfb2c681 3e95e2d9 bf9232ec 3e10b8c2 3f17d818", - "416a3e40 c17d216c 4229fd6a -> 3f384674 bec8e2c9 bf12981e 3f1e0033 bfa42569 be1c84aa bd482ee0 3d17e470 3f2db4c7", - "bfd73f60 4205b610 40258a00 -> bf29200d bf26dee7 3ebea656 3f267dbd 3f8f141b 3de3d7e0 bf8a0fa3 3db1e6e0 3d8ad980", - "c1189934 c13c4078 bf880ae0 -> bf397ebb 3e394c6d 3f2a3d68 3f007fd8 3f548e29 3f40d51c bf80bb16 3e5b6960 3f5d36aa", - "4233ec00 c211244c 41eb5ab4 -> 3f1cd5c4 3e8f46da 3f3d3a05 3f319a94 bf3bbb17 3f135c59 bf9f1301 3dfbe378 3eebf90c", - "c22ba028 4239302a c0e6b040 -> 3e8bf794 3f7275d5 3e2c1b92 3f3e5be8 bf57a031 bfe0cb04 bca99f98 3dd12ad0 3f19ccba", - "42244b52 404cf800 413900c0 -> bea9ecfe 3f6c2ca5 3e498d7f 3f4b917e bf1c883e bf9d7ffd bd95c967 3d80c7f8 3f46e8ba", - "c1906695 4196f320 c18b8fc2 -> bc8cccc3 bed00bf9 3f69df0d 3f021d20 bca5596d 3facc6ab bf9f1759 3e99a986 3d860718", - "c1d32393 c1dfe94c 422f0e12 -> 3f6b0efe beca2b37 3d016906 3f3b4fb1 bf45834e beb79879 bf2c2b76 3cbe1520 3f2afd1d", - "418a807c c2253c12 41ef981c -> bf585938 3e9294e1 3ee726d8 3f1dad3e 3fa12df6 bf91fa18 bf4419be 3d232190 3de28620", - "c1b08afc c1d20f38 41563b0c -> be99fdcb 3f591411 bedf782f 3f4cd60e 3f7f033c bfba2779 3d4fe9d0 3d2981d0 3f02f2df", - "42086e42 c1a12d48 405effd0 -> 3e799ab4 3f62918b becb108e 3eb84485 3f0556ab bfbb806b 3f2d9166 3e6b9952 3e761a58", - "4158fe88 41d07c08 420ae6d2 -> 3dd78f08 bf26f58d 3f402f0c 3f04523e 3ebe5436 bde7fea0 bf976067 3e5b28bc 3f376229", - "419efd64 41f8f2e4 40fa5310 -> bf6e7470 be1ec742 bea884c6 3f4587b3 3fcd46e1 bd25bf00 3f858675 3e0d89ec 3dd51558", - "c1412334 c1dbcf0c c1ac37f8 -> be9210e9 3f074aba 3f4cb0d1 3eb3da13 beb7e27d bf2e592a bfc640f8 3ebbe2b5 3f7e3967", - "4247c262 c206f65e 419d0370 -> bf3d91f1 bf108832 bebaa6c0 3efa1c55 3eb25252 3f8e2a5a bec05942 3ed3ac9b 3f72040e", - "c2008764 4242a580 422d10ce -> 3f0324af bdeeb415 bf59d2da 3f1ba40d be33c94c be6af406 3fdd0186 3e8374a4 3f4856a4", - "4203d0a8 c168d268 409be1e8 -> 3f511954 3ee30017 3ebd02fa 3f26943c bf8e660d bf0b7648 3f14aa14 3e0d4f84 3ec66eb6", - "41d20400 c18560a0 c0fa8510 -> 3e25d28a 3f72900b 3e8d2632 3f13d470 bea7bda2 becc8abc 3f0b519b 3e4509c0 3f2e17d3", - "c181760c c10f7aa0 c21753b6 -> bd93fc81 be56f507 3f799c8b 3f2dc41b 3ec1fabf 3f527754 be7c2118 3d765730 3ddc2dc0", - "4242ef58 41f80b90 41c5e444 -> bdb8c999 3ee467a1 3f63f2ae 3f307bdb bf234e9e beeb6d9c bfc9b0bc 3d7206c0 3f449d39", - "41b51924 c215e0d0 c20e0882 -> 3f58844c bef19122 be7f1e4e 3f35d34d be933a60 beaa4472 3d3b19e4 3e73dda0 3f4a77f8", - "420e30e8 c21c8241 42077258 -> 3cdd3025 be533585 3f7a6664 3e1650c6 bf39c755 be83c73e bfc2f0d8 3f5b1494 3eea98ec", - "c1c08546 c0cefe50 c1ee1bb3 -> bed2875d 3f608309 3e7e8db6 3ebed304 3f9ddad8 bed8ec84 3dc494c0 3ebcf3d8 3f3181d4", - "41010c98 c1e666c1 41b0ac18 -> bf43ec29 beee2085 bee3cf23 3ef19216 3e516228 be969afd 3f466c86 3d7510f0 3edc0b50", - "c2390a33 42301582 c069eea0 -> be13e90c 3f47a823 bf1be73e 3f48be45 3cdb372c bfe2c284 3f2964e4 3c8360a0 3e133954", - "c237abe5 c1d2a857 c230fe48 -> bf11f91b bf3ac06b 3ec16889 3e98b3ec 3f0c4e46 bcbc1c60 3e8f9f7b 3e973bbc 3f63cea3", - "c1cee74d bf0e17c0 c21fe192 -> bf485f2b 3eb5baaa 3f02e278 3ec783f1 3fb401c6 bf62e2f8 bf8ad6d6 3ef57bad 3dc02cc0", - "4212bb40 c0a0b138 42192cfc -> 3dda7c64 3f66a8a2 bed7486b 3e0140d1 baac94c0 be96a2de 3f9aaa0f 3f084bad 3f5a8200", - "c225ed7a c22893bf 423a19ac -> 3d7b55e9 bebb27df 3f6dc3f6 3eaba08a bf8591dc 3f0813c1 bf572204 3e431590 3f6e5c8d", - "c21abf60 c1a20aaf c16f8d50 -> 3f028bc2 3edb7ba4 bf3eeb9a 3f36ef84 bf26fe47 bf86b2a0 3fc1d847 3de72df0 3f7ada64", - "41b47510 41a91eb8 c2478c54 -> bf291f1c 3f37eb13 be5eff38 3f2b0aee 3ef8405e bfd9eedd 3e7633db 3e3d6928 3ef79c6e", - "42045842 4174aa88 c22006b6 -> 3e7f9464 3e99c1f1 bf6bad02 3ed2b693 bf330259 3f0ac700 3f1fab1a 3d95d02c 3dcf7838", - "c210137a c20e6e85 c232741c -> bf71030b 3ea4bd12 bdce3c31 3f39f170 3f0d93ba 3f197d0f 3daa9e39 3df11088 3e8a03ac", - "420f0f60 4227bb3e 40a42a50 -> 3f2653c3 3f26a9e1 bec8f161 3ef6bb06 bf39eb16 bf0c410b 3fb12ce7 3e04a390 3f1b27e6", - "41b83d4c c1c8e4fa c20f0139 -> be4a4f44 bf6be012 3eab5b4e 3f3bd558 3d5bbe48 3e2dc860 3e9e2f58 3d475c30 3e5f6f24", - "42032632 41b41868 c12b1748 -> befe3b50 3f1448c7 3f257f4b 3eafc4d0 bed6c59e be8b7bb9 bec6b14e 3ed810ee 3f68261f", - "42374e48 c1a21e42 c2028a7c -> 3f254324 3f42e394 3d793f48 3f0af663 bf8371a2 bf3436a7 bf7bc6dc 3ea768de 3f10e726", - "c22e556d 41c4c5fc c19383b2 -> beb73d38 bf6e8134 bd805742 3eb0fb5a 3e2ff487 3f8706fa bf698036 3f064fbd 3f0a766c", - "416b4ec8 420fd152 418c6ab0 -> bf2af088 3f358334 be682aff 3f0bf34e 3fa6c11e 3d3cae50 3ec7853a 3e3c0978 3f68451a", - "c1be6aff 41d83cc4 c23bee82 -> bd4df0eb beecfdd6 bf628f29 3f45b9f9 3f1801f7 bea2fc84 3f989740 3d5c17e0 3f72d47d", - "421558aa c20d8342 c210da72 -> bef3ed3f be0cfb3c 3f5e4d9c 3f220e8e 3ebec18f 3da8aed4 bfee4331 3e83e3c4 3f2c26f2", - "420cd57a 420e089e 3d751000 -> 3e94ff11 be04d49a 3f72a8a4 3f1d8de0 bf6fb666 bf20ed86 bf8512b2 3b05b500 3f584273", - "41afc4c0 c1eac4e8 c1aa2a3e -> 3d039468 be74c2c1 3f787184 3f2aaa24 3ee35a05 be9df990 be909942 3d4ec4b0 3b2d3100", - "c15a60d0 42206794 c222e5a7 -> bf3987a4 3f2b9951 3e23639e 3f51a8b4 bd860cb8 bfa1fe76 be9c5d7c 3d0c60d0 3e540968", - "c2468a2c c13a0c1c 40f06310 -> bf57aa48 3e7b52da bef5934d 3e586a08 3fd53882 bf3b660a 3e40069e 3ed7bece 3eece5c0", - "409cc920 c2116366 c1ef4754 -> 3f3028ba bf16a600 bed956b4 3eb4f894 bfd1047e 3f65a7e7 3ea1219c 3e825290 3f019973", - "41c05c6c c1c22757 c16a7fcc -> be95fb07 bf04b181 bf4dae7e 3f35c829 3fa1f48f 3ea276d4 3f6c1e5e 3d9315b0 3ed44f80", - "40e6fbf0 c20a0da8 c247f636 -> bf31d595 bdf6a0ae bf358ce9 3f23f293 3f91ea34 3f8049c9 3f5d4926 3d23fb80 3f7df300", - "c20158d8 41811fe8 423a2c5e -> bd996592 3f7f2850 bcfe0040 3f263c4f 3e577763 bfef43a9 bee07096 3e9ca20e 3f13a9e6", - "41946b0c c1fcf6e5 41eab2a0 -> 3e9ec768 bf1329ed bf41d87b 3f24fff6 bfa72494 3f23ab02 3f30c5e3 3df24490 3e6bcc8c", - "c0f1e060 42172206 c14a3398 -> 3e2402f1 bd229aa2 3f7c7d96 3e414137 3ee02a72 3cee0daf be3d4bbc 3f0f6fff 3ef9cc38", - "c23e859a 4241b6b6 41da7d00 -> bf106d37 bef03252 3f2def56 3ea10171 3fa5fd3e 3f14245d bbfb7180 3ed7e333 3f081982", - "c10a8110 4217492c c129ec6c -> 3f6bf64e bd72a849 bec43e51 3f067611 bfc594c8 3f578ea4 3eb8768b 3eb3688e 3f3c7e05", - "41630608 c21cbc2f 3fedd500 -> bf5348d7 befe6ca9 be89495f 3ebf638b 3f586f1b 3f0d8466 bf3ae7a4 3c1e2380 3f7d6077", - "c21db0b2 411799f0 c125dad8 -> 3ece6853 be347e42 3f65e38a 3f179607 bf4ca6d4 bf082d72 bea09ddc 3e3c1f68 3e567484", - "c227a4d6 c22fcb42 c15c67e8 -> bf38e2d8 3f2939ae be50753f 3f33a70a 3fd74a02 bf389761 bd9118e2 3e921890 3e8df7ce", - "41c06388 c220c571 41b26970 -> bee85f7d 3f60279a 3e294c76 3f3fe381 3e862fec bf915842 bf8e4d3e 3d70c4c0 3f2dc65a", - "c0226ff0 4009c4a0 3fa641c0 -> 3f187f9c 3f4a26d2 3e16764d 3f16251b bf5bc7cc bdae1218 3f031b9b 3e7ac340 3f2f78e3", - "418d62e4 c19f0da8 42448a66 -> 3effbe0d bee00764 3f3f68ea 3f2ec285 3e5cc49e 3f84efcb bf8d65c9 3d62b070 3d917988", - "c210e43b 418c5ca4 c1f50ead -> bf6a64fb beb66101 be3efc5c 3ee1b134 3f953c48 bf0b0312 3f0b9a2e 3e11b6e0 3f3ce8ac", - "40610e90 c23a5325 c23ee702 -> 3f5a6f4e 3ef195f8 be6360f5 3e988797 bf0f2852 bfb16dfd bd671fe4 3ebafc33 3f1f7d3e", - "bf1b9b80 422fa3d8 c23eba71 -> badb176d 3f201e4d bf47bea2 3f29b110 3c3a6cca bf941078 bd88f948 3e84d1e6 3ec2a5aa", - "41af4e7c 423ffb6e c120e6f8 -> bf1a7780 3f3e8d9d be927fc2 3f5610f4 3f24b79e bf273c1a 3fa3fd54 3d698290 3f4e8cf3", - "41f19bc0 c211c698 c1c15925 -> bf36957c 3e92aabe 3f23c5aa 3f3d8e28 3f3788eb 3f294019 bf758da4 3d5254f0 3f705f94", - "41f5aee4 c220934c c20c577d -> 3f1a7cf9 bf1bf0b8 3f03ba24 3f4cc8fc bcb42fe0 3f466f60 3e905418 3c005500 3e4b77a8", - "4205f166 c056fcf0 40c05ef0 -> 38aed89a bebce466 bf6df0e7 3f184564 3e3ee819 3f9a4bc2 3ed414ce 3eab01b0 3ef8e2ce", - "41260200 c221b402 41216cdc -> bf6e7ad1 3eb779c2 bd7bc121 3f0c1de1 3f2e489f bfa6b0a2 be1d05f1 3e052878 3d29b6b0", - "4125195c 423203c0 c225b602 -> bf2cd99d bf265f6d 3eb2a66d 3e43a51f 3f17a77f 3fd1460a befff9a8 3eb75a9a 3f69e9de", - "c22bdb6a 4233eaf2 c165e910 -> 3f7572fa be908c79 bd031941 3f347b7f bfe4fa9b 3e182fbf bf0262fb 3dbafb68 3f714072", - "4210410c c174dc30 41927b14 -> 3f3f92a3 bf10cd26 beb1688a 3ede876b be8cc4a1 3ed3f072 3f9b6aac 3c8449c0 3f2f78cb", - "41e16838 c1b37813 c1edca4c -> beadd4a1 bebccb06 bf5d8513 3eedcb75 3fa8052c 3f0a1364 3f8289e9 3e6e925e 3ef76bbe", - "c1efe78b c21d4f66 c22a690a -> 3e258253 bf22df66 bf411f71 3f04a910 bf44e19a 3f98bae6 3e4083bc 3d89e1d8 3f76a919", - "bed52b80 4132f6f0 41790a88 -> bf7cd75d 3c696bec be1fb30e 3f13d5e5 3ed0e34a bf192bfc 3f3960c6 3db8c6c8 3ed25020", - "c14af118 c15d3054 c227c6b0 -> bf594e0c 3f05c97c 3da317e1 3e99c6ec 3dad73f0 bf4070d0 3f05f969 3e406c6c 3f3cd8af", - "42391fc4 422f63e4 42390126 -> be9cf025 bf30b536 bf27c9d3 3ef91e0d 3e12f9be 3efa09c3 be9ee2c0 3e2176a2 3e8f9118", - "c061eb60 4186031c c0f68350 -> bf27d626 3f395d82 be5b54b9 3eb375e6 3f3e91d1 bf20451e 3f9a4aaf 3eab99fc 3ce5f3a0", - "c159d9d8 4208c00c 4205e8fc -> 3f74bfbd 3e896d9c bdf1a309 3f1c24b6 bf16eb6c 3f1ee3eb be1ffd2e 3e46e50c 3e1aa0b4", - "c0dc0bc0 4059b450 40ff12a0 -> 3f33f861 3f35737a bd6e8364 3f1168bc bfc1c3e4 bf27e4cf bf0653dd 3e8f5f0c 3ebd4770", - "411475c8 422cca92 c22456e6 -> 3da77776 3f3778c6 bf314d3e 3ef61bd4 3de32b8e bfc243e0 3fa1333d 3e7835d4 3eedf452", - "422ecf00 c0f49820 4243b8e6 -> bf2e07d8 bdf08734 bf395337 3eb60973 3e35f4b8 3ed2d9c4 3fc4bf24 3ef3e521 3e138ed4", - "41857fa8 420f6632 4154c9e8 -> bec6d2dc 3f697a2f be07270e 3f2661e2 3d905960 bfed0cdf 3bf59af0 3e0dc848 3f77bf02", - "41ad1170 c23fe63b 420ff572 -> bf5f6548 3efa0a54 bb16e9a2 3efbe848 3fc81158 be1b1364 3f247a9a 3eab495e 3da02e00", - "c231c76c 412b2cd8 4244bc1a -> bec73d97 bf69d702 3df40fa6 3f12ee2f 3e7917eb 3f8ef053 3f595988 3d27fb40 3f5fe448", - "c229ee74 c180c888 420dd276 -> be9c7885 3f72fcd0 bd9a5b1b 3eff54ff 3ebe99e4 be6e82a0 bf1e895e 3e9301f7 3f0aaeb4", - "4221c93a c1d78674 41bb3028 -> bd8190cc bed56d11 bf682237 3e8c87f7 3d42371b 3fa9ef4f 3efd0238 3f0083b6 3f5b6e1e", - "40021e70 41609a48 c2456022 -> bf77a773 bdcde2d9 3e6e077d 3f5019b9 3fe57676 3ea7e3ff 3e91a6cc 3cb4cc20 3e7fa96c", - "c216b728 41290d2c c1ae2d39 -> 3f25a030 3f17e8be 3ef52cdd 3ec3464d bf0f4608 bf10ebfd 3f0456c4 3e87ca13 3f0b6640", - "422d5626 bea43f00 3f023a40 -> bef007e8 3f37e959 bf039028 3f21aef1 3f8440cc 3ddb3020 3f061c82 3e1bc2bc 3f354742", - "420b5490 c16f29b4 41c15164 -> 3e979713 bf7427d0 3d562da9 3f13c88b bf605bcc 3f702f95 3f430ef0 3e1113ac 3e84891c", - "4144e214 412bbb24 c20219f7 -> 3f4fd4ed 3ea9e9f6 3ef5f62c 3e64c04b bc9e60e0 bf184c64 3d8efc60 3f2f05c0 3e3b7a30", - "4241eddc 40bc3550 c1f95e7f -> bf23bd13 bf2bedaf 3ebf7b41 3f310262 3f8e949c 3f99e79f bf89c588 3e3536b0 3e34f7e8", - "4185137c 41a507cc 3ea6db80 -> bf4ca8a8 3f0d69c3 be71c370 3f2ea6fb 3fd512d2 bd76c150 3eaa15e1 3b711400 3d6f02a0", - "c0a7c950 c1cad1e8 42274a1e -> bf48b0ee bbf56b47 bf1eeb61 3ee0665d 3f6d2a88 3f0b565e be57dfcc 3c21a820 3f738cad", - "c21ef44b c1115d24 c22fc9a8 -> bf7acb9a 3e3c971c 3da2ef11 3f163eba 3ee8ed6e bf378080 3f15a0fe 3e03ea50 3f606b4e", - "c0dc6418 c1a91004 3e922780 -> beeac8ce 3ed8f065 3f47f93c 3f08c5b5 bebc50e2 bf5dfc94 bede394c 3e67f834 3f5f7919", - "42401686 402b54f0 c19d4302 -> becd2a47 3f5d6f7a 3e9aa666 3f3868f4 3f9b2b97 bf746772 bf612033 3e4562b8 3f2bfdbe", - "420a4a40 c22b0474 c1a6b804 -> 3f16bcf8 3e1dd245 bf4b1e6f 3f5e7f97 bfb3bd1f bec69fcd 3fa9590a 3ac8b600 3f457c4c", - "c226f6c4 41fb0c50 41fe5360 -> 3e31ad13 bf26afd5 3f3d26e4 3f3286f2 3f1b2a28 3f82794a bf9f6aaa 3e8010c6 3ebb62d2" - ] - }, - { - "glsl": "ivec3 cultmath_pcg3d(ivec3)", - "tolerance": "exact", - "cases": [ - "a5802853 2e4c61bd 6f1aee13 -> 5ef3f2f8 1300bb2a f26b8884", - "f0dd3375 800b6194 f46f75ce -> 98dedf7c e3440ec1 6e7308b0", - "aab7c655 431c7074 0950579e -> a9522a1a 6f6d524e b7fe0bad", - "f4b15c4c 192739ef bfb7785c -> 3bfe2c44 a3cdd8c3 29f2365d", - "0049270e 6970b9f0 637f71f3 -> 29d7e66b de94b678 14aec4fb", - "8ef51b31 a0a3ade2 85350bc6 -> a49ab220 3ed42d8d 6aacc27a", - "ede197a9 307190ac 8200551b -> febd639b 808dc02f 36d843f4", - "f835260f 1962a846 282f9f61 -> 91f1b9eb 4a6a0b97 84066aa1", - "63ba1e86 7ff5e977 7f43acf5 -> 130c42d5 42a7bddf 1a945724", - "b0760be4 e26426c0 efe9ee8c -> 225351af 6669e5ee e9da87a1", - "6c48ef7c 53dcbbb4 778b86bb -> 724f7f33 3e6e4395 8702ab01", - "04817697 dc503ce9 f495f920 -> 7ca54127 04e0390b 820ee16d", - "fe063242 04a3416b 14976739 -> 0573d4f4 0efe13b5 70c93b8f", - "0141072a b91187f1 545da004 -> 83900e30 9b5e0750 3600ed63", - "4480e233 8bc75099 a0214aeb -> 8406f8b7 904e2111 ce73787c", - "a118943c e72b6c00 cc7a3d57 -> b504f141 e5ec4f39 5613ce01", - "2926095a a8f2bff7 57fe4ab2 -> 06a60563 0e00a946 3eaa37c0", - "0142bd6f bcb1bd53 8f11f989 -> 253fde12 a3d974a5 ad573004", - "60e4c07a d679d0b6 ed9854dd -> c6c30283 0c2e1c16 44f808d2", - "390e5e96 fd529208 89030f76 -> 7349a07e 7f47dc62 659b7554", - "23db7e6c b9ff2497 67b1bfb0 -> 32895174 4586a1cd 20962f6a", - "47911e2f 37fa2ee4 8d01947b -> b8ba139f 80771b6a 6dd07b11", - "e55d7f28 b434e4ef bcc48402 -> 3f610c35 018c36bf 547a33a1", - "ae871a3f 0d350a25 e7107045 -> 0ec4c949 fb3e8052 c39c3903", - "ecd8d190 6c0e0ae6 8899a48e -> 942a61ad e0e42a88 f727a744", - "dbb8d10c aaafe956 a28d03f8 -> 8e04f1ec de6b4de8 65742fc1", - "3c4f337e ca90cc9d a800e6e5 -> 53b76bbd fd2ae411 ead2eea3", - "a436737a 406713b6 eeb66874 -> ee6b9060 55561171 c118632c", - "df7e6f5f 648f3a13 92635274 -> 7cd39f6b 0d9fdcf2 db742dbf", - "6c336bf9 71bd96a8 53db36ef -> 7feeddce beb19bd7 c3bf8d63", - "20e645ec 5a1eb841 39677590 -> 6e6322a5 5e7f3190 1aa9d58b", - "72fa495e dd806f4e 084f35a6 -> 8c7646a5 164458d8 3cc2014e", - "01cd7990 4cf191cf 04ab6776 -> db8e0a34 401fe77f cdcf7837", - "93edddde 21b1bbd7 f3f9a84e -> bfbc929d f4423ca9 9d90fa42", - "d8d42d7d 838c3779 71715dea -> 245533a7 35ac8100 0c047f88", - "a46c7258 b99adede ea8c5415 -> 2ff94b5f b6960454 3a086c33", - "454a3a7e b6315998 91be7a1f -> fa4bc82c efc29ae1 04d7dcef", - "900a7245 6c20bfc8 49a34771 -> fb7370ca f91570ba 35a3d745", - "fae54c30 c144dd04 d28a7c90 -> acc77713 22f3aa43 40ef6455", - "1304b076 f0fd21cd faecb030 -> c8f7ffd3 ab2ed6e0 e456bdfc", - "0c7a2cec 4b8c5902 dd1996e6 -> 752c99ad 2146719e 873ee5df", - "629602c9 fa54b7fe 2881dce3 -> ea0683b6 1ef40a7a 0446e193", - "b41532a4 43a9d94d 69a35ec2 -> 736570cb 5c6db64a baaaef09", - "16d5a635 f0ccd982 81d6e2c3 -> a9e3211e 3a357bcb d4dd1680", - "5b514e99 8aadf57d 6db41699 -> 174482bc ec159a1c 91671e23", - "d20cfaf7 2a771a66 2afef156 -> 8df170b4 ba6433cb 94f63270", - "f7407867 7f2130c6 58fe135d -> aee07fff d9cb9c92 55875a19", - "4cd271a0 aa1a884c 1019558d -> 02f8f81c 58e82dfe dbebfbbd", - "5e45fe72 5da9faaa bfad53f2 -> ae3d3d91 2f5e273c 4ac6038f", - "aea21ed8 8e72a4e5 d2de2f7e -> f07d0180 cf69d8cd d30689f2", - "8fca62ca ec9f641a 6208a98f -> 95fff0a9 1b46e598 80f2f751", - "d5561d24 f665ed79 44a653a5 -> a823b1a3 4a8029d3 34439682", - "6add8d06 ed665705 a2dc62bc -> 9c4e7e86 b9000ef4 17fa3cc8", - "1d2491a1 6f76152e 462f4ae9 -> 2f702be4 8f874f4d 47967d69", - "8f83a831 2dcf3c2f e8204261 -> 74c7d84a 4ac195f1 1631f940", - "f3024d8e 3a609e1d e99c8520 -> 83256e06 98497568 32f32bc1", - "352df90e 13165ba4 3ef042dd -> 9b71b5c2 5da3c7b3 8ce2c70d", - "6f426d0b ff077e6b 3a269358 -> bc674895 dd953722 5eedc6dc", - "f91e1581 056080c5 c4a241f2 -> b0d385af 4eea0f05 1f6f0226", - "cc1f16d4 880e917d b8f76246 -> aae39909 3c7c9b1c 1e353c32", - "0c90b876 b5328f05 c7dee6aa -> ae768b65 08c7e87b 4f73ea09", - "b83fadf8 8626ecba 11769878 -> 72d257ac d37ae66f af9f1093", - "75f3bc5f cd3919fb 0d331de2 -> 1efe00a8 a09fe327 fae33775", - "271cbfcd b137aeb2 0a199c73 -> 9e9ab855 6f6d36dc 8b6e5f55", - "bce5ad76 74df79da 27e94942 -> b3d88837 f1ce5ce4 449ed0e8", - "dd14148e b1bb219c 0ef4ca93 -> 5abf21e5 6b6df56c bde97e6b", - "9d614a01 9ef9e6a4 13c8b87f -> f172ecf2 83d0b3c9 348342bc", - "c9c2f55a 86bd48da 728f86b1 -> 5ef16077 1477235c 5f5e930f", - "08a3c19a 99730b9d 442e9ab3 -> b2927362 82c8ec45 0a1c535a", - "f5ae8c60 f06b4089 81fb1351 -> bd36539f e0945596 d9f77ac0", - "e0765e1c 672a1155 ab2f9c68 -> d66f5b5a a868b22a f1ea371a", - "866ebd3a 8d55bbfc a094c7c4 -> b1a4e7ef a52a1a58 89564f7f", - "4c01fedf 012a94c6 477c13a1 -> a7159e01 28f008d9 a9e87d20", - "ec1c4924 ce151755 765234e3 -> ad2214c6 dde02c66 d2e51e16", - "3c167436 05b403d7 d054dce2 -> d27c43be 6bef679b 700473d5", - "15ad277f cfe1bed6 4d05c3f1 -> 70219ce7 ae373747 5282bb5c", - "bc16d896 c5aac81f bc06e325 -> fa6c9f1b f3bbbbf2 91dabe16", - "b8eb948c 126bc2b6 7ee75764 -> 427fd81c 9b92db8e e7ff3ecc", - "cf154454 475b868c 29c34c1f -> 462e1891 dc9e91af 824eccb3", - "61bbc14d 527826a0 e4e0c98a -> a765286f fd40b16b 90497a6c", - "41dff613 f3b3fd74 77d7d78c -> ee12eb6f 7404d51a b214b618", - "2ef1aee3 6d879605 5fcbf123 -> b4d44f99 fa96965a d4497f2f", - "409ec91d be6929ee 740c5ef2 -> d977518c 8b5be7ee b36b6a6f", - "dc597464 a6e4c23b 6b44d245 -> 4ea08072 25d843cb 01e52911", - "38c1a9d5 84cb991c 945c51eb -> 9918e2da 66b2cf63 fd2eaa86", - "78863656 bc17d67a 6fcec722 -> 3bfcd8b4 0c2f8ed2 e39b1c3a", - "2a4c5e81 0346eafe a774aa8e -> 759c71b4 f9a7b363 4b3f37d5", - "e3e6554a 06d069eb abfe0aa6 -> 26a1c574 eb06ebf8 ec0acb96", - "36de23b2 705c7886 0d71376a -> 03dcf627 f697bda2 a42ed50a", - "23b290a8 8de31d72 c6349636 -> 1eea8734 45c1c02e ecb01181", - "3f3f1e53 ed011e94 3da60174 -> 0c0adc9e 9a8d961e 45d71b69", - "db7375d9 8d99cd81 aef9d6e4 -> 5df4eb2e 2bf68fb2 3f8cb039", - "881378a6 5c0e1a70 5ff91867 -> 1c5bae37 504bc6c3 6c88e1db", - "bdc1a1df d2f58c4e ff34dc4d -> a282eaa8 1fec6005 cb1c8a6c", - "87bf8c10 fa9fd306 e62b2735 -> 8cf33b1c 8adabeb5 c185e371", - "747a8577 e54411f3 e746e0d3 -> 06491014 dd3a62a8 78467e66", - "92ba1981 c2e77d97 c5a5b740 -> 24ad6d9d 225d3a65 dc920899", - "aad7dffe 15631096 a0a7d30e -> e9c37cee d0a18450 f4c3bfc4", - "0a77ac1f 65d41a8d 00fedc5e -> 69b852af faa3c3ef f4c1dd4e", - "b63f052a 8982bc30 0caa35a0 -> dc1b097a aa98cd77 51c9bece", - "b865a035 694286e1 997b176d -> 27d8cfab f6266f9f 5c732caa", - "fb36e6e9 cd0ad10f 946f70a1 -> 23e56cfd ea10b96f e2290032", - "336dcc01 1f808e33 a1820b9b -> 68c54a31 56821d1d 18ca5ca6", - "6fd763c9 41e9551c 52eab6d1 -> 4740612e 6636f85f e0903bb9", - "442d799c 661047a3 42ba81a4 -> a225db06 4fca17fe d841d1b8", - "6ac5aa20 f57b347b 723b7d5f -> ce501731 0fa77854 21401bb0", - "67a80ec8 8aa632e8 4c0e5851 -> 40dfa90f 766a7447 aec086ab", - "0ecdba60 a0b4748f 4e28c81f -> fa8a4d10 189d9600 005b92fe", - "bf8ffb5d d2e4ea72 1ded093c -> 35f66b09 1188daab 8170fe3b", - "a584d5b5 743f705e 043724b3 -> 18d25808 064aa672 d57e95da", - "03e6bd71 d74976c5 effa7d9f -> 38e1d891 30a38fcc cf35036e", - "c1bab43d e9d2fc6a 8b8830c5 -> 3a6ea6a6 dfbde340 6eb2af0d", - "d06d5f0d 5b5aaa33 34cf8945 -> caad2aaf 11ec1e69 1a0cd268", - "6fad328a db44d6c9 85a4a96b -> b3ae46c8 d85a02ef 7ea717dd", - "6004ffad 41947037 b9c72748 -> 4236f2af c2b36e90 4a882e44", - "810f4ed3 088c5cfa 27854e0d -> d282043c 9a5c96fe ecb41a96", - "b4cf6726 7fa6fd3e a13b4876 -> 35073bb4 8d2cf358 fd427a2d", - "626957d4 79294d95 de01cb29 -> 2de4e3e4 f4bdfbcb 30714a40", - "f6197719 b0d26d23 d56369a3 -> b4dcf4e1 459c9e1b b7cedf4f", - "4ee5ce05 b05d98b3 45d01a04 -> 220bb2ed 8635fbd8 f8a8bdb9", - "b5855a4f 4c80f04a 2d5fbb7b -> c4f97b2e e5c18033 b59f5322", - "b6d1ea45 1ce60a3b 02d19a32 -> 04e125dc 4f119ff5 d0d0bd92", - "bc68c60b b7a14134 f4ef6b99 -> 1ae14823 06d34fa0 3a4785fc", - "5bf0173c 77369f84 e4a2f07a -> 1b6a28ba 8a1c3ae1 30b48b25", - "1f10ce62 dd3e5077 32d307d3 -> 7f97e083 0df09b22 04d91e69", - "326e3326 dcd77957 f73e3026 -> 2f9b2174 f40ca51d f3b72918", - "9111f12c 66bfdc7b edcd72e0 -> 4415c490 c980bebe 40ebd15d", - "3c9ba6b5 f658a2f3 6d69ff37 -> b6525f29 d5585a72 4b1beab5", - "14b4ef95 f4a3c32c 8852f2d8 -> 3ab331ea 8ba3f795 7f535d07", - "7f9a0e7c 7da4a3d2 f7222c0c -> e3b8644b e3cf2688 9d1a06a1", - "0457d9cf 7b06c340 26dbdc99 -> f98dab9b 1a488b8e 8a40d8ca", - "28ae61f1 ec5112d2 85a1e4bb -> d6187644 a85be492 dec6bdca", - "80841de1 7271cfb7 d488e76f -> ea591d83 d099d7c4 a16784a6", - "3018846c 9f7a8738 e93c40fa -> 6f40050f 07b27015 4b730b08", - "fa43bff9 801998b2 f6c3bf40 -> 169881e0 8f3836ff a8aa65a2", - "481e605b ce631e70 b248158f -> 8f5f8ac5 217c89b4 937a511f", - "791da67b 09c09c88 5aa8484e -> bcc084c8 f0a737dd cdc7945c", - "858313d4 6b3b88aa 9615396c -> 8c62af28 f9486f3e 480b8267", - "b1461289 36f0cdd9 9d577599 -> c29cbb61 810c54e0 1f28fe69", - "7eeacab4 06f1a81a 06114d5f -> fe2891d5 60312a1c 12af6fa0", - "0b57be71 3184a9f8 c582a5c1 -> 05305d39 ddf135e9 10e5fad8", - "1ef8fd55 3c28688d 09f48f49 -> 7e7a150b 65d89db5 11013adb", - "60fff9d6 4111dbd0 e5e715f9 -> c9f052a4 13f8cb48 3be35dfb", - "61fddb37 a0e33c1b 1342dc02 -> 274e716b a74df4c2 e963b777", - "6f691b92 79847598 0864ce49 -> 3d09679a da45d001 a8ed8e78", - "6d8b7de2 2abccbf0 8cee8725 -> 9d27a88b 0dd54959 499f2b3c", - "01246a87 579bdabd e4329f67 -> 99080336 477cf3c3 6eda4a1b", - "31a45199 8d6cb692 ce1bec63 -> b211b51d 12a7e40e 9a91afbe", - "d3ee2bff 55a91999 b4307bda -> f8362998 0e90e132 3d636a9d", - "7eb78e3e cc914388 821417d5 -> 2ee65ebf 54e9434b f7c29447", - "db535a54 9038852b ef96d428 -> e3e9c258 ae3bc175 194901d2", - "b013ccb2 3e9dd446 d3480641 -> 34dcb151 c7631d0e d2ebecb6", - "2d0eaf48 d0d77e7e 60755b88 -> 83bf81d9 3b53b8f6 e7ccc1c8", - "1a211e99 03563f4d 18675dbd -> c5bfa911 bd59a1f4 36c8ca7a", - "f7b332c9 807f3d04 2d34bc24 -> 96e61484 72914bec 10cd6b7e", - "6087f35e f0c3ffbb d7a23841 -> 89ce0495 a090cc98 2785beba", - "01f702a0 bfa3e819 93a464af -> eb0c52d4 57f88feb 20ff3706", - "725b68fb dba9934b 55386ec8 -> 952926a5 f23c35c8 0983055f", - "0bf2e9c7 e7374a3a f550dca6 -> f6be9295 58017940 09ef755c", - "fe1337f8 bde79224 55e5b488 -> a974a856 e1a119bd 4b14c7a3", - "3f23852e 07def34c 4c93389a -> af296c3b 67a389b9 d76b0471", - "824afeaa 6c95a612 9498bc31 -> 59f3ae16 f205532b 7c7c3385", - "02218061 46c5b1a6 a9d030a6 -> f3f885eb a31d11ec fb0f74b7", - "ed0004d8 160bf106 9c51891e -> 39f2a44d e133d6d7 c294b3eb", - "9ef54e37 ae5afac1 af93f49a -> 352dc726 808465e1 2d381fb5", - "80cad8db 8273e4ad 8b3483ec -> 90f8aafa b5802bb5 da94e31d", - "74f170da 32636f67 b4fce951 -> c013d27e 7803bb78 4686f832", - "b5b98fbf da0dfbfb 91305c32 -> 20e26d52 9ca152fc 6cc21c19", - "fbfb1673 fa0e6202 257117d3 -> d6f68963 b95cd0a6 dacf0ac1", - "0f18dafd 8363a43c 9c40450b -> cc4d69c7 24c70c3c 48736dc8", - "81413415 0a49d079 6ea5c55c -> 4a72c56f 9b237f91 3f5434f7", - "0f77705b 7166a143 11946a48 -> eeb96d83 59061bd8 f92232c1", - "98f2b9ad 8b6e617a 81a1c397 -> eadddba0 685603bb 98795093", - "75e9704f 00c72b63 406c7b84 -> e65be4c1 e8354ae1 d16f380e", - "464abc6b dbeb282c f3e18f1c -> 18ab2c5e f83a621c cc8e8f26", - "0f746ce8 49d1414c 5533cfa0 -> 1c498195 dd6fad3d 23892c8c", - "8fc73d8e d08dc816 7c4db9b8 -> 15931558 e23623b4 c853306a", - "331664ba 962d7d67 419a71cd -> 5e6a1232 5b782ba5 193bd46f", - "21bf60d1 87df63df 89e5f157 -> 6368ee0b b5ab1f38 9b7f7d5d", - "a3cac1f8 8728df40 a5f170c0 -> 17a77c87 6f34208b 4836c33b", - "7dcc7c53 5acbc39e d4bf83ec -> 80eeb406 ec8d7e6d b6603e99", - "a1326e35 69d98ff7 2b509baa -> 0afe0b9d 0d6e557d 234fec03", - "e9dbbe4c a7083207 7a119a80 -> 42ad911e 0b3796ac ff38c981", - "6b329bea eb0d02c9 ba8444d6 -> 3e7ecc53 2750269e 17485411", - "f9d3f893 12d3e33a 7931c7f5 -> 8ec6dbe2 878bb3a6 c1e56477", - "e717a654 b0216aa9 f9bbcc77 -> 8e4a2740 e9683248 acce0648", - "2d19abaa 1e0f847c 817ac6e4 -> dd181838 7f6f79a2 d4311ae2", - "8375d7be b7c11ec8 20e1a075 -> 6512c687 170d3d36 ac9d26e7", - "35826549 57853229 b5ede9f4 -> 00824c75 be3ec061 1934eb00", - "fcdaa6d9 62c09937 6cedf64d -> 2bd9522c 73705f58 2068a3c6", - "8a2d6ad4 1874785c b616358d -> cfcf7333 757ebed9 936a78a9", - "0492827d 6b948cec b437ef91 -> e73c83b2 5cb3415d 32c43a4c", - "a6f30986 958d4792 bed908a7 -> 5b1fb7f8 c630182b b64d4b41", - "afafed35 c87315b4 05d4a8c0 -> f627105e a7a05888 1ae161cd", - "2c17d0c9 8f1e058f ebcb7795 -> 86046358 522582b9 4bc1c0cb", - "7150cc1e 530e70b1 94a68af8 -> 30e7aba8 33edf9ad 66ecd5cd", - "177fb91c 75037243 e0e2fe30 -> bd904885 94eb9be5 d70d8192", - "18acc144 e8748e7e d75250ae -> 4b436c42 fe193fc2 433f8d84", - "f95c1ab4 810b9a9a 8e134329 -> dc857104 230cdcc9 b651af37", - "e4baf8f7 e25e2501 c5db43c5 -> 6ac3c0b2 f3b146ea becaa735", - "7f7a90bf 6a95d7b9 13959c7e -> 4118b4a4 4c76bc1b 95107c71", - "6706c2cc e152e34b b280ed61 -> ae3aa734 a7ce69eb bc978a4d", - "118b0c2c bca07eae 75e5d3c1 -> 2dc3a59e ce96fcd2 97b65003", - "81ad2b76 6e80048f a7dbedaa -> 1f6e4380 e94a98fd e7669ab9", - "47347164 870fe0c9 d00773da -> 23d7f5c7 e457d463 4ad8c0a9", - "3d6cda5e a3d720fb a7983aba -> 71775816 ae006c56 07b954e0", - "37816896 e2f99fd2 36693bdb -> 76a963cf a5a1f047 e0d4ccbf", - "215e679c af588532 4aa70e98 -> 983b8dbe 066b954f 059014fa", - "4711f1de 715a2c5e 04435dca -> cd8fa57c 48f957f9 a1146af0", - "443c11fe 4da67889 5e3744bc -> 83d1f7c0 4953158d 75fbd3e9", - "67fb152a 5dd6d727 ae08d74e -> 737a6872 54a5dbb6 c2444216", - "b14f82e8 2005f77e 5df4415f -> 4bd35146 ddf9fb87 c6f49a60", - "c7cdb415 583e9642 f087f17c -> 3d0b1440 5cf9f7a8 849b1055", - "da997fcc 4a77a2be 018b0ba2 -> 2f83cac2 12200772 870eb846", - "12bf4883 ef59d700 7e0b49b3 -> c4104c54 67744354 5f3c4d0f", - "2babfe63 eaf6399a 4ea527f1 -> a4902eb0 53359813 fb16c6a4", - "c2f88b24 dab74675 fa9573ca -> e0faa2a8 f392d8b3 8dab85dc", - "59790891 d824e450 efc91d00 -> 75f2b0e5 cd94223a abfa6be4", - "533e53d4 3f2c0c1e b0dea375 -> 501f0f84 22ca25ff b83bcb56", - "33ff4865 1cdeb9a7 f82ba0b3 -> 64ad5a47 d69ea8ac 0730b57d", - "d8109d28 aec7993b 1e610bfc -> 2bed6ebc 6c8bb625 a81846b9", - "6d9b023b 86f29087 e965bc4b -> 597998d5 b10b6f3f 1947f170", - "c464896d 92512418 25f81690 -> 7db8ad46 ffa479e9 6e30fa7e", - "024e1366 64ccc878 5d6da113 -> 450ffb53 3402383c 77833e1d", - "b568617b 73d82f50 956fd35f -> e9393b8d 1a52ac95 2e3bbd0a", - "7b20bce7 81099f7c 70228c20 -> 007153b6 924c1cf9 243ba1d8", - "d5d508a1 5ea3db7f fee59e7c -> 376a02e1 9aa93623 4d31ca98", - "438356e7 5a0015bd 3126d1dd -> ab196c92 578a0ce8 378a6aed", - "7d6f00ba 4291df75 315f94ab -> 0aa4241e c3941f69 64a47984", - "87d94b40 bf6918e7 b45551a6 -> e090427c 1dd483c0 1e0da852", - "27228632 2f12aa42 bae19d35 -> f6c0ef29 c094947e 69705a41", - "f64911cd 1d320517 db16b2bd -> 6cde6b0b 62b7a36c a28e45c0", - "25e248a3 dd107cbb 10920bb4 -> 3a522ad4 84a27f6f 6a5efc40", - "cc8f257a f23d1be8 d38316f9 -> 3326eb2c c8d054c4 1c58ddd1", - "23895273 57fa3819 502e8790 -> 4512b8a1 79e19f46 6a64d9b0", - "d930e30e 778c0d5c 9a422009 -> 0fcc4383 8f532d71 ff5af66c", - "478161d6 b21f2ea5 2cc7cf39 -> 5f63e2bb cfc4669a b4aefffc", - "db6539c7 4001b685 8d89b320 -> c7ff97b3 18079941 884bbabf", - "bf2508bc 4347f482 efa96402 -> c398310a bed8c7ea f0a5a863", - "ae4b8e0c 17322f75 6f68eb17 -> 71a83f93 d06bc683 a5b52f44", - "35463ed0 2317b2ae a0864510 -> a9099a6e 3d9c6f49 4e858555", - "94cab282 f05032b6 26b75a86 -> d9278679 0b045553 4e6bddf5", - "7c8d9b96 98aeee21 f28f6233 -> 36c5d522 07337835 ca3ef7ad", - "ba5c8dad 8fae2578 5a50eeb9 -> 19a49539 6b9ebd36 e6a9b83f", - "a6ff6899 560ce4df d287ec79 -> 0cad0949 8d9959e7 57120eae", - "d9c6e66e 41282e41 e8869ffd -> ea98c1bb 6540e695 56169b6a", - "e5371b10 e8539210 8b64c8e0 -> d6bbf583 82d998e9 769f75fe", - "2c421a25 63369dd7 86652171 -> ef680c2e 912b7c1d 70171057", - "afbf449c 67a68464 9c35f0e5 -> 68fb67c7 f41ef2d0 a09c4f0a", - "720460db 143a1978 d8171e35 -> 90ab2817 d4fca390 c5fd9d6e", - "6878e782 793dafa5 3f4b20ab -> ae7409cf 5424ad50 fa1fad13", - "e1273be7 4f37dbaf cae69874 -> 8fa1ceb7 77546ed5 087ad93b", - "1daa5239 b0e26945 9039c979 -> 7234d2f7 d2ee54ca 460d0aad", - "6309f157 c8f43bc2 6fb984b9 -> efcd8573 733f24d2 d3bdc59d", - "f6ffc69f c5b62eac 79863517 -> a093491d 290a6a4e bedfb5f3", - "d5fd5271 7bc86b3d 1903029d -> 6a195bd7 64db8239 6e441fd5" - ] - }, - { - "glsl": "ivec4 cultmath_pcg4d(ivec4)", - "tolerance": "exact", - "cases": [ - "5282da0a 1c0b9c58 446e3e11 5a6d8498 -> 7ad5acf5 bfa99213 1ddf75b7 2fd1385c", - "b347420f bbcee2eb a36d7978 d688485f -> af6e5c04 c30f8fb0 f570b858 75b760a5", - "79cd3223 77c753e6 3b8188a3 1608d623 -> e1a2f55f 1841915e e83ab622 3a149c5e", - "4e59a8c7 e8832f75 7f119d48 92091a7b -> e42dd7fe d6c6477f 4603ab4b 42d5a384", - "d4db7a6d adf18936 62ee955a ceb4a8d5 -> bef3459e c1aab385 a7e110e3 e5fd57de", - "51f9fffb a112cfe3 ffd372cf c71a7583 -> 2213da42 afd5ecda 9ffb76f6 cf98837a", - "54c3ba3b 44248f4a 8eedfe1d f2215ee3 -> fb95d9ba 9d99cf40 4d16ef35 4b9c1b45", - "7730347d 0c397af4 511b0861 281ad340 -> ff979306 253e5192 cdc0d38d 37ee9b32", - "0ff04e1e 8b81fea6 849b66bf 32515267 -> 0a5bac11 4cc7ed11 6a7c354d 468b80e4", - "00e3f563 95e89d0e 91556e7f 853f16c4 -> f5d15e45 858f318e f0bc49b4 384748f0", - "af84d765 83c75067 ccfce930 bc410570 -> 03ddd9d9 931d8c04 6d68a022 9b68596a", - "88213420 94a3089b 7c3d52a4 7d58e2ec -> 0d8a0142 731003be 9752c542 dd18dfc1", - "df8dbf10 7b28b79b d9d6b6ef cf51742e -> 76dd6ba8 58583b48 2576f30a 14030c6e", - "6271735f b74ad6b1 8d25c33f e9bf790e -> 2a2e26c5 cb3b3ea3 9f6c698c 98500915", - "d9a2c34a 6a926262 f2c794d1 dd71fef7 -> 6f081526 c8189c5f 1ec7b529 75fc0142", - "b45ed9ea 5ef64dac 5b8d9457 8ae6ee1b -> 6cf7c320 a2eafa06 81907499 d17bd088", - "2bfa85a8 52823385 0fc718ca f276eaad -> bc5ccc5f e9d8c788 09062b99 1b75741c", - "3abb1fa7 f8229bde 5ba89d83 a4a756de -> 6264a739 c8c265a9 631acf48 559517a0", - "c91d2896 1b7332b7 f4549636 3b507a09 -> bd1c4622 25744196 1a67b1c7 ab72607a", - "9931e8c0 dad4b987 031a2340 cdb465d7 -> f416c46b 5a4d4c56 a64bbb34 183ec8c8", - "5db518dc e43bec5d b79806df 5c794b4a -> 509bc767 5fd3817c a38dfee9 4d3c7efb", - "b501f8bb 2af63d40 ca11685e f0161636 -> 39f132fb 395ef884 d8c0b288 68dc541d", - "4af27256 775e637d aaf24fbb 7efabf6e -> 784a235d 22b03af4 cc234186 ef049054", - "99c1fc50 7e8061f9 9b36c9c7 6b509468 -> edb0f656 30358476 12bf5aaf b8c85d7a", - "3c13e6ef 027fd32e 9fc3b25c eb7359e5 -> 4717f4c5 07b36df6 527546a6 1296c299", - "dd5cb7fd 58b82ecc 6cb148c1 d3485271 -> c407acb1 e73638b1 6328708e 918ea277", - "8053b977 cb1444bf 0b0eed69 1ce2e020 -> 1968683d b1238fcd 9c96d867 3eb9f8fa", - "c0ebbf59 94f244a7 cd8e5443 379f89cc -> 13f4f0b9 84cd4264 27132526 787a10f2", - "10d7164e 62c50323 c026be33 6f64772c -> ac124381 5bfaace7 b2725bfb 370e1266", - "928af7a3 c63246f4 875552fa 27a1b6e1 -> 8bef317c 348ed446 3181c5ec 968a88a5", - "bcdbbf33 0084a1f2 58bf2c79 d2c11ea9 -> a1bc1733 010337cc 7a7633f4 1553488e", - "7909f398 a17aa335 e100d13c ac80e208 -> 959faa13 56ce06e1 c3736a41 fd0a3e2c", - "b8951719 8153573f c64d732e 649bc077 -> 7fba3d15 e94fd37c 3e4f360f 4948f02b", - "66260a77 13a36c6f e3f31fed ec586ff8 -> 1c7911ef 97088df5 e5f5a261 dd7fb3a9", - "a030a2e5 ea983603 a43c3f21 6493f30d -> 4d3fff4a 2335a34f 8e5e0cc2 e64dadcc", - "45698d2b 26f7d04a 13caef8e 21e6597a -> bcafa4c9 7dd9b4ca af758ef0 6eb2aea2", - "1dee7bd5 f167ab53 70ca579f 1013e6e8 -> d7b008ed ce6049fe 51b42d6f 1ce2b32d", - "756f9f3c d6e755e6 a96b4cd1 4a2c6dc2 -> 6a15b875 9d999a60 de57da23 e0a8a067", - "6286061c 78fbdc8b 2698d156 6a972451 -> 6a8385c2 6b6fe948 e2c0711b 83df9559", - "c92ee3c9 cb60b2ea 65be195b 79910a9e -> 4a32c4c1 890e446f 05c2ebaa 70ccf0b9", - "ade02678 7bb2d7c5 38474de4 a12d175b -> 756a932a 43693bc0 7fd1f5c8 01d2b381", - "113360b4 62f6acc5 7f482b22 aff5bc7b -> a1c89f62 09d46599 a1660b81 c0224054", - "325f478b 98da5a75 1d9d60f9 f524644c -> 7c25240d bac1a5f7 85979857 be82e09d", - "08dbaf86 d98b7e73 87067072 af4fc238 -> 5bb8eb7c 8fcdbc57 320cf6a9 93856036", - "866862db ed66e00c e8154a0d 861cfcdb -> 1d108255 b87cdf67 dccadcc5 080f2ded", - "cfeacc1d 6c84866d 1822252a 1fc1e884 -> 901db5cb 96be0a2b 8501815a 1cf438f0", - "f7fc9173 f538700a 33ca6f46 31ef6bf6 -> 94597f2b e88eb156 92829450 cad443fe", - "a8ac9c4a 1fbe5caf 0fed70b9 c6c30f13 -> 36299106 48d1dd9d 0c5d7f73 f4dbe4e0", - "f1b6caed 6f037bf4 92be265b e61eb67b -> 925de2a4 a19fb7b9 2c0d476d cc1df6e6", - "7aea7c1c 54cd9f27 c8561416 f54c7b45 -> 92365952 215c4fb8 f5aa8dd2 b0ba0428", - "4fcc587b ef46c8f7 48257f73 d94ae4d9 -> 7e63cf39 ab729ef5 e2ad4737 e9a3ef8f", - "d8638ecf e2edafec fe2bfb22 1c36a31d -> 0831b492 1bea5992 cf54fb4e 6c8f9ded", - "f27794d5 3956296d 12f88f42 b64bb703 -> 3f8cf2fb 83163a42 988b08e2 4cf809c2", - "68f2041b 76061dfb 1fe0986c 89b884b8 -> aa47336d 6931496d 7077ed4d be490cc9", - "b1d656d5 87134b98 caa2f3f4 7620d1d6 -> 5a72edca 0be5a253 49a14a37 20235a80", - "61c20733 7e1fdccc c16dc054 0ef8e123 -> ef695fb4 3175faaf a0499058 262060b7", - "e135116b b6b06642 09e613c3 8c18eaf4 -> c0092a9e 0c399557 4a257703 c7024b26", - "da35ea0e f2cbc22e 69b985ad 6508cd1f -> fd20627e ac3b2038 1634b7de b1ce69b1", - "919fc283 70e3dee3 383d41d8 cb5e1b39 -> 29dc8128 2c194a2d 5d03112d 06e16f00", - "381d6349 2de8fb9b 841a4245 923360db -> 41911c83 eb8f8c3f 142e9840 459101c8", - "6b01c8ce a60210fc ee3832a9 0a3112bd -> ec906b30 7e44d625 bc150b4c c00ad8fb", - "db085ca7 7aa4fbdc 35e2712d 44d00bb5 -> fcd31f00 53afe935 b8b66d7c 9109e5c5", - "faeeb6b7 e5c61c99 96101d6f 11834403 -> b1e5f4cf e77920a7 46c35726 de09d261", - "362cc992 aeb1ac83 4d1f864a 59e10039 -> d52752a2 2a53cbfc 83d702d5 84e72a7a", - "768db913 63290caf ac11b172 3abd3cc7 -> 9e84ddd8 5f3349b3 50438358 c0c53e0a", - "7eca16d0 43fda921 01229571 148f4afb -> f3c0ba41 f413863c e744d700 43877b05", - "ba0373ac 23cd2f93 26e044b4 242e6017 -> 2582718c a7b93517 55c437c2 c3fa8c34", - "1ac2541a 7ee5207f 1b8d7104 0601a0f5 -> 95663f54 b843379d f0a485a4 9b3ca6b0", - "b6bb09c7 a58b0542 44ccefa5 a01884e6 -> 1acbc07f 35aa1515 16450d35 3ea19625", - "89226a17 c93300b6 9dfa1477 21e0c7d0 -> 4cec37bb 95cddff5 24b1b02f 59490ab8", - "95b16d69 c6e31096 273b6c9a 3dcfa91f -> 61f0e1e2 7834fab5 76fc0ac0 7e110f36", - "5ae79b0e 22b19973 3111c28a 9a08f809 -> b55f8313 b3fab109 b8109a59 d188903e", - "e83ee951 4bd2552e 092a3636 4b5a774b -> 9496938c 14eb6663 107d3833 a1ebd983", - "1a2bb6dd 536d5520 016889c0 9d07b761 -> c998d4e5 e9ae84f1 6d09a193 9896ba51", - "1519c9ed d764a2d1 51faa799 cd4c6572 -> c1b4509c c3868da4 e0fe5c28 0457f14b", - "582564e6 5be4daf5 64aa84b1 dbf75c4f -> b9d84611 23776268 c825d00f 424dcfa8", - "32be6273 cb93ebbf 3099a36c b69c9d96 -> 7da7be20 6546e2d7 2a023f32 bce2e0e8", - "8a338ac3 38e09d75 3c28c00e c31059b4 -> 8a776419 961fd3d6 0e26a9de d4be8b0d", - "c4cd7011 f8260d1f 7f37efd6 21b7d833 -> 2dc88384 1c365a2f 88cd8aa1 092732ff", - "375b076d 13082281 01ddf9fe a60a1686 -> 9100c292 9ec2d71d 1d9a973c ae4e018e", - "2aaa25a9 5b6c77d5 dc6adf12 924347ee -> 3b6598e5 3193c16b b1098a0e 0104ee3a", - "62f42577 649a0f3f 85eb50d4 8279df08 -> 5f04ec68 2bfdccd8 86fd3659 70849337", - "a0d2db98 949078d1 3b19cb6b 4fd25909 -> 92f1e3a1 36347a41 a2f62a5d 444dffc9", - "2162a744 bf63bde0 dc54e219 f5523c5d -> aa6a7d14 438e0235 cd0b05e5 985413e6", - "208697c3 d2218267 abc7a900 a0aebb07 -> 840cea27 a404dbac f276fc15 96c5db6c", - "e9617a19 de39eacd d9098bc6 6ab71adf -> 0900a09e 1f97afce fda6279f c6b54dbe", - "149d5331 f21fb8df 3948d902 1c1e2d25 -> b4424b02 fa307130 d62f9ba4 7e69ad27", - "3490b333 e3149cfc d59b430c c544945d -> a34e4c26 ec4d6fc0 325b9721 c9c56f42", - "ee9e2412 36f78e98 d3b3864b 54483f12 -> 321925a5 ca8656d0 10fbddaf 1552b3e8", - "79ad3019 b64f3f27 7d8853d2 ffc8953b -> d6c6dbc7 1cbed898 3e96dab3 cd98d1a5", - "9b16d0ac 09d8dc11 b18a503b e834c3f7 -> 5433814e 6859954e 6bb45486 4cf9ade9", - "ba758841 0335009b 61b638ff da332c14 -> 59a20b9a 9b516939 5bbfea6b ff3b2223", - "6eb7fdb5 ae398ba0 1342233c 30e3966f -> dad59afb 31c9e3cd 27ef90aa 8e041f31", - "163f4d5b d0cdab2d d00a1e1a f22c972d -> a3c9045d 45470ab1 274817bd 24c64240", - "34072e17 6f0ba764 ba925344 38287ed1 -> 91981422 8e2d0f16 4d69ad42 fe15b9ca", - "7bbabe2d 52e19288 bd749374 7ed54f61 -> 7ee7c8a8 63dac721 bcf5aa45 b99a95f0", - "75712265 dd119ba1 e51c6b9d 43e6d230 -> 0591ec4c 29e8ba3e eca3175c 7fdc6474", - "cd776474 dd1bbbe5 cd64161b 76ea1322 -> ea055805 92fa2918 4d52d433 080dc6b6", - "14af5820 6bf29009 e3af3925 fe15afa0 -> c4b44ed6 923820bd c0e2fe04 5c16d243", - "62ff67c7 e84a442b 7f697e0e 0c517980 -> cac0d45e a1e19173 10e6b067 d4430ff6", - "2e7f6f57 2899c04a 9876994a 2d031612 -> 84e73b7d d322fbe3 16e825e4 902abffb", - "fe24649c eb901091 a14c69ec 83084cab -> 5028e70e 76165091 4370066c ba317a88", - "e6d27991 751a609e 485bf0e4 ae0004fc -> bf5bc4b2 afc4baf1 da534e52 127a294e", - "ff918c9d 7f61056e 551134ec 1334a0a8 -> 291c5a91 66115545 e7015941 2801a6f1", - "2eaa7c84 72a181ae aed966f5 ac76ba08 -> 88e6bee7 ead08c90 25d46f6c 7d8f2ccc", - "0e4b4013 e5e7cff3 4a645984 f1937286 -> 6bdd80d7 8e1fc98f 05a73bda d3c4764c", - "253b23d2 69fd033d ce0082ef e66b2478 -> d79fab57 eb084e9d 68c48f32 4c2b218b", - "6ee197f1 d2d1553a 2c11f627 8dd0f795 -> f2515c92 ef8a9e9b 4a1968ac 86e1de6f", - "b6c717fb 5bc73a2d db99f3e4 cf2c342e -> 09147e07 5d693252 a02cf3ed 8d403645", - "44459fe6 870e29b0 b736ac14 4c387fed -> e3b47e33 a6ce3e6f 9913522c f1537946", - "2761b359 ac8a6698 56bf4545 596f40ca -> ef131a63 e03ffec0 abe43828 b14e4898", - "275e9c26 fd274103 e3e1b5c4 c2d5999e -> 606948a3 4d7a37ec 36323cce 52b798a6", - "cd7cb5b5 76aa5627 e44ea083 2791cde3 -> db848a31 7cf06923 e898b738 a394e897", - "9b1874d6 dcab07b4 0c228cce fd2b6886 -> 6bede8b7 5339eab8 6db2e154 26b06107", - "45c466e7 f5a68d76 60dcbf71 959ff269 -> 6f283761 aa04c07b 9587ac15 de39703f", - "2f91f0c5 899e7dc1 08649d6a 33c24733 -> 33472e6a c1e69436 c77d18e5 d517f426", - "b14c6248 712653e7 1b7266ac 6d447a3a -> 38729db4 36e29259 b7362c68 865a93a8", - "0bd75d8c a591ad33 0845102c 1d738c97 -> f6505c2a 0fe3e1b9 7595089d 71345827", - "dbd10129 869ab4b5 1774ad8b 791c27c6 -> 2bc46fef 143c422e aaef513f ed0f4e57", - "91673066 11d1372c 7a4aecd3 ee66d5fc -> 784f3223 0a3c365e b16690e4 a5cf4f45", - "665a2a9a a89224bd fb3b1693 4152746e -> a9e6a874 4b47d58c 40081a3b facc6484", - "c90ba92d 6cd16d28 586ad7a8 eaa6309f -> f94d9a62 2331ba6f 1b528c70 414185c2", - "eb426bcf a6cc8907 7844ce52 0b02d246 -> fcdec043 76c7e9ec 10203859 6f7acd61", - "da2338b2 fec858db 86fbdf31 3c6a5771 -> 3c0455a5 16ce0123 e7d88902 e23213f0", - "d8215807 a9b75724 5bdfec90 2cae7567 -> e45cb24b f43a242d 9a2a2318 993831af", - "9b3e9090 40f1225a a84fd17f 273f4829 -> ecd06c53 608ecded a3da6b51 91cbde9a", - "bc4e58c1 ab3d557a 50fbe11e 85075cc8 -> 87774758 912f1b90 7a8c6940 e6d98263", - "8a2559cf b8b32990 ee338665 41eaee1e -> e4f24cb3 72f816c5 53bfb387 e886d421", - "e8c62930 8079ba7d 57749143 20643c60 -> 8c4f526a 8ebc22ce 4f54c10e 9b4c294f", - "e7c051fc 7d8f4a1c 7aebabaa 3281d38c -> 160cbfae b3cec701 4635cc17 f2cfb8f3", - "4a3cebe9 7eb548d1 d0fe6efb 10ac2455 -> 6026dd9d 55e66f66 aa2acf35 0ceda93f", - "93c7c1f5 118cf185 9702e790 7f5e647e -> 2fc13667 9a90d096 a0425aa1 8fe7da1c", - "8374b1c2 2c96a87c 5230f4cb 9698fbca -> 36c7e0ab c45e3391 fdb32865 623fd8a1", - "8ad72e26 1d1d1b67 31b92656 d06e4f16 -> 787d3c84 99aeedf7 5c995c41 7ceda439", - "e545fa57 490bc96a 00363b8b fbd175b8 -> e3870e5d b44677e2 541befb5 4cac3427", - "8582bca1 fafe479f 839ab9dc 7b768ce1 -> b5cb86f0 19f97580 894b6aaf 1399a1ed", - "b755cba0 3d4343b9 1a9baa7d 01f49830 -> 30d1aaee 1f6954a7 5f6aa06e add2ffdf", - "a90af28a 91b1bf44 69f0729e b922eed4 -> 2ef656eb 19142fef 6f82fcb6 012a359e", - "7c399b5c 73ea0db4 afa60958 659faf82 -> 8a2631f4 c4d7bcdf 26af8087 68bdd3fb", - "09927ccb adf67c91 cefc669c c6a5d68d -> 03c7dec0 a9d5c34f 13d89981 dedc2dbf", - "8b2787af 404913e1 fc193279 140ca8b5 -> 2852591c ebb9566c 6564b827 9b4b7135", - "8ecd4ebf 7a7b5a79 70259acf d9c429d8 -> 2deea220 13344894 3347001a 0280e7ba", - "bfed0329 2f6fa99f 1dd61b4d d18008b5 -> 22e9df47 ac1d9513 3efac874 fce3db23", - "3219af89 9c67d831 ec0e76aa 9ccbff38 -> d4e6bf82 595b6fa5 ffb01720 629d153c", - "f0645031 49da137f 476fc831 27275f44 -> 743ab7ea 1612c403 5ba7fd22 122c9057", - "b1280a63 fb5ce240 cc8d5de9 d20e281e -> 1f6db4c8 ca36aab2 9c236609 c4d7171a", - "89d1766e 0b2de9f6 f1b1ea68 ba6d7278 -> 82a7d95f 0ac76459 5a812dfa 6dbf8ff2", - "903cc9d0 67e617bd 5ecee47f 20cd6f90 -> ff052882 adb1e6c9 64220554 7a30211f", - "ae5fd183 d85b4d7e 845e150a d4ab60e8 -> 9740c96c c261c51d 486ff70e b74265f4", - "cd33d3af 4aa8b234 00fda026 98b66a46 -> 1f10cb4e c384d793 2c00a26a 44048ffb", - "7139f927 0802c135 2b85c76c f516c756 -> f7b6bd80 979e9e36 cd773471 170b6f3b", - "45530a5e a415f106 44f73221 a4fc5570 -> f129955e ec910ed3 fe1e8755 6e518ebe", - "e1a25abf b61a6716 06ba9ab5 b78b6c9d -> 8efac9a2 66618d32 cfed9ad7 5e055f5d", - "cc0f82f0 2443e17d aacf3094 6e3a1a42 -> 7a39b43f 960e2bad 3d52ff58 bb745e8d", - "c1bcb9a3 73810351 0dd89cb8 f106c790 -> 824b423f c2eb300f e1cacadb 8bf4505a", - "565ad393 1fecf88a 815b7df9 4e3e80d0 -> 0a947096 8de235a6 18f3a79e 2768a62e", - "1a997001 bfb29ec0 b6eb6902 7cffc79c -> 8406a0ec 006fc954 4e97519c 4d1bc88e", - "570d1614 ff440fdd 981fee84 e56ea13c -> 4f1a9378 41855a1d ac00bc33 d855d7ad", - "9397c12d 639fa5c1 4eeb5f75 2b23faf2 -> 02cdef6d 60be8ab8 4362437f 35590005", - "c4d51a8a 842c3dbb d73b2394 e3048972 -> 6eae9ffe 286d78b6 58ce4a7f fe205a23", - "d64649cd 7e178b01 269a25c9 13b46f4c -> 76cb078c 350c30a0 b055c892 d56598bf", - "672bedcb 684024f2 6b65123f 5d9c2a06 -> 88706321 6cb68bb3 bec1c0ff 3e618ffa", - "e2aeda6d cb68acf1 25d20d34 de8b95ef -> e86305c3 2190cf33 813be083 338a5c2d", - "66881f94 8451632f 19473d9b 7fc347c7 -> da4fb4d0 d2e14ba7 bce01702 63eae04c", - "b098ade7 f62c25c5 8bdf4d5f c82ea272 -> 893cdb27 7b1d4d96 c39e5834 1a306784", - "6b6c9960 799f8ee9 cc89b56d b9286f62 -> 4a109aab 1c2a263c b1716b79 5244db64", - "d932cca0 3186f0d0 72ddae73 04acbce0 -> f1cb01e0 9d6c7299 e61a13f6 c22e0bdb", - "126fade8 5cfc954a c44e04cf 0fe108de -> 177bec91 79d4bc37 5e87ad1e 8cffd36e", - "b4ca68a8 adf17e01 5197cdc9 8ffe1cad -> 702b5b8f 9811ad90 83c9454b cd14f477", - "f64fe856 1416dff4 8c2c8ad0 4b6cb5ea -> 9ed01ead ae52ebb5 7ca8f3b0 aaf0f814", - "47392dc3 e221f9c6 7ca0c068 c34599e0 -> f12187b4 849dcdf3 66c91041 1dfe2fe4", - "51906928 218c4b98 7a101493 7955aba1 -> 7d5a5c5f 20ea08d8 a641702b 145a77f1", - "2a965667 c74316fe c8605b1e f1d89058 -> a05d17be f295d20d 7c3ce107 80e712a8", - "d850b6fe 5d934f8c 09611d3f b78cc316 -> b98d8407 2c469e19 429bab1c af03ae27", - "cc382b64 aeafc65a 312b2f7d 3c637c26 -> e55dcd82 611b1c17 f949afb2 9a2698fd", - "7bedaa40 4397830b 0813e4eb b3cb98e3 -> aa71f805 6fa22999 a53dfa88 417d68bc", - "063a0097 40c45784 9b3aff47 dac5ac27 -> 99825b64 63597d19 6e3f82c6 f3323b63", - "0dc7efb8 59e6c848 c5136ef9 d771c85c -> c79fa76a 9033767d 5c89ebee 34c98f22", - "fae614c5 bedbac7f b2084380 6b38342b -> db81ec9f 2316c32d e56902df 7a552400", - "0437d631 7ee08fed 6e182158 8ae6e212 -> 1eacb2dd e4848c71 91e44390 15d21a08", - "e0f1f1f9 92ebfe5d 588db76c 1028c378 -> c1781c74 f9d568c0 da4db30e 4863f832", - "a517b742 11faac16 cb9bd0b3 77c925bc -> 5d2a9dc1 0ef43102 d9d09f5d 10de8873", - "886f0a86 7ef0ba6e c60e9846 1c706505 -> c113e1b7 3f7cd5af 3be23b63 bc9f0f4e", - "f384b7e1 d0ffb35b ae421433 d88e97fa -> 63486e63 e02093ab fabf7741 359d0fd6", - "2b97e571 8dafc2bb a3a79dbc 5fb0a2c7 -> 77fbb227 d54703a7 cd19bd4b 7517aeb1", - "1c75c3ee e0fad0ba 479863ba 67e72f86 -> 703ad6bd b2988cc7 0120d706 a3b4fb2e", - "0e3e0c7e 1fef824b 0b2c0f8c 8d57d9ef -> 6998ff94 409e2508 8088847c 4c48c9f0", - "a94536fc 053258d8 99c5328f ee9492ea -> b8f98a9b 887392e5 e60bcd64 8d355b52", - "14554841 9b1db952 38b4f399 a9d71be4 -> 95d850ff 8bd2ed39 4dc068e2 e0a0569f", - "d45779f1 c100666a ccbe4028 650e8d08 -> da7bdcd7 08b480e2 536f0d25 7cff607c", - "3c91c929 af803e03 9235a639 787f162d -> 1de71482 a93a24b6 acff8728 0b587d7c", - "3aa51470 8ef96605 11ae3dd2 f65bfc48 -> 81caf356 3272e72c a5ca6163 c6b9a903", - "4c8f8d8a 82243c09 75dbc15f 207db1b8 -> 90afa019 5e91b080 58650822 a83dbd27", - "76366575 c8e98d88 5aa426d3 e67aa0ea -> 532d85c6 db7f31ef 6379c163 69f408f6", - "5b5e83d1 887d0a6e 9f14ccfc 5f6412e3 -> 047dfcd1 08004eaa 4db16230 9a1851c3", - "15d0702b 4c71e057 c0fed737 b0fddf05 -> 3b8f0dd3 b837e8d2 fd839da6 3f0b5b6b", - "056de593 f0992071 0c6394d7 c41e8150 -> 21ddee60 093e5822 6de119fc 8c4a3db9", - "354ff595 f0d7c33b 0d9bfd09 c8b001ca -> d8ae99b2 16d78d9d 341a5dd3 2e0ab794", - "0c03bf44 408ccd92 3418ee7b 0a1f9bed -> fdd6c4d1 4a5d1fa5 fce27ae1 d5b20494", - "8d8d504a 23786d33 eba1a599 e0cadf08 -> b229379e 2a39483d 7d4f3056 84753821", - "8fc2fd79 76ac40ad 074ad969 4017db5b -> e361da34 447940e0 b3412315 3e18c699", - "e86c65e3 a4e2cf75 831b71e8 bdf92447 -> d05970c8 dd49c53f 95cdceb2 7eca4bc9", - "e461dc8f f8d7ea02 864f3ade b40c4c7b -> b87309e7 3eb0ac45 767e8ab3 35115f4d", - "49d52eb4 6ef84d86 084d4274 b89ccbf7 -> 395efcb6 0cfbe646 4c10b5d9 74c764b5", - "aceba8b7 3e4e33bf 05b8af3c 1ca8820f -> 1a92e3e2 90f7652b 28c5e666 56d78311", - "9b8cb196 d95a7510 1e19ad0b bc61cb64 -> d5da5cd3 40ba3204 333086c7 e587b0e7", - "93cdf082 f8b083b0 f9d63982 42480da0 -> e40ab36b c1c14f97 c1a9ca00 617d9f2b", - "94e9e30c c325d283 b6ddebaf 274b91b3 -> 6349e2c7 34d6f6c8 beab0aca b27fc31b", - "545e331b e4729c81 728aa8dc 13b2d102 -> cccdefb7 7ef5adb2 42f6dae9 e753fa3e", - "f429fd30 c9fd4f65 6a237100 91e2a50d -> 1f2c3d51 9ef8b01d c06b6843 65c176dd", - "0b45e840 8e0765d8 ee5b9d5b 21d452a1 -> 66e1fe58 c5db0a11 6f23c9c3 65425b45", - "ef18a39f 9483f05e 73c67486 f538b6e0 -> e4a93057 d8f6eaed b7b7591a c6389a96", - "96579849 bc06abc3 800f8253 4f0f2a37 -> 3ee30459 1205ac85 5a642d79 47743cad", - "89a5e40e 6009d2b7 b1438ea4 75509592 -> affd8955 faf477c3 070cffad 14640659", - "7c57ddbd d2df2bb1 6ff49790 6cfb5885 -> af1edfae 2e861d59 f3aa028a a5aa6aef", - "114ac4c8 18cdc7b6 8007607c 88c8f31b -> 9a056093 cc11714f 788bb755 ab3fe67d", - "28776f6f 7f1463ff 6fa2d7ee d199301e -> cd6f077d 3d99ae75 036c7c00 2bb33c9d", - "5e4f5037 f819c66e 84867437 80673c06 -> e9dec034 cec8a966 7b15dfa1 5f2cff58", - "69899795 e1146731 3720f133 ed6e7ae0 -> 648d8be4 e5f39fe4 a79c47cb 0224c067", - "3b0a773c a6502f27 011b48cc 00c4c0d5 -> 674a9196 b1f88c8b 2250768b ca418f2a", - "dae51200 2a739e7c a5892215 47d718d6 -> 06ec973a 9d191258 d55fdb75 ca0da93d", - "9fe3eff0 3d7449a4 212502a2 829eb72b -> 5bd3d6bd 37bbcd46 b139d3c3 23c40c5f", - "b26095ce 2a26e41b 5983c1a8 8f8cb3e7 -> b3902532 0074b0c1 c5efbab7 d0e20781", - "df14f133 f8ecd5fe 2972f478 70418eee -> b591d253 8c940ba5 bda7c20b 39f587e8", - "8f898707 503779c1 2475a636 a31ac374 -> 98a86463 f9c71b4f 19361c17 e876cca2", - "6c2b0600 05278489 ce709a64 1f7828de -> 7d52b01c a4a2fd53 f8c72c62 3e42ec9f", - "4dbd36ca 9ae71aad eec83595 2466ffcf -> 0a8b4859 2bf014fb edba9bde 5691c099", - "b7fdb6aa 7a54cea4 2c1fca55 b03ddc0a -> 952023ef 5eb2e381 bda2b278 f3419f68", - "b47d925e 0e42e4cb d88e88fb e2142621 -> b16f5cd8 ad6b9622 eccad7c3 b27daed1", - "048c70b7 a0348557 0ccbf3c0 07e45a95 -> 97d76341 489991e2 01bfb0f8 b1584b49", - "e100f05f a938de7a 16959b0b 11b8d749 -> af6fe1cf 3825c46c 46c66ddd c347dfcf", - "65947844 84fe52f8 6a0417e0 f5c92714 -> 8c757528 66e8f2bc b44dc8cc 9b6d0f90", - "55f45c69 d02578fb fa6abd70 1bf00f73 -> 346c84d6 c0fc7e0e 147a75f2 215c8e80", - "869d8919 1b1d2ad1 5502c583 f9a47e0c -> ac817ccc 9469732f 6f9c0430 b6a6d103", - "96e47c48 7d0095ca b37460fc b2280b5a -> 7418d18c 4726c8cd 63dd9c1f 7a914238", - "f7352f56 31951246 c0a45a8d 80bd9438 -> 19719c23 647125d6 fdce1303 25d0d1ff", - "699967f0 5dd8e4de 453bd06f 077da4e2 -> 48b4a01a 97a53e36 5a8d3cd1 88b190fe", - "27c19413 18c22ccf ca85376b 66a57345 -> 33e0c86e 2b5aa53b 2bc94cec b89717ee", - "c94b7de1 b5a5bbcb bc1afeab 83b35987 -> 50c03a8a 550bd10d 344d4651 f19a35d1", - "ad1dffca 0e40ecff a94673f4 54043ee0 -> 1b23c381 3fe21451 bb7878dc 703b895b", - "7c8ff5e0 33ce219a ed3f2658 f24fde8e -> 37b50f2f 7e79f66e dafcad5c efbdb9c4", - "9a3bbdad 40ac92b8 24db536d 456fb1a6 -> 827ba5dc d62bb280 9b42f92c 7abde2e4", - "6bf538b8 33acf0d5 dfe4323f 7fc1d843 -> dbd54ac8 a818485e 2bf3b9be 3274bcfb", - "1aa68eb4 e6d0014b 6297afec 3ff6e541 -> 46eea90c 1756eb3a 08cc2d93 92b807f7", - "6f62fe4e 1e334380 40832c20 6239e018 -> e994460f c57f81b2 15c7729b 0856ac3d", - "e59a6648 e90211a3 9ee3e09c 737b88bc -> 9e0fb8df 50e3c6d5 a1b3ed44 3c45c1f9", - "907fa4de 47055dd2 821e5455 6ed09732 -> 57b5efd7 2becb71a 977d9680 994476a2", - "57b478f3 dc96fe5c 01198456 ea54c923 -> 74a181f6 32afe5cf 161b86c7 219cd49d", - "26593f3b 19c16380 14e177bf ac09a935 -> 7fed3db8 704ca09c 052cfac4 23e68077", - "5a60786c 831faf6a 947db340 994b698c -> fee5a8bc 10ef1615 30a63306 c6865aaf", - "52067ff4 df349777 0d7db081 78514be8 -> c8232746 58471f94 7c4cdb54 581447c9", - "1b0530a8 064ffe64 052ce14c e4ae8542 -> 873e226e 86daead9 e31dad7e f13fc486", - "3c6c268e 373b9d97 a6991ed9 0aebcd32 -> e8c3aa26 d8aa9b73 0d9c4f7d 47349a2e", - "25d1134a c04144e9 3fde0400 f17291f5 -> 1b6cd397 f624b69b d020f38e c9ff2fa4", - "0548d552 7b3850fb a3670abe 03c38379 -> 164ca20a 96541a1d 1fb1108f c7eb5df0", - "52284f3a ffffa516 611b3be7 c1cd8b81 -> dcf45def 241cd402 6c6c5d66 399ab4ea" - ] - }, - { - "glsl": "vec2 cultmath_iv_point(float)", - "tolerance": "ulp-bounded", - "cases": [ - "4195d92a -> 4195d92a 4195d92a", - "411f5b66 -> 411f5b66 411f5b66", - "c168068f -> c168068f c168068f", - "413cdbdc -> 413cdbdc 413cdbdc", - "4156b6d8 -> 4156b6d8 4156b6d8", - "40a0b4b4 -> 40a0b4b4 40a0b4b4", - "408cea18 -> 408cea18 408cea18", - "418fe948 -> 418fe948 418fe948", - "416852a0 -> 416852a0 416852a0", - "c1447099 -> c1447099 c1447099", - "3f6fbfc0 -> 3f6fbfc0 3f6fbfc0", - "c18764db -> c18764db c18764db", - "413e7cd0 -> 413e7cd0 413e7cd0", - "c1678826 -> c1678826 c1678826", - "417de13c -> 417de13c 417de13c", - "41918e98 -> 41918e98 41918e98", - "c154117a -> c154117a c154117a", - "40a7d508 -> 40a7d508 40a7d508", - "40986130 -> 40986130 40986130", - "c188da98 -> c188da98 c188da98", - "c13f3249 -> c13f3249 c13f3249", - "c15dfa90 -> c15dfa90 c15dfa90", - "3e025800 -> 3e025800 3e025800", - "c17229f4 -> c17229f4 c17229f4", - "c19b10f7 -> c19b10f7 c19b10f7", - "c03976c0 -> c03976c0 c03976c0", - "3fb31840 -> 3fb31840 3fb31840", - "417b72c4 -> 417b72c4 417b72c4", - "40f49858 -> 40f49858 40f49858", - "c13d1aa9 -> c13d1aa9 c13d1aa9", - "c0fa3d0e -> c0fa3d0e c0fa3d0e", - "c1001d90 -> c1001d90 c1001d90", - "3fda0f10 -> 3fda0f10 3fda0f10", - "4191df4c -> 4191df4c 4191df4c", - "41556c50 -> 41556c50 41556c50", - "411ffaae -> 411ffaae 411ffaae", - "c173fcae -> c173fcae c173fcae", - "c0e8316a -> c0e8316a c0e8316a", - "4053ba78 -> 4053ba78 4053ba78", - "c057b8c0 -> c057b8c0 c057b8c0", - "c0b5beec -> c0b5beec c0b5beec", - "c19bdc7c -> c19bdc7c c19bdc7c", - "c141c0aa -> c141c0aa c141c0aa", - "3f9b6b20 -> 3f9b6b20 3f9b6b20", - "41514ab8 -> 41514ab8 41514ab8", - "4190cda4 -> 4190cda4 4190cda4", - "c13bf50e -> c13bf50e c13bf50e", - "3e146c00 -> 3e146c00 3e146c00", - "4182d732 -> 4182d732 4182d732", - "c1918db5 -> c1918db5 c1918db5", - "4107c726 -> 4107c726 4107c726", - "c16e6259 -> c16e6259 c16e6259", - "c09dfb4c -> c09dfb4c c09dfb4c", - "c05d3a28 -> c05d3a28 c05d3a28", - "c0cba552 -> c0cba552 c0cba552", - "4149ace4 -> 4149ace4 4149ace4", - "c122adfa -> c122adfa c122adfa", - "c19aee4d -> c19aee4d c19aee4d", - "4132fdca -> 4132fdca 4132fdca", - "c06badf0 -> c06badf0 c06badf0", - "c1830457 -> c1830457 c1830457", - "410b0248 -> 410b0248 410b0248", - "c11a799e -> c11a799e c11a799e", - "40cada90 -> 40cada90 40cada90", - "4178adf0 -> 4178adf0 4178adf0", - "c130e673 -> c130e673 c130e673", - "3fafa340 -> 3fafa340 3fafa340", - "415abe38 -> 415abe38 415abe38", - "c0f9e8e8 -> c0f9e8e8 c0f9e8e8", - "c1621970 -> c1621970 c1621970", - "415719e0 -> 415719e0 415719e0", - "4160073c -> 4160073c 4160073c", - "c190820d -> c190820d c190820d", - "c13de139 -> c13de139 c13de139", - "41092a48 -> 41092a48 41092a48", - "c1477950 -> c1477950 c1477950", - "4191e30c -> 4191e30c 4191e30c", - "41974dfe -> 41974dfe 41974dfe", - "c10374ad -> c10374ad c10374ad", - "c18bde9a -> c18bde9a c18bde9a", - "c13268a2 -> c13268a2 c13268a2", - "c195f755 -> c195f755 c195f755", - "419ae230 -> 419ae230 419ae230", - "40bacf28 -> 40bacf28 40bacf28", - "be9c3a00 -> be9c3a00 be9c3a00", - "c14ebc2e -> c14ebc2e c14ebc2e", - "4187700c -> 4187700c 4187700c", - "c16d6f94 -> c16d6f94 c16d6f94", - "40932280 -> 40932280 40932280", - "c19a204a -> c19a204a c19a204a", - "3e2a2a00 -> 3e2a2a00 3e2a2a00", - "c17e2014 -> c17e2014 c17e2014", - "3fc74c00 -> 3fc74c00 3fc74c00", - "c15025e6 -> c15025e6 c15025e6", - "c0dfcb04 -> c0dfcb04 c0dfcb04", - "40b43c80 -> 40b43c80 40b43c80", - "4122c0a4 -> 4122c0a4 4122c0a4", - "3fc69070 -> 3fc69070 3fc69070", - "40b57ef0 -> 40b57ef0 40b57ef0", - "40846258 -> 40846258 40846258", - "c0516488 -> c0516488 c0516488", - "c0ad668c -> c0ad668c c0ad668c", - "c140b9da -> c140b9da c140b9da", - "4127c7d4 -> 4127c7d4 4127c7d4", - "c13a354a -> c13a354a c13a354a", - "4167bfec -> 4167bfec 4167bfec", - "c186af20 -> c186af20 c186af20", - "c1511c6e -> c1511c6e c1511c6e", - "40ff0e5c -> 40ff0e5c 40ff0e5c", - "c15e5958 -> c15e5958 c15e5958", - "4165e6c8 -> 4165e6c8 4165e6c8", - "c11149f8 -> c11149f8 c11149f8", - "410d9810 -> 410d9810 410d9810", - "410abafe -> 410abafe 410abafe", - "c14882da -> c14882da c14882da", - "c18d0d02 -> c18d0d02 c18d0d02", - "41153de6 -> 41153de6 41153de6", - "40903d9c -> 40903d9c 40903d9c", - "c155b0ea -> c155b0ea c155b0ea", - "41076a1c -> 41076a1c 41076a1c", - "c0ff8d16 -> c0ff8d16 c0ff8d16", - "c0727008 -> c0727008 c0727008", - "c12ed309 -> c12ed309 c12ed309", - "c108b3e0 -> c108b3e0 c108b3e0", - "40b67bd0 -> 40b67bd0 40b67bd0", - "411539f4 -> 411539f4 411539f4", - "c0f1c48c -> c0f1c48c c0f1c48c", - "416f21cc -> 416f21cc 416f21cc", - "41720448 -> 41720448 41720448", - "c18879fd -> c18879fd c18879fd", - "c028e7d0 -> c028e7d0 c028e7d0", - "c0542fd0 -> c0542fd0 c0542fd0", - "c0d846f2 -> c0d846f2 c0d846f2", - "40f4b450 -> 40f4b450 40f4b450", - "40b937dc -> 40b937dc 40b937dc", - "41644aa4 -> 41644aa4 41644aa4", - "4154cb30 -> 4154cb30 4154cb30", - "c1320374 -> c1320374 c1320374", - "c0218c80 -> c0218c80 c0218c80", - "40a6bc8c -> 40a6bc8c 40a6bc8c", - "c180aef8 -> c180aef8 c180aef8", - "411ffc86 -> 411ffc86 411ffc86", - "c033db10 -> c033db10 c033db10", - "bfc0ab30 -> bfc0ab30 bfc0ab30", - "c15a275c -> c15a275c c15a275c", - "c12c0d62 -> c12c0d62 c12c0d62", - "c097704a -> c097704a c097704a", - "414e2e84 -> 414e2e84 414e2e84", - "419c2e7a -> 419c2e7a 419c2e7a", - "c115cb7e -> c115cb7e c115cb7e", - "4182702e -> 4182702e 4182702e", - "c1655e28 -> c1655e28 c1655e28", - "c0a2fa12 -> c0a2fa12 c0a2fa12", - "4189aaac -> 4189aaac 4189aaac", - "c0fc1094 -> c0fc1094 c0fc1094", - "c19bde8f -> c19bde8f c19bde8f", - "c167e03c -> c167e03c c167e03c", - "4183fd04 -> 4183fd04 4183fd04", - "c1737614 -> c1737614 c1737614", - "bf76f3c0 -> bf76f3c0 bf76f3c0", - "400288c0 -> 400288c0 400288c0", - "c13c800b -> c13c800b c13c800b", - "c10320b8 -> c10320b8 c10320b8", - "40a0f654 -> 40a0f654 40a0f654", - "410be09c -> 410be09c 410be09c", - "c0143510 -> c0143510 c0143510", - "418d6cc0 -> 418d6cc0 418d6cc0", - "c196610b -> c196610b c196610b", - "c188f078 -> c188f078 c188f078", - "c0d99afc -> c0d99afc c0d99afc", - "c12ee535 -> c12ee535 c12ee535", - "3ee82b40 -> 3ee82b40 3ee82b40", - "c14f7e13 -> c14f7e13 c14f7e13", - "3fb78680 -> 3fb78680 3fb78680", - "40919018 -> 40919018 40919018", - "4000f3b8 -> 4000f3b8 4000f3b8", - "41982d60 -> 41982d60 41982d60", - "4129425c -> 4129425c 4129425c", - "c16e8c84 -> c16e8c84 c16e8c84", - "c062d2d8 -> c062d2d8 c062d2d8", - "c0be1bd0 -> c0be1bd0 c0be1bd0", - "bee21900 -> bee21900 bee21900", - "4176c4d8 -> 4176c4d8 4176c4d8", - "408f9f90 -> 408f9f90 408f9f90", - "c155d455 -> c155d455 c155d455", - "c104dbcc -> c104dbcc c104dbcc", - "c191c776 -> c191c776 c191c776", - "c07de348 -> c07de348 c07de348", - "c08f3b1e -> c08f3b1e c08f3b1e", - "40a8b218 -> 40a8b218 40a8b218", - "410c2ae2 -> 410c2ae2 410c2ae2", - "41866896 -> 41866896 41866896", - "c17e8d60 -> c17e8d60 c17e8d60", - "4193860e -> 4193860e 4193860e", - "c186a1f5 -> c186a1f5 c186a1f5", - "417b221c -> 417b221c 417b221c", - "bfe71610 -> bfe71610 bfe71610", - "41428e14 -> 41428e14 41428e14", - "411c09fc -> 411c09fc 411c09fc", - "410ae5e8 -> 410ae5e8 410ae5e8", - "c106e6e2 -> c106e6e2 c106e6e2", - "c0bdec1e -> c0bdec1e c0bdec1e", - "41200f74 -> 41200f74 41200f74", - "40ca54e4 -> 40ca54e4 40ca54e4", - "c1937324 -> c1937324 c1937324", - "c084c202 -> c084c202 c084c202", - "41950ff4 -> 41950ff4 41950ff4", - "41579228 -> 41579228 41579228", - "c0eae566 -> c0eae566 c0eae566", - "4121bac8 -> 4121bac8 4121bac8", - "c1940bef -> c1940bef c1940bef", - "c0a24534 -> c0a24534 c0a24534", - "4136868c -> 4136868c 4136868c", - "41053ea2 -> 41053ea2 41053ea2", - "c1706155 -> c1706155 c1706155", - "c18c2684 -> c18c2684 c18c2684", - "c0e689c8 -> c0e689c8 c0e689c8", - "40ea1f00 -> 40ea1f00 40ea1f00", - "bfcd8410 -> bfcd8410 bfcd8410", - "c03d0e60 -> c03d0e60 c03d0e60", - "c082fcb2 -> c082fcb2 c082fcb2", - "3fd29290 -> 3fd29290 3fd29290", - "40b5b6f0 -> 40b5b6f0 40b5b6f0", - "c018e7e8 -> c018e7e8 c018e7e8", - "408e0f40 -> 408e0f40 408e0f40", - "c0f76cbe -> c0f76cbe c0f76cbe", - "c068c518 -> c068c518 c068c518", - "c1368a30 -> c1368a30 c1368a30", - "bfde5a30 -> bfde5a30 bfde5a30", - "410da5f2 -> 410da5f2 410da5f2", - "c1817028 -> c1817028 c1817028", - "c1523355 -> c1523355 c1523355", - "c19963d0 -> c19963d0 c19963d0", - "c065c9b0 -> c065c9b0 c065c9b0", - "c171cdd4 -> c171cdd4 c171cdd4", - "419ff414 -> 419ff414 419ff414", - "4118dfc6 -> 4118dfc6 4118dfc6", - "c12e6598 -> c12e6598 c12e6598", - "403ad838 -> 403ad838 403ad838", - "412c8cac -> 412c8cac 412c8cac", - "c0ddf76e -> c0ddf76e c0ddf76e", - "c13b2113 -> c13b2113 c13b2113", - "c185030f -> c185030f c185030f", - "40ad4f54 -> 40ad4f54 40ad4f54", - "4071c3a0 -> 4071c3a0 4071c3a0", - "c0c5650a -> c0c5650a c0c5650a", - "c169b561 -> c169b561 c169b561", - "c0879804 -> c0879804 c0879804", - "41576d70 -> 41576d70 41576d70", - "c19a7b71 -> c19a7b71 c19a7b71", - "40399bf8 -> 40399bf8 40399bf8", - "412e0dbe -> 412e0dbe 412e0dbe", - "c0c782d4 -> c0c782d4 c0c782d4", - "c0e964d6 -> c0e964d6 c0e964d6", - "c0e7377e -> c0e7377e c0e7377e", - "411ec6cc -> 411ec6cc 411ec6cc" - ] - }, - { - "glsl": "vec2 cultmath_iv_add(vec2, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "41062738 410635b8 c192c576 c18f17b8 -> c11f63b4 c117f9b8", - "4199a15f 419e2ee5 c09ac88d c097c1bb -> 4165de78 41707cec", - "40a715f6 40eb5662 c0bcd4a7 c0bc9741 -> bf2df588 3fbafc84", - "405c2e68 405c3548 c0e25ac8 c0e25868 -> c0688728 c0687b88", - "c17be971 c17763af c18024da c1802306 -> c1fe1992 c1fbd4de", - "bfdd3e44 bfdd3abc 415d50c5 415d5973 -> 4141a8fc 4141b21c", - "c152013c c15200c0 c09c2fad c09baed7 -> c1900c89 c18fec16", - "c160c98d c160b891 414eefb8 41542c70 -> bf8ecea8 bf48c210", - "c182f2f0 c182e3be c10662ed c10629b3 -> c1c62466 c1c5f898", - "c15947be c13fc916 413421da 413556f6 -> c0149790 bf272200", - "41514853 4151baad 419743f5 419ac89f -> 41ffe81e 4201d2fb", - "419b4f11 41a05963 41423f7c 41480f94 -> 41fc6ecf 42023096", - "40f804ca 40f8d2d6 40cc6ef7 40d26249 -> 416239e0 41659a90", - "c1346b72 c13469a2 c10830be c102f288 -> c19e4e18 c19bae15", - "bfec51e5 bf84691b bf9a2ef2 40c1d00c -> c043406c 40a0b5c5", - "c0f3c9ed c0235e56 c009847a c0093826 -> c11c4615 c0964b3e", - "c1946e84 c193041a c10a32b3 c10a2e01 -> c1d987de c1d81b1a", - "413e584b 416da15d 4183d249 4183d6d7 -> 41e2fe6e 41faa786", - "41825883 4182ade5 c10ef8b0 c003136a -> 40eb70ac 416496f0", - "c196ecc6 c196ebfc c11205d4 c111d6ce -> c1dfefb0 c1dfd763", - "c13d4346 c139d656 411b31ff 411eb969 -> c008451c bfd8e768", - "40ceb843 40cebe4d c074420c 4026ecac -> 40292e7a 41111a52", - "c185d9c3 c1852939 4194c6f3 4194db15 -> 3feed300 3ffb1dc0", - "c115ea42 c103ebf8 c153eac5 c128a44f -> c1b4ea84 c1964824", - "c192f5fa c1919fec 40f37ab8 40f3a588 -> c12c2e98 c1296d14", - "bf820f0f bf6ba1e1 4169bb18 4179b918 -> 41597936 416afefa", - "402e2979 402ebfe7 411b1855 411fd263 -> 4146a2b3 414b825d", - "412a97cc 412aa8d0 40df90a0 40dfbd08 -> 418d300e 418d43aa", - "3ecabb36 3ecb03ca 41270674 412c7e3c -> 412d5c4e 4132d65a", - "c148f2fa c13c94ca 40ba98b6 40fe1552 -> c0d74d3e c0762884", - "c156a37e c15692b6 c16d5f74 c16d5866 -> c1e20179 c1e1f58e", - "4189279d 41897337 419caef9 419caf9b -> 4212eb4b 42131169", - "c0e5179f c0e45279 4187e568 4187f668 -> 411d3f00 411dc394", - "c0a3aeeb bf3b9568 418b21b2 418c09aa -> 41446bee 41862cff", - "410dfa35 4163347b c17fa90d c17f9fff -> c0e35db0 bfe35c20", - "c056556e c01cc2e2 c148378a c13e397c -> c17dcce6 c1656a34", - "41837778 41847424 4178b6ff 4178b8d9 -> 41ffd2f8 42006848", - "c191bca4 c1917ed4 40f41e73 40f42fcd -> c1296a0e c128e5c2", - "4191cf05 419c88e3 c14d77de c14d757a -> 40ac4c58 40d73898", - "bfb20328 bf9fd6b8 416d5dda 416d5e9e -> 41571d75 415963c7", - "c07e0cb5 c072e12b c0a2e77e c0a2d052 -> c110f6ec c10e2074", - "c081726b c0815b15 41860bb5 4186b157 -> 414b5e34 414cb524", - "c13808d6 c138066a 4185daa4 4185de4c -> 40a758e4 40a76c5c", - "40e27e0f 40e2d311 c020c433 c0204aed -> 40921bf6 4092ad9a", - "c16e6e22 c16e5122 c0d36a50 c0d34cf8 -> c1ac11a5 c1abfbcf", - "408065bd 40bf2373 c1947de9 c189c711 -> c168c8f4 c133fc68", - "41352754 413854a4 c0661139 c05f8f97 -> 40f7460c 410070be", - "411907c7 41262c7d c163f6e6 c163f460 -> c095de3e c0771f8c", - "c18830f6 c188309e 4163efad 41708563 -> c031c8fc bffedec8", - "c09e4867 bfce2225 c0b4fc84 c0b0e3b8 -> c129a276 c0e46c41", - "40fdd29f 40fdeeb9 41754a04 419153c6 -> 41ba19aa 41d0cf74", - "40463a89 40473f47 405f5994 4063d6cc -> 40d2ca0e 40d58b0a", - "c0a0198c c07c55f0 c197c36c c197c2cc -> c1bfc9cf c1b74d8a", - "c1035730 c1025490 c0352d89 c031cd17 -> c130a292 c12ec7d6", - "40732c14 4076aa2c bd69b8c8 3ee16899 -> 406f8531 40896ba0", - "4172dbb1 4172ebb7 41547c9e 4154b62a -> 41e3ac28 41e3d0f0", - "c19f2302 c19a11c2 c1508458 c14e398e -> c203b297 c2009744", - "3fb2214e 3fcb2172 4191dc55 4191deff -> 419cfe6a 419e9116", - "c19e5620 c19b6250 408fea54 40900a1c -> c174b716 c16ebf92", - "418cb9a8 418cbafc c1217cd1 c1216707 -> 40efecfe 40f01de2", - "c18fa2eb c182a1a5 c161a3cf c10d64b1 -> c2003a69 c1c953fe", - "41249712 412497c6 4167a484 41683d4c -> 41c61dcb 41c66a89", - "40945f1c 4094804c c15c9ee1 c1388861 -> c1126f53 c0dc9076", - "c08238fa c07c4e5b 411ac812 411ae88e -> 40b3572a 40b7a9ee", - "bf82715f bf7dbd41 41696084 417ce6dc -> 41591258 416d0b08", - "c14781b5 c0cc306a c1978f0b c193fbef -> c1fb4fe6 c1c7080a", - "415742b6 4167cb1a c1846db9 c183c6f7 -> c04662f0 bffe16a0", - "418f3977 418f3a35 4085c42e 40863ca2 -> 41b0aa82 41b0c95e", - "c1003a9f c100380d 40d6decb 40d6e00d -> bfa659cc bfa64034", - "c18955bd c166a72a 40665430 41230a74 -> c159166e c087396c", - "417d0c92 418026b7 c19b1f44 c19b1cd0 -> c064c7d8 c057b0c8", - "bf81af9e bf81a6e2 414eada4 414ed1b4 -> 413e77b0 413e9cd8", - "4196dd70 4196e06c 415b4e38 415b9790 -> 42024246 4202561a", - "c10b74af c10b3a87 c18624f6 c1862432 -> c1cbdf4e c1cbc176", - "41465848 4146c310 c1993c27 c153e5b6 -> c0d8400c bf522a60", - "41931382 419318aa 4029d915 402bf69b -> 41a84ea5 41a8977d", - "410645fd 410f44f7 4035b463 4035ce6d -> 4133b316 413cb892", - "418fa0fa 41924c1a c110e90c c10f8880 -> 410e58e8 41150fb4", - "412c4d76 4169364a 4185c87c 41869bd4 -> 41dbef37 41fb36f9", - "41888080 419225dc c121dd00 c117485c -> 40de4800 410d035c", - "41984be6 419ac696 4087a954 4093af14 -> 41ba363b 41bfb25b", - "c113b155 c113aeeb c170f89f c14d7ac9 -> c1c254fa c1b094da", - "c18703cc c1868c28 c12fb479 c12da4dd -> c1dede08 c1dd5e96", - "41385370 413e8d90 c19f29b9 c19e2eb3 -> c1060002 c0fb9fac", - "c181c834 c1817e58 be827102 3e296303 -> c183d1f8 c1802b92", - "3f06bf00 3f1bbf80 c0241af7 c023f799 -> c0026b37 bffa0f72", - "41928a09 41928def 40ab2691 40ab5e0f -> 41bd53ad 41bd6573", - "3edcc476 3ee9588a c18dfde7 c106ae98 -> c18a8ad5 c0fec7a7", - "c12e32bb c12e203b 4197d752 4197db7a -> 41017be9 410196b9", - "40bc0219 40f6194f c12a602b c129556d -> c098be3d c0392316", - "407288cd 40839919 c158c363 c1589a91 -> c11c2130 c116ce04", - "bf7d38e5 bf4e47db 413c385d 413c39a3 -> 412c64cf 412f5525", - "4183d0e3 4183d77d 3e9d256a 3ea46596 -> 41864579 41866913", - "c0ea7d4f c0e90c91 c1202523 c11ffd91 -> c18ab1e5 c18a41ed", - "c11827dc c1181266 41247c45 41247cbf -> 3f454690 3f46a590", - "3ec7fe6b 3f9dc0e5 c0b73a36 c0b40006 -> c0aaba4f c08c8fcd", - "c0991e7d c099127f c087daeb c08733cd -> c1107cb4 c1102326", - "4117b43d 411ffb1b 418f62e9 418f6647 -> 41db3d08 41df63d4", - "c1353033 c0d0f90a c178a464 c166308c -> c1d6ea4c c1a75688", - "c0494af6 c049487a 41391bb0 41392974 -> 4106c8f2 4106d756", - "bfc68445 bfc0757b bfea91b2 bfea6d2e -> c0588afc c0557154", - "41946721 419889eb 40dd2cf6 40e6f97a -> 41cbb25e 41d2484a", - "c1865f32 c185c112 419fb005 419fb8bb -> 404a8698 404fbd48", - "c181acd1 c181aa33 c197193c c18dba82 -> c20c6306 c207b25a", - "c0c91a7a c0c71172 c199d452 c199d0e8 -> c1cc1af0 c1cb9544", - "c11a914f c11a7e8d c0b9436c c0b93dac -> c1773305 c1771d63", - "c0bb727c c0bb6138 c15de2a2 c15dc1a2 -> c19dcdf0 c19db91f", - "c07452a9 c0735657 419831c6 4198348a -> 41734ee2 4173937e", - "400b1f53 400c487d c00a3b8a 40c8f61d -> 3c63c900 41078d2e", - "c0d886b3 c0d88229 40a49766 40a987ca -> bfcfbd34 bfbbe97c", - "4006c642 401a4e6e c0987e01 c0987877 -> c02a35c0 c016a280", - "411aea3d 411cfc2f c1611567 c16114a1 -> c08c5654 c08830e4", - "417bed00 417bfbe8 c010773e be7c4f20 -> 4157cf30 41780aac", - "c19acc0b c19a5f93 c1910ab4 c19109ca -> c215eb60 c215b4ae", - "c14cfb69 c14cf083 41610776 41666aca -> 3fa06068 3fcbd238", - "40647d1f 4064ae41 c10626e1 c10382a7 -> c09a0f32 c094ae2e", - "406d707f 408e2a29 412c3a12 412eda92 -> 41679632 4175efa6", - "40d95079 40d9520f bf2f632d bf2f2553 -> 40c36413 40c36d65", - "41899fe9 4189b07b 40efa308 40f1b1b8 -> 41c588ab 41c61ce9", - "41906958 41906b28 c04d19af c0301cb1 -> 416d8c44 4174cf24", - "c175796a c1757826 beff0787 befee179 -> c17d71a6 c17d6f32", - "419603f6 419604ba c13a20e5 c13a206f -> 40e3ce0e 40e3d20a", - "c073b3b3 c072e0fd 414387e3 41438895 -> 41069af6 4106d056", - "c1264da6 c0c5942d c190848c c1908068 -> c1e3ab5f c1c1e573", - "c08210b8 c06506c1 bf80b472 40c42dbc -> c0a23dd4 402354b7", - "416082c5 41610c5b c0aa9601 c073c19f -> 410b37c4 41241bf3", - "4152bb7f 4152c511 418928b8 418a5c44 -> 41f28678 41f3becc", - "41641f0b 41648c2d c18ac323 c1062fb2 -> c0459cec 40bcb8f6", - "41660998 41660b50 4062f3cf 4064c931 -> 418f6346 418f9ece", - "41450264 4145067c 40df3c4f 40e01b41 -> 419a5046 419a8a0e", - "400ed34e 4037da32 c127a0e9 c12799cd -> c103ec16 c0f34681", - "c11f0d9c c11ecee2 4180a9b4 4180a9ec -> 40c48b98 40c509ec", - "c0d5b954 c0d5499c c15b6b86 c15b66b6 -> c1a32418 c1a305c2", - "40a0009a 40a09aa6 4172489e 41741aa2 -> 41a12476 41a233fa", - "41064ffb 41093151 c119e54c c1151d86 -> bf9caa88 bf3ec350", - "c14a8b9f c1495c77 c17dde53 c13e4883 -> c1e434f9 c1c3d27d", - "c12dac7a c11aa46a c148b1c0 c148aee8 -> c1bb2f1d c1b1a9a9", - "c0d2d6f4 c0d0e3b4 bfef8675 bfef63eb -> c1075c49 c1065e57", - "c18bf94c c18bf8cc c06e605e c06e5bc2 -> c1a9c558 c1a9c444", - "c11508b7 c11506b7 4058d7e5 40596dcb -> c0bda57c c0bd5688", - "c0e80964 c0410491 c0fd841f c0fd10a5 -> c172c6c2 c12ec977", - "c12333d6 c0641a79 c0acb2aa c0ac5c4e -> c1798d2b c10f34c5", - "c161674f c0caf822 4132c095 4132c313 -> c03a9ae8 409a8e04", - "41581eba 41ab5e6b c145a55d c05c8ce4 -> 3f93cae8 418fccce", - "408aa721 408ac717 c19ea55b c19e8625 -> c177f726 c177a8be", - "c12359a0 c11be282 40cc4174 40e496f4 -> c074e398 c0265c20", - "41806a62 41aec3aa c15f8ded c15eac7d -> 40051b5c 40fdb5ae", - "c19438f4 c18d1484 c0c8c8a1 c0c6675f -> c1c66b1c c1beae5c", - "c193dc4b c181be89 c0e2124c c0e20220 -> c1cc60de c1ba3f11", - "c115634f c10ec7c9 406b2f99 406b5857 -> c0b52ed2 c0a7e366", - "c01a52a1 bfcccc3d 41878c9d 41879947 -> 41688492 41759906", - "4131b088 4131bcf8 c1147fb6 c1147ea6 -> 3fe98690 3fe9f290", - "412fa3e6 412fd5ae c061182c 4002373c -> 40eebbb6 4150637d", - "c16a9f63 c16a9d21 c1669004 c1641686 -> c1e897b4 c1e759d4", - "c11c4fd2 c11ba14a bfe13a1e bfe04362 -> c1387716 c137a9b6", - "413e9491 41520e7f c0b7d2e3 c0b73985 -> 40c5563f 40ece379", - "40ab2a51 40ab32ff c1830787 c1830717 -> c13079e6 c13074ae", - "40c80563 40c806bd 40eca209 4120faf3 -> 415a53b6 41827f29", - "410d7b43 41144085 419bab3e 419bd872 -> 41e268e0 41e5f8b4", - "41467232 414680de 419e8eb9 41a08137 -> 4200e3e9 4201e0d3", - "40ec4e05 40ec4fd3 412deccf 41303639 -> 419209e9 41932f11", - "c0f50a26 c0f4bca6 c089f25c bed6afc4 -> c13f7e41 c10113d1", - "41109ef0 4114e770 c1a1416c c19cf79c -> c131e3e8 c12507c8", - "c1151442 c1150f4e bfb6c7ee bfa41cb2 -> c12bed40 c12992e4", - "c040284f c03ebce1 410f1930 41104428 -> 40be1e38 40c129e0", - "c13c38b2 c13c347c c04a4828 c02d5038 -> c16ecabc c167888a", - "40fcdbb9 40ffec97 c131aaf8 c1317e00 -> c04cf46e c0461ed2", - "c15a81bb c156cd69 41271283 417c75bd -> c04dbce0 4016a150", - "3f33eff0 3fbe4ac8 40ebb375 40fc98ab -> 410118ba 411615ae", - "c193c49a c1905efa c162b55e c162aefc -> c2028fa4 c200db3c", - "41290d42 4129103e c121e3dc c03e9b37 -> 3ee52cc0 40f2d2e0", - "c1b015f9 c16bc767 40969ce4 4097beec -> c18a6ec0 c11fe7f1", - "c11a2c81 c11a1465 c1921604 c1920ba4 -> c1df2c44 c1df15d6", - "405c9754 405d740c bf94579e bf910ae2 -> 40126b85 4014ee9b", - "40b58b0d 40b58c63 4188deb0 418bc9b4 -> 41b64173 41b92ccd", - "c1518136 c151809e 4124303c 41243104 -> c03543e8 c0353e68", - "4164f8b7 4164f981 c1346667 c133f547 -> 40424940 404410e8", - "3f544fa0 3f9e0f90 405a6713 406e8d3d -> 4087bd7e 409eca82", - "c0e2764e c0e199f2 41457047 414570e1 -> 40a86a40 40a947d0", - "416a214d 416a6f43 40ecf75f 40faad51 -> 41b04e7e 41b3e2f6", - "41978cfc 419a7ac4 c1696838 c157f5ea -> 408b6380 40b9ff3c", - "40a52a16 40a608ba c0b45577 c0b452d5 -> bef2b610 bee4a1b0", - "c0f66e66 c0f6655e c17e4759 c17e46ef -> c1bcbf46 c1bcbccf", - "413b9bf0 413bd818 c18cb9f3 c1891869 -> c0bbafec c0acb174", - "c05735be c0570ca2 c19cde9c c135a96a -> c1b7c554 c16b6c92", - "41227c94 41227e68 419ab00f 419b13e1 -> 41ebee59 41ec5315", - "41295f75 412974ef c19a6669 c19a65c3 -> c10b6d5d c10b5697", - "409600ae 40967f7a 4094b4f0 4094bbe8 -> 41155acf 41159db1", - "c0bd92ac c0bd89e8 4115bf05 411610af -> 405bd6bc 405d2eec", - "41492a85 419111fd c03b0cce c03a9792 -> 411a6752 41737e16", - "40fdb1d5 40fdb4fb c14c59a6 c14c49d6 -> c09b0177 c09adeb1", - "4096cf14 4099997c 416d7932 418d4a4f -> 419c705e 41b3b0ae", - "c04cb0c6 c04cacca 4094f573 4097b00d -> 3fba7440 3fc566a0", - "c0ce8958 c0c38cbc 419038bb 419e2c39 -> 41392cca 415a9214", - "411176cb 41134999 c1924ffd c1924a83 -> c113292f c1114b6d", - "bf9d1be7 bf9cdb79 bfdfeb7f 3ef48f7c -> c03e83b3 bf3f6f34", - "3fe31c2a 40b3824e 40bda0ad 40c0657b -> 40f667b8 4139f3e4", - "40fd3601 410051c3 415e430d 415e9b93 -> 41ae6f07 41af76ab", - "415dbc3b 4165f1e5 c10abc38 c10849c2 -> 40a60006 40bb5046", - "418edb02 4190945e 4185f86c 4185f9fc -> 420a69b7 420b472d", - "c01fa98e c01fa272 40e6086e 40e7a44a -> 409633a7 4097d311", - "414d1f1a 414d1fae 415a2d54 415cdb1c -> 41d3a637 41d4fd65", - "c1402268 c1151b8e 4113f60c 4113ff7c -> c030b170 bd8e0900", - "4181fd32 4181fe3e 418071fa 4180923e -> 42013796 4201483e", - "40aa0770 40aa24e8 410d6abe 41129a72 -> 41626e76 4167ace6", - "418c6d46 418c7552 c14f40de c13c7078 -> 4093335c 40b8f458", - "c12d1676 c12d1424 41147fcf 41161da5 -> bfc4b538 bfb7b3f8", - "c047d136 c047832a 417f7a4d 417f7b23 -> 414d8600 414d9a58", - "40d459e2 410c76fb 415e8e4b 415ea345 -> 41a45d9e 41b58d20", - "3f043efc 40b82538 c19090e0 c1900c38 -> c18c6ee8 c14405d4", - "c1886524 c18864ec c0cd7c31 c0a837af -> c1bbc430 c1b272d8", - "416f3e3a 417071a6 400fe704 4026f3bc -> 41899bfe 418d174a", - "414c5b1a 41676c56 c19f5489 c19e17a9 -> c0e49bf0 c0a985f8", - "418d54f7 418d5771 c127dd5a c127dbbe -> 40e59928 40e5a648", - "41832352 41944b76 c0f5de55 c0eeb45f -> 410b577a 41313cbc", - "c1021b9f c10214f9 c14a1af3 c118c32d -> c1a61b49 c18d6c13", - "419ade5e 419ca4a6 404c4254 404c44ec -> 41b466a8 41b62d44", - "c1047d71 c1037bcf 4164dd13 416952e5 -> 40c0bf44 40cbae2c", - "c1183847 c118359d 40324161 40ef8780 -> c0d74fde c001c774", - "4194b800 4194c7d4 418bd51b 418d5495 -> 4210468e 42110e34", - "4065dbf2 4065de0e 412612d8 41274ac8 -> 415f89d4 4160c24c", - "c0d7a3c7 c0d79331 c1732c73 c172ca01 -> c1af7f2b c1af49cd", - "409d6693 40ab8965 c07e33d9 c066eef7 -> 3f726534 3fe047a6", - "40aa442a 40aa8486 c12190b9 c10a86e1 -> c098dd48 c0551278", - "41342319 41347153 4150f371 4150f7cf -> 41c28b45 41c2b491", - "419e54ac 419ea6dc c05336b8 c0530d38 -> 4183edd5 41844535", - "419b0d09 419b14bb c0ab996c c0927d20 -> 41604d5c 416ceae6", - "406186a8 4061bc78 c15dfbe8 c15cfc78 -> c1259a3e c1248d5a", - "4187dc4c 41896394 c18657a7 c18652cf -> 3e425280 3ec43140", - "bf51a9d1 bf25fa6f 401c11e0 403733d0 -> 3fcf4ed8 400db534", - "3ffa20f9 3ffa2bc7 c064a1d7 c0605e29 -> bfcf22b5 bfc6908b", - "c15d2302 c15d20bc c19884a5 c183aff3 -> c2038b13 c1f24051", - "41767e7e 4182f33d c15e8a4a c15dfb36 -> 3fbfa1a0 401fad10", - "3fe7ee5a 4011d173 40cbc488 40cbc658 -> 4102e00f 410a5789", - "4085521b 40861f35 406ae6b2 406ae8ae -> 40fac574 40fb938c", - "4176b282 4176c75e 41784e7c 41785fcc -> 41f7807f 41f79395", - "4009c343 4076c75d 40f26585 4173d0e6 -> 411ba393 4198c15f", - "c148b9dc c06313e6 c0bfff28 c0bffb44 -> c1945cb8 c118c29c", - "41798eb4 41799004 409a9bca 40f68a76 -> 41a36e4c 41ba6aa0", - "c18468bf c16b6fd0 c17b4250 c163260c -> c20104f4 c1e74aee", - "c11a70ad c119f9b1 416d13d6 417b92aa -> 40a54652 40c331f2", - "c160fa38 c15e484c c19d7d72 c19d7b8e -> c206fd47 c2064fda", - "419f0d10 419f0d4c 40d9eead 40d9ef83 -> 41d588bb 41d5892d", - "c18ebbb8 c18e48f8 41598c8d 41599103 -> c087d5c6 c08601da", - "c1360650 c1360534 419caae3 419cb201 -> 41034f76 41035ece", - "c0ae581b c0ae5611 3fd5cf8d 40a2558d -> c071c870 bec00840", - "c0086f78 c0086d78 4097a7e1 409839b7 -> 4026e04a 402805f6", - "c18a17c0 c184967c 4190e135 4195775b -> 3f592ea0 400706f8", - "c0c53610 c0b1e5c4 4124be56 4124e416 -> 4084469c 4097e268", - "bfcea6ac bfce9cb4 c173e79e c12c95e2 -> c186de3a c1466978", - "4157d9d6 41594f4a 41998a90 41999030 -> 4202bbbe 42031bea", - "c0e5c4f5 c0e597e7 c1863852 c1862e06 -> c1bfa98f c1bf9400", - "c11908fa c118c0c6 40e15f50 40e16060 -> c0216548 c0204258", - "415e9412 417244b6 bf9054c4 bf903abc -> 414c897a 41603d5e", - "414910d2 41a0cca7 c0c6c56e c0c6c1a2 -> 40cb5c36 415e387d", - "c197bd24 c1973f34 c175b018 c175aa58 -> c2094a98 c2090a30" - ] - }, - { - "glsl": "vec2 cultmath_iv_sub(vec2, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c19f4813 c17fe5b2 40bdfd30 40be16a8 -> c1cecdbd c1af7225", - "413ad844 413b1ea8 411e992a 411e9ac6 -> 3fe1ebf0 3fe42bf0", - "4183bf2c 4183bf94 bfc8d4d1 bf58969e -> 418a83e1 41904ce1", - "c1804556 c1803f1c 405ba2f3 405ba80d -> c19bba58 c19bb37a", - "418bc4c9 418bc9d7 c1482612 c145f1d6 -> 41eebdb4 41efdce0", - "c1961d7e c15eb3c1 41784541 4179080f -> c20950c3 c1eb7c81", - "c10aa6ae c1096a7c bf215912 bf1a986e -> c100fd27 c0fea9d6", - "412135f3 4121369d 41810639 41810b67 -> c0c1c1b6 c0c1abaa", - "bf9fce69 bf2f136e c128b716 c1288d2e -> 41149361 411dc5df", - "40f27750 41064134 3faaf7d6 4020bdd5 -> 40a21866 40e1c472", - "41006cdc 410166cc c18097f8 c1708ee7 -> 41b87de2 41c14b5e", - "c0c758b9 c0bd3a37 c18698c3 c185ae49 -> 4127b036 412e946a", - "c08d5784 c08d4998 c146bf55 c13df0fd -> 40ee8a76 41001a89", - "c0a869a8 c0a78738 c167a797 c167a611 -> 4113713d 4113e3fb", - "c1966174 c19660b4 c19b767c c19b7410 -> 3f225380 3f22b900", - "4193fa47 4193fe89 c0ce0c33 c086360d -> 41b587ca 41c78196", - "c15bcbd2 c15bc834 c1029eab c10287f1 -> c0b287c2 c0b25312", - "c18cc814 c18cc660 c0813d4e c0813872 -> c158f3ef c158ee19", - "41135f26 41137dd6 418841f9 4188a22b -> c0fbca60 c0fa0c38", - "41509818 41509930 c148d675 c147807f -> 41cc0c4c 41ccb7d2", - "bfa4e38d 3f831f8d c181d924 c18193e4 -> 416e8b56 418a0b1d", - "415ce1bb 415ce42d 41424aef 41a6737c -> c0e00a7a 3fd4c9f0", - "408fbddf 408fc139 c0a55216 c0a2942a -> 41192904 411a89a8", - "412b6dcf 412b80d9 4160e965 416128bb -> c056ebb0 c055a230", - "c1466884 c14661f4 40bbdb06 40bbe022 -> c1922c4a c19227bc", - "c082295b c067142a 4004479f 40045921 -> c0c455ec c0b5ade4", - "415e1a57 415e1b01 c1bf9520 c16a16d4 -> 41e41896 42175150", - "401b2c14 4021d95c c131f872 c0ba423d -> 4103ec24 415a6ec9", - "418831e3 41884ec5 410b7a71 410b7b97 -> 4104e82f 41052319", - "c1641628 c143b13e c197f798 c197f762 -> 4097b138 40d87be4", - "c10e8ed7 c10e8091 40e0af3d 413e6e0e -> c1a67e72 c17ed830", - "413e62c2 4150da86 c0911285 c090c377 -> 4183623f 418cb1e4", - "3f6b05cb 3f721df5 c0c89172 c0c5dfe6 -> 40e3409f 40e6d531", - "c01db4c2 c01db27e c151f017 c147470b -> 411fd9da 412a8378", - "c108baae c0b86fcd 40ba947a 40dbe506 -> c176ad31 c1398224", - "c1839e58 c148fae4 c03e6ce8 c03e6b18 -> c157a1ea c1195faa", - "4155c2d8 4155fac0 40cdbd22 40cde546 -> 40dda06a 40de385e", - "408986de 409e2ef2 c113eac4 c113d8bc -> 41589c2b 4163023d", - "c1373d63 c1348b71 4174511a 41745256 -> c1d5c7dc c1d46e46", - "419e1175 419f020f c087d89e c087d766 -> 41c0074e 41c0f836", - "40c42e39 40c83fc7 bf96bff0 bf96b850 -> 40e9dc4d 40edefc3", - "c11ca89f c1176939 bfa3956e 3fe6238e -> c1396d11 c102f68b", - "c14ef4a0 c0e330fc 412bd224 412bdc70 -> c1bd6888 c18eb551", - "c13e6a9d c13e655d 4169014b 41691aed -> c1d3c2c5 c1d3b354", - "417184e5 41787f23 c17dd077 c17dae0b -> 41f79978 41fb27cd", - "c15eefa6 c15eeeee 412ef8a6 41393882 -> c1cc1414 c1c6f3ca", - "c13374ea c133746c c0b6269c c098979c -> c0ce5238 c0b0c23c", - "c16247bf c16246a9 41299abf 412f1905 -> c1c8b062 c1c5f0b4", - "be88488c be0943e8 c1612cd7 c1609045 -> 415c4e01 415f07c7", - "c006b3cc c0065544 411f8d05 411f8edf -> c1413bd2 c1412256", - "4183f276 41892f22 c18481cc c182de30 -> 42036853 4206d877", - "41757095 41c11b7e c19d02e2 c1246180 -> 41cce90a 422f0f30", - "41339a7b 4134423d c137da5b c137d171 -> 41b5b5f6 41b60e4c", - "3ed672bb 3ed68145 417434e9 4175ec67 -> c16f38d1 c16d80df", - "41567081 415c1137 41626861 41626f27 -> bf3fea60 becae540", - "c0da79b7 c0ceab4d 4120bbfa 4120beb6 -> c186fdc9 c18408d0", - "c14a4cae c14a4bda 4135d020 41370f24 -> c1c0ade9 c1c00dfd", - "c188ac4a c188a114 41839afc 4183f718 -> c20651b1 c2061e08", - "417802da 41b64e6b bfb6fab7 bfb5dbc9 -> 41875f2a 41c1be16", - "4193481d 419348eb 412b6759 412b6d2f -> 40f64616 40f654fa", - "4179238a 41794246 c19cb2d2 c19ba4ec -> 420c1b58 420ca9fa", - "416dcc1d 416e5053 c14258cb c141ea87 -> 41d7db52 41d8548f", - "411a02b5 411ad60b 40dab8d6 40ea6eda -> 40132d20 4035e680", - "bda17630 bd38c39f 413e1ea1 413e2313 -> c13f65ff c13ed765", - "c1acbfd8 c18b8b0a c049c85c 3fb65238 -> c1b824fc c164a3fd", - "c13dfdd9 c13d1cdd 4186bb62 4186d97e -> c1e5d86a c1e549d0", - "40897e94 4091bc44 c1077e61 c106b5df -> 414b7529 41505c83", - "3fe283b9 3fe64fc7 40b44d6b 40c11855 -> c0887767 c07572f2", - "418cba8b 418dc5a1 c10f0e98 c02d9e89 -> 41a26e5c 41d54ced", - "4100e91d 4100eae3 c1069c45 c1027de7 -> 4181b382 4183c394", - "41696064 41696d34 415752ad 41580a93 -> 3f8aae88 3f90d438", - "40da6fca 40da75d6 c195cec1 c1959f4b -> 41cc3b3e 41cc6c36", - "c14fbbab c14fb3c1 c09e2e56 c09e2d16 -> c100a520 c1009c96", - "409bf606 40cc3c92 c1976a03 c1975f95 -> 41be5d16 41ca7928", - "bff15ec0 bfe76080 c19bbc41 c19bba6f -> 418ca483 418d4639", - "c1395457 c1362f17 418d3de6 418d416a -> c1e9eb96 c1e85572", - "414d4c2d 41973775 412ae5ff 4151028d -> be6d9800 410388eb", - "c16b9a19 c152c35d bf8cd9a3 3fc72ea3 -> c1823ff7 c1412829", - "4098043c 40b6abb4 c197c988 c17a1d39 -> 41a30fac 41c57475", - "4106f055 4107152b 41281241 412850fb -> c0058298 c003f458", - "40acd192 40d33e96 c0b00671 c0aff00b -> 412e60ce 4141a284", - "c1755a7f c1739301 c186829f c18681ed -> 3fbd4ad8 3fcb91e8", - "4076303d 40763223 3e4e3b08 3e4ea6f8 -> 406945ce 40694e72", - "c17724aa c1772352 bf9d874d bf9d6433 -> c1637824 c1637268", - "c0b7a61e c0b4ca9e 40a54a37 40b12e39 -> c1346a2c c12d0a6a", - "c09dafc3 c09daac9 c0e44309 c0e41b43 -> 400cd700 400d3080", - "4120c334 412138bc c093236f c03b87e2 -> 414fa52c 416aca74", - "412bb2ee 412bb49a 40a6fcbf 40a6fe71 -> 40b0676b 40b06c75", - "41496fae 414aa78a 3fcb0330 3fcc3fb0 -> 412fe7b8 41314724", - "c103ec39 c100f131 c16d94df c16d89a9 -> 40d33ae0 40d9475c", - "416efdbc 41738f04 c10d4dda c10d4bd6 -> 41be24c9 41c06e6f", - "c0d5af09 c0d56bdb 412d1ac1 412dccd3 -> c18c522c c18be857", - "c0fde022 c0bcf2e6 3ff1571b 3ff16445 -> c11d1c9a c0f948ad", - "41247ac4 41247b7c c18cda1d c18c9e2d -> 41dedb8f 41df17db", - "be6f2109 be6efdf7 3faeb1d4 3fc00dcc -> bfddf1ed bfcc9193", - "c13de1eb c13ddbc7 c0d07e85 c0cfbe5b -> c0ac057b c0ab3909", - "c096b951 c096347b c0f78530 c0f5f628 -> 403e79ae 4042a16a", - "4022181e 40221be2 4181cf61 41847273 -> c1605ede c15b17ca", - "bfc63914 bfc5886c 41558bdf 4159d691 -> c1729db4 c16e3cec", - "41719da7 4171a109 c19eb92a c19eaade -> 420bbcd9 420bc4d7", - "40f2e763 4120d76e bf81ca39 401a0c2c -> 40a5e14d 413110b5", - "403ecb1f 40410e41 c101976e c0ed526d -> 41265bfe 4131dafe", - "3f2502e7 3f250e19 4180e4db 4180e97d -> c17782cc c17778d4", - "c1749928 c1741414 c185bb15 c1846fd3 -> 3fa233f0 3fbb10b0", - "c0cc3cec c0aa4750 410ceea0 413aa420 -> c190614b c1621248", - "c187d5d1 c187d2cf 41949378 41949750 -> c20e3690 c20e3324", - "4189ef0e 419723da 40cbe614 40cc42b4 -> 412dbcc2 414854aa", - "c1388677 c13867ed 409415b9 4094330f -> c1814fff c1813965", - "c199381e c19936b8 4181e0da 4181e97e -> c20d90ce c20d8bc9", - "410b4955 410b8393 416cec59 4188f40f -> c1069ec9 c0c2d18c", - "c16967c5 c16899b3 c1994daf c198ff15 -> 40912cca 40940356", - "c154cf7e c1524ed6 3e97d080 40d11740 -> c19ead8f c1570d5a", - "c1182f2b c1182b4b c0d70b8d c0d709ab -> c032a956 c0329612", - "c039be79 c039b877 c10489be c1041a2a -> 40ab5518 40ac3740", - "418472ef 41847725 418fd50d 41937713 -> bff04240 bfb5de80", - "41482908 417823f0 400d1ef1 400d274f -> 4124df34 4154dc34", - "c0342992 c02e52ee c14dc883 c0e52302 -> 408b0e39 412233c8", - "4062e228 408568f4 416e5074 41982c5e -> c177a032 c12b9bfa", - "416f0dd8 418c5c94 4122f9ef 4123bc31 -> 4096a34e 40eb7e72", - "c138669a c1381fd4 c184b625 c184aea3 -> 40a1ed58 40a298ec", - "c11d52b3 c1183cf1 c160ffbe c160ff40 -> 4087591a 4091859a", - "c1929ba9 c19230f7 4159828e 418896d9 -> c20d9941 c1fef23e", - "416f1f0c 416f51f4 c06411c8 c062dc98 -> 4193eb19 41942b33", - "bf7bbc94 bf7b8f6c c198caf2 c198c7ae -> 4190e9c9 4190ee77", - "41913d71 41a5495b c184c53e c1842756 -> 420ab264 4215074c", - "c09049d4 c08b8b70 c0b06d38 c0af607c -> 3f78b540 3f938720", - "c1127518 c11247ba c155fdc4 c155260a -> 408561e4 40876c14", - "c0c011c5 c0ac53f3 c110333f c10fdb3f -> 403f4972 40682516", - "c14fcfcf c14d3501 bf88db61 bf88c8ff -> c13eb6af c13c1995", - "411da6e6 411e70ee c18b396b c16aaefe -> 41c42af2 41da71e2", - "41058285 41059763 c1873ba2 c1873a0e -> 41c9fb50 41ca0754", - "c0c30d3f c0c25861 c015a197 bfec43d3 -> c087fc4a c06f0f2b", - "41667b6c 416714d4 3fffbcea 4000299b -> 41467105 41471d37", - "c0b1e6e1 c0b0cb23 41870e58 41881c34 -> c1b495ec c1b34121", - "c0d23c8e c0ccd93e 411bc368 411e1eac -> c1839e7a c1811804", - "c09d6f4e c09d46b2 4001a0bd 4001a6f3 -> c0de42c8 c0de1710", - "c1871cca c1398e59 c119e5df c1027a0d -> c10bbf87 bffd43d0", - "40d3d554 410ee28a be87823f be7d8283 -> 40dbc168 41131e9c", - "41339fae 4133a3b6 416bfe71 416bff27 -> c0617de4 c0616aec", - "401158db 401166a5 c164d897 c15460ad -> 4178b6e4 41849920", - "419384dd 4193a117 40d0ea54 4102b1d2 -> 412457e8 413ecd04", - "c16431ca c11183c0 c17e97c9 c17b08e3 -> 3fb6b8c8 40da2812", - "40fb9e13 411a09ab 4147a427 4147a579 -> c093acdf c03669f0", - "413b9995 413bf0a3 3ed1dd01 3ed578ff -> 4134edcd 413561bb", - "4106a5a0 416d8f60 c19547ca c195328c -> 41d8855c 420607bd", - "c146bb63 c144d6c9 c1b4af7b c15e3fe6 -> 3fbc2418 4124882d", - "c1993fb3 c1993f07 400423f2 40042e9e -> c1a9c587 c1a9c385", - "408bc014 40d8829c c18a8198 c18a8068 -> 41ad706d 41c0a23f", - "c03f2c2a 400bc57a 40839bae 411af201 -> c14abd0c bff6e3c4", - "40c14af5 40cc590b 4182757c 41827790 -> c12449a6 c11ebe72", - "41588dc5 415a5103 c182171d c1694d01 -> 41e0ed63 41ef3f9e", - "c18c94bc c18c8214 40c407a3 40c4267d -> c1bd9e5b c1bd83fd", - "40f08c4b 40f18cb5 c11c54e3 c11ad1af -> 41898bea 418a8d9f", - "c163b6f8 c15a7ea0 408eb14c 408edd94 -> c19592e1 c190eba3", - "c099863a c08fe052 414dfc69 414dfdc7 -> c18d6072 c18af649", - "c0ddb6fa bfe4fd48 c19cda29 c18fc865 -> 4130b54d 418e8a54", - "4132fd4f 41362645 4064af62 40abb11f -> 40ba497f 40f9f4d9", - "413b065f 413c0c3d 410926ea 410927fa -> 40477994 404b954c", - "c19488d4 c188ec2c 401fc286 4024feba -> c1a928ab c19ce47d", - "3ba34e68 3bc3b198 41881928 418937c8 -> c1892d93 c1880ced", - "bffef22c bffec054 bf82bae7 bf82aa79 -> bf788f66 bf780ada", - "40980f56 4098cb22 c1a17f5c c19d962a -> 41c39a00 41c7b224", - "c0d82c18 c0d80930 bf056418 40b8015b -> c14816ba c0c75cad", - "416ea3a8 417f3760 412df431 415f258f -> 3f77e190 40a2865e", - "4047ff25 4048249b c18be7f0 c18bd30e -> 41a4d2f3 41a4ec83", - "412b1317 413b8ba5 3f62e455 3f6300ab -> 411ce30c 412d5d60", - "41364560 41364868 3fd2669e 3fd2e7a2 -> 411be86c 411bfb94", - "c1473c9f c1473c0d 415db4f8 415db868 -> c1d27a84 c1d27882", - "412c068e 412c0a52 40c59d9a 40c5a276 -> 40926aa6 4092770a", - "c02d0e48 3df7def0 c130f4dd c130e651 -> 4105a2bf 4132e49b", - "40a45f04 40ef4b9c 3f44faa3 3f4a861d -> 408b0e40 40d6ac48", - "419c457f 41a10711 c141c14c c141b9f0 -> 41fd2277 4200f3dc", - "c199c5dc c19810a6 c19e9927 c19e9651 -> 3f1a0ea0 3f511020", - "c16941fa c1689482 415dfda6 4160c30a -> c1e50282 c1e34914", - "4109178a 41092dde c0b98e19 c0b90423 -> 4165999c 4165f4ea", - "4188dc33 418aed05 3ffb6850 3ffbd290 -> 41723e14 41766d00", - "bf53441a bf513866 c1484f6c c143a22c -> 41366dea 413b3be6", - "c1625c79 c15f5335 c03c68b8 c02acae8 -> c137a9bf c1303907", - "c192df7f c18e398b 4100f7a7 41375b1d -> c1ee8d0e c1ceb55e", - "c10adf99 c10aded3 c16be85b c16be7c7 -> 40c2105c 40c21310", - "41987a53 4198801d c1024ee2 c101a66e -> 41d94d8a 41d9a78e", - "c1989f10 c197a2be c19065c5 c1906265 -> bf83cab0 bf679f20", - "c0c82657 c0c82575 c018cbcf c018c541 -> c077876d c0777f1b", - "3f8126ec 3fe4d3b4 c1098630 bf892700 -> 400526f6 412620a6", - "c0e056a4 c0e04ca4 419b9323 419c8745 -> c1d49cee c1d3a64c", - "402332d1 4025520f c17ea345 c17e876b -> 4193aa10 4193fbe4", - "c128f8d9 c128e931 c14cdac5 c14cb901 -> 400f00a0 400fc650", - "410ab142 415d75be c0b05bae c0aa0762 -> 415fb4f3 419ad1ca", - "c135db6c c135ca18 bfaa3dd1 bf95cc4f -> c12321e2 c120825e", - "c09293f4 c09292d8 c11e9038 c0fc487c -> 40536910 40aa8d98", - "c11743aa c0803594 c0c09bee c0c097ba -> c05bdf34 4000ccb4", - "c13638c9 c1362a59 c15e1ae4 c15e11b8 -> 401f63bc 401fc22c", - "c0acdb7b c096891d 4050b399 4050b717 -> c10a9b83 c0fee2ea", - "c18a97df c18a49e3 bfb08550 bfad9310 -> c17f7d5c c17e831c", - "c16b911b c123c013 c10b3b2d c105ac83 -> c0cbc930 bfc42730", - "c0254074 c017a38c bfc2e535 bfc19a2b -> bf88e6bd bf58c3c6", - "40a8e351 40c29fb7 418170b1 418172fb -> c12e744e c1219186", - "c0fbaf26 c0ebebde 4065c96f 4065fc51 -> c13756a7 c12f684b", - "418cb8b6 418cb996 c10b85b2 c10993fa -> 41d182b3 41d27c6f", - "c187d5d4 c12a7607 c180cf23 c13ce438 -> c0a58ee0 40ae507e", - "c173c5cc c13aff40 c19cf1d3 c19cf197 -> 408c3ac4 40fdc8cc", - "c0b1afd0 c0b19634 406117c2 407546be -> c1162998 c111110a", - "41195c88 41995fa0 bff3b6fb bff14d45 -> 41378631 41a89b10", - "4118bc5c 4119dc6c c04b5f33 c03da8bd -> 4148268b 414cb439", - "c0571afe 400b37fe bbf7c535 3bee4535 -> c0579221 400bb3e1", - "c0cd01ca bf99a958 4192c105 4193f413 -> c1c73486 c19c5b9a", - "c14d83ae c14d7904 c18bff9e c146d3e7 -> bed5f8e0 40950c70", - "c1392aaf c11d13a5 c0e93398 c0e92850 -> c0892d0e c021e764", - "4132ac73 4132c659 3fe2006f 3fe79871 -> 4115b965 4116864b", - "40c76748 40c7f7f8 c19353f3 c1934953 -> 41c52325 41c551f1", - "c146ea2a c146e5d6 c0bfc43c c0bfa614 -> c0ce2e40 c0ce0770", - "c1090d62 c1090b74 40168eb0 40170320 -> c12ece2a c12eaf20", - "4100fee1 4102f2e7 c16bb0dc c16bac7a -> 41b655ae 41b751e2", - "bfe43eb6 bfb3100a 3f5decac 3f5e3f54 -> c029af30 c0110330", - "418fd1b4 418fe0f4 415596fb 415597fd -> 409416d6 409455da", - "c152a78c c14fc84c bfa83e8a bfa83ad6 -> c13da031 c13ac07b", - "40e476dd 40e481c3 40e0e936 40e129ca -> 3dd344c0 3de62340", - "c1a40b45 c18c1f8b c19cbde1 c19cbd91 -> bf69b680 4004f2b0", - "4182def0 4182e030 c1232f6f c1232b55 -> 41d4749a 41d477e8", - "4068bff4 4073c7cc c0c0e0c6 c0c0df6a -> 411a9fb2 411d6256", - "410ab057 411448a1 c128a6c9 c126be51 -> 4198b754 419e77b5", - "410af772 410af8ee 412b416b 412b4241 -> c0012b3c c00121f4", - "41589bd9 4158ad07 40490f48 40493938 -> 41264d8b 41266935", - "3fb5306a 40fad18e c153aa98 c152e112 -> 4169871f 41a889b0", - "411807c9 41181c3b 40ac6704 40ac68ac -> 4083a6e6 4083d172", - "bfd25e53 bfd2446d c0d72b91 c0b41af7 -> 407f06c4 40a29a76", - "4089233b 408925b5 c101f88c c101eb1c -> 41467cba 41468b66", - "bf903642 bf8fb17e 40a29ef5 40a2b98b -> c0c6c71c c0c68b54", - "c19b8768 c1946f7e c0bb2b7c c0bac744 -> c159ab2e c14b493e", - "c08ca035 c024ff66 c104bf47 c103a861 -> 4075611a 40b6fedb", - "bfe27181 bfd37edf 3fbcc784 3fe55afc -> c063e63e c0482332", - "c0f1d2ef c0e3c43d c0bda154 beee9740 -> c0e2e97b bf988ba4", - "419a83f4 419d3f0c bfbfd9fe bfbf9d62 -> 41a67dca 41a93cac", - "c19bfb45 c19bf59d 405893f6 405bf61a -> c1b77a08 c1b7081c", - "c066e1b9 c065fa37 c19de6bf c19ce171 -> 4180053a 41812778", - "41496296 4149b88a 4066540e 4068ca02 -> 410f3016 41102386", - "40fcaecb 40fcc285 c12698be c110fbf0 -> 4187a9ab 41927d00", - "40808014 4092fe6c c1828f6b c15a2c2b -> 418d361a 41a74f06", - "c19135c7 c1913555 4053bf1b 409fdf92 -> c1b92dac c1abad38", - "40aee04a 40b445a6 bfca5194 3f641028 -> 40925e45 40e6da0b", - "40e107b8 40e13588 c0f6235d c0e0b0f3 -> 4160dc56 416bac72", - "4165af30 4165cd70 c10a7c8d c102c26b -> 41b438ce 41b824fe", - "c146281b c134599b c1be695e c1798bdc -> 404d8f04 41487921", - "415a1ff0 415dcd30 40aecd18 416ac334 -> bf851a20 410666a4", - "c198a246 c198a200 c19f1cf7 c19f1ca3 -> 3f4f4ba0 3f4f5ee0", - "bf9577b2 bf89862e c0cd0cfa c0cd00c2 -> 40a7a2d6 40aaab6e", - "404d2349 40520977 c165a12f c11128cd -> 4144719f 418d11c6", - "40e41e5b 40f41f3d 417e74cd 41848cf5 -> c1170abc c104652e", - "418c5dc1 418c5eab 418e6864 418e93e0 -> be8d87c0 be826e40", - "c16bc8a7 c156655b 40ca2d88 40ca4f98 -> c1a8783a c19dbe10", - "419b93ca 419be522 408c3e1a 40aba166 -> 416156e1 4171ab37", - "411cb333 411cb551 c192910c c19281e0 -> 41e0db7a 41e0ebb4", - "c0ecd770 c0e93620 414d6793 414f4dad -> c1a2dcb2 c1a10152", - "40b640af 40b6d449 c06f10da c06f0ca6 -> 4116e381 41172e5b", - "c19ce58f c19ce509 c14a2974 c14a1ee6 -> c0df5870 c0df413c", - "c1557fac c15569e4 c18f5841 c18f2d3b -> 4091b594 40928d3c" - ] - }, - { - "glsl": "vec2 cultmath_iv_neg(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "418113e2 4181173e -> c181173e c18113e2", - "c1935b26 c1906118 -> 41906118 41935b26", - "41113eca 411149da -> c11149da c1113eca", - "415c8211 415c860f -> c15c860f c15c8211", - "c0afae98 c0a7bc48 -> 40a7bc48 40afae98", - "c1a5ec7c c16f9759 -> 416f9759 41a5ec7c", - "4196e2ff 41974b6d -> c1974b6d c196e2ff", - "bed2c222 becacbde -> 3ecacbde 3ed2c222", - "3f27cd86 4007cb1e -> c007cb1e bf27cd86", - "40a40114 40a402fc -> c0a402fc c0a40114", - "41858d3a 41859312 -> c1859312 c1858d3a", - "c1722476 c171b448 -> 4171b448 41722476", - "40fc2b5f 411f4868 -> c11f4868 c0fc2b5f", - "bfe2d22b bfe2cb15 -> 3fe2cb15 3fe2d22b", - "40b46e02 40b4ac06 -> c0b4ac06 c0b46e02", - "c15c9f83 c15a0ab9 -> 415a0ab9 415c9f83", - "bfa68027 bfa66c19 -> 3fa66c19 3fa68027", - "417c7fd0 417d0440 -> c17d0440 c17c7fd0", - "c1807932 c1807042 -> 41807042 41807932", - "40bc1f64 40bc208c -> c0bc208c c0bc1f64", - "41296ec5 412b8e93 -> c12b8e93 c1296ec5", - "c1553de0 c0d805b8 -> 40d805b8 41553de0", - "c0836715 c082cdc3 -> 4082cdc3 40836715", - "c179f24f c179987d -> 4179987d 4179f24f", - "4058e6fd 407b31e3 -> c07b31e3 c058e6fd", - "411e5819 411e6b17 -> c11e6b17 c11e5819", - "40986c20 41498da8 -> c1498da8 c0986c20", - "3fe9be9b 3ff88065 -> bff88065 bfe9be9b", - "c1731822 c1721f76 -> 41721f76 41731822", - "4194dcee 41a57f36 -> c1a57f36 c194dcee", - "414d64eb 4159c15d -> c159c15d c14d64eb", - "c00c056e 40d74e47 -> c0d74e47 400c056e", - "3f5cde4d 3f5fcef3 -> bf5fcef3 bf5cde4d", - "bf9a4d1c bca02100 -> 3ca02100 3f9a4d1c", - "3fc12e2c 41237502 -> c1237502 bfc12e2c", - "c0cd1af0 c0cd1214 -> 40cd1214 40cd1af0", - "c149917b c148010d -> 4148010d 4149917b", - "c0f6efe9 c0f6d813 -> 40f6d813 40f6efe9", - "c1928f3a c1928df6 -> 41928df6 41928f3a", - "c1833ac1 c183363f -> 4183363f 41833ac1", - "40ba22f4 41679fce -> c1679fce c0ba22f4", - "c01e6b22 3f04cc88 -> bf04cc88 401e6b22", - "408f2d1f 40b96409 -> c0b96409 c08f2d1f", - "4187bdaa 4187f686 -> c187f686 c187bdaa", - "408d14cf 408d2a01 -> c08d2a01 c08d14cf", - "c0992171 c0977daf -> 40977daf 40992171", - "c0de2ba1 c0c3bd5f -> 40c3bd5f 40de2ba1", - "c1835232 c0f3f682 -> 40f3f682 41835232", - "c18a4ada c18a46d0 -> 418a46d0 418a4ada", - "c0d1dc8a 3ff46ac8 -> bff46ac8 40d1dc8a", - "41964f56 41965572 -> c1965572 c1964f56", - "414d037d 414eadb3 -> c14eadb3 c14d037d", - "c0722eb8 c06ef2f8 -> 406ef2f8 40722eb8", - "c161f308 c161f16c -> 4161f16c 4161f308", - "40dbb808 40dbc758 -> c0dbc758 c0dbb808", - "bede54b0 40c1fcbb -> c0c1fcbb 3ede54b0", - "bfc4afd2 bf9020ce -> 3f9020ce 3fc4afd2", - "c1836563 c16c8462 -> 416c8462 41836563", - "c10050d2 c0fa2290 -> 40fa2290 410050d2", - "c0b5f67b c0ac1d15 -> 40ac1d15 40b5f67b", - "c0a8cecd 4088c54d -> c088c54d 40a8cecd", - "c13d2273 c13d0763 -> 413d0763 413d2273", - "40729c9d 40988642 -> c0988642 c0729c9d", - "416cbb00 416ce558 -> c16ce558 c16cbb00", - "c081f4ee c081d4f2 -> 4081d4f2 4081f4ee", - "c136a3ad c1297adb -> 41297adb 4136a3ad", - "410a8e76 410a8fd2 -> c10a8fd2 c10a8e76", - "c100f5f2 c100a564 -> 4100a564 4100f5f2", - "c16830ff c1437fdb -> 41437fdb 416830ff", - "bedccbfa bedca806 -> 3edca806 3edccbfa", - "40d1a21b 40f3c04d -> c0f3c04d c0d1a21b", - "414ad73c 414aefe4 -> c14aefe4 c14ad73c", - "4107ba29 4107ecd3 -> c107ecd3 c107ba29", - "c1886799 c18776cb -> 418776cb 41886799", - "40ddf42a 40de25c6 -> c0de25c6 c0ddf42a", - "40eee37a 40ef3b9e -> c0ef3b9e c0eee37a", - "417a0f54 41813d76 -> c1813d76 c17a0f54", - "c07183f4 40679ed4 -> c0679ed4 407183f4", - "c1832985 c18301bf -> 418301bf 41832985", - "419e6fce 419f50d2 -> c19f50d2 c19e6fce", - "40d20f6d 40e2de93 -> c0e2de93 c0d20f6d", - "410d0aa7 410d2299 -> c10d2299 c10d0aa7", - "c19a0ae5 c19320f9 -> 419320f9 419a0ae5", - "c12296e6 c1227c5a -> 41227c5a 412296e6", - "c04879c3 c03cf0bd -> 403cf0bd 404879c3", - "40e29cf0 40e31098 -> c0e31098 c0e29cf0", - "c151c214 c151b878 -> 4151b878 4151c214", - "c19a73bf c19865d1 -> 419865d1 419a73bf", - "c15b74e8 c13f72b4 -> 413f72b4 415b74e8", - "40c23d7e 40c244aa -> c0c244aa c0c23d7e", - "410e7aa8 410e8274 -> c10e8274 c10e7aa8", - "4112d105 4112d1af -> c112d1af c112d105", - "40948fc8 40bc2e38 -> c0bc2e38 c0948fc8", - "413cbcf8 41987ef8 -> c1987ef8 c13cbcf8", - "4088040b 40882695 -> c0882695 c088040b", - "c0ae07aa c0a2e7f2 -> 40a2e7f2 40ae07aa", - "415c0bf6 41825ca5 -> c1825ca5 c15c0bf6", - "c0b44622 bf81159a -> 3f81159a 40b44622", - "c184d89a c184adfe -> 4184adfe 4184d89a", - "c110bc11 c09aad16 -> 409aad16 4110bc11", - "c15492c0 c14eb49c -> 414eb49c 415492c0", - "c1465239 c14651b1 -> 414651b1 41465239", - "40e55bcf 40e56b91 -> c0e56b91 c0e55bcf", - "c12b3cfd c129259f -> 4129259f 412b3cfd", - "4105879d 4118cc83 -> c118cc83 c105879d", - "413ca588 413cac28 -> c13cac28 c13ca588", - "413afe87 414c8989 -> c14c8989 c13afe87", - "4176a4cd 4176d553 -> c176d553 c176a4cd", - "c19c4a1b c19a514d -> 419a514d 419c4a1b", - "410df6be 410dfb62 -> c10dfb62 c10df6be", - "41808087 41808551 -> c1808551 c1808087", - "4123d9a6 4123daee -> c123daee c123d9a6", - "c14300af c0a610aa -> 40a610aa 414300af", - "400b0ce5 400b3bbb -> c00b3bbb c00b0ce5", - "416484d0 416485f0 -> c16485f0 c16484d0", - "406bbdd6 4081f1d5 -> c081f1d5 c06bbdd6", - "3f2b7407 3f8cdedd -> bf8cdedd bf2b7407", - "c19add0e c19adcd4 -> 419adcd4 419add0e", - "c18c4eae c1898fec -> 41898fec 418c4eae", - "c0afa1af c0af6471 -> 40af6471 40afa1af", - "405831a7 40585349 -> c0585349 c05831a7", - "c1281034 c119c6a2 -> 4119c6a2 41281034", - "3f9a9c95 3f9aaaab -> bf9aaaab bf9a9c95", - "4180bf45 4180bfb7 -> c180bfb7 c180bf45", - "419e90a3 419e90d9 -> c19e90d9 c19e90a3", - "4185d3f6 4185ea1a -> c185ea1a c185d3f6", - "411ac12a 411ac2b6 -> c11ac2b6 c11ac12a", - "c1a4ff72 c18c1630 -> 418c1630 41a4ff72", - "419230e5 4192317b -> c192317b c19230e5", - "411672f1 411c23d7 -> c11c23d7 c11672f1", - "40b04ba2 412b0033 -> c12b0033 c0b04ba2", - "412926a9 412b93d7 -> c12b93d7 c12926a9", - "c1339ef0 c1339dea -> 41339dea 41339ef0", - "410c8a6a 410c8b6e -> c10c8b6e c10c8a6a", - "4127b546 414dfade -> c14dfade c127b546", - "c0c178ce c0c15c8a -> 40c15c8a 40c178ce", - "c0ec4695 c0ec1a07 -> 40ec1a07 40ec4695", - "409f45b5 40a44b1b -> c0a44b1b c09f45b5", - "c1b2edd5 c179de09 -> 4179de09 41b2edd5", - "402ffec6 403008aa -> c03008aa c02ffec6", - "c18ac71a c18a8f80 -> 418a8f80 418ac71a", - "c111c6af c0e767f3 -> 40e767f3 4111c6af", - "c153bc1a c153b872 -> 4153b872 4153bc1a", - "41977c99 419792ab -> c19792ab c1977c99", - "4102452d 410246c3 -> c10246c3 c102452d", - "c1acf166 c1625e2f -> 41625e2f 41acf166", - "4194e3c4 41965b50 -> c1965b50 c194e3c4", - "40d9eb4f 40df1661 -> c0df1661 c0d9eb4f", - "be53a926 bdbb1db4 -> 3dbb1db4 3e53a926", - "4034ba52 4035e03e -> c035e03e c034ba52", - "c08be38d c0441366 -> 40441366 408be38d", - "c10f9471 c10f92d1 -> 410f92d1 410f9471", - "40c27d21 40c61c6f -> c0c61c6f c0c27d21", - "c182d402 c182c0be -> 4182c0be 4182d402", - "bede6cb5 beda284b -> 3eda284b 3ede6cb5", - "4126e1da 419b9083 -> c19b9083 c126e1da", - "3f5ae8e1 3f700e1f -> bf700e1f bf5ae8e1", - "40b7bb3b 40b7c50d -> c0b7c50d c0b7bb3b", - "4082a161 40f5fe0f -> c0f5fe0f c082a161", - "bfa8fddc bfa8f944 -> 3fa8f944 3fa8fddc", - "c17c3f26 c17c3016 -> 417c3016 417c3f26", - "c0a32ae4 c09b9e44 -> 409b9e44 40a32ae4", - "414e8c77 414eaae9 -> c14eaae9 c14e8c77", - "c0d01608 c0c97dc4 -> 40c97dc4 40d01608", - "40331894 4133044b -> c133044b c0331894", - "c164aa46 c1647acc -> 41647acc 4164aa46", - "c0865d70 c0865a40 -> 40865a40 40865d70", - "411f63d0 411f6a90 -> c11f6a90 c11f63d0", - "c138e94b c138e62f -> 4138e62f 4138e94b", - "c13f90f1 c13e9331 -> 413e9331 413f90f1", - "c180b553 c18014d5 -> 418014d5 4180b553", - "418580f4 4185890c -> c185890c c18580f4", - "c123e054 c123df7e -> 4123df7e 4123e054", - "bff5005e bff3ef42 -> 3ff3ef42 3ff5005e", - "c19d292b c19d01e5 -> 419d01e5 419d292b", - "419de90f 419e9529 -> c19e9529 c19de90f", - "c1635ab5 c16289cb -> 416289cb 41635ab5", - "c0c69859 c0c695ef -> 40c695ef 40c69859", - "c008c764 c0024bec -> 40024bec 4008c764", - "c101fa77 c101f047 -> 4101f047 4101fa77", - "c112d38a c1129ab2 -> 41129ab2 4112d38a", - "410c72e5 410cfb4b -> c10cfb4b c10c72e5", - "c125b747 c12564f7 -> 412564f7 4125b747", - "40755567 407601c9 -> c07601c9 c0755567", - "4155e3cd 41560cdb -> c1560cdb c155e3cd", - "c19e9c2e c19e6db6 -> 419e6db6 419e9c2e", - "40d4db7c 41224842 -> c1224842 c0d4db7c", - "41899917 4189f18d -> c189f18d c1899917", - "c0854e48 c0854cb8 -> 40854cb8 40854e48", - "c0460c91 c01d3fcf -> 401d3fcf 40460c91", - "415df45c 419f16ba -> c19f16ba c15df45c", - "40c4b6c2 40c4c0de -> c0c4c0de c0c4b6c2", - "419ca0d5 419d1f0f -> c19d1f0f c19ca0d5", - "c123a90d c10608c1 -> 410608c1 4123a90d", - "412d4d6a 413051f6 -> c13051f6 c12d4d6a", - "413c3aca 413e063e -> c13e063e c13c3aca", - "4151db7a 4189a403 -> c189a403 c151db7a", - "c109b327 c1061b09 -> 41061b09 4109b327", - "4165a424 4165d394 -> c165d394 c165a424", - "c18a52ba c183b884 -> 4183b884 418a52ba", - "bfae45c8 bfae4018 -> 3fae4018 3fae45c8", - "3ff82298 40032894 -> c0032894 bff82298", - "bff8c675 bff37a8b -> 3ff37a8b 3ff8c675", - "416ff67f 416ffcc1 -> c16ffcc1 c16ff67f", - "4074dd59 40a1b213 -> c0a1b213 c074dd59", - "40fd6b22 40fdb59e -> c0fdb59e c0fd6b22", - "c15342b4 c1527e8e -> 41527e8e 415342b4", - "c0b6e842 c0b6c97e -> 40b6c97e 40b6e842", - "412f988d 41301c77 -> c1301c77 c12f988d", - "3ee11edc 3f3365d2 -> bf3365d2 bee11edc", - "c1487a5a c1403aaa -> 41403aaa 41487a5a", - "40a80497 40a80b09 -> c0a80b09 c0a80497", - "4085dc64 4086296c -> c086296c c085dc64", - "4050283f 4083d2d9 -> c083d2d9 c050283f", - "409ac386 409ad3ea -> c09ad3ea c09ac386", - "4026fbec 412d7425 -> c12d7425 c026fbec", - "419848ab 4199a9a5 -> c199a9a5 c19848ab", - "c1160759 c0e0eb46 -> 40e0eb46 41160759", - "c070b067 c070ada9 -> 4070ada9 4070b067", - "412a4afd 412aa373 -> c12aa373 c12a4afd", - "40ea3dd3 40ea3efd -> c0ea3efd c0ea3dd3", - "c154a4ee c0e9d9ec -> 40e9d9ec 4154a4ee", - "41923416 4192497a -> c192497a c1923416", - "c01b1e3c c01ac944 -> 401ac944 401b1e3c", - "bf85d92c 40c84deb -> c0c84deb 3f85d92c", - "417d1667 417d2f79 -> c17d2f79 c17d1667", - "417ef783 417f1e0d -> c17f1e0d c17ef783", - "40597439 4073fbd7 -> c073fbd7 c0597439", - "c055d45b c0555f85 -> 40555f85 4055d45b", - "c19ea771 c19ea70b -> 419ea70b 419ea771", - "4189fc38 4189fcc8 -> c189fcc8 c189fc38", - "40943b04 4094697c -> c094697c c0943b04", - "c1633c45 c15d38dd -> 415d38dd 41633c45", - "c05e41ab c05b9cc5 -> 405b9cc5 405e41ab", - "c125e548 c1257ac4 -> 41257ac4 4125e548", - "4181134a 4184a5de -> c184a5de c181134a", - "41168c5e 41168d12 -> c1168d12 c1168c5e", - "c19fe3be c19fe26a -> 419fe26a 419fe3be", - "bdfb0d90 3defa790 -> bdefa790 3dfb0d90", - "c131cd0c c131c8e8 -> 4131c8e8 4131cd0c", - "4191a682 4191aa1e -> c191aa1e c191a682", - "c1330921 c1303f9f -> 41303f9f 41330921", - "c0ad3a1b c0ad1cc9 -> 40ad1cc9 40ad3a1b", - "c1854283 c1849975 -> 41849975 41854283", - "c18dff36 c18d6bd6 -> 418d6bd6 418dff36", - "bfd932b6 bfd92dca -> 3fd92dca 3fd932b6", - "c1946ac7 c1919bcf -> 41919bcf 41946ac7", - "3fb08ad7 3fbcb789 -> bfbcb789 bfb08ad7", - "c09b282c bffc6f91 -> 3ffc6f91 409b282c", - "4143a7f2 4143ae96 -> c143ae96 c143a7f2", - "418d9279 41ac1353 -> c1ac1353 c18d9279", - "c17ed03f c17ecf31 -> 417ecf31 417ed03f", - "c18b9784 c18b9624 -> 418b9624 418b9784", - "407f074c 40b9292a -> c0b9292a c07f074c", - "c0877482 c0870406 -> 40870406 40877482", - "c134f2eb c12cde51 -> 412cde51 4134f2eb" - ] - }, - { - "glsl": "vec2 cultmath_iv_mul(vec2, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c1694f46 c158b172 c1805b78 c17c99c3 -> 4355d0d3 4369f5ff", - "413269c5 41905796 41954606 41a1caae -> 435010ba 43b672b9", - "40903929 40bd9c3f bfbc0b38 bf9f7d48 -> c10b470d c0b3b42a", - "c1a13239 c18e87a9 40f26bc6 40f26ce2 -> c318a609 c306f83f", - "3eed17eb 3ef27f95 411dbd6f 411f7f5d -> 4092171d 409715e3", - "412d3a30 41964adc c1390ea7 c1390e03 -> c3594966 c2fa7110", - "c161b7d5 c161b5c5 405817e3 4058281d -> c23e967a c23e866e", - "40f166da 40f172e6 c1482b45 c145eb3f -> c2bcca93 c2baa1fb", - "c0c8e980 c0bc9df0 41779cca 4177a316 -> c2c25948 c2b66fe8", - "405685d4 40a69a4e 41138768 4113cdd4 -> 41f740a1 4240611d", - "414d0e3b 419d243f 408edb0d 408ee033 -> 4264dab5 42af6774", - "bffff3d5 bffe194b c18dd90f c18dd73b -> 420cc990 420dd251", - "bf8032bf bf67f442 c12dc815 bffe2118 -> 3fe64256 412e0cfa", - "40e41b45 40e7eda3 416d1ce8 416d1fc0 -> 42d34701 42d6d3c4", - "406c9fd6 406ca33a 3f96d142 3fcc93de -> 408b6713 40bd1ac1", - "c0a3340f c087b0d9 c15fe66c c15fbee2 -> 426d3074 428ebd3f", - "409c9a51 40cd4917 c0e415ab c0e3f919 -> c236e679 c20b7537", - "419baa29 419bcf77 c05524bd c048a7a3 -> c281b9fa c27405be", - "40dea32f 40debd51 40ce8876 411bd61d -> 42339dfd 428796ec", - "c0a83cb1 c0a83b37 40571eb7 406f3799 -> c19d3533 c18d5dea", - "c1854e8a c1853b60 410eb922 410eba52 -> c314a52d c3148e92", - "417c2fd8 417c33e8 418e22bc 4191cf5c -> 438c04c1 438fa5af", - "415a927e 4160d82a 40b89773 40ba446d -> 429d9a99 42a39928", - "c0e7c3d6 c0e7c2f6 c18b93b0 c18b92e2 -> 42fcb7ab 42fcba14", - "414a97b3 414a9c8d 3f2cf6fe 3f4af442 -> 4108e163 4120a0d9", - "c17dcede c174fe18 c13dc11f c13dc095 -> 433597e5 433c2132", - "c150e380 c14cce88 c0ec1221 c0ebd1db -> 42bca97b 42c0a085", - "41517f09 419f922c 413f6495 414034f7 -> 431ca017 436f9d49", - "bfd3106a becb05d6 3f9e9394 4120cebe -> c18494b6 befb8548", - "c18b902c c18b8fc6 3ddb3ff0 3dfc7810 -> c009a360 bfef0db3", - "4176abb4 41781664 bfc23afa bfc1f346 -> c1bc3a1f c1bae1db", - "41319274 4157ad34 c0d16829 c0ca6a13 -> c2b06c28 c28c6723", - "c12904ba c127b1bc c1843d6a c1843c36 -> 432d3e2c 432e9df8", - "c01c0980 40a1ed30 40862041 40864727 -> c123b0af 41a9de51", - "c1486fbe c1437018 41850fd3 41851231 -> c3506098 c34b2aa2", - "4174fbf8 41762140 413881ca 4160596e -> 4330914f 4357b313", - "418611dc 41861288 c189ecc7 c189ac79 -> c39077d8 c39033c4", - "c0acda4c c0acd85c c190e560 c18be91c -> 42bcedbc 42c3ab56", - "41078d06 41078e02 411118a2 4111bd5a -> 4299a7d7 429a5765", - "c12ef0c9 c0c59dce c1354006 c13532dc -> 428bdfd5 42f7b7fd", - "c0ccbc84 c0c730a8 c16529d5 c16517a7 -> 42b240ee 42b74617", - "41721c77 4174d279 c19d65c3 c19d256b -> c3968666 c3949ed8", - "c1369dd3 c1368ff9 413ed9cb 413ef525 -> c3083802 c3081a2c", - "c1654374 c16537e2 4015338c 40157184 -> c205d5ec c20597ae", - "412c2751 412d7783 c0c67ed7 c0bbf0c9 -> c2868062 c27cc548", - "413731ac 41507a7c c0fc40f4 c0fc3ba8 -> c2cd6d77 c2b47f96", - "3f92095e 3f929822 c014dfc0 c013a600 -> c02a8028 c0287426", - "c1216cc6 c1216bb2 c190459a c19041bc -> 4335ec0e 4335f226", - "bf464f54 bf2817ac 416d19eb 416d201d -> c137b051 c11baeef", - "c036ab99 c034dde7 419f9da3 419fa265 -> c263d0e9 c2618a63", - "c181ded4 c1814df2 c109ce28 c109cd58 -> 430b34dd 430bd1aa", - "c111473d c10cc3eb 4095b255 40961b6b -> c22a5e9a c224a02d", - "3f370113 3f39eead 411dec7b 41232db5 -> 40e1c96b 40ed0855", - "405c1ccb 405e77c5 be4ba366 be2a529a -> bf30f6f8 bf127224", - "c122bfcc c00f7102 4140155c 414102a4 -> c2f5688d c1d74173", - "c13e1548 c13d2954 c11ef090 c11eeeb8 -> 42eadfcc 42ec0783", - "c11c2b33 c11b5691 4174a726 417558ba -> c315ab78 c31473ef", - "c04dbda1 c04d7a8f 41775f07 41776951 -> c246d69a c2468d86", - "40571462 4057184e 408b02e8 408b0f50 -> 41699505 4169ae20", - "400ce9d0 400d04f0 416a51db 41819f8a -> 4200fac7 420ecebe", - "4106dce6 4106dd6a 41863b72 41925b0a -> 430d6de3 431a3479", - "c0d5b574 c0d58984 40505475 4123f893 -> c288e20b c1adc62e", - "c173ea65 c173ce0d 417a25c1 417a6ddf -> c36e9b96 c36e3b2d", - "40f1d152 40f25cd6 c189fb3d c189910d -> c302a189 c301f209", - "c0e89de5 c0e89913 413de44d 41455493 -> c2b34e5b c2ac8871", - "4144a449 4144a56f c19f61b3 c19f5fc1 -> c374db98 c374d72d", - "3f7e58da 3f821113 c173f42e c17361e6 -> c177e489 c171cf9b", - "41817315 41817723 418f2b10 418f2bb8 -> 4390ca1e 4390cf51", - "c19bc3e8 c14fd061 415ac804 415acb64 -> c3852095 c33199d1", - "40914fb2 4091b1ae 4121da09 415b1cef -> 4237bdc4 427966ef", - "4151d8c1 41869ad4 c06a66b4 c06a63bc -> c2767f0c c24021e1", - "c03041e6 c02f45da 4068ad60 4068b560 -> c1203899 c11f4e01", - "c19df23a c19df1ca 4185a63b 4185baf9 -> c3a50468 c3a4ea5a", - "c0166159 c01657e7 c196823a c1957d5a -> 422f958e 4230d313", - "c19c258d c198013b c1095acc c0d12abf -> 42f864c6 43278ef4", - "c12ef81c c12ef594 c19357a0 c1837498 -> 4333aeb4 434968b8", - "c067c05f c02eb281 c0c0a61e c0b2dfc2 -> 4174219f 41ae66a9", - "4034ea46 40b0c8a5 4178a1ae 41966b35 -> 422fb536 42cfbf32", - "c0e5ef97 c089e459 414e7443 417d560d -> c2e38b12 c25e68be", - "408dc086 41212449 41291f0e 4129202e -> 423b4a95 42d4ea6b", - "41328228 4199e7cc bf1dd5ea 3f72b2aa -> c13dc785 4191e888", - "c0cb9dd7 c0c9e475 4074af32 410f5be4 -> c2640c83 c1c0f7ea", - "4189f1d7 4189f471 c168a66a c1447a26 -> c37abe68 c353bdf5", - "c1918a86 c1571193 40e599d0 40f1c598 -> c30973be c2c0e3f1", - "415f3c81 41601fcf 40a52ac3 40aa50fd -> 42900749 42951c07", - "c18df482 c17a7094 3faae136 3faaee4a -> c1bd9101 c1a72b14", - "c168b422 c168b3a6 c191e316 c1917096 -> 43843418 43849c73", - "c1048a12 c1048812 418cb8ba 418cb92e -> c311b6c3 c311b418", - "419922c5 41992573 419a575f 419a5ad1 -> 43b8a65c 43b8adb7", - "40c534aa 40c53fa6 bee9f0ac 3ff2b7cb -> c034405e 413b03c8", - "c16cbe71 c16c8f03 413d2d99 413d4f7f -> c32f121e c32ecfb8", - "410dbaa5 410dbb73 413eb6e8 413eeb0c -> 42d32b93 42d36682", - "c13b1d7a c13b1b58 c191f614 c191f524 -> 43555b51 43555f1e", - "c0e7639a c0e7603a c19e58ab c19e586d -> 430f1d4f 430f1f9e", - "c00515cc c0048da4 41018d2a 41019ebe -> c186c504 c18628ef", - "3d725d59 3d73d2a7 40b03573 40cdce1d -> 3ea6d2c7 3ec403ff", - "c10c1d01 c10c1bc3 4166aad8 4187badc -> c3149322 c2fc7ce4", - "4190e714 4191072c c18cb3e9 c18ba5ed -> c39f6bb0 c39e16c6", - "c1988e3d c193b1f3 3ea9e618 3f0e2174 -> c12965ab c0c40a72", - "c18a1c17 c18a1af1 c08194ad c08192ab -> 428bcd66 428bd0ba", - "c1363aea c1341ff4 c0ca6ea8 c0ca6a10 -> 428e6bd7 42901942", - "c18645fc c17b229c 41102e60 412e8a08 -> c33717ee c30d70f6", - "c16ad0ad c0fc0316 413e1074 413e19a4 -> c32e5e65 c2bb1a7d", - "3f6b9e8d 3f6bd9f3 c0a2c24c c0a2c144 -> c095f2ed c095cc36", - "4128a59e 4128a60a c17f7a9e c17d58c4 -> c3284e2b c326e627", - "c1746457 c136f51b bfd0b6cd bf6f07a6 -> 412ad44c 41c7400a", - "c1860efd c185f53f c17f8619 c17e7c11 -> 43852a40 4385cf27", - "408f16aa 408f3d96 418f2903 418f2f5d -> 42a0092b 42a03bce", - "419ab7ff 419bc785 c186b2b4 c16647f0 -> c3a3ee5c c38b2cc9", - "412b8c3c 412c0d00 40fea06a 40ff5fde -> 42aaa0a2 42aba161", - "c0c33010 c0c32ed0 400fca1a 412ced7a -> c283d95b c15b427a", - "40a735d0 40c452e8 c185fb82 c172c7ac -> c2cd7fe7 c29e934a", - "c09519be c0942fca 4182031c 4182038c -> c2977247 c2968423", - "c193cf36 c18de40e 4183c767 4183cde1 -> c39833cf c3921471", - "c15cd10f c15ba41b c18b03c7 c18922ff -> 436b51b2 436fd18a", - "4103b281 4103b603 c138b7de c10f3d30 -> c2be12d7 c2936061", - "c19a03ac c199c3de c122776c c0e17198 -> 43076961 43437c57", - "c185ef64 c185b21c c11f0e10 c11f0580 -> 432618fd 43266e15", - "c0fe0eea c0f99a56 c10e729e c10e70cc -> 428ae196 428d5e05", - "c11dda37 c11d719d c16efb90 c16ef018 -> 4312f349 43135bfd", - "c0e7d8fb c0e7c839 c14dac20 c14daa7c -> 42ba35b1 42ba44a4", - "c083a998 bfc79d62 c11f668b c11f61e1 -> 41788e24 4223f625", - "40fe52db 411106cf 410de9fc 410deddc -> 428cfc16 42a0cf00", - "c030b678 c030b448 412b7ae1 412b7d7f -> c1ecc106 c1ecba7b", - "41350d35 4141d35b 419591f0 41959300 -> 43538fcc 43627ea1", - "3e8a9896 3e8b1f6a 410ea514 413b0de4 -> 401a7405 404b4efe", - "c127ed94 c1255340 41280425 412836e3 -> c2dcafd4 c2d9029e", - "bf0d6820 3e8723c0 c1921a1b c190377f -> c09a4057 4121679b", - "c021d94f bfdf18c2 c0b9925f c0b90afd -> 41214278 416aa528", - "c19d7dd3 c19d7cfb bfed425d bfed3263 -> 4211ebb4 4211f650", - "c1216fbf c1216ecb c1490e71 c1490507 -> 42fd8652 42fd93b1", - "412f0172 412f023a 4155223f 41552c51 -> 4311b39d 4311bb26", - "4166e8e8 4166ea78 c0d184a9 c0d0c64f -> c2bcfd15 c2bc501c", - "c0643536 4096028b 4134e558 4134e6e8 -> c2214341 42540230", - "3e39ebb6 3e3cce4a 416d002f 417abf21 -> 402c1f5a 4038ee6b", - "c17f94b4 c1685bfc 40cb6ae3 412d67c6 -> c32d1f18 c2b8a1f5", - "41287216 412872ca 411da7a5 41209017 -> 42cf788d 42d34d1c", - "40d95cf9 40d97f3f c15fc02e c15c2d70 -> c2be191e c2baf27a", - "c0f4467c c0c72e38 417d06f5 417d42eb -> c2f1a983 c2c4de17", - "c19acd57 c19a96a5 c17643ab c1764049 -> 4394b394 4394ea3d", - "4145af3f 41461ba1 4013b3a8 401435c8 -> 41e41cb9 41e5632f", - "c00d2f5b c0087cb5 c1597df0 c1592912 -> 41e78f36 41efe531", - "419ed972 419edca6 418af223 418e0dbd -> 43ac6eed 43b04dd5", - "c126d3a2 c1235f40 c19a0669 c199edf5 -> 43447792 4348befa", - "c0b4d50b c0b4c581 3e180454 3f1365ab -> c0503c4c bf56b0a6", - "c0f62ce4 c0f6264c 4089d8af 408b6301 -> c2060994 c2048ad7", - "41935e5d 4195185b c1646060 c1602828 -> c38501d2 c38109af", - "c183edf2 c183e27c c1800b6d c1800b2b -> 4383edfe 4383f9b9", - "c1529fe6 c14db27a 41983cdc 41996cc0 -> c37c7614 c374a5be", - "c11051f1 c1103e93 bf1ebf59 bf1e84e7 -> 40b2a302 40b2fce4", - "41779378 41779e68 40c6c61b 40c73b45 -> 42c03ba5 42c0b577", - "c0931f8b c092a489 c03f5300 c0329100 -> 414c92ed 415be878", - "4146d27e 4147398a c18ac29f c185a7d7 -> c357f8f3 c34f9b6c", - "41985f46 41987156 416f526e 41718832 -> 438e7202 438fd3cc", - "4170c859 4170c8df c06e3241 c03bf83f -> c2600a04 c230cbd6", - "c03c7486 c03aea9a c0a2202a c09ca2fe -> 4164bbf0 416eb2d5", - "c1836ef6 c1474e6b 3fd96d3c 3fe02b84 -> c1e62edd c1a94684", - "40f21dd0 40f26260 c165dc35 c165dbab -> c2d9a27f c2d9646c", - "412d77f7 412d8815 41592330 415923b8 -> 43132288 43133090", - "3f837775 3f8390ab c15f8d78 c15edad8 -> c165c773 c164e3f4", - "c12737c1 c126c8d3 416e02a8 416fc200 -> c31c9bc5 c31b106f", - "c10fe873 c10fd42f c195a3d0 c18edb2c -> 432085ab 43283cc2", - "414e0e63 414e254d 412523b8 41252b48 -> 4304ec06 430500e5", - "4184780b 41872a79 41287758 4128a5a8 -> 432e5911 433216ad", - "418326d3 4183270d c1053184 c104da84 -> c3087950 c3081fef", - "41661822 4187f337 41968eac 4196aa70 -> 43875260 43a0060a", - "c0cdb69a c0cdb522 419bfd0b 419d890d -> c2fd2e3b c2fab001", - "3f88b490 403a9738 c1807e1a c17bfba4 -> c23b4f0b c1868f6a", - "41569685 41818b3e bf6a2030 40836256 -> c16cf321 4284f807", - "40716f1c 408ecfc2 c0b44783 c09443c1 -> c1c923f2 c18bd422", - "416c4670 41761408 410e3b57 410e4fcd -> 430345d7 4308cbd2", - "406c17ca 40cdc42b c17c66cc c17c65ee -> c2cadfba c268c56c", - "400df691 400eda4f c1784e9a c177b0ec -> c20a8f59 c2095b02", - "41744b1a 41789726 40ada49c 40add5c4 -> 42a5b3d6 42a8cdb9", - "3f206575 3f24c90b c114415a c1143bea -> c0bedc97 c0b9c063", - "c0c16854 c0c122d8 c160d730 c0e2759f -> 422ad980 42a9dddc", - "c121cf74 c121cea6 c09582d3 c09581ad -> 423cfe7a 423d00de", - "c1606cc2 c14b853a 4144f1eb 4144f405 -> c32ca931 c31c9254", - "40aed24c 40afbedc 4062ca23 4062d1dd -> 419adfb1 419bb691", - "c15a05f1 c157bd09 413fd159 41401b9f -> c3239bfb c321a676", - "417b4450 419f1d98 c17ef2ef c17ef147 -> c39e765b c37a3a98", - "41197214 411acbd8 4148eaab 4148ee15 -> 42f0db91 42f2fe6e", - "c11e037e c11e0014 c041e4a1 c041dabf -> 41ef4a22 41ef5b81", - "bcb369a8 bcaef658 bffc892c bff8e174 -> 3d2a18bb 3d30fc24", - "3f11d32f 3f93ec48 c182a95b c1821c93 -> c196ffb0 c1143b09", - "3e33d374 3e34128c 417c3df4 4181cb76 -> 40312fab 403698ed", - "3fa34782 41064e78 417337de 41735da2 -> 419b2082 42ff5b37", - "c18104f2 c180c36e c158c7d3 c12e3df3 -> 432f47fb 435a81c3", - "40a8a02d 40cf653b c10d12a8 c10cdc40 -> c26493bd c2399159", - "c10a35a6 c10a341e c12fc5f1 c12c82b7 -> 42ba432b 42bdcb14", - "c1232468 c123205c 40e060e9 41715e8c -> c319d186 c28efa11", - "c0843c4c c07ce04f 40b60808 40b6eec0 -> c1bcfc63 c1b3cf67", - "c192db43 c192daa1 4090ae6f 409107c9 -> c2a66550 c2a5fe16", - "3fc4886f 3fc4b811 418652ce 4197f3ca -> 41ce3df8 41e987d0", - "c1983216 c19823b6 beaf75af 3ebc69af -> c0e00739 40d0a068", - "4103303a 41036462 c1867425 c181d815 -> c30a0450 c3051411", - "419c847e 419cea5a 3e755ab6 3eff7c25 -> 40960242 411c9988", - "416b0c0d 416b0c9b c13b8d11 c13b60bb -> c32c33bb c32c0a9e", - "3f8290f3 3f84634d c0e374fe c0e3596a -> c0eb411b c0e7e844", - "c11f3ce8 c0c15478 c122bea6 c049c367 -> 41985ee3 42ca7643", - "c0dc69ba c0dc208a c12e9370 bf7056b8 -> 40cea913 42964ece", - "4171535f 417f18e1 c0c4a1b2 c0c44106 -> c2c3f02c c2b90121", - "416c4d1a 416c7ba6 c0bbc3d3 c007857a -> c2ad7337 c1fa2fbb", - "409217e0 4092b6d0 418ce11f 41977079 -> 42a0cb0e 42ad9494", - "c178608d c1786003 419563df 41a54855 -> c3a05c69 c390f0c7", - "c18b9c02 c1328759 409d05a8 409d06a0 -> c2ab4494 c25b01e7", - "4179d3f8 4179d860 41746397 41746501 -> 436e7f39 436e84cf", - "41829a3a 4183e5d6 402f7ac9 402f8057 -> 42330c23 4234d87a", - "c194ba0d c1945d73 c013852c c01347a4 -> 422ab65c 422b6867", - "c189e2b7 c189e227 4169224b 41692685 -> c37b2830 c37b229c", - "c1449b34 c14499fc 414870f5 4148bf23 -> c31a2c0b c319ef0c", - "40a178fa 40a190ae 413b31c5 413b32ab -> 426c2586 426c4953", - "bf879713 bf839fcd c1442851 c1441e7f -> 4149ac0e 414fca0a", - "418879a3 4188a98d 41512437 41514099 -> 435efd39 435f69d0", - "412b2e55 412b4233 c17c096d c177f23b -> c3289b78 c325cbad", - "4181a106 4181a43a 3e2c801a 3e2de7e6 -> 402eb21b 403022d6", - "415b3746 415b4362 41729153 41729265 -> 434fb6b2 434fc316", - "c19bccfe c19a8190 41233382 4123340e -> c346a668 c344ff2a", - "c160c1f4 c152acf2 40d584cb 40d58635 -> c2bb7734 c2afb72e", - "c162582d c1625563 c09042dc c08d2174 -> 42798d36 427f196d", - "c08113af c0372d12 40ab2396 40ab8192 -> c1acf2f5 c174e923", - "c0046109 c0043177 c14dcc8c c14cc432 -> 41d37975 41d4d6f4", - "4102ae33 4102af29 3fd57a01 4007f8af -> 4159f270 418ad2a3", - "4198ebc9 4198ed77 c1309f5b c0a4c112 -> c35304e7 c2c4d4c3", - "40654321 406ab46f 409151d2 40917746 -> 4182244c 41855d8d", - "c0694bb5 c052cd3b c194d6b4 c1894350 -> 42620e84 4287a36e", - "411ba844 411bab20 c175aa14 c175a814 -> c3156231 c3155e3c", - "413e2f03 414acbad c132dc3c c1313dde -> c30db015 c303ac77", - "418f6cc7 418fb689 c114a792 c114a666 -> c326e732 c3269039", - "40864f29 40865187 41323946 41331f92 -> 423b022e 423bf724", - "c1767bf8 c1766c34 c0ebb620 c013747f -> 420df045 42e2f328", - "c181ca2d c181c9e9 c1afc24a c164a557 -> 4367d74e 43b2376b", - "bf0877d2 be2ab3b7 bfe0a1d6 bfd8844a -> 3e905fd8 3f6f7e3a", - "40078336 4007865a c14c6080 c1470a64 -> c1d8644c c1d2b8fe", - "411ebd1c 412f10a8 40d7e793 40d7fc05 -> 4285e06a 4293b355", - "c14f1754 c14f16ac 41017cc5 4144d95b -> c31f3db1 c2d17eb6", - "41366e50 41866020 41352180 413579ac -> 430113de 433e83a9", - "4184cd5e 4184cf92 c0c1a77e c0c0a966 -> c2c8eec4 c2c7e3ce", - "4144511b 414451f5 c1350da9 c1350c6b -> c30ad86c c30ad6de", - "c0d98a09 c0d9870f 4114ed38 411b4ed8 -> c283f993 c27d174d", - "c171d3bf c171d1b7 40bba9aa 40bbac16 -> c2b1483c c2b14475", - "c0e68dd9 c0e0113f c19c2cd8 c1850f8e -> 42e8ed26 430ca6d3", - "c0df2b7b c0dd13c9 c0e975b5 c0c84457 -> 422cf279 424b8530", - "c0449cf7 c0429859 c0a1d821 c0a1d637 -> 4176094a 4178996a", - "401e607d 401f9283 c183b899 c183b779 -> c2243613 c222f9c4", - "c1272daa c125e7ba c18c27e4 c18c2272 -> 4335a219 43370e0c", - "c108e844 c01646b8 41222075 41229303 -> c2ade334 c1be579c", - "41593487 415935a9 c0a35943 c09dbe6d -> c28a98e7 c285d6c8", - "c1a19e41 c16ac0de c15b5835 c15b5793 -> 4349234c 438a7a11", - "c089ec3a c0837c16 40831d81 408324e7 -> c18d4f87 c186af4d", - "416816da 418ae2e3 c1665d71 c16645e5 -> c379f513 c350c3e6", - "4170084f 4170e411 c18819d2 c18812cc -> c3801175 c37f2c14", - "40f33ebc 40f34304 3e2c1868 4023e6ea -> 3fa38557 419bbf18", - "c198c381 c1980da9 bf4f787b bf425785 -> 4166dcab 41779bf5", - "c1875f42 c1875216 41137e03 41139905 -> c31c193b c31bed7d", - "4182374b 4182b6a5 c18f1e7f c18f1b55 -> c3922731 c3919594" - ] - }, - { - "glsl": "vec2 cultmath_iv_scale(vec2, float)", - "tolerance": "ulp-bounded", - "cases": [ - "c14964a3 c1454919 3ff4d8d0 -> c1c09e7c c1bcb0c2", - "bf801a8d bf7ee327 bfa7b39e -> 3fa6f905 3fa7d667", - "40b16d65 410c1e96 403421fe -> 4179b0f4 41c53039", - "417e3caf 417e43f1 bf9afb3c -> c199ee67 c199ea02", - "c024e649 c00e2837 bf39e34c -> 3fce728f 3fef79a8", - "41365d3e 416062ea beda6b40 -> c0bf723d c09b97cd", - "413d22b6 4141f516 3edf4070 -> 40a4f0d8 40a92550", - "bdebc5f7 3c94cfdc be51bc50 -> bb73d654 3cc12a0e", - "bfaa9cc3 bf9b59bd 406bab38 -> c09d1003 c08f0347", - "c1a74fcf c1838089 c005d22f -> 42097b7e 422eeba9", - "c10aa88c c10a941e 402d3cec -> c1bba9cc c1bb8e25", - "4180b9f6 4180bb4e c01cc28a -> c21da7ee c21da648", - "41438f62 4145277e 406dd60e -> 4235af42 42372a69", - "c0bb74f5 c0bac83b 3f87eb88 -> c0c70e4a c0c656e0", - "c198555b c198547b bfa3d910 -> 41c2fde7 41c2ff06", - "c16bb226 c16bb0d2 bf884872 -> 417af144 417af2af", - "41821fd6 419f6d76 be244f50 -> c04ca708 c027096b", - "bfefaa1f bf9f6ac1 bf927a70 -> 3fb66e41 400921a6", - "40e62ef8 40ef2d00 c062d988 -> c1d3f0f6 c1cbf90f", - "c11695ff c116958d 3fe8a5b4 -> c188d968 c188d900", - "c0a1818e c09c1796 407140aa -> c19833c2 c19319a2", - "408f01fb 4092c2e5 4051f6ea -> 416a9519 4170bd55", - "3ec659eb 3edf5b15 3ebf7bd0 -> 3e145d05 3e2710fb", - "c1362416 c13623a0 bfdcfdc8 -> 419d3b2d 419d3b93", - "bf38ee46 bf349bfa c009b73e -> 3fc25180 3fc6f7c5", - "4186df32 41870faa bc442f00 -> be4f0194 be4eb74b", - "c16a04e7 c169f133 3dda1480 -> bfc75aea bfc74a21", - "406f0b1d 406f0f43 c0771523 -> c166bb77 c166b776", - "411b3586 412fe96a 3f242568 -> 40c709ef 40e19678", - "bf3e9e00 bf3e4c80 be57f490 -> 3e20880b 3e20cccc", - "c168cc6a c167fa1c 3f3e1190 -> c12cd7af c12c3b8b", - "c1661e9e c0d432c4 402363ce -> c212df36 c1876f0d", - "40ce9662 40cef31e 3dce62c0 -> 3f268cb3 3f26d776", - "c03789b2 c02f58be 3f038540 -> bfbc95fd bfb42b5c", - "41490793 4150c72d 404db8a6 -> 42218c11 4227c616", - "c180b91e c103fced bfbe7fbc -> 41446f27 41bf933d", - "c1748b49 c16a43a7 c011f60e -> 4205917b 420b6df0", - "4015919c 401598f4 3fae8750 -> 404bf00d 404bfa11", - "c13da8a8 c13091d2 3f051ba0 -> c0c53a2d c0b79da0", - "4189b7c7 4198b379 40153c8c -> 42209112 42320926", - "c0d9aeaa c0d9ad86 bfb98890 -> 411dc284 411dc358", - "c1889b08 c1889a86 be7f07a0 -> 408815fd 4088167f", - "40f4f0ef 40f4fea9 be84b1d8 -> bffdfb04 bffdecc9", - "c06197a4 c06176dc c05f348b -> 414494d0 4144b165", - "419a286b 419cd27d 3fdc2a38 -> 42049428 4206dec0", - "418cc54b 4192a5e1 bfa017aa -> c1b76a76 c1b010a4", - "c17686e4 c1757b92 402fdff8 -> c2295de4 c228a63d", - "c115b0be c1159836 beaea588 -> 404c1c5f 404c3dd7", - "c11b0b5d c119cbb7 bf34a690 -> 40d90e9b 40dad1bc", - "41872854 41872898 c01bff8c -> c224b8ff c224b8ac", - "c1202004 c11a97ba 3ee67ae0 -> c090299f c08b2e85", - "410d8386 410d84d2 3f3d84e8 -> 40d18724 40d18910", - "c1274a40 c11e97c6 3fa24f98 -> c15421ff c1491ab5", - "c02cc2ce c02aa1f2 3fefabbc -> c0a1bdc3 c09fbfa8", - "415ab2ce 4160a51a 3c2fba00 -> 3e161f21 3e1a3415", - "c1600727 c15edca1 bf17f324 -> 410447ce 4104f8fe", - "4191baef 4191bf41 c07b379a -> c28f062c c28f01ef", - "c13ec27a c125eeae bfd56ee2 -> 418a5776 419f0a6f", - "418f59a5 418f5a13 3fb19668 -> 41c6e268 41c6e300", - "415de36d 4170c593 39cc8000 -> 3bb1402d 3bc055d4", - "c1908903 c18aef89 c00ea7a6 -> 421ad7b5 4221154e", - "c111bd9d c111bb19 3ed6ef00 -> c074b923 c074b4e9", - "3e9ed994 3e9fedec 3f5614d8 -> 3e84d6d1 3e85bde9", - "c17442df c16efb6d c0729a68 -> 426279d1 42677a8a", - "40e8d9c0 40f12420 c0620460 -> c1d4e603 c1cd9436", - "c17a0d1c c179d9a6 3f90d614 -> c18d787a c18d5b5d", - "4191ece3 4191ed99 c07cf598 -> c29031e2 c290312e", - "41802de9 41b6da07 40046e1e -> 42049d9e 423d2e25", - "c148fa3a c148f9a2 403d3bba -> c2148fa1 c2148f30", - "c11c76dd c110b81f c06d755a -> 42063ccc 421121c4", - "41861541 41862647 405d858e -> 42680c99 42682a0f", - "c15aa5c0 c15a86bc 3ff10278 -> c1cdd826 c1cdbaf2", - "3ef09e19 3f0b4d73 3ee66830 -> 3e588ff8 3e7ac08e", - "418efaff 41904b51 bfc4e088 -> c1ddf071 c1dbeb26", - "4141ec18 41594ee8 3efa4900 -> 40bd97dc 40d47506", - "419a6ca3 419acedd c0306582 -> c2555734 c254cfd7", - "c13756da c11e68d0 3f9362fc -> c1531b86 c13666df", - "c1a33b0f c1884cbd 3fd37f6c -> c206daed c1e1362f", - "be715eb7 be712349 401aa9ce -> bf11d314 bf11af2c", - "bfbede0d bfbed533 c040021d -> 408f217a 408f281d", - "40ea0ea6 40ea1c1a bd88f880 -> befa845c befa75f7", - "402edc4c 402eed54 bfb896e0 -> c07c4359 c07c2ac9", - "c1824002 c181e7f2 bfc5cdbe -> 41c8bfc9 41c947df", - "c0e3d8b2 c0e0c35a 403105d0 -> c19d8dff c19b6c2c", - "c184bd59 c184bd21 be9050e0 -> 4095a8a4 4095a8e3", - "40fdaff6 40fdb56a c03b687d -> c1b9bb12 c1b9b714", - "c14193e1 c1418fa7 bcde1980 -> 3ea7eddb 3ea7f185", - "41090940 410909d8 405e877a -> 41ee3d15 41ee3e1e", - "c0b581f5 c03c8086 be2ffa50 -> 3f01942c 3f798aa0", - "c130f64b c12d9b15 bfc7ec1e -> 418793ad 418a32ac", - "418aa675 418aa6d3 bdc886e0 -> bfd936c3 bfd93630", - "c03005d3 c02fe2cd bf4ccb9c -> 400cb49f 400cd0a4", - "414a499b 414a5125 3f84b9a0 -> 4151c143 4151c914", - "c13bfc6c c10f102a c07b249c -> 420c594f 42386b60", - "4142cf0e 417b745a c0043a19 -> c201e10f c1c93df2", - "41137b39 416a31fb 404beb16 -> 41eaf44a 423a8cb2", - "c12ce57f c11da1f7 405010e0 -> c20c85dd c2001dfd", - "40d7250b 40d73665 40445c02 -> 41a505af 41a512ff", - "3fd29f26 4109fd53 c013c494 -> c19f4cd9 c073263d", - "4011ed90 4011fa00 bfbc3000 -> c0569dee c0568ba5", - "4149003a 416bc24e 4039858c -> 4211aa05 422ada67", - "c19f5fa0 c19f4d64 3ebfca70 -> c0eeccbf c0eeb16d", - "c0b8c0f5 c0b2cce7 3ff6f410 -> c132398f c12c7b5c", - "c19591c0 c180fb42 4052d1b4 -> c2765829 c2546f88", - "c0361295 404c5d95 bfbf5b0a -> c098c27f 4088189d", - "bfc9ee31 3f0c2ce2 c04198ac -> bfd402de 4098b500", - "40f5653c 40f8629c 406173b6 -> 41d81ce5 41dabef0", - "bf773ac8 40ec51a9 403ca41c -> c0362da8 41ae2376", - "c0821a03 c08208a9 4011ce08 -> c11432e1 c1141f1e", - "4069c93d 4095fa42 bfcfa26e -> c0f34908 c0bd9e0e", - "c1474df3 c14745dd c0589df8 -> 42289de9 4228a4c1", - "c0ef0500 c0eeb2f0 c074976b -> 41e40fbc 41e45e24", - "c16f81c4 c15427a0 3e22f940 -> c018794f c0070fa3", - "40f93e6f 40f9c091 bfd41978 -> c14eec51 c14e8080", - "c15b7440 c15b711c 4053de22 -> c2359f3d c2359ca3", - "419e46cf 419e4829 bfc3965a -> c1f1dbda c1f1d9ca", - "40342b76 403433ca c04b1ef6 -> c10efadc c10ef441", - "c18bba13 c175f99e 3f27cfb8 -> c1372f85 c1213d6c", - "c09ee58e c09ed506 40441e28 -> c17374f1 c1735b9d", - "419da210 419e77bc c040222b -> c26ddde7 c26c9d2c", - "412303be 412c6872 4033b9d4 -> 41e4e3e5 41f2145c", - "c05c6d9c bf8543c7 3f7bf1b8 -> c058ef9a bf832749", - "415649c0 41564d70 3ee58090 -> 40c01b96 40c01ee4", - "c105e5e3 c105d15d c076524c -> 4200c234 4200d5f4", - "bf4df8d8 410f6aee c031342e -> c1c68c54 400e9309", - "40bc8ba7 40bcf691 401d5b02 -> 4167c959 41684cc8", - "4191710b 4191866d c04c1276 -> c268033b c267e124", - "bf780cd7 bf780329 3fa586c0 -> bfa062d7 bfa05c95", - "c143df75 c143de2d bf5721c8 -> 41249970 41249a84", - "c028afb8 400efcb8 c038be96 -> c0ce602f 40f377c3", - "c166e429 c166e1c5 c003a3f4 -> 41ed72cb 41ed7541", - "c0d012c2 bff1521a 3fbeeed0 -> c11b3006 c033fc0e", - "c020a7cc c00919d4 bfcbec32 -> 405a6bf3 407ff292", - "c105e729 c105e495 407211b4 -> c1fd3b8f c1fd36ae", - "4121e0d4 4121eb10 401a3f1c -> 41c3124f 41c31ea4", - "c1851bf6 c184e3de 403b7a36 -> c242f5f0 c242a3c8", - "c04640d3 c02a2e0d 402cfaba -> c105f5b9 c0e5fb3b", - "c187c632 c187c5e0 c019a3c5 -> 4222f83d 4222f89f", - "c1988c95 c198870d 3fe12800 -> c2062b65 c2062688", - "c146cf94 c146c84c 400dd98a -> c1dc528b c1dc4a7a", - "c12e1426 c12dffa8 bffc7548 -> 41ab9760 41abab96", - "c054db71 c054d20f c02061d6 -> 4105549f 41055a80", - "4130a3db 4130a849 c05eac5c -> c219a8e0 c219a505", - "bfa6c54b bfa6a255 3fd6fcd0 -> c00c0d9e c00bf042", - "3e1e8f1f 3eba1170 c003159a -> bf3e8d3f bea2613c", - "c170f75c c16a630e 400236a0 -> c1f5220f c1ee70a1", - "4166a49b 4166a60d 3f6484f0 -> 414de25f 414de3a9", - "3f9361d6 3f9368ea c014f350 -> c02b8984 c02b8147", - "c0fe5024 c0fe4e70 c045a710 -> 41c45851 41c459a2", - "c1924785 c19238b5 3f961e88 -> c1ab8eb4 c1ab7d55", - "41954c40 41955000 be96bd90 -> c0afd6e0 c0afd276", - "3f73c0a1 3f73ce1f 4023cdec -> 401bf7b8 401c005b", - "410c55a0 410c6940 c03e7fd8 -> c1d0f878 c1d0db43", - "40928419 4092a09f bfe09356 -> c100a0ef c10087e9", - "410ddcb7 417383b9 3e3acd40 -> 3fcf0834 4031b0f2", - "c16eb44d c16d94e3 bf7f233c -> 416cc801 416de673", - "41860118 419dcd30 3f01f678 -> 41080f22 412038a5", - "4194f5d9 4194fee3 c0381ce8 -> c256500c c256430c", - "c1589be3 c153975d bfe888d4 -> 41c03244 41c4c10c", - "c191ccf8 c191cc32 c052e7d0 -> 42703b0d 42703c54", - "c18a8e77 c186db01 402b8490 -> c239a9d2 c234b43d", - "c051afbb c04fa475 40680406 -> c13e0a8d c13c304d", - "c1639c5e c0c118c5 3f4f1dd0 -> c13825f2 c09c3984", - "c042cccd c0421673 bf6806a4 -> 402fe961 40308ea7", - "40a1c13a 40a1cf1e 401a38ba -> 4142e429 4142f4e6", - "c0df6acd c0d17eab c0498db4 -> 41a4f06a 41afe686", - "40ee6ca4 40ee72ac bd3ab040 -> beade37b beaddf15", - "4118a9a1 4118aabf be3b3020 -> bfdf42d9 bfdf4137", - "c1856514 c18564de 4058d0ce -> c261f42d c261f3d1", - "c0e2ec51 c0e2b99b bf8bd570 -> 40f7af9e 40f7e704", - "3fe18c23 3fffe29d c00f11dd -> c08f0171 c07c1a09", - "c193735d c1930aad 3f1a3f60 -> c131afcd c13131a6", - "c00b4a31 c00ac41f bea4ea98 -> 3f32c99b 3f337658", - "3fc1b053 4081dff3 3f314530 -> 3f861f42 4033dde1", - "412f2e2b 412fe92d bdef60e0 -> bfa47d42 bfa3ce65", - "c14eeb10 c14ed6bc c0557124 -> 422c7414 422c8507", - "c0e5a8bf c0b60371 407170c6 -> c1d89907 c1aba96c", - "c1557108 c15557c0 40625d9c -> c23cbbd5 c23ca57a", - "406fe84a 40703526 3f9587b8 -> 408c2163 408c4e48", - "c0b6088b c0b5e1a1 baa81000 -> 3beecee0 3bef01f8", - "c1a72a9e c185d55c 3f7ea2b8 -> c1a6468a c1851ec2", - "c13b4cbb c11475d9 3feff79c -> c1af91cc c18b299e", - "c1565b24 c154fc5a 3fd10f34 -> c1af0d23 c1adeeac", - "c144c2b7 c11a1711 bf9e96da -> 413eea12 4173c83d", - "40bba57a 40bba89e bfd4b7ba -> c11bee51 c11bebb5", - "414ff321 419cfb60 3ee1c500 -> 40b764b6 410a71bd", - "418fbfa2 41aafa66 3fa5be38 -> 41ba22a6 41dd64de", - "4117958a 418e07ab 3e42aac0 -> 3fe688db 40580116", - "c08a856f c08a4409 bfbb8a44 -> 40ca94c0 40caf492", - "c10dee27 c10da887 c015c7c1 -> 41a5c33f 41a614b8", - "41895f36 41895fc6 c067d08c -> c278caa9 c278c9a4", - "4192f782 41935e1a 406a1556 -> 4286627d 4286c04c", - "4193b808 41941abc 3f9e9670 -> 41b704c7 41b77f11", - "4120ab39 4120abaf 4001586c -> 41a25b8d 41a25c04", - "c09aef5e c09aec5a 40661442 -> c18b3f51 c18b3c9b", - "40a13379 40a2797f c0045e3e -> c12804eb c126b3c5", - "40bb80df 40c41e79 bf851d12 -> c0cbf434 c0c2fe7d", - "c182efea c182e20e bf117e84 -> 4114c571 4114d532", - "41584d0c 415850ac 4061760a -> 423e7f74 423e82a5", - "c1869865 c1721431 bcdf7480 -> 3ed34dc1 3eeaf801", - "c0958723 bff6d094 c0381688 -> 40b17ba3 41570c94", - "be08c21c be05a4e4 40183ef0 -> bea2a9c0 be9ef585", - "c1038553 c0fe5bbf 3f1d05d8 -> c0a15789 c09c0413", - "c114476c c07b4e50 bf142e38 -> 401176a5 40aba81f", - "418012bf 41801605 404aa34a -> 424ac0f7 424ac626", - "4182df6b 418308f1 403d9962 -> 4241dab7 42421839", - "4028f0ea 4053ef36 40388f62 -> 40f3978f 4118caa3", - "c1886ea0 c18751fc 40052608 -> c20deb7c c20cc365", - "414b8669 41646a87 3fe31550 -> 41b48921 41ca9d7a", - "40976405 4097675b bf98f75e -> c0b4ef55 c0b4eb58", - "c1a2bed9 c1927a07 3fc35fd0 -> c1f86891 c1df938b", - "c15abcdf c15aa9cf c041109a -> 4224e833 4224f694", - "404caa52 40b8d58f 40222492 -> 4101a105 416a2318", - "c15ebe59 c15eac5b 402aa1bc -> c2147720 c2146b22", - "40d2e15d 40d30013 3ff64758 -> 414adf54 414afce0", - "418d8d39 418d8f0f c03fcf50 -> c25420be c2541dfe", - "bf5fd134 4061d72d 3fe96d2c -> bfcc14db 40cded27", - "c189c1dd c1896a51 c056daa6 -> 4266a87b 42673b6e", - "40ae2738 40ae5148 bff6aec4 -> c127f91c c127d094", - "c09c4196 c095ed36 beab1ed0 -> 3fc86efd 3fd0e53c", - "c188cf65 c186cf41 3f04b088 -> c10dd28f c10bbfa7", - "c12f5b8d c12f4b93 c0550f48 -> 4211e458 4211f1a4", - "41137bb7 411bafa1 405076a2 -> 41f031ba 41fd8db1", - "412e9a99 412ea71f 3f220b20 -> 40dd0ad7 40dd1ab1", - "c18ee43e c18ec9be bf013b10 -> 41102934 411043f6", - "c1975709 c1973fe7 bfbea73a -> 41e14875 41e16ae9", - "c1a5b2de c18dca2e 3f9745e0 -> c1c3d376 c1a791e9", - "4076bfa9 4076c407 c01d1966 -> c1176eb4 c1176c06", - "400c9529 40f3ba0c bfa879fa -> c1206639 c03909bd", - "408cb339 408e018f 407ba066 -> 418a4be1 418b9481", - "4168d584 4168db6c c00dd0ac -> c200fea9 c200fb64", - "c0b52bf1 c0b529f7 3f988214 -> c0d7dc4b c0d7d9f0", - "c1144d00 c1140d04 407e3b2c -> c21346ad c2130722", - "40c87b03 40c883bd bed22bb8 -> c0249e4f c0249725", - "c1396876 c12f4666 3f86dae8 -> c1435671 c138a974", - "c160bf7d c160beff c04ad97e -> 423215a6 4232160a", - "40b5dc69 40b9682f 405cef02 -> 419cf334 41a002a2", - "418e771e 418e842a 40073ed0 -> 4216878b 42169554", - "4146848b 4146ea7d 3f419028 -> 411619b6 411666cb", - "c0a5fc12 c0a2a846 bf83a64a -> 40a74b88 40aab79d", - "411ef843 411efa05 c00f7524 -> c1b22ccf c1b22ad6", - "416df976 41930f11 c05e93c4 -> c27fb7e6 c24ee7b1", - "c0bcf878 c0b36640 bf9dbfe4 -> 40dd185d 40e8e40f", - "413352d2 413d45aa 407195ac -> 422939cf 42329d3e", - "c0e9ffb0 c0e9ca3c 3fc22290 -> c131735b c1314ad2", - "c140ad6c c1408d90 bfb36e64 -> 4186f604 41870c58", - "401c9e16 401e1d6a 405c5ace -> 4106cf69 4108195d", - "c1626dbc c0ea1605 4053945e -> c23b23ad c1c177d1", - "c19c79af c17a5129 403dea6e -> c2682a41 c239b325", - "bfd61ee8 bfcf16d8 3f471ae8 -> bfa68888 bfa11086", - "c19ac8c2 c1826300 402bb3b8 -> c24fa186 c22ee754", - "4051034e 40d7c5f1 c0578182 -> c1b5a466 c12ff383", - "c12d8b14 c12d7dbe 4033dc18 -> c1f3dae6 c1f3c828", - "400c9815 4047741b bfb70918 -> c08e9b15 c0490b6b", - "4115e023 41342ffd 40334c00 -> 41d1f06e 41fc6618", - "41928a76 4193a536 407ef1aa -> 4291efb7 4293094c" - ] - }, - { - "glsl": "vec2 cultmath_iv_abs(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c1889861 c187aeb5 -> 4187aeb5 41889861", - "c17f5b90 c17f526c -> 417f526c 417f5b90", - "41467e93 41468065 -> 41467e93 41468065", - "c0181fcf c015aba1 -> 4015aba1 40181fcf", - "c159fa8b c159ec93 -> 4159ec93 4159fa8b", - "411bf84c 4195b1ea -> 411bf84c 4195b1ea", - "c15c1f7c c12b1c04 -> 412b1c04 415c1f7c", - "c1663a76 c15d5c96 -> 415d5c96 41663a76", - "4105286c 4125c794 -> 4105286c 4125c794", - "c16af54d c16655d1 -> 416655d1 416af54d", - "bfef5312 bfe0e16e -> 3fe0e16e 3fef5312", - "41967337 419673b5 -> 41967337 419673b5", - "c0b915b4 406a6a88 -> 00000000 40b915b4", - "40e608f2 40e996e6 -> 40e608f2 40e996e6", - "bf86296a bf861d96 -> 3f861d96 3f86296a", - "c18bd319 c18bd273 -> 418bd273 418bd319", - "c1189a26 c0e70e05 -> 40e70e05 41189a26", - "c0e120f5 c00e203e -> 400e203e 40e120f5", - "bf125782 3e888883 -> 00000000 3f125782", - "c1859bde c182e788 -> 4182e788 41859bde", - "c14a473e c14a2218 -> 414a2218 414a473e", - "416bdc98 4196a364 -> 416bdc98 4196a364", - "c048b3d2 bf8fad1c -> 3f8fad1c 4048b3d2", - "c0d3ca7a c06770d4 -> 406770d4 40d3ca7a", - "c1509a64 c15099f0 -> 415099f0 41509a64", - "c19bf04c c12c059c -> 412c059c 419bf04c", - "41289b7a 41750efe -> 41289b7a 41750efe", - "3fdc3459 3fdee187 -> 3fdc3459 3fdee187", - "40b4dba0 40b4dcb8 -> 40b4dba0 40b4dcb8", - "4134155f 41471ef1 -> 4134155f 41471ef1", - "c0322bd1 bfab79be -> 3fab79be 40322bd1", - "c1924336 c19242da -> 419242da 41924336", - "c128f0da c11f5bd2 -> 411f5bd2 4128f0da", - "40ffe6f4 4100040a -> 40ffe6f4 4100040a", - "3f0459f1 3f04a40f -> 3f0459f1 3f04a40f", - "c14ac6ca c0e3f15c -> 40e3f15c 414ac6ca", - "4130003b 41303a8d -> 4130003b 41303a8d", - "3ea5fbb1 3ea616cf -> 3ea5fbb1 3ea616cf", - "40f44ae6 40f44c52 -> 40f44ae6 40f44c52", - "40a31ec4 40a6d2e4 -> 40a31ec4 40a6d2e4", - "408fde6a 40aafc1e -> 408fde6a 40aafc1e", - "c026e712 c0258e1e -> 40258e1e 4026e712", - "419ca4e0 419ca55c -> 419ca4e0 419ca55c", - "c10eb34f c10e9b01 -> 410e9b01 410eb34f", - "c10ce927 c09a1752 -> 409a1752 410ce927", - "c1033e5a c102e1cc -> 4102e1cc 41033e5a", - "419c49ae 419c4e5a -> 419c49ae 419c4e5a", - "c11b58ef c11b4155 -> 411b4155 411b58ef", - "c0e65441 c09d4f4f -> 409d4f4f 40e65441", - "40e047cc 40e96f74 -> 40e047cc 40e96f74", - "c1591434 c1591378 -> 41591378 41591434", - "c0ff4a58 bfb58992 -> 3fb58992 40ff4a58", - "412436a3 412439a5 -> 412436a3 412439a5", - "c137ab29 c1378599 -> 41378599 4137ab29", - "c039c69b c0382a85 -> 40382a85 4039c69b", - "412e1db4 412f998c -> 412e1db4 412f998c", - "c0848076 c08479ae -> 408479ae 40848076", - "c146b348 c14366dc -> 414366dc 4146b348", - "c08542dd c082c507 -> 4082c507 408542dd", - "c18d4b2f c18d49c1 -> 418d49c1 418d4b2f", - "bf5e3c32 bf5cdf0e -> 3f5cdf0e 3f5e3c32", - "419cf4b2 419db102 -> 419cf4b2 419db102", - "4181b581 41883107 -> 4181b581 41883107", - "41933524 419378a0 -> 41933524 419378a0", - "c1510f70 c1510cf8 -> 41510cf8 41510f70", - "40feb3ee 41134f25 -> 40feb3ee 41134f25", - "c0f59a20 c0333ea0 -> 40333ea0 40f59a20", - "bffb0866 bff1bada -> 3ff1bada 3ffb0866", - "c078e179 c0776b77 -> 40776b77 4078e179", - "40f70161 410ed558 -> 40f70161 410ed558", - "41523c62 417c9f3e -> 41523c62 417c9f3e", - "418188f1 418fb27b -> 418188f1 418fb27b", - "c1647e42 c15f5464 -> 415f5464 41647e42", - "c18c7307 c183fced -> 4183fced 418c7307", - "c186f011 c1862fd5 -> 41862fd5 4186f011", - "418ed765 41948687 -> 418ed765 41948687", - "414828a1 4148b9ff -> 414828a1 4148b9ff", - "c14148ea c12e27f6 -> 412e27f6 414148ea", - "c190a7cf c18989e9 -> 418989e9 4190a7cf", - "c1ae9e50 c16571b8 -> 416571b8 41ae9e50", - "c13ab99b c13513bd -> 413513bd 413ab99b", - "c133c5ea c133bc8e -> 4133bc8e 4133c5ea", - "40f5a678 41590f10 -> 40f5a678 41590f10", - "c1308b5b c1303aa7 -> 41303aa7 41308b5b", - "41134516 411547b6 -> 41134516 411547b6", - "c13b8c0e c0efe294 -> 40efe294 413b8c0e", - "416ce86d 416cef13 -> 416ce86d 416cef13", - "c0f85056 c0f55612 -> 40f55612 40f85056", - "c050f7fc c050ef94 -> 4050ef94 4050f7fc", - "c00b0db0 c00afa80 -> 400afa80 400b0db0", - "4104bd78 4104bfec -> 4104bd78 4104bfec", - "c044d926 c03fd4da -> 403fd4da 4044d926", - "c169a65d c1156ccf -> 41156ccf 4169a65d", - "c1a5f87c c1962f66 -> 41962f66 41a5f87c", - "410e8edb 4110fd6d -> 410e8edb 4110fd6d", - "3ef0bc5c 3f162dd2 -> 3ef0bc5c 3f162dd2", - "c051f089 c0344647 -> 40344647 4051f089", - "4084d144 4084d5fc -> 4084d144 4084d5fc", - "40d0ce0e 40d6d80a -> 40d0ce0e 40d6d80a", - "c1851993 c18517af -> 418517af 41851993", - "bf770427 bf587299 -> 3f587299 3f770427", - "c188a8a1 c1887fed -> 41887fed 4188a8a1", - "c0d38cea c0d38bc2 -> 40d38bc2 40d38cea", - "417f81a8 418053c0 -> 417f81a8 418053c0", - "c13f2c42 c13d2d5e -> 413d2d5e 413f2c42", - "c0c13b93 c00c33ca -> 400c33ca 40c13b93", - "c0df381c c0afc71c -> 40afc71c 40df381c", - "c114d5b4 c114d4ea -> 4114d4ea 4114d5b4", - "c10a92a2 c1080756 -> 41080756 410a92a2", - "c18e6095 c1842851 -> 41842851 418e6095", - "418f562b 418f63e9 -> 418f562b 418f63e9", - "4115ed03 4115ee3d -> 4115ed03 4115ee3d", - "c17d2216 c17a661a -> 417a661a 417d2216", - "3d61e63a 3d63e1c6 -> 3d61e63a 3d63e1c6", - "40b0f9c3 40b0fea5 -> 40b0f9c3 40b0fea5", - "41866c35 418ba923 -> 41866c35 418ba923", - "c18d7657 c18d7295 -> 418d7295 418d7657", - "4117405d 4117418b -> 4117405d 4117418b", - "c1a031fe c1562b10 -> 41562b10 41a031fe", - "c123c4a7 c123c1bb -> 4123c1bb 4123c4a7", - "c191ef78 c191d0e0 -> 4191d0e0 4191ef78", - "40c7e85f 40c7eb21 -> 40c7e85f 40c7eb21", - "c127a87a c1262090 -> 41262090 4127a87a", - "c1147ea4 c1131354 -> 41131354 41147ea4", - "bfb2bf5f bfabd1c1 -> 3fabd1c1 3fb2bf5f", - "416a9d42 416a9dce -> 416a9d42 416a9dce", - "40574a5e 40576c22 -> 40574a5e 40576c22", - "c1233658 c12334dc -> 412334dc 41233658", - "4135ebd8 4198f8c0 -> 4135ebd8 4198f8c0", - "c0c082ab c0b7adad -> 40b7adad 40c082ab", - "3f5230f0 3fbcd728 -> 3f5230f0 3fbcd728", - "418a8579 418a85d3 -> 418a8579 418a85d3", - "40f20973 40f6c405 -> 40f20973 40f6c405", - "4165d0ce 4165d1fa -> 4165d0ce 4165d1fa", - "c180af77 c180adeb -> 4180adeb 4180af77", - "4197e456 4197ec96 -> 4197e456 4197ec96", - "c0b7beca c02427ec -> 402427ec 40b7beca", - "413111e9 4131a89f -> 413111e9 4131a89f", - "4104c2b8 4106fd6c -> 4104c2b8 4106fd6c", - "41639bc1 41642dd7 -> 41639bc1 41642dd7", - "c0d6cf50 c045c8a9 -> 4045c8a9 40d6cf50", - "40db253b 40db2795 -> 40db253b 40db2795", - "c1218b99 c0da4795 -> 40da4795 41218b99", - "c154f26d c145d0e7 -> 4145d0e7 4154f26d", - "c19e0f73 c19d0075 -> 419d0075 419e0f73", - "c1390cf0 c1390b92 -> 41390b92 41390cf0", - "408d9665 408f83ab -> 408d9665 408f83ab", - "40b5a0b8 40b5b588 -> 40b5a0b8 40b5b588", - "3cc3702a 3e0948fb -> 3cc3702a 3e0948fb", - "c05e3e90 c05770e0 -> 405770e0 405e3e90", - "4117b8ed 4117bc17 -> 4117b8ed 4117bc17", - "beaa5ae5 bea8e81b -> 3ea8e81b 3eaa5ae5", - "40368856 4039f38a -> 40368856 4039f38a", - "40a0fa4c 40a95e04 -> 40a0fa4c 40a95e04", - "bf4d1b98 beb0a4d0 -> 3eb0a4d0 3f4d1b98", - "c078d1cf c078b3e1 -> 4078b3e1 4078d1cf", - "c17f1e34 c164fd12 -> 4164fd12 417f1e34", - "c0f43858 c0f05524 -> 40f05524 40f43858", - "c18903ac c1784a31 -> 41784a31 418903ac", - "411eef9d 412cda73 -> 411eef9d 412cda73", - "bfe74a3c bfe74364 -> 3fe74364 3fe74a3c", - "c1854d13 c1851d51 -> 41851d51 41854d13", - "418bb033 419da455 -> 418bb033 419da455", - "40f2f7b5 4112e84d -> 40f2f7b5 4112e84d", - "c11ad0f5 c11a550f -> 411a550f 411ad0f5", - "c19c6c5d c19c6bb5 -> 419c6bb5 419c6c5d", - "c136dd90 c136d636 -> 4136d636 4136dd90", - "412ef373 412ef789 -> 412ef373 412ef789", - "c04cd83d c04c54c3 -> 404c54c3 404cd83d", - "3f067d70 3f85a4a8 -> 3f067d70 3f85a4a8", - "c110df8b c11064bb -> 411064bb 4110df8b", - "c0f3e86e c0f3d4ce -> 40f3d4ce 40f3e86e", - "c163de94 c1009cca -> 41009cca 4163de94", - "4197acc2 419d422e -> 4197acc2 419d422e", - "c1230fd0 c1230f44 -> 41230f44 41230fd0", - "c1489ddb c145662b -> 4145662b 41489ddb", - "415e6c3b 416098c5 -> 415e6c3b 416098c5", - "c1618c7f c15dd5d1 -> 415dd5d1 41618c7f", - "c181f245 c181f205 -> 4181f205 4181f245", - "c0e43580 c0d9e208 -> 40d9e208 40e43580", - "414fea42 415dfb76 -> 414fea42 415dfb76", - "c0ed85f5 3fb88bf4 -> 00000000 40ed85f5", - "410d307a 410d3dbe -> 410d307a 410d3dbe", - "c19ce34a c18ac458 -> 418ac458 419ce34a", - "c189d927 c189d86b -> 4189d86b 4189d927", - "c144e83b c13f2937 -> 413f2937 4144e83b", - "c0e441ba c0e440be -> 40e440be 40e441ba", - "c0251e50 406c2ad0 -> 00000000 406c2ad0", - "411a19fc 412b9ce8 -> 411a19fc 412b9ce8", - "c11eb186 c11eb116 -> 411eb116 411eb186", - "414f7bae 419042d5 -> 414f7bae 419042d5", - "40732b0e 40734322 -> 40732b0e 40734322", - "c0f70315 c0f6d4bf -> 40f6d4bf 40f70315", - "c11fbba7 c11e5845 -> 411e5845 411fbba7", - "c17fd0b0 c17fcf64 -> 417fcf64 417fd0b0", - "c17c4edf c17c2501 -> 417c2501 417c4edf", - "c1934491 c1897101 -> 41897101 41934491", - "41822cf2 4182638e -> 41822cf2 4182638e", - "c18992aa c1898a84 -> 41898a84 418992aa", - "3e6e0e38 4085f74e -> 3e6e0e38 4085f74e", - "41868e13 41868ed1 -> 41868e13 41868ed1", - "40ff666c 40ff6a44 -> 40ff666c 40ff6a44", - "4151da5e 41523eea -> 4151da5e 41523eea", - "c0e5790b c0b6ad21 -> 40b6ad21 40e5790b", - "c177d8c2 c177d510 -> 4177d510 4177d8c2", - "4185f6b4 4185fc38 -> 4185f6b4 4185fc38", - "412a4b1e 412a5b5e -> 412a4b1e 412a5b5e", - "4131412c 4160fd34 -> 4131412c 4160fd34", - "c143f7c7 c143f40d -> 4143f40d 4143f7c7", - "40e967e8 40e9a200 -> 40e967e8 40e9a200", - "c18fe1ef c18fbd5b -> 418fbd5b 418fe1ef", - "40ea90fa 41653eb3 -> 40ea90fa 41653eb3", - "c1a22b60 c19a9fd6 -> 419a9fd6 41a22b60", - "40c70930 40c817e0 -> 40c70930 40c817e0", - "c17a2f19 c17a2e87 -> 417a2e87 417a2f19", - "41790bc7 417948b9 -> 41790bc7 417948b9", - "c11e5ed2 c11e4bf6 -> 411e4bf6 411e5ed2", - "c187a5ee c18197b2 -> 418197b2 4187a5ee", - "c125ade1 c1255b7f -> 41255b7f 4125ade1", - "c08fa4d3 c045d2cb -> 4045d2cb 408fa4d3", - "c19c5eda c19c4584 -> 419c4584 419c5eda", - "c030cc51 3f417d44 -> 00000000 4030cc51", - "c155d8ae c141bef2 -> 4141bef2 4155d8ae", - "40a62e5f 40b56669 -> 40a62e5f 40b56669", - "c19ed88a c19ed84e -> 419ed84e 419ed88a", - "c1193b8a c0e3993b -> 40e3993b 41193b8a", - "40afffe9 40b006cf -> 40afffe9 40b006cf", - "416bdcf3 416c38c5 -> 416bdcf3 416c38c5", - "c0d2c198 c0c45f3c -> 40c45f3c 40d2c198", - "c16d3f7b c16d3ee1 -> 416d3ee1 416d3f7b", - "4142240e 415a2202 -> 4142240e 415a2202", - "410f4f16 410f502a -> 410f4f16 410f502a", - "c0fe3cdf c0fd6505 -> 40fd6505 40fe3cdf", - "c19558c8 c1953aaa -> 41953aaa 419558c8", - "c12a27db c12a2737 -> 412a2737 412a27db", - "40bd27ac 40cbf89c -> 40bd27ac 40cbf89c", - "412898ea 41462a8e -> 412898ea 41462a8e", - "c0b73df6 c0b29c7a -> 40b29c7a 40b73df6", - "41900783 41a04305 -> 41900783 41a04305", - "4137f166 4137f4da -> 4137f166 4137f4da", - "c17a2b30 c13a2188 -> 413a2188 417a2b30", - "3c050013 3c09ffed -> 3c050013 3c09ffed", - "4117df65 4117dfdb -> 4117df65 4117dfdb", - "413e1528 413e160c -> 413e1528 413e160c", - "bfc0e30a bfb19896 -> 3fb19896 3fc0e30a", - "c027ef85 c025a49b -> 4025a49b 4027ef85", - "c0d7eefd c0d7b3ab -> 40d7b3ab 40d7eefd", - "c19dc2ed c19dc15d -> 419dc15d 419dc2ed", - "40f8e653 40f9300d -> 40f8e653 40f9300d", - "4084c409 408e969f -> 4084c409 408e969f", - "4137403e 41374472 -> 4137403e 41374472", - "c052ecbf 4059a5af -> 00000000 4059a5af", - "c0b5f342 c0b3f89a -> 40b3f89a 40b5f342", - "c185f3ea c17e925c -> 417e925c 4185f3ea", - "4150e868 4150eea8 -> 4150e868 4150eea8", - "be676cbd be4dd943 -> 3e4dd943 3e676cbd" - ] - }, - { - "glsl": "vec2 cultmath_iv_min(vec2, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "41719018 41a2d1b0 4155ad74 41849d6e -> 4155ad74 41849d6e", - "c0d567fe c0d109d2 c0c42fd2 c0c4188a -> c0d567fe c0d109d2", - "40836c8e 412dd5cd 4195ccf0 4196cae8 -> 40836c8e 412dd5cd", - "408496ba 40849af6 c07bf68a c07b34c6 -> c07bf68a c07b34c6", - "415da65c 415da9b4 418bad2d 418c58b7 -> 415da65c 415da9b4", - "c11d81d5 c11d80ad c0e2d86e bf8065a8 -> c11d81d5 c11d80ad", - "c0507d7e c04d75f2 41187d70 411880a8 -> c0507d7e c04d75f2", - "4186213c 41862178 c125b89f c125b307 -> c125b89f c125b307", - "c191451e c142dbe0 402d0c25 402d99ab -> c191451e c142dbe0", - "bdb31932 bdb268ce 415a723a 415a731e -> bdb31932 bdb268ce", - "c191e878 c191e09c c1a1c595 c197a7eb -> c1a1c595 c197a7eb", - "c13fd8d9 c1166ca7 c0b13345 c0b1296f -> c13fd8d9 c1166ca7", - "c15dc2f8 c159de38 418b70d6 418cc516 -> c15dc2f8 c159de38", - "c11cede1 c0c83e57 c13e5b76 c120dd42 -> c13e5b76 c120dd42", - "bdf35bb0 406f560e bf99af4d be4e2196 -> bf99af4d be4e2196", - "4178cb1a 4178cdee c0a82525 c0a09df7 -> c0a82525 c0a09df7", - "410bcb68 41140df4 be2ef368 3b60da20 -> be2ef368 3b60da20", - "40401290 40401480 41835563 41876335 -> 40401290 40401480", - "c0ef5026 c0a7adc6 bf4d5638 408165e7 -> c0ef5026 c0a7adc6", - "c186cbe1 c1862c0b 410f24b1 410fe9ef -> c186cbe1 c1862c0b", - "c1514fff c150a865 c198ce8c c198cb3a -> c198ce8c c198cb3a", - "c188620a c1879c3a 4188ee8d 4188f0df -> c188620a c1879c3a", - "4110096b 41160581 415a4155 415b88b3 -> 4110096b 41160581", - "409d507f 409d51d1 c160d79d c13a4d4f -> c160d79d c13a4d4f", - "418e75dc 418e7fa8 c1818d77 c18153b9 -> c1818d77 c18153b9", - "c099763a c08daa1a 40b44afe 40b44f32 -> c099763a c08daa1a", - "4126b53e 4126b932 c0fc49af c0fbd70d -> c0fc49af c0fbd70d", - "c0a7096a c0a6f2b6 40f0c3d4 41658c3e -> c0a7096a c0a6f2b6", - "c16f67a4 c11987c8 40a1ca69 40a20207 -> c16f67a4 c11987c8", - "c1630edb c1630d09 407e2f0e 407e3632 -> c1630edb c1630d09", - "414959ea 41496516 417bce94 418df292 -> 414959ea 41496516", - "c151b0a6 c1519cfe c174785f c1746b79 -> c174785f c1746b79", - "40f16343 40f815fd 419b4a3c 419f7a40 -> 40f16343 40f815fd", - "bf2e9cf9 bf2e3bc7 c15f0050 c15eae76 -> c15f0050 c15eae76", - "415ffce5 41842ea2 bffc7d7c 3ef8e0f0 -> bffc7d7c 3ef8e0f0", - "c10425d0 c103a626 415a3b53 415a7d25 -> c10425d0 c103a626", - "4183ac88 4196b1f8 c093dc37 c08c195d -> c093dc37 c08c195d", - "c07ec9dd c034f103 410a5a23 411d7f0d -> c07ec9dd c034f103", - "40c0befa 414e8f73 40e07c5e 40e07ee2 -> 40c0befa 40e07ee2", - "41364b12 4143103a 41963e7b 41965991 -> 41364b12 4143103a", - "c186c784 c186c74e 41159e55 411b004f -> c186c784 c186c74e", - "c1021b24 c1021a90 c0708167 401db267 -> c1021b24 c1021a90", - "413c3e40 413c4108 bf1b881e bf1afde2 -> bf1b881e bf1afde2", - "40b74cda 40c435d6 4155b909 4155c897 -> 40b74cda 40c435d6", - "c00b08bd c00979b3 41862543 41862b89 -> c00b08bd c00979b3", - "418f851e 418fa5fe 41626c1e 41850611 -> 41626c1e 41850611", - "418a90fd 418a928b c19de067 c19d931b -> c19de067 c19d931b", - "4016a730 4016aa40 40d39bf8 40d39e98 -> 4016a730 4016aa40", - "41836e47 41836ead 413f8b7c 413f9718 -> 413f8b7c 413f9718", - "4126e182 4126e376 c1803834 c1469e3d -> c1803834 c1469e3d", - "c08b39f5 c08ac7eb 4174fd1b 41750445 -> c08b39f5 c08ac7eb", - "c0dd0639 c0dc5677 c154e7bb c154e73d -> c154e7bb c154e73d", - "c16a89b2 c16a7002 40c1e8c0 40c20870 -> c16a89b2 c16a7002", - "41654e9f 4168fe41 bf86ee0e bf6656e3 -> bf86ee0e bf6656e3", - "c181ed4b c1643797 412e4c7a 412e4e1e -> c181ed4b c1643797", - "c1b49eda c179f50f c0881760 c0702851 -> c1b49eda c179f50f", - "3d1730cd 3d392733 c0bc318a c0b94e16 -> c0bc318a c0b94e16", - "4186c701 418731e3 400d0fbf 400d4a01 -> 400d0fbf 400d4a01", - "c0d5f9c3 c0d5f8dd 4181b140 418202c0 -> c0d5f9c3 c0d5f8dd", - "40105983 401a0eed 400252bd 4003b3f3 -> 400252bd 4003b3f3", - "c1c17656 c171adc1 c0975fd9 c09757b7 -> c1c17656 c171adc1", - "c0792ba7 c078d1c9 c12673c7 c1266d6b -> c12673c7 c1266d6b", - "4050c9c4 4050d44c c16bd061 c1384f83 -> c16bd061 c1384f83", - "c0aec45a c0aec346 4178ea1c 41791f74 -> c0aec45a c0aec346", - "c196c970 c196c860 40e8fc94 41485506 -> c196c970 c196c860", - "c178cc54 c17794c8 c182612a c181aa70 -> c182612a c181aa70", - "4142bb77 4142d051 4193aed4 41a27f74 -> 4142bb77 4142d051", - "40f567b2 415aad33 c186af49 c1867a57 -> c186af49 c1867a57", - "c0f5c432 c0f5a88e c178993c c17898a6 -> c178993c c17898a6", - "405df2d1 405e034f c0d07d00 c0d07838 -> c0d07d00 c0d07838", - "c163fa34 c163f8a6 c19f7a64 c19a6adc -> c19f7a64 c19a6adc", - "c0a723a9 c0a1352f 418eef84 418ef6b0 -> c0a723a9 c0a1352f", - "c1745488 c173ea38 beb7da58 beb1bea8 -> c1745488 c173ea38", - "4177e1df 41799f71 c0ba7290 c0b9fb3c -> c0ba7290 c0b9fb3c", - "41776669 4182f79b c0865a79 c08658cf -> c0865a79 c08658cf", - "c0af4594 c0aeff84 bf9a61da bf891fa6 -> c0af4594 c0aeff84", - "c186d27a c184960c 406f5e78 406f61a8 -> c186d27a c184960c", - "417855e4 418bccd6 414c1d2e 4162429a -> 414c1d2e 4162429a", - "4142fb1e 41447ad2 40e6b435 41865f3b -> 40e6b435 41447ad2", - "402a96f4 402ae31c c13441a7 c1343f55 -> c13441a7 c1343f55", - "c08ab12e c08307a6 41165b07 411665c9 -> c08ab12e c08307a6", - "bfc37b41 bfa8b4bf 4065fb96 407a641a -> bfc37b41 bfa8b4bf", - "418f5c68 41915858 c1727212 c16354b6 -> c1727212 c16354b6", - "414383f6 41438dc2 4134b6b7 413e8229 -> 4134b6b7 413e8229", - "40b89d94 40b8e164 40dfc4ad 40e8098b -> 40b89d94 40b8e164", - "c197e5bb c181a3e7 c084aebd c0849e53 -> c197e5bb c181a3e7", - "40b85d88 40bef840 408c1ca9 408c34ef -> 408c1ca9 408c34ef", - "41449510 4144ae60 4169b180 416ac190 -> 41449510 4144ae60", - "403b978b 403bb2d5 40d10d85 40d9cc93 -> 403b978b 403bb2d5", - "40c1d862 40c1df7e c158b911 c15886a3 -> c158b911 c15886a3", - "c18d182b c16ba0b1 c17bb2fb c17bacf3 -> c18d182b c17bacf3", - "4110206c 41102114 c198e926 c1988d94 -> c198e926 c1988d94", - "4142c1ba 4142c266 c0bd734b c0bd6c8d -> c0bd734b c0bd6c8d", - "40c627cc 40c7af6c c1832209 c182dcd5 -> c1832209 c182dcd5", - "c10d534b c10cf29d 409f6434 40bff2c4 -> c10d534b c10cf29d", - "c18e89ec c18e837c 417b1857 417c91e1 -> c18e89ec c18e837c", - "4147b634 4148d34c c1329661 c131904d -> c1329661 c131904d", - "408b865e 408b890a c17c5d17 c17c0e73 -> c17c5d17 c17c0e73", - "c131e6a2 c131de76 405eb5d0 405ec110 -> c131e6a2 c131de76", - "4134900c 413492b8 3fad43be 3fbae462 -> 3fad43be 3fbae462", - "40b37b5a 40b37d66 bf3b1616 bd873554 -> bf3b1616 bd873554", - "c19f0f78 c19cfbd0 4182e5a8 4182e5f8 -> c19f0f78 c19cfbd0", - "c15da6c3 c15da425 c06be6af c06bda21 -> c15da6c3 c15da425", - "4000e834 40014f9c c0be0b12 c09f7d66 -> c0be0b12 c09f7d66", - "419fa013 419fec01 c04b31f2 c04b27fe -> c04b31f2 c04b27fe", - "414c43b1 414c96d7 4185746d 4188084f -> 414c43b1 414c96d7", - "417f8f95 4197c20e 41938061 419393cf -> 417f8f95 419393cf", - "417e33dd 41a0305e 410f1e33 410f1fc5 -> 410f1e33 410f1fc5", - "418c9d2a 418c9d76 c18a73e0 c11ca994 -> c18a73e0 c11ca994", - "414608cd 41460a9b 405e0967 405e10b9 -> 405e0967 405e10b9", - "40cc1ba8 40cc2280 c06d43da c06c2706 -> c06d43da c06c2706", - "40b2abb0 41200958 4173a52c 418a2976 -> 40b2abb0 41200958", - "41768e49 41827e0b c1547b69 c154726b -> c1547b69 c154726b", - "411aee7d 411b0e77 41370ca2 41370fd6 -> 411aee7d 411b0e77", - "c161a928 c153a8b4 4151c310 4151c488 -> c161a928 c153a8b4", - "410da7ec 410e3f74 c183ae88 c183aba0 -> c183ae88 c183aba0", - "c0207ab9 c0204be7 c1285a0e c127b98a -> c1285a0e c127b98a", - "c140de9d c140bad3 4192b487 41a4af71 -> c140de9d c140bad3", - "4188a77c 4188ad4c be3f26ba bd174d16 -> be3f26ba bd174d16", - "c18ed305 c18ea389 c19dd2a0 c19dd266 -> c19dd2a0 c19dd266", - "419c842c 419c84d0 bd33b8c8 bd313338 -> bd33b8c8 bd313338", - "41233c29 41238997 c0a1ae84 c09fa41c -> c0a1ae84 c09fa41c", - "c16424ce c0c2866b 414ac775 414ac7fb -> c16424ce c0c2866b", - "c0fedac5 c0fe167b c06adfb4 c06ad6ec -> c0fedac5 c0fe167b", - "c1815573 c18153df c19c9f69 c19c8a0f -> c19c9f69 c19c8a0f", - "40f522e2 40f569e6 40d070b1 40d18d87 -> 40d070b1 40d18d87", - "4142d6e2 4142e37e c0cb810e c0caecaa -> c0cb810e c0caecaa", - "417405b6 4174080a c1724a29 c16e0485 -> c1724a29 c16e0485", - "412a2717 413e4e05 c1732375 c1710f1b -> c1732375 c1710f1b", - "c1ad4a67 c1894a3d c0a205a5 404468fa -> c1ad4a67 c1894a3d", - "41846243 41865079 c11161b5 c1115cc5 -> c11161b5 c1115cc5", - "bf0137b4 40c70476 40307005 4031975b -> bf0137b4 4031975b", - "4174a305 4174ba6b 3eb78ae8 4031df43 -> 3eb78ae8 4031df43", - "bfc75f7d bfba1863 c0ed0658 c0e9c4a4 -> c0ed0658 c0e9c4a4", - "c0e1f0e5 3ff5e054 c0bbf7a5 c0bb58a3 -> c0e1f0e5 c0bb58a3", - "c18bf58c c15612c2 40e5ec6c 40e5eedc -> c18bf58c c15612c2", - "4164fba6 4164fd82 c126fa83 c126923f -> c126fa83 c126923f", - "c0c8302c c0ad1c64 c16c1619 c16c135b -> c16c1619 c16c135b", - "41015811 410158a3 bf061786 bf060fba -> bf061786 bf060fba", - "c176b4b0 c1766e42 418583f3 41920ac5 -> c176b4b0 c1766e42", - "40f76711 4128d390 402ff1d1 4032cd0f -> 402ff1d1 4032cd0f", - "408effb6 408f0df2 c1315213 c1314ee1 -> c1315213 c1314ee1", - "3e0d181a 3e35f3e6 c1484fbb c1484f31 -> c1484fbb c1484f31", - "4045c228 4045c428 4120fb9f 419b02a4 -> 4045c228 4045c428", - "419f000c 419f01a4 c0b57de2 c0b4fc36 -> c0b57de2 c0b4fc36", - "4110b59e 4110b6be c180f624 c180f584 -> c180f624 c180f584", - "c1331b0c c132fcac c1505127 c15014c5 -> c1505127 c15014c5", - "c1759bdb c1758ec1 c09d5a13 40770d76 -> c1759bdb c1758ec1", - "c18ee9e2 c18e9d66 41129827 41129d8d -> c18ee9e2 c18e9d66", - "c0bb687c c0bb63e4 bf3ba39e bf1ef962 -> c0bb687c c0bb63e4", - "4182bfdf 4182c049 4192cacf 419e9f71 -> 4182bfdf 4182c049", - "407c1661 407c1bff 4058aa20 40699f50 -> 4058aa20 40699f50", - "c159673c c158efa4 c1ad781a c186dee6 -> c1ad781a c186dee6", - "c183bf3c c18380ba c1790f6d c176822b -> c183bf3c c18380ba", - "413b5fdd 413bbe33 c0f39faf c0f39309 -> c0f39faf c0f39309", - "c18c1582 c1850442 c18c1ddd c18c1bbf -> c18c1ddd c18c1bbf", - "c1955013 c1954e11 41967562 419675ce -> c1955013 c1954e11", - "c108c145 c10619cd 4097f6d0 40cf0d78 -> c108c145 c10619cd", - "40f0b432 4101343b 3f92b0a0 3fadc7e0 -> 3f92b0a0 3fadc7e0", - "c1791de3 c179156d bd879576 bd86d48a -> c1791de3 c179156d", - "4136dd2d 413750af c1124c95 c110358b -> c1124c95 c110358b", - "c10b79b9 c10a9325 417f837f 41803e80 -> c10b79b9 c10a9325", - "c07be4e5 c07be05b c0811a82 bfbeab38 -> c0811a82 c07be05b", - "41599898 41599f80 3fbb1206 3fbb1efa -> 3fbb1206 3fbb1efa", - "419ca7b2 41a29a72 41404975 4140727b -> 41404975 4140727b", - "c168ba59 c1680d57 c0856bdd c08431db -> c168ba59 c1680d57", - "4161ce44 4161d134 c1255529 c125409d -> c1255529 c125409d", - "4194ee03 4195117d 3f9588c7 3f9b4139 -> 3f9588c7 3f9b4139", - "4197b636 4197b82e bffce3b8 bff25648 -> bffce3b8 bff25648", - "3f23d051 3f27d26f 41865a43 41868fb5 -> 3f23d051 3f27d26f", - "c10127db c100f827 40ce51b9 40ce59e7 -> c10127db c100f827", - "c13caaea c132acf0 c19dc6fd c19da2bb -> c19dc6fd c19da2bb", - "c1386264 c1383366 40d4c34b 40d4eabd -> c1386264 c1383366", - "bfc050b3 bfc0468d 4198663f 41986a61 -> bfc050b3 bfc0468d", - "c18466a8 c17f1fd4 412d096c 412d0ae8 -> c18466a8 c17f1fd4", - "c0f64ea0 c0f44a40 3f3658b4 40d2fdaa -> c0f64ea0 c0f44a40", - "3f40b250 407cad8c 41819651 4182e837 -> 3f40b250 407cad8c", - "410d3ee4 416ab7f4 40830bf5 4085103b -> 40830bf5 4085103b", - "416294de 4162a4aa c1811621 c17b87a5 -> c1811621 c17b87a5", - "4168ea11 4168edff c0fb45ba c0fb4352 -> c0fb45ba c0fb4352", - "c15e6e18 c14fd120 c16e8567 c16d9515 -> c16e8567 c16d9515", - "41341c27 41341ff1 c193f37e c180c88a -> c193f37e c180c88a", - "c1330bf0 c1330842 bf3cf5c6 bddd83d4 -> c1330bf0 c1330842", - "40c62294 40e966b4 c153f6ce c14c16d2 -> c153f6ce c14c16d2", - "414b46db 4150c7cd 40b48fb8 40b4ad80 -> 40b48fb8 40b4ad80", - "4161481d 41616313 40c77fda 40c78ff6 -> 40c77fda 40c78ff6", - "41459ba6 41459d0a bf33e3af bf33c0d1 -> bf33e3af bf33c0d1", - "419ed8de 419edc9e c0b4f793 c0257122 -> c0b4f793 c0257122", - "c000fe63 bfe30d1a 418f2a36 418f784a -> c000fe63 bfe30d1a", - "c02e6abb c02e6835 c151ae07 c151927d -> c151ae07 c151927d", - "41554fe5 4155507b c047d1c3 c041315d -> c047d1c3 c041315d", - "c0111ee2 bf1f03ba 417a72fb 417a73ad -> c0111ee2 bf1f03ba", - "c164fba0 c164e0c2 41808d09 41808e47 -> c164fba0 c164e0c2", - "c014fbd0 40d7f8a8 c12d5e8f c11d5573 -> c12d5e8f c11d5573", - "c17a9310 c157095c 411ad9d4 411ea5b4 -> c17a9310 c157095c", - "40cc5622 4127a933 413bc17a 4194fca3 -> 40cc5622 4127a933", - "413b3dab 413cb32d c14443a8 c049ecc2 -> c14443a8 c049ecc2", - "416531ea 4168573e c1027b14 c0ea41f4 -> c1027b14 c0ea41f4", - "3fb243e2 3fb2921e bfbdf96a be5857b0 -> bfbdf96a be5857b0", - "418cf066 418cf0c6 4106f198 417272e8 -> 4106f198 417272e8", - "c1367cc5 c1363e33 c19fa8f1 c19e7d4f -> c19fa8f1 c19e7d4f", - "c0bee12f c0bed425 c0ca5939 c0c9b3cb -> c0ca5939 c0c9b3cb", - "c0266234 c026593c c09aa5a8 c0989158 -> c09aa5a8 c0989158", - "c104e88c c1046ad4 408cade5 40ff62ab -> c104e88c c1046ad4", - "c15f188c c15ecad8 4133a822 41584516 -> c15f188c c15ecad8", - "be0286b0 4040dc7b c149c47b c1495945 -> c149c47b c1495945", - "c18dd229 c18dd15f 409bd8d8 409bed58 -> c18dd229 c18dd15f", - "3f01417d 3f048103 41663deb 41663efd -> 3f01417d 3f048103", - "c18b533a c185028c bfccf8e9 bfccac17 -> c18b533a c185028c", - "41863d97 41864115 40947b1e 409659da -> 40947b1e 409659da", - "c12dbacf c1127ff1 4005ef57 401d6a09 -> c12dbacf c1127ff1", - "c111cfe5 c1096a4f beacabd6 beac97aa -> c111cfe5 c1096a4f", - "40999eab 409bd4e5 40d84a75 40d923fb -> 40999eab 409bd4e5", - "c1451319 c1033049 c034e3f4 c034a5ec -> c1451319 c1033049", - "c11f34d9 c11e930f 40431e36 4043364a -> c11f34d9 c11e930f", - "4097c62d 4097c7db 418f719f 418f71dd -> 4097c62d 4097c7db", - "c107c1cd c107b557 befd905e beeab422 -> c107c1cd c107b557", - "c1940f45 c193fedf 418fcda4 41aaab7c -> c1940f45 c193fedf", - "4158de89 4158e657 4097c31f 40a0c501 -> 4097c31f 40a0c501", - "c0c9f535 c0c9392f c13cedbe c13cdeba -> c13cedbe c13cdeba", - "409fc830 40a27450 406ce640 411007f8 -> 406ce640 40a27450", - "4120d11d 4120efcf 41597d64 41597fbc -> 4120d11d 4120efcf", - "c0bfeaaf c0bfe65d c198e9cf c198d547 -> c198e9cf c198d547", - "40d9b5be 40d9f952 418b1f0b 418b20d1 -> 40d9b5be 40d9f952", - "417e41ce 417f1542 c0e23ea6 3f88ceb8 -> c0e23ea6 3f88ceb8", - "c15a896c c0bbc598 c19fffa5 c19ffc65 -> c19fffa5 c19ffc65", - "402ed1b0 40592510 3fc09254 4122bbc6 -> 3fc09254 40592510", - "c10370ef c0f6efd3 41943de6 419a90a2 -> c10370ef c0f6efd3", - "c0ed81dc c0ed70dc 4089b258 4089b390 -> c0ed81dc c0ed70dc", - "c076878a c07685d6 c135149b c0f4a6aa -> c135149b c0f4a6aa", - "bfdd9858 bfdcfa88 c16eeb06 c14034d6 -> c16eeb06 c14034d6", - "c0b6a56e c0b3c182 c129baa5 c1296cf5 -> c129baa5 c1296cf5", - "c0e51657 c0e49c1d 4132dd72 4142da7e -> c0e51657 c0e49c1d", - "c190e83e c190e594 c18e7c2b c18d1a13 -> c190e83e c190e594", - "4057797e 40584482 c11963dd bf72d8f0 -> c11963dd bf72d8f0", - "4103f3b2 4121282e 415f89bc 4161585c -> 4103f3b2 4121282e", - "c1526f22 c1526870 c1849bf1 c18485cd -> c1849bf1 c18485cd", - "4116fe9e 4149e7b6 411dc4d4 414d4594 -> 4116fe9e 4149e7b6", - "c10d57b5 c10cc2ff bf768c0c 403f5893 -> c10d57b5 c10cc2ff", - "4149ae5c 4149afc4 4130b0e6 419bf701 -> 4130b0e6 4149afc4", - "3f94ace7 3f94ca39 40b2b0a0 40f72e10 -> 3f94ace7 3f94ca39", - "418f34e5 418f3667 4114b9d9 4114bb07 -> 4114b9d9 4114bb07", - "c16e4faa c1095606 c0c6dead 400d3daa -> c16e4faa c1095606", - "40ace256 40acf5ea c14b1635 c14966c3 -> c14b1635 c14966c3", - "bf1856c3 bf0980fd 410dfa21 410dfbaf -> bf1856c3 bf0980fd", - "bef34ee0 3f68d070 40e61150 40e67940 -> bef34ee0 3f68d070", - "409050fd 40f2942b 3f4a1f8f 3f5642f1 -> 3f4a1f8f 3f5642f1", - "40fca91d 40fcad1b 41548f05 4154f2d3 -> 40fca91d 40fcad1b", - "3fbc564c 3fbd6374 bfd8fd7f bfd2ac81 -> bfd8fd7f bfd2ac81", - "c18601d8 c10604a4 3fd1381c 41368b54 -> c18601d8 c10604a4", - "c088199e 40a2810e c1496d98 c1364302 -> c1496d98 c1364302", - "c01dd802 bfbdcf9d c119f819 c119f7ab -> c119f819 c119f7ab", - "c10e3a6c c09bda09 c02a3784 c02a15dc -> c10e3a6c c09bda09", - "c09ddd5a c0883ade bf75f758 bf2447a8 -> c09ddd5a c0883ade", - "3ed5641d 3ed641e3 c1366c93 c1366bd9 -> c1366c93 c1366bd9", - "40c3a781 40c3af6f c0873ddc c0873c0c -> c0873ddc c0873c0c" - ] - }, - { - "glsl": "vec2 cultmath_iv_max(vec2, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c194544c c1340640 c004b050 c0049270 -> c004b050 c0049270", - "4149d0a7 414c8301 c05168e1 c04f5b3f -> 4149d0a7 414c8301", - "4175fe64 417ca674 40865c72 408783f6 -> 4175fe64 417ca674", - "40825c59 40c56247 418f15b4 419dbd98 -> 418f15b4 419dbd98", - "40b00ee8 40b147d0 c14183cf c1354c03 -> 40b00ee8 40b147d0", - "4101fb03 41031cad c18557e6 c17f3e49 -> 4101fb03 41031cad", - "417cfb14 4183646a c1ab12c8 c182df1c -> 417cfb14 4183646a", - "412ba26b 412d7df1 c0c643b8 c0c62598 -> 412ba26b 412d7df1", - "407f12f2 407f1a5e 40f05d89 40f126d7 -> 40f05d89 40f126d7", - "c0bf8be8 c0bf8b04 c14ab8d9 c14693f3 -> c0bf8be8 c0bf8b04", - "c00d0eb4 40186de4 c0a5db6b c09f605d -> c00d0eb4 40186de4", - "c1887502 c1218b38 c1896620 c188096c -> c1887502 c1218b38", - "c10fa43c c10f89ac c06124a1 c0611cbf -> c06124a1 c0611cbf", - "419c5157 419d4ca1 c0adbd61 c0abc617 -> 419c5157 419d4ca1", - "41717175 417556e3 c0c0f88d c0c0f6eb -> 41717175 417556e3", - "4095886f 40965261 4114382a 4114420e -> 4114382a 4114420e", - "c09b5837 c09b4081 4183a701 4183e56b -> 4183a701 4183e56b", - "c14f8322 c14f0d14 3c9259c4 3e243fc8 -> 3c9259c4 3e243fc8", - "c0da5fb0 c0d90828 c1163034 c10aa340 -> c0da5fb0 c0d90828", - "c14210d9 c141d65b 40040015 40d862f6 -> 40040015 40d862f6", - "40ec485e 40ec8af2 40d2805e 40d2d96a -> 40ec485e 40ec8af2", - "c13f6e6a c13f69e4 c13228e5 c0412dc4 -> c13228e5 c0412dc4", - "412a5cab 412a5e81 4072ef47 4080e32c -> 412a5cab 412a5e81", - "40ca3a0e 40ca3d92 c18b07c0 c18b077c -> 40ca3a0e 40ca3d92", - "c13f94b3 c13f9375 c11cadc9 c0f321f6 -> c11cadc9 c0f321f6", - "c18e25e3 c18d8a99 bfce1e12 bf480c9c -> bfce1e12 bf480c9c", - "41600c7e 416cf232 41440482 41445b96 -> 41600c7e 416cf232", - "c0c9e935 c0c6f27f c0b28ad4 c0b1fa3c -> c0b28ad4 c0b1fa3c", - "c18a9bc3 c18a8377 c09fa6ae c09f9a66 -> c09fa6ae c09f9a66", - "4148c8f9 4148da1f c187c747 c187c5d3 -> 4148c8f9 4148da1f", - "41844d64 41a80110 41139503 411395b5 -> 41844d64 41a80110", - "41711020 4183b9a8 419749cd 41974bef -> 419749cd 41974bef", - "bfd21e7e bfd1e3e2 4035d8f4 4035de2c -> 4035d8f4 4035de2c", - "c1652cea c15cf74a 4171b5c9 4171b737 -> 4171b5c9 4171b737", - "41734d2a 418df433 3ff055df 3ff1f0a1 -> 41734d2a 418df433", - "c09c4c2e c03c6b63 40b1377d 40b13d7b -> 40b1377d 40b13d7b", - "412c9616 412c985a 4087b934 4087c6ac -> 412c9616 412c985a", - "41156b87 412c1f19 c14cce9a c1264cac -> 41156b87 412c1f19", - "c19964ac c19963ec 417f61be 417f6382 -> 417f61be 417f6382", - "415ced0a 415d2346 41794e9d 41794f33 -> 41794e9d 41794f33", - "41449a26 414642ba c19de98c c19de8f4 -> 41449a26 414642ba", - "c198df54 c198db3c c0fec1be c0fe9f36 -> c0fec1be c0fe9f36", - "3fbe19bf 3fbe6041 c1160d7e c0985745 -> 3fbe19bf 3fbe6041", - "412fee65 4132fb8b 412b69fa 412b6b76 -> 412fee65 4132fb8b", - "c105f509 c104f93b c1139d6d c10b0d25 -> c105f509 c104f93b", - "c134c281 c12da4bf bffd87d7 bfebbd69 -> bffd87d7 bfebbd69", - "c19440d6 c191df2a c1866ad1 c1866a81 -> c1866ad1 c1866a81", - "4156f9e6 41601032 c117a8ed c11738c5 -> 4156f9e6 41601032", - "419d1478 419d6270 407ce03a 409e14cb -> 419d1478 419d6270", - "41603d92 41611866 c15fec77 c15f5be7 -> 41603d92 41611866", - "415e5412 415e5e7e 4103a1e2 41040e6e -> 415e5412 415e5e7e", - "3e914460 3e928320 c1805803 c1804a65 -> 3e914460 3e928320", - "c0d47ed4 c0b8d27c 41569aea 4156a626 -> 41569aea 4156a626", - "c1611000 c1610dda 4145061e 41450722 -> 4145061e 41450722", - "c15f7c80 c15f5cba c18f3918 c18f3034 -> c15f7c80 c15f5cba", - "c14cb260 c14ca9b0 bf9307e2 be96dbf6 -> bf9307e2 be96dbf6", - "c1a50526 c198f198 418d4856 418d4c7a -> 418d4856 418d4c7a", - "c1ad8dee c16b6020 c11d7fbe c114ea46 -> c11d7fbe c114ea46", - "c081b0d0 c057dc20 4155dcd9 4193f8f4 -> 4155dcd9 4193f8f4", - "c1b3fa84 c179cf61 c1777f27 c16d0481 -> c1777f27 c16d0481", - "406906e0 40809780 40f456ed 40f4587b -> 40f456ed 40f4587b", - "414d6950 41a337e8 c0e98a78 c0b23de0 -> 414d6950 41a337e8", - "4104ecde 4105a8b2 40bd3b1d 40bdf933 -> 4104ecde 4105a8b2", - "bf6dd812 3ebfa524 c0dbbc0c c0d92184 -> bf6dd812 3ebfa524", - "411fb488 415f3108 bf5ae0dc bf20aaa4 -> 411fb488 415f3108", - "c0eb19ac c0b99f08 c0e6fab7 c0e6bc95 -> c0e6fab7 c0b99f08", - "3f8908a9 3f8911d7 41736b2a 41738c66 -> 41736b2a 41738c66", - "c133eaf5 c111c74b c18e5381 c18e51d1 -> c133eaf5 c111c74b", - "c11be3b2 c11bd840 41142f2d 4114858f -> 41142f2d 4114858f", - "403e22a7 403f0089 416d4db0 416d4e40 -> 416d4db0 416d4e40", - "be0a84b1 be0a374f 40063761 40088ebf -> 40063761 40088ebf", - "c0f360b7 c0d7aaa1 c11ed82b c11d82d5 -> c0f360b7 c0d7aaa1", - "c0210118 c020c2a8 c1648df1 c1648c97 -> c0210118 c020c2a8", - "bf109561 bf0c065f c04d1699 c025ad17 -> bf109561 bf0c065f", - "c08586b9 c08567f7 3ef5407e 3fea1ba0 -> 3ef5407e 3fea1ba0", - "c199f806 c152115c 4050dd84 409c9866 -> 4050dd84 409c9866", - "bf6dd1f0 bf686c10 c1355964 c135551c -> bf6dd1f0 bf686c10", - "c18b3873 c174ce6e c19d9529 c19d862f -> c18b3873 c174ce6e", - "c1906b3f c1904519 c1502f2c c150288e -> c1502f2c c150288e", - "c1124a4d c100f327 c1904ac6 c18c50f8 -> c1124a4d c100f327", - "41576580 415771e8 417921a1 41a00897 -> 417921a1 41a00897", - "40c1fed4 413c5d52 40eb3ce1 4106d488 -> 40eb3ce1 413c5d52", - "412c373a 41915a33 c189e676 c189e266 -> 412c373a 41915a33", - "417e649c 417e654c 418a1485 418a7a5b -> 418a1485 418a7a5b", - "befe005c be0ed049 c19c3714 c18cfdba -> befe005c be0ed049", - "40355c67 40355f49 bea30649 be7b556e -> 40355c67 40355f49", - "c10031b6 c0e9b5e1 c18e67e4 c18e6798 -> c10031b6 c0e9b5e1", - "c10fc260 c10fbee4 bf9043d9 bf850567 -> bf9043d9 bf850567", - "c120f261 c112c14b 4198acb3 41a095f5 -> 4198acb3 41a095f5", - "c19ce277 c19b09f7 c173dbc1 c1732d9f -> c173dbc1 c1732d9f", - "412b27ec 412b560c c0ca0837 c0ca050d -> 412b27ec 412b560c", - "4138af18 41417cec bf7ce0f0 bf7cda10 -> 4138af18 41417cec", - "3f4d2b17 3f73a7e9 411f228e 4120540a -> 411f228e 4120540a", - "412dabaf 412dafc1 c15b24fb c14d4713 -> 412dabaf 412dafc1", - "41421223 41422fd5 3ff6911c 40f79731 -> 41421223 41422fd5", - "417bf85c 417f5ba4 3f8f2c46 3fadc65a -> 417bf85c 417f5ba4", - "3cdd3822 3d55e7ef 419ff98b 419ffa41 -> 419ff98b 419ffa41", - "c18e51fd c18e510b 3ee2885a 3fd8bdaa -> 3ee2885a 3fd8bdaa", - "4067acbb 4069f175 c183bdcb c183bc7f -> 4067acbb 4069f175", - "410453db 410472cd 4130e281 4131e643 -> 4130e281 4131e643", - "c10356e3 c1035627 3ea752c3 3ef8713d -> 3ea752c3 3ef8713d", - "c0831e9c bf7e3920 414b1d47 414b1e19 -> 414b1d47 414b1e19", - "409b1278 409b1ad8 419dfcb7 419f4361 -> 419dfcb7 419f4361", - "c18f6b83 c18f6a1d 40a591c7 40a59471 -> 40a591c7 40a59471", - "417112e3 4174833d 4094d166 4094f03a -> 417112e3 4174833d", - "411ec8d2 411ee4f6 418fa089 418fb28b -> 418fa089 418fb28b", - "c18f1b22 c156a088 419abd20 419ac148 -> 419abd20 419ac148", - "c178e65e c178e5ec c18639e7 c1861dbd -> c178e65e c178e5ec", - "4072e8ec 4072ec34 40af492e 40e55bda -> 40af492e 40e55bda", - "c17398e1 c145fd9f c127a5a4 c125ffa0 -> c127a5a4 c125ffa0", - "4080ab66 4110465d bfba28e6 3ec9b798 -> 4080ab66 4110465d", - "c17da38e c152810c 412b2baa 412b61d6 -> 412b2baa 412b61d6", - "412f8a00 419bc918 c10c0e25 c10c0d7f -> 412f8a00 419bc918", - "4125d050 41262404 41252b31 416a84ff -> 4125d050 416a84ff", - "c17ed370 c17ed1c8 3f9dd4c1 3fa22dff -> 3f9dd4c1 3fa22dff", - "41847fc7 4184fb0d 418f3f12 41902dae -> 418f3f12 41902dae", - "c172ff20 c171e3a8 c1b5a540 c15a41ad -> c172ff20 c15a41ad", - "bd92015c 3f422a2c 41585a3a 41b2294b -> 41585a3a 41b2294b", - "c03a9376 c03a918a 40b1159a 40d45b66 -> 40b1159a 40d45b66", - "41739d92 41739ece c11f178f c11f123f -> 41739d92 41739ece", - "c1587cc0 c1577c64 c09871c7 c0986e51 -> c09871c7 c0986e51", - "41111a3b 41111ae1 40d77698 40d77a60 -> 41111a3b 41111ae1", - "c124d230 c11d9e3c 411bfbd7 411bfc71 -> 411bfbd7 411bfc71", - "c0baf3f0 c0ac2340 40f05af8 40f05dc8 -> 40f05af8 40f05dc8", - "4193ae46 41a6522e 41140778 41152750 -> 4193ae46 41a6522e", - "4153d348 415ffbc0 418505a2 41850642 -> 418505a2 41850642", - "c193b0ea c193aaf4 40887048 40998c90 -> 40887048 40998c90", - "41465da5 41465e13 c1910bb9 c1910b81 -> 41465da5 41465e13", - "416cb404 416cc254 c0c826a3 c0c7f58d -> 416cb404 416cc254", - "c15a895a c145775a 41776387 41776491 -> 41776387 41776491", - "41627875 418e9135 41158e91 4121f6d7 -> 41627875 418e9135", - "c1a1fe58 c1845dc4 409ff404 40a965e4 -> 409ff404 40a965e4", - "c0dfa72f c0ddf401 414b6907 414b6979 -> 414b6907 414b6979", - "c0b2f25f c0aab6e5 c0970bb3 c096c5ad -> c0970bb3 c096c5ad", - "40b7c3dd 40b7d973 c184518d c1843347 -> 40b7c3dd 40b7d973", - "c09f1ae9 bf5d56b8 c0e2c176 c0e2b3d2 -> c09f1ae9 bf5d56b8", - "40e3a8fc 40f33d0c c1572d11 c1572c55 -> 40e3a8fc 40f33d0c", - "c08da2b8 c08d7d28 418a42ad 418a4413 -> 418a42ad 418a4413", - "419b17f7 419c89b1 4093a26b 410f5bf2 -> 419b17f7 419c89b1", - "c19583b9 c19582b9 c18ddb58 c18dda7c -> c18ddb58 c18dda7c", - "4092ec80 41089fd0 c04daafb c04d8865 -> 4092ec80 41089fd0", - "c148fb2a c148fa84 40b6d1b9 40b6d8d7 -> 40b6d1b9 40b6d8d7", - "41600dcb 41a0fa77 40e1b643 411e657a -> 41600dcb 41a0fa77", - "4117acbd 4117f7cb 40144b2a 411fd1c2 -> 4117acbd 411fd1c2", - "40655a75 40675b1b c181f194 c181eae8 -> 40655a75 40675b1b", - "411f5665 412092df c1476dde c04ab59a -> 411f5665 412092df", - "408dbc6b 40937ff5 c19af8d4 c198105a -> 408dbc6b 40937ff5", - "c19c1aeb c19bf493 c0bbef42 c0bada46 -> c0bbef42 c0bada46", - "c162093b c0f5ae9a 412c6730 412cf4d8 -> 412c6730 412cf4d8", - "3df7bce7 3df82319 c18e0099 c18cab2d -> 3df7bce7 3df82319", - "c1a00cb6 c146c434 c17071c9 c1703689 -> c17071c9 c146c434", - "409a0be3 409a0d35 c035fd9b c032fc75 -> 409a0be3 409a0d35", - "419e0874 41a05bd4 c0d09008 c0cf1238 -> 419e0874 41a05bd4", - "c1945619 c18f9e8f c0a031fc c0a02fc4 -> c0a031fc c0a02fc4", - "40928da0 4092fc28 40c1b054 40c3334c -> 40c1b054 40c3334c", - "c1abd822 c187ce64 c14feb63 c14f8d73 -> c14feb63 c14f8d73", - "4084c3ef 4084ccb9 40c52157 40dd36a9 -> 40c52157 40dd36a9", - "40e9f7c9 40e9fc2f bf884c24 bf82723c -> 40e9f7c9 40e9fc2f", - "c0183c9f c0171ab1 c140d698 c134fba0 -> c0183c9f c0171ab1", - "c041ccfa bf391e1a c0a34f32 c0a0ff56 -> c041ccfa bf391e1a", - "c132619a c131f370 410952b8 410962f8 -> 410952b8 410962f8", - "c17f4968 c16b2a70 bfc4143b bfc11a05 -> bfc4143b bfc11a05", - "405684bf 40673681 417b96cd 417b97cb -> 417b96cd 417b97cb", - "c071cc64 c06f258c 40a01cc8 40a02230 -> 40a01cc8 40a02230", - "413ee543 4141d1fd 415209f3 41523a35 -> 415209f3 41523a35", - "c09f6653 c0996dad 415282e8 416f7068 -> 415282e8 416f7068", - "c13c8ad0 c12b783a c182a242 c181e296 -> c13c8ad0 c12b783a", - "3fe5e260 3ff2d100 40a290d6 40b3006a -> 40a290d6 40b3006a", - "c18f22f8 c18f2274 c0efcb46 c0ee4eee -> c0efcb46 c0ee4eee", - "c144e034 c1267e78 c0c68cbd c0abfc37 -> c0c68cbd c0abfc37", - "411c38e6 411c3c8e c18b8931 c0efebb1 -> 411c38e6 411c3c8e", - "c11e328a c11e0afe c18721fa c1508785 -> c11e328a c11e0afe", - "414faa39 414faae7 4193746c 419b8564 -> 4193746c 419b8564", - "c1aad322 c171c5a8 c14469ac c1435026 -> c14469ac c1435026", - "408aefdc 40cd2a2c c17f67ec c17f5930 -> 408aefdc 40cd2a2c", - "40ff9d2e 4122b5d9 414d29fb 41aacd6e -> 414d29fb 41aacd6e", - "c1900c9c c1900b72 c1983d30 c1983476 -> c1900c9c c1900b72", - "c13974bf c1397391 41742dee 41a47e0d -> 41742dee 41a47e0d", - "c101d61a c101d56a 40d9c3d6 40d9caf2 -> 40d9c3d6 40d9caf2", - "c0117606 bee7ebce 4053094a 4092a56b -> 4053094a 4092a56b", - "40e5ff38 40e60568 412c6425 412ce8db -> 412c6425 412ce8db", - "408bdfae 40ba81a2 40fd5760 40fd59c8 -> 40fd5760 40fd59c8", - "4172de4e 417b712a 417f46e2 417f5eb6 -> 417f46e2 417f5eb6", - "412305df 4123068d c197704d c1842b23 -> 412305df 4123068d", - "c117bc26 c117b7f4 418fe411 418fe4bb -> 418fe411 418fe4bb", - "c0b30753 c0930569 4100d3d2 41083412 -> 4100d3d2 41083412", - "c181320a c18131c2 c09adc1a 40a408e2 -> c09adc1a 40a408e2", - "c10715fb c107158b c182c905 c178810a -> c10715fb c107158b", - "c116a085 c1169653 40a7692d 40a93cdb -> 40a7692d 40a93cdb", - "c180b2e2 c180978e c0b4eb1b c0b4e121 -> c0b4eb1b c0b4e121", - "c0841d6c 3ebf0248 c01aef24 c019972c -> c01aef24 3ebf0248", - "c1455d5a c143db5a c1465405 c1464c79 -> c1455d5a c143db5a", - "41985220 419fc49c 4187ec35 4187f07b -> 41985220 419fc49c", - "4180a0f1 4180df2f c0523a60 bf4846c0 -> 4180a0f1 4180df2f", - "bfa0c722 bfa0c21e c0743233 c06ddf6d -> bfa0c722 bfa0c21e", - "c0dfadbe c0d5c38a 412eee5f 41571671 -> 412eee5f 41571671", - "40b8b45b 40b8b77d c183d9f1 c183a911 -> 40b8b45b 40b8b77d", - "c060edcf c05ec581 4125c9ac 413e8888 -> 4125c9ac 413e8888", - "41581bf5 415f7763 40be54c9 40bed997 -> 41581bf5 415f7763", - "c0b2de79 c0b2d117 3fca7519 3fce9267 -> 3fca7519 3fce9267", - "4158906a 415897be c19c429f c19c0561 -> 4158906a 415897be", - "c18c1a0c c17f8458 416db280 4178c878 -> 416db280 4178c878", - "414e9d75 4157cdd3 c185887e c1858814 -> 414e9d75 4157cdd3", - "c19c5eb5 c19756ab 417393e1 417d16e7 -> 417393e1 417d16e7", - "c16fe1a6 c16edfc2 414cdefa 414cdff6 -> 414cdefa 414cdff6", - "3d9c32a4 3ee68fd7 4159b8de 415a2242 -> 4159b8de 415a2242", - "c19b1251 c19b11c3 c04bc0aa c04bb516 -> c04bc0aa c04bb516", - "415e7e6f 415e7ee1 3f466f71 3f46c7cf -> 415e7e6f 415e7ee1", - "bfe3e788 3fc60608 4126bfe6 4126c0ea -> 4126bfe6 4126c0ea", - "40ee3ca3 40ee598d 413660dc 4147a620 -> 413660dc 4147a620", - "c128b075 c128a021 40b710bd 40bd810b -> 40b710bd 40bd810b", - "c051e4bf c0392921 414bf25f 414bf371 -> 414bf25f 414bf371", - "4144d961 41741b4f c0fb9e58 c0db7260 -> 4144d961 41741b4f", - "c0470249 c045ad37 419e58bb 419e5995 -> 419e58bb 419e5995", - "c067d3e0 c064f840 c0b0368d 4078b75a -> c067d3e0 4078b75a", - "c05f399c c0487484 41815a37 418bc179 -> 41815a37 418bc179", - "c13a9e2a c11bddee 4023821e 40238842 -> 4023821e 40238842", - "419b46d8 41a43130 c18edc48 c1853222 -> 419b46d8 41a43130", - "41274433 412744ad 415974ff 41597881 -> 415974ff 41597881", - "c189e832 c189e692 c18d0dc7 c18d0773 -> c189e832 c189e692", - "c1145d9e c11449da c11eaaff c081d1d2 -> c1145d9e c081d1d2", - "40ee7470 40fb09d0 4142338b 41423425 -> 4142338b 41423425", - "41827512 4183adaa 40d7cfd3 40d7d4c5 -> 41827512 4183adaa", - "414ab5e3 415b71f5 c08e44c2 c08ce65a -> 414ab5e3 415b71f5", - "c0953a8b c057531a c039baa1 c03565bf -> c039baa1 c03565bf", - "c16060ad c15b1615 c184f38f c184f341 -> c16060ad c15b1615", - "4150026e 41508352 c1938780 c19370c6 -> 4150026e 41508352", - "408cf72e 40b035e2 c18e7adc c18e77f6 -> 408cf72e 40b035e2", - "bf95ebc8 bf95d138 4110d7d5 4110d8df -> 4110d7d5 4110d8df", - "c1004fed bf980fd8 c16c10f3 c16b79a3 -> c1004fed bf980fd8", - "c18f1f27 c18ec32b c13cba6d c13c9fd9 -> c13cba6d c13c9fd9", - "c1818bc4 c148af40 41833498 41b43998 -> 41833498 41b43998", - "409ec670 409ee4b8 41378954 41379050 -> 41378954 41379050", - "4120b7d5 41212f8b c1641677 c16306c1 -> 4120b7d5 41212f8b", - "c11e9eeb c11e9357 c16dfa8a c16df6d2 -> c11e9eeb c11e9357", - "40e60541 40e6520f c067b028 c067aae8 -> 40e60541 40e6520f", - "405153dc 405252c4 40ea9c94 40f02d04 -> 40ea9c94 40f02d04", - "c1873053 c1872927 c165aa4b c1656e93 -> c165aa4b c1656e93", - "40b8a16e 41184e39 3ee47f06 3f13a27d -> 40b8a16e 41184e39", - "be83179c 3e1b6737 415efb5a 418cda4f -> 415efb5a 418cda4f", - "3f04b07c 3f04c144 413657f6 4136668e -> 413657f6 4136668e", - "c19d7f98 c194aeb6 c096d234 4040bd88 -> c096d234 4040bd88", - "c1940fb9 c1940e67 415222b0 415223e8 -> 415222b0 415223e8", - "4130b540 41806f88 4153fb0b 4157221d -> 4153fb0b 41806f88", - "c17293e6 c172928a 4130e762 41361b0a -> 4130e762 41361b0a", - "c12ec17b c12ead4b 41731754 417326c4 -> 41731754 417326c4", - "c151d381 c151bb5f 3fb9173a 403e3113 -> 3fb9173a 403e3113", - "41998e11 4199e0e7 c18b2b89 c18acff3 -> 41998e11 4199e0e7", - "c08531ee c085282a 40e32384 40e6459c -> 40e32384 40e6459c", - "408c13cc 408c165c c18979b9 c18393c3 -> 408c13cc 408c165c", - "4191b4fb 41947a2d 40225e5a 40ca4be3 -> 4191b4fb 41947a2d", - "bf4789bc bf477e84 405e71c0 40817460 -> 405e71c0 40817460", - "c18d7b96 c17d36e0 3da194b5 3db4d94b -> 3da194b5 3db4d94b", - "418d5009 418d51e7 40edfb7b 40ee0195 -> 418d5009 418d51e7", - "c13f0a98 c13eaf30 c1695723 c165dbb9 -> c13f0a98 c13eaf30", - "c11f3dc0 c11ca530 419ef4b0 419f4280 -> 419ef4b0 419f4280" - ] - }, - { - "glsl": "vec2 cultmath_iv_sqr(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c18130bc c1812a64 -> 43825780 4382644d", - "40fc3f58 4100388c -> 42788cc5 42807131", - "c118c87a c118c250 -> 42b64ea5 42b65d5c", - "c1902b76 c1902b32 -> 43a2613f 43a261d8", - "c198320b c19831d3 -> 43b4f669 43b4f6ee", - "411b0a6e 411babda -> 42bbcb43 42bd531b", - "40b9936b 4146d3d2 -> 42068666 431a6c58", - "41563721 415638df -> 43334037 43334321", - "411e0973 412ece99 -> 42c31f55 42eebafd", - "41239249 4123940b -> 42d10739 42d10bb7", - "c19abbe7 c198ec5d -> 43b6b311 43bb0d38", - "40627e8a 40628fb6 -> 414863aa 4148820e", - "3f93e153 3f9821cd -> 3faad917 3fb4d050", - "c084a0f0 c0849cd8 -> 4189643e 41896cb9", - "41937bb0 41939338 -> 43a9ee90 43aa24ce", - "3f4f83d0 3f5081b0 -> 3f28366e 3f29d300", - "4106d46e 4106d5a6 -> 428e0627 428e08b8", - "414c5694 414c59ec -> 43231a19 43231f70", - "c11a4682 c0215717 -> 40cb5d51 42b9f1d0", - "bfa02e48 3ee0b822 -> 00000000 3fc873c5", - "41429e3a 4143056e -> 4313f432 43149146", - "c0f16a42 c0352e3c -> 41003a69 4263a93c", - "c0023b6f c0023041 -> 40846a16 408480d5", - "c008cf9e c008b662 -> 40920494 40923a81", - "40acce8f 40accf81 -> 41e94c6e 41e94efb", - "41825525 41827933 -> 4384b52c 4384fea2", - "41654494 4184b18e -> 434d53c3 43898f2b", - "be0fdd46 be0226ba -> 3c8456b6 3ca1b1e7", - "410600ea 41067aae -> 428c49ea 428d4952", - "c1844b0f c17ed4d9 -> 437dab10 4388bafb", - "413cbc39 4175587f -> 430b24fe 436b2282", - "c18d01d2 c18c15ca -> 43994fae 439b5603", - "bf0a902d bf072513 -> 3e8eb03f 3e95ff83", - "41443bc9 414692e7 -> 43166b9a 431a0792", - "c164acea c161bfc6 -> 434712aa 434c4476", - "412a9174 4138c004 -> 42e34b01 43055496", - "c11344e5 c0b50226 -> 41fff814 42a97063", - "c0e4870a c0e2f116 -> 42492e8e 424c00d1", - "c1011382 c0fc34b4 -> 427877cd 42822955", - "41231bf6 4123368e -> 42cfd93d 42d01d09", - "c18d8a23 c18d88dd -> 439c8019 439c82ea", - "c024b8fe 403cd51e -> 00000000 410b49b5", - "3e3a5741 3e3a92bf -> 3d07a2e8 3d07f992", - "c062dee8 bffafd11 -> 4076133f 41490e54", - "407aeffe 407b88c2 -> 4175f99d 41772575", - "c001777e be33591c -> 3cfb4b78 4082f34a", - "416d250e 4174871a -> 435bada1 436991d1", - "c1a9d2e4 c1920966 -> 43a69d71 43e1503e", - "c061df18 c03a6af8 -> 4107bf9d 414749eb", - "c0050cbd c0050a93 -> 408a47fa 408a4c7a", - "c0c7fc46 c0a29592 -> 41ce8348 421c3a2d", - "c1a31e10 c14354cb -> 43150a49 43cfde98", - "c1299d8b c1299bf3 -> 42e0be8c 42e0c2c5", - "c1935692 c12ca9d0 -> 42e8e940 43a99912", - "bf8fef0a 40a08172 -> 00000000 41c94420", - "c1702d51 c1702c89 -> 43615389 43615500", - "4115c1f2 411d0c2e -> 42af36ad 42c0afe2", - "40fb1af0 41019538 -> 42764dd5 42832f73", - "c07317c4 c07311cc -> 4166cacb 4166d620", - "c17b1e52 c17aed62 -> 4375f480 43765478", - "41823ac2 41b9e3e6 -> 43847f75 4406fb2d", - "c1971c98 c1928eca -> 43a7ce5c 43b2657d", - "c16e4ddd c12b6731 -> 42e5860a 435dd4df", - "4183e7ff 41848d59 -> 4387ee82 43894424", - "418112a5 41812ebb -> 43822797 43826042", - "c173e7fa c173144e -> 4366cf8e 43686237", - "c13fe745 c138ae33 -> 43053ae0 430fdaea", - "c19eb0d0 c19ead68 -> 43c4b504 43c4bd76", - "c18aede0 c18a9a4e -> 43961572 4396caa5", - "41088e20 4108b138 -> 4291aea2 4291f98c", - "418b89d4 418bb048 -> 43981ded 439871cf", - "c106d63d c104494f -> 4288b75d 428e09f6", - "c113cfc1 c1139e2b -> 42aa3e0e 42aab080", - "c177469b c1774471 -> 436ed524 436ed953", - "c1954c3c c195437a -> 43ae0f3c 43ae23a9", - "bed5ca7d bed40883 -> 3e2f9e19 3e328a94", - "40c04277 40c043a9 -> 421063c4 4210658f", - "c19668aa c1965670 -> 43b092d1 43b0bda4", - "41324c7e 4132615e -> 42f85cec 42f89718", - "4141aae0 4141b988 -> 43128318 43129946", - "c13d6a4c c13c7a90 -> 430ac43e 430c2620", - "c188a9bc c188a8e8 -> 4391e7cc 4391e991", - "4157bae8 41590818 -> 4335cb7a 4337feb9", - "416015f6 4160166a -> 43442670 4344273b", - "411184c2 4111d212 -> 42a56f51 42a61f4a", - "40506fc6 40bb54d5 -> 4129b5d3 4209150b", - "c087e9f9 c075fdc6 -> 416c5fb9 41905135", - "bf5bc206 bf4f0afa -> 3f2772c1 3f3ca589", - "40e2a486 40e2f152 -> 4248a6e6 42492ef8", - "bf86d07a becb9d9a -> 3e21f353 3f8dfdd3", - "41413982 414c5fe6 -> 4311d7c3 432328fa", - "3ff06b2b 3ffa4655 -> 4061c91d 4074ad71", - "41877dab 4190b819 -> 438f6b90 43a39f41", - "417b2a5b 417b2d5d -> 43766c15 437671fc", - "40ff2f14 41017a12 -> 427e5ed3 4282f881", - "bfcba001 bf95b77f -> 3faf1e3b 4021f726", - "410c6482 410c8eca -> 4299fc2b 429a58f9", - "c14bb775 c14b95d9 -> 4321e6fe 43221c77", - "c0975277 c0974ca9 -> 41b2d70d 41b2e4c6", - "413f5bc6 4143b8aa -> 430f0a12 4315a2d8", - "402a2043 402a25bd -> 40e21dba 40e22c49", - "c0570865 c0520bdb -> 412c5774 41349f1a", - "41070851 4108c2c3 -> 428e738b 42921f07", - "4161f8d2 41944f17 -> 43477753 43abd716", - "4007d5fd 4009a863 -> 409026c7 40940b51", - "41080f4a 41083176 -> 4290a07f 4290e92e", - "4166252a 416625ce -> 434ee6cd 434ee7f4", - "bb7b22ec 3c3998bb -> 00000000 39068e19", - "c19e57c4 c19e1a2e -> 43c348a7 43c3e0e8", - "c14aa316 c14aa28a -> 432064e9 432065c7", - "40eed2a3 40f694a5 -> 425ecc54 426d8203", - "c0f5d865 c0f5d55f -> 426c121a 426c17e8", - "41918dc6 41a7d796 -> 43a583d2 43dc15f7", - "c191f485 c10aec54 -> 4296c749 43a66dd0", - "3fc9ca28 3fc9d418 -> 401f0f12 401f1ebd", - "c15b8567 c15af8df -> 433b4cce 433c3d84", - "404d5c98 4084cc5c -> 4124bd6d 4189c6c4", - "c144b63a c13f4e2a -> 430ef5bb 4317278b", - "c1175088 c01a45e6 -> 40b9f058 42b2e034", - "416989db 41699c65 -> 43550c3b 43552e0f", - "414e1dad 419b963d -> 4325f3c6 43bd1e8c", - "40995394 40995cc4 -> 41b7aa04 41b7c008", - "41807d85 41807e0b -> 4380fb85 4380fc92", - "4167c4ed 416bcbbb -> 4351d4fb 43592fab", - "417d6cc2 4182fddf -> 437ae026 43860da4", - "c0c83e4c c063ec18 -> 414aec8c 421ca166", - "4198b0d3 419ecf45 -> 43b624e9 43c50902", - "4193fdf1 41aa6b97 -> 43ab1b3d 43e2e624", - "413e01ce 413e0f4e -> 430d06ae 430d1ab9", - "40390ea7 408664dc -> 4105c62e 418d1b7c", - "c082cb56 bee62fa0 -> 3e4ef99c 4185a64a", - "c08da637 c08d082d -> 419b6404 419cc109", - "c0d53675 c0d52db7 -> 4231851b 423193aa", - "413b0ef1 413b0fcf -> 4308aed5 4308b019", - "4153af2a 4162ac86 -> 432f0a37 4348b511", - "c184f719 c184f6c9 -> 438a1eda 438a1f81", - "408a0fe0 40c47660 -> 4194ea3d 4216c57a", - "c1759f4a c16ec906 -> 435eba65 436baa47", - "c18db936 c18db894 -> 439ce9b0 439ceb17", - "c1544e59 c11c89d3 -> 42bf7087 433011db", - "c1988431 c1984ec9 -> 43b53b4e 43b5ba7d", - "c185d20f c17cc00d -> 43798aaa 438be7e0", - "410c310f 410c3a5d -> 42998b64 42999fc6", - "3e5fa364 3fb48d34 -> 3d435e11 3ffeadbe", - "413e3090 413e3ea8 -> 430d4c1f 430d6111", - "4182d356 4182d3b2 -> 4385b6a4 4385b760", - "c0986161 c098600f -> 41b5646c 41b56790", - "412f48e2 41a0932b -> 42f00973 43c97095", - "403d1f53 403d29fd -> 410bb744 410bc706", - "416e901f 417363f1 -> 435e504b 436766e3", - "c10f1cb1 c0fe1227 -> 427c2807 42a00222", - "41581f72 415820de -> 43367514 4336777b", - "40ce3769 40ce6117 -> 42261d39 42266066", - "c11c7f01 c11c7d13 -> 42bf5159 42bf5610", - "40c69197 40c6a439 -> 421a0588 421a2272", - "41524056 41574022 -> 432cad9d 4334fcc9", - "c183a4bd c181a12f -> 438347ae 43876407", - "410d4310 41724344 -> 429be5e2 4365433e", - "414b383c 414cbe94 -> 4321523c 4323c04a", - "41185109 411851df -> 42b540a9 42b542a6", - "4064a7be 4133f638 -> 414c3b38 42fd047e", - "c1151455 c1145233 -> 42abde4b 42ada159", - "4176b86c 4176b90c -> 436dc6f4 436dc829", - "40c4fe5e 40c7d092 -> 4217967d 421bf5ed", - "41949c53 41949d3d -> 43ac8a3f 43ac8c5e", - "c1764460 c146d574 -> 431a6ee1 436ce77b", - "c132943f c131f8a9 -> 42f77396 42f924fb", - "4098f225 4098fcdb -> 41b6c0e2 41b6da7c", - "3fce02b0 41208dfa -> 4025c853 42c9638e", - "c16b3452 c16b149c -> 4357ded8 43581919", - "c19afb05 c19ae99b -> 43bb7bc7 43bba5f0", - "c159df4e c15930e4 -> 433843ec 43396c55", - "bf80995b bf8074a5 -> 3f80e9b4 3f81336e", - "4190bcc7 41934a25 -> 43a3a9d6 43a97c78", - "c147f756 c1024916 -> 42849c9e 431c3277", - "c187a2b2 c112f9f0 -> 42a8c414 438fb9fe", - "c06672a2 c01af19e -> 40bb8f2c 414f722e", - "c19c9a12 c19c92a4 -> 43bf8618 43bf9845", - "3fa784b5 3fa7ef6b -> 3fdb3cd2 3fdc547b", - "c1327486 c13053f6 -> 42f2e71c 42f8cc7f", - "40eb079f 40f1e7a9 -> 4257c6fe 426495fe", - "c1538191 c152d3b3 -> 432da001 432ebed7", - "c18d7c00 c14c9397 -> 43237b8e 439c63a8", - "bf6ffa1e bf5c97e2 -> 3f3e1567 3f60f4f8", - "c18ce2c2 c18c46ce -> 4399bb0a 439b119a", - "c102818c c0d5e518 -> 4232b707 42850fa7", - "bfbcade5 bfbbde9b -> 4009def8 400b0fde", - "c1912c19 c19125ab -> 43a49763 43a4a5f8", - "4146ba0b 414eea2d -> 431a4450 43273db7", - "c18dace8 c18bc3bc -> 43989c48 439ccfd9", - "c19df92e c15d7944 -> 433f9a99 43c2f72a", - "c0c3c2f8 c0c3c1b8 -> 4215b0b1 4215b29a", - "4192071d 419208a3 -> 43a6983b 43a69bb4", - "bf9c0325 bf9a9f9b -> 3fbac8d4 3fbe27aa", - "3e558bc2 3e59143e -> 3d3221dd 3d381353", - "40f3ce4c 40f3f8cc -> 4268314b 42688245", - "412796c8 41282490 -> 42db6c23 42dce004", - "40f4fdd6 40f52b92 -> 426a74dc 426acc6d", - "c1370cfd c134ab63 -> 42ff02ec 4302e392", - "c0704b86 c06d337a -> 415bc85a 41618db2", - "4114a642 4114c6f6 -> 42aca151 42aced4e", - "40afe5c0 40b6b650 -> 41f1b7d5 420267bc", - "4090f4a3 40911d85 -> 41a42842 41a484e8", - "3f17ec5d 3f17fa23 -> 3eb45160 3eb47213", - "4128a083 412e63d9 -> 42de2621 42ed97c4", - "bf2644f8 3e80c970 -> 00000000 3ed7fb08", - "c1255d32 c1247e2c -> 42d363cd 42d5a289", - "3fc70ff4 4000ce86 -> 401ac9ce 40819e59", - "c0e738db c0e7350d -> 4250d0c8 4250d7a8", - "3df062a0 40ad74f6 -> 3c61b912 41eb0e94", - "bfa1fac0 bfa1f360 -> 3fcce80c 3fccfab6", - "c18bbeb1 c1871503 -> 438e8e56 43989145", - "413d4b3d 419842be -> 430bf82e 43b51ea6", - "c1a11bd5 c1627fb2 -> 434865b6 43cac80a", - "40d31e6e 40dce552 -> 422e1b2d 423e9af2", - "c185474a c185459e -> 438ac2d2 438ac64d", - "c0d3c4f7 c0d271e1 -> 422cff08 422f2e47", - "418c9562 418f1ab2 -> 439a6775 439ffdab", - "c0f1f71d c0e9cbdb -> 425584b7 4264b333", - "c04836dc c04074f4 -> 4110afa3 411c95c4", - "40cbcf78 40cc2668 -> 422242b0 4222cd3c", - "40a32179 40c0fa57 -> 41cfe749 42117877", - "412ed9c4 4161358c -> 42eed97f 43461f2b", - "c17f8f45 c17f8a65 -> 437f1500 437f1ebc", - "41765a05 41ad4eb5 -> 436d1121 43eaa6f2", - "c1966683 c19665fb -> 43b0b756 43b0b895", - "c18b2e69 c18b04ad -> 4396fc28 439756dd", - "c18ae566 c189438a -> 439332b7 4396b83f", - "c10f751a c0c7d174 -> 421bf74e 42a0c811", - "4131d1d3 413468c1 -> 42f707a4 42fe46f5", - "c114c666 c113c58c -> 42aa98ee 42acebff", - "c0857273 c0857099 -> 418b1c61 418b203d", - "40a38394 40a3a18c -> 41d0e1a4 41d12e3c", - "bffb1539 bfc8c1e7 -> 401d6f8c 407642a0", - "40546974 409fdf36 -> 41303ed4 41c7ae0f", - "c0571b14 c04d32ac -> 41247a31 4134be7e", - "40b05918 4134cb00 -> 41f2f540 42ff5c32", - "c109405e c1093f84 -> 42932a16 42932bea", - "c02fe663 c02fbecd -> 40f14cd5 40f1b995", - "4155b620 41af1b14 -> 43326893 43ef8c10", - "415e04d8 417c95c0 -> 43408c67 4379372a", - "419c11dc 419ee31c -> 43be4b8b 43c53a40", - "40d5c4fa 40d5c5ce -> 42328160 423282c2", - "c183d642 c1627e29 -> 434862ff 4387c9f6", - "bfe728d9 bfe6d547 -> 405023ed 4050babe", - "c08d4095 c08cd08f -> 419ae98d 419be069", - "417a850c 4183b95a -> 43752821 43878e71", - "c0c2128b c0c20ff5 -> 42131c30 4213201c", - "c19d43bf c19cb5d7 -> 43bfdc3e 43c13854", - "c155e91b c15567bd -> 4331e5cb 4332bdbb", - "c01058ed c00fd413 -> 40a19d3a 40a2c853", - "408e459e 408e48d2 -> 419e229c 419e29bb", - "3fd3deb1 3fd509af -> 402f58d9 4031491e", - "c0a37e08 c0a37b08 -> 41d0cbcf 41d0d378", - "c14f2db0 c14f2d40 -> 4327aa35 4327aaeb", - "c12c675a c12c66c0 -> 42e83476 42e83615" - ] - }, - { - "glsl": "vec2 cultmath_iv_sqrt(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "418b2194 41929180 -> 40857317 4088f84b", - "412d5f3e 412d8e52 -> 4052ac5e 4052c8f6", - "4023bf3d 40350d33 -> 3fccbdec 3fd749e4", - "c07a34ab c0718115 -> 00000000 00000000", - "c14378f0 c1422990 -> 00000000 00000000", - "c1170d65 c116fc97 -> 00000000 00000000", - "c0c946b2 402c9fb4 -> 00000000 3fd237de", - "40e841d5 413a7e0a -> 402c6bb6 405a7fe0", - "40854637 40854d29 -> 40029c4b 40029fb2", - "c19710f5 c18681ff -> 00000000 00000000", - "c1796cdb c1792b6f -> 00000000 00000000", - "3fd7bffa 3fdb50e6 -> 3fa62e3b 3fa78c61", - "c135dc70 c110735a -> 00000000 00000000", - "c1549741 c1548d8b -> 00000000 00000000", - "40a4e746 40a4e822 -> 401148e0 40114941", - "40fbd1da 40fc62d6 -> 4033890a 4033bcb1", - "c18fcccc c18fc060 -> 00000000 00000000", - "bf44dc18 bf44c568 -> 00000000 00000000", - "c1afdd7d c18972d7 -> 00000000 00000000", - "3fa667a8 3fa6eeb8 -> 3f91f1d2 3f922d00", - "c1575453 c1568845 -> 00000000 00000000", - "c10d69fd c0da2e12 -> 00000000 00000000", - "c174a8a7 c1749d4d -> 00000000 00000000", - "40d00e75 40d1df3b -> 402330d7 4023e6b7", - "40c6edac 40c7750c -> 401f921f 401fc862", - "c0848d47 409abcaf -> 00000000 400cbc29", - "4190743c 41908250 -> 4087fa76 40880117", - "4187264f 41876b7d -> 408386b8 4083a85e", - "c11f4475 c11f39ed -> 00000000 00000000", - "c1577336 c152c062 -> 00000000 00000000", - "3f3dc9a8 3f3de698 -> 3f5c6bea 3f5c7cb7", - "419f4eff 419f50d9 -> 408ecc7e 408ecd53", - "416d6327 41802418 -> 4076849f 4080120b", - "c111fa40 c111f8fa -> 00000000 00000000", - "3ea819aa 3eef3956 -> 3f12afa9 3f2efcd5", - "4184f333 4186b275 -> 40827397 40834e4d", - "40bcc173 40cb2d5d -> 401b6fed 40214410", - "40fd9806 40ffe2aa -> 40342aa8 4034fa94", - "c16ac26a c166acc2 -> 00000000 00000000", - "c102e78f c0079fd5 -> 00000000 00000000", - "c13a3d7c c1384ad8 -> 00000000 00000000", - "4098c044 4098c72c -> 400bd435 400bd75f", - "beb14d62 bbcae7a0 -> 00000000 00000000", - "be540ab8 3d5c1ee0 -> 00000000 3e6d6226", - "c0ccc3ea 3f8d53ca -> 00000000 3f867fa9", - "4160c70a 4167cb66 -> 406fe19d 407398c8", - "411fcac1 4138daf7 -> 404a4112 405989d6", - "4142dd7d 4142de1b -> 405f59c1 405f5a1b", - "3fd51a1c 3fd52624 -> 3fa5285d 3fa52d06", - "41981d91 4198244b -> 408b89aa 408b8cc0", - "c19af23a c19a69c2 -> 00000000 00000000", - "c192efa7 c192ef5f -> 00000000 00000000", - "3e5e848c 3fe89b6e -> 3eeeac27 3fac8cf5", - "c0cff9bf c0cfef59 -> 00000000 00000000", - "40d77c4e 40d7ab52 -> 40261429 40262646", - "c0a85bac c0a61940 -> 00000000 00000000", - "4183737a 418375ca -> 4081b6cd 4081b7f1", - "c0124cc5 3f6e01d4 -> 00000000 3f76d6f5", - "be450b64 3f76ded9 -> 00000000 3f7b64d1", - "40fa8a1d 40fa9093 -> 4033140f 4033165e", - "c0ec7667 c0e9a791 -> 00000000 00000000", - "40d20e61 40d39187 -> 4023f91f 40248ff5", - "412dfa6e 412dfe12 -> 40530a93 40530cc8", - "4175af88 41844124 -> 407aca31 40821c1e", - "4187946d 41893f87 -> 4083bc42 40848b1f", - "c1969a28 c19699e4 -> 00000000 00000000", - "4103d739 4103d81f -> 4037b70e 4037b7ae", - "418c1762 418d724e -> 4085e8c6 40868e2e", - "40404bef 404626f1 -> 3fdddfaa 3fe139f7", - "40c97fd8 40cf82e8 -> 40209940 4022fa13", - "c0a7fdf5 c0a7e9ff -> 00000000 00000000", - "c19b4016 c19b3f90 -> 00000000 00000000", - "40873edb 40875525 -> 400392aa 40039d81", - "414ac583 414bc445 -> 4063d62b 4064651e", - "c0ecca74 c08402f8 -> 00000000 00000000", - "3f4cdfed 3f9ef18a -> 3f6503df 3f8ea295", - "c072832d c0355c93 -> 00000000 00000000", - "419bc4e0 419be124 -> 408d341b 408d40ea", - "417fc1e1 41802647 -> 407fe0ef 40801322", - "c11cb2cb c11c9f45 -> 00000000 00000000", - "418d592f 418dadfd -> 4086823b 4086aa8e", - "c1038f5f c1038ef1 -> 00000000 00000000", - "c0e36a3f c0e33e49 -> 00000000 00000000", - "415bb4c4 4175ea74 -> 406d28e8 407ae842", - "c11f1a83 c10687e1 -> 00000000 00000000", - "c10ec66d c0a1f3db -> 00000000 00000000", - "c15e289d c15e27f5 -> 00000000 00000000", - "4146c39a 4146c43e -> 406192ee 4061934b", - "403a5047 403f8e09 -> 3fda6510 3fdd7201", - "41893d0b 4189737d -> 408489ec 4084a434", - "c0a3af4d c0a38653 -> 00000000 00000000", - "bfd62284 bfd61e3c -> 00000000 00000000", - "c16780e4 c16773e2 -> 00000000 00000000", - "401e69f4 40c0b1b6 -> 3fc96150 401d0ced", - "c1863b4f c185f103 -> 00000000 00000000", - "411d44f6 411d45e2 -> 4048a6be 4048a755", - "c0d0a1c4 c0d07f90 -> 00000000 00000000", - "40f51440 41158398 -> 40311dbb 4043a439", - "419a880c 419a8848 -> 408ca437 408ca453", - "41262881 412630a7 -> 404e3e69 404e4378", - "c0d9fb20 3f2a22c4 -> 00000000 3f50b2a2", - "c107e4ba c1074424 -> 00000000 00000000", - "4043bb55 404ac2fb -> 3fdfd8bf 3fe3d4bf", - "40429147 40430de9 -> 3fdf2e0f 3fdf757f", - "41856280 41b1517c -> 4082aa26 4096a785", - "4162a432 4162b406 -> 4070dfb2 4070e81b", - "402db0ab 405b26b5 -> 3fd2ddd1 3fecdc30", - "4193e512 4194b79a -> 4089969a 4089f865", - "c18b21bb c18b1d15 -> 00000000 00000000", - "416a6850 416a68d8 -> 4074f748 4074f78f", - "40d4d513 41486c3e -> 40250d9a 40628363", - "4122a346 412c947e -> 404c0c17 4052310a", - "c182b7bb c182b3e1 -> 00000000 00000000", - "40210c3c 407a2864 -> 3fcb0c20 3ffd0fe1", - "c123661b c060d94b -> 00000000 00000000", - "c18e4fcb c18dc935 -> 00000000 00000000", - "414cf16d 4150807b -> 40650da7 40670894", - "c18c45ef c18c320d -> 00000000 00000000", - "c1a365bc c1770e99 -> 00000000 00000000", - "c00d1c6b c00a3f35 -> 00000000 00000000", - "410f898c 410f8f54 -> 403fb0f8 403fb4d4", - "4187d56b 4187d65d -> 4083dbd2 4083dc47", - "40c9b2a0 40ca2428 -> 4020ad7c 4020daae", - "be94768d be6314e6 -> 00000000 00000000", - "c0b257ed c0b25503 -> 00000000 00000000", - "41306251 41362d13 -> 40547ed6 4057f4c9", - "c167bd5d c15fef83 -> 00000000 00000000", - "3f4a7081 3f5020bf -> 3f63a664 3f66d383", - "c138217b c1376b9b -> 00000000 00000000", - "c03aa7ff c03a6481 -> 00000000 00000000", - "c19945e3 c194e8d5 -> 00000000 00000000", - "c190b354 c190b312 -> 00000000 00000000", - "417ac1e3 417acd85 -> 407d5d79 407d6359", - "bff8d4e1 3fbf6061 -> 00000000 3f9c8339", - "4104ea23 4105ff19 -> 40387635 40393601", - "4001d324 4001da1c -> 3fb64e19 3fb652fe", - "41506e24 415081c4 -> 4066fe6a 4067094a", - "c101bf5f c1012e75 -> 00000000 00000000", - "c1972cb3 c1960f37 -> 00000000 00000000", - "c180884d c17dc0cb -> 00000000 00000000", - "412734b3 4127352d -> 404ee499 404ee4e5", - "bfa38809 bfa35f97 -> 00000000 00000000", - "c149976f c14981d9 -> 00000000 00000000", - "c04e01e0 c04dfd80 -> 00000000 00000000", - "c1611fa1 c15fa845 -> 00000000 00000000", - "c14a2fd2 c1498896 -> 00000000 00000000", - "3efd3ae8 3efd7098 -> 3f340991 3f341ca6", - "c06f7542 407b5912 -> 00000000 3ffda9ce", - "c165f9ce c130dcd0 -> 00000000 00000000", - "c125b0ba c12594ae -> 00000000 00000000", - "418a860b 418b34fd -> 4085286b 40857c66", - "415dc07d 416ccc53 -> 406e42ea 40763642", - "401225f4 401e1e9c -> 3fc16d47 3fc93166", - "416e48cf 417fcef1 -> 4076fbc1 407fe777", - "c019c914 c019c73c -> 00000000 00000000", - "c01c2fea c016dd26 -> 00000000 00000000", - "c04c0458 c021c198 -> 00000000 00000000", - "401df6c1 401df8af -> 3fc91809 3fc91944", - "c1188124 c10206ac -> 00000000 00000000", - "415615b1 4156f577 -> 406a1b2d 406a9567", - "416d6bab 416d991d -> 4076890b 4076a0a2", - "41250d80 41250f10 -> 404d8e7b 404d8f74", - "c097c956 c097c832 -> 00000000 00000000", - "408bd9ee 40965b92 -> 4005cb64 400abaab", - "4155961e 4155a692 -> 4069d562 4069de63", - "c0dcb0e7 c0dcad71 -> 00000000 00000000", - "c097448e c0885512 -> 00000000 00000000", - "4112b415 4112b727 -> 4041cb3e 4041cd45", - "c15e77bc c15abdfe -> 00000000 00000000", - "40ca9d92 40cc0e66 -> 40210af5 40219d46", - "bfdc96bf bfcdf481 -> 00000000 00000000", - "40ba25e0 40ba29f0 -> 401a5c1a 401a5dc9", - "c15f4700 c15daa98 -> 00000000 00000000", - "c1843ee0 c17fa7f7 -> 00000000 00000000", - "401aad4c 401c70b4 -> 3fc6fd9e 3fc81f29", - "40fcedb6 40fd1d32 -> 4033ee1e 4033ff01", - "c18b168e c188bc30 -> 00000000 00000000", - "be395d2f be0e37d1 -> 00000000 00000000", - "414e1368 41564b58 -> 4065af7a 406a3881", - "c05f8ad8 c05ca758 -> 00000000 00000000", - "c192dfb6 c192de08 -> 00000000 00000000", - "4197b7cb 4197b899 -> 408b5af4 408b5b53", - "40e9ceaf 40e9ed71 -> 402cfec6 402d0a27", - "c144b8a7 c13ff569 -> 00000000 00000000", - "c194ecb4 c194db1e -> 00000000 00000000", - "4164e581 41669baf -> 407211b8 4072f8fc", - "c152cbc5 c152be21 -> 00000000 00000000", - "c1837b6b c183775b -> 00000000 00000000", - "4127b48f 4129b131 -> 404f33a5 40506cee", - "41912ec4 41979914 -> 40885225 408b4cd8", - "4182b73a 41939ce2 -> 408159ca 40897501", - "c164d871 c164c283 -> 00000000 00000000", - "3f968376 410abea5 -> 3f8acd11 403c76c3", - "c18f3c08 c18cdff8 -> 00000000 00000000", - "c127ceea c127ca9c -> 00000000 00000000", - "c0c49fdb c0c44085 -> 00000000 00000000", - "c1197e73 c1197ca9 -> 00000000 00000000", - "bed46d7b bed33485 -> 00000000 00000000", - "40af529e 40b0b12a -> 4015cde2 4016635b", - "c020eb88 bf799f60 -> 00000000 00000000", - "c0756fd9 c074ce17 -> 00000000 00000000", - "4108c32f 4108c639 -> 403b1cde 403b1ef2", - "40a52b1a 40a52d76 -> 401166be 401167c8", - "c150ddab c1463b21 -> 00000000 00000000", - "4085d0db 4085dd55 -> 4002e029 4002e642", - "41273f0c 412743a0 -> 404eeb00 404eedd5", - "41310608 413358f0 -> 4054e15d 405645e6", - "4075c698 4075d308 -> 3ffad5f6 3ffadc4f", - "c193ac6d c1929081 -> 00000000 00000000", - "bea8fcaa 3c806a98 -> 00000000 3e003541", - "c11a9978 c11a1452 -> 00000000 00000000", - "c01baacc bf81ab48 -> 00000000 00000000", - "c19331fd c1930f47 -> 00000000 00000000", - "c0c585b7 c0c58461 -> 00000000 00000000", - "414026b4 4152da0c -> 405dca2f 406854ee", - "409c19ed 409c2683 -> 400d5aa2 400d6055", - "c1580cc7 c1580b07 -> 00000000 00000000", - "c09ebfcc c09d37b4 -> 00000000 00000000", - "c18b6e89 c1278b5a -> 00000000 00000000", - "410a54a2 410b0e4e -> 403c2eb5 403cacd5", - "413b804a 413b8c0a -> 405b16f5 405b1dd3", - "c1836577 c1836541 -> 00000000 00000000", - "c012039f c011fbb1 -> 00000000 00000000", - "40aa48cb 40aeb065 -> 4013a2d3 40158884", - "3fa3474d 3fa3c073 -> 3f90912e 3f90c6c6", - "c1296198 c1296124 -> 00000000 00000000", - "c1988cd0 c1941f1a -> 00000000 00000000", - "3fc3c5f9 40985272 -> 3f9e4ce1 400ba1e9", - "4182fd98 4197dc6c -> 40817c96 408b6bc6", - "c16a634f c16a5fef -> 00000000 00000000", - "411d8450 411d8658 -> 4048cf24 4048d070", - "418c4a24 419380e4 -> 40860106 408967f8", - "4091f48c 40934a1c -> 4008aee1 40094e72", - "c191a1e0 c1902c84 -> 00000000 00000000", - "c11c4331 c11c425f -> 00000000 00000000", - "c1980d40 c1980cc8 -> 00000000 00000000", - "41522076 419e6715 -> 4067ee99 408e6468", - "41528a08 41a02a18 -> 406828d5 408f2e8f", - "c05f4ffc c05e1914 -> 00000000 00000000", - "c0c4a0c6 c0370905 -> 00000000 00000000", - "4143f85a 414a30ae -> 405ffba1 4063827e", - "3ed4a575 3ee5138b -> 3f24fb22 3f2b3c6b", - "40447dd7 404be949 -> 3fe047dd 3fe479dc", - "c13b8977 c13b5975 -> 00000000 00000000", - "3ff262ea 3ff56976 -> 3fb023f4 3fb13c83", - "4070aea6 4070d27a -> 3ff83915 3ff84b8e", - "4155d7ce 41569642 -> 4069f954 406a616e", - "4135030d 4137fbc3 -> 405743dc 40590659", - "c0ca7196 c0ca582a -> 00000000 00000000", - "c0cfe7a5 c0241266 -> 00000000 00000000", - "c1a4046a c14515f8 -> 00000000 00000000", - "c0a451f9 c0a3967b -> 00000000 00000000", - "c107379c c10734ea -> 00000000 00000000", - "c180cfcc c180cf5c -> 00000000 00000000", - "4154c7da 41569a86 -> 4069645e 406a63c2", - "beeb428b bedd6df5 -> 00000000 00000000" - ] - }, - { - "glsl": "vec2 cultmath_iv_clamp(vec2, float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "be2ae9ac be297554 c17b22bf 3f346da0 -> be2ae9ac be297554", - "40a42325 40a4b22b c19d7006 3d2ed2b6 -> 3d2ed2b6 3d2ed2b6", - "c0ecb93a c0e80616 c1b31873 419c3981 -> c0ecb93a c0e80616", - "bfd52e3e bf874342 c19896ee 411745bb -> bfd52e3e bf874342", - "c14d0c1d c14d03d9 c115d628 40376a0a -> c115d628 c115d628", - "c18a0a2e c189dd20 c0952918 41a5b17d -> c0952918 c0952918", - "c0c517ae c0c51666 c19d7dd6 4125d972 -> c0c517ae c0c51666", - "3f1d6100 3f1d8280 c1280a61 41bb42d9 -> 3f1d6100 3f1d8280", - "419b7a07 419b7abd c0b64fc4 4171b13e -> 4171b13e 4171b13e", - "c15da06c c153e0e4 c1c2ef8f 41b2b201 -> c15da06c c153e0e4", - "c184a78f c1849651 c11f2d40 41368bbe -> c11f2d40 c11f2d40", - "41713f6b 4172afcd c1c6cf76 4154bd03 -> 4154bd03 4154bd03", - "4186e8dc 418a1180 c036c460 41652b83 -> 41652b83 41652b83", - "419b7728 419b8660 c16908fc 3f2f137d -> 3f2f137d 3f2f137d", - "c05654b9 c052fbe7 c0fe43e4 416bd5aa -> c05654b9 c052fbe7", - "c130e24e c12136d8 c14d779f 408c25df -> c130e24e c12136d8", - "c18ee31a c18ee1ae c0a3cbf4 410f4bef -> c0a3cbf4 c0a3cbf4", - "419a8b59 419bb62f c19ca0ee 4129123c -> 4129123c 4129123c", - "c12cd6d2 c125880e c1c22f69 4188c5f2 -> c12cd6d2 c125880e", - "416a7799 416a909f bf9ebe40 41970c10 -> 416a7799 416a909f", - "c1967ad2 c194743e c14cc307 419f37d3 -> c14cc307 c14cc307", - "c11c32ff c11c328d bf9ec620 4174a937 -> bf9ec620 bf9ec620", - "40eb2334 40fc13f4 c1a28a3b 41770d4e -> 40eb2334 40fc13f4", - "c1882079 c1880191 c108f424 40e5e5a3 -> c108f424 c108f424", - "417f0f90 417f4760 c16ed945 418df8ac -> 417f0f90 417f4760", - "413bc18b 413e86f1 c1352bf2 40eaf727 -> 40eaf727 40eaf727", - "3db1c0f7 3ddc1909 c1848b6c 40cb313b -> 3db1c0f7 3ddc1909", - "c0cda994 c0bec5dc c1a7d0ac 3fbf2fe7 -> c0cda994 c0bec5dc", - "3fc9be82 40bc6a60 c13154ec 415e10d2 -> 3fc9be82 40bc6a60", - "c0f79a4e c0ee8f0e c0013558 3f94d730 -> c0013558 c0013558", - "c13497d1 c134946d c104d4b0 40c0041a -> c104d4b0 c104d4b0", - "c00ea341 c0084b5f c1826c3e 419ffb92 -> c00ea341 c0084b5f", - "c18a4366 c1862ca6 c0abde8c 412fd2c0 -> c0abde8c c0abde8c", - "41915f28 4191626c bf80f430 411a1572 -> 411a1572 411a1572", - "c16a7cb3 c16a78dd c18d4481 419e91cd -> c16a7cb3 c16a78dd", - "40d45ba8 40de10d0 c192b2b0 41bf5abf -> 40d45ba8 40de10d0", - "405697a9 40569ec7 c1c32261 406c9334 -> 405697a9 40569ec7", - "41729925 41729a7b bf116b80 40a6c4dd -> 40a6c4dd 40a6c4dd", - "3e9aae31 3e9dc74f c14b30d5 4174c5d9 -> 3e9aae31 3e9dc74f", - "4199845b 41998b61 c072e720 41b4a3e9 -> 4199845b 41998b61", - "c176a81f c175e0f9 c1a410ae 41716039 -> c176a81f c175e0f9", - "418ddd66 419119a6 c1b2e97f 410d1b2f -> 410d1b2f 410d1b2f", - "419582d3 4195844d c1676270 40392092 -> 40392092 40392092", - "c0846295 c0845f13 c179460d 4150938d -> c0846295 c0845f13", - "418407f7 4186e851 c1098634 40fe5f9c -> 40fe5f9c 40fe5f9c", - "403fb52e 403fc592 bffd4810 41c25f77 -> 403fb52e 403fc592", - "41289eb6 4129d7f2 bfd9d330 416f2d26 -> 41289eb6 4129d7f2", - "411f011c 411f1790 c16dd464 41a550a0 -> 411f011c 411f1790", - "c0c500f1 c0c4b78b c100f18e 4053bbb4 -> c0c500f1 c0c4b78b", - "3f10bd6d 3f45a813 c1c65274 41ac7e2d -> 3f10bd6d 3f45a813", - "c199d5c5 c19802f5 c1a3dfd4 418d8541 -> c199d5c5 c19802f5", - "40c70f8b 410409c7 c0967e9c 41187e15 -> 40c70f8b 410409c7", - "4179e52f 41b5f6d0 c0f420ac 40d6e807 -> 40d6e807 40d6e807", - "40c062d4 40c1d1ac c18656e2 41b70939 -> 40c062d4 40c1d1ac", - "40951ecd 409527c3 c080c9b8 4114ac1c -> 40951ecd 409527c3", - "4138f6aa 413983de c11e4c88 4177c8d3 -> 4138f6aa 413983de", - "412981f9 412b047f c0b86610 3e1ca474 -> 3e1ca474 3e1ca474", - "c0033ce4 c003218c c1c70e36 40cb378e -> c0033ce4 c003218c", - "40f4a639 410935a4 c18cd45f 41b4aac4 -> 40f4a639 410935a4", - "c199cc1a c199c9b8 c18dcf47 41b491f9 -> c18dcf47 c18dcf47", - "4129080f 4129f041 c118a4bc 419b960d -> 4129080f 4129f041", - "40c3bde6 40c3c1da c1a4db7a 41a33262 -> 40c3bde6 40c3c1da", - "c18eb4b7 c1898361 c141ac1a 40f72088 -> c141ac1a c141ac1a", - "414e2cb4 41509dbc c1b964f9 414dd8b1 -> 414dd8b1 414dd8b1", - "c18ab76a c18a3472 bfbafc30 400984b4 -> bfbafc30 bfbafc30", - "c186cfb6 c17c8670 bfd81450 4193036e -> bfd81450 bfd81450", - "419502d8 4195239c c12da6b8 41ab6d61 -> 419502d8 4195239c", - "c12a1ca9 c129e60f c026bfa8 41214e89 -> c026bfa8 c026bfa8", - "41646d2a 41989373 c11d417d 40befd8d -> 40befd8d 40befd8d", - "416e3268 4181ee24 bf563220 417bb26e -> 416e3268 417bb26e", - "c0c50d72 be9aa858 bfb35300 41894251 -> bfb35300 be9aa858", - "410fef0b 4114c15d c164037e 3fd35dff -> 3fd35dff 3fd35dff", - "4106ccec 4113b120 c0832e1c 41374ad7 -> 4106ccec 4113b120", - "c1122227 c1121dd1 c0976074 41bfcfbd -> c0976074 c0976074", - "405b229c 40c1157a c09657e0 40a9b027 -> 405b229c 40a9b027", - "40356ebb 4035aee5 c1275a64 417ee03e -> 40356ebb 4035aee5", - "416aabe8 416aad68 c1732e00 41b19409 -> 416aabe8 416aad68", - "c19c627e c1908328 c115cbe6 40c0ca70 -> c115cbe6 c115cbe6", - "40722665 4072621b c1055216 405dafde -> 405dafde 405dafde", - "41678a1c 41679114 c1c6b822 40d80975 -> 40d80975 40d80975", - "c19ca737 c19c6695 c1acb651 41354095 -> c19ca737 c19c6695", - "4063336e 40642fe2 c1adaebd 418e5eff -> 4063336e 40642fe2", - "c1712405 c16e5dd5 c117cb49 3e140be4 -> c117cb49 c117cb49", - "c19dce77 c19912a5 c1bc55f1 402113dd -> c19dce77 c19912a5", - "c0a405b5 c0a3e9b3 c0904e90 417671c4 -> c0904e90 c0904e90", - "c0fc0142 c0fa5cc2 c1c0c25c 41b1480f -> c0fc0142 c0fa5cc2", - "c15d1713 c15b9439 c05a3f48 41bfdefb -> c05a3f48 c05a3f48", - "3fb56b0b 3fd2d135 c1b48c82 4114d13b -> 3fb56b0b 3fd2d135", - "4170d19c 4171a3bc c19fbfa7 3fe3863f -> 3fe3863f 3fe3863f", - "c14b6f6b c14b6d9f c1be59c2 412ba6a9 -> c14b6f6b c14b6d9f", - "4198e6e0 419aea78 c0bdfeb4 4118d16f -> 4118d16f 4118d16f", - "c138301c c1362e14 c19aa70c 41a80af0 -> c138301c c1362e14", - "c11dfa99 c11ce599 c0baad40 415e031c -> c0baad40 c0baad40", - "c03c4882 c03bb5fe bf57c940 413b82f0 -> bf57c940 bf57c940", - "bfba66b5 bfba2c6b c18c84f2 41c6c805 -> bfba66b5 bfba2c6b", - "403d4db5 403d599b c1a54a2e 4135439d -> 403d4db5 403d599b", - "40015870 40017510 c1ae3a3e 413ce3f9 -> 40015870 40017510", - "c00c1d54 40ce28d2 c00257d8 40c2bb20 -> c00257d8 40c2bb20", - "c11a9db5 c11a78ff c111f114 41796d4d -> c111f114 c111f114", - "41316e69 41346a83 c102f274 4156668e -> 41316e69 41346a83", - "c0a89455 c0a89343 c0ebb7f8 41c274b3 -> c0a89455 c0a89343", - "418193b1 4181fcff bfae7710 4142a6b2 -> 4142a6b2 4142a6b2", - "403330bd 40509b03 c11d0178 41ba6bd6 -> 403330bd 40509b03", - "4153e44a 4153e50e c067b9a0 41a1bf23 -> 4153e44a 4153e50e", - "3e872c37 3e88f9c9 c086cd3c 41c10f8a -> 3e872c37 3e88f9c9", - "bf29607b bd8df228 c18e971b 40d56d37 -> bf29607b bd8df228", - "40bc200d 40bd7293 c18cb2e6 3f66e0e0 -> 3f66e0e0 3f66e0e0", - "412340b1 412355df c0f8a1b4 41a1e434 -> 412340b1 412355df", - "40319fa0 405aa970 c115c1c8 415c3ac4 -> 40319fa0 405aa970", - "bfa9a330 bfa981f0 c134f6d2 3e550b4b -> bfa9a330 bfa981f0", - "c0fec5b5 c0f99187 c0259fc8 41a42329 -> c0259fc8 c0259fc8", - "c1116602 bf08a9e0 c16b115a 40a358ea -> c1116602 bf08a9e0", - "3f3c2838 4005c8b2 c1b09d88 413c16c1 -> 3f3c2838 4005c8b2", - "414bc019 41514167 c1bef8ec 417583e0 -> 414bc019 41514167", - "411720e4 411760c0 c1870ac2 4118ee9f -> 411720e4 411760c0", - "c13eee46 c1068c5c c0d6d0b8 40ba6b9d -> c0d6d0b8 c0d6d0b8", - "c1961087 c18e3e7d c1810f04 3fdefade -> c1810f04 c1810f04", - "c0368d10 c0365670 c183a124 40f44c44 -> c0368d10 c0365670", - "411d13e1 4131f877 c107134a 41a9b9c9 -> 411d13e1 4131f877", - "4164f70c 41654efc c034b8c8 41843645 -> 4164f70c 41654efc", - "c1790521 c17903f1 c147b26a 41b9bf33 -> c147b26a c147b26a", - "c12f80a9 c12f7b91 bea90200 41ae039f -> bea90200 bea90200", - "410a686a 410a68e2 c0949b80 3f353239 -> 3f353239 3f353239", - "4170f16d 4170f42b c0bdeb00 411d6f50 -> 411d6f50 411d6f50", - "41829c54 41844590 c0b21090 4168aeae -> 4168aeae 4168aeae", - "40a885ba 40a8b00e c0b3a388 40b8934c -> 40a885ba 40a8b00e", - "bf9827f1 bd3e69e0 c0e93a34 41c7e5a2 -> bf9827f1 bd3e69e0", - "c191992d c1919735 c0c36404 40d7fa1b -> c0c36404 c0c36404", - "3ffa7356 400a8e25 c191b746 40756fbf -> 3ffa7356 400a8e25", - "c0857213 c048d5ca c1c68db0 41a4db1c -> c0857213 c048d5ca", - "4146fa0c 41476694 c1815106 4126c3e1 -> 4126c3e1 4126c3e1", - "bec66eb5 bec48a4b c164719e 416e994b -> bec66eb5 bec48a4b", - "c18ca018 c18c9b94 bfc6cce0 409ba747 -> bfc6cce0 bfc6cce0", - "40f1cb06 40f1e692 c1c221ee 4199a6f1 -> 40f1cb06 40f1e692", - "c0ea7125 c0ea5ecb c15e548a 4125b260 -> c0ea7125 c0ea5ecb", - "c07991da 4097b8e5 c08bf50c 414fe6d1 -> c07991da 4097b8e5", - "c11c8b3f c11bb39d c1514879 40aa339c -> c11c8b3f c11bb39d", - "417b2ae2 417cf246 bec0c540 402ccfbd -> 402ccfbd 402ccfbd", - "40555e28 4112a0d6 c0b79f04 406b56b3 -> 40555e28 406b56b3", - "419c8784 419c9438 c0cfb5d8 4088d0b6 -> 4088d0b6 4088d0b6", - "c0963357 c096305d bfc37b80 419b422f -> bfc37b80 bfc37b80", - "c11afc4d c119f647 c12796b3 40c4f0f9 -> c11afc4d c119f647", - "40ab7f75 40ac8c1b c082c728 405dc627 -> 405dc627 405dc627", - "c0b680ee c0b38d3e c1893fa4 41a4c8c2 -> c0b680ee c0b38d3e", - "40b4b104 40e3d704 c1a7d43d 41bd37af -> 40b4b104 40e3d704", - "41578269 41578757 c0eddfa0 41348c24 -> 41348c24 41348c24", - "c115a92e c0fe3075 c138a9fb 41932920 -> c115a92e c0fe3075", - "3dd8d0a0 402bc19b c0b0c6e8 41bfaa95 -> 3dd8d0a0 402bc19b", - "3f97cb57 3f981769 c1c1af06 411f6be5 -> 3f97cb57 3f981769", - "c190834b c19082ef c193c6b1 418af900 -> c190834b c19082ef", - "41943b43 41943e2d c128a800 411c4587 -> 411c4587 411c4587", - "4120e024 413c26b4 c0c873b4 3fca5af4 -> 3fca5af4 3fca5af4", - "4037df54 41047103 c14cff93 4078e8c4 -> 4037df54 4078e8c4", - "c148f8d5 c139fe1f c1852559 408537b0 -> c148f8d5 c139fe1f", - "c0690a91 c06749af c14aff32 412b81be -> c0690a91 c06749af", - "c19f6b4b c191f42d c0e6f44c 41966dab -> c0e6f44c c0e6f44c", - "40f7861a 4123203f c11c6d52 4008aabb -> 4008aabb 4008aabb", - "3f12a142 408ae0f8 c0b39530 41745423 -> 3f12a142 408ae0f8", - "40390768 403a65a8 bedb9100 41727401 -> 40390768 403a65a8", - "40b04c92 40b06a4e c10085fe 412efb43 -> 40b04c92 40b06a4e", - "c1865b44 c1862aa4 c1b4b742 416b53aa -> c1865b44 c1862aa4", - "c088d213 c084a0d9 c0bf7b58 41931492 -> c088d213 c084a0d9", - "4183fbbd 4194e723 be89b0c0 416057b0 -> 416057b0 416057b0", - "3fc32196 403e7325 c1033254 403cd363 -> 3fc32196 403cd363", - "3dc4f408 3fb968e0 c1056182 41b2e56f -> 3dc4f408 3fb968e0", - "c129bc97 c12664a3 c14744ed 4190d5f8 -> c129bc97 c12664a3", - "c165e1de c13f32be c126ca54 419256a7 -> c126ca54 c126ca54", - "4143d101 414acfcf c13c80bb 401bbb03 -> 401bbb03 401bbb03", - "4145a9e1 4145aaa7 c1825548 415b19af -> 4145a9e1 4145aaa7", - "411f3b42 411f3cf2 c180855a 402112b8 -> 402112b8 402112b8", - "c183b601 c1621dca c1aab18f 418b4517 -> c183b601 c1621dca", - "41884d78 41884fe4 c1bd1616 419409d2 -> 41884d78 41884fe4", - "412b462f 414d0621 c1b6a298 41a24ff5 -> 412b462f 414d0621", - "40accfc6 40c77e1a c19ffd2e 412690d7 -> 40accfc6 40c77e1a", - "41976b6c 41977a4c c16915e6 414f39c2 -> 414f39c2 414f39c2", - "c1930f99 c1930f4f bff348f0 40a89900 -> bff348f0 bff348f0", - "c0ff9ca6 c0a36abe c0c66570 41487ac4 -> c0c66570 c0a36abe", - "bf23b573 bf239a0d c17c50b8 411e8701 -> bf23b573 bf239a0d", - "bfa3f3d1 bf9b4f8f c0b27424 41118c12 -> bfa3f3d1 bf9b4f8f", - "3e2ae7e8 3f9db1e3 c0a16cd4 41bf45ec -> 3e2ae7e8 3f9db1e3", - "41410dad 415b4093 bfc75450 41bd51d0 -> 41410dad 415b4093", - "40aeb6f8 40bb0c20 c15b3d6a 3f1db462 -> 3f1db462 3f1db462", - "413eaa80 4183ddc8 c12a35e5 4116a004 -> 4116a004 4116a004", - "40ee2322 41103b83 c1bbf400 400dbfab -> 400dbfab 400dbfab", - "41798558 41a2f4c8 c17ffca9 3f59ea16 -> 3f59ea16 3f59ea16", - "bfc2eb5a bfbb6fc6 c194c3e7 4185f1ef -> bfc2eb5a bfbb6fc6", - "bea24df7 bd094848 c18373ba 3ffe92d3 -> bea24df7 bd094848", - "c1a3bd10 c1979a9a c021b6f0 40863d62 -> c021b6f0 c021b6f0", - "403cda9e 403e2502 c0f33d64 409e154f -> 403cda9e 403e2502", - "c1a1a0fc c147f2a1 c12c39fc 4177a77d -> c12c39fc c12c39fc", - "c0277023 c00bb47d c10d8522 415cd6da -> c0277023 c00bb47d", - "c02695ec 40d2bd5e c0f78228 417bcbd5 -> c02695ec 40d2bd5e", - "3db31e6a 3eba5966 c16a4697 4168ae33 -> 3db31e6a 3eba5966", - "c020d848 bfecf4af c14a8498 40d6fec5 -> c020d848 bfecf4af", - "405dc69d 405dea73 c15b9bb6 41be2956 -> 405dc69d 405dea73", - "c0a0d4cd c0a09937 c1c486f8 3ef0ca72 -> c0a0d4cd c0a09937", - "c1957c64 c1956646 c09df7e4 40c3d3a6 -> c09df7e4 c09df7e4", - "c174b05c c153c880 bd87d200 41c26fb4 -> bd87d200 bd87d200", - "c0b32c32 c0a2f7da c1226282 41930f38 -> c0b32c32 c0a2f7da", - "4180f7fc 41839ebc c1b00302 41493014 -> 41493014 41493014", - "419e7def 41a17049 c12a6f77 40ff2667 -> 40ff2667 40ff2667", - "c0481e97 c047df69 c0de1db4 41a1f881 -> c0481e97 c047df69", - "41957446 4195904a c11b9f2e 41a4a6fc -> 41957446 4195904a", - "3f7e6f7a 3f8f1443 c1970fa9 3fd8873e -> 3f7e6f7a 3f8f1443", - "41054d98 41077f08 c1405b7b 4064f9d9 -> 4064f9d9 4064f9d9", - "c146772c c14631c0 c14d8e67 41809a3d -> c146772c c14631c0", - "40f435f9 40f4bb07 c19cee16 418ce8d8 -> 40f435f9 40f4bb07", - "c1581265 c14e28ef c17f5ed1 41b0843f -> c1581265 c14e28ef", - "c1869c3f c13548bd bf9d11b0 41843d0c -> bf9d11b0 bf9d11b0", - "413c8382 41417b86 c12139d6 418f2722 -> 413c8382 41417b86", - "4031b314 413f80e3 c1907c84 418f3c28 -> 4031b314 413f80e3", - "c11eed7c c11eea72 c15daf91 41958b84 -> c11eed7c c11eea72", - "be317752 be0598ae c1c2f0c1 40dfd353 -> be317752 be0598ae", - "c18371df c10c599f c1896d92 415d9fca -> c18371df c10c599f", - "c152bcad c10a8627 c114d275 41c3f313 -> c114d275 c10a8627", - "c17eccad c17ecc2d c1101c73 40a70bc5 -> c1101c73 c1101c73", - "c18cc046 c1893e8c c101e9a8 41675ac0 -> c101e9a8 c101e9a8", - "40d558a6 40d7fe22 c1922766 3e9422a3 -> 3e9422a3 3e9422a3", - "c19a6979 c1921921 c1587bcf 409df059 -> c1587bcf c1587bcf", - "c159f893 c14ea705 c173780c 414ec343 -> c159f893 c14ea705", - "419ebe28 419eeac4 c19e54bd 4180c070 -> 4180c070 4180c070", - "4115303e 4115314a c0f1e8ac 4088f831 -> 4088f831 4088f831", - "40acd66b 40ad256d c1626105 41ad81d2 -> 40acd66b 40ad256d", - "c189eef5 c188f557 c11a71f7 41854d69 -> c11a71f7 c11a71f7", - "c0bc35c1 c0bc33f3 c10bc86c 41515431 -> c0bc35c1 c0bc33f3", - "bf90d977 3f8540f7 c1b7ff44 41b68a4b -> bf90d977 3f8540f7", - "c11b6e09 c11b6d8f c196225b 4118a693 -> c11b6e09 c11b6d8f", - "3f38af1f 3f38c7e1 c175ae55 4136e1d5 -> 3f38af1f 3f38c7e1", - "3fca950e 3fcaa0d2 bed46dc0 417db36e -> 3fca950e 3fcaa0d2", - "40f36075 4189362f c151b898 41c4c49c -> 40f36075 4189362f", - "c1964afb c1960729 bfb5a4c0 40d8af23 -> bfb5a4c0 bfb5a4c0", - "c1606f1d c1604559 bfbc81e0 41254e5a -> bfbc81e0 bfbc81e0", - "c14e1177 c13f6dd9 c078dd40 401f342a -> c078dd40 c078dd40", - "c1828bd7 c1621609 c1c46464 404e4f94 -> c1828bd7 c1621609", - "c08fe80c c08fcf68 c1755a81 418fe089 -> c08fe80c c08fcf68", - "4154befb 4154ce8d c10abb3c 414fe2a9 -> 414fe2a9 414fe2a9", - "c1bb1a1c c17ba458 c186683c 41bfe384 -> c186683c c17ba458", - "3fb2bc18 4114e6b5 c064b878 410ecccf -> 3fb2bc18 410ecccf", - "4067584b 40752395 c14af879 41c6f8e5 -> 4067584b 40752395", - "4183498b 418c2d4d c0bd6608 41ab16e8 -> 4183498b 418c2d4d", - "c18ed0ea c182b2dc c1a190d2 419126fa -> c18ed0ea c182b2dc", - "c11298bb c1128dab c1846ff1 4186502c -> c11298bb c1128dab", - "c189ba73 c175814f c196abf4 414d86ff -> c189ba73 c175814f", - "40824a0a 4095a3f6 c1a9b982 418ef3c9 -> 40824a0a 4095a3f6", - "41606dee 4160a3a2 c1940a61 408a14eb -> 408a14eb 408a14eb", - "c1a8c9ac c1500c8c c0b06a30 40a7db37 -> c0b06a30 c0b06a30", - "418b29f7 418b6205 c1456ca3 4135135b -> 4135135b 4135135b", - "c09f72fb c09f71e9 c19f0b31 4167616f -> c09f72fb c09f71e9", - "3fa2f33d 3fa8bec3 c10d4c94 41c747a5 -> 3fa2f33d 3fa8bec3", - "c189b8b2 c14e12ac c19640ac 4190f3d9 -> c189b8b2 c14e12ac", - "40aee670 40b50690 c055b018 419bdd63 -> 40aee670 40b50690", - "411512f5 41152843 c0c9e0c0 41a759ab -> 411512f5 41152843", - "3e672aa8 3f800a6b c1ab31d9 41484189 -> 3e672aa8 3f800a6b", - "3ff6fc70 40013d68 c0aea074 4011939f -> 3ff6fc70 40013d68", - "c1ae89df c15a7f5a c0a79314 419cb40f -> c0a79314 c0a79314", - "411dcaa3 41486c9d c18cc5f2 3fdf6d06 -> 3fdf6d06 3fdf6d06" - ] - }, - { - "glsl": "vec2 cultmath_iv_saturate(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "40bc1486 40c318aa -> 3f800000 3f800000", - "419a0e2e 419a0eae -> 3f800000 3f800000", - "c179e2f4 c179e084 -> 00000000 00000000", - "3fc89b82 40b6ab50 -> 3f800000 3f800000", - "c1508402 c14fc220 -> 00000000 00000000", - "3fab170a 3faca716 -> 3f800000 3f800000", - "c1764563 c17644f9 -> 00000000 00000000", - "bf78f6c9 bf619df7 -> 00000000 00000000", - "4117b12a 411b42da -> 3f800000 3f800000", - "418b912a 418c586e -> 3f800000 3f800000", - "417000f1 41754f77 -> 3f800000 3f800000", - "c1ab2523 c1823cd3 -> 00000000 00000000", - "411f2b2d 41202153 -> 3f800000 3f800000", - "418cbd4a 418cbe56 -> 3f800000 3f800000", - "c1689139 c1683a6f -> 00000000 00000000", - "418c0468 4190b918 -> 3f800000 3f800000", - "c0c2406c c0a378ac -> 00000000 00000000", - "c16d074e c16d0670 -> 00000000 00000000", - "c0b47325 c0ad5443 -> 00000000 00000000", - "41115a1b 4111740d -> 3f800000 3f800000", - "c1486a6c c148653a -> 00000000 00000000", - "c0dee8a4 c0dee7ac -> 00000000 00000000", - "c18dc2b9 c18db521 -> 00000000 00000000", - "41983fea 4198404e -> 3f800000 3f800000", - "3e61c21f 3e62c3e1 -> 3e61c21f 3e62c3e1", - "c19203ad c19202f3 -> 00000000 00000000", - "418e0a4b 419086f1 -> 3f800000 3f800000", - "c170b4bc c11b3ce0 -> 00000000 00000000", - "40b20bca 40b20d16 -> 3f800000 3f800000", - "c0dc2b86 c0da4a4a -> 00000000 00000000", - "c1367050 c13627e8 -> 00000000 00000000", - "413490ab 413a36bd -> 3f800000 3f800000", - "404d6895 408005fe -> 3f800000 3f800000", - "c18dc100 c18db8fa -> 00000000 00000000", - "416d092b 416d3835 -> 3f800000 3f800000", - "c12cada4 c12cacb8 -> 00000000 00000000", - "418d4ab1 418de7df -> 3f800000 3f800000", - "c06abff5 c05e310b -> 00000000 00000000", - "c09bcb44 c09bca4c -> 00000000 00000000", - "41761db1 4176402f -> 3f800000 3f800000", - "3ff25b0c 40902bad -> 3f800000 3f800000", - "403ea7c7 40fcae24 -> 3f800000 3f800000", - "c078ab20 c0193290 -> 00000000 00000000", - "41424e3d 41459023 -> 3f800000 3f800000", - "40879c1b 4087a2ed -> 3f800000 3f800000", - "c03e54db c03e1205 -> 00000000 00000000", - "c0cbdae8 c0cbd4e0 -> 00000000 00000000", - "c166f869 c15f306d -> 00000000 00000000", - "c02cad63 c024f50d -> 00000000 00000000", - "c04220ca c041f8d6 -> 00000000 00000000", - "c0f9ba0e c0f38b4e -> 00000000 00000000", - "c14904aa c1490376 -> 00000000 00000000", - "4170db8d 41b34f2e -> 3f800000 3f800000", - "c154bf36 c154a1f6 -> 00000000 00000000", - "c1083315 c107779b -> 00000000 00000000", - "4027ec87 403064c9 -> 3f800000 3f800000", - "c1834d83 c132f752 -> 00000000 00000000", - "419799bf 4197a315 -> 3f800000 3f800000", - "413abb35 415699c3 -> 3f800000 3f800000", - "c10c6e6c c102db9e -> 00000000 00000000", - "41977c6e 41978fd6 -> 3f800000 3f800000", - "4105ea55 410a3deb -> 3f800000 3f800000", - "418dbde8 41a980f0 -> 3f800000 3f800000", - "410d5477 41188a3d -> 3f800000 3f800000", - "c035f85b c0271365 -> 00000000 00000000", - "c1357d30 c12b289c -> 00000000 00000000", - "40645d06 406b51da -> 3f800000 3f800000", - "c1978fbe c16d5ab4 -> 00000000 00000000", - "40fbf2f5 40fd993b -> 3f800000 3f800000", - "419654e7 4196788d -> 3f800000 3f800000", - "40d59aa6 40d615ca -> 3f800000 3f800000", - "c0a14be1 c0a149f7 -> 00000000 00000000", - "4085538b 40a5d545 -> 3f800000 3f800000", - "c1552243 c154faa7 -> 00000000 00000000", - "c1499959 c136ed03 -> 00000000 00000000", - "41874a57 4187f85d -> 3f800000 3f800000", - "c0df6525 c0d85427 -> 00000000 00000000", - "c11a8b4a c0c0e7b8 -> 00000000 00000000", - "418e23eb 418e6451 -> 3f800000 3f800000", - "c17b6835 c17b6763 -> 00000000 00000000", - "c1240d89 c123e53d -> 00000000 00000000", - "418bfb71 418ced27 -> 3f800000 3f800000", - "c1039e51 c0e53e31 -> 00000000 00000000", - "c1956949 c194f905 -> 00000000 00000000", - "416a2db2 416a2e6e -> 3f800000 3f800000", - "40abda67 40abecf9 -> 3f800000 3f800000", - "416560ef 417eb6c1 -> 3f800000 3f800000", - "c183eebe c1838a4e -> 00000000 00000000", - "c199cce7 c1988cd1 -> 00000000 00000000", - "c189bfca c189be12 -> 00000000 00000000", - "411a2f7c 411a4250 -> 3f800000 3f800000", - "402dfbdd 4035e503 -> 3f800000 3f800000", - "411e726d 4120f183 -> 3f800000 3f800000", - "c095c680 bf1e4344 -> 00000000 00000000", - "c0fbbf1b c0fbb995 -> 00000000 00000000", - "41990502 41990702 -> 3f800000 3f800000", - "c08b765b bf52252a -> 00000000 00000000", - "c13d3ccd c13d33c9 -> 00000000 00000000", - "bee8d895 3e316d2a -> 00000000 3e316d2a", - "41213b36 413384ea -> 3f800000 3f800000", - "412a4215 412c41b3 -> 3f800000 3f800000", - "3f9f9f10 3f9fb130 -> 3f800000 3f800000", - "c14ed30e c14be34a -> 00000000 00000000", - "4104adf0 41051f28 -> 3f800000 3f800000", - "40387599 4063a0b7 -> 3f800000 3f800000", - "417a00a4 417a0e7c -> 3f800000 3f800000", - "c09afe2e bf425fd4 -> 00000000 00000000", - "c1107602 c0adad94 -> 00000000 00000000", - "41529230 4152a298 -> 3f800000 3f800000", - "4167bed6 416b492a -> 3f800000 3f800000", - "c0a4819d c0a47ea3 -> 00000000 00000000", - "c1261606 c121047a -> 00000000 00000000", - "c188c147 c188a22b -> 00000000 00000000", - "411f4b71 41874a0f -> 3f800000 3f800000", - "40996f4a 40c1a486 -> 3f800000 3f800000", - "c192afb8 c192ab8c -> 00000000 00000000", - "416e6eb2 416e76ae -> 3f800000 3f800000", - "c0538dd3 c053872d -> 00000000 00000000", - "4140bd2f 4140f151 -> 3f800000 3f800000", - "c01b766f c01b7171 -> 00000000 00000000", - "4169229a 419f42db -> 3f800000 3f800000", - "c0cbf4e4 c0ca65d0 -> 00000000 00000000", - "c111c9d6 c10e1b22 -> 00000000 00000000", - "412b3abd 412bd13f -> 3f800000 3f800000", - "40676d7e 40679d52 -> 3f800000 3f800000", - "c01b194e c01b0ce2 -> 00000000 00000000", - "417c9fef 417ca131 -> 3f800000 3f800000", - "c01f58ff c0133691 -> 00000000 00000000", - "c0b70a60 c0894cc8 -> 00000000 00000000", - "c189d643 c185b20d -> 00000000 00000000", - "4146d8f2 414ecade -> 3f800000 3f800000", - "415caa1b 4166d605 -> 3f800000 3f800000", - "410e59b5 41109547 -> 3f800000 3f800000", - "c02afad0 c02aeef0 -> 00000000 00000000", - "3e466470 3e476390 -> 3e466470 3e476390", - "c179b369 c179866f -> 00000000 00000000", - "416e7369 4179880f -> 3f800000 3f800000", - "411836c9 41186e0f -> 3f800000 3f800000", - "412a8af4 41300594 -> 3f800000 3f800000", - "c0402463 c03f7fbd -> 00000000 00000000", - "40d75ffd 40d781ab -> 3f800000 3f800000", - "c09c3612 c09c0bce -> 00000000 00000000", - "c0bb26d8 c06e0170 -> 00000000 00000000", - "c0b649a7 c09e31c5 -> 00000000 00000000", - "41463edc 41508d54 -> 3f800000 3f800000", - "40ca3f2d 4156c3da -> 3f800000 3f800000", - "c0cafb3d c0c1440f -> 00000000 00000000", - "c10ce379 c10cdfbf -> 00000000 00000000", - "c182a652 c182027c -> 00000000 00000000", - "414731bf 4149ea79 -> 3f800000 3f800000", - "c127afc3 c12628b5 -> 00000000 00000000", - "c19d6b0f c19d5835 -> 00000000 00000000", - "c14ad600 c14ad56a -> 00000000 00000000", - "c1035fea c1035e28 -> 00000000 00000000", - "c0b4325f c0b43169 -> 00000000 00000000", - "4174883f 417807d9 -> 3f800000 3f800000", - "c0785b4c c0692074 -> 00000000 00000000", - "c188473f c1880abb -> 00000000 00000000", - "c0b2456a c0b1220e -> 00000000 00000000", - "c0b8aa75 c073d05d -> 00000000 00000000", - "c119ea0a c116cc92 -> 00000000 00000000", - "c0c2e7fa c0b24b2a -> 00000000 00000000", - "bffba88f bffb9831 -> 00000000 00000000", - "c18bdfaf c18bddf7 -> 00000000 00000000", - "beff1dbb bee38d45 -> 00000000 00000000", - "c0d560b0 c0d55960 -> 00000000 00000000", - "41759830 418112f4 -> 3f800000 3f800000", - "c158ce39 c158cd47 -> 00000000 00000000", - "c13a2270 c04ca060 -> 00000000 00000000", - "c159fe1c c159e750 -> 00000000 00000000", - "40358737 4035a149 -> 3f800000 3f800000", - "c0781d5a c0355156 -> 00000000 00000000", - "41714482 41714586 -> 3f800000 3f800000", - "401d82b9 402bd2f7 -> 3f800000 3f800000", - "408e883a 40a9b206 -> 3f800000 3f800000", - "4152f0e8 41543fd0 -> 3f800000 3f800000", - "c16f5753 c1102f9f -> 00000000 00000000", - "c095845b c092efbd -> 00000000 00000000", - "c1254ae1 c1254235 -> 00000000 00000000", - "418d6bb3 418d6c09 -> 3f800000 3f800000", - "4195e2d1 4195e38b -> 3f800000 3f800000", - "409e995e 40c3c4c2 -> 3f800000 3f800000", - "40e2a587 40ec2a09 -> 3f800000 3f800000", - "412e8677 4130b599 -> 3f800000 3f800000", - "3f0ff364 3f0ffa1c -> 3f0ff364 3f0ffa1c", - "c14d2fd4 c14d10c8 -> 00000000 00000000", - "c0bf0a34 c0bf0908 -> 00000000 00000000", - "c107f3db c107f355 -> 00000000 00000000", - "c125bc71 c124d4c5 -> 00000000 00000000", - "416a3aa5 416a5853 -> 3f800000 3f800000", - "4040a8ee 40414012 -> 3f800000 3f800000", - "401661bc 402b3304 -> 3f800000 3f800000", - "41057145 410e85e3 -> 3f800000 3f800000", - "4188facd 41b0790f -> 3f800000 3f800000", - "c0880370 c085793c -> 00000000 00000000", - "415391eb 415392a5 -> 3f800000 3f800000", - "c1922656 c192258e -> 00000000 00000000", - "c0990487 c0985f3d -> 00000000 00000000", - "4080d0f4 4084221c -> 3f800000 3f800000", - "c17154da c1715182 -> 00000000 00000000", - "c12406ac c0ac9828 -> 00000000 00000000", - "c15d4227 c15b3fad -> 00000000 00000000", - "4087bbaa 40885566 -> 3f800000 3f800000", - "c12badec c12bab0c -> 00000000 00000000", - "40d605da 40d63b1e -> 3f800000 3f800000", - "c0d1ed92 c0c8c732 -> 00000000 00000000", - "c082583f c08014cd -> 00000000 00000000", - "bfa8a7a2 bf9f02de -> 00000000 00000000", - "bf01a570 4088e97e -> 00000000 3f800000", - "c192b198 c15dedb3 -> 00000000 00000000", - "40ee2452 410f356f -> 3f800000 3f800000", - "c150cd5a c105dae0 -> 00000000 00000000", - "c15230ec c1522f18 -> 00000000 00000000", - "c0d639c3 c0d62d8d -> 00000000 00000000", - "40aad1b4 40d649cc -> 3f800000 3f800000", - "c052af6d c048b383 -> 00000000 00000000", - "c041ce38 c0310468 -> 00000000 00000000", - "c18afe69 c189c0eb -> 00000000 00000000", - "c151bd27 c0fd72a6 -> 00000000 00000000", - "c1813b85 c1813763 -> 00000000 00000000", - "3e0339a8 3fb28ceb -> 3e0339a8 3f800000", - "c1124e24 c1124d8c -> 00000000 00000000", - "c1262bc9 c12629bf -> 00000000 00000000", - "40c03037 40c0eed9 -> 3f800000 3f800000", - "40ac8935 40ce8cc3 -> 3f800000 3f800000", - "41839134 418546d8 -> 3f800000 3f800000", - "3e696628 3e6a57d8 -> 3e696628 3e6a57d8", - "bf6a39f9 bf649447 -> 00000000 00000000", - "41032f7b 410334bd -> 3f800000 3f800000", - "c0055403 c003c9bd -> 00000000 00000000", - "c19fa29e c1248af6 -> 00000000 00000000", - "bd3fac20 3fc678e1 -> 00000000 3f800000", - "418c781e 418f06d2 -> 3f800000 3f800000", - "c11a42fa c1143a74 -> 00000000 00000000", - "bf1ca7b4 3f4c9ff4 -> 00000000 3f4c9ff4", - "c0d0b223 c0cd56e9 -> 00000000 00000000", - "414d4bda 4165a646 -> 3f800000 3f800000", - "c09c3f5b c00f726a -> 00000000 00000000", - "40249dba 4024ae26 -> 3f800000 3f800000", - "40f803b0 40f804e0 -> 3f800000 3f800000", - "bfe74dd8 3e3024c4 -> 00000000 3e3024c4", - "4027ddef 4089bc89 -> 3f800000 3f800000", - "4181beb5 41867067 -> 3f800000 3f800000", - "c16af231 c16aec17 -> 00000000 00000000", - "c13cb78d c13b2347 -> 00000000 00000000", - "418a9661 418a969f -> 3f800000 3f800000", - "be8aefc6 be151c74 -> 00000000 00000000", - "c1676dcb c166c707 -> 00000000 00000000", - "c0fdff3b c0fd8a8d -> 00000000 00000000", - "c183ab53 c183455d -> 00000000 00000000", - "414a7f03 418b2a87 -> 3f800000 3f800000", - "4191cbd9 419ba813 -> 3f800000 3f800000", - "bfa9036a bfa88f96 -> 00000000 00000000", - "414ef720 415283f0 -> 3f800000 3f800000", - "4133bcd3 413536dd -> 3f800000 3f800000", - "41814688 41818afc -> 3f800000 3f800000" - ] - }, - { - "glsl": "vec2 cultmath_iv_smoothstep(float, float, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c13cd084 412662c3 419ef0b8 419ef4f0 -> 3f7fffff 3f800000", - "c16bccd3 4186bbaf 4188ec18 4188ede8 -> 3f7fffff 3f800000", - "c12cc9ff 3f39e923 bfa4f840 40002c40 -> 3f6b42d5 3f800000", - "c02510f8 4101246e c17a05b7 c17a0091 -> 00000000 00000001", - "c0f1ee68 41b1cccc 40538010 405387b0 -> 3e9aae73 3e9ab14d", - "c1b1cb87 4076f26a c15c315b c15b5961 -> 3e7d6bb8 3e8012e2", - "c032c390 4199afa1 c09db187 c09a6071 -> 00000000 00000001", - "bfe7e270 41397a24 bff9f51b bfeb08e5 -> 00000000 00000001", - "c0f46ecc 412b4f53 bf00907f bf008041 -> 3eac26a6 3eac292f", - "c116ba06 41af3c0e c179c720 c1779138 -> 00000000 00000001", - "c146de94 41b3fa31 4190018e 419daf9e -> 3f745d21 3f7b5f33", - "c1658247 3fd82143 4186d27c 4186d390 -> 3f7fffff 3f800000", - "c19fefa8 4172804e 418b4141 41a297b7 -> 3f7fffff 3f800000", - "c1c5eadc 419a2958 c08811e3 c087d56d -> 3ee58fca 3ee5b09e", - "c19420f1 4134ebde c0a34b23 c09e197d -> 3ed9897e 3eddadd5", - "c18ce2e9 4101e988 c1187e47 c1187ceb -> 3e6f8416 3e6f8876", - "c1296f83 41b31e84 c13a6730 c13a0d00 -> 00000000 00000001", - "c083ac7c 3f436876 404ea87a 4090467b -> 3f7fffff 3f800000", - "c0b1f598 41bee8c1 40a75e08 40a76758 -> 3e9c1578 3e9c1c8a", - "c1a36911 40f801e1 c17e84fd c16a34cb -> 3d8d2163 3ddfc899", - "c074a218 40bb22bb c078fa89 c078b857 -> 00000000 00000001", - "c14b2d77 415fdb87 400298dd 40c629a2 -> 3f13fcf0 3f4b3421", - "c1c11a44 40361f2d 414c73f5 414c76e3 -> 3f7fffff 3f800000", - "c147502a 413bc079 c0d6669e c0d66042 -> 3e126022 3e12694a", - "c110bd1e 41ad6970 c113709b c112b84f -> 00000000 00000001", - "c0625e28 41351b58 c0f4c913 c0f4c349 -> 00000000 00000001", - "c1c617f0 40705bb5 c1761e38 c1761d70 -> 3e81b94a 3e81ba76", - "c1abfe13 40921e95 c1729e88 c1195170 -> 3e181398 3edf32f0", - "c1852d09 415d7d55 413cc6b3 413cc789 -> 3f7cb36d 3f7cb39b", - "bff9a3f0 41bc170e 408fb6f1 408fb7ef -> 3e2373d1 3e23753c", - "c18d76b5 40e44b8e c035bfda c01bcd66 -> 3f252fc4 3f2b2d04", - "c19dc96e 412a5611 c0e6d857 c0e6bbe1 -> 3ebd0bfd 3ebd21cc", - "c1172f6b 413516f3 403ab87d 403af6b3 -> 3f2438a4 3f2449f8", - "c1c00923 416b0541 4193deca 4193f1fa -> 3f7fffff 3f800000", - "bfef85a0 40ba67bc c0f10a85 c0f0e097 -> 00000000 00000001", - "c15e51d5 415ad1ab 4126fb82 41440b16 -> 3f7639f3 3f7e05f7", - "bff5e9b0 41ae061c 412b90f9 4181be33 -> 3f0d11c3 3f5c8fc5", - "c1023bfa 40d8b03b c11e961f c119a8a9 -> 00000000 00000001", - "c1950b3a 40cabc7f c1284c94 c1271fe4 -> 3e7e0f2d 3e810400", - "c1c442d0 416ae01b 4192758d 41931f4b -> 3f7fffff 3f800000", - "c08793d4 41a17451 c03223a0 c020a6a0 -> 3c273673 3c6a2abd", - "c11c2264 41aef502 4180e2d3 418535e5 -> 3f69a0f4 3f6d64ac", - "c1236526 41204053 c16ade73 c1666981 -> 00000000 00000001", - "c1148528 40d85b70 4028a843 404ae1fd -> 3f55eaa3 3f5f4385", - "c1474c48 4168e4ca 413ef450 413f0910 -> 3f793c66 3f7942de", - "c1245e1d 4114ae56 40ab1e1b 40ab4ccd -> 3f64f8f1 3f650b61", - "c1a0aab7 41af0e75 c18fdda4 c1890670 -> 3bedfb96 3c684d52", - "c182146d 411b9fcc c09f41a9 c09f198f -> 3ecdc0f4 3ecde558", - "c1912494 41919c9a 3ec0570e 3f075579 -> 3f03a8b8 3f05464a", - "c1b15b44 401a14a2 c12502a5 c12501ef -> 3ef280a0 3ef28205", - "bf7c33c0 40104e04 c0b7bdde c0b7aab6 -> 00000000 00000001", - "c1ad20b3 4162d4bd c1ab515d c1510a52 -> 38f9f2c5 3e13ffdc", - "c0ff511c 4144ed2f c18936ce c18917a4 -> 00000000 00000001", - "c0a8fe24 41771c1a 419e3262 419e5ab2 -> 3f7fffff 3f800000", - "c1a54c0a 40043eee bf1be6a0 be0e887f -> 3f7631b5 3f793c6c", - "c0950ee0 4044ffe2 c083e5bb c083dd4d -> 3c614600 3c621e26", - "c1c300b7 419fb52a c0a02948 bfe8e001 -> 3ecfc629 3f035913", - "c0c0af9c 41bb20a1 40a9529f 40a9a9d9 -> 3ea8f735 3ea93a9b", - "c183fce4 41960334 c099a5ce c098a60a -> 3e83b70c 3e845198", - "c1c4f4aa 410ffd00 c1365cef c1341d19 -> 3eaf49bd 3eb25be8", - "c09afa04 3ff5acf8 c185f5d7 c16cfa9e -> 00000000 00000001", - "c1887797 41bbd615 3fefa56b 4004170a -> 3ee6ae8a 3eea4ca5", - "c0d53df0 3fa7ee2c bfbb5414 bfbb4f6c -> 3f38931b 3f3894b5", - "c11dbd2c 414b1de0 c1361d1a c11d7bd6 -> 00000000 35c95189", - "c0f56c0c 4076726b c120ce60 c120bad0 -> 00000000 00000001", - "c1a98608 4086b08f c134228d c12b9e9f -> 3eada327 3ebd1a57", - "c0602910 41853035 c1812711 c18126bf -> 00000000 00000001", - "c1988406 414649cb c035c5e2 bfd5f23c -> 3f060bfa 3f143d66", - "c056a888 41ac3640 41870eec 418aed68 -> 3f689238 3f6ceb1f", - "c1c47c08 4157df90 41764307 41764421 -> 3f7fffff 3f800000", - "c19621f8 4197a307 c157ba4c c15243bc -> 3d5a92a3 3d76162f", - "c1531c5b 4170bdb6 41344621 414b7903 -> 3f737941 3f7b100f", - "c141d9cb 4159275c 413371df 4153cf69 -> 3f79ee3a 3f7fdf0f", - "c1b1c410 41b032cc bf7d3772 bf559ace -> 3ef08a33 3ef338db", - "c06d7808 411021d8 419e700a 419fe386 -> 3f7fffff 3f800000", - "c07b8cd0 414c33c0 c04f2dfe c04f14b2 -> 3ba4dd88 3ba5970c", - "c11c734e 4181f959 c15acd93 c152593d -> 00000000 00000001", - "c1281fd3 41471d43 414cb9c5 414cbc2b -> 3f7fffff 3f800000", - "c19226d0 4082656e c1845c9c c1844974 -> 3c8abda8 3c8c359e", - "c1c7c42b 414f6936 c1114cbb c11144bd -> 3ec23dee 3ec247c8", - "c0562d48 40d34e0b 3f48d21e 3f8a6b91 -> 3ebf7bf9 3ed5f356", - "c0f7f538 4168f700 40794e38 4144b636 -> 3f086bf9 3f789d37", - "c1767566 40e825f9 41750f3e 41782702 -> 3f7fffff 3f800000", - "c13714aa 40ba73a6 c1286bb8 c120824c -> 3c05784e 3c9b12ed", - "c1842e5e 41b9e4b1 c185e18e c17710f3 -> 00000000 3b0eb3ee", - "c161262a 3fb0ab36 c11e5994 c11e5914 -> 3e37dd73 3e37dfe8", - "c0dd9b00 41826cff 3f6cbc74 40cdccea -> 3e87e65b 3f1c95f5", - "c0a4653c 4004d00c 40aef6d1 40af1cb7 -> 3f7fffff 3f800000", - "c1b68859 4193de1a 413625cb 41376621 -> 3f6be86f 3f6c51fa", - "bea411c0 4190e919 3ff41567 3ff419d9 -> 3d24f176 3d24f662", - "bfa802e0 408fe734 c0b24c5a c0b23566 -> 00000000 00000001", - "c11b03b1 40821d86 408e62d1 408e640f -> 3f7fffff 3f800000", - "c0000ba0 410b0fe8 c18e5e24 c18e5dac -> 00000000 00000001", - "c167b485 41344196 414450dc 41567624 -> 3f7fffff 3f800000", - "c1c5b093 414a4b5e 4196e4b7 4196e509 -> 3f7fffff 3f800000", - "be742c80 4196d6f3 c146351c c1462808 -> 00000000 00000001", - "c10aa010 415ce82c 4011dc46 4054144a -> 3ef603ae 3f0cab3f", - "c15d01e7 4184dfed 41201c0c 4122004c -> 3f610f64 3f62115f", - "c1774879 3fe4404a 416fe48b 416fec75 -> 3f7fffff 3f800000", - "c0f46ca8 41c09d7d c074e956 c070db6a -> 3d234223 3d287c72", - "c1bfd28b 415e4f27 c1970b1d c196e7fd -> 3d4aa188 3d4beddf", - "c1c26b4d 416204c4 418354cd 41848d47 -> 3f7fffff 3f800000", - "c00287f0 41c2ee39 402af4a6 402c971a -> 3dac47d4 3dae06bf", - "c0c597d0 414be675 c1947bd7 c19479f1 -> 00000000 00000001", - "be85e940 3fbfa917 40ae2996 40ae2b3a -> 3f7fffff 3f800000", - "c122e809 41a1a7fa 40630026 40631f3a -> 3edb1202 3edb1e2d", - "c12198f5 4130398a 40f2febb 40f32c7d -> 3f6e0576 3f6e1396", - "c129afbc 416177f4 c1757763 c17576ab -> 00000000 00000001", - "c1b3e0a2 41247a5d 419efdec 419f1c74 -> 3f7fffff 3f800000", - "c0db3454 4194b2b5 c11151db c11150b9 -> 00000000 00000001", - "c1100521 41baa489 4175ec06 41764ac2 -> 3f591655 3f594a7e", - "c1b48b89 40d82990 41550b9c 4179b784 -> 3f7fffff 3f800000", - "c1c0ef2d 41884fca c115db4b c113796d -> 3e962ae4 3e98ba99", - "c1869924 4109f87f 4195a186 4195a482 -> 3f7fffff 3f800000", - "bf52b4e0 419a8569 415fd941 41613b4f -> 3f53c619 3f550ca9", - "c047c7f0 416129dc c18c881f c18c7bf5 -> 00000000 00000001", - "c062e4a8 414f730b c0989d72 c0987386 -> 00000000 00000001", - "c142ea07 4170863b bfa78367 bfa74bb9 -> 3eb3e27e 3eb3ee4a", - "c0aa701c 415b1214 c05284a5 c045d19b -> 3d02e281 3d1c729b", - "bff40950 40396331 c15ab503 c15aa395 -> 00000000 00000001", - "c1286371 41a392d7 c10ea8eb c0bea2ae -> 3bffd503 3d70ec31", - "c18ccec9 4140c112 4108ef74 41128aa0 -> 3f76334b 3f792f48", - "c15e9168 4198e2c2 c08702e4 3fd063ee -> 3e54d64d 3ee96b0d", - "c02bc408 41891eac c137850a c137840c -> 00000000 00000001", - "c04c5188 4153eb10 40917bdc 4093fc8c -> 3ee99b2d 3eed3ff2", - "c0310240 414fe340 c0b44c45 c0b3d313 -> 00000000 00000001", - "c19d262b 3f0aa3ca 41582c38 4164c8e0 -> 3f7fffff 3f800000", - "bff10620 40f679bf c108bffe c0d7cbf5 -> 00000000 00000001", - "c11a497f 4152042b c19d572a c19d56c4 -> 00000000 00000001", - "c1963bf8 40855985 c18d3818 c18d2880 -> 3be552b8 3be86122", - "c0a24638 417a0f1b 417a7575 4181a3e6 -> 3f7fffff 3f800000", - "c1ad429c 414d90e4 c0bba6c1 c0bba41f -> 3edf9903 3edf9ad3", - "c1851d8a 4109483f 4137bef0 4137e524 -> 3f7fffff 3f800000", - "c1478204 4167de6c c022bc4f c022b911 -> 3e9d1b76 3e9d1cd0", - "c158956d 41b00330 40e65341 40e66687 -> 3f1fbde3 3f1fc438", - "c1124b87 41bc6d41 4153d707 4153d8f9 -> 3f43a85a 3f43a998", - "c159c69e 41768f8d c0ce0dc4 c0cdd558 -> 3e1cb33f 3e1cf8ba", - "c10115f2 4079934f 414f5b74 4154c134 -> 3f7fffff 3f800000", - "c1539892 40beaa17 413423b4 41342c48 -> 3f7fffff 3f800000", - "c11767e3 41746aa6 c10255f4 c0fa8338 -> 3c065500 3c4d1276", - "c104b210 41954100 c00f9e0b c00a7255 -> 3e039f45 3e06d7ff", - "c13fa665 41b6fc2f c0c00746 c0c0060e -> 3da00f5f 3da01149", - "c1b64755 41bdccfd 407c854b 407cf7a5 -> 3f1c7b2e 3f1c899c", - "c14d5044 419ce5b8 410bd5bb 4129fb39 -> 3f3d057c 3f4ff12d", - "c0a4afcc 41988cb6 c104f6eb c10458d9 -> 00000000 00000001", - "c1a509d0 41c528bd c0426944 c0425c7c -> 3eabd593 3eabd8cb", - "c14200b7 400291a0 4187548f 418758c9 -> 3f7fffff 3f800000", - "c0a17524 4089c502 c05675bc bfcfc289 -> 3db16815 3e9b8d90", - "c1281a42 41c3ed20 40375400 40b3cad0 -> 3ea7197e 3ee1eac7", - "c1491c36 40c7a007 4091e4c5 4093825b -> 3f7a3e32 3f7a92dc", - "c192b72f 40f398df c110f1b6 c109efee -> 3e959851 3ea19f9a", - "c13118ef 4137c746 c1361259 c131bd3b -> 00000000 00000001", - "c1497c41 41b94b4e c00b8575 be5aaeb0 -> 3e51f6ec 3e8da089", - "c1885636 419c9ab4 3f645cb2 3f934247 -> 3ef82487 3efd8fc6", - "c1878f46 40d52d3e c18ac9ee c18aa9be -> 00000000 00000001", - "be4cfe80 400b53ec c1473cb6 c10a2136 -> 00000000 00000001", - "c143873a 41963eea 4138b33e 41393fc6 -> 3f5ca94e 3f5cf70f", - "c1a44f68 41aacf69 c0b6dcf6 c0b52c02 -> 3e92fa8d 3e93dd9c", - "c1aa5f59 41966b07 c1316a09 c10d773f -> 3e254d7f 3e6b0123", - "c0ea9004 418b283d 409b1c1d 409b1dab -> 3efa4033 3efa41b9", - "c05baae0 40bd20b3 41185dff 413ce5d1 -> 3f7fffff 3f800000", - "c0ee4b70 4167a284 3f2f937b 3fd30c22 -> 3e9f1631 3ebf4019", - "c15a5c26 41b8b6e6 40286144 4028789c -> 3ed47f30 3ed486b6", - "c1a363d8 408c45d5 3ff8ffd5 3ff919ab -> 3f79112c 3f79124a", - "c1ba631b 41110aa8 c13da118 c12c7ac0 -> 3e92d6db 3eaa8d86", - "c103d4ac 418e5cd3 3e7775dc 3ecefe12 -> 3e7f337e 3e83d5fc", - "c12c87fd 41b91810 41063dca 4107536e -> 3f18ea06 3f19ab05", - "c13b2431 41830b3b 4197abfc 4198c194 -> 3f7fffff 3f800000", - "c10de268 3e8bf609 4030cefc 40573004 -> 3f7fffff 3f800000", - "c187e81b 4111e3d5 c15b7a40 c11243fe -> 3d30ca9e 3e5dea68", - "c19b9743 41c675cf c18f0d6d c18f0993 -> 3b70c1c2 3b7153f9", - "c18e591a 404b45ba c1131722 bff0e62e -> 3ebbb9db 3f5a8028", - "c19f4f78 3fe4e796 4141657a 41417b06 -> 3f7fffff 3f800000", - "c15086d2 41a307e5 c0930cf0 c0930848 -> 3e22eda0 3e22f2b0", - "c0d954e8 4047010e c1042c27 c0efe285 -> 00000000 00000001", - "c0526b78 41c0976b c11e91c0 c10ec630 -> 00000000 00000001", - "bfa6b570 41bbe007 405ac41f 405ad001 -> 3dc28dfd 3dc29c2f", - "c1207d01 419e9ca8 41630d2b 41684f35 -> 3f681463 3f6a9c20", - "c1aa54f2 40e40215 404f20bd 405edc33 -> 3f72edc8 3f7474cf", - "c10877fa 40ca8ed6 c0bb2b53 c0baa709 -> 3dafdc5c 3db1d6f8", - "c12e6fa7 41938f7f c0aff742 c0af52a6 -> 3db6b5cd 3db7f9d2", - "c06b3ed0 417c9724 c16cc4e4 c1562228 -> 00000000 00000001", - "c115ad00 412a444d c19748e0 c19746ea -> 00000000 00000001", - "c1bba97d 412f0a64 c18ba786 c18ba37a -> 3da53f3d 3da55946", - "c0d9d1d0 40cb4874 c0f729b9 c0f6fc3f -> 00000000 00000001", - "c1375e24 40978e51 c0a1701a c0a113c6 -> 3eb15b4e 3eb1de42", - "c19d77f5 401e40c9 c142a98c c142a5be -> 3e88d173 3e88d8d7", - "c199c3fc 418d667c bea88f93 be9c666d -> 3f049db5 3f04dcf4", - "c0b7adbc 41ac481d c137d7a1 c137d5c9 -> 00000000 00000001", - "c11fed9f 41a0cad4 418eacf6 418eb4ca -> 3f7bde92 3f7be20d", - "c0a6af80 419710e2 3fed08ba 3fed20c6 -> 3e544e37 3e545826", - "c0bb59a4 41848eab 40af960e 40bb098a -> 3f023809 3f085775", - "c19bb80b 4101f51f 419015b0 41902b50 -> 3f7fffff 3f800000", - "bfac1540 3e0258a5 417ff84d 41800b6a -> 3f7fffff 3f800000", - "c17e7c67 41be7a5a c1260598 c11c97ec -> 3d580db6 3d82d699", - "c161c014 41becfd5 3fff5ecf 40bd807c -> 3ec642ba 3f0a9e9f", - "bfd47a60 415cd801 c03e45b8 c03e3548 -> 00000000 00000001", - "c19b07b5 41ba957e 4088e296 4106f5f1 -> 3f14a6f9 3f3857ef", - "c18a5c6f 41c61bf2 3fee71be 402dda41 -> 3eddeb01 3eed6de0", - "c10ebe76 40a0b967 40b8289e 40b9f49a -> 3f7fffff 3f800000", - "c15918bd 41420b81 41898747 41a4b915 -> 3f7fffff 3f800000", - "c0c2b750 400bbf35 3f523964 3fbef74e -> 3f6d70ca 3f7aed1b", - "bf7747e0 41a7a84f 41296dd5 412c33eb -> 3f0a6389 3f0d69e4", - "c131991e 409979fb 416761ff 418005d1 -> 3f7fffff 3f800000", - "c1a8ba02 417aff96 c126b8ce c126b402 -> 3e50944b 3e509e9d", - "c1989487 41308c25 bf10d762 bf1021de -> 3f2b4610 3f2b4ea2", - "c1059b24 3f2a7314 c1991fad c15231bb -> 00000000 00000001", - "c15cdc1b 40361284 41140ae8 41140d94 -> 3f7fffff 3f800000", - "c18a6fef 418b9e03 c12f4c43 c0a99542 -> 3db405bc 3e8d0dff", - "bee91200 418a8970 c165d0df c14a901d -> 00000000 00000001", - "c1c35c63 41841352 c1272916 c1270600 -> 3e8a4475 3e8a697b", - "c1a6cbc8 3e8e5283 c0a94636 c0a94316 -> 3f540888 3f5409ea", - "c1b20d2f 418fee73 40a63fd6 40a640d2 -> 3f42d2d6 3f42d31a", - "bf7714a0 412c5964 c0efa784 c0efa688 -> 00000000 00000001", - "bc9f4000 4188c1a6 c129c8d6 c122a3ce -> 00000000 00000001", - "be6b3700 41654b51 c102a8c1 c0cdfc35 -> 00000000 00000001", - "c1b29b84 41719ba7 c0ebffba c0ada992 -> 3eb3d67c 3edae35e", - "c027ef70 41ba0eec 41638a6e 4163dfb2 -> 3f382ccf 3f3874a4", - "c155e21c 411d4d19 c146afef c14576a1 -> 3ba0433e 3bbab194", - "c19f8292 401eecab c1732063 c1701e09 -> 3dec2f2c 3dfd9f85", - "c108735a 41c40943 4159e626 4160e61a -> 3f3eeb0f 3f435da5", - "c14e6f7a 418f22d9 c15272d1 c12ba631 -> 00000000 3c69798f", - "c175dfc7 40e0bb77 4190667a 41906cce -> 3f7fffff 3f800000", - "c15b0b2d 412ce48b 41635805 4163a0d3 -> 3f7fffff 3f800000", - "c1836a9b 411c8a68 c10d92a3 c10c8a2d -> 3e4f53a8 3e527206", - "c1038af8 414befb1 c1325e6c c1325b30 -> 00000000 00000001", - "c059d110 4084f5fb 3ffd5e4a 40031e7b -> 3f4c94bf 3f4f70a1", - "c197ed48 419335c0 412f5582 4161de7e -> 3f659bf6 3f76aff3", - "c12f7933 416a2bc4 c1893fb6 c1893f7a -> 00000000 00000001", - "c0da2908 416bb4db c0aeaa50 c0ae6038 -> 3c3b53dd 3c3dc606", - "c16efc88 413936ce bf93cc6a bf84bcf6 -> 3f079c39 3f094fa2", - "bf066360 415f1d06 c19c631d c19c62d1 -> 00000000 00000001", - "c138e0aa 41941c05 c13374b6 c1214672 -> 39c640f3 3be4dd45", - "c09037ac 41602fb5 419aca08 419acb2c -> 3f7fffff 3f800000", - "c0c0e6f4 41854c05 416923af 41693391 -> 3f79e10c 3f79e6ac", - "c1a6ef30 417d5694 40abfeb9 40b1a337 -> 3f4d7a86 3f4ef987", - "c1550285 3fa476ba 4106305d 4128c723 -> 3f7fffff 3f800000", - "c17f8bf7 41a8f692 4109cf8c 411331cc -> 3f3c4edb 3f41abe5", - "c1c275f9 41b1a9dc c159f357 c159eed7 -> 3e094a24 3e0950b9", - "c1c08d79 4172df96 c13fbd5a c13faf76 -> 3e6779b7 3e6796af", - "c1a904a6 414eeab9 c1966b4b c1962aab -> 3c5a97ee 3c606c1d", - "c1471a03 3d6fcdb6 c18658e0 c18658ac -> 00000000 00000001", - "c11f517b 41b869c7 c11ee045 c11edf71 -> 360d132b 360f2551", - "c0dc0cd4 3f930697 c1350026 c129c75e -> 00000000 00000001", - "c08ad500 41a4aaf5 c1827431 c13f616c -> 00000000 00000001", - "c08f20a4 4066ecf2 40d76628 40e0bbd8 -> 3f7fffff 3f800000", - "c1c46c31 41400f95 41110ec8 4159b280 -> 3f7b4e5e 3f800000", - "c16f999d 419b1f83 c178748c c1787232 -> 00000000 00000001", - "c15595f4 415f4c8d c15932b9 c1566a9f -> 00000000 00000001", - "c11ecbb2 405acf9d c16213c6 c161bd12 -> 00000000 00000001", - "bf382300 41932b1f c1165c0d c1161bd3 -> 00000000 00000001", - "c122c6f2 41845e7d c1b73b38 c16cc878 -> 00000000 00000001", - "c1070dee 411c1c6d c097827b c09778dd -> 3ddc3e19 3ddc5f05", - "c157c95a 40da4615 bf19b614 bf19aeac -> 3f326b5e 3f326be2", - "c0776a58 4106f015 bf3909ba bf390146 -> 3e266f10 3e267232", - "c19c364c 406e0257 4054681e 40956a11 -> 3f7fc670 3f800000" - ] - }, - { - "glsl": "vec2 cultmath_iv_lerp(vec2, vec2, float)", - "tolerance": "ulp-bounded", - "cases": [ - "41469202 4146934e 40729cfb 4072a825 3f6215c1 -> 409987c9 40999198", - "4047727b 40477d95 40eef7b8 40f6ac18 3f2e77d9 -> 40c29b1c 40c7e4a6", - "41920a3e 41920aca 417297b7 41729db1 3dcca9a7 -> 418f912c 418f9213", - "c0b88e68 c0b7fa4c 41410a23 41411335 3c2fac75 -> c0b271a8 c0b1dbc4", - "c0b91ba7 c02cab62 40f4a9f2 40f4b186 3d9607c4 -> c0a0dc2c bfdb6524", - "c166d429 c1565443 c1177a3f c1147841 3dffd8bc -> c15efa1d c14c0a5a", - "c12ccc50 c11812d6 c169174c c168d700 3f20f8d8 -> c15fbdda c13dd3e1", - "be8facaf be8f9051 4167b171 4167b2b7 3dacf23e -> 3f774662 3f77577a", - "c132e1bd c12e4531 3f8e222d 3ff2a9f3 3ea2078b -> c0ec37d4 c0d81f6d", - "c080565b c08052a1 408ffb93 4090082d 3e00e955 -> c03c1d10 c03c1180", - "40347d1a 40354506 41724ed3 4173b83d 3edd3efc -> 41023ef6 410322b6", - "4183ea2f 418400e1 c07bf317 c07bee49 3f3b1dd7 -> 3fc69298 3fc90e30", - "4116b5d8 41499b08 c1951155 c1949c4d 3edee28d -> c085ad12 3ed38e20", - "c18b73c8 c13db247 c01d363d c0168163 3f1b60c9 -> c13b9fb8 c02d03c4", - "c107c39a c1065900 4101f15d 4101f4cb 3f496015 -> 409043f4 40955902", - "41013e7c 4101586c 41746a68 418d8f74 3f2c6b78 -> 414ebee0 4168fbce", - "c199606f c1995e9b c1972292 c196c834 3f0de496 -> c198235f c197ee71", - "41291bd9 417be437 3fefeea9 3feff237 3f37679e -> 3f222580 411839c5", - "c185f261 c1843f23 412bd7ee 412bf42a 3e9e4f6a -> c104fa7a c1007e1c", - "c0e4e4a5 c0deb867 419b8ebf 419b9975 3e3af08f -> c01547e0 c0069ec8", - "c007f20c bfeb23c7 c19dddc2 c19cbaea 3f56400e -> c188d076 c183a4e7", - "419881df 419b7ce5 40e94552 41051a8f 3f3ae7b6 -> 41232089 413976c4", - "40044742 40063a7e 3f7ceb1d 3f8011b1 3f35d0a8 -> 3fa3b52e 3fab857c", - "401048da 4091aacb c0932f99 40a26601 3f1b3e10 -> c052e59a 40c86661", - "c145c067 c145964d c081d625 bfa845ab 3f05daff -> c10061f4 c0d25f62", - "4089bd37 40b26861 c0f8d9dc c0ac9dc0 3eed12c5 -> bff0626c 3f8acf94", - "c191a4cc c1919598 4025c018 4038ace8 3e6461de -> c1591b3f c157e7ed", - "c0dac4f8 c0dabe54 c087723a c07c6e25 3f12b1e0 -> c0ab09b1 c0a5b518", - "c176a0d0 c17699ba 411c5e7e 411c686e 3e285151 -> c1346417 c1345a34", - "405f761d 405f7e63 c0c4cc67 c0be98dd 3f395fc9 -> c05f6289 c0565925", - "bff93805 bff9255b 419a8e2a 419e70f2 3f7dcd7b -> 4199172c 419cf3bc", - "c1909e5c c1909a54 c172aff3 c172ae89 3e5a8ac7 -> c18ba795 c18ba28a", - "c15964bd c159449f 414c92c4 414ca72c 3f2f6578 -> 408f416a 408fc99a", - "c17130be c12b141a 4153a16e 4153a562 3ec321f9 -> c0beaa6c 3dc0bf80", - "c078271c c076a4f4 4148cdf5 41490403 3efbc6bd -> 40860f12 40876442", - "418d22aa 418eb22a c15f881b c158eaff 3f6f81f8 -> c141ddc8 c135a33a", - "bf325714 bf2c772c 40e3b32e 40e3b7da 3c3fbad2 -> bf1b014e bf150f5c", - "417bfc1d 417c1e9b 4151553f 41568e41 3e3322f8 -> 41747ff4 41759260", - "c1897e75 c1897e0b c1067901 c10613c3 3ed34118 -> c1590308 c158d816", - "4116cb45 411703c7 c0766832 c070953e 3f7c887f -> c06bc5d4 c064460c", - "40cb69fe 40cb870a c15ee071 c15ed693 3ea43a60 -> be1b2240 be158c20", - "419893ac 41989d9c 40263d0a 402658b6 3d445253 -> 41924208 41924c9d", - "c08cbc33 c08cb985 c08328f4 c0832304 3f3b0546 -> c085bf67 c085b66d", - "40ebdf2b 40f61b15 40d783bb 40d7a765 3f4a9353 -> 40d3aa23 40e61b70", - "413b696e 413b6aae c16e202e c16e1fa6 3e9f1f2c -> 405ca398 405caad0", - "c0c9af89 c0c9a8b3 c0d2ca48 c0d2c958 3f4186c3 -> c0d096a9 c0d089f2", - "3f1ee353 3f1f5c2d 40149c4b 40338765 3e8da089 -> 3f8b9e83 3f9d0688", - "c1515b10 c1514ab0 c094c115 c04e8ed6 3d0eb358 -> c14ca7ca c14bcc0d", - "3fd1419e 40395011 40553527 40613d19 3f48ee1d -> 3ffd0b75 408bfd2d", - "4194c2ba 41966b8e c178c3a5 c16ff767 3f396dec -> c0c926bc c0b0f5d0", - "c1975f06 c19259ea c18b58a7 c1834cdd 3e46451a -> c19603cf c18e770c", - "401e2817 401e3569 c1915c4e c1371719 3f7a72d0 -> c18dc936 c1323fd7", - "413b41ca 413b4236 4007f8fd 4009c473 3f084ac0 -> 40d351dc 40d3cd76", - "c168c70c c167fca4 409dc051 40fdb9af 3f0ec006 -> c06dbd98 bffb8fc0", - "c0a92046 c0a9068a 41583b9c 4158478c 3e705052 -> bf5fbcf8 bf5e91f0", - "41971fa3 41976999 bf89cc2b bf8999f5 3eafc6f4 -> 41405e90 4141276c", - "40e533ec 40e535ac 405f5338 405f7fe8 3f389d89 -> 40906eea 4090820b", - "4123d860 4123db7c 4128484e 41291d42 3f36feca -> 41270225 41279fb3", - "419d1779 419d194f c05e3f56 bfd301f4 3e78100a -> 41609c10 4167b29b", - "400c161a 400c3966 c181428d c18141b7 3f25e20d -> c11b35be c11b261e", - "c0368ad0 c0368920 c1316dd4 c1316a28 3eb67d35 -> c0b93893 c0b934d0", - "40ec6335 4137175e 41355680 41366ad8 3e623653 -> 40eb9ce3 41454768", - "c191520f c18e8485 417a5681 417c67af 3e9936e6 -> c1026ea9 c0f50f92", - "4110dcf9 41110d6f c11b202a c11000ee 3f46c061 -> c0b05fbc c09e6e8c", - "41907899 41967b9f c174c672 c174c32c 3f1112e9 -> bfa29c70 bdbdac00", - "c15f1563 c13dde43 419b6b83 419b6be1 3f2e101a -> 40eabaa6 412d2a81", - "4103c7a3 4103f895 c0c08d31 c0bdbab7 3f6a247a -> c099f546 c096a50c", - "40c77a6d 40fc2b03 c0cc204a bfefe30a 3f7c5bbe -> c0fa5337 bde5d6c0", - "4155f0cb 41561615 c1417513 c1416455 3f2a216c -> c0639b4c c0627684", - "c10b8842 c10b7ba2 41485396 414941ea 3f040855 -> 400ee698 40111ed0", - "c166500b c1664fa1 c0dcaffd c0dc83f7 3f2fe6c2 -> c113e1a0 c113d1cd", - "4099e0e2 40ef1d36 c1930554 c191f828 3e3756ef -> 3e38cc00 40560c7e", - "4147c730 418a2644 40ffdff3 412af1c6 3f03cd8a -> 40f6c96a 4182ba16", - "40ac6c71 40ac9f17 c10067f0 c0f5c37f 3f1f714e -> c03e1316 c02fab8a", - "41753c28 41753ca8 c0df9267 c0c55ea1 3f712568 -> c0b6250c c09d7488", - "402e3441 4033236f 413cabf6 413d47b2 3e91c0fa -> 40a90639 40ac8a48", - "4172f4cb 4172f585 c02dbbfb c02ab565 3f0a300a -> 40b0b9bc 40b18d08", - "4103a5de 4103a6fe c1ab76d4 c19195ca 3e85afbc -> 3ef76ba0 3faa03b0", - "4132591f 41428ded 412a3206 41335eb6 3de924c3 -> 412f933a 4142abb4", - "417d7365 41804aa6 c1011a89 c0df5a9d 3cf408af -> 4171f620 4175b4d0", - "41447ef6 41acf9dd c18ff11d c1584c5a 3f21f02b -> c14c733c 40a9a930", - "c1735fa2 c170001e 3fe5d166 3fe728da 3df1dfc9 -> c153a2d9 c14fd847", - "c187a5e0 c187a54c 3f85d364 3f8675dc 3e994dbf -> c1390e84 c13906ee", - "414df6c9 414e7d2f c140f518 c140df14 3f4f2491 -> c0ea7f5a c0e8756a", - "3ff01ab2 3ff0dace c07c2b7e c07b1392 3f54dcb2 -> c03dc27b c03c29cf", - "c185bea5 c185bb39 404fa8a6 405dca2a 3d323aa3 -> c17d97a5 c17d6926", - "4183671d 41836b77 419c0187 419c38c9 3eb8c64c -> 418c4690 418c606e", - "414cf4cc 419044e2 bfc2b919 3fdd3199 3ed5b993 -> 4094b3a8 4156864e", - "c1931cc1 c192b2c1 4066c575 408df645 3e3d7157 -> c16545ad c161d51e", - "4100f2a8 4100fc5c c02974a9 c0284997 3e954e00 -> 409df600 409e3aac", - "c0866355 c085c04b 415bb171 41bc4438 3ef73444 -> 408e55a5 41135d6e", - "4030b1d3 40368e6d 40cc436a 40cc45f6 3f0cedb7 -> 40968bc0 409b187f", - "4171b7ef 4171b8f9 4170bac2 4170d4c6 3e546bc3 -> 41718333 417189da", - "4146c58e 4146c6e2 c1b25131 c1682efa 3ed3e7eb -> bff8cf40 3fa34f38", - "4172529f 41725309 c1259c5a c0be79d4 3f44aac5 -> c08e2192 bf880048", - "c1a0feff c19c558b 4096cdb7 4096de59 3e0519f7 -> c187c669 c182814a", - "413b8985 414d9f5b c16bd598 c16bb618 3f25f407 -> c0c54756 c0898032", - "bffbb2b4 bffb4b6c 419cab01 419cab37 3f4a6cbc -> 41712326 41713a98", - "c10463da c1045914 c0761b30 c075bd10 3f0a2c9b -> c0bc5450 c0bc19bc", - "41925812 419410da c12709d5 c125d197 3ebfb3b2 -> 40ee89b0 40f8eac6", - "407ecaf9 407ee377 bfe202fd bfe1fde3 3ed37225 -> 3fcdb832 3fcdff86", - "c086dff7 c086da95 c1941e8d c1941ba9 3ef5117f -> c130f53e c130ee7e", - "410f424b 41834bd2 c0f2061a bf177534 3f3e4bf1 -> c10de44f 41151092", - "c1a0dbb2 c1687698 be6239f8 3e12ebf8 3f41ae18 -> c1148483 3f4ac130", - "3ede79da 3edea9a6 c1944b31 c194496b 3df7345c -> bfed7f66 bfed6e92", - "406f2374 40754c7c 418e288b 418e3a91 3f4ee734 -> 4170029e 4172e8a8", - "c0d077fe c0cf4aa2 c19da6b7 c187d807 3f07ca91 -> c1588121 c1407806", - "4038b793 403918ed c19ca9ba c14f5cd4 3e81da2a -> c0341639 bf903a0a", - "c1082334 c1081ac8 4125c6ee 41267326 3f794126 -> 411dca2a 411e8276", - "c1099647 c0bd183e c0293cf8 c0222de8 3ef20534 -> c0e1c9f2 c042b41f", - "c19c92f5 c19c918d 3ef444a8 3fddf516 3f5d11a0 -> c0109630 bf9612a0", - "bf037ae5 bf033a9b c1333b89 c0ea6aea 3f518046 -> c1142ece c0c2caea", - "413eae0e 413eb32a 40bd87a0 40bdf0f0 3e1070d8 -> 413125d3 41313315", - "c12285dc c0b0e388 3edc8341 3ee476bf 3e2f3942 -> c112359b c06da632", - "40f12e44 41171bde 3fb10b85 3fb38f9b 3ef041c8 -> 407044b3 40d21ba8", - "c1212338 c1210b6c 3ef25ded 3ef2f793 3f4d53d3 -> bfcf2998 bfcdb3b0", - "41058aac 41058d4c c1078d25 c09522f2 3f4c2902 -> c0a22302 c001a9e0", - "c18b6f5c c10f780c c1323587 c13234fd 3d3133cf -> c18c2fbc c10b1d30", - "c0a16af1 c0a168bb c14fab2d c14fa8fb 3ee94ce0 -> c10a8fda c10a8d3e", - "c18aae47 c189bcb5 c0cfd62e c0cf924a 3f2b72ac -> c12277a4 c11f3a32", - "c092a412 c09266a6 419efd9c 419f1d1c 3f42ab9a -> 41602575 41608b6b", - "c15e3491 c15bdf93 c189f633 c189ea99 3f1d815b -> c1805860 c17cde2f", - "c16c2e6e c167d9d0 c18e876c c18e86a6 3de0a8a4 -> c172049c c16d3636", - "4084fd4e 40d88cb2 41136e06 41158bfa 3f7893f7 -> 40d10770 413ceb42", - "c0ee3021 c0e2a0ab bf02243e beff7384 3f4c16af -> c00cf822 bfc5de84", - "409d176d 40a52e93 c08e1b11 c08e1a37 3ecd642c -> 3f874948 3fb4a2a6", - "40ab7567 40ab7661 c16e65c6 c16d8e9a 3ed54365 -> c0451eb6 c043b572", - "c0d4e6f4 c0d4e184 417f00d5 417f034b 3f24936f -> 40fbd2e8 40fbdefe", - "bed721f8 405a00df 416d4fec 416d7cfc 3f68ae7c -> 411f6fc5 418a3bd3", - "40efe249 40efe377 c18cd562 c18cd512 3f51b23d -> c1510740 c15105a8", - "c15e6a6d c135222b 41087d89 4108acef 3eb3dbe7 -> c0ddad59 c05bf518", - "40b2d254 41054402 40801b55 40853043 3e09c59a -> 40a03293 41023223", - "bf84e8cc bf84b294 c1a14374 c1691ce1 3f7b3694 -> c19e6a9b c16509c4", - "c1742b6e c1732dee 3e874328 3f13bfac 3f46a921 -> c050b614 c03a2224", - "c0aa2179 4045bbc2 bf7d4038 40e2cb77 3ede0b78 -> c0e2bc75 410780c0", - "c097257f c0482011 c186cac6 c186939e 3de0e40e -> c0c75d5a c08e93a0", - "406cde6d 4074fcf3 c0bc62ad c0bc5bdf 3e5d9f38 -> 3fcc9b22 3fe061c4", - "4121039c 412110d0 4109e651 4109ea17 3f3e18aa -> 410fcfd6 410fe9a6", - "c00c0f6c c007e9d4 c11ab41f c11ab399 3e2cdd47 -> c05d9484 c058bb5c", - "c1127035 c0eb8aba 4186d1b7 4186eda9 3f4a26c2 -> 411f7b23 4152f543", - "c16db51d c16d0fab c0b2355f c0b22501 3eb1a532 -> c13a5f2f c1397d7f", - "c140267c c1401896 40ab474d 415346ba 3f730ce8 -> 408f1264 413eec6a", - "414c8493 415e2805 c1761c91 c17564d7 3f0a59a1 -> c0423160 bfa7ea98", - "414b63a2 4178f4be 4170c751 41782ddf 3e6b3060 -> 414982d2 41819f23", - "413e2616 415859ea c1252970 c0885100 3ea8eb2d -> 40808f7e 4103217b", - "41816f3f 4184df5d 3fcf7ccd 4031c34a 3e0f74fd -> 416145ec 416bb46a", - "3d9f06a0 4080a206 40bdda7e 40c78ff2 3f7b10aa -> 3ffa19d1 4120f4a8", - "c188b1d8 c188adc4 c1887466 c1786d77 3c882703 -> c188b0e4 c18878aa", - "c00db8bd c00934a3 4117558a 41175c4a 3f68c2f2 -> 41055aa0 41078893", - "40afe50c 40b070a4 4111a990 4112116c 3ea17e7d -> 40d421a6 40d51aca", - "c0ec1986 bed09998 c1476629 c1476231 3f78d9f6 -> c198c5a6 c0ab299e", - "c108d029 c108cbe5 c0c22e7e bfcb9728 3edfccb5 -> c0eeea35 c0b03c7e", - "bfadda24 bf49dff8 417fda3b 418c724e 3ecbe096 -> 40aa5853 40d7c645", - "41848a13 41848b51 c04f986c c04c02e4 3eef6626 -> 40e9b9dc 40ea97a8", - "405015ff 40876300 c1931c5a c1900e0c 3f48be5c -> c167c696 c14705aa", - "c1215ed9 c1215d75 c1883689 c188362f 3f3139d1 -> c16e41ba c16e3ee2", - "c0cc51b0 405e0ec0 c1886389 c18824d1 3f3cc729 -> c1ac1f92 c08be17e", - "4044f39f 4061c4e1 c0011c94 bfcca999 3f31c979 -> bf460634 3e8f6228", - "415d2fdb 417b88e5 c1581519 c157ec37 3f0b1fdf -> c003c494 3f5fc3c0", - "40f5f9ba 40fbb0ee 4170fd40 4185f420 3f7eba62 -> 416d8f31 418705c3", - "bf3fbab5 bf3fb1cb c14de7be c14de744 3f38cdd8 -> c117f9ad c117f860", - "4006aebe 40c82101 bf8fe427 bf8e66d9 3f396606 -> c04f4b16 407b2785", - "c14ce1a8 c14cdfd8 c0b71eb3 c0b71205 3f793a96 -> c0bd20dd c0bd0d5d", - "bf92677e bf66b884 c047638b c0475e45 3f50cd78 -> c03cc8e2 c02095f1", - "c14d2305 c147fc55 40dbc3f7 410c1394 3f1927b9 -> bf9e0890 3ed15ba0", - "411710d0 41197aa8 40b9ddf8 40b9e3f8 3db7d0c0 -> 4111a1a9 4114433a", - "40798378 40799598 c12d581d c12d575d 3e58131a -> 3f4a27e8 3f4a8240", - "c04a1bdc bff23b48 c18f835f c1897ddb 3e081fb0 -> c0a950a4 c0707772", - "40cb7054 40cb806c c192ada0 c192ad6c 3f03bcf9 -> c0cb3518 c0cb1c4c", - "41196be5 4119eb6b 4187cf52 4187eb0a 3d8d5956 -> 41218b7e 412217a5", - "c19a6c17 c19a6941 413d7e30 413d7ec4 3f4fc0a7 -> 40bf1c28 40bf31a4", - "4132fc52 41330eea c0e29a4d c0e238f7 3f7be526 -> c0d95f48 c0d8b5bc", - "4195ffa2 419604ae c1009dff c1008d09 3e01c649 -> 4175ac2e 4175b9b4", - "418a178a 41a367be c0fa033f c0fa0221 3f0963dc -> 4006cfb8 40df0074", - "40c32cbc 40c705e4 4018fb36 4115a6ae 3e206f2d -> 40affa23 40d7564b", - "41872725 4188bf6b 40f9bb6f 40f9e4c1 3f5bafdc -> 410ec25c 4114c15a", - "c129bc5e c123fc08 c133e2d8 c133e17e 3d941510 -> c12ae2b6 c124b7d2", - "c0a79709 c0a73837 c140445b c1403dcf 3edcd1da -> c102a859 c10261aa", - "c17cbfcf c17c4231 40ac564c 40c94e84 3e2818ca -> c14531ad c1423eba", - "c0fd4f96 bfd1a4e8 40f214d2 411e483b 3f0b23a9 -> c03a8040 4100a967", - "4159a147 4159a519 41680f68 418a799c 3ed47f69 -> 415f9ce2 417243ca", - "c07ef034 c079c48c 413f1acf 41642139 3f62fe07 -> 41211516 414459d3", - "c1748b3f c1721d91 419a2cde 419aa972 3f3ea3a0 -> 41256121 412a5751", - "c11b1b83 c11b1ab3 c1431e1e c14316be 3f41ecb2 -> c1396b16 c1396412", - "400b4b32 401fa31e c18bebcd c18b2911 3edcc885 -> c0ce1e2f c0be3f75", - "c18a36bc c1231115 415b1022 416be4fe 3f46ae46 -> 3fa122e0 416a8b77", - "418071d4 41a95574 414635c1 4155acb7 3c943922 -> 417e590f 41a8f15e", - "c1962b72 c18cd408 c0deea3d c0d6026f 3f2bbede -> c13a27f7 c117f3b1", - "41377b50 4138d4a8 c0dde206 c0ddb1c2 3e9f7bc8 -> 40b6b3d7 40ba4cb6", - "bf9ffc57 bf9b2fe9 c1837a89 c1837a2f 3f68110a -> c170c96c c16fa408", - "c0ef94a9 c0da565b bfa86428 bfa857b8 3f7c3158 -> c003ecaa bf3e3c50", - "c166a746 c166a572 c0fdb305 c0fd1293 3e844ba1 -> c14bd55d c14bbe56", - "c03d627e c0221292 c19899ca c198992a 3f6be184 -> c1919d30 c18b0d51", - "c15777fd c1449241 c149aa91 c148e043 3f3309d1 -> c15b082f c13a5d9b", - "c01d354c c0009444 3e573434 3e946066 3f78431a -> be9bc638 3f277470", - "41976599 419774bb 41064d49 41065813 3f76455d -> 410c976f 410cdd32", - "408cf5ec 40de368c 412cea85 415e4c6b 3ee8f1f3 -> 40c53428 41342ded", - "c13fa2c2 c13f4216 40f53a02 410cf74f 3f60e454 -> 40a830c8 40c9dabc", - "4184bf41 4185091f 416d495e 416d8392 3e754617 -> 41814cbd 4181af45", - "c18c82fa c18bfeac c12cf2f3 c12cb74d 3e08995a -> c1855f45 c184c557", - "40c60744 40c62b8c 4000da9f 400133f1 3eecb63c -> 408831fa 40887bae", - "4068e617 40690619 41779b46 41779d7a 3c434dc0 -> 4071ed65 40720de4", - "412a1150 412a44f8 c19a63c3 c19a25a3 3f1dd492 -> c0fa8e40 c0f94e0c", - "3db3a340 407c87c6 c17124bd c16e8deb 3f3875af -> c159d766 c0db8933", - "41023db7 41023f25 c0a4ff23 c09e97fd 3f48b9ab -> c012464c c00831a8", - "41829389 419263c7 c187c8c5 c187be6d 3f6876f6 -> c17b4fea c13ee484", - "c06374b2 c0636c1e c10e9326 c10e90d4 3e9d4d5f -> c0a6662c c0a65f24", - "c0eff23d c0efcd6b bfc64f8d bfc46213 3f5d2d2b -> c0173206 c015d396", - "418d5104 418e02c4 3ff25766 40392aed 3de6988e -> 417e106d 4180b490", - "be564c82 be383f7e c0b3609e c08dc942 3f306948 -> c07cadb5 c045b286", - "c163af1e c163708a 405602c5 406d464b 3edc1abb -> c0d5d197 c0d01e85", - "bf937944 409b37a1 41792d15 417a394b 3f0791cb -> 4090d84f 415be1a6", - "41145a98 41145df0 3fec68fe 3fec9bc2 3f19cba8 -> 4099f28c 409a04e0", - "409c4cf1 409c512f 416afca5 416b0043 3e9b9c45 -> 40fba111 40fba8cc", - "c1336d46 c1331f64 40e662a4 40ff2dbc 3f4720f8 -> 4046057c 406ec178", - "c176531a c175702e 403aab38 403e2bf8 3e93f102 -> c121ebdb c1208696", - "c01c5f62 c01aad3e c119edd0 c11707f4 3f437d4b -> c0fe37d3 c0f84bfb", - "41978ca3 41980785 4019e129 40339b47 3f42d0f5 -> 40c9f880 40d7241c", - "c0b762a6 c0b6e03e 4163c36d 418cfcca 3e07543f -> c0460812 c0283864", - "4126927b 41269325 c0e41a3b c0e4121d 3efb201d -> 3fe77288 3fe78a58", - "c0bf53bd c0bafe6b c149a369 c14911fb 3ef03e08 -> c11267f1 c10ef4c8", - "40e8b900 40fa2290 41211121 416c1f7f 3ea0cf3f -> 40ff560c 4122aeb2", - "419f2d10 419f3db8 c0c9a12c c0c98de8 3db8f9ca -> 418c3d94 418c502c", - "c141e893 c101b655 417c5b32 417cbba6 3f205d32 -> 4035b5e4 411612e7", - "c18b08c3 c18a6a2f c162749f c1623bf9 3f726e6c -> c1665d49 c163be23", - "4132643d 41335f97 41343377 4136e881 3c8ffafa -> 413267f6 413373e9", - "c1883a1a c1883750 c0a0cf63 c0a0cdcd 3f6fcd85 -> c0b92724 c0b9100c", - "41483d8c 41484a64 41211316 4121166e 3d99a116 -> 41454c75 41455a84", - "c132dad7 c12a542b 40a75abd 40a7b34b 3f43730c -> 3f7127c0 3ff1eaf8", - "4197f45f 4197f501 408b80b5 40b1d4c3 3f628e71 -> 40c15b5a 40e34baa", - "415955d4 4159580c 415dc277 415eedf9 3ed915ab -> 415b351e 415bb744", - "412f701f 412fd701 4124199c 41252554 3f309172 -> 4127573e 4128bdbc", - "c19055b1 c1379c66 c1754b19 c137fc9b 3e758727 -> c197bac9 c11e82c4", - "412d33ed 412d345f c1096c91 c109589d 3e8e0812 -> 40ae10ca 40ae1cff", - "418f5459 418f55c7 4107bfc2 4107e86e 3ecc66cb -> 41626872 41627caf", - "c11dde4f c08e17d6 4117a4be 411b034e 3f78dde1 -> 406a775c 41691dd1", - "409df883 4119808e 419337b2 41984e42 3e36410f -> 40d02352 4141a8e0", - "4188bd08 4188cd34 413fd36f 41422b91 3e263061 -> 41821a39 41825db8", - "c0d6afb3 c0d50b65 c147830d c1470c09 3f71a8e4 -> c1431fb5 c14116d3", - "c117d92b c116912d 410915ab 41091879 3f7e2afc -> 4105beab 41084f17", - "4190df11 419a1d13 c1091698 c1084d5c 3f6fe3fe -> c0ff19b0 c0b60408", - "40da22a2 40da9cbe c0050e93 c005027d 3dd29a3c -> 40bcd037 40bd5781", - "414d97ba 4155a696 c182bfa0 c1820722 3c04856b -> 4149bfdd 4151e265", - "c186cadd c0eb79c5 c082de10 c0662321 3e9fee96 -> c17d3f2d c04e0034", - "c08b58eb c08b5021 40c2c047 40c2c671 3f71c9f2 -> 40b02c0d 40b042f7", - "c0f81982 3e64c730 c1339e63 c13350e1 3e0abc42 -> c114de9b be7a6ea8", - "4119e1e4 4119e7dc 403281ee 40412482 3ba2e88f -> 411956cf 41196177", - "416ad79f 416d9901 c05de02f c009dfe1 3f01e387 -> 40ac4b1e 40c9e914", - "c023efd3 3ffd7f46 40a315e4 40a48544 3eab65a8 -> bfc25b39 4091e391", - "406c3922 406d5ace 40794292 407af44e 3f3f1fd0 -> 40751c88 40785a48", - "c1144e74 c1144b52 4190a935 419faa17 3f1a08b1 -> 40e60294 41051464", - "41270d24 41270fbc c17999b9 c1781c6d 3f07fc52 -> c0591b90 c055e184", - "40f37d89 40f38747 419da4b5 419da507 3eb9890f -> 413fdf68 413fe647", - "4072c1b8 4072cd08 c04dbef7 c0484d29 3e0e54a8 -> 40346939 403537d7", - "3ffcaa3c 4002a542 404d8c48 404da3c8 3f51d34e -> 403bb98d 4043a5f1", - "bfd350c2 bfc95c3e c17eca1e c165499a 3eb4384c -> c0d67a30 c0c128d4" - ] - }, - { - "glsl": "vec2 cultmath_iv_snoise_ball(vec3, float)", - "tolerance": "ulp-bounded", - "cases": [ - "42368d6a c13bbc84 41bc0454 3fb57e94 -> bf800000 3f800000", - "4212e198 40cbcec0 c1c23f76 3fb7d5f8 -> bf800000 3f800000", - "c22bf0db c1ccd7de 41a6f8d8 3f8949ca -> bf800000 3f800000", - "420661d0 c1a60ee7 41fdb588 3f0e5767 -> bf800000 3f800000", - "422f8640 410fc954 c204cfde 3fbd7437 -> bf800000 3f800000", - "c0f11528 c23c7a7c c2434da2 3f3118f7 -> bf800000 3f800000", - "c1f2e3b6 41a20c3c 411a55cc 3fbe8bb8 -> bf800000 3f800000", - "c23a010c c20f33aa c1fdb69e 3d9fed1b -> bef85cca 3f423b6d", - "c1b77660 c1ce9199 40ef66a0 3f1da819 -> bf800000 3f800000", - "bfff2740 c1acf18f c203a3af 3fcc7d26 -> bf800000 3f800000", - "c181e23e c0a06d78 c16f2060 3f2f4717 -> bf800000 3f800000", - "c0df1ad0 c24257f9 41b7d004 3f13940e -> bf800000 3f800000", - "c1094fac 408656e8 4005afd0 3ffd01aa -> bf800000 3f800000", - "423589b4 c21fc601 422aeea0 3fed7813 -> bf800000 3f800000", - "c14e85fc c130df5c 3f9f1720 3ea905bd -> bf800000 3f800000", - "423ae466 3fa66200 419261dc 3fed9dc0 -> bf800000 3f800000", - "c22f90a0 41881efc c1bbb28b 3f982893 -> bf800000 3f800000", - "41ae1770 3f74b8c0 41ee110c 3fa7b8c4 -> bf800000 3f800000", - "c101a7f0 c1512468 c11c5a6c 3ff98d02 -> bf800000 3f800000", - "418e9b38 4187c908 42261d5a 3ebb0a34 -> bf800000 3f800000", - "423d1e1a c1992387 c187fdbe 3f7c8cdc -> bf800000 3f800000", - "4141c564 c1f45a9e c2261cc7 3eae9cf0 -> bf800000 3f800000", - "c1946eda 416b93b8 422ea960 3e3a80e3 -> bf800000 3f800000", - "41d91d00 c2457f28 420494d6 3fd321ca -> bf800000 3f800000", - "41d582c4 c0f85730 c1af430e 3fc29fa4 -> bf800000 3f800000", - "41c70298 c211c29a 40e0dbe8 3fe7985e -> bf800000 3f800000", - "41c384ac 42125bf4 40dddfd8 3f95b340 -> bf800000 3f800000", - "419ea138 42350398 c1c88b68 3fb38b11 -> bf800000 3f800000", - "c0255310 c187dac8 c1f68545 3fa8a8bb -> bf800000 3f800000", - "c1fd9c23 c1f80651 c19a5d15 3fddd94b -> bf800000 3f800000", - "4108b110 c221e416 c1b03beb 3e111679 -> bf558d8e 3f800000", - "40e94c20 41a593d4 4219708a 3f5374ca -> bf800000 3f800000", - "40722110 40f86c98 c1e9acb2 3f03316a -> bf800000 3f800000", - "c131e7d4 c209efce c0d4d978 3fd657b6 -> bf800000 3f800000", - "41bea580 c0eec080 41c6e380 3fc15d65 -> bf800000 3f800000", - "41485ad0 3c835000 c0345ca0 3f3977e0 -> bf800000 3f800000", - "c123557c c1d3a13b 413a4f38 3f620ae0 -> bf800000 3f800000", - "41fb86f4 c202e154 4162a790 3f93beda -> bf800000 3f800000", - "c219dc5c c108f8d4 c2021f1d 3fa7567c -> bf800000 3f800000", - "420e5b5c bc34e000 c186a0a6 3d9b44b3 -> bf16e2a0 3f1e411c", - "4240eb6a c2095930 c2354f42 3e780049 -> bf800000 3f800000", - "41c3b3e0 424561ca c196181c 3f2381e6 -> bf800000 3f800000", - "421eadca c1688d60 4228236a 3fc1f9dd -> bf800000 3f800000", - "c0bba748 40a5e090 c1cef40c 3e2f92e3 -> bf161964 3f800000", - "414586d4 42271d0e 4189f854 3f2cf0b5 -> bf800000 3f800000", - "c223c9e4 c0b85ad0 411d46c4 3f3b0f3c -> bf800000 3f800000", - "422e63ae 41519470 c20fcb23 3ff97433 -> bf800000 3f800000", - "42402f4e 41dffedc 4240855a 3ef487cc -> bf800000 3f800000", - "c22287bd 41a8f2a8 41da53f4 3f700e36 -> bf800000 3f800000", - "c09502a0 c16e2350 413bac30 3f4f3c94 -> bf800000 3f800000", - "42293b70 c1a20da0 408e70c8 3f6b884b -> bf800000 3f800000", - "c1c6097c 42199fe4 c211c68c 3f905098 -> bf800000 3f800000", - "c202c42f c2243af8 c23bfc52 3ff029e6 -> bf800000 3f800000", - "4202f888 4245b58c 4232c252 3f8a469c -> bf800000 3f800000", - "40baa8e8 41915ab0 c1fc414e 3e69a4ea -> bf800000 3f800000", - "420d2cee c181a09c c1812962 3e6fe965 -> bf800000 3f800000", - "c14aa2c8 41918ab8 41832378 3fbaf57d -> bf800000 3f800000", - "41df2430 41da2c28 4152f0bc 3f0b9955 -> bf800000 3f800000", - "c19f9bf9 c1b99959 c1090538 3fcb0f0e -> bf800000 3f800000", - "421f268e c2109520 c21af7dd 3dd692ca -> bf7b89c6 3f2fad88", - "beea2c00 40f66a50 41f110dc 3fe41ea0 -> bf800000 3f800000", - "41c7f780 c236b8f3 c10e69e8 3e4c7f23 -> bf800000 3f800000", - "41d36e08 c1d59995 42241ac8 3fc59853 -> bf800000 3f800000", - "c205682c 3ebb1c00 40a4df48 3f95d7ac -> bf800000 3f800000", - "42378de0 c0e70220 c225707c 3f921c17 -> bf800000 3f800000", - "c1dfe3af c1176138 41e3aaf8 3f4d2466 -> bf800000 3f800000", - "c087b938 41ce324c 415c312c 3f8f44f8 -> bf800000 3f800000", - "40ffb6c8 c20a7a9c 416340d8 3f57146a -> bf800000 3f800000", - "40dd29b8 c212e472 413d24ac 3f0d76ab -> bf800000 3f800000", - "406a7420 c0a7f7b8 c1553590 3f293677 -> bf800000 3f800000", - "c1b74053 40ce7818 423a5abe 3f8bd0ba -> bf800000 3f800000", - "4210fb4e 421009de c21dad4c 3fcc03f7 -> bf800000 3f800000", - "41ad2ed8 4203b2f2 4205af0c 3f70cf4a -> bf800000 3f800000", - "c23324a4 408691e8 4204b5a2 3e3954bf -> bf800000 3f18d1e8", - "41e9ef9c c11e7534 c0d4f498 3ffe01eb -> bf800000 3f800000", - "c11714f4 420ca052 3ff97c00 3f9c557c -> bf800000 3f800000", - "41118bf8 bf73ddc0 c1ede5c9 3d8c11e0 -> bd762900 3f800000", - "421a2d0c c1b38777 c2349b83 3f82f982 -> bf800000 3f800000", - "c22f92e0 41ccfe84 c1a053e2 3fa7e1c7 -> bf800000 3f800000", - "c0c19868 c1d112ce 4072a6f0 3f99024d -> bf800000 3f800000", - "417319c8 4208507e 42092dca 3fc033a1 -> bf800000 3f800000", - "c1905352 c203369a c153c478 3d61a9c0 -> be650587 3f276475", - "c19f3429 40345360 bfd30540 3e8b5e3b -> bf800000 3f800000", - "c2426064 c148bff4 4229d57e 3f56ddc2 -> bf800000 3f800000", - "c235fcdc c1675b88 4235fbe4 3f3e9d56 -> bf800000 3f800000", - "417bf308 c22b2991 42248ec0 3f61e0ff -> bf800000 3f800000", - "41e09cec c18dbb94 c1119940 3f17ae44 -> bf800000 3f800000", - "c1ce07a4 c2018983 4170dc08 3f8dd1f4 -> bf800000 3f800000", - "42113844 42066270 c17f8f64 3f90a432 -> bf800000 3f800000", - "c2448d78 41d70ff0 c1a7496d 3f56ad3b -> bf800000 3f800000", - "c216de59 c201c5de 41ba2cb4 3f37156e -> bf800000 3f800000", - "41e9a8e0 42251fee be896280 3fafcafd -> bf800000 3f800000", - "4204a9c4 4218168a 4130f004 3e2d2cae -> bf800000 3f58ee06", - "c1ad0a96 c205a055 4230023a 3f947e6b -> bf800000 3f800000", - "422bc1be c11cb574 423bf572 3fff2bb6 -> bf800000 3f800000", - "41d25f6c c22b4d37 41e3ad94 3e80484c -> bf800000 3f800000", - "42170e32 422be6a0 c1b5e76b 3eb6cae1 -> bf800000 3f800000", - "c23a4c24 c1605318 c10ecc08 3f0d99e4 -> bf800000 3f800000", - "c22e322b 406624d0 c1c8adc6 3f76dda1 -> bf800000 3f800000", - "c1807fd6 40ad3750 416e1ae0 3fde3696 -> bf800000 3f800000", - "420234fa 41b1f924 c064dac0 3f39a1a8 -> bf800000 3f800000", - "40d1d3e0 40d49970 c1b7f2ff 3fb28011 -> bf800000 3f800000", - "421e6036 41d05848 4158a21c 3f9b5482 -> bf800000 3f800000", - "41ef2510 c1a4b1b2 4179a788 3dd32d91 -> bf13fd28 3f800000", - "c12e72a4 412c9bac c00265d0 3fdcc5ab -> bf800000 3f800000", - "41604e90 c1909fe0 4173a508 3f71ba59 -> bf800000 3f800000", - "c0436750 c1847e52 c2402a00 3fbf740c -> bf800000 3f800000", - "4226b68e c0860320 c1cfa023 3f404b47 -> bf800000 3f800000", - "41ca97d4 c21f3915 c20380d8 3da7d9c1 -> bf0ce864 3f414878", - "412c01d8 c0f876c8 40bda7a0 3f1f82ed -> bf800000 3f800000", - "417f8088 40f19d90 c1ae4615 3f0c626f -> bf800000 3f800000", - "41b38564 41f35a30 c01175c0 3fc53f00 -> bf800000 3f800000", - "4217f86c c1f18b81 c223a0b8 3fbb4c1a -> bf800000 3f800000", - "c22a32b8 41e531d4 c1d9ca3b 3f81aced -> bf800000 3f800000", - "c22becae 4244f3ca 421d1c1a 3eed214c -> bf800000 3f800000", - "4095e970 400ee170 41e04414 3f604e92 -> bf800000 3f800000", - "3fff86a0 c1bfe497 420d53fc 3fb277c2 -> bf800000 3f800000", - "c216d800 4138daf8 c0b48cb8 3ff7f830 -> bf800000 3f800000", - "c2348e08 c204a162 c1ede4a6 3e056fca -> bf158d87 3f800000", - "c2392ce5 c14279dc 41c5f7b4 3faa5a9d -> bf800000 3f800000", - "420ed832 c1c8a15d 42131ffe 3fb806db -> bf800000 3f800000", - "c1547eb0 3f65b140 c19f64e8 3ff77de4 -> bf800000 3f800000", - "4215ac08 4183f47c 423c1fd2 3f9d855d -> bf800000 3f800000", - "403d50e0 c1898964 41d37bb0 3e8d1a1e -> bf800000 3f800000", - "41ec2350 4209bc5c 41cb1708 3f6dd794 -> bf800000 3f800000", - "42345920 41e03a10 416bfab8 3f078e84 -> bf800000 3f800000", - "41cb97ac c21712e8 41924e64 3fe7f7fb -> bf800000 3f800000", - "41062cf4 c206c510 c044e300 3fb11fb9 -> bf800000 3f800000", - "c1cc1020 c1da00b2 c1497a34 3f1891b0 -> bf800000 3f800000", - "41773870 c22f5a45 c22bbfba 3cbc2c13 -> bea75872 3d1fd730", - "4237c028 421aa0fa 42011f92 3f6a9b89 -> bf800000 3f800000", - "41685bb0 420361bc c0c316e8 3fb87e0f -> bf800000 3f800000", - "c1197ce4 c22de45c c1b8636b 3ec5c2c3 -> bf800000 3f800000", - "41475814 c1ad724a 41ab86a4 3e1e49e4 -> bf800000 3f800000", - "4122c28c 4125793c 4239b078 3efb2394 -> bf800000 3f800000", - "42026f92 c1288478 c13b60f0 3fb61469 -> bf800000 3f800000", - "c1f36f24 c1b123ee c14fad10 3f1ad87d -> bf800000 3f800000", - "423599dc c0550050 bfdb8240 3fbbd2ec -> bf800000 3f800000", - "41daf82c 41c24c28 3efa6b00 3e04a41c -> bf800000 3eadf9d6", - "4236fd76 c1f85e26 413eab08 3fed1321 -> bf800000 3f800000", - "41929fe8 4238f08a 3e4de200 3f84d214 -> bf800000 3f800000", - "421d6ca6 c1b2c9e0 c22d243b 3ff63525 -> bf800000 3f800000", - "3fa78a60 c1a2336e 419cba74 3dd3371d -> bec7f0e7 3f800000", - "c2210abd 42024d0a c1fc1443 3f909e71 -> bf800000 3f800000", - "3ebc9b80 c21b5185 c1be3559 3f3be2f6 -> bf800000 3f800000", - "c08597f8 c2113843 41d5399c 3feff853 -> bf800000 3f800000", - "4103dedc 406625e0 c101955c 3fe1bc28 -> bf800000 3f800000", - "41dea40c 41702cb8 c218424a 3f533064 -> bf800000 3f800000", - "4241b38c c238b9a2 40c51a40 3fdd2291 -> bf800000 3f800000", - "421d1100 4211b82a 41fe08e4 3feb52e2 -> bf800000 3f800000", - "c1e6db78 c1127164 41e73224 3fa82c41 -> bf800000 3f800000", - "41d8a584 c0da5ef8 4159daa0 3ff2af2e -> bf800000 3f800000", - "40b981a8 42301390 40c1f778 3fd88985 -> bf800000 3f800000", - "422aeb98 c1c5fc42 c04e2e70 3f8beb2a -> bf800000 3f800000", - "c1f35889 40cee8b0 422e77e2 3f37417f -> bf800000 3f800000", - "420f0066 c1fba859 c1fd41e1 3fdcf0be -> bf800000 3f800000", - "c200d76d c1ad04fa c22d43c0 3df4714d -> bf800000 3eb521ea", - "c1bcac7f c18f1254 4189a08c 3fa3ba91 -> bf800000 3f800000", - "c1a4abed c17b2028 c209e961 3dcdd711 -> bebc5798 3f800000", - "c1734554 c21c16c5 c20561f5 3e9ab5ee -> bf800000 3f800000", - "421febb6 c0394630 c18d0088 3fd693ae -> bf800000 3f800000", - "c22433c0 c1b52288 bfc17c60 3fbb5bc9 -> bf800000 3f800000", - "40e14a20 c241e4ef 41865698 3f281c92 -> bf800000 3f800000", - "422b4048 c0802eb0 c22f5309 3d58fc10 -> bf08a931 3e9eb1e9", - "c1dbf6d2 422a67ec c0075000 3f79847c -> bf800000 3f800000", - "c1582078 40f63e18 41930a98 3ef2e26a -> bf800000 3f800000", - "c1b9796d 42287de2 40a52780 3f959f50 -> bf800000 3f800000", - "c22114c0 c1033104 c1f14ce7 3e31255d -> bf800000 3f800000", - "c12303d4 41e4689c c0870b70 3f460560 -> bf800000 3f800000", - "4210ac18 c1777d98 41dac9cc 3fe78450 -> bf800000 3f800000", - "41ef12cc c183eadc bf8f4be0 3eff405e -> bf800000 3f800000", - "41752e28 c1798e90 41a9018c 3fd594b6 -> bf800000 3f800000", - "c1aeea02 c2144fd1 4201e4c2 3f582e85 -> bf800000 3f800000", - "415178ec 418f9198 41e49764 3f25791b -> bf800000 3f800000", - "41e5cca4 c22539a2 40dfd960 3eacbac0 -> bf800000 3f800000", - "41b19398 4220407c 415719b8 3e9c7d39 -> bf800000 3f800000", - "41fd8308 41030330 422bf4e0 3e927a8f -> bf800000 3f800000", - "c2472468 418c305c c20645a7 3fe139b2 -> bf800000 3f800000", - "c20afcfa 40ee8948 419697b4 3d783d2a -> be94a519 3f2cccb4", - "c224bdde c0d04b28 4105b754 3fec9647 -> bf800000 3f800000", - "c1e805c5 41adea20 c19daeb9 3ff7d4ee -> bf800000 3f800000", - "41153bf4 41dd2598 c08f9dd0 3fb802f9 -> bf800000 3f800000", - "4247e89a c2120560 411eb9e4 3fc65cf8 -> bf800000 3f800000", - "41dc4adc 41285a24 c1fe1feb 3fe5f490 -> bf800000 3f800000", - "41a08848 c182dfc8 c0d996a0 3e1315f4 -> bf800000 3f800000", - "c109620c 40dba650 4204d448 3f9b37ac -> bf800000 3f800000", - "4239f5d6 423200c4 c1b8788c 3de8daf1 -> bf800000 3e87fcb4", - "42447cf4 41ccbcc4 c1d43c62 3f349079 -> bf800000 3f800000", - "3eac4500 416950f8 42375140 3c264d95 -> be20fe00 3b920130", - "411c5f60 418516bc 40bd3448 3da7ac80 -> bf4efa59 3efdb8d2", - "c2154b7a c1e702be c20edca0 3fde04f9 -> bf800000 3f800000", - "c229964b c130ad84 c21e4170 3f8c2b4f -> bf800000 3f800000", - "c12c7b84 41e805dc c188ada6 3fc07a13 -> bf800000 3f800000", - "c246d690 3f9c62c0 3f7fdc00 3fa43a0b -> bf800000 3f800000", - "421a20ca 419d6ba4 c246bac5 3fa60025 -> bf800000 3f800000", - "3f33c4c0 c1220330 41b5f294 3efa16db -> bf800000 3f800000", - "422018d0 c1ca827d c1b6e59e 3e8518f4 -> bf800000 3f800000", - "416b1520 c200e4b0 c19f9dd9 3d8e7d1b -> be8fb422 3f53d7eb", - "41ddd324 c12d8630 4231d636 3ed02d3e -> bf800000 3f800000", - "c0ed74b0 4239f34e 404091c0 3f935660 -> bf800000 3f800000", - "42084236 41b1ae78 418357e4 3ece6de1 -> bf800000 3f800000", - "c0ea5650 bfda0700 c170e6e8 3ffdbc18 -> bf800000 3f800000", - "c211ab30 c1926e27 c2184c0f 3fe6a861 -> bf800000 3f800000", - "41828c44 42245850 4055fa40 3fba687a -> bf800000 3f800000", - "bfcf5520 421f9928 423ac826 3fd44a0c -> bf800000 3f800000", - "c218b892 423ded62 42202734 3edbfaf6 -> bf800000 3f800000", - "bf85c4a0 c1a41f33 423dc872 3f9c8ea5 -> bf800000 3f800000", - "40d866f8 c19a52d9 c1e3922d 3feba4d5 -> bf800000 3f800000", - "c205534a c0e6dfe0 41f61804 3fc8f795 -> bf800000 3f800000", - "41bba684 4027f450 41fdaa04 3f55cb5a -> bf800000 3f800000", - "421ef87c c1afd084 42457c60 3f291d02 -> bf800000 3f800000", - "c23098a2 c120c3c8 c14e3570 3fddd1fc -> bf800000 3f800000", - "420f3ed0 c1e2be34 41af470c 3f86ebd4 -> bf800000 3f800000", - "42472b28 41a0bc50 c08931b8 3fddab54 -> bf800000 3f800000", - "4200b00a c0a0cee8 41a95058 3e878855 -> bf800000 3f800000", - "3f59d540 41be7694 c0f4bb68 3fd42d72 -> bf800000 3f800000", - "c21f6dfc c1f0f313 41bb6aa0 3ef15f68 -> bf800000 3f800000", - "c21eb3b1 41c6cf9c 42456210 3ff523ff -> bf800000 3f800000", - "c2273bd8 409ef8f0 422cb278 3fd68a3a -> bf800000 3f800000", - "42407102 40e156c8 c209a18e 3e394ece -> bf800000 3f800000", - "42297dc4 c21cc8cf 41ca9858 3f33e7ef -> bf800000 3f800000", - "410ccc38 4196fd50 42290252 3f6e9c08 -> bf800000 3f800000", - "423c4a3a 4230b72e 423947ce 3f12023a -> bf800000 3f800000", - "41fbae34 41942064 422381b4 3ea39a32 -> bf800000 3f800000", - "420eaf2a c20601de c1d92b4f 3fdc19a8 -> bf800000 3f800000", - "4184337c c211af7b 41d289e8 3e615f38 -> bf800000 3f800000", - "c1dd8253 41d13ae8 c0b05f40 3f65a435 -> bf800000 3f800000", - "41d75760 413ea868 4219e3d2 3f00db8d -> bf800000 3f800000", - "c1a4f09f 41429578 c1e971e8 3f4d31b5 -> bf800000 3f800000", - "4241ef1e c22b0366 c1cf69a3 3f537276 -> bf800000 3f800000", - "c1b2f7b7 c1b93279 c1bc5039 3ea5c2bb -> bf800000 3f800000", - "41e44000 41a6e9e0 c20ed107 3f4b4b53 -> bf800000 3f800000", - "416175a8 41d9ea8c 42408084 3fd0f363 -> bf800000 3f800000", - "c17cfe00 c1a304eb c0f0b788 3fc9bd81 -> bf800000 3f800000", - "c1783708 4165d4a8 c214d2de 3fd398a2 -> bf800000 3f800000", - "c1cceae0 c0249b70 419d45b8 3f342aa8 -> bf800000 3f800000", - "c2312ca5 41a9853c 42446570 3ec607cf -> bf800000 3f800000", - "c0136da0 3f546400 c20231ed 3fc8cb46 -> bf800000 3f800000", - "4229b2f4 41fcadfc 41057310 3f4b4a10 -> bf800000 3f800000", - "421478a2 4122bf40 c18c91fa 3f83c454 -> bf800000 3f800000", - "413db9e4 c234bfde 41f5dd40 3fff2d2c -> bf800000 3f800000", - "415ca654 c22c8f0e 4223c4b0 3fff62bc -> bf800000 3f800000", - "c1f28763 c0ff3190 c231c21a 3f2edbc1 -> bf800000 3f800000", - "4231cf76 c10929b0 c2047736 3fcd5709 -> bf800000 3f800000", - "40e61f48 422537c2 c21e3e39 3e174beb -> bf800000 3f49cf31", - "41ae1f00 4233fd3e 4227ead0 3e883e1c -> bf800000 3f800000", - "411c9cd4 c1f2641a 421cbfec 3f86b975 -> bf800000 3f800000", - "41aa4190 c23cc9eb 4226b49c 3fbe4769 -> bf800000 3f800000", - "c19083b1 41358cec c1e9b1be 3ec8d60a -> bf800000 3f800000", - "41858f54 419fd8e4 41aaed18 3ffd0c29 -> bf800000 3f800000", - "41f1fbd8 42455b48 4246756e 3dea39ba -> bf21c8a3 3f800000", - "c09762b0 42055420 4207e318 3f829dbd -> bf800000 3f800000", - "416b38d0 41e11dd0 4201ef12 3ff5499c -> bf800000 3f800000", - "be88fb00 c1c74cc0 41ed74cc 3fab349c -> bf800000 3f800000", - "c214aab0 418bc58c c121c324 3f61e19d -> bf800000 3f800000", - "c2014efa c13a9344 c1ac2d42 3ead49ae -> bf800000 3f800000" - ] - }, - { - "glsl": "vec2 cultmath_iv_fbm_ball(vec3, float, int, float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "3eb29880 c196090f c23f4433 3f29ac23 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1eae31a 423d3e5c c211f9ce 3fdf4669 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f07d92 c219a0a2 c1b74111 3fb97222 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423587d0 42113b7a 418ff060 3fc3c202 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1645498 c13cf5d0 42179b50 3fee7415 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1ed71fb 423773be c1cb5739 3e0d345b 00000004 40000000 3f000000 -> bff00000 3fe9780e", - "41fd51ac 407b5e50 c22d0ae2 3ffe0362 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19f458b c1b5ca2d 41f962c8 3f56b8f0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41a6e3d4 4202ef34 40aa5130 3e900ac9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41f930a4 3f5db780 c19d2226 3fac8fb5 00000004 40000000 3f000000 -> bff00000 3ff00000", - "416a22d8 4235179c 41ceff50 3f436e84 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423ffa28 c22af9d1 41abd2d4 3f07ff4d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4245ea96 4156f084 c2268f37 3fcb80a1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3edff000 c16aa200 423a3f38 3f8b8ab9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22d58eb 42355744 3fb86cc0 3faad2f2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4222493e c20edeb1 40e3d1f0 3fed39a4 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19ca40b 420cbcba c241bdb3 3e81f930 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1981d58 407dfff0 42353ac4 3fd944f3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c228ac61 c1ebe910 c1abedac 3f006dcd 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f017d4 4211c5b8 c22495a0 3fbe84f7 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4201cc7a 41f1b690 4246fa4e 3faaaf78 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f8abbf c2413d16 4225e2de 3f360e9f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4210affc c244a74d c22a8ee3 3fdbb367 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4245b378 415a597c 41d68d34 3f80f649 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c13d8a88 4204d95a c2291f4f 3e839ee7 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2313c1e 410d4334 42362882 3f692705 00000004 40000000 3f000000 -> bff00000 3ff00000", - "419102bc c1d40666 41ad35b8 3f1966c3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22cb1aa 41ac1fa0 c1780a90 3ecf764b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4211ece4 41d84180 42090c14 3e55097b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c20dd900 4221d922 41bdf858 3f13471d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "422ed9dc 41804fc8 c1bc2ebb 3f1a8abe 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c05911e0 c222064a 420dc084 3f625e7e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0c9d910 41e14384 4213920a 3f3c749d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41e5ca10 42382cf2 4195bd8c 3ef24492 00000004 40000000 3f000000 -> bff00000 3ff00000", - "420ab2c8 40877dc0 42421fbc 3ff44778 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19fafe2 4138b9d8 c1aa67d9 3e9684c9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4182b6b0 42148fc0 4245542a 3ee5b45c 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41eb149c 4183b14c c162fe68 3f7450a6 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22222d3 41e7eb3c c1f738db 3f4b2ca8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c18d2fac 41763f88 42439bb6 3f9626f0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c13f0edc c1b444c9 4210ef8a 3f12f72a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "420a7dc6 423ee2a0 c1080eac 3fe78839 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c226be06 412a4194 c1c289a6 3f9a6dd4 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4227b968 41e29db4 4242c302 3f24dee2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c14a90c4 c218b78a 415cf528 3f984a2a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c21f5a74 4150b72c 416ccbc8 3fc5bd5d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0f4f520 c12cc8c4 c1b584e2 3fff51a1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41d792c0 c1a77a72 42251384 3ec5e1db 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40aaa020 c1219fb4 40eb8848 3d56bf1e 00000004 40000000 3f000000 -> bfc80532 3f5b852c", - "41ca7dd8 c247e07f c19fbb31 3fafb3b3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c08b64a8 c2246bca c20faf42 3ec05ae7 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1138a20 41cc123c 40b85690 3f1f9ba0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41f26538 4213b82c c23ebfd1 3ed2a4d9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c241ad69 c1290db4 bfc3bc80 3fc01176 00000004 40000000 3f000000 -> bff00000 3ff00000", - "414aaaa4 c223fcaf 42114b38 3f68b313 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41a34a24 c103cc50 c212096b 3fcae792 00000004 40000000 3f000000 -> bff00000 3ff00000", - "419af9c0 c22e67b9 c2341cbc 3f8543c6 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1e84460 42387890 40db63c8 3f3f2e98 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41fe4c1c 4234c494 c210b44a 3cd7a996 00000004 40000000 3f000000 -> be97be92 3f9b1541", - "bf845e40 c07c6f60 c158c500 3fab249f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4205c2fc 4238af3a c1f48667 3fe674ac 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1b9facf 41a5e7a0 c2012fb1 3ea33998 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4225b5f8 4201628c c12180d8 3fa9caca 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2112bb6 420a7272 4240d3a4 3da0f2ce 00000004 40000000 3f000000 -> bf83fa27 3ff00000", - "42359da0 c172b9d4 bf20be40 3f3031a6 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41a44bb4 c2391683 c21f4f7c 3fd7867f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19f6898 41700f80 c1341964 3e03cc83 00000004 40000000 3f000000 -> bfd5bfcc 3ff00000", - "c1c31e46 c032f3b0 c1bf9d22 3eaa85ee 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41b46920 c1f41a0c 413fb3e0 3fbe166b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1dd5fc1 c1d43539 401fc9b0 3ffc8122 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421ac7f8 421c4bd4 4129ad78 3f45e4b8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40c6c630 422230de c1d32ff5 3ff8c5cc 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423bf0ee c2203aca c2308c4a 3e9131da 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423abc02 c23fb670 42393264 3fcc16f8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "420ffeb6 c16bf500 411f15f4 3f9e2032 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1900baf c21abdb5 42212692 3f629199 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40c988e8 c1d5a3ab 422f070c 3ff135ef 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1daf50f c1d04466 41fc6cc0 3fb82d31 00000004 40000000 3f000000 -> bff00000 3ff00000", - "420154f0 3f3cfd40 c08a1638 3fd0919c 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0dc0f08 41ac6a80 c1b03d73 3f4a876b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1099094 c106e7dc c22262ec 3ea0de49 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c10a8bc4 c2185a14 c1f094c7 3fb4771d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1d67ed2 4201137a 4218f720 3fdeee13 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41587f94 4222fde4 41851dd0 3fc61f87 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42432542 c20679d3 42014a26 3f28b46c 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423b29d4 c1a4f295 41c45c48 3fbaf65e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1ace253 c1808910 c19192d8 3f6b60ee 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40cc62b8 c20ca7a3 c1569280 3e945f66 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22ade87 c1ecaab0 c1ed3a47 3fe780a8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2405aca 41c4f5d8 c23c77de 3f6365f8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c23a8772 c1d5c7ed 41a84174 3f4ecd7a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c164654c 4231e900 c22667a8 3fea77e8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4208650c 41926f14 4202b4c4 3f091b75 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421ceb1c 423436ac c0e877e8 3e771578 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41882fcc c159d838 42151cd0 3e18a8f1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41f0deb0 41bfdb20 c20fa156 3e2bfba5 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c08a3f40 41be5b54 41ee57cc 3f5ce44f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41a33610 41d1b594 41cbc0ec 3ef7da01 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c21201f5 c141042c c1a39be5 3fbc3a77 00000004 40000000 3f000000 -> bff00000 3ff00000", - "410597f4 c17d0f6c c14b4e28 3f2dcc60 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1c3b9be c11c81e0 413d8c08 3fe181db 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c18eb8d0 c2209c91 c1c64348 3e7b5adc 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41dd734c c226b249 c1d4c78d 3fa7cad4 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42155e1c 4235e68a 41646f68 3f16a2c0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22342a1 414ae1fc 4232b9e6 3f9e975d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c20d42e6 41748c68 c1e687f7 3e226daf 00000004 40000000 3f000000 -> bff00000 3fe1c714", - "422b5714 410829bc c213061a 3f835f6a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41781270 4199c670 406af290 3f284f89 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42445d7c 40576fb0 41fefcec 3f4c6497 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2177571 c1bfec43 41d18944 3f37a0a9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "bfb61640 418c8230 4176ee60 3f9ef63a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4033e900 c2203acd c152cf1c 3eb8f987 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41bd4638 c24758f0 416541b0 3ff4eb55 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c127f708 41cae6e4 c1f62e89 3f9a4a7c 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f7b8f8 407d8bf0 4234fdb8 3fbc939e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423a6988 41bf646c c0519ce0 3e2e2f95 00000004 40000000 3f000000 -> bfc67fcb 3ff00000", - "4094f470 4222407a 41837b90 3f2e1fe9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c21197eb c1cce7ed c202ff90 3fd4f346 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4211f3de 410d94f4 c212964b 3f716539 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42476780 4111bad0 40a25d90 3fd43a02 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1e28394 4234e266 41dd1210 3fa75179 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2346d32 410006b0 422d5982 3ef35ef0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c17dc704 c1e30321 c1e92769 3f94fa63 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c199e7b3 c23dd487 c12c537c 3fbf2529 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1e94a34 40df2968 c22a513d 3f9f674f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0cfc4b0 c23c9ae7 c2365094 3f7c67bd 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4203a6a0 41f939d4 c2234660 3fce7f4e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "414026f8 41b0d974 41266218 3f99769d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42438d0c c2169429 3ffb5e60 3cea8023 00000004 40000000 3f000000 -> bf16d493 3f6d6f4a", - "4239292e 41fb114c c239bc61 3ff76fbe 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423ce6f8 c0e96200 424758e2 3feb7971 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c239e042 41113a7c 401a75a0 3fd6ebea 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f30bc9 c134cd84 c1bdbdc8 3f5bad8a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3fd7fe20 422b4d9c c129d628 3ec14e82 00000004 40000000 3f000000 -> bff00000 3ff00000", - "422332fa c1ad1c15 4201b6ee 3ef37d45 00000004 40000000 3f000000 -> bff00000 3ff00000", - "bf96fe60 c2154380 413b812c 3f9eda37 00000004 40000000 3f000000 -> bff00000 3ff00000", - "413397a8 412eddf0 41149310 3ebce69e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3f142180 c1427008 41e2e7d0 3f4a2a8f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "405a18d0 c21cee1e 41705c80 3c8b45e2 00000004 40000000 3f000000 -> bd97a84b 3f66d6ce", - "c23bf3c8 c2163a39 c0884550 3ef4784f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1aa14e0 c1c61d8c 41308b9c 3eef1579 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c085a310 c201e9d0 c2270b21 3dfa38b6 00000004 40000000 3f000000 -> bff00000 3fe413bf", - "41b7c2c0 c186fc56 c21dabd7 3fadf069 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4243d1b8 41ee9b74 c00ab2b0 3fd8722b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41f7e6ec c1432290 c199f88a 3f5a44a9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "424729dc c17fe3d8 c1851042 3fd15bce 00000004 40000000 3f000000 -> bff00000 3ff00000", - "412562d8 42134edc 421de0c8 3f51a95b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1b1930a c136a4d0 c208b31b 3fc89ee7 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42027aa0 41097bb4 42340052 3ef1e643 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3fd33340 c1397354 c2072a18 3f5fe71a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "402c29d0 404e5530 c0920888 3eb3212a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1b5e055 c21e4350 c117fddc 3fbc6743 00000004 40000000 3f000000 -> bff00000 3ff00000", - "414ef434 41f3d950 c1f17f95 3fa6fa09 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41fd8418 c23b70ec c1cfa3b6 3ff285e7 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4227795c 41ea1990 414f91ac 3f97159b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1af9530 418a8d9c 41e211ec 3f30388a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c202cb10 c18e3214 420d3c9a 3f4ece7f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "420b4d68 c1ce03fb c188de44 3f5a25ff 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1e33d18 42143400 421fa5a4 3f6e8f38 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421a481c c20856d2 40903240 3f7fa0db 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c06b1ae0 c2087309 41dfe208 3f726c89 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1f9d2d2 3f1e0200 423aab26 3fcb7ec1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1773cdc c246ee33 c1924512 3fb958ee 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41cb7d80 40e6c928 c20965ae 3fda9178 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41c7b8b8 c21bcba4 c2476640 3ff34efc 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1c6ffd1 c2477242 421b066a 3f463b6e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c01a4360 41d9dfd8 c0cc64b8 3ff2482f 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2131691 41dbd338 c22f5995 3fc278a1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1c9f2fe c213b79b c2155190 3e7a073e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421d55cc c19881bb c2098c03 3faac142 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c16710c8 c230aef3 c230bdfe 3fd87d20 00000004 40000000 3f000000 -> bff00000 3ff00000", - "422a208c 41281038 41892310 3fa4ddca 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41ab3360 c235d62a 41acd058 3fc67a67 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c208f092 411775a0 c1c9c824 3f6c9ee3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1b6f2e5 c12b381c 4246ee0a 3f54d2b0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22bfb60 c23fe2e3 4182043c 3f922723 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42306b62 40b86a58 c0179b10 3f9fb43e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0aeaa58 c23a0e20 42382602 3f6191c5 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4235c05e c184464e 4117b44c 3ec600ec 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42314bbc c2373532 c0761810 3fdef4b3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c21fa19d 41e9d630 c1d6174b 3e32d8d7 00000004 40000000 3f000000 -> bff00000 3fd46f06", - "c2307e8f c1aadaa7 412302fc 3fa72feb 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42192c76 4183dbb8 420c21e4 3f80274d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1965dce 41c09aa4 411ae120 3f2bd7f6 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c126c440 bfa0a540 4221d038 3f3c6b09 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2148241 c234e4d3 c1f144cc 3fade68e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c225fc2e c1b36a1d 42005360 3fd2b589 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4247f056 c232131d 3fee9b00 3eeb3b67 00000004 40000000 3f000000 -> bff00000 3ff00000", - "422c937a c21569b1 c1946f70 3f0e647d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41e65188 40f21420 3f98b780 3fa7a040 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42364c8c 42015d36 41c093cc 3fc7dc37 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1fc6007 c07fdce0 c214b3de 3edb2734 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41be4924 c1c0633c 41edc034 3f6980fa 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c211056a c22274c1 41c1b3f8 3ddbaaea 00000004 40000000 3f000000 -> bfb94bc9 3ff00000", - "41163600 40aa6450 c2474439 3fc87be8 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c05c0b30 41df1c54 4174e310 3fd4055d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c20d86fc 41419894 40dc82b8 3ebe71e2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c0ebd7b0 c190c27f 4097af70 3fd1f95e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423e351a c1c810fb c10ce530 3f1c8020 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19a5d72 c1037d00 bf0a0b00 3fa00d55 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c20d0130 412b814c c225f1fc 3fbd8ee0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1c1e66e c22edc0f c2233ed6 3fd670fe 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1390eb0 c1bef5dd 41931810 3ef0ac8d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40ec35e0 41b71e78 c1f8cd2d 3eb58679 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c203db8d 42250a52 41570f58 3f90520b 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421c71da 42311158 41e5dc08 3f5693ee 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41a9b0e8 423ed3ac bffc8660 3fe338db 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41918918 c0ca3460 41c4e3e0 3eb4b596 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2308b49 c1451768 4158dec0 3fdbc68c 00000004 40000000 3f000000 -> bff00000 3ff00000", - "419b004c 422516d2 40e19658 3e2b99a2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "403a4fb0 41b91038 41f0fcec 3ea96320 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41584ae8 c195cc94 c1caf49e 3efceca3 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c22fa1e7 c1d3ef5d c21203ea 3f4a1c1d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41e2b9d4 422c6dfc 41bb1f8c 3ed2244e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41ffe4a0 41851064 c23cb681 3f0fd469 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41042090 c1ec83d4 c209bc50 3ff292eb 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3fc26440 3f47d200 c201987f 3eca2312 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c222a873 c1878b20 bfd83880 3f041923 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c17ca1e0 40a37618 c23a3b23 3ea40c32 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c20f6d1e 4143b82c 41e2e630 3f4ca0a2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41b89bf8 c1d51421 4202a4fa 3f64ec38 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c19e8543 c16d541c c12bc0ac 3e8312f1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4164a980 c0ddae48 c2389355 3d649ea0 00000004 40000000 3f000000 -> bfa7dca9 3f90cc57", - "4219cd52 c1a80ca4 3d99dc00 3f267284 00000004 40000000 3f000000 -> bff00000 3ff00000", - "40f22358 420d7b98 416fb358 3e82e195 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2114dcb c23446e5 c20ab1af 3fbb00f0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41c99428 4216ee74 c2331092 3eee4b69 00000004 40000000 3f000000 -> bff00000 3ff00000", - "421ea91e 40ed3038 c22ea569 3ecab18a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4219151a 414e2b00 409f5908 3f32d155 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1439b94 41a70eec 41691608 3ea7deb0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c219f08c c2349f3b 40ad11b8 3fa9ad30 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1a66476 c08dcdb8 c14afec4 3dd79d7e 00000004 40000000 3f000000 -> bf97cb6e 3ff00000", - "c233de2b 41a7bbf0 4106954c 3f137fb1 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423d0136 4179fe98 c1bde6ee 3fae7e33 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c227d862 c2217eae 419be448 3f59807d 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1a088e9 c207de52 c1d744c7 3e0dd72b 00000004 40000000 3f000000 -> bfb7133e 3ff00000", - "c154417c 42086866 c20e1d28 3f03155a 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41c01d1c c20b4546 4232cdca 3fddedf0 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1e993d3 bfaf6a80 c2431c03 3e35c328 00000004 40000000 3f000000 -> bff00000 3ff00000", - "bef48d80 bf6fc140 c0c550e0 3f17e10e 00000004 40000000 3f000000 -> bff00000 3ff00000", - "3ed71200 c247ee6c c1fe675b 3ebfe346 00000004 40000000 3f000000 -> bff00000 3ff00000", - "424400b4 41dc8698 c1dbf9e3 3ee84a63 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c1560724 42135640 c1b92ad3 3f104d89 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c2426aaf c1df12d5 4211ac9e 3ff470b2 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41fe0654 bfbc4440 c1a3c497 3f670c21 00000004 40000000 3f000000 -> bff00000 3ff00000", - "c197391e c2190243 c1966166 3fe607df 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41d2205c 41add0bc c2281ecc 3f7912fe 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41666ea8 c20244e7 c1fb0408 3f970774 00000004 40000000 3f000000 -> bff00000 3ff00000", - "417cadb8 c122469c 422820c8 3f195968 00000004 40000000 3f000000 -> bff00000 3ff00000", - "423f555a c2366d8b c2287c5a 3f9785e9 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41399560 42274d64 421bc45a 3fdf3279 00000004 40000000 3f000000 -> bff00000 3ff00000", - "42195024 41846bfc 420d27a4 3ffca3f4 00000004 40000000 3f000000 -> bff00000 3ff00000", - "4143603c c23109c9 c1b76371 3caad5d3 00000004 40000000 3f000000 -> bf7b111c 3e6a832e", - "c1f3b972 4242f084 4242205a 3f4628b4 00000004 40000000 3f000000 -> bff00000 3ff00000", - "41968490 c1ad3591 c0f22840 3f0bd3ed 00000004 40000000 3f000000 -> bff00000 3ff00000", - "419cc42c 41bf0d0c 4103e728 3ec4ecc5 00000004 40000000 3f000000 -> bff00000 3ff00000" - ] - }, - { - "glsl": "vec4 cultmath_iv_frustum_ball(vec2, float, float, float, float)", - "tolerance": "ulp-bounded", - "check": "enclosure and tightness: from the arguments (mx, my, z0, z1, fp, warp) compute in double zm = (z0 + z1) / 2, c = (mx zm, my zm, zm), |c|_1 = |mx zm| + |my zm| + |zm|, r = (z1 - z0) / 2 sqrt(mx^2 + my^2 + 1) + z1 fp + warp and d = |GPU centre - c| (Euclidean); every case must have r + d <= GPU radius <= r + d + 2^-19 (r + |c|_1). Report the largest ulp distance per component as for any ulp-bounded family; only the two bounds fail the check.", - "cases": [ - "3eba7b90 3eb7145c 427992e9 42ba552a 3c779789 3f90a589 -> 41e2a26a 41de7fa1 429b8f4f 419e80d6", - "3f73f64c 3f0c1560 4222d6fe 4297c95b 3d2b135d 3f4911fc -> 425e3d89 41ff38c0 426934da 41f0be8c", - "bf0b3bac bdf4d708 3fcf79e5 40cf912e 3d3114bd 3e3e1d32 -> c00d1a19 bef82057 4081b7d4 40500a91", - "3f3a6c22 3e316390 42b4bb59 42c660ce 3ca20ba7 3fabaad2 -> 428a094c 418358f4 42bd8e14 410d060f", - "be31a3d8 3d899d70 42748f85 42bfc55b 3cfe1a00 3fce5929 -> c159ec11 40a8d228 429d068f 41b20e9c", - "3f4a9c78 3f411d36 4206979d 42890daa 3c1cb84a 3ed166e1 -> 4221bb7f 421a26c5 424c5978 41d73c63", - "bf6a8307 bf066589 428944ec 428eff1a 3b87959a 3f7e8c43 -> c2805ed0 c21322c4 428c2203 4057d762", - "3e53d0f0 bc876000 41751d2c 4233d09e 3c035ac7 3efddf6e -> 40c77b7a befefc0a 41f117e9 417fd2f9", - "beed4c2a beb0f3c0 42239431 428e1c3a 3d333100 3ffeee4d -> c1cf8ad7 c19ac388 425fe652 41b427bb", - "bed8bcb0 3c3e8000 41e413bf 4298518b 3c26e20b 3fc469e0 -> c1b13b43 3f1bc6db 4251567b 41e1777c", - "3f687470 bedf98e0 4177bf60 42360b63 3d258870 3ff533f9 -> 41dd8aa6 c155198b 41f3fb3b 41c88b16", - "bf62de25 3d7a4040 41c9076e 42835586 3b3af21b 3fa07ae9 -> c220ed38 40318369 42359762 41e46bc0", - "be3ee140 3f1d3204 424a7a45 428de3fc 3ceaff9c 3fe71569 -> c1354881 42154ad0 4273211e 417ea87a", - "3d155040 3f242db2 4216395d 425ede18 3caf3282 3f15b6a9 -> 3fd99b9b 41ef459f 423a8bba 41491a58", - "be5186a0 bed461aa 3eb176b7 418ad2a2 3ca8146d 3faf1262 -> bfe7c7e9 c06af099 410d987d 41317a97", - "3f571914 bf527068 4068a7bb 42464d73 3babcf63 3fcc9d21 -> 41b2d633 c1aef697 41d4d7ef 42153b67", - "bea098aa bf7e7b00 4288d592 429c4d84 3cdbcdc2 3fa0cc15 -> c1b7e4bd c291b2d4 4292918b 41262439", - "3f7ea95c bdadf0f8 41da358f 4284b466 3c2226dc 3e0a9e8e -> 423a4728 c07e7771 423b41ca 41e3353b", - "bca1cf40 3f438e26 42ba9a04 42e0c8f8 3cb28a08 3f434e6d -> c0020326 429d206a 42cdb17e 41739f77", - "be5c8f00 3e3a3608 42ab0a9e 430099fa 3c27696a 3f83e9c8 -> c1b87a7e 419bbfec 42d61f49 41c5cbfd", - "3f692462 3ede1ca8 41439ca8 422240ba 3d367174 3ff75747 -> 41c04d51 4137343b 41d327e4 41beeaf2", - "3e3b5de8 bcc485a0 428cd979 42d37f82 3b5555d3 3f91e546 -> 4180f120 c0073e06 42b02c7e 419b8e6a", - "bf0ff773 beb4875a 41e48a22 4283d273 3c964fe0 3ff81378 -> c1d486fc c1854029 423cf4fc 41cc7754", - "bf759152 3e6e00c0 411b7809 4261d395 3d2e1d59 3f86f841 -> c1fde838 40f615e2 420458cc 4211296a", - "3f007a50 3d9d4c50 4282ea47 42c450a8 3cd80964 3f831c17 -> 422439d0 40c910b1 42a39d78 41af98b7", - "3f636f84 bd16e440 42a01495 42b0f436 3c452c66 3fd19c95 -> 4295b6cf c046a7a8 42a88466 41058ed4", - "3c5cb300 be0de0f4 4262f0a1 429011d6 3c1cf805 3fb554e5 -> 3f5e06cc c10ebb65 4280c513 411d49fc", - "be8b8962 3f1140b4 42a3c75f 42c8185d 3c06d0b1 3e63702a -> c1c655c1 424e75b1 42b5efde 413c603a", - "bf4e97c7 3e94f9d8 41b4cb94 4285cd78 3d2c585b 3f96285a -> c210746b 415055d0 4233005d 4204b12a", - "be25d7fc bf757789 42ad6f1f 42e8db86 3d272309 3f34556b -> c1839a72 c2c2c993 42cb2552 41d16b3d", - "bec0915a 3f600790 42c04fbd 42d38210 3d1c330e 3f94e70e -> c217e150 42b0b1c0 42c9e8e6 413d3025", - "3f0a1670 bf664628 4108b80d 41fede26 3c45ec62 3fef5ae7 -> 412e59b0 c1915f6c 41a19d16 41992df4", - "be486fe8 3edbaa80 422ab7b0 4278545e 3cea40d8 3e078533 -> c1240c4c 41b3c934 42518607 414a2433", - "3ed58464 be65965c 421673f1 42818d9f 3ce4afc5 3fe18959 -> 41aacbf8 c137a6d2 424cc798 4194c7c0", - "beda2f86 bf623449 42802552 429586c3 3d199c25 3edfd7ad -> c1eca815 c2755aa0 428ad60a 412ba98b", - "3f674cd8 3f533df0 427626cd 42908fcf 3d4b8e48 3f013f1d -> 4271d09c 425cd846 4285d19b 41495e4f", - "3efcbb28 bf27f8d8 400fbbc4 4161b481 3cf35cdc 3e66b496 -> 40812616 c0ababf2 4102d1b9 41051545", - "bf726bfc 3e85765c 422265b0 425c792a 3cc69f42 3e81bc02 -> c2354815 41479acc 423f6f6d 413c3ed0", - "bf2de8d0 bf7015c3 42340781 42aa1aec 3d356d0f 3f5b0cde -> c230b549 c273f2de 42820f56 420d08c3", - "3f7412de 3f099c24 42184c5f 42287042 3d395b8a 3fb43acb -> 4218e5b6 41ac6892 42205e50 40c9c110", - "3f61efa0 3de59850 41f11e40 4292e041 3cd31933 3f27ae99 -> 4236d3e6 40b9c9de 424f27d1 41fc315b", - "beb8555c bf20097a 42902d49 42a1926c 3d03734f 3f4c5975 -> c1dc27bc c23f2322 4298dfda 410c0d6b", - "bf691e1b bd69e000 429ef423 42b94118 3cd404b3 3fed5642 -> c29cb877 c09d3ad1 42ac1a9e 41527036", - "bd47db10 3f7e4e1c 4265e4eb 42a6530b 3b34e8d7 3fb7ed3c -> c05b95b7 428bb463 428ca2c0 419e41b1", - "3f09c3fc bf32be2e 4032a729 414285bd 3c443705 3ee68bed -> 4080b78c c0a700bc 40ef2f87 40dad7f2", - "3f3e9f40 3eaa481c 41d63aab 422aa228 3c737515 3d98b369 -> 41ced0e7 4138bf66 420adfbf 412f4330", - "3f1fb802 bf2dc82b 413ae66e 41795cfe 3d46b83f 3f17c941 -> 410817ba c1141357 415a21b6 4080218a", - "be405494 3f791cc8 421c39c0 42265819 3d1af6d1 3f5410aa -> c0f257f4 421cf210 422148ec 4085d752", - "3e8877d8 3edafaec 41ca49f0 423fc5a2 3cf8189f 3fe87ee7 -> 411c25c2 417a8ee2 4212754d 417f43ec", - "bf3d965a be144368 42494b41 429ee0fa 3ba1a96f 3f3a1e60 -> c24032cc c1164e27 4281c34d 419adaa1", - "becc395a bf3bfe4c 42bde57c 42ef73e5 3c781d3b 3ff98f12 -> c22b41b4 c29da564 42d6acb0 419f44e5", - "bf3c61c8 3ee8b028 418d320e 425e105f 3cb92445 3f364f56 -> c1d75c30 41850173 421254b3 41d7fe89", - "3f1f518a be517dec 402f6f49 418520cc 3bb331ca 3e08bdb7 -> 40c0ff0b bffdc68e 411b0eb5 4108873c", - "beaf9b28 3edfeb30 421e2147 428c5912 3ce33d4f 3f862e96 -> c196823f 41bfeaa9 425b69b6 41a42f23", - "3f7230fe be255068 40c7692d 41c1736c 3c1b21c0 3fde40b6 -> 41662e07 c01d1d82 41734db7 41667a4c", - "3d8d7cd0 bf0a62ac 40cee4ba 42305acc 3d1f49ef 3fd6618e -> 3fdf8631 c15a9f99 41ca3763 41c68156", - "be9ca544 3f523dac 428913c2 42b299b0 3d3c1bd5 3d6d10c0 -> c1c1297c 4281a02a 429dd6b9 418fb2e1", - "bf05e0c4 3f408168 41d2f10d 428e5765 3d03997b 3ed42d63 -> c1cc08fa 4212b15a 424313a8 4204514f", - "3f437482 3f3426f8 42004794 42577efe 3c511304 3f41a29a -> 42033c5b 41f1ebf3 422be349 41894800", - "3f7005ae 3ec05170 4267bdef 429e6929 3cd6611c 3fe1d7a1 -> 428094da 41ce0d59 42892410 41979fcc", - "3f53b14c 3f0be0ca 4257fad5 428ac0d7 3c37bddf 3ee28024 -> 424c09b3 4206d1f7 4276be42 4140c8a2", - "bed4a09a bf61eb11 42784d7c 428f119a 3d3ea961 3ec9afe4 -> c1ddf24d c26bd1e4 42859c2c 41254876", - "be7248cc 3f53a884 42a01b57 42c4b295 3c99cc55 3fad8b25 -> c1a8d810 4293804c 42b266f6 417447e1", - "bef485c8 bf5894a5 429b8756 42f0f2e8 3cc3db31 3f2bf933 -> c23d59da c2a7b6ad 42c63d1f 42054dae", - "3dc53f20 bf4d87cc 42c333f6 4303e17f 3d20930f 3e3756fa -> 4130d09b c2b83d9c 42e57b7a 41db217d", - "bef74dce 3f57eea6 421b85ce 429e0d80 3ccde299 3e949ec7 -> c1e3cdbf 4246e7db 426bd067 41f22740", - "bcacdba0 3f5caf3a 4282b80a 4286e9b2 3cf797dd 3f954671 -> bfb35c8e 4264fccf 4284d0de 4092de01", - "3e31d288 3ec55ca4 42b838f1 42c48bbe 3b3809b0 3f2e3fbd -> 41843e91 4212c693 42be6258 4089a73e", - "3e1f74b8 3e52f818 41fb696e 4298f538 3c07c796 3f6410d6 -> 41066c52 4131d96d 4257cf94 41c65214", - "bf4a5ad3 bf61a4da 41ed6d75 421f7761 3d1b9c7c 3e7e4ada -> c1dbe314 c1f531a9 420b170e 411a852d", - "bf027502 3e5acab0 41dcaf58 4258884a 3d3e9953 3c94d55b -> c1a69322 410baec2 42236ffb 418d9f16", - "3f1e1676 3e216db8 4224eeaa 4293fe26 3d3385fa 3f62ec26 -> 420e50ba 411152a8 4266757b 41bc71dd", - "bf736034 bf0fa2e2 423d88ab 42646dd4 3c5c35b7 3fc8cd4c -> c246ad06 c1ea82a0 4250fb40 41194085", - "be2e61d0 be1966c8 4090d234 42113fd8 3bb35275 3eb8f1cc -> c05e8b55 c043c4e3 41a35a1e 4186db1f", - "3f0d4866 be91f542 42979500 42f5dbcc 3d0f1823 3f627d75 -> 425b5786 c1e299a7 42c6b866 4203b3be", - "3f32b786 bedb4b24 418a02c0 422ed72c 3d233756 3fff31a2 -> 41aa3b61 c150e1d2 41f3d88c 41a6afc1", - "bec4a242 bf6357ae 42987da8 42f3b000 3c814be6 3f736e2b -> c2182708 c2afea16 42c616d4 420a648b", - "3f5b6fd6 3f586726 4291640e 42e86e34 3d338823 3ff1d23f -> 42a1edf6 429fb0d2 42bce921 42242731", - "3f71bb6a 3f5227fa 429e6e2b 42d19c23 3d219f6b 3f2b21d0 -> 42adc392 429710f6 42b80527 41ca62c6", - "bf571be5 3e6056a0 4247ddfd 425acec2 3d1ab4de 3f92b3dc -> c22fe65a 4137726a 42515660 40cb2247", - "befe8cbe 3f3b65d2 42b02b2b 43088db7 3d252d55 3f972a0b -> c25f5d85 42a470a1 42e0a34c 421c31af", - "bee9f5ee bc10fec0 4229656f 42845ab2 3d3591a6 3ed87261 -> c1c65db9 bef5df13 42590d6a 4183a56d", - "bf74a6a3 3bbe4800 4132b52b 421e76e1 3d10edb7 3ebd7165 -> c1c222b5 3e16fdfb 41cb242c 41ab91ae", - "bdbcb4e8 3f4fa734 4240a4c3 42b1a182 3d46cb93 3fc9a29c -> c0c9f0b3 425e3723 4288f9f2 420081b3", - "3e9a07a4 bea68b80 42470a0d 42b74464 3cb8733e 3ebf7eae -> 41aa259a c1b7f8b3 428d64b5 41cab2ce", - "bb97c700 bf12b63d 41f16809 421e914a 3d076a8a 3f65854d -> be2592f8 c1a00c54 420ba2a7 40f532d3", - "3e41ffb8 3f6b1d62 413bd8e1 4194788f 3cf59dda 3f42f7ea -> 4037b046 415e9e89 41726500 40bfbca1", - "3d31c600 bc0daf80 40209f69 41fc56df 3cc8ee2d 3f125a99 -> 3f3d2c8a be16c594 41883566 417e03d9", - "bf0d995f 3cb47540 42b4834e 42d3f16b 3d03572d 3fd96e5a -> c2591369 400a52e8 42c43a5c 41613f5a", - "bf50e9b9 bdfc7750 42b31956 42bc6cfe 3c833420 3f700442 -> c295f658 c13539c2 42b7c32a 40af09a3", - "bf502f2f be070110 40976663 4184461b 3d48761c 3fac4249 -> c10a591d bfb36ed9 412a1fb4 411cd1fc", - "3f5214c8 3f2a7fda 42a88172 42eac3b2 3d4782eb 3fbf740f -> 42a577ba 42864aa8 42c9a292 41fa8548", - "bf5ceff2 bebaa414 41f5ef3f 420f0fcf 3c6fd64a 3f732bfa -> c1e597bb c141f3e7 420503b7 409d4b51", - "3f06eb94 bf5c3ca2 42a99885 42bebc80 3cfbcfe3 3ff02e01 -> 423de816 c29aff34 42b42a82 41450d63", - "bedca1a2 bf2209ae 426550b5 429fd72a 3ba232e4 3ee3808a -> c1ec92e5 c22dbf13 42893fc2 4171126d", - "3dd8a5c0 3b56ea00 42801f2f 42c0e718 3b1289d0 3ea8b8d9 -> 4107d693 3e86c058 42a08324 4186a5d7", - "bea988de bedb58cc 424ef45d 428a9d1f 3d09673f 3fa81207 -> c1a052d1 c1cf6de9 4272174e 415a092f", - "bde784e0 3df98600 4256f0e3 4275e52f 3c4a7fb0 3f254dc3 -> c0d0622e 40e096b8 42666b09 40aa7e82", - "3dae8d40 3f7bbcc0 416c94c3 420f41ee 3c878a8c 3eff1685 -> 400a01c4 41c70857 41ca671f 417dd268", - "3e77b7a8 3f43a826 42a40d21 42aee283 3d42dc23 3fcb95b2 -> 41a3fc2f 42818595 42a977d2 41138c90", - "bf4cc979 bda99760 42933734 42d13e49 3bb68839 3f71e998 -> c28e9314 c0ec2456 42b23abe 41ab6b73", - "bf48e6a4 be22514c 41dc85bc 420aafde 3d1cf156 3c36242d -> c1c35dec c09dd8aa 41f8f2bc 40bc8638", - "3f6a846e be33a5fc 422013ff 42465eec 3d1d55a9 3dd96f64 -> 42242f3c c0fb8ac4 42333976 4108e86c", - "be4a1c98 bf3d78dc 42bb9479 42d4985e 3d3a38c0 3e5819f8 -> c19df80a c2941704 42c8166c 414ebf0b", - "bf5984a7 bf3c2fe6 418a515e 4213694a 3abc478f 3ea484ed -> c1b803f5 c19f33b8 41d891f9 417163ad", - "be9f0948 bf0c24c6 42060978 428b3068 3c4f048a 3ed8bd2e -> c1801a7b c1e1c55d 424e3524 41b4f9ac", - "3f576772 3f258474 4234bc5c 4241a76d 3b203676 3fd32f32 -> 421d828b 41f21005 423b31e4 4083ee46", - "bf677596 be4b73e0 41b546a7 41edece4 3cbdd74a 3fead377 -> c1bd8208 c0a693cf 41d199c6 40eb27a4", - "3f32f38e be101180 4138693a 424782ac 3d10e1bc 3fd2493a -> 41abb0d2 c08a3917 41f59cfa 41d7ab9c", - "3f36ff22 3f333640 425bfa20 42ad0686 3cdf9f14 3ffa2888 -> 424a4e9b 42461f7b 428d81cb 41d4df09", - "becc5fc4 3eddabb8 421dd3a0 4234b70b 3d235cf7 3f8a215e -> c1872293 41929266 42294556 40c671b7", - "3eaf3d20 bf06f7bb 41818740 41ccc480 3c5edce2 3ff1ca69 -> 40e4d59a c1303f26 41a725e0 40f953ce", - "3e507960 bea7016a 4106300f 4160a610 3c26d80f 3f822982 -> 40121c0e c06a17aa 41336b10 408608bb", - "3f4267b6 3f5e0efe 4286131d 429f914d 3cde39ad 3f98dd6c -> 425efd8e 427eb5c6 4292d235 41515ce0", - "bf684c68 3e1f20e0 424ff7a2 429b4b09 3d310d0c 3f4d684b -> c26b4598 41212a4d 4281a36d 41acc146", - "3ea60f1c bed69d58 41df2a6d 424e6d06 3d1c8fba 3f2938d3 -> 414e4838 c1854ca9 421f011e 418068cf", - "be0d5b44 3f5e0986 427183ee 42bd638c 3cc113b8 3ee76fd4 -> c12b413b 42868009 429b12c2 41cc2802", - "3f032efa 3ea574e4 417fd8e6 41c3f0ce 3c08b29f 3f3d6832 -> 4125f5a6 40d1517b 41a1eea0 40bd4456", - "3ef433fc 3efa6288 4281a92d 4285c8df 3d19d31d 3f9c804c -> 41fb4e32 4200d563 4283b906 409f7882", - "bec57db6 bf68a26d 418c8a3d 4265a500 3b64d728 3ee0d619 -> c1675e70 c208453b 4215f50f 41e511e4", - "bf75b100 bf2f08fe 42151d13 42968cd4 3cd7be4c 3ffaecc2 -> c2580ad5 c219e99d 42611b5e 42053838", - "3eaa3fe8 bf3ea02e 426556ce 42bdeb19 3d0bc9a0 3f096c57 -> 41ca8ffa c262ce48 42984b40 41e06b41", - "3f4f633e bf1cf456 423991e3 428932fa 3ccc9f37 3fe14abf -> 423a4fdc c20d0105 4265fbec 419a6b26", - "bdfdaf88 3f40b98c 42253c54 42432b8c 3d1eb6ab 3e752f0c -> c0b292e3 4207a990 423433f0 40dac5e6", - "3f01a7e8 3e780e20 42581c66 42aec09d 3c0a2600 3fb7e5ef -> 420f3bb4 418903fa 428d6768 41aa5dff", - "bf304d18 3e895da4 42ad2a68 42d38f7c 3d088ea1 3f1fd6ca -> c28479d4 41ce7035 42c05cf2 4180b244", - "3f352cac 3f7e1f50 415aadc0 41b4f5df 3cceb02c 3d99a7d4 -> 414d72ec 419015d4 41912660 40f686f2", - "3f18125a 3f78da5c 40cb4e94 41cab204 3be1a410 3f8ea160 -> 41169989 417671bb 417d85a9 417ad4f9", - "bf34409a 3f39e924 425b02b3 428affeb 3c9379eb 3ec4277f -> c22ef99a 423477bb 42788144 4141f5b3", - "3f1d37a2 3f3dc374 4219b180 424c35f4 39e26e74 3fe79703 -> 41dbccb9 4204a691 4232f3ba 41298ae9", - "bdf44b38 3f7fabae 42c02677 430ace14 3cf4c524 3dc3aee5 -> c16023c4 42ea93f3 42eae150 420a2ecb", - "be473f94 3d2de880 42531f52 42716594 3cf21237 3f809221 -> c13019d9 4019b465 42624273 40d4afc9", - "3efa1934 bef69a6c 42155ecc 42606496 3c90e8c0 3fc9d999 -> 41b692cd c1b4059b 423ae1b1 415f1119", - "bf62c0d3 be815848 424241e0 42c36550 3cd4f595 3f1b943d -> c2818d6d c193cc87 42924320 4212309d", - "bf284e22 3f38c27c 41dce214 42754831 3cec966d 3fcba4cc -> c1e9de21 42005db1 4231dc9e 41d7573b", - "3f5b6d56 3e4fb4c0 42c5f03b 42dd11ea 3d175bb0 3f811735 -> 42b392e5 41a9fb49 42d18112 414ccb26", - "bf58ad78 3f62885e 421bf330 421ef427 3d4810ce 3f9d6120 -> c205444a 420b53fd 421d73ac 4070e914", - "bf70bbde 3f7e54fc 41daed7a 41ecf107 3ce1e14f 3e4bf610 -> c1d65791 41e2730c 41e3ef40 403b1dc1", - "3f23344c be0b1b3c 424f735c 42a33f5a 3c2151ff 3fa209f3 -> 422a331a c111119e 42857c84 419ea8c5", - "be24d2f0 bdad4c98 42405e06 42a1e00b 3d0c1142 3fbc6520 -> c1262647 c0aeb162 42810787 41a77489", - "3f0b775a 3eea0f40 42bce7a8 43030c31 3c37a7c5 3ffd1f13 -> 4275b349 424e2c73 42e18005 41cf32a4", - "3ccd9680 3cd63780 4250733d 42bf14de 3c756c9c 3f51f0d3 -> 3fed2775 3ff71ba1 4293a73e 41bfd66d", - "be4e69c0 bf6a578c 421efb33 42a6879d 3d4329c3 3f85aff2 -> c1465dd2 c26134e6 42760536 420b584a", - "bf702991 bf3f43e2 41f8c92b 421f956a 3d2f3da4 3e9427ca -> c205343e c1d42ad3 420dfd00 410dd7b6", - "bee40158 beaa91d8 4222ade1 426a0c65 3d264d31 3f0fca3f -> c1b0abfe c1842adb 42465d23 41525397", - "bf73c865 be23eeb4 41cfeb1f 426aa46e 3c47d659 3efe38a3 -> c221389d c0d8d3c6 42294cff 41bf5d06", - "3eae619c becee1c8 429adde8 42b74c81 3cda6951 3d9990a6 -> 41e659c3 c208a430 42a91534 4128ee29", - "3e21ad98 3f668342 41579c48 41971e48 3c21d25c 3e9cafb4 -> 40238643 4169252b 41817636 4085220b", - "bf071c06 3dc95610 424a2252 42c4e2da 3d005723 3f8e8dff -> c21d404c 40ea54c2 4294fa02 41fb184b", - "be1851a8 3e45d968 42aeaa15 42fea5a0 3cba9d5a 3fe3a2ff -> c17f7043 41a5e576 42d6a7da 41ca158d", - "3e294510 bf3036f4 428c589f 42a4578d 3d2d0da9 3fe0d3ca -> 41497680 c251ba86 42985816 41494082", - "bf32bf6e 3efbc45c 42a003cb 42aee3fb 3c253572 3fa7a677 -> c269d797 4224af10 42a773e3 40e2a1d4", - "3efe0ff4 3efcad90 426dd177 4292342a 3cf4cc3a 3fe7b877 -> 42038d99 4202d618 42848e73 41452db9", - "bf7a7965 bf295a1c 415d613e 41d3fc5a 3bc87a44 3f0664d9 -> c19ddaf7 c15575c4 41a1567c 4127c14f", - "3f0d4fda bf5e5f50 429ed973 42e515ee 3c3bd066 3fa55483 -> 425623d9 c2a87d02 42c1f7b0 41de6b15", - "be7fdc74 3f3db342 42a8b8f1 43009b84 3d0fcb74 3f40bffd -> c1d4da6a 429dd035 42d4f7fc 4205690d", - "bea7e01c bea4b8f4 412a4d12 41bb793d 3d440e6f 3f666e84 -> c0b2c6e4 c0af6b52 41884fe3 4110f3b4", - "be966274 bf532fa0 420be4c9 429af20a 3c2d6339 3fe1107f -> c1841c56 c239861d 4260e46e 41f696d2", - "3f6ce8ea bf31c0ff 42c7f3ce 431460da 3d21ac1b 3f120fce -> 42e5d59f c2ac71fb 42f85ac1 422dbef9", - "3f00df9c beae8788 4067a1c9 41cc9399 3cbe6a10 3fc76c5f -> 40eb1fc9 c09f35f3 416987d2 416ff8af", - "bf54e4f9 bdd29d80 424f7372 426e4ba1 3d1e826f 3f28bc74 -> c2395876 c0b75c7e 425edf8a 40ffd630", - "3f1f7382 3f39f60e 4093ca91 4178292a 3d3fdee4 3f03f214 -> 40c89849 40e9f1fc 41210739 410c77f1", - "3f19671c 3f02a0e6 41aa3dbc 425e9ee4 3d3859cc 3d877a71 -> 41b8685c 419d07c8 4219dee1 41c38c6a", - "3f53a9cc 3f5a2264 42ab2654 430351e3 3d17930b 3e196331 -> 42b354a6 42b8d030 42d8e50d 42220f3e", - "3e95908c be3e6674 4103e4b1 4210a074 3bdd11b8 3f3e7228 -> 40cf8563 c0841718 41b199a0 417c1f53", - "bea292c2 3f4b52a8 42af1761 42cfc26a 3c0dd300 3f823647 -> c1f3214d 42980929 42bf6ce6 414a9edb", - "3f5d2424 bf1a1148 41fbc156 4201d229 3b048cc6 3f3198e2 -> 41dce17a c199e2d6 41ffb2d4 3fbcd2fc", - "3f2af89c 3efaeba4 41ad7e3e 426b2afe 3c0b556a 3d8ab058 -> 41d6fe16 419dc378 4220f50e 41c54612", - "bf5a7d38 bf5f1844 422c1293 422c8af9 3cd7a64a 3f89aad0 -> c2130f5d c21628f4 422c4ec6 401372e8", - "3f58c6fe bf295088 428ddb47 42ba3150 3cd07a34 3f3ba454 -> 428ae4d0 c258f783 42a4064c 419af92c", - "bf00ffdc befcac32 42920e49 42d5638c 3d338b8b 3da24fd9 -> c2352029 c23162ea 42b3b8ea 41cad7b7", - "be70e5b4 bd5c9f80 4269a1fe 42bb28dc 3d1ad4bb 3fb36bc5 -> c18f057f c082fc0f 4297fcee 41b83d3c", - "3ee05348 3f49ab34 42b1868e 42e468ae 3b87a5ff 3ffe9ac3 -> 4231dab2 429fe428 42caf79e 419cb4b3", - "3f37b66e 3f4ed99c 41bf7f1e 41d2a285 3cc70b15 3e0d2a4d -> 41904a4e 41a27673 41c910d2 40227bec", - "3f627c2e bea4c6e2 4214e1b3 42586c08 3ca59ed6 3b8d9b84 -> 422197ea c16b2199 4236a6de 414b1864", - "3f196b94 bcb9ae00 428a47c7 42e9088e 3d1e1759 3fc90806 -> 425e870b c006a8b7 42b9a82a 4206c21a", - "3e6f5490 bf2dbda0 42adbf21 42bf689c 3c93d98f 3fb202ae -> 41aab05b c277d255 42b693de 4108dac1", - "bdcc0168 be853b62 41f78cd5 4286c48b 3c6913c3 3fa1b424 -> c09cb6c2 c14cb189 4244a7c0 41a916b9", - "3e99da60 be2ec77c 410ed285 42329b06 3cefb9ab 3f9a9f16 -> 4100cc6b c0925123 41d64fa7 41ab4f60", - "bf3e86ac bf196622 4299b68f 42dbd3f6 3d15cd09 3f898ff5 -> c28b00a8 c25fd4d0 42bac542 41dfa502", - "3eac15a0 bf690f4e 40e2b494 4210a7e8 3d391f41 3f08a12b -> 40e8932e c19d7df5 41acfe7a 41b36e8a", - "bf7aff66 3f0b0850 4145434b 418b9917 3d36b33b 3feb984a -> c1699307 410161a0 416e3abc 40cee096", - "bf3f83d5 3ebabc18 4259e958 42a34a5c 3cf50cc6 3e6b9217 -> c24bab3a 41c695d4 42881f84 41a2c319", - "3f053692 bf12a241 40b63931 422ac5c0 3d0ce444 3ffd0dfa -> 41496eeb c15dba0f 41c18ce6 41d6b2c2", - "3f53deb4 bf545fde 42b4dd8d 42bd9810 3d27efb7 3f92324b -> 42994c9b c299aa10 42b93ace 41064047", - "bf775306 3f695bf8 422c20e6 426e67b0 3cd0a526 3f213766 -> c2464f76 423b1ce6 424d444b 417ec08e", - "3e8072d4 3f3cc4d2 423aae25 424318d0 3d135c9a 3f82f40e -> 413f8eb9 420cc1d0 423ee37a 4083913c", - "3c977140 3dc4a660 42514dff 4272f32e 3cf16286 3fe6ee8d -> 3f85c541 40adb3e9 42622096 40fa3a5b", - "bf617357 3e2d4ec8 427154d5 42ba00e8 3d388b6f 3f846e27 -> c287095f 414f9c26 429955a9 41d9532a", - "bd18c3a0 3f5b33ee 420f400c 421f9233 3d08e15e 3fd18a61 -> bfb4b43d 4201a5a5 42176920 40b50751", - "be8cac80 3f5867d6 42be6415 42f58879 3b8ebd6f 3fefa3e1 -> c1ef8b1b 42b84034 42d9f647 41a6cfb2", - "bc9af820 3f16e2ba 418bd2eb 41e7aa1a 3d3c00b5 3fba90d0 -> bee0e144 415af443 41b9be82 41173533", - "3e986e38 3edf8778 42460dae 42997b76 3c3e3b3b 3e8ea7cb -> 41965a15 41dc7b20 427c824d 41848a50", - "bd8c7390 3efba588 4246e2b4 42475b34 3ac08d91 3ef0a89e -> c05a7da1 41c3bc1a 42471ef4 3f1be83c", - "3f6fb12a be8ba324 40b2a4c5 424cd2b1 3d2e1ecf 3f948cd2 -> 41d4aee2 c0f7ce2e 41e3274a 420ccd43", - "3f6a2f64 3db44b70 41a16ef4 425242b7 3d0b3ede 3fcbdb00 -> 42051747 404ceda8 42117d18 41cafa67", - "3df43e70 3f6a7362 42394d59 4297540e 3d0ae34a 3fcb3647 -> 40e8c67b 425f7125 4273faba 41c0f94b", - "3ee99940 3f29128c 42856d7b 42dcd89a 39a8e24c 3ebafdbe -> 4221a2ee 4269f9ee 42b1230a 41e36792", - "bf74639c 3f5fafbe 428b8d18 42a16246 3cfc828a 3fec04c5 -> c28fa49f 4283798d 429677af 41542173", - "beb67832 be8ee122 42b31132 42fac2fd 3cef369b 3fb8be7e -> c2192f55 c1efe5b3 42d6ea18 41c63b6b", - "3f432e66 3e1ff0e0 42bcf8ad 42f858f8 3c600f47 3f3f62cb -> 42a6b639 41889c98 42daa8d2 41aa0bb1", - "3d6391a0 bf7f618e 407fe383 421bab2d 3d49b348 3f0ba7f7 -> 3f9898db c1ab3f26 41aba965 41d92420", - "3eb4d508 3f420ee8 40dd5182 42284269 3c61acce 3ec9f321 -> 410a6566 419484b4 41c3ec99 41bf11f1", - "3e0bb358 bf4fe0a3 420fee13 429f31de 3d364503 3fe9baf7 -> 40fc4a4e c23bb4eb 426728e8 420677c9", - "3f44010e 3ef4f694 42b9acf7 42d59835 3c860463 3f2339a8 -> 4298d94d 423f0741 42c7a296 413c9db0", - "3f4d5a46 3f2f7bce 42162435 42952e9a 3d109a2f 3e4b9de0 -> 4233e2e4 4219b8af 426040b4 41ee228d", - "3f32af80 bf3b2a36 425f715a 428d0936 3c8e69a3 3bd47f6c -> 42306c17 c238cb4e 427cc1e3 413a7274", - "bf367bc6 beb3db08 42be6b94 42e8e685 3cde349d 3fbc97c3 -> c296e084 c214b44c 42d3a90c 4191943f", - "3f351a78 3e737e68 410bc39f 422e8e58 3bf66112 3f7a77a1 -> 419434a1 40c7433b 41d17f40 41b8aa11", - "be8cd402 bf7b6c19 4289ba60 428ced3a 3d11b3d4 3f8867b8 -> c1994a6d c288d5ff 428b53cd 4096dd79", - "bddf41a0 bf00a5e2 42872368 42cf2a88 3d235b84 3e9180d9 -> c11542d2 c22c04c6 42ab26f8 41c54f29", - "3f4bcb94 3f5efe1e 418b7eeb 4283c160 3d2ef13e 3e8eefd0 -> 4204a642 4211251d 4226a11b 4222399a", - "3e8e637c bee62fb4 42959286 42b92dee 3d15588f 3f90be93 -> 41ba30d7 c2167fa4 42a7603a 41693759", - "3f6c026a bdab7c80 419ec1f8 41eb77fc 3caeaf54 3fb4fa94 -> 41b5b892 c0040a38 41c51cfa 410932f0", - "bf090815 bf1807e2 428adfda 42e36e1e 3c9b943d 3fb2502c -> c244134a c2598993 42b726fc 41ff2e89", - "be36147c 3f22685e 4229aa09 422ec50b 3d2da1f2 3e47fa55 -> c0f4fa88 41da82b6 422c378a 4033f41c", - "beb04164 be1cf30c 425309a6 42ba84c6 3cd81a81 3f9b25bd -> c1c91131 c1330b1b 429204cc 41ca7fb9", - "3e015378 3f4512dc 42990ac0 42f7ba71 3b4760af 3fdf9b82 -> 414a7609 429a42a2 42c86298 42009606", - "3ef761f0 bf7ca7fe 41e0c7b6 4209025e 3b6e3514 3f016556 -> 4171010b c1f62449 41f96639 40a6796c", - "bea8c484 befc0758 42a4b77b 4302c794 3cc83f75 3f981bc2 -> c20c82cb c251d4e2 42d52352 42021a28", - "bdd4e1b0 bf799930 425ef466 429f3044 3ce4cd55 3d966382 -> c0e113c9 c283f2e3 4287553c 41980349", - "3edd2fc8 3e68e568 422b4ee7 4296a852 3ac4ac73 3f1c5306 -> 41cc2cf9 4156fc0f 426c4fc6 419676b7", - "bf6c65b3 bf32b0ae 42ba4f75 42f57a84 3d00dcce 3f8a58d3 -> c2c75cdd c296b237 42d7e4fc 41dc8ed4", - "3f624a5c bedba3d2 4167eea2 425e1c30 3beea70e 3f3e7e65 -> 41f79668 c1704fa3 420c0bec 41ef485f", - "be2b7528 bed8e920 429552e9 42a66d1e 3d0d77f3 3f97f848 -> c15379c5 c205c4c8 429de004 410c27f2", - "bee72e0a be8fea76 42bb1d07 430c346b 3c94c541 3f839f1e -> c25318ef c20369fb 42e9c2ee 41eff0b0", - "bf66dc3d bf53e573 420325b0 428a67aa 3c3e5f4e 3f63f710 -> c237f28d c228d64c 424bfa82 41f3cb95", - "bdde21f8 bf51171d 42c3b27e 43129879 3b8da9ea 3feb7ab3 -> c1541b0d c2c7a6e9 42f471b8 420837f2", - "beb70c1c 3ef96f0c 427a5053 4299785b 3aba11cd 3ecf35f6 -> c1c739ec 4207bd7f 428b5042 410c8b89", - "bdcc8170 3e827c54 42adbca8 42c03de6 3b4d254d 3f0a0149 -> c1122e5a 41ba8afa 42b6fd47 40b45e04", - "bed6ae6c 3db8e9c0 42b8bae9 430611ed 3c9a6899 3fab29f6 -> c23de363 41238ed0 42e26f62 41d46eb9", - "be854e4a bf4a1108 429ddace 42c7999c 3cde951d 3f8ad607 -> c1ba22cc c28d12d2 42b2ba35 418aef9e", - "bf12d47c bf129400 40b1ee60 42220661 3c9a0b00 3dd65745 -> c1535fa7 c15302d2 41b8442d 41badb30", - "be59ebb4 bdf03f38 41a377f5 42770bd2 3d2e1010 3ff2518f -> c10bf009 c09a4640 422463e6 41ce43e0", - "3f6fbad6 3f7b8508 420578c2 428c0e56 3cc635a8 3fbc0891 -> 4241a62d 424b2c37 424ecab7 4208439a", - "3e951670 3f3a7a70 4028e196 40b0fd27 3cb3d3ef 3faf8a5c -> 3f983fe8 403e6eeb 4082b6f9 40552b32", - "3d3185a0 3e64c430 428f3c5f 42ae3c36 3cf82dd1 3ffab316 -> 405c2614 418dd958 429ebc4a 4148bc27", - "bf3d0a9f 3f4eccc8 41a18289 41c2d0de 3b6ab514 3fd00f17 -> c183902e 418fec13 41b229b4 40998f95", - "bf34612c 3f009f30 41caacca 42844b79 3d222462 3f9e8fc1 -> c200eae4 41b7da37 4236f6ac 41f6c0f6", - "bf5e3503 bd942bb0 428b2ab7 42ecde78 3d316137 3f44da12 -> c2a332eb c0d9a57c 42bc0498 421928b9", - "bea85958 3e8bf354 427922db 42820aed 3d1e2583 3fada402 -> c1a76f77 418b30e7 427e9c5a 40ab6191", - "3d0a91c0 bf305956 429b34bd 42c01d2c 3c127ff5 3fc35c69 -> 403bffe5 c26f4184 42ada8f4 41598122", - "bea77dc2 bf552054 42a7475d 42bdb7fc 3d0e9d0e 3ff219f9 -> c1e991f2 c2949ac5 42b27fac 414b8a1a", - "3efb5c1c 3f45312c 42b84ff0 42ec599d 3cf02406 3fbb4e29 -> 424e84cc 42a203a3 42d254c6 41b4615b", - "bd1432a0 3f28a31c 40ec522d 41dd8a66 3d4b1806 3ff95d84 -> bf227362 4138db1b 418c4f79 4177c56f", - "3f7af83c 3db6e620 429538fa 42b660b8 3d4789ee 3ff7ec0c -> 42a28ad1 40ece95a 42a5ccd9 4190158b", - "be929a90 bf58f981 4154d95b 421dcad3 3ce841d3 3fea08e3 -> c0f1ac1f c1b2d6a2 41d3012a 41a3e5b0", - "bf6d1840 3f0eb766 4265c805 42a3d8fe 3cc4f2af 3fb52249 -> c28113b0 421b6486 428b5e80 41ab4450", - "3f10f92a 3f2efadc 4299a986 42e4a639 3c3ef190 3ffb0f59 -> 425880f6 4282a86b 42bf27e0 41e2e2bb", - "bd979428 3f2170ec 40a6ef64 42470814 3ceae80f 3ff13f6a -> c00233ed 418aaca5 41dbe600 41ed89fb", - "3e57c750 bf473a54 4183cd3a 426240d9 3c9ba809 3fa1edc2 -> 40f6409a c1e35d3e 421213bb 41e0b2f6", - "bf77285e bf7d6e99 41309743 4259b5bd 3d31b344 3f9e9930 -> c1fcd020 c2019d8e 4202edc7 42227e76", - "3f20891a bf0dfefe 41ffb971 42015bdc 3cc66812 3fce847b -> 41a14d1e c18eac5f 42009c4a 402901ac", - "bf2f4a96 3f7c215a 420c1793 425530f5 3cff70e8 3e997e01 -> c1f1e783 422df8b6 4230a444 4181da37", - "bf1686a4 bf04f04c 41fb087a 428b474f 3d31e84b 3ea2c24d -> c1ed9792 c1d1d503 424a096e 41dd4108", - "3f559eca bd8b2348 4249a0d0 426f9e4e 3d3bed26 3f691ae3 -> 4238199b c06fd215 425c9f8f 411da3b1" - ] - }, - { - "glsl": "vec2 cultmath_iv_exp(vec2)", - "tolerance": "ulp-bounded, platform exp", - "platform": "Ubuntu 24.04.5 LTS; .NET 10.0.12", - "cases": [ - "41202b2a 4120314e -> 46ade79e 46ae2a6b", - "c0d1a016 bfb9db96 -> 3abb4cbc 3e6fb77f", - "bf8fdd04 bf8cd5fc -> 3ea6664d 3eaa61db", - "40024c0a 40b9ecd3 -> 40f51721 43a6d60d", - "4197c9d9 4197cafb -> 4d25c5b1 4d25dd2e", - "418b9b87 418b9bc1 -> 4c10a577 4c10a991", - "40ceb567 40cf50f9 -> 441fb557 4422c533", - "c0d71f2c c0d71180 -> 3a9dbd63 3a9e00d8", - "41149716 4115dd36 -> 4628ae10 4636a8d3", - "406d8085 406d9a7b -> 422392dc 4223d546", - "bef5bff4 bef5b08c -> 3f1e6964 3f1e6e2a", - "40750628 40750e38 -> 4237f95f 42381090", - "c0e728c3 c0e719d5 -> 3a3f1fca 3a3f790c", - "c18aec70 c13b5136 -> 32f6c219 370a21a5", - "41902341 4190380f -> 4c7ed262 4c80b63b", - "c176d7d2 c174bd5e -> 3456290a 34743f6f", - "c10d5076 c0d80228 -> 39190e2c 3a996ddd", - "c11b8847 c11b8125 -> 387bc1f8 387c324f", - "c06ec60d c06eb253 -> 3cc46278 3cc49f0b", - "bebf1b28 3fff14ca -> 3f3040e5 40eac236", - "41284f27 412dd379 -> 4710a018 474c2b74", - "c14fa678 c14fa5ac -> 361b0a4e 361b1209", - "c0fad4ed c0fab9bb -> 39ceb51b 39cf6513", - "c17de632 c17db6c8 -> 3409c9b1 340b6464", - "414f6c8c 41531eac -> 48d06242 490343fa", - "40e7d966 413623fd -> 44af2f87 47aba695", - "4070804e 40800e69 -> 422b6be7 425ac6f1", - "41939c17 41977345 -> 4cc4a616 4d1ee90f", - "40b28176 40b2921a -> 43844fa5 43849487", - "409c38a3 409c42f5 -> 4303e1fe 43040c90", - "c0d1e402 c0cc5be6 -> 3ab9c0d3 3adcce50", - "41947227 4195082d -> 4cda50ce 4ceae88e", - "c19594e2 c1958d68 -> 32023b0e 3202b4fe", - "40f50c60 410a2aac -> 4504502d 45afdbe3", - "c140d47e c140d36a -> 36c3be27 36c3cb5a", - "4157dcae 41587a42 -> 49308d18 493779c5", - "c18e5e55 c18b41ad -> 32a06b8f 32ecb2ea", - "bfbee7f0 bf3151e0 -> 3e66724b 3f00101e", - "41583ab2 415903ee -> 4934a680 493dbf51", - "4155faca 4155fb46 -> 491cf494 491cf956", - "c1642b98 c15d8292 -> 352bff46 3582660f", - "c170f311 c170e907 -> 349ac48d 349b25c9", - "40d7b019 40d7b79f -> 44537137 4453a2f5", - "c197fc9c c196e2aa -> 31c0d460 31dd4a53", - "417d6191 417e0607 -> 4ae63cd8 4aefab93", - "408b17d2 408b1c2e -> 429a709b 429a85a9", - "4070bc94 4070f07c -> 422c0da3 422c9969", - "3fbb7abf 3fbb87c1 -> 408a7002 408a7e16", - "411a81e4 411c27dc -> 46742941 468753f5", - "c1bc5882 c167813d -> 2e8314cf 350ba3e2", - "4080a820 4080c3b0 -> 425eebc5 425fac1c", - "c13b3160 c132dfce -> 370b358e 376a223e", - "41565c23 4156610d -> 4920baf8 4920ec5f", - "4154b6dc 417c728c -> 49110553 4ad92fd3", - "c13cf6ed c13cf369 -> 36f93c12 36f972de", - "417e9504 417e9654 -> 4af82f45 4af843a3", - "c03dd70d c036ea23 -> 3d52ed7e 3d6b086f", - "c189a001 c188ae87 -> 33111f87 332348b9", - "3f52dca6 3f8c44ed -> 4011d8fd 403f7897", - "417629fd 4187c3a2 -> 4a92a631 4bb2ef53", - "c1091e4a c1091d4e -> 3946f2f5 3946ff35", - "417f141f 41818095 -> 4b0000e3 4b2399cf", - "bf91ec53 bf59891a -> 3ea3be49 3edae43d", - "4184d364 4189dc9c -> 4b77dc1a 4be8937a", - "c14bf8de c14be10a -> 36431c63 36443fd0", - "c193ea76 c193e75e -> 32206043 32209e56", - "be900eda 3fad7536 -> 3f41378f 407825b7", - "c08794db c025ce1a -> 3c6cc82d 3d99886a", - "3ec7f803 3ecc0d7d -> 3fbd2902 3fbeacd1", - "c012cb8e c0119f12 -> 3dcea215 3dd27533", - "c0daaa3f c0daa5c1 -> 3a8d34be 3a8d4894", - "c050634f c039c7b1 -> 3d1ddc02 3d60bdf3", - "409cd424 409dee6c -> 43066900 430b1f58", - "408cef3e 415094cd -> 42a3968b 48e003a2", - "c14e4c28 c10ce1c8 -> 3628b807 391d3f60", - "40752252 4075256e -> 42384a67 4238535d", - "40fd9a10 40fda0f0 -> 452cdb86 452d00af", - "41036130 41040d3c -> 456620f1 45700037", - "c077e68c c074d5f4 -> 3caa48ab 3cb2a306", - "c1147257 c114703b -> 38c40310 38c41ceb", - "c1048df6 c1048c9c -> 39844f07 39845a37", - "40dfedd6 410d03dd -> 4488c689 45d22042", - "c1624386 c15f0030 -> 3541c354 356d98cb", - "405e12af 40636bf1 -> 4200886a 420bbc84", - "c14500ef c144fb45 -> 3696ccaf 3697021d", - "c17d28a2 c17d267e -> 34105085 341063d7", - "c123eec5 c123a46f -> 3814ecdd 3817a718", - "3eddffe7 3ede4019 -> 3fc57a2b 3fc592f1", - "40c3acf4 40c3b46c -> 43e24452 43e2792a", - "c1a9f6d8 c165a819 -> 30230d14 351cbd2c", - "4184c5e2 41aaf14e -> 4b763af9 4ee31c73", - "3f9ec35a 3f9f0406 -> 405d3bd5 405dabba", - "40c71490 4165a95c -> 43fbab24 49d1201c", - "3fc1015d 3fc19163 -> 40908b7c 40912e7d", - "c17ee168 c151c9c2 -> 34019755 3607a61b", - "c0c3c1df 3fa3ddfc -> 3b107367 40663bd7", - "c17826ef c17819e9 -> 34455621 3445f704", - "c159be3f c159b8bf -> 35a50371 35a53c36", - "c0020079 bffad0ae -> 3e0650d0 3e104fe8", - "bf44e41c 40b3c1d4 -> 3eed4658 43899686", - "41864aa6 41864b9a -> 4b94d9e9 4b94eba8", - "413cd099 413cd103 -> 48023ffc 4802435d", - "414b49e2 414b9486 -> 48a0ebfd 48a3e196", - "414771e6 414778e2 -> 487d1ce3 487d8b7a", - "40dd96fa 40dfcc76 -> 447e4461 4488382e", - "416ded4c 416df1fc -> 4a2f472a 4a2f7a8d", - "bf429f16 bf41ceea -> 3eef6343 3ef0263e", - "c154a284 c1548980 -> 35e3142d 35e4784d", - "40394b3b 403a4ab5 -> 4190b309 4192f92f", - "c181b997 c181b831 -> 33c2cb42 33c2ed54", - "c1708f7c c1708764 -> 349e939c 349ee3ea", - "c006ab5a c0067636 -> 3df9bcce 3dfa8c83", - "4138ad4a 4138af22 -> 47c922dd 47c93a0e", - "c1aaddba c18114f2 -> 3011aaed 33d319ca", - "c1052891 c1051da3 -> 397ed0c3 397f7f11", - "40f07cfb 40f07f15 -> 44e57ad1 44e589e6", - "40a83277 40a834e1 -> 433fbe6b 433fcce4", - "c1970cb1 c18a3aaf -> 31d8cba2 330690ee", - "c1664f64 c16597a8 -> 35167759 351d5e8f", - "c016aa8e c01673a2 -> 3dc28157 3dc3288b", - "c152f8e3 c152ed29 -> 35fbf1e6 35fcaad3", - "40c4c97f 40c707f1 -> 43ea43a1 43fb47f7", - "c19a2cb6 c19a29e4 -> 3192b092 3192e454", - "bf5cb30b 3e91dd16 -> 3ed833f5 3faa30d9", - "c173577e c162d986 -> 3485462a 353acbab", - "40c3d3a0 40c3d490 -> 43e35669 43e35d14", - "bf70eaa9 bf6e8997 -> 3ec7c912 3ec9a69e", - "4156037d 41593933 -> 491d4a01 49403b2d", - "40edd117 40eebf99 -> 44d3199b 44d95626", - "c13a6ff3 c13611a9 -> 3711f0d7 373fc165", - "c0886ac7 c004b4a2 -> 3c66adc4 3e00c274", - "41915f3c 41917138 -> 4c94aa97 4c95fa47", - "416c02e9 417a49a7 -> 4a1b802a 4abdc33b", - "404d6730 404df460 -> 41c61e4c 41c7d540", - "c11e8199 c11e6ff3 -> 38510e1b 3851f534", - "c1357761 c13576b7 -> 37471dab 374725f1", - "419b9eea 41a2b6d6 -> 4d85d234 4e22655d", - "4199121e 41a4bcae -> 4d42976e 4e511dca", - "403ceedf 40ad4180 -> 41992a72 43609544", - "c10ac2eb c109be27 -> 39338851 393f5577", - "40b06b2d 40b0756b -> 4377ea0c 43783974", - "4146c423 414736b5 -> 4872998b 48797b3f", - "40a579c5 40ad2ef3 -> 43301c69 43601338", - "40867c7c 40868924 -> 4285bb91 4285f082", - "c11b8dde c11b6a62 -> 387b6a13 387d9a15", - "c15e5062 c15b8992 -> 3578044a 3593823d", - "c0f20ac4 c0df35c8 -> 3a080645 3a7504c4", - "4175e861 4175f5af -> 4a9051a2 4a90c9d8", - "c0d0b202 c0d0a082 -> 3ac0d2ae 3ac13c40", - "40f23807 40f24359 -> 44f23b80 44f29142", - "40bcb7fe 40bcbac2 -> 43b60e43 43b61e01", - "3fec5a99 403a96c4 -> 40cace61 4193a841", - "4058f90a 406037f6 -> 41ed6007 4204ea3f", - "c19c9154 c19a637e -> 315987b7 318ed16a", - "c083c2e8 c083c20c -> 3c85670b 3c856aa2", - "c1927ebc c189bbdc -> 323f8b7c 330f29a6", - "c13bc94e c138e5ba -> 370623e5 3720af66", - "c1903287 c1903073 -> 327f45d2 327f882c", - "c18dcc20 c18da0d0 -> 32ac4a91 32aff94d", - "41241856 41241c9a -> 46de4628 46de8174", - "c149a219 c1498cf3 -> 3661d2b7 3662fdfc", - "c17daadb c15be833 -> 340bcc6f 359023d4", - "c1526edf c1515197 -> 36024a19 360baffd", - "410f5073 410f5735 -> 45f2990a 45f2ff98", - "418081a1 4182dfcb -> 4b107375 4b4234b8", - "be2f2f61 be2a219f -> 3f57bec7 3f58d00a", - "c147088e c14707c6 -> 3684d52f 3684dbae", - "418415d1 41847393 -> 4b61f244 4b6c87da", - "40cca9b9 40ccaa97 -> 4415d180 4415d592", - "418103b8 418103fc -> 4b19ec9e 4b19f1bc", - "40915d28 4106f73c -> 42bbdf9c 458ff907", - "415a09c0 415a1148 -> 494a45ac 494aa4fb", - "c0d79718 c0d76aa4 -> 3a9b728e 3a9c4b17", - "c022fa3b c0152575 -> 3da077df 3dc72e06", - "4100d622 4104fde6 -> 45444f18 457e8659", - "c1356667 c110c6bd -> 3747f160 38f68d2d", - "3ebbca75 3ec9858b -> 3fb8b6cf 3fbdbc1c", - "c19237e7 c192310d -> 32464918 3246f335", - "419707fd 4199690f -> 4d16cce4 4d4b07b9", - "40ab2960 40ab2a60 -> 43525b19 435261ad", - "4171dd3d 417d47d3 -> 4a602e46 4ae4cb97", - "4131b591 4136ef6f -> 47822040 47b4644a", - "3e10a062 3f06df68 -> 3f936ad1 3fd8c755", - "409828ee 40982db2 -> 42e85391 42e8762f", - "411800b7 41189eb9 -> 4650c83b 4658fe59", - "3fd45d75 3fd4636b -> 40a8259a 40a82d71", - "400f4bec 402d8b74 -> 411624f8 4170dcbf", - "3fd386e5 3fd3cdbb -> 40a70caa 40a76938", - "bf91ee69 3fa50909 -> 3ea3bb9e 40685834", - "3f29298b 3fff963a -> 3ff7d963 40ebb013", - "c16d1803 c16d1739 -> 34c4f0fc 34c4fab4", - "3fc7105d 3fc73ac3 -> 40978d13 4097bf50", - "c00692a2 bffc4cbd -> 3dfa1d56 3e0ea5e3", - "41500857 41554a31 -> 48d87662 49165507", - "c19c5c71 c19b7aa9 -> 315f3881 31793cc7", - "bf8bdf6c 40b3764b -> 3eabab4a 4388533e", - "c0cf7436 c0737944 -> 3ac87344 3cb67ab6", - "c180611b c152db2e -> 33e679ea 35fdc764", - "c168c603 c168c403 -> 3500fedf 35010f02", - "411b944b 411d77cd -> 46828a0c 4692e51f", - "4111ea58 4111f560 -> 460eb64f 460f18d8", - "418942a2 41894466 -> 4bd7bb33 4bd7ead7", - "c165800d c1657c43 -> 351e4765 351e6ce7", - "c0ff15d8 c0e732e0 -> 39b4fa92 3a3ee36f", - "418b2695 41913acb -> 4c089e3d 4c920b63", - "4141eb39 4141ec7f -> 4833310b 48333f51", - "c1618094 c14fd848 -> 354b353c 36192a8e", - "416d127a 4181d013 -> 4a2628ec 4b2a1365", - "c12c2882 c12b27f0 -> 37b22074 37bda432", - "c132c5f9 c10872dd -> 376b9d70 394f73c3", - "415a1b25 418b5009 -> 494b220b 4c0b695d", - "c1664144 c1663f72 -> 3516fc69 35170d99", - "4193287c 4193c44c -> 4cb9db17 4cc88c31", - "40e35323 40eb070d -> 4498166f 44c17aa3", - "407ae7f7 4083215c -> 4249af1d 4270d60b", - "c16c6d87 c16c5279 -> 34cd4fbb 34ceac0d", - "c1854c1f c14bc377 -> 33794569 3645abde", - "c1878438 c174a2d0 -> 333ce31c 3475d61f", - "c16e15b2 c16dfe3c -> 34b91d2a 34ba2d63", - "c186191d c1861537 -> 33618758 3361f55c", - "c0ee532b c0ee51a1 -> 3a18c798 3a18cef4", - "4125bcb1 4125c2ef -> 46f64bf5 46f6ac20", - "41435826 4143a7e2 -> 4843e39d 4847bd60", - "4141e5b9 4142f0c7 -> 4832f37d 483f01e0", - "419f32eb 419f39c5 -> 4dd14cf3 4dd20083", - "40cb4342 40cdb75e -> 440f676c 441ad4f1", - "4165e3b7 4182eb9d -> 49d4204a 4b43547f", - "41079ed6 411a174a -> 4595fc6e 466de380", - "c16a9ed5 c15ab975 -> 34e5dd5c 359b327a", - "c12f9849 c12e8603 -> 378fb266 3799a604", - "3edb505a 3f136953 -> 3fc471ac 3fe3a921", - "c1506cd1 c15060a7 -> 3613b61c 36142695", - "40b9f7e9 40ba784f -> 43a70fe1 43a9b37f", - "419521ae 41952506 -> 4cedda1d 4cee3d9e", - "41074ff8 410750a8 -> 45932031 45932685", - "40d9f8c3 4115426e -> 4463159f 462fe2c7", - "c0b7ab40 40806080 -> 3b52c17e 425cfafe", - "4005e1fc 40640484 -> 41019b63 420d0b33", - "c1762c19 c1416a91 -> 345f546a 36bcb364", - "c0e1be65 c0e0b257 -> 3a625df5 3a69e58a", - "412e612d 412e62c3 -> 47535b4e 47537044", - "40e4c428 40e4dcb8 -> 449f1864 449f92b3", - "419c93fb 419d0c35 -> 4d96d4f0 4d9ff38c", - "bf4f1957 bf4e8269 -> 3ee3ffea 3ee48680", - "c144d67d c144cba1 -> 36985ed0 3698c65f", - "40fcf00d 40fd1413 -> 45294e9f 452a0da4", - "c170377a c16f9c1a -> 34a2054c 34a848e7", - "4119be6c 411dc410 -> 4668c871 4695a7d5", - "41732663 41737c65 -> 4a72f06f 4a78182a", - "40690b7e 40697ad2 -> 421891cf 42199c1e", - "beb85bd2 be97a02e -> 3f329775 3f3e61d7", - "41325a08 4187bbc4 -> 4787750a 4bb23fb3", - "406ea634 40909ea6 -> 4226883c 42b78e0b", - "c18b47ee c16b52c0 -> 32ebfa26 34dbfc84", - "c11e1519 c0deff46 -> 3856aab4 3a76a784", - "40c786cc 40c7941c -> 43ff33d9 43ff9e1c" - ] - }, - { - "glsl": "CultPhasor cultmath_phacelle(vec3, vec3, float, float)", - "tolerance": "ulp-bounded, platform exp, sin, cos; across platforms |diff| <= 2^-20 max(|v|, 1)", - "platform": "Ubuntu 24.04.5 LTS; .NET 10.0.12", - "cases": [ - "c01d8630 41b2cd8c 41ea274c bfa19894 40aeb6ce 40918978 3e9be843 3f000000 -> bf74d9fb 3fb71956 bf35fe4e 3f21280a c01277e2 403b5fe4 40464bbd bd5b4455", - "c2234cf7 4237b112 419ae0c0 c0acbcd4 bf60f9a0 bfeb2b08 3ebf0a10 3f000000 -> c0d0048f 3f228da3 bfc85f60 3edaf41b c0171c80 be137f8c be1c92a3 bf5747bf", - "41cc0920 42390a28 c1c4714d 4095ff5a 40ae1422 40138f40 3ea0019d 3f000000 -> c0626854 c06c83d4 bfb294eb be676f09 bfcf7e6e 3d2e218b c0200a4a 3f167e2f", - "42370b68 c2438846 c1e6efa5 c03373ff 402d665c 4013a940 3e578396 3f000000 -> 3d678d11 3e4c172f beeb5835 be30e395 3f0a6332 3ede254b bee8e250 3eae4126", - "c08f5578 411586a8 42413a4c c019de34 3fc5c70c bf08ccf0 3f5a6e2e 3f000000 -> 401e1cfd bfc4bac6 bf58739f 3f279e2b bcc6aac3 3f322772 3edf42e6 3df7608b", - "c11d6390 41b27d04 c17248a0 402cdca8 c0bf8bd5 c0829639 3effad62 3f000000 -> bf03c0db 3ff17078 3f87ac38 3f75d4e0 3fe2b4b6 c0cfb86d c0697330 3e8ede55", - "c114785c 41ee8f54 3f8c8d40 bf6775d0 3fa2f210 c04f602b 3cc8f8e9 3f000000 -> 3fca86f2 3f6577fa c01a4f40 bec279f7 3f5a1dbd bf3c2a09 4028e32f bf207dbd", - "c211a0fa 41530bc8 c121f734 40a8c3f0 40b21602 40a4ff6c 3f048cf0 3f000000 -> 40c38039 40992e68 408dfc05 3a08c9d8 3b50ece4 3b23b31a 3b17bbad bf7ffffe", - "41a9de18 41022de0 c2149dfc c04ff8bc c0709652 c09be326 3f22f44d 3f000000 -> 403bf7c9 40419292 408b5124 3e679c10 bf2e9566 bf33ca05 bf816597 3f795da6", - "c156c260 41a86c28 41c868c0 4064de10 40964edc 3e7448e0 3eb4f280 3f000000 -> bf8c32e0 bffb8ca7 3d8b13de 3e438cc7 3f323542 3f99dc06 40017862 3e874112", - "c1d068b3 42225982 c205c8f0 40ad9ff8 3ec5dd80 40707e58 3f0ce75b 3f000000 -> c0349e81 3f3fc530 bfaf1dbc bf18915a c08caaaa 3eac5ccd c005c769 3e9225e7", - "c1e59fe1 41a04784 4208ac42 c0920956 bee7b4a0 c07134a5 3ea378b1 3f000000 -> bf3feef3 bdb8ba0b bfa29638 be587b15 3f3930d2 3ef203a1 3fff1a53 bdbfd9a5", - "42389eb6 4106e060 c15fbf54 3ffd6f00 3e9e6f60 bffcb888 3f3075cd 3f000000 -> 3f332fdc 3c8560b8 bfe1216d 3c2f34ca 3bf5488d 393690af bc9a1676 bf7ffc41", - "c20f4cf6 c1dfe857 bed31800 40717ea8 c0a6b312 408b5396 3d29b33a 3f000000 -> bfdb8d4f 403490e4 3fb46b68 3e471378 bd600a14 bfbec46f 3fc2be3f 3eaf81a2", - "c224ee6a 41d06018 414aa3f8 4024db50 40215b48 40036b94 3f657d0a 3f000000 -> bff064ec 3f7da25d 3e056ae2 be8ac707 bf782c47 bed3745c c00c9402 bcacdb39", - "41b4d2e4 c1d569b9 4242f024 bf523eb0 c0933fbf 40b37860 3effacc8 3f000000 -> be71736c bd8a544e 3c17c22f 3f7aa6b3 bf04a68a c05faf26 40b9af6e bd872883", - "421867b6 c1aa947d c21c327e 402c6040 409cb72c c00c5822 3ecef6a5 3f000000 -> 402c1659 40ac0e18 c01c7aba 3e2e0e0e 3eed75dd 3f6d6a7b bed7ec61 bf7c4657", - "c2158204 c12f6f30 c212cbea bfce6068 c0725f30 3ffc14b0 3dc82c17 3f000000 -> bf1395df bf305c8f bd010deb 3c80722f 3faded2e bcab6bdf 3e04aa20 3d81745f", - "41949b58 4187ba84 c210eb56 becef150 40aceb96 3ddc8e80 3e004e03 3f000000 -> 3f1c001d bfbfd00c 3f9c703f bf46ef9f 3ee14306 c015c255 3facb8b2 3e843e47", - "422ff3b8 c1e3f97a c117efcc 4041ae24 3e35fc40 bf6d0858 3e712c37 3f000000 -> bfdb3c1a bdd2c0db 3f47d294 bf103816 bf957c53 bd8fb3dc 3f083fd8 3f5382c9", - "c16e4c30 c14b7fe0 c1d54085 bf8b652c bfca9a04 c06e21c5 3e857f24 3f000000 -> bfff4d45 3eda6caf c0881cdc 3e7adfa2 3e134e36 bfc64ff6 bec024d1 bf36ee7d", - "422d5612 c135cecc c224002b c0836a40 3f0bfd30 3fd2bf48 3f762107 3f000000 -> 4058e898 bf411a76 bfb68041 3eaab85a bf996e7b 3e8897c4 3f0117dc 3f715983", - "c14fd0a4 bf22c600 c17192b0 3e9dd3c0 c0bd4f62 40656694 3d24f368 3f000000 -> beff75fe c0d75ce4 4082d09b bcb4fe19 3c34a7be 3e184c99 bdb90498 bf7ff000", - "40cb6f18 420bdb7a 423a18e2 c0802b55 beff9dc0 bfc16eb0 3f70ee13 3f000000 -> c05a7f35 3bd810da bfa0cad2 bf57161c 40a94183 bc275f6f 3ff91c8a bf0ad490", - "c22b4d81 41a392ec 423ce770 bfa3e2d8 409774fa c07e6f32 3f46714c 3f000000 -> bfdd6fa6 c021e2ac 3f2cb532 bdb4ffec 3f462d16 3f9d4611 bd304b02 3e837570", - "c240fbd4 421fd45a 42368e94 4072edd4 be9e9f10 408168ea 3f409e77 3f000000 -> be0c201f 3e503fdd 3f593961 beb7f078 bfceca04 3fd3e1ed c01a947b be971b5a", - "c1ad5e19 c234eb2b c1992a12 bf925044 408ec268 c0811449 3f11dc15 3f000000 -> 3ce1b4ed bf8e626e bf3702ca 3e813a39 bfef3d1c 3ee5ef0e bf8e2b47 3ea3bffa", - "41b11cb4 c2319747 c1daccd8 3dbfd100 3fbeaea8 c06a0c7a 3f499901 3f000000 -> bd08f86d be126b45 3f3e0a22 3f7b45e0 3e2fb5ee 3f3bd519 c073ca22 3e43df83", - "401448f0 c1b97248 c1cd9516 409d535c 40729590 c00a8b84 3f5c91a7 3f000000 -> c02190d3 c0074540 3fcc5f79 bf5d6668 c08b293c c0690647 4030083b 3f0085c2", - "419185b0 c218e79b 41d39378 3fe82ab8 bec18960 c070f0d1 3eb484b2 3f000000 -> bff7009f bf8500a5 bee6158c be3828fa bf6a662c 3eccb98c bf6cdf5c 3dbafc39", - "41168240 c12bcd00 41a77fd8 3ec9a8f0 40b14a60 c022edc0 3e8f8133 3f000000 -> bf4d6951 bfced089 3fd09f28 3e4b56a7 bf235d91 3faeeb49 3f05c7de 3ed2998b", - "41f18d48 417ab7a8 41d12f88 3f850ee8 c05e8ec5 bfc59408 3eb36176 3f000000 -> bfd29c74 3fd88088 3fe1c9a7 bed46ebc bf931609 3f5efd4d 3fb82d63 3f5cc8b1", - "416d82f0 41c49bb8 421a3306 c0306d62 40b5cea4 40bb4472 3efd1e3a 3f000000 -> 3f8d136e c0ac0e05 c0871c46 bf11f6d0 3f43d331 c06ed382 c03b8b60 3f524f79", - "415235f8 41aab240 4222a50a 3ff32d18 3e55d580 40961338 3f19f48d 3f000000 -> bf5d50c2 beaba634 c00d26d8 bf5a88cc bfb55d2e bf0ca9d7 c06757b1 3f055641", - "422bfc72 408d09e0 41cadff4 bf949404 40b76420 c05932ce 3e0260c0 3f000000 -> 3e1ad712 c0700bfc 4035036a 3e345710 3f873541 3ed84397 bf4514a3 3f2c6e39", - "4182b7f0 3fdb3500 423dfe3e 3ff98528 409c70a4 3db12680 3f38a282 3f000000 -> 3ef90c71 3fbabdde 3cffa967 3f70ef28 3fad5f13 4081ff52 3db1f9b3 bead0d2a", - "413263c8 bfec49e0 c18d8a1c 3fa248b0 40ac1f40 3e0a2c00 3d090b54 3f000000 -> bca80779 3e97874d be698984 3ed80cf6 400f1075 3fccdce2 c02c14f7 be947a34", - "c14cd5dc 421796b6 c13e9a50 bd739d00 c06779b4 40898cda 3f76729b 3f000000 -> 3dc4e9ea 401d4ac1 c064800e 3d4e6b1f 3f0e7a24 bd288139 bf8f7aa8 3f1baa65", - "418f6740 41f235c8 4215cd42 bf2b2258 bf9e2864 40096424 3f5f39ba 3f000000 -> be5562ac bf1d54e0 3f6bf72d 3f43aa38 be7cebc0 bf3a7b3d 3f8bd79c bf25145c", - "c21af350 c244d836 c1fd5079 c04d5704 c084cb9b c054b65e 3f7c2c02 3f000000 -> c02a3303 c06ce177 c052a8f5 bf0fe3fb 3fe753f7 4020fab9 400f290a bf53bc0b", - "c1d91797 422434ca 412c86c4 c0a6a1ff be700520 4051c5d0 3ca2ec6d 3f000000 -> bf1cff92 bda671ee 3ec4b46b 3f7e5aae c0ac3c44 bf369954 4057cba2 bde7da35", - "c1d68924 4105a85c c232ef2e 3f547b60 bfb8f8a0 3f50ae20 3f0ed843 3f000000 -> bd6ae04d 3e01e51e 3e889d50 bf7356a6 3e33b352 bec6c2fc bf510b30 be9f06e2", - "41841508 c14ba5c8 42234a50 405641f4 bfd89908 c080c7a1 3f7bf0dc 3f000000 -> bf3b659f 3ec0b685 3f5fef14 bca2d5fe beed41b9 3fcc95eb bf9ffd2c 3e6bca16", - "41ab7d88 c21fcf04 c1e179b7 3dfeaf00 407c2510 40861d2c 3eff6bda 3f000000 -> bdcb6bb1 c05d2a17 c0889194 3f1af01f 3d9aa858 402825d1 404fa971 3f4bca27", - "c028a180 c2101cd1 c14b29b0 4061d5b4 c022a6e0 c0ad68f3 3e12c886 3f000000 -> 40663b25 bf6aa5f7 c09d9806 3eca8ae2 3f001429 bfbc0b57 c013a1d4 bf1b5a3b", - "423b61ee 41da6f74 c0e340e8 402786a0 c09f560e 40aa08d4 3ee514bd 3f000000 -> bfb36e85 3f46f4b1 bf106e8a 3f005d21 3fa2e925 bff0bd92 4082f0a6 3ea0c372", - "c1e09e66 4200bc6e 42160ccc c0b94bf0 c09563b1 c00edb9a 3ee5217f 3f000000 -> 3f5e70d3 be3daa49 bf60e2d7 bf7f2f3e 40a22522 4058004b 407f97ff 3d6acf26", - "415844f0 c1b3e51b c09452b0 4062b54c c0a9938e c0bfa747 3f03a752 3f000000 -> c07e79d5 3f9abc5e 40b3b865 bec9329d bf4d4643 3fcc1b8d 4055427f 3f135eda", - "41f8079c c13085d0 40b23b40 3fe9b53c 40a2c5bc 3e812310 3f421804 3f000000 -> 3f9a888b 4048fc90 3f2853bf bea6db97 bf8b3b40 c06871cf 3f4b592b bf27064d", - "c0b3c8c0 418fb67c 41dc16dc c09ceab9 3e6fd6c0 bf831b38 3f32576b 3f000000 -> 4041fbf6 3f30df22 3fa02073 bf35b78a 40437cf4 3f323e29 3fa15e3f 3f3451ab", - "411f7b4c c004d920 c22fa918 c02da068 c055a0e8 3ee19bd0 3efd8284 3f000000 -> 3f9817c5 bf273561 3feaa15a beceee3b 3f36eacf 3f6dbac9 3fb6cd63 bd3d9141", - "c1b116e6 c17b269c bf359880 4026ec70 3ed8af80 c0ac483c 3f56a6d4 3f000000 -> bfc59e8c bf8b6c76 406a4bac beedc8bf 3d8c6f6d 3f194605 401f620f 3f57d242", - "4211d5bc 4227bfec 42478b8c c04f7fc3 c0adc1ad 3fc640d8 3e2238a6 3f000000 -> c0065870 4085e896 bddecf21 3ef51ec6 c001e4e3 c0942e30 3f93742c 3ecffd80", - "c13a9b48 4215507c c22d9bc0 c0821bca bf704af0 40115710 3f468136 3f000000 -> c0918384 bf52e975 4012a5ad 3c75cf34 bd8bbcac bc4a8a30 3d0cd357 bf7ff8a0", - "c20f1ece c21ffea2 422a7012 3f8c7660 40995902 4040ac00 3d116056 3f000000 -> 3dd24475 3f0257e2 3e94b0e7 3f7ee7e0 3f8dad6c 40afa654 40486001 bdbd2806", - "41ecb608 c12b84f8 40081f90 40813ce6 bedc1030 c0b8a6e8 3f0809c3 3f000000 -> c02fa8c1 beab3a7f 40960677 3eae650f 401e01bb 3f4be807 c061dff9 3f3e784e", - "c23557cd c22ee236 422dec0c bfab14f0 beba5920 40a129c8 3f14486e 3f000000 -> 3edf63e2 3f89ad66 3f62bc48 be82f506 3ecb6c7d 3fb2124c bf4d3800 3dd416de", - "41d036a8 41dcffc4 42109e0a beabf9d0 405b51f8 3eeade20 3e5d7f17 3f000000 -> 3f07ea04 bfa56fed 3ea81b0a 3f2ee322 3ece768c 3faf645c 3f384e15 3e505428", - "412987c8 4245f2a6 c21ae699 406671d4 40856e34 4028c024 3e0bb6ab 3f000000 -> 3f36a476 3feda490 4014acd0 becb2833 bf62aeef c0067f23 bff1138a bf226e54", - "c1cd9608 40d5cc60 c215a3ae 3fd0c7dc c0193c75 4068b26c 3d8cb1c1 3f000000 -> 3d10422e 3e40f172 bfb70337 3dd36d87 3e9b9b68 bf061072 3ed68cdd 3dae5656", - "402a1290 c00f66d0 c12ac7e8 3f7ffab0 3fa8dc78 3fc31a68 3eac67a8 3f000000 -> 3e849364 beeb2a60 beb11aa9 bf096646 3e28a9a7 be9596b3 be614fcc 3f5800d1", - "41f86560 c21387cc 41da0bb0 40ad9c34 404f0380 c06955a6 3ec38ca3 3f000000 -> 4051060c 4049a136 c06c3932 3d6e93ca 3ec49aee 3eeeeaf1 be2756e4 bf199aea", - "c18cfd0a c22e2df9 c2183993 c0944ff9 c05cafc6 407522c0 3e427d9e 3f000000 -> bed10aec bf8a4c66 be3b9a2f 3f4c99f9 c05992f6 bfe5ef19 40b04277 3b9e4922", - "c1234f94 c1125db8 c2396684 3fb34320 c01a0df2 bfa15770 3f4dba61 3f000000 -> bf06b0b0 3f9ab722 4015f0a2 bef806f6 bf0ed8df 401d45a2 4033805d bd94d008", - "becde100 41f71f74 41ca27ac c07e0eb0 c0932f6e 3e016a20 3e6f4d36 3f000000 -> bfd75631 c004ac1e beb4ac39 3f5e9e60 c03da0d3 c069aa76 bf1f1a4c befcccbd", - "c1a11363 c04affc0 421b7918 c0791c48 409de748 4091c1ec 3f4ba35d 3f000000 -> c082f030 bf2e5549 3fc22296 bea4b41a 4020d624 3f92c389 bef4f62e bf176b8b", - "42117a74 c17fb1c4 420b2de8 c0a2138a 3e90ae40 4043760c 3f6b5429 3f000000 -> 3f357a64 3fe93e1a 3f995c83 bf49b691 405b25af 3f11d84b bfe6e01a be9351e1", - "3e678500 c2456a1b 400dcaf0 c09e4658 40b9c7d6 4091723a 3e03bb08 3f000000 -> bfce6c50 3fd00387 3f9bfd05 3f75addb c0b03212 40b18dab 40852572 be8fe9d9", - "c22c5efe c1652dd8 423aa5d4 c01183cf c04dc713 3ecb62c0 3ea10842 3f000000 -> 3dea2095 3e3771af bd19b328 bf7fba6c 401ea6d5 40789d53 bf504d96 3d3cb169", - "c18e2f0a c2400dfe 41e254b8 3feac4b8 400e93b8 c087137a 3ccdb1ae 3f000000 -> bfee5ffa 3f0532af 40811089 be0c8abf 3ce87098 3f4b5598 3f7990fc 3f5a06b9", - "411a0808 c1d76557 422f40c2 c0187e55 40a8cf74 bfa217c0 3f08c39f 3f000000 -> 3fa8459b bf44e415 3fac528a 3e6f3f61 be2930ac 401bd788 bf1e6729 3e589a03", - "c22caafd c1f928d8 407832b0 4053dc44 3fd7bc78 40939954 3f7e644d 3f000000 -> 3e1e1f8e bfbbd6ee bf3cd4af be587210 bfc0cf54 beac3507 bf05c38c bd7a7df4", - "41f1f3ac c1d791b3 c22773b6 c08cf745 3fca6460 c097a92e 3e6b17cf 3f000000 -> 3fb2c595 bf287dd8 3ea01096 3e248278 bffb4423 be4af11d bf458e45 3e88ae50", - "c21b6485 4228d344 42120b42 400995a0 bfebd108 be6a24e0 3f0a9adc 3f000000 -> 3f0a5e61 bf117da5 be163445 bf6a971a bf9e5cce 3fa68385 3eabe881 beccf8ee", - "c18fbce6 c22dfc75 c0efbca8 4081c10a 3fa33a00 409759ea 3f67ef0c 3f000000 -> bf3f410e bf22565c 3f2ec5e2 bed5b35d c03d3bcc bf0b39ee c00f3505 be7c1db3", - "41dc9120 41066fb4 41e51bb4 c0af079e be40fae0 3f9102d0 3a428d58 3f000000 -> 40858dd5 3fa1c560 bfc5d334 bf01413a 40289b75 3f7b7b03 c01d7e4a 3f0b485f", - "c204b70a c0e6eab0 405ddf70 3f8cb560 3fe47360 c009a082 3f05139d 3f000000 -> 3e0506c1 3fb50296 3ddaf7a8 3da04aa2 be4289ee 402cda41 c04a45dd befee595", - "41e775b8 41a13c24 3fff4440 c0ab4f3c c0af6a4b 4062f6d0 3ef83151 3f000000 -> c0938b46 c0791d1e 402f4bb1 3ddd00cd bf001f3a bed8524c 3e983873 bf7e814d", - "c1990bdd c22aca80 4143abc0 3f8f0ed4 409ecb36 40bd3d24 3f3f7d18 3f000000 -> 3e7c42ad c02acd31 c02ad591 3f5df0f6 bedb68e4 40948f0c 40949653 3eff2bcd", - "c21697f6 c21a8540 422f2efa c0b2df61 40bc3f6a c09e501f 3cdafb54 3f000000 -> 404b0750 bff7ce6c 3f54574b 3e692377 bf9b078c 3f74d3af 3f4e90a2 3e170af8", - "416a6ce0 c1a40321 c224844e c0875f12 3e02c380 c050400e 3f717c7e 3f000000 -> 3f5bfafd bf578513 3e09b82a bf210791 40546be4 bf3e6ade 3fbb2d42 3ea4603f", - "bf13d980 c187a568 c224fbf8 4017ddcc c08280e5 c0b7b521 3f07efce 3f000000 -> c035c7e9 4046f7b2 408de22d 3eda80e7 3f27ddb6 c0458a5f c0085163 3f5ebdad", - "c15a6a20 42220e4a 41e33738 3f41c650 c09a217d bf71f350 3eef1ccb 3f000000 -> bf9232a6 bfd661c0 bf881c2f 3dd9ae5b bf511ebb bf7d8751 be02f9d2 be208642", - "3f8ccd80 c2065d14 c09c9e60 3f596790 3f9c0e48 c03de55e 3d3713ad 3f000000 -> 3d8701f5 bf856906 3ee69b79 3f589fb3 bd5be9b1 3f9dc717 bed7dece 3ecce28f", - "c194b02e 411abbf0 40b7bf58 3ff375b4 c04d0045 bda99740 3e123c80 3f000000 -> 3fe78ed8 c042110d 3ef8a224 bf318c2d c036b693 4081fc19 3f83136c beb7e53b", - "c1158174 c0dc0c78 42229080 3ec7f980 3f4cdb70 3efea3f0 3f5080f0 3f000000 -> 3e73860e bd68f779 be9c8d3b 3e9f1250 3d9f3286 bc984bc7 bdccaeef bf7354c9", - "41c2106c 405e6e80 421e2858 40429838 40b4f244 c0595821 3f429101 3f000000 -> bf08a4d0 3f0467fe bf3d3d16 3e670e91 3d3e3def 3ed61720 4047141f 3cdd6ce6", - "c1e92711 c20a6ca2 c038e830 409660e8 3fffb930 3f377180 3e0ac49b 3f000000 -> 3f558c3c 3f2b69c1 bf308c3f 3f2c6b1f 4072bb10 3fa110d8 3e8db4f1 bb866fe9", - "c213a47c 415c3df4 40f57130 409d128a 40b6d2a8 409910e6 3e38682c 3f000000 -> c0609695 c0375c02 c08b0570 bf2306eb c0194810 c0870187 c045b923 3f3d16a2", - "41bafc9c 4040c1d0 c2384dcc 40a3ff3e 3eaf13d0 bfabbbf0 3f74f97e 3f000000 -> c09ae81a 3fbb6006 3f9d6de1 be502d30 bf6b220d 3db0f756 bed9d3fa 3f554e4a", - "c0270280 42170b1e c23bc9c1 3ec43160 4091d758 3fea50c4 3f44b72e 3f000000 -> bdf61ce9 406c7377 3fccac48 baeddb4e 3fab5485 3db1b1bb bfd68e22 bf307c0c", - "414ef014 40b21ee0 41fde9c0 3fc84534 c0b2469e c0255f52 3dd83a99 3f000000 -> 3d054e09 bd9dbe7f 3e93b33e beed3ddb 3f6c8450 407824b2 3d04c278 3e29c43d", - "c0b72308 c2257991 41d5836c 3f4c8c90 40a66b74 c0bd330a 3e8d23ff 3f000000 -> be960ca6 c0053936 3e27d95c be06b313 3fb1cec1 bfbd90a3 bf792711 3e1a0b33", - "41eadde8 c1883b50 41459bb8 3f8b2318 3fdb6564 3fce6960 3c10f1a3 3f000000 -> 3e2a07ce 3e976bc2 3e862015 3f7ac176 3f4ec396 3fb8224e 3fa31a12 be4e34e9", - "c2462536 420e7624 42028568 bf2ff7c0 407c85d8 4068c688 3f3c1252 3f000000 -> bf98ace4 bffc1d44 c0491ccb 3e8a3a95 bd352040 3f921df4 3ef19767 3f2e5386", - "c1b2ef80 c0be2610 c16083bc 405c2de8 409c59fe bfcc2428 3f006614 3f000000 -> 4005d507 404199d8 be0bb2fe be922beb c0366336 bf9059ee 3d024f4a bf452778", - "c2273460 41cf728c c1b112be 40a91946 3faf023c c0a363ec 3e94f933 3f000000 -> 4085d5e3 3f12b892 c073a0f3 3f26a5f3 40658a97 3efba42a c050ec85 bf42549f", - "c0b3d290 c1b61f04 c15f370c 3f921720 bfb6efc4 400b367c 3f2e2988 3f000000 -> bfa65b5f 3fa0ff42 bf233ab0 3e6e63eb 3f0c7d89 bf44156f 3fcdcd5c bf00936d", - "40994630 c114c2bc 42308a12 c04a0406 c0b90626 40475a34 3f1fec4e 3f000000 -> bf19ea83 bf56db87 3ef47061 3f7cc248 c06f8376 c0a72c5c 403e3083 be226d82", - "419f9b74 42446f7a c1f9de1a c0611312 be625da0 bfc641f8 3e2a6f08 3f000000 -> 400ee70d be6ba7b2 3f33d83e bf22f77c 3febeadc be42856c 3f1473dc 3f456d95", - "41692cc8 c114756c 41dfea20 c0b5ee8a 3fd75800 405283c0 3f362b17 3f000000 -> c05275e1 3edb82ec bf503b09 bf580669 40930788 bfe983dd c0866d83 be87e41f", - "40e14890 c1783ecc 41705b40 c0b4e735 3f37f220 40275588 3f0f92a2 3f000000 -> c098015d 3f9e4ea3 403885e9 3ed705d2 c00cae84 3f12839b 3faac6ed bf685485", - "41061698 c05acd50 420b0b0c bf200920 c09137fb c0ab22d1 3f3a7a8c 3f000000 -> 3fac4705 405d74ef 3fc6b2e6 3f1823a6 bf7c495e c01de987 c09a3534 3efb88e0", - "c23a9414 c102ac08 409f2568 40956024 3fa5276c 4090b6aa 3ec3d45c 3f000000 -> c03644f7 bfc427a8 c068d345 bf289191 c033cf05 bf5aef0d c070d206 3ef8745d", - "41d6939c c2239a52 41babdd8 c08d2c84 401c5920 c0902ebd 3f4c4e64 3f000000 -> 3f6d1340 bfbaa59f 3ebe7a7e 3d867d94 be1b76eb bf281843 be7ba74c 3df2a956", - "42120dd8 4100f4b8 40dc7408 4038dc1c 409c595e 40b3fdaa 3f7a3d3f 3f000000 -> bfc33673 bffef515 c03c889a 3f270b90 4074c748 408c812d 4083588d 3e5d753d", - "c22f20fc c1a7197a c1e98d2e bf002348 c0affda8 c0a7797e 3decf621 3f000000 -> 3eec79c4 4099377f 406dddce 3f115d84 bea3210e c0536376 c02416ab 3f52b98c", - "4021c4e0 c17fe868 41cf392c bfd76bc8 c00cdb5a bf3e7170 3f1cb7da 3f000000 -> 3f2dcc2a 3f315cd7 3f09d94c bf19b99a bf9c3b88 3f07253b be70219d be6aa357", - "42438da6 c1d7df3c c2111ca0 c0b373da 40988b36 c0033d45 3f4d5bb2 3f000000 -> 4012b7e4 3f5c743d 3c8db636 bd901a7a 3f8ab549 3eb60a09 3fc49512 3dcd570a", - "c1c4eac1 4226b7e4 421e9d8a 4088d1b2 3f8f6600 4049ccb8 3f37fac1 3f000000 -> 3f3d1fc2 3ea8dcef 3f66ca8d 3f7646e5 40269fb6 3f94c5f7 404b5579 be8bc43e", - "421a15fe c1b106e9 41a5c304 c05b22b2 c09f207a 4040b7e4 3f78ac19 3f000000 -> 401a7e7d 406f51b9 bfdd05ac 3e8588b6 bef1ea6b 3e268e1e 3fbae05e 3f581092", - "c2151e44 c17d52f0 c0ddba10 3f4a3c20 40706050 c0331dc2 3e78c661 3f000000 -> bf1b45e1 bf02a724 3e3068a7 3f672b51 40029c9f 4055188c bfdd893a 3e2cd55a", - "41c8bf8c 423dc256 41da160c bfad9708 400f3ee4 c0713c62 3f60520b 3f000000 -> 3ff3a6ef c01c8623 bf00ae11 bf0f27cf 400efeae c01a4744 3ffdc24a bd54a470", - "c16f4cd0 c0daa6f0 41a66bfc c0bc31d8 3fd67130 c0795b57 3f4eee55 3f000000 -> 409b4569 bf558889 4035a6c3 3f3c6aff c0a8cfb3 3f68277a c0457df7 3f2d4e1e", - "c1491284 c196c840 41232e90 bf1eb940 c018bfb3 bf9e27f0 3f23db16 3f000000 -> 3f7f5350 3f838185 3fa294d9 bf1ee30d 3e5c5e79 bfa98a5b 3de4aca0 3d74a95a", - "c22f76a5 c23344eb c20df755 c04e9a64 400fabc0 3fd84688 3f5c96fd 3f000000 -> 40692189 bfd19f2f bf6b430d 3e8f7457 bf7755c8 bfdd4632 3f8d9965 3f6983dc", - "421b651e 41a53544 c05432c0 c09fa4f1 c0a80fc1 3f35f930 3f00bf43 3f000000 -> beea3767 3fefb99c 3f8ccf09 be2a0d41 3e1760b8 3f94851b 3ecd7130 bdd8dab9", - "4230f58c c2166d7f c04463c0 409c3a0e 3f6c2460 40837d10 3f08e72a 3f000000 -> c01c16d9 bf07400b bfedb2cf bf27bdda c07c9495 3f425d8b c0178264 3ee3df2e", - "420ad16a 4247ab84 c1ec31a2 bf25e630 3f684cf0 c081635a 3f40bc64 3f000000 -> bf6bb447 bf53d21f 3e84eba6 3e5d36f7 3f1bfc0a 3fd5cb13 bf978f7d be81d8e3", - "c23bf09c 42037d1a c219000d 3e120000 408dfb1a 3f9e0710 3f30893b 3f000000 -> bfcc7bb5 bec50c07 3eaf8922 be220b89 3e3c8770 bf9a0da0 bfc9e61d bd94d272", - "42290740 414c0974 c2099996 40bfc992 3f0a8170 c0ba676a 3eec84b5 3f000000 -> 40441441 bfd4da9c c018e65b 3f6ae859 408ffe01 3ff9e5cd c08eb6a7 bec5f101", - "41b42100 c1cf0dad 422a4290 3f6d6070 3fb24cb8 c01572c8 3edd262d 3f000000 -> beef1c7a bdcfe77d 3f564c05 bf2dbd7f bedcf473 bdc01e16 3f46065a 3f3c0450", - "c1f9ed42 c212ee20 4084c5e8 402c3734 3f27c7a0 c097921e 3e5b707e 3f000000 -> bf819ee5 bea0058d 3fde8951 3ec594a4 3fd7a293 3e0c6676 c0415a62 3ead3500", - "c232f06f 4230217c 41e3fdc8 c09533bf be88b040 c096381b 3f5bbbfd 3f000000 -> c06f242b bf14e793 bfc4ff22 3ee388d2 c0392aab bf64486a c039cbce bf168559", - "42171d88 c1710c80 40e79c20 c06c15b7 40af3d62 4070a218 3ca26c6a 3f000000 -> be6a59e7 3f6608c5 3ffb9f73 3dc14ee9 bf84c37f 3efa15df 400c80ba bd8df087", - "beb7ed80 c195594f 4222f52c c0b3cba0 407bc8f4 c0a408c9 3df99e44 3f000000 -> c0a288e1 40708608 c09d54d0 3ed96bd0 c01878a2 3fe1a1a0 c013970b bf67c57f", - "41ce64b4 c1b0b6c0 42137d78 40b07670 4089560c c0098416 3f57b1ee 3f000000 -> 409cba32 4044130f bfbef7a6 3efc4b56 40318153 3fde1194 bf5848d9 bf5ec312", - "419cd674 40f339b8 41e61d2c c00dfbb4 bcec1e00 be97c570 3f5eb300 3f000000 -> bfa4ebea 3e859d5c 3e755616 3f1e14e6 bf817970 3e51caf5 3e409af2 bf495c61", - "4195c1c0 c14e61e8 421b328a c0a624ce 409bd0b0 3f9f2634 3f58ed6d 3f000000 -> 3f937937 bf6a804a 3b690f70 3f7a8584 c0af5603 408b6729 bc8a8bf6 3e52b61d", - "421cbc4a c16ac3d4 c13885e0 3ff55734 bdc29c00 bf8701d0 3f30f16d 3f000000 -> bff16ed0 3f48f783 401d00b8 be5a52d8 3fdb6fb6 3b230683 3f603255 bf0297ea", - "41ff7d0c 41568e44 4199f70c 402e28f4 c0b38955 c09c837e 3e96ddb7 3f000000 -> 3ff7467f c08bec22 c06b205c bf1a5df9 bfbae8e8 4053873e 4031ba08 bf4c38f2", - "4180f9b8 4226816c c20b3bf0 3fb87bc0 405d13e0 c0b9f0eb 3e3a1a5e 3f000000 -> 3ee60b4f bf9b697a bf6b936c bda6b11c 3fa4d0d8 c028f33d 3fc6aa15 bda01ac2", - "41daab54 41e3c9dc 4216fd1e befd6810 bff8ca78 c0866f6b 3f4f287e 3f000000 -> bf78e253 bfe0c602 bee3de0b beccb74e 3fb6d047 bf19d2b0 4008c649 be462eb9", - "4230ebd4 c2403d60 4239c78e 40a213ca bebd2560 c02d2cec 3f5dbc34 3f000000 -> c0bf4bfc bf8ed97d 401ee005 3f1971b3 408f3ecd 3f55ef55 bfedef63 3f4ceab3", - "422a5594 bfcc21e0 c1a026ad bfce7e18 409cfe68 c085df3e 3f606e87 3f000000 -> c02d78d1 40a81587 c0586130 3de16393 bfbc01ea 401f46e5 3f9472c3 bf79e8d7", - "4230c3a6 c221ecf1 410d5e50 bed62c80 bfb3e364 3f6731b0 3cd4cd10 3f000000 -> bbdd1df0 3cc38920 bd02a4ba 3f7fa877 3e058efd beec36ce 3f1dd271 3d53a192", - "c090cf30 41bcdcf8 c0a8df38 c092b93f 3f86e9d8 3ffe6900 3df2b147 3f000000 -> c0a8149d bf85af97 4003f5b3 bc90ae16 3f003f8f be7cff91 3f8d1c80 bf64ce2e", - "40db50f0 3f385a80 c1ef3909 c084d7d2 c036a212 4092ad64 3f6086da 3f000000 -> bef5fbc3 bf9d8919 4003dcd1 3f1ce771 c06da7a2 c0146115 40588b76 be543cc8", - "413783c4 41b667f0 41f3c170 3f424800 407425f0 bf5ba028 3f3c421a 3f000000 -> c015292a c0219f94 3f821a9d 3ebf7882 bf47c247 3fbbab23 bf04da17 3e1452c5", - "c0d8ec28 420cd766 c1c45dde 40918b88 408bee54 c015b7ce 3f54d854 3f000000 -> bfb50e58 bedc5db0 bf3c38a8 bef299df bfb7a02f c0241e8f 406e8512 3dbd8bc1", - "4197a3bc c1a8b4e9 42457220 40aec63a 3f6552f0 40598640 3ef9a0ed 3f000000 -> bfaf855b bf010a7a bf633e16 3f765eb0 409b6d80 3fe48991 40493a79 3e8b1c20", - "c1ad57b7 3fdc6ee0 41f355d0 40927334 3fa73d28 403e3220 3eb6eff5 3f000000 -> bf6d0f7f 3e4f7034 c0833b58 be18dcc9 bfb9ada4 3eb4ace0 bf8ea70f 3f198fad", - "423ebd88 c22076d2 c1e6cab8 3fe13dc0 c0311946 40bfdb84 3ea78895 3f000000 -> 3f0821df c0431559 40e07c7b 3e483e55 3dd92881 bf1b9935 3fb30cd9 bf7b0ebe", - "c15483a4 41e2edb8 4220c264 3f47a178 c087a5c5 c020d313 3cb89c14 3f000000 -> c000b46a 3ed9bd91 3f8b13c6 bef25c20 bfa8218e 4034d6d6 40147392 3e9c6f34", - "42199716 c1f5d9f0 c1d0e49e 402b9848 bfd62764 c0238681 3f610546 3f000000 -> c02dcfc8 3fabac9b 3ef7a840 3d98d223 bfa0e9c0 be35a763 bf35cc8c 3d489da4", - "c1e18843 c1ea1d4a c1f0de9a 40100934 c09a15bb bfa9b9b0 3ea9a9fc 3f000000 -> bfedbc48 4041fa37 3fa3c95f bf2ce41f bfd9b49b 4031a25a 3f95fcaf 3f3ccc46", - "c1e75efe c247ca30 41917d6c c05f78a5 400ae5d8 bfbb4348 3ee9250f 3f000000 -> 3fbbc938 bf63c8c9 3f5c342f bf6d0d7f 406647ec c00baa52 40070473 3ec14ee3", - "41ca9c70 c236c993 c1d61825 3f91ebd8 c0156ed7 3d4f0700 3ea50dcd 3f000000 -> be2ded4d 3f293293 be97a457 bedbf082 bda57901 3ea0f91e be104557 3f672d3b", - "3f0bac40 c2235044 c12fbf78 bf5d7ee8 bdb4d580 bed6e9f0 3ecc771d 3f000000 -> bcc0b1ef 3b6388a9 3e1d37ca bf60c54b bd30bcf4 3bd0b11f 3e9032e0 3ef5107f", - "c18c5f22 40d0e9c0 c208d1fb c0414db8 bef23af0 be853f10 3f423e80 3f000000 -> 3f9f5cd2 bf89a54c 3fb99ee5 3de3410e 3e101ef2 bcacae0e bf22ac7d beed1c82", - "421c97d2 c242f60f 4237a34a c07cedd0 3fa927c0 40be66f4 3e202557 3f000000 -> bf7861a7 3e63b5ad 3fc16f81 3f7971d1 c0868b6f 3f76b1b3 40d19003 be663f9c", - "41e28214 c1dff8a2 c16675e8 bed18b00 409e6748 3f4e5c30 3e05d941 3f000000 -> bf52ff06 40809974 3f97be2e bebe104e 3ea8b4bd bfcda5f1 bef2a865 bf6db52c", - "c20c2366 c245663c c214a0c5 c0aad26e 40593d60 3f2dec80 3f366ed6 3f000000 -> c0a9bbed 4081e8c9 3f70011d bd97cbb8 3fa470e3 bf618115 be2e2972 bf7e74d7", - "c219be60 41f70120 c1c0480b 3fa2f66c 40a30034 40a5e626 3f62e153 3f000000 -> bf2663c1 401936d2 402ec5b1 be1913e6 3f3aa917 bfd2c7bf bf59a145 bf07d43a", - "c0cf3b38 40190b00 423849a4 c056d2cc 40998320 4016fc14 3f5c9db1 3f000000 -> 3f8dc83a c00b68e5 bf262904 bc704ba6 be832c7d 3f8554e7 bebbab2c 3ed4df04", - "c23bd384 c1b55ebb c0f22070 4015fd48 3dcdc700 c08043a7 3f38ea04 3f000000 -> c018c7ad bf2c4c08 407497f6 beaa6cba bf57b810 be7346b7 3facad94 3f7166e0", - "4214ac0e c23a5265 4238cd32 3f762b10 4098c5dc c031b044 3e33140b 3f000000 -> 3f186dcc 3fceda1b bf6f0696 bf6efc3a bfc678e3 c086aad3 401b9d09 beb78b1c", - "40bc1ba0 c23c3137 c1f57a92 40087b40 40a1ee80 c0ae4880 3f469d92 3f000000 -> bf044bd6 c00a237b 3fbe7e23 bd559266 3df17c0d 3ebf6267 beab2ba6 3e1930e7", - "c1eced40 419f8ea0 40ce9fc0 400e9378 c0a77f34 c03087fa 3eb21f49 3f000000 -> 3e805e09 c006be5f c018befd bee68d6d bea44c27 3f51fce7 3f0d08c5 beed7183", - "419ce5fc c1279c7c c1cb8284 c0bb1bd8 408e4d7c c0317624 3df42990 3f000000 -> 40d473a6 c081f15d 4030a9a7 be3a28c4 3f9d1c13 bf402ff7 3f02a4b5 3f7bbbed", - "41ba9240 41a34694 c1603c74 c02d30d4 bfa7fb28 40bc473c 3e79d0d3 3f000000 -> bee94a00 be985718 bf196cf0 bf16564e 402c7e7f 4007a505 c03c6075 bdedd750", - "41dba5ec c1a1e26b c23d9d70 c0b5c5a8 3ffaf928 402254f4 3f605f74 3f000000 -> 4084be0b bfd1174d bfcbd2f7 bf1263c7 40390e1e bf91bf04 bf8e1329 3f5203ae", - "bf0f8640 41d60ddc 40883ad0 40b794a0 3fe71a28 c09effd0 3f539b97 3f000000 -> bfaffc52 bf5a47b6 400b5847 bf5a7b6e c09c0249 c006d443 40b5fcb9 3ecc4088", - "40ec4a90 420fe7f8 c244238f bf2a4d88 40980056 bfc0e1c4 3e33c544 3f000000 -> bf78cc22 3fb49484 3ee7cec5 3da1eb09 3fad4658 bfa8db20 bfa7d7cd be97247f", - "415e52ec 41ad1ce4 40d7aa40 c0b5879f 40bfe2f0 c0aaa047 3f535887 3f000000 -> bfee62ad 3ff4ec56 3fa1a4bc bf0ce290 401452d1 c09c6b79 403f20cd be2b6ddc", - "c18ba900 420551d4 c11ad980 3ebed490 c0aa8fba 3ec3e0c0 3edbcac5 3f000000 -> 3f97c9c0 4046a558 3f7d2b66 3d81e967 bd866e58 be7c9574 be25dd5b 3f239634", - "c11d1de8 40771690 417e6ad0 bf98f5f8 3f348c58 beaf7b70 3e4e9226 3f000000 -> bed036bc 3e08ad66 be6dbc71 3dafba24 3d0f7434 bc3c556a 3ca3cb5c 3f7f0e4f", - "414c47cc 41a26ec8 c23a227d c056f220 c0737683 c01f432f 3e2332b7 3f000000 -> bfdc38b8 bfb54418 bf5928c8 bf3104a3 3fe251c0 403e2bdc 40401d65 be090696", - "4209bb50 c16fae3c 4203f8aa bd7f9000 3fb1feac c0a5bbaa 3e0adcc1 3f000000 -> 3eb143f3 3ffac051 c014a408 bdd44645 bf05c2ca bf2d7f49 3f86124f bedb4630", - "41020160 c08495c0 4247bf62 3ffb6d68 3fef2b00 c0ac759c 3e2d0629 3f000000 -> 3f9dc932 3fbc95ef c0a53cd9 bf137fd0 bf5e758f bf84f10b 4068f71e bf513c94", - "422db51a c2104247 c0a98d80 3f915910 3f261120 bf9dbac4 3e302b00 3f000000 -> bf0924bb bd9c4a69 3f16e273 3d8961a2 3d1386ed 3ba81f49 bd224eee 3f7f6c61", - "c18f12e0 c16ef90c c2365760 bffa44d0 409abf46 40b5f32c 3c38c3ab 3f000000 -> be853e27 3f811c8a 3ee21cfd bece44f5 3f41eef9 bfafe117 c0893e6d 3c98ccc6", - "c242a8f3 40517c50 41f5b700 40733c64 404a02a0 3fff4718 3ef65227 3f000000 -> c02dda72 bfd30ff8 bf89d51b bf0a1a18 c03d3488 bfd45a81 c02d2396 3f448659", - "bfd853a0 40ea87b0 c2397f13 bf387b28 bee064a0 c01e7568 3f520f7a 3f000000 -> bc240b38 be52e55c bf0fd68e 3f725341 bcf0c64e bf1ac56a bfd31e3a bea51997", - "c227fbe0 417f6d50 41bd6194 409ac6cc bf7410e0 c0b36b81 3f31831b 3f000000 -> 40a2c131 bfc09ff1 c0babbbf 3e2e85ed 3f613468 be8544a2 bf81312d bf7c412a", - "40cbcd60 410c3cd0 4148cac8 3fc60a68 4097cd18 40bb22e4 3f05ee90 3f000000 -> 40085878 40936972 40bb20cd 3e32fc7e 3ec1a31c 3f515a7c 3f84e10d bf7c0f1b", - "4247d2b4 41e4a010 c208e7d5 402380c8 c09baed6 c09041ce 3f11621b 3f000000 -> 3f8e75e3 bfa2086a bfa3c375 3f1f1939 3fae7dd8 c03ec76d bfc1c893 bd28b1a1", - "422a5582 c1f6383c 420aca60 4096c970 bfb11d80 40104964 3ee6ffa1 3f000000 -> 4067264f 3c19936e 3fa74666 bf0672a5 c045dd09 3f849cef bf094798 bec147d2", - "40d36610 c10eca74 c20a20c4 c09d3791 c09833fd bfe41c58 3e76e785 3f000000 -> bf353260 bf08f646 be182f0f 3f7e9763 c0d7036f c0a285ef bfb495f7 bdd68ccf", - "4198ccd4 c19a1053 c0d332a8 be57d3a0 40a95eac c00be024 3ee63a16 3f000000 -> 3f2205eb 403ebadc bf487752 bf4465e8 bf41c95b c0641f00 3f6fc41a bf2434e3", - "42320892 c1feae66 c1f9c684 408d3438 40095dc0 40afd7c6 3ef792cb 3f000000 -> bfe8ace2 bf5b35a5 c0044a07 bef8ad56 c0153a3e c010d751 c016a53b 3e35bfd1", - "41e601dc 421768c2 41b5a474 bfc95dd0 c07df1ce c03df7e4 3e1de7f8 3f000000 -> bfd25bca 3ca5561d 3f9306d7 3eb216af bef1b3a8 bfc39485 be42ec99 3c62a2db", - "c05088f0 421be66c c243d816 c0b23abb bfee40cc c045f621 3f7f646d 3f000000 -> bf705371 bec54772 bf292b6f 3f7af7f9 c0954746 bff5146a c05228ce be4a04f7", - "c2013e30 c03ac890 40757420 4060022c 3fd0a7e8 c02761f4 3e9dfb41 3f000000 -> 3f229860 3fbbb9cd be2e986f be09eb42 3f0cab3b 3f16b897 3f5d86d8 bd017017", - "c00a7cd0 41b2fd00 c1d7a213 c0850d82 406b5c88 c0929868 3f7b1287 3f000000 -> 3fbebf76 c057717e 4013c62d 3f2454b6 c036cf71 3fea6b3e c068b1c1 3f2ba4d3", - "c243c4eb 417eb688 c23e0491 401e1380 403099d8 40b391a0 3f474f40 3f000000 -> 400bfacf 4083cbf9 40a2e376 bf0e5734 bfbb47fb c0305543 c059ee64 bf54c792", - "404e4a10 c0e797e8 41b157c4 40a6c4ea c09a0b24 c09ea02b 3e64f321 3f000000 -> 4093444d c09ab7f9 c0659141 be4d1fc6 bfbabc58 bed4cacb 3fb73ce6 bf4a6663", - "c103ba54 c0f471f8 c0aaf5b0 3f93bb80 c0a2f502 bf135898 3f44a829 3f000000 -> be060f36 bfb4cb50 be42d2df bc376352 bb8d8407 3cdebcc3 3f15e1a3 bec043f4", - "41a8aaac 416f15f0 c2299568 c0af7b1a 40071180 c0799cb0 3e9e489d 3f000000 -> 3fb918ac bfc7c10e 401fcde3 3e2906a8 bfdf07fa 40083c98 bf5fde91 3e25d9fc", - "c20a15bd beae5e80 c1e3af64 bfd29cb0 c08c638b c07ac99a 3ee9e6dd 3f000000 -> 3f4391ef 3fb0e78f 3fec0d2d bf4b4b1f 3f5775ae 40749efa 4042f9ef 3e8dabfc", - "c1d78e6e 42422c7c c187f954 3fb08b84 c02d1963 c057c07a 3f250871 3f000000 -> 3f6c5286 bfd5ad0c bff00194 3f5cc47a 3fc945d4 c035fc30 c04c6901 bf019b21", - "c236b98b 41fd56c0 420ef404 3ee35200 c06a219e c09f5ebc 3d789758 3f000000 -> be13c42d c0408230 c03d0f4a be571e81 3ec66089 bf45a439 3efd7cbb bf3b845d", - "c19fe682 41e31b58 40b77378 4031468c 3fff4aac c05cc0e8 3e9977ff 3f000000 -> 3f9c3314 4011b56f c01e2cc7 3f19ad40 40204e76 40868514 c018c422 bed35d1c", - "c24417da 423390d8 41823f70 c0ab3bd4 4060bff0 bebbf960 3ec14078 3f000000 -> 409a37d3 c042455e 3f2cd0ce 3ed1ab70 c05074fc 3fa60dd1 bea3210b 3f2dd460", - "422c69c0 3f20e500 40e484b8 40b25868 409ec4a2 404cdc10 3e3f9b39 3f000000 -> 40a1be65 40973bd8 4064ae91 bcf040e4 be17dc3a be0dfe13 bdd6b547 bf7fe3cf", - "c0c5d5d0 c219620c 42407f2a 40672f60 c04d15ab c090906b 3f2aeacd 3f000000 -> 3ee65e0c 404a626b be98913b 3ebc7b04 3fbd4895 bf49ff12 bf401597 3eb5dc34", - "42051a1c c1e112d7 3f1a1b80 be6cce20 c09d6f9c c0412f74 3f5acb36 3f000000 -> bf8205c5 bfdb21ff bfd37e40 3ed876b8 bf58e3a4 c01c8d91 bff37350 becc745c", - "41aa2b2c 417ce778 415349cc bec36360 40b0fba8 c083acda 3e62161c 3f000000 -> 3f360908 c0a390e1 40295271 3edb639f beaca7e2 401b235b bfa098fb 3f674eb1", - "c239645c 4185c73c 40c2bfe0 be5d9540 403fbeb0 c032c761 3de5b1b4 3f000000 -> bc78e501 c0333266 3f388fc4 3dc4e1d2 3fcc0c35 bf8872bc 3e297f0a 3f3ccabe", - "c197b069 c1ab3928 40e82f58 c027aae2 c00b9984 408f73fa 3f5ca89f 3f000000 -> bf12a568 c0016e70 40308da9 bf1e4ef9 3fe10fff 3fe796db c043ee39 bf080e8f", - "4185df70 40f37a38 422bec12 bf4d13f8 c09dd009 3fcae72c 3e3542a9 3f000000 -> 3fd461d9 3ed7c63c 3f59fdc4 bd28239d 3f63ee2f 3f59ad7c 3e9780e8 3e804315", - "41b83484 c20948b7 40eab878 401b9f2c c0564fb7 3e8bf890 3e5f8fc5 3f000000 -> 3dff97ed bfeb584a be2988c0 3ee1ef26 4009072c bfc1d168 bfd795dc 3dc08d3a", - "420b49b6 422fbe24 bec06380 40adc8fc 3fa86b80 40b311ea 3ecda5ee 3f000000 -> c07e66b9 c0059c3f bfd74385 3f16a1f1 402bfc8a 3daf08b7 40a89a12 3f104404", - "c0a22d58 c0fec698 c190c199 be4d45c0 4088d346 3f2a7710 3f05b9cd 3f000000 -> bfa7a613 408ae9e2 3e373e20 be1b2bac 3e4d9c2b bf2a5e44 bce0bc21 bf7d0b32", - "422d1328 422d6282 c1f0c36c 4050ba4c bfc02ed4 40bd33e2 3d39d5b1 3f000000 -> 409edc90 bed8a956 40a231dc 3e2c166a bf68567d bfc54d4c 4007a02f bf76f711", - "c2273568 41a1ccc4 c23a0489 408ecbb0 3e9995c0 c0af30b5 3e9cce91 3f000000 -> 3e873f98 bd71677a 3de51ebb be84e2bd bfffcb88 3f9cbd06 3f4ca756 be08b640", - "3f858ac0 424300ee 41df77d0 3eb07340 403bb98c 40973b68 3eeca164 3f000000 -> 3dfaa501 be582042 3f13be1b bf6061ff bf1cffc1 bff35d69 c0750801 be4dc4d3", - "c1756ae0 c229794e c188b4b4 402030bc 409c6210 bef3f840 3e5f40ff 3f000000 -> c040e02e c07f14e7 3f1d72ed bf111cf4 c004b64c c02f83a2 3ed8ac06 3f52e607", - "c209b7e6 41313378 4233faaa c04d469d c0a29518 3fed8930 3f4c2d81 3f000000 -> beaab748 bed3efd7 bf545af8 bf04ebdb 3f9c37e7 401c85c7 3fb13d8d bcbd0dfc", - "c1dd5675 c1491cec 422c5734 4084e3d8 3eb8ba60 c07b2c3d 3f442865 3f000000 -> c04595bb 3ee6196a 40292293 bf381f14 bfc6c159 bfc82800 4019a52f 3f20c6a6", - "c1d2507c c077c3e0 c227b828 c09f7e7c 40a242a0 c09b5e7a 3f705ae0 3f000000 -> c090b276 40a29943 c06f2e4e bf0625d5 40320ccf c04813f3 401327fe bf5a099d", - "c0d6ce00 407e34b0 4235d490 c0950981 3ff84dec c0a8e257 3f1608e1 3f000000 -> c03c00ac 3ea1ef7f c041bc69 beead960 40181511 c00c665c 40940081 bec47b0e", - "420edbd2 4213f8a4 c22eb859 bec6dc50 3ec73660 407b6750 3f6d2051 3f000000 -> 3e9509a0 3f0e98a2 c0241151 3f36d780 be9815b3 bf1182fe 40276c11 3f332da9", - "c223667d c225ff34 415ea3d4 bf1e8c60 bfaa4c04 3dd5aa80 3e92ff72 3f000000 -> 3f1d6979 bee9bdd3 beff057f be95961a 3e4059d5 be0ecfab be1bd013 3f74d49c", - "413520a0 420b64b4 41921efc c05b5dc1 4029a30c 401678e8 3de04541 3f000000 -> 3e519ec4 bee0a927 be91cfb8 3f7e59b3 bfe5b178 40762c98 401fc637 3de81f56", - "41380bc4 c1c94463 414649dc 40ba1f70 bfcf8424 c0299fe2 3f390b6d 3f000000 -> 3fb61a66 c027a579 c02e92f1 3d09ecb9 40109a20 3f875e20 bc81bf2b be8cb958", - "c22b966d 4246261a c217aae1 bf82a248 3f91128c c05d921e 3ebb7c1a 3f000000 -> bffbe4d3 403cca92 c0712475 3ef2cfa3 bf87afe1 3fcb6439 c001e544 bf616197", - "3ee01000 42130f8e c1428140 40bf1842 bfed2720 40828c1e 3e151a3c 3f000000 -> c000583a 3f59d55a bfed76d7 bf6cca17 c09c2c92 40048896 c0907a2e 3ec2983d", - "c145f42c c0bb08e8 415a04c4 3ecd5a00 3f852b68 3fe922e8 3f51d5d1 3f000000 -> bed83b5f bd89baca 3f6bba4c 3e9cbc6e be0b107a bcb127b4 3e979a44 bf73b5b3", - "4198fd2c c1b675db 421f0198 40a941f4 bfd07b28 be8ffaa0 3e77edc4 3f000000 -> c0828a2f 3f794475 3f83f80e 3ef09e78 400b00df bf04b6e7 bf0c8677 3f61f7dc", - "41426b58 c0c25688 bfda62e0 c07f5722 3f141cd0 c063c153 3ca7acc0 3f000000 -> 404111db 3f26356e 40827751 3e7d6520 bf453d4a be29cc5e bf8548a2 3f7809c6", - "c224254f 3fea7a80 c23aa004 406250b8 c01bc08c 40a1a282 3ddee173 3f000000 -> 3ea5b584 bff2a66e 405fb6c2 bf4065cc c038a012 40003379 bfd5b921 beb0bfe7", - "42405528 c19ca065 c1e29eda bfbf92c8 4088b056 40b22326 3e747ad6 3f000000 -> bf3d1192 bebb7f44 3f3f7d5d bf02f6bb 3fc3405a c05302c0 c0862d00 becac4b3", - "41f57dd8 42431146 c09bee40 4055a838 3fc39d50 409ad06a 3ec27477 3f000000 -> 4079617d 3fabe365 40a8fdd2 3ea3ab10 3fa843df 3ee7f4f5 3fe40c3c bf729161", - "41b2c214 c1dd58f3 c02544c0 c04f3926 40346d38 c0905c16 3f620363 3f000000 -> bfb7152d be4a31d4 c013843e bf4f2173 40582ab5 c02ff1ec 408cf24e bdfe21e6", - "c0e52d10 421e32c8 42040bfa 4064653c 3fd1b318 c08ff242 3e92c2e6 3f000000 -> 3fd3177a 3f94dcc5 c00c76c3 bed9a5fd bf6d6b6c 3fc3313d 3fdd4b2e befb2843", - "42294b0e 412484d4 41befe50 c021a9be 40314c70 4021ece8 3f35dd14 3f000000 -> c00d6ea3 4004b53a 400ba01d bd23a6f2 bf9460ec 3ed131ba 3d70ceb0 bf4c2887", - "423b1544 4190a20c 40d19768 3dcc3800 3e1ba600 c0beb4e7 3f508cbf 3f000000 -> bfc9acf4 3fdd15a5 be9e6d06 3f11bc01 3fb9246c 3f8f3841 c06379c9 3d2e42ec", - "c09ae0b8 c23b5550 c13113fc 40a19c44 c0196226 3fd81300 3ebb7d00 3f000000 -> 3f49278a bada5100 bfca8df6 be8e0490 c00bdedd bfb048b4 be6778bd 3e8e0a9c", - "c1a3ff64 40bda240 40ce6920 3f3f48f0 4063fd30 c052759e 3f0d6d4e 3f000000 -> 3fae6fa2 403c9b58 3dc42885 3f31d2b1 3c8aeb7f 3f7dcaa7 bfe535aa be1c1843", - "c1120be8 c1356da0 40f93db8 c05778e2 40821568 40ad9be4 3f6235ac 3f000000 -> 4048150c c001d8cb c0a22786 3ee7fc7e bfcaf663 3e8548d7 4031cd73 3f259945", - "c1383fb8 41aa0624 bf90aa00 4098411c c06c4c15 40021778 3f41782c 3f000000 -> c0acf6e7 406374a9 bfdcf47c bd15df43 bea0354c bbffb3e8 bea19208 3f58dcb2", - "40881408 422378c8 41b17ea8 c0554d28 c091a72f c0a5ce0a 3f7a0e60 3f000000 -> c0101919 bf9ae321 c03ce2bd 3e380a5c bf844d98 bf53e851 bf477512 bf1b3db8", - "42118818 c0bd7838 42169c9e bffb8898 be3ee040 40a1746c 3f20d3ae 3f000000 -> 3f2bc9d9 bf70eead c034deee 3c6efce6 3efc10da 3f136b94 3f1ef384 3e963716", - "c2369313 c2024dfc 41b5c988 40a6a7a0 be39d7a0 c0835858 3f0f19c1 3f000000 -> 40b6284d bf17c534 c0863005 be5ff5ca bfa35031 3e0811d7 3f709c9c bf79cd59", - "c1a4a724 42430b36 c1a8e6ee 40058f8c c0ac50ca 40a5829c 3d88b77f 3f000000 -> bed25962 bff6fcd2 3ff7c99a 3e0ff477 bf297e8c bea6924a 3f10e1d0 becfae02", - "c190b0c1 42204050 c23e410a c0968b08 40b4f904 3fa9a5f8 3f40a26f 3f000000 -> 40857c43 c0aa193a bf4d8505 bf02d7d7 401ec093 c04a4bb6 bef46bea 3f5c0959", - "4170ee00 42090dd0 c17ffe98 40074b8c c0836cc5 3f687328 3f0b7e09 3f000000 -> c0046046 402f536a bfc50270 3e9bd151 3fc00ae8 c000ac49 3f9ca688 3f04ec25", - "4232539e 41a11634 42194746 bfdfce54 c0b3d889 c03bda06 3eaebc57 3f000000 -> bef834a3 3d55f4e9 bf4a62e4 3f4ef17c bfb30196 c081e6eb bf9c933c be837555", - "407510d0 41d12bd8 4238ffde 401f5168 3e0c8260 c068e4c0 3e7e4cff 3f000000 -> 3fd784a2 bfd9df18 bfe8fe65 3ece32b4 3f159759 bfe183d1 bfbcece7 bf435b24", - "42286d90 c0d669b0 409abdb8 c0a55665 c08b50a6 409d7328 3f0b70f0 3f000000 -> 409f4eb2 3fd59c64 c0a1cfd2 3ebdbccc bf6a8504 c0345791 3fb43350 3f67637d", - "40808538 420cdda6 c1d96028 3e21ff00 c011ea23 409049de 3ec93506 3f000000 -> bea31741 bf95c98c 3fb2f070 3f5fbbe7 3f7413b0 bf87054b 408474c4 bda142aa", - "c186b798 c1346e60 c1c1bc24 c004c3f0 3f7cca10 c0ba966c 3eb25d32 3f000000 -> bf5ea3d1 bf17a595 bf07cc86 bf175dba 3f97106c bce874fc 40284694 be111a86", - "c1aaffc6 c116eaf8 c1904f01 c0b87841 4006df40 402d2a4c 3f47e57d 3f000000 -> 3fe2a698 bf7fd8cc bf80fca3 bf1c08c1 4085b579 c004ce71 c032ce1f 3f213d89", - "c210559c c22f40e9 c11f2ce0 bef6b0e0 bf849088 3d4b6300 3f3ac13d 3f000000 -> beaf70e5 bf105e10 be064829 bda9fd9a 3ce9cd31 3d40642e 3c32f36a bf7f1ddb", - "c11093ec 41e95144 412ac560 c0b81c1f 3ffe6cf8 c0bfec5a 3ecfb1e0 3f000000 -> 3fd42658 bf560945 40677723 be22be66 3f1f2328 3f0f1db6 401a756e 3ee47007", - "420bad72 4177dd68 420871a2 402a3910 bfb8db88 40ac257e 3e53a602 3f000000 -> 3da61c89 3f646b2a 403a8407 bd32a950 3e4a2167 bec97eba bf606b13 bf3749a3", - "c14939ec 41a3bbe0 c13f7e3c 40a4cad0 c073b7e8 409996fa 3f22837d 3f000000 -> 406fb95c c04ba0bd 40908492 bf0ed481 c0212a5a 4008e5eb c0425142 bf54738a", - "c23d1277 c1d90192 c2341210 beec0460 c07243fe 404aa258 3ecd4fb2 3f000000 -> 3ee93428 407a3e36 c04b7377 3e609676 bdd1b1b5 bf61040b 3f36f0e4 3f79c456", - "41e83d20 42031b24 c232aa82 40982f10 bfc5339c 3ffb17a4 3f6c05e1 3f000000 -> 40812bdf bfe484b2 3fac3cf5 bd1971e8 bf9264b0 beba5e27 bffaa777 bf3604c8", - "4118ef14 4171c258 c19abc2f 409ffe06 c0baaa12 40aa007e 3edfc5fa 3f000000 -> 3fa27adf bfc62049 3f5ad200 bf31592f c0664301 4085500c c05eefc1 be76e087", - "41c89bcc c0099220 c1a1a0a1 c01cb2fe 4054df54 3f63cfd0 3f43d27a 3f000000 -> bfbfd9c0 c00802d4 c00278c7 3e7948b7 bf86d4f0 bd7c57da 3f28b741 bd40d775", - "c1647b68 c23feba9 40447e20 c04e905c 3f9fff30 c09ba360 3ec3bf57 3f000000 -> be753bd3 3d9e4c0a bef57eb2 bf7eb18d 40172199 bf431be4 40974ace bdcea3c6", - "40c94b68 40b61b48 40bcad48 be685880 c04a7b0f c0be365d 3d713c40 3f000000 -> bf180eb6 3fef3945 4050470c bf5059aa bf156518 4077e618 40ad4a5a 3eefc5c3", - "4202dc38 41e63848 42022206 c0bce9fa c02540d7 c0255520 3f47559a 3f000000 -> c084d4fc bfadaba0 bf72e71b bddc8f95 3dda9c31 3fbc9547 3f9a20cf bf31ddcc", - "c23292a4 c22a8178 c2430002 c07e63c5 40af967c c0681e7e 3e8d9922 3f000000 -> c075f932 4021c599 bff901fa bf2674b0 40528333 c00a732d 3fd51bfd bf427ed1" - ] - }, - { - "glsl": "float cultmath_snoise(vec3)", - "tolerance": "ulp-bounded, on the simplex tie set", - "cases": [ - "42101793 c21be86d c0ff4367 -> 3f0b6571", - "c16005b2 420bfe93 c00016ca -> bf1b7d58", - "4186163c 414c2c79 c250f4e1 -> bf293e3d", - "c1ae4edc 41b1b124 422cd892 -> bf166489", - "41d3f056 c0207d52 c1cc0faa -> 3d672c77", - "423e12a4 c221ed5c 422a12a4 -> be138760", - "416b0c20 416b0c20 416b0c20 -> bf264714", - "c25d17e3 420ee81d 420ae81d -> 3e556a08", - "c2355597 c2355597 c2355597 -> be2d7849", - "41e69d22 c244b16f c18962de -> 3f0ba67b", - "415a0446 418d0224 418d0224 -> 3ec0e014", - "41ae8e8a c00b8bae c248b8bb -> 3d493310", - "c2485705 c1a8ae09 425fa8fb -> 3e9a4c72", - "41800913 c24bfb76 4230048a -> 3bbee378", - "c22b1eb5 41e1c296 c031eb51 -> be9071e1", - "c18a1c64 c1821c64 41fde39c -> 3e240f96", - "4244307a c14f3e18 c1d79f0c -> 3e306bb5", - "4169ecf1 c1cb0988 c136130f -> 3ea5029c", - "41ccb06d 419cb06d c24da7ca -> 3f257dfa", - "411a57b1 410a57b1 c2156a14 -> bf3db042", - "4150e9b2 c1f78b27 c18f8b27 -> 3f0241fb", - "c2365216 c2365216 c2365216 -> 3e35ef14", - "c131e43e 40fc3783 423b86f1 -> bf1e07b3", - "40c44913 c22f76de 40a44913 -> bf4c78fc", - "423cf8a3 c22b075d c16c1d72 -> 3ea06505", - "c1d80ea9 c2480755 4277f8ab -> bc97fd7b", - "417015b4 c13fea4c 41d00adb -> bf1a70d1", - "40f2862d 422650c5 c209af3b -> bf1e6f15", - "41591060 420e4419 41291060 -> beb85e22", - "41258130 40eb0261 418ac098 -> bdce06a0", - "c21e6e11 bfcdc22c c1ccdc23 -> bf031bce", - "c253d27d 42382d83 c17f49f5 -> 3effb419", - "c21588dc 418cee47 418cee47 -> be0736c5", - "c2414913 4272b6ed c2194913 -> 3daafcdf", - "411e7ebc 411e7ebc 411e7ebc -> bf1a70e3", - "41eb3975 bf18d15c c2066345 -> bf39607e", - "c2104c35 4217b3cb c2144c35 -> bf2ba806", - "423e2ce8 c1f3a632 4091673b -> bf2bbf73", - "c18450a5 c1bc50a5 c19c50a5 -> bcba69ae", - "c13de9ce 41c10b19 4228858c -> bf2dc157", - "c1e087a7 414ef0b3 419f7859 -> bebaad19", - "4148840b 42222103 c0aef7ea -> 3ef9cd78", - "415c7b06 c1c9c27d 41f63d83 -> 3f1ba7b7", - "41706f52 41506f52 c1b7c857 -> 3eaa73d8", - "c1ae4ede 4244d891 c1ee4ede -> beb1d769", - "4245906d 41eb20da c2226f93 -> 3e516a38", - "4246696e 3fcd2dca c2519692 -> bf21ac15", - "3ffc0680 3ffc0680 3ffc0680 -> 3da12b7b", - "c17970b8 c17970b8 c17970b8 -> bdc659ec", - "41448f7c 41448f7c 41448f7c -> beec41ef", - "41b19451 c1b66baf 41e19451 -> 3ec02c55", - "c0d7aa13 419a157b c216f543 -> 3e7bc777", - "412fcde2 c2200c88 3ffe6f0e -> bdaeb7c8", - "c1776ed9 4272244a c251dbb6 -> be07428f", - "40f1dd80 c1171140 422e3bb0 -> bf10a782", - "c18ed0b8 c1e6d0b8 41325e90 -> 3f538113", - "c161daab c171daab c188ed55 -> 3f13ab84", - "41158c14 41158c14 c24a9cfb -> 3e663427", - "c122dc27 c1b96e13 c1d96e13 -> be88a4e2", - "c1865805 4189a7fb 41434ff7 -> 3e910bed", - "c21b0cd0 c16c333f 4191e660 -> 3e16f485", - "c19cf121 41361dbf c2227890 -> beaeb612", - "c209415c c241415c 42875f53 -> be680992", - "c21b0567 4224fa99 41a1f532 -> becad777", - "42170a3e 42330a3e c238f5c2 -> 3ee36a71", - "3eb417aa c15a5f43 4165a0bd -> be63e4b0", - "40c4a547 bf5ad5cb 41d92952 -> 3da73820", - "423ade7f 414b79fd c1648603 -> 3ea2aeb1", - "c240f7da 40308262 410c2098 -> bed4246e", - "c2022372 c2062372 4231dc8e -> bf172d7e", - "40248770 40248770 40248770 -> be2ec0a5", - "c204003d 421fffc3 c1a80078 -> bf15791a", - "4137bc74 4137bc74 4137bc74 -> 3d36d618", - "42068770 42068770 42068770 -> 3f513c53", - "41d7cdea 410f9bd5 41a7cdea -> 3e689353", - "c21e7b0c 424984f4 420984f4 -> 3e061bff", - "3e79bd34 c0b83216 c2230642 -> 3e51e14d", - "c15b8000 42492000 c0f70000 -> 3eac7579", - "4103a583 425ce961 c227169f -> be8bcee8", - "c103030e c254c0c3 42073f3d -> beaf9b54", - "c2292eeb c052eeb4 4185a22a -> 3e8933d8", - "41cfa5a5 4197a5a5 c1f85a5b -> be637b3a", - "c250604b 42279fb5 422f9fb5 -> bdabc3f3", - "4152e045 c23b47ef 4230b811 -> 3e55b150", - "c213eecf c213eecf 420c1131 -> be0970da", - "421a9019 c145bf9b 3f240650 -> be2c524c", - "c19ef057 c17de0ae 41810fa9 -> bdac05ca", - "42383bea 41a077d3 c15f1059 -> be58075b", - "41bde07d 410bc0f9 415bc0f9 -> bed6b808", - "41e491cf c25db718 41b491cf -> 3e886641", - "c1eb0107 c1eb0107 c1eb0107 -> be6cca06", - "41de9035 bf96fca9 41c69035 -> 3dd23862", - "c22c4e3d c08271e5 c0a271e5 -> 3d1f3e05", - "423e028a 423e028a 423e028a -> bc1c0cdd", - "40b928db 4223251c c1d9b5ca -> 3f1e16ca", - "c2014e41 c2014e41 c2014e41 -> bec05c66", - "41ff41e6 c2045f0d c20c5f0d -> 3f0e016f", - "bf2a562a c216a959 bfd52b15 -> bc384e7c", - "421a3eae bfb82a34 c201c152 -> bed37477", - "c1b197e7 421b340d 422f340d -> 3e601579", - "421089b4 c213764c c10dd930 -> be60fb64", - "41923de8 c23ae10c 42551ef4 -> bf3050af", - "42197d8a c15a09d6 42017d8a -> becb6e4d", - "c2711f54 41edc158 41ddc158 -> be5b0f68", - "408b5ae3 40eb5ae3 41ead6b8 -> bd731314", - "4104b872 41b25c39 c12b478e -> bdce4bd7", - "c0d7cfdb c21ef9fc 41da0c0a -> 3e3f15df", - "c08d3c18 c08d3c18 c08d3c18 -> bf2d81e5", - "41917cab c21b41ab 41d97cab -> 3c4bbbcd", - "c221f754 c221f754 c221f754 -> bd050888", - "42283674 c20bc98c 4100d9d1 -> 3ebbe2a1", - "c22597a8 422a6858 c1bb2f51 -> 3e9afa10", - "41d0607c c22bcfc2 c0fe7e11 -> 3f4e3ac0", - "c2259259 c2259259 c2259259 -> bf247382", - "418e86fb c132f209 421b437e -> 3d37ca3f", - "421fc48b 424bc48b c2703b75 -> bf2562e8", - "c2490014 4097ff65 41ddffda -> 3dbd20e9", - "bf51393e 41817636 4142ec6c -> bf204705", - "41823060 41823060 41823060 -> 3ecb15f4", - "c11f8655 41c03cd5 c217e195 -> 3e8c4780", - "bfbdad7e c21ded6c c1dbdad8 -> 3f424213", - "c22d901e 420e6fe2 c01901e2 -> 3f43c67b", - "c1c44b71 c21625b8 408ed23d -> beb7f85c", - "c1b1e64d 42070cda 418e19b3 -> bca9f381", - "40200b98 c221ff47 415802e6 -> bf14b271", - "4245c3a5 c23e3c5b c18478b6 -> 3eaaaae8", - "c1d07d24 423bc16d c1d07d24 -> 3f45bba3", - "c1f1ed69 c228f6b4 414c252e -> 3ef59315", - "41dc4067 42022033 41c44067 -> 3f189496", - "41062f23 42098bc9 c1ace86f -> bea03aa6", - "c044da87 423bb257 c1b09b51 -> be53cb4b", - "c1fc4795 40cee1ad 3eee1ace -> 3eb6234f", - "c246e1ee c02e1ed8 41f23c25 -> be0c5173", - "c1a5ade4 421d290d c1cdade4 -> 3d5e4963", - "c0bdc0a4 c07b8148 c18f7029 -> bf10fe60", - "c0031290 c0031290 c0031290 -> 3ee05a50", - "c1efc584 c20fe2c2 41d83a7c -> 3d9c3f64", - "416b5282 c2152b60 419da941 -> beb7ed0c", - "416f7238 41cfb91c c1208dc8 -> 3f171acd", - "420962bf 41358afd c1e53a81 -> 3e00e9ab", - "401593f2 401593f2 c1c54d82 -> 3f4a8d0a", - "c12b2c0e 424534fd c21acb03 -> be6822e6", - "4229e0a7 c1087d64 41dbc14e -> bdab02fb", - "c17fe3a0 c253f8e8 42300718 -> 3f23b7af", - "c112b183 4207539f bf958c1a -> beaf3a80", - "3ded3800 3ded3800 3ded3800 -> bee5cda7", - "c21c0e8f 420ff171 411fc5c5 -> be6168a5", - "bd4ce000 bd4ce000 bd4ce000 -> 3e82b9c1", - "41838569 41170ad2 41fb8569 -> 3f240593", - "c215fba5 419408b7 4256045b -> 3c3dad93", - "3c9f8540 c247ec0f 425413f1 -> be3eb00b", - "c210c7d9 41e6704e 42173827 -> bd9bee88", - "41b346dd 3ed1b733 420da36e -> 3f04704b", - "c27c598e 425ba672 419f4ce4 -> bf1402b0", - "4254b1db 4220b1db c27b4e25 -> be8332e5", - "418b924a c091b6d6 c1dc6db6 -> 3ee60369", - "c2249c82 c2249c82 c2249c82 -> bebd6e1f", - "c1b437e1 4221e40f c19c37e1 -> 3e6fbebe", - "42233417 41fe682e c18197d2 -> 3f168a66", - "c23035f3 422bca0d c150d7cb -> bf38341c", - "41056ce9 c246a4c6 40cad9d1 -> bf215446", - "41081618 41081618 41081618 -> bc709d14", - "420f9d92 418f3b23 c268626e -> bdbaca65", - "41889cd8 42044e6c c0fd8ca0 -> beeaa472", - "419a514a c17b5d6c c17b5d6c -> 3f4f7c0d", - "41e0f7c8 41e0f7c8 41e0f7c8 -> 3f165bc4", - "c2872ab7 4209aa93 4241aa93 -> be5d983d", - "42110b49 c1c5e970 c1a5e970 -> 3f3b2457", - "423f83db c2347c25 41ff07b5 -> be7a25e0", - "421cc314 421cc314 421cc314 -> bf0a9dc8", - "c280f5e8 41bc2861 42561431 -> be640c2b", - "c20dc9e2 41e46c3c c1a393c4 -> bf0f9ed7", - "c1e7f348 c247f9a4 423c065c -> bf4592c1", - "c15eb9a2 c22fae68 bf6b9a20 -> bcf2caab", - "c2225674 4106a630 4231a98c -> 3e276dff", - "c2421a2f 422de5d1 4225e5d1 -> be90cad4", - "c1f95e3c 417d438b 3f5438a5 -> bd0369e9", - "c14fec50 c14fec50 c14fec50 -> bc567060", - "c22cf9eb c113e7ab 41de0c2b -> 3edd24bf", - "4265d5e1 40aeaf05 c2562a1f -> be025648", - "c24b6498 4084db43 42709b68 -> bf0a43ed", - "423b1dc4 c1e9c478 c218e23c -> 3e46ca3c", - "c1ef8dc0 3f872410 3d6481f4 -> bebaea2f", - "421fc6b1 c1b8729f 422fc6b1 -> beb0c33a", - "4218ecf2 4153b3c9 c26b130e -> bf0d26cb", - "424c354a 404354aa c19f956b -> bf0c9e1e", - "c1cf8846 419077ba 418077bb -> 3e616f89", - "c1a3ff57 c1c3ff57 425a0055 -> 3f05fb97", - "c219e6b0 42221950 41686541 -> bd816643", - "41303855 42380e15 c1a7e3d6 -> bdf4eb5d", - "bfb870ae 4108f1ea bfb870ae -> 3ea3ae40", - "404f37b5 3f9e6f6a 4113cded -> 3f2a92fe", - "c2115d0f 421ea2f1 c0cae879 -> 3f253dba", - "bfca4aef 41f35b51 c0652578 -> 3ef5ec53", - "41b2b778 41156eef c21ea444 -> 3f1a2098", - "4215aa76 4215aa76 c18cab13 -> 3d3ff1fd", - "c252919c c202919c 42756e64 -> 3ef79322", - "41c56405 c2494dfe 423ab202 -> 3f2782cc", - "421fbab9 41df7572 c2784547 -> be6e18b0", - "c11595df c15595df 421a9a89 -> bdade9b9", - "4215a576 4215a576 4215a576 -> bf1500a9", - "c2522b83 c2162b83 4275d47d -> bea62919", - "41864888 c181b778 414c9111 -> bf1d8636", - "4208be28 4208be28 4208be28 -> 3e630eaa", - "c13c3b2a c2630ecb 4258f135 -> bed23ace", - "41d5816e c1d27e92 4216c0b7 -> bf12e53b", - "3d720330 422c3c81 c10f0dfd -> be3a7f99", - "42440e8c 3f81d176 c247f174 -> bd218a91", - "c100b3eb 41b7a60a c2082cfa -> bf0a4668", - "c1fd42fb c12a85f5 41357a0b -> 3cc79e6a", - "3f84c825 41984c82 42042641 -> 3f510a19", - "40af4f00 40af4f00 40af4f00 -> 3da81a63", - "c18cf6da c1d4f6da c194f6da -> 3e967d0c", - "c2116e6f 422a9191 40691904 -> 3d8a1212", - "41b10615 c186f9eb 3f90614a -> 3e5fdd89", - "4166c912 c1dc9b76 c1849b76 -> beb32302", - "c256c622 425d39de 40539de2 -> 3de49603", - "c14b3284 3e99af84 40e99af8 -> 3e2a0de4", - "c210d227 c210d227 c210d227 -> bf3dffde", - "41fe886c c1a97794 c1997794 -> bd3dcd05", - "42500487 c197f6f3 c197f6f3 -> 3f2bb88a", - "c1d06501 41bf9aff 416f35fd -> bf14f7e2", - "41b9842d c2133de9 c1967bd3 -> befc3d51", - "c19d86ac c19d86ac c19d86ac -> 3e668e81", - "4018047e c1dcff71 41830090 -> 3e947be4", - "41413526 41e89a94 c1df656c -> bd99ba6e", - "c15465b4 c24d196d 4206e693 -> 3ee814c9", - "41808a15 c1df75ea c19775ea -> be98ffbe", - "c100580f 420be9fc 409f4fe2 -> bf021486", - "41bc93d8 c1cb6c28 421a49ec -> be589124", - "c0755e14 c22355e2 bf55784e -> 3b8da7e6", - "c23ee69b c09734d8 41ca32cb -> be66d015", - "41cb0a8b c2567aba 41061516 -> 3f1de475", - "4129a175 c1565e8b 41d4d0ba -> 3e93ad2e", - "c21599bc 41199912 c1b33377 -> 3da12c84", - "40f18c6e 40f18c6e 41c4631c -> bf1545cf", - "c1dd71cc c1dd71cc c1dd71cc -> bf003f5c", - "423f09e6 c22cf61a 411c2797 -> be40ab00", - "417cdde4 c199910e 41ce6ef2 -> 3f19f6dd", - "c208c2d0 c210c2d0 42233d30 -> 3e26b927", - "c1a2b7e9 402a40bf c1c2b7e9 -> bf1dc80e", - "c2385bfc 422ba404 bdb7f888 -> 3e90e108", - "c0c850d6 4222f5e5 c2210a1b -> 3f0504cd", - "420d1a56 c256e5aa 41246958 -> 3d5e142e", - "c1918cbe 422739a1 c218c65f -> 3de67fa8", - "c0954e4a c23ea9c9 411558db -> bbc538f3", - "c23a1a31 c1dc3462 4225e5cf -> bf01edaa", - "c1adf1d0 41920e30 41c20e30 -> bf029729", - "c253c185 41e87cf6 41d07cf6 -> bf17759d", - "42481a96 c1ffcad5 c18fcad5 -> be414b1a", - "c257434a 4102f2da 4260bcb6 -> bf19fcc3", - "c094b308 c094b308 c094b308 -> 3f4c791d", - "c1cdc2e0 418a3d20 c195c2e0 -> be6a789c", - "42264043 c01bfbd6 41a48085 -> bef2a965", - "4210fac4 4210fac4 4210fac4 -> be800215", - "c160b7ee c2142dfc c042dfba -> bed354c3" - ] - }, - { - "glsl": "vec4 cultmath_snoise_grad(vec3)", - "tolerance": "ulp-bounded, on the simplex tie set", - "cases": [ - "c23acaaa c23acaaa c23acaaa -> 401052c9 3f0f16a7 bcbff362 3e0fd123", - "c25f203d 4200dfc3 41f9bf86 -> c002a42c 3fe43930 bfc80ae3 3f28af46", - "417a38d0 417a38d0 417a38d0 -> 4021c916 c01f15f9 becc73d1 be72b3c3", - "41d8995e c217b352 3d995d5e -> 3f5ba362 403ba6d9 400dd8ac 3e1dbd57", - "c1cdab59 4280952a c236d5ad -> 3fdbe5ab 408b8779 40183995 bec6de00", - "c1df605f 41513f42 41e09fa1 -> 3ee2b2ae 3ffd7d1a 3ebd27bc becd2159", - "41046bc0 41046bc0 41046bc0 -> 3e8d739e 3fc850ad 3f84baea 3dacafd4", - "421fd4d7 c1885653 c1905653 -> bf13f661 3ffd3295 3fa13f1d 3ef60904", - "4193e077 bf03f11e 4211f03b -> bf5a2722 bff6615b bfbfe7d0 bf36b29d", - "c135363e 406b2706 3f2c9c19 -> 3f88875d 3f8e18ff bfd68db4 3ec25bf5", - "3fbad472 c02295c7 c19452b9 -> c0b172f2 3ff7d196 3fa80473 3dce4aee", - "423ab63f 40f5b1fa c0aa4e06 -> c0994cdd c002adfc c02ea8f9 bdded0ee", - "41211cec 41211cec 41211cec -> 40648992 bf9400d0 403eb853 3efc8a00", - "41b80fec c0dfc04d c1b7f014 -> 3f4a3c57 400ca9ca c0129dad 3dcd5a1d", - "c2034030 c2034030 c2034030 -> bfc5b121 3f96408e bf890e26 3f0f06e8", - "c23970b6 421e8f4a c192e16b -> 3ef895b9 c038b63a 3fe20dfd 3e6b5583", - "c161b020 422793f8 c1c0d80f -> bf79bfc1 3fa30ad2 40a6b947 3ed356a4", - "c020441e 3fbf77c4 423dfbbe -> 3f2393c8 40b84bd6 c023eac0 bc82c6fa", - "c1f07fd5 c130ffaa 40be00ac -> 3f2fbdb6 402c4d24 c074df7b bdd62088", - "c24a9048 c20a9048 42496fb8 -> bff7047b 3fa2df38 3f6247a0 bf2f6ba2", - "c2414d22 412acb75 4262b2de -> 3f2c0542 c0946cd5 c07e5e45 bd829d92", - "4124abc8 4124abc8 4124abc8 -> bf7d3ba6 3ef86dca 3f660c9e 3f1072f8", - "c1c9be73 41d6418d 412c8319 -> 4048f97f 4048f97f c03460c6 be50c78f", - "42295f25 c10a8369 c246a0db -> c0b7d205 bf221d02 4023eab4 bd16719e", - "41227e6f 41d13f38 c17d8191 -> c0cc3984 bef546a1 3c52b5d9 3d9850c7", - "41b52981 40b4a605 c1f2d67f -> bf1af97a c0b57e97 4023e8e4 3da689a2", - "c1bc8ea1 4231b8b0 419b715f -> bf760574 c0a18b55 3f1259ea 3eff09a9", - "422868d7 c18f2e51 4198d1af -> bf98e393 bfc09ac5 be701e25 bee13aa0", - "42458cb1 c24a734f c1cce69e -> 3f1530ea bf51103a bf46cbf7 be8d3595", - "c21757f4 4230a80c 41895016 -> 3f2a6072 c094dd92 c07f30ba 3ca7511e", - "c2534bdb 4112d096 4204b425 -> becb5029 401d6289 bcb2b330 3f2709ab", - "c2787f22 425780de 41a701bd -> c0be3c0e 3f410c59 bf6bae55 be91d135", - "412dfb4e c16204b2 c22c812c -> 40395b10 3feb361c 3ed2b53d bed6ee38", - "c1cbe510 424e0d78 413835df -> c0b74d90 bf2085f7 4023ea86 bd4e210d", - "c1896aa4 41be955c c1a16aa4 -> bee53a16 bfde5181 3ff0a2b7 3f2260bd", - "4175c4cf 40eb899e c20a8ecc -> 3fbd2b6b bf5b4360 3fddb876 bf0356c9", - "41de3b35 42131d9a c220e266 -> c08a1945 4052b53a bf92a3df 3e0d5300", - "42405631 c213a9cf c13ea73e -> 40718601 c0493d45 3f642778 be42cea4", - "425731a7 41ce634e c23cce59 -> bf7f5cfa 3fb604c6 bea7e7c5 bf18be56", - "4098304d 427b060a c278f9f6 -> bf30aea2 bfb18a0d bfda4980 3ca5b37d", - "c13bf1a2 c18df8d1 c1bdf8d1 -> 3e454a06 3faab43f 3e12d8ff 3ede4d67", - "40da4fa0 c1816c18 c218b60c -> 3f0d2784 3f0d2784 c0cf4861 3d762401", - "c0152670 41cd5b32 c0ca9338 -> bd78718d 40283d33 bf6cab10 be50cb98", - "41ac4a8a c25ddaba 419c4a8a -> bf464f75 4036480c c0090c92 3e7122fc", - "c1f92d69 c1f92d69 c1f92d69 -> 3f8f1c99 bee1b3d0 3f41d9d6 3f4ee9ac", - "c1b642e5 41c1bd1b c1b642e5 -> 3f38e746 3f38e746 c0bce62b be8437b4", - "411ecf07 c1a8987d c17130f9 -> beed16b8 c08631c5 3f6f9544 bf1a1b13", - "42739224 c1b8dbb8 c2386ddc -> 3f2c1b6d 40455831 c098180f bd929e67", - "c0630a75 c21230a8 424dcf58 -> 3e3c7a14 c059b44a 401b5119 bea48961", - "423da984 c0d2b3e4 c1b4acf9 -> 3fabe9d9 401fcf03 405d87f2 be479240", - "c265def6 41688427 421a210a -> 40576b48 c0935f8b bfa45ada bdaf915d", - "c20801a2 c20401a2 4217fe5e -> bf82da2f c018d9d7 3fe7dba4 3da28c2a", - "401f0a79 c060f587 418be14f -> 405ea10e c0048e10 c084dfe4 3d2a5460", - "422ec79c c2153864 c18a70c9 -> 404f2ea9 3f292231 c0a45e99 bd151acd", - "c1c1d74d c22ceba7 41fe28b3 -> bfa60e4c c0730a5f bff61026 3f0e2ae7", - "c1bb8e8d 424e38b9 c1071d1b -> 3f4158ea 3f415858 c0b94424 be8ec97c", - "4235c4a6 c1ac76b3 c2563b5a -> 3ff226bf 40710acc 4020c4d6 3e81ce88", - "421820de c17f7c88 41a841bc -> bf0f0420 c03b809b c002228b 3ecd4759", - "41f78cfc 407c67de c150e608 -> 3fcb6e71 be689ec6 c05a065d bf1a3e60", - "422ccfc6 c12cc0ea 420ccfc6 -> bf3d7ecc 4038c65d c006e892 3e700be4", - "420e7ae5 c219851b c166146d -> 40aad885 3ef531d7 c023c08e be2e20b4", - "424053f6 424053f6 424053f6 -> 3f947526 c098ce67 bea5da3e bef927ab", - "42662514 c245daec c23ddaec -> 3e3294e1 3fadc9c8 4000c557 bf1b8d41", - "415a02d5 425e80b5 c2417f4b -> 4005b7c6 3ecead0e 402b2dc3 3df42dda", - "c1ac0cc6 408fcce8 4219f99d -> 3fbad271 bf1551a7 4009423d 3f1fc671", - "c2002bc1 421bd43f c2402bc1 -> bf6b3ea5 4037aa2b c01592ea be70c4d4", - "c26180af 422a7f51 40f3fa88 -> 4018ae51 40077174 4074322a 3ed62f73", - "4131d958 4131d958 4131d958 -> 3e052188 3e0681f2 c011d54a bf4785f2", - "421ce193 c0b8f364 4200e193 -> 4046c9f4 4046c9d8 c03453fd 3e58d8b5", - "c1a73963 423c634f 41018d3c -> be2de0e4 bf810173 3bc8f9b5 3f1cd89d", - "c21d747b c229747b 42768b85 -> c093f1f4 4057b3cc bfa57414 3da5fe25", - "422e0da1 3f036817 c221f25f -> bfea2043 3ff95074 bf5b92f9 bf179153", - "42465de8 42465de8 42465de8 -> c04546f5 4063fa71 3f4b2769 3e4ffd8c", - "c2558aae 41e4eaa5 3fceaa40 -> 3f73caea c080e5f1 c059f3e5 3ec742af", - "425e4891 c265b76f bfb6edd2 -> 3f7e6459 3f384c0d 3f71d93f bef89218", - "c233c183 42841f3f c24bc183 -> c077bb48 bfad0978 bffda5ab bf09babc", - "42764950 c20db6b0 c215b6b0 -> 403266d0 3f2fa211 c08159d3 3dcc9604", - "40b75282 423aea50 c0e8ad7e -> c082b517 3fecaba9 3fad63f5 3e53b670", - "c24c92de 410db48a 425b6d22 -> c0b7a388 3ff8a412 3fa6b524 bd73bbc8", - "413d1124 3fe88920 41a68893 -> 400244c3 c0155f26 3fd5a407 be4df706", - "c1b6549d c22b2a4e 4224d5b2 -> c08b83e8 bfdbdae4 c018340b bec6f420", - "4120f008 4120f008 4120f008 -> 4077ad83 bf83014a 405087bc 3edc3bcf", - "423ea770 4246a770 c284ac48 -> 40521628 3f281cad c0a80d42 3b87a509", - "421d5cb3 c15a8d32 3eae59b1 -> bef953cc c0ccc5b5 3bbb43c7 bd4b41f7", - "c223cc65 c17f3194 41f06736 -> 3f6f4d2e c0822359 c05c4376 bec19408", - "409ffe00 409ffe00 409ffe00 -> 40045877 409a674c 403075f7 bb1a675e", - "c170afa8 c0815f50 c20c2bea -> 3ff60996 c05a954a 407b1e90 bdea6488", - "4115e543 4057950e c20286af -> bfd49c68 40364011 bf07cb8c bf18e442", - "c2382835 4233d7cb c0e141a5 -> 3fe79c1e c03553fa 3f2715b7 bf16d605", - "c1f5e848 40a85ee1 c216f424 -> beef1900 beef18fb c04a518b bf374cad", - "4155549e 4135549e 4182aa4f -> 405f30cc c005ea02 c085ea0e 39fde108", - "41318042 bff3fdf1 c079fef8 -> 3e88705c 40988a5e c022f623 be7bce51", - "41357cf3 c21ea0c4 41457cf3 -> c05ef4f1 400558f0 40857b0c 3cdc8290", - "41676cb6 c108934a 41f3b65b -> bf59afe1 bfbc0762 bfcf3e57 bf2bcf8b", - "41393b88 42264ee2 c251b11e -> 3fb70412 c03bd5ad c018eab9 3f163ada", - "42084341 41510d05 c25bbcbf -> bfae28c9 bfb29c2d bf69bb0e 3f13c0f1", - "c12cc191 c23b3064 41819f37 -> bf634fe8 c0006104 3f8f1317 3d39cc43", - "40af1a48 40af1a48 40af1a48 -> c0b36d15 bf14a543 4023e539 3dd87fc4", - "41e6d375 c2349645 c2209645 -> bf1c29e8 c0b5e1e0 4023e963 bd9b3ab0", - "42068a0c c175d7d1 c135d7d0 -> bf1d9bb4 bf1d9be0 40c8731c be2ca06c", - "40041d57 c11ef8aa c1df7c55 -> 406e0d68 bf8b97ac 40479241 3eed80b7", - "421b9677 c2106989 c1a8d312 -> bfb63828 407d0730 bda287a2 bf0ddef3", - "42136374 c2409c8c 41bec6e8 -> 405ff438 405ff438 c034a44d 3d6e0a13", - "c1c511a1 c1ed11a1 42017730 -> bf39fc17 3fd61b94 40bbe20b 3e73abb9", - "4207c02f 423fc02f c2343fd1 -> 3eb9c922 bfc22cde 4069c466 3f16a984", - "4229a7b3 c1f4b099 c1196132 -> c07f5e75 bfee0ee0 3f4d93d1 bf198848", - "41a12108 41a12108 41a12108 -> bf07c935 c005f8af 40427a80 3df1af83", - "c0b37808 40ec87f8 c1fcde02 -> 3ffce781 3f4466e0 40128b6b 3d0a997a", - "417e6bb8 417e6bb8 417e6bb8 -> 40843171 bfaf28bb 3bd2e9ca bf0af4fb", - "c1942e99 c1185d32 3ef459c2 -> befef937 bff5c156 40031999 3f20ef59", - "4211707d c11a3e0a c1dd1f04 -> 4094622a 3ff6875d 4026a3a7 3e80d524", - "41b1b20a c0326fac 41736415 -> 3fcb781d be9f4a74 3e2777fe bf4efd66", - "3f9f5936 40a7d64d c22b0536 -> c09986e5 3ff375aa 3fabff0d be32ee4b", - "419c31ed c1379c25 41ac31ed -> 3f13f3e5 c00c3635 bf07c190 3e29957f", - "4224fe59 c20701a7 41d1fcb2 -> be4c9140 3facb4aa 3ff70f32 bed63d1f", - "41ee1ec8 c214f09c 40f87b20 -> 3ff50a16 c0a104ff 3faaf23b 3e21f21f", - "c1dc4e04 c1289c07 4225d8ff -> bf1e47bc 3fc08e6c 3f9d355f 3f00a006", - "41058091 41258091 c1ed3fb8 -> bf934a5f 3ebeb548 bf429e94 bf4ea0cd", - "40e6d3b5 c25b2589 41b9b4ee -> 408823a7 3fd1ba3f 4012b795 3edacd0d", - "41adf624 41adf624 41adf624 -> bde611e0 bd1cb601 3e038041 3dcd4edd", - "428eef15 c24621d4 c24221d4 -> 40243fab 3f90b617 3fa98640 3eff74d0", - "4221d60f c18c53e2 c24229f1 -> 3f589e6f c0885cd3 c067dd81 3ea0a968", - "c24871ce c20071ce 425f8e32 -> bf419836 bf419836 40b928a2 3e8f14de", - "41cfb3b8 41cfb3b8 41cfb3b8 -> c0a7bdff c0350055 3e41a40c 3ea11c8c", - "c2798a0f 427275f1 4159d7c4 -> bdd02373 3f628cd1 3cb1b6f1 3f1f45ff", - "c1f0dd9c c1a0dd9c c121bb38 -> 4049f35e c03ceb52 3f1c6437 be61a037", - "c1d76516 42244d75 41889aea -> 4019684f 3e690704 3f0d917a bcb4a4fd", - "c1c29b78 c1fa9b78 c14536f0 -> bf1f19d6 3feb5294 40c4966d 3d604727", - "c1422a78 417dd588 418eeac4 -> c0c5064f bec03b03 3dd9cca4 be582e5f", - "41f5c1a2 420ae0d1 c1823e5e -> 40b64e5a bf57b22f 3f4ad6f9 3eb10fcb", - "c18ab573 410a951a c1a2b573 -> c0ca2372 bfdc2ea5 3b69d609 3d2d83c1", - "c22f6b01 c22f6b01 c22f6b01 -> bfc3a2fa 40410e60 bf90f89a 3e69c10c", - "42126692 42126692 42126692 -> 407ee67a bc5665d4 c020acf5 3e99b241", - "421ce8c2 41e9d183 c12c5cf9 -> bf27ebde c0033068 bfc95f51 3f112da1", - "4244e20a c24b1df6 41d9c415 -> 403985d5 c043a800 bf134a2b 3e653955", - "c24ca519 42335ae7 c1629462 -> 3f1605e4 c0cd02b8 bf94c07e bd1bc5b0", - "c1df4511 c03a288c c12e8a23 -> 404578c4 c064a1b8 bf4c5ad6 be4f6c31", - "42321e25 c22de1db 41843c4b -> c0470b69 be7dd5de bfa75abd 3d976422", - "bfbb3b4c 42162625 40b1312d -> be99aba6 bf714fe4 bf230b4d 3f3ea0ca", - "c1b6a318 c20f518c c15d462f -> bff900a4 40baadf2 bfa606af 3c1d0a3b", - "c28a0e93 4233e2dc 4247e2dc -> 3ea13555 402b8b6a 4032727f 3ecab3d5", - "c1c96066 c1b16066 c20cb034 -> 3d4e87d6 402e6eb7 3ea5d0cb bf210d81", - "c1ee493a c1ee493a c1ee493a -> bffd00f1 bf29ccfe bfc72cec 3f1f6539", - "423c93cd c1eed866 41e1279a -> 402d39dc bf0e23ca bfe7c0fb be7018eb", - "c235b891 c05b8916 c01b8916 -> bea5d46f 3f8b56de bfb3745c be0f019d", - "c1924a83 422adabf c1d24a83 -> 3fcc2603 3fcc2595 409920a6 3ed6bcd0", - "c232a0b5 c1fd416a 421d5f4b -> 4060e1f4 4060e1f4 c034a493 3d2846ac", - "c20b955b 422c6aa5 42006aa5 -> c01aa60c bec55416 be851f06 bd8b78b3", - "3ff8cc80 3f719900 c081cce0 -> c05fdfb9 c039f7d9 c0222698 beb0dfe0", - "c24616b9 c1d42d73 421de947 -> bebcbed8 bfead9e7 4009904b 3f223499", - "c1c64ae4 425cda8d c23b2573 -> 3e9b05c2 bfcf417b be3705d7 3f4e33e9", - "42171c86 42171c86 42171c86 -> 3b0c0bc2 3f863254 bf2b788b 3f164873", - "41df9f54 41d79f54 c110c158 -> 3e85372f bfd56562 be610c04 bf4e2e19", - "41704893 4180244a c247eddb -> 3f2d035d c0167bef 3e862848 bf2a32e8", - "4240cc4b 3e4c4a52 bf4ced6c -> 408cc795 bf4861aa 40701a62 3e82b079", - "418d6ca7 c1ca9359 c1aa9359 -> 405eddd8 c00520ed c0855041 bd01b4e1", - "414d5175 411d5175 c210aba2 -> bf8e40ea c01cf194 3fe0da91 3d9880ee", - "416c6b88 416c6b88 416c6b88 -> 400776f9 3d1678b2 3f2d5655 beb1e6f1", - "c112c540 c1a162a0 c208b150 -> bc9cedfc 4003ef82 40324adc 3f144df7", - "41d58a10 41ad8a10 c2493af7 -> c094b9b0 bff78f49 c0273263 be7a69b6", - "c21fc111 42403eef 42283eef -> c04058bd bf8e0527 3fa15c09 3f32b9b6", - "bed70a84 c215ae15 c1a35c2a -> 3e53f75a c09b56f8 3f20f7a4 bef1dc13", - "4218ba02 4218ba02 4218ba02 -> 3f376eac 3fc90a14 bf986d3f bf1ba274", - "c18d2939 424d6b63 c22e949d -> c0c956a9 3f20cfa0 bf8d08de be189ee8", - "c21c3076 c21c3076 c21c3076 -> c0844975 3f677f60 c0604495 3eb71e70", - "40f657b2 c1ca6a14 4256caf6 -> be777e3d 403ea154 c00fcf70 bea9d831", - "c20c2821 421bd7df 41d7afbe -> 3fd05647 c04112ba 3eee4f8a bf183824", - "42281c68 42281c68 42281c68 -> 3fdca504 bf31b95c 40be91fe 3e4e0f8d", - "421efefd c174040d 41d5fdfa -> 3f41651d 3f41651d 40653cc6 bf2ad41e", - "c11a38ce 422971cc 41c2e399 -> c067830c bfce9f7c bff6ef15 3ee337f0", - "4269ab2a c27654d6 4146aca6 -> 40237656 3fe2df99 40311398 be880f11", - "42487cdc c2038324 c2038324 -> 3efba243 40abe99c c023c70b be27ae72", - "3febfddf 420f5fef c1a14022 -> 3f188e04 c00d2f9b 3e4d95de bf2a2747", - "c22698f8 41159c21 4192ce11 -> 400d9f41 bfd98cab 3f9da3dd 3f13303f", - "40dd1ed4 c1d0b84b c1e0b84b -> 3f6d8318 3f6d8318 c0a5b78f beb869d0", - "c217ddeb c03ddeb1 425c2215 -> 3fa6873e c004bcf0 3f60f066 bf2d1587", - "c2134451 c09a2281 c1de88a0 -> c0c7eaae bfd6cba9 3d10f898 be081179", - "427a6ecc c1eb2266 c21d9134 -> 4045da41 400618c0 407e89d1 3e86f3bd", - "4101912c 4101912c 4101912c -> 3fef2043 c088a9e2 3fada502 be4d3aa2", - "416f1bcc c1e8721a c0c1c869 -> 3e4d00f9 bfce4efa 4057d0aa 3f1a68c1", - "bfd45400 bfd45400 bfd45400 -> 3f663143 bfeb202c 3f1248e5 bf2f384d", - "c1d025df c21412f0 40bf6883 -> 4003d8fa c05e55cd 4084553e bd5193c3", - "40d6a221 41a5a888 41f5a888 -> c04c13d2 bf2a27a8 40a0762f 3d51ffac", - "c14ab103 c0d56206 c1955882 -> 401c2ae7 3f94a4c6 bf5763db 3f141b9e", - "419444af c1fbbb50 41cc44af -> bf13a0c5 bf165a4e 3fc8c685 bf4d21dd", - "c1a6c93f 42409b60 c19ec93f -> 3f0e23d3 402e7369 be99480f 3e21c0b5", - "4273bd9c c2822132 414ef670 -> c05f40c3 c05f40c3 3f0ef4d0 3f06554d", - "425eb2d1 c2194d2f c2494d2f -> 3f864097 4014fb12 bf918e3e 3f18d9dd", - "4233dc77 413f71db c2042389 -> c0b0d116 bf0cb025 4023ddc1 3e049d63", - "4188541f c24bd5f0 41f0541f -> bfb3a8cf 3ee77f73 bc120676 3f503a10", - "42019299 c159b59b c22e6d67 -> 3f68fd3c c0b02c58 bf319ae4 bec485bd", - "c1fe49d1 400db178 c17c93a1 -> c0aa7b81 bef300de 4023be41 be30400d", - "c1fab43e 41cd4bc2 40f52f07 -> 3f4f4a5e bf072d63 40157608 bf34417b", - "4196efa1 c238882f 424b77d1 -> bf19469b 3f960838 be188c9e bf521670", - "c21a422f c1a4845c 425dbdd1 -> c07fd687 3fb452f0 3d6a68c0 bf0d37d8", - "c2627bae 4286c22a c1d4f75b -> bfc2118d 3f532e99 c0b39da4 bea50053", - "c187f3ea c1eff3ea 4120182b -> 3fccecce bff55146 3f408ab8 3f192291", - "40ec0dc2 421d81b8 c0d3f23e -> be93264d 404d5c90 c01de457 bea52c08", - "c13ebe6d 42205065 c11ebe6d -> 3e596a5a 4093c660 c022a333 3e84d2ae", - "c16d9d7b c1eecebe c1b6cebe -> 3ec5d3f1 3fc2faef 40371821 3f1d8b03", - "c103e181 c230f860 423b07a0 -> 409b5eeb bff3de40 bfabc17c be2f1f68", - "c13e1132 c09c2263 4083dd9d -> 3f30edae 3f30ed90 c0c04dc6 3e721259", - "c1b8ec0c c1c8ec0c c180ec0c -> 405f6c78 3fefa135 404c20d5 be4700dc", - "c20134a9 c174d2a4 c164d2a4 -> bfc6f6ef c0c15e61 3e03cf5c be805010", - "41da95ca 41052b93 bfd6a364 -> 3e29eb39 3fbbabb2 3f8084d1 3f446eb1", - "c206ce67 42093199 42013199 -> bfa62996 40087a6d bf5cc459 bf2c639b", - "4229adb3 41eb5b66 c1b4a49a -> 4027e8d0 4027e8d0 c0331921 be94bdc9", - "c1ce5182 bf4a3033 c21328c1 -> bff563cf 405a714b c07a9f25 bded9d0e", - "c18d4bc5 40aad0eb c20aa5e3 -> 3f95f3af c02ca88c 3f63e8f5 3e73d9c1", - "c18f5136 41d0aeca c1cf5136 -> be13625f c08db126 40222572 be8c65bb", - "4251ef9f 4215ef9f c26e1061 -> 3fa97ac3 bfd4717a bfbd2c51 be30d06c", - "41df6857 3f6d0aea c0a25ea3 -> bff42bac 409cc77b bfab903c be2c0dc4", - "402db957 414b6e56 c18a48d6 -> c0ba752c be6647c4 3e77bd86 be9fd9ab", - "c1a193ea 41f66c16 c1b993ea -> bfd47bce 3ddfa79f 3fc081ec 3ea873bc", - "42266905 c20596fb c20196fb -> 3fcbd4d1 3e652430 3ff4fc93 3f01cabb", - "c18de16a 40887a55 41da1e96 -> 3e9d5ba9 409c1b7e c0232bcb be701f9e", - "413c022a 3fe0114d 41ae0115 -> bdc01632 be05b5d6 bf890896 3f263a81", - "c250542b 4203abd5 418757ac -> bf245aae c09019ed 3f4e5349 bf121e22", - "bf6dd748 41e89146 40a24517 -> 3f8b2f90 bf8bb7c7 c09cf330 beed68c8", - "420b9e3e c22861c2 c22861c2 -> 404e378e 3f9e08a5 3fe23d60 be8d4f0d", - "413183a0 413183a0 413183a0 -> bef317ed bef317e1 c04b0c88 bf3701b0", - "42513853 c222c7ad 4124e14a -> bf2f9606 3ee5eb97 4017a261 be3c08bf", - "421033d0 c281e618 424c33d0 -> beff81eb bf1f2bf4 3fcabcca 3e042f68", - "41116c49 41e8b624 c1d749dc -> bf6fe628 bf6fe689 40a4a170 beba3049", - "4123be4b 4123be4b c03106d0 -> bf85b17e 3f94b3dc 40a0b93e 3ee409a4", - "41a17d38 41a17d38 41a17d38 -> bd6234b1 bf6c7400 401cd761 3e20a134", - "c206e35f 424d1ca1 3e8e506a -> 400a0fe8 bfdfae2a 3fd5b7a7 3f26de2d", - "c2139432 c2139432 c2139432 -> 3f2089a2 c0778c6e 3f803b42 bf0d5366", - "c0cd9e79 c106cf3d 42164c31 -> c07c9fa3 404c5f28 bf78d5cc be3559b4", - "41c100e2 40e40386 c22b7f8f -> 3ed7dd22 c02b0424 3fcad2e0 bf2d4e8a", - "42230ced c04f3127 4098676c -> c0626452 3f95e344 c03cb9d0 3effb025", - "c22b6037 42289fc9 41d13f92 -> 3ea908be 402fbe9a 3f13ad5c 3f1861cc", - "c1226b75 c1226b75 41d6ca46 -> bff8d9d7 40b960f3 bfa65223 3d2304b9", - "400b6327 41996c65 421cb632 -> befc6f63 3ff83926 be2f5ac8 bf283133", - "c1062ade 41bcea91 42167548 -> bf2a0de7 c023a9d4 4065ed25 3ddec8f2", - "c1cff936 41c806ca 418006ca -> c0bab1ea 3ff9012a 3fa605be bc0cd7af", - "c1e3242d c106485a 42626de9 -> 400c9250 3e00ffb4 3f24ce7b 3f4721f0", - "4182f92c c21e836a c19d06d4 -> c033ebfa c0a70c98 3e4cc8d1 bea57a20", - "41800c7e c1bff382 41b00c7e -> 3e2de8a4 3fc164e6 c0344986 3e0bfdd1", - "c23e7c5e 422983a2 c159f178 -> 3efa0ae3 40aba62c c023c57f 3e294e21", - "42157598 3faeb310 c15a299e -> bf03b9ea bf03b80b 3fcc22d9 bf4e57a7", - "c2107687 420f8979 c2387687 -> 3feed40b 3f4e600f 3e769654 bef61d79", - "bee9463b c20dd28c 420a2d74 -> c0552489 408ed5a0 3f9ba948 3dec2fe2", - "42401820 c18fcfc0 40a0c0ff -> bf2981fb 40172dad c022cd13 bea270c8", - "411a4518 411a4518 411a4518 -> bfaf3d3e bfb128c5 401b29f4 bebbea12", - "c1af9776 42483445 40434455 -> 3ef824a6 bf73200b 3f2b14d5 be521161", - "40f91788 40f91788 40f91788 -> 401966d2 3ef494ea 4027a253 bcca160f", - "416f44db 40de89b6 c170bb25 -> 4036c56c c0333bce bee2b43f be695215", - "c02288c7 4221d773 c256288d -> bfdddc0e 403ae0e3 bf10a541 3f175582", - "410ad0f1 423ab43c c2654bc4 -> 3f2233c8 40b7d965 c023eaaf 3d12b808", - "c1ed68d2 bfd68d20 4182972e -> 3fcb2b83 c009f5a0 bf9d6643 3f127fc9", - "4257e7fd 414f9ff4 c2441803 -> 400299cb c05dd0b2 408360db bd8437c7", - "c2160c0f c0b06075 c1ac181d -> bf213218 c0b78598 4023ea9d 3d38aa90", - "414f9c31 426fe70d c26c18f3 -> 3fd9032a 3cb7522e bf9d1762 beb0b6cb", - "4256e995 c229166b c225166b -> c03e87af 404ed03a 3f250ae5 be5f05f6", - "40b5fd99 4206bfb4 41a57f66 -> 4007362a bf7b6b1a bf118d1e 3f2d6b64" - ] - }, - { - "glsl": "vec3 cultmath_af_point(float)", - "tolerance": "ulp-bounded", - "cases": [ - "c100e863 -> c100e863 00000000 00000000", - "c157318a -> c157318a 00000000 00000000", - "3fe21080 -> 3fe21080 00000000 00000000", - "40170740 -> 40170740 00000000 00000000", - "c10f7504 -> c10f7504 00000000 00000000", - "41180cbc -> 41180cbc 00000000 00000000", - "c1577606 -> c1577606 00000000 00000000", - "40af8864 -> 40af8864 00000000 00000000", - "c0006dc0 -> c0006dc0 00000000 00000000", - "40fea250 -> 40fea250 00000000 00000000", - "411f93f6 -> 411f93f6 00000000 00000000", - "419e382c -> 419e382c 00000000 00000000", - "c06c0b10 -> c06c0b10 00000000 00000000", - "41886cbe -> 41886cbe 00000000 00000000", - "40732908 -> 40732908 00000000 00000000", - "c0d8619c -> c0d8619c 00000000 00000000", - "c1607274 -> c1607274 00000000 00000000", - "408b9b40 -> 408b9b40 00000000 00000000", - "3ff0ee20 -> 3ff0ee20 00000000 00000000", - "41692bc0 -> 41692bc0 00000000 00000000", - "40a5c5f0 -> 40a5c5f0 00000000 00000000", - "402690c8 -> 402690c8 00000000 00000000", - "41326d56 -> 41326d56 00000000 00000000", - "411bb610 -> 411bb610 00000000 00000000", - "c03c2cd0 -> c03c2cd0 00000000 00000000", - "c10162e3 -> c10162e3 00000000 00000000", - "c169c276 -> c169c276 00000000 00000000", - "c0cccb2c -> c0cccb2c 00000000 00000000", - "c149162d -> c149162d 00000000 00000000", - "c1926dea -> c1926dea 00000000 00000000", - "c14ac648 -> c14ac648 00000000 00000000", - "c190b787 -> c190b787 00000000 00000000", - "4153a474 -> 4153a474 00000000 00000000", - "414332f0 -> 414332f0 00000000 00000000", - "c14e198b -> c14e198b 00000000 00000000", - "c0b05794 -> c0b05794 00000000 00000000", - "be7d3100 -> be7d3100 00000000 00000000", - "410da948 -> 410da948 00000000 00000000", - "41731d34 -> 41731d34 00000000 00000000", - "41206a28 -> 41206a28 00000000 00000000", - "407e7480 -> 407e7480 00000000 00000000", - "419dbc20 -> 419dbc20 00000000 00000000", - "3fde4680 -> 3fde4680 00000000 00000000", - "c09c7f94 -> c09c7f94 00000000 00000000", - "4018a490 -> 4018a490 00000000 00000000", - "40625700 -> 40625700 00000000 00000000", - "c0357360 -> c0357360 00000000 00000000", - "c157aec4 -> c157aec4 00000000 00000000", - "3e1a6400 -> 3e1a6400 00000000 00000000", - "c18b9397 -> c18b9397 00000000 00000000", - "bfb0efd0 -> bfb0efd0 00000000 00000000", - "c184437f -> c184437f 00000000 00000000", - "c0ad8f06 -> c0ad8f06 00000000 00000000", - "418e7d26 -> 418e7d26 00000000 00000000", - "410f9790 -> 410f9790 00000000 00000000", - "4115736a -> 4115736a 00000000 00000000", - "c0933dc0 -> c0933dc0 00000000 00000000", - "41408c00 -> 41408c00 00000000 00000000", - "c16b32fc -> c16b32fc 00000000 00000000", - "4198f6f0 -> 4198f6f0 00000000 00000000", - "40839e64 -> 40839e64 00000000 00000000", - "414eef90 -> 414eef90 00000000 00000000", - "bff92d10 -> bff92d10 00000000 00000000", - "c06cfe70 -> c06cfe70 00000000 00000000", - "3f2176e0 -> 3f2176e0 00000000 00000000", - "41010306 -> 41010306 00000000 00000000", - "c1573420 -> c1573420 00000000 00000000", - "40839498 -> 40839498 00000000 00000000", - "411ef306 -> 411ef306 00000000 00000000", - "c12b09f6 -> c12b09f6 00000000 00000000", - "4157c3f4 -> 4157c3f4 00000000 00000000", - "c0386ef0 -> c0386ef0 00000000 00000000", - "4112b06e -> 4112b06e 00000000 00000000", - "413db39a -> 413db39a 00000000 00000000", - "c1167161 -> c1167161 00000000 00000000", - "40aed570 -> 40aed570 00000000 00000000", - "c199124e -> c199124e 00000000 00000000", - "c07d4b80 -> c07d4b80 00000000 00000000", - "c14a7314 -> c14a7314 00000000 00000000", - "41585f0c -> 41585f0c 00000000 00000000", - "416bf9f8 -> 416bf9f8 00000000 00000000", - "4196f628 -> 4196f628 00000000 00000000", - "415730dc -> 415730dc 00000000 00000000", - "c171eeff -> c171eeff 00000000 00000000", - "40450898 -> 40450898 00000000 00000000", - "c1811fa5 -> c1811fa5 00000000 00000000", - "40eab0ec -> 40eab0ec 00000000 00000000", - "4176aa28 -> 4176aa28 00000000 00000000", - "c186324f -> c186324f 00000000 00000000", - "c00e33d0 -> c00e33d0 00000000 00000000", - "4198b98c -> 4198b98c 00000000 00000000", - "40f6fe78 -> 40f6fe78 00000000 00000000", - "40637110 -> 40637110 00000000 00000000", - "418097aa -> 418097aa 00000000 00000000", - "c161650a -> c161650a 00000000 00000000", - "4130ad92 -> 4130ad92 00000000 00000000", - "3fd4ef20 -> 3fd4ef20 00000000 00000000", - "c168f794 -> c168f794 00000000 00000000", - "4167a8c8 -> 4167a8c8 00000000 00000000", - "41652620 -> 41652620 00000000 00000000", - "c040d880 -> c040d880 00000000 00000000", - "4150d8dc -> 4150d8dc 00000000 00000000", - "c05a8728 -> c05a8728 00000000 00000000", - "c1128c7c -> c1128c7c 00000000 00000000", - "c12eeb24 -> c12eeb24 00000000 00000000", - "c194011f -> c194011f 00000000 00000000", - "c0b66eda -> c0b66eda 00000000 00000000", - "402e1380 -> 402e1380 00000000 00000000", - "40e6d758 -> 40e6d758 00000000 00000000", - "c183e994 -> c183e994 00000000 00000000", - "41079806 -> 41079806 00000000 00000000", - "419ada00 -> 419ada00 00000000 00000000", - "4095fe28 -> 4095fe28 00000000 00000000", - "c1039209 -> c1039209 00000000 00000000", - "c17a0c17 -> c17a0c17 00000000 00000000", - "40a7c5c8 -> 40a7c5c8 00000000 00000000", - "419bdf5a -> 419bdf5a 00000000 00000000", - "c0da6d46 -> c0da6d46 00000000 00000000", - "41537e3c -> 41537e3c 00000000 00000000", - "c04ea520 -> c04ea520 00000000 00000000", - "c19a2ab8 -> c19a2ab8 00000000 00000000", - "c10dde4a -> c10dde4a 00000000 00000000", - "3f62ee80 -> 3f62ee80 00000000 00000000", - "c0fb0008 -> c0fb0008 00000000 00000000", - "c11c7d0c -> c11c7d0c 00000000 00000000", - "c163bb46 -> c163bb46 00000000 00000000", - "41590800 -> 41590800 00000000 00000000", - "4151811c -> 4151811c 00000000 00000000", - "40be3148 -> 40be3148 00000000 00000000", - "bee3de80 -> bee3de80 00000000 00000000", - "c1819995 -> c1819995 00000000 00000000", - "4176d2f8 -> 4176d2f8 00000000 00000000", - "3fc822c0 -> 3fc822c0 00000000 00000000", - "c0df3266 -> c0df3266 00000000 00000000", - "c05dab50 -> c05dab50 00000000 00000000", - "c1926f73 -> c1926f73 00000000 00000000", - "40123860 -> 40123860 00000000 00000000", - "4026f560 -> 4026f560 00000000 00000000", - "417cfc24 -> 417cfc24 00000000 00000000", - "3fca2330 -> 3fca2330 00000000 00000000", - "4118f824 -> 4118f824 00000000 00000000", - "c1762c6c -> c1762c6c 00000000 00000000", - "c13cc183 -> c13cc183 00000000 00000000", - "419db744 -> 419db744 00000000 00000000", - "4114db06 -> 4114db06 00000000 00000000", - "419ddf8a -> 419ddf8a 00000000 00000000", - "c187bfec -> c187bfec 00000000 00000000", - "c10391b3 -> c10391b3 00000000 00000000", - "413b3b6a -> 413b3b6a 00000000 00000000", - "3f2b8120 -> 3f2b8120 00000000 00000000", - "4138eee0 -> 4138eee0 00000000 00000000", - "c1382b7a -> c1382b7a 00000000 00000000", - "c0f8eba4 -> c0f8eba4 00000000 00000000", - "c012b7c0 -> c012b7c0 00000000 00000000", - "41597b90 -> 41597b90 00000000 00000000", - "c16257d4 -> c16257d4 00000000 00000000", - "c0faac1a -> c0faac1a 00000000 00000000", - "c17921c6 -> c17921c6 00000000 00000000", - "c19b07b8 -> c19b07b8 00000000 00000000", - "c18597ef -> c18597ef 00000000 00000000", - "c1410a40 -> c1410a40 00000000 00000000", - "3f9a3bb0 -> 3f9a3bb0 00000000 00000000", - "4186361e -> 4186361e 00000000 00000000", - "c1457560 -> c1457560 00000000 00000000", - "419db000 -> 419db000 00000000 00000000", - "4150c50c -> 4150c50c 00000000 00000000", - "c00d4158 -> c00d4158 00000000 00000000", - "c10567b8 -> c10567b8 00000000 00000000", - "4173d8cc -> 4173d8cc 00000000 00000000", - "c18a9698 -> c18a9698 00000000 00000000", - "c188559b -> c188559b 00000000 00000000", - "c047fa98 -> c047fa98 00000000 00000000", - "c028cb20 -> c028cb20 00000000 00000000", - "c105c628 -> c105c628 00000000 00000000", - "40e6bd30 -> 40e6bd30 00000000 00000000", - "4180eb7e -> 4180eb7e 00000000 00000000", - "c1888e64 -> c1888e64 00000000 00000000", - "3f960300 -> 3f960300 00000000 00000000", - "403693d8 -> 403693d8 00000000 00000000", - "c1183c20 -> c1183c20 00000000 00000000", - "c18a1db6 -> c18a1db6 00000000 00000000", - "3fe4cdb0 -> 3fe4cdb0 00000000 00000000", - "c194dd26 -> c194dd26 00000000 00000000", - "c16b9f6f -> c16b9f6f 00000000 00000000", - "40ffe45c -> 40ffe45c 00000000 00000000", - "4174f850 -> 4174f850 00000000 00000000", - "404d2328 -> 404d2328 00000000 00000000", - "c18126db -> c18126db 00000000 00000000", - "bf114c40 -> bf114c40 00000000 00000000", - "c1151300 -> c1151300 00000000 00000000", - "41187728 -> 41187728 00000000 00000000", - "c0094088 -> c0094088 00000000 00000000", - "3ffe6640 -> 3ffe6640 00000000 00000000", - "41482c04 -> 41482c04 00000000 00000000", - "c0cb62b6 -> c0cb62b6 00000000 00000000", - "c13a4f54 -> c13a4f54 00000000 00000000", - "c14298aa -> c14298aa 00000000 00000000", - "c19ba612 -> c19ba612 00000000 00000000", - "c19ff8bd -> c19ff8bd 00000000 00000000", - "41820afc -> 41820afc 00000000 00000000", - "3ff87b50 -> 3ff87b50 00000000 00000000", - "4135e7e0 -> 4135e7e0 00000000 00000000", - "c05da9f8 -> c05da9f8 00000000 00000000", - "4110689a -> 4110689a 00000000 00000000", - "c01272e0 -> c01272e0 00000000 00000000", - "c0aa24f6 -> c0aa24f6 00000000 00000000", - "4132074e -> 4132074e 00000000 00000000", - "c19b57d5 -> c19b57d5 00000000 00000000", - "4127f378 -> 4127f378 00000000 00000000", - "418bd24a -> 418bd24a 00000000 00000000", - "c1889d86 -> c1889d86 00000000 00000000", - "412fe994 -> 412fe994 00000000 00000000", - "3fc9ca20 -> 3fc9ca20 00000000 00000000", - "41222cb0 -> 41222cb0 00000000 00000000", - "c19b7a38 -> c19b7a38 00000000 00000000", - "40c4b818 -> 40c4b818 00000000 00000000", - "be3f8f00 -> be3f8f00 00000000 00000000", - "41380bac -> 41380bac 00000000 00000000", - "beacf180 -> beacf180 00000000 00000000", - "c179984c -> c179984c 00000000 00000000", - "c12283bd -> c12283bd 00000000 00000000", - "c0c20540 -> c0c20540 00000000 00000000", - "4143ad0c -> 4143ad0c 00000000 00000000", - "4091d798 -> 4091d798 00000000 00000000", - "c0db48ac -> c0db48ac 00000000 00000000", - "40a349d8 -> 40a349d8 00000000 00000000", - "416e3494 -> 416e3494 00000000 00000000", - "409b4268 -> 409b4268 00000000 00000000", - "418ff59a -> 418ff59a 00000000 00000000", - "bf9290b0 -> bf9290b0 00000000 00000000", - "41046fa4 -> 41046fa4 00000000 00000000", - "c18ce852 -> c18ce852 00000000 00000000", - "3f958ed0 -> 3f958ed0 00000000 00000000", - "40d31df8 -> 40d31df8 00000000 00000000", - "4108b474 -> 4108b474 00000000 00000000", - "c10a234c -> c10a234c 00000000 00000000", - "c16bfbcc -> c16bfbcc 00000000 00000000", - "c0f445d0 -> c0f445d0 00000000 00000000", - "40f1fa90 -> 40f1fa90 00000000 00000000", - "c0d5f6ae -> c0d5f6ae 00000000 00000000", - "c17d0eff -> c17d0eff 00000000 00000000", - "4027e1d0 -> 4027e1d0 00000000 00000000", - "c0d48260 -> c0d48260 00000000 00000000", - "3ffa3530 -> 3ffa3530 00000000 00000000", - "c143d7f4 -> c143d7f4 00000000 00000000", - "419446c8 -> 419446c8 00000000 00000000", - "41823b4e -> 41823b4e 00000000 00000000", - "413da018 -> 413da018 00000000 00000000", - "413f2074 -> 413f2074 00000000 00000000", - "40efe534 -> 40efe534 00000000 00000000", - "4108aee8 -> 4108aee8 00000000 00000000", - "c06a9158 -> c06a9158 00000000 00000000", - "3f61b6a0 -> 3f61b6a0 00000000 00000000", - "4179a6d4 -> 4179a6d4 00000000 00000000", - "40cd336c -> 40cd336c 00000000 00000000", - "c13fedf5 -> c13fedf5 00000000 00000000" - ] - }, - { - "glsl": "vec3 cultmath_af_symbol(float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "41991d6a 403fa9b6 -> 41991d6a 403fa9b6 00000000", - "c083e620 4049be5c -> c083e620 4049be5c 00000000", - "be51c380 c05b99e6 -> be51c380 c05b99e6 00000000", - "c18b4d6e c005ba72 -> c18b4d6e c005ba72 00000000", - "c12ccb11 c09bb534 -> c12ccb11 c09bb534 00000000", - "c122c845 406faa44 -> c122c845 406faa44 00000000", - "c19343e2 40132edc -> c19343e2 40132edc 00000000", - "3f657d80 c048db56 -> 3f657d80 c048db56 00000000", - "c18078ce c05a6c36 -> c18078ce c05a6c36 00000000", - "c19e44a7 3fe7079c -> c19e44a7 3fe7079c 00000000", - "c19b60b8 c01b999c -> c19b60b8 c01b999c 00000000", - "c04cf108 bfac63d0 -> c04cf108 bfac63d0 00000000", - "410d2e50 c087b5c2 -> 410d2e50 c087b5c2 00000000", - "414e80c0 c0180766 -> 414e80c0 c0180766 00000000", - "4124ff00 c000ec04 -> 4124ff00 c000ec04 00000000", - "3fc09f90 3fb21608 -> 3fc09f90 3fb21608 00000000", - "c19e855c 3e0a2680 -> c19e855c 3e0a2680 00000000", - "c0f8bc40 bfd74b04 -> c0f8bc40 bfd74b04 00000000", - "4183e814 406f3eec -> 4183e814 406f3eec 00000000", - "41584bb8 408f4574 -> 41584bb8 408f4574 00000000", - "3d135000 c092435f -> 3d135000 c092435f 00000000", - "c0e7dc90 c04c6d8c -> c0e7dc90 c04c6d8c 00000000", - "410b55d6 c09599d5 -> 410b55d6 c09599d5 00000000", - "412427dc c08a0734 -> 412427dc c08a0734 00000000", - "c1566540 3e8c51f0 -> c1566540 3e8c51f0 00000000", - "c0f36576 bfaef0c0 -> c0f36576 bfaef0c0 00000000", - "41763020 40998af2 -> 41763020 40998af2 00000000", - "c1492c84 400dd470 -> c1492c84 400dd470 00000000", - "c09a3414 c095e094 -> c09a3414 c095e094 00000000", - "c181b7fa bf4f6e28 -> c181b7fa bf4f6e28 00000000", - "c0d43550 40416c88 -> c0d43550 40416c88 00000000", - "3faa3470 408a1078 -> 3faa3470 408a1078 00000000", - "bf77e580 3f885970 -> bf77e580 3f885970 00000000", - "416cb4fc 3e86aea0 -> 416cb4fc 3e86aea0 00000000", - "c041cc10 c04602a5 -> c041cc10 c04602a5 00000000", - "c110ab7e c0303088 -> c110ab7e c0303088 00000000", - "c0e56fda c08d8a1a -> c0e56fda c08d8a1a 00000000", - "c14d0f82 4096e2a6 -> c14d0f82 4096e2a6 00000000", - "418c2a56 c026ceb5 -> 418c2a56 c026ceb5 00000000", - "40bcf084 3ff0c3f4 -> 40bcf084 3ff0c3f4 00000000", - "c0e726c2 40228f28 -> c0e726c2 40228f28 00000000", - "c180d113 c02c8b3e -> c180d113 c02c8b3e 00000000", - "419c635c c05073af -> 419c635c c05073af 00000000", - "4122dae6 c098104f -> 4122dae6 c098104f 00000000", - "c0dc6224 3f5735c0 -> c0dc6224 3f5735c0 00000000", - "4190ba44 40739150 -> 4190ba44 40739150 00000000", - "4132aee0 bf4f6300 -> 4132aee0 bf4f6300 00000000", - "40914b20 3ffe4d90 -> 40914b20 3ffe4d90 00000000", - "3ec65680 bf901e74 -> 3ec65680 bf901e74 00000000", - "410310ce c078d6e0 -> 410310ce c078d6e0 00000000", - "c157e8a6 c02cadf6 -> c157e8a6 c02cadf6 00000000", - "40b8c938 4097ceb2 -> 40b8c938 4097ceb2 00000000", - "c11dca43 c084c11a -> c11dca43 c084c11a 00000000", - "c1926039 40514454 -> c1926039 40514454 00000000", - "41402568 c036f1d2 -> 41402568 c036f1d2 00000000", - "41357fc4 c0664b54 -> 41357fc4 c0664b54 00000000", - "c09472d0 bf6f47b8 -> c09472d0 bf6f47b8 00000000", - "c1802414 3f4d58c0 -> c1802414 3f4d58c0 00000000", - "41030eb0 bffc5c6a -> 41030eb0 bffc5c6a 00000000", - "418dad1e bffe1554 -> 418dad1e bffe1554 00000000", - "416151d0 405cd59c -> 416151d0 405cd59c 00000000", - "c140f91c 4059bf8c -> c140f91c 4059bf8c 00000000", - "c127772c bf88799c -> c127772c bf88799c 00000000", - "c00b7da0 4080906a -> c00b7da0 4080906a 00000000", - "c00ee710 be436480 -> c00ee710 be436480 00000000", - "bfc36b30 3f018f90 -> bfc36b30 3f018f90 00000000", - "3fb103f0 3eba7900 -> 3fb103f0 3eba7900 00000000", - "3f825500 c08372b5 -> 3f825500 c08372b5 00000000", - "c179d574 c0713f8b -> c179d574 c0713f8b 00000000", - "41989f84 40812476 -> 41989f84 40812476 00000000", - "c16bb33c 4088cb48 -> c16bb33c 4088cb48 00000000", - "c1304606 c0773f40 -> c1304606 c0773f40 00000000", - "41404dac 4047bfdc -> 41404dac 4047bfdc 00000000", - "be0d5200 bfa2fe66 -> be0d5200 bfa2fe66 00000000", - "c0e7212e c0955851 -> c0e7212e c0955851 00000000", - "419e0c0c c03b9f17 -> 419e0c0c c03b9f17 00000000", - "c00da5d8 bf779228 -> c00da5d8 bf779228 00000000", - "c11a28b0 bfe97c80 -> c11a28b0 bfe97c80 00000000", - "c195da6e 4042a510 -> c195da6e 4042a510 00000000", - "41171490 4066728c -> 41171490 4066728c 00000000", - "40b2ba68 c065e145 -> 40b2ba68 c065e145 00000000", - "c09603d2 bfe7489c -> c09603d2 bfe7489c 00000000", - "41217b94 c02ae422 -> 41217b94 c02ae422 00000000", - "40872858 405e7778 -> 40872858 405e7778 00000000", - "4173e370 c09cb15f -> 4173e370 c09cb15f 00000000", - "bf96a2e0 3f5138e8 -> bf96a2e0 3f5138e8 00000000", - "c0deda76 c0937758 -> c0deda76 c0937758 00000000", - "c153576e 4087dda0 -> c153576e 4087dda0 00000000", - "409a3740 c084dcee -> 409a3740 c084dcee 00000000", - "c1934710 bf3cdc20 -> c1934710 bf3cdc20 00000000", - "417df878 c088b01b -> 417df878 c088b01b 00000000", - "4052c5a8 bf642480 -> 4052c5a8 bf642480 00000000", - "bf04e620 c01cce4f -> bf04e620 c01cce4f 00000000", - "c17c32a4 c06bfafa -> c17c32a4 c06bfafa 00000000", - "c10e882f c03af71f -> c10e882f c03af71f 00000000", - "c18d9848 bff8f50a -> c18d9848 bff8f50a 00000000", - "c090a838 c0753384 -> c090a838 c0753384 00000000", - "c117144a 409d1704 -> c117144a 409d1704 00000000", - "3fe4c3d0 4081af24 -> 3fe4c3d0 4081af24 00000000", - "c0b175a8 3f2cc738 -> c0b175a8 3f2cc738 00000000", - "c13bd452 3fbea680 -> c13bd452 3fbea680 00000000", - "beac5480 bff45bb4 -> beac5480 bff45bb4 00000000", - "40208ef0 bf60d888 -> 40208ef0 bf60d888 00000000", - "4173ce24 bf71eb20 -> 4173ce24 bf71eb20 00000000", - "c12a8d1b bfd3c7e0 -> c12a8d1b bfd3c7e0 00000000", - "40fc4c40 408f0280 -> 40fc4c40 408f0280 00000000", - "41293330 bff368d0 -> 41293330 bff368d0 00000000", - "41943d08 3f2af5a8 -> 41943d08 3f2af5a8 00000000", - "4015b548 4097039c -> 4015b548 4097039c 00000000", - "4154aa10 bcdb0e00 -> 4154aa10 bcdb0e00 00000000", - "c16eb17e be8386c0 -> c16eb17e be8386c0 00000000", - "4033fe98 3fddb520 -> 4033fe98 3fddb520 00000000", - "4190e6e8 c05659d8 -> 4190e6e8 c05659d8 00000000", - "c1435daa c03a39b7 -> c1435daa c03a39b7 00000000", - "4130259a c04d8577 -> 4130259a c04d8577 00000000", - "c099ba74 4009bd56 -> c099ba74 4009bd56 00000000", - "410f00f8 be8dff60 -> 410f00f8 be8dff60 00000000", - "c13362b6 c0215ac8 -> c13362b6 c0215ac8 00000000", - "405009c0 c01120bc -> 405009c0 c01120bc 00000000", - "415ed324 c0880c20 -> 415ed324 c0880c20 00000000", - "c0a138e8 40004824 -> c0a138e8 40004824 00000000", - "417e9224 408dade0 -> 417e9224 408dade0 00000000", - "3edc5800 c0793590 -> 3edc5800 c0793590 00000000", - "3fd29250 c0874fda -> 3fd29250 c0874fda 00000000", - "c15dad96 3ffc5c98 -> c15dad96 3ffc5c98 00000000", - "c02cfd20 3f3a4508 -> c02cfd20 3f3a4508 00000000", - "c188a5e5 4068fb48 -> c188a5e5 4068fb48 00000000", - "c01872d0 40149c88 -> c01872d0 40149c88 00000000", - "c186d632 404bc2cc -> c186d632 404bc2cc 00000000", - "c0b7f754 bf8304dc -> c0b7f754 bf8304dc 00000000", - "c134d879 3fdc0fb8 -> c134d879 3fdc0fb8 00000000", - "40a6bf38 c08e83d2 -> 40a6bf38 c08e83d2 00000000", - "41917ca4 409a3464 -> 41917ca4 409a3464 00000000", - "c130fbf7 c0050ce4 -> c130fbf7 c0050ce4 00000000", - "c18328d9 4009d4da -> c18328d9 4009d4da 00000000", - "419b5d7e c00971f4 -> 419b5d7e c00971f4 00000000", - "c170cbec 4024c252 -> c170cbec 4024c252 00000000", - "c17119a8 bf3be688 -> c17119a8 bf3be688 00000000", - "4043f410 3fa347c8 -> 4043f410 3fa347c8 00000000", - "c1580830 405b0360 -> c1580830 405b0360 00000000", - "409ea7b8 c074bdf4 -> 409ea7b8 c074bdf4 00000000", - "c18e4610 c0870458 -> c18e4610 c0870458 00000000", - "411db9d0 40449184 -> 411db9d0 40449184 00000000", - "40b61240 406605b0 -> 40b61240 406605b0 00000000", - "c195d19c bdffe7c0 -> c195d19c bdffe7c0 00000000", - "c153ae64 40283fa4 -> c153ae64 40283fa4 00000000", - "41856d78 befd5370 -> 41856d78 befd5370 00000000", - "4164c038 40015bb0 -> 4164c038 40015bb0 00000000", - "c1898bbe 405b99c8 -> c1898bbe 405b99c8 00000000", - "419c313e 3e93cfc0 -> 419c313e 3e93cfc0 00000000", - "4177c668 c020a0d1 -> 4177c668 c020a0d1 00000000", - "419bd8fe bf1e09c0 -> 419bd8fe bf1e09c0 00000000", - "41077350 c061cd54 -> 41077350 c061cd54 00000000", - "c0028b48 bfec1c38 -> c0028b48 bfec1c38 00000000", - "411a14f0 c09b918a -> 411a14f0 c09b918a 00000000", - "c15c607d befa8240 -> c15c607d befa8240 00000000", - "40c795f8 3e100f40 -> 40c795f8 3e100f40 00000000", - "412f29b6 c0800d42 -> 412f29b6 c0800d42 00000000", - "409527f8 3f05a138 -> 409527f8 3f05a138 00000000", - "c0f582e8 c061983c -> c0f582e8 c061983c 00000000", - "c0cd40b0 bfae034e -> c0cd40b0 bfae034e 00000000", - "c11969ab 3f835b18 -> c11969ab 3f835b18 00000000", - "3fec19f0 c03184a7 -> 3fec19f0 c03184a7 00000000", - "c0a899c2 3fddbd04 -> c0a899c2 3fddbd04 00000000", - "4180010c bf49d560 -> 4180010c bf49d560 00000000", - "c0b7c44a 4015633e -> c0b7c44a 4015633e 00000000", - "40b282d4 3faafbb0 -> 40b282d4 3faafbb0 00000000", - "41919e7c bfa016a4 -> 41919e7c bfa016a4 00000000", - "c16c6ff2 3f95eca0 -> c16c6ff2 3f95eca0 00000000", - "c0aaf800 3f7e1c90 -> c0aaf800 3f7e1c90 00000000", - "c0b59754 bfddd188 -> c0b59754 bfddd188 00000000", - "c1740f40 c09a4012 -> c1740f40 c09a4012 00000000", - "c0d73d7e 400ba1e4 -> c0d73d7e 400ba1e4 00000000", - "c17b8b58 bf789818 -> c17b8b58 bf789818 00000000", - "40e257bc 4024dabe -> 40e257bc 4024dabe 00000000", - "c1849c26 3e380360 -> c1849c26 3e380360 00000000", - "3fb2d9c0 4059fab4 -> 3fb2d9c0 4059fab4 00000000", - "c146e5b0 3e6c8100 -> c146e5b0 3e6c8100 00000000", - "419c646c bf93f71c -> 419c646c bf93f71c 00000000", - "417afa54 bde10140 -> 417afa54 bde10140 00000000", - "41327f8e 40307eac -> 41327f8e 40307eac 00000000", - "c05840d0 bfe6eb70 -> c05840d0 bfe6eb70 00000000", - "40c97e20 bf470ef0 -> 40c97e20 bf470ef0 00000000", - "41476e50 c098d96e -> 41476e50 c098d96e 00000000", - "40170fe8 bf8195f2 -> 40170fe8 bf8195f2 00000000", - "41962ab8 409fced8 -> 41962ab8 409fced8 00000000", - "c1491bb2 4005b768 -> c1491bb2 4005b768 00000000", - "4139336c c09bdbca -> 4139336c c09bdbca 00000000", - "c122f268 c024e987 -> c122f268 c024e987 00000000", - "c112b3b5 4051e158 -> c112b3b5 4051e158 00000000", - "c175f94f 4094ec92 -> c175f94f 4094ec92 00000000", - "419ed952 c064d8a6 -> 419ed952 c064d8a6 00000000", - "c0d27a18 40589da4 -> c0d27a18 40589da4 00000000", - "c140f7fb 403f46b6 -> c140f7fb 403f46b6 00000000", - "c00e71e8 bf2e2c58 -> c00e71e8 bf2e2c58 00000000", - "c091a858 401d8b9c -> c091a858 401d8b9c 00000000", - "410ffbfc 40718c08 -> 410ffbfc 40718c08 00000000", - "414d0798 3f52d6a8 -> 414d0798 3f52d6a8 00000000", - "418393b8 403f6678 -> 418393b8 403f6678 00000000", - "c0b27e6a 4083127e -> c0b27e6a 4083127e 00000000", - "418219cc c084ec3e -> 418219cc c084ec3e 00000000", - "415c1600 c00e092a -> 415c1600 c00e092a 00000000", - "41388550 c0846afd -> 41388550 c0846afd 00000000", - "c0d6c82e 4050a3d4 -> c0d6c82e 4050a3d4 00000000", - "c18f9c5c c04f2e1c -> c18f9c5c c04f2e1c 00000000", - "c10e458a 401db262 -> c10e458a 401db262 00000000", - "c17747da c08b7383 -> c17747da c08b7383 00000000", - "c0a21d74 4048a668 -> c0a21d74 4048a668 00000000", - "4132cc08 c011378d -> 4132cc08 c011378d 00000000", - "419ae3aa 404c216c -> 419ae3aa 404c216c 00000000", - "c130cbc2 c09bec34 -> c130cbc2 c09bec34 00000000", - "4047a678 c06eb0f0 -> 4047a678 c06eb0f0 00000000", - "c19bfb67 c0313630 -> c19bfb67 c0313630 00000000", - "c1105e4e bff54f78 -> c1105e4e bff54f78 00000000", - "4178afd0 c03b823c -> 4178afd0 c03b823c 00000000", - "c17edf04 bf096380 -> c17edf04 bf096380 00000000", - "417455ac bfb1b162 -> 417455ac bfb1b162 00000000", - "4186d6e0 c0961069 -> 4186d6e0 c0961069 00000000", - "c1723cda 400bbbce -> c1723cda 400bbbce 00000000", - "c0babbf0 c0206713 -> c0babbf0 c0206713 00000000", - "3e803780 bfa3379a -> 3e803780 bfa3379a 00000000", - "411e7f6c c0146e5d -> 411e7f6c c0146e5d 00000000", - "c15d458c 3fb2f2e8 -> c15d458c 3fb2f2e8 00000000", - "40a9a6ec 3fcdc600 -> 40a9a6ec 3fcdc600 00000000", - "3e26b100 c09dcf69 -> 3e26b100 c09dcf69 00000000", - "4141e9a0 3fb0bdf8 -> 4141e9a0 3fb0bdf8 00000000", - "41499f24 3ed4fae0 -> 41499f24 3ed4fae0 00000000", - "40ede17c 407c0c00 -> 40ede17c 407c0c00 00000000", - "3e87bcc0 400ac6f0 -> 3e87bcc0 400ac6f0 00000000", - "c116125c 3f26ee08 -> c116125c 3f26ee08 00000000", - "41478854 c0985e2d -> 41478854 c0985e2d 00000000", - "418bfa00 405c4984 -> 418bfa00 405c4984 00000000", - "c188278c 40541358 -> c188278c 40541358 00000000", - "41695cb0 402190d8 -> 41695cb0 402190d8 00000000", - "c16494c7 bfc9dbd0 -> c16494c7 bfc9dbd0 00000000", - "40f5c684 c08c77e3 -> 40f5c684 c08c77e3 00000000", - "41861336 40162e66 -> 41861336 40162e66 00000000", - "c0efc09c 4060d00c -> c0efc09c 4060d00c 00000000", - "c11657d4 bff3500a -> c11657d4 bff3500a 00000000", - "41974a4e bfa2e084 -> 41974a4e bfa2e084 00000000", - "4067d968 3f917d60 -> 4067d968 3f917d60 00000000", - "4142bd80 40744ea4 -> 4142bd80 40744ea4 00000000", - "c075af70 beb9f000 -> c075af70 beb9f000 00000000", - "40a80ff8 bfcc935e -> 40a80ff8 bfcc935e 00000000", - "40e06d20 c0972f1e -> 40e06d20 c0972f1e 00000000", - "3f7a1480 bf740f20 -> 3f7a1480 bf740f20 00000000", - "bff18eb0 4038e688 -> bff18eb0 4038e688 00000000", - "c01fbda0 be341ea0 -> c01fbda0 be341ea0 00000000", - "c0263f40 40811af4 -> c0263f40 40811af4 00000000", - "c1441f46 bfe2b1c4 -> c1441f46 bfe2b1c4 00000000", - "41301cc2 407342a0 -> 41301cc2 407342a0 00000000", - "3f377c80 c0587754 -> 3f377c80 c0587754 00000000", - "c0ed0428 401ad968 -> c0ed0428 401ad968 00000000", - "410c3892 c08647a0 -> 410c3892 c08647a0 00000000", - "c12d8054 405620b4 -> c12d8054 405620b4 00000000", - "40a4c7a8 c0421a14 -> 40a4c7a8 c0421a14 00000000" - ] - }, - { - "glsl": "vec3 cultmath_af_from_iv(vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "4104ebdf 413378c5 -> 411c3252 00000000 3fba33f2", - "4197e194 4197e394 -> 4197e294 00000000 3a04bf1d", - "c1337a3e c1337976 -> c13379da 00000000 38de6f48", - "c01cca84 c0158a7c -> c0192a80 00000000 3d680373", - "c1404a76 c13f9ed2 -> c13ff4a4 00000000 3cabbc09", - "c187533f c1875279 -> c18752dc 00000000 3956ea68", - "414b6b37 414b7669 -> 414b70d0 00000000 3ab4b6ed", - "408a824b 408a85f5 -> 408a8420 00000000 396ed430", - "c10d3886 c0ed17bd -> c101e232 00000000 3f3565c9", - "c056b53c c0564be4 -> c0568090 00000000 3b52e5ad", - "c176f478 c1741d08 -> c17588c0 00000000 3db5e3b8", - "406e6178 40829b34 -> 4079cbf0 00000000 3e36a885", - "c1820399 c180b57f -> c1815c8c 00000000 3da71520", - "4024b8c4 4031ccec -> 402b42d8 00000000 3dd143e4", - "411c1508 411cfdd4 -> 411c896e 00000000 3ce8dfa0", - "c182c9d8 c16bff08 -> c178c95c 00000000 3f4ca646", - "c08195f2 c081724e -> c0818420 00000000 3b0ed0cb", - "40cc912d 40ce966b -> 40cd93cc 00000000 3d0155f5", - "41491e26 4149249a -> 41492160 00000000 3a51a492", - "c117d836 c117b7ea -> c117c810 00000000 3b817bec", - "bfc13aab bfb6bcd5 -> bfbbfbc0 00000000 3d27dee2", - "c17167ea c1716092 -> c171643e 00000000 3a6ec5a0", - "4141d33c 4141fd74 -> 4141e858 00000000 3ba940ff", - "c0c7d0d8 c0c7cfb8 -> c0c7d048 00000000 389c7d0e", - "c16b1d21 c169b42d -> c16a68a7 00000000 3d3488b2", - "41353eca 4135671a -> 413552f2 00000000 3ba19ab4", - "c0510e5d c050eae3 -> c050fca0 00000000 3a8e5087", - "c18648f9 c186485d -> c18648ab 00000000 392cc91f", - "c1031961 c10310cd -> c1031517 00000000 3a8a4633", - "c17f1a84 c17ddffe -> c17e7d41 00000000 3d1d52f2", - "bf562c5e bd73e218 -> bee56a80 00000000 3ec6ee57", - "4168fcdb 416bce1d -> 416a657c 00000000 3db457de", - "c05e4d83 c05e349d -> c05e4110 00000000 3a480e4e", - "410a51af 410ac559 -> 410a8b84 00000000 3c6776b1", - "40a23995 40a23b03 -> 40a23a4c 00000000 38c123b0", - "c0ebc3c1 c0ebc22b -> c0ebc2f6 00000000 38d9bc3c", - "402ca56f 402ca7f1 -> 402ca6b0 00000000 38a5e540", - "417e925a 417f511e -> 417ef1bc 00000000 3cbee3ea", - "3f8a3515 3f8ae6cb -> 3f8a8df0 00000000 3b31c75d", - "41813a8b 418390d9 -> 418265b2 00000000 3e15979d", - "c10148fd c1007d15 -> c100e309 00000000 3ccbf829", - "3f91114d 3f9124f3 -> 3f911b20 00000000 399dc125", - "4128571f 412e3175 -> 412b444a 00000000 3e3b4d79", - "c046afa3 c046a82d -> c046abe8 00000000 3971dabf", - "c1223e78 c1212826 -> c121b34f 00000000 3d0b3324", - "c116edf2 c116075a -> c1167aa6 00000000 3ce6aade", - "c16a61a6 c16615f4 -> c1683bcd 00000000 3e0979ea", - "4177d404 417c1844 -> 4179f624 00000000 3e088bf0", - "410a5c85 410abc2f -> 410a8c5a 00000000 3c3f76af", - "41577b2e 4158921a -> 415806a4 00000000 3d0b8389", - "40d0928a 4105fc53 -> 40ee4598 00000000 3f6d98f6", - "c07e1b42 c07e16de -> c07e1910 00000000 3910786d", - "c1148d0b c10dbea5 -> c11125d8 00000000 3e59cf12", - "4153e3da 415404f6 -> 4153f468 00000000 3b84da02", - "c0a8de2f c0a72281 -> c0a80058 00000000 3cdde18e", - "bd972560 40ae28ee -> 402bcc58 00000000 4030859a", - "c0b7a179 c0b7465b -> c0b773ea 00000000 3bb669e8", - "c13a76d0 c0c240e9 -> c10dcba2 00000000 4032ace6", - "c123050d c11d4c6d -> c12028bd 00000000 3e37168c", - "4171a43b 4176bb75 -> 41742fd8 00000000 3e22eb1b", - "4148438c 41499b3c -> 4148ef64 00000000 3d2be49a", - "c12497a5 c12496d3 -> c124973c 00000000 38e692f5", - "412fe85d 413ab07f -> 41354c6e 00000000 3eac8395", - "4178971c 4190c71e -> 41868956 00000000 3fa3dd11", - "c162637e c1625eba -> c162611c 00000000 3a1c098e", - "414af8b3 414af975 -> 414af914 00000000 38db5f2f", - "3ebd7340 3ec00ac0 -> 3ebebf00 00000000 3b25e600", - "c19dd647 c19db3f1 -> c19dc51c 00000000 3c09a6eb", - "c167616a c1671e66 -> c1673fe8 00000000 3c0641d8", - "4174b643 4174b6ed -> 4174b698 00000000 38c896de", - "417423d8 41742480 -> 4174242c 00000000 38c68490", - "4125c05f 412ad8b9 -> 41284c8c 00000000 3e230deb", - "419fc511 419fcce7 -> 419fc8fc 00000000 3afd3f34", - "c147b2fc c140b936 -> c1443619 00000000 3e5f3bdf", - "c0c7e582 bf954638 -> c06d3710 00000000 4022940d", - "c0254660 c02544a0 -> c0254580 00000000 386a5466", - "406bdb29 406be317 -> 406bdf20 00000000 3980b7c6", - "4121b3e4 4121b534 -> 4121b48c 00000000 39321b53", - "408ddea6 408e07ea -> 408df348 00000000 3b255704", - "c0fd9af4 c0fc8090 -> c0fd0dc2 00000000 3c8d41da", - "4116ac26 417026b2 -> 4143696c 00000000 4032f554", - "c1297450 c12971dc -> c1297316 00000000 39a24ba2", - "4112a44e 41133c02 -> 4112f028 00000000 3c97c668", - "c01c1fa4 c01c1dac -> c01c1ea8 00000000 3882e0fd", - "c094a2c1 c04b175d -> c07a2e70 00000000 3f3c5c94", - "413e2f18 414f8668 -> 4146dac0 00000000 3f0abb50", - "41457ba4 415ec09c -> 41521e20 00000000 3f4a289f", - "414654b3 41521145 -> 414c32fc 00000000 3ebbcac4", - "414d894b 414e5be5 -> 414df298 00000000 3cd2b3cb", - "c18c9306 c18c66de -> c18c7cf2 00000000 3c30e64a", - "40390b34 40391a3c -> 403912b8 00000000 39f1f234", - "bf838ad0 bf836810 -> bf837970 00000000 3a0b41c5", - "41289fae 413adac2 -> 4131bd38 00000000 3f11d95b", - "bfc6e47c bfc5f644 -> bfc66d60 00000000 3b6e50dd", - "3febc758 40a6d9da -> 4061cbb0 00000000 3fd7d032", - "414dea2c 415d97ac -> 4155c0ec 00000000 3efad9bb", - "c1662aa0 c1660bf4 -> c1661b4a 00000000 3b76462b", - "c14d2d19 c1041555 -> c128a137 00000000 40122fbb", - "4142bd5c 41447b44 -> 41439c50 00000000 3d5f0048", - "41969e37 4196d515 -> 4196b9a6 00000000 3c5bc36b", - "41719d23 4171a04d -> 41719eb8 00000000 39d20d02", - "c0e06397 c0de05d5 -> c0df34b6 00000000 3d177783", - "c16d9b9c c16b6344 -> c16c7f70 00000000 3d8e1d6d", - "c1530702 c149c5fa -> c14e667e 00000000 3e941226", - "c133c0db c0551893 -> c0e90700 00000000 407cf599", - "c10d0f63 c10d0e7b -> c10d0eef 00000000 38f9a1ec", - "c11930e9 c1011801 -> c10d2475 00000000 3f40c7d9", - "418acccc 418bba1c -> 418b4374 00000000 3d6d6177", - "bf7dfc63 bf7df31d -> bf7df7c0 00000000 38965bf9", - "c0dac064 c03bc918 -> c09c5278 00000000 3ff9b7e7", - "c18f34e5 c18f3473 -> c18f34ac 00000000 3903e69d", - "c03a4ab9 c03857f7 -> c0395158 00000000 3c796ca5", - "419fdc52 419fdc8e -> 419fdc70 00000000 389ff724", - "40d4ddad 40d5753b -> 40d52974 00000000 3c17a8af", - "4030e6b6 40afb00d -> 408411b4 00000000 3fae7990", - "419593b9 41959623 -> 419594ee 00000000 3a1f2cb1", - "4033df13 4038b0fd -> 40364808 00000000 3d1a4023", - "40640da1 4064a7bf -> 40645ab0 00000000 3b9a3a95", - "41515e4a 418223d7 -> 416ad2fc 00000000 3fcba612", - "c1881f10 c1881dec -> c1881e7e 00000000 399a81f1", - "40a5b67e 40b0e952 -> 40ab4fe8 00000000 3e332ea2", - "c18f0c17 c18e29eb -> c18e9b01 00000000 3d623de2", - "409686be 40abfd7a -> 40a1421c 00000000 3eabb68c", - "3f3fc0a1 3f409bdf -> 3f402e40 00000000 3adb5613", - "c01ea3fb c0163b25 -> c01a6f90 00000000 3d868e9d", - "c006d9be bfad2743 -> bfdd6d60 00000000 3ec118b5", - "c12d1e94 c12d1dd4 -> c12d1e34 00000000 38d5a3d2", - "c04f7580 c006f7d0 -> c02b36a8 00000000 3f10fb94", - "4114d64d 412b2903 -> 411fffa8 00000000 3f32965b", - "403dfb10 403e0170 -> 403dfe40 00000000 394ef806", - "4192250c 41957b68 -> 4193d03a 00000000 3e559bac", - "c16095e9 c1605b7f -> c16078b4 00000000 3bea184b", - "c19c1df6 c19c1d86 -> c19c1dbe 00000000 390383bf", - "be8891c0 3d849902 -> bdced6ff 00000000 3e29b811", - "c122ba2d c121ebad -> c12252ed 00000000 3cce9457", - "411cc4d2 411df6c6 -> 411d5dcc 00000000 3d1903df", - "4191c1bc 4191c494 -> 4191c328 00000000 3a3a8e25", - "c10a03f4 c109ee8a -> c109f93f 00000000 3b2bda04", - "c1a1064b c19711db -> c19c0c13 00000000 3f1f4842", - "416d3e2e 416d4442 -> 416d4138 00000000 3a463511", - "be827828 be7e5ab1 -> be80d2c0 00000000 3b52b7f4", - "c1bb2c17 c17809d6 -> c19b9881 00000000 407c9d0e", - "c032503f c0324151 -> c03248c8 00000000 39f044a0", - "419b0415 419b542b -> 419b2c20 00000000 3ca052d5", - "c16b31f2 c15eb87e -> c164f538 00000000 3ec79916", - "40b932c6 40b9340a -> 40b93368 00000000 38ad9341", - "c11fb5df c07a61ec -> c0de4e5a 00000000 40423af0", - "c1646837 c12bc8a5 -> c148186e 00000000 3fe27eba", - "4014398f 401c9d81 -> 40186b88 00000000 3d864059", - "4074f671 407909cf -> 40770020 00000000 3d026fa4", - "c11e0eb3 c10b1cbd -> c11495b8 00000000 3f17904e", - "c199cd1a c180bf00 -> c18d460d 00000000 3fc8716a", - "415d3a58 41833304 -> 4171d030 00000000 3fa4af43", - "414ccc73 414cccdd -> 414ccca8 00000000 3883999c", - "412bbd47 412bbe6d -> 412bbdda 00000000 391dbbe7", - "411ade0b 41632c01 -> 413f0506 00000000 40109c25", - "41929bf3 4192a635 -> 4192a114 00000000 3b25454c", - "409d7acc 40a0b094 -> 409f15b0 00000000 3d4d7706", - "410695f6 410698da -> 41069768 00000000 39bd34c7", - "c1a4e4d7 c19acc9b -> c19fd8b9 00000000 3f21850a", - "c1a5bc8f c14dc94a -> c186509a 00000000 407b5ffb", - "401d9b65 401f01cb -> 401e4e98 00000000 3c333cf0", - "417a8e91 41800c94 -> 417d53dc 00000000 3e3156e0", - "c17008f6 c0a430df -> c12110b3 00000000 409df0a4", - "c192d411 c192c4c5 -> c192cc6b 00000000 3b75e5a8", - "4135c796 4135eb9a -> 4135d998 00000000 3b906af6", - "c131a02c c13191a8 -> c13198ea 00000000 3ae9a340", - "419442a1 41963f5f -> 41954100 00000000 3dfe6864", - "c0fc01d4 c0fbfec4 -> c0fc004c 00000000 394be00f", - "c17f663c c17e8474 -> c17ef558 00000000 3ce1e7ed", - "c114836d bf768210 -> c0a3eb8e 00000000 40851b5f", - "41200f2e 41200fee -> 41200f8e 00000000 38d401fe", - "41981756 419b0d6e -> 41999262 00000000 3e3d8ad8", - "c1a8a951 c1489276 -> c1867946 00000000 4088c056", - "c0d7f925 c0d5372f -> c0d6982a 00000000 3d308440", - "c1406810 c14043aa -> c14055dd 00000000 3b91f834", - "409150d7 40a9ab79 -> 409d7e28 00000000 3ec2d5ba", - "bf47a777 bf46f149 -> bf474c60 00000000 3ab646f5", - "c11ee6d3 c11d7787 -> c11e2f2d 00000000 3d37afee", - "c19eef5e c19eedec -> c19eeea5 00000000 39c2eef6", - "4096ce09 40bf9d97 -> 40ab35d0 00000000 3f233e98", - "41930c6e 41931f7a -> 419315f4 00000000 3b98f31f", - "c0f9653c c0f909b4 -> c0f93778 00000000 3bb74e59", - "41040c46 4106d69e -> 41057172 00000000 3db29a37", - "c0f70d58 c0195af9 -> c0a1dd6a 00000000 402a5ffb", - "c102960b c101103d -> c101d324 00000000 3d42ef29", - "c18a41c9 c18a1c6d -> c18a2f1b 00000000 3c15b521", - "c00474db c0046fe5 -> c0047260 00000000 3920d1d3", - "c12dc27f c12d32c9 -> c12d7aa4 00000000 3c8fcbb8", - "bef4649c bef3f9e4 -> bef42f40 00000000 39d5ad19", - "40a3f920 40a409d8 -> 40a4017c 00000000 3a86640a", - "40d4dad7 40d573b1 -> 40d52744 00000000 3c18f4ae", - "c14ff822 c14fd1ba -> c14fe4ee 00000000 3b9a07fc", - "4129f846 412a3e02 -> 412a1b24 00000000 3c0ba290", - "4150d776 4154c07a -> 4152cbf8 00000000 3dfa47a6", - "c048a23e c0313cd2 -> c03cef88 00000000 3e3b2c29", - "c18e9d3c c1545a17 -> c178ca48 00000000 4011c109", - "41846a38 4184de78 -> 4184a458 00000000 3ce8a138", - "c1983990 c1982d2a -> c198335d 00000000 3b479073", - "411dd735 411efa1b -> 411e68a8 00000000 3d117cf0", - "c19e66da c19e496e -> c19e5824 00000000 3bebfe67", - "40904532 40908bce -> 40906880 00000000 3b8d5c23", - "c10747e9 c1059c19 -> c1067201 00000000 3d55f074", - "c0e469a3 c0e463c9 -> c0e466b6 00000000 39bed1a7", - "c0dc442f c0dbffd1 -> c0dc2200 00000000 3b88f311", - "c18ef03d c18abfc3 -> c18cd800 00000000 3e86117c", - "c18451e6 c1743803 -> c17e6de8 00000000 3f235f51", - "3fd593aa 3fd68076 -> 3fd60a10 00000000 3b6ce6d0", - "c15d537c c15cc98c -> c15d0e84 00000000 3c8a0baa", - "c150d04f c1177491 -> c1342270 00000000 3fe56f60", - "40b816f0 40b827b8 -> 40b81f54 00000000 3a86f828", - "4149b509 414e88f7 -> 414c1f00 00000000 3e1a80fa", - "3f38657b 3f4dd385 -> 3f431c80 00000000 3d2b711e", - "bf1f7bc5 bf1f5c3b -> bf1f6c00 00000000 397cef7c", - "bcdd8000 4042cd20 -> 3fc11220 00000000 3fc48838", - "c192388d c17f8e35 -> c188ffd4 00000000 3f938c26", - "410850a0 41466b80 -> 41275e10 00000000 3ff86be3", - "c14ebf01 c14ebb0f -> c14ebd08 00000000 3a017afc", - "40bee0cf 40bef541 -> 40beeb08 00000000 3aa44ef5", - "c1577504 c1564e60 -> c156e1b2 00000000 3d135f77", - "c189115f c188501b -> c188b0bd 00000000 3d415522", - "c1747cba c17437e6 -> c1745a50 00000000 3c09e51f", - "409297c4 409adacc -> 4096b948 00000000 3e0431b6", - "408ceebe 408d05da -> 408cfa4c 00000000 3ab96d06", - "c08dc506 c08c1d62 -> c08cf134 00000000 3cd3dadc", - "c08579c6 c08437ba -> c084d8c0 00000000 3ca10e58", - "c173f891 c15b94b9 -> c167c6a5 00000000 3f431fb4", - "41866291 418a87b7 -> 41887524 00000000 3e84a6ea", - "40252358 40cd7c44 -> 409006f8 00000000 3ff5d563", - "4168db49 416e3d37 -> 416b8c40 00000000 3e2c4179", - "c1739fd2 c1739c5e -> c1739e18 00000000 39e49cff", - "40aa2983 40aa9dfd -> 40aa63c0 00000000 3be91ea7", - "c0f02106 c0f019f2 -> c0f01d7c 00000000 39e64084", - "419a5528 419a56e0 -> 419a5604 00000000 39e5a56e", - "40b88455 40b8afe3 -> 40b89a1c 00000000 3b2e9458", - "40f6f313 41217dba -> 410e7ba2 00000000 3f981113", - "c0cdfe51 c0c87c83 -> c0cb3d6a 00000000 3db03cf8", - "41585a38 41585af0 -> 41585a94 00000000 38d30b5e", - "c163d816 c163b9c6 -> c163c8ee 00000000 3b7363d8", - "c18d15d9 c180e221 -> c186fbfd 00000000 3f433c9a", - "4197cf46 4197d132 -> 4197d03c 00000000 39ff7d13", - "40a49c60 41695544 -> 411dd1ba 00000000 40970731", - "3ca6fad8 3da0eb4a -> 3d4aaa00 00000000 3cee5950", - "40e906b6 4137e6d1 -> 41163516 00000000 4006c71a", - "419d2dfb 419d4c4d -> 419d3d24 00000000 3bf32d4c", - "4048bf51 406616ef -> 40576b20 00000000 3e6abdd6", - "c0637be9 c0623937 -> c062da90 00000000 3c216738", - "c052ad0c bf0b8bd2 -> bff59000 00000000 3fafca32", - "4192b1be 4194e366 -> 4193ca92 00000000 3e0c6ea7", - "c16b33f9 c16af9d3 -> c16b16e6 00000000 3be90d9a", - "40ffe513 41002977 -> 41000e00 00000000 3bdbf615", - "40bab098 40bab1f8 -> 40bab148 00000000 38bbab20", - "414c8967 414d2e71 -> 414cdbec 00000000 3ca523a6", - "c14e81cd c14e0d6f -> c14e479e 00000000 3c68efa0", - "4195c5e3 41a94f19 -> 419f8a7e 00000000 3f9c4a59", - "407ce2c7 407cfc59 -> 407cef90 00000000 3a4d8cfc" - ] - }, - { - "glsl": "vec2 cultmath_af_range(vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "4158c790 c095f5c1 3ee73bea -> 410692bd 41957e31", - "4187ff2c bf1d78e0 3e1ed5f4 -> 4181d5b0 418e28a8", - "41896304 40260a98 3c962126 -> 4168f83e 419e49e9", - "c18da13d c0444cc2 3a934ca7 -> c1a62d2c c16a2a9a", - "41270838 409ceada 3caabb56 -> 40b07abc 4175d311", - "4174b35c c043205a 40b48d39 -> 40d34922 41bfe114", - "c184263f bedeef60 3ad295eb -> c187a54f c180a72f", - "40bd19e0 c068963f 3d63848c -> 400e0f49 4119960e", - "3ff85750 40012d54 3a4457c0 -> bda1c01b 407d6551", - "4199a976 bf9fa36e 3ad9881f -> 418fabcf 41a3a71d", - "41886cc2 c077275a 3fc02270 -> 413b0b4a 41b353df", - "c0c5c820 407bde5c 3c022872 -> c121fc3b c00f2f94", - "4111de08 3e8a7d30 3c907749 -> 410d41da 41167a36", - "c0e1a408 40254ef8 3bf0c6fe -> c11a43e5 c08ec047", - "4198e74c 3fb6a0f4 3abde733 -> 418d7a3b 41a4545d", - "c02491a0 c00a63d0 3fb43bf6 -> c0c489c2 3f7fc10e", - "c18dad62 c002fafa 3b44f6c9 -> c19e12f3 c17a8fa2", - "c1908d49 4039ee20 3a06fa86 -> c1a7cc25 c1729cd9", - "419f31a8 c045c560 403e9b9e -> 415d4af6 41cfbdd5", - "c14b80f8 bf9e1920 3ef6e4fb -> c166fb52 c130069e", - "bfbc3d10 408fb98e 3c0885df -> c0bf0d21 4041dd32", - "c13a7ce8 c06c1bff 3982e0b5 -> c17584fd c0fee9a6", - "c0a02e28 bf584ee0 399fd698 -> c0bb3a8f c08521c1", - "c185312e c05d2aac 3e6032b9 -> c1a296f3 c14f96d2", - "3d265400 40288586 3e9e8577 -> c039bcf1 403eef91", - "416b7d08 3fd97cb0 3cf17f31 -> 414fd4a2 418392b7", - "c0ea9704 c077d0ae 3c49bcd1 -> c1337228 c05c9370", - "c0c62ed8 408756d8 39839a6c -> c126c3e9 bffb5775", - "418f7eaa 4071f418 3b87836f -> 41626f48 41adc5b0", - "40f6f4a4 bfc28ebc 3ea6c151 -> 40bbe4cd 4119023e", - "bf175de0 3eeaf800 3a145f69 -> bf867f84 be06f2dd", - "410814ca 4066b5a0 3f8e3a1d -> 40728045 41538983", - "419c811a 402c4b84 3d14085f -> 4186ad9a 41b2549a", - "c15e3e39 c08c86aa 400c7037 -> c1a3ced8 c0e9bd83", - "41150ede 409783cc 3a04c6be -> 409295ae 4160d2e5", - "40a33820 3ef1f8e0 390f6b11 -> 40941768 40b258d8", - "c00ee540 c06d19bb 3d251680 -> c0bf49b6 3fc191da", - "c07dba28 4069ca88 3b087282 -> c0f3d375 be9e6b24", - "c0e8395e c0747036 390dc884 -> c1313955 c05c0023", - "c0fa99ea c0197a3c 3af15922 -> c123b319 c0adcda2", - "4123f010 3fe8dd38 39641810 -> 4106d379 41410ca7", - "c08758ca 3f7c4e10 3de1f207 -> c0aa6a5f c0488e6b", - "3f333c80 4038918a 40511789 -> c0ae6d08 40db3c28", - "4178f744 40727ad4 404c0672 -> 410956db 41b44bd6", - "419a5668 c0570d49 393ea966 -> 417ee8a8 41b5387b", - "3fff09e0 3f8fb36c 40b2d0e2 -> c096fb56 410b4023", - "418c7cc8 bfe53d76 3b93b5d3 -> 417c3f57 419ad9e5", - "c1027e12 c020cc5f 3aa221a2 -> c12ab646 c0b48bbd", - "c14bd88c c08503aa 3e817d9a -> c1893330 c1054ab9", - "41779818 bf879d12 3f03ed2c -> 415e6592 4188654f", - "4135166c 3fec9e50 3d0fb33f -> 4116f2e2 415339f6", - "c11a8370 bf845c98 3c008d09 -> c12b2f31 c109d7af", - "41407c40 bfce8978 3bf58502 -> 41268c52 415a6c2e", - "3fa5cb10 c07997ba 3f1f70cb -> c04e8e7b 40ba2cc6", - "c1706750 3f0d3db0 3aead95f -> c1794292 c1678c0e", - "409a12f0 bf506d68 3ea46203 -> 406b7e2e 40be66c9", - "c1387889 402c0214 3d0a782f -> c1640394 c10ced7e", - "c1877054 bfac8d08 409f10ce -> c1b9fd64 c129c689", - "41871d76 becc8ef0 3c700a0c -> 4183cd30 418a6dbc", - "415f614c c037d3d9 3d1893f7 -> 4130d3b1 4186f773", - "4188f0ee 3fa73760 3c197f6c -> 417cd47e 4193779d", - "c15955ec c07c1f27 3a74b181 -> c18c30cd c11a4a3e", - "c08aa5dc 400f3040 3f2fddf9 -> c0e839ca bfb447ba", - "40dd7130 401f64fc 3b18f772 -> 408dab80 41169b6f", - "403ec808 bf6eff48 3a949689 -> 4002f593 407a9a7d", - "40381db8 c05216c1 3e965fab -> bf33145f 40ce8044", - "4195b374 3f1c77f8 3e5a4a7d -> 418f1b15 419c4bd3", - "41995e52 3fe02144 3e09020d -> 418a4a2f 41a87275", - "c1289040 4003f714 3b81f288 -> c1499e50 c1078230", - "40328500 bfd17cbc 409a204c -> c06a7a1b 4113e107", - "418ea48c 40908d7a 39df5331 -> 41550086 41b2c8d5", - "4166d93c 3f85af0c 3ccc4b93 -> 4155bd26 4177f552", - "c0ad6508 4094774e 3c90320e -> c121364e bf42eb9f", - "c18de01b c02da39c 3e9896fe -> c1a5f6f4 c16b9282", - "418adb68 3ec676f0 390390f6 -> 4187c141 418df58f", - "c12b685c 3cb6ac00 40c6920a -> c1878664 c08f87e0", - "41122b80 bfbf9904 3b352617 -> 40f45a05 412a29fe", - "411956c4 4073fa60 3e3995f6 -> 40b2e38d 41593bc2", - "415f06d4 408f929c 40bfcad9 -> 405d6006 41c35ad3", - "412c30b2 40879d2a 3c239595 -> 40d07251 4170283b", - "416f95fc 404e0bd4 3c0db4d6 -> 413bef88 41919e38", - "4153bd70 40116f80 3f783dbb -> 411fdda4 4183ce9e", - "c16170ac 4008d8c6 3f834917 -> c18a0809 c12ed147", - "41142c6a c03b460e 3a8f5a8b -> 40caacc0 41430274", - "c1238a5c 40839390 3b96865c -> c1656703 c0c35b69", - "4196afce c0917d17 39fbebc0 -> 41649f01 41bb101c", - "4087248c c09e93f2 3a8931eb -> bf3bc05b 4112e091", - "c0b1c740 405a75c0 4108382c -> c18bdca7 40cbe41b", - "40bdbd5c c03c0dae 396c220a -> 403f6936 410de30f", - "bf83f860 c09c16cc 3e429dbc -> c0c329de 40812dae", - "3f741880 3f747320 39267ffe -> baca4d13 3ff44b13", - "c1903d9a c04b5632 3c31103a -> c1a9be8d c16d794f", - "c0f6746e c07e069e 3f922728 -> c14d00d1 c025ce77", - "c131ace9 c084fbd8 3f60036d -> c181158e c0c25d6c", - "c15bef5c 409eff8c 3a07e3c7 -> c195b8aa c10c6d63", - "c1863adf bd47b800 40e2a536 -> c1bf4814 c11a5b53", - "c0e766e0 4071a738 40524366 -> c164ae26 be2e2e8d", - "414c494c c0576194 407ce334 -> 40ae700c 41a0ad49", - "c1429ff6 3e0799c0 40fff4fe -> c1a25c78 c0810df7", - "c07c7e18 c04b213e 3d251931 -> c0e519ec bf3b2161", - "41112970 3fde1cc4 3ea4ebe1 -> 40e07cdb 41321473", - "c16249a4 c03b151c 3deadcc6 -> c189725b c131ae93", - "c154b9a5 c0430f28 3ee1cc33 -> c18645f0 c11ce769", - "41883884 3fd133a8 40a49d36 -> 4123fbe0 41be7318", - "c0e03b36 bf9581a0 407ed79e -> c14283c2 bfedbb9b", - "c0582b50 c03cf444 3fd5970f -> c0fff59e 3f9f2938", - "415b9498 3f2d51b0 3eb7db9d -> 414b0091 416c289f", - "c17fb2ac c05ccb9c 39f7099a -> c19b73ca c1487dc4", - "412192e6 4002f838 3c6ce0ff -> 41009994 41428c38", - "c172adf0 406224c4 3e62bc7c -> c1976113 c13699ba", - "c03d1600 4081f2a8 408017c7 -> c1304ac3 40a37f86", - "c1061dd2 bd359600 3c39bf4d -> c10701e0 c10539c4", - "c18438e7 c09cd2dc 3f62080a -> c1b27de9 c12be7ca", - "3f9ee310 408421f2 3b4f03a6 -> c0390631 40abf4a1", - "c125aa12 bf8848f0 3a9a4084 -> c136b80d c1149c17", - "4193897c bd664600 3f4bfa65 -> 418cb67c 419a5c7c", - "419fc934 40336adc 3b648142 -> 418954a9 41b63dbf", - "c168e099 3f152f88 3df324f2 -> c17419ea c15da748", - "41466c00 3fa1b838 3d204e57 -> 4131949d 415b4363", - "402b6cb0 bf87b914 3d062565 -> 3fcaef03 407161df", - "c14ce136 c09105da 3ba7cde2 -> c18abc97 c104493f", - "c18cd970 bb92f000 3f1cacbf -> c191c80e c187ead2", - "c1990718 c094ffe5 402f8633 -> c1d437e5 c13bac96", - "3ebabbc0 bfdb320c 3a770139 -> bfaca20d 4004fff6", - "c18e4ec4 bff08f98 3e406a95 -> c19ed89d c17b89d7", - "c0637c58 4065f764 3f244cf6 -> c0f9438d 3f2e39a5", - "41868ee8 403a7ff0 3a93826f -> 415e7924 419de13e", - "40c23e44 c072405a 397305fd -> 4012383b 411db036", - "c0b27b58 c00664e7 3bb3aee0 -> c0f5dac6 c05e37d3", - "c0f8df6c be489d00 400e00af -> c1231260 c0ab9a18", - "417b1ff4 3e4b3040 3df61bf8 -> 417606eb 41801c7e", - "c108de78 bfbe84ce 4009011f -> c142ef66 c09d9b15", - "4192921a c04bf732 403cd329 -> 4142f185 41c3ab72", - "bfdd3910 408c9094 3ca37487 -> c0c48259 402bcba3", - "417b49b4 bdc86e80 3c945c85 -> 41796e99 417d24cf", - "c1774395 c0862188 3adf2414 -> c19d2db3 c1342bc4", - "41933ce8 bf8169d6 3f2f1fa4 -> 4185ad44 41a0cc8c", - "41248120 3fbb7ab8 3dd2ed63 -> 410b6be2 413d965e", - "c1049ea9 3e8ffd40 40877170 -> c14cd758 c07197e9", - "c113edd2 3fff1598 3a924ae0 -> c133d522 c0e80d03", - "c06793a8 400a6188 3d71199e -> c0badcd7 bfb2db45", - "c19a1c02 3f956bd8 3f8dd432 -> c1ac500e c187e7f6", - "4049ea90 402c40f0 40cc0526 -> c0bd306e 41438d7f", - "4138c0ea bef01a50 3e7b6a9f -> 412d5261 41442f73", - "416b33dc beb9d860 3fe94ce6 -> 41483b6b 41871626", - "41202aa4 4025d570 3e12c5c1 -> 40e8d449 414beb24", - "409b6c08 c021fa17 3a91a9fe -> 4014cba6 40ec723d", - "c17efa3f bfc5d30c 3986026d -> c18bdadf c1663ec1", - "c17e9728 c069612e 4014f431 -> c1af164b c11f01ba", - "c19bb65a 409de01a 3fa6df13 -> c1cd9c5f c153a0aa", - "418d0d7c 3ff2240c 3cd29ced -> 417b6d14 419c646e", - "40ec1328 c090e11d 3aaae573 -> 40364e8a 413e7f86", - "4181ee56 406f81b8 401521b0 -> 4122b3bc 41b282ce", - "40b69fdc 3eb20e40 3b6d1c67 -> 40ab6148 40c1de70", - "c10966ed c052471b 40ab6fd8 -> c189d859 3d62d73b", - "c18384f2 40794d48 3a56f771 -> c1a2b053 c148b322", - "412044bc 3ed9b5b0 3f332ce7 -> 410e4435 41324543", - "c103ce75 3fbcb858 3c95b664 -> c11bb065 c0d7d90b", - "c19fe15e bff5d554 3bea0c03 -> c1af4d5f c190755d", - "bf8d08a0 40852f92 3cd1187b -> c0a942dd 40457d19", - "418b5f28 3f279d58 3f41b7a7 -> 41801477 4196a9d9", - "c167c357 405ea5f4 3f290188 -> c194fe7f c12589af", - "c1428f69 c04ad5ba 3c460091 -> c1757667 c10fa86b", - "40a53e58 405c4df8 402a1022 -> bf6f865c 413436bd", - "4124fc7a 4099330c 3eba2f25 -> 40a522d7 41776788", - "417e6228 404a6cb0 3a425972 -> 414bc3df 41988039", - "c1692344 c09bc6a2 3ade1b3c -> c19b86cd c11b38ef", - "40f3fa78 c017b16f 3c931741 -> 40a78e95 4120332e", - "c18eb623 3fbbd2d4 39298a7b -> c19a73af c182f897", - "c1968372 3feb98a0 3efe9351 -> c1a93754 c183cf90", - "41617490 bf2a0908 40c55d29 -> 40e84aac 41a761e4", - "c08a20f4 4004919e 40e0bacb -> c1569254 4098e2c1", - "3fb7da20 c061a396 3b87e612 -> c005fa8d 409eea56", - "c14b9c51 407b8584 3eae6aad -> c187f88c c1074789", - "412a713e c0725a72 3e9ec32d -> 40d1c8f3 416bfe03", - "4175d680 3eb9a880 3e61cfe4 -> 416c81ec 417f2b14", - "4119c0c6 c07e24e6 3ceb5259 -> 40b383ab 4159bfb7", - "c1421287 bfd0fba0 405182d7 -> c1884961 c0e72498", - "c1293a70 c0233eee 3b55483a -> c152178d c1005d53", - "c0e01180 c0852b89 3a84d1f0 -> c132a2b6 c035bb27", - "410e34d6 c0558885 3d000f77 -> 40b0a531 41441713", - "40e2bd78 40312a9c 3c393422 -> 4089cb7c 411dd7ba", - "41889892 bfabe616 3b1575e9 -> 417baaf8 41935ba8", - "411b69ac bfb13234 3e623a5e -> 4101ba71 413518e7", - "41604aa4 40913c88 39d132df -> 4117aaab 4194754e", - "3fc97460 4087c5fe 3a05e9bd -> c02ada41 40ba2751", - "4121a0c0 c05342c7 39bb0bd2 -> 40d99d15 415672f5", - "c0a28074 c006c7a8 3da4dd6f -> c0e877cd c0391238", - "c1218037 3fc70e30 399fe2b4 -> c13a6349 c1089d25", - "c18e64ea c05bd60a 3ca7aa28 -> c1aa09a1 c1658067", - "40d5835c c038fbfc 395a0f88 -> 4072072e 41190191", - "c171a99b bece8940 3edc0b79 -> c17efe51 c16454e5", - "c13b3af6 c08376be 3bacf66c -> c17d0c04 c0f2d3d0", - "c107e77d 409252b0 3a3ac740 -> c15113cd c07aecb4", - "c083bccc 409f2b8c 3f024a40 -> c11998da 3faee06d", - "414e9864 bfc4ba58 3c06831a -> 4135df6a 4167515e", - "4134ff32 3ffb2e0c 3b836942 -> 411588f6 4154756e", - "c159103e 3f395a00 406d9d54 -> c19006a3 c1121337", - "c182fbe8 bfc115e0 401b35bb -> c1a27407 c1470791", - "4185b660 bf348438 39d3e559 -> 41801161 418b5b5f", - "c0ee56a8 406dfaf8 3a91b6ab -> c132aeab c06e9ff4", - "414603f0 c087ac00 3a147139 -> 41022b8d 4184ee29", - "4086b990 4011f440 3cf25417 -> 3ff3343c 40d0a611", - "c08841a8 bfd72d00 3fbfc672 -> c0edfe93 bf8a12f3", - "413e2e10 beb3be20 3a979d0d -> 41388b56 4143d0ca", - "418cc61e 40984f16 3b3d01eb -> 414d58cb 41b2dfd7", - "41597d00 bf406268 3b6669f1 -> 414d6865 4165919b", - "4108f26c c011c906 3ca3f6d8 -> 40c85c48 412db6b4", - "c165648a 3d747b00 3e1f9f77 -> c168d792 c161f182", - "c160383c c095d8e6 39bb1e17 -> c195931b c1154a40", - "415fcee8 c006a7b7 3e4b9617 -> 413af692 4182539f", - "c1312892 4097a1ec 398c2ab6 -> c17cfab0 c0caace7", - "4193a28e 3f6076a8 40816fae -> 415885c3 41bb023b", - "40684548 c034c466 3dfcb1b3 -> 3f2e6ce7 40d277ab", - "4178bef0 bf8dbff4 3bd9588d -> 4166ebb5 41854915", - "bf144660 bfae7c9c 39b4c3d9 -> bff8ab28 3f48c98f", - "4100d3dc c05f840e 3bf0a5fa -> 4091a971 4138d300", - "40597790 c0870820 38dd365f -> bf526a22 40f3c4d4", - "4147bf40 3f7f8900 3dcbf030 -> 41362ec2 41594fbe", - "411f5010 3fd6d0f4 3d9114f4 -> 410353bc 413b4c64", - "3ef6ab80 bee357e0 3e9b33f1 -> be87e077 3f9d4dde", - "c094df28 3ee08220 392aa209 -> c0a2e8a9 c086d5a7", - "c14fba16 3f3d5a88 3ce9ab6e -> c15c04a2 c1436f8a", - "c16e928e 40992390 3c0f2aa1 -> c19da41a c121dce8", - "c0a59bb0 c0209452 3a8e8fc9 -> c0f5eed1 c02a911d", - "40f46b60 4050337c 402651c5 -> 3fe4a294 4157d70d", - "c1814d4a 3fc7bfb4 3a06e346 -> c18dca5c c169a070", - "3f9efa10 bf043060 40229155 -> bfe840ec 40898d43", - "4117e2e4 c0168efe 3a95c1d2 -> 40e474d5 413d8b5e", - "40c67808 bf639f50 3bf3015c -> 40a9c750 40e328c0", - "bf119960 c0380af2 407e5dbe -> c0ed6793 40c9013b", - "c0be4df8 c086d205 3f253352 -> c12ce33f bf8b55ce", - "41870444 3d4ba100 3fd7e676 -> 41724005 4194e885", - "c0e3c766 bff314a0 3f636a54 -> c11e7cf6 c08a94e0", - "409513bc 3f3d99a8 3a3e56a8 -> 407ab512 40acccef", - "419b2b32 c036d444 3fb297e3 -> 41724e3e 41bd2f45", - "413e4bc0 c072766d 3f3ee155 -> 40eb7ffe 41836bc0", - "410aad0c 3fc3d548 38f026f9 -> 40e463c2 41232837", - "c038e898 4099eb0e 38e3ed6b -> c0f6604d 3ff5ded6", - "4149d3c8 3fbb5b10 3b22eaa6 -> 41325e29 41614967", - "4153a8ac 3e509e60 3a2afaf5 -> 4150637a 4156edde", - "c1751d32 3fb50e10 3f2d5414 -> c18b4a24 c153a61e", - "bfa1a580 c099d36e 3a3a755e -> c0c242ae 4062dfdc", - "c00beb20 402c2d26 3b82f7bd -> c09c2ceb 3f020e56", - "c193fc68 402f491e 3bafe505 -> c1a9f095 c17c1077", - "c0bcb5ac 4084aab2 40168d32 -> c1465388 3f19ddbe", - "41059d76 40218c80 393b6042 -> 40ba731f 412e015d", - "c0963712 4064f044 3b389010 -> c104632b bf8e9f36", - "407ecb50 402c395e 3d80632f -> 3f9d1d7c 40d783f1", - "4182964a 40878996 39a1726f -> 41416671 41a4795b", - "4123057a c07bcb40 3ffb4f24 -> 4089516b 4180b11f", - "4029c1f8 bdb18c00 3f636d55 -> 3fd6b469 406829bc", - "40a25930 bbb1e000 40934e11 -> 3eede93a 411ae9e6", - "c0707518 3e28b140 3a7794a7 -> c07b0fb5 c065da7b", - "40cae8b4 bfbd72ec 3bbcd5cf -> 409b5cb4 40fa74b4", - "bfeab1b0 3fe54bb4 401f1fa2 -> c0c38f36 401c6cbc" - ] - }, - { - "glsl": "vec3 cultmath_af_add(vec3, vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "40d43ce8 c087efa9 39613e6a c16aec62 c07bc9ac 403cc5ae -> c100cdee c102ea40 403cc980", - "c12da602 bf04ef28 3e52a901 416eafe0 3e32ffc0 401334ae -> 408213bc beb05e70 40205f5a", - "c13bb855 3f1a7af0 399ddbc6 c188bb12 3ff3ff78 3e522b2e -> c1e6973c 40209e78 3e5281fe", - "bfc3dff0 be934a60 3b29878b 400ff980 40107892 3c43020f -> 3f382620 3ffc1e8c 3c6d6ec2", - "418d570e bffc8a8c 3ac6433a 416372b0 400f701e 3d0a596e -> 41ff1066 3e8956c0 3d10abb8", - "418c1916 c062f6f7 3993b387 40e6d1c4 c024f1e0 3fdf597a -> 41c5cd87 c0c3f46c 3fdf63ba", - "c195fd6e 3f9be3b8 411ffb75 4194aff8 bfcfd300 392c8a53 -> be26bb00 becfbd20 411ffc2d", - "c16eadd8 40227cbc 410204a5 c18cb723 c04064f0 40c11ba2 -> c2020708 beef41a0 416292a5", - "c18039b0 3f5ba9f0 3e4f8fe4 40f2c80c 409d92e4 3a8f8f7d -> c1070f5a 40b90822 3e50b29e", - "40773020 c079dfec 3bb7222b 40c1a4c0 c0459a7c 3f85d8af -> 411e9e68 c0dfbd34 3f869061", - "40ca3f3c bfa23160 3ed550f9 c15b9017 408b3ed8 3bedb0ff -> c0ece0f2 40456500 3ed9091a", - "4134ba24 3e86f640 3b7f2baa c121ac83 c092bda4 39679e62 -> 3f986d08 c08a4e40 3b86feeb", - "40cff3f0 bcedf700 39f4164e c126d9ec bf354f20 40e76b14 -> c07b7fd0 bf3cbed8 40e76efc", - "c02b2300 40741c60 39ac403a c10ceaec 4023e60e 3a00dc23 -> c137b3ac 40cc0137 3a5b731f", - "415c62ec c02131da 3a188197 4174845c c0853193 39f197d6 -> 41e873a4 c0d5ca80 3a8d1e63", - "bd35a200 bf999a7c 3c68e268 c1427d2d bff77f5c 40d446dc -> c14332cf c0488cec 40d4bb79", - "c0e7495e 40967120 3f9ed448 408ca048 c00e286b 3e6d5e06 -> c035522c 401eb9d5 3fbc803f", - "40b0b778 40613920 3d57e1b7 406ce3b0 c0974af9 3cf57942 -> 411394a8 bf9ab9a4 3da9546e", - "c1883885 bfb6b418 3e8131bb c09ca770 c03464df 3b680d8b -> c1af6261 c087df76 3e830524", - "41005bee bf9beaee 3df9a294 405b39e0 bfefe608 3e8b6aa6 -> 41372a66 c045e87b 3ec9d529", - "c133bc4f 40801ae6 3c85c395 c1495d70 401f091e 3e4fb998 -> c1be8ce0 40cf9f75 3e6079ad", - "40b10314 beac46d0 3a6adb4b c153aefe 40866562 3ca1aa3e -> c0f65ae8 407741ea 3ca91842", - "c15e0335 404ee720 3dd554cc c0327270 3fb572b0 40545d57 -> c1854fe8 4094d03c 405b0860", - "40707f70 c01ed5fd 3aa6c604 40c9c314 4044f564 3edbafeb -> 41210166 3f187d9c 3edc5814", - "bff42e80 c07261e9 3a28fcd5 c172bccc bd364700 408c6a78 -> c188a14e c0753b05 408c6ff3", - "c0c3a420 40158cd8 3e46a2db c16bb081 bf8be71c 3bfd0bde -> c1a6c148 3f9f3294 3e4e90cd", - "c12c85a6 bef236a0 39ac72e6 417513d0 40915bb0 3d828091 -> 40911c54 40823846 3d83315a", - "c0f9c412 40819efa 3c7ba656 c132561c c0305084 3c1a67e2 -> c1979c12 3fa5dae0 3ccb2fa7", - "41040458 c0130774 3ef6488c 41085452 409d574e 39530ecd -> 41862c55 4027a728 3ef6656a", - "bfada460 3f1d8898 39983863 410a4b08 40152860 3e0c14b3 -> 40e92cf8 403c8a86 3e0c6367", - "bc8b5800 3e33e540 40e4a528 c118520b 404e2310 3a5feeb0 -> c11897b7 40596164 40e4ac4f", - "4140f4b4 c099295a 3c6e6b9a c12f5d00 c04016f6 3a672177 -> 3f8cbda0 c0f934d5 3c7d014d", - "41407ce8 40070c0a 3b49894a 40cce260 bfbc78dc 4050bb94 -> 4193770c 3f233e70 4050ee4f", - "c106e449 c02c2fb4 4042fec1 412ae39e bf5b0490 3aaf5b82 -> 400ffd54 c062f0d8 404314cf", - "c1451b66 3fabb33c 3f0343b1 4077c928 3fd40818 3fb312e4 -> c107291c 403fddaa 3ff4b527", - "c1099e9a 3e12f540 3ecaf927 bf73b040 bf954d06 3c79eb8e -> c118d99e bf82ee5e 3ed2c9e3", - "40668a98 c09247ff 39884958 c11f62ba bf4d2b40 3a87e4fa -> c0cb8028 c0abed67 3aab6ec8", - "4193ecac be49ea80 396bd992 3ff28820 4083ebb4 3b25e98f -> 41a3152e 407b38c0 3b362c2c", - "41287054 4043da44 3a9103bf c146770c bf3b42c0 3d04b260 -> bff035c0 40150994 3d093ebb", - "41137c6c 4014d6b4 39abdc8e 411d21e8 c0899b52 3a642e9d -> 41984f2a bffcbfe0 3a9faee8", - "c00e8148 c03cfd96 3bc4cffc 408460c0 408d20ce 3e89076b -> 3ff48070 3fba880c 3e8c1b20", - "bf9c84f0 bfe09024 3b8e7751 4166f998 c08998bb 3b683910 -> 415368fa c0c1bcc4 3c019706", - "414c9c90 c093c0c8 3f917426 40f7d8d4 40430a48 4095f582 -> 41a4447d bfc8ee90 40ba52c4", - "c15ce12a 3fb92730 3ed04fa5 bfc622b0 405581f4 3ffe4ed9 -> c175a580 40990ac6 401931bb", - "409a176c c08193c7 398f927d c134c749 401d4890 3e37c6e7 -> c0cf7726 bfcbbdfc 3e3810c0", - "c0d50cdc 405c80bc 40ea3685 417cd170 40443d98 3a9c0e1a -> 41124b02 40d05f2a 40ea4074", - "415e58f0 bfb4ae0e 3d4b892d c0935466 c0870f2f 3db1be07 -> 4114aebd c0b43ab2 3e0bc513", - "4190f802 4080bb60 3ef51586 417f4b04 bfa62738 3c0fa76d -> 42084ec2 402e6324 3ef9976a", - "40f479ec c09437ff 408b615c c153de0c 3f680c50 3c5b4fb0 -> c0b3422c c06e6cea 408bcf1f", - "bfadc600 409a9202 3beaed49 be202280 409a9254 3fd942cb -> bfc1ca50 411a922b 3fda2e1f", - "407ae6c0 c01ec955 3da07483 40e25f8c 3e8c0040 3aafbedc -> 412fe976 c00d494d 3da33a22", - "c0d0a62e 4087e590 3abcaf85 4075a160 405d9378 3c8af860 -> c02baafc 40f6af4c 3c96d82a", - "c086846c 402cc908 3d8b999e c16a1d46 3da97480 40912003 -> c196afbe 403214ac 40934e9d", - "c170e1ef 400dc0b0 3ed79b31 40fe9e48 3e87de00 3eb3756a -> c0e32596 401ebc70 3f4588f4", - "410eb658 c056a862 3af3c399 3ff38710 bf35d748 3fa7f302 -> 412d273a c0820f1a 3fa83075", - "415c3250 bfbe4d0a 3bf80550 40f76d28 40379c1c 3facc0f7 -> 41abf472 3fb0eb2e 3fadb9be", - "c19d27f2 c00f3fc2 3bf590ac 3ed7bd00 3f1e7870 3c8a58a9 -> c199c8fe bfcf434c 3cc7e690", - "c15b8ff8 c08195b1 3a6b441d bf394dc0 402f642a 3fa2625f -> c16724d4 bfa78e70 3fa28050", - "416583d0 bfd736f4 3cc1b901 c01a2b08 bfa33d36 3b051cb7 -> 413ef90e c03d3a15 3cd27a6e", - "c17282e4 407f6a8c 3ed8cdee 416cb6d0 40913cb6 3bd56500 -> beb98280 410878fe 3edc24ac", - "4196e814 40393c0a 3cf69113 c06b62f0 40213608 3cf43d53 -> 4172f76c 40ad3909 3d757bdc", - "c1899183 40010736 4103b0b0 411a0700 c06fcd62 3abdad44 -> c0f2380c bfdd8c58 4103b6af", - "401051f8 3f90c050 3a249d89 c10d3537 3ed6f8e0 3c6b6e69 -> c0d24172 3fc67e88 3c75d8cd", - "3f3bc040 c025b4c9 3c12f286 c02af188 3ff1da20 39a05bfa -> bff802f0 bf331ee4 3c17fffc", - "c0c17d98 bf750bb8 40fadd5a c176dfa4 3f38e5e0 402fdecc -> c1abcf38 be709760 41296680", - "c17f8ff4 c06706b6 3b85f69d c19c18d9 3ec76e10 3f3a7832 -> c20df06a c04e18f4 3f3b8696", - "418ff028 401f48c2 3baa4e07 40fa8518 bf61c760 397170fb -> 41ce916e 3fcdadd4 3bb2b506", - "41580d20 c074832d 3a8d5887 c124b308 407560c0 3f206182 -> 404d6860 3c5d9300 3f20a86c", - "c17ebea1 405ab254 3bc7f729 c103ec38 bfbe0a62 3ebb93c1 -> c1c1556c 3ff75a46 3ebeb6ed", - "41971a7c 3ec46450 39a6b792 c081c96e c08d0cf8 3bb34612 -> 416d5041 c080c6b3 3bbe4871", - "3f241e80 4091de50 39e886fc c1818253 3fb32de0 4108a229 -> c178c2be 40bea9c8 4108a418", - "4183224c 3ee23190 397631ca c0907ef8 bfda2b14 3f6c76e5 -> 413e051c bfa19eb0 3f6c8729", - "c183bbba 404e7978 3fb34f54 c0e8d304 3f74d9f0 3d92a978 -> c1bdf07b 4085d7fa 3fbc7ad7", - "4179f3c0 c07c0bc3 3d24b7b1 c1338928 c09c1081 3ee60e13 -> 408cd530 c10d0b31 3efaa6c0", - "3f9d3120 40445c44 3f5da9cb 408c3138 c0933354 38d32724 -> 40b37d80 bfc414c8 3f5db0e4", - "40dc2634 3f031430 3e8fbedc 419e92d0 c04cff5e 3c9c08f7 -> 41d59c5d c02c3a52 3e998321", - "418dc79c 401b11c6 3cc90297 c133076b bfd5ef3c 3ba2c4f9 -> 40d10f9a 3f4068a0 3cf1c276", - "40ed1db4 400980dc 3d14fc8b 4023d450 c03c74c5 3d34b070 -> 411f83ee bf4bcfa4 3da4dbea", - "41757128 3fc53cf4 40a577c0 3f96f5f0 3da4f100 40ba5b0a -> 418427f3 3fcf8c04 412fe982", - "41511ca4 c00234ee 40a70d3d c08172c8 3f2554d8 3fbb86e0 -> 41106340 bfb1bf70 40d5ef17", - "c140c528 bfffa80c 3d07e9a0 c188776a 4009ad6c 3f47878a -> c1e8d9fe 3e1d9660 3f500805", - "c17dcc58 c0824e89 3e27d9f8 c0a228fa bf9ff16e 3fec9147 -> c1a7706a c0aa4ae4 4000c6b4", - "c1823ad3 3fd9f658 3f3c489d c14bbe3b 3eaf4000 3b493f05 -> c1e819f0 4002e32c 3f3d13d9", - "c13440b9 40955888 3dcfd49d c11a82dc 4010a772 3c0b4ccb -> c1a761ca 40ddac41 3de14c31", - "c18d7a6a c064cba4 392c52c8 411770de c053f705 4026ad73 -> c10383f6 c0dc6154 4026b06b", - "3efe7d80 3ee244c0 3a4ad175 40b95668 c0992122 39189b8c -> 40c93e40 c08afcd6 3a73a0dd", - "41566db4 3f8efb58 411f7ff0 4115a272 bec9f4b0 39bfffda -> 41b60813 3f38fc58 411f8191", - "41770880 3dd0b4c0 3b22d2fb c1836754 bf22ae78 3fc5b9cb -> bf7c6280 bf0897e0 3fc60b4d", - "c14cfa08 3fb9b5bc 3f25e773 40bafef8 c04c78aa 3dc7dad5 -> c0def518 bfdf3b98 3f3ee365", - "c12b965c 408cdeda 3d98406c c1744e06 c09afd00 3d956aaa -> c1cff231 bee1e260 3e16dc30", - "411687e8 bfaa7a6e 408560a5 41264346 4066f798 3fb695f1 -> 419e6597 4011ba61 40b30658", - "40e0d048 bf048368 3e339f89 411a0f74 bfc457de 4083267c -> 41853bcc c0034cc9 4088c3a6", - "c101754f be1e32a0 3d0b07e1 beeae880 bfa316bc 3a9d4709 -> c108cc93 bfb6dd10 3d0ffc1d", - "c17b9c51 4095ecea 3ead98db c13c8ed8 3f11ab98 3d2a32b4 -> c1dc1594 40a8225d 3ec2e357", - "c172ad82 406a746c 3bd7b2eb 404c61a0 bf5ef9c0 39859ac1 -> c13f951a 4032b5fc 3be082c6", - "bfd54100 400abbbc 3dc3addd c03a9678 409f8d44 399a44d2 -> c0929b7c 40e4eb22 3dc44e0c", - "c14731a6 c06f3ac5 3e34a4be c0049e00 bf5cdb30 410bb34e -> c1685926 c09338c8 410e85fd", - "c1471115 bf1c25f0 3b4ba548 415978c0 bfc21666 3e9a8e09 -> 3f933d58 c00814af 3e9c25c7", - "c182a5bf 401bc0e8 3d8d171e c0b53a8c c09c58db 39346f97 -> c1aff462 c01cf0ce 3d8d7d98", - "416a9914 3e98b610 3f8f78d6 c07f50a8 3fb1e190 41164530 -> 412ac4ea 3fd80f14 41283462", - "bfa814a0 c0815822 391d8053 402cf5a0 c00b486d 3e105efd -> 3fb1d6a0 c0c6fc58 3e10884d", - "c0de1ab4 406d304c 3cdc5e1c c0603bf0 c000259f 3adf937c -> c1271c56 3fda155a 3cea6faf", - "402a4f08 3fcb1660 3d73642c 410b6abe c09abee2 39cbbb61 -> 4135fe80 c04ff294 3d750a52", - "c12fd8b2 c00c2643 3d1f4a97 40d6ad88 bdf38300 3e640588 -> c08903dc c013c25b 3e85ecf2", - "3f0b6fa0 c080056c 3eac34a1 3ffa5c00 3f1b0540 3cb4d2d1 -> 402009e8 c0594988 3eb78296", - "c10a5940 4038a284 3cdfa554 40c615c0 4099ed8a 3b7ec187 -> c01d3980 40f63ecc 3cff91e3", - "4190ebd4 3f9b630c 3a1f1d70 40d7dcf0 3e0861a0 3cc889fe -> 41c6e310 3fac6f40 3ccdb761", - "c13997ce 3fe586fc 3c8751fa c0e4ccac 403acef8 3bbe33e5 -> c195ff12 4096c93b 3cb70deb", - "be9c8e80 c060d1a9 3d172502 40f5c700 c04ffb78 3bc9efdb -> 40ebfe18 c0d86690 3d30712b", - "bf6fc740 403fa6a8 3ddfc1ca c0abc622 c08ebcc9 3a56270c -> c0c9bf0a bfbba5d4 3de17209", - "4187d572 4031a724 3b68abcb c19a80bc c06db5bc 3d137c88 -> c0155a50 bf703a60 3d220a95", - "4125daf4 4083c470 3e7a509b c12868d8 40299318 3c1ab7b0 -> be237900 40d88dfc 3e81fef1", - "41939ab8 3f10e350 3f307e78 c1932270 bed88b70 3f8da25b -> 3d709000 3e127660 3fe5e1a7", - "c12f65e1 c044e2b1 3b635b53 c0bcab58 c08de806 3c3bc166 -> c186ddc6 c0f0595e 3c74f9c4", - "4191b7a0 3f6b0cf8 3def23b4 c16d4298 c04df8ad 3a5406c2 -> 4058b2a0 c013356f 3df0cea9", - "41068da4 3f5eeae0 3d8ccb22 4197be44 401c4394 3ef45081 -> 41db0516 4053fe4c 3f0bc399", - "c154aa82 c0449657 3d684e2d 418a5754 3f1efad0 4020f96c -> 4080084c c01cd7a3 40249ac9", - "40e02608 c01c7b9c 3c07e673 c1743c34 4013ae14 3dfd363a -> c1042930 be0cd880 3e071ba6", - "40670da0 bf22de50 3ba7918e 413f4b66 c0667d31 40020a1a -> 41790ece c0879a62 40025e3a", - "416f9c3c 3f380248 3ece4938 417edc08 c08c385c 3d45c609 -> 41f73c22 c06a7026 3ee7065a", - "417e99e0 3fa63b18 3eee6394 be211500 3e884c20 3a4b3707 -> 417c158c 3fc84e20 3eeecb69", - "4151a5a0 409bdc74 3f93b35d c195c5a9 406e65a0 3b0a4ef5 -> c0b3cb64 410987a2 3f93f8ff", - "c11ad8cd c004148b 3e1115f3 c0387f98 3fe32ea0 3f818d6e -> c148f8b3 be93e9d8 3f93b09c", - "c1970424 4057ab74 40014654 419e6924 3ec7cff0 3f02f9cc -> 3f6ca000 4070a572 402204e4", - "41597c58 4083a120 3c8d14f2 4103c1f8 c0800fda 3a3e8742 -> 41ae9f28 3de45180 3c933516", - "c19b4c1d c013868a 39ecf54b c19b86e7 c094f59c 4092a983 -> c21b6982 c0deb8e1 4092ad9c", - "c1623b78 c04d68a8 3ee1c245 c13c3d22 c005e1d5 3f05dcd4 -> c1cf3c4d c0a9a53e 3f76bff9", - "4143d670 3f153ae0 3d872138 c187666a 3ed12190 3fd9f7a9 -> c095ecc8 3f7dcba8 3fe269f8", - "c12bf57d bf090f78 403dbb8b 418665d0 406ce450 3aae7116 -> 40c1ac46 404aa072 403dd18a", - "40e0e3b4 4080e3cc 3995342e 419d6154 3fc7fea0 3df43005 -> 41d59a41 40b2e374 3df4d56d", - "4113a078 c0721c57 402ec640 40b36488 c09a798c 3dd401bf -> 416d52bc c109c3dc 403566b7", - "c16a5576 c023caff 3b017295 40fd7ae8 c00be46d 3cfe6f57 -> c0d73004 c097d7b6 3d075a56", - "c188e7a8 404e34d8 3d5c6950 c174dffe c0470426 41002b59 -> c201abd4 3de61640 410107eb", - "c14e23e4 4028492e 3be94ed1 40814118 be824450 3e3d3f37 -> c10d8358 401800a4 3e448c88", - "c10e2641 c081b1ec 3c229d46 4181fb44 bfceff50 39eee0ad -> 40eba08e c0b571c0 3c2a4878", - "415a7d9c c05cfe22 3d28699a c1774c62 be7dd9c0 3a37af8d -> bfe67630 c06cdbbe 3d2b4de3", - "41641c90 c055dbd5 3d4fba2a 41937b4e 408dc450 3b47aefe -> 4202c4cb 3f8b5996 3d5c56f0", - "405f02b0 3eaa6870 3a2f49c0 c0852d70 405e9aec 39361bb4 -> bf2d60c0 4073e7fa 3a5deffb", - "40e4ad1c 3f154760 3ebdaa52 c17987b8 4048e690 403b5c0f -> c107312a 406e3868 40531197", - "c12356c8 c06d0014 3e303512 c12a4b90 bfb04ef6 408335ad -> c1a6d12c c0a293c8 4088b792", - "c13da8f9 c02e4c01 40585641 c16e7682 40643fdc 39e182b2 -> c1d60fbe 3f57cf6c 40585dc9", - "419833fa 4092be8a 3bb1fcad c09d5a76 c018fc8e 3908f2cf -> 4161bab9 400c8086 3bb6c6bc", - "c01a5a30 c0351a82 3fa100f7 c1886894 c09b9010 40a2c01f -> c19bb3da c0f61d51 40cb00a0", - "beef8c80 40747078 3ae0dd8a c0be34a4 c02e6003 3f4b47e8 -> c0cd2d6c 3f8c20ea 3f4bb8dc", - "c051fa40 40140552 3ba5bb98 40a5c3c4 406c0a64 3baf02b6 -> 3ff31a90 40c007db 3c2a7ecb", - "3f60e500 3f9cd03c 3f856575 4097a224 40249f96 3ec13a8f -> 40b3bec4 407307b4 3fb5b470", - "c08b8aec bece4690 3e77774f c193bc92 bf4bfab0 4032d09d -> c1b69f4d bf998efc 4042487e", - "41009d00 bffdf870 3b490617 40f3e820 3fda1da8 3dc593d4 -> 417a9110 be8f6b20 3dcbe40a", - "c1888534 c05285a2 39c6eadf 4103c1ce 401d30d4 3cce8a17 -> c10d489a bf555338 3cd1b923", - "40e0df08 40617158 38d202a0 c16f79d7 4006080c 39de006a -> c0fe14a6 40b3bcb2 3a0ca434", - "4136fe64 bfc4f3da 39935c5c c19f8801 40634474 3e1f6b41 -> c108119e 4000ca87 3e1fb79a", - "c13373f6 404d9860 3ca3143a c17d1417 3fe9e89c 3d719ec1 -> c1d84406 40a14657 3da1a482", - "c116a2cf bf000d00 3ca6855f c0b63940 3fc0915c 40886eaf -> c171bf6f 3f808adc 4089155d", - "bf31fe60 40118d60 395358fa 411c1a42 3f0fb120 3e9dc69c -> 4110fa5c 403579a8 3e9de28e", - "c12cfd94 404a4c80 401b1fcb c0e238d0 408db0c8 40564da7 -> c18f0cfe 40f2d708 40b8b6f7", - "4109c0a0 c0164b9f 3f106fd8 40034ab0 c01e7789 39765913 -> 412a934c c09a6194 3f10803f", - "413fab2e 3fff5a04 3c8be434 40cb6628 be94bfe0 3fe16e1b -> 4192af21 3fda2a0c 3fe39e5b", - "c16844d6 409604d8 3ce27463 401ddd68 bf166d90 3b451339 -> c140cd7c 40833726 3cfb3727", - "c19a038a bfe8e7b6 3a85d543 c188441a 3fb74c20 41020d0d -> c21123d2 bec66e58 41021169", - "c18b5dfb c0928def 3f6429cc c08a3ab6 402ded90 39244fa3 -> c1adeca8 bfee5c9c 3f643599", - "41276408 407da870 401def58 400c5ea8 bf8da970 3c4896f0 -> 414a7bb2 4036d3b8 401eb837", - "41427990 40088a84 3a7ef47b c090183e 3f14e0c8 40b5eda4 -> 40f4dae2 402dc2b6 40b5f5bc", - "bf5231c0 404f2d04 3afb217f c1387ff4 3f88be2c 3db0fbc7 -> c145a310 4089c60d 3db4f0ac", - "c139f609 3fd71628 3bf54f3d 40500ce0 bffa2aa8 3e082503 -> c105f2d1 be8c5200 3e0fd1af", - "41020594 3fb491a8 3e03dc18 412bb474 be0715c0 3a93b4e2 -> 4196dd04 3fa3aef0 3e050893", - "c10a1e89 bf6cdde0 408b40d1 c06ce288 407e4f0c 3d98e27a -> c145572b 40431794 408da483", - "41969fd0 3f528e08 3da1b646 c1895cee 4024fdc8 3edf38fc -> 3fd42e20 4059a14a 3f03d3a0", - "c180a01a 3fa80a18 3f2150cf c11f7300 3f726ba8 3fa0325b -> c1d0599a 40109ff6 3ff0dbb3", - "4110554e 4061c3fc 3c75abf7 c13e48cf c04b2752 39ad0fca -> c037ce04 3eb4e550 3c7b216b", - "40d2201c c04c9f2d 3dba507b c11d9e95 40611214 3f0d197f -> c0523a1c 3ea39738 3f2463d2", - "413d319a c0949d72 3ab1e889 419be7fa c07ded97 3a14935e -> 41fa80c7 c109ca1f 3b0097f0", - "c19891e4 c088f53d 4089106d 40e8cb90 c025bf92 390b28c5 -> c13cbe00 c0dbd506 408911b1", - "c19d7de7 c0673c2c 4063b3ac 40bc1b9c be2bc960 3e6e0ed1 -> c15cee00 c071f8c2 407294ef", - "41698178 bef43b60 3932d79d 41419548 c092506e 3e178c01 -> 41d58b60 c0a19424 3e17c0b0", - "41301f48 c085eadd 3aae96d5 414f5cf4 401bb750 3ec51711 -> 41bfbe1e bfe03cd4 3ec5c8eb", - "419a80e6 400ade32 3ee638a3 4153fbf4 c00feb78 3ed11c1e -> 42023f70 bda1a8c0 3f5bac78", - "3d5e3a00 c0791028 3d32e2dc 408bc890 c02e4f38 3d28312a -> 408d8504 c0d3afb0 3dad8f93", - "417b9b10 c092083d 3dea70bd c064da30 c0434d00 392dc64b -> 41426484 c0f3aebd 3dead191", - "c1442aca c09a7edf 3e9c8296 4185ec12 bf8e4018 3c22aa07 -> 408f5ab4 c0be0ee5 3ea1993e", - "41013486 409dce28 411349e6 406cc4d8 c0384f55 3906a997 -> 413c65bc 40034cfb 41134a84", - "41883fe8 c04080bc 3b9031ed c13a103e 3ffec7fc 3d2ad296 -> 40acdf24 bf82397c 3d3cdf4b", - "c103d5d7 c04ef7c4 40050df5 c147ab64 c062d06e 3bee701b -> c1a5c09e c0d8e419 400585a3", - "c1630d02 c01c62d0 3aae1930 3f7288a0 4082fd1c 411e628e -> c153e478 3fd32ed0 411e6818", - "c198dc74 bfad5458 402d954c c14c2500 3fa70f7c 3edaac56 -> c1feeef4 bd489b80 4048eb63", - "c1999798 c08b6b2d 3b8f39cf c0d81026 c06d3892 3b286bff -> c1cf9ba2 c10103bb 3be47ffa", - "4112d2b6 4082d682 4047a976 3e815000 3feac8f0 3911751c -> 4116dd36 40bd88be 4047ac06", - "c143d8d4 3feb5698 3bad2a08 c183ef56 c07560b4 39015841 -> c1e5dbc0 bfff6ad0 3bb22aa8", - "c14c9a72 c09e3fb2 4011f073 c0e06c54 402ee528 39f3091f -> c19e684e c00d9a3c 4011f86c", - "c1502e4c c04df403 3989966e 419dfb2c 3f33a880 3fdcfb72 -> 40d79018 c02109e3 3fdd0463", - "c1698f24 401ca4d0 3d8ed4a8 40835250 c046e10e 3e18bda9 -> c127e5fc bf28f0f8 3e602ad5", - "c1429c03 4094191e 3934b29c 4050dc60 bed3f0d0 3ac811da -> c10e64eb 4086da11 3ae04be0", - "bf875cd0 3fb1d100 3d94be26 c14269b8 bfd9fd44 3aafc265 -> c1535552 bea0b110 3d9783fc", - "40c5c82c 408b12e2 3ae3bf97 416bcc84 c09fc547 3e089ef9 -> 41a7584d bf259328 3e0a6be5", - "4162e25c 3ffa0df0 3b3aefdc c1434486 c05bd9c7 40b655c5 -> 3ffceeb0 bfbda59e 40b66d35", - "c14129e4 4016dc5c 3ba1c513 c18f8dd5 bfa4ccb8 409df144 -> c1f022c7 3f88ec00 409e19fd", - "bfce3010 3f69f810 3cf37527 41065132 407abd58 3a19fd82 -> 40d91660 409a9dae 3cf85c5e", - "4196b4fc 3f7cb9e0 3d5e2cdb 40aca044 4060b570 39f63b31 -> 41c1dd0d 408ff1f4 3d60361a", - "401c2840 40991db6 3fdfba8d 4165532c bfcddb78 3e1a3ab9 -> 41862e9e 404b4db0 3ff30293", - "407e9138 c0155ba6 3f066940 418df834 401ec6ca 3cf1797e -> 41adca5b 3e16b240 3f0df673", - "c0c81450 c09fabbe 3f89aa7e c1813d52 bf953e0c 3ed2b735 -> c1b34266 c0c4fb41 3fbe593b", - "417ebfa8 bf473fc0 3b0ed4d9 40aaf218 40175c4a 3efba3aa -> 41aa1c5a 3fcb18b4 3efcc43f", - "4113c290 408e4972 392bae87 c181db44 407e628c 3c27a5e6 -> c0dfe7f0 4106bd5c 3c2a9257", - "c186fbca c0336dc5 3fd5089a c15bb82b 3fab62d4 3a4b7a6a -> c1f4d7e0 bfbb78b6 3fd52317", - "c17e4f2e bfccfa24 3c1d73e4 4101fe88 bef5ffc0 39aedb23 -> c0f8a14c c0053d0a 3c23122f", - "c1436fb3 3e249980 3fd2bc6f c19fc5cd bfab494c 4035f1f8 -> c200bed3 bf96b61c 408fa864", - "c0c33dea 406fe498 3a9c592e 414f592c 4017907a 3c649edb -> 40db746e 40c3ba89 3c785df6", - "416aadd0 4088c880 3ad48ab5 c17978ba c06e6f60 3c19d5f0 -> bf6caea0 3f0c8680 3c346d37", - "406d6fc0 3d56b580 3be5b98d c0ca2f3a 4069e7f8 3d33b783 -> c026eeb4 406d42ce 3d507513", - "40bf8cdc c04851fc 3be072ad 40a44270 409dea46 392d1b53 -> 4131e7a6 3fe70520 3be642fb", - "c0de4924 c0433ee2 40e31aac c157a670 bf1c5d00 3aa5d283 -> c1a36581 c06a5622 40e32547", - "417ccc20 40134e2a 3d9fd3aa c15eac68 401de870 39081670 -> 3ff0fdc0 40989b4d 3da01b12", - "c1488683 c01d50c1 3cd49268 c058cf60 c00665fb 3eae628a -> c17eba5b c091db5e 3ebbae4b", - "418b85d4 409d94c6 3a9736c8 c19f5aa3 c0795d65 40ad436b -> c01ea678 3f83984e 40ad4cf0", - "4116b37e 4061a7e8 3e37596b c0ecfaac bfbea410 3a4e476b -> 4000d8a0 400255e0 3e3828c1", - "3f71dbc0 400c3fd4 40234672 c1521090 bcc12100 3d51cdc4 -> c142f2d4 400abd92 40268ded", - "bfd35540 40025440 3ce2ffdb c19919c8 c03644db 3c1eca44 -> c1a64f1c bf4fc26c 3d194821", - "414a47d8 bf17dea0 3f1ec780 c0c4784c c05c911a 3de935f5 -> 40d01764 c0814461 3f3beef3", - "c1916699 c02a05bc 40438224 40cdad60 3ff62b18 38d44017 -> c13bf682 bf3bc0c0 4043840b", - "4153ebc0 bfe0de94 398acbb2 c1987a94 bf3967b8 3daefbac -> c0ba12d0 c01ec938 3daf8aa9", - "4032c440 3f4d25d8 3c00ce23 c080eb9c 3fa46bb8 39101093 -> bf9e25f0 40057f52 3c031bb6", - "c165921b c09b3af9 3f1b3d2f 418d1930 40921b68 3daf0b37 -> 40528114 be91f910 3f311eda", - "c13487da 40849f9e 3f44fad7 4149afd8 c048fd20 3e646eb4 -> 3fa93ff0 3f808438 3f7e16b9", - "c1478d36 bf8e20b8 3e9cd065 c1936b8d c013b024 39c8fdfb -> c1f73228 c05ac080 3e9d06f8", - "c10b66a8 4068470c 390ecaa8 4173650c bfcbf8a0 3a40d185 -> 40cffcc8 40024abc 3a66a682", - "bfda7920 bf25d600 3b1d52f8 4180b3b6 bef72500 3e19560b -> 41661848 bf90b440 3e1bcf41", - "c19a2ede bf550960 3f935710 4113c9cc c03caa0c 3a041469 -> c12093f0 c071ec64 3f93680b", - "41630738 c07cff94 3b206b65 c0f26390 bf1285d8 3f466c67 -> 40d3aae0 c090d085 3f470d91", - "c130c367 c09ae20c 3a00ef29 c059ef00 40569810 39238e68 -> c1673f27 bfbe5810 3a2dcef6", - "417907d0 3e9c4150 3b6af2b6 c1181382 c0750f27 3f2c1fa5 -> 40c1e89c c06186fd 3f2d0b3c", - "c19fc0d7 c018f729 3e70c30d 405511e8 be27e7a0 3d25a562 -> c1851e9a c02375a3 3e8d18a2", - "c0f2d0ca bfebde8c 3ca8a632 c1650349 403e0d94 3f338403 -> c1af35d7 3f903c9c 3f38cab1", - "4164c7c8 bedab820 3a596aa3 401150b0 c049de51 3a2e4aac -> 41848dfa c0653555 3ac65f87", - "4158f040 4096e590 3c4eaa0a c120ac0a 3fc850ec 3b89a304 -> 406110d8 40c8f9cb 3c89d167", - "c194d066 c09269b2 3dcc9aea c1280842 c09bd033 40812ecd -> c1e8d487 c1171cf2 4084618e", - "c0e10fd4 4023b5c6 3b4e7fb3 c1910e2b 40134b7c 40a85d93 -> c1c95220 409b80a1 40a877aa", - "bfad0c20 c0123d43 3e028996 41241724 c09fe4b1 39e25679 -> 410e75a0 c0e90352 3e02fed5", - "c0ec9b16 c085e00f 3aa32ebc c0a76ecc 3f12f1d8 3bfe6c93 -> c14a04f1 c06703a8 3c13dd1c", - "41631cc0 bfd698b6 3bafd95b c16255d6 bf440f08 3a0c0a5b -> 3d46ea00 c01c501d 3bc16ea0", - "c0c5f360 40212a5c 3dd7ad27 c0c082d8 3ef72a40 3c838e00 -> c1433b1c 40400fa4 3df89851", - "4186dcf0 c088b012 3b55a5c4 3fd48540 404b84a0 39286c92 -> 41942544 bf8bb708 3b61665c", - "bf9c3ca0 4046e420 3edd46e3 c126b36d c0830527 406b469a -> c13a3b01 bf7c98b8 408377dc", - "3fde8450 c0859371 40e5be8d c1046550 408ad0c0 3d995366 -> c0d1298c 3e27a9e0 40e823f7", - "c17c668c 3fd42d30 3cda1daf c131fca0 bf964a00 3e81b45f -> c1d73196 3ef78cc0 3e8f59af", - "4040b2e8 c04e3214 3b967089 c15d58eb 4000dd5c 40f95625 -> c12d2c31 bf9aa970 40f97be9", - "c0cd2686 c0756019 3ed38ba1 c14cd605 40565d44 408adb00 -> c199b4a4 bef816a8 409813eb", - "414f9cb0 402f21cc 3b085cc0 c14e2976 407fd030 3f0a7c53 -> 3db99d00 40d778fe 3f0b0526", - "40c12320 3f93a058 3ad40bff c02be1d8 3f83b340 3ba5d2e5 -> 40566468 400ba9cc 3bdb0234", - "c1506eca c08f4a30 3f9d840b c196841a c023dae1 40257a1b -> c1febb7f c0e137a0 40743ccb", - "4191f262 3fff6d00 3e90bd93 409c0a54 409531f8 3e22a01a -> 41b8f4f7 40d50d38 3ee21167", - "41059e42 bfec5d54 39b8c74a 411f3c64 407fdfd8 40ed1cec -> 41926d53 4009b12e 40ed2007", - "c1467e86 bfaeb2e2 3ae2cfae c192011f bea01000 3a25b22f -> c1f54062 bfd6b6e2 3b1cd9c4", - "c0f1a556 4088e176 3f2d2fb3 411897d0 3f35c740 3f2f97e2 -> 3ffe2928 409f9a5e 3fae640d", - "c01c47f8 c064dad2 3d9973bc 419d4b34 40998af0 3e3448d4 -> 4189c235 3f9c761c 3e8083af", - "c15967be bff3161e 4013ac5d 415a0ec8 c030bac9 39f9312b -> 3d270a00 c09522ec 4013b443", - "c1282e1b c03e6878 3f8b65b8 409e0918 be9e3dc0 3dab1186 -> c0b2531e c0523030 3f961720", - "40afa324 4080aa96 3ec19aec c11497d8 c02479f0 3ace3e64 -> c0731918 3fb9b678 3ec269de" - ] - }, - { - "glsl": "vec3 cultmath_af_sub(vec3, vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "c1822c5d c06c6c8c 3da954e2 40ca1250 400bca78 3b79ce30 -> c1b4b0f1 c0bc1b82 3db1319b", - "c17577bb c034b30b 39e64c6a 41875d04 c04ae8d8 3fa86375 -> c2010c71 3eb1ae68 3fa872e9", - "c18b1ecb 400b07d6 3b9bf8c7 bfcb57b0 3f629090 3db5ee20 -> c17cd2a0 3fa4c764 3dbfb643", - "c17f24fc bfc11a9e 3a02dd69 c1782aea 40442bdc 3b0c849d -> bedf4240 c0925c96 3b2d8c2a", - "c0bc7c56 3ff05194 3ca0f276 c14bb870 c07f39c4 3e626cc0 -> 40daf48a 40bbb147 3e768e4c", - "c18f72c0 c0527a26 40490343 c0d27d8a 407eef24 3fe19eb9 -> c135a6bb c0e8b4a5 409ce97f", - "c18afdf3 3cc78d00 3dba0fda 40106250 400f8684 38e13d31 -> c19d0a3d c00df76a 3dba5321", - "c19dcef6 bfedd046 39034d06 419abf8e 3f150888 3f131283 -> c21c4742 c01c2a45 3f131d59", - "c120bc9e c04ec377 3b7250f4 c16f7a8f c05572db 403c9754 -> 409d7be2 3dd5ec80 403cd408", - "c1801724 4099e918 3b88b5a5 c0e9f1ae bff97158 39154507 -> c10b3571 40d8456e 3b8ddb82", - "4164d790 408b205a 39c85b9f bfcebfa0 406d9f88 38f04c84 -> 417eaf84 3f2284b0 3a065ac7", - "4187cfd2 40130130 3f9f1db2 bf0c6f40 bf86de20 398d3893 -> 418c334c 40567040 3f9f2737", - "419f6034 3ee61380 3e085ccb c16a96e9 c07c8cfe 3ced1a79 -> 420a55d4 408ca7b7 3e2609e3", - "c12219e9 bfa77a90 39e8ef41 41045a32 408a8218 4085d368 -> c1933a0e c0b460bc 4085d744", - "c0b928ca 40884a88 38dd3af9 c19e3a20 c029107d 40772c4b -> 415fdfdb 40dcd2c6 40772e68", - "3f80d690 401efcf0 3a7e28ac 401c2338 3ffe8200 3f62d21b -> bfb76fe0 3efddf80 3f6311d2", - "41797188 3ef1d050 3c8646c0 c19d8877 c08d1043 3fb1c0cb -> 420d209e 409c2d48 3fb3db33", - "418a8be0 40280a58 3f50cc52 c12e63ff c06e3af8 3e033c11 -> 41e1bde0 40cb22a8 3f719d8e", - "c113d8cc 40953450 4018c94a 41545398 c0896f77 409919de -> c1b41632 410f51e4 40e57ed0", - "41805d82 c05f82a2 38d66e9a c14502f9 c07d4390 40aa9ef9 -> 41e2defe 3eee0770 40aaa013", - "c19db3b3 408609f2 3cf15e1c 41807dde 40938f1c 3e2e5537 -> c20f18c8 bed852a0 3e4c8a13", - "4178cd44 bf212190 3fd9a1c5 4156a65c c0240871 3d7d0609 -> 40089ba0 3ff7801a 3fe18a24", - "c190322a c02708fc 3b687a9a c0feb49a 402f4274 3a3a2c0d -> c1210a07 c0ab25b8 3b8bfe26", - "c16521e6 c06e3066 3f7a9704 c095a400 4017648c 3b11ff6e -> c11a4fe6 c0c2ca79 3f7b2a0e", - "c192a11c 3ff78e78 3e7b15f2 c118bcd6 3fcc9b8c 3d61455d -> c10c8562 3eabcbb0 3e99b4d2", - "41380948 3ffce900 3c86537d bdc91400 c09fd4c3 3a03d879 -> 41399b70 40df0f03 3c8a976e", - "c0d3a16c c095f1ff 3f822432 c168e869 bfce6286 3e917afd -> 40fe2f66 c044b2bb 3fa68354", - "41304944 bf29fca0 3ed1f0b1 c0e9b394 4034b7ea 3fb7f7e6 -> 41929187 c05f3712 3fec74cf", - "40a142bc 3f802aa4 3bfb393b 415442b0 c08ff08a 40f3fe48 -> c103a152 40affb33 40f43d41", - "c161c58b 3f9ed530 3a55dd9a c1307537 40663df4 3b0ee9c0 -> c0454150 c016d35c 3b44b837", - "4195dc12 3fa31434 3f44ea9f c1014234 c090b175 3d5c40cf -> 41d67d2c 40b97682 3f52b0c3", - "c17644a2 3f04b750 3acc2198 c153685a 40953b36 3f03eea3 -> c00b7120 c084a44c 3f045521", - "c0a7e48e c09e1cbe 3f61b979 c17b3d64 3f89c974 3b56687f -> 41274b1d c0c08f1b 3f6290f7", - "3ff0ae70 400f9792 4065cabc 415db1d0 3fad439c 39508b4c -> c13f9c02 3f63d710 4065ce40", - "c1527746 4091e34c 3e30b86a bfab79e0 bfbf993a 3bf9d506 -> c13d080a 40c1c99a 3e388b95", - "41928e20 c0795b7f 3a3d2e79 3faca900 c054a08c 3eb88613 -> 4187c390 bf12ebcc 3eb8e6e7", - "418451cc be674880 3c0b12e4 c14f11fc c03e9528 3aba4722 -> 41ebdaca 403020a0 3c22dcc2", - "406e2610 bedfb250 3e1714eb 40ac28f0 bebe5840 392e99ff -> bfd457a0 bd856840 3e174109", - "c1481407 c0934413 38fd6b6b 4172cba4 3fe2e9f0 39f92f7d -> c1dd6fd6 c0cbfe8f 3a24c8b2", - "c0b770ac c071f9aa 4111fe63 410b3160 c06ecaee 39971781 -> c166e9b6 bd4baf00 4111ffa9", - "417f2d7c 3fbe5538 3a85662c 4167b4a8 c0388499 3ff3cf9e -> 3fbbc6a0 408bd79a 3ff3f136", - "403521a0 40567898 3fc68b14 c18721e4 c043e0fa 39ead170 -> 419dc618 40cd2cc9 3fc69a9e", - "41857ffa bfa5b06a 3d2725c9 40e70a7c c01dd7b4 3a4df89f -> 41177ab6 3f95fefe 3d2a6859", - "c03d99c8 3ebba210 3cef34a2 4083fa54 c00d5b36 3b69ed03 -> c0e2c738 4024cf78 3d0642d3", - "c0b333f8 c086d7b2 3c6fd8a5 c194642b c04eb288 3931c797 -> 414f2e5a bf7bf370 3c72d78e", - "410c5c58 c0428dca 3bb963df c103f2bf c00e3f76 3d6fda69 -> 4188278c bf513950 3d838c65", - "c196b82e 4013d4da 3adb1482 4131ccfe c08b99f8 3e0ce244 -> c1ef9ead 40d58465 3e0ea19e", - "c13c0ea6 c079d040 3fd90303 41772c98 4093e5d8 3b5fea8c -> c1d99d9f c10866fc 3fd97423", - "4090f354 3fe184d8 400ce4f9 41485034 c005682e 3db70826 -> c0ffad14 40762a9a 40129d73", - "407d1388 c002cfb1 3be6d34c 417a3ee8 3ca75300 39f2a062 -> c13afa06 c0041e57 3bf66b62", - "c0457678 3eb085f0 3e47d69c 413b0df2 bfb5403e 411c3b48 -> c16c6b90 3fe161ba 411f5abc", - "413302de 3f9de564 3998a2f1 4195f63e 3fc1eb34 3d279a51 -> c0f1d33c be901740 3d28d378", - "418b04e4 3fbd9920 3cbda048 4169d53c bf83e85e 3a38715a -> 4030d230 4020c0bf 3cc36e6c", - "bfb4ea50 be8634c0 39c85525 c16f1da7 bf450800 3d02cc76 -> 4158805d 3f01eda0 3d046b32", - "c14e84ec 40820612 40550b51 41269596 3ff990c0 41023f89 -> c1ba8d41 400743c4 41378282", - "c14a4593 c067af45 3ab6e835 c1789c7b bfb9aac8 3d356d45 -> 40395ba0 c00ad9e1 3d3b29a4", - "419648a0 bf5c7260 3f1213e2 415eac04 c07bd642 3ba20571 -> 409bca78 4044b9aa 3f135875", - "c1371a11 3fb91a58 390b53f5 c0c4eacc 4072466c 3e28d390 -> c0a94956 c015b940 3e28f858", - "c174e764 40156fa2 404749c1 c13fef39 bf3c8f38 39112b2f -> c053e0ac 40449370 40474c2c", - "c19aad12 c0023ff7 39bd23b7 c15b5fea 3f9325b8 3c953241 -> c0b3f474 c04bd2d3 3c983877", - "c18216ca c099c95d 408c4d83 c17928fc 40363210 3d17517e -> bf304980 c0f4e265 408d7c40", - "c10432c2 404ea640 3b3f9593 418df670 407d4400 4103a5fe -> c1d00fd1 bf3a7700 4103b21a", - "c0516b58 3f956d68 3be0d5ff 4131abf0 4083fe36 3f47b07f -> c16606c6 c03d45b8 3f49734d", - "bf741ca0 4053f07c 39105c18 c118f0df 3fb6f9f4 40cd5fbe -> 4109af15 3ff0e704 40cd6101", - "c1854a21 409ad4d4 3eb9254f c13f8f08 c081a12c 394d8c7d -> c0960a74 410e3b00 3eb940bf", - "c0525da8 4047f128 3f7cdce6 c10083dd 4022d998 398ee472 -> 4097d8e6 3f145e40 3f7cef28", - "c0654550 c07df114 3fff30e7 3ee4fe80 c08f2152 39470877 -> c080f290 3f014640 3fff3753", - "c0bfad62 c050d444 3fc5b759 4184fe0a 40346b9e 3f8ef703 -> c1b4e962 c0c29ff1 402a57ab", - "40ce0b20 c0270613 3c084950 c0d5bc2e 3fe7c3c0 3f547363 -> 4151e3a7 c08d73fa 3f5695ae", - "c041c7e8 4054c34c 3bf9e8e6 419568ca c0974a5e 3f813ba2 -> c1ada1c7 4100d602 3f823681", - "41413054 c08251dd 3edf733d c129c8a0 3e842250 3988d2c5 -> 41b57c7a c08a9402 3edf98e0", - "c14a2820 c073d6f8 40031a91 c10caccc bfaa057a 3f8e6746 -> c075ed50 c01ed43b 404a4e5a", - "4185eadc 4094cb20 3f47b8bf 419712c6 408372e8 3cb5cf85 -> c0093f50 3f0ac1c0 3f4d6773", - "c170d2e8 c0549055 3a8608be 4180a786 3ecb5b40 3ff3917e -> c1f910fa c06dfbbd 3ff3b426", - "40df4dec c084dca9 39edd73b c19b28ed 406fee1c 408260da -> 41d2fc68 c0fcd3b7 408264de", - "4106cc2c bf108ba0 397b8850 c18d16a6 4005f7a0 40c9d4b3 -> 41d07cbc c02a1a88 40c9d6f0", - "c0dc90e0 c0760e10 3e31bd6b 4122d8d0 40142434 3e534465 -> c18890a0 c0c51922 3ec283dc", - "418f2430 bf989b46 40125ed6 403f5880 bf5acf38 3ec2d9e1 -> 416e7240 beaccea8 402aba5a", - "c19e485e bef4bc40 4081dbdf 41824f88 405ba47c 3ffd7bf8 -> c2104bf3 c07a3c04 40c13b39", - "407d2988 407fe14c 3d6e84e3 416e24e0 3f1a41b0 3c8356e5 -> c12eda7e 405950e0 3d981f5e", - "4190a1c6 c053d646 3ad9ccd3 418ce36a 3f321c20 4084d641 -> 3eef9700 c0802ea7 4084e3ef", - "411549d8 40660300 3af8c3ba 414bd208 3fb8dbfc 3f72581f -> c05a20c0 40099502 3f72d4e9", - "414da9c8 bfa75770 3c791ef9 3fc7dba0 40918356 3a236624 -> 4134ae54 c0bb5932 3c81cd01", - "419ae388 c0801796 3e65fb66 c058f158 c09ce08f 3c54c079 -> 41b601b3 3f6647c8 3e734d67", - "c19fe398 40422d1c 3dcd9dcd c13557f3 becbbd70 3f8ed003 -> c10a6f3d 405ba4ca 3f9baa4a", - "c06e3f20 bee36a80 3d74c750 c13b9629 40419544 3d84f112 -> 41000661 c05e0294 3dff5a86", - "c04fe150 c09dbf38 3f919e9c 418f6e40 405a8c48 3d745c48 -> c1a96a6a c10582ae 3f994274", - "bfca9810 c04862c5 3f8bfe07 c16f1668 c084855e 3cbfe0ba -> 4155c366 3f814fee 3f8efe06", - "c0453f70 c08cd889 40aa0c53 c0879056 40785dd0 3ca47abe -> 3f93c278 c10483b8 40aab0ec", - "412d4320 3ebbff00 3a23f8cb 414db548 408cc700 3f2d6c8a -> c001c8a0 c0810710 3f2d95f4", - "c0e230ea 3e2a1cc0 3c224ff6 c009ded0 bf6278b8 3a668858 -> c09d4182 3f867ff4 3c30d063", - "c1266da2 3f927fe8 3d8bba70 416f50fc c0730c38 40af38a1 -> c1cadf4f 409e2616 40b167d3", - "c0c2e494 c0948ab9 3b00200d c1764eb5 40918b56 3fa68a38 -> 4114dc6b c1130b08 3fa6cae6", - "4093164c 406f4f38 3ec61cc7 c16f1796 403bf7ea 3c248088 -> 419c515e 3f4d5d38 3ecb4363", - "41693bb4 c09be3cf 3d8ce3ea c181af09 bf236530 3b0bb83b -> 41f64ce3 c0877729 3d915338", - "c077c178 3f794988 396311a2 c191974c 3f9fe9f0 3b89f906 -> 41653e3a be8d14b0 3b918670", - "c15c3180 c09b6da7 3f40c6a6 40983e60 40775738 3cba6acb -> c1942858 c10b8ca2 3f469bbc", - "41824898 3efaf940 409fad80 419f2ac4 c0912af1 3fe9a2cc -> c0671160 40a0da85 40da1652", - "c13e84f8 3fc723ac 3da642d4 c0d16da0 c03bd5e0 396033e4 -> c0ab9c50 408fb3db 3da6b7e6", - "c1906ef6 c04200de 3ed2c7ad 419fa0a6 3f513258 3c216367 -> c21807ce c0764d74 3ed7d811", - "409b4cd8 c0630f8f 3a4c24b3 c0feacba be95f530 3d2885fd -> 414cfcc9 c05050e9 3d2bc6ac", - "41739190 bffc8764 3c39b0ca 418aad08 4092f166 40a1610c -> c0072200 c0d2133f 40a1bdff", - "c190cce0 409eb5fc 410a79f7 c1227d79 c033a8c5 3adb3db8 -> c0fe388e 40f88a5e 410a80e9", - "bfc90e00 406ae630 40d9942c 4109c1a2 407b26e4 3f4cbf9f -> c122e362 be8205a0 40f32c44", - "40eb585c c08a9cc7 3c137e64 c19fa59e 409ed7aa 3c625377 -> 41da7bb5 c114ba38 3cbb3230", - "40828134 c05b72cc 3c6e60a6 c09ddc10 409f3c62 3f022ad3 -> 41102ea2 c1067ae4 3f05e575", - "c10463ee 3f87cf18 39812726 c0551900 c0753c07 3f05cb21 -> c09e3b5c 409c91ca 3f05dbec", - "c0160960 c013df0b 3e9b4d0e 40b4ee74 c0071d0f 3a93f998 -> c0fff324 be4c1fc0 3e9be218", - "c186dc9c 40419f8c 40f738c1 bf5eee20 3ec31860 3ebfbcd0 -> c17fca56 40293c80 41019a62", - "c02d9358 4081f264 3af0b2c8 c082f740 3f95faec 3c2b50ad -> 3fb0b650 4038e752 3c497827", - "c16b86de 4072dcc8 3b5ee874 419a7fe2 bfd7cd0c 3f831c11 -> c20821a8 40af61a7 3f838cc9", - "3ea33bc0 3fdaa88c 411d018f c1226ec8 4090f33a 3dee5cd5 -> 412788a6 c034922e 411ede60", - "c155850a c091edc0 3f104e4e c1315f8c c010bc06 3e062c91 -> c01095f8 c0131f7a 3f31d9c6", - "c1850d16 c0926586 3f469b78 c14c95e8 408736fe 3a7436ec -> c0761110 c10cce42 3f46d95d", - "bffd9090 c070d086 3dfee5e5 410b71b8 408e3b66 39966329 -> c12b23ca c10351d4 3dff85cc", - "beec5880 407d17b4 410cda31 40df45c8 c009bf62 3ac97d59 -> c0ee0b50 40c36b8b 410ce093", - "c0207ca0 bed410e0 409be95e 417c5970 c06aa2a4 3dfc20ca -> c1923c4c 40502088 409fda16", - "c1383507 4054b590 3fe27d0c c0ad8f92 bff0d3ae 3cf2214c -> c0c2da7c 40a68fb4 3fe645fa", - "4194a218 c03a0548 3e146873 40a58738 bfeec2e6 3d98fb0b -> 41568094 bf8547aa 3e60e9a3", - "40a12ed0 40908784 40c2e2e2 c17802cf 3ea58ea0 3a8f2fa8 -> 41a44d1c 40862e9a 40c2ec13", - "c14ad490 4039a828 3edb4b83 41822f98 4024f3fa 394b4f78 -> c1e799e0 3ea5a170 3edb68a3", - "409f0b2c bda4fdc0 3f200cea 3f03b060 4036bf9c 3f989acb -> 408e9520 c03be78a 3fe8a18a", - "40edfcec c04673a0 4060d030 c159ab2a 4095cf90 399415b1 -> 41a854d0 c0f90960 4060d552", - "c0c752a4 c0847524 3f92bfd6 c1701464 40222d88 3ef29f6d -> 410c6b12 c0d58be8 3fcf683a", - "bfd06690 4065d9a4 3da67285 c05b79a8 c0907a42 3b97b6c4 -> 3fe68cc0 4101b38a 3daff2f0", - "c10c879b bfe038b4 4088e44e 41131d7c 40072e04 3baa936b -> c18fd28c c0774a5e 40890f27", - "417ab134 bff92874 3977918b 413aea58 4019b2a0 3fa0f9d0 -> 407f1b70 c08b236d 3fa101da", - "41165aaa bef7b6b0 3c577b6f 414adab8 408de292 39d96d1f -> c0520038 c09d5dfd 3c5e67b2", - "40d3e1d8 beadeb70 41044fc8 416ab664 402ba682 3c8b8bb9 -> c100c578 c04163f0 410495a1", - "c0855ea0 c08d6016 391ff77b 419d30b2 bf064ff0 4047255b -> c1be885a c0792c30 40472856", - "bf7aa660 c0399bfe 3c8712e0 c03d36c8 c02b3d60 3ca4cec8 -> 3ffd1a60 be65e9e0 3d15f311", - "4178fa08 4091f07c 3ccab81b 40288990 c0145c5c 3e530a87 -> 414ed7a4 40dc1eaa 3e6c668c", - "c19b0497 3f05b158 3bafcea1 419d6d9e bf8cde1c 3b538b75 -> c21c391a 3fcfb6c8 3c0d6cee", - "c0f17e0c 3fb630ec 40729f4a bfd4c840 401f30ac 3da76207 -> c0bc4bfc bf88306c 4077da85", - "c0c07cac bf5cf7f0 3d7895e4 bf4d0100 bfd46668 3e3c87c8 -> c0a6dc8c 3f4bd4e0 3e7aaed1", - "c0f78ad4 408027e8 3ff909af c14f58be bfead686 3d37507f -> 40a726a8 40badd8a 3ffec49b", - "c09e1d00 bff4af4a 3aa375de 41942f94 4088f058 410a489b -> c1bbb6d4 c0c61c2a 410a4ddd", - "40b9679c c08018bc 3a7fb86a c0e586de 4060bf90 3a9d8c09 -> 414f773d c0f07884 3b0ffbdb", - "c17fc6fa bf762a30 3e60af69 41165642 3fe640d4 3f87e4a6 -> c1cb0e9e c030aaf6 3fa3fb7e", - "419a82ec c09a88af 3ca5d29f 416703ac c08787ae 3f9ed8ca -> 409c0458 bf180808 3fa1704a", - "41814f68 bf68d7a0 3e03e9ff 41507030 c01a1834 3be1ea52 -> 4048ba80 3fbfc498 3e0afa83", - "41433398 40594f90 3ac5ae44 414a147c 3f93d378 3985626f -> bedc1c80 400f65d4 3ae75c63", - "c1859116 bfc23c58 3ebf1c49 4189182a 4048b328 3e341649 -> c20754a0 c094e8aa 3f0c9628", - "c093ac0c c096bd73 3d85042b c0cbfa10 bf9a122e 408f4d60 -> 3fe13810 c06071cf 40916185", - "419b1fa6 3f379150 3aa62838 c18f29e6 c0445e97 3b4df027 -> 421524c6 407242eb 3b91cabd", - "c189f25c 3e1edd00 3abe44b3 c07ee848 c08d1fd6 3d20fd7e -> c1542aa6 409216be 3d270182", - "c0ac600a 404c43a0 3fcbf809 41534b1c 3e208fa0 38efbcb7 -> c194bd90 40423aa6 3fcbfc82", - "4199b14a c009db74 3f5fdfc5 405f1928 3fc2f0dc 3b95253a -> 417b9c4a c06b53e2 3f610b54", - "c182f21c c08e953d 3a88714a 4147d130 be7264c0 39353dba -> c1e6dab4 c0870217 3aa33b78", - "c11c01d6 3f226f68 39131e8f 40f579b0 405a30e4 3e8c3dc4 -> c18b5f57 c031950a 3e8c52b7", - "c161db92 40218764 3e2ea74c 418b98c0 401df930 39a5bf30 -> c1fc8689 3d638d00 3e2f021f", - "415f30dc 3fe92fcc 3b37273f c142ded0 3f218160 41161021 -> 41d107d6 3f986f1c 41161bb8", - "41457b68 3f0b7b78 3d16e2ba 400249d0 bfb2bf38 399c94ce -> 4124e8f4 3ff87cf4 3d18282d", - "c1653460 bf830dfc 407d0f49 4178f0d0 4093c836 3a017f6c -> c1ef1298 c0b48bb5 407d17ff", - "c1814aae c01bb5e8 3924a2fd c149b3d2 c063b83d 3cf612f6 -> c0638628 3f9004aa 3cf765a8", - "bed79300 3fde264c 40f915b4 c15e1cbd 3fea4d58 3f27c326 -> 41576025 bdc270c0 41070722", - "c0ac7c52 c091e775 3d481209 40f11fa0 4018956c 40e2db62 -> c14ecdf9 c0de322b 40e46bbc", - "c1927175 407cfa98 3cea78d5 c13a3412 c09ed51d 4082207e -> c0d55db0 410ea934 40830b1e", - "3faf7b40 40036bb6 3a87d489 418b0068 3eff89c0 3c86e092 -> c18008b4 3fc6f4fc 3c8f8102", - "412b9792 c01acc62 3f65a980 3e9c48c0 4059c6d8 3ce73b1d -> 4126b54c c0ba499d 3f6ce46c", - "c18c8c1b 3fd1c960 3d48969c 413bfd02 4003ddc8 40336929 -> c1ea8a9c bed7c8c0 40368c05", - "c19ad19b 3fc73050 4011aaf2 411ffa8a c0492f63 3b7a0920 -> c1eacee0 409663c6 4011ea05", - "40129c08 beee2180 3e4a7203 418fc5b0 405dd3b8 3961940b -> c17ae45e c07b97e8 3e4aaf5c", - "40bcad6c 40779eb8 3af16c3c c174e6b6 3fc0b988 3c801dd6 -> 41a99eb6 401741f4 3c8f63c5", - "c104d6fa 3f0d0a50 39d9aac2 3fb2d710 bf93689c 3c5a491e -> c11b31dc 3fd9edc4 3c61441e", - "4197454e 4064df94 3a88e443 c190c1df 3fa35008 39774681 -> 42140396 40133790 3aacb6d6", - "c02dbe68 c020dfed 3a6798aa 40824ff8 c04490dc 3bb42405 -> c0d92f2c 3f0ec3bc 3bd151e9", - "c18fdeae 4035f4dc 3d227f08 41778c28 bf9d4c60 399f196b -> c205d261 40824d86 3d23e2cc", - "4135d448 404c0c34 3c3b1530 410f6126 40668b90 40bb1176 -> 4019cc88 bed3fae0 40bb6f12", - "c1284539 408de740 38f47fd4 c18045f5 3c53fe00 3a1507ea -> 40b08d62 408d7d41 3a361404", - "412a2b46 be3fe160 3b1409f0 c008eb80 40316ff0 3b8f17d3 -> 414c6626 c03d6e06 3bd99ab9", - "c177faec 3dc55800 3fac7903 4058cb68 3e2faf80 3dc8128f -> c19716e3 bd9a0700 3fb8facf", - "41717904 c09168a2 3e972c0a 41819b58 c08a94ac 40093d0e -> bf8ded60 be5a7ec0 401c229e", - "4186207a bf718c88 3a4b7302 c19749bd 40208698 3d8a7b50 -> 420eb51c c05ce9ba 3d8c25cf", - "c19bb66a c020d688 411b4280 c11fbdea 4046c17c 3e86e31b -> c117aeea c0b3cc02 411f79b2", - "c18c6b97 bfd5c762 3f0b9dd2 c193bf31 4056fcb4 3eb90cfc -> 3f6a7340 c0a0f032 3f6824be", - "c187476a 3f84fb08 38e379fe c14555f3 402f8714 400b2c2f -> c09271c2 bfda1320 400b2e18", - "c112de67 c0405e91 3b5342b3 4148ac3c 405de820 3f977ae3 -> c1adc552 c0cf2358 3f97e56f", - "c11a076c bfd6f7d4 401a6f2a c161dffd c04cccde 399db19f -> 408fb122 3fc2a1e8 401a743a", - "41975938 4018bec0 3ee5dd2d 41030cf8 bf2b3830 3d33f177 -> 412ba578 40438ccc 3efc5d25", - "c0d8c5ec 4067c300 3ea033e6 c16545b6 3e70a0a0 3a5a7911 -> 40f1c580 4058b8f6 3ea0a28b", - "41606790 4058f768 3a928667 419a612a 4051c584 3ca9482b -> c0a8b588 3de63c80 3cb27b61", - "4165e2f8 401196e6 3e12f720 c0f28c94 40244aec 3d6a12fc -> 41af94a1 be95a030 3e4d817b", - "c116d1bf c0401912 3c2794e4 c14b08d0 409d24c2 3cca4004 -> 4050dc44 c0fd314b 3d0f1071", - "4144e1ac 40848468 3a1891d7 40c229ec c08b1868 39a0a220 -> 40c7996c 4107ce68 3a6c9162", - "4199f8f4 bfa33796 3a3b3e7e bf5c1880 40670d04 4068babc -> 41a0d9b8 c09c5468 4068c6e3", - "c1543a35 c06d98b0 3e756d03 c174cd6e 40942256 38e534c7 -> 40024ce4 c1057757 3e758c52", - "40865590 c00ec9c1 3d0814fe c05d8530 c007c2f7 3c95f54f -> 40f51828 bde0d940 3d531778", - "bfb6f560 3fcff16c 4101fd02 c14d69d6 bf188528 3ac03f7a -> 41368b2a 400e1a00 4102031a", - "c16efae0 c0615a27 40110700 c132d421 bfd44ec4 3de42961 -> c0709afc bfee658a 4018286b", - "c1960541 c040ad63 3f3d1583 c1780beb c09f97ca 3c9acf32 -> c04ffa5c 3ffd0462 3f41ec5d", - "c104f269 bf98b6fc 4009910e 410c51b6 c0650c14 3e0d45d6 -> c188a210 4018b096 401265c2", - "41704dc4 c0620450 3ac88423 c0875ec8 3f473198 3ebe9ee9 -> 4199fe94 c089e85b 3ebf6a6b", - "4197bf6a bf877a10 3e0a859a 41004cf0 c0480c61 3c2958db -> 412f31e4 40044f59 3e151e72", - "c17635df 40415bc0 4092609e 418c0044 bfbd8d52 3ebc545f -> c2038d9a 40901134 409e2639", - "c192dab4 408f4cf6 3f70a08f c18ab4ea c0846176 3f2917f5 -> bf825ca0 4109d736 3fccdc9c", - "c12a377b bd992980 3b1c86b4 c190515f c0726ee4 405bd425 -> 40ecd686 406da598 405bfb81", - "405c4968 401ccfa0 3d23b525 c0badf98 bffb6f32 3b40765f -> 41148226 408d439c 3d2fca48", - "419ed462 4014b484 3d911dc4 c15b99c6 c02252f6 40a055e2 -> 420650a2 409b83bd 40a29ab0", - "419a9aba bfd8aee6 38ef7369 c0a55c88 409f14fa 3a81cb85 -> 41c3f1dc c0d540b4 3a94a7cd", - "3f6dbd20 bfb9e5e2 39120c48 c15ddd48 3fe40e40 3a757dd5 -> 416cb91a c04efa11 3a8f416c", - "415554f0 4045b798 395284ef bf8a7e60 c05977e9 398bf682 -> 4166a4bc 40cf97c0 39ffac8e", - "c01d4a38 408810ca 3b17cdc9 410c3340 c076c568 3c857ba8 -> c13385ce 4101b9bf 3c989c12", - "4174d1b0 402739ec 3cfec80c 40b144f0 408d2be4 3e00437e -> 411c2f38 bfe63bb8 3e201f6e", - "c1647248 4075e460 3ea4a051 4162f908 c0854fa4 3f198933 -> c1e3b5a8 410020ea 3f6bdbb2", - "41219310 406876c8 3cf5a9fd c187876e 3e840b80 3f2df027 -> 41d850f6 4057f558 3f359f69", - "41722d5c bf2c4178 39626208 c0deaa6a 3e53b480 3cf388a8 -> 41b0c148 bf612e98 3cf57b6e", - "c12adb94 3e6f8900 3d949d48 bf1bc3e0 400bb8c8 3b843615 -> c1211f56 bff98070 3d9ce6b5", - "40d5c794 c016fdcb 3a9e1f14 4030ebf0 bdeffe80 3ac6053e -> 407aa338 c00f7dd7 3b3274bc", - "41006154 40763958 3c3fa001 c06866a0 c09cb580 3f6ecf09 -> 413a7afc 410be916 3f71cedf", - "be925c40 40992df0 3ed93b06 c0f9abd8 400d1d24 3b4829a3 -> 40f08614 40253ebc 3edaccaa", - "406623c8 bfb08764 3c22bd70 3e85b9c0 405a05e4 3e83296b -> 40556c90 c09924cb 3e884062", - "c09f48fe 3f109b90 3ad1371e c19ebebc bf7207d0 3c4907f7 -> 416dd8f9 3fc151b0 3c63706a", - "c190d3cd 3fca93ec 3a31024c c0993d28 c047eac0 3f9fe603 -> c1550906 40969a5b 3f9ffcbd", - "3fc93480 c04aa7ed 3bf590be c119e348 bf9ee062 3e244b97 -> 413309d8 bff66f78 3e2bfb6f", - "c0bc6278 be9dc7f0 3c541c1f c1115a40 40553dac 3d520a46 -> 404ca410 c068f6aa 3d838c1a", - "412c39f4 4088fd2c 3f845927 c10fe4e1 407cbad0 3bc5f77a -> 419e0f6a 3ea9fc40 3f851fc7", - "4186f5ac c0594a04 3c56888d 3fb11800 c0442084 4091ec09 -> 4177c858 bea94c00 40925776", - "419e78b2 3ffbbd9c 3ccc0c1a 419eab08 bfb0e41a 3bbc9acc -> bcc95800 405650db 3cfb399c", - "40a3ee50 c077f44e 3f66f38c 4181fc2e 402a0384 3d46a33d -> c1320134 c0d0fbe9 3f735eea", - "41870d4a bfd9278e 410882a5 4125580a c05da0f6 3bebf5b3 -> 40d18514 3fe21a5e 4108a035", - "c11a0fab c07e4a40 3ed3b85d 40fe3e7c c029b76b 3cc7a0d3 -> c18c9774 bfa925aa 3ee034d5", - "4093079c 402e3d46 3f27ec19 41462f20 bed44f50 390f5302 -> c0f956a4 4048c730 3f27f5c7", - "c0853b98 c09e7e38 410e4507 c01189b0 c016d4ad 3e7edfef -> bff1db00 c02627c3 41124095", - "c1587334 bfb70e98 39b47efa c1897834 3fb95d30 3ecd490a -> 4069f4d0 c03835e4 3ecd7708", - "412098c4 40684198 3a2a1f29 c115e9a7 bfbbfee4 3d882845 -> 419b4136 40a32085 3d8988cc", - "c0a6600c c0576cb6 38e2be20 c18f614a c00fcd54 399544c5 -> 414b928e bf8f3ec4 39d4e02d", - "c13a900c c0022ddb 3ca6fa9d c19f6435 bf985b78 3db5985f -> 4104385e bf58007c 3ddf5ba2", - "4062ef98 404bc808 3e3ec2f0 4128e75e 3dd2c500 3f234703 -> c0e056f0 404531e0 3f52f86e", - "3ff263d0 be583000 39603c6f c0f70904 3f772d00 3f768228 -> 4119d0fc bf969c80 3f7690e8", - "c116fa2c c0471f42 3c9f778e c19f2463 408f433e 3bed2886 -> 41274e9a c0f2d2df 3cdae5d5", - "c0ece638 bfc12516 3c4c2f40 c140bf74 bf1a8360 3b43f3e3 -> 409498b0 bf67c6cc 3c7d427b", - "c1997bd7 bfc7b670 3ee320a6 417f4ed8 c029d260 40dcb41a -> c20c91a2 3f8bee50 40eae67b", - "c134e537 c059aaca 40f2ca05 3f368620 be3ac500 3fad7a8d -> c1404d99 c04dfe7a 410f146c", - "c18ab1d0 409bd8b2 3bbde2f7 c07c2488 400bc9de 40167256 -> c1565a7e 402be786 4016d191", - "bd724e00 c08bd5c2 3d8bd125 c1398f65 40383798 398dd39d -> 41389d17 c0e7f18e 3d8c6866", - "40aa4528 c03c4747 3bb5f29b c1833863 3fef5564 3917549c -> 41adc9ad c099f8fc 3bbb8194", - "c152ec0c bf8d094c 3c004e3e c0b49a5e 401bdf0c 3a31e10b -> c0f13dba c06263b2 3c0b98a6", - "c195e878 3fbdfb40 3ada1d05 c1808c24 c0834fa6 3c79de12 -> c02ae2a0 40b2ce76 3c8aa166", - "414d3fe8 401d9d74 3eafb8a6 40a84130 408b8d6e 40cb7ba4 -> 40f23ea0 bff2fad0 40d6774e", - "c199d239 40844b04 3e11ca63 3fe5c950 400032dc 3bfa5f94 -> c1a82ece 4008632c 3e19a333", - "41121abe 404697b4 3d77315c 40b6fdec c015d3bc 391225d8 -> 405a6f20 40ae35b8 3d77cc6d", - "40981b08 c06e7471 3cbda82b 418e20d0 bfc35726 39971c7f -> c150341c c00cc8de 3cc02316", - "c0060948 4004e98e 3ad83497 c148c5ef bfa67066 396abcdc -> 4127439d 405821c1 3af746d9", - "40a66860 bf7f6818 40eb7c48 c16cadfd bf8d9e98 3929360c -> 419ff116 3ddea8c0 40eb7dd1", - "c09a7640 c09f7f01 3b123bd8 c08f12dc c089662a 3f3cd30b -> beb63640 bf30c6b8 3f3d6564", - "c07cfb18 3fa0b594 3e8f7b30 c19f50e5 3fa73024 40946289 -> 417f6304 bd4f5200 409d5a66", - "408d085c bf8e9fcc 3c05fc64 c1362588 be525cc0 40cf2d5f -> 417ca9b6 bf68a868 40cf708b", - "419465c2 4070fe48 3c21bf34 4093696c c04a5d17 3ab5d1ac -> 415f16ce 40ddadb0 3c38ccf1", - "410b02c0 4055217c 3d559847 401b5d68 4084c27c 3b4f6e3c -> 40c856cc bf518df0 3d62964d", - "c077a470 3f7b22f0 3c508273 3f1530c0 c01745eb 3b096e29 -> c08e7850 40560ea7 3c72fd3c", - "4125d70a c02c690f 39499e8b 40ff2bb0 3edc0330 3ed02f82 -> 401904c8 c047e975 3ed04973", - "c079c0a0 bf0b8220 397e9fb6 c0f2ea00 3f42d788 41012652 -> 406c1360 bfa72cd4 4101275e", - "40eff5c0 bf5a9920 4080893e c19c70af c0557982 3d161b32 -> 41d86e1f 401ed33a 4081b5b7", - "40b6a23c 4029102a 3f9d0dd3 c192c9b8 3fdae7a8 3aca1970 -> 41c07247 3f6e7158 3f9d412b", - "c12cb990 4059e9e0 3eb717a5 c08d88c0 3f7d1d40 391877af -> c0cbea60 401aa290 3eb72bd9" - ] - }, - { - "glsl": "vec3 cultmath_af_neg(vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "3efc0ac0 c081676f 39dcef73 -> befc0ac0 4081676f 39dcef73", - "c17458ea bedfe490 3ae60300 -> 417458ea 3edfe490 3ae60300", - "4181bea0 c016ca53 3b988793 -> c181bea0 4016ca53 3b988793", - "40e29ec4 c037db20 3efba417 -> c0e29ec4 4037db20 3efba417", - "c15f2030 bf6e2100 3afc5f9a -> 415f2030 3f6e2100 3afc5f9a", - "401eda20 406edc78 3d01ebd0 -> c01eda20 c06edc78 3d01ebd0", - "c09a7dcc bf8a0f7a 3c6be155 -> 409a7dcc 3f8a0f7a 3c6be155", - "41829a4a 406e01f0 3d00bee8 -> c1829a4a c06e01f0 3d00bee8", - "c008d338 400b6a78 3d809c4e -> 4008d338 c00b6a78 3d809c4e", - "414c45b4 be9d84c0 3ea699b5 -> c14c45b4 3e9d84c0 3ea699b5", - "c19c6e18 c09bd5e4 3fdaf64f -> 419c6e18 409bd5e4 3fdaf64f", - "c191beec 403eaaaa 3ccef4d8 -> 4191beec c03eaaaa 3ccef4d8", - "416421b0 3f314f30 40c6150f -> c16421b0 bf314f30 40c6150f", - "40dc1108 c07c5ea0 404f3bad -> c0dc1108 407c5ea0 404f3bad", - "c14d4b76 409500de 3d6a2cd1 -> 414d4b76 c09500de 3d6a2cd1", - "c186922e 40798cc0 3b08fc23 -> 4186922e c0798cc0 3b08fc23", - "4199d34a 3fd71fd0 40db8808 -> c199d34a bfd71fd0 40db8808", - "c139556f c09cc2be 3a8da2bd -> 4139556f 409cc2be 3a8da2bd", - "40811a2c 3f855780 3aac3dd7 -> c0811a2c bf855780 3aac3dd7", - "40a09834 3fdbb7c8 3efc058f -> c0a09834 bfdbb7c8 3efc058f", - "40f24048 c0846439 3f721cc9 -> c0f24048 40846439 3f721cc9", - "40a7cebc 3fd45724 3a82a2fd -> c0a7cebc bfd45724 3a82a2fd", - "417aab4c c07ba257 3de353b4 -> c17aab4c 407ba257 3de353b4", - "4130e6d8 400394d8 3b58e883 -> c130e6d8 c00394d8 3b58e883", - "3fd6a7c0 4004b898 3b315857 -> bfd6a7c0 c004b898 3b315857", - "3f978b60 4012800c 40597cfb -> bf978b60 c012800c 40597cfb", - "418f5f50 bfaa20e2 3fb08496 -> c18f5f50 3faa20e2 3fb08496", - "c102d8f6 40589f20 3f81bbed -> 4102d8f6 c0589f20 3f81bbed", - "4116891c 40407940 38d8d03d -> c116891c c0407940 38d8d03d", - "40b31230 bf102bc0 3a73ece7 -> c0b31230 3f102bc0 3a73ece7", - "c11baa72 c02c2a6c 4044e2bf -> 411baa72 402c2a6c 4044e2bf", - "c13342ac 409a742e 390317c6 -> 413342ac c09a742e 390317c6", - "c17b9572 3ef66960 3b4ea273 -> 417b9572 bef66960 3b4ea273", - "c0bdcaba c047cfa8 3f52bc88 -> 40bdcaba 4047cfa8 3f52bc88", - "40c65e00 c03d4043 40cfbae4 -> c0c65e00 403d4043 40cfbae4", - "40d10974 3fd7ab38 3b55e65c -> c0d10974 bfd7ab38 3b55e65c", - "41867c16 c089322a 40183c16 -> c1867c16 4089322a 40183c16", - "c0e9a1fe 3fe31af8 3b5a6eb3 -> 40e9a1fe bfe31af8 3b5a6eb3", - "41835da0 bf880dc6 3ae3446e -> c1835da0 3f880dc6 3ae3446e", - "419e1362 407d5e40 40077fa0 -> c19e1362 c07d5e40 40077fa0", - "c142090c c01eddcc 3e53d510 -> 4142090c 401eddcc 3e53d510", - "c058c758 3e491480 3cc161a2 -> 4058c758 be491480 3cc161a2", - "c06fbce8 bfe3d0b8 3ed72f65 -> 406fbce8 3fe3d0b8 3ed72f65", - "c11512ed bf45e480 3a521ad5 -> 411512ed 3f45e480 3a521ad5", - "40885414 3f768ff8 3a4e89ca -> c0885414 bf768ff8 3a4e89ca", - "c191a8b0 3fb3f014 3e17c487 -> 4191a8b0 bfb3f014 3e17c487", - "4158c470 c088fdd0 39f0554f -> c158c470 4088fdd0 39f0554f", - "410017c8 400c90ec 3bee8913 -> c10017c8 c00c90ec 3bee8913", - "c0e85992 408c9346 3d6ffc55 -> 40e85992 c08c9346 3d6ffc55", - "406e2e50 bff3fbd6 3db45b36 -> c06e2e50 3ff3fbd6 3db45b36", - "412dd162 c077bc38 3e3ada16 -> c12dd162 4077bc38 3e3ada16", - "c02770a8 c05cdc50 40993420 -> 402770a8 405cdc50 40993420", - "c1733982 c0269f2a 3e87b1cd -> 41733982 40269f2a 3e87b1cd", - "bef886c0 c01b8c0b 3bb0eef3 -> 3ef886c0 401b8c0b 3bb0eef3", - "4047c6c8 3fc41630 3e331c67 -> c047c6c8 bfc41630 3e331c67", - "40f8f1ac 400704f8 3985649c -> c0f8f1ac c00704f8 3985649c", - "c16fd2e3 406a0ca0 3f153e8d -> 416fd2e3 c06a0ca0 3f153e8d", - "40917218 c05c9daa 3fa8b5b4 -> c0917218 405c9daa 3fa8b5b4", - "41150eae bd083500 3d3b84ad -> c1150eae 3d083500 3d3b84ad", - "c105f0cb c0810286 3da35083 -> 4105f0cb 40810286 3da35083", - "4186bb96 40488534 38f28adc -> c186bb96 c0488534 38f28adc", - "c1691f07 bd391380 3b67f446 -> 41691f07 3d391380 3b67f446", - "3f921f90 c051f9cd 3c83f4d7 -> bf921f90 4051f9cd 3c83f4d7", - "c1244eec 4087f412 3c25970f -> 41244eec c087f412 3c25970f", - "418fd878 bfbeeeb8 3f9807bb -> c18fd878 3fbeeeb8 3f9807bb", - "4136e5ae c071d9ea 39615327 -> c136e5ae 4071d9ea 39615327", - "410f4498 3f9eb4c0 3ab59e4a -> c10f4498 bf9eb4c0 3ab59e4a", - "bf8d0b20 bea50c50 3c87765c -> 3f8d0b20 3ea50c50 3c87765c", - "4156ee2c c05ae7ae 40c4766a -> c156ee2c 405ae7ae 40c4766a", - "4152150c 40011528 3e4831f0 -> c152150c c0011528 3e4831f0", - "c0760c98 4052b74c 3a07b3be -> 40760c98 c052b74c 3a07b3be", - "c17d3c4a 3f2b1280 3c876602 -> 417d3c4a bf2b1280 3c876602", - "c0d4af2c bf13bd18 3a21199f -> 40d4af2c 3f13bd18 3a21199f", - "c0ce5c96 c055cb1d 3d4b109b -> 40ce5c96 4055cb1d 3d4b109b", - "40b2d260 40747c08 40a1f3e9 -> c0b2d260 c0747c08 40a1f3e9", - "c0bd2c44 3fd21040 3f86bc07 -> 40bd2c44 bfd21040 3f86bc07", - "c19d1b45 408f1480 3bf48100 -> 419d1b45 c08f1480 3bf48100", - "bfafa460 3f2b2a70 3cbd8640 -> 3fafa460 bf2b2a70 3cbd8640", - "c0bd6db0 bf039dc0 3baf102b -> 40bd6db0 3f039dc0 3baf102b", - "40308058 c0000d36 3b9f9b7c -> c0308058 40000d36 3b9f9b7c", - "c0bd3cb4 40002ee8 3cb7dd1f -> 40bd3cb4 c0002ee8 3cb7dd1f", - "41353bca 4059343c 399d9fce -> c1353bca c059343c 399d9fce", - "c11aceae 405ced38 3f54f414 -> 411aceae c05ced38 3f54f414", - "c0a4bcac bef615e0 3e8056d5 -> 40a4bcac 3ef615e0 3e8056d5", - "4182cb38 bf931a3c 3c9fceab -> c182cb38 3f931a3c 3c9fceab", - "40f245a0 4054f56c 3dadd37d -> c0f245a0 c054f56c 3dadd37d", - "3de87e00 be27bb00 3cf157c5 -> bde87e00 3e27bb00 3cf157c5", - "c15df840 404c4b94 3f17baeb -> 415df840 c04c4b94 3f17baeb", - "c10a7494 408c38b4 3b0665ac -> 410a7494 c08c38b4 3b0665ac", - "40d98aa0 40217a8e 39cc87d7 -> c0d98aa0 c0217a8e 39cc87d7", - "c1809bfe 40298852 3a07048f -> 41809bfe c0298852 3a07048f", - "414cec08 409bb808 3cae75e9 -> c14cec08 c09bb808 3cae75e9", - "c189f923 40642d68 392b49e8 -> 4189f923 c0642d68 392b49e8", - "415cf3a4 c081e3ba 3f9f2401 -> c15cf3a4 4081e3ba 3f9f2401", - "c199752a 3fb04f9c 3cf5184a -> 4199752a bfb04f9c 3cf5184a", - "40f94778 3f11d420 3a548d8e -> c0f94778 bf11d420 3a548d8e", - "c19b4276 3fd04cb0 3df5c4e7 -> 419b4276 bfd04cb0 3df5c4e7", - "41264450 c08ad872 3f9a6bce -> c1264450 408ad872 3f9a6bce", - "415bf32c c040a61b 4022c343 -> c15bf32c 4040a61b 4022c343", - "410a04e4 bb9f4000 404d2cf2 -> c10a04e4 3b9f4000 404d2cf2", - "4155442c 3f61b010 3998c251 -> c155442c bf61b010 3998c251", - "40d42fec c011265a 3e8b7831 -> c0d42fec 4011265a 3e8b7831", - "3fbfbb60 c083aacc 3c20f371 -> bfbfbb60 4083aacc 3c20f371", - "419d8fc2 3f9a2a2c 40f35cea -> c19d8fc2 bf9a2a2c 40f35cea", - "3fdcd500 3fc9baac 3c1139e1 -> bfdcd500 bfc9baac 3c1139e1", - "40dfea98 c06b0ded 3a53c74c -> c0dfea98 406b0ded 3a53c74c", - "c119ff97 3f639ec8 3c03fedd -> 4119ff97 bf639ec8 3c03fedd", - "c1863586 3fc69470 39930bb8 -> 41863586 bfc69470 39930bb8", - "3dc47600 bfcef89a 3e9fa9ab -> bdc47600 3fcef89a 3e9fa9ab", - "c0dea116 40987c6c 3f5e0854 -> 40dea116 c0987c6c 3f5e0854", - "40588aa8 bfbbee54 3bc7c364 -> c0588aa8 3fbbee54 3bc7c364", - "c1657b07 c09c2844 3d0ab028 -> 41657b07 409c2844 3d0ab028", - "4110a83a bfba0494 3bd9d851 -> c110a83a 3fba0494 3bd9d851", - "414536d0 c05b53b2 3cb4194b -> c14536d0 405b53b2 3cb4194b", - "413554e8 c098d237 392aa221 -> c13554e8 4098d237 392aa221", - "40b2b63c c035564f 3c34b2ca -> c0b2b63c 4035564f 3c34b2ca", - "c03b7528 c0540222 3960d9a6 -> 403b7528 40540222 3960d9a6", - "40ff7f18 bedfdc30 4064a773 -> c0ff7f18 3edfdc30 4064a773", - "3f4c6760 4021af38 4093fe72 -> bf4c6760 c021af38 4093fe72", - "c19ef0c6 c05770f5 40973bc8 -> 419ef0c6 405770f5 40973bc8", - "419c3ddc c038b809 39be6763 -> c19c3ddc 4038b809 39be6763", - "408dd94c bf6c0c98 3b0e2a1f -> c08dd94c 3f6c0c98 3b0e2a1f", - "40989600 bf7ba960 3e2d1611 -> c0989600 3f7ba960 3e2d1611", - "41757f3c 408fa68a 3f46d7bd -> c1757f3c c08fa68a 3f46d7bd", - "414ad5a4 bef9b330 3c6bc43c -> c14ad5a4 3ef9b330 3c6bc43c", - "418418e0 c001bff5 3e1538dc -> c18418e0 4001bff5 3e1538dc", - "c190de85 40682dcc 39d4b575 -> 4190de85 c0682dcc 39d4b575", - "c106388d 407f8cc0 3f8bff54 -> 4106388d c07f8cc0 3f8bff54", - "410dae5a 40766320 40434b1b -> c10dae5a c0766320 40434b1b", - "c0092ea0 3f9b7d08 3b01d381 -> 40092ea0 bf9b7d08 3b01d381", - "403aab00 400e89c6 3a6d2917 -> c03aab00 c00e89c6 3a6d2917", - "c0341f30 404cbb14 40abb3a6 -> 40341f30 c04cbb14 40abb3a6", - "c0b7cdde c05197bf 3df26676 -> 40b7cdde 405197bf 3df26676", - "41300500 c09977f1 3f9811a6 -> c1300500 409977f1 3f9811a6", - "412843e4 3edd1bd0 3aa4af7c -> c12843e4 bedd1bd0 3aa4af7c", - "c1078c8a 4074e9e8 38de42ee -> 41078c8a c074e9e8 38de42ee", - "bf572b40 3f892968 3c9af5d5 -> 3f572b40 bf892968 3c9af5d5", - "c0ff99be 4091edbe 3b50a9fc -> 40ff99be c091edbe 3b50a9fc", - "41487bf0 3ffd6888 3b6e2aa8 -> c1487bf0 bffd6888 3b6e2aa8", - "c0fa92e0 40793e4c 3d286ec9 -> 40fa92e0 c0793e4c 3d286ec9", - "c0a5f032 c0516959 3f4bdcb4 -> 40a5f032 40516959 3f4bdcb4", - "c091a4bc bff25706 3ab133d9 -> 4091a4bc 3ff25706 3ab133d9", - "405e16c0 bf904522 3e12e3e7 -> c05e16c0 3f904522 3e12e3e7", - "bf128f40 3f1062c0 39dc7772 -> 3f128f40 bf1062c0 39dc7772", - "c19a3807 c011c20a 3fd07989 -> 419a3807 4011c20a 3fd07989", - "c0f77410 3e8c1c80 3bc5b323 -> 40f77410 be8c1c80 3bc5b323", - "406128c8 bf2b1478 38d7592b -> c06128c8 3f2b1478 38d7592b", - "417ac978 40959388 38f74bf8 -> c17ac978 c0959388 38f74bf8", - "41429110 c0118863 3f2e7486 -> c1429110 40118863 3f2e7486", - "417a0d6c 3f94f880 39d5612b -> c17a0d6c bf94f880 39d5612b", - "40ab5240 c08f4ec0 3b2a89e3 -> c0ab5240 408f4ec0 3b2a89e3", - "c1829d82 bf740b98 3fdd7551 -> 41829d82 3f740b98 3fdd7551", - "c194e18c bf9dd37c 3abe9466 -> 4194e18c 3f9dd37c 3abe9466", - "419df6c0 4000edc6 3cf5a8d0 -> c19df6c0 c000edc6 3cf5a8d0", - "c0a1a748 409ddb20 393c1922 -> 40a1a748 c09ddb20 393c1922", - "c0d8d13a c00b5cd0 3e8651dc -> 40d8d13a 400b5cd0 3e8651dc", - "bfd5e390 3d86bf40 3a3ae422 -> 3fd5e390 bd86bf40 3a3ae422", - "4191e8fa 400a6c5e 3c9c9534 -> c191e8fa c00a6c5e 3c9c9534", - "3f520880 be5c1920 3a8b6dd1 -> bf520880 3e5c1920 3a8b6dd1", - "412a2d52 3f527250 392287bf -> c12a2d52 bf527250 392287bf", - "bfcf57f0 3ffaf088 3f372230 -> 3fcf57f0 bffaf088 3f372230", - "3ec0f680 40612dec 3d080075 -> bec0f680 c0612dec 3d080075", - "415aadd8 4088657c 400b58c4 -> c15aadd8 c088657c 400b58c4", - "419e521c c011f6f0 3a148d10 -> c19e521c 4011f6f0 3a148d10", - "c170e5b8 3f7172c8 3ee9471d -> 4170e5b8 bf7172c8 3ee9471d", - "3e8d9740 3e39d1e0 40ed9054 -> be8d9740 be39d1e0 40ed9054", - "419456e6 be8832a0 410f30e2 -> c19456e6 3e8832a0 410f30e2", - "c185779f bf2cd888 39b99adc -> 4185779f 3f2cd888 39b99adc", - "41906b0e 3fe3ae58 3b9c9db7 -> c1906b0e bfe3ae58 3b9c9db7", - "41512688 3f3691d0 4088c358 -> c1512688 bf3691d0 4088c358", - "40b613bc c013f06b 3f7045b1 -> c0b613bc 4013f06b 3f7045b1", - "c1438de3 3eaec3f0 38df2dd8 -> 41438de3 beaec3f0 38df2dd8", - "410fab4e 406924a8 3a059b16 -> c10fab4e c06924a8 3a059b16", - "3fee2eb0 bde2ce80 3bc57694 -> bfee2eb0 3de2ce80 3bc57694", - "414a5cac bebb0550 3ac352f8 -> c14a5cac 3ebb0550 3ac352f8", - "c1999e4c 4054b7ac 39d5832f -> 41999e4c c054b7ac 39d5832f", - "410fb64e c09ba619 40cabe72 -> c10fb64e 409ba619 40cabe72", - "c12c0135 40417f88 39b77c79 -> 412c0135 c0417f88 39b77c79", - "c190bbc6 bf9df77e 3b083d3e -> 4190bbc6 3f9df77e 3b083d3e", - "40ce35d0 3f14c660 3a424194 -> c0ce35d0 bf14c660 3a424194", - "c1543ff3 c09b3c58 3bc30338 -> 41543ff3 409b3c58 3bc30338", - "418d4118 bfbccb4a 38d94c4d -> c18d4118 3fbccb4a 38d94c4d", - "c0b818c2 40895416 3951a833 -> 40b818c2 c0895416 3951a833", - "4110d79c 4034c16c 3e3e5efd -> c110d79c c034c16c 3e3e5efd", - "4154e87c bf546028 4105cf3e -> c154e87c 3f546028 4105cf3e", - "40abf864 c0154be8 40dff963 -> c0abf864 40154be8 40dff963", - "41701958 408a095a 3fd823aa -> c1701958 c08a095a 3fd823aa", - "c137198b c07e8fc5 3d7bbdb2 -> 4137198b 407e8fc5 3d7bbdb2", - "41950eae bf63d3b8 3cb02956 -> c1950eae 3f63d3b8 3cb02956", - "40edad98 c0621656 3a20cafa -> c0edad98 40621656 3a20cafa", - "411ac71e c08bb7cc 3b5e80ab -> c11ac71e 408bb7cc 3b5e80ab", - "419598ca bf9bf470 3cc01f08 -> c19598ca 3f9bf470 3cc01f08", - "c19fa724 406fda78 39bc1be6 -> 419fa724 c06fda78 39bc1be6", - "c12bcc8f 3fd19f94 40520744 -> 412bcc8f bfd19f94 40520744", - "c18c3a44 409f6f58 3abba5e9 -> 418c3a44 c09f6f58 3abba5e9", - "c0f7ae4c bf81d362 3c0a54cc -> 40f7ae4c 3f81d362 3c0a54cc", - "c1706d3d bf5dcf00 39b9bbde -> 41706d3d 3f5dcf00 39b9bbde", - "c1037c23 4037018a 3e0b5558 -> 41037c23 c037018a 3e0b5558", - "c0db917e 40916ccc 406a173c -> 40db917e c0916ccc 406a173c", - "413e35dc 4098326a 40a32c38 -> c13e35dc c098326a 40a32c38", - "3fbb4b70 3fda39a4 3f511369 -> bfbb4b70 bfda39a4 3f511369", - "4180d7fc 409b0840 3ec99c9a -> c180d7fc c09b0840 3ec99c9a", - "c0c2f534 4069b6e8 39240f54 -> 40c2f534 c069b6e8 39240f54", - "3ed5bc80 3faa94f0 3c1557ea -> bed5bc80 bfaa94f0 3c1557ea", - "4165258c 3fb7cbd8 3b0eb630 -> c165258c bfb7cbd8 3b0eb630", - "418d8800 c05ea503 39ada273 -> c18d8800 405ea503 39ada273", - "c0de0376 3fcbe908 38f1fbf6 -> 40de0376 bfcbe908 38f1fbf6", - "c18603c2 3f1d1020 3eedc8ca -> 418603c2 bf1d1020 3eedc8ca", - "c190bdf6 bf06f300 3b1fd3e7 -> 4190bdf6 3f06f300 3b1fd3e7", - "40e5a858 3fb1f4a0 3c57419f -> c0e5a858 bfb1f4a0 3c57419f", - "401d2ca0 c03d8422 40486d79 -> c01d2ca0 403d8422 40486d79", - "c1538a4d 3ff99408 41141678 -> 41538a4d bff99408 41141678", - "c172af00 c05a2480 38f5b5b6 -> 4172af00 405a2480 38f5b5b6", - "3ef82c00 4092d1ba 3d3e4106 -> bef82c00 c092d1ba 3d3e4106", - "c0c4953c 3f91c9bc 3f4b8e6f -> 40c4953c bf91c9bc 3f4b8e6f", - "410b768a bf2286c0 3a06fef1 -> c10b768a 3f2286c0 3a06fef1", - "c0b4480c bf91b17c 3f837ce7 -> 40b4480c 3f91b17c 3f837ce7", - "4145858c be964360 3b7a0d9f -> c145858c 3e964360 3b7a0d9f", - "41894d42 bee47880 39b82ebd -> c1894d42 3ee47880 39b82ebd", - "c1904f74 40632be4 3d46c079 -> 41904f74 c0632be4 3d46c079", - "c0157768 3fd76274 3ab11e7c -> 40157768 bfd76274 3ab11e7c", - "40936bfc 408fb15e 3c65ccd1 -> c0936bfc c08fb15e 3c65ccd1", - "be9380c0 3ff15fb4 40b11687 -> 3e9380c0 bff15fb4 40b11687", - "c110700c 404dbf00 41138d90 -> 4110700c c04dbf00 41138d90", - "c1831e55 40493ce8 3ea2d561 -> 41831e55 c0493ce8 3ea2d561", - "bf56aa20 4016431a 40aec135 -> 3f56aa20 c016431a 40aec135", - "41910dd2 bfd9e4ec 38ed67e1 -> c1910dd2 3fd9e4ec 38ed67e1", - "c1698cc3 bfe60f9c 3af0dbee -> 41698cc3 3fe60f9c 3af0dbee", - "409b5b2c 4021c59c 3eed5d61 -> c09b5b2c c021c59c 3eed5d61", - "40541550 c02624d2 3acecb9f -> c0541550 402624d2 3acecb9f", - "4175da2c c089080c 3b59809f -> c175da2c 4089080c 3b59809f", - "bf6ff0e0 c0897064 3b39dbfd -> 3f6ff0e0 40897064 3b39dbfd", - "c0f6ba64 4013ff64 3e581088 -> 40f6ba64 c013ff64 3e581088", - "c0bf19ac c02fed6f 3f0c95c5 -> 40bf19ac 402fed6f 3f0c95c5", - "c1440046 c084d9fe 3d886735 -> 41440046 4084d9fe 3d886735", - "4145ff20 400bc234 3e439bc3 -> c145ff20 c00bc234 3e439bc3", - "40943e80 beffd6c0 3ecd39b9 -> c0943e80 3effd6c0 3ecd39b9", - "c1588660 c0815d46 3d2d1878 -> 41588660 40815d46 3d2d1878", - "3f874290 bff7a22e 3bb41522 -> bf874290 3ff7a22e 3bb41522", - "419774c6 409e0434 3a7b211e -> c19774c6 c09e0434 3a7b211e", - "40fb14a4 40832f52 3c8ea506 -> c0fb14a4 c0832f52 3c8ea506", - "4105c2d2 bf8c946e 3f0f772b -> c105c2d2 3f8c946e 3f0f772b", - "40f19fc4 3f9184cc 3f063e8c -> c0f19fc4 bf9184cc 3f063e8c", - "c06684a0 c0520d70 38da6f3d -> 406684a0 40520d70 38da6f3d", - "c10b22f7 3f8350f4 39aeed08 -> 410b22f7 bf8350f4 39aeed08", - "c117c988 408d39c2 3ac5141e -> 4117c988 c08d39c2 3ac5141e", - "40f0d594 4047ae78 391bcdd9 -> c0f0d594 c047ae78 391bcdd9", - "c1875b32 4095730a 3f65218c -> 41875b32 c095730a 3f65218c", - "3f42b3e0 400e608c 40f2db8f -> bf42b3e0 c00e608c 40f2db8f", - "41329144 40900c50 3f2912a2 -> c1329144 c0900c50 3f2912a2", - "418d9c98 bfd48d7c 3ef92b62 -> c18d9c98 3fd48d7c 3ef92b62", - "bfa0d7f0 3fc5d1b0 3b76c3ca -> 3fa0d7f0 bfc5d1b0 3b76c3ca", - "c1002637 be1c3180 3e984442 -> 41002637 3e1c3180 3e984442", - "41499930 c072d0c4 39aefc40 -> c1499930 4072d0c4 39aefc40", - "4183ee7e c03c3f97 3b215064 -> c183ee7e 403c3f97 3b215064", - "410aea1e 40729c98 3cef6591 -> c10aea1e c0729c98 3cef6591" - ] - }, - { - "glsl": "vec3 cultmath_af_scale(vec3, float)", - "tolerance": "ulp-bounded", - "cases": [ - "c04b7280 c0174e26 3bdb8610 c0465c1e -> 411da3c4 40ea79c6 3caa3b15", - "c109813e c04ba610 3a29032c 3f740248 -> c1031069 c0421c18 3a23e6ef", - "418dbc48 3fc9fd4c 3a699a57 3fabbb98 -> 41be2942 40078036 3a9ff1b6", - "412f24a4 40831f50 3e54cdf3 4075bde8 -> 42281ffe 417bbc79 3f4c4a9f", - "bfa6d2d0 40583950 3b0c439a 4020c66c -> c0518a1f 4107cb6a 3bb08c11", - "418f5fd0 4039470e 40d128f4 beb1d5b8 -> c0c731e1 bf80b4ce 40114c14", - "3fd0af80 406ed19c 3e92a609 405c02e0 -> 40b3592a 414d3ed1 3f7c11e2", - "c1569360 402725ac 3d14f0a7 401a9a7e -> c2019626 40c9e311 3db3f8b3", - "415bc3f4 be2f2880 3bcb2c4b 3fbf0ad8 -> 41a40082 be82b6a3 3c17f1b6", - "c081962e 40532c58 3937e56c 3ee3ed20 -> bfe6c066 3fbc03ec 38aa45e0", - "c0f7696a c094abef 3bee0858 3f915e9c -> c10c7e25 c0a8d8a8 3c0762f5", - "c1035aae c0975f81 3928c3b8 c0140c4e -> 4197ed7a 412f14fa 39d22a12", - "c016a7d0 408a57cc 3efc0dbe bef42b00 -> 3f8fb140 c003f2eb 3e70684a", - "bffb14d0 c08b2db8 3d59b415 3f862d50 -> c0039956 c091e522 3d643c43", - "c0ff55b0 4082c264 3d940e76 bf343c54 -> 40b3c46c c0381efe 3d5082aa", - "bec4a980 c02b69e2 3c9947dd c022f0e2 -> 3f7a589f 40da3497 3d432741", - "c162c4c9 bf8f5310 3fa95e3b bfd64152 -> 41bdca5d 3fefe803 400dc06b", - "400342f0 4098a180 3da4f2fc 3f8cc214 -> 4010583c 40a7d811 3db567a9", - "4138fed0 4006afae 3d0ce3ec 40534600 -> 4218ac9b 40de4f41 3de8a361", - "c053d138 bfe4fce6 3a28e98d 3de21840 -> bebb12c4 be4a3cf4 38964e6a", - "41545d14 be471620 3ce3157d c0090262 -> c1e34f93 3ed51963 3d732e1e", - "c198ba8d c0890aec 3bba6676 400e7f82 -> c22a0719 c11890a2 3c505392", - "418c180e 4011918e 3c0b85d4 bda196a0 -> bfb0db1d be37c461 3a308679", - "c11aca90 3faf1ab4 395e403c c059d575 -> 4203b6c5 c094ffa4 3a46833b", - "404f5028 c046178a 3cf837c0 40503f16 -> 4128a437 c12123f1 3dc9f4d2", - "c13e504d 40205d5c 3e4b4e18 be92b940 -> 405a2707 bf37d294 3d690f7f", - "c0be91bc c07f5e8a 3e38e9b1 3ff64924 -> c137567d c0f5adce 3eb1e7d4", - "4013df50 3fa98bb0 3a999848 40757616 -> 410dc8ed 40a290e4 3b93b528", - "411df382 c08d6f06 3da30245 c07af655 -> c21ad7c9 418aa684 3e9fd41d", - "411be890 c031e8ee 3a239224 c05a258e -> c204daea 41179a74 3b0e0d81", - "c19426a1 c091470c 3bbeaf11 4025cc22 -> c23fe610 c13c2d45 3c77ecc7", - "4068c580 c082dbd2 3c0120ea c0320ba2 -> c121e3e7 41360595 3cb3c88a", - "40b9daa8 bf2c21c8 3b953249 c00be3d0 -> c14b1e3a 3fbc1f0b 3c2346d8", - "414fe1a0 c01cbd91 3b6bab82 c05666a0 -> c22e19f2 4103454d 3c462ed0", - "414d6eb8 c09832c0 40232889 4057edf4 -> 422d46f0 c1806017 41099ef7", - "c04bc148 3f8d6c08 3aa610c8 bfc755fa -> 409ea7ad bfdc3cf2 3b01b9b5", - "3f0c0f00 bf6f07f0 3f0554e9 c0198a04 -> bfa800f3 400f5c9c 3f9fef68", - "c18de15c c08e44de 3b93f4ac bf906b3e -> 41a01467 40a084ac 3ba7b778", - "c195efc5 bf46c490 400ec9ed c02fce90 -> 424defc6 400880c0 40c41ef7", - "c0831366 4056e0b8 4014beb9 bff5b528 -> 40fb9ca4 c0ce3d1f 408ec3ef", - "410ddd98 bc16fe00 399d16a1 c03fffc7 -> c1d4cc25 3ce27cbd 3a7249e1", - "c0fefb3a 409bd6b2 3a1b6f6b bd87e4a0 -> 3f075a33 bea572c9 38286d7d", - "411dfcb4 bc2fa400 3a6690e6 3fe07ce8 -> 418a8a33 bc9a0533 3acc5a17", - "c0cbdda0 c0282171 3e3da2bc bf1670dc -> 406f9b78 3fc59b6f 3ddee49c", - "41504a5c c090c19a 3b68eb97 c021a3b6 -> c20383f7 4136cca8 3c13c25e", - "c0c2e880 c04d4f9c 399da94a 3f37e368 -> c08c0157 c0137a4a 39692e24", - "c17ed510 4097433e 3a786b98 bf47c3f0 -> 4146daab c06c1216 3a45e14f", - "c092b35c c05d188c 3e86214e 4078719a -> c18e5edb c15691e4 3f822ccb", - "c15f472f 3f9b2e38 3a832e5f 4057b88a -> c23c25bc 4082c3ae 3b60470b", - "3f1b5a00 c0816c5d 38dcf80a 3e5a93c0 -> 3e04a44d bf5d01f3 37c49c25", - "c11eb3f7 c01ef476 3c974152 3eec52b0 -> c092812a bf92bcb4 3c0bb802", - "416a98e8 3f8efd18 39015aa2 40169b20 -> 420a03c0 40283de2 39aac3f7", - "412c0d7c bf118278 3b945c28 bf99a400 -> c14e848f 3f2ea863 3bb28101", - "3f8313e0 3ff1dca4 40693c76 3eadee20 -> 3eb21cb6 3f245314 3f9e76e1", - "c0772cb0 3d625480 3908ed09 bfb0068e -> 40a9f50d bd9b9fe4 3941b017", - "413aaa9c 40215f36 39b24c72 3f3d10c8 -> 4109dc32 3fee5bbe 3988eb66", - "4149c6f0 c03db0a5 3d8dd901 3fe0c350 -> 41b12804 c0a68b49 3df921ef", - "c19416a5 40149ab4 4066b1c5 3feb6b50 -> c2082edd 4088a84e 40d4263e", - "c192358a 40356ab2 4092b9c2 c04ecca2 -> 426c37e8 c1128cdf 416d0dd9", - "4110999c 3ec23a20 3ed38e3f bda1f620 -> bf36f742 bcf5c295 3d05d8a2", - "41916d5a bf7cfc88 3e16cf56 40626bf4 -> 42809fdd c05fc19f 3f0566e7", - "414ef404 bfd4e02a 3ca2c6ed be9af010 -> c07a81b8 3f00d679 3bc52c01", - "4105b414 3fc9bd48 3d1f231f c07b0fc2 -> c2031fca c0c5d901 3e1c1b02", - "c188d708 3fe1d7f4 3ef24be8 ba756000 -> 3c83291b bad8785d 39e83fd2", - "c162ff36 40670188 3f03ed8b 3fa6dc14 -> c193f4a2 40969196 3f2bfc63", - "c1920b59 c000ce4a 3f1be9d3 c06d3dc6 -> 428757bf 40eebc1f 40107e4e", - "3fa2c240 3f81a0c0 3b6048d7 3ff7f2dc -> 401da3d3 3ffb1a25 3bd95e81", - "41244700 404a62d0 3f9ad306 403b2474 -> 41f02e83 4113f300 40625d0d", - "4134ab2a 3ea947a0 3bf1e884 bf604734 -> c11e4805 be944dc1 3bd4403e", - "c1742612 c056fc30 3f330ff4 be16d960 -> 400fdd9e 3efd5ca1 3dd30835", - "411c23d6 c07c353e 38ece3e6 bf768c94 -> c116602e 4072e5a9 38fe8856", - "c136d725 40808d66 3e46941e bf888b48 -> 41430b8c c089221e 3e53d9a0", - "c1907f1e bf2d1608 40b59155 403ae012 -> c252f5aa bffcb303 41848aa8", - "413d2144 c08cb5b2 3c8bedae 3f9f74c8 -> 416b9be0 c0af4a14 3cae795b", - "40b8a358 3f784a00 3c38c46b c00e49e2 -> c14d3fc9 c00a00b4 3ccd8292", - "c1976a55 400b33bc 3eac7901 40490dce -> c26dd54e 40daa641 3f87766a", - "415a4b0c 3fc30890 3ab39510 3ea10640 -> 40894e87 3ef55a4b 39e44ce2", - "c0fc6a74 bfc701a2 3c043463 407663fa -> c1f2f0df c0bf894a 3cfec4b6", - "c1828fda c0191106 407bd08f 40601870 -> c26494ab c105fd82 415c6ed6", - "c1079448 bf9d09c0 3fa5843b 3f852f28 -> c10d1206 bfa365fc 3fac38bc", - "418dff9e 408cddd0 3e968fe2 bfb3ec00 -> c1c79946 c0c601ea 3ed3a6c1", - "4169e368 40907dc2 396abd17 3fe35748 -> 41cfb463 410050c6 39e1738d", - "c1844d10 400b7838 3f09dc91 3e305f20 -> c0364c48 3ec02cf3 3dbdf765", - "41225526 3eefecb0 3c99e16a c072731e -> c219bd7d bfe339a2 3d91d06c", - "c07ee2f0 c0748b44 3d49d85d 3efdb6e0 -> bffc9c5c bff25c53 3cc812cc", - "40df3350 c07457d6 395ab73b 3fd0d0ec -> 41360fd8 c0c74ec6 39bb3523", - "c18fac34 4096413a 3f3b98a0 3e8e0eb0 -> c09f7386 3fa6c19a 3e503477", - "c165911a 3db49140 3be18eb3 bfeea8ba -> 41d60434 be28560c 3c52b30c", - "412fc890 40337130 3b218428 c053a6a3 -> c21154bb c1145b18 3c063f84", - "c1986126 bf981204 390f78a8 404772d4 -> c26d6fbc c06cf46e 39ff1638", - "4052dff0 3d5aa600 3c965e4d 3f2dd500 -> 400f30ca 3d14781a 3c4c3ed2", - "407b9c70 40664b78 3ab41230 3eb8de10 -> 3fb5b2b2 3fa64e02 3a02b74e", - "4143e34c 407b359c 3d46e453 c028d403 -> c2012f64 c125ab3a 3e033540", - "4158d21c c0195aa6 40c02050 4026ac0e -> 420d29f7 c0c7afb2 417a2c61", - "4170dd74 409cb9ba 3b18596f 404ab3f6 -> 423eb810 41783172 3bf33ced", - "c14dbc48 3eb4d010 3da403e0 3f1f3778 -> c0ffe909 3e60e8cf 3d4c0c28", - "c0bf8a1a be53e780 3f0adc72 40724ffa -> c1b54c63 bf48930a 4003702b", - "c11426d4 bfa8c80e 38d83727 c076262d -> 420e7368 40a24969 39e43cde", - "c182fc90 3fbeb2fc 40fced52 c02973f2 -> 422d681d c07c750e 41a76b5b", - "40d3ca20 be574620 39b0e8f1 c01e1cb2 -> c182ce7d 3f04f569 3a5ebef1", - "411adaa0 c02e2ae9 3ee1105c c0009ef8 -> c19b9af2 40af0337 3f62297d", - "4196e6a2 c041b9b8 3c628f02 3de9ebc0 -> 4009e2e0 beb1046f 3acf54db", - "414fcd60 bef19530 3a9384e1 c06e9164 -> c241a6f4 3fe121e6 3b8b0aba", - "c17aedea c06bf316 3eb7c9d1 c067e804 -> 4263501a 4155be31 3fa67fe9", - "4187e17a 407001c0 3ac30824 c0431524 -> c24f17f1 c136e527 3b9698fb", - "c177b368 c01d3c25 3b1e5655 befe3788 -> 40f5f9bc 3f9c23c8 3a9e590e", - "41798338 3e387000 39831367 c01ed2b6 -> c21acc5c bee4d9de 3a2c6d24", - "c10c473e 403774c0 3a25895c bf522d50 -> 40e6568a c0169e3e 3a0a4b4e", - "4175d7f8 c085bb9d 3a1a438f 4066bee6 -> 425d975c c1711491 3b0f7336", - "41444b00 bfd72348 3ddbe538 c031a2ab -> c2083496 40954819 3e989a16", - "c18fa175 c02b2457 3a11042f 4021a310 -> c235600f c0d81dbb 3abda32b", - "c15af646 4095f410 40668cd2 406b2e5e -> c24927bb 4189c234 4153cd58", - "418c26d6 408a6750 3ada8df0 4014b5d8 -> 4222d403 4120cc14 3b808b64", - "c1238bfe 409bbaf2 3981060a bdca85e0 -> 3f8161fd bef665e7 37d8143e", - "419065c8 c005f854 3bcc34cc bebe3e50 -> c0d69d60 3f471dd5 3b1838ae", - "c174a9d5 c027742b 3ac0ac51 c06c85e6 -> 42620c88 411ab6ad 3bb41521", - "c104a4a6 40484068 3a1345bf c072c55a -> 41fb93cd c13de742 3b0e5e8f", - "4198c34a 40269d32 3ad09309 3f3ddb78 -> 41629649 3ff721c9 3a9cb25c", - "c113f251 c085ee87 3964f13a 4042c0c0 -> c1e11a0c c14bc733 3a386327", - "c17c52be bec81260 3b24bd40 4057af44 -> c254963d bfa89068 3c0ba59d", - "40889198 c07309d9 3aee07dd bf9b562a -> c0a5bc3d 409378c4 3b110b85", - "3fd84500 bfa6e298 3a1872be 404b81a8 -> 40abec40 c084aa34 3af3910b", - "c19ec362 3fd4df20 411ef560 3e035dc0 -> c022f03e 3e5a7844 3fa323ad", - "41975c24 c05e5230 391d82ea 40202768 -> 423d61c6 c10b1597 39e11914", - "419fb89a c0794208 3d28b3bf bf9ebde2 -> c1c614cf 409a8fa3 3d5155c7", - "414bf5d8 4076b4e4 4101fbfc c0250c6c -> c2037f5a c11f0e90 41a79b90", - "40f5f744 3fc22f14 3d26209e c02c8bf4 -> c1a5c899 c082e1ca 3ddffdee", - "418606b6 c0416166 3c050302 bd9e9d00 -> bfa614ad 3e6fa16b 3a2534eb", - "c19c9af6 bf1f9400 3fdb8979 407eb336 -> c29bcf61 c01ec48e 40da6cc3", - "419bb072 40768050 3cf6d3e2 4058a3b8 -> 4283c071 415099e8 3dd10823", - "40ccc520 c01e6fc8 39070a7e bfc174c2 -> c11abe02 406f7511 395982c1", - "4126fa22 400f8fa6 3e0079b0 c044801a -> c2002b10 c0dc63a3 3ec53fd3", - "c1913dc6 c01cc8c4 40231678 407d8c3c -> c28fd99d c11b484c 412186e7", - "418c269c 408b3a24 39aac672 3fe28644 -> 41f8072e 40f664b2 3a20c9ce", - "c1677d39 c08842c4 3e4370f3 4047f410 -> c234cf09 c154db9d 3f18aad3", - "415eb918 409cc664 40fa3db3 401caee8 -> 420850f6 413fe804 419928b3", - "c109f9f4 3dbaa640 3d09e0fd 3e90bb70 -> c01c033e 3cd30c5a 3c1bf0e8", - "c0f89f4e c093e0c2 3fad355d c045a5ad -> 41bff37e 41645752 4085ba7e", - "4092dbf0 3f7f8f50 3e883b83 3f07aba0 -> 401ba8e1 3f076fe8 3e106635", - "4168a4d0 3fdab8b0 3c46a8de 406f8996 -> 4259aee7 40cca7f9 3d3a1f49", - "c195c261 bf722910 39c9581d 3fa7bd18 -> c1c440d8 bf9eaba8 3a0a5e99", - "c0eac23e bf910b8e 3d6ca53f c05954f6 -> 41c74c90 407645dd 3e48edd9", - "c0d31478 c06f9674 3ffcf19c 40531ebc -> c1ae1336 c14595c5 40d099d3", - "c12d6e35 3f86bdd8 3978ffa5 3fae22dc -> c16bf10b 3fb74ec4 39b1768c", - "c110c470 c035ca8f 390e89bc bffe2b4a -> 418fbb62 40b47db7 39995279", - "c133e99a c085007f 3f905bba c07bc806 -> 4230f29d 4182cf68 408dfb3c", - "c0366490 402b0ed2 3c02dbef bfa5bdc4 -> 406c2c09 c05d7eb5 3c298e28", - "c11ff27b 3eb9fcc0 3ff8bf1c be857078 -> 4026be7e bdc1e40b 3f01a8c5", - "40c98840 3ff10510 3ffb1cde beeb1dc8 -> c0391785 bf5d5bb0 3f66a101", - "416ec02c bfed030c 3ce55d4d 404ba30e -> 423dea74 c0bc8860 3db68dce", - "41922a46 bf337230 3a836fbc c023c75c -> c23b057c 3fe59ae6 3b2b35d4", - "c14d9ec2 408474fa 402a32fe c07b272a -> 4249ba1d c181f2f5 4126fa56", - "3f7d0440 c09b3785 3b3dfa25 3f971898 -> 3f9555d0 c0b73952 3b60afed", - "40b896b8 c0566e9a 3f0e3eef 40653030 -> 41a54191 c13ff94d 3ffeb33a", - "407318d8 c07a795c 3ac43cd1 3eca0060 -> 3fbfd1f6 bfc5a421 3a1b9b0c", - "c19e038d c036e8c0 3fab8f56 4018f824 -> c23cd68b c0da96fa 404d07b1", - "c1148591 bf8a9260 3af699bf 3ea6c820 -> c041856e beb48e7c 3a21809a", - "411de914 3fa9a070 3f775434 406afdaa -> 4210f384 409bb4bb 406308bd", - "4110f9ae c06d7ad6 3b43b313 4013f58e -> 41a794dd c1094153 3be3235a", - "4175d77c 3fa6d174 3fb3cf86 3df2e440 -> 3fe940e5 3e1e46bc 3e2a9b07", - "4174afb4 bfa51b74 3f956940 c0079c5a -> c2019e19 402eeca2 401e4c19", - "c123ea7a c0398042 3fa7368c bd75db00 -> 3f1d6ba0 3e322670 3da096af", - "418c9678 40837cce 3fdd83f2 40076138 -> 4214b17a 410b117f 406a4a2e", - "c186786c 408cd5da 40379082 3ff86214 -> c202782d 4108a520 40b21aaf", - "4085b654 bf7c3a98 4068dd6a 4012eebe -> 41197d5d c010c4a4 4105a785", - "40cb8f50 bfc76050 3b06f07a 4048ccd8 -> 419faad8 c09c62c7 3bd47683", - "c13484aa bfd52606 4080ea48 3dfa3840 -> bfb07138 be5055f7 3efc027e", - "416cc100 40933152 3959d5bc 406de462 -> 425c01e4 4188c7f9 3a5c73a0", - "c10d5e16 400cf26a 3e5d72ab 3f8a7100 -> c118e63d 401871c8 3e6f862b", - "c07e0780 3f672ee0 3d73aa55 c0626aa6 -> 4160ac73 c04c77b1 3e57863f", - "402f6ef8 4027ef92 3dd0154a 402bf2c6 -> 40ebaafc 40e19892 3e8bc563", - "41365314 c09591f3 401f431e 4012a4ca -> 41d0e17d c12b5b08 40b675ed", - "c1280dc2 3f064c60 3a5b59f6 be0e17d0 -> 3fba8e87 bd9515b6 38f6902b", - "410b9c5c c09262da 3ff35221 3e9bff20 -> 402a259c bfb2677a 3f144581", - "c17ab3b1 4086cc8a 38ffa031 4052206e -> c24dc729 415d49b9 39f2750a", - "c106f5f1 bff5d648 3e04c8ad 40756ea2 -> c20163b3 c0ebb051 3efe9fe7", - "415e54dc 40751fa8 3cdab8bb bf8fd202 -> c179cf94 c089b5c5 3cf5e920", - "c11134a6 c01bf3b5 3ba7a6f1 c078c071 -> 420d1828 41178953 3ca34148", - "415dd0b4 4062d1ac 3aa216ed 404b1344 -> 422ff530 4133ed55 3b824e4a", - "411b6d84 bf3b2600 39b457b9 c0211a36 -> c1c39f94 3feb8c1f 3a698e16", - "bfea0780 c069d84d 3b209b0f bfbae9c2 -> 402adf25 40aabcaf 3b6b06c4", - "41304ade 3f4efa68 3adfdacb c006e04e -> c1b9c34f bfda18d9 3b6d702c", - "41693d28 c06d7f85 3d309599 be27bf60 -> c018d541 3f1b9fbb 3be78337", - "403b2a08 3fb8f038 3f3273ab bff52830 -> c0b33c9b c0311aee 3faae504", - "c1668227 3f9c3014 410c1151 404dc2be -> c2394593 407b12a1 41e128fd", - "3ff223e0 3e491300 3d16f465 40765190 -> 40e8fb9f 3f417852 3e1140fc", - "c1392c12 c052f7ac 3e1b1c55 403a3bc0 -> c206b53d c1197930 3ee1b30a", - "414f6b9c 4092ee96 3f72517b 3fb9bc80 -> 41967d7e 40d53536 3fafd026", - "4148ec1c 405461fc 3c9c4c36 c030e482 -> c20ad5ac c112c0f0 3d582bc0", - "c1965f8c bff9785e 3a89187a bfef0f92 -> 420c6c59 4068f68c 3b027228", - "40aebd10 c020d001 3cf4e2bf c0362a80 -> c178aed8 40e4dd26 3dae4d3f", - "4112d1fa 4067da20 3c83683b c01885ee -> c1aef2f8 c10a22cf 3d1cb3cf", - "c1848f7a 409283e6 3f1baf14 c0422207 -> 42490cb2 c15e36dc 3fec20cd", - "c01d9068 c03c8674 3e1eb280 405e8b1a -> c108f8d8 c123e309 3f09f63b", - "409b4a24 c00211fd 39b34b3e 3f573b58 -> 40828f44 bfdab685 3999a2be", - "418e5494 bf961320 3c3d257b 404f7ffa -> 4266bb15 c07348fa 3d198d62", - "c0d4e3c2 405d2484 3e59e04a 3ff70da0 -> c14d7315 40d56a00 3ed2457d", - "c147715e 3f921c88 3aba3964 402b61a0 -> c20584c8 4043a18e 3b7b9dbf", - "c0519d80 400e0454 3b0b1680 bfce459c -> 40a8e5bc c064dc33 3b60b192", - "c1982735 bfa7907c 3aeda598 bf9b3d1c -> 41b8881e 3fcb38f6 3b11a67d", - "4112c360 bf290c98 3f46b16a 403b830c -> 41d6ffb0 bff7a579 401189cb", - "c13e7d10 3fdf39c8 3ad6ddb3 3f5e3b60 -> c1255ca2 3fc1c7e1 3abc014e", - "c143f8c4 3e5bb9c0 3d3dcc73 3feeeb08 -> c1b6e532 3ecd106b 3db12e01", - "c1411628 3f7cf380 3b851f1f bffc2640 -> 41be2ea9 bff9257d 3c03856f", - "415733fc 3f65fe78 3f907e11 40448ac6 -> 42253875 40309381 405dde6f", - "c1421ed1 3fffb8dc 38f5a2ff be68a940 -> 40306c44 bee86898 37f8ed56", - "411181d4 4087101a 3ea70cb4 3fddbf50 -> 417c13a3 40e9fbab 3f10b448", - "418cd254 bfcd737c 40636e14 bffdb782 -> c20b90cf 404b9e67 40e1672b", - "c19192fc 4025602a 40192157 3db13b40 -> bfc990a3 3e64fb87 3e54077c", - "40861998 3eecc1a0 3ea76d90 3fa31b94 -> 40aae17c 3f16d8ca 3ed55a63", - "40835530 c08dbccf 3d5fb82e 3faaeb3c -> 40af5e80 c0bd433e 3d95639d", - "c1861784 bce67600 3e1bc099 40237c98 -> c22b4478 bd932d4c 3ec6f447", - "c07fa318 c09c4999 3ca7da58 bf05c680 -> 400595f3 402356d7 3c2f7fc7", - "4015ec08 bfa932fc 3a1659a5 c070e0d7 -> c10d10f4 409f3467 3b0e54cb", - "c04c3470 bff7d246 3a01b2ee bfe0fba0 -> 40b37699 4059cb93 3a6638de", - "4196f006 3e8712c0 3e612cf0 4035672e -> 4255e914 3f3f6d65 3f1f92f5", - "408e7ea0 c00c3003 3e8d6724 bef62870 -> c0090430 3f86cc48 3e07f848", - "410ebdb6 404700cc 3e34001e bfd706be -> c16fca2c c0a726e9 3e973367", - "4177a298 c05f347c 3b2709f7 c038842a -> c2327cb6 4120e0f5 3bf28045", - "c15e84db bfc41222 3c131881 c00a2768 -> 41f02bbd 40539fe9 3c9f0666", - "c1092ffa 40756118 3b7a55c6 405b5fe2 -> c1eb1eda 415245f7 3c572f51", - "417165c0 be7b5ae0 3e9685d0 3fb585a4 -> 41ab2af5 beb23a78 3ed57925", - "40888f14 405d9838 3994c343 bfce7682 -> c0dc44b3 c0b2b712 39f62ff9", - "c06d2720 bf4616d0 3e8c6064 c058f966 -> 4149000d 4027e43b 3f6df52e", - "c08e8f0a 3ff740a0 3946dbdf 40199a62 -> c12b12eb 40945abb 39f64cba", - "4145ba38 c042397f 399ed699 3f36ae28 -> 410d18e7 c00a9902 396dad40", - "c0afdcfc c051bb47 3d6071fb bf3dce70 -> 408263f7 401b8064 3d266fb0", - "c1844e2e c09c2116 401bb2a7 c05a69a3 -> 4261c257 4185349a 4104d6b3", - "41850a88 4082c99e 41166f3c c052cda4 -> c25b1b04 c15764e6 41f7c05f", - "c1399e00 4019960e 40f5e4b1 c03a6f33 -> 42072d6c c0dfb37a 41b31318", - "405f76c0 c09c7d55 3fbba006 4040eacc -> 41286605 c16bdb0e 408d6455", - "410d0760 bfbf3548 4025be41 be923160 -> c02112d0 3eda6288 3f3d4d2c", - "bfba2d60 c03cc562 3f119c63 bea75440 -> 3ef361be 3f76c5c6 3e3e5a49", - "c1059cc5 3f680350 3c512d72 c0525ec9 -> 41db9824 c03ea89f 3d2c0332", - "4137c30e 401169ec 3d8a3cbd 3fd1ce70 -> 41969a6e 406e5979 3de2a174", - "4188dd78 c008bd31 3db80d31 3f41b8b0 -> 414f2369 bfcef290 3d8b4e0b", - "41961634 c09a8144 3c0621ce bc30d000 -> be4f526c 3d556cd0 38b9cad4", - "c03861a0 3f7e48f0 400938f7 3f983714 -> c05b4345 3f973204 40232ece", - "410a4514 40864f5a 3a97bc47 401890b4 -> 41a4ce58 41201611 3b36c4dc", - "c0aef744 c0338776 400d616b c079dcb0 -> 41aac556 412f3986 4109fdcb", - "c106a0d7 c0854c73 40a75403 40435406 -> c1cd7167 c14b69f8 417f580a", - "c118e47e bf51bc20 3f508580 bfb312d4 -> 4155e606 3f92b5f7 3f91dd2c", - "bf0014a0 4081c498 3b51ff55 be0d3230 -> 3d8d48f0 bf0f2571 39e7f610", - "c150904b c011c5cb 3a8ffe76 bfcbd4fe -> 41a60ff2 40682241 3ae85989", - "c04c2a30 c0274796 405d535d 3fd00fd8 -> c0a5eeea c087f484 40b3e18c", - "4195c23e bf947ad8 391f511e 403a867a -> 425a3b98 c0585e80 3a0290bf", - "c0ce5746 c07e801b 3f04f7df bf83925c -> 40d41941 4082cd0e 3f08ae6d", - "c09c44f0 3f9dbf48 3ed9f02d 3f0a8810 -> c0292070 3f2ab9e9 3e6bdf7e", - "41655ae0 3f09e8d0 3c4346a6 40304312 -> 421dea91 3fbde861 3d069cba", - "c0c964b4 4005e6dc 3b985c98 3ed0afa0 -> c0242bfc 3f5a4edf 3af8d4f3", - "c1299b43 c08d99ae 38ee76f8 3e37eb80 -> bff3b406 bf4b763d 37c0e967", - "c10129a6 bf9523a6 3cc135f3 bee620d8 -> 406837fb 3f061129 3c2dbfe9", - "410764a4 4083c434 3bfd92dc c04029a4 -> c1cb4302 c145d12c 3cbea2fb", - "c0f1011a c055fadb 392e011e 404fb076 -> c1c38604 c12d9956 3a15fd76", - "c190eccc c0869977 3d53c72e c02eb6b6 -> 4245d0c4 4137b8bf 3e1097cc", - "40dff668 bf64af30 40ae4238 403a7f42 -> 41a3285d c02698f7 417de5a0" - ] - }, - { - "glsl": "vec3 cultmath_af_add_iv(vec3, vec2)", - "tolerance": "ulp-bounded", - "cases": [ - "c14cfbf6 4015715c 3e079ba3 40762a88 40b8c0bc -> c1000676 4015715c 3f8c4aed", - "c0ae338e 4092a69c 3eb7d309 41819edf 4181ab55 -> 412c306d 4092a69c 3eb965c7", - "bfa2d6b0 40835bec 3befb189 3f057a33 3f16cf4d -> bf3788a0 40835bec 3d28a475", - "4191b318 3fa39a5c 3b4d8b6a 40cc680d 40cd177b -> 41c4e309 3fa39a5c 3c63521b", - "c122dfc9 3f817268 3af98ae6 40f61a4f 40f73c91 -> c01e2844 3f817268 3ca0d023", - "3ec4a940 403e2d6e 3b07cd20 c1556f56 c1556c46 -> c14f4884 403e2d6e 3b22216d", - "4170a038 404f908c 39baa597 c1620566 c161f036 -> 3f6a56a0 404f908c 3b41f94e", - "402593f0 4025d0f8 3fef1dd0 405e1d4a 405e76f6 -> 40c1ef08 4025d0f8 3fef77ec", - "41911d98 3fd561a4 3aa42457 4190566b 4192cb65 -> 42115740 3fd561a4 3e1e94e9", - "c16a9032 3ea7f220 3d3de3b7 3ef9464e 3f12c759 -> c16214de 3ea7f220 3db78a33", - "3f9e7370 bf9f1f5c 3f112411 bf51c87b bf320485 -> 3ef600c0 bf9f1f5c 3f21063f", - "40492b58 be659b40 4091bdad c1796839 c17951df -> c1471236 be659b40 4091d448", - "402ae328 3ff99948 3d5839ae 411343a6 4113ab8a -> 413e3062 3ff99948 3d862167", - "40b82940 404021e8 3ab0ad97 c1527845 c15277db -> c0ecc6e0 404021e8 3aba3f6b", - "c1426ac6 402f0ff8 3ebade69 c0f0d2ed c0efa73b -> c19d44a8 402f0ff8 3ec43fc3", - "4049bd98 bf979118 3b51b905 419e7313 419e82ad -> 41b7b293 bf979118 3be70c3f", - "41989384 c01716ad 3f100333 404542ea 404fdaf6 -> 41b1e562 c01716ad 3f253513", - "3c3fa000 c08871e4 3e0f5c36 3f4bac8b 3fba8f1a -> 3f91b1f0 c08871e4 3ef120af", - "c18420a8 40518978 3f063644 c12d2c21 c12054e9 -> c1d780ea 40518978 3f6cf2a3", - "c11a9175 c071cb96 3ce490f7 bf84e009 bf84d9f7 -> c12b2d15 c071cb96 3ce5724c", - "c0d56436 bff735b4 3bd3c710 3eef823e 3ef42242 -> c0c64712 bff735b4 3c34063e", - "4124be76 3fd0efe8 3c7eeb31 4195e3ac 4195e400 -> 41e84311 3fd0efe8 3c80806f", - "c141ec9e c04f02f9 4099eee6 4115b19d 4115cecf -> c030b1a0 c04f02f9 409a0c41", - "c0fc6112 408e63b2 40d6d1fd c1a43fff c148992a -> c1c35e8e 408e63b2 412b5ca5", - "4033e1a8 c052926e 3e9dce6a c0b2bd99 bfed82fb -> bf68f2c0 c052926e 400b16d7", - "c0a7e880 c0968525 3cbdd936 3fa0c00e 3fa0fd32 -> c07f61b0 c0968525 3cc591aa", - "bfde2820 407b2d4c 3faea1e6 418d5507 418d555d -> 417ee560 407b2d4c 3faea5cd", - "40d983c0 40809694 3acb881b c15d54dd c1321629 -> c0b5e746 40809694 3fad2e79", - "4157b7f4 3fad12b8 3e4e4072 bf015747 bedf9973 -> 41502ed4 3fad12b8 3e715953", - "418360d4 407a37c0 38eb199c 416be125 416c45c3 -> 41f96a8e 407a37c0 3c4bd9a9", - "c0eeb1b2 c05ba444 3c28971b be8bd2ce be7cec64 -> c0f703fa c05ba444 3cbf4753", - "c1581fad 3f8ba4bc 40bed57a 407980f1 4079830f -> c119bf2d 3f8ba4bc 40bed62a", - "4111c8be c04640ed 405b4fe3 41087344 4109c554 -> 418d7285 c04640ed 405df486", - "c0fa33d8 bfc08fbc 4116a717 40ef3dc8 40f96fb8 -> be3ba300 bfc08fbc 411933a6", - "c07d76c0 400450b2 3f456b95 c13fd35f c13fd13b -> c17f2ffd 400450b2 3f457ea2", - "418b3786 3dd01d00 3a924c21 41597c11 41597c7f -> 41f7f5aa 3dd01d00 3a9ec23b", - "bf62bfc0 c099b22a 3dd6c8ee c1a31fec c17574d5 -> c1960329 c099b22a 40284d08", - "c10020c0 bdcd2dc0 3b985c1a c03bbf6c becc27a0 -> c11ac94c bdcd2dc0 3fa2d343", - "c18c8840 408ef4b2 3e23b860 c1560445 c15601bb -> c1f789c0 408ef4b2 3e2415dc", - "40bbf1c0 40121256 40ad0299 41818f17 4181934d -> 41b08da2 40121256 40ad0b61", - "401c2618 407d9064 3b8102a0 c1545735 c1545637 -> c12d4d30 407d9064 3b85db2d", - "4088ace8 bf9a64ec 3a867094 c0c0df2c c0bf1b9c -> bfdd41f0 bf9a64ec 3cea4104", - "40c2bed8 bf809316 39c5aeec 406e1ffb 407180b5 -> 411d5382 bf809316 3cdb6282", - "41052d14 3f5c6690 3fed4f9d 412f12b6 412f1d6e -> 419a2293 3f5c6690 3fed7b85", - "41494f80 c09adaf2 3d45023d 414532f6 4147baba -> 41c7e32c c09adaf2 3e0243ab", - "bfea38a0 c08ae2c0 3deaaa3a c192c6cc c192887a -> c1a14b2d c08ae2c0 3e04f45b", - "c13ba348 3f22c218 3b5aa28b 404512cd 40461ef3 -> c10a3d10 3f22c218 3c3ced2b", - "40510e78 40006d00 3c77bc88 41986420 41986db0 -> 41b28ab7 40006d00 3c8f550e", - "418688da c007d278 41044828 4183385b 41833b35 -> 4204e151 c007d278 41044b3e", - "40ce7218 405421ec 39344ef0 409abdcc 409b504c -> 4134bc92 405421ec 3c159f21", - "c18c9061 406fc0f8 3a401aff 409b1310 409ba190 -> c14b739a 406fc0f8 3c1ad707", - "3fe5fb50 bfb37efc 3d0f8f46 3f89224c 3f99c7b4 -> 403bb828 bfb37efc 3dccf5b5", - "3fd0dfa0 402b3c58 3a265b42 41621a30 41622f10 -> 417c4094 402b3c58 3b52a01d", - "c183a88c c081a188 3d48d46a c189ca49 c12b490a -> c1f35ff3 c081a188 4053bb3e", - "c19d9ff7 c05fe282 401be9f7 c01a8c5a c01a2136 -> c1b0ead0 c05fe282 401c2003", - "3f890fd0 c095914f 3e0aaee1 bf258410 40e53782 -> 408a8774 c095914f 408149a2", - "409d2e00 c099f3ce 410fc49b 4069076f 4069ff31 -> 4108f7d4 c099f3ce 410fe3ad", - "c0d6c884 bf8c0f94 3e858e4e c18307fe c154b0ab -> c1ac624b bf8c0f94 3fe6e21e", - "c131fce3 c0454ad4 405ca620 c0ca5871 c0accbff -> c187e300 c0454ad4 407a330b", - "c15e2aa4 c06e8ac7 39ea88f2 402fad6c 402fb5a4 -> c1323e42 c06e8ac7 3a3b6bbd", - "4029f070 c0043f58 4041b741 40ca5814 40cade94 -> 410fc9c6 c0043f58 40423e12", - "418360e0 409f20b6 3eed86e4 c13b0c2c c0f4c124 -> 40d816c2 409f20b6 401f0879", - "3efc4140 4015642e 408ad953 3fff667c 3fff69c4 -> 401f3c38 4015642e 408ad9d2", - "3f603900 40312eac 3d8fcc0c c0536431 c053625f -> c01b5508 40312eac 3d8fed75", - "40fd6d60 bf623db8 3c35b701 c1221fd0 c11a04bc -> bffadcb0 bf623db8 3e87609f", - "414a0ae8 c024b008 3d2a840e 40bbac60 40bbb598 -> 4193f1b3 c024b008 3d2ced08", - "c080a67e 4080caa4 394bc8f6 c0166ffe c015b392 -> c0cbaf62 4080caa4 3bc33041", - "c0da534c c0717886 3b968206 c16185bd c160d849 -> c1a72c54 c0717886 3cd36216", - "c0d34b5e 3fc95468 3c5a86b9 c13b1640 c13af390 -> c192554c 3fc95468 3c903283", - "beec2240 c016e0e7 3bc92a16 c0bba35c c0bb90c4 -> c0ca5c34 c016e0e7 3beece81", - "c09eb2a2 3f1476e8 3ebb66ef 40177ed2 401888ce -> c0256174 3f1476e8 3ebf8f9c", - "c15cf475 4075ff10 3e285a0a 41850120 418619cc -> 403899dc 4075ff10 3e6e8af9", - "40d6e390 be8839d0 398e2e84 c190cbe7 c19078a3 -> c135d2c2 be8839d0 3ca8fc3a", - "408c9980 3fe0e87c 3cdcbe33 c169a619 c1660add -> c1218bbb 3fe0e87c 3e0f05ed", - "c08107d4 bf0e4550 3c50f8b4 41790999 417ccd5f -> 413a6792 bf0e4550 3e058f54", - "c192f9c3 409bb6ea 3a84e9be 416b2889 416b3007 -> c06b1cf8 409bb6ea 3affb173", - "4003af38 40766f78 3a3a8965 c0b725af c087b159 -> c03b27d0 40766f78 3f3e00ce", - "415a8f08 c0468ba1 3cfe2194 419fc40a 419fc802 -> 420686c5 c0468ba1 3d034187", - "c00ca2d8 be51bb60 3c42e19f be0d5fe8 3fe66cdd -> bfaee540 be51bb60 3f7b24a6", - "4167618c 3f34d2c8 3bfb7125 40e1edb1 40fa1f67 -> 41af3269 3f34d2c8 3ec57f4f", - "41482ab0 40320492 3aa4c7c0 40c564eb 41075852 -> 419e980a 40320492 3f92c1a6", - "418a1c02 c06868c5 3fa254dd 41765b09 417684a7 -> 4202a9f7 c06868c5 3fa2fcfd", - "c154624a 3fea7128 3f41956b 40d30d41 40d30f37 -> c0d5b658 3fea7128 3f419e41", - "41350250 bffc39d8 3eb831f2 c1393067 c13527a7 -> be0a6dc0 bffc39d8 3ef8bfb7", - "c04c9e78 c04e7aba 3cde8c8e 41736ad1 4173704f -> 414045f2 c04e7aba 3ce44787", - "41864be8 c0969b34 404b37f3 c19991ab c1904cc1 -> bfea34e0 c0969b34 40704c11", - "bf9941c0 3f8c4d1c 3d1a64d5 c182b45f c1829405 -> c18c384e 3f8c4d1c 3d3ae1d7", - "412ee73c 3fd36cf8 3ce096a0 bfbedd0a 3fe25e4a -> 41311f50 3fd36cf8 3fd42085", - "4102f7cc bfa7821c 3dee9f21 407aa1c6 407aa65a -> 4141a0d0 bfa7821c 3deef119", - "41279eb6 40026d62 3f104346 c00d363f c00d3261 -> 410451a2 40026d62 3f104bd3", - "4015f9e0 4066096c 3a2b9dcb c19e38e8 c19e2c9e -> c18b7387 4066096c 3b72145d", - "40ad4ad4 c00589e8 3ba3544e c09307e4 3f97114e -> 406d5218 c00589e8 40391e17", - "4180b736 c028a337 3f5a09d7 c19b03e0 c16d77b4 -> bf828a70 c028a337 4047a2f7", - "4015dca8 c0548aa7 3e86a387 c12fe8af c12fdb55 -> c10a6ad8 c0548aa7 3e877c0f", - "c174b42c 4049d2c8 3a8f4754 c13553c3 c0718ceb -> c1b6c7d6 4049d2c8 4071f39d", - "c18fb348 3f241890 40321b95 413a26ba 413a7bee -> c0ca2a78 3f241890 4032c653", - "c135d595 c00d545f 3c9b39c0 41932b13 41932ee5 -> 40e108c6 c00d545f 3ca31511", - "408d9cb8 bf093308 3d10b403 410eb2e0 411f83b8 -> 415de9a8 bf093308 3f0f938f", - "bf38edc0 bfdf29e0 3914983f 4002f60d 4002f7b3 -> 3fa976e0 bfdf29e0 394e756c", - "bfa327e0 3f54ac68 3d4faf22 40d4831a 40d5f3f6 -> 40ac7190 3f54ac68 3d95f98e", - "4070a578 c099a8f4 3d2cb9fc c18ae188 c1343ae1 -> c128d59a c099a8f4 4045c3d5", - "411babb0 3fc22c78 3fe909c9 c1966eae c19667d8 -> c1112ad6 3fc22c78 3fe94172", - "c189305c bf79bd80 3d62227c 419c0f3e 419fe84a -> 40265b40 bf79bd80 3e9768cb", - "409d8598 4033d544 3facef50 414b86f4 414b9764 -> 418d28fc 4033d544 3fad3224", - "c1783c15 3fca9938 40af9a1b c073345d c021f963 -> c19570e6 3fca9938 40c3e916", - "413ae0c6 40367198 3e446b0e c0f2c661 c0f1abc7 -> 40838878 40367198 3e56185f", - "bfa48d50 c0989c5c 3aa97654 c12b2889 c1077efb -> c12de56c c0989c5c 3f8ed172", - "c14283ac 4022abaa 3b7197d6 c19f35a4 c19eec28 -> c200295e 4022abaa 3cb197fd", - "4192dc10 3f7191c0 3ccd062f c03e6b98 c020d0e8 -> 4179d090 3f7191c0 3e833d9c", - "c1868fbe 403170f6 391fc6a8 41495dfd 41497d8b -> c0876370 403170f6 3b83d303", - "40ef8b80 4024713a 3ed2ddb1 c0c570f4 c0c50b84 -> 3fa93510 4024713a 3ed60a80", - "418b6e62 c088faf4 39ade173 c0e48235 c0e47cbb -> 41249d08 c088faf4 3a33fe33", - "41929d0c 409e7062 3d505596 3e065cc4 3fd46c48 -> 4199c6cb 409e7062 3f50a7b4", - "c1909400 c04cb712 3b34731b c170fdba c1702f9a -> c2046faa c04cb712 3ce5152f", - "416c1724 bea589e0 3fa73855 c0f706db c0f6d21d -> 40e141cc bea589e0 3fa7a254", - "3f35f7a0 c04db2a9 3d1c9532 40e84a00 40f88d70 -> 41039556 c04db2a9 3e95b096", - "c19b4819 401f07f2 3fcf37fd 4185a359 418fc1df -> c004abe8 401f07f2 40101679", - "4106fd1a bfffd0d2 401a3fe0 41356b62 41801563 -> 41b0e417 bfffd0d2 4097dfae", - "c1708dc5 3fc00bf0 4111a4ff 4157cc42 4158ba26 -> bfc25488 3fc00bf0 41121c0b", - "41946bac c08f0373 40c3b924 40698fef 407a8f51 -> 41b2ada0 c08f0373 40c7f946", - "417f9798 bddb9c80 4069b771 c110ad37 c1101e77 -> 40de6382 bddb9c80 406ad540", - "c1338904 408acaca 3c44a75c 418e2a3d 41a7b1df -> 41025318 408acaca 3fcdc778", - "41248f6c 3f0dfa30 3c45ad7d 404d7b81 404d84bf -> 4157ef74 3f0dfa30 3c4a9195", - "c139cdda c05de6ed 3de02bd5 4101425f 4101441d -> c0622a70 c05de6ed 3de0a2ed", - "411ec068 bffb3bc6 3c8b4c2e c14660cb c1462f6d -> c01e1ed0 bffb3bc6 3cbccbe4", - "c133eed5 be777760 41071903 4122aa70 4122d270 -> bf898328 be777760 41072d17", - "bfb4cd10 c0325e70 40823e89 c1a58527 c198916d -> c1aa581b c0325e70 409c2660", - "3f8265a0 405707a4 3d8cd14f c04343b2 c03ccb8e -> bffda9a0 405707a4 3df457d1", - "4131678a 4075f1ac 40391db6 418d23e9 418d257b -> 41e5d877 4075f1ac 403924d3", - "402fcec0 c02a69dd 3c3b2a70 40f01ab8 40f04548 -> 41240bb0 c02a69dd 3c660c31", - "4146be48 bf0c3420 3af7d215 c06adebe 3f9484fc -> 4132aac0 bf0c3420 401aafe0", - "4074d5e0 c0922fd6 3ed15765 41653305 41653e83 -> 4191371e c0922fd6 3ed213f3", - "411bee72 408f7e8e 3e500a15 405c3e9c 405d36e4 -> 41531d22 408f7e8e 3e57d1ab", - "3fb76ed0 3faaedc0 3c3efeb0 411786ea 4119a7d6 -> 412f853a 3faaedc0 3da025d4", - "c0a1aaf6 3f5bae28 3a5733de c17f615d c17f4aab -> c1a815c0 3f5bae28 3b6dba4d", - "4168cebc bf62a268 3d0942f4 c1a29f44 c194cade -> c09d36cc bf62a268 3f65dc3f", - "419b3d84 c08b6ed5 3b49bb6b c0662f77 c060a659 -> 417da04e c08b6ed5 3d3dd751", - "c199c64c 40951c84 3c974d55 c18ad30b c18acf8f -> c2124bcc 40951c84 3c9eba8c", - "bf353a00 c07740ca 3eb4383a c178d0bd c159def5 -> c174ab79 c07740ca 3fa8d64f", - "41526a6c c03175d0 3b5e247f 3df2f93f 3e8ec6b0 -> 41559880 c03175d0 3dab0a22", - "418b3e68 404d0fbc 3e6dad45 c1a804d0 c15f835c -> bda4d700 404d0fbc 406fe7cc", - "c1302d42 c0181511 3a1adfe0 c17343e7 c17342f3 -> c1d1b858 c0181511 3a4452d4", - "c14a21ee 3ec33790 3eb36213 c19c9ddf c19c970d -> c200d5b6 3ec33790 3eb442e3", - "40e59838 3fc0f950 3aea2b63 419f935f 419fac2d -> 41d905d4 3fc0f950 3c013fd5", - "4032d358 c04ca450 3bb244f3 be9f9b4d be9f57b3 -> 401ee428 c04ca450 3bbae82e", - "c11994b2 4070f6c8 393517bd c1245251 c123af55 -> c19ecac2 4070f6c8 3ca4a9fe", - "40b4891c c07c849e 38d1e1c1 c0dd9a43 c051bde2 -> 3f0a6410 c07c849e 3fe97a55", - "c15694b3 bf8b58fa 3ac3ae77 c0155ace c014f032 -> c17bde13 bf8b58fa 3b9c20f7", - "41248878 40477a78 3b9831e1 419dcfda 419dd046 -> 41f0144c 40477a78 3b9d38be", - "418e22b8 bf73cd60 3e9f7d10 4153cba5 4153ced3 -> 41f80956 bf73cd60 3e9fb5a1", - "c14e123a 409723fe 3b612ad1 c183bd26 c183bcb0 -> c1eac608 409723fe 3b6bb378", - "41232120 be88ca40 3a5274b4 41851ae3 4187ec81 -> 41d81442 be88ca40 3e354511", - "c0c24814 c03674f2 40648139 407f660c 4080296a -> c004b3b8 c03674f2 4064f7cf", - "c186cea8 3ec2dd10 3b9d9e24 c180936a c1809264 -> c203b0c8 3ec2dd10 3ba7592e", - "c1078766 bf572928 3f8d6d4a 40ab191a 40b1737e -> c0419100 bf572928 3f9a2267", - "41253a5a 405dfd14 3bc0dd5d c032cba9 c032bb97 -> 40f112e4 405dfd14 3bd15dc7", - "41635ea8 c04e32e8 3a9e878c c18af503 c18aea83 -> c04a0378 c04e32e8 3b78bfcd", - "40d7f924 403edee8 4067b3d3 c0fe3dc9 c0fe38c3 -> bf990888 403edee8 4067b918", - "40f50928 c039771e 3b74c14d 4114b30a 4114b386 -> 41879bee c039771e 3b7a73a6", - "3fd7eb50 40805d8e 3eedf3fb bfd6eb90 40d25864 -> 40844994 40805d8e 4092e90a", - "c07058c8 c08a221a 3dcdf273 40c7ccd5 4110d4d2 -> 40791db0 c08a221a 3fc0995b", - "4127b80e c0574398 3e680a8c c036832f c0364711 -> 40f43d8c c0574398 3e69ef01", - "41829206 c073a22f 3f1136e6 40fe5edc 411d05fa -> 41c99f60 c073a22f 3fbff6e6", - "c152f122 409f7c34 3fd631df c1201e2e c115a300 -> c1b6e8dc 409f7c34 40000feb", - "c10c7c37 3fa1acfc 391cfb1e 418cf35c 418d1714 -> 410d8e39 3fa1acfc 3c11c2f2", - "c1870824 c07f09d7 397c76fb 409bc3d3 409bc6fd -> c1402d94 c07f09d7 39edea29", - "41647f40 c0776a70 3f6b9698 c0254e23 bfd598da -> 41427bee c0776a70 3fb04da2", - "4137a2da 3f45f670 3d2d5f25 c14fe814 c14ea32c -> bfbd1630 3f45f670 3da7f13d", - "3e500b00 c06e9a6c 3cd50028 419c4ce3 419c5081 -> 419deec8 c06e9a6c 3cdc923a", - "40389b10 becf9530 3dbbab36 4164c5b3 417f577d -> 41901aae becf9530 3f6c05eb", - "3fe02800 c08df1e5 3cc33fea 413c0e2d 4141483f -> 415ab036 c08df1e5 3e3fb1d5", - "41331352 c0955959 3e4bd629 c12db3a6 c11b672e -> 3f685e80 c0955959 3f455a5e", - "40cd83cc c0840df3 3939172b c0f1c494 c0f128ac -> bf8fcb50 c0840df3 3c1effa0", - "413c8e7c bfde076a 3b58c22d 41898bb1 41898c23 -> 41e7d328 bfde076a 3b62e0ba", - "406e4500 be89e4f0 3e6188a8 40e3f787 40e40789 -> 412d9104 be89e4f0 3e628d66", - "c15de1cb c06447ef 393348f5 40ce4568 410d9abc -> c0c70626 c06447ef 3f99e659", - "4097c4c0 3dba2a00 3a803ebc 413119fc 41324848 -> 417d9382 3dba2a00 3d1b4315", - "41406308 3fb09af0 4116cfae 411c2dd0 411c2e48 -> 41ae488a 3fb09af0 4116d015", - "4122558c 40859c48 3b294d7f c0ecabb8 c05c88a1 -> 40973314 40859c48 3ffd2408", - "c0528fc8 c0871887 3a3d1fcd 3fa588fc 3fa7f144 -> bffe6270 c0871887 3c26021e", - "c122d587 c05c7182 3e527937 41470911 4147106f -> 4010dce4 c05c7182 3e53698e", - "c1895f31 bf8f90a0 3f783632 3fc7e57c 3fcf0de4 -> c1794f2c bf8f90a0 3f7f5fcf", - "40aeb680 409bbe18 40dee740 c0aaa726 c0aa9f96 -> 3e026440 409bbe18 40deeb2b", - "c15f0f6a 40791a64 3b15a3b6 4116a498 4119aab8 -> c08dcf84 40791a64 3dc63e21", - "c15bbefb bfd77408 3d810628 41859059 418597eb -> 403da524 bfd77408 3d84d9dd", - "40e0b164 c045ff0e 3b5945a8 4118e415 41325ffb -> 418afd5d c045ff0e 3f4cba7c", - "c187d85f 4096ef2a 3d183872 c129e1e2 c1279b20 -> c1dc37a0 4096ef2a 3ddde235", - "bfbd6100 405dc448 3c0d367f 3f866eab 3f8a9e15 -> bed36a80 405dc448 3ccc9278", - "c05f5298 405a0524 3c9a8644 c14391e3 c14372d9 -> c17b5704 405a0524 3cb9cefd", - "412ad95a 408fa91e 40729da7 c157d680 c14cc988 -> c01ddaa8 408fa91e 40845bfc", - "3f920d50 4043e974 3c720e7e 41716e9c 41717b4c -> 4181db4f 4043e974 3c85fc0c", - "4184723e 3f74f6c8 3f0822aa be0e799e bd8298c3 -> 4183a278 3f74f6c8 3f11c974", - "417340ac c085346d 39235ef8 40febe7a 40ff7e96 -> 41b967f8 c085346d 3c4336d3", - "40d2f9d8 be8bea30 3eeab853 411380e2 411aa82a -> 418048b9 be8bea30 3f2e9814", - "c0f9a768 3caeb600 3f07fb5f c129b719 c129b06b -> c19343bb 3caeb600 3f0832a8", - "c0eb883e 4070fee0 3bdbe3fe 3fd129a7 3fd81599 -> c0b66056 4070fee0 3d0a46d0", - "41110674 c010132e 39f1a2b3 419d16b9 419d1e27 -> 41e59daa c010132e 3b183ddd", - "c1139a31 3ec16200 3e1c5381 418aaa09 418dbb3f -> 4104cb17 3ec16200 3eb053d9", - "416b162c c07f2078 40339a9b 418fdf6b 4190e9c1 -> 4202f7d6 c07f2078 4037c4d9", - "c0dad798 40415ed8 3f19eae0 410a3cb8 410ffc38 -> 3ffd8560 40415ed8 3f47e7cd", - "c103a95e c0355297 3a4f798a c016e996 c015979a -> c1293984 c0355297 3c3634b7", - "c1978de1 c08c75a0 3a81a8e6 3fa857b0 4117703a -> c158de2a c08c75a0 40826d9e", - "c1940d32 c02c9577 3a88a5b2 4189420d 41974b77 -> bef19c00 c02c9577 3f60dc63", - "4086a7b4 4090534c 393550e9 c090225a c09019b6 -> be976540 4090534c 3a39e81e", - "c16eaf57 4056fe34 3f6f4ae8 c1a20d68 c1919360 -> c2089408 4056fe34 3ffb7792", - "c13db33c 3f9001d8 3f6e6b68 40289206 40ca7cfd -> c0ec0378 3f9001d8 4031cf1b", - "3f0dd080 c072b8f6 3e2ba483 415378d2 4153804e -> 415c5998 c072b8f6 3e2c9bc0", - "3ecb2140 c0818964 3e92a9e9 3f8f7446 3f8fcbfa -> 3fc26870 c0818964 3e935a30", - "c13aaef0 bfce732a 38d696b3 4190e30d 4192e1e7 -> 40d22c08 bfce732a 3dffaffb", - "40af5748 407e8ebc 409e1ce3 c17e7844 c17e77c4 -> c126cc60 407e8ebc 409e1daa", - "c09c24cc 4022ed6c 3be3bfb3 3f176b8e 3f2cb832 -> c087e290 4022ed6c 3d46e49a", - "bfd53c90 bf464890 3a2613b4 40490769 404927d7 -> 3fbcf2b0 bf464890 3ad56e81", - "c05c72b8 c014f6c8 3db068be 410d6d76 410dc776 -> 40acfb90 c014f6c8 3dc6f116", - "41854f48 3f5acf60 3bf09a7a 40fe0e26 40fe36b2 -> 41c4d7e3 3f5acf60 3c215ee5", - "3eccd440 c019da19 3d222852 c1a5bf58 c132136e -> c178626d c019da19 409aafea", - "41388a3c 4055b748 3fc6d0e2 c0cce677 c0ccdb71 -> 40a43384 4055b748 3fc6e771", - "c0f883ec 3fde63dc 3e92b16a 407024ac 40733034 -> c07f5d68 3fde63dc 3e9ee0c5", - "4125ef9c 4021802e 39e79c74 c129c0ca c11ad38c -> 3e695c40 4021802e 3eef0f82", - "c1840a69 408b266a 39c03fc3 c1263f75 c101c0b3 -> c1ce0a73 408b266a 3f920859", - "418d23ec 40211214 3b260717 bf534e02 be31f3f8 -> 418924c0 40211214 3ea81fac", - "c18f841a 3e7ba7c0 3ad04392 41285925 4128e68b -> c0ecd0b8 3e7ba7c0 3c9a8eab", - "c174384c c0298ffc 3b0ced88 3e9b4507 3fa09bfe -> c167c178 c0298ffc 3ef4b1af", - "409f424c 3f57cd20 3fa1ea3b c10d0878 c03da150 -> bf697400 3f57cd20 40861ad0", - "4119b164 3f4216b0 4112ff2a c14bea47 c1464bdf -> c03da6bc 3f4216b0 4115ce78", - "c156e19b bedf0dd0 39e195c7 418174d1 41817887 -> 40302ef4 bedf0dd0 3ab19167", - "40406730 c06214e6 3aeb25a0 c12ca02b c12c9f65 -> c0f90bf8 c06214e6 3afa4906", - "c19443ec 3f082b50 3bb9d72c 40457381 40457faf -> c1772972 3f082b50 3bc69dbe", - "4134038e bf2a2f70 408b9bbd c184474a c1842e5c -> c0a8e430 bf2a2f70 408bcdcf", - "3f77f980 be10fbe0 3de4a29e bffc40ca bffc29b6 -> bf803880 be10fbe0 3de55cdb", - "3dfbf400 c076c407 3f21aba4 c0ec6e1e c0ec6a66 -> c0e87c72 c076c407 3f21bbb6", - "c0ac7ba8 4025c85a 399c764c 41316490 4132f764 -> 40b7e04c 4025c85a 3d4ab67f", - "40736620 bf82c7d8 3b9c33a7 bfe90106 40319793 -> 4088f8d4 bf82c7d8 40135a4e", - "4196ee4c 409af944 391f206d bfdf496a bf8f7056 -> 418b787e 409af944 3e9fc917", - "c18934d6 c02a85a8 3ad7b8ba c14dc065 c14dbd6b -> c1f0144a c02a85a8 3b0684ef", - "c0f78582 3fbd43f4 40587ffc 412bf55f 412bf8d1 -> 4040d15c 3fbd43f4 4058872a", - "40e45c48 405dff88 3e75a967 4111ff10 411ad628 -> 41844c60 405dff88 3f0424fd", - "bfc91160 bf911030 40983b6b c181834b c17e83a2 -> c18cf3a4 bf911030 409cbeae", - "c10e5030 bed5e5a0 3d94eef9 4198d543 41997669 -> 4123fb7c bed5e5a0 3de590f4", - "c095310c c080ae26 3c45069b c15d5ea8 c15d1990 -> c193ea51 c080ae26 3ca7e40a", - "3fcc6880 bf00fdc0 3a0bc580 40f568bf 40f56b49 -> 41144212 bf00fdc0 3a38c1a9", - "c1138271 406d8984 3da59e58 c16f0f16 c159c228 -> c1bbf588 406d8984 3f3f1de9", - "410b2034 406208f8 3b8c3867 3fdf9819 40b7818a -> 4146fa18 406208f8 3fffc3fe", - "411eda00 400df704 3dce454b 41286f0c 4128cc98 -> 41a3bbe9 400df704 3de5b8f7", - "405992c8 c090608a 409bb4fd 412f3fd8 412fa860 -> 4165d8ce c090608a 409c1dcb", - "4090a614 3fce5ec8 3b0a0416 40623497 408d3634 -> 4107e72a 3fce5ec8 3ee1f52b", - "c13a6674 c02b9ed9 3f1286ac c0e4e3a4 c0df84ec -> c195c04c c02b9ed9 3f28035f", - "c12d926c 4000f530 4105821d 40ae96c5 40af6213 -> c0ac286c 4000f530 4105b506", - "40655140 404345d0 3f6a71aa c14b123d c0ac9046 -> c0aeb1c0 404345d0 40921883", - "c04164a0 c06b8d26 40fabdb3 c193033a c18795b0 -> c1a57909 c06b8d26 4108cc97", - "40cee0ec bce11000 3e3b8975 40c9a190 4104e5c0 -> 415c4bba bce11000 3f97c5c9", - "beb63b40 3df97880 3beb4968 c1399632 c13928d2 -> c13f115c 3df97880 3ca861b8", - "408a9c58 3f884574 41025fc4 c0bc5454 c0b87a40 -> bfbf2bc8 3f884574 4103565a", - "bf140f40 c07ef286 38d91218 418e644f 4190ae91 -> 418ae8f6 c07ef286 3e12b586", - "c1910d98 401806f4 40d33646 c11e8348 c0eaa031 -> c1d60270 401806f4 40fc69d3", - "41331ee4 c01bdd50 3e54b02c 4140f3a3 4140f46d -> 41ba0976 c01bdd50 3e54d2e9", - "bf41fd00 3fe97ca8 3a8cd91a 412bc041 412bc207 -> 411fa154 3fe97ca8 3aac0a4a" - ] - }, - { - "glsl": "vec3 cultmath_af_mul(vec3, vec3)", - "tolerance": "ulp-bounded", - "cases": [ - "41075bac 3f4af898 3967eae5 bfbe3570 c05d8722 3ec408e6 -> c1492496 c1f3b01c 40c939a5", - "c0d94220 402f4f90 3a15cdde 416d3958 409a98ca 3fa69caa -> c2c952e2 40fa03d8 41cd308c", - "c01ec080 3fca088c 3cdf5746 c0e2cd42 c06d77bb 3914903a -> 418ca53a bffdd898 40c4d91f", - "c0aa1fdc 4035ee2c 408585f8 3faab210 bfa8e69c 3f80a3bf -> c0e2defa 412ce582 41d9b797", - "c186392d c029d48a 3fe03804 403288d8 c05dcd2e 38dc3ebb -> c23b3702 424af9bc 41a13fd4", - "418847ec bf7f73e8 3a99ba0f c12e8e34 4081796e 40597fca -> c339d92c 429f9f9b 4282af9c", - "c1958961 3ecd8a20 3f70d183 4197ea98 400a85e0 40d27f52 -> c3b17a21 c203564e 43188e0b", - "414802c4 bf5c8c20 4048295a 41923b8a 404bd2d0 38dfcf7a -> 43648030 41c08296 428bbfb0", - "c0ed9a00 4015d44c 3bbcc67f 40c2c048 40590fa0 41053c59 -> c234c12a c12ef540 42b2bc31", - "c13e0ef2 c04dfa95 3a952dbb c11426b6 bf96a8a8 407c8497 -> 42dbfac2 422f2100 427d7c87", - "416b780c 4026bcba 3e01a3e2 c161d454 408e54c0 3da83447 -> c34fb7cf 41e57dd8 4175f08a", - "408b95f0 c03921ec 3f156a6f 404f0088 c00653df 3db40ca0 -> 4161bd0e c194179f 411df92e", - "c1293bd2 bf89ca3c 3964f06c 4193590e 400d537c 40bcdbe2 -> c342d071 c22cbc32 428e5259", - "4180721a c070e96e 3c455b28 415b8c0c c01c90cc 3c4cab89 -> 435c4fc1 c2b5dbec 411a6c3c", - "40c2c284 c010d04d 3d82ccee c12cf620 c0983fa1 3edb8a92 -> c28395f0 c08fe5c4 4175e023", - "40f99ee4 402913f2 3a2159ff 41704c98 c07ba2db 40c0a18c -> 42ea4fa5 411019f8 42928705", - "c0c8cab2 3fd3ae30 3cb56e3f c0eb57aa bfc2a7ca 3ddfe5a7 -> 423896d4 c027b0b4 40652b54", - "c11e73b4 401572de 3c87f222 412880e8 bf559028 3c8c6ae9 -> c2d0976f 42036a82 401632c7", - "41853558 c024c10d 3c9e83cd c11b7e45 bfaa15d4 3b00da3a -> c321d201 403915e8 406b0a03", - "3dfa6000 c0980a01 3d0974b9 c13f41c5 bd4d6580 3e680c81 -> bfbb0df3 426326c6 3fe06645", - "c199026a bf9a7dce 3a606d70 c1976e04 4076f0b0 3d2e957e -> 43b5045c c24bcdc1 40b16590", - "c030ba50 bfb310d4 3b2f725a c17860dd 3f962ee8 3946888b -> 422b775c 4193d0ab 3fd7ee0d", - "bf183be0 3f5a4028 3f416a20 414563ec 3f67ff10 3d269488 -> c0eac2fe 411fa934 412de241", - "41981b2c 4078e05c 3ff7279d c176e15a bfeec1a0 3f4f4062 -> c392b002 c2beef7e 4273038e", - "c113c47c bf1ec928 3c1e64ad 417f707c bfa3504c 3986abaf -> c31371a5 3ff0c620 3f75f3d0", - "bffc2300 c0652394 3a3a6b2d 413eb9aa c003a700 40defa0c -> c1bbd8d7 c21a814a 42383686", - "c049a270 c02f97ad 3fdd9800 4185c7fe bfd6a104 3948e40a -> c252bdd3 c2226460 4211d225", - "c158c8fc 4042cb8c 3e08ee9c c07b29d8 402e0578 3f4fc3ff -> 4254b07e c2432497 41b5ea64", - "bf2d55e0 3ff921a4 3c730c3e 419aa898 c02f781d 3ddbbd96 -> c1516fa0 421def40 40be4ccd", - "4148e610 40826e42 395fbf8d c07391d0 4024e874 3c8e25b5 -> c23f24cf 4186baa9 412cae3e", - "c16d86af 3ea30780 410add15 c13db36a 3fce4704 3cc3120f -> 433002e7 c1dd97f8 42ebefc3", - "41766fb8 3fef8530 3b3ac2a4 41447f74 bf9066ec 3bdaf83c -> 433d283a 40b35d34 4010f46a", - "40def454 c08dacd3 3d785eff 41406f60 4090f3d2 3d0fd72c -> 42a7983f c1ad8176 41abb0ab", - "c15be5b4 406b05f8 3e5b17ec 409373a4 bf56e898 3e7ab7f1 -> c27d5077 41e3ab80 410909e3", - "40bd09d4 bea6ac80 4073b763 40248a80 409ae9cc 3c0c930f -> 41730123 41de1711 41ef19a7", - "4180e48e c09ac214 3cb327c1 c080419c 403916ac 3f80b566 -> c281269f 4283f4ef 420ce477", - "c189fdae 40927536 3a08559e c160138b 3e2c5d40 398b26a1 -> 43719102 c2860048 3f48aa40", - "beba3fc0 3fe15658 3b61cc45 c189d59a bff451f4 3a368a76 -> 40c88f0a c1ed1870 405b5fad", - "c1902367 c09bc4a7 40bdc775 40113910 c020fec0 40354d7d -> c223885c 42091c92 42f480db", - "41345abe 3e0bf800 39c6d918 c0f34e94 3f0f1eb0 3a73d332 -> c2ab697e 40a866c6 3db8c1fa", - "40179a00 bfe565d2 3ea7a3b1 41815d48 40815b2c 3bea23cc -> 421937af c19b3d33 415e5197", - "417e1790 c0106508 3b0f7bcc 4123e24e 40146aba 4117907b -> 4322a99f 415b7e52 4331166f", - "c0aba8ce c09de915 3bb919b4 40501568 c0707430 3f005048 -> c18b8782 40838654 41bdf549", - "c0a5fa82 3f48c080 3a223c84 411e7302 3e1696c0 40e4d91c -> c24d765a 40e0195d 422b4fae", - "c02de1a8 bfc50a54 3f30fa49 40467590 3f9708e8 3b1c5d86 -> c106cc62 c0ff56a0 409934b6", - "40ec66f8 4025abf0 3c2738d5 418fd77c 3f6817d0 3a7a7cee -> 4304d482 4254f767 402328cf", - "c097583a 3f5dcdd0 3f390b22 418bb9ca c051c2c5 391c6cea -> c2a5357b 41f511e5 418ead1c", - "418028ec c004291e 3b27254c 4192fbd8 c045dd55 3ad45deb -> 43932ad6 c2aeefc2 40ceff62", - "3fcd12c0 c03faa9c 3c10fb07 c09eff34 408caafc 40f6f00a -> c0febc04 41af61fb 4243286c", - "c194ad2e 40477380 3f8946b0 4114921a be8e6830 3d7d11a1 -> c32c91f1 42086dbe 41487ec0", - "4083ac38 bfe70ba0 3e43fdce 419d9c40 c0892896 40ea9c51 -> 42a221f8 c254cb30 4264882c", - "406f69b8 bf560d80 3c44ae45 c15d3898 c0404e87 3d47cdba -> c24ee331 3ea40800 403c0eed", - "4195d2ee bf29c358 3c2fe6d1 c170e8a1 405e2128 3aa7519b -> c38cfde5 4295f87f 4021a3d1", - "40f2a1d8 be8b80d0 3a1c8e33 3f853960 c094027b 3c485a15 -> 40fc88ec c20d6a50 3fae0b93", - "4177237c bff499d4 3f9fcd70 c041d320 408484aa 3f49106b -> c23b1d92 428b817a 41fbd268", - "c08cd5d8 3fbf8394 39c3d11e c13746b2 bfd4c50e 3feaf31d -> 4249a784 c11d2a65 41551490", - "c09bb4f2 40828cac 3aa91601 c0f565a4 bfabc57c 3f3ec367 -> 421541fe c1c60bed 41427429", - "4150ab88 bf924a20 38d4250b 41611b54 bf6c95d8 3d0aa1e0 -> 43377d09 c1e10ee6 3fc4de2c", - "403692a0 4083c724 40d4cd46 40594478 c0925f6a 411ef560 -> 411af31e 3f6e6c10 434f2701", - "c07872a0 c0876888 3b288100 c1271889 c07beafd 3f263125 -> 42222a96 426de372 41afb25b", - "c15d972e c053b0c8 3d04f369 40af2ad4 40293254 3d661236 -> c2979f6b c25ae100 411f93f1", - "c044a078 4022ec8e 39a5a0b5 4008bf60 401cf1d8 409ebecc -> c0d2107a c006104c 42087629", - "419fb53e bf97f884 39b39ae3 c0989bbe 3ffff748 3e39d1e9 -> c2be698c 423655cf 40c6e034", - "c055d368 c094fbeb 404d7d2b c0eee1aa 4061e690 38d76050 -> 41c78707 41b7b360 424ef1de", - "41494020 404343f4 3dde13df c1766299 4046d5f4 3afc6ce8 -> c341b122 c0fcf5b0 41384285", - "40350f98 c066c1f0 3f825cfb bfce9d80 c05d1ba4 3a7bfe78 -> c09221f1 c07d0bfe 418d02e2", - "c111cd41 c046e9e1 3e02ebad bffa5e30 bf36f238 3e3c8717 -> 418e9816 414976aa 409ac0e6", - "c070ab88 c09a4598 3a326b05 c197dabc 3f5b9a80 3e4f6ce6 -> 428ec2d0 42b0921a 40bc67d7", - "417b3070 c098e764 3bfb16d0 40a6be14 404e5c50 3970160e -> 42a39bea 41cdc7f7 41779f4c", - "41672334 4059d9a8 3b79eb31 baf84000 404e5548 40c835eb -> bce023e3 423a44ba 42f5617b", - "418db78a bff58b0c 40a7b8c7 415b8328 409a75f8 3ddae775 -> 4373093c 426cc0fc 42da4090", - "c167fc89 3ec9f170 3ab25a5d 4183524c c07a809e 3d12a2bd -> c36e019c 427ce709 4006b819", - "c1964440 4094eb74 3ddb2a31 c1211570 40825d08 3fbfabc5 -> 433d1b03 c2f6bf14 425ee973", - "4156dea0 4038f59a 3aa3b8ef 418ea198 c0319308 3f6044a2 -> 436f6e3d 41643a88 41b2bcea", - "41733b3c 408cf26e 3b7c0de4 4112f77c 3f7c2478 3b73d912 -> 430ba2ec 425db947 408e6a76", - "41736564 402e3a80 3bdf9805 40cf7478 3da8a500 39d19b6f -> 42c53db8 41973609 3e8d716e", - "4105d764 3f2147d8 391d45b0 401ba290 40784710 3932c60c -> 41a2bcce 4207ee9f 401c93e4", - "c02787d8 409a45ea 406ca684 416a4dc4 3f7f9e28 3ff6e7df -> c2195510 4287f886 42a845bb", - "bfadbef0 3f907144 4093f89f bf409180 3fd2333c 391a059d -> 3f82b1f4 c044fced 414ed1a5", - "4119910a 409f15f2 398c8359 c15c8e24 409423f4 392a82eb -> c3044de9 c1c0c718 41b82d8a", - "c1072df6 bf6bd018 40a2243d 41840a58 c0966064 3b9d7c32 -> c30b7252 41c3fe7c 42dfad95", - "c163db50 bfa8857a 3c9e2830 bf144400 3ec89970 3bacbbc8 -> 4103f751 c09a256c 3f1de00f", - "413fe8e0 c0100a05 404ce216 c1514b21 3de4a4c0 3ad0c835 -> c31ce571 41f63b56 422a0ca9", - "416ff2e8 c09b8944 3ba5624b bfcd1d40 c01750a4 4107a160 -> c1c040ee c1dd5860 4333e213", - "c09829cc bf81230c 39b5d155 c0d53db2 40871498 3d132b79 -> 41fd7ee5 c15597d8 408f07d4", - "c194e246 3f099620 3dccf1d4 419dc0e8 c011e964 3ccde34e -> c3b77deb 42541c2c 407a4cac", - "c17c8c9a 3e6095a0 40b8345f 4045b3d8 400e2916 3abc62f1 -> c243099e c20988c2 41f8b251", - "c08018ba 4099c630 3974ddf9 4062de00 3fe81c10 3c10d12e -> c16309d3 411c682c 410cb0af", - "c16b4ed8 3f2b70b0 3cdc6fa4 415cec60 c00c810b 40b1de2a -> c34b1107 42262284 42af098c", - "410109c0 405275b0 3a0a134f 4191b24a 3ea14ca0 3e124101 -> 4312e0c8 4279b82f 402ab966", - "c12ddc03 4046c388 3c8b7783 418ebc3e befbfd90 41074c8b -> c341dfc3 42730997 42f04498", - "411c5e0c 40446714 38d8e655 c04a3240 c08a5f44 410d5859 -> c1f701ce c24fd1bf 42fd6eef", - "c1076b78 c0017a0d 3b3c9fde c17a2cf2 c08ccba6 3b2a7483 -> 430456ba 4289be76 410fc844", - "4183d584 403b3398 3ec6adb5 410bfd42 c03f5001 3bc38a8b -> 43102eb5 c1bd5996 4156ac53", - "c197f6ba c046b0ec 3b185df9 40c15f34 c00587f2 3c86a8ec -> c2e5930b 41a6fa40 40db8364", - "c0d2430c c05ff12e 410f4e13 c0e50842 bfc16e10 40673049 -> 423c1cc2 420be4b8 4317a813", - "41369634 beec26c0 3d367596 c183c41a 405c5974 4016d23c -> c33bf574 423b8c10 41f47a6b", - "c0917778 40073db8 3d009bad be054500 3f115f60 410335f2 -> 3f17748d c036cf9b 42605999", - "40c92c20 3f6cdac0 3f32cecc 416739a0 c0922339 3efdacac -> 42b5b419 c1756cac 41ab6d48", - "41843824 3dc4d740 3de4748f c182dc7a 4086b2f8 3b04a372 -> c3872cc3 4287fead 402eea01", - "4107c718 c08228c7 3d1adea9 4018f9d8 c084b585 40778ccc -> 41a24573 c233a97c 4283a346", - "419f9e04 40958c54 40b18006 c0994256 bfe1864a 3ddbcb64 -> c2bf1d9a c266253a 423f3eec", - "412216e8 404f3338 40b04581 415bb980 bfd68e02 3ce63eb2 -> 430b1f0c 41dbd4da 42b5acf0", - "4163b254 3e913d00 3e154fe5 c1061271 409e0cc6 3e9fc10e -> c2ee7f7e 4287d266 40fd5d3e", - "40df27d8 be82d940 39b33c13 c11f1637 bf6bd1a8 3fc92bff -> c28aad1d c0788017 41399fdc", - "c0fd5bf8 3ff89e54 3d3d43ce c1142526 bf9e9e92 3f11b321 -> 42929def c102c386 41087b2c", - "c0b49022 405105d0 3e0a2e75 4051a030 bca88e00 3db55f4a -> c193daa8 412d0415 3fa80d01", - "c19521fd c00ec8c6 3b108ed2 c157e090 c07add44 3aa431dc -> 437b84ba 42ce5806 410cf553", - "413a1bd8 c089a49b 3a49b2a6 c1735ebe c0296b49 3c166765 -> c330ed4e 420a8a00 4138bf39", - "40a473fc bf4899e0 39a48d2b 414aada8 4076aa88 3de8061f -> 42823313 411e1884 406c9257", - "4146dd64 401e523e 3d80695b c179e541 c086f997 3e0ff06a -> c3421f6d c2b61fa8 415c82ee", - "c18893d5 be1c3f40 3c8dd2c7 c141d0e0 be1fe700 3d0a70fc -> 434ecdc6 409074a4 3f51b807", - "4168c988 c010b5b8 3914d73d c19223fa c01bce77 3ec4ecdf -> c384e3a6 40bc5170 413f935a", - "c032e1e0 3dee8f80 3bde9c47 4177cef0 bec99080 3ba085ef -> c22d2889 4039e2ce 3e2c200b", - "40cf6904 c04b4f3e 3ca17d1f c166291a 3fb341c0 40bd6229 -> c2ba79a6 425b18c3 427825b0", - "40c22c34 3ed85240 40a293dc c19b23af 402d8aa8 3f10e650 -> c2eb57a9 41042a20 42effdd2", - "c19666f1 4087d0a4 3a811e92 40b21848 c0835c73 3e05e134 -> c2d143af 42c997f6 41a39038", - "412e03d2 3f6fb2e0 3dad4663 40db7518 c01c2845 40cd2af3 -> 42952cdd c1a0ec7d 429eb239", - "c0b074d4 3f5a07c0 3a2f6135 c0969ad0 bf9133c2 3bf2434a -> 41cf9e54 400fce9c 3f823212", - "c12391fd 4087873a 3b31e97a c13247b9 bf066708 4040ff65 -> 42e3d2ab c2274bee 423774ed", - "c152ccc0 408a80ba 3fd6238b be8a95c0 3ee8c830 40a45e9c -> 40643b5e c0e52b9a 42cb5c82", - "40255fa8 405f10e4 3d05aa6f c10ce3ea c09bbd09 3b9600f5 -> c1b60716 c22d1158 418b7f15", - "3f3b7e80 403a3b66 3c536fbd 411b9b6e c07634e4 400a69d4 -> 40e3eedb 41cbdbc8 419a323a", - "41219f90 409cfcfa 40890441 bdc7ff00 40321150 39453bd9 -> bf7c880e 41dd0298 41cfe09e", - "41392f30 c0139c7c 3a1d64c9 402c94f0 402d4a9e 3fdd8046 -> 41f9aee2 41c8f439 41f22765", - "bfb93d50 404579d8 3cc69c85 c0fc634c bea138e0 3a1f30a1 -> 4136a034 c1bf0b43 3f962d65", - "41324b82 c00da780 3936928f 40b77be4 c07b9d5e 3c328a7e -> 427f9486 c2620147 410d95e5", - "bfd3a980 c085ab40 3d941c12 415517bc 4068fab0 3dc29fb7 -> c1b02fa7 c2769bde 4187f2e6", - "41908456 3c529600 3f8cb5fb c04d7398 be9f3a50 3c9dbdb4 -> c267f674 c0b5183b 4087d024", - "41964184 3fdd8678 3a1b6a44 41397c40 40027c24 3b1d67c2 -> 4359bc8b 42696d1c 4065836c", - "4137531c 409f1958 39805c6d 40c686d0 404a43c0 3a8a7515 -> 428e2ad2 42861cbd 417bb949", - "41635538 c0361672 3b86396c c1161847 4094a7f6 3fc32973 -> c305497e 42b963a1 421d2124", - "414c0d84 c07a1e62 4027d398 3f412300 c0938d67 3e9a8691 -> 4119f216 c2770423 4217a3ff", - "bf2dd160 40920bba 3c2e3409 4019e5c8 3f943924 3b11d872 -> bfd0fc4d 412303b7 40aab4fd", - "c1936392 c091e562 3ba3942a c19998a0 bfd5695e 3f72eb88 -> 43b0dcc3 42ec8167 41ec27f7", - "c19f553d 409c67a0 3d9931b6 412e1e2e 40646ad4 39b95065 -> c358bd70 c18f2624 41944624", - "c0d9fede 40424768 3b0c82c7 c0aa2024 4098e142 3e331093 -> 4210de9e c242bd0c 4181f97c", - "c11137c9 3fee41e0 3d45b680 4196e85e 3f812b28 3bce10e3 -> c32b34ff 41cfa020 403a0af1", - "403b53e0 befc7940 3e17c0e2 bfd3bd70 bff74d54 3f0bdbae -> c09af0c1 c09adc2a 405bc0cb", - "416d4cb0 c02f2653 3c043c06 41454e3c 3f941518 3f3960be -> 4336e488 c184b827 41800537", - "4169aaf0 40568678 4024ea1e 3f8a66e0 c0176dcd 40f2254c -> 417ca818 c1f7716c 432c303c", - "c11869c1 c0910855 3aef4d74 412f6760 c046ee61 3ac4e120 -> c2d0dbad c1a09d9d 4162277e", - "c033f7c0 c075cd04 40fa3ee5 412457b0 c0084ec6 408e61bd -> c1e710b8 c205d6c8 43298e37", - "4114f560 c08a4bf0 3c86a5e0 41999504 bf0818e0 40259d31 -> 4332bab7 c2afd5e1 4217c230", - "c158c864 3ede69a0 3e838ef0 415177ac 408068c0 3e119a1b -> c33160f0 c242ba46 41029c7c", - "411219d6 3e5b2560 3a63faf1 be6a3200 3ca27e00 3a074dc9 -> c005a827 3e0759c6 3c1829df", - "412a72e4 401d7b5c 3c54e351 401c07e8 40063a7e 3d719418 -> 41cfc68d 41e2bc30 40bfce97", - "c17b3fb0 403f6d96 3b051161 c0817f7c c096bcdf 3a6bf555 -> 427e306c 42777698 4161fd49", - "412c0fc4 c0770b02 409f1c1e bff72c20 c087d393 3d60bef8 -> c1a620de c218c442 4240a94c", - "c0db2246 407680e8 3c0f4a02 419fe1e2 bfabd580 3ecbb815 -> c308dba4 42ac5666 4119e3a3", - "c103f53c bf2785b0 3a0bf686 409bcb44 c091593b 3e5f6e92 -> c2209c84 4209196c 409d6f63", - "c190cf89 408b556c 3df07ce4 415718e0 409cf268 3d4f8d85 -> c37358bc c1f1f396 41c53bd7", - "3e8d9c80 c0520c9a 3bca41f8 4178f968 406e69b8 3e316666 -> 4089b993 c24829c9 414f67e3", - "409af680 4027f75c 3d190d33 beb60e00 c08d4c0b 3f5d2279 -> bfdc6771 c1b286ca 4191fe3f", - "40f4d168 c00f00a6 3c8ae4d9 40b334dc c05617a4 3df8906e -> 422b60f9 c2186c52 410d3fdc", - "4122af60 402aaf20 3c029bf5 4101c9be c01508c8 3b1bb72a -> 42a4f528 c002ce60 40ca6066", - "c069de60 be125500 3f1591ce 406fffb8 bfbe415a 3999e335 -> c15b4038 409ca8ce 40517a36", - "4044e168 408a7b72 39d9655c c0821ad0 408e56cc 40534cff -> c1481e2b c07a54cc 422ecb7b", - "c1468b34 bf1a2a30 38f291fc 411a007c bf9b6ef8 3dd4bfba -> c2eee03b 41145b06 40056516", - "c13c81f4 4041bb34 3bf8e64b c0b57d54 4089be76 3f33a0fb -> 4285a42b c287c3d8 41bc0466", - "c131fa32 bf6ce5f8 3f351a51 419f14f8 c085cb3f 3aac51e9 -> c35d31f2 41e0dae8 41a74aa2", - "c1593040 4042a328 40558cff c1857724 be48efe0 3c0cc203 -> 4362764a c2404b1f 42645cb1", - "417c6c24 c0974258 3c3a23ef c04a51e0 40848b9a 39deda7c -> c2477e0f 42a09418 419d5d77", - "40d198a0 c00489e3 3b9558b8 3fd7a040 befed2f0 3ed9a8b4 -> 41308a62 c0d7f3d6 4096a356", - "408559c8 c09ba88f 3c0ee802 41314838 bcda2600 3cac008f -> 4238b163 c258088b 3ed527cf", - "417f6544 c08fdc77 3d74b6c5 419ae8f0 bfa40bbc 40a7bf79 -> 439a8b4e c2d70532 42e51a68", - "c0e1ce22 3f4c39b0 3fe5e46d 417fda84 c027dd28 3a046ddf -> c2e1ad12 41fa1e6e 420e1d01", - "419fb4a4 c07b9cec 40c8857f 40a11050 405d9458 3bbaf1be -> 42c8f591 4245501e 4286097c", - "c144fa22 40361282 40314a4e c11fba5e 3ff8ea0c 3e1dc394 -> 42f5cd82 c2515d3e 422557d4", - "c0200e50 3fe6238c 40c392c2 c191d837 bf8905e8 39664476 -> 42365e94 c1f0ce2e 42efc714", - "4156cf14 bf94f0f2 3b6013d9 c018ff58 c04a538a 3c674792 -> c2006136 c21ea50b 4079d4b4", - "41543148 40834d24 3e41f213 bfa80650 c080d6b3 3b9a068e -> c18b4593 c26b20aa 418ce978", - "c1101c5a 4028f1cc 3945f5e1 c145b8ae 3edc5600 3baabc62 -> 42de9b8f c211fd0c 3f9980da", - "412a6e78 4099125e 3a340199 c194334c 3f590968 3ebbb8dc -> c3455408 c29f2ad8 411ba86d", - "40426010 3fbe3f40 3bc560a1 4185ab78 3eeeaba0 3e93bc63 -> 424afc33 41d2000d 40069cf2", - "419bbbfa c00d36a4 3a613fe2 4134d2c4 c08b7a48 3fee8c24 -> 435c00c6 c2db923f 424818a0", - "4155b300 3f16a468 4083db02 3f96d400 403c56e0 4098fcd4 -> 417bcfb4 421ffe02 42d228e5", - "40fa9808 401006a8 3e8b93b9 400a6ce0 40983100 408fbea7 -> 41878088 42287272 426c6652", - "4052ce30 c0224ae6 39fd2660 4091bca0 c00e1ee5 3c41d53a -> 41700439 c196e7e8 40b68267", - "4180500a 403f35ac 3f7ca93f 40707900 40692824 3d4253a9 -> 42710f5e 428b508e 41991a47", - "c188540e 40846d2a 3bd7c0be 41944c6a be478be0 3f9d8526 -> c39df293 42a01184 41d8046a", - "c1618899 bd9de3c0 3ea19df8 c13f480d bfb6d760 41055f92 -> 43288464 41a87471 42fa381f", - "c04bd040 c0286c0a 3a5a370f c12bdf82 bfcb6538 3ffea0e4 -> 4208d60d 4205510e 417c3829", - "c197c35c c0990199 3e6d63d4 c03ec4b8 bfd2b934 3b4fb6ef -> 42622f3a 4235ee6e 41105371", - "400d8558 bfa2ccbc 38d52a7c 412e3910 407432b0 3b0b18bb -> 41c0a05b c0ad2f8c 409b9494", - "c18e54ee c0266b40 3e980a08 c08fac6e bee3eb20 40219768 -> 429fc29e 419cc205 425b6ffc", - "4038d4e8 4014b330 3adad9bc 416c36a8 bf6f70c0 3cd5c2b8 -> 422a8bbc 41fccdda 4015783b", - "c12c6322 bf9808cc 4032da04 c15e5aa1 c0442d9f 39284c52 -> 4315baff 42462159 424c2efa", - "c12c758c 3fd8ff2c 3c9f1f0f 418c84be 3f2e93e0 3fd0acc6 -> c33d536a 41b36a5f 41af06fe", - "4167cf34 3fbe1224 3d9fd1ef c18badc2 bf6b2208 39b529f5 -> c37cf5b0 c21cef5d 4033733f", - "414aa0fc bf9f8352 3de7bb55 c027bdb0 c0629e32 39ca1106 -> c204c529 c2264eba 40a3b10d", - "c1069f4e c0958eec 3f4e8c1b c0fb5d60 3fcbd684 3de28407 -> 42842f4c 41ba823a 4184d173", - "40937898 c05bbd62 3df47def c1469378 c0434e0c 40bcc0fa -> c264c872 41e4644c 4271daa4", - "c06401c0 bf791020 3a4ea7a3 41934d8e 3ed574f0 3a968b43 -> c2833214 c19b3190 3ed9fb69", - "4144ed80 c075b355 3e69fb0e 4161559c 3e82d4a0 3f8abac0 -> 432d5698 c24bb043 41b00bfa", - "c0fd74c6 3db21800 3b88e723 c1686e3b c08f3529 3915fb83 -> 42e61ef6 4208bb49 3ef08fcf", - "416e72e8 403d8c4a 3ac4d2fd 412e2138 406844ac 3a2702ea -> 4322310b 42aca306 412c82e0", - "c119c434 40889c92 38ec1099 415f4e14 bfe165a6 3c3b1d79 -> c30620cf 429902ae 40f5b274", - "c12eada6 3fdcc558 3c97f0c5 409f1e40 3fc349d8 38df4600 -> c25924fc c10148a8 40303808", - "41891330 406405e0 3fbca694 c081a9d6 3fa24628 3913cd82 -> c28adb37 40e924b6 4145c4bc", - "c00bc0d8 bf1fd3b0 3d0c85df 4197cbe8 c09f7a26 3a145ae2 -> c225bc20 bf76b6b0 407bd79d", - "c109e17f be5d5780 39adf822 4057ce10 bfea0cc4 3c215873 -> c1e876bb 41707492 3ef7cf9d", - "410c0e04 3fb1bcb0 3d4ccabd c19a147d 40005f50 3df2c9c7 -> c3289748 c112fa52 40a1d257", - "c13ee136 4092cfb8 3f69f891 c1197294 3fa00688 3febd301 -> 42e4d410 c26ba885 423f09ec", - "c0bbbb26 3fe36cf8 3ff44169 c0e7ffa6 c03a949b 3a7ae4ef -> 422a2158 408716ea 41c4b203", - "c141aa40 be85c150 3a384a20 c13c7b59 bfdddd26 3c5b5ecb -> 430e9657 41c075e0 3f20c76b", - "40c4d150 c0095c02 40875fda 416639d0 3f24be40 3fd82fe1 -> 42b10080 c1d76547 42ac44bb", - "c0f6952c 3fb6bdb0 3bc3ed30 c18e6747 4081c08e 38f5940d -> 43092a39 c262a194 40bd76e7", - "bfafde20 408327ac 3a1d6b93 c133e5c1 c041f3b4 3e6000e6 -> 41772c4d c227ad29 415a06f9", - "c127ea5c c0497da1 3f93e4b7 40c51f4c 3f9aeac4 3b88887c -> c2814be0 c20061a4 4146350c", - "c1039152 40950f2a 3b129379 41828e92 bf90c478 3fd2a7d3 -> c3063223 42aaa31b 41d414f3", - "c12d438c 3e0895c0 3b6e767b c176c24f bfad2344 3c432faf -> 4327026b 41497324 3ebe9acf", - "40f29014 bfca360e 3c19ab06 418eee6e 4090ec02 41026ede -> 43076dd5 40c352c8 42a439e7", - "bdb89100 c0010f06 3f39e274 415b2540 4061fbf0 3b4bf328 -> bf9dfee6 c1df80f7 419d1b83", - "c1930b62 40991dc0 3b1ee50b 3d659200 4095b782 3a05ab42 -> bf83dd0b c2ab74c1 41b34811", - "40906390 409fec80 3e56cce0 4081b074 3f272c88 3dc9647e -> 41924b63 41b99b53 40a69bb7", - "40418e00 bf80cf76 3af95e06 3ef6e880 405074fc 3c15a8fa -> 3fbaae3d 4115d80e 40549728", - "4100f9aa bfbe72ea 3d59c240 4119eb3e 3e9691b0 3ff0e7e0 -> 429b1776 c13f1587 41984a99", - "c110ec3a c005c736 3abe1706 41536368 c05bff36 3b868b5e -> c2ef55f4 406136b8 40e82bd9", - "40047f68 bef5b480 39bfeb6e 4196d18c 406b33e8 3c34806f -> 421c1e37 bfb82880 3fe66747", - "4029d8f8 4011d6e2 3d5aa36d c152c224 3c85f600 3bdaf014 -> c20bd4ca c1efc8dc 3f464e86", - "41208cb6 c083c818 3f43d016 413d5ea0 bfa50d48 3d6fd838 -> 42ed8675 c276b862 4181c92c", - "4110e358 409b6bcc 3cbd09ad c09984ca c065d46c 3d045fad -> c22dc60e c25f47a2 4190af69", - "41223b10 c0000202 3c902461 c047af20 c02e2e34 3e782e29 -> c1fd15c8 c1aad648 4107e26b", - "4182f258 4034ce60 3fd339ad c0caab96 c09023d0 39c13591 -> c2cf55fc c2b73e48 41f4f117", - "bf111280 3f8580cc 3d3aed62 415e5ed0 408ea082 39a1b8ec -> c0fc078b 413f84a9 40af94e7", - "415ddd68 3e9dde70 3fe28349 c14cb464 409caf44 3c83aded -> c33168c5 427fce12 42044995", - "c186f943 be64ada0 407e8c97 40e4d544 c07d7ff3 3a3acae6 -> c2f14ce2 42827628 4234620f", - "4160086c c0521dc2 3b6b8c26 408dda00 c03497f7 3d8ce691 -> 427846d5 c2584192 4127acef", - "4192fc7c c0639df8 3d0192bd 416be420 c018a6d5 3ec9ca12 -> 438770c1 c2c08420 418d71d6", - "3f5bd280 bf6875f8 39239165 40d13050 bff3206e 3f2e9607 -> 40b3a057 c0f22558 403b96d8", - "c1991250 4072848c 3926271f c0a04444 3eab0180 3de5f0cf -> 42bfa887 c1caf394 4075c80e", - "40c2f588 3f3bbdd0 3b6976f9 c19d7c8d bfc7f286 3f103fd9 -> c2efdedd c1bfa188 40a23a39", - "412476cc c02c85f1 3e7d1d10 40dd5e08 bdabc6c0 401cdd88 -> 428e36f7 c19c14b1 420974ad", - "414163d8 407001d8 3c0c37d8 41949738 407865d4 3f82057c -> 43607fea 42e921a9 41f6bf19", - "407a6420 4098fca6 3b11a05e c16c82eb 3fcb1ce8 3da38350 -> c267545a c280ec8b 410512c9", - "c0795430 bf5a2ab0 3a348c77 c15df988 3fc91e88 3aaebb68 -> 425830b5 40b6762c 3fad93d4", - "c16c6d62 be7d5740 3e1f22dc 4100ae18 4092b91e 3e2ae528 -> c2edaef3 c28b7c18 40b42b29", - "c11b698a 40907908 3f80d2e5 411fe870 c07892ad 3915ea56 -> c2c22751 42a5b1fe 41fc0a62", - "c1930863 405f0e24 4077cb85 c1591eae 40673450 3c7545f4 -> 43796776 c2e36179 429f01e9", - "c0993ed0 c08da988 410ff0ae c1274869 403144d8 3d74df05 -> 424846a4 42041481 43045392", - "c0cbe5be 3e5fdae0 406f94c7 41132370 3f86b7e4 408d52a7 -> c26a624b c096449c 42a8777d", - "40535d20 3f84e0a8 3d969da2 bfed6970 3ed8e320 38fd28bf -> c0c40444 bf06c6a6 3f1b9c27", - "c126abed c07f4a3e 4074baef 411adfc8 400497fa 409a4d34 -> c2c9aa3d c270c56a 430d1a79", - "c19fbe27 405eb098 40099633 c1277c78 c0833912 3f8fe14f -> 4351056d 4235d631 4294b8f7", - "40d07698 c025365f 3d6fddc8 4114d76e 402ea5e0 3dcc5f8b -> 427267fa c0c794fc 410a9a3e", - "c12a2334 407adb08 3e9eba85 c185726c bfb2be16 3c79d766 -> 433160ab c24a226e 4134dfc3", - "41131796 3e8b9830 3bb07050 416dc9e4 c054eed8 3d0dafed -> 4308a0d6 c1d4470a 3faa9a91", - "bfd85d80 3f5e71a0 3b5e7b62 418064be 4086c6a0 3f21cca5 -> c1d907ca 40da6fc5 40ab2460", - "3f3de580 3fb101a0 3bb88a2b c18eaa87 c027cc1a 408d59e2 -> c153a797 c1d4d8a2 4152699f", - "40f1b5d8 c07e7667 3c6ca313 c17d1f52 c08a8bee 3bd6fd10 -> c2eefe49 41f19402 418ca681", - "c09f5f3a 405fffdc 3fb6bc9a 4197843e c03389fb 3e36ef25 -> c2bca6fe 42a08500 422a8791", - "c0e8dcf0 c05bc716 3f016b63 bf4e4f20 c09c1be7 3a500519 -> 40bba9c2 421911e6 419d14e7", - "40677690 c06d4631 3e81972a c0b4e20e 40338f38 3d062279 -> c1a38bc1 41f8d392 414ca642", - "3e23a480 402771d2 3b837a8c 413bc27a c03706ea 39f6ee63 -> 3ff00af4 41f1f6b9 40f15889", - "c12032a6 c04cce27 3e3eff23 412c5174 bf877f8c 3aff7019 -> c2d7aa00 c1beecd2 40b3d77b" - ] - }, - { - "glsl": "vec3 cultmath_af_snoise(vec3, vec3, float)", - "tolerance": "ulp-bounded", - "check": "the arguments are (cx, cy, cz, ax, ay, az, radius, ...) and the result is the form (x0, a, e). Enclosure: for eps in {-1, -0.5, 0, 0.5, 1} and d in {0, +-ex, +-ey, +-ez, (+-1, +-1, +-1) / sqrt(3)} (15 directions), form the point p = c + axis eps + radius d in double and round it to float32; the device's own reference value at p must lie in [x0 + a eps - e, x0 + a eps + e] with no tolerance, so a device whose gradient error exceeds the allowance fails. Tightness: with L = 7.9640074 and, for each octave (one for af_snoise), R = |axis| + radius, B = L R + 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R), the width |a| + e must be at most B + 2^-16 (1 + B). Report the least slack of each side, absolutely and as a fraction of e; only the two bounds fail the check. The reference value is cultmath_snoise(p).", - "cases": [ - "c2461d0c 41488940 c07e9320 bb68fabd be288e0f 3e232bc5 3ca64a9f -> beffc1bc 3e2be983 3fe385e0", - "c154200c 417938f0 41050be4 bde44cd9 bddb2245 3cefa790 3b3cd34c -> 3ee504ba 3cf9f4d3 3f39e2bf", - "c067faf0 c21c93b2 c1c94dfa bb35db00 3bdae5af 3acd2c25 3bdacdef -> bee953ce 3ca5297e 3d0af24f", - "c236ea4a 410362cc 415990ec 3d0b18b8 bd8f1cf1 3d9a37a6 3cf87170 -> 3de3c2dd 3d3e2c82 3f10c992", - "41d1f6dc bfdc3340 c01f20c0 3b9f7bd8 3b1c31c3 3b41665a 3c1cdc28 -> 3f41ec30 3c66bd58 3d1456ad", - "4191738c c1a2f3c2 c211c115 be007580 3cb352be 3ddaed92 3b42ecb4 -> bd614cfc be8b1bbd 3f4f4020", - "3f58f200 c22835ab 41acfdb0 3aa2ac08 bcd45342 3cd46062 3ad20095 -> 3f16b968 3d46a2fe 3d3d1b3e", - "c23e1102 c20a1325 42300caa 3dd9fbdc 3e906f25 3e1c9070 3bfbb52b -> bdd23a0d 00000000 40304b61", - "417f3760 c23a4512 c24726ba 3b6a246f bc701b24 bb364517 3e51e0fa -> 3d83ad16 bb88b1ff 3fc8a197", - "c01dbe40 421a002e 416d56d0 3a3436ce 3a1b036b ba653da9 3ca8bed4 -> 3def6ebd 3b1f6279 3d821064", - "41f68280 c07bd660 c1f9b8cf bc9f0747 bbb189f2 bd545910 3d9d7708 -> 3bc135aa 3db9a1d4 3f2c163a", - "40956248 c1211810 c15cd0bc 3c37df98 3c70c3ab 3c47e6e8 3da03b19 -> 3d884938 bb29a7d2 3edd21d0", - "40657ae0 41f62314 c1f905f5 398ab1f8 baa8afa5 3a0f968b 3baeab17 -> 3f2e43bd 3b20efbc 3c50670f", - "414e5270 421006ac c22be7f5 bc100185 3d2f3fe6 bcb9a388 3bb26407 -> 3df30361 3e6aabd0 3def1061", - "c23cd8ee c094c010 c21dae02 3b1742d1 bb465fce bb7ff518 3b7014cc -> 3f3487af bc0b7258 3c7ad7d2", - "c2457338 c19d12f9 4243f768 3b094bb0 3b0c5426 bae289aa 3de14cc3 -> bda277a3 ba9df30b 3f080f75", - "c1eda426 4232d426 bf842a20 3d6e9677 3ee29130 3ecb07d5 3d0e5d6e -> bd926e3d 00000000 40a109d0", - "420b8d12 42277864 c241d9fc bb8b87b9 bb7be31b bbfd72ef 3d55b614 -> 3c32f06c bbaf9848 3e6a8cab", - "c21949eb c2243ab9 406cc5c0 3a60f1e7 b99916ea 3b4a7e0e 3c5eadae -> be7426b6 bc2b1393 3d848f20", - "41f25fd8 423ff36a c210e38c bb1cee61 ba026a59 ba8666bb 3dd016ed -> be7865e2 bb927307 3ef941a3", - "418913f8 c194ae3b c0d6a1a0 bb3ee6e1 bbf513ce 3bfc3faa 3aad7ebf -> be80db84 3c1a9f75 3c1af026", - "4005b130 40604800 c14d245c be3b4149 3c9bd311 3e1a08e0 3d3aa021 -> bd92cb87 00000000 4010518c", - "c23fa949 c169e48c c23503f9 bd2635e4 3e025995 bdc43cd5 3dcdd83c -> be833861 00000000 4007176e", - "c23898cc c22c052e c1fde2c4 3cd4e3c5 3c60fc4c bc5a14f8 3c46a1ca -> bcd1eb00 bb51e190 3da1b49f", - "402b9f10 c1b6589a 41e97638 3ab5bdc8 3a78c21b ba617814 3e277459 -> bcc51abc bac7aac2 3f86ad0b", - "c13f5754 bf4f8a00 419a70d4 baaf2e19 bac6af50 ba1a8d15 3ba6785a -> bdee80f9 3b174562 3c4c24ed", - "c20b69fe 40164180 c1d86af0 bd53cc85 3d5c6035 bd5f4972 3d9b9f19 -> 3e8bdc90 3c6819c0 3f759278", - "c203634e 41991848 c0dfc318 bbe00bc5 bbd99f71 bbae32ca 3e3c248c -> bec70efe 00000000 3fc67e64", - "c1e6994a 423c2d46 c17476dc 3db0b4a3 3db9803d 3d5b9834 3b6cc85b -> bdc7a7d3 bdec47b1 3f0e6294", - "c2108c9f c1d9e95f c1140ac0 bdb7e96d be379935 3d8008c0 3a8658d1 -> be99a951 3dff0554 3fa006a0", - "41c8c984 42287b38 c0d8eff0 ba368f94 ba8820c8 bbf13e8b 3e9ed55e -> 3e92e363 00000000 4021f862", - "4216f750 c221e5ae 421de69e baa07b01 3b7c486a 3b0e6264 3ba00190 -> 3db84cc3 3bbd76bc 3ca4fb07", - "c1a6912a 420dc904 4212ab1c 3a4e0501 b82b28d8 384e8cd9 3c385796 -> 3d097d77 3a9615eb 3d0d5552", - "4213545e c23edb34 41cc0434 bae8753f 3968304e ba027252 3aff73f0 -> be86120e 3a6be24a 3bba7373", - "c2383c25 c0ec7700 411ff5ec 3aa828e8 3b24cf8d ba46ed11 3e046e28 -> bde900db baf3e614 3f277255", - "423bab08 c0f20580 423482c8 3d2ffeee bc57d0c8 3d1a7ad1 3bb46f25 -> bd5314ba bdf70cd4 3e0ac6ab", - "400d15b0 c20b09c3 40cfe558 bc0d2c21 3a74e62b bbab27ff 3ba5b7c6 -> 3e637557 bca6a5f5 3cb48687", - "c110db14 c236d9e8 c095c2e8 3ba5c372 3c1c1005 3bd6db0b 3c073f50 -> 3e1551c0 bb4782d7 3cb101e8", - "419054a0 41e5ef50 c1d94ebe be3a6cd1 3c1df6c1 3d43e7fc 3c55d7c3 -> 3eb77933 3eb99f10 3f95b1a6", - "c0485400 c2262c96 c20c00f0 39d1b4bc 3b702cd2 396c2885 3ca2e941 -> 3e8ccea5 3b98e540 3da9afb8", - "c1efaf29 bff800c0 4170aaf0 3aa313a4 3aa82145 3a8d4fe6 3cbf194c -> 3e95d663 3b48aa42 3d89c9a3", - "c21c36ef c18096a4 41e2e49c bc0b52cf 3d54c0d0 bd373713 3b1cd69d -> 3f3b5fa3 3dab6e35 3e16ff64", - "419e6c00 4132cf0c 423d9cc8 ba92f360 3a9d0bc0 bad31b43 3a8b1925 -> 3db757fd 3b8e70ae 3b78b48b", - "4110c100 c20b4c54 42376d04 b9f8081f baec2544 3a6a9dfd 3cfda902 -> 3e817738 bb3522b2 3dd7d4a7", - "4005daa0 423ce684 c1d85827 bb0ccf78 3a9f9603 ba69a2b5 3d980c0e -> bd4c51d8 3b18b086 3eccecc5", - "42170b4a 41b165f0 420b6f2c 3e135d33 3e848883 3e9d0dbb 3cc6b565 -> bd905ee4 00000000 4065c012", - "423ed542 c24425d0 40cfc8e8 3e7a403e bd177d2e bde887ad 3c044d25 -> be19ba00 00000000 400ecfc5", - "c03ce630 41615f38 c09466b0 be1f0994 3dc8791b bdfe0dcf 3ab967cc -> befcf22b be8d1524 3fb2dbdf", - "413c1438 c1d6d80f c21442ab 3bf8037d 3c62a5d2 3c7d3979 3a9095ad -> bdc2ea43 3b52acb8 3c893867", - "c1cbdf45 c1af0a8f c1ee1ef0 bc70779e bc4e0a08 bbd9d7c5 3d8b5886 -> be3d4f50 3d1698b9 3ecb0246", - "c2066e8c c0adde88 c211a60f b9701cbd 3bc4611e 3b61488a 3ad6158e -> 3ebb0280 bc58369a 3c07c3de", - "41708008 421d6fa4 41b2cfec bc7b6783 3b2852a4 3c17c23f 3ad88e55 -> 3ee3d64a bc6ae034 3c858173", - "411cb1c0 41ea3e18 c19a0bee 3c4bd09f 3ac871cb 3c4ef413 3ac2a3b4 -> 3cd8c2c2 b8980738 3c43b2bb", - "c234ef43 409d4800 4191aa18 bcb41dbf 3d051048 bc78d941 3c33d094 -> be476ac7 bb7e1eb8 3de6ac32", - "c15fbc08 41dbdbd0 417b9a00 3c4642cc 3c9a5a7e 3ba520ce 3e2ad83c -> bdb4b597 3ce3e183 3f9dcef9", - "40c81df8 c233d3b8 41f24084 bde0da0c bcdb392b 3dd043b9 3d9eb6de -> 3ef89b09 00000000 3fea113a", - "413bcf8c c2175d9b 4207bb36 3b11a2de 3b148d68 3b4fec6d 3d4cc1a8 -> 3e123c18 3a7b9697 3e1d68df", - "417e6560 c22b16bd c18b9796 be88a602 be98b4fb 3e6f36ca 3def151e -> bdca3873 00000000 4093e0e0", - "40eb0298 c18174c0 c2010d5f 3c55a985 bc66ec78 bb30973d 3e469b20 -> 3f09d9f0 00000000 3fd98c3f", - "c1db627e bfc819e0 422df468 3d33cb1b 3db00301 3d90d868 3d4547ec -> bd12dc7b 3e7f3350 3f6ea0fe", - "41d19738 4240f01e 4241df82 baf84eb6 badc07dc 39eb1f8b 3d13e7c9 -> bea963c4 3b5fa641 3e0c4daf", - "4217564e c23cc902 4229bdb2 bbbea7d3 3c224243 3c862003 3cb28ccb -> 3e36edd0 bcf152a1 3daedb1b", - "c1e71165 c23920e4 c1c0a3f0 bdcea1e3 bd882118 3dfe865a 3ce6b4f4 -> 3e42159b bea074eb 3f9a5183", - "41a16ef0 4244d05c 4246e72a 3b8d6f19 bb882ac8 3ba14d85 3da3f6ae -> bd288bc2 bcb31ff7 3f0772c3", - "c1f11599 41a1d298 c200f4c8 baf5db3f 3a822815 3a819e1d 3c9e49b2 -> 3f220bef bb30afc2 3d9e33ad", - "41b8710c 4120c12c 40f17428 be13f2f3 3e0e7319 bd05f369 3d28fd3d -> be9d7ddd bcea9e04 3fe83537", - "41daf308 c0c29420 4004a140 3cefc569 bd931cfe bc986562 3c6b5814 -> bf29921f 3e2d4608 3e95a55d", - "c203afdd c0a724c0 c105f72c ba921d35 ba07a165 3a26e424 3dad29ee -> bd9f1336 bb1138e6 3edfe07e", - "c213b6d3 c1e07e58 c12fecfc bc131ab1 3c6c6758 bc7d84fa 3cac4cbc -> 3f407e64 bd12855c 3dccbf3e", - "c1927cc8 41e24e34 c2178187 3ceb5583 3d4df474 bc5987a3 3e65b2ea -> 3e4576e1 00000000 4010aa24", - "40df9728 c121b880 3ffb9120 3b7009ee bbf8177a bc4c53d6 3b44b6c6 -> 3ebc6a0f bcdc2448 3c821a3f", - "c18b1cd2 41c7305c 4237b4ea bca4fe75 3c8d3b75 bc510041 3c59f049 -> bcbe0cea bd4f5060 3d998771", - "4214c838 4210ae70 41b7898c bd234dec 3e0a0c97 be7374e4 3b59a2af -> bf25902b 00000000 400e8774", - "c23dbc19 c23bb1ed c1437c1c 3e6dda75 3e084e79 3dcab699 3b8025ea -> 3b4d9c60 00000000 40138924", - "c22d3698 4091dda8 bfd3f3a0 3d3c7512 bce72037 bd898f01 3ea41de4 -> 3f30225c 00000000 404f54c1", - "c1e89b2e c1e566c7 c1253604 3c9b290b 3d326f0c bd495713 3d68e16b -> 3eb863f7 bd985cf5 3f14cd3b", - "c115b664 41a3f9f8 41dbb560 be15aad9 bcf0e501 bd178a26 3e65849c -> beada6ca 00000000 4040934a", - "c1c7aa59 c18ab8ae c13a5c84 3cf0a949 bd14dd77 bca5d747 3d271b55 -> be27a594 3d205051 3eb47623", - "c228b0ce 41bfeda0 40d7c418 bd9185de 3d2169ba 3cdfb897 3cfe60ea -> beb264a0 3e7064f2 3f064f09", - "41e974fc 41f10dac 41b5fdb4 bad5534b b9e22fe0 3a1aec7b 3b97bab0 -> be569e9f ba58ebe8 3bc2b9f3", - "420a4b28 41b65324 3f0d3c40 3b493b4a 3af2d71e 3b5bfd80 3d44df10 -> bd845d10 bc978a5f 3e934ad3", - "c2199e96 41349b78 c09e53c8 3c830a94 bacff359 bc6e8e39 3b02b5dc -> bd9754bf bd62eaf6 3cb2724f", - "422ed30e 41f02b68 41441b78 be0d9b6b bd120669 bc841a38 3dc0ab09 -> 3e984c6f 00000000 3ff28118", - "c226aa00 c1de6476 c21e3ee0 3bc211c2 bc059799 3af3b56d 3e169144 -> 3e1f1425 00000000 3fa074a5", - "41cbed00 c211335e 41d5e5d4 39b17b3d bac8d1a3 3a079327 3bd89512 -> bee348ed ba330dee 3cfacfbd", - "41c20bf8 4231cfd6 41656fe0 bc9c8205 bcc52336 3c04f6fd 3c0388ff -> 3ebddd3b 3dfa1cea 3dafff84", - "419e6654 413a4e10 c1a766e8 3c72014e 3c0d9cf8 bcad2490 3c5f22a0 -> beb758d4 bbc47048 3d8de246", - "c1bec7ff 41dbadc8 c21b1465 3d04c245 3c6f4f69 3d9e8aaf 3e967551 -> be81cf31 00000000 4041411a", - "c2360bc5 416c6ec8 41aa80b0 3d5e9dbd be11072b 3bacbd99 3e52530a -> 3df7e87c 00000000 40361b13", - "c2088cf8 c190f5ea c2107112 3b42cbb9 3b888ab3 3882f305 3ea5cc71 -> bee83861 00000000 4027b6ca", - "41284d20 41d77904 41b22688 3ac8d5db bad43629 3ae95cd7 3ac3f043 -> 3c063524 3af3b259 3b100eac", - "c21f2073 c1744ad0 420624b2 3e1b19f9 3e075ce7 3d31140c 3b37d223 -> bd0bd4b8 bcdb1738 3f9c30cb", - "c238b6f6 41b76a7c 4024eb80 bb8d2a5a 3cbc84eb 3c2cac28 3d96da5b -> bd426809 bbd01c9c 3f088fa5", - "c220c5af c0d27478 c17a076c 3b1cab54 3c4c2c9c 3bd2361d 3c1f3eb8 -> becea382 bd0fba39 3d455394", - "c1b910af c1fdf482 c214e6f1 3e44115f 3e29976b be89a146 3ee18b90 -> bf0ee728 00000000 40ce666b", - "418817f8 416d8870 419d4c80 bbb4cdca 3b5c320a 3bd56cef 3b9b02d9 -> 3eed274f bc0c01f8 3ca60c40", - "41941eec 423d3358 c1d8d373 b9bd960e 3a9c4163 b7fa1b60 3e08ab34 -> beb34fd1 3a41f8b3 3f540746", - "c2168529 c23b8cee c2472bf5 3c0cf5dd ba9192d3 3a077900 3c032136 -> 3e3d9be1 bb33d8d1 3cdae9c4", - "41a7a27c c042cb10 409e1cb8 3d982804 3d7c44e4 bd4bc004 3b8aa8de -> bf11f9e3 bd753a06 3eba4a33", - "41b4f950 4094dfa0 4222d724 bdd54ab9 bd5d5669 3bb8aaa5 3c424679 -> 3ee01606 bd9fd59b 3f01490b", - "40931578 c2227e8e 4200759e 3b38a853 3bca6587 3d13fe74 3c079d08 -> bd7eae4f 3cd9cf37 3d9e5efb", - "419a9f5c c17f1628 41dda9cc 3dcf8831 3c0f179d bda599c2 3b617f36 -> 3df095f7 3e4575be 3f015df7", - "c211f2d0 c15cae20 415411b4 bd601a65 bd7f1bfd bb9ee6fa 3ebebc1f -> be79e8e7 00000000 40683ee6", - "4180ddd0 4246c5ac c18a90a8 be23d443 3d871d1d 3d631891 3e27c2dc -> 3f21be68 00000000 40302d37", - "3f882560 4126dec0 422c5a04 3c74695d 3d30f3bd 3cf0ba21 3b0e5c10 -> beaefc97 3e032fcf 3dc36630", - "c02822d0 c1e86fed c2230915 3c66bed2 b9b12103 bb11f07e 3b633f78 -> bf0129cc bc194b5e 3ca002bd", - "c1a8a6fd 41a6ab94 417b0200 3d1d3dfe 3d92a53f bd68b9f0 3c80fb36 -> bedd5b69 be0d6581 3ee2b2df", - "41478814 42138c00 4226e714 bc662621 bc9bc27f bc2cbc93 3efa51a7 -> be16f938 00000000 408338a8", - "418bd498 4236c60e c1963a36 3a2d1955 3a6a96bf 39b0573a 3b636f23 -> bd336746 3a14a726 3bb40c40", - "40d3d170 3f46ba80 c1d9c5af beaeaa31 bea80cff 3eb10a19 3b3ef3d5 -> befb4c94 00000000 409628bc", - "40dccbd0 c2154916 405b3710 bbd334e6 3bbac905 bba13c2d 3d96f1ed -> 3d939d7b bc1c6444 3e8f5269", - "c1642930 bfa01020 c246a026 bdfe3fe0 bd819d25 3dc161af 3bd55366 -> 3d320f5e 3edf7889 3f5fcaa0", - "421c7172 c2217063 41d47108 bea4aba1 be8a8b65 3dd55d3e 3d77ee79 -> 3e9b2c99 00000000 407ba151", - "c2081690 c08a6df0 c1f5806c 3a03e975 ba8cb461 b9c137b1 3d268bbd -> 3e44952a 391d7cda 3dd524ba", - "4214f352 41c43118 423d1856 3a23b83c bb12a342 3b06fdd0 3df31b6a -> bf25c2dc bbdebc64 3f4b35ad", - "41f63d94 4140e298 4208f704 3a00e75b 3a88f374 baa2c48d 3be40608 -> 3f088596 3b683da2 3cca3fed", - "416185d8 422a94e0 c233df1c be0e36ea 3e9568e2 3e94ab29 3c0864ad -> 3de8a823 00000000 4061bf89", - "400d8070 4215b484 c20a9a44 3c83a0fe 3d15e402 bcf67ffe 3ab505b3 -> 3f108c97 be2bd979 3da53210", - "c23249c7 c1141638 422395b2 bb1be944 3b280fd0 3ae8c8b6 3e7cb1cb -> be504ab6 00000000 3fffaa3a", - "c20fafd1 4246e468 c1f727d0 bbedf519 b952789a bcf26f18 3c3c1330 -> bef6d5d0 bdc377eb 3db6e4a3", - "c1b4883e 42186e12 400eb340 bcfa19e0 3b1eee2a bcaac181 3e6b8f66 -> 3ec09b54 00000000 40082beb", - "41c80f04 4152f960 412e8478 3da64a41 bcf238ad bdd27caf 3e299e4e -> 3ea43568 00000000 4018e694", - "400082a0 41e861e8 c23293d8 3b36740e 3b50c28d bb6f08f1 3e8e71a8 -> bdb53598 00000000 4010b211", - "c1bd629b c2064924 41da62e4 3b51ee3e ba277008 3b9bd6f3 3a995e48 -> bf1ea68d 3bfaba5b 3baf8aec", - "4208034e 41d0bf40 c1988c87 bc52c6bb bcb9fe69 3dd6c040 3ce3bc45 -> bf2b0b66 3d9e04d5 3f13cfb3", - "c22a26dc c23a4fd1 400f7cd0 bd2d8a20 3d398e2c bd585660 3df3d9a2 -> 3e7efdba 3d4fd63a 3fa4d85c", - "4230e6b4 c1516060 c2398356 bb966b0b 3cd17747 3b35f247 3c1de448 -> beafa1e5 bcd6807c 3d6c4fc1", - "420c2c7c 413b283c c11da73c 3a635301 bac7bc3d bac72621 3be2d489 -> 3e0647b4 bae522ee 3c66febb", - "418d59a4 4106166c 42298a48 bac96baa ba7f6a72 ba027edc 3add6d83 -> bf2aadff bbaa6035 3bec9095", - "424579a8 3fefb240 c20e85dc bd1ab186 bd237e99 3dbfa61e 3c1d71d5 -> 3bd36372 be348758 3ed5365e", - "c214117d c24654ed c18d0e04 bb419bc4 bb8b46a3 3b230d3d 3a9845af -> bd5c0811 3bd8ca8b 3bc7bde4", - "c1dab1b1 4231f4ec 4240bbd8 be3836c6 3da2e882 3de41e35 3a898647 -> 3e708668 00000000 3fe7a1b2", - "423a6c60 c1e706fe 423d24f6 3ce37bfc 3cd45875 3c45460b 3db383ae -> 3ebffccb bdb84e88 3f3d66d0", - "c243ace1 4234c018 41227774 3ddd3038 3e070574 3e992165 3c979210 -> be931683 00000000 4038f2fa", - "4207481a c238ffec 42386962 3d492c41 3cd841e1 3da8f812 3beac839 -> 3f3f9277 be2af61a 3eac169c", - "c247458f 421fe4e6 42119ae6 ba8d4252 384c54f6 baf5460f 3bc40fbb -> 3ca4795e bb59ec3f 3caaf64e", - "41b84a60 c2119d62 420f3114 ba0ff365 bacf0af2 ba2ee129 3b505186 -> 3e96a23c 3a0b9b4c 3c46d924", - "c1a19673 41269ea8 c0eaca98 3c0b959d 3baa142b bba00380 3ccb0a9f -> 3efe1c98 3ca68f7b 3dc5e9c2", - "423b2f60 3f9fe560 c244a2c0 3e76612b bee455d4 be6ce64a 3c03c5d5 -> 3e9ed054 00000000 40900abb", - "c19dde82 4179c890 4082f928 bab05f88 399466d7 b88f3f89 3cb65ef8 -> bd169103 3b03b723 3daf4df0", - "4220b8f0 c194f8c6 c1f4a4d1 3ca1e3c2 3c8a2995 bcc9b013 3d2d15b8 -> bf0976b4 3cc21604 3e93afcb", - "416e6110 41dc0254 c0b24d40 bab827f4 b95238e2 39913f5f 3c0b6863 -> 3f0a34c8 3ad81f90 3cdb38ed", - "40991a58 c173c4f0 c20c1439 3a2059c9 bda96ffe 3c0209d7 3d90302b -> beab6ba4 bc400612 3f4fbeb6", - "421493b6 4010eba0 42157204 3d2b8798 bd249858 bdad1cd7 3da8c766 -> bcdc4ac9 bdbe0608 3fa65fba", - "c215d020 422b0300 409cb420 ba98edb8 3c241776 3baa9c33 3b397237 -> bdf859de bc270ac6 3c7605d7", - "c09b9548 c11609e8 c1738bbc 3dad4868 be9f6923 be9cf21c 3e43a829 -> bede6957 00000000 40a22051", - "c220e48c c1f2c5d7 403261d0 bc3ec6a0 3d4260b1 3dc0859e 3e481c1c -> ba9fb3cd 00000000 4019a648", - "41d8bec8 3f7d6a80 4183dae8 3bd94245 bb425991 3bcf1cb5 3c047989 -> 3ed37c3c 3a120bd0 3cc26301", - "418708b4 41bbb970 c2428eec 3b95876e bb8d48fc 3b8b6b24 3dc23a4d -> 3e71a554 bb5f0ea8 3ef79e85", - "4192d928 4240ff34 c1b265f4 3a450673 398be58c bac81f1b 3dd39944 -> bebc9c1c bc0132f9 3f4e5986", - "c12dc124 c23c826d 4176f508 3c4f2603 bbb71e25 bc267653 3c28d02a -> 3edacc8d 3cad9768 3d6bf71d", - "422cb184 41a05ed4 418af244 be8613cf bdfe4619 be477460 3b1ed346 -> 3eacc7d9 00000000 40334330", - "bdb1f200 c2435ccc c19f1efb be2e6acd 3e1f5f60 3e43f3c4 3ee85d00 -> 3f0db625 00000000 40c0137b", - "c193b465 41ec8688 c2348ff2 ba6ea8e2 3c5ea012 bc475611 3b6062e2 -> bea7f541 bd2ccddf 3cd2a99e", - "c0e85ac0 422787b0 422f4b80 3da8b635 bd478f2d 3cdfb604 3bccbf0d -> 3f07a4ce bebd0546 3eb14733", - "c068d8a0 415d7a88 c17844b8 b9e59311 3b4ccaaf 3a1bdd52 3c0f8f9c -> be8e5e5e 3bb7c696 3cbc4d67", - "41c1c6cc c2122734 411cb694 bd0bb139 bd2e476d 3ca448d5 3ce670aa -> 3dd7ce20 3bd6aadd 3e835272", - "c222f113 41883ff0 c1fd734f be279492 3e973366 3ec0f228 3aa0ef47 -> 3f07533a 00000000 40814961", - "40b7e8a8 c01b6e50 40260770 ba6632fc baaf414e b8d98f86 3ae633cd -> 3e31ed05 b9981e00 3b82abcf", - "c07de5e0 c24573a7 c11a6110 39c3daab 3c0d9e31 3adad382 3c364a94 -> 3e25418a bbd8e6fc 3ca6fdf2", - "c1e49928 419f94e4 41ab1988 bb566b12 ba5b4115 3be54c59 3b74dab1 -> 3d060a92 38702640 3c434822", - "c1ac4267 c11d9628 41f48890 be7fbf54 3d66ec76 3eda7b6b 3d67176e -> bb846395 00000000 408d3918", - "41bd3934 c1968bc2 41716528 bda159cb bdf7a5bc 3eba3768 3c454cc7 -> bea90450 00000000 404d9de3", - "416b01a8 3f3c3dc0 c1d52023 3b54f734 bb67ae0b bba189ef 3c1e5ec7 -> 3e745d03 bc5b6615 3cf8b660", - "c215784e 41ec8568 41dc0330 bd202111 3bcb07f1 3cba70d8 3b0093c9 -> beb086c9 3df66766 3d96a7df", - "409ebf80 c194dac6 4232ec82 3d102c57 3b584f9a 3eb55e60 3e88624e -> bedc109f 00000000 409ea23c", - "c23927b0 41cbdeb8 41bd8348 bb3df507 3a0f0828 3b5a04eb 3e5d7cb9 -> 3eec0e81 3b5e0630 3fd847aa", - "41c540a0 c1951c17 41996e60 bda1b354 3d368ef1 bce30019 3b0d9fb0 -> 3c80e5b9 3d644aac 3e889983", - "c1489ae4 c0bd9300 420f3432 3c07fc7a bb948996 3ab478e7 3b407c1b -> 3d787853 bbb67f21 3c461e62", - "40fea4b8 4087e7c0 c1087014 b9b1598e 3acf89fe 3aa4da57 3b1fe7f1 -> 3a970728 bb2b91e1 3b80bc8c", - "41636128 c183ca50 c1d94b9c b963b0c9 3a75c9ad ba1e69f1 3cf522e1 -> be8608d9 bae9b985 3da870a6", - "41f80184 422412b8 4217c560 3dcb6925 3df04fe5 3dd72d76 3e80b1e6 -> 3efdfdde 00000000 405f16c5", - "422583d6 4201585c 41401ef0 3a0a0e77 b974d35a bab884ed 3d99025b -> 3f518b0d bb8c0d0a 3ec176ee", - "c1ea3768 40cb7bc0 413d8494 bc983448 3cb4a4e5 bb077615 3e09ac4b -> 3e6758ea 3c0b3296 3f86967e", - "c0a12468 409a9a10 c20b7a16 bd042127 bd98f070 3dc313ab 3cf3bf9d -> be1397ec be159edf 3f3c3e42", - "c20aea0f c196ee48 413f822c bc8a0c99 3df84873 bdbd184a 3d5bfcb1 -> 3e3e8a0c 3e6fc26d 3fad88da", - "416f45e8 4024ab60 c20254c2 bc41bc5a 3ca0a608 b912e455 3b6cb69f -> bcb75721 bba9ac1b 3cbebc12", - "c1dcde97 405d03d0 420beb6a bdf95a09 3dda683b bd4ba50f 3e94c781 -> bdacd2ad 00000000 406a7469", - "c0a82100 c22391cf c181c02c 3b8c77a9 bbee11e2 ba28fafe 3d0e4a28 -> beb07d40 3c01300d 3e0e9ad4", - "c216b2c6 c22a4617 423120be 3ba529a1 bb8acf04 bb8d2ed1 3c83f9e7 -> 3f10580c 3a753e68 3d708e36", - "c1be9eed 423f13e4 4219f088 3cc2c84d 3d274f82 bbad8d0a 3d8d721b -> 3da46a90 bdb84453 3f17cb72", - "c233e861 4231e500 417a1520 bb686b9a 3e38ad4a bdb2f14b 3c43d66a -> 3d9b99b7 3df1ba5c 3fa3b839", - "422bd5e6 41a5e550 c0e21d20 bacea02d 3c1f3918 3beaf795 3d56b130 -> bdcc2910 bc09d068 3e9577f0", - "c22c6a16 412599e0 c08e6c68 3b5c0ef1 bb630f15 ba93b3f7 3ef0300f -> 3eb39ea9 00000000 4071ac24", - "c19c617d c11ba4b8 411da408 3b4d6b75 3b07199b bb2d549f 3d08122a -> bd87e2f3 bb54e136 3dbc8d0b", - "41616198 417a9120 c1b5af49 bd5dd42d 3cb680e2 be233b5d 3bbed10f -> 3dafc5b0 3e5340f8 3f5fd0eb", - "41bf2ccc 408c03c0 c118d9dc 3a9d0c25 3ab7d2d5 baf48cd0 3bbe5476 -> 3c7c10a2 bb25a5d9 3c27e9ca", - "c21637f6 c1c996e2 40e0be00 b99e2351 baad5d5d 3ac4926b 3e7cf616 -> bdf16ec9 00000000 3ffdf7f7", - "40acd768 41858cf8 411513ec ba6e2f3c bab6f428 38def2c1 3b51a499 -> bdf9cd2c 3b25ab3b 3c35e4df", - "3fed8c80 421257a8 41b984c8 3d44faee bdea39fc bd521db6 3cc30896 -> 3da093e7 bba91a30 3f3a72d5", - "40275560 c2032930 401f1160 3b443b4e bb24a0c5 bb6ec9c8 3c8423ea -> be4f0b62 bbe4885c 3d3a6e93", - "c14337f8 c1939123 c21cb19d bcfeae16 bd2791a6 bd0dd7c9 3c8a3000 -> 3c3f0b74 bdbac0a2 3e5297ec", - "41f0cf74 c1354c3c c1a8fd07 3d8abeaa 3d90f579 bd886028 3d560868 -> 3e6d9f0e be96773c 3f761d73", - "c2429aaa c1e20e23 410fdf20 be83e19b be29abf1 3d593a9d 3b051f85 -> 3e7adf3c 00000000 401f83df", - "423b08d2 c22fdd9a 41162f4c 3ad07900 3a3e4eb4 bb70eb25 3bb18299 -> be100548 ba56f4bf 3c0df863", - "bfdc5860 c20da416 41aa15a4 3e9ff348 3e847c72 be9d0338 3c863215 -> 3f258785 00000000 4085cab1", - "41b8af54 c1b20f6c 4239e3c8 3b5358e6 3aad6b92 3a27c9ea 3cea46ea -> be00c12a 391bb04e 3dd34a5d", - "c213fc40 421b67c6 c1b94d77 3c3753d9 bc734322 bc29be17 3b0953bf -> be94b48e bc687abc 3cc8e7b1", - "41beb8ec 4245b5ca 41751f10 b8d2e890 3ac71c2b 3a9a0dc9 3b869f0f -> bee54054 bb4559ca 3c06fa2c", - "c1bff79c c241338a c1eaa6fd bd976991 be00a1bd 3d3e5f52 3afa3b20 -> 3ec9623d 3eb4baf6 3f2db788", - "c1edd443 c20fef81 c1e93388 bda413e1 bdc10586 bd2bce42 3c2a5736 -> 3e2b7586 3e08df3d 3f11f12f", - "3fd11400 c2323537 c21575d8 bd42e357 3ca941c6 3c9f1605 3b8fe28d -> 3f120a03 3e2d271c 3decddd1", - "420196a6 4115c874 c1fa169e b9ffb342 3a534341 3a791457 3e4ccfa4 -> bea107e3 00000000 3fcd56cc", - "bfc69300 41bdf404 c2305a89 bc978c7a 3d12abae bd19b81f 3a8ec908 -> be215327 bcc9ff7c 3db93967", - "c1cac5a9 c2064184 c1807842 bceb3bfa bad30653 3ca4baae 3ca260cb -> bd81d10b bc8adbaa 3dcefc93", - "41232c90 c1b2be18 41190a14 3be1b75b bc56c78d 3c3cc2ac 3d888808 -> 3e3391a5 3cfa8d08 3eb671ff", - "c0c7d398 423b7a9e 42466902 3d71a61c 3c9fe543 3d43edae 3bd38aad -> 3f3fa311 3d513dae 3e5b0105", - "c205dd82 c165fd64 c15a7f94 bc9d431f 3c43ee41 3d008ff8 3e0d1ebf -> 3edb1868 00000000 3fb3ff04", - "41e76678 c21af7ae 40298460 baa08ad4 bb14defb babbe422 3c1052f2 -> bda13306 bae883be 3d0abea3", - "41d71ddc 41a59318 c12308e8 be2e8b0e 3d44c4b0 beb4f67b 3c9323b1 -> 3f541e72 00000000 4052b0d0", - "41fc69d4 c13a3ee4 c1ba481e 3bc5e457 3b13065e bc3429de 3d2fc02b -> 3d845c36 3c8761ba 3e1857d2", - "c192b304 c2383a15 c1351380 bd5abf9d bd0260ec bcf566fa 3e96b51f -> be68728a 00000000 40394068", - "c1aca0b8 41f2a800 4151ed0c ba37ca9c 3cf58f8d bbf35092 3c51f94b -> 3e261a96 bbe7f2e2 3daca82f", - "41d59bac 4169b068 4224a870 bb056f3e 3b3fab2d 3b805980 3d36cc22 -> be688573 3b954814 3e315418", - "c1c2fa04 421f8c22 41c10d30 bccf2c4d 3cc7f122 be0dce5a 3b69c5ef -> 3e65af67 3e6ee93a 3f1b961e", - "c23cec4c 4228bccc 4201bfb4 3a843f80 39230961 baf55fa1 3cb88ca1 -> be0c2037 3aa4aacd 3d2c11d7", - "c0eeadf8 bfd086c0 419c6464 3c9ee37f baee8a88 3cb0e6de 3aa284bc -> 3ec1b1fa bc674aa4 3d011f29", - "4235463a 420ebfae 416db430 3a16fb15 3a9e5944 b9f2cea5 3c853ade -> 3e87b5c2 3a5e56fb 3d094aca", - "c23562a4 41dcb048 c0f3f440 394fccc2 b983d1ce b83d273d 3da67eb3 -> bec8ea51 b8eace08 3ef5b8a6", - "41bf2d28 c0eabe50 41332f9c 3d02aa9b bc9d8ffc 3c9a72d1 3b96a3c1 -> bf03530c 3de42ee1 3d99af11", - "c1155cb0 c10efb44 41ed32d8 bd974378 bb20a400 3d2d801d 3e105d68 -> 3e602e32 3d040628 3fc2e275", - "422b1754 41a5612c 4210d558 3ce93242 3d035bd4 3b094e3f 3b367a35 -> 3dbc19f1 3d4905f8 3d85dc83", - "40c329e0 c146c284 c2085825 be31dc53 be50e555 3e51d88d 3ec706c6 -> 3db6cb49 00000000 40b90cc9", - "4243e704 424338fc 41d3d5a0 3c7a0bd5 bb903808 bc9776d8 3dbdbc37 -> 3d0c398b 3c98e2a2 3f02458b", - "c2252e6a c11ae1f0 418c3858 bb91353c 3a870507 bb1604d9 3d030631 -> be2fee50 bbfb1b78 3dda87f1", - "c224c69d 414c721c c1acd3aa 3d0b979b 3e10232b 3dbb05ae 3de1f18d -> be1503ea 00000000 400f8b2d", - "421e0ce6 c0a8b6d8 c243c2de bd03a3f0 3cf59a17 bcd5a601 3c2ccd2c -> bebf64ad bda6233d 3e0b9f5d", - "c0cc27e8 4206f2e4 41d8423c 3ab92905 bafecea7 3b38bfdc 3cda80a6 -> bddfb159 bb35ffb7 3dd3afd6", - "414de710 c2128c0b c01640e0 bc254755 bc45e1d0 bcac29ee 3ec8602d -> bebc1ef2 00000000 4054e467", - "c2201cfe 4122c6a8 41dd3948 3c147a28 bc526849 bbb0bef9 3abd9726 -> be60b16f bc5bbe60 3c487927", - "c1e8edaf c244b358 41223c84 bb301a46 b88b4467 3b81231f 3b4af11d -> 3d1bf59d 3c080b88 3c32f853", - "c1c36e59 c1a2edc6 42027b8c 3b33f959 bb5e708f 3b356599 3e871420 -> beb920cf 00000000 400926d9", - "4190137c 41cca28c c1f7128c bae1812b bc162ac0 baf755f2 3d48ba28 -> be32dc85 3c31f3fd 3e4dffa2", - "c1718858 c233d8ac bff265c0 bc59910c 3bcfe2a8 3b9e6f0e 3bbcb75a -> bed721df 3c7205f5 3cf95843", - "bfe0a840 41a8c2b0 423e41d4 3c7cab55 3c032a7b bd7d8fd7 3b145f10 -> 3db8ea2f 3dbe60f0 3e06a639", - "c03b0740 c1a43b25 c1b88de9 b9001163 3a4efc0e ba4f9bc2 3a89e062 -> 3db4fd18 bb3e3d24 3b82a7e0", - "41d6efa4 4217e5fa 41e80124 3edcacd0 3eb70573 3dc8f8d4 3ec18d90 -> 3ee4cdb6 00000000 40f14053", - "40bc5620 423e26fa c23334e8 bc02192e bba1e241 bbf05824 3d15392d -> 3cebfb60 3c339561 3e4a3a8e", - "4180eb54 408eb1c0 41c553cc bad3a44d bad31177 ba54cfc9 3b163b32 -> bd9db823 ba664a9e 3b73f96a", - "413a86bc c2301c0d 4247eae0 3b2af1ff b9ad38ab badf6e7c 3ca1de3a -> 3d53d5a3 3b90cdbe 3d979f71", - "42283fd8 c02d4ce0 419c2700 3b6eb148 3ab57258 bae00e1c 3d28bd87 -> bf48e082 bc22c8e0 3e29bca3", - "c21dd324 c23f9961 c2091b10 b9febcc6 3ce0b479 bd0fc9e0 3bb1868a -> 3c1ab991 3bd3b354 3d999864", - "c1ceb757 4198c930 c1708a10 be4dee66 be859196 3e55efa9 3d6b78d8 -> bf43b721 00000000 406427b5", - "40e91718 417a8270 c14dcd6c 3e58e9cc bcf20852 3e847b8f 3b0a6d23 -> be5916ae 00000000 402c3640", - "41e9d014 40e69e30 c1034778 3969c314 3c91fe86 3c374f8b 3a8ee9ad -> bc3cc926 3c97b892 3c8bfaae", - "c1dae051 c20c931f c2425fe1 3ad973d9 3a360394 3a03445e 3e236e37 -> 3d529c6e 3a85d7e6 3f744771", - "4231cb58 41b668d8 42270488 bba77add bb2f58dc bae84f97 3e92fa8c -> 3edb6c95 00000000 40157490", - "41012484 c2369a2e 418ce520 baf6be46 ba3c4749 3aeb1332 3d768676 -> be58290a 3bcf3624 3e9386f0", - "c2337fae c2393715 4200e490 bd94d81d 3d36a176 3e2a01ac 3c78a1a7 -> 3e590b84 3d3e3574 3f95c76a", - "c247fc0d c1836620 41898648 3ed884b0 3e81b803 3e278634 3e740ba4 -> bec03c1b 00000000 40c122ed", - "c240e0ab 40b16498 4237afaa 391ff3aa 3a73fc50 bb22910a 3cc01aac -> be98ac14 3843e420 3db82549", - "c1e44db8 3f423340 423905d6 bc553488 bab6d05e 3c08716c 3e1f65a7 -> bc8fb0f5 3bc1f562 3f73b4ee", - "c0cfea50 c1680478 c2368762 3e6b16e3 3e094688 bd299219 3c260a75 -> befa6cc8 00000000 400e5825", - "4238038e bffee4e0 c1a4e745 3cc7d463 bcce20bc 3db744ee 3e0587df -> bec23c1a bd0efd54 3fe00d58", - "c16d8a98 41ec8c54 c1e59844 bc012e78 3c24970e bd857b20 3c290ee4 -> bec731fd 3dacd1dc 3e48c93b", - "c245c1d5 c1942f0a 41a6638c 3d4ea696 bdb5a227 bdb3f7fd 3ceb09ea -> bf5c99fe be175a98 3f4a8269" - ] - }, - { - "glsl": "vec3 cultmath_af_fbm(vec3, vec3, float, int, float, float)", - "tolerance": "ulp-bounded", - "check": "the arguments are (cx, cy, cz, ax, ay, az, radius, ...) and the result is the form (x0, a, e). Enclosure: for eps in {-1, -0.5, 0, 0.5, 1} and d in {0, +-ex, +-ey, +-ez, (+-1, +-1, +-1) / sqrt(3)} (15 directions), form the point p = c + axis eps + radius d in double and round it to float32; the device's own reference value at p must lie in [x0 + a eps - e, x0 + a eps + e] with no tolerance, so a device whose gradient error exceeds the allowance fails. Tightness: with L = 7.9640074 and, for each octave (one for af_snoise), R = |axis| + radius, B = L R + 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R), the width |a| + e must be at most B + 2^-16 (1 + B). Report the least slack of each side, absolutely and as a fraction of e; only the two bounds fail the check. The reference value is cultmath_fbm_grad(p, octaves, lacunarity, gain).w, and B is the sum over octaves i of gain^i B_i, where B_i is B for the centre lacunarity^i c, the axis lacunarity^i axis and the radius lacunarity^i radius.", - "cases": [ - "411c537c 420ffeae 4078d1a0 3cdfc7fe 3ced8823 bd581451 3bd5bfdb 00000004 40000000 3f000000 -> 3f1c017f bdc20710 3fd2f8e2", - "c2172004 410ab7d0 c1f2ca42 b9a78fc6 ba1d7262 3a8c08d4 3e338f4e 00000004 40000000 3f000000 -> bea9d56b b95ec7d0 40b0ea05", - "4115776c c2005a28 c21c7d94 bb82d4de bbf99288 bb14556b 3e706f99 00000004 40000000 3f000000 -> 3e0cb256 00000000 40f88286", - "c1dc368a 41869c94 4226de20 bcfe94ff 3b70c570 3c88304e 3d6c7520 00000004 40000000 3f000000 -> bf10b24d 3d77694a 401c59dc", - "c203bcc0 41cb2bbc c209d08b 3d98457a bd489b84 bdcfb707 3d19027b 00000004 40000000 3f000000 -> 3d8f1a2c be4d5c90 40a0b74b", - "41e45754 42248ae6 411d2fac bd7d08bb be3dbc00 3e5fb94c 3dbc85a8 00000004 40000000 3f000000 -> be1bcf46 00000000 414455cf", - "c0ff5658 4216c372 c1aea658 bc0f34a6 3c62e6bc bbc51abb 3d16dd85 00000004 40000000 3f000000 -> 3db396b2 3d0fb0eb 3fadf568", - "3eaaf500 4180ac44 c105a4e0 3a9cdb0e b920ef6e ba380c9d 3d088bb6 00000004 40000000 3f000000 -> 3e9e0360 bb918bc6 3f41cdd7", - "4201700c 408d4338 42173afe bd1957c4 bd11a659 3d45b37c 3bf04183 00000004 40000000 3f000000 -> 3dbb520b 3dbf9818 3fe33039", - "c20c49a6 40291410 40962208 baaa709c b949a8bd 39947c97 3b1fa49a 00000004 40000000 3f000000 -> be925bbe 3a69b13a 3cf0f01a", - "418bdb28 c1f8333f c211ebc4 ba84873a ba463c1f b95ca930 3b5a553a 00000004 40000000 3f000000 -> bf770906 3b95ac4f 3d269588", - "c07870c0 40f13610 c1c85790 3b1283eb 3b36b039 3abd56b7 3bffdb24 00000004 40000000 3f000000 -> 3d822045 bc9bcf63 3e0c92f5", - "413c9a20 c23a522a c236024b bdc256ec bd305cf0 3d093814 3bb9292f 00000004 40000000 3f000000 -> beb0848a 3e05dd8c 403e9559", - "421c32d8 42387e66 c1af30cc bc15aee6 3d74e834 bd35d262 3a901e4e 00000004 40000000 3f000000 -> bf049507 bd8d8e0e 3fdb1326", - "c20eaff6 c1b56412 c10f2d70 bcb56591 bd29e076 bcd5a70f 3cad2e7c 00000004 40000000 3f000000 -> bda46ee0 3dc371cd 3fe8c2be", - "c223bb64 41939ad4 c2054531 3cc10801 3c94f8ed bb0df003 3b6a1616 00000004 40000000 3f000000 -> 3e312a49 3d449980 3f02597c", - "41ecdc4c c1e2ecba 41ae504c baa38c97 3b90982b 3c1dffdf 3be0462f 00000004 40000000 3f000000 -> 3d881847 bccf5634 3e406db7", - "41081668 420ea82c c1cf6363 bbd07906 3b82b3d6 3b750849 3cbc359b 00000004 40000000 3f000000 -> 3c0f8e9a 3b831b8a 3f07cf87", - "c10886cc c1d48d63 c237c876 3b2755b3 bd04e56a bd167c20 3c8b3546 00000004 40000000 3f000000 -> 3cb79922 3e79e8a4 3fc564c4", - "41c549ac 40ad6cf0 41b487b4 bc78b86e bcb6a67e bbbb5f82 3ae26484 00000004 40000000 3f000000 -> bf25ff3f bdbb9878 3ed4ffdb", - "be8bae80 c229817c 42168f44 bb01345a 3b0875c2 3a0ef65d 3c7fd6ec 00000004 40000000 3f000000 -> 3ef5653e bc729d21 3edbb09a", - "c18533dc c21f8bfe c2291deb 3c75a994 3c89ab5a bb0e449f 3be0ad70 00000004 40000000 3f000000 -> be030eba 3ced209d 3ed5778e", - "42287142 41822030 c212ee17 3d00286c 3d3a3436 3ca70d22 3dbd32ca 00000004 40000000 3f000000 -> 3e915cf4 3d8731fe 408ece44", - "c1eba852 c1be364e 415db64c 3e74ab13 bd22f014 be4840b7 3cd9de60 00000004 40000000 3f000000 -> 3e4f34fc 00000000 412c4558", - "c03eef80 c20adb80 41fe5c14 3eb261dc 3d2ed9e9 be4f2d0b 3d59cb57 00000004 40000000 3f000000 -> 3de797f8 00000000 4169a53e", - "4181b764 411d948c c1c836c3 3c6d35eb 3ab92f87 3a843a10 3dfc3962 00000004 40000000 3f000000 -> be51e980 3d343773 4087664a", - "c219ea1f c1066980 411c8900 3cc2c99a 3c51cdbe bc1fbebf 3d3d3d98 00000004 40000000 3f000000 -> 3f37dd86 3becb908 3fef3576", - "c11747d0 c20ca374 c244a40f bea1618a 3e22ed86 bcee5530 3e951a5f 00000004 40000000 3f000000 -> 3e8898e5 00000000 41a48846", - "42442582 409e6848 4245239e bda85104 bc0e8ace bcb8f19f 3c250714 00000004 40000000 3f000000 -> 3eadbadf 3dc9675a 40155b20", - "c123d224 bf259680 42463fec 3a3dde01 babdeb21 3aabd6a4 3d7429e7 00000004 40000000 3f000000 -> bd9e4602 bb32844d 3fb36747", - "41b66cec 4211bb12 41daf39c 3cab930c 3b9ef4de 3bdaec73 3dcdb7c9 00000004 40000000 3f000000 -> 3d7f76c2 3d994a22 40717d6a", - "4202cc30 c1eedf0b 40e05e58 3c1488c3 bd3f0b41 39fc484d 3ee10a01 00000004 40000000 3f000000 -> bf143d2e 00000000 41784a5a", - "c213337c c1825a24 c0b80728 3ae06722 3c0753d5 3b743588 3d6b9e8d 00000004 40000000 3f000000 -> bee90a95 bc5732b8 3fd40627", - "c243a17e c1daf546 c210a96c 3bdee19b bc217553 3c6824f7 3b39b092 00000004 40000000 3f000000 -> 3d4dace2 3e09c90c 3e73dffa", - "c10df350 c16e9b00 c1c8ea76 3b92303d 3b913dd4 bb927456 3c58fb7d 00000004 40000000 3f000000 -> 3f0b8c5d 3ad46f70 3e993c3a", - "423296a6 c1c6e3ca 4230a43a 3e96b5c1 3de42fdd 3e7d2deb 3b016bd0 00000004 40000000 3f000000 -> be8b11b8 00000000 414d1209", - "424489da c2414dd9 c23b602a 3b70c6de bb267566 bba1fd58 3ecb270b 00000004 40000000 3f000000 -> be882fb2 00000000 414db6b4", - "c1cc6650 c2173e2d 409bad30 bbaa0af1 bcdb880d bd247759 3d7f487e 00000004 40000000 3f000000 -> 3e938264 bdca314e 404c4dfa", - "c1e34d41 c11bd9a0 c1782270 bb4520aa bae77110 bb384961 3b84c9fe 00000004 40000000 3f000000 -> 3d8e1b40 3c2a59b9 3d96e29f", - "c1ca1942 c23d39f4 bf029600 3b8c41e0 3b106e20 3b5fccdd 3c1b94a7 00000004 40000000 3f000000 -> bf26dd3c 3cae430a 3e4db4df", - "c1267c64 c23c717d c0c0a6d8 bd81f5f6 3d06ddcd bcb414ab 3b0666f5 00000004 40000000 3f000000 -> be709ffd 3d31fd14 3fdcfdc4", - "c1c947d7 c1aadb76 c23cbf72 bd1b72b3 baf5d1cc 3e035db1 3dfcc1b7 00000004 40000000 3f000000 -> bf4845aa 00000000 41032705", - "c1cd979f c1b277ff 41bdb4e0 bc07bdf0 3bc1f212 bc94d0c4 3de96f8a 00000004 40000000 3f000000 -> be3c9e4e 3be7a95c 4080284d", - "4232f882 41f52f90 c2355fd8 3d9271cc 3d9172a4 bdb00051 3d14a05c 00000004 40000000 3f000000 -> 3f521f0e 3dbf640f 409cbc80", - "c15a902c c1fab89a c1ef6846 3bbfaefb bbabc19a 3a6049be 3cd54597 00000004 40000000 3f000000 -> bebeb15e 3aac906c 3f2764da", - "c23bcbdc c1d87d68 4230c31a bd83e10a bd40e6d3 3da20469 3ddeecaa 00000004 40000000 3f000000 -> 3f8edc0a 00000000 40e19e49", - "c234dd23 41b040d0 c22fbcc4 3cd334f5 bc644858 bcd9368a 3de10869 00000004 40000000 3f000000 -> 3e69ba9e 3d803067 408dc815", - "42377f12 418e6760 41d721e0 3b0eb82f 3acbdba7 bb365e5e 3c860ebf 00000004 40000000 3f000000 -> 3eaa7286 bba2a423 3ece0df9", - "c20ccc7e c09e8f00 c0f24d40 ba9e563f 39da0c06 bb2e59a2 3ebd30c4 00000004 40000000 3f000000 -> 3ebb9461 00000000 413de01c", - "41c25fcc c1e5b6b7 c07eba00 3a2527b8 ba184cec 394943db 3d808514 00000004 40000000 3f000000 -> 3e2705be ba8ce326 3fc880f6", - "422fde8c c1a640d7 41b087ac 3a4e0054 399e043c 3a0003d7 3aed7f91 00000004 40000000 3f000000 -> be81ba06 ba65e97c 3cfd9943", - "c2149916 c0b07e18 c0a3bdb0 3887bc26 ba550c0d 3a8b272d 3c68e036 00000004 40000000 3f000000 -> 3e8ac2bc bbbf2d7f 3e8046b0", - "4225e29e bf44cf40 4127cb64 3d9bfc92 3d2a5b7b bc04426d 3c9e49f7 00000004 40000000 3f000000 -> 3ded1620 3ca6bc60 402f7cda", - "418e42d4 c21c207c 41f34ba8 3d592b51 3daab19f bd9c1fa4 3d5cf5df 00000004 40000000 3f000000 -> bedddc4c 3d445dfc 40a7be4c", - "c218f1ed c21ec03c c138a8d0 3be10d36 bb9c4122 3b788abe 3d026c59 00000004 40000000 3f000000 -> 3f544f07 bb308b88 3f5d5ef0", - "41f1f754 c1891084 c236bbcc be15fac3 3e422392 bce56cbc 3ce18e2c 00000004 40000000 3f000000 -> bd84f716 00000000 41090701", - "c1851b76 c23ab103 c2080ec0 3ac83244 3b11ce25 3b115b03 3b95dd08 00000004 40000000 3f000000 -> bf389656 bc51612a 3d92e101", - "420405ee c1cc8666 c11ba998 3cea263b 3d2fbfa9 bcaccf37 3b2168a8 00000004 40000000 3f000000 -> be056936 3e2bf367 3f930530", - "c134a4dc 41f5e4a0 422e947e 3c11079d 3a3c6129 3a9d0fc8 3d8ce42f 00000004 40000000 3f000000 -> 3db34a97 ba72b87c 40125b72", - "41e0b1dc c234b7a2 4233680e 3c053f76 3bc92a3f bc00568a 3d94dbc6 00000004 40000000 3f000000 -> bedbca2d 3d135bc2 40173713", - "419176a4 c1b754a1 c13adbc4 3da35925 3db19a6e 3dd8896f 3bdeb1ae 00000004 40000000 3f000000 -> be140a2c 3e085bd4 40975461", - "c1a440cf c20ffaa2 4011de90 3d0fdb5c bd3502aa 3ce9e87c 3e6690c8 00000004 40000000 3f000000 -> 3f0be84b 00000000 41130af8", - "c237bde3 421f4634 c07e0180 bbd08915 bbe50f3f 3b41cacb 3e1acfe4 00000004 40000000 3f000000 -> be204d5f 3c589908 409f8144", - "bf896f40 c0049b30 c0f01c28 3d37b07c bce0367d 3c3c765e 3b79fa70 00000004 40000000 3f000000 -> 3ed17233 be48385e 3f909692", - "421c494e 41aaa140 4232a7ac 3b1bc953 3a322380 bc1122f9 3ce43c6f 00000004 40000000 3f000000 -> 3da43514 bb0616fb 3f2c2fa6", - "42175292 414d2140 c215dfd5 bd8fd165 3d6aecf2 3d4a4ff1 3d9ce7b6 00000004 40000000 3f000000 -> bf36ed0d 3d868ea6 40acb83f", - "c1b0fdd2 c2291c77 bf991b60 bd9983d4 bdcd1673 3cf442c9 3d8739ba 00000004 40000000 3f000000 -> be1dcbc2 00000000 40c67817", - "40c87c08 40f32a88 c1abf512 baa2ef7f bb831d5b ba6aca33 3a8fd1b4 00000004 40000000 3f000000 -> 3f42ae20 3ba64d34 3cd4f1f8", - "4097f6e0 c19a0a22 41c649a4 bac6b4ca ba86ed60 ba410d2d 3cd8d4f6 00000004 40000000 3f000000 -> bf3f72b6 3bef905a 3f1f2d81", - "40f5fef0 422a0d2a c0c98ac0 3c2eae2b bc59bfb3 3c0aa4ee 3d1a6b3e 00000004 40000000 3f000000 -> 3d16c7e3 3d9de831 3fb396a2", - "415035b0 41b5a8c4 c1374cdc 3d9c060c 3db531a3 bdead4db 3e4d0732 00000004 40000000 3f000000 -> 3ead9ab2 00000000 41397e32", - "c229ac66 c1b5de74 42357e04 be69f671 3ecd9be6 bea8e569 3d39a28d 00000004 40000000 3f000000 -> bdf96add 00000000 419c42f5", - "c1ff5411 c21bd882 c210fa43 bd549937 3d0f6cb8 3c18dc4c 3a99c6d9 00000004 40000000 3f000000 -> 3ee1da62 3e7d93f9 3fb1543d", - "41cb1a2c 423870ac c2013c28 3a5ce20a bb1c13ca 3b1ee37e 3cea75d9 00000004 40000000 3f000000 -> 3d269dc6 3bb40300 3f1c0167", - "41d9e464 41a0fa94 41ab67e0 3d7116bd 3cd00be8 bd2fdf7a 3da7d2a4 00000004 40000000 3f000000 -> be85143e 3d43d7a8 409975b0", - "c1cac9fe 421e2dca c2371229 bdb08185 bd82b8fd bdb16dce 3d2ab264 00000004 40000000 3f000000 -> 3d9154df 3dfe6ec5 40a9a30d", - "41fd83f0 42016df2 c1cdacaa 3dbfffe8 bdc374a6 bc92e18e 3e890e37 00000004 40000000 3f000000 -> 3d64fd94 00000000 414d49ff", - "c205ca8a c1606a2c c23c16c8 3d67d977 3ded8794 bdb23d0c 3e59beb6 00000004 40000000 3f000000 -> bf08c549 00000000 413bc6c5", - "bff03ba0 c1093fa0 c1f052e0 bc4e7a21 bb9f73ad 3c4b9813 3ccc00b4 00000004 40000000 3f000000 -> bd2eebf3 3d405ca8 3f61c43e", - "421ade98 c0e3b290 c0a12a90 3afc5cba 3b045372 3b17603b 3c480e98 00000004 40000000 3f000000 -> bdab8b47 bbf0eb80 3e5d6612", - "418240c0 40f64790 c10c3058 3df2ae14 bdf7c941 3d1eae4f 3d7f99fc 00000004 40000000 3f000000 -> bdbdfd18 3b2e3084 40e75c85", - "c1b406b5 41fc1bec 405bdb60 3bde1568 bbb217ef bcbbd99c 3c5808db 00000004 40000000 3f000000 -> bf43c50d bcbe6da6 3f1f6467", - "4166e980 c1ffd0bc c13c16fc be2efa14 3e081ab6 bda387be 3c4fb685 00000004 40000000 3f000000 -> be67fc48 00000000 40f834f1", - "c2242daf 41b49f7c 4219fe2c 3bb0f7aa bc3c4955 bc22543b 3c95fae2 00000004 40000000 3f000000 -> be595a64 bc9c4132 3f1b535d", - "41556784 414ba754 c204e145 b98f7dbb b8bd070d 3aade21e 3c90c46f 00000004 40000000 3f000000 -> bd90727f 3ba44422 3eb8d3e6", - "41d03c0c 405e1cf0 c1c60785 3c45ff78 bc173ac0 3c4adc98 3cb15136 00000004 40000000 3f000000 -> bf37474a 3c594a64 3f50ef39", - "c13ccdb8 c23a1648 413c7d78 bc0eb46b 3c83ec9e bc40c023 3e8316fe 00000004 40000000 3f000000 -> bdd993ce 00000000 410da223", - "c1d041d6 c246760a 419686b4 bb5be93a bb361775 bb943699 3b028a06 00000004 40000000 3f000000 -> bdbe74d9 bc955d8f 3d6ca599", - "4127864c c22d5136 421a85be ba166083 3a7c6a4e 3a87654d 3b3da2f8 00000004 40000000 3f000000 -> 3e9066ff bb12e24f 3d1dd7a9", - "c1a8d5b4 422831fc c216125e 3adf7cd6 3d1403ca 3b51cc8b 3e6c424d 00000004 40000000 3f000000 -> bc525770 00000000 41082a35", - "420908a6 c12f5a80 c22a1a67 3b920fbd 3c9f363a bd091319 3e0cf1ac 00000004 40000000 3f000000 -> 3f54b1af 00000000 40b41dcb", - "c14579b4 c1b3547a 420a16ec 3bf763d4 3b7da53e bb9575d9 3d07c0a4 00000004 40000000 3f000000 -> 3d22982e bbcadc76 3f7ef1a5", - "4030fd10 c20f5980 42092180 bd5515bb 3de948c8 bd8ea10b 3c5f2217 00000004 40000000 3f000000 -> bf11160b bdc067ed 408e7523", - "c238511b c0a9ea10 c1e0665d 3ba54046 3b4c0d0c bb411075 3c104895 00000004 40000000 3f000000 -> bdc964ee bca0f31c 3e48f979", - "c0445af0 41fa5a18 c11c12b0 bd9db44f bcc1d296 3c579407 3e8c2982 00000004 40000000 3f000000 -> bf0edfe3 00000000 41352a42", - "4225cc26 c2225436 41501db0 be8f3834 3d6f936d bdaaebbd 3d5eb176 00000004 40000000 3f000000 -> bd8cbc96 00000000 41338247", - "411485a0 40c57c18 c2243a7e bc1a7bc9 3b9af474 3a80b769 3ecfc4b5 00000004 40000000 3f000000 -> be4fb387 00000000 4154452e", - "c217c05c 41778088 4106289c b8885eb7 3a7a4344 bace5f60 3dcfa3b6 00000004 40000000 3f000000 -> be25ac6e 3a19bc8d 40358063", - "4220e7f6 bef0af00 423271da be5d6948 3d90c874 bd4d1b49 3b201707 00000004 40000000 3f000000 -> bb612ed0 00000000 40f008c6", - "40f6c250 42300a56 421d1f5e bb0e366d bac902cd badca25e 3c8e304c 00000004 40000000 3f000000 -> bdd38c54 bb943dda 3e8ae6dd", - "c22f7f7d 40f5b168 41f1b1c8 397280f0 3b2a6234 ba872054 3dce86ff 00000004 40000000 3f000000 -> bd005989 3b4a8604 403c3591", - "c1bb65fe c0cb79d0 41453ab8 3c342f8d baa7a691 bb3f8190 3b2e2cdb 00000004 40000000 3f000000 -> bd17f51e bc281275 3dd0dd1d", - "c2409be0 421ad8c6 c23552aa 3c512ad4 bc0741f7 bc1db66c 3a8aa963 00000004 40000000 3f000000 -> be01052c bd693f44 3e2a9fe4", - "c217944c 42324ea4 41efb8c4 3aaa51b2 ba3e226c 3a5fa69c 3e13d388 00000004 40000000 3f000000 -> 3e9369d7 bb1c69b6 408ccb52", - "c16dd4a0 c2161616 c238bbb8 3e81f7fc 3e706cde be2c0998 3e8e8ffa 00000004 40000000 3f000000 -> be969c26 00000000 41a8f6be", - "c1f628bc c1ecc8a9 41a540b4 3e0eb5c7 3e128dc3 bd41fa29 3b0380ac 00000004 40000000 3f000000 -> 3ec5d8cc 00000000 40d36afb", - "3ffe1900 41bc7720 c1e3b349 bb8a3a10 3b5ea705 3bc6e9fd 3d66046c 00000004 40000000 3f000000 -> 3d18bda5 bc9131e1 3fe18603", - "c200dd4a 41ea7378 c23a88ed bcccd3df bccd7e23 3d09dcf5 3ebee519 00000004 40000000 3f000000 -> befe117a 00000000 41570078", - "41ad79cc 4201637a c21970ac bc1f7965 3afe1001 bd228b52 3af04ad1 00000004 40000000 3f000000 -> 3e208181 3d110ee0 3f37508b", - "4196af18 c20f817f c0e2d0b0 3bc45404 3b2de722 bc56553f 3b249da9 00000004 40000000 3f000000 -> 3ede3592 3cb61a04 3e1b6d9f", - "41239a48 41961b08 410b28b0 bac2d6bf ba077ccb 38c70206 3d837891 00000004 40000000 3f000000 -> 3d0d4b5c 3ace0db9 3fcb23b9", - "c1a0330c c12f9d68 41b64970 3b0b10a0 3a10198f 3a9593f7 3efa8171 00000004 40000000 3f000000 -> bd7d845a 00000000 417aacd9", - "c1a2eb82 41cb51d0 c223ca7e 3adb1379 3a4eaa89 3a637c03 3a87764e 00000004 40000000 3f000000 -> 3d0c1b02 bbf8c03c 3c84595a", - "40567380 c218d8e1 4188ccb8 ba940e27 b9fb7ccd 3b041baa 3d1cc688 00000004 40000000 3f000000 -> beaf346b 3c0748c7 3f727311", - "41c39c50 421a3504 42467836 3ba9fc01 3c705f45 3c89f11a 3c166ce4 00000004 40000000 3f000000 -> bf0dcecd 3c8ef3cd 3f0e8120", - "c1a1c142 c0a9be30 c147065c 3a3cd099 ba977b2c ba3ee15d 3ae28c45 00000004 40000000 3f000000 -> 3f322a1e bb3eebc2 3cd506a9", - "c0d69ca8 c0d66d60 c212891e 3a4d922a 3e9d4e5f be1f4bc1 3eaa5834 00000004 40000000 3f000000 -> beb9cb24 00000000 41ac9285", - "c246fc38 4102ae20 40d10fc8 3e2b97b6 bdc27d20 bd972b41 3e8deaeb 00000004 40000000 3f000000 -> be3e7e40 00000000 417674a0", - "c0a2f3b0 c20f5cef c103e1c4 395ce8bd ba1fb581 b96fcc80 3ca9b456 00000004 40000000 3f000000 -> 3ea20d74 bad004a6 3ec6929e", - "421fe0aa 41bb1d2c 4207b0bc bbad74cd 3b782db1 bbeb47a7 3cb027fc 00000004 40000000 3f000000 -> 3ebac1aa bd0e746c 3f106090", - "422315b2 4104c504 419ff858 bd9fcb38 3e239163 be0adefd 3e35b690 00000004 40000000 3f000000 -> bf4326af 00000000 414c74c0", - "41163514 c22f2b2f 3f32dd00 ba1f93d7 3a68e94b 39d04ee4 3e8e30da 00000004 40000000 3f000000 -> be3b7978 00000000 410e2b5b", - "c23be10c c03a5c40 410c2bd0 3c5d55c0 bd03d389 bae984a1 3b8c7f92 00000004 40000000 3f000000 -> 3ea82377 bdbdf1bf 3f267d7c", - "c2359360 4169d378 c232d50b bdce756a 3db86fdd 3d08a77d 3c141a22 00000004 40000000 3f000000 -> beec6c7e 3dc6e3c2 4085a7aa", - "c15b16b8 c22b46a0 c22b0d9e 3a43ab54 39c49540 3a117eec 3c8f7ce5 00000004 40000000 3f000000 -> bf4b1b94 bac84690 3ebbf1db", - "c2317306 41075380 c11351e0 3c36c52c bc05fac0 bc73f063 3a996a28 00000004 40000000 3f000000 -> be540e3f 3cfed04b 3e5416b4", - "c22d68b6 422dace0 c1413374 be14c27c 3cc72c35 3dfb6543 3d9e54aa 00000004 40000000 3f000000 -> be3afd1f 00000000 41093001", - "c220599d c05ad660 41dafdc0 3d23882a bc88995f 3cc3bb24 3dab11a4 00000004 40000000 3f000000 -> bd8922a7 bdc3c9f0 40788856", - "c0fe4e78 c20adb17 4183900c 3ae63506 39ba8a8c badb5a15 3c7282ee 00000004 40000000 3f000000 -> 3e15b863 3bd70782 3e7a2246", - "4203017a c2152b1a 410df588 3a474995 3a928480 38e0cfb6 3d9250ff 00000004 40000000 3f000000 -> beed58a7 3b72db13 40075ce5", - "c11c9b98 c23cf58c 41a08b5c 3760a7fb 3ac5e2a1 ba7fb52f 3e0ab73e 00000004 40000000 3f000000 -> 3ea7d74d 3a7f8b97 407fe5eb", - "c1ef704d c14b2ac0 c2452805 3b2daf91 bb7da37c 39562286 3dc9bd51 00000004 40000000 3f000000 -> bdec5160 3ba3a1c4 4040e47b", - "42018cf0 419ce7d8 c21760c6 3c362d87 bcc7d1d6 bc814785 3cbd890f 00000004 40000000 3f000000 -> bef82201 bd6c0ce0 3f94be22", - "41b190bc 423251f6 4245a90e 3ea4c751 3e629011 3e8796f5 3b2e5070 00000004 40000000 3f000000 -> 3d5829c9 00000000 4171eed5", - "4229606e c2252a63 c1e5851a 3d880688 3d8e1367 be28a442 3d2b6fb2 00000004 40000000 3f000000 -> 3da3fda3 00000000 40ed21f1", - "420fd0a8 4215f48c 423c6508 3acc1227 3c64e999 3b50349e 3e136eb8 00000004 40000000 3f000000 -> be110df8 3b2e4a0b 4094fb19", - "41237d7c 420c2988 c1e4d57e 3aa08d69 baf8f89a 3af687e4 3bfe9c2f 00000004 40000000 3f000000 -> 3e2598c2 bb834a07 3df01623", - "41f36f74 c1f3b158 c10629fc 3caa5373 bc12d517 3c9f5f5c 3c20de7a 00000004 40000000 3f000000 -> bec3b24f 3d6050fa 3f3718bc", - "c025aa70 420be70c c19d2761 3d7aa26c 3cb9f35a bd96c78f 3b650cdd 00000004 40000000 3f000000 -> 3e496efb 3e1098e1 4021384d", - "bfa424c0 4005d200 418f83a8 be05b11b 3dc56793 3e175267 3dc7bff5 00000004 40000000 3f000000 -> bf1512b0 00000000 41219a0f", - "c183a0a4 c1f42c6c c186c3f8 3a103d46 3ab210cb ba44e1d3 3e9c0f2a 00000004 40000000 3f000000 -> 3eee9c87 00000000 411c3c2e", - "c221d850 4219533c c21e81a6 bc049735 3b893ce3 3bf85884 3cb753b6 00000004 40000000 3f000000 -> bf50002d bd3c01d0 3f1df244", - "c22bf575 4125b210 4235f31e 3ced564a 3d747ea1 3d9e2d85 3eea36a8 00000004 40000000 3f000000 -> bceb5634 00000000 418e8f1c", - "41b7923c c242eda0 413b694c bb1444dd bb8a58ed bb64d35d 3a8b7539 00000004 40000000 3f000000 -> beee7494 bcadd192 3d14bf16", - "c1ccac23 418f89cc c1debe36 bd435d47 3c8d15cf 3ccd69b8 3d8bf797 00000004 40000000 3f000000 -> 3ec7788d 3dc40de4 4064d5aa", - "3fa18a80 c13a51b8 41610668 3c0d1e47 3e05953b 3ea61ff9 3e384977 00000004 40000000 3f000000 -> 3f051bbe 00000000 4187068d", - "41c4cc20 c20037f8 41c7f87c 3c759bb1 bc37204b bca0f93c 3c900d50 00000004 40000000 3f000000 -> bf1569a6 3dea34f8 3f5d944a", - "c1e7a170 c17607a8 c11824c0 bce59249 bd247b14 3c089c8f 3e9fbd09 00000004 40000000 3f000000 -> 3d839393 00000000 41385f5e", - "4177cb88 c2227f1d c200ddd1 bb71c7ac bc9a7c83 bac33178 3c449a2d 00000004 40000000 3f000000 -> 3d66dd71 bc867476 3ef4c752", - "420e2e14 c1b3b6de c1f6a4d5 bb5ec704 bbbb1ef4 b9ba3033 3a9e7431 00000004 40000000 3f000000 -> be3f6fcb 3c8c025e 3d2f4373", - "c240dbf3 41e17ff4 40aa9840 b9c9cce5 3a948e51 bad432f8 3efc4242 00000004 40000000 3f000000 -> becc3aa6 00000000 417c3364", - "4146ff04 41d0546c c0fe7040 bd052f6a bd4ba0c2 39952496 3c9ccb33 00000004 40000000 3f000000 -> be8c8080 be39cb6b 3feb450b", - "41e61164 41ad821c c1b282b6 3a16211e ba64f483 bb2907c6 3d2cec18 00000004 40000000 3f000000 -> bf28d674 bafb911c 3fa36a13", - "41a60e2c c16f90e8 4163bd10 bcf30046 3c8c5e01 bc94e11d 3b2ee13c 00000004 40000000 3f000000 -> 3e9f5902 bd92cc11 3f2e582b", - "42159f40 c148f810 410e0e98 b9bde814 ba951933 384cb80e 3ea032af 00000004 40000000 3f000000 -> 3f18309e 00000000 41201f5a", - "42294a94 c1ff8889 42210fe6 3cebc33b 3d19012b bd40f60c 3dad6897 00000004 40000000 3f000000 -> 3e94f0f4 be4eab35 4093400a", - "41daa4f8 41ad85bc 3f86e620 3c608281 bcb6110d 39f4f78a 3cfa574a 00000004 40000000 3f000000 -> 3e45d604 3da15402 3fa524cb", - "c144db10 423482c8 c0c98a00 baa83824 39adf9e1 3ab49f60 3e611d77 00000004 40000000 3f000000 -> bf0c89ac 3a7eab6c 40de1b95", - "4052aeb0 c1bde8aa 41f63704 3cdbd6d0 be4d42a7 3e7fb717 3c047d34 00000004 40000000 3f000000 -> be41d3e9 00000000 4127f1e8", - "c1e42928 c16bc4e4 bec52e00 3a8ddb4f 3b7fd64f 3bce15d3 3e99a768 00000004 40000000 3f000000 -> 3f51a34e 00000000 411ccded", - "c1e322db 422b57ea 41e8a030 bb882c35 3b6246c9 bafd1d26 3e28ec8e 00000004 40000000 3f000000 -> bd686c66 39259560 40a68df7", - "4211ff44 c23881bb c2408cbc bcdb0532 bb7a122e 3c977ce9 3bead6df 00000004 40000000 3f000000 -> be84d440 3d96ff04 3f300a90", - "c1d129a4 c239ea97 c2113185 3c8ab16e bc13c331 bc42ce29 3d815d00 00000004 40000000 3f000000 -> be1b01cc 3d0b6454 4009ee29", - "41b54d74 c2024474 c19e6a2d 3ace17b7 bc169492 3c5c82cb 3d5daf55 00000004 40000000 3f000000 -> bd42580a bced5044 3fdcb0a3", - "c22ae99e 3ff9bb80 420e208e 3adfb11f 3a13028b 3a2b936b 3e29ece0 00000004 40000000 3f000000 -> bd41e7a0 bb644498 40a920c7", - "42182fb4 42429ae2 c23d8dfd bca4e0f7 bb097ff9 bc0e8822 3e061731 00000004 40000000 3f000000 -> bea790ca bd25623e 40940379", - "3fd654c0 c2004134 c21f34ce 3bad1e4c bb91738e 3cc04991 3ed8f2a8 00000004 40000000 3f000000 -> 3e20721b 00000000 41647cdc", - "41d5a748 c2166cd2 4132b138 b995c986 3abc59b0 ba4128e2 3d9b3055 00000004 40000000 3f000000 -> 3ed7857d bb6b41e7 3ffd5342", - "c2327858 c1456280 c07ca960 3b5630f5 3bf9ff4c 384c9e8e 3d540510 00000004 40000000 3f000000 -> 3edd0178 bc011321 3fbd2e0a", - "c1095c08 c19426f6 4100a1e0 be8d7e18 3e1350ea 3d9dfedf 3baf2075 00000004 40000000 3f000000 -> bf2c9d8d 00000000 41265815", - "420cfe34 3fe4c000 422288ea bc14289d ba767164 bc1bf9dd 3d7063e9 00000004 40000000 3f000000 -> 3c6a2ab8 bcce93c2 3ff04f9d", - "4106de90 4218ede8 c12b5f44 3d949959 3becc8fc bc510b9d 3e9d6a79 00000004 40000000 3f000000 -> 3e463517 00000000 41427983", - "41b1867c c18801d6 c07f2d90 3da94056 3d5eefa9 bd4691c9 3e3ec0cb 00000004 40000000 3f000000 -> bebd6f7d 00000000 411723ed", - "418e9730 c0522760 c219afa1 3b808738 3ba77258 3b431d1f 3b09f536 00000004 40000000 3f000000 -> bf3c3145 bc62cc8d 3d6be9a6", - "408fc498 c17ca84c c1e0575a be68ed93 3e49b4e1 3d869b3a 3d2988f4 00000004 40000000 3f000000 -> 3f19b000 00000000 41321d1d", - "c185eb50 41f46684 422438ce bd041fbb 3d3c6d0a 3cade74c 3e5debbd 00000004 40000000 3f000000 -> bd979076 00000000 410d1fc9", - "4220889c 417e64a8 c1b4e6e5 be1f032a 3e3afb7f bde6b793 3a999237 00000004 40000000 3f000000 -> 3eb36a56 00000000 4107a31b", - "c198b1ec c22dc971 419f3d30 bc5b4a3f 3cb1e0ae 3cd8a0b5 3d61ab08 00000004 40000000 3f000000 -> 3e54ad7c 3e057830 40219e7e", - "c2157ad6 c1b57802 c20d481f bc9eed89 3b2893fb 3d2bc0b8 3e378580 00000004 40000000 3f000000 -> bf574a4b 00000000 40e5f8ca", - "41a09a98 421082c0 c1423da4 3b32fab0 38d7d112 39c69431 3e6311b9 00000004 40000000 3f000000 -> bb058760 00000000 40e4f043", - "4201c118 c1c77d72 c13d190c 3a8380d5 3b128f31 3b2bc499 3d89e52e 00000004 40000000 3f000000 -> bcbb300c bbc28f87 40006f56", - "c22c6586 c1f4b9f0 4102c408 be93be68 bedefc74 be63d070 3d0f3748 00000004 40000000 3f000000 -> bed4e2bb 00000000 4199a654", - "42431cda c1bb70d4 40d59710 39b54f8a 3a8960da 389f4e82 3c2c9140 00000004 40000000 3f000000 -> 3ea25656 ba5ed09c 3e224482", - "41e842ac c0c249e0 c1fb04ef b92baa35 bbcfc7da bbc25faa 3e0e18ce 00000004 40000000 3f000000 -> 3e8a698a 3c04b047 409012aa", - "3f471400 420415be 41dc4504 b9dbe505 39fd8182 3ad9e25e 3ba232df 00000004 40000000 3f000000 -> bf288f4c bbc690bd 3da9375c", - "c17ef784 c0421070 41018340 3b060b54 3ae7f604 3a31f106 3d84f2a8 00000004 40000000 3f000000 -> be810e8d 3be6dc30 3ffa1506", - "412294e8 41f581e0 c1ed6a5b 3d522f51 3bb34d0a bd098914 3e3419fb 00000004 40000000 3f000000 -> 3e9609bc 00000000 40f22257", - "41abef80 c246c2fe c1333b00 3ac3aa06 3a6426cf bb270329 3eec98d8 00000004 40000000 3f000000 -> beacfb15 00000000 416d2701", - "c225fa27 41e6a1c0 c003b630 bb953b24 bbc7a807 bbba95e9 3c0ee528 00000004 40000000 3f000000 -> 3f08274a bba4dae8 3e70fc35", - "c1aadf86 c19868be 418763fc ba194e68 ba2d4f0f b9d85039 3e919a5e 00000004 40000000 3f000000 -> bf7cb3fc 00000000 41117ac4", - "41ea5fb0 3fbfcd80 41b374a8 3d57d5c6 bbbe1e28 3d4444a2 3ec7fdcb 00000004 40000000 3f000000 -> 3eb095c7 00000000 416b8cd5", - "41465f10 42318290 c14a3098 bba8ade1 3babb17a 3aca10ff 3dc477fc 00000004 40000000 3f000000 -> bf058600 00000000 40530957", - "c1ae95b5 4116686c c233e34f ba049bd3 ba8f5621 b9e09208 3c6e1b79 00000004 40000000 3f000000 -> bf51f676 baf6e444 3e9c2141", - "4136c8f0 420df1ca c1590ee0 3d254034 bd546a0d bc0c3685 3be794f5 00000004 40000000 3f000000 -> beec463a bd946bf4 3fd6b638", - "40d0d920 c0059320 c0d565e8 3b0e3d53 3804f389 bb11d2c6 3d49ab0a 00000004 40000000 3f000000 -> bede810c 3c0b459f 3fabacea", - "423184c6 3ff9cda0 41bb42b4 3b8648a8 3b8ef1d1 bbb5f177 3ce1b7bb 00000004 40000000 3f000000 -> 3f158afa bc5be546 3f4ea486", - "41bc0984 422e1234 422476c0 bd465b77 bd8e18e0 3b0ff000 3cbcd7b0 00000004 40000000 3f000000 -> babf4056 3b116770 403b0e68", - "c220d502 c1a4f1f4 c22cc417 ba771b8c ba33810c ba7ed2d6 3d3678eb 00000004 40000000 3f000000 -> 3f3aef80 bacf8f28 3f8e58ad", - "401a2f80 c2305cea 41f8919c bd33b9ab bcba2e38 3daf557f 3dff4a0f 00000004 40000000 3f000000 -> 3e8f9f3c bd98cf34 40de0b11", - "bfb474e0 c0f4c3e8 c1e8f590 3cd65c3f be428311 3d838fb4 3e11cbe8 00000004 40000000 3f000000 -> bea73a61 00000000 412fab2b", - "41ce56a4 4204604a 4221c3a6 be8fab07 3d930e63 3ea7b5e0 3bbade5b 00000004 40000000 3f000000 -> 3d565f00 00000000 4161d489", - "423ceea8 422b713c c22c0909 bb9eebd7 bd042d73 3b26e6ad 3dca4b4d 00000004 40000000 3f000000 -> 3ee0bd66 bd16e86d 4079c760", - "c0c59d08 c216a452 41e50c4c bdc76c2a bd0d92aa bd672195 3bfc7add 00000004 40000000 3f000000 -> 3c26156f 3dd027b8 4056b35b", - "c226a59a c21202b7 c1866c38 be89b9ca 3da19dd1 3e927d8d 3ef30817 00000004 40000000 3f000000 -> 3eb0dd15 00000000 41df1535", - "4180a394 c1b79724 c1bb2854 bb060fa8 bb73898d 38b7b883 3e9e4800 00000004 40000000 3f000000 -> be8d94f5 00000000 411fc504", - "c2222362 40445870 41effa38 bb737865 bbb06a60 bb708108 3c472a25 00000004 40000000 3f000000 -> bccaa1e0 3bb19ba5 3ea98722", - "421c46b6 c03fbdb0 c0b24410 bbab6847 3c3c440b 3c0b1ee9 3c72448e 00000004 40000000 3f000000 -> be0c85f5 3c9240b3 3f0483f0", - "413b9520 40f31e78 42100788 be40a08d bec16475 be781059 3c0ea11a 00000004 40000000 3f000000 -> bf39cb79 00000000 417c796d", - "423f3baa c22889b6 422b0f2e 3aeb777b baaa67f5 b9b7313c 3bd4231b 00000004 40000000 3f000000 -> bf08ccaa bbadc97b 3df9aa09", - "4137c568 42119c8c 4165f978 3a783f09 3c4af1c9 3c9aab30 3e27a578 00000004 40000000 3f000000 -> bf4a8912 bd28a51e 40bac9e0", - "41ed0734 422c1422 c239a3ed bce3710f 3ae065d0 3c72ead0 3defdf8f 00000004 40000000 3f000000 -> be366f45 3b49a570 4089fd3d", - "c0071180 42051b36 41693b40 bd24be5a 3bf55025 3ce1fcbc 3aba96cf 00000004 40000000 3f000000 -> becee216 be658794 3f6bcb47", - "c18a5630 c099ea10 c10b2fac bad63cdd bb560a47 3a5a484b 3d426a9e 00000004 40000000 3f000000 -> 3f319d4b bc0f10d4 3fa786df", - "c23b3cde c20e74c2 41fcbedc bc0b48f4 bbcd6318 3c647aff 3e0f2700 00000004 40000000 3f000000 -> be08fc3a bb105cd8 40998908", - "4106c7bc c237fc09 c203a58b bc06d21c 3ad282f0 bbb3b018 3c8d8e89 00000004 40000000 3f000000 -> 3d593f9d 3d228bcc 3efce465", - "c11398e4 c207685c 419678e0 3de869b0 3e47ffa9 bedf9423 3acefa7e 00000004 40000000 3f000000 -> bf4c4df4 00000000 417b6f1a", - "c1e6bb2b 410b15b8 c20cb87c b99502f3 3a409ba8 b84e92bb 3d46f1f0 00000004 40000000 3f000000 -> bda597d2 3a76de04 3f9423e4", - "c1759b68 c107f7b8 40ee5b00 3a05be61 ba3b4e24 38205568 3b340bba 00000004 40000000 3f000000 -> 3f218382 b8b35630 3d0f07a9", - "4229a830 420c74cc c20fd5af ba94d0d5 bad71942 bb7fbe29 3dbf6ae6 00000004 40000000 3f000000 -> 3d166c7c 3b6258aa 403599af", - "c1acf5a6 4235dd36 420c1de2 b8cb08b3 3a1860fe 3b405c26 3bed3d75 00000004 40000000 3f000000 -> 3e8b8939 bb24b98e 3ddab037", - "c217886d 41c1f4b0 c1cc3599 bd28addb 3d2ab68d bc69c127 3e4aa918 00000004 40000000 3f000000 -> 3ec8ee4b 00000000 4103a8fd", - "40b24060 40942988 4245422e bd1644e3 bce7bb46 3ca04920 3b59cb51 00000004 40000000 3f000000 -> 3f42f670 bd9f0b88 3f8f43c4", - "4169eff0 40236a10 c22f88a3 3c923781 3d8e9199 3d4b1af5 3e88c514 00000004 40000000 3f000000 -> 3e1e4a00 00000000 4134b1fc", - "404d4180 c102ad20 41e72b58 3c548ac1 bbd286fe bc4707fc 3dd66424 00000004 40000000 3f000000 -> be3ca775 bc2e1158 406b62c7", - "c102e82c c1c325fc 4225f9fa 3ebda24a 3e8dca26 3ec78d8e 3ae2eb11 00000004 40000000 3f000000 -> bf1ca4e9 00000000 419a98d6", - "c058e0d0 c1a81acd 41919924 bd78327d bc308e3f 3d8e8ae1 3b286860 00000004 40000000 3f000000 -> be0c390c be01de0d 40130b7a", - "c1efe89c 417b6400 40334040 3ceb8e66 be5a5990 3e420eb0 3c0476c8 00000004 40000000 3f000000 -> 3f1998b9 00000000 41164ac5", - "c23838ee c17679ac c2133da4 bdc45bd1 3dba62a1 3dca71ab 3b96d8b8 00000004 40000000 3f000000 -> 3ea6e903 3e7a2c18 409bf8e6", - "c11778b0 c1cbf70c c204806c bd882870 3d8d15da bd8522b3 3e0f6713 00000004 40000000 3f000000 -> be568d96 00000000 410266e0", - "40472670 423d275e c19a91b4 bb975444 3b906510 3a714d3b 3ac34c3f 00000004 40000000 3f000000 -> 3e5e2750 3cb9a972 3d360dc4", - "41a8f150 415b720c c1c42375 3b16f824 bb29b313 bb1ab960 3b5b411a 00000004 40000000 3f000000 -> be97ae58 bc144a86 3d58b580", - "3f8922e0 40fc0ba0 4228c3f2 3cadd7fa bcca5d19 bd35b16c 3ce56f73 00000004 40000000 3f000000 -> 3ed33dab 3dbeae4e 4003077c", - "c18dd196 c0cb7c78 c101d4d4 ba276cf4 3ab79f6b 3ab53b75 3c4da549 00000004 40000000 3f000000 -> 3d36d904 bc69a408 3e76d2bd", - "c0d3e190 41ba7a78 c0e9b910 3ce44345 bb25b220 bc920066 3b31e6a7 00000004 40000000 3f000000 -> bed4363a bd465f38 3f0ea10f", - "41d57528 c22ce5f0 c2388bcb 3b92b73c 3bc9a1bd ba74957d 3b82a0a5 00000004 40000000 3f000000 -> be36458a 3d0cacf4 3ddb4461", - "c23a5527 423dcca2 c1c33eba 3d20dd56 3c2c58ed bd37ec2f 3bc28d97 00000004 40000000 3f000000 -> bf0272e0 bd3bbc57 3fbbb50a", - "422c99e0 41d89c28 423830a4 bba57b65 3a15735e 3d08e1b9 3df6b561 00000004 40000000 3f000000 -> 3e2fa9cd 00000000 409d613a", - "41a1eacc 420b2912 41e9ff0c 3a35fa62 39d061f2 ba1e7df4 3ab14509 00000004 40000000 3f000000 -> 3e9c8394 3a48b28a 3cb04edf", - "c177126c 41d10714 420ed386 bd0a6e68 3c77e5f1 3d29d9a3 3d188bb1 00000004 40000000 3f000000 -> 3f20880a bdff1e40 4012c3e2", - "423d2c32 c1f2dde3 c237d2b5 3b3614b1 bb48cf27 3a0cb284 3e373e09 00000004 40000000 3f000000 -> 3e53c1b8 ba434f80 40b86241", - "417c2520 c20fd22d 41548b5c 370b906e 39ad8287 3a82b1fd 3ba75d7e 00000004 40000000 3f000000 -> be32a6c1 3a3d6eb0 3dca28bb", - "c19dc40a c1b9a43b 41a5e134 3e1d562e bcf01cb7 bc3c0a09 3c3667be 00000004 40000000 3f000000 -> be9da6b7 beb73c62 409af455", - "419deb20 c1ea18c4 c1a5d59f 3a7bca2b b99e31cb bad9ded7 3bd364aa 00000004 40000000 3f000000 -> bf2e6463 bbebd10a 3dc1e3a2", - "4223ff9c c1423a04 419aebac b9c1e0bf ba212a04 bb8b9add 3c4c5f36 00000004 40000000 3f000000 -> 3f3803e2 bc13d2e9 3e7dccba", - "c1963329 423742d0 c12dba78 bd36da8e bd0ada39 3b8d0c54 3e01e136 00000004 40000000 3f000000 -> be33466c 3cbf1722 40aeabd1", - "c22fc106 41179f3c c171d4d4 3e941ead bea2e3a2 3dba6c98 3d03e3b4 00000004 40000000 3f000000 -> 3e257e4a 00000000 41707c95", - "41b7ed18 41747d70 414ba814 bc9dee16 bb3d457a bc81dc09 3b8c20c3 00000004 40000000 3f000000 -> 3ece9045 3d4c876e 3ed52822", - "c2300a12 c1859f1c c1d2e3a6 3ad21ef4 b98db128 3aa80509 3e5a515d 00000004 40000000 3f000000 -> be4154d9 bacb3114 40db655c", - "c1fe8d79 c19edc85 3fc163c0 bee653f5 3ea98448 bdf37fad 3d0acddd 00000004 40000000 3f000000 -> 3f0b5b03 00000000 419a3189", - "41806410 3fafba00 c2343ff7 bb0b762f baea9be6 ba234fac 3e6e47fd 00000004 40000000 3f000000 -> bf436251 00000000 40f02fed", - "41c415cc c211ecc7 40574420 3dc6c26a 3d0a65f3 bcf88436 3e7d910f 00000004 40000000 3f000000 -> bf60255c 00000000 4134dda1", - "421279ac c208ecb7 40b1dbc8 3d5e6d68 bc2bdf44 3d6506e8 3d4598af 00000004 40000000 3f000000 -> bf187b25 3cadf2c8 40668cab", - "41ed3b54 bfaed640 41ccf804 3ae68342 3c61a0fd 3b5f0ebf 3e71b396 00000004 40000000 3f000000 -> becdc708 00000000 40ff40e7", - "c1b0e8fc c22fc242 41fd581c bbaa9b2c 3c99314e bc6b4fe0 3e9986f6 00000004 40000000 3f000000 -> 3ea0fa29 00000000 41253310", - "4236f4f0 c1605208 c14343d8 3da23d25 3dc3cc31 bdb521c0 3d103852 00000004 40000000 3f000000 -> bc472e12 3e48026a 40b1773a", - "421fb438 414da15c c21663f1 bdb5d1f9 3dabbff3 3d99331f 3b8eb4bd 00000004 40000000 3f000000 -> be2c2033 3c2c802c 40848512" - ] - }, - { - "glsl": "vec3 cultmath_af_frustum_axis(vec2, float, float)", - "tolerance": "ulp-bounded", - "cases": [ - "be17c8ac be987fc8 42733cca 42b47e45 -> c00ba0ce c08c4940 416b7f80", - "3f01644e be911c7a 421ac577 422f2bac -> 3fa4f7ee bf39028f 402331a8", - "3e9e77d8 3d84bf80 427011cb 42c34759 -> 40ba4f13 3f9c11f3 41967ce7", - "3f53028c 3ca8d400 429e7fe2 42faaf5a -> 4197f815 3ef32df8 41b85ef0", - "3e8d858c 3ee4afdc 42c7cad7 42fd4120 -> 406c704f 40bf084b 4155d924", - "bf29d94e 3ee14700 4095d287 4234a723 -> c156dd93 410e7e0d 41a1ecd2", - "bf221d14 3ee4f81c 422ef3f7 42b074ea -> c1616399 411f2b72 41b1f5dd", - "3eae2290 3e2ae048 424fe60c 42a28578 -> 409f5dc8 401c6241 416a49c8", - "3e23df98 3f43c12a 421b8b36 42acd010 -> 40735aac 4191595b 41be14ea", - "3e0f7e20 3d7e7460 426d78f6 428b3832 -> 3f37b32b 3ea2e07a 40a3ddb8", - "bee53ad2 bf395966 3e806db5 414b1f91 -> c03249eb c09028dd 40c71c23", - "becfbcbc 3f0fa424 42360915 42bdbb2a -> c12034e3 415d8d38 41c56d3f", - "bf187b27 3f3b98c2 413e8dd6 423319b4 -> c11c9ae5 4140aba2 4183763e", - "bf396ea6 bf1e4fa8 42c1fc4e 42edf0c6 -> c0feb552 c0d9747b 412fd1e0", - "3da9ef10 bf32418e 428d3c99 42a18c04 -> 3ed7b651 c06246bd 40a27b58", - "bd80fbd8 3e291060 40408dc2 4245fb3c -> bfbb603b 407599cd 41b9f260", - "3f64bf40 be8b1e4a 40e730d4 418ec529 -> 4097da69 bfb8b4e9 40a9f1e8", - "3df56000 beaf8ce6 4044e6d9 41c4377d -> 3fa47b57 c06b5a4f 412b9aa2", - "3d18cf20 3d873d80 412cdbaa 42452b12 -> 3f37cb0f 3fa2a97a 4199f428", - "bd6b6f90 be946f56 4047f604 4121e0c8 -> be4dccc9 bf81c01c 405fc68e", - "3ef22598 3f0b0aa2 42215e33 4260cfb5 -> 40700a78 4089d511 40fdc608", - "3f5a3632 3e6d0910 42a0c521 42b9d3b8 -> 40aaddd4 3fb99b27 40c874b8", - "bde9e630 bf02cfb6 421bee73 422653a4 -> be17f727 bf29fa43 3fa65310", - "beb001b2 bf261d44 4227856d 428911e8 -> c0929b32 c10a5dc9 41553cc6", - "bf155da2 bf252960 428ac799 42bd9112 -> c0ed0eb6 c1031041 414b25e4", - "3e0bd408 3f6a27e0 42ba9c7c 42f27372 -> 3ff3ffbb 414c4cbe 415f5bd8", - "bdfffbd0 3dcd3300 42aebfe2 42dbe28c -> bfb487b4 3f90b700 41348aa8", - "be21a2f0 be3a08a4 42721504 429084ef -> bf6d2f01 bf887df0 40bbd368", - "bf79c6b4 3f19a956 4195ce4b 420575c4 -> c0e488af 408c97e2 40ea3a7a", - "bef02888 bf3f744a 428b7310 4299fa9b -> bfda15f3 c02ddba5 406878b0", - "bf45c632 3f256792 4204ae26 427a13a9 -> c1356403 4117b3d8 416acb06", - "bee4947c bf7a88d9 41fcdd83 428d1f8c -> c10b1fed c1987cbf 419bd056", - "bf7ffdb2 bf59056b 4209803f 4296f458 -> c1a466f6 c18b6003 41a46871", - "3f31cdb0 bf162ba2 41eba360 428e5e1a -> 4167dc84 c143d3b9 41a6ea84", - "bf12cffa bde79780 429bdf13 42c07fc2 -> c0a80b2c bf848aac 411282bc", - "bf2bc738 3e951ac4 4216b03f 42ac28b8 -> c181ed5a 40e18e20 41c1a131", - "bf7af105 3f3b0e3e 405e1279 41be3b90 -> c11f4361 40ed6f39 41227941", - "3f440d4a 3f2c0f80 42536360 42948488 -> 41032e9a 40e64207 412b4b60", - "bf6f7708 bf258258 4104feb9 42451c01 -> c19946e2 c153e0df 41a3dc53", - "be84ac8c bf03a11b 4295184b 42d0c990 -> c0777d1b c0f58a39 416ec514", - "3f0aca06 bf48a0bc 422af603 4291f7b8 -> 41032bd9 c13d9da4 4171f2da", - "3e328070 3f61aee8 420a3d7c 424e19d3 -> 3fbd4501 40ef4c17 4107b8ae", - "3f6e5f90 3cdd50c0 42a12163 42d1826d -> 4134311a 3ea74c21 41418428", - "3f0513b8 3f09bdd4 42a47018 42b51baf -> 400aa6e3 400f8305 40855cb8", - "3f35b748 3dd9c620 423b752b 427896c1 -> 40ad920d 3f50031f 40f48658", - "3e563d70 befef2ec 4224cf24 42806efc -> 401a14fa c0b75c22 41381da8", - "3e978fa4 3ef58e28 4183d69b 41ec841a -> 3ff7e448 4048d056 40d15afe", - "be668a6c bf5243aa 42862c22 42af0de5 -> c01343c1 c1065001 4123870c", - "3f317786 3f60eea0 42c21336 42fe95de -> 4127ca5a 4154aae9 41720aa0", - "bf6b19fb 3e7c4e70 40b75480 41e08196 -> c1241672 40301883 4132ac76", - "3d566600 3e4e0b70 40e01315 420c830f -> 3f3c70c7 40351923 41610159", - "be972cba 3e595060 421403bb 42547fd2 -> c01851d7 3fdaf5ba 4100f82e", - "bf7ac68d be986ae6 41d3344b 428dd576 -> c1ae6e7c c0d408a1 41b210c6", - "3f5ff22a bf2111fa 42a37d7b 42f5b739 -> 418fdc29 c14ef05b 41a4737c", - "3e9784b0 bdf25b88 425035de 42adce10 -> 40a50323 c003f882 418b6642", - "3eb78af0 3eacafa8 42a98098 42d3510c -> 406fd5a4 4061a5f7 412741d0", - "bf4a56ab 3cda9740 42af4619 4308682f -> c19a3040 3f2692bf 41c3148a", - "bf2c07f8 bf47954e 42a427ad 42cee55c -> c0e5c631 c1054982 412af6bc", - "bf496c83 bf06f358 41b9fd15 42870695 -> c18b4f88 c13aabeb 41b10ea0", - "3ec12094 bf5185d6 3effe07d 42245343 -> 40f4eb3b c184db0a 41a25382", - "be28ef70 3f7f1e4c 4089242a 421538d2 -> c02e51b7 41839fda 4184144d", - "bf1a19d3 3e3b40f0 406e5689 40ac3343 -> beff6145 3e1b292a 3f541ffa", - "bf440b63 bf547daf 42844f0f 42ad289d -> c0fa430f c107a0df 41236638", - "3f5a3ebe 3e4b30f8 4270279a 429f131f -> 4104fbea 3ff79f5d 411bfd48", - "bf2284ac 3ebea60c 42ab88fa 42c60276 -> c08674c7 401dbab0 40d3cbe0", - "3e85d9e4 3b5dd800 42a7d669 42b1c841 -> 3f266382 3c09e2b8 401f1d80", - "3f590426 3ea264f8 42b405e2 42fb189e -> 41710021 40b4578d 418e2578", - "becca63c 3f22ed84 428c40f6 42df66d2 -> c104f053 4153ac69 41a64bb8", - "3e8456c8 3e9ec248 425f0dbc 429a85de -> 4031d07a 4055501b 412bfc00", - "bf7bbec3 be722d40 428841a4 42cbfc38 -> c18534ce c08024b1 41877528", - "bd20a3d0 bebe44b4 424d8b6f 42ad20b4 -> bf30978c c0d129a4 418cb5f9", - "3ecea70c 3f2794f2 40ffd22d 41ba31a0 -> 404559d5 40a009ef 40f47a2a", - "3f31720c bf71cd69 424b261a 42b7b852 -> 4163c175 c19b2dff 41a44a8a", - "3f2700ba 3f71f442 3eaf0261 41a74166 -> 40d6a6ed 411b7e85 4124855c", - "3f4c4b30 3f0547d6 42b72e44 42c270ae -> 400fc3b1 3fbb953d 403426a0", - "3f42f2c4 beac0d14 42585b71 42904c15 -> 40dc0a14 c04231f4 41107972", - "befc61c0 3f33cefe 41efaaae 429cfe01 -> c13f6833 41885e05 41c226ab", - "bf2948a6 3ed5e6dc 41d98f80 428b50bf -> c160a1e4 410deb57 41a9d9be", - "bf7b6a09 3f00a056 42a034cb 42c41529 -> c10cef61 4090353a 410f8178", - "3f18ad5e bf75a29b 41fdc3e1 42268e4a -> 403d4999 c0984493 409eb166", - "be9664e4 bf17e9c6 411bed8e 4251ddfc -> c0c8c83c c14acf68 41aae298", - "3f7e5c58 3f2875ec 41da8418 427f78b6 -> 419146fb 41406e73 419236aa", - "bf0325a4 3ce5d340 4283671d 42d19a32 -> c1203e8d 3f0c6873 419c662a", - "beec3406 bf39f6a2 41c6ffb6 42620997 -> c0e98161 c137d6e3 417d1378", - "3f680108 be435a7c 416ed143 4260cf2d -> 4195a102 c07bfba2 41a51adc", - "3f368ee2 bf6e78ab 42aa276b 42cbf7e9 -> 40c0e8c9 c0fbfe2c 410741f8", - "bf249ab8 bf757579 415dace4 427e1ca5 -> c17f837d c1be82f9 41c6b16c", - "3e695478 bf4f8885 40f2d040 4157a536 -> 3f2bc962 c018cb4c 403c7a2c", - "3dfe64d0 bf77e080 42afc718 42c28634 -> 3f1507fd c09136a5 4095f8e0", - "bd37a000 bf529dae 42878ea9 42a5c796 -> bead6ca8 c0c6ea7f 40f1c768", - "bf427876 bebe6222 422a089f 422f8bd8 -> bf060128 be833029 3f306720", - "3f5a9770 3e4f4fa0 42832310 42b84bd7 -> 413590af 402c3207 4154a31c", - "bf4345fd bf145d29 42ae7578 42d2cf84 -> c0ddd43b c0a88a4c 41116830", - "bf1c4932 be9c129a 421dad37 424db4a0 -> c06a91fc bfea400b 40c01da4", - "3f3b0656 3edde9ac 41ffa937 4212a618 -> 3fdbf7d3 3f82802e 40168be4", - "3f2bce9e 3e9fce1c 42c33f2e 42c78a39 -> 3f3865d9 3eab842c 3f896160", - "be542948 3f4e6e34 4170117f 42453518 -> c06364f0 415d4086 418930b8", - "3f66233c 3f6909c8 41cb5f08 426bdd19 -> 41713ed7 4174493a 41862d95", - "bf4b8160 be4aca74 42acecef 42f5f9ba -> c168483f c0677775 41921996", - "bf7c7be8 3ebb0e44 42592cce 4281ad99 -> c0a66854 3ff691e6 40a8b990", - "bcb2c3e0 bf41e54c 426714dc 42d32d26 -> bf0590a1 c190deab 41bf4570", - "3eecd270 3ee569dc 4221b857 42954487 -> 40fd21c0 40f5368e 4188d0b7", - "3f0d3f2e 3f3c9fe8 41ac3f17 42789124 -> 41334150 416f61c7 41a27198", - "3f7d4d50 beb24e20 429838f3 42d3201f -> 41692102 c0a41ada 416b9cb0", - "beea262a 3f41a05c 4239dc40 426dad4a -> c03d9333 409cc437 40cf4428", - "3f54a71a bee34bac 401e42f6 42426e22 -> 41994ab2 c123d8df 41b889f3", - "3da16450 bb107200 41836eae 41f7e966 -> 3f12dda4 bc8371cc 40e8f570", - "3e6fe6d0 3eca40c0 429ecbbc 42be032c -> 3fea0736 40454d1d 40f9bb80", - "3c436a00 3d083a20 4192be28 422ad0ee -> 3e14c424 3ecf6a6f 4142e3b4", - "3ecc815c 3e8e5f7c 428ee8e9 42b8b6a7 -> 4085944c 4039fdb8 412736f8", - "bf0fc8ca bd6a9190 42868a11 42b64f2b -> c0d6a48a bf2f154d 413f1468", - "bf36cc6b 3f51e524 410332cb 424ec1d4 -> c1786e5b 418ea0d5 41adf521", - "3f1fc2ce beef46f8 429b6028 42b6811b -> 408770de c04ada41 40d90798", - "be1c2fc0 bf20420e 414f4c93 42383a1f -> c0218ee5 c125c50c 418466fa", - "bf1a4ea8 3f15f628 41a97a22 4280cd59 -> c15064e0 414a866d 41acdda1", - "be0941c4 3f47cd92 41ba834e 4254bfca -> c0002266 413a8603 416efc46", - "3de6ee40 3e84ae00 40fdb38b 41a572e3 -> 3f3810ae 3fd381c0 40cc0c00", - "3f2d7100 3f3fd6aa 423f7301 42ac2b6c -> 414f2aea 41652463 4198e3d7", - "bda2ca78 3e314950 427d1173 42cefeff -> bfcca9ec 405ee344 41a0ec8b", - "3f19d2da 3f2ee608 4231cf97 4235f24f -> 3e9f09fe 3eb4d419 3f045700", - "3e843c50 3cebf5c0 427bedb9 42e0237f -> 40cad894 3f34fa6f 41c45945", - "be16ca9c bf22219c 420c9548 42922f0d -> c032cf98 c1404205 4197c8d2", - "3f35995a bee54f8c 41ffb807 426701fc -> 41125745 c0b8ca09 414e4bf1", - "3f0caa00 bf20fffe 42b561e2 42cd5623 -> 405297bc c07109cb 40bfa208", - "3f3f7ab4 be4e5dfc 4203d740 426cccc9 -> 411d0300 c029383a 4151eb12", - "3e9ec344 be5de11c 424d8e29 42c491b0 -> 40e8aa59 c0a294c3 41bb9537", - "3b7cb600 3e8e2bb0 42bb7b73 42fe5512 -> 3d83fb7e 4094807b 4185b33e", - "be70d054 bf1065ea 42a77784 42d08a6c -> c01a8c99 c0b957e4 41244ba0", - "3f0b7982 bf07c1a9 420f10ad 4283dd3e -> 41037af2 c0fff34f 4171539e", - "3f5126f6 bf01c0fe 42b7bb5f 42f8f010 -> 415517c4 c10432d6 41826962", - "3f3dcbdc 3f5f33cc 421577ba 4289153b -> 4138e683 415971d9 41796578", - "be9057d4 3f371546 42614022 42c6628a -> c0c16b41 41755494 41ab84f2", - "be9c7dbc bd4779e0 41dc58fe 4260304c -> c08b64a1 bf31ae78 4164079a", - "bebb7f06 3c680400 4220b867 42b1cd36 -> c10ebbcc 3eb09fe0 41c2e205", - "3e1cabf8 bf694589 41be9737 428489ec -> 404fd024 c19ab55c 41a9c83c", - "3cf42b00 3f57e968 429d8c8f 42fb34a0 -> 3f32a7d7 419dfb15 41bb5022", - "3f3b1b5e bf2ec8bb 427ed4a0 428cdf91 -> 401d616d c01303fa 40575410", - "3e289200 beb77d5e 4258233a 42961f9b -> 3fdd8955 c07124c7 412837f8", - "3efd2e18 bf3259d8 427b1ccc 42bdd57e -> 40fe4756 c1331ff7 41808e30", - "3f095766 be7f9054 428fe04a 42c9b726 -> 40f83dd6 c066f684 41675b70", - "3f1002aa be59a690 4280f09d 42b1f318 -> 40dc8f3e c026abf6 414409ec", - "3e978930 bf7b2d7e 42b55f27 42b9672e -> 3e98b94c bf7d2591 3f8100e0", - "bef54eda be8975da 41d4da38 422ede41 -> c0832aba c013003b 4108e24a", - "be5185e0 3f3a99f6 42acd956 43015537 -> c08c792b 417a361f 41aba230", - "3f7fb000 3f79310e 42bdcf12 4301c50e -> 418b4a7f 4187c093 418b7614", - "3ee48884 bebab0f6 41a0f8c9 425afa66 -> 40f74428 c0c9fe92 418a7e02", - "bf63ba4c 3f6299ca 402ef8e6 420dbda3 -> c168b7da 41679106 4182ce15", - "3f3a8f56 befa9026 4184dc1b 42204c1c -> 4108cfca c0b7bf6a 413bbc1d", - "bd8aecc0 bf1746f6 41a1ab23 41a440c4 -> bc338655 bdc37cae 3e256840", - "be0bdccc bf70bfbd 41434a4a 4276919c -> c0581290 c1b9f735 41c5bf0a", - "bf43538d 3f3cf792 42ab3bd4 42c7313f -> c0aaa884 40a51a23 40dfab58", - "3f751c70 3de6b180 41addd8e 4204e810 -> 40b012b9 3f25b760 40b7e524", - "bed36fcc 3ec65c8c 42b094dd 42f88ee0 -> c0edc9fd 40df158e 418ff406", - "3eb63d04 be7a130c 429c5a2a 42f87870 -> 410326f5 c0b3f8d6 41b83c8c", - "3ece2858 bd94f9b0 4239a623 42b1fb68 -> 410927c2 bfc63983 41aa50ad", - "be940198 3f3ff07c 428d23ce 42b53f58 -> c039815e 40f091ca 41206e28", - "3f4b060a bf37ea32 3f1cd876 41a428fa -> 40fc9a85 c0e4d40c 411f4236", - "3f376520 3ef2a624 419b2bd1 42350fdf -> 4114421f 40c428e5 414ef3ed", - "3f7ef662 3f2eb48e 42c1ed34 42ca22da -> 4002d216 3fb34823 40035a60", - "bf6c6b92 bd45d3d0 42aad96e 42afa1b7 -> bf8d54b8 bd6c8549 3f990920", - "3ed9f93c 3f0ad63a 4247c26f 42bb0df0 -> 4114738f 413d1c3a 41ae5971", - "3d91d0b0 3ec03160 41893184 422d479d -> 3f6e8180 409d2eaa 41515db6", - "beddd444 3daecd70 410e8fe1 41ef44a6 -> c0919073 3f656925 4127fcb6", - "bf24bd91 bedde044 42c19f44 42f3b036 -> c100dfb8 c0ad91f4 414843c8", - "bd829450 bee71b20 41c3809a 4221c82e -> bf02a463 c0673793 41000fc2", - "bf2ef3e7 bf6d4852 42a79ee3 42aa198f -> bed8decb bf131122 3f1eab00", - "bf25ab61 3f000e1c 425eccd7 42bdc2e5 -> c14ad83f 411cca3a 419cb8f3", - "bed0ea42 bf5da984 42a761bf 42d1ed80 -> c08ae1ee c1135b47 412a2f04", - "be2c0a60 be96e360 41b4ffd3 42908104 -> c0856778 c0ea011b 41c6821e", - "bf7e61bf bf0a16f6 4269e295 42a3e80a -> c13aab02 c0caa9cd 413bdafe", - "3e7094f0 bec2ba28 41a7b4e4 4284e83c -> 40ab0082 c10a68c2 41b5f606", - "bebb477c 3dc98d20 41fcf611 428e616f -> c0e79558 3ff93b51 419e47d6", - "bea32a32 3f2d3468 428efca8 42b598e6 -> c044dec5 40d0fbeb 411a70f8", - "bf3036a0 bf14a340 4298d55d 42bae828 -> c0bba187 c09e44bf 41084b2c", - "3efc7c88 bebd459a 42875380 42eabff6 -> 41441e43 c1130436 41c6d8ec", - "3f4ee8ba 3ebf0d3c 429d2429 42ec5dc0 -> 418010bb 40ec8041 419e732e", - "bf43ed09 bf1c7a99 41adab8b 42454501 -> c12909f6 c1070157 415cde77", - "bed63ca4 3f5520ac 42a5274a 42bd36fb -> c0211688 40a04103 40c07d88", - "3f1c0bde bf4713f7 41bedf01 420b8f88 -> 40572c82 c089415b 40b0801e", - "bf3f17f1 3ed61908 42a9b8d8 42c1ae94 -> c08f14a7 40204e17 40bfade0", - "3f6ae0ce bf5cb68e 427b0981 42af2326 -> 4136196d c12b1e05 41467996", - "3eb96e80 3ea54974 42374b16 42454240 -> 3f21da49 3f1044fe 3fdf72a0", - "bf79d51b bebc2d80 41a5ad94 427a6422 -> c1a383f5 c0f65328 41a78d58", - "bf072368 3ebc7530 4289a963 42a825d9 -> c080becd 40338ada 40f3e3b0", - "3d106a00 3ec62078 42ba317f 42ce0722 -> 3e330622 3ff59c01 409ead18", - "3f7e8708 3f6e792e 4145c6c1 42063d7a -> 41289dd9 411dfb33 41299794", - "3e485ac8 bf342532 4229fcee 42b4e8ff -> 4096227b c186fdaf 41bfd510", - "3f7a7b5a bc80b840 4091f600 42002ba6 -> 41571ca0 be5d1643 415bd9cc", - "bf593b94 be882d14 407616e0 4234bc91 -> c18c50bc c0afeb11 41a55b23", - "bf1e7870 bea97458 42a712a8 42dc9aa0 -> c1048c69 c08dbc5b 41561fe0", - "bf4022a1 be9dec1a 423695d6 42aca6ac -> c1743f48 c0c8c139 41a2b782", - "bf57ca0a 3dd6e540 42c2ea59 42c31cbd -> bd29e703 3ba932e0 3d499000", - "3f1ce76a bed77a72 41429625 41e5adc6 -> 40a247a3 c05edc6e 410462b4", - "3cb28100 bf443e14 422d8aa4 4295c9ad -> 3eafc322 c1413a77 417c116c", - "3e948938 bf5b4b2c 42c698d7 430e4b02 -> 40c791d5 c19351ab 41abfa5a", - "3ecf1d34 bf73354f 42555c0d 42806752 -> 400c9a74 c0a51b46 40adca5c", - "3f088c5e 3f19b8f6 4250272b 42a54fea -> 4102a681 41131533 4174f152", - "3f36ef6c bd79aaa0 42add5ae 42f7e184 -> 4153a6aa bf906dbb 419417ac", - "bf2ef7e4 3ef8147c 4193248b 428895e0 -> c1886b98 41416ca7 41c7997a", - "bf32100c bdcf9cc8 428256b6 42a4f005 -> c0c08621 bf60793b 410a653c", - "bf350d06 3f2d44d8 409438c6 418465ec -> c086dbc1 40810fda 40beaf75", - "bf2d6850 bf447af1 428bfd7a 42c0a8b4 -> c10eb4b1 c121b18e 4152ace8", - "3ef29b04 3f2ae38c 42bfcf13 42d2d6ee -> 40104799 404b421d 40983ed8", - "bd4f9f20 bf7ed451 413f7b7c 42469cc1 -> bf748279 c1960d6b 4196bde2", - "bf3e1b5b bed34eda 41210b20 41a3ba36 -> c07727dd c0095c0b 40a6694c", - "3f616006 bf3c0b4e 41df371d 42245354 -> 40b9a52b c09ae524 40d2df16", - "3dc95dc0 bf345e3e 42070986 423e1216 -> 3f2d2782 c09b191f 40dc2240", - "bf433790 3f751ee0 4299c5ab 42edd9dc -> c1803b42 41a102ee 41a82862", - "3ee74120 3f2105bc 419d3c89 421bf3c0 -> 408bb79e 40c291f9 411aaaf7", - "3f12d4c4 3d0ecba0 42accbc8 42d0aaf1 -> 40a498ad 3ea01289 410f7ca4", - "bee7c984 3e9cf444 428228c1 428f638c -> bfbfa773 3f81c734 4053acb0", - "bee1eaac 3e791150 401cd43a 42178132 -> c0fa1a14 4089dd98 418db3ee", - "3f7a2a9a 3f4be6ce 417aea88 42274712 -> 414c5517 41268b3e 415118e0", - "bf045fa8 bf5d68bb 42abbe5f 42b64789 -> bfae552f c011cb8b 402892a0", - "3e198bf0 3f4d73d8 3fbb7514 410ff586 -> 3f109500 4041751d 40710dc7", - "3f2eb558 3f0413ee 3fbaa46e 422de574 -> 41656449 412d6afe 41a81051", - "3f7c6be2 3f7d2276 4297ae99 42befd81 -> 411b08f4 411b7918 411d3ba0", - "3e6d08e0 3f4795e2 42841986 42a36922 -> 3fe7ee4a 40c349ba 40fa7ce0", - "3f5ebf9c 3deb2600 4274a97d 4275a1de -> 3dd81e06 3c6425e9 3df86100", - "bf7fb0ed bf052a03 41e61941 41fd31d9 -> bfb88bae bf403914 3fb8c4c0", - "bdf8c7d8 bf430cb6 42b98619 4303c3e8 -> c0179d1d c16dbcb8 419c036e", - "bdb3cc80 3f76e04a 41b10034 428badf2 -> c0060c25 41b80e6c 41bedbca", - "3ed65770 be8229a0 4283b920 42a09fd6 -> 404195da bfeb1db7 40e735b0", - "be884042 be9eb9ec 42b11fb9 4301065a -> c0ac48d6 c0c8b423 41a1d9f6", - "3f204010 be811206 424e774e 42549bba -> 3ef6133f be463248 3f448d80", - "bf0aedd8 bf674595 41e48d42 425e5793 -> c0ea9625 c1434154 415821e4", - "3e2ea390 3f52a086 411f81e5 4260958a -> 407c0229 4197f85a 41b8b511", - "bf5fca7c 3f22f41e 4288df74 428a32ba -> be944b2a 3e57f5d2 3ea9a300", - "3f2ffc6e bf0dda88 42064a3f 42792c6e -> 411df3cc c0fea296 4165c45e", - "3f74b4be 3e7561b8 42907e07 42aeb674 -> 40e718f0 3fe7bc4b 40f1c368", - "bf6b7567 3ef051c4 3f974b17 4242e5e6 -> c1aee931 41328592 41be2b8d", - "3e4ebc78 be148c08 41c2e30d 421256a8 -> 3f9df181 bf62f9b2 40c39486", - "3efe2594 bcb4b1e0 426c304c 42a57f3b -> 40bc3cf1 be85d5aa 413d9c54", - "bf14ca00 3f0b8f36 427acf0c 42c34cb6 -> c1227e9a 41186a2b 418bca60", - "3e216458 3eb994ec 421ca136 428dd78f -> 40203318 40b835ec 417e1bd0", - "bf61f77a beeb4772 425a123d 42a8948e -> c1523c74 c0dae676 416e2dbe", - "be8f880a 3f6859c4 42b23b4c 42b66dd5 -> be969d62 3f73d13c 3f865120", - "3f0a9422 bf537018 4167c522 42258246 -> 40e8e99b c131af35 415721fb", - "bf5b3136 bf75eb9a 419b2f2b 41fd2fc4 -> c0a7d2b3 c0bc4988 40c40132", - "bf4e1a2f becf79a6 4245ca10 4294b072 -> c1205b1c c0a16c91 41472da8", - "3eab10f8 beaa899a 417dd624 427aa221 -> 40fa2663 c0f96071 41bb2c98", - "be9f636c be68a384 4265bec8 427ee9b8 -> bf7ab715 bf36f7e7 40495780", - "3d4503c0 bf221db2 40e6a380 416628da -> 3e30c26b c01172e1 4065ae34", - "3f781fb0 3f03c248 41edee18 429ab35e -> 41b893c5 4144075b 41be6fb0", - "bf38aae5 bf616300 429a05e0 42f253c2 -> c17ecbb5 c19b7d34 41b09bc4", - "be6a1e04 bf4ca25d 42817f67 42d370fa -> c095e0d8 c18300f4 41a3e326", - "3f6707de bee0839c 42844c7a 42bbc892 -> 41484ab9 c0c2a46d 415df060", - "3d6319c0 bf17140a 41986a74 4206f01d -> 3ed0667e c08aa353 40eaeb8c", - "bf221b24 bd393260 41e1b567 4290323a -> c15e4f8f bf7dfa2d 41af89c0", - "bea9990a bf75074d 42911846 42c7c62a -> c090e5ee c15157ea 415ab790", - "3f2802c4 3f70f748 42c2b0c2 430058b8 -> 4122c477 4169721d 417802b8", - "3f6326f0 bf0497b4 426b1530 428a69b3 -> 4094280d c02cf683 40a6f8d8", - "bf5d6eac bd4d0b70 41fc2fed 42450c74 -> c0f57ef4 bee353d0 410de8fb", - "be2f5f84 3f339042 407736e8 4229e258 -> c05396e2 4158a528 419a6eea", - "3ce65840 bee6b42c 4262ddd6 42afb61a -> 3ee025b1 c0e07f24 41791cbc", - "3f29cdd2 3f5f3566 40ce83b3 4206846c -> 41103465 413d8edf 415967eb" - ] - }, - { - "glsl": "vec4 cultmath_af_frustum_ball(vec2, float, float, float, float)", - "tolerance": "ulp-bounded", - "check": "enclosure and tightness: from the arguments (mx, my, z0, z1, fp, warpVariation) compute in double zm = (z0 + z1) / 2, h = (z1 - z0) / 2, axis = (mx h, my h, h), c0 = (mx zm, my zm, zm), |c0|_1 = |mx zm| + |my zm| + |zm|, R0 = z1 fp + warpVariation, spread = (|mx| + |my| + 1) h and d = |GPU centre - c0|. Enclosure: for z in {z0, (3 z0 + z1) / 4, zm, (z0 + 3 z1) / 4, z1}, eps = clamp((z - zm) / h, -1, 1) and the nine footprint offsets e in {(0, 0), (+-1, 0), (0, +-1), (+-1, +-1) / sqrt(2)}, the point P = ((mx + fp e.x) z, (my + fp e.y) z, z) satisfies |P - (GPU centre + axis eps)| + warpVariation <= GPU radius. Tightness: R0 + d <= GPU radius <= R0 + d + 2^-19 (R0 + |c0|_1 + spread). Report the least slack of each side; only the bounds fail the check.", - "cases": [ - "beb93774 3f479b84 42ac6b83 42b7c51c 3cd0299c 3fe1326d -> c200da26 428add17 42b21850 40830530", - "bf0bca41 be0414a4 413e0a14 421625b2 3d3a525b 3fd1a94a -> c157dcfe c04bf558 41c5a837 40561d5f", - "be2dfb28 bd20c890 41ba4c99 426ca91c 3d11916b 3e13d8fb -> c0e024bb bfcf2405 4224e7b4 400fd0ef", - "bf050336 bf416fba 40abd67f 423f8aa3 3c52ce78 3fddf6e5 -> c15d5d01 c1a0f614 41d50573 40166bbd", - "beab56ce 3ed232e4 41f94c2b 4226e88a 3b49b3a1 3f4c257e -> c1432321 416f64f5 4211c750 3f6d0a86", - "bd0a6c90 bf3768f6 42b275bf 42dd3156 3c779517 3fb28b28 -> c058198c c28f2a26 42c7d38a 40443e5d", - "bf562c1f bf3e9d20 428c538a 42b7d32e 3d2c355b 3da1a394 -> c287981e c2715bb1 42a2135c 407c6148", - "bf06c83c 3d495200 424a1bb8 42507dbb 3c92c895 3e30dd85 -> c1d82d7b 40217301 424d4cba 3f8da95b", - "bedf47b4 3dea4fc0 42b684a6 430cd45f 3cf29681 3fd05290 -> c24a6cc7 41546d0c 42e816b2 40b989f1", - "bc98d6e0 bd7f3840 427dc08f 42e25e16 3d1ff754 3fcd4cb1 -> bfd2e587 c0b0155f 42b09f2f 40c0c750", - "3e0cc908 bf77e4d2 42169549 429336ce 3ad13ce8 3fc48f94 -> 40f4bb0a c25775c7 425e8172 3fd39ed2", - "3f5a8534 3f79c588 41904b3a 4233197f 3d025c9d 3f951e59 -> 41d67679 41f5223f 41fb3f1c 4025c4ef", - "be843dbe 3f1c5522 41e1e573 41e74a7f 3cfb9dde 3fbb346c -> c0ec2afd 418b98a1 41e497f9 40167043", - "be8d0848 becbd22c 420b8a6a 42387c7c 3d3e5397 3f80a1cd -> c1328248 c180fdbf 42220373 40497ac9", - "bce1c4a0 bc881460 425c50bd 426c09e6 3d3fd46a 3fd4fcb5 -> bfc93b16 bf729479 42642d52 408daf50", - "bf5f873d bf539164 420b15f6 429f7baa 3d317033 3fd32033 -> c247f9c7 c23d468c 426506a5 40a3542c", - "3ea78e58 3d100da0 42460993 42acb84e 3baed6c5 3f3d0ca9 -> 41b1db73 4018e8d4 4287de8c 3f998521", - "3f5049d0 3efd37b0 42b84bc4 42d94f6d 3cfe7cf5 3fc93df3 -> 42a360f1 42469edd 42c8cd98 409e54ec", - "3d838380 bd394970 42ab17c6 4302af48 3d01b716 3f7599e8 -> 40de2ab3 c09c80ca 42d83b2b 40a323fd", - "bdbd6ef8 be9f91e6 410c1800 4251b393 3c40169e 3f89cd8e -> c0351716 c1188abb 41f4b993 3fd87c82", - "bf10a6da 3f325cf6 40a72cca 41b4df4e 3cc174eb 3f8c8cba -> c0fba210 411b2368 415eaa80 3fd0e5da", - "bf07755a bd69a9b0 42bbda82 42e98f00 3c8fc0f2 3e447cb1 -> c25efbd1 c0c0522e 42d2b4c1 400f71a2", - "bf06d1d0 3e805228 419d7836 4289439b 3c82b697 3eba4523 -> c1ba0ac3 41311307 4230a1a8 3fbac19b", - "3e2606c8 bf300516 42ae4131 42faaee0 3ce02564 3f6b16fc -> 4189cb76 c29216be 42d47808 408b2388", - "3f740cf6 bf2dbbf3 4235dff5 42b1ad60 3cb6fbf1 3f859f2c -> 428009ca c2364b8c 42864ead 4041d367", - "3ef3c748 3f149d80 41e447ef 4298b35e 3cd52c7a 3f035b85 -> 41c7c1a0 41f38e4e 4251c55a 40200124", - "beba6cf4 3df2ad50 41dd6801 4239343a 3b9deba9 3e98a6a8 -> c1577caa 408c40ee 4213f41d 3f057769", - "3f319c28 bf5983db 414dc001 424b52a8 3d088c06 3c70151e -> 41b0bffd c1d87638 41fec2a8 3fdaca80", - "bedd8910 bd4e8780 402f41d6 423fe7d2 3c709bfe 3e1d2890 -> c12f8c7a bfa3a85a 41cadbef 3f5bace9", - "3eab28f0 bdbf87b8 41f230fb 426f89ea 3c987015 3f1f037d -> 41711e27 c086e82e 42345134 3fde273c", - "bf4f6bbf be871b00 402ba770 41bc66f4 3d135757 3f8f3499 -> c12a091f c05d822d 4151dbe2 3ffba594", - "3f1f6362 bee0e2b4 412ac288 42669665 3d0783f9 3fc22ddd -> 41aa2535 c1701028 4208a384 405b2906", - "3f4fce44 bf1526c0 40c83c1d 42297468 3d3be7d9 3f713bab -> 419ddee7 c1629f21 41c27bec 4038b20b", - "beac9b74 bf10c054 42460bd3 428fb732 3cef6e3e 3ff88909 -> c1a3aa75 c20940bd 4272bd1c 40815852", - "bc11d3c0 3f2aa972 42476339 4270ffbb 3c6e08a8 3e07aa63 -> befadc50 4212ca9a 425c317a 3f81036f", - "3f68b660 3ee73abc 419752d8 428660ac 3c64828b 3fb9fce5 -> 421c8b0f 419b8bae 422c3562 4018fa46", - "bf40e876 be1014ec 420ec5e5 42803a48 3d422fcf 3f4577df -> c2166b2e c0e0b182 42479d3a 4073e827", - "3f4d90e2 be9f8ee6 42a2ca8f 42bd987f 3d4c91b1 3e2b3ae6 -> 428d7b61 c1dba239 42b03187 409cdcde", - "bf78447c 3f63e128 42568b5f 42be5d27 3c56c5e4 3e9d4f0b -> c29052af 42847895 4294d16b 3fc71157", - "3f21c5f4 3e979ec4 429ce991 42a26e8e 3d3ccbb1 3fe2b39b -> 4249cd5b 41bd2308 429fac10 40b07899", - "bf608c53 3e53c6e8 42c63fd9 42ca3a36 3d49b9cc 3fef69da -> c2afa329 41a5a5e2 42c83d08 40db36a3", - "3e0fb508 3f617d72 42ba4080 42dbc6f9 3cf59d8c 3f79b32e -> 4163ed4c 42b2d1c3 42cb03bc 4088a682", - "bf452fd3 3f06b6c4 41d7f3ad 4201cc2d 3cdfbc25 3ef54841 -> c1b725cc 417a3ece 41edc604 3faec4af", - "bf2f9462 bf0b713c 42a6ec81 42d05f15 3c1f42c9 3f3029e8 -> c280b319 c24c6c0b 42bba5cb 3fd9bdaf", - "3d789820 bf40b31a 423a4280 42413e1a 3bf7b902 3fa12268 -> 4038430c c20ed4fa 423dc04d 3fcfe4d6", - "3f6263f8 bf5d122e 424b6081 4294c5cc 3cd00747 3f30782e -> 425d7e05 c25849b2 427a760c 40250638", - "be582edc 3f394c08 420ff1fe 429fd4c8 3d0f04c4 3def73ea -> c143c00e 4227c88d 4267cdc7 403a13c0", - "bf31f656 3eb84d60 420ac126 42146ed4 3d12c17f 3f7ec31d -> c1c7a484 414ec149 420f97fd 4014c967", - "3f44d1c2 3ed40098 4125d51f 4216705b 3d37f058 3fb1acf8 -> 4193890d 411eea9d 41bfe5a3 4044ef5f", - "bf65d64d 3e9699c0 42247ae8 4292f6c6 3cd0fccb 3fdc7fd3 -> c24dc796 4186d642 4265343a 40663c1d", - "bd74fca0 3d913270 429e3976 42bc6a16 3ca17333 3f87d6fa -> c0a5dcfa 40c49aee 42ad51c6 403ac0b4", - "3f75a11c 3e9397c8 41cd91a8 428fd914 3d1271b0 3faef3fb -> 423b54b9 41612022 42433d7e 407c0ff2", - "3f42b820 bee2ce46 42542845 42b7aeb7 3c57ca93 3f8347ba -> 425c6611 c2005bbf 4290e16d 400f119a", - "3f7ee486 bd124650 422348f9 42b2657a 3bf90c98 3f628a92 -> 42817502 c014951a 428204fb 3fc811bc", - "3d5a96a0 be5236ec 4188e47b 42673c12 3cac5bc7 3fdc1d7b -> 3fffe2c4 c0f61549 4215d728 403be78d", - "3f5e3c98 3efd3538 420d5353 4270eccb 3ca7cae3 3ea62cba -> 4225eb0a 41bd0a6a 423f200f 3fc77917", - "beee0830 3f33896a 41e6321d 428b1d0c 3b666cc0 3e13359e -> c1b6dbf1 4209ec22 4244a993 3ec6e4e2", - "bf046bd1 3f6b742c 42c682b5 42f074ba 3d083a35 3f9e929f -> c2631076 42c9de2c 42db7bb8 40a79bab", - "bf2bf828 bee64aa4 421a4c43 42a6ee46 3d05206e 3d5dfbc1 -> c223f63b c1db9180 42741468 4031189e", - "bdbd9fa0 3ba7ea00 421a4d54 426004a2 3d1ed3ec 3ffedf4c -> c08c1d34 3e782546 423d28fb 4085367d", - "be8f0384 bf2b1706 41b437df 4229696b 3d4adaff 3ff79b62 -> c110fb0e c1ad716a 4201c2ad 40810693", - "bead5176 be70d0ec 42ae08df 42d2cfc6 3cd0a993 3f5293b8 -> c202466e c1b50296 42c06c52 40607c09", - "bf0c665e bf22b2e8 4225b59c 4268e255 3d14d4cb 3ec3020d -> c1da9a7a c1fd52b5 42474bf8 401fc6b6", - "bdcd22c8 bf490a04 42929fd3 42c9b82c 3d05380a 3e93ffce -> c10b90e6 c288c75c 42ae2c00 406474af", - "bd4f4c80 bf6d6f8c 411e268e 41d15b56 3b17125d 3fe7e95b -> bf698fa1 c185c20a 4190374e 3fefa3c6", - "3f0de540 3f5693e4 40f4d16f 41b1d604 3cbaecc9 3fe711e8 -> 41047ec7 41485cc4 416f0a60 40140051", - "3f31dc18 3f30a038 42c1e20e 42c46f83 3b942376 3f106dce -> 428796fc 4286a62e 42c328c8 3f811418", - "3eff5dd8 3f17cc1e 429960e7 42fac382 3d09c365 3f6f280e -> 42499235 426fa3b6 42ca1234 40a4d91f", - "3e6843b0 bf439a26 429b52de 42aecf62 3d380f96 3faaf06d -> 4195c32a c27c3ee0 42a51120 40a86d35", - "bef2f434 3f1e73c4 424e9dd9 425ea592 3d3ccbb6 3ff44845 -> c1cbb19c 4204d8dd 4256a1b6 408f2c65", - "3f3d114e bf7d59af 42078db7 42a430ff 3cf234a8 3f96df9c -> 422b51aa c2659136 4267f7da 4066cb73", - "bea83dbc 3f5e626a 42917241 42c49028 3cc87361 3fe195fd -> c1e0c40e 42948cc8 42ab0134 40855bd2", - "bf0ed226 be1a7200 3ffc94e7 41c42310 3d243970 3fda7216 -> c0ec7627 bfffb520 4153ec5e 402c22f9", - "be7a1ea8 3ade6400 4211f380 42881122 3d11f7cc 3fed1d3b -> c14c3da9 3db59918 42510ae2 4088dd6a", - "bf3db0ec 3e28d4b0 4009e2de 41b46c58 3ac8cc13 3fa552b6 -> c1127627 40025aee 4145a8b4 3fa9c03c", - "be685384 3f08eab0 42b8ab99 42ba34a8 3c0139bc 3e2ad761 -> c1a84a1c 42465b22 42b97020 3f66bd35", - "3f634258 3f120b50 41a56a6e 41ec67ce 3d02d71a 3fbcd80c -> 41b25ac7 41653ba8 41c8e91e 401ad6df", - "3ef5e84c bf4b9a14 427bfd9c 42d78476 3d476a0f 3f72a8dd -> 42240642 c287ce51 42aac1a2 40c63854", - "3e988e10 3f1fbb02 3f661fd5 420828f7 3d0fe944 3f57798f -> 40a690d8 412e667f 418bc176 40026a65", - "3e384a60 bf05ec1a 41eafa9d 4247e978 3d2afff4 3c8429d8 -> 40e47e15 c1a60b20 421eb363 4006929b", - "3e0cdec0 3f5b0f66 42b52601 42bd488a 3bcede04 3fb88fb5 -> 414bd6c6 429e7d6d 42b93746 400287f7", - "3f6a7484 bf1694c8 41d76892 42936300 3cd007d9 3d0503d9 -> 42384d7a c1ecbd8f 42493d24 3ff3b7db", - "3e96dd10 bf195004 42ac9176 42eb3b94 3d367591 3f9c1d0e -> 41f05249 c2743901 42cbe685 40ceb170", - "bed04296 bf080894 4273abdb 42b081be 3d1b83f7 3eddeca0 -> c1f2b4d5 c21e8893 42952bd6 40723364", - "3e8d1a6c 3ee52d34 40d403c4 41fe0380 3cae9efb 3feae97a -> 40a93922 41096c97 41998238 4020c6aa", - "3f14af90 3d828ac0 42be21ed 42d1f081 3cf992a1 3fb5d5bf -> 42685d05 40cc0232 42c80937 4093cc68", - "3f29ff00 3ea2cb50 42c391ff 430f3820 3d3ffb09 3fc48b82 -> 42a009ce 4219421d 42f10120 4103f9e5", - "bf16d3c9 3edac618 41f49d2d 42a05464 3a64023b 3f80648b -> c2027db3 41bd46b5 425d7baf 3f89566a", - "3dee2a10 3f6d44bc 420b5b1a 428a010d 3bbfed6a 3f99ae8e -> 40c13673 42407c67 424fae9a 3fcd6e65", - "be4e4680 bf74a6fc 4187d986 424db8e8 3cb60f5c 3f4d2946 -> c0dc7ead c202c233 4208d2d6 3ff8e5f7", - "3e9f5b9c bdb64b28 429c3058 42bf4ad0 3bf041d2 3ff99b99 -> 41d84dd6 c0f76f92 42adbd94 4029b1c3", - "bf5e668b bdcf2e60 426cfa3e 4285bf2e 3d22ceaf 3eed4736 -> c25b2154 c0cc2274 427c3c4d 4047c8ef", - "3e872820 be657680 41ee2faa 428fa72e 3c8c4c20 3db93d41 -> 41568f96 c13622c4 424b3318 3fa90b7f", - "3f52c3d8 3e958a78 428dbbec 42c61f12 3d41694e 3f6c6b4d -> 428be6d1 41c68649 42a9ed7f 40b33e04", - "3e0f2148 bf491c9e 4226d503 426ceab2 3d23a44d 3f961bd3 -> 40e1bc93 c21e9753 4249dfda 4062813c", - "3da93660 bf36bbc6 41ad1d7a 4249ffcf 3c5083bd 3f76ac89 -> 403ebb65 c1cdf8ff 42104746 3fcd9d0d", - "3f795bd6 3f358286 4263a898 4292d8ce 3d3db3f4 3f90e5e5 -> 427de9e2 4238d34c 4282568d 40910c56", - "3f51a9c4 be410e38 4187c269 41b63d02 3b2e055f 3fba37f5 -> 41823834 c06fcf3a 419effb6 3fc1f784", - "bec96e5c 3dee93a0 42884165 4294a60d 3d1f46ed 3fcc1e06 -> c1e02c8a 4104c1bb 428e73b9 408f84bb", - "3ec4f150 bf50fab9 424cae74 42864051 3d200ab7 3d9a884d -> 41b6030b c24122d8 426c978b 402cb23e", - "3defc120 3edc7f90 42823a49 4282d0a0 3cfa9ff7 3fa6c550 -> 40f47a1c 41e0d773 42828574 405375c4", - "bf77c0c5 bf63e8b7 4159405c 42595e82 3d2ef5be 3f792ff0 -> c2037704 c1f1dec9 4207d74c 4052dd5b", - "bd406fa0 3e272250 42900937 429e4a4d 3d0623c2 3f89de1b -> c0634276 41456101 429729c2 406ad29c", - "bed4152a bdbcf5b0 40b633b8 42209a8f 3b204455 3ef62701 -> c117eb82 c0075b3e 41b76106 3f143a2f", - "3f4f9118 be28d8f0 42129553 42664309 3d3540ed 3ea51280 -> 4218c644 c0f88d54 423c6c2e 4037abed", - "3f70ee96 3eac17ec 40ee2627 4207fc22 3d1e1936 3ed7dd77 -> 419bff53 40deda31 41a5c0e7 3fddefda", - "3f54978a 3f4ec216 429ef7d7 42d2b842 3ba6a59a 3fff106b -> 42998055 429549fd 42b8d80c 4021d78a", - "3e3d7048 bcc3ddc0 428ce853 42a0599e 3d04b365 3ec85cb6 -> 415eedd0 bfe67e2e 4296a0f8 403f4a4e", - "bf585aac 3dcc9ea0 422f3eaf 42b8e3d2 3ab7b03a 3f278016 -> c2664f31 40d9d161 42884195 3f48b5e7", - "3f76a5c6 3f3d2902 4285bb50 42aec8ba 3ba73b05 3ec6307d -> 42949f55 4263f6e7 429a4205 3f55544c", - "bedb8556 3e485ba0 4188b7ec 42838d2f 3d2d0d8f 3ebe683b -> c18e1d6f 4101b58a 4225bb2a 4049a980", - "be31c4d8 3f641b6e 42a20eda 42d4fa2d 3c3b596a 3fc01e56 -> c18236cf 42a7161d 42bb8484 402e0136", - "3ef9c38c 3f0d0a28 420dd712 4219cec6 3ba132d9 3f8f17e4 -> 41903912 41a2e213 4213d2ec 3fa750c8", - "3d940900 3ed834f0 429a1b82 42ab23cd 3c8c263c 3f2b704a -> 40bc1409 42095857 42a29fa8 40088f3e", - "3ee50578 3f7eecd8 428077ab 42cb1b6c 3ce157fc 3fe6ed0f -> 421450d5 42a5175b 42a5c98c 409321b1", - "3dadfe70 3c1db300 42a0c00d 42dcde06 3c3f254a 3f808872 -> 4101af8f 3f6b14c8 42becf0a 4012bb0f", - "3f270daa 3e7345e8 4280bed9 42b495ba 3d200d4a 3fb3a44a -> 4249daaf 4192f9e0 429aaa4a 409dd165", - "be6a5c60 3e0bf558 42016474 42856940 3c3ca9d5 3f00504d -> c1355c9a 40d89d8f 42461b7a 3fa27cd6", - "3f724698 3f581b5a 429a9eb3 42a59318 3d3319d5 3f473c1e -> 429783af 4287261d 42a018e6 408cbfea", - "be1d3608 bf44e19b 41ce2f46 42871279 3c4e13ec 3fd8c62a -> c0e534ed c20f85a7 423a9e4a 4022c2d7", - "3db414f0 3eaadb78 421ebfa5 42aa2e42 3d45f9f9 3fb8eb3f -> 40af8c4f 41a68e4b 42798e14 40b1d792", - "3f64d12c bf36e06b 4259a6c9 42c20414 3c406f8f 3f74a197 -> 428757ac c25856aa 42976bbc 4006182f", - "3f54c7e2 bf76dd24 42ba075c 42c0e7d4 3d20c5cd 3fc5c2d5 -> 429d7af9 c2b6b497 42bd7798 40aa98cd", - "bf79d640 bf6d471b 4299dfd9 42c105f3 3d1e6f2d 3fa08e3c -> c2a945eb c2a0c38c 42ad72e6 409f9b48", - "bf3ddbd2 be08fd58 427c5df1 42a7a33a 3c130b8e 3e6e3e20 -> c259e87b c11d3a70 4292e919 3f7c2e02", - "bf028302 3f7b6aca 4213be28 42998901 3d478dc0 3e69e867 -> c1e7de75 425f55e9 42636815 407dfe9a", - "bec73610 bd3826c0 4270d950 42b47a96 3d17b1ea 3e30018e -> c1ea274d c05873c1 4296739f 4060e5a5", - "3ed3e824 bf41e201 4289cde3 42a75379 3c2010f8 3fdb3e62 -> 41fc9330 c2671787 429890ae 4021f1b3", - "bda7b428 be94d55e 42049e0c 426588e4 3d28a965 3eda9dee -> c06d3e43 c1528c5a 42351378 40328ebc", - "bf58408b bf31de96 42b2c2f8 42ffad0c 3d1f9a0c 3f8893c2 -> c2b77e06 c296ec97 42d93802 40c18ddb", - "bf5100b0 3d850e40 42c0ffff 42ebbee9 3cf8dbc0 3ef823f0 -> c2af0481 40ded70c 42d65f74 408219aa", - "bf482807 bf4313b2 408e4c9d 4234f78d 3d1c6285 3f1d3875 -> c19b65f5 c1977467 41c6c121 4015dc72", - "bf288f7f be351938 41edac75 427f7d5a 3d0c4cbf 3fa6de3c -> c1f678ac c10466fc 423b29ca 405f7626", - "3f607de2 3f2b0fd4 41c0127a 427adede 3d43ad72 3fd2bd31 -> 42181ad7 41e7ce7e 422d740e 40949173", - "3f12272c 3f056ec0 4186f404 41c51d24 3d135beb 3fd25d1e -> 413d9499 412d1492 41a60894 4021eaa8", - "bf0f192a 3d94eea0 428bcab1 4292a1e0 3cd0c13b 3ed4adc5 -> c2201acc 40a6a1bf 428f3648 401229d5", - "bf420f7e bee1b144 424e0314 4293a7d7 3c19b606 3e192bd3 -> c23e0387 c1dcfc70 427aa961 3f57a5c1", - "3f20358e 3e92a1e4 426cc691 42719346 3c810e1e 3f52bf6f -> 4215ae1c 4188fedf 426f2cec 3fe32bea", - "3f558ebe be583418 423b7b4e 426be2f9 3d2a2f10 3ff1dbaa -> 423096c1 c132c6da 4253af24 408adff0", - "bed2c3c2 bebab636 42670414 4281b3a2 3d039af7 3fd89e6e -> c1c9e189 c1b2d787 427535ac 4071abf1", - "bf59dfb0 3f685d52 42204016 424ca320 3cf42fd2 3ee834c3 -> c21b45b7 42259976 4236719b 3ffd435e", - "3e5e0820 bf4b7d22 42b49978 42bd7cb6 3ce6a563 3f4f45c3 -> 41a07d7d c293163e 42b90b17 405e8cef", - "bf39b5ec bc81d7a0 4281b09d 42922916 3d44df9c 3f1fd4f6 -> c2481c5a bf8be90c 4289ecda 408462c5", - "bf0962ba 3f05f744 4232fbec 42a51f05 3c44529c 3f262924 -> c208a433 42053d7b 427e9cfb 3fd1baf8", - "be95f41c 3f75100a 428d3419 42d8992e 3d1e9de7 3ec397b1 -> c1d195aa 42ab41f0 42b2e6a4 40926f90", - "3e85b604 3f755b04 427f3a88 42c2756b 3c98da5d 3eedbe20 -> 41a838b4 429a5732 42a10958 4011d6c2", - "3eb2f588 3e3aa250 409c2745 41b8fef6 3caa9f4d 3ed835be -> 409c9cfa 4023546c 416008c7 3f676991", - "3c8ecf40 3f282566 42a67993 42acd3f5 3bae4b07 3f2d5800 -> 3fbd47b2 425edc73 42a9a6c4 3f9185eb", - "bed0383c bf3da053 420ed5ec 4243daa6 3d3a6cb7 3fe15722 -> c189bcee c1fae078 42295849 407f4d4f", - "be4e5098 beba23d4 428f32db 4296c437 3d31dd6f 3f9de0d5 -> c16ce95c c1d5bea7 4292fb89 4090393d", - "3d2c5d20 3f3582ee 4203ace0 42890859 3cbc16b5 3f95407b -> 4008977b 420fd746 424adec9 402f5071", - "3f08c3ee bd7eb730 4141a7dd 42039f68 3cc9078b 3f3d7c49 -> 41405d8a bfb32221 41b4095f 3fc61bdf", - "bef15490 3f3bda8c 420ac448 4239f341 3c4c019a 3f51c683 -> c1990e05 41ee4746 42225bc4 3fb2fe01", - "bc7b7740 bed6d128 42aed5bf 42d39051 3cbbbacd 3fa4f7ec -> bfbdc708 c2221e82 42c13308 406da32f", - "3f2b4bd0 be8997d0 40e02405 423385a2 3c5da86f 3ddbf1c9 -> 418adebb c0df1800 41cf8a23 3f36f42e", - "3d06da80 3e4b4ed8 4290a34a 42bbc33b 3d2cdbf4 3f8f9579 -> 402f195f 4183fdd5 42a63342 40a2aece", - "3f43e786 3f17f95e 42145e81 42463cce 3c73d1bc 3fa2bc16 -> 42049ee3 41cdc33d 422d4da8 4000936f", - "bf102cf4 3f42ef80 42800b61 42e2ae2e 39094534 3db0ed69 -> c247c6ab 42870e3e 42b15cc8 3dcfd452", - "3d8b2700 bf2c4a49 40e533e7 41b3c0b4 3cef34f2 3f93f7ce -> 3f80da8b c11f89fa 416d0dae 3fe7f41f", - "3ef87cb0 bf3136c0 421f26bf 4293fe2d 3d33ba2f 3e3d68f3 -> 41dce3d7 c21d884d 4263918c 405ba5d8", - "3ce3c580 bf7b0fa4 41a078e0 41bb2140 3d38406f 3fe3f7fc -> 3f1aa2eb c1aa72ad 41adcd10 40355445", - "3e96b57c 3f2a9824 401a92d9 4226bf46 3c912cf2 3f66c261 -> 40cfb487 416b1c68 41b06874 3fd1f369", - "bf6bd08e bf0383e8 42c6ccd2 42dea6e6 3bf68221 3f9395db -> c2c21c49 c258835f 42d2b9dc 3ffed12a", - "bf7dac27 3f324812 42124249 42177b42 3c385d33 3e584fd8 -> c2138446 41cf599e 4214dec6 3f23321b", - "3f774be2 bf143d3d 3fdab9ff 410f684e 3d0d205c 3fb099d4 -> 40a4f16f c045bf2d 40aabf8e 3fd821e2", - "bf2c3cc5 bf1a5bfc 42b7ea46 42d3b5da 3d16b21b 3f12ba3c -> c28516c0 c26e8c7b 42c5d010 408ef90b", - "be034ad0 bf3233ae 42c441e4 43079963 3c8b7830 3eab721a -> c16fbd4f c2a2b2be 42e9ba55 4029320f", - "bf75bff5 3efe8cd8 42a21bfc 42e01dcc 3c5b92bf 3f2e18d2 -> c2b96174 424004e9 42c11ce4 400ba786", - "3e2c0b20 3c0ccc80 3f1caacb 42269bf1 3d0b4e44 3d6e93a6 -> 40633a53 3e39f613 41a90e9c 3fbcc968", - "3ee8eeac bcc4de20 429d4599 42a6b4f6 3b8bbd28 3fb061fb -> 42136490 bff924f2 42a1fd48 3fdde59a", - "3f3fb12a 3b946700 4168ec2b 41f9d888 3cfefeb1 3e9e5531 -> 41892514 3dd458d5 41b7274f 3fa405c1", - "3d7fa4e0 3f05f29c 424b55b3 42ac6a3a 3d246d74 3fff2e99 -> 4088d9c2 420f68b2 42890a8a 40ae8a87", - "3e430bc0 befab05e 424bce8b 42735b1c 39cebbd9 3f732845 -> 412a58a1 c1daf15f 425f94d4 3f7952e7", - "bed1a648 be8c4828 42bccabb 430033e7 3ce61b68 3ebc9811 -> c2364bb7 c1f3f51e 42de9944 407e0f27", - "3ebd27d8 bea0f18a 424fc62a 42c0ed2b 3ce1c918 3efd3da0 -> 41db4ff1 c1ba9a34 42946820 4049d249", - "3a624800 bea2133a 40de284c 41ac8155 3d333e42 3fd6401a -> 3c499235 c0906058 41640b68 402784ba", - "bf745fdc 3ebf2c24 414c44af 42363a55 3b9474de 3f81446b -> c1deb352 412e378f 41e94b81 3f9bb2ff", - "3f2a1498 3f40d030 428c6c9b 428d46ae 3c3a0689 3f5947d8 -> 423b27b7 42542b8c 428cd9a4 3fd35245", - "3d24a2a0 3d74d7e0 42410aa5 427f509e 3d23b2b6 3fb86f76 -> 40102ba5 40566889 42602da2 407f7b74", - "3efaf950 bf1a74d0 42bc4885 430e2b5e 3d04fa77 3f0ed3fd -> 4267abe6 c28e93ba 42ec4fa0 40a58fc8", - "3e8aec78 3e9036ec 41a9a808 4208f734 3c2adca7 3f6be777 -> 40f0b8d7 40f9e3ca 41ddcb38 3fa3aa8b", - "3f5b4bba bec9c3c4 42185695 428f62ff 3c109cd0 3f236f01 -> 423c13ac c1ad0a9e 425b8e4a 3fa2bc1a", - "be9b85de 3e8ee0b4 41dbf470 4245ca5e 3d2ce420 3faf2f7c -> c13af8f7 412bc530 4219e24b 405d2d3d", - "bd109500 3eb4a2c8 413d15d4 4184723c 3c982e35 3d27800b -> bf003283 40a02a54 4162fd26 3eb26a63", - "3f07cad4 bf1f20d4 42594f74 428f78f0 3ce07f18 3fad37d6 -> 4205bcfc c21cb89e 427c20aa 40546f6f", - "3f4a8690 bf602cbd 4079e83e 42393125 3a905b89 3f655a30 -> 419edd69 c1afd8cc 41c8cfa9 3f726fb3", - "bed34890 3e12bcb8 4285fc93 429e1bec 3b861989 3fec2d79 -> c1f112fd 41276d4d 42920c40 400acd4a", - "bf69651d 3f322b4e 420e4301 422edf06 3d454267 3ea33366 -> c210909e 41dcb74f 421e9104 401b273a", - "bddc3ac8 bec683a2 420e0944 4241794b 3cc44bfb 3ff8e255 -> c090509f c18215c0 4227c148 40469f7e", - "bf2d3a2e 3da84dc0 41d907fe 4212b708 3ccb4be8 3d11ada8 -> c1acb4e5 4027cc41 41ff3b07 3f722439", - "3f55fb22 3e2464b8 42973494 42dd9210 3d1f2127 3e66d9c7 -> 429bcb7b 416f61eb 42ba6352 4090f2fb", - "bee02208 3a176800 4277efd9 42ce992c 3bf0d5c9 3f0b6234 -> c210b573 3d4381e0 42a5488c 3fa6e3d9", - "bf787730 bf047732 426eb818 428ad92d 3b2b76bd 3f85b4b1 -> c27a9bc5 c2059baa 42811a9c 3f9cf9ff", - "3ea96870 3e519760 41b57ef0 42277610 3d38bb0e 3ef6d3f6 -> 412adead 40d36662 42011ac4 4017b2c2", - "beb61442 3e8dd7c8 4269c050 4276f710 3d0ca7de 3f753c8c -> c1aaf434 41852d19 42705bb0 404501d1", - "bf252c98 bf4b5965 40f73567 42214768 3c84e9bf 3f7fdda2 -> c177fe5b c198a7a6 41c02e15 3fd3ae05", - "bf2a9b02 bea344c8 40e78f6a 419addcc 3d34a200 3f6cf67b -> c10dc96b c087b076 4154c1a6 3fe3c274", - "3da37ce0 3e75b248 41815ab9 41a24ff5 3c47c0c4 3ef29ac7 -> 3fba43f3 408bf6bc 4191d557 3f38a24b", - "be7e57a8 3f6f129a 424477fb 42ad1106 3cd79773 3fe49a5f -> c186c5a8 427d5c9d 4287a682 408207f1", - "3f155802 3d8d4400 4287c1af 42bb3d82 3c9cbada 3e8d58d5 -> 423c6d91 40b23c59 42a17f98 40044fb3", - "3d6b9600 bf11cc60 42a2dc82 42b0ed4e 3d05084b 3dade129 -> 409c58ad c2418493 42a9e4e8 403d535f", - "bf1bb265 be8c64fe 42b7a4ce 42c153d5 3ac3da35 3fb5ba02 -> c265453d c1cebcb1 42bc7c52 3fc83cb3", - "bdc94cf0 be1d647c 42902bff 42dc811f 3d2cd19e 3f104d53 -> c10f60c3 c1603550 42b6568f 40a6e617", - "bf56f174 bf0521ba 421eb82a 4264277a 3d0d7435 3fb81f66 -> c22269eb c1c93128 42416fd2 405a232a", - "3f7a0474 be112800 426724ba 4285ec44 3d303663 3fc9e520 -> 4273aa00 c10d77b5 42797ea1 408ea94f", - "3f247e5a 3e9bb208 42bfd6c4 430e9712 3d123fa1 3faaa130 -> 4299414a 42110eda 42ee8274 40cd95b6", - "3e98440c be4df7b4 42c239c1 42ce1561 3d358feb 3fe1222d -> 41ee1964 c1a1095a 42c82791 40ca72c5", - "beb99154 bee225b6 42bbcfd5 4304f2a0 3c74cb85 3e516812 -> c22470b6 c2486659 42e2da8a 400c3b3b", - "bf27bb19 bf71745a 428a40f6 42b1ed8f 3cb27486 3e90d246 -> c24f296d c2951bbf 429e1742 400e2619", - "3ef7a4c4 bf22f650 42524176 42654531 3bfc177c 3ee1055b -> 41d496e7 c20be50e 425bc354 3f616ce7", - "bd8f4c80 bf799240 42494de5 42633c6b 3c62c745 3f407536 -> c06fe152 c250e3ad 42564528 3fc4e465", - "3f005dd2 3d0efcc0 428dfb41 429367fa 3bbea16b 3f6360f3 -> 42111bac 4021a2c2 4290b19e 3fa8961c", - "bec1cd24 3f6c6f42 420dba06 42751970 3ac5f43e 3f526421 -> c1926bb3 4232a187 424169bb 3f6a1dce", - "3f0f7a6c bf15bf9f 41541e75 4214168e 3a296c33 3fd4ebd3 -> 4161700e c16b4a33 41c91e2b 3fd7fe68", - "bf4dfb39 be1a4e68 41ae9f5e 427add27 3c1e4032 3f882523 -> c2080ce2 c0cbd68c 4229166b 3fd5b2b8", - "bf379ffa 3ddc62f0 41c66934 42797c60 3d05f4b0 3fdfae1f -> c1fa1c69 4096176d 422e587d 407264fa", - "be7c9768 bf1f1476 3ef43138 41e51791 3ad1d366 3fc7ab9d -> c065ce74 c110baeb 4168e856 3fcd8b81", - "be5be394 bf436890 42b6c86d 42cf7beb 3b8fb3b3 3f720e2b -> c1a79bb4 c294f2bb 42c3222c 3fb34979", - "3f1354dc bf0cc34a 4176e0f3 41a9353b 3c817251 3ff1d45b -> 41286c28 c120e9dd 419252da 400e4ec3", - "bf52ec4d 3f7acac0 3e8575fe 4207438a 3add0aa2 3fd9c918 -> c1609c5c 41858893 41884e76 3fe118cc", - "bf2ee662 3f5db0c2 4202a098 42263863 3d3af4ef 3f8f8efc -> c1cacea0 42008824 42146c7e 40412d33", - "bf1b380a 3df341b0 41f745a7 425ba40a 3be85c9f 3fd6c668 -> c1d0230d 40a3182d 422ba36f 4004503b", - "be3e29b4 bf10d4be 418e9d47 420dae8e 3b8a437b 3fe481c2 -> c09e369d c170fed8 41d4fd32 3ff7a51e", - "3f55f656 3f33a040 4207c63c 428e5d8c 3ad11fde 3ff76bbe -> 422fba1e 421386d4 425240aa 4002fd7b", - "be791c44 bf721e34 41bfec95 421c834a 3d07fbe9 3fa9df0d -> c0f5ae21 c1eec8b7 41fc7994 40281427", - "3f3e8972 3ed28f2c 417d5b33 41bbf71b 3ca64147 3e46d602 -> 416a2f2c 4101658a 419d525a 3f2bcadf", - "bdbc2310 bf120188 41a5264e 42193616 3b2a23cf 3f86c828 -> c02d4814 c1867a2e 41ebc93d 3f93849a", - "bf2bd83d bec4c658 41096a7e 41c28ed4 3d10eefa 3e47bfee -> c130b8da c0ca5c18 4183a20a 3f871f8c", - "3f08ce96 3ef1f7e4 42b57928 42c06434 3d1a5860 3eb94d8a -> 4247cb4c 4230afb5 42baeeae 407f2a29", - "3cc3ca00 be30cf34 42b49f8f 42d893a5 3d23ce83 3fe2b5d3 -> 4017e3b6 c1892a58 42c6999a 40c3433c", - "beb6a64e 3f49d7ae 42b33c80 42f3ba30 3cf94452 3f5e73f1 -> c216e313 42a6be04 42d37b58 40927924", - "3eb9d098 befbcd96 42a28596 42aa9372 3d37e2c9 3fde230f -> 41f1c681 c223d186 42a68c84 40b2108d", - "3ebf7308 3e04cbf8 42a033a4 42f16f0c 3cee0fba 3fb8ddb0 -> 42162e6d 415057e4 42c8d158 409e7aea", - "3f43564e bf5f4b9a 42004746 421ca283 3cdbaf96 3fed50c9 -> 41d96621 c1f883c9 420e74e4 4039df47", - "3f0337f0 3f06ba2a 42be815f 43101486 3d0371a7 3ffdb4ac -> 427559cd 427be94b 42ef5536 40d36473", - "bf1ca30d bf4f8880 42266466 42666e38 3ada9ec5 3e9f89c3 -> c1f2cd17 c220d8f2 4246694f 3ed0cd73", - "3e858b3c 3d1ff740 428c126c 42cd20cc 3d01cb61 3f67ef72 -> 41b4135c 4057b436 42ac999c 4084ff7f", - "bedc0b76 3ebf53f0 42a7c1b0 42abbb1d 3cad576b 3ec0d27b -> c211e739 41fdb96c 42a9be66 400c64da", - "be7573ac 3ecc7584 42a6b197 42b8cc7c 3cc42bc0 3fbc4da7 -> c1a8813d 420c5ce9 42afbf0a 406bc565", - "3e064a00 bf23d44c 420fc7d6 42a8cc1c 3d36056f 3fd83a36 -> 40fc836d c21a07ae 4270b007 40ae1474", - "bd1376a0 3ed1d518 42755ad8 42ccd1c0 3d358efe 3fcd9251 -> c03ca5c8 420637b7 42a3bf96 40c4a87c", - "bdc34530 be8849aa 42558e09 42ab491a 3c1653da 3df931a0 -> c0d4196d c1940893 428b080f 3f68576c", - "bf74b2df bf09b6f0 422c9127 42acfce7 3d2f7833 3fd93bdd -> c277d360 c20b7975 4281a2bd 40ace2cc", - "bf52be3e 3eddefc8 4208b3e8 4290c613 3cf49d2c 3ff101a6 -> c22f72a7 41b8c445 42552007 40816c8f", - "bf2f3d32 bf79403b 4276dcce 42bf6bd8 3d1a9e7c 3fd9f566 -> c2578675 c29946a4 429d6d20 40aa1cc1", - "3f180ee4 3ea53900 427c8993 42d3d052 3c0b6434 3fed98d9 -> 4248d033 41da32e2 42a90a8e 40307a26", - "3f2e144a bd9490c8 42a0269c 42a3bb1b 3cf0dd85 3de1d4c4 -> 425c3d16 c0bbf5aa 42a1f0dc 40211e05", - "3e9e9980 3ef0c88c 424f4fe3 42b4e82c 3c037a81 3efcc983 -> 41b04b93 4205d304 428e480f 3f9c20d3", - "bec7f9b4 3ecb519c 4201ae0c 4267bf62 3d34690f 3eaff0f6 -> c18d2a4d 418f867f 4234b6b7 40395175", - "3be80400 3edf0cf0 412f0ec8 42321761 3d080d7f 3fdf83f3 -> 3e491201 41414d0c 41dddb13 404e68d6", - "bf20a50b 3f0b83e4 42751fa8 42bec52a 3d2dbcb4 3f8540b8 -> c2449f20 422ac293 429caa7f 40a2c9b3", - "be0fa388 bf2aacb0 40cb1b88 41fbe91e 3abdd2db 3f4918f9 -> c029d5ab c149cd0e 41975800 3f54c93e", - "bf676a91 bf64f96b 41509c09 41dabf4c 3bb5fc5b 3fdc7b32 -> c19203bf c190794d 41a186a8 3fefedc1", - "be1c6614 be6af620 42aae719 42cfe809 3c9a29b2 3de5185e -> c1676d45 c1add6c4 42bd6791 40045e7c", - "3d645f60 beda5ebe 429c2dfc 42ca1b2b 3c90a95a 3f66be2e -> 409fcf52 c218cf72 42b32494 402be6e8", - "3f23a1d0 bf29c393 42a00e6f 42fccd76 3d2e0315 3fd09267 -> 4283f27c c288e449 42ce6df2 40dffd9f" - ] - }, - { - "glsl": "vec2 cultmath_iv_snoise_ball(vec2, float)", - "tolerance": "ulp-bounded", - "cases": [ - "c0b75188 423d2522 3fe31de1 -> bf800000 3f800000", - "4246e964 c17bd730 3ffdfea1 -> bf800000 3f800000", - "c1fc8975 41f194d4 3fabf475 -> bf800000 3f800000", - "422c4d44 c071c1a0 3fd3f608 -> bf800000 3f800000", - "c23713bf c1e1f045 3f9bd561 -> bf800000 3f800000", - "c1ca302c c1c9a6d7 3f0eb662 -> bf800000 3f800000", - "c240811b 41fd106c 3f4b9b12 -> bf800000 3f800000", - "40b4c4b8 c20a57d5 3f8fbe05 -> bf800000 3f800000", - "41bfdf38 423c4866 3fd09ad4 -> bf800000 3f800000", - "4132fb74 41928344 3fdbd120 -> bf800000 3f800000", - "41144c7c c217c5e0 3ed0b522 -> bf800000 3f800000", - "c1942dc5 42094cd8 3e8c25d3 -> bf800000 3f800000", - "423da796 c0ebaa98 3db0bfe8 -> bf7ce0fc 3ed394b1", - "4210e1d4 c1fb88da 3f92c7ce -> bf800000 3f800000", - "c138f714 411b6590 3fd319a6 -> bf800000 3f800000", - "42351de6 c1050a60 3e89f897 -> bf800000 3f800000", - "4208db38 40e77400 3feba820 -> bf800000 3f800000", - "400aeda0 42237bba 3d894c73 -> beee05c0 3f1f9a22", - "c104362c 421a7d38 3fd19d99 -> bf800000 3f800000", - "c18b5312 c1c20c75 3f3e91df -> bf800000 3f800000", - "c2010afc 40e7e338 3e744721 -> bf800000 3f800000", - "41fa5b44 c1818bb6 3f2f18ef -> bf800000 3f800000", - "4147268c 41b60648 3f3fd0b5 -> bf800000 3f800000", - "c0329330 c1b57f58 3fd258fd -> bf800000 3f800000", - "c1d3705e c20962ee 3fa184d5 -> bf800000 3f800000", - "4201aff6 c20329a4 3f8ea755 -> bf800000 3f800000", - "41bd66b0 41e5a36c 3f8dd837 -> bf800000 3f800000", - "41905f4c 41d7c74c 3e63da68 -> bf800000 3f800000", - "422f3ce6 c22b9bbc 3ed958f6 -> bf800000 3f800000", - "c203d8fc 421ef6a8 3ff5012b -> bf800000 3f800000", - "c191d4ce 416d4478 3ead6501 -> bf800000 3f800000", - "41889fd8 4193d99c 3f9d01e8 -> bf800000 3f800000", - "c0923388 40e4a4d0 3f04d36f -> bf800000 3f800000", - "bfdb55c0 c189577a 3fb08164 -> bf800000 3f800000", - "41cffb88 c14fee54 3f195ec9 -> bf800000 3f800000", - "c2206f47 c1ab31ee 3fc0969f -> bf800000 3f800000", - "c11c56bc 411509fc 3fb6da8f -> bf800000 3f800000", - "c1bea39f 410e8c74 3f70f9d2 -> bf800000 3f800000", - "41fe6da0 be9d5180 3fcd86f3 -> bf800000 3f800000", - "c244ca5b 4215f0bc 3f08efe0 -> bf800000 3f800000", - "c21414a0 c092eb00 3fd48870 -> bf800000 3f800000", - "c1045274 c20a3ecc 3fa0018c -> bf800000 3f800000", - "41744400 40cfbf28 3f71a813 -> bf800000 3f800000", - "c240f288 c1502664 3f99d0c5 -> bf800000 3f800000", - "c1a1a0f2 c1c4e3f1 3f6b017e -> bf800000 3f800000", - "4211d0ba 422831e2 3f4cca33 -> bf800000 3f800000", - "41f949ec 4207ac2c 3fc8fb09 -> bf800000 3f800000", - "c0810210 41d67964 3f1bf57a -> bf800000 3f800000", - "c1cdae76 c2319898 3df46831 -> bf800000 3f62119a", - "419ed1b0 420d191c 3ec0cf6a -> bf800000 3f800000", - "41f84cd4 c0abe0b0 3fb25e57 -> bf800000 3f800000", - "4244c95e c16b1838 3fdfd1f8 -> bf800000 3f800000", - "420fadc8 c17bb67c 3edd3bd3 -> bf800000 3f800000", - "418b7dec c0ac0238 3fb8a231 -> bf800000 3f800000", - "c1afa335 c1388c9c 3ee4ffa8 -> bf800000 3f800000", - "c21a9ae5 42397eaa 3f2bcbae -> bf800000 3f800000", - "c2435565 42356616 3f939f77 -> bf800000 3f800000", - "c11b19e8 c1f2dea0 3d9413cd -> be5b2b20 3f75b1a4", - "bfe4eb60 41881744 3fafa7af -> bf800000 3f800000", - "40258540 c2023d62 3e4a6634 -> bf800000 3f800000", - "40d209a0 4235a828 3fb65a94 -> bf800000 3f800000", - "c1acee5c c1ea31e3 3fec74bd -> bf800000 3f800000", - "42219de2 c19b33af 3fe69f77 -> bf800000 3f800000", - "41072f40 c245dd0e 3f93f90b -> bf800000 3f800000", - "c1fcc7f6 c2111a02 3f495671 -> bf800000 3f800000", - "c22e71e8 c2004ea8 3f447a22 -> bf800000 3f800000", - "c22797f0 c2143c56 3e3de781 -> bf800000 3f800000", - "41b331d8 41957c7c 3fe6386f -> bf800000 3f800000", - "41324fe0 c1144c70 3f0020cf -> bf800000 3f800000", - "4180bea0 3f7c2e40 3faee059 -> bf800000 3f800000", - "c1f96894 c1855516 3eacbe51 -> bf800000 3f800000", - "c2191696 c21c823d 3f7c167c -> bf800000 3f800000", - "c2446fa6 4246a594 3eb6143f -> bf800000 3f800000", - "c1a04cc9 c1e8718f 3fa86cd2 -> bf800000 3f800000", - "c0d1f7f8 c0e909b0 3ff2bc08 -> bf800000 3f800000", - "424773f8 c1e0c4ff 3df4464a -> befb28db 3f800000", - "41646070 c102d5c8 3f7b7637 -> bf800000 3f800000", - "c19df3d7 c0b07de8 3dba3bf0 -> bf3a8330 3f3f673a", - "c2458ef1 4208a848 3f090982 -> bf800000 3f800000", - "41fa5788 4189e9b4 3fcccf9f -> bf800000 3f800000", - "418afe84 c1cd82da 3fcbd6f5 -> bf800000 3f800000", - "c1e1b473 c125ff98 3fac1362 -> bf800000 3f800000", - "c110c100 c22d4d65 3d6d98fb -> bf1e5894 3ea573f7", - "422054e2 c2320242 3ebb6a8b -> bf800000 3f800000", - "c1eb2be4 41e11ce8 3feb8577 -> bf800000 3f800000", - "c0d17e20 c1a8502c 3f052593 -> bf800000 3f800000", - "42346fe0 41347ffc 3ec135a0 -> bf800000 3f800000", - "c1f76eef c240b8cc 3e3c92d6 -> bf800000 3f800000", - "c1f657f6 421a45a2 3fe3779e -> bf800000 3f800000", - "c216af32 c21b87a4 3f08ef5e -> bf800000 3f800000", - "c1dc24b0 c1f336d7 3f262d36 -> bf800000 3f800000", - "c1441180 41496960 3ff762cc -> bf800000 3f800000", - "4210a312 c1e2c98b 3d80a6f4 -> bf57e016 3e34c4b6", - "c1b314b1 410e90e0 3e9c620b -> bf800000 3f800000", - "c23bbd89 41c18670 3f3a25a4 -> bf800000 3f800000", - "c19962f5 c22163fa 3fa9e339 -> bf800000 3f800000", - "c215fd7c 40e50690 3f8d60d6 -> bf800000 3f800000", - "c244f58b 4210bbe6 3df5f5cc -> bf019788 3f800000", - "4132ab1c bfd928a0 3ee6b5e6 -> bf800000 3f800000", - "41a39e88 c23dae3e 3f82c4d2 -> bf800000 3f800000", - "41e2d098 c1ab021b 3ff4a19e -> bf800000 3f800000", - "41d12580 418cce74 3fdbebc4 -> bf800000 3f800000", - "420f5b0c 42036e6e 3e9fac69 -> bf800000 3f800000", - "423573cc 40e96950 3e16a495 -> bf5bf7b0 3f800000", - "c1d8fe78 418bf470 3d4638aa -> bf800000 be6cc936", - "c2399b82 c207f9ee 3f0da52a -> bf800000 3f800000", - "41b6b2b8 4219857e 3fca0d0f -> bf800000 3f800000", - "c1dbf93a 42474e48 3f8a32a1 -> bf800000 3f800000", - "41ac0a38 c1e2399c 3f2b40fe -> bf800000 3f800000", - "c1bc4843 41d4a1b0 3e92b70b -> bf800000 3f800000", - "41c1228c c2092c32 3ec3b585 -> bf800000 3f800000", - "40024370 bf3ca900 3f1b3ead -> bf800000 3f800000", - "c1f29eb5 c1b8a092 3e07ea92 -> be474494 3f800000", - "3ed9d280 c0a06438 3f096018 -> bf800000 3f800000", - "3f4b6c80 c2037147 3fffa63a -> bf800000 3f800000", - "c006c520 41df1364 3ebfcb06 -> bf800000 3f800000", - "c239a6ed 40f23248 3f25895f -> bf800000 3f800000", - "42337362 423e75e8 3e91d785 -> bf800000 3f800000", - "41b121bc 40bb2748 3f13a025 -> bf800000 3f800000", - "c1067524 c235725d 3f6b09e9 -> bf800000 3f800000", - "401f07a0 4115fcb4 3e018d22 -> be98b714 3f800000", - "c242ef82 c1e63af8 3f55138a -> bf800000 3f800000", - "4218f336 41a6b918 3ebb1b74 -> bf800000 3f800000", - "41b0ad04 4207b3d8 3fe411e3 -> bf800000 3f800000", - "c1e7b003 c1dcb492 3f5e50a5 -> bf800000 3f800000", - "4007c020 41adab60 3fd3b379 -> bf800000 3f800000", - "40831f00 c1d31d22 3f60975e -> bf800000 3f800000", - "c20d18fe c1d8fa68 3ec3148d -> bf800000 3f800000", - "41ffe5e8 41ea3bc8 3eb9ada8 -> bf800000 3f800000", - "c23482c9 41ef26b4 3fef2649 -> bf800000 3f800000", - "c2420b64 41e09bdc 3ee49425 -> bf800000 3f800000", - "412b5fcc 423fc32c 3fdb306d -> bf800000 3f800000", - "c1ebdff8 bef16600 3ff58e45 -> bf800000 3f800000", - "41046930 411a81dc 3e1136fd -> bf800000 3f31b00e", - "c2462b2f c193fae0 3fbc8f52 -> bf800000 3f800000", - "c0d92d90 41be96c8 3fc08d5e -> bf800000 3f800000", - "41a67478 c1efd64c 3fd76b19 -> bf800000 3f800000", - "c078ee70 4215fed8 3fcf746d -> bf800000 3f800000", - "c23fd577 c143da20 3f3b0644 -> bf800000 3f800000", - "42151304 c1f5c4ec 3f56e44a -> bf800000 3f800000", - "c1d40914 42057600 3fe8d5a6 -> bf800000 3f800000", - "c1c97730 41a4c3cc 3df1864f -> bf800000 3e991814", - "41866890 4125402c 3efaf8de -> bf800000 3f800000", - "40f8edc8 c1932802 3ee385f6 -> bf800000 3f800000", - "4213135c 42374994 3fa3c4c1 -> bf800000 3f800000", - "c1534e94 c20eedce 3fe9ee7f -> bf800000 3f800000", - "c0943f10 c1339d64 3de16564 -> bed84297 3f800000", - "c0e39258 c17ef418 3f9953df -> bf800000 3f800000", - "c222e6c4 40ac1c18 3fe7e3c9 -> bf800000 3f800000", - "c10be87c 410ab5ac 3f9a1d7f -> bf800000 3f800000", - "bf620540 c1860600 3f1b0e90 -> bf800000 3f800000", - "407e7930 c17384a4 3fc35626 -> bf800000 3f800000", - "c2079c0c 41cd20d0 3f9bf8c2 -> bf800000 3f800000", - "418e5910 41d34c10 3e8aa2ec -> bf800000 3f800000", - "3f3b6940 c213e37c 3fe25b62 -> bf800000 3f800000", - "413f5ae8 411576f0 3feab42e -> bf800000 3f800000", - "c203b4c4 4173f8b8 3ef0f1c8 -> bf800000 3f800000", - "c09c1ed0 c1019468 3fce1dff -> bf800000 3f800000", - "c1583778 41f4db84 3f7c8b7e -> bf800000 3f800000", - "c1976a9e c209d4d4 3e9c4208 -> bf800000 3f800000", - "c20ae92e c1c3a334 3d0beaf9 -> bf1a297a bd432a58", - "4164a360 c2255a32 3ffbccb3 -> bf800000 3f800000", - "4227b8d2 c189a870 3f9c5113 -> bf800000 3f800000", - "4216a680 c1ea6f31 3f45ed0f -> bf800000 3f800000", - "c19c40dc 41dc972c 3f9fb1d9 -> bf800000 3f800000", - "4227d724 4228a010 3ed7d434 -> bf800000 3f800000", - "41abab4c c02bd7f0 3ff5dc09 -> bf800000 3f800000", - "424399d2 c1ce8ab6 3fef2aa1 -> bf800000 3f800000", - "c154f64c c238043b 3fe9db38 -> bf800000 3f800000", - "be829c80 c2020a8e 3f8abdca -> bf800000 3f800000", - "c1b8111e 420c1942 3f99e778 -> bf800000 3f800000", - "c089edc0 40215b70 3f824830 -> bf800000 3f800000", - "c218a745 4211c4ce 3db4c976 -> bf800000 3e018a1c", - "422039dc 41a03bd4 3f081e29 -> bf800000 3f800000", - "c19aeaee c1a4b68c 3f644035 -> bf800000 3f800000", - "420b757e c20d636c 3fa4b955 -> bf800000 3f800000", - "c1fedb76 c0af2810 3fe272f3 -> bf800000 3f800000", - "c1ade6e1 4119d42c 3faeb3cc -> bf800000 3f800000", - "c1f68ec9 c2068301 3ce7669a -> beaa1041 3e017172", - "c2270c9e c1b33329 3dc112e5 -> bf087695 3f7f54f7", - "c22bf319 c0fa0fa0 3e9d2311 -> bf800000 3f800000", - "c22c865a 412abc40 3f36cce7 -> bf800000 3f800000", - "41e43914 420b1d4c 3f007613 -> bf800000 3f800000", - "c21a0503 41f0fcd4 3debfb38 -> bf47f35e 3f800000", - "c205503f 41fb3794 3fc5e16c -> bf800000 3f800000", - "419be7a4 41921e94 3ff29f1a -> bf800000 3f800000", - "bf90d100 3fe99de0 3fe4bb4c -> bf800000 3f800000", - "c1b7da70 c1932efc 3fbad21c -> bf800000 3f800000", - "417b8d90 4242eae2 3f024ac2 -> bf800000 3f800000", - "42277c94 c1bbeca9 3f393f3e -> bf800000 3f800000", - "befe0f80 c2399aa7 3f96b04b -> bf800000 3f800000", - "4246ccac 42042cf4 3f0ebe78 -> bf800000 3f800000", - "c21b0461 c1d1de3b 3fb003a0 -> bf800000 3f800000", - "c224795f c22ea70c 3f1922cd -> bf800000 3f800000", - "c12b9a3c c22d68b8 3fa4eac1 -> bf800000 3f800000", - "4202f270 c219a332 3fc84044 -> bf800000 3f800000", - "4223c412 be9d9b80 3f7670fe -> bf800000 3f800000", - "c22da22a 4115e7a8 3fc203c5 -> bf800000 3f800000", - "c20ab528 41eff43c 3e59aa9b -> bf800000 3f800000", - "c0f520f8 c10da6f8 3f9e9e82 -> bf800000 3f800000", - "c21ef512 42129ff8 3f9538f4 -> bf800000 3f800000", - "421b9d28 413fdc70 3fc3eec6 -> bf800000 3f800000", - "c04831f0 c2041cec 3ffbcc98 -> bf800000 3f800000", - "bf0ed140 4103e0d0 3f63f95e -> bf800000 3f800000", - "c1bfbf7d c12034a8 3f690a19 -> bf800000 3f800000", - "41177fa4 4216f958 3effea9d -> bf800000 3f800000", - "c225c220 4203f0f6 3fdf1777 -> bf800000 3f800000", - "c03350a0 c244477e 3fc4ae91 -> bf800000 3f800000", - "42182b02 c0e2cfa8 3f629994 -> bf800000 3f800000", - "420444e6 420981d4 3d7dcc44 -> 3d5939d0 3f800000", - "c202f5ad 41973f7c 3fd38761 -> bf800000 3f800000", - "c22cce85 42427bb4 3ec9f0eb -> bf800000 3f800000", - "41acd754 3ebe2480 3f64c854 -> bf800000 3f800000", - "42178384 c16229c8 3ff23b30 -> bf800000 3f800000", - "41eed4d8 c10802a4 3fea1f56 -> bf800000 3f800000", - "c23990b3 41f47b28 3ec6e230 -> bf800000 3f800000", - "c19db4fb 40bb5778 3fec2bff -> bf800000 3f800000", - "420e8450 c181c3fe 3f94f262 -> bf800000 3f800000", - "41c66c38 4150ffe0 3fdb7a17 -> bf800000 3f800000", - "41fb9d78 c2448dda 3ec3c8f3 -> bf800000 3f800000", - "c18da4bc 415cdff0 3f270f0c -> bf800000 3f800000", - "42353c00 c18e8b30 3fe4b6fd -> bf800000 3f800000", - "413e0f1c c1f62274 3f53f21f -> bf800000 3f800000", - "c1c18a04 42177440 3f3f8170 -> bf800000 3f800000", - "41f2621c c1ea8b48 3f716472 -> bf800000 3f800000", - "422a145a 418ac110 3f9831e1 -> bf800000 3f800000", - "420d784e 4209bbb4 3f9fab5a -> bf800000 3f800000", - "c1c9374c 4031f620 3f1237ad -> bf800000 3f800000", - "c21ccdf2 c192f3fc 3f3403c7 -> bf800000 3f800000", - "c1cc5556 c1900941 3f36393f -> bf800000 3f800000", - "c1805cf4 42209cee 3f7d9eb3 -> bf800000 3f800000", - "c1c361c9 40b2af10 3fb8827b -> bf800000 3f800000", - "414061ec 420a2e6c 3e3fbf48 -> bf800000 3f800000", - "c23f8be0 c10451e4 3f9d0be8 -> bf800000 3f800000", - "41e01fe4 c236157c 3fae1902 -> bf800000 3f800000", - "409c1dc8 c232acbc 3e868fb8 -> bf800000 3f800000", - "c21bd61a 420121c2 3ff50b48 -> bf800000 3f800000", - "c1bda36b 4238566e 3ea8a6fc -> bf800000 3f800000", - "40d744c8 c22a36b8 3e62aee3 -> bf800000 3f800000", - "c237b5a8 420a09f0 3c44e6e9 -> 3f19dd46 3f4bcf4e", - "4086b5c8 c149463c 3fdf5848 -> bf800000 3f800000", - "c230c498 42276978 3ffa2427 -> bf800000 3f800000", - "421772ec 40970f98 3fa6b224 -> bf800000 3f800000", - "41c87ba8 c19c0843 3fd3fcc0 -> bf800000 3f800000", - "3de87800 4205042e 3f5ac99d -> bf800000 3f800000", - "c243e657 c04ab970 3f776fcb -> bf800000 3f800000", - "412880d8 40bd72b0 3f06d7a6 -> bf800000 3f800000", - "c1dfc3d2 c2125490 3f7ea824 -> bf800000 3f800000", - "c1228ed0 c2295cc4 3ff0d2e7 -> bf800000 3f800000", - "c187589c 4196cd04 3f769886 -> bf800000 3f800000", - "413093e0 40fe7120 3ae06ada -> bee3835e bed5482c", - "c224ef78 c0062990 3db27bb7 -> bf800000 3e7ffa0c", - "41c0b6d0 41b1a910 3e81bce1 -> bf800000 3f800000", - "41a23ebc 41882198 3f81a063 -> bf800000 3f800000", - "c0000d30 c1604fbc 3f84a2ee -> bf800000 3f800000", - "c21452ae 41d1741c 3e83d42d -> bf800000 3f800000" - ] - }, - { - "glsl": "vec3 cultmath_af_snoise(vec3, vec3, float)", - "tolerance": "ulp-bounded, reach 1e-6 to 1e-3", - "check": "the arguments are (cx, cy, cz, ax, ay, az, radius, ...) and the result is the form (x0, a, e). Enclosure: for eps in {-1, -0.5, 0, 0.5, 1} and d in {0, +-ex, +-ey, +-ez, (+-1, +-1, +-1) / sqrt(3)} (15 directions), form the point p = c + axis eps + radius d in double and round it to float32; the device's own reference value at p must lie in [x0 + a eps - e, x0 + a eps + e] with no tolerance, so a device whose gradient error exceeds the allowance fails. Tightness: with L = 7.9640074 and, for each octave (one for af_snoise), R = |axis| + radius, B = L R + 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R), the width |a| + e must be at most B + 2^-16 (1 + B). Report the least slack of each side, absolutely and as a fraction of e; only the two bounds fail the check. The reference value is cultmath_snoise(p). These cases have reach |axis| + radius of 1e-6 to 1e-3, where the float32 allowance is most of e and the second order remainder is not; the enclosure above fails a device whose gradient error exceeds the allowance. Centre leg, for every cultmath_af_snoise and cultmath_af_fbm family of this fixture, the earlier ones included: the fixture's own x0 in the result (C#'s value at the centre) must lie in [x0 - e, x0 + e] of the GPU's form, with no tolerance, so a device whose noise differs from C#'s by more than its e fails.", - "cases": [ - "3de98ec0 3e5960a0 3e824700 b64c3554 36674e47 b629f5b3 37601e01 -> bee8782f 36405f94 38e47f80", - "3f2f1238 bf6d5b1d 3dc3cf20 b943c815 b9552ec5 390597fe 3791eb35 -> 3ebaf9fc 38759590 3903a998", - "c139b3a4 c1b8837e 41c4ffc0 38e3ec26 38dc4b8d 389176fa 395ca6ba -> 3e59bf01 b9c019c6 3aa3838f", - "beec548a bebdab10 3f1ff0f4 b5bb676f 35bed139 35f5b0c6 3911e058 -> be35088f 367641c8 39f059aa", - "c2091b3b 41f27428 c156f984 00000000 00000000 00000000 36ef2dcd -> 3e02aba0 00000000 3a2ee486", - "bf415a24 3e96f054 bec22aba 00000000 00000000 00000000 3979f5b4 -> 3f00ce18 00000000 3a7b5a27", - "c172a69c 41dbd6f0 c16ab350 375ab8b5 b70b7f01 359ff929 3a6d5e2c -> bd169e91 353c0390 3b08a588", - "bd8ca798 be54ffb4 be60513c b674cdf7 36c97804 3649905b 3646a75a -> 3f0e31c6 37195340 38983a7e", - "bf460e64 bf5d040d bf1b828d 3660aadc 35cca052 b66df0c7 39513c96 -> 3dbd40e3 b5bb6f1a 39c64322", - "c0e04328 40af6150 c1fa88dd 396b6d16 b96965b5 b9031a1e 3595385d -> beb2ac89 3a28b532 39d1bdd9", - "3e63bbf8 bebac5a0 be8fda88 b8724e47 392ef8ff 38801b83 37b225b5 -> bd469206 3a15fbc6 391151c2", - "42281202 c24198d2 c22f046a 00000000 00000000 00000000 36769265 -> 3dd08ee9 00000000 3a8ebaf1", - "40fb4bc0 41d9f458 c139afc4 00000000 00000000 00000000 3683c860 -> bd915b07 00000000 39dd7762", - "41504874 421674b2 c20b5de4 b6667f0c b574ab23 35408169 39116440 -> 3ec66a90 34c78fd0 3a93c57e", - "bee2441e bde396a0 3f70b70e 39c53600 3963ae74 b9f24965 3591be10 -> be52a73e 39db57bc 38b819c8", - "41eb0098 411db0ac c1f88cee b5d5548d 38cf478f 38735753 37c7eba0 -> 3ec4e662 39735a97 3a2a8349", - "c0806970 4207b82e 3fbb4dc0 37938dcc b5d15df2 b6eeda70 394876f3 -> 3e299ef9 3610b078 3a031d28", - "c1f2d8ed c1c343a1 c092bdf8 00000000 00000000 00000000 392a6aa0 -> be841b57 00000000 3a8b9908", - "bf04a494 be5b8028 3e11d388 381eae8f b8893bfa b9e5e3f6 380771e6 -> be0c82b1 37fe2d4c 38f45877", - "41957650 41be235c c1026468 00000000 00000000 00000000 38b2c682 -> bf485844 00000000 3a3177fd", - "3ee8d84c bf01f67b be1c98b0 366355ec 35a4befd b64f4484 36824a2f -> be305f08 b62249d8 389934d6", - "bf271ebc 3f069042 bf432953 b99449fe b990e5f2 391393bd 3927e7c0 -> be9b8b31 3a8f6452 3a40ecac", - "c219e9fe 3dd99800 422f887c 00000000 00000000 00000000 38de6c5d -> be66d34d 80000000 3a6bdfb7", - "3f1f6cce 3e9f8c24 3f17d57e b7179bf6 35057781 36021be1 382187fe -> bf496c88 b6edbe56 3906d627", - "41352b58 c1a236d5 419692dc b8a5fb2f b86dc7e0 38c9aa74 36e23fe4 -> bc78d716 b96082cc 39eed366", - "41d327e0 423a1498 421ae206 b6c534f3 351ea919 b2a20814 39468d10 -> be99d01b 373e6c27 3ab7bc9d", - "c19a2218 c10a5698 41d3a4d4 3809d622 b698a636 b6e3bbb1 398c0264 -> be308f7f 38434f83 3aa855a1", - "bf2f79f6 3f17e7c8 bf7b3ce9 34af4f09 b5861a9f b62ef6bb 36078865 -> be373174 3435f5e8 38ab890e", - "3ef533f0 bf0be5d1 3eef5408 3684116e 367886d9 3640d57f 389e1322 -> 3e46b642 b6b4b726 39753aa2", - "c23c9be7 c1728468 40c9bdf0 3746859f b714ce0f 3581890e 392f07e4 -> be63bedf b543e2e0 3ab4c727", - "3f5572b0 befe432c 3f4e7150 b98837cd 39f8a638 39f29b6b 3a7d3137 -> be1e0035 bae0ca24 3b572b8a", - "be9157a2 be9aa8de bf3073fd b564e7b7 b7e47e1b 3743ebc4 37a396ef -> 3d01088c 38264ae1 38e609f9", - "3ebc2358 bf2ab187 3f44b152 381a2fa6 38c9b21b b8adf22a 35abddae -> be1729da b9a229fe 38a5f3f6", - "420acfe0 41ecab00 c111f0ec 35f6037d b388ab51 b576402f 35a4f81c -> bf5e99ac 35f71757 3a22c8ec", - "3f47d23a 3f22ba9e beee49b2 b82384f5 3794ee57 b7fea625 39926a12 -> be5bdfbc b886d39f 3aad1fd4", - "3d22cc00 bf6a7da4 3f6ba68c b81a65c2 37dbf2d6 b768d528 3591854a -> 3e736ce9 366bcff0 38aa1ab0", - "41bae30c c1c8f478 4225fdb0 398f4069 385585ba 39bccb38 362d021a -> 3e813bc5 3a8f6cc4 3a4687e4", - "3f0397c4 3e1b5948 bda08d28 b9ca5a56 39bcd58c 39ce14bf 36af1af3 -> 3e8c0ed2 bad63992 38c4b500", - "3e6d2048 3ea41868 3f48943e 00000000 00000000 00000000 3996f19f -> be57c54d 00000000 3a278923", - "3f2bd122 3eaa1e44 bf422a0e 00000000 00000000 00000000 3619fab4 -> be437cda 00000000 38a29b37", - "bf50c330 3e41eb48 bf2a77b8 37fcc4ce 370c7b9e b7f4401d 392d38b3 -> 3f2a3a72 b8e82782 3a1c5ffa", - "c0cbd658 41fcfb70 c22ec733 365f9692 b63e42ce 36b9809f 39bb42c4 -> bd14aeb4 b6f7b921 3aa6089c", - "c190c5ba c22abb87 41ff83b8 00000000 00000000 00000000 3745a35b -> bda5b210 00000000 3a4d8025", - "3f2bd3d6 bf712a22 3ee816c0 39c82020 ba2f85b7 3a0ef5dd 37ecd8f8 -> be5828a7 bb42b998 39584fa8", - "be8d0096 bd897928 3f6d145c 36bf2f5a 366386f2 b6aef199 369d9d3c -> be38d5fd 38001fdd 38c38409", - "c20aeeef 42164ab8 c1dcf32f b8ba4961 38866176 b845b6f2 37b70f8d -> bf0a7584 3826e548 3a661091", - "41dc3c30 c2228583 c1ac76f5 00000000 00000000 00000000 395fb00d -> 3e400d51 00000000 3af6ceac", - "41fd8b10 c05e2a70 40861770 38d0d6f7 b8ccad21 b7172dd8 35d792ab -> 3dcf4a5d 38a1298e 39bd96b2", - "c1904117 40cb7c90 411efac8 36ab60a9 341cfc94 36a01fdb 3836fd90 -> 3e0a2dd7 375cebed 39dfdbd5", - "3f1c3e4e beb64e66 bf03c15f 378a7ea9 b799080f 363158a5 35fb591c -> bebaea08 b7927659 38a53e58", - "c1fe62b5 41cf8f3c 3f8d14c0 396078ee 390aa93f 391e2529 362e5013 -> be83cfd5 b969a1a1 3a06daa7", - "c1078380 3f5f42c0 c183212e 3749f1de 390108e4 b98bf39c 3636e04a -> 3ef1b783 ba44988a 398c8ec2", - "c1cc9256 c246d757 417b3620 b837ccc0 b5849e00 b86431f7 3895d183 -> be73a7c3 37f62b8a 3a70333e", - "3d54f2e0 3f7de9dc 3e7e8100 398a98dc 3809558c b97f0aeb 3933d47b -> bea586d2 b9f0a6d9 39dfb3bd", - "41c322f8 c23d3902 c20eaa17 359bbef9 b6b1d76a 37543f48 378d44bf -> bec5131e b7370d7a 3a733010", - "c2226a7d 41b20174 c1907ff6 b8ad4189 b869bf29 b890cd4b 37d8337f -> 3f13a6a2 38dd6069 3a44b396", - "3f909160 c20b3045 c1ec68a8 36bdce6d b70a5cc8 3824f333 39dfd1e1 -> bf2f9ae1 3759b222 3acc185c", - "3e8a6754 bf04eb40 bf5800ee 00000000 00000000 00000000 3818fd87 -> bd6a4378 80000000 395872f6", - "420fd2c0 c1f6a1ad c1b678ec 3546ed21 37eabe9f b7c936eb 38c3b026 -> 3f595d16 b86d98a6 3a6d7e74", - "3eb4c96c 3f189838 3f0d244e b63520a7 b7184ff3 b6fd2eb5 38a165f8 -> 3ea5f7f5 37173f60 39cca28d", - "3f2518ba 3f02f312 3f51eb52 00000000 00000000 00000000 37906e56 -> bf038b0c 00000000 3901eaa4", - "3e905500 c09de718 c07c0f80 3902c51b b9282f1b b930185e 37188c7a -> bf44fb9c 39bb6fe0 39207151", - "be1e7114 bc9fd000 3f3fcf6a 391d9da0 3880d283 38a333a9 3931747e -> 3f3c365a b911cb8a 3a210610", - "41d05878 c22c289f 3d0af800 3a037b44 399f465d b9357f0e 37805668 -> 3ca99dd3 3889b1ae 3a26e8bc", - "c1aea15d c20d4fb2 40da1758 00000000 00000000 00000000 372fee37 -> 3eded15e 00000000 3a14caaa", - "bf607798 3f1b2cf6 bf2e8aa4 b53ca5da 38377f2e b59b39df 3a27c39a -> 3ea53d0f b8e55b3b 3aee1dd3", - "bcdea220 3f6bc518 3e955588 00000000 00000000 00000000 359f53f2 -> bde0af67 00000000 3898d0e1", - "c13c3a04 c18b8a4a 41977a44 39c10126 b987a91f 39d43adf 3a2acc88 -> be486436 ba157e60 3af41bf5", - "c10ca7a0 c1e36336 414e6e70 363edeb1 360e96eb b59b804d 3898a8eb -> 3c47d632 36215d9b 3a188709", - "3e3ddfc0 be749268 3e4065c8 390c3107 3a41c0f6 b9874945 36a5198a -> bec28bbc ba9efe9e 38cca834", - "c1ada584 c1c43976 c2286978 00000000 00000000 00000000 394dea7d -> 3ef66c5c 00000000 3a7f7f01", - "c1501140 4222cbea 41f3ffcc 35dd42a7 b5c0bd08 b4d9af69 384416ed -> bec6093e b5569379 3a5251da", - "42273736 417f27d0 423bdd2e 35f5fd35 b526d71b 3490aaba 38507dce -> 3f0c77e8 354adfcb 3a84763b", - "41b94df0 421f0aa6 420c7d2c 37abe1ef b7ed240f 3745d1cc 36005407 -> 3b6424f5 37effa4f 3a53f5ea", - "c2114824 3f0cb000 3f93d9a0 b881b7f5 b8bb682f b907a43f 3619af99 -> 3e5d367a b93940e9 39bc0277", - "42368666 c00b1f30 c1d3e256 b8041083 374f2efa 380d3897 396adc5f -> bea6d948 b84310af 3a8f3e29", - "3ef0e534 3f76c88a 3dedc390 36dafa93 b78a3d7e b98ad4f3 35ac9137 -> 3e1eb420 b91184ec 389fd5da", - "3d8feec0 3f4de232 bf74d21b b6b0972b b5a9458d b6aa5ca2 369f8e31 -> bf00d467 3745f0bb 38c26014", - "c22c42d3 41dd8150 423eced4 00000000 00000000 00000000 35b7bdd3 -> be447b9f 00000000 3a7ccd2b", - "4181f7a4 40836f68 4238b7c2 00000000 00000000 00000000 35a6e636 -> 3ed0f20b 00000000 3a155b4d", - "41beff84 c1bb33d9 c0f935a8 00000000 00000000 00000000 3a36572e -> be15657f 00000000 3b28e9e0", - "bf29b1ce 3f722eb6 be89ee8a 3540e9fa b5152575 35986492 37c452e9 -> 3eb6df0e 363a945a 39031dde", - "bf26594c 3e7b48e0 3d8cbaa0 b9cf01ce 393388f5 3a210aea 358aea0c -> bf038f7a 3ad55a27 38b9e201", - "41adb20c c1c1efa8 41f7ea70 371fbc13 372dee6e 36e4b629 364f6fd8 -> 3efda2a8 b617df30 3a2bb0c4", - "3f744716 3f75e39c bd8ef7b0 b7a6591a b75969a9 37981f29 35dab19d -> 3f24d687 382071b6 38a60bcb", - "be784a14 3f7b87b4 3f18089c b6adb4ef b6d08a66 36a21fe9 3986a5fd -> 3f0dcef7 37a7ca75 3a32df1f", - "3f3fd680 c067f940 c20c12a8 b976f7d5 3958cf4d b931b7b0 39243938 -> 3e35e9ca 3a014c02 3a2e928a", - "3e3df470 be140aa4 3f481a86 35d2b9fe b5b3364c b5c91613 386f03bb -> 3dcf1e35 b67af167 39807bf0", - "41b4cae8 c1ba7374 421b13b4 3a526b07 39c83589 b88b91ad 363b79d5 -> bf1779c3 3a8d9341 3a408c30", - "befe1c54 be1d7680 3e424690 b9825e49 375d51c7 39ab2dc4 3753dc13 -> bd9316fa 39afb828 38b88ff1", - "c22429fa 42462e1e 41cff6d0 00000000 00000000 00000000 35b580ab -> 3d833059 00000000 3a78c816", - "bf4c92d3 bf4eab1f 3f6f7a0c 00000000 00000000 00000000 366b1b50 -> 3f6037b8 80000000 38b5e474", - "41bf90dc 41b1a608 c0bdba30 00000000 00000000 00000000 38604ee4 -> 3ea2f3f2 00000000 3a17328b", - "3e7428c0 bec6a8d6 bdcb6198 00000000 00000000 00000000 3905bc9d -> 3c9998be 00000000 39877870", - "40f7c328 c204251d 42052424 b5dbad63 b6b1b9ae b69bee46 395394cd -> be7161e1 37398358 3a9c2666", - "42449fb6 41b86eac 3f32b800 b68b3a85 b73d4f7a 36475ec3 359583fa -> 3de4bb19 376f917c 3a21aa87", - "beb29c04 3f06396e 3ebc1074 33ff620b b58c6666 3579776d 36bf3803 -> bf1178e7 b6247cdc 38b460b4", - "41d03308 4223ee26 c1a5258c 35a3ab4c 363aac60 b63e8a50 38b3733d -> be0ea413 b45ad3e0 3a5643f8", - "3f1d0964 3f4a427e 3ee2b58c 39beea9a 39ae13a6 39c176ab 37c455b9 -> 3ed721f3 bab8f22d 39165f09", - "3eb8ec60 bf53f036 bf2bf5fe 3a1c0507 39f6946b b7af6eeb 372d82c0 -> 3f16cdef bb0e652c 3908ed57", - "c112ec2c c193caa9 c23a3029 3960f554 ba4d9a7e b8f7d9b1 3a67fcf7 -> 3eb311d1 bb01a775 3b4ddfba", - "42223180 c1016684 41b025a0 b6af89f8 b59431a6 b6f4f115 3633572b -> befb19f6 367ea1e8 3a1f04df", - "bee73566 bf7c2701 3e3de280 b79ddac1 37e62524 38224da3 38aa35db -> bd6a6a9a b7293717 39222c93", - "be653a44 bf2f078c 3f3c750c 00000000 00000000 00000000 36933d83 -> bce7a14a 00000000 38a3f2e1", - "4210341c c2425044 41c84f74 b4dfb2e2 35013626 355cab6a 38f67c33 -> 3eaff8b6 b5a54c72 3aab8f6b", - "c15699ec 41d89f88 40aae458 3780f554 b79c611c 3795462f 365988aa -> be4d3646 b7c487ee 39d81b23", - "41b208dc c142f9f0 c18aace6 b57e9353 360ebbb0 b580031c 35ceffc3 -> bccbed00 b54b1472 39ef4e26", - "3dd113c0 3d284020 bf243704 3692fa13 b7f86bbd 368fb48e 385afecb -> 3f564ca8 b81df745 393a4a51", - "bf614131 3e325378 3f6ec39e 00000000 00000000 00000000 370d2593 -> 3f24fbd2 00000000 38d6852d", - "bf77df2f bf29f860 bf5a021c 00000000 00000000 00000000 373027f6 -> 3e028310 00000000 38cf970d", - "c23c3dd1 41fabf38 41d7207c 36fdf273 3751f9fd b6fd914c 37a0185c -> becbad8e 3716fa1e 3a6fe6b2", - "3f62c6fe 3f62aba8 3ed77868 37f2f373 38f83662 39043628 3883185a -> 3e6ecb33 b8102384 3965b693", - "4227eddc 417ce0d0 c17f0690 00000000 00000000 00000000 37903eb4 -> 3f11eb04 80000000 3a315b54", - "41530afc c15e2d60 420cba4a 00000000 00000000 00000000 35ca4cf7 -> 3e6c046b 00000000 3a0d2c23", - "be3e9384 bf2634d6 bc9120e0 39064732 b906df4c b852aa80 366a0038 -> bda9f02d b92f4216 38982629", - "c225e0df c1cb0dd1 4166a360 00000000 00000000 00000000 378d2046 -> bf36a909 00000000 3a41f501", - "c13a90b0 c20f3d12 c1b84b87 36550372 b752ada3 b599d22e 37dbde7a -> 3eb92688 b7f8b44d 3a2e13b7", - "bf5bded6 bd2422b0 bf24ba24 34a3bbe4 b5b72634 35c209c1 3829d03f -> 3e6a4f2f b661f522 393bc6f3", - "be954e3a bf0c740f 3f6d491c b80a03c0 3901042a b9072c39 385b3a3a -> be9c867b b9c326fb 397e7adb", - "bf5e2e00 c132e824 41ef2a78 00000000 00000000 00000000 3a60c8fa -> 3ed2ebd7 00000000 3b57ce7a", - "3f4b7f58 3eeec058 bf0fa160 36298746 b692cce6 3697be80 35970a65 -> bf00117f 34e6ed10 38a3ccbe", - "3e23e8d8 bf0aa220 3e684268 b89fc1fa 39cf2baf b8ea307a 360e4787 -> 3ed20b27 ba7bae10 38a7811b", - "c2009e2f c08388b0 4226e7ac 372480c1 36b34490 3703c66b 36331d7c -> bf240e71 b73368b9 3a2cfbf3", - "3eb959c8 bf7b36e9 3f729aec b5205113 b60b6163 35de45ac 399295f2 -> 3e1692ce 34a53ab8 3a5a1b1f", - "c185ddac 41951744 41eae9a4 b8925c42 38fce9c1 b8dc3e3f 3886d399 -> bee6257e 37443750 3a3d9ad3", - "3f4cf886 3f59c8d6 bf613635 36061b5c b682f33c 37a8520d 381634c1 -> be67bb7a 37cab0f6 39458d9f", - "c18f0bda 3fbb05e0 c212035c b9278403 38131a37 b8fe8450 37cda4c2 -> 3ea773dd 391759f2 3a04fcf9", - "41810c8c c17b6fc0 c230c39b 373d10e8 b493329c 36c03d88 381a02a4 -> be465588 b6e4363e 3a333d4c", - "3e02a228 bf65b51d 3f0d2658 00000000 00000000 00000000 3968ac4b -> 3ef6e600 00000000 3a7cef3b", - "3f65ff4c bf313f1b bec032cc b96cc8ea b8338bd9 38cc2630 3a0feee3 -> bde475bb b99408b5 3ac1cee4", - "3dd28510 bda83aa8 be832172 35b26240 b5926755 b5f28b00 36f3aad1 -> 3f51a74d b698faa6 38aa0d9e", - "3f3c0ae4 bf20e606 3f7d6ccc 00000000 00000000 00000000 395b0955 -> be834045 00000000 39fa9e0c", - "42265ba8 40be2620 c0978e98 3712fa29 3787b209 360195bd 38997ae0 -> 3d95c29b 36ad4dd6 3a237090", - "c0888720 407bd570 c1bc056b 00000000 00000000 00000000 39134bd8 -> 3e8dfd12 00000000 3a17f0ec", - "423878f6 c24533a4 4230472e 00000000 00000000 00000000 3a7de13d -> 3dacf968 00000000 3b06147f", - "beccffe8 bf1c9e9c 3f08d446 3904ee39 b8b404a5 38fdd5f2 36490e02 -> bf170f4e 39ff5d10 38ad7ee0", - "c20bce18 41cd77b4 4034e1b0 00000000 00000000 00000000 3737ad25 -> 3eb45863 00000000 3a154125", - "bf577c7d 3e61bae8 3f5001ee b90178fe 37893485 38f74148 39d1b43e -> 3f13cea6 3853e0e8 3a944d11", - "4208a5a0 412d38cc c1dc5952 b5eac9ee 349cbd67 b45aeb37 36c9a68d -> bd0ee186 b5fc8f2b 3a240371", - "3e84dd80 c221c63c c23a3d40 3464b906 36168e31 363a2fd5 377635a4 -> 3e94f1f7 34583ba8 3a437c20", - "3ec16c90 3e97db38 3f533b62 359d066a b4f8dbcf b512c0ad 394d2df0 -> becb69c4 b603dc24 3a1d0a89", - "bedf7be0 bf747cc9 3f0d5244 b5cada72 b63e89c1 3506d8a9 365fa6b6 -> be19df97 b5b67dec 38a5f15c", - "bec91a98 bde3de50 3f1daba8 00000000 00000000 00000000 36317570 -> 3ef2e4b5 00000000 38a0f351", - "3e1b4670 3e2016b0 be2ce340 00000000 00000000 00000000 38923b77 -> 3f27da87 80000000 39839a56", - "be938fa2 be902c22 be73c528 00000000 00000000 00000000 39002547 -> 3e82907b 00000000 39839309", - "bf613992 3f09514c beeead2e b7233328 3576e97a 37d83379 371887e4 -> 3efb900b b837f226 38d449ed", - "42320f02 c1c4e544 c190b818 b6893f7f 362b1ac4 b625910f 39ae0651 -> beb973d4 b571a1b4 3aaf807e", - "bf255adb 3f637bb4 3f026274 377beb4a 36cfc5f6 b833df15 38d199fb -> b8998fbf b797c5dc 39489cc5", - "c08cfd40 c1f84bdd 41070e9c b9e22bbd b8da53af b95524d6 361e6467 -> 3e1ea9ad bacfe659 39d71258", - "c21b8ca8 418087c4 418336f4 38b028e2 b96000c1 39817740 39154bfe -> 3ec36410 b97dc33d 3a8d2d67", - "bf30ce29 bf3a235d be968e26 377b9b5c b7d26904 b8053549 39610eab -> 3d312315 38195905 39f4d844", - "be638f98 be1dbd50 3f2085e4 38954ba8 389dedda 38517da4 38c9ce60 -> 3f3dbe50 394cda26 39a4a622", - "bcb81c80 bec43e12 bf427489 371d2335 3540d8d1 b721b0eb 35f7fc12 -> 3a6af6bf b732b05f 3896c313", - "41821dc4 c1ab9509 42066502 00000000 00000000 00000000 36cd3052 -> bf25728f 00000000 3a222736", - "4206a998 41aab0d0 4220fa66 b63216b6 36e0feb6 b71ddae0 3a054157 -> 3e01eccb b7d58e42 3af96abc", - "3f31bc88 3f05c706 3e8c1010 b3285be2 b5c8670f b5d7b4dd 35cda96c -> 3e915989 b57bb94e 38a0c224", - "bf77aed4 3f1b6c54 bf2f5992 00000000 00000000 00000000 39a85142 -> 3e7ae68d 00000000 3a87ee6b", - "bdb39958 bec3dd1e bf4ae67d 00000000 00000000 00000000 3871e685 -> 3d207825 00000000 39076d03", - "3e8ff964 be1fa0cc 3f5674ec 38c12ad2 38619cd4 b8c3da29 3678540d -> be4731d8 b9038f82 38ad2866", - "3e96e6b0 bf730168 3ead4c64 371d6f0f b73db148 379c8165 3609aab5 -> 3eec467e 36b26518 38a8d766", - "bf6437a7 be2c6988 bec97974 00000000 00000000 00000000 384311f8 -> 3c6b7233 00000000 3968fbe2", - "bf2e5e27 3f02b84a bebd0422 b5a6ee51 35cae3a8 b6077689 361a774a -> 3e7c269c 3606a660 38a31a72", - "42377524 40673380 c100a384 36aa0882 b603678c 3604a9f9 364568f7 -> bed05b86 36a43053 3a0540e7", - "408d19c8 c192c8e9 421f10b8 00000000 00000000 00000000 3726c1af -> be5ad31f 00000000 3a127afc", - "3f7faa7a 3f3ac114 3e92a6d0 00000000 00000000 00000000 36187a51 -> 3dbfd921 00000000 38ac4777", - "be4c42e8 bf4f2973 3c5bbe00 b9684627 b98ed699 37972acb 3a1b50ac -> be2edde8 38e62bbc 3a45b66a", - "be503f7c 3d4b5ea0 befd363a b8e50aba 37b02a65 389efc19 39464d8a -> 3e40c7e7 b9824e21 3a279316", - "4216c272 c0f425e8 c20dfde4 383433d6 b858571c b63349dc 398317d7 -> 3e00173c b8f3664c 3aa62cde", - "3f251c40 421e5c0c c221a25c 00000000 00000000 00000000 362b8a59 -> 3ef0c750 00000000 3a32a4b7", - "c24489a3 c0ace358 42311f00 3536ec85 b50f1f6d b5592e8a 3a14fc9b -> be48c024 3495ee1a 3a99e2a8", - "4244d33e 421cec3c 4129f5b0 b59ceeaf 3595700c b3bc32fa 358eb201 -> 3e8971ea b4ed92cc 3a55ea2d", - "3f669668 3ea7b7cc 3e49e5c8 3886af32 3885d571 b8973246 3592f404 -> bd464715 b8aa6edf 3899aa76", - "be119720 bf23eb72 bec86976 36f3d431 b73fecc2 37cb5a54 370846ce -> 3f00dc89 b87a6054 38cf6716", - "bf11842c bf424ded 3f59746c b71d9ea8 35ffae75 b739ef1f 367c3e84 -> 3eacfb89 b3935d00 38bc4ebf", - "be0f5008 bf72821c bf5f39d4 00000000 00000000 00000000 375df434 -> beebc205 00000000 38fd123e", - "420af4b2 4132a340 c145fa94 b7037292 352ebc71 b784cabf 3a31f599 -> 3e79d34e b7e294ef 3b75bff7", - "3e3444c8 3f487238 3f2950be b7344ed9 3783152a 37100fd0 3948de64 -> 3e3754ca b7375245 398e577c", - "3ef4cef4 bf45bfb8 befd5956 37a2a1bf 3703fabb b44ab961 35dd4e50 -> be1eec36 b828f137 38a8120e", - "c219aac4 c20e01d0 c17e9734 00000000 00000000 00000000 381f77f4 -> bd10b912 00000000 3a541ab8", - "c21e05de c08c6490 c197082e b6d20bdd 341992df 352fc00d 3a80c45d -> 3da1c5f8 b772c0de 3b633c80", - "40b97050 40068930 c115ff48 b8155a08 379b0049 b77c989b 3889ba86 -> 3e851f34 b865cd5d 39e0dc2d", - "be9052a8 bf612380 3f66f184 b8260019 36c696cf b75a70bf 3900c0de -> bdcb98e4 36316184 39c2feb5", - "40a1f840 4118e724 c20e67ad 00000000 00000000 00000000 39e46dd5 -> bd9c9842 00000000 3a67c3c4", - "c214b0c2 c22df86c 41b09cec 00000000 00000000 00000000 385b7177 -> 3e52b499 00000000 3a7f4c1b", - "beb9cc8c 3f11c1c6 bf4b6453 b7c1bbf5 36d33e9d b79498e6 3935f30e -> bee2d810 b79cd727 3a391a2b", - "3e846f84 3f160b22 3f17a332 00000000 00000000 00000000 38095bf3 -> 3e655111 00000000 3932068b", - "3eafdec8 3d9b49e0 bf2b3e3f 3a03a379 39ccb0ad 39e49c07 3762e499 -> 3f13f29f b6935c80 3905f143", - "40d20100 4233ed7c bebfc980 3712ed16 b6621752 b71a3977 393019c5 -> beb4bb2f b7cf0e34 3a6251c8", - "bf071a40 c2347826 406e4650 b8520c30 b91912f8 38cc1337 3a4f9ae0 -> beee008a b92a82de 3b2efcba", - "c1e3c92a 42060632 41f41bf4 b72b16b7 b7fe537d b82e942c 3794c6ed -> 3f41bc50 38d6a88c 3a51ba4a", - "bf0d589c bf382218 3e48e270 b72eed10 b6f51ce3 37457258 3a5a92dd -> beb7f6c4 38411231 3b7b1353", - "4153b794 c0f54810 c19da49c b73318e7 369cb2b9 b79f215a 3884f3c8 -> bf2a0286 37b6dd68 39fa4610", - "420f1f04 41f5a054 4246760a 00000000 00000000 00000000 3667f7bc -> bdaa055c 00000000 3a790b5f", - "bf35ec26 bf56291c 3f615906 b9a912c8 391c595e 3a4c441d 3a302615 -> 3f49d560 3ad953d2 3ae68df2", - "c09da300 421f3c5a 4177e530 00000000 00000000 00000000 368f2aeb -> 3d78a56b 00000000 3a099c5c", - "41e005fc 41aa0c3c 41aee374 37b314ae b7bb159d b9543c48 366c357c -> 3e422c3d b9a00ae0 3a202770", - "3f720358 bf65ae71 3f500e82 b720a65e 36020531 b591f711 35bb088c -> bebf59ff b79c7779 38b294cd", - "bd5e5500 beaaacae 3f629e22 00000000 00000000 00000000 37d2ed4b -> bf0522b1 00000000 39297da7", - "c1260454 4211dce4 c2032074 00000000 00000000 00000000 397d2536 -> 3ededdd1 00000000 3aa979c5", - "c20a0fb1 40ed7568 c23d32d3 b8693ba7 b808237c b8b6aafa 39eede20 -> 3d6ec4ef 396cb143 3b044bf9", - "c085cc30 419c85b0 41377c44 b9bbbf53 37b2f61d b97dd1d2 37ad740b -> bc6039a6 ba49b4fe 39c6b6f5", - "c208c553 c1a2a407 41f896fc 364eaf37 3604f3f4 b605e89e 35d9fe49 -> be2a71d2 b6b0757a 3a3bb647", - "411d2754 c2282b0b 420075d4 39b29abe b91730e0 b8c65b50 36d09152 -> 3f162e3a 39486164 3a3e3c91", - "c2130a79 c1505028 c23d2531 38266946 b7e07f60 b6f767f7 36c23c6d -> 3db69226 b6d4225c 3a547395", - "3e9e3848 bed38654 3ea8087c b7eb82e7 38200e75 37eb7d1c 3811bf09 -> 3e3d692c b895fe51 390c5356", - "bf5ffc7a 3f7bc398 3e5d3a28 34770c17 b4d1b1e5 35a1bb36 358e688f -> bed267c8 35168803 38a90a64", - "bf3a8c2e be9a15c6 3e69fc80 b7b33f0d 37a797e3 b785f8bc 3859731c -> be1476f0 38917912 394ae529", - "bf0365f0 3f06df42 3f67b238 00000000 00000000 00000000 38e03a4c -> be0422e8 00000000 39bcf61c", - "c107396c c16e6ee0 c17d71f8 00000000 00000000 00000000 38552a8e -> be8662eb 00000000 3a2107de", - "be9cb308 3e85cb10 bf7b2b7e 00000000 00000000 00000000 394a4746 -> be86b896 00000000 3a0b7472", - "41b94ca8 beb1b900 c14c1150 35f2b738 350a7fe3 37064752 38e4a6ed -> bd865874 b758f515 3a0fd310", - "c1b13687 c0a5a400 410dbc90 b6b921c2 36b8e729 b5a5173f 35aff3cd -> 3e54d044 b76caee8 39b24eed", - "4217975a c1ba9fea 42393fde 364d3082 36f764da b6ad7434 35889b10 -> bda6bdbb 3746212d 3a66c1fd", - "be925392 bf65e129 bf72707e 3926698a b9801f74 b952b9a3 368f72c7 -> be8bf82d ba1b3472 38beb937", - "c0635e70 c14dcfbc 4148f85c 00000000 00000000 00000000 35dd75e3 -> 3e1552b5 80000000 39959f44", - "bdcd85b8 bebfab4c 3f1a0ab0 b6c05d82 369bb8ef b7138756 387bd9ba -> 3e6fc248 37a85ac9 39680818", - "4055caf0 420b92f0 419efbf0 b894be03 b82e709b b8bd57eb 3a2dbded -> 3d7fa498 390f95a8 3b15ed42", - "c0fa64f0 41e8a9bc c000c190 382a4e0f 36a387c1 b84de54d 3a3215f2 -> 3e17d679 b8d9c22a 3af83688", - "3e907fe4 3f30bda6 bdc897a0 36a51cfd 38b55f65 36cc74de 39322c9e -> be706181 b7ecc166 3a140d02", - "3f662a2e 3eb15cd4 bf17138b 3703e63e b81d25bf b88a3e49 35fe6c76 -> be7b142a 370cccfd 38a21679", - "c22c6cfe 422c01de c20102df b8008f03 3933fad2 39bc7130 3814535d -> be0a50bf b8cc0bc8 3a9430dd", - "3e78e9a0 ba320400 be39db1c 00000000 00000000 00000000 399b383e -> 3f170b06 00000000 3a4b8d06", - "be5115cc 3f4b521c bf5ff324 369faa82 3601f4f7 36bc1bfb 36e4d6ce -> 3ec89075 b5d920f4 38c3934d", - "3e2fec30 bf29924a be5d0d48 b9e46737 b9201758 38193ba4 37adaa63 -> bee241f9 b6a84ec0 38fe0b45", - "3eabc018 3e591600 beae116a b58ae8c8 34b8b0e1 b558304f 359fc6e3 -> 3e3dbda8 363a692c 389726e2", - "c1bcd5e2 c2181d88 bfa2c4a0 386839ec b80d9f56 37150ddb 365bb1ff -> bd4a07a7 b963a8e8 3a108ba2", - "423f2358 42198438 40d6b9b0 ba515e5c 39a0fec4 b843605b 370e421d -> be07524e 3ae307fc 3a545fba", - "42442bc4 40047ea0 416a77f0 00000000 00000000 00000000 359a9e31 -> be6527f2 00000000 3a13aadb", - "3e096b40 bf18f5b2 bd98e2c0 00000000 00000000 00000000 381ee26e -> bebaca3f 00000000 392c8f80", - "beed1c7a 3f27f5ba bcfc7860 3607f25f 34e782fb 35c9fb80 3a005e1e -> 3f1a1254 3623632d 3ae76164", - "3ede1284 bf72b8f1 3eeed8ec b7285989 361c30e6 36d27bc2 366d6f8a -> 3e6ea6ad 37a14c3c 38b53ae4", - "41bbafd8 42120b4e c081c068 b42ec4c6 b54c39b5 36078a7e 38f0dd17 -> bec2ad26 b592aa58 3a28205e", - "c20ef158 42325c5e 421aa3f6 00000000 00000000 00000000 38931e2c -> 3d67c8d8 00000000 3a8c978f", - "bf05e71c 3e5af218 3f77191a b5313775 b5b81ddd b585513e 39873afd -> 3dfca400 36144135 3a2c5ebf", - "be76e3c4 bf06e2fc 3f018ab4 b5fc2761 b7101bd5 b7259d67 365e7ab3 -> be45b561 b7d130bc 38abbe7a", - "c1523fe8 41c111d8 4245352c 3820f0f5 3690661c b71e7064 394990e3 -> 3e6e025c b795c530 3a85d934", - "bf38a988 3ea770bc bf29aec0 b6046e94 b6a06e4b b5f60232 398cb975 -> 3ea4592e 37141908 3ada3e5e", - "3e502098 be821bd4 3f60fb76 3915e8c5 37e9782b b82b0a63 3a3a4308 -> be474176 b8cadc02 3aa0be3a", - "422137e6 3fa4a5c0 421e7df6 00000000 00000000 00000000 3758d26e -> bdb0433e 00000000 3a3d179d", - "41363870 418c8ab8 c1d7641e 354e49a5 35542aa5 b520f2f5 37e91740 -> 3f16355e b655cfb4 3a14d08a", - "bf5d343c bdbfd1d0 3e3bbd78 00000000 00000000 00000000 391c37e1 -> 3e14f3cd 00000000 3a1dea64", - "3e035ae8 3e65e800 3f1a79de 35aa776a b5cafff2 b554856a 3650c79d -> 3ca348d8 b505c934 389cd11e", - "3e292228 3ee22618 3f3c5ff4 3929218f 3990748f 3987d9aa 38535d5d -> bdbb7cc9 b8c3fb7c 391bf985", - "bf77f631 3f7acfd2 3f2caca4 b6a7faef 3696fd38 b5bf38cc 38216ae6 -> 3ea91cd3 372ef9e0 394a906e", - "bf3aef12 3ee020d8 bebc5e48 00000000 00000000 00000000 3a37f4cf -> 3ecd6001 80000000 3b03f2fb", - "c10f85bc c1484eb4 419c2c1c b4aad798 b56d8d7e 34c3139e 363a4566 -> 3e970871 b5b39dd4 39c68a55", - "bf2b8bb2 3f35a9a8 3f65b4fe 00000000 00000000 00000000 381c52bb -> bd1ae63c 00000000 39193c58", - "3ea822c0 bf74a083 3f0fb74c 394e06c4 39a13ead 39a7cc1d 3954e1f7 -> 3e87707a ba222e99 3a406c74", - "410167c8 c1c1093b 410ca9fc b70860cf 37bb24a6 377ea164 383699bc -> bd1c1a10 b887b7de 3a0d8e4b", - "bf25d255 bf4fdb43 bea59878 b7081d38 378a25df 3737b702 392ff411 -> 3e19831c b7977800 39c9cc89", - "bead8206 be29e268 be720d98 b73ea051 b6b0816a b6950153 380d1c66 -> 3e2a8494 b7ec677b 391451b8", - "c0ea0fb8 41efe068 41a365d0 36099420 b6af1783 b6930cfd 36853437 -> be8de572 b7272324 3a064fd3", - "c2012c68 c05de050 40d052c0 38d1a9ea 39266e82 39da2387 36afe53f -> 3ec17651 39915561 39d6c14a", - "bf160490 3c181b00 bf314502 35a51676 b60958c5 3619fc40 398c2bb8 -> be3247a0 b5d4e0c4 3a217856", - "c0ceff28 c19d5e2b 423dbd36 00000000 00000000 00000000 362227e0 -> 3e99f27a 00000000 3a2496dd", - "c13058d4 c2453334 c16a1f68 b642d5a7 b6190007 b721b7ad 372ef509 -> 3d248017 b80dd421 3a2fd796" - ] - }, - { - "glsl": "vec3 cultmath_af_fbm(vec3, vec3, float, int, float, float)", - "tolerance": "ulp-bounded, reach 1e-6 to 1e-3", - "check": "the arguments are (cx, cy, cz, ax, ay, az, radius, ...) and the result is the form (x0, a, e). Enclosure: for eps in {-1, -0.5, 0, 0.5, 1} and d in {0, +-ex, +-ey, +-ez, (+-1, +-1, +-1) / sqrt(3)} (15 directions), form the point p = c + axis eps + radius d in double and round it to float32; the device's own reference value at p must lie in [x0 + a eps - e, x0 + a eps + e] with no tolerance, so a device whose gradient error exceeds the allowance fails. Tightness: with L = 7.9640074 and, for each octave (one for af_snoise), R = |axis| + radius, B = L R + 2^-14 + 2^-12 R + L 2^-20 (|c|_1 + R), the width |a| + e must be at most B + 2^-16 (1 + B). Report the least slack of each side, absolutely and as a fraction of e; only the two bounds fail the check. The reference value is cultmath_fbm_grad(p, octaves, lacunarity, gain).w, and B is the sum over octaves i of gain^i B_i, where B_i is B for the centre lacunarity^i c, the axis lacunarity^i axis and the radius lacunarity^i radius. These cases have reach |axis| + radius of 1e-6 to 1e-3, where the float32 allowance is most of e and the second order remainder is not; the enclosure above fails a device whose gradient error exceeds the allowance. Centre leg, for every cultmath_af_snoise and cultmath_af_fbm family of this fixture, the earlier ones included: the fixture's own x0 in the result (C#'s value at the centre) must lie in [x0 - e, x0 + e] of the GPU's form, with no tolerance, so a device whose noise differs from C#'s by more than its e fails.", - "cases": [ - "3f34327a be330120 3f3da1b8 3774dae1 b706c4b2 b84b80f6 36dcf110 00000004 40000000 3f000000 -> 3c5e7638 3909beed 397d0650", - "3e9594c8 bdc680d0 3e845a64 3415e1fb b5f5b7b4 b43c93e2 3a52b06c 00000004 40000000 3f000000 -> be5f5b71 b5158925 3c160240", - "bc93b780 bb2fb800 3f2ed8b0 00000000 00000000 00000000 36694e2d 00000004 40000000 3f000000 -> 3f66201d 00000000 392e9ae8", - "3d863eb0 becaa00a 3d040d80 b90dd6fa 393b6325 39753445 3710aa74 00000004 40000000 3f000000 -> beb877c6 39df7941 3993e965", - "c19d9f93 c18c6396 3dd97200 b64b03f0 b56a8741 3633e5c5 3922a3ab 00000004 40000000 3f000000 -> 3f2c7106 36299b78 3b33a96e", - "be7a5ec8 3f743008 be282e30 00000000 00000000 00000000 3a4ce666 00000004 40000000 3f000000 -> 3eb11f0e 00000000 3c2b72d0", - "c150b7fc c05bfb60 c1493628 392182bc 39e5f647 b9de781c 3a09a353 00000004 40000000 3f000000 -> 3e4503d7 3b226c9c 3bedd68e", - "bf6464e8 3c2b6100 3ea52a00 33e53557 355b28ea b5a30c56 3a2995aa 00000004 40000000 3f000000 -> 3f58aef7 b5ea5135 3bad1852", - "410c1850 423d0648 41a41564 00000000 00000000 00000000 3908b42d 00000004 40000000 3f000000 -> bf014dc1 00000000 3b965487", - "bdff2b60 bf0406c7 becda42a 35cf24bf b533cf68 35a37ef2 37b70f66 00000004 40000000 3f000000 -> 3eb9dae2 b6b26ccf 3a00bb48", - "c06f95a0 42377004 421d47c4 b7012f36 3592b3fa b6dd5d35 373cc137 00000004 40000000 3f000000 -> 3e85ed76 371f6f46 3b423262", - "408d7948 421ffe80 c11ffa20 396d3819 b89e7c4d b91241c1 38537c62 00000004 40000000 3f000000 -> bed52d26 3ae20321 3b16fe9c", - "41d06b34 c1a9f1dc 416d2a30 b6ad129d b7212019 3644e1cb 3a375b08 00000004 40000000 3f000000 -> 3ecc0274 b8235f0a 3c2a3122", - "3ececc64 3de336b0 be6dba50 00000000 00000000 00000000 3723d0c2 00000004 40000000 3f000000 -> 3eb91274 00000000 397bddec", - "c2071164 c182d8e2 c213efff 00000000 00000000 00000000 39ea70f4 00000004 40000000 3f000000 -> beca3b2e 00000000 3bcd3578", - "41bd065c c1054b48 c2234971 37f67a85 379a153c 374f2b36 35f54979 00000004 40000000 3f000000 -> 3d165d2a 38a2e227 3b19ef94", - "3d9ccbe0 bf66c09a 3ebfa574 00000000 00000000 00000000 370f28a3 00000004 40000000 3f000000 -> 3f1aecc4 00000000 3982ea9c", - "bea831ca 3f6ab10a 3f5e5a38 ba0d96e7 3a23dcea 39da5a1a 3814335c 00000004 40000000 3f000000 -> 3f3cda9e bb10d2e4 3a682c11", - "c1c3a880 41f4a380 c1effc06 37721df0 367d7962 358e675c 383d06e9 00000004 40000000 3f000000 -> bf15b177 b76deea6 3b5374bd", - "42095436 41b5a25c c1e01948 38e7caac b824d694 38954c7a 35972458 00000004 40000000 3f000000 -> 3df85f0b b95e142f 3b3228d7", - "c11a8fcc c20a0c0a 41ecb8d0 00000000 00000000 00000000 3586dcbb 00000004 40000000 3f000000 -> 3e4f4b3a 00000000 3b1b737d", - "c225ec12 c20de114 4240668a 00000000 00000000 00000000 39a253c3 00000004 40000000 3f000000 -> bf2ef7d7 00000000 3bd65e65", - "c23f569f 40510720 c084f958 b9d1b4e1 ba3dab5a b9e495a0 3829dc2e 00000004 40000000 3f000000 -> bf0d0d76 3af367c9 3b2874a4", - "4145eec0 c22877e5 c21a1738 3985edae ba085a54 ba03a84c 3a7f897e 00000004 40000000 3f000000 -> 3dfd2569 bb1d9d5e 3c411be3", - "3f716e94 bf231891 3f4fe75a 00000000 00000000 00000000 358fb6ac 00000004 40000000 3f000000 -> beb3237b 00000000 394e1096", - "3f514f24 3cc26e80 bd981660 b8d82cb8 b885aed7 b8eebcf7 390903ac 00000004 40000000 3f000000 -> 3f3f2547 3a3af2a6 3acf86c7", - "bd9dc4e0 3f3cfe4a bf4a8123 b4ba22e6 b5ebc07d 3594eb62 382481b3 00000004 40000000 3f000000 -> 3e01d8e7 b6ad1ebb 39eaddd8", - "bf523222 be5d350c be08aa44 00000000 00000000 00000000 3613b968 00000004 40000000 3f000000 -> beb68223 00000000 39337cb0", - "c21be42c 423687e4 c21366a7 36551035 b66f2684 370a0a4a 36d7203f 00000004 40000000 3f000000 -> be5bdf57 b87d0c0c 3b7fc1ea", - "3d600720 bf2a2ee2 3f4519f2 00000000 00000000 00000000 38e21d4c 00000004 40000000 3f000000 -> 3d83969a 00000000 3a8ea9b0", - "42215390 c2337bf7 40a930d8 00000000 00000000 00000000 39c35ac9 00000004 40000000 3f000000 -> 3eeb5095 00000000 3bd96bd6", - "bd85e0a8 3f639ee2 be70535c 36b3354c b785cda5 380335bb 35e6fef9 00000004 40000000 3f000000 -> bf80f8b4 b90f092c 3938f5da", - "c1c4d1d5 c12e243c c18472ba 34cd5fa9 35ac5d88 b5cf627a 35b23677 00000004 40000000 3f000000 -> bee1e211 3619a83d 3adffc60", - "bf2071e1 3e66ba10 ba430000 b8918e3a b81b4882 b8f1de4f 37f54e42 00000004 40000000 3f000000 -> bf370b6e 38a85e98 39d87864", - "3fe5fe60 4234e8d2 c2070f7e b73232b8 b99eaa64 b82c1e97 397353e0 00000004 40000000 3f000000 -> 3f09468d 39bfed9f 3baf774a", - "be2451e0 3f011b78 3edc8afc 00000000 00000000 00000000 3a105c24 00000004 40000000 3f000000 -> be28a946 00000000 3ba45044", - "4209d296 c1d5e556 41d4925c 00000000 00000000 00000000 3a75c916 00000004 40000000 3f000000 -> 3f602435 00000000 3c4bbf61", - "c217a314 c228861b c1698070 b577050e 368d0794 35a905bb 36c10fcf 00000004 40000000 3f000000 -> 3ee068d2 3738920a 3b47d6ec", - "c23cbde4 419d4b7c 42159fd2 b70d6f02 370a2255 376dc7c3 378c27e7 00000004 40000000 3f000000 -> bf20135f b8886e3c 3b643788", - "c193f598 3f13fd40 c16231c4 390795f0 b8393bc0 38947e38 380bce49 00000004 40000000 3f000000 -> 3eb49fb1 3a877674 3abd2ba2", - "3f66044a bdca91e8 be5e9a2c 00000000 00000000 00000000 39a38e8a 00000004 40000000 3f000000 -> be1ad0cc 00000000 3b6e5249", - "c1e395f6 4156f874 41c19604 b66e2d24 35899935 b6524aaf 391bd47c 00000004 40000000 3f000000 -> bdeebd14 b80aff3f 3b79497c", - "c1befe77 41331818 c1bc0235 00000000 00000000 00000000 36e2eaf4 00000004 40000000 3f000000 -> 3f898542 00000000 3b013707", - "4150c7c8 41cebee0 c2124dd4 351c918f 359543d6 35a2b424 35a9a590 00000004 40000000 3f000000 -> 3e8301f7 35b318dc 3b1eaa9e", - "3ed69998 bddb6358 bf040aad b5c40026 3619b869 b46ee9fd 383a810a 00000004 40000000 3f000000 -> 3e2c42ff 35dfb117 3a124bf5", - "418fe5cc 41a13f10 423faed2 b976afc8 b9a52766 393bfca6 3608c0c3 00000004 40000000 3f000000 -> bca01ea2 3a832d8f 3b38fcaa", - "c065da00 c0e6a320 404117a0 362c225c 358eed60 3669a6a7 374ec7c3 00000004 40000000 3f000000 -> be0277a2 371f9874 3a22c12c", - "418d96e0 4181143c 4189bc94 35c0b512 35b2b813 360185a9 3910dace 00000004 40000000 3f000000 -> be66976c 377e46e6 3b536e0a", - "c20f5c57 c21810ed 40424260 3697fda3 3746c652 370165fe 377a60e9 00000004 40000000 3f000000 -> 3ea75939 388fcbbe 3b273f0d", - "bf14eb68 bf57a258 3f74858a b7a5d393 b819aaff 38927973 39447106 00000004 40000000 3f000000 -> 3efd3e97 38d4316e 3b329c4e", - "3f3dec9c befbce40 3f102862 3737bb02 b818f687 b81582f7 39e7f43d 00000004 40000000 3f000000 -> 3e9f7627 393e9a77 3b9eda58", - "c20e6ec8 40cce9e8 c205f730 3823e385 b75c09a0 380c6b78 3a2ee242 00000004 40000000 3f000000 -> 3e179330 b8de69ea 3c26e920", - "3f3511b0 3db3dac0 3f265f78 b91f9b64 3817a3aa 388df655 359f0e30 00000004 40000000 3f000000 -> 3e621513 ba1fa011 393ffdb8", - "3f56a6ac be9a05c0 be639760 00000000 00000000 00000000 386e79f7 00000004 40000000 3f000000 -> bedfb649 00000000 3a578037", - "bea59ad2 bee46b28 bec1fd02 355cdb93 b52215a3 3297d5c8 37b69540 00000004 40000000 3f000000 -> 3f31858e 357d2929 39c705dd", - "3f53d77e beadaac6 3f6db504 00000000 00000000 00000000 376e322c 00000004 40000000 3f000000 -> bec64cc0 00000000 399a6ca6", - "419c3fcc 4212912a 41ff0730 b42f20dc b598134c b54e006a 37296dc3 00000004 40000000 3f000000 -> 3eab18c9 33e7f5c0 3b3ead91", - "40992a80 c19e8b3b c045da20 b55f67dc b581452f b5968801 358bdf6f 00000004 40000000 3f000000 -> bf5b7096 36f7e17c 3a7eb51e", - "bef12dde bed0f58a 3f7bb0ec b78b6a62 374134fc b6ce9f48 38ed08c4 00000004 40000000 3f000000 -> bee98d9c 38540eca 3adf397f", - "41dfaf6c 4242a89e c1f32879 3641048e 34e0bd5d b6adc411 37c6f3e8 00000004 40000000 3f000000 -> bf169582 b6f14f60 3b6a3fb0", - "c21be13e c1bcb33d c1976ec3 38332936 b8a54bc4 3718c9a3 37d788b1 00000004 40000000 3f000000 -> bf12dc10 39c81aef 3b39f032", - "beed6928 3f46878e bf6fa323 b6222fa9 b51a3e0c 360fa338 36fbb2aa 00000004 40000000 3f000000 -> 3ea93587 b3cf7520 39863926", - "3eb84a8c 3ee65b30 be8d4572 36e9e9a7 3897a09e b9f41d1e 363094bd 00000004 40000000 3f000000 -> be7679c6 ba1f2766 398d5ddb", - "3f4dbfcc 3f1bd4b6 3e7200b8 3458463e b7235561 371e9e77 3a713649 00000004 40000000 3f000000 -> 3e254c45 35d69708 3c0444d2", - "bed8fc5c 3eb477e8 3f718752 b73d5e79 3732e5dc 374f95a7 3805c730 00000004 40000000 3f000000 -> be1c02d6 b64aac70 3a0e1ca1", - "416c3150 c233e073 423a7918 365d112d b6286a83 3713a713 360da2d1 00000004 40000000 3f000000 -> bf380b26 b71f1b0a 3b5d248b", - "c21f9a0a 41647ab0 3f93afc0 3728acff b57beff2 b6c86d4d 36c0c4fb 00000004 40000000 3f000000 -> be6aeb55 38a27f7e 3af6c508", - "c1095ea4 be8b1d00 c1fcd481 b702c1d9 b7b352c2 37370026 39ffecb3 00000004 40000000 3f000000 -> 3de1e4e9 3903b932 3bca0998", - "3e5a2c30 3eb14df8 be619bd0 b9155479 38d42515 38cc136c 359f8485 00000004 40000000 3f000000 -> bd3e752c 3a4a0ac2 392f838d", - "c220b1ce 41797550 c1b876f1 35ce4893 3583b5ff b617f858 358cc3fe 00000004 40000000 3f000000 -> be62150f b6d8a542 3b252f49", - "3e7a66a0 3e492d30 bf241599 379739f9 b79b2d88 37a294ef 382594a6 00000004 40000000 3f000000 -> 3f516f1c 38ec20f3 39ed7cfa", - "3e874ad4 be059b08 be08ef74 b62e3c79 b7b1f3f8 b89851df 398f3799 00000004 40000000 3f000000 -> 3ee3fe36 b90e7436 3b83b694", - "4148fea8 3e857a80 c186d56c 00000000 00000000 00000000 3a616b4d 00000004 40000000 3f000000 -> be87056e 00000000 3c1389f9", - "bf0b5572 bed33e2c 3ef13bf4 36d5a1e2 35f8d14a b5477d2b 3a77adb5 00000004 40000000 3f000000 -> be81b1c3 368eb8e2 3c24588a", - "bf232ac0 423a0134 c2363e26 374063ac b682bd5c b6d242d6 37fc8729 00000004 40000000 3f000000 -> bd272e15 b88cedf4 3b4f9760", - "bf0df084 3f0cf8f4 be4eac80 b9eca763 3928717f ba2d41cb 3a7ea28d 00000004 40000000 3f000000 -> 3e8cafb0 bbb4c5d1 3c4c5fa9", - "c1ba94ec c2336e7a c0aaa1d0 00000000 00000000 00000000 3a1972af 00000004 40000000 3f000000 -> bf1cb1db 00000000 3c08c9dc", - "3f08efe0 3f37796c 3f1d8f84 00000000 00000000 00000000 3a5b8ecb 00000004 40000000 3f000000 -> bd20ade1 00000000 3c2d7bd4", - "3e6b7800 bfdb42a0 422db02a 357d5ef9 36b0ace0 b6ad67c3 36d54b47 00000004 40000000 3f000000 -> 3f85a57d 3729211f 3acb5f04", - "3e8a7958 bebdcc7e 3d913c90 36e7fbc3 b596d247 b6807d6d 36c528b7 00000004 40000000 3f000000 -> bdaffb50 3644e5c8 393147d9", - "c1b0d231 4214d97a 41c13888 35066c98 3753a56e 37461679 3853b226 00000004 40000000 3f000000 -> bed16622 38a1688e 3b645bb7", - "40e19628 c081b288 419754e0 00000000 00000000 00000000 36dd3d40 00000004 40000000 3f000000 -> 3e0c974e 00000000 3a955ad4", - "be89ba6a bf4a8d21 3f69a2fa 36d1f6a4 364d7f85 36b01e7c 3794af6e 00000004 40000000 3f000000 -> 3e2fae58 3842180e 39b8d324", - "40969e40 c0405710 418e6960 36ff0446 353a1f63 37e5a063 39e3e8a9 00000004 40000000 3f000000 -> 3f1bcfd6 b7be6902 3b835054", - "3ef722f4 bc82d280 3f0a0ad8 b9d87a9e 38fc9120 394b2032 376c000b 00000004 40000000 3f000000 -> be14263f baa3122c 39ba62e3", - "4148c6bc c0394060 c2003448 b9a59140 b978eac2 b8efdaff 385780c7 00000004 40000000 3f000000 -> 3e67316e 38797528 3b076d16", - "bf75a754 be137f5c bf72ae7b b5e7770c b54caa10 369f4c41 398353dd 00000004 40000000 3f000000 -> 3e096f03 354b5040 3b322b84", - "4191eff8 c1ec4aa6 c1fbfea5 b6d5298d 36f4dd70 b658a583 374983d6 00000004 40000000 3f000000 -> 3ec2196e 37d0fc81 3b2efbfb", - "42410138 42384688 422c5384 00000000 00000000 00000000 380ac47f 00000004 40000000 3f000000 -> 3f2bfe90 00000000 3b9a00c1", - "c1a7a252 419faf54 c1bf031d b68b76af 36a7b0fa 36ab3efa 388dc0df 00000004 40000000 3f000000 -> be779d18 b746f16c 3b2fa0f7", - "c0599540 c13ab534 c1ebbce0 36d60c20 b4615afa b6d86141 37fd56c1 00000004 40000000 3f000000 -> 3f03f077 b7f92e65 3ae92a1f", - "c1ab2967 406a6ad0 41f2d490 00000000 00000000 00000000 39b05644 00000004 40000000 3f000000 -> 3f450922 00000000 3b90e878", - "3f937560 c1a89c93 4111d7ac 00000000 00000000 00000000 38021002 00000004 40000000 3f000000 -> bee9cfb0 00000000 3ab2bb8b", - "3f427064 bea51598 bf280012 00000000 00000000 00000000 3a5c5846 00000004 40000000 3f000000 -> 3e365e53 00000000 3bccf912", - "422057c8 41dd67b8 c1a7b400 ba127a0e 39e2b97c b8e818d9 3625b90b 00000004 40000000 3f000000 -> bda7125f bb45adf6 3b482f1c", - "be7bc658 bc098900 3f3cf508 38a81cf7 b90cf016 38c54795 39ffb9d3 00000004 40000000 3f000000 -> 3f49f3d9 ba22e0a1 3bde13d8", - "40b867b8 c20a3b6d c1295e30 38806351 377179b8 38bd3016 3807ec2b 00000004 40000000 3f000000 -> be712daf 38c00d06 3afc47c0", - "be5f6da8 3f3cf0ba 3cc23a80 b65099a4 370a6844 b76c2514 380819e4 00000004 40000000 3f000000 -> 3e9ee5ea 37a1e69e 3a18aa18", - "3f142b6a 3f48154a 3f4131e6 39959f96 b992e4a3 b960bb55 35af16a2 00000004 40000000 3f000000 -> be54aa7b bacc1804 39911aa3", - "3dc7f660 be27d824 bf38e58e 38a26e32 386a07a7 b7def4e2 3651571d 00000004 40000000 3f000000 -> 3e3ba09d b7ca7b00 3941caf0", - "c235e0b6 41b5a584 c0a6a298 b52da694 336e1180 365feee6 367ed96b 00000004 40000000 3f000000 -> bef78bbe 36b38d12 3b1c34be", - "423615f4 c13ae4f4 c1c7ec62 b8904027 3855e49c b88ee431 39104491 00000004 40000000 3f000000 -> 3e9f5b91 3a11c47b 3b87c482", - "be8f5f96 3f5c7784 3e915908 b7aef875 3862f42a 37dced1d 39b9d08c 00000004 40000000 3f000000 -> 3df346c0 b83ee280 3b5f4cdf", - "beaa03e6 bd8ecd10 bf040d94 00000000 00000000 00000000 3a007214 00000004 40000000 3f000000 -> be041893 00000000 3b4b1219", - "c0b6d858 4134d094 c1996509 b52915ad b553c221 34a775e1 39ac3df4 00000004 40000000 3f000000 -> bee21217 36a0d390 3bc13362", - "c204d206 c1fc214b 4158d8fc 00000000 00000000 00000000 37d6a836 00000004 40000000 3f000000 -> 3e80bdb7 00000000 3b36659d", - "3f67ac32 3dba31c0 bf414d32 00000000 00000000 00000000 35f1a2b8 00000004 40000000 3f000000 -> bf508b91 00000000 3947920c", - "3f64a8d6 be088f54 3f0e4768 b7a2f6a9 36201d8c 37b976d9 3631de8e 00000004 40000000 3f000000 -> 3f5bc4bc 37c6c3c4 39494d04", - "c231137a c1e5e564 c1dcd13e b6cd180f b718967d 34c7f167 36ade128 00000004 40000000 3f000000 -> be5360a8 36a2ef96 3b52cfc9", - "3f3dc17e bf322078 3f1c1d36 3883ce8a 37c59a6c b8284bb0 3810bf78 00000004 40000000 3f000000 -> be111927 b92ab8c4 3a0cdcb9", - "3f4c3398 3f1064f2 3f7455fc 3879d0e8 390cb72a 383d856e 38efb936 00000004 40000000 3f000000 -> 3e52dc6c 39ffbfa0 3ab33847", - "c196dcf4 c171f460 c23e3111 b92c6590 b80ebdd2 3950ddc4 37259ac3 00000004 40000000 3f000000 -> 3f198afe ba71e74a 3b312c54", - "bf6cbc65 3f0d3546 3f40c9de 367bfefe 3649c213 35aff100 37954481 00000004 40000000 3f000000 -> 3de824a6 b6edd21f 399ad0c6", - "beb9bfc4 bf5e7983 3f747152 b785930a b7b08963 b7cfdda1 3a80fa3f 00000004 40000000 3f000000 -> be9bfaad b83a2a42 3c179488", - "4191fb90 41df374c 418081d8 00000000 00000000 00000000 371bbb7d 00000004 40000000 3f000000 -> bf166ef6 00000000 3b0a72e0", - "bf3eae76 3f3b45f4 be286020 39954258 b9093ce8 b985ed35 38c6e631 00000004 40000000 3f000000 -> 3f06db46 b9805e5a 3ab65c1b", - "42223128 4026e240 4206a0e2 b5809c48 b4d7ce2b b53eb980 39bd6b75 00000004 40000000 3f000000 -> bf75367a b525c6d9 3be1dd6c", - "c14dd67c 41001060 412eaab4 b96c190b b84e6919 3968647d 3a48a0d0 00000004 40000000 3f000000 -> bf6a8e7d 3a411014 3c16d4d2", - "c219ef4d 41f7ad70 c2149064 39256891 39821fe3 399bf60a 3a20f2e7 00000004 40000000 3f000000 -> 3d239b30 bac4e44e 3c2462bf", - "3f081f38 bf486da1 3f122a64 00000000 00000000 00000000 3757d92f 00000004 40000000 3f000000 -> 3d8250b8 00000000 3993b829", - "3ebb6440 bf3f9bde bf000162 b43f74e6 353878d2 b5cef6b4 363dc6a5 00000004 40000000 3f000000 -> bd639822 36dbd10b 39509de4", - "bef93d80 3e063dc0 be940722 36647601 b5b3dd11 3781bbe4 358db7a1 00000004 40000000 3f000000 -> 3e7b7e28 b514fa80 391f2d2e", - "c12405dc bf7153c0 c1ec052a 38fbfed6 b8c55a22 ba1e29c7 37e72ac6 00000004 40000000 3f000000 -> be44003b 3b2d5198 3af97aa3", - "41eba5f4 c11c708c bfe0eac0 38a9e145 38786d67 37e81958 39789beb 00000004 40000000 3f000000 -> be16637a 3a3df8f8 3b94fc07", - "41186f68 c233355e c1f39762 00000000 00000000 00000000 380a497e 00000004 40000000 3f000000 -> be80094f 00000000 3b3fa8f0", - "3feb5ac0 415c67f4 c186c294 b69774ca b5e8c9ec b6986668 3710a248 00000004 40000000 3f000000 -> be048d6c 37d75534 3a9a3991", - "422850d0 41d4e258 41a7f1ac 00000000 00000000 00000000 381be1a9 00000004 40000000 3f000000 -> 3dd59176 00000000 3b6576d8", - "411a73a8 421b11dc 41ca6144 b9cd20a7 39b9a56d 38290019 39e4712c 00000004 40000000 3f000000 -> 3f2e97aa ba6053f1 3bca8a4a", - "412e02e8 40002510 3d7a5800 b649a211 b6cbde50 36eb11b9 3a16adfb 00000004 40000000 3f000000 -> becbf2fd 372959fc 3baf5245", - "411fac00 c20070fd c22f3fa2 b7d9c997 b7d5dd47 b7f4d333 39494313 00000004 40000000 3f000000 -> 3d9db5fd 388f7320 3b9f0143", - "3f6cd2b0 3f069a92 3f6dcf08 b78d6fac b89881ce b854072a 36536c14 00000004 40000000 3f000000 -> 3d59c98a 39650bef 396e0180", - "bf4f7394 be1c5348 be20e088 3a062979 39addccc 3a04b32d 3a010339 00000004 40000000 3f000000 -> bef19934 ba7bc30f 3bba797f", - "3f139704 be7528a0 bf483de6 00000000 00000000 00000000 38eb1042 00000004 40000000 3f000000 -> bd87374a 00000000 3a927a04", - "4202517c c17a6718 4171f440 35075a87 359c1a89 b5629205 36dc8c5c 00000004 40000000 3f000000 -> 3f44e95b b63ef035 3b0a9871", - "3de38b00 bf1f949f 3f47b5fe 36668604 b636d510 b6b0f73d 375a2cb1 00000004 40000000 3f000000 -> 3e2962b4 36b36aa8 39981c49", - "41cdf5b8 c2219208 41550a40 b8eb9b86 ba08566d 399069ab 35a5c91a 00000004 40000000 3f000000 -> bdf13c9e baf759b2 3b3067c5", - "3e9db0ec 3f50864e 3e843498 00000000 00000000 00000000 37ea524b 00000004 40000000 3f000000 -> 3f492ae1 00000000 3a0648af", - "c247d29e c1a6cb7d 422c0b6e 00000000 00000000 00000000 36e321b4 00000004 40000000 3f000000 -> 3f5058f4 00000000 3b70ad67", - "419a9378 422c2fe0 c2169a14 b775d912 376df81e b75ec6b5 36960019 00000004 40000000 3f000000 -> 3e110264 38a5c3cb 3b51afd9", - "3ebe4b48 3c675300 3ea407c8 378b4383 b7f6dfa2 b6a06742 37216e97 00000004 40000000 3f000000 -> 3cf24616 3842f5c2 39883c3d", - "c23bdfa1 41984444 c1f6824a 37aa8f5e 38fda980 35eef92e 371f31bf 00000004 40000000 3f000000 -> 3f25be5e b9ec1769 3b4f2f0c", - "be9b0126 bef27b0a 3f4c6ed2 b9134376 39999f73 b916a9a0 361db112 00000004 40000000 3f000000 -> bf07ea37 b919405a 397f37b6", - "3f1e9dec 3e0c47d8 be89c218 b8d98fe7 b913986e b83f2807 37115b8d 00000004 40000000 3f000000 -> 3ea7949d 3a0f7266 398c35ce", - "3f34434e be25b720 3f0f90e8 00000000 00000000 00000000 37243865 00000004 40000000 3f000000 -> 3f00d28d 00000000 3986809a", - "41bee20c c01e9ba0 c23dafc2 00000000 00000000 00000000 378993f6 00000004 40000000 3f000000 -> 3da53402 00000000 3b2294b3", - "c211761c c1785c68 bfec5c60 34c342bf b5566d92 b51cd554 391e876a 00000004 40000000 3f000000 -> 3e3523b4 b670e7e3 3b6f82d8", - "be66b480 3e21c4d8 be35e5f0 b782342a b74438a4 b6d99179 37de9eac 00000004 40000000 3f000000 -> 3eeaef8a b7d36886 39c05b99", - "be6e3f6c bdc2f0c0 bf75cbae b5043fe8 37250907 b7503ed7 3a4c89fd 00000004 40000000 3f000000 -> 3d16389c 38002c80 3b92bf60", - "3f2618b2 3f4c9e00 be9fef06 b80b41b9 b975eebb b8a1d5ae 38126081 00000004 40000000 3f000000 -> 3ea654f2 b8641ad0 3a2ab97b", - "c0ee8ea8 c19c1314 c20d4508 b9ac602f b95bd3ed 38d5089b 38e2d4a9 00000004 40000000 3f000000 -> 3f770c57 3a1b8c1c 3b5d9b6b", - "c234a5da 410dca38 41c786e0 b8269ad5 37842177 b77ba477 3a2cfec8 00000004 40000000 3f000000 -> 3e6455be b8caa9e6 3c31ebdc", - "bf1b53ea 3f5a92c2 bf69aef7 355b9e13 b32317c3 b55b9cb2 35a4bf70 00000004 40000000 3f000000 -> be02add9 36824ebf 394da6cc", - "c23db4ef 414cd848 42292856 b8888e1d b926a650 b899d4c5 3a01694c 00000004 40000000 3f000000 -> bea1b46f 3a8e3b05 3c0545d1", - "c1f10183 c1f1671f 41b18df0 38a298fd b863e5aa b896d89e 3741529e 00000004 40000000 3f000000 -> beaaf135 b94587cc 3b3369d6", - "3ec88d78 3f14a342 3f37cbee 371ead77 b30d049a b6b55629 3802d1b3 00000004 40000000 3f000000 -> beaa51f6 b7bb4ff9 3a06b739", - "3f6eb6fa 3e7ce7b8 3f2d701e b71f11dd b6a34f04 3729e667 371e0723 00000004 40000000 3f000000 -> bee29caa b8ae05c0 3992cc6b", - "be791f50 3e0ac070 3e9de130 362936b4 37a0aa23 b73e3a60 3a1b2d22 00000004 40000000 3f000000 -> bf187d3f b90daed8 3be0f1b6", - "bea66d46 3db1f440 3eab5a10 3574a453 b61564d8 3617ebc3 37b268da 00000004 40000000 3f000000 -> bc214646 3689f612 39c1c491", - "3f2287ae 3f6b7356 bef6b104 b70cb1b1 36651b33 b6d5df30 36baf607 00000004 40000000 3f000000 -> 3f0ec4e2 b81c4f1c 3987e8a2", - "40e03430 41d0e408 c154b580 b582241a b639f061 b635ed0d 366fb678 00000004 40000000 3f000000 -> 3dd98a45 b7848c5d 3acae0aa", - "bed35c9c 3f1f5abe be2084c0 b7d3103e b6de1f62 38240b65 394f99ba 00000004 40000000 3f000000 -> 3f401dac b7b2d06c 3b1872eb", - "41721550 bf39ae00 42329e32 b6e76d27 b5d18c21 b675f679 3733ba43 00000004 40000000 3f000000 -> beaae468 b6a671a0 3b08018e", - "3e8e3628 3f36b7f4 bf18e050 36b07d45 356ae656 b678df77 3a0e5a09 00000004 40000000 3f000000 -> 3e8d3006 37e4293e 3baebacf", - "c220480e 40db4188 4243783a 350d7e1e b6f798b7 351966fe 36398f2e 00000004 40000000 3f000000 -> bf0ab4a3 b688a510 3b4874b2", - "3e73eb08 3f1abbcc 3e290c30 00000000 00000000 00000000 3988a97e 00000004 40000000 3f000000 -> 3f1bd6f7 00000000 3b47bf52", - "41fba7a0 42148020 c1c2c42a 360be14a 361303a0 361c6db5 36e8de8f 00000004 40000000 3f000000 -> 3e1ccfb6 b781dc6e 3b43fa44", - "412fb890 4235acda c244021f b6b069fe 3680e6a3 364aaf0a 358fef26 00000004 40000000 3f000000 -> be137b1e 368918b2 3b5a5afc", - "3ed08700 c0f56f68 4238367e 00000000 00000000 00000000 39e54208 00000004 40000000 3f000000 -> 3e87c341 00000000 3bbca0c1", - "c20abc77 c09cf968 c14dfcc8 b9497f91 b9c3786e 3910b6d4 394a4a5f 00000004 40000000 3f000000 -> 3f1fab35 baad420d 3b7903d2", - "c242460c 4238198a 41809d90 357c005a 35afc3ac b59963e0 3781aa02 00000004 40000000 3f000000 -> be56d902 b6d815ca 3b70561f", - "bee11ffc 3d0b9e20 3e957358 b8c297de b865c867 b8d21e05 385bfbfc 00000004 40000000 3f000000 -> 3eb8d70e ba32572e 3a76b751", - "422449a2 c216e05c c22b8eae 372bc9e7 b6b05959 3797cfb3 364e0a2e 00000004 40000000 3f000000 -> bf1249d1 b7c9b4f6 3b7c54cb", - "bed4e02e bf3e4d68 3f3c9ed2 38dd5765 38f00c54 38a1404f 375a62be 00000004 40000000 3f000000 -> be736564 b9083e60 3995812c", - "bf2393e2 3f39553c 3ef30d98 37481458 36e47ee0 377fff1e 38e6274a 00000004 40000000 3f000000 -> bedc16a6 37f3b0ec 3a917330", - "3f5db59e 3f610616 bec42da8 b895a2f2 398ab793 3989e123 386811b7 00000004 40000000 3f000000 -> 3f12693b b9f1b7c2 3a5b951e", - "423cd10a 41ef3314 422e7720 b883574b b8dbc8ed 383bab14 36ce2c09 00000004 40000000 3f000000 -> be961e6a 392deec2 3b7cb2a1", - "418a1ee0 c13be004 c16e4850 b8e9c169 b9365813 b8392507 35cebce5 00000004 40000000 3f000000 -> bf8b03f0 3a8d3148 3ac38730", - "412210e0 c1379fa4 41d2edb0 00000000 00000000 00000000 389266bb 00000004 40000000 3f000000 -> 3e909095 00000000 3b102c4f", - "41ffeab8 be59ac00 4095ea50 357274f9 35589d2a b588d5bd 392acece 00000004 40000000 3f000000 -> 3ed5aaf9 36656892 3b49c238", - "422a5378 421b7534 c2464c2e 364364d4 b6203483 b6026b8a 3709712a 00000004 40000000 3f000000 -> bdc9d08c 36f9ccc7 3b88e57e", - "3e3518b8 bde33f70 bf2e3296 3505ef81 b8055719 37cd8944 39076d9b 00000004 40000000 3f000000 -> 3ee96c76 b8938fa8 3ab41bf0", - "bf6de812 3f0074b2 bf082782 b719bb28 b79fba1a b79c7f30 38dddd41 00000004 40000000 3f000000 -> 3edc47bb 38b23134 3a8fe73c", - "bf10e469 bedc9aac bf3f2ea0 b7b69202 b445d49b 37830b41 35c9bacf 00000004 40000000 3f000000 -> bee5b836 b916385c 3945d934", - "bf142af4 3ddfcb20 3f42f910 00000000 00000000 00000000 394daaa8 00000004 40000000 3f000000 -> 3ea652ff 00000000 3aee1442", - "c181844e c1ef1049 c1b54417 362fda3a 354537f6 b54e7a28 37375576 00000004 40000000 3f000000 -> 3e5d9855 b67070da 3b1839dc", - "41775048 c22e0740 c1c45182 376daea1 36cd7bc1 3592fbcb 3727e590 00000004 40000000 3f000000 -> 3eef2cc0 b7a08a5a 3b37cffd", - "c191a98a c18793b8 c1ddcc4a 00000000 00000000 00000000 373413b6 00000004 40000000 3f000000 -> be7a33b8 00000000 3b0b7592", - "c01c8ae0 c1edd11f c14615fc 39f271e8 b9d84315 b9d4d1b3 398fbc8a 00000004 40000000 3f000000 -> 3b919eee 392695d0 3b88dd8c", - "bf14831f 3f7c4bc6 3f6190bc 39f2a8c3 3a08f623 b79bdfc5 39b04fb9 00000004 40000000 3f000000 -> 3e2d1d46 3a1d9137 3b721c75", - "bf0ea593 bf0e30ce 3def9240 b7b5a98c b53e7f95 372ed160 35c79b16 00000004 40000000 3f000000 -> bf31c38d b88a0e36 39337225", - "423f5e00 c1bca9ce c1813880 b9803171 b97cfbda 394c24cd 3709cc42 00000004 40000000 3f000000 -> 3f057674 3a95e14b 3b3f55e3", - "421bea88 c1a191a1 c23e629c b8583435 38effbcd b8ff05bb 376af87a 00000004 40000000 3f000000 -> 3e74ecf3 385f4110 3b65fd3c", - "420afc0c c1b432d9 c2053234 b99eb565 b943c488 38e4e19a 37c99a59 00000004 40000000 3f000000 -> 3f22b924 3ac7b7ec 3b51819b", - "c0c2c570 41abd938 421fa4bc 36b6acf3 36aa4526 35ebbd6f 37a415da 00000004 40000000 3f000000 -> 3eb8be7d b7ee78e1 3b19dffc", - "bf18ad93 3e70d598 3e929888 37e39359 381879fa b7d95c51 35ae8317 00000004 40000000 3f000000 -> 3ec345c8 b91b438c 392dca39", - "c23cac06 42414f12 c228b536 b89f7d78 383f2398 b8bd07c9 38366a2e 00000004 40000000 3f000000 -> 3f0607c1 372a7dc0 3b9dc0e4", - "3d01b980 3f55bb10 be4224b0 b673bca8 b62e521f b558d490 358d6eb0 00000004 40000000 3f000000 -> bf88ba65 b7873c70 392ed8ab", - "3f463828 bf2d53ae bebb5fd2 b957dc31 b921fc01 389dd11c 399939d7 00000004 40000000 3f000000 -> bea112d4 ba2a6210 3b3c2b91", - "c231ff08 c22b5ed0 41ff14e8 b627efdc b55009b1 3620efe5 38b488c9 00000004 40000000 3f000000 -> be1d7973 b6a12279 3b93ff77", - "420b712a 4235780c 41c6b030 b8b40bc7 b898c444 b8cbbfeb 3710c789 00000004 40000000 3f000000 -> bea628d6 b99afb59 3b60275e", - "3d481480 3f7566da 3e054bd8 36b048b1 37b00686 371f8c64 385f9cfe 00000004 40000000 3f000000 -> beea8788 392523d5 3a485dc5", - "bf5b190d bed96500 3f41e4c0 374c1b03 b6030d49 b76bf288 384aee1e 00000004 40000000 3f000000 -> 3e7df1c4 37b78ac5 39f754f1", - "3d9d48b0 bf11aff1 3e177d90 38bde962 395c280a b8308519 375f0c92 00000004 40000000 3f000000 -> 3ed31132 3988be59 39a442f9", - "bf770d83 3f50a056 bba62500 00000000 00000000 00000000 38bdb583 00000004 40000000 3f000000 -> 3f3bad12 00000000 3aabfade", - "3f261800 c192de5a c130ea4c 38bde695 b8d2a46d 380d74ab 3687e988 00000004 40000000 3f000000 -> bcba75ce 39faafd1 3a8d2ae5", - "bf599d02 be7835e0 3eb9517c b8b1f11f 38a3595c b8bf15f0 360848bc 00000004 40000000 3f000000 -> becb254e 39707e86 3940507b", - "c11778a8 4204d562 41fc6160 b746c900 38cabcb4 b8dfd754 3a0f806d 00000004 40000000 3f000000 -> bd34b5d5 ba49b778 3c0e9ddb", - "41e8304c 419e2f80 41adec5c 35894c43 3530ff2a b591fe59 3983c5b6 00000004 40000000 3f000000 -> bec909eb 36a0b8c5 3ba1e417", - "412c2570 420fb23e 40433220 00000000 00000000 00000000 39c5466e 00000004 40000000 3f000000 -> be340cf4 00000000 3be0054b", - "c21cde3f 40e98188 4187ea94 00000000 00000000 00000000 39340858 00000004 40000000 3f000000 -> 3eb997e2 00000000 3b5e92fa", - "bf57da78 bea0948e 3eae77c0 3584b6cb 397f2c71 b9ffb94d 3601cdbe 00000004 40000000 3f000000 -> bea9b05d bae6f95b 399e6814", - "3f1a9a1a bf6c9825 3f0a9514 369a173d 374373e6 372dabbc 393fa3ef 00000004 40000000 3f000000 -> beeb8c03 37db203e 3b2363db", - "4228e33c 41c2555c 41a11a34 b71476ef 370dbb5d 37606102 3955880e 00000004 40000000 3f000000 -> 3ead9f3c b89b33f3 3b9d59a7", - "bf665f41 3ebc2ba0 be247ca8 00000000 00000000 00000000 389736bf 00000004 40000000 3f000000 -> bec37dc5 00000000 3ad229cb", - "c21f8a3e c1bd4e00 c1af028a b8d8a177 38b45a55 b85b500c 35c75edd 00000004 40000000 3f000000 -> bf284978 39e3f3ed 3b33cbe7", - "c1676090 bfefe300 c14b58f0 00000000 00000000 00000000 390ca00f 00000004 40000000 3f000000 -> 3eb6fcca 00000000 3b1344ad", - "c01fae60 417544d8 420d2d40 38c00663 b97e6228 b8ac386b 3a22f6fc 00000004 40000000 3f000000 -> 3e1a996c ba8959c1 3beb8bbd", - "bf370584 3e2e84b8 3f2cfbd2 00000000 00000000 00000000 389610f0 00000004 40000000 3f000000 -> 3f354951 00000000 3a511119", - "3f040e46 bed9ede0 3f1dd900 b55c1086 b3e6ad61 b580e75b 37e51a9e 00000004 40000000 3f000000 -> bf02f954 36a94e78 3a0a8706", - "bcb76700 3f1e3388 bea9f47a b9427646 37f462ed 39012235 368dddea 00000004 40000000 3f000000 -> be99bdc2 395930fa 395fe3ff", - "bf2cfce6 bedd5cb0 3eedfe50 378d503e b5af5255 b6b8e1c3 39349fd2 00000004 40000000 3f000000 -> be7bf26a b8b2a4de 3aea1c5b", - "3f437dd6 3f60d002 3f3faebc 35836c96 b5f3c7a9 b5015b8e 36356610 00000004 40000000 3f000000 -> 3f0b024b b68545f7 395d4cbc", - "41192298 41feebb0 420eaf78 38811c8b 37f352e5 b72b96d0 385881b8 00000004 40000000 3f000000 -> 3ede9b87 b8d90cd1 3b441a7e", - "3f1172f8 bf644bda 3f51a834 39894fc2 b8983c5b 3920ea29 390d595c 00000004 40000000 3f000000 -> beae05ee ba1a2217 3b1a66e7", - "bf57ee9f 3e906340 bed82ae2 b8e1ba6f 37606486 38f52f2e 38801278 00000004 40000000 3f000000 -> 3f56e2c6 399ff76c 3a452aec", - "bf23404c 3ec50b70 3e8f2758 00000000 00000000 00000000 365a2f59 00000004 40000000 3f000000 -> 3f2462fe 00000000 3944b54c", - "c0e93d60 c22b1379 c17dcb8c 3627d72c 35b11956 35ebb7b6 39fd9169 00000004 40000000 3f000000 -> 3e2768c0 b7948410 3be789a2", - "bf70d831 bf7473e0 bf7cc1b1 00000000 00000000 00000000 3824452b 00000004 40000000 3f000000 -> bebf5e98 00000000 3a3934a8", - "be4f3cd8 bc8e4d60 3f647e1c 3400e47c b5eff9f9 34827484 38a1ec3e 00000004 40000000 3f000000 -> 3ea8d853 b6db3b82 3a9f7d49", - "bf7724d0 3e6192c0 be60f9b8 00000000 00000000 00000000 3792c3b1 00000004 40000000 3f000000 -> bd980765 00000000 39d7ae76", - "3eb97e10 bf0002d0 bf67f1e2 b4f29cd0 b6b2275a 36f4a323 397f155f 00000004 40000000 3f000000 -> bd0c3e22 b670f794 3b45c0d5", - "422201d0 c1b643a6 4000c200 38783523 b827b02c b798da04 36ff08f4 00000004 40000000 3f000000 -> 3e340876 b801bf9e 3b0ec1ca", - "c1d1ad5b c1e3382a 41fafbf4 346665f3 b6919af6 366b547b 3930eaf0 00000004 40000000 3f000000 -> bf3d83b3 3794f08e 3b9b6004", - "41e327dc 41f28cd4 c10a8f3c b50c79fb 356312f6 b583dd9b 35d792ba 00000004 40000000 3f000000 -> bf1fd62e 3753a8eb 3b0fc820", - "42045c48 414c53e8 c2084311 b8fab05b b8989b5a 37bd1150 35953e5d 00000004 40000000 3f000000 -> bf3a3f73 390b05ab 3b28550d", - "bf23adb0 3f090980 3f189854 b7999ce9 b8546635 b8c26136 3a559f3d 00000004 40000000 3f000000 -> bf3a4764 37e8e94e 3c054a90", - "41948d70 c10dae1c 40f3c610 b5b3622c b65324af 363e3ff0 385811fb 00000004 40000000 3f000000 -> be868c52 b69e2677 3ad75a6b", - "bf366356 be731154 3ddcc9a0 b6c38d75 366c447e b76da5c4 3697b5cf 00000004 40000000 3f000000 -> 3e20c7d8 b87c199e 39410c08", - "4197f990 42402090 c1d51e68 00000000 00000000 00000000 35c47ffe 00000004 40000000 3f000000 -> 3f40a8d6 00000000 3b435025", - "c245f097 c20cf86c 41fd8298 b9029a47 37944eeb b999227b 3723e207 00000004 40000000 3f000000 -> 3e3a1983 ba9de308 3b79c553", - "c23363c8 411f2c9c c2265dab 00000000 00000000 00000000 37a2c2ac 00000004 40000000 3f000000 -> bde807a5 00000000 3b542dbb", - "c20d6394 c23678d5 402ff150 b9717972 37874d62 39bd1009 378d072c 00000004 40000000 3f000000 -> bdcdfad4 b98c8268 3b3d5ddd", - "c0856e40 41c51268 408e5180 b7135728 3413e99b 3408e663 3602dd0d 00000004 40000000 3f000000 -> 3f5c0f59 37f3828e 3a96ca1e", - "be4ef964 3ec71244 3e9b1188 b93e59b1 3954847a 39d8a685 3846eb99 00000004 40000000 3f000000 -> bdff5c6c 3aece48a 3a533135", - "c1943db8 c204a252 41ebcb4c 368f9709 b6857325 35162ae0 39860849 00000004 40000000 3f000000 -> bebc9453 36ad23bb 3bb156e7", - "c1f0891f 422fdf66 c04eb6e0 b8851f40 b7cef3ad b80164a0 36b20e8b 00000004 40000000 3f000000 -> bf2cc29f b92011da 3b25577b", - "bf4f7576 3f09fe4a 3f681a80 3a0781ec b8663a5b b9015e79 3800deb2 00000004 40000000 3f000000 -> be66c4e6 39b04e1b 3a0d1dbb", - "40e66580 c233f488 c1912c76 35e0c4df b5d4005e 3663d444 39d7ee87 00000004 40000000 3f000000 -> be623c26 377a08a4 3bafd2df", - "3f6c3efe bf00c570 3cc4f180 35131e9d b5fc996e b753cbdd 383ca8da 00000004 40000000 3f000000 -> be43affb b7957f83 3a0a217f", - "be0f355c beb4c064 3ea0490c 00000000 00000000 00000000 374cfe3f 00000004 40000000 3f000000 -> bd079e71 00000000 397c5e44", - "bf11e006 bf58c11b be62c77c 36c96bbd 36360796 36b05511 3a0fd451 00000004 40000000 3f000000 -> 3e0bd010 b7f82fa7 3ba95053", - "4141d688 3fd0c200 40bf9bd0 b5b9323b b6a04234 36438d71 386eaf13 00000004 40000000 3f000000 -> 3eb30e9b 379b6cb8 3aabd806", - "bef85282 bea20c86 bf16698b b797e38f b803c3bb b71cd356 35d0b9bf 00000004 40000000 3f000000 -> bea63cce b95142cd 393f2053", - "c12a4440 c19aef27 410e7b9c 00000000 00000000 00000000 35e103c3 00000004 40000000 3f000000 -> 3d9ae607 00000000 3aac2e7d", - "3f214f36 bca54120 bf1e6058 b4da5b13 b72a9f47 36e46766 39ab5a96 00000004 40000000 3f000000 -> 3ec02a86 37f9278f 3b8889c5", - "3f1e29d6 3f0c1d76 3e3ab140 3794e381 b7ccdd57 b799db12 36f4cadc 00000004 40000000 3f000000 -> 3e9615aa b934f110 397ece3d" - ] - } - ] -} diff --git a/packages/cultmath/tests/CultMath.Tests/stryker-config.json b/packages/cultmath/tests/CultMath.Tests/stryker-config.json deleted file mode 100644 index 82c6d79c..00000000 --- a/packages/cultmath/tests/CultMath.Tests/stryker-config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "stryker-config": { - "project": "CultMath.csproj", - "mutate": [ - "**/packages/cultmath/src/CultMath/**/*.cs", - "!**/packages/cultmath/src/CultMath/Swizzles.g.cs", - "!**/packages/cultmath/src/CultMath/*.meta" - ], - "mutation-level": "Standard", - "reporters": [ "progress", "html", "json" ], - "thresholds": { "high": 80, "low": 60, "break": 0 }, - "test-runner": "mtp" - } -} diff --git a/packages/cultmath/tools/compile-glsl.ps1 b/packages/cultmath/tools/compile-glsl.ps1 deleted file mode 100644 index f43a7e8c..00000000 --- a/packages/cultmath/tools/compile-glsl.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -param( - # A GLSL source to append after the generated wrapper's library instead of the call-every-function - # body; tools\compile-glsl.ps1 -Body 'float x = lerp(0.0, 1.0, 0.5);' is the negative control. - [string]$Body = "", - # Also concatenate shaders\CultMath.Phacelle.glsl (MPL-2.0) after CultMath.glsl, as a consumer that - # calls cultmath_phacelle does. Without it the wrapper is the MIT library alone. - [switch]$Phacelle, - [string]$GlslangPath = "" -) - -$ErrorActionPreference = "Stop" - -$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") -if (-not $GlslangPath) { - $found = Get-ChildItem -LiteralPath (Join-Path $repoRoot ".tools\glslang\current") -Recurse -File -Include "glslang.exe", "glslangValidator.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 - if ($found) { $GlslangPath = $found.FullName } -} - -# The wrapper is what a WebGL2 consumer writes: its own #version line and precision, then the library -# by string concatenation (GLSL has no #include), then a fragment shader that calls every public -# function once with zero arguments of its declared types. -$library = Get-Content -LiteralPath (Join-Path $repoRoot "shaders\CultMath.glsl") -Raw -if ($Phacelle) { - $library += Get-Content -LiteralPath (Join-Path $repoRoot "shaders\CultMath.Phacelle.glsl") -Raw -} -$calls = foreach ($match in [regex]::Matches($library, '(?m)^\w+\s+(cultmath_\w+)\s*\(([^)]*)\)')) { - $arguments = foreach ($parameter in ($match.Groups[2].Value -split ',')) { - $type = ($parameter.Trim() -split '\s+')[0] - if ($type -eq 'int' -or $type -like 'ivec*') { "$type(0)" } - elseif ($type -eq 'uint' -or $type -like 'uvec*') { "$type(0u)" } - else { "$type(0.0)" } - } - " $($match.Groups[1].Value)($($arguments -join ', '));" -} -if (-not $Body) { - $Body = $calls -join "`n" -} - -$wrapper = "#version 300 es`nprecision highp float;`nprecision highp int;`n$library`nout vec4 cultmathColor;`nvoid main()`n{`n$Body`n cultmathColor = vec4(0.0);`n}`n" -$wrapperPath = Join-Path $repoRoot ".tools\glsl\cultmath-wrapper.frag" -New-Item -ItemType Directory -Force -Path (Split-Path -Parent $wrapperPath) | Out-Null -[System.IO.File]::WriteAllText($wrapperPath, $wrapper) -Write-Host "wrapper: $wrapperPath ($(@($calls).Count) functions)" - -if (-not $GlslangPath -or -not (Test-Path $GlslangPath)) { - throw "glslang not found. Run tools\get-glslang.ps1 first or pass -GlslangPath." -} - -& $GlslangPath -S frag $wrapperPath -if ($LASTEXITCODE -ne 0) { - throw "glslang failed with exit code $LASTEXITCODE." -} diff --git a/packages/cultmath/tools/compile-glsl.ps1.meta b/packages/cultmath/tools/compile-glsl.ps1.meta deleted file mode 100644 index f8a18295..00000000 --- a/packages/cultmath/tools/compile-glsl.ps1.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 81a35b09c28246fe8d52cf8996540a46 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/tools/generate-swizzles.ps1 b/packages/cultmath/tools/generate-swizzles.ps1 index e5f79011..9030f2be 100644 --- a/packages/cultmath/tools/generate-swizzles.ps1 +++ b/packages/cultmath/tools/generate-swizzles.ps1 @@ -21,19 +21,6 @@ $families = @( @{ Scalar = "bool"; Sizes = @(2, 3, 4); Functions = $true }, @{ Scalar = "double"; Sizes = @(2, 3); Functions = $false } ) -# Same-size vector conversions, as dxc lowers them: float to int is fptosi (toward zero; NaN -# and out-of-range are undefined in DXIL), int to float is sitofp, numeric to bool is `!= 0` -# (fcmp une, so NaN is true), bool to numeric is 0 or 1. Keyed "target<-source"; {0} is a -# source component. Identity forms (intN(intN), ...) come from the composition loop, which -# also keeps an int vector argument off the lossy intN(floatN) overload. -$conversions = [ordered]@{ - "float<-int" = "{0}" - "float<-bool" = "{0} ? 1.0f : 0.0f" - "int<-float" = "(int){0}" - "int<-bool" = "{0} ? 1 : 0" - "bool<-float" = "{0} != 0.0f" - "bool<-int" = "{0} != 0" -} $componentFields = @("x", "y", "z", "w") $namings = @(@("x", "y", "z", "w"), @("r", "g", "b", "a")) @@ -99,20 +86,6 @@ foreach ($family in $families) { } } - foreach ($source in @("float", "int", "bool")) { - $expression = $conversions["$scalar<-$source"] - if (-not $expression) { continue } - $converted = for ($i = 0; $i -lt $size; $i++) { $expression -f "value.$($componentFields[$i])" } - Line " public $type($source$size value) : this($($converted -join ', ')) { }" - if ($family.Functions) { - $functionLines.Add(" public static $type $type($source$size value) => new(value);") - } - } - if ($scalar -eq "float" -and $family.Functions) { - # floatN(int) splat: without it floatN(0) is ambiguous between floatN(float) and floatN(intN). - $functionLines.Add(" public static $type $type(int value) => new($((@('value') * $size) -join ', '));") - } - # Single-component color aliases; x/y/z/w are the fields themselves. $letters = $namings[1] for ($i = 0; $i -lt $size; $i++) { diff --git a/packages/cultmath/tools/get-glslang.ps1 b/packages/cultmath/tools/get-glslang.ps1 deleted file mode 100644 index e22e1095..00000000 --- a/packages/cultmath/tools/get-glslang.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -param( - [string]$InstallRoot = ".tools\glslang" -) - -$ErrorActionPreference = "Stop" - -$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") -$installPath = Join-Path $repoRoot $InstallRoot -New-Item -ItemType Directory -Force -Path $installPath | Out-Null - -# Pinned: the GLSL compile check means this front end (Khronos glslang 16.6.0). The hash is the -# SHA256 digest GitHub publishes for this asset of KhronosGroup/glslang release 16.6.0. -$zipName = "glslang-16.6.0-windows-x86_64-release.zip" -$zipUrl = "https://github.com/KhronosGroup/glslang/releases/download/16.6.0/$zipName" -$zipSha256 = "82BF434E69B9BB4829DE7E2B4BC2C5E7A7861E53D66CF75E5CC70F5F694A8D9B" - -$zipPath = Join-Path $installPath $zipName -Remove-Item -LiteralPath $zipPath -Force -ErrorAction SilentlyContinue - -& curl.exe -L --retry 5 --retry-delay 2 --fail -o $zipPath $zipUrl -if ($LASTEXITCODE -ne 0) { - throw "curl.exe failed with exit code $LASTEXITCODE." -} - -$actualSha256 = (Get-FileHash -LiteralPath $zipPath -Algorithm SHA256).Hash -if ($actualSha256 -ne $zipSha256) { - Remove-Item -LiteralPath $zipPath -Force - throw "$zipName SHA256 is $actualSha256, expected $zipSha256." -} - -$currentPath = Join-Path $installPath "current" -Remove-Item -LiteralPath $currentPath -Recurse -Force -ErrorAction SilentlyContinue -New-Item -ItemType Directory -Force -Path $currentPath | Out-Null -Expand-Archive -LiteralPath $zipPath -DestinationPath $currentPath -Force - -$glslangPath = Get-ChildItem -LiteralPath $currentPath -Recurse -File -Include "glslang.exe", "glslangValidator.exe" | Select-Object -First 1 -if (-not $glslangPath) { - throw "glslang executable was not found after extraction." -} - -& $glslangPath.FullName --version -Write-Host "glslang installed at $($glslangPath.FullName)" diff --git a/packages/cultmath/tools/get-glslang.ps1.meta b/packages/cultmath/tools/get-glslang.ps1.meta deleted file mode 100644 index e254d120..00000000 --- a/packages/cultmath/tools/get-glslang.ps1.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 37d057d5ae6847b7b4689d36514b3dc9 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md b/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md deleted file mode 100644 index 2cb099ce..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md +++ /dev/null @@ -1,119 +0,0 @@ -# Changelog - -All notable changes to this package are documented in this file. - -Earlier releases (0.2.0-0.2.3) predate this package's changelog and are not -backfilled here; see `docs/semver-policy.md` for why. - -## [0.4.0] - -### Breaking - -- `math.snoise(float3)` and `math.snoise_grad`, and their HLSL mirrors in - `Shaders/CultMath.hlsl`, now resolve ties among the components of the cell - offset in a fixed order: x over y, y over z, x over z. The cyclic rule they - used before read a different function wherever the three components of the - cell offset are equal. That is every input whose coordinate differences - `y - x` and `z - x` are whole numbers: every integer point (the origin - included), and the whole `(1, 1, 1)` line through each of them (`(t, t, t)` - among them). On that set values change by up to 0.776; for example - `snoise(0, 0, 0)` was -0.4358730 and is 0, `snoise(5, 0, 0)` was 0.7076616 and - is 0.671713, and `snoise(1, 2, 3)` was 0.22423841 and is 0. Float32 rounding - decides whether a given input ties, and an input that ties may still keep its - value; measured over random integer points, about 97% change. The cell offset - is computed in float32, so an input whose differences `y - x` and `z - x` - round, in float32, onto whole numbers can tie and change too. How far from the set that - reaches scales with the coordinates' magnitude: a few float32 ulps of the largest - coordinate (a probe over random inputs found changed inputs up to about two ulps - away; measured, not proved). Computed coordinates such as `i * 0.1f` - can land there, so near large coordinates the band is wide. Elsewhere the results are - bit-identical to 0.3.0 (`SnoiseTieScopeTests`, goldens computed by the 0.3.0 - DLL). `snoise` is now - continuous across the diagonals to within 1e-4 over two ulps either side - (`NoiseGradTests`, `SnoiseIsContinuousOnTheSimplexDiagonal`). Anything keyed - on integer lattice coordinates (voxel or tile seeds, cell centres, generated - content sampled on a whole-number grid) changes; regenerate it when you take - this version. - -### Added - -- Interval arithmetic on `float2(lo, hi)`: `math.iv_point`, `iv_add`, `iv_sub`, - `iv_mul`, `iv_neg`, `iv_scale`, `iv_abs`, `iv_min`, `iv_max`, `iv_clamp`, - `iv_saturate`, `iv_lerp`, `iv_sqr`, `iv_sqrt`, `iv_exp`, `iv_smoothstep`, - `iv_snoise_ball` (`float3` and `float2` centres), `iv_fbm_ball` and - `iv_frustum_ball`, with the HLSL mirrors in the new - `Shaders/CultMath.Interval.hlsl`. Each function is built to return an interval that - contains the pointwise float32 result for the operand intervals, but the noise - functions rest on empirical constants with a margin, not on a proof: - `iv_snoise_ball(float3)` on `SNOISE_LIPSCHITZ`, `iv_fbm_ball` on the same constant through - `iv_snoise_ball(float3)`, `iv_snoise_ball(float2)` on `SNOISE2_LIPSCHITZ`, and - `af_snoise` on `SNOISE_HESSIAN` and `SNOISE_LIPSCHITZ`, which `af_fbm` reaches through - `af_snoise`. `iv_frustum_ball` and `af_frustum_ball` read no noise constant: they are - geometry plus a 2^-20 rounding widening, and they return a ball (`float4`) to hand to a noise - call, which carries the constant. The enclosure tests sample - points and check containment without a tolerance; they do not prove it for - every input. -- Reduced affine forms on `float3(x0, a, e)` that share one symbol over a - region: `math.af_point`, `af_symbol`, `af_range`, `af_from_iv`, `af_add`, - `af_add_iv`, `af_sub`, `af_neg`, `af_scale`, `af_mul`, `af_snoise`, `af_fbm`, - `af_frustum_axis` and `af_frustum_ball`, with the HLSL mirrors in the new - `Shaders/CultMath.Affine.hlsl`. -- Noise bound constants `math.SNOISE_LIPSCHITZ`, `SNOISE2_LIPSCHITZ` and - `SNOISE_HESSIAN`: empirical bounds with a margin, re-measured and pinned by - `NoiseBoundTests`. -- `math.asfloat(uint)`, the inverse of `math.asuint`. -- `BoundedLeastSquares.Solve` overload taking `kktRelativeTolerance`, and the - constant `BoundedLeastSquares.DefaultKktRelativeTolerance` (1e-6). The - tolerance must be finite and greater than zero, else the result is - `InvalidInput`. The overload without it passes the default and returns the same - result as before. - -### Fixed - -- The NuGet package `GameCult.Math` now carries `CultMath.Affine.hlsl` under - `contentFiles/any/any/shaders`, as the README says it does. - -## [0.3.0] - -### Breaking - -- `math.snoise(float3)` and `math.snoise(float2)`, and their HLSL mirrors - `cultmath_snoise`, return different values. The kernel now follows - stegu/webgl-noise. For 3D only, the falloff `r^2` constant is 0.5 (was 0.6) - and the output scale is 105 (was 42). For 2D, the falloff constant (0.5) and - the output scale (130) are unchanged. In both, the shared permutation offset - is now +10 (was +1), which changes the values of both. This removes the value - discontinuities the 3D kernel had at simplex cell boundaries. Any content - seeded from `snoise` changes; regenerate it when you take this version. - -### Added - -- `math.smin_grad`: smooth minimum with gradient, for `float4` operands - carrying the gradient in `xyz` and the value in `w`. -- `math.cellular` and the `CultCellular` result struct: cellular (Worley) - noise returning the gradient and distance to the nearest feature points. -- `math.snoise_grad`, `math.fbm_grad` and `math.ridged_grad`: simplex noise, - fractal Brownian motion and ridged multifractal with analytic gradients, - returned as `float4` with the gradient in `xyz` and the value in `w`. -- `math.phacelle` and the `CultPhasor` result struct: Phacelle noise with - gradient. `math.Phacelle.cs`, `CultPhasor.cs` and - `Shaders/CultMath.Phacelle.hlsl` are MPL-2.0 (see - `THIRD-PARTY-NOTICES.md`). -- `BoundedLeastSquares`: an allocation-free, deterministic bounded - least-squares solver (`Solve`) with a status result and the input contract - documented on the type. -- The matching `cultmath_*` HLSL mirrors of the functions above in - `Shaders/CultMath.hlsl` and `Shaders/CultMath.Phacelle.hlsl`. - -## [0.2.4] - -### Added - -- `math.erf` and `math.erfinv`: single-precision error function and its - inverse. `erf` is the Abramowitz & Stegun 7.1.26 rational/exponential fit - (max absolute error 1.5e-7 by that source, 6.621e-7 measured here against - an independent reference). `erfinv` is Giles' minimax polynomial - ("Approximating the erfinv function", GPU Computing Gems, 2010), guarded - explicitly at the domain edges (`erfinv(1) = +Infinity`, - `erfinv(-1) = -Infinity`, outside `[-1, 1]` is `NaN`); measured worst - absolute error 5.066e-7, worst `erf(erfinv(y))` round trip 6.109e-7. diff --git a/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md.meta b/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md.meta deleted file mode 100644 index 8a5177b2..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/CHANGELOG.md.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 0a6d25c5f7894c0d8e83f2b9d69358a4 \ No newline at end of file diff --git a/packages/cultmath/unity/org.gamecult.cultmath/LICENSE.md b/packages/cultmath/unity/org.gamecult.cultmath/LICENSE.md index e31bf344..5e50f2d6 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/LICENSE.md +++ b/packages/cultmath/unity/org.gamecult.cultmath/LICENSE.md @@ -1,19 +1,10 @@ # CultMath License -CultMath is licensed under the MIT License (`MIT`), except for the Phacelle -files, which are licensed under the Mozilla Public License 2.0 (`MPL-2.0`): +CultMath is licensed under the Mozilla Public License 2.0 (`MPL-2.0`). -- `Shaders/CultMath.Phacelle.hlsl` -- the Phacelle sources compiled into `Runtime/Plugins/CultMath.dll` - (`math.Phacelle.cs` and `CultPhasor.cs` in the GameCult/CultLib repository) - -The package license expression is therefore `MIT AND MPL-2.0`, matching the -`GameCult.Math` NuGet package. MPL-2.0 is file-level: it applies to those files -and not to the rest of CultMath. - -The MPL-2.0 text is available from the Mozilla Foundation at +The complete license text is available from the Mozilla Foundation at . Source and modification history for the -precompiled assembly in this package are available in the GameCult/CultLib -repository (`packages/cultmath`) at the corresponding package tag. +precompiled assembly in this package are available in the GameCult/CultMath +repository at the corresponding package tag. Third-party code retains its original license. See `THIRD-PARTY-NOTICES.md`. diff --git a/packages/cultmath/unity/org.gamecult.cultmath/README.md b/packages/cultmath/unity/org.gamecult.cultmath/README.md index 4981c54c..20e1840c 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/README.md +++ b/packages/cultmath/unity/org.gamecult.cultmath/README.md @@ -2,7 +2,7 @@ This is CultMath's Unity 2021.3-compatible Git-UPM surface. It contains the precompiled `CultMath.dll`, portable symbols, the numeric -`Shaders/CultMath.hlsl` mirror (with its `CultMath.Phacelle.hlsl` include), and the `CultMath.UnityBridge` assembly. +`Shaders/CultMath.hlsl` mirror, and the `CultMath.UnityBridge` assembly. `CultMath.UnityBridge` is the only C# source Unity compiles here. It holds the UnityEngine conversions the engine-free core cannot declare: `ToCultMath()` on diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.dll b/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.dll index 9e3501f2..bf712012 100644 Binary files a/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.dll and b/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.dll differ diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.pdb b/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.pdb index 6312e80e..1eaadd23 100644 Binary files a/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.pdb and b/packages/cultmath/unity/org.gamecult.cultmath/Runtime/Plugins/CultMath.pdb differ diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl deleted file mode 100644 index f165148b..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef CULTMATH_AFFINE_HLSL -#define CULTMATH_AFFINE_HLSL - -// Reduced affine forms with one shared symbol over float3(x0, a, e): the set { x0 + a eps + e delta : -// delta in [-1, 1] } at the region's shared eps in [-1, 1], e >= 0. Every cultmath_af_* function mirrors -// math.Affine.cs bit for bit; see that file and docs/design.md ("Affine forms") for each op's enclosure -// and the float32 rounding allowance it folds into e. Included by CultMath.hlsl after -// CultMath.Interval.hlsl, whose CULTMATH_SNOISE_LIPSCHITZ it shares, and after its own -// definition of cultmath_snoise_grad. - -// An upper bound on the spectral norm of the Hessian of cultmath_snoise(float3); provenance in -// math.Affine.cs (SNOISE_HESSIAN). -static const float CULTMATH_SNOISE_HESSIAN = 56.050385; - -float3 cultmath_af_point(float value) { return float3(value, 0.0, 0.0); } -float3 cultmath_af_symbol(float x0, float a) { return float3(x0, a, 0.0); } - -float3 cultmath_af_from_iv(float2 interval) -{ - float x0 = interval.x * 0.5 + interval.y * 0.5; - float e = interval.y * 0.5 - interval.x * 0.5; - return float3(x0, 0.0, e + (abs(x0) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// An endpoint that would be NaN is the infinity on its side. NaN is found by its bit pattern: dxc marks -// compares fast, so a test that needs NaN to make `lo == lo` false is deleted under its default flags. -float2 cultmath_af_range(float3 x) -{ - float r = abs(x.y) + x.z; - float w = abs(x.x) * 9.5367431640625e-7 + r * 9.5367431640625e-7; - float lo = x.x - r - w; - float hi = x.x + r + w; - return float2((asuint(lo) & 0x7fffffffu) > 0x7f800000u ? asfloat(0xff800000u) : lo, - (asuint(hi) & 0x7fffffffu) > 0x7f800000u ? asfloat(0x7f800000u) : hi); -} - -float3 cultmath_af_add(float3 x, float3 y) -{ - float x0 = x.x + y.x; - float a = x.y + y.y; - float e = x.z + y.z; - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -float3 cultmath_af_sub(float3 x, float3 y) -{ - float x0 = x.x - y.x; - float a = x.y - y.y; - float e = x.z + y.z; - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7); -} - -float3 cultmath_af_neg(float3 x) { return float3(-x.x, -x.y, x.z); } - -float3 cultmath_af_scale(float3 x, float s) -{ - float x0 = x.x * s; - float a = x.y * s; - float e = x.z * abs(s); - return float3(x0, a, e + (abs(x0) + abs(a) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -float3 cultmath_af_add_iv(float3 x, float2 interval) { return cultmath_af_add(x, cultmath_af_from_iv(interval)); } - -float3 cultmath_af_mul(float3 x, float3 y) -{ - float x0 = x.x * y.x; - float p = x.x * y.y; - float q = y.x * x.y; - float a = p + q; - float e = abs(x.x) * y.z + abs(y.x) * x.z + (abs(x.y) + x.z) * (abs(y.y) + y.z); - return float3(x0, a, e + (abs(x0) + abs(p) + abs(q) + e) * 9.5367431640625e-7 + 1.17549435e-38); -} - -// The narrower of the Lipschitz form and the centred (Taylor) form over every p = centre + axis eps + w, -// |w| <= radius, from one cultmath_snoise_grad at the centre; the allowance for the float32 evaluation is -// in math.Affine.cs. -float3 cultmath_af_snoise(float3 centre, float3 axis, float radius) -{ - float4 g = cultmath_snoise_grad(centre); - float3 gradient = float3(g.x, g.y, g.z); - float reach = length(axis) + radius; - float lipschitz = CULTMATH_SNOISE_LIPSCHITZ * reach; - float a = dot(gradient, axis); - float remainder = length(gradient) * radius + 0.5 * CULTMATH_SNOISE_HESSIAN * reach * reach; - float allowance = 6.103515625e-5 + 2.44140625e-4 * reach - + CULTMATH_SNOISE_LIPSCHITZ * 9.5367431640625e-7 * (abs(centre.x) + abs(centre.y) + abs(centre.z) + reach); - bool centred = abs(a) + remainder < lipschitz; - float slope = centred ? a : 0.0; - float e = (centred ? remainder : lipschitz) + allowance; - return float3(g.w, slope, e + (abs(g.w) + abs(slope) + e) * 9.5367431640625e-7); -} - -// Octave sum of cultmath_af_snoise, compounding frequency and amplitude as the value-and-gradient fBm does. -float3 cultmath_af_fbm(float3 centre, float3 axis, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float3 sum = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_af_add(sum, cultmath_af_scale(cultmath_af_snoise(centre * frequency, axis * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// The axis of a screen tile's slice over the depth segment [z0, z1]; camera frame of -// cultmath_iv_frustum_ball. -float3 cultmath_af_frustum_axis(float2 centreSlope, float z0, float z1) -{ - float h = (z1 - z0) * 0.5; - return float3(centreSlope.x * h, centreSlope.y * h, h); -} - -// The affine slice of a screen tile over [z0, z1]: centre xyz, radius w. Derivation in math.Affine.cs. -float4 cultmath_af_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warpVariation) -{ - float zm = (z0 + z1) * 0.5; - float h = (z1 - z0) * 0.5; - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float spread = (abs(centreSlope.x) + abs(centreSlope.y) + 1.0) * h; - float radius = z1 * footprintPerDepth + warpVariation; - radius += (abs(cx) + abs(cy) + abs(zm) + spread + radius) * 9.5367431640625e-7; - return float4(cx, cy, zm, radius); -} - -#endif diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl.meta b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl.meta deleted file mode 100644 index 9cf91737..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Affine.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5dbcf0fdd66a4a74b22f5ca1c8e33058 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl deleted file mode 100644 index bc084ace..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef CULTMATH_INTERVAL_HLSL -#define CULTMATH_INTERVAL_HLSL - -// Interval arithmetic over float2(lo, hi), lo <= hi, both finite. Every cultmath_iv_* function returns -// an interval containing f(x) for every x in its input intervals, mirroring math.Interval.cs bit for -// bit; see that file and docs/design.md ("Intervals") for each op's enclosure and its ulp widening. -// Included by CultMath.hlsl after its own definitions of cultmath_smoothstep and cultmath_snoise. - -// Lipschitz constant of cultmath_snoise(float3); provenance in math.Interval.cs (SNOISE_LIPSCHITZ). -static const float CULTMATH_SNOISE_LIPSCHITZ = 7.9640074; - -// Lipschitz constant of cultmath_snoise(float2); provenance in math.Interval.cs (SNOISE2_LIPSCHITZ). -static const float CULTMATH_SNOISE2_LIPSCHITZ = 8.117002; - -float2 cultmath_iv_point(float value) { return float2(value, value); } -float2 cultmath_iv_add(float2 a, float2 b) { return float2(a.x + b.x, a.y + b.y); } -float2 cultmath_iv_sub(float2 a, float2 b) { return float2(a.x - b.y, a.y - b.x); } -float2 cultmath_iv_neg(float2 a) { return float2(-a.y, -a.x); } - -float2 cultmath_iv_mul(float2 a, float2 b) -{ - float p0 = a.x * b.x; - float p1 = a.x * b.y; - float p2 = a.y * b.x; - float p3 = a.y * b.y; - return float2(min(min(p0, p1), min(p2, p3)), max(max(p0, p1), max(p2, p3))); -} - -float2 cultmath_iv_scale(float2 a, float s) { return s >= 0.0 ? float2(a.x * s, a.y * s) : float2(a.y * s, a.x * s); } - -float2 cultmath_iv_abs(float2 a) -{ - if (a.x >= 0.0) - return a; - if (a.y <= 0.0) - return float2(-a.y, -a.x); - return float2(0.0, max(-a.x, a.y)); -} - -float2 cultmath_iv_min(float2 a, float2 b) { return float2(min(a.x, b.x), min(a.y, b.y)); } -float2 cultmath_iv_max(float2 a, float2 b) { return float2(max(a.x, b.x), max(a.y, b.y)); } - -float2 cultmath_iv_sqr(float2 a) -{ - float l = a.x * a.x; - float h = a.y * a.y; - if (a.x >= 0.0) - return float2(l, h); - if (a.y <= 0.0) - return float2(h, l); - return float2(0.0, max(l, h)); -} - -float2 cultmath_iv_sqrt(float2 a) { return float2(sqrt(max(a.x, 0.0)), sqrt(max(a.y, 0.0))); } - -// Widened by one ulp on each side: exp is not required to be correctly rounded. -float2 cultmath_iv_exp(float2 a) -{ - float lo = exp(a.x); - float hi = exp(a.y); - return float2(lo > 0.0 ? asfloat(asuint(lo) - 1u) : 0.0, asfloat(asuint(hi) + 1u)); -} - -float2 cultmath_iv_clamp(float2 a, float minimum, float maximum) -{ - return float2(cultmath_clamp(a.x, minimum, maximum), cultmath_clamp(a.y, minimum, maximum)); -} - -float2 cultmath_iv_saturate(float2 a) { return float2(cultmath_saturate(a.x), cultmath_saturate(a.y)); } - -// The endpoints, ordered, widened by one ulp inside [0, 1]: the float32 evaluation of smoothstep is -// monotone only to within one ulp. -float2 cultmath_iv_smoothstep(float minimum, float maximum, float2 a) -{ - float s0 = cultmath_smoothstep(minimum, maximum, a.x); - float s1 = cultmath_smoothstep(minimum, maximum, a.y); - float lo = min(s0, s1); - float hi = max(s0, s1); - return float2(lo > 0.0 ? asfloat(asuint(lo) - 1u) : 0.0, hi < 1.0 ? asfloat(asuint(hi) + 1u) : 1.0); -} - -// The natural interval extension of x + (y - x) * amount, which is how cultmath_lerp evaluates. -float2 cultmath_iv_lerp(float2 a, float2 b, float amount) { return cultmath_iv_add(a, cultmath_iv_scale(cultmath_iv_sub(b, a), amount)); } - -// [n - L r, n + L r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -float2 cultmath_iv_snoise_ball(float3 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE_LIPSCHITZ * radius; - return float2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// The 2D overload: [n - L2 r, n + L2 r] intersected with [-1, 1], n = cultmath_snoise(centre). One snoise, value only. -float2 cultmath_iv_snoise_ball(float2 centre, float radius) -{ - float n = cultmath_snoise(centre); - float e = CULTMATH_SNOISE2_LIPSCHITZ * radius; - return float2(max(n - e, -1.0), min(n + e, 1.0)); -} - -// Octave sum of cultmath_iv_snoise_ball, compounding frequency and amplitude as the value-and-gradient fBm does. -float2 cultmath_iv_fbm_ball(float3 centre, float radius, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float2 sum = float2(0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - sum = cultmath_iv_add(sum, cultmath_iv_scale(cultmath_iv_snoise_ball(centre * frequency, radius * abs(frequency)), amplitude)); - frequency *= lacunarity; - amplitude *= gain; - } - - return sum; -} - -// A ball (xyz centre, w radius) enclosing every point of every ray of a screen tile over the depth segment -// [z0, z1], warped by at most warp. Camera frame: pinhole at the origin looking down +z, ray (m z, z). -// footprintPerDepth = N / (sqrt(2) f) for an N x N tile at focal length f. The radius is widened by -// (|c|_1 + radius) 2^-20, which covers the ball's own float32 rounding. Derivation in math.Interval.cs. -float4 cultmath_iv_frustum_ball(float2 centreSlope, float z0, float z1, float footprintPerDepth, float warp) -{ - float zm = (z0 + z1) * 0.5; - float axis = sqrt(centreSlope.x * centreSlope.x + centreSlope.y * centreSlope.y + 1.0); - float cx = centreSlope.x * zm; - float cy = centreSlope.y * zm; - float radius = (z1 - z0) * 0.5 * axis + z1 * footprintPerDepth + warp; - radius += (abs(cx) + abs(cy) + abs(zm) + radius) * 9.5367431640625e-7; - return float4(cx, cy, zm, radius); -} - -#endif diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl.meta b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl.meta deleted file mode 100644 index 023d218c..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Interval.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 18b031192f344246ac523cea014b8f24 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl deleted file mode 100644 index c95aafc6..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef CULTMATH_PHACELLE_HLSL -#define CULTMATH_PHACELLE_HLSL - -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of -// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Phacelle noise. Copyright (c) 2025 Rune Skovbo Johansen (Shadertoy t3dyWl; MPL-2.0), read from the -// C# port PhacelleNoise in lpmitchell/AdvancedTerrainErosion, converted to burstable C# by Luke -// Mitchell (2026). Modified by GameCult: 3D cells, a caller-supplied stripe wave vector, an exact -// gradient and exact pruning. This file is an MPL-2.0 file; CultMath.hlsl, which includes it after -// its own definitions of CULTMATH_TAU and cultmath_pcg3d, is MIT (see THIRD-PARTY-NOTICES.md). - -// Invariant 8's struct return shape for cultmath_phacelle, compared field by field and bit for bit -// against CultMath.CultPhasor, same field order. -struct CultPhasor -{ - float4 cos; - float4 sin; -}; - -// Johansen's Phacelle noise on 3D cells. See math.phacelle's comment (math.Phacelle.cs) for the stripe wave -// vector, the weight, the normalization, the exact gradient and why the prune is exact. Mirrors -// the C# body operation for operation; the C#-only internal overload that switches the prune off -// has no shader twin. -CultPhasor cultmath_phacelle(float3 p, float3 side, float offset, float normalization) -{ - float3 cell = floor(p); - float3 local = p - cell; - float phaseOffset = offset * CULTMATH_TAU; - float sumW = 0.0; - float sumCos = 0.0; - float sumSin = 0.0; - float3 gradW = float3(0.0, 0.0, 0.0); - float3 gradCos = float3(0.0, 0.0, 0.0); - float3 gradSin = float3(0.0, 0.0, 0.0); - - for (int dz = -1; dz <= 2; dz++) - { - float gz = max(0.0, abs(local.z - (float)dz) - 0.5); - for (int dy = -1; dy <= 2; dy++) - { - float gy = max(0.0, abs(local.y - (float)dy) - 0.5); - for (int dx = -1; dx <= 2; dx++) - { - float gx = max(0.0, abs(local.x - (float)dx) - 0.5); - if (gx * gx + gy * gy + gz * gz >= 2.25) - continue; - - float3 gridStep = float3(dx, dy, dz); - int3 hash = cultmath_pcg3d(int3(cell + gridStep)); - float3 jitter = float3( - (float)((uint)hash.x >> 8) * (1.0 / 16777216.0) - 0.5, - (float)((uint)hash.y >> 8) * (1.0 / 16777216.0) - 0.5, - (float)((uint)hash.z >> 8) * (1.0 / 16777216.0) - 0.5); - float3 v = local - gridStep - jitter; - float falloff = exp(-2.0 * dot(v, v)); - float w = max(0.0, falloff - 0.01111); - float3 dw = w > 0.0 ? (-4.0 * falloff) * v : float3(0.0, 0.0, 0.0); - float phase = dot(v, side) + phaseOffset; - float c = cos(phase); - float s = sin(phase); - - sumW += w; - sumCos += w * c; - sumSin += w * s; - gradW += dw; - gradCos += dw * c - (w * s) * side; - gradSin += dw * s + (w * c) * side; - } - } - } - - float invW = 1.0 / sumW; - float rawCos = sumCos * invW; - float rawSin = sumSin * invW; - float3 gradRawCos = (gradCos - rawCos * gradW) * invW; - float3 gradRawSin = (gradSin - rawSin * gradW) * invW; - float rawLength = sqrt(rawCos * rawCos + rawSin * rawSin); - float floorLength = 1.0 - normalization; - - CultPhasor result; - if (rawLength > floorLength) - { - float outCos = rawCos / rawLength; - float outSin = rawSin / rawLength; - float3 gradLength = (rawCos * gradRawCos + rawSin * gradRawSin) / rawLength; - result.cos = float4((gradRawCos - outCos * gradLength) / rawLength, outCos); - result.sin = float4((gradRawSin - outSin * gradLength) / rawLength, outSin); - } - else - { - result.cos = float4(gradRawCos / floorLength, rawCos / floorLength); - result.sin = float4(gradRawSin / floorLength, rawSin / floorLength); - } - - return result; -} - -#endif diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl.meta b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl.meta deleted file mode 100644 index 9c074cb5..00000000 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Phacelle.hlsl.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5b1c7e0a94d24f6c8a3e2d17f60b9c48 -ShaderIncludeImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.hlsl index 6856a000..365705f5 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.hlsl +++ b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.hlsl @@ -11,6 +11,7 @@ static const float CULTMATH_PI = 3.14159265358979323846; static const float CULTMATH_TAU = 6.28318530717958647692; static const float CULTMATH_HALF_PI = 1.57079632679489661923; +static const float CULTMATH_NORMALIZE_EPSILON = 1.0e-20; float cultmath_radians(float degrees_value) { return degrees_value * (CULTMATH_PI / 180.0); } float cultmath_degrees(float radians_value) { return radians_value * (180.0 / CULTMATH_PI); } @@ -76,18 +77,17 @@ float cultmath_smootherstep(float value) float2 cultmath_snoise_mod289(float2 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } float3 cultmath_snoise_mod289(float3 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } float4 cultmath_snoise_mod289(float4 value) { return value - floor(value * (1.0 / 289.0)) * 289.0; } -float3 cultmath_snoise_permute(float3 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } -float4 cultmath_snoise_permute(float4 value) { return cultmath_snoise_mod289(((value * 34.0) + 10.0) * value); } +float3 cultmath_snoise_permute(float3 value) { return cultmath_snoise_mod289(((value * 34.0) + 1.0) * value); } +float4 cultmath_snoise_permute(float4 value) { return cultmath_snoise_mod289(((value * 34.0) + 1.0) * value); } // Ashima Arts / Ian McEwan 3D simplex noise (MIT), same float32 evaluation -// order as the C# math.snoise(float3) mirror. Ties resolve in simplexnoise1234's -// total order; see math.snoise. +// order as the C# math.snoise(float3) mirror. float cultmath_snoise(float3 value) { float2 c = float2(1.0 / 6.0, 1.0 / 3.0); float3 i = floor(value + dot(value, c.yyy)); float3 x0 = value - i + dot(i, c.xxx); - float3 g = float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); + float3 g = step(x0.yzx, x0.xyz); float3 l = 1.0 - g; float3 i1 = min(g.xyz, l.zxy); float3 i2 = max(g.xyz, l.zxy); @@ -112,7 +112,7 @@ float cultmath_snoise(float3 value) float4 b1 = float4(x.zw, y.zw); float4 s0 = floor(b0) * 2.0 + 1.0; float4 s1 = floor(b1) * 2.0 + 1.0; - float4 sh = -step(h, float4(0.0, 0.0, 0.0, 0.0)); + float4 sh = -step(h, 0.0); float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; @@ -126,9 +126,9 @@ float cultmath_snoise(float3 value) p2 *= norm.z; p3 *= norm.w; - float4 m = max(0.5 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); + float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); m = m * m; - return 105.0 * dot(m * m, float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); + return 42.0 * dot(m * m, float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); } float cultmath_snoise(float2 value) @@ -163,114 +163,6 @@ float cultmath_snoise(float2 value) return 130.0 * dot(m, g); } -// Analytic gradient of cultmath_snoise(float3) (invariant 8), following webgl-noise -// src/noise3Dgrad.glsl (Ashima Arts / McEwan, MIT); same kernel, permutation and scale as -// cultmath_snoise(float3) (stegu/webgl-noise 22434e04d7). See the C# math.snoise_grad comment for the -// derivation. Every local up through p0..p3 and x0..x3 is cultmath_snoise(float3)'s own derivation -// verbatim. -float4 cultmath_snoise_grad(float3 value) -{ - float2 c = float2(1.0 / 6.0, 1.0 / 3.0); - float3 i = floor(value + dot(value, c.yyy)); - float3 x0 = value - i + dot(i, c.xxx); - float3 g = float3(step(x0.y, x0.x), step(x0.z, x0.y), 1.0 - step(x0.z, x0.x)); - float3 l = 1.0 - g; - float3 i1 = min(g.xyz, l.zxy); - float3 i2 = max(g.xyz, l.zxy); - float3 x1 = x0 - i1 + c.xxx; - float3 x2 = x0 - i2 + c.yyy; - float3 x3 = x0 - 0.5; - - i = cultmath_snoise_mod289(i); - float4 p = cultmath_snoise_permute(cultmath_snoise_permute(cultmath_snoise_permute( - i.z + float4(0.0, i1.z, i2.z, 1.0)) + i.y + float4(0.0, i1.y, i2.y, 1.0)) + i.x + float4(0.0, i1.x, i2.x, 1.0)); - - const float n_ = 0.142857142857; - float3 ns = float3(2.0 * n_, 0.5 * n_ - 1.0, n_); - float4 j = p - 49.0 * floor(p * ns.z * ns.z); - float4 x_ = floor(j * ns.z); - float4 y_ = floor(j - 7.0 * x_); - float4 x = x_ * ns.x + ns.yyyy; - float4 y = y_ * ns.x + ns.yyyy; - float4 h = 1.0 - abs(x) - abs(y); - - float4 b0 = float4(x.xy, y.xy); - float4 b1 = float4(x.zw, y.zw); - float4 s0 = floor(b0) * 2.0 + 1.0; - float4 s1 = floor(b1) * 2.0 + 1.0; - float4 sh = -step(h, float4(0.0, 0.0, 0.0, 0.0)); - float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; - float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; - - float3 p0 = float3(a0.xy, h.x); - float3 p1 = float3(a0.zw, h.y); - float3 p2 = float3(a1.xy, h.z); - float3 p3 = float3(a1.zw, h.w); - float4 norm = 1.79284291400159 - 0.85373472095314 * float4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - float4 m0 = max(0.5 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); - float4 m2 = m0 * m0; - float4 m3 = m2 * m0; - float4 m4 = m2 * m2; - - float4 px = float4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)); - float value2 = 105.0 * dot(m4, px); - float3 grad = -8.0 * m3.x * x0 * px.x + m4.x * p0 - + -8.0 * m3.y * x1 * px.y + m4.y * p1 - + -8.0 * m3.z * x2 * px.z + m4.z * p2 - + -8.0 * m3.w * x3 * px.w + m4.w * p3; - grad *= 105.0; - - return float4(grad, value2); -} - -// Octave sum of cultmath_snoise_grad (invariant 8); see the C# math.fbm_grad comment for the -// per-octave frequency/amplitude derivation and why octaves is clamped. -float4 cultmath_fbm_grad(float3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - float3 gradient = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - float4 n = cultmath_snoise_grad(p * frequency); - value += amplitude * n.w; - gradient += amplitude * frequency * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return float4(gradient, value); -} - -// Ridged multifractal noise (Musgrave, Texturing and Modeling, ch. 16); see the C# math.ridged_grad -// comment for the fold/sign derivation, the deliberate crease at n = 0, and why octaves is clamped. -float4 cultmath_ridged_grad(float3 p, int octaves, float lacunarity, float gain) -{ - octaves = clamp(octaves, 0, 16); - float amplitude = 1.0; - float frequency = 1.0; - float value = 0.0; - float3 gradient = float3(0.0, 0.0, 0.0); - for (int i = 0; i < octaves; i++) - { - float4 n = cultmath_snoise_grad(p * frequency); - float s = sign(n.w); - value += amplitude * (1.0 - abs(n.w)); - gradient += -amplitude * frequency * s * n.xyz; - frequency *= lacunarity; - amplitude *= gain; - } - - return float4(gradient, value); -} - float cultmath_lengthsq(float2 value) { return dot(value, value); } float cultmath_lengthsq(float3 value) { return dot(value, value); } float cultmath_lengthsq(float4 value) { return dot(value, value); } @@ -279,6 +171,10 @@ float cultmath_distance(float2 left, float2 right) { return length(left - right) float cultmath_distance(float3 left, float3 right) { return length(left - right); } float cultmath_distance(float4 left, float4 right) { return length(left - right); } +float2 cultmath_normalize(float2 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } +float3 cultmath_normalize(float3 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } +float4 cultmath_normalize(float4 value) { return value / max(length(value), CULTMATH_NORMALIZE_EPSILON); } + float2 cultmath_reflect(float2 incident, float2 normal_value) { return incident - 2.0 * dot(normal_value, incident) * normal_value; @@ -317,20 +213,17 @@ float cultmath_damp(float start, float end, float lambda_value, float dt) float2 cultmath_damp(float2 start, float2 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float2(amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float3 cultmath_damp(float3 start, float3 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float3(amount, amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float4 cultmath_damp(float4 start, float4 end, float lambda_value, float dt) { - float amount = 1.0 - exp(-lambda_value * dt); - return cultmath_lerp(start, end, float4(amount, amount, amount, amount)); + return cultmath_lerp(start, end, 1.0 - exp(-lambda_value * dt)); } float cultmath_catmullrom(float p0, float p1, float p2, float p3, float t) @@ -393,124 +286,6 @@ float cultmath_hash(float value) { return cultmath_frac(sin(value) * 43758.5453) float cultmath_hash(float2 value) { return cultmath_hash(dot(value, float2(127.1, 311.7))); } float cultmath_hash(float3 value) { return cultmath_hash(dot(value, float3(127.1, 311.7, 74.7))); } -// PCG hashes (Jarzynski and Olano, JCGT 2020), written over scalar uints so CultMath's int3/int4 carry the bits. -uint cultmath_pcg(uint value) -{ - uint state = value * 747796405u + 2891336453u; - uint word = ((state >> (int)((state >> 28) + 4u)) ^ state) * 277803737u; - return (word >> 22) ^ word; -} - -int3 cultmath_pcg3d(int3 value) -{ - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u, z = (uint)value.z * 1664525u + 1013904223u; - x += y * z; y += z * x; z += x * y; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; - x += y * z; y += z * x; z += x * y; - return int3((int)x, (int)y, (int)z); -} - -int3 cultmath_pcg3d(float3 value) { return cultmath_pcg3d(int3((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z))); } -int3 cultmath_pcg3d(float2 value) { return cultmath_pcg3d(float3(value, 0.0)); } - -int4 cultmath_pcg4d(int4 value) -{ - uint x = (uint)value.x * 1664525u + 1013904223u, y = (uint)value.y * 1664525u + 1013904223u; - uint z = (uint)value.z * 1664525u + 1013904223u, w = (uint)value.w * 1664525u + 1013904223u; - x += y * w; y += z * x; z += x * y; w += y * z; - x ^= x >> 16; y ^= y >> 16; z ^= z >> 16; w ^= w >> 16; - x += y * w; y += z * x; z += x * y; w += y * z; - return int4((int)x, (int)y, (int)z, (int)w); -} - -int4 cultmath_pcg4d(float4 value) { return cultmath_pcg4d(int4((int)asuint(value.x), (int)asuint(value.y), (int)asuint(value.z), (int)asuint(value.w))); } - -// Inigo Quilez, "smooth minimum": quadratic-polynomial smin carried to value-and-gradient form. See -// math.smin_grad's comment (math.cs) for why the gradient blend is exact, not an approximation. -float4 cultmath_smin_grad(float4 a, float4 b, float k) -{ - float h = saturate(0.5 + 0.5 * (b.w - a.w) / k); - float value = lerp(b.w, a.w, h) - k * h * (1.0 - h); - float3 gradient = lerp(b.xyz, a.xyz, h); - return float4(gradient, value); -} - -// Invariant 8's one struct return shape (design.md, "HLSL Target: Source Transformations"): -// compared field by field and bit for bit against CultMath.CultCellular, same field order. -struct CultCellular -{ - float4 nearest; - float4 edge; - float id; -}; - -// Worley, "A Cellular Texture Basis Function" (SIGGRAPH 1996). See math.cellular's comment -// (math.cs) for the hashing, gradient, search-radius exactness proof, id source and -// degenerate-point conventions this mirrors exactly, including the 5x5x5 lower-bound prune. -CultCellular cultmath_cellular(float3 p) -{ - float3 cell = floor(p); - float f1 = 1.0e30; - float f2 = 1.0e30; - float3 c1 = float3(0.0, 0.0, 0.0); - float3 c2 = float3(0.0, 0.0, 0.0); - float3 cellId = float3(0.0, 0.0, 0.0); - - for (int dz = -2; dz <= 2; dz++) - { - float lz = max(0.0, abs((float)dz) - 1.0); - for (int dy = -2; dy <= 2; dy++) - { - float ly = max(0.0, abs((float)dy) - 1.0); - for (int dx = -2; dx <= 2; dx++) - { - float lx = max(0.0, abs((float)dx) - 1.0); - float lowerBound = sqrt(lx * lx + ly * ly + lz * lz); - if (lowerBound >= f2) - continue; - - float3 neighbor = cell + float3(dx, dy, dz); - int3 hash = cultmath_pcg3d(int3(neighbor)); - float3 jitter = float3( - (float)((uint)hash.x >> 8) * (1.0 / 16777216.0), - (float)((uint)hash.y >> 8) * (1.0 / 16777216.0), - (float)((uint)hash.z >> 8) * (1.0 / 16777216.0)); - float3 feature = neighbor + jitter; - float d = cultmath_distance(p, feature); - - if (d < f1) - { - f2 = f1; c2 = c1; - f1 = d; c1 = feature; cellId = neighbor; - } - else if (d < f2) - { - f2 = d; c2 = feature; - } - } - } - } - - // F1 = 0 and F2 = 0 share the same degenerate-gradient guard; see math.cellular's comment - // (math.cs) for why F2 = 0 is reachable past roughly |p| = 2^23. - float3 grad1 = f1 > 0.0 ? (p - c1) / f1 : float3(0.0, 0.0, 0.0); - float3 grad2 = f2 > 0.0 ? (p - c2) / f2 : float3(0.0, 0.0, 0.0); - - // id comes from pcg4d over the winning cell's integer coordinate alone (same int-hashing rule - // as the jitter above), never from the pcg3d hash that produced its jitter (F4). - int4 idHash = cultmath_pcg4d(int4(int3(cellId), 0)); - - CultCellular result; - result.nearest = float4(grad1, f1); - result.edge = float4(grad2 - grad1, f2 - f1); - result.id = (float)((uint)idHash.w >> 8) * (1.0 / 16777216.0); - return result; -} - -#include "CultMath.Phacelle.hlsl" -#include "CultMath.Interval.hlsl" -#include "CultMath.Affine.hlsl" - float cultmath_value_noise(float2 position) { float2 cell = floor(position); diff --git a/packages/cultmath/unity/org.gamecult.cultmath/THIRD-PARTY-NOTICES.md b/packages/cultmath/unity/org.gamecult.cultmath/THIRD-PARTY-NOTICES.md index f7e22fd0..06ebb6c3 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/THIRD-PARTY-NOTICES.md +++ b/packages/cultmath/unity/org.gamecult.cultmath/THIRD-PARTY-NOTICES.md @@ -6,38 +6,6 @@ simplex-noise functions by Ian McEwan and Ashima Arts, as distributed by Stefan Gustavson's `webgl-noise` project and Unity Mathematics. -`math.snoise(float3)` and `cultmath_snoise(float3)` follow `src/noise3D.glsl` and -`math.snoise(float2)` follows `src/noise2D.glsl` of stegu/webgl-noise at commit -`22434e04d7753f7e949e8d724ab3da2864c17a0f` (the simplex-boundary fix is -`21d9fe23d7`, scale `ff3b5d34ea`, permutation `a3e6d57095`). Modified from upstream: -the 3D corner tie order follows Gustavson's `simplexnoise1234`, because the -upstream `step` compares are cyclic where the offset's components are equal. - -`math.snoise_grad`/`cultmath_snoise_grad` (and the `fbm_grad`/`ridged_grad` -octave sums built on them) follow the analytic-gradient differentiation from -the same project's `src/noise3Dgrad.glsl`, with the same kernel radius, -permutation and scale as `snoise(float3)`. - - Copyright 2011 Ashima Arts. - Upstream: - License: MIT. - -## Phacelle Noise - -`math.phacelle` and `cultmath_phacelle` follow Rune Skovbo Johansen's Phacelle -noise (Shadertoy `t3dyWl`; erosion filter `wXcfWn`; blog, March 2026), read -from the C# port `PhacelleNoise` in `lpmitchell/AdvancedTerrainErosion` -(`AdvancedTerrainErosion.cs`, converted to burstable C# by Luke Mitchell, -2026). The cell weight, the phase blend and the normalization follow it. The -3D-cell generalisation, the caller-supplied stripe wave vector, the exact -gradient and the exact pruning are new here. - -- Copyright (c) 2025 Rune Skovbo Johansen. -- Upstream: -- License: MPL-2.0 (). MPL-2.0 is file-level, so it - covers exactly the files that carry the port and nothing else: - `src/CultMath/math.Phacelle.cs`, `src/CultMath/CultPhasor.cs`, - `shaders/CultMath.Phacelle.hlsl` and the Unity copy of that include. Each - carries the MPL-2.0 header and this attribution. The rest of CultMath is MIT, - so the `GameCult.Math` NuGet package and the `org.gamecult.cultmath` Unity - package both declare `MIT AND MPL-2.0` and ship this file. diff --git a/packages/cultmath/unity/org.gamecult.cultmath/package.json b/packages/cultmath/unity/org.gamecult.cultmath/package.json index 368ee715..c09bf6bb 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/package.json +++ b/packages/cultmath/unity/org.gamecult.cultmath/package.json @@ -1,10 +1,10 @@ { "name": "org.gamecult.cultmath", "displayName": "CultMath", - "version": "0.4.0", + "version": "0.2.0", "unity": "2021.3", "description": "Precompiled CultMath numeric primitives and matching HLSL semantics for GameCult Unity runtimes.", - "license": "MIT AND MPL-2.0", + "license": "MPL-2.0", "author": { "name": "GameCult" }, diff --git a/packages/cultmesh-browser/package.json b/packages/cultmesh-browser/package.json index 186ab630..c49062b0 100644 --- a/packages/cultmesh-browser/package.json +++ b/packages/cultmesh-browser/package.json @@ -37,7 +37,7 @@ "directory": "packages/cultmesh-browser" }, "engines": { - "node": ">=20" + "node": ">=18" }, "dependencies": { "@msgpack/msgpack": "^3.1.3", diff --git a/packages/cultmesh-browser/src/index.ts b/packages/cultmesh-browser/src/index.ts index ea37c17e..4dddfa7d 100644 --- a/packages/cultmesh-browser/src/index.ts +++ b/packages/cultmesh-browser/src/index.ts @@ -15,28 +15,42 @@ import { type CultMeshSessionAcceptedMessage, type CultMeshSessionOpenMessage, } from "cultnet-ts/contracts"; -import { - base64ToBytes, - bytesToBase64, - isLoopbackEndpoint, - isUnsignedCertificate, - routeCertificateView, - verifyAuthorityRoute, - verifyProviderSessionProof, - type CultMeshAuthorityIdentity, - type CultMeshAuthorityRouteCertificate, - type CultMeshAuthorityRouteView, - type CultMeshAuthorityTrustMode, - type CultMeshAuthorityTrustPolicy, - type CultMeshP256PublicKey, -} from "cultnet-ts/authority"; -export type CultMeshBrowserIdentity = CultMeshAuthorityIdentity; -export type CultMeshBrowserRoute = CultMeshAuthorityRouteView; -export type CultMeshBrowserP256PublicKey = CultMeshP256PublicKey; -export type CultMeshBrowserRouteCertificate = CultMeshAuthorityRouteCertificate; -export type CultMeshBrowserAuthorityTrustMode = CultMeshAuthorityTrustMode; -export type CultMeshBrowserAuthorityTrustPolicy = CultMeshAuthorityTrustPolicy; +export interface CultMeshBrowserIdentity { + verseId: string; + authorityRuntimeId: string; +} + +export interface CultMeshBrowserRoute extends CultMeshBrowserIdentity { + endpoint: string; + protocolId?: string; + protocolIds?: readonly string[]; + priority?: number; + generation: string; + certificate?: CultMeshBrowserRouteCertificate; +} + +export interface CultMeshBrowserP256PublicKey { + keyId: string; + x: string; + y: string; +} + +export interface CultMeshBrowserRouteCertificate { + providerKey: CultMeshBrowserP256PublicKey; + odinKeyId: string; + issuedAtUnixMilliseconds: number; + expiresAtUnixMilliseconds: number; + signature: string; +} + +export type CultMeshBrowserAuthorityTrustMode = "authenticated-remote" | "local-development"; + +export interface CultMeshBrowserAuthorityTrustPolicy { + mode: CultMeshBrowserAuthorityTrustMode; + odinRoots?: readonly CultMeshBrowserP256PublicKey[]; + now?: () => number; +} export interface CultMeshBrowserRendezvous { resolve( @@ -780,6 +794,19 @@ export function decodeCultNetOperationPayload(response: CultNetOperationRespo return decode(base64ToBytes(response.payload)) as T; } +function bytesToBase64(bytes: Uint8Array): string { + let binary = ""; + for (let offset = 0; offset < bytes.length; offset += 0x8000) { + binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); + } + return btoa(binary); +} + +function base64ToBytes(value: string): Uint8Array { + const binary = atob(value); + return Uint8Array.from(binary, character => character.charCodeAt(0)); +} + function requireWebSocketEndpoint(value: string, field: string): URL { let endpoint: URL; try { @@ -871,7 +898,17 @@ async function selectOdinRoute( protocolIds: route.protocolIds, priority: route.priority, generation: route.generation, - ...(route.certificate ? { certificate: routeCertificateView(route.certificate) } : {}), + ...(route.certificate ? { certificate: { + providerKey: { + keyId: route.certificate.providerKeyId, + x: route.certificate.providerPublicKeyX, + y: route.certificate.providerPublicKeyY, + }, + odinKeyId: route.certificate.odinKeyId, + issuedAtUnixMilliseconds: route.certificate.issuedAtUnixMilliseconds, + expiresAtUnixMilliseconds: route.certificate.expiresAtUnixMilliseconds, + signature: route.certificate.signature, + } } : {}), }; try { await verifyAuthorityRoute(candidate, trust); @@ -904,26 +941,136 @@ async function validateSessionAcceptance( `expected '${request.verseId}/${request.authorityRuntimeId}/${protocolId}/${route.generation}'.`, ); } - // `CultMeshVerifiedAuthorityRoute.IsLocalDevelopment` in C#: an unsigned - // loopback route under local-development needs no provider session proof. - if (trust.mode === "local-development" && isLoopbackEndpoint(route.endpoint) && isUnsignedCertificate(route.certificate)) { - return undefined; - } + if (trust.mode === "local-development" && isLoopbackEndpoint(route.endpoint) && !route.certificate) return undefined; const providerKey = route.certificate?.providerKey; if (!providerKey || message.providerKeyId !== providerKey.keyId || !message.providerSignature) { return new Error("CultMesh authority did not prove possession of the Odin-certified provider key."); } - if (!await verifyProviderSessionProof(request, route.endpoint, providerKey, message.providerSignature)) { + if (!await verifyP256(providerKey, canonicalSession(request, route.endpoint), message.providerSignature)) { return new Error("CultMesh provider session proof is invalid."); } return undefined; } +async function verifyAuthorityRoute( + route: CultMeshBrowserRoute, + trust: CultMeshBrowserAuthorityTrustPolicy, +): Promise { + const certificate = route.certificate; + if (!certificate) { + if (trust.mode === "local-development" && isLoopbackEndpoint(route.endpoint)) return; + throw new Error("Remote CultMesh routes require an Odin-signed authority certificate."); + } + const endpoint = new URL(route.endpoint); + if (endpoint.protocol !== "wss:" && !(trust.mode === "local-development" && isLoopbackEndpoint(route.endpoint))) { + throw new Error("Authenticated remote CultMesh browser routes require wss:// channel protection."); + } + const now = trust.now?.() ?? Date.now(); + if (now < certificate.issuedAtUnixMilliseconds || now >= certificate.expiresAtUnixMilliseconds) { + throw new Error("The Odin route certificate is not currently valid."); + } + const root = trust.odinRoots?.find(candidate => candidate.keyId === certificate.odinKeyId); + if (!root) throw new Error(`Odin key '${certificate.odinKeyId}' is not trusted by this consumer.`); + if (!await verifyP256(root, canonicalRoute(route), certificate.signature)) { + throw new Error("The Odin route certificate signature is invalid."); + } +} + +function canonicalRoute(route: CultMeshBrowserRoute): Uint8Array { + const certificate = route.certificate!; + return canonicalFields( + "gamecult.cultmesh.route-certificate.v1", + route.verseId, + route.authorityRuntimeId, + route.endpoint, + [...(route.protocolIds ?? [route.protocolId ?? "cultmesh.documents.v1"])].sort().join("\u001f"), + String(route.priority ?? 0), + route.generation, + certificate.providerKey.keyId, + certificate.providerKey.x, + certificate.providerKey.y, + certificate.odinKeyId, + String(certificate.issuedAtUnixMilliseconds), + String(certificate.expiresAtUnixMilliseconds), + ); +} + +function canonicalSession(request: CultMeshSessionOpenMessage, endpoint: string): Uint8Array { + return canonicalFields( + "gamecult.cultmesh.session-proof.v1", + request.clientNonce, + request.messageId, + request.sourceRuntimeId, + request.verseId, + request.authorityRuntimeId, + request.protocolId, + endpoint, + request.routeGeneration, + ); +} + +function canonicalFields(...values: string[]): Uint8Array { + const encoder = new TextEncoder(); + const encoded = values.map(value => encoder.encode(value)); + const total = encoded.reduce((sum, value) => sum + 4 + value.byteLength, 0); + const result = new Uint8Array(total); + const view = new DataView(result.buffer); + let offset = 0; + for (const value of encoded) { + view.setUint32(offset, value.byteLength, false); + offset += 4; + result.set(value, offset); + offset += value.byteLength; + } + return result; +} + +async function verifyP256( + key: CultMeshBrowserP256PublicKey, + payload: Uint8Array, + signatureBase64: string, +): Promise { + try { + const x = base64ToBytes(key.x); + const y = base64ToBytes(key.y); + const signature = base64ToBytes(signatureBase64); + if (x.byteLength !== 32 || y.byteLength !== 32 || signature.byteLength !== 64) return false; + const raw = new Uint8Array(65); + raw[0] = 4; + raw.set(x, 1); + raw.set(y, 33); + const publicKey = await crypto.subtle.importKey( + "raw", + raw.slice().buffer as ArrayBuffer, + { name: "ECDSA", namedCurve: "P-256" }, + false, + ["verify"], + ); + return await crypto.subtle.verify( + { name: "ECDSA", hash: "SHA-256" }, + publicKey, + signature.slice().buffer as ArrayBuffer, + payload.slice().buffer as ArrayBuffer, + ); + } catch { + return false; + } +} + function randomNonce(): string { const bytes = crypto.getRandomValues(new Uint8Array(32)); return bytesToBase64(bytes); } +function isLoopbackEndpoint(value: string): boolean { + try { + const host = new URL(value).hostname.replace(/^\[|\]$/g, "").toLowerCase(); + return host === "localhost" || host === "127.0.0.1" || host === "::1"; + } catch { + return false; + } +} + function requireText(value: string, field: string): void { if (!value || value.trim().length === 0) throw new Error(`CultMesh browser ${field} is required.`); } diff --git a/packages/cultmesh-browser/test/cultmesh-browser.test.ts b/packages/cultmesh-browser/test/cultmesh-browser.test.ts index 59f9fac1..6c169d93 100644 --- a/packages/cultmesh-browser/test/cultmesh-browser.test.ts +++ b/packages/cultmesh-browser/test/cultmesh-browser.test.ts @@ -236,54 +236,6 @@ test("browser client rejects a credential-free authority impersonator", async () ); }); -test("browser client opens an unsigned-certificate loopback session under local-development without a provider proof, as in C#", async () => { - const connect = (route: CultMeshBrowserRoute, trust: { mode: "local-development" | "authenticated-remote"; odinRoots: CultMeshBrowserP256PublicKey[] }) => - CultMeshBrowserClient.connect({ - ...route, - runtimeId: "browser-unsigned-certificate-test", - rendezvous: { resolve: async () => route }, - trust, - socketFactory: () => handshakeOnlySocket(route), - }); - const blank = (route: CultMeshBrowserRoute, signature: string) => - ({ ...route, certificate: { ...route.certificate!, signature } }); - - const loopback = await createSignedRoute("ws://127.0.0.1:4501/mesh"); - const localTrust = { mode: "local-development" as const, odinRoots: [loopback.odinPublic] }; - const remote = await createSignedRoute("wss://provider.example/mesh"); - - // Empty is the easy case. The whitespace signatures are the ones that catch a - // local re-reading of "unsigned" here: an inline `signature === ""` passes - // every other test in this file and fails these, and U+0085 also separates - // `String.prototype.trim` from the C# `char.IsWhiteSpace` the shared - // `isUnsignedCertificate` uses. Both sides of the session check have to read - // "unsigned" the same way, or the route verifier accepts a session the - // acceptance check then demands a provider proof for. - for (const signature of ["", " ", "\u0085", "\u00a0\t\n"]) { - const label = JSON.stringify(signature); - const client = await connect(blank(loopback.route, signature), localTrust); - assert.equal(client.state, "connected", label); - await client.dispose(); - await assert.rejects( - connect(blank(remote.route, signature), { mode: "local-development", odinRoots: [remote.odinPublic] }), - /Odin-signed authority certificate/, - label, - ); - await assert.rejects( - connect(blank(remote.route, signature), { mode: "authenticated-remote", odinRoots: [remote.odinPublic] }), - /Odin-signed authority certificate/, - label, - ); - } - // U+FEFF is whitespace to JavaScript and not to C#, so it is a signature, not - // an unsigned route, and the loopback route is refused for its bytes. - await assert.rejects(connect(blank(loopback.route, "\ufeff"), localTrust), /not base64|not IEEE P1363/); - - // A signed loopback certificate is an authenticated route even under - // local-development; the provider must still prove its key. - await assert.rejects(connect(loopback.route, localTrust), /did not prove possession/); -}); - test("browser client rejects a mutated or expired signed route before opening a provider socket", async () => { const fixture = await createSignedRoute("wss://provider.example/mesh"); let opened = false; diff --git a/packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt b/packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt index 368b5338..104bd1b9 100644 --- a/packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt +++ b/packages/cultmesh-kotlin/src/main/kotlin/org/gamecult/cultmesh/CultMesh.kt @@ -11,7 +11,6 @@ import java.io.InputStream import java.io.OutputStream import java.net.DatagramPacket import java.net.DatagramSocket -import java.net.Inet6Address import java.net.InetAddress import java.net.InetSocketAddress import java.net.ServerSocket @@ -582,7 +581,7 @@ object CultMesh { connectionId: Long, remoteHost: String, remotePort: Int, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection = cultNetRudpClient( @@ -601,7 +600,7 @@ object CultMesh { runtimeId: String, connectionId: Long, endpoint: CultNetRudpEndpoint, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection = createRudpClient( @@ -618,7 +617,7 @@ object CultMesh { runtimeId: String, connectionId: Long, endpoint: String, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection = createRudpClient( @@ -634,7 +633,7 @@ object CultMesh { runtimeId: String, connectionId: Long, peer: CultMeshPeerCard, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection { @@ -652,7 +651,7 @@ object CultMesh { role: String, shardId: String? = null, at: Instant = Instant.now(), - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection { @@ -665,7 +664,7 @@ object CultMesh { runtimeId: String, connectionId: Long, endpoint: CultNetRudpEndpoint, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), connectPayload: ByteArray = ByteArray(0), @@ -684,7 +683,7 @@ object CultMesh { runtimeId: String, connectionId: Long, endpoint: String, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), connectPayload: ByteArray = ByteArray(0), @@ -706,7 +705,7 @@ object CultMesh { runtimeId: String, connectionId: Long, peer: CultMeshPeerCard, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), connectPayload: ByteArray = ByteArray(0), @@ -737,7 +736,7 @@ object CultMesh { role: String, shardId: String? = null, at: Instant = Instant.now(), - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), connectPayload: ByteArray = ByteArray(0), @@ -1360,7 +1359,7 @@ fun defineCultNetSchemaDescriptor( schemaJson = schemaJson, ) -private const val cultNetSchemaBase = "https://github.com/GameCult/CultLib/contracts/cultnet" +private const val cultNetSchemaBase = "https://github.com/GameCult/cultnet-ts/contracts" private data class CultNetBuiltInSchemaSpec( val schemaVersion: String, @@ -1378,58 +1377,58 @@ private val cultNetBuiltInSchemaSpecs = listOf( title = "CultNet Hello Message", schemaId = "$cultNetSchemaBase/cultnet.hello.schema.json", requiredFields = listOf("schemaVersion", "runtimeId", "runtimeKind"), - contentHash = "f660ef803f293e2882650b3981c6eed835bd8e595c9b880d6c6271e0dcbd79e4", + contentHash = "1d2114bf0c92a2dd5e07dd735778ceeb939402c6424550d6d281d9db423f56b3", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.document_delete.v0", title = "CultNet Document Delete Message", schemaId = "$cultNetSchemaBase/cultnet.document-delete.schema.json", requiredFields = listOf("schemaVersion", "messageId", "schemaId", "recordKey"), - contentHash = "ed7dc202e4f1ebe0d88c5d60c81c53005b44a2557698d3d3c5d2126c01b40f08", + contentHash = "037f7cf1b30756904e0bfada6bcff486269378997afbe3c4b6fc5c573fc8a4df", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.document_put_raw.v0", title = "CultNet Raw Document Put Message", schemaId = "$cultNetSchemaBase/cultnet.document-put-raw.schema.json", - contentHash = "34b61b14b49cfc887728673f08aa0f33df7ccd401e79c77d3bc324c72e547177", + contentHash = "b61e7e6cce8508653fbeccc4d956ef211c853a174d67c7e1903ce294e15985a2", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.snapshot_request.v0", title = "CultNet Snapshot Request Message", schemaId = "$cultNetSchemaBase/cultnet.snapshot-request.schema.json", - contentHash = "05267d9b5eb450d4aa8979179f74ba3aec2f3a82fead7ba4a16ab5462c7750fa", + contentHash = "9f6546f51a1aab85978554e6908d7a59e96b3329feff7b35022be210495dd721", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.snapshot_response_raw.v0", title = "CultNet Raw Snapshot Response Message", schemaId = "$cultNetSchemaBase/cultnet.snapshot-response-raw.schema.json", - contentHash = "fdefbdf5d6b0844dd0eabe2c7430d054295d78e41289f96b227dc39f4aab78b9", + contentHash = "0dbca3338a3ae5d4011aed2c973c75b9b47b6b9dfc0874459ac56da01fef4582", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.schema_catalog_request.v0", title = "CultNet Schema Catalog Request Message", schemaId = "$cultNetSchemaBase/cultnet.schema-catalog-request.schema.json", wireContracts = listOf("cultnet.schema.v0", "gamecult.networking.v0"), - contentHash = "ed6d63e29de2d492bb831f030b26ff49ba6883cd2be791ec4936c385f765c76a", + contentHash = "bdd49b44428daf24b514c521e53027ec944aecfebb39ca0d10967661c303e096", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.schema_catalog_response.v0", title = "CultNet Schema Catalog Response Message", schemaId = "$cultNetSchemaBase/cultnet.schema-catalog-response.schema.json", wireContracts = listOf("cultnet.schema.v0", "gamecult.networking.v0"), - contentHash = "10b4835d33181fe4b93a33e39b63886c5514899e93682de786e298f7e4a213e9", + contentHash = "b158de53d1ca614eacf2e05767122fb4b9e06504c037ad76c649cffdf71dd648", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.shard_catalog_request.v0", title = "CultNet Shard Catalog Request Message", - schemaId = "$cultNetSchemaBase/cultnet.shard-catalog-request.schema.json", - contentHash = "b4edecd8a24f68ebccf0aca9b429d234618ff7e8858a10123d0b328aeae7eb3f", + schemaId = "cultnet.shard_catalog_request.v0", + contentHash = "0abd131a1db12f6731010333b86e104d550160bd58f539b18413a2b61198fa38", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.shard_catalog_response.v0", title = "CultNet Shard Catalog Response Message", - schemaId = "$cultNetSchemaBase/cultnet.shard-catalog-response.schema.json", - contentHash = "d86a94c57d7820483912b8b5cef6214ac951d34cb2641d2d21dcb1f1bc0263c0", + schemaId = "cultnet.shard_catalog_response.v0", + contentHash = "93a0e90ac81bc6ab21b68925ad25e381edfac8773232333679d3275141cff37b", ), CultNetBuiltInSchemaSpec( schemaVersion = "cultnet.shard_log_request.v0", @@ -1469,7 +1468,7 @@ private val cultNetBuiltInSchemaSpecs = listOf( schemaId = "$cultNetSchemaBase/cultnet.transport-profile.schema.json", kind = "shared_contract", requiredFields = listOf("schemaVersion", "runtimeId", "transports"), - contentHash = "63dfd484e1fd332c167caadf52cb5b4fe12d5ffea4415206c3ef111c196507aa", + contentHash = "84473264f543ca3443267999e43d72b7993b61b7b2ac53c642c9cbe8b6de0217", ), ) @@ -3029,36 +3028,22 @@ fun cultNetRudpServer( ) } -/** - * The address an RUDP client binds when its caller names none: loopback for a - * loopback endpoint, otherwise the unspecified address of the endpoint's family. - * A socket bound to loopback cannot send off the host on Windows. - */ -fun cultNetRudpClientBindAddress(remote: InetAddress): InetAddress = when { - remote is Inet6Address && remote.isLoopbackAddress -> InetAddress.getByName("::1") - remote is Inet6Address -> InetAddress.getByName("::") - remote.isLoopbackAddress -> InetAddress.getByName("127.0.0.1") - else -> InetAddress.getByName("0.0.0.0") -} - fun cultNetRudpClient( runtimeId: String, connectionId: Long, remoteHost: String, remotePort: Int, - bindHost: String? = null, + bindHost: String = "127.0.0.1", bindPort: Int = 0, tuning: CultNetRudpSocketTuning = CultNetRudpSocketTuning(), ): CultNetRudpSocketTransportConnection { - val remote = InetAddress.getByName(remoteHost) - val bindAddress = bindHost?.let(InetAddress::getByName) ?: cultNetRudpClientBindAddress(remote) - val socket = DatagramSocket(bindPort, bindAddress).also { it.soTimeout = 20 } + val socket = DatagramSocket(bindPort, InetAddress.getByName(bindHost)).also { it.soTimeout = 20 } return CultNetRudpSocketTransportConnection( socket = socket, mode = CultNetRudpSocketMode.Client, runtimeId = runtimeId, connectionId = connectionId, - remoteAddress = InetSocketAddress(remote, remotePort), + remoteAddress = InetSocketAddress(InetAddress.getByName(remoteHost), remotePort), initialSequence = tuning.initialSequence, resendDelayMs = tuning.resendDelayMs, maxFragmentBytes = tuning.maxFragmentBytes, @@ -3383,7 +3368,6 @@ fun main(args: Array) { rudpSessionFragmentsAndReassemblesReliableOrderedPayloads() rudpSessionAdvancesLargeFragmentSetsThroughBoundedReliableWindow() rudpSocketTransportErgonomicFactoriesCarrySchemaFrames() - rudpClientBindsLoopbackOnlyForALoopbackEndpoint() rudpSocketTransportHandshakesAndCarriesReliableOrderedSchemaFrames() rudpSocketTransportCarriesFragmentedReliableOrderedSchemaFrames() return @@ -3733,16 +3717,16 @@ private fun cultNetReconnectControllerSchedulesAttemptsAndReset() { private const val interopDocumentType = "cultnet.interop-note" private const val interopSchemaVersion = "cultnet.interop_note.v0" private const val interopMutationIntentType = "cultnet.interop-note-mutation-intent" -private const val interopMutationIntentSchemaId = "https://github.com/GameCult/CultLib/contracts/cultnet/interop/cultnet.interop-note-mutation-intent.schema.json" +private const val interopMutationIntentSchemaId = "https://github.com/GameCult/cultnet-ts/integration/contracts/cultnet.interop-note-mutation-intent.schema.json" private const val interopMutationIntentSchemaVersion = "cultnet.interop_note_mutation_intent.v0" private const val interopMutationReceiptType = "cultnet.interop-note-mutation-receipt" -private const val interopMutationReceiptSchemaId = "https://github.com/GameCult/CultLib/contracts/cultnet/interop/cultnet.interop-note-mutation-receipt.schema.json" +private const val interopMutationReceiptSchemaId = "https://github.com/GameCult/cultnet-ts/integration/contracts/cultnet.interop-note-mutation-receipt.schema.json" private const val interopMutationReceiptSchemaVersion = "cultnet.interop_note_mutation_receipt.v0" private const val interopFireCommandType = "cultnet.interop-fire-weapon-command" -private const val interopFireCommandSchemaId = "https://github.com/GameCult/CultLib/contracts/cultnet/interop/cultnet.interop-fire-weapon-command.schema.json" +private const val interopFireCommandSchemaId = "https://github.com/GameCult/cultnet-ts/integration/contracts/cultnet.interop-fire-weapon-command.schema.json" private const val interopFireCommandSchemaVersion = "cultnet.interop_fire_weapon_command.v0" private const val interopFireReceiptType = "cultnet.interop-fire-weapon-receipt" -private const val interopFireReceiptSchemaId = "https://github.com/GameCult/CultLib/contracts/cultnet/interop/cultnet.interop-fire-weapon-receipt.schema.json" +private const val interopFireReceiptSchemaId = "https://github.com/GameCult/cultnet-ts/integration/contracts/cultnet.interop-fire-weapon-receipt.schema.json" private const val interopFireReceiptSchemaVersion = "cultnet.interop_fire_weapon_receipt.v0" private const val rudpInteropConnectionId = 0x43554c54L private const val rudpInteropMaxFragmentBytes = 1024 @@ -4643,11 +4627,11 @@ private fun cultNetBuiltInSchemaCatalogAdvertisesWireContracts() { check(schemaCatalogRequest["wireContracts"] == listOf("cultnet.schema.v0", "gamecult.networking.v0")) check(!schemaCatalogRequest.containsKey("schemaJson")) val shardCatalogRequest = schemas.single { it["schemaVersion"] == "cultnet.shard_catalog_request.v0" } - check(shardCatalogRequest["schemaId"] == "$cultNetSchemaBase/cultnet.shard-catalog-request.schema.json") + check(shardCatalogRequest["schemaId"] == "cultnet.shard_catalog_request.v0") check(shardCatalogRequest["wireContracts"] == listOf("cultnet.schema.v0")) - check(shardCatalogRequest["contentHash"] == "b4edecd8a24f68ebccf0aca9b429d234618ff7e8858a10123d0b328aeae7eb3f") + check(shardCatalogRequest["contentHash"] == "0abd131a1db12f6731010333b86e104d550160bd58f539b18413a2b61198fa38") val shardCatalogResponse = schemas.single { it["schemaVersion"] == "cultnet.shard_catalog_response.v0" } - check(shardCatalogResponse["schemaId"] == "$cultNetSchemaBase/cultnet.shard-catalog-response.schema.json") + check(shardCatalogResponse["schemaId"] == "cultnet.shard_catalog_response.v0") check(shardCatalogResponse["wireContracts"] == listOf("cultnet.schema.v0")) val inlineCatalog = cultNetBuiltInSchemaCatalog(includeSchemaJson = true) @@ -4660,7 +4644,7 @@ private fun cultNetBuiltInSchemaCatalogAdvertisesWireContracts() { ) val transportProfile = mapList(transportResponse.body["schemas"]).single() check(transportProfile["kind"] == "shared_contract") - check(transportProfile["contentHash"] == "63dfd484e1fd332c167caadf52cb5b4fe12d5ffea4415206c3ef111c196507aa") + check(transportProfile["contentHash"] == "84473264f543ca3443267999e43d72b7993b61b7b2ac53c642c9cbe8b6de0217") check(!transportProfile.containsKey("schemaJson")) val filteredTransportCatalog = CultMesh.createBuiltInSchemaCatalog( @@ -5394,27 +5378,6 @@ private fun rudpSessionAdvancesLargeFragmentSetsThroughBoundedReliableWindow() { check(oldAck.ackMask == 0L) } -private fun rudpClientBoundHost(endpoint: String, bindHost: String? = null): InetAddress = - CultMesh.createRudpClient("kotlin-rudp-bind-client", 0x10203060L, endpoint, bindHost).use { client -> - InetAddress.getByName(client.profile.transports.single().host) - } - -// A client bound to loopback cannot send to another host on Windows, so a -// client for a remote endpoint binds the unspecified address. A JVM wildcard -// socket is dual-stack and reports one wildcard for either family, so the -// family is not observable here. -private fun rudpClientBindsLoopbackOnlyForALoopbackEndpoint() { - check(rudpClientBoundHost("rudp://10.77.0.1:17872").isAnyLocalAddress) - check(rudpClientBoundHost("rudp://[2001:db8::1]:17872").isAnyLocalAddress) - check(rudpClientBoundHost("rudp://127.0.0.1:17872") == InetAddress.getByName("127.0.0.1")) - check(rudpClientBoundHost("rudp://[::1]:17872") == InetAddress.getByName("::1")) - check(rudpClientBoundHost("rudp://10.77.0.1:17872", "127.0.0.1") == InetAddress.getByName("127.0.0.1")) - check(rudpClientBoundHost("rudp://127.0.0.1:17872", "0.0.0.0").isAnyLocalAddress) - CultMesh.createRudpServer("kotlin-rudp-bind-server", 0x10203061L).use { server -> - check(InetAddress.getByName(server.profile.transports.single().host) == InetAddress.getByName("127.0.0.1")) - } -} - private fun rudpSocketTransportErgonomicFactoriesCarrySchemaFrames() { val connectionId = 0x10203042L CultMesh.createRudpServer( diff --git a/packages/cultmesh-py/src/cultmesh_py/__init__.py b/packages/cultmesh-py/src/cultmesh_py/__init__.py index f2dc6b28..af4da272 100644 --- a/packages/cultmesh-py/src/cultmesh_py/__init__.py +++ b/packages/cultmesh-py/src/cultmesh_py/__init__.py @@ -24,7 +24,7 @@ from .node import ( CultMeshReactiveDocumentReconciliation, create_node, ) -from .server import CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES, CultMeshLocalServer +from .server import CultMeshLocalServer from .session import ( CultMeshGameSession, CultMeshGameSessionOptions, @@ -79,7 +79,6 @@ __all__ = [ "CultMeshReactiveDocumentReconciliation", "CultMeshGameSession", "CultMeshGameSessionOptions", - "CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES", "CultMeshLocalServer", "CultMeshPeerCard", "CultMeshPeerCatalog", diff --git a/packages/cultmesh-py/src/cultmesh_py/daemon.py b/packages/cultmesh-py/src/cultmesh_py/daemon.py index 5b127008..d21d42d8 100644 --- a/packages/cultmesh-py/src/cultmesh_py/daemon.py +++ b/packages/cultmesh-py/src/cultmesh_py/daemon.py @@ -24,18 +24,10 @@ from cultnet_py.cultmesh_contracts import ( READY_SCHEMA_VERSION = "cultmesh.daemon_ready.v0" -def _port(value: str) -> int: - """A TCP/UDP port: 0 (any free port) through 65535.""" - port = int(value) - if not 0 <= port <= 65535: - raise argparse.ArgumentTypeError("port must be between 0 and 65535") - return port - - def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser(prog="cultmesh-py-daemon") parser.add_argument("--host", default="127.0.0.1") - parser.add_argument("--port", type=_port, default=3075) + parser.add_argument("--port", type=int, default=3075) parser.add_argument("--runtime-id", default="python-runtime") parser.add_argument("--display-name") parser.add_argument("--cache-file") @@ -58,7 +50,7 @@ def main(argv: list[str] | None = None) -> int: stop = threading.Event() install_signal_handlers(stop) - server = start_server(args, parser) + server = start_server(args) try: ready = daemon_ready_document(server) publish_ready(ready, ready_file=args.ready_file) @@ -69,7 +61,7 @@ def main(argv: list[str] | None = None) -> int: return 0 -def start_server(args: argparse.Namespace, parser: argparse.ArgumentParser) -> CultMeshLocalServer: +def start_server(args: argparse.Namespace) -> CultMeshLocalServer: node = CultMesh.create_node( args.cache_file, runtime_id=args.runtime_id, @@ -106,21 +98,17 @@ def start_server(args: argparse.Namespace, parser: argparse.ArgumentParser) -> C quorum_ratio=args.simulation_quorum_ratio, ) ) - try: - server = CultMesh.serve_node( - node, - verse_catalog=verse_catalog, - peer_catalog=peer_catalog, - observation_hub=observation_hub, - host=args.host, - port=args.port, - display_name=args.display_name, - max_snapshot_documents=args.max_snapshot_documents, - max_snapshot_bytes=args.max_snapshot_bytes, - ) - except ValueError as error: - # The server owns its option rules; a limit it refuses is a usage error, not a crash. - parser.error(str(error)) + server = CultMesh.serve_node( + node, + verse_catalog=verse_catalog, + peer_catalog=peer_catalog, + observation_hub=observation_hub, + host=args.host, + port=args.port, + display_name=args.display_name, + max_snapshot_documents=args.max_snapshot_documents, + max_snapshot_bytes=args.max_snapshot_bytes, + ) advertise_self(server, verse_catalog, peer_catalog, args) return server diff --git a/packages/cultmesh-py/src/cultmesh_py/facade.py b/packages/cultmesh-py/src/cultmesh_py/facade.py index 84bea2c8..53328aab 100644 --- a/packages/cultmesh-py/src/cultmesh_py/facade.py +++ b/packages/cultmesh-py/src/cultmesh_py/facade.py @@ -18,7 +18,6 @@ from cultnet_py import ( CultNetShardCatalog, CultNetSimulationObservationHub, create_rudp_schema_transport, - rudp_client_bind_host, wire_message_schema_catalog, ) @@ -32,7 +31,7 @@ from .node import ( CultMeshPublicationDocumentBinding, create_node, ) -from .server import CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES, CultMeshLocalServer +from .server import CultMeshLocalServer from .session import CultMeshGameSession, CultMeshGameSessionOptions from .simulation import CultMeshSimulationFactCommitter from cultnet_py.cultmesh_contracts import ( @@ -158,7 +157,7 @@ class CultMesh: bind_host: str = "127.0.0.1", bind_port: int = 0, socket: socket_module.socket | None = None, - initial_sequence: int | None = None, + initial_sequence: int = 1, resend_delay_ms: int = 250, transport_id: str = "rudp", max_payload_bytes: int | None = None, @@ -189,10 +188,10 @@ class CultMesh: connection_id: int, endpoint: str | CultMeshRudpEndpoint, *, - bind_host: str | None = None, + bind_host: str = "127.0.0.1", bind_port: int = 0, socket: socket_module.socket | None = None, - initial_sequence: int | None = None, + initial_sequence: int = 1, resend_delay_ms: int = 250, transport_id: str = "rudp", max_payload_bytes: int | None = None, @@ -205,10 +204,7 @@ class CultMesh: if isinstance(endpoint, str) else endpoint ) - transport_socket = socket or _bind_rudp_socket( - bind_host if bind_host is not None else rudp_client_bind_host(parsed_endpoint.host), - bind_port, - ) + transport_socket = socket or _bind_rudp_socket(bind_host, bind_port) return CultNetRudpSocketTransportConnection( CultNetRudpSocketTransportOptions( runtime_id=runtime_id, @@ -408,8 +404,6 @@ class CultMesh: enable_rudp: bool = True, rudp_connection_id: int = 0x43554C54, rudp_resend_delay_ms: int = 25, - rudp_max_fragment_bytes: int = CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES, - rudp_max_pending_reliable_packets: int | None = None, ) -> CultMeshLocalServer: return CultMeshLocalServer( node=node, @@ -424,8 +418,6 @@ class CultMesh: enable_rudp=enable_rudp, rudp_connection_id=rudp_connection_id, rudp_resend_delay_ms=rudp_resend_delay_ms, - rudp_max_fragment_bytes=rudp_max_fragment_bytes, - rudp_max_pending_reliable_packets=rudp_max_pending_reliable_packets, ).start() @staticmethod @@ -437,7 +429,7 @@ class CultMesh: endpoint: str | CultMeshRudpEndpoint | None = None, connection_id: int = 0x43554C54, runtime_id: str = "cultmesh-python-rudp-client", - bind_host: str | None = None, + bind_host: str = "127.0.0.1", bind_port: int = 0, ) -> CultNetRawClient: if endpoint is None and host.lower().startswith("rudp://"): @@ -473,7 +465,7 @@ class CultMesh: endpoint: str | CultMeshRudpEndpoint | None = None, connection_id: int = 0x43554C54, runtime_id: str = "cultmesh-python-rudp-client", - bind_host: str | None = None, + bind_host: str = "127.0.0.1", bind_port: int = 0, ) -> CultNetRawClient: return CultMesh.create_client( @@ -489,10 +481,7 @@ class CultMesh: def _bind_rudp_socket(bind_host: str, bind_port: int) -> socket_module.socket: - transport_socket = socket_module.socket( - socket_module.AF_INET6 if ":" in bind_host else socket_module.AF_INET, - socket_module.SOCK_DGRAM, - ) + transport_socket = socket_module.socket(socket_module.AF_INET, socket_module.SOCK_DGRAM) transport_socket.bind((bind_host, bind_port)) transport_socket.settimeout(0.02) return transport_socket diff --git a/packages/cultmesh-py/src/cultmesh_py/node.py b/packages/cultmesh-py/src/cultmesh_py/node.py index bf092060..09ac2012 100644 --- a/packages/cultmesh-py/src/cultmesh_py/node.py +++ b/packages/cultmesh-py/src/cultmesh_py/node.py @@ -651,38 +651,6 @@ class CultMeshDatabase: return message def apply_raw_put_message(self, message: dict[str, Any]) -> CultMeshDatabaseChange | None: - prepared = self._raw_put_envelope(message) - if prepared is None: - return None - document, envelope = prepared - record_key = envelope.key - previous = self.cache.get(document, record_key) - value = self.cache.put_envelope(document, envelope) - change_kind = "added" if previous is None else "updated" - change = self._publish_local_change(document, record_key, change_kind, value, previous) - self._append_shard_log_put(CultNetMessage( - "cultnet.document_put_raw.v0", - {key: value for key, value in message.items() if key != "schemaVersion"}, - ), change_kind) - return change - - def raw_put_served_alone(self, message: dict[str, Any], *, message_id: str) -> dict[str, Any] | None: - """The snapshot response that would serve this put's document alone, as a wire map. - - It is built from the envelope the put would store, exactly as a snapshot builds it, so a - server can judge a put by the size it would be served at. None when the put would not apply. - """ - prepared = self._raw_put_envelope(message) - if prepared is None: - return None - return CultNetRawSnapshotResponse( - message_id=message_id, - documents=(self._served_record(prepared[1]),), - ).to_wire() - - def _raw_put_envelope( - self, message: dict[str, Any] - ) -> tuple[DocumentDefinition[Any], CultCacheEnvelope] | None: document_record = message.get("document") if not isinstance(document_record, dict): return None @@ -696,24 +664,24 @@ class CultMeshDatabase: ) except KeyError: return None - return document, CultCacheEnvelope( - key=str(document_record["recordKey"]), + record_key = str(document_record["recordKey"]) + previous = self.cache.get(document, record_key) + envelope = CultCacheEnvelope( + key=record_key, type=document.type, schema_id=resolved_schema_id, payload=bytes(document_record["payload"]), stored_at=str(document_record.get("storedAt") or ""), catalog_entry=document.catalog_entry(), ) - - @staticmethod - def _served_record(envelope: CultCacheEnvelope) -> CultNetRawDocumentRecord: - return CultNetRawDocumentRecord( - schema_id=envelope.schema_id or envelope.type, - record_key=envelope.key, - stored_at=envelope.stored_at, - payload_encoding="messagepack", - payload=envelope.payload, - ) + value = self.cache.put_envelope(document, envelope) + change_kind = "added" if previous is None else "updated" + change = self._publish_local_change(document, record_key, change_kind, value, previous) + self._append_shard_log_put(CultNetMessage( + "cultnet.document_put_raw.v0", + {key: value for key, value in message.items() if key != "schemaVersion"}, + ), change_kind) + return change def apply_raw_delete_message(self, message: dict[str, Any]) -> CultMeshDatabaseChange | None: schema_id = str(message.get("schemaId") or "") @@ -806,7 +774,13 @@ class CultMeshDatabase: continue if shard_record_keys is not None and (schema_id, envelope.key) not in shard_record_keys: continue - documents.append(self._served_record(envelope)) + documents.append(CultNetRawDocumentRecord( + schema_id=schema_id, + record_key=envelope.key, + stored_at=envelope.stored_at, + payload_encoding="messagepack", + payload=envelope.payload, + )) return CultNetRawSnapshotResponse( message_id=message_id, diff --git a/packages/cultmesh-py/src/cultmesh_py/server.py b/packages/cultmesh-py/src/cultmesh_py/server.py index e50def4d..e0c7fdd0 100644 --- a/packages/cultmesh-py/src/cultmesh_py/server.py +++ b/packages/cultmesh-py/src/cultmesh_py/server.py @@ -1,16 +1,14 @@ from __future__ import annotations -import logging import socket import threading import time -from dataclasses import dataclass, field, replace +from dataclasses import dataclass, field from typing import Any import msgpack from cultnet_py import ( - CultNetRawSnapshotResponse, CultNetSimulationObservationHub, CultNetRudpPacket, CultNetRudpPacketType, @@ -22,25 +20,10 @@ from cultnet_py import ( create_tcp_framed_transport_profile, decode_rudp_packet, encode_rudp_packet, - is_permanent_send_error, wire_message_schema_descriptors, ) from .node import CultMeshNode - -# The shortest message id this server answers a snapshot request under. It takes a -# request's messageId as given, an empty one included, so no response it sends is smaller. -_SHORTEST_SERVED_MESSAGE_ID = "" -# The most fragments one RUDP message can carry: its fragment count is a u16. -_MAX_FRAGMENTS_PER_MESSAGE = 0xFFFF -# Replies larger than one fragment are split into fragments of at most this many bytes, -# as the Rust and TypeScript document servers do by default. -CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES = 1200 -# The answer to a request whose reply the peer's reliable queue cannot take. Fixed text: it -# never quotes the reply or the queue's error. -_REPLY_UNQUEUEABLE = "The reply could not be queued for this peer." -# The answer to a message the server could not handle. Fixed text: it never quotes the message. -_MESSAGE_UNHANDLED = "The message could not be handled." from cultnet_py.cultmesh_contracts import ( PEER_EXCHANGE_REQUEST, VERSE_CATALOG_REQUEST, @@ -48,17 +31,6 @@ from cultnet_py.cultmesh_contracts import ( CultMeshVerseCatalog, ) -_LOGGER = logging.getLogger(__name__) - - -class _ReplyUnqueueable(Exception): - """A reply the peer's reliable queue cannot take. The peer's session ends, and the peer is - answered first with a small cultnet.error.v0 under the request's message id.""" - - def __init__(self, message_id: str) -> None: - super().__init__("reply could not be queued") - self.message_id = message_id - @dataclass(frozen=True) class _DatabaseSubscription: @@ -96,63 +68,17 @@ class CultMeshLocalServer: enable_rudp: bool = True rudp_connection_id: int = 0x43554C54 rudp_resend_delay_ms: int = 25 - # RUDP replies are fragmented by rudp_max_fragment_bytes, and each peer's reliable queue - # holds at most rudp_max_pending_reliable_packets (None: only the 65535 fragments one - # message can carry). A put arriving over RUDP whose served reply could not fit them is - # refused as document_unservable. - rudp_max_fragment_bytes: int = CULTMESH_RUDP_DEFAULT_MAX_FRAGMENT_BYTES - rudp_max_pending_reliable_packets: int | None = None _socket: socket.socket | None = field(default=None, init=False, repr=False) _rudp_socket: socket.socket | None = field(default=None, init=False, repr=False) _stop: threading.Event = field(default_factory=threading.Event, init=False, repr=False) _thread: threading.Thread | None = field(default=None, init=False, repr=False) _rudp_thread: threading.Thread | None = field(default=None, init=False, repr=False) - _rudp_send_failures: int = field(default=0, init=False, repr=False) - - @property - def rudp_send_failures(self) -> int: - """Datagrams that could not be sent to a peer. Each is that peer's lost - datagram: a reliable packet stays pending and is resent, and no other - peer is affected. A datagram that can never be sent as built - (`is_permanent_send_error`) is not counted here: it ends that peer's - session, and the peer's goodbye names the error.""" - return self._rudp_send_failures def __post_init__(self) -> None: - # The Rust document server's option rules (validate_options), for each option this - # server shares with it: every limit is greater than zero, and the limits leave room for - # the smallest response the server sends, an empty snapshot. A server that could answer - # nothing is misconfigured. The RUDP options are checked only when RUDP is served, as - # Rust checks them only for the RUDP server they configure. - if self.max_snapshot_bytes is not None and self.max_snapshot_bytes <= 0: - raise ValueError("max_snapshot_bytes must be greater than zero") - if self.max_snapshot_documents is not None and self.max_snapshot_documents <= 0: - raise ValueError("max_snapshot_documents must be greater than zero") - if self.enable_rudp: - if self.rudp_resend_delay_ms <= 0: - raise ValueError("rudp_resend_delay_ms must be greater than zero") - if self.rudp_max_pending_reliable_packets is not None and self.rudp_max_pending_reliable_packets <= 0: - raise ValueError("rudp_max_pending_reliable_packets must be greater than zero") - if self.rudp_max_fragment_bytes <= 0: - raise ValueError("rudp_max_fragment_bytes must be greater than zero") - empty = _snapshot_response_bytes( - CultNetRawSnapshotResponse(message_id=_SHORTEST_SERVED_MESSAGE_ID, documents=()).to_wire() - ) - if self.max_snapshot_bytes is not None and empty > self.max_snapshot_bytes: - raise ValueError("max_snapshot_bytes cannot hold an empty snapshot response") - if self.enable_rudp and -(-empty // self.rudp_max_fragment_bytes) > self._max_rudp_reply_fragments(): - raise ValueError( - "rudp_max_fragment_bytes and rudp_max_pending_reliable_packets cannot carry an empty " - "snapshot response" - ) - - def _max_rudp_reply_fragments(self) -> int: - """The most fragments one RUDP reply can take: one message's fragment count, and the - peer's reliable queue it must fit into whole.""" - return min( - _MAX_FRAGMENTS_PER_MESSAGE, - self.rudp_max_pending_reliable_packets or _MAX_FRAGMENTS_PER_MESSAGE, - ) + if self.max_snapshot_documents is not None and self.max_snapshot_documents < 0: + raise ValueError("max_snapshot_documents must be non-negative") + if self.max_snapshot_bytes is not None and self.max_snapshot_bytes < 0: + raise ValueError("max_snapshot_bytes must be non-negative") def start(self) -> "CultMeshLocalServer": if self._socket is not None: @@ -270,22 +196,7 @@ class CultMeshLocalServer: return if not isinstance(message, dict): continue - try: - responses = self._handle_connection_message(message, subscriptions) - except Exception as error: # noqa: BLE001 - one message never ends the connection - # Whatever a peer's message makes the handling raise is that peer's failure: - # it is refused with fixed text and the connection serves on. The log names - # the error type only, because the error's own message can quote the peer. - _LOGGER.warning( - "CultMesh server could not handle a peer's message (%s); it was refused.", - type(error).__name__, - ) - message_id = message.get("messageId") - responses = [self._error_response( - _MESSAGE_UNHANDLED, - message_id=message_id if isinstance(message_id, str) else "", - code="message_unhandled", - )] + responses = self._handle_connection_message(message, subscriptions) for response in responses: transport.send("schema", msgpack.packb(response, use_bin_type=True)) @@ -297,10 +208,7 @@ class CultMeshLocalServer: while not self._stop.is_set(): try: wire, remote_addr = rudp_socket.recvfrom(65535) - except (TimeoutError, ConnectionResetError): - # Windows reports an earlier ICMP port-unreachable, from a peer that - # has gone away, as an error on the next receive. It names no datagram - # of this read, so it is idle, not the end of the thread. + except TimeoutError: self._poll_rudp_resends(rudp_socket, peers) continue except OSError: @@ -316,96 +224,55 @@ class CultMeshLocalServer: now_ms = _now_ms() peer = peers.get(remote_addr) if packet.packet_type == CultNetRudpPacketType.CONNECT: - # The session decides whether this Connect repeats the one it - # accepted. Any other Connect is a new client session, with new - # subscriptions. - if peer is None or not peer.session.connect_repeats(packet): - peer = _RudpPeerConnection( - CultNetRudpSession( - CultNetRudpSessionOptions( - connection_id=self.rudp_connection_id, - resend_delay_ms=self.rudp_resend_delay_ms, - max_pending_reliable_packets=self.rudp_max_pending_reliable_packets, - ) + peer = _RudpPeerConnection( + CultNetRudpSession( + CultNetRudpSessionOptions( + connection_id=self.rudp_connection_id, + resend_delay_ms=self.rudp_resend_delay_ms, ) ) - peers[remote_addr] = peer - unsendable = self._send_rudp_packet( + ) + peers[remote_addr] = peer + self._send_rudp_packet( rudp_socket, remote_addr, peer.session.accept_connect(packet, now_ms, b"cultmesh-local-rudp"), ) - if unsendable is not None: - self._end_unsendable_peer(rudp_socket, peers, remote_addr, unsendable) continue if peer is None: continue - try: - result = peer.session.receive(packet, now_ms) - except ValueError: - # receive() has already recorded the packet's reliable sequence, so the - # session cannot be kept: a retransmit would be acknowledged and the - # frame silently lost. It ends, never the thread, and the peer is told. - self._end_refused_peer(rudp_socket, peers, remote_addr) - continue - unsendable: OSError | None = None - for outgoing in (*([result.reply] if result.reply is not None else []), *result.ready_to_send): - unsendable = self._send_rudp_packet(rudp_socket, remote_addr, outgoing) - if unsendable is not None: - break + result = peer.session.receive(packet, now_ms) + if result.reply is not None: + self._send_rudp_packet(rudp_socket, remote_addr, result.reply) + for ready in result.ready_to_send: + self._send_rudp_packet(rudp_socket, remote_addr, ready) if result.disconnected: peers.pop(remote_addr, None) continue - try: - for delivered in result.delivered: - if delivered.channel_id != "schema": - continue - try: - message = msgpack.unpackb(delivered.payload, raw=False) - except (msgpack.ExtraData, msgpack.FormatError, msgpack.StackError, ValueError): - continue - if not isinstance(message, dict): - continue - responses = self._handle_connection_message(message, peer.subscriptions, over_rudp=True) - for response in responses: - if unsendable is None: - unsendable = self._send_rudp_schema_frame( - rudp_socket, - remote_addr, - peer.session, - msgpack.packb(response, use_bin_type=True), - message_id=str(response.get("messageId") or ""), - ) - except Exception as error: # noqa: BLE001 - one peer's message never ends the thread - # Whatever a peer's message makes the handling raise is that peer's failure. - # The session recorded the frame's sequence, so it cannot be kept: a retransmit - # would be acknowledged and never handled. The session ends, never the thread, - # and the peer is told. The log names the error type only, because the error's - # own message can quote what the peer sent. - _LOGGER.warning( - "CultMesh RUDP server could not handle a peer's message (%s); that peer's session ended.", - type(error).__name__, - ) - refusal = None - if isinstance(error, _ReplyUnqueueable): - refusal = self._error_response( - _REPLY_UNQUEUEABLE, - message_id=error.message_id, - code="response_unqueueable", + for delivered in result.delivered: + if delivered.channel_id != "schema": + continue + try: + message = msgpack.unpackb(delivered.payload, raw=False) + except (msgpack.ExtraData, msgpack.FormatError, msgpack.StackError, ValueError): + continue + if not isinstance(message, dict): + continue + responses = self._handle_connection_message(message, peer.subscriptions) + for response in responses: + self._send_rudp_schema_frame( + rudp_socket, + remote_addr, + peer.session, + msgpack.packb(response, use_bin_type=True), ) - self._end_refused_peer(rudp_socket, peers, remote_addr, refusal=refusal) - continue - if unsendable is None and ( - packet.reliable or packet.packet_type == CultNetRudpPacketType.DATA or result.delivered - ): - unsendable = self._send_rudp_packet( + if packet.reliable or packet.packet_type == CultNetRudpPacketType.DATA or result.delivered: + self._send_rudp_packet( rudp_socket, remote_addr, peer.session.create_ack_for_received(packet.sequence), ) - if unsendable is not None: - self._end_unsendable_peer(rudp_socket, peers, remote_addr, unsendable) def _poll_rudp_resends( self, @@ -415,10 +282,7 @@ class CultMeshLocalServer: now_ms = _now_ms() for remote_addr, peer in list(peers.items()): for packet in peer.session.due_resends(now_ms): - unsendable = self._send_rudp_packet(rudp_socket, remote_addr, packet) - if unsendable is not None: - self._end_unsendable_peer(rudp_socket, peers, remote_addr, unsendable) - break + self._send_rudp_packet(rudp_socket, remote_addr, packet) def _send_rudp_schema_frame( self, @@ -426,103 +290,26 @@ class CultMeshLocalServer: remote_addr: tuple[str, int], session: CultNetRudpSession, payload: bytes, - *, - message_id: str = "", - ) -> OSError | None: - try: - packets = session.send_many( - "schema", - payload, - CultNetRudpSendOptions(reliable=True, ordered=True, now_ms=_now_ms()), - max_fragment_bytes=self.rudp_max_fragment_bytes, - ) - except ValueError: - # The peer's reliable queue cannot take this reply. The peer is answered, not left - # to time out, and its session ends: see _end_refused_peer. - raise _ReplyUnqueueable(message_id) from None - for packet in packets: - unsendable = self._send_rudp_packet(rudp_socket, remote_addr, packet) - if unsendable is not None: - return unsendable - return None + ) -> None: + for packet in session.send_many( + "schema", + payload, + CultNetRudpSendOptions(reliable=True, ordered=True, now_ms=_now_ms()), + ): + self._send_rudp_packet(rudp_socket, remote_addr, packet) + @staticmethod def _send_rudp_packet( - self, rudp_socket: socket.socket, remote_addr: tuple[str, int], packet: CultNetRudpPacket, - ) -> OSError | None: - # A transient send failure is that peer's lost datagram: counted, never - # raised (raising here ended the RUDP thread for every peer). A permanent - # one (`is_permanent_send_error`) is returned: the datagram can never be - # sent as built, and the caller ends that peer's session. - wire = encode_rudp_packet(packet) - try: - rudp_socket.sendto(wire, remote_addr) - except OSError as error: - if is_permanent_send_error(error): - return error - self._rudp_send_failures += 1 - return None - - def _end_refused_peer( - self, - rudp_socket: socket.socket, - peers: dict[tuple[str, int], _RudpPeerConnection], - remote_addr: tuple[str, int], - *, - refusal: dict[str, Any] | None = None, ) -> None: - """Ends a peer's session that refused one of its messages, and says goodbye. A - refusal, when there is one, goes first, unreliable and unordered: the session ends - with it, so it is never resent and needs no room in the reliable queue. It is built - before the reset and carries acknowledgement fields built after it, which acknowledge - nothing, like the goodbye: the ack would otherwise cover the very frame refused. A - refusal fragment that can never be sent is not dropped: the goodbye names its failure.""" - peer = peers.pop(remote_addr) - packets: list[CultNetRudpPacket] = [] - if refusal is not None: - try: - packets = peer.session.send_many( - "schema", - msgpack.packb(refusal, use_bin_type=True), - CultNetRudpSendOptions(reliable=False, ordered=False, now_ms=_now_ms()), - max_fragment_bytes=self.rudp_max_fragment_bytes, - ) - except ValueError: - packets = [] - peer.session.reset_peer_state() - nothing = peer.session.create_ack() - for packet in packets: - unsendable = self._send_rudp_packet( - rudp_socket, remote_addr, replace(packet, ack=nothing.ack, ack_mask=nothing.ack_mask) - ) - if unsendable is not None: - self._send_rudp_packet(rudp_socket, remote_addr, peer.session.end_unsendable_session(unsendable)) - return - goodbye = peer.session.create_disconnect(b"session refused a packet") - self._send_rudp_packet(rudp_socket, remote_addr, goodbye) - - def _end_unsendable_peer( - self, - rudp_socket: socket.socket, - peers: dict[tuple[str, int], _RudpPeerConnection], - remote_addr: tuple[str, int], - error: OSError, - ) -> None: - """The session owes its peer a packet that can never be sent as built. It ends, - never the thread, and the peer's goodbye names the error.""" - peer = peers.pop(remote_addr, None) - if peer is None: - return - self._send_rudp_packet(rudp_socket, remote_addr, peer.session.end_unsendable_session(error)) + rudp_socket.sendto(encode_rudp_packet(packet), remote_addr) def _handle_connection_message( self, message: dict[str, Any], subscriptions: dict[str, _DatabaseSubscription], - *, - over_rudp: bool = False, ) -> list[dict[str, Any]]: schema_version = message.get("schemaVersion") if schema_version == "cultnet.database_subscribe.v0": @@ -546,7 +333,7 @@ class CultMeshLocalServer: subscriptions.pop(str(message.get("subscriptionId") or ""), None) return [] if schema_version == "cultnet.document_put_raw.v0": - return self._handle_raw_put(message, subscriptions, over_rudp=over_rudp) + return self._handle_raw_put(message, subscriptions) if schema_version == "cultnet.document_delete.v0": return self._handle_raw_delete(message, subscriptions) if schema_version == "cultnet.simulation_observation.v0": @@ -558,8 +345,6 @@ class CultMeshLocalServer: self, message: dict[str, Any], subscriptions: dict[str, _DatabaseSubscription], - *, - over_rudp: bool = False, ) -> list[dict[str, Any]]: document_record = message.get("document") if not isinstance(document_record, dict): @@ -568,22 +353,7 @@ class CultMeshLocalServer: message_id=str(message.get("messageId") or ""), code="malformed_document_put", )] - unservable = self._unservable_put(message, over_rudp=over_rudp) - if unservable is not None: - return [unservable] - try: - change = self.node.database.apply_raw_put_message(message) - except Exception as error: # noqa: BLE001 - a put the store cannot take is that peer's refusal - # The store refused the put: a blank key, a payload its schema cannot decode, a global - # document under another key, or anything a document's own decoder or validator - # raises. It is refused to the peer that sent it; no thread and no other peer is - # affected. Neither the refusal nor the log quotes the error, which can quote the put. - _LOGGER.warning("CultMesh server refused a raw put the store could not take (%s).", type(error).__name__) - return [self._error_response( - "Raw put document could not be stored.", - message_id=str(message.get("messageId") or ""), - code="malformed_document_put", - )] + change = self.node.database.apply_raw_put_message(message) if change is None: return [self._error_response( "Raw put message did not apply to a registered document.", @@ -785,7 +555,7 @@ class CultMeshLocalServer: details={"documentCount": document_count, "maxSnapshotDocuments": self.max_snapshot_documents}, ) if self.max_snapshot_bytes is not None: - response_bytes = _snapshot_response_bytes(response) + response_bytes = len(msgpack.packb(response, use_bin_type=True)) if response_bytes > self.max_snapshot_bytes: return self._error_response( f"Snapshot byte limit exceeded: {response_bytes} > {self.max_snapshot_bytes}.", @@ -795,51 +565,6 @@ class CultMeshLocalServer: ) return response - def _unservable_put(self, message: dict[str, Any], *, over_rudp: bool) -> dict[str, Any] | None: - """The refusal for a put this server could never serve, or None. The document alone, - as a snapshot would serve it under the shortest message id, must fit max_snapshot_bytes; - a put arriving over RUDP must also fit, as fragments of rudp_max_fragment_bytes, in one - message and the peer's reliable queue. A put whose document has no string recordKey or - binary payload could never be stored or served, and is refused as malformed.""" - document_record = message.get("document") - if not ( - isinstance(document_record, dict) - and isinstance(document_record.get("recordKey"), str) - and isinstance(document_record.get("payload"), (bytes, bytearray)) - ): - return self._error_response( - "Raw put documents must carry a string recordKey and a binary payload.", - message_id=str(message.get("messageId") or ""), - code="malformed_document_put", - ) - if self.max_snapshot_bytes is None and not over_rudp: - return None - alone = self.node.database.raw_put_served_alone(message, message_id=_SHORTEST_SERVED_MESSAGE_ID) - if alone is None: - return None - response_bytes = _snapshot_response_bytes(alone) - details: dict[str, Any] = {"responseBytes": response_bytes, "maxSnapshotBytes": self.max_snapshot_bytes} - fits = self.max_snapshot_bytes is None or response_bytes <= self.max_snapshot_bytes - limits = f"limit is {self.max_snapshot_bytes}" - if over_rudp: - fragment_count = max(1, -(-response_bytes // self.rudp_max_fragment_bytes)) - max_fragment_count = self._max_rudp_reply_fragments() - details |= {"fragmentCount": fragment_count, "maxFragmentCount": max_fragment_count} - fits = fits and fragment_count <= max_fragment_count - limits = ( - f"it takes {fragment_count} fragments; limits are " - f"{'unbounded' if self.max_snapshot_bytes is None else self.max_snapshot_bytes} bytes " - f"and {max_fragment_count} fragments" - ) - if fits: - return None - return self._error_response( - f"Document can never be served: its snapshot response is {response_bytes} bytes; {limits}.", - message_id=str(message.get("messageId") or ""), - code="document_unservable", - details=details, - ) - @staticmethod def _error_response( error: str, @@ -994,8 +719,3 @@ def _infer_schema_name(schema_id: str) -> str | None: return None version = schema_id[marker + 2:] return schema_id[:marker] if version.isdigit() else None - - -def _snapshot_response_bytes(response: dict[str, Any]) -> int: - """The one measure of a snapshot response, shared by the snapshot path and put admission.""" - return len(msgpack.packb(response, use_bin_type=True)) diff --git a/packages/cultmesh-py/tests/test_cultmesh.py b/packages/cultmesh-py/tests/test_cultmesh.py index cdf2c965..b6a21bb8 100644 --- a/packages/cultmesh-py/tests/test_cultmesh.py +++ b/packages/cultmesh-py/tests/test_cultmesh.py @@ -1,6 +1,5 @@ from __future__ import annotations -import errno import json import os import socket @@ -15,8 +14,6 @@ from dataclasses import dataclass from datetime import UTC, datetime, timedelta from pathlib import Path from typing import Any, Callable - -import msgpack from cultcache_py import ( CultCache, SingleFileMessagePackBackingStore, @@ -50,24 +47,16 @@ from cultnet_py import ( CultNetSimulationConsensusCandidate, CultNetSimulationObservation, CultNetSimulationObservationHub, - CultNetRudpPacketType, - CultNetRudpSendOptions, - CultNetRudpSession, - CultNetRudpSessionOptions, CultNetRudpSocketMode, CultNetRudpSocketTransportConnection, CultNetRudpSocketTransportOptions, apply_shard_log_response, - create_rudp_schema_transport, - decode_rudp_packet, document_delete, document_put_raw, - encode_rudp_packet, hello, simulation_observation, snapshot_request, ) -from cultnet_py.cultmesh_contracts import VERSE_CATALOG_REQUEST from cultmesh_py import create_node from cultmesh_py import ( CultMesh, @@ -224,37 +213,6 @@ class CultMeshTests(unittest.TestCase): self.assertEqual(received_messages[0]["schemaVersion"], "cultnet.schema_catalog_request.v0") self.assertEqual(received_messages[0]["messageId"], "rudp-transport-factory") - def _rudp_client_bound_host(self, endpoint: str, bind_host: str | None = None) -> str: - client = CultMesh.create_rudp_client("python-cultmesh-bind-client", 0x10203060, endpoint, bind_host=bind_host) - try: - return client.socket.getsockname()[0] - finally: - client.socket.close() - - # A client bound to loopback cannot send to another host on Windows, so a - # client for a remote endpoint binds the unspecified address of its family. - def test_cultmesh_rudp_client_for_a_remote_endpoint_binds_the_unspecified_address(self) -> None: - self.assertEqual(self._rudp_client_bound_host("rudp://10.77.0.1:17872"), "0.0.0.0") - self.assertEqual(self._rudp_client_bound_host("rudp://[2001:db8::1]:17872"), "::") - - def test_cultmesh_rudp_client_for_a_loopback_endpoint_binds_loopback(self) -> None: - self.assertEqual(self._rudp_client_bound_host("rudp://127.0.0.1:17872"), "127.0.0.1") - self.assertEqual(self._rudp_client_bound_host("rudp://[::1]:17872"), "::1") - - def test_cultmesh_rudp_client_binds_an_explicit_bind_host_whatever_the_endpoint(self) -> None: - self.assertEqual(self._rudp_client_bound_host("rudp://10.77.0.1:17872", "127.0.0.1"), "127.0.0.1") - self.assertEqual(self._rudp_client_bound_host("rudp://127.0.0.1:17872", "0.0.0.0"), "0.0.0.0") - - def test_cultmesh_rudp_server_binds_loopback_unless_told_otherwise(self) -> None: - loopback = CultMesh.create_rudp_server("python-cultmesh-bind-server", 0x10203061) - anywhere = CultMesh.create_rudp_server("python-cultmesh-bind-server", 0x10203062, bind_host="0.0.0.0") - try: - self.assertEqual(loopback.socket.getsockname()[0], "127.0.0.1") - self.assertEqual(anywhere.socket.getsockname()[0], "0.0.0.0") - finally: - loopback.socket.close() - anywhere.socket.close() - def test_cultmesh_facade_creates_rudp_client_from_peer_endpoint(self) -> None: connection_id = 0x10203042 server = CultMesh.create_rudp_server( @@ -1801,11 +1759,11 @@ class CultMeshTests(unittest.TestCase): ) self.assertEqual( builtins.list()[0].schema_id, - "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.transport-profile.schema.json", + "https://github.com/GameCult/cultnet-ts/contracts/cultnet.transport-profile.schema.json", ) self.assertIsNone(builtins.list()[0].schema_json) peer_exchange_schema_id = ( - "https://github.com/GameCult/CultLib/contracts/cultnet/cultmesh.peer-exchange-request.schema.json" + "https://github.com/GameCult/cultnet-ts/contracts/cultmesh.peer-exchange-request.schema.json" ) filtered_builtin = CultMesh.create_builtin_schema_catalog( include_schema_json=True, @@ -3759,11 +3717,7 @@ class CultMeshTests(unittest.TestCase): finally: self._terminate_process(process) - def test_cultmesh_daemon_refuses_a_snapshot_document_limit_of_zero_at_startup(self) -> None: - # A limit of zero is a server that could answer no snapshot, which the Rust document - # server's options also refuse; the daemon passes the flag to the server, and exits with - # a usage error naming the rule instead of serving. The limit's enforcement as a peer error is pinned - # in process by test_cultmesh_local_server_rejects_oversized_snapshot_responses. + def test_cultmesh_daemon_enforces_snapshot_document_limit_as_peer_error(self) -> None: with tempfile.TemporaryDirectory() as temp: ready_path = Path(temp) / "ready.json" package_src = Path(__file__).resolve().parents[1] / "src" @@ -3774,7 +3728,7 @@ class CultMeshTests(unittest.TestCase): if not existing_pythonpath else f"{package_src}{os.pathsep}{existing_pythonpath}" ) - completed = subprocess.run( + process = subprocess.Popen( [ sys.executable, "-m", @@ -3789,27 +3743,25 @@ class CultMeshTests(unittest.TestCase): "--ready-file", str(ready_path), ], - capture_output=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True, env=env, - timeout=30, ) - # A usage error from argparse: exit status 2, the rule named, no traceback. - self.assertEqual(completed.returncode, 2, completed.stderr) - self.assertIn("error: max_snapshot_documents must be greater than zero", completed.stderr) - self.assertNotIn("Traceback", completed.stderr) - self.assertFalse(ready_path.exists()) - # A port no socket can bind is a usage error too. - completed = subprocess.run( - [sys.executable, "-m", "cultmesh_py.daemon", "--port", "99999"], - capture_output=True, - text=True, - env=env, - timeout=30, - ) - self.assertEqual(completed.returncode, 2, completed.stderr) - self.assertIn("port must be between 0 and 65535", completed.stderr) - self.assertNotIn("Traceback", completed.stderr) + try: + ready = self._wait_for_ready_file(process, ready_path) + self.assertEqual(ready["snapshotLimits"], {"maxSnapshotBytes": None, "maxSnapshotDocuments": 0}) + client = CultMesh.create_client("127.0.0.1", int(ready["port"]), timeout_seconds=2.0) + + with self.assertRaisesRegex(CultNetPeerError, "Snapshot document limit exceeded") as raised: + client.fetch_snapshot_response(schema_ids=["cultcache.interop-note"]) + + self.assertEqual(raised.exception.response["schemaVersion"], "cultnet.error.v0") + self.assertEqual(raised.exception.response["code"], "snapshot_document_limit_exceeded") + self.assertEqual(raised.exception.response["details"]["documentCount"], 1) + self.assertEqual(raised.exception.response["details"]["maxSnapshotDocuments"], 0) + finally: + self._terminate_process(process) def test_cultmesh_daemon_serves_opt_in_simulation_observations(self) -> None: with tempfile.TemporaryDirectory() as temp: @@ -4081,7 +4033,7 @@ class CultMeshTests(unittest.TestCase): self.assertIn("cultmesh.peer_exchange_response.v0", wire_descriptors) self.assertIn("cultnet.error.v0", {descriptor.schema_version for descriptor in synced_wire_descriptors}) self.assertIn("cultnet.document_put_raw.v0", {descriptor.schema_version for descriptor in synced_wire_descriptors}) - self.assertIsNotNone(synced_schema_catalog.get("https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.document-put-raw.schema.json")) + self.assertIsNotNone(synced_schema_catalog.get("https://github.com/GameCult/cultnet-ts/contracts/cultnet.document-put-raw.schema.json")) self.assertEqual(snapshot_response["documents"][0]["recordKey"], "note:1") self.assertEqual(typed_snapshot_response.documents[0].record_key, "note:1") self.assertEqual(typed_snapshot_response.documents[0].schema_id, "mesh.server_note.v1") @@ -4341,638 +4293,6 @@ class CultMeshTests(unittest.TestCase): self.assertEqual(error["details"]["documentCount"], 2) self.assertEqual(error["details"]["maxSnapshotDocuments"], 1) - def test_cultmesh_local_server_refuses_a_put_it_could_never_serve(self) -> None: - # A put is admitted only if some snapshot request could return it. The put arrives under a - # long foreign schema alias and is stored and served under the shorter local schema id, so - # the size that decides is the served one, not the put's own. - document = define_database_entry_type( - "mesh.served_bound_note", - [("schema_version", 0), ("body", 1)], - schema_id="sha256:mesh-served-bound", - schema_name="mesh.served_bound_note", - schema_version="mesh.served_bound_note.v1", - ) - - def put(message_id: str, key: str, body_length: int) -> dict[str, Any]: - return document_put_raw( - message_id=message_id, - key=key, - schema_id="runtime.generated.mesh.served_bound_note.ui.99", - stored_at="2026-09-30T00:00:00Z", - payload=document.encode_payload({ - "schema_version": "mesh.served_bound_note.v1", - "body": "x" * body_length, - }), - ).to_wire() - - def exchange(server: Any, *messages: dict[str, Any]) -> tuple[dict[str, Any], bytes]: - client = CultMesh.create_client("127.0.0.1", server.port, timeout_seconds=2.0) - with client.open_transport() as transport: - for message in messages: - transport.send("schema", msgpack.packb(message, use_bin_type=True)) - payload = transport.receive().payload - return msgpack.unpackb(payload, raw=False), payload - - empty_id_snapshot = snapshot_request(message_id="").to_wire() - - # The bound is what the server actually serves for the at-bound document alone, under the - # shortest message id it answers (an empty one), measured on an unbounded server. - def served_alone_bytes(key: str, body_length: int) -> int: - node = CultMesh.create_node(runtime_id="mesh-served-bound-probe") - node.database.register_document(document) - server = CultMesh.serve_node(node, enable_rudp=False) - try: - response, payload = exchange(server, put("probe", key, body_length), empty_id_snapshot) - finally: - server.stop() - self.assertEqual(response["schemaVersion"], "cultnet.snapshot_response_raw.v0") - self.assertEqual(len(response["documents"]), 1) - return len(payload) - - limit = served_alone_bytes("note:fits", 100) - self.assertEqual(served_alone_bytes("note:over", 101), limit + 1, "fixture: the documents must straddle the bound by one byte") - - node = CultMesh.create_node(runtime_id="mesh-served-bound") - node.database.register_document(document) - server = CultMesh.serve_node(node, max_snapshot_bytes=limit, enable_rudp=False) - try: - refused, _ = exchange(server, put("put-over", "note:over", 101)) - stored_after_refusal = node.database.get(document, "note:over") - served, served_payload = exchange(server, put("put-at", "note:fits", 100), empty_id_snapshot) - finally: - server.stop() - - self.assertEqual(refused["schemaVersion"], "cultnet.error.v0") - self.assertEqual(refused["messageId"], "put-over") - self.assertEqual(refused["code"], "document_unservable") - self.assertEqual(refused["details"], {"responseBytes": limit + 1, "maxSnapshotBytes": limit}) - self.assertIn(str(limit + 1), refused["error"]) - self.assertIn(str(limit), refused["error"]) - self.assertIsNone(stored_after_refusal) - - self.assertEqual(served["schemaVersion"], "cultnet.snapshot_response_raw.v0") - self.assertEqual([record["recordKey"] for record in served["documents"]], ["note:fits"]) - self.assertEqual(served["documents"][0]["schemaId"], document.catalog_entry().schema_id) - self.assertEqual(len(served_payload), limit) - - def _rudp_bound_note(self) -> Any: - return define_database_entry_type( - "mesh.rudp_bound_note", - [("schema_version", 0), ("body", 1)], - schema_id="sha256:mesh-rudp-bound", - schema_name="mesh.rudp_bound_note", - schema_version="mesh.rudp_bound_note.v1", - ) - - @staticmethod - def _rudp_note_put(document: Any, message_id: str, key: str, body_length: int) -> dict[str, Any]: - return document_put_raw( - message_id=message_id, - key=key, - schema_id=document.catalog_entry().schema_id, - stored_at="2026-09-30T00:00:00Z", - payload=document.encode_payload({"schema_version": "mesh.rudp_bound_note.v1", "body": "x" * body_length}), - ).to_wire() - - @staticmethod - def _rudp_exchange(server: Any, *messages: dict[str, Any]) -> tuple[dict[str, Any], bytes]: - """Sends each message over RUDP in 1200-byte fragments; returns the first reply.""" - transport = create_rudp_schema_transport( - host="127.0.0.1", - port=server.port, - connection_id=server.rudp_connection_id, - timeout_seconds=4.0, - max_fragment_bytes=1200, - ) - try: - for message in messages: - transport.send("schema", msgpack.packb(message, use_bin_type=True)) - payload = transport.receive(timeout_seconds=4.0).payload - finally: - transport.close() - return msgpack.unpackb(payload, raw=False), payload - - def test_cultmesh_local_server_serves_a_100_kb_put_over_rudp_in_fragments(self) -> None: - # The reply is larger than any one UDP datagram: it arrives only because it is sent - # in fragments, and the RUDP thread serves on afterwards. - document = self._rudp_bound_note() - node = CultMesh.create_node(runtime_id="mesh-rudp-large") - node.database.register_document(document) - server = CultMesh.serve_node(node) - try: - served, payload = self._rudp_exchange( - server, - self._rudp_note_put(document, "put-large", "note:large", 100_000), - snapshot_request(message_id="large").to_wire(), - ) - again, _ = self._rudp_exchange(server, snapshot_request(message_id="again").to_wire()) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - server.stop() - self.assertEqual(served["schemaVersion"], "cultnet.snapshot_response_raw.v0") - self.assertEqual([record["recordKey"] for record in served["documents"]], ["note:large"]) - self.assertGreater(len(served["documents"][0]["payload"]), 100_000) - self.assertGreater(len(payload), 65_507, "fixture: the reply cannot be one UDP datagram") - self.assertEqual(again["messageId"], "again") - self.assertTrue(alive) - self.assertEqual(server.rudp_send_failures, 0) - - def _rudp_body_for(self, document: Any, key: str) -> Callable[[int], int]: - """The body length whose document, keyed `key`, is served alone under the empty message - id in exactly the given bytes, measured on an unbounded server: what a snapshot sends.""" - - def served_alone_bytes(body_length: int) -> int: - node = CultMesh.create_node(runtime_id="mesh-rudp-bound-probe") - node.database.register_document(document) - server = CultMesh.serve_node(node) - try: - _, payload = self._rudp_exchange( - server, self._rudp_note_put(document, "probe", key, body_length), - snapshot_request(message_id="").to_wire(), - ) - finally: - server.stop() - return len(payload) - - probe = served_alone_bytes(500) - - def body_for(served_bytes: int) -> int: - body_length = 500 + served_bytes - probe - self.assertEqual(served_alone_bytes(body_length), served_bytes, "fixture: served size is linear in the body") - return body_length - - return body_for - - def test_cultmesh_local_server_refuses_a_rudp_put_whose_reply_would_overflow_the_reliable_queue(self) -> None: - # Replies go in fragments of 100 bytes and a peer's reliable queue holds 8: a put over RUDP - # whose served reply takes 8 fragments is admitted and served, 9 or 20 are refused. A - # snapshot of two such documents needs 16 and cannot be queued: the peer is answered with a - # small cultnet.error.v0 rather than left to time out, its session ends, and the thread - # serves on. - document = self._rudp_bound_note() - body_for = self._rudp_body_for(document, "note:q") - - node = CultMesh.create_node(runtime_id="mesh-rudp-bound") - node.database.register_document(document) - server = CultMesh.serve_node(node, rudp_max_fragment_bytes=100, rudp_max_pending_reliable_packets=8) - try: - refusals = [ - self._rudp_exchange(server, self._rudp_note_put(document, f"put-{served}", "note:q", body_for(served)))[0] - for served in (2000, 801) - ] - stored_after_refusals = node.database.get(document, "note:q") - served, served_payload = self._rudp_exchange( - server, - self._rudp_note_put(document, "put-at", "note:q", body_for(800)), - snapshot_request(message_id="").to_wire(), - ) - unqueueable, _ = self._rudp_exchange( - server, - self._rudp_note_put(document, "put-r", "note:r", body_for(800)), - snapshot_request(message_id="both").to_wire(), - ) - failures_after = server.rudp_send_failures - # An empty snapshot fits the small queue; a hello reply would not. - after_reply, _ = self._rudp_exchange( - server, snapshot_request(message_id="after-queue", record_keys=["note:none"]).to_wire() - ) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - server.stop() - - for refusal, (served_bytes, fragments) in zip(refusals, ((2000, 20), (801, 9))): - self.assertEqual(refusal["schemaVersion"], "cultnet.error.v0") - self.assertEqual(refusal["messageId"], f"put-{served_bytes}") - self.assertEqual(refusal["code"], "document_unservable") - self.assertEqual(refusal["details"], { - "responseBytes": served_bytes, - "maxSnapshotBytes": None, - "fragmentCount": fragments, - "maxFragmentCount": 8, - }) - self.assertIn(f"{served_bytes} bytes; it takes {fragments} fragments", refusal["error"]) - self.assertNotIn("note:q", refusal["error"]) - self.assertIsNone(stored_after_refusals) - self.assertEqual(served["schemaVersion"], "cultnet.snapshot_response_raw.v0") - self.assertEqual([record["recordKey"] for record in served["documents"]], ["note:q"]) - self.assertEqual(len(served_payload), 800) - self.assertEqual(unqueueable["schemaVersion"], "cultnet.error.v0") - self.assertEqual(unqueueable["messageId"], "both") - self.assertEqual(unqueueable["code"], "response_unqueueable") - self.assertEqual(failures_after, 0) - self.assertEqual(after_reply["messageId"], "after-queue") - self.assertTrue(alive) - - class _RawPeer: - """A peer driven packet by packet, so a test decides what it acknowledges: nothing.""" - - def __init__(self, server: Any) -> None: - self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.sock.bind(("127.0.0.1", 0)) - self.sock.settimeout(0.05) - self.address = self.sock.getsockname()[:2] - self.target = ("127.0.0.1", server.port) - self.session = CultNetRudpSession( - CultNetRudpSessionOptions( - connection_id=server.rudp_connection_id, initial_sequence=100, resend_delay_ms=100_000 - ) - ) - self.sock.sendto(encode_rudp_packet(self.session.create_connect(0)), self.target) - accept = self.receive(1.0) - assert accept is not None and accept.packet_type == CultNetRudpPacketType.ACCEPT, accept - self.session.receive(accept, 1) - - def receive(self, timeout: float = 0.3) -> Any: - deadline = time.monotonic() + timeout - while time.monotonic() < deadline: - try: - wire, _ = self.sock.recvfrom(65535) - except (TimeoutError, socket.timeout): - continue - return decode_rudp_packet(wire) - return None - - def drain(self, timeout: float = 0.5) -> list[Any]: - # Bounded overall: the server resends what the peer never acknowledges. - packets = [] - deadline = time.monotonic() + timeout - while time.monotonic() < deadline: - packet = self.receive(0.05) - if packet is not None: - packets.append(packet) - return packets - - def send(self, message: dict[str, Any]) -> list[int]: - packets = self.session.send_many( - "schema", - msgpack.packb(message, use_bin_type=True), - CultNetRudpSendOptions(reliable=True, ordered=True, now_ms=2), - max_fragment_bytes=1200, - ) - for packet in packets: - self.sock.sendto(encode_rudp_packet(packet), self.target) - return [packet.sequence for packet in packets] - - def close(self) -> None: - self.sock.close() - - @staticmethod - def _acknowledges(packet: Any, sequence: int) -> bool: - return packet.ack == sequence or any( - packet.ack_mask & (1 << bit) and packet.ack > bit and packet.ack - bit - 1 == sequence - for bit in range(32) - ) - - def _brim_server(self) -> tuple[Any, Any]: - """A server whose peer's reliable queue (8) is filled exactly by an 8-fragment reply the - peer never acknowledges, and the peer.""" - document = self._rudp_bound_note() - node = CultMesh.create_node(runtime_id="mesh-rudp-brim") - node.database.register_document(document) - server = CultMesh.serve_node(node, rudp_max_fragment_bytes=100, rudp_max_pending_reliable_packets=8) - - def served(body: int) -> int: - put = self._rudp_note_put(document, "p", "note:q", body) - return len(msgpack.packb(node.database.raw_put_served_alone(put, message_id=""), use_bin_type=True)) - - body = 400 + 800 - served(400) - self.assertEqual(served(body), 800, "fixture: served size is linear in the body") - node.database.apply_raw_put_message(self._rudp_note_put(document, "p", "note:q", body)) - peer = self._RawPeer(server) - peer.send(snapshot_request(message_id="", record_keys=["note:q"]).to_wire()) - first = {p.sequence for p in peer.drain(0.3) if p.packet_type == CultNetRudpPacketType.DATA} - self.assertEqual(len(first), 8, "fixture: the first reply fills the queue exactly") - return server, peer - - def test_cultmesh_local_server_answers_a_peer_whose_queue_is_full_to_the_brim(self) -> None: - # The next reply cannot be queued. The peer is answered with a cultnet.error.v0 that takes - # no room in the full queue and acknowledges nothing the peer sent, then its session ends. - server, peer = self._brim_server() - try: - refused = peer.send(snapshot_request(message_id="b", record_keys=["note:none"]).to_wire()) - packets = peer.drain(0.5) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - peer.close() - server.stop() - parts = sorted( - ( - p for p in packets - if p.packet_type == CultNetRudpPacketType.DATA and p.channel_id == "schema" and not p.reliable - ), - key=lambda p: p.fragment_index, - ) - self.assertTrue(parts, "the refusal reaches the peer") - for part in parts: - self.assertFalse( - any(self._acknowledges(part, sequence) for sequence in refused), - f"the refusal acknowledges the refused request: ack={part.ack} mask={part.ack_mask:#x}", - ) - refusal = msgpack.unpackb(b"".join(bytes(p.payload) for p in parts), raw=False) - self.assertEqual(refusal["schemaVersion"], "cultnet.error.v0") - self.assertEqual(refusal["messageId"], "b") - self.assertEqual(refusal["code"], "response_unqueueable") - goodbyes = [bytes(p.payload) for p in packets if p.packet_type == CultNetRudpPacketType.DISCONNECT] - self.assertEqual(goodbyes, [b"session refused a packet"], "then the session ends") - self.assertTrue(alive) - - def test_cultmesh_local_server_names_a_refusal_that_can_never_be_sent_in_the_goodbye(self) -> None: - # The refusal's own fragment fails permanently: the failure is not dropped, the goodbye - # names it by its fixed code, never the error's text. - import errno - - server, peer = self._brim_server() - original_sendto = socket.socket.sendto - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - packet = decode_rudp_packet(data) - if ( - args and tuple(args[-1]) == tuple(peer.address) - and packet.packet_type == CultNetRudpPacketType.DATA and not packet.reliable - ): - raise OSError(errno.EMSGSIZE, "Message too long CANARY-7f3a") - return original_sendto(sock, data, *args) - - try: - with patch.object(socket.socket, "sendto", sendto): - peer.send(snapshot_request(message_id="b", record_keys=["note:none"]).to_wire()) - packets = peer.drain(0.5) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - peer.close() - server.stop() - self.assertFalse( - [p for p in packets if p.packet_type == CultNetRudpPacketType.DATA and not p.reliable], - "the refusal could not be sent", - ) - goodbyes = [bytes(p.payload) for p in packets if p.packet_type == CultNetRudpPacketType.DISCONNECT] - self.assertEqual(goodbyes, [b"packet could not be sent: EMSGSIZE"]) - self.assertTrue(alive) - - def test_cultmesh_local_server_refuses_a_tcp_message_it_cannot_handle_and_serves_on(self) -> None: - # Messages whose handling raises: the TCP peer is refused with fixed text, the log names - # the error type only, and the connection's thread serves its next message. - shapes = [ - {"schemaVersion": "cultnet.snapshot_request.v0", "messageId": "snapshot", "recordKeys": 5}, - {"schemaVersion": "cultnet.shard_log_request.v0", "messageId": "shard-log", "shardId": "a", "afterSequence": "CANARY-7f3a"}, - {"schemaVersion": "cultnet.database_subscribe.v0", "messageId": "subscribe", "subscriptionId": "s", "schemaIds": 5}, - {"schemaVersion": "cultnet.schema_catalog_request.v0", "messageId": "catalog", "schemaIds": 5}, - {"schemaVersion": VERSE_CATALOG_REQUEST, "messageId": "verse", "verseIds": 5}, - ] - deaths: list[str] = [] - original_hook = threading.excepthook - threading.excepthook = lambda args: deaths.append(f"{args.exc_type.__name__}") - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-tcp-shapes")) - try: - with self.assertLogs("cultmesh_py.server", level="WARNING") as logs: - with CultMesh.create_client("127.0.0.1", server.port, timeout_seconds=4.0).open_transport() as transport: - refusals = [] - for shape in shapes: - transport.send("schema", msgpack.packb(shape, use_bin_type=True)) - refusals.append((shape["messageId"], msgpack.unpackb(transport.receive().payload, raw=False))) - transport.send("schema", msgpack.packb(hello(runtime_id="same-connection").to_wire(), use_bin_type=True)) - after = msgpack.unpackb(transport.receive().payload, raw=False) - finally: - server.stop() - threading.excepthook = original_hook - for message_id, refusal in refusals: - self.assertEqual(refusal["schemaVersion"], "cultnet.error.v0", message_id) - self.assertEqual(refusal["messageId"], message_id) - self.assertEqual(refusal["code"], "message_unhandled", message_id) - self.assertEqual(refusal["error"], "The message could not be handled.", message_id) - self.assertEqual(after["schemaVersion"], "cultnet.hello.v0") - self.assertEqual(deaths, []) - self.assertEqual(len(logs.output), len(shapes)) - self.assertFalse([line for line in logs.output if "CANARY" in line]) - - def test_cultmesh_local_server_refuses_a_rudp_put_whose_reply_needs_more_than_65535_fragments(self) -> None: - # One message carries at most 65535 fragments, however deep the queue: with one-byte - # fragments a put served in 65536 bytes is refused, one served in 65535 is stored. - document = self._rudp_bound_note() - body_for = self._rudp_body_for(document, "note:w") - node = CultMesh.create_node(runtime_id="mesh-rudp-wide") - node.database.register_document(document) - server = CultMesh.serve_node(node, rudp_max_fragment_bytes=1) - try: - transport = create_rudp_schema_transport( - host="127.0.0.1", port=server.port, connection_id=server.rudp_connection_id, - timeout_seconds=4.0, max_fragment_bytes=1200, - ) - try: - transport.send("schema", msgpack.packb(self._rudp_note_put(document, "put-over", "note:w", body_for(65_536)), use_bin_type=True)) - refusal = msgpack.unpackb(transport.receive(timeout_seconds=8.0).payload, raw=False) - transport.send("schema", msgpack.packb(self._rudp_note_put(document, "put-at", "note:w", body_for(65_535)), use_bin_type=True)) - deadline = time.monotonic() + 4.0 - while node.database.get(document, "note:w") is None and time.monotonic() < deadline: - transport.receive_once() - time.sleep(0.005) - finally: - transport.close() - stored = node.database.get(document, "note:w") - finally: - server.stop() - self.assertEqual(refusal["code"], "document_unservable") - self.assertEqual(refusal["details"]["fragmentCount"], 65_536) - self.assertEqual(refusal["details"]["maxFragmentCount"], 65_535) - self.assertIsNotNone(stored) - - def test_cultmesh_local_server_rudp_thread_survives_a_datagram_that_cannot_leave(self) -> None: - # Fragments larger than any UDP datagram: the reply's one packet can never be sent as - # built. That is a permanent failure: it ends that peer's session and is not counted as - # a lost datagram; the thread serves the next peer. - document = self._rudp_bound_note() - node = CultMesh.create_node(runtime_id="mesh-rudp-emsgsize") - node.database.register_document(document) - server = CultMesh.serve_node(node, rudp_max_fragment_bytes=200_000) - try: - transport = create_rudp_schema_transport( - host="127.0.0.1", port=server.port, connection_id=server.rudp_connection_id, - timeout_seconds=4.0, max_fragment_bytes=1200, - ) - try: - transport.send("schema", msgpack.packb(self._rudp_note_put(document, "put-large", "note:big", 80_000), use_bin_type=True)) - transport.send("schema", msgpack.packb(snapshot_request(message_id="big").to_wire(), use_bin_type=True)) - deadline = time.monotonic() + 1.0 - while time.monotonic() < deadline: - try: - transport.receive_once() - except ConnectionError: - break - time.sleep(0.005) - finally: - transport.close() - failures = server.rudp_send_failures - hello_reply, _ = self._rudp_exchange(server, hello(runtime_id="after").to_wire()) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - server.stop() - self.assertEqual(failures, 0) - self.assertEqual(hello_reply["schemaVersion"], "cultnet.hello.v0") - self.assertTrue(alive) - - def test_cultmesh_local_server_refuses_a_malformed_put_over_rudp_and_serves_on(self) -> None: - # A put whose document has no string recordKey or no binary payload could never be stored - # or served: it is refused as malformed before any sizing reads it, and the RUDP thread - # serves the next peer. - document = self._rudp_bound_note() - node = CultMesh.create_node(runtime_id="mesh-rudp-malformed") - node.database.register_document(document) - server = CultMesh.serve_node(node) - try: - refusals = [] - for field_name, value in ( - ("recordKey", None), - ("recordKey", 5), - ("payload", None), - ("payload", "not binary"), - ): - put = self._rudp_note_put(document, f"bad-{field_name}-{value}", "note:bad", 10) - if value is None: - del put["document"][field_name] - else: - put["document"][field_name] = value - refusal, _ = self._rudp_exchange(server, put) - refusals.append((put["messageId"], refusal)) - after, _ = self._rudp_exchange(server, snapshot_request(message_id="after").to_wire()) - alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - finally: - server.stop() - for message_id, refusal in refusals: - self.assertEqual(refusal["schemaVersion"], "cultnet.error.v0", message_id) - self.assertEqual(refusal["messageId"], message_id) - self.assertEqual(refusal["code"], "malformed_document_put", message_id) - self.assertEqual(after["messageId"], "after") - self.assertEqual(after["documents"], []) - self.assertTrue(alive) - - def test_cultmesh_local_server_refuses_a_put_its_store_cannot_take_and_serves_on(self) -> None: - # Well-formed puts the store refuses: a blank key, a payload that is not MessagePack, a - # payload its schema cannot decode, a global document under another key. Each is refused - # to the peer that sent it, over RUDP and over TCP; the RUDP thread lives, the TCP - # connection serves its next message, and other peers are served. - document = self._rudp_bound_note() - global_document = define_database_entry_type( - "mesh.rudp_global_note", - [("schema_version", 0), ("body", 1)], - schema_id="sha256:mesh-rudp-global", - schema_name="mesh.rudp_global_note", - schema_version="mesh.rudp_global_note.v1", - global_document=True, - ) - - def cases() -> list[dict[str, Any]]: - puts = [] - for name, field_name, value in ( - ("empty-key", "recordKey", ""), - ("blank-key", "recordKey", " "), - ("garbage-payload", "payload", bytes([0xC1])), - ("int-payload", "payload", msgpack.packb(5)), - ): - put = self._rudp_note_put(document, name, "note:ok", 10) - put["document"][field_name] = value - puts.append(put) - puts.append(self._rudp_note_put(global_document, "global-wrong-key", "not-global", 10)) - return puts - - node = CultMesh.create_node(runtime_id="mesh-unstorable-put") - node.database.register_document(document) - node.database.register_document(global_document) - server = CultMesh.serve_node(node) - try: - rudp_refusals = [(put["messageId"], self._rudp_exchange(server, put)[0]) for put in cases()] - rudp_after, _ = self._rudp_exchange(server, hello(runtime_id="rudp-after").to_wire()) - rudp_alive = server._rudp_thread is not None and server._rudp_thread.is_alive() - - tcp_refusals = [] - with CultMesh.create_client("127.0.0.1", server.port, timeout_seconds=4.0).open_transport() as transport: - for put in cases(): - transport.send("schema", msgpack.packb(put, use_bin_type=True)) - tcp_refusals.append((put["messageId"], msgpack.unpackb(transport.receive().payload, raw=False))) - transport.send("schema", msgpack.packb(hello(runtime_id="same-connection").to_wire(), use_bin_type=True)) - same_connection = msgpack.unpackb(transport.receive().payload, raw=False) - other_connection = CultMesh.create_client("127.0.0.1", server.port, timeout_seconds=4.0).request( - hello(runtime_id="other-connection").to_wire(), expected_schema_version="cultnet.hello.v0" - ) - finally: - server.stop() - self.assertEqual(len(rudp_refusals), 5) - for message_id, refusal in rudp_refusals + tcp_refusals: - self.assertEqual(refusal["schemaVersion"], "cultnet.error.v0", message_id) - self.assertEqual(refusal["messageId"], message_id) - self.assertEqual(refusal["code"], "malformed_document_put", message_id) - self.assertNotIn("note:ok", refusal["error"], message_id) - self.assertEqual(len(tcp_refusals), 5) - self.assertEqual(rudp_after["schemaVersion"], "cultnet.hello.v0") - self.assertTrue(rudp_alive) - self.assertEqual(same_connection["schemaVersion"], "cultnet.hello.v0") - self.assertEqual(other_connection["schemaVersion"], "cultnet.hello.v0") - self.assertIsNone(node.database.get(document, "note:ok")) - - def test_cultmesh_local_server_refuses_options_that_could_answer_nothing(self) -> None: - # The Rust document server's option rules: every limit is greater than zero, and the limits - # leave room for an empty snapshot, the smallest response the server sends. One-byte - # fragments and a queue of 16 could never carry one, so no reply would ever be sent. - node = CultMesh.create_node(runtime_id="mesh-rudp-options") - probe = CultMesh.serve_node(node) - try: - _, empty_payload = self._rudp_exchange(probe, snapshot_request(message_id="").to_wire()) - finally: - probe.stop() - empty = len(empty_payload) - self.assertGreater(empty, 16, "fixture: an empty snapshot takes more than 16 one-byte fragments") - self.assertNotEqual(empty % (empty - 1), 0, "fixture: empty - 1 byte fragments leave a remainder") - - def refused(**options: Any) -> str: - server = None - try: - with self.assertRaises(ValueError, msg=str(options)) as raised: - server = CultMesh.serve_node(node, **options) - finally: - if server is not None: - server.stop() - return str(raised.exception) - - def accepted(**options: Any) -> None: - CultMesh.serve_node(node, **options).stop() - - carry = "cannot carry an empty snapshot response" - self.assertIn(carry, refused(rudp_max_fragment_bytes=1, rudp_max_pending_reliable_packets=16)) - self.assertIn(carry, refused(rudp_max_fragment_bytes=1, rudp_max_pending_reliable_packets=empty - 1)) - accepted(rudp_max_fragment_bytes=1, rudp_max_pending_reliable_packets=empty) - # Fragments are counted rounding up: empty - 1 bytes a fragment takes two. - self.assertIn(carry, refused(rudp_max_fragment_bytes=empty - 1, rudp_max_pending_reliable_packets=1)) - accepted(rudp_max_fragment_bytes=empty - 1, rudp_max_pending_reliable_packets=2) - self.assertIn("cannot hold an empty snapshot response", refused(max_snapshot_bytes=empty - 1)) - accepted(max_snapshot_bytes=empty) - self.assertIn("greater than zero", refused(max_snapshot_bytes=0)) - self.assertIn("greater than zero", refused(max_snapshot_documents=0)) - accepted(max_snapshot_documents=1) - self.assertIn("greater than zero", refused(rudp_resend_delay_ms=0)) - accepted(rudp_resend_delay_ms=1) - self.assertIn("greater than zero", refused(rudp_max_fragment_bytes=0)) - self.assertIn("greater than zero", refused(rudp_max_pending_reliable_packets=0)) - # The RUDP options configure only the RUDP server: without one, none of them is checked. - accepted(enable_rudp=False, rudp_max_fragment_bytes=1, rudp_max_pending_reliable_packets=16) - accepted( - enable_rudp=False, - rudp_max_fragment_bytes=0, - rudp_max_pending_reliable_packets=0, - rudp_resend_delay_ms=0, - ) - self.assertIn("greater than zero", refused(enable_rudp=False, max_snapshot_documents=0)) - self.assertIn("cannot hold an empty snapshot response", refused(enable_rudp=False, max_snapshot_bytes=empty - 1)) - - # The configuration at the bound does answer: an empty snapshot in one-byte fragments, - # exactly as many as the queue holds. - server = CultMesh.serve_node(node, rudp_max_fragment_bytes=1, rudp_max_pending_reliable_packets=empty) - try: - served, payload = self._rudp_exchange(server, snapshot_request(message_id="").to_wire()) - finally: - server.stop() - self.assertEqual(served["documents"], []) - self.assertEqual(len(payload), empty) - self.assertEqual(server.rudp_send_failures, 0) - def test_cultmesh_local_server_returns_errors_for_bad_requests(self) -> None: document = define_database_entry_type( "mesh.error_note", @@ -4997,14 +4317,6 @@ class CultMeshTests(unittest.TestCase): {"schemaVersion": "cultnet.document_delete.v0", "messageId": "bad-delete", "schemaId": "mesh.error_note.v1"}, expected_schema_version="cultnet.error.v0", ) - # R-2, owed by Cut 1 (docs/cultnet-selection-cut.md, section 9): this v0-only Mesh server - # refuses a cultnet.selection.v1 carrier message through the same delegating path - # (_handle_connection_message -> handle_message) as any other unsupported schema, not a - # silent empty response. - unsupported_v1 = raw_client.request( - {"schemaVersion": "cultnet.snapshot_request.v1", "messageId": "bad-v1-selection"}, - expected_schema_version="cultnet.error.v0", - ) finally: server.stop() @@ -5016,9 +4328,6 @@ class CultMeshTests(unittest.TestCase): self.assertEqual(malformed_put["code"], "malformed_document_put") self.assertEqual(malformed_delete["messageId"], "bad-delete") self.assertEqual(malformed_delete["code"], "malformed_document_delete") - self.assertEqual(unsupported_v1["messageId"], "bad-v1-selection") - self.assertEqual(unsupported_v1["code"], "unsupported_schema_version") - self.assertEqual(unsupported_v1["details"]["schemaVersion"], "cultnet.snapshot_request.v1") def test_cultmesh_authority_lease_requires_live_matching_lease(self) -> None: peer = CultMeshPeerCard( @@ -5178,459 +4487,5 @@ class CultMeshTests(unittest.TestCase): self.assertEqual(streams.latest_frame("mimir:kiyo-pro").sequence, 42) -class CultMeshRudpSendFailureTests(unittest.TestCase): - """One peer whose datagrams cannot be sent must not stop the RUDP thread - serving the others.""" - - def _client(self, server: Any, name: str) -> tuple[CultNetRudpSocketTransportConnection, tuple[str, int]]: - sock = bind_udp_socket() - client = CultNetRudpSocketTransportConnection( - CultNetRudpSocketTransportOptions( - runtime_id=name, - socket=sock, - mode=CultNetRudpSocketMode.CLIENT, - connection_id=server.rudp_connection_id, - remote_addr=("127.0.0.1", server.port), - resend_delay_ms=25, - ) - ) - client.connect(b"join") - for _ in range(200): - client.receive_once() - if client.connected: - break - self.assertTrue(client.connected) - return client, sock.getsockname()[:2] - - def test_a_failed_send_to_one_peer_does_not_kill_the_rudp_thread(self) -> None: - import msgpack # type: ignore - - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - x, x_addr = self._client(server, "peer-x") - y, _ = self._client(server, "peer-y") - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(x_addr): - raise OSError("injected send failure") - return original_sendto(sock, data, *args) - - request = hello(runtime_id="probe").to_bytes() - with patch.object(socket.socket, "sendto", sendto): - # The server's reply and ack to X both fail to send. - x.send("schema", request) - self._wait_for(lambda: server.rudp_send_failures > 0) - self.assertTrue(server._rudp_thread.is_alive()) - - y.send("schema", request) - response = None - for _ in range(200): - response = y.receive_once() - if response is not None: - break - time.sleep(0.005) - - self.assertIsNotNone(response, "Y is still served after X's send failed") - self.assertEqual(msgpack.unpackb(response.payload, raw=False)["runtimeId"], "mesh-server") - self.assertTrue(server._rudp_thread.is_alive()) - self.assertGreater(server.rudp_send_failures, 0) - finally: - server.stop() - - def _served(self, y: CultNetRudpSocketTransportConnection) -> Any: - import msgpack # type: ignore - - y.send("schema", hello(runtime_id="probe").to_bytes()) - for _ in range(200): - response = y.receive_once() - if response is not None: - return msgpack.unpackb(response.payload, raw=False) - time.sleep(0.005) - return None - - def test_a_vanished_peer_does_not_kill_the_rudp_thread(self) -> None: - # On Windows the closed port of a peer that went away is reported as - # ConnectionResetError (WinError 10054) by the next receive. It can only fail there. - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - try: - x, _ = self._client(server, "peer-x") - y, _ = self._client(server, "peer-y") - x.send("schema", hello(runtime_id="probe").to_bytes()) - x.socket.close() - time.sleep(1.0) # the server's reply and resends to X draw ICMP port-unreachable - - self.assertTrue(server._rudp_thread.is_alive()) - served = self._served(y) - self.assertIsNotNone(served, "Y is still served after X vanished") - self.assertEqual(served["runtimeId"], "mesh-server") - finally: - server.stop() - - def test_a_reset_reported_by_a_receive_is_idle_not_the_end_of_the_thread(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_recvfrom = socket.socket.recvfrom - resets = [3] - try: - y, _ = self._client(server, "peer-y") - - def recvfrom(sock: socket.socket, *args: Any) -> Any: - if sock is server._rudp_socket and resets[0] > 0: - resets[0] -= 1 - raise ConnectionResetError(errno.ECONNRESET, "injected reset") - return original_recvfrom(sock, *args) - - with patch.object(socket.socket, "recvfrom", recvfrom): - self._wait_for(lambda: resets[0] == 0) - self.assertTrue(server._rudp_thread.is_alive()) - self.assertIsNotNone(self._served(y)) - finally: - server.stop() - - def test_a_permanent_send_failure_ends_only_that_peers_session_and_the_goodbye_names_it(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - x, x_addr = self._client(server, "peer-x") - y, _ = self._client(server, "peer-y") - failures = [1] - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(x_addr) and failures[0] > 0: - failures[0] -= 1 - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - # The server's response to X can never be sent as built. - x.send("schema", hello(runtime_id="probe").to_bytes()) - for _ in range(200): - x.receive_once() - if x.disconnect_reason is not None: - break - time.sleep(0.005) - self.assertIsNotNone(x.disconnect_reason, "X is told its session ended") - self.assertTrue(x.disconnect_reason.startswith(b"packet could not be sent: ")) - self.assertGreater(len(x.disconnect_reason), len(b"packet could not be sent: ")) - self.assertTrue(server._rudp_thread.is_alive()) - - # Y is unaffected. - self.assertFalse(x.connected) - self.assertIsNotNone(self._served(y)) - self.assertEqual(server.rudp_send_failures, 0) - finally: - server.stop() - - def test_healthy_sends_are_not_failures(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - try: - x, _ = self._client(server, "peer-x") - self.assertIsNotNone(self._served(x)) - self.assertEqual(server.rudp_send_failures, 0) - finally: - server.stop() - - def test_a_permanent_failure_in_a_resend_ends_only_that_peers_session(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - x, x_addr = self._client(server, "peer-x") - y, _ = self._client(server, "peer-y") - mode = ["transient"] - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(x_addr) and mode[0] == "transient": - raise OSError(errno.ENOBUFS, "injected transient failure") - if args and tuple(args[-1]) == tuple(x_addr) and mode[0] == "permanent": - mode[0] = "healthy" - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - # X's response is lost, so a resend is pending; then it can never be sent as built. - x.send("schema", hello(runtime_id="probe").to_bytes()) - self._wait_for(lambda: server.rudp_send_failures > 0) - self.assertFalse(x.disconnect_reason, "a transient failure ends no session") - mode[0] = "permanent" - for _ in range(200): - x.receive_once() - if x.disconnect_reason is not None: - break - time.sleep(0.005) - self.assertIsNotNone(x.disconnect_reason) - self.assertTrue(x.disconnect_reason.startswith(b"packet could not be sent: ")) - self.assertTrue(server._rudp_thread.is_alive()) - self.assertIsNotNone(self._served(y)) - finally: - server.stop() - - def test_a_permanent_failure_acknowledging_a_frame_ends_the_session(self) -> None: - import msgpack # type: ignore - - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - x, x_addr = self._client(server, "peer-x") - failures = [1] - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(x_addr) and failures[0] > 0: - failures[0] -= 1 - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - # Not a message the server answers, so its ack is the only datagram owed. - x.send("schema", msgpack.packb(1)) - for _ in range(200): - x.receive_once() - if x.disconnect_reason is not None: - break - time.sleep(0.005) - self.assertIsNotNone(x.disconnect_reason) - self.assertTrue(x.disconnect_reason.startswith(b"packet could not be sent: ")) - self.assertTrue(server._rudp_thread.is_alive()) - finally: - server.stop() - - def test_a_connect_whose_accept_can_never_be_sent_starts_no_session(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - y, _ = self._client(server, "peer-y") - z_socket = bind_udp_socket() - z_addr = z_socket.getsockname()[:2] - failures = [1] - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(z_addr) and failures[0] > 0: - failures[0] -= 1 - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - z = CultNetRudpSocketTransportConnection( - CultNetRudpSocketTransportOptions( - runtime_id="peer-z", - socket=z_socket, - mode=CultNetRudpSocketMode.CLIENT, - connection_id=server.rudp_connection_id, - remote_addr=("127.0.0.1", server.port), - resend_delay_ms=25, - ) - ) - z.connect(b"join") - # A session that started would resend its Accept, and the resend would get through. - time.sleep(0.5) - z_socket.settimeout(0.05) - received = [] - while True: - try: - wire, _ = z_socket.recvfrom(65535) - except TimeoutError: - break - received.append(decode_rudp_packet(wire).packet_type) - self.assertEqual(received, [CultNetRudpPacketType.DISCONNECT]) - self.assertTrue(server._rudp_thread.is_alive()) - self.assertIsNotNone(self._served(y)) - finally: - server.stop() - - def test_a_packet_the_session_refuses_ends_only_that_peers_session(self) -> None: - from cultnet_py import CultNetRudpPacket, encode_rudp_packet - - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - try: - x, _ = self._client(server, "peer-x") - y, _ = self._client(server, "peer-y") - # A fragment whose metadata the session refuses: fragment id 0 names no set. - refused = CultNetRudpPacket( - packet_type=CultNetRudpPacketType.DATA, - connection_id=server.rudp_connection_id, - sequence=0, - ack=0, - ack_mask=0, - channel_id="schema", - reliable=False, - fragment_id=0, - fragment_index=0, - fragment_count=2, - payload=b"x", - ) - x.socket.sendto(encode_rudp_packet(refused), ("127.0.0.1", server.port)) - for _ in range(200): - x.receive_once() - if x.disconnect_reason is not None: - break - time.sleep(0.005) - self.assertEqual(x.disconnect_reason, b"session refused a packet") - self.assertTrue(server._rudp_thread.is_alive()) - self.assertIsNotNone(self._served(y), "Y is still served") - finally: - server.stop() - - def test_a_message_whose_handling_fails_ends_only_that_peers_session(self) -> None: - import msgpack # type: ignore - - canary = "canary-7f3e1c" - # Well-formed frames whose fields have the wrong type: handling raises TypeError. - frames = [ - {"schemaVersion": "cultnet.database_subscribe.v0", "subscriptionId": canary, "schemaIds": 5}, - {"schemaVersion": "cultnet.database_subscribe.v0", "subscriptionId": canary, "recordKeys": True}, - ] - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - try: - y, _ = self._client(server, "peer-y") - for frame in frames: - with self.subTest(frame=frame): - x, _ = self._client(server, "peer-x") - with self.assertLogs("cultmesh_py.server", level="WARNING") as logs: - x.send("schema", msgpack.packb(frame, use_bin_type=True)) - for _ in range(200): - x.receive_once() - if x.disconnect_reason is not None: - break - time.sleep(0.005) - self.assertEqual(x.disconnect_reason, b"session refused a packet") - self.assertTrue(server._rudp_thread.is_alive()) - self.assertIsNotNone(self._served(y), "Y is still served") - self.assertEqual(len(logs.output), 1) - self.assertIn("TypeError", logs.output[0]) - self.assertNotIn(canary, logs.output[0]) - finally: - server.stop() - - def _raw_peer(self, server: Any) -> tuple[socket.socket, Any]: - """A peer driven packet by packet, to deliver frames in an order a client would not.""" - from cultnet_py import CultNetRudpSession, CultNetRudpSessionOptions, encode_rudp_packet - - sock = bind_udp_socket() - sock.settimeout(0.05) - session = CultNetRudpSession(CultNetRudpSessionOptions(connection_id=server.rudp_connection_id)) - sock.sendto(encode_rudp_packet(session.create_connect(0, b"join")), ("127.0.0.1", server.port)) - wire, _ = sock.recvfrom(65535) - accept = decode_rudp_packet(wire) - self.assertEqual(accept.packet_type, CultNetRudpPacketType.ACCEPT) - session.receive(accept, 0) - return sock, session - - def test_the_goodbye_for_a_refused_reliable_frame_does_not_acknowledge_it(self) -> None: - import dataclasses - - from cultnet_py import CultNetRudpSendOptions, encode_rudp_packet - - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - try: - sock, session = self._raw_peer(server) - # A reliable fragment whose metadata the session refuses: fragment id 0 names no set. - # The session records its sequence before it refuses it. - (fragment,) = session.send_many("schema", b"x", CultNetRudpSendOptions(reliable=True, ordered=True)) - refused = dataclasses.replace(fragment, fragment_id=0, fragment_index=0, fragment_count=2) - sock.sendto(encode_rudp_packet(refused), ("127.0.0.1", server.port)) - goodbye = None - for _ in range(40): - try: - wire, _ = sock.recvfrom(65535) - except TimeoutError: - continue - packet = decode_rudp_packet(wire) - if packet.packet_type == CultNetRudpPacketType.DISCONNECT: - goodbye = packet - break - self.assertIsNotNone(goodbye) - self.assertEqual(goodbye.payload, b"session refused a packet") - distance = goodbye.ack - refused.sequence - acknowledged = distance == 0 or (0 < distance <= 32 and goodbye.ack_mask & (1 << (distance - 1)) != 0) - self.assertFalse(acknowledged, "the goodbye acknowledged the refused frame") - finally: - server.stop() - - def test_responses_after_one_that_can_never_be_sent_are_not_sent(self) -> None: - from cultnet_py import CultNetRudpSendOptions, encode_rudp_packet - - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - sock, session = self._raw_peer(server) - addr = sock.getsockname()[:2] - request = hello(runtime_id="probe").to_bytes() - options = CultNetRudpSendOptions(reliable=True, ordered=True) - first = session.send("schema", request, options) - second = session.send("schema", request, options) - attempts: list[CultNetRudpPacketType] = [] - failures = [1] - - def sendto(sock_: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(addr): - packet_type = decode_rudp_packet(data).packet_type - attempts.append(packet_type) - if packet_type == CultNetRudpPacketType.DATA and failures[0] > 0: - failures[0] -= 1 - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock_, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - # The second frame waits for the first, so one receive delivers both, and - # the first of the two responses can never be sent as built. - sock.sendto(encode_rudp_packet(second), ("127.0.0.1", server.port)) - time.sleep(0.1) - attempts.clear() - sock.sendto(encode_rudp_packet(first), ("127.0.0.1", server.port)) - self._wait_for(lambda: CultNetRudpPacketType.DISCONNECT in attempts) - time.sleep(0.1) - - # The unsendable response, then only the goodbye: no second response, no ack. - self.assertEqual(attempts, [CultNetRudpPacketType.DATA, CultNetRudpPacketType.DISCONNECT]) - self.assertTrue(server._rudp_thread.is_alive()) - finally: - server.stop() - - def test_a_peer_ended_in_the_resend_loop_is_sent_nothing_more_from_it(self) -> None: - server = CultMesh.serve_node(CultMesh.create_node(runtime_id="mesh-server")) - original_sendto = socket.socket.sendto - try: - x, x_addr = self._client(server, "peer-x") - mode = ["transient"] - attempts: list[CultNetRudpPacketType] = [] - - def sendto(sock: socket.socket, data: bytes, *args: Any) -> int: - if args and tuple(args[-1]) == tuple(x_addr): - packet_type = decode_rudp_packet(data).packet_type - if mode[0] != "transient": - attempts.append(packet_type) - # Only responses fail; X's requests are acknowledged, so X goes quiet. - if packet_type == CultNetRudpPacketType.DATA and mode[0] == "transient": - raise OSError(errno.ENOBUFS, "injected transient failure") - if packet_type == CultNetRudpPacketType.DATA and mode[0] == "permanent": - mode[0] = "healthy" - raise OSError(errno.EMSGSIZE, "Message too long") - return original_sendto(sock, data, *args) - - with patch.object(socket.socket, "sendto", sendto): - x.send("schema", hello(runtime_id="one").to_bytes()) - x.send("schema", hello(runtime_id="two").to_bytes()) - for _ in range(40): - x.receive_once() - time.sleep(0.005) - self._wait_for(lambda: server.rudp_send_failures >= 2) - # Both responses are owed; the next resend of the first can never be sent. - mode[0] = "permanent" - self._wait_for(lambda: CultNetRudpPacketType.DISCONNECT in attempts) - time.sleep(0.2) - - self.assertEqual(attempts, [CultNetRudpPacketType.DATA, CultNetRudpPacketType.DISCONNECT]) - self.assertTrue(server._rudp_thread.is_alive()) - finally: - server.stop() - - def _wait_for(self, predicate: Callable[[], bool]) -> None: - deadline = time.monotonic() + 2.0 - while time.monotonic() < deadline: - if predicate(): - return - time.sleep(0.005) - self.fail("condition not reached") - - if __name__ == "__main__": unittest.main() diff --git a/packages/cultmesh-py/tests/test_rudp_server_generation.py b/packages/cultmesh-py/tests/test_rudp_server_generation.py deleted file mode 100644 index cd84c908..00000000 --- a/packages/cultmesh-py/tests/test_rudp_server_generation.py +++ /dev/null @@ -1,160 +0,0 @@ -"""The CultMesh local server's RUDP loop asks each peer's session whether a Connect -repeats. A retransmitted Connect keeps the peer; a restarted client on the same -address is a new one, with none of the old one's subscriptions.""" -from __future__ import annotations - -import socket -import time -import unittest -from dataclasses import dataclass - -import msgpack -from cultcache_py import define_database_entry_type -from cultmesh_py import create_node -from cultmesh_py.server import CultMeshLocalServer -from cultnet_py import ( - CultNetRudpSendOptions, - CultNetRudpSession, - CultNetRudpSessionOptions, - document_put_raw, -) -from cultnet_py.transport import CultNetRudpPacketType, decode_rudp_packet, encode_rudp_packet - -CONNECTION_ID = 0x10203091 -SCHEMA_ID = "mesh.rudp_generation_note.v1" -RELIABLE = CultNetRudpSendOptions(reliable=True, ordered=True) - - -@dataclass -class Note: - body: str - - -NOTE = define_database_entry_type( - "mesh.rudp_generation_note", - [("body", 0)], - cls=Note, - schema_id=SCHEMA_ID, - schema_name="mesh.rudp_generation_note", - schema_version=SCHEMA_ID, -) - - -def wire(message: dict) -> bytes: - return msgpack.packb(message, use_bin_type=True) - - -class RudpServerGenerationTests(unittest.TestCase): - def setUp(self) -> None: - node = create_node(runtime_id="rudp-generation") - node.database.register_document(NOTE) - # Replies stay whole datagrams here, so each server packet the pump reads is one message. - self.server = CultMeshLocalServer(node=node, rudp_connection_id=CONNECTION_ID, rudp_max_fragment_bytes=60_000) - self.server.start() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.sock.bind(("127.0.0.1", 0)) - self.sock.settimeout(0.02) - self.target = ("127.0.0.1", self.server.port) - # Every schema data packet the server sent, by sequence, whether or not the receiving - # session delivered it: a new server-side session numbers its packets afresh. - self.sent: dict[int, str] = {} - - def tearDown(self) -> None: - self.sock.close() - self.server.stop() - - def to_server(self, packet) -> None: - self.sock.sendto(encode_rudp_packet(packet), self.target) - - def pump(self, session: CultNetRudpSession, until, seconds: float = 2.0) -> bool: - deadline = time.monotonic() + seconds - while time.monotonic() < deadline: - if until(): - return True - try: - data, _ = self.sock.recvfrom(65535) - except TimeoutError: - continue - packet = decode_rudp_packet(data) - session.receive(packet, int(time.monotonic() * 1000)) - if packet.reliable or packet.packet_type == CultNetRudpPacketType.ACCEPT: - self.to_server(session.create_ack_for_received(packet.sequence)) - if packet.packet_type == CultNetRudpPacketType.DATA and packet.channel_id == "schema": - self.sent[packet.sequence] = msgpack.unpackb(packet.payload, raw=False).get("schemaVersion") - return until() - - def count(self, schema_version: str) -> int: - return sum(1 for value in self.sent.values() if value == schema_version) - - def new_session(self, initial_sequence: int) -> CultNetRudpSession: - return CultNetRudpSession(CultNetRudpSessionOptions(connection_id=CONNECTION_ID, initial_sequence=initial_sequence)) - - def test_a_retransmitted_connect_keeps_the_peer_and_a_restarted_client_is_a_new_one(self) -> None: - first = self.new_session(50_000) - connect = first.create_connect(0, b"same") - self.to_server(connect) - self.assertTrue(self.pump(first, lambda: first.connected), "the first Accept") - hello = first.send( - "schema", wire({"schemaVersion": "cultnet.hello.v0", "runtimeId": "probe", "runtimeKind": "test"}), RELIABLE - ) - self.to_server(hello) - self.assertTrue(self.pump(first, lambda: self.count("cultnet.hello.v0") == 1), "the first answer") - self.to_server( - first.send( - "schema", - wire({ - "schemaVersion": "cultnet.database_subscribe.v0", - "messageId": "subscribe", - "subscriptionId": "old-incarnation", - "schemaIds": [SCHEMA_ID], - "includeSnapshot": False, - }), - RELIABLE, - ) - ) - self.pump(first, lambda: False, 0.2) - first_put = document_put_raw( - message_id="first-put", - key="note:a", - schema_id=SCHEMA_ID, - stored_at="2026-09-30T00:00:00Z", - payload=NOTE.encode_payload(Note("first")), - ) - self.to_server(first.send("schema", first_put.to_bytes(), RELIABLE)) - self.assertTrue( - self.pump(first, lambda: self.count("cultnet.database_change_raw.v0") == 1), - "the subscription did not notify its own connection", - ) - - # A retransmitted Connect repeats: the data already delivered is not delivered, or answered, again. - self.to_server(connect) - self.to_server(hello) - self.pump(first, lambda: False, 0.4) - self.assertEqual(self.count("cultnet.hello.v0"), 1, "the retransmitted Connect reset the peer") - - # The same client restarted on the same address, connection id and payload: a new peer. - second = self.new_session(7) - self.to_server(second.create_connect(0, b"same")) - self.assertTrue(self.pump(second, lambda: second.connected), "the restarted client's Accept") - self.to_server( - second.send( - "schema", wire({"schemaVersion": "cultnet.hello.v0", "runtimeId": "probe", "runtimeKind": "test"}), RELIABLE - ) - ) - self.assertTrue(self.pump(second, lambda: self.count("cultnet.hello.v0") == 2), "the restarted client's answer") - - # It inherited none of the old incarnation's subscriptions. - put = document_put_raw( - message_id="second-put", - key="note:a", - schema_id=SCHEMA_ID, - stored_at="2026-09-30T00:00:01Z", - payload=NOTE.encode_payload(Note("second")), - ) - self.to_server(second.send("schema", put.to_bytes(), RELIABLE)) - self.pump(second, lambda: False, 0.4) - self.assertEqual(self.count("cultnet.database_change_raw.v0"), 1, "the new peer inherited a subscription") - - -if __name__ == "__main__": - unittest.main() diff --git a/packages/cultmesh-rs/src/lib.rs b/packages/cultmesh-rs/src/lib.rs index 1af0d906..8cfe8cec 100644 --- a/packages/cultmesh-rs/src/lib.rs +++ b/packages/cultmesh-rs/src/lib.rs @@ -820,13 +820,9 @@ pub fn request_raw_snapshot_from_rudp_catalog( } if received == &message_id => { snapshot_response = Some(message); } - cultnet_rs::CultNetMessage::Error { error, .. } => { + cultnet_rs::CultNetMessage::Error { error } => { let _ = client.disconnect(b"snapshot-error".to_vec()); - anyhow::bail!( - "CultMesh RUDP catalog {} refused the snapshot{}", - options.target, - recognised_refusal(error) - ); + anyhow::bail!("CultMesh RUDP snapshot failed: {error}"); } _ => {} } @@ -860,17 +856,6 @@ pub fn request_raw_snapshot_from_rudp_catalog( ) } -/// A catalog's refusal text, quoted (`": text"`) only when it is one of the -/// fixed refusals a CultMesh catalog sends; any other text could carry -/// anything, so it is left out. -fn recognised_refusal(text: &str) -> String { - if REFUSAL_TEXTS.contains(&text) { - format!(": {text}") - } else { - String::new() - } -} - fn unix_millis() -> u128 { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -881,12 +866,7 @@ fn unix_millis() -> u128 { /// Publish one raw CultNet schema message to a RUDP catalog. /// /// Each call owns a fresh connection epoch and returns only after the catalog -/// acknowledges reliable application admission. Against a Rust CultMesh -/// catalog, which never acknowledges a message it refuses, a refusal is -/// returned as an error, naming the refusal when it is one of the fixed texts -/// such a catalog sends. A catalog that acknowledges a message on receipt and -/// refuses it afterwards (the TypeScript document server does) is reported as -/// having admitted it: the acknowledgement arrives first. +/// acknowledges reliable application admission. pub fn publish_cultnet_message_to_rudp_catalog( message: &cultnet_rs::CultNetMessage, options: CultMeshRudpDocumentPublishOptions, @@ -907,23 +887,7 @@ pub fn publish_cultnet_message_to_rudp_catalog( let receipt = client.send_reliable("schema", payload)?; let flush_deadline = Instant::now() + options.flush_timeout; while Instant::now() < flush_deadline { - if let Some(frame) = client.receive_once()? { - if frame.channel_id == "schema" { - if let Ok(cultnet_rs::CultNetMessage::Error { error, .. }) = - decode_cultnet_message_from_slice( - &frame.payload, - CultNetWireContract::CultNetSchemaV0, - ) - { - let _ = client.disconnect(b"document-refused".to_vec()); - anyhow::bail!( - "CultMesh RUDP catalog {} refused the put{}", - options.target, - recognised_refusal(&error) - ); - } - } - } + let _ = client.receive_once()?; match client.reliable_send_status(&receipt) { cultnet_rs::CultNetRudpReliableSendStatus::Acknowledged => { let _ = client.disconnect(b"document-acknowledged".to_vec()); @@ -997,7 +961,7 @@ fn connect_rudp_client( mode: cultnet_rs::CultNetRudpSocketMode::Client, remote_addr: Some(target), connection_id: fresh_rudp_connection_epoch(), - initial_sequence: None, + initial_sequence: 1, resend_delay_ms, transport_id: Some(transport_id.to_string()), max_payload_bytes: None, @@ -1316,7 +1280,7 @@ mod tests { } #[test] - fn a_refused_publish_fails_with_the_catalogs_reason_not_a_timeout() -> Result<()> { + fn document_publish_requires_application_acknowledgement() -> Result<()> { let temp = tempfile::tempdir()?; let node = CultMesh::create_node( temp.path().join("cultmesh.cc"), @@ -1331,7 +1295,7 @@ mod tests { let mut server = CultMeshRudpDocumentServer::new( socket, |_receipt: CultMeshRudpRawDocumentReceipt| { - anyhow::bail!("injected durable sink failure CANARY-7f3a") + anyhow::bail!("injected durable sink failure") }, |_query: &CultMeshRudpSnapshotQuery| Ok(Vec::new()), CultMeshSystemClock::default(), @@ -1344,7 +1308,6 @@ mod tests { Ok(()) }); - let started = Instant::now(); let error = node .publish_document_to_rudp_catalog( "note", @@ -1354,164 +1317,16 @@ mod tests { CultMeshRudpDocumentPublishOptions { target, connect_timeout: Duration::from_millis(100), - flush_timeout: Duration::from_secs(10), + flush_timeout: Duration::from_millis(50), poll_interval: Duration::from_millis(2), resend_delay_ms: 5, ..CultMeshRudpDocumentPublishOptions::default() }, ) - .expect_err("a refused document must fail closed"); - let waited = started.elapsed(); + .expect_err("unacknowledged document must fail closed"); stop.store(true, std::sync::atomic::Ordering::SeqCst); server.join().expect("server thread should not panic")?; - // The publisher hears the refusal and its reason, long before its flush - // deadline: a refusal is not mistaken for loss. - assert!( - error - .to_string() - .ends_with("refused the put: the catalog refused the document"), - "{error:#}" - ); - assert!(!error.to_string().contains("CANARY"), "{error:#}"); - assert!(waited < Duration::from_secs(5), "waited {waited:?}"); - Ok(()) - } - - /// A catalog that answers every message with a refusal of its own wording, - /// never acknowledging it. Stops when the flag is set. - fn refusing_catalog( - text: &'static str, - ) -> Result<( - SocketAddr, - std::sync::Arc, - thread::JoinHandle>, - )> { - use cultnet_rs::{ - CultNetRudpPacketType, CultNetRudpSendOptions, CultNetRudpSession, - CultNetRudpSessionOptions, decode_rudp_packet, encode_rudp_packet, - }; - let socket = UdpSocket::bind("127.0.0.1:0")?; - socket.set_read_timeout(Some(Duration::from_millis(5)))?; - let target = socket.local_addr()?; - let stop = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)); - let catalog_stop = stop.clone(); - let catalog = thread::spawn(move || -> Result<()> { - let mut session: Option = None; - let mut wire = vec![0_u8; 65_535]; - while !catalog_stop.load(std::sync::atomic::Ordering::SeqCst) { - let Ok((bytes, peer)) = socket.recv_from(&mut wire) else { - continue; - }; - let Ok(packet) = decode_rudp_packet(&wire[..bytes]) else { - continue; - }; - if packet.packet_type == CultNetRudpPacketType::Connect { - let mut accepted = CultNetRudpSession::new(CultNetRudpSessionOptions { - connection_id: packet.connection_id, - initial_sequence: None, - resend_delay_ms: 10_000, - max_pending_reliable_packets: Some(64), - }); - let accept = accepted.accept_connect(&packet, 0, Vec::new())?; - socket.send_to(&encode_rudp_packet(&accept)?, peer)?; - session = Some(accepted); - continue; - } - let Some(session) = session.as_mut() else { - continue; - }; - let Ok(received) = session.receive(&packet, 1) else { - continue; - }; - for _message in received.delivered { - let refusal = encode_cultnet_message_to_vec( - &cultnet_rs::CultNetMessage::Error { - error: text.into(), - code: None, - details: None, - }, - CultNetWireContract::CultNetSchemaV0, - )?; - let options = CultNetRudpSendOptions { - reliable: false, - ordered: false, - sequenced: false, - now_ms: 2, - reliable_expire_after_ms: None, - }; - for packet in session.send_many("schema", refusal, options, Some(1200))? { - socket.send_to(&encode_rudp_packet(&packet)?, peer)?; - } - } - } - Ok(()) - }); - Ok((target, stop, catalog)) - } - - /// A catalog's refusal text is quoted only when it is one of the fixed - /// refusals a CultMesh catalog sends. Any other text, which could carry - /// anything, stays out of the publisher's error. - #[test] - fn a_publisher_never_quotes_a_refusal_it_does_not_recognise() -> Result<()> { - let temp = tempfile::tempdir()?; - let node = CultMesh::create_node( - temp.path().join("cultmesh.cc"), - TestDocuments, - Default::default(), - )?; - let (target, stop, catalog) = refusing_catalog("no such tenant: CANARY-7f3a")?; - let error = node - .publish_document_to_rudp_catalog( - "note", - &Note { - body: "refused by a stranger".into(), - }, - CultMeshRudpDocumentPublishOptions { - target, - connect_timeout: Duration::from_secs(2), - flush_timeout: Duration::from_secs(10), - poll_interval: Duration::from_millis(2), - resend_delay_ms: 5, - ..CultMeshRudpDocumentPublishOptions::default() - }, - ) - .expect_err("a refused document must fail closed"); - stop.store(true, std::sync::atomic::Ordering::SeqCst); - catalog.join().expect("catalog thread should not panic")?; - assert_eq!( - error.to_string(), - format!("CultMesh RUDP catalog {target} refused the put") - ); - Ok(()) - } - - /// The snapshot client filters a catalog's refusal the same way: a fixed - /// refusal is named, any other text is left out. - #[test] - fn a_snapshot_client_quotes_only_a_refusal_it_recognises() -> Result<()> { - for (text, expected) in [ - ("no such tenant: CANARY-7f3a", ""), - ("the snapshot source failed", ": the snapshot source failed"), - ] { - let (target, stop, catalog) = refusing_catalog(text)?; - let error = request_raw_snapshot_from_rudp_catalog(CultMeshRudpSnapshotOptions { - target, - message_id: "refused".into(), - connect_timeout: Duration::from_secs(2), - response_timeout: Duration::from_secs(10), - poll_interval: Duration::from_millis(2), - resend_delay_ms: 5, - ..CultMeshRudpSnapshotOptions::default() - }) - .expect_err("a refused snapshot must fail"); - stop.store(true, std::sync::atomic::Ordering::SeqCst); - catalog.join().expect("catalog thread should not panic")?; - assert_eq!( - error.to_string(), - format!("CultMesh RUDP catalog {target} refused the snapshot{expected}") - ); - } + assert!(error.to_string().contains("reliable acknowledgement")); Ok(()) } @@ -1591,7 +1406,7 @@ mod tests { let mut session = cultnet_rs::CultNetRudpSession::new(cultnet_rs::CultNetRudpSessionOptions { connection_id: connect.connection_id, - initial_sequence: Some(1), + initial_sequence: 1, resend_delay_ms: 5, max_pending_reliable_packets: Some(64), }); diff --git a/packages/cultmesh-rs/src/rudp_document_server.rs b/packages/cultmesh-rs/src/rudp_document_server.rs index 09c31adf..bebeb6c3 100644 --- a/packages/cultmesh-rs/src/rudp_document_server.rs +++ b/packages/cultmesh-rs/src/rudp_document_server.rs @@ -3,21 +3,14 @@ use cultnet_rs::{ CultNetMessage, CultNetRawDocumentRecord, CultNetRudpPacket, CultNetRudpPacketType, CultNetRudpSendOptions, CultNetRudpSession, CultNetRudpSessionOptions, CultNetWireContract, decode_cultnet_message_from_slice, decode_rudp_packet, encode_cultnet_message_to_vec, - encode_rudp_packet, is_permanent_send_error, send_error_code, + encode_rudp_packet, }; use std::collections::BTreeMap; -#[cfg(test)] -use std::collections::BTreeSet; use std::io::ErrorKind; use std::net::{SocketAddr, UdpSocket}; use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; const MAX_UDP_DATAGRAM_BYTES: usize = 65_535; -/// The most fragments one RUDP message can carry: its fragment count is a u16. -const MAX_FRAGMENTS_PER_MESSAGE: usize = u16::MAX as usize; -/// The shortest message id CultNet encodes: one character. A snapshot request -/// can carry no shorter id, so no response to it can be smaller. -const SHORTEST_MESSAGE_ID: &str = "0"; /// The transport identity of one remote CultNet RUDP session. /// @@ -77,20 +70,6 @@ pub trait CultMeshRudpSnapshotSource { &mut self, query: &CultMeshRudpSnapshotQuery, ) -> Result>; - - /// The record this source would serve for a received put's `document`. - /// - /// The server admits a put only if a snapshot response carrying this record - /// alone fits its limits, so a source that serves a different shape than it - /// receives (dropping provenance, or adding its own) overrides this to keep - /// admission exact. The default serves the record as received. An error - /// refuses the put as `SnapshotSourceFailed`. - fn served_record( - &mut self, - document: &CultNetRawDocumentRecord, - ) -> Result { - Ok(document.clone()) - } } impl CultMeshRudpSnapshotSource for F @@ -159,10 +138,6 @@ pub struct CultMeshRudpDocumentServerOptions { /// finite without duplicating its fragment/ordering machinery here. pub max_admitted_payload_bytes: usize, pub max_admitted_payload_bytes_per_session: usize, - /// The largest encoded snapshot response the server sends. It also bounds - /// puts: a document whose snapshot response alone would exceed it, or would - /// take more fragments than one message or the reliable queue can hold, is - /// refused with `DocumentUnservable`, since no request could return it. pub max_snapshot_response_bytes: usize, pub max_snapshot_documents: usize, pub resend_delay: Duration, @@ -199,129 +174,12 @@ pub enum CultMeshRudpApplicationOperation { SnapshotRequest, } -/// Why the server refused an application message. -/// -/// `Display` gives the operator-facing sentence; match on the variant to act on -/// the cause. -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum CultMeshRudpRejectionReason { - /// The caller's sink refused the document. Carries the sink's error text. - SinkRefused(String), - /// The document could never be served: a snapshot response carrying it - /// alone, as the snapshot source would serve it (`served_record`) and under - /// the shortest message id CultNet allows, would - /// exceed `max_snapshot_response_bytes`, or would take more than - /// `max_fragment_count` fragments of `max_fragment_bytes`: the lesser of - /// 65535 and `max_pending_reliable_packets_per_session`. It was not offered - /// to the sink. - DocumentUnservable { - response_bytes: usize, - max_snapshot_response_bytes: usize, - fragment_count: usize, - max_fragment_count: usize, - }, - /// The caller's snapshot source failed. Carries its error text. - SnapshotSourceFailed(String), - SnapshotTooManyDocuments { - documents: usize, - max_snapshot_documents: usize, - }, - SnapshotResponseTooLarge { - response_bytes: usize, - max_snapshot_response_bytes: usize, - }, - /// A snapshot response could not be encoded. Carries the encoder's error text. - ResponseEncodingFailed(String), - /// The server's retained payload budget cannot hold the response. - PayloadBudgetFull, - /// The session could not queue the response. Carries the session's error text. - ResponseQueueFailed(String), - /// A packet of the response can never be sent to the peer as built - /// (`is_permanent_send_error`). Carries the failure's fixed name - /// (`send_error_code`). The session has ended with a goodbye carrying the - /// same name, and no refusal: the server knows the peer cannot be reached. - ResponseSendFailed(&'static str), -} - -impl std::fmt::Display for CultMeshRudpRejectionReason { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::SinkRefused(error) | Self::SnapshotSourceFailed(error) => f.write_str(error), - Self::DocumentUnservable { - response_bytes, - max_snapshot_response_bytes, - fragment_count, - max_fragment_count, - } => write!( - f, - "document can never be served: its snapshot response is {response_bytes} bytes in {fragment_count} fragments; limits are {max_snapshot_response_bytes} bytes and {max_fragment_count} fragments" - ), - Self::SnapshotTooManyDocuments { - documents, - max_snapshot_documents, - } => write!( - f, - "snapshot returned {documents} documents; limit is {max_snapshot_documents}" - ), - Self::SnapshotResponseTooLarge { - response_bytes, - max_snapshot_response_bytes, - } => write!( - f, - "snapshot response is {response_bytes} bytes; limit is {max_snapshot_response_bytes}" - ), - Self::ResponseEncodingFailed(error) => { - write!(f, "snapshot response could not be encoded: {error}") - } - Self::PayloadBudgetFull => f.write_str("retained payload budget is full"), - Self::ResponseQueueFailed(error) => { - write!(f, "snapshot response could not be queued: {error}") - } - Self::ResponseSendFailed(code) => { - write!(f, "snapshot response could not be sent: {code}") - } - } - } -} - -/// The texts a refused peer is sent, one per rejection variant. They are fixed: -/// a sink's or source's error text can quote what a peer sent, so it stays with -/// the caller that receives the rejection and never reaches the wire. -pub(crate) const REFUSAL_TEXTS: [&str; 9] = [ - "the catalog refused the document", - "the document can never be served", - "the snapshot source failed", - "the snapshot has too many documents", - "the snapshot response is too large", - "the snapshot response could not be encoded", - "the retained payload budget is full", - "the snapshot response could not be queued", - "the snapshot response could not be sent", -]; - -impl CultMeshRudpRejectionReason { - /// The fixed text the refused peer is sent for this variant. - fn refusal_text(&self) -> &'static str { - REFUSAL_TEXTS[match self { - Self::SinkRefused(_) => 0, - Self::DocumentUnservable { .. } => 1, - Self::SnapshotSourceFailed(_) => 2, - Self::SnapshotTooManyDocuments { .. } => 3, - Self::SnapshotResponseTooLarge { .. } => 4, - Self::ResponseEncodingFailed(_) => 5, - Self::PayloadBudgetFull => 6, - Self::ResponseQueueFailed(_) => 7, - Self::ResponseSendFailed(_) => 8, - }] - } -} - #[derive(Clone, Debug, PartialEq, Eq)] pub struct CultMeshRudpApplicationRejection { pub session: CultMeshRudpSessionKey, pub operation: CultMeshRudpApplicationOperation, pub message_id: String, - pub reason: CultMeshRudpRejectionReason, + pub reason: String, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -331,16 +189,6 @@ pub enum CultMeshRudpPollOutcome { ApplicationRejected(CultMeshRudpApplicationRejection), } -/// Why a session ends before its peer is done with it. -enum SessionEnd { - /// The session refused a packet. - Refused, - /// The server rejected a peer's message; the peer is sent this fixed text. - Rejected(&'static str), - /// The session owes its peer a packet that can never be sent as built. - Unsendable(std::io::Error), -} - struct SessionEntry { session: CultNetRudpSession, created_at_monotonic_millis: u64, @@ -359,15 +207,6 @@ pub struct CultMeshRudpDocumentServer { snapshot_source: Q, clock: C, options: CultMeshRudpDocumentServerOptions, - packets_dropped: u64, - send_failures: u64, - /// Peers whose every datagram fails to send, standing in for an unroutable - /// or full path that a loopback peer cannot be made to have. - #[cfg(test)] - failing_peers: BTreeSet, - /// Peers whose next datagram after this many fails permanently, once. - #[cfg(test)] - unsendable_after: BTreeMap, } impl CultMeshRudpDocumentServer @@ -395,35 +234,9 @@ where snapshot_source, clock, options, - packets_dropped: 0, - send_failures: 0, - #[cfg(test)] - failing_peers: BTreeSet::new(), - #[cfg(test)] - unsendable_after: BTreeMap::new(), }) } - /// Datagrams read and discarded because they belong to no admissible - /// session: malformed frames, unknown sessions, a Connect the session cap - /// refuses, a packet that fails its session. Never an - /// error: a moved flow or a scanner must not end the daemon loop. - pub fn packets_dropped(&self) -> u64 { - self.packets_dropped - } - - /// Datagrams that could not be sent to a peer and may yet be: no route, full - /// buffers, a refused path. Each is that peer's lost datagram: a reliable - /// packet stays pending and is resent, and the peer's session ends by idle - /// timeout, lifetime, refusal or Disconnect, never by the failure. Never an - /// error: one unreachable peer must not stop the poll that serves the - /// others. A datagram that can never be sent as built - /// (`is_permanent_send_error`) is not counted here: it ends that peer's - /// session, and the peer's goodbye names the error. - pub fn send_failures(&self) -> u64 { - self.send_failures - } - pub fn local_addr(&self) -> Result { Ok(self.socket.local_addr()?) } @@ -435,25 +248,14 @@ where /// Poll transport maintenance and receive at most one UDP datagram. /// /// Application rejection invalidates only the responsible peer session and - /// is returned as data so a daemon can log it and keep serving. The peer is - /// sent the refusal as a `cultnet.error.v0` carrying fixed text for the - /// rejection's variant, then a goodbye; neither acknowledges the refused - /// message. The rejection's own detail, which can quote a sink's or - /// source's error, stays with the caller. Local socket and server-state - /// failures remain errors. + /// is returned as data so a daemon can log it and keep serving. Local + /// socket and server-state failures remain errors. pub fn poll_once(&mut self) -> Result { self.maintain()?; let mut wire = vec![0_u8; MAX_UDP_DATAGRAM_BYTES]; let (received, remote_addr) = match self.socket.recv_from(&mut wire) { Ok(value) => value, - // Windows reports an earlier ICMP port-unreachable on the next - // receive; it names no datagram of this poll. - Err(error) - if matches!( - error.kind(), - ErrorKind::WouldBlock | ErrorKind::ConnectionReset - ) => - { + Err(error) if error.kind() == ErrorKind::WouldBlock => { return Ok(CultMeshRudpPollOutcome::Idle); } Err(error) => return Err(error.into()), @@ -462,10 +264,7 @@ where let packet = match decode_rudp_packet(&wire) { Ok(packet) => packet, - Err(_) => { - self.packets_dropped += 1; - return Ok(CultMeshRudpPollOutcome::Handled); - } + Err(_) => return Ok(CultMeshRudpPollOutcome::Handled), }; let now_unix = self.clock.now_unix_millis(); let now_monotonic = self.clock.now_monotonic_millis(); @@ -475,14 +274,11 @@ where }; if packet.packet_type == CultNetRudpPacketType::Connect { - if !self.accept_connection(key, &packet, now_monotonic)? { - self.packets_dropped += 1; - } + self.accept_connection(key, &packet, now_monotonic)?; return Ok(CultMeshRudpPollOutcome::Handled); } if !self.sessions.contains_key(&key) { - self.packets_dropped += 1; return Ok(CultMeshRudpPollOutcome::Handled); } if packet.packet_type == CultNetRudpPacketType::Data @@ -513,16 +309,14 @@ where let result = match result { Ok(result) => result, Err(_) => { - self.end_session(key, SessionEnd::Refused)?; - self.packets_dropped += 1; + self.sessions.remove(&key); return Ok(CultMeshRudpPollOutcome::Handled); } }; - let mut unsendable = match result.reply { - Some(reply) => self.send_packet(key.remote_addr, &reply)?, - None => None, - }; + if let Some(reply) = result.reply { + self.send_packet(key.remote_addr, &reply)?; + } if result.disconnected { self.sessions.remove(&key); @@ -547,31 +341,19 @@ where now_unix, now_monotonic, )? { - // The only reply `receive` returns is a Pong, which delivers no - // frame, so no earlier send of this poll can precede a rejection. - // A response that could not be sent ended its session where the - // send failed, over the real error. - if !matches!( - rejection.reason, - CultMeshRudpRejectionReason::ResponseSendFailed(_) - ) { - self.end_session(key, SessionEnd::Rejected(rejection.reason.refusal_text()))?; - } + self.sessions.remove(&key); return Ok(CultMeshRudpPollOutcome::ApplicationRejected(rejection)); } } - if packet.reliable && unsendable.is_none() { + if packet.reliable { let ack = self .sessions .get_mut(&key) .ok_or_else(|| anyhow!("CultMesh RUDP session disappeared before ACK"))? .session .create_ack(); - unsendable = self.send_packet(key.remote_addr, &ack)?; - } - if let Some(error) = unsendable { - self.end_session(key, SessionEnd::Unsendable(error))?; + self.send_packet(key.remote_addr, &ack)?; } Ok(CultMeshRudpPollOutcome::Handled) } @@ -591,17 +373,11 @@ where let mut resends = Vec::new(); for (key, entry) in &mut self.sessions { for packet in entry.session.due_resends(now) { - resends.push((*key, packet)); + resends.push((key.remote_addr, packet)); } } - for (key, packet) in &resends { - // A session ended earlier in this loop has nothing left to resend. - if !self.sessions.contains_key(key) { - continue; - } - if let Some(error) = self.send_packet(key.remote_addr, packet)? { - self.end_session(*key, SessionEnd::Unsendable(error))?; - } + for (remote_addr, packet) in &resends { + self.send_packet(*remote_addr, packet)?; } Ok(CultMeshRudpMaintenance { sessions_expired: expired, @@ -609,65 +385,45 @@ where }) } - /// `Ok(false)` when the Connect was refused because the session cap is full; - /// only a socket failure is an `Err`. fn accept_connection( &mut self, key: CultMeshRudpSessionKey, packet: &CultNetRudpPacket, now: u64, - ) -> Result { - // The session decides whether a Connect repeats the one it accepted. Any - // other Connect from this key is a new client session: the old one ends - // with its budget, and the new one starts fresh. - if self - .sessions - .get(&key) - .is_some_and(|entry| !entry.session.connect_repeats(packet)) - { - self.sessions.remove(&key); + ) -> Result<()> { + if !self.sessions.contains_key(&key) { + if self.sessions.len() >= self.options.max_sessions { + return Ok(()); + } + self.sessions.insert( + key, + SessionEntry { + session: CultNetRudpSession::new(CultNetRudpSessionOptions { + connection_id: key.connection_id, + initial_sequence: 1, + resend_delay_ms: duration_millis(self.options.resend_delay), + max_pending_reliable_packets: Some( + self.options.max_pending_reliable_packets_per_session, + ), + }), + created_at_monotonic_millis: now, + last_activity_monotonic_millis: now, + admitted_payload_bytes: 0, + }, + ); } - let reply = match self.sessions.get_mut(&key) { - Some(entry) => { - entry.last_activity_monotonic_millis = now; - match entry.session.accept_connect(packet, now, Vec::new()) { - Ok(reply) => reply, - Err(_) => { - self.end_session(key, SessionEnd::Refused)?; - return Ok(false); - } - } - } - None => { - if self.sessions.len() >= self.options.max_sessions { - return Ok(false); - } - let mut session = CultNetRudpSession::new(CultNetRudpSessionOptions { - connection_id: key.connection_id, - initial_sequence: None, - resend_delay_ms: duration_millis(self.options.resend_delay), - max_pending_reliable_packets: Some( - self.options.max_pending_reliable_packets_per_session, - ), - }); - let accept = session.accept_connect(packet, now, Vec::new())?; - self.sessions.insert( - key, - SessionEntry { - session, - created_at_monotonic_millis: now, - last_activity_monotonic_millis: now, - admitted_payload_bytes: 0, - }, - ); - accept - } + + let accept = { + let entry = self + .sessions + .get_mut(&key) + .expect("accepted session must be present"); + // The same key is a retransmitted Connect for the existing epoch. + // A genuinely fresh client incarnation must choose a fresh id. + entry.last_activity_monotonic_millis = now; + entry.session.accept_connect(packet, now, Vec::new())? }; - if let Some(error) = self.send_packet(key.remote_addr, &reply)? { - self.end_session(key, SessionEnd::Unsendable(error))?; - return Ok(false); - } - Ok(true) + self.send_packet(key.remote_addr, &accept) } fn deliver_application_message( @@ -683,49 +439,6 @@ where message_id, document, } => { - let reject = |reason| { - Ok(Some(CultMeshRudpApplicationRejection { - session: key, - operation: CultMeshRudpApplicationOperation::DocumentPutRaw, - message_id: message_id.clone(), - reason, - })) - }; - // Admit only what some snapshot request can return: the smallest - // response that could carry this document is the record the snapshot - // source would serve for it, alone, under the shortest message id - // CultNet encodes, sized by the snapshot path's encoder and fragmented - // as the snapshot path sends it. - let served = match self.snapshot_source.served_record(&document) { - Ok(served) => served, - Err(error) => { - return reject(CultMeshRudpRejectionReason::SnapshotSourceFailed( - format!("{error:#}"), - )); - } - }; - let alone = CultNetMessage::SnapshotResponseRaw { - message_id: SHORTEST_MESSAGE_ID.into(), - documents: vec![served], - }; - let response_bytes = match encode_snapshot_response(&alone) { - Ok(payload) => payload.len(), - Err(error) => { - return reject(CultMeshRudpRejectionReason::ResponseEncodingFailed(error)); - } - }; - let fragment_count = self.fragments_for(response_bytes); - let max_fragment_count = self.max_fragments_per_response(); - if response_bytes > self.options.max_snapshot_response_bytes - || fragment_count > max_fragment_count - { - return reject(CultMeshRudpRejectionReason::DocumentUnservable { - response_bytes, - max_snapshot_response_bytes: self.options.max_snapshot_response_bytes, - fragment_count, - max_fragment_count, - }); - } let receipt = CultMeshRudpRawDocumentReceipt { session: key, message_id: message_id.clone(), @@ -734,9 +447,12 @@ where document, }; if let Err(error) = self.sink.accept_raw_document(receipt) { - return reject(CultMeshRudpRejectionReason::SinkRefused(format!( - "{error:#}" - ))); + return Ok(Some(CultMeshRudpApplicationRejection { + session: key, + operation: CultMeshRudpApplicationOperation::DocumentPutRaw, + message_id, + reason: format!("{error:#}"), + })); } } CultNetMessage::SnapshotRequest { @@ -758,9 +474,7 @@ where session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::SnapshotSourceFailed(format!( - "{error:#}" - )), + reason: format!("{error:#}"), })); } }; @@ -769,24 +483,28 @@ where session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::SnapshotTooManyDocuments { - documents: documents.len(), - max_snapshot_documents: self.options.max_snapshot_documents, - }, + reason: format!( + "snapshot returned {} documents; limit is {}", + documents.len(), + self.options.max_snapshot_documents + ), })); } let response = CultNetMessage::SnapshotResponseRaw { message_id: message_id.clone(), documents, }; - let payload = match encode_snapshot_response(&response) { + let payload = match encode_cultnet_message_to_vec( + &response, + CultNetWireContract::CultNetSchemaV0, + ) { Ok(payload) => payload, Err(error) => { return Ok(Some(CultMeshRudpApplicationRejection { session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::ResponseEncodingFailed(error), + reason: format!("snapshot response could not be encoded: {error:#}"), })); } }; @@ -795,10 +513,11 @@ where session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::SnapshotResponseTooLarge { - response_bytes: payload.len(), - max_snapshot_response_bytes: self.options.max_snapshot_response_bytes, - }, + reason: format!( + "snapshot response is {} bytes; limit is {}", + payload.len(), + self.options.max_snapshot_response_bytes + ), })); } if !self.payload_budget_allows(key, payload.len()) { @@ -806,7 +525,7 @@ where session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::PayloadBudgetFull, + reason: "retained payload budget is full".into(), })); } let payload_bytes = payload.len(); @@ -832,25 +551,14 @@ where session: key, operation: CultMeshRudpApplicationOperation::SnapshotRequest, message_id, - reason: CultMeshRudpRejectionReason::ResponseQueueFailed(format!( - "{error:#}" - )), + reason: format!("snapshot response could not be queued: {error:#}"), })); } }; entry.admitted_payload_bytes = entry.admitted_payload_bytes.saturating_add(payload_bytes); for packet in &packets { - if let Some(error) = self.send_packet(key.remote_addr, packet)? { - let code = send_error_code(&error); - self.end_session(key, SessionEnd::Unsendable(error))?; - return Ok(Some(CultMeshRudpApplicationRejection { - session: key, - operation: CultMeshRudpApplicationOperation::SnapshotRequest, - message_id, - reason: CultMeshRudpRejectionReason::ResponseSendFailed(code), - })); - } + self.send_packet(key.remote_addr, packet)?; } } _ => {} @@ -858,86 +566,6 @@ where Ok(None) } - /// Ends a session before its peer is done with it, and says goodbye. It is - /// the one way a session ends early: every end removes the session, sends - /// what the peer is owed, then the goodbye. - /// - /// A rejected message's refusal goes first, unreliable and unordered: the - /// session ends with it, so it is never resent, and a gap in what the peer - /// has received must not hold it back. It is built before the reset and - /// carries acknowledgement fields built after it, which acknowledge - /// nothing: a publisher reads an acknowledgement as admission. A refusal - /// that can never be sent as built is not dropped: the goodbye names its - /// error instead. A refusal that cannot be encoded is not sent. - fn end_session(&mut self, key: CultMeshRudpSessionKey, end: SessionEnd) -> Result<()> { - let Some(mut entry) = self.sessions.remove(&key) else { - return Ok(()); - }; - let (refusal, mut unsendable) = match end { - SessionEnd::Refused => (Vec::new(), None), - SessionEnd::Rejected(text) => (self.refusal_packets(&mut entry.session, text), None), - SessionEnd::Unsendable(error) => (Vec::new(), Some(error)), - }; - entry.session.reset_peer_state(); - let nothing = entry.session.create_ack(); - for mut packet in refusal { - packet.ack = nothing.ack; - packet.ack_mask = nothing.ack_mask; - if let Some(error) = self.send_packet(key.remote_addr, &packet)? { - unsendable = Some(error); - break; - } - } - let goodbye = match &unsendable { - Some(error) => entry.session.end_unsendable_session(error), - None => entry.session.end_refused_session(), - }; - // The goodbye is the session's last datagram. If it too can never be - // sent, nobody is left to tell. - self.send_packet(key.remote_addr, &goodbye)?; - Ok(()) - } - - /// The refusal a rejected peer is sent, as unreliable, unordered packets. - fn refusal_packets( - &self, - session: &mut CultNetRudpSession, - text: &str, - ) -> Vec { - let refusal = CultNetMessage::Error { - error: text.into(), - code: None, - details: None, - }; - encode_cultnet_message_to_vec(&refusal, CultNetWireContract::CultNetSchemaV0) - .and_then(|payload| { - session.send_many( - "schema", - payload, - CultNetRudpSendOptions { - reliable: false, - ordered: false, - sequenced: false, - now_ms: self.clock.now_monotonic_millis(), - reliable_expire_after_ms: None, - }, - Some(self.options.max_fragment_bytes), - ) - }) - .unwrap_or_default() - } - - /// The fragments `send_many` splits a response of `bytes` into. - fn fragments_for(&self, bytes: usize) -> usize { - bytes.div_ceil(self.options.max_fragment_bytes).max(1) - } - - /// The most fragments one response can take: one message's fragment count, - /// and the reliable queue it must fit into whole. - fn max_fragments_per_response(&self) -> usize { - MAX_FRAGMENTS_PER_MESSAGE.min(self.options.max_pending_reliable_packets_per_session) - } - fn payload_budget_allows(&self, key: CultMeshRudpSessionKey, bytes: usize) -> bool { let Some(session_bytes) = self .sessions @@ -961,48 +589,13 @@ where .is_some_and(|total| total <= self.options.max_admitted_payload_bytes) } - /// A transient send failure is that peer's lost datagram: counted, never an - /// error. A permanent one (`is_permanent_send_error`) is returned as `Some` - /// for the caller to end the session over. Only an encode failure, the - /// server's own bug, is an error. - fn send_packet( - &mut self, - remote_addr: SocketAddr, - packet: &CultNetRudpPacket, - ) -> Result> { + fn send_packet(&mut self, remote_addr: SocketAddr, packet: &CultNetRudpPacket) -> Result<()> { let wire = encode_rudp_packet(packet)?; - match self.send_datagram(&wire, remote_addr) { - Ok(_) => {} - Err(error) if is_permanent_send_error(&error) => return Ok(Some(error)), - Err(_) => self.send_failures += 1, - } - Ok(None) - } - - fn send_datagram(&mut self, wire: &[u8], remote_addr: SocketAddr) -> std::io::Result { - #[cfg(test)] - { - match self.unsendable_after.get(&remote_addr).copied() { - Some(0) => { - self.unsendable_after.remove(&remote_addr); - return Err(std::io::Error::from(ErrorKind::InvalidInput)); - } - Some(remaining) => { - self.unsendable_after.insert(remote_addr, remaining - 1); - } - None => {} - } - if self.failing_peers.contains(&remote_addr) { - return Err(std::io::Error::other("injected send failure")); - } - } - self.socket.send_to(wire, remote_addr) + self.socket.send_to(&wire, remote_addr)?; + Ok(()) } } -#[cfg(test)] -mod send_failure_tests; - fn validate_options(options: &CultMeshRudpDocumentServerOptions) -> Result<()> { if options.max_sessions == 0 { return Err(anyhow!("max_sessions must be greater than zero")); @@ -1046,37 +639,9 @@ fn validate_options(options: &CultMeshRudpDocumentServerOptions) -> Result<()> { if options.max_fragment_bytes == 0 { return Err(anyhow!("max_fragment_bytes must be greater than zero")); } - // The limits must leave room for the smallest response the server sends, an - // empty snapshot: a server that could answer nothing is misconfigured. - let empty = encode_snapshot_response(&CultNetMessage::SnapshotResponseRaw { - message_id: SHORTEST_MESSAGE_ID.into(), - documents: Vec::new(), - }) - .map_err(|error| anyhow!(error))? - .len(); - if empty > options.max_snapshot_response_bytes { - return Err(anyhow!( - "max_snapshot_response_bytes cannot hold an empty snapshot response" - )); - } - let max_fragments = - MAX_FRAGMENTS_PER_MESSAGE.min(options.max_pending_reliable_packets_per_session); - if empty.div_ceil(options.max_fragment_bytes) > max_fragments { - return Err(anyhow!( - "max_fragment_bytes and max_pending_reliable_packets_per_session cannot carry an empty snapshot response" - )); - } Ok(()) } - -/// The one encoder for a snapshot response, shared by the snapshot path and by -/// put admission so the size a put is judged by is the size it would be served at. -fn encode_snapshot_response(response: &CultNetMessage) -> std::result::Result, String> { - encode_cultnet_message_to_vec(response, CultNetWireContract::CultNetSchemaV0) - .map_err(|error| format!("{error:#}")) -} - fn duration_millis(duration: Duration) -> u64 { duration.as_millis().try_into().unwrap_or(u64::MAX) } diff --git a/packages/cultmesh-rs/src/rudp_document_server/send_failure_tests.rs b/packages/cultmesh-rs/src/rudp_document_server/send_failure_tests.rs deleted file mode 100644 index bbf3dee1..00000000 --- a/packages/cultmesh-rs/src/rudp_document_server/send_failure_tests.rs +++ /dev/null @@ -1,502 +0,0 @@ -//! One peer whose datagrams cannot be sent must not stop the server serving -//! the others. The failure is injected in `send_packet` through -//! `failing_peers`; a loopback peer cannot be made unroutable on demand. - -use super::*; -use cultnet_rs::{ - CultNetRawPayloadEncoding, CultNetRudpSocketMode, CultNetRudpSocketTransportConnection, - CultNetRudpSocketTransportOptions, -}; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Arc, Mutex}; -use std::thread; - -#[derive(Clone)] -struct Clock(Arc); - -impl CultMeshRudpServerClock for Clock { - fn now_unix_millis(&self) -> u64 { - self.0.load(Ordering::SeqCst) - } - fn now_monotonic_millis(&self) -> u64 { - self.0.load(Ordering::SeqCst) - } -} - -type Received = Arc>>; -type Server = CultMeshRudpDocumentServer< - Box Result<()>>, - Box Result>>, - Clock, ->; -type Client = CultNetRudpSocketTransportConnection; - -fn document(key: &str) -> CultNetRawDocumentRecord { - CultNetRawDocumentRecord { - schema_id: "test.raw.v1".into(), - record_key: key.into(), - stored_at: "2026-09-03T00:00:00Z".into(), - payload_encoding: CultNetRawPayloadEncoding::Messagepack, - payload: vec![0x81, 0xa1, 0x78, 0x2a], - source_runtime_id: None, - source_agent_id: None, - source_role: None, - tags: None, - } -} - -fn client(target: SocketAddr, id: u32) -> (Client, SocketAddr) { - let socket = UdpSocket::bind("127.0.0.1:0").unwrap(); - socket.set_nonblocking(true).unwrap(); - let addr = socket.local_addr().unwrap(); - let client = CultNetRudpSocketTransportConnection::new(CultNetRudpSocketTransportOptions { - media_delivery: None, - runtime_id: "test-client".into(), - socket, - mode: CultNetRudpSocketMode::Client, - remote_addr: Some(target), - connection_id: id, - initial_sequence: Some(1), - resend_delay_ms: 10, - transport_id: None, - max_payload_bytes: None, - max_fragment_bytes: Some(1200), - max_pending_reliable_packets: Some(64), - media_reliable_expire_after_ms: None, - reconnect_policy: None, - }) - .unwrap(); - (client, addr) -} - -fn send(client: &mut Client, message: &CultNetMessage) { - client - .send( - "schema", - encode_cultnet_message_to_vec(message, CultNetWireContract::CultNetSchemaV0).unwrap(), - ) - .unwrap(); -} - -/// A server with a 1 s idle timeout and two connected peers, the first -/// returned being the one whose address sorts first. -fn two_peers() -> ( - Server, - Clock, - Received, - (Client, SocketAddr), - (Client, SocketAddr), -) { - let clock = Clock(Arc::new(AtomicU64::new(1_000))); - let received: Received = Arc::default(); - let sink_received = received.clone(); - let sink: Box Result<()>> = - Box::new(move |receipt| { - sink_received.lock().unwrap().push(receipt.message_id); - Ok(()) - }); - let source: Box< - dyn FnMut(&CultMeshRudpSnapshotQuery) -> Result>, - > = Box::new(|_| Ok(vec![document("catalog")])); - let mut server = CultMeshRudpDocumentServer::new( - UdpSocket::bind("127.0.0.1:0").unwrap(), - sink, - source, - clock.clone(), - CultMeshRudpDocumentServerOptions { - session_idle_timeout: Duration::from_secs(1), - resend_delay: Duration::from_millis(10), - ..Default::default() - }, - ) - .unwrap(); - let target = server.local_addr().unwrap(); - let (mut a, a_addr) = client(target, 7); - let (mut b, b_addr) = client(target, 7); - a.connect(Vec::new()).unwrap(); - b.connect(Vec::new()).unwrap(); - for _ in 0..500 { - server.poll_once().unwrap(); - a.receive_once().unwrap(); - b.receive_once().unwrap(); - if a.connected() && b.connected() { - break; - } - thread::sleep(Duration::from_millis(1)); - } - assert!(a.connected() && b.connected()); - for _ in 0..4 { - server.poll_once().unwrap(); - } - assert_eq!(server.session_count(), 2); - if a_addr < b_addr { - (server, clock, received, (a, a_addr), (b, b_addr)) - } else { - (server, clock, received, (b, b_addr), (a, a_addr)) - } -} - -#[test] -fn one_peer_whose_sends_fail_does_not_stop_the_server_serving_the_others() { - let (mut server, clock, received, (mut x, x_addr), (mut y, _)) = two_peers(); - server.failing_peers.insert(x_addr); - - // X's reply, ack and snapshot response all fail to send. X is visited first. - send( - &mut x, - &CultNetMessage::SnapshotRequest { - message_id: "x-snapshot".into(), - schema_ids: None, - record_keys: None, - }, - ); - send( - &mut y, - &CultNetMessage::DocumentPutRaw { - message_id: "y-put".into(), - document: document("y"), - }, - ); - send( - &mut y, - &CultNetMessage::SnapshotRequest { - message_id: "y-snapshot".into(), - schema_ids: None, - record_keys: None, - }, - ); - let mut y_response = None; - for step in 0..200 { - // The clock moves past X's resend delay so `maintain` has X's resend due. - clock.0.store(1_000 + step * 15, Ordering::SeqCst); - // Never `Err`: X's failed sends are its own lost datagrams. - server.poll_once().unwrap(); - if let Some(frame) = y.receive_once().unwrap() { - y_response = Some(frame); - break; - } - thread::sleep(Duration::from_millis(1)); - } - let frame = y_response.expect("Y receives its snapshot response"); - let response = - decode_cultnet_message_from_slice(&frame.payload, CultNetWireContract::CultNetSchemaV0) - .unwrap(); - assert!(matches!( - response, - CultNetMessage::SnapshotResponseRaw { ref message_id, .. } if message_id == "y-snapshot" - )); - assert!(server.send_failures() > 0); - assert_eq!(received.lock().unwrap().as_slice(), ["y-put"]); - assert!(server.maintain().is_ok()); - - // X's session ends by the idle rule that already ends sessions, not by the - // failure: Y stays active, X does not. - clock.0.store(1_900, Ordering::SeqCst); - send( - &mut y, - &CultNetMessage::DocumentPutRaw { - message_id: "y-put-2".into(), - document: document("y2"), - }, - ); - for _ in 0..20 { - server.poll_once().unwrap(); - thread::sleep(Duration::from_millis(1)); - } - assert_eq!(server.session_count(), 2, "the failure ended no session"); - clock.0.store(2_500, Ordering::SeqCst); - let maintenance = server.maintain().unwrap(); - assert_eq!(maintenance.sessions_expired, 1); - assert_eq!(server.session_count(), 1); -} - -// A permanent send failure is one that can never succeed for the datagram as -// built (`is_permanent_send_error`). It ends that peer's session, never the -// poll, and the peer's goodbye names the error. - -fn put(id: &str) -> CultNetMessage { - CultNetMessage::DocumentPutRaw { - message_id: id.into(), - document: document(id), - } -} - -fn snapshot(id: &str) -> CultNetMessage { - CultNetMessage::SnapshotRequest { - message_id: id.into(), - schema_ids: None, - record_keys: None, - } -} - -fn goodbye_reason(client: &mut Client) -> Vec { - for _ in 0..50 { - client.receive_once().unwrap(); - if let Some(reason) = client.disconnect_reason() { - return reason.to_vec(); - } - thread::sleep(Duration::from_millis(2)); - } - panic!("the client was never told the session ended"); -} - -fn is_unsendable_reason(reason: &[u8]) -> bool { - reason.starts_with(b"packet could not be sent: ") - && reason.len() > b"packet could not be sent: ".len() -} - -#[test] -fn a_permanent_failure_acknowledging_a_document_ends_the_session_after_the_document_is_kept() { - let (mut server, _clock, received, (mut x, x_addr), (mut y, _)) = two_peers(); - server.unsendable_after.insert(x_addr, 0); - send(&mut x, &put("x-put")); - send(&mut y, &put("y-put")); - - for _ in 0..10 { - // Never `Err`: the failure ends X's session, not the poll. - server.poll_once().unwrap(); - } - let mut kept = received.lock().unwrap().clone(); - kept.sort(); - assert_eq!(kept, ["x-put", "y-put"]); - assert_eq!(server.session_count(), 1); - assert_eq!(server.send_failures(), 0); - assert!(is_unsendable_reason(&goodbye_reason(&mut x))); -} - -#[test] -fn a_permanent_failure_sending_a_snapshot_response_rejects_it_and_sends_no_refusal() { - let (mut server, _clock, _received, (mut x, x_addr), (_y, _)) = two_peers(); - server.unsendable_after.insert(x_addr, 0); - send(&mut x, &snapshot("x-snapshot")); - - let mut rejection = None; - for _ in 0..10 { - if let CultMeshRudpPollOutcome::ApplicationRejected(found) = server.poll_once().unwrap() { - rejection = Some(found); - break; - } - } - let rejection = rejection.expect("the response can never be sent"); - assert_eq!(rejection.operation, CultMeshRudpApplicationOperation::SnapshotRequest); - assert_eq!(rejection.message_id, "x-snapshot"); - assert_eq!( - rejection.reason, - CultMeshRudpRejectionReason::ResponseSendFailed("EINVAL") - ); - assert_eq!(server.session_count(), 1); - // The server knows X cannot be reached: X is sent no refusal, only the - // goodbye naming the error, which carries no text of the peer's. - let mut frames = Vec::new(); - let mut reason = None; - for _ in 0..50 { - if let Some(frame) = x.receive_once().unwrap() { - frames.push(frame); - } - if let Some(found) = x.disconnect_reason() { - reason = Some(found.to_vec()); - break; - } - thread::sleep(Duration::from_millis(2)); - } - assert!( - frames.is_empty(), - "no refusal is sent to an unreachable peer: {frames:?}" - ); - // The goodbye names the failure by its fixed name, never the error's text. - assert_eq!( - reason.expect("the client was told the session ended"), - b"packet could not be sent: EINVAL" - ); -} - -#[test] -fn a_permanent_failure_in_resends_ends_only_that_peers_session() { - let (mut server, clock, received, (mut x, x_addr), (mut y, _)) = two_peers(); - // X's snapshot response is lost, so a resend is due; then the datagram can - // never be sent as built. - server.failing_peers.insert(x_addr); - send(&mut x, &snapshot("x-snapshot")); - for _ in 0..5 { - server.poll_once().unwrap(); - } - server.failing_peers.clear(); - server.unsendable_after.insert(x_addr, 0); - clock.0.store(1_200, Ordering::SeqCst); - - let maintenance = server.maintain().unwrap(); - assert!(maintenance.packets_resent > 0); - assert_eq!(server.session_count(), 1); - assert!(is_unsendable_reason(&goodbye_reason(&mut x))); - - send(&mut y, &put("y-put")); - for _ in 0..5 { - server.poll_once().unwrap(); - } - assert_eq!(received.lock().unwrap().as_slice(), ["y-put"]); -} - -#[test] -fn a_connect_whose_accept_can_never_be_sent_starts_no_session() { - let (mut server, _clock, _received, _x, _y) = two_peers(); - let (mut z, z_addr) = client(server.local_addr().unwrap(), 9); - server.unsendable_after.insert(z_addr, 0); - z.connect(Vec::new()).unwrap(); - - for _ in 0..10 { - server.poll_once().unwrap(); - thread::sleep(Duration::from_millis(1)); - } - assert_eq!(server.session_count(), 2); - assert_eq!(server.packets_dropped(), 1); -} - -#[test] -fn healthy_sends_are_not_failures() { - let (mut server, _clock, _received, (mut x, _), (_y, _)) = two_peers(); - send(&mut x, &put("x-put")); - send(&mut x, &snapshot("x-snapshot")); - for _ in 0..10 { - server.poll_once().unwrap(); - thread::sleep(Duration::from_millis(1)); - } - assert_eq!(server.send_failures(), 0); - assert_eq!(server.session_count(), 2); -} - -#[test] -fn a_session_ended_in_the_resend_loop_is_sent_nothing_more_from_it() { - let (mut server, clock, _received, (mut x, x_addr), (_y, _)) = two_peers(); - server.failing_peers.insert(x_addr); - send(&mut x, &snapshot("one")); - send(&mut x, &snapshot("two")); - for _ in 0..10 { - server.poll_once().unwrap(); - } - let before = server.send_failures(); - - server.unsendable_after.insert(x_addr, 0); - clock.0.store(1_200, Ordering::SeqCst); - let maintenance = server.maintain().unwrap(); - - // Both responses are due. The first can never be sent and ends the session; - // the goodbye is the only other datagram attempted at X. - assert_eq!(maintenance.packets_resent, 2); - assert_eq!(server.send_failures() - before, 1); - assert_eq!(server.session_count(), 1); -} - -#[test] -fn no_ack_follows_a_reply_that_can_never_be_sent() { - let (mut server, _clock, _received, _x, _y) = two_peers(); - let target = server.local_addr().unwrap(); - // A peer driven packet by packet: a client never sends a reliable Ping, but a - // peer may, and the server both answers it and acknowledges it. - let socket = UdpSocket::bind("127.0.0.1:0").unwrap(); - socket - .set_read_timeout(Some(Duration::from_millis(20))) - .unwrap(); - let addr = socket.local_addr().unwrap(); - let mut session = CultNetRudpSession::new(CultNetRudpSessionOptions { - connection_id: 7, - ..Default::default() - }); - let connect = session.create_connect(0, Vec::new()).unwrap(); - socket - .send_to(&encode_rudp_packet(&connect).unwrap(), target) - .unwrap(); - let mut wire = vec![0_u8; MAX_UDP_DATAGRAM_BYTES]; - for _ in 0..10 { - server.poll_once().unwrap(); - } - let (read, _) = socket.recv_from(&mut wire).unwrap(); - let accept = decode_rudp_packet(&wire[..read]).unwrap(); - assert_eq!(accept.packet_type, CultNetRudpPacketType::Accept); - session.receive(&accept, 0).unwrap(); - assert_eq!(server.session_count(), 3); - - let mut ping = session.create_ping(b"p".to_vec()); - ping.reliable = true; - ping.sequence = connect.sequence.wrapping_add(1); - // The Pong can never be sent; the ack after it could. - server.unsendable_after.insert(addr, 0); - socket - .send_to(&encode_rudp_packet(&ping).unwrap(), target) - .unwrap(); - for _ in 0..10 { - server.poll_once().unwrap(); - } - - // The session ends over the Pong: the peer gets its goodbye and nothing else. - assert_eq!(server.session_count(), 2); - let mut arrived = Vec::new(); - while let Ok((read, _)) = socket.recv_from(&mut wire) { - arrived.push(decode_rudp_packet(&wire[..read]).unwrap()); - } - assert_eq!(arrived.len(), 1, "{arrived:?}"); - assert_eq!(arrived[0].packet_type, CultNetRudpPacketType::Disconnect); - assert!(is_unsendable_reason(&arrived[0].payload)); -} - -/// Windows reports an ICMP port-unreachable for an earlier datagram as -/// `ConnectionReset` on the next receive. It names no datagram of this poll, so -/// the poll is idle and the server goes on serving. Only Windows reports it, so -/// only a Windows run can see the rule break. -#[cfg(windows)] -#[test] -fn a_reset_reported_by_a_receive_is_idle_not_an_error() { - let (mut server, _clock, received, (mut x, _), (mut y, _)) = two_peers(); - // X asks for a snapshot and goes away before the answer. - send(&mut x, &snapshot("x-snapshot")); - drop(x); - for _ in 0..20 { - server - .poll_once() - .expect("a reset from X's closed port is not an error"); - thread::sleep(Duration::from_millis(1)); - } - - send(&mut y, &put("y-put")); - for _ in 0..20 { - server.poll_once().unwrap(); - thread::sleep(Duration::from_millis(1)); - } - assert_eq!(received.lock().unwrap().as_slice(), ["y-put"]); -} - -#[test] -fn a_refusal_that_can_never_be_sent_ends_the_session_naming_the_error() { - let (mut server, _clock, received, (mut x, x_addr), (mut y, _)) = two_peers(); - // Any document is now unservable, so X's put is refused; the refusal is - // the first datagram X is owed, and it can never be sent as built. - server.options.max_snapshot_response_bytes = 16; - server.unsendable_after.insert(x_addr, 0); - send(&mut x, &put("x-put")); - let mut rejected = false; - for _ in 0..10 { - rejected |= matches!( - server.poll_once().unwrap(), - CultMeshRudpPollOutcome::ApplicationRejected(_) - ); - } - assert!(rejected); - assert!(received.lock().unwrap().is_empty()); - assert_eq!(server.session_count(), 1); - // The failure is not dropped: the goodbye names it, where a refusal's - // goodbye would say the session refused a packet. - assert!(is_unsendable_reason(&goodbye_reason(&mut x))); - assert_eq!(server.send_failures(), 0); - server.options.max_snapshot_response_bytes = - CultMeshRudpDocumentServerOptions::default().max_snapshot_response_bytes; - send(&mut y, &snapshot("y-snapshot")); - let mut served = false; - for _ in 0..50 { - server.poll_once().unwrap(); - if y.receive_once().unwrap().is_some() { - served = true; - break; - } - thread::sleep(Duration::from_millis(1)); - } - assert!(served, "the other peer is still served"); -} diff --git a/packages/cultmesh-rs/tests/rudp_document_server.rs b/packages/cultmesh-rs/tests/rudp_document_server.rs index 30fe4678..df14b4ea 100644 --- a/packages/cultmesh-rs/tests/rudp_document_server.rs +++ b/packages/cultmesh-rs/tests/rudp_document_server.rs @@ -2,8 +2,8 @@ use anyhow::Result; use cultmesh_rs::{ CultMeshRudpApplicationOperation, CultMeshRudpDocumentServer, CultMeshRudpDocumentServerOptions, CultMeshRudpPollOutcome, CultMeshRudpRawDocumentReceipt, - CultMeshRudpRawDocumentSink, CultMeshRudpRejectionReason, CultMeshRudpServerClock, - CultMeshRudpSnapshotQuery, CultMeshRudpSnapshotSource, + CultMeshRudpRawDocumentSink, CultMeshRudpServerClock, CultMeshRudpSnapshotQuery, + CultMeshRudpSnapshotSource, }; use cultnet_rs::{ CultNetMessage, CultNetRawDocumentRecord, CultNetRawPayloadEncoding, @@ -41,7 +41,7 @@ impl CultMeshRudpRawDocumentSink for Sink { let mut state = self.0.lock().unwrap(); if state.failures_remaining > 0 { state.failures_remaining -= 1; - anyhow::bail!("injected sink failure CANARY-7f3a"); + anyhow::bail!("injected sink failure"); } state.receipts.push(receipt); Ok(()) @@ -70,22 +70,11 @@ impl Source { Self(Arc::new(Mutex::new(SourceState { documents, failures_remaining: 1, - ..Default::default() + calls: 0, }))) } } -/// `document` without the source provenance a peer reports about itself. -fn stripped(document: &CultNetRawDocumentRecord) -> CultNetRawDocumentRecord { - CultNetRawDocumentRecord { - source_runtime_id: None, - source_agent_id: None, - source_role: None, - tags: None, - ..document.clone() - } -} - impl CultMeshRudpSnapshotSource for Source { fn raw_snapshot( &mut self, @@ -95,54 +84,12 @@ impl CultMeshRudpSnapshotSource for Source { state.calls += 1; if state.failures_remaining > 0 { state.failures_remaining -= 1; - anyhow::bail!("injected source failure CANARY-7f3a"); + anyhow::bail!("injected source failure"); } Ok(state.documents.clone()) } } -/// A source that serves `Source`'s records without source provenance, and says -/// so to admission through `served_record`. `Source` keeps the default. -#[derive(Clone, Default)] -struct StrippingSource { - inner: Source, - /// Refuses to say what it would serve. - served_record_fails: bool, -} - -impl CultMeshRudpSnapshotSource for StrippingSource { - fn raw_snapshot( - &mut self, - query: &CultMeshRudpSnapshotQuery, - ) -> Result> { - Ok(self.inner.raw_snapshot(query)?.iter().map(stripped).collect()) - } - - fn served_record( - &mut self, - document: &CultNetRawDocumentRecord, - ) -> Result { - if self.served_record_fails { - anyhow::bail!("injected served-record failure"); - } - Ok(stripped(document)) - } -} - -fn stripping_server( - options: CultMeshRudpDocumentServerOptions, - sink: Sink, - source: StrippingSource, -) -> Result> { - CultMeshRudpDocumentServer::new( - UdpSocket::bind("127.0.0.1:0")?, - sink, - source, - Clock::new(64_000), - options, - ) -} - #[derive(Clone)] struct Clock { unix: Arc, @@ -213,15 +160,7 @@ fn server( } fn client(target: SocketAddr, id: u32) -> Result { - client_on(UdpSocket::bind("127.0.0.1:0")?, target, id, 1) -} - -fn client_on( - socket: UdpSocket, - target: SocketAddr, - id: u32, - initial_sequence: u32, -) -> Result { + let socket = UdpSocket::bind("127.0.0.1:0")?; socket.set_nonblocking(true)?; CultNetRudpSocketTransportConnection::new(CultNetRudpSocketTransportOptions { media_delivery: None, @@ -230,7 +169,7 @@ fn client_on( mode: CultNetRudpSocketMode::Client, remote_addr: Some(target), connection_id: id, - initial_sequence: Some(initial_sequence), + initial_sequence: 1, resend_delay_ms: 10, transport_id: None, max_payload_bytes: None, @@ -241,8 +180,8 @@ fn client_on( }) } -fn connect( - server: &mut CultMeshRudpDocumentServer, +fn connect( + server: &mut Server, clients: &mut [&mut CultNetRudpSocketTransportConnection], ) -> Result<()> { for client in &mut *clients { @@ -264,144 +203,6 @@ fn connect( anyhow::bail!("client connection timed out") } -/// The encoded size of the snapshot response that carries `document` alone -/// under a one-character message id, the shortest CultNet encodes: the -/// smallest response that could ever serve it. -fn served_alone_bytes(document: &CultNetRawDocumentRecord) -> Result { - Ok(encode_cultnet_message_to_vec( - &CultNetMessage::SnapshotResponseRaw { - message_id: "r".into(), - documents: vec![document.clone()], - }, - CultNetWireContract::CultNetSchemaV0, - )? - .len()) -} - -/// A document keyed `key` whose served-alone response is exactly `bytes`. -fn document_served_at(key: &str, bytes: usize) -> Result { - let probe = bytes / 2; - let base = served_alone_bytes(&document(key, vec![7; probe]))?; - let fitted = document(key, vec![7; probe + bytes - base]); - assert_eq!( - served_alone_bytes(&fitted)?, - bytes, - "fixture: the served size is linear in the payload" - ); - Ok(fitted) -} - -/// Polls the server and client until the client receives a frame. -fn serve_until_frame( - server: &mut CultMeshRudpDocumentServer, - client: &mut CultNetRudpSocketTransportConnection, -) -> Result> { - for _ in 0..2_000 { - let outcome = server.poll_once()?; - assert!( - !matches!(outcome, CultMeshRudpPollOutcome::ApplicationRejected(_)), - "{outcome:?}" - ); - if let Some(frame) = client.receive_once()? { - return Ok(frame.payload); - } - thread::sleep(Duration::from_millis(1)); - } - anyhow::bail!("the client received no frame") -} - -/// Polls the server, and the client so its sends progress, until the server -/// returns a rejection or the sink holds `receipts`. -fn poll_until_rejected_or_stored( - server: &mut CultMeshRudpDocumentServer, - client: &mut CultNetRudpSocketTransportConnection, - sink: &Sink, - receipts: usize, -) -> Result> { - for _ in 0..5_000 { - client.receive_once()?; - client.poll_resends()?; - match server.poll_once()? { - CultMeshRudpPollOutcome::ApplicationRejected(rejection) => { - return Ok(Some(rejection.reason)); - } - CultMeshRudpPollOutcome::Idle => thread::sleep(Duration::from_millis(1)), - _ => {} - } - if sink.0.lock().unwrap().receipts.len() >= receipts { - return Ok(None); - } - } - anyhow::bail!("the put was neither refused nor stored") -} - -/// What a refused peer is sent: a `cultnet.error.v0` carrying fixed text, never -/// a sink's or source's error (the fixtures' errors carry a canary), then the goodbye. The -/// refused message is never acknowledged, so its receipt stays pending until the -/// goodbye invalidates it. Returns the refusal's text. -fn refusal_seen_by( - client: &mut CultNetRudpSocketTransportConnection, - receipt: &CultNetRudpReliableSendReceipt, -) -> Result { - let mut refusal = None; - for _ in 0..2_000 { - if let Some(frame) = client.receive_once()? { - refusal = Some(decode_cultnet_message_from_slice( - &frame.payload, - CultNetWireContract::CultNetSchemaV0, - )?); - break; - } - thread::sleep(Duration::from_millis(1)); - } - let Some(CultNetMessage::Error { - error, - code, - details, - }) = refusal - else { - panic!("the refused peer was sent no refusal: {refusal:?}"); - }; - assert_eq!((code, details), (None, None)); - assert!( - !error.contains("CANARY"), - "a sink's or source's text reached the peer: {error}" - ); - assert_eq!( - client.reliable_send_status(receipt), - CultNetRudpReliableSendStatus::Pending, - "a refusal must not acknowledge the refused message" - ); - for _ in 0..2_000 { - client.receive_once()?; - if !client.connected() { - break; - } - thread::sleep(Duration::from_millis(1)); - } - assert!(!client.connected(), "the refusal is followed by a goodbye"); - assert_eq!( - client.reliable_send_status(receipt), - CultNetRudpReliableSendStatus::Invalidated - ); - Ok(error) -} - -/// Reads every datagram waiting at the server, such as a refused peer's -/// acknowledgement of its refusal, which reaches no session and is dropped. -fn drain_until_idle( - server: &mut CultMeshRudpDocumentServer, -) -> Result<()> { - for _ in 0..100 { - match server.poll_once()? { - CultMeshRudpPollOutcome::Idle => return Ok(()), - CultMeshRudpPollOutcome::Handled => {} - rejected => panic!("draining must not reject: {rejected:?}"), - } - } - anyhow::bail!("the server never went idle") -} - fn send(client: &mut CultNetRudpSocketTransportConnection, message: &CultNetMessage) -> Result<()> { client.send( "schema", @@ -490,8 +291,7 @@ fn same_connection_id_is_peer_scoped_and_raw_bytes_are_untouched() -> Result<()> } #[test] -fn a_second_connect_from_a_client_replaces_its_session_and_a_fresh_epoch_is_separate() -> Result<()> -{ +fn duplicate_connect_preserves_epoch_and_fresh_epoch_is_separate() -> Result<()> { let clock = Clock::new(45_000); let sink = Sink::default(); let mut server = server(Default::default(), clock, sink.clone(), Source::default())?; @@ -525,112 +325,8 @@ fn a_second_connect_from_a_client_replaces_its_session_and_a_fresh_epoch_is_sepa Ok(()) } -/// A client that restarts on the same address and connection id starts a new -/// session: its Connect carries a sequence the accepted one did not, so the -/// server does not mistake it for a retransmit, and what it sends is delivered. #[test] -fn a_restarted_client_on_the_same_address_and_connection_id_is_admitted() -> Result<()> { - let sink = Sink::default(); - let mut server = server( - Default::default(), - Clock::new(46_000), - sink.clone(), - Source::default(), - )?; - let target = server.local_addr()?; - let shared = UdpSocket::bind("127.0.0.1:0")?; - let twin = shared.try_clone()?; - let mut first = client_on(shared, target, 93, 50_000)?; - connect(&mut server, &mut [&mut first])?; - for index in 0..3 { - send( - &mut first, - &CultNetMessage::DocumentPutRaw { - message_id: format!("before-{index}"), - document: document("before", vec![index]), - }, - )?; - } - for _ in 0..40 { - server.poll_once()?; - first.receive_once()?; - } - assert_eq!(sink.0.lock().unwrap().receipts.len(), 3); - - let mut restarted = client_on(twin, target, 93, 7)?; - connect(&mut server, &mut [&mut restarted])?; - assert_eq!(server.session_count(), 1); - send( - &mut restarted, - &CultNetMessage::DocumentPutRaw { - message_id: "after-restart".into(), - document: document("after", vec![9]), - }, - )?; - for _ in 0..40 { - server.poll_once()?; - restarted.receive_once()?; - } - let receipts = sink.0.lock().unwrap(); - assert!( - receipts - .receipts - .iter() - .any(|r| r.message_id == "after-restart"), - "the restarted client's frame was not delivered" - ); - Ok(()) -} - -/// A restarted client is a new session, and starts with a new payload budget: -/// what the old one spent is not charged to it. -#[test] -fn a_restarted_client_starts_with_a_fresh_payload_budget() -> Result<()> { - let put = |id: &str| CultNetMessage::DocumentPutRaw { - message_id: id.into(), - document: document("budget", vec![7; 64]), - }; - let encoded = - encode_cultnet_message_to_vec(&put("put-a"), CultNetWireContract::CultNetSchemaV0)?; - let budget = encoded - .len() - .max(served_alone_bytes(&document("budget", vec![7; 64]))?); - let options = CultMeshRudpDocumentServerOptions { - max_admitted_payload_bytes: budget * 2, - max_admitted_payload_bytes_per_session: budget, - max_snapshot_response_bytes: budget, - ..Default::default() - }; - let sink = Sink::default(); - let mut server = server(options, Clock::new(47_000), sink.clone(), Source::default())?; - let target = server.local_addr()?; - let shared = UdpSocket::bind("127.0.0.1:0")?; - let twin = shared.try_clone()?; - let mut first = client_on(shared, target, 94, 50_000)?; - connect(&mut server, &mut [&mut first])?; - send(&mut first, &put("put-a"))?; - for _ in 0..20 { - server.poll_once()?; - } - assert_eq!(sink.0.lock().unwrap().receipts.len(), 1); - - let mut restarted = client_on(twin, target, 94, 7)?; - connect(&mut server, &mut [&mut restarted])?; - send(&mut restarted, &put("put-b"))?; - for _ in 0..20 { - server.poll_once()?; - } - assert_eq!( - sink.0.lock().unwrap().receipts.len(), - 2, - "the restarted client was charged what the old session spent" - ); - Ok(()) -} - -#[test] -fn application_rejection_is_nonfatal_peer_scoped_refused_to_the_peer_and_unacknowledged() --> Result<()> { +fn application_rejection_is_nonfatal_peer_scoped_and_unacknowledged() -> Result<()> { let clock = Clock::new(48_000); let sink = Sink::fail_once(); let source = Source::fail_once(vec![document("snapshot", vec![4, 5, 6])]); @@ -665,17 +361,13 @@ fn application_rejection_is_nonfatal_peer_scoped_refused_to_the_peer_and_unackno CultMeshRudpApplicationOperation::DocumentPutRaw ); assert_eq!(rejection.message_id, "rejected-put"); - assert_eq!( - rejection.reason, - CultMeshRudpRejectionReason::SinkRefused("injected sink failure CANARY-7f3a".into()) - ); + assert!(rejection.reason.contains("injected sink failure")); assert_eq!(server.session_count(), 2); - // The caller keeps the sink's text; the peer is sent fixed text, never it. + publisher.receive_once()?; assert_eq!( - refusal_seen_by(&mut publisher, &publish_receipt)?, - "the catalog refused the document" + publisher.reliable_send_status(&publish_receipt), + CultNetRudpReliableSendStatus::Pending ); - drain_until_idle(&mut server)?; let snapshot_receipt = send_reliable( &mut snapshot_client, @@ -694,18 +386,13 @@ fn application_rejection_is_nonfatal_peer_scoped_refused_to_the_peer_and_unackno CultMeshRudpApplicationOperation::SnapshotRequest ); assert_eq!(rejection.message_id, "rejected-snapshot"); - assert_eq!( - rejection.reason, - CultMeshRudpRejectionReason::SnapshotSourceFailed( - "injected source failure CANARY-7f3a".into() - ) - ); + assert!(rejection.reason.contains("injected source failure")); assert_eq!(server.session_count(), 1); + snapshot_client.receive_once()?; assert_eq!( - refusal_seen_by(&mut snapshot_client, &snapshot_receipt)?, - "the snapshot source failed" + snapshot_client.reliable_send_status(&snapshot_receipt), + CultNetRudpReliableSendStatus::Pending ); - drain_until_idle(&mut server)?; let survivor_receipt = send_reliable( &mut survivor, @@ -784,24 +471,15 @@ fn snapshot_response_resends_until_acknowledged() -> Result<()> { fn payload_and_snapshot_output_budgets_fail_closed() -> Result<()> { let clock = Clock::new(55_000); let sink = Sink::default(); - // The message id is long enough that the put's frame is at least its - // served-alone response, so the snapshot limit below admits it. let message = CultNetMessage::DocumentPutRaw { - message_id: "budget-exact".into(), + message_id: "budget".into(), document: document("budget", vec![7; 64]), }; let encoded = encode_cultnet_message_to_vec(&message, CultNetWireContract::CultNetSchemaV0)?; - // The put's frame is exactly both budgets, so the first put is admitted only - // if a charge equal to a limit fits it. - let budget = encoded.len(); - assert!( - served_alone_bytes(&document("budget", vec![7; 64]))? <= budget, - "fixture: the snapshot limit must admit the put" - ); let options = CultMeshRudpDocumentServerOptions { - max_admitted_payload_bytes: budget, - max_admitted_payload_bytes_per_session: budget, - max_snapshot_response_bytes: budget, + max_admitted_payload_bytes: encoded.len(), + max_admitted_payload_bytes_per_session: encoded.len(), + max_snapshot_response_bytes: encoded.len(), ..Default::default() }; let mut budget_server = server(options, clock, sink.clone(), Source::default())?; @@ -840,425 +518,12 @@ fn payload_and_snapshot_output_budgets_fail_closed() -> Result<()> { CultMeshRudpApplicationOperation::SnapshotRequest ); assert_eq!(rejection.message_id, "too-large"); - assert!(matches!( - rejection.reason, - CultMeshRudpRejectionReason::SnapshotResponseTooLarge { - response_bytes, - max_snapshot_response_bytes: 128, - } if response_bytes > 128 - )); + assert!(rejection.reason.contains("snapshot response is")); assert_eq!(snapshot_server.session_count(), 0); + snapshot_client.receive_once()?; assert_eq!( - refusal_seen_by(&mut snapshot_client, &receipt)?, - "the snapshot response is too large" - ); - Ok(()) -} - -/// A put is admitted only if some snapshot request could return it. One byte -/// over the served bound is refused before the sink sees it; exactly at the -/// bound is admitted, and a snapshot then serves it at exactly that size. The -/// source keeps the default `served_record`, so the record is sized as received. -#[test] -fn a_put_the_server_could_never_serve_is_refused_and_one_at_the_bound_is_served() -> Result<()> { - let at_bound = document("fit", vec![7; 100]); - let over_bound = document("fit", vec![7; 101]); - let limit = served_alone_bytes(&at_bound)?; - assert_eq!( - served_alone_bytes(&over_bound)?, - limit + 1, - "fixture: the two documents must straddle the bound by one byte" - ); - let options = CultMeshRudpDocumentServerOptions { - max_snapshot_response_bytes: limit, - ..Default::default() - }; - let sink = Sink::default(); - let source = Source::default(); - let mut server = server(options, Clock::new(60_000), sink.clone(), source.clone())?; - let target = server.local_addr()?; - - let mut refused = client(target, 121)?; - let mut writer = client(target, 122)?; - connect(&mut server, &mut [&mut refused, &mut writer])?; - let refused_receipt = send_reliable( - &mut refused, - &CultNetMessage::DocumentPutRaw { - message_id: "put-over".into(), - document: over_bound, - }, - )?; - let CultMeshRudpPollOutcome::ApplicationRejected(rejection) = server.poll_once()? else { - panic!("an unservable put must be refused as an application rejection"); - }; - assert_eq!(rejection.session.connection_id, 121); - assert_eq!( - rejection.operation, - CultMeshRudpApplicationOperation::DocumentPutRaw - ); - assert_eq!(rejection.message_id, "put-over"); - assert_eq!( - rejection.reason, - CultMeshRudpRejectionReason::DocumentUnservable { - response_bytes: limit + 1, - max_snapshot_response_bytes: limit, - fragment_count: 1, - max_fragment_count: 1024, - } - ); - let sentence = rejection.reason.to_string(); - assert!(sentence.contains(&(limit + 1).to_string()) && sentence.contains(&limit.to_string())); - assert!(sink.0.lock().unwrap().receipts.is_empty()); - assert_eq!(server.session_count(), 1); - // The peer hears the refusal and why, rather than waiting on a put that - // will never be acknowledged. - assert_eq!( - refusal_seen_by(&mut refused, &refused_receipt)?, - "the document can never be served" - ); - - send( - &mut writer, - &CultNetMessage::DocumentPutRaw { - message_id: "put-at".into(), - document: at_bound.clone(), - }, - )?; - for _ in 0..500 { - let outcome = server.poll_once()?; - assert!( - !matches!(outcome, CultMeshRudpPollOutcome::ApplicationRejected(_)), - "{outcome:?}" - ); - if !sink.0.lock().unwrap().receipts.is_empty() { - break; - } - thread::sleep(Duration::from_millis(1)); - } - let stored: Vec<_> = sink - .0 - .lock() - .unwrap() - .receipts - .iter() - .map(|receipt| receipt.document.clone()) - .collect(); - assert_eq!(stored, vec![at_bound.clone()]); - source.0.lock().unwrap().documents = stored; - - send( - &mut writer, - &CultNetMessage::SnapshotRequest { - message_id: "r".into(), - schema_ids: None, - record_keys: None, - }, - )?; - let mut served = None; - for _ in 0..500 { - let outcome = server.poll_once()?; - assert!( - !matches!(outcome, CultMeshRudpPollOutcome::ApplicationRejected(_)), - "{outcome:?}" - ); - if let Some(frame) = writer.receive_once()? { - served = Some(frame.payload); - break; - } - thread::sleep(Duration::from_millis(1)); - } - let served = served.expect("the admitted document must be served"); - assert_eq!(served.len(), limit); - assert_eq!( - decode_cultnet_message_from_slice(&served, CultNetWireContract::CultNetSchemaV0)?, - CultNetMessage::SnapshotResponseRaw { - message_id: "r".into(), - documents: vec![at_bound], - } - ); - Ok(()) -} - -/// A source that serves records without provenance says so through -/// `served_record`, and admission sizes that: a put over the bound only in its -/// received form is admitted and served at exactly the bound. -#[test] -fn a_put_is_sized_as_its_source_would_serve_it() -> Result<()> { - let provenance = |mut document: CultNetRawDocumentRecord| { - document.source_agent_id = Some("provenance-agent-that-is-not-served".into()); - document.source_role = Some("provenance-role".into()); - document.tags = Some(vec!["provenance".into(), "tags".into()]); - document - }; - let at_bound = provenance(document("fit", vec![7; 100])); - let over_bound = provenance(document("fit", vec![7; 101])); - let limit = served_alone_bytes(&stripped(&at_bound))?; - assert_eq!( - served_alone_bytes(&stripped(&over_bound))?, - limit + 1, - "fixture: the two documents must straddle the bound by one byte as served" - ); - assert!( - served_alone_bytes(&at_bound)? > limit + 1, - "fixture: the at-bound put is over the bound as received" - ); - let options = CultMeshRudpDocumentServerOptions { - max_snapshot_response_bytes: limit, - ..Default::default() - }; - let sink = Sink::default(); - let source = StrippingSource::default(); - let mut server = stripping_server(options, sink.clone(), source.clone())?; - let target = server.local_addr()?; - - let mut refused = client(target, 151)?; - connect(&mut server, &mut [&mut refused])?; - send( - &mut refused, - &CultNetMessage::DocumentPutRaw { - message_id: "put-over".into(), - document: over_bound, - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut refused, &sink, 1)?, - Some(CultMeshRudpRejectionReason::DocumentUnservable { - response_bytes: limit + 1, - max_snapshot_response_bytes: limit, - fragment_count: 1, - max_fragment_count: 1024, - }) - ); - - let mut writer = client(target, 152)?; - connect(&mut server, &mut [&mut writer])?; - send( - &mut writer, - &CultNetMessage::DocumentPutRaw { - message_id: "put-at".into(), - document: at_bound.clone(), - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut writer, &sink, 1)?, - None - ); - assert_eq!( - sink.0.lock().unwrap().receipts[0].document, - at_bound, - "the sink receives the record as it was sent" - ); - source.inner.0.lock().unwrap().documents = vec![at_bound.clone()]; - send( - &mut writer, - &CultNetMessage::SnapshotRequest { - message_id: "r".into(), - schema_ids: None, - record_keys: None, - }, - )?; - let served = serve_until_frame(&mut server, &mut writer)?; - assert_eq!(served.len(), limit); - assert_eq!( - decode_cultnet_message_from_slice(&served, CultNetWireContract::CultNetSchemaV0)?, - CultNetMessage::SnapshotResponseRaw { - message_id: "r".into(), - documents: vec![stripped(&at_bound)], - } - ); - Ok(()) -} - -/// A source that cannot say what it would serve refuses the put. -#[test] -fn a_put_whose_served_record_the_source_cannot_give_is_refused() -> Result<()> { - let sink = Sink::default(); - let source = StrippingSource { - served_record_fails: true, - ..Default::default() - }; - let mut server = stripping_server(Default::default(), sink.clone(), source)?; - let mut refused = client(server.local_addr()?, 161)?; - connect(&mut server, &mut [&mut refused])?; - send( - &mut refused, - &CultNetMessage::DocumentPutRaw { - message_id: "put".into(), - document: document("unsized", vec![1, 2, 3]), - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut refused, &sink, 1)?, - Some(CultMeshRudpRejectionReason::SnapshotSourceFailed( - "injected served-record failure".into() - )) - ); - assert!(sink.0.lock().unwrap().receipts.is_empty()); - Ok(()) -} - -/// A put is admitted only if its served response fits the fragments one -/// response may take: here eight of 100 bytes, the reliable queue, although the -/// byte limit is far larger. Eight fragments are admitted and served; nine are -/// refused, and so is Soul's 2000-byte probe, each naming its sizes. -#[test] -fn a_put_whose_response_would_overflow_the_reliable_queue_is_refused() -> Result<()> { - let options = CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 100, - max_pending_reliable_packets_per_session: 8, - max_snapshot_response_bytes: 8192, - ..Default::default() - }; - let sink = Sink::default(); - let source = Source::default(); - let mut server = server(options, Clock::new(61_000), sink.clone(), source.clone())?; - let target = server.local_addr()?; - let unservable = |response_bytes, fragment_count| { - Some(CultMeshRudpRejectionReason::DocumentUnservable { - response_bytes, - max_snapshot_response_bytes: 8192, - fragment_count, - max_fragment_count: 8, - }) - }; - - for (id, bytes, fragments) in [(131, 2000, 20), (132, 801, 9)] { - let mut refused = client(target, id)?; - connect(&mut server, &mut [&mut refused])?; - send( - &mut refused, - &CultNetMessage::DocumentPutRaw { - message_id: "put-over".into(), - document: document_served_at("queue", bytes)?, - }, - )?; - let reason = poll_until_rejected_or_stored(&mut server, &mut refused, &sink, 1)?; - assert_eq!(reason, unservable(bytes, fragments)); - let sentence = reason.unwrap().to_string(); - assert!( - sentence.contains(&format!("{bytes} bytes in {fragments} fragments")) - && sentence.contains("8 fragments"), - "{sentence}" - ); - } - assert!(sink.0.lock().unwrap().receipts.is_empty()); - - let at_bound = document_served_at("queue", 800)?; - let mut writer = client(target, 133)?; - connect(&mut server, &mut [&mut writer])?; - send( - &mut writer, - &CultNetMessage::DocumentPutRaw { - message_id: "put-at".into(), - document: at_bound.clone(), - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut writer, &sink, 1)?, - None - ); - source.0.lock().unwrap().documents = vec![at_bound.clone()]; - send( - &mut writer, - &CultNetMessage::SnapshotRequest { - message_id: "r".into(), - schema_ids: None, - record_keys: None, - }, - )?; - let served = serve_until_frame(&mut server, &mut writer)?; - assert_eq!(served.len(), 800); - assert_eq!( - decode_cultnet_message_from_slice(&served, CultNetWireContract::CultNetSchemaV0)?, - CultNetMessage::SnapshotResponseRaw { - message_id: "r".into(), - documents: vec![at_bound], - } - ); - Ok(()) -} - -/// One message carries at most 65535 fragments, however deep the reliable -/// queue: a response of 65536 one-byte fragments is refused, one of 65535 is not. -#[test] -fn a_put_whose_response_needs_more_than_65535_fragments_is_refused() -> Result<()> { - let options = CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 1, - max_pending_reliable_packets_per_session: 100_000, - max_snapshot_response_bytes: 70_000, - ..Default::default() - }; - let sink = Sink::default(); - let mut server = server(options, Clock::new(62_000), sink.clone(), Source::default())?; - let target = server.local_addr()?; - - let mut refused = client(target, 141)?; - connect(&mut server, &mut [&mut refused])?; - send( - &mut refused, - &CultNetMessage::DocumentPutRaw { - message_id: "put-over".into(), - document: document_served_at("wide", 65_536)?, - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut refused, &sink, 1)?, - Some(CultMeshRudpRejectionReason::DocumentUnservable { - response_bytes: 65_536, - max_snapshot_response_bytes: 70_000, - fragment_count: 65_536, - max_fragment_count: 65_535, - }) - ); - - let mut writer = client(target, 142)?; - connect(&mut server, &mut [&mut writer])?; - send( - &mut writer, - &CultNetMessage::DocumentPutRaw { - message_id: "put-at".into(), - document: document_served_at("wide", 65_535)?, - }, - )?; - assert_eq!( - poll_until_rejected_or_stored(&mut server, &mut writer, &sink, 1)?, - None - ); - Ok(()) -} - -/// The limits must leave room for an empty snapshot response, the smallest the -/// server sends; exactly enough room is accepted. -#[test] -fn options_that_cannot_carry_an_empty_snapshot_response_are_refused() -> Result<()> { - let empty = encode_cultnet_message_to_vec( - &CultNetMessage::SnapshotResponseRaw { - message_id: "r".into(), - documents: Vec::new(), - }, - CultNetWireContract::CultNetSchemaV0, - )? - .len(); - let build = |options: CultMeshRudpDocumentServerOptions| { - server(options, Clock::new(63_000), Sink::default(), Source::default()).map(|_| ()) - }; - let bytes = |max_snapshot_response_bytes| CultMeshRudpDocumentServerOptions { - max_snapshot_response_bytes, - ..Default::default() - }; - let fragments = |max_pending_reliable_packets_per_session| CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 1, - max_pending_reliable_packets_per_session, - ..Default::default() - }; - build(bytes(empty))?; - let error = build(bytes(empty - 1)).unwrap_err().to_string(); - assert!(error.contains("max_snapshot_response_bytes"), "{error}"); - build(fragments(empty))?; - let error = build(fragments(empty - 1)).unwrap_err().to_string(); - assert!( - error.contains("max_pending_reliable_packets_per_session"), - "{error}" + snapshot_client.reliable_send_status(&receipt), + CultNetRudpReliableSendStatus::Pending ); Ok(()) } @@ -1288,434 +553,3 @@ fn session_cap_and_expiry_use_monotonic_time() -> Result<()> { assert_eq!(server.session_count(), 0); Ok(()) } - -#[test] -fn a_connect_storm_and_stray_frames_are_dropped_not_fatal() -> Result<()> { - use cultnet_rs::{ - CultNetRudpSendOptions, CultNetRudpSession, CultNetRudpSessionOptions, encode_rudp_packet, - }; - let clock = Clock::new(60_000); - let sink = Sink::default(); - let options = CultMeshRudpDocumentServerOptions { - max_pending_reliable_packets_per_session: 4, - ..Default::default() - }; - let mut server = server(options, clock.clone(), sink.clone(), Source::default())?; - let target = server.local_addr()?; - let mut real = client(target, 101)?; - connect(&mut server, &mut [&mut real])?; - assert_eq!(server.packets_dropped(), 0); - - let raw = UdpSocket::bind("127.0.0.1:0")?; - let session = |id| { - CultNetRudpSession::new(CultNetRudpSessionOptions { - connection_id: id, - initial_sequence: Some(1), - resend_delay_ms: 10, - max_pending_reliable_packets: None, - }) - }; - let send_raw = |server: &mut Server, packet: &cultnet_rs::CultNetRudpPacket| -> Result<()> { - raw.send_to(&encode_rudp_packet(packet)?, target)?; - server.poll_once()?; - Ok(()) - }; - - // A malformed frame. - raw.send_to(b"not a rudp packet", target)?; - server.poll_once()?; - assert_eq!(server.packets_dropped(), 1); - - // Data for a session no Connect admitted. - let mut unadmitted = session(300); - unadmitted.assume_connected(0); - let reliable = CultNetRudpSendOptions { - reliable: true, - ..Default::default() - }; - send_raw( - &mut server, - &unadmitted.send("schema", vec![1], reliable.clone())?, - )?; - assert_eq!(server.packets_dropped(), 2); - - // A moved flow re-sends Connect from a socket that never hears the Accept. - // Each repeat re-sends the Accept still awaiting acknowledgement and queues - // nothing, so the storm neither errors nor grows the session's queue. - let mut stormer = session(102); - let connect_packet = stormer.create_connect(0, Vec::new())?; - for _ in 0..200 { - send_raw(&mut server, &connect_packet)?; - } - assert_eq!(server.packets_dropped(), 2); - assert_eq!(server.session_count(), 2); - clock.set(60_000 + 1_000); - assert_eq!( - server.maintain()?.packets_resent, - 1, - "one Accept awaits acknowledgement, however many Connects repeated" - ); - - // A packet its own admitted session refuses ends that session, not the loop. - stormer.assume_connected(0); - let mut poison = stormer.send("schema", vec![1], reliable)?; - poison.fragment_count = 2; - poison.fragment_id = 0; - send_raw(&mut server, &poison)?; - assert_eq!(server.packets_dropped(), 3); - assert_eq!(server.session_count(), 1); - // ...and the refused client is told, after the Accepts its storm drew. - raw.set_read_timeout(Some(Duration::from_millis(200)))?; - let mut buffer = vec![0_u8; 65_535]; - let mut told = false; - while let Ok(received) = raw.recv(&mut buffer) { - told |= cultnet_rs::decode_rudp_packet(&buffer[..received])?.packet_type - == cultnet_rs::CultNetRudpPacketType::Disconnect; - } - assert!(told, "the refused client must be sent a goodbye"); - - send( - &mut real, - &CultNetMessage::DocumentPutRaw { - message_id: "after-storm".into(), - document: document("real", vec![9]), - }, - )?; - for _ in 0..20 { - server.poll_once()?; - if sink.0.lock().unwrap().receipts.len() == 1 { - break; - } - } - assert_eq!(sink.0.lock().unwrap().receipts.len(), 1); - Ok(()) -} - -/// A peer driven packet by packet, so a test decides what it receives and what -/// it acknowledges. -struct RawPeer { - socket: UdpSocket, - target: SocketAddr, - session: cultnet_rs::CultNetRudpSession, -} - -impl RawPeer { - fn connect( - server: &mut CultMeshRudpDocumentServer, - connection_id: u32, - ) -> Result { - let socket = UdpSocket::bind("127.0.0.1:0")?; - socket.set_read_timeout(Some(Duration::from_millis(50)))?; - let mut peer = Self { - socket, - target: server.local_addr()?, - session: cultnet_rs::CultNetRudpSession::new(cultnet_rs::CultNetRudpSessionOptions { - connection_id, - initial_sequence: Some(100), - resend_delay_ms: 10_000, - max_pending_reliable_packets: Some(64), - }), - }; - let connect = peer.session.create_connect(0, Vec::new())?; - peer.send_packet(&connect)?; - server.poll_once()?; - let accept = peer.receive().expect("the server accepts the connect"); - assert_eq!( - accept.packet_type, - cultnet_rs::CultNetRudpPacketType::Accept - ); - peer.session.receive(&accept, 1)?; - Ok(peer) - } - - fn send_packet(&self, packet: &cultnet_rs::CultNetRudpPacket) -> Result<()> { - self.socket - .send_to(&cultnet_rs::encode_rudp_packet(packet)?, self.target)?; - Ok(()) - } - - /// Sends `message` reliably and in order; returns its sequences. - fn send(&mut self, message: &CultNetMessage) -> Result> { - let payload = encode_cultnet_message_to_vec(message, CultNetWireContract::CultNetSchemaV0)?; - let options = cultnet_rs::CultNetRudpSendOptions { - reliable: true, - ordered: true, - sequenced: false, - now_ms: 2, - reliable_expire_after_ms: None, - }; - let packets = self - .session - .send_many("schema", payload, options, Some(1200))?; - for packet in &packets { - self.send_packet(packet)?; - } - Ok(packets.iter().map(|packet| packet.sequence).collect()) - } - - fn receive(&self) -> Option { - let mut wire = vec![0_u8; 65_535]; - let (bytes, _) = self.socket.recv_from(&mut wire).ok()?; - cultnet_rs::decode_rudp_packet(&wire[..bytes]).ok() - } - - /// Every packet waiting, none of them processed or acknowledged. - fn drain(&self) -> Vec { - std::iter::from_fn(|| self.receive()).collect() - } -} - -/// Whether `packet`'s acknowledgement fields cover `sequence`. -fn acknowledges(packet: &cultnet_rs::CultNetRudpPacket, sequence: u32) -> bool { - packet.ack == sequence - || (0..32).any(|bit| { - packet.ack_mask & (1 << bit) != 0 - && packet.ack > bit - && packet.ack - bit - 1 == sequence - }) -} - -/// The refusal is unreliable and unordered: a peer missing an earlier reliable -/// packet from the server still receives it. An ordered refusal would wait -/// behind the gap for a resend that never comes, because the session ends with it. -#[test] -fn a_refusal_reaches_a_peer_missing_an_earlier_packet() -> Result<()> { - let mut server = server( - Default::default(), - Clock::new(71_000), - Sink::fail_once(), - Source::documents(vec![document("held", vec![1, 2, 3])]), - )?; - let mut peer = RawPeer::connect(&mut server, 78)?; - - // The snapshot reply is lost: the peer never sees it, so its ordered - // stream from the server has a gap. - peer.send(&CultNetMessage::SnapshotRequest { - message_id: "lost".into(), - schema_ids: None, - record_keys: None, - })?; - assert_eq!(server.poll_once()?, CultMeshRudpPollOutcome::Handled); - assert!( - !peer.drain().is_empty(), - "fixture: the server sent the reply that is lost" - ); - - peer.send(&CultNetMessage::DocumentPutRaw { - message_id: "refused".into(), - document: document("refused", vec![4, 5, 6]), - })?; - assert!(matches!( - server.poll_once()?, - CultMeshRudpPollOutcome::ApplicationRejected(_) - )); - let mut delivered = Vec::new(); - let mut disconnected = false; - for packet in peer.drain() { - let result = peer.session.receive(&packet, 3)?; - delivered.extend(result.delivered); - disconnected |= result.disconnected; - } - let refusals: Vec<_> = delivered - .iter() - .map(|frame| { - decode_cultnet_message_from_slice(&frame.payload, CultNetWireContract::CultNetSchemaV0) - }) - .collect::>()?; - assert_eq!( - refusals, - vec![CultNetMessage::Error { - error: "the catalog refused the document".into(), - code: None, - details: None, - }] - ); - assert!(disconnected, "the refusal is followed by a goodbye"); - Ok(()) -} - -/// The peer's reliable queue is full to the brim: an 8-fragment reply the peer -/// never acknowledges fills a queue of 8 exactly. The next reply cannot be -/// queued, and its refusal still reaches the peer, because it takes no room in -/// that queue; it acknowledges nothing the peer sent. -#[test] -fn a_refusal_reaches_a_peer_whose_queue_is_full_to_the_brim() -> Result<()> { - let options = CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 100, - max_pending_reliable_packets_per_session: 8, - max_snapshot_response_bytes: 8192, - ..Default::default() - }; - let source = Source::documents(vec![document_served_at("q1", 800)?]); - let mut server = server(options, Clock::new(74_000), Sink::default(), source)?; - let mut peer = RawPeer::connect(&mut server, 79)?; - peer.send(&CultNetMessage::SnapshotRequest { - message_id: "a".into(), - schema_ids: None, - record_keys: None, - })?; - assert_eq!(server.poll_once()?, CultMeshRudpPollOutcome::Handled); - let unacknowledged = peer - .drain() - .into_iter() - .filter(|packet| packet.packet_type == cultnet_rs::CultNetRudpPacketType::Data) - .count(); - assert_eq!( - unacknowledged, 8, - "fixture: the first reply fills the queue exactly" - ); - - let refused = peer.send(&CultNetMessage::SnapshotRequest { - message_id: "b".into(), - schema_ids: None, - record_keys: None, - })?; - let CultMeshRudpPollOutcome::ApplicationRejected(rejection) = server.poll_once()? else { - panic!("the second reply cannot be queued"); - }; - assert!( - matches!( - rejection.reason, - CultMeshRudpRejectionReason::ResponseQueueFailed(_) - ), - "{:?}", - rejection.reason - ); - let arrived = peer.drain(); - let mut parts: Vec<_> = arrived - .iter() - .filter(|packet| { - packet.packet_type == cultnet_rs::CultNetRudpPacketType::Data - && packet.channel_id == "schema" - && !packet.reliable - }) - .collect(); - assert!(!parts.is_empty(), "the refusal reaches the peer"); - for part in &parts { - assert!( - refused - .iter() - .all(|sequence| !acknowledges(part, *sequence)), - "the refusal acknowledges the refused request: ack {} mask {:#x}", - part.ack, - part.ack_mask - ); - } - parts.sort_by_key(|part| part.fragment_index); - let payload: Vec = parts.iter().flat_map(|part| part.payload.clone()).collect(); - assert_eq!( - decode_cultnet_message_from_slice(&payload, CultNetWireContract::CultNetSchemaV0)?, - CultNetMessage::Error { - error: "the snapshot response could not be queued".into(), - code: None, - details: None, - } - ); - assert!( - arrived - .iter() - .any(|packet| packet.packet_type == cultnet_rs::CultNetRudpPacketType::Disconnect), - "the refusal is followed by a goodbye" - ); - Ok(()) -} - -/// A snapshot the reliable queue cannot take is answered with a refusal, not -/// left to time out: the refusal needs no room in that queue. -#[test] -fn a_snapshot_the_queue_cannot_take_is_answered() -> Result<()> { - let options = CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 100, - max_pending_reliable_packets_per_session: 8, - max_snapshot_response_bytes: 8192, - ..Default::default() - }; - // Each document alone is served in 800 bytes, eight fragments; both need sixteen. - let source = Source::documents(vec![ - document_served_at("q1", 800)?, - document_served_at("q2", 800)?, - ]); - let mut server = server(options, Clock::new(72_000), Sink::default(), source)?; - let mut client = client(server.local_addr()?, 151)?; - connect(&mut server, &mut [&mut client])?; - let receipt = send_reliable( - &mut client, - &CultNetMessage::SnapshotRequest { - message_id: "both".into(), - schema_ids: None, - record_keys: None, - }, - )?; - let mut rejection = None; - for _ in 0..100 { - if let CultMeshRudpPollOutcome::ApplicationRejected(found) = server.poll_once()? { - rejection = Some(found); - break; - } - client.receive_once()?; - } - let rejection = rejection.expect("the response cannot be queued"); - assert!( - matches!( - rejection.reason, - CultMeshRudpRejectionReason::ResponseQueueFailed(_) - ), - "{:?}", - rejection.reason - ); - assert_eq!( - refusal_seen_by(&mut client, &receipt)?, - "the snapshot response could not be queued" - ); - Ok(()) -} - -/// A response too large for any datagram fails with the kernel's EMSGSIZE. The -/// caller's rejection and the peer's goodbye both carry its fixed name, never -/// the platform's text, and the peer is sent no refusal. -#[test] -fn a_response_that_is_too_large_to_send_is_named_emsgsize() -> Result<()> { - let options = CultMeshRudpDocumentServerOptions { - max_fragment_bytes: 70_000, - ..Default::default() - }; - let source = Source::documents(vec![document("big", vec![7; 66_000])]); - let mut server = server(options, Clock::new(73_000), Sink::default(), source)?; - let mut client = client(server.local_addr()?, 152)?; - connect(&mut server, &mut [&mut client])?; - send_reliable( - &mut client, - &CultNetMessage::SnapshotRequest { - message_id: "big".into(), - schema_ids: None, - record_keys: None, - }, - )?; - let mut rejection = None; - for _ in 0..100 { - if let CultMeshRudpPollOutcome::ApplicationRejected(found) = server.poll_once()? { - rejection = Some(found); - break; - } - } - assert_eq!( - rejection.expect("the response can never be sent").reason, - CultMeshRudpRejectionReason::ResponseSendFailed("EMSGSIZE") - ); - let mut frames = 0; - for _ in 0..500 { - if client.receive_once()?.is_some() { - frames += 1; - } - if !client.connected() { - break; - } - thread::sleep(Duration::from_millis(1)); - } - assert_eq!(frames, 0, "no refusal is sent to an unreachable peer"); - assert_eq!( - client.disconnect_reason(), - Some(&b"packet could not be sent: EMSGSIZE"[..]) - ); - Ok(()) -} diff --git a/packages/cultmesh-ts/native/MANIFEST.txt b/packages/cultmesh-ts/native/MANIFEST.txt deleted file mode 100644 index 074975f0..00000000 --- a/packages/cultmesh-ts/native/MANIFEST.txt +++ /dev/null @@ -1,9 +0,0 @@ -msquic.version=2.5.9 -msquic.windows.source=https://www.nuget.org/api/v2/package/Microsoft.Native.Quic.MsQuic.OpenSSL/2.5.9 sha256=FEE9A664C0052DEEE66D40CED2E19BFE20BC423DE5AE5234CFC0CEBC22CA3F5E -msquic.linux.source=https://packages.microsoft.com/debian/13/prod/pool/main/libm/libmsquic/libmsquic_2.5.9_amd64.deb sha256=1baa61ade0b7b4a99f6dcb6b00d9aedb12b5566d00918a325be7425e878e51ba -bridge.commit=e5bf1c9243acb6b76de72c7864e3b79214177199 -build.workflow_run=https://github.com/GameCult/CultLib/actions/runs/35912386052 -build.release=none (TEMPORARY push-to-quic-cut6 trigger, no tag; see quic-native.yml history for the tagged release path) -build.win32-x64.host=windows-2025-vs2026, cl.exe (MSVC) 19.51.36256.0 -build.linux-x64.host=ubuntu-24.04, container debian:13@sha256:f324c7ff54321e8d9c588493a20244965938ce0aa50bbd1022d38010e9ffc4b1, g++ (Debian 14.2.0-19) 14.2.0 -date=2026-09-23T19:54:08Z diff --git a/packages/cultmesh-ts/native/MSQUIC-LICENSE.txt b/packages/cultmesh-ts/native/MSQUIC-LICENSE.txt deleted file mode 100644 index 63447fd8..00000000 --- a/packages/cultmesh-ts/native/MSQUIC-LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Microsoft Corporation. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/cultmesh-ts/native/SHA256SUMS b/packages/cultmesh-ts/native/SHA256SUMS deleted file mode 100644 index a1233d52..00000000 --- a/packages/cultmesh-ts/native/SHA256SUMS +++ /dev/null @@ -1,4 +0,0 @@ -9dae391a44d59f12e19baa08a44d86c7e8b4916ca5d40007a42d65913ce0896f *win32-x64/gamecult_mesh_quic_native.dll -c17c65813fe007eb486a5270d244f3659261355795b27abb99bd19ff77539263 *win32-x64/msquic.dll -0ee3d28324c79a5b0135368187e7bd75c1969ad94fc6985755e81de4ec96e430 *linux-x64/libgamecult_mesh_quic_native.so -c09a72f9b3bfd9119044b305c6064731c1e1879411e6f54276474fb58b524b68 *linux-x64/libmsquic.so.2 diff --git a/packages/cultmesh-ts/native/linux-x64/libgamecult_mesh_quic_native.so b/packages/cultmesh-ts/native/linux-x64/libgamecult_mesh_quic_native.so deleted file mode 100644 index 7363d1cb..00000000 Binary files a/packages/cultmesh-ts/native/linux-x64/libgamecult_mesh_quic_native.so and /dev/null differ diff --git a/packages/cultmesh-ts/native/linux-x64/libmsquic.so.2 b/packages/cultmesh-ts/native/linux-x64/libmsquic.so.2 deleted file mode 100644 index e14af169..00000000 Binary files a/packages/cultmesh-ts/native/linux-x64/libmsquic.so.2 and /dev/null differ diff --git a/packages/cultmesh-ts/native/win32-x64/gamecult_mesh_quic_native.dll b/packages/cultmesh-ts/native/win32-x64/gamecult_mesh_quic_native.dll deleted file mode 100644 index da7be3c0..00000000 Binary files a/packages/cultmesh-ts/native/win32-x64/gamecult_mesh_quic_native.dll and /dev/null differ diff --git a/packages/cultmesh-ts/native/win32-x64/msquic.dll b/packages/cultmesh-ts/native/win32-x64/msquic.dll deleted file mode 100644 index 71107c2c..00000000 Binary files a/packages/cultmesh-ts/native/win32-x64/msquic.dll and /dev/null differ diff --git a/packages/cultmesh-ts/package.json b/packages/cultmesh-ts/package.json index 4d59133a..0ca8afb3 100644 --- a/packages/cultmesh-ts/package.json +++ b/packages/cultmesh-ts/package.json @@ -12,14 +12,13 @@ } }, "files": [ - "dist", - "native" + "dist" ], "scripts": { "build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json", "prepack": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json", "typecheck": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json --pretty false", - "test": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --expose-gc --test dist-test/test/*.test.js" + "test": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node ../../node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test dist-test/test/*.test.js" }, "keywords": [ "cultmesh", @@ -40,13 +39,12 @@ }, "homepage": "https://github.com/GameCult/CultLib/tree/main/packages/cultmesh-ts#readme", "engines": { - "node": ">=20" + "node": ">=18" }, "dependencies": { "@msgpack/msgpack": "^3.1.2", "@gamecult/cultcache-ts": "^0.14.0", - "cultnet-ts": "^0.2.0", - "koffi": "3.3.0" + "cultnet-ts": "^0.2.0" }, "devDependencies": { "@types/node": "^24.0.0", diff --git a/packages/cultmesh-ts/src/index.ts b/packages/cultmesh-ts/src/index.ts index 36a5ae88..e9fbb8be 100644 --- a/packages/cultmesh-ts/src/index.ts +++ b/packages/cultmesh-ts/src/index.ts @@ -14,7 +14,6 @@ import { CultNetRudpSession, CultNetPeer, CultNetRudpSocketTransportConnection, - rudpClientBindHost, CultNetSchemaCatalog, CultNetShardCatalog, cultNetBuiltinSchemaRegistry, @@ -22,9 +21,7 @@ import { defineCultNetDocumentBinding, encodeCultNetMessageForWire, encodeRudpPacket, - isPermanentSendError, parseCultNetMessage, - sendRudpDatagram, type CultNetErrorMessage, type CultNetDocumentBinding, type CultNetMessage, @@ -32,24 +29,11 @@ import { type CultNetOperationResponseMessage, type CultNetRawDocumentRecord, type CultNetReconnectPolicy, - type CultNetRudpPacket, type CultNetSchemaCatalogOptions, type CultNetSnapshotResponseRawMessage, type CultNetWireContract, } from "cultnet-ts"; -import { - CultMeshQuicRealtimeConnector, - CultMeshQuicRealtimeProvider, - CultMeshQuicRealtimeSessionManager, - parseQuicRealtimeEndpoint, - type CultMeshQuicRealtimeConnectorOptions, - type CultMeshQuicRealtimeProviderOptions, - type CultMeshQuicRealtimeSessionManagerOptions, -} from "./realtime-quic"; - -export * from "./realtime-wire"; -export * from "./realtime-quic"; export * from "./provider-session"; export * from "./provider-session-wire"; export * from "./provider-rudp-transport"; @@ -4284,30 +4268,6 @@ export interface CultMeshRudpDocumentReceipt Promise | CultCache; @@ -4325,39 +4285,6 @@ export interface CultMeshRudpDocumentServerOptions extends CultMeshRudpSocketOpt sessionTimeoutMs?: number; } -/** Replies larger than one fragment are split into fragments of at most this many bytes. */ -export const CULTMESH_RUDP_DOCUMENT_SERVER_DEFAULT_MAX_FRAGMENT_BYTES = 1200; - -const RUDP_MAX_FRAGMENTS_PER_MESSAGE = 0xffff; - -/** CultNet parses no message id shorter than one character, so no reply is smaller. */ -const SHORTEST_MESSAGE_ID = "0"; - -/** - * A put the document server refused because it could never serve the document: - * the snapshot reply carrying it alone (`responseBytes`) would exceed the - * server's reply limits. - */ -export class CultMeshRudpUnservableDocumentError extends Error { - constructor( - readonly messageId: string, - readonly recordKey: string, - readonly responseBytes: number, - readonly maxPayloadBytes: number | undefined, - readonly fragmentCount: number, - readonly maxFragmentCount: number, - ) { - // The sentence names sizes only: it is sent to the peer, and a record key of - // any length would make the refusal itself too large to send. - super( - `Document can never be served: its reply is ${responseBytes} bytes in ` - + `${fragmentCount} fragments; limits are ${maxPayloadBytes ?? "unbounded"} bytes and ` - + `${maxFragmentCount} fragments.`, - ); - this.name = "CultMeshRudpUnservableDocumentError"; - } -} - export interface CultMeshRudpServerSession { readonly sessionId: string; readonly remote: { address: string; family: string; port: number }; @@ -4367,12 +4294,6 @@ export interface CultMeshRudpServerSession { export interface CultMeshRudpDocumentServer { readonly bind: { host: string; port: number }; - /** - * Datagrams that could not be sent to a peer. Each is that peer's lost datagram: a - * reliable packet stays pending and is resent, and no other peer is affected. A datagram - * that can never be sent as built is not counted here: it ends that peer's session. - */ - readonly sendFailures: number; start(): Promise; close(): void; } @@ -4397,11 +4318,6 @@ export interface CultMeshRudpEndpoint { } export interface CultMeshRudpSocketOptions { - /** - * Local address to bind. Unset, a server binds loopback, and a client binds - * loopback for a loopback endpoint and the unspecified address of the - * endpoint's family otherwise, so it can reach a remote host. - */ bindHost?: string; bindPort?: number; socket?: Socket; @@ -5833,33 +5749,18 @@ export class CultMesh { const port = options.bindPort ?? 0; const bind = { host, port }; const socket = options.socket ?? createSocket(host.includes(":") ? "udp6" : "udp4"); - type SessionRecord = { + const sessions = new Map; - }; - const sessions = new Map(); + }>(); let sessionSequence = 0; - let sendFailures = 0; const resendPollMs = Math.max(10, options.resendPollMs ?? 25); const sessionTimeoutMs = Math.max(1_000, options.sessionTimeoutMs ?? 30_000); const wireContract = options.wireContract ?? "cultnet.schema.v0"; - const maxFragmentBytes = options.maxFragmentBytes ?? CULTMESH_RUDP_DOCUMENT_SERVER_DEFAULT_MAX_FRAGMENT_BYTES; - if (!(maxFragmentBytes > 0)) { - throw new Error("CultMesh RUDP document server maxFragmentBytes must be greater than zero."); - } - const maxPayloadBytes = options.maxPayloadBytes; - // The most fragments one reply can take: the wire's fragment count, and the - // reliable queue a reply must fit into whole. - const maxReplyFragments = Math.min( - RUDP_MAX_FRAGMENTS_PER_MESSAGE, - options.maxPendingReliablePackets ?? RUDP_MAX_FRAGMENTS_PER_MESSAGE, - ); let resendTimer: NodeJS.Timeout | undefined; function reportError(error: unknown): void { @@ -5880,16 +5781,20 @@ export class CultMesh { if (packet.packetType === "connect") { const connectPayload = Uint8Array.from(packet.payload ?? []); - if (record?.session.connectRepeats(packet)) { - sendPacket(record, record.session.acceptConnect(packet, nowMs)); + if (record && byteArraysEqual(record.connectPayload, connectPayload)) { + socket.send( + encodeRudpPacket(record.session.acceptConnect(packet, nowMs)), + remote.port, + remote.address, + ); return; } - const next: SessionRecord = { + if (record) closeSession(record); + record = { sessionId: `${runtimeId}:${++sessionSequence}`, remote: { address: remote.address, family: remote.family, port: remote.port }, connectPayload, closed: false, - unsendable: false, session: new CultNetRudpSession({ connectionId, initialSequence: options.initialSequence, @@ -5898,12 +5803,8 @@ export class CultMesh { }), work: Promise.resolve(), }; - sendPacket(next, next.session.acceptConnect(packet, nowMs)); - // A peer whose Accept can never be sent cannot be answered: no session - // starts, and one already there is left as it was. - if (next.unsendable) return; - if (record) closeSession(record); - sessions.set(key, next); + sessions.set(key, record); + socket.send(encodeRudpPacket(record.session.acceptConnect(packet, nowMs)), remote.port, remote.address); return; } @@ -5911,22 +5812,12 @@ export class CultMesh { return; } - let result: ReturnType; - try { - result = record.session.receive(packet, nowMs); - } catch { - // receive() has already recorded the packet's reliable sequence, so the - // session cannot be kept: a retransmit would be acknowledged and the frame - // silently lost. It ends, never the server, and the peer is told. What a - // datagram carries is the sender's business, so nothing is reported. - endRefusedSession(key, record); - return; - } + const result = record.session.receive(packet, nowMs); if (result.reply) { - sendPacket(record, result.reply); + socket.send(encodeRudpPacket(result.reply), record.remote.port, record.remote.address); } for (const ready of result.readyToSend ?? []) { - sendPacket(record, ready); + socket.send(encodeRudpPacket(ready), record.remote.port, record.remote.address); } for (const frame of result.delivered) { if (frame.channelId !== "schema") { @@ -5942,7 +5833,11 @@ export class CultMesh { return; } if (packet.reliable) { - sendPacket(record, record.session.createAckForReceived(packet.sequence)); + socket.send( + encodeRudpPacket(record.session.createAckFor(packet.sequence)), + record.remote.port, + record.remote.address, + ); } } catch (error) { reportError(error); @@ -5951,7 +5846,7 @@ export class CultMesh { socket.on("error", reportError); async function handleDocumentServerFrame( - record: SessionRecord, + record: { sessionId: string; remote: { address: string; family: string; port: number }; session: CultNetRudpSession; connectPayload: Uint8Array; closed: boolean }, payload: Uint8Array, ): Promise { if (record.closed) return; @@ -5965,25 +5860,14 @@ export class CultMesh { }); return; } - let reply: CultNetMessage; try { const cache = await options.getCache(); - reply = options.documents.createRawSnapshotResponse(cache, message.messageId, message); + sendSchemaMessage(record, options.documents.createRawSnapshotResponse(cache, message.messageId, message)); } catch (error) { - reportError(error); - refuse(record, "the snapshot source failed"); - return; - } - try { - sendSchemaMessage(record, reply); - } catch (error) { - reportError(error); - refuse( - record, - maxPayloadBytes !== undefined && encodeSchemaMessage(reply).byteLength > maxPayloadBytes - ? "the snapshot response is too large" - : "the snapshot response could not be queued", - ); + sendSchemaMessage(record, { + schemaVersion: "cultnet.error.v0", + error: error instanceof Error ? error.message : String(error), + }); } return; } @@ -5992,24 +5876,17 @@ export class CultMesh { return; case "cultnet.document_put_raw.v0": if (options.onDocumentPutRaw) { - const unservable = unservablePut(message); - if (unservable) { - reportError(unservable); - sendSchemaMessage(record, { schemaVersion: "cultnet.error.v0", error: unservable.message }); - return; - } const receipt = await options.onDocumentPutRaw(normalizeRudpDocumentPut(message, record.remote)); if (receipt) { - try { - sendSchemaMessage(record, receiptMessage(receipt, message.messageId)); - } catch (error) { - // The put is stored: the peer must hear that its receipt is not coming. - reportError(error); - sendSchemaMessage(record, { - schemaVersion: "cultnet.error.v0", - error: `CultMesh RUDP document server stored a put but could not send its receipt.`, - }); - } + sendSchemaMessage(record, options.documents.createRawDocumentPutMessage( + receipt.binding, receipt.messageId ?? message.messageId, receipt.recordKey, receipt.value, + { + sourceRuntimeId: receipt.sourceRuntimeId ?? runtimeId, + sourceAgentId: receipt.sourceAgentId, + sourceRole: receipt.sourceRole ?? "provider", + tags: receipt.tags ?? ["receipt"], + }, + )); } } return; @@ -6031,7 +5908,13 @@ export class CultMesh { } } - function publicSession(record: SessionRecord): CultMeshRudpServerSession { + function publicSession(record: { + sessionId: string; + remote: { address: string; family: string; port: number }; + session: CultNetRudpSession; + connectPayload: Uint8Array; + closed: boolean; + }): CultMeshRudpServerSession { return { sessionId: record.sessionId, remote: { ...record.remote }, @@ -6043,156 +5926,46 @@ export class CultMesh { }; } - function notifySessionClosed(record: SessionRecord): void { + function notifySessionClosed(record: { + sessionId: string; + remote: { address: string; family: string; port: number }; + session: CultNetRudpSession; + connectPayload: Uint8Array; + closed: boolean; + }): void { if (!options.onSessionClosed) return; void Promise.resolve(options.onSessionClosed(publicSession(record))).catch(reportError); } - function closeSession(record: SessionRecord): void { + function closeSession(record: { + sessionId: string; + remote: { address: string; family: string; port: number }; + session: CultNetRudpSession; + connectPayload: Uint8Array; + closed: boolean; + }): void { if (record.closed) return; record.closed = true; notifySessionClosed(record); } - /** - * Sends one packet to a session's peer. A failure is that peer's alone: one that may - * pass (no route, full buffers) is a lost datagram, counted, and resent if it was - * reliable; one that can never pass as built ends that peer's session. Neither ends - * the server, a timer or another peer's session. - */ - function sendPacket(record: SessionRecord, packet: CultNetRudpPacket): void { - sendRudpDatagram(socket, encodeRudpPacket(packet), record.remote.port, record.remote.address, (error) => { - if (isPermanentSendError(error)) { - endUnsendableSession(record, error); - } else { - sendFailures += 1; - } - }); - } - - function endRefusedSession(key: string, record: SessionRecord): void { - sessions.delete(key); - closeSession(record); - // The goodbye is built after the reset, or its ack field would acknowledge the - // very frame the session refused. - record.session.resetPeerState(); - const goodbye = encodeRudpPacket(record.session.createDisconnect(Buffer.from("session refused a packet", "utf8"))); - sendRudpDatagram(socket, goodbye, record.remote.port, record.remote.address, () => {}); - } - - /** The session owes its peer a packet that can never be sent as built. */ - function endUnsendableSession(record: SessionRecord, error: Error): void { - if (record.unsendable) return; - record.unsendable = true; - const key = `${record.remote.address}:${record.remote.port}`; - // A session that never started, or was already replaced, has nothing to end. - if (sessions.get(key) !== record) return; - sessions.delete(key); - closeSession(record); - const goodbye = encodeRudpPacket(record.session.endUnsendableSession(error)); - sendRudpDatagram(socket, goodbye, record.remote.port, record.remote.address, () => {}); - } - function sendSchemaMessage( - record: SessionRecord, + record: { sessionId: string; remote: { address: string; port: number }; session: CultNetRudpSession; closed: boolean }, message: CultNetMessage, ): void { if (record.closed) throw new Error(`CultMesh RUDP session ${record.sessionId} is closed.`); - const payload = encodeSchemaMessage(message); - if (maxPayloadBytes !== undefined && payload.byteLength > maxPayloadBytes) { - throw new Error( - `CultMesh RUDP reply ${message.schemaVersion} is ${payload.byteLength} bytes; ` - + `maxPayloadBytes is ${maxPayloadBytes}.`, - ); - } + const payload = encode(encodeCultNetMessageForWire(message, wireContract)); for (const packet of record.session.sendMany("schema", payload, { reliable: true, ordered: true, nowMs: Date.now(), - maxFragmentBytes, })) { - sendPacket(record, packet); + socket.send(encodeRudpPacket(packet), record.remote.port, record.remote.address); } } - /** - * Answers a request the server cannot serve with fixed text, never an error's message, - * which can quote what a peer or the application supplied. The answer is unreliable and - * unordered, so it needs no room in a reliable queue that may just have refused the reply, - * and its acknowledgement fields acknowledge nothing, as every runtime's refusal does. - */ - function refuse(record: SessionRecord, text: string): void { - if (record.closed) return; - const payload = encodeSchemaMessage({ schemaVersion: "cultnet.error.v0", error: text }); - for (const packet of record.session.sendMany("schema", payload, { - reliable: false, - ordered: false, - nowMs: Date.now(), - maxFragmentBytes, - })) { - sendPacket(record, { ...packet, ack: 0, ackMask: 0 }); - } - } - - /** The one reply encoder, shared by sends and by put admission. */ - function encodeSchemaMessage(message: CultNetMessage): Uint8Array { - return encode(encodeCultNetMessageForWire(message, wireContract)); - } - - /** Builds the receipt `onDocumentPutRaw` returned, under the put's message id by default. */ - function receiptMessage(receipt: CultMeshRudpDocumentReceipt, putMessageId: string): CultNetMessage { - return options.documents.createRawDocumentPutMessage( - receipt.binding, receipt.messageId ?? putMessageId, receipt.recordKey, receipt.value, - { - sourceRuntimeId: receipt.sourceRuntimeId ?? runtimeId, - sourceAgentId: receipt.sourceAgentId, - sourceRole: receipt.sourceRole ?? "provider", - tags: receipt.tags ?? ["receipt"], - }, - ); - } - - /** - * Refuse a put whose document could never be served: the snapshot reply - * carrying it alone, under the shortest message id CultNet parses, sized as - * `sendSchemaMessage` would send it. It is built from the record the - * registry would store, which is exact only when the application stores - * through the registry; a document the registry has no binding for is - * sized as received. - */ - function unservablePut(message: CultNetMessage): CultMeshRudpUnservableDocumentError | undefined { - if (message.schemaVersion !== "cultnet.document_put_raw.v0") return undefined; - let reply: CultNetMessage; - try { - reply = options.documents.createRawSnapshotResponseForPut(message, SHORTEST_MESSAGE_ID); - } catch { - reply = { - schemaVersion: "cultnet.snapshot_response_raw.v0", - messageId: SHORTEST_MESSAGE_ID, - documents: [message.document], - }; - } - const responseBytes = encodeSchemaMessage(reply).byteLength; - const fragmentCount = Math.max(1, Math.ceil(responseBytes / maxFragmentBytes)); - if ((maxPayloadBytes === undefined || responseBytes <= maxPayloadBytes) - && fragmentCount <= maxReplyFragments) { - return undefined; - } - return new CultMeshRudpUnservableDocumentError( - message.messageId, - message.document.recordKey, - responseBytes, - maxPayloadBytes, - fragmentCount, - maxReplyFragments, - ); - } - return { bind, - get sendFailures() { - return sendFailures; - }, async start(): Promise { await new Promise((resolve, reject) => { socket.once("error", reject); @@ -6214,7 +5987,7 @@ export class CultMesh { continue; } for (const packet of record.session.dueResends(nowMs)) { - sendPacket(record, packet); + socket.send(encodeRudpPacket(packet), record.remote.port, record.remote.address); } } }, resendPollMs); @@ -6350,7 +6123,7 @@ export class CultMesh { options: CultMeshRudpSocketOptions = {}, ): Promise { requireNonEmpty(runtimeId, "runtimeId"); - const socket = options.socket ?? (await bindRudpSocket(options.bindHost ?? "127.0.0.1", options)); + const socket = options.socket ?? (await bindRudpSocket(options)); return new CultNetRudpSocketTransportConnection({ runtimeId, socket, @@ -6376,10 +6149,7 @@ export class CultMesh { requireNonEmpty(runtimeId, "runtimeId"); const parsedEndpoint = typeof endpoint === "string" ? CultMesh.parseRudpEndpoint(endpoint) : endpoint; - const socket = options.socket ?? (await bindRudpSocket( - options.bindHost ?? (await rudpClientBindHost(parsedEndpoint.host)), - options, - )); + const socket = options.socket ?? (await bindRudpSocket(options)); return new CultNetRudpSocketTransportConnection({ runtimeId, socket, @@ -6498,28 +6268,6 @@ export class CultMesh { } return CultMesh.createRudpPeerForPeer(runtimeId, connectionId, peer, options); } - - public static parseQuicRealtimeEndpoint(endpoint: string): ReturnType { - return parseQuicRealtimeEndpoint(endpoint); - } - - public static createQuicRealtimeConnector( - options: CultMeshQuicRealtimeConnectorOptions = {}, - ): CultMeshQuicRealtimeConnector { - return new CultMeshQuicRealtimeConnector(options); - } - - public static createQuicRealtimeSessionManager( - options: CultMeshQuicRealtimeSessionManagerOptions, - ): CultMeshQuicRealtimeSessionManager { - return new CultMeshQuicRealtimeSessionManager(options); - } - - public static createQuicRealtimeProvider( - options: CultMeshQuicRealtimeProviderOptions, - ): Promise { - return CultMeshQuicRealtimeProvider.listen(options); - } } function cultMeshSchemaFromDefinition( @@ -6804,8 +6552,9 @@ function toUint8Array(value: unknown): Uint8Array { throw new Error("CultNet raw document payload was not binary."); } -async function bindRudpSocket(host: string, options: CultMeshRudpSocketOptions): Promise { - const socket = createSocket(host.includes(":") ? "udp6" : "udp4"); +async function bindRudpSocket(options: CultMeshRudpSocketOptions): Promise { + const socket = createSocket("udp4"); + const host = options.bindHost ?? "127.0.0.1"; const port = options.bindPort ?? 0; await new Promise((resolve, reject) => { socket.once("error", reject); @@ -6888,6 +6637,14 @@ function nonBlankOr(value?: string, fallback = ""): string { return value && value.trim() ? value : fallback; } +function byteArraysEqual(left: Uint8Array, right: Uint8Array): boolean { + if (left.byteLength !== right.byteLength) return false; + for (let index = 0; index < left.byteLength; index += 1) { + if (left[index] !== right[index]) return false; + } + return true; +} + function parseCultMeshLocalityKind( value: string | undefined, fallback: CultMeshLocalityKind, diff --git a/packages/cultmesh-ts/src/realtime-quic-native.ts b/packages/cultmesh-ts/src/realtime-quic-native.ts deleted file mode 100644 index 52b0ce01..00000000 --- a/packages/cultmesh-ts/src/realtime-quic-native.ts +++ /dev/null @@ -1,583 +0,0 @@ -// The koffi binding for `native/GameCult.Mesh.Quic.Native`'s C ABI v2 -// (`include/cultmesh_quic_native.h`). This file is the only place `koffi` is -// imported, and it is imported lazily, inside `loadBindings`, so a consumer -// that never touches QUIC (AetheriaEve Electron, Odin, Stonks, weksa) loads no -// native module at all. -// -// No koffi callbacks. `cultmesh_quic_next_event` is the single blocking -// export; `CultMeshQuicNativeRuntime` runs it on koffi's async thread pool in -// one loop per process-wide runtime and dispatches decoded events to -// registered listener/connection handlers by id. Every other export is a -// plain synchronous call. -// -// Binary resolution: `CULTMESH_QUIC_NATIVE_DIR` when set (the development -// loop and CI point it at `artifacts/quic-native/` straight from a -// build), otherwise `path.join(__dirname, "..", "native", "-")` -// (the committed tree a later cut lands; `__dirname` is `dist/` at runtime, so -// this path holds in the repo, an `npm pack` tarball and a pnpm `file:` copy -// alike). No `node_modules` lookup, no platform package, no registry. -// -// Two koffi quirks this file works around, both probed against the pinned -// 3.3.0 build: `_Out_` does not auto-allocate storage, so every out -// parameter is `koffi.alloc(type, 1)` written by the call and read back with -// `koffi.decode(buffer, type)`; and a decoded 64-bit value (`void *`, -// `uint64_t`) comes back as a plain `number` when it fits a safe integer, -// not a `bigint`. `toBigInt64` below is the one place that coerces either -// into the `bigint` every exported type in this module promises. - -import { existsSync } from "node:fs"; -import { join } from "node:path"; - -/** One decoded native event, payload already sliced to `payload_length`. */ -export interface CultMeshQuicNativeEvent { - readonly type: number; - readonly streamKind: number; - readonly listenerId: bigint; - readonly connectionId: bigint; - readonly streamId: bigint; - readonly code: bigint; - readonly status: number; - readonly payload: Uint8Array; -} - -export const CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION = 1; -export const CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED = 2; -export const CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED = 3; -export const CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN = 4; -export const CULTMESH_QUIC_EVENT_STREAM_STARTED = 5; -export const CULTMESH_QUIC_EVENT_STREAM_FRAME = 6; -export const CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE = 7; -export const CULTMESH_QUIC_EVENT_STREAM_SHUTDOWN = 8; -export const CULTMESH_QUIC_EVENT_LISTENER_STOPPED = 9; - -export const CULTMESH_QUIC_SEND_COMPLETED = 0; -export const CULTMESH_QUIC_SEND_CANCELED = 1; - -export const CULTMESH_QUIC_STREAM_RELIABLE = 1; -export const CULTMESH_QUIC_STREAM_LATEST_ONLY = 2; - -export const CULTMESH_QUIC_RESULT_BAD_CALL = -1; -export const CULTMESH_QUIC_RESULT_BAD_ARGUMENT = -2; - -type NativeEventListener = (event: CultMeshQuicNativeEvent) => void; -/** Invoked once when a connection is faulted: a throwing listener, a malformed - * frame, or any other error raised while dispatching an event for it. */ -type NativeFaultHandler = (error: Error) => void; - -/** koffi decodes a 64-bit value as `number` when it fits a safe integer and as - * `bigint` otherwise (probed on the pinned 3.3.0 build); this is the single - * place that coerces either into the `bigint` every exported type promises. */ -function toBigInt64(value: number | bigint): bigint { - return typeof value === "bigint" ? value : BigInt(value); -} - -/** The opaque native runtime handle: a `void *`, decoded by koffi as a `bigint`. */ -export type CultMeshQuicNativeHandle = bigint; - -interface NativeEventStruct { - type: number; - stream_kind: number; - listener_id: bigint; - connection_id: bigint; - stream_id: bigint; - code: bigint; - status: number; - payload_length: number; -} - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type KoffiLib = any; - -/** `nextEventAsync`'s signature, typed explicitly because `promisify` cannot - * infer one from koffi's untyped (`any`) async export. */ -type NextEventAsyncFn = ( - runtime: CultMeshQuicNativeHandle, - timeoutMs: number, - outEvent: unknown, - payload: Uint8Array | null, - payloadCapacity: number, - outRequired: unknown, -) => Promise; - -/** - * The loaded native library: koffi itself, the declared struct, and the - * twelve raw v2 exports. Untyped (koffi is `any`); the runtime class methods - * below are the type surface for these calls, so wrapping them a second time - * in a typed interface would only restate what the methods already say. The - * type is inferred from `buildLibrary`'s return value instead of restated. - */ -// eslint-disable-next-line @typescript-eslint/no-use-before-define -type LoadedNativeLibrary = ReturnType; - -let libraryCache: LoadedNativeLibrary | undefined; - -function platformArchDir(): string { - return `${process.platform}-${process.arch}`; -} - -function platformFileNames(): { bridge: string; dependency: string } { - if (process.platform === "win32") { - return { bridge: "gamecult_mesh_quic_native.dll", dependency: "msquic.dll" }; - } - if (process.platform === "linux") { - return { bridge: "libgamecult_mesh_quic_native.so", dependency: "libmsquic.so.2" }; - } - throw new Error(`CultMesh QUIC native binding does not support platform '${process.platform}'.`); -} - -function resolveNativeDir(): string { - const configured = process.env.CULTMESH_QUIC_NATIVE_DIR; - if (configured && configured.length > 0) return configured; - return join(__dirname, "..", "native", platformArchDir()); -} - -/** Loads koffi, resolves the binary directory, and declares the ABI. */ -function buildLibrary() { - // Untyped on purpose: koffi's own type declarations are ESM-flavored and - // fight a CommonJS `typeof import(...)` reference under Node16 resolution. - // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-explicit-any - const koffi: any = require("koffi"); - const { bridge, dependency } = platformFileNames(); - const dir = resolveNativeDir(); - const bridgePath = join(dir, bridge); - const dependencyPath = join(dir, dependency); - if (!existsSync(bridgePath) || !existsSync(dependencyPath)) { - const envDir = process.env.CULTMESH_QUIC_NATIVE_DIR; - throw new Error( - "CultMesh QUIC native binaries were not found. Tried " + - `'${dir}' (${envDir ? "CULTMESH_QUIC_NATIVE_DIR" : "the package's committed native/ tree"}). ` + - "Set CULTMESH_QUIC_NATIVE_DIR to a directory built by scripts/build-quic-native.ps1 or " + - "scripts/build-quic-native.sh, or ship the committed native/ tree.", - ); - } - - // The dependent library must be resolvable before the bridge loads. - koffi.load(dependencyPath); - const bridgeLib = koffi.load(bridgePath); - - const event = koffi.struct("cultmesh_quic_event", { - type: "uint32_t", - stream_kind: "uint32_t", - listener_id: "uint64_t", - connection_id: "uint64_t", - stream_id: "uint64_t", - code: "uint64_t", - status: "int32_t", - payload_length: "int32_t", - reserved: koffi.array("uint8_t", 16), - }); - - const runtimeOpenFn = bridgeLib.func( - "int32_t cultmesh_quic_runtime_open(str app_name, void **out_runtime)", - ); - const runtimeCloseFn = bridgeLib.func("void cultmesh_quic_runtime_close(void *runtime)"); - const listenerOpenFn = bridgeLib.func( - "int32_t cultmesh_quic_listener_open(void *runtime, str host, uint16_t port, " + - "uint8_t *pkcs12, int32_t pkcs12_length, str password, " + - "uint64_t *out_listener_id, uint16_t *out_bound_port)", - ); - const listenerCloseFn = bridgeLib.func( - "void cultmesh_quic_listener_close(void *runtime, uint64_t listener_id)", - ); - const connectionOpenFn = bridgeLib.func( - "int32_t cultmesh_quic_connection_open(void *runtime, str host, uint16_t port, " + - "uint64_t *out_connection_id)", - ); - const connectionCertificateCompleteFn = bridgeLib.func( - "int32_t cultmesh_quic_connection_certificate_complete(void *runtime, uint64_t connection_id, int32_t accept)", - ); - const connectionShutdownFn = bridgeLib.func( - "void cultmesh_quic_connection_shutdown(void *runtime, uint64_t connection_id, uint64_t code)", - ); - const streamOpenFn = bridgeLib.func( - "int32_t cultmesh_quic_stream_open(void *runtime, uint64_t connection_id, uint8_t kind, " + - "uint64_t *out_stream_id)", - ); - const streamSendFrameFn = bridgeLib.func( - "int32_t cultmesh_quic_stream_send_frame(void *runtime, uint64_t stream_id, " + - "uint8_t *encoded_frame, int32_t length, int32_t fin)", - ); - const streamShutdownFn = bridgeLib.func( - "void cultmesh_quic_stream_shutdown(void *runtime, uint64_t stream_id, uint64_t code)", - ); - const nextEventFn = bridgeLib.func( - "int32_t cultmesh_quic_next_event(void *runtime, int32_t timeout_ms, " + - `${event.name} *out_event, uint8_t *payload, int32_t payload_capacity, ` + - "int32_t *out_required)", - ); - const lastErrorFn = bridgeLib.func( - "int32_t cultmesh_quic_last_error(void *runtime, uint8_t *destination, int32_t capacity)", - ); - - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { promisify } = require("node:util") as typeof import("node:util"); - const nextEventAsync = promisify(nextEventFn.async) as NextEventAsyncFn; - - return { - koffi, - event, - runtimeOpenFn, - runtimeCloseFn, - listenerOpenFn, - listenerCloseFn, - connectionOpenFn, - connectionCertificateCompleteFn, - connectionShutdownFn, - streamOpenFn, - streamSendFrameFn, - streamShutdownFn, - nextEventAsync, - lastErrorFn, - }; -} - -/** Lazily builds and caches the loaded native library. */ -function loadBindings(): LoadedNativeLibrary { - if (libraryCache) return libraryCache; - libraryCache = buildLibrary(); - return libraryCache; -} - -function readLastError(lib: LoadedNativeLibrary, runtime: CultMeshQuicNativeHandle): string { - const buffer = Buffer.alloc(1024); - const written = lib.lastErrorFn(runtime, buffer, buffer.length); - return written > 0 ? buffer.subarray(0, written).toString("utf8") : "CultMesh native QUIC call failed."; -} - -/** - * One MsQuic registration and one event queue, shared process-wide. - * `open`/`release` are reference-counted: the underlying runtime opens on the - * first `open` and closes on the last matching `release`. `open`/`release` - * calls do not need to be paired 1:1 by the same caller as long as the counts - * balance overall. - */ -export class CultMeshQuicNativeRuntime { - private static shared: CultMeshQuicNativeRuntime | undefined; - private static refCountValue = 0; - - /** Outstanding `open()` references not yet matched by `release()`. Test-visible: the UAF and eviction regression tests assert it returns to its baseline. */ - static get refCount(): number { - return CultMeshQuicNativeRuntime.refCountValue; - } - - private readonly handle: CultMeshQuicNativeHandle; - private readonly lib: LoadedNativeLibrary; - private readonly listenerListeners = new Map(); - private readonly connectionListeners = new Map< - bigint, - { listener: NativeEventListener; onFault?: NativeFaultHandler } - >(); - private closed = false; - private pumpLoop: Promise; - - /** - * `nextEvent`'s out-parameter buffers, allocated once and reused for every - * call instead of per call: the pump is single-threaded with at most one - * `nextEvent` in flight (`nextEventAsync` is only ever awaited, never - * fired concurrently), so decode-then-reuse is safe. Freed once in - * `release()` after the pump loop has exited. - */ - private readonly outEventBuffer: unknown; - private readonly outRequiredBuffer: unknown; - - private constructor(handle: CultMeshQuicNativeHandle, lib: LoadedNativeLibrary) { - this.handle = handle; - this.lib = lib; - this.outEventBuffer = lib.koffi.alloc(lib.event, 1); - this.outRequiredBuffer = lib.koffi.alloc("int32_t", 1); - this.pumpLoop = this.pump(); - } - - static async open(): Promise { - if (!CultMeshQuicNativeRuntime.shared) { - const lib = loadBindings(); - const out = lib.koffi.alloc("void *", 1); - const status = lib.runtimeOpenFn(null, out); - if (status !== 0) { - lib.koffi.free(out); - throw new Error(`cultmesh_quic_runtime_open failed with status ${status}.`); - } - const handle = toBigInt64(lib.koffi.decode(out, "void *")); - lib.koffi.free(out); - CultMeshQuicNativeRuntime.shared = new CultMeshQuicNativeRuntime(handle, lib); - } - CultMeshQuicNativeRuntime.refCountValue += 1; - return CultMeshQuicNativeRuntime.shared; - } - - /** - * Takes one more reference on this already-open runtime, synchronously — - * unlike `open()`, this never awaits a runtime-open call, so a caller - * already holding a live instance (a provider handing a reference to a - * newly accepted peer) can attach it in the same synchronous turn instead - * of crossing a microtask boundary that would leave the event a caller is - * mid-dispatching unowned until the next tick. - */ - retain(): CultMeshQuicNativeRuntime { - CultMeshQuicNativeRuntime.refCountValue += 1; - return this; - } - - /** - * Drops one reference; closes the shared runtime once none remain. Refuses - * a release when no reference is outstanding. The bridge header (section 4) - * forbids any host call beginning once `cultmesh_quic_runtime_close` has - * started, so this marks the runtime closed and waits for the pump to exit - * (it wakes within its 250 ms `nextEvent` timeout) before making that call: - * a queued, not-yet-started `nextEvent` call must never begin after close - * and run against freed memory. - */ - async release(): Promise { - if (CultMeshQuicNativeRuntime.refCountValue === 0) { - throw new Error("CultMeshQuicNativeRuntime.release called with no outstanding reference."); - } - CultMeshQuicNativeRuntime.refCountValue -= 1; - if (CultMeshQuicNativeRuntime.refCountValue > 0) return; - this.closed = true; - CultMeshQuicNativeRuntime.shared = undefined; - await this.pumpLoop; - this.lib.runtimeCloseFn(this.handle); - this.lib.koffi.free(this.outEventBuffer); - this.lib.koffi.free(this.outRequiredBuffer); - } - - onListenerEvent(listenerId: bigint, listener: NativeEventListener): void { - this.listenerListeners.set(listenerId, listener); - } - - offListenerEvent(listenerId: bigint): void { - this.listenerListeners.delete(listenerId); - } - - /** - * Registers the event listener for one connection. `onFault`, if given, is - * invoked exactly once if `listener` (or anything it calls synchronously, - * such as a caller-supplied certificate validator) throws while dispatching - * an event for this connection: the pump isolates the fault to this - * connection, shuts it down at the native level, removes the listener, and - * keeps running for every other connection. - */ - onConnectionEvent(connectionId: bigint, listener: NativeEventListener, onFault?: NativeFaultHandler): void { - this.connectionListeners.set(connectionId, { listener, onFault }); - } - - offConnectionEvent(connectionId: bigint): void { - this.connectionListeners.delete(connectionId); - } - - listenerOpen( - host: string | null, - port: number, - pkcs12: Uint8Array, - password: string | null, - ): { listenerId: bigint; boundPort: number } { - const outListenerId = this.lib.koffi.alloc("uint64_t", 1); - const outBoundPort = this.lib.koffi.alloc("uint16_t", 1); - try { - const status = this.lib.listenerOpenFn( - this.handle, - host, - port, - pkcs12, - pkcs12.length, - password, - outListenerId, - outBoundPort, - ); - if (status !== 0) { - throw new Error(`cultmesh_quic_listener_open failed: ${readLastError(this.lib, this.handle)}`); - } - return { - listenerId: toBigInt64(this.lib.koffi.decode(outListenerId, "uint64_t")), - boundPort: this.lib.koffi.decode(outBoundPort, "uint16_t") as number, - }; - } finally { - this.lib.koffi.free(outListenerId); - this.lib.koffi.free(outBoundPort); - } - } - - listenerClose(listenerId: bigint): void { - this.lib.listenerCloseFn(this.handle, listenerId); - this.offListenerEvent(listenerId); - } - - connectionOpen(host: string, port: number): bigint { - const out = this.lib.koffi.alloc("uint64_t", 1); - try { - const status = this.lib.connectionOpenFn(this.handle, host, port, out); - if (status !== 0) { - throw new Error(`cultmesh_quic_connection_open failed: ${readLastError(this.lib, this.handle)}`); - } - return toBigInt64(this.lib.koffi.decode(out, "uint64_t")); - } finally { - this.lib.koffi.free(out); - } - } - - connectionCertificateComplete(connectionId: bigint, accept: boolean): void { - const status = this.lib.connectionCertificateCompleteFn(this.handle, connectionId, accept ? 1 : 0); - if (status !== 0) { - throw new Error( - `cultmesh_quic_connection_certificate_complete failed: ${readLastError(this.lib, this.handle)}`, - ); - } - } - - connectionShutdown(connectionId: bigint, code: bigint): void { - this.lib.connectionShutdownFn(this.handle, connectionId, code); - } - - streamOpen(connectionId: bigint, kind: number): bigint { - const out = this.lib.koffi.alloc("uint64_t", 1); - try { - const status = this.lib.streamOpenFn(this.handle, connectionId, kind, out); - if (status !== 0) { - throw new Error(`cultmesh_quic_stream_open failed: ${readLastError(this.lib, this.handle)}`); - } - return toBigInt64(this.lib.koffi.decode(out, "uint64_t")); - } finally { - this.lib.koffi.free(out); - } - } - - streamSendFrame(streamId: bigint, encodedFrame: Uint8Array, fin: boolean): void { - const status = this.lib.streamSendFrameFn(this.handle, streamId, encodedFrame, encodedFrame.length, fin ? 1 : 0); - if (status !== 0) { - throw new Error(`cultmesh_quic_stream_send_frame failed: ${readLastError(this.lib, this.handle)}`); - } - } - - streamShutdown(streamId: bigint, code: bigint): void { - this.lib.streamShutdownFn(this.handle, streamId, code); - } - - /** - * Isolates the faulting connection so one bad event never brings down the - * pump: a malformed frame, a stream-kind/delivery mismatch, or a throwing - * caller-supplied listener (certificate validator, waiter) faults only its - * own connection. The listener is removed, the connection is shut down at - * the native level, and `onFault` (if registered) is told, so pending and - * future work on that connection can reject with the error. Every other - * connection, and the pump itself, keep running. - */ - private dispatch(event: NativeEventStruct, payload: Uint8Array): void { - const decoded: CultMeshQuicNativeEvent = { - type: event.type, - streamKind: event.stream_kind, - listenerId: event.listener_id, - connectionId: event.connection_id, - streamId: event.stream_id, - code: event.code, - status: event.status, - payload, - }; - if (decoded.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION || decoded.type === CULTMESH_QUIC_EVENT_LISTENER_STOPPED) { - try { - this.listenerListeners.get(decoded.listenerId)?.(decoded); - } catch (error) { - // No fault contract for listener-level events today; do not let a - // throwing handler crash the pump. - this.reportUnhandledDispatchError(error); - } - return; - } - const entry = this.connectionListeners.get(decoded.connectionId); - if (!entry) return; - try { - entry.listener(decoded); - } catch (error) { - this.faultConnection(decoded.connectionId, error instanceof Error ? error : new Error(String(error)), entry.onFault); - } - } - - private faultConnection(connectionId: bigint, error: Error, onFault: NativeFaultHandler | undefined): void { - this.connectionListeners.delete(connectionId); - try { - this.lib.connectionShutdownFn(this.handle, connectionId, 0n); - } catch { - // Best-effort: the connection may already be gone. - } - if (onFault) { - try { - onFault(error); - } catch (handlerError) { - // The fault handler itself is caller-supplied code; a throw here - // must not escape into the pump any more than the original fault did. - this.reportUnhandledDispatchError(handlerError); - } - } else { - this.reportUnhandledDispatchError(error); - } - } - - private reportUnhandledDispatchError(error: unknown): void { - // eslint-disable-next-line no-console - console.error("CultMesh QUIC native event dispatch failed with no fault handler registered:", error); - } - - private async nextEvent( - timeoutMs: number, - payload: Uint8Array | null, - payloadCapacity: number, - ): Promise<{ status: number; event: NativeEventStruct | null; required: number }> { - // Reuses the buffers allocated once in the constructor instead of - // allocating fresh ones per call: the pump awaits each `nextEventAsync` - // before issuing the next one, so at most one call is ever in flight - // against them, and both are fully decoded here before the buffers can - // be reused by the pump's next call. - const status = await this.lib.nextEventAsync( - this.handle, - timeoutMs, - this.outEventBuffer, - payload, - payloadCapacity, - this.outRequiredBuffer, - ); - const decoded = - status === 1 ? (this.lib.koffi.decode(this.outEventBuffer, this.lib.event) as NativeEventStruct) : null; - return { - status, - event: decoded && { - ...decoded, - listener_id: toBigInt64(decoded.listener_id), - connection_id: toBigInt64(decoded.connection_id), - stream_id: toBigInt64(decoded.stream_id), - code: toBigInt64(decoded.code), - }, - required: this.lib.koffi.decode(this.outRequiredBuffer, "int32_t") as number, - }; - } - - private async pump(): Promise { - while (!this.closed) { - let first: Awaited>; - try { - first = await this.nextEvent(250, null, 0); - } catch { - if (this.closed) return; - continue; - } - if (this.closed) return; - if (first.status === 0 || first.status === CULTMESH_QUIC_RESULT_BAD_CALL) continue; - if (first.status === 1 && first.event) { - this.dispatch(first.event, new Uint8Array(0)); - continue; - } - if (first.status === 2 && first.required > 0) { - const buffer = Buffer.alloc(first.required); - let second: Awaited>; - try { - second = await this.nextEvent(0, buffer, buffer.length); - } catch { - if (this.closed) return; - continue; - } - if (second.status === 1 && second.event) { - this.dispatch(second.event, buffer.subarray(0, second.event.payload_length)); - } - continue; - } - } - } -} diff --git a/packages/cultmesh-ts/src/realtime-quic.ts b/packages/cultmesh-ts/src/realtime-quic.ts deleted file mode 100644 index c368c96f..00000000 --- a/packages/cultmesh-ts/src/realtime-quic.ts +++ /dev/null @@ -1,1329 +0,0 @@ -// The Node QUIC realtime plane: a consumer transport and connector over the -// native v2 bridge, and the session manager that binds an advertised route to -// a connected, authority-verified transport. -// -// Provider and consumer semantics (which stream kind carries which delivery -// mode, the generation filter, the certificate pin decision) are pinned rule -// for rule against the C# reference, `src/GameCult.Mesh.Quic/CultMeshQuicRealtimeTransport.cs` -// (the connector) and `src/GameCult.Mesh/CultMeshSessions.cs` (the session -// manager's binding, ordering and racing). -// -// This module never touches `koffi` directly; every native call goes through -// `CultMeshQuicNativeRuntime` in `realtime-quic-native.ts`, which loads it -// lazily. No Odin WebSocket rendezvous lives here (Q7, ruled A): a lookup -// source is a port this module takes, not a transport it owns. - -import { createHash } from "node:crypto"; -import { createSecureContext } from "node:tls"; - -import { - routeCertificateView, - trimCSharp, - verifyAuthorityRoute, - type CultMeshAuthorityTrustPolicy, -} from "cultnet-ts"; -import type { CultMeshVerseDescriptorMessage } from "cultnet-ts/contracts"; - -import { - decodeRealtimeFrame, - encodeRealtimeFrame, - CULTMESH_REALTIME_CONNECTION_CLOSE_CODE, - type CultMeshRealtimeFrame, -} from "./realtime-wire"; -import { - CultMeshQuicNativeRuntime, - CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED, - CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED, - CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN, - CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION, - CULTMESH_QUIC_EVENT_STREAM_FRAME, - CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE, - CULTMESH_QUIC_EVENT_STREAM_SHUTDOWN, - CULTMESH_QUIC_EVENT_STREAM_STARTED, - CULTMESH_QUIC_SEND_CANCELED, - CULTMESH_QUIC_STREAM_LATEST_ONLY, - CULTMESH_QUIC_STREAM_RELIABLE, - type CultMeshQuicNativeEvent, -} from "./realtime-quic-native"; - -/** `CultMeshProtocols.RealtimeState.Value` in the C# reference. */ -export const CULTMESH_REALTIME_STATE_PROTOCOL_ID = "cultmesh.realtime_state.v1"; - -/** The QUIC realtime connector's discovery scheme; `CultMeshQuicRealtimeTransportConnector.Scheme`. */ -export const CULTMESH_QUIC_REALTIME_SCHEME = "cultmesh-state+quic"; - -/** Stable provider identity inside one Verse; `CultMeshSessionTarget` in the C# reference. */ -export interface CultMeshRealtimeTarget { - readonly verseId: string; - readonly authorityRuntimeId: string; -} - -/** A physical route candidate; the TS analogue of `CultMeshTransportCandidate`. */ -export interface CultMeshRealtimeCandidate { - readonly endpoint: string; - readonly authorityRuntimeId: string; - readonly priority: number; - readonly generation: string; -} - -/** Transport-neutral realtime plane; the TS analogue of `ICultMeshRealtimeTransport`. */ -export interface CultMeshRealtimeTransport { - readonly transportId: string; - readonly endpoint: string; - sendFrame(frame: CultMeshRealtimeFrame): Promise; - receiveFrame(signal?: AbortSignal): Promise; - dispose(): void; - isVerifiedFor( - verseId: string, - authorityRuntimeId: string, - protocolId: string, - routeGeneration: string, - ): boolean; - /** - * Registers a handler invoked once this transport becomes unusable for any - * reason (explicit `dispose()`, a peer-initiated shutdown, or an internal - * fault). A session manager uses this to evict a dead cached session so the - * next `connect()` redials, mirroring `CultMeshSessions.InvalidateRealtimeSession`. - */ - onDisposed?(handler: () => void): void; -} - -/** Creates realtime transports; the TS analogue of `ICultMeshRealtimeTransportConnector`. */ -export interface CultMeshRealtimeTransportConnector { - readonly connectorId: string; - readonly priority: number; - canConnect(candidate: CultMeshRealtimeCandidate): boolean; - connect( - candidate: CultMeshRealtimeCandidate, - target: CultMeshRealtimeTarget, - signal?: AbortSignal, - ): Promise; -} - -/** A route source the session manager resolves against; Q7's lookup-source port. */ -export interface ICultMeshRealtimeLookupSource { - resolve(target: CultMeshRealtimeTarget): Promise; -} - -/** `CultMeshQuicRealtimeTransportConnector.TryParseEndpoint` (`:98-109`). */ -export function parseQuicRealtimeEndpoint( - endpoint: string, -): { host: string; port: number; certificateSha256?: string } { - let parsed: URL; - try { - parsed = new URL(endpoint); - } catch { - throw new Error(`QUIC realtime connector does not support '${endpoint}'.`); - } - if (parsed.protocol.toLowerCase() !== `${CULTMESH_QUIC_REALTIME_SCHEME}:`) { - throw new Error(`QUIC realtime connector does not support '${endpoint}'.`); - } - if (!parsed.hostname) { - throw new Error(`QUIC realtime connector does not support '${endpoint}'.`); - } - const port = parsed.port ? Number.parseInt(parsed.port, 10) : Number.NaN; - if (!Number.isInteger(port) || port <= 0) { - throw new Error(`QUIC realtime connector does not support '${endpoint}'.`); - } - const pin = parsed.searchParams.get("cert-sha256") ?? undefined; - return { host: parsed.hostname, port, certificateSha256: pin ?? undefined }; -} - -function certificateSha256Hex(der: Uint8Array): string { - return createHash("sha256").update(der).digest("hex"); -} - -/** Shared by `CultMeshQuicRealtimeTransport.sendFrame` and `CultMeshQuicRealtimeProvider.broadcast`: one message, not two copies that can drift. */ -const CULTMESH_QUIC_UNRELIABLE_UNSUPPORTED_MESSAGE = - "The native MsQuic connector exposes streams but not QUIC datagrams; unreliable delivery is not supported."; - -interface PendingSend { - resolve(): void; - reject(error: Error): void; -} - -interface LatestGeneration { - producerEpoch: bigint; - sequence: bigint; -} - -function compareGeneration(a: LatestGeneration, b: LatestGeneration): number { - if (a.producerEpoch !== b.producerEpoch) return a.producerEpoch < b.producerEpoch ? -1 : 1; - if (a.sequence === b.sequence) return 0; - return a.sequence < b.sequence ? -1 : 1; -} - -/** A direct entry, or a coalesced `key` to resolve against `pending` at delivery time. */ -type InboxToken = { readonly value: T } | { readonly key: string }; - -/** - * Mirrors the C# reference's `CultMeshRealtimeInbox` - * (`CultMeshQuicRealtimeTransport.cs:598-644`): publishing under `key` - * coalesces to at most one pending entry per key, keeping that key's - * first-arrival queue position while a later publish overwrites its value; - * publishing with no `key` always queues, unbounded. `receive` drains - * whatever is queued before a `complete(error)` rejects further calls. - * Shared by the transport's inbound queue, the provider's fan-in, and (via - * a pump reading it instead of `receive` callers) each peer's outbox. - */ -class CultMeshRealtimeInbox { - private readonly pending = new Map(); - private readonly ready: InboxToken[] = []; - private readonly waiters: { resolve(value: T): void; reject(error: Error): void }[] = []; - private completed = false; - private terminalError: Error | undefined; - - /** Entries queued but not yet delivered: one per ready key, or one per unkeyed entry. Test-visible. */ - get size(): number { - return this.ready.length; - } - - /** Publishes `value`, coalescing on `key` when given. Returns `false` once `complete()` has run. */ - publish(value: T, key?: string): boolean { - if (this.completed) return false; - if (key === undefined) { - this.deliver({ value }); - return true; - } - const alreadyPending = this.pending.has(key); - this.pending.set(key, value); - if (!alreadyPending) this.deliver({ key }); - return true; - } - - /** Resolves the oldest ready entry, or waits for one; rejects once `complete(error)` has drained the backlog. */ - async receive(signal?: AbortSignal): Promise { - if (this.ready.length > 0) return this.take(this.ready.shift()!); - if (this.completed) throw this.terminalError ?? new Error("CultMesh realtime inbox is completed."); - if (signal?.aborted) throw new Error("CultMesh realtime inbox receive aborted."); - return await new Promise((resolve, reject) => { - const onAbort = (): void => { - const index = this.waiters.indexOf(waiter); - if (index >= 0) this.waiters.splice(index, 1); - reject(new Error("CultMesh realtime inbox receive aborted.")); - }; - const waiter = { - resolve: (value: T) => { - signal?.removeEventListener("abort", onAbort); - resolve(value); - }, - reject: (error: Error) => { - signal?.removeEventListener("abort", onAbort); - reject(error); - }, - }; - signal?.addEventListener("abort", onAbort, { once: true }); - this.waiters.push(waiter); - }); - } - - /** Completes the inbox: entries already queued still drain via `receive`; every call after that rejects with `error`. */ - complete(error?: Error): void { - if (this.completed) return; - this.completed = true; - this.terminalError = error; - for (const waiter of this.waiters.splice(0, this.waiters.length)) { - waiter.reject(error ?? new Error("CultMesh realtime inbox is completed.")); - } - } - - private deliver(token: InboxToken): void { - const waiter = this.waiters.shift(); - if (waiter) { - waiter.resolve(this.take(token)); - return; - } - this.ready.push(token); - } - - private take(token: InboxToken): T { - if ("value" in token) return token.value; - const value = this.pending.get(token.key)!; - this.pending.delete(token.key); - return value; - } -} - -/** Configures certificate acceptance for an outbound QUIC realtime connection. */ -export interface CultMeshQuicRealtimeConnectorOptions { - readonly handshakeTimeoutMs?: number; - readonly validateProviderCertificate?: ( - target: CultMeshRealtimeTarget, - der: Uint8Array, - ) => boolean; -} - -/** Creates Node-native MsQuic realtime connections. `ConnectorId` is `"msquic-realtime"`. */ -export class CultMeshQuicRealtimeConnector implements CultMeshRealtimeTransportConnector { - private readonly options: CultMeshQuicRealtimeConnectorOptions; - - constructor(options: CultMeshQuicRealtimeConnectorOptions = {}) { - this.options = options; - } - - readonly connectorId = "msquic-realtime"; - readonly priority = 0; - - canConnect(candidate: CultMeshRealtimeCandidate): boolean { - try { - parseQuicRealtimeEndpoint(candidate.endpoint); - return true; - } catch { - return false; - } - } - - async connect( - candidate: CultMeshRealtimeCandidate, - target: CultMeshRealtimeTarget, - signal?: AbortSignal, - ): Promise { - if (signal?.aborted) { - throw new Error("CultMesh QUIC connect aborted."); - } - const { host, port, certificateSha256 } = parseQuicRealtimeEndpoint(candidate.endpoint); - const runtime = await CultMeshQuicNativeRuntime.open(); - let connectionId: bigint; - try { - connectionId = runtime.connectionOpen(host, port); - } catch (error) { - await runtime.release(); - throw error; - } - - const handshakeTimeoutMs = this.options.handshakeTimeoutMs ?? 10_000; - const validator = this.options.validateProviderCertificate; - - return await new Promise((resolve, reject) => { - let settled = false; - - // Every failure path below — an already-aborted signal, the handshake - // timeout, a later abort, and any handshake-time error — settles here - // exactly once: shut the native connection down, drop the runtime - // reference, and reject. - const fail = (error: Error): void => { - if (settled) return; - settled = true; - clearTimeout(timer); - signal?.removeEventListener("abort", onAbort); - runtime.offConnectionEvent(connectionId); - runtime.connectionShutdown(connectionId, CULTMESH_REALTIME_CONNECTION_CLOSE_CODE); - void runtime.release(); - reject(error); - }; - - const succeed = (transport: CultMeshRealtimeTransport): void => { - if (settled) return; - settled = true; - clearTimeout(timer); - signal?.removeEventListener("abort", onAbort); - resolve(transport); - }; - - // Honour a signal already aborted by the time we reach here (it fired - // before `addEventListener` could observe it, so it never would). - if (signal?.aborted) { - fail(new Error("CultMesh QUIC connect aborted.")); - return; - } - - const timer = setTimeout( - () => fail(new Error(`CultMesh QUIC handshake with '${candidate.endpoint}' timed out.`)), - handshakeTimeoutMs, - ); - const onAbort = (): void => fail(new Error("CultMesh QUIC connect aborted.")); - signal?.addEventListener("abort", onAbort, { once: true }); - - // Told by the runtime when this connection faults mid-dispatch (a - // throwing validator during the handshake, or a malformed frame / - // stream-kind mismatch afterwards): reject the still-pending connect, - // or hand the fault to the connected transport. - const onFault = (error: Error): void => { - if (!settled) { - fail(error); - return; - } - transport.fault(error); - }; - - const transport = new CultMeshQuicRealtimeTransport( - candidate.endpoint, - runtime, - connectionId, - target, - candidate.generation, - ); - - runtime.onConnectionEvent( - connectionId, - (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED) { - const der = event.payload; - const accepted = validator - ? validator(target, der) - : certificateSha256 !== undefined && - certificateSha256Hex(der).toLowerCase() === certificateSha256.toLowerCase(); - try { - runtime.connectionCertificateComplete(connectionId, accepted); - } catch (error) { - fail(error instanceof Error ? error : new Error(String(error))); - return; - } - if (!accepted) { - fail(new Error(`CultMesh QUIC provider certificate for '${candidate.endpoint}' was rejected.`)); - } - return; - } - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN && !settled) { - const reason = Buffer.from(event.payload).toString("utf8"); - fail(new Error(`CultMesh QUIC connection closed during handshake: ${reason || event.code}`)); - return; - } - transport.handleConnectionEvent(event); - if (!settled && event.type === CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED) { - succeed(transport); - } - }, - onFault, - ); - }); - } -} - -/** - * `CultMeshQuicRealtimeTransport`, over the native v2 bridge. `TransportId` - * is `"msquic-realtime"`. - */ -export class CultMeshQuicRealtimeTransport implements CultMeshRealtimeTransport { - readonly transportId = "msquic-realtime"; - readonly endpoint: string; - - private readonly runtime: CultMeshQuicNativeRuntime; - private readonly connectionId: bigint; - private readonly target: CultMeshRealtimeTarget; - private readonly routeGeneration: string; - /** Serializes writes to the reliable-ordered outbound stream: each send chains onto this tail. */ - private reliableSendTail: Promise = Promise.resolve(); - private readonly pendingSends = new Map(); - /** Peer-opened stream id to its declared kind, pruned on `STREAM_SHUTDOWN`; see `trackedStreamCount`. */ - private readonly streamKinds = new Map(); - /** Generation staleness filter: the newest `(channel, body)` generation delivered so far. */ - private readonly latestGenerations = new Map(); - /** Inbound frame queue: bounded to one pending latest-only frame per key. */ - private readonly inbox = new CultMeshRealtimeInbox(); - private reliableOutboundStreamId: bigint | undefined; - private disposed = false; - private terminalError: Error | undefined; - private readonly disposalHandlers = new Set<() => void>(); - - constructor( - endpoint: string, - runtime: CultMeshQuicNativeRuntime, - connectionId: bigint, - target: CultMeshRealtimeTarget, - routeGeneration: string, - ) { - this.endpoint = endpoint; - this.runtime = runtime; - this.connectionId = connectionId; - this.target = target; - this.routeGeneration = routeGeneration ?? ""; - } - - isVerifiedFor( - verseId: string, - authorityRuntimeId: string, - protocolId: string, - routeGeneration: string, - ): boolean { - return ( - this.target.verseId === verseId && - this.target.authorityRuntimeId === authorityRuntimeId && - CULTMESH_REALTIME_STATE_PROTOCOL_ID === protocolId && - this.routeGeneration === routeGeneration - ); - } - - /** Number of peer-opened streams still tracked for their kind. Test-visible: proves `STREAM_SHUTDOWN` prunes `streamKinds` instead of leaking one entry per stream for the life of the connection. */ - get trackedStreamCount(): number { - return this.streamKinds.size; - } - - async sendFrame(frame: CultMeshRealtimeFrame): Promise { - if (this.disposed) throw new Error("CultMesh QUIC realtime transport is disposed."); - if (frame.delivery === "unreliable") { - throw new Error(CULTMESH_QUIC_UNRELIABLE_UNSUPPORTED_MESSAGE); - } - return this.sendEncodedFrame(frame.delivery, encodeRealtimeFrame(frame)); - } - - /** - * @internal The primitive `sendFrame` itself calls, after encoding. Exposed - * so a caller that already holds the encoded bytes for many peers at once - * — `CultMeshQuicRealtimeProvider.broadcast` fanning a frame out to every - * peer, and each peer's `CultMeshQuicRealtimeProviderOutbox` pump — sends - * them without re-encoding (and re-validating) per peer. - */ - async sendEncodedFrame(delivery: "reliable-ordered" | "latest-only", encoded: Uint8Array): Promise { - if (this.disposed) throw new Error("CultMesh QUIC realtime transport is disposed."); - if (delivery === "reliable-ordered") { - const send = this.reliableSendTail.then(async () => { - if (this.reliableOutboundStreamId === undefined) { - this.reliableOutboundStreamId = this.runtime.streamOpen( - this.connectionId, - CULTMESH_QUIC_STREAM_RELIABLE, - ); - } - await this.sendOnStream(this.reliableOutboundStreamId, encoded, false); - }); - // The tail must advance even if this send rejects, so the next queued - // send is not blocked forever on a settled promise; the caller still - // observes the rejection through `send` itself. - this.reliableSendTail = send.catch(() => {}); - return send; - } - // latest-only: a fresh stream per send, mirroring the C# reference. - const streamId = this.runtime.streamOpen(this.connectionId, CULTMESH_QUIC_STREAM_LATEST_ONLY); - await this.sendOnStream(streamId, encoded, true); - } - - /** - * A pending send registered after `cleanup()` already ran (a `sendFrame` - * queued behind `reliableSendTail` whose microtask lands after `dispose()` - * or a fault settles this transport) would otherwise sit in `pendingSends` - * forever: `cleanup()`'s own reject sweep already ran once and is guarded - * against running again, and `offConnectionEvent` means no later native - * event can resolve it either. Checking `this.disposed` here closes that - * window: any send that loses the race against disposal rejects - * immediately instead of registering an entry nothing will ever settle. - */ - private sendOnStream(streamId: bigint, encoded: Uint8Array, fin: boolean): Promise { - return new Promise((resolve, reject) => { - if (this.disposed) { - reject(this.terminalError ?? new Error("CultMesh QUIC realtime transport is disposed.")); - return; - } - this.pendingSends.set(streamId, { resolve, reject }); - try { - this.runtime.streamSendFrame(streamId, encoded, fin); - } catch (error) { - this.pendingSends.delete(streamId); - reject(error instanceof Error ? error : new Error(String(error))); - } - }); - } - - async receiveFrame(signal?: AbortSignal): Promise { - return this.inbox.receive(signal); - } - - /** Registers a handler invoked once, when this transport becomes unusable. */ - onDisposed(handler: () => void): void { - if (this.disposed) { - handler(); - return; - } - this.disposalHandlers.add(handler); - } - - dispose(): void { - if (this.disposed) return; - try { - this.runtime.connectionShutdown(this.connectionId, CULTMESH_REALTIME_CONNECTION_CLOSE_CODE); - } catch { - // Best-effort: the connection may already be gone. - } - this.cleanup(); - } - - /** - * @internal Called by the connector when the native runtime faults this - * connection mid-dispatch (a malformed frame, a stream-kind mismatch, or a - * throwing caller callback). Mirrors the C# reference's - * `_received.Complete(error)` / `_shutdown.Cancel()`: pending and future - * `receiveFrame` calls reject with `error`, and the connection is torn - * down. The native side has already shut the connection down and removed - * its listener by the time this runs. - */ - fault(error: Error): void { - this.cleanup(error); - } - - /** - * Runs exactly once, however the transport becomes unusable: explicit - * `dispose()`, a peer-initiated `CONNECTION_SHUTDOWN`, or `fault()`. - * Releases the runtime reference before running any `onDisposed` handler, - * so a handler that throws (or blocks) can never delay or skip the - * release; every handler runs in its own try/catch, so one throwing - * handler cannot stop the rest from running. Also rejects every pending - * and future receive/send, so none of those paths can leak the reference - * or hang a waiter forever. - */ - private cleanup(error?: Error): void { - if (this.disposed) return; - this.disposed = true; - this.terminalError = error; - this.runtime.offConnectionEvent(this.connectionId); - const rejection = error ?? new Error("CultMesh QUIC realtime transport is disposed."); - for (const [, pending] of this.pendingSends) pending.reject(rejection); - this.pendingSends.clear(); - this.inbox.complete(rejection); - void this.runtime.release(); - const handlers = [...this.disposalHandlers]; - this.disposalHandlers.clear(); - for (const handler of handlers) { - try { - handler(); - } catch (handlerError) { - // eslint-disable-next-line no-console - console.error("CultMesh QUIC realtime transport onDisposed handler threw:", handlerError); - } - } - } - - /** @internal Routed here by the connector's connection-event registration. */ - handleConnectionEvent(event: CultMeshQuicNativeEvent): void { - switch (event.type) { - case CULTMESH_QUIC_EVENT_STREAM_STARTED: - this.streamKinds.set(event.streamId, event.streamKind); - return; - case CULTMESH_QUIC_EVENT_STREAM_FRAME: - this.onStreamFrame(event); - return; - case CULTMESH_QUIC_EVENT_STREAM_SHUTDOWN: - this.streamKinds.delete(event.streamId); - return; - case CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE: { - const pending = this.pendingSends.get(event.streamId); - if (!pending) return; - this.pendingSends.delete(event.streamId); - if (event.code === BigInt(CULTMESH_QUIC_SEND_CANCELED)) { - pending.reject(new Error("CultMesh QUIC send was canceled.")); - } else { - pending.resolve(); - } - return; - } - case CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN: - this.cleanup(new Error("CultMesh QUIC connection was closed by the remote peer.")); - return; - default: - return; - } - } - - /** - * `ReadStreamAsync`'s stream-kind/delivery consistency check (`:519-524`). - * Throwing here is intentional: the native runtime's dispatch loop (fix 1) - * catches it, faults only this connection, and keeps the pump and every - * other connection running. - */ - private onStreamFrame(event: CultMeshQuicNativeEvent): void { - const kind = this.streamKinds.get(event.streamId); - const frame = decodeRealtimeFrame(event.payload); - if (kind === CULTMESH_QUIC_STREAM_RELIABLE && frame.delivery !== "reliable-ordered") { - throw new Error("Reliable QUIC stream carried incompatible delivery semantics."); - } - if (kind === CULTMESH_QUIC_STREAM_LATEST_ONLY && frame.delivery !== "latest-only") { - throw new Error("Latest-only QUIC stream carried incompatible delivery semantics."); - } - this.publishReceived(frame); - } - - /** - * `PublishReceived`'s per-`(channel, body)` generation filter (`:538-560`), - * plus the inbox's own coalescing: a latest-only frame overwrites the - * still-pending frame for its key rather than queuing beside it, so an - * unread backlog holds at most one frame per `(channel, body)`. - * Reliable-ordered frames queue directly, unbounded, exactly as the C# - * reference's unbounded channel does. - */ - private publishReceived(frame: CultMeshRealtimeFrame): void { - if (frame.delivery === "latest-only") { - const key = frame.channelId + "\u001f" + frame.bodyId; - const candidate: LatestGeneration = { producerEpoch: frame.producerEpoch, sequence: frame.sequence }; - const current = this.latestGenerations.get(key); - if (current && compareGeneration(candidate, current) <= 0) return; - this.latestGenerations.set(key, candidate); - this.inbox.publish(frame, key); - return; - } - this.inbox.publish(frame); - } -} - -/** - * `TryPublishLatest` plus `SendPublishedFramesAsync` (`:363-367`, `:421-439`), - * over a coalescing outbox (`:572-618`). Owns one peer's outbound - * `latest-only` traffic: `publish` never blocks (it just replaces whatever is - * still pending for the frame's `(channel, body)` key and, if a pump is not - * already draining, starts one), and the pump opens a fresh kind-2 stream per - * frame through the peer's own `sendFrame` (unchanged from the consumer path - * above), sending with `fin` and waiting for `send_complete` before it takes - * the next ready key. A stalled peer therefore accumulates at most one - * pending frame per key and never blocks a caller's `broadcast`. A send - * failure evicts the peer once, the same way a reliable-ordered send failure - * does in `CultMeshQuicRealtimeProvider.broadcast`. - */ -interface OutboxEntry { - readonly frame: CultMeshRealtimeFrame; - readonly encoded: Uint8Array; -} - -class CultMeshQuicRealtimeProviderOutbox { - private readonly inbox = new CultMeshRealtimeInbox(); - private readonly transport: CultMeshQuicRealtimeTransport; - private readonly onSendFailure: (error: Error) => void; - private pumping = false; - private disposed = false; - - constructor(transport: CultMeshQuicRealtimeTransport, onSendFailure: (error: Error) => void) { - this.transport = transport; - this.onSendFailure = onSendFailure; - } - - /** - * Enqueues an already-encoded `frame`, coalescing on `(channelId, - * bodyId)`. Never blocks. Takes the encoded bytes rather than encoding its - * own copy so every peer's outbox reuses the one encode `broadcast` (or a - * retained-frame seed) already did for this frame. - */ - publish(frame: CultMeshRealtimeFrame, encoded: Uint8Array): void { - if (this.disposed) return; - const key = frame.channelId + "\u001f" + frame.bodyId; - this.inbox.publish({ frame, encoded }, key); - if (!this.pumping) void this.pump(); - } - - dispose(): void { - this.disposed = true; - this.inbox.complete(); - } - - /** One in flight per peer: the next ready key is taken only after `send_complete`, mirroring `SendPublishedFramesAsync`. */ - private async pump(): Promise { - this.pumping = true; - try { - for (;;) { - if (this.disposed) return; - let entry: OutboxEntry; - try { - entry = await this.inbox.receive(); - } catch { - return; - } - try { - await this.transport.sendEncodedFrame("latest-only", entry.encoded); - } catch (error) { - this.dispose(); - this.onSendFailure(error instanceof Error ? error : new Error(String(error))); - return; - } - } - } finally { - this.pumping = false; - } - } -} - -/** Stable placeholder target for a provider's accepted peer connections: `isVerifiedFor` is a consumer-side concept the provider never calls. */ -const CULTMESH_PROVIDER_PEER_TARGET: CultMeshRealtimeTarget = { verseId: "", authorityRuntimeId: "" }; - -/** Configures a `CultMeshQuicRealtimeProvider` listener. */ -export interface CultMeshQuicRealtimeProviderOptions { - readonly host: string; - readonly port: number; - readonly serverCertificate: { readonly pkcs12: Uint8Array; readonly password?: string }; - readonly handshakeTimeoutMs?: number; - /** - * The host advertised in `advertisedEndpoint`, when it differs from the - * bind address `host` — the usual case for a public service: `host` is - * typically `0.0.0.0`, an empty string, or an IPv6 wildcard (`::`), none of - * which describe a route a client can dial, and the native listener (which - * `host` also configures) only accepts IP addresses in the first place, not - * a DNS name. Defaults to `host`. - */ - readonly advertisedHost?: string; - /** - * When `false` (the default: every existing caller, test, and interop - * peer calls `receive()`), the provider fans client-originated streams - * into `receive()` as before. When `true`, the provider is publish-only: - * any stream a peer opens faults that connection at `STREAM_STARTED`, - * before a frame can be decoded or queued, so no inbox, generation-map, - * or fan-in entry is ever created for client data; `receive()` itself - * rejects. StreamPixels sets this explicitly — it closes the unbounded - * per-client memory growth Soul's probe found. - */ - readonly acceptClientFrames?: boolean; - /** - * Refuses a new connection at accept once the number of connections this - * provider is tracking (including mid-handshake ones) has reached this - * many: shut down immediately, before any transport, outbox, or - * retained-frame seeding is allocated for it. Existing peers are - * unaffected. Defaults to 1024 — far more than any single StreamPixels - * fan-out needs today, while still bounding per-connection overhead - * against a public UDP port whose pin authenticates only the server, so - * any internet client can dial in. StreamPixels sets its own value. - */ - readonly maxConnections?: number; -} - -/** - * Brackets an IPv6 literal for use in a URL authority (`[::1]:443`), the way - * `URL` itself renders one; a hostname or IPv4 literal passes through - * unchanged, and an already-bracketed literal is left alone. - */ -function formatEndpointHost(host: string): string { - if (host.startsWith("[")) return host; - return host.includes(":") ? `[${host}]` : host; -} - -/** - * Recovers the leaf certificate's DER bytes from a PKCS12 credential, to - * compute the pin a provider advertises. Node has no public PKCS12 decoder; - * `tls.createSecureContext` loads the PKCS12 through OpenSSL, and its - * internal `context.getCertificate()` is the only way to read back the DER - * bytes OpenSSL parsed out of it. Probed against the pinned Node 24 build and - * this package's own test fixture pair (`test/fixtures/quic-test.p12` and - * `quic-test-cert.der`, generated independently by `openssl pkcs12 -export`): - * the returned buffer is byte-identical to the `.der` file and its SHA-256 - * matches the pin the fixture's tests already assert. - */ -function extractLeafCertificateDer(serverCertificate: CultMeshQuicRealtimeProviderOptions["serverCertificate"]): Uint8Array { - const context = createSecureContext({ - pfx: Buffer.from(serverCertificate.pkcs12), - passphrase: serverCertificate.password ?? "", - }) as unknown as { context: { getCertificate(): Buffer | undefined } }; - const der = context.context.getCertificate(); - if (!der || der.length === 0) { - throw new Error("CultMesh QUIC provider certificate has no parseable leaf certificate."); - } - return new Uint8Array(der); -} - -/** - * The StreamPixels role: a TypeScript listener that broadcasts with an - * explicit delivery mode and cannot be backpressured by a slow consumer. - * Rule for rule, this is `CultMeshQuicRealtimeServer` (`CultMeshQuicRealtimeTransport.cs:151-310`): - * `listen` opens a listener and computes the advertised endpoint; - * `broadcast` mirrors `BroadcastAsync` (`:216-235`); `receive` mirrors - * `ReceiveAsync` fanned in from every accepted peer's inbox - * (`CultMeshRealtimeInbox.ReceiveAsync`, `:597-609`); peers are evicted on - * send failure or shutdown, and there is no reconnect logic here, matching - * the C# reference's `AcceptLoopAsync` (`:276-309`). - */ -export class CultMeshQuicRealtimeProvider { - /** `cultmesh-state+quic://:?cert-sha256=`, uppercase — the Unity connector requires the pin. */ - readonly advertisedEndpoint: string; - - private readonly runtime: CultMeshQuicNativeRuntime; - private readonly listenerId: bigint; - private readonly handshakeTimeoutMs: number; - private readonly peers = new Set(); - private readonly outboxes = new Map(); - /** The newest `latest-only` frame broadcast so far per `(channel, body)` key, already - * encoded, seeded into every peer attached after that broadcast. Reliable-ordered frames - * are events, not state, and are never retained. */ - private readonly retained = new Map(); - /** Client-to-provider fan-in, bounded the same way as the transport's inbound queue. */ - private readonly received = new CultMeshRealtimeInbox(); - /** - * Every transport `acceptConnection` has created for a still-live native - * connection, whether or not its handshake has reached CONNECTED and - * joined `peers` yet. A connection whose handshake never reaches CONNECTED - * (a rejected certificate, a stalled client) would otherwise sit on its - * own handshake timer — and hold a runtime reference — for up to - * `handshakeTimeoutMs` after the provider itself was disposed, keeping the - * process alive over a connection nothing can still reach; `dispose()` - * sweeps this set instead of only `peers` to close that gap. - */ - private readonly accepted = new Set(); - private readonly acceptClientFrames: boolean; - private readonly maxConnections: number; - private disposed = false; - - private constructor( - runtime: CultMeshQuicNativeRuntime, - listenerId: bigint, - advertisedEndpoint: string, - handshakeTimeoutMs: number, - acceptClientFrames: boolean, - maxConnections: number, - ) { - this.runtime = runtime; - this.listenerId = listenerId; - this.advertisedEndpoint = advertisedEndpoint; - this.handshakeTimeoutMs = handshakeTimeoutMs; - this.acceptClientFrames = acceptClientFrames; - this.maxConnections = maxConnections; - } - - /** Number of currently accepted peer connections. */ - get connectionCount(): number { - return this.peers.size; - } - - /** Frames fanned in from peers but not yet drained by `receive()`. Test-visible: proves the fan-in queue is bounded. */ - get receiveQueueSize(): number { - return this.received.size; - } - - static async listen(options: CultMeshQuicRealtimeProviderOptions): Promise { - const handshakeTimeoutMs = options.handshakeTimeoutMs ?? 10_000; - const der = extractLeafCertificateDer(options.serverCertificate); - const pinHex = certificateSha256Hex(der).toUpperCase(); - const bindHost = options.host && options.host.length > 0 ? options.host : "127.0.0.1"; - const advertisedHost = options.advertisedHost && options.advertisedHost.length > 0 ? options.advertisedHost : bindHost; - - const runtime = await CultMeshQuicNativeRuntime.open(); - let listenerId: bigint; - let boundPort: number; - try { - ({ listenerId, boundPort } = runtime.listenerOpen( - options.host || null, - options.port, - options.serverCertificate.pkcs12, - options.serverCertificate.password ?? null, - )); - } catch (error) { - await runtime.release(); - throw error; - } - - const advertisedEndpoint = `${CULTMESH_QUIC_REALTIME_SCHEME}://${formatEndpointHost(advertisedHost)}:${boundPort}?cert-sha256=${pinHex}`; - const provider = new CultMeshQuicRealtimeProvider( - runtime, - listenerId, - advertisedEndpoint, - handshakeTimeoutMs, - options.acceptClientFrames ?? true, - options.maxConnections ?? 1024, - ); - runtime.onListenerEvent(listenerId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) provider.acceptConnection(event.connectionId); - }); - return provider; - } - - /** - * `BroadcastAsync` (`:216-235`). `latest-only` enqueues into each peer's - * outbox and returns as soon as every peer has accepted the frame into its - * outbox — never once any peer's I/O. `reliable-ordered` awaits every - * peer's `send_complete` (or eviction) before resolving, matching - * `Task.WhenAll` over `SendToConnectedClientAsync` (`:233-255`). - */ - async broadcast(frame: CultMeshRealtimeFrame): Promise { - if (this.disposed) throw new Error("CultMesh QUIC realtime provider is disposed."); - if (frame.delivery === "unreliable") { - throw new Error(CULTMESH_QUIC_UNRELIABLE_UNSUPPORTED_MESSAGE); - } - // Encode (and validate) exactly once, up front: an invalid frame throws - // here, to the caller, before touching any peer. The old per-peer encode - // inside `sendFrame` meant an invalid frame failed identically for every - // peer in turn, evicting all of them while `broadcast` itself still - // reported success. - const encoded = encodeRealtimeFrame(frame); - if (frame.delivery === "latest-only") { - const key = frame.channelId + "\u001f" + frame.bodyId; - const current = this.retained.get(key); - const candidate: LatestGeneration = { producerEpoch: frame.producerEpoch, sequence: frame.sequence }; - if (!current || compareGeneration(candidate, current.generation) > 0) { - this.retained.set(key, { frame, encoded, generation: candidate }); - } - for (const outbox of this.outboxes.values()) outbox.publish(frame, encoded); - return; - } - const sends = [...this.peers].map(async (transport) => { - try { - await transport.sendEncodedFrame("reliable-ordered", encoded); - } catch { - transport.dispose(); - } - }); - if (sends.length > 0) await Promise.all(sends); - } - - /** The next client-originated frame, fanned in from every accepted peer. */ - async receive(signal?: AbortSignal): Promise { - if (!this.acceptClientFrames) { - throw new Error( - "CultMesh QUIC realtime provider is publish-only (acceptClientFrames: false); it never accepts client frames.", - ); - } - return this.received.receive(signal); - } - - dispose(): void { - if (this.disposed) return; - this.disposed = true; - try { - this.runtime.listenerClose(this.listenerId); - } catch { - // Best-effort: the listener may already be gone. - } - // `accepted` is every transport this provider ever created for a native - // connection, from the moment `acceptConnection` synchronously builds - // it — whether or not its handshake ever reached CONNECTED and joined - // `peers`. A still-handshaking connection has no other owner to sweep it. - for (const transport of [...this.accepted]) transport.dispose(); - this.received.complete(new Error("CultMesh QUIC realtime provider is disposed.")); - void this.runtime.release(); - } - - /** Coalesces client-sent `latest-only` frames by `(channel, body)`, so a publish-only `receive()` caller (StreamPixels) backs up to at most one pending frame per key. */ - private async pumpReceivedFrom(transport: CultMeshQuicRealtimeTransport): Promise { - for (;;) { - let frame: CultMeshRealtimeFrame; - try { - frame = await transport.receiveFrame(); - } catch { - return; // The transport is disposed/faulted; nothing more to read. - } - if (frame.delivery === "latest-only") { - this.received.publish(frame, frame.channelId + "\u001f" + frame.bodyId); - } else { - this.received.publish(frame); - } - } - } - - /** - * Handles `LISTENER_NEW_CONNECTION`, fully synchronously: one handler owns - * this connection from this point on, so there is no async window in which - * a NEW_CONNECTION-then-CONNECTED pair (the bridge's own event order, - * `native/GameCult.Mesh.Quic.Native/cultmesh_quic_native.cpp:731-757,627`) - * can be split across a temporary buffering handler and a later real one. - * `this.runtime.retain()` takes a reference on the provider's own - * already-open runtime instead of `await`ing a fresh - * `CultMeshQuicNativeRuntime.open()`, which is what used to force that - * split: the previous async gap left `CONNECTION_CONNECTED` dispatched - * straight to `transport.handleConnectionEvent` (which has no case for - * it) with nothing to clear the handshake timer, so a healthy peer was - * evicted at `handshakeTimeoutMs` regardless of how well-behaved the - * client was. - */ - private acceptConnection(connectionId: bigint): void { - if (this.disposed) { - this.runtime.connectionShutdown(connectionId, CULTMESH_REALTIME_CONNECTION_CLOSE_CODE); - return; - } - if (this.accepted.size >= this.maxConnections) { - // Refused before any transport, timer, or outbox exists for it: - // existing accepted connections are untouched. - this.runtime.connectionShutdown(connectionId, CULTMESH_REALTIME_CONNECTION_CLOSE_CODE); - return; - } - - const transport = new CultMeshQuicRealtimeTransport( - `quic-peer-${connectionId}`, - this.runtime.retain(), - connectionId, - CULTMESH_PROVIDER_PEER_TARGET, - "", - ); - this.accepted.add(transport); - - const handshakeTimer = setTimeout(() => transport.dispose(), this.handshakeTimeoutMs); - transport.onDisposed(() => { - clearTimeout(handshakeTimer); - this.accepted.delete(transport); - this.peers.delete(transport); - this.outboxes.get(transport)?.dispose(); - this.outboxes.delete(transport); - }); - - // CONNECTED fires at most once per connection; `attached` guards against - // ever running the join-`peers` bookkeeping twice. - let attached = false; - this.runtime.onConnectionEvent( - connectionId, - (event) => { - // Publish-only: a peer-opened stream faults this connection alone, - // before `handleConnectionEvent` can record its stream kind or - // decode a frame off it. Throwing here drives the dispatch loop's - // own fault path (`CultMeshQuicNativeRuntime.dispatch`), which - // shuts the connection down and evicts it. - if (!this.acceptClientFrames && event.type === CULTMESH_QUIC_EVENT_STREAM_STARTED) { - throw new Error( - "CultMesh QUIC provider is publish-only (acceptClientFrames: false); it does not accept inbound streams from peers.", - ); - } - transport.handleConnectionEvent(event); - if (attached || event.type !== CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED) return; - attached = true; - clearTimeout(handshakeTimer); - // Cut C's retained-frame seeding happens atomically here, before the - // peer joins `peers`: nothing can observe this transport as an - // attached peer with a not-yet-seeded outbox. - const outbox = new CultMeshQuicRealtimeProviderOutbox(transport, () => transport.dispose()); - for (const { frame, encoded } of this.retained.values()) outbox.publish(frame, encoded); - this.outboxes.set(transport, outbox); - this.peers.add(transport); - if (this.acceptClientFrames) void this.pumpReceivedFrom(transport); - }, - (error) => transport.fault(error), - ); - } -} - -/** `CultMeshStaticRealtimeLookupSource`: an array of pre-resolved Verse descriptors. */ -export class CultMeshStaticRealtimeLookupSource implements ICultMeshRealtimeLookupSource { - private readonly verses: readonly CultMeshVerseDescriptorMessage[]; - - constructor(verses: readonly CultMeshVerseDescriptorMessage[]) { - this.verses = verses; - } - - async resolve(target: CultMeshRealtimeTarget): Promise { - return this.verses.filter((verse) => verse.verseId === target.verseId); - } -} - -/** Options for `CultMeshQuicRealtimeSessionManager`. */ -export interface CultMeshQuicRealtimeSessionManagerOptions { - readonly lookupSource: ICultMeshRealtimeLookupSource; - readonly trust: CultMeshAuthorityTrustPolicy; - readonly connectors: readonly CultMeshRealtimeTransportConnector[]; - readonly maxRacedCandidates?: number; -} - -/** - * Binds an advertised route to a connected, authority-verified realtime - * transport. Rule for rule, this is `CultMeshSessionManager`'s realtime path - * in the C# reference (`ConnectRealtimeAsync`, `:833-896`). - */ -export class CultMeshQuicRealtimeSessionManager { - private readonly options: CultMeshQuicRealtimeSessionManagerOptions; - private readonly sessions = new Map(); - /** Single-flight: concurrent `connect()` calls for the same key share one dial. */ - private readonly connecting = new Map>(); - /** One controller per in-flight dial, so `dispose()` and `disconnect()` can cancel it. */ - private readonly dialAborts = new Map(); - private disposed = false; - - constructor(options: CultMeshQuicRealtimeSessionManagerOptions) { - if (options.connectors.length === 0) { - throw new Error("CultMeshQuicRealtimeSessionManager requires at least one realtime connector."); - } - if ((options.maxRacedCandidates ?? 2) <= 0) { - throw new Error("maxRacedCandidates must be positive."); - } - this.options = options; - } - - private sessionKey(target: CultMeshRealtimeTarget): string { - return target.verseId + "\u001f" + target.authorityRuntimeId; - } - - /** - * Resolves, verifies, races and connects; disposes losing candidates. - * Returns the cached session for `target` when one is live. Concurrent - * calls for the same target share one dial (mirrors C#'s `Lazy`); a - * transport that dies later (peer shutdown, an internal fault, or explicit - * disposal) evicts itself from the cache so the next call redials, mirroring - * `CultMeshSessions.InvalidateRealtimeSession` (`:898-913`). - */ - async connect(target: CultMeshRealtimeTarget): Promise { - if (this.disposed) throw new Error("CultMeshQuicRealtimeSessionManager is disposed."); - const key = this.sessionKey(target); - const existing = this.sessions.get(key); - if (existing) return existing; - - const inFlight = this.connecting.get(key); - if (inFlight) return inFlight; - - const controller = new AbortController(); - this.dialAborts.set(key, controller); - const attempt = this.connectOwnedAsync(key, target, controller.signal).finally(() => { - this.connecting.delete(key); - if (this.dialAborts.get(key) === controller) this.dialAborts.delete(key); - }); - this.connecting.set(key, attempt); - return attempt; - } - - private async connectOwnedAsync( - key: string, - target: CultMeshRealtimeTarget, - signal: AbortSignal, - ): Promise { - const transport = await this.dialAsync(key, target, signal); - if (this.disposed || signal.aborted) { - transport.dispose(); - throw new Error( - this.disposed - ? "CultMeshQuicRealtimeSessionManager was disposed while connecting." - : `Dial for '${key}' was cancelled while connecting.`, - ); - } - this.sessions.set(key, transport); - transport.onDisposed?.(() => { - if (this.sessions.get(key) === transport) this.sessions.delete(key); - }); - return transport; - } - - private async dialAsync( - key: string, - target: CultMeshRealtimeTarget, - signal: AbortSignal, - ): Promise { - const verses = await this.options.lookupSource.resolve(target); - const routes = verses - .flatMap((verse) => verse.authorityRoutes ?? []) - .filter((route) => route.authorityRuntimeId === target.authorityRuntimeId) - .filter((route) => route.protocolIds.includes(CULTMESH_REALTIME_STATE_PROTOCOL_ID)); - if (routes.length === 0) { - throw new Error(`No realtime state route was advertised for '${key}'.`); - } - - const verifiedCandidates: CultMeshRealtimeCandidate[] = []; - const verificationFailures: Error[] = []; - for (const route of routes) { - const candidate: CultMeshRealtimeCandidate = { - endpoint: route.endpoint, - authorityRuntimeId: route.authorityRuntimeId, - priority: route.priority, - generation: trimCSharp(route.generation), - }; - try { - await verifyAuthorityRoute( - { - verseId: target.verseId, - authorityRuntimeId: route.authorityRuntimeId, - endpoint: route.endpoint, - protocolIds: route.protocolIds, - priority: route.priority, - generation: route.generation, - certificate: routeCertificateView(route.certificate), - }, - this.options.trust, - ); - verifiedCandidates.push(candidate); - } catch (error) { - verificationFailures.push(error instanceof Error ? error : new Error(String(error))); - } - } - if (verifiedCandidates.length === 0) { - throw new Error( - `No trusted realtime route remained for '${key}': ${verificationFailures.map((error) => error.message).join("; ")}`, - ); - } - - const tiers = new Map>(); - for (const candidate of verifiedCandidates) { - for (const connector of this.options.connectors) { - if (!connector.canConnect(candidate)) continue; - const tier = connector.priority; - const list = tiers.get(tier) ?? []; - list.push({ candidate, connector }); - tiers.set(tier, list); - } - } - if (tiers.size === 0) { - throw new Error(`No realtime connector supports an advertised route for '${key}'.`); - } - - const maxRaced = this.options.maxRacedCandidates ?? 2; - const failures: Error[] = []; - for (const tier of [...tiers.keys()].sort((a, b) => a - b)) { - if (signal.aborted) break; - const entries = [...(tiers.get(tier) ?? [])] - .sort((a, b) => a.candidate.priority - b.candidate.priority) - .slice(0, maxRaced); - const winner = await this.raceFirstSuccessAsync(key, target, entries, failures, signal); - if (winner) return winner; - } - throw new Error( - `No realtime state path connected for '${key}': ${failures.map((error) => error.message).join("; ")}`, - ); - } - - /** - * Races one tier's candidates and returns the first verified success, - * mirroring C#'s `Task.WhenAny` loop (`:851-866`): as soon as one candidate - * both connects and proves `isVerifiedFor`, the rest are aborted (an - * `AbortSignal` is threaded into `connector.connect`) and disposed once - * they settle, without blocking the return. `Promise.allSettled` here would - * instead wait out every candidate, including a dead route stalled on its - * own handshake timeout. - */ - private async raceFirstSuccessAsync( - key: string, - target: CultMeshRealtimeTarget, - entries: ReadonlyArray<{ candidate: CultMeshRealtimeCandidate; connector: CultMeshRealtimeTransportConnector }>, - failures: Error[], - outerSignal: AbortSignal, - ): Promise { - const controller = new AbortController(); - if (outerSignal.aborted) controller.abort(); - else outerSignal.addEventListener("abort", () => controller.abort(), { once: true }); - const pending = new Set( - entries.map((entry) => this.connectCandidateAsync(key, target, entry, controller.signal)), - ); - let winner: CultMeshRealtimeTransport | undefined; - while (pending.size > 0 && !winner) { - const settled = await Promise.race( - [...pending].map((attempt) => - attempt.then( - (value) => ({ attempt, ok: true as const, value }), - (error) => ({ attempt, ok: false as const, error }), - ), - ), - ); - pending.delete(settled.attempt); - if (settled.ok) { - winner = settled.value; - } else { - failures.push(settled.error instanceof Error ? settled.error : new Error(String(settled.error))); - } - } - if (!winner) return undefined; - - controller.abort(); - // The remaining candidates may already be in flight past the point an - // abort signal helps; dispose whatever they eventually produce, without - // blocking the winner's return. - for (const loser of pending) { - loser.then((transport) => transport.dispose()).catch(() => {}); - } - return winner; - } - - private async connectCandidateAsync( - key: string, - target: CultMeshRealtimeTarget, - entry: { candidate: CultMeshRealtimeCandidate; connector: CultMeshRealtimeTransportConnector }, - signal: AbortSignal, - ): Promise { - const transport = await entry.connector.connect(entry.candidate, target, signal); - if (!transport.isVerifiedFor(target.verseId, target.authorityRuntimeId, CULTMESH_REALTIME_STATE_PROTOCOL_ID, entry.candidate.generation)) { - transport.dispose(); - throw new Error(`Transport did not prove CultMesh authority for '${key}'.`); - } - return transport; - } - - /** - * Marks the session for `target` offline, disposing its transport. Also - * cancels a dial still in flight for `target`, so a connect racing this - * call cannot cache a transport this call meant to discard. - */ - disconnect(target: CultMeshRealtimeTarget): void { - const key = this.sessionKey(target); - const transport = this.sessions.get(key); - if (transport) { - this.sessions.delete(key); - transport.dispose(); - } - this.dialAborts.get(key)?.abort(); - } - - dispose(): void { - this.disposed = true; - for (const controller of this.dialAborts.values()) controller.abort(); - this.dialAborts.clear(); - for (const transport of this.sessions.values()) transport.dispose(); - this.sessions.clear(); - } -} diff --git a/packages/cultmesh-ts/src/realtime-wire.ts b/packages/cultmesh-ts/src/realtime-wire.ts deleted file mode 100644 index fa647133..00000000 --- a/packages/cultmesh-ts/src/realtime-wire.ts +++ /dev/null @@ -1,191 +0,0 @@ -// The one TypeScript encoding of a CultMesh realtime frame. -// -// Rule for rule, this is `CultMeshRealtimeWireProtocol` in the C# reference -// (`src/GameCult.Mesh/CultMeshRealtimeWireProtocol.cs`), over the frame shape -// `CultMeshRealtimeTransports.cs` defines. QUIC stream framing stays -// transport-owned; this file owns only the typed frame bytes and never touches -// a socket. -// -// Byte parity is proven both ways, cross-process, by two committed vector files -// under `contracts/cultmesh/`: `realtime-frame-vectors.json`, which the C# test -// `CultMeshRealtimeWireProtocolTests` writes under CULTMESH_WRITE_VECTORS=1 and -// this package's test decodes and re-encodes, and -// `realtime-frame-vectors.ts-written.json`, which -// `scripts/write-cultmesh-realtime-frame-vectors.mjs` writes with this codec and -// the same C# test decodes. A fixture authored on one side alone would only -// agree with itself. - -import { isNullOrWhiteSpaceCSharp } from "cultnet-ts"; - -/** `CultMeshRealtimeWireProtocol.ApplicationProtocolName`: the QUIC ALPN. */ -export const CULTMESH_REALTIME_ALPN = "cultmesh-state-v1"; - -/** `ConnectionCloseCode`: ASCII "CULT". A QUIC error code is 62-bit, so bigint. */ -export const CULTMESH_REALTIME_CONNECTION_CLOSE_CODE = 0x43554c54n; - -/** `StreamAbortCode`: ASCII "STAT". */ -export const CULTMESH_REALTIME_STREAM_ABORT_CODE = 0x53544154n; - -/** `ReliableStream`: the stream kind carrying `reliable-ordered`. */ -export const CULTMESH_REALTIME_RELIABLE_STREAM = 1; - -/** `LatestOnlyStream`: the stream kind carrying `latest-only`. */ -export const CULTMESH_REALTIME_LATEST_ONLY_STREAM = 2; - -/** `MaximumFrameBytes`: the payload ceiling, 64 MiB. */ -export const CULTMESH_REALTIME_MAX_PAYLOAD_BYTES = 64 * 1024 * 1024; - -/** `MaximumEncodedFrameBytes`: the payload ceiling plus the header and three maximal identities. */ -export const CULTMESH_REALTIME_MAX_ENCODED_FRAME_BYTES = - CULTMESH_REALTIME_MAX_PAYLOAD_BYTES + 37 + 3 * 0xffff; - -/** - * `CultMeshRealtimeDelivery`. The wire byte is the C# enum's ordinal, so the - * order of these three is the wire contract, not a naming choice. - */ -export type CultMeshRealtimeDelivery = "reliable-ordered" | "latest-only" | "unreliable"; - -const DELIVERY_BYTES: readonly CultMeshRealtimeDelivery[] = ["reliable-ordered", "latest-only", "unreliable"]; - -/** `CultMeshRealtimeFrame`. `producerEpoch` and `sequence` are `long` in C#, which exceeds `Number.MAX_SAFE_INTEGER`. */ -export interface CultMeshRealtimeFrame { - channelId: string; - schemaId: string; - bodyId: string; - producerEpoch: bigint; - sequence: bigint; - delivery: CultMeshRealtimeDelivery; - payload: Uint8Array; -} - -const MAGIC = 0x31545343; -const FIXED_HEADER_BYTES = 37; -const WIRE_VERSION = 1; -const MAX_IDENTITY_BYTES = 0xffff; -const INT64_MIN = -(2n ** 63n); -const INT64_MAX = 2n ** 63n - 1n; - -/** - * `CultMeshRealtimeFrame.Validate`. The C# reading of "non-empty" is - * `string.IsNullOrWhiteSpace`, whose whitespace set is not - * `String.prototype.trim`'s, so this borrows the one TypeScript implementation - * of that set from `cultnet-ts` rather than keeping a second reading here. - * - * The range check has no C# counterpart because `long` gives it for free; a - * `bigint` does not, and a `DataView` would otherwise throw a bare `RangeError` - * from inside the encoder. - */ -function validateFrame(frame: CultMeshRealtimeFrame): void { - if (isNullOrWhiteSpaceCSharp(frame.channelId)) throw new Error("Realtime channel identity is required."); - if (isNullOrWhiteSpaceCSharp(frame.schemaId)) throw new Error("Realtime schema identity is required."); - if (isNullOrWhiteSpaceCSharp(frame.bodyId)) throw new Error("Realtime body identity is required."); - if (frame.producerEpoch < 0n || frame.sequence < 0n) { - throw new Error("Realtime epoch and sequence must be non-negative."); - } - if (frame.producerEpoch > INT64_MAX || frame.sequence > INT64_MAX || frame.producerEpoch < INT64_MIN || frame.sequence < INT64_MIN) { - throw new Error("Realtime epoch and sequence must fit a 64-bit signed integer."); - } -} - -/** `CultMeshRealtimeWireProtocol.EncodeFrame`. */ -export function encodeRealtimeFrame(frame: CultMeshRealtimeFrame): Uint8Array { - validateFrame(frame); - const deliveryByte = DELIVERY_BYTES.indexOf(frame.delivery); - // C# reads an enum, which holds any byte; a TypeScript union does not, so the - // unspellable value is refused here with the message decode gives it. - if (deliveryByte < 0) throw new Error("Realtime frame delivery mode is invalid."); - const encoder = new TextEncoder(); - const channel = encoder.encode(frame.channelId); - const schema = encoder.encode(frame.schemaId); - const body = encoder.encode(frame.bodyId); - if (channel.byteLength > MAX_IDENTITY_BYTES || schema.byteLength > MAX_IDENTITY_BYTES || body.byteLength > MAX_IDENTITY_BYTES) { - throw new Error("Realtime frame identity exceeds the QUIC wire limit."); - } - if (frame.payload.byteLength > CULTMESH_REALTIME_MAX_PAYLOAD_BYTES) { - throw new Error("Realtime frame payload exceeds the QUIC wire limit."); - } - - const result = new Uint8Array( - FIXED_HEADER_BYTES + channel.byteLength + schema.byteLength + body.byteLength + frame.payload.byteLength, - ); - const view = new DataView(result.buffer); - view.setUint32(0, MAGIC, true); - result[4] = deliveryByte; - view.setBigInt64(5, frame.producerEpoch, true); - view.setBigInt64(13, frame.sequence, true); - view.setUint16(21, channel.byteLength, true); - view.setUint16(23, schema.byteLength, true); - view.setUint16(25, body.byteLength, true); - view.setInt32(27, frame.payload.byteLength, true); - view.setInt32(31, FIXED_HEADER_BYTES, true); - view.setUint16(35, WIRE_VERSION, true); - let offset = FIXED_HEADER_BYTES; - result.set(channel, offset); offset += channel.byteLength; - result.set(schema, offset); offset += schema.byteLength; - result.set(body, offset); offset += body.byteLength; - result.set(frame.payload, offset); - return result; -} - -/** - * `CultMeshRealtimeWireProtocol.DecodeFrame`, refusal for refusal and in the - * same order. Like the reference, it does not call `validateFrame`: a frame - * whose identities are blank decodes here exactly as it does in C#, and only - * encoding refuses it. - * - * One corner has no C# counterpart. The reference sums the lengths under - * `checked`, so a payload length near `int.MaxValue` throws `OverflowException` - * there rather than its length refusal; JavaScript numbers do not overflow, so - * the sum simply fails to match and the length refusal covers that case too. - * No encoder on either side can produce such a frame. - */ -export function decodeRealtimeFrame(bytes: Uint8Array): CultMeshRealtimeFrame { - if (bytes.byteLength < FIXED_HEADER_BYTES) throw new Error("Realtime frame header is truncated."); - const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); - if (view.getUint32(0, true) !== MAGIC) throw new Error("Realtime frame magic is invalid."); - if (view.getUint16(35, true) !== WIRE_VERSION || view.getInt32(31, true) !== FIXED_HEADER_BYTES) { - throw new Error("Realtime frame wire version is unsupported."); - } - const delivery = DELIVERY_BYTES[bytes[4]!]; - if (delivery === undefined) throw new Error("Realtime frame delivery mode is invalid."); - const channelLength = view.getUint16(21, true); - const schemaLength = view.getUint16(23, true); - const bodyLength = view.getUint16(25, true); - const payloadLength = view.getInt32(27, true); - const expected = FIXED_HEADER_BYTES + channelLength + schemaLength + bodyLength + payloadLength; - if (payloadLength < 0 || expected !== bytes.byteLength) throw new Error("Realtime frame length is invalid."); - // `Encoding.UTF8.GetString` substitutes U+FFFD for invalid bytes rather than - // throwing, which is what a non-fatal `TextDecoder` does. `ignoreBOM` is not - // cosmetic: by default `TextDecoder` *deletes* a leading U+FEFF, and - // `GetString` keeps it, so an identity starting with a byte-order mark would - // decode to a different string on the two sides. U+FEFF is not whitespace to - // .NET either, so such an identity passes the transport contract and reaches - // the wire. - const decoder = new TextDecoder("utf-8", { ignoreBOM: true }); - let offset = FIXED_HEADER_BYTES; - const channelId = decoder.decode(bytes.subarray(offset, offset + channelLength)); offset += channelLength; - const schemaId = decoder.decode(bytes.subarray(offset, offset + schemaLength)); offset += schemaLength; - const bodyId = decoder.decode(bytes.subarray(offset, offset + bodyLength)); offset += bodyLength; - return { - channelId, - schemaId, - bodyId, - producerEpoch: view.getBigInt64(5, true), - sequence: view.getBigInt64(13, true), - delivery, - // Not `bytes.slice(...)`. Node's `Buffer` overrides `slice` with an alias of - // `subarray`, so on a `Buffer` — which is what every socket read hands a Node - // caller — that spelling returns a *view* of the frame, and a decoded payload - // that changes when the frame buffer is reused. - // - // Nor `Uint8Array.prototype.slice.call(bytes, ...)`, which does bypass the - // override and copy, but takes its result constructor from `@@species`: on a - // `Buffer` that is `FastBuffer`, so the payload comes back a `Buffer` from a - // `Buffer` frame and a `Uint8Array` from a `Uint8Array` one. The declared - // type holds either way, but `deepStrictEqual` does not, so the same frame - // would compare equal or not depending on how it reached the decoder. - // - // The constructor copies and is the one type on both inputs. - payload: new Uint8Array(bytes.subarray(offset, offset + payloadLength)), - }; -} diff --git a/packages/cultmesh-ts/test/cultmesh.test.ts b/packages/cultmesh-ts/test/cultmesh.test.ts index 5ec961a5..16d51e1e 100644 --- a/packages/cultmesh-ts/test/cultmesh.test.ts +++ b/packages/cultmesh-ts/test/cultmesh.test.ts @@ -1,26 +1,18 @@ -import { createSocket } from "node:dgram"; import { mkdtemp } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import test from "node:test"; import assert from "node:assert/strict"; -import { decode, encode } from "@msgpack/msgpack"; +import { encode } from "@msgpack/msgpack"; import { z } from "zod"; import { defineDocumentType } from "@gamecult/cultcache-ts"; import { CultNetDocumentRegistry, CultNetPeer, - CultNetRudpSession, cultNetBuiltinSchemaRegistry, - decodeRudpPacket, defineCultNetDocumentBinding, - encodeRudpPacket, - type CultNetDocumentPutRawMessage, - type CultNetRudpPacket, - type CultNetMessage, - type CultNetSnapshotResponseRawMessage, } from "cultnet-ts"; -import { CultMesh, CultMeshRudpUnservableDocumentError } from "../src/index"; +import { CultMesh } from "../src/index"; const noteDocument = defineDocumentType({ type: "cultmesh.note", @@ -2508,20 +2500,16 @@ test("CultMesh TS branded facade exposes schema and shard catalogs", () => { const builtIns = CultMesh.createBuiltInSchemaCatalog(); assert.equal( - builtIns.get( - "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.shard-catalog-request.schema.json", - )?.schemaVersion, + builtIns.get("cultnet.shard_catalog_request.v0")?.schemaVersion, "cultnet.shard_catalog_request.v0", ); assert.equal( - builtIns.get( - "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.shard-catalog-response.schema.json", - )?.kind, + builtIns.get("cultnet.shard_catalog_response.v0")?.kind, "wire_message", ); assert.equal( builtIns.get( - "https://github.com/GameCult/CultLib/contracts/cultnet/cultnet.transport-profile.schema.json", + "https://github.com/GameCult/cultnet-ts/contracts/cultnet.transport-profile.schema.json", )?.schemaVersion, "cultnet.transport_profile.v0", ); @@ -2555,44 +2543,6 @@ test("CultMesh TS branded facade exposes schema and shard catalogs", () => { ); }); -async function rudpClientBoundHost(endpoint: string, bindHost?: string): Promise { - const client = await CultMesh.createRudpClient("cultmesh-ts-bind-client", 0x10203060, endpoint, { bindHost }); - try { - return client.profile.transports[0]?.host; - } finally { - client.close(); - } -} - -// A client bound to loopback cannot send to another host on Windows, so a -// client for a remote endpoint binds the unspecified address of its family. -test("CultMesh TS RUDP client for a remote endpoint binds the unspecified address", async () => { - assert.equal(await rudpClientBoundHost("rudp://10.77.0.1:17872"), "0.0.0.0"); - assert.equal(await rudpClientBoundHost("rudp://[2001:db8::1]:17872"), "::"); -}); - -test("CultMesh TS RUDP client for a loopback endpoint binds loopback", async () => { - assert.equal(await rudpClientBoundHost("rudp://127.0.0.1:17872"), "127.0.0.1"); - assert.equal(await rudpClientBoundHost("rudp://[::1]:17872"), "::1"); -}); - -test("CultMesh TS RUDP client binds an explicit bindHost whatever the endpoint", async () => { - assert.equal(await rudpClientBoundHost("rudp://10.77.0.1:17872", "127.0.0.1"), "127.0.0.1"); - assert.equal(await rudpClientBoundHost("rudp://127.0.0.1:17872", "0.0.0.0"), "0.0.0.0"); -}); - -test("CultMesh TS RUDP server binds loopback unless told otherwise", async () => { - const loopback = await CultMesh.createRudpServer("cultmesh-ts-bind-server", 0x10203061); - const any = await CultMesh.createRudpServer("cultmesh-ts-bind-server", 0x10203062, { bindHost: "0.0.0.0" }); - try { - assert.equal(loopback.profile.transports[0]?.host, "127.0.0.1"); - assert.equal(any.profile.transports[0]?.host, "0.0.0.0"); - } finally { - loopback.close(); - any.close(); - } -}); - test("CultMesh TS branded facade creates RUDP clients from peer endpoints", async () => { const connectionId = 0x10203044; const server = await CultMesh.createRudpServer( @@ -3269,493 +3219,6 @@ test("CultMesh TS negotiates streaming frame body transports explicitly", () => assert.deepEqual(frameUpdates, [42n]); }); -// A put the RUDP document server admits must be one it can serve. The server -// fragments its replies as its puts are reassembled, and refuses a put whose -// snapshot reply, carrying the document alone under the shortest message id, -// could never be sent within its limits. -type ServedBoundRig = { - server: ReturnType; - peer: CultNetPeer; - admitted: string[]; - errors: Error[]; - messages: CultNetMessage[]; - /** Why each frame the peer could not parse was refused. */ - unparsed: Error[]; -}; - -const servedBoundRegistry = () => - new CultNetDocumentRegistry([defineCultNetDocumentBinding({ definition: noteDocument })]); - -/** - * A put's own storedAt, kept by the served record and replaced in the receipt by the server's - * 24-character clock. `SERVED_STORED_AT` is long, so an echoed receipt is smaller than the served - * reply; `RECEIPT_STORED_AT` is short, so an echoed receipt is the larger reply, which shows that - * admission sizes only the served reply. - */ -const SERVED_STORED_AT = `2026-09-30T00:00:00.000Z${"~".repeat(200)}`; -const RECEIPT_STORED_AT = "2026-09-30T00:00:00.000Z"; -const SERVED_BOUND_SERVER = "cultmesh-ts-served-bound-server"; - -function notePut( - messageId: string, - recordKey: string, - bodyLength: number, - sourceRuntimeId?: string, - storedAt = SERVED_STORED_AT, -): CultNetDocumentPutRawMessage { - return { - schemaVersion: "cultnet.document_put_raw.v0", - messageId, - document: { - schemaId: "cultmesh.note.v0", - recordKey, - storedAt, - payloadEncoding: "messagepack", - payload: encode({ noteId: recordKey, body: "x".repeat(bodyLength) }), - ...(sourceRuntimeId ? { sourceRuntimeId } : {}), - }, - }; -} - -/** - * The encoded size of the reply that would serve this put's document alone, - * under the shortest message id: the record as a snapshot serves it, which - * keeps no source fields. - */ -function servedAloneBytes(put: CultNetDocumentPutRawMessage): number { - const { schemaId, recordKey, storedAt, payloadEncoding, payload } = put.document; - return encode({ - schemaVersion: "cultnet.snapshot_response_raw.v0", - messageId: "0", - documents: [{ schemaId, recordKey, storedAt, payloadEncoding, payload }], - }).byteLength; -} - -/** - * The encoded size of the receipt that would acknowledge this put by echoing its value: the - * put's message id, the server's clock and its default provenance. Spelled out here rather than - * asked of the server, so a server that sized another receipt is caught. - */ -function echoReceiptBytes(put: CultNetDocumentPutRawMessage): number { - return encode({ - schemaVersion: "cultnet.document_put_raw.v0", - messageId: put.messageId, - document: { - schemaId: "cultmesh.note.v0", - recordKey: put.document.recordKey, - storedAt: new Date().toISOString(), - payloadEncoding: "messagepack", - payload: encode(decode(put.document.payload)), - sourceRuntimeId: SERVED_BOUND_SERVER, - sourceAgentId: undefined, - sourceRole: "provider", - tags: ["receipt"], - }, - }).byteLength; -} - -/** The body length whose served-alone reply is exactly `bytes`. */ -function bodyLengthForReplyBytes(recordKey: string, bytes: number): number { - const probe = 8_000; - const length = probe + bytes - servedAloneBytes(notePut("p", recordKey, probe)); - const put = notePut("p", recordKey, length); - assert.equal(servedAloneBytes(put), bytes, "fixture: reply size is linear in the body"); - return length; -} - -async function withServedBoundRig( - connectionId: number, - serverLimits: { maxFragmentBytes?: number; maxPendingReliablePackets?: number; maxPayloadBytes?: number }, - body: (rig: ServedBoundRig) => Promise, - handler: { receipt?: "echo" | "oversized" } = {}, -): Promise { - const node = await CultMesh.startNode( - join(await mkdtemp(join(tmpdir(), "cultmesh-ts-served-bound-")), "node.ccmp"), - { documents: [noteDocument] }, - ); - const registry = servedBoundRegistry(); - const admitted: string[] = []; - const errors: Error[] = []; - const messages: CultNetMessage[] = []; - const unparsed: Error[] = []; - const server = CultMesh.createRudpDocumentServer(SERVED_BOUND_SERVER, connectionId, { - documents: registry, - getCache: () => node.cache, - bindHost: "127.0.0.1", - bindPort: 0, - resendDelayMs: 25, - resendPollMs: 5, - ...serverLimits, - // Stored as the registry stores a raw put, so the served record is the one it sizes. - onDocumentPutRaw: async (document) => { - admitted.push(document.recordKey); - await registry.applyRawDocumentPutMessage(node.cache, { - schemaVersion: "cultnet.document_put_raw.v0", - messageId: `store:${document.recordKey}`, - document: { - schemaId: document.schemaId, - recordKey: document.recordKey, - storedAt: document.storedAt, - payloadEncoding: "messagepack", - payload: encode(document.payload), - }, - }); - if (!handler.receipt) return undefined; - // An echo acknowledges the stored value; an oversized receipt carries a tag larger than - // maxPayloadBytes. Admission sizes neither: receipts are the handler's choice. - return { - binding: defineCultNetDocumentBinding({ definition: noteDocument }), - recordKey: document.recordKey, - value: document.payload as { noteId: string; body: string }, - ...(handler.receipt === "oversized" ? { tags: ["x".repeat(8_000)] } : {}), - }; - }, - onError: (error) => errors.push(error), - }); - let peer: CultNetPeer | undefined; - try { - await server.start(); - peer = await CultMesh.createRudpPeer( - "cultmesh-ts-served-bound-client", - connectionId, - `rudp://127.0.0.1:${server.bind.port}`, - { resendDelayMs: 25, resendPollMs: 5, maxFragmentBytes: 1024, maxPendingReliablePackets: 512, connectTimeoutMs: 1_000 }, - ); - peer.on("message", (message: CultNetMessage) => messages.push(message)); - peer.on("invalidMessage", (error: Error) => unparsed.push(error)); - await body({ server, peer, admitted, errors, messages, unparsed }); - } finally { - peer?.close(); - server.close(); - } -} - -/** Requests `recordKey` under the shortest message id and waits for the reply. */ -async function snapshotUnderShortestId(rig: ServedBoundRig, recordKey: string): Promise { - const before = rig.messages.length; - rig.peer.sendSnapshotRequest({ schemaVersion: "cultnet.snapshot_request.v0", messageId: "0", recordKeys: [recordKey] }); - const startedAt = Date.now(); - while (Date.now() - startedAt < 3_000) { - const reply = rig.messages.slice(before).find((message) => - message.schemaVersion === "cultnet.snapshot_response_raw.v0" && message.messageId === "0"); - if (reply) return reply; - await delay(5); - } - throw new Error(`Timed out waiting for the snapshot of ${recordKey}; server errors: ${rig.errors.map(e => e.message).join("; ")}`); -} - -function servedBodies(reply: CultNetMessage): Array<[string, number]> { - assert.equal(reply.schemaVersion, "cultnet.snapshot_response_raw.v0"); - return (reply as CultNetSnapshotResponseRawMessage).documents.map((document) => [ - document.recordKey, - (decode(document.payload) as { body: string }).body.length, - ]); -} - -async function waitForAdmission(rig: ServedBoundRig, recordKey: string): Promise { - const startedAt = Date.now(); - while (!rig.admitted.includes(recordKey) && Date.now() - startedAt < 3_000) await delay(5); - assert.ok(rig.admitted.includes(recordKey), `${recordKey} was not admitted; server errors: ${rig.errors.map(e => e.message).join("; ")}`); -} - -async function waitForError(rig: ServedBoundRig, description: string): Promise { - const startedAt = Date.now(); - while (rig.errors.length === 0 && Date.now() - startedAt < 3_000) await delay(5); - assert.ok(rig.errors.length > 0, `no server error for ${description}`); - return rig.errors[0]!; -} - -test("CultMesh TS RUDP document server serves an 80 KB note put in 1 KiB fragments", async () => { - await withServedBoundRig(0x10203060, { maxFragmentBytes: 1024, maxPendingReliablePackets: 512 }, async (rig) => { - rig.peer.send(notePut("put-large", "note:large", 80_000)); - await waitForAdmission(rig, "note:large"); - assert.deepEqual(servedBodies(await snapshotUnderShortestId(rig, "note:large")), [["note:large", 80_000]]); - assert.deepEqual(rig.errors, []); - }); -}); - -test("CultMesh TS RUDP document server refuses a put whose reply would overflow its reliable queue", async () => { - // Eight 1 KiB fragments fit the queue, nine do not. - const atBound = bodyLengthForReplyBytes("note:at", 8 * 1024); - const overBound = bodyLengthForReplyBytes("note:ov", 8 * 1024 + 1); - await withServedBoundRig(0x10203061, { maxFragmentBytes: 1024, maxPendingReliablePackets: 8 }, async (rig) => { - // The puts carry a source the registry does not store, so only the served record is the right size. - rig.peer.send(notePut("put-over", "note:ov", overBound, "cultmesh-ts-served-bound-client")); - const refusal = await waitForError(rig, "the over-bound put"); - assert.ok(refusal instanceof CultMeshRudpUnservableDocumentError, refusal.message); - assert.equal(refusal.messageId, "put-over"); - assert.equal(refusal.recordKey, "note:ov"); - assert.equal(refusal.responseBytes, 8 * 1024 + 1); - assert.equal(refusal.fragmentCount, 9); - assert.equal(refusal.maxFragmentCount, 8); - assert.equal(refusal.maxPayloadBytes, undefined); - assert.match(refusal.message, /8193 bytes in 9 fragments/); - assert.deepEqual(rig.admitted, []); - - rig.peer.send(notePut("put-at", "note:at", atBound, "cultmesh-ts-served-bound-client")); - await waitForAdmission(rig, "note:at"); - assert.deepEqual(servedBodies(await snapshotUnderShortestId(rig, "note:at")), [["note:at", atBound]]); - assert.equal(rig.errors.length, 1); - }); -}); - -test("CultMesh TS RUDP document server answers a snapshot its reliable queue cannot take", async () => { - // Two documents each served in exactly the eight fragments the queue holds are admitted; a - // snapshot of both needs sixteen and cannot be queued. The peer is answered with a - // cultnet.error.v0, not left to time out, and onError hears why. - const atBound = bodyLengthForReplyBytes("note:q1", 8 * 1024); - await withServedBoundRig(0x10203068, { maxFragmentBytes: 1024, maxPendingReliablePackets: 8 }, async (rig) => { - rig.peer.send(notePut("put-q1", "note:q1", atBound)); - rig.peer.send(notePut("put-q2", "note:q2", atBound)); - await waitForAdmission(rig, "note:q1"); - await waitForAdmission(rig, "note:q2"); - assert.deepEqual(rig.errors, []); - rig.peer.sendSnapshotRequest({ schemaVersion: "cultnet.snapshot_request.v0", messageId: "both", recordKeys: ["note:q1", "note:q2"] }); - await waitForPeerErrors(rig, 1); - assert.equal(rig.errors.length, 1); - assert.ok(!rig.messages.some((message) => message.schemaVersion === "cultnet.snapshot_response_raw.v0")); - }); -}); - -/** - * A document server over a node that already holds `stored`, and a peer driven packet by packet - * that acknowledges nothing, so a test fills the server's reliable queue at will. - */ -async function withRawPeerRig( - connectionId: number, - serverLimits: { maxFragmentBytes?: number; maxPendingReliablePackets?: number }, - stored: CultNetDocumentPutRawMessage[], - getCache: ((cache: unknown) => unknown) | undefined, - body: (rig: { - errors: Error[]; - inbox: CultNetRudpPacket[]; - request: (messageId: string, recordKeys: string[]) => number[]; - }) => Promise, -): Promise { - const node = await CultMesh.startNode( - join(await mkdtemp(join(tmpdir(), "cultmesh-ts-raw-peer-")), "node.ccmp"), - { documents: [noteDocument] }, - ); - const registry = servedBoundRegistry(); - for (const put of stored) await registry.applyRawDocumentPutMessage(node.cache, put); - const errors: Error[] = []; - const server = CultMesh.createRudpDocumentServer(SERVED_BOUND_SERVER, connectionId, { - documents: registry, - getCache: () => (getCache ? getCache(node.cache) : node.cache) as typeof node.cache, - bindHost: "127.0.0.1", - bindPort: 0, - resendDelayMs: 100_000, - resendPollMs: 5, - ...serverLimits, - onError: (error) => errors.push(error), - }); - await server.start(); - const socket = createSocket("udp4"); - try { - await new Promise((resolve) => socket.bind(0, "127.0.0.1", () => resolve())); - const inbox: CultNetRudpPacket[] = []; - socket.on("message", (wire) => inbox.push(decodeRudpPacket(wire))); - const session = new CultNetRudpSession({ connectionId, initialSequence: 100, resendDelayMs: 100_000, maxPendingReliablePackets: 64 }); - const send = (packet: CultNetRudpPacket) => socket.send(encodeRudpPacket(packet), server.bind.port, "127.0.0.1"); - send(session.createConnect(0)); - const startedAt = Date.now(); - while (!inbox.some((packet) => packet.packetType === "accept") && Date.now() - startedAt < 2_000) await delay(5); - const accept = inbox.find((packet) => packet.packetType === "accept"); - assert.ok(accept, "the server accepts the connect"); - session.receive(accept, 1); - inbox.length = 0; - const request = (messageId: string, recordKeys: string[]): number[] => { - const packets = session.sendMany( - "schema", - encode({ schemaVersion: "cultnet.snapshot_request.v0", messageId, recordKeys }), - { reliable: true, ordered: true, nowMs: 2, maxFragmentBytes: 1200 }, - ); - packets.forEach(send); - return packets.map((packet) => packet.sequence); - }; - await body({ errors, inbox, request }); - } finally { - socket.close(); - server.close(); - } -} - -/** The refusal among `packets`: its unreliable fragments, reassembled, and the fragments. */ -function refusalIn(packets: CultNetRudpPacket[]): { message: Record; parts: CultNetRudpPacket[] } | undefined { - const parts = packets - .filter((packet) => packet.packetType === "data" && packet.channelId === "schema" && !packet.reliable) - .sort((a, b) => (a.fragmentIndex ?? 0) - (b.fragmentIndex ?? 0)); - if (parts.length === 0) return undefined; - const message = decode(Buffer.concat(parts.map((part) => Buffer.from(part.payload ?? new Uint8Array())))) as Record; - return { message, parts }; -} - -function acknowledges(packet: CultNetRudpPacket, sequence: number): boolean { - if (packet.ack === sequence) return true; - for (let bit = 0; bit < 32; bit += 1) { - if ((packet.ackMask & (1 << bit)) !== 0 && packet.ack - bit - 1 === sequence) return true; - } - return false; -} - -test("CultMesh TS RUDP document server answers a peer whose reliable queue is full to the brim", async () => { - // An 8-fragment reply the peer never acknowledges fills a queue of 8 exactly. The next reply - // cannot be queued; the peer is still answered, with fixed text that takes no room in that - // queue and acknowledges nothing the peer sent. - const body = bodyLengthForReplyBytes("q1", 800); - await withRawPeerRig(0x10203069, { maxFragmentBytes: 100, maxPendingReliablePackets: 8 }, [notePut("s", "q1", body)], undefined, async (rig) => { - rig.request("0", ["q1"]); - await delay(300); - const first = new Set(rig.inbox.filter((packet) => packet.packetType === "data" && packet.reliable).map((packet) => packet.sequence)); - assert.equal(first.size, 8, "fixture: the first reply fills the queue exactly"); - rig.inbox.length = 0; - const refused = rig.request("b", ["none"]); - const startedAt = Date.now(); - while (!refusalIn(rig.inbox) && Date.now() - startedAt < 3_000) await delay(5); - const refusal = refusalIn(rig.inbox); - assert.ok(refusal, "the refusal reaches the peer"); - assert.deepEqual(refusal.message, { schemaVersion: "cultnet.error.v0", error: "the snapshot response could not be queued" }); - for (const part of refusal.parts) { - assert.ok(refused.every((sequence) => !acknowledges(part, sequence)), `ack ${part.ack} mask ${part.ackMask}`); - } - assert.equal(rig.errors.length, 1); - }); -}); - -test("CultMesh TS RUDP document server refuses a snapshot with fixed text, never an error's message", async () => { - // The cache the snapshot needs fails with a message a peer must not see: the peer is told - // only that the snapshot source failed; onError keeps the detail. - await withRawPeerRig(0x1020306a, {}, [], () => { throw new Error("no such tenant CANARY-7f3a"); }, async (rig) => { - rig.request("0", ["q1"]); - const startedAt = Date.now(); - while (!refusalIn(rig.inbox) && Date.now() - startedAt < 3_000) await delay(5); - const refusal = refusalIn(rig.inbox); - assert.ok(refusal, "the refusal reaches the peer"); - assert.deepEqual(refusal.message, { schemaVersion: "cultnet.error.v0", error: "the snapshot source failed" }); - assert.match(rig.errors[0]?.message ?? "", /CANARY-7f3a/); - }); -}); - -test("CultMesh TS RUDP document server honours maxPayloadBytes for replies and judges puts by what it would serve", async () => { - const limit = 4_000; - const atBound = bodyLengthForReplyBytes("note:at", limit); - const overBound = bodyLengthForReplyBytes("note:ov", limit + 1); - await withServedBoundRig(0x10203062, { maxFragmentBytes: 1024, maxPayloadBytes: limit }, async (rig) => { - rig.peer.send(notePut("put-over", "note:ov", overBound)); - const refusal = await waitForError(rig, "the over-bound put"); - assert.ok(refusal instanceof CultMeshRudpUnservableDocumentError, refusal.message); - assert.equal(refusal.responseBytes, limit + 1); - assert.equal(refusal.maxPayloadBytes, limit); - assert.equal(refusal.fragmentCount, 4); - assert.deepEqual(rig.admitted, []); - // The peer is sent the refusal, and it names sizes, never the record. - await waitForPeerErrors(rig, 1); - assert.ok(!refusal.message.includes("note:ov"), refusal.message); - - // A put whose own frame is over the limit only by the provenance it carries is served at the - // bound, so it is admitted and served. - const carried = notePut("put-at", "note:at", atBound, `runtime-${"r".repeat(200)}`); - assert.ok(encode(carried).byteLength > limit, "fixture: the put's frame is over the limit"); - rig.peer.send(carried); - await waitForAdmission(rig, "note:at"); - assert.deepEqual(servedBodies(await snapshotUnderShortestId(rig, "note:at")), [["note:at", atBound]]); - assert.equal(rig.errors.length, 1); - - // A record key longer than the limit: the refusal is still small enough to reach the peer. - const longKey = `note:${"k".repeat(2 * limit)}`; - rig.peer.send(notePut("put-long-key", longKey, 10)); - await waitForPeerErrors(rig, 2); - assert.ok(rig.errors[1] instanceof CultMeshRudpUnservableDocumentError, rig.errors[1]!.message); - assert.equal(rig.errors.length, 2, "the refusal itself was sent"); - assert.deepEqual(rig.admitted, ["note:at"]); - - // Two servable documents make a reply over the limit: it is not sent, and onError hears why. - rig.peer.send(notePut("put-a2", "note:a2", atBound)); - await waitForAdmission(rig, "note:a2"); - rig.peer.sendSnapshotRequest({ schemaVersion: "cultnet.snapshot_request.v0", messageId: "0", recordKeys: ["note:at", "note:a2"] }); - const replyStartedAt = Date.now(); - while (rig.errors.length < 3 && Date.now() - replyStartedAt < 3_000) await delay(5); - assert.equal(rig.errors.length, 3); - assert.match(rig.errors[2]!.message, /reply cultnet\.snapshot_response_raw\.v0 is \d+ bytes; maxPayloadBytes is 4000/); - }); -}); - -test("CultMesh TS RUDP document server admits a put served at the bound, whatever receipt its handler returns", async () => { - // These puts keep a short storedAt, so the receipt echoing one is larger than its served reply, - // and over the limit. Admission sizes only the served reply: exactly at the limit is admitted - // with or without a receipt, one byte over is refused. An echoed receipt that cannot be sent - // goes the way of any unsendable receipt: the put is stored and the peer is told. - const limit = 4_000; - const put = (messageId: string, recordKey: string, body: number) => - notePut(messageId, recordKey, body, undefined, RECEIPT_STORED_AT); - const bodyServedAt = (messageId: string, recordKey: string, bytes: number): number => { - const probe = 2_000; - const length = probe + bytes - servedAloneBytes(put(messageId, recordKey, probe)); - assert.equal(servedAloneBytes(put(messageId, recordKey, length)), bytes, "fixture: reply size is linear in the body"); - assert.ok(echoReceiptBytes(put(messageId, recordKey, length)) > limit, "fixture: the echoed receipt is over the limit"); - return length; - }; - const atBound = bodyServedAt("put-at", "note:at", limit); - const overBound = bodyServedAt("put-ov", "note:ov", limit + 1); - for (const [connectionId, receipt] of [[0x10203066, undefined], [0x10203067, "echo"]] as const) { - await withServedBoundRig(connectionId, { maxFragmentBytes: 1024, maxPayloadBytes: limit }, async (rig) => { - rig.peer.send(put("put-at", "note:at", atBound)); - await waitForAdmission(rig, "note:at"); - if (receipt === "echo") { - const failure = await waitForError(rig, "the echoed receipt"); - assert.match(failure.message, /reply cultnet\.document_put_raw\.v0 is \d+ bytes; maxPayloadBytes is 4000/); - await waitForPeerErrors(rig, 1); - assert.ok(!rig.messages.some(isDocumentPut)); - } - assert.deepEqual(servedBodies(await snapshotUnderShortestId(rig, "note:at")), [["note:at", atBound]]); - const errorsBefore = rig.errors.length; - assert.equal(errorsBefore, receipt === "echo" ? 1 : 0, rig.errors.map((error) => error.message).join("; ")); - - rig.peer.send(put("put-ov", "note:ov", overBound)); - const startedAt = Date.now(); - while (rig.errors.length === errorsBefore && Date.now() - startedAt < 3_000) await delay(5); - const refusal = rig.errors[errorsBefore]; - assert.ok(refusal instanceof CultMeshRudpUnservableDocumentError, refusal?.message); - assert.equal(refusal.responseBytes, limit + 1); - assert.deepEqual(rig.admitted, ["note:at"]); - }, receipt ? { receipt } : {}); - } -}); - -test("CultMesh TS RUDP document server tells the peer when a stored put's receipt cannot be sent", async () => { - // A handler whose receipt is larger than maxPayloadBytes: admission does not size receipts, so - // the put is stored, the receipt cannot be sent, and the peer hears that it is not coming. - const limit = 4_000; - const small = bodyLengthForReplyBytes("note:small", 1_000); - await withServedBoundRig(0x10203064, { maxFragmentBytes: 1024, maxPayloadBytes: limit }, async (rig) => { - rig.peer.send(notePut("put-small", "note:small", small)); - await waitForAdmission(rig, "note:small"); - await waitForPeerErrors(rig, 1); - assert.equal(rig.errors.length, 1); - assert.match(rig.errors[0]!.message, /reply cultnet\.document_put_raw\.v0 is \d+ bytes; maxPayloadBytes is 4000/); - assert.ok(!rig.messages.some(isDocumentPut)); - assert.deepEqual(servedBodies(await snapshotUnderShortestId(rig, "note:small")), [["note:small", small]]); - }, { receipt: "oversized" }); -}); - -function isDocumentPut(message: CultNetMessage): boolean { - return message.schemaVersion === "cultnet.document_put_raw.v0"; -} - -/** - * Waits until the peer has been sent `count` cultnet.error.v0 replies. A TypeScript peer cannot - * yet parse the two-key error this server sends (docs/cultnet-error-contract-cut.md: - * "TypeScript cannot parse the errors TypeScript sends"), - * so each arrives as an unparsed cultnet.error.v0 frame; its text is asserted through onError. - */ -async function waitForPeerErrors(rig: ServedBoundRig, count: number): Promise { - const errors = () => rig.unparsed.filter((error) => /cultnet\.error\.v0/.test(error.message)).length - + rig.messages.filter((message) => message.schemaVersion === "cultnet.error.v0").length; - const startedAt = Date.now(); - while (errors() < count && Date.now() - startedAt < 3_000) await delay(5); - assert.equal(errors(), count, `peer errors: ${rig.unparsed.map((error) => error.message).join("; ")}`); -} - function delay(milliseconds: number): Promise { return new Promise(resolve => setTimeout(resolve, milliseconds)); } diff --git a/packages/cultmesh-ts/test/fixtures/README.md b/packages/cultmesh-ts/test/fixtures/README.md deleted file mode 100644 index 70573ff2..00000000 --- a/packages/cultmesh-ts/test/fixtures/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# QUIC test fixtures - -`quic-test.p12` and `quic-test-cert.der` are a self-signed P-256 credential -used only to open a loopback MsQuic listener in tests -(`realtime-quic-native.test.ts`, `realtime-quic-consumer.test.ts`). Not a -production credential; no private key outside this pair signs anything real. - -`quic-test-cert.der`'s subject is `CN=cultmesh-quic-native-tests`, and its -SHA-256 is what the tests pin as the expected certificate pin -(`cert-sha256`). - -Generated with (mirrors the recipe the cut map records at P13): - -```sh -openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ - -keyout quic-test-key.pem -out quic-test-cert.pem \ - -subj "/CN=cultmesh-quic-native-tests" -days 3650 - -openssl x509 -in quic-test-cert.pem -outform der -out quic-test-cert.der - -openssl pkcs12 -export -inkey quic-test-key.pem -in quic-test-cert.pem \ - -out quic-test.p12 -passout pass: -``` - -Regenerate the same way if the pair ever needs replacing; nothing here -depends on today's exact bytes past what the tests read back out (the DER -cert and its SHA-256, and a PKCS12 the native bridge can load). diff --git a/packages/cultmesh-ts/test/fixtures/quic-test-cert.der b/packages/cultmesh-ts/test/fixtures/quic-test-cert.der deleted file mode 100644 index 5cce6f94..00000000 Binary files a/packages/cultmesh-ts/test/fixtures/quic-test-cert.der and /dev/null differ diff --git a/packages/cultmesh-ts/test/fixtures/quic-test.p12 b/packages/cultmesh-ts/test/fixtures/quic-test.p12 deleted file mode 100644 index e9d03ce6..00000000 Binary files a/packages/cultmesh-ts/test/fixtures/quic-test.p12 and /dev/null differ diff --git a/packages/cultmesh-ts/test/interop/cultmesh-quic-peer.ts b/packages/cultmesh-ts/test/interop/cultmesh-quic-peer.ts deleted file mode 100644 index aadd1265..00000000 --- a/packages/cultmesh-ts/test/interop/cultmesh-quic-peer.ts +++ /dev/null @@ -1,234 +0,0 @@ -// The TypeScript half of the QUIC realtime interop lane. Two modes: -// -// `dial` (Cut 4): a one-shot process that dials an advertised -// `cultmesh-state+quic://` endpoint with the native connector, receives -// `--expect` frames from a peer (normally the C# managed provider started by -// `cultnet-interop.test.ts`'s "CultMesh QUIC realtime" test), and prints them -// as one JSON line. -// -// `serve` (Cut 5): the StreamPixels role. Opens a `CultMeshQuicRealtimeProvider` -// listener, prints `{status: "ready", endpoint}` (the same shape the C# -// `quic-realtime-serve` peer prints), waits for a first peer before -// broadcasting (mirroring `QuicRealtimeServeAsync`'s -// `WaitForFirstConnectionAsync`, since a broadcast to nobody would otherwise -// silently no-op), then broadcasts `--frames` frames at `--delivery` with -// `--interval-ms` between them, watching stdin for EOF as its own shutdown -// signal like the C# peer's `WatchStdinCloseAsync`. `--linger-ms` (default 0) -// keeps the listener open that long after broadcasting finishes, so the -// harness can dial a peer late and exercise Cut C's retained-state seed -// instead of the provider always tearing down the moment it is done sending. -// -// Neither mode imports `cultmesh-ts` itself (the harness drives processes, -// and the dependency direction is `cultmesh-ts` -> `cultnet-ts`, never the -// reverse); this script reaches the provider/connector through its own -// package's `src/`. - -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import process from "node:process"; - -import { - CultMeshQuicRealtimeConnector, - CultMeshQuicRealtimeProvider, - type CultMeshRealtimeTarget, -} from "../../src/realtime-quic"; -import { encodeRealtimeFrame, type CultMeshRealtimeDelivery, type CultMeshRealtimeFrame } from "../../src/realtime-wire"; - -// `__dirname` at runtime is `dist-test/test/interop`; fixtures are binary and -// are never compiled/copied there, so they are read from their source -// location, three levels up. The same self-signed test credential the unit -// tests use (`test/fixtures/README.md`): not a production credential. -const FIXTURE_P12 = join(__dirname, "..", "..", "..", "test", "fixtures", "quic-test.p12"); - -function parseArgs(argv: readonly string[]): Map { - const args = new Map(); - for (let index = 0; index < argv.length; index += 1) { - const token = argv[index]; - if (!token.startsWith("--")) continue; - const name = token.slice(2); - const value = argv[index + 1]; - if (!value || value.startsWith("--")) throw new Error(`Missing value for --${name}`); - args.set(name, value); - index += 1; - } - return args; -} - -function requireArg(args: Map, name: string): string { - const value = args.get(name); - if (!value) throw new Error(`Missing required argument --${name}`); - return value; -} - -function optionalIntArg(args: Map, name: string, fallback: number): number { - const raw = args.get(name); - if (!raw) return fallback; - const parsed = Number.parseInt(raw, 10); - if (!Number.isInteger(parsed)) throw new Error(`Argument --${name} must be an integer.`); - return parsed; -} - -function writeJsonLine(value: unknown): void { - process.stdout.write(`${JSON.stringify(value)}\n`); -} - -function writeLog(event: string, payload: Record): void { - process.stderr.write(`${JSON.stringify({ event, ...payload })}\n`); -} - -function watchStdinCloseAsync(): Promise { - return new Promise((resolve) => { - process.stdin.resume(); - process.stdin.once("end", resolve); - }); -} - -async function serveAsync(args: Map): Promise { - const frames = optionalIntArg(args, "frames", 5); - const deliveryArg = args.get("delivery") ?? "latest-only"; - if (deliveryArg !== "latest-only" && deliveryArg !== "reliable-ordered") { - throw new Error(`Unsupported --delivery '${deliveryArg}'.`); - } - const delivery = deliveryArg as CultMeshRealtimeDelivery; - const intervalMs = optionalIntArg(args, "interval-ms", 50); - const lingerMs = optionalIntArg(args, "linger-ms", 0); - const port = optionalIntArg(args, "port", 0); - - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - }); - writeJsonLine({ status: "ready", endpoint: provider.advertisedEndpoint }); - - try { - // A broadcast to zero peers is not an error, but it sends nothing: - // matching the C# `quic-realtime-serve` peer, wait for a first - // connection, bounded, so a peer that never shows up still exits. - const connectDeadline = Date.now() + 30_000; - while (provider.connectionCount === 0) { - if (Date.now() >= connectDeadline) throw new Error("quic-realtime-serve: no client connected within 30000ms."); - await new Promise((resolve) => setTimeout(resolve, 20)); - } - - const stdinClosed = watchStdinCloseAsync(); - let stopped = false; - void stdinClosed.then(() => { - stopped = true; - }); - for (let sequence = 1; sequence <= frames && !stopped; sequence += 1) { - const frame: CultMeshRealtimeFrame = { - channelId: "interop.quic-realtime", - schemaId: "gamecult.interop.quic_realtime_frame.v0", - bodyId: "interop:quic-realtime:frame", - producerEpoch: 1n, - sequence: BigInt(sequence), - delivery, - payload: Buffer.from(`frame-${sequence}`, "utf8"), - }; - await provider.broadcast(frame); - // Printed so the harness can compare this exact frame's TypeScript - // encoding against the same frame's C#-side re-encoding (golden bytes - // across processes), without the harness importing the codec itself. - writeLog("quic-realtime-serve", { sent: sequence, hex: Buffer.from(encodeRealtimeFrame(frame)).toString("hex") }); - if (intervalMs > 0) await new Promise((resolve) => setTimeout(resolve, intervalMs)); - } - if (lingerMs > 0 && !stopped) await new Promise((resolve) => setTimeout(resolve, lingerMs)); - } finally { - provider.dispose(); - // Mirrors the C# peer returning from `QuicRealtimeServeAsync`: once - // broadcasting is done (or stdin closed early), let the process exit on - // its own instead of keeping the event loop alive on a stdin that may - // never close. The harness still ends/kills this process explicitly in - // its own cleanup; this only lets a plain manual run exit cleanly too. - process.stdin.pause(); - } -} - -async function main(): Promise { - const [mode, ...rest] = process.argv.slice(2); - if (mode === "serve") { - await serveAsync(parseArgs(rest)); - return; - } - if (mode !== "dial") throw new Error("Expected mode: dial | serve"); - const args = parseArgs(rest); - const endpoint = requireArg(args, "endpoint"); - const expect = optionalIntArg(args, "expect", 1); - // Alternative stop condition to --expect: keep receiving (through whatever - // the consumer's own coalescing inbox delivers) until a frame with this - // sequence arrives, then stop. Lets a caller prove convergence under - // latest-only coalescing, where the frame *count* a stalled reader sees is - // not the interesting number, but the final value it converges on is. - const expectSequenceRaw = args.get("expect-sequence"); - const expectSequence = expectSequenceRaw !== undefined ? BigInt(expectSequenceRaw) : undefined; - const timeoutMs = optionalIntArg(args, "timeout-ms", 15_000); - // Simulates "a test hook on the runtime that stops calling next_event" - // (spec section 10, LatestOnly-under-a-stalled-consumer lane) at the level - // this subprocess can reach: after receiving --pause-after frames, stop - // calling receiveFrame for --pause-ms. The shared native pump keeps - // dispatching and coalescing into this transport's own inbox regardless - // (Cut 4), so not reading is externally equivalent to not polling. - const pauseAfter = optionalIntArg(args, "pause-after", -1); - const pauseMs = optionalIntArg(args, "pause-ms", 0); - - const target: CultMeshRealtimeTarget = { verseId: "interop", authorityRuntimeId: "interop.csharp-provider" }; - const connector = new CultMeshQuicRealtimeConnector(); - const transport = await connector.connect( - { endpoint, authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "interop" }, - target, - ); - writeLog("connected", { endpoint, transportId: transport.transportId }); - - const frames: Array<{ - channelId: string; - schemaId: string; - bodyId: string; - producerEpoch: string; - sequence: string; - delivery: string; - payloadHex: string; - }> = []; - try { - const deadline = Date.now() + timeoutMs; - let lastSequence: bigint | undefined; - while ( - (expectSequence === undefined && frames.length < expect) || - (expectSequence !== undefined && lastSequence !== expectSequence) - ) { - if (pauseAfter >= 0 && frames.length === pauseAfter) { - writeLog("pausing", { afterFrames: frames.length, pauseMs }); - await new Promise((resolve) => setTimeout(resolve, pauseMs)); - writeLog("resumed", { afterFrames: frames.length }); - } - const remaining = deadline - Date.now(); - if (remaining <= 0) throw new Error(`Timed out after receiving ${frames.length} frames (last sequence ${lastSequence}).`); - const controller = new AbortController(); - const timer = setTimeout(() => controller.abort(), remaining); - try { - const frame = await transport.receiveFrame(controller.signal); - lastSequence = frame.sequence; - frames.push({ - channelId: frame.channelId, - schemaId: frame.schemaId, - bodyId: frame.bodyId, - producerEpoch: frame.producerEpoch.toString(), - sequence: frame.sequence.toString(), - delivery: frame.delivery, - payloadHex: Buffer.from(frame.payload).toString("hex"), - }); - } finally { - clearTimeout(timer); - } - } - } finally { - transport.dispose(); - } - - writeJsonLine({ endpoint, transportId: transport.transportId, frames }); -} - -main().catch((error) => { - writeLog("fatal", { error: error instanceof Error ? (error.stack ?? error.message) : String(error) }); - process.exitCode = 1; -}); diff --git a/packages/cultmesh-ts/test/provider-rudp-transport.test.ts b/packages/cultmesh-ts/test/provider-rudp-transport.test.ts index f1dd5d2d..5b44c84b 100644 --- a/packages/cultmesh-ts/test/provider-rudp-transport.test.ts +++ b/packages/cultmesh-ts/test/provider-rudp-transport.test.ts @@ -8,7 +8,6 @@ import { decodeRudpPacket, encodeRudpPacket, type CultNetOperationRequestMessage, - type CultNetRudpPacket, } from "cultnet-ts"; import { @@ -321,80 +320,6 @@ test("a replaced RUDP generation drops operations queued behind an active handle } }); -test("a client restarted on the same address with the same Connect payload replaces its RUDP session, and a retransmitted Connect does not", async () => { - const connectionId = 0x43554c54; - let closedSessions = 0; - const server = CultMesh.createRudpDocumentServer("odin-restart-test", connectionId, { - bindPort: 0, - documents: new CultNetDocumentRegistry(), - onSessionClosed: () => { closedSessions += 1; }, - onError: () => undefined, - }); - await server.start(); - const socket = createSocket("udp4"); - const received: CultNetRudpPacket[] = []; - socket.on("message", wire => received.push(decodeRudpPacket(wire))); - const toServer = (packet: CultNetRudpPacket) => - socket.send(encodeRudpPacket(packet), server.bind.port, "127.0.0.1"); - const evidence = Buffer.from("same connect payload"); - try { - const first = new CultNetRudpSession({ connectionId, initialSequence: 50_000 }); - const connect = first.createConnect(Date.now(), evidence); - toServer(connect); - await waitFor(() => received.some(packet => packet.packetType === "accept"), "the first Accept"); - - // A retransmitted Connect repeats: the session stays. - toServer(connect); - await new Promise(resolve => setTimeout(resolve, 100)); - assert.equal(closedSessions, 0, "a retransmitted Connect closed the session"); - - // The same client restarted: another sequence, the same payload. - received.length = 0; - const second = new CultNetRudpSession({ connectionId, initialSequence: 7 }); - toServer(second.createConnect(Date.now(), evidence)); - await waitFor(() => closedSessions === 1, "the old RUDP session to close"); - await waitFor(() => received.some(packet => packet.packetType === "accept"), "the restarted client's Accept"); - } finally { - socket.close(); - server.close(); - } -}); - -test("the RUDP document server does not acknowledge by name a reliable packet its session did not receive", async () => { - const connectionId = 0x43554c55; - const server = CultMesh.createRudpDocumentServer("odin-ack-test", connectionId, { - bindPort: 0, - documents: new CultNetDocumentRegistry(), - onError: () => undefined, - }); - await server.start(); - const socket = createSocket("udp4"); - const received: CultNetRudpPacket[] = []; - socket.on("message", wire => received.push(decodeRudpPacket(wire))); - const toServer = (packet: CultNetRudpPacket) => - socket.send(encodeRudpPacket(packet), server.bind.port, "127.0.0.1"); - try { - const client = new CultNetRudpSession({ connectionId, initialSequence: 50_000 }); - const connect = client.createConnect(Date.now()); - toServer(connect); - await waitFor(() => received.some(packet => packet.packetType === "accept"), "the Accept"); - received.length = 0; - - // A reliable packet the session ignores (a client does not send an Accept). - // The session never received it, so the Ack must not name it. - const ignored: CultNetRudpPacket = { ...client.createAck(), packetType: "accept", reliable: true, sequence: connect.sequence + 5 }; - toServer(ignored); - await waitFor(() => received.some(packet => packet.packetType === "ack"), "the acknowledgement"); - const ack = received.find(packet => packet.packetType === "ack")!; - const names = ack.ack === ignored.sequence - || Array.from({ length: 32 }, (_, bit) => bit).some(bit => (ack.ackMask & (1 << bit)) !== 0 && ack.ack - bit - 1 === ignored.sequence); - assert.equal(names, false, "the server acknowledged by name a packet its session refused"); - } finally { - socket.close(); - server.close(); - } -}); - function deferred(): { promise: Promise; resolve(value: T): void } { let resolve!: (value: T) => void; return { promise: new Promise(done => resolve = done), resolve }; diff --git a/packages/cultmesh-ts/test/realtime-quic-consumer.test.ts b/packages/cultmesh-ts/test/realtime-quic-consumer.test.ts deleted file mode 100644 index 8a2063fe..00000000 --- a/packages/cultmesh-ts/test/realtime-quic-consumer.test.ts +++ /dev/null @@ -1,1074 +0,0 @@ -// The TypeScript QUIC realtime consumer, proven two ways: directly against a -// raw listener opened through the native runtime (no provider semantics yet, -// mirrors `CultMeshNativeQuicRealtimeTransportTests.cs`), and through -// `CultMeshQuicRealtimeSessionManager` with a static lookup source and routes -// signed with `node:crypto`, mirroring `CultMeshQuicRealtimeTransportTests.cs` -// and `CultMeshSessions.cs`'s realtime binding. -// -// Skips instead of failing when no native bridge is available; see -// `realtime-quic-native.test.ts` for why. - -import assert from "node:assert/strict"; -import { createHash, generateKeyPairSync, sign as cryptoSign, type KeyObject } from "node:crypto"; -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import test from "node:test"; - -import { - canonicalRoute, - type CultMeshAuthorityRouteView, - type CultMeshAuthorityTrustPolicy, - type CultMeshP256PublicKey, -} from "cultnet-ts"; -import type { CultMeshAuthorityRouteMessage, CultMeshVerseDescriptorMessage } from "cultnet-ts/contracts"; - -import { - CultMeshQuicNativeRuntime, - CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION, - CULTMESH_QUIC_STREAM_LATEST_ONLY, - CULTMESH_QUIC_STREAM_RELIABLE, -} from "../src/realtime-quic-native"; -import { - CultMeshQuicRealtimeConnector, - CultMeshQuicRealtimeSessionManager, - CultMeshStaticRealtimeLookupSource, - CULTMESH_REALTIME_STATE_PROTOCOL_ID, - type CultMeshQuicRealtimeTransport, - type CultMeshRealtimeCandidate, - type CultMeshRealtimeTarget, - type CultMeshRealtimeTransport, - type CultMeshRealtimeTransportConnector, -} from "../src/realtime-quic"; -import { encodeRealtimeFrame, type CultMeshRealtimeFrame } from "../src/realtime-wire"; -import { nativeBridgeAvailable } from "./support/native-bridge"; - -// __dirname at runtime is dist-test/test; fixtures are binary and are never -// compiled/copied there, so they are read from their source location, two -// levels up. -const FIXTURE_P12 = join(__dirname, "..", "..", "test", "fixtures", "quic-test.p12"); -const FIXTURE_DER = join(__dirname, "..", "..", "test", "fixtures", "quic-test-cert.der"); - -function fixturePinHex(): string { - return createHash("sha256").update(readFileSync(FIXTURE_DER)).digest("hex"); -} - -/** A bare loopback listener over the raw native runtime, no provider semantics. */ -class RawQuicListener { - private constructor( - private readonly runtime: CultMeshQuicNativeRuntime, - private readonly listenerId: bigint, - readonly boundPort: number, - ) {} - - static async open(): Promise { - const runtime = await CultMeshQuicNativeRuntime.open(); - try { - const pkcs12 = readFileSync(FIXTURE_P12); - const { listenerId, boundPort } = runtime.listenerOpen("127.0.0.1", 0, pkcs12, ""); - return new RawQuicListener(runtime, listenerId, boundPort); - } catch (error) { - // A runtime opened above and never handed to a caller would otherwise - // leak: the shared runtime's refcount never reaches zero, its MsQuic - // registration and worker threads never tear down, and a process that - // hits this on every one of several tests never exits on its own. - await runtime.release(); - throw error; - } - } - - /** Waits for one inbound connection and returns its native connection id. */ - async acceptOnce(): Promise { - return await new Promise((resolve) => { - this.runtime.onListenerEvent(this.listenerId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) resolve(event.connectionId); - }); - }); - } - - /** Sends one frame to an accepted connection on a fresh stream of `kind`. */ - sendFrame(connectionId: bigint, frame: CultMeshRealtimeFrame, kind: number): void { - const streamId = this.runtime.streamOpen(connectionId, kind); - this.runtime.streamSendFrame(streamId, encodeRealtimeFrame(frame), true); - } - - /** Sends arbitrary bytes (not necessarily a valid encoded frame) on a fresh stream of `kind`. */ - sendRaw(connectionId: bigint, bytes: Uint8Array, kind: number): void { - const streamId = this.runtime.streamOpen(connectionId, kind); - this.runtime.streamSendFrame(streamId, bytes, true); - } - - /** Shuts down one accepted connection from this side, as a peer disconnect. */ - shutdownConnection(connectionId: bigint, code = 0n): void { - this.runtime.connectionShutdown(connectionId, code); - } - - async close(): Promise { - this.runtime.listenerClose(this.listenerId); - await this.runtime.release(); - } -} - -/** - * `assert.rejects`, but safe against a mutant or a real regression that - * makes the promise resolve instead: a transport that unexpectedly connects - * is disposed before the assertion fails, rather than left live with an open - * native connection and an outstanding runtime reference. A bare - * `assert.rejects(connector.connect(...))` hung the whole file exactly this - * way under M1 (the certificate-accept mutation): three tests failed their - * assertion correctly, but each left a connected, undisposed transport - * behind, and Node's test runner refuses to exit while any promise or - * native handle is still outstanding. - */ -async function assertRejectsAndDisposes( - promise: Promise<{ dispose(): void }>, - match?: RegExp, -): Promise { - let resolved: { dispose(): void } | undefined; - try { - resolved = await promise; - } catch (error) { - if (match) assert.match(error instanceof Error ? error.message : String(error), match); - return; - } - resolved.dispose(); - assert.fail("expected the promise to reject, but it resolved (the resolved value has been disposed)"); -} - -/** - * `transport.receiveFrame()`, bounded: a fault-path regression that leaves a - * malformed frame undelivered-but-not-rejected would otherwise hang this - * call (and, through a bare `assert.rejects`, the whole test file) forever, - * rather than fail the one assertion it was supposed to fail. - */ -function receiveFrameOrTimeout(transport: { receiveFrame(signal?: AbortSignal): Promise }, ms = 3_000): Promise { - const controller = new AbortController(); - const timer = setTimeout(() => controller.abort(), ms); - return transport.receiveFrame(controller.signal).finally(() => clearTimeout(timer)); -} - -function testFrame(overrides: Partial = {}): CultMeshRealtimeFrame { - return { - channelId: "aetheria.entities", - schemaId: "eve.entity_soa.v1", - bodyId: "body:aetheria:entities", - producerEpoch: 7n, - sequence: 1n, - delivery: "latest-only", - payload: new Uint8Array([3, 4, 5]), - ...overrides, - }; -} - -test("connect with the correct pin succeeds and receives a frame", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - assert.equal(transport.transportId, "msquic-realtime"); - const connectionId = await accepted; - listener.sendFrame(connectionId, testFrame(), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const received = await transport.receiveFrame(); - assert.equal(received.bodyId, "body:aetheria:entities"); - assert.equal(received.sequence, 1n); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("connect refuses a wrong advertised pin", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${"0".repeat(64)}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - await assertRejectsAndDisposes(connector.connect(candidate, target), /certificate|rejected/i); - } finally { - await listener.close(); - } -}); - -test("connect refuses a missing certificate pin when no validator is supplied", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - await assertRejectsAndDisposes(connector.connect(candidate, target), /certificate|rejected/i); - } finally { - await listener.close(); - } -}); - -test("a caller-supplied validator observes the target identity and the DER bytes", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - let observedTarget: CultMeshRealtimeTarget | undefined; - let observedDerLength = 0; - const connector = new CultMeshQuicRealtimeConnector({ - validateProviderCertificate: (validatorTarget, der) => { - observedTarget = validatorTarget; - observedDerLength = der.byteLength; - return true; - }, - }); - const transport = await connector.connect(candidate, target); - transport.dispose(); - assert.deepEqual(observedTarget, target); - assert.ok(observedDerLength > 0); - } finally { - await listener.close(); - } -}); - -test("a late older generation is dropped by the receive-side filter", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - listener.sendFrame(connectionId, testFrame({ producerEpoch: 8n, sequence: 0n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const latest = await transport.receiveFrame(); - assert.equal(latest.producerEpoch, 8n); - assert.equal(latest.sequence, 0n); - - listener.sendFrame(connectionId, testFrame({ producerEpoch: 7n, sequence: 999n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const staleTimeout = new AbortController(); - const timer = setTimeout(() => staleTimeout.abort(), 300); - await assert.rejects(transport.receiveFrame(staleTimeout.signal)); - clearTimeout(timer); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -// --------------------------------------------------------------------------- -// Trust negatives, through the session manager with a static lookup source. -// --------------------------------------------------------------------------- - -function base64UrlToBase64(value: string): string { - let base64 = value.replace(/-/g, "+").replace(/_/g, "/"); - while (base64.length % 4 !== 0) base64 += "="; - return base64; -} - -let odinRootSequence = 0; - -function generateOdinRoot(): { privateKey: KeyObject; publicKey: CultMeshP256PublicKey } { - const { publicKey, privateKey } = generateKeyPairSync("ec", { namedCurve: "prime256v1" }); - const jwk = publicKey.export({ format: "jwk" }) as { x: string; y: string }; - odinRootSequence += 1; - return { - privateKey, - publicKey: { - keyId: `odin-root-${odinRootSequence}`, - x: base64UrlToBase64(jwk.x), - y: base64UrlToBase64(jwk.y), - }, - }; -} - -interface SignedRouteOptions { - readonly verseId: string; - readonly authorityRuntimeId: string; - readonly endpoint: string; - readonly protocolIds: readonly string[]; - readonly privateKey: KeyObject; - readonly odinKeyId: string; - readonly priority?: number; - readonly generation?: string; - readonly issuedAtUnixMilliseconds?: number; - readonly expiresAtUnixMilliseconds?: number; - readonly providerKey?: CultMeshP256PublicKey; - readonly corruptSignature?: boolean; -} - -function signRoute(options: SignedRouteOptions): CultMeshAuthorityRouteMessage { - const priority = options.priority ?? 0; - const generation = options.generation ?? ""; - const issuedAt = options.issuedAtUnixMilliseconds ?? Date.now() - 60_000; - const expiresAt = options.expiresAtUnixMilliseconds ?? Date.now() + 3_600_000; - const providerKey = options.providerKey ?? { keyId: "provider-1", x: "unused", y: "unused" }; - const view: CultMeshAuthorityRouteView = { - verseId: options.verseId, - authorityRuntimeId: options.authorityRuntimeId, - endpoint: options.endpoint, - protocolIds: options.protocolIds, - priority, - generation, - certificate: { - providerKey, - odinKeyId: options.odinKeyId, - issuedAtUnixMilliseconds: issuedAt, - expiresAtUnixMilliseconds: expiresAt, - signature: "", - }, - }; - const payload = canonicalRoute(view); - const signatureBytes = options.corruptSignature - ? Buffer.alloc(64, 0x41) - : (cryptoSign("sha256", Buffer.from(payload), { key: options.privateKey, dsaEncoding: "ieee-p1363" }) as Buffer); - return { - authorityRuntimeId: options.authorityRuntimeId, - endpoint: options.endpoint, - protocolIds: [...options.protocolIds], - priority, - generation, - certificate: { - providerKeyId: providerKey.keyId, - providerPublicKeyX: providerKey.x, - providerPublicKeyY: providerKey.y, - odinKeyId: options.odinKeyId, - issuedAtUnixMilliseconds: issuedAt, - expiresAtUnixMilliseconds: expiresAt, - signature: signatureBytes.toString("base64"), - }, - }; -} - -function verseWithRoute(verseId: string, route: CultMeshAuthorityRouteMessage): CultMeshVerseDescriptorMessage { - return { - verseId, - displayName: verseId, - authorityModel: "operator-cluster", - compatibility: { transportVersion: "cultmesh.v1", rulesHash: "test", compatibleVerseIds: [], requiredPluginIds: [], optionalPluginIds: [] }, - discoveryEndpoints: [route.endpoint], - authorityRuntimeIds: [route.authorityRuntimeId], - authorityRoutes: [route], - }; -} - -const unreachableConnector: CultMeshRealtimeTransportConnector = { - connectorId: "unreachable", - priority: 0, - canConnect: () => true, - connect: async () => { - throw new Error("a trust-refused route must never reach a connector"); - }, -}; - -test("trust negative (a): an expired certificate is refused", async () => { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const root = generateOdinRoot(); - const route = signRoute({ - verseId: target.verseId, - authorityRuntimeId: target.authorityRuntimeId, - endpoint: "cultmesh-state+quic://127.0.0.1:9443", - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - privateKey: root.privateKey, - odinKeyId: root.publicKey.keyId, - issuedAtUnixMilliseconds: Date.now() - 120_000, - expiresAtUnixMilliseconds: Date.now() - 60_000, - }); - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [root.publicKey] }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, route)]), - trust, - connectors: [unreachableConnector], - }); - await assertRejectsAndDisposes(manager.connect(target), /valid|expired/i); -}); - -test("trust negative (b): an unsigned remote route is refused", async () => { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const route: CultMeshAuthorityRouteMessage = { - authorityRuntimeId: target.authorityRuntimeId, - endpoint: "cultmesh-state+quic://198.51.100.7:9443", - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - priority: 0, - generation: "gen-1", - }; - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [] }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, route)]), - trust, - connectors: [unreachableConnector], - }); - await assertRejectsAndDisposes(manager.connect(target), /Odin-signed/i); -}); - -test("trust negative (c): a route signed by an untrusted Odin root is refused", async () => { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const signer = generateOdinRoot(); - const trustedRoot = generateOdinRoot(); - const route = signRoute({ - verseId: target.verseId, - authorityRuntimeId: target.authorityRuntimeId, - endpoint: "cultmesh-state+quic://127.0.0.1:9443", - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - privateKey: signer.privateKey, - odinKeyId: signer.publicKey.keyId, - }); - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [trustedRoot.publicKey] }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, route)]), - trust, - connectors: [unreachableConnector], - }); - await assertRejectsAndDisposes(manager.connect(target), /not trusted/i); -}); - -test("trust negative (d): a route that verifies but pins the wrong certificate is refused at the transport", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const root = generateOdinRoot(); - const route = signRoute({ - verseId: target.verseId, - authorityRuntimeId: target.authorityRuntimeId, - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${"0".repeat(64)}`, - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - privateKey: root.privateKey, - odinKeyId: root.publicKey.keyId, - }); - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [root.publicKey] }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, route)]), - trust, - connectors: [new CultMeshQuicRealtimeConnector()], - }); - await assertRejectsAndDisposes(manager.connect(target), /certificate|rejected/i); - } finally { - await listener.close(); - } -}); - -test("trust negative (e): a transport that fails isVerifiedFor is disposed and rejected", async () => { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const root = generateOdinRoot(); - const route = signRoute({ - verseId: target.verseId, - authorityRuntimeId: target.authorityRuntimeId, - endpoint: "cultmesh-state+quic://127.0.0.1:9443", - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - privateKey: root.privateKey, - odinKeyId: root.publicKey.keyId, - generation: "route-generation-1", - }); - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [root.publicKey] }; - - let disposed = false; - const staleTransport: CultMeshRealtimeTransport = { - transportId: "msquic-realtime", - endpoint: route.endpoint, - async sendFrame() {}, - async receiveFrame() { - return testFrame(); - }, - dispose() { - disposed = true; - }, - // A replayed/stale generation: the transport proves a different route - // generation than the one the session manager just verified. - isVerifiedFor: () => false, - }; - const staleConnector: CultMeshRealtimeTransportConnector = { - connectorId: "stale", - priority: 0, - canConnect: () => true, - connect: async () => staleTransport, - }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, route)]), - trust, - connectors: [staleConnector], - }); - - await assertRejectsAndDisposes(manager.connect(target), /did not prove|No realtime state path/i); - assert.equal(disposed, true, "the session manager must dispose a transport that fails isVerifiedFor"); -}); - -test("M3: a real connected transport's isVerifiedFor rejects a generation other than the one it connected with", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "route-generation-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const transport = await connector.connect(candidate, target); - try { - assert.equal( - transport.isVerifiedFor(target.verseId, target.authorityRuntimeId, CULTMESH_REALTIME_STATE_PROTOCOL_ID, "route-generation-1"), - true, - "the generation it actually connected with must verify", - ); - assert.equal( - transport.isVerifiedFor(target.verseId, target.authorityRuntimeId, CULTMESH_REALTIME_STATE_PROTOCOL_ID, "route-generation-2"), - false, - "a mutated/replayed generation must not verify against a real transport", - ); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("trust negative (e2): a real transport whose generation no longer matches the freshly verified route is disposed", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const root = generateOdinRoot(); - const signedRoute = signRoute({ - verseId: target.verseId, - authorityRuntimeId: target.authorityRuntimeId, - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - privateKey: root.privateKey, - odinKeyId: root.publicKey.keyId, - generation: "route-generation-1", - }); - const trust: CultMeshAuthorityTrustPolicy = { mode: "authenticated-remote", odinRoots: [root.publicKey] }; - const realConnector = new CultMeshQuicRealtimeConnector(); - let connectedTransport: CultMeshRealtimeTransport | undefined; - // A real transport, connected for real against the raw listener, but - // stamped with a generation different from the one the session manager - // just verified — the way a stale cached transport would look after its - // route rotated underneath it. - const replayConnector: CultMeshRealtimeTransportConnector = { - connectorId: "replay", - priority: 0, - canConnect: (c) => realConnector.canConnect(c), - connect: async (c, t, signal) => { - const accepted = listener.acceptOnce(); - const transport = await realConnector.connect({ ...c, generation: "route-generation-1-stale" }, t, signal); - await accepted; - connectedTransport = transport; - return transport; - }, - }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoute(target.verseId, signedRoute)]), - trust, - connectors: [replayConnector], - }); - - await assertRejectsAndDisposes(manager.connect(target), /did not prove|No realtime state path/i); - assert.ok(connectedTransport, "a real transport must have connected"); - // Real cleanup ran: receiveFrame on the disposed transport rejects. - await assert.rejects(connectedTransport!.receiveFrame(), /disposed/i); - } finally { - await listener.close(); - } -}); - -test("the advertised certificate pin is matched case-insensitively (M2)", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex().toUpperCase()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const transport = await connector.connect(candidate, target); - transport.dispose(); - } finally { - await listener.close(); - } -}); - -// --------------------------------------------------------------------------- -// Fix batch: pump/dispatch isolation (1), peer-shutdown cleanup (3), the -// bounded receive backlog and stream-kind pruning (6). -// --------------------------------------------------------------------------- - -test("fix 1 / M4: a stream-kind/delivery mismatch faults only that connection; the pump keeps running", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const endpoint = (): string => `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`; - - // A reliable stream carrying a frame whose own delivery byte says - // latest-only: `onStreamFrame` throws, which must fault only this - // connection. - const connectorA = new CultMeshQuicRealtimeConnector(); - const acceptedA = listener.acceptOnce(); - const transportA = await connectorA.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - try { - const connectionIdA = await acceptedA; - listener.sendFrame(connectionIdA, testFrame({ delivery: "latest-only" }), CULTMESH_QUIC_STREAM_RELIABLE); - // Bounded: if the mismatch check regresses (never faults), receiveFrame() - // waits forever for a frame that will not arrive, and a bare - // `assert.rejects` would hang this test, and the whole file, right along - // with it (as M4 did before this bound existed). - await assert.rejects(receiveFrameOrTimeout(transportA), /incompatible delivery semantics/i); - // Future receives on the faulted transport reject immediately, with the - // same error, rather than hanging. - await assert.rejects(receiveFrameOrTimeout(transportA), /incompatible delivery semantics/i); - } finally { - transportA.dispose(); - } - - // A second, independent connection through the same process-wide runtime - // and pump must still work: the fault above did not bring it down. - const connectorB = new CultMeshQuicRealtimeConnector(); - const acceptedB = listener.acceptOnce(); - const transportB = await connectorB.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - try { - const connectionIdB = await acceptedB; - listener.sendFrame(connectionIdB, testFrame(), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const received = await transportB.receiveFrame(); - assert.equal(received.bodyId, "body:aetheria:entities"); - } finally { - transportB.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("M4b: a latest-only stream carrying a reliable-ordered frame faults only that connection", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const endpoint = (): string => `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`; - - // The mirror image of the M4 test above: a latest-only stream carrying - // a frame whose own delivery byte says reliable-ordered. - const connectorA = new CultMeshQuicRealtimeConnector(); - const acceptedA = listener.acceptOnce(); - const transportA = await connectorA.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - try { - const connectionIdA = await acceptedA; - listener.sendFrame(connectionIdA, testFrame({ delivery: "reliable-ordered" }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - await assert.rejects(receiveFrameOrTimeout(transportA), /incompatible delivery semantics/i); - } finally { - transportA.dispose(); - } - - // A second, independent connection still works. - const connectorB = new CultMeshQuicRealtimeConnector(); - const acceptedB = listener.acceptOnce(); - const transportB = await connectorB.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - try { - const connectionIdB = await acceptedB; - listener.sendFrame(connectionIdB, testFrame(), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const received = await transportB.receiveFrame(); - assert.equal(received.bodyId, "body:aetheria:entities"); - } finally { - transportB.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("fix 1: a throwing onDisposed handler cannot crash the pump when a malformed frame faults a connection", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const endpoint = (): string => `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`; - - const connectorA = new CultMeshQuicRealtimeConnector(); - const acceptedA = listener.acceptOnce(); - const transportA = await connectorA.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - // A throwing onDisposed handler, registered before the fault: fix 1 - // must run it inside its own try/catch so it cannot escape cleanup(), - // and must have already released the runtime reference regardless. - let secondHandlerRan = false; - transportA.onDisposed?.(() => { - throw new Error("first onDisposed handler throws on purpose"); - }); - transportA.onDisposed?.(() => { - secondHandlerRan = true; - }); - - try { - const connectionIdA = await acceptedA; - // Random bytes on a reliable stream: not a valid encoded frame, so - // decodeRealtimeFrame throws inside onStreamFrame, which native's - // dispatch loop (fix 1's native half) catches and faults only this - // connection. Bounded: if the fault path regresses and never faults - // this connection, receiveFrame() would otherwise wait forever for a - // frame that will not arrive. - listener.sendRaw(connectionIdA, new Uint8Array([9, 9, 9, 9, 9, 9, 9, 9]), CULTMESH_QUIC_STREAM_RELIABLE); - await assert.rejects(receiveFrameOrTimeout(transportA)); - assert.equal(secondHandlerRan, true, "a throwing handler must not stop the next onDisposed handler from running"); - } finally { - transportA.dispose(); - } - - // The process (and this test file's pump) survives, and a second, - // independent connection through the same runtime still works. - const connectorB = new CultMeshQuicRealtimeConnector(); - const acceptedB = listener.acceptOnce(); - const transportB = await connectorB.connect( - { endpoint: endpoint(), authorityRuntimeId: target.authorityRuntimeId, priority: 0, generation: "gen-1" }, - target, - ); - try { - const connectionIdB = await acceptedB; - listener.sendFrame(connectionIdB, testFrame(), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const received = await transportB.receiveFrame(); - assert.equal(received.bodyId, "body:aetheria:entities"); - } finally { - transportB.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("fix 1: a throwing onDisposed handler on a peer shutdown still releases the runtime and runs every handler", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - - let secondHandlerRan = false; - transport.onDisposed?.(() => { - throw new Error("first onDisposed handler throws on purpose"); - }); - transport.onDisposed?.(() => { - secondHandlerRan = true; - }); - - const before = CultMeshQuicNativeRuntime.refCount; - listener.shutdownConnection(connectionId); - // Wait for cleanup() to run (driven by the pump's CONNECTION_SHUTDOWN - // dispatch), rather than asserting immediately. Bounded: if the - // shutdown-cleanup path regresses (F3) and never rejects, this would - // otherwise hang instead of failing the assertion below it. - await assert.rejects(receiveFrameOrTimeout(transport)); - assert.equal( - CultMeshQuicNativeRuntime.refCount, - before - 1, - "the runtime reference must be released even though a handler threw", - ); - assert.equal(secondHandlerRan, true, "every onDisposed handler must still run despite an earlier one throwing"); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("M10: an equal generation delivered after the first was already consumed is dropped, not redelivered", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - - // Send one frame and consume it, so the coalescer no longer holds - // anything pending for this key: the generation filter's own record - // (`latestGenerations`) is the only thing left that could still know - // this generation was already seen. Sending a frame back-to-back with - // an unconsumed duplicate would mask a broken filter behind the - // coalescer overwriting the pending value with an identical one; this - // sequencing is what M10 needs to be observable at all (Soul's note). - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 3n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const first = await transport.receiveFrame(); - assert.equal(first.sequence, 3n); - - // The exact same generation, sent again after consumption: the - // filter must drop it outright rather than deliver it as new. - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 3n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - await new Promise((resolve) => setTimeout(resolve, 200)); - - const timeout = new AbortController(); - const timer = setTimeout(() => timeout.abort(), 300); - await assert.rejects( - transport.receiveFrame(timeout.signal), - "an equal generation already consumed must not be redelivered", - ); - clearTimeout(timer); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -// F7 ("a canceled send must not resolve as success") is covered in -// realtime-quic-native.test.ts, at the native binding layer, not here. -// A consumer-level scenario was attempted first: prime the reliable stream, -// start a second send, and shut the connection down from the peer mid-flight. -// It proved unreliable on this host regardless of payload size or added -// delay before the shutdown call — MsQuic here appears to accept and locally -// complete a `StreamSend` (marking it as a plain, non-canceled -// SEND_COMPLETE) faster than any JS-observable window can reliably land a -// shutdown ahead of it, and a delay long enough to guarantee the shutdown -// wins just lets the send finish first instead. This is recorded as not yet -// reached at the consumer layer, not as unreachable: the native-layer test -// asserts the exact field (`code`, decoded through the same struct decode -// F7 mutates) that this scenario would also exercise, so the fix itself is -// defended; only the end-to-end SEND_CANCELED proof through the consumer's -// own `sendFrame()` promise is the open gap. - -test("fix 3: a peer-initiated shutdown rejects a pending receive and cleans up exactly once", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - - // Bounded: this is F3's own mutant target (removing the - // CONNECTION_SHUTDOWN cleanup call), and a broken cleanup path means - // this receive never settles. - const pendingReceive = receiveFrameOrTimeout(transport); - listener.shutdownConnection(connectionId); - await assert.rejects(pendingReceive, /closed by the remote peer/i); - - // Cleanup already ran: a further explicit dispose is a harmless no-op, - // and a fresh receive rejects immediately instead of hanging forever - // (the leak fix 3 exists for). - transport.dispose(); - await assert.rejects(receiveFrameOrTimeout(transport), /closed by the remote peer/i); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("fix 6: a slow latest-only reader accumulates at most one pending frame per key, and an equal generation is dropped", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - - // Three increasing-sequence frames for the same (channel, body), - // published while nothing reads: an unbounded queue would deliver all - // three in order; the coalescing inbox keeps only the newest. - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 1n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 2n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 3n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - // An equal generation, sent last: it must be dropped outright, not - // queued as a fourth pending frame. - listener.sendFrame(connectionId, testFrame({ producerEpoch: 1n, sequence: 3n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - - // Give the pump time to process all four sends before reading. - await new Promise((resolve) => setTimeout(resolve, 200)); - - const first = await transport.receiveFrame(); - assert.equal(first.sequence, 3n, "only the newest pending frame for the key is kept"); - - const timeout = new AbortController(); - const timer = setTimeout(() => timeout.abort(), 300); - await assert.rejects(transport.receiveFrame(timeout.signal), "nothing else should be pending"); - clearTimeout(timer); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("fix 6: a stream shutdown prunes its entry so streamKinds does not grow without bound", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const accepted = listener.acceptOnce(); - const transport = await connector.connect(candidate, target); - try { - const connectionId = await accepted; - listener.sendFrame(connectionId, testFrame(), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const received = await transport.receiveFrame(); - assert.equal(received.sequence, 1n); - - // The server-side stream the frame arrived on is a fresh latest-only - // stream the listener opened and finished with `fin: true`; the native - // bridge emits its own shutdown event once MsQuic completes teardown. - // Wait for that STREAM_SHUTDOWN to actually land, then assert the - // internal map was pruned, not just that a second frame still works - // (F6kinds's removed prune line has no behavioural symptom until a - // stream id is reused, which QUIC never does within one connection). - await new Promise((resolve) => setTimeout(resolve, 300)); - assert.equal( - (transport as CultMeshQuicRealtimeTransport).trackedStreamCount, - 0, - "streamKinds must be pruned once the stream shuts down, not accumulate one entry per stream", - ); - - listener.sendFrame(connectionId, testFrame({ sequence: 2n }), CULTMESH_QUIC_STREAM_LATEST_ONLY); - const second = await transport.receiveFrame(); - assert.equal(second.sequence, 2n); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); - -test("P8: a reliable send still queued behind reliableSendTail rejects instead of hanging when disposal wins the race", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const listener = await RawQuicListener.open(); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: `cultmesh-state+quic://127.0.0.1:${listener.boundPort}?cert-sha256=${fixturePinHex()}`, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - const transport = await connector.connect(candidate, target); - try { - // Prime the reliable outbound stream and let it fully settle, so its - // id is already cached: a second reliable send then chains straight - // onto `sendOnStream` with no `streamOpen` call of its own in between - // (a `streamOpen` against an already-shut-down connection fails with - // its own native error, which would mask the guard this test targets). - await transport.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 1n })); - - // `sendFrame` chains onto `reliableSendTail`, which resolves as a - // microtask; calling `dispose()` synchronously right after, in the - // same turn, guarantees `cleanup()` has already set `disposed = true` - // by the time that microtask runs `sendOnStream`. Without the - // `this.disposed` guard `sendOnStream` registers (P8's target), this - // send would sit in `pendingSends` forever: `cleanup()`'s reject sweep - // already ran once before this send was ever registered, and no later - // native event can reach it either, since `offConnectionEvent` already - // ran too. - const send = transport.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 2n })); - transport.dispose(); - // Bounded: without the guard, `send` never settles (nothing left to - // reject it), so a bare `assert.rejects(send, ...)` would hang this - // whole file instead of failing this one test by assertion. Racing - // against a timeout that rejects with a different message turns a - // regression into a prompt, loud assertion mismatch. - const bounded = Promise.race([ - send, - new Promise((_, reject) => - setTimeout(() => reject(new Error("P8 guard timed out instead of rejecting")), 3_000), - ), - ]); - await assert.rejects(bounded, /disposed/i); - } finally { - transport.dispose(); - } - } finally { - await listener.close(); - } -}); diff --git a/packages/cultmesh-ts/test/realtime-quic-native.test.ts b/packages/cultmesh-ts/test/realtime-quic-native.test.ts deleted file mode 100644 index 039d9047..00000000 --- a/packages/cultmesh-ts/test/realtime-quic-native.test.ts +++ /dev/null @@ -1,388 +0,0 @@ -// The Cut 3 FFI smoke, now run against `CultMeshQuicNativeRuntime` instead of -// raw koffi calls: open a runtime, open a listener with a real credential, -// connect a real loopback connection, exchange one frame's worth of raw -// bytes, and close everything down. This proves the binding's declared ABI -// matches the shipped bridge; frame semantics (delivery, generation) are -// `realtime-quic-consumer.test.ts`'s job. -// -// Skips instead of failing when no native bridge is available: set -// CULTMESH_QUIC_NATIVE_DIR to a directory `scripts/build-quic-native.ps1` or -// `scripts/build-quic-native.sh` built, or run from the committed -// `packages/cultmesh-ts/native/` tree once a later cut lands it. - -import assert from "node:assert/strict"; -import { spawnSync } from "node:child_process"; -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import test from "node:test"; - -import { - CultMeshQuicNativeRuntime, - CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION, - CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED, - CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED, - CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN, - CULTMESH_QUIC_EVENT_STREAM_STARTED, - CULTMESH_QUIC_EVENT_STREAM_FRAME, - CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE, - CULTMESH_QUIC_STREAM_RELIABLE, -} from "../src/realtime-quic-native"; -import { nativeBridgeAvailable } from "./support/native-bridge"; - -// __dirname at runtime is dist-test/test; fixtures are binary and are never -// compiled/copied there, so they are read from their source location, two -// levels up. -const FIXTURE_P12 = join(__dirname, "..", "..", "test", "fixtures", "quic-test.p12"); - -async function waitFor(collect: (resolve: (value: T) => void) => void, timeoutMs = 5_000): Promise { - return await new Promise((resolve, reject) => { - const timer = setTimeout(() => reject(new Error("timed out waiting for a native QUIC event")), timeoutMs); - collect((value) => { - clearTimeout(timer); - resolve(value); - }); - }); -} - -test("CultMeshQuicNativeRuntime opens and closes with no listener or connection", async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - await runtime.release(); -}); - -test("CultMeshQuicNativeRuntime opens and closes a listener with a real PKCS12 credential", async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - try { - const pkcs12 = readFileSync(FIXTURE_P12); - const { listenerId, boundPort } = runtime.listenerOpen("127.0.0.1", 0, pkcs12, ""); - assert.ok(boundPort > 0); - runtime.listenerClose(listenerId); - } finally { - await runtime.release(); - } -}); - -test("a full loopback connection delivers one raw frame end to end", async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - try { - const pkcs12 = readFileSync(FIXTURE_P12); - const { listenerId, boundPort } = runtime.listenerOpen("127.0.0.1", 0, pkcs12, ""); - - const accepted = waitFor((resolve) => { - runtime.onListenerEvent(listenerId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) resolve(event.connectionId); - }); - }); - - const clientConnectionId = runtime.connectionOpen("127.0.0.1", boundPort); - const clientConnected = waitFor((resolve) => { - runtime.onConnectionEvent(clientConnectionId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED) { - runtime.connectionCertificateComplete(clientConnectionId, true); - return; - } - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED) resolve(); - }); - }); - - const serverConnectionId = await accepted; - const serverFrame = waitFor((resolve) => { - runtime.onConnectionEvent(serverConnectionId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_STREAM_STARTED) { - assert.equal(event.streamKind, CULTMESH_QUIC_STREAM_RELIABLE); - return; - } - if (event.type === CULTMESH_QUIC_EVENT_STREAM_FRAME) resolve(event.payload); - }); - }); - - await clientConnected; - const streamId = runtime.streamOpen(clientConnectionId, CULTMESH_QUIC_STREAM_RELIABLE); - const sendComplete = waitFor((resolve) => { - runtime.onConnectionEvent(clientConnectionId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_STREAM_SEND_COMPLETE) resolve(); - }); - }); - runtime.streamSendFrame(streamId, new Uint8Array([1, 2, 3, 4]), true); - await sendComplete; - - const payload = await serverFrame; - assert.deepEqual(Array.from(payload), [1, 2, 3, 4]); - - runtime.connectionShutdown(clientConnectionId, 0n); - runtime.connectionShutdown(serverConnectionId, 0n); - runtime.listenerClose(listenerId); - } finally { - await runtime.release(); - } -}); - -test("F7: a 64-bit event code round-trips exactly through the struct decode", async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - try { - const pkcs12 = readFileSync(FIXTURE_P12); - const { listenerId, boundPort } = runtime.listenerOpen("127.0.0.1", 0, pkcs12, ""); - - // `code` (a `uint64_t`, the same field `CULTMESH_QUIC_SEND_CANCELED` is - // compared against on the stream-send path) is exercised here through - // CONNECTION_SHUTDOWN instead, whose code is an application-chosen value - // this test fully controls: two values above 2^53 (where koffi's decode - // stops being a plain safe-integer `number`) prove the whole - // encode-native-decode-coerce path is exact, deterministically, with no - // dependency on MsQuic's own send-completion timing. - for (const code of [(1n << 53n) + 1n, (1n << 62n) - 1n]) { - const accepted = waitFor((resolve) => { - runtime.onListenerEvent(listenerId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) resolve(event.connectionId); - }); - }); - const clientConnectionId = runtime.connectionOpen("127.0.0.1", boundPort); - const clientConnected = waitFor((resolve) => { - runtime.onConnectionEvent(clientConnectionId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED) { - runtime.connectionCertificateComplete(clientConnectionId, true); - return; - } - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED) resolve(); - }); - }); - const serverConnectionId = await accepted; - await clientConnected; - - const seenOnClient = waitFor((resolve) => { - runtime.onConnectionEvent(clientConnectionId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_SHUTDOWN) resolve(event.code); - }); - }); - runtime.connectionShutdown(serverConnectionId, code); - const seen = await seenOnClient; - assert.equal(typeof seen, "bigint", "a decoded event code must always be bigint, never number"); - assert.equal(seen, code, `shutdown code ${code} must round-trip exactly through the struct decode`); - } - - runtime.listenerClose(listenerId); - } finally { - await runtime.release(); - } -}); - -test( - "P10b: a throwing onFault handler is isolated — the pump survives and other connections' handlers still run", - { timeout: 10_000 }, - async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - try { - const pkcs12 = readFileSync(FIXTURE_P12); - const { listenerId, boundPort } = runtime.listenerOpen("127.0.0.1", 0, pkcs12, ""); - - // Connection B: a normal, fully connected loopback pair, established - // before A ever faults — so proving B still works afterward exercises - // an already-running connection's handler, not a second accept cycle - // racing whatever state A's fault left behind. - const acceptedB = waitFor((resolve) => { - runtime.onListenerEvent(listenerId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) resolve(event.connectionId); - }); - }); - const clientB = runtime.connectionOpen("127.0.0.1", boundPort); - const clientBConnected = waitFor((resolve) => { - runtime.onConnectionEvent(clientB, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED) { - runtime.connectionCertificateComplete(clientB, true); - return; - } - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CONNECTED) resolve(); - }); - }); - const serverBId = await acceptedB; - const serverBFrame = waitFor((resolve) => { - runtime.onConnectionEvent(serverBId, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_STREAM_FRAME) resolve(event.payload); - }); - }); - await clientBConnected; - - // Connection A, opened only after B is fully connected: both its - // listener and its onFault handler throw on the first event delivered - // to it. Without `faultConnection`'s own try/catch isolating a - // throwing `onFault` (P10b's target), that throw would escape the - // pump's dispatch loop and take every other connection — including - // the already-live B — down with it, instead of staying scoped to A. - // - // The server-side connection listener is registered synchronously, - // inside the LISTENER_NEW_CONNECTION callback itself, rather than - // after an `await`: the native bridge can dispatch a connection's next - // event (CERTIFICATE_RECEIVED, or CONNECTED) before a later `await`'s - // continuation ever runs, and an event with no listener registered for - // its connection id is silently dropped (`dispatch`'s own - // `if (!entry) return`) — the same async-registration gap fix 1 closed - // for the provider's own accept path. - const serverAFaulted = waitFor((resolve) => { - runtime.onListenerEvent(listenerId, (event) => { - if (event.type !== CULTMESH_QUIC_EVENT_LISTENER_NEW_CONNECTION) return; - runtime.onConnectionEvent( - event.connectionId, - () => { - throw new Error("P10b: connection A's listener always throws."); - }, - () => { - resolve(); - throw new Error("P10b: connection A's onFault also throws."); - }, - ); - }); - }); - const clientA = runtime.connectionOpen("127.0.0.1", boundPort); - runtime.onConnectionEvent(clientA, (event) => { - if (event.type === CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED) { - runtime.connectionCertificateComplete(clientA, true); - } - }); - await serverAFaulted; - - // Prove B's handler is still live after A's onFault threw: send a - // frame on B and confirm the server side still receives it. - const streamId = runtime.streamOpen(clientB, CULTMESH_QUIC_STREAM_RELIABLE); - runtime.streamSendFrame(streamId, new Uint8Array([9, 9, 9]), true); - const payload = await serverBFrame; - assert.deepEqual( - Array.from(payload), - [9, 9, 9], - "connection B must still deliver frames after A's onFault threw", - ); - - runtime.connectionShutdown(clientA, 0n); - runtime.connectionShutdown(clientB, 0n); - runtime.connectionShutdown(serverBId, 0n); - runtime.listenerClose(listenerId); - } finally { - await runtime.release(); - } - }, -); - -test("fix 2: release() refuses a call with no outstanding reference", async (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - const runtime = await CultMeshQuicNativeRuntime.open(); - await runtime.release(); - await assert.rejects(runtime.release(), /no outstanding reference/i); -}); - -test("negative grep: no koffi callbacks, .async only on nextEvent", () => { - // __dirname at runtime is dist-test/test; the source lives two levels up, - // in src/, since only .js output is mirrored under dist-test. - const source = readFileSync(join(__dirname, "..", "..", "src", "realtime-quic-native.ts"), "utf8"); - // `.async` is referenced (not necessarily called with a literal "(" at the - // reference site: it is handed to `promisify`, which calls it) only for - // `nextEvent`, the ABI's single blocking export. - const asyncUses = [...source.matchAll(/\.async\b/g)]; - assert.ok(asyncUses.length > 0, "expected at least one .async use for nextEvent"); - for (const match of asyncUses) { - const before = source.slice(Math.max(0, match.index! - 40), match.index!); - assert.match(before, /nextEvent/i, "the only .async reference must be nextEvent"); - } - assert.doesNotMatch(source, /koffi\.register/, "no koffi callbacks"); -}); - -// The measurement below runs in its own `node --expose-gc` child process -// instead of in this test's own process: by the time this test would run, -// ~150 earlier tests in the suite have already grown and partly freed the -// glibc heap, so a real per-call native leak can land in already-mapped free -// space and never show up as RSS growth in *this* process (confirmed by hand: -// the in-process version of this test passed even with `nextEvent` mutated -// back to allocating fresh koffi buffers every call). A freshly spawned -// process has no such history, matching the ~8 MiB (fixed) vs ~30 MiB -// (pre-fix) split measured in isolation. -const MEMORY_PROBE_SCRIPT = ` -const { CultMeshQuicNativeRuntime } = require(process.argv[1]); -(async () => { - const runtime = await CultMeshQuicNativeRuntime.open(); - const nextEvent = runtime.nextEvent.bind(runtime); - try { - for (let i = 0; i < 2000; i += 1) await nextEvent(0, null, 0); - global.gc(); - const before = process.memoryUsage().rss; - const ITERATIONS = 200000; - for (let i = 0; i < ITERATIONS; i += 1) await nextEvent(0, null, 0); - global.gc(); - const after = process.memoryUsage().rss; - process.stdout.write(JSON.stringify({ before, after, growthBytes: after - before, ITERATIONS })); - } finally { - await runtime.release(); - } -})().catch((error) => { - console.error(error); - process.exit(1); -}); -`; - -test( - "memory: sustained nextEvent calls do not leak koffi-allocated out-parameter buffers", - { timeout: 60_000 }, - (t) => { - if (!nativeBridgeAvailable()) { - t.skip("CULTMESH_QUIC_NATIVE_DIR is not set to a built native bridge."); - return; - } - - // `nextEvent` is private; the compiled module path is resolved the same - // way this file's own `import` resolves it, and handed to the child by - // argv so the child needs no path logic of its own. - const modulePath = require.resolve("../src/realtime-quic-native"); - const result = spawnSync(process.execPath, ["--expose-gc", "-e", MEMORY_PROBE_SCRIPT, modulePath], { - encoding: "utf8", - env: process.env, - }); - if (result.status !== 0 || typeof result.stdout !== "string" || result.stdout.trim().length === 0) { - if (/--expose-gc/.test(result.stderr ?? "")) { - t.skip("this Node build does not support --expose-gc."); - return; - } - assert.fail( - `memory probe child process failed (status ${String(result.status)}):\n${result.stderr ?? "(no stderr)"}`, - ); - } - - const { before, after, growthBytes, ITERATIONS } = JSON.parse(result.stdout.trim()) as { - before: number; - after: number; - growthBytes: number; - ITERATIONS: number; - }; - // Measured on Yggdrasil, same build and host, in a dedicated process: - // fixed code (0 `koffi.alloc` calls in the loop): ~8.0 MiB RSS growth. - // pre-fix code (400k `koffi.alloc` calls, never freed): ~29.9 MiB. - // 18 MiB sits well above the fixed baseline and well below the leaking - // one, so the bound stays robust to ordinary run-to-run noise while - // still catching the regression. - const BOUND_BYTES = 18 * 1024 * 1024; - assert.ok( - growthBytes < BOUND_BYTES, - `RSS grew by ${growthBytes} bytes (${(growthBytes / 1024 / 1024).toFixed(2)} MiB, from ${before} to ${after}) ` + - `over ${ITERATIONS} nextEvent calls; expected it to stay under ${BOUND_BYTES / 1024 / 1024} MiB once ` + - "out-parameter buffers are reused instead of allocated per call.", - ); - }, -); diff --git a/packages/cultmesh-ts/test/realtime-quic-provider.test.ts b/packages/cultmesh-ts/test/realtime-quic-provider.test.ts deleted file mode 100644 index 8a541641..00000000 --- a/packages/cultmesh-ts/test/realtime-quic-provider.test.ts +++ /dev/null @@ -1,1083 +0,0 @@ -// `CultMeshQuicRealtimeProvider`, Cut 5's StreamPixels role, exercised -// end-to-end against the real native bridge and the real consumer connector -// from Cut 4 (no mocks): reliable ordering in both directions -// (`CultMeshQuicRealtimeTransportTests.cs:71-110`), latest-only coalescing -// per `(channel, body)` key, a non-blocking broadcast, the uppercase pin, and -// eviction on peer shutdown. -// -// Skips instead of failing when no native bridge is available; see -// `realtime-quic-native.test.ts` for why. - -import assert from "node:assert/strict"; -import { readFileSync } from "node:fs"; -import { join } from "node:path"; -import test from "node:test"; - -import { - CultMeshQuicNativeRuntime, -} from "../src/realtime-quic-native"; -import { - CultMeshQuicRealtimeConnector, - CultMeshQuicRealtimeProvider, - CultMeshQuicRealtimeTransport as CultMeshQuicRealtimeTransportClass, - parseQuicRealtimeEndpoint, - type CultMeshRealtimeCandidate, - type CultMeshRealtimeTarget, - type CultMeshRealtimeTransport, -} from "../src/realtime-quic"; -import type { CultMeshRealtimeFrame } from "../src/realtime-wire"; -import { nativeBridgeAvailable } from "./support/native-bridge"; - -// __dirname at runtime is dist-test/test; fixtures are binary and are never -// compiled/copied there, so they are read from their source location, two -// levels up. -const FIXTURE_P12 = join(__dirname, "..", "..", "test", "fixtures", "quic-test.p12"); - -/** - * `assert.rejects`, but safe against a mutant or a real regression that - * makes the promise resolve instead: a transport that unexpectedly connects - * is disposed before the assertion fails, so a broken certificate check - * cannot hang this file the way M1 did before realtime-quic-consumer.test.ts - * gained this same helper. - */ -async function assertRejectsAndDisposes( - promise: Promise<{ dispose(): void }>, - match?: RegExp, -): Promise { - let resolved: { dispose(): void } | undefined; - try { - resolved = await promise; - } catch (error) { - if (match) assert.match(error instanceof Error ? error.message : String(error), match); - return; - } - resolved.dispose(); - assert.fail("expected the promise to reject, but it resolved (the resolved value has been disposed)"); -} - -function testFrame(overrides: Partial = {}): CultMeshRealtimeFrame { - return { - channelId: "aetheria.entities", - schemaId: "eve.entity_soa.v1", - bodyId: "body:aetheria:entities", - producerEpoch: 7n, - sequence: 1n, - delivery: "latest-only", - payload: new Uint8Array([3, 4, 5]), - ...overrides, - }; -} - -async function startProvider(): Promise { - return await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - }); -} - -async function dialProvider(provider: CultMeshQuicRealtimeProvider): Promise { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - endpoint: provider.advertisedEndpoint, - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - return await connector.connect(candidate, target); -} - -async function waitUntil(predicate: () => boolean, timeoutMs = 5_000): Promise { - const deadline = Date.now() + timeoutMs; - while (!predicate()) { - if (Date.now() >= deadline) throw new Error("timed out waiting for a provider condition"); - await new Promise((resolve) => setTimeout(resolve, 10)); - } -} - -/** - * Waits for `CultMeshQuicNativeRuntime.refCount` to stop moving: `dispose()` - * releases its runtime reference fire-and-forget (`void this.runtime.release()`), - * so a just-finished test's cleanup can still be landing when the next test - * starts. A test that snapshots refCount as a baseline without waiting for - * this first can catch that in-flight decrement mid-test and see refCount - * undershoot its own "before" value instead of returning to it. - */ -async function waitForRefCountToStabilize(quietMs = 200, timeoutMs = 5_000): Promise { - const deadline = Date.now() + timeoutMs; - let last = CultMeshQuicNativeRuntime.refCount; - let stableSince = Date.now(); - for (;;) { - await new Promise((resolve) => setTimeout(resolve, 20)); - const current = CultMeshQuicNativeRuntime.refCount; - if (current !== last) { - last = current; - stableSince = Date.now(); - } else if (Date.now() - stableSince >= quietMs) { - return current; - } - if (Date.now() >= deadline) return current; - } -} - -test("the advertised endpoint carries an uppercase cert-sha256 pin the Unity connector requires", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - assert.match( - provider.advertisedEndpoint, - /^cultmesh-state\+quic:\/\/127\.0\.0\.1:\d+\?cert-sha256=[0-9A-F]{64}$/, - ); - // Not merely uppercase-tolerant: it must not contain a lowercase hex digit. - const pin = new URL(provider.advertisedEndpoint).searchParams.get("cert-sha256")!; - assert.equal(pin, pin.toUpperCase()); - assert.notEqual(pin, pin.toLowerCase()); - } finally { - provider.dispose(); - } -}); - -test("reliable-ordered delivers frames in order, provider to consumer and consumer to provider", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 1n })); - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 2n })); - const firstAtConsumer = await consumer.receiveFrame(); - const secondAtConsumer = await consumer.receiveFrame(); - assert.deepEqual([firstAtConsumer.sequence, secondAtConsumer.sequence], [1n, 2n]); - - await consumer.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 3n })); - await consumer.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 4n })); - const firstAtProvider = await provider.receive(); - const secondAtProvider = await provider.receive(); - assert.deepEqual([firstAtProvider.sequence, secondAtProvider.sequence], [3n, 4n]); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("latest-only broadcast coalesces back-to-back sends for the same key to the newest frame, and never blocks on I/O", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // Three broadcasts for the same (channelId, bodyId) key, issued back to - // back with no await between them. `broadcast` for latest-only never - // awaits any I/O (mutating it to await the peer's send would make this - // loop, and the assertion below, run after real network round trips - // instead of within one JS turn): the synchronous middle publish is - // therefore always coalesced away, deterministically, not by luck of - // network timing. Mutating the coalescing key (e.g. dropping bodyId) - // would let sequence 200 leak through as a separate delivered frame - // instead of overwriting 100. - const before = Date.now(); - const first = provider.broadcast(testFrame({ sequence: 1n })); - const second = provider.broadcast(testFrame({ sequence: 100n })); - const third = provider.broadcast(testFrame({ sequence: 200n })); - const afterCallsReturned = Date.now(); - // All three promises exist before any of them could possibly have - // waited on the peer's round trip: the loop above ran in well under a - // network round trip's worth of time. - assert.ok(afterCallsReturned - before < 50, "broadcast must not block on any peer's I/O"); - await Promise.all([first, second, third]); - - // The consumer's own receive-side inbox (Cut 4) also coalesces - // latest-only frames it has not yet read, so whether 1 is delivered as - // its own frame or is itself coalesced away by 200 arriving first - // depends on read timing; that is Cut 4's contract, not this test's. - // What this test owns is the provider's outbox: 100 must never appear, - // and the last frame delivered must be 200. - const received: bigint[] = []; - let last: bigint | undefined; - while (last !== 200n) { - const frame = await consumer.receiveFrame(); - received.push(frame.sequence); - last = frame.sequence; - } - assert.ok(!received.includes(100n), `100 must be coalesced away, got ${received}`); - assert.ok(received.length <= 2, `expected at most 2 delivered frames, got ${received}`); - assert.equal(last, 200n); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("a stalled peer's outbox holds at most one pending frame per key across many broadcasts", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // 200 broadcasts, none awaited individually, none read by the consumer - // until they are all issued: mirrors the interop lane's stalled-reader - // scenario at unit-test speed. `broadcast` completing this loop at all - // (bounded time) proves it never blocks on the unread peer. - const started = Date.now(); - const sends: Promise[] = []; - for (let sequence = 1; sequence <= 200; sequence += 1) { - sends.push(provider.broadcast(testFrame({ sequence: BigInt(sequence) }))); - } - await Promise.all(sends); - assert.ok(Date.now() - started < 2_000, "200 broadcasts to one key must complete quickly, unread"); - - const receivedSequences: bigint[] = []; - let last: bigint | undefined; - while (last !== 200n) { - const frame = await consumer.receiveFrame(); - receivedSequences.push(frame.sequence); - last = frame.sequence; - } - assert.equal(last, 200n); - // Coalescing means far fewer than 200 frames were actually put on the - // wire; the exact count depends on scheduling, but it must be small. - assert.ok(receivedSequences.length < 200, `expected coalescing, got ${receivedSequences.length} frames`); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test( - "20,000 client latest-only frames on one key leave at most 1 pending in the provider's receive queue", - { timeout: 120_000 }, - async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // The exact scenario Soul's probe reproduced against the unbounded - // `readyFrames` array this replaced: a publish-only StreamPixels-style - // consumer of `receive()` never drains the provider's fan-in queue, - // so a client hammering one key must not be able to grow it past one - // entry no matter how many frames it sends. - const total = 20_000; - const sends: Promise[] = []; - for (let sequence = 1; sequence <= total; sequence += 1) { - sends.push(consumer.sendFrame(testFrame({ delivery: "latest-only", sequence: BigInt(sequence) }))); - } - await Promise.all(sends); - await waitUntil(() => provider.receiveQueueSize > 0, 30_000); - // Let any trailing send_complete events land before asserting the - // queue has settled, so this isn't racing the last few deliveries. - await new Promise((resolve) => setTimeout(resolve, 200)); - - assert.equal( - provider.receiveQueueSize, - 1, - `one client key must coalesce to at most one pending frame, got ${provider.receiveQueueSize}`, - ); - const frame = await provider.receive(); - assert.equal(frame.sequence, BigInt(total), "the one pending frame must be the newest generation sent"); - assert.equal(provider.receiveQueueSize, 0); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } - }, -); - -test( - "many distinct client latest-only keys stay bounded by the key count, not the frame count", - async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - const keyCount = 50; - const sendsPerKey = 20; - const sends: Promise[] = []; - for (let key = 0; key < keyCount; key += 1) { - for (let sequence = 1; sequence <= sendsPerKey; sequence += 1) { - sends.push( - consumer.sendFrame( - testFrame({ - delivery: "latest-only", - bodyId: `body:${key}`, - sequence: BigInt(sequence), - }), - ), - ); - } - } - await Promise.all(sends); - await waitUntil(() => provider.receiveQueueSize > 0, 10_000); - await new Promise((resolve) => setTimeout(resolve, 200)); - - assert.equal( - provider.receiveQueueSize, - keyCount, - `the queue must hold exactly one pending frame per distinct key, got ${provider.receiveQueueSize}`, - ); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } - }, -); - -test("reliable-ordered client frames are delivered in order at the provider, never coalesced", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - const total = 500; - for (let sequence = 1; sequence <= total; sequence += 1) { - await consumer.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: BigInt(sequence) })); - } - await waitUntil(() => provider.receiveQueueSize === total, 10_000); - - const received: bigint[] = []; - for (let i = 0; i < total; i += 1) { - received.push((await provider.receive()).sequence); - } - const expected = Array.from({ length: total }, (_, i) => BigInt(i + 1)); - assert.deepEqual(received, expected, "reliable-ordered frames must never be coalesced or reordered"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("frames already queued in the provider's receive queue drain before dispose's rejection", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await consumer.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 1n })); - await consumer.sendFrame(testFrame({ delivery: "reliable-ordered", sequence: 2n })); - await waitUntil(() => provider.receiveQueueSize === 2); - - // Dispose while two frames are still sitting in the queue, unread. - provider.dispose(); - - const first = await provider.receive(); - const second = await provider.receive(); - assert.deepEqual([first.sequence, second.sequence], [1n, 2n], "already-queued frames must drain first"); - await assert.rejects(() => provider.receive(), /disposed/, "only a call past the drained backlog rejects"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("unreliable broadcast fails closed", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await assert.rejects(provider.broadcast(testFrame({ delivery: "unreliable" })), /datagrams/i); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("a peer is evicted from the provider on connection shutdown", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - await waitUntil(() => provider.connectionCount === 1); - consumer.dispose(); - await waitUntil(() => provider.connectionCount === 0); - } finally { - provider.dispose(); - } -}); - -test("a reliable-ordered send failure evicts the peer without broadcast() throwing to the caller", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - await waitUntil(() => provider.connectionCount === 1); - consumer.dispose(); - // Keep broadcasting reliable-ordered frames into the dying/dead peer's - // outbound stream for a short window: somewhere in this window the - // send to that peer fails (either the native stream call itself, or - // the peer's own CONNECTION_SHUTDOWN cleanup rejecting it), and - // CultMeshQuicRealtimeProvider.broadcast()'s per-peer try/catch must - // dispose it rather than let the rejection propagate or leave a dead - // peer counted forever. - const deadline = Date.now() + 2_000; - let sequence = 0n; - while (Date.now() < deadline && provider.connectionCount > 0) { - sequence += 1n; - // Must never throw: a removed subtraction of the catch's dispose() - // call would not itself make broadcast() throw, but a regression - // that let the rejection propagate instead of being caught at all - // would, and this loop would then fail loudly instead of hanging. - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence })); - } - assert.equal(provider.connectionCount, 0, "the dead peer must be evicted, not counted forever"); - } finally { - provider.dispose(); - } -}); - -test("connectionCount reflects accepted peers, and dispose releases the runtime for a fresh listen", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - assert.equal(provider.connectionCount, 0); - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - } finally { - consumer.dispose(); - provider.dispose(); - } - // A leaked runtime reference from any earlier path (accept, handshake - // timeout, dispose) would leave the shared runtime unable to open a fresh - // listener cleanly; opening and tearing down a second provider proves - // release ran on every path exercised above. - const again = await startProvider(); - again.dispose(); -}); - -test("the runtime reference is released when extracting the certificate fails, before any listener opens", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const before = CultMeshQuicNativeRuntime.refCount; - await assert.rejects( - CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - // Not a PKCS12 credential at all: extractLeafCertificateDer() throws - // before CultMeshQuicNativeRuntime.open() is ever called, so there is - // no reference to leak on this path; this pins that (trivial but - // real) invariant rather than exercising listen()'s own - // `catch { await runtime.release(); throw error; }`, which the next - // test covers with a listener-level failure instead. - serverCertificate: { pkcs12: new Uint8Array([1, 2, 3, 4]), password: "" }, - }), - ); - assert.equal(CultMeshQuicNativeRuntime.refCount, before, "must not leak a reference that was never opened"); -}); - -test("the runtime reference is released when the listener itself fails to open", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const holder = await startProvider(); - try { - const boundPort = new URL(holder.advertisedEndpoint).port; - const before = CultMeshQuicNativeRuntime.refCount; - // A real, valid PKCS12 (so extractLeafCertificateDer succeeds and - // CultMeshQuicNativeRuntime.open() actually runs), but the port - // `holder` already has bound: listenerOpen() itself must fail, driving - // listen()'s `catch { await runtime.release(); throw error; }`. - await assert.rejects( - CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: Number(boundPort), - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - }), - ); - assert.equal( - CultMeshQuicNativeRuntime.refCount, - before, - "a listenerOpen() failure must release the reference listen() had already opened", - ); - } finally { - holder.dispose(); - } -}); - -test( - "the runtime reference is released on dispose with a pending send in flight", - { timeout: 10_000 }, - async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const before = CultMeshQuicNativeRuntime.refCount; - const provider = await startProvider(); - const consumer = await dialProvider(provider); - await waitUntil(() => provider.connectionCount === 1); - - // Start a reliable-ordered broadcast and dispose before it can possibly - // have settled; dispose() must tear the peer down (and release its - // runtime reference) regardless of the outstanding send. `broadcast()` - // must itself never hang: an explicit `{ timeout }` above fails this - // test loudly, rather than the whole file, if it ever does. - const broadcasting = provider.broadcast(testFrame({ delivery: "reliable-ordered" })).catch(() => {}); - provider.dispose(); - await broadcasting; - consumer.dispose(); - await waitUntil(() => CultMeshQuicNativeRuntime.refCount === before); - }, -); - -test( - "dispose() evicts a connection still mid-handshake, not just fully attached peers", - { timeout: 10_000 }, - async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - // A long handshake timeout: without dispose() sweeping still-pending - // accepts (fixed alongside this test), a connection whose handshake - // never reaches CONNECTED — here, the client rejects the provider's - // certificate — would sit on its own handshake timer, and once - // attachPeer's own CultMeshQuicNativeRuntime.open() resolves, hold a - // runtime reference, for up to this long after dispose() returns. Found - // this way: mutating the certificate-pin comparison to be - // case-sensitive (M2) made every provider test that dials with an - // uppercase-pinned endpoint reject during the handshake, and the whole - // file then hung for over two minutes past its last visible test. - // Earlier tests' dispose() releases fire-and-forget; wait for the - // shared refCount to actually settle before treating it as a baseline - // (see waitForRefCountToStabilize's own doc comment). - const before = await waitForRefCountToStabilize(); - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - handshakeTimeoutMs: 30_000, - }); - try { - const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - const candidate: CultMeshRealtimeCandidate = { - // A pin that can never match this provider's real certificate: the - // connector rejects it during CULTMESH_QUIC_EVENT_CONNECTION_CERTIFICATE_RECEIVED, - // before the connection ever reaches CONNECTED. - endpoint: provider.advertisedEndpoint.replace(/cert-sha256=[0-9A-F]+/, `cert-sha256=${"0".repeat(64)}`), - authorityRuntimeId: target.authorityRuntimeId, - priority: 0, - generation: "gen-1", - }; - const connector = new CultMeshQuicRealtimeConnector(); - // If the certificate check ever regresses into accepting everything - // (M1), this resolves into a fully attached peer instead of rejecting; - // assertRejectsAndDisposes() disposes the client-side transport either - // way, but only the outer `finally` below disposes the provider itself - // (and the peer it would then hold), which is what actually closes - // the file-hanging gap M1 found here. - await assertRejectsAndDisposes(connector.connect(candidate, target), /certificate|rejected/i); - - // The provider's own accept flow is asynchronous (attachPeer awaits a - // runtime reference before it can even see the rejection); give it a - // moment to actually start before disposing, so this test exercises a - // real in-flight pending accept rather than one that never began. - await new Promise((resolve) => setTimeout(resolve, 100)); - - const disposedAt = Date.now(); - provider.dispose(); - await waitUntil(() => CultMeshQuicNativeRuntime.refCount === before, 5_000); - assert.ok( - Date.now() - disposedAt < 5_000, - "dispose() must evict a mid-handshake connection promptly, not wait out its 30s handshake timeout", - ); - } finally { - provider.dispose(); - } - }, -); - -test("a peer attaching after two latest-only broadcasts for one key receives exactly the newer frame", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - await provider.broadcast(testFrame({ sequence: 1n, payload: new Uint8Array([1]) })); - await provider.broadcast(testFrame({ sequence: 2n, payload: new Uint8Array([2]) })); - - // Attach after both broadcasts have already resolved: nothing in this - // peer's outbox came from `broadcast()`'s own fan-out, only from the - // retained seed on attach. - const consumer = await dialProvider(provider); - try { - const seeded = await consumer.receiveFrame(); - assert.equal(seeded.sequence, 2n, "a late joiner must be seeded with the newest retained generation"); - assert.deepEqual(seeded.payload, new Uint8Array([2])); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("retention keeps the newer generation when an older one broadcasts afterward", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - await provider.broadcast(testFrame({ sequence: 5n, payload: new Uint8Array([5]) })); - // An older generation broadcast after a newer one must not overwrite the - // retained frame: mutating the retention comparison to a plain - // last-write-wins assignment would regress this. - await provider.broadcast(testFrame({ sequence: 3n, payload: new Uint8Array([3]) })); - - const consumer = await dialProvider(provider); - try { - const seeded = await consumer.receiveFrame(); - assert.equal(seeded.sequence, 5n, "an older generation must not replace the retained newer one"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("a reliable-ordered frame is never retained and is not delivered to a late joiner", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const firstConsumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 9n })); - assert.deepEqual((await firstConsumer.receiveFrame()).sequence, 9n); - } finally { - firstConsumer.dispose(); - } - await waitUntil(() => provider.connectionCount === 0); - - // A second peer attaches after the reliable-ordered frame above and - // after a real latest-only frame, so the assertion below proves the - // reliable-ordered frame specifically was never retained, rather than - // merely proving the provider had nothing at all to seed. - await provider.broadcast(testFrame({ delivery: "latest-only", sequence: 1n, payload: new Uint8Array([1]) })); - const secondConsumer = await dialProvider(provider); - try { - const seeded = await secondConsumer.receiveFrame(); - assert.equal(seeded.delivery, "latest-only"); - assert.equal(seeded.sequence, 1n, "only the latest-only frame may be seeded, never the reliable-ordered one"); - } finally { - secondConsumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test( - "fix 1: a peer stays connected and keeps receiving well past handshakeTimeoutMs", - { timeout: 10_000 }, - async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - // Must fail on the pre-fix code: the buffering-handler/attachPeer swap - // there loses `state.connected` to whichever handler happens to be - // registered when CONNECTED actually arrives, and the handshake timer - // evicts a fully healthy peer at this deadline regardless. - const handshakeTimeoutMs = 500; - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - handshakeTimeoutMs, - }); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await new Promise((resolve) => setTimeout(resolve, handshakeTimeoutMs * 3)); - assert.equal(provider.connectionCount, 1, "a connected peer must not be evicted by the handshake timer"); - - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 1n })); - const received = await consumer.receiveFrame(); - assert.equal(received.sequence, 1n, "a peer past the handshake deadline must still receive frames"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } - }, -); - -test("fix 2: an invalid frame throws from broadcast, and connectionCount is unchanged", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - // A 70,000-byte channelId exceeds the wire's 0xffff identity limit: - // `encodeRealtimeFrame` throws. Before fix 2, encoding happened once - // per peer inside `sendFrame`, so the same failure evicted every peer - // while `broadcast()` itself reported success. - await assert.rejects( - provider.broadcast(testFrame({ delivery: "reliable-ordered", channelId: "x".repeat(70_000) })), - /exceeds the QUIC wire limit/i, - ); - assert.equal(provider.connectionCount, 1, "an invalid frame must not evict any peer"); - - // The peer must still be usable afterward: prove the connection itself - // survived, not merely that the count field wasn't decremented. - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 42n })); - assert.equal((await consumer.receiveFrame()).sequence, 42n); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("fix 2: a latest-only invalid frame also throws from broadcast without evicting any peer", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await assert.rejects( - provider.broadcast(testFrame({ delivery: "latest-only", channelId: "x".repeat(70_000) })), - /exceeds the QUIC wire limit/i, - ); - assert.equal(provider.connectionCount, 1, "an invalid latest-only frame must not evict any peer"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("fix 3: advertisedHost is used in place of the bind address, and round-trips through the module's parser", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "0.0.0.0", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - advertisedHost: "streampixels.gamecult.org", - }); - try { - assert.match( - provider.advertisedEndpoint, - /^cultmesh-state\+quic:\/\/streampixels\.gamecult\.org:\d+\?cert-sha256=[0-9A-F]{64}$/, - ); - const parsed = parseQuicRealtimeEndpoint(provider.advertisedEndpoint); - assert.equal(parsed.host, "streampixels.gamecult.org"); - assert.equal(parsed.port, Number(new URL(provider.advertisedEndpoint).port)); - assert.ok(parsed.certificateSha256); - } finally { - provider.dispose(); - } -}); - -test("fix 3: an IPv6 bind advertises a bracketed literal that round-trips through the module's parser", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "::1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - }); - try { - assert.match( - provider.advertisedEndpoint, - /^cultmesh-state\+quic:\/\/\[::1\]:\d+\?cert-sha256=[0-9A-F]{64}$/, - ); - // `URL`'s own `hostname` keeps the brackets for an IPv6 literal (unlike - // the unbracketed form `formatEndpointHost` accepted as input); the - // round trip's job is proving the endpoint parses at all, not stripping - // brackets the WHATWG URL parser itself never strips. - const parsed = parseQuicRealtimeEndpoint(provider.advertisedEndpoint); - assert.equal(parsed.host, "[::1]"); - } finally { - provider.dispose(); - } -}); - -test("fix 4: receive() with an already-aborted signal rejects immediately instead of hanging", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const controller = new AbortController(); - controller.abort(); - await assert.rejects(provider.receive(controller.signal), /aborted/i); - } finally { - provider.dispose(); - } -}); - -test("P3: a latest-only send failure evicts the peer without broadcast() throwing to the caller", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - await waitUntil(() => provider.connectionCount === 1); - consumer.dispose(); - // Mirrors the existing reliable-ordered eviction test, but for the - // outbox's own send failure path (`CultMeshQuicRealtimeProviderOutbox.pump`'s - // catch, which disposes the peer and reports failure through - // `onSendFailure`) rather than `broadcast()`'s direct per-peer catch. - // - // What made this flaky: unlike the reliable-ordered version, - // `broadcast()` never awaits a latest-only peer's actual send — it only - // hands the frame to that peer's outbox and returns (see - // `CultMeshQuicRealtimeProvider.broadcast`). A `while (Date.now() < - // deadline)` loop therefore does no real I/O per iteration; it just - // spins encoding and enqueueing frames as fast as the CPU allows, - // starving the event-loop turns the native pump needs to actually - // observe the dead connection and fire `send_complete`/ - // `CONNECTION_SHUTDOWN`. Under any extra load in the test process - // (exactly what running under mutation testing adds, regardless of - // which line was mutated) that starvation can burn the whole wall-clock - // bound without ever landing an attempt past the point the connection - // is actually dead — a failure with nothing to do with the mutant under - // test. Raising the bound only buys more spinning, not more real - // attempts. Fixed by decoupling "how many attempts to seed" (a small, - // fixed count, each with a real yield) from "how long to wait for the - // result" (a single `waitUntil` afterward, which is what actually - // bounds this test). - for (let sequence = 0n; sequence < 20n && provider.connectionCount > 0; sequence += 1n) { - await provider.broadcast(testFrame({ delivery: "latest-only", sequence, bodyId: `body:${sequence}` })); - await new Promise((resolve) => setTimeout(resolve, 25)); - } - await waitUntil(() => provider.connectionCount === 0); - assert.equal(provider.connectionCount, 0, "the dead peer must be evicted, not counted forever"); - } finally { - provider.dispose(); - } -}); - -test("I1: an inbox key keeps its first-arrival position when a newer frame overwrites it", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // Key A arrives first, then key B, then A is republished with a new - // value while still unread: `CultMeshRealtimeInbox.publish`'s - // coalescing must overwrite A's *value* in place, not move it to the - // back of the queue behind B. `received` is exactly that inbox, - // reached through the provider's client fan-in. - await consumer.sendFrame(testFrame({ delivery: "latest-only", bodyId: "body:A", sequence: 1n })); - await waitUntil(() => provider.receiveQueueSize === 1); - await consumer.sendFrame(testFrame({ delivery: "latest-only", bodyId: "body:B", sequence: 1n })); - await waitUntil(() => provider.receiveQueueSize === 2); - await consumer.sendFrame(testFrame({ delivery: "latest-only", bodyId: "body:A", sequence: 2n })); - // Still 2: the second A publish must coalesce onto the already-queued - // A entry, not add a third. - await new Promise((resolve) => setTimeout(resolve, 200)); - assert.equal(provider.receiveQueueSize, 2, "a republish of a still-pending key must not grow the queue"); - - const first = await provider.receive(); - const second = await provider.receive(); - assert.equal(first.bodyId, "body:A", "A must still drain first: its position must survive the overwrite"); - assert.equal(first.sequence, 2n, "A's value must be the newer, overwritten one"); - assert.equal(second.bodyId, "body:B"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("L1: the outbox keeps one send in flight per peer; the next frame dequeues only after send_complete", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // Prototype-patched for the life of this test, restored in `finally`: - // the provider builds its peer transport internally, so this is the - // only vantage point outside the module from which to observe - // concurrency of `sendEncodedFrame` calls, which is what - // `CultMeshQuicRealtimeProviderOutbox.pump` serializes one-at-a-time - // against `send_complete`. - const original = CultMeshQuicRealtimeTransportClass.prototype.sendEncodedFrame; - let active = 0; - let maxActive = 0; - CultMeshQuicRealtimeTransportClass.prototype.sendEncodedFrame = function ( - this: InstanceType, - delivery: "reliable-ordered" | "latest-only", - encoded: Uint8Array, - ) { - active += 1; - maxActive = Math.max(maxActive, active); - return original.call(this, delivery, encoded).finally(() => { - active -= 1; - }); - }; - try { - const total = 20; - const sends: Promise[] = []; - for (let key = 0; key < total; key += 1) { - sends.push(provider.broadcast(testFrame({ bodyId: `body:${key}`, sequence: 1n }))); - } - await Promise.all(sends); - - const seen = new Set(); - while (seen.size < total) { - const frame = await consumer.receiveFrame(); - seen.add(frame.bodyId); - } - } finally { - CultMeshQuicRealtimeTransportClass.prototype.sendEncodedFrame = original; - } - assert.equal(maxActive, 1, "the outbox pump must never have two sends in flight for one peer at once"); - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("P15: broadcast() after dispose rejects instead of touching a torn-down provider", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - provider.dispose(); - await assert.rejects(provider.broadcast(testFrame()), /disposed/i); -}); - -test("P17: an accept arriving after dispose is refused, not attached as a peer", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await startProvider(); - const runtime = await CultMeshQuicNativeRuntime.open(); - let connectionId: bigint | undefined; - try { - // A real native connection handle this test owns outright (never dialed - // anywhere reachable, so shutting it down is safe): stands in for the - // handle a genuine NEW_CONNECTION event would have carried, without - // fabricating a bogus native pointer. `acceptConnection` is private; - // reaching it directly is what lets this test drive the exact race - // (an accept event landing after `dispose()` has already run) without - // depending on real listener-close timing to reproduce it. - connectionId = runtime.connectionOpen("127.0.0.1", 1); - provider.dispose(); - // This synthetic connection never reaches CONNECTED either way (it was - // never dialed anywhere), so `connectionCount` alone cannot distinguish - // "refused" from "attached but still handshaking". `retain()` is - // synchronous and only the attach path calls it: a stable `refCount` - // across the call proves no transport (and no runtime reference) was - // ever allocated for this connection. - const beforeRefCount = CultMeshQuicNativeRuntime.refCount; - assert.doesNotThrow(() => - (provider as unknown as { acceptConnection(id: bigint): void }).acceptConnection(connectionId!), - ); - assert.equal( - CultMeshQuicNativeRuntime.refCount, - beforeRefCount, - "a post-dispose accept must never retain a runtime reference for a new transport", - ); - assert.equal(provider.connectionCount, 0, "a post-dispose accept must never join peers"); - } finally { - if (connectionId !== undefined) { - try { - runtime.connectionShutdown(connectionId, 0n); - } catch { - // Best-effort: acceptConnection's own disposed-path may already have shut it down. - } - } - await runtime.release(); - } -}); - -test("fix 1: a publish-only provider faults a client that sends to it, and its memory stays empty", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - acceptClientFrames: false, - }); - try { - const consumer = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // receive() itself rejects clearly rather than hanging forever. - await assert.rejects(provider.receive(), /publish-only/i); - - // Any inbound stream from the client faults that connection. The - // client's own `sendFrame` promise settles on its *local* stream - // send completing (MsQuic hands the bytes off and reports - // send_complete without waiting for the peer to process them), so it - // may well resolve even though the server already faulted its side — - // the proof this test owns is the server's state, not the client's - // send outcome, so the client send is fired and ignored either way. - void consumer.sendFrame(testFrame({ delivery: "latest-only" })).catch(() => {}); - await waitUntil(() => provider.connectionCount === 0); - assert.equal(provider.receiveQueueSize, 0, "no frame from a faulted publish-only client may be queued"); - - // The provider itself is otherwise healthy: broadcasting still works - // for a freshly attached peer. - const second = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 1n })); - assert.equal((await second.receiveFrame()).sequence, 1n); - } finally { - second.dispose(); - } - } finally { - consumer.dispose(); - } - } finally { - provider.dispose(); - } -}); - -test("fix 2: a connection beyond maxConnections is refused and existing peers are unaffected", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - const provider = await CultMeshQuicRealtimeProvider.listen({ - host: "127.0.0.1", - port: 0, - serverCertificate: { pkcs12: readFileSync(FIXTURE_P12), password: "" }, - maxConnections: 1, - }); - try { - const first = await dialProvider(provider); - try { - await waitUntil(() => provider.connectionCount === 1); - - // Refused at accept: never reaches CONNECTED, never becomes a peer. - await assertRejectsAndDisposes(dialProvider(provider), /certificate|rejected|closed|shut|timed out/i); - // Give the refusal a moment to be visible either way, then prove the - // existing peer was never touched. - await new Promise((resolve) => setTimeout(resolve, 200)); - assert.equal(provider.connectionCount, 1, "the existing peer must be unaffected by a refused connection"); - - await provider.broadcast(testFrame({ delivery: "reliable-ordered", sequence: 7n })); - assert.equal((await first.receiveFrame()).sequence, 7n, "the existing peer must still be fully usable"); - } finally { - first.dispose(); - } - } finally { - provider.dispose(); - } -}); diff --git a/packages/cultmesh-ts/test/realtime-quic-release-uaf.test.ts b/packages/cultmesh-ts/test/realtime-quic-release-uaf.test.ts deleted file mode 100644 index f7958570..00000000 --- a/packages/cultmesh-ts/test/realtime-quic-release-uaf.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Regression test for fix 2: CultMeshQuicNativeRuntime.release() must await -// the pump loop's exit before calling cultmesh_quic_runtime_close, never -// after. Reverting that order (close before awaiting the pump) reliably -// crashes this test under a saturated libuv thread pool and MALLOC_PERTURB_, -// at every pool size tried by hand while verifying this batch; restored -// immediately afterward, never committed. -// -// UV_THREADPOOL_SIZE and MALLOC_PERTURB_ must be set before Node starts, so -// this spawns a child `node` process running test/support/release-uaf-probe.js -// with that environment, once per pool size, and asserts it exits 0. Kept to -// one scenario (see the probe's own header) so the whole test stays bounded -// to a few seconds. - -import assert from "node:assert/strict"; -import { spawnSync } from "node:child_process"; -import { join } from "node:path"; -import test from "node:test"; - -import { nativeBridgeAvailable } from "./support/native-bridge"; - -const PROBE_SCRIPT = join(__dirname, "..", "..", "test", "support", "release-uaf-probe.js"); - -test("fix 2 regression: release()'s ordering survives a saturated thread pool at pool sizes 1, 2 and 4", async (t) => { - if (!nativeBridgeAvailable()) return void t.skip("no native bridge available"); - - for (const poolSize of [1, 2, 4]) { - const result = spawnSync(process.execPath, [PROBE_SCRIPT], { - env: { - ...process.env, - UV_THREADPOOL_SIZE: String(poolSize), - MALLOC_PERTURB_: "165", - }, - encoding: "utf8", - timeout: 60_000, - }); - assert.equal( - result.status, - 0, - `pool size ${poolSize}: probe exited status=${result.status} signal=${result.signal}\n` + - `stdout:\n${result.stdout}\nstderr:\n${result.stderr}`, - ); - } -}); diff --git a/packages/cultmesh-ts/test/realtime-quic-session-manager.test.ts b/packages/cultmesh-ts/test/realtime-quic-session-manager.test.ts deleted file mode 100644 index e1843466..00000000 --- a/packages/cultmesh-ts/test/realtime-quic-session-manager.test.ts +++ /dev/null @@ -1,358 +0,0 @@ -// `CultMeshQuicRealtimeSessionManager`'s own rules, isolated from the native -// bridge with fake connectors/transports: eviction on transport death (fix -// 4), single-flight (fix 4), the disposed guard (fix 4), first-success racing -// with abort of the losers (fix 5), the `protocolIds` filter (M7), the -// `authorityRuntimeId` filter (M8), the session key including -// `authorityRuntimeId` (M9), and the `maxRacedCandidates` cap (M6). -// -// Routes use `trust.mode = "local-development"` over loopback endpoints, so -// `verifyAuthorityRoute` short-circuits without a signed certificate -// (`cultmesh-authority.ts:99`): these tests are about the session manager's -// own binding/racing/caching rules, not route trust, which -// `realtime-quic-consumer.test.ts`'s trust negatives already pin. - -import assert from "node:assert/strict"; -import test from "node:test"; - -import type { CultMeshAuthorityTrustPolicy } from "cultnet-ts"; -import type { CultMeshAuthorityRouteMessage, CultMeshVerseDescriptorMessage } from "cultnet-ts/contracts"; - -import { - CultMeshQuicRealtimeSessionManager, - CultMeshStaticRealtimeLookupSource, - CULTMESH_REALTIME_STATE_PROTOCOL_ID, - type CultMeshRealtimeCandidate, - type CultMeshRealtimeTarget, - type CultMeshRealtimeTransport, - type CultMeshRealtimeTransportConnector, -} from "../src/realtime-quic"; - -const trust: CultMeshAuthorityTrustPolicy = { mode: "local-development", odinRoots: [] }; - -function route(overrides: Partial = {}): CultMeshAuthorityRouteMessage { - return { - authorityRuntimeId: "service:aetheria.daemon", - endpoint: "cultmesh-state+quic://127.0.0.1:9443", - protocolIds: [CULTMESH_REALTIME_STATE_PROTOCOL_ID], - priority: 0, - generation: "gen-1", - ...overrides, - }; -} - -function verseWithRoutes(verseId: string, routes: readonly CultMeshAuthorityRouteMessage[]): CultMeshVerseDescriptorMessage { - return { - verseId, - displayName: verseId, - authorityModel: "operator-cluster", - compatibility: { transportVersion: "cultmesh.v1", rulesHash: "test", compatibleVerseIds: [], requiredPluginIds: [], optionalPluginIds: [] }, - discoveryEndpoints: routes.map((r) => r.endpoint), - authorityRuntimeIds: [...new Set(routes.map((r) => r.authorityRuntimeId))], - authorityRoutes: [...routes], - }; -} - -interface FakeTransportHandle { - readonly transport: CultMeshRealtimeTransport; - disposed(): boolean; -} - -/** A transport that never resolves `receiveFrame` and tracks its own disposal. */ -function fakeTransport(endpoint: string, verified = true): FakeTransportHandle { - let disposed = false; - const disposalHandlers: Array<() => void> = []; - const transport: CultMeshRealtimeTransport = { - transportId: "fake", - endpoint, - async sendFrame() {}, - async receiveFrame() { - return await new Promise(() => {}); - }, - dispose() { - if (disposed) return; - disposed = true; - for (const handler of disposalHandlers) handler(); - }, - isVerifiedFor: () => verified, - onDisposed(handler) { - if (disposed) { - handler(); - return; - } - disposalHandlers.push(handler); - }, - }; - return { transport, disposed: () => disposed }; -} - -/** A connector that resolves immediately (unless `delayMs` is given) with one fake transport per call. */ -function spyConnector( - connectorId: string, - priority: number, - options: { delayMs?: number; fails?: boolean; ignoreAbort?: boolean } = {}, -): { - connector: CultMeshRealtimeTransportConnector; - calls: CultMeshRealtimeCandidate[]; - handles: FakeTransportHandle[]; - /** Timestamps at which this connector's abort signal actually fired. */ - aborts: number[]; -} { - const calls: CultMeshRealtimeCandidate[] = []; - const handles: FakeTransportHandle[] = []; - const aborts: number[] = []; - const connector: CultMeshRealtimeTransportConnector = { - connectorId, - priority, - canConnect: () => true, - connect: async (candidate, _target, signal) => { - calls.push(candidate); - if (options.delayMs) { - await new Promise((resolve, reject) => { - const timer = setTimeout(resolve, options.delayMs); - if (!options.ignoreAbort) { - signal?.addEventListener("abort", () => { - clearTimeout(timer); - aborts.push(Date.now()); - reject(new Error(`${connectorId} connect aborted`)); - }); - } - }); - } - if (options.fails) throw new Error(`${connectorId} refused to connect`); - const handle = fakeTransport(candidate.endpoint); - handles.push(handle); - return handle.transport; - }, - }; - return { connector, calls, handles, aborts }; -} - -const target: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:aetheria.daemon" }; - -test("fix 4: connect() caches a session and evicts it once the transport dies, so the next connect redials", async () => { - const { connector, calls } = spyConnector("fake", 0); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoutes(target.verseId, [route()])]), - trust, - connectors: [connector], - }); - - const first = await manager.connect(target); - assert.equal(await manager.connect(target), first, "a live session is returned from cache, not redialed"); - assert.equal(calls.length, 1); - - first.dispose(); - const second = await manager.connect(target); - assert.notEqual(second, first, "a dead session is evicted, so the next connect redials"); - assert.equal(calls.length, 2); -}); - -test("fix 4: concurrent connect() calls for the same target share one dial (single-flight)", async () => { - const { connector, calls } = spyConnector("fake", 0, { delayMs: 50 }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoutes(target.verseId, [route()])]), - trust, - connectors: [connector], - }); - - const [a, b, c] = await Promise.all([manager.connect(target), manager.connect(target), manager.connect(target)]); - assert.equal(a, b); - assert.equal(b, c); - assert.equal(calls.length, 1, "three concurrent callers must share one dial"); -}); - -test("fix 4/low: dispose() aborts a dial in flight instead of letting it land and discarding the result", async () => { - // A long delay: if `dispose()` did not cancel the dial, this test would - // have to wait it out (or race a timing-dependent assertion) to observe - // that the eventually-created transport gets disposed instead of cached. - const { connector, handles } = spyConnector("fake", 0, { delayMs: 5_000 }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoutes(target.verseId, [route()])]), - trust, - connectors: [connector], - }); - - const pending = manager.connect(target); - const start = Date.now(); - manager.dispose(); - await assert.rejects(pending); - assert.ok( - Date.now() - start < 1_000, - "dispose() must cancel the in-flight dial rather than waiting out the connector's own timeout", - ); - assert.equal(handles.length, 0, "an aborted dial must never construct a transport only to immediately discard it"); - await assert.rejects(manager.connect(target), /disposed/i, "a disposed manager refuses further connects"); -}); - -test("fix 4/low: disconnect() during a dial does not let the dial cache a session once it lands", async () => { - const { connector, handles } = spyConnector("fake", 0, { delayMs: 30 }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoutes(target.verseId, [route()])]), - trust, - connectors: [connector], - }); - - const pending = manager.connect(target); - manager.disconnect(target); - await assert.rejects(pending); - // Whether or not the aborted dial still managed to construct a transport - // (a race against the abort), it must end up disposed, never cached. - await new Promise((resolve) => setTimeout(resolve, 60)); - for (const handle of handles) assert.equal(handle.disposed(), true, "a cancelled dial's transport must be disposed"); - - // The manager itself is still usable: a fresh connect redials and succeeds. - const { connector: connector2 } = spyConnector("fake", 0); - const manager2 = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([verseWithRoutes(target.verseId, [route()])]), - trust, - connectors: [connector2], - }); - const fresh = await manager2.connect(target); - assert.ok(fresh); -}); - -test("fix 5: the race returns the first verified success and aborts the losers", async () => { - const winner = spyConnector("fast", 0, { delayMs: 10 }); - const loser = spyConnector("slow", 0, { delayMs: 5_000 }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [ - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9001" }), - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9002" }), - ]), - ]), - trust, - connectors: [winner.connector, loser.connector], - maxRacedCandidates: 2, - }); - - const startedAt = Date.now(); - const transport = await manager.connect(target); - const elapsedMs = Date.now() - startedAt; - assert.ok(elapsedMs < 1_000, `connect() must return on the first success, not wait out the slow route (took ${elapsedMs}ms)`); - assert.equal(transport.endpoint, "cultmesh-state+quic://127.0.0.1:9001"); -}); - -test("F5abort: a losing candidate is told to abort promptly, not left to run out its own timeout", async () => { - const winner = spyConnector("fast", 0, { delayMs: 10 }); - const loser = spyConnector("slow", 0, { delayMs: 5_000 }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [ - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9001" }), - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9002" }), - ]), - ]), - trust, - connectors: [winner.connector, loser.connector], - maxRacedCandidates: 2, - }); - - const startedAt = Date.now(); - await manager.connect(target); - await new Promise((resolve) => setTimeout(resolve, 300)); - assert.equal(loser.aborts.length, 1, "the losing candidate's connect() must observe an abort signal"); - assert.ok( - loser.aborts[0]! - startedAt < 1_000, - "the abort must arrive promptly after the winner is decided, not after the loser's own 5s timeout", - ); -}); - -test("F5loser: a losing candidate that connects anyway (past the point abort helps) is disposed, not left dangling", async () => { - const winner = spyConnector("fast", 0, { delayMs: 10 }); - // Ignores the abort signal entirely, simulating a candidate already past - // the point where cancellation helps: it still produces a real transport. - const loser = spyConnector("slow", 0, { delayMs: 80, ignoreAbort: true }); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [ - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9001" }), - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9002" }), - ]), - ]), - trust, - connectors: [winner.connector, loser.connector], - maxRacedCandidates: 2, - }); - - const transport = await manager.connect(target); - assert.equal(transport.endpoint, "cultmesh-state+quic://127.0.0.1:9001"); - await new Promise((resolve) => setTimeout(resolve, 200)); - assert.equal(loser.handles.length, 1, "the loser still connects despite racing to lose"); - assert.equal( - loser.handles[0]!.disposed(), - true, - "a losing candidate that connects after the race is decided must be disposed, never left connected", - ); -}); - -test("M6: maxRacedCandidates caps how many candidates in a tier are attempted", async () => { - const spy = spyConnector("fake", 0); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [ - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9001", priority: 0 }), - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9002", priority: 1 }), - route({ endpoint: "cultmesh-state+quic://127.0.0.1:9003", priority: 2 }), - ]), - ]), - trust, - connectors: [spy.connector], - maxRacedCandidates: 1, - }); - - await manager.connect(target); - assert.equal(spy.calls.length, 1, "only the top maxRacedCandidates entries in the tier are attempted"); - assert.equal(spy.calls[0]!.endpoint, "cultmesh-state+quic://127.0.0.1:9001", "the lowest route priority races first"); -}); - -test("M7: a route whose protocolIds omit the realtime-state protocol is not a candidate", async () => { - const spy = spyConnector("fake", 0); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [route({ protocolIds: ["cultmesh.other_protocol.v1"] })]), - ]), - trust, - connectors: [spy.connector], - }); - - await assert.rejects(manager.connect(target), /No realtime state route was advertised/); - assert.equal(spy.calls.length, 0); -}); - -test("M8: a route advertised for a different authorityRuntimeId is not a candidate", async () => { - const spy = spyConnector("fake", 0); - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes(target.verseId, [route({ authorityRuntimeId: "service:other.daemon" })]), - ]), - trust, - connectors: [spy.connector], - }); - - await assert.rejects(manager.connect(target), /No realtime state route was advertised/); - assert.equal(spy.calls.length, 0); -}); - -test("M9: the session key includes authorityRuntimeId, so two authorities in the same Verse get separate sessions", async () => { - const spy = spyConnector("fake", 0); - const targetA: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:a.daemon" }; - const targetB: CultMeshRealtimeTarget = { verseId: "aetheria", authorityRuntimeId: "service:b.daemon" }; - const manager = new CultMeshQuicRealtimeSessionManager({ - lookupSource: new CultMeshStaticRealtimeLookupSource([ - verseWithRoutes("aetheria", [ - route({ authorityRuntimeId: "service:a.daemon", endpoint: "cultmesh-state+quic://127.0.0.1:9001" }), - route({ authorityRuntimeId: "service:b.daemon", endpoint: "cultmesh-state+quic://127.0.0.1:9002" }), - ]), - ]), - trust, - connectors: [spy.connector], - }); - - const sessionA = await manager.connect(targetA); - const sessionB = await manager.connect(targetB); - assert.notEqual(sessionA, sessionB); - assert.equal(sessionA.endpoint, "cultmesh-state+quic://127.0.0.1:9001"); - assert.equal(sessionB.endpoint, "cultmesh-state+quic://127.0.0.1:9002"); - assert.equal(spy.calls.length, 2); -}); diff --git a/packages/cultmesh-ts/test/realtime-wire.test.ts b/packages/cultmesh-ts/test/realtime-wire.test.ts deleted file mode 100644 index 93f23365..00000000 --- a/packages/cultmesh-ts/test/realtime-wire.test.ts +++ /dev/null @@ -1,397 +0,0 @@ -// The realtime frame codec, pinned rule by rule against the C# reference. -// -// The bytes themselves are pinned by two committed files under -// `contracts/cultmesh/`. `realtime-frame-vectors.json` is written by -// `CultMeshRealtimeWireProtocolTests.RealtimeFrameVectorsAreSharedWithTypeScript` -// under CULTMESH_WRITE_VECTORS=1: this side decodes it and re-encodes to the -// same bytes. `realtime-frame-vectors.ts-written.json` is written by -// `scripts/write-cultmesh-realtime-frame-vectors.mjs` with this codec and -// decoded by the C# reference, so parity is proven in both directions and in -// two processes. A fixture authored on one side alone would only agree with -// itself, which is what the authority vectors already taught. - -import test from "node:test"; -import assert from "node:assert/strict"; -import { createHash } from "node:crypto"; -import { readFileSync } from "node:fs"; -import { join } from "node:path"; - -import { - CULTMESH_REALTIME_ALPN, - CULTMESH_REALTIME_CONNECTION_CLOSE_CODE, - CULTMESH_REALTIME_LATEST_ONLY_STREAM, - CULTMESH_REALTIME_MAX_ENCODED_FRAME_BYTES, - CULTMESH_REALTIME_MAX_PAYLOAD_BYTES, - CULTMESH_REALTIME_RELIABLE_STREAM, - CULTMESH_REALTIME_STREAM_ABORT_CODE, - decodeRealtimeFrame, - encodeRealtimeFrame, - type CultMeshRealtimeDelivery, - type CultMeshRealtimeFrame, -} from "../src/realtime-wire"; - -const CONTRACTS = join(__dirname, "..", "..", "..", "..", "contracts", "cultmesh"); -const CSHARP_VECTORS = join(CONTRACTS, "realtime-frame-vectors.json"); -const TS_VECTORS = join(CONTRACTS, "realtime-frame-vectors.ts-written.json"); - -interface IdentityRule { repeat: string; byteLength: number } -interface RampRule { ramp: number } -interface VectorFields { - channelId: string | IdentityRule; - schemaId: string | IdentityRule; - bodyId: string | IdentityRule; - producerEpoch: number; - sequence: number; - delivery: CultMeshRealtimeDelivery; - payload: string | RampRule; -} -interface Vectors { - frames: { - label: string; - fields: VectorFields; - encoding: string | null; - encodedLength: number; - sha256OfEncoding: string; - }[]; - malformed: { label: string; encoding: string; message: string }[]; -} - -/** The repeat unit written whole until the UTF-8 byte length is exactly `byteLength`. */ -function repeatToByteLength(unit: string, byteLength: number): string { - const unitBytes = Buffer.byteLength(unit, "utf8"); - assert.equal(byteLength % unitBytes, 0, `'${unit}' is ${unitBytes} UTF-8 bytes and does not divide ${byteLength}`); - return unit.repeat(byteLength / unitBytes); -} - -/** The deterministic payload both runtimes build the same way. */ -function ramp(length: number): Uint8Array { - const bytes = new Uint8Array(length); - for (let index = 0; index < length; index += 1) bytes[index] = index % 251; - return bytes; -} - -function identity(value: string | IdentityRule): string { - return typeof value === "string" ? value : repeatToByteLength(value.repeat, value.byteLength); -} - -function payload(value: string | RampRule): Uint8Array { - return typeof value === "string" ? new Uint8Array(Buffer.from(value, "base64")) : ramp(value.ramp); -} - -function frameOf(fields: VectorFields): CultMeshRealtimeFrame { - return { - channelId: identity(fields.channelId), - schemaId: identity(fields.schemaId), - bodyId: identity(fields.bodyId), - // The C# `long` fields are written as JSON integers and can exceed the safe - // integer range, so they are read from the raw text, never through - // `JSON.parse`'s number. - producerEpoch: 0n, - sequence: 0n, - delivery: fields.delivery, - payload: payload(fields.payload), - }; -} - -// `JSON.parse` would round `long.MaxValue` to 9223372036854775808, which is not -// a valid i64 and not what either side encoded. The two i64 fields are lifted -// out of the raw text as bigints before the document is parsed. -function readVectors(path: string): { doc: Vectors; int64s: Map } { - const text = readFileSync(path, "utf8"); - const int64s = new Map(); - const pattern = /"label": "(?