Skip to content

Low-resource mode: suspend copy trading, schedule ML training, resource view - #57

Merged
yonixnetwork merged 2 commits into
mainfrom
claude/yonixalpha-platform-architecture-804nb5
Oct 8, 2026
Merged

yonixnetwork merged 2 commits into
mainfrom
claude/yonixalpha-platform-architecture-804nb5

Conversation

@yonixnetwork

Copy link
Copy Markdown
Owner

Keeps the trading core reliable on the 2 GB / 2 vCPU droplet. The database is about 16 GB; measured load was 8–12, with 345 MB free and 1.3 GB of swap in use.

This PR deletes no data, keeps the copy-trading code, and does not change Solana execution, risk or position management. Full report: docs/LOW_RESOURCE_MODE.md.

Changes

Modes and status

  • SYSTEM_RESOURCE_MODE: NORMAL / LOW_RESOURCE / EMERGENCY. The default is LOW_RESOURCE.
  • COPY_TRADING_STATUS: ACTIVE / THROTTLED / SUSPENDED. The default is SUSPENDED.
  • Both are defaults from .env. The dashboard can change them at runtime; the value is stored in platform_settings.operating_mode.
  • Code: yonixalpha_core.operating_mode.

Resource level

  • NORMAL / WARNING / CRITICAL, read from /proc: available memory, load per CPU, and Linux memory pressure (PSI).
  • Thresholds are the RESOURCE_* settings.
  • CRITICAL pauses priority-3 work only (copy trading, ML training, automatic review refreshes).
  • Code: yonixalpha_core.resources.

Copy engine

  • SUSPENDED stops:
    • target watching on all chains;
    • copy entries and mirrored sells;
    • outcome evaluation, wallet profiles and enrichment.
  • SUSPENDED keeps stop loss, trailing and exits for copy positions that are already open.
  • THROTTLED watches less often: EVM every 10 s, outcomes every 10 minutes.
  • Step timers now start due on the first pass.

ml service

  • In LOW_RESOURCE, training runs once a day and never while the level is CRITICAL. A skipped run is recorded as SKIPPED with the reason.
  • Wallet ML pauses together with copy trading.
  • Inference is unchanged.

ML Review

  • New review_status values: CURRENT / STALE / RUNNING / PENDING / FAILED.
  • Returns HTTP 202 while there is no result yet.
  • Automatic refreshes wait while the level is CRITICAL. The Refresh button still computes, except in EMERGENCY.
  • The page shows last calculated, age and status.

API

  • GET /system/resources
  • PUT /system/resource-mode
  • GET /copy/trading-status and POST /copy/trading-status. Resuming returns 409 unless all four COPY_* thresholds hold. Auto-resume is off. Changes are audited.

UI

  • System Health gets a "Server resources" panel: mode badge, level, host / Postgres / Redis figures, memory and CPU per service, and the mode selector.
  • The Copy Trading page gets the status banner ("SUSPENDED — LOW SERVER RESOURCES") and a "Resume Copy Trading" check with a WAIT / OK recommendation.

Infrastructure

  • Heartbeats now include CPU seconds.
  • Worker database pools are 5 + 10 (were 10 + 10). The API keeps 10 + 10.
  • Postgres in prod compose: explicit defaults, effective_cache_size=512MB, max_parallel_workers_per_gather=0, jit=off. A deploy restarts Postgres for a few seconds.

Measurement

  • db_health now prints the mode, per-service memory and CPU, Redis, and Solana pipeline latency.

Tests

  • New tests:
    • core: resources and operating mode;
    • copy-engine: policy against a real DB; SUSPENDED and THROTTLED loops;
    • ml: training schedule and wallet pause;
    • api: resources, resume refusal and audit, review 202/PENDING, review cache statuses.
  • Full suite: core 887, api 175, data-solana 10, data-evm 14, copy-engine 17, discovery 18, migration 11, momentum 11, decision-engine 58, ml 46, paper-trading 81.
  • ruff clean; web tsc / lint / build OK.

Rollout

Staged, as docs/LOW_RESOURCE_MODE.md section 4 describes:

  1. Deploy PR Unblock the copy-engine loop and trim the remaining long EVM queries #56 alone and measure.
  2. Then deploy this PR and measure.

Not yet measured on the server: per-process memory/CPU (docker stats), and the after-deploy figures.

🤖 Generated with Claude Code

https://claude.ai/code/session_015vpuZ1UX4MXz7NCF7wrtDv


Generated by Claude Code

claude added 2 commits October 8, 2026 12:13
…ce view

The 2 GB / 2 vCPU droplet (16 GB database) ran at load 8-12 with 345 MB
free and 1.3 GB swap. Keep the trading core reliable on it; nothing is
deleted and Solana execution is unchanged.

- SYSTEM_RESOURCE_MODE (NORMAL / LOW_RESOURCE / EMERGENCY, default
  LOW_RESOURCE) and COPY_TRADING_STATUS (ACTIVE / THROTTLED / SUSPENDED,
  default SUSPENDED), changeable from the dashboard
  (yonixalpha_core.operating_mode).
- Resource level NORMAL / WARNING / CRITICAL from /proc with configurable
  thresholds (yonixalpha_core.resources); CRITICAL pauses priority-3 work
  only.
- Copy engine: SUSPENDED stops target watching, copy entries, outcomes,
  wallet profiles and enrichment, and keeps managing open copy positions;
  THROTTLED watches less often. Step timers start due on the first pass.
- ml: training once a day in LOW_RESOURCE and never while CRITICAL
  (recorded as SKIPPED with the reason); wallet ML pauses with copy trading.
  Inference is unaffected.
- ML Review: review_status CURRENT / STALE / RUNNING / PENDING / FAILED,
  202 with no result, automatic refreshes deferred while CRITICAL, explicit
  Refresh button.
- API: GET /system/resources, PUT /system/resource-mode,
  GET/POST /copy/trading-status (resume refused unless the COPY_* thresholds
  hold; audited).
- UI: Server resources panel on System Health, copy-trading status banner
  with the resume check, review status lines.
- Heartbeats carry CPU seconds; worker DB pools 5 + 10 (API 10 + 10).
- Postgres (prod): explicit defaults, effective_cache_size 512MB, no
  parallel workers, jit off.
- db_health: mode, per-service memory / CPU, Redis, Solana pipeline latency.
- docs/LOW_RESOURCE_MODE.md: pre-deploy report, changes, PR #56, staged
  rollout, after-deploy table, 8 GB values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vpuZ1UX4MXz7NCF7wrtDv
@yonixnetwork
yonixnetwork merged commit c63f95b into main Oct 8, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants