# MazeXChain Data Flow

## 1. Current Challenge Flow

```text
Node loads chain head
  -> derives current Layer / Step
  -> computes public challenge commitments
  -> exposes current state through /api/base1/current
  -> UI renders grid, commitments, score, wallet state, and submission form
```

## 2. Sampling Flow

```text
User clicks A(x,y)
  -> UI sends POST /api/base1/sample
  -> server evaluates current challenge behavior
  -> server returns B(u,v)
  -> UI highlights input cell and output cell
```

Sampling is behavior observation only. It does not charge a fee and does not advance chain state.

## 3. Solve Submission Flow

```text
Solver builds candidate explanation
  -> wallet signs submission payload
  -> client runs or requests latest-head preflight
  -> server rejects expired Step or stale chain head
  -> answer budget checks payload size and expression shape
  -> verifier checks behavior equivalence
  -> valid solve creates a Solve Block
  -> reward is minted to solver
  -> submit fee is deducted from reward and burned
  -> next Step commitment is derived from chain state
```

Invalid answers stop before broadcast and before state transition.

## 4. Fragment Registry Flow

```text
Fragment proposal
  -> format and version checks
  -> size and budget checks
  -> executable and composable checks
  -> registry action recorded
  -> registry root updates
  -> future challenge selection can reference active registry state
```

Fragment data is governed by protocol rules. Fragment propagation does not imply that a fragment is selected into a challenge.

## 5. Wallet Signing Flow

```text
Site requests account or signature
  -> extension checks connected origin
  -> wallet must be unlocked locally
  -> signing request opens approval window
  -> user approves or rejects
  -> extension returns signature only after approval
```

The server verifies signatures and addresses. It does not hold production wallet private keys or mnemonic phrases.

## 6. Chain Sync Flow

```text
Node queries peer heads
  -> compares height, state root, and block hash
  -> fetches missing blocks or snapshots
  -> verifies parent hash and state transition
  -> updates local chain head only after validation
```

Network messages speed up discovery. Chain validity still comes from replayable protocol rules.
