Files
AFFiNE/packages/backend/native
CommaBotandDarkSky 6bf2a097df fix: test & lint (#15920)
## Summary

- Ignore `packages/backend/native/src/*.license.json` in
`.prettierignore` and `.oxlintrc.json` so signed license payloads stay
byte-stable.
- Format native Rust sources to `rustfmt.toml` and box
`VerifiedAnyLicense::V2` to keep enum size small.
- Set `claimed_attempt` on the claimed worker snapshot in
`snapshot_commit_is_atomic_and_transfer_moves_the_entitlement` to match
receipt generation fencing.
- Inject the `event` stub in `gateway-cluster.spec.ts` and add
table-driven checks for cross-channel `sync-027` invalidation
broadcasts.

## Production Lock-Release Race Fix

- `PaymentConnection::reacquire_with` previously dropped its
`close_on_drop()` connection and called `try_acquire` before Postgres
finished releasing session advisory locks.
- Under load, that race caused self-collision and spurious
`payment_busy` failures.
- `PaymentConnection::release` now runs `SELECT
pg_advisory_unlock_all()` and closes the connection before
`reacquire_with` or partial `try_acquire` failures return.
- `payment_session_locks_are_sorted_nonblocking_and_connection_bound`
now verifies 32 consecutive `reacquire_with` lock expansions without
collision.

## Verification

- `yarn lint:format` passed across 7504 files.
- `cargo +nightly fmt --all -- --check` passed.
- `cargo clippy --workspace --exclude affine_server_native --all-targets
--all-features -- -D warnings` passed.
- `cargo clippy -p affine_server_native --all-targets --all-features --
-D warnings` passed.
- `cargo test -p affine_server_native` passed for `license_v2`,
`receipt_attempt`,
`payment_session_locks_are_sorted_nonblocking_and_connection_bound`, and
`snapshot_commit_is_atomic_and_transfer_moves_the_entitlement` against
PostgreSQL 16 and Redis.
- `ava` passed both tests in
`packages/backend/server/src/__tests__/sync/gateway-cluster.spec.ts`.

Models: Gemini 4 Neon, Gemini 4 Carbon.
Test frameworks: Cargo test, Clippy, rustfmt, oxfmt, AVA.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved payment connection recovery so locks acquired before a failed
scope acquisition are released before retrying. Connections now release
their locks explicitly, and failures to unlock are reported as database
errors.
* Corrected gateway invalidation broadcasts so updates reach appropriate
remote channels without unnecessary broadcasts to local or unspecified
channels.
* **Tests**
* Expanded coverage for payment lock cleanup and gateway invalidation
routing, including cases with missing or local channel information.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: DarkSky <darksky2048@gmail.com>
2026-11-23 17:19:29 +08:00
..
2026-11-23 17:19:29 +08:00
2025-12-10 16:02:28 +08:00