# flenn-chess G1 — architecture design (DRAFT for Tom's sign-off)

Executes the G0 approval. Freezes PLAN.md's architecture into concrete, buildable choices. Your
calls are flagged **⟨TOM⟩**.

## 1. Base predicates (level-1 concept nodes)
Per-position features, each a fuzzy value in [0,1] (booleans = {0,1}):
- piece-on-square (per type × square), side-to-move
- attacks(sq), defends(sq), attacker-count, defender-count per square
- pinned / skewered / hanging (per piece)
- passed / doubled / isolated pawns; pawn-structure flags
- king-exposure (attackers near king, open files to king), king-safety
- mobility (legal moves per piece / side), center-control, space
- material balance, bishop-pair
Continuous features squashed to [0,1]; booleans stay {0,1}.
- **⟨TOM⟩** keep level-1 purely positional, or seed a few SLA features now? (recommend positional only.)

## 2. Concept-node layer (the discovered library)
A growing set of nodes. Each node = a function of earlier nodes via fuzzy-logic ops (AND=min/product,
OR=max/prob-sum, NOT=1−x, IMPLIES, XOR) + arithmetic (weighted sum, product, difference). Level-1 =
base predicates; level ≥2 = combinations discovered in DREAM. Library capped for compactness.
- **⟨TOM⟩** library cap K_total (proposed ~64–256).

## 3. WAKE phase
Train a small value head over the current library's activations → predict Stockfish eval (centipawn,
tanh-scaled) and/or move policy, on sampled positions. Standard SGD. Log per-node marginal contribution.

## 4. DREAM phase (the core novelty, offline)
- **Candidate generation:** propose pairwise + ≤3-tuple combinations of current nodes via the op set;
  bound the Zipfian explosion with cheap priors (high-leverage nodes, diverse pairings).
  **⟨TOM⟩** candidates scored per night (proposed ~10k).
- **Leverage = what to keep:** a candidate's worth = marginal reduction in wake eval-loss when added,
  minus a redundancy penalty = conditional mutual information with the target given the current library
  (estimated by a frozen-library loss-delta probe). Keep top-k; discard the low-leverage tail.
  **⟨TOM⟩** keep-k per night (proposed 1–4 — the "few per night" dynamic).
- Log each kept node as a readable expression + its leverage, so the library is inspectable.

## 5. DECIDE phase (planning over abstractions)
For a position: compute activations; enumerate a SMALL candidate move/plan set; project each result
into abstract space and score with the learned value → best action / best future. Compare vs. raw
minimax/MCTS at MATCHED node budget.
- **⟨TOM⟩** abstract look-ahead depth (proposed 1-ply + value; deepen only if it beats search).

## 6. Baselines (matched compute)
(a) plain MLP on the raw board tensor; (b) small CNN; (c) HAND-WIRED motif nodes (fork = AND(attacks…),
pin, passed-pawn) — the ablation the DISCOVERED library must match or beat. Equal param/FLOP budget.

## 7. Metrics + kill criteria
Inherited from PLAN §Success-metrics: sample-efficiency, abstraction-leverage, planning (Elo / top-1
vs Stockfish), interpretability. A clean negative on any metric is a valid, cheap result.

## 8. SLA (Tom's Newton-Raphson update)
- **⟨TOM⟩** PLAN recommends SLA as a LATER ablation, not a G1 variable (one novelty at a time). Confirm.

## Build shape (opens at G3)
Me: architecture + leverage criterion + verdicts. Sonnet agents (≤4, -responsibly-primed): data
pipeline (Lichess→Stockfish), baselines, the wake/dream + decide harness. Oracle = Stockfish, no data risk.

## Sign-off
Approve to FREEZE this design → opens **G2** (dataset: Lichess games → Stockfish labels, game-disjoint
splits). Amend any **⟨TOM⟩** item first.
