# Candidate Validation and Stale-Reference Gate

Candidate-Commit: `BLOCKED_NO_FINAL_SOURCE_COMMIT`

Run the Python structural tests and the manifest validator before an external
review. Run the document gate against every new partner-facing V3 document:

```bash
python3 scripts/check_v3_document_refs.py \
  --manifest base_sepolia_v3_candidate_manifest.json \
  --package-root .
python3 scripts/validate_v3_candidate_manifest.py \
  --manifest base_sepolia_v3_candidate_manifest.json
```

The manifest validator deliberately reports `ready: false` while the source
candidate is dirty or has no final reachable commit, canonical source archive,
and exact 0.8.24 artifact evidence. The document gate rejects obsolete
score/selectors and a wrong candidate marker. Neither gate certifies
deployment, roles, privacy compliance, independent review, or code hashes.

After the Base source candidate is committed in a clean dedicated worktree,
create the deterministic archive before a `READY_FOR_REHEARSAL` claim:

```bash
python3 scripts/create_canonical_v3_source_archive.py \
  --repo-root ../.. --source-commit <40-hex-commit> \
  --out /safe/path/v3-contracts.tar
```

Pass that exact archive and clean repository root back to the manifest
validator. The command prints the only source-tree and archive digests that
may be inserted into a future ready manifest.


## Canonical evidence and authenticated READY boundary

All evidence inputs are UTF-8 JSON. Duplicate object members are rejected at
every nesting level before any semantic check or digest. Canonical evidence
statements use compact JSON (no insignificant whitespace), lexicographically
sorted ASCII-identifier object keys, UTF-8 bytes, and no surrogate/non-BMP key
normalization ambiguity. Numeric fields are integers only where their schemas
require block heights or chain IDs; hashes, bytecode, addresses, and ABI values
are strings and must never be coerced through floating-point values.

A future READY bundle must contain the full transitive Solidity source closure,
the exact pinned `solc-0.8.24` SHA-256, source archive, standard-json input and
output, Foundry build information, exact dependency gitlink, and a canonical
external deployment-verification statement. That statement must be signed by a
production-pinned independent verifier and bind Base Sepolia 84532, creation
transaction input/to, receipt/address/block, `eth_getCode` bytes at a fixed
block, ABI constructor bytes, runtime evidence, and every manifest/bundle/source
digest. No production verifier key is pinned in this candidate, so READY is
deliberately impossible. The SDK makes the same refusal before provider access;
it does not treat a self-computed hash as a Python-validator attestation.

All local raw JSON boundaries (manifest/evidence, public rehearsal intake and
record, and document-marker manifest) use the same duplicate-rejecting UTF-8
loader. Duplicate members at any nested object level are rejected before a
semantic check. Canonical signed evidence additionally requires compact sorted
byte serialization; unsigned public records need not claim canonical bytes.

READY recompilation is Linux fail-closed: the validator opens the fixed compiler
path without following links, checks its owner/mode/inode and SHA-256 through an
open descriptor, copies it into a sealed `memfd`, and runs both version and
standard-json checks through that sealed descriptor. A missing memfd/seal,
path replacement, symlink, wrapper, or digest mismatch rejects READY.

Runtime verification consumes the exact fresh compiler immutable-reference map.
A no-immutable runtime must equal its compiler template byte-for-byte. An
immutable-bearing runtime may differ only at complete, non-overlapping,
32-byte compiler-declared immutable ranges and must carry the exact canonical
map in the independently signed statement. Production READY remains disabled:
no production verification/attestation key is pinned.

For immutable-bearing required targets, the current validator deliberately
rejects READY until a later audited implementation can deterministically
reconstruct every immutable value from reviewed constructor, AST, and build-info
bindings. An external signature is never enough to override that local proof
requirement. This restriction is intentional and does not authorize a future
key-enable patch without another audit.
