Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/GAMEPLAY_EVIDENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Gameplay Evidence Exchange v0.1

`mcproof.gameplay_evidence` implements the closed interchange envelope in [`schema/gameplay-evidence-v0.1.schema.json`](../schema/gameplay-evidence-v0.1.schema.json). It uses only the Python standard library.

```python
from mcproof.gameplay_evidence import load_gameplay_artifact, verify_gameplay_artifact

artifact = load_gameplay_artifact(received_text) # rejects duplicate JSON keys
report = verify_gameplay_artifact(artifact)
if not report["valid"]:
raise ValueError(report["errors"])
print(report["source_badges"])
print(report["admitted_badges"])
```

`canonical_json_bytes` emits sorted, compact, ASCII-escaped UTF-8 JSON. `sha256_json` hashes those bytes.

The verifier recomputes the artifact self-digest, exact source UTF-8 digest, four payload commitments, and three payload commitments on every check. It rejects unknown or missing envelope keys, duplicate keys during loading, every floating-point value, integers outside signed 64 bits, non-string object keys, malformed or all-zero SHA-256 fields, and non-boolean negative-control results.

## Badge boundary

`source_badges` summarizes the producer's checks. Higher source badges require the explicit passing checks and a passing negative control stated in the contract. `LIVE_CONFIRMED` also needs passing model replay or model proof over the same payload commitments. `MODEL_PROVEN` and `LIVE_CONFIRMED` remain independent. Any recorded `FAIL` is an unresolved aggregation veto, so a second `PASS` cannot hide it. Missing checks or negative controls do not promote an artifact.

`admitted_badges` contains only `OBSERVED`: this dependency-free module validates structure and commitments but does not independently rerun domain checks. Higher admissions belong to a trusted domain verifier bound to the exact artifact, check, and negative-control digests. `derive_evidence_badges` returns only the admitted list.

`source_labels` is preserved as source data and ignored by source badge derivation. In particular, `VERIFIED`, `MODEL_PROVEN`, or `LIVE_CONFIRMED` supplied as labels cannot promote evidence. Invalid artifacts always return empty source and admitted lists.

## What validation does not establish

A `valid` report establishes structural and digest consistency only. It does **not** parse or execute `source.raw`, rerun replay/proof/live checkers, validate SimGrammar YAML, establish that negative-control prose genuinely documents rejection, or resolve domain semantics.

A trusted domain adapter must do those checks separately. Source check records, checker pins, controls, limitations, and labels remain claims bound by the envelope, not independently reproduced findings.

The JSON Schema closes the envelope and expresses field types, formats, and recursive JSON-safe values where practical. JSON Schema alone cannot reject duplicate input keys, compare digests, hash exact source bytes, derive badges, or consistently distinguish lexical floats such as `1.0` from integers across implementations. The runtime verifier rejects every float and is authoritative for those rules.
219 changes: 219 additions & 0 deletions schema/gameplay-evidence-v0.1.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://proven-commons.github.io/mcproof/schema/gameplay-evidence-v0.1.schema.json",
"title": "Gameplay Evidence Exchange v0.1",
"description": "Closed evidence envelope. Digest equality, duplicate-key rejection, exact source UTF-8 hashing, and badge derivation require the runtime validator.",
"type": "object",
"required": [
"schema",
"artifact_sha256",
"producer",
"claim",
"mechanics",
"payload",
"evidence",
"source"
],
"additionalProperties": false,
"properties": {
"schema": {"const": "gameplay-evidence/v0.1"},
"artifact_sha256": {"$ref": "#/definitions/sha256"},
"producer": {
"type": "object",
"required": ["repository", "revision", "adapter"],
"additionalProperties": false,
"properties": {
"repository": {
"type": "string",
"pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
},
"revision": {"$ref": "#/definitions/commit"},
"adapter": {"$ref": "#/definitions/nonemptyText"}
}
},
"claim": {
"type": "object",
"required": ["id", "kind", "statement"],
"additionalProperties": false,
"properties": {
"id": {"$ref": "#/definitions/identifier"},
"kind": {
"type": "string",
"enum": ["route", "state_transition", "goal", "counterexample", "observation"]
},
"statement": {"$ref": "#/definitions/nonemptyText"}
}
},
"mechanics": {
"type": "array",
"items": {"$ref": "#/definitions/mechanic"}
},
"payload": {
"type": "object",
"required": [
"domain",
"model",
"model_sha256",
"initial_state",
"initial_state_sha256",
"actions",
"actions_sha256",
"trajectory",
"trajectory_sha256",
"outcome"
],
"additionalProperties": false,
"properties": {
"domain": {"$ref": "#/definitions/identifier"},
"model": {"$ref": "#/definitions/jsonValue"},
"model_sha256": {"$ref": "#/definitions/sha256"},
"initial_state": {"$ref": "#/definitions/jsonValue"},
"initial_state_sha256": {"$ref": "#/definitions/sha256"},
"actions": {
"type": "array",
"items": {"$ref": "#/definitions/jsonValue"}
},
"actions_sha256": {"$ref": "#/definitions/sha256"},
"trajectory": {
"type": "array",
"items": {"$ref": "#/definitions/jsonValue"}
},
"trajectory_sha256": {"$ref": "#/definitions/sha256"},
"outcome": {
"type": "object",
"additionalProperties": {"$ref": "#/definitions/jsonValue"}
}
}
},
"evidence": {
"type": "object",
"required": ["checks", "negative_controls", "limitations"],
"additionalProperties": false,
"properties": {
"checks": {
"type": "array",
"items": {"$ref": "#/definitions/check"}
},
"negative_controls": {
"type": "array",
"items": {"$ref": "#/definitions/negativeControl"}
},
"limitations": {
"type": "array",
"minItems": 1,
"items": {"$ref": "#/definitions/nonemptyText"}
}
}
},
"source": {
"type": "object",
"required": ["media_type", "raw_sha256", "raw"],
"additionalProperties": false,
"properties": {
"media_type": {"$ref": "#/definitions/nonemptyText"},
"raw_sha256": {"$ref": "#/definitions/sha256"},
"raw": {"type": "string"}
}
}
},
"definitions": {
"sha256": {
"type": "string",
"pattern": "^(?!0{64}$)[0-9a-f]{64}$"
},
"commit": {
"type": "string",
"pattern": "^[0-9a-f]{40}$"
},
"identifier": {
"type": "string",
"pattern": "^[A-Za-z0-9_.:-]+$"
},
"nonemptyText": {
"type": "string",
"pattern": "\\S"
},
"jsonValue": {
"anyOf": [
{"type": "null"},
{"type": "boolean"},
{"type": "string"},
{
"type": "integer",
"minimum": -9223372036854775808,
"maximum": 9223372036854775807
},
{
"type": "array",
"items": {"$ref": "#/definitions/jsonValue"}
},
{
"type": "object",
"additionalProperties": {"$ref": "#/definitions/jsonValue"}
}
]
},
"mechanic": {
"type": "object",
"required": ["id", "path", "source_revision", "raw_sha256"],
"additionalProperties": false,
"properties": {
"id": {"$ref": "#/definitions/identifier"},
"path": {
"type": "string",
"pattern": "^(?!/)(?!.*//)(?!.*(?:^|/)\\.\\.?(?:/|$))(?!.*\\\\)[^\\x00]+\\.(?:[yY][aA][mM][lL]|[yY][mM][lL])$"
},
"source_revision": {"$ref": "#/definitions/commit"},
"raw_sha256": {"$ref": "#/definitions/sha256"}
}
},
"check": {
"type": "object",
"required": [
"kind",
"status",
"checker",
"source_labels",
"initial_state_sha256",
"actions_sha256",
"trajectory_sha256"
],
"additionalProperties": false,
"properties": {
"kind": {
"type": "string",
"enum": ["model_replay", "model_proof", "live_execution"]
},
"status": {"type": "string", "enum": ["PASS", "FAIL"]},
"checker": {
"type": "object",
"required": ["name", "revision", "artifact_sha256"],
"additionalProperties": false,
"properties": {
"name": {"$ref": "#/definitions/nonemptyText"},
"revision": {"$ref": "#/definitions/nonemptyText"},
"artifact_sha256": {"$ref": "#/definitions/sha256"}
}
},
"source_labels": {
"type": "array",
"items": {"$ref": "#/definitions/nonemptyText"}
},
"initial_state_sha256": {"$ref": "#/definitions/sha256"},
"actions_sha256": {"$ref": "#/definitions/sha256"},
"trajectory_sha256": {"$ref": "#/definitions/sha256"}
}
},
"negativeControl": {
"type": "object",
"required": ["name", "mutation", "observed", "passed"],
"additionalProperties": false,
"properties": {
"name": {"$ref": "#/definitions/nonemptyText"},
"mutation": {"$ref": "#/definitions/nonemptyText"},
"observed": {"$ref": "#/definitions/nonemptyText"},
"passed": {"type": "boolean"}
}
}
}
}
Loading
Loading