Skip to content

Commit 61f0a39

Browse files
grokifyclaude
andcommitted
feat(schema): add JSON schema with embedding
Add PIDL JSON Schema for validation: - pidl.schema.json: Full JSON Schema (draft 2020-12) - embed.go: Embedded schema for programmatic access Schema defines protocol metadata, entities, phases, flows, entity types, and flow modes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6555cbb commit 61f0a39

2 files changed

Lines changed: 219 additions & 0 deletions

File tree

schema/embed.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Package schema provides the embedded PIDL JSON Schema.
2+
package schema
3+
4+
import (
5+
_ "embed"
6+
)
7+
8+
// SchemaJSON is the embedded PIDL JSON Schema.
9+
//
10+
//go:embed pidl.schema.json
11+
var SchemaJSON []byte
12+
13+
// SchemaVersion is the version of the embedded schema.
14+
const SchemaVersion = "1.0"

schema/pidl.schema.json

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://github.com/grokify/pidl/schema/pidl.schema.json",
4+
"title": "PIDL Protocol",
5+
"description": "Protocol Interaction Description Language - describes protocol choreography for diagram generation",
6+
"type": "object",
7+
"required": ["protocol", "entities", "flows"],
8+
"properties": {
9+
"protocol": {
10+
"$ref": "#/$defs/protocolMetadata"
11+
},
12+
"entities": {
13+
"type": "array",
14+
"description": "Participants in the protocol (systems, actors, services)",
15+
"items": {
16+
"$ref": "#/$defs/entity"
17+
},
18+
"minItems": 2
19+
},
20+
"phases": {
21+
"type": "array",
22+
"description": "Optional grouping of flows into logical phases",
23+
"items": {
24+
"$ref": "#/$defs/phase"
25+
}
26+
},
27+
"flows": {
28+
"type": "array",
29+
"description": "Interactions between entities",
30+
"items": {
31+
"$ref": "#/$defs/flow"
32+
},
33+
"minItems": 1
34+
}
35+
},
36+
"$defs": {
37+
"protocolMetadata": {
38+
"type": "object",
39+
"description": "Metadata about the protocol being described",
40+
"required": ["id", "name"],
41+
"properties": {
42+
"id": {
43+
"type": "string",
44+
"description": "Unique identifier for the protocol",
45+
"pattern": "^[a-z][a-z0-9_-]*$"
46+
},
47+
"name": {
48+
"type": "string",
49+
"description": "Human-readable name of the protocol"
50+
},
51+
"version": {
52+
"type": "string",
53+
"description": "Version of the protocol specification"
54+
},
55+
"description": {
56+
"type": "string",
57+
"description": "Brief description of the protocol"
58+
},
59+
"category": {
60+
"type": "string",
61+
"description": "Protocol category",
62+
"enum": ["auth", "agent", "messaging", "provisioning", "other"]
63+
},
64+
"references": {
65+
"type": "array",
66+
"description": "Links to relevant specifications or documentation",
67+
"items": {
68+
"$ref": "#/$defs/reference"
69+
}
70+
}
71+
}
72+
},
73+
"reference": {
74+
"type": "object",
75+
"required": ["name", "url"],
76+
"properties": {
77+
"name": {
78+
"type": "string",
79+
"description": "Name of the reference (e.g., RFC 6749)"
80+
},
81+
"url": {
82+
"type": "string",
83+
"format": "uri",
84+
"description": "URL to the reference"
85+
}
86+
}
87+
},
88+
"entity": {
89+
"type": "object",
90+
"description": "A participant in the protocol (system, actor, or service)",
91+
"required": ["id", "name", "type"],
92+
"properties": {
93+
"id": {
94+
"type": "string",
95+
"description": "Unique identifier for the entity, used in flow references",
96+
"pattern": "^[a-z][a-z0-9_]*$"
97+
},
98+
"name": {
99+
"type": "string",
100+
"description": "Human-readable display name"
101+
},
102+
"type": {
103+
"$ref": "#/$defs/entityType"
104+
},
105+
"description": {
106+
"type": "string",
107+
"description": "Optional description of the entity's role"
108+
}
109+
}
110+
},
111+
"entityType": {
112+
"type": "string",
113+
"description": "Type classification of the entity",
114+
"enum": [
115+
"client",
116+
"authorization_server",
117+
"resource_server",
118+
"user",
119+
"browser",
120+
"agent",
121+
"tool_server",
122+
"tool",
123+
"delegated_agent",
124+
"identity_provider",
125+
"service_provider",
126+
"server",
127+
"other"
128+
]
129+
},
130+
"phase": {
131+
"type": "object",
132+
"description": "A logical grouping of flows",
133+
"required": ["id", "name"],
134+
"properties": {
135+
"id": {
136+
"type": "string",
137+
"description": "Unique identifier for the phase",
138+
"pattern": "^[a-z][a-z0-9_]*$"
139+
},
140+
"name": {
141+
"type": "string",
142+
"description": "Human-readable name for the phase"
143+
},
144+
"description": {
145+
"type": "string",
146+
"description": "Optional description of the phase"
147+
}
148+
}
149+
},
150+
"flow": {
151+
"type": "object",
152+
"description": "An interaction between two entities",
153+
"required": ["from", "to", "action"],
154+
"properties": {
155+
"from": {
156+
"type": "string",
157+
"description": "Entity ID of the sender/initiator"
158+
},
159+
"to": {
160+
"type": "string",
161+
"description": "Entity ID of the receiver/target"
162+
},
163+
"action": {
164+
"type": "string",
165+
"description": "Identifier for the action being performed"
166+
},
167+
"label": {
168+
"type": "string",
169+
"description": "Human-readable label for diagram display (defaults to action)"
170+
},
171+
"mode": {
172+
"$ref": "#/$defs/flowMode"
173+
},
174+
"phase": {
175+
"type": "string",
176+
"description": "Phase ID this flow belongs to"
177+
},
178+
"description": {
179+
"type": "string",
180+
"description": "Optional detailed description of the flow"
181+
},
182+
"sequence": {
183+
"type": "integer",
184+
"description": "Optional explicit ordering (flows are ordered by array position by default)",
185+
"minimum": 1
186+
}
187+
}
188+
},
189+
"flowMode": {
190+
"type": "string",
191+
"description": "The type/mode of the interaction",
192+
"enum": [
193+
"request",
194+
"response",
195+
"redirect",
196+
"callback",
197+
"interactive",
198+
"event",
199+
"tool_call",
200+
"tool_result"
201+
],
202+
"default": "request"
203+
}
204+
}
205+
}

0 commit comments

Comments
 (0)