@sentropic/track 0.98.9 → 0.98.10

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 (44) hide show
  1. package/dist/focus-vendor/index.d.ts +1 -1
  2. package/dist/focus-vendor/index.js +1 -1
  3. package/dist/focus-vendor/index.js.map +1 -1
  4. package/dist/focus-vendor/model.d.ts +1 -0
  5. package/dist/focus-vendor/model.d.ts.map +1 -1
  6. package/dist/focus-vendor/model.js +3 -2
  7. package/dist/focus-vendor/model.js.map +1 -1
  8. package/dist/focus-vendor/registry/definitions.d.ts.map +1 -1
  9. package/dist/focus-vendor/registry/definitions.js +44 -17
  10. package/dist/focus-vendor/registry/definitions.js.map +1 -1
  11. package/dist/focus-vendor/registry/entries.v1.json +45 -6
  12. package/dist/focus-vendor/render/evidence.d.ts +10 -0
  13. package/dist/focus-vendor/render/evidence.d.ts.map +1 -1
  14. package/dist/focus-vendor/render/evidence.js +60 -7
  15. package/dist/focus-vendor/render/evidence.js.map +1 -1
  16. package/dist/focus-vendor/render/html.d.ts.map +1 -1
  17. package/dist/focus-vendor/render/html.js +42 -6
  18. package/dist/focus-vendor/render/html.js.map +1 -1
  19. package/dist/focus-vendor/render/markdown-table.d.ts +5 -0
  20. package/dist/focus-vendor/render/markdown-table.d.ts.map +1 -0
  21. package/dist/focus-vendor/render/markdown-table.js +9 -0
  22. package/dist/focus-vendor/render/markdown-table.js.map +1 -0
  23. package/dist/focus-vendor/render/md.d.ts.map +1 -1
  24. package/dist/focus-vendor/render/md.js +34 -5
  25. package/dist/focus-vendor/render/md.js.map +1 -1
  26. package/dist/focus-vendor/render/presentation.d.ts +17 -0
  27. package/dist/focus-vendor/render/presentation.d.ts.map +1 -1
  28. package/dist/focus-vendor/render/presentation.js +2 -2
  29. package/dist/focus-vendor/render/presentation.js.map +1 -1
  30. package/dist/focus-vendor/render/terminal.d.ts.map +1 -1
  31. package/dist/focus-vendor/render/terminal.js +28 -8
  32. package/dist/focus-vendor/render/terminal.js.map +1 -1
  33. package/dist/focus-vendor/track/index.js +3 -3
  34. package/dist/focus-vendor/track/index.js.map +1 -1
  35. package/dist/focus-vendor/validation/index.d.ts +336 -2
  36. package/dist/focus-vendor/validation/index.d.ts.map +1 -1
  37. package/dist/focus-vendor/validation/index.js +212 -14
  38. package/dist/focus-vendor/validation/index.js.map +1 -1
  39. package/dist/focus-vendor/validation/readability.d.ts +9 -1
  40. package/dist/focus-vendor/validation/readability.d.ts.map +1 -1
  41. package/dist/focus-vendor/validation/readability.js +232 -14
  42. package/dist/focus-vendor/validation/readability.js.map +1 -1
  43. package/package.json +1 -1
  44. package/registry/entries.v1.json +1 -1
@@ -2,6 +2,12 @@
2
2
  export const DOSSIER_SCHEMA_ID: "urn:sentropic:focus:DecisionDossierDocument:1.0.0";
3
3
  /** Version of the dossier schema, independent of the package version. */
4
4
  export const DOSSIER_SCHEMA_VERSION: "1.0.0";
5
+ /** Stable v2.0.0 schema ID preserved for compatibility. */
6
+ export const DOSSIER_V2_SCHEMA_ID: "urn:sentropic:focus:DecisionDossierDocument:2.0.0";
7
+ /** Additive v1.1.0 schema ID (diagram by reference, section inputs, completion criterion). */
8
+ export const DOSSIER_V1_1_SCHEMA_ID: "urn:sentropic:focus:DecisionDossierDocument:1.1.0";
9
+ /** Additive v2.1.0 schema ID (v2 embedded evidence + 1.1.0 section/diagram extensions). */
10
+ export const DOSSIER_V2_1_SCHEMA_ID: "urn:sentropic:focus:DecisionDossierDocument:2.1.0";
5
11
  /** Thrown by {@link assertDecisionDossierDocument} on an invalid dossier. */
6
12
  export class DecisionDossierValidationError extends Error {
7
13
  constructor(issues: any);
@@ -115,7 +121,7 @@ export function assertDecisionDossierDocument(value: any): import("../model.js")
115
121
  };
116
122
  amendmentTrace: any[];
117
123
  } | undefined;
118
- export function validateDecisionDossierForPresentation(value: any): {
124
+ export function validateDecisionDossierForPresentation(value: any, options: any): {
119
125
  readonly ok: false;
120
126
  readonly issues: readonly import("./index.js").ValidationIssue[];
121
127
  } | {
@@ -156,7 +162,335 @@ export function validateDecisionDossierForPresentation(value: any): {
156
162
  readonly ok: true;
157
163
  readonly value: import("../model.js").DecisionDossierDocumentV2;
158
164
  };
159
- export function assertDecisionDossierForPresentation(value: any): import("../model.js").DecisionDossierDocumentV2 | {
165
+ export function assertDecisionDossierForPresentation(value: any, options: any): import("../model.js").DecisionDossierDocumentV2 | {
166
+ readability?: {
167
+ glossary?: any[];
168
+ readingBudgetMinutes?: number;
169
+ stakesLevel?: any;
170
+ stakes?: string;
171
+ noOwnerRequest?: boolean;
172
+ ownerRequestQuote?: string;
173
+ };
174
+ ref: string;
175
+ subject: string;
176
+ title: string;
177
+ hash: string;
178
+ cursor: string;
179
+ sections: any[];
180
+ interactions: any[];
181
+ provenance: {
182
+ comprehensionEvidence?: {
183
+ signature?: string;
184
+ subject: any;
185
+ dossierHash: any;
186
+ };
187
+ source: any;
188
+ readAt: any;
189
+ };
190
+ amendmentTrace: any[];
191
+ } | undefined;
192
+ /** A separate schema identity: the four published decision schemas remain frozen. */
193
+ export const REPORT_SCHEMA_ID: "urn:sentropic:focus:ReportDocument:1.0.0";
194
+ export function validateFocusDocument(value: any): {
195
+ readonly ok: false;
196
+ readonly issues: readonly import("./index.js").ValidationIssue[];
197
+ } | {
198
+ ok: boolean;
199
+ issues: any[];
200
+ value?: never;
201
+ } | {
202
+ ok: boolean;
203
+ value: {
204
+ readability?: {
205
+ glossary?: any[];
206
+ readingBudgetMinutes?: number;
207
+ stakesLevel?: any;
208
+ stakes?: string;
209
+ noOwnerRequest?: boolean;
210
+ ownerRequestQuote?: string;
211
+ };
212
+ ref: string;
213
+ subject: string;
214
+ title: string;
215
+ hash: string;
216
+ cursor: string;
217
+ sections: any[];
218
+ interactions: any[];
219
+ provenance: {
220
+ comprehensionEvidence?: {
221
+ signature?: string;
222
+ subject: any;
223
+ dossierHash: any;
224
+ };
225
+ source: any;
226
+ readAt: any;
227
+ };
228
+ amendmentTrace: any[];
229
+ };
230
+ issues?: never;
231
+ } | {
232
+ readonly ok: true;
233
+ readonly value: import("../model.js").DecisionDossierDocumentV2;
234
+ } | {
235
+ ok: boolean;
236
+ value: {
237
+ kind: string;
238
+ } | {
239
+ kind: string;
240
+ schemaVersion: 2;
241
+ sources: readonly import("../model.js").EvidenceSource[];
242
+ citations: readonly import("../model.js").EvidenceCitation[];
243
+ evidenceGroups: readonly import("../model.js").EvidenceGroup[];
244
+ annexes: readonly import("../model.js").EvidenceAnnex[];
245
+ ref: import("../model.js").FocusRef;
246
+ subject: string;
247
+ title: string;
248
+ hash: string;
249
+ cursor: string;
250
+ sections: readonly import("../model.js").FocusNode[];
251
+ interactions: readonly import("../model.js").Affordance[];
252
+ provenance: import("../model.js").FocusProvenance;
253
+ amendmentTrace: readonly import("../model.js").AmendmentStep[];
254
+ readability?: import("../model.js").DossierReadability;
255
+ } | {
256
+ kind: string;
257
+ readability?: {
258
+ glossary?: any[];
259
+ readingBudgetMinutes?: number;
260
+ stakesLevel?: any;
261
+ stakes?: string;
262
+ noOwnerRequest?: boolean;
263
+ ownerRequestQuote?: string;
264
+ };
265
+ ref: string;
266
+ subject: string;
267
+ title: string;
268
+ hash: string;
269
+ cursor: string;
270
+ sections: any[];
271
+ interactions: any[];
272
+ provenance: {
273
+ comprehensionEvidence?: {
274
+ signature?: string;
275
+ subject: any;
276
+ dossierHash: any;
277
+ };
278
+ source: any;
279
+ readAt: any;
280
+ };
281
+ amendmentTrace: any[];
282
+ };
283
+ };
284
+ export function assertFocusDocument(value: any): import("../model.js").DecisionDossierDocumentV2 | {
285
+ readability?: {
286
+ glossary?: any[];
287
+ readingBudgetMinutes?: number;
288
+ stakesLevel?: any;
289
+ stakes?: string;
290
+ noOwnerRequest?: boolean;
291
+ ownerRequestQuote?: string;
292
+ };
293
+ ref: string;
294
+ subject: string;
295
+ title: string;
296
+ hash: string;
297
+ cursor: string;
298
+ sections: any[];
299
+ interactions: any[];
300
+ provenance: {
301
+ comprehensionEvidence?: {
302
+ signature?: string;
303
+ subject: any;
304
+ dossierHash: any;
305
+ };
306
+ source: any;
307
+ readAt: any;
308
+ };
309
+ amendmentTrace: any[];
310
+ } | {
311
+ kind: string;
312
+ } | {
313
+ kind: string;
314
+ schemaVersion: 2;
315
+ sources: readonly import("../model.js").EvidenceSource[];
316
+ citations: readonly import("../model.js").EvidenceCitation[];
317
+ evidenceGroups: readonly import("../model.js").EvidenceGroup[];
318
+ annexes: readonly import("../model.js").EvidenceAnnex[];
319
+ ref: import("../model.js").FocusRef;
320
+ subject: string;
321
+ title: string;
322
+ hash: string;
323
+ cursor: string;
324
+ sections: readonly import("../model.js").FocusNode[];
325
+ interactions: readonly import("../model.js").Affordance[];
326
+ provenance: import("../model.js").FocusProvenance;
327
+ amendmentTrace: readonly import("../model.js").AmendmentStep[];
328
+ readability?: import("../model.js").DossierReadability;
329
+ } | {
330
+ kind: string;
331
+ readability?: {
332
+ glossary?: any[];
333
+ readingBudgetMinutes?: number;
334
+ stakesLevel?: any;
335
+ stakes?: string;
336
+ noOwnerRequest?: boolean;
337
+ ownerRequestQuote?: string;
338
+ };
339
+ ref: string;
340
+ subject: string;
341
+ title: string;
342
+ hash: string;
343
+ cursor: string;
344
+ sections: any[];
345
+ interactions: any[];
346
+ provenance: {
347
+ comprehensionEvidence?: {
348
+ signature?: string;
349
+ subject: any;
350
+ dossierHash: any;
351
+ };
352
+ source: any;
353
+ readAt: any;
354
+ };
355
+ amendmentTrace: any[];
356
+ } | undefined;
357
+ export function validateFocusForPresentation(value: any): {
358
+ readonly ok: false;
359
+ readonly issues: readonly import("./index.js").ValidationIssue[];
360
+ } | {
361
+ ok: boolean;
362
+ issues: any[];
363
+ value?: never;
364
+ } | {
365
+ ok: boolean;
366
+ value: {
367
+ readability?: {
368
+ glossary?: any[];
369
+ readingBudgetMinutes?: number;
370
+ stakesLevel?: any;
371
+ stakes?: string;
372
+ noOwnerRequest?: boolean;
373
+ ownerRequestQuote?: string;
374
+ };
375
+ ref: string;
376
+ subject: string;
377
+ title: string;
378
+ hash: string;
379
+ cursor: string;
380
+ sections: any[];
381
+ interactions: any[];
382
+ provenance: {
383
+ comprehensionEvidence?: {
384
+ signature?: string;
385
+ subject: any;
386
+ dossierHash: any;
387
+ };
388
+ source: any;
389
+ readAt: any;
390
+ };
391
+ amendmentTrace: any[];
392
+ };
393
+ issues?: never;
394
+ } | {
395
+ readonly ok: true;
396
+ readonly value: import("../model.js").DecisionDossierDocumentV2;
397
+ } | {
398
+ ok: boolean;
399
+ value: {
400
+ kind: string;
401
+ } | {
402
+ kind: string;
403
+ schemaVersion: 2;
404
+ sources: readonly import("../model.js").EvidenceSource[];
405
+ citations: readonly import("../model.js").EvidenceCitation[];
406
+ evidenceGroups: readonly import("../model.js").EvidenceGroup[];
407
+ annexes: readonly import("../model.js").EvidenceAnnex[];
408
+ ref: import("../model.js").FocusRef;
409
+ subject: string;
410
+ title: string;
411
+ hash: string;
412
+ cursor: string;
413
+ sections: readonly import("../model.js").FocusNode[];
414
+ interactions: readonly import("../model.js").Affordance[];
415
+ provenance: import("../model.js").FocusProvenance;
416
+ amendmentTrace: readonly import("../model.js").AmendmentStep[];
417
+ readability?: import("../model.js").DossierReadability;
418
+ } | {
419
+ kind: string;
420
+ readability?: {
421
+ glossary?: any[];
422
+ readingBudgetMinutes?: number;
423
+ stakesLevel?: any;
424
+ stakes?: string;
425
+ noOwnerRequest?: boolean;
426
+ ownerRequestQuote?: string;
427
+ };
428
+ ref: string;
429
+ subject: string;
430
+ title: string;
431
+ hash: string;
432
+ cursor: string;
433
+ sections: any[];
434
+ interactions: any[];
435
+ provenance: {
436
+ comprehensionEvidence?: {
437
+ signature?: string;
438
+ subject: any;
439
+ dossierHash: any;
440
+ };
441
+ source: any;
442
+ readAt: any;
443
+ };
444
+ amendmentTrace: any[];
445
+ };
446
+ };
447
+ export function assertFocusForPresentation(value: any): import("../model.js").DecisionDossierDocumentV2 | {
448
+ readability?: {
449
+ glossary?: any[];
450
+ readingBudgetMinutes?: number;
451
+ stakesLevel?: any;
452
+ stakes?: string;
453
+ noOwnerRequest?: boolean;
454
+ ownerRequestQuote?: string;
455
+ };
456
+ ref: string;
457
+ subject: string;
458
+ title: string;
459
+ hash: string;
460
+ cursor: string;
461
+ sections: any[];
462
+ interactions: any[];
463
+ provenance: {
464
+ comprehensionEvidence?: {
465
+ signature?: string;
466
+ subject: any;
467
+ dossierHash: any;
468
+ };
469
+ source: any;
470
+ readAt: any;
471
+ };
472
+ amendmentTrace: any[];
473
+ } | {
474
+ kind: string;
475
+ } | {
476
+ kind: string;
477
+ schemaVersion: 2;
478
+ sources: readonly import("../model.js").EvidenceSource[];
479
+ citations: readonly import("../model.js").EvidenceCitation[];
480
+ evidenceGroups: readonly import("../model.js").EvidenceGroup[];
481
+ annexes: readonly import("../model.js").EvidenceAnnex[];
482
+ ref: import("../model.js").FocusRef;
483
+ subject: string;
484
+ title: string;
485
+ hash: string;
486
+ cursor: string;
487
+ sections: readonly import("../model.js").FocusNode[];
488
+ interactions: readonly import("../model.js").Affordance[];
489
+ provenance: import("../model.js").FocusProvenance;
490
+ amendmentTrace: readonly import("../model.js").AmendmentStep[];
491
+ readability?: import("../model.js").DossierReadability;
492
+ } | {
493
+ kind: string;
160
494
  readability?: {
161
495
  glossary?: any[];
162
496
  readingBudgetMinutes?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/focus-vendor/validation/index.js"],"names":[],"mappings":"AAsBA,uEAAuE;AACvE,gCAAiC,mDAAmD,CAAC;AACrF,yEAAyE;AACzE,qCAAsC,OAAO,CAAC;AAC9C,6EAA6E;AAC7E;IAEI,yBAMC;IAPD,YAAO;CAQV;AAoXM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2FAON;AAEM;;;;IAiDN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/focus-vendor/validation/index.js"],"names":[],"mappings":"AAsBA,uEAAuE;AACvE,gCAAiC,mDAAmD,CAAC;AACrF,yEAAyE;AACzE,qCAAsC,OAAO,CAAC;AAC9C,2DAA2D;AAC3D,mCAAoC,mDAAmD,CAAC;AACxF,8FAA8F;AAC9F,qCAAsC,mDAAmD,CAAC;AAC1F,2FAA2F;AAC3F,qCAAsC,mDAAmD,CAAC;AAC1F,6EAA6E;AAC7E;IAEI,yBAMC;IAPD,YAAO;CAQV;AAieM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2FAON;AAEM;;;;IAyFN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMN;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN;AACD,qFAAqF;AACrF,+BAAgC,0CAA0C,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBN;AACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN;AACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMN;AACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKN"}
@@ -24,6 +24,12 @@ export { READABILITY_LIMITS, READABILITY_BUDGETS, validateDecisionDossierReadabi
24
24
  export const DOSSIER_SCHEMA_ID = "urn:sentropic:focus:DecisionDossierDocument:1.0.0";
25
25
  /** Version of the dossier schema, independent of the package version. */
26
26
  export const DOSSIER_SCHEMA_VERSION = "1.0.0";
27
+ /** Stable v2.0.0 schema ID preserved for compatibility. */
28
+ export const DOSSIER_V2_SCHEMA_ID = "urn:sentropic:focus:DecisionDossierDocument:2.0.0";
29
+ /** Additive v1.1.0 schema ID (diagram by reference, section inputs, completion criterion). */
30
+ export const DOSSIER_V1_1_SCHEMA_ID = "urn:sentropic:focus:DecisionDossierDocument:1.1.0";
31
+ /** Additive v2.1.0 schema ID (v2 embedded evidence + 1.1.0 section/diagram extensions). */
32
+ export const DOSSIER_V2_1_SCHEMA_ID = "urn:sentropic:focus:DecisionDossierDocument:2.1.0";
27
33
  /** Thrown by {@link assertDecisionDossierDocument} on an invalid dossier. */
28
34
  export class DecisionDossierValidationError extends Error {
29
35
  issues;
@@ -119,6 +125,44 @@ const checkAmendmentStep = (value, path, issues) => {
119
125
  return undefined;
120
126
  return { at: step["at"], author: step["author"], summary: step["summary"] };
121
127
  };
128
+ const SOURCE_REF_PATTERN = /^[A-Za-z][A-Za-z0-9+.-]*:\S+$/;
129
+ const RENDER_COMPONENT_PATTERN = /^[A-Za-z][A-Za-z0-9-]*$/;
130
+ const checkNonBlank = (value, path, issues) => {
131
+ if (typeof value === "string" && value.trim().length === 0) {
132
+ issues.push(issue(path, "invalid_type", "expected a non-blank string"));
133
+ }
134
+ };
135
+ const checkSectionInput = (value, path, issues) => {
136
+ const start = issues.length;
137
+ const input = checkClosedObject(value, path, ["ref", "kind", "label"], ["ref", "kind"], ["ref", "kind", "label"], issues);
138
+ if (input === undefined)
139
+ return undefined;
140
+ checkNonBlank(input["ref"], `${path}.ref`, issues);
141
+ checkNonBlank(input["kind"], `${path}.kind`, issues);
142
+ checkNonBlank(input["label"], `${path}.label`, issues);
143
+ if (issues.length !== start)
144
+ return undefined;
145
+ return {
146
+ ref: input["ref"],
147
+ kind: input["kind"],
148
+ ...(typeof input["label"] === "string" ? { label: input["label"] } : {}),
149
+ };
150
+ };
151
+ const checkSectionInputs = (value, path, issues) => {
152
+ if (value === undefined)
153
+ return undefined;
154
+ if (!Array.isArray(value)) {
155
+ issues.push(issue(path, "invalid_type", "expected an array"));
156
+ return undefined;
157
+ }
158
+ const inputs = [];
159
+ value.forEach((entry, index) => {
160
+ const checked = checkSectionInput(entry, `${path}[${index}]`, issues);
161
+ if (checked !== undefined)
162
+ inputs.push(checked);
163
+ });
164
+ return inputs;
165
+ };
122
166
  const checkSectionNode = (value, path, issues) => {
123
167
  if (!isRecord(value)) {
124
168
  issues.push(issue(path, "invalid_type", "expected an object"));
@@ -132,19 +176,33 @@ const checkSectionNode = (value, path, issues) => {
132
176
  const start = issues.length;
133
177
  switch (kind) {
134
178
  case "prose": {
135
- const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "markdown", "questionId"], ["kind", "id", "targetRef", "markdown"], ["id", "targetRef", "markdown", "questionId"], issues);
136
- if (node === undefined || issues.length !== start)
179
+ const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "markdown", "questionId", "inputs", "completionCriterion"], ["kind", "id", "targetRef", "markdown"], ["id", "targetRef", "markdown", "questionId", "completionCriterion"], issues);
180
+ if (node === undefined)
137
181
  return undefined;
138
- return { kind: "prose", id: node["id"], targetRef: node["targetRef"], markdown: node["markdown"], ...(typeof node["questionId"] === "string" ? { questionId: node["questionId"] } : {}) };
182
+ const inputs = checkSectionInputs(node["inputs"], `${path}.inputs`, issues);
183
+ checkNonBlank(node["completionCriterion"], `${path}.completionCriterion`, issues);
184
+ if (issues.length !== start)
185
+ return undefined;
186
+ return {
187
+ kind: "prose",
188
+ id: node["id"],
189
+ targetRef: node["targetRef"],
190
+ markdown: node["markdown"],
191
+ ...(typeof node["questionId"] === "string" ? { questionId: node["questionId"] } : {}),
192
+ ...(inputs !== undefined ? { inputs } : {}),
193
+ ...(typeof node["completionCriterion"] === "string" ? { completionCriterion: node["completionCriterion"] } : {}),
194
+ };
139
195
  }
140
196
  case "question": {
141
- const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "question", "recommendedAnswer", "answer", "state", "context", "readingTimeMinutes", "recommendedOptionId"], ["kind", "id", "targetRef", "question", "state"], ["id", "targetRef", "question", "recommendedAnswer", "answer", "context", "recommendedOptionId"], issues);
197
+ const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "question", "recommendedAnswer", "answer", "state", "context", "readingTimeMinutes", "recommendedOptionId", "inputs", "completionCriterion"], ["kind", "id", "targetRef", "question", "state"], ["id", "targetRef", "question", "recommendedAnswer", "answer", "context", "recommendedOptionId", "completionCriterion"], issues);
142
198
  if (node === undefined)
143
199
  return undefined;
144
200
  checkEnum(node["state"], `${path}.state`, ["open", "answered", "validated"], issues);
145
201
  if (node["readingTimeMinutes"] !== undefined && (typeof node["readingTimeMinutes"] !== "number" || !Number.isFinite(node["readingTimeMinutes"]))) {
146
202
  issues.push(issue(`${path}.readingTimeMinutes`, "invalid_type", "expected a finite number"));
147
203
  }
204
+ const inputs = checkSectionInputs(node["inputs"], `${path}.inputs`, issues);
205
+ checkNonBlank(node["completionCriterion"], `${path}.completionCriterion`, issues);
148
206
  if (issues.length !== start)
149
207
  return undefined;
150
208
  return {
@@ -158,6 +216,8 @@ const checkSectionNode = (value, path, issues) => {
158
216
  ...(typeof node["context"] === "string" ? { context: node["context"] } : {}),
159
217
  ...(typeof node["recommendedOptionId"] === "string" ? { recommendedOptionId: node["recommendedOptionId"] } : {}),
160
218
  ...(typeof node["readingTimeMinutes"] === "number" ? { readingTimeMinutes: node["readingTimeMinutes"] } : {}),
219
+ ...(inputs !== undefined ? { inputs } : {}),
220
+ ...(typeof node["completionCriterion"] === "string" ? { completionCriterion: node["completionCriterion"] } : {}),
161
221
  };
162
222
  }
163
223
  case "optionSet": {
@@ -227,24 +287,79 @@ const checkSectionNode = (value, path, issues) => {
227
287
  };
228
288
  }
229
289
  case "diagram": {
230
- const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "syntax", "source", "alt", "scene"], ["kind", "id", "targetRef", "syntax", "source", "alt"], ["id", "targetRef", "source", "alt"], issues);
290
+ const node = checkClosedObject(value, path, ["kind", "id", "targetRef", "syntax", "source", "sourceRef", "renderComponent", "alt", "scene"], ["kind", "id", "targetRef", "alt"], ["id", "targetRef", "source", "sourceRef", "renderComponent", "alt"], issues);
231
291
  if (node === undefined)
232
292
  return undefined;
233
- checkEnum(node["syntax"], `${path}.syntax`, ["mermaid", "plantuml"], issues);
293
+ checkNonBlank(node["alt"], `${path}.alt`, issues);
294
+ const hasSource = node["source"] !== undefined;
295
+ const hasSourceRef = node["sourceRef"] !== undefined;
296
+ const hasSyntax = node["syntax"] !== undefined;
297
+ const hasRenderComponent = node["renderComponent"] !== undefined;
298
+ const hasScene = node["scene"] !== undefined;
299
+ if (hasSource) {
300
+ checkNonBlank(node["source"], `${path}.source`, issues);
301
+ }
302
+ if (hasSyntax) {
303
+ checkEnum(node["syntax"], `${path}.syntax`, ["mermaid", "plantuml"], issues);
304
+ }
305
+ if (hasSourceRef && typeof node["sourceRef"] === "string" && !SOURCE_REF_PATTERN.test(node["sourceRef"])) {
306
+ issues.push(issue(`${path}.sourceRef`, "invalid_type", "expected a URI-like <scheme>:<opaque-id> reference"));
307
+ }
308
+ if (hasRenderComponent && typeof node["renderComponent"] === "string" && !RENDER_COMPONENT_PATTERN.test(node["renderComponent"])) {
309
+ issues.push(issue(`${path}.renderComponent`, "invalid_type", "expected a component identifier matching /^[A-Za-z][A-Za-z0-9-]*$/"));
310
+ }
234
311
  // Opaque diagram-core JSON; its authoritative schema will be pinned when published.
235
- if (node["scene"] !== undefined && !isRecord(node["scene"])) {
312
+ if (hasScene && !isRecord(node["scene"])) {
236
313
  issues.push(issue(`${path}.scene`, "invalid_type", "expected a diagram-core SemanticDocument object"));
237
314
  }
315
+ if (!hasSource && !hasSourceRef) {
316
+ issues.push(issue(path, "diagram_source_missing", "diagram requires either inline (syntax + source) or reference (sourceRef + renderComponent)"));
317
+ if (hasSyntax || hasRenderComponent) {
318
+ issues.push(issue(path, "diagram_source_conflict", "syntax requires source and renderComponent requires sourceRef"));
319
+ }
320
+ }
321
+ else if (hasSource && hasSourceRef) {
322
+ issues.push(issue(path, "diagram_source_conflict", "diagram cannot mix inline source and reference sourceRef"));
323
+ }
324
+ else if (hasSource) {
325
+ if (!hasSyntax) {
326
+ issues.push(issue(`${path}.syntax`, "diagram_source_conflict", "inline diagram source requires syntax"));
327
+ }
328
+ if (hasRenderComponent) {
329
+ issues.push(issue(`${path}.renderComponent`, "diagram_source_conflict", "inline diagram cannot declare renderComponent"));
330
+ }
331
+ }
332
+ else {
333
+ if (!hasRenderComponent) {
334
+ issues.push(issue(`${path}.renderComponent`, "diagram_source_conflict", "reference diagram sourceRef requires renderComponent"));
335
+ }
336
+ if (hasSyntax) {
337
+ issues.push(issue(`${path}.syntax`, "diagram_source_conflict", "reference diagram cannot declare syntax"));
338
+ }
339
+ if (hasScene) {
340
+ issues.push(issue(`${path}.scene`, "diagram_source_conflict", "reference diagram cannot carry an inline scene"));
341
+ }
342
+ }
238
343
  if (issues.length !== start)
239
344
  return undefined;
345
+ if (hasSource) {
346
+ return {
347
+ kind: "diagram",
348
+ id: node["id"],
349
+ targetRef: node["targetRef"],
350
+ syntax: node["syntax"],
351
+ source: node["source"],
352
+ alt: node["alt"],
353
+ ...(hasScene ? { scene: node["scene"] } : {}),
354
+ };
355
+ }
240
356
  return {
241
357
  kind: "diagram",
242
358
  id: node["id"],
243
359
  targetRef: node["targetRef"],
244
- syntax: node["syntax"],
245
- source: node["source"],
360
+ sourceRef: node["sourceRef"],
361
+ renderComponent: node["renderComponent"],
246
362
  alt: node["alt"],
247
- ...(node["scene"] === undefined ? {} : { scene: node["scene"] }),
248
363
  };
249
364
  }
250
365
  }
@@ -436,6 +551,46 @@ export const validateDecisionDossierSemantics = (doc) => {
436
551
  });
437
552
  }
438
553
  });
554
+ // Duplicate input refs: within a single prose/question node, or across a
555
+ // prose <-> question pair linked strictly by prose.questionId === question.id
556
+ // (never by shared targetRef).
557
+ const questionIds = new Set(doc.sections.filter((s) => s.kind === "question").map((q) => q.id));
558
+ const seenInputsByQuestion = new Map();
559
+ doc.sections.forEach((section, index) => {
560
+ if (section.kind !== "prose" && section.kind !== "question")
561
+ return;
562
+ if (!section.inputs?.length)
563
+ return;
564
+ const path = `$.sections[${index}]`;
565
+ const localSeen = new Map();
566
+ const groupKey = section.kind === "question"
567
+ ? section.id
568
+ : section.questionId !== undefined && questionIds.has(section.questionId)
569
+ ? section.questionId
570
+ : undefined;
571
+ let groupSeen = groupKey !== undefined ? seenInputsByQuestion.get(groupKey) : undefined;
572
+ if (groupKey !== undefined && groupSeen === undefined) {
573
+ groupSeen = new Map();
574
+ seenInputsByQuestion.set(groupKey, groupSeen);
575
+ }
576
+ section.inputs.forEach((inp, inputIndex) => {
577
+ const inputPath = `${path}.inputs[${inputIndex}].ref`;
578
+ const prevLocal = localSeen.get(inp.ref);
579
+ if (prevLocal !== undefined) {
580
+ issues.push(issue(inputPath, "duplicate_input_ref", `input ref "${inp.ref}" already declared at ${prevLocal}`));
581
+ return;
582
+ }
583
+ localSeen.set(inp.ref, inputPath);
584
+ if (groupSeen !== undefined) {
585
+ const prevGroup = groupSeen.get(inp.ref);
586
+ if (prevGroup !== undefined) {
587
+ issues.push(issue(inputPath, "duplicate_input_ref", `input ref "${inp.ref}" already declared on linked section at ${prevGroup}`));
588
+ return;
589
+ }
590
+ groupSeen.set(inp.ref, inputPath);
591
+ }
592
+ });
593
+ });
439
594
  // Every interaction target must resolve: the dossier ref, a section
440
595
  // id/targetRef, or a nested option id/targetRef.
441
596
  const resolvable = new Set([doc.ref]);
@@ -483,16 +638,59 @@ export const assertDecisionDossierDocument = (value) => {
483
638
  return result.value;
484
639
  };
485
640
  /** Presentation requires the backward-compatible structure AND the readability gate. */
486
- export const validateDecisionDossierForPresentation = (value) => {
641
+ export const validateDecisionDossierForPresentation = (value, options) => {
487
642
  const result = validateDecisionDossierDocument(value);
488
643
  if (!result.ok)
489
644
  return result;
490
- const issues = validateDecisionDossierReadability(result.value);
645
+ const issues = validateDecisionDossierReadability(result.value, options);
491
646
  return issues.length > 0 ? { ok: false, issues } : result;
492
647
  };
493
648
  /** Refuse before any presentation or host rendering hook runs. */
494
- export const assertDecisionDossierForPresentation = (value) => {
495
- const result = validateDecisionDossierForPresentation(value);
649
+ export const assertDecisionDossierForPresentation = (value, options) => {
650
+ const result = validateDecisionDossierForPresentation(value, options);
651
+ if (!result.ok)
652
+ throw new DecisionDossierValidationError(result.issues);
653
+ return result.value;
654
+ };
655
+ /** A separate schema identity: the four published decision schemas remain frozen. */
656
+ export const REPORT_SCHEMA_ID = 'urn:sentropic:focus:ReportDocument:1.0.0';
657
+ /** Explicit dispatch; legacy decision APIs deliberately remain decision-only (including N3). */
658
+ export const validateFocusDocument = (value) => {
659
+ if (!isRecord(value) || value.kind !== 'report')
660
+ return validateDecisionDossierDocument(value);
661
+ if (value.schemaVersion !== 2)
662
+ return { ok: false, issues: [issue('$.schemaVersion', 'unsupported_version', 'Reports require the evidence envelope schemaVersion: 2.')] };
663
+ const { kind: _kind, ...base } = value;
664
+ const result = validateDecisionDossierDocument(base);
665
+ if (!result.ok)
666
+ return result;
667
+ const issues = [];
668
+ result.value.sections.forEach((section, i) => {
669
+ if (!['prose', 'diagram', 'amendmentTrace'].includes(section.kind) || 'questionId' in section) {
670
+ issues.push(issue('$.sections[' + i + ']', 'report_decision_content', 'Reports cannot contain questions, choices, outcomes or question references.'));
671
+ }
672
+ });
673
+ if (result.value.interactions.length)
674
+ issues.push(issue('$.interactions', 'report_interactions', 'Reports have no decision interactions.'));
675
+ if (issues.length)
676
+ return { ok: false, issues };
677
+ return { ok: true, value: { ...result.value, kind: 'report' } };
678
+ };
679
+ export const assertFocusDocument = (value) => {
680
+ const result = validateFocusDocument(value);
681
+ if (!result.ok)
682
+ throw new DecisionDossierValidationError(result.issues);
683
+ return result.value;
684
+ };
685
+ export const validateFocusForPresentation = (value) => {
686
+ const result = validateFocusDocument(value);
687
+ if (!result.ok)
688
+ return result;
689
+ const issues = validateDecisionDossierReadability(result.value);
690
+ return issues.length ? { ok: false, issues } : result;
691
+ };
692
+ export const assertFocusForPresentation = (value) => {
693
+ const result = validateFocusForPresentation(value);
496
694
  if (!result.ok)
497
695
  throw new DecisionDossierValidationError(result.issues);
498
696
  return result.value;