{
  "schema": "DAT006_LAB_MODEL_CONTRACT_v1",
  "lesson_id": "DAT-006",
  "lab_id": "DAT006-LAB1",
  "starter_must_not_pre_solve_skill": true,
  "business_question": "Return exactly one row per customer with recent paid spend since 2026-09-01, latest qualifying order date, and rank within plan_tier.",
  "required_result_grain": "one row per customer",
  "relationships": [
    "customers 1:N orders",
    "orders 1:N line_items"
  ],
  "must_preserve": [
    "customers with no qualifying recent paid order"
  ],
  "required_query_behaviors": [
    "recent paid filter does not destroy customer preservation",
    "line-item values are aggregated without multiplying precomputed totals",
    "one row per customer exists before rank",
    "rank is a window over customer-grain rows"
  ],
  "forbidden_shortcuts": [
    "DISTINCT used as the repair for a cardinality error",
    "claim that CTE is always materialized",
    "claim EXPLAIN cost is milliseconds",
    "fabricated EXPLAIN/ANALYZE output"
  ],
  "source_ids": [
    "PG18-QUERIES",
    "PG18-WINDOW",
    "PG18-WITH",
    "PG18-EXPLAIN",
    "PG18-USING-EXPLAIN"
  ],
  "runtime_required_for_learner_completion": true,
  "postgresql_version_must_be_recorded": true,
  "plan_evidence": {
    "estimate": "EXPLAIN (FORMAT JSON, COSTS TRUE)",
    "actual": "EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)",
    "actual_executes_statement": true
  },
  "transfer_required": true,
  "production_performance_claims_forbidden": true,
  "runtime_isolation_required": "EPHEMERAL_RANDOM_SCHEMA",
  "explicit_disposable_confirmation": {
    "env": "MAKNOW_DAT006_DISPOSABLE_CONFIRM",
    "required_value": "YES"
  },
  "normal_runtime_query_policy": "exactly one SELECT/WITH read-only statement; data-modifying CTEs and appended statements are rejected",
  "runtime_structural_assertions": [
    "output row count equals customer count",
    "customer_id unique and complete",
    "customer_id non-null",
    "recent_spend non-null",
    "tier_rank non-null"
  ],
  "negative_observation_required": "starter_broken.sql output is captured before repaired output"
}
