{
  "name": "prism_prompt",
  "title": "Build a whole Prism app from one prompt",
  "description": "Write every file of a Prism application from one prism/prompt/1 prompt: the model the guest is built from and the theorems Lean proves about it (from app, a prism/spec/1 spec), and the architecture, design views, features and journeys, security and threat model, quality model and compliance obligations, each checked by the Lean kernel; plus the register rows, scenarios, tests, page description and OpenSpec spec of a repository created from UOR-Foundation/template. Push the files to such a repository and its gate and Pages workflow build, verify and publish the app.",
  "inputSchema": {
    "type": "object",
    "description": "One prism/prompt/1 prompt: the app as a prism/spec/1 spec, and, optionally, everything else every facet needs.",
    "properties": {
      "schema": {
        "const": "prism/prompt/1"
      },
      "goal": {
        "type": "string",
        "description": "The goal the app is built toward, in one sentence a developer would say. It becomes the spec purpose when app.purpose is left out."
      },
      "app": {
        "type": "object",
        "description": "A whole prism/spec/1 spec. Omit to read.",
        "properties": {
          "name": {
            "type": "string",
            "description": "Lower case and hyphens, such as loan-approval."
          },
          "title": {
            "type": "string"
          },
          "purpose": {
            "type": "string",
            "description": "What the app decides, in one sentence."
          },
          "fields": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "description": "One request is these values in order, separated by spaces.",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "A lower-case word."
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "number",
                    "choice"
                  ]
                },
                "values": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "For a choice: two to 32 lower-case words."
                },
                "min": {
                  "type": "integer",
                  "minimum": 0
                },
                "max": {
                  "type": "integer",
                  "minimum": 0
                },
                "means": {
                  "type": "string",
                  "description": "What the field is, with its unit, such as \"yearly income, in whole dollars\"."
                }
              },
              "required": [
                "name",
                "kind"
              ]
            }
          },
          "outcomes": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "string"
            },
            "description": "Lower-case words; invalid is reserved."
          },
          "meanings": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "What each answer means, such as {\"review\": \"a person must decide\"}."
          },
          "rules": {
            "type": "array",
            "minItems": 1,
            "maxItems": 24,
            "description": "In order; the first that matches decides.",
            "items": {
              "type": "object",
              "properties": {
                "when": {
                  "type": "array",
                  "minItems": 1,
                  "description": "All must hold. A choice field compares with is or is not and one of its choices; a number field compares with a whole number or another number field, as {\"field\": \"income\"}.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "field": {
                        "type": "string"
                      },
                      "op": {
                        "type": "string",
                        "enum": [
                          "is",
                          "is not",
                          "<",
                          "<=",
                          ">",
                          ">=",
                          "=",
                          "!="
                        ]
                      },
                      "value": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "integer",
                            "minimum": 0
                          },
                          {
                            "type": "object",
                            "properties": {
                              "field": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "field"
                            ]
                          }
                        ]
                      }
                    },
                    "required": [
                      "field",
                      "op",
                      "value"
                    ]
                  }
                },
                "then": {
                  "type": "string"
                },
                "why": {
                  "type": "string",
                  "description": "Why, in a few words, such as \"it enforces INV-001\"."
                }
              },
              "required": [
                "when",
                "then"
              ]
            }
          },
          "otherwise": {
            "type": "string",
            "description": "The answer when no rule matches."
          },
          "otherwiseWhy": {
            "type": "string",
            "description": "Why, in a few words, such as \"it enforces INV-001\"."
          },
          "properties": {
            "type": "array",
            "description": "What must never or always happen; each becomes a theorem Lean proves.",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "never",
                    "always"
                  ]
                },
                "when": {
                  "type": "array",
                  "minItems": 1,
                  "description": "All must hold. A choice field compares with is or is not and one of its choices; a number field compares with a whole number or another number field, as {\"field\": \"income\"}.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "field": {
                        "type": "string"
                      },
                      "op": {
                        "type": "string",
                        "enum": [
                          "is",
                          "is not",
                          "<",
                          "<=",
                          ">",
                          ">=",
                          "=",
                          "!="
                        ]
                      },
                      "value": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "integer",
                            "minimum": 0
                          },
                          {
                            "type": "object",
                            "properties": {
                              "field": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "field"
                            ]
                          }
                        ]
                      }
                    },
                    "required": [
                      "field",
                      "op",
                      "value"
                    ]
                  }
                },
                "then": {
                  "type": "string"
                },
                "why": {
                  "type": "string",
                  "description": "The harm it prevents, such as \"poor credit history predicts default\". Ask the user when you cannot tell."
                }
              },
              "required": [
                "kind",
                "when",
                "then"
              ]
            }
          },
          "limits": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What the app does not decide, and choices the rules make silently, such as \"fair credit is treated as good\"."
          },
          "examples": {
            "type": "array",
            "description": "Requests and their expected answers; each becomes an acceptance vector.",
            "items": {
              "type": "object",
              "properties": {
                "request": {
                  "type": "string"
                },
                "response": {
                  "type": "string"
                }
              },
              "required": [
                "request",
                "response"
              ]
            }
          }
        },
        "required": [
          "purpose",
          "fields",
          "outcomes",
          "rules",
          "otherwise"
        ]
      },
      "stakeholders": {
        "type": "array",
        "description": "Who the app is for. A Verifier, anyone who replays the holo before trusting it, is always added.",
        "items": {
          "type": "object",
          "description": "A stakeholder.",
          "properties": {
            "name": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "concerns": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Names of concerns, from concerns or the derived ones."
            }
          },
          "required": [
            "name"
          ]
        }
      },
      "concerns": {
        "type": "array",
        "description": "What the stakeholders care about, each viewed in one model.",
        "items": {
          "type": "object",
          "description": "A concern.",
          "properties": {
            "name": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "model": {
              "enum": [
                "component",
                "quality",
                "security"
              ]
            }
          },
          "required": [
            "name"
          ]
        }
      },
      "components": {
        "type": "array",
        "description": "Systems outside the app that send it requests or read its answers.",
        "items": {
          "type": "object",
          "description": "A component.",
          "properties": {
            "name": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "kind": {
              "enum": [
                "service",
                "database",
                "externalSystem",
                "cliAdapter",
                "staticSite",
                "releaseBinary"
              ]
            }
          },
          "required": [
            "name"
          ]
        }
      },
      "threats": {
        "type": "array",
        "description": "What can go wrong, beyond the threats every app has (an oversized or malformed request, a substituted holo or source, a granted capability, an answer a property rules out).",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "stride": {
              "enum": [
                "spoofing",
                "tampering",
                "repudiation",
                "informationDisclosure",
                "denialOfService",
                "elevationOfPrivilege"
              ]
            },
            "asset": {
              "enum": [
                "request",
                "answer",
                "holo",
                "source"
              ]
            },
            "likelihood": {
              "enum": [
                "low",
                "medium",
                "high"
              ]
            },
            "impact": {
              "enum": [
                "minor",
                "major",
                "critical"
              ]
            },
            "control": {
              "type": "object",
              "description": "The control that answers it.",
              "properties": {
                "name": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                },
                "evidence": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "enum": [
                          "gate",
                          "proof",
                          "review"
                        ]
                      },
                      "reference": {
                        "type": "string",
                        "description": "For proof evidence, a property id such as INV-001 (its theorem) or Module::theorem; otherwise the gate or file that is the evidence."
                      }
                    },
                    "required": [
                      "kind",
                      "reference"
                    ]
                  }
                }
              },
              "required": [
                "name",
                "text",
                "evidence"
              ]
            },
            "accepted": {
              "type": "string",
              "description": "Instead of a control: why the risk is accepted."
            }
          },
          "required": [
            "name",
            "text",
            "stride",
            "asset"
          ]
        }
      },
      "quality": {
        "type": "array",
        "description": "How good is good enough, as ISO/IEC 25010:2023 requirements with a measure and its threshold.",
        "items": {
          "type": "object",
          "properties": {
            "characteristic": {
              "enum": [
                "Functional suitability",
                "Performance efficiency",
                "Compatibility",
                "Interaction capability",
                "Reliability",
                "Security",
                "Maintainability",
                "Flexibility",
                "Safety"
              ]
            },
            "subcharacteristic": {
              "type": "string"
            },
            "requirement": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "measure": {
              "type": "string"
            },
            "measureText": {
              "type": "string"
            },
            "threshold": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "characteristic",
            "subcharacteristic",
            "requirement",
            "text",
            "measure",
            "measureText",
            "threshold"
          ]
        }
      },
      "journeys": {
        "type": "array",
        "description": "Ordered steps a stakeholder takes. A step is a rule ID (REQ-001), a property ID (INV-001), otherwise or refuse.",
        "items": {
          "type": "object",
          "properties": {
            "stakeholder": {
              "type": "string"
            },
            "steps": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": [
            "stakeholder",
            "steps"
          ]
        }
      },
      "pattern": {
        "enum": [
          "decisionTable",
          "policyDecision",
          "stateMachine"
        ],
        "description": "The pattern the behavior follows: decisionTable (OMG DMN 1.5, hit policy FIRST, the default), policyDecision (OASIS XACML 3.0: the answers are exactly permit, deny, not-applicable and indeterminate) or stateMachine (OMG UML 2.5.1: the answer is the next state, and machine is required)."
      },
      "machine": {
        "type": "object",
        "description": "For a stateMachine: which choice field carries the current state, the initial state, and the final states. The answers are exactly the state values. The builder proves that a final state is never left and that no run from the initial state reaches a state outside the reachable set.",
        "properties": {
          "state": {
            "type": "string",
            "description": "The choice field whose values are the states."
          },
          "initial": {
            "type": "string",
            "description": "The state every run starts in."
          },
          "final": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "uniqueItems": true,
            "description": "States a run never leaves once it reaches them (UML FinalState)."
          }
        },
        "required": [
          "state",
          "initial"
        ]
      },
      "license": {
        "type": "string",
        "description": "The SPDX license expression; MIT OR Apache-2.0 when left out."
      },
      "repository": {
        "type": "string",
        "description": "owner/name of the repository the app will live in, for its page and links."
      },
      "axioms": {
        "type": "object",
        "description": "The exact axiom set a verify observed for a generated declaration, by declaration name, as prism-code records it when LexLean reports LLV7005. `node builder/cli.mjs axioms` writes it from a verify log.",
        "additionalProperties": {
          "type": "array",
          "items": {
            "enum": [
              "Classical.choice",
              "Quot.sound",
              "propext"
            ]
          },
          "uniqueItems": true
        }
      }
    },
    "required": [
      "app"
    ]
  }
}
