# SURPRISE REGISTER WRITE CONTRACT (Public RAM -- shared by all writers)

**Scope:** Defines the write surface of the Surprise Register for every component that writes (S3, S7, S8, plus S5 self-writes during instantiation). Ownership stays with Claim-Typing Engine (S5); writers append via token.

## 1. Ownership invariants

- **Owner:** Claim-Typing Engine (S5). Instantiates the register at run start, binds `register_id` to `run_id`, publishes write handle.
- **Writers:** S3 Multi-Method Orchestrator, S7 Fitness Adjudicator, S8 Adversarial Pass Engine, plus S5 itself.
- **Renderer:** Epistemic Output Layer (S4). Renders existing entries. Cannot write new entries. Cannot mutate existing entries.
- **Ownership-controlled fields:** `owner_metadata`, `register_id`, `run_id`, `manifest`. Writers NEVER mutate these.

## 2. Allowed entry kinds (CLOSED)

Writers may emit ONLY these `entry_kind` values:

- `anomaly` -- unexpected finding that does not contradict a prior finding but is off-model
- `contradiction` -- two findings incompatible on the same claim (S3 on discipline-vs-discipline; S7 on source-vs-source; S8 on RAM-vs-adversarial)
- `meta-anomaly` -- anomaly about the inquiry process itself (not about a claim's world-model)
- `charter-amendment-request` -- structural request for S5 to reopen scope

**Prohibited entry kinds:** `tiebreaker-vote`, `confidence-delta`, `winner-declaration`, or any kind implying adjudication. The register EXPANDS inquiry; it does not adjudicate. Any write attempting these kinds is refused.

## 3. Required fields per write

```json
{
  "entry_id": "uuid (writer-generated)",
  "run_id": "string (from token)",
  "register_id": "string (from token)",
  "claim_id": "string | null",
  "entry_kind": "anomaly | contradiction | meta-anomaly | charter-amendment-request",
  "writer_component": "S3 | S5 | S7 | S8",
  "write_timestamp_utc": "ISO-8601",
  "source_refs": ["<search-ledger-source-id>", ...],
  "description": "string (<= 1000 chars, non-boilerplate)",
  "provenance": {
    "query_ids": ["<ledger-query-id>", ...],
    "rationale": "string"
  },
  "expansion_directive": "sub-inquiry | expand-corpus | defer-to-operator | informational",
  "downstream_effect": {
    "triggers_sub_inquiry_id": "string | null",
    "charter_amendment_ref": "string | null"
  }
}
```

Missing required field => write refused. `rendered_in_output` is NOT writable; S4 sets it.

## 4. Write protocol

1. Writer acquires write token from S5-published handle.
2. Writer constructs entry with all required fields.
3. Writer atomically appends one JSONL line to `state/ram/surprise-register/<run-id>/register.jsonl`.
4. Writer logs a corresponding RAM Search Ledger entry referencing the new `entry_id` for auditability.
5. Write without token is classified refusal (RAM state manager enforces).

## 5. CLAIM_TYPE_REVISION handling (load-bearing -- S3 specific)

When S3 detects a discipline finding that re-types the underlying claim, S3 MUST:

1. Halt orchestration for that claim.
2. Write a `charter-amendment-request` entry with `expansion_directive: sub-inquiry`, `description` naming the revision (e.g., "descriptive claim C-017 surfaced causal evidence via realist review").
3. Return the claim to S5 for re-decomposition.
4. NEVER silently re-type and continue. Silent re-routing masks S5 with S3 and is a structural defect.

## 6. Forbidden writer behaviors

- Mutate an existing entry (register is append-only)
- Set `rendered_in_output` (S4 owns)
- Write to `owner_metadata`, `register_id`, `run_id`, or `manifest`
- Emit `tiebreaker-vote` or `winner-declaration` entry kinds
- Batch writes to end of run (every anomaly / contradiction written at the moment it is surfaced)
- Write without acquiring the write token
- Write after S4 has rendered (register is closed)

## 7. Post-close behavior

Once S4 renders the register and emits the output artifact, the register closes. Subsequent write attempts are refused. A legitimate late finding triggers a reopen via S6 / E7, not a direct register write.

## 8. Degraded mode

Register file unreachable at write time: writer halts and escalates to orchestrator. Silent drop of an anomaly is forbidden. Orchestrator either routes to an incident channel or halts the run.
