feat(economy): add semantic gil telemetry module#121
Closed
Shuu-37 wants to merge 1 commit into
Closed
Conversation
Author
|
Superseded by #122 on the consolidated �conomy branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I affirm:
What does this pull request do?
This draft adds semantic gil telemetry as one independently enabled Phoenix module:
modules/phoenix/economy/**plus onemodules/init.txtentry. It does not patch LandSandBoatsrc/**,scripts/**, SQL, or core settings.The producer is disabled by default. This PR does not deploy or enable it in beta or production. The companion schema-v2 API draft is phoenix-api#62.
Architecture and data flow
authoritative Lua/native transaction -> fixed-size record -> bounded tokenized MPSC queue -> background validator/sequencer -> canonical JSON + SHA-256 -> durable gzip spool -> separate forwarder -> API/PostgreSQLtry_enqueueonly. It performs no network, database, JSON, compression, or filesystem work.OnTimeServerTick; a stalled game loop cannot manufacture continuing progress.super, preserve return values/errors, and synchronously unwind semantic context. With the enable flag unset/false, the Lua file returns before loading module utilities or registering overrides.OnIncomingPacketis observation-only, always returnsfalse, and never callspacket.process; core retains transaction ownership.Instrumented transaction points
Semantic Lua before/after attribution:
addGil,delGil,setGil,confirmTrade, andtradeCompletebindings, covering all Lua callers through one module seam.InteractionLookupquest/mission containers andnpcUtil.completeQuest/completeMission.createShopcaptures stable active-NPC identity for the later native shop packet.Version-pinned, non-consuming native correlation:
0x083+ walletITEM_NUMdebit + S2C shop success.0x085+ wallet credit + S2C item result; clipped mint emits applied value plusforgoneMint.0x106+ both wallet legs + success result -> base transfer, tax burn, and any currency-cap loss.0x033+ both wallet legs + both S2C0x022end results; canceled/failed trades emit no event.0x04eLotIn + wallet debit + S2C listing success -> listing-fee burn.onMobDeathExstable mob/member stage + walletITEM_NUM+ S2C0x029Obtains -> correlated applied drop/forgone mint or an explicit gap.Direct-mutation audit also covered AH bid debit, delivery escrow/claim/return, item movement, native monster distribution, shops, bazaar, and trade. AH sale remains owned by the existing replica lane to prevent double counting; delivery lacks a reliable after-commit seam. Unmatched wallet deltas become
attributionGaps, never guessedother_*accounting events.Semantic coverage matrix
mugstarting_gil,admin_grant,admin_removeregime_reward, standardbattlefield_rewardbazaar_sale,bazaar_taxplayer_tradeauction_listing_feechocobo_rentalmob_dropquest_reward,mission_reward,quest_feetransport_feeservice_feecurrency_cap_lossauction_saledelivery_boxscript_reward,other_mint,other_burn,other_transferPerformance and backpressure evidence
Test results
xi_mapconfigure/build/link — passed.clang-format22.1 dry run and C++ sanity checks — passed..lua; the test fixture uses.luatestand is not recursively executed.git diff --check— passed.Security and privacy considerations
xi_map.xi_maprequires a unique producer ID and spool directory. The current flat-directory forwarder design requires one service instance per map spool.Beta rollout sequence
beta, apply migration 0027, and verify API health with no producer credential or game producer enabled.modules/init.txtchange; do not overwrite unrelated work.beta, build, and restart beta withPHOENIX_ECONOMY_TELEMETRY_ENABLEDunset/false. Verify the current singlexi_maphas no producer thread/spool/Lua overrides and establish disabled tick/CPU baselines./var/lib/phoenix-economy/xi_map-54230/spool, owned by the game/forwarder principals with 0750 directory and 0640 files; enforce the 256 MiB budget.economy:ingest:betakey and store it only in the forwarder environment. Configure endpoint, poll/timeout, and producer settings; keep producer and forwarder disabled.CONTENT_VERSION, and its spool path. Do not change production.Rollback procedure
Unset/set
PHOENIX_ECONOMY_TELEMETRY_ENABLED=falseand gracefully restart the beta canary so it attempts a final watermark. Stop expansion; let the forwarder drain only API-acknowledged files, preserve unacknowledged spool files for diagnosis, then stop/disable the forwarder if needed. Roll back to the priorxi_mapbinary only if required. The additive API schema can remain; do not drop it during an incident. No gameplay MariaDB reversal is involved.Remaining gaps and risks
other_*events are unsupported.CPPModule::OnShutdownhook exists;atexitfinal watermark is best effort and crashes remain conservatively visible as unclean boots.xi_mapprocesses.Steps to test these changes
Also build the full
xi_maptarget, run the repository C++/Lua formatting checks, and test once withPHOENIX_ECONOMY_TELEMETRY_ENABLEDunset to confirm no Lua overrides or spool worker are activated.