Start a new SiXiS project

PROJECT-ONBOARDING-V0-1 / PHASE 1 / PASTE-BASED FLOW

Draft cc08adcd…

PROD ADMIN VIEW · READ-ONLY · WRITES STILL ON LOCAL
Resume this draft in a fresh Claude Code session
Owner: quangholio. Two ways to pick this up:
OPTION A — Bootstrap prompt (works for any operator, no slash command needed)
You are operating as the SiXiS Project Onboarding orchestrator brain (Claude) for a NON-TOMMY operator (no local SiXiS install — all substrate writes go through HTTP endpoints on dashboard.sixis.ai).

A user has initiated a new SiXiS project via the dashboard at https://dashboard.sixis.ai/new-project. They have provided this brain dump:

---
# Card 4 Handoff — for next chat session

**Prev card:** Card 3 (Stripe placeholder — synthetic walkthrough) — shipped 2026-05-15
**Cycle:** `879ca7b7` (Sweats v1 umbrella)

---

## What you start with

Card 3 is done — both R1 (DeepSeek + Gemini judge) and R2 (GPT + Claude.ai)
council rounds converged at RATIFY-WITH-NITS, all nits folded in (commit
`2d51e44`). Live on `sweats.poker`. The synthetic walkthrough is gated off
in prod (no `SYNTHETIC_WEBHOOK_SECRET` configured + double NODE_ENV/VERCEL_ENV
guard); the webhook + admin refund routes are deployed but inert until real
Stripe is wired or the flag is enabled in a dev env.

Read first, in order:
1. [`docs/cards/CARD_3_SPEC.md`](CARD_3_SPEC.md) — narrative + decisions register (R1 + R2)
2. [`docs/cards/CARD_3_MANIFEST.md`](CARD_3_MANIFEST.md) — inventory + verification
3. Run `bash scripts/verify-card-3.sh` — should print 28 PASS / 0 FAIL
4. Run `bash scripts/verify-card-2.sh` — should print 11 PASS / 0 FAIL

## Possible Card 4 candidates (Tommy picks)

The Card 3 closeout surfaces three viable next moves:

### Option A — Real Stripe integration (cutover Card)

Direct continuation of Card 3 once a Stripe account is registered. Scope:

- `pnpm add stripe`
- Replace the synthetic verify branch in `src/lib/payments/webhook-verify.ts`
  with `stripe.webhooks.constructEvent` (the stub is annotated for this).
- Wire Stripe Checkout button on /wallet, replacing `SimulateCheckoutButton`
  (or leaving both behind a feature toggle for dev parity).
- Vercel env: `STRIPE_WEBHOOK_SECRET` set; `SYNTHETIC_WEBHOOK_SECRET` unset.
- Reuse `verify-card-3.sh` happy-path with `source='stripe'`.
- **Blocker:** Sweepstakes attorney signoff (Gate A) before real money flows.
- **Pre-requisite:** Tommy registers Stripe account.

### Option B — Card 1a (admin audit log)

Co-requisite that Card 3 punted on. Currently `ledger.audit` is the inline
audit store; promote to a global `audit_events` table per Card 1 spec so
admin actions across the platform (grants, refunds, age-gate, KYC) share one
trail.

### Option C — Card 3a (pre-launch GC sale on landing page)

Founding-member bonus tiers + referral GC mechanics on the existing
`sweats.poker` landing page. The synthetic walkthrough is already plumbed,
so Card 3a's UI work can ship before real Stripe — selling "founder seats"
that hold tagged synthetic GC redeemable into real GC at Stripe cutover.
This needs the Tier-3 sovereign question resolved first (see below).

## Open Tier-3 sovereign question

**Are synthetic-source ledger entries PERMANENT or wiped on real-Stripe cutover?**

The Card 3 default is **permanent + tagged** (`metadata.purchase_source = 'synthetic'`).
Tommy's later call is one SQL UPDATE/DELETE in either direction. Surface this
explicitly at the start of Card 3a (Option C) — the answer determines whether
"founding-member purchases" are marketing language or actual ledger truth.

## Protocol going forward (carried from Card 3 — DO NOT skip)

1. **Council cross-poll** at architectural decision points. Card 3's R1 went
   only to DeepSeek, then closed convergence on DeepSeek + Gemini judge +
   Gemini reviewer without polling GPT or Claude.ai. Sovereign correctly
   flagged this as a protocol gap; R2 ratification round rectified. **Future
   Cards: every cross-poll must hit all three brains (DeepSeek API + GPT
   desktop + Claude.ai Chrome MCP) before declaring R1 converged.** Claude.ai
   recommended a formal quorum rule: convergence requires one vote each from
   {reasoning-model, judge, peer-reviewer} tiers. Worth surfacing to the
   SiXiS protocol layer at the next FORCED_RULE proposal.
2. **Per-brain relay matrix** (unchanged from Card 2 handoff):
   - DeepSeek → API via `~/Documents/Claude/Projects/SixiS/projects/deepseek_api_v0_1/sixis/deepseek_client.py` (REMEMBER: `DEEPSEEK_API_KEY` in `~/.zshrc`, bash does not auto-source).
   - GPT → ChatGPT desktop app, **sweats.poker** project folder.
   - Claude.ai → Chrome MCP on Tommy's Desktop PC Chrome, **Sweats.Poker** project folder.
   - Gemini → judge + reviewer via `~/.npm-global/bin/gemini --skip-trust --output-format text -p "..."`.
3. **At Card N closeout:** `CARD_N_SPEC.md` + `CARD_N_MANIFEST.md` +
   `scripts/verify-card-N.sh` + `CARD_(N+1)_HANDOFF.md`. Gemini reviewer
   final-stamp before commit. `SIXIS_OPERATOR=quangholio` for all Sweats CLI work.

## Don't-repeat gotchas (carried from Card 3)

- The `ledger` schema is NOT in PostgREST's `db_schemas`. New ledger
  functions intended for HTTP need a `public.*` SECURITY DEFINER shim
  (migration 0006 is the template). Plain `admin.rpc("fn_name")` resolves
  against `public` only.
- After any new RPC migration, fire `NOTIFY pgrst, 'reload schema'` (or
  include it at the end of the migration file) — PostgREST caches the
  schema and won't see new functions until reload.
- Repo-local git author is `Sweats <valuebet.app@gmail.com>` — do NOT override.
- `LEDGER_ADMIN_TOKEN` still not set in Vercel — admin grant + admin refund
  both 500 in prod until Tommy adds via dashboard (Vercel CLI is on the
  wrong account).
- Substrate sync gap: Sweats cycle `879ca7b7` lives on Supabase but not in
  local SQLite; CLI event writes go straight to Supabase. The Card 3 project
  on SQLite (`p_sweats_v1_card_3_stripe_placeholder`) is parallel scaffolding,
  not the source of truth.

## Carry-forward still pending (not addressed in Card 3)

- `LEDGER_ADMIN_TOKEN` Vercel env var
- Card 1a (admin audit log) — Card 3 used `ledger.audit` as documented stopgap
- Sweepstakes attorney signoff (Gate A) — required before Option A (real Stripe)
- CSRF tokens on POST routes — Card 3 webhook auth is HMAC, not session, so
  not technically blocked, but other future POST routes still need this
---

## CURRENT STACK & DEPLOY STATE (auto-injected from substrate)

**Hosting:**
- `dashboard.sixis.ai` → Vercel static export (`ui/`)
- `dashboard.sixis.ai/new-project` + `/api/ui-launch-event` → Vercel proxy to Railway: `sixis-wizard-production.up.railway.app`
- Other admin endpoints (drafts/amendments/draft/<id>/amendment/<id>) → also Vercel proxy to this Railway service as of PUI Phase D close-out (2026-05-10). Honor-system admin gate via ?owner= URL param. Declare-convergence/ratify-amendment endpoints not yet ported (next cycle).

**Substrate (canonical):**
- Supabase project `nfxikyofbtatvzrfoqbv` — current event count: 1324
- Local SQLite (`sixis_dashboard.db`) is an archive after Phase B replay caught up (2026-05-07). Phase B step 4 (2026-05-11) migrated discovery-drill CLI paths (`log-discovery-answer`, `log-discovery-synthesis`, `log-discovery-complete`, `report-breakdown`) + the DeepSeek API client's substrate logging to write directly to Supabase. Remaining SQLite-writing CLI paths sync up via the post-invoke mirror.
- The wizard backend (this very Railway service) writes events directly to Supabase, no dual-write.

**Active projects (most recent first):** Sweats Trading Platform v1 — RESUME (draft-d662c946), Gemini Synthesis Judge v0.1 (gemini-synthesis-judge-v0-1), Active Attention Engine (active-attention-engine)

**Last shipped change:** Built gcloud ADC + venv + gsc_pull.py demand-brief tool; tested end-to-end; scheduled task updated to pull GSC before Batch 3.

**Council relay discipline — CORRECTED MATRIX (ratified by Tommy 2026-05-11T02:14, Universal Shell amendment in flight):**
- `cross-poll` defaults `--auto-relay ON`. The orchestrator (Claude Code session) drives all brains directly. API/CLI is the PRIMARY path for the two non-browser brains; browser control is FOR THE TWO REMAINING BROWSER-ONLY BRAINS ONLY:
  - **DeepSeek (voter)** → API via `deepseek_api_v0_1/sixis/deepseek_client.py` (`call_deepseek`). Browser fallback at chat.deepseek.com (Expert/DeepThink mode) ONLY when the API client returns `ok=False` with `fallback=browser`.
  - **Gemini (judge + reviewer)** → CLI/API via `gemini-synthesis-judge-v0-1/` (and `gemini-cli-judge-wrapper-v0-1/`). No browser path needed.
  - **GPT (voter)** → ChatGPT desktop app via computer-use MCP. New chat created INSIDE the "SiXiS" project folder (per per-project chat-thread rule).
  - **Claude.ai (voter)** → claude.ai via Claude-in-Chrome MCP. New chat created INSIDE the SiXiS project folder.
- Tommy is NOT a packet-routing relay node. Pipeline: prompt DeepSeek first via API (longest reasoning), kick off GPT + Claude.ai in browser windows while DeepSeek streams, capture all three responses in any order they arrive.

**Ratification cadence (extended convergence rule, ratified 2026-05-07):**
- Genuine multi-brain convergence at any tier (1/2/3) = automatic ratification — orchestrator proceeds without explicit Tommy ask.
- "Doubt is the cross-poll trigger" — when orchestrator has uncertainty, fire a cross-poll, don't decide unilaterally and don't ask Tommy.
- Sovereign-only matters (red-line risks, irreversible data destruction, money movement, account creation) still always escalate.

**Discoveries fold into scope (rule established 2026-05-07):** anything surfaced during this drill that's adjacent and relevant folds INTO the project's scope by default — don't punt to followups unless folding shifts the tier.


Wizard IDs (use these in the curl POSTs below — DO NOT change them):
- draft_id: cc08adcd-0d5b-41e9-8bff-6aa46f81f49c
- cycle_id: 37245c60-914e-443b-bede-66a36fe09099
- owner: ask the user which operator they're acting as (e.g. "quangholio") and use that value verbatim — DO NOT default to "tommy"

## Your job

Per FORCED_RULE_PO_01 (Conversational Discovery Drill), drill the user ONE QUESTION AT A TIME.

The internal checklist below is YOUR scaffolding — NOT an interrogation script for the user. Pick the most upstream open question, ask it, listen, let the answer pivot/collapse/deepen the queue.

Internal checklist:
- intent (the frozen Z1 statement of what they want to build)
- scope (in scope vs explicitly out of scope)
- consumers (who/what uses this)
- constraints (technical, time, resources, external commitments)
- success criteria (how they know it shipped well)
- failure modes (what could break, how they'd detect)
- reversibility / tier classification (Tier 1/2/3)
- required artifacts / deliverables
- known unknowns

Do NOT batch questions. Do NOT pre-load 5+ at once. Per FORCED_RULE_PO_01 this is a hard rule from the project's own Cycle Zero.

## Substrate logging (HTTP, no local CLI required)

After EACH user answer, log it to substrate via curl:
```
curl -sS -X POST https://dashboard.sixis.ai/api/log-discovery-answer \
  -H "Content-Type: application/json" \
  -d '{"draft_id": "cc08adcd-0d5b-41e9-8bff-6aa46f81f49c", "cycle_id": "37245c60-914e-443b-bede-66a36fe09099", "question": "<the question you asked>", "answer": "<their answer>", "owner": "<operator>"}'
```

When you reach pollable sufficiency (the council can disagree productively without first asking what the project is), summarize the sharpened intent and ask the user to confirm. Then log the synthesis:
```
curl -sS -X POST https://dashboard.sixis.ai/api/log-discovery-synthesis \
  -H "Content-Type: application/json" \
  -d '{"draft_id": "cc08adcd-0d5b-41e9-8bff-6aa46f81f49c", "cycle_id": "37245c60-914e-443b-bede-66a36fe09099", "synthesis_text": "<your sharpened-intent summary>", "owner": "<operator>"}'
```

After the user confirms the synthesis, mark discovery complete:
```
curl -sS -X POST https://dashboard.sixis.ai/api/log-discovery-complete \
  -H "Content-Type: application/json" \
  -d '{"draft_id": "cc08adcd-0d5b-41e9-8bff-6aa46f81f49c", "cycle_id": "37245c60-914e-443b-bede-66a36fe09099", "owner": "<operator>"}'
```

Then propose firing the council cross-poll. (Council cross-poll endpoints are not yet HTTP-exposed; for now, the user will need to surface to Tommy/admin to fire R1+R2. This is a known gap — see draft f8b196a0 next phase.)

## Error handling

If anything crashes, the user reports a wizard issue, or you encounter a malformed/unworkable state mid-drill, log a breakdown:
```
curl -sS -X POST https://dashboard.sixis.ai/api/report-breakdown \
  -H "Content-Type: application/json" \
  -d '{"draft_id": "cc08adcd-0d5b-41e9-8bff-6aa46f81f49c", "cycle_id": "37245c60-914e-443b-bede-66a36fe09099", "description": "<what went wrong>", "severity": "blocking", "owner": "<operator>"}'
```

The user can also report breakdowns from the dashboard "⚠ Report friction" button (bottom-right corner of any wizard page).

## Verifying writes landed

Each curl returns JSON like `{"ok": true, "event_id": "..."}` on success or `{"error": "..."}` on failure. ALWAYS check the response. If a write fails, surface the error to the user immediately and DO NOT proceed to the next question — the substrate must reflect every Q&A for the council to deliberate from.

You can verify substrate state any time by fetching:
```
curl -sS https://dashboard.sixis.ai/draft/cc08adcd-0d5b-41e9-8bff-6aa46f81f49c?owner=<operator>
```
Returns the live event timeline rendered as HTML; grep for "discovery_answer_logged" / "discovery_synthesis_logged" / "wizard_step_completed" to confirm.
Paste into any fresh Claude Code chat — Claude runs the discovery drill on the brain dump.
OPTION B — Slash-command shortcut (Tommy's setup only — needs ~/.claude/commands/sixis-pickup.md installed)
/sixis-pickup cc08adcd-0d5b-41e9-8bff-6aa46f81f49c
Brain dump (raw)
Original input from /new-project. Stored as raw evidence per FORCED_RULE_PO_02; never edited in place.
# Card 4 Handoff — for next chat session

**Prev card:** Card 3 (Stripe placeholder — synthetic walkthrough) — shipped 2026-05-15
**Cycle:** `879ca7b7` (Sweats v1 umbrella)

---

## What you start with

Card 3 is done — both R1 (DeepSeek + Gemini judge) and R2 (GPT + Claude.ai)
council rounds converged at RATIFY-WITH-NITS, all nits folded in (commit
`2d51e44`). Live on `sweats.poker`. The synthetic walkthrough is gated off
in prod (no `SYNTHETIC_WEBHOOK_SECRET` configured + double NODE_ENV/VERCEL_ENV
guard); the webhook + admin refund routes are deployed but inert until real
Stripe is wired or the flag is enabled in a dev env.

Read first, in order:
1. [`docs/cards/CARD_3_SPEC.md`](CARD_3_SPEC.md) — narrative + decisions register (R1 + R2)
2. [`docs/cards/CARD_3_MANIFEST.md`](CARD_3_MANIFEST.md) — inventory + verification
3. Run `bash scripts/verify-card-3.sh` — should print 28 PASS / 0 FAIL
4. Run `bash scripts/verify-card-2.sh` — should print 11 PASS / 0 FAIL

## Possible Card 4 candidates (Tommy picks)

The Card 3 closeout surfaces three viable next moves:

### Option A — Real Stripe integration (cutover Card)

Direct continuation of Card 3 once a Stripe account is registered. Scope:

- `pnpm add stripe`
- Replace the synthetic verify branch in `src/lib/payments/webhook-verify.ts`
  with `stripe.webhooks.constructEvent` (the stub is annotated for this).
- Wire Stripe Checkout button on /wallet, replacing `SimulateCheckoutButton`
  (or leaving both behind a feature toggle for dev parity).
- Vercel env: `STRIPE_WEBHOOK_SECRET` set; `SYNTHETIC_WEBHOOK_SECRET` unset.
- Reuse `verify-card-3.sh` happy-path with `source='stripe'`.
- **Blocker:** Sweepstakes attorney signoff (Gate A) before real money flows.
- **Pre-requisite:** Tommy registers Stripe account.

### Option B — Card 1a (admin audit log)

Co-requisite that Card 3 punted on. Currently `ledger.audit` is the inline
audit store; promote to a global `audit_events` table per Card 1 spec so
admin actions across the platform (grants, refunds, age-gate, KYC) share one
trail.

### Option C — Card 3a (pre-launch GC sale on landing page)

Founding-member bonus tiers + referral GC mechanics on the existing
`sweats.poker` landing page. The synthetic walkthrough is already plumbed,
so Card 3a's UI work can ship before real Stripe — selling "founder seats"
that hold tagged synthetic GC redeemable into real GC at Stripe cutover.
This needs the Tier-3 sovereign question resolved first (see below).

## Open Tier-3 sovereign question

**Are synthetic-source ledger entries PERMANENT or wiped on real-Stripe cutover?**

The Card 3 default is **permanent + tagged** (`metadata.purchase_source = 'synthetic'`).
Tommy's later call is one SQL UPDATE/DELETE in either direction. Surface this
explicitly at the start of Card 3a (Option C) — the answer determines whether
"founding-member purchases" are marketing language or actual ledger truth.

## Protocol going forward (carried from Card 3 — DO NOT skip)

1. **Council cross-poll** at architectural decision points. Card 3's R1 went
   only to DeepSeek, then closed convergence on DeepSeek + Gemini judge +
   Gemini reviewer without polling GPT or Claude.ai. Sovereign correctly
   flagged this as a protocol gap; R2 ratification round rectified. **Future
   Cards: every cross-poll must hit all three brains (DeepSeek API + GPT
   desktop + Claude.ai Chrome MCP) before declaring R1 converged.** Claude.ai
   recommended a formal quorum rule: convergence requires one vote each from
   {reasoning-model, judge, peer-reviewer} tiers. Worth surfacing to the
   SiXiS protocol layer at the next FORCED_RULE proposal.
2. **Per-brain relay matrix** (unchanged from Card 2 handoff):
   - DeepSeek → API via `~/Documents/Claude/Projects/SixiS/projects/deepseek_api_v0_1/sixis/deepseek_client.py` (REMEMBER: `DEEPSEEK_API_KEY` in `~/.zshrc`, bash does not auto-source).
   - GPT → ChatGPT desktop app, **sweats.poker** project folder.
   - Claude.ai → Chrome MCP on Tommy's Desktop PC Chrome, **Sweats.Poker** project folder.
   - Gemini → judge + reviewer via `~/.npm-global/bin/gemini --skip-trust --output-format text -p "..."`.
3. **At Card N closeout:** `CARD_N_SPEC.md` + `CARD_N_MANIFEST.md` +
   `scripts/verify-card-N.sh` + `CARD_(N+1)_HANDOFF.md`. Gemini reviewer
   final-stamp before commit. `SIXIS_OPERATOR=quangholio` for all Sweats CLI work.

## Don't-repeat gotchas (carried from Card 3)

- The `ledger` schema is NOT in PostgREST's `db_schemas`. New ledger
  functions intended for HTTP need a `public.*` SECURITY DEFINER shim
  (migration 0006 is the template). Plain `admin.rpc("fn_name")` resolves
  against `public` only.
- After any new RPC migration, fire `NOTIFY pgrst, 'reload schema'` (or
  include it at the end of the migration file) — PostgREST caches the
  schema and won't see new functions until reload.
- Repo-local git author is `Sweats <valuebet.app@gmail.com>` — do NOT override.
- `LEDGER_ADMIN_TOKEN` still not set in Vercel — admin grant + admin refund
  both 500 in prod until Tommy adds via dashboard (Vercel CLI is on the
  wrong account).
- Substrate sync gap: Sweats cycle `879ca7b7` lives on Supabase but not in
  local SQLite; CLI event writes go straight to Supabase. The Card 3 project
  on SQLite (`p_sweats_v1_card_3_stripe_placeholder`) is parallel scaffolding,
  not the source of truth.

## Carry-forward still pending (not addressed in Card 3)

- `LEDGER_ADMIN_TOKEN` Vercel env var
- Card 1a (admin audit log) — Card 3 used `ledger.audit` as documented stopgap
- Sweepstakes attorney signoff (Gate A) — required before Option A (real Stripe)
- CSRF tokens on POST routes — Card 3 webhook auth is HMAC, not session, so
  not technically blocked, but other future POST routes still need this
Event timeline (6)
Every event tagged with this draft_id, in chronological order.
project_draft_started system · 2026-05-15 09:14:58+00:00
You started a new project draft via /new-project (draft_id=cc08adcd-0d5b-41e9-8bff-6aa46f81f49c).
draft_saved system · 2026-05-15 09:14:58+00:00
You saved the brain-dump for draft cc08adcd-0d5b-41e9-8bff-6aa46f81f49c: "# Card 4 Handoff — for next chat session **Prev card:** Card 3 (Stripe placeholder — synthetic walkthrough) — shipped 2026-05-15 **Cycle:** `879ca7b7` (Sweats v1 umbrella) --- ## What you start wit…"
discovery_prompt_generated system · 2026-05-15 09:14:58+00:00
Generated the discovery drill prompt for draft cc08adcd-0d5b-41e9-8bff-6aa46f81f49c using prompt_templates.discovery_drill v1.
brain_response_logged deepseek · 2026-05-15 09:24:51+00:00
DEEPSEEK Round 1 response for draft cc08adcd-0d5b-41e9-8bff-6aa46f81f49c: "**DeepSeek R1 — Sweats v1 Card 4 scope-decision poll** PICK B — It is the only option with zero external blockers or deferred decisions, directly builds the compliance infrastructure needed for Cards…"
brain_response_logged gpt · 2026-05-15 09:25:13+00:00
GPT Round 1 response for draft cc08adcd-0d5b-41e9-8bff-6aa46f81f49c: "**GPT R1 — Sweats v1 Card 4 scope-decision poll** (B) is the strongest sequencing decision given the constraints already locked by sovereign directive. Reasoning by option: A — Real Stripe integrat…"
brain_response_logged claude · 2026-05-15 09:25:33+00:00
CLAUDE Round 1 response for draft cc08adcd-0d5b-41e9-8bff-6aa46f81f49c: "**Claude.ai R1 — Sweats v1 Card 4 scope-decision poll** Reading the constraints as given: A is out. Gate A attorney signoff isn't in hand and Tommy hasn't registered the Stripe account. Picking a ca…"