Services and operators
Which processes keep each feature moving, and what authority each holds.
The web app serves pages and short HTTP requests. The ops service runs the work that must continue between requests: trading loops, game rooms, event projection and mention polling.
Long-running actors
| Actor | Job | Authority |
|---|---|---|
| Strategy runner | Read strategies, make decisions and copy permitted trades | Its key acts under subscribers' live Strategy grants. |
| X relay | Read new mentions and produce execution receipts | Its key acts under linked users' Executor grants. |
| Market maker | Refresh bounded quotes, merge pairs and settle inventory | The key must match the vault's maker role. |
| Leverage keeper | Settle resolved positions or trigger eligible knock-outs | Calls permissionless functions; key pays gas. |
| Game room + matchmaker | Queue players, commit decks and exchange room messages | Holds room/deck secrets; does not own players' signing keys. |
| Duel projector | Read arena events into history, ratings and room updates | Read access and database writes; no trading key needed. |
| Duel settler | Reveal decks and trigger lock, refund, settlement and finalization | Calls available arena functions; key pays gas. |
The full entry point starts all of these:
pnpm --filter @masayume/ops startUse it only with an intentional operator configuration. For one creator's bot, use start:runner instead.
Explicit execution modes
| Actor | When DRY_RUN is omitted |
|---|---|
| Strategy runner | Execution is enabled if its key, database, consent and grants pass the checks. |
| Market maker | Dry-run |
| Leverage keeper | Dry-run |
| Duel settler | Dry-run |
| X relay | This flag is not its execution control. |
Set the mode explicitly for each deployment. X_POSTING_ENABLED controls replies, not X trade execution. Starting a configured relay while reply posting is off can still place trades.
Server services inside web
Sensei and Dry read use the model credential. The sponsor validates requests then spends its own STT. PrivateDesk verifies signed owner instructions and signs desk operations. X sign-in holds the OAuth application secret and session-signing secret.
These keys are server-only. A statement that all operator keys live exclusively in ops would be inaccurate for the current app.
Game deployment dependencies
Web and room must share ROOM_TOKEN_SECRET; web needs GAME_ROOM_PUBLIC_URL. The room requires a secret of at least 16 characters and a known arena. Deck creation requires GAME_DECK_KEY and a writable, persistent journal path.
The journal is written before the deck commitment is published. Persist it outside an ephemeral container filesystem if the operator expects restart recovery. Keep the encryption key separately from the database containing encrypted decks.
The projector starts at a saved cursor or deployment block and catches up in bounded log spans. Without a database it can feed rooms, but history and its cursor do not persist. The settler needs a database worklist and idles without it.
Observe before assuming
- Heartbeats explain why an actor traded, held or could not run.
- Contract receipts establish what actually landed.
- Stored history shows the projection, which may lag or be unavailable.
- Public Status checks core dependencies; it is not a complete attestation of every operator key or background loop.
X reports mention polling, execution recovery and reply delivery separately. Catch-up drains up to 50 pages of 20 mentions while preserving the saved cursor on an incomplete drain. Its durable execution recovery does not replay an instruction or automatically repost an ambiguous reply. See the X execution path for those boundaries.
The X relay verifies its authenticated account and excludes its own replies before command claiming. A startup sweep and repeated database checks suppress unfinished recursive deliveries. If a live reply loop appears, pause reply posting while investigating; separately verify whether any new trade happened and whether execution authority should be revoked.
The strategy runner requires durable decision and execution records before new trades, and holds all submissions by its key while an earlier attempt remains unresolved. Once evidence is readable, paused strategies can still settle their earlier positions to the owner. Current refunded-duel recovery may require manually settling outstanding cards; that is a separate actor's limitation.
Source notes
This guide follows the application code reviewed on 2026-09-07. Links point to that reviewed commit and require repository access. GitHub may show 404 if you are signed out or do not have access.
- services/ops/src/main.ts
- services/ops/src/runner-main.ts
- services/ops/src/actors/strategy-runner/env.ts
- services/ops/src/actors/market-maker/env.ts
- services/ops/src/actors/leverage-keeper/env.ts
- services/ops/src/actors/duel-settler/index.ts
- services/ops/src/actors/duel-projector/index.ts
- services/ops/src/actors/x-relay/index.ts
- web/src/features/private/desk.server.ts
- web/src/features/session/sponsor.server.ts
- services/ops/src/actors/strategy-runner/lifecycle.ts
- services/ops/src/actors/x-relay/poll-cycle.ts
- services/ops/src/actors/x-relay/execution-recovery.ts
- packages/db/src/x-reply-delivery.ts
- web/src/features/x/XRelayStatus.tsx