From 1088ede04bb7444032d98b26f895ea0da349bba4 Mon Sep 17 00:00:00 2001 From: claude-bot-go Date: Tue, 28 Jul 2026 12:36:56 +0800 Subject: [PATCH 1/2] Fix #137: Fix WasmAgent/wasmagent-protocol#133 ([milestone Milestone 2] Create canonical-event.schema.json in @wasmagent/protocol --- schemas/index.json | 16 ++++ schemas/v0.1/canonical-event.schema.json | 86 +++++++++++++++++++ .../invalid/canonical-event/example.json | 10 +++ .../valid/canonical-event/example.json | 28 ++++++ 4 files changed, 140 insertions(+) create mode 100644 schemas/v0.1/canonical-event.schema.json create mode 100644 tests/fixtures/invalid/canonical-event/example.json create mode 100644 tests/fixtures/valid/canonical-event/example.json diff --git a/schemas/index.json b/schemas/index.json index 2bc43b1..b30f6a4 100644 --- a/schemas/index.json +++ b/schemas/index.json @@ -184,6 +184,22 @@ "open-agent-audit" ], "summary": "Trust Passport \u2014 signed, expiring, verifiable trust-state artifact for AI agents." + }, + { + "id": "canonical-event", + "title": "CanonicalEvent", + "path": "schemas/v0.1/canonical-event.schema.json", + "canonical_id": "https://wasmagent.dev/schemas/v0.1/canonical-event.schema.json", + "version": "open-agent-audit/v0.1", + "stability": "evolving", + "owners": [ + "wasmagent-protocol" + ], + "consumers": [ + "open-agent-audit", + "wasmagent-js" + ], + "summary": "A single observable event in an AI agent's runtime trace \u2014 canonical audit-event shape emitted by open-agent-audit and mapped onto aep-record." } ] } diff --git a/schemas/v0.1/canonical-event.schema.json b/schemas/v0.1/canonical-event.schema.json new file mode 100644 index 0000000..5e8cd87 --- /dev/null +++ b/schemas/v0.1/canonical-event.schema.json @@ -0,0 +1,86 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://wasmagent.dev/schemas/v0.1/canonical-event.schema.json", + "title": "CanonicalEvent", + "description": "A single observable event in an AI agent's runtime trace — the canonical audit-event shape emitted by open-agent-audit and other producers. Cross-repository contract: downstream repos consume this via @wasmagent/protocol and map it onto aep-record (see open-agent-audit adapter). The schema_version field identifies the event format and is independent of aep-record's schema_version.", + "type": "object", + "required": ["schema_version", "run_id", "event_id", "timestamp", "type", "actor", "agent_id", "model_id"], + "additionalProperties": false, + "properties": { + "schema_version": { "const": "open-agent-audit/v0.1" }, + "run_id": { "type": "string", "minLength": 1 }, + "session_id": { "type": "string" }, + "agent_id": { "type": "string", "minLength": 1 }, + "model_id": { "type": "string", "minLength": 1 }, + "event_id": { "type": "string", "minLength": 1 }, + "timestamp": { "type": "string", "format": "date-time", "description": "RFC 3339 timestamp with timezone offset" }, + "type": { + "type": "string", + "enum": ["tool_call", "policy_decision", "human_approval", "observation", "model_output", "final_answer", "error"] + }, + "actor": { "type": "string", "enum": ["agent", "user", "system", "tool", "human_reviewer"] }, + "tool": { + "type": "object", "additionalProperties": false, "required": ["name"], + "properties": { + "name": { "type": "string", "minLength": 1 }, + "capability": { "type": "string" }, + "args_hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "result_hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "risk_tags": { "type": "array", "items": { "type": "string" }, "uniqueItems": true } + } + }, + "policy": { + "type": "object", "additionalProperties": false, "required": ["decision", "reason"], + "properties": { + "decision": { "type": "string", "enum": ["allow", "deny", "ask_user"] }, + "reason": { "type": "string" }, + "rule_id": { "type": "string" } + } + }, + "human": { + "type": "object", "additionalProperties": false, "required": ["reviewer_id", "decision"], + "properties": { + "reviewer_id": { "type": "string" }, + "decision": { "type": "string", "enum": ["approve", "deny", "escalate"] }, + "justification": { "type": "string" } + } + }, + "error": { + "type": "object", "additionalProperties": false, "required": ["kind", "message"], + "properties": { "kind": { "type": "string" }, "message": { "type": "string" } } + }, + "model_output": { + "type": "object", "additionalProperties": false, + "properties": { + "content_hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "token_count": { "type": "integer", "minimum": 0 }, + "finish_reason": { "type": "string" } + } + }, + "observation": { + "type": "object", "additionalProperties": false, + "properties": { + "source": { "type": "string" }, + "content_hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "byte_size": { "type": "integer", "minimum": 0 } + } + }, + "evidence": { + "type": "object", "additionalProperties": false, + "properties": { + "evidence_id": { "type": "string" }, + "hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "prev_hash": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" }, + "signature": { "type": "string" }, + "signature_algorithm": { "type": "string", "enum": ["ed25519", "ecdsa-p256"] }, + "signer_key_id": { "type": "string" } + } + } + }, + "allOf": [ + { "if": { "properties": { "type": { "const": "tool_call" } }, "required": ["type"] }, "then": { "required": ["tool"] } }, + { "if": { "properties": { "type": { "const": "policy_decision" } }, "required": ["type"] }, "then": { "required": ["policy"] } }, + { "if": { "properties": { "type": { "const": "human_approval" } }, "required": ["type"] }, "then": { "required": ["human"] } }, + { "if": { "properties": { "type": { "const": "error" } }, "required": ["type"] }, "then": { "required": ["error"] } } + ] +} diff --git a/tests/fixtures/invalid/canonical-event/example.json b/tests/fixtures/invalid/canonical-event/example.json new file mode 100644 index 0000000..ef29a3a --- /dev/null +++ b/tests/fixtures/invalid/canonical-event/example.json @@ -0,0 +1,10 @@ +{ + "schema_version": "open-agent-audit/v0.1", + "run_id": "run-abc123", + "agent_id": "agent-researcher-1", + "model_id": "claude-opus-4-8", + "event_id": "evt-0002", + "timestamp": "2026-07-28T14:03:23Z", + "type": "tool_call", + "actor": "agent" +} diff --git a/tests/fixtures/valid/canonical-event/example.json b/tests/fixtures/valid/canonical-event/example.json new file mode 100644 index 0000000..39e7cc7 --- /dev/null +++ b/tests/fixtures/valid/canonical-event/example.json @@ -0,0 +1,28 @@ +{ + "schema_version": "open-agent-audit/v0.1", + "run_id": "run-abc123", + "session_id": "session-001", + "agent_id": "agent-researcher-1", + "model_id": "claude-opus-4-8", + "event_id": "evt-0001", + "timestamp": "2026-07-28T14:03:22Z", + "type": "tool_call", + "actor": "agent", + "tool": { + "name": "write_file", + "capability": "filesystem.write", + "args_hash": "9e6ce95e6a1e4d0f4b8b0e8b0a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d", + "result_hash": "f0e1d2c3b4a5968778695a4b3c2d1e0f1234567890abcdef1234567890abcdef", + "risk_tags": [ + "shell", + "filesystem" + ] + }, + "evidence": { + "evidence_id": "ev-0001", + "hash": "1f2e3d4c5b6a79887766554433221100ffeeddccbbaa99887766554433221100", + "signature": "base64sig==", + "signature_algorithm": "ed25519", + "signer_key_id": "k1" + } +} From a1c589fc46e5ddfebe65b02e0fbdde37920b01a9 Mon Sep 17 00:00:00 2001 From: claude-bot-go Date: Tue, 28 Jul 2026 17:35:44 +0800 Subject: [PATCH 2/2] Fix #137: add missing allOf conditional requirements for observation, model_output, and final_answer in canonical-event schema The allOf section previously only covered tool_call, policy_decision, human_approval, and error types. Added conditional requirements for observation (requires 'observation' property) and model_output (requires 'model_output' property). Added explicit final_answer entry (no extra properties required). This ensures all event types in the enum have corresponding conditional constraints. Co-Authored-By: Claude --- schemas/v0.1/canonical-event.schema.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schemas/v0.1/canonical-event.schema.json b/schemas/v0.1/canonical-event.schema.json index 5e8cd87..e693d6a 100644 --- a/schemas/v0.1/canonical-event.schema.json +++ b/schemas/v0.1/canonical-event.schema.json @@ -81,6 +81,9 @@ { "if": { "properties": { "type": { "const": "tool_call" } }, "required": ["type"] }, "then": { "required": ["tool"] } }, { "if": { "properties": { "type": { "const": "policy_decision" } }, "required": ["type"] }, "then": { "required": ["policy"] } }, { "if": { "properties": { "type": { "const": "human_approval" } }, "required": ["type"] }, "then": { "required": ["human"] } }, + { "if": { "properties": { "type": { "const": "observation" } }, "required": ["type"] }, "then": { "required": ["observation"] } }, + { "if": { "properties": { "type": { "const": "model_output" } }, "required": ["type"] }, "then": { "required": ["model_output"] } }, + { "if": { "properties": { "type": { "const": "final_answer" } }, "required": ["type"] }, "then": { "required": [] } }, { "if": { "properties": { "type": { "const": "error" } }, "required": ["type"] }, "then": { "required": ["error"] } } ] }