# mode-driven-response-schema

> Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a…

Page: Ontology · Algorithms
Canonical: https://banes-lab.com/ontology/algorithms#algo-domain-mode-driven-response-schema

Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a grammar, what it composes and is composed by, which forces and principles it answers to, what grounds it and what it grounds, and an exemplar where the record carries one. The diagram shows what composes what inside the domain.

Relations diagram

What composes what inside this domain.

```mermaid
flowchart LR
n_composed_turn_contract["Composed Turn Contract"]
n_loop_owned_mode_selection["Loop-Owned Mode Selection"]
n_versioned_turn_provenance["Versioned Turn Provenance"]
n_mode_contract_validation["Mode Contract Validation"]
n_mode_driven_response_schema["<Mode-Driven Response Schema>"]
n_loop_owned_mode_selection --> n_composed_turn_contract
n_loop_owned_mode_selection --> n_mode_contract_validation
n_loop_owned_mode_selection --> n_versioned_turn_provenance
n_mode_driven_response_schema --> n_composed_turn_contract
n_mode_driven_response_schema --> n_loop_owned_mode_selection
n_mode_driven_response_schema --> n_versioned_turn_provenance
```

### Composed Turn Contract

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Compose a model turn's validation schema and its instruction from one self-registering field registry, projected per mode, so the schema the response is graded against and the instruction the model is given can never drift.

Invariant
The per-mode validation schema and the per-mode instruction are projections of a single field registry; there is no second hand-authored contract surface, and adding or changing a field changes both at once.

Flow

```text
RegisterField → SelectByMode → ProjectSchema → ProjectInstruction → StampVersion
```

Productions

```bnf
ComposedTurnContract ::= <FieldRegistry> "->" <ModeProjection> "->" <SchemaAndInstruction>
ModeKey ::= "(" "phase" "," "activity" ")"
SchemaVersion ::= "content_hash" "(" <FieldSet> ")"
Determinism ::= "same_mode" "->" "byte_identical" "(" <Schema> "," <Instruction> ")"
```

Composes
[Interface Contract](https://banes-lab.com/records/algo/interface-contract.md), [Canonical Data](https://banes-lab.com/records/algo/canonical-data.md), [Canonical Semantics](https://banes-lab.com/records/algo/canonical-semantics.md), [Extension Point](https://banes-lab.com/records/algo/extension-point.md)

Composed by
[<Mode-Driven Response Schema>](https://banes-lab.com/records/algo/mode-driven-response-schema.md)

Named in the derivation of
[Loop-Owned Mode Selection](https://banes-lab.com/records/algo/loop-owned-mode-selection.md)

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)

Grounds
none

Before

```text
The validation schema and the model's instruction hand-maintained twice, so they drift.
```

After

```text
field registry → project per (phase, activity) mode → schema + instruction from one source → same mode = byte-identical, changing a field changes both
```

### Loop-Owned Mode Selection

- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
The loop assigns the (phase, activity) mode that selects which contract a response is validated against; the model's output carries no contract-selecting field, so a model can never grade itself against a contract it chose.

Invariant
The mode that selects the response contract is loop-assigned; the model has no field that selects the contract it is graded against.

Flow

```text
LoopAssignMode → ComposeContract → ValidateAgainstContract
```

Productions

```bnf
LoopOwnedModeSelection ::= <LoopAssignedMode> "->" <ComposeContract> "->" <ValidateResponse>
ModeAuthority ::= "loop_owned" "not_model_selected"
```

Composes
[Contract Compatibility](https://banes-lab.com/records/algo/contract-compatibility.md)

Composed by
[<Mode-Driven Response Schema>](https://banes-lab.com/records/algo/mode-driven-response-schema.md)

Forces
[security_governance](https://banes-lab.com/records/force/security-governance.md), [state_transaction](https://banes-lab.com/records/force/state-transaction.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
[derivation-loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)

Derivation map

act
[Composed Turn Contract](https://banes-lab.com/records/algo/composed-turn-contract.md)

verify
[Mode Contract Validation](https://banes-lab.com/records/algo/mode-contract-validation.md)

commit
[Versioned Turn Provenance](https://banes-lab.com/records/algo/versioned-turn-provenance.md)

Before

```text
The model's output carries the field that selects which contract it's graded against.
```

After

```text
loop assigns (phase, activity) mode → compose contract → validate; the model can never grade itself against a contract it chose
```

### Versioned Turn Provenance

- Stage: [commit](https://banes-lab.com/records/stage/commit.md)
- Axis: [representation](https://banes-lab.com/records/reason/axis-representation.md)
- Math type: [information-theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- Yields: hash | novelty-score

Details

Intent
Persist each accepted model turn as an append-only, mode-tagged, schema-versioned, causally ordered record with change-only provenance, so the turn history is a queryable, auditable log and a turn is never graded against a schema version its stored state never saw.

Invariant
Turn records are append-only and single-writer causally ordered; a version is stamped by content and never mutated in place; a no-op change appends nothing.

Flow

```text
StampVersion → AssignCausalOrder → AppendOnly → BumpOnChange → Query
```

Productions

```bnf
VersionedTurnProvenance ::= <SchemaVersion> "->" <CausalOrder> "->" <AppendOnlyRecord>
CausalOrder ::= "single_writer_counter" "not" "disk_read_max"
Provenance ::= "bump_on_real_change" "no_op_appends_nothing"
```

Composes
[Version Provenance](https://banes-lab.com/records/algo/version-provenance.md)

Composed by
[<Mode-Driven Response Schema>](https://banes-lab.com/records/algo/mode-driven-response-schema.md)

Named in the derivation of
[Loop-Owned Mode Selection](https://banes-lab.com/records/algo/loop-owned-mode-selection.md)

Forces
[observability_traceability](https://banes-lab.com/records/force/observability-traceability.md), [state_transaction](https://banes-lab.com/records/force/state-transaction.md), [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)

Grounds
none

Before

```text
A turn graded against a schema version its stored state never saw.
```

After

```text
accepted turn → stamp version by content → single-writer causal order → append-only, mode-tagged record; a no-op appends nothing
```

### Mode Contract Validation

- Stage: [verify](https://banes-lab.com/records/stage/verify.md)
- Axis: [verification](https://banes-lab.com/records/reason/axis-verification.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Validate the model's response against the loop-selected mode contract and, on a validation miss, drive an error-specific self-healing retry bounded by the contract, so a response is accepted only when it satisfies the schema it is graded against.

Invariant
A response is accepted only against the mode contract the loop selected; a validation miss self-heals with error-specific remediation, never against a relaxed contract.

Flow

```text
Response → ValidateAgainstContract → Valid|SelfHealRetry → Accepted|Rejected
```

Productions

```bnf
ModeContractValidation ::= <Response> "," <ModeContract> "->" <Validation> "->" (<Accepted> | <SelfHealRetry> "->" <ModeContractValidation>)
SelfHealRetry ::= "error_specific_remediation" "(" <ValidationIssues> ")" "bounded"
```

Composes
none

Named in the derivation of
[Loop-Owned Mode Selection](https://banes-lab.com/records/algo/loop-owned-mode-selection.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)

Grounds
[ver-evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)

Before

```text
A response accepted because it looked right, not because it satisfied the mode's schema.
```

After

```text
response + mode contract → validate → {valid | error-specific self-heal retry, bounded} → accepted | rejected
```

### <Mode-Driven Response Schema>

- Meta record

Details

Intent
Make the model's structured output a mode-driven composed contract — the output mirror of composed input context: per loop-owned mode the schema and instruction are projected from one field registry, the response is validated and self-heals against it, the typed fields are governed, and every turn is persisted as a versioned queryable record — so the output has one source, cannot drift from its instruction, and can be audited.

Invariant
The response contract is composed per loop-owned mode from a single field registry; instruction and validation are the same source; a validation miss self-heals with error-specific remediation; output governance is advisory and never blocks the hard verify gate; and every accepted turn is a versioned, append-only record.

Flow

```text
ComposeContract → ValidateByMode → SelfRemediate → GovernFields → PersistVersioned
```

Productions

```bnf
ModeDrivenResponseSchema ::= <ComposedTurnContract> "->" <LoopOwnedModeSelection> "->" <SelfRemediation> "->" <GroundingAdvisory> "->" <VersionedTurnProvenance>
SingleSource ::= "instruction" "=" "validation" "=" "projection" "(" <FieldRegistry> ")"
SelfRemediation ::= "error_specific_retry" "(" <ValidationIssues> "," <ModeContract> ")"
GroundingAdvisory ::= "typed_field" "->" "validator" "(" "advisory_not_blocking" ")"
```

Composes
[Composed Turn Contract](https://banes-lab.com/records/algo/composed-turn-contract.md), [Loop-Owned Mode Selection](https://banes-lab.com/records/algo/loop-owned-mode-selection.md), [Versioned Turn Provenance](https://banes-lab.com/records/algo/versioned-turn-provenance.md), [Interface Contract](https://banes-lab.com/records/algo/interface-contract.md), [Canonical Data](https://banes-lab.com/records/algo/canonical-data.md), [Contract Compatibility](https://banes-lab.com/records/algo/contract-compatibility.md), [Self-Description Manifest](https://banes-lab.com/records/algo/self-description-manifest.md), [Runtime Discovery](https://banes-lab.com/records/algo/runtime-discovery.md), [Extension Point](https://banes-lab.com/records/algo/extension-point.md)

Forces
[contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md), [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [security_governance](https://banes-lab.com/records/force/security-governance.md)

Grounds
none

## Links to

- [Act](https://banes-lab.com/records/stage/act.md)
- [Formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- [Computation](https://banes-lab.com/records/reason/math-type-computation.md)
- [Interface Contract](https://banes-lab.com/records/algo/interface-contract.md)
- [Canonical Data](https://banes-lab.com/records/algo/canonical-data.md)
- [Canonical Semantics](https://banes-lab.com/records/algo/canonical-semantics.md)
- [Extension Point](https://banes-lab.com/records/algo/extension-point.md)
- [<Mode-Driven Response Schema>](https://banes-lab.com/records/algo/mode-driven-response-schema.md)
- [Loop-Owned Mode Selection](https://banes-lab.com/records/algo/loop-owned-mode-selection.md)
- [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)
- [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)
- [runtime_extensibility](https://banes-lab.com/records/force/runtime-extensibility.md)
- [Contract Compatibility](https://banes-lab.com/records/algo/contract-compatibility.md)
- [security_governance](https://banes-lab.com/records/force/security-governance.md)
- [state_transaction](https://banes-lab.com/records/force/state-transaction.md)
- [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)
- [The derivation loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)
- [Composed Turn Contract](https://banes-lab.com/records/algo/composed-turn-contract.md)
- [Mode Contract Validation](https://banes-lab.com/records/algo/mode-contract-validation.md)
- [Versioned Turn Provenance](https://banes-lab.com/records/algo/versioned-turn-provenance.md)
- [Commit](https://banes-lab.com/records/stage/commit.md)
- [Representation](https://banes-lab.com/records/reason/axis-representation.md)
- [Information Theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- [Version Provenance](https://banes-lab.com/records/algo/version-provenance.md)
- [observability_traceability](https://banes-lab.com/records/force/observability-traceability.md)
- [causality_ordering](https://banes-lab.com/records/force/causality-ordering.md)
- [Verify](https://banes-lab.com/records/stage/verify.md)
- [Verification](https://banes-lab.com/records/reason/axis-verification.md)
- [Logic](https://banes-lab.com/records/reason/math-type-logic.md)
- [Ver Evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)
- [Self-Description Manifest](https://banes-lab.com/records/algo/self-description-manifest.md)
- [Runtime Discovery](https://banes-lab.com/records/algo/runtime-discovery.md)
