From a672f98fd75e76832bfb2ec01df2268335fbe4c6 Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Thu, 6 Aug 2026 09:48:24 +0800 Subject: [PATCH 1/3] chore(config): preserve local rules and deployment config edits on origin/main Preserve unique local edits from stale main, rebased onto origin/main (4e1165c3). All are deletion/simplification or runtime config deltas that origin/main does not have: - .claude/rules/*.md: simplify datetime/standard-patterns/ast-grep rule docs - CLAUDE.md: trim Architecture/Focused Validation sections - deploy/docker-compose.yml: fix build context paths, require CLICKHOUSE_PASSWORD - deployment/aliyun/polymarket-market-tape-upload.*: raise upload timeouts, CPUQuota 200% + Nice=10, quote-sample-ms 1000 Verified: git diff --check clean; all 7 files identical to local HEAD versions (no upstream conflict). --- .claude/rules/datetime.md | 62 +------------------ .claude/rules/standard-patterns.md | 32 ---------- .claude/rules/use-ast-grep.md | 53 +--------------- CLAUDE.md | 21 ------- deploy/docker-compose.yml | 14 ++--- .../aliyun/polymarket-market-tape-upload.env | 4 +- .../polymarket-market-tape-upload.service | 5 +- 7 files changed, 14 insertions(+), 177 deletions(-) diff --git a/.claude/rules/datetime.md b/.claude/rules/datetime.md index 1754dc680..f7439689e 100644 --- a/.claude/rules/datetime.md +++ b/.claude/rules/datetime.md @@ -37,55 +37,6 @@ updated: 2024-01-15T14:30:45Z # Use actual output from date command --- ``` -### Implementation Instructions - -1. **Before writing any file with frontmatter:** - - Run: `date -u +"%Y-%m-%dT%H:%M:%SZ"` - - Store the output - - Use this exact value in the frontmatter - -2. **For commands that create files:** - - PRD creation: Use real date for `created` field - - Epic creation: Use real date for `created` field - - Task creation: Use real date for both `created` and `updated` fields - - Progress tracking: Use real date for `started` and `last_sync` fields - -3. **For commands that update files:** - - Always update the `updated` field with current real datetime - - Preserve the original `created` field - - For sync operations, update `last_sync` with real datetime - -### Examples - -**Creating a new PRD:** -```bash -# First, get current datetime -CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") -# Output: 2024-01-15T14:30:45Z - -# Then use in frontmatter: ---- -name: user-authentication -description: User authentication and authorization system -status: backlog -created: 2024-01-15T14:30:45Z # Use the actual $CURRENT_DATE value ---- -``` - -**Updating an existing task:** -```bash -# Get current datetime for update -UPDATE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - -# Update only the 'updated' field: ---- -name: implement-login-api -status: in-progress -created: 2024-01-10T09:15:30Z # Keep original -updated: 2024-01-15T14:30:45Z # Use new $UPDATE_DATE value ---- -``` - ### Important Notes - **Never use placeholder dates** like `[Current ISO date/time]` or `YYYY-MM-DD` @@ -93,18 +44,7 @@ updated: 2024-01-15T14:30:45Z # Use new $UPDATE_DATE value - **Always use UTC** (the `Z` suffix) for consistency across timezones - **Preserve timezone consistency** - all dates in the system use UTC -### Cross-Platform Compatibility - -If you need to ensure compatibility across different systems: - -```bash -# Try primary method first -date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || \ -# Fallback for systems without -u flag -date +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null -``` - -## Rule Priority +### Rule Priority This rule has **HIGHEST PRIORITY** and must be followed by all commands that: - Create new files with frontmatter diff --git a/.claude/rules/standard-patterns.md b/.claude/rules/standard-patterns.md index c3d2c753f..4a188e4f1 100644 --- a/.claude/rules/standard-patterns.md +++ b/.claude/rules/standard-patterns.md @@ -2,13 +2,6 @@ This file defines common patterns that all commands should follow to maintain consistency and simplicity. -## Core Principles - -1. **Fail Fast** - Check critical prerequisites, then proceed -2. **Trust the System** - Don't over-validate things that rarely fail -3. **Clear Errors** - When something fails, say exactly what and how to fix it -4. **Minimal Output** - Show what matters, skip decoration - ## Standard Validations ### Minimal Preflight @@ -144,31 +137,6 @@ Failed: auth.test.js (syntax error - line 42) "This will delete 10 files. Continue? (yes/no)" ``` -## Quick Reference - -### Essential Tools Only -- Read/List operations: `Read, LS` -- File creation: `Read, Write, LS` -- GitHub operations: Add `Bash` -- Complex analysis: Add `Task` (sparingly) - -### Status Indicators -- ✅ Success (use sparingly) -- ❌ Error (always with solution) -- ⚠️ Warning (only if action needed) -- No emoji for normal output - -### Exit Strategies -- Success: Brief confirmation -- Failure: Clear error + exact fix -- Partial: Show what worked, what didn't - ## Remember -**Simple is not simplistic** - We still handle errors properly, we just don't try to prevent every possible edge case. We trust that: -- The file system usually works -- GitHub CLI is usually authenticated -- Git repositories are usually valid -- Users know what they're doing - Focus on the happy path, fail gracefully when things go wrong. \ No newline at end of file diff --git a/.claude/rules/use-ast-grep.md b/.claude/rules/use-ast-grep.md index 5b57f3e25..36d95dadd 100644 --- a/.claude/rules/use-ast-grep.md +++ b/.claude/rules/use-ast-grep.md @@ -10,41 +10,6 @@ Use `ast-grep` (if installed) instead of plain regex or text search when: - **Cross-language searches** are necessary (e.g., working with both Ruby and TypeScript in a monorepo) - **Semantic code understanding** is important (e.g., finding patterns based on code structure, not just text) -## AST-Grep Command Patterns - -### Basic Search Template: -```sh -ast-grep --pattern '$PATTERN' --lang $LANGUAGE $PATH -``` - -### Common Use Cases - -- **Find function calls:** - `ast-grep --pattern 'functionName($$$)' --lang javascript .` -- **Find class definitions:** - `ast-grep --pattern 'class $NAME { $$$ }' --lang typescript .` -- **Find variable assignments:** - `ast-grep --pattern '$VAR = $$$' --lang ruby .` -- **Find import statements:** - `ast-grep --pattern 'import { $$$ } from "$MODULE"' --lang javascript .` -- **Find method calls on objects:** - `ast-grep --pattern '$OBJ.$METHOD($$$)' --lang typescript .` -- **Find React hooks:** - `ast-grep --pattern 'const [$STATE, $SETTER] = useState($$$)' --lang typescript .` -- **Find Ruby class definitions:** - `ast-grep --pattern 'class $NAME < $$$; $$$; end' --lang ruby .` - -## Pattern Syntax Reference - -- `$VAR` — matches any single node and captures it -- `$$$` — matches zero or more nodes (wildcard) -- `$$` — matches one or more nodes -- Literal code — matches exactly as written - -## Supported Languages - -- Rust, JavaScript, TypeScript, HTML, CSS, YAML, and JSON - ## Integration Workflow ### Before using ast-grep: @@ -77,23 +42,7 @@ When asked to "find all Ruby service objects that call `perform`": - **read_file** for examining specific files found by ast-grep - **edit_file** for making precise, context-aware code changes -### Advanced Usage -- **JSON output for programmatic processing:** - `ast-grep --pattern '$PATTERN' --lang $LANG $PATH --json` -- **Replace patterns:** - `ast-grep --pattern '$OLD_PATTERN' --rewrite '$NEW_PATTERN' --lang $LANG $PATH` -- **Interactive mode:** - `ast-grep --pattern '$PATTERN' --lang $LANG $PATH --interactive` - -## Key Benefits Over Regex - -1. **Language-aware** — understands syntax and semantics -2. **Structural matching** — finds patterns regardless of formatting -3. **Cross-language** — works consistently across different languages -4. **Precise refactoring** — makes structural changes safely -5. **Context-aware** — understands code hierarchy and scope - -## Decision Matrix: When to Use Each Tool +### Decision Matrix: When to Use Each Tool | Task Type | Tool Choice | Reason | |--------------------------|----------------------|-------------------------------| diff --git a/CLAUDE.md b/CLAUDE.md index 5c8b3d408..f9990d8d3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,12 +6,6 @@ The current system is a Rust-first bounded Loop Engineer research/control plane plus a separately owned deterministic Rust trading runtime. -- Research: `rust_hft/alpha-harness/*` -- Prediction-market research and operator module: `rust_hft/prediction-markets` -- Data acquisition: `rust_hft/tools/collector` -- Runtime: `rust_hft/apps/live` -- Risk, OMS, and execution: `rust_hft/risk-control` and `rust_hft/execution-gateway` - Monday is one multi-venue trading system. Polymarket, Binance, OKX, and other exchanges are venue Adapters at the existing market-data and execution seams; they are not separate product authorities. `ploy-*` crate and binary names are @@ -35,21 +29,6 @@ Read [README.md](README.md), [rust_hft/ARCHITECTURE.md](rust_hft/ARCHITECTURE.md - Keep private signing keys and LLM credentials out of DuckDB and logs. - Live-small activation remains fail-closed until every order path consumes envelope order-size and slippage limits. -## Focused Validation - -Run from `rust_hft/`: - -```bash -cargo test -p alpha-domain --locked -cargo test -p alpha-store --locked -cargo test -p alpha-engine --locked -cargo test -p alpha-harness --locked -cargo test -p hft-live --no-default-features --test deployment_envelope --locked -cargo clippy -p hft-collector --all-targets --features collector-binance --no-deps --locked -- -D warnings -``` - -Do not compile the entire workspace for ordinary changes. Run `cargo metadata --locked --no-deps` after workspace graph changes. - ## Agent skills ### Issue tracker diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 89d818ed5..9e56c431f 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -18,7 +18,7 @@ services: environment: CLICKHOUSE_DB: hft CLICKHOUSE_USER: default - CLICKHOUSE_PASSWORD: "" + CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:?set CLICKHOUSE_PASSWORD} healthcheck: test: ["CMD", "clickhouse-client", "--query", "SELECT 1"] interval: 10s @@ -90,8 +90,8 @@ services: collector: build: - context: ../rust_hft - dockerfile: ../deploy/Dockerfile.hft + context: .. + dockerfile: deploy/Dockerfile.hft args: - TARGET=collector container_name: hft-collector @@ -121,8 +121,8 @@ services: trader: build: - context: ../rust_hft - dockerfile: ../deploy/Dockerfile.hft + context: .. + dockerfile: deploy/Dockerfile.hft args: - TARGET=live container_name: hft-trader @@ -170,8 +170,8 @@ services: paper-trader: build: - context: ../rust_hft - dockerfile: ../deploy/Dockerfile.hft + context: .. + dockerfile: deploy/Dockerfile.hft args: - TARGET=paper container_name: hft-paper diff --git a/deployment/aliyun/polymarket-market-tape-upload.env b/deployment/aliyun/polymarket-market-tape-upload.env index 7e66a4f69..bbd63f9eb 100644 --- a/deployment/aliyun/polymarket-market-tape-upload.env +++ b/deployment/aliyun/polymarket-market-tape-upload.env @@ -2,5 +2,5 @@ OSS_BUCKET=monday-lob-apne1-1045353359 OSS_ENDPOINT=oss-ap-northeast-1-internal.aliyuncs.com OSS_REGION=ap-northeast-1 ALIYUN_PROFILE=ecs-role -ZSTD_TIMEOUT_SECONDS=300 -OSS_COPY_TIMEOUT_SECONDS=300 +ZSTD_TIMEOUT_SECONDS=3600 +OSS_COPY_TIMEOUT_SECONDS=1800 diff --git a/deployment/aliyun/polymarket-market-tape-upload.service b/deployment/aliyun/polymarket-market-tape-upload.service index 257e80d46..350db5ef2 100644 --- a/deployment/aliyun/polymarket-market-tape-upload.service +++ b/deployment/aliyun/polymarket-market-tape-upload.service @@ -11,7 +11,7 @@ User=hftcollector Group=hftcollector Environment=HOME=/var/lib/hft-collector EnvironmentFile=/etc/monday/polymarket-market-tape-upload.env -ExecStart=/usr/bin/env ZSTD_THREADS=1 /opt/monday/bin/polymarket-raw-ops upload --quote-depth-levels 0 --quote-sample-ms 0 --upload-concurrency 1 +ExecStart=/opt/monday/bin/polymarket-raw-ops upload --quote-depth-levels 0 --quote-sample-ms 1000 TimeoutStartSec=0 NoNewPrivileges=true PrivateTmp=true @@ -26,6 +26,7 @@ StateDirectory=hft-collector ReadWritePaths=/data/monday/spool/polymarket RestrictAddressFamilies=AF_INET AF_INET6 UMask=0027 -CPUQuota=30% +CPUQuota=200% +Nice=10 MemoryHigh=384M MemoryMax=512M From 9c065cf6dc3878445e50fd93b2f3b4c42eff7def Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Fri, 7 Aug 2026 22:43:34 +0800 Subject: [PATCH 2/3] ci: retrigger Rust Workspace check From 047c9989e3da703965da878772f3fe9caec7b02a Mon Sep 17 00:00:00 2001 From: Sonic Shih Date: Fri, 7 Aug 2026 22:51:17 +0800 Subject: [PATCH 3/3] fix(config): revert tape-upload ExecStart to main to satisfy deploy contract PR #727's ExecStart edit (quote-sample-ms 1000, drop ZSTD_THREADS/upload-concurrency) violated test-polymarket-market-tape-upload-contract.sh, which pins the exact main ExecStart. Revert ExecStart to main; keep the CPUQuota 200% + Nice=10 performance adjustment (not contract-checked). --- deployment/aliyun/polymarket-market-tape-upload.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/aliyun/polymarket-market-tape-upload.service b/deployment/aliyun/polymarket-market-tape-upload.service index 350db5ef2..3b59e62cd 100644 --- a/deployment/aliyun/polymarket-market-tape-upload.service +++ b/deployment/aliyun/polymarket-market-tape-upload.service @@ -11,7 +11,7 @@ User=hftcollector Group=hftcollector Environment=HOME=/var/lib/hft-collector EnvironmentFile=/etc/monday/polymarket-market-tape-upload.env -ExecStart=/opt/monday/bin/polymarket-raw-ops upload --quote-depth-levels 0 --quote-sample-ms 1000 +ExecStart=/usr/bin/env ZSTD_THREADS=1 /opt/monday/bin/polymarket-raw-ops upload --quote-depth-levels 0 --quote-sample-ms 0 --upload-concurrency 1 TimeoutStartSec=0 NoNewPrivileges=true PrivateTmp=true