@agent-teams/docs-protocol 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +68 -10
  3. package/dist/adapters/adoption-input.d.ts +0 -3
  4. package/dist/adapters/adoption-input.d.ts.map +1 -1
  5. package/dist/adapters/adoption-input.js +12 -5
  6. package/dist/adapters/adoption-input.js.map +1 -1
  7. package/dist/adapters/adoption-package-identity.d.ts.map +1 -1
  8. package/dist/adapters/adoption-package-identity.js +4 -3
  9. package/dist/adapters/adoption-package-identity.js.map +1 -1
  10. package/dist/adapters/docs-command-envelope-schema-validator.js +3 -3
  11. package/dist/adapters/docs-command-envelope-schema-validator.js.map +1 -1
  12. package/dist/adapters/docs-profile-schema-validator.d.ts.map +1 -1
  13. package/dist/adapters/docs-profile-schema-validator.js +4 -1
  14. package/dist/adapters/docs-profile-schema-validator.js.map +1 -1
  15. package/dist/adapters/foundation-docs-port.d.ts +8 -1
  16. package/dist/adapters/foundation-docs-port.d.ts.map +1 -1
  17. package/dist/adapters/foundation-docs-port.js +9 -1
  18. package/dist/adapters/foundation-docs-port.js.map +1 -1
  19. package/dist/adapters/node-adoption-inspector.d.ts +1 -1
  20. package/dist/adapters/node-adoption-inspector.d.ts.map +1 -1
  21. package/dist/adapters/node-adoption-inspector.js +63 -25
  22. package/dist/adapters/node-adoption-inspector.js.map +1 -1
  23. package/dist/adapters/node-profile-discovery.d.ts +7 -0
  24. package/dist/adapters/node-profile-discovery.d.ts.map +1 -0
  25. package/dist/adapters/node-profile-discovery.js +38 -0
  26. package/dist/adapters/node-profile-discovery.js.map +1 -0
  27. package/dist/adapters/node-profile-reader.d.ts +1 -1
  28. package/dist/adapters/node-profile-reader.d.ts.map +1 -1
  29. package/dist/adapters/node-profile-reader.js +9 -8
  30. package/dist/adapters/node-profile-reader.js.map +1 -1
  31. package/dist/application/docs-execution.d.ts +7 -0
  32. package/dist/application/docs-execution.d.ts.map +1 -0
  33. package/dist/application/docs-execution.js +49 -0
  34. package/dist/application/docs-execution.js.map +1 -0
  35. package/dist/application/docs-protocol.d.ts +10 -2
  36. package/dist/application/docs-protocol.d.ts.map +1 -1
  37. package/dist/application/docs-protocol.js +32 -45
  38. package/dist/application/docs-protocol.js.map +1 -1
  39. package/dist/community/bootstrap/index.d.ts +3 -0
  40. package/dist/community/bootstrap/index.d.ts.map +1 -0
  41. package/dist/community/bootstrap/index.js +2 -0
  42. package/dist/community/bootstrap/index.js.map +1 -0
  43. package/dist/community/bootstrap/portable-bootstrap-assets.d.ts +10 -0
  44. package/dist/community/bootstrap/portable-bootstrap-assets.d.ts.map +1 -0
  45. package/dist/community/bootstrap/portable-bootstrap-assets.js +183 -0
  46. package/dist/community/bootstrap/portable-bootstrap-assets.js.map +1 -0
  47. package/dist/community/bootstrap/portable-bootstrap.d.ts +48 -0
  48. package/dist/community/bootstrap/portable-bootstrap.d.ts.map +1 -0
  49. package/dist/community/bootstrap/portable-bootstrap.js +387 -0
  50. package/dist/community/bootstrap/portable-bootstrap.js.map +1 -0
  51. package/dist/community/context/community-query.d.ts +52 -0
  52. package/dist/community/context/community-query.d.ts.map +1 -0
  53. package/dist/community/context/community-query.js +306 -0
  54. package/dist/community/context/community-query.js.map +1 -0
  55. package/dist/community/context/index.d.ts +7 -0
  56. package/dist/community/context/index.d.ts.map +1 -0
  57. package/dist/community/context/index.js +5 -0
  58. package/dist/community/context/index.js.map +1 -0
  59. package/dist/community/context/llms-text.d.ts +37 -0
  60. package/dist/community/context/llms-text.d.ts.map +1 -0
  61. package/dist/community/context/llms-text.js +130 -0
  62. package/dist/community/context/llms-text.js.map +1 -0
  63. package/dist/community/context/minisearch-adapter.d.ts +8 -0
  64. package/dist/community/context/minisearch-adapter.d.ts.map +1 -0
  65. package/dist/community/context/minisearch-adapter.js +59 -0
  66. package/dist/community/context/minisearch-adapter.js.map +1 -0
  67. package/dist/community/context/ranked-search.d.ts +38 -0
  68. package/dist/community/context/ranked-search.d.ts.map +1 -0
  69. package/dist/community/context/ranked-search.js +118 -0
  70. package/dist/community/context/ranked-search.js.map +1 -0
  71. package/dist/composition/cli.d.ts +2 -4
  72. package/dist/composition/cli.d.ts.map +1 -1
  73. package/dist/composition/cli.js +236 -115
  74. package/dist/composition/cli.js.map +1 -1
  75. package/dist/composition/docs-cli-machine.d.ts +9 -0
  76. package/dist/composition/docs-cli-machine.d.ts.map +1 -0
  77. package/dist/composition/docs-cli-machine.js +130 -0
  78. package/dist/composition/docs-cli-machine.js.map +1 -0
  79. package/dist/composition/docs-human-renderer.d.ts +2 -0
  80. package/dist/composition/docs-human-renderer.d.ts.map +1 -1
  81. package/dist/composition/docs-human-renderer.js +18 -1
  82. package/dist/composition/docs-human-renderer.js.map +1 -1
  83. package/dist/composition/node-docs-api.d.ts +12 -0
  84. package/dist/composition/node-docs-api.d.ts.map +1 -1
  85. package/dist/composition/node-docs-api.js +14 -0
  86. package/dist/composition/node-docs-api.js.map +1 -1
  87. package/dist/composition/node-docs-bootstrap-api.d.ts +75 -0
  88. package/dist/composition/node-docs-bootstrap-api.d.ts.map +1 -0
  89. package/dist/composition/node-docs-bootstrap-api.js +97 -0
  90. package/dist/composition/node-docs-bootstrap-api.js.map +1 -0
  91. package/dist/domain/model-v2.d.ts +25 -1
  92. package/dist/domain/model-v2.d.ts.map +1 -1
  93. package/dist/domain/model-v3.d.ts +72 -0
  94. package/dist/domain/model-v3.d.ts.map +1 -0
  95. package/dist/domain/model-v3.js +2 -0
  96. package/dist/domain/model-v3.js.map +1 -0
  97. package/dist/domain/model.d.ts +5 -0
  98. package/dist/domain/model.d.ts.map +1 -1
  99. package/dist/domain/model.js +3 -0
  100. package/dist/domain/model.js.map +1 -1
  101. package/dist/domain/profile-policy.d.ts +4 -3
  102. package/dist/domain/profile-policy.d.ts.map +1 -1
  103. package/dist/domain/profile-policy.js +43 -13
  104. package/dist/domain/profile-policy.js.map +1 -1
  105. package/dist/index.d.ts +9 -3
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +5 -2
  108. package/dist/index.js.map +1 -1
  109. package/package.json +7 -3
  110. package/schemas/docs-protocol-command-envelope/v3.schema.json +529 -0
  111. package/schemas/docs-protocol-profile/v3.schema.json +49 -0
@@ -0,0 +1,529 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://agent-teams.ai/schemas/docs-protocol-command-envelope/v3",
4
+ "title": "Agent Teams Docs Protocol Command Envelope",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "protocol", "command", "outcome", "diagnostics", "result"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 3 },
10
+ "protocol": { "$ref": "#/$defs/protocol" },
11
+ "command": { "enum": ["docs.info", "docs.find", "docs.context", "docs.init", "docs.new", "docs.doctor", "docs.recover", "docs.check", "docs.qualify"] },
12
+ "outcome": { "enum": ["success", "conflict", "violation", "authority-stale", "recovery-required", "invalid-input", "execution-failure", "cancelled"] },
13
+ "diagnostics": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/diagnostic" } },
14
+ "result": {
15
+ "oneOf": [
16
+ { "$ref": "#/$defs/emptyResult" },
17
+ { "$ref": "#/$defs/infoResult" },
18
+ { "$ref": "#/$defs/findResult" },
19
+ { "$ref": "#/$defs/contextResult" },
20
+ { "$ref": "#/$defs/initResult" },
21
+ { "$ref": "#/$defs/newResult" },
22
+ { "$ref": "#/$defs/doctorResult" },
23
+ { "$ref": "#/$defs/recoverResult" },
24
+ { "$ref": "#/$defs/checkResult" },
25
+ { "$ref": "https://agent-teams.ai/schemas/docs-protocol-qualification-receipt/v2" }
26
+ ]
27
+ }
28
+ },
29
+ "allOf": [
30
+ { "$ref": "#/$defs/infoEnvelope" },
31
+ { "$ref": "#/$defs/findEnvelope" },
32
+ { "$ref": "#/$defs/contextEnvelope" },
33
+ { "$ref": "#/$defs/initEnvelope" },
34
+ { "$ref": "#/$defs/newEnvelope" },
35
+ { "$ref": "#/$defs/doctorEnvelope" },
36
+ { "$ref": "#/$defs/recoverEnvelope" },
37
+ { "$ref": "#/$defs/checkEnvelope" },
38
+ { "$ref": "#/$defs/qualificationEnvelope" }
39
+ ],
40
+ "$defs": {
41
+ "protocol": {
42
+ "type": "object", "additionalProperties": false, "required": ["id", "version"],
43
+ "properties": { "id": { "const": "agent-teams.docs-protocol" }, "version": { "const": 1 } }
44
+ },
45
+ "lowerId": { "type": "string", "minLength": 1, "maxLength": 160, "pattern": "^[a-z0-9][a-z0-9._/-]*$" },
46
+ "opaqueId": { "type": "string", "minLength": 1, "maxLength": 214, "pattern": "^[A-Za-z0-9@][A-Za-z0-9@._/-]*$" },
47
+ "repositoryPath": { "type": "string", "minLength": 1, "maxLength": 512, "pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))[A-Za-z0-9._@-]{1,255}(?:/[A-Za-z0-9._@-]{1,255})*$" },
48
+ "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
49
+ "emptyResult": { "type": "object", "additionalProperties": false, "maxProperties": 0 },
50
+ "diagnostic": {
51
+ "type": "object", "additionalProperties": false,
52
+ "required": ["ruleId", "severity", "phase", "subject", "message"],
53
+ "properties": {
54
+ "ruleId": { "$ref": "#/$defs/opaqueId" },
55
+ "severity": { "enum": ["error", "info", "warning"] },
56
+ "phase": { "enum": ["apply", "authority", "input", "planning", "query", "recovery"] },
57
+ "subject": { "type": "string", "minLength": 1, "maxLength": 512 },
58
+ "message": { "type": "string", "minLength": 1, "maxLength": 1000 }
59
+ }
60
+ },
61
+ "jsonValue": {
62
+ "oneOf": [
63
+ { "type": "boolean" },
64
+ { "type": "null" },
65
+ { "type": "number" },
66
+ { "type": "string" },
67
+ { "type": "array", "maxItems": 10000, "items": { "$ref": "#/$defs/jsonValue" } },
68
+ { "type": "object", "maxProperties": 10000, "additionalProperties": { "$ref": "#/$defs/jsonValue" } }
69
+ ]
70
+ },
71
+ "foundationProfile": {
72
+ "oneOf": [
73
+ { "type": "object", "additionalProperties": false, "required": ["path", "schemaVersion", "metadataSidecarPolicy"], "properties": { "path": { "$ref": "#/$defs/repositoryPath" }, "schemaVersion": { "const": 2 }, "metadataSidecarPolicy": { "const": "foundation-profile-v2-strict-merge" } } },
74
+ { "type": "object", "additionalProperties": false, "required": ["path", "schemaVersion", "metadataSidecarPolicy"], "properties": { "path": { "$ref": "#/$defs/repositoryPath" }, "schemaVersion": { "const": 3 }, "metadataSidecarPolicy": { "const": "foundation-profile-v3-strict-merge" } } }
75
+ ]
76
+ },
77
+ "metadataSidecar": {
78
+ "oneOf": [
79
+ { "type": "object", "additionalProperties": false, "required": ["kind"], "properties": { "kind": { "const": "none" } } },
80
+ { "type": "object", "additionalProperties": false, "required": ["kind", "path"], "properties": { "kind": { "const": "path-metadata-map" }, "path": { "$ref": "#/$defs/repositoryPath" } } }
81
+ ]
82
+ },
83
+ "authorityEvidence": { "type": "object", "additionalProperties": false, "required": ["path", "digest", "size"], "properties": { "path": { "$ref": "#/$defs/repositoryPath" }, "digest": { "$ref": "#/$defs/digest" }, "size": { "type": "integer", "minimum": 0, "maximum": 10485760 } } },
84
+ "identity": {
85
+ "type": "object", "additionalProperties": false, "required": ["kind", "format"],
86
+ "properties": {
87
+ "kind": { "const": "explicit" },
88
+ "format": { "enum": ["adr-four-digits", "open-decision-three-digits", "qualified"] },
89
+ "grammar": {
90
+ "type": "object", "additionalProperties": false,
91
+ "required": ["prefixSegments", "minSuffixSegments", "maxSuffixSegments"],
92
+ "properties": {
93
+ "prefixSegments": { "type": "array", "minItems": 1, "maxItems": 8, "items": { "$ref": "#/$defs/lowerId" } },
94
+ "minSuffixSegments": { "type": "integer", "minimum": 1, "maximum": 16 },
95
+ "maxSuffixSegments": { "type": "integer", "minimum": 1, "maximum": 16 }
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "placement": {
101
+ "oneOf": [
102
+ {
103
+ "type": "object", "additionalProperties": false, "required": ["kind", "directory", "filename"],
104
+ "properties": { "kind": { "const": "collection" }, "directory": { "$ref": "#/$defs/repositoryPath" }, "filename": { "enum": ["numeric-id-slug", "id-slug", "slug", "README.md"] } }
105
+ },
106
+ {
107
+ "type": "object", "additionalProperties": false, "required": ["kind", "root", "requiredBasename"],
108
+ "properties": { "kind": { "const": "qualified-leaf-index" }, "root": { "$ref": "#/$defs/repositoryPath" }, "requiredBasename": { "const": "README.md" } }
109
+ },
110
+ {
111
+ "type": "object", "additionalProperties": false,
112
+ "required": ["kind", "allowedRoots", "requiredSegmentsInOrder", "requiredBasename", "minimumSegmentsBeforeRequired", "minimumSegmentsAfterRequired"],
113
+ "properties": {
114
+ "kind": { "const": "explicit" },
115
+ "allowedRoots": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/repositoryPath" } },
116
+ "requiredSegmentsInOrder": { "type": "array", "minItems": 1, "maxItems": 16, "items": { "type": "string", "pattern": "^[A-Za-z0-9._@-]+$", "maxLength": 255 } },
117
+ "requiredBasename": { "const": "README.md" },
118
+ "minimumSegmentsBeforeRequired": { "type": "integer", "minimum": 0, "maximum": 16 },
119
+ "minimumSegmentsAfterRequired": { "type": "integer", "minimum": 0, "maximum": 16 }
120
+ }
121
+ }
122
+ ]
123
+ },
124
+ "reachability": {
125
+ "oneOf": [
126
+ { "type": "object", "additionalProperties": false, "required": ["kind", "indexPath"], "properties": { "kind": { "const": "manual-fixed-index" }, "indexPath": { "$ref": "#/$defs/repositoryPath" } } },
127
+ { "type": "object", "additionalProperties": false, "required": ["kind", "pathPrefix", "indexBasename"], "properties": { "kind": { "const": "manual-colocated-index" }, "pathPrefix": { "const": "before-required-segments" }, "indexBasename": { "const": "README.md" } } },
128
+ { "type": "object", "additionalProperties": false, "required": ["kind", "reason"], "properties": { "kind": { "const": "not-required" }, "reason": { "type": "string", "minLength": 1, "maxLength": 500 } } }
129
+ ]
130
+ },
131
+ "typeInfo": {
132
+ "type": "object", "additionalProperties": false,
133
+ "required": ["type", "initialStatus", "allowedOwnerIds", "identity", "heading", "placement", "template", "requiredMetadata", "reachability"],
134
+ "properties": {
135
+ "type": { "$ref": "#/$defs/lowerId" },
136
+ "initialStatus": { "$ref": "#/$defs/lowerId" },
137
+ "allowedOwnerIds": { "type": "array", "minItems": 1, "maxItems": 4096, "items": { "$ref": "#/$defs/opaqueId" } },
138
+ "identity": { "$ref": "#/$defs/identity" },
139
+ "heading": { "type": "object", "additionalProperties": false, "required": ["kind"], "properties": { "kind": { "enum": ["id-colon-title", "title"] } } },
140
+ "placement": { "$ref": "#/$defs/placement" },
141
+ "template": { "type": "object", "additionalProperties": false, "required": ["kind", "path"], "properties": { "kind": { "const": "fenced-markdown-body" }, "path": { "$ref": "#/$defs/repositoryPath" } } },
142
+ "requiredMetadata": { "type": "array", "minItems": 5, "maxItems": 128, "items": { "type": "string", "maxLength": 128 } },
143
+ "reachability": { "$ref": "#/$defs/reachability" }
144
+ }
145
+ },
146
+ "infoResult": {
147
+ "type": "object", "additionalProperties": false,
148
+ "required": ["kind", "projectId", "protocol", "foundationProfile", "agentWorkflow", "authority", "authorityPaths", "catalog", "semanticDigest", "metadataSchemaPath", "metadataSidecar", "ownerIds", "types", "semanticValidatorIds"],
149
+ "properties": {
150
+ "kind": { "const": "info" }, "projectId": { "$ref": "#/$defs/lowerId" }, "protocol": { "$ref": "#/$defs/protocol" },
151
+ "foundationProfile": { "$ref": "#/$defs/foundationProfile" },
152
+ "agentWorkflow": { "type": "object", "additionalProperties": false, "required": ["skillPath"], "properties": { "skillPath": { "$ref": "#/$defs/repositoryPath" } } },
153
+ "authority": {
154
+ "type": "object",
155
+ "additionalProperties": false,
156
+ "required": ["metadataSchema", "ownerCatalog", "profile", "templates"],
157
+ "properties": {
158
+ "metadataSchema": { "$ref": "#/$defs/authorityEvidence" },
159
+ "metadataSidecar": { "$ref": "#/$defs/authorityEvidence" },
160
+ "ownerCatalog": { "$ref": "#/$defs/authorityEvidence" },
161
+ "profile": { "$ref": "#/$defs/authorityEvidence" },
162
+ "templates": {
163
+ "type": "array",
164
+ "maxItems": 32,
165
+ "items": {
166
+ "type": "object",
167
+ "additionalProperties": false,
168
+ "required": ["evidence", "type"],
169
+ "properties": {
170
+ "evidence": { "$ref": "#/$defs/authorityEvidence" },
171
+ "type": { "$ref": "#/$defs/lowerId" }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ },
177
+ "authorityPaths": { "type": "array", "minItems": 3, "maxItems": 96, "uniqueItems": true, "items": { "$ref": "#/$defs/repositoryPath" } },
178
+ "catalog": { "type": "object", "additionalProperties": false, "required": ["collections", "excludedPrefixes"], "properties": { "collections": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/catalogCollection" } }, "excludedPrefixes": { "type": "array", "maxItems": 128, "items": { "$ref": "#/$defs/repositoryPath" } } } },
179
+ "semanticDigest": { "$ref": "#/$defs/digest" },
180
+ "metadataSchemaPath": { "$ref": "#/$defs/repositoryPath" }, "metadataSidecar": { "$ref": "#/$defs/metadataSidecar" },
181
+ "ownerIds": { "type": "array", "maxItems": 4096, "items": { "$ref": "#/$defs/opaqueId" } },
182
+ "types": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/typeInfo" } },
183
+ "semanticValidatorIds": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/lowerId" } }
184
+ }
185
+ },
186
+ "catalogCollection": {
187
+ "oneOf": [
188
+ { "type": "object", "additionalProperties": false, "required": ["kind", "root"], "properties": { "kind": { "const": "markdown-tree" }, "root": { "$ref": "#/$defs/repositoryPath" } } },
189
+ { "type": "object", "additionalProperties": false, "required": ["kind", "roots"], "properties": { "kind": { "const": "frontmatter-readme" }, "roots": { "type": "array", "minItems": 1, "maxItems": 32, "uniqueItems": true, "items": { "$ref": "#/$defs/repositoryPath" } } } }
190
+ ]
191
+ },
192
+ "document": {
193
+ "type": "object", "additionalProperties": false,
194
+ "required": ["id", "type", "status", "owner", "summary", "title", "repositoryPath", "source", "metadata", "related", "blockedBy"],
195
+ "properties": {
196
+ "id": { "$ref": "#/$defs/opaqueId" }, "type": { "$ref": "#/$defs/lowerId" }, "status": { "$ref": "#/$defs/lowerId" },
197
+ "owner": { "$ref": "#/$defs/opaqueId" }, "summary": { "type": "string", "minLength": 1, "maxLength": 1000 },
198
+ "title": { "type": "string", "minLength": 1, "maxLength": 240 }, "repositoryPath": { "$ref": "#/$defs/repositoryPath" },
199
+ "source": { "enum": ["frontmatter-readme", "markdown-tree"] },
200
+ "metadata": { "type": "object", "maxProperties": 10000, "additionalProperties": { "$ref": "#/$defs/jsonValue" } },
201
+ "related": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/opaqueId" } },
202
+ "blockedBy": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/opaqueId" } }
203
+ }
204
+ },
205
+ "findResult": { "type": "object", "additionalProperties": false, "required": ["kind", "matches", "documents"], "properties": { "kind": { "const": "find" }, "matches": { "type": "integer", "minimum": 0, "maximum": 10000 }, "documents": { "type": "array", "maxItems": 10000, "items": { "$ref": "#/$defs/document" } }, "ranking": { "const": "fuzzy-advisory" } } },
206
+ "contextResult": {
207
+ "type": "object",
208
+ "additionalProperties": false,
209
+ "required": ["kind", "format", "projectId", "catalogSemanticDigest", "selection", "limits", "includedDocuments", "omittedDocuments", "truncated", "content"],
210
+ "allOf": [
211
+ {
212
+ "if": {
213
+ "properties": { "omittedDocuments": { "type": "integer", "minimum": 1 } },
214
+ "required": ["omittedDocuments"]
215
+ },
216
+ "then": { "properties": { "truncated": { "const": true } } },
217
+ "else": { "properties": { "truncated": { "const": false } } }
218
+ }
219
+ ],
220
+ "properties": {
221
+ "kind": { "const": "context" },
222
+ "format": { "const": "llms.txt" },
223
+ "projectId": { "$ref": "#/$defs/lowerId" },
224
+ "catalogSemanticDigest": { "$ref": "#/$defs/digest" },
225
+ "selection": {
226
+ "type": "object", "additionalProperties": false, "required": ["ranking", "query"],
227
+ "allOf": [{
228
+ "if": { "properties": { "ranking": { "const": "fuzzy-advisory" } }, "required": ["ranking"] },
229
+ "then": { "properties": { "query": { "type": "object", "required": ["text"], "properties": { "text": { "type": "string" } } } } }
230
+ }],
231
+ "properties": {
232
+ "ranking": { "enum": ["binary-default", "fuzzy-advisory"] },
233
+ "query": {
234
+ "type": "object", "additionalProperties": false,
235
+ "properties": {
236
+ "text": { "type": "string", "minLength": 1, "maxLength": 1000, "pattern": "^(?!\\s)(?!.*\\s$)[^\\u0000-\\u001F\\u007F\\uD800-\\uDFFF]+$" },
237
+ "id": { "$ref": "#/$defs/opaqueId" },
238
+ "type": { "$ref": "#/$defs/lowerId" },
239
+ "status": { "$ref": "#/$defs/lowerId" },
240
+ "owner": { "$ref": "#/$defs/opaqueId" },
241
+ "related": { "$ref": "#/$defs/opaqueId" },
242
+ "blockedBy": { "$ref": "#/$defs/opaqueId" }
243
+ }
244
+ }
245
+ }
246
+ },
247
+ "limits": {
248
+ "type": "object", "additionalProperties": false, "required": ["maxBytes", "maxDocuments"],
249
+ "properties": {
250
+ "maxBytes": { "type": "integer", "minimum": 1024, "maximum": 1048576 },
251
+ "maxDocuments": { "type": "integer", "minimum": 0, "maximum": 10000 }
252
+ }
253
+ },
254
+ "includedDocuments": { "type": "integer", "minimum": 0, "maximum": 10000 },
255
+ "omittedDocuments": { "type": "integer", "minimum": 0, "maximum": 10000 },
256
+ "truncated": { "type": "boolean" },
257
+ "content": { "type": "string", "maxLength": 1048576 }
258
+ }
259
+ },
260
+ "bootstrapFile": {
261
+ "type": "object", "additionalProperties": false,
262
+ "required": ["ownership", "path", "writeState"],
263
+ "properties": {
264
+ "ownership": { "enum": ["create-only", "managed-block"] },
265
+ "path": { "$ref": "#/$defs/repositoryPath" },
266
+ "writeState": { "enum": ["blocked", "create", "current", "replace"] }
267
+ }
268
+ },
269
+ "bootstrapIssue": {
270
+ "type": "object", "additionalProperties": false,
271
+ "required": ["code", "message", "path"],
272
+ "properties": {
273
+ "code": { "enum": ["PORTABLE_BOOTSTRAP_AGENTS_TOO_LARGE", "PORTABLE_BOOTSTRAP_CONFLICT", "PORTABLE_BOOTSTRAP_INVALID_AGENTS_MARKERS"] },
274
+ "message": { "type": "string", "minLength": 1, "maxLength": 1000 },
275
+ "path": { "$ref": "#/$defs/repositoryPath" }
276
+ }
277
+ },
278
+ "initResult": {
279
+ "oneOf": [
280
+ {
281
+ "type": "object", "additionalProperties": false,
282
+ "required": ["kind", "operation", "writeState", "planDigest", "files", "issues"],
283
+ "allOf": [
284
+ {
285
+ "if": { "properties": { "writeState": { "const": "applied" } }, "required": ["writeState"] },
286
+ "then": {
287
+ "required": ["receiptDigest", "receiptOutcome"],
288
+ "properties": {
289
+ "receiptDigest": { "$ref": "#/$defs/digest" },
290
+ "receiptOutcome": { "const": "applied" }
291
+ }
292
+ },
293
+ "else": {
294
+ "if": { "properties": { "writeState": { "const": "current" } }, "required": ["writeState"] },
295
+ "then": {
296
+ "oneOf": [
297
+ {
298
+ "required": ["receiptDigest", "receiptOutcome"],
299
+ "properties": {
300
+ "receiptDigest": { "$ref": "#/$defs/digest" },
301
+ "receiptOutcome": { "const": "already-satisfied" }
302
+ }
303
+ },
304
+ { "properties": { "receiptDigest": false, "receiptOutcome": false } }
305
+ ]
306
+ },
307
+ "else": { "properties": { "receiptDigest": false, "receiptOutcome": false } }
308
+ }
309
+ },
310
+ {
311
+ "if": { "properties": { "writeState": { "const": "blocked" } }, "required": ["writeState"] },
312
+ "then": { "properties": { "issues": { "type": "array", "minItems": 1 } } },
313
+ "else": { "properties": { "issues": { "type": "array", "maxItems": 0 } } }
314
+ },
315
+ {
316
+ "if": { "properties": { "writeState": { "const": "current" } }, "required": ["writeState"] },
317
+ "then": {
318
+ "properties": {
319
+ "files": {
320
+ "type": "array",
321
+ "items": {
322
+ "type": "object",
323
+ "properties": { "writeState": { "const": "current" } },
324
+ "required": ["writeState"]
325
+ }
326
+ }
327
+ }
328
+ }
329
+ },
330
+ {
331
+ "if": { "properties": { "writeState": { "enum": ["applied", "preview"] } }, "required": ["writeState"] },
332
+ "then": {
333
+ "properties": {
334
+ "files": {
335
+ "type": "array",
336
+ "items": {
337
+ "type": "object",
338
+ "properties": { "writeState": { "enum": ["create", "current", "replace"] } },
339
+ "required": ["writeState"]
340
+ },
341
+ "contains": {
342
+ "type": "object",
343
+ "properties": { "writeState": { "enum": ["create", "replace"] } },
344
+ "required": ["writeState"]
345
+ },
346
+ "minContains": 1
347
+ }
348
+ }
349
+ }
350
+ },
351
+ {
352
+ "if": { "properties": { "writeState": { "const": "blocked" } }, "required": ["writeState"] },
353
+ "then": {
354
+ "properties": {
355
+ "files": {
356
+ "type": "array",
357
+ "contains": {
358
+ "type": "object",
359
+ "properties": { "writeState": { "const": "blocked" } },
360
+ "required": ["writeState"]
361
+ },
362
+ "minContains": 1
363
+ }
364
+ }
365
+ }
366
+ }
367
+ ],
368
+ "properties": {
369
+ "kind": { "const": "init" }, "operation": { "const": "plan" },
370
+ "writeState": { "enum": ["applied", "blocked", "current", "preview"] },
371
+ "planDigest": { "$ref": "#/$defs/digest" },
372
+ "files": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/bootstrapFile" } },
373
+ "issues": { "type": "array", "maxItems": 32, "items": { "$ref": "#/$defs/bootstrapIssue" } },
374
+ "receiptDigest": { "$ref": "#/$defs/digest" },
375
+ "receiptOutcome": { "enum": ["already-satisfied", "applied", "rolled-back"] }
376
+ }
377
+ },
378
+ {
379
+ "type": "object", "additionalProperties": false,
380
+ "required": ["kind", "operation", "writeState"],
381
+ "allOf": [
382
+ {
383
+ "if": { "properties": { "writeState": { "const": "recovered" } }, "required": ["writeState"] },
384
+ "then": {
385
+ "required": ["receiptDigest", "receiptOutcome"],
386
+ "properties": {
387
+ "receiptDigest": { "$ref": "#/$defs/digest" },
388
+ "receiptOutcome": { "enum": ["already-satisfied", "applied", "rolled-back"] }
389
+ }
390
+ },
391
+ "else": { "properties": { "receiptDigest": false, "receiptOutcome": false } }
392
+ }
393
+ ],
394
+ "properties": {
395
+ "kind": { "const": "init" }, "operation": { "const": "recover" },
396
+ "writeState": { "enum": ["blocked", "recovered", "unchanged"] },
397
+ "receiptDigest": { "$ref": "#/$defs/digest" },
398
+ "receiptOutcome": { "enum": ["already-satisfied", "applied", "rolled-back"] }
399
+ }
400
+ },
401
+ {
402
+ "type": "object", "additionalProperties": false,
403
+ "required": ["kind", "operation", "writeState", "reason"],
404
+ "properties": {
405
+ "kind": { "const": "init" },
406
+ "operation": { "const": "wait" },
407
+ "writeState": { "const": "blocked" },
408
+ "reason": { "const": "operation-active" }
409
+ }
410
+ }
411
+ ]
412
+ },
413
+ "reachabilityAction": {
414
+ "oneOf": [
415
+ { "type": "object", "additionalProperties": false, "required": ["state", "indexPath", "markdownLink"], "properties": { "state": { "const": "manual-required" }, "indexPath": { "$ref": "#/$defs/repositoryPath" }, "markdownLink": { "type": "string", "minLength": 1, "maxLength": 1024 } } },
416
+ { "type": "object", "additionalProperties": false, "required": ["state", "reason"], "properties": { "state": { "const": "not-required" }, "reason": { "type": "string", "minLength": 1, "maxLength": 500 } } }
417
+ ]
418
+ },
419
+ "compiledDocument": {
420
+ "type": "object", "additionalProperties": false,
421
+ "required": ["schemaVersion", "document", "frontmatter", "metadata", "relations", "anchors"],
422
+ "properties": {
423
+ "schemaVersion": { "const": 1 },
424
+ "document": { "type": "object", "additionalProperties": false, "required": ["content", "digest", "mediaType", "size"], "properties": { "content": { "type": "string", "maxLength": 1048576 }, "digest": { "$ref": "#/$defs/digest" }, "mediaType": { "const": "text/markdown; charset=utf-8" }, "size": { "type": "integer", "minimum": 1, "maximum": 1048576 } } },
425
+ "frontmatter": { "type": "string", "minLength": 1, "maxLength": 262144 },
426
+ "metadata": { "type": "object", "maxProperties": 10000, "additionalProperties": { "$ref": "#/$defs/jsonValue" } },
427
+ "relations": { "type": "object", "additionalProperties": false, "required": ["blockedBy", "related"], "properties": { "blockedBy": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/opaqueId" } }, "related": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/opaqueId" } } } },
428
+ "anchors": { "type": "array", "maxItems": 256, "items": { "type": "object", "additionalProperties": false, "required": ["enforcement", "pattern"], "properties": { "enforcement": { "enum": ["advisory", "required"] }, "pattern": { "type": "string", "minLength": 1, "maxLength": 1000 } } } }
429
+ }
430
+ },
431
+ "recovery": { "type": "object", "additionalProperties": false, "required": ["commandId", "args"], "properties": { "commandId": { "enum": ["detach", "docs.recover", "docs-recover", "scaffold-recover"] }, "args": { "type": "object", "maxProperties": 16, "additionalProperties": { "type": "string", "maxLength": 512 } } } },
432
+ "receiptEvidence": {
433
+ "type": "object", "additionalProperties": false, "required": ["outcome", "commit"],
434
+ "properties": {
435
+ "outcome": { "enum": ["applied", "already-applied", "authority-stale", "rejected", "recovery-required", "manual-recovery-required", "failed-before-publication", "cancelled"] },
436
+ "commit": { "type": "object", "additionalProperties": false, "required": ["state", "publication", "recoverability"], "properties": { "state": { "enum": ["committed", "not-published", "recovery-required", "manual-recovery-required"] }, "publication": { "enum": ["none", "preexisting-exact", "published", "unknown"] }, "recoverability": { "enum": ["not-required", "preserved-for-recovery"] } } },
437
+ "directoryMaterialization": { "type": "object", "additionalProperties": false, "required": ["state", "plannedDirectories", "observedCreatedDirectories"], "properties": { "state": { "enum": ["none-created", "created-and-retained", "preserved-unknown"] }, "plannedDirectories": { "type": "array", "maxItems": 128, "items": { "$ref": "#/$defs/repositoryPath" } }, "observedCreatedDirectories": { "type": "array", "maxItems": 128, "items": { "$ref": "#/$defs/repositoryPath" } } } }
438
+ }
439
+ },
440
+ "transaction": {
441
+ "type": "object", "additionalProperties": false, "required": ["state"],
442
+ "properties": { "state": { "enum": ["idle", "recoverable", "manual-recovery-required"] }, "transactionKind": { "enum": ["corrupt", "document", "local-mode", "scaffold", "transition-residue", "unknown", "version-mismatch"] }, "reason": { "type": "string", "minLength": 1, "maxLength": 1000 }, "recovery": { "$ref": "#/$defs/recovery" } }
443
+ },
444
+ "newResult": {
445
+ "oneOf": [
446
+ { "type": "object", "additionalProperties": false, "required": ["kind", "reservation", "writeState", "transaction"], "properties": { "kind": { "const": "new" }, "reservation": { "const": "none" }, "writeState": { "const": "blocked" }, "transaction": { "$ref": "#/$defs/transaction" } } },
447
+ { "type": "object", "additionalProperties": false, "required": ["kind", "reservation", "writeState", "reason"], "properties": { "kind": { "const": "new" }, "reservation": { "const": "none" }, "writeState": { "const": "blocked" }, "reason": { "enum": ["adoption-invalid", "authority-stale"] } } },
448
+ { "type": "object", "additionalProperties": false, "required": ["kind", "reservation", "writeState", "documentPath", "planDigest", "compiled", "reachability"], "properties": { "kind": { "const": "new" }, "reservation": { "const": "none" }, "writeState": { "const": "preview" }, "documentPath": { "$ref": "#/$defs/repositoryPath" }, "planDigest": { "$ref": "#/$defs/digest" }, "compiled": { "$ref": "#/$defs/compiledDocument" }, "reachability": { "$ref": "#/$defs/reachabilityAction" } } },
449
+ { "type": "object", "additionalProperties": false, "required": ["kind", "reservation", "writeState", "documentPath", "planDigest", "compiled", "receiptDigest", "receiptOutcome", "receipt"], "properties": { "kind": { "const": "new" }, "reservation": { "const": "none" }, "writeState": { "enum": ["applied", "already-applied", "published-recovery-required", "unchanged", "unknown"] }, "documentPath": { "$ref": "#/$defs/repositoryPath" }, "planDigest": { "$ref": "#/$defs/digest" }, "compiled": { "$ref": "#/$defs/compiledDocument" }, "receiptDigest": { "$ref": "#/$defs/digest" }, "receiptOutcome": { "enum": ["applied", "already-applied", "authority-stale", "rejected", "recovery-required", "manual-recovery-required", "failed-before-publication", "cancelled"] }, "receipt": { "$ref": "#/$defs/receiptEvidence" }, "reachability": { "$ref": "#/$defs/reachabilityAction" } } }
450
+ ]
451
+ },
452
+ "environment": { "type": "object", "additionalProperties": false, "required": ["installedFoundationVersion", "installedFoundationBuildIdentity", "filesystem"], "properties": { "installedFoundationVersion": { "type": "string", "minLength": 1, "maxLength": 100 }, "installedFoundationBuildIdentity": { "$ref": "#/$defs/digest" }, "filesystem": { "type": "object", "additionalProperties": false, "required": ["basis", "strictDirectoryDurability"], "properties": { "basis": { "const": "platform-contract" }, "strictDirectoryDurability": { "enum": ["platform-supported", "platform-unsupported"] } } } } },
453
+ "doctorResult": { "type": "object", "additionalProperties": false, "required": ["kind", "protocol", "environment", "transaction"], "properties": { "kind": { "const": "doctor" }, "protocol": { "$ref": "#/$defs/protocol" }, "projectId": { "$ref": "#/$defs/lowerId" }, "environment": { "$ref": "#/$defs/environment" }, "transaction": { "$ref": "#/$defs/transaction" } } },
454
+ "recoverResult": { "oneOf": [
455
+ { "type": "object", "additionalProperties": false, "required": ["kind", "transactionState", "writeState"], "properties": { "kind": { "const": "recover" }, "transactionState": { "const": "no-pending-transaction" }, "writeState": { "const": "unchanged" } } },
456
+ { "type": "object", "additionalProperties": false, "required": ["kind", "transactionState", "writeState", "transaction"], "properties": { "kind": { "const": "recover" }, "transactionState": { "const": "manual-required" }, "writeState": { "const": "unknown" }, "transaction": { "$ref": "#/$defs/transaction" } } },
457
+ { "type": "object", "additionalProperties": false, "required": ["kind", "transactionState", "writeState", "receiptDigest", "receipt"], "properties": { "kind": { "const": "recover" }, "transactionState": { "enum": ["recovered", "recovery-required"] }, "writeState": { "enum": ["unchanged", "unknown", "committed", "published-recovery-required"] }, "receiptDigest": { "$ref": "#/$defs/digest" }, "receipt": { "$ref": "#/$defs/receiptEvidence" } } }
458
+ ] },
459
+ "checkResult": { "type": "object", "additionalProperties": false, "required": ["kind", "projectId", "catalogStatus", "documents", "foundationProfile", "metadataSidecar", "semanticValidatorIds", "valid"], "properties": { "kind": { "const": "check" }, "projectId": { "$ref": "#/$defs/lowerId" }, "catalogStatus": { "enum": ["complete", "partial"] }, "documents": { "type": "integer", "minimum": 0, "maximum": 100000 }, "foundationProfile": { "$ref": "#/$defs/foundationProfile" }, "metadataSidecar": { "$ref": "#/$defs/metadataSidecar" }, "semanticValidatorIds": { "type": "array", "maxItems": 256, "items": { "$ref": "#/$defs/lowerId" } }, "valid": { "type": "boolean" } } },
460
+ "infoEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.info" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [{ "if": { "type": "object", "properties": { "outcome": { "const": "success" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/infoResult" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } }] } },
461
+ "findEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.find" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [
462
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/findResult" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } },
463
+ { "if": { "type": "object", "properties": { "outcome": { "const": "violation" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "type": "object", "properties": { "matches": { "type": "integer", "const": 0 }, "documents": { "type": "array", "maxItems": 0 } } } } } }
464
+ ] } },
465
+ "contextEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.context" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "authority-stale", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [
466
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "authority-stale"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/contextResult" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } },
467
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["violation", "authority-stale"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "type": "object", "properties": { "includedDocuments": { "type": "integer", "const": 0 }, "content": { "type": "string", "const": "" } } } } } }
468
+ ] } },
469
+ "initEnvelope": {
470
+ "if": { "type": "object", "properties": { "command": { "const": "docs.init" } }, "required": ["command"] },
471
+ "then": {
472
+ "type": "object",
473
+ "properties": { "outcome": { "enum": ["success", "conflict", "authority-stale", "recovery-required", "invalid-input", "execution-failure", "cancelled"] } },
474
+ "allOf": [
475
+ {
476
+ "if": { "type": "object", "properties": { "outcome": { "enum": ["success", "conflict", "authority-stale", "recovery-required"] } }, "required": ["outcome"] },
477
+ "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/initResult" } } },
478
+ "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } }
479
+ },
480
+ {
481
+ "if": { "properties": { "result": { "type": "object", "properties": { "operation": { "const": "wait" } }, "required": ["operation"] } }, "required": ["result"] },
482
+ "then": { "properties": { "outcome": { "const": "conflict" } } }
483
+ },
484
+ {
485
+ "if": { "properties": { "outcome": { "const": "recovery-required" } }, "required": ["outcome"] },
486
+ "then": { "properties": { "result": { "type": "object", "properties": { "operation": { "const": "recover" }, "writeState": { "const": "blocked" } }, "required": ["operation", "writeState"] } } }
487
+ },
488
+ {
489
+ "if": { "properties": { "result": { "type": "object", "properties": { "operation": { "const": "recover" }, "writeState": { "const": "blocked" } }, "required": ["operation", "writeState"] } }, "required": ["result"] },
490
+ "then": { "properties": { "outcome": { "const": "recovery-required" } } }
491
+ }
492
+ ]
493
+ }
494
+ },
495
+ "newEnvelope": {
496
+ "if": { "type": "object", "properties": { "command": { "const": "docs.new" } }, "required": ["command"] },
497
+ "then": {
498
+ "type": "object",
499
+ "properties": { "outcome": { "enum": ["success", "conflict", "violation", "authority-stale", "recovery-required", "invalid-input", "execution-failure", "cancelled"] } },
500
+ "allOf": [
501
+ { "if": { "type": "object", "properties": { "outcome": { "const": "success" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "enum": ["preview", "applied", "already-applied"] } }, "required": ["writeState"] }] } } } },
502
+ { "if": { "type": "object", "properties": { "outcome": { "const": "authority-stale" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "enum": ["blocked", "unchanged", "unknown"] } }, "required": ["writeState"] }] } } } },
503
+ { "if": { "type": "object", "properties": { "outcome": { "const": "recovery-required" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "enum": ["blocked", "published-recovery-required", "unknown", "unchanged"] } }, "required": ["writeState"] }] } } } },
504
+ { "if": { "type": "object", "properties": { "outcome": { "const": "conflict" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "enum": ["unchanged", "unknown"] }, "receipt": true }, "required": ["writeState", "receipt"] }] } } } },
505
+ { "if": { "type": "object", "properties": { "outcome": { "const": "violation" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "const": "blocked" }, "reason": { "const": "adoption-invalid" } }, "required": ["writeState", "reason"] }] } } } },
506
+ { "if": { "type": "object", "properties": { "outcome": { "const": "invalid-input" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } },
507
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["execution-failure", "cancelled"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "oneOf": [{ "$ref": "#/$defs/emptyResult" }, { "allOf": [{ "$ref": "#/$defs/newResult" }, { "type": "object", "properties": { "writeState": { "enum": ["unchanged", "unknown", "published-recovery-required"] }, "receipt": true }, "required": ["writeState", "receipt"] }] }] } } } }
508
+ ]
509
+ }
510
+ },
511
+ "doctorEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.doctor" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "recovery-required", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [{ "if": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "recovery-required"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/doctorResult" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } }] } },
512
+ "recoverEnvelope": {
513
+ "if": { "type": "object", "properties": { "command": { "const": "docs.recover" } }, "required": ["command"] },
514
+ "then": {
515
+ "type": "object",
516
+ "properties": { "outcome": { "enum": ["success", "conflict", "authority-stale", "recovery-required", "invalid-input", "execution-failure", "cancelled"] } },
517
+ "allOf": [
518
+ { "if": { "type": "object", "properties": { "outcome": { "const": "success" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/recoverResult" }, { "type": "object", "properties": { "transactionState": { "enum": ["no-pending-transaction", "recovered"] } }, "required": ["transactionState"] }] } } } },
519
+ { "if": { "type": "object", "properties": { "outcome": { "const": "recovery-required" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/recoverResult" }, { "type": "object", "properties": { "transactionState": { "enum": ["manual-required", "recovery-required"] } }, "required": ["transactionState"] }] } } } },
520
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["conflict", "authority-stale"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "allOf": [{ "$ref": "#/$defs/recoverResult" }, { "type": "object", "properties": { "transactionState": { "const": "recovery-required" }, "receipt": true }, "required": ["transactionState", "receipt"] }] } } } },
521
+ { "if": { "type": "object", "properties": { "outcome": { "const": "invalid-input" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } },
522
+ { "if": { "type": "object", "properties": { "outcome": { "enum": ["execution-failure", "cancelled"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "oneOf": [{ "$ref": "#/$defs/emptyResult" }, { "allOf": [{ "$ref": "#/$defs/recoverResult" }, { "type": "object", "properties": { "transactionState": { "const": "recovery-required" }, "receipt": true }, "required": ["transactionState", "receipt"] }] }] } } } }
523
+ ]
524
+ }
525
+ },
526
+ "checkEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.check" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [{ "if": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation"] } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "#/$defs/checkResult" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } }] } },
527
+ "qualificationEnvelope": { "if": { "type": "object", "properties": { "command": { "const": "docs.qualify" } }, "required": ["command"] }, "then": { "type": "object", "properties": { "outcome": { "enum": ["success", "violation", "invalid-input", "execution-failure", "cancelled"] } }, "allOf": [{ "if": { "type": "object", "properties": { "outcome": { "const": "success" } }, "required": ["outcome"] }, "then": { "type": "object", "properties": { "result": { "$ref": "https://agent-teams.ai/schemas/docs-protocol-qualification-receipt/v2" } } }, "else": { "type": "object", "properties": { "result": { "$ref": "#/$defs/emptyResult" } } } }] } }
528
+ }
529
+ }