Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions AUDIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Audit and Fix Plan — Polymarket MVP Phase 2 Live Path

Scope: Review all Phase 2 live-path changes, unify data paths, ensure safety gates, and prepare a clean, auditable path toward Phase 3 live pilot.

Summary of issues found (high level):
- Unused/legacy imports in Phase 2 live index (ingest-live import not used in runtime path).
- Inconsistent wallet/config gating across modules; added PHASE2_KILL_SWITCH and wallet-config checks, but some paths may still bypass gates.
- Live-bet path currently relies on sandbox logic but still retains a live bet call in some patches; ensure all live bets are gated behind edge checks and kill switches.
- Phase 2 live data ingestion tables in Supabase may not align with Phase 2 DB migrations; ensure table naming is consistent (polymarket_phase2_prices, polymarket_phase2_markets, polymarket_trades).
- Tests exist for edge logic but CI smoke tests are not fully wired; need CI to run a sandbox ingest + edge-run with no money.
- Wallet signer scaffolds are in place but not wired for a real wallet; ensure configuration guards are explicit and secure for future live path usage.
- Documentation gaps: Phase 2 gating protocol, how to enable live mode, and what to test in sandbox should be documented clearly in AUDIT and PR bodies.

Proposed fixes (high-level):
- Remove unused imports and dead code paths; ensure a clean baseline in main Phase 2 index.
- Strengthen gating: ensure PHASE2_KILL_SWITCH, PHASE2_LIVE_MODE, PHASE2_LIVE_WALLET_CONFIGURED are all checked in every live path, and log when a path is skipped.
- Align DB schema expectations with existing migrations and ensure the Phase 2 patch creates/uses the expected tables consistently.
- Add a robust, minimal test harness for Phase 2 edge logic with deterministic scenarios.
- Document Phase 2 live gating clearly in a single place (FIX_PLAN.md and PR body templates).
- Prepare Phase 3 Phase PR body with onboarding, compliance steps, and a test plan.

Acceptance criteria:
- [ ] Phase 2 index.js has no unused imports and all live paths are gated by a kill switch and wallet config check.
- [ ] All Phase 2 data ingestion and signal generation flows are auditable in Supabase with clear log entries.
- [ ] Phase 2 tests pass locally or in CI for edge logic; no money is involved.
- [ ] Phase 3 gating checklist exists in PR and Phase 3 patch is ready for review.

Owner: You (fintech development strategist) and the patching agent.
184 changes: 42 additions & 142 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,42 @@
# CLAUDE.md — VibeFlow AI Compliance Platform

## Project Overview
VibeFlow is an AI-powered compliance officer SaaS for small businesses.
It uses multi-agent AI to scan businesses, identify applicable regulations
(GDPR, CCPA, HIPAA, SOC 2, EU AI Act), generate compliant policies,
perform gap analysis, and provide remediation steps — all at $49/month
instead of the $15,000+/year that competitors charge.

## Tech Stack
- **IDE**: Claude Code + Antigravity Skills
- **Framework**: Next.js 14+ (App Router)
- **Database**: Supabase (PostgreSQL + pgvector for AI)
- **Auth**: Supabase Auth (Email/Password + Google Social)
- **Payments**: Stripe Checkout
- **Hosting**: Vercel
- **UI/Styling**: Tailwind CSS + Shadcn UI
- **Animations**: Framer Motion (Clean, professional transitions)
- **AI Engine**: VoltAgent Framework + Groq (Llama 3) + Gemini Proase (PostgreSQL + Auth + Realtime)
- **Vector DB**: Qdrant Cloud (free tier) for regulation embeddings
- **Hosting**: Vercel (free tier)
- **Payments**: Stripe (free to setup, pay-per-transaction)

## Project Structure
```
vibeflow/
├── src/
│ ├── app/ # Next.js App Router pages
│ │ ├── page.tsx # Landing page
│ │ ├── dashboard/ # User dashboard
│ │ ├── scan/ # Compliance scan interface
│ │ ├── policies/ # Generated policies
│ │ ├── reports/ # Gap analysis reports
│ │ └── api/ # API routes
│ │ ├── agents/ # VoltAgent endpoints
│ │ ├── scan/ # Scan API
│ │ ├── policies/ # Policy generation API
│ │ └── webhooks/ # Stripe webhooks
│ ├── agents/ # VoltAgent agent definitions
│ │ ├── supervisor.ts # Supervisor agent (orchestrator)
│ │ ├── scanner.ts # Regulation Scanner agent
│ │ ├── policy-generator.ts # Policy Generator agent
│ │ ├── gap-analyzer.ts # Gap Analysis agent
│ │ ├── remediation.ts # Remediation agent
│ │ └── monitor.ts # Regulatory Monitor agent
│ ├── tools/ # VoltAgent tools
│ │ ├── web-scraper.ts # Website analysis tool
│ │ ├── regulation-rag.ts # RAG retrieval tool
│ │ ├── policy-template.ts # Policy template tool
│ │ └── scoring.ts # Compliance scoring tool
│ ├── lib/ # Shared utilities
│ │ ├── supabase.ts # Supabase client
│ │ ├── qdrant.ts # Qdrant vector client
│ │ ├── embeddings.ts # Embedding generation
│ │ └── regulations/ # Regulation data (JSON)
│ │ ├── gdpr.json
│ │ ├── ccpa.json
│ │ ├── hipaa.json
│ │ ├── soc2.json
│ │ └── eu-ai-act.json
│ ├── components/ # React components
│ │ ├── ui/ # shadcn/ui base components
│ │ ├── dashboard/ # Dashboard components
│ │ ├── scan/ # Scan UI components
│ │ └── landing/ # Landing page components
│ └── types/ # TypeScript types
│ ├── regulations.ts
│ ├── scan-results.ts
│ └── policies.ts
├── .env.local # Environment variables (NEVER COMMIT)
├── CLAUDE.md # This file
└── package.json
```

## Code Style
- TypeScript strict mode, no `any` types ever
- Use named exports, not default exports
- Tailwind utility classes only, no custom CSS files
- Functional components with hooks only
- 2-space indentation
- camelCase for variables/functions, PascalCase for components/types
- Every component must have proper TypeScript interfaces

## Commands
- `npm run dev` — Start development server (port 3000)
- `npm run build` — Production build
- `npm run lint` — ESLint check
- `npx supabase start` — Start local Supabase

## Critical Rules
- NEVER commit .env or .env.local files
- NEVER store API keys in code — always use environment variables
- NEVER use `any` type — always define proper interfaces
- ALL user data must go through Supabase Row Level Security (RLS)
- ALL API routes must validate authentication before processing
- ALL AI-generated policy text must include disclaimer: "This is not legal advice"
- Regulation data in /lib/regulations/ must cite specific articles/sections
- Every compliance score must show calculation methodology

## Agent Architecture (VoltAgent)
The system uses a Supervisor pattern:
1. **SupervisorAgent** — Routes user requests to specialized agents
2. **ScannerAgent** — Analyzes business type and identifies applicable regulations
3. **PolicyGeneratorAgent** — Creates compliant policy documents using RAG
4. **GapAnalyzerAgent** — Compares current state vs requirements, produces scored report
5. **RemediationAgent** — Generates step-by-step fixes with code snippets
6. **MonitorAgent** — Tracks regulatory changes and sends alerts

Each agent has:
- Specific system prompt defining its role
- Access to relevant tools only (principle of least privilege)
- RAG access to regulation embeddings in Qdrant

## Database Schema (Supabase)
- `users` — Auth users (managed by Supabase Auth)
- `organizations` — Business profiles
- `scans` — Scan results with compliance scores
- `policies` — Generated policy documents
- `gaps` — Identified compliance gaps
- `remediations` — Remediation steps and status
- `alerts` — Regulatory change alerts

## Environment Variables Required
```
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
GOOGLE_GENERATIVE_AI_API_KEY=
GROQ_API_KEY=
QDRANT_URL=
QDRANT_API_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
```

## When Building Features
1. Always start with the TypeScript types/interfaces
2. Build the agent tool first, then the agent, then the API route, then the UI
3. Use VoltAgent's Supervisor pattern for all multi-agent orchestration
4. Test each agent individually before connecting to supervisor
5. All regulation references must include article numbers and direct quotes
# CLAUDE.md — VibeFlow Polymarket Bot (Phase 2+)

Overview
- This document describes the Phase 2+ architecture for a zero-cost Polymarket MVP that ingests live data, generates signals, and simulates trades in a sandboxed environment prior to any live money.
- All data and bets are sandboxed; live money path requires explicit compliance gating.

Project Scope and Roadmap (concise)
- Phase 0/Phase 1: Foundation and data ingestion scaffolding (Phase 1 patch already in repo)
- Phase 2: Live data path + sandboxed trading loop; edge-based bet sizing; gated live wallet integration scaffolds; CI workflows
- Phase 3: Fully gated live pilot with formal compliance review and wallet onboarding; phased rollout toward live trading with risk controls

Key Tech Stack (2026):
- Hosting: Free tiers (Replit/Render/Railway) for cloud deployments
- Backend: Supabase (PostgreSQL + Auth + RLS) – FREE tier
- Data: Live Polymarket data adapter (Phase 2) with Phase 1 as fallback mock data
- Orchestration: Inngest (free tier) for background jobs (Phase 3 gating when enabling live path)
- ML/LLM: Free-tier LLM (OpenRouter or equivalent) in sandbox; deterministic prompts for Phase 2+ until real API is wired
- Wallet: Wallet signer scaffolds with gated live integration; no private keys committed

Architecture Overview (high-level analogy)
- Data Ingest: Like a rain gauge—collects market data regularly and stores it.
- Signal Engine: The weather predictor—uses a small model to decide BUY/SELL/HOLD with a confidence score.
- Ledger: Paper wallet—simulates balances and PnL.
- Executor: Sandbox trading engine—executes simulated bets, logs results, and tracks risk.
- Orchestrator: A scheduler (Inngest later) that stitches data, signals, and ledger updates together.
- LLM: The market whisperer—returns structured signals that the engine validates before applying them.
- Secrets: All keys live in environment variables; never exposed in the browser or repo.

Security & Compliance Guardrails
- Phase 2 live path is opt-in; a kill switch (PHASE2_KILL_SWITCH) gates any live bets.
- Wallet onboarding must be explicit, with keys stored in a secrets manager or env vars; never in code.
- All data is sandboxed; avoid any PII in prompts/logs; record only audit logs and non-sensitive metrics.

How to Read this Document
- Start with Phase 2: Live Data & Sandbox Path; Phase 3 adds live pilots and governance.
- Section references link to actual code changes in the repo.

Environment and Secrets
- Keys live in environment variables (SUPABASE_URL, SUPABASE_ANON_KEY, PHASE2_LIVE_MODE, PHASE2_LIVE_WALLET_CONFIGURED, PHASE2_KILL_SWITCH, etc).
- No keys should be committed to Git or exposed in UI logs.

This doc is the single source of truth for governance about the Phase 2+ rollout. It will be updated as we implement changes and reach new stages.
32 changes: 32 additions & 0 deletions FIX_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Phase 2 Live Patch Fix Plan (auditable, incremental)

1) Phase 2 – Gate enforcement
- Ensure PHASE2_KILL_SWITCH, PHASE2_LIVE_MODE, PHASE2_LIVE_WALLET_CONFIGURED are checked on every live path
- Add logs when gates block progress

2) Phase 2 – Code Hygiene
- Remove unused imports (ingest-live) from polymarket-mvp-phase2-live/index.js
- Normalize environment variable handling; convert string booleans to booleans robustly

3) Phase 2 – Data path alignment
- Align live ingestion tables to existing naming conventions: polymarket_phase2_markets, polymarket_phase2_prices, polymarket_trades
- Ensure ingestion writes to these tables consistently

4) Phase 2 – Edge logic robustness
- Ensure edge and betFraction from edge.js are always numeric and clamped
- Add a small unit test to validate edge outputs (Yes/No) for a couple of market scenarios

5) Phase 2 – Tests and CI
- Add a small CI smoke test that runs ingestion and a single signal generation in sandbox mode
- Ensure tests don’t perform any live bets or external API calls

6) Phase 3 readiness
- Add Phase 3 governance checklist in PR body (privacy, compliance, wallet onboarding)
- Add a Phase 3 pilot plan with a safe, auditable live path gated behind compliance

Acceptance criteria for Phase 2 fixes:
- All gating variables defined and used consistently; no bypass paths
- No unused imports anywhere in Phase 2
- Data ingestion and signals are persisted in a stable schema
- Tests pass and CI can verify sandbox end-to-end
- Phase 3 patch will be ready for governance review
24 changes: 24 additions & 0 deletions debug-market-research.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: debug-market-research
summary: "Focused assistant for code debugging plus market/competitive research in the VibeFlow codebase."
persona: "Technical analyst who combines engineer-level debugging with product and market research context."
when_to_use:
- "Need a fast, structured debugging triage with code search and test build loops."
- "Need product/market research recommendations or competitive context for new features."
tool_preferences:
use:
- grep_search
- file_search
- read_file
- run_in_terminal
- fetch_webpage
avoid:
- speculative brainstorming without explicit evidence
- unverified external data sources (unless explicitly requested)
scopes:
- code: "Find and fix bugs in the codebase, suggest minimal reproducible test cases, and apply TDD steps when safe."
- market: "Collect market landscape insights, compare competitive features, and align with the product roadmap in this repo."
protocol:
- "Start with a revised problem statement and target outcome."
- "Always cite source files and command outputs for conclusions."
- "Produce concise root-cause analysis bullets and concrete code edits (with patch commands)."
- "When market research is requested, include brief 'why this matters' impact notes."
53 changes: 53 additions & 0 deletions extension/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* LeakWall Service Worker (Background Script)
* Handles extension lifecycle, badge updates, and cross-tab state.
*/

chrome.runtime.onInstalled.addListener(({ reason }) => {
if (reason === 'install') {
chrome.storage.local.set({
totalBlocked: 0,
leakEvents: [],
settings: {
enabled: true,
sensitivity: 'medium',
showNotifications: true,
monitoredTools: [
'ChatGPT', 'Claude', 'Gemini', 'Copilot', 'DeepSeek',
'Perplexity', 'Poe', 'Mistral', 'Jasper', 'Copy.ai',
],
},
});

chrome.tabs.create({ url: chrome.runtime.getURL('onboarding.html') });
}
});

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === 'GET_STATS') {
chrome.storage.local.get(['totalBlocked', 'leakEvents', 'settings'], (data) => {
sendResponse({
totalBlocked: data.totalBlocked || 0,
recentEvents: (data.leakEvents || []).slice(0, 5),
settings: data.settings || {},
});
});
return true;
}

if (message.type === 'UPDATE_SETTINGS') {
chrome.storage.local.get(['settings'], (data) => {
const updated = { ...data.settings, ...message.payload };
chrome.storage.local.set({ settings: updated });
sendResponse({ ok: true });
});
return true;
}

if (message.type === 'CLEAR_EVENTS') {
chrome.storage.local.set({ leakEvents: [], totalBlocked: 0 });
chrome.action.setBadgeText({ text: '' });
sendResponse({ ok: true });
return true;
}
});
Loading