Skip to content

feat(auto-trading): restore Phase 1 snapshot scheduler after UTA-split#207

Open
marrrrrcus wants to merge 4 commits into
TraderAlice:masterfrom
marrrrrcus:claude/tender-jackson-e72214
Open

feat(auto-trading): restore Phase 1 snapshot scheduler after UTA-split#207
marrrrrcus wants to merge 4 commits into
TraderAlice:masterfrom
marrrrrcus:claude/tender-jackson-e72214

Conversation

@marrrrrcus
Copy link
Copy Markdown

Summary

Restore the read-only auto-trading snapshot notification layer that was
lost during the UTA-split refactor. Phase 1 only — order execution deferred
to Phase 2 pending new UTA HTTP routes.

Changes

  • src/domain/auto-trading/market-snapshot.ts — reads and validates
    market-snapshot.json written by okx_snapshot_writer.py
  • src/domain/auto-trading/scheduler.ts — Pump-driven tick (not cron engine),
    prevAllClear dedup set, stale-snapshot + CIRCUIT_BREAKER=HALT guards,
    connectorCenter.notify() for signal notification
  • src/core/config.tsautoTradingSchema (enabled=false default,
    tickEvery, marketSnapshotPath), wired into Config + sectionSchemas
  • src/main.ts — wire createAutoTradingScheduler() after heartbeat,
    stop() in shutdown

Per-session contributions

2026-05-24 — Auto-trading Phase 1 restore

  • Restore read-only snapshot scheduler lost during UTA-split (PR workspaces/chat: usability polish (rolling) #183–206)
  • Use Pump primitive (consistent with heartbeat pattern)
  • 7-case unit test covering: first notify, dedup, re-notify after false,
    stale skip, CIRCUIT_BREAKER=HALT skip, missing file, missing price guard
  • Key commits: c105576, 0ed8be4

Test plan

  • pnpm vitest run src/domain/auto-trading/scheduler.spec.ts → 7 passed
  • npx tsc --noEmit — no new errors (existing workspace dependency errors unrelated)
  • Enable with data/config/auto-trading.json: {"enabled":true,"tickEvery":"15m","marketSnapshotPath":"data/market-snapshot.json"}

🤖 Generated with Claude Code

marrrrrcus and others added 4 commits May 24, 2026 01:30
readMarketSnapshotFile + all_clear notify re-added to Alice main process.
Uses Pump (not cron engine) — consistent with heartbeat pattern post-split.

- src/domain/auto-trading/market-snapshot.ts: reads/validates market-snapshot.json
- src/domain/auto-trading/scheduler.ts: Pump tick, dedup prevAllClear set,
  stale-snapshot + CIRCUIT_BREAKER=HALT guards, notify via ConnectorCenter
- src/core/config.ts: autoTradingSchema (enabled=false, tickEvery=15m,
  marketSnapshotPath=data/market-snapshot.json), wired into Config + sectionSchemas
- src/main.ts: createAutoTradingScheduler() after heartbeat, stop() in shutdown

Phase 2 (open/reduce/stp order execution via UTA HTTP routes) deferred.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- scheduler.spec.ts: 7 cases covering all Phase 1 success criteria
  (notify once on transition, no re-notify on stay, re-notify after false,
  stale skip, CIRCUIT_BREAKER=HALT skip, missing file skip, price=undefined guard)
- scheduler.ts: add runNow() to interface (delegates to pump.runNow())
- scheduler.ts: fix price cast — typeof guard, falls back to 0 instead of undefined

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…joined cmdline

On Windows, node_modules/.bin entries are .CMD files. node's spawn()
without shell:true looks for tsx.exe and throws ENOENT. Fix: join
command+args into a single string when shell:true (avoids DEP0190
concat warning). Non-Windows paths unchanged.

Also fix scheduler.spec.ts: createEventLog now takes {logPath} opts
object, not a bare string path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…stderr capture + explicit exe path

- Upgrade @anthropic-ai/claude-agent-sdk 0.2.72 → 0.3.150 (claudeCodeVersion 2.1.150,
  resolves protocol mismatch with user's claude.exe 2.1.149)
- Upgrade @modelcontextprotocol/sdk 1.27.1 → 1.29.0 (peer dep for new agent SDK)
- query.ts: always capture claude.exe stderr so exit-code-1 errors include the real
  error message (previously stderr was /dev/null by default)
- query.ts: on Windows, resolve claude.exe path explicitly via APPDATA lookup so the
  SDK doesn't rely on PATH finding it
- guardian/shared.ts: use cmd.exe /c for spawning .cmd shims on Windows (fixes EINVAL),
  resolve local .bin shims via resolveLocalBin()
- guardian/dev.ts: inject claude.exe directory into PATH so agent-sdk subprocess can
  find it; detect latest versioned dir under %APPDATA%\Claude\claude-code\

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant