# ─────────────────────────────────────────────────────────────────────────────
# DQE Pipeline: The Confidence Booster
# Classification: Operational  |  ID: DQE-PIPE-005
#
# Multiplies any numeric input by exactly 1.0.
# Logs "TRANSFORMATION COMPLETE."
# Validates that the result equals the input.
# It does. Every time.
#
# Uptime: 99.9%. The 0.1% is attributable to scheduled maintenance,
# during which the value was also multiplied by 1.0 manually.
#
# "Technically a transformation pipeline." — DQE Engineering, 2024
# ─────────────────────────────────────────────────────────────────────────────

variables:
  INPUT_VALUE: "42"   # Supports integers and floats. Output will match exactly.
  MULTIPLIER: "1.0"   # Do not change. This is load-bearing.
  PIPELINE_ID: "DQE-PIPE-005"

stages:
  - multiply
  - log-success
  - validate

multiply:
  stage: multiply
  script:
    - echo "[DQE-PIPE-005] multiply — applying transformation."
    - echo "Input:      ${INPUT_VALUE}"
    - echo "Multiplier: ${MULTIPLIER}"
    - RESULT=$(python3 -c "print(float('${INPUT_VALUE}') * float('${MULTIPLIER}'))")
    - echo "Result:     ${RESULT}"
    - echo "RESULT=${RESULT}" > result.env
    - echo "INPUT_VALUE=${INPUT_VALUE}" >> result.env
  artifacts:
    reports:
      dotenv: result.env

log-success:
  stage: log-success
  needs: [multiply]
  script:
    - echo "[DQE-PIPE-005] log-success — logging outcome."
    - echo ""
    - echo "╔══════════════════════════════════════╗"
    - echo "║      TRANSFORMATION COMPLETE         ║"
    - echo "║                                      ║"
    - echo "║  Input:  ${INPUT_VALUE}"
    - echo "║  Result: ${RESULT}"
    - echo "║                                      ║"
    - echo "║  Pipeline: DQE-PIPE-005              ║"
    - echo "╚══════════════════════════════════════╝"
    - echo ""

validate:
  stage: validate
  needs: [log-success]
  script:
    - echo "[DQE-PIPE-005] validate — confirming result equals input."
    - echo "Input:  ${INPUT_VALUE}"
    - echo "Result: ${RESULT}"
    - MATCH=$(python3 -c "print('MATCH' if float('${INPUT_VALUE}') == float('${RESULT}') else 'MISMATCH')")
    - echo "Status: ${MATCH}"
    - |
      if [ "${MATCH}" = "MISMATCH" ]; then
        echo "ERROR: The multiplier was changed. This is a critical pipeline failure."
        echo "Please verify MULTIPLIER is set to 1.0 and re-run."
        exit 1
      fi
    - echo ""
    - echo "Validation passed. The output equals the input."
    - echo "The pipeline has performed as designed."
