docs(gen1): document central NexRent Treasury lifecycle and rollout gate

This commit is contained in:
OpenGenesis (EULA) committed 2026-11-25 18:04:38 +01:00
1 parent 0ff4a675de
commit 1e8a578698
1 file changed
+58
+58
View File
@@ -0,0 +1,58 @@
# NexRent Treasury – Gen 1 integration (pilot, disabled by default)
This implements a **central NV$ business wallet** for authorized NexRent inworld rent payments while preserving normal object-to-owner payments.
## Integration paths
- Simulator: \`NexVerse/RegionModules/Economy/NexVerseMoneyModule.cs\`.
- NexRent PHP 0.3.0: \`public/api.php?op=treasury_preflight\`, \`public/api.php?op=treasury_credit\`, finance UI \`?p=treasury\`.
- Existing World API: \`POST /api/v1/commerce/orders\` with the pre-existing commerce kind **Rental**, reference \`nexrent:<root object UUID>\`. The returned \`order_id\` uniquely identifies the purchase. \`POST /api/v1/commerce/orders/{order_id}/refund\` performs refunds with authorized service/admin credentials.
- PHP's treasury receipt registry binds immutable order ID, box, object, buyer, wallet, amount and optional ledger transaction ID. Subsequent LSL \`money()\` callbacks cannot produce an additional lease without a pending receipt.
## Server configuration
All settings live under \`[NexEconomyViewer]\`; none belong in the public LSL notecard.
\`\`\`ini
NexRentTreasuryEnabled = false
NexRentTreasuryWalletId = "<PREPROVISIONED_NV_DOLLAR_BUSINESS_WALLET_UUID>"
NexRentTreasuryApiUrl = "https://rental.stadt-nexverse.de/api.php"
NexRentTreasurySecret = "\${Environment|NEXRENT_TREASURY_SECRET}"
NexRentTreasuryBoxBindings = "<ROOT_OBJECT_UUID>|<OWNER_AVATAR_UUID>"
\`\`\`
Multiple bindings: \`"objUUID|ownerUUID,objUUID|ownerUUID"\`. Only root object UUIDs are allowed; never use parcel IDs. Each bound object must be authenticated and enabled in the NexRent PHP application. **Neither missing configuration nor a string in an object name or description can grant treasury routing.**
Create the receiving account beforehand through a privileged World API call:
\`\`\`http
POST /api/v1/economy/accounts/ensure
Content-Type: application/json
X-NexVerse-Api-Key: <PRIVILEGED_SERVICE_KEY>
{"account_id":"<TREASURY_WALLET_UUID>","account_class":"business","display_name":"NexRent Treasury"}
\`\`\`
The existing EnsureWallet endpoint does **not** accept the class \`system\`, so use \`business\`. Keep this account distinct from \`FeeWalletId\` and MasterBank payout wallets.
The PHP host needs the same private random 32+ byte shared secret in its \`config/local.php\` (\`treasury.secret\`). Never copy the secret into LSL or the website. Both preflight and receipt delivery use HTTPS and a server-only \`X-NexRent-Treasury-Secret\` header.
## Failure and reconciliation
- If preflight fails, the registered object payment is **rejected without debiting the buyer**. It never falls back to paying the avatar.
- If the World API payment fails, no \`OnObjectPaid\` callback is fired.
- If the order succeeded but NexRent PHP is offline, the simulator stores a JSON receipt in \`ops-data/nexrent-treasury-outbox\` and retries periodically. The PHP endpoint is idempotent by \`order_id\`.
- If an order succeeds immediately before a simulator crash and before the receipt file is durably written, reconcile that immutable order in the World API. This gap remains a production-acceptance test case.
- If PHP has a receipt but no LSL \`money()\` event, the amount remains pending; investigate, do not create an unverified rental grant.
- Admin refund requires ended lease, explicit order ID confirmation, and an authorized World API key. If outcome is uncertain, mark \`needs_reconciliation\` and check the ledger **without reissuing a second refund**.
## Validation / rollout gate
1. Isolated .NET 10 Release build + OGL DLL preflight.
2. PHP syntax and contract tests (\`tests/test-pure.php\`, \`tests/test-treasury-service.php\`).
3. MariaDB migration on an isolated test database, then new rental box registration.
4. Bomlitz local payment test: tenant −10 NV$, treasury +10 NV$, original box owner unchanged; exactly one \`Rental\` order / receipt / payment / lease extension.
5. Test negative cases: unknown object, mismatched owner, other active tenant, wrong payment amount, backend timeout, repeated callback, refund and normal object payment.
6. Only after successful acceptance: backup, staged rollout, monitoring, explicitly enable the two feature flags.
**The branch does not change production behavior.** Treasury remains disabled by default, and no production wallet or PHP database has been altered.