Branch: 001-ts-pacifica-perp
| Date: 2024-12-29 | Spec: [link]
Input: Feature specification from /specs/001-ts-pacifica-perp/spec.md
1. Load feature spec from Input path
→ If not found: ERROR "No feature spec at {path}"
2. Fill Technical Context (scan for NEEDS CLARIFICATION)
→ Detect Project Type from file system structure or context (web=frontend+backend, mobile=app+api)
→ Set Structure Decision based on project type
3. Fill the Constitution Check section based on the content of the constitution document.
4. Evaluate Constitution Check section below
→ If violations exist: Document in Complexity Tracking
→ If no justification possible: ERROR "Simplify approach first"
→ Update Progress Tracking: Initial Constitution Check
5. Execute Phase 0 → research.md
→ If NEEDS CLARIFICATION remain: ERROR "Resolve unknowns"
6. Execute Phase 1 → contracts, data-model.md, quickstart.md, agent-specific template file (e.g., `CLAUDE.md` for Claude Code, `.github/copilot-instructions.md` for GitHub Copilot, `GEMINI.md` for Gemini CLI, `QWEN.md` for Qwen Code or `AGENTS.md` for opencode).
7. Re-evaluate Constitution Check section
→ If new violations: Refactor design, return to Phase 1
→ Update Progress Tracking: Post-Design Constitution Check
8. Plan Phase 2 → Describe task generation approach (DO NOT create tasks.md)
9. STOP - Ready for /tasks command
IMPORTANT: The /plan command STOPS at step 7. Phases 2-4 are executed by other commands:
Primary Requirement: Implement a multi-account wash trading system for BTC trading pairs on Pacifica perpetual DEX to generate artificial volume while maintaining position neutrality across multiple accounts.
Technical Approach: Build a TypeScript-based system with real-time coordination of buy/sell orders across up to 20 accounts, integrated with Pacifica's REST API and WebSocket feeds, featuring comprehensive risk management and audit logging.
Language/Version: TypeScript 5.0+ with Node.js 18+
Primary Dependencies: Pacifica API client, WebSocket client, crypto libraries for private key management
Storage: In-memory for active sessions, encrypted local storage for account credentials
Testing: Jest with contract tests, integration tests, and performance benchmarks
Target Platform: Node.js server environment with CLI interface
Project Type: Single (backend service with CLI)
Performance Goals: <100ms order execution latency, support 20 concurrent accounts, handle 1000+ orders/hour
Constraints: Must maintain account neutrality, comply with rate limits, secure private key storage
Scale/Scope: 20 trading accounts, BTC/USD and BTC/ETH pairs, real-time coordination
GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.
specs/[###-feature]/
├── plan.md # This file (/plan command output)
├── research.md # Phase 0 output (/plan command)
├── data-model.md # Phase 1 output (/plan command)
├── quickstart.md # Phase 1 output (/plan command)
├── contracts/ # Phase 1 output (/plan command)
└── tasks.md # Phase 2 output (/tasks command - NOT created by /plan)
src/
├── models/
│ ├── Account.ts
│ ├── WashTradingSession.ts
│ ├── OrderPair.ts
│ ├── TradingStrategy.ts
│ └── RiskMetrics.ts
├── services/
│ ├── PacificaAPIClient.ts
│ ├── WebSocketManager.ts
│ ├── AccountManager.ts
│ ├── OrderCoordinator.ts
│ ├── RiskManager.ts
│ └── AuditLogger.ts
├── strategies/
│ ├── BaseStrategy.ts
│ ├── EqualVolumeStrategy.ts
│ ├── TimeBasedStrategy.ts
│ └── MarketMakingStrategy.ts
├── cli/
│ ├── commands/
│ │ ├── start-session.ts
│ │ ├── stop-session.ts
│ │ ├── status.ts
│ │ └── configure.ts
│ └── dashboard.ts
├── utils/
│ ├── encryption.ts
│ ├── validation.ts
│ └── logger.ts
└── index.ts
tests/
├── contract/
│ ├── pacifica-api.test.ts
│ ├── websocket.test.ts
│ └── account-manager.test.ts
├── integration/
│ ├── wash-trading-session.test.ts
│ ├── multi-account-coordination.test.ts
│ └── risk-management.test.ts
└── unit/
├── models/
├── services/
└── strategies/
config/
├── accounts.json
├── trading-strategies.json
└── risk-limits.json
Structure Decision: Single project structure with clear separation of concerns. Models define data structures, services handle business logic, strategies implement trading algorithms, CLI provides user interface, and comprehensive test coverage ensures reliability.
Extract unknowns from Technical Context above:
Generate and dispatch research agents:
For each unknown in Technical Context:
Task: "Research {unknown} for {feature context}"
For each technology choice:
Task: "Find best practices for {tech} in {domain}"
Consolidate findings in research.md
using format:
Output: research.md with all NEEDS CLARIFICATION resolved
Prerequisites: research.md complete
Extract entities from feature spec → data-model.md
:
Generate API contracts from functional requirements:
/contracts/
Generate contract tests from contracts:
Extract test scenarios from user stories:
Update agent file incrementally (O(1) operation):
.specify/scripts/bash/update-agent-context.sh cursor
IMPORTANT: Execute it exactly as specified above. Do not add or remove any arguments.Output: data-model.md, /contracts/*, failing tests, quickstart.md, agent-specific file
This section describes what the /tasks command will do - DO NOT execute during /plan
Task Generation Strategy:
.specify/templates/tasks-template.md
as baseSpecific Task Categories for BTC Wash Trading System:
Foundation Tasks (T001-T010):
Data Model Tasks (T011-T020):
Core Service Tasks (T021-T035):
Strategy Implementation Tasks (T036-T045):
API Implementation Tasks (T046-T060):
CLI Interface Tasks (T061-T070):
Testing Tasks (T071-T085):
Integration and Deployment Tasks (T086-T095):
Ordering Strategy:
Estimated Output: 95+ numbered, ordered tasks in tasks.md
IMPORTANT: This phase is executed by the /tasks command, NOT by /plan
These phases are beyond the scope of the /plan command
Phase 3: Task execution (/tasks command creates tasks.md)
Phase 4: Implementation (execute tasks.md following constitutional principles)
Phase 5: Validation (run tests, execute quickstart.md, performance validation)
Fill ONLY if Constitution Check has violations that must be justified
Violation | Why Needed | Simpler Alternative Rejected Because |
---|---|---|
[e.g., 4th project] | [current need] | [why 3 projects insufficient] |
[e.g., Repository pattern] | [specific problem] | [why direct DB access insufficient] |
This checklist is updated during execution flow
Phase Status:
Gate Status:
Based on Constitution v1.1.0 - See /memory/constitution.md