Repository navigation
feat: market-maker saga, versioned schemas, confidential traces, and wallet PnL - #161
Merged
Levi-Ojukwu merged 2 commits intoOct 25, 2026
Merged
Conversation
…aces, and wallet pnl - Make market-maker cycle a resumable saga with explicit step states, checkpoints, and creation recovery (Closes OracleDesk#152) - Publish versioned JSON Schemas for reasoning traces and question documents (Closes OracleDesk#153) - Seal premium reasoning traces with XChaCha20-Poly1305 envelope encryption and key release endpoints (Closes OracleDesk#154) - Compute per-wallet trading PnL, daily performance ledger, and leaderboard from indexed events (Closes OracleDesk#155) Closes OracleDesk#152, OracleDesk#153, OracleDesk#154, OracleDesk#155
This was referenced Oct 17, 2026
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.
Summary
Resolves issues #152, #153, #154, and #155 on OracleDesk-Backend:
1. Resumable Market-Maker Saga (#152)
MarketGenerationRun) with step checkpoints:STARTED→SIGNALS_READY→PROPOSED→MARKET_PERSISTED→QUESTION_PINNED→CHAIN_SUBMITTED→CHAIN_CONFIRMED→TRACE_PERSISTED→TRACE_PINNED→TRACE_PUBLISHED→COMPLETED.market_count()downward matchingquestion_hashandcreator === CONTRACTS.treasuryto prevent duplicate seed capital expenditure.createMarketOnChainintoprepareMarketCommitmentandsubmitMarketCreation.pinAndPublishTraceintopinTraceandpublishPinnedTrace.NEEDS_ATTENTIONterminal state.GET /admin/generation-runs,GET /admin/generation-runs/:id, andPOST /admin/generation-runs/:id/cancel.2. Versioned JSON Schemas for Traces and Questions (#153)
TraceDocV1atsrc/schemas/trace.ts,QuestionDocV1&QuestionDocV2atsrc/schemas/question.ts) with top-level$id,schemaVersion,kind, and strict properties.scripts/gen-schemas.tsandscripts/gen-schemas.mjs(npm run gen:schemas,npm run check:schemas) to validate schema sync.canonicalJsonStrict) rejectingundefined, functions, symbols, and non-finite numbers before hashing./api/v1/schemasserving immutableapplication/schema+json.fromContractsTrace) for contracts-repo traces.3. Confidential Traces with Envelope Encryption (#154)
oracledesk.trace.encv1) with XChaCha20-Poly1305 and AEAD associated data binding public headers andplaintextHash.trace-publish.service.tsto pin sealed envelopes whenTRACE_CONFIDENTIAL=true, ensuring plaintext never leaks to public IPFS while preserving on-chaintrace_hashverifiability.GET /traces/:id/keyfor client-side decryption by subscribed users withTRACE_KEY_RELEASEDaudit logging.POST /internal/traces/:onChainTraceId/keyfor x402 integration with HMAC authentication, timestamp freshness, and nonce replay protection.scripts/unpin-legacy-traces.tsandscripts/rewrap-trace-keys.ts.4. Wallet Trading PnL and Leaderboard (#155)
WalletPosition,WalletStatsDaily,WalletEventApplied) driven by indexedMarketCreated,Trade,Redeemed, andMarketResolvedevents.(yes + no) / 2matching contractsettle_value).npm run pnl:rebuild(scripts/rebuild-wallet-pnl.ts).GET /leaderboard(with windowing, metrics, pagination, caching, and treasury agent labelling) andGET /wallets/:address/stats.Closes #152
Closes #153
Closes #154
Closes #155