# SRC-X.5 v1.6: anchored heads and seal anchors

v1.6 adds two things to v1.5.1. Records, ids and the log format are unchanged. A record without the new field is checked exactly as before.

## 1. Every head is stamped

The log head (the hash of the last entry) is stamped on Bitcoin through OpenTimestamps after each admission. A failed stamp never blocks an admission: the record is in the log either way, and the head is stamped later.

- **Node:** with `SRCX5_ANCHOR_DIR` set, `serve` stamps the new head in the background after each admitted `/submit`.
- **Command line:** `srcx5 admit record.json --log log --anchors anchors`.
- **Watcher:** `srcx5_anchor.py watch --log log --dir anchors [--every 600]` stamps any head that is not yet stamped and upgrades pending proofs.

Each stamp is three files in the anchors directory: `<head>`, `<head>.ots` and `<head>.json`. A stamp reads as confirmed only when its proof holds a Bitcoin block-header attestation.

## 2. Seal anchors (`seal.anchor`, optional)

```json
"seal": {
  "seal_file": "SEAL.md",
  "files": [{"path": "SEAL.md", "sha256": "…"}, …],
  "sealed_at": "…",
  "anchor": {"network": "bitcoin", "method": "opentimestamps",
             "proof": "<base64 of SEAL.md.ots>", "block_heights": [978698, 978704, 978715]}
}
```

**Admission checks (offline, standard library only).** A failure quarantines the record.

1. The proof parses.
2. `seal.seal_file` is among the fingerprinted files.
3. The proof covers that file's sha256.
4. `block_heights` equals the proof's Bitcoin attestations.

**Online check:** `srcx5_anchor.py verify-record record.json`. Anyone can run it, without trusting a node.

1. For each attested height, it reads the block from a public explorer (default mempool.space) and compares merkle roots.
2. It requires the earliest attested block to be older than `run.started_at`.

Together these show that the prediction existed on Bitcoin before the run began.

**Writing the field:** `srcx5_anchor.py seal record.json SEAL.md.ots` adds the anchor and re-finalizes the record. Its id changes, because the anchor is part of the record.

## Tests

`tests/v16/test_anchor_v16.py` (13 checks; `--online` adds the two explorer checks). The fixture is a real seal with a proof confirmed in blocks 978698, 978704 and 978715. Under v1.6, the v1.4 and v1.5 suites give the same results as under v1.5.1.
