@contentful/experience-design-system-types 2.42.1-dev-build-f69db6bf.0 → 2.43.0-alpha.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 (94) hide show
  1. package/README.md +15 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/agent-process-lifecycle.d.ts +26 -0
  4. package/dist/src/agent-process-lifecycle.js +171 -0
  5. package/dist/src/agent-prompt-artifact.d.ts +8 -0
  6. package/dist/src/agent-prompt-artifact.js +37 -0
  7. package/dist/src/agent-prompt-transport.d.ts +1 -0
  8. package/dist/src/agent-prompt-transport.js +4 -0
  9. package/dist/src/cdf/build.d.ts +9 -2
  10. package/dist/src/cdf/build.js +134 -17
  11. package/dist/src/cdf/finite-values.d.ts +8 -0
  12. package/dist/src/cdf/finite-values.js +21 -0
  13. package/dist/src/cdf/index.d.ts +2 -1
  14. package/dist/src/cdf/index.js +1 -0
  15. package/dist/src/cdf/property-validation.d.ts +16 -0
  16. package/dist/src/cdf/property-validation.js +211 -0
  17. package/dist/src/cdf/representation-validation.d.ts +6 -0
  18. package/dist/src/cdf/representation-validation.js +182 -0
  19. package/dist/src/cdf/schema.d.ts +778 -20
  20. package/dist/src/cdf/schema.js +362 -5
  21. package/dist/src/cdf/types.d.ts +57 -59
  22. package/dist/src/cdf/types.js +72 -15
  23. package/dist/src/cdf/validate.js +31 -1
  24. package/dist/src/cdf/vocabularies.d.ts +1 -1
  25. package/dist/src/cdf/vocabularies.js +9 -1
  26. package/dist/src/config/index.js +6 -3
  27. package/dist/src/exploration/constants.d.ts +10 -0
  28. package/dist/src/exploration/constants.js +18 -0
  29. package/dist/src/exploration/index.d.ts +3 -0
  30. package/dist/src/exploration/index.js +3 -0
  31. package/dist/src/exploration/schemas.d.ts +201 -0
  32. package/dist/src/exploration/schemas.js +126 -0
  33. package/dist/src/exploration/types.d.ts +393 -0
  34. package/dist/src/exploration/types.js +1 -0
  35. package/dist/src/handoff/index.d.ts +1 -1
  36. package/dist/src/index.d.ts +15 -1
  37. package/dist/src/index.js +12 -4
  38. package/dist/src/property-contract/analysis-representation-candidates.d.ts +19 -0
  39. package/dist/src/property-contract/analysis-representation-candidates.js +45 -0
  40. package/dist/src/property-contract/classification.d.ts +38 -0
  41. package/dist/src/property-contract/classification.js +84 -0
  42. package/dist/src/property-contract/compact-model-components.d.ts +16 -0
  43. package/dist/src/property-contract/compact-model-components.js +113 -0
  44. package/dist/src/property-contract/content-digest.d.ts +2 -0
  45. package/dist/src/property-contract/content-digest.js +69 -0
  46. package/dist/src/property-contract/decision-protocol.d.ts +45 -0
  47. package/dist/src/property-contract/decision-protocol.js +251 -0
  48. package/dist/src/property-contract/definition-import-rules.d.ts +10 -0
  49. package/dist/src/property-contract/definition-import-rules.js +105 -0
  50. package/dist/src/property-contract/definition-import.d.ts +13 -0
  51. package/dist/src/property-contract/definition-import.js +52 -0
  52. package/dist/src/property-contract/discriminated-union-source.d.ts +17 -0
  53. package/dist/src/property-contract/discriminated-union-source.js +180 -0
  54. package/dist/src/property-contract/import-prerequisites.d.ts +70 -0
  55. package/dist/src/property-contract/import-prerequisites.js +208 -0
  56. package/dist/src/property-contract/index.d.ts +18 -1
  57. package/dist/src/property-contract/index.js +18 -6
  58. package/dist/src/property-contract/logical-source-graph.d.ts +36 -0
  59. package/dist/src/property-contract/logical-source-graph.js +240 -0
  60. package/dist/src/property-contract/mapper-readiness.d.ts +6 -0
  61. package/dist/src/property-contract/mapper-readiness.js +34 -0
  62. package/dist/src/property-contract/model-exploration.d.ts +42 -0
  63. package/dist/src/property-contract/model-exploration.js +94 -0
  64. package/dist/src/property-contract/native-source-region.d.ts +5 -0
  65. package/dist/src/property-contract/native-source-region.js +125 -0
  66. package/dist/src/property-contract/null-handling.d.ts +10 -0
  67. package/dist/src/property-contract/null-handling.js +45 -0
  68. package/dist/src/property-contract/physical-property-import.d.ts +6 -0
  69. package/dist/src/property-contract/physical-property-import.js +55 -0
  70. package/dist/src/property-contract/property-decision.d.ts +14 -0
  71. package/dist/src/property-contract/property-decision.js +155 -0
  72. package/dist/src/property-contract/property-model.d.ts +197 -0
  73. package/dist/src/property-contract/property-model.js +833 -0
  74. package/dist/src/property-contract/representation-plan.d.ts +133 -0
  75. package/dist/src/property-contract/representation-plan.js +756 -0
  76. package/dist/src/property-contract/representation-proposal.d.ts +65 -0
  77. package/dist/src/property-contract/representation-proposal.js +204 -0
  78. package/dist/src/property-contract/resource-link-schema.d.ts +55 -0
  79. package/dist/src/property-contract/resource-link-schema.js +28 -0
  80. package/dist/src/property-contract/source-representation.d.ts +9 -0
  81. package/dist/src/property-contract/source-representation.js +79 -0
  82. package/dist/src/property-contract/target-definition.d.ts +17 -16
  83. package/dist/src/property-contract/target-definition.js +4 -26
  84. package/dist/src/schema-export.d.ts +30 -0
  85. package/dist/src/schema-export.js +285 -0
  86. package/dist/src/shared-source.d.ts +105 -0
  87. package/dist/src/shared-source.js +1 -0
  88. package/dist/src/source-input-association.d.ts +23 -0
  89. package/dist/src/source-input-association.js +52 -0
  90. package/dist/src/sources-api/preview/index.d.ts +37 -3
  91. package/dist/src/sources-api/preview/index.js +39 -1
  92. package/dist/src/sources-api/preview/schema.d.ts +2 -0
  93. package/dist/src/sources-api/preview/schema.js +74 -0
  94. package/package.json +1 -1
@@ -1,6 +1,12 @@
1
1
  import { Ajv } from 'ajv';
2
2
  import { cdfJsonSchema, CDF_SCHEMA_URL } from './schema.js';
3
3
  import { DESIGN_TOKEN_TYPES } from '../dtcg/token-types.js';
4
+ import { CDFComponentSchema } from './types.js';
5
+ import { validateCDFProperty } from './property-validation.js';
6
+ import { validateRepresentationClosure } from './representation-validation.js';
7
+ import { jsonValueIssue } from '../property-contract/json-value.js';
8
+ import { componentDefinitionImportIssues } from '../property-contract/definition-import-rules.js';
9
+ import { validateImportPrerequisites } from '../property-contract/import-prerequisites.js';
4
10
  const ajv = new Ajv({ allErrors: true });
5
11
  const validate = ajv.compile(cdfJsonSchema);
6
12
  const TOKEN_TYPE_SET = new Set(DESIGN_TOKEN_TYPES);
@@ -93,6 +99,9 @@ function entryErrors(node, prefix) {
93
99
  return errors;
94
100
  }
95
101
  export function validateCDF(input) {
102
+ const unsafe = jsonValueIssue(input);
103
+ if (unsafe)
104
+ return { valid: false, errors: [unsafe], components: [], tokens: [] };
96
105
  const valid = validate(input);
97
106
  if (!valid) {
98
107
  const focused = typeof input === 'object' && input !== null ? entryErrors(input, '') : [];
@@ -116,5 +125,26 @@ export function validateCDF(input) {
116
125
  };
117
126
  }
118
127
  const { components, tokens } = parseCDFComponents(file);
119
- return { valid: true, errors: [], components, tokens };
128
+ const errors = [];
129
+ for (const component of components) {
130
+ if (!CDFComponentSchema.safeParse(component.entry).success) {
131
+ errors.push({ path: '/' + component.key, message: 'Invalid complete component metadata or source ownership' });
132
+ continue;
133
+ }
134
+ for (const [key, property] of Object.entries(component.entry.$properties)) {
135
+ for (const issue of validateCDFProperty(property).issues)
136
+ errors.push({ path: `/${component.key}/$properties/${key}${issue.path}`, message: issue.message });
137
+ }
138
+ errors.push(...componentDefinitionImportIssues(component.entry).map(({ path, message }) => ({
139
+ path: `/${component.key}${path}`,
140
+ message,
141
+ })));
142
+ }
143
+ errors.push(...validateRepresentationClosure(components));
144
+ if (!errors.length) {
145
+ const prerequisites = validateImportPrerequisites({ components, tokens });
146
+ if (!prerequisites.valid)
147
+ errors.push(...prerequisites.errors);
148
+ }
149
+ return { valid: !errors.length, errors, components, tokens };
120
150
  }
@@ -1,2 +1,2 @@
1
- export declare const CDF_PROPERTY_TYPES: readonly ["string", "richtext", "number", "media", "link", "enum", "token", "boolean"];
1
+ export declare const CDF_PROPERTY_TYPES: readonly ["string", "richtext", "number", "media", "link", "token", "boolean", "array", "record", "Integer", "DateTime", "Literal", "RichText", "JSON", "ResourceLink", "DiscriminatedUnion"];
2
2
  export declare const CDF_PROPERTY_CATEGORIES: readonly ["content", "design", "state", "unattached"];
@@ -4,8 +4,16 @@ export const CDF_PROPERTY_TYPES = [
4
4
  'number',
5
5
  'media',
6
6
  'link',
7
- 'enum',
8
7
  'token',
9
8
  'boolean',
9
+ 'array',
10
+ 'record',
11
+ 'Integer',
12
+ 'DateTime',
13
+ 'Literal',
14
+ 'RichText',
15
+ 'JSON',
16
+ 'ResourceLink',
17
+ 'DiscriminatedUnion',
10
18
  ];
11
19
  export const CDF_PROPERTY_CATEGORIES = ['content', 'design', 'state', 'unattached'];
@@ -18,11 +18,14 @@ export const configFilePath = () => join(configRoot(), 'config.json');
18
18
  export const runsFilePath = () => join(configRoot(), 'state', 'runs.json');
19
19
  export const debugSessionsDir = () => join(configRoot(), 'debug', 'sessions');
20
20
  export async function readSettings() {
21
+ const path = configFilePath();
21
22
  try {
22
- return JSON.parse(await readFile(configFilePath(), 'utf8'));
23
+ return JSON.parse(await readFile(path, 'utf8'));
23
24
  }
24
- catch {
25
- return {};
25
+ catch (error) {
26
+ if (error.code === 'ENOENT')
27
+ return {};
28
+ throw new Error(`Unable to read settings at ${path}. Check the file contents and permissions.`, { cause: error });
26
29
  }
27
30
  }
28
31
  // Write-then-rename so a crash can never leave a half-written config.
@@ -0,0 +1,10 @@
1
+ export declare const COMPONENT_SCOPES: readonly ["components-1", "components-2", "components-3", "components-4", "components-5", "components-6", "components-7"];
2
+ export declare const CANDIDATE_FREE_SCOPES: readonly ["components-6", "components-7"];
3
+ export declare const DETAIL_SCOPES: readonly ["full-inventory-1", "full-inventory-2", "full-inventory-3"];
4
+ export declare const EXPLORE_SCOPES: readonly ["components-1", "components-2", "components-3", "components-4", "components-5", "components-6", "components-7", "full-inventory-1", "full-inventory-2", "full-inventory-3"];
5
+ export declare const EXPLORE_MAX_ATTEMPTS = 6;
6
+ /** @alias Shared agent-call limit under its general stage name. */
7
+ export declare const AGENT_CALL_MAX_ATTEMPTS = 6;
8
+ export declare const SUPERMAJORITY = 0.75;
9
+ export declare const SLOT_THRESHOLD = 0.6;
10
+ export declare const ABSENT = "__absent__";
@@ -0,0 +1,18 @@
1
+ export const COMPONENT_SCOPES = [
2
+ 'components-1',
3
+ 'components-2',
4
+ 'components-3',
5
+ 'components-4',
6
+ 'components-5',
7
+ 'components-6',
8
+ 'components-7',
9
+ ];
10
+ export const CANDIDATE_FREE_SCOPES = ['components-6', 'components-7'];
11
+ export const DETAIL_SCOPES = ['full-inventory-1', 'full-inventory-2', 'full-inventory-3'];
12
+ export const EXPLORE_SCOPES = [...COMPONENT_SCOPES, ...DETAIL_SCOPES];
13
+ export const EXPLORE_MAX_ATTEMPTS = 6;
14
+ /** @alias Shared agent-call limit under its general stage name. */
15
+ export const AGENT_CALL_MAX_ATTEMPTS = EXPLORE_MAX_ATTEMPTS;
16
+ export const SUPERMAJORITY = 0.75;
17
+ export const SLOT_THRESHOLD = 0.6;
18
+ export const ABSENT = '__absent__';
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
3
+ export * from './schemas.js';
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
3
+ export * from './schemas.js';
@@ -0,0 +1,201 @@
1
+ import { z } from 'zod';
2
+ import { type JsonValue } from '../property-contract/json-value.js';
3
+ import type { CDFPropertyDefinition } from '../cdf/types.js';
4
+ import { type RepresentationProposalDraft } from '../property-contract/representation-proposal.js';
5
+ export declare const VerifyEvidenceSchema: z.ZodObject<{
6
+ source: z.ZodString;
7
+ line: z.ZodString;
8
+ quote: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export declare const SlotRestrictionSchema: z.ZodObject<{
11
+ kind: z.ZodEnum<{
12
+ declared: "declared";
13
+ enforced: "enforced";
14
+ }>;
15
+ applicable: z.ZodBoolean;
16
+ evidence: z.ZodArray<z.ZodObject<{
17
+ source: z.ZodString;
18
+ line: z.ZodString;
19
+ quote: z.ZodString;
20
+ }, z.core.$strip>>;
21
+ }, z.core.$strip>;
22
+ export declare const ExplorePropReportSchema: z.ZodObject<{
23
+ name: z.ZodString;
24
+ category: z.ZodOptional<z.ZodEnum<{
25
+ content: "content";
26
+ design: "design";
27
+ state: "state";
28
+ unattached: "unattached";
29
+ }>>;
30
+ type: z.ZodOptional<z.ZodString>;
31
+ definition: z.ZodOptional<z.ZodCustom<CDFPropertyDefinition, CDFPropertyDefinition>>;
32
+ values: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
33
+ observedValues: z.ZodOptional<z.ZodArray<z.ZodCustom<JsonValue, JsonValue>>>;
34
+ tokenKind: z.ZodOptional<z.ZodString>;
35
+ tokenPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ required: z.ZodOptional<z.ZodBoolean>;
37
+ default: z.ZodOptional<z.ZodUnknown>;
38
+ description: z.ZodOptional<z.ZodString>;
39
+ reasoning: z.ZodOptional<z.ZodString>;
40
+ representationProposal: z.ZodOptional<z.ZodCustom<RepresentationProposalDraft, RepresentationProposalDraft>>;
41
+ }, z.core.$strict>;
42
+ export declare const ExploreSlotEvidenceSchema: z.ZodObject<{
43
+ name: z.ZodString;
44
+ sourceInput: z.ZodOptional<z.ZodCustom<{
45
+ schemaVersion: 1;
46
+ componentId: string;
47
+ componentDeclarationId: string;
48
+ rootSymbolId: string;
49
+ inputName: string;
50
+ inputPath: string[];
51
+ }, {
52
+ schemaVersion: 1;
53
+ componentId: string;
54
+ componentDeclarationId: string;
55
+ rootSymbolId: string;
56
+ inputName: string;
57
+ inputPath: string[];
58
+ }>>;
59
+ isRealSlot: z.ZodBoolean;
60
+ allowedComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
+ evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
+ required: z.ZodOptional<z.ZodBoolean>;
63
+ reasoning: z.ZodOptional<z.ZodString>;
64
+ restriction: z.ZodOptional<z.ZodObject<{
65
+ kind: z.ZodEnum<{
66
+ declared: "declared";
67
+ enforced: "enforced";
68
+ }>;
69
+ applicable: z.ZodBoolean;
70
+ evidence: z.ZodArray<z.ZodObject<{
71
+ source: z.ZodString;
72
+ line: z.ZodString;
73
+ quote: z.ZodString;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>>;
76
+ }, z.core.$strip>;
77
+ export declare const ExploreCompanionSchema: z.ZodObject<{
78
+ agentRole: z.ZodEnum<{
79
+ "components-1": "components-1";
80
+ "components-2": "components-2";
81
+ "components-3": "components-3";
82
+ "components-4": "components-4";
83
+ "components-5": "components-5";
84
+ "components-6": "components-6";
85
+ "components-7": "components-7";
86
+ "full-inventory-1": "full-inventory-1";
87
+ "full-inventory-2": "full-inventory-2";
88
+ "full-inventory-3": "full-inventory-3";
89
+ }>;
90
+ components: z.ZodArray<z.ZodObject<{
91
+ name: z.ZodString;
92
+ source: z.ZodString;
93
+ componentId: z.ZodOptional<z.ZodString>;
94
+ included: z.ZodOptional<z.ZodBoolean>;
95
+ inclusionReasoning: z.ZodOptional<z.ZodString>;
96
+ modelingNotes: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
+ props: z.ZodOptional<z.ZodArray<z.ZodObject<{
98
+ name: z.ZodString;
99
+ category: z.ZodOptional<z.ZodEnum<{
100
+ content: "content";
101
+ design: "design";
102
+ state: "state";
103
+ unattached: "unattached";
104
+ }>>;
105
+ type: z.ZodOptional<z.ZodString>;
106
+ definition: z.ZodOptional<z.ZodCustom<CDFPropertyDefinition, CDFPropertyDefinition>>;
107
+ values: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
108
+ observedValues: z.ZodOptional<z.ZodArray<z.ZodCustom<JsonValue, JsonValue>>>;
109
+ tokenKind: z.ZodOptional<z.ZodString>;
110
+ tokenPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
+ required: z.ZodOptional<z.ZodBoolean>;
112
+ default: z.ZodOptional<z.ZodUnknown>;
113
+ description: z.ZodOptional<z.ZodString>;
114
+ reasoning: z.ZodOptional<z.ZodString>;
115
+ representationProposal: z.ZodOptional<z.ZodCustom<RepresentationProposalDraft, RepresentationProposalDraft>>;
116
+ }, z.core.$strict>>>;
117
+ slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
118
+ name: z.ZodString;
119
+ sourceInput: z.ZodOptional<z.ZodCustom<{
120
+ schemaVersion: 1;
121
+ componentId: string;
122
+ componentDeclarationId: string;
123
+ rootSymbolId: string;
124
+ inputName: string;
125
+ inputPath: string[];
126
+ }, {
127
+ schemaVersion: 1;
128
+ componentId: string;
129
+ componentDeclarationId: string;
130
+ rootSymbolId: string;
131
+ inputName: string;
132
+ inputPath: string[];
133
+ }>>;
134
+ isRealSlot: z.ZodBoolean;
135
+ allowedComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
136
+ evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
137
+ required: z.ZodOptional<z.ZodBoolean>;
138
+ reasoning: z.ZodOptional<z.ZodString>;
139
+ restriction: z.ZodOptional<z.ZodObject<{
140
+ kind: z.ZodEnum<{
141
+ declared: "declared";
142
+ enforced: "enforced";
143
+ }>;
144
+ applicable: z.ZodBoolean;
145
+ evidence: z.ZodArray<z.ZodObject<{
146
+ source: z.ZodString;
147
+ line: z.ZodString;
148
+ quote: z.ZodString;
149
+ }, z.core.$strip>>;
150
+ }, z.core.$strip>>;
151
+ }, z.core.$strip>>>;
152
+ }, z.core.$strip>>;
153
+ rawTokenReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
154
+ tokenPath: z.ZodString;
155
+ file: z.ZodString;
156
+ line: z.ZodNumber;
157
+ property: z.ZodString;
158
+ }, z.core.$strip>>>;
159
+ }, z.core.$strip>;
160
+ export declare const TierHypothesisSchema: z.ZodObject<{
161
+ disagreementIds: z.ZodArray<z.ZodString>;
162
+ hypothesis: z.ZodString;
163
+ tier: z.ZodEnum<{
164
+ factual: "factual";
165
+ interpretive: "interpretive";
166
+ }>;
167
+ tierReason: z.ZodString;
168
+ gatedOn: z.ZodOptional<z.ZodLiteral<"category">>;
169
+ }, z.core.$strip>;
170
+ export declare const VerifiedItemSchema: z.ZodObject<{
171
+ itemId: z.ZodString;
172
+ component: z.ZodString;
173
+ source: z.ZodString;
174
+ outcome: z.ZodEnum<{
175
+ confirmed: "confirmed";
176
+ resolved: "resolved";
177
+ conflicting: "conflicting";
178
+ }>;
179
+ resolved: z.ZodOptional<z.ZodArray<z.ZodObject<{
180
+ path: z.ZodString;
181
+ value: z.ZodUnknown;
182
+ }, z.core.$strip>>>;
183
+ evidence: z.ZodArray<z.ZodObject<{
184
+ source: z.ZodString;
185
+ line: z.ZodString;
186
+ quote: z.ZodString;
187
+ }, z.core.$strip>>;
188
+ reason: z.ZodString;
189
+ }, z.core.$strip>;
190
+ export declare const EvidenceCheckSchema: z.ZodObject<{
191
+ checkId: z.ZodString;
192
+ itemId: z.ZodString;
193
+ component: z.ZodString;
194
+ source: z.ZodString;
195
+ verdict: z.ZodEnum<{
196
+ supports: "supports";
197
+ "does-not-support": "does-not-support";
198
+ unclear: "unclear";
199
+ }>;
200
+ reason: z.ZodString;
201
+ }, z.core.$strip>;
@@ -0,0 +1,126 @@
1
+ import { z } from 'zod';
2
+ import { EXPLORE_SCOPES } from './constants.js';
3
+ import { SourceInputAssociationSchema } from '../source-input-association.js';
4
+ import { validatePropertyDecisionMetadata } from '../property-contract/property-decision.js';
5
+ import { jsonValueIssue, jsonEqual, own } from '../property-contract/json-value.js';
6
+ import { validateCDFProperty, containsCDFDefinitionType, cdfToTarget } from '../cdf/property-validation.js';
7
+ import { validateTargetValue } from '../property-contract/target-definition.js';
8
+ import { validateProposalDraft, } from '../property-contract/representation-proposal.js';
9
+ export const VerifyEvidenceSchema = z.object({
10
+ source: z.string().min(1),
11
+ line: z.string().min(1),
12
+ quote: z.string().min(1),
13
+ });
14
+ export const SlotRestrictionSchema = z.object({
15
+ kind: z.enum(['declared', 'enforced']),
16
+ applicable: z.boolean(),
17
+ evidence: z.array(VerifyEvidenceSchema).min(1),
18
+ });
19
+ export const ExplorePropReportSchema = z
20
+ .object({
21
+ name: z.string().refine((value) => value.trim().length > 0),
22
+ category: z.enum(['content', 'design', 'state', 'unattached']).optional(),
23
+ type: z.string().optional(),
24
+ definition: z.custom((value) => validateCDFProperty(value).valid).optional(),
25
+ values: z
26
+ .array(z.union([z.string(), z.number(), z.boolean()]))
27
+ .nonempty()
28
+ .optional(),
29
+ observedValues: z.array(z.custom((value) => !jsonValueIssue(value))).optional(),
30
+ tokenKind: z.string().optional(),
31
+ tokenPaths: z.array(z.string()).optional(),
32
+ required: z.boolean().optional(),
33
+ default: z.unknown().optional(),
34
+ description: z.string().optional(),
35
+ reasoning: z.string().optional(),
36
+ representationProposal: z
37
+ .custom((value) => validateProposalDraft(value).length === 0)
38
+ .optional(),
39
+ })
40
+ .strict()
41
+ .superRefine((report, ctx) => {
42
+ if (report.type === 'DiscriminatedUnion' || report.definition !== undefined) {
43
+ const definition = report.definition;
44
+ if (!definition ||
45
+ !validateCDFProperty(definition).valid ||
46
+ !containsCDFDefinitionType(definition, 'DiscriminatedUnion') ||
47
+ definition.$type !== report.type ||
48
+ definition.$category !== report.category ||
49
+ report.category !== 'content' ||
50
+ ['values', 'tokenKind', 'tokenPaths', 'representationProposal'].some((key) => own(report, key)) ||
51
+ (own(report, 'required') && report.required !== (definition.$required ?? false)) ||
52
+ (own(report, 'description') && report.description !== definition.$description) ||
53
+ (own(report, 'default') &&
54
+ (validateTargetValue(cdfToTarget(definition), report.default).length ||
55
+ (own(definition, '$default') && !jsonEqual(report.default, definition.$default)))))
56
+ ctx.addIssue({
57
+ code: 'custom',
58
+ path: ['definition'],
59
+ message: 'Union decisions require one complete consistent content definition',
60
+ });
61
+ }
62
+ for (const issue of validatePropertyDecisionMetadata(report, {
63
+ definition: report.definition,
64
+ representationProposal: report.representationProposal,
65
+ }))
66
+ ctx.addIssue({
67
+ code: 'custom',
68
+ path: issue.path
69
+ .split('/')
70
+ .slice(1)
71
+ .map((key) => key.replace(/~1/g, '/').replace(/~0/g, '~')),
72
+ message: issue.message,
73
+ });
74
+ });
75
+ export const ExploreSlotEvidenceSchema = z.object({
76
+ name: z.string().refine((value) => value.trim().length > 0),
77
+ sourceInput: z
78
+ .custom((value) => SourceInputAssociationSchema.safeParse(value).success)
79
+ .optional(),
80
+ isRealSlot: z.boolean(),
81
+ allowedComponents: z.array(z.string().refine((value) => value.trim().length > 0)).optional(),
82
+ evidence: z.array(z.string().refine((value) => value.trim().length > 0)).optional(),
83
+ required: z.boolean().optional(),
84
+ reasoning: z.string().optional(),
85
+ restriction: SlotRestrictionSchema.optional(),
86
+ });
87
+ export const ExploreCompanionSchema = z.object({
88
+ agentRole: z.enum(EXPLORE_SCOPES),
89
+ components: z.array(z.object({
90
+ name: z.string().refine((value) => value.trim().length > 0),
91
+ source: z.string().refine((value) => value.trim().length > 0),
92
+ componentId: z.string().optional(),
93
+ included: z.boolean().optional(),
94
+ inclusionReasoning: z.string().optional(),
95
+ modelingNotes: z.array(z.string().refine((value) => value.trim().length > 0)).optional(),
96
+ props: z.array(ExplorePropReportSchema).optional(),
97
+ slots: z.array(ExploreSlotEvidenceSchema).optional(),
98
+ })),
99
+ rawTokenReferences: z
100
+ .array(z.object({ tokenPath: z.string(), file: z.string(), line: z.number().int().positive(), property: z.string() }))
101
+ .optional(),
102
+ });
103
+ export const TierHypothesisSchema = z.object({
104
+ disagreementIds: z.array(z.string().min(1)).min(1),
105
+ hypothesis: z.string(),
106
+ tier: z.enum(['factual', 'interpretive']),
107
+ tierReason: z.string(),
108
+ gatedOn: z.literal('category').optional(),
109
+ });
110
+ export const VerifiedItemSchema = z.object({
111
+ itemId: z.string().min(1),
112
+ component: z.string().min(1),
113
+ source: z.string().min(1),
114
+ outcome: z.enum(['confirmed', 'resolved', 'conflicting']),
115
+ resolved: z.array(z.object({ path: z.string().min(1), value: z.unknown() })).optional(),
116
+ evidence: z.array(VerifyEvidenceSchema),
117
+ reason: z.string(),
118
+ });
119
+ export const EvidenceCheckSchema = z.object({
120
+ checkId: z.string().min(1),
121
+ itemId: z.string().min(1),
122
+ component: z.string().min(1),
123
+ source: z.string().min(1),
124
+ verdict: z.enum(['supports', 'does-not-support', 'unclear']),
125
+ reason: z.string(),
126
+ });