=== META ===
{
  "id": "GTPX-RUNTIME-MODEL",
  "title": "GTPX Runtime Model",
  "version": "0.1.1",
  "status": "draft",
  "updated": "2026-04-26",
  "authority": "09_runtime/GTPX-RUNTIME-MODEL.gtpx",
  "type": "runtime_model",
  "project": "GTPX",
  "depends_on": [
    "04_contract/GTPX-CONTRACT-CORE.gtpx",
    "06_protocol/GTPX-REQUEST-MODEL.gtpx",
    "06_protocol/GTPX-RESPONSE-MODEL.gtpx",
    "06_protocol/GTPX-ACK-HASH.gtpx",
    "07_validation/GTPX-VALIDATION-MODEL.gtpx",
    "08_agents/GTPX-AGENT-MODEL.gtpx"
  ]
}

=== DATA ===
{
  "purpose": "Defines how GTPX execution is orchestrated from request to response, including response delivery validation before final output.",

  "runtime_definition": "Runtime is the execution layer that enforces contract, validation, agent processing, response generation, response delivery validation, and deterministic finalization.",

  "execution_flow": [
    "receive_request",
    "verify_ack_and_hash",
    "validate_structure",
    "validate_contract",
    "validate_completeness",
    "validate_sources",
    "select_agent",
    "execute_agent",
    "generate_response",
    "validate_response_delivery",
    "attach_ack",
    "finalize_output"
  ],

  "step_definitions": {
    "receive_request": "Runtime receives structured request.",
    "verify_ack_and_hash": "Checks payload integrity and completeness.",
    "validate_structure": "Ensures syntax is correct.",
    "validate_contract": "Ensures contract constraints are respected.",
    "validate_completeness": "Ensures all required data exists.",
    "validate_sources": "Ensures sources are declared and verified.",
    "select_agent": "Chooses appropriate agent based on contract.",
    "execute_agent": "Agent processes request within constraints.",
    "generate_response": "Agent produces structured output.",
    "validate_response_delivery": "Ensures generated response uses allowed response_mode, has complete delivery status, and contains required response hash before ACK and finalization.",
    "attach_ack": "Adds ACK confirmation and validation result.",
    "finalize_output": "Returns final deterministic response."
  },

  "response_delivery_runtime_policy": {
    "validation_step_required": true,
    "validation_step_position": "after_generate_response_before_attach_ack",
    "default_response_mode": "atomic",
    "system_outputs_require_atomic": true,
    "complete_status_required": true,
    "response_hash_required": true,
    "streaming_system_output_must_be_blocked": true,
    "interrupted_or_incomplete_response_must_be_invalid": true
  },

  "runtime_constraints": [
    "must_follow_execution_order",
    "must_not_skip_validation_steps",
    "must_not_modify_request_payload",
    "must_not_allow_execution_if_blocked",
    "must_be_deterministic",
    "must_validate_response_delivery_before_ack",
    "must_not_finalize_incomplete_response"
  ]
}

=== RULES ===
{
  "execution_flow_is_mandatory": true,
  "step_order_must_not_change": true,
  "validation_must_precede_execution": true,
  "response_delivery_validation_must_precede_ack": true,
  "runtime_must_be_traceable": true,
  "runtime_must_not_have_hidden_steps": true,
  "atomic_response_is_required_for_system_outputs": true,
  "incomplete_response_must_not_be_finalized": true,
  "streaming_response_must_not_be_finalized_for_system_outputs": true
}

=== STATUS ===
{
  "state": "draft",
  "open_questions": [
    "Confirm if execution flow can be parallelized in future versions.",
    "Confirm if multiple agents per request are allowed.",
    "Define exact response delivery validation result structure."
  ],
  "next_step": "Align DEV Manager PRQ with response delivery enforcement."
}