# Compression admission

> Decide if a new UORC archive replaces the best one so far. A smaller size must never come at the cost of lost data.

Inspired by UOR-Foundation/compression (https://github.com/UOR-Foundation/compression), live at https://uor-foundation.github.io/compression/. UORC, lossless compression whose compressed object is an executable Universal Object Reference. Pattern: Decision table, OMG DMN 1.5, hit policy FIRST. To write one of your own, follow How to build a decision table app (../../guides/decision-table/index.md). The prompt below is data, quoted from the example.

**Figure: What the Compression admission app does.** A request goes in, the rules decide, and the Lean kernel has already proved what the rules promise.

| Step | What happens |
| --- | --- |
| 1. Request | roundtrip, incumbent, candidate, order |
| 2. 4 rules | the first that matches wins |
| 3. Answer | admit, keep, refuse |
| 4. Proved | 3 theorems, 40 tests |

Verified by prismpm verify in the pinned SDK. Fingerprint: ac05263a0359acd8888df31d00c7b77fb4d3bc5de05f13fa6655c357a867fc3a. Acceptance vectors: 40. Claims: 6.

## The prompt

```json
{
  "schema": "prism/prompt/1",
  "goal": "Decide if a new UORC archive replaces the best one so far. A smaller size must never come at the cost of lost data.",
  "pattern": "decisionTable",
  "repository": "UOR-Foundation/compression",
  "app": {
    "name": "uorc-admission",
    "title": "Compression admission",
    "purpose": "Decide whether a checked candidate replaces the incumbent archive, the incumbent is kept, or the candidate is refused, from its byte-exact replay, both wire lengths and, on a tie, their byte order.",
    "fields": [
      {
        "name": "roundtrip",
        "kind": "choice",
        "values": [
          "exact",
          "differs"
        ],
        "means": "whether replay reproduces every object and boundary byte for byte"
      },
      {
        "name": "incumbent",
        "kind": "number",
        "min": 0,
        "means": "the best-known archive's wire length, in bytes"
      },
      {
        "name": "candidate",
        "kind": "number",
        "min": 0,
        "means": "the candidate archive's wire length, in bytes"
      },
      {
        "name": "order",
        "kind": "choice",
        "values": [
          "before",
          "same",
          "after"
        ],
        "means": "with equal lengths, the candidate bytes against the incumbent bytes"
      }
    ],
    "outcomes": [
      "admit",
      "keep",
      "refuse"
    ],
    "meanings": {
      "admit": "the candidate replaces the incumbent as best-known archive",
      "keep": "the incumbent stays best-known",
      "refuse": "the candidate is not lossless and is rejected"
    },
    "rules": [
      {
        "when": [
          {
            "field": "roundtrip",
            "op": "is",
            "value": "differs"
          }
        ],
        "then": "refuse",
        "why": "src/Uorc/Search/Verify.lex.tex runTrial: any mismatch rejects the trial (full_bytes_not_digest_equality)"
      },
      {
        "when": [
          {
            "field": "candidate",
            "op": "<",
            "value": {
              "field": "incumbent"
            }
          }
        ],
        "then": "admit",
        "why": "src/Uorc/Search/OrderRope.lex.tex beginDecision: a shorter challenger replaces the incumbent"
      },
      {
        "when": [
          {
            "field": "candidate",
            "op": ">",
            "value": {
              "field": "incumbent"
            }
          }
        ],
        "then": "keep",
        "why": "OrderRope.lex.tex beginDecision: a longer challenger keeps the incumbent"
      },
      {
        "when": [
          {
            "field": "order",
            "op": "is",
            "value": "before"
          }
        ],
        "then": "admit",
        "why": "OrderRope.lex.tex: on equal length the first differing byte decides, and a smaller byte replaces"
      }
    ],
    "otherwise": "keep",
    "otherwiseWhy": "equal length and not before in byte order: keepIncumbent",
    "properties": [
      {
        "kind": "never",
        "when": [
          {
            "field": "roundtrip",
            "op": "is",
            "value": "differs"
          }
        ],
        "then": "admit",
        "why": "a lossy candidate is never admitted"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "candidate",
            "op": ">",
            "value": {
              "field": "incumbent"
            }
          }
        ],
        "then": "admit",
        "why": "the best-known archive never grows"
      },
      {
        "kind": "always",
        "when": [
          {
            "field": "roundtrip",
            "op": "is",
            "value": "exact"
          },
          {
            "field": "candidate",
            "op": "<",
            "value": {
              "field": "incumbent"
            }
          }
        ],
        "then": "admit",
        "why": "an exact, strictly shorter archive always replaces"
      }
    ],
    "examples": [
      {
        "request": "exact 1000 640 same",
        "response": "admit"
      },
      {
        "request": "exact 640 640 before",
        "response": "admit"
      },
      {
        "request": "exact 640 640 after",
        "response": "keep"
      },
      {
        "request": "exact 640 640 same",
        "response": "keep"
      },
      {
        "request": "exact 640 700 before",
        "response": "keep"
      },
      {
        "request": "differs 1000 10 before",
        "response": "refuse"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "Compression researcher",
      "text": "Searches for smaller references and needs every admitted one to be exact and no longer than the one it replaces.",
      "concerns": [
        "Proved guarantees",
        "Correct answers"
      ]
    },
    {
      "name": "Benchmark reviewer",
      "text": "Compares measured results and needs a best-known archive never to be stated as a record or a minimum.",
      "concerns": [
        "Claim boundaries"
      ]
    }
  ],
  "concerns": [
    {
      "name": "Claim boundaries",
      "text": "A best-known checked archive is not a minimality certificate or a record; record status exists only when an external authority accepts it.",
      "model": "quality"
    }
  ],
  "components": [
    {
      "name": "UORC web client",
      "text": "The accessible file-oriented client in web/ and client/ that runs the search and shows the archive.",
      "kind": "staticSite"
    },
    {
      "name": "External record authority",
      "text": "The benchmark authority whose own rules decide whether a measured result is a record.",
      "kind": "externalSystem"
    }
  ],
  "threats": [
    {
      "name": "Digest-only verification",
      "text": "A candidate is accepted because a digest matched, while its bytes or boundaries differ.",
      "stride": "tampering",
      "asset": "answer",
      "likelihood": "low",
      "impact": "critical",
      "control": {
        "name": "Full byte replay",
        "text": "Verification compares every byte and boundary, never only a digest, and a mismatch is never admitted.",
        "evidence": [
          {
            "kind": "review",
            "reference": "src/Uorc/Search/Verify.lex.tex full_bytes_not_digest_equality"
          },
          {
            "kind": "proof",
            "reference": "UorcAdmissionProofs::inv001Holds"
          }
        ]
      }
    },
    {
      "name": "Boundary-shifted collection",
      "text": "An archive reproduces the same flattened bytes with the object boundaries moved.",
      "stride": "tampering",
      "asset": "request",
      "likelihood": "low",
      "impact": "major",
      "control": {
        "name": "Boundaries checked",
        "text": "Replay checks object counts and lengths, so a shifted boundary is a mismatch.",
        "evidence": [
          {
            "kind": "review",
            "reference": "src/Uorc/Search/Verify.lex.tex same_flattening_different_boundary_rejected"
          }
        ]
      }
    },
    {
      "name": "Record claimed",
      "text": "A best-known archive is published as a compression record or a minimum.",
      "stride": "repudiation",
      "asset": "answer",
      "likelihood": "medium",
      "impact": "major",
      "accepted": "The engine states only a best-known checked archive and produces no minimality certificate; README claim boundaries leave record status to the external authority."
    }
  ],
  "quality": [
    {
      "characteristic": "Functional suitability",
      "subcharacteristic": "Functional correctness",
      "requirement": "Lossless admissions",
      "text": "Every admitted archive replays its objects exactly.",
      "measure": "Lossy admissions",
      "measureText": "Requests with roundtrip differs answered admit.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "Compression researcher",
      "steps": [
        "REQ-001",
        "REQ-002",
        "REQ-003",
        "REQ-004",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Benchmark reviewer",
      "steps": [
        "INV-001",
        "INV-002",
        "INV-003"
      ]
    }
  ],
  "license": "MIT OR Apache-2.0",
  "axioms": {}
}
```

## Claims

- UA-01: The app never answers admit when roundtrip is differs
- UA-02: The app never answers admit when candidate is above incumbent
- UA-03: The app always answers admit when roundtrip is exact and candidate is below incumbent
- UA-04: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
- UA-05: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
- UA-06: Every compliance obligation is numbered in order and names its evidence

## 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.

| Pattern | Standard | Answers |
| --- | --- | --- |
| Decision table | OMG DMN 1.5, hit policy FIRST | admit, keep, refuse |

**Figure: Rules for each answer.** Each bar counts the rules that give one answer. When no rule matches, the answer is keep.

|  | rules |
| --- | --- |
| admit | 2 |
| keep | 1 |
| refuse | 1 |

## Behavior

A request is roundtrip, incumbent, candidate, order, separated by spaces. The first rule that matches decides. If none matches, the answer is keep. A request over 112 bytes, or in any other form, is answered invalid.

| Rule | When | Answer | Why |
| --- | --- | --- | --- |
| REQ-001 | roundtrip is differs | refuse | src/Uorc/Search/Verify.lex.tex runTrial: any mismatch rejects the trial (full\_bytes\_not\_digest\_equality) |
| REQ-002 | candidate is below incumbent | admit | src/Uorc/Search/OrderRope.lex.tex beginDecision: a shorter challenger replaces the incumbent |
| REQ-003 | candidate is above incumbent | keep | OrderRope.lex.tex beginDecision: a longer challenger keeps the incumbent |
| REQ-004 | order is before | admit | OrderRope.lex.tex: on equal length the first differing byte decides, and a smaller byte replaces |
| otherwise | no rule matches | keep | equal length and not before in byte order: keepIncumbent |

## 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.

| Property | Statement | Theorem | Why |
| --- | --- | --- | --- |
| INV-001 | It never answers admit when roundtrip is differs. | UorcAdmissionProofs::inv001Holds | a lossy candidate is never admitted |
| INV-002 | It never answers admit when candidate is above incumbent. | UorcAdmissionProofs::inv002Holds | the best-known archive never grows |
| INV-003 | It always answers admit when roundtrip is exact and candidate is below incumbent. | UorcAdmissionProofs::inv003Holds | an exact, strictly shorter archive always replaces |

## Architecture

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

| Stakeholder | Who they are | Concerns |
| --- | --- | --- |
| Benchmark reviewer | Compares measured results and needs a best-known archive never to be stated as a record or a minimum. | Claim boundaries |
| Compression researcher | Searches for smaller references and needs every admitted one to be exact and no longer than the one it replaces. | Proved guarantees, Correct answers |
| Verifier | Anyone 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.

| Concern | What it means | Model |
| --- | --- | --- |
| Claim boundaries | A best-known checked archive is not a minimality certificate or a record; record status exists only when an external authority accepts it. | quality |
| Correct answers | Every well-formed request is answered by the first rule that matches it, or keep when none does, as the spec states. | quality |
| Integrity of the published app | What a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it. | security |
| Proved guarantees | Each of the 3 properties of the spec holds for every request, proved by the Lean kernel. | quality |
| Refused malformed requests | A request that is not the 4 fields in order, or is longer than 112 bytes, is answered invalid and never guessed. | security |

## Components

8 components and 11 edges between them.

| Component | Kind | What it is |
| --- | --- | --- |
| Browser | externalSystem | The visitor's web browser, which loads the page and runs the Compression admission guest. |
| Compression admission guest | service | The Core-Wasm guest built from the model: it answers one request of at most 112 bytes with one answer of at most 64. |
| Compression admission page | staticSite | The page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors. |
| External record authority | externalSystem | The benchmark authority whose own rules decide whether a measured result is a record. |
| GitHub Pages | externalSystem | Serves the page and the holo from the repository Pages workflow. |
| Prism build | cliAdapter | prismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector. |
| Source repository | externalSystem | The repository that holds the prompt, the model and its gate. |
| UORC web client | staticSite | The accessible file-oriented client in web/ and client/ that runs the search and shows the archive. |

## Design views

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

| View | Diagram | Viewpoint |
| --- | --- | --- |
| Deciding a Compression admission request | opmObjectProcess | Compression researcher: Correct answers |
| Components of Compression admission | umlComponent | Verifier: Integrity of the published app |
| Answering a Compression admission request | umlSequence | Compression researcher: Correct answers |
| States of the Compression admission guest | umlStateMachine | Verifier: Refused malformed requests |

## Features and journeys

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

| Feature | Calls | Accepted by |
| --- | --- | --- |
| When roundtrip is differs, the answer is refuse. | UorcAdmission::rule1, UorcAdmission::judge | UorcAdmission::application |
| When candidate is below incumbent, the answer is admit. | UorcAdmission::rule2, UorcAdmission::judge | UorcAdmission::application |
| When candidate is above incumbent, the answer is keep. | UorcAdmission::rule3, UorcAdmission::judge | UorcAdmission::application |
| When order is before, the answer is admit. | UorcAdmission::rule4, UorcAdmission::judge | UorcAdmission::application |
| When no rule matches, the answer is keep. | UorcAdmission::judge | UorcAdmission::application |
| A request that is not roundtrip, incumbent, candidate, order in order, separated by single spaces, or is over 112 bytes, is answered invalid. | UorcAdmission::dispatch, UorcAdmission::decodeField1 | UorcAdmission::application |
| It never answers admit when roundtrip is differs. | UorcAdmission::judge | UorcAdmissionProofs::inv001Holds |
| It never answers admit when candidate is above incumbent. | UorcAdmission::judge | UorcAdmissionProofs::inv002Holds |
| It always answers admit when roundtrip is exact and candidate is below incumbent. | UorcAdmission::judge | UorcAdmissionProofs::inv003Holds |

## Journeys

The ordered features each stakeholder takes.

| Stakeholder | Steps |
| --- | --- |
| Benchmark reviewer | INV-001 → INV-002 → INV-003 |
| Compression researcher | REQ-001 → REQ-002 → REQ-003 → REQ-004 → otherwise |
| Verifier | refuse → INV-001 → INV-002 → INV-003 |

## Security and threat model

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

| Threat | STRIDE | Asset | Risk | Answered by |
| --- | --- | --- | --- | --- |
| Answer that breaks INV-001 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-001: proof UorcAdmissionProofs::inv001Holds |
| Answer that breaks INV-002 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-002: proof UorcAdmissionProofs::inv002Holds |
| Answer that breaks INV-003 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-003: proof UorcAdmissionProofs::inv003Holds |
| Boundary-shifted collection | tampering | Request bytes | low likelihood, major impact | Boundaries checked: review src/Uorc/Search/Verify.lex.tex same\_flattening\_different\_boundary\_rejected |
| Digest-only verification | tampering | Answer | low likelihood, critical impact | Full byte replay: review src/Uorc/Search/Verify.lex.tex full\_bytes\_not\_digest\_equality; proof UorcAdmissionProofs::inv001Holds |
| Granted capability | informationDisclosure | Answer | low likelihood, major impact | No capability granted: gate prism-code check refuses an ungranted guest import |
| Malformed request | tampering | Request bytes | high likelihood, major impact | Strict decoder: gate malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify |
| Oversized request | denialOfService | Request bytes | medium likelihood, minor impact | Bounded request: gate acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify |
| Record claimed | repudiation | Answer | medium likelihood, major impact | accepted: The engine states only a best-known checked archive and produces no minimality certificate; README claim boundaries leave record status to the external authority. |
| Substituted holo | spoofing | Published holo | low likelihood, critical impact | Fingerprint and provenance: gate actions/attest-build-provenance in the pages workflow; gate prism-code check of the holo identities in the page |
| Substituted host | spoofing | Published holo | low likelihood, critical impact | accepted: 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 model | tampering | Model source | low likelihood, major impact | Regenerated 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.

| Requirement | Characteristic | Measure | Threshold |
| --- | --- | --- | --- |
| Bounded allocation: The guest allocates at most 224 bytes for one request. | Performance efficiency: Resource utilization | Guest allocation bytes | 224 |
| Bounded request: A request over 112 bytes is refused before any field is read. | Performance efficiency: Time behaviour | Request bytes read | 112 |
| Every property proved: All 3 properties are theorems the Lean kernel checks. | Security: Integrity | Unproved properties | 0 |
| Every request answered: Every request gets an answer: a rule, keep otherwise, or invalid. | Functional suitability: Functional completeness | Unanswered requests | 0 |
| Every vector replays: All 40 acceptance vectors replay in the compiled guest, the shortest 0 bytes long. | Reliability: Faultlessness | Failed vectors | 0 |
| Examples answered as stated: Every one of the 6 examples of the spec is answered as it states. | Functional suitability: Functional correctness | Example mismatches | 0 |
| Lossless admissions: Every admitted archive replays its objects exactly. | Functional suitability: Functional correctness | Lossy admissions | 0 |

## Compliance

One obligation per standard, each naming its evidence.

| Standard | Subject | Evidence |
| --- | --- | --- |
| ISO/IEC/IEEE 42010:2022 | Architecture description | Architecture::architectureDescriptionHolds |
| ISO/PAS 19450:2015 and OMG UML 2.5.1 | Design views | Design::viewOpmDecide, Design::viewUmlComponents, Design::viewUmlRequest, Design::viewUmlStates |
| ISO/IEC 25010:2023 | Product quality | Quality::qualityModelHolds |
| ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022 | Application security and risk | Security::controlSet |
| OMG DMN 1.5, hit policy FIRST | Decision table | UorcAdmission::judge |
| OpenSpec | Requirements | UorcAdmission::application |
| SPDX MIT OR Apache-2.0 | Licensing | UorcAdmission::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 Compression admission request
Viewpoint: Architecture::viewpointCompressionResearcherCorrectAnswers
Notation: ISO/PAS 19450:2015 OPM, Prism OPL profile

componentBrowser is an object.
componentCompressionAdmissionGuest is an object.
componentCompressionAdmissionGuest can be stateDeciding or stateIdle.
processDecide is a process.
processEncodeAnswer is a process.
processJudge is a process.
processParseRequest is a process.
componentCompressionAdmissionGuest 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 Compression admission
component "componentBrowser" as c0
component "componentCompressionAdmissionGuest" as c1
component "componentCompressionAdmissionPage" as c2
component "componentExternalRecordAuthority" as c3
component "componentGitHubPages" as c4
component "componentPrismBuild" as c5
component "componentSourceRepository" as c6
component "componentUORCWebClient" as c7
c0 --> c1 : edgeBrowserToCompressionAdmissionGuest
c1 --> c0 : edgeCompressionAdmissionGuestToBrowser
c1 --> c3 : edgeCompressionAdmissionGuestToExternalRecordAuthority
c1 --> c7 : edgeCompressionAdmissionGuestToUORCWebClient
c2 --> c4 : edgeCompressionAdmissionPageToGitHubPages
c3 --> c1 : edgeExternalRecordAuthorityToCompressionAdmissionGuest
c4 --> c0 : edgeGitHubPagesToBrowser
c5 --> c1 : edgePrismBuildToCompressionAdmissionGuest
c5 --> c2 : edgePrismBuildToCompressionAdmissionPage
c6 --> c5 : edgeSourceRepositoryToPrismBuild
c7 --> c1 : edgeUORCWebClientToCompressionAdmissionGuest
@enduml

```

### design/Design.viewUmlRequest.puml

```
@startuml
' UML 2.5.1 sequence diagram
' view: Design::viewUmlRequest
' viewpoint: Architecture::viewpointCompressionResearcherCorrectAnswers
title Answering a Compression admission request
participant "componentBrowser" as p0
participant "componentCompressionAdmissionGuest" 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::viewpointVerifierRefusedMalformedRequests
title States of the Compression admission guest
state "stateAnsweredAdmit" as s0
state "stateAnsweredKeep" as s1
state "stateAnsweredRefuse" as s2
state "stateDeciding" as s3
state "stateIdle" as s4
state "stateRefused" as s5
[*] --> s4
s4 --> s3 : processParseRequest
s4 --> s5 : processParseRequest
s3 --> s2 : processRule1
s3 --> s0 : processRule2
s3 --> s1 : processRule3
s3 --> s0 : processRule4
s3 --> s1 : processOtherwise
s0 --> s4 : processEncodeAnswer
s1 --> s4 : processEncodeAnswer
s2 --> s4 : processEncodeAnswer
s5 --> s4 : processEncodeAnswer
@enduml

```

## Prism source

Every file the builder wrote, laid out as a repository created from UOR-Foundation/template; the download prism-uorc-admission.zip has them all.

- app/src/Architecture.lex.tex (399 lines)
- app/src/Compliance.lex.tex (56 lines)
- app/src/Design.lex.tex (549 lines)
- app/src/Features.lex.tex (116 lines)
- app/src/Quality.lex.tex (347 lines)
- app/src/Security.lex.tex (551 lines)
- app/src/UorcAdmission.lex.tex (234 lines)
- app/src/UorcAdmissionProofs.lex.tex (105 lines)
- app/lexlean.toml (43 lines)
- app/prompt.json (300 lines)
- model/ids.toml (59 lines)
- features/suites/uorc\_admission.feature (38 lines)
- crates/conformance/tests/uorc\_admission.rs (122 lines)
- site/app.json (102 lines)
- openspec/specs/uorc-admission/spec.md (159 lines)
