PrismDevRelOpen the app
Examples: Draft admission

Overview

Example apps

Decision tables

Rule 30 cellStrike dieWise deferralCurrent supportHeader workPlant attunementCapability routePublish gateProposal admissionCompression admissionQuorum commitAddress admissionDataflow policyDraft admissionCoded matmul admissionUTQC row honestyCalculator protocolRequantization clampJCS NFC admissionTwo-seed barDocs sync

Policy decisions

Open policyNamespace authorizationAxiom policyGNAF claim wordingEmporous admissionPortal publication

State machines

MCP task lifecycleContainer lifecycleAtlas walk controlsVault escrow lifecycleRelease lifecycleOrganization lifecycle

// example · Decision tables

Draft admission

Decide if LexLean MCP takes a draft from an AI model. No file path leaves its folders, and no draft goes over the owner's limits.

Inspired by UOR-Foundation/lexlean-mcp. LexLean MCP serves LexLean to LLM clients and admits each draft's paths and size before the engine reads it.

Pattern: Decision table, OMG DMN 1.5, hit policy FIRST. To write one of your own, follow How to build a decision table app.

What the Draft admission app does1. Request: path, files, bytes, repeats 2. 11 rules: the first that matches wins 3. Answer: admitted, path-refused, too-many-files, too-many-bytes, duplicate-path 4. Proved: 5 theorems, 60 tests01Requestpath, files,bytes, repeats0211 rulesthe first thatmatches wins03Answeradmitted,path-refused,too-many-files,too-many-bytes,duplicate-path04Proved5 theorems, 60testsWhat the Draft admission app does1. Request: path, files, bytes, repeats 2. 11 rules: the first that matches wins 3. Answer: admitted, path-refused, too-many-files, too-many-bytes, duplicate-path 4. Proved: 5 theorems, 60 tests01Requestpath, files, bytes, repeats0211 rulesthe first that matches wins03Answeradmitted, path-refused,too-many-files, too-many-bytes,duplicate-path04Proved5 theorems, 60 tests
What the Draft admission app does. A request goes in, the rules decide, and the Lean kernel has already proved what the rules promise.
The data in this figure
StepWhat happens
1. Requestpath, files, bytes, repeats
2. 11 rulesthe first that matches wins
3. Answeradmitted, path-refused, too-many-files, too-many-bytes, duplicate-path
4. Proved5 theorems, 60 tests
Fingerprint
a5c81270f90cbae8216819f3671cf3ad4aaf968cb9c344fe44a111906b60f8bc
Acceptance vectors
60
Claims
8

Verified by prismpm verify in the pinned SDK when this site was built.

The prompt

This is the whole input. Raw JSON · Open it in the builder · Download the app (.zip)

The prompt 461 lines
{
  "schema": "prism/prompt/1",
  "pattern": "decisionTable",
  "goal": "Decide if LexLean MCP takes a draft from an AI model. No file path leaves its folders, and no draft goes over the owner's limits.",
  "repository": "UOR-Foundation/lexlean-mcp",
  "app": {
    "name": "lexlean-mcp-draft-admission",
    "title": "Draft admission",
    "purpose": "Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.",
    "limits": [
      "It does not read the rows: the path field is the refusal of the first row whose path admitPath refuses, or clean.",
      "The limits are the owner values draft.max_files 256 and draft.max_bytes 8388608 of OWNER-VALUES.md."
    ],
    "fields": [
      {
        "name": "path",
        "kind": "choice",
        "values": [
          "clean",
          "non-utf8",
          "non-nfc",
          "absolute",
          "empty-component",
          "dot-component",
          "dotdot-component",
          "outside-roots",
          "non-lex-tex"
        ],
        "means": "the first row's path refusal in admitPath's order: UTF-8, NFC, relative, no empty, . or .. component, under a source root, .lex.tex suffix; clean when every row passes"
      },
      {
        "name": "files",
        "kind": "number",
        "min": 0,
        "means": "rows in the draft"
      },
      {
        "name": "bytes",
        "kind": "number",
        "min": 0,
        "means": "content bytes of all rows, not counting path bytes"
      },
      {
        "name": "repeats",
        "kind": "number",
        "min": 0,
        "means": "paths that occur more than once among the rows, compared as octets"
      }
    ],
    "outcomes": [
      "admitted",
      "path-refused",
      "too-many-files",
      "too-many-bytes",
      "duplicate-path"
    ],
    "meanings": {
      "admitted": "Verdict.Admitted: the draft reaches LexLean",
      "path-refused": "Verdict.Refused with the row's path refusal, NotUtf8 to NotLexTex",
      "too-many-files": "Verdict.Refused TooManyFiles",
      "too-many-bytes": "Verdict.Refused TooManyBytes",
      "duplicate-path": "Verdict.Refused DuplicatePath"
    },
    "rules": [
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-utf8"
          }
        ],
        "then": "path-refused",
        "why": "src/Admission.lex.tex admitPath: a path that is not UTF-8 is NotUtf8"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-nfc"
          }
        ],
        "then": "path-refused",
        "why": "Admission.admitPath: a path not in NFC under Unicode 17.0.0 is NotNfc, decided by src/Nfc.lex.tex"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "absolute"
          }
        ],
        "then": "path-refused",
        "why": "Admission.admitPath: an absolute path is AbsolutePath"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "empty-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: an empty component is EmptyComponent"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dot-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: a . component is DotComponent"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dotdot-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: a .. component is DotDotComponent (admittedPathHasNoDotDot)"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "outside-roots"
          }
        ],
        "then": "path-refused",
        "why": "Admission.rootsStage: a path under no source root is OutsideRoots"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-lex-tex"
          }
        ],
        "then": "path-refused",
        "why": "Admission.hasSuffix: a path without the .lex.tex suffix is NotLexTex"
      },
      {
        "when": [
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "too-many-files",
        "why": "Admission.filesStage: more rows than draft.max_files (OwnerValues.draftMaxFiles 256) is TooManyFiles"
      },
      {
        "when": [
          {
            "field": "bytes",
            "op": ">",
            "value": 8388608
          }
        ],
        "then": "too-many-bytes",
        "why": "Admission.bytesStage: more content bytes than draft.max_bytes (OwnerValues.draftMaxBytes 8388608) is TooManyBytes"
      },
      {
        "when": [
          {
            "field": "repeats",
            "op": ">=",
            "value": 1
          }
        ],
        "then": "duplicate-path",
        "why": "Admission.admitDraft: the duplicate scan runs last, on a draft the limits admit, and a repeated path is DuplicatePath"
      }
    ],
    "otherwise": "admitted",
    "otherwiseWhy": "Admission.admitDraft: every row's path is admitted, the draft is within both limits and no path repeats",
    "properties": [
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dotdot-component"
          }
        ],
        "then": "admitted",
        "why": "Admission.admittedPathHasNoDotDot: an admitted path has no .. component"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "outside-roots"
          }
        ],
        "then": "admitted",
        "why": "risk R5 (path escape): no path outside the source roots is admitted"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "admitted",
        "why": "Admission: an admitted draft never has more rows than max_files"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "bytes",
            "op": ">",
            "value": 8388608
          }
        ],
        "then": "admitted",
        "why": "Admission: an admitted draft never has more content bytes than max_bytes"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "clean"
          },
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "duplicate-path",
        "why": "the duplicate scan runs only on a draft the limits admit"
      }
    ],
    "examples": [
      {
        "request": "clean 3 4200 0",
        "response": "admitted"
      },
      {
        "request": "dotdot-component 3 4200 0",
        "response": "path-refused"
      },
      {
        "request": "outside-roots 1 10 0",
        "response": "path-refused"
      },
      {
        "request": "clean 257 4200 0",
        "response": "too-many-files"
      },
      {
        "request": "clean 148 8388609 0",
        "response": "too-many-bytes"
      },
      {
        "request": "clean 148 5413010 1",
        "response": "duplicate-path"
      },
      {
        "request": "non-nfc 300 9000000 2",
        "response": "path-refused"
      },
      {
        "request": "clean 256 8388608 0",
        "response": "admitted"
      },
      {
        "request": "clean 3",
        "response": "invalid"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "LLM client",
      "text": "Submits drafts of LexLean modules through the MCP tools and needs each refusal to name what to fix.",
      "concerns": [
        "Correct answers",
        "Refused malformed requests"
      ]
    },
    {
      "name": "Server owner",
      "text": "Runs LexLean MCP on loopback and needs no draft to escape the source roots or exceed the owner-set limits.",
      "concerns": [
        "No path escapes the roots",
        "Proved guarantees"
      ]
    }
  ],
  "concerns": [
    {
      "name": "No path escapes the roots",
      "text": "No admitted draft has an absolute path, a .. component or a path outside the source roots.",
      "model": "security"
    }
  ],
  "components": [
    {
      "name": "LexLean MCP gateway",
      "text": "The gateway that serves the LexLean tools over MCP and admits a draft before the engine reads it.",
      "kind": "service"
    },
    {
      "name": "LexLean engine",
      "text": "LexLean v0.4.0, which checks, snapshots, formats and builds an admitted draft.",
      "kind": "externalSystem"
    },
    {
      "name": "Draft store",
      "text": "The store of lexlean-mcp/store/1, which keeps drafts for store.draft_retention.",
      "kind": "database"
    }
  ],
  "threats": [
    {
      "name": "Path escape",
      "text": "A draft row names ../ or an absolute path to write or read outside the source roots (risk R5).",
      "stride": "elevationOfPrivilege",
      "asset": "request",
      "likelihood": "high",
      "impact": "critical",
      "control": {
        "name": "Path admission",
        "text": "Absolute paths, .. components and paths outside the roots are refused, proved for every request.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv001Holds"
          },
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv002Holds"
          },
          {
            "kind": "gate",
            "reference": "lexlean-mcp crates/nfc-oracle admitRun SM-01"
          }
        ]
      }
    },
    {
      "name": "Oversized draft",
      "text": "A draft with very many rows or bytes exhausts the engine or the store.",
      "stride": "denialOfService",
      "asset": "request",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Owner-set limits",
        "text": "More than 256 rows or 8388608 content bytes is refused before the engine sees the draft.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv003Holds"
          },
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv004Holds"
          },
          {
            "kind": "review",
            "reference": "lexlean-mcp OWNER-VALUES.md OV-03"
          }
        ]
      }
    },
    {
      "name": "Look-alike path",
      "text": "Two paths that look the same but differ in Unicode normalization name two files a reviewer reads as one.",
      "stride": "spoofing",
      "asset": "source",
      "likelihood": "low",
      "impact": "major",
      "control": {
        "name": "NFC required",
        "text": "A path not in NFC under Unicode 17.0.0 is refused, so equal-looking paths compare as equal octets.",
        "evidence": [
          {
            "kind": "gate",
            "reference": "lexlean-mcp crates/nfc-oracle NF-01 to NF-15"
          }
        ]
      }
    },
    {
      "name": "Symbolic link escape",
      "text": "A row's path is clean but resolves through a symbolic link outside the roots once materialized.",
      "stride": "elevationOfPrivilege",
      "asset": "source",
      "likelihood": "low",
      "impact": "major",
      "accepted": "The symlink clause of control K5 is pending until materialization (issue 9) builds it; path admission is pure and sees no file system."
    }
  ],
  "quality": [
    {
      "characteristic": "Security",
      "subcharacteristic": "Resistance",
      "requirement": "No escaping path admitted",
      "text": "No request whose path is absolute, has a .. component or is outside the roots is admitted.",
      "measure": "Escaping admissions",
      "measureText": "Acceptance vectors answered admitted with path absolute, dotdot-component or outside-roots.",
      "threshold": 0
    },
    {
      "characteristic": "Functional suitability",
      "subcharacteristic": "Functional correctness",
      "requirement": "Every verdict matches admitDraft",
      "text": "Each vector answers the verdict admitDraftRun gives.",
      "measure": "Vectors that disagree",
      "measureText": "Acceptance vectors whose replayed verdict differs from the expected one.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "LLM client",
      "steps": [
        "REQ-002",
        "REQ-009",
        "REQ-011",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Server owner",
      "steps": [
        "REQ-006",
        "REQ-007",
        "INV-001",
        "INV-002",
        "refuse"
      ]
    }
  ],
  "license": "MIT OR Apache-2.0",
  "axioms": {}
}

What the app claims

Each claim is a row in model/ids.toml, a scenario and a test, and a theorem the Lean kernel checks. The claims are quoted as the model states them.

Pattern

Decision table: OMG DMN 1.5, hit policy FIRST. The rules are tried in order, and the first one that matches gives the answer. If none matches, the default answer applies. This is a DMN decision table with the FIRST hit policy.

PatternStandardAnswers
Decision tableOMG DMN 1.5, hit policy FIRSTadmitted, path-refused, too-many-files, too-many-bytes, duplicate-path
Rules for each answeradmitted: 0 rules; path-refused: 8 rules; too-many-files: 1 rules; too-many-bytes: 1 rules; duplicate-path: 1 rulesadmitted0 + defaultpath-refused8too-many-files1too-many-bytes1duplicate-path1
Rules for each answer. Each bar counts the rules that give one answer. When no rule matches, the answer is admitted.
The data in this figure
rules
admitted0
path-refused8
too-many-files1
too-many-bytes1
duplicate-path1

Behavior

A request is path, files, bytes, repeats, separated by spaces. The first rule that matches decides. If none matches, the answer is admitted. A request over 112 bytes, or in any other form, is answered invalid.

Behavior 12 rows
RuleWhenAnswerWhy
REQ-001path is non-utf8path-refusedsrc/Admission.lex.tex admitPath: a path that is not UTF-8 is NotUtf8
REQ-002path is non-nfcpath-refusedAdmission.admitPath: a path not in NFC under Unicode 17.0.0 is NotNfc, decided by src/Nfc.lex.tex
REQ-003path is absolutepath-refusedAdmission.admitPath: an absolute path is AbsolutePath
REQ-004path is empty-componentpath-refusedAdmission.classifyBits: an empty component is EmptyComponent
REQ-005path is dot-componentpath-refusedAdmission.classifyBits: a . component is DotComponent
REQ-006path is dotdot-componentpath-refusedAdmission.classifyBits: a .. component is DotDotComponent (admittedPathHasNoDotDot)
REQ-007path is outside-rootspath-refusedAdmission.rootsStage: a path under no source root is OutsideRoots
REQ-008path is non-lex-texpath-refusedAdmission.hasSuffix: a path without the .lex.tex suffix is NotLexTex
REQ-009files is above 256too-many-filesAdmission.filesStage: more rows than draft.max_files (OwnerValues.draftMaxFiles 256) is TooManyFiles
REQ-010bytes is above 8388608too-many-bytesAdmission.bytesStage: more content bytes than draft.max_bytes (OwnerValues.draftMaxBytes 8388608) is TooManyBytes
REQ-011repeats is at least 1duplicate-pathAdmission.admitDraft: the duplicate scan runs last, on a draft the limits admit, and a repeated path is DuplicatePath
otherwiseno rule matchesadmittedAdmission.admitDraft: every row's path is admitted, the draft is within both limits and no path repeats

Properties Lean proves

Each property is a theorem about the same definitions the app is built from. It is proved for every request, not only the tested ones.

Properties Lean proves 5 rows
PropertyStatementTheoremWhy
INV-001It never answers admitted when path is dotdot-component.LexleanMcpDraftAdmissionProofs::inv001HoldsAdmission.admittedPathHasNoDotDot: an admitted path has no .. component
INV-002It never answers admitted when path is outside-roots.LexleanMcpDraftAdmissionProofs::inv002Holdsrisk R5 (path escape): no path outside the source roots is admitted
INV-003It never answers admitted when files is above 256.LexleanMcpDraftAdmissionProofs::inv003HoldsAdmission: an admitted draft never has more rows than max_files
INV-004It never answers admitted when bytes is above 8388608.LexleanMcpDraftAdmissionProofs::inv004HoldsAdmission: an admitted draft never has more content bytes than max_bytes
INV-005It never answers duplicate-path when path is clean and files is above 256.LexleanMcpDraftAdmissionProofs::inv005Holdsthe duplicate scan runs only on a draft the limits admit

Architecture

Stakeholders and the concerns each one views the app through (ISO/IEC/IEEE 42010).

StakeholderWho they areConcerns
LLM clientSubmits drafts of LexLean modules through the MCP tools and needs each refusal to name what to fix.Correct answers, Refused malformed requests
Server ownerRuns LexLean MCP on loopback and needs no draft to escape the source roots or exceed the owner-set limits.No path escapes the roots, Proved guarantees
VerifierAnyone who loads the holo, checks its fingerprint and replays its acceptance vectors before trusting an answer.Integrity of the published app, Refused malformed requests, Proved guarantees

Concerns

What the stakeholders care about, and the model each is viewed in.

ConcernWhat it meansModel
Correct answersEvery well-formed request is answered by the first rule that matches it, or admitted when none does, as the spec states.quality
Integrity of the published appWhat a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it.security
No path escapes the rootsNo admitted draft has an absolute path, a .. component or a path outside the source roots.security
Proved guaranteesEach of the 5 properties of the spec holds for every request, proved by the Lean kernel.quality
Refused malformed requestsA request that is not the 4 fields in order, or is longer than 112 bytes, is answered invalid and never guessed.security

Components

9 components and 13 edges between them.

ComponentKindWhat it is
BrowserexternalSystemThe visitor's web browser, which loads the page and runs the Draft admission guest.
Draft admission guestserviceThe Core-Wasm guest built from the model: it answers one request of at most 112 bytes with one answer of at most 64.
Draft admission pagestaticSiteThe page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors.
Draft storedatabaseThe store of lexlean-mcp/store/1, which keeps drafts for store.draft_retention.
GitHub PagesexternalSystemServes the page and the holo from the repository Pages workflow.
LexLean engineexternalSystemLexLean v0.4.0, which checks, snapshots, formats and builds an admitted draft.
LexLean MCP gatewayserviceThe gateway that serves the LexLean tools over MCP and admits a draft before the engine reads it.
Prism buildcliAdapterprismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector.
Source repositoryexternalSystemThe repository that holds the prompt, the model and its gate.

Design views

The SDK checks each view against the system model and draws it as OPL and PlantUML.

ViewDiagramViewpoint
Deciding a Draft admission requestopmObjectProcessLLM client: Correct answers
Components of Draft admissionumlComponentVerifier: Integrity of the published app
Answering a Draft admission requestumlSequenceLLM client: Correct answers
States of the Draft admission guestumlStateMachineLLM client: Refused malformed requests

Features and journeys

18 features. Each names the definitions that do the work and the tests that accept it. Each stakeholder has one journey.

Features and journeys 18 rows
FeatureCallsAccepted by
When path is non-utf8, the answer is path-refused.LexleanMcpDraftAdmission::rule1, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is non-nfc, the answer is path-refused.LexleanMcpDraftAdmission::rule2, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is absolute, the answer is path-refused.LexleanMcpDraftAdmission::rule3, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is empty-component, the answer is path-refused.LexleanMcpDraftAdmission::rule4, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is dot-component, the answer is path-refused.LexleanMcpDraftAdmission::rule5, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is dotdot-component, the answer is path-refused.LexleanMcpDraftAdmission::rule6, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is outside-roots, the answer is path-refused.LexleanMcpDraftAdmission::rule7, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When path is non-lex-tex, the answer is path-refused.LexleanMcpDraftAdmission::rule8, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When files is above 256, the answer is too-many-files.LexleanMcpDraftAdmission::rule9, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When bytes is above 8388608, the answer is too-many-bytes.LexleanMcpDraftAdmission::rule10, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When repeats is at least 1, the answer is duplicate-path.LexleanMcpDraftAdmission::rule11, LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
When no rule matches, the answer is admitted.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmission::application
A request that is not path, files, bytes, repeats in order, separated by single spaces, or is over 112 bytes, is answered invalid.LexleanMcpDraftAdmission::dispatch, LexleanMcpDraftAdmission::decodeField1LexleanMcpDraftAdmission::application
It never answers admitted when path is dotdot-component.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmissionProofs::inv001Holds
It never answers admitted when path is outside-roots.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmissionProofs::inv002Holds
It never answers admitted when files is above 256.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmissionProofs::inv003Holds
It never answers admitted when bytes is above 8388608.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmissionProofs::inv004Holds
It never answers duplicate-path when path is clean and files is above 256.LexleanMcpDraftAdmission::judgeLexleanMcpDraftAdmissionProofs::inv005Holds

Journeys

The ordered features each stakeholder takes.

StakeholderSteps
LLM clientREQ-002 → REQ-009 → REQ-011 → otherwise
Server ownerREQ-006 → REQ-007 → INV-001 → INV-002 → refuse
Verifierrefuse → INV-001 → INV-002 → INV-003 → INV-004 → INV-005

Security and threat model

15 threats against 4 assets. Each has a STRIDE category, and either a control with evidence or a risk that is accepted on purpose.

Security and threat model 15 rows
ThreatSTRIDEAssetRiskAnswered by
Answer that breaks INV-001repudiationAnswermedium likelihood, critical impactProof of INV-001: proof LexleanMcpDraftAdmissionProofs::inv001Holds
Answer that breaks INV-002repudiationAnswermedium likelihood, critical impactProof of INV-002: proof LexleanMcpDraftAdmissionProofs::inv002Holds
Answer that breaks INV-003repudiationAnswermedium likelihood, critical impactProof of INV-003: proof LexleanMcpDraftAdmissionProofs::inv003Holds
Answer that breaks INV-004repudiationAnswermedium likelihood, critical impactProof of INV-004: proof LexleanMcpDraftAdmissionProofs::inv004Holds
Answer that breaks INV-005repudiationAnswermedium likelihood, critical impactProof of INV-005: proof LexleanMcpDraftAdmissionProofs::inv005Holds
Granted capabilityinformationDisclosureAnswerlow likelihood, major impactNo capability granted: gate prism-code check refuses an ungranted guest import
Look-alike pathspoofingModel sourcelow likelihood, major impactNFC required: gate lexlean-mcp crates/nfc-oracle NF-01 to NF-15
Malformed requesttamperingRequest byteshigh likelihood, major impactStrict decoder: gate malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify
Oversized draftdenialOfServiceRequest bytesmedium likelihood, major impactOwner-set limits: proof LexleanMcpDraftAdmissionProofs::inv003Holds; proof LexleanMcpDraftAdmissionProofs::inv004Holds; review lexlean-mcp OWNER-VALUES.md OV-03
Oversized requestdenialOfServiceRequest bytesmedium likelihood, minor impactBounded request: gate acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify
Path escapeelevationOfPrivilegeRequest byteshigh likelihood, critical impactPath admission: proof LexleanMcpDraftAdmissionProofs::inv001Holds; proof LexleanMcpDraftAdmissionProofs::inv002Holds; gate lexlean-mcp crates/nfc-oracle admitRun SM-01
Substituted holospoofingPublished hololow likelihood, critical impactFingerprint and provenance: gate actions/attest-build-provenance in the pages workflow; gate prism-code check of the holo identities in the page
Substituted hostspoofingPublished hololow likelihood, critical impactaccepted: A page cannot defend against its own host. The holo carries signed build provenance a visitor can check, and the app can be rebuilt from its prompt.
Symbolic link escapeelevationOfPrivilegeModel sourcelow likelihood, major impactaccepted: The symlink clause of control K5 is pending until materialization (issue 9) builds it; path admission is pure and sees no file system.
Tampered modeltamperingModel sourcelow likelihood, major impactRegenerated from the prompt: gate prismpm verify in the SDK image prismpm.lock pins; review app/prompt.json

Quality

ISO/IEC 25010:2023 requirements. Each has a measure and a threshold that a theorem pins.

Quality 8 rows
RequirementCharacteristicMeasureThreshold
Bounded allocation: The guest allocates at most 224 bytes for one request.Performance efficiency: Resource utilizationGuest allocation bytes224
Bounded request: A request over 112 bytes is refused before any field is read.Performance efficiency: Time behaviourRequest bytes read112
Every property proved: All 5 properties are theorems the Lean kernel checks.Security: IntegrityUnproved properties0
Every request answered: Every request gets an answer: a rule, admitted otherwise, or invalid.Functional suitability: Functional completenessUnanswered requests0
Every vector replays: All 60 acceptance vectors replay in the compiled guest, the shortest 0 bytes long.Reliability: FaultlessnessFailed vectors0
Every verdict matches admitDraft: Each vector answers the verdict admitDraftRun gives.Functional suitability: Functional correctnessVectors that disagree0
Examples answered as stated: Every one of the 9 examples of the spec is answered as it states.Functional suitability: Functional correctnessExample mismatches0
No escaping path admitted: No request whose path is absolute, has a .. component or is outside the roots is admitted.Security: ResistanceEscaping admissions0

Compliance

One obligation per standard, each naming its evidence.

StandardSubjectEvidence
ISO/IEC/IEEE 42010:2022Architecture descriptionArchitecture::architectureDescriptionHolds
ISO/PAS 19450:2015 and OMG UML 2.5.1Design viewsDesign::viewOpmDecide, Design::viewUmlComponents, Design::viewUmlRequest, Design::viewUmlStates
ISO/IEC 25010:2023Product qualityQuality::qualityModelHolds
ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022Application security and riskSecurity::controlSet
OMG DMN 1.5, hit policy FIRSTDecision tableLexleanMcpDraftAdmission::judge
OpenSpecRequirementsLexleanMcpDraftAdmission::application
SPDX MIT OR Apache-2.0LicensingLexleanMcpDraftAdmission::application

Rendered design views

Written by the SDK from the design records when it verified the app.

design/Design.viewOpmDecide.opl
View: Design::viewOpmDecide
Title: Deciding a Draft admission request
Viewpoint: Architecture::viewpointLLMClientCorrectAnswers
Notation: ISO/PAS 19450:2015 OPM, Prism OPL profile

componentBrowser is an object.
componentDraftAdmissionGuest is an object.
componentDraftAdmissionGuest can be stateDeciding or stateIdle.
processDecide is a process.
processEncodeAnswer is a process.
processJudge is a process.
processParseRequest is a process.
componentDraftAdmissionGuest handles processDecide.
processParseRequest requires componentBrowser.
processEncodeAnswer affects componentBrowser.
processJudge invokes processEncodeAnswer.
processParseRequest invokes processJudge.
processDecide zooms into processParseRequest, processJudge, and processEncodeAnswer, in that sequence.
design/Design.viewUmlComponents.puml
@startuml
' UML 2.5.1 component diagram
' view: Design::viewUmlComponents
' viewpoint: Architecture::viewpointVerifierIntegrityOfThePublishedApp
title Components of Draft admission
component "componentBrowser" as c0
component "componentDraftAdmissionGuest" as c1
component "componentDraftAdmissionPage" as c2
component "componentDraftStore" as c3
component "componentGitHubPages" as c4
component "componentLexLeanEngine" as c5
component "componentLexLeanMCPGateway" as c6
component "componentPrismBuild" as c7
component "componentSourceRepository" as c8
c0 --> c1 : edgeBrowserToDraftAdmissionGuest
c1 --> c0 : edgeDraftAdmissionGuestToBrowser
c1 --> c3 : edgeDraftAdmissionGuestToDraftStore
c1 --> c5 : edgeDraftAdmissionGuestToLexLeanEngine
c1 --> c6 : edgeDraftAdmissionGuestToLexLeanMCPGateway
c2 --> c4 : edgeDraftAdmissionPageToGitHubPages
c3 --> c1 : edgeDraftStoreToDraftAdmissionGuest
c4 --> c0 : edgeGitHubPagesToBrowser
c5 --> c1 : edgeLexLeanEngineToDraftAdmissionGuest
c6 --> c1 : edgeLexLeanMCPGatewayToDraftAdmissionGuest
c7 --> c1 : edgePrismBuildToDraftAdmissionGuest
c7 --> c2 : edgePrismBuildToDraftAdmissionPage
c8 --> c7 : edgeSourceRepositoryToPrismBuild
@enduml
design/Design.viewUmlRequest.puml
@startuml
' UML 2.5.1 sequence diagram
' view: Design::viewUmlRequest
' viewpoint: Architecture::viewpointLLMClientCorrectAnswers
title Answering a Draft admission request
participant "componentBrowser" as p0
participant "componentDraftAdmissionGuest" as p1
p0 -> p1 : processDecide
p1 --> p0 : processDecide
@enduml
design/Design.viewUmlStates.puml
@startuml
' UML 2.5.1 state machine diagram
' view: Design::viewUmlStates
' viewpoint: Architecture::viewpointLLMClientRefusedMalformedRequests
title States of the Draft admission guest
state "stateAnsweredAdmitted" as s0
state "stateAnsweredDuplicatePath" as s1
state "stateAnsweredPathRefused" as s2
state "stateAnsweredTooManyBytes" as s3
state "stateAnsweredTooManyFiles" as s4
state "stateDeciding" as s5
state "stateIdle" as s6
state "stateRefused" as s7
[*] --> s6
s6 --> s5 : processParseRequest
s6 --> s7 : processParseRequest
s5 --> s2 : processRule1
s5 --> s2 : processRule2
s5 --> s2 : processRule3
s5 --> s2 : processRule4
s5 --> s2 : processRule5
s5 --> s2 : processRule6
s5 --> s2 : processRule7
s5 --> s2 : processRule8
s5 --> s4 : processRule9
s5 --> s3 : processRule10
s5 --> s1 : processRule11
s5 --> s0 : processOtherwise
s0 --> s6 : processEncodeAnswer
s2 --> s6 : processEncodeAnswer
s4 --> s6 : processEncodeAnswer
s3 --> s6 : processEncodeAnswer
s1 --> s6 : processEncodeAnswer
s7 --> s6 : processEncodeAnswer
@enduml

Prism source

Every file the builder wrote, laid out as a repository created from UOR-Foundation/template. The language packages and Foundation modules every app shares are in the download.

app/src/Architecture.lex.tex 434 lines
\begin{lexlean}{Architecture}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Foundation.Arch}
\title{architectural component}
\begin{semanticmodule}
definition{
  name: standardIso25010,
  parameters: [],
  result: Foundation.Arch::StandardReference,
  body: (record Foundation.Arch::StandardReference {standardIndex := 0, editionIndex := 0, standardId := "ISO-25010-2023", edition := "2023"})
}

definition{
  name: standardIso27005,
  parameters: [],
  result: Foundation.Arch::StandardReference,
  body: (record Foundation.Arch::StandardReference {standardIndex := 1, editionIndex := 0, standardId := "ISO-27005-2022", edition := "2022"})
}

definition{
  name: standardIso27034,
  parameters: [],
  result: Foundation.Arch::StandardReference,
  body: (record Foundation.Arch::StandardReference {standardIndex := 2, editionIndex := 0, standardId := "ISO-27034-1-2011", edition := "2011"})
}

definition{
  name: standardIso42010,
  parameters: [],
  result: Foundation.Arch::StandardReference,
  body: (record Foundation.Arch::StandardReference {standardIndex := 4, editionIndex := 0, standardId := "ISO-42010-2022", edition := "2022"})
}

definition{
  name: stakeholderLLMClient,
  parameters: [],
  result: Foundation.Arch::Stakeholder,
  body: (record Foundation.Arch::Stakeholder {index := 0, name := "LLM client", text := "Submits drafts of LexLean modules through the MCP tools and needs each refusal to name what to fix."})
}

definition{
  name: stakeholderServerOwner,
  parameters: [],
  result: Foundation.Arch::Stakeholder,
  body: (record Foundation.Arch::Stakeholder {index := 1, name := "Server owner", text := "Runs LexLean MCP on loopback and needs no draft to escape the source roots or exceed the owner-set limits."})
}

definition{
  name: stakeholderVerifier,
  parameters: [],
  result: Foundation.Arch::Stakeholder,
  body: (record Foundation.Arch::Stakeholder {index := 2, name := "Verifier", text := "Anyone who loads the holo, checks its fingerprint and replays its acceptance vectors before trusting an answer."})
}

definition{
  name: concernCorrectAnswers,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 0, name := "Correct answers", text := "Every well-formed request is answered by the first rule that matches it, or admitted when none does, as the spec states."})
}

definition{
  name: concernIntegrityOfThePublishedApp,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 1, name := "Integrity of the published app", text := "What a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it."})
}

definition{
  name: concernNoPathEscapesTheRoots,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 2, name := "No path escapes the roots", text := "No admitted draft has an absolute path, a .. component or a path outside the source roots."})
}

definition{
  name: concernProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 3, name := "Proved guarantees", text := "Each of the 5 properties of the spec holds for every request, proved by the Lean kernel."})
}

definition{
  name: concernRefusedMalformedRequests,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 4, name := "Refused malformed requests", text := "A request that is not the 4 fields in order, or is longer than 112 bytes, is answered invalid and never guessed."})
}

definition{
  name: componentBrowser,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 0, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Browser", text := "The visitor's web browser, which loads the page and runs the Draft admission guest."})
}

definition{
  name: componentDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 1, kind := (ctor Foundation.Arch::ComponentKind.service), name := "Draft admission guest", text := "The Core-Wasm guest built from the model: it answers one request of at most 112 bytes with one answer of at most 64."})
}

definition{
  name: componentDraftAdmissionPage,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 2, kind := (ctor Foundation.Arch::ComponentKind.staticSite), name := "Draft admission page", text := "The page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors."})
}

definition{
  name: componentDraftStore,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 3, kind := (ctor Foundation.Arch::ComponentKind.database), name := "Draft store", text := "The store of lexlean-mcp/store/1, which keeps drafts for store.draft_retention."})
}

definition{
  name: componentGitHubPages,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 4, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "GitHub Pages", text := "Serves the page and the holo from the repository Pages workflow."})
}

definition{
  name: componentLexLeanEngine,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 5, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "LexLean engine", text := "LexLean v0.4.0, which checks, snapshots, formats and builds an admitted draft."})
}

definition{
  name: componentLexLeanMCPGateway,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 6, kind := (ctor Foundation.Arch::ComponentKind.service), name := "LexLean MCP gateway", text := "The gateway that serves the LexLean tools over MCP and admits a draft before the engine reads it."})
}

definition{
  name: componentPrismBuild,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 7, kind := (ctor Foundation.Arch::ComponentKind.cliAdapter), name := "Prism build", text := "prismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector."})
}

definition{
  name: componentSourceRepository,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 8, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Source repository", text := "The repository that holds the prompt, the model and its gate."})
}

definition{
  name: edgeBrowserToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 0, fromIndex := 0, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftAdmissionGuestToBrowser,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 1, fromIndex := 1, toIndex := 0, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftAdmissionGuestToDraftStore,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 2, fromIndex := 1, toIndex := 3, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftAdmissionGuestToLexLeanEngine,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 3, fromIndex := 1, toIndex := 5, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftAdmissionGuestToLexLeanMCPGateway,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 4, fromIndex := 1, toIndex := 6, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftAdmissionPageToGitHubPages,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 5, fromIndex := 2, toIndex := 4, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeDraftStoreToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 6, fromIndex := 3, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeGitHubPagesToBrowser,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 7, fromIndex := 4, toIndex := 0, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeLexLeanEngineToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 8, fromIndex := 5, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeLexLeanMCPGatewayToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 9, fromIndex := 6, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgePrismBuildToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 10, fromIndex := 7, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgePrismBuildToDraftAdmissionPage,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 11, fromIndex := 7, toIndex := 2, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: edgeSourceRepositoryToPrismBuild,
  parameters: [],
  result: Foundation.Arch::Edge,
  body: (record Foundation.Arch::Edge {index := 12, fromIndex := 8, toIndex := 7, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}

definition{
  name: viewpointLLMClientCorrectAnswers,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 0, stakeholderIndex := 0, concernIndex := 0, modelKindIndex := 1})
}

definition{
  name: viewpointLLMClientRefusedMalformedRequests,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 1, stakeholderIndex := 0, concernIndex := 4, modelKindIndex := 2})
}

definition{
  name: viewpointServerOwnerNoPathEscapesTheRoots,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 2, stakeholderIndex := 1, concernIndex := 2, modelKindIndex := 2})
}

definition{
  name: viewpointServerOwnerProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 3, stakeholderIndex := 1, concernIndex := 3, modelKindIndex := 1})
}

definition{
  name: viewpointVerifierIntegrityOfThePublishedApp,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 4, stakeholderIndex := 2, concernIndex := 1, modelKindIndex := 2})
}

definition{
  name: viewpointVerifierProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 5, stakeholderIndex := 2, concernIndex := 3, modelKindIndex := 1})
}

definition{
  name: viewpointVerifierRefusedMalformedRequests,
  parameters: [],
  result: Foundation.Arch::Viewpoint,
  body: (record Foundation.Arch::Viewpoint {index := 6, stakeholderIndex := 2, concernIndex := 4, modelKindIndex := 2})
}

definition{
  name: viewLLMClientCorrectAnswers,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 0, viewpointIndex := 0, modelKindIndex := 1})
}

definition{
  name: viewLLMClientRefusedMalformedRequests,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 1, viewpointIndex := 1, modelKindIndex := 2})
}

definition{
  name: viewServerOwnerNoPathEscapesTheRoots,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 2, viewpointIndex := 2, modelKindIndex := 2})
}

definition{
  name: viewServerOwnerProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 3, viewpointIndex := 3, modelKindIndex := 1})
}

definition{
  name: viewVerifierIntegrityOfThePublishedApp,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 4, viewpointIndex := 4, modelKindIndex := 2})
}

definition{
  name: viewVerifierProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 5, viewpointIndex := 5, modelKindIndex := 1})
}

definition{
  name: viewVerifierRefusedMalformedRequests,
  parameters: [],
  result: Foundation.Arch::View,
  body: (record Foundation.Arch::View {index := 6, viewpointIndex := 6, modelKindIndex := 2})
}

definition{
  name: componentRecords,
  parameters: [],
  result: (List Foundation.Arch::Component),
  body: (cons (componentBrowser) (cons (componentDraftAdmissionGuest) (cons (componentDraftAdmissionPage) (cons (componentDraftStore) (cons (componentGitHubPages) (cons (componentLexLeanEngine) (cons (componentLexLeanMCPGateway) (cons (componentPrismBuild) (cons (componentSourceRepository) (nil Foundation.Arch::Component))))))))))
}

definition{
  name: edgeRecords,
  parameters: [],
  result: (List Foundation.Arch::Edge),
  body: (cons (edgeBrowserToDraftAdmissionGuest) (cons (edgeDraftAdmissionGuestToBrowser) (cons (edgeDraftAdmissionGuestToDraftStore) (cons (edgeDraftAdmissionGuestToLexLeanEngine) (cons (edgeDraftAdmissionGuestToLexLeanMCPGateway) (cons (edgeDraftAdmissionPageToGitHubPages) (cons (edgeDraftStoreToDraftAdmissionGuest) (cons (edgeGitHubPagesToBrowser) (cons (edgeLexLeanEngineToDraftAdmissionGuest) (cons (edgeLexLeanMCPGatewayToDraftAdmissionGuest) (cons (edgePrismBuildToDraftAdmissionGuest) (cons (edgePrismBuildToDraftAdmissionPage) (cons (edgeSourceRepositoryToPrismBuild) (nil Foundation.Arch::Edge))))))))))))))
}

definition{
  name: viewpointRecords,
  parameters: [],
  result: (List Foundation.Arch::Viewpoint),
  body: (cons (viewpointLLMClientCorrectAnswers) (cons (viewpointLLMClientRefusedMalformedRequests) (cons (viewpointServerOwnerNoPathEscapesTheRoots) (cons (viewpointServerOwnerProvedGuarantees) (cons (viewpointVerifierIntegrityOfThePublishedApp) (cons (viewpointVerifierProvedGuarantees) (cons (viewpointVerifierRefusedMalformedRequests) (nil Foundation.Arch::Viewpoint))))))))
}

definition{
  name: viewRecords,
  parameters: [],
  result: (List Foundation.Arch::View),
  body: (cons (viewLLMClientCorrectAnswers) (cons (viewLLMClientRefusedMalformedRequests) (cons (viewServerOwnerNoPathEscapesTheRoots) (cons (viewServerOwnerProvedGuarantees) (cons (viewVerifierIntegrityOfThePublishedApp) (cons (viewVerifierProvedGuarantees) (cons (viewVerifierRefusedMalformedRequests) (nil Foundation.Arch::View))))))))
}

definition{
  name: edgesKnown,
  parameters: [count : Nat, records : (List Foundation.Arch::Edge)],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons edge rest => (((project edge fromIndex) <? count) && (((project edge toIndex) <? count) && (edgesKnown count rest)))),
  recursive_argument: records
}

definition{
  name: viewpointsKnown,
  parameters: [
    stakeholderCount : Nat,
    concernCount : Nat,
    records : (List Foundation.Arch::Viewpoint)
  ],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons viewpoint rest => (((project viewpoint stakeholderIndex) <? stakeholderCount) && (((project viewpoint concernIndex) <? concernCount) && (((project viewpoint modelKindIndex) <? 3) && (viewpointsKnown stakeholderCount concernCount rest))))),
  recursive_argument: records
}

definition{
  name: viewMatches,
  parameters: [view : Foundation.Arch::View, viewpoints : (List Foundation.Arch::Viewpoint)],
  result: Bool,
  body: (match viewpoints
    | List.nil => false
    | List.cons viewpoint rest => ((((project viewpoint index) =? (project view viewpointIndex)) && ((project viewpoint modelKindIndex) =? (project view modelKindIndex))) || (viewMatches view rest))),
  recursive_argument: viewpoints
}

definition{
  name: viewsConform,
  parameters: [
    viewpoints : (List Foundation.Arch::Viewpoint),
    records : (List Foundation.Arch::View)
  ],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons view rest => ((viewMatches view viewpoints) && (viewsConform viewpoints rest))),
  recursive_argument: records
}

definition{
  name: architectureValid,
  parameters: [],
  result: Bool,
  body: ((edgesKnown 9 (edgeRecords)) && ((viewpointsKnown 3 5 (viewpointRecords)) && (viewsConform (viewpointRecords) (viewRecords))))
}

theorem{
  name: architectureDescriptionHolds,
  parameters: [],
  statement: ((architectureValid) = true),
  proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Compliance.lex.tex 56 lines
\begin{lexlean}{Compliance}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Architecture}
\importmodule{Design}
\importmodule{Quality}
\importmodule{Security}
\importmodule{LexleanMcpDraftAdmission}
\title{standards reference}
\begin{semanticmodule}
structure{
  name: Obligation,
  type_parameters: [],
  parameters: [],
  fields: [
    {name: index, type: Nat},
    {name: standard, type: String},
    {name: subject, type: String},
    {name: text, type: String},
    {name: evidence, type: (List String)}
  ]
}

definition{
  name: obligations,
  parameters: [],
  result: (List Obligation),
  body: (cons (record Obligation {index := 0, standard := "ISO/IEC/IEEE 42010:2022", subject := "Architecture description", text := "Stakeholders, concerns, viewpoints and views are declared and their references resolve.", evidence := (cons "Architecture::architectureDescriptionHolds" (nil String))}) (cons (record Obligation {index := 1, standard := "ISO/PAS 19450:2015 and OMG UML 2.5.1", subject := "Design views", text := "Every design view is checked by the SDK against the system model before it is rendered.", evidence := (cons "Design::viewOpmDecide" (cons "Design::viewUmlComponents" (cons "Design::viewUmlRequest" (cons "Design::viewUmlStates" (nil String)))))}) (cons (record Obligation {index := 2, standard := "ISO/IEC 25010:2023", subject := "Product quality", text := "Characteristics, subcharacteristics, requirements and measures are numbered and their parents resolve.", evidence := (cons "Quality::qualityModelHolds" (nil String))}) (cons (record Obligation {index := 3, standard := "ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022", subject := "Application security and risk", text := "Every threat has a STRIDE category and a mapped control with evidence, or an accepted risk with its rationale.", evidence := (cons "Security::controlSet" (nil String))}) (cons (record Obligation {index := 4, standard := "OMG DMN 1.5, hit policy FIRST", subject := "Decision table", text := "The 11 rules are tried in order and the first that matches gives the answer; otherwise admitted.", evidence := (cons "LexleanMcpDraftAdmission::judge" (nil String))}) (cons (record Obligation {index := 5, standard := "OpenSpec", subject := "Requirements", text := "Every rule and property of the spec is a requirement with a scenario in openspec/specs.", evidence := (cons "LexleanMcpDraftAdmission::application" (nil String))}) (cons (record Obligation {index := 6, standard := "SPDX MIT OR Apache-2.0", subject := "Licensing", text := "The application and its model are offered under MIT OR Apache-2.0.", evidence := (cons "LexleanMcpDraftAdmission::application" (nil String))}) (nil Obligation))))))))
}

definition{
  name: obligationsEvidenced,
  parameters: [position : Nat, items : (List Obligation)],
  result: Bool,
  body: (match items
    | List.nil => true
    | List.cons item rest => (((project item index) =? position) && (match{
      branches: [
        {body: false, binders: [], constructor: List.nil},
        {body: true, binders: [first, others], constructor: List.cons}
      ],
      scrutinee: (project item evidence)
    } && (obligationsEvidenced (position + 1) rest)))),
  recursive_argument: items
}

theorem{
  name: everyObligationEvidenced,
  parameters: [],
  statement: ((obligationsEvidenced 0 (obligations)) = true),
  proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Design.lex.tex 710 lines
\begin{lexlean}{Design}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Architecture}
\importmodule{Foundation.Arch}
\title{design view}
\begin{semanticmodule}
definition{
  name: processSendRequest,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentBrowser"})
}

definition{
  name: processDecide,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processParseRequest,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processJudge,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processEncodeAnswer,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processBuildAndVerify,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentPrismBuild"})
}

definition{
  name: processRule1,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule2,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule3,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule4,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule5,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule6,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule7,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule8,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule9,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule10,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processRule11,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: processOtherwise,
  parameters: [],
  result: Foundation.Arch::SystemProcess,
  body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateIdle,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateDeciding,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateRefused,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateAnsweredAdmitted,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateAnsweredPathRefused,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateAnsweredTooManyFiles,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateAnsweredTooManyBytes,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: stateAnsweredDuplicatePath,
  parameters: [],
  result: Foundation.Arch::SystemState,
  body: (record Foundation.Arch::SystemState {owner := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: viewOpmDecide,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "Deciding a Draft admission request", viewpoint := "Architecture::viewpointLLMClientCorrectAnswers", diagram := (ctor Foundation.Arch::DesignDiagram.opmObjectProcess)})
}

definition{
  name: viewUmlComponents,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "Components of Draft admission", viewpoint := "Architecture::viewpointVerifierIntegrityOfThePublishedApp", diagram := (ctor Foundation.Arch::DesignDiagram.umlComponent)})
}

definition{
  name: viewUmlRequest,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "Answering a Draft admission request", viewpoint := "Architecture::viewpointLLMClientCorrectAnswers", diagram := (ctor Foundation.Arch::DesignDiagram.umlSequence)})
}

definition{
  name: viewUmlStates,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "States of the Draft admission guest", viewpoint := "Architecture::viewpointLLMClientRefusedMalformedRequests", diagram := (ctor Foundation.Arch::DesignDiagram.umlStateMachine)})
}

definition{
  name: opmBrowser,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.object), subject := "Architecture::componentBrowser"})
}

definition{
  name: opmGuest,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.object), subject := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: opmDecide,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processDecide"})
}

definition{
  name: opmParseRequest,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processParseRequest"})
}

definition{
  name: opmJudge,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processJudge"})
}

definition{
  name: opmEncodeAnswer,
  parameters: [],
  result: Foundation.Arch::OpmThing,
  body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processEncodeAnswer"})
}

definition{
  name: opmGuestIdle,
  parameters: [],
  result: Foundation.Arch::OpmState,
  body: (record Foundation.Arch::OpmState {view := "Design::viewOpmDecide", thing := "Architecture::componentDraftAdmissionGuest", state := "Design::stateIdle"})
}

definition{
  name: opmGuestDeciding,
  parameters: [],
  result: Foundation.Arch::OpmState,
  body: (record Foundation.Arch::OpmState {view := "Design::viewOpmDecide", thing := "Architecture::componentDraftAdmissionGuest", state := "Design::stateDeciding"})
}

definition{
  name: opmGuestAgent,
  parameters: [],
  result: Foundation.Arch::OpmLink,
  body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.agent), source := "Architecture::componentDraftAdmissionGuest", target := "Design::processDecide"})
}

definition{
  name: opmBrowserInstrument,
  parameters: [],
  result: Foundation.Arch::OpmLink,
  body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.instrument), source := "Architecture::componentBrowser", target := "Design::processParseRequest"})
}

definition{
  name: opmParseInvokesJudge,
  parameters: [],
  result: Foundation.Arch::OpmLink,
  body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.invocation), source := "Design::processParseRequest", target := "Design::processJudge"})
}

definition{
  name: opmJudgeInvokesEncode,
  parameters: [],
  result: Foundation.Arch::OpmLink,
  body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.invocation), source := "Design::processJudge", target := "Design::processEncodeAnswer"})
}

definition{
  name: opmEncodeAffectsBrowser,
  parameters: [],
  result: Foundation.Arch::OpmLink,
  body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.effect), source := "Architecture::componentBrowser", target := "Design::processEncodeAnswer"})
}

definition{
  name: opmZoomParseRequest,
  parameters: [],
  result: Foundation.Arch::OpmZoom,
  body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processParseRequest", order := 0})
}

definition{
  name: opmZoomJudge,
  parameters: [],
  result: Foundation.Arch::OpmZoom,
  body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processJudge", order := 1})
}

definition{
  name: opmZoomEncodeAnswer,
  parameters: [],
  result: Foundation.Arch::OpmZoom,
  body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processEncodeAnswer", order := 2})
}

definition{
  name: umlBrowser,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentBrowser"})
}

definition{
  name: umlDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentDraftAdmissionGuest"})
}

definition{
  name: umlDraftAdmissionPage,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentDraftAdmissionPage"})
}

definition{
  name: umlDraftStore,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentDraftStore"})
}

definition{
  name: umlGitHubPages,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentGitHubPages"})
}

definition{
  name: umlLexLeanEngine,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentLexLeanEngine"})
}

definition{
  name: umlLexLeanMCPGateway,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentLexLeanMCPGateway"})
}

definition{
  name: umlPrismBuild,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentPrismBuild"})
}

definition{
  name: umlSourceRepository,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentSourceRepository"})
}

definition{
  name: umlBrowserToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeBrowserToDraftAdmissionGuest"})
}

definition{
  name: umlDraftAdmissionGuestToBrowser,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftAdmissionGuestToBrowser"})
}

definition{
  name: umlDraftAdmissionGuestToDraftStore,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftAdmissionGuestToDraftStore"})
}

definition{
  name: umlDraftAdmissionGuestToLexLeanEngine,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftAdmissionGuestToLexLeanEngine"})
}

definition{
  name: umlDraftAdmissionGuestToLexLeanMCPGateway,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftAdmissionGuestToLexLeanMCPGateway"})
}

definition{
  name: umlDraftAdmissionPageToGitHubPages,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftAdmissionPageToGitHubPages"})
}

definition{
  name: umlDraftStoreToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeDraftStoreToDraftAdmissionGuest"})
}

definition{
  name: umlGitHubPagesToBrowser,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeGitHubPagesToBrowser"})
}

definition{
  name: umlLexLeanEngineToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeLexLeanEngineToDraftAdmissionGuest"})
}

definition{
  name: umlLexLeanMCPGatewayToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeLexLeanMCPGatewayToDraftAdmissionGuest"})
}

definition{
  name: umlPrismBuildToDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgePrismBuildToDraftAdmissionGuest"})
}

definition{
  name: umlPrismBuildToDraftAdmissionPage,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgePrismBuildToDraftAdmissionPage"})
}

definition{
  name: umlSourceRepositoryToPrismBuild,
  parameters: [],
  result: Foundation.Arch::UmlConnector,
  body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeSourceRepositoryToPrismBuild"})
}

definition{
  name: seqBrowser,
  parameters: [],
  result: Foundation.Arch::UmlLifeline,
  body: (record Foundation.Arch::UmlLifeline {view := "Design::viewUmlRequest", component := "Architecture::componentBrowser", order := 0})
}

definition{
  name: seqDraftAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlLifeline,
  body: (record Foundation.Arch::UmlLifeline {view := "Design::viewUmlRequest", component := "Architecture::componentDraftAdmissionGuest", order := 1})
}

definition{
  name: seqRequest,
  parameters: [],
  result: Foundation.Arch::UmlMessage,
  body: (record Foundation.Arch::UmlMessage {view := "Design::viewUmlRequest", kind := (ctor Foundation.Arch::UmlMessageKind.synchronous), order := 0, source := "Architecture::componentBrowser", target := "Architecture::componentDraftAdmissionGuest", process := "Design::processDecide"})
}

definition{
  name: seqReply,
  parameters: [],
  result: Foundation.Arch::UmlMessage,
  body: (record Foundation.Arch::UmlMessage {view := "Design::viewUmlRequest", kind := (ctor Foundation.Arch::UmlMessageKind.reply), order := 1, source := "Architecture::componentDraftAdmissionGuest", target := "Architecture::componentBrowser", process := "Design::processDecide"})
}

definition{
  name: stIdle,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateIdle", initial := true})
}

definition{
  name: stDeciding,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateDeciding", initial := false})
}

definition{
  name: stRefused,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateRefused", initial := false})
}

definition{
  name: stAnsweredAdmitted,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredAdmitted", initial := false})
}

definition{
  name: stAnsweredPathRefused,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredPathRefused", initial := false})
}

definition{
  name: stAnsweredTooManyFiles,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredTooManyFiles", initial := false})
}

definition{
  name: stAnsweredTooManyBytes,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredTooManyBytes", initial := false})
}

definition{
  name: stAnsweredDuplicatePath,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredDuplicatePath", initial := false})
}

definition{
  name: trAccept,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 0, source := "Design::stateIdle", target := "Design::stateDeciding", trigger := "Design::processParseRequest"})
}

definition{
  name: trRefuse,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 1, source := "Design::stateIdle", target := "Design::stateRefused", trigger := "Design::processParseRequest"})
}

definition{
  name: trRule1,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 2, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule1"})
}

definition{
  name: trRule2,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 3, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule2"})
}

definition{
  name: trRule3,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 4, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule3"})
}

definition{
  name: trRule4,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 5, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule4"})
}

definition{
  name: trRule5,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 6, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule5"})
}

definition{
  name: trRule6,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 7, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule6"})
}

definition{
  name: trRule7,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 8, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule7"})
}

definition{
  name: trRule8,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 9, source := "Design::stateDeciding", target := "Design::stateAnsweredPathRefused", trigger := "Design::processRule8"})
}

definition{
  name: trRule9,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 10, source := "Design::stateDeciding", target := "Design::stateAnsweredTooManyFiles", trigger := "Design::processRule9"})
}

definition{
  name: trRule10,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 11, source := "Design::stateDeciding", target := "Design::stateAnsweredTooManyBytes", trigger := "Design::processRule10"})
}

definition{
  name: trRule11,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 12, source := "Design::stateDeciding", target := "Design::stateAnsweredDuplicatePath", trigger := "Design::processRule11"})
}

definition{
  name: trOtherwise,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 13, source := "Design::stateDeciding", target := "Design::stateAnsweredAdmitted", trigger := "Design::processOtherwise"})
}

definition{
  name: trResetAdmitted,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 14, source := "Design::stateAnsweredAdmitted", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}

definition{
  name: trResetPathRefused,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 15, source := "Design::stateAnsweredPathRefused", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}

definition{
  name: trResetTooManyFiles,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 16, source := "Design::stateAnsweredTooManyFiles", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}

definition{
  name: trResetTooManyBytes,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 17, source := "Design::stateAnsweredTooManyBytes", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}

definition{
  name: trResetDuplicatePath,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 18, source := "Design::stateAnsweredDuplicatePath", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}

definition{
  name: trResetRefused,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 19, source := "Design::stateRefused", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
\end{semanticmodule}
\end{lexlean}
app/src/Features.lex.tex 193 lines
\begin{lexlean}{Features}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{LexleanMcpDraftAdmission}
\importmodule{Architecture}
\importmodule{Foundation.Arch}
\title{feature}
\begin{semanticmodule}
definition{
  name: acceptINV001,
  parameters: [],
  result: String,
  body: "LexleanMcpDraftAdmissionProofs::inv001Holds"
}

definition{
  name: acceptINV002,
  parameters: [],
  result: String,
  body: "LexleanMcpDraftAdmissionProofs::inv002Holds"
}

definition{
  name: acceptINV003,
  parameters: [],
  result: String,
  body: "LexleanMcpDraftAdmissionProofs::inv003Holds"
}

definition{
  name: acceptINV004,
  parameters: [],
  result: String,
  body: "LexleanMcpDraftAdmissionProofs::inv004Holds"
}

definition{
  name: acceptINV005,
  parameters: [],
  result: String,
  body: "LexleanMcpDraftAdmissionProofs::inv005Holds"
}

definition{
  name: featureRule1,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is non-utf8, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule1" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule2,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is non-nfc, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule2" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule3,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is absolute, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule3" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule4,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is empty-component, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule4" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule5,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is dot-component, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule5" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule6,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is dotdot-component, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule6" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule7,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is outside-roots, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule7" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule8,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When path is non-lex-tex, the answer is path-refused.", calls := (cons "LexleanMcpDraftAdmission::rule8" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule9,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When files is above 256, the answer is too-many-files.", calls := (cons "LexleanMcpDraftAdmission::rule9" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule10,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When bytes is above 8388608, the answer is too-many-bytes.", calls := (cons "LexleanMcpDraftAdmission::rule10" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRule11,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When repeats is at least 1, the answer is duplicate-path.", calls := (cons "LexleanMcpDraftAdmission::rule11" (cons "LexleanMcpDraftAdmission::judge" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureOtherwise,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When no rule matches, the answer is admitted.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureRefuseMalformed,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "A request that is not path, files, bytes, repeats in order, separated by single spaces, or is over 112 bytes, is answered invalid.", calls := (cons "LexleanMcpDraftAdmission::dispatch" (cons "LexleanMcpDraftAdmission::decodeField1" (nil String))), acceptance := (cons "LexleanMcpDraftAdmission::application" (nil String))})
}

definition{
  name: featureINV001,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It never answers admitted when path is dotdot-component.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV001" (nil String))})
}

definition{
  name: featureINV002,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It never answers admitted when path is outside-roots.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV002" (nil String))})
}

definition{
  name: featureINV003,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It never answers admitted when files is above 256.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV003" (nil String))})
}

definition{
  name: featureINV004,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It never answers admitted when bytes is above 8388608.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV004" (nil String))})
}

definition{
  name: featureINV005,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It never answers duplicate-path when path is clean and files is above 256.", calls := (cons "LexleanMcpDraftAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV005" (nil String))})
}

definition{
  name: journeyLLMClient,
  parameters: [],
  result: Foundation.Arch::Journey,
  body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderLLMClient", steps := (cons "Features::featureRule2" (cons "Features::featureRule9" (cons "Features::featureRule11" (cons "Features::featureOtherwise" (nil String)))))})
}

definition{
  name: journeyServerOwner,
  parameters: [],
  result: Foundation.Arch::Journey,
  body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderServerOwner", steps := (cons "Features::featureRule6" (cons "Features::featureRule7" (cons "Features::featureINV001" (cons "Features::featureINV002" (cons "Features::featureRefuseMalformed" (nil String))))))})
}

definition{
  name: journeyVerifier,
  parameters: [],
  result: Foundation.Arch::Journey,
  body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderVerifier", steps := (cons "Features::featureRefuseMalformed" (cons "Features::featureINV001" (cons "Features::featureINV002" (cons "Features::featureINV003" (cons "Features::featureINV004" (cons "Features::featureINV005" (nil String)))))))})
}
\end{semanticmodule}
\end{lexlean}
app/src/Quality.lex.tex 375 lines
\begin{lexlean}{Quality}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\useglossary{prism.qual@1.0.0}
\importmodule{Foundation.Qual}
\title{quality measure}
\begin{semanticmodule}
structure{
  name: Named,
  type_parameters: [],
  parameters: [],
  fields: [{name: index, type: Nat}, {name: name, type: String}, {name: text, type: String}]
}

definition{
  name: characteristicFunctionalSuitability,
  parameters: [],
  result: Foundation.Qual::ProductQualityCharacteristic,
  body: (record Foundation.Qual::ProductQualityCharacteristic {index := 0})
}

definition{
  name: characteristicPerformanceEfficiency,
  parameters: [],
  result: Foundation.Qual::ProductQualityCharacteristic,
  body: (record Foundation.Qual::ProductQualityCharacteristic {index := 1})
}

definition{
  name: characteristicReliability,
  parameters: [],
  result: Foundation.Qual::ProductQualityCharacteristic,
  body: (record Foundation.Qual::ProductQualityCharacteristic {index := 2})
}

definition{
  name: characteristicSecurity,
  parameters: [],
  result: Foundation.Qual::ProductQualityCharacteristic,
  body: (record Foundation.Qual::ProductQualityCharacteristic {index := 3})
}

definition{
  name: subcharacteristicFaultlessness,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 0, characteristicIndex := 2})
}

definition{
  name: subcharacteristicFunctionalCompleteness,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 1, characteristicIndex := 0})
}

definition{
  name: subcharacteristicFunctionalCorrectness,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 2, characteristicIndex := 0})
}

definition{
  name: subcharacteristicIntegrity,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 3, characteristicIndex := 3})
}

definition{
  name: subcharacteristicResistance,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 4, characteristicIndex := 3})
}

definition{
  name: subcharacteristicResourceUtilization,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 5, characteristicIndex := 1})
}

definition{
  name: subcharacteristicTimeBehaviour,
  parameters: [],
  result: Foundation.Qual::QualitySubcharacteristic,
  body: (record Foundation.Qual::QualitySubcharacteristic {index := 6, characteristicIndex := 1})
}

definition{
  name: requirementBoundedAllocation,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 0, subcharacteristicIndex := 5})
}

definition{
  name: requirementBoundedRequest,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 1, subcharacteristicIndex := 6})
}

definition{
  name: requirementEveryPropertyProved,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 2, subcharacteristicIndex := 3})
}

definition{
  name: requirementEveryRequestAnswered,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 3, subcharacteristicIndex := 1})
}

definition{
  name: requirementEveryVectorReplays,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 4, subcharacteristicIndex := 0})
}

definition{
  name: requirementEveryVerdictMatchesAdmitDraft,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 5, subcharacteristicIndex := 2})
}

definition{
  name: requirementExamplesAnsweredAsStated,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 6, subcharacteristicIndex := 2})
}

definition{
  name: requirementNoEscapingPathAdmitted,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 7, subcharacteristicIndex := 4})
}

definition{
  name: measureEscapingAdmissions,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 0, requirementIndex := 7, threshold := 0})
}

definition{
  name: measureExampleMismatches,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 1, requirementIndex := 6, threshold := 0})
}

definition{
  name: measureFailedVectors,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 2, requirementIndex := 4, threshold := 0})
}

definition{
  name: measureGuestAllocationBytes,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 3, requirementIndex := 0, threshold := 224})
}

definition{
  name: measureRequestBytesRead,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 4, requirementIndex := 1, threshold := 112})
}

definition{
  name: measureUnansweredRequests,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 5, requirementIndex := 3, threshold := 0})
}

definition{
  name: measureUnprovedProperties,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 6, requirementIndex := 2, threshold := 0})
}

definition{
  name: measureVectorsThatDisagree,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 7, requirementIndex := 5, threshold := 0})
}

definition{
  name: characteristicNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Functional suitability", text := "Functional suitability, as ISO/IEC 25010:2023 defines it, for Draft admission."}) (cons (record Named {index := 1, name := "Performance efficiency", text := "Performance efficiency, as ISO/IEC 25010:2023 defines it, for Draft admission."}) (cons (record Named {index := 2, name := "Reliability", text := "Reliability, as ISO/IEC 25010:2023 defines it, for Draft admission."}) (cons (record Named {index := 3, name := "Security", text := "Security, as ISO/IEC 25010:2023 defines it, for Draft admission."}) (nil Named)))))
}

definition{
  name: subcharacteristicNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Faultlessness", text := "Reliability: Faultlessness."}) (cons (record Named {index := 1, name := "Functional completeness", text := "Functional suitability: Functional completeness."}) (cons (record Named {index := 2, name := "Functional correctness", text := "Functional suitability: Functional correctness."}) (cons (record Named {index := 3, name := "Integrity", text := "Security: Integrity."}) (cons (record Named {index := 4, name := "Resistance", text := "Security: Resistance."}) (cons (record Named {index := 5, name := "Resource utilization", text := "Performance efficiency: Resource utilization."}) (cons (record Named {index := 6, name := "Time behaviour", text := "Performance efficiency: Time behaviour."}) (nil Named))))))))
}

definition{
  name: requirementNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Bounded allocation", text := "The guest allocates at most 224 bytes for one request."}) (cons (record Named {index := 1, name := "Bounded request", text := "A request over 112 bytes is refused before any field is read."}) (cons (record Named {index := 2, name := "Every property proved", text := "All 5 properties are theorems the Lean kernel checks."}) (cons (record Named {index := 3, name := "Every request answered", text := "Every request gets an answer: a rule, admitted otherwise, or invalid."}) (cons (record Named {index := 4, name := "Every vector replays", text := "All 60 acceptance vectors replay in the compiled guest, the shortest 0 bytes long."}) (cons (record Named {index := 5, name := "Every verdict matches admitDraft", text := "Each vector answers the verdict admitDraftRun gives."}) (cons (record Named {index := 6, name := "Examples answered as stated", text := "Every one of the 9 examples of the spec is answered as it states."}) (cons (record Named {index := 7, name := "No escaping path admitted", text := "No request whose path is absolute, has a .. component or is outside the roots is admitted."}) (nil Named)))))))))
}

definition{
  name: measureNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Escaping admissions", text := "Acceptance vectors answered admitted with path absolute, dotdot-component or outside-roots."}) (cons (record Named {index := 1, name := "Example mismatches", text := "Examples the guest answers otherwise than they state."}) (cons (record Named {index := 2, name := "Failed vectors", text := "Acceptance vectors whose replay differs from the model."}) (cons (record Named {index := 3, name := "Guest allocation bytes", text := "Most bytes the guest allocates for one request."}) (cons (record Named {index := 4, name := "Request bytes read", text := "Longest request the guest decodes, in bytes."}) (cons (record Named {index := 5, name := "Unanswered requests", text := "Acceptance vectors the guest does not answer."}) (cons (record Named {index := 6, name := "Unproved properties", text := "Properties of the spec without a checked theorem."}) (cons (record Named {index := 7, name := "Vectors that disagree", text := "Acceptance vectors whose replayed verdict differs from the expected one."}) (nil Named)))))))))
}

definition{
  name: subcharacteristicRecords,
  parameters: [],
  result: (List Foundation.Qual::QualitySubcharacteristic),
  body: (cons (subcharacteristicFaultlessness) (cons (subcharacteristicFunctionalCompleteness) (cons (subcharacteristicFunctionalCorrectness) (cons (subcharacteristicIntegrity) (cons (subcharacteristicResistance) (cons (subcharacteristicResourceUtilization) (cons (subcharacteristicTimeBehaviour) (nil Foundation.Qual::QualitySubcharacteristic))))))))
}

definition{
  name: requirementRecords,
  parameters: [],
  result: (List Foundation.Qual::QualityRequirement),
  body: (cons (requirementBoundedAllocation) (cons (requirementBoundedRequest) (cons (requirementEveryPropertyProved) (cons (requirementEveryRequestAnswered) (cons (requirementEveryVectorReplays) (cons (requirementEveryVerdictMatchesAdmitDraft) (cons (requirementExamplesAnsweredAsStated) (cons (requirementNoEscapingPathAdmitted) (nil Foundation.Qual::QualityRequirement)))))))))
}

definition{
  name: measureRecords,
  parameters: [],
  result: (List Foundation.Qual::QualityMeasure),
  body: (cons (measureEscapingAdmissions) (cons (measureExampleMismatches) (cons (measureFailedVectors) (cons (measureGuestAllocationBytes) (cons (measureRequestBytesRead) (cons (measureUnansweredRequests) (cons (measureUnprovedProperties) (cons (measureVectorsThatDisagree) (nil Foundation.Qual::QualityMeasure)))))))))
}

definition{
  name: namesNumbered,
  parameters: [position : Nat, names : (List Named)],
  result: Bool,
  body: (match names
    | List.nil => true
    | List.cons item rest => (((project item index) =? position) && (namesNumbered (position + 1) rest))),
  recursive_argument: names
}

definition{
  name: parentsKnown,
  parameters: [count : Nat, records : (List Foundation.Qual::QualitySubcharacteristic)],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons item rest => (((project item characteristicIndex) <? count) && (parentsKnown count rest))),
  recursive_argument: records
}

definition{
  name: requirementsKnown,
  parameters: [count : Nat, records : (List Foundation.Qual::QualityRequirement)],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons item rest => (((project item subcharacteristicIndex) <? count) && (requirementsKnown count rest))),
  recursive_argument: records
}

definition{
  name: measuresKnown,
  parameters: [count : Nat, records : (List Foundation.Qual::QualityMeasure)],
  result: Bool,
  body: (match records
    | List.nil => true
    | List.cons item rest => (((project item requirementIndex) <? count) && (measuresKnown count rest))),
  recursive_argument: records
}

definition{
  name: thresholdOf,
  parameters: [wanted : Nat, records : (List Foundation.Qual::QualityMeasure)],
  result: Nat,
  body: (match records
    | List.nil => 0
    | List.cons head rest => (if ((project head index) =? wanted) then (project head threshold) else (thresholdOf wanted rest))),
  recursive_argument: records
}

definition{
  name: qualityValid,
  parameters: [],
  result: Bool,
  body: ((namesNumbered 0 (characteristicNames)) && ((namesNumbered 0 (subcharacteristicNames)) && ((namesNumbered 0 (requirementNames)) && ((namesNumbered 0 (measureNames)) && ((parentsKnown 4 (subcharacteristicRecords)) && ((requirementsKnown 7 (requirementRecords)) && (measuresKnown 8 (measureRecords))))))))
}

theorem{
  name: qualityModelHolds,
  parameters: [],
  statement: ((qualityValid) = true),
  proof: decide{}
}

theorem{
  name: measureEscapingAdmissionsThreshold,
  parameters: [],
  statement: ((thresholdOf 0 (measureRecords)) = 0),
  proof: decide{}
}

theorem{
  name: measureExampleMismatchesThreshold,
  parameters: [],
  statement: ((thresholdOf 1 (measureRecords)) = 0),
  proof: decide{}
}

theorem{
  name: measureFailedVectorsThreshold,
  parameters: [],
  statement: ((thresholdOf 2 (measureRecords)) = 0),
  proof: decide{}
}

theorem{
  name: measureGuestAllocationBytesThreshold,
  parameters: [],
  statement: ((thresholdOf 3 (measureRecords)) = 224),
  proof: decide{}
}

theorem{
  name: measureRequestBytesReadThreshold,
  parameters: [],
  statement: ((thresholdOf 4 (measureRecords)) = 112),
  proof: decide{}
}

theorem{
  name: measureUnansweredRequestsThreshold,
  parameters: [],
  statement: ((thresholdOf 5 (measureRecords)) = 0),
  proof: decide{}
}

theorem{
  name: measureUnprovedPropertiesThreshold,
  parameters: [],
  statement: ((thresholdOf 6 (measureRecords)) = 0),
  proof: decide{}
}

theorem{
  name: measureVectorsThatDisagreeThreshold,
  parameters: [],
  statement: ((thresholdOf 7 (measureRecords)) = 0),
  proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Security.lex.tex 677 lines
\begin{lexlean}{Security}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\useglossary{prism.sec@1.0.0}
\importmodule{Foundation.Sec}
\importmodule{Production.ThreatModel}
\importmodule{Architecture}
\title{security threat}
\begin{semanticmodule}
definition{
  name: assetAnswer,
  parameters: [],
  result: Foundation.Sec::Asset,
  body: (record Foundation.Sec::Asset {index := 0, componentIndex := 1})
}

definition{
  name: assetModelSource,
  parameters: [],
  result: Foundation.Sec::Asset,
  body: (record Foundation.Sec::Asset {index := 1, componentIndex := 8})
}

definition{
  name: assetPublishedHolo,
  parameters: [],
  result: Foundation.Sec::Asset,
  body: (record Foundation.Sec::Asset {index := 2, componentIndex := 2})
}

definition{
  name: assetRequestBytes,
  parameters: [],
  result: Foundation.Sec::Asset,
  body: (record Foundation.Sec::Asset {index := 3, componentIndex := 1})
}

definition{
  name: threatAnswerThatBreaksINV001,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 0})
}

definition{
  name: threatAnswerThatBreaksINV002,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 1})
}

definition{
  name: threatAnswerThatBreaksINV003,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 2})
}

definition{
  name: threatAnswerThatBreaksINV004,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 3})
}

definition{
  name: threatAnswerThatBreaksINV005,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 4})
}

definition{
  name: threatGrantedCapability,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 5})
}

definition{
  name: threatLookAlikePath,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 6})
}

definition{
  name: threatMalformedRequest,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 7})
}

definition{
  name: threatOversizedDraft,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 8})
}

definition{
  name: threatOversizedRequest,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 9})
}

definition{
  name: threatPathEscape,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 10})
}

definition{
  name: threatSubstitutedHolo,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 11})
}

definition{
  name: threatSubstitutedHost,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 12})
}

definition{
  name: threatSymbolicLinkEscape,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 13})
}

definition{
  name: threatTamperedModel,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 14})
}

definition{
  name: riskAnswerThatBreaksINV001,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 0, assetIndex := 0, threatIndex := 0, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskAnswerThatBreaksINV002,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 1, assetIndex := 0, threatIndex := 1, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskAnswerThatBreaksINV003,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 2, assetIndex := 0, threatIndex := 2, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskAnswerThatBreaksINV004,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 3, assetIndex := 0, threatIndex := 3, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskAnswerThatBreaksINV005,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 4, assetIndex := 0, threatIndex := 4, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskGrantedCapability,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 5, assetIndex := 0, threatIndex := 5, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: riskLookAlikePath,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 6, assetIndex := 1, threatIndex := 6, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: riskMalformedRequest,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 7, assetIndex := 3, threatIndex := 7, likelihood := (ctor Foundation.Sec::Likelihood.high), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: riskOversizedDraft,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 8, assetIndex := 3, threatIndex := 8, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: riskOversizedRequest,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 9, assetIndex := 3, threatIndex := 9, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.minor)})
}

definition{
  name: riskPathEscape,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 10, assetIndex := 3, threatIndex := 10, likelihood := (ctor Foundation.Sec::Likelihood.high), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskSubstitutedHolo,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 11, assetIndex := 2, threatIndex := 11, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskSubstitutedHost,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 12, assetIndex := 2, threatIndex := 12, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskSymbolicLinkEscape,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 13, assetIndex := 1, threatIndex := 13, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: riskTamperedModel,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 14, assetIndex := 1, threatIndex := 14, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}

definition{
  name: controlBoundedRequest,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 0, riskIndex := 9})
}

definition{
  name: controlFingerprintAndProvenance,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 1, riskIndex := 11})
}

definition{
  name: controlNFCRequired,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 2, riskIndex := 6})
}

definition{
  name: controlNoCapabilityGranted,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 3, riskIndex := 5})
}

definition{
  name: controlOwnerSetLimits,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 4, riskIndex := 8})
}

definition{
  name: controlPathAdmission,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 5, riskIndex := 10})
}

definition{
  name: controlProofOfINV001,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 6, riskIndex := 0})
}

definition{
  name: controlProofOfINV002,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 7, riskIndex := 1})
}

definition{
  name: controlProofOfINV003,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 8, riskIndex := 2})
}

definition{
  name: controlProofOfINV004,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 9, riskIndex := 3})
}

definition{
  name: controlProofOfINV005,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 10, riskIndex := 4})
}

definition{
  name: controlRegeneratedFromThePrompt,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 11, riskIndex := 14})
}

definition{
  name: controlStrictDecoder,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 12, riskIndex := 7})
}

definition{
  name: controlSet,
  parameters: [],
  result: Production.ThreatModel::ControlSet,
  body: (record Production.ThreatModel::ControlSet {title := "Draft admission security controls", text := "Draft admission answers one request with one answer in a Core-Wasm guest granted no capability. Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.", version := "0.1.0", lastModified := "2026-11-12T18:44:38Z"})
}

definition{
  name: modeledAssetAnswer,
  parameters: [],
  result: Production.ThreatModel::ModeledAsset,
  body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetAnswer", name := "Answer", text := "The answer the guest returns: one of admitted, path-refused, too-many-files, too-many-bytes, duplicate-path, or invalid."})
}

definition{
  name: modeledAssetModelSource,
  parameters: [],
  result: Production.ThreatModel::ModeledAsset,
  body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetModelSource", name := "Model source", text := "The prompt, the spec and the LexLean model in the repository, from which the holo is built."})
}

definition{
  name: modeledAssetPublishedHolo,
  parameters: [],
  result: Production.ThreatModel::ModeledAsset,
  body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetPublishedHolo", name := "Published holo", text := "The holo and page the Pages workflow publishes, with its fingerprint and signed provenance."})
}

definition{
  name: modeledAssetRequestBytes,
  parameters: [],
  result: Production.ThreatModel::ModeledAsset,
  body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetRequestBytes", name := "Request bytes", text := "The bytes a caller sends, at most 112 of them."})
}

definition{
  name: modeledThreatAnswerThatBreaksINV001,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV001", name := "Answer that breaks INV-001", text := "The guest answers admitted although path is dotdot-component, which matters because Admission.admittedPathHasNoDotDot: an admitted path has no .. component.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatAnswerThatBreaksINV002,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV002", name := "Answer that breaks INV-002", text := "The guest answers admitted although path is outside-roots, which matters because risk R5 (path escape): no path outside the source roots is admitted.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatAnswerThatBreaksINV003,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV003", name := "Answer that breaks INV-003", text := "The guest answers admitted although files is above 256, which matters because Admission: an admitted draft never has more rows than max_files.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatAnswerThatBreaksINV004,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV004", name := "Answer that breaks INV-004", text := "The guest answers admitted although bytes is above 8388608, which matters because Admission: an admitted draft never has more content bytes than max_bytes.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatAnswerThatBreaksINV005,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV005", name := "Answer that breaks INV-005", text := "The guest answers duplicate-path although path is clean and files is above 256, which matters because the duplicate scan runs only on a draft the limits admit.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatGrantedCapability,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatGrantedCapability", name := "Granted capability", text := "The guest reads, stores or sends data beyond the request it answers.", category := (ctor Production.ThreatModel::Stride.informationDisclosure)})
}

definition{
  name: modeledThreatLookAlikePath,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatLookAlikePath", name := "Look-alike path", text := "Two paths that look the same but differ in Unicode normalization name two files a reviewer reads as one.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}

definition{
  name: modeledThreatMalformedRequest,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatMalformedRequest", name := "Malformed request", text := "A request with a missing, extra, unknown or badly written field is answered as if it were well formed.", category := (ctor Production.ThreatModel::Stride.tampering)})
}

definition{
  name: modeledThreatOversizedDraft,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatOversizedDraft", name := "Oversized draft", text := "A draft with very many rows or bytes exhausts the engine or the store.", category := (ctor Production.ThreatModel::Stride.denialOfService)})
}

definition{
  name: modeledThreatOversizedRequest,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatOversizedRequest", name := "Oversized request", text := "A request longer than 112 bytes makes the guest parse or allocate without bound.", category := (ctor Production.ThreatModel::Stride.denialOfService)})
}

definition{
  name: modeledThreatPathEscape,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatPathEscape", name := "Path escape", text := "A draft row names ../ or an absolute path to write or read outside the source roots (risk R5).", category := (ctor Production.ThreatModel::Stride.elevationOfPrivilege)})
}

definition{
  name: modeledThreatSubstitutedHolo,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatSubstitutedHolo", name := "Substituted holo", text := "A holo other than the one the build verified is served under the app address.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}

definition{
  name: modeledThreatSubstitutedHost,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatSubstitutedHost", name := "Substituted host", text := "Something other than the repository Pages workflow serves pages under its address.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}

definition{
  name: modeledThreatSymbolicLinkEscape,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatSymbolicLinkEscape", name := "Symbolic link escape", text := "A row's path is clean but resolves through a symbolic link outside the roots once materialized.", category := (ctor Production.ThreatModel::Stride.elevationOfPrivilege)})
}

definition{
  name: modeledThreatTamperedModel,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatTamperedModel", name := "Tampered model", text := "The model the holo is built from differs from the reviewed prompt and spec.", category := (ctor Production.ThreatModel::Stride.tampering)})
}

definition{
  name: modeledControlBoundedRequest,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlBoundedRequest", name := "Bounded request", text := "dispatch answers invalid for a request over 112 bytes before reading a field, and the guest allocates at most 224.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlFingerprintAndProvenance,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlFingerprintAndProvenance", name := "Fingerprint and provenance", text := "The page verifies the holo digests before it runs, and the build signs its provenance as the repository workflow.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "actions/attest-build-provenance in the pages workflow"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prism-code check of the holo identities in the page"}) (nil Production.ThreatModel::Evidence)))})
}

definition{
  name: modeledControlNFCRequired,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlNFCRequired", name := "NFC required", text := "A path not in NFC under Unicode 17.0.0 is refused, so equal-looking paths compare as equal octets.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "lexlean-mcp crates/nfc-oracle NF-01 to NF-15"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlNoCapabilityGranted,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlNoCapabilityGranted", name := "No capability granted", text := "prism.toml grants the holo nothing and the model declares capabilitiesEmpty, so a guest import of any host capability is refused.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prism-code check refuses an ungranted guest import"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlOwnerSetLimits,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlOwnerSetLimits", name := "Owner-set limits", text := "More than 256 rows or 8388608 content bytes is refused before the engine sees the draft.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv003Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv004Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "lexlean-mcp OWNER-VALUES.md OV-03"}) (nil Production.ThreatModel::Evidence))))})
}

definition{
  name: modeledControlPathAdmission,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlPathAdmission", name := "Path admission", text := "Absolute paths, .. components and paths outside the roots are refused, proved for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv001Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv002Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "lexlean-mcp crates/nfc-oracle admitRun SM-01"}) (nil Production.ThreatModel::Evidence))))})
}

definition{
  name: modeledControlProofOfINV001,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV001", name := "Proof of INV-001", text := "It never answers admitted when path is dotdot-component. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv001Holds"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlProofOfINV002,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV002", name := "Proof of INV-002", text := "It never answers admitted when path is outside-roots. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv002Holds"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlProofOfINV003,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV003", name := "Proof of INV-003", text := "It never answers admitted when files is above 256. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv003Holds"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlProofOfINV004,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV004", name := "Proof of INV-004", text := "It never answers admitted when bytes is above 8388608. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv004Holds"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlProofOfINV005,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV005", name := "Proof of INV-005", text := "It never answers duplicate-path when path is clean and files is above 256. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "LexleanMcpDraftAdmissionProofs::inv005Holds"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: modeledControlRegeneratedFromThePrompt,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlRegeneratedFromThePrompt", name := "Regenerated from the prompt", text := "The model is written from the prompt by the builder, and the build checks every theorem and replays every vector in the pinned SDK.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prismpm verify in the SDK image prismpm.lock pins"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "app/prompt.json"}) (nil Production.ThreatModel::Evidence)))})
}

definition{
  name: modeledControlStrictDecoder,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlStrictDecoder", name := "Strict decoder", text := "Every field is decoded exactly: choices from their list, numbers as plain decimal digits within their bounds, single spaces between fields; anything else is invalid.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify"}) (nil Production.ThreatModel::Evidence))})
}

definition{
  name: mappingOversizedRequest,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatOversizedRequest", controls := (cons "Security::controlBoundedRequest" (nil String))})
}

definition{
  name: mappingSubstitutedHolo,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatSubstitutedHolo", controls := (cons "Security::controlFingerprintAndProvenance" (nil String))})
}

definition{
  name: mappingLookAlikePath,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatLookAlikePath", controls := (cons "Security::controlNFCRequired" (nil String))})
}

definition{
  name: mappingGrantedCapability,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatGrantedCapability", controls := (cons "Security::controlNoCapabilityGranted" (nil String))})
}

definition{
  name: mappingOversizedDraft,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatOversizedDraft", controls := (cons "Security::controlOwnerSetLimits" (nil String))})
}

definition{
  name: mappingPathEscape,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatPathEscape", controls := (cons "Security::controlPathAdmission" (nil String))})
}

definition{
  name: mappingAnswerThatBreaksINV001,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV001", controls := (cons "Security::controlProofOfINV001" (nil String))})
}

definition{
  name: mappingAnswerThatBreaksINV002,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV002", controls := (cons "Security::controlProofOfINV002" (nil String))})
}

definition{
  name: mappingAnswerThatBreaksINV003,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV003", controls := (cons "Security::controlProofOfINV003" (nil String))})
}

definition{
  name: mappingAnswerThatBreaksINV004,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV004", controls := (cons "Security::controlProofOfINV004" (nil String))})
}

definition{
  name: mappingAnswerThatBreaksINV005,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV005", controls := (cons "Security::controlProofOfINV005" (nil String))})
}

definition{
  name: mappingTamperedModel,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatTamperedModel", controls := (cons "Security::controlRegeneratedFromThePrompt" (nil String))})
}

definition{
  name: mappingMalformedRequest,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatMalformedRequest", controls := (cons "Security::controlStrictDecoder" (nil String))})
}

definition{
  name: acceptedSubstitutedHost,
  parameters: [],
  result: Production.ThreatModel::AcceptedRisk,
  body: (record Production.ThreatModel::AcceptedRisk {threat := "Security::threatSubstitutedHost", rationale := "A page cannot defend against its own host. The holo carries signed build provenance a visitor can check, and the app can be rebuilt from its prompt."})
}

definition{
  name: acceptedSymbolicLinkEscape,
  parameters: [],
  result: Production.ThreatModel::AcceptedRisk,
  body: (record Production.ThreatModel::AcceptedRisk {threat := "Security::threatSymbolicLinkEscape", rationale := "The symlink clause of control K5 is pending until materialization (issue 9) builds it; path admission is pure and sees no file system."})
}
\end{semanticmodule}
\end{lexlean}
app/src/LexleanMcpDraftAdmission.lex.tex 298 lines
\begin{lexlean}{LexleanMcpDraftAdmission}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Foundation.Bytes}
\importmodule{Foundation.View.Text.V1.Model}
\title{Text application model}
\begin{semanticmodule}
definition{name: pathClean, parameters: [], result: Nat, body: 0}

definition{name: pathNonUtf8, parameters: [], result: Nat, body: 1}

definition{name: pathNonNfc, parameters: [], result: Nat, body: 2}

definition{name: pathAbsolute, parameters: [], result: Nat, body: 3}

definition{name: pathEmptyComponent, parameters: [], result: Nat, body: 4}

definition{name: pathDotComponent, parameters: [], result: Nat, body: 5}

definition{name: pathDotdotComponent, parameters: [], result: Nat, body: 6}

definition{name: pathOutsideRoots, parameters: [], result: Nat, body: 7}

definition{name: pathNonLexTex, parameters: [], result: Nat, body: 8}

definition{name: answerAdmitted, parameters: [], result: Nat, body: 0}

definition{name: answerPathRefused, parameters: [], result: Nat, body: 1}

definition{name: answerTooManyFiles, parameters: [], result: Nat, body: 2}

definition{name: answerTooManyBytes, parameters: [], result: Nat, body: 3}

definition{name: answerDuplicatePath, parameters: [], result: Nat, body: 4}

structure{
  name: Request,
  type_parameters: [],
  parameters: [],
  fields: [
    {name: path, type: Nat},
    {name: files, type: Nat},
    {name: bytes, type: Nat},
    {name: repeats, type: Nat}
  ]
}

definition{
  name: byteAt,
  parameters: [s : Bytes, i : Nat],
  result: (Option Nat),
  body: (match (prim index s i : (Option UInt8))
    | Option.none => (ctor Option.none [Nat])
    | Option.some b => (ctor Option.some [Nat] (prim to_nat b : Nat))),
  axioms: [Quot.sound, propext]
}

definition{
  name: digitsValue,
  parameters: [s : Bytes, i : Nat, acc : Nat, fuel : Nat],
  result: (Option Nat),
  body: (match fuel
    | Nat.zero => (ctor Option.some [Nat] acc)
    | Nat.succ rest => (match (byteAt s i)
      | Option.none => (ctor Option.none [Nat])
      | Option.some d => (if ((d <? 48) || (57 <? d)) then (ctor Option.none [Nat]) else (digitsValue s (i + 1) ((prim multiply acc 10 : Nat) + (prim subtract d 48 : Nat)) rest)))),
  axioms: [Quot.sound, propext],
  recursive_argument: fuel
}

definition{
  name: parseDigits,
  parameters: [s : Bytes],
  result: (Option Nat),
  body: (if ((Foundation.Bytes::byteLength s) =? 0) then (ctor Option.none [Nat]) else (if (18 <? (Foundation.Bytes::byteLength s)) then (ctor Option.none [Nat]) else (match (byteAt s 0)
    | Option.none => (ctor Option.none [Nat])
    | Option.some lead => (if ((lead =? 48) && (1 <? (Foundation.Bytes::byteLength s))) then (ctor Option.none [Nat]) else (digitsValue s 0 0 (Foundation.Bytes::byteLength s)))))),
  axioms: [Quot.sound, propext]
}

definition{
  name: parseNumber,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (parseDigits value),
  axioms: [Quot.sound, propext]
}

definition{
  name: parsePath,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x636c65616e : Bool) then (ctor Option.some [Nat] (pathClean)) else (if (prim equal value 0x6e6f6e2d75746638 : Bool) then (ctor Option.some [Nat] (pathNonUtf8)) else (if (prim equal value 0x6e6f6e2d6e6663 : Bool) then (ctor Option.some [Nat] (pathNonNfc)) else (if (prim equal value 0x6162736f6c757465 : Bool) then (ctor Option.some [Nat] (pathAbsolute)) else (if (prim equal value 0x656d7074792d636f6d706f6e656e74 : Bool) then (ctor Option.some [Nat] (pathEmptyComponent)) else (if (prim equal value 0x646f742d636f6d706f6e656e74 : Bool) then (ctor Option.some [Nat] (pathDotComponent)) else (if (prim equal value 0x646f74646f742d636f6d706f6e656e74 : Bool) then (ctor Option.some [Nat] (pathDotdotComponent)) else (if (prim equal value 0x6f7574736964652d726f6f7473 : Bool) then (ctor Option.some [Nat] (pathOutsideRoots)) else (if (prim equal value 0x6e6f6e2d6c65782d746578 : Bool) then (ctor Option.some [Nat] (pathNonLexTex)) else (ctor Option.none [Nat]))))))))))
}

definition{
  name: parseFiles,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (match (parseNumber value)
    | Option.none => (ctor Option.none [Nat])
    | Option.some parsed => (ctor Option.some [Nat] parsed)),
  axioms: [Quot.sound, propext]
}

definition{
  name: parseBytes,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (match (parseNumber value)
    | Option.none => (ctor Option.none [Nat])
    | Option.some parsed => (ctor Option.some [Nat] parsed)),
  axioms: [Quot.sound, propext]
}

definition{
  name: parseRepeats,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (match (parseNumber value)
    | Option.none => (ctor Option.none [Nat])
    | Option.some parsed => (ctor Option.some [Nat] parsed)),
  axioms: [Quot.sound, propext]
}

definition{
  name: sliceOf,
  parameters: [s : Bytes, start : Nat, count : Nat],
  result: Bytes,
  body: (match (prim slice s start count : (Option Bytes))
    | Option.none => 0x
    | Option.some part => part)
}

definition{
  name: fieldEnd,
  parameters: [s : Bytes, i : Nat, fuel : Nat],
  result: Nat,
  body: (match fuel
    | Nat.zero => i
    | Nat.succ rest => (match (byteAt s i)
      | Option.none => i
      | Option.some d => (if (d =? 32) then i else (fieldEnd s (i + 1) rest)))),
  axioms: [Quot.sound, propext],
  recursive_argument: fuel
}

definition{
  name: decodeField4,
  parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat],
  result: (Option Request),
  body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseRepeats (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v4 => (if (e =? (Foundation.Bytes::byteLength s)) then (ctor Option.some [Request] (record Request {path := v1, files := v2, bytes := v3, repeats := v4})) else (ctor Option.none [Request])))),
  axioms: [Quot.sound, propext]
}

definition{
  name: decodeField3,
  parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat],
  result: (Option Request),
  body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseBytes (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v3 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField4 s (e + 1) v1 v2 v3) else (ctor Option.none [Request])))),
  axioms: [Quot.sound, propext]
}

definition{
  name: decodeField2,
  parameters: [s : Bytes, start : Nat, v1 : Nat],
  result: (Option Request),
  body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseFiles (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v2 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField3 s (e + 1) v1 v2) else (ctor Option.none [Request])))),
  axioms: [Quot.sound, propext]
}

definition{
  name: decodeField1,
  parameters: [s : Bytes, start : Nat],
  result: (Option Request),
  body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parsePath (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v1 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField2 s (e + 1) v1) else (ctor Option.none [Request])))),
  axioms: [Quot.sound, propext]
}

definition{
  name: rule1,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathNonUtf8))
}

definition{
  name: rule2,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathNonNfc))
}

definition{
  name: rule3,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathAbsolute))
}

definition{
  name: rule4,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathEmptyComponent))
}

definition{
  name: rule5,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathDotComponent))
}

definition{
  name: rule6,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathDotdotComponent))
}

definition{
  name: rule7,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathOutsideRoots))
}

definition{
  name: rule8,
  parameters: [request : Request],
  result: Bool,
  body: ((project request path) =? (pathNonLexTex))
}

definition{
  name: rule9,
  parameters: [request : Request],
  result: Bool,
  body: (256 <? (project request files))
}

definition{
  name: rule10,
  parameters: [request : Request],
  result: Bool,
  body: (8388608 <? (project request bytes))
}

definition{
  name: rule11,
  parameters: [request : Request],
  result: Bool,
  body: (1 <=? (project request repeats))
}

definition{
  name: judge,
  parameters: [request : Request],
  result: Nat,
  body: (if (rule1 request) then (answerPathRefused) else (if (rule2 request) then (answerPathRefused) else (if (rule3 request) then (answerPathRefused) else (if (rule4 request) then (answerPathRefused) else (if (rule5 request) then (answerPathRefused) else (if (rule6 request) then (answerPathRefused) else (if (rule7 request) then (answerPathRefused) else (if (rule8 request) then (answerPathRefused) else (if (rule9 request) then (answerTooManyFiles) else (if (rule10 request) then (answerTooManyBytes) else (if (rule11 request) then (answerDuplicatePath) else (answerAdmitted))))))))))))
}

definition{
  name: encodeAnswer,
  parameters: [code : Nat],
  result: Bytes,
  body: (if (code =? (answerAdmitted)) then 0x61646d6974746564 else (if (code =? (answerPathRefused)) then 0x706174682d72656675736564 else (if (code =? (answerTooManyFiles)) then 0x746f6f2d6d616e792d66696c6573 else (if (code =? (answerTooManyBytes)) then 0x746f6f2d6d616e792d6279746573 else (if (code =? (answerDuplicatePath)) then 0x6475706c69636174652d70617468 else 0x696e76616c6964)))))
}

definition{
  name: dispatch,
  parameters: [value : Bytes],
  result: Bytes,
  body: (if (112 <? (Foundation.Bytes::byteLength value)) then 0x696e76616c6964 else (match (decodeField1 value 0)
    | Option.none => 0x696e76616c6964
    | Option.some request => (encodeAnswer (judge request)))),
  axioms: [Quot.sound, propext]
}

definition{
  name: application,
  parameters: [],
  result: Foundation.View.Text.V1.Model::TextApplication,
  body: (record Foundation.View.Text.V1.Model::TextApplication {profile := "prismpm/text-application/1", name := "Draft admission", cargoName := "prism-lexlean-mcp-draft-admission", cargoVersion := "0.1.0", cargoDescription := "Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.", cargoRepository := "https://github.com/UOR-Foundation/PrismPM", cargoHomepage := "https://github.com/UOR-Foundation/PrismPM", libraryRoots := (cons "PrismLexleanMcpDraftAdmission.LexleanMcpDraftAdmission.dispatch" (nil String)), acceptanceVectors := (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203320343230302030, response := 0x61646d6974746564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x646f74646f742d636f6d706f6e656e74203320343230302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6f7574736964652d726f6f747320312031302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353720343230302030, response := 0x746f6f2d6d616e792d66696c6573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2031343820383338383630392030, response := 0x746f6f2d6d616e792d6279746573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2031343820353431333031302031, response := 0x6475706c69636174652d70617468}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e66632033303020393030303030302032, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353620383338383630382030, response := 0x61646d6974746564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2033, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020302030, response := 0x61646d6974746564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020302031, response := 0x6475706c69636174652d70617468}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020383338383630392030, response := 0x746f6f2d6d616e792d6279746573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020383338383630392031, response := 0x746f6f2d6d616e792d6279746573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353720302030, response := 0x746f6f2d6d616e792d66696c6573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353720302031, response := 0x746f6f2d6d616e792d66696c6573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353720383338383630392030, response := 0x746f6f2d6d616e792d66696c6573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2032353720383338383630392031, response := 0x746f6f2d6d616e792d66696c6573}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d75746638203020302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d75746638203020302031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d75746638203020383338383630392030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d75746638203020383338383630392031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d757466382032353720302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d757466382032353720302031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d757466382032353720383338383630392030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d757466382032353720383338383630392031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e6663203020302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e6663203020302031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e6663203020383338383630392030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e6663203020383338383630392031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e66632032353720302030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e66632032353720302031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e66632032353720383338383630392030, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x6e6f6e2d6e66632032353720383338383630392031, response := 0x706174682d72656675736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0xff, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2030203020302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e202030202030202030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x756e6b6e6f776e203020302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20303720302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e202d3120302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e202b3120302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203130303030303030303030303030303030303020302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20d9a120302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e207820302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20302030372030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2030202d312030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2030202b312030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020313030303030303030303030303030303030302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020d9a12030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020782030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20302030203037, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20302030202d31, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e20302030202b31, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020302031303030303030303030303030303030303030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e2030203020d9a1, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x636c65616e203020302078, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (nil Foundation.View.Text.V1.Model::AcceptanceVector))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), entryRoot := "PrismLexleanMcpDraftAdmission.LexleanMcpDraftAdmission.dispatch", coreContract := "hologram:guest/core-wasm@1", requestMaximum := (112 : UInt32), responseMaximum := (64 : UInt32), guestAllocationMaximum := (224 : UInt32), capabilitiesEmpty := true, fatArchive := true, primaryLayer := (0 : UInt8), viewLayer := (1 : UInt8), view := (record Foundation.View.Text.V1.Model::TextView {title := "Draft admission", heading := "Draft admission", inputLabel := "Request: path files bytes repeats", submitLabel := "Decide", outputLabel := "Answer", inputError := "Invalid request", responseError := "Invalid response"})})
}
\end{semanticmodule}
\end{lexlean}
app/src/LexleanMcpDraftAdmissionProofs.lex.tex 234 lines
\begin{lexlean}{LexleanMcpDraftAdmissionProofs}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{LexleanMcpDraftAdmission}
\title{Text application model}
\begin{semanticmodule}
definition{
  name: breaksInv001,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  result: Bool,
  body: ((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathDotdotComponent))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))
}

theorem{
  name: inv001Holds,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  statement: ((breaksInv001 request) = false),
  proof: linear_arithmetic{
    definitions: [
      LexleanMcpDraftAdmission::answerAdmitted,
      LexleanMcpDraftAdmission::answerDuplicatePath,
      LexleanMcpDraftAdmission::answerPathRefused,
      LexleanMcpDraftAdmission::answerTooManyBytes,
      LexleanMcpDraftAdmission::answerTooManyFiles,
      LexleanMcpDraftAdmission::judge,
      LexleanMcpDraftAdmission::pathAbsolute,
      LexleanMcpDraftAdmission::pathClean,
      LexleanMcpDraftAdmission::pathDotComponent,
      LexleanMcpDraftAdmission::pathDotdotComponent,
      LexleanMcpDraftAdmission::pathEmptyComponent,
      LexleanMcpDraftAdmission::pathNonLexTex,
      LexleanMcpDraftAdmission::pathNonNfc,
      LexleanMcpDraftAdmission::pathNonUtf8,
      LexleanMcpDraftAdmission::pathOutsideRoots,
      LexleanMcpDraftAdmission::rule1,
      LexleanMcpDraftAdmission::rule10,
      LexleanMcpDraftAdmission::rule11,
      LexleanMcpDraftAdmission::rule2,
      LexleanMcpDraftAdmission::rule3,
      LexleanMcpDraftAdmission::rule4,
      LexleanMcpDraftAdmission::rule5,
      LexleanMcpDraftAdmission::rule6,
      LexleanMcpDraftAdmission::rule7,
      LexleanMcpDraftAdmission::rule8,
      LexleanMcpDraftAdmission::rule9,
      breaksInv001
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv002,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  result: Bool,
  body: ((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathOutsideRoots))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))
}

theorem{
  name: inv002Holds,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  statement: ((breaksInv002 request) = false),
  proof: linear_arithmetic{
    definitions: [
      LexleanMcpDraftAdmission::answerAdmitted,
      LexleanMcpDraftAdmission::answerDuplicatePath,
      LexleanMcpDraftAdmission::answerPathRefused,
      LexleanMcpDraftAdmission::answerTooManyBytes,
      LexleanMcpDraftAdmission::answerTooManyFiles,
      LexleanMcpDraftAdmission::judge,
      LexleanMcpDraftAdmission::pathAbsolute,
      LexleanMcpDraftAdmission::pathClean,
      LexleanMcpDraftAdmission::pathDotComponent,
      LexleanMcpDraftAdmission::pathDotdotComponent,
      LexleanMcpDraftAdmission::pathEmptyComponent,
      LexleanMcpDraftAdmission::pathNonLexTex,
      LexleanMcpDraftAdmission::pathNonNfc,
      LexleanMcpDraftAdmission::pathNonUtf8,
      LexleanMcpDraftAdmission::pathOutsideRoots,
      LexleanMcpDraftAdmission::rule1,
      LexleanMcpDraftAdmission::rule10,
      LexleanMcpDraftAdmission::rule11,
      LexleanMcpDraftAdmission::rule2,
      LexleanMcpDraftAdmission::rule3,
      LexleanMcpDraftAdmission::rule4,
      LexleanMcpDraftAdmission::rule5,
      LexleanMcpDraftAdmission::rule6,
      LexleanMcpDraftAdmission::rule7,
      LexleanMcpDraftAdmission::rule8,
      LexleanMcpDraftAdmission::rule9,
      breaksInv002
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv003,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  result: Bool,
  body: ((((project request path) <? 9) && (256 <? (project request files))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))
}

theorem{
  name: inv003Holds,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  statement: ((breaksInv003 request) = false),
  proof: linear_arithmetic{
    definitions: [
      LexleanMcpDraftAdmission::answerAdmitted,
      LexleanMcpDraftAdmission::answerDuplicatePath,
      LexleanMcpDraftAdmission::answerPathRefused,
      LexleanMcpDraftAdmission::answerTooManyBytes,
      LexleanMcpDraftAdmission::answerTooManyFiles,
      LexleanMcpDraftAdmission::judge,
      LexleanMcpDraftAdmission::pathAbsolute,
      LexleanMcpDraftAdmission::pathClean,
      LexleanMcpDraftAdmission::pathDotComponent,
      LexleanMcpDraftAdmission::pathDotdotComponent,
      LexleanMcpDraftAdmission::pathEmptyComponent,
      LexleanMcpDraftAdmission::pathNonLexTex,
      LexleanMcpDraftAdmission::pathNonNfc,
      LexleanMcpDraftAdmission::pathNonUtf8,
      LexleanMcpDraftAdmission::pathOutsideRoots,
      LexleanMcpDraftAdmission::rule1,
      LexleanMcpDraftAdmission::rule10,
      LexleanMcpDraftAdmission::rule11,
      LexleanMcpDraftAdmission::rule2,
      LexleanMcpDraftAdmission::rule3,
      LexleanMcpDraftAdmission::rule4,
      LexleanMcpDraftAdmission::rule5,
      LexleanMcpDraftAdmission::rule6,
      LexleanMcpDraftAdmission::rule7,
      LexleanMcpDraftAdmission::rule8,
      LexleanMcpDraftAdmission::rule9,
      breaksInv003
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv004,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  result: Bool,
  body: ((((project request path) <? 9) && (8388608 <? (project request bytes))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))
}

theorem{
  name: inv004Holds,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  statement: ((breaksInv004 request) = false),
  proof: linear_arithmetic{
    definitions: [
      LexleanMcpDraftAdmission::answerAdmitted,
      LexleanMcpDraftAdmission::answerDuplicatePath,
      LexleanMcpDraftAdmission::answerPathRefused,
      LexleanMcpDraftAdmission::answerTooManyBytes,
      LexleanMcpDraftAdmission::answerTooManyFiles,
      LexleanMcpDraftAdmission::judge,
      LexleanMcpDraftAdmission::pathAbsolute,
      LexleanMcpDraftAdmission::pathClean,
      LexleanMcpDraftAdmission::pathDotComponent,
      LexleanMcpDraftAdmission::pathDotdotComponent,
      LexleanMcpDraftAdmission::pathEmptyComponent,
      LexleanMcpDraftAdmission::pathNonLexTex,
      LexleanMcpDraftAdmission::pathNonNfc,
      LexleanMcpDraftAdmission::pathNonUtf8,
      LexleanMcpDraftAdmission::pathOutsideRoots,
      LexleanMcpDraftAdmission::rule1,
      LexleanMcpDraftAdmission::rule10,
      LexleanMcpDraftAdmission::rule11,
      LexleanMcpDraftAdmission::rule2,
      LexleanMcpDraftAdmission::rule3,
      LexleanMcpDraftAdmission::rule4,
      LexleanMcpDraftAdmission::rule5,
      LexleanMcpDraftAdmission::rule6,
      LexleanMcpDraftAdmission::rule7,
      LexleanMcpDraftAdmission::rule8,
      LexleanMcpDraftAdmission::rule9,
      breaksInv004
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv005,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  result: Bool,
  body: (((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathClean))) && (256 <? (project request files))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerDuplicatePath)))
}

theorem{
  name: inv005Holds,
  parameters: [request : LexleanMcpDraftAdmission::Request],
  statement: ((breaksInv005 request) = false),
  proof: linear_arithmetic{
    definitions: [
      LexleanMcpDraftAdmission::answerAdmitted,
      LexleanMcpDraftAdmission::answerDuplicatePath,
      LexleanMcpDraftAdmission::answerPathRefused,
      LexleanMcpDraftAdmission::answerTooManyBytes,
      LexleanMcpDraftAdmission::answerTooManyFiles,
      LexleanMcpDraftAdmission::judge,
      LexleanMcpDraftAdmission::pathAbsolute,
      LexleanMcpDraftAdmission::pathClean,
      LexleanMcpDraftAdmission::pathDotComponent,
      LexleanMcpDraftAdmission::pathDotdotComponent,
      LexleanMcpDraftAdmission::pathEmptyComponent,
      LexleanMcpDraftAdmission::pathNonLexTex,
      LexleanMcpDraftAdmission::pathNonNfc,
      LexleanMcpDraftAdmission::pathNonUtf8,
      LexleanMcpDraftAdmission::pathOutsideRoots,
      LexleanMcpDraftAdmission::rule1,
      LexleanMcpDraftAdmission::rule10,
      LexleanMcpDraftAdmission::rule11,
      LexleanMcpDraftAdmission::rule2,
      LexleanMcpDraftAdmission::rule3,
      LexleanMcpDraftAdmission::rule4,
      LexleanMcpDraftAdmission::rule5,
      LexleanMcpDraftAdmission::rule6,
      LexleanMcpDraftAdmission::rule7,
      LexleanMcpDraftAdmission::rule8,
      LexleanMcpDraftAdmission::rule9,
      breaksInv005
    ]
  },
  axioms: [Quot.sound, propext]
}
\end{semanticmodule}
\end{lexlean}
app/lexlean.toml 43 lines
spec = "lexlean/project/1"
name = "prism-lexlean-mcp-draft-admission"
language = "1.2"
module_prefix = "PrismLexleanMcpDraftAdmission"
source_roots = ["src"]
entrypoints = ["src/Architecture.lex.tex", "src/Compliance.lex.tex", "src/Design.lex.tex", "src/Features.lex.tex", "src/LexleanMcpDraftAdmission.lex.tex", "src/LexleanMcpDraftAdmissionProofs.lex.tex", "src/Quality.lex.tex", "src/Security.lex.tex"]
build_root = ".lexlean"
lockfile = "lexlean.lock"
lean_workspace = "."
lean_toolchain = "leanprover/lean4:v4.32.1"

[[lexicon_source]]
package = "lexlean.std.nat"
kind = "builtin"

[[lexicon_source]]
package = "prism.arch"
kind = "path"
path = "language/prism.arch"

[[lexicon_source]]
package = "prism.qual"
kind = "path"
path = "language/prism.qual"

[[lexicon_source]]
package = "prism.sec"
kind = "path"
path = "language/prism.sec"

[limits]
max_file_bytes = 4194304
max_total_source_bytes = 67108864
max_primitive_atoms = 2000000
max_token_lattice_edges = 4000000
max_parse_states = 4000000
max_ir_nodes = 2000000
max_scope_depth = 1024
max_import_depth = 128
max_diagnostics = 256
max_child_output_bytes = 16777216
child_timeout_ms = 300000
app/prompt.json 462 lines
{
  "schema": "prism/prompt/1",
  "pattern": "decisionTable",
  "goal": "Decide if LexLean MCP takes a draft from an AI model. No file path leaves its folders, and no draft goes over the owner's limits.",
  "repository": "UOR-Foundation/lexlean-mcp",
  "app": {
    "name": "lexlean-mcp-draft-admission",
    "title": "Draft admission",
    "purpose": "Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.",
    "limits": [
      "It does not read the rows: the path field is the refusal of the first row whose path admitPath refuses, or clean.",
      "The limits are the owner values draft.max_files 256 and draft.max_bytes 8388608 of OWNER-VALUES.md."
    ],
    "fields": [
      {
        "name": "path",
        "kind": "choice",
        "values": [
          "clean",
          "non-utf8",
          "non-nfc",
          "absolute",
          "empty-component",
          "dot-component",
          "dotdot-component",
          "outside-roots",
          "non-lex-tex"
        ],
        "means": "the first row's path refusal in admitPath's order: UTF-8, NFC, relative, no empty, . or .. component, under a source root, .lex.tex suffix; clean when every row passes"
      },
      {
        "name": "files",
        "kind": "number",
        "min": 0,
        "means": "rows in the draft"
      },
      {
        "name": "bytes",
        "kind": "number",
        "min": 0,
        "means": "content bytes of all rows, not counting path bytes"
      },
      {
        "name": "repeats",
        "kind": "number",
        "min": 0,
        "means": "paths that occur more than once among the rows, compared as octets"
      }
    ],
    "outcomes": [
      "admitted",
      "path-refused",
      "too-many-files",
      "too-many-bytes",
      "duplicate-path"
    ],
    "meanings": {
      "admitted": "Verdict.Admitted: the draft reaches LexLean",
      "path-refused": "Verdict.Refused with the row's path refusal, NotUtf8 to NotLexTex",
      "too-many-files": "Verdict.Refused TooManyFiles",
      "too-many-bytes": "Verdict.Refused TooManyBytes",
      "duplicate-path": "Verdict.Refused DuplicatePath"
    },
    "rules": [
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-utf8"
          }
        ],
        "then": "path-refused",
        "why": "src/Admission.lex.tex admitPath: a path that is not UTF-8 is NotUtf8"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-nfc"
          }
        ],
        "then": "path-refused",
        "why": "Admission.admitPath: a path not in NFC under Unicode 17.0.0 is NotNfc, decided by src/Nfc.lex.tex"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "absolute"
          }
        ],
        "then": "path-refused",
        "why": "Admission.admitPath: an absolute path is AbsolutePath"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "empty-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: an empty component is EmptyComponent"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dot-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: a . component is DotComponent"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dotdot-component"
          }
        ],
        "then": "path-refused",
        "why": "Admission.classifyBits: a .. component is DotDotComponent (admittedPathHasNoDotDot)"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "outside-roots"
          }
        ],
        "then": "path-refused",
        "why": "Admission.rootsStage: a path under no source root is OutsideRoots"
      },
      {
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "non-lex-tex"
          }
        ],
        "then": "path-refused",
        "why": "Admission.hasSuffix: a path without the .lex.tex suffix is NotLexTex"
      },
      {
        "when": [
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "too-many-files",
        "why": "Admission.filesStage: more rows than draft.max_files (OwnerValues.draftMaxFiles 256) is TooManyFiles"
      },
      {
        "when": [
          {
            "field": "bytes",
            "op": ">",
            "value": 8388608
          }
        ],
        "then": "too-many-bytes",
        "why": "Admission.bytesStage: more content bytes than draft.max_bytes (OwnerValues.draftMaxBytes 8388608) is TooManyBytes"
      },
      {
        "when": [
          {
            "field": "repeats",
            "op": ">=",
            "value": 1
          }
        ],
        "then": "duplicate-path",
        "why": "Admission.admitDraft: the duplicate scan runs last, on a draft the limits admit, and a repeated path is DuplicatePath"
      }
    ],
    "otherwise": "admitted",
    "otherwiseWhy": "Admission.admitDraft: every row's path is admitted, the draft is within both limits and no path repeats",
    "properties": [
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "dotdot-component"
          }
        ],
        "then": "admitted",
        "why": "Admission.admittedPathHasNoDotDot: an admitted path has no .. component"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "outside-roots"
          }
        ],
        "then": "admitted",
        "why": "risk R5 (path escape): no path outside the source roots is admitted"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "admitted",
        "why": "Admission: an admitted draft never has more rows than max_files"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "bytes",
            "op": ">",
            "value": 8388608
          }
        ],
        "then": "admitted",
        "why": "Admission: an admitted draft never has more content bytes than max_bytes"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "path",
            "op": "is",
            "value": "clean"
          },
          {
            "field": "files",
            "op": ">",
            "value": 256
          }
        ],
        "then": "duplicate-path",
        "why": "the duplicate scan runs only on a draft the limits admit"
      }
    ],
    "examples": [
      {
        "request": "clean 3 4200 0",
        "response": "admitted"
      },
      {
        "request": "dotdot-component 3 4200 0",
        "response": "path-refused"
      },
      {
        "request": "outside-roots 1 10 0",
        "response": "path-refused"
      },
      {
        "request": "clean 257 4200 0",
        "response": "too-many-files"
      },
      {
        "request": "clean 148 8388609 0",
        "response": "too-many-bytes"
      },
      {
        "request": "clean 148 5413010 1",
        "response": "duplicate-path"
      },
      {
        "request": "non-nfc 300 9000000 2",
        "response": "path-refused"
      },
      {
        "request": "clean 256 8388608 0",
        "response": "admitted"
      },
      {
        "request": "clean 3",
        "response": "invalid"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "LLM client",
      "text": "Submits drafts of LexLean modules through the MCP tools and needs each refusal to name what to fix.",
      "concerns": [
        "Correct answers",
        "Refused malformed requests"
      ]
    },
    {
      "name": "Server owner",
      "text": "Runs LexLean MCP on loopback and needs no draft to escape the source roots or exceed the owner-set limits.",
      "concerns": [
        "No path escapes the roots",
        "Proved guarantees"
      ]
    }
  ],
  "concerns": [
    {
      "name": "No path escapes the roots",
      "text": "No admitted draft has an absolute path, a .. component or a path outside the source roots.",
      "model": "security"
    }
  ],
  "components": [
    {
      "name": "LexLean MCP gateway",
      "text": "The gateway that serves the LexLean tools over MCP and admits a draft before the engine reads it.",
      "kind": "service"
    },
    {
      "name": "LexLean engine",
      "text": "LexLean v0.4.0, which checks, snapshots, formats and builds an admitted draft.",
      "kind": "externalSystem"
    },
    {
      "name": "Draft store",
      "text": "The store of lexlean-mcp/store/1, which keeps drafts for store.draft_retention.",
      "kind": "database"
    }
  ],
  "threats": [
    {
      "name": "Path escape",
      "text": "A draft row names ../ or an absolute path to write or read outside the source roots (risk R5).",
      "stride": "elevationOfPrivilege",
      "asset": "request",
      "likelihood": "high",
      "impact": "critical",
      "control": {
        "name": "Path admission",
        "text": "Absolute paths, .. components and paths outside the roots are refused, proved for every request.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv001Holds"
          },
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv002Holds"
          },
          {
            "kind": "gate",
            "reference": "lexlean-mcp crates/nfc-oracle admitRun SM-01"
          }
        ]
      }
    },
    {
      "name": "Oversized draft",
      "text": "A draft with very many rows or bytes exhausts the engine or the store.",
      "stride": "denialOfService",
      "asset": "request",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Owner-set limits",
        "text": "More than 256 rows or 8388608 content bytes is refused before the engine sees the draft.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv003Holds"
          },
          {
            "kind": "proof",
            "reference": "LexleanMcpDraftAdmissionProofs::inv004Holds"
          },
          {
            "kind": "review",
            "reference": "lexlean-mcp OWNER-VALUES.md OV-03"
          }
        ]
      }
    },
    {
      "name": "Look-alike path",
      "text": "Two paths that look the same but differ in Unicode normalization name two files a reviewer reads as one.",
      "stride": "spoofing",
      "asset": "source",
      "likelihood": "low",
      "impact": "major",
      "control": {
        "name": "NFC required",
        "text": "A path not in NFC under Unicode 17.0.0 is refused, so equal-looking paths compare as equal octets.",
        "evidence": [
          {
            "kind": "gate",
            "reference": "lexlean-mcp crates/nfc-oracle NF-01 to NF-15"
          }
        ]
      }
    },
    {
      "name": "Symbolic link escape",
      "text": "A row's path is clean but resolves through a symbolic link outside the roots once materialized.",
      "stride": "elevationOfPrivilege",
      "asset": "source",
      "likelihood": "low",
      "impact": "major",
      "accepted": "The symlink clause of control K5 is pending until materialization (issue 9) builds it; path admission is pure and sees no file system."
    }
  ],
  "quality": [
    {
      "characteristic": "Security",
      "subcharacteristic": "Resistance",
      "requirement": "No escaping path admitted",
      "text": "No request whose path is absolute, has a .. component or is outside the roots is admitted.",
      "measure": "Escaping admissions",
      "measureText": "Acceptance vectors answered admitted with path absolute, dotdot-component or outside-roots.",
      "threshold": 0
    },
    {
      "characteristic": "Functional suitability",
      "subcharacteristic": "Functional correctness",
      "requirement": "Every verdict matches admitDraft",
      "text": "Each vector answers the verdict admitDraftRun gives.",
      "measure": "Vectors that disagree",
      "measureText": "Acceptance vectors whose replayed verdict differs from the expected one.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "LLM client",
      "steps": [
        "REQ-002",
        "REQ-009",
        "REQ-011",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Server owner",
      "steps": [
        "REQ-006",
        "REQ-007",
        "INV-001",
        "INV-002",
        "refuse"
      ]
    }
  ],
  "license": "MIT OR Apache-2.0",
  "axioms": {}
}
model/ids.toml 71 lines
# model/ids.toml --- the conformance ID register.
#
# Every ID this repository claims, in one place, so that nothing is referenced
# without being defined. `CONFORMANCE.md` is generated from this file. A test
# whose name ends in an ID not listed here fails `check-model`, and an ID listed
# here with no scenario and no test fails it too (CM-02).
#
# `level` is the honesty level (R2):
#   some-true  a fact reproduced from an authority; not established here
#   build      constructed here and validated against its oracle
#   open       measured and reported, never asserted
#
# Every row here has a scenario in `features/suites/` and a test whose name ends
# in the ID, lowercased with underscores (R3, CM-02). There is no "pending"
# state: a capability that is not built does not get a row, and every row in this
# file is built.
#
# The first row is the template's own Prism application in `app/` (TC-01).
# A capability starts with a row here; `just new-capability` writes the row,
# its scenario and its failing test in the order `AGENTS.md` sets out.

spec = "template/1"

[[id]]
id = "LM-01"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The app never answers admitted when path is dotdot-component"

[[id]]
id = "LM-02"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The app never answers admitted when path is outside-roots"

[[id]]
id = "LM-03"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The app never answers admitted when files is above 256"

[[id]]
id = "LM-04"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The app never answers admitted when bytes is above 8388608"

[[id]]
id = "LM-05"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The app never answers duplicate-path when path is clean and files is above 256"

[[id]]
id = "LM-06"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references"

[[id]]
id = "LM-07"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared"

[[id]]
id = "LM-08"
level = "build"
suite = "lexlean_mcp_draft_admission"
statement = "Every compliance obligation is numbered in order and names its evidence"
features/suites/lexlean_mcp_draft_admission.feature 50 lines
Feature: lexlean_mcp_draft_admission

  This repository's Prism application, in app/, generated by prism-code from its
  spec: Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.

  @LM-01 @build
  Scenario: The app never answers admitted when path is dotdot-component
    Given the model in app/src/LexleanMcpDraftAdmission.lex.tex
    When the Lean kernel checks inv001Holds during prismpm verify
    Then no request meets breaksInv001

  @LM-02 @build
  Scenario: The app never answers admitted when path is outside-roots
    Given the model in app/src/LexleanMcpDraftAdmission.lex.tex
    When the Lean kernel checks inv002Holds during prismpm verify
    Then no request meets breaksInv002

  @LM-03 @build
  Scenario: The app never answers admitted when files is above 256
    Given the model in app/src/LexleanMcpDraftAdmission.lex.tex
    When the Lean kernel checks inv003Holds during prismpm verify
    Then no request meets breaksInv003

  @LM-04 @build
  Scenario: The app never answers admitted when bytes is above 8388608
    Given the model in app/src/LexleanMcpDraftAdmission.lex.tex
    When the Lean kernel checks inv004Holds during prismpm verify
    Then no request meets breaksInv004

  @LM-05 @build
  Scenario: The app never answers duplicate-path when path is clean and files is above 256
    Given the model in app/src/LexleanMcpDraftAdmission.lex.tex
    When the Lean kernel checks inv005Holds during prismpm verify
    Then no request meets breaksInv005
  @LM-06 @build
  Scenario: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
    Given the model in app/src/Architecture.lex.tex
    When the Lean kernel checks architectureDescriptionHolds during prismpm verify
    Then the architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
  @LM-07 @build
  Scenario: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
    Given the model in app/src/Quality.lex.tex
    When the Lean kernel checks qualityModelHolds during prismpm verify
    Then the ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
  @LM-08 @build
  Scenario: Every compliance obligation is numbered in order and names its evidence
    Given the model in app/src/Compliance.lex.tex
    When the Lean kernel checks everyObligationEvidenced during prismpm verify
    Then every compliance obligation is numbered in order and names its evidence
crates/conformance/tests/lexlean_mcp_draft_admission.rs 142 lines
//! The `lexlean_mcp_draft_admission` suite: one test per scenario in `features/suites/lexlean_mcp_draft_admission.feature`.
//!
//! Written by the Prism-DevRel builder from the app's prompt. The theorems are
//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.
//! What these tests hold fixed is what each theorem is about, so a weakened
//! statement that still verifies fails the gate.

use std::path::PathBuf;

fn root() -> PathBuf {
    PathBuf::from(env!("CARGO_MANIFEST_DIR"))
        .ancestors()
        .nth(2)
        .expect("crates/conformance is two below the root")
        .to_path_buf()
}

/// The body of the top-level declaration named `name`, up to its closing brace.
fn declaration<'a>(model: &'a str, name: &str) -> &'a str {
    let start = model
        .find(&format!("\n  name: {name},\n"))
        .unwrap_or_else(|| panic!("{name} is not declared"));
    let end = model[start..]
        .find("\n}\n")
        .unwrap_or_else(|| panic!("{name} is not closed"));
    &model[start..start + end]
}

fn module(path: &str) -> String {
    std::fs::read_to_string(root().join(path)).expect("the module")
}

/// The condition no request may meet, and the theorem that says none does.
fn pinned(breaks: &str, condition: &str, theorem: &str) {
    let model = module("app/src/LexleanMcpDraftAdmissionProofs.lex.tex");
    let found = declaration(&model, breaks);
    assert!(
        found.contains(condition),
        "the condition of {breaks} changed:\n{found}"
    );
    let holds = declaration(&model, theorem);
    let statement = format!("statement: (({breaks} request) = false),");
    assert!(
        holds.contains(&statement),
        "{theorem} must state that no request meets {breaks}:\n{holds}"
    );
}

/// A facet theorem: proved by `decide`, about exactly this predicate.
fn holds(path: &str, theorem: &str, statement: &str) {
    let model = module(path);
    let found = declaration(&model, theorem);
    assert!(
        found.contains(&format!("statement: {statement},")),
        "{theorem} must state {statement}:\n{found}"
    );
    assert!(
        found.contains("proof: decide{}"),
        "{theorem} is proved by decide"
    );
}

/// `LM-01`: The app never answers admitted when path is dotdot-component
#[test]
fn lexlean_mcp_draft_admission_lm_01() {
    pinned(
        "breaksInv001",
        "body: ((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathDotdotComponent))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))",
        "inv001Holds",
    );
}

/// `LM-02`: The app never answers admitted when path is outside-roots
#[test]
fn lexlean_mcp_draft_admission_lm_02() {
    pinned(
        "breaksInv002",
        "body: ((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathOutsideRoots))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))",
        "inv002Holds",
    );
}

/// `LM-03`: The app never answers admitted when files is above 256
#[test]
fn lexlean_mcp_draft_admission_lm_03() {
    pinned(
        "breaksInv003",
        "body: ((((project request path) <? 9) && (256 <? (project request files))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))",
        "inv003Holds",
    );
}

/// `LM-04`: The app never answers admitted when bytes is above 8388608
#[test]
fn lexlean_mcp_draft_admission_lm_04() {
    pinned(
        "breaksInv004",
        "body: ((((project request path) <? 9) && (8388608 <? (project request bytes))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerAdmitted)))",
        "inv004Holds",
    );
}

/// `LM-05`: The app never answers duplicate-path when path is clean and files is above 256
#[test]
fn lexlean_mcp_draft_admission_lm_05() {
    pinned(
        "breaksInv005",
        "body: (((((project request path) <? 9) && ((project request path) =? (LexleanMcpDraftAdmission::pathClean))) && (256 <? (project request files))) && ((LexleanMcpDraftAdmission::judge request) =? (LexleanMcpDraftAdmission::answerDuplicatePath)))",
        "inv005Holds",
    );
}

/// `LM-06`: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
#[test]
fn lexlean_mcp_draft_admission_lm_06() {
    holds(
        "app/src/Architecture.lex.tex",
        "architectureDescriptionHolds",
        "((architectureValid) = true)",
    );
}

/// `LM-07`: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
#[test]
fn lexlean_mcp_draft_admission_lm_07() {
    holds(
        "app/src/Quality.lex.tex",
        "qualityModelHolds",
        "((qualityValid) = true)",
    );
}

/// `LM-08`: Every compliance obligation is numbered in order and names its evidence
#[test]
fn lexlean_mcp_draft_admission_lm_08() {
    holds(
        "app/src/Compliance.lex.tex",
        "everyObligationEvidenced",
        "((obligationsEvidenced 0 (obligations)) = true)",
    );
}
site/app.json 126 lines
{
  "name": "Draft admission",
  "shortName": "Draft",
  "live": "https://uor-foundation.github.io/lexlean-mcp/",
  "purpose": "Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path. Send path, files, bytes or repeats, separated by spaces; it answers admitted, path-refused, too-many-files, too-many-bytes or duplicate-path, and invalid request for anything else.",
  "inputLabel": "Request: path files bytes repeats",
  "placeholder": "clean 3 4200 0",
  "submitLabel": "Decide",
  "outputLabel": "Answer",
  "answers": {
    "positive": [
      "admitted"
    ],
    "negative": [
      "path-refused",
      "too-many-files",
      "too-many-bytes",
      "duplicate-path"
    ],
    "refusal": "invalid request"
  },
  "promise": {
    "headline": "Says conformant exactly when every policy file matches its lock.",
    "detail": "Each of the six universal policy files is compared with the digest the lock records, and any file that drifted is named."
  },
  "claim": "LM-01: the app never answers admitted when path is dotdot-component. LM-02: the app never answers admitted when path is outside-roots. LM-03: the app never answers admitted when files is above 256. LM-04: the app never answers admitted when bytes is above 8388608. LM-05: the app never answers duplicate-path when path is clean and files is above 256.",
  "proposition": {
    "name": "judge",
    "text": "judge request :=\n  path is non-utf8 → path-refused\n  path is non-nfc → path-refused\n  path is absolute → path-refused\n  path is empty-component → path-refused\n  path is dot-component → path-refused\n  path is dotdot-component → path-refused\n  path is outside-roots → path-refused\n  path is non-lex-tex → path-refused\n  files is above 256 → too-many-files\n  bytes is above 8388608 → too-many-bytes\n  repeats is at least 1 → duplicate-path\n  otherwise → admitted",
    "plain": "Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path."
  },
  "theorems": [
    {
      "name": "inv001Holds",
      "statement": "no request meets breaksInv001: the app never answers admitted when path is dotdot-component",
      "how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
      "where": "app/src/LexleanMcpDraftAdmissionProofs.lex.tex"
    },
    {
      "name": "inv002Holds",
      "statement": "no request meets breaksInv002: the app never answers admitted when path is outside-roots",
      "how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
      "where": "app/src/LexleanMcpDraftAdmissionProofs.lex.tex"
    },
    {
      "name": "inv003Holds",
      "statement": "no request meets breaksInv003: the app never answers admitted when files is above 256",
      "how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
      "where": "app/src/LexleanMcpDraftAdmissionProofs.lex.tex"
    },
    {
      "name": "inv004Holds",
      "statement": "no request meets breaksInv004: the app never answers admitted when bytes is above 8388608",
      "how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
      "where": "app/src/LexleanMcpDraftAdmissionProofs.lex.tex"
    },
    {
      "name": "inv005Holds",
      "statement": "no request meets breaksInv005: the app never answers duplicate-path when path is clean and files is above 256",
      "how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
      "where": "app/src/LexleanMcpDraftAdmissionProofs.lex.tex"
    }
  ],
  "pinned": [
    {
      "name": "lexlean_mcp_draft_admission_lm_01",
      "what": "LM-01's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
      "where": "crates/conformance/tests/lexlean_mcp_draft_admission.rs"
    },
    {
      "name": "lexlean_mcp_draft_admission_lm_02",
      "what": "LM-02's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
      "where": "crates/conformance/tests/lexlean_mcp_draft_admission.rs"
    },
    {
      "name": "lexlean_mcp_draft_admission_lm_03",
      "what": "LM-03's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
      "where": "crates/conformance/tests/lexlean_mcp_draft_admission.rs"
    },
    {
      "name": "lexlean_mcp_draft_admission_lm_04",
      "what": "LM-04's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
      "where": "crates/conformance/tests/lexlean_mcp_draft_admission.rs"
    },
    {
      "name": "lexlean_mcp_draft_admission_lm_05",
      "what": "LM-05's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
      "where": "crates/conformance/tests/lexlean_mcp_draft_admission.rs"
    }
  ],
  "trusted": [
    {
      "name": "SDK image",
      "value": "the digest prismpm.lock pins; see the bootstrap workflow's log"
    },
    {
      "name": "Lean toolchain",
      "value": "leanprover/lean4:v4.32.1"
    },
    {
      "name": "LexLean compiler semantics",
      "value": "5262e5b4c8b5668ae7066ad686757a6bb7f80c941d515fb9d586894fbc7de69a"
    },
    {
      "name": "prism-code runtime, vendored",
      "value": "0.2.0, see try/vendor/prism-code/VENDOR.md"
    },
    {
      "name": "Your browser",
      "value": "runs the WebAssembly guest and this page"
    }
  ],
  "attestations": {
    "proof": {
      "id": "not recorded: the proof ran in the SDK image, not on the UOR MCP server",
      "url": "https://github.com/UOR-Foundation/lexlean-mcp/actions/workflows/bootstrap.yml"
    },
    "build": {
      "id": "printed by prismpm verify in every pages run",
      "url": "https://github.com/UOR-Foundation/lexlean-mcp/actions/workflows/pages.yml"
    }
  },
  "repository": "https://github.com/UOR-Foundation/lexlean-mcp",
  "report": "https://github.com/UOR-Foundation/lexlean-mcp/blob/main/TEMPLATE-VERIFICATION.md"
}
openspec/specs/lexlean-mcp-draft-admission/spec.md 270 lines
# lexlean-mcp-draft-admission Specification

<!-- Generated by Prism from prism/spec.json. Change the app through your agent with /prism, not by editing this file. -->

## Purpose

Draft admission: Decide whether a draft is admitted or which refusal it gets, in the order admitDraft decides: the first path refusal among its rows, too many files, too many content bytes, then a duplicate path.

## Requirements

### Requirement: Never admitted when path is dotdot-component

The app SHALL NOT answer `admitted` when path is dotdot-component, because Admission.admittedPathHasNoDotDot: an admitted path has no .. component.

Verified: to be proved by Lean for every request (INV-001, theorem `inv001Holds`).

#### Scenario: INV-001 holds

- **WHEN** the request is `dotdot-component 3 4200 0` (an acceptance example)
- **THEN** the answer SHALL NOT be `admitted`
- **AND** the app answers `path-refused`, decided by REQ-006

### Requirement: Never admitted when path is outside-roots

The app SHALL NOT answer `admitted` when path is outside-roots, because risk R5 (path escape): no path outside the source roots is admitted.

Verified: to be proved by Lean for every request (INV-002, theorem `inv002Holds`).

#### Scenario: INV-002 holds

- **WHEN** the request is `outside-roots 1 10 0` (an acceptance example)
- **THEN** the answer SHALL NOT be `admitted`
- **AND** the app answers `path-refused`, decided by REQ-007

### Requirement: Never admitted when files is above 256

The app SHALL NOT answer `admitted` when files is above 256, because Admission: an admitted draft never has more rows than max_files.

Verified: to be proved by Lean for every request (INV-003, theorem `inv003Holds`).

#### Scenario: INV-003 holds

- **WHEN** the request is `clean 257 4200 0` (an acceptance example)
- **THEN** the answer SHALL NOT be `admitted`
- **AND** the app answers `too-many-files`, decided by REQ-009

### Requirement: Never admitted when bytes is above 8388608

The app SHALL NOT answer `admitted` when bytes is above 8388608, because Admission: an admitted draft never has more content bytes than max_bytes.

Verified: to be proved by Lean for every request (INV-004, theorem `inv004Holds`).

#### Scenario: INV-004 holds

- **WHEN** the request is `clean 148 8388609 0` (an acceptance example)
- **THEN** the answer SHALL NOT be `admitted`
- **AND** the app answers `too-many-bytes`, decided by REQ-010

### Requirement: Never duplicate-path when path is clean and files is above 256

The app SHALL NOT answer `duplicate-path` when path is clean and files is above 256, because the duplicate scan runs only on a draft the limits admit.

Verified: to be proved by Lean for every request (INV-005, theorem `inv005Holds`).

#### Scenario: INV-005 holds

- **WHEN** the request is `clean 257 4200 0` (an acceptance example)
- **THEN** the answer SHALL NOT be `duplicate-path`
- **AND** the app answers `too-many-files`, decided by REQ-009

### Requirement: REQ-001 path-refused when path is non-utf8

The app SHALL answer `path-refused` when path is non-utf8, because src/Admission.lex.tex admitPath: a path that is not UTF-8 is NotUtf8.

Verified: tested by the acceptance vectors (`rule1`).

#### Scenario: REQ-001 decides

- **WHEN** the request is `non-utf8 0 0 0`
- **THEN** the answer SHALL be `path-refused`, decided by REQ-001

### Requirement: REQ-002 path-refused when path is non-nfc

The app SHALL answer `path-refused` when path is non-nfc and no earlier rule matches, because Admission.admitPath: a path not in NFC under Unicode 17.0.0 is NotNfc, decided by src/Nfc.lex.tex.

Verified: tested by the acceptance vectors (`rule2`).

#### Scenario: REQ-002 decides

- **WHEN** the request is `non-nfc 300 9000000 2` (an acceptance example)
- **THEN** the answer SHALL be `path-refused`, decided by REQ-002

### Requirement: REQ-003 path-refused when path is absolute

The app SHALL answer `path-refused` when path is absolute and no earlier rule matches, because Admission.admitPath: an absolute path is AbsolutePath.

Verified: tested by the acceptance vectors (`rule3`).

#### Scenario: REQ-003 decides

- **WHEN** the request is `absolute 0 0 0`
- **THEN** the answer SHALL be `path-refused`, decided by REQ-003

### Requirement: REQ-004 path-refused when path is empty-component

The app SHALL answer `path-refused` when path is empty-component and no earlier rule matches, because Admission.classifyBits: an empty component is EmptyComponent.

Verified: tested by the acceptance vectors (`rule4`).

#### Scenario: REQ-004 decides

- **WHEN** the request is `empty-component 0 0 0`
- **THEN** the answer SHALL be `path-refused`, decided by REQ-004

### Requirement: REQ-005 path-refused when path is dot-component

The app SHALL answer `path-refused` when path is dot-component and no earlier rule matches, because Admission.classifyBits: a . component is DotComponent.

Verified: tested by the acceptance vectors (`rule5`).

#### Scenario: REQ-005 decides

- **WHEN** the request is `dot-component 0 0 0`
- **THEN** the answer SHALL be `path-refused`, decided by REQ-005

### Requirement: REQ-006 path-refused when path is dotdot-component

The app SHALL answer `path-refused` when path is dotdot-component and no earlier rule matches, because Admission.classifyBits: a .. component is DotDotComponent (admittedPathHasNoDotDot).

Verified: tested by the acceptance vectors (`rule6`).

#### Scenario: REQ-006 decides

- **WHEN** the request is `dotdot-component 3 4200 0` (an acceptance example)
- **THEN** the answer SHALL be `path-refused`, decided by REQ-006

### Requirement: REQ-007 path-refused when path is outside-roots

The app SHALL answer `path-refused` when path is outside-roots and no earlier rule matches, because Admission.rootsStage: a path under no source root is OutsideRoots.

Verified: tested by the acceptance vectors (`rule7`).

#### Scenario: REQ-007 decides

- **WHEN** the request is `outside-roots 1 10 0` (an acceptance example)
- **THEN** the answer SHALL be `path-refused`, decided by REQ-007

### Requirement: REQ-008 path-refused when path is non-lex-tex

The app SHALL answer `path-refused` when path is non-lex-tex and no earlier rule matches, because Admission.hasSuffix: a path without the .lex.tex suffix is NotLexTex.

Verified: tested by the acceptance vectors (`rule8`).

#### Scenario: REQ-008 decides

- **WHEN** the request is `non-lex-tex 0 0 0`
- **THEN** the answer SHALL be `path-refused`, decided by REQ-008

### Requirement: REQ-009 too-many-files when files is above 256

The app SHALL answer `too-many-files` when files is above 256 and no earlier rule matches, because Admission.filesStage: more rows than draft.max_files (OwnerValues.draftMaxFiles 256) is TooManyFiles.

Verified: tested by the acceptance vectors (`rule9`).

#### Scenario: REQ-009 decides

- **WHEN** the request is `clean 257 4200 0` (an acceptance example)
- **THEN** the answer SHALL be `too-many-files`, decided by REQ-009

### Requirement: REQ-010 too-many-bytes when bytes is above 8388608

The app SHALL answer `too-many-bytes` when bytes is above 8388608 and no earlier rule matches, because Admission.bytesStage: more content bytes than draft.max_bytes (OwnerValues.draftMaxBytes 8388608) is TooManyBytes.

Verified: tested by the acceptance vectors (`rule10`).

#### Scenario: REQ-010 decides

- **WHEN** the request is `clean 148 8388609 0` (an acceptance example)
- **THEN** the answer SHALL be `too-many-bytes`, decided by REQ-010

### Requirement: REQ-011 duplicate-path when repeats is at least 1

The app SHALL answer `duplicate-path` when repeats is at least 1 and no earlier rule matches, because Admission.admitDraft: the duplicate scan runs last, on a draft the limits admit, and a repeated path is DuplicatePath.

Verified: tested by the acceptance vectors (`rule11`).

#### Scenario: REQ-011 decides

- **WHEN** the request is `clean 148 5413010 1` (an acceptance example)
- **THEN** the answer SHALL be `duplicate-path`, decided by REQ-011

### Requirement: Otherwise admitted

The app SHALL answer `admitted` when no rule matches, because Admission.admitDraft: every row's path is admitted, the draft is within both limits and no path repeats.

Verified: tested by the acceptance vectors.

#### Scenario: No rule matches

- **WHEN** the request is `clean 3 4200 0` (an acceptance example)
- **THEN** the answer SHALL be `admitted`

### Requirement: The first matching rule decides

The app SHALL try REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-006, REQ-007, REQ-008, REQ-009, REQ-010, REQ-011 in that order, and the first rule that matches SHALL decide.

Verified: tested by the acceptance vectors.

#### Scenario: Two rules match

- **WHEN** the request is `non-nfc 300 9000000 2` (an acceptance example)
- **THEN** the answer SHALL be `path-refused`, decided by REQ-002, the earlier rule

### Requirement: Request and answers

The app SHALL read one request as one line of 4 fields separated by single spaces, in this order, and SHALL answer exactly one of `admitted`, `path-refused`, `too-many-files`, `too-many-bytes`, `duplicate-path`, or `invalid` for anything else.

| Field | Accepts | Means |
| --- | --- | --- |
| `path` | `clean`, `non-utf8`, `non-nfc`, `absolute`, `empty-component`, `dot-component`, `dotdot-component`, `outside-roots`, `non-lex-tex` | the first row's path refusal in admitPath's order: UTF-8, NFC, relative, no empty, . or .. component, under a source root, .lex.tex suffix; clean when every row passes |
| `files` | whole number from 0 | rows in the draft |
| `bytes` | whole number from 0 | content bytes of all rows, not counting path bytes |
| `repeats` | whole number from 0 | paths that occur more than once among the rows, compared as octets |

| Answer | Means |
| --- | --- |
| `admitted` | Verdict.Admitted: the draft reaches LexLean |
| `path-refused` | Verdict.Refused with the row's path refusal, NotUtf8 to NotLexTex |
| `too-many-files` | Verdict.Refused TooManyFiles |
| `too-many-bytes` | Verdict.Refused TooManyBytes |
| `duplicate-path` | Verdict.Refused DuplicatePath |
| `invalid` | the request is malformed |

Verified: reading a request is tested, not proved.

#### Scenario: A malformed request is invalid

- **WHEN** the request is not 4 fields in this order
- **THEN** the answer SHALL be `invalid`

## Out of scope

- It does not read the rows: the path field is the refusal of the first row whose path admitPath refuses, or clean.
- The limits are the owner values draft.max_files 256 and draft.max_bytes 8388608 of OWNER-VALUES.md.

## Examples

- `clean 3 4200 0` gives `admitted`
- `dotdot-component 3 4200 0` gives `path-refused`
- `outside-roots 1 10 0` gives `path-refused`
- `clean 257 4200 0` gives `too-many-files`
- `clean 148 8388609 0` gives `too-many-bytes`
- `clean 148 5413010 1` gives `duplicate-path`
- `non-nfc 300 9000000 2` gives `path-refused`
- `clean 256 8388608 0` gives `admitted`
- `clean 3` gives `invalid`

## What is proved and what is tested

Lean proves each property marked proved above, for every request that decodes, with no exceptions and no sampling. The proof is about `judge`, the function the WebAssembly guest runs, because both come from the same model.

The parsing of requests is tested, not proved: the acceptance vectors in the app replay through the built guest, including malformed and oversized requests.

Nothing here says the rules are the right rules. That is the part only you can judge.

## Files

- `prism/spec.json` is this spec as data.
- `src/LexleanMcpDraftAdmission.lex.tex` is the LexLean model generated from it. It is the single source of the app.

how-to guideBuildexampleMarkdown

Words on this page 8
record
One entry in a facet: a component, a threat, a measure or a journey step, with the place in the source it came from.
LexLean
The language Prism models are written in. It reads like LaTeX and compiles to Lean 4.
Lean kernel
The small checker at the heart of the Lean prover. It accepts a proof only if every step follows the rules.
theorem
A statement about the model that the Lean kernel has checked, so it holds for every input, not only the ones tested.
SDK
Software development kit. Here, the PrismPM container image that builds, checks and verifies Prism models.
stakeholder
A person or group with an interest in the system, as ISO/IEC/IEEE 42010 defines it.
MCP
Model Context Protocol: an open protocol through which AI agents call tools such as the Prism builder.
decision table
A table of rules, as in OMG DMN 1.5: each row says which inputs lead to which outcome.