PrismDevRelOpen the app
Examples: JCS NFC 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

JCS NFC admission

Give the one refusal code for a broken JSON document, or let it through. Then every tool refuses the same input with the same code.

Inspired by UOR-Foundation/uor-jcs-nfc. A JSON digest context: RFC 8785 with integer-only admission, NFC before member sort, collision refusal and a pinned sha256 representation.

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 JCS NFC admission app does1. Request: bom, utf8, parse, names, surrogate 2. 10 rules: the first that matches wins 3. Answer: addressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate, e-nfc-collision 4. Proved: 4 theorems, 40 tests01Requestbom, utf8, parse,names, surrogate0210 rulesthe first thatmatches wins03Answeraddressed, e-bom,e-utf8, e-json,e-num-token,e-num-range,e-constant,e-trailing,e-dup-name,e-surrogate,e-nfc-collision04Proved4 theorems, 40testsWhat the JCS NFC admission app does1. Request: bom, utf8, parse, names, surrogate 2. 10 rules: the first that matches wins 3. Answer: addressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate, e-nfc-collision 4. Proved: 4 theorems, 40 tests01Requestbom, utf8, parse, names,surrogate0210 rulesthe first that matches wins03Answeraddressed, e-bom, e-utf8, e-json,e-num-token, e-num-range,e-constant, e-trailing,e-dup-name, e-surrogate,e-nfc-collision04Proved4 theorems, 40 tests
What the JCS NFC 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. Requestbom, utf8, parse, names, surrogate
2. 10 rulesthe first that matches wins
3. Answeraddressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate, e-nfc-collision
4. Proved4 theorems, 40 tests
Fingerprint
e6faeb7b37c054196bcc12f7b2351bbf9e29e8416e4d432b7c65b66c63c67fd2
Acceptance vectors
40
Claims
7

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 420 lines
{
  "schema": "prism/prompt/1",
  "pattern": "decisionTable",
  "goal": "Give the one refusal code for a broken JSON document, or let it through. Then every tool refuses the same input with the same code.",
  "repository": "UOR-Foundation/uor-jcs-nfc",
  "license": "Apache-2.0",
  "app": {
    "name": "jcs-nfc-admission",
    "title": "JCS NFC admission",
    "purpose": "Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest.",
    "fields": [
      {
        "name": "bom",
        "kind": "choice",
        "values": [
          "absent",
          "present"
        ],
        "means": "whether the bytes start with EF BB BF"
      },
      {
        "name": "utf8",
        "kind": "choice",
        "values": [
          "valid",
          "invalid"
        ],
        "means": "whether the bytes are well-formed UTF-8, raw surrogates included as invalid"
      },
      {
        "name": "parse",
        "kind": "choice",
        "values": [
          "ok",
          "json",
          "number-token",
          "number-range",
          "constant",
          "trailing"
        ],
        "means": "the first parse-time finding in input order, then trailing content after the top-level value"
      },
      {
        "name": "names",
        "kind": "choice",
        "values": [
          "distinct",
          "duplicate",
          "colliding"
        ],
        "means": "member names: distinct, duplicate after escape decoding, or distinct but colliding after NFC"
      },
      {
        "name": "surrogate",
        "kind": "choice",
        "values": [
          "none",
          "lone"
        ],
        "means": "whether an escaped unpaired surrogate is reached"
      }
    ],
    "outcomes": [
      "addressed",
      "e-bom",
      "e-utf8",
      "e-json",
      "e-num-token",
      "e-num-range",
      "e-constant",
      "e-trailing",
      "e-dup-name",
      "e-surrogate",
      "e-nfc-collision"
    ],
    "meanings": {
      "addressed": "admitted, canonicalized and digested as sha256:<hex>",
      "e-bom": "E_BOM, leading byte-order mark",
      "e-utf8": "E_UTF8, not well-formed UTF-8",
      "e-json": "E_JSON, malformed JSON",
      "e-num-token": "E_NUM_TOKEN, number token outside -?(0|[1-9][0-9]*)",
      "e-num-range": "E_NUM_RANGE, integer outside plus or minus 9007199254740991",
      "e-constant": "E_CONSTANT, NaN, Infinity or another non-standard constant",
      "e-trailing": "E_TRAILING, content after the top-level value",
      "e-dup-name": "E_DUP_NAME, duplicate member name",
      "e-surrogate": "E_SURROGATE, escaped lone surrogate",
      "e-nfc-collision": "E_NFC_COLLISION, member names collide after NFC, never merged"
    },
    "rules": [
      {
        "when": [
          {
            "field": "bom",
            "op": "is",
            "value": "present"
          }
        ],
        "then": "e-bom",
        "why": "SPEC.md 3.2 and 3.9: E_BOM is a byte-level check before parsing and comes first"
      },
      {
        "when": [
          {
            "field": "utf8",
            "op": "is",
            "value": "invalid"
          }
        ],
        "then": "e-utf8",
        "why": "SPEC.md 3.1 and 3.9: E_UTF8 follows E_BOM"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "json"
          }
        ],
        "then": "e-json",
        "why": "SPEC.md 3.9: parse-time codes fire in input order"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-token"
          }
        ],
        "then": "e-num-token",
        "why": "SPEC.md 3.5: tokens such as 1.0 and 1e0 are refused as text"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-range"
          }
        ],
        "then": "e-num-range",
        "why": "SPEC.md 3.5: values outside the safe-integer bound are refused"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "constant"
          }
        ],
        "then": "e-constant",
        "why": "SPEC.md 3.6: NaN and Infinity are refused"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "trailing"
          }
        ],
        "then": "e-trailing",
        "why": "SPEC.md 3.3 and 3.9: the remainder check follows the parse-time codes"
      },
      {
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "duplicate"
          }
        ],
        "then": "e-dup-name",
        "why": "SPEC.md 3.4 and 3.9: duplicates after escape decoding, a post-parse scan"
      },
      {
        "when": [
          {
            "field": "surrogate",
            "op": "is",
            "value": "lone"
          }
        ],
        "then": "e-surrogate",
        "why": "SPEC.md 3.7 and 3.9: E_SURROGATE follows E_DUP_NAME"
      },
      {
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "colliding"
          }
        ],
        "then": "e-nfc-collision",
        "why": "SPEC.md 4.1 and 4.3: NFC precedes member sort, and post-normalization collisions are refused in canonicalization, after admission"
      }
    ],
    "otherwise": "addressed",
    "otherwiseWhy": "SPEC.md 5 and uor_jcs_nfc_ref.py address_json: an admitted, canonicalized document is digested",
    "properties": [
      {
        "kind": "always",
        "when": [
          {
            "field": "bom",
            "op": "is",
            "value": "present"
          }
        ],
        "then": "e-bom",
        "why": "one malformed input receives one code, and E_BOM has precedence"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "colliding"
          }
        ],
        "then": "addressed",
        "why": "a collision is never resolved by last-write-wins, first-write-wins or merging"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-token"
          }
        ],
        "then": "addressed",
        "why": "an integral value such as 1.0 is still refused"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "surrogate",
            "op": "is",
            "value": "lone"
          }
        ],
        "then": "addressed",
        "why": "a lone escaped surrogate is never digested"
      }
    ],
    "examples": [
      {
        "request": "absent valid ok distinct none",
        "response": "addressed"
      },
      {
        "request": "present invalid json duplicate lone",
        "response": "e-bom"
      },
      {
        "request": "absent invalid ok distinct none",
        "response": "e-utf8"
      },
      {
        "request": "absent valid number-token distinct none",
        "response": "e-num-token"
      },
      {
        "request": "absent valid trailing duplicate none",
        "response": "e-trailing"
      },
      {
        "request": "absent valid ok duplicate lone",
        "response": "e-dup-name"
      },
      {
        "request": "absent valid ok colliding lone",
        "response": "e-surrogate"
      },
      {
        "request": "absent valid ok colliding none",
        "response": "e-nfc-collision"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "Context implementer",
      "text": "Writes an implementation of the digest context and needs the same refusal code as every other implementation for every input.",
      "concerns": [
        "Correct answers",
        "Proved guarantees"
      ]
    },
    {
      "name": "Registry maintainer",
      "text": "Cites the context's final corpus in a registry entry and needs no inadmissible document to receive an address.",
      "concerns": [
        "Proved guarantees",
        "Refused malformed requests"
      ]
    }
  ],
  "components": [
    {
      "name": "Reference implementation",
      "text": "uor_jcs_nfc_ref.py, admit and canonicalize written from SPEC.md.",
      "kind": "cliAdapter"
    },
    {
      "name": "Conformance corpus",
      "text": "conformance/uor-jcs-nfc-vectors-v0.1-rc5.json and its mutation suite run_mutants.py.",
      "kind": "externalSystem"
    }
  ],
  "threats": [
    {
      "name": "Merged colliding names",
      "text": "An implementation merges members whose names collide after NFC, giving two documents one address.",
      "stride": "tampering",
      "asset": "answer",
      "likelihood": "medium",
      "impact": "critical",
      "control": {
        "name": "Collision refusal",
        "text": "Colliding names are refused, never addressed.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "JcsNfcAdmissionProofs::inv002Holds"
          },
          {
            "kind": "gate",
            "reference": "UOR-Foundation/uor-jcs-nfc conformance/run_mutants.py"
          }
        ]
      }
    },
    {
      "name": "Integral float admitted",
      "text": "A type-based guard admits 1.0 or 2^53 as a float with an integral value.",
      "stride": "tampering",
      "asset": "request",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Lexical number admission",
        "text": "Number tokens are validated as text.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "JcsNfcAdmissionProofs::inv003Holds"
          },
          {
            "kind": "review",
            "reference": "UOR-Foundation/uor-jcs-nfc SPEC.md 8 mutation probes"
          }
        ]
      }
    },
    {
      "name": "Different Unicode database",
      "text": "NFC under a Unicode version other than 15.0.0 normalizes differently and yields another digest.",
      "stride": "tampering",
      "asset": "source",
      "likelihood": "medium",
      "impact": "major",
      "accepted": "The app takes the collision finding as given; SPEC.md 1.3 pins Unicode 15.0.0, and gen_vectors.py refuses any other runtime."
    }
  ],
  "quality": [
    {
      "characteristic": "Compatibility",
      "subcharacteristic": "Interoperability",
      "requirement": "One code per input",
      "text": "Every malformed combination receives exactly one of the ten refusal codes SPEC.md 3.8 and 4.3 define.",
      "measure": "Refusal codes",
      "measureText": "Distinct refusal codes the app answers.",
      "threshold": 10
    },
    {
      "characteristic": "Security",
      "subcharacteristic": "Integrity",
      "requirement": "No refused document addressed",
      "text": "No document with any refusal finding receives an address.",
      "measure": "Addressed refusals",
      "measureText": "Acceptance vectors with a refusal finding answered addressed.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "Context implementer",
      "steps": [
        "REQ-001",
        "REQ-002",
        "REQ-003",
        "REQ-007",
        "REQ-008",
        "REQ-009",
        "REQ-010",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Registry maintainer",
      "steps": [
        "INV-001",
        "INV-002",
        "INV-003",
        "INV-004",
        "refuse"
      ]
    }
  ],
  "concerns": [],
  "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 FIRSTaddressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate, e-nfc-collision
Rules for each answeraddressed: 0 rules; e-bom: 1 rules; e-utf8: 1 rules; e-json: 1 rules; e-num-token: 1 rules; e-num-range: 1 rules; e-constant: 1 rules; e-trailing: 1 rules; e-dup-name: 1 rules; e-surrogate: 1 rules; e-nfc-collision: 1 rulesaddressed0 + defaulte-bom1e-utf81e-json1e-num-token1e-num-range1e-constant1e-trailing1e-dup-name1e-surrogate1e-nfc-collision1
Rules for each answer. Each bar counts the rules that give one answer. When no rule matches, the answer is addressed.
The data in this figure
rules
addressed0
e-bom1
e-utf81
e-json1
e-num-token1
e-num-range1
e-constant1
e-trailing1
e-dup-name1
e-surrogate1
e-nfc-collision1

Behavior

A request is bom, utf8, parse, names, surrogate, separated by spaces. The first rule that matches decides. If none matches, the answer is addressed. A request over 136 bytes, or in any other form, is answered invalid.

Behavior 11 rows
RuleWhenAnswerWhy
REQ-001bom is presente-bomSPEC.md 3.2 and 3.9: E_BOM is a byte-level check before parsing and comes first
REQ-002utf8 is invalide-utf8SPEC.md 3.1 and 3.9: E_UTF8 follows E_BOM
REQ-003parse is jsone-jsonSPEC.md 3.9: parse-time codes fire in input order
REQ-004parse is number-tokene-num-tokenSPEC.md 3.5: tokens such as 1.0 and 1e0 are refused as text
REQ-005parse is number-rangee-num-rangeSPEC.md 3.5: values outside the safe-integer bound are refused
REQ-006parse is constante-constantSPEC.md 3.6: NaN and Infinity are refused
REQ-007parse is trailinge-trailingSPEC.md 3.3 and 3.9: the remainder check follows the parse-time codes
REQ-008names is duplicatee-dup-nameSPEC.md 3.4 and 3.9: duplicates after escape decoding, a post-parse scan
REQ-009surrogate is lonee-surrogateSPEC.md 3.7 and 3.9: E_SURROGATE follows E_DUP_NAME
REQ-010names is collidinge-nfc-collisionSPEC.md 4.1 and 4.3: NFC precedes member sort, and post-normalization collisions are refused in canonicalization, after admission
otherwiseno rule matchesaddressedSPEC.md 5 and uor_jcs_nfc_ref.py address_json: an admitted, canonicalized document is digested

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.

PropertyStatementTheoremWhy
INV-001It always answers e-bom when bom is present.JcsNfcAdmissionProofs::inv001Holdsone malformed input receives one code, and E_BOM has precedence
INV-002It never answers addressed when names is colliding.JcsNfcAdmissionProofs::inv002Holdsa collision is never resolved by last-write-wins, first-write-wins or merging
INV-003It never answers addressed when parse is number-token.JcsNfcAdmissionProofs::inv003Holdsan integral value such as 1.0 is still refused
INV-004It never answers addressed when surrogate is lone.JcsNfcAdmissionProofs::inv004Holdsa lone escaped surrogate is never digested

Architecture

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

StakeholderWho they areConcerns
Context implementerWrites an implementation of the digest context and needs the same refusal code as every other implementation for every input.Correct answers, Proved guarantees
Registry maintainerCites the context's final corpus in a registry entry and needs no inadmissible document to receive an address.Proved guarantees, Refused malformed requests
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 addressed 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
Proved guaranteesEach of the 4 properties of the spec holds for every request, proved by the Lean kernel.quality
Refused malformed requestsA request that is not the 5 fields in order, or is longer than 136 bytes, is answered invalid and never guessed.security

Components

8 components and 11 edges between them.

ComponentKindWhat it is
BrowserexternalSystemThe visitor's web browser, which loads the page and runs the JCS NFC admission guest.
Conformance corpusexternalSystemconformance/uor-jcs-nfc-vectors-v0.1-rc5.json and its mutation suite run_mutants.py.
GitHub PagesexternalSystemServes the page and the holo from the repository Pages workflow.
JCS NFC admission guestserviceThe Core-Wasm guest built from the model: it answers one request of at most 136 bytes with one answer of at most 64.
JCS NFC admission pagestaticSiteThe page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors.
Prism buildcliAdapterprismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector.
Reference implementationcliAdapteruor_jcs_nfc_ref.py, admit and canonicalize written from SPEC.md.
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 JCS NFC admission requestopmObjectProcessContext implementer: Correct answers
Components of JCS NFC admissionumlComponentVerifier: Integrity of the published app
Answering a JCS NFC admission requestumlSequenceContext implementer: Correct answers
States of the JCS NFC admission guestumlStateMachineRegistry maintainer: Refused malformed requests

Features and journeys

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

Features and journeys 16 rows
FeatureCallsAccepted by
When bom is present, the answer is e-bom.JcsNfcAdmission::rule1, JcsNfcAdmission::judgeJcsNfcAdmission::application
When utf8 is invalid, the answer is e-utf8.JcsNfcAdmission::rule2, JcsNfcAdmission::judgeJcsNfcAdmission::application
When parse is json, the answer is e-json.JcsNfcAdmission::rule3, JcsNfcAdmission::judgeJcsNfcAdmission::application
When parse is number-token, the answer is e-num-token.JcsNfcAdmission::rule4, JcsNfcAdmission::judgeJcsNfcAdmission::application
When parse is number-range, the answer is e-num-range.JcsNfcAdmission::rule5, JcsNfcAdmission::judgeJcsNfcAdmission::application
When parse is constant, the answer is e-constant.JcsNfcAdmission::rule6, JcsNfcAdmission::judgeJcsNfcAdmission::application
When parse is trailing, the answer is e-trailing.JcsNfcAdmission::rule7, JcsNfcAdmission::judgeJcsNfcAdmission::application
When names is duplicate, the answer is e-dup-name.JcsNfcAdmission::rule8, JcsNfcAdmission::judgeJcsNfcAdmission::application
When surrogate is lone, the answer is e-surrogate.JcsNfcAdmission::rule9, JcsNfcAdmission::judgeJcsNfcAdmission::application
When names is colliding, the answer is e-nfc-collision.JcsNfcAdmission::rule10, JcsNfcAdmission::judgeJcsNfcAdmission::application
When no rule matches, the answer is addressed.JcsNfcAdmission::judgeJcsNfcAdmission::application
A request that is not bom, utf8, parse, names, surrogate in order, separated by single spaces, or is over 136 bytes, is answered invalid.JcsNfcAdmission::dispatch, JcsNfcAdmission::decodeField1JcsNfcAdmission::application
It always answers e-bom when bom is present.JcsNfcAdmission::judgeJcsNfcAdmissionProofs::inv001Holds
It never answers addressed when names is colliding.JcsNfcAdmission::judgeJcsNfcAdmissionProofs::inv002Holds
It never answers addressed when parse is number-token.JcsNfcAdmission::judgeJcsNfcAdmissionProofs::inv003Holds
It never answers addressed when surrogate is lone.JcsNfcAdmission::judgeJcsNfcAdmissionProofs::inv004Holds

Journeys

The ordered features each stakeholder takes.

StakeholderSteps
Context implementerREQ-001 → REQ-002 → REQ-003 → REQ-007 → REQ-008 → REQ-009 → REQ-010 → otherwise
Registry maintainerINV-001 → INV-002 → INV-003 → INV-004 → refuse
Verifierrefuse → INV-001 → INV-002 → INV-003 → INV-004

Security and threat model

13 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 13 rows
ThreatSTRIDEAssetRiskAnswered by
Answer that breaks INV-001repudiationAnswermedium likelihood, critical impactProof of INV-001: proof JcsNfcAdmissionProofs::inv001Holds
Answer that breaks INV-002repudiationAnswermedium likelihood, critical impactProof of INV-002: proof JcsNfcAdmissionProofs::inv002Holds
Answer that breaks INV-003repudiationAnswermedium likelihood, critical impactProof of INV-003: proof JcsNfcAdmissionProofs::inv003Holds
Answer that breaks INV-004repudiationAnswermedium likelihood, critical impactProof of INV-004: proof JcsNfcAdmissionProofs::inv004Holds
Different Unicode databasetamperingModel sourcemedium likelihood, major impactaccepted: The app takes the collision finding as given; SPEC.md 1.3 pins Unicode 15.0.0, and gen_vectors.py refuses any other runtime.
Granted capabilityinformationDisclosureAnswerlow likelihood, major impactNo capability granted: gate prism-code check refuses an ungranted guest import
Integral float admittedtamperingRequest bytesmedium likelihood, major impactLexical number admission: proof JcsNfcAdmissionProofs::inv003Holds; review UOR-Foundation/uor-jcs-nfc SPEC.md 8 mutation probes
Malformed requesttamperingRequest byteshigh likelihood, major impactStrict decoder: gate malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify
Merged colliding namestamperingAnswermedium likelihood, critical impactCollision refusal: proof JcsNfcAdmissionProofs::inv002Holds; gate UOR-Foundation/uor-jcs-nfc conformance/run_mutants.py
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
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.
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 272 bytes for one request.Performance efficiency: Resource utilizationGuest allocation bytes272
Bounded request: A request over 136 bytes is refused before any field is read.Performance efficiency: Time behaviourRequest bytes read136
Every property proved: All 4 properties are theorems the Lean kernel checks.Security: IntegrityUnproved properties0
Every request answered: Every request gets an answer: a rule, addressed otherwise, or invalid.Functional suitability: Functional completenessUnanswered requests0
Every vector replays: All 40 acceptance vectors replay in the compiled guest, the shortest 0 bytes long.Reliability: FaultlessnessFailed vectors0
Examples answered as stated: Every one of the 8 examples of the spec is answered as it states.Functional suitability: Functional correctnessExample mismatches0
No refused document addressed: No document with any refusal finding receives an address.Security: IntegrityAddressed refusals0
One code per input: Every malformed combination receives exactly one of the ten refusal codes SPEC.md 3.8 and 4.3 define.Compatibility: InteroperabilityRefusal codes10

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 tableJcsNfcAdmission::judge
OpenSpecRequirementsJcsNfcAdmission::application
SPDX Apache-2.0LicensingJcsNfcAdmission::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 JCS NFC admission request
Viewpoint: Architecture::viewpointContextImplementerCorrectAnswers
Notation: ISO/PAS 19450:2015 OPM, Prism OPL profile

componentBrowser is an object.
componentJCSNFCAdmissionGuest is an object.
componentJCSNFCAdmissionGuest can be stateDeciding or stateIdle.
processDecide is a process.
processEncodeAnswer is a process.
processJudge is a process.
processParseRequest is a process.
componentJCSNFCAdmissionGuest 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 JCS NFC admission
component "componentBrowser" as c0
component "componentConformanceCorpus" as c1
component "componentGitHubPages" as c2
component "componentJCSNFCAdmissionGuest" as c3
component "componentJCSNFCAdmissionPage" as c4
component "componentPrismBuild" as c5
component "componentReferenceImplementation" as c6
component "componentSourceRepository" as c7
c0 --> c3 : edgeBrowserToJCSNFCAdmissionGuest
c1 --> c3 : edgeConformanceCorpusToJCSNFCAdmissionGuest
c2 --> c0 : edgeGitHubPagesToBrowser
c3 --> c0 : edgeJCSNFCAdmissionGuestToBrowser
c3 --> c1 : edgeJCSNFCAdmissionGuestToConformanceCorpus
c3 --> c6 : edgeJCSNFCAdmissionGuestToReferenceImplementation
c4 --> c2 : edgeJCSNFCAdmissionPageToGitHubPages
c5 --> c3 : edgePrismBuildToJCSNFCAdmissionGuest
c5 --> c4 : edgePrismBuildToJCSNFCAdmissionPage
c6 --> c3 : edgeReferenceImplementationToJCSNFCAdmissionGuest
c7 --> c5 : edgeSourceRepositoryToPrismBuild
@enduml
design/Design.viewUmlRequest.puml
@startuml
' UML 2.5.1 sequence diagram
' view: Design::viewUmlRequest
' viewpoint: Architecture::viewpointContextImplementerCorrectAnswers
title Answering a JCS NFC admission request
participant "componentBrowser" as p0
participant "componentJCSNFCAdmissionGuest" 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::viewpointRegistryMaintainerRefusedMalformedRequests
title States of the JCS NFC admission guest
state "stateAnsweredAddressed" as s0
state "stateAnsweredEBom" as s1
state "stateAnsweredEConstant" as s2
state "stateAnsweredEDupName" as s3
state "stateAnsweredEJson" as s4
state "stateAnsweredENfcCollision" as s5
state "stateAnsweredENumRange" as s6
state "stateAnsweredENumToken" as s7
state "stateAnsweredESurrogate" as s8
state "stateAnsweredETrailing" as s9
state "stateAnsweredEUtf8" as s10
state "stateDeciding" as s11
state "stateIdle" as s12
state "stateRefused" as s13
[*] --> s12
s12 --> s11 : processParseRequest
s12 --> s13 : processParseRequest
s11 --> s1 : processRule1
s11 --> s10 : processRule2
s11 --> s4 : processRule3
s11 --> s7 : processRule4
s11 --> s6 : processRule5
s11 --> s2 : processRule6
s11 --> s9 : processRule7
s11 --> s3 : processRule8
s11 --> s8 : processRule9
s11 --> s5 : processRule10
s11 --> s0 : processOtherwise
s0 --> s12 : processEncodeAnswer
s1 --> s12 : processEncodeAnswer
s10 --> s12 : processEncodeAnswer
s4 --> s12 : processEncodeAnswer
s7 --> s12 : processEncodeAnswer
s6 --> s12 : processEncodeAnswer
s2 --> s12 : processEncodeAnswer
s9 --> s12 : processEncodeAnswer
s3 --> s12 : processEncodeAnswer
s8 --> s12 : processEncodeAnswer
s5 --> s12 : processEncodeAnswer
s13 --> s12 : 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 406 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: stakeholderContextImplementer,
  parameters: [],
  result: Foundation.Arch::Stakeholder,
  body: (record Foundation.Arch::Stakeholder {index := 0, name := "Context implementer", text := "Writes an implementation of the digest context and needs the same refusal code as every other implementation for every input."})
}

definition{
  name: stakeholderRegistryMaintainer,
  parameters: [],
  result: Foundation.Arch::Stakeholder,
  body: (record Foundation.Arch::Stakeholder {index := 1, name := "Registry maintainer", text := "Cites the context's final corpus in a registry entry and needs no inadmissible document to receive an address."})
}

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 addressed 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: concernProvedGuarantees,
  parameters: [],
  result: Foundation.Arch::Concern,
  body: (record Foundation.Arch::Concern {index := 2, name := "Proved guarantees", text := "Each of the 4 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 := 3, name := "Refused malformed requests", text := "A request that is not the 5 fields in order, or is longer than 136 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 JCS NFC admission guest."})
}

definition{
  name: componentConformanceCorpus,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 1, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Conformance corpus", text := "conformance/uor-jcs-nfc-vectors-v0.1-rc5.json and its mutation suite run_mutants.py."})
}

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

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

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

definition{
  name: componentPrismBuild,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 5, 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: componentReferenceImplementation,
  parameters: [],
  result: Foundation.Arch::Component,
  body: (record Foundation.Arch::Component {index := 6, kind := (ctor Foundation.Arch::ComponentKind.cliAdapter), name := "Reference implementation", text := "uor_jcs_nfc_ref.py, admit and canonicalize written from SPEC.md."})
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 := 2, modelKindIndex := 1})
}

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

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

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

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

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

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 (componentConformanceCorpus) (cons (componentGitHubPages) (cons (componentJCSNFCAdmissionGuest) (cons (componentJCSNFCAdmissionPage) (cons (componentPrismBuild) (cons (componentReferenceImplementation) (cons (componentSourceRepository) (nil Foundation.Arch::Component)))))))))
}

definition{
  name: edgeRecords,
  parameters: [],
  result: (List Foundation.Arch::Edge),
  body: (cons (edgeBrowserToJCSNFCAdmissionGuest) (cons (edgeConformanceCorpusToJCSNFCAdmissionGuest) (cons (edgeGitHubPagesToBrowser) (cons (edgeJCSNFCAdmissionGuestToBrowser) (cons (edgeJCSNFCAdmissionGuestToConformanceCorpus) (cons (edgeJCSNFCAdmissionGuestToReferenceImplementation) (cons (edgeJCSNFCAdmissionPageToGitHubPages) (cons (edgePrismBuildToJCSNFCAdmissionGuest) (cons (edgePrismBuildToJCSNFCAdmissionPage) (cons (edgeReferenceImplementationToJCSNFCAdmissionGuest) (cons (edgeSourceRepositoryToPrismBuild) (nil Foundation.Arch::Edge))))))))))))
}

definition{
  name: viewpointRecords,
  parameters: [],
  result: (List Foundation.Arch::Viewpoint),
  body: (cons (viewpointContextImplementerCorrectAnswers) (cons (viewpointContextImplementerProvedGuarantees) (cons (viewpointRegistryMaintainerProvedGuarantees) (cons (viewpointRegistryMaintainerRefusedMalformedRequests) (cons (viewpointVerifierIntegrityOfThePublishedApp) (cons (viewpointVerifierProvedGuarantees) (cons (viewpointVerifierRefusedMalformedRequests) (nil Foundation.Arch::Viewpoint))))))))
}

definition{
  name: viewRecords,
  parameters: [],
  result: (List Foundation.Arch::View),
  body: (cons (viewContextImplementerCorrectAnswers) (cons (viewContextImplementerProvedGuarantees) (cons (viewRegistryMaintainerProvedGuarantees) (cons (viewRegistryMaintainerRefusedMalformedRequests) (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 8 (edgeRecords)) && ((viewpointsKnown 3 4 (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{JcsNfcAdmission}
\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 10 rules are tried in order and the first that matches gives the answer; otherwise addressed.", evidence := (cons "JcsNfcAdmission::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 "JcsNfcAdmission::application" (nil String))}) (cons (record Obligation {index := 6, standard := "SPDX Apache-2.0", subject := "Licensing", text := "The application and its model are offered under Apache-2.0.", evidence := (cons "JcsNfcAdmission::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 801 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::componentJCSNFCAdmissionGuest"})
}

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

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

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

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::componentJCSNFCAdmissionGuest"})
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

definition{
  name: viewUmlComponents,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "Components of JCS NFC 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 JCS NFC admission request", viewpoint := "Architecture::viewpointContextImplementerCorrectAnswers", diagram := (ctor Foundation.Arch::DesignDiagram.umlSequence)})
}

definition{
  name: viewUmlStates,
  parameters: [],
  result: Foundation.Arch::DesignView,
  body: (record Foundation.Arch::DesignView {title := "States of the JCS NFC admission guest", viewpoint := "Architecture::viewpointRegistryMaintainerRefusedMalformedRequests", 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::componentJCSNFCAdmissionGuest"})
}

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::componentJCSNFCAdmissionGuest", state := "Design::stateIdle"})
}

definition{
  name: opmGuestDeciding,
  parameters: [],
  result: Foundation.Arch::OpmState,
  body: (record Foundation.Arch::OpmState {view := "Design::viewOpmDecide", thing := "Architecture::componentJCSNFCAdmissionGuest", 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::componentJCSNFCAdmissionGuest", 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: umlConformanceCorpus,
  parameters: [],
  result: Foundation.Arch::UmlComponent,
  body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentConformanceCorpus"})
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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: seqJCSNFCAdmissionGuest,
  parameters: [],
  result: Foundation.Arch::UmlLifeline,
  body: (record Foundation.Arch::UmlLifeline {view := "Design::viewUmlRequest", component := "Architecture::componentJCSNFCAdmissionGuest", 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::componentJCSNFCAdmissionGuest", 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::componentJCSNFCAdmissionGuest", 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: stAnsweredAddressed,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredAddressed", initial := false})
}

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

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

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

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

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

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

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

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

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

definition{
  name: stAnsweredENfcCollision,
  parameters: [],
  result: Foundation.Arch::UmlState,
  body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredENfcCollision", 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::stateAnsweredEBom", 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::stateAnsweredEUtf8", 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::stateAnsweredEJson", 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::stateAnsweredENumToken", 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::stateAnsweredENumRange", 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::stateAnsweredEConstant", 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::stateAnsweredETrailing", 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::stateAnsweredEDupName", 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::stateAnsweredESurrogate", 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::stateAnsweredENfcCollision", trigger := "Design::processRule10"})
}

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

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

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

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

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

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

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

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

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

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

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

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

definition{
  name: trResetRefused,
  parameters: [],
  result: Foundation.Arch::UmlTransition,
  body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 24, source := "Design::stateRefused", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
\end{semanticmodule}
\end{lexlean}
app/src/Features.lex.tex 172 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{JcsNfcAdmission}
\importmodule{Architecture}
\importmodule{Foundation.Arch}
\title{feature}
\begin{semanticmodule}
definition{
  name: acceptINV001,
  parameters: [],
  result: String,
  body: "JcsNfcAdmissionProofs::inv001Holds"
}

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

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

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

definition{
  name: featureRule1,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When bom is present, the answer is e-bom.", calls := (cons "JcsNfcAdmission::rule1" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule2,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When utf8 is invalid, the answer is e-utf8.", calls := (cons "JcsNfcAdmission::rule2" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

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

definition{
  name: featureRule4,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When parse is number-token, the answer is e-num-token.", calls := (cons "JcsNfcAdmission::rule4" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule5,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When parse is number-range, the answer is e-num-range.", calls := (cons "JcsNfcAdmission::rule5" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule6,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When parse is constant, the answer is e-constant.", calls := (cons "JcsNfcAdmission::rule6" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule7,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When parse is trailing, the answer is e-trailing.", calls := (cons "JcsNfcAdmission::rule7" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule8,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When names is duplicate, the answer is e-dup-name.", calls := (cons "JcsNfcAdmission::rule8" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule9,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When surrogate is lone, the answer is e-surrogate.", calls := (cons "JcsNfcAdmission::rule9" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureRule10,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "When names is colliding, the answer is e-nfc-collision.", calls := (cons "JcsNfcAdmission::rule10" (cons "JcsNfcAdmission::judge" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

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

definition{
  name: featureRefuseMalformed,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "A request that is not bom, utf8, parse, names, surrogate in order, separated by single spaces, or is over 136 bytes, is answered invalid.", calls := (cons "JcsNfcAdmission::dispatch" (cons "JcsNfcAdmission::decodeField1" (nil String))), acceptance := (cons "JcsNfcAdmission::application" (nil String))})
}

definition{
  name: featureINV001,
  parameters: [],
  result: Foundation.Arch::Feature,
  body: (record Foundation.Arch::Feature {statement := "It always answers e-bom when bom is present.", calls := (cons "JcsNfcAdmission::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 addressed when names is colliding.", calls := (cons "JcsNfcAdmission::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 addressed when parse is number-token.", calls := (cons "JcsNfcAdmission::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 addressed when surrogate is lone.", calls := (cons "JcsNfcAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV004" (nil String))})
}

definition{
  name: journeyContextImplementer,
  parameters: [],
  result: Foundation.Arch::Journey,
  body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderContextImplementer", steps := (cons "Features::featureRule1" (cons "Features::featureRule2" (cons "Features::featureRule3" (cons "Features::featureRule7" (cons "Features::featureRule8" (cons "Features::featureRule9" (cons "Features::featureRule10" (cons "Features::featureOtherwise" (nil String)))))))))})
}

definition{
  name: journeyRegistryMaintainer,
  parameters: [],
  result: Foundation.Arch::Journey,
  body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderRegistryMaintainer", steps := (cons "Features::featureINV001" (cons "Features::featureINV002" (cons "Features::featureINV003" (cons "Features::featureINV004" (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" (nil String))))))})
}
\end{semanticmodule}
\end{lexlean}
app/src/Quality.lex.tex 382 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: characteristicCompatibility,
  parameters: [],
  result: Foundation.Qual::ProductQualityCharacteristic,
  body: (record Foundation.Qual::ProductQualityCharacteristic {index := 0})
}

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

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

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

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

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

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

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

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

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

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

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

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: requirementExamplesAnsweredAsStated,
  parameters: [],
  result: Foundation.Qual::QualityRequirement,
  body: (record Foundation.Qual::QualityRequirement {index := 5, subcharacteristicIndex := 2})
}

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

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

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

definition{
  name: measureExampleMismatches,
  parameters: [],
  result: Foundation.Qual::QualityMeasure,
  body: (record Foundation.Qual::QualityMeasure {index := 1, requirementIndex := 5, 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 := 272})
}

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

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

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

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

definition{
  name: characteristicNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Compatibility", text := "Compatibility, as ISO/IEC 25010:2023 defines it, for JCS NFC admission."}) (cons (record Named {index := 1, name := "Functional suitability", text := "Functional suitability, as ISO/IEC 25010:2023 defines it, for JCS NFC admission."}) (cons (record Named {index := 2, name := "Performance efficiency", text := "Performance efficiency, as ISO/IEC 25010:2023 defines it, for JCS NFC admission."}) (cons (record Named {index := 3, name := "Reliability", text := "Reliability, as ISO/IEC 25010:2023 defines it, for JCS NFC admission."}) (cons (record Named {index := 4, name := "Security", text := "Security, as ISO/IEC 25010:2023 defines it, for JCS NFC 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 := "Interoperability", text := "Compatibility: Interoperability."}) (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 272 bytes for one request."}) (cons (record Named {index := 1, name := "Bounded request", text := "A request over 136 bytes is refused before any field is read."}) (cons (record Named {index := 2, name := "Every property proved", text := "All 4 properties are theorems the Lean kernel checks."}) (cons (record Named {index := 3, name := "Every request answered", text := "Every request gets an answer: a rule, addressed otherwise, or invalid."}) (cons (record Named {index := 4, name := "Every vector replays", text := "All 40 acceptance vectors replay in the compiled guest, the shortest 0 bytes long."}) (cons (record Named {index := 5, name := "Examples answered as stated", text := "Every one of the 8 examples of the spec is answered as it states."}) (cons (record Named {index := 6, name := "No refused document addressed", text := "No document with any refusal finding receives an address."}) (cons (record Named {index := 7, name := "One code per input", text := "Every malformed combination receives exactly one of the ten refusal codes SPEC.md 3.8 and 4.3 define."}) (nil Named)))))))))
}

definition{
  name: measureNames,
  parameters: [],
  result: (List Named),
  body: (cons (record Named {index := 0, name := "Addressed refusals", text := "Acceptance vectors with a refusal finding answered addressed."}) (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 := "Refusal codes", text := "Distinct refusal codes the app answers."}) (cons (record Named {index := 5, name := "Request bytes read", text := "Longest request the guest decodes, in bytes."}) (cons (record Named {index := 6, name := "Unanswered requests", text := "Acceptance vectors the guest does not answer."}) (cons (record Named {index := 7, name := "Unproved properties", text := "Properties of the spec without a checked theorem."}) (nil Named)))))))))
}

definition{
  name: subcharacteristicRecords,
  parameters: [],
  result: (List Foundation.Qual::QualitySubcharacteristic),
  body: (cons (subcharacteristicFaultlessness) (cons (subcharacteristicFunctionalCompleteness) (cons (subcharacteristicFunctionalCorrectness) (cons (subcharacteristicIntegrity) (cons (subcharacteristicInteroperability) (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 (requirementExamplesAnsweredAsStated) (cons (requirementNoRefusedDocumentAddressed) (cons (requirementOneCodePerInput) (nil Foundation.Qual::QualityRequirement)))))))))
}

definition{
  name: measureRecords,
  parameters: [],
  result: (List Foundation.Qual::QualityMeasure),
  body: (cons (measureAddressedRefusals) (cons (measureExampleMismatches) (cons (measureFailedVectors) (cons (measureGuestAllocationBytes) (cons (measureRefusalCodes) (cons (measureRequestBytesRead) (cons (measureUnansweredRequests) (cons (measureUnprovedProperties) (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 5 (subcharacteristicRecords)) && ((requirementsKnown 7 (requirementRecords)) && (measuresKnown 8 (measureRecords))))))))
}

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

theorem{
  name: measureAddressedRefusalsThreshold,
  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)) = 272),
  proof: decide{}
}

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

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

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

theorem{
  name: measureUnprovedPropertiesThreshold,
  parameters: [],
  statement: ((thresholdOf 7 (measureRecords)) = 0),
  proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Security.lex.tex 593 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 := 3})
}

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

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

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

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: threatDifferentUnicodeDatabase,
  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: threatIntegralFloatAdmitted,
  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: threatMergedCollidingNames,
  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: threatSubstitutedHolo,
  parameters: [],
  result: Foundation.Sec::Threat,
  body: (record Foundation.Sec::Threat {index := 10})
}

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

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

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: riskDifferentUnicodeDatabase,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 4, assetIndex := 1, threatIndex := 4, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.major)})
}

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: riskIntegralFloatAdmitted,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 6, assetIndex := 3, threatIndex := 6, likelihood := (ctor Foundation.Sec::Likelihood.medium), 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: riskMergedCollidingNames,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 8, assetIndex := 0, threatIndex := 8, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}

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: riskSubstitutedHolo,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 10, assetIndex := 2, threatIndex := 10, 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 := 11, assetIndex := 2, threatIndex := 11, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.critical)})
}

definition{
  name: riskTamperedModel,
  parameters: [],
  result: Foundation.Sec::Risk,
  body: (record Foundation.Sec::Risk {index := 12, assetIndex := 1, threatIndex := 12, 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: controlCollisionRefusal,
  parameters: [],
  result: Foundation.Sec::ApplicationSecurityControl,
  body: (record Foundation.Sec::ApplicationSecurityControl {index := 1, riskIndex := 8})
}

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

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

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

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

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

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

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

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

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

definition{
  name: controlSet,
  parameters: [],
  result: Production.ThreatModel::ControlSet,
  body: (record Production.ThreatModel::ControlSet {title := "JCS NFC admission security controls", text := "JCS NFC admission answers one request with one answer in a Core-Wasm guest granted no capability. Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest.", 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 addressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate, e-nfc-collision, 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 136 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 e-bom not when bom is present, which matters because one malformed input receives one code, and E_BOM has precedence.", 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 addressed although names is colliding, which matters because a collision is never resolved by last-write-wins, first-write-wins or merging.", 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 addressed although parse is number-token, which matters because an integral value such as 1.0 is still refused.", 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 addressed although surrogate is lone, which matters because a lone escaped surrogate is never digested.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}

definition{
  name: modeledThreatDifferentUnicodeDatabase,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatDifferentUnicodeDatabase", name := "Different Unicode database", text := "NFC under a Unicode version other than 15.0.0 normalizes differently and yields another digest.", category := (ctor Production.ThreatModel::Stride.tampering)})
}

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: modeledThreatIntegralFloatAdmitted,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatIntegralFloatAdmitted", name := "Integral float admitted", text := "A type-based guard admits 1.0 or 2^53 as a float with an integral value.", category := (ctor Production.ThreatModel::Stride.tampering)})
}

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: modeledThreatMergedCollidingNames,
  parameters: [],
  result: Production.ThreatModel::ModeledThreat,
  body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatMergedCollidingNames", name := "Merged colliding names", text := "An implementation merges members whose names collide after NFC, giving two documents one address.", category := (ctor Production.ThreatModel::Stride.tampering)})
}

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

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: 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 136 bytes before reading a field, and the guest allocates at most 272.", 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: modeledControlCollisionRefusal,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlCollisionRefusal", name := "Collision refusal", text := "Colliding names are refused, never addressed.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::inv002Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "UOR-Foundation/uor-jcs-nfc conformance/run_mutants.py"}) (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: modeledControlLexicalNumberAdmission,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlLexicalNumberAdmission", name := "Lexical number admission", text := "Number tokens are validated as text.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::inv003Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "UOR-Foundation/uor-jcs-nfc SPEC.md 8 mutation probes"}) (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: modeledControlProofOfINV001,
  parameters: [],
  result: Production.ThreatModel::ModeledControl,
  body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV001", name := "Proof of INV-001", text := "It always answers e-bom when bom is present. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::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 addressed when names is colliding. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::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 addressed when parse is number-token. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::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 addressed when surrogate is lone. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "JcsNfcAdmissionProofs::inv004Holds"}) (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: mappingMergedCollidingNames,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatMergedCollidingNames", controls := (cons "Security::controlCollisionRefusal" (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: mappingIntegralFloatAdmitted,
  parameters: [],
  result: Production.ThreatModel::ThreatMapping,
  body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatIntegralFloatAdmitted", controls := (cons "Security::controlLexicalNumberAdmission" (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: 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: 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: acceptedDifferentUnicodeDatabase,
  parameters: [],
  result: Production.ThreatModel::AcceptedRisk,
  body: (record Production.ThreatModel::AcceptedRisk {threat := "Security::threatDifferentUnicodeDatabase", rationale := "The app takes the collision finding as given; SPEC.md 1.3 pins Unicode 15.0.0, and gen_vectors.py refuses any other runtime."})
}

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."})
}
\end{semanticmodule}
\end{lexlean}
app/src/JcsNfcAdmission.lex.tex 324 lines
\begin{lexlean}{JcsNfcAdmission}
\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: bomAbsent, parameters: [], result: Nat, body: 0}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

definition{name: answerESurrogate, parameters: [], result: Nat, body: 9}

definition{name: answerENfcCollision, parameters: [], result: Nat, body: 10}

structure{
  name: Request,
  type_parameters: [],
  parameters: [],
  fields: [
    {name: bom, type: Nat},
    {name: utf8, type: Nat},
    {name: parse, type: Nat},
    {name: names, type: Nat},
    {name: surrogate, 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: parseBom,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x616273656e74 : Bool) then (ctor Option.some [Nat] (bomAbsent)) else (if (prim equal value 0x70726573656e74 : Bool) then (ctor Option.some [Nat] (bomPresent)) else (ctor Option.none [Nat])))
}

definition{
  name: parseUtf8,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x76616c6964 : Bool) then (ctor Option.some [Nat] (utf8Valid)) else (if (prim equal value 0x696e76616c6964 : Bool) then (ctor Option.some [Nat] (utf8Invalid)) else (ctor Option.none [Nat])))
}

definition{
  name: parseParse,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x6f6b : Bool) then (ctor Option.some [Nat] (parseOk)) else (if (prim equal value 0x6a736f6e : Bool) then (ctor Option.some [Nat] (parseJson)) else (if (prim equal value 0x6e756d6265722d746f6b656e : Bool) then (ctor Option.some [Nat] (parseNumberToken)) else (if (prim equal value 0x6e756d6265722d72616e6765 : Bool) then (ctor Option.some [Nat] (parseNumberRange)) else (if (prim equal value 0x636f6e7374616e74 : Bool) then (ctor Option.some [Nat] (parseConstant)) else (if (prim equal value 0x747261696c696e67 : Bool) then (ctor Option.some [Nat] (parseTrailing)) else (ctor Option.none [Nat])))))))
}

definition{
  name: parseNames,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x64697374696e6374 : Bool) then (ctor Option.some [Nat] (namesDistinct)) else (if (prim equal value 0x6475706c6963617465 : Bool) then (ctor Option.some [Nat] (namesDuplicate)) else (if (prim equal value 0x636f6c6c6964696e67 : Bool) then (ctor Option.some [Nat] (namesColliding)) else (ctor Option.none [Nat]))))
}

definition{
  name: parseSurrogate,
  parameters: [value : Bytes],
  result: (Option Nat),
  body: (if (prim equal value 0x6e6f6e65 : Bool) then (ctor Option.some [Nat] (surrogateNone)) else (if (prim equal value 0x6c6f6e65 : Bool) then (ctor Option.some [Nat] (surrogateLone)) else (ctor Option.none [Nat])))
}

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: decodeField5,
  parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat, v4 : Nat],
  result: (Option Request),
  body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseSurrogate (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v5 => (if (e =? (Foundation.Bytes::byteLength s)) then (ctor Option.some [Request] (record Request {bom := v1, utf8 := v2, parse := v3, names := v4, surrogate := v5})) else (ctor Option.none [Request])))),
  axioms: [Quot.sound, propext]
}

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 (parseNames (sliceOf s start (prim subtract e start : Nat)))
    | Option.none => (ctor Option.none [Request])
    | Option.some v4 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField5 s (e + 1) v1 v2 v3 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 (parseParse (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 (parseUtf8 (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 (parseBom (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 bom) =? (bomPresent))
}

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

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

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

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

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

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

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

definition{
  name: rule9,
  parameters: [request : Request],
  result: Bool,
  body: ((project request surrogate) =? (surrogateLone))
}

definition{
  name: rule10,
  parameters: [request : Request],
  result: Bool,
  body: ((project request names) =? (namesColliding))
}

definition{
  name: judge,
  parameters: [request : Request],
  result: Nat,
  body: (if (rule1 request) then (answerEBom) else (if (rule2 request) then (answerEUtf8) else (if (rule3 request) then (answerEJson) else (if (rule4 request) then (answerENumToken) else (if (rule5 request) then (answerENumRange) else (if (rule6 request) then (answerEConstant) else (if (rule7 request) then (answerETrailing) else (if (rule8 request) then (answerEDupName) else (if (rule9 request) then (answerESurrogate) else (if (rule10 request) then (answerENfcCollision) else (answerAddressed)))))))))))
}

definition{
  name: encodeAnswer,
  parameters: [code : Nat],
  result: Bytes,
  body: (if (code =? (answerAddressed)) then 0x616464726573736564 else (if (code =? (answerEBom)) then 0x652d626f6d else (if (code =? (answerEUtf8)) then 0x652d75746638 else (if (code =? (answerEJson)) then 0x652d6a736f6e else (if (code =? (answerENumToken)) then 0x652d6e756d2d746f6b656e else (if (code =? (answerENumRange)) then 0x652d6e756d2d72616e6765 else (if (code =? (answerEConstant)) then 0x652d636f6e7374616e74 else (if (code =? (answerETrailing)) then 0x652d747261696c696e67 else (if (code =? (answerEDupName)) then 0x652d6475702d6e616d65 else (if (code =? (answerESurrogate)) then 0x652d737572726f67617465 else (if (code =? (answerENfcCollision)) then 0x652d6e66632d636f6c6c6973696f6e else 0x696e76616c6964)))))))))))
}

definition{
  name: dispatch,
  parameters: [value : Bytes],
  result: Bytes,
  body: (if (136 <? (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 := "JCS NFC admission", cargoName := "prism-jcs-nfc-admission", cargoVersion := "0.1.0", cargoDescription := "Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it", cargoRepository := "https://github.com/UOR-Foundation/PrismPM", cargoHomepage := "https://github.com/UOR-Foundation/PrismPM", libraryRoots := (cons "PrismJcsNfcAdmission.JcsNfcAdmission.dispatch" (nil String)), acceptanceVectors := (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b2064697374696e6374206e6f6e65, response := 0x616464726573736564}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x70726573656e7420696e76616c6964206a736f6e206475706c6963617465206c6f6e65, response := 0x652d626f6d}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e7420696e76616c6964206f6b2064697374696e6374206e6f6e65, response := 0x652d75746638}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e2064697374696e6374206e6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c696420747261696c696e67206475706c6963617465206e6f6e65, response := 0x652d747261696c696e67}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b206475706c6963617465206c6f6e65, response := 0x652d6475702d6e616d65}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b20636f6c6c6964696e67206c6f6e65, response := 0x652d737572726f67617465}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b20636f6c6c6964696e67206e6f6e65, response := 0x652d6e66632d636f6c6c6973696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b2064697374696e6374206c6f6e65, response := 0x652d737572726f67617465}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b206475706c6963617465206e6f6e65, response := 0x652d6475702d6e616d65}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e2064697374696e6374206e6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e2064697374696e6374206c6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e206475706c6963617465206e6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e206475706c6963617465206c6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e20636f6c6c6964696e67206e6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206a736f6e20636f6c6c6964696e67206c6f6e65, response := 0x652d6a736f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e2064697374696e6374206c6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e206475706c6963617465206e6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e206475706c6963617465206c6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e20636f6c6c6964696e67206e6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d746f6b656e20636f6c6c6964696e67206c6f6e65, response := 0x652d6e756d2d746f6b656e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e67652064697374696e6374206e6f6e65, response := 0x652d6e756d2d72616e6765}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e67652064697374696e6374206c6f6e65, response := 0x652d6e756d2d72616e6765}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e6765206475706c6963617465206e6f6e65, response := 0x652d6e756d2d72616e6765}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e6765206475706c6963617465206c6f6e65, response := 0x652d6e756d2d72616e6765}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e676520636f6c6c6964696e67206e6f6e65, response := 0x652d6e756d2d72616e6765}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206e756d6265722d72616e676520636f6c6c6964696e67206c6f6e65, response := 0x652d6e756d2d72616e6765}) (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 := 0x616273656e742076616c6964206f6b2064697374696e6374, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b2064697374696e6374206e6f6e65206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e74202076616c696420206f6b202064697374696e637420206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x756e6b6e6f776e2076616c6964206f6b2064697374696e6374206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e7420756e6b6e6f776e206f6b2064697374696e6374206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c696420756e6b6e6f776e2064697374696e6374206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b20756e6b6e6f776e206e6f6e65, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x616273656e742076616c6964206f6b2064697374696e637420756e6b6e6f776e, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (nil Foundation.View.Text.V1.Model::AcceptanceVector))))))))))))))))))))))))))))))))))))))))), entryRoot := "PrismJcsNfcAdmission.JcsNfcAdmission.dispatch", coreContract := "hologram:guest/core-wasm@1", requestMaximum := (136 : UInt32), responseMaximum := (64 : UInt32), guestAllocationMaximum := (272 : UInt32), capabilitiesEmpty := true, fatArchive := true, primaryLayer := (0 : UInt8), viewLayer := (1 : UInt8), view := (record Foundation.View.Text.V1.Model::TextView {title := "JCS NFC admission", heading := "JCS NFC admission", inputLabel := "Request: bom utf8 parse names surrogate", submitLabel := "Decide", outputLabel := "Answer", inputError := "Invalid request", responseError := "Invalid response"})})
}
\end{semanticmodule}
\end{lexlean}
app/src/JcsNfcAdmissionProofs.lex.tex 233 lines
\begin{lexlean}{JcsNfcAdmissionProofs}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{JcsNfcAdmission}
\title{Text application model}
\begin{semanticmodule}
definition{
  name: breaksInv001,
  parameters: [request : JcsNfcAdmission::Request],
  result: Bool,
  body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request bom) =? (JcsNfcAdmission::bomPresent))) && (not ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerEBom))))
}

theorem{
  name: inv001Holds,
  parameters: [request : JcsNfcAdmission::Request],
  statement: ((breaksInv001 request) = false),
  proof: linear_arithmetic{
    definitions: [
      JcsNfcAdmission::answerAddressed,
      JcsNfcAdmission::answerEBom,
      JcsNfcAdmission::answerEConstant,
      JcsNfcAdmission::answerEDupName,
      JcsNfcAdmission::answerEJson,
      JcsNfcAdmission::answerENfcCollision,
      JcsNfcAdmission::answerENumRange,
      JcsNfcAdmission::answerENumToken,
      JcsNfcAdmission::answerESurrogate,
      JcsNfcAdmission::answerETrailing,
      JcsNfcAdmission::answerEUtf8,
      JcsNfcAdmission::bomAbsent,
      JcsNfcAdmission::bomPresent,
      JcsNfcAdmission::judge,
      JcsNfcAdmission::namesColliding,
      JcsNfcAdmission::namesDistinct,
      JcsNfcAdmission::namesDuplicate,
      JcsNfcAdmission::parseConstant,
      JcsNfcAdmission::parseJson,
      JcsNfcAdmission::parseNumberRange,
      JcsNfcAdmission::parseNumberToken,
      JcsNfcAdmission::parseOk,
      JcsNfcAdmission::parseTrailing,
      JcsNfcAdmission::rule1,
      JcsNfcAdmission::rule10,
      JcsNfcAdmission::rule2,
      JcsNfcAdmission::rule3,
      JcsNfcAdmission::rule4,
      JcsNfcAdmission::rule5,
      JcsNfcAdmission::rule6,
      JcsNfcAdmission::rule7,
      JcsNfcAdmission::rule8,
      JcsNfcAdmission::rule9,
      JcsNfcAdmission::surrogateLone,
      JcsNfcAdmission::surrogateNone,
      JcsNfcAdmission::utf8Invalid,
      JcsNfcAdmission::utf8Valid,
      breaksInv001
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv002,
  parameters: [request : JcsNfcAdmission::Request],
  result: Bool,
  body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request names) =? (JcsNfcAdmission::namesColliding))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))
}

theorem{
  name: inv002Holds,
  parameters: [request : JcsNfcAdmission::Request],
  statement: ((breaksInv002 request) = false),
  proof: linear_arithmetic{
    definitions: [
      JcsNfcAdmission::answerAddressed,
      JcsNfcAdmission::answerEBom,
      JcsNfcAdmission::answerEConstant,
      JcsNfcAdmission::answerEDupName,
      JcsNfcAdmission::answerEJson,
      JcsNfcAdmission::answerENfcCollision,
      JcsNfcAdmission::answerENumRange,
      JcsNfcAdmission::answerENumToken,
      JcsNfcAdmission::answerESurrogate,
      JcsNfcAdmission::answerETrailing,
      JcsNfcAdmission::answerEUtf8,
      JcsNfcAdmission::bomAbsent,
      JcsNfcAdmission::bomPresent,
      JcsNfcAdmission::judge,
      JcsNfcAdmission::namesColliding,
      JcsNfcAdmission::namesDistinct,
      JcsNfcAdmission::namesDuplicate,
      JcsNfcAdmission::parseConstant,
      JcsNfcAdmission::parseJson,
      JcsNfcAdmission::parseNumberRange,
      JcsNfcAdmission::parseNumberToken,
      JcsNfcAdmission::parseOk,
      JcsNfcAdmission::parseTrailing,
      JcsNfcAdmission::rule1,
      JcsNfcAdmission::rule10,
      JcsNfcAdmission::rule2,
      JcsNfcAdmission::rule3,
      JcsNfcAdmission::rule4,
      JcsNfcAdmission::rule5,
      JcsNfcAdmission::rule6,
      JcsNfcAdmission::rule7,
      JcsNfcAdmission::rule8,
      JcsNfcAdmission::rule9,
      JcsNfcAdmission::surrogateLone,
      JcsNfcAdmission::surrogateNone,
      JcsNfcAdmission::utf8Invalid,
      JcsNfcAdmission::utf8Valid,
      breaksInv002
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv003,
  parameters: [request : JcsNfcAdmission::Request],
  result: Bool,
  body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request parse) =? (JcsNfcAdmission::parseNumberToken))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))
}

theorem{
  name: inv003Holds,
  parameters: [request : JcsNfcAdmission::Request],
  statement: ((breaksInv003 request) = false),
  proof: linear_arithmetic{
    definitions: [
      JcsNfcAdmission::answerAddressed,
      JcsNfcAdmission::answerEBom,
      JcsNfcAdmission::answerEConstant,
      JcsNfcAdmission::answerEDupName,
      JcsNfcAdmission::answerEJson,
      JcsNfcAdmission::answerENfcCollision,
      JcsNfcAdmission::answerENumRange,
      JcsNfcAdmission::answerENumToken,
      JcsNfcAdmission::answerESurrogate,
      JcsNfcAdmission::answerETrailing,
      JcsNfcAdmission::answerEUtf8,
      JcsNfcAdmission::bomAbsent,
      JcsNfcAdmission::bomPresent,
      JcsNfcAdmission::judge,
      JcsNfcAdmission::namesColliding,
      JcsNfcAdmission::namesDistinct,
      JcsNfcAdmission::namesDuplicate,
      JcsNfcAdmission::parseConstant,
      JcsNfcAdmission::parseJson,
      JcsNfcAdmission::parseNumberRange,
      JcsNfcAdmission::parseNumberToken,
      JcsNfcAdmission::parseOk,
      JcsNfcAdmission::parseTrailing,
      JcsNfcAdmission::rule1,
      JcsNfcAdmission::rule10,
      JcsNfcAdmission::rule2,
      JcsNfcAdmission::rule3,
      JcsNfcAdmission::rule4,
      JcsNfcAdmission::rule5,
      JcsNfcAdmission::rule6,
      JcsNfcAdmission::rule7,
      JcsNfcAdmission::rule8,
      JcsNfcAdmission::rule9,
      JcsNfcAdmission::surrogateLone,
      JcsNfcAdmission::surrogateNone,
      JcsNfcAdmission::utf8Invalid,
      JcsNfcAdmission::utf8Valid,
      breaksInv003
    ]
  },
  axioms: [Quot.sound, propext]
}

definition{
  name: breaksInv004,
  parameters: [request : JcsNfcAdmission::Request],
  result: Bool,
  body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request surrogate) =? (JcsNfcAdmission::surrogateLone))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))
}

theorem{
  name: inv004Holds,
  parameters: [request : JcsNfcAdmission::Request],
  statement: ((breaksInv004 request) = false),
  proof: linear_arithmetic{
    definitions: [
      JcsNfcAdmission::answerAddressed,
      JcsNfcAdmission::answerEBom,
      JcsNfcAdmission::answerEConstant,
      JcsNfcAdmission::answerEDupName,
      JcsNfcAdmission::answerEJson,
      JcsNfcAdmission::answerENfcCollision,
      JcsNfcAdmission::answerENumRange,
      JcsNfcAdmission::answerENumToken,
      JcsNfcAdmission::answerESurrogate,
      JcsNfcAdmission::answerETrailing,
      JcsNfcAdmission::answerEUtf8,
      JcsNfcAdmission::bomAbsent,
      JcsNfcAdmission::bomPresent,
      JcsNfcAdmission::judge,
      JcsNfcAdmission::namesColliding,
      JcsNfcAdmission::namesDistinct,
      JcsNfcAdmission::namesDuplicate,
      JcsNfcAdmission::parseConstant,
      JcsNfcAdmission::parseJson,
      JcsNfcAdmission::parseNumberRange,
      JcsNfcAdmission::parseNumberToken,
      JcsNfcAdmission::parseOk,
      JcsNfcAdmission::parseTrailing,
      JcsNfcAdmission::rule1,
      JcsNfcAdmission::rule10,
      JcsNfcAdmission::rule2,
      JcsNfcAdmission::rule3,
      JcsNfcAdmission::rule4,
      JcsNfcAdmission::rule5,
      JcsNfcAdmission::rule6,
      JcsNfcAdmission::rule7,
      JcsNfcAdmission::rule8,
      JcsNfcAdmission::rule9,
      JcsNfcAdmission::surrogateLone,
      JcsNfcAdmission::surrogateNone,
      JcsNfcAdmission::utf8Invalid,
      JcsNfcAdmission::utf8Valid,
      breaksInv004
    ]
  },
  axioms: [Quot.sound, propext]
}
\end{semanticmodule}
\end{lexlean}
app/lexlean.toml 43 lines
spec = "lexlean/project/1"
name = "prism-jcs-nfc-admission"
language = "1.2"
module_prefix = "PrismJcsNfcAdmission"
source_roots = ["src"]
entrypoints = ["src/Architecture.lex.tex", "src/Compliance.lex.tex", "src/Design.lex.tex", "src/Features.lex.tex", "src/JcsNfcAdmission.lex.tex", "src/JcsNfcAdmissionProofs.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 421 lines
{
  "schema": "prism/prompt/1",
  "pattern": "decisionTable",
  "goal": "Give the one refusal code for a broken JSON document, or let it through. Then every tool refuses the same input with the same code.",
  "repository": "UOR-Foundation/uor-jcs-nfc",
  "license": "Apache-2.0",
  "app": {
    "name": "jcs-nfc-admission",
    "title": "JCS NFC admission",
    "purpose": "Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest.",
    "fields": [
      {
        "name": "bom",
        "kind": "choice",
        "values": [
          "absent",
          "present"
        ],
        "means": "whether the bytes start with EF BB BF"
      },
      {
        "name": "utf8",
        "kind": "choice",
        "values": [
          "valid",
          "invalid"
        ],
        "means": "whether the bytes are well-formed UTF-8, raw surrogates included as invalid"
      },
      {
        "name": "parse",
        "kind": "choice",
        "values": [
          "ok",
          "json",
          "number-token",
          "number-range",
          "constant",
          "trailing"
        ],
        "means": "the first parse-time finding in input order, then trailing content after the top-level value"
      },
      {
        "name": "names",
        "kind": "choice",
        "values": [
          "distinct",
          "duplicate",
          "colliding"
        ],
        "means": "member names: distinct, duplicate after escape decoding, or distinct but colliding after NFC"
      },
      {
        "name": "surrogate",
        "kind": "choice",
        "values": [
          "none",
          "lone"
        ],
        "means": "whether an escaped unpaired surrogate is reached"
      }
    ],
    "outcomes": [
      "addressed",
      "e-bom",
      "e-utf8",
      "e-json",
      "e-num-token",
      "e-num-range",
      "e-constant",
      "e-trailing",
      "e-dup-name",
      "e-surrogate",
      "e-nfc-collision"
    ],
    "meanings": {
      "addressed": "admitted, canonicalized and digested as sha256:<hex>",
      "e-bom": "E_BOM, leading byte-order mark",
      "e-utf8": "E_UTF8, not well-formed UTF-8",
      "e-json": "E_JSON, malformed JSON",
      "e-num-token": "E_NUM_TOKEN, number token outside -?(0|[1-9][0-9]*)",
      "e-num-range": "E_NUM_RANGE, integer outside plus or minus 9007199254740991",
      "e-constant": "E_CONSTANT, NaN, Infinity or another non-standard constant",
      "e-trailing": "E_TRAILING, content after the top-level value",
      "e-dup-name": "E_DUP_NAME, duplicate member name",
      "e-surrogate": "E_SURROGATE, escaped lone surrogate",
      "e-nfc-collision": "E_NFC_COLLISION, member names collide after NFC, never merged"
    },
    "rules": [
      {
        "when": [
          {
            "field": "bom",
            "op": "is",
            "value": "present"
          }
        ],
        "then": "e-bom",
        "why": "SPEC.md 3.2 and 3.9: E_BOM is a byte-level check before parsing and comes first"
      },
      {
        "when": [
          {
            "field": "utf8",
            "op": "is",
            "value": "invalid"
          }
        ],
        "then": "e-utf8",
        "why": "SPEC.md 3.1 and 3.9: E_UTF8 follows E_BOM"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "json"
          }
        ],
        "then": "e-json",
        "why": "SPEC.md 3.9: parse-time codes fire in input order"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-token"
          }
        ],
        "then": "e-num-token",
        "why": "SPEC.md 3.5: tokens such as 1.0 and 1e0 are refused as text"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-range"
          }
        ],
        "then": "e-num-range",
        "why": "SPEC.md 3.5: values outside the safe-integer bound are refused"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "constant"
          }
        ],
        "then": "e-constant",
        "why": "SPEC.md 3.6: NaN and Infinity are refused"
      },
      {
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "trailing"
          }
        ],
        "then": "e-trailing",
        "why": "SPEC.md 3.3 and 3.9: the remainder check follows the parse-time codes"
      },
      {
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "duplicate"
          }
        ],
        "then": "e-dup-name",
        "why": "SPEC.md 3.4 and 3.9: duplicates after escape decoding, a post-parse scan"
      },
      {
        "when": [
          {
            "field": "surrogate",
            "op": "is",
            "value": "lone"
          }
        ],
        "then": "e-surrogate",
        "why": "SPEC.md 3.7 and 3.9: E_SURROGATE follows E_DUP_NAME"
      },
      {
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "colliding"
          }
        ],
        "then": "e-nfc-collision",
        "why": "SPEC.md 4.1 and 4.3: NFC precedes member sort, and post-normalization collisions are refused in canonicalization, after admission"
      }
    ],
    "otherwise": "addressed",
    "otherwiseWhy": "SPEC.md 5 and uor_jcs_nfc_ref.py address_json: an admitted, canonicalized document is digested",
    "properties": [
      {
        "kind": "always",
        "when": [
          {
            "field": "bom",
            "op": "is",
            "value": "present"
          }
        ],
        "then": "e-bom",
        "why": "one malformed input receives one code, and E_BOM has precedence"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "names",
            "op": "is",
            "value": "colliding"
          }
        ],
        "then": "addressed",
        "why": "a collision is never resolved by last-write-wins, first-write-wins or merging"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "parse",
            "op": "is",
            "value": "number-token"
          }
        ],
        "then": "addressed",
        "why": "an integral value such as 1.0 is still refused"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "surrogate",
            "op": "is",
            "value": "lone"
          }
        ],
        "then": "addressed",
        "why": "a lone escaped surrogate is never digested"
      }
    ],
    "examples": [
      {
        "request": "absent valid ok distinct none",
        "response": "addressed"
      },
      {
        "request": "present invalid json duplicate lone",
        "response": "e-bom"
      },
      {
        "request": "absent invalid ok distinct none",
        "response": "e-utf8"
      },
      {
        "request": "absent valid number-token distinct none",
        "response": "e-num-token"
      },
      {
        "request": "absent valid trailing duplicate none",
        "response": "e-trailing"
      },
      {
        "request": "absent valid ok duplicate lone",
        "response": "e-dup-name"
      },
      {
        "request": "absent valid ok colliding lone",
        "response": "e-surrogate"
      },
      {
        "request": "absent valid ok colliding none",
        "response": "e-nfc-collision"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "Context implementer",
      "text": "Writes an implementation of the digest context and needs the same refusal code as every other implementation for every input.",
      "concerns": [
        "Correct answers",
        "Proved guarantees"
      ]
    },
    {
      "name": "Registry maintainer",
      "text": "Cites the context's final corpus in a registry entry and needs no inadmissible document to receive an address.",
      "concerns": [
        "Proved guarantees",
        "Refused malformed requests"
      ]
    }
  ],
  "components": [
    {
      "name": "Reference implementation",
      "text": "uor_jcs_nfc_ref.py, admit and canonicalize written from SPEC.md.",
      "kind": "cliAdapter"
    },
    {
      "name": "Conformance corpus",
      "text": "conformance/uor-jcs-nfc-vectors-v0.1-rc5.json and its mutation suite run_mutants.py.",
      "kind": "externalSystem"
    }
  ],
  "threats": [
    {
      "name": "Merged colliding names",
      "text": "An implementation merges members whose names collide after NFC, giving two documents one address.",
      "stride": "tampering",
      "asset": "answer",
      "likelihood": "medium",
      "impact": "critical",
      "control": {
        "name": "Collision refusal",
        "text": "Colliding names are refused, never addressed.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "JcsNfcAdmissionProofs::inv002Holds"
          },
          {
            "kind": "gate",
            "reference": "UOR-Foundation/uor-jcs-nfc conformance/run_mutants.py"
          }
        ]
      }
    },
    {
      "name": "Integral float admitted",
      "text": "A type-based guard admits 1.0 or 2^53 as a float with an integral value.",
      "stride": "tampering",
      "asset": "request",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Lexical number admission",
        "text": "Number tokens are validated as text.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "JcsNfcAdmissionProofs::inv003Holds"
          },
          {
            "kind": "review",
            "reference": "UOR-Foundation/uor-jcs-nfc SPEC.md 8 mutation probes"
          }
        ]
      }
    },
    {
      "name": "Different Unicode database",
      "text": "NFC under a Unicode version other than 15.0.0 normalizes differently and yields another digest.",
      "stride": "tampering",
      "asset": "source",
      "likelihood": "medium",
      "impact": "major",
      "accepted": "The app takes the collision finding as given; SPEC.md 1.3 pins Unicode 15.0.0, and gen_vectors.py refuses any other runtime."
    }
  ],
  "quality": [
    {
      "characteristic": "Compatibility",
      "subcharacteristic": "Interoperability",
      "requirement": "One code per input",
      "text": "Every malformed combination receives exactly one of the ten refusal codes SPEC.md 3.8 and 4.3 define.",
      "measure": "Refusal codes",
      "measureText": "Distinct refusal codes the app answers.",
      "threshold": 10
    },
    {
      "characteristic": "Security",
      "subcharacteristic": "Integrity",
      "requirement": "No refused document addressed",
      "text": "No document with any refusal finding receives an address.",
      "measure": "Addressed refusals",
      "measureText": "Acceptance vectors with a refusal finding answered addressed.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "Context implementer",
      "steps": [
        "REQ-001",
        "REQ-002",
        "REQ-003",
        "REQ-007",
        "REQ-008",
        "REQ-009",
        "REQ-010",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Registry maintainer",
      "steps": [
        "INV-001",
        "INV-002",
        "INV-003",
        "INV-004",
        "refuse"
      ]
    }
  ],
  "concerns": [],
  "axioms": {}
}
model/ids.toml 65 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 = "JN-01"
level = "build"
suite = "jcs_nfc_admission"
statement = "The app always answers e-bom when bom is present"

[[id]]
id = "JN-02"
level = "build"
suite = "jcs_nfc_admission"
statement = "The app never answers addressed when names is colliding"

[[id]]
id = "JN-03"
level = "build"
suite = "jcs_nfc_admission"
statement = "The app never answers addressed when parse is number-token"

[[id]]
id = "JN-04"
level = "build"
suite = "jcs_nfc_admission"
statement = "The app never answers addressed when surrogate is lone"

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

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

[[id]]
id = "JN-07"
level = "build"
suite = "jcs_nfc_admission"
statement = "Every compliance obligation is numbered in order and names its evidence"
features/suites/jcs_nfc_admission.feature 44 lines
Feature: jcs_nfc_admission

  This repository's Prism application, in app/, generated by prism-code from its
  spec: Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest.

  @JN-01 @build
  Scenario: The app always answers e-bom when bom is present
    Given the model in app/src/JcsNfcAdmission.lex.tex
    When the Lean kernel checks inv001Holds during prismpm verify
    Then no request meets breaksInv001

  @JN-02 @build
  Scenario: The app never answers addressed when names is colliding
    Given the model in app/src/JcsNfcAdmission.lex.tex
    When the Lean kernel checks inv002Holds during prismpm verify
    Then no request meets breaksInv002

  @JN-03 @build
  Scenario: The app never answers addressed when parse is number-token
    Given the model in app/src/JcsNfcAdmission.lex.tex
    When the Lean kernel checks inv003Holds during prismpm verify
    Then no request meets breaksInv003

  @JN-04 @build
  Scenario: The app never answers addressed when surrogate is lone
    Given the model in app/src/JcsNfcAdmission.lex.tex
    When the Lean kernel checks inv004Holds during prismpm verify
    Then no request meets breaksInv004
  @JN-05 @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
  @JN-06 @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
  @JN-07 @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/jcs_nfc_admission.rs 132 lines
//! The `jcs_nfc_admission` suite: one test per scenario in `features/suites/jcs_nfc_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/JcsNfcAdmissionProofs.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"
    );
}

/// `JN-01`: The app always answers e-bom when bom is present
#[test]
fn jcs_nfc_admission_jn_01() {
    pinned(
        "breaksInv001",
        "body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request bom) =? (JcsNfcAdmission::bomPresent))) && (not ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerEBom))))",
        "inv001Holds",
    );
}

/// `JN-02`: The app never answers addressed when names is colliding
#[test]
fn jcs_nfc_admission_jn_02() {
    pinned(
        "breaksInv002",
        "body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request names) =? (JcsNfcAdmission::namesColliding))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))",
        "inv002Holds",
    );
}

/// `JN-03`: The app never answers addressed when parse is number-token
#[test]
fn jcs_nfc_admission_jn_03() {
    pinned(
        "breaksInv003",
        "body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request parse) =? (JcsNfcAdmission::parseNumberToken))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))",
        "inv003Holds",
    );
}

/// `JN-04`: The app never answers addressed when surrogate is lone
#[test]
fn jcs_nfc_admission_jn_04() {
    pinned(
        "breaksInv004",
        "body: ((((((((project request bom) <? 2) && ((project request utf8) <? 2)) && ((project request parse) <? 6)) && ((project request names) <? 3)) && ((project request surrogate) <? 2)) && ((project request surrogate) =? (JcsNfcAdmission::surrogateLone))) && ((JcsNfcAdmission::judge request) =? (JcsNfcAdmission::answerAddressed)))",
        "inv004Holds",
    );
}

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

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

/// `JN-07`: Every compliance obligation is numbered in order and names its evidence
#[test]
fn jcs_nfc_admission_jn_07() {
    holds(
        "app/src/Compliance.lex.tex",
        "everyObligationEvidenced",
        "((obligationsEvidenced 0 (obligations)) = true)",
    );
}
site/app.json 121 lines
{
  "name": "JCS NFC admission",
  "shortName": "JCS",
  "live": "https://uor-foundation.github.io/uor-jcs-nfc/",
  "purpose": "Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest. Send bom, utf8, parse, names or surrogate, separated by spaces; it answers addressed, e-bom, e-utf8, e-json, e-num-token, e-num-range, e-constant, e-trailing, e-dup-name, e-surrogate or e-nfc-collision, and invalid request for anything else.",
  "inputLabel": "Request: bom utf8 parse names surrogate",
  "placeholder": "absent valid ok distinct none",
  "submitLabel": "Decide",
  "outputLabel": "Answer",
  "answers": {
    "positive": [
      "addressed"
    ],
    "negative": [
      "e-bom",
      "e-utf8",
      "e-json",
      "e-num-token",
      "e-num-range",
      "e-constant",
      "e-trailing",
      "e-dup-name",
      "e-surrogate",
      "e-nfc-collision"
    ],
    "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": "JN-01: the app always answers e-bom when bom is present. JN-02: the app never answers addressed when names is colliding. JN-03: the app never answers addressed when parse is number-token. JN-04: the app never answers addressed when surrogate is lone.",
  "proposition": {
    "name": "judge",
    "text": "judge request :=\n  bom is present → e-bom\n  utf8 is invalid → e-utf8\n  parse is json → e-json\n  parse is number-token → e-num-token\n  parse is number-range → e-num-range\n  parse is constant → e-constant\n  parse is trailing → e-trailing\n  names is duplicate → e-dup-name\n  surrogate is lone → e-surrogate\n  names is colliding → e-nfc-collision\n  otherwise → addressed",
    "plain": "Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest."
  },
  "theorems": [
    {
      "name": "inv001Holds",
      "statement": "no request meets breaksInv001: the app always answers e-bom when bom is present",
      "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/JcsNfcAdmissionProofs.lex.tex"
    },
    {
      "name": "inv002Holds",
      "statement": "no request meets breaksInv002: the app never answers addressed when names is colliding",
      "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/JcsNfcAdmissionProofs.lex.tex"
    },
    {
      "name": "inv003Holds",
      "statement": "no request meets breaksInv003: the app never answers addressed when parse is number-token",
      "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/JcsNfcAdmissionProofs.lex.tex"
    },
    {
      "name": "inv004Holds",
      "statement": "no request meets breaksInv004: the app never answers addressed when surrogate is lone",
      "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/JcsNfcAdmissionProofs.lex.tex"
    }
  ],
  "pinned": [
    {
      "name": "jcs_nfc_admission_jn_01",
      "what": "JN-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/jcs_nfc_admission.rs"
    },
    {
      "name": "jcs_nfc_admission_jn_02",
      "what": "JN-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/jcs_nfc_admission.rs"
    },
    {
      "name": "jcs_nfc_admission_jn_03",
      "what": "JN-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/jcs_nfc_admission.rs"
    },
    {
      "name": "jcs_nfc_admission_jn_04",
      "what": "JN-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/jcs_nfc_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/uor-jcs-nfc/actions/workflows/bootstrap.yml"
    },
    "build": {
      "id": "printed by prismpm verify in every pages run",
      "url": "https://github.com/UOR-Foundation/uor-jcs-nfc/actions/workflows/pages.yml"
    }
  },
  "repository": "https://github.com/UOR-Foundation/uor-jcs-nfc",
  "report": "https://github.com/UOR-Foundation/uor-jcs-nfc/blob/main/TEMPLATE-VERIFICATION.md"
}
openspec/specs/jcs-nfc-admission/spec.md 248 lines
# jcs-nfc-admission Specification

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

## Purpose

JCS NFC admission: Give the UOR-JCS-NFC answer for one document from what admission and canonicalization find in it: the first refusal code by the section 3.9 precedence and the NFC collision check, or addressed when it receives its sha256 digest.

## Requirements

### Requirement: Always e-bom when bom is present

The app SHALL answer `e-bom` when bom is present, because one malformed input receives one code, and E_BOM has precedence.

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

#### Scenario: INV-001 holds

- **WHEN** the request is `present invalid json duplicate lone` (an acceptance example)
- **THEN** the answer SHALL be `e-bom`
- **AND** the app answers `e-bom`, decided by REQ-001

### Requirement: Never addressed when names is colliding

The app SHALL NOT answer `addressed` when names is colliding, because a collision is never resolved by last-write-wins, first-write-wins or merging.

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

#### Scenario: INV-002 holds

- **WHEN** the request is `absent valid ok colliding lone` (an acceptance example)
- **THEN** the answer SHALL NOT be `addressed`
- **AND** the app answers `e-surrogate`, decided by REQ-009

### Requirement: Never addressed when parse is number-token

The app SHALL NOT answer `addressed` when parse is number-token, because an integral value such as 1.0 is still refused.

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

#### Scenario: INV-003 holds

- **WHEN** the request is `absent valid number-token distinct none` (an acceptance example)
- **THEN** the answer SHALL NOT be `addressed`
- **AND** the app answers `e-num-token`, decided by REQ-004

### Requirement: Never addressed when surrogate is lone

The app SHALL NOT answer `addressed` when surrogate is lone, because a lone escaped surrogate is never digested.

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

#### Scenario: INV-004 holds

- **WHEN** the request is `present invalid json duplicate lone` (an acceptance example)
- **THEN** the answer SHALL NOT be `addressed`
- **AND** the app answers `e-bom`, decided by REQ-001

### Requirement: REQ-001 e-bom when bom is present

The app SHALL answer `e-bom` when bom is present, because SPEC.md 3.2 and 3.9: E_BOM is a byte-level check before parsing and comes first.

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

#### Scenario: REQ-001 decides

- **WHEN** the request is `present invalid json duplicate lone` (an acceptance example)
- **THEN** the answer SHALL be `e-bom`, decided by REQ-001

### Requirement: REQ-002 e-utf8 when utf8 is invalid

The app SHALL answer `e-utf8` when utf8 is invalid and no earlier rule matches, because SPEC.md 3.1 and 3.9: E_UTF8 follows E_BOM.

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

#### Scenario: REQ-002 decides

- **WHEN** the request is `absent invalid ok distinct none` (an acceptance example)
- **THEN** the answer SHALL be `e-utf8`, decided by REQ-002

### Requirement: REQ-003 e-json when parse is json

The app SHALL answer `e-json` when parse is json and no earlier rule matches, because SPEC.md 3.9: parse-time codes fire in input order.

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

#### Scenario: REQ-003 decides

- **WHEN** the request is `absent valid json distinct none`
- **THEN** the answer SHALL be `e-json`, decided by REQ-003

### Requirement: REQ-004 e-num-token when parse is number-token

The app SHALL answer `e-num-token` when parse is number-token and no earlier rule matches, because SPEC.md 3.5: tokens such as 1.0 and 1e0 are refused as text.

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

#### Scenario: REQ-004 decides

- **WHEN** the request is `absent valid number-token distinct none` (an acceptance example)
- **THEN** the answer SHALL be `e-num-token`, decided by REQ-004

### Requirement: REQ-005 e-num-range when parse is number-range

The app SHALL answer `e-num-range` when parse is number-range and no earlier rule matches, because SPEC.md 3.5: values outside the safe-integer bound are refused.

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

#### Scenario: REQ-005 decides

- **WHEN** the request is `absent valid number-range distinct none`
- **THEN** the answer SHALL be `e-num-range`, decided by REQ-005

### Requirement: REQ-006 e-constant when parse is constant

The app SHALL answer `e-constant` when parse is constant and no earlier rule matches, because SPEC.md 3.6: NaN and Infinity are refused.

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

#### Scenario: REQ-006 decides

- **WHEN** the request is `absent valid constant distinct none`
- **THEN** the answer SHALL be `e-constant`, decided by REQ-006

### Requirement: REQ-007 e-trailing when parse is trailing

The app SHALL answer `e-trailing` when parse is trailing and no earlier rule matches, because SPEC.md 3.3 and 3.9: the remainder check follows the parse-time codes.

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

#### Scenario: REQ-007 decides

- **WHEN** the request is `absent valid trailing duplicate none` (an acceptance example)
- **THEN** the answer SHALL be `e-trailing`, decided by REQ-007

### Requirement: REQ-008 e-dup-name when names is duplicate

The app SHALL answer `e-dup-name` when names is duplicate and no earlier rule matches, because SPEC.md 3.4 and 3.9: duplicates after escape decoding, a post-parse scan.

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

#### Scenario: REQ-008 decides

- **WHEN** the request is `absent valid ok duplicate lone` (an acceptance example)
- **THEN** the answer SHALL be `e-dup-name`, decided by REQ-008

### Requirement: REQ-009 e-surrogate when surrogate is lone

The app SHALL answer `e-surrogate` when surrogate is lone and no earlier rule matches, because SPEC.md 3.7 and 3.9: E_SURROGATE follows E_DUP_NAME.

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

#### Scenario: REQ-009 decides

- **WHEN** the request is `absent valid ok colliding lone` (an acceptance example)
- **THEN** the answer SHALL be `e-surrogate`, decided by REQ-009

### Requirement: REQ-010 e-nfc-collision when names is colliding

The app SHALL answer `e-nfc-collision` when names is colliding and no earlier rule matches, because SPEC.md 4.1 and 4.3: NFC precedes member sort, and post-normalization collisions are refused in canonicalization, after admission.

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

#### Scenario: REQ-010 decides

- **WHEN** the request is `absent valid ok colliding none` (an acceptance example)
- **THEN** the answer SHALL be `e-nfc-collision`, decided by REQ-010

### Requirement: Otherwise addressed

The app SHALL answer `addressed` when no rule matches, because SPEC.md 5 and uor_jcs_nfc_ref.py address_json: an admitted, canonicalized document is digested.

Verified: tested by the acceptance vectors.

#### Scenario: No rule matches

- **WHEN** the request is `absent valid ok distinct none` (an acceptance example)
- **THEN** the answer SHALL be `addressed`

### 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 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 `present invalid json duplicate lone` (an acceptance example)
- **THEN** the answer SHALL be `e-bom`, decided by REQ-001, the earlier rule

### Requirement: Request and answers

The app SHALL read one request as one line of 5 fields separated by single spaces, in this order, and SHALL answer exactly one of `addressed`, `e-bom`, `e-utf8`, `e-json`, `e-num-token`, `e-num-range`, `e-constant`, `e-trailing`, `e-dup-name`, `e-surrogate`, `e-nfc-collision`, or `invalid` for anything else.

| Field | Accepts | Means |
| --- | --- | --- |
| `bom` | `absent`, `present` | whether the bytes start with EF BB BF |
| `utf8` | `valid`, `invalid` | whether the bytes are well-formed UTF-8, raw surrogates included as invalid |
| `parse` | `ok`, `json`, `number-token`, `number-range`, `constant`, `trailing` | the first parse-time finding in input order, then trailing content after the top-level value |
| `names` | `distinct`, `duplicate`, `colliding` | member names: distinct, duplicate after escape decoding, or distinct but colliding after NFC |
| `surrogate` | `none`, `lone` | whether an escaped unpaired surrogate is reached |

| Answer | Means |
| --- | --- |
| `addressed` | admitted, canonicalized and digested as sha256:<hex> |
| `e-bom` | E_BOM, leading byte-order mark |
| `e-utf8` | E_UTF8, not well-formed UTF-8 |
| `e-json` | E_JSON, malformed JSON |
| `e-num-token` | E_NUM_TOKEN, number token outside -?(0|[1-9][0-9]*) |
| `e-num-range` | E_NUM_RANGE, integer outside plus or minus 9007199254740991 |
| `e-constant` | E_CONSTANT, NaN, Infinity or another non-standard constant |
| `e-trailing` | E_TRAILING, content after the top-level value |
| `e-dup-name` | E_DUP_NAME, duplicate member name |
| `e-surrogate` | E_SURROGATE, escaped lone surrogate |
| `e-nfc-collision` | E_NFC_COLLISION, member names collide after NFC, never merged |
| `invalid` | the request is malformed |

Verified: reading a request is tested, not proved.

#### Scenario: A malformed request is invalid

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

## Examples

- `absent valid ok distinct none` gives `addressed`
- `present invalid json duplicate lone` gives `e-bom`
- `absent invalid ok distinct none` gives `e-utf8`
- `absent valid number-token distinct none` gives `e-num-token`
- `absent valid trailing duplicate none` gives `e-trailing`
- `absent valid ok duplicate lone` gives `e-dup-name`
- `absent valid ok colliding lone` gives `e-surrogate`
- `absent valid ok colliding none` gives `e-nfc-collision`

## 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/JcsNfcAdmission.lex.tex` is the LexLean model generated from it. It is the single source of the app.

how-to guideBuildexampleMarkdown

Words on this page 6
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.
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.
decision table
A table of rules, as in OMG DMN 1.5: each row says which inputs lead to which outcome.