# Workflow

# Drop — Development Workflow

## Overview

Drop development follows the GOTCHA framework workflow:
**Boot → Mission Control → Agent Spawn → Build → Validate → Done**

---

## 1. Boot (`boot.sh`)

Every session starts with:
```bash
bash ~/system/boot.sh
```

This verifies all 6 GOTCHA layers:
- **Goals** — specs and rules loaded
- **Orchestration** — John (AI Director) ready
- **Tools** — task.sh, mc.js, hivemind accessible
- **Context** — domain knowledge available
- **Hard prompts** — instruction templates loaded
- **Args** — behavior config applied

Boot also reads HiveMind intel.

---

## 2. Mission Control — Task Management

### Create a task
```bash
node ~/system/tools/mc.js add "Feature: Send Money" --desc "Wire /send to /api/transactions" --priority H --owner john
```

### Start working
```bash
node ~/system/tools/mc.js start <id>
```
This creates `/tmp/mc-active-task` — required by enforcer hooks to allow Write/Edit operations.

### Complete
```bash
node ~/system/tools/mc.js done <id> "Wired /send to API. Tests passing."
```

### Other commands
```bash
mc.js list                    # All open tasks
mc.js list --owner john       # My tasks
mc.js pause <id>              # Pause (blocks Write/Edit)
mc.js resume <id>             # Resume paused task
mc.js block <id> "reason"     # Block with reason
mc.js show <id>               # Full details
mc.js active                  # Who's working on what
```

---

## 3. Agent Spawn — Builder/Validator Teams

For implementation tasks, John spawns Claude subagents:

### Builder Agent
- **Role:** Implements ONE task
- **Tools:** Read, Write, Edit, Bash, Glob, Grep
- **Model:** Sonnet (never Opus for agents)
- **Config:** `~/.claude/agents/builder.md`

Spawn pattern:
```
Task tool → subagent_type: "general-purpose"
Prompt: "Implement feature X. Read the code first. Follow CLAUDE.md rules."
```

### Validator Agent
- **Role:** Verifies ONE task (READ-ONLY)
- **Tools:** Read, Bash, Glob, Grep (no Write/Edit)
- **Model:** Sonnet or Haiku
- **Config:** `~/.claude/agents/validator.md`

Spawn pattern:
```
Task tool → subagent_type: "general-purpose"
Prompt: "Validate feature X. Check code quality, tests, no regressions."
```

### Model Budget
| Model | When |
|-------|------|
| **Opus** | Alem session, planning — NEVER for agents |
| **Sonnet** | Builders, validators — default for agents |
| **Haiku** | Trivial tasks — file search, lint, git |

---

## 4. Development Flow — Feature Lifecycle

```
[Pending] → mc.js start → [In Progress] → Build → Test → mc.js done → [Done]
                              ↓
                        spawn builder
                              ↓
                        spawn validator
                              ↓
                         HiveMind post
```

### Feature Tracking

Drop uses a built-in feature tracking system (`src/lib/features.ts`) with 25 features across categories:

| Category | Features | Status |
|----------|----------|--------|
| Authentication | Registration, PIN Login, Logout, Biometric | 3/4 passing |
| KYC | Identity Verification | 1/1 passing |
| Banking | IBAN, Balance, Send, Receive, History, Top-up | 5/6 passing |
| Cards | Virtual, Freeze/Unfreeze, Transactions, Physical | 4/4 passing |

Check feature status:
```typescript
import { getFeatureStats, printFeatureReport } from '@/lib/features'
printFeatureReport() // ASCII status report
```

---

## 5. Architecture Quick Reference

### Stack
- **Framework:** Next.js 16.1.6 (App Router)
- **Runtime:** React 19.2.3
- **Database:** PostgreSQL 16 (all environments) via Drizzle ORM
- **Auth:** JWT (7-day expiry) + SHA-256 PIN hashing
- **Styling:** Tailwind CSS 4

### API Endpoints
| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/api/auth/register` | POST | Register (phone + PIN) |
| `/api/auth/login` | POST | Login |
| `/api/account` | GET | Account details + balance |
| `/api/cards` | GET/POST | List/create cards |
| `/api/cards/[id]` | GET/PATCH | Card details/freeze |
| `/api/transactions` | GET/POST | List/send money |
| `/api/transactions/simulate` | POST | Simulate incoming (demo) |
| `/api/health` | GET | Health check |

### Service Mocks (dev mode)
| Service | Provider | Mock File |
|---------|----------|-----------|
| BaaS | Swan | `src/lib/services/mock-swan.ts` |
| Cards | Stripe Issuing | `src/lib/services/mock-stripe.ts` |
| KYC | Sumsub | `src/lib/services/mock-sumsub.ts` |

Mode controlled by `NEXT_PUBLIC_SERVICE_MODE` env var (default: "mock").

### Database Schema
4 tables: `users`, `accounts`, `cards`, `transactions`
Schema defined in `src/lib/db.ts`

### State Management
Global context via `AppProvider` (`src/lib/context/AppContext.tsx`):
- Auth: register, login, logout
- KYC: start, submit, check
- Banking: getBalance, sendMoney, refreshTransactions
- Cards: create, freeze, getDetails
- Demo: simulateIncoming, simulatePurchase

---

## 6. Local Development

```bash
cd ~/ALAI/products/Drop/src/drop-app
npm install
npm run dev          # Dev server on localhost:3000
npm run build        # Production build
npm run test         # Jest tests (25 tests, 100% passing)
npm run lint         # ESLint
```

### Test Results (Feb 7, 2026)
- 25 tests total — 100% passed
- Integration: 9/9
- Edge cases: 16/16
- Execution time: 21.2s

---

## 7. Deployment

- **Platform:** AWS Amplify (Next.js optimized)
- **Region:** eu-central-1 (Frankfurt)
- **Build:** Turbopack with standalone output
- **Details:** See `DEPLOYMENT.md`

---

## 8. Open Tasks (Drop)

| Task | Priority | Owner | Description |
|------|----------|-------|-------------|
| #191 | HIGH | john | Wire /send page to /api/transactions/remittance |
| #192 | HIGH | john | Wire /scan page to /api/transactions/qr-payment |
| #193 | HIGH | john | Wire /merchant page to real APIs |
| #180 | MED | john | E2E test: full remittance flow |
| #182 | MED | john | Update design and layout |
| #196 | MED | john | Document merchant, recipients, rates feature |
| #198 | LOW | john | Delete mock-data.ts and orphaned components |

---

## 9. Anti-Hallucination Rules

From `~/system/rules/agent-anti-hallucination.md`:
- **TBD > Hallucination** — say "I don't know" rather than guess
- **Cross-file check** — read schema before writing code
- **No phantom deps** — only import what exists in package.json
- **Placeholder = fatalError()** — never leave silent stubs