{
  "openapi": "3.1.0",
  "info": {
    "title": "My Prevention Plan draft API",
    "version": "0.2.0",
    "description": "Portfolio R1 local implementation. Synthetic data only. POC extensions are explicitly marked planned."
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "Relative service root for a future same-origin demo"
    }
  ],
  "security": [
    {
      "demoSession": []
    }
  ],
  "paths": {
    "/members/me": {
      "get": {
        "operationId": "getMember",
        "summary": "Read own member preferences and permissions",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Member"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      },
      "patch": {
        "operationId": "updatePreferences",
        "summary": "Replace own preferences",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Member"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1MemberUpdate"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/members/me/consents/{purpose}": {
      "put": {
        "operationId": "recordConsent",
        "summary": "Grant or revoke one optional purpose",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Consent"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "purpose",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "activity_import",
                "coaching_share"
              ]
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1ConsentChoice"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/plans": {
      "post": {
        "operationId": "proposePlan",
        "summary": "Match demo template and create proposal",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "201": {
            "description": "Successful R1 operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Plan"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/plans/{planId}": {
      "get": {
        "operationId": "getPlan",
        "summary": "Read owned or assigned authorized plan",
        "x-demo-roles": [
          "member",
          "coach"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Plan"
                }
              }
            },
            "headers": {
              "ETag": {
                "description": "Quoted plan revision",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "x-r1-status": "implemented-local"
      },
      "patch": {
        "operationId": "changePlanState",
        "summary": "Apply valid member-controlled transition",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Plan"
                }
              }
            },
            "headers": {
              "ETag": {
                "description": "Quoted plan revision",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "428": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Latest plan ETag; mismatch returns 412."
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1PlanAction"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/activities": {
      "post": {
        "operationId": "createActivity",
        "summary": "Record manual activity",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "201": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activity"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityInput"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      },
      "get": {
        "operationId": "listActivities",
        "x-r1-status": "implemented-local",
        "responses": {
          "200": {
            "description": "Own manual activity items"
          }
        }
      }
    },
    "/activities/{activityId}": {
      "patch": {
        "operationId": "correctActivity",
        "summary": "Correct own manual record",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activity"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "activityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityInput"
              }
            }
          }
        },
        "x-r1-status": "planned-poc"
      },
      "delete": {
        "operationId": "removeActivity",
        "summary": "Remove own manual activity with audit",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "204": {
            "description": "Successful operation; draft behavior is defined in the FA pack."
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "activityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "x-r1-status": "planned-poc"
      }
    },
    "/imports/activity-batches": {
      "post": {
        "operationId": "importActivities",
        "summary": "Process permission-scoped synthetic batch",
        "x-demo-roles": [
          "adapter"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportResult"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportRequest"
              }
            }
          }
        },
        "x-r1-status": "planned-poc"
      }
    },
    "/plans/{planId}/check-ins/{weekStart}": {
      "put": {
        "operationId": "saveCheckIn",
        "summary": "Save a new current check-in revision",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1CheckIn"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "weekStart",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1CheckInInput"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/plans/{planId}/reviews": {
      "post": {
        "operationId": "calculateReview",
        "summary": "Create versioned weekly review",
        "x-demo-roles": [
          "member",
          "coach"
        ],
        "responses": {
          "201": {
            "description": "Successful R1 operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Review"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1ReviewRequest"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/support-requests": {
      "post": {
        "operationId": "requestSupport",
        "summary": "Explicitly request authorized coaching support",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "201": {
            "description": "Successful R1 operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Support"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportInput"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/coach/support-requests": {
      "get": {
        "operationId": "listSupportQueue",
        "summary": "List authorized coach queue",
        "x-demo-roles": [
          "coach"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/R1Support"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/support-requests/{requestId}": {
      "patch": {
        "operationId": "updateSupport",
        "summary": "Apply authorized support state transition",
        "x-demo-roles": [
          "member",
          "coach"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportRequest"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "requestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAction"
              }
            }
          }
        },
        "x-r1-status": "planned-poc"
      }
    },
    "/plans/{planId}/changes": {
      "post": {
        "operationId": "proposeChange",
        "summary": "Propose adjustment without activating it",
        "x-demo-roles": [
          "coach"
        ],
        "responses": {
          "201": {
            "description": "Successful R1 operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Change"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/R1ChangeInput"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      },
      "get": {
        "operationId": "listPlanChanges",
        "x-r1-status": "implemented-local",
        "parameters": [
          {
            "in": "path",
            "name": "planId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Owner or authorized assigned-coach change history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/R1Change"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/plans/{planId}/changes/{changeId}/decision": {
      "post": {
        "operationId": "decideChange",
        "summary": "Accept or decline proposed change",
        "x-demo-roles": [
          "member"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/R1Plan"
                }
              }
            },
            "headers": {
              "ETag": {
                "description": "Quoted plan revision",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "428": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "changeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Latest plan ETag; mismatch returns 412."
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeDecision"
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/analyst/decisions": {
      "get": {
        "operationId": "listDecisions",
        "summary": "Read pseudonymous traces without member notes",
        "x-demo-roles": [
          "analyst"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/R1Decision"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-r1-status": "implemented-local"
      }
    },
    "/analyst/metrics": {
      "get": {
        "operationId": "getMetrics",
        "summary": "Read defined synthetic delivery measures",
        "x-demo-roles": [
          "analyst"
        ],
        "responses": {
          "200": {
            "description": "Successful operation; draft behavior is defined in the FA pack.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Metric"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "See error semantics in FA Deliverables/11-api-contract.md",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-r1-status": "planned-poc"
      }
    },
    "/demo/start": {
      "post": {
        "operationId": "startDemo",
        "summary": "startDemo",
        "x-r1-status": "implemented-local",
        "security": [],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "201": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/demo/session": {
      "get": {
        "operationId": "readDemoSession",
        "summary": "readDemoSession",
        "x-r1-status": "implemented-local",
        "security": [
          {
            "demoSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        }
      }
    },
    "/demo/state": {
      "get": {
        "operationId": "readRoleScopedDemoState",
        "summary": "readRoleScopedDemoState",
        "x-r1-status": "implemented-local",
        "security": [
          {
            "demoSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "Session envelope plus member/coach programme context, or analyst decisions. Protected coach view fails when sharing is off."
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        }
      }
    },
    "/demo/role": {
      "post": {
        "operationId": "switchDemoRole",
        "summary": "switchDemoRole",
        "x-r1-status": "implemented-local",
        "security": [
          {
            "demoSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "role"
                ],
                "properties": {
                  "role": {
                    "enum": [
                      "member",
                      "coach",
                      "analyst"
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/demo/scenario": {
      "post": {
        "operationId": "loadDemoScenario",
        "summary": "loadDemoScenario",
        "x-r1-status": "implemented-local",
        "security": [
          {
            "demoSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scenario"
                ],
                "properties": {
                  "scenario": {
                    "enum": [
                      "guided",
                      "camille",
                      "jules",
                      "noor"
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/demo/reset": {
      "post": {
        "operationId": "resetOwnDemo",
        "summary": "resetOwnDemo",
        "x-r1-status": "implemented-local",
        "security": [
          {
            "demoSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current session or role-scoped state, no-store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoSession"
                }
              }
            }
          },
          "401": {
            "description": "Session missing or expired"
          },
          "409": {
            "description": "Stale generation/actor or idempotency conflict"
          },
          "503": {
            "description": "Save not confirmed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Generation",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "X-Demo-Revision",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "demoSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "prevention_demo",
        "description": "Opaque HttpOnly SameSite=Lax token. Only its SHA-256 digest is stored. Session actor is server-controlled."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "fieldErrors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "field",
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "Preferences": {
        "type": "object",
        "properties": {
          "goal": {
            "type": "string"
          },
          "activityType": {
            "type": "string",
            "enum": [
              "walking",
              "cycling",
              "other"
            ]
          },
          "availableDays": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7
            }
          },
          "minutesPerSlot": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          }
        },
        "required": [
          "goal",
          "activityType",
          "availableDays",
          "minutesPerSlot"
        ],
        "additionalProperties": false
      },
      "ConsentChoice": {
        "type": "object",
        "properties": {
          "granted": {
            "type": "boolean"
          },
          "policyVersion": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "granted",
          "policyVersion"
        ],
        "additionalProperties": false
      },
      "Consent": {
        "type": "object",
        "properties": {
          "purpose": {
            "type": "string",
            "enum": [
              "activity_import",
              "coaching_share"
            ]
          },
          "granted": {
            "type": "boolean"
          },
          "policyVersion": {
            "type": "string",
            "minLength": 1
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "purpose",
          "granted",
          "policyVersion",
          "revision",
          "recordedAt"
        ],
        "additionalProperties": false
      },
      "Member": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "displayName": {
            "type": "string"
          },
          "locale": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "preferences": {
            "$ref": "#/components/schemas/Preferences"
          },
          "consents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Consent"
            }
          }
        },
        "required": [
          "id",
          "displayName",
          "locale",
          "timezone",
          "preferences",
          "consents"
        ],
        "additionalProperties": false
      },
      "Slot": {
        "type": "object",
        "properties": {
          "dayOfWeek": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7
          },
          "durationMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          }
        },
        "required": [
          "dayOfWeek",
          "durationMinutes"
        ],
        "additionalProperties": false
      },
      "PlanProposalRequest": {
        "type": "object",
        "properties": {
          "preferences": {
            "$ref": "#/components/schemas/Preferences"
          }
        },
        "required": [
          "preferences"
        ],
        "additionalProperties": false
      },
      "Plan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "proposed",
              "active",
              "paused",
              "completed",
              "withdrawn",
              "declined"
            ]
          },
          "currentVersion": {
            "type": "integer",
            "minimum": 1
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "templateId": {
            "type": "string",
            "minLength": 1
          },
          "templateVersion": {
            "type": "integer",
            "minimum": 1
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string"
          },
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanVersion"
            },
            "description": "Historical versions retained with original acceptance and template."
          }
        },
        "required": [
          "id",
          "memberId",
          "state",
          "currentVersion",
          "revision",
          "templateId",
          "templateVersion",
          "slots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "PlanAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "accept",
              "decline",
              "pause",
              "resume",
              "complete",
              "withdraw"
            ]
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "ActivityInput": {
        "type": "object",
        "properties": {
          "occurredOn": {
            "type": "string",
            "format": "date"
          },
          "durationMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          },
          "activityType": {
            "type": "string",
            "enum": [
              "walking",
              "cycling"
            ]
          }
        },
        "required": [
          "occurredOn",
          "durationMinutes",
          "activityType"
        ],
        "additionalProperties": false
      },
      "Activity": {
        "type": "object",
        "properties": {
          "occurredOn": {
            "type": "string",
            "format": "date"
          },
          "durationMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          },
          "activityType": {
            "type": "string",
            "enum": [
              "walking",
              "cycling"
            ]
          },
          "id": {
            "type": "string",
            "minLength": 1
          },
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "source": {
            "type": "string",
            "enum": [
              "manual",
              "imported"
            ]
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalEventId": {
            "type": [
              "string",
              "null"
            ]
          },
          "overlapStatus": {
            "type": "string",
            "enum": [
              "clear",
              "unresolved",
              "resolved"
            ]
          }
        },
        "required": [
          "id",
          "memberId",
          "occurredOn",
          "durationMinutes",
          "activityType",
          "source",
          "overlapStatus"
        ],
        "additionalProperties": false
      },
      "ImportedEvent": {
        "type": "object",
        "properties": {
          "occurredOn": {
            "type": "string",
            "format": "date"
          },
          "durationMinutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          },
          "activityType": {
            "type": "string",
            "enum": [
              "walking",
              "cycling"
            ]
          },
          "externalEventId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "occurredOn",
          "durationMinutes",
          "activityType",
          "externalEventId"
        ],
        "additionalProperties": false
      },
      "ImportRequest": {
        "type": "object",
        "properties": {
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "provider": {
            "type": "string",
            "minLength": 1
          },
          "coverageDates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            }
          },
          "coverageComplete": {
            "type": "boolean"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImportedEvent"
            }
          }
        },
        "required": [
          "memberId",
          "provider",
          "coverageDates",
          "coverageComplete",
          "events"
        ],
        "additionalProperties": false
      },
      "ImportResult": {
        "type": "object",
        "properties": {
          "batchId": {
            "type": "string",
            "minLength": 1
          },
          "accepted": {
            "type": "integer",
            "minimum": 0
          },
          "duplicates": {
            "type": "integer",
            "minimum": 0
          },
          "rejected": {
            "type": "integer",
            "minimum": 0
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalEventId": {
                  "type": "string",
                  "minLength": 1
                },
                "code": {
                  "type": "string"
                }
              },
              "required": [
                "externalEventId",
                "code"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "batchId",
          "accepted",
          "duplicates",
          "rejected",
          "errors"
        ],
        "additionalProperties": false
      },
      "CheckInInput": {
        "type": "object",
        "properties": {
          "difficulty": {
            "type": "string",
            "enum": [
              "manageable",
              "difficult",
              "not_attempted",
              "prefer_not_to_say"
            ]
          },
          "barriers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "time",
                "organization",
                "other"
              ]
            }
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "reportingComplete": {
            "type": "boolean"
          }
        },
        "required": [
          "difficulty",
          "reportingComplete"
        ],
        "additionalProperties": false
      },
      "CheckIn": {
        "type": "object",
        "properties": {
          "difficulty": {
            "type": "string",
            "enum": [
              "manageable",
              "difficult",
              "not_attempted",
              "prefer_not_to_say"
            ]
          },
          "barriers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "time",
                "organization",
                "other"
              ]
            }
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "reportingComplete": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "planVersion": {
            "type": "integer",
            "minimum": 1
          },
          "weekStart": {
            "type": "string",
            "format": "date"
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "id",
          "planId",
          "planVersion",
          "weekStart",
          "revision",
          "difficulty",
          "reportingComplete"
        ],
        "additionalProperties": false
      },
      "ReviewRequest": {
        "type": "object",
        "properties": {
          "weekStart": {
            "type": "string",
            "format": "date"
          },
          "planVersion": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "weekStart",
          "planVersion"
        ],
        "additionalProperties": false
      },
      "Review": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "planVersion": {
            "type": "integer",
            "minimum": 1
          },
          "weekStart": {
            "type": "string",
            "format": "date"
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "sessionCount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "target": {
            "type": "integer",
            "minimum": 1
          },
          "completeness": {
            "type": "string",
            "enum": [
              "complete",
              "incomplete"
            ]
          },
          "outcome": {
            "type": "string",
            "enum": [
              "review_stopped",
              "review_paused",
              "support_offered",
              "data_check_needed",
              "check_in_invited",
              "plan_review_offered",
              "progress_acknowledged",
              "continue_or_adjust"
            ]
          },
          "ruleId": {
            "type": "string",
            "minLength": 1
          },
          "ruleVersion": {
            "type": "string",
            "minLength": 1
          },
          "nextActions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "planId",
          "planVersion",
          "weekStart",
          "revision",
          "sessionCount",
          "target",
          "completeness",
          "outcome",
          "ruleId",
          "ruleVersion",
          "nextActions"
        ],
        "additionalProperties": false
      },
      "SupportInput": {
        "type": "object",
        "properties": {
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "reviewId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "planId",
          "reviewId"
        ],
        "additionalProperties": false
      },
      "SupportRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "reviewId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "open",
              "assigned",
              "responded",
              "closed",
              "cancelled"
            ]
          },
          "assignedCoachId": {
            "type": [
              "string",
              "null"
            ]
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "memberId",
          "planId",
          "reviewId",
          "state",
          "assignedCoachId",
          "requestedAt"
        ],
        "additionalProperties": false
      },
      "SupportAction": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "assign",
              "respond",
              "close",
              "cancel"
            ]
          },
          "response": {
            "type": "string",
            "maxLength": 1000
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "ChangeInput": {
        "type": "object",
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 1
          },
          "proposedSlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          }
        },
        "required": [
          "baseVersion",
          "proposedSlots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "PlanChange": {
        "type": "object",
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 1
          },
          "proposedSlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "proposed",
              "accepted",
              "declined"
            ]
          },
          "proposedBy": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "planId",
          "state",
          "proposedBy",
          "baseVersion",
          "proposedSlots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "ChangeDecision": {
        "type": "object",
        "properties": {
          "decision": {
            "type": "string",
            "enum": [
              "accept",
              "decline"
            ]
          }
        },
        "required": [
          "decision"
        ],
        "additionalProperties": false
      },
      "Decision": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "reviewId": {
            "type": "string",
            "minLength": 1
          },
          "ruleId": {
            "type": "string",
            "minLength": 1
          },
          "ruleVersion": {
            "type": "string",
            "minLength": 1
          },
          "outcome": {
            "type": "string"
          },
          "inputCategories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "reviewId",
          "ruleId",
          "ruleVersion",
          "outcome",
          "inputCategories",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "Metric": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "numerator": {
            "type": "integer",
            "minimum": 0
          },
          "denominator": {
            "type": "integer",
            "minimum": 0
          },
          "value": {
            "type": [
              "number",
              "null"
            ]
          },
          "definition": {
            "type": "string"
          },
          "periodStart": {
            "type": "string",
            "format": "date"
          },
          "periodEnd": {
            "type": "string",
            "format": "date"
          },
          "missingCount": {
            "type": "integer",
            "minimum": 0
          },
          "synthetic": {
            "const": true
          }
        },
        "required": [
          "name",
          "numerator",
          "denominator",
          "value",
          "definition",
          "periodStart",
          "periodEnd",
          "missingCount",
          "synthetic"
        ],
        "additionalProperties": false
      },
      "PlanVersion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "templateId",
          "templateVersion",
          "slots"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "templateId": {
            "type": "string"
          },
          "templateVersion": {
            "type": "integer",
            "minimum": 1
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "acceptedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "DemoSession": {
        "type": "object",
        "required": [
          "generation",
          "revision",
          "role",
          "scenario",
          "expiresAt"
        ],
        "properties": {
          "generation": {
            "type": "integer"
          },
          "revision": {
            "type": "integer"
          },
          "role": {
            "enum": [
              "member",
              "coach",
              "analyst"
            ]
          },
          "scenario": {
            "enum": [
              "guided",
              "camille",
              "jules",
              "noor"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "R1Member": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "displayName": {
            "type": "string"
          },
          "preferences": {
            "$ref": "#/components/schemas/Preferences"
          },
          "consents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Consent"
            }
          },
          "reportingComplete": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "displayName",
          "preferences",
          "consents"
        ],
        "additionalProperties": false
      },
      "R1MemberUpdate": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/Preferences"
          },
          {
            "type": "object",
            "properties": {
              "preferences": {
                "$ref": "#/components/schemas/Preferences"
              }
            },
            "required": [
              "preferences"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "reportingComplete": {
                "type": "boolean"
              }
            },
            "required": [
              "reportingComplete"
            ],
            "additionalProperties": false
          }
        ]
      },
      "R1Plan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "proposed",
              "active",
              "declined"
            ]
          },
          "currentVersion": {
            "type": "integer",
            "minimum": 0
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "templateId": {
            "type": "string",
            "minLength": 1
          },
          "templateVersion": {
            "type": "integer",
            "minimum": 1
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string"
          },
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/R1PlanVersion"
            },
            "description": "Historical versions retained with original acceptance and template."
          }
        },
        "required": [
          "id",
          "memberId",
          "state",
          "currentVersion",
          "revision",
          "templateId",
          "templateVersion",
          "slots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "R1PlanVersion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "templateId",
          "templateVersion",
          "slots"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "templateId": {
            "type": "string"
          },
          "templateVersion": {
            "type": "integer",
            "minimum": 1
          },
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "acceptedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "planId": {
            "type": "string"
          }
        }
      },
      "R1PlanAction": {
        "type": "object",
        "properties": {
          "action": {
            "enum": [
              "accept",
              "decline"
            ]
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "R1ConsentChoice": {
        "type": "object",
        "properties": {
          "granted": {
            "type": "boolean"
          }
        },
        "required": [
          "granted"
        ],
        "additionalProperties": false
      },
      "R1CheckInInput": {
        "type": "object",
        "properties": {
          "difficulty": {
            "type": "string",
            "enum": [
              "manageable",
              "difficult",
              "not_attempted",
              "prefer_not_to_say"
            ]
          },
          "barriers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "time",
                "organization",
                "other"
              ]
            },
            "maxItems": 3
          },
          "note": {
            "type": "string",
            "maxLength": 500
          },
          "reportingComplete": {
            "type": "boolean"
          }
        },
        "required": [
          "difficulty",
          "reportingComplete"
        ],
        "additionalProperties": false
      },
      "R1CheckIn": {
        "type": "object",
        "properties": {
          "difficulty": {
            "type": "string",
            "enum": [
              "manageable",
              "difficult",
              "not_attempted",
              "prefer_not_to_say"
            ]
          },
          "barriers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "time",
                "organization",
                "other"
              ]
            },
            "maxItems": 3
          },
          "note": {
            "type": "string",
            "maxLength": 500
          },
          "reportingComplete": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "planVersion": {
            "type": "integer",
            "minimum": 1
          },
          "weekStart": {
            "type": "string",
            "format": "date"
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "id",
          "planId",
          "planVersion",
          "weekStart",
          "revision",
          "difficulty",
          "reportingComplete"
        ],
        "additionalProperties": false
      },
      "R1ReviewRequest": {
        "type": "object",
        "properties": {
          "weekStart": {
            "enum": [
              "2026-10-05"
            ]
          }
        },
        "required": [
          "weekStart"
        ],
        "additionalProperties": false
      },
      "R1Review": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "planVersion": {
            "type": "integer",
            "minimum": 1
          },
          "weekStart": {
            "type": "string",
            "format": "date"
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "sessionCount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "target": {
            "type": "integer",
            "minimum": 1
          },
          "completeness": {
            "type": "string",
            "enum": [
              "complete",
              "incomplete"
            ]
          },
          "outcome": {
            "type": "string",
            "enum": [
              "review_stopped",
              "review_paused",
              "support_offered",
              "data_check_needed",
              "check_in_invited",
              "plan_review_offered",
              "progress_acknowledged",
              "continue_or_adjust"
            ]
          },
          "ruleId": {
            "type": "string",
            "minLength": 1
          },
          "ruleVersion": {
            "type": "string",
            "minLength": 1
          },
          "nextActions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recordedCount": {
            "type": "integer",
            "minimum": 0
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "snapshot": {
            "type": "object",
            "properties": {
              "difficulty": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "reportingComplete": {
                "type": "boolean"
              },
              "recordedCount": {
                "type": "integer"
              }
            },
            "required": [
              "difficulty",
              "reportingComplete",
              "recordedCount"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "planId",
          "planVersion",
          "weekStart",
          "revision",
          "sessionCount",
          "target",
          "completeness",
          "outcome",
          "ruleId",
          "ruleVersion",
          "nextActions"
        ],
        "additionalProperties": false
      },
      "R1Support": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "memberId": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "reviewId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "requested",
              "proposed",
              "closed",
              "cancelled"
            ]
          },
          "assignedCoachId": {
            "type": [
              "string",
              "null"
            ]
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "memberId",
          "planId",
          "reviewId",
          "state",
          "assignedCoachId",
          "requestedAt"
        ],
        "additionalProperties": false
      },
      "R1ChangeInput": {
        "type": "object",
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 1
          },
          "proposedSlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "required": [
          "baseVersion",
          "proposedSlots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "R1Change": {
        "type": "object",
        "properties": {
          "baseVersion": {
            "type": "integer",
            "minimum": 1
          },
          "proposedSlots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          },
          "rationale": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "id": {
            "type": "string",
            "minLength": 1
          },
          "planId": {
            "type": "string",
            "minLength": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "proposed",
              "accepted",
              "declined",
              "cancelled"
            ]
          },
          "proposedBy": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "planId",
          "state",
          "proposedBy",
          "baseVersion",
          "proposedSlots",
          "rationale"
        ],
        "additionalProperties": false
      },
      "R1Decision": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "memberRef": {
            "type": "string"
          },
          "ruleId": {
            "type": "string"
          },
          "ruleVersion": {
            "type": "string"
          },
          "outcome": {
            "type": "string"
          },
          "inputCategories": {
            "type": "object",
            "properties": {
              "difficulty": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "completeness": {
                "enum": [
                  "complete",
                  "incomplete"
                ]
              },
              "recordedCount": {
                "type": "integer"
              }
            },
            "required": [
              "difficulty",
              "completeness",
              "recordedCount"
            ],
            "additionalProperties": false
          },
          "planVersion": {
            "type": "integer"
          },
          "reviewRevision": {
            "type": "integer"
          },
          "templateId": {
            "type": "string"
          },
          "templateVersion": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "memberRef",
          "ruleId",
          "ruleVersion",
          "outcome",
          "inputCategories",
          "planVersion",
          "reviewRevision",
          "templateId",
          "templateVersion",
          "createdAt"
        ],
        "additionalProperties": false
      }
    }
  }
}
