diff --git a/schemas/aep/_base.schema.json b/schemas/aep/_base.schema.json new file mode 100644 index 0000000..dd6c0e6 --- /dev/null +++ b/schemas/aep/_base.schema.json @@ -0,0 +1,56 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "urn:wasmagent:aep:base", + "title": "AEPEnvelopeBase", + "description": "Shared base properties for all AEP evidence envelope schemas. Not registered in the schema index — intended to be composed via $ref / allOf.", + "type": "object", + "required": [ + "schema_version", + "created_at_ms" + ], + "properties": { + "schema_version": { + "type": "string", + "description": "Semver-like schema identifier, e.g. aep/v0.1" + }, + "trace_id": { + "type": "string", + "description": "Optional correlation ID linking related evidence records" + }, + "created_at_ms": { + "type": "number", + "description": "UTC epoch milliseconds when the record was created (envelope timestamp)" + }, + "metadata": { + "type": "object", + "description": "Optional key-value metadata about the evidence record", + "additionalProperties": { + "type": ["string", "number", "boolean", "null", "array", "object"] + } + }, + "signature": { + "type": "object", + "description": "Optional tamper-evident signature over the record content", + "required": [ + "alg", + "key_id", + "sig" + ], + "properties": { + "alg": { + "type": "string", + "description": "Signature algorithm, e.g. ed25519" + }, + "key_id": { + "type": "string", + "description": "Identifier of the signing key" + }, + "sig": { + "type": "string", + "description": "Base64-encoded signature bytes" + } + }, + "additionalProperties": false + } + } +} diff --git a/schemas/aep/evidence-envelope.schema.json b/schemas/aep/evidence-envelope.schema.json index 227648e..e6e3440 100644 --- a/schemas/aep/evidence-envelope.schema.json +++ b/schemas/aep/evidence-envelope.schema.json @@ -2,48 +2,33 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wasmagent.dev/schemas/aep/evidence-envelope.schema.json", "title": "EvidenceEnvelope", - "description": "Shared base fields for all AEP evidence records \u2014 schema_version, trace_id, created_at_ms, and optional signature. Every evidence type $refs this schema for its envelope fields.", - "type": "object", - "required": [ - "schema_version", - "created_at_ms" - ], - "properties": { - "schema_version": { - "type": "string", - "description": "Semver-like schema identifier, e.g. aep/v0.1" + "description": "Shared envelope base for all AEP evidence records. Every evidence type wraps its payload in this envelope, which carries schema_version, trace_id, created_at_ms, evidence_type, payload, metadata, and an optional signature.", + "allOf": [ + { + "$ref": "_base.schema.json" }, - "trace_id": { - "type": "string", - "description": "Optional correlation ID linking related evidence records" - }, - "created_at_ms": { - "type": "number", - "description": "UTC epoch milliseconds when the record was created" - }, - "signature": { + { "type": "object", - "description": "Optional tamper-evident signature over the record content", "required": [ - "alg", - "key_id", - "sig" + "evidence_type", + "payload" ], "properties": { - "alg": { + "evidence_type": { "type": "string", - "description": "Signature algorithm, e.g. ed25519" + "description": "Discriminator for the kind of evidence enclosed, e.g. 'execution', 'artifact', 'checkpoint', 'replay', 'memory'" }, - "key_id": { - "type": "string", - "description": "Identifier of the signing key" - }, - "sig": { - "type": "string", - "description": "Base64-encoded signature bytes" + "payload": { + "description": "The evidence content — structure depends on evidence_type", + "type": "object", + "properties": { + "contents": { + "description": "The primary evidence payload (opaque per evidence_type)" + } + }, + "additionalProperties": true } - }, - "additionalProperties": false + } } - } + ] } diff --git a/tests/fixtures/valid/evidence-envelope/example.json b/tests/fixtures/valid/evidence-envelope/example.json index e8a3ef0..34a896a 100644 --- a/tests/fixtures/valid/evidence-envelope/example.json +++ b/tests/fixtures/valid/evidence-envelope/example.json @@ -2,6 +2,14 @@ "schema_version": "aep/v0.1", "trace_id": "trace-abc123", "created_at_ms": 1737600000000, + "evidence_type": "artifact", + "payload": { + "contents": "artifact-evidence-data" + }, + "metadata": { + "source": "wasmagent-js", + "correlation_tag": "run-42" + }, "signature": { "alg": "ed25519", "key_id": "key-001",