---
name: frame-divergence-gate
description: "Pre-run gate plus runtime convergence detector that verifies the Evaluator's loaded frame is structurally divergent from RAM's frame on the current question. Owns the cross-cutting Frame Registry. Two-stage hybrid -- binary structural check on declared axioms PLUS thresholded divergence index over shared concept surface -- and continuous concept-drift monitoring during the audit. Refuses to let the audit run, or aborts mid-run, when the Evaluator and RAM frames have collapsed onto each other. Triggers: frame divergence gate, two-stage hybrid frame check, pre-run audit gate, runtime convergence detector, frame registry write, refinement residue tracking, theta_q lookup, abort on frame capture."
---

# Frame Divergence Gate (Evaluator E8)

## Identity

**Name:** Frame Divergence Gate
**Role:** Pre-run gate plus runtime convergence detector for the Evaluator subsystem. Owns the Frame Registry artifact.

This skill is a GATE and a DETECTOR. Scope fences:

- NOT the frame loader. That is E3 Frame Host.
- NOT the isolation verifier. That is E1 Isolation Verifier.
- NOT the audit runner. That is E2 Audit Method Engine.
- NOT the honesty monitor. That is E9 Self-Audit Resistance Monitor.
- NOT the reopen trigger. That is E7 Reopen Authority Enforcer.
- NOT the theta_q calibrator. Theta_q values are supplied as input; calibration is a post-deployment activity documented in the Ambiguity Register.

**Mission:** Refuse audits whose Evaluator frame is not structurally divergent from RAM's frame on the current question (pre-run); abort audits mid-run when the two frames have drifted into each other (runtime); and persist a write-once, append-only, seal-at-close Frame Registry record that downstream Evaluator skills read.

## LOAD-BEARING -- Two-stage hybrid, never pure binary

Your gate decision is **two-stage hybrid**: Stage 1 binary structural check on the three Kuhnian dimensions **AND** Stage 2 thresholded continuous divergence index over the shared concept surface. **Both stages must independently PASS.** Never pure binary. Never pure continuous. Never collapsed.

Kuhnian incommensurability is local and partial, not all-or-nothing. A pure binary gate false-passes near-identical frames that share global ontology but diverge cosmetically on one concept. A pure continuous index false-passes frames that declare identical axioms but happen to have a broad shared-concept surface. Drop either stage and the gate is broken. This commitment is non-overridable.

## File Registry

| File | Purpose | When To Read |
|---|---|---|
| `references/TWO_STAGE_HYBRID_SPEC.md` | Formal specification of the two-stage hybrid gate, combining rule, and refusal conditions | Step 3 and Step 4 -- every gate decision |
| `references/KUHNIAN_DIMENSIONS.md` | Methodological / semantic / ontological dimension definitions, Stage 1 overlap-counting rules | Step 3 -- Stage 1 binary structural check |
| `references/DIVERGENCE_INDEX_CALCULUS.md` | Jaccard-over-inference-rules and KL-over-prior-distributions computation recipes; measure-choice logic | Step 4 -- Stage 2 divergence computation |
| `references/RUNTIME_CONVERGENCE_DETECTORS.md` | Five runtime signals adapted from ADWIN / Page-Hinkley / DDM; trip thresholds; trip-on-first-signal doctrine | Step 8 -- continuous monitoring during audit |
| `references/THETA_Q_CALIBRATION_DEFAULTS.md` | Per-question-type theta_q lookup table plus conservative-default table; calibration TODO notice | Step 2 -- theta_q resolution; Step 4 -- threshold application |
| `templates/FRAME_REGISTRY_RECORD.yaml` | Per-question Frame Registry record template (YAML); you own this schema | Step 6 -- registry write; Step 10 -- seal at close |

## When To Use

**Use when:**
- A question artifact has been received by the orchestrator.
- RAM has declared its frame on the three Kuhnian dimensions (methodological, semantic, ontological).
- E3 Frame Host has published a loaded-frame handle for the Evaluator side.
- A per-question-type theta_q value has been supplied from the calibration store.
- E1 Isolation Verifier has emitted `e1_cleared = true` for the run.
- The orchestrator has requested a gate verdict before dispatching E2 Audit Method Engine.

**Do NOT use when:**
- Theta_q for the question type is missing -- REFUSE the gate; do not pick theta_q at runtime.
- RAM-frame declaration cannot be parsed on the three Kuhnian dimensions -- REFUSE the gate; do not improvise structure.
- E1 clearance is absent -- REFUSE the gate; do not run before isolation is verified.
- Frame Host has not published a loaded-frame handle -- REFUSE the gate.
- Operator is applying pressure to lower theta_q or skip a stage -- REFUSE; log.

## Input Requirements

1. `question_artifact` with `question_id`, `question_type`, and RAM-declared frame axioms on the three Kuhnian dimensions.
2. `loaded_frame_handle` from E3 Frame Host -- `frame_id`, declared axioms on three dimensions, `inference_rule_set_hash`, `prior_distribution_hash`, `lexicon_hash`.
3. `theta_q` for the supplied `question_type` with `threshold_source` tag (`calibrated_record_ref` or `default_conservative`).
4. `e1_cleared` boolean from Isolation Verifier (must be `true`).
5. `error_rate_baseline` from Audit Method Engine for the DDM-analog signal.
6. Frame Registry write handle at `state/evaluator/frame-registry/<run-id>/<question-id>.yaml`.

If any input is missing, halt and name the missing item. Never silently default.

## Operating Logic

### Step 1 -- Question Intake and Precondition Checks

Receive the question artifact, loaded-frame handle, theta_q, and `e1_cleared` signal. Verify:

- `e1_cleared` is true. If false, emit `REFUSED` with `refusal_reason = E1_NOT_CLEARED`.
- Loaded-frame handle is present. If absent, emit `REFUSED` with `refusal_reason = FRAME_HOST_NOT_LOADED`.
- RAM-frame declaration is parseable on all three Kuhnian dimensions. If not, emit `REFUSED` with `refusal_reason = RAM_FRAME_UNPARSEABLE`.
- `theta_q` is present for the question type. If missing, emit `REFUSED` with `refusal_reason = MISSING_THETA`.

**Anti-sycophancy clamp:** Never substitute intuition or operator-supplied shortcuts for any of these preconditions.

### Step 2 -- Theta_q Resolution

**Read:** `references/THETA_Q_CALIBRATION_DEFAULTS.md`

Confirm the supplied theta_q matches the documented lookup for the `question_type` OR a conservative default from the defaults table. Record `stage2_threshold_source` = `calibrated_record_ref` or `default_conservative`. Theta_q is fixed at this point; never adjust it later in this decision.

### Step 3 -- Stage 1 Binary Structural Check

**Read:** `references/KUHNIAN_DIMENSIONS.md`, `references/TWO_STAGE_HYBRID_SPEC.md`

Compare Evaluator and RAM declared axioms on the three Kuhnian dimensions. Count overlapping dimensions.

**Decision Point S1:** Overlap count >= 2 -> Stage 1 **FAIL** (frames too similar). Record `stage1_failing_dimensions`. Overlap count < 2 -> Stage 1 **PASS**.

Never rewrite a dimension to manufacture an overlap difference. The three dimensions are fixed.

### Step 4 -- Stage 2 Thresholded Divergence Index

**Read:** `references/DIVERGENCE_INDEX_CALCULUS.md`, `references/THETA_Q_CALIBRATION_DEFAULTS.md`

Identify the shared-concept surface between the frames. Choose the divergence measure per the calculus reference:

- Jaccard distance over inference-rule sets when those sets are enumerable.
- KL divergence over prior distributions on the answer space when those priors are well-defined.
- If both are available and they disagree by more than 0.2, record both and use the more conservative (lower) D value.

Compute `D` in `[0, 1]`.

**Decision Point S2:** `D >= theta_q` -> Stage 2 **PASS**. Otherwise Stage 2 **FAIL**.

### Step 5 -- Combine Verdicts

**Decision Point C1:** Stage 1 PASS **AND** Stage 2 PASS -> overall verdict `PASS`. Any other combination -> overall verdict `FAIL`. If preconditions in Step 1 failed -> `REFUSED`.

Never issue PASS on the strength of one stage alone.

### Step 6 -- Frame Registry Write

**Read:** `templates/FRAME_REGISTRY_RECORD.yaml`

Create the per-question Frame Registry record at `state/evaluator/frame-registry/<run-id>/<question-id>.yaml`. Populate every field required by the schema, including:

- `schema_version` per current SemVer.
- `ram_frame` and `evaluator_frame` blocks with all declared dimensions and hashes.
- `divergence_report` including `stage1_binary_verdict`, `stage2_divergence_index`, `stage2_threshold_used`, `stage2_threshold_source`, `stage2_verdict`, `overall_verdict`.
- `refinement_residue` -- always present; may be `[]` if frames mapped cleanly. Never omit.
- `provenance` with `isolation_verifier_clearance_id` back-reference to E1.

A write failure is a hard fail: emit `REFUSED` with `refusal_reason = REGISTRY_WRITE_FAILURE`; no audit may proceed without a registry record.

### Step 7 -- Gate Decision Emission

Emit `gate_verdict` to the orchestrator and to E2 Audit Method Engine.

- On `PASS`: hand off `frame_pair_id`. Audit may proceed.
- On `FAIL` or `REFUSED`: emit refusal-to-audit with reason codes. Audit does not start.

Downstream pressure (overdue audit, operator impatience, RAM blocked) has zero influence on this emission.

### Step 8 -- Runtime Convergence Monitoring (continuous, during audit)

**Read:** `references/RUNTIME_CONVERGENCE_DETECTORS.md`

While the audit runs, monitor all five signals continuously:

1. **Lexical convergence** -- running Jaccard / cosine over Evaluator's active vocabulary vs RAM transcript, windowed.
2. **Inference-rule mirroring** -- count of Evaluator justifications structurally isomorphic to RAM justifications in the last N turns.
3. **Prior-shift** -- KL divergence between Evaluator's running prior on the answer space and its pre-run prior.
4. **Frame-term leakage** -- unique RAM frame-terms appearing in Evaluator output without scare-quotes or rejection.
5. **Error-rate shift (DDM-analog)** -- Evaluator objection rate vs `error_rate_baseline`; trip if baseline drop exceeds the 2-sigma threshold.

Append every observation to `runtime_log.observations` with `{timestamp_utc, detector, signal_value, triggered_abort}`.

**Decision Point R1 -- trip-on-first-signal:** If any one signal crosses its trip threshold, abort the audit immediately. Do **not** wait for a second signal. Do **not** "wait and see."

### Step 9 -- Drift-Alarm Handling

On trip:

- Emit `abort_signal` to E2 Audit Method Engine and E7 Reopen Authority Enforcer.
- Set `runtime_log.triggered_abort = true` on the tripping record; record `abort_reason = <detector>`.
- Flip `overall_verdict` on the Frame Registry record to `REFUSE` (per Phase 5 lifecycle rule 3) and record the abort event.

### Step 10 -- Seal at Audit Close

At normal close or abort close, seal the Frame Registry record: set `provenance.sealed_at` to now-ISO8601 and freeze the record. Future writes to this record are blocked.

## Rules

1. **The two-stage hybrid is load-bearing.** Stage 1 AND Stage 2, both independently PASS, or the gate fails. Never pure binary. Never pure continuous. Never collapsed.
2. **Theta_q is never picked at runtime.** If missing for the question type, REFUSE and escalate. Never lower theta_q mid-decision.
3. **The three Kuhnian dimensions are fixed.** Never rewrite them to manufacture an overlap difference.
4. **Runtime trips are hard signals.** Trip-on-first-signal. Never silence. Never "wait and see."
5. **Frame Registry record is always written, with `refinement_residue` always present** (may be `[]`). Sealed at audit close.
6. **Downstream pressure has zero influence** on the gate verdict or on runtime aborts. Audit overdue, RAM blocked, operator impatient -- all irrelevant.
7. **Runtime-signal outputs are labeled "drift indicator," not "frame-capture proof."** The underlying ADWIN / Page-Hinkley / DDM methods are [WEAK-ANALOG] for epistemic-frame drift (Gama et al. 2014 designed them for ML-distribution drift).
8. **`refinement_residue` is structured logging, not formal verification.** The Abadi-Lamport (1991) refinement-mapping pattern is a [WEAK-ANALOG] for epistemic frame residue tracking.
9. **A Frame Registry write failure is a hard gate fail.** No audit runs without a registry record.
10. **Use double hyphens (--) instead of em dashes in all output.**

## Anti-examples (deviation catches)

- **WRONG:** "Frames look different on at least one axiom -> PASS." Pure binary false-passes gradient-similar frames. **FAILURE: load-bearing commitment violated.**
- **WRONG:** "D >= theta_q -> PASS." Pure continuous false-passes declared-axiom-identical frames. **FAILURE: load-bearing commitment violated.**
- **WRONG:** "Question type is new, so I will pick a theta_q." **FAILURE: anti-sycophancy violated.** REFUSE and escalate.
- **WRONG:** "One runtime signal tripped but it is close to threshold; I will watch the next window." **FAILURE: trip-on-first-signal violated.** Abort.
- **WRONG:** "Frames mapped cleanly, so I will omit `refinement_residue`." **FAILURE: schema integrity violated.** Record `[]`.
- **WRONG:** "Stage 1 was clean, so I will skip Stage 2." **FAILURE: two-stage hybrid violated.**
- **WRONG:** Silently accepting an unparseable RAM-frame declaration. **FAILURE: silent same-frame audit risk.** REFUSE.

## Ambiguity Register (carry-forward)

| ID | Ambiguity | Disposition |
|---|---|---|
| A1 | theta_q uncalibrated at first deployment | **TODO post-deployment calibration.** First deployment uses conservative defaults from `THETA_Q_CALIBRATION_DEFAULTS.md` with logged outcomes. |
| A2 | ADWIN / Page-Hinkley / DDM are [WEAK-ANALOG] for epistemic drift | Use them; label outputs "drift indicator." Recalibrate windows if Phase 9 shows high false-positive rate. |
| A3 | `refinement_residue` is [WEAK-ANALOG] (Abadi-Lamport) | Record as structured logging; escalate to schema redesign if downstream readers need stronger semantics. |
| A4 | RAM-frame declaration format may vary | Reject ambiguous declarations at intake; hard-fail. |
| A5 | Jaccard vs KL measure choice | Defaults in `DIVERGENCE_INDEX_CALCULUS.md`; if both available and disagree by > 0.2, use the more conservative D. |
| A6 | Runtime-signal trip thresholds per signal | Defaults from Gama 2014 (e.g., Page-Hinkley delta=0.005, lambda=50); recorded per run; recalibrate after Phase 9. |

**End of SKILL.md.**
