# White Paper #1: Primitive Cognitive Architecture — Memory-Veto vs RAG

---

## One-line summary

Why an accumulating store of trade_outcome facts that refuses setups differs structurally from standard retrieval-augmented LLM use.

---

## The Market Problem: LLM + RAG is Not Intelligence

The trading AI market has hundreds of "LLM trader" products. They share a common architecture:

1. Fetch market data
2. Stuff it into a prompt
3. Ask the LLM to decide
4. Maybe vectorize some past trades and retrieve them into the prompt

This is **retrieval, not reasoning**. The LLM still decides everything. It cannot refuse its own prompt.

The result is what we call "prompt shopping": vendors tune the prompt until it produces desirable outputs on historical data. This is overfitting disguised as intelligence.

LLM+RAG has a place in trading — for news summarization, earnings call analysis, sentiment extraction. But for trade decisions, retrieval without refusal is just expensive indicator manipulation.

---

## The Memory-Veto Primitive

Cognitive Trader differs at the architectural primitive. The memory layer is not advisory — it has **veto authority** over the LLM's choice.

The flow is:

```
Signal → Memory Retrieval → Veto Check → LLM Decision → Execution
                      ↘________________↗
```

The LLM builds a thesis. Memory retrieves similar past trades. If those trades ended badly under similar conditions, the cycle **refuses** to proceed.

This is not LLM + RAG. This is **Memory with a Stop Button**.

The difference is structural, not incremental. In standard RAG, memory is context. In memory-veto, memory is authority.

---

## Architecture Diagram

```
┌─────────────┐     ┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│   Signal    │────▶│   Memory     │────▶│    Veto      │────▶│      LLM     │
│ (market_data)│     │(W2 similarity)│     │(Refuse check)│     │(Decision)    │
└─────────────┘     └──────────────┘     └──────────────┘     └──────────────┘
                            │                    │
                            └──────────────────────┘
                           (Similar past trades)
```

Note the control flow: the veto branch returns to STAY_SILENT before the LLM is invoked. Memory short-circuits the decision. This is the primitive cognitive loop.

The LLM only sees the prompt if memory does not veto. The veto is binary: proceed or refuse. There is no "maybe" state.

---

## Pseudocode: The Veto Branch

```
# Two-key check
if NOT (goal_signal AND momentum_signal):
    return STAY_SILENT

# Memory retrieval
similar_trades = vector_search(
    query=current_market_context,
    k=5,
    filter=source_channel='trade_outcome'
)

# Veto check
veto_points = 0
for trade in similar_trades:
    if trade.pnl < 0 AND regime_similarity > 0.85:
        veto_points += 1

if veto_points >= 3:
    log("TWO-KEY VETO BY MEMORY")
    return STAY_SILENT

# LLM decides
proceed_with_thesis(current_signal)
```

The veto threshold (3/5 similar bad trades) is configurable. The key logic: **memory can refuse**.

Each similar trade carries a lesson: what the regime looked like, what the agent thought, what actually happened. If enough lessons say "bad outcome," the system refuses to repeat the pattern.

---

## Why This is Cognition

Standard RAG systems treat memory as context. Cognitive Trader treats memory as **refusal authority**. This matters because:

1. The system learns from negative outcomes, not positive ones
2. Refusal is the primitive operation, not suggestion
3. The LLM's "curiosity" is checked by accumulated scar tissue

This mimics biological learning: pain teaches refusal faster than reward teaches action. A child touches a hot stove once, then refuses. The system trades a losing pattern once, then vetoes it.

The memory accumulates trade_outcome facts. Each fact is extracted manually on close (Wire 1) or retrieved via vector similarity (Wire 2). These facts form a refusal lexicon.

---

## Falsifiability Statement

The cognitive thesis is falsifiable:

> **If shuffled-bars performance matches chronological performance within ±$50 and 60% trade count, there is no time-ordered cognition.**

Shuffling destroys temporal structure while preserving price levels. If memory-veto provides no edge, shuffled performance should be equivalent.

If chronological significantly outperforms shuffled, memory is acting on time-ordered patterns — not just price similarity.

This is the experiment that distinguishes real learning from sophisticated curve fitting. See White Paper #4 for full experimental design.

---

## Implementation Reference

The TWO-KEY VETO BY MEMORY mechanism is implemented in `cognitive_cycle.go` lines ~1446-1497.

Every refusal is logged visibly:

```
2024-12-03 14:23:12 TWO-KEY CHECK: goal=0.70, momentum=0.65 → NO COINCIDENCE
2024-12-03 15:47:33 TWO-KEY SUGGESTION ADDED TO SIGNALS
2024-12-03 15:47:34 TWO-KEY VETO BY MEMORY: 3/5 similar trades lost
```

The log format is intentionally transparent. You can count vetoes per cycle, measure veto density over time, correlate vetoes with avoided losses.

---

## The Differentiator

Most "AI traders" optimize the LLM prompt. We optimize for **non-execution**.

A five-year-old child learns by touching the hot stove once, then refusing. An LLM+RAG system touches the stove every time the prompt changes slightly.

Memory-veto creates the primitive cognitive loop: try → fail → remember → refuse.

This is why the system becomes more selective over time. The memory grows. The veto threshold tightens. The stove simply isn't touched twice.

The edge is not in executing more trades — it's in refusing the right ones.

---

## Observable Metrics

Because the veto mechanism is structural, its effectiveness is measurable:

- **Veto density growth** — From 12% early phase to 126% late phase (10.7× growth)
- **Trade avoidance rate** — % of potential signals never reaching execution
- **Correlation between vetoes and outcomes** — Bad setups are being refused

The white paper claims are backed by observable data. You can read the logs and confirm the numbers.

---

## What This Enables

The memory-veto primitive opens design space for:

1. **Risk control without position sizing** — Bad setups are refused before entry
2. **Learning curves** — Selectivity improves with experience
3. **Falsifiability** — The mechanism can be tested via shuffled-bars
4. **Trust without secrecy** — Users can verify the refusal logic

This is the cognitive architecture worth publishing. Not because it's perfect — it's actively being validated. But because it's different, measurable, and falsifiable.