@treeseed/sdk 0.13.0-rc.122 → 0.13.0-rc.124

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 (126) hide show
  1. package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +1392 -974
  2. package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +72 -27
  3. package/dist/agent-capacity/contracts/capacity/assignments/assignment-context-pack.d.ts +34 -34
  4. package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.d.ts +2 -0
  5. package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.js +13 -0
  6. package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +1 -0
  7. package/dist/agent-capacity/contracts/capacity/providers/supply-policy.d.ts +126 -1
  8. package/dist/agent-capacity/contracts/capacity/providers/supply-policy.js +35 -1
  9. package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.d.ts +1 -3
  10. package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.js +21 -15
  11. package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.d.ts +3 -42
  12. package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.js +8 -8
  13. package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +227 -66
  14. package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +54 -19
  15. package/dist/agent-capacity/contracts/capacity/workdays/workday-records.d.ts +214 -5
  16. package/dist/agent-capacity/contracts/capacity/workdays/workday-records.js +19 -0
  17. package/dist/agent-capacity/contracts/operations/agent-team-clone.d.ts +47 -47
  18. package/dist/agent-capacity/contracts/projects/agents/project-agent-class.d.ts +119 -0
  19. package/dist/agent-capacity/contracts/projects/agents/project-agent-class.js +16 -0
  20. package/dist/agent-capacity/contracts/support/execution-graph.d.ts +434 -230
  21. package/dist/agent-capacity/contracts/support/execution-graph.js +20 -18
  22. package/dist/agent-capacity/contracts/support/financial-records.d.ts +2 -0
  23. package/dist/agent-capacity/validation/agent-definition-schema.d.ts +286 -254
  24. package/dist/agent-capacity/validation/agent-definition-schema.js +22 -28
  25. package/dist/agent-capacity/validation/agent-lab-forensics-schema.d.ts +1 -1
  26. package/dist/agent-capacity/validation/assignment-records.js +45 -0
  27. package/dist/capacity/agents/agent-capacity.d.ts +1 -0
  28. package/dist/capacity/agents/agent-capacity.js +1 -0
  29. package/dist/capacity-provider/capability-ontology.d.ts +102 -102
  30. package/dist/capacity-provider/client.d.ts +14 -7
  31. package/dist/capacity-provider/client.js +1 -4
  32. package/dist/capacity-provider/contracts/capacity-facts.d.ts +0 -1
  33. package/dist/capacity-provider/contracts/environment-profiles.d.ts +40 -40
  34. package/dist/capacity-provider/contracts/governance.d.ts +2 -17
  35. package/dist/capacity-provider/contracts/index.d.ts +2 -0
  36. package/dist/capacity-provider/contracts/index.js +2 -0
  37. package/dist/capacity-provider/core-capability-catalog.d.ts +7 -7
  38. package/dist/capacity-provider/environment-catalog.d.ts +22 -22
  39. package/dist/capacity-provider/environment-catalog.js +1 -1
  40. package/dist/capacity-provider/install-configuration.d.ts +4 -4
  41. package/dist/capacity-provider/sandbox-contracts.d.ts +54 -54
  42. package/dist/capacity-provider/source-workspace.d.ts +76 -76
  43. package/dist/capacity-provider/validation.d.ts +10 -2
  44. package/dist/capacity-provider/validation.js +52 -22
  45. package/dist/content/validation/agent-operational-content-schemas.d.ts +120 -118
  46. package/dist/content/validation/agent-operational-content-schemas.js +2 -0
  47. package/dist/content/validation/auxiliary-content-schemas.d.ts +92 -92
  48. package/dist/content/validation/content-model-schemas.d.ts +3155 -2512
  49. package/dist/content/validation/content-model-schemas.js +97 -87
  50. package/dist/content/validation/portable-content-data.d.ts +173 -168
  51. package/dist/content/validation/schema-constraints.d.ts +78 -0
  52. package/dist/content/validation/schema-constraints.js +149 -0
  53. package/dist/deployment/ai/storage.d.ts +20 -20
  54. package/dist/deployment/ai-hosting.d.ts +12 -12
  55. package/dist/deployment/ai-instance.d.ts +12 -12
  56. package/dist/deployment/ai-mode.d.ts +34 -34
  57. package/dist/deployment/hosted-topology-template.d.ts +25 -25
  58. package/dist/deployment/hosted-topology.d.ts +146 -146
  59. package/dist/deployment/postgres/transfer.d.ts +2 -2
  60. package/dist/deployment/schemas.d.ts +504 -504
  61. package/dist/development/schemas.d.ts +325 -325
  62. package/dist/graph/context-query-contracts.js +1 -1
  63. package/dist/guarantees/index.d.ts +26 -2
  64. package/dist/identity/contracts.js +6 -1
  65. package/dist/operator-contracts/canonical-command-tree.js +22 -8
  66. package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.d.ts +27 -27
  67. package/dist/operator-contracts/catalog/capability-ontology-operations.d.ts +25 -25
  68. package/dist/operator-contracts/catalog/commands/command-tree-builders.d.ts +11 -9
  69. package/dist/operator-contracts/catalog/communication-operations.d.ts +108 -90
  70. package/dist/operator-contracts/catalog/hosted-topology-operations.d.ts +33 -33
  71. package/dist/operator-contracts/catalog/inbox-operations.d.ts +27 -27
  72. package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.d.ts +4 -4
  73. package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.js +2 -1
  74. package/dist/operator-contracts/catalog/knowledge-share-operations.d.ts +5 -5
  75. package/dist/operator-contracts/catalog/provider-environment-operations.d.ts +3 -3
  76. package/dist/operator-contracts/catalog/services/secret-operations.d.ts +16 -8
  77. package/dist/operator-contracts/catalog/services/secret-operations.js +2 -1
  78. package/dist/operator-contracts/catalog/workdays/profile-operations.d.ts +11 -11
  79. package/dist/operator-contracts/catalog/workdays/selection-commands.js +7 -6
  80. package/dist/operator-contracts/communication/contracts.d.ts +340 -198
  81. package/dist/operator-contracts/communication/contracts.js +6 -1
  82. package/dist/operator-contracts/control-plane-operation.d.ts +7 -0
  83. package/dist/operator-contracts/control-plane-operation.js +6 -0
  84. package/dist/operator-contracts/control-plane-operations.d.ts +469 -442
  85. package/dist/operator-contracts/control-plane-operations.js +26 -10
  86. package/dist/operator-contracts/inbox/contracts.d.ts +100 -100
  87. package/dist/operator-contracts/knowledge/contracts.d.ts +6 -6
  88. package/dist/operator-contracts/mcp.js +4 -3
  89. package/dist/operator-contracts/workday-lifecycle.d.ts +192 -2
  90. package/dist/operator-contracts/workday-lifecycle.js +108 -45
  91. package/dist/platform/agent-schema-verification.js +316 -33
  92. package/dist/platform/contracts.d.ts +72 -72
  93. package/dist/platform/schemas.d.ts +144 -36
  94. package/dist/platform/schemas.js +26 -0
  95. package/dist/platform/verification.js +4 -0
  96. package/dist/sdk-types/support/sdk-search-request.d.ts +2 -2
  97. package/dist/secrets-capability/secret-contracts.d.ts +2 -2
  98. package/dist/secrets-capability/shared-access.d.ts +1 -1
  99. package/dist/secrets-capability/shared-resources.d.ts +30 -30
  100. package/dist/security/encrypted-envelope.d.ts +6 -6
  101. package/dist/treedx/client.d.ts +4 -4
  102. package/dist/treedx/index.d.ts +1 -1
  103. package/dist/treedx/index.js +1 -0
  104. package/dist/treedx/types.d.ts +286 -0
  105. package/dist/treedx/types.js +44 -0
  106. package/dist/types/agents/agent-activity-profile.d.ts +1 -0
  107. package/guarantees/agent/golden/component-boundaries.guarantee.yaml +12 -0
  108. package/guarantees/agent/golden/product-custody.guarantee.yaml +12 -0
  109. package/guarantees/agent/golden/product.guarantee.yaml +12 -0
  110. package/guarantees/agent/golden/scenes/component-boundaries.scene.yaml +837 -0
  111. package/guarantees/agent/golden/scenes/product-custody.scene.yaml +53 -0
  112. package/guarantees/agent/golden/scenes/product.scene.yaml +8 -0
  113. package/guarantees/verifiers/golden.verifiers.yaml +1429 -0
  114. package/package.json +10 -5
  115. package/tests/acceptance/golden-product.test.ts +205 -0
  116. package/tests/acceptance/golden-product.ts +404 -0
  117. package/tests/acceptance/product/base-red.ts +73 -0
  118. package/tests/acceptance/product/documentation-examples.ts +68 -0
  119. package/tests/acceptance/product/intent-runtime.ts +145 -0
  120. package/tests/acceptance/product/release-output.ts +160 -0
  121. package/tests/acceptance/product/research-artifact.ts +87 -0
  122. package/tests/acceptance/product/research-revision.ts +82 -0
  123. package/tests/acceptance/product/research-source.ts +91 -0
  124. package/tests/acceptance/product/test-chain.ts +192 -0
  125. package/treeseed.package.yaml +147 -0
  126. package/dist/.treeseed-build-complete.json +0 -1
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
- import { agentDefinitionSchema } from "../../agent-capacity/validation/agent-definition-schema.js";
2
+ import { conditionalFields, requiredProperties, uniqueArray as unique } from "./schema-constraints.js";
3
+ import { agentClassSchema as agentClass, agentDefinitionSchema, permissionSetSchema } from "../../agent-capacity/validation/agent-definition-schema.js";
3
4
  import {
4
5
  BOOK_SCHEMA_VERSION,
5
6
  KNOWLEDGE_PAGE_SCHEMA_VERSION,
@@ -13,33 +14,26 @@ import { agentTestContentSchema, templateProductContentSchema, workdayContentSch
13
14
  export * from "./agent-operational-content-schemas.js";
14
15
  const nonEmpty = z.string().trim().min(1);
15
16
  const strings = z.array(z.string());
16
- const identifier = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
17
- const slug = z.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[._/-][a-z0-9]+)*$/u);
18
- const agentClass = z.string().trim().min(1).max(100).regex(/^[a-z][a-z0-9-]*$/u);
17
+ const identifier = z.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
18
+ const slug = z.string().min(1).max(100).regex(/^[a-z0-9]+(?:[._/-][a-z0-9]+)*$/u);
19
19
  const identifiers = z.array(identifier);
20
- const unique = (schema) => schema.superRefine((values, context) => {
21
- if (new Set(values.map((value) => JSON.stringify(value))).size !== values.length) {
22
- context.addIssue({ code: z.ZodIssueCode.custom, message: "Values must be unique." });
23
- }
24
- });
25
20
  const date = z.coerce.date();
26
21
  const lifecycleStatus = z.enum(["live", "in progress", "exploratory", "planned", "speculative"]);
27
22
  const exactRefs = z.array(exactEntityReferenceSchema);
23
+ const exactWorkItemReferenceSchema = z.intersection(exactEntityReferenceSchema, requiredProperties(
24
+ z.object({
25
+ store: z.literal("treedx"),
26
+ model: z.literal("proposal"),
27
+ anchor: z.string().regex(new RegExp("^work-item/[a-z0-9]+(?:-[a-z0-9]+)*$", "u"))
28
+ }).passthrough(),
29
+ ["store", "model", "id", "revision", "digest", "repository", "commit", "path", "anchor"],
30
+ "A dependency endpoint must identify an exact proposal work item."
31
+ ));
28
32
  const exactDependencyLinkSchema = z.object({
29
33
  relation: z.literal("depends_on"),
30
- from: exactEntityReferenceSchema,
31
- to: exactEntityReferenceSchema
34
+ from: exactWorkItemReferenceSchema,
35
+ to: exactWorkItemReferenceSchema
32
36
  }).strict().superRefine((link, context) => {
33
- for (const end of ["from", "to"]) {
34
- const ref = link[end];
35
- if (ref.store !== "treedx" || ref.model !== "proposal" || !ref.repository || !ref.commit || !ref.path || !ref.digest || !ref.revision || !/^work-item\/[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(ref.anchor ?? "")) {
36
- context.addIssue({
37
- code: z.ZodIssueCode.custom,
38
- path: [end],
39
- message: "A dependency endpoint must identify an exact proposal work item."
40
- });
41
- }
42
- }
43
37
  if (JSON.stringify(link.from) === JSON.stringify(link.to)) context.addIssue({
44
38
  code: z.ZodIssueCode.custom,
45
39
  message: "A work item cannot depend on itself."
@@ -82,29 +76,28 @@ const proposalLinks = {
82
76
  decision_dependencies: z.array(z.object({ projectId: nonEmpty, decisionId: nonEmpty }).strict()).optional(),
83
77
  ...linked
84
78
  };
85
- const executionPlanWorkItemSchema = z.object({
86
- id: nonEmpty.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u),
79
+ const executionPlanWorkItemSchema = conditionalFields(z.object({
80
+ id: slug,
81
+ priority: z.number().int().safe().optional(),
87
82
  activity: z.literal("acting"),
88
- agentClass: nonEmpty.regex(/^[a-z][a-z0-9-]*$/u),
83
+ agentClass,
89
84
  workspace: z.enum(["read-only", "treedx", "git"]),
90
85
  review: z.enum(["required", "none"]),
91
86
  objective: nonEmpty,
92
87
  estimate: estimateSchema.optional(),
93
88
  reviewEstimate: estimateSchema.optional(),
94
89
  maximumReviewCycles: z.number().int().positive().optional(),
95
- dependsOn: z.array(nonEmpty.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u)),
96
- requestedPermissions: z.object({
97
- content: z.object({ read: z.array(z.enum(["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"])), write: z.array(z.enum(["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"])) }).strict(),
98
- tools: z.array(z.enum(["discussion", "source.read", "source.write", "verification", "release"]))
99
- }).strict(),
100
- requiredCapabilities: z.array(nonEmpty).min(1),
101
- contextRefs: z.array(exactEntityReferenceSchema).optional(),
90
+ dependsOn: unique(z.array(slug)),
91
+ requestedPermissions: permissionSetSchema,
92
+ requiredCapabilities: unique(z.array(identifier)).optional(),
93
+ contextRefs: unique(exactRefs).optional(),
102
94
  acceptanceCriteria: z.array(nonEmpty).min(1)
103
- }).strict().superRefine((value, context) => {
104
- if (value.review === "required" && !value.maximumReviewCycles) context.addIssue({ code: z.ZodIssueCode.custom, message: "Required review needs a maximum cycle count." });
105
- if (value.review === "none" && (value.reviewEstimate || value.maximumReviewCycles)) context.addIssue({ code: z.ZodIssueCode.custom, message: "Unreviewed work cannot define review estimates or cycles." });
95
+ }).strict(), [
96
+ { field: "review", equals: "required", alternatives: [["maximumReviewCycles"]], message: "Required review needs a maximum cycle count." },
97
+ { field: "review", equals: "none", forbidden: { fields: ["reviewEstimate", "maximumReviewCycles"] }, message: "Unreviewed work cannot define review estimates or cycles." }
98
+ ]).superRefine((value, context) => {
106
99
  if (value.workspace !== "read-only") {
107
- const mutable = (value.contextRefs ?? []).filter((reference) => reference.store === value.workspace);
100
+ const mutable = (value.contextRefs ?? []).filter((reference) => reference.store === value.workspace && reference.model === "repository");
108
101
  if (mutable.length !== 1) context.addIssue({ code: z.ZodIssueCode.custom, path: ["contextRefs"], message: `${value.workspace} work requires exactly one exact ${value.workspace} workspace reference.` });
109
102
  }
110
103
  });
@@ -128,11 +121,12 @@ const executionPlanSchema = z.object({ workItems: z.array(executionPlanWorkItemS
128
121
  };
129
122
  if ([...ids].some(cyclic)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["workItems"], message: "Work-item dependencies must be acyclic." });
130
123
  });
131
- const proposalSchema = z.object({
124
+ const proposalSchema = conditionalFields(z.object({
132
125
  schemaVersion: z.literal("treeseed.proposal/v1"),
133
- id: nonEmpty,
134
- projectId: nonEmpty,
126
+ id: identifier,
127
+ projectId: identifier,
135
128
  title: nonEmpty,
129
+ groupIds: unique(identifiers).optional(),
136
130
  request: nonEmpty,
137
131
  summary: nonEmpty.optional(),
138
132
  status: z.enum(["draft", "discussing", "ready", "decided", "withdrawn"]),
@@ -140,26 +134,18 @@ const proposalSchema = z.object({
140
134
  evidenceRefs: unique(exactRefs).optional(),
141
135
  discussionRef: exactEntityReferenceSchema.optional(),
142
136
  executionPlan: executionPlanSchema.optional()
143
- }).strict().superRefine((value, context) => {
144
- if (["ready", "decided"].includes(value.status)) for (const [index, item] of (value.executionPlan?.workItems ?? []).entries()) {
145
- if (!item.estimate) context.addIssue({
146
- code: z.ZodIssueCode.custom,
147
- path: ["executionPlan", "workItems", index, "estimate"],
148
- message: "Ready work requires its agent-authored estimate."
149
- });
150
- if (item.review === "required" && !item.reviewEstimate) context.addIssue({
151
- code: z.ZodIssueCode.custom,
152
- path: ["executionPlan", "workItems", index, "reviewEstimate"],
153
- message: "Ready reviewed work requires its Reviewer-authored estimate."
154
- });
155
- }
156
- if (["ready", "decided"].includes(value.status) && !value.summary) {
157
- context.addIssue({ code: z.ZodIssueCode.custom, path: ["summary"], message: "A ready proposal requires a summary." });
158
- }
159
- if (["ready", "decided"].includes(value.status) && !value.executionPlan) {
160
- context.addIssue({ code: z.ZodIssueCode.custom, path: ["executionPlan"], message: "A ready proposal requires an execution plan." });
161
- }
162
- });
137
+ }).strict(), [{
138
+ field: "status",
139
+ in: ["ready", "decided"],
140
+ alternatives: [["summary", "executionPlan"]],
141
+ items: {
142
+ field: "executionPlan",
143
+ key: "workItems",
144
+ required: ["estimate"],
145
+ conditional: { field: "review", equals: "required", required: ["reviewEstimate"] }
146
+ },
147
+ message: "Ready proposals require a summary, an execution plan, and each required independent estimate."
148
+ }]);
163
149
  const schemas = {
164
150
  page: z.object({
165
151
  title: nonEmpty,
@@ -172,35 +158,40 @@ const schemas = {
172
158
  summary: nonEmpty.optional(),
173
159
  updated_at: date.optional()
174
160
  }),
175
- note: z.object({
161
+ note: conditionalFields(z.object({
176
162
  schemaVersion: z.literal("treeseed.note/v1"),
177
- id: nonEmpty,
178
- projectId: nonEmpty,
163
+ id: identifier,
164
+ projectId: identifier,
179
165
  classification: z.enum(["general", "feedback", "research", "workday-report"]),
180
- subjectRefs: exactRefs.min(1),
166
+ subjectRefs: unique(exactRefs.min(1)),
181
167
  body: nonEmpty,
182
168
  createdAt: z.string().datetime({ offset: true }),
183
169
  links: z.array(exactDependencyLinkSchema).optional()
184
- }).strict().superRefine((value, context) => {
185
- if (value.classification === "workday-report" && !value.subjectRefs.some((reference) => reference.store === "postgresql" && reference.model === "workday")) {
186
- context.addIssue({ code: z.ZodIssueCode.custom, path: ["subjectRefs"], message: "Workday reports must reference their exact workday." });
187
- }
188
- }),
189
- question: z.object({
170
+ }).strict(), [{
171
+ field: "classification",
172
+ equals: "workday-report",
173
+ contains: { field: "subjectRefs", properties: { store: "postgresql", model: "workday" } },
174
+ path: ["subjectRefs"],
175
+ message: "Workday reports must reference their exact workday."
176
+ }]),
177
+ question: conditionalFields(z.object({
190
178
  schemaVersion: z.literal("treeseed.question/v1"),
191
- id: nonEmpty,
192
- projectId: nonEmpty,
179
+ id: identifier,
180
+ projectId: identifier,
193
181
  subjectRef: exactEntityReferenceSchema,
194
182
  question: nonEmpty,
195
183
  status: z.enum(["open", "answered", "withdrawn"]),
196
- addressedTo: strings.optional(),
184
+ addressedTo: unique(z.array(agentClass)).optional(),
197
185
  answer: nonEmpty.optional(),
198
- answerRefs: exactRefs.optional(),
186
+ answerRefs: unique(exactRefs).optional(),
199
187
  askedAt: z.string().datetime({ offset: true }),
200
188
  answeredAt: z.string().datetime({ offset: true }).optional()
201
- }).strict().superRefine((value, context) => {
202
- if (value.status === "answered" && !(value.answer || value.answerRefs?.length)) context.addIssue({ code: z.ZodIssueCode.custom, message: "Answered questions require an answer or exact answer reference." });
203
- }),
189
+ }).strict(), [{
190
+ field: "status",
191
+ equals: "answered",
192
+ alternatives: [["answer"], ["answerRefs"]],
193
+ message: "Answered questions require an answer or exact answer reference."
194
+ }]),
204
195
  objective: z.object({
205
196
  schemaVersion: z.literal("treeseed.objective/v1"),
206
197
  id: identifier,
@@ -211,25 +202,44 @@ const schemas = {
211
202
  evidenceRefs: unique(exactRefs).optional()
212
203
  }).strict(),
213
204
  proposal: proposalSchema,
214
- decision: z.object({
205
+ decision: conditionalFields(z.object({
215
206
  schemaVersion: z.literal("treeseed.decision/v1"),
216
- id: nonEmpty,
217
- projectId: nonEmpty,
207
+ id: identifier,
208
+ projectId: identifier,
218
209
  decisionClass: z.enum(["proposal", "work-review", "publication"]),
219
210
  decisionMethod: z.enum(["authority", "approval", "vote"]),
220
211
  subjectRef: exactEntityReferenceSchema,
221
212
  disposition: z.enum(["approved", "rejected", "request-changes", "deferred", "superseded"]),
222
213
  rationale: nonEmpty,
223
- findingRefs: exactRefs.optional(),
224
- authorityRefs: exactRefs.min(1),
225
- decidedByRefs: exactRefs.min(1),
214
+ findingRefs: unique(exactRefs).optional(),
215
+ authorityRefs: unique(exactRefs.min(1)),
216
+ decidedByRefs: unique(exactRefs.min(1)),
226
217
  positions: z.array(z.object({ actorRef: exactEntityReferenceSchema, position: z.enum(["approve", "reject", "abstain"]), rationale: z.string().optional(), recordedAt: z.string().datetime({ offset: true }) }).strict()).min(1).optional(),
227
218
  decidedAt: z.string().datetime({ offset: true })
228
- }).strict().superRefine((value, context) => {
229
- if (value.decisionMethod !== "authority" && !value.positions?.length) context.addIssue({ code: z.ZodIssueCode.custom, path: ["positions"], message: "Approval and vote decisions require signed positions." });
230
- if (value.decisionClass === "work-review" && !["approved", "request-changes"].includes(value.disposition)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["disposition"], message: "Work review must approve or request changes." });
231
- if (value.decisionClass !== "work-review" && value.disposition === "request-changes") context.addIssue({ code: z.ZodIssueCode.custom, path: ["disposition"], message: "Only work review may request changes." });
232
- }),
219
+ }).strict(), [
220
+ { field: "decisionMethod", in: ["approval", "vote"], alternatives: [["positions"]], path: ["positions"], message: "Approval and vote decisions require signed positions." },
221
+ {
222
+ field: "decisionClass",
223
+ equals: "work-review",
224
+ allowed: { field: "disposition", values: ["approved", "request-changes"] },
225
+ path: ["disposition"],
226
+ message: "Work review must approve or request changes."
227
+ },
228
+ {
229
+ field: "decisionClass",
230
+ equals: "proposal",
231
+ allowed: { field: "disposition", values: ["approved", "rejected", "deferred", "superseded"] },
232
+ path: ["disposition"],
233
+ message: "Only work review may request changes."
234
+ },
235
+ {
236
+ field: "decisionClass",
237
+ equals: "publication",
238
+ allowed: { field: "disposition", values: ["approved", "rejected", "deferred", "superseded"] },
239
+ path: ["disposition"],
240
+ message: "Only work review may request changes."
241
+ }
242
+ ]),
233
243
  book: z.object({
234
244
  schemaVersion: z.literal(BOOK_SCHEMA_VERSION),
235
245
  id: identifier,
@@ -393,7 +403,7 @@ function fieldContract(schema) {
393
403
  let required = true;
394
404
  while (current instanceof z.ZodOptional || current instanceof z.ZodNullable || current instanceof z.ZodDefault || current instanceof z.ZodEffects) {
395
405
  if (current instanceof z.ZodOptional || current instanceof z.ZodDefault) required = false;
396
- current = current instanceof z.ZodEffects ? current.innerType() : current.removeDefault?.() ?? current.unwrap();
406
+ current = current instanceof z.ZodEffects ? current.innerType() : current instanceof z.ZodDefault ? current.removeDefault() : current.unwrap();
397
407
  }
398
408
  const contract = { required };
399
409
  if (current instanceof z.ZodEnum) return { ...contract, type: "string", values: current.options };