@felspar/sdk 0.4.0 → 0.4.2

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.
@@ -51,26 +51,26 @@ function append(token, state, bytes = utf8Bytes(token)) {
51
51
  state.parts.push(state.buffer);
52
52
  state.buffer = "";
53
53
  }
54
- function quoted(value) {
55
- if (value.length > canonicalJsonLimits.maxBytes) {
54
+ function quoted(value2) {
55
+ if (value2.length > canonicalJsonLimits.maxBytes) {
56
56
  throw new RangeError("Canonical JSON string exceeds the byte limit");
57
57
  }
58
- if (/[\uD800-\uDFFF]/u.test(value)) {
58
+ if (/[\uD800-\uDFFF]/u.test(value2)) {
59
59
  throw new TypeError("Canonical JSON requires valid Unicode strings");
60
60
  }
61
- return JSON.stringify(value);
61
+ return JSON.stringify(value2);
62
62
  }
63
- function appendQuoted(value, state) {
64
- let entry2 = state.strings.get(value);
65
- if (!entry2) {
66
- const token = quoted(value);
67
- entry2 = { token, bytes: utf8Bytes(token) };
68
- if (state.strings.size < 256 && state.stringBytes + entry2.bytes <= 65536) {
69
- state.strings.set(value, entry2);
70
- state.stringBytes += entry2.bytes;
63
+ function appendQuoted(value2, state) {
64
+ let entry3 = state.strings.get(value2);
65
+ if (!entry3) {
66
+ const token = quoted(value2);
67
+ entry3 = { token, bytes: utf8Bytes(token) };
68
+ if (state.strings.size < 256 && state.stringBytes + entry3.bytes <= 65536) {
69
+ state.strings.set(value2, entry3);
70
+ state.stringBytes += entry3.bytes;
71
71
  }
72
72
  }
73
- append(entry2.token, state, entry2.bytes);
73
+ append(entry3.token, state, entry3.bytes);
74
74
  }
75
75
  function dataValue(input, key3) {
76
76
  const descriptor = Object.getOwnPropertyDescriptor(input, key3);
@@ -131,13 +131,13 @@ function writeObject(input, state, depth) {
131
131
  }
132
132
  append("}", state);
133
133
  }
134
- function writeSealed(entry2, state, depth) {
135
- state.nodes += entry2.nodes - 1;
136
- if (depth + entry2.height > canonicalJsonLimits.maxDepth || state.nodes > canonicalJsonLimits.maxNodes) {
134
+ function writeSealed(entry3, state, depth) {
135
+ state.nodes += entry3.nodes - 1;
136
+ if (depth + entry3.height > canonicalJsonLimits.maxDepth || state.nodes > canonicalJsonLimits.maxNodes) {
137
137
  throw new RangeError("Canonical JSON exceeds the depth or node limit");
138
138
  }
139
- state.height = Math.max(state.height, depth + entry2.height);
140
- append(entry2.json, state, entry2.bytes);
139
+ state.height = Math.max(state.height, depth + entry3.height);
140
+ append(entry3.json, state, entry3.bytes);
141
141
  }
142
142
  function writeContainer(input, state, depth) {
143
143
  const sealed = sealedEntries.get(input);
@@ -266,12 +266,12 @@ function sealValue(input, depth, state) {
266
266
  throw new RangeError("Canonical JSON exceeds the depth, node or byte limit");
267
267
  }
268
268
  Object.freeze(input);
269
- const entry2 = { json, bytes, nodes, height };
269
+ const entry3 = { json, bytes, nodes, height };
270
270
  sealedContainers.add(input);
271
271
  if (bytes >= sealedEntryMinimumBytes) {
272
- sealedEntries.set(input, entry2);
272
+ sealedEntries.set(input, entry3);
273
273
  }
274
- return entry2;
274
+ return entry3;
275
275
  }
276
276
  function sealCanonicalJson(input) {
277
277
  sealValue(input, 0, { ancestors: /* @__PURE__ */ new Set() });
@@ -316,8 +316,8 @@ async function sha256(text8) {
316
316
  const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(text8)));
317
317
  return `sha256:${Array.from(hash, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
318
318
  }
319
- function reference(digest28) {
320
- return { [draftContentPartReferenceKey]: digest28 };
319
+ function reference(digest31) {
320
+ return { [draftContentPartReferenceKey]: digest31 };
321
321
  }
322
322
  var referenceBytes = utf8(canonicalizeJson(reference(`sha256:${"0".repeat(64)}`)));
323
323
  var logicalLimit = "Content parts exceed the logical byte, node or depth limit";
@@ -326,12 +326,12 @@ function admit(logical, depth) {
326
326
  throw new RangeError(logicalLimit);
327
327
  }
328
328
  }
329
- function scalar(value) {
330
- if (value === void 0 || typeof value === "function" || typeof value === "symbol") {
329
+ function scalar(value2) {
330
+ if (value2 === void 0 || typeof value2 === "function" || typeof value2 === "symbol") {
331
331
  throw new TypeError("Content parts require JSON values");
332
332
  }
333
- const bytes = utf8(JSON.stringify(value));
334
- return { value, tokenBytes: bytes, logical: { bytes, nodes: 1, height: 0 } };
333
+ const bytes = utf8(JSON.stringify(value2));
334
+ return { value: value2, tokenBytes: bytes, logical: { bytes, nodes: 1, height: 0 } };
335
335
  }
336
336
  function combine(keys, children) {
337
337
  let tokenBytes = 2 + Math.max(children.length - 1, 0);
@@ -350,8 +350,8 @@ function combine(keys, children) {
350
350
  }
351
351
  var hydratedValues = /* @__PURE__ */ new WeakSet();
352
352
  var knownSplits = /* @__PURE__ */ new WeakMap();
353
- function isImmutable(value) {
354
- return hydratedValues.has(value) || isCanonicalJsonSealed(value);
353
+ function isImmutable(value2) {
354
+ return hydratedValues.has(value2) || isCanonicalJsonSealed(value2);
355
355
  }
356
356
  function entriesOf(input) {
357
357
  const isArray = Array.isArray(input);
@@ -397,7 +397,7 @@ function measure(input, state, depth) {
397
397
  throw new RangeError(logicalLimit);
398
398
  }
399
399
  const entries2 = entriesOf(input);
400
- const children = entries2.map(([, value]) => measure(value, state, depth + 1));
400
+ const children = entries2.map(([, value2]) => measure(value2, state, depth + 1));
401
401
  const keys = Array.isArray(input) ? null : entries2.map(([key3]) => key3);
402
402
  const { tokenBytes: tokenBytes2, logical } = combine(keys, children);
403
403
  const isPart = tokenBytes2 >= contentPartsLimits.minPartBytes;
@@ -419,19 +419,19 @@ function storedForm(input, state) {
419
419
  if (known) {
420
420
  return known.value;
421
421
  }
422
- const digest28 = state.digests.get(input);
423
- if (digest28 !== void 0) {
424
- return reference(digest28);
422
+ const digest31 = state.digests.get(input);
423
+ if (digest31 !== void 0) {
424
+ return reference(digest31);
425
425
  }
426
426
  const node = state.measured.get(input);
427
427
  if (!node) {
428
428
  throw new Error("Content parts lost a measured container");
429
429
  }
430
- return rebuild(input, node.entries, node.entries.map(([, value]) => storedForm(value, state)));
430
+ return rebuild(input, node.entries, node.entries.map(([, value2]) => storedForm(value2, state)));
431
431
  }
432
- function remember(node, value, tokenBytes) {
432
+ function remember(node, value2, tokenBytes) {
433
433
  if (isImmutable(node.input)) {
434
- knownSplits.set(node.input, { value, tokenBytes, logical: node.logical });
434
+ knownSplits.set(node.input, { value: value2, tokenBytes, logical: node.logical });
435
435
  }
436
436
  }
437
437
  function isCanonicalDocumentSized(logical) {
@@ -446,7 +446,7 @@ function freezeMeasured(state) {
446
446
  hydratedValues.add(node.input);
447
447
  }
448
448
  }
449
- async function splitRoot(value, isCollecting, isFreezing = false) {
449
+ async function splitRoot(value2, isCollecting, isFreezing = false) {
450
450
  const state = {
451
451
  isCollecting,
452
452
  measured: /* @__PURE__ */ new Map(),
@@ -454,26 +454,26 @@ async function splitRoot(value, isCollecting, isFreezing = false) {
454
454
  digests: /* @__PURE__ */ new Map(),
455
455
  parts: /* @__PURE__ */ new Map()
456
456
  };
457
- const root = measure(value, state, 0);
457
+ const root = measure(value2, state, 0);
458
458
  if (isFreezing) {
459
459
  freezeMeasured(state);
460
460
  }
461
461
  for (const node of state.order) {
462
462
  const token = canonicalizeJson(storedForm(node.input, state));
463
- const digest29 = await sha256(token);
464
- state.digests.set(node.input, digest29);
465
- state.parts.set(digest29, token);
466
- remember(node, reference(digest29), referenceBytes);
467
- }
468
- const stored = storedForm(value, state);
469
- if (value !== null && typeof value === "object") {
470
- const node = state.measured.get(value);
463
+ const digest32 = await sha256(token);
464
+ state.digests.set(node.input, digest32);
465
+ state.parts.set(digest32, token);
466
+ remember(node, reference(digest32), referenceBytes);
467
+ }
468
+ const stored = storedForm(value2, state);
469
+ if (value2 !== null && typeof value2 === "object") {
470
+ const node = state.measured.get(value2);
471
471
  if (node && !node.isPart) {
472
472
  remember(node, stored, node.tokenBytes);
473
473
  }
474
474
  }
475
- const digest28 = await sha256(canonicalizeJson(stored));
476
- return { state, root: { ...root, value: stored }, digest: digest28 };
475
+ const digest31 = await sha256(canonicalizeJson(stored));
476
+ return { state, root: { ...root, value: stored }, digest: digest31 };
477
477
  }
478
478
  function byDigest(left, right) {
479
479
  return left < right ? -1 : 1;
@@ -483,8 +483,8 @@ function admitStored(parts, bytes) {
483
483
  throw new RangeError("Content parts exceed the stored part or byte limit");
484
484
  }
485
485
  }
486
- async function packContentParts(value) {
487
- const { state, root, digest: digest28 } = await splitRoot(value, true);
486
+ async function packContentParts(value2) {
487
+ const { state, root, digest: digest31 } = await splitRoot(value2, true);
488
488
  const parts = [];
489
489
  for (const part of state.parts.keys()) {
490
490
  parts.push(part);
@@ -495,7 +495,7 @@ async function packContentParts(value) {
495
495
  const storedBytes = utf8(text8);
496
496
  admitStored(parts.length, storedBytes);
497
497
  return {
498
- digest: digest28,
498
+ digest: digest31,
499
499
  text: text8,
500
500
  parts: parts.length,
501
501
  storedBytes,
@@ -524,12 +524,12 @@ import { z as z5 } from "zod";
524
524
 
525
525
  // ../schemas/src/draft-calendar-date.ts
526
526
  import { z as z2 } from "zod";
527
- var CalendarDateSchema = z2.string().regex(/^(?!0000)\d{4}-\d{2}-\d{2}$/u).refine((value) => {
528
- const instant2 = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
529
- return Number.isFinite(instant2.getTime()) && instant2.toISOString().slice(0, 10) === value;
527
+ var CalendarDateSchema = z2.string().regex(/^(?!0000)\d{4}-\d{2}-\d{2}$/u).refine((value2) => {
528
+ const instant2 = /* @__PURE__ */ new Date(`${value2}T00:00:00.000Z`);
529
+ return Number.isFinite(instant2.getTime()) && instant2.toISOString().slice(0, 10) === value2;
530
530
  }, "Expected a real Gregorian calendar date in years 0001\u20139999");
531
- function calendarDay(value) {
532
- return Date.parse(`${value}T00:00:00.000Z`) / 864e5;
531
+ function calendarDay(value2) {
532
+ return Date.parse(`${value2}T00:00:00.000Z`) / 864e5;
533
533
  }
534
534
 
535
535
  // ../schemas/src/draft-evidence-scope.ts
@@ -537,8 +537,8 @@ import { z as z3 } from "zod";
537
537
  var identifier = z3.string().min(1).max(256).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]*$/u);
538
538
  var draftSourceIdLimit = 2048;
539
539
  var draftSourceIdPattern = /^[a-zA-Z0-9](?:[a-zA-Z0-9\-._~:/?#[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*$/u;
540
- function isDraftSourceId(value) {
541
- return value.length <= draftSourceIdLimit && draftSourceIdPattern.test(value);
540
+ function isDraftSourceId(value2) {
541
+ return value2.length <= draftSourceIdLimit && draftSourceIdPattern.test(value2);
542
542
  }
543
543
  var sourceId = z3.string().min(1).max(draftSourceIdLimit).regex(draftSourceIdPattern);
544
544
  var reference2 = z3.strictObject({
@@ -630,8 +630,8 @@ var businessCalendar = z5.strictObject({
630
630
  });
631
631
  }
632
632
  if (calendar.holidays.some((day) => {
633
- const value = calendarDay(day);
634
- return value < calendarDay(calendar.validFrom) || value > calendarDay(calendar.validThrough);
633
+ const value2 = calendarDay(day);
634
+ return value2 < calendarDay(calendar.validFrom) || value2 > calendarDay(calendar.validThrough);
635
635
  })) {
636
636
  context3.addIssue({ code: "custom", message: "Holiday outside declared calendar coverage" });
637
637
  }
@@ -691,20 +691,20 @@ function unique(values, context3, path3) {
691
691
  function checkAuthority(authority, context3) {
692
692
  unique(authority.definition.allowedValues, context3, ["definition", "allowedValues"]);
693
693
  unique(authority.allowedOutcomes, context3, ["allowedOutcomes"]);
694
- unique(authority.rules.map((entry2) => entry2.id), context3, ["rules"]);
694
+ unique(authority.rules.map((entry3) => entry3.id), context3, ["rules"]);
695
695
  const values = new Set(authority.definition.allowedValues);
696
696
  const outcomes = new Set(authority.allowedOutcomes);
697
- for (const [index, entry2] of authority.rules.entries()) {
697
+ for (const [index, entry3] of authority.rules.entries()) {
698
698
  const at = ["rules", index];
699
- requireBinding(entry2.when.key === authority.definition.key, context3, {
699
+ requireBinding(entry3.when.key === authority.definition.key, context3, {
700
700
  path: [...at, "when", "key"],
701
701
  message: unknownDefinition
702
702
  });
703
- requireBinding(values.has(entry2.when.equals), context3, {
703
+ requireBinding(values.has(entry3.when.equals), context3, {
704
704
  path: [...at, "when", "equals"],
705
705
  message: "Unknown definition value"
706
706
  });
707
- requireBinding(outcomes.has(entry2.outcome), context3, {
707
+ requireBinding(outcomes.has(entry3.outcome), context3, {
708
708
  path: [...at, "outcome"],
709
709
  message: "Unknown outcome"
710
710
  });
@@ -769,15 +769,15 @@ var admission = z8.strictObject({
769
769
  trustDomain: identifier5,
770
770
  status: z8.enum(["approved", "revoked"])
771
771
  });
772
- function draftEvidenceReferenceKey(value) {
773
- return JSON.stringify([draftPassageKey(value), value.contentDigest]);
772
+ function draftEvidenceReferenceKey(value2) {
773
+ return JSON.stringify([draftPassageKey(value2), value2.contentDigest]);
774
774
  }
775
- function draftAdmissionKey(value) {
775
+ function draftAdmissionKey(value2) {
776
776
  return JSON.stringify([
777
- draftEvidenceReferenceKey(value.reference),
778
- value.purpose,
779
- value.sensitivity,
780
- value.trustDomain
777
+ draftEvidenceReferenceKey(value2.reference),
778
+ value2.purpose,
779
+ value2.sensitivity,
780
+ value2.trustDomain
781
781
  ]);
782
782
  }
783
783
  function requireCoverage({ expected: expected2, actual, path: path3 }, context3) {
@@ -909,9 +909,9 @@ import { z as z12 } from "zod";
909
909
 
910
910
  // ../schemas/src/draft-decision-date.ts
911
911
  import { z as z11 } from "zod";
912
- function isTimeZone(value) {
912
+ function isTimeZone(value2) {
913
913
  try {
914
- const format = new Intl.DateTimeFormat("en-US", { timeZone: value });
914
+ const format = new Intl.DateTimeFormat("en-US", { timeZone: value2 });
915
915
  const options = format.resolvedOptions();
916
916
  return options.timeZone.length > 0;
917
917
  } catch {
@@ -992,22 +992,22 @@ function interval(clause, definition3) {
992
992
  if (!bounds) {
993
993
  return null;
994
994
  }
995
- const { minimum, maximum, operator, value } = bounds;
995
+ const { minimum, maximum, operator, value: value2 } = bounds;
996
996
  return {
997
- low: operator === "lt" || operator === "lte" ? minimum : Math.max(minimum, value),
998
- high: operator === "gt" || operator === "gte" ? maximum : Math.min(maximum, value),
999
- lowClosed: operator !== "gt" || minimum > value,
1000
- highClosed: operator !== "lt" || maximum < value
997
+ low: operator === "lt" || operator === "lte" ? minimum : Math.max(minimum, value2),
998
+ high: operator === "gt" || operator === "gte" ? maximum : Math.min(maximum, value2),
999
+ lowClosed: operator !== "gt" || minimum > value2,
1000
+ highClosed: operator !== "lt" || maximum < value2
1001
1001
  };
1002
1002
  }
1003
- function nextNumber(value) {
1004
- if (value === 0) {
1003
+ function nextNumber(value2) {
1004
+ if (value2 === 0) {
1005
1005
  return Number.MIN_VALUE;
1006
1006
  }
1007
1007
  const view = new DataView(new ArrayBuffer(8));
1008
- view.setFloat64(0, value);
1008
+ view.setFloat64(0, value2);
1009
1009
  const bits = view.getBigUint64(0);
1010
- view.setBigUint64(0, value > 0 ? bits + 1n : bits - 1n);
1010
+ view.setBigUint64(0, value2 > 0 ? bits + 1n : bits - 1n);
1011
1011
  return view.getFloat64(0);
1012
1012
  }
1013
1013
  function isNonempty(range2, isInteger) {
@@ -1046,7 +1046,7 @@ function isConditionSupported(clause, definition3, definitions) {
1046
1046
  return clause.key !== clause.compareFact.key && areCompatibleFacts(definition3, definitions?.get(clause.compareFact.key));
1047
1047
  }
1048
1048
  if ("allowedValues" in definition3) {
1049
- return "oneOf" in clause ? clause.oneOf.every((value) => definition3.allowedValues.includes(value)) : "equals" in clause && typeof clause.equals === "string" && definition3.allowedValues.includes(clause.equals);
1049
+ return "oneOf" in clause ? clause.oneOf.every((value2) => definition3.allowedValues.includes(value2)) : "equals" in clause && typeof clause.equals === "string" && definition3.allowedValues.includes(clause.equals);
1050
1050
  }
1051
1051
  if (definition3.valueRule.type === "boolean") {
1052
1052
  return "equals" in clause && typeof clause.equals === "boolean";
@@ -1066,7 +1066,7 @@ function relativeConditionsOverlap(left, right) {
1066
1066
  const { operator: b, ...rightOffset } = right.relativeDate;
1067
1067
  if (JSON.stringify(leftOffset) === JSON.stringify(rightOffset)) {
1068
1068
  const signs = { eq: [0], lt: [-1], lte: [-1, 0], gt: [1], gte: [0, 1] };
1069
- return signs[a].some((value) => signs[b].includes(value));
1069
+ return signs[a].some((value2) => signs[b].includes(value2));
1070
1070
  }
1071
1071
  }
1072
1072
  return null;
@@ -1127,12 +1127,12 @@ function areConditionsOverlapping(left, right, definition3) {
1127
1127
  }
1128
1128
  if ("compareFact" in left && "compareFact" in right && left.compareFact.key === right.compareFact.key) {
1129
1129
  const signs = { eq: [0], lt: [-1], lte: [-1, 0], gt: [1], gte: [0, 1] };
1130
- return signs[left.compareFact.operator].some((value) => signs[right.compareFact.operator].includes(value));
1130
+ return signs[left.compareFact.operator].some((value2) => signs[right.compareFact.operator].includes(value2));
1131
1131
  }
1132
1132
  const leftValues = optionsOf(left);
1133
1133
  const rightValues = optionsOf(right);
1134
1134
  if (leftValues && rightValues) {
1135
- return leftValues.some((value) => rightValues.includes(value));
1135
+ return leftValues.some((value2) => rightValues.includes(value2));
1136
1136
  }
1137
1137
  const a = interval(left, definition3);
1138
1138
  const b = interval(right, definition3);
@@ -1286,7 +1286,7 @@ function isGuardImplied(guard, clause) {
1286
1286
  const allowed = choiceValues(guard);
1287
1287
  const values = choiceValues(clause);
1288
1288
  const isSameKey = clause.key === guard.key;
1289
- return isSameKey && values.length > 0 && values.every((value) => allowed.includes(value));
1289
+ return isSameKey && values.length > 0 && values.every((value2) => allowed.includes(value2));
1290
1290
  }
1291
1291
  function isPolicyValid(proposal, context3) {
1292
1292
  const clauses2 = [
@@ -1534,7 +1534,7 @@ function inspectScoredPolicy(proposal, context3) {
1534
1534
  }
1535
1535
  inspectScoringReferences(scoring, proposal.requirements, context3);
1536
1536
  const ids3 = new Set(rules2.map((rule3) => rule3.id));
1537
- if (gates.some((id13) => !ids3.has(id13))) {
1537
+ if (gates.some((id15) => !ids3.has(id15))) {
1538
1538
  fail("Unknown mandatory gate rule");
1539
1539
  }
1540
1540
  if (rules2.every((rule3) => gates.includes(rule3.id))) {
@@ -1547,7 +1547,7 @@ function inspectScoredPolicy(proposal, context3) {
1547
1547
  if (isGate ? hasRange || rule3.when.length === 0 : !hasRange) {
1548
1548
  fail("Mandatory gates require fact predicates only; other rules require score ranges");
1549
1549
  }
1550
- if (rule3.overrides.some((id13) => gates.includes(id13) !== isGate)) {
1550
+ if (rule3.overrides.some((id15) => gates.includes(id15) !== isGate)) {
1551
1551
  fail("Explicit overrides cannot cross mandatory-gate and score-band classes");
1552
1552
  }
1553
1553
  const range2 = rule3.scoreRange;
@@ -1569,6 +1569,8 @@ function areScoredRulesDisjoint(proposal, left, right) {
1569
1569
 
1570
1570
  // ../schemas/src/draft-required-decision.ts
1571
1571
  var typedResolutionPolicy = "strict-required-types/direct-overrides/v2";
1572
+ var valueAgreementOutcomeRegions = "outcome-regions";
1573
+ var freshnessStaleBeforeReview = "stale-before-review";
1572
1574
  var identifier8 = DraftEvidenceScopeSchema.shape.entityId;
1573
1575
  var duplicateIdentity = "Duplicate identity";
1574
1576
  var uniqueIds = z15.array(identifier8).max(64).refine(hasUniqueValues, duplicateIdentity);
@@ -1611,7 +1613,9 @@ var shape = z15.strictObject({
1611
1613
  }),
1612
1614
  scope: z15.strictObject({
1613
1615
  entityId: identifier8,
1614
- evaluationTime: DraftObservationChecksSchema.shape.evaluationTime
1616
+ evaluationTime: DraftObservationChecksSchema.shape.evaluationTime,
1617
+ valueAgreement: z15.literal(valueAgreementOutcomeRegions).optional(),
1618
+ freshness: z15.literal(freshnessStaleBeforeReview).optional()
1615
1619
  }),
1616
1620
  evidence: z15.array(DraftEvidenceValidationSchema).max(64)
1617
1621
  });
@@ -1631,23 +1635,44 @@ function draftRulePriority(ranked) {
1631
1635
  function hasDraftRulePrecedence(winner, other) {
1632
1636
  return winner.overrides.includes(other.id) || draftRulePriority(winner) > draftRulePriority(other);
1633
1637
  }
1638
+ function overlappingRulePairs(proposal) {
1639
+ const { rules: rules2, requirements: requirements3 } = proposal;
1640
+ const definitions = new Map(requirements3.map((item) => [item.definition.key, item.definition]));
1641
+ const pairs = [];
1642
+ for (const [index, item] of rules2.entries()) {
1643
+ const later = rules2.slice(index + 1);
1644
+ for (const [offset, other] of later.entries()) {
1645
+ if (item.outcome !== other.outcome && !areScoredRulesDisjoint(proposal, item, other) && hasOverlap(item, other, definitions)) {
1646
+ pairs.push([index, index + offset + 1]);
1647
+ }
1648
+ }
1649
+ }
1650
+ return pairs;
1651
+ }
1652
+ function contradictoryRulePairs(proposal) {
1653
+ const { rules: rules2 } = proposal;
1654
+ return overlappingRulePairs(proposal).filter(([left, right]) => {
1655
+ const [item, other] = [rules2[left], rules2[right]];
1656
+ return item !== void 0 && other !== void 0 && !hasDraftRulePrecedence(item, other) && !hasDraftRulePrecedence(other, item);
1657
+ });
1658
+ }
1634
1659
  function hasCycle(rules2) {
1635
1660
  const graph = new Map(rules2.map((item) => [item.id, item.overrides]));
1636
1661
  const visiting = /* @__PURE__ */ new Set();
1637
1662
  const visited = /* @__PURE__ */ new Set();
1638
- const hasPathCycle = (id13) => {
1639
- if (visiting.has(id13)) {
1663
+ const hasPathCycle = (id15) => {
1664
+ if (visiting.has(id15)) {
1640
1665
  return true;
1641
1666
  }
1642
- if (visited.has(id13)) {
1667
+ if (visited.has(id15)) {
1643
1668
  return false;
1644
1669
  }
1645
- visiting.add(id13);
1646
- if ((graph.get(id13) ?? []).some(hasPathCycle)) {
1670
+ visiting.add(id15);
1671
+ if ((graph.get(id15) ?? []).some(hasPathCycle)) {
1647
1672
  return true;
1648
1673
  }
1649
- visiting.delete(id13);
1650
- visited.add(id13);
1674
+ visiting.delete(id15);
1675
+ visited.add(id15);
1651
1676
  return false;
1652
1677
  };
1653
1678
  return rules2.some((item) => hasPathCycle(item.id));
@@ -1656,7 +1681,7 @@ function inspectRules(proposal, context3) {
1656
1681
  const { rules: rules2, requirements: requirements3, allowedOutcomes } = proposal;
1657
1682
  const definitions = new Map(requirements3.map((item) => [item.definition.key, item.definition]));
1658
1683
  const ids3 = new Set(rules2.map((item) => item.id));
1659
- const byId = new Map(rules2.map((entry2) => [entry2.id, entry2]));
1684
+ const byId = new Map(rules2.map((entry3) => [entry3.id, entry3]));
1660
1685
  for (const [index, item] of rules2.entries()) {
1661
1686
  const fail = (message) => {
1662
1687
  context3.addIssue({
@@ -1676,22 +1701,22 @@ function inspectRules(proposal, context3) {
1676
1701
  fail("Undeclared condition key or value");
1677
1702
  }
1678
1703
  }
1679
- if (item.overrides.some((id13) => id13 === item.id || !ids3.has(id13))) {
1704
+ if (item.overrides.some((id15) => id15 === item.id || !ids3.has(id15))) {
1680
1705
  fail("Unknown or self override");
1681
1706
  }
1682
- if (item.overrides.some((id13) => {
1683
- const target = byId.get(id13);
1684
- return target !== void 0 && draftRulePriority(target) > draftRulePriority(item);
1707
+ if (item.overrides.some((id15) => {
1708
+ const target2 = byId.get(id15);
1709
+ return target2 !== void 0 && draftRulePriority(target2) > draftRulePriority(item);
1685
1710
  })) {
1686
1711
  fail("Override points to a higher priority tier");
1687
1712
  }
1688
- const laterRules = rules2.slice(index + 1);
1689
- for (const other of laterRules) {
1690
- const isContradictory = item.outcome !== other.outcome && !areScoredRulesDisjoint(proposal, item, other) && hasOverlap(item, other, definitions);
1691
- if (isContradictory && !hasDraftRulePrecedence(item, other) && !hasDraftRulePrecedence(other, item)) {
1692
- fail("Overlapping contradictory rules require a direct override");
1693
- }
1694
- }
1713
+ }
1714
+ for (const [index] of contradictoryRulePairs(proposal)) {
1715
+ context3.addIssue({
1716
+ code: "custom",
1717
+ path: ["rules", index],
1718
+ message: "Overlapping contradictory rules require a direct override"
1719
+ });
1695
1720
  }
1696
1721
  if (hasCycle(rules2)) {
1697
1722
  context3.addIssue({ code: "custom", path: ["rules"], message: "Override cycle" });
@@ -1817,26 +1842,26 @@ function unique2(values, context3, path3) {
1817
1842
  }
1818
1843
  function checkObservations(candidate2, context3) {
1819
1844
  const { authority, observations } = candidate2;
1820
- unique2(observations.map((entry2) => entry2.id), context3, ["observations"]);
1821
- for (const [index, entry2] of observations.entries()) {
1845
+ unique2(observations.map((entry3) => entry3.id), context3, ["observations"]);
1846
+ for (const [index, entry3] of observations.entries()) {
1822
1847
  const at = ["observations", index];
1823
- requireBinding2(entry2.key === authority.definition.key, context3, {
1848
+ requireBinding2(entry3.key === authority.definition.key, context3, {
1824
1849
  path: [...at, "key"],
1825
1850
  message: unknownDefinition2
1826
1851
  });
1827
- requireBinding2(authority.definition.allowedValues.includes(entry2.value), context3, {
1852
+ requireBinding2(authority.definition.allowedValues.includes(entry3.value), context3, {
1828
1853
  path: [...at, "value"],
1829
1854
  message: "Unknown definition value"
1830
1855
  });
1831
- requireBinding2(entry2.definitionDigest === authority.definition.contentDigest, context3, {
1856
+ requireBinding2(entry3.definitionDigest === authority.definition.contentDigest, context3, {
1832
1857
  path: [...at, "definitionDigest"],
1833
1858
  message: "Definition fingerprint mismatch"
1834
1859
  });
1835
- requireBinding2(entry2.evidence.entityId === candidate2.entityId, context3, {
1860
+ requireBinding2(entry3.evidence.entityId === candidate2.entityId, context3, {
1836
1861
  path: [...at, "evidence", "entityId"],
1837
1862
  message: "Evidence belongs to a different entity"
1838
1863
  });
1839
- requireBinding2(Date.parse(entry2.observedAt) <= Date.parse(candidate2.evaluatedAt), context3, {
1864
+ requireBinding2(Date.parse(entry3.observedAt) <= Date.parse(candidate2.evaluatedAt), context3, {
1840
1865
  path: [...at, "observedAt"],
1841
1866
  message: "Observation is later than evaluation"
1842
1867
  });
@@ -1852,9 +1877,9 @@ function checkExpected(candidate2, context3) {
1852
1877
  return;
1853
1878
  }
1854
1879
  unique2(result.observationIds, context3, ["expected", "observationIds"]);
1855
- const observationIds = new Set(candidate2.observations.map((entry2) => entry2.id));
1856
- for (const [index, id13] of result.observationIds.entries()) {
1857
- requireBinding2(observationIds.has(id13), context3, {
1880
+ const observationIds = new Set(candidate2.observations.map((entry3) => entry3.id));
1881
+ for (const [index, id15] of result.observationIds.entries()) {
1882
+ requireBinding2(observationIds.has(id15), context3, {
1858
1883
  path: ["expected", "observationIds", index],
1859
1884
  message: "Unknown observation"
1860
1885
  });
@@ -1866,7 +1891,7 @@ function checkExpected(candidate2, context3) {
1866
1891
  path: ["expected", "outcome"],
1867
1892
  message: "Unknown outcome"
1868
1893
  });
1869
- requireBinding2(candidate2.authority.rules.some((entry2) => entry2.id === result.ruleId), context3, { path: ["expected", "ruleId"], message: "Unknown rule" });
1894
+ requireBinding2(candidate2.authority.rules.some((entry3) => entry3.id === result.ruleId), context3, { path: ["expected", "ruleId"], message: "Unknown rule" });
1870
1895
  }
1871
1896
  var DraftDecisionCaseSchema = shape2.superRefine((candidate2, context3) => {
1872
1897
  checkObservations(candidate2, context3);
@@ -1994,10 +2019,10 @@ var expectation = z19.strictObject({
1994
2019
  status: z19.enum(["ready", "blocked", "review_required", "stale", "conflict", "gap"]),
1995
2020
  outcome: identifier11.nullable(),
1996
2021
  selectedRuleIds: z19.array(identifier11).max(256).refine(hasUniqueValues, "Duplicate rule identity")
1997
- }).superRefine((value, context3) => {
1998
- const hasOutcome = value.outcome !== null;
1999
- const hasRules = value.selectedRuleIds.length > 0;
2000
- const isReady = value.status === "ready";
2022
+ }).superRefine((value2, context3) => {
2023
+ const hasOutcome = value2.outcome !== null;
2024
+ const hasRules = value2.selectedRuleIds.length > 0;
2025
+ const isReady = value2.status === "ready";
2001
2026
  if (isReady ? !hasOutcome || !hasRules : hasOutcome || hasRules) {
2002
2027
  context3.addIssue({
2003
2028
  code: "custom",
@@ -2014,9 +2039,22 @@ var DraftEvidenceFixtureSchema = z19.strictObject({
2014
2039
  ...fixtureIdentity,
2015
2040
  evidence: DraftRequiredDecisionSchema.shape.evidence
2016
2041
  });
2042
+ var fixtureFact = z19.strictObject({
2043
+ key: identifier11,
2044
+ value: DraftEvidenceValueSchema,
2045
+ held: z19.enum(["stale", "review"]).optional(),
2046
+ conflictsWith: DraftEvidenceValueSchema.optional()
2047
+ }).superRefine((fact, context3) => {
2048
+ if (fact.held !== void 0 && fact.conflictsWith !== void 0) {
2049
+ context3.addIssue({ code: "custom", message: "A fact is stale, flagged or conflicting" });
2050
+ }
2051
+ if (fact.conflictsWith === fact.value) {
2052
+ context3.addIssue({ code: "custom", message: "Conflicting values must differ" });
2053
+ }
2054
+ });
2017
2055
  var DraftFactFixtureSchema = z19.strictObject({
2018
2056
  ...fixtureIdentity,
2019
- facts: z19.array(z19.strictObject({ key: identifier11, value: DraftEvidenceValueSchema })).max(64).refine((facts) => hasUniqueValues(facts.map((fact) => fact.key)), "Duplicate fact key")
2057
+ facts: z19.array(fixtureFact).max(64).refine((facts) => hasUniqueValues(facts.map((fact) => fact.key)), "Duplicate fact key")
2020
2058
  });
2021
2059
  var DraftAnyCompilationFixtureSchema = z19.union([
2022
2060
  DraftEvidenceFixtureSchema,
@@ -2148,40 +2186,40 @@ function boundedDraftInput(limits2) {
2148
2186
  let nodes = 0;
2149
2187
  let text8 = 0;
2150
2188
  const budgetError = new Error("Draft input budget exceeded or non-data input");
2151
- function copy(value, depth) {
2189
+ function copy(value2, depth) {
2152
2190
  nodes += 1;
2153
2191
  if (nodes > limits2.nodes || depth > maxDepth) {
2154
2192
  throw budgetError;
2155
2193
  }
2156
- if (typeof value === "string") {
2157
- text8 += value.length;
2158
- if (value.length > limits2.stringLength || text8 > limits2.totalText) {
2194
+ if (typeof value2 === "string") {
2195
+ text8 += value2.length;
2196
+ if (value2.length > limits2.stringLength || text8 > limits2.totalText) {
2159
2197
  throw budgetError;
2160
2198
  }
2161
- return value;
2199
+ return value2;
2162
2200
  }
2163
- if (value === null || typeof value !== "object") {
2164
- return value;
2201
+ if (value2 === null || typeof value2 !== "object") {
2202
+ return value2;
2165
2203
  }
2166
- const isArray = Array.isArray(value);
2167
- const prototype = Object.getPrototypeOf(value);
2204
+ const isArray = Array.isArray(value2);
2205
+ const prototype = Object.getPrototypeOf(value2);
2168
2206
  if (prototype !== null && prototype !== (isArray ? Array.prototype : Object.prototype)) {
2169
2207
  throw budgetError;
2170
2208
  }
2171
- if (isArray && value.length > limits2.arrayLength) {
2209
+ if (isArray && value2.length > limits2.arrayLength) {
2172
2210
  throw budgetError;
2173
2211
  }
2174
- const output = isArray ? Array.from({ length: value.length }) : {};
2212
+ const output = isArray ? Array.from({ length: value2.length }) : {};
2175
2213
  let properties = 0;
2176
- for (const key3 in value) {
2177
- if (!Object.hasOwn(value, key3)) {
2214
+ for (const key3 in value2) {
2215
+ if (!Object.hasOwn(value2, key3)) {
2178
2216
  continue;
2179
2217
  }
2180
2218
  properties += 1;
2181
2219
  if (properties > (isArray ? limits2.arrayLength : 32)) {
2182
2220
  throw budgetError;
2183
2221
  }
2184
- const descriptor = Object.getOwnPropertyDescriptor(value, key3);
2222
+ const descriptor = Object.getOwnPropertyDescriptor(value2, key3);
2185
2223
  if (!descriptor || !("value" in descriptor)) {
2186
2224
  throw budgetError;
2187
2225
  }
@@ -2206,7 +2244,7 @@ function boundedDraftInput(limits2) {
2206
2244
  }
2207
2245
  });
2208
2246
  }
2209
- var isUnicodeText = (value) => !/[\uD800-\uDFFF]/u.test(value);
2247
+ var isUnicodeText = (value2) => !/[\uD800-\uDFFF]/u.test(value2);
2210
2248
  var isSplitCharacter = (text8, offset) => offset > 0 && offset < text8.length && /[\uDC00-\uDFFF]/u.test(text8.charAt(offset));
2211
2249
  var sourceText = DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
2212
2250
  text: z21.string().min(1).max(1048576).refine(isUnicodeText, "Lone Unicode surrogate"),
@@ -2225,11 +2263,11 @@ var sourceBundle = z21.strictObject({
2225
2263
  const identities = /* @__PURE__ */ new Set();
2226
2264
  for (const [sourceIndex, source3] of bundle.sources.entries()) {
2227
2265
  const at = ["sources", sourceIndex];
2228
- const identity = sourceKey(source3);
2229
- if (identities.has(identity)) {
2266
+ const identity2 = sourceKey(source3);
2267
+ if (identities.has(identity2)) {
2230
2268
  context3.addIssue({ code: "custom", path: at, message: "Duplicate source/revision" });
2231
2269
  }
2232
- identities.add(identity);
2270
+ identities.add(identity2);
2233
2271
  const locators2 = /* @__PURE__ */ new Set();
2234
2272
  for (const [index, passage4] of source3.passages.entries()) {
2235
2273
  const path3 = [...at, "passages", index];
@@ -2378,10 +2416,11 @@ var DraftEvaluatorContractSchema = z24.strictObject({
2378
2416
  evaluator,
2379
2417
  calibration: z24.strictObject({ id: identifier13, version: identifier13, contentDigest: digest9 }),
2380
2418
  minimumSelectedProbability: z24.number().gt(0).max(1),
2381
- inputContextContract: z24.enum(["job-entity-time/v1", "job-only/v2"]).optional(),
2419
+ inputContextContract: z24.enum(["job-entity-time/v1", "job-only/v2", "job-only/v3", "job-only/v4"]).optional(),
2382
2420
  probabilityContract: z24.enum([
2383
2421
  "closed-distribution-unique-maximum/v1",
2384
- "closed-distribution-with-abstention/v1"
2422
+ "closed-distribution-with-abstention/v1",
2423
+ "independent-option-support/v1"
2385
2424
  ])
2386
2425
  });
2387
2426
  var judgment = z24.discriminatedUnion("status", [
@@ -2389,11 +2428,25 @@ var judgment = z24.discriminatedUnion("status", [
2389
2428
  status: z24.literal("evaluated"),
2390
2429
  abstentionProbability: z24.number().min(0).max(1).optional(),
2391
2430
  promptInjectionProbability: z24.number().min(0).max(1).optional(),
2431
+ applicabilityProbability: z24.number().min(0).max(1).optional(),
2432
+ irrelevanceProbability: z24.number().min(0).max(1).optional(),
2433
+ independentOptions: z24.array(z24.strictObject({
2434
+ value: z24.string().min(1).max(200),
2435
+ supported: z24.number().min(0).max(1),
2436
+ ruledOut: z24.number().min(0).max(1),
2437
+ unresolved: z24.number().min(0).max(1)
2438
+ })).min(1).max(64).optional(),
2392
2439
  probabilities: z24.array(z24.strictObject({
2393
2440
  value: z24.string().min(1).max(200),
2394
2441
  probability: z24.number().min(0).max(1)
2395
- })).min(1).max(64)
2396
- }),
2442
+ })).max(64)
2443
+ }).refine((row2) => {
2444
+ if (row2.independentOptions === void 0) {
2445
+ return row2.probabilities.length > 0 && row2.applicabilityProbability === void 0 && row2.irrelevanceProbability === void 0;
2446
+ }
2447
+ const hasSignals = row2.applicabilityProbability !== void 0 && row2.promptInjectionProbability !== void 0 && row2.irrelevanceProbability !== void 0;
2448
+ return row2.probabilities.length === 0 && row2.abstentionProbability === void 0 && hasSignals;
2449
+ }, "Judgment score contracts must not be mixed"),
2397
2450
  z24.strictObject({ status: z24.enum(["abstained", "timeout", "malformed", "review_required"]) })
2398
2451
  ]);
2399
2452
  var DraftNormalizedEvidenceSchema = z24.strictObject({
@@ -2571,22 +2624,22 @@ var DraftPrimitiveMappingSchema = z26.strictObject({
2571
2624
  caseId: id,
2572
2625
  rows: z26.array(row).min(requiredAuthorityPrimitives.length).max(authorityPrimitives.length)
2573
2626
  }).superRefine((mapping, context3) => {
2574
- if (!coversAuthorityPrimitives(mapping.rows.map((entry2) => entry2.primitive))) {
2627
+ if (!coversAuthorityPrimitives(mapping.rows.map((entry3) => entry3.primitive))) {
2575
2628
  context3.addIssue({ code: "custom", path: ["rows"], message: "Every category is explicit" });
2576
2629
  }
2577
2630
  const seen = /* @__PURE__ */ new Set();
2578
- for (const [index, entry2] of mapping.rows.entries()) {
2631
+ for (const [index, entry3] of mapping.rows.entries()) {
2579
2632
  const path3 = ["rows", index];
2580
- if (seen.has(entry2.primitive)) {
2633
+ if (seen.has(entry3.primitive)) {
2581
2634
  context3.addIssue({ code: "custom", path: path3, message: "Duplicate primitive" });
2582
2635
  }
2583
- seen.add(entry2.primitive);
2584
- if (entry2.status !== "mapped") {
2636
+ seen.add(entry3.primitive);
2637
+ if (entry3.status !== "mapped") {
2585
2638
  continue;
2586
2639
  }
2587
2640
  const references = /* @__PURE__ */ new Set();
2588
- for (const [at, ref] of entry2.references.entries()) {
2589
- if (!kinds[entry2.primitive].includes(ref.kind)) {
2641
+ for (const [at, ref] of entry3.references.entries()) {
2642
+ if (!kinds[entry3.primitive].includes(ref.kind)) {
2590
2643
  context3.addIssue({
2591
2644
  code: "custom",
2592
2645
  path: [...path3, "references", at],
@@ -2606,7 +2659,7 @@ var DraftPrimitiveMappingSchema = z26.strictObject({
2606
2659
  }
2607
2660
  });
2608
2661
  function readObservation(input, ref) {
2609
- const index = input.observations.findIndex((entry2) => entry2.id === ref.observationId);
2662
+ const index = input.observations.findIndex((entry3) => entry3.id === ref.observationId);
2610
2663
  const observation2 = input.observations[index];
2611
2664
  if (!observation2) {
2612
2665
  return void 0;
@@ -2642,7 +2695,7 @@ function readReference(input, ref) {
2642
2695
  return { path: "expected", value: input.expected };
2643
2696
  }
2644
2697
  case "rule": {
2645
- const index = authority.rules.findIndex((entry2) => entry2.id === ref.ruleId);
2698
+ const index = authority.rules.findIndex((entry3) => entry3.id === ref.ruleId);
2646
2699
  const rule3 = authority.rules[index];
2647
2700
  return rule3 ? {
2648
2701
  path: `authority.rules.${index}`,
@@ -2671,18 +2724,18 @@ var DraftMappedCaseSchema = z26.strictObject({
2671
2724
  message: "Mapping belongs to a different case"
2672
2725
  });
2673
2726
  }
2674
- for (const [index, entry2] of mapping.rows.entries()) {
2675
- if (entry2.status !== "mapped") {
2727
+ for (const [index, entry3] of mapping.rows.entries()) {
2728
+ if (entry3.status !== "mapped") {
2676
2729
  continue;
2677
2730
  }
2678
- if (entry2.primitive === "gaps" && input.expected.state === "ready") {
2731
+ if (entry3.primitive === "gaps" && input.expected.state === "ready") {
2679
2732
  context3.addIssue({
2680
2733
  code: "custom",
2681
2734
  path: ["mapping", "rows", index],
2682
2735
  message: "Ready expectation cannot demonstrate an unresolved gap or conflict"
2683
2736
  });
2684
2737
  }
2685
- for (const [at, ref] of entry2.references.entries()) {
2738
+ for (const [at, ref] of entry3.references.entries()) {
2686
2739
  if (!readReference(input, ref)) {
2687
2740
  context3.addIssue({
2688
2741
  code: "custom",
@@ -2849,6 +2902,8 @@ var PackDraftBoundSchema = z29.union([
2849
2902
  z29.number(),
2850
2903
  CalendarDateSchema,
2851
2904
  z29.strictObject({ question: draftIdentifier, days: dayOffset }),
2905
+ z29.strictObject({ question: draftIdentifier, businessDays: dayOffset }),
2906
+ z29.strictObject({ question: draftIdentifier }),
2852
2907
  z29.strictObject({ decisionDate: dayOffset })
2853
2908
  ]);
2854
2909
  var PackDraftComparisonSchema = z29.strictObject({
@@ -2858,10 +2913,10 @@ var PackDraftComparisonSchema = z29.strictObject({
2858
2913
  gte: PackDraftBoundSchema.optional(),
2859
2914
  eq: PackDraftBoundSchema.optional(),
2860
2915
  quote: draftQuote
2861
- }).superRefine((value, context3) => {
2862
- const lower = Number(value.gt !== void 0) + Number(value.gte !== void 0);
2863
- const upper = Number(value.lt !== void 0) + Number(value.lte !== void 0);
2864
- const hasEquality = value.eq !== void 0;
2916
+ }).superRefine((value2, context3) => {
2917
+ const lower = Number(value2.gt !== void 0) + Number(value2.gte !== void 0);
2918
+ const upper = Number(value2.lt !== void 0) + Number(value2.lte !== void 0);
2919
+ const hasEquality = value2.eq !== void 0;
2865
2920
  if (lower + upper + Number(hasEquality) === 0) {
2866
2921
  context3.addIssue({ code: "custom", message: "Give a bound: lt, lte, gt, gte or eq" });
2867
2922
  } else if (lower > 1 || upper > 1) {
@@ -2876,6 +2931,9 @@ var PackDraftConditionSchema = z29.union([
2876
2931
  PackDraftComparisonSchema
2877
2932
  ]);
2878
2933
  var PackDraftConditionsSchema = z29.record(draftIdentifier, PackDraftConditionSchema);
2934
+ function isComparison(condition) {
2935
+ return typeof condition === "object" && !Array.isArray(condition);
2936
+ }
2879
2937
  var questionTypes = ["number", "date"];
2880
2938
  var typedQuestionFields = {
2881
2939
  type: z29.enum(questionTypes).optional(),
@@ -2885,6 +2943,66 @@ var typedQuestionFields = {
2885
2943
  minimum: z29.number().optional(),
2886
2944
  maximum: z29.number().optional()
2887
2945
  };
2946
+ function unitKindOf(unit) {
2947
+ if (unit === "percent") {
2948
+ return "percent";
2949
+ }
2950
+ return isKnownCurrency(unit) ? "currency" : "count";
2951
+ }
2952
+ function fieldIssue(question3, field) {
2953
+ return { path: [field], message: `A ${question3.type ?? "choice"} question has no ${field}` };
2954
+ }
2955
+ function fieldIssues(question3, allowed) {
2956
+ const fields = ["answers", "unit", "unitWords", "integer", "minimum", "maximum"];
2957
+ const present = fields.filter((field) => question3[field] !== void 0);
2958
+ return present.filter((field) => !allowed.includes(field)).map((field) => fieldIssue(question3, field));
2959
+ }
2960
+ function numberIssues(question3) {
2961
+ const issues = [];
2962
+ const { unit } = question3;
2963
+ if (unit === void 0) {
2964
+ return [
2965
+ {
2966
+ path: ["unit"],
2967
+ message: 'Give the unit: a currency code such as "USD", "percent", or a count noun'
2968
+ }
2969
+ ];
2970
+ }
2971
+ const kind = unitKindOf(unit);
2972
+ if (kind === "count" && !/^[a-z][a-z0-9_-]*$/u.test(unit)) {
2973
+ issues.push({
2974
+ path: ["unit"],
2975
+ message: 'Use a currency code such as "USD", "percent", or a lowercase count noun'
2976
+ });
2977
+ }
2978
+ if (kind === "count" && question3.unitWords === void 0) {
2979
+ issues.push({
2980
+ path: ["unitWords"],
2981
+ message: 'A count needs the words that name its unit next to its number, such as "claims"'
2982
+ });
2983
+ }
2984
+ if (kind !== "count" && question3.unitWords !== void 0) {
2985
+ issues.push({ path: ["unitWords"], message: "Only a count has unit words" });
2986
+ }
2987
+ const { minimum, maximum } = question3;
2988
+ if (minimum !== void 0 && maximum !== void 0 && minimum > maximum) {
2989
+ issues.push({ path: ["maximum"], message: "maximum is below minimum" });
2990
+ }
2991
+ return issues;
2992
+ }
2993
+ function questionIssues(question3) {
2994
+ if (question3.type === "number") {
2995
+ return [
2996
+ ...fieldIssues(question3, ["unit", "unitWords", "integer", "minimum", "maximum"]),
2997
+ ...numberIssues(question3)
2998
+ ];
2999
+ }
3000
+ if (question3.type === "date") {
3001
+ return fieldIssues(question3, []);
3002
+ }
3003
+ const missing = question3.answers === void 0 ? [{ path: ["answers"], message: "A choice question needs answers" }] : [];
3004
+ return [...fieldIssues(question3, ["answers"]), ...missing];
3005
+ }
2888
3006
  var declaredDateOrders = [
2889
3007
  "month-first",
2890
3008
  "day-first"
@@ -2894,7 +3012,51 @@ var packConventionFields = {
2894
3012
  dateOrder: z29.enum(declaredDateOrders).optional(),
2895
3013
  timeZone: z29.string().min(1).max(64).regex(/^[A-Za-z][A-Za-z0-9_+/-]*$/u, "Use an IANA time zone name, such as Europe/Paris").refine(isTimeZone, "Unknown IANA time zone").optional()
2896
3014
  };
2897
- var caseFactSchema = z29.union([draftValue, z29.number()]);
3015
+ var plainFact = z29.union([draftValue, z29.number()]);
3016
+ var heldFactSchema = z29.union([
3017
+ z29.strictObject({ missing: z29.literal(true) }),
3018
+ z29.strictObject({ stale: plainFact }),
3019
+ z29.strictObject({ review: plainFact }),
3020
+ z29.strictObject({ conflict: z29.tuple([plainFact, plainFact]) }).refine((fact) => fact.conflict[0] !== fact.conflict[1], "Conflicting readings must differ")
3021
+ ]);
3022
+ var caseFactSchema = z29.union([plainFact, heldFactSchema]);
3023
+ var heldStates = ["missing", "stale", "conflict", "review"];
3024
+ var weekdayNames = [
3025
+ "sunday",
3026
+ "monday",
3027
+ "tuesday",
3028
+ "wednesday",
3029
+ "thursday",
3030
+ "friday",
3031
+ "saturday"
3032
+ ];
3033
+ var calendarYear = z29.number().int().min(1900).max(2200);
3034
+ var PackDraftBusinessDaysSchema = z29.strictObject({
3035
+ workingDays: z29.array(z29.enum(weekdayNames)).min(1).max(7).refine(hasUniqueValues, "Duplicate working day"),
3036
+ quote: draftQuote,
3037
+ years: z29.strictObject({ from: calendarYear, through: calendarYear }),
3038
+ holidays: z29.array(z29.strictObject({ date: CalendarDateSchema, quote: draftQuote })).max(400).refine((rows) => hasUniqueValues(rows.map((row2) => row2.date)), "Duplicate holiday").optional()
3039
+ }).superRefine((calendar, context3) => {
3040
+ const { from, through } = calendar.years;
3041
+ if (through < from || through - from > 99) {
3042
+ context3.addIssue({
3043
+ code: "custom",
3044
+ path: ["years"],
3045
+ message: "years.through must be on or after years.from, within 100 years"
3046
+ });
3047
+ }
3048
+ const holidays = calendar.holidays ?? [];
3049
+ for (const [index, holiday] of holidays.entries()) {
3050
+ const year = Number(holiday.date.slice(0, 4));
3051
+ if (year < from || year > through) {
3052
+ context3.addIssue({
3053
+ code: "custom",
3054
+ path: ["holidays", index, "date"],
3055
+ message: "This holiday is outside the calendar's years"
3056
+ });
3057
+ }
3058
+ }
3059
+ });
2898
3060
  var caseDecisionDate = CalendarDateSchema.optional();
2899
3061
 
2900
3062
  // ../schemas/src/draft-pack-subjects.ts
@@ -3017,7 +3179,7 @@ var group = z31.strictObject({
3017
3179
  min: z31.number().int().min(0).max(64),
3018
3180
  max: z31.number().int().min(0).max(64),
3019
3181
  candidates: z31.array(candidate).max(64)
3020
- }).refine((value) => value.min <= value.max, "Group minimum exceeds maximum");
3182
+ }).refine((value2) => value2.min <= value2.max, "Group minimum exceeds maximum");
3021
3183
  function areSubjectsValid(subjects, isIsolated) {
3022
3184
  const types = new Set(subjects.types.map((row2) => row2.id));
3023
3185
  const job = subjects.types.find((row2) => row2.id === subjects.job);
@@ -3038,13 +3200,13 @@ function areSubjectsValid(subjects, isIsolated) {
3038
3200
  function areEscalationsValid(escalations, context3) {
3039
3201
  const { isIsolated, outcomes } = context3;
3040
3202
  const ids3 = new Set(escalations.routes.map((row2) => row2.id));
3041
- const named = [escalations.unresolved, escalations.attemptLimit].filter((id13) => id13 !== null);
3203
+ const named = [escalations.unresolved, escalations.attemptLimit].filter((id15) => id15 !== null);
3042
3204
  return [
3043
3205
  ids3.size === escalations.routes.length,
3044
3206
  escalations.routes.every((row2) => isIsolated(row2.entryId, "routing_jobs")),
3045
3207
  hasUniqueValues(escalations.outcomes.map((row2) => row2.outcome)),
3046
3208
  escalations.outcomes.every((row2) => ids3.has(row2.escalation) && outcomes.has(row2.outcome)),
3047
- named.every((id13) => ids3.has(id13))
3209
+ named.every((id15) => ids3.has(id15))
3048
3210
  ].every(Boolean);
3049
3211
  }
3050
3212
  function isGuideValid(guide, isIsolated) {
@@ -3060,10 +3222,10 @@ function subjectPlanIssues(plan) {
3060
3222
  const issues = [];
3061
3223
  const candidates = plan.groups.flatMap((item) => item.candidates);
3062
3224
  const isIsolated = (entryId, primitive) => {
3063
- const entry2 = plan.entries.find((row2) => row2.id === entryId);
3225
+ const entry3 = plan.entries.find((row2) => row2.id === entryId);
3064
3226
  return [
3065
- entry2?.primitive === primitive,
3066
- entry2?.dependencies.length === 0,
3227
+ entry3?.primitive === primitive,
3228
+ entry3?.dependencies.length === 0,
3067
3229
  !plan.requiredIds.includes(entryId),
3068
3230
  candidates.every((row2) => row2.entryId !== entryId),
3069
3231
  plan.entries.every((row2) => !row2.dependencies.includes(entryId))
@@ -3102,7 +3264,7 @@ var DraftContextSelectionPlanSchema = z31.strictObject({
3102
3264
  attempts: z31.strictObject({
3103
3265
  max: z31.number().int().min(1).max(10),
3104
3266
  withProgress: z31.number().int().min(1).max(10)
3105
- }).refine((value) => value.withProgress >= value.max, "withProgress below max").optional(),
3267
+ }).refine((value2) => value2.withProgress >= value2.max, "withProgress below max").optional(),
3106
3268
  entries: base2.entries,
3107
3269
  requiredIds: base2.requiredIds,
3108
3270
  budget: base2.budget,
@@ -3134,19 +3296,19 @@ var DraftContextSelectionPlanSchema = z31.strictObject({
3134
3296
  if (candidateIds.length > 64 || !hasUniqueIds(candidateIds) || !hasUniqueIds(plan.groups.map((item) => item.id)) || !hasUniqueIds(plan.entries.map((item) => item.id))) {
3135
3297
  context3.addIssue({ code: "custom", message: "Duplicate identities or too many candidates" });
3136
3298
  }
3137
- if (plan.requiredIds.some((id13) => candidateIds.includes(id13))) {
3299
+ if (plan.requiredIds.some((id15) => candidateIds.includes(id15))) {
3138
3300
  context3.addIssue({ code: "custom", message: "Global required root cannot be a candidate" });
3139
3301
  }
3140
3302
  const guidanceId = plan.unresolvedGuidanceEntryId;
3141
3303
  if (guidanceId === void 0) {
3142
3304
  return;
3143
3305
  }
3144
- const entry2 = plan.entries.find((row2) => row2.id === guidanceId);
3306
+ const entry3 = plan.entries.find((row2) => row2.id === guidanceId);
3145
3307
  if ([
3146
- !entry2,
3147
- entry2?.primitive !== "gaps",
3148
- entry2?.dependencies.length,
3149
- entry2?.conflictsWith.length,
3308
+ !entry3,
3309
+ entry3?.primitive !== "gaps",
3310
+ entry3?.dependencies.length,
3311
+ entry3?.conflictsWith.length,
3150
3312
  plan.requiredIds.includes(guidanceId),
3151
3313
  candidateIds.includes(guidanceId),
3152
3314
  plan.entries.some((row2) => row2.dependencies.includes(guidanceId))
@@ -3669,7 +3831,7 @@ var DraftApplicationTargetSchema = DraftApplicationScopeSchema.extend({
3669
3831
  action,
3670
3832
  resourceId: identifier18,
3671
3833
  jobId: identifier18.nullable()
3672
- }).refine((target) => target.action === "execute_job" === (target.jobId !== null), "Only job execution carries a job ID");
3834
+ }).refine((target2) => target2.action === "execute_job" === (target2.jobId !== null), "Only job execution carries a job ID");
3673
3835
  var DraftApplicationActorSchema = z43.strictObject({
3674
3836
  principalId: identifier18,
3675
3837
  organizationId: identifier18,
@@ -3725,7 +3887,20 @@ var DraftApplicationReleaseSchema = z43.strictObject({
3725
3887
  });
3726
3888
 
3727
3889
  // ../schemas/src/draft-hosted-application.ts
3728
- import { z as z53 } from "zod";
3890
+ import { z as z59 } from "zod";
3891
+
3892
+ // ../schemas/src/draft-decision-attempt.ts
3893
+ import { z as z44 } from "zod";
3894
+ var DecisionGraphAttemptSchema = z44.strictObject({
3895
+ schema: z44.literal("felspar.decision-attempt/v1"),
3896
+ executionId: z44.string().min(1).max(200),
3897
+ releaseId: z44.string().min(1).max(200),
3898
+ receiptDigest: z44.string().regex(/^sha256:[a-f0-9]{64}$/u),
3899
+ ordinal: z44.number().int().min(1).max(12),
3900
+ next: z44.enum(["decided", "retry", "escalate"]),
3901
+ remaining: z44.number().int().min(0).max(10),
3902
+ escalationId: z44.string().min(1).max(200).nullable()
3903
+ });
3729
3904
 
3730
3905
  // ../schemas/src/draft-source-instant.ts
3731
3906
  var localPattern = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?([^.\d].*)$/u;
@@ -3765,11 +3940,11 @@ function utcOf(local, offset) {
3765
3940
  const utc = date.toISOString();
3766
3941
  return utcYear.test(utc) ? utc.slice(0, 19) : null;
3767
3942
  }
3768
- function normalizedSourceInstant(value) {
3769
- if (value.length > sourceInstantMaxLength) {
3943
+ function normalizedSourceInstant(value2) {
3944
+ if (value2.length > sourceInstantMaxLength) {
3770
3945
  return null;
3771
3946
  }
3772
- const match = localPattern.exec(value);
3947
+ const match = localPattern.exec(value2);
3773
3948
  if (match === null) {
3774
3949
  return null;
3775
3950
  }
@@ -3795,62 +3970,62 @@ function normalizedSourceInstant(value) {
3795
3970
  }
3796
3971
 
3797
3972
  // ../schemas/src/draft-hosted-output-checks.ts
3798
- import { z as z49 } from "zod";
3973
+ import { z as z50 } from "zod";
3799
3974
 
3800
3975
  // ../schemas/src/draft-artifact-check-manifest.ts
3801
- import { z as z47 } from "zod";
3976
+ import { z as z48 } from "zod";
3802
3977
 
3803
3978
  // ../schemas/src/draft-artifact-lint-semantic.ts
3804
- import { z as z46 } from "zod";
3979
+ import { z as z47 } from "zod";
3805
3980
 
3806
3981
  // ../schemas/src/draft-claim-evaluation-recipe.ts
3807
- import { z as z45 } from "zod";
3982
+ import { z as z46 } from "zod";
3808
3983
 
3809
3984
  // ../schemas/src/draft-output-check.ts
3810
- import { z as z44 } from "zod";
3985
+ import { z as z45 } from "zod";
3811
3986
  var identifier19 = DraftContextPlanSchema.shape.job;
3812
3987
  var digest19 = DraftJobReceiptBodySchema.shape.inputDigest;
3813
- var byteLimit = z44.number().int().min(1).max(65536);
3814
- var text5 = z44.string().max(16384);
3815
- var sectionRule = z44.discriminatedUnion("check", [
3816
- z44.strictObject({ id: identifier19, check: z44.literal("text"), maxBytes: byteLimit }),
3817
- z44.strictObject({
3988
+ var byteLimit = z45.number().int().min(1).max(65536);
3989
+ var text5 = z45.string().max(16384);
3990
+ var sectionRule = z45.discriminatedUnion("check", [
3991
+ z45.strictObject({ id: identifier19, check: z45.literal("text"), maxBytes: byteLimit }),
3992
+ z45.strictObject({
3818
3993
  id: identifier19,
3819
- check: z44.literal("exact"),
3994
+ check: z45.literal("exact"),
3820
3995
  maxBytes: byteLimit,
3821
- alternatives: z44.array(text5.min(1).regex(/\S/u)).min(1).max(8).refine(hasUniqueValues)
3996
+ alternatives: z45.array(text5.min(1).regex(/\S/u)).min(1).max(8).refine(hasUniqueValues)
3822
3997
  })
3823
3998
  ]);
3824
3999
  var draftOutputCheckerContract = "felspar.structured-output-check/v1";
3825
- var DraftOutputContractSchema = z44.strictObject({
3826
- schema: z44.literal("felspar.output-contract.draft/v0"),
4000
+ var DraftOutputContractSchema = z45.strictObject({
4001
+ schema: z45.literal("felspar.output-contract.draft/v0"),
3827
4002
  id: identifier19,
3828
- version: z44.number().int().min(1).max(65535),
4003
+ version: z45.number().int().min(1).max(65535),
3829
4004
  compiledArtifactDigest: digest19,
3830
4005
  job: identifier19,
3831
4006
  trustDomain: identifier19,
3832
4007
  outputSurface: identifier19,
3833
4008
  maxBytes: byteLimit,
3834
- sections: z44.array(sectionRule).min(1).max(16)
4009
+ sections: z45.array(sectionRule).min(1).max(16)
3835
4010
  }).superRefine((contract, context3) => {
3836
4011
  if (!hasUniqueValues(contract.sections.map((section) => section.id))) {
3837
4012
  context3.addIssue({ code: "custom", message: "Duplicate output section rule" });
3838
4013
  }
3839
4014
  const encoder2 = new TextEncoder();
3840
4015
  for (const section of contract.sections) {
3841
- if (section.check === "exact" && section.alternatives.some((value) => encoder2.encode(value).byteLength > section.maxBytes)) {
4016
+ if (section.check === "exact" && section.alternatives.some((value2) => encoder2.encode(value2).byteLength > section.maxBytes)) {
3842
4017
  context3.addIssue({ code: "custom", message: "Exact alternative exceeds section budget" });
3843
4018
  }
3844
4019
  }
3845
4020
  });
3846
- var DraftStructuredOutputSchema = z44.strictObject({
3847
- schema: z44.literal("felspar.structured-output.draft/v0"),
4021
+ var DraftStructuredOutputSchema = z45.strictObject({
4022
+ schema: z45.literal("felspar.structured-output.draft/v0"),
3848
4023
  id: identifier19,
3849
4024
  revision: identifier19,
3850
- sections: z44.array(z44.strictObject({ id: identifier19, text: text5 })).max(32).refine((sections) => hasUniqueValues(sections.map((section) => section.id)))
4025
+ sections: z45.array(z45.strictObject({ id: identifier19, text: text5 })).max(32).refine((sections) => hasUniqueValues(sections.map((section) => section.id)))
3851
4026
  });
3852
- var DraftOutputCheckSchema = z44.strictObject({
3853
- schema: z44.literal("felspar.output-check.draft/v0"),
4027
+ var DraftOutputCheckSchema = z45.strictObject({
4028
+ schema: z45.literal("felspar.output-check.draft/v0"),
3854
4029
  execution: DraftJobExecutionSchema,
3855
4030
  expectedJobReceiptDigest: digest19,
3856
4031
  contractEntryId: identifier19,
@@ -3858,8 +4033,8 @@ var DraftOutputCheckSchema = z44.strictObject({
3858
4033
  output: DraftStructuredOutputSchema,
3859
4034
  expectedOutputDigest: digest19
3860
4035
  });
3861
- var DraftOutputDiagnosticSchema = z44.strictObject({
3862
- code: z44.enum([
4036
+ var DraftOutputDiagnosticSchema = z45.strictObject({
4037
+ code: z45.enum([
3863
4038
  "upstream_blocked",
3864
4039
  "contract_coverage_incomplete",
3865
4040
  "contract_invalid",
@@ -3872,13 +4047,13 @@ var DraftOutputDiagnosticSchema = z44.strictObject({
3872
4047
  ]),
3873
4048
  sectionId: identifier19.nullable()
3874
4049
  });
3875
- var DraftOutputReceiptBodySchema = z44.strictObject({
3876
- schema: z44.literal("felspar.output-receipt.draft/v0"),
3877
- authority: z44.literal("unapproved"),
3878
- checkerContract: z44.literal(draftOutputCheckerContract),
3879
- coverage: z44.literal("declared_structure_and_exact_text"),
3880
- semanticEvaluation: z44.literal("not_performed"),
3881
- actionAuthorized: z44.literal(false),
4050
+ var DraftOutputReceiptBodySchema = z45.strictObject({
4051
+ schema: z45.literal("felspar.output-receipt.draft/v0"),
4052
+ authority: z45.literal("unapproved"),
4053
+ checkerContract: z45.literal(draftOutputCheckerContract),
4054
+ coverage: z45.literal("declared_structure_and_exact_text"),
4055
+ semanticEvaluation: z45.literal("not_performed"),
4056
+ actionAuthorized: z45.literal(false),
3882
4057
  inputDigest: digest19,
3883
4058
  jobReceiptDigest: digest19,
3884
4059
  compiledArtifactDigest: digest19,
@@ -3887,39 +4062,39 @@ var DraftOutputReceiptBodySchema = z44.strictObject({
3887
4062
  outputDigest: digest19,
3888
4063
  outputId: identifier19,
3889
4064
  outputRevision: identifier19,
3890
- status: z44.enum(["checks_passed", "invalid", "blocked"]),
3891
- structuralOnlySectionIds: z44.array(identifier19).max(16),
3892
- diagnostics: z44.array(DraftOutputDiagnosticSchema).max(81)
4065
+ status: z45.enum(["checks_passed", "invalid", "blocked"]),
4066
+ structuralOnlySectionIds: z45.array(identifier19).max(16),
4067
+ diagnostics: z45.array(DraftOutputDiagnosticSchema).max(81)
3893
4068
  });
3894
4069
  var DraftOutputReceiptSchema = DraftOutputReceiptBodySchema.extend({
3895
4070
  receiptDigest: digest19
3896
4071
  });
3897
- var DraftOutputVerificationOptionsSchema = z44.strictObject({
4072
+ var DraftOutputVerificationOptionsSchema = z45.strictObject({
3898
4073
  expectedReceiptDigest: digest19
3899
4074
  });
3900
4075
 
3901
4076
  // ../schemas/src/draft-claim-evaluation-recipe.ts
3902
4077
  var scope = DraftOutputContractSchema.shape;
3903
4078
  var identifier20 = scope.id;
3904
- var text6 = z45.string().min(1).max(2048).regex(/\S/u);
3905
- var ids2 = z45.array(identifier20).max(8).refine(hasUniqueValues, "Duplicate identifier");
4079
+ var text6 = z46.string().min(1).max(2048).regex(/\S/u);
4080
+ var ids2 = z46.array(identifier20).max(8).refine(hasUniqueValues, "Duplicate identifier");
3906
4081
  var { judgment: judgment3 } = DraftNormalizedEvidenceSchema.shape.normalizations.element.shape;
3907
- var option = z45.strictObject({
4082
+ var option = z46.strictObject({
3908
4083
  value: judgment3.options[0].shape.probabilities.element.shape.value,
3909
4084
  meaning: text6,
3910
- effect: z45.enum(["satisfied", "violated", "unresolved"])
4085
+ effect: z46.enum(["satisfied", "violated", "unresolved"])
3911
4086
  });
3912
- var question = z45.strictObject({
4087
+ var question = z46.strictObject({
3913
4088
  id: identifier20,
3914
4089
  sectionIds: ids2.min(1),
3915
4090
  instructions: text6,
3916
4091
  authorityEntryIds: ids2.min(1),
3917
4092
  evidenceKeys: ids2,
3918
- options: z45.array(option).min(2).max(8).refine((items) => hasUniqueValues(items.map((item) => item.value)), "Duplicate option").refine((items) => items.some((item) => item.effect === "unresolved"), "Explicit unresolved option required"),
3919
- minimumSelectedProbability: z45.number().gt(0).max(1)
4093
+ options: z46.array(option).min(2).max(8).refine((items) => hasUniqueValues(items.map((item) => item.value)), "Duplicate option").refine((items) => items.some((item) => item.effect === "unresolved"), "Explicit unresolved option required"),
4094
+ minimumSelectedProbability: z46.number().gt(0).max(1)
3920
4095
  });
3921
- var DraftClaimEvaluationRecipeSchema = z45.strictObject({
3922
- schema: z45.literal("felspar.claim-evaluation-recipe.draft/v0"),
4096
+ var DraftClaimEvaluationRecipeSchema = z46.strictObject({
4097
+ schema: z46.literal("felspar.claim-evaluation-recipe.draft/v0"),
3923
4098
  id: identifier20,
3924
4099
  version: identifier20,
3925
4100
  compiledArtifactDigest: scope.compiledArtifactDigest,
@@ -3929,11 +4104,11 @@ var DraftClaimEvaluationRecipeSchema = z45.strictObject({
3929
4104
  evaluator: DraftEvaluatorContractSchema.shape.evaluator,
3930
4105
  calibration: DraftEvaluatorContractSchema.shape.calibration,
3931
4106
  probabilityContract: DraftEvaluatorContractSchema.shape.probabilityContract,
3932
- questions: z45.array(question).min(1).max(8).refine((items) => hasUniqueValues(items.map((item) => item.id)), "Duplicate question"),
3933
- limits: z45.strictObject({
3934
- maxRequests: z45.number().int().min(1).max(128),
3935
- maxRequestBytes: z45.number().int().min(1).max(16384),
3936
- maxTotalBytes: z45.number().int().min(1).max(65536)
4107
+ questions: z46.array(question).min(1).max(8).refine((items) => hasUniqueValues(items.map((item) => item.id)), "Duplicate question"),
4108
+ limits: z46.strictObject({
4109
+ maxRequests: z46.number().int().min(1).max(128),
4110
+ maxRequestBytes: z46.number().int().min(1).max(16384),
4111
+ maxTotalBytes: z46.number().int().min(1).max(65536)
3937
4112
  })
3938
4113
  });
3939
4114
 
@@ -3950,92 +4125,95 @@ var artifactSemanticLimits = {
3950
4125
  maxRequestBytes: 32768,
3951
4126
  maxTotalBytes: 16777216
3952
4127
  };
3953
- var ArtifactSemanticQuestionSchema = z46.strictObject({
4128
+ var ArtifactSemanticQuestionSchema = z47.strictObject({
3954
4129
  id: id3,
3955
4130
  instructions: recipeQuestion.instructions,
3956
4131
  options: recipeQuestion.options,
3957
4132
  minimumSelectedProbability: recipeQuestion.minimumSelectedProbability,
3958
- aggregation: z46.enum(["prohibit", "require", "match"])
4133
+ aggregation: z47.enum(["prohibit", "require", "match"])
3959
4134
  });
3960
- var ArtifactSemanticRecipeSchema = z46.strictObject({
4135
+ var ArtifactSemanticRecipeSchema = z47.strictObject({
3961
4136
  evaluator: recipe.evaluator,
3962
4137
  calibration: recipe.calibration,
3963
4138
  probabilityContract: recipe.probabilityContract,
3964
- questions: z46.array(ArtifactSemanticQuestionSchema).min(1).max(artifactSemanticLimits.maxQuestions),
3965
- limits: z46.strictObject({
3966
- maxEvaluations: z46.number().int().min(1).max(artifactSemanticLimits.maxEvaluations),
3967
- maxRequestBytes: z46.number().int().min(1).max(artifactSemanticLimits.maxRequestBytes),
3968
- maxTotalBytes: z46.number().int().min(1).max(artifactSemanticLimits.maxTotalBytes)
4139
+ questions: z47.array(ArtifactSemanticQuestionSchema).min(1).max(artifactSemanticLimits.maxQuestions),
4140
+ limits: z47.strictObject({
4141
+ maxEvaluations: z47.number().int().min(1).max(artifactSemanticLimits.maxEvaluations),
4142
+ maxRequestBytes: z47.number().int().min(1).max(artifactSemanticLimits.maxRequestBytes),
4143
+ maxTotalBytes: z47.number().int().min(1).max(artifactSemanticLimits.maxTotalBytes)
3969
4144
  })
3970
4145
  });
3971
- var ArtifactSemanticRequestSchema = z46.strictObject({
3972
- schema: z46.literal("felspar.artifact-question.draft/v1"),
4146
+ var ArtifactSemanticRequestSchema = z47.strictObject({
4147
+ schema: z47.literal("felspar.artifact-question.draft/v1"),
3973
4148
  preparationDigest: digest20,
3974
4149
  unitId: id3,
3975
4150
  sectionId: id3,
3976
- start: z46.number().int().min(0),
3977
- end: z46.number().int().min(1),
4151
+ start: z47.number().int().min(0),
4152
+ end: z47.number().int().min(1),
3978
4153
  textDigest: digest20,
3979
- text: z46.string().min(1),
4154
+ text: z47.string().min(1),
3980
4155
  questionId: id3,
3981
4156
  instructions: recipeQuestion.instructions,
3982
- options: z46.array(z46.strictObject({ value: z46.string(), meaning: z46.string() })).min(2).max(8),
3983
- policy: z46.array(z46.strictObject({ sourceLocator: z46.string(), text: z46.string() })).min(1),
4157
+ options: z47.array(z47.strictObject({ value: z47.string(), meaning: z47.string() })).min(2).max(8),
4158
+ policy: z47.array(z47.strictObject({ sourceLocator: z47.string(), text: z47.string() })).min(1),
3984
4159
  evaluator: recipe.evaluator,
3985
4160
  calibration: recipe.calibration,
3986
4161
  requestDigest: digest20
3987
4162
  });
3988
- var ArtifactSemanticResponseSchema = z46.strictObject({
3989
- schema: z46.literal("felspar.artifact-question-response.draft/v1"),
4163
+ var artifactInjectionScreen = z47.literal("paragraph-injection/v1");
4164
+ var ArtifactSemanticResponseSchema = z47.strictObject({
4165
+ schema: z47.literal("felspar.artifact-question-response.draft/v1"),
4166
+ screen: artifactInjectionScreen.optional(),
3990
4167
  preparationDigest: digest20,
3991
4168
  evaluator: recipe.evaluator,
3992
4169
  calibrationDigest: digest20,
3993
- answers: z46.array(z46.strictObject({ unitId: id3, questionId: id3, requestDigest: digest20, judgment: judgment4 })).max(artifactSemanticLimits.maxEvaluations)
4170
+ answers: z47.array(z47.strictObject({ unitId: id3, questionId: id3, requestDigest: digest20, judgment: judgment4 })).max(artifactSemanticLimits.maxEvaluations)
3994
4171
  });
3995
- var ArtifactSemanticJudgmentSchema = z46.strictObject({
4172
+ var ArtifactSemanticJudgmentSchema = z47.strictObject({
3996
4173
  unitId: id3,
3997
4174
  sectionId: id3,
3998
- start: z46.number().int().min(0),
3999
- end: z46.number().int().min(1),
4175
+ start: z47.number().int().min(0),
4176
+ end: z47.number().int().min(1),
4000
4177
  textDigest: digest20,
4001
4178
  questionId: id3,
4002
4179
  requestDigest: digest20,
4003
4180
  judgment: judgment4.nullable(),
4004
- value: z46.string().nullable(),
4005
- effect: z46.enum(["satisfied", "violated", "unresolved", "unavailable", "not_stated"]),
4006
- reasons: z46.array(z46.string().max(128)).max(8)
4181
+ value: z47.string().nullable(),
4182
+ effect: z47.enum(["satisfied", "violated", "unresolved", "unavailable", "not_stated"]),
4183
+ reasons: z47.array(z47.string().max(128)).max(8)
4007
4184
  });
4008
- var ArtifactSemanticRecordSchema = z46.strictObject({
4009
- state: z46.enum(["ready", "skipped", "over_budget", "not_evaluated"]),
4185
+ var ArtifactSemanticRecordSchema = z47.strictObject({
4186
+ state: z47.enum(["ready", "skipped", "over_budget", "not_evaluated"]),
4187
+ screen: artifactInjectionScreen.optional(),
4010
4188
  preparationDigest: digest20,
4011
4189
  evaluator: ArtifactSemanticRecipeSchema.shape.evaluator,
4012
4190
  calibrationDigest: digest20,
4013
4191
  probabilityContract: ArtifactSemanticRecipeSchema.shape.probabilityContract,
4014
- questions: z46.array(ArtifactSemanticQuestionSchema.pick({
4192
+ questions: z47.array(ArtifactSemanticQuestionSchema.pick({
4015
4193
  id: true,
4016
4194
  minimumSelectedProbability: true,
4017
4195
  aggregation: true
4018
4196
  }).extend({
4019
4197
  checkId: id3,
4020
4198
  anchorSectionId: id3,
4021
- sectionsAvailable: z46.boolean(),
4022
- units: z46.number().int().min(0).max(artifactSemanticLimits.maxEvaluations),
4023
- options: z46.array(z46.strictObject({
4199
+ sectionsAvailable: z47.boolean(),
4200
+ units: z47.number().int().min(0).max(artifactSemanticLimits.maxEvaluations),
4201
+ options: z47.array(z47.strictObject({
4024
4202
  value: ArtifactSemanticQuestionSchema.shape.options.element.shape.value,
4025
- effect: z46.enum(["satisfied", "violated", "unresolved", "not_stated"])
4203
+ effect: z47.enum(["satisfied", "violated", "unresolved", "not_stated"])
4026
4204
  })).min(2).max(8)
4027
4205
  })).max(artifactSemanticLimits.maxQuestions),
4028
- judgments: z46.array(ArtifactSemanticJudgmentSchema).max(artifactSemanticLimits.maxEvaluations)
4206
+ judgments: z47.array(ArtifactSemanticJudgmentSchema).max(artifactSemanticLimits.maxEvaluations)
4029
4207
  });
4030
4208
  var caseNotStated = "not_stated";
4031
4209
  var abstain = "cannot_determine";
4032
- function isMatchOf(question2, check) {
4033
- if (check?.kind !== "case_answer" || question2.aggregation !== "match") {
4034
- return check?.kind === "semantic_question" && question2.aggregation !== "match";
4210
+ function isMatchOf(question3, check) {
4211
+ if (check?.kind !== "case_answer" || question3.aggregation !== "match") {
4212
+ return check?.kind === "semantic_question" && question3.aggregation !== "match";
4035
4213
  }
4036
- const offered = new Set(question2.options.map((option2) => option2.value));
4214
+ const offered = new Set(question3.options.map((option2) => option2.value));
4037
4215
  const expected2 = [...(check.answers ?? []).map((row2) => row2.value), caseNotStated, abstain];
4038
- return offered.size === question2.options.length && offered.size === expected2.length && expected2.every((value) => offered.has(value));
4216
+ return offered.size === question3.options.length && offered.size === expected2.length && expected2.every((value2) => offered.has(value2));
4039
4217
  }
4040
4218
  function isAsking(check) {
4041
4219
  const isAsker = check.kind === "semantic_question" || check.kind === "case_answer";
@@ -4045,22 +4223,22 @@ function inspectSemantic(manifest2, issue) {
4045
4223
  const askers = manifest2.checks.filter(isAsking);
4046
4224
  const asked = askers.map((check) => check.questionId ?? "");
4047
4225
  const questions = manifest2.semantic?.questions ?? [];
4048
- for (const question2 of questions) {
4049
- const asker = askers.find((check) => check.questionId === question2.id);
4050
- if (!isMatchOf(question2, asker)) {
4226
+ for (const question3 of questions) {
4227
+ const asker = askers.find((check) => check.questionId === question3.id);
4228
+ if (!isMatchOf(question3, asker)) {
4051
4229
  issue("A semantic question's aggregation differs from the check that asks it");
4052
4230
  }
4053
4231
  }
4054
4232
  const distinctAsked = new Set(asked);
4055
- if (distinctAsked.size !== asked.length || asked.length !== questions.length || questions.some((question2) => !distinctAsked.has(question2.id))) {
4233
+ if (distinctAsked.size !== asked.length || asked.length !== questions.length || questions.some((question3) => !distinctAsked.has(question3.id))) {
4056
4234
  issue("Every released semantic question is asked by exactly one check");
4057
4235
  }
4058
- for (const question2 of questions) {
4059
- if (question2.aggregation === "match") {
4236
+ for (const question3 of questions) {
4237
+ if (question3.aggregation === "match") {
4060
4238
  continue;
4061
4239
  }
4062
- const effects = new Set(question2.options.map((option2) => option2.effect));
4063
- const needed = question2.aggregation === "prohibit" ? "violated" : "satisfied";
4240
+ const effects = new Set(question3.options.map((option2) => option2.effect));
4241
+ const needed = question3.aggregation === "prohibit" ? "violated" : "satisfied";
4064
4242
  if (!effects.has(needed)) {
4065
4243
  issue("A semantic question needs an option that can decide its aggregation");
4066
4244
  }
@@ -4080,15 +4258,15 @@ var artifactLintLimits = {
4080
4258
  maxLiteralUnits: 512,
4081
4259
  maxOccurrencesPerCheck: 16
4082
4260
  };
4083
- function isWellFormedText(value) {
4084
- return !/\p{Cs}/u.test(value);
4261
+ function isWellFormedText(value2) {
4262
+ return !/\p{Cs}/u.test(value2);
4085
4263
  }
4086
- var literal = z47.string().min(1).max(artifactLintLimits.maxLiteralUnits).regex(/\S/u).refine(isWellFormedText);
4087
- var passage = z47.strictObject({
4088
- sourceLocator: z47.string().min(1).max(4096).regex(/\S/u),
4264
+ var literal = z48.string().min(1).max(artifactLintLimits.maxLiteralUnits).regex(/\S/u).refine(isWellFormedText);
4265
+ var passage = z48.strictObject({
4266
+ sourceLocator: z48.string().min(1).max(4096).regex(/\S/u),
4089
4267
  contentDigest: digest21
4090
4268
  });
4091
- var common = { id: id4, required: z47.boolean(), specification: passage };
4269
+ var common = { id: id4, required: z48.boolean(), specification: passage };
4092
4270
  var artifactCheckKinds = [
4093
4271
  "section",
4094
4272
  "required_wording",
@@ -4101,64 +4279,64 @@ var artifactLintMediaTypes = [
4101
4279
  "text/plain",
4102
4280
  "application/vnd.felspar.structured-output+json"
4103
4281
  ];
4104
- var sectionTargets = z47.array(id4).min(1).max(artifactLintLimits.maxSections);
4105
- var ArtifactCheckSchema = z47.discriminatedUnion("kind", [
4106
- z47.strictObject({ ...common, kind: z47.literal("section"), sectionId: id4 }),
4107
- z47.strictObject({
4282
+ var sectionTargets = z48.array(id4).min(1).max(artifactLintLimits.maxSections);
4283
+ var ArtifactCheckSchema = z48.discriminatedUnion("kind", [
4284
+ z48.strictObject({ ...common, kind: z48.literal("section"), sectionId: id4 }),
4285
+ z48.strictObject({
4108
4286
  ...common,
4109
- kind: z47.literal("required_wording"),
4287
+ kind: z48.literal("required_wording"),
4110
4288
  sectionId: id4,
4111
- alternatives: z47.array(literal).min(1).max(artifactLintLimits.maxAlternatives)
4289
+ alternatives: z48.array(literal).min(1).max(artifactLintLimits.maxAlternatives)
4112
4290
  }),
4113
- z47.strictObject({
4291
+ z48.strictObject({
4114
4292
  ...common,
4115
- kind: z47.literal("prohibited_literal"),
4293
+ kind: z48.literal("prohibited_literal"),
4116
4294
  sectionIds: sectionTargets,
4117
- literals: z47.array(literal).min(1).max(artifactLintLimits.maxLiterals)
4295
+ literals: z48.array(literal).min(1).max(artifactLintLimits.maxLiterals)
4118
4296
  }),
4119
- z47.strictObject({
4297
+ z48.strictObject({
4120
4298
  ...common,
4121
- kind: z47.literal("field_value"),
4299
+ kind: z48.literal("field_value"),
4122
4300
  sectionId: id4,
4123
- label: z47.string().min(1).max(128).regex(/^[^\s:](?:[^\n\r:]*[^\s:])?$/u).refine(isWellFormedText),
4124
- unit: z47.string().min(1).max(32).regex(/^\S+$/u).refine(isWellFormedText).nullable(),
4301
+ label: z48.string().min(1).max(128).regex(/^[^\s:](?:[^\n\r:]*[^\s:])?$/u).refine(isWellFormedText),
4302
+ unit: z48.string().min(1).max(32).regex(/^\S+$/u).refine(isWellFormedText).nullable(),
4125
4303
  evidenceKey: id4,
4126
- comparator: z47.enum(["eq", "lte", "gte"])
4304
+ comparator: z48.enum(["eq", "lte", "gte"])
4127
4305
  }),
4128
- z47.strictObject({
4306
+ z48.strictObject({
4129
4307
  ...common,
4130
- kind: z47.literal("case_answer"),
4308
+ kind: z48.literal("case_answer"),
4131
4309
  sectionIds: sectionTargets,
4132
- fact: z47.discriminatedUnion("comparison", [
4133
- z47.strictObject({ key: id4, comparison: z47.literal("choice") }),
4134
- z47.strictObject({
4310
+ fact: z48.discriminatedUnion("comparison", [
4311
+ z48.strictObject({ key: id4, comparison: z48.literal("choice") }),
4312
+ z48.strictObject({
4135
4313
  key: id4,
4136
- comparison: z47.literal("number"),
4314
+ comparison: z48.literal("number"),
4137
4315
  reader: ExactReaderSchema.options[0]
4138
4316
  }),
4139
- z47.strictObject({
4317
+ z48.strictObject({
4140
4318
  key: id4,
4141
- comparison: z47.literal("date"),
4319
+ comparison: z48.literal("date"),
4142
4320
  reader: ExactReaderSchema.options[1]
4143
4321
  })
4144
4322
  ]),
4145
- answers: z47.array(z47.strictObject({
4323
+ answers: z48.array(z48.strictObject({
4146
4324
  value: id4,
4147
- wording: z47.array(literal).max(artifactLintLimits.maxAlternatives)
4325
+ wording: z48.array(literal).max(artifactLintLimits.maxAlternatives)
4148
4326
  })).max(artifactLintLimits.maxLiterals),
4149
4327
  questionId: id4.nullable()
4150
4328
  }),
4151
- z47.strictObject({
4329
+ z48.strictObject({
4152
4330
  ...common,
4153
- kind: z47.literal("semantic_question"),
4331
+ kind: z48.literal("semantic_question"),
4154
4332
  sectionIds: sectionTargets,
4155
4333
  questionId: id4
4156
4334
  })
4157
4335
  ]);
4158
- var sectionDeclaration = z47.strictObject({
4336
+ var sectionDeclaration = z48.strictObject({
4159
4337
  id: id4,
4160
- heading: z47.string().min(1).max(256).regex(/\S/u).refine((value) => !/[\n\r]/u.test(value) && isWellFormedText(value)).nullable(),
4161
- maxUnits: z47.number().int().min(1).max(artifactLintLimits.maxSectionUnits)
4338
+ heading: z48.string().min(1).max(256).regex(/\S/u).refine((value2) => !/[\n\r]/u.test(value2) && isWellFormedText(value2)).nullable(),
4339
+ maxUnits: z48.number().int().min(1).max(artifactLintLimits.maxSectionUnits)
4162
4340
  });
4163
4341
  function caseAnswerIssues(checks) {
4164
4342
  const issues = [];
@@ -4178,18 +4356,18 @@ function caseAnswerIssues(checks) {
4178
4356
  }
4179
4357
  return issues;
4180
4358
  }
4181
- var ArtifactCheckManifestSchema = z47.strictObject({
4182
- schema: z47.literal("felspar.artifact-check-manifest.draft/v1"),
4359
+ var ArtifactCheckManifestSchema = z48.strictObject({
4360
+ schema: z48.literal("felspar.artifact-check-manifest.draft/v1"),
4183
4361
  id: id4,
4184
- version: z47.number().int().min(1).max(65535),
4362
+ version: z48.number().int().min(1).max(65535),
4185
4363
  jobId: id4,
4186
4364
  trustDomain: id4,
4187
- contract: z47.strictObject({ id: id4, digest: digest21 }),
4188
- parser: z47.enum(["body", "headings"]),
4189
- maxBytes: z47.number().int().min(1).max(artifactLintLimits.maxTotalBytes),
4190
- sections: z47.array(sectionDeclaration).min(1).max(artifactLintLimits.maxSections),
4191
- caseContext: z47.enum(["required", "not_required"]),
4192
- checks: z47.array(ArtifactCheckSchema).min(1).max(artifactLintLimits.maxChecks),
4365
+ contract: z48.strictObject({ id: id4, digest: digest21 }),
4366
+ parser: z48.enum(["body", "headings"]),
4367
+ maxBytes: z48.number().int().min(1).max(artifactLintLimits.maxTotalBytes),
4368
+ sections: z48.array(sectionDeclaration).min(1).max(artifactLintLimits.maxSections),
4369
+ caseContext: z48.enum(["required", "not_required"]),
4370
+ checks: z48.array(ArtifactCheckSchema).min(1).max(artifactLintLimits.maxChecks),
4193
4371
  semantic: ArtifactSemanticRecipeSchema.nullable()
4194
4372
  }).superRefine((manifest2, context3) => {
4195
4373
  const issue = (message) => {
@@ -4234,11 +4412,11 @@ var ArtifactCheckManifestSchema = z47.strictObject({
4234
4412
  var ArtifactSpecificationSchema = passage;
4235
4413
 
4236
4414
  // ../schemas/src/draft-job-obligations-manifest.ts
4237
- import { z as z48 } from "zod";
4415
+ import { z as z49 } from "zod";
4238
4416
  var id5 = DraftApplicationScopeSchema.shape.authorityId;
4239
4417
  var digest22 = DraftJobReceiptSchema.shape.receiptDigest;
4240
4418
  var passage2 = {
4241
- sourceLocator: z48.string().min(1).max(4096).regex(/\S/u),
4419
+ sourceLocator: z49.string().min(1).max(4096).regex(/\S/u),
4242
4420
  contentDigest: digest22
4243
4421
  };
4244
4422
  var jobObligationsLimits = {
@@ -4249,41 +4427,41 @@ var jobObligationsLimits = {
4249
4427
  maxApprovalTargets: 16,
4250
4428
  maxManifestBytes: 65536
4251
4429
  };
4252
- var DraftJobObligationsScopeSchema = z48.strictObject({
4430
+ var DraftJobObligationsScopeSchema = z49.strictObject({
4253
4431
  purposeRef: id5,
4254
4432
  useRef: id5.nullable()
4255
4433
  });
4256
- var artifact = z48.strictObject({
4434
+ var artifact = z49.strictObject({
4257
4435
  id: id5,
4258
4436
  role: id5,
4259
- contract: z48.strictObject({ id: id5, digest: digest22 }),
4437
+ contract: z49.strictObject({ id: id5, digest: digest22 }),
4260
4438
  ...passage2
4261
4439
  });
4262
- var approval = z48.strictObject({
4440
+ var approval = z49.strictObject({
4263
4441
  id: id5,
4264
- policy: z48.strictObject({ id: id5, ...passage2 }),
4265
- phase: z48.enum(["before_decision", "before_generation", "before_use"]),
4266
- appliesTo: z48.array(z48.discriminatedUnion("kind", [
4267
- z48.strictObject({ kind: z48.literal("decision") }),
4268
- z48.strictObject({ kind: z48.literal("artifact"), id: id5 }),
4269
- z48.strictObject({ kind: z48.literal("use") })
4442
+ policy: z49.strictObject({ id: id5, ...passage2 }),
4443
+ phase: z49.enum(["before_decision", "before_generation", "before_use"]),
4444
+ appliesTo: z49.array(z49.discriminatedUnion("kind", [
4445
+ z49.strictObject({ kind: z49.literal("decision") }),
4446
+ z49.strictObject({ kind: z49.literal("artifact"), id: id5 }),
4447
+ z49.strictObject({ kind: z49.literal("use") })
4270
4448
  ])).min(1).max(jobObligationsLimits.maxApprovalTargets)
4271
4449
  });
4272
- var outcome = z48.strictObject({
4450
+ var outcome = z49.strictObject({
4273
4451
  outcomeId: id5,
4274
4452
  ...passage2,
4275
- contextRequired: z48.boolean(),
4276
- artifacts: z48.array(artifact).max(jobObligationsLimits.maxArtifacts),
4277
- approvals: z48.array(approval).max(jobObligationsLimits.maxApprovals)
4453
+ contextRequired: z49.boolean(),
4454
+ artifacts: z49.array(artifact).max(jobObligationsLimits.maxArtifacts),
4455
+ approvals: z49.array(approval).max(jobObligationsLimits.maxApprovals)
4278
4456
  });
4279
- var manifest = z48.strictObject({
4280
- schema: z48.literal("felspar.job-obligations.draft/v0"),
4457
+ var manifest = z49.strictObject({
4458
+ schema: z49.literal("felspar.job-obligations.draft/v0"),
4281
4459
  jobId: id5,
4282
4460
  trustDomain: id5,
4283
4461
  scope: DraftJobObligationsScopeSchema,
4284
4462
  source: DraftSourceReferenceSchema,
4285
- contracts: z48.array(z48.strictObject({ id: id5, ...passage2 })).max(jobObligationsLimits.maxContracts),
4286
- outcomes: z48.array(outcome).min(1).max(jobObligationsLimits.maxOutcomes)
4463
+ contracts: z49.array(z49.strictObject({ id: id5, ...passage2 })).max(jobObligationsLimits.maxContracts),
4464
+ outcomes: z49.array(outcome).min(1).max(jobObligationsLimits.maxOutcomes)
4287
4465
  });
4288
4466
  function unique3(values, context3, path3) {
4289
4467
  const distinct = new Set(values);
@@ -4291,16 +4469,16 @@ function unique3(values, context3, path3) {
4291
4469
  context3.addIssue({ code: "custom", path: path3, message: "Duplicate obligation identity or target" });
4292
4470
  }
4293
4471
  }
4294
- function isApprovalTargetValid(item, target, useRef) {
4472
+ function isApprovalTargetValid(item, target2, useRef) {
4295
4473
  switch (item.phase) {
4296
4474
  case "before_decision": {
4297
- return target.kind === "decision";
4475
+ return target2.kind === "decision";
4298
4476
  }
4299
4477
  case "before_generation": {
4300
- return target.kind === "artifact";
4478
+ return target2.kind === "artifact";
4301
4479
  }
4302
4480
  case "before_use": {
4303
- return target.kind === "artifact" || target.kind === "use" && useRef !== null;
4481
+ return target2.kind === "artifact" || target2.kind === "use" && useRef !== null;
4304
4482
  }
4305
4483
  default: {
4306
4484
  return false;
@@ -4308,11 +4486,11 @@ function isApprovalTargetValid(item, target, useRef) {
4308
4486
  }
4309
4487
  }
4310
4488
  function inspectApproval(item, binding, context3) {
4311
- unique3(item.appliesTo.map((target) => JSON.stringify(target)), context3, ["approvals", item.id]);
4312
- const artifacts = new Set(binding.selected.artifacts.map((entry2) => entry2.id));
4313
- for (const target of item.appliesTo) {
4314
- const isKnown = target.kind !== "artifact" || artifacts.has(target.id);
4315
- const isValid = isApprovalTargetValid(item, target, binding.scope.useRef);
4489
+ unique3(item.appliesTo.map((target2) => JSON.stringify(target2)), context3, ["approvals", item.id]);
4490
+ const artifacts = new Set(binding.selected.artifacts.map((entry3) => entry3.id));
4491
+ for (const target2 of item.appliesTo) {
4492
+ const isKnown = target2.kind !== "artifact" || artifacts.has(target2.id);
4493
+ const isValid = isApprovalTargetValid(item, target2, binding.scope.useRef);
4316
4494
  if (!isKnown || !isValid) {
4317
4495
  context3.addIssue({
4318
4496
  code: "custom",
@@ -4322,18 +4500,18 @@ function inspectApproval(item, binding, context3) {
4322
4500
  }
4323
4501
  }
4324
4502
  }
4325
- function inspectManifest(value, context3) {
4503
+ function inspectManifest(value2, context3) {
4326
4504
  if (context3.issues.length > 0) {
4327
4505
  return;
4328
4506
  }
4329
- unique3(value.contracts.map((entry2) => entry2.id), context3, ["contracts"]);
4330
- unique3(value.outcomes.map((entry2) => entry2.outcomeId), context3, ["outcomes"]);
4331
- const contracts = new Map(value.contracts.map((entry2) => [entry2.id, entry2.contentDigest]));
4332
- for (const selected of value.outcomes) {
4333
- unique3(selected.artifacts.map((entry2) => entry2.id), context3, ["outcomes", selected.outcomeId, "artifacts"]);
4334
- unique3(selected.approvals.map((entry2) => entry2.id), context3, ["outcomes", selected.outcomeId, "approvals"]);
4335
- for (const entry2 of selected.artifacts) {
4336
- if (contracts.get(entry2.contract.id) !== entry2.contract.digest) {
4507
+ unique3(value2.contracts.map((entry3) => entry3.id), context3, ["contracts"]);
4508
+ unique3(value2.outcomes.map((entry3) => entry3.outcomeId), context3, ["outcomes"]);
4509
+ const contracts = new Map(value2.contracts.map((entry3) => [entry3.id, entry3.contentDigest]));
4510
+ for (const selected of value2.outcomes) {
4511
+ unique3(selected.artifacts.map((entry3) => entry3.id), context3, ["outcomes", selected.outcomeId, "artifacts"]);
4512
+ unique3(selected.approvals.map((entry3) => entry3.id), context3, ["outcomes", selected.outcomeId, "approvals"]);
4513
+ for (const entry3 of selected.artifacts) {
4514
+ if (contracts.get(entry3.contract.id) !== entry3.contract.digest) {
4337
4515
  context3.addIssue({
4338
4516
  code: "custom",
4339
4517
  message: "Dangling or mismatched specification reference"
@@ -4341,11 +4519,11 @@ function inspectManifest(value, context3) {
4341
4519
  }
4342
4520
  }
4343
4521
  for (const item of selected.approvals) {
4344
- inspectApproval(item, { selected, scope: value.scope }, context3);
4522
+ inspectApproval(item, { selected, scope: value2.scope }, context3);
4345
4523
  }
4346
4524
  }
4347
4525
  const encoder2 = new TextEncoder();
4348
- if (encoder2.encode(JSON.stringify(value)).length > jobObligationsLimits.maxManifestBytes) {
4526
+ if (encoder2.encode(JSON.stringify(value2)).length > jobObligationsLimits.maxManifestBytes) {
4349
4527
  context3.addIssue({ code: "custom", message: "Obligations manifest byte limit exceeded" });
4350
4528
  }
4351
4529
  }
@@ -4354,19 +4532,19 @@ var DraftJobObligationsOutcomeSchema = outcome;
4354
4532
 
4355
4533
  // ../schemas/src/draft-hosted-output-checks.ts
4356
4534
  var hostedOutputCheckLimits = { maxOutputs: 8 };
4357
- var HostedOutputChecksSchema = z49.strictObject({
4358
- schema: z49.literal("felspar.output-checks.draft/v0"),
4535
+ var HostedOutputChecksSchema = z50.strictObject({
4536
+ schema: z50.literal("felspar.output-checks.draft/v0"),
4359
4537
  obligations: DraftJobObligationsSchema,
4360
- manifests: z49.array(ArtifactCheckManifestSchema).min(1).max(hostedOutputCheckLimits.maxOutputs)
4361
- }).superRefine((value, context3) => {
4538
+ manifests: z50.array(ArtifactCheckManifestSchema).min(1).max(hostedOutputCheckLimits.maxOutputs)
4539
+ }).superRefine((value2, context3) => {
4362
4540
  if (context3.issues.length > 0) {
4363
4541
  return;
4364
4542
  }
4365
4543
  const issue = (message) => {
4366
4544
  context3.addIssue({ code: "custom", message });
4367
4545
  };
4368
- const { obligations, manifests } = value;
4369
- const contracts = new Map(obligations.contracts.map((entry2) => [entry2.id, entry2]));
4546
+ const { obligations, manifests } = value2;
4547
+ const contracts = new Map(obligations.contracts.map((entry3) => [entry3.id, entry3]));
4370
4548
  const checked = new Set(manifests.map((manifest2) => manifest2.contract.id));
4371
4549
  if (checked.size !== manifests.length) {
4372
4550
  issue("One manifest per output contract");
@@ -4377,20 +4555,20 @@ var HostedOutputChecksSchema = z49.strictObject({
4377
4555
  issue("A manifest differs from its job or contract");
4378
4556
  }
4379
4557
  }
4380
- const required = obligations.outcomes.flatMap((entry2) => entry2.artifacts.map((artifact2) => artifact2.contract.id));
4558
+ const required = obligations.outcomes.flatMap((entry3) => entry3.artifacts.map((artifact2) => artifact2.contract.id));
4381
4559
  if (required.some((contractId) => !checked.has(contractId)) || checked.size > contracts.size) {
4382
4560
  issue("Every required output needs exactly one manifest");
4383
4561
  }
4384
4562
  });
4385
4563
 
4386
4564
  // ../schemas/src/draft-pack-revision.ts
4387
- import { z as z52 } from "zod";
4565
+ import { z as z56 } from "zod";
4388
4566
 
4389
4567
  // ../schemas/src/draft-pack-draft-outputs.ts
4390
- import { z as z50 } from "zod";
4391
- var identifier21 = z50.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/u, "Use lowercase letters, digits, - and _");
4392
- var quote = z50.string().min(1).max(4e3);
4393
- var wording = z50.string().min(1).max(artifactLintLimits.maxLiteralUnits).regex(/\S/u, "Wording needs a visible character").refine(isWellFormedText, "Wording has a broken character");
4568
+ import { z as z51 } from "zod";
4569
+ var identifier21 = z51.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/u, "Use lowercase letters, digits, - and _");
4570
+ var quote = z51.string().min(1).max(4e3);
4571
+ var wording = z51.string().min(1).max(artifactLintLimits.maxLiteralUnits).regex(/\S/u, "Wording needs a visible character").refine(isWellFormedText, "Wording has a broken character");
4394
4572
  var packDraftOutputLimits = {
4395
4573
  maxOutputs: 8,
4396
4574
  maxChecks: 16,
@@ -4399,26 +4577,26 @@ var packDraftOutputLimits = {
4399
4577
  defaultCharacters: 8e3,
4400
4578
  maxCharacters: artifactLintLimits.maxSectionUnits
4401
4579
  };
4402
- var wordingCheck = (max) => z50.strictObject({ id: identifier21, quote, wording: z50.array(wording).min(1).max(max) });
4403
- var PackDraftOutputSchema = z50.strictObject({
4580
+ var wordingCheck = (max) => z51.strictObject({ id: identifier21, quote, wording: z51.array(wording).min(1).max(max) });
4581
+ var PackDraftOutputSchema = z51.strictObject({
4404
4582
  id: identifier21,
4405
4583
  what: quote,
4406
- outcomes: z50.array(identifier21).min(1).max(64).refine(hasUniqueValues, "Duplicate outcome"),
4407
- maxCharacters: z50.number().int().min(1).max(packDraftOutputLimits.maxCharacters).optional(),
4408
- context: z50.array(z50.strictObject({ id: identifier21, quote })).min(1).max(packDraftOutputLimits.maxContext).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate context id").optional(),
4409
- require: z50.array(wordingCheck(artifactLintLimits.maxAlternatives)).max(packDraftOutputLimits.maxChecks).optional(),
4410
- prohibit: z50.array(wordingCheck(artifactLintLimits.maxLiterals)).max(packDraftOutputLimits.maxChecks).optional(),
4411
- ask: z50.array(z50.strictObject({
4584
+ outcomes: z51.array(identifier21).min(1).max(64).refine(hasUniqueValues, "Duplicate outcome"),
4585
+ maxCharacters: z51.number().int().min(1).max(packDraftOutputLimits.maxCharacters).optional(),
4586
+ context: z51.array(z51.strictObject({ id: identifier21, quote })).min(1).max(packDraftOutputLimits.maxContext).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate context id").optional(),
4587
+ require: z51.array(wordingCheck(artifactLintLimits.maxAlternatives)).max(packDraftOutputLimits.maxChecks).optional(),
4588
+ prohibit: z51.array(wordingCheck(artifactLintLimits.maxLiterals)).max(packDraftOutputLimits.maxChecks).optional(),
4589
+ ask: z51.array(z51.strictObject({
4412
4590
  id: identifier21,
4413
4591
  quote,
4414
- kind: z50.enum(["require", "prohibit"]),
4415
- question: z50.string().min(1).max(2e3).regex(/\S/u)
4592
+ kind: z51.enum(["require", "prohibit"]),
4593
+ question: z51.string().min(1).max(2e3).regex(/\S/u)
4416
4594
  })).max(packDraftOutputLimits.maxQuestions).optional(),
4417
- states: z50.array(z50.strictObject({
4595
+ states: z51.array(z51.strictObject({
4418
4596
  id: identifier21,
4419
4597
  quote,
4420
4598
  question: identifier21,
4421
- wording: z50.record(identifier21, z50.array(wording).min(1).max(8)).optional()
4599
+ wording: z51.record(identifier21, z51.array(wording).min(1).max(8)).optional()
4422
4600
  })).max(packDraftOutputLimits.maxQuestions).optional()
4423
4601
  }).refine((output) => {
4424
4602
  const ids3 = [
@@ -4433,22 +4611,22 @@ var PackDraftOutputSchema = z50.strictObject({
4433
4611
  }, `At most ${packDraftOutputLimits.maxQuestions} asked questions and stated answers together`).refine((output) => {
4434
4612
  return (output.require?.length ?? 0) + (output.prohibit?.length ?? 0) + (output.ask?.length ?? 0) + (output.states?.length ?? 0) > 0;
4435
4613
  }, "An output needs at least one check");
4436
- var PackDraftOutputsSchema = z50.array(PackDraftOutputSchema).min(1).max(packDraftOutputLimits.maxOutputs).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate output");
4614
+ var PackDraftOutputsSchema = z51.array(PackDraftOutputSchema).min(1).max(packDraftOutputLimits.maxOutputs).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate output");
4437
4615
 
4438
4616
  // ../schemas/src/draft-pack-draft-scoring.ts
4439
- import { z as z51 } from "zod";
4440
- var points = z51.number().min(0).max(1e6);
4441
- var PackDraftScoreSchema = z51.strictObject({
4617
+ import { z as z52 } from "zod";
4618
+ var points = z52.number().min(0).max(1e6);
4619
+ var PackDraftScoreSchema = z52.strictObject({
4442
4620
  lt: points.optional(),
4443
4621
  lte: points.optional(),
4444
4622
  gt: points.optional(),
4445
4623
  gte: points.optional(),
4446
4624
  eq: points.optional(),
4447
4625
  quote: draftQuote
4448
- }).superRefine((value, context3) => {
4449
- const lower = Number(value.gt !== void 0) + Number(value.gte !== void 0);
4450
- const upper = Number(value.lt !== void 0) + Number(value.lte !== void 0);
4451
- const hasEquality = value.eq !== void 0;
4626
+ }).superRefine((value2, context3) => {
4627
+ const lower = Number(value2.gt !== void 0) + Number(value2.gte !== void 0);
4628
+ const upper = Number(value2.lt !== void 0) + Number(value2.lte !== void 0);
4629
+ const hasEquality = value2.eq !== void 0;
4452
4630
  if (lower + upper + Number(hasEquality) === 0) {
4453
4631
  context3.addIssue({ code: "custom", message: "Give a bound: lt, lte, gt, gte or eq" });
4454
4632
  } else if (lower > 1 || upper > 1) {
@@ -4457,170 +4635,723 @@ var PackDraftScoreSchema = z51.strictObject({
4457
4635
  context3.addIssue({ code: "custom", message: "eq stands alone" });
4458
4636
  }
4459
4637
  });
4460
- var contribution2 = z51.strictObject({
4638
+ var contribution2 = z52.strictObject({
4461
4639
  id: draftIdentifier,
4462
4640
  points,
4463
4641
  quote: draftQuote,
4464
4642
  when: PackDraftConditionsSchema
4465
4643
  });
4466
- var criterion2 = z51.strictObject({
4644
+ var criterion2 = z52.strictObject({
4467
4645
  id: draftIdentifier,
4468
4646
  meaning: draftQuote,
4469
4647
  activeWhen: PackDraftConditionsSchema.optional(),
4470
- points: z51.array(contribution2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate points id"),
4471
- otherwise: z51.strictObject({ points, quote: draftQuote }).optional()
4648
+ points: z52.array(contribution2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate points id"),
4649
+ otherwise: z52.strictObject({ points, quote: draftQuote }).optional()
4472
4650
  });
4473
- var PackDraftScoringSchema = z51.strictObject({
4474
- scale: z51.union([z51.literal(1), z51.literal(100)]).optional(),
4475
- criteria: z51.array(criterion2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate criterion")
4651
+ var PackDraftScoringSchema = z52.strictObject({
4652
+ scale: z52.union([z52.literal(1), z52.literal(100)]).optional(),
4653
+ criteria: z52.array(criterion2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate criterion")
4476
4654
  });
4477
4655
  var packDraftScoreExpectation = {
4478
- score: z51.number().min(0).optional(),
4479
- points: z51.record(draftIdentifier, z51.number().min(0).nullable()).optional()
4656
+ score: z52.number().min(0).optional(),
4657
+ points: z52.record(draftIdentifier, z52.number().min(0).nullable()).optional()
4480
4658
  };
4481
4659
 
4660
+ // ../schemas/src/draft-pack-draft.ts
4661
+ import { z as z55 } from "zod";
4662
+
4663
+ // ../schemas/src/draft-pack-draft-coverage.ts
4664
+ import { z as z53 } from "zod";
4665
+ var coverageDispositions = ["represented", "needs_review", "unsupported"];
4666
+ var coverageTargetKinds = [
4667
+ "question",
4668
+ "rule",
4669
+ "outcome",
4670
+ "escalation",
4671
+ "subject"
4672
+ ];
4673
+ var coverageFields = [
4674
+ "purpose",
4675
+ "useWhen",
4676
+ "notFor",
4677
+ "owner",
4678
+ "evidenceKinds",
4679
+ "maxEvidenceAgeDays",
4680
+ "manualFacts",
4681
+ "businessDays",
4682
+ "whenUnresolved",
4683
+ "attempts",
4684
+ "scoring",
4685
+ "outputChecks",
4686
+ "subject"
4687
+ ];
4688
+ var target = z53.union([
4689
+ ...coverageTargetKinds.map((kind) => z53.strictObject({ [kind]: draftIdentifier })),
4690
+ z53.strictObject({ field: z53.enum(coverageFields) })
4691
+ ]);
4692
+ var entry2 = z53.strictObject({
4693
+ quote: draftQuote,
4694
+ categories: z53.array(z53.enum(authorityPrimitives)).min(1).max(authorityPrimitives.length).refine(hasUniqueValues, "Duplicate category"),
4695
+ disposition: z53.enum(coverageDispositions),
4696
+ carriedBy: z53.array(target).min(1).max(16).optional(),
4697
+ why: z53.string().min(1).max(600).optional()
4698
+ }).superRefine((row2, context3) => {
4699
+ const isRepresented = row2.disposition === "represented";
4700
+ if (isRepresented && row2.carriedBy === void 0) {
4701
+ context3.addIssue({
4702
+ code: "custom",
4703
+ path: ["carriedBy"],
4704
+ message: "Name what carries a represented passage: a question, rule, outcome, escalation or subject"
4705
+ });
4706
+ }
4707
+ if (!isRepresented && row2.why === void 0) {
4708
+ context3.addIssue({
4709
+ code: "custom",
4710
+ path: ["why"],
4711
+ message: "Say why it is open or left out, for the owner"
4712
+ });
4713
+ }
4714
+ if (!isRepresented && row2.carriedBy !== void 0) {
4715
+ context3.addIssue({
4716
+ code: "custom",
4717
+ path: ["carriedBy"],
4718
+ message: "Only a represented passage is carried by the pack"
4719
+ });
4720
+ }
4721
+ });
4722
+ var PackDraftCoverageSchema = z53.array(entry2).min(1).max(128);
4723
+
4724
+ // ../schemas/src/draft-pack-draft-readings.ts
4725
+ import { z as z54 } from "zod";
4726
+ var readingCheckLimits = {
4727
+ maxPerAnswer: 8,
4728
+ maxPerCheck: 96,
4729
+ maxKept: 200,
4730
+ maxCharacters: 2e3,
4731
+ maxLabelCharacters: 120
4732
+ };
4733
+ var PackDraftReadingTestSchema = z54.strictObject({
4734
+ id: draftIdentifier,
4735
+ question: draftIdentifier,
4736
+ text: z54.string().trim().min(1).max(readingCheckLimits.maxCharacters),
4737
+ expect: draftValue
4738
+ });
4739
+ var PackDraftReadingTestsSchema = z54.array(PackDraftReadingTestSchema).min(1).max(readingCheckLimits.maxKept).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate reading test");
4740
+ function readingTestIssue(row2, questions, path3) {
4741
+ const question3 = questions.find((item) => item.key === row2.question);
4742
+ if (question3 === void 0 || question3.type !== void 0 || question3.derive !== void 0) {
4743
+ return {
4744
+ path: [...path3, "question"],
4745
+ message: `"${row2.question}" is not a choice question Felspar reads from text`
4746
+ };
4747
+ }
4748
+ const answers2 = question3.answers ?? [];
4749
+ return answers2.every((answer) => answer.value !== row2.expect) ? {
4750
+ path: [...path3, "expect"],
4751
+ message: `"${row2.expect}" is not one of the answers of "${row2.question}"`
4752
+ } : null;
4753
+ }
4754
+ function readingTestIssues(tests, questions) {
4755
+ const issues = [];
4756
+ const perAnswer = /* @__PURE__ */ new Map();
4757
+ const rows = tests ?? [];
4758
+ for (const [index, row2] of rows.entries()) {
4759
+ const path3 = ["readingTests", index];
4760
+ const issue = readingTestIssue(row2, questions, path3);
4761
+ const at = JSON.stringify([row2.question, row2.expect]);
4762
+ const count2 = (perAnswer.get(at) ?? 0) + 1;
4763
+ perAnswer.set(at, count2);
4764
+ if (issue !== null) {
4765
+ issues.push(issue);
4766
+ } else if (count2 > readingCheckLimits.maxPerAnswer) {
4767
+ issues.push({
4768
+ path: path3,
4769
+ message: `At most ${readingCheckLimits.maxPerAnswer} reading tests per answer`
4770
+ });
4771
+ }
4772
+ }
4773
+ return issues;
4774
+ }
4775
+ var variant = z54.strictObject({
4776
+ id: draftIdentifier.optional(),
4777
+ question: draftIdentifier,
4778
+ text: z54.string().trim().min(1).max(readingCheckLimits.maxCharacters),
4779
+ expect: draftValue.optional(),
4780
+ label: z54.string().trim().min(1).max(readingCheckLimits.maxLabelCharacters).optional()
4781
+ });
4782
+ var ReadingCheckRequestSchema = z54.strictObject({
4783
+ sourceObjectId: z54.string().min(1).max(200),
4784
+ draft: z54.unknown(),
4785
+ variants: z54.array(variant).max(readingCheckLimits.maxPerCheck).optional(),
4786
+ includeTests: z54.boolean().default(true)
4787
+ });
4788
+ var readingResults = ["as_expected", "different", "held", "read", "not_read"];
4789
+ var readingReasons = [
4790
+ "below_bar",
4791
+ "cannot_tell",
4792
+ "tie",
4793
+ "looks_like_instructions",
4794
+ "evaluation_off",
4795
+ "limit_reached",
4796
+ "not_answered"
4797
+ ];
4798
+ var probability = z54.number().min(0).max(1);
4799
+ var ReadingOutcomeSchema = z54.strictObject({
4800
+ id: z54.string().min(1).max(200),
4801
+ origin: z54.enum(["test", "sent"]),
4802
+ question: z54.string().min(1).max(200),
4803
+ label: z54.string().optional(),
4804
+ expect: z54.string().nullable(),
4805
+ result: z54.enum(readingResults),
4806
+ picked: z54.string().nullable(),
4807
+ leaning: z54.string().nullable(),
4808
+ confidence: probability.nullable(),
4809
+ bar: probability,
4810
+ reason: z54.enum(readingReasons).nullable()
4811
+ });
4812
+ var count = z54.number().int().min(0);
4813
+ var counts = z54.strictObject({
4814
+ as_expected: count,
4815
+ different: count,
4816
+ held: count,
4817
+ read: count,
4818
+ not_read: count
4819
+ });
4820
+ var ReadingCheckSchema = z54.strictObject({
4821
+ schema: z54.literal("felspar.reading-check/v0"),
4822
+ authority: z54.literal("unapproved"),
4823
+ jobId: z54.string(),
4824
+ status: z54.enum(["clean", "misses", "incomplete"]),
4825
+ counts,
4826
+ questions: z54.array(z54.strictObject({ question: z54.string(), bar: probability, counts })),
4827
+ readings: z54.array(ReadingOutcomeSchema)
4828
+ });
4829
+
4830
+ // ../schemas/src/draft-pack-draft.ts
4831
+ var identifier22 = draftIdentifier;
4832
+ var quote2 = draftQuote;
4833
+ var value = draftValue;
4834
+ var conditions = PackDraftConditionsSchema;
4835
+ var ruleOrders = ["first-match", "unordered"];
4836
+ var packDraftVersions = [
4837
+ "felspar.pack-draft/v0",
4838
+ "felspar.pack-draft/v1",
4839
+ "felspar.pack-draft/v2"
4840
+ ];
4841
+ var answers = z55.array(z55.strictObject({
4842
+ value,
4843
+ meaning: quote2,
4844
+ inclusions: z55.array(quote2).max(8).optional(),
4845
+ exclusions: z55.array(quote2).max(8).optional(),
4846
+ examples: z55.array(quote2).max(8).optional(),
4847
+ edgeCases: z55.array(quote2).max(8).optional(),
4848
+ noneOfThese: z55.literal(true).optional()
4849
+ })).min(2).max(64).refine((rows) => hasUniqueValues(rows.map((row2) => row2.value)), "Duplicate answer").refine((rows) => rows.filter((row2) => row2.noneOfThese === true).length <= 1, "Only one answer may be noneOfThese");
4850
+ var derive = z55.strictObject({
4851
+ from: identifier22,
4852
+ when: z55.record(value, z55.union([value, z55.array(value).min(2).max(64)])),
4853
+ otherwise: value.optional()
4854
+ });
4855
+ var notDerived = [
4856
+ "type",
4857
+ "askOnlyWhen",
4858
+ "whereToLook",
4859
+ "about",
4860
+ "evidence",
4861
+ "minimumConfidence",
4862
+ "highConsequence"
4863
+ ];
4864
+ function computedIssue(field) {
4865
+ return {
4866
+ path: [field],
4867
+ message: `A derived question is computed, never asked: it has no ${field}`
4868
+ };
4869
+ }
4870
+ function deriveIssues(row2) {
4871
+ const rule3 = row2.derive;
4872
+ if (rule3 === void 0) {
4873
+ return [];
4874
+ }
4875
+ const present = notDerived.filter((field) => row2[field] !== void 0);
4876
+ const issues = present.map(computedIssue);
4877
+ const values = new Set((row2.answers ?? []).map((answer) => answer.value));
4878
+ const named = [
4879
+ ...Object.keys(rule3.when),
4880
+ ...rule3.otherwise === void 0 ? [] : [rule3.otherwise]
4881
+ ];
4882
+ const unknown = named.filter((item) => !values.has(item));
4883
+ for (const answer of unknown) {
4884
+ issues.push({ path: ["derive"], message: `"${answer}" is not one of this question's answers` });
4885
+ }
4886
+ if (rule3.otherwise !== void 0 && Object.hasOwn(rule3.when, rule3.otherwise)) {
4887
+ issues.push({
4888
+ path: ["derive", "otherwise"],
4889
+ message: "otherwise names an answer already in when"
4890
+ });
4891
+ }
4892
+ if ((row2.answers ?? []).some((answer) => answer.noneOfThese === true)) {
4893
+ issues.push({ path: ["answers"], message: "A derived question has no noneOfThese answer" });
4894
+ }
4895
+ return issues;
4896
+ }
4897
+ var evidenceKinds = z55.array(identifier22).min(1).max(8).refine(hasUniqueValues, "Duplicate kind");
4898
+ var evidenceAge = z55.number().int().min(1).max(3650);
4899
+ var questionEvidence = z55.strictObject({
4900
+ evidenceKinds: evidenceKinds.optional(),
4901
+ maxEvidenceAgeDays: evidenceAge.optional(),
4902
+ quote: quote2
4903
+ }).refine((row2) => row2.evidenceKinds !== void 0 || row2.maxEvidenceAgeDays !== void 0, "Give evidenceKinds, maxEvidenceAgeDays or both");
4904
+ var minimumConfidence = z55.number().min(0.5).max(0.99);
4905
+ var question2 = z55.strictObject({
4906
+ key: identifier22,
4907
+ meaning: quote2,
4908
+ answers: answers.optional(),
4909
+ ...typedQuestionFields,
4910
+ askOnlyWhen: conditions.optional(),
4911
+ whereToLook: z55.array(quote2).max(8).optional(),
4912
+ about: identifier22.optional(),
4913
+ derive: derive.optional(),
4914
+ evidence: questionEvidence.optional(),
4915
+ minimumConfidence: minimumConfidence.optional(),
4916
+ highConsequence: z55.literal(true).optional()
4917
+ }).superRefine((row2, context3) => {
4918
+ if (row2.type !== void 0 && row2.highConsequence !== void 0) {
4919
+ context3.addIssue({
4920
+ code: "custom",
4921
+ path: ["highConsequence"],
4922
+ message: "A number or date is read exactly, with no confidence bar to calibrate"
4923
+ });
4924
+ }
4925
+ if (row2.type !== void 0 && row2.minimumConfidence !== void 0) {
4926
+ context3.addIssue({
4927
+ code: "custom",
4928
+ path: ["minimumConfidence"],
4929
+ message: "A number or date is read exactly, with no confidence bar"
4930
+ });
4931
+ }
4932
+ for (const issue of questionIssues(row2)) {
4933
+ context3.addIssue({ code: "custom", ...issue });
4934
+ }
4935
+ for (const issue of deriveIssues(row2)) {
4936
+ context3.addIssue({ code: "custom", ...issue });
4937
+ }
4938
+ });
4939
+ var shape3 = z55.strictObject({
4940
+ schema: z55.enum(packDraftVersions),
4941
+ job: identifier22,
4942
+ purpose: quote2.optional(),
4943
+ useWhen: z55.array(quote2).min(1).max(8).optional(),
4944
+ notFor: z55.array(quote2).min(1).max(8).optional(),
4945
+ owner: quote2.optional(),
4946
+ evidenceKinds,
4947
+ maxEvidenceAgeDays: evidenceAge,
4948
+ manualFacts: z55.strictObject({ allowed: z55.literal(false), quote: quote2 }).optional(),
4949
+ ...packConventionFields,
4950
+ businessDays: PackDraftBusinessDaysSchema.optional(),
4951
+ questions: z55.array(question2).min(1).max(64).refine((rows) => hasUniqueValues(rows.map((row2) => row2.key)), "Duplicate question"),
4952
+ subjects: PackDraftSubjectsSchema.optional(),
4953
+ subject: identifier22.optional(),
4954
+ escalations: PackDraftEscalationsSchema.optional(),
4955
+ outcomes: z55.array(z55.strictObject({
4956
+ id: identifier22,
4957
+ nextStep: quote2,
4958
+ escalate: identifier22.optional()
4959
+ })).min(1).max(64).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate outcome"),
4960
+ whenUnresolved: z55.union([quote2, z55.strictObject({ quote: quote2, escalate: identifier22 })]),
4961
+ attempts: z55.strictObject({
4962
+ max: z55.number().int().min(1).max(10).optional(),
4963
+ escalate: identifier22.optional()
4964
+ }).optional(),
4965
+ scoring: PackDraftScoringSchema.optional(),
4966
+ ruleOrder: z55.enum(ruleOrders).optional(),
4967
+ rules: z55.array(z55.strictObject({
4968
+ id: identifier22,
4969
+ meaning: quote2,
4970
+ when: conditions.optional(),
4971
+ score: PackDraftScoreSchema.optional(),
4972
+ gate: z55.literal(true).optional(),
4973
+ outcome: identifier22,
4974
+ except: z55.array(identifier22).min(1).max(16).refine(hasUniqueValues, "Duplicate rule").optional()
4975
+ })).min(1).max(256).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate rule"),
4976
+ cases: z55.array(z55.strictObject({
4977
+ id: identifier22,
4978
+ why: z55.string().min(1).max(2e3),
4979
+ facts: z55.record(identifier22, caseFactSchema),
4980
+ decisionDate: caseDecisionDate,
4981
+ subject: z55.strictObject({ id: SubjectIdSchema }).optional(),
4982
+ expect: z55.union([
4983
+ z55.strictObject({
4984
+ outcome: identifier22,
4985
+ rule: identifier22,
4986
+ escalation: identifier22.optional(),
4987
+ ...packDraftScoreExpectation
4988
+ }),
4989
+ z55.strictObject({ held: z55.enum(heldStates), ...packDraftScoreExpectation })
4990
+ ])
4991
+ })).min(1).max(200).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate case"),
4992
+ outputChecks: PackDraftOutputsSchema.optional(),
4993
+ readingTests: PackDraftReadingTestsSchema.optional(),
4994
+ coverage: PackDraftCoverageSchema.optional()
4995
+ });
4996
+ function comparisonPaths(when2, at) {
4997
+ const entries2 = Object.entries(when2 ?? {});
4998
+ return entries2.flatMap(([key3, condition]) => isComparison(condition) ? [[...at, key3]] : []);
4999
+ }
5000
+ function presentPaths(row2, fields, at) {
5001
+ return fields.filter((field) => row2[field] !== void 0).map((field) => [...at, field]);
5002
+ }
5003
+ function casePaths(row2, at) {
5004
+ const facts = Object.entries(row2.facts);
5005
+ const isTyped = (fact) => typeof fact !== "string";
5006
+ return [
5007
+ ...presentPaths(row2, ["decisionDate"], at),
5008
+ ...presentPaths(row2.expect, ["score", "points"], [...at, "expect"]),
5009
+ ..."held" in row2.expect ? [[...at, "expect", "held"]] : [],
5010
+ ...facts.flatMap(([key3, fact]) => isTyped(fact) ? [[...at, "facts", key3]] : [])
5011
+ ];
5012
+ }
5013
+ function v1Paths(draft) {
5014
+ const paths = presentPaths(draft, ["numberStyle", "dateOrder", "timeZone", "scoring", "businessDays", "ruleOrder"], []);
5015
+ for (const [index, row2] of draft.questions.entries()) {
5016
+ const at = ["questions", String(index)];
5017
+ paths.push(...presentPaths(row2, ["type", "derive", "evidence", "minimumConfidence", "highConsequence"], at), ...comparisonPaths(row2.askOnlyWhen, [...at, "askOnlyWhen"]));
5018
+ }
5019
+ for (const [index, rule3] of draft.rules.entries()) {
5020
+ const at = ["rules", String(index)];
5021
+ paths.push(...presentPaths(rule3, ["score", "gate", "except"], at), ...comparisonPaths(rule3.when, [...at, "when"]));
5022
+ }
5023
+ for (const [index, row2] of draft.cases.entries()) {
5024
+ paths.push(...casePaths(row2, ["cases", String(index)]));
5025
+ }
5026
+ return paths;
5027
+ }
5028
+ var PackDraftSchema = shape3.superRefine((draft, context3) => {
5029
+ for (const issue of readingTestIssues(draft.readingTests, draft.questions)) {
5030
+ context3.addIssue({ code: "custom", ...issue });
5031
+ }
5032
+ if (draft.schema === "felspar.pack-draft/v2" && draft.purpose === void 0) {
5033
+ context3.addIssue({
5034
+ code: "custom",
5035
+ path: ["purpose"],
5036
+ message: "Quote the job's purpose: why it exists and what it resolves"
5037
+ });
5038
+ }
5039
+ if (draft.schema !== "felspar.pack-draft/v0") {
5040
+ return;
5041
+ }
5042
+ for (const path3 of v1Paths(draft)) {
5043
+ context3.addIssue({
5044
+ code: "custom",
5045
+ path: path3,
5046
+ message: 'Number and date questions, derived questions, thresholds, conventions, scoring, business days, exceptions, rule order, per-question evidence and held cases need "schema": "felspar.pack-draft/v1"'
5047
+ });
5048
+ }
5049
+ });
5050
+
4482
5051
  // ../schemas/src/draft-pack-revision.ts
4483
- var KeptPackDraftSchema = z52.looseObject({
4484
- schema: z52.string().regex(/^felspar\.pack-draft\/v\d{1,3}$/u),
4485
- job: z52.string().min(1).max(200)
5052
+ var KeptPackDraftSchema = z56.looseObject({
5053
+ schema: z56.string().regex(/^felspar\.pack-draft\/v\d{1,3}$/u),
5054
+ job: z56.string().min(1).max(200)
4486
5055
  });
4487
- var id6 = z52.string().min(1).max(200);
4488
- var text7 = z52.string().min(1).max(262144);
4489
- var texts = z52.array(z52.string()).max(8);
5056
+ var id6 = z56.string().min(1).max(200);
5057
+ var text7 = z56.string().min(1).max(262144);
5058
+ var texts = z56.array(z56.string()).max(8);
4490
5059
  var when = PackDraftConditionsSchema;
4491
5060
  var conventions = packConventionFields;
4492
- var PackOutlineSchema = z52.strictObject({
4493
- schema: z52.literal("felspar.pack-outline/v0"),
5061
+ var PackOutlineSchema = z56.strictObject({
5062
+ schema: z56.literal("felspar.pack-outline/v0"),
4494
5063
  job: id6,
4495
5064
  purpose: text7.nullable(),
4496
5065
  useWhen: texts,
4497
5066
  notFor: texts,
4498
5067
  owner: text7.nullable(),
4499
- evidenceKinds: z52.array(id6).max(8),
4500
- maxEvidenceAgeDays: z52.number().int().min(1).nullable(),
4501
- numberStyle: z52.enum(numberStyles).nullable(),
5068
+ evidenceKinds: z56.array(id6).max(8),
5069
+ maxEvidenceAgeDays: z56.number().int().min(1).nullable(),
5070
+ numberStyle: z56.enum(numberStyles).nullable(),
4502
5071
  dateOrder: conventions.dateOrder.unwrap().nullable(),
4503
- timeZone: z52.string().min(1).max(64).nullable(),
5072
+ timeZone: z56.string().min(1).max(64).nullable(),
5073
+ businessDays: PackDraftBusinessDaysSchema.nullable(),
4504
5074
  subject: id6.nullable(),
4505
- subjects: z52.array(z52.strictObject({
5075
+ subjects: z56.array(z56.strictObject({
4506
5076
  id: id6,
4507
5077
  definition: text7,
4508
- identifier: z52.string().nullable(),
4509
- example: z52.string().nullable(),
4510
- match: z52.string(),
4511
- relationships: z52.array(z52.strictObject({
5078
+ identifier: z56.string().nullable(),
5079
+ example: z56.string().nullable(),
5080
+ match: z56.string(),
5081
+ relationships: z56.array(z56.strictObject({
4512
5082
  name: id6,
4513
5083
  subject: id6,
4514
- cardinality: z52.enum(["one", "many"]),
4515
- required: z52.boolean(),
5084
+ cardinality: z56.enum(["one", "many"]),
5085
+ required: z56.boolean(),
4516
5086
  definition: text7
4517
5087
  })).max(16),
4518
5088
  identity: PackDraftIdentitySchema.nullable()
4519
5089
  })).max(16),
4520
- escalations: z52.array(z52.strictObject({ id: id6, quote: text7 })).max(16),
4521
- questions: z52.array(z52.strictObject({
5090
+ escalations: z56.array(z56.strictObject({ id: id6, quote: text7 })).max(16),
5091
+ questions: z56.array(z56.strictObject({
4522
5092
  key: id6,
4523
- type: z52.enum(["enum", "boolean", "number", "date"]),
5093
+ type: z56.enum(["enum", "boolean", "number", "date"]),
4524
5094
  meaning: text7,
4525
5095
  about: id6.nullable(),
4526
- askOnlyWhen: z52.string().nullable(),
5096
+ askOnlyWhen: z56.string().nullable(),
4527
5097
  when: when.nullable(),
4528
- unit: z52.string().nullable(),
4529
- unitWords: z52.array(z52.string()).max(16).nullable(),
4530
- integer: z52.boolean().nullable(),
4531
- minimum: z52.number().nullable(),
4532
- maximum: z52.number().nullable(),
4533
- answers: z52.array(z52.strictObject({
5098
+ unit: z56.string().nullable(),
5099
+ unitWords: z56.array(z56.string()).max(16).nullable(),
5100
+ integer: z56.boolean().nullable(),
5101
+ minimum: z56.number().nullable(),
5102
+ maximum: z56.number().nullable(),
5103
+ answers: z56.array(z56.strictObject({
4534
5104
  value: id6,
4535
- meaning: z52.string().nullable(),
5105
+ meaning: z56.string().nullable(),
4536
5106
  inclusions: texts,
4537
5107
  exclusions: texts,
4538
5108
  examples: texts,
4539
5109
  edgeCases: texts
4540
5110
  })).max(64),
4541
- whereToLook: texts
5111
+ whereToLook: texts,
5112
+ evidence: z56.strictObject({
5113
+ evidenceKinds: z56.array(id6).max(8).nullable(),
5114
+ maxEvidenceAgeDays: z56.number().int().min(1).nullable(),
5115
+ quote: text7
5116
+ }).nullable(),
5117
+ minimumConfidence: z56.number().nullable()
4542
5118
  })).max(64),
4543
- outcomes: z52.array(z52.strictObject({ id: id6, nextStep: text7.nullable(), escalate: id6.nullable() })).max(64),
4544
- whenUnresolved: z52.strictObject({ quote: text7, escalate: id6.nullable() }).nullable(),
4545
- attempts: z52.strictObject({ max: z52.number().int(), escalate: id6.nullable() }).nullable(),
4546
- rules: z52.array(z52.strictObject({
5119
+ outcomes: z56.array(z56.strictObject({ id: id6, nextStep: text7.nullable(), escalate: id6.nullable() })).max(64),
5120
+ whenUnresolved: z56.strictObject({ quote: text7, escalate: id6.nullable() }).nullable(),
5121
+ attempts: z56.strictObject({ max: z56.number().int(), escalate: id6.nullable() }).nullable(),
5122
+ rules: z56.array(z56.strictObject({
4547
5123
  id: id6,
4548
5124
  meaning: text7,
4549
5125
  outcome: id6,
4550
5126
  when: when.nullable(),
4551
- conditions: z52.string().nullable(),
4552
- scoreRange: z52.record(z52.string(), z52.unknown()).nullable(),
5127
+ conditions: z56.string().nullable(),
5128
+ scoreRange: z56.record(z56.string(), z56.unknown()).nullable(),
4553
5129
  score: PackDraftScoreSchema.nullable(),
4554
- gate: z52.boolean()
5130
+ gate: z56.boolean(),
5131
+ except: z56.array(id6).max(16).nullable()
4555
5132
  })).max(256),
5133
+ ruleOrder: z56.enum(ruleOrders).nullable(),
4556
5134
  scoring: PackDraftScoringSchema.nullable(),
4557
- cases: z52.array(z52.strictObject({
5135
+ cases: z56.array(z56.strictObject({
4558
5136
  id: id6,
4559
- why: z52.string().nullable(),
4560
- facts: z52.record(id6, caseFactSchema),
5137
+ why: z56.string().nullable(),
5138
+ facts: z56.record(id6, caseFactSchema),
4561
5139
  decisionDate: CalendarDateSchema.nullable(),
4562
- subject: z52.strictObject({ id: id6 }).nullable(),
4563
- expect: z52.strictObject({ outcome: id6, rule: id6, score: z52.number().nullable() })
5140
+ subject: z56.strictObject({ id: id6 }).nullable(),
5141
+ expect: z56.union([
5142
+ z56.strictObject({ outcome: id6, rule: id6, score: z56.number().nullable() }),
5143
+ z56.strictObject({ held: z56.enum(heldStates), score: z56.number().nullable() })
5144
+ ])
4564
5145
  })).max(200),
4565
5146
  outputChecks: PackDraftOutputsSchema.nullable(),
4566
- notKept: z52.array(z52.strictObject({ path: z52.string().min(1), reason: z52.string().min(1) })).max(64)
5147
+ manualFacts: z56.strictObject({ allowed: z56.literal(false), quote: z56.string().min(1) }).nullable(),
5148
+ notKept: z56.array(z56.strictObject({ path: z56.string().min(1), reason: z56.string().min(1) })).max(64)
5149
+ });
5150
+
5151
+ // ../schemas/src/draft-bar-calibration.ts
5152
+ import { z as z57 } from "zod";
5153
+ var barCalibrationPolicy = {
5154
+ lowestBar: 0.8,
5155
+ highestBar: 0.99,
5156
+ targets: { ordinary: 0.9, strict: 0.97 },
5157
+ minimumCases: 10,
5158
+ minimumDecided: 5,
5159
+ maxLabels: 400
5160
+ };
5161
+ var barCalibrationId = "felspar-backtest-bar";
5162
+ var barCalibrationVersion = "v1";
5163
+ var id7 = z57.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
5164
+ var digest23 = z57.string().regex(/^sha256:[a-f0-9]{64}$/u);
5165
+ var share = z57.number().min(0).max(1);
5166
+ var bar = z57.number().min(barCalibrationPolicy.lowestBar).max(barCalibrationPolicy.highestBar);
5167
+ var BacktestLabelSchema = z57.strictObject({
5168
+ executionObjectId: id7,
5169
+ question: draftValue,
5170
+ answer: draftValue.nullable()
5171
+ });
5172
+ var BacktestLabelsSchema = z57.array(BacktestLabelSchema).min(1).max(barCalibrationPolicy.maxLabels).refine((rows) => {
5173
+ const seen = new Set(rows.map((row2) => JSON.stringify([row2.executionObjectId, row2.question])));
5174
+ return seen.size === rows.length;
5175
+ }, "Label each question of a case once");
5176
+ var calibrationReadings = ["right", "wrong", "held"];
5177
+ var caseRow = z57.strictObject({
5178
+ executionObjectId: id7,
5179
+ label: draftValue.nullable(),
5180
+ leaning: draftValue.nullable(),
5181
+ confidence: share.nullable(),
5182
+ atCurrentBar: z57.enum(calibrationReadings),
5183
+ atSuggestedBar: z57.enum(calibrationReadings).nullable()
5184
+ });
5185
+ var barRow = z57.strictObject({
5186
+ bar,
5187
+ decided: z57.number().int().min(0),
5188
+ right: z57.number().int().min(0),
5189
+ precision: share.nullable(),
5190
+ coverage: share
5191
+ });
5192
+ var calibrationStatuses = [
5193
+ "suggested",
5194
+ "too_few_cases",
5195
+ "coverage_gap",
5196
+ "needs_more_evidence_or_rewrite"
5197
+ ];
5198
+ var QuestionCalibrationSchema = z57.strictObject({
5199
+ question: id7,
5200
+ status: z57.enum(calibrationStatuses),
5201
+ consequence: z57.enum(["ordinary", "strict"]),
5202
+ target: share,
5203
+ currentBar: share,
5204
+ labeled: z57.number().int().min(0),
5205
+ insufficient: z57.number().int().min(0),
5206
+ otherAnswers: z57.number().int().min(0),
5207
+ notRead: z57.number().int().min(0),
5208
+ suggestion: z57.strictObject({
5209
+ bar,
5210
+ precision: share,
5211
+ coverage: share,
5212
+ calibration: z57.strictObject({
5213
+ id: z57.literal(barCalibrationId),
5214
+ version: z57.literal(barCalibrationVersion),
5215
+ contentDigest: digest23
5216
+ })
5217
+ }).optional(),
5218
+ bars: z57.array(barRow).max(20),
5219
+ cases: z57.array(caseRow).max(50)
5220
+ });
5221
+ var BacktestCalibrationSchema = z57.strictObject({
5222
+ schema: z57.literal("felspar.bar-calibration/v1"),
5223
+ calibrationDigest: digest23,
5224
+ minimumCases: z57.number().int().min(1),
5225
+ questions: z57.array(QuestionCalibrationSchema).max(64),
5226
+ ignoredLabels: z57.number().int().min(0)
5227
+ });
5228
+ var AcceptedBarsSchema = z57.strictObject({
5229
+ savedResultId: z57.string().regex(/^backtest-[a-f0-9]{32}$/u),
5230
+ calibrationDigest: digest23,
5231
+ questions: z57.array(id7).min(1).max(64)
5232
+ });
5233
+ var ReleaseCalibrationSchema = AcceptedBarsSchema.extend({
5234
+ acceptedBy: z57.string().min(1).max(200),
5235
+ approvedMaterialDigest: digest23,
5236
+ bars: z57.array(z57.strictObject({ question: id7, bar, calibrationDigest: digest23 })).min(1).max(64)
5237
+ });
5238
+
5239
+ // ../schemas/src/draft-pack-environments.ts
5240
+ import { z as z58 } from "zod";
5241
+ var packEnvironments = ["staging", "production"];
5242
+ var PackEnvironmentSchema = z58.enum(packEnvironments);
5243
+ var packEnvironmentMoves = ["release", "stage", "promote", "rollback"];
5244
+ var PackEnvironmentMoveActionSchema = z58.enum(packEnvironmentMoves);
5245
+ var id8 = z58.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
5246
+ var digest24 = z58.string().regex(/^sha256:[a-f0-9]{64}$/u);
5247
+ var CandidateBindingSchema = z58.strictObject({
5248
+ candidateSourceObjectId: id8,
5249
+ capturedSourceObjectId: id8,
5250
+ providerRevision: id8,
5251
+ textDigest: digest24
5252
+ });
5253
+ var PackEnvironmentServedSchema = z58.strictObject({
5254
+ environment: PackEnvironmentSchema,
5255
+ releaseId: id8.nullable(),
5256
+ releaseDigest: digest24.nullable(),
5257
+ candidate: z58.boolean(),
5258
+ movedBy: z58.string().nullable(),
5259
+ movedAt: z58.string().nullable()
5260
+ });
5261
+ var PackEnvironmentMoveSchema = z58.strictObject({
5262
+ environment: PackEnvironmentSchema,
5263
+ action: PackEnvironmentMoveActionSchema,
5264
+ fromReleaseId: id8.nullable(),
5265
+ releaseId: id8,
5266
+ principalId: z58.string(),
5267
+ movedAt: z58.string(),
5268
+ binding: CandidateBindingSchema.nullable()
5269
+ });
5270
+ var PackEnvironmentsSchema = z58.strictObject({
5271
+ jobId: id8,
5272
+ staging: PackEnvironmentServedSchema,
5273
+ production: PackEnvironmentServedSchema,
5274
+ moves: z58.array(PackEnvironmentMoveSchema).max(50)
5275
+ });
5276
+ var PromoteInputSchema = z58.strictObject({
5277
+ expectedReleaseId: id8,
5278
+ writeBack: z58.literal(true).optional()
5279
+ });
5280
+ var RollbackInputSchema = z58.strictObject({ releaseId: id8, expectedReleaseId: id8 });
5281
+ var StageReleaseInputSchema = z58.strictObject({ releaseId: id8 });
5282
+ var StageCandidateInputSchema = z58.strictObject({
5283
+ reviewedMeaning: z58.literal(true),
5284
+ reviewedFixtures: z58.literal(true),
5285
+ reviewNote: z58.string().min(1).max(2e3)
4567
5286
  });
4568
5287
 
4569
5288
  // ../schemas/src/draft-hosted-application.ts
4570
- var id7 = z53.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
4571
- var digest23 = DraftApplicationReleaseSchema.shape.releaseDigest;
4572
- var HostedSourceInputSchema = z53.strictObject({
4573
- sourceId: id7,
4574
- revision: id7,
4575
- title: z53.string().min(1).max(200),
4576
- text: z53.string().min(1).max(1048576)
4577
- });
4578
- var HostedProposalInputV0Schema = z53.strictObject({
4579
- sourceObjectId: id7,
4580
- expectedSourceDigest: digest23,
5289
+ var id9 = z59.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
5290
+ var digest25 = DraftApplicationReleaseSchema.shape.releaseDigest;
5291
+ var HostedSourceInputSchema = z59.strictObject({
5292
+ sourceId: id9,
5293
+ revision: id9,
5294
+ title: z59.string().min(1).max(200),
5295
+ text: z59.string().min(1).max(1048576)
5296
+ });
5297
+ var HostedProposalInputV0Schema = z59.strictObject({
5298
+ sourceObjectId: id9,
5299
+ expectedSourceDigest: digest25,
4581
5300
  material: DraftApplicationJobMaterialSchema,
4582
5301
  compilation: DraftCompilationSchema
4583
5302
  });
4584
- var HostedProposalInputV2Schema = z53.strictObject({
4585
- schema: z53.literal("felspar.hosted-proposal.draft/v2"),
4586
- sourceObjectId: id7,
4587
- expectedSourceDigest: digest23,
5303
+ var HostedManualFactsRuleSchema = z59.strictObject({
5304
+ allowed: z59.literal(false),
5305
+ text: z59.string().min(1).max(4e3),
5306
+ sourceLocator: z59.string().min(1).max(4096),
5307
+ contentDigest: digest25
5308
+ });
5309
+ var HostedProposalInputV2Schema = z59.strictObject({
5310
+ schema: z59.literal("felspar.hosted-proposal.draft/v2"),
5311
+ sourceObjectId: id9,
5312
+ expectedSourceDigest: digest25,
4588
5313
  material: DraftApplicationJobMaterialV2Schema,
4589
5314
  outputChecks: HostedOutputChecksSchema.optional(),
5315
+ manualFacts: HostedManualFactsRuleSchema.optional(),
4590
5316
  draft: KeptPackDraftSchema.optional()
4591
5317
  });
4592
- var HostedProposalInputSchema = z53.union([
5318
+ var HostedProposalInputSchema = z59.union([
4593
5319
  HostedProposalInputV2Schema,
4594
5320
  HostedProposalInputV0Schema
4595
5321
  ]);
4596
- var HostedApprovalInputSchema = z53.strictObject({
4597
- expectedProposalDigest: digest23,
4598
- reviewedMeaning: z53.literal(true),
4599
- reviewedFixtures: z53.literal(true),
4600
- reviewNote: z53.string().min(1).max(2e3)
4601
- });
4602
- var HostedReleaseInputSchema = z53.strictObject({ expectedApprovalDigest: digest23 });
4603
- var HostedReleaseBundleSchema = z53.strictObject({
5322
+ var HostedApprovalInputSchema = z59.strictObject({
5323
+ expectedProposalDigest: digest25,
5324
+ reviewedMeaning: z59.literal(true),
5325
+ reviewedFixtures: z59.literal(true),
5326
+ reviewNote: z59.string().min(1).max(2e3)
5327
+ });
5328
+ var HostedReleaseInputSchema = z59.strictObject({
5329
+ expectedApprovalDigest: digest25,
5330
+ acceptBars: AcceptedBarsSchema.optional(),
5331
+ environment: PackEnvironmentSchema.optional()
5332
+ });
5333
+ var HostedReleaseBundleSchema = z59.strictObject({
4604
5334
  release: DraftApplicationReleaseSchema,
4605
5335
  material: DraftAnyApplicationJobMaterialSchema,
4606
- approvalObjectId: id7,
4607
- approvalDigest: digest23,
4608
- proposalDigest: digest23,
4609
- sourceDigest: digest23,
4610
- verifiedCompilation: DraftVerifiedCompilationSchema.optional()
4611
- });
4612
- var HostedJobInputSchema = z53.strictObject({
4613
- executionId: id7,
4614
- expectedReleaseDigest: digest23,
5336
+ approvalObjectId: id9,
5337
+ approvalDigest: digest25,
5338
+ proposalDigest: digest25,
5339
+ sourceDigest: digest25,
5340
+ verifiedCompilation: DraftVerifiedCompilationSchema.optional(),
5341
+ calibration: ReleaseCalibrationSchema.optional()
5342
+ });
5343
+ var HostedJobInputSchema = z59.strictObject({
5344
+ executionId: id9,
5345
+ expectedReleaseDigest: digest25,
4615
5346
  material: DraftAnyApplicationJobMaterialSchema
4616
5347
  });
4617
- var HostedSuppliedJobInputSchema = z53.strictObject({
4618
- mode: z53.literal("supplied"),
4619
- executionId: id7,
4620
- expectedReleaseDigest: digest23,
4621
- expectedAuthorityDigest: digest23,
4622
- jobId: id7,
4623
- entityId: id7,
5348
+ var HostedSuppliedJobInputSchema = z59.strictObject({
5349
+ mode: z59.literal("supplied"),
5350
+ executionId: id9,
5351
+ expectedReleaseDigest: digest25,
5352
+ expectedAuthorityDigest: digest25,
5353
+ jobId: id9,
5354
+ entityId: id9,
4624
5355
  evidence: DraftRequiredDecisionSchema.shape.evidence,
4625
5356
  passages: DraftLayeredEvaluationSchema.shape.passages.max(256)
4626
5357
  });
@@ -4630,97 +5361,186 @@ var hostedFactsLimits = {
4630
5361
  maxFactsBytes: 524288,
4631
5362
  maxQuestions: 64
4632
5363
  };
4633
- var factSourceId = z53.string().refine(isDraftSourceId, "source_id_invalid").describe(`The source's own ID or address, such as its page URL with any query: RFC 3986 characters, starting with a letter or digit, at most ${draftSourceIdLimit} characters.`);
4634
- var observedAt = z53.string().refine((value) => normalizedSourceInstant(value) !== null, "observed_at_invalid").transform((value) => normalizedSourceInstant(value) ?? value).describe(`When the source was read: an RFC 3339 date and time with Z or an offset, such as 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00, at most ${sourceInstantMaxLength} characters. Stored in UTC.`);
4635
- var factSource = z53.strictObject({
4636
- class: id7,
5364
+ var factSourceId = z59.string().refine(isDraftSourceId, "source_id_invalid").describe(`The source's own ID or address, such as its page URL with any query: RFC 3986 characters, starting with a letter or digit, at most ${draftSourceIdLimit} characters.`);
5365
+ var observedAt = z59.string().refine((value2) => normalizedSourceInstant(value2) !== null, "observed_at_invalid").transform((value2) => normalizedSourceInstant(value2) ?? value2).describe(`When the source was read: an RFC 3339 date and time with Z or an offset, such as 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00, at most ${sourceInstantMaxLength} characters. Stored in UTC.`);
5366
+ var sourceFields = {
5367
+ class: id9,
4637
5368
  id: factSourceId,
4638
- revision: id7.optional(),
4639
- locator: z53.string().min(1).max(4096).optional(),
5369
+ revision: id9.optional(),
5370
+ locator: z59.string().min(1).max(4096).optional(),
4640
5371
  observedAt,
4641
- sensitivity: id7.optional()
4642
- });
4643
- var excerptText = z53.string().min(1).refine((text8) => text8.length <= hostedFactsLimits.maxExcerptCharacters, "text_too_long");
4644
- var about = z53.string().min(1).max(200).optional();
4645
- var HostedExcerptSchema = z53.strictObject({ text: excerptText, source: factSource, about });
4646
- var HostedValueFactSchema = z53.strictObject({
4647
- value: z53.union([z53.string().min(1).max(200), z53.number(), z53.boolean()]),
4648
- source: factSource.extend({ excerpt: excerptText.optional() }),
4649
- about
4650
- });
4651
- var HostedFactSchema = z53.union([
4652
- HostedValueFactSchema,
4653
- HostedExcerptSchema,
4654
- z53.array(HostedExcerptSchema).min(1).refine((excerpts2) => excerpts2.length <= hostedFactsLimits.maxExcerptsPerQuestion, "too_many_excerpts")
4655
- ]);
5372
+ sensitivity: id9.optional()
5373
+ };
5374
+ var manualSourcePrefix = "felspar:";
5375
+ var suppliedBy = z59.string().trim().min(1).max(200);
5376
+ var isReserved = (sourceId2) => sourceId2?.toLowerCase().startsWith(manualSourcePrefix) === true;
5377
+ function sourceIssues(source3) {
5378
+ if (source3.manual === true) {
5379
+ return [
5380
+ ...source3.id === void 0 ? [] : [{ path: ["id"], code: "manual_source_id" }],
5381
+ ...source3.revision === void 0 ? [] : [{ path: ["revision"], code: "manual_source_id" }]
5382
+ ];
5383
+ }
5384
+ return [
5385
+ ...source3.id === void 0 ? [{ path: ["id"], code: "source_id_required" }] : [],
5386
+ ...isReserved(source3.id) ? [{ path: ["id"], code: "source_id_reserved" }] : [],
5387
+ ...source3.observedAt === void 0 ? [{ path: ["observedAt"], code: "observed_at_required" }] : [],
5388
+ ...source3.suppliedBy === void 0 ? [] : [{ path: ["suppliedBy"], code: "supplied_by_needs_manual" }]
5389
+ ];
5390
+ }
5391
+ function isAdmittedManual(source3) {
5392
+ return source3.by !== void 0 && source3.id === void 0 && source3.revision === void 0;
5393
+ }
5394
+ function isAdmittedOrdinary(source3) {
5395
+ const isUnmarked = source3.by === void 0 && source3.stamped === void 0 && source3.suppliedBy === void 0;
5396
+ return source3.id !== void 0 && isUnmarked;
5397
+ }
5398
+ function isAdmitted(source3) {
5399
+ return source3.manual === true ? isAdmittedManual(source3) : isAdmittedOrdinary(source3);
5400
+ }
5401
+ var excerptText = z59.string().min(1).refine((text8) => text8.length <= hostedFactsLimits.maxExcerptCharacters, "text_too_long");
5402
+ var valueSourceFields = { excerpt: excerptText.optional() };
5403
+ var requestSourceFields = {
5404
+ ...sourceFields,
5405
+ id: factSourceId.optional(),
5406
+ observedAt: observedAt.optional(),
5407
+ manual: z59.literal(true).optional(),
5408
+ suppliedBy: suppliedBy.optional()
5409
+ };
5410
+ function refusedSourceIssues(source3, context3) {
5411
+ for (const issue of sourceIssues(source3)) {
5412
+ context3.addIssue({ code: "custom", path: issue.path, message: issue.code });
5413
+ }
5414
+ }
5415
+ var admittedSourceFields = {
5416
+ ...sourceFields,
5417
+ id: factSourceId.optional(),
5418
+ manual: z59.literal(true).optional(),
5419
+ suppliedBy: suppliedBy.optional(),
5420
+ by: id9.optional(),
5421
+ stamped: z59.literal(true).optional()
5422
+ };
5423
+ var requestSource = z59.strictObject(requestSourceFields).superRefine(refusedSourceIssues);
5424
+ var requestValueSource = z59.strictObject({ ...requestSourceFields, ...valueSourceFields }).superRefine(refusedSourceIssues);
5425
+ var admittedSource = z59.strictObject(admittedSourceFields).refine(isAdmitted, "source_not_admitted");
5426
+ var admittedValueSource = z59.strictObject({ ...admittedSourceFields, ...valueSourceFields }).refine(isAdmitted, "source_not_admitted");
5427
+ var about = z59.string().min(1).max(200).optional();
5428
+ var hostedCaseRecordLimits = {
5429
+ maxExcerptsPerQuestion: 30,
5430
+ maxExcerpts: hostedFactsLimits.maxQuestions * hostedFactsLimits.maxExcerptsPerQuestion,
5431
+ maxAttempts: 12
5432
+ };
5433
+ function factSchemas(source3, valueSource, isRecord) {
5434
+ const excerpt2 = z59.strictObject({ text: excerptText, source: source3, about });
5435
+ const valueFact = z59.strictObject({
5436
+ value: z59.union([z59.string().min(1).max(200), z59.number(), z59.boolean()]),
5437
+ source: valueSource,
5438
+ about
5439
+ });
5440
+ const cap = isRecord ? hostedCaseRecordLimits.maxExcerptsPerQuestion : hostedFactsLimits.maxExcerptsPerQuestion;
5441
+ const listed = isRecord ? z59.union([excerpt2, valueFact]) : excerpt2;
5442
+ const fact = z59.union([
5443
+ valueFact,
5444
+ excerpt2,
5445
+ z59.array(listed).min(1).refine((excerpts2) => excerpts2.length <= cap, "too_many_excerpts")
5446
+ ]);
5447
+ return { excerpt: excerpt2, valueFact, fact };
5448
+ }
5449
+ var admittedFacts = factSchemas(admittedSource, admittedValueSource, true);
5450
+ var requestFacts = factSchemas(requestSource, requestValueSource, false);
5451
+ var HostedExcerptSchema = admittedFacts.excerpt;
5452
+ var HostedValueFactSchema = admittedFacts.valueFact;
5453
+ var HostedFactSchema = admittedFacts.fact;
4656
5454
  function factsBytes(facts) {
4657
5455
  const encoder2 = new TextEncoder();
4658
5456
  return encoder2.encode(JSON.stringify(facts)).length;
4659
5457
  }
4660
- var HostedFactsJobInputSchema = z53.strictObject({
4661
- mode: z53.literal("facts"),
4662
- executionId: id7,
4663
- expectedReleaseDigest: digest23,
4664
- jobId: id7,
4665
- entityId: id7,
5458
+ function questionsOf(fact) {
5459
+ return z59.record(id9, fact).refine((facts) => Object.keys(facts).length <= hostedFactsLimits.maxQuestions, "too_many_questions");
5460
+ }
5461
+ function factsOf(fact) {
5462
+ return questionsOf(fact).refine((facts) => factsBytes(facts) <= hostedFactsLimits.maxFactsBytes, "request_too_large");
5463
+ }
5464
+ var HostedFactsJobInputSchema = z59.strictObject({
5465
+ mode: z59.literal("facts"),
5466
+ executionId: id9,
5467
+ expectedReleaseDigest: digest25,
5468
+ jobId: id9,
5469
+ entityId: id9,
4666
5470
  related: HostedRelatedSubjectsSchema.optional(),
4667
- identity: z53.record(z53.string().min(1).max(128), z53.string().min(1).max(200)).optional(),
4668
- facts: z53.record(id7, HostedFactSchema).refine((facts) => Object.keys(facts).length <= hostedFactsLimits.maxQuestions, "too_many_questions").refine((facts) => factsBytes(facts) <= hostedFactsLimits.maxFactsBytes, "request_too_large")
5471
+ identity: z59.record(z59.string().min(1).max(128), z59.string().min(1).max(200)).optional(),
5472
+ facts: questionsOf(HostedFactSchema)
4669
5473
  });
4670
5474
  var HostedFactsRequestSchema = HostedFactsJobInputSchema.extend({
4671
- entityId: id7.optional()
5475
+ entityId: id9.optional(),
5476
+ facts: factsOf(requestFacts.fact)
4672
5477
  });
4673
- var HostedJobRequestSchema = z53.union([
5478
+ var HostedJobRequestSchema = z59.union([
4674
5479
  HostedJobInputSchema,
4675
5480
  HostedSuppliedJobInputSchema,
4676
5481
  HostedFactsJobInputSchema
4677
5482
  ]);
4678
- var HostedClassificationResultSchema = z53.strictObject({
4679
- key: id7,
4680
- observationId: id7,
5483
+ var HostedClassificationResultSchema = z59.strictObject({
5484
+ key: id9,
5485
+ observationId: id9,
4681
5486
  record: DraftNormalizedEvidenceSchema.shape.normalizations.element,
4682
- reason: z53.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
4683
- cached: z53.boolean()
5487
+ reason: z59.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
5488
+ cached: z59.boolean()
4684
5489
  });
4685
5490
  function retainsFactsExactly(record) {
4686
5491
  const hasFacts = record.facts !== void 0 && record.judgments !== void 0 && record.judgmentsDigest !== void 0;
4687
5492
  return record.schema === "felspar.hosted-supplied-execution/v3" === hasFacts;
4688
5493
  }
4689
- var HostedSuppliedExecutionRecordSchema = z53.strictObject({
4690
- schema: z53.enum([
5494
+ var HostedCaseAttemptSchema = z59.strictObject({
5495
+ executionId: id9,
5496
+ added: z59.array(z59.string().min(1).max(draftSourceIdLimit + 4200)).max(192),
5497
+ considered: z59.boolean()
5498
+ });
5499
+ var HostedCaseRecordSchema = z59.strictObject({
5500
+ rule: z59.literal("whole-case"),
5501
+ attempt: z59.number().int().min(1).max(hostedCaseRecordLimits.maxAttempts + 1),
5502
+ attempts: z59.array(HostedCaseAttemptSchema).min(1).max(hostedCaseRecordLimits.maxAttempts + 1),
5503
+ facts: questionsOf(HostedFactSchema).optional()
5504
+ });
5505
+ var HostedSuppliedExecutionRecordSchema = z59.strictObject({
5506
+ schema: z59.enum([
4691
5507
  "felspar.hosted-supplied-execution/v1",
4692
5508
  "felspar.hosted-supplied-execution/v2",
4693
5509
  "felspar.hosted-supplied-execution/v3"
4694
5510
  ]),
4695
- release: z53.strictObject({ releaseId: id7, releaseDigest: digest23, materialDigest: digest23 }),
4696
- evaluationTime: z53.iso.datetime(),
5511
+ release: z59.strictObject({ releaseId: id9, releaseDigest: digest25, materialDigest: digest25 }),
5512
+ evaluationTime: z59.iso.datetime(),
4697
5513
  input: HostedSuppliedJobInputSchema,
4698
5514
  facts: HostedFactsJobInputSchema.optional(),
4699
- judgments: z53.array(HostedClassificationResultSchema).max(192).optional(),
4700
- judgmentsDigest: digest23.optional(),
4701
- expansion: z53.literal("agreeing-excerpts").optional(),
4702
- job: z53.record(z53.string(), z53.unknown())
4703
- }).refine(retainsFactsExactly, "Version 3 records, and only they, retain facts with their judgments");
4704
- var HostedObjectSchema = z53.strictObject({
4705
- id: id7,
4706
- kind: z53.enum(["source", "proposal", "approval", "release", "evidence", "result", "execution"]),
4707
- payloadDigest: digest23,
4708
- objectKey: z53.string().min(1).max(1e3),
4709
- parentId: id7.nullable(),
4710
- status: z53.enum(["active", "released", "revoked"]),
4711
- metadata: z53.record(z53.string(), z53.unknown())
4712
- });
4713
- var HostedJobResultSchema = z53.object({
4714
- status: z53.string(),
4715
- reason: z53.string().nullable(),
4716
- result: z53.object({
4717
- executionId: z53.string(),
4718
- releaseId: id7,
4719
- releaseDigest: digest23,
4720
- outcome: z53.string().nullable(),
4721
- scoring: z53.unknown(),
4722
- context: z53.unknown(),
4723
- receipt: z53.unknown()
5515
+ judgments: z59.array(HostedClassificationResultSchema).max(192).optional(),
5516
+ judgmentsDigest: digest25.optional(),
5517
+ expansion: z59.enum(["agreeing-excerpts", "agreeing-excerpts/v2"]).optional(),
5518
+ caseRecord: HostedCaseRecordSchema.optional(),
5519
+ decisionAttempt: DecisionGraphAttemptSchema.optional(),
5520
+ job: z59.record(z59.string(), z59.unknown())
5521
+ }).refine(retainsFactsExactly, "Version 3 records, and only they, retain facts with their judgments").refine((record) => record.caseRecord === void 0 || record.facts !== void 0, {
5522
+ message: "Only a facts record keeps a case record"
5523
+ });
5524
+ var HostedObjectSchema = z59.strictObject({
5525
+ id: id9,
5526
+ kind: z59.enum(["source", "proposal", "approval", "release", "evidence", "result", "execution"]),
5527
+ payloadDigest: digest25,
5528
+ objectKey: z59.string().min(1).max(1e3),
5529
+ parentId: id9.nullable(),
5530
+ status: z59.enum(["active", "released", "revoked"]),
5531
+ metadata: z59.record(z59.string(), z59.unknown())
5532
+ });
5533
+ var HostedJobResultSchema = z59.object({
5534
+ status: z59.string(),
5535
+ reason: z59.string().nullable(),
5536
+ result: z59.object({
5537
+ executionId: z59.string(),
5538
+ releaseId: id9,
5539
+ releaseDigest: digest25,
5540
+ outcome: z59.string().nullable(),
5541
+ scoring: z59.unknown(),
5542
+ context: z59.unknown(),
5543
+ receipt: z59.unknown()
4724
5544
  }).loose().nullable()
4725
5545
  });
4726
5546
 
@@ -4730,6 +5550,12 @@ var formatFix = "The request does not match the facts request format at this pat
4730
5550
  var fixes = {
4731
5551
  observed_at_invalid: "Send observedAt as the date and time the source was read, with Z or an offset: for example 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00. A date alone, a time with no offset or words such as yesterday are not accepted.",
4732
5552
  source_id_invalid: `Send source.id as the source's own ID or address, such as a ticket number or a document URL with its query: at most ${draftSourceIdLimit} characters, starting with a letter or digit, using URL characters only (percent-encode spaces and non-ASCII characters).`,
5553
+ source_id_required: "Send source.id: the source's own ID or address. For words a person gave you, mark the source manual: true instead and leave id out.",
5554
+ observed_at_required: "Send source.observedAt: when the source was read, with Z or an offset. For words a person gave you, mark the source manual: true and Felspar stamps the time it received them.",
5555
+ source_id_reserved: "Source IDs starting with felspar: are Felspar's own. Send the source's own ID, or mark words a person gave you manual: true with no id.",
5556
+ manual_source_id: "A manual source takes no id or revision. Name the source the person gave in locator, such as the record or message it came from.",
5557
+ supplied_by_needs_manual: "suppliedBy is only for words a person gave you: mark that source manual: true, or leave suppliedBy out.",
5558
+ manual_facts_refused: "This job's pack refuses facts supplied by a person (its manualFacts setting). Quote the source record itself, with its source.id and observedAt, or leave the question out.",
4733
5559
  unknown_question: "This question is not in the released job. Use the question keys from describe.",
4734
5560
  source_class_not_accepted: "This question does not accept this source class. Send an excerpt from a source class the question's evidence policy in describe lists.",
4735
5561
  value_not_in_excerpt: "The quoted words do not state this value. Quote the exact words that state it, or send the text without a typed value.",
@@ -4746,6 +5572,7 @@ var fixes = {
4746
5572
  job_mismatch: "This release serves a different job. Use the job and release from describe.",
4747
5573
  job_retired: "The workspace owner retired this job. Don't call it again: use the job named in replacement (check it with list_jobs), or, if replacement is null, tell the person the job is retired and stop.",
4748
5574
  attempt_limit_reached: "This case has used its decision attempts. Don't ask again: escalate it with the escalation this refusal names (report its id exactly), or with the next step from your last result.",
5575
+ case_in_progress: "This case is already being decided. Wait for the first attempt's decision, then resend that attempt unchanged with the same executionId to read it. Send new evidence only after it finishes.",
4749
5576
  subject_id_invalid: "Send the case's ID as the job's subject describes it (its identifier and example in the job requirements): letters, digits and . _ : @ - only.",
4750
5577
  unknown_relationship: "This job's subject has no relationship of this name. Use a relationship listed under subject.related in the job requirements, or leave related out.",
4751
5578
  related_subject_required: "A question you answered is about a related record. Send that record's ID under related.<relationship>, and quote that record for the question.",
@@ -4784,6 +5611,8 @@ var fixes = {
4784
5611
  proposal_closed: "This proposal was released, rejected, withdrawn or replaced by a newer proposal, so nothing more can be done with it. Call list_jobs for the job's open proposals.",
4785
5612
  not_proposer: "Only the person who made a proposal may withdraw it; an approver may reject it.",
4786
5613
  not_job_approver: "Only this job's owner and named approvers, or a workspace owner, may approve, release or reject its proposals. details.owners names who may; ask one of them to review it on the Felspar web page.",
5614
+ own_proposal: "The person who proposed a change can't approve it while another approver can. details.reason says why; ask one of the job's other approvers to review it on the Felspar web page.",
5615
+ proposal_review_unavailable: "This proposal's review can't be read. Call list_jobs for the job's open proposals.",
4787
5616
  withdraw_on_web_page: "Withdraw a proposal on the Felspar web page, or propose the job again, which replaces your earlier proposal.",
4788
5617
  change_request_needs_release: "This job has no release yet, so there is no document version to propose changes on. Draft its first pack with check_pack and propose_pack.",
4789
5618
  change_request_quote_invalid: "Each change must quote a passage exactly as it is in the release's version of the document (read_source on the source list_jobs names), found exactly once, with changes that don't overlap and a replacement that differs. details.problems names each change by its index: quote_not_found, quote_not_unique (quote more of the passage), edits_overlap or edit_unchanged.",
@@ -4795,9 +5624,27 @@ var fixes = {
4795
5624
  change_request_comment_limit: "This change request has as many comments as it can hold. Continue the discussion on the Felspar web page.",
4796
5625
  change_request_closed: "This change request is already closed.",
4797
5626
  change_request_close_on_web_page: "Withdraw or reject a change request on the Felspar web page; opening the job's change request again replaces your earlier one.",
5627
+ environments_on_web_page: "Releasing to staging, promoting and rolling back are a person's click on the Felspar web page. Read which release each environment serves with read_environments and tell the person.",
5628
+ staging_agent_pinned: "A staging agent follows its jobs and is never pinned. Register it with its jobs on Latest, or register a production agent to pin a release.",
5629
+ nothing_staged: "Nothing is released to staging for this job. An approver releases a proposal or a change request's candidate to staging on the Felspar web page.",
5630
+ environment_release_unavailable: "Only a live release of this job that production has served can be staged or rolled back to. Pick one from the job's environments.",
5631
+ environment_moved: "The environment moved since the page was read: it no longer serves the release you expected. Reload the job's environments and decide again.",
5632
+ promotion_out_of_date: "Production moved after this staged release was proposed, so promoting it would replace newer production meaning. Propose the change again on production's current release, or roll production back on purpose.",
5633
+ document_not_captured: "Felspar has no captured version of this document to compare with the candidate. Add its current version (add_current_version or the Sources page), then promote again.",
5634
+ document_not_updated: "The document's newest captured version doesn't hold exactly the candidate's text. details.missing names the change request's changes still missing by index: edit the document to match, add its current version and promote again.",
5635
+ candidate_needs_promotion: "This proposal was built on a change request's text that the document may not hold, so it is released to staging, never straight to production. Release it to staging, then promote it once the document holds exactly that text.",
5636
+ change_request_not_stageable: "Only an open, up-to-date change request with a revised pack draft, built on production's current release, can be released to staging. Open the change request again on the current release.",
4798
5637
  proposal_draft_invalid: "A proposal's draft must be a valid felspar.pack-draft for the proposal's own job. Propose with propose_pack, which keeps the draft it checked.",
4799
5638
  preview_too_large: "This draft changes more than one preview can show (2,048 item changes or 64 breaking changes). Preview a smaller revision, or split the pack.",
5639
+ backtest_allowance_used: "This proposal has used its whole fresh-read allowance, which all its backtests share. Backtest it again without reinterpret: true: the answers already read are reused and nothing new is read.",
4800
5640
  preview_reinterpret_blocked: "Fix the draft's blocking findings (check_pack lists them) before previewing with reinterpret: true. A preview without reinterpret still runs.",
5641
+ readings_blocked: "Fix the draft's blocking findings (check_pack lists them) before check_readings reads its wording.",
5642
+ nothing_to_read: "Send phrasings in variants, or add readingTests to the draft: there is nothing to read.",
5643
+ too_many_readings: `Read at most ${readingCheckLimits.maxPerCheck} phrasings per check_readings call, the draft's readingTests included. Split them across calls, or send include_tests: false.`,
5644
+ too_many_per_answer: `Send at most ${readingCheckLimits.maxPerAnswer} phrasings per answer (and per question for phrasings with no expected answer), the draft's readingTests included.`,
5645
+ duplicate_reading: "Two phrasings have the same id (a readingTests id counts too). Give each its own id, or leave id out.",
5646
+ question_not_read: "check_readings reads only choice questions Felspar classifies from text: not number, date or derived questions. Use a choice question's key from the draft.",
5647
+ answer_not_in_question: "expect must be one of that question's answer values in the draft.",
4801
5648
  pack_job_mismatch: "That release or proposal belongs to another job. Pass the jobId list_jobs shows with it.",
4802
5649
  decision_not_found: "Check the output against a decision this caller made: send the executionId from your get_job_decision result for this job.",
4803
5650
  decision_not_decided: "This decision has no outcome, so nothing is written for it. Follow its next step instead.",
@@ -4817,7 +5664,12 @@ var hostedRefusalCodes = Object.freeze(Object.keys(fixes));
4817
5664
  function hostedRefusalFix(code) {
4818
5665
  return Object.hasOwn(fixes, code) ? fixes[code] ?? null : null;
4819
5666
  }
4820
- var retried = /* @__PURE__ */ new Set(["rate_limited", "history_unavailable", "operation_unavailable"]);
5667
+ var retried = /* @__PURE__ */ new Set([
5668
+ "case_in_progress",
5669
+ "rate_limited",
5670
+ "history_unavailable",
5671
+ "operation_unavailable"
5672
+ ]);
4821
5673
  var escalated = /* @__PURE__ */ new Set([
4822
5674
  "unauthenticated",
4823
5675
  "forbidden",
@@ -4839,236 +5691,254 @@ function hostedRefusalRecovery(code) {
4839
5691
  }
4840
5692
 
4841
5693
  // ../schemas/src/draft-hosted-job-description.ts
4842
- import { z as z55 } from "zod";
5694
+ import { z as z61 } from "zod";
4843
5695
 
4844
5696
  // ../schemas/src/draft-hosted-output-guides.ts
4845
- import { z as z54 } from "zod";
4846
- var id8 = z54.string().min(1).max(200);
4847
- var located = z54.strictObject({
4848
- text: z54.string().min(1).max(262144),
4849
- locator: z54.string().min(1).max(4096)
5697
+ import { z as z60 } from "zod";
5698
+ var id10 = z60.string().min(1).max(200);
5699
+ var located = z60.strictObject({
5700
+ text: z60.string().min(1).max(262144),
5701
+ locator: z60.string().min(1).max(4096)
4850
5702
  });
4851
5703
  var hostedOutputGuideLimits = { maxOutputs: 8, maxContext: 8, maxChecks: 64 };
4852
- var HostedOutputGuideSchema = z54.strictObject({
4853
- id: id8,
5704
+ var HostedOutputGuideSchema = z60.strictObject({
5705
+ id: id10,
4854
5706
  what: located,
4855
- maxCharacters: z54.number().int().min(1),
4856
- context: z54.array(located.extend({ id: id8 })).max(hostedOutputGuideLimits.maxContext).optional(),
4857
- checks: z54.array(z54.strictObject({
4858
- check: id8,
4859
- rule: z54.string().nullable(),
4860
- must: z54.string().min(1).max(8e3)
5707
+ maxCharacters: z60.number().int().min(1),
5708
+ context: z60.array(located.extend({ id: id10 })).max(hostedOutputGuideLimits.maxContext).optional(),
5709
+ checks: z60.array(z60.strictObject({
5710
+ check: id10,
5711
+ rule: z60.string().nullable(),
5712
+ must: z60.string().min(1).max(8e3)
4861
5713
  })).max(hostedOutputGuideLimits.maxChecks)
4862
5714
  });
4863
- var HostedOutputGuidesSchema = z54.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
5715
+ var HostedOutputGuidesSchema = z60.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
4864
5716
 
4865
5717
  // ../schemas/src/draft-hosted-job-description.ts
4866
- var id9 = z55.string().min(1).max(200);
4867
- var digest24 = DraftApplicationReleaseSchema.shape.releaseDigest;
5718
+ var id11 = z61.string().min(1).max(200);
5719
+ var digest26 = DraftApplicationReleaseSchema.shape.releaseDigest;
4868
5720
  var { requirements, rules } = DraftRequiredProposalSchema.shape;
4869
- var quotedText = z55.strictObject({
4870
- text: z55.string().min(1).max(262144),
5721
+ var quotedText = z61.strictObject({
5722
+ text: z61.string().min(1).max(262144),
4871
5723
  source: DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
4872
- locator: z55.string().min(1).max(4096),
4873
- contentDigest: digest24
5724
+ locator: z61.string().min(1).max(4096),
5725
+ contentDigest: digest26
4874
5726
  }),
4875
- parts: z55.array(z55.strictObject({ locator: z55.string().min(1).max(4096), text: z55.string() })).max(16)
5727
+ parts: z61.array(z61.strictObject({ locator: z61.string().min(1).max(4096), text: z61.string() })).max(16)
4876
5728
  });
4877
5729
  var subjectShape = {
4878
- identifier: z55.string().min(1).max(200),
4879
- example: z55.string().min(1).max(200),
4880
- match: z55.enum(subjectMatchRules)
5730
+ identifier: z61.string().min(1).max(200),
5731
+ example: z61.string().min(1).max(200),
5732
+ match: z61.enum(subjectMatchRules)
4881
5733
  };
4882
- var HostedJobSubjectSchema = z55.strictObject({
4883
- type: id9,
5734
+ var HostedJobSubjectSchema = z61.strictObject({
5735
+ type: id11,
4884
5736
  definition: quotedText,
4885
5737
  identifier: subjectShape.identifier.optional(),
4886
5738
  example: subjectShape.example.optional(),
4887
5739
  match: subjectShape.match,
4888
- related: z55.array(z55.strictObject({
4889
- relationship: id9,
5740
+ related: z61.array(z61.strictObject({
5741
+ relationship: id11,
4890
5742
  meaning: quotedText,
4891
- cardinality: z55.enum(relationshipCardinalities),
4892
- required: z55.boolean(),
4893
- subject: id9,
5743
+ cardinality: z61.enum(relationshipCardinalities),
5744
+ required: z61.boolean(),
5745
+ subject: id11,
4894
5746
  definition: quotedText,
4895
5747
  ...subjectShape
4896
5748
  })).max(16),
4897
- send: z55.string().min(1).max(2e4)
5749
+ send: z61.string().min(1).max(2e4)
4898
5750
  });
4899
- var HostedJobEscalationsSchema = z55.strictObject({
4900
- routes: z55.array(z55.strictObject({ id: id9, quote: quotedText })).min(1).max(16),
4901
- unresolved: id9.nullable(),
4902
- attemptLimit: id9.nullable(),
4903
- rule: z55.string().min(1).max(1e3)
5751
+ var HostedJobEscalationsSchema = z61.strictObject({
5752
+ routes: z61.array(z61.strictObject({ id: id11, quote: quotedText })).min(1).max(16),
5753
+ unresolved: id11.nullable(),
5754
+ attemptLimit: id11.nullable(),
5755
+ rule: z61.string().min(1).max(1e3)
4904
5756
  });
4905
- var HostedEscalationSchema = z55.strictObject({
4906
- id: id9,
4907
- trigger: z55.enum(escalationTriggers),
5757
+ var HostedEscalationSchema = z61.strictObject({
5758
+ id: id11,
5759
+ trigger: z61.enum(escalationTriggers),
4908
5760
  why: quotedText
4909
5761
  });
4910
- var HostedJobDescriptionSchema = z55.strictObject({
4911
- schema: z55.literal("felspar.hosted-job-description.draft/v0"),
4912
- job: id9,
5762
+ var HostedJobDescriptionSchema = z61.strictObject({
5763
+ schema: z61.literal("felspar.hosted-job-description.draft/v0"),
5764
+ job: id11,
4913
5765
  purpose: quotedText.optional(),
4914
- useWhen: z55.array(quotedText).max(8).optional(),
4915
- notFor: z55.array(quotedText).max(8).optional(),
5766
+ useWhen: z61.array(quotedText).max(8).optional(),
5767
+ notFor: z61.array(quotedText).max(8).optional(),
4916
5768
  owner: quotedText.optional(),
4917
5769
  subject: HostedJobSubjectSchema.optional(),
4918
- identity: z55.strictObject({
4919
- mode: z55.enum(identityModes),
4920
- send: z55.string().min(1).max(4e3),
4921
- fields: z55.array(z55.strictObject({ name: id9, ...subjectShape })).max(8).optional(),
4922
- question: id9.optional()
5770
+ identity: z61.strictObject({
5771
+ mode: z61.enum(identityModes),
5772
+ send: z61.string().min(1).max(4e3),
5773
+ fields: z61.array(z61.strictObject({ name: id11, ...subjectShape })).max(8).optional(),
5774
+ question: id11.optional()
4923
5775
  }).optional(),
4924
- trustDomain: id9,
4925
- release: z55.strictObject({
4926
- releaseId: id9,
4927
- releaseDigest: digest24,
4928
- materialDigest: digest24,
4929
- expectedAuthorityDigest: digest24
5776
+ manualFacts: z61.strictObject({ allowed: z61.literal(false), quote: z61.string().min(1).max(4e3) }).optional(),
5777
+ trustDomain: id11,
5778
+ release: z61.strictObject({
5779
+ releaseId: id11,
5780
+ releaseDigest: digest26,
5781
+ materialDigest: digest26,
5782
+ expectedAuthorityDigest: digest26
4930
5783
  }),
4931
5784
  resolutionPolicy: DraftRequiredProposalSchema.shape.resolutionPolicy,
4932
- questions: z55.array(requirements.element.extend({
4933
- key: id9,
4934
- type: z55.enum(["enum", "boolean", "number", "date"]),
5785
+ questions: z61.array(requirements.element.extend({
5786
+ key: id11,
5787
+ type: z61.enum(["enum", "boolean", "number", "date"]),
4935
5788
  meaning: quotedText,
4936
- answer: z55.strictObject({
4937
- send: z55.enum(["text", "text_or_value"]),
4938
- valueFormat: z55.enum(["number", "calendar-date"]).nullable(),
4939
- interpretation: z55.enum(["classified", "exact_read", "unsupported"]),
4940
- threshold: z55.number().gt(0).max(1).nullable(),
4941
- applies: z55.enum(["always", "conditional"]),
4942
- dependsOn: z55.array(id9).max(32),
4943
- appliesWhen: z55.string().min(1).max(2e3).nullable(),
5789
+ answer: z61.strictObject({
5790
+ send: z61.enum(["text", "text_or_value"]),
5791
+ valueFormat: z61.enum(["number", "calendar-date"]).nullable(),
5792
+ interpretation: z61.enum(["classified", "exact_read", "unsupported"]),
5793
+ threshold: z61.number().gt(0).max(1).nullable(),
5794
+ applies: z61.enum(["always", "conditional"]),
5795
+ dependsOn: z61.array(id11).max(32),
5796
+ appliesWhen: z61.string().min(1).max(2e3).nullable(),
4944
5797
  reading: ExactReaderSchema.optional()
4945
5798
  }),
4946
- answers: z55.array(z55.strictObject({
4947
- value: id9,
4948
- meaning: z55.string().nullable(),
4949
- inclusions: z55.array(z55.string()).max(8),
4950
- exclusions: z55.array(z55.string()).max(8),
4951
- examples: z55.array(z55.string()).max(8),
4952
- edgeCases: z55.array(z55.string()).max(8)
5799
+ answers: z61.array(z61.strictObject({
5800
+ value: id11,
5801
+ meaning: z61.string().nullable(),
5802
+ inclusions: z61.array(z61.string()).max(8),
5803
+ exclusions: z61.array(z61.string()).max(8),
5804
+ examples: z61.array(z61.string()).max(8),
5805
+ edgeCases: z61.array(z61.string()).max(8)
4953
5806
  })).max(64).optional(),
4954
- whereToLook: z55.array(quotedText).max(8).optional(),
4955
- about: z55.strictObject({ relationship: id9, subject: id9 }).optional()
5807
+ whereToLook: z61.array(quotedText).max(8).optional(),
5808
+ about: z61.strictObject({ relationship: id11, subject: id11 }).optional()
4956
5809
  })).max(64),
4957
- rules: z55.array(rules.element.extend({ text: quotedText })).max(256),
4958
- outcomes: z55.array(z55.strictObject({
4959
- id: id9,
5810
+ rules: z61.array(rules.element.extend({ text: quotedText })).max(256),
5811
+ outcomes: z61.array(z61.strictObject({
5812
+ id: id11,
4960
5813
  meaning: quotedText.nullable(),
4961
5814
  nextStep: quotedText.nullable().optional(),
4962
5815
  outputs: HostedOutputGuidesSchema.optional(),
4963
- escalate: id9.optional()
5816
+ escalate: id11.optional()
4964
5817
  })).max(64),
4965
5818
  escalations: HostedJobEscalationsSchema.optional(),
4966
5819
  whenUnresolved: quotedText.nullable().optional(),
4967
- attempts: z55.strictObject({
4968
- max: z55.number().int().min(1).max(10),
4969
- withProgress: z55.number().int().min(1).max(10),
4970
- rule: z55.string().min(1).max(1e3)
5820
+ attempts: z61.strictObject({
5821
+ max: z61.number().int().min(1).max(10),
5822
+ withProgress: z61.number().int().min(1).max(10),
5823
+ rule: z61.string().min(1).max(1e3)
4971
5824
  }).optional(),
4972
- guidance: z55.strictObject({ gather: z55.string().min(1).max(2e3) }),
4973
- input: z55.strictObject({
4974
- jsonSchema: z55.record(z55.string(), z55.unknown()),
5825
+ guidance: z61.strictObject({ gather: z61.string().min(1).max(2e3) }),
5826
+ input: z61.strictObject({
5827
+ jsonSchema: z61.record(z61.string(), z61.unknown()),
4975
5828
  example: HostedFactsJobInputSchema.nullable(),
4976
- exampleNote: z55.string().max(1e3)
5829
+ exampleNote: z61.string().max(1e3)
4977
5830
  }),
4978
- limits: z55.strictObject({
4979
- maxEvidenceItems: z55.number().int().positive(),
4980
- maxPassages: z55.number().int().positive(),
4981
- facts: z55.strictObject({
4982
- maxExcerptCharacters: z55.literal(hostedFactsLimits.maxExcerptCharacters),
4983
- maxExcerptsPerQuestion: z55.literal(hostedFactsLimits.maxExcerptsPerQuestion),
4984
- maxFactsBytes: z55.literal(hostedFactsLimits.maxFactsBytes),
4985
- maxQuestions: z55.literal(hostedFactsLimits.maxQuestions)
5831
+ limits: z61.strictObject({
5832
+ maxEvidenceItems: z61.number().int().positive(),
5833
+ maxPassages: z61.number().int().positive(),
5834
+ facts: z61.strictObject({
5835
+ maxExcerptCharacters: z61.literal(hostedFactsLimits.maxExcerptCharacters),
5836
+ maxExcerptsPerQuestion: z61.literal(hostedFactsLimits.maxExcerptsPerQuestion),
5837
+ maxFactsBytes: z61.literal(hostedFactsLimits.maxFactsBytes),
5838
+ maxQuestions: z61.literal(hostedFactsLimits.maxQuestions)
4986
5839
  })
4987
5840
  })
4988
5841
  });
4989
- var interpretedExcerpt = z55.strictObject({
4990
- id: id9,
4991
- method: z55.enum(["value", "exact_read", "classified"]),
4992
- status: z55.enum(["accepted", "needs_evidence", "not_needed"]),
4993
- value: z55.union([z55.string(), z55.number(), z55.boolean()]).optional(),
4994
- reasons: z55.array(z55.string()),
4995
- classification: z55.strictObject({
4996
- candidate: z55.string().nullable(),
4997
- probability: z55.number().min(0).max(1).nullable(),
4998
- abstention: z55.number().min(0).max(1).nullable(),
4999
- threshold: z55.number().min(0).max(1),
5000
- alternatives: z55.array(z55.strictObject({ value: z55.string(), probability: z55.number() }))
5842
+ var interpretedExcerpt = z61.strictObject({
5843
+ id: id11,
5844
+ method: z61.enum(["value", "exact_read", "classified"]),
5845
+ status: z61.enum(["accepted", "needs_evidence", "not_needed"]),
5846
+ value: z61.union([z61.string(), z61.number(), z61.boolean()]).optional(),
5847
+ reasons: z61.array(z61.string()),
5848
+ classification: z61.strictObject({
5849
+ candidate: z61.string().nullable(),
5850
+ probability: z61.number().min(0).max(1).nullable(),
5851
+ abstention: z61.number().min(0).max(1).nullable(),
5852
+ threshold: z61.number().min(0).max(1),
5853
+ alternatives: z61.array(z61.strictObject({ value: z61.string(), probability: z61.number() }))
5001
5854
  }).optional()
5002
5855
  });
5003
- var ruleSummary = z55.strictObject({ id: id9, outcome: id9, text: quotedText });
5004
- var HostedJobExplanationSchema = z55.strictObject({
5005
- schema: z55.literal("felspar.hosted-job-explanation.draft/v0"),
5006
- decision: z55.strictObject({ status: z55.string().nullable(), reasons: z55.array(z55.string()) }),
5007
- needs: z55.array(z55.strictObject({
5008
- key: id9,
5009
- status: z55.string(),
5010
- reasons: z55.array(z55.string()),
5011
- acceptedSourceClasses: z55.array(z55.string()),
5012
- maxAgeMs: z55.number().int().nonnegative(),
5856
+ var ruleSummary = z61.strictObject({ id: id11, outcome: id11, text: quotedText });
5857
+ var HostedJobExplanationSchema = z61.strictObject({
5858
+ schema: z61.literal("felspar.hosted-job-explanation.draft/v0"),
5859
+ decision: z61.strictObject({ status: z61.string().nullable(), reasons: z61.array(z61.string()) }),
5860
+ needs: z61.array(z61.strictObject({
5861
+ key: id11,
5862
+ status: z61.string(),
5863
+ reasons: z61.array(z61.string()),
5864
+ acceptedSourceClasses: z61.array(z61.string()),
5865
+ maxAgeMs: z61.number().int().nonnegative(),
5013
5866
  requiredWhen: HostedJobDescriptionSchema.shape.questions.element.shape.requiredWhen,
5014
- excerpts: z55.array(interpretedExcerpt).optional()
5867
+ excerpts: z61.array(interpretedExcerpt).optional()
5015
5868
  })),
5016
- why: z55.strictObject({
5017
- rules: z55.array(ruleSummary),
5018
- overrides: z55.array(z55.strictObject({ by: id9, target: id9 })),
5019
- suppressedRuleIds: z55.array(id9),
5020
- evidence: z55.array(z55.record(z55.string(), z55.unknown()))
5869
+ why: z61.strictObject({
5870
+ rules: z61.array(ruleSummary),
5871
+ overrides: z61.array(z61.strictObject({ by: id11, target: id11 })),
5872
+ suppressedRuleIds: z61.array(id11),
5873
+ evidence: z61.array(z61.record(z61.string(), z61.unknown()))
5021
5874
  }).nullable(),
5022
- context: z55.strictObject({ status: z55.string(), reason: z55.string().nullable() }).nullable(),
5023
- reviewNeeds: z55.array(z55.string()),
5024
- evidenceFreshUntil: z55.iso.datetime().nullable()
5875
+ context: z61.strictObject({ status: z61.string(), reason: z61.string().nullable() }).nullable(),
5876
+ reviewNeeds: z61.array(z61.string()),
5877
+ evidenceFreshUntil: z61.iso.datetime().nullable()
5025
5878
  });
5026
- var HostedReceiptVerificationInputSchema = z55.strictObject({
5879
+ var HostedReceiptVerificationInputSchema = z61.strictObject({
5027
5880
  receipt: DraftJobReceiptSchema,
5028
- expectedReceiptDigest: digest24,
5881
+ expectedReceiptDigest: digest26,
5029
5882
  deliveredCapsule: DraftContextVerificationOptionsSchema.shape.deliveredCapsule
5030
5883
  });
5031
- var HostedReceiptVerificationSchema = z55.strictObject({
5032
- authority: z55.literal("unapproved"),
5033
- status: z55.enum(["reproduced", "mismatch"]),
5034
- mismatches: z55.array(z55.string()),
5035
- decided: z55.strictObject({
5036
- jobId: id9,
5037
- entityId: id9,
5038
- releaseId: id9,
5039
- outcome: id9.nullable(),
5040
- case: z55.strictObject({ id: id9, mode: z55.enum(identityModes) }).optional(),
5041
- subject: z55.strictObject({
5042
- type: id9,
5043
- related: z55.array(z55.strictObject({ relationship: id9, subject: id9, id: id9, questions: z55.array(id9).max(64) })).max(256)
5884
+ var HostedReceiptVerificationSchema = z61.strictObject({
5885
+ authority: z61.literal("unapproved"),
5886
+ status: z61.enum(["reproduced", "mismatch"]),
5887
+ mismatches: z61.array(z61.string()),
5888
+ decided: z61.strictObject({
5889
+ jobId: id11,
5890
+ entityId: id11,
5891
+ releaseId: id11,
5892
+ outcome: id11.nullable(),
5893
+ environment: PackEnvironmentSchema.optional(),
5894
+ case: z61.strictObject({ id: id11, mode: z61.enum(identityModes) }).optional(),
5895
+ subject: z61.strictObject({
5896
+ type: id11,
5897
+ related: z61.array(z61.strictObject({ relationship: id11, subject: id11, id: id11, questions: z61.array(id11).max(64) })).max(256)
5044
5898
  }).optional(),
5045
- escalation: HostedEscalationSchema.omit({ why: true }).optional()
5899
+ escalation: HostedEscalationSchema.omit({ why: true }).optional(),
5900
+ manualFacts: z61.array(z61.strictObject({
5901
+ question: id11,
5902
+ excerpt: z61.number().int().min(0).max(hostedCaseRecordLimits.maxExcerptsPerQuestion - 1),
5903
+ via: z61.strictObject({
5904
+ principal: id11,
5905
+ agent: z61.strictObject({ name: z61.string(), accountable: id11 }).nullable()
5906
+ }),
5907
+ observedAt: z61.string(),
5908
+ stampedByFelspar: z61.boolean(),
5909
+ suppliedBy: z61.strictObject({ text: z61.string(), verified: z61.literal(false) }).optional()
5910
+ })).max(192).optional(),
5911
+ caseRecord: z61.strictObject({
5912
+ rule: z61.literal("whole-case"),
5913
+ attempt: z61.number().int().min(1),
5914
+ attempts: z61.array(HostedCaseAttemptSchema).max(hostedCaseRecordLimits.maxAttempts + 1)
5915
+ }).optional()
5046
5916
  }).optional()
5047
5917
  });
5048
5918
 
5049
5919
  // ../schemas/src/draft-hosted-output-check-record.ts
5050
- import { z as z58 } from "zod";
5920
+ import { z as z64 } from "zod";
5051
5921
 
5052
5922
  // ../schemas/src/draft-artifact-lint.ts
5053
- import { z as z57 } from "zod";
5923
+ import { z as z63 } from "zod";
5054
5924
 
5055
5925
  // ../schemas/src/draft-job-obligations.ts
5056
- import { z as z56 } from "zod";
5057
- var id10 = DraftApplicationScopeSchema.shape.authorityId;
5058
- var digest25 = DraftJobReceiptSchema.shape.receiptDigest;
5926
+ import { z as z62 } from "zod";
5927
+ var id12 = DraftApplicationScopeSchema.shape.authorityId;
5928
+ var digest27 = DraftJobReceiptSchema.shape.receiptDigest;
5059
5929
  var outcome2 = DraftJobObligationsOutcomeSchema;
5060
5930
  var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.extend({
5061
- schema: z56.literal("felspar.application-job-material.draft/v3"),
5931
+ schema: z62.literal("felspar.application-job-material.draft/v3"),
5062
5932
  obligations: DraftJobObligationsSchema
5063
- }).superRefine((value, context3) => {
5933
+ }).superRefine((value2, context3) => {
5064
5934
  if (context3.issues.length > 0) {
5065
5935
  return;
5066
5936
  }
5067
- const { obligations, discovery } = value;
5068
- const { proposal } = value.input.invocation.authority.catalog;
5937
+ const { obligations, discovery } = value2;
5938
+ const { proposal } = value2.input.invocation.authority.catalog;
5069
5939
  const isSourceMatches = Object.entries(proposal.source).every(([key3, expected2]) => Reflect.get(obligations.source, key3) === expected2);
5070
- const outcomes = new Set(obligations.outcomes.map((entry2) => entry2.outcomeId));
5071
- const isComplete = outcomes.size === proposal.allowedOutcomes.length && proposal.allowedOutcomes.every((entry2) => outcomes.has(entry2));
5940
+ const outcomes = new Set(obligations.outcomes.map((entry3) => entry3.outcomeId));
5941
+ const isComplete = outcomes.size === proposal.allowedOutcomes.length && proposal.allowedOutcomes.every((entry3) => outcomes.has(entry3));
5072
5942
  const matches = [
5073
5943
  isSourceMatches,
5074
5944
  isComplete,
@@ -5086,57 +5956,57 @@ var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.ex
5086
5956
  }
5087
5957
  });
5088
5958
  var HostedProposalInputV3Schema = HostedProposalInputV2Schema.extend({
5089
- schema: z56.literal("felspar.hosted-proposal.draft/v3"),
5959
+ schema: z62.literal("felspar.hosted-proposal.draft/v3"),
5090
5960
  material: DraftApplicationJobMaterialV3Schema
5091
5961
  });
5092
5962
  var jobObligationsReplayRoutes = ["supplied", "evaluated"];
5093
5963
  var replayRoutes = new Set(jobObligationsReplayRoutes);
5094
5964
  var DraftJobObligationsExecutionSchema = DraftAnyJobExecutionSchema.refine((execution) => replayRoutes.has(execution.invocation.route), "Obligations assessments support supplied and evaluated native executions");
5095
- var DraftJobObligationsNativeResultSchema = z56.strictObject({
5096
- authority: z56.literal("unapproved"),
5097
- discovery: z56.record(z56.string(), z56.unknown()),
5098
- executed: z56.record(z56.string(), z56.unknown()),
5965
+ var DraftJobObligationsNativeResultSchema = z62.strictObject({
5966
+ authority: z62.literal("unapproved"),
5967
+ discovery: z62.record(z62.string(), z62.unknown()),
5968
+ executed: z62.record(z62.string(), z62.unknown()),
5099
5969
  receipt: DraftJobReceiptSchema
5100
5970
  });
5101
- var DraftJobObligationsInputSchema = z56.strictObject({
5971
+ var DraftJobObligationsInputSchema = z62.strictObject({
5102
5972
  release: DraftApplicationReleaseSchema,
5103
- material: z56.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
5973
+ material: z62.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
5104
5974
  execution: DraftJobObligationsExecutionSchema,
5105
- expectedReceiptDigest: digest25,
5975
+ expectedReceiptDigest: digest27,
5106
5976
  job: DraftJobObligationsNativeResultSchema,
5107
5977
  explanation: HostedJobExplanationSchema,
5108
- invocation: DraftJobObligationsScopeSchema.extend({ caseId: id10 })
5978
+ invocation: DraftJobObligationsScopeSchema.extend({ caseId: id12 })
5109
5979
  });
5110
- var requirements2 = z56.strictObject({
5111
- status: z56.enum(["established", "unresolved"]),
5980
+ var requirements2 = z62.strictObject({
5981
+ status: z62.enum(["established", "unresolved"]),
5112
5982
  scope: DraftJobObligationsScopeSchema,
5113
5983
  artifacts: outcome2.shape.artifacts,
5114
5984
  approvals: outcome2.shape.approvals,
5115
- unresolved: z56.array(z56.strictObject({ scopeRef: id10, reasonCodes: z56.array(id10).min(1).max(64) })).max(64)
5985
+ unresolved: z62.array(z62.strictObject({ scopeRef: id12, reasonCodes: z62.array(id12).min(1).max(64) })).max(64)
5116
5986
  });
5117
- var nextReference = z56.discriminatedUnion("kind", [
5118
- z56.strictObject({ kind: z56.literal("evidence_need"), id: id10 }),
5119
- z56.strictObject({ kind: z56.literal("artifact_requirement"), id: id10 }),
5120
- z56.strictObject({ kind: z56.literal("approval_requirement"), id: id10 }),
5121
- z56.strictObject({ kind: z56.literal("unresolved_scope"), scopeRef: id10 })
5987
+ var nextReference = z62.discriminatedUnion("kind", [
5988
+ z62.strictObject({ kind: z62.literal("evidence_need"), id: id12 }),
5989
+ z62.strictObject({ kind: z62.literal("artifact_requirement"), id: id12 }),
5990
+ z62.strictObject({ kind: z62.literal("approval_requirement"), id: id12 }),
5991
+ z62.strictObject({ kind: z62.literal("unresolved_scope"), scopeRef: id12 })
5122
5992
  ]);
5123
- var DraftJobObligationsAssessmentBodySchema = z56.strictObject({
5124
- schema: z56.literal("felspar.job-obligations-assessment.draft/v0"),
5125
- binding: z56.strictObject({
5126
- releaseDigest: digest25,
5127
- materialDigest: digest25,
5128
- nativeReceiptDigest: digest25,
5129
- jobId: id10,
5993
+ var DraftJobObligationsAssessmentBodySchema = z62.strictObject({
5994
+ schema: z62.literal("felspar.job-obligations-assessment.draft/v0"),
5995
+ binding: z62.strictObject({
5996
+ releaseDigest: digest27,
5997
+ materialDigest: digest27,
5998
+ nativeReceiptDigest: digest27,
5999
+ jobId: id12,
5130
6000
  applicationScope: DraftApplicationScopeSchema,
5131
- caseId: id10,
5132
- entityId: id10,
5133
- evaluationTime: z56.iso.datetime({ offset: true }),
5134
- purposeRef: id10,
5135
- useRef: id10.nullable()
6001
+ caseId: id12,
6002
+ entityId: id12,
6003
+ evaluationTime: z62.iso.datetime({ offset: true }),
6004
+ purposeRef: id12,
6005
+ useRef: id12.nullable()
5136
6006
  }),
5137
6007
  requirements: requirements2,
5138
- next: z56.strictObject({
5139
- kind: z56.enum([
6008
+ next: z62.strictObject({
6009
+ kind: z62.enum([
5140
6010
  "stop",
5141
6011
  "review_required",
5142
6012
  "gather_evidence",
@@ -5144,20 +6014,20 @@ var DraftJobObligationsAssessmentBodySchema = z56.strictObject({
5144
6014
  "verify_before_action",
5145
6015
  "return_result"
5146
6016
  ]),
5147
- reasonCodes: z56.array(id10).max(64),
5148
- refs: z56.array(nextReference).max(64)
6017
+ reasonCodes: z62.array(id12).max(64),
6018
+ refs: z62.array(nextReference).max(64)
5149
6019
  })
5150
6020
  });
5151
6021
  function isNextRefDeclared(ref, required) {
5152
6022
  switch (ref.kind) {
5153
6023
  case "artifact_requirement": {
5154
- return required.artifacts.some((entry2) => entry2.id === ref.id);
6024
+ return required.artifacts.some((entry3) => entry3.id === ref.id);
5155
6025
  }
5156
6026
  case "approval_requirement": {
5157
- return required.approvals.some((entry2) => entry2.id === ref.id);
6027
+ return required.approvals.some((entry3) => entry3.id === ref.id);
5158
6028
  }
5159
6029
  case "unresolved_scope": {
5160
- return required.unresolved.some((entry2) => entry2.scopeRef === ref.scopeRef);
6030
+ return required.unresolved.some((entry3) => entry3.scopeRef === ref.scopeRef);
5161
6031
  }
5162
6032
  case "evidence_need": {
5163
6033
  return true;
@@ -5168,13 +6038,13 @@ function isNextRefDeclared(ref, required) {
5168
6038
  }
5169
6039
  }
5170
6040
  var DraftJobObligationsAssessmentSchema = DraftJobObligationsAssessmentBodySchema.extend({
5171
- assessmentDigest: digest25
5172
- }).superRefine((value, context3) => {
5173
- const { requirements: required } = value;
6041
+ assessmentDigest: digest27
6042
+ }).superRefine((value2, context3) => {
6043
+ const { requirements: required } = value2;
5174
6044
  if (required.status === "established" !== (required.unresolved.length === 0) || required.status === "unresolved" && (required.artifacts.length > 0 || required.approvals.length > 0)) {
5175
6045
  context3.addIssue({ code: "custom", message: "Requirements completeness differs" });
5176
6046
  }
5177
- for (const ref of value.next.refs) {
6047
+ for (const ref of value2.next.refs) {
5178
6048
  if (!isNextRefDeclared(ref, required)) {
5179
6049
  context3.addIssue({ code: "custom", message: "Dangling next reference" });
5180
6050
  }
@@ -5182,48 +6052,48 @@ var DraftJobObligationsAssessmentSchema = DraftJobObligationsAssessmentBodySchem
5182
6052
  });
5183
6053
 
5184
6054
  // ../schemas/src/draft-artifact-lint.ts
5185
- var id11 = DraftApplicationScopeSchema.shape.authorityId;
5186
- var digest26 = DraftJobReceiptSchema.shape.receiptDigest;
6055
+ var id13 = DraftApplicationScopeSchema.shape.authorityId;
6056
+ var digest28 = DraftJobReceiptSchema.shape.receiptDigest;
5187
6057
  var passage3 = ArtifactSpecificationSchema;
5188
- var plainArtifact = z57.strictObject({
5189
- id: id11,
5190
- revision: id11,
5191
- mediaType: z57.literal("text/plain"),
5192
- exportProfile: id11.nullable(),
5193
- content: z57.string().max(artifactLintLimits.maxTotalBytes),
5194
- expectedContentDigest: digest26
5195
- });
5196
- var structuredArtifact = z57.strictObject({
5197
- id: id11,
5198
- revision: id11,
5199
- mediaType: z57.literal("application/vnd.felspar.structured-output+json"),
5200
- exportProfile: id11.nullable(),
6058
+ var plainArtifact = z63.strictObject({
6059
+ id: id13,
6060
+ revision: id13,
6061
+ mediaType: z63.literal("text/plain"),
6062
+ exportProfile: id13.nullable(),
6063
+ content: z63.string().max(artifactLintLimits.maxTotalBytes),
6064
+ expectedContentDigest: digest28
6065
+ });
6066
+ var structuredArtifact = z63.strictObject({
6067
+ id: id13,
6068
+ revision: id13,
6069
+ mediaType: z63.literal("application/vnd.felspar.structured-output+json"),
6070
+ exportProfile: id13.nullable(),
5201
6071
  content: DraftStructuredOutputSchema,
5202
- expectedContentDigest: digest26
6072
+ expectedContentDigest: digest28
5203
6073
  });
5204
- var ArtifactLintArtifactSchema = z57.discriminatedUnion("mediaType", [
6074
+ var ArtifactLintArtifactSchema = z63.discriminatedUnion("mediaType", [
5205
6075
  plainArtifact,
5206
6076
  structuredArtifact
5207
6077
  ]);
5208
- var ArtifactLintDecisionSchema = z57.strictObject({
6078
+ var ArtifactLintDecisionSchema = z63.strictObject({
5209
6079
  inputs: DraftJobObligationsInputSchema,
5210
6080
  assessment: DraftJobObligationsAssessmentSchema,
5211
- expectedAssessmentDigest: digest26
6081
+ expectedAssessmentDigest: digest28
5212
6082
  });
5213
- var ArtifactLintInputSchema = z57.strictObject({
5214
- schema: z57.literal("felspar.lint.draft/v1"),
5215
- requestId: id11,
6083
+ var ArtifactLintInputSchema = z63.strictObject({
6084
+ schema: z63.literal("felspar.lint.draft/v1"),
6085
+ requestId: id13,
5216
6086
  release: DraftApplicationReleaseSchema,
5217
6087
  material: DraftApplicationJobMaterialV3Schema,
5218
6088
  manifest: ArtifactCheckManifestSchema,
5219
- expectedManifestDigest: digest26,
5220
- attachedObligations: z57.strictObject({ expectedObligationsDigest: digest26 }).optional(),
5221
- attachedCase: z57.strictObject({
5222
- decisionReceiptDigest: digest26,
5223
- answers: z57.array(z57.strictObject({ key: id11, value: z57.union([z57.string().min(1).max(200), z57.null()]) })).max(256)
6089
+ expectedManifestDigest: digest28,
6090
+ attachedObligations: z63.strictObject({ expectedObligationsDigest: digest28 }).optional(),
6091
+ attachedCase: z63.strictObject({
6092
+ decisionReceiptDigest: digest28,
6093
+ answers: z63.array(z63.strictObject({ key: id13, value: z63.union([z63.string().min(1).max(200), z63.null()]) })).max(256)
5224
6094
  }).optional(),
5225
- case: z57.strictObject({ caseId: id11, purposeRef: id11, useRef: id11.nullable() }),
5226
- artifactRequirementId: id11.nullable(),
6095
+ case: z63.strictObject({ caseId: id13, purposeRef: id13, useRef: id13.nullable() }),
6096
+ artifactRequirementId: id13.nullable(),
5227
6097
  decision: ArtifactLintDecisionSchema.nullable(),
5228
6098
  artifact: ArtifactLintArtifactSchema
5229
6099
  });
@@ -5236,11 +6106,11 @@ var artifactCheckStatuses = [
5236
6106
  "not_applicable",
5237
6107
  "skipped"
5238
6108
  ];
5239
- var range = z57.strictObject({
5240
- sectionId: id11,
5241
- start: z57.number().int().min(0).max(artifactLintLimits.maxSectionUnits),
5242
- end: z57.number().int().min(1).max(artifactLintLimits.maxSectionUnits),
5243
- offsetUnit: z57.literal("utf16_code_units")
6109
+ var range = z63.strictObject({
6110
+ sectionId: id13,
6111
+ start: z63.number().int().min(0).max(artifactLintLimits.maxSectionUnits),
6112
+ end: z63.number().int().min(1).max(artifactLintLimits.maxSectionUnits),
6113
+ offsetUnit: z63.literal("utf16_code_units")
5244
6114
  });
5245
6115
  var findingCodes = [
5246
6116
  "section_missing",
@@ -5261,6 +6131,7 @@ var findingCodes = [
5261
6131
  "semantic_violation",
5262
6132
  "semantic_missing",
5263
6133
  "semantic_unresolved",
6134
+ "possible_prompt_injection",
5264
6135
  "case_answer_conflict",
5265
6136
  "case_answer_missing",
5266
6137
  "case_answer_unconfirmed",
@@ -5268,174 +6139,331 @@ var findingCodes = [
5268
6139
  "evaluation_budget_exceeded",
5269
6140
  "evaluation_skipped"
5270
6141
  ];
5271
- var ArtifactFindingSchema = z57.strictObject({
5272
- code: z57.enum(findingCodes),
5273
- checkId: id11.nullable(),
5274
- severity: z57.enum(["error", "warning"]),
6142
+ var ArtifactFindingSchema = z63.strictObject({
6143
+ code: z63.enum(findingCodes),
6144
+ checkId: id13.nullable(),
6145
+ severity: z63.enum(["error", "warning"]),
5275
6146
  specification: passage3.nullable(),
5276
6147
  location: range.nullable(),
5277
- insertionAnchor: z57.strictObject({ sectionId: id11.nullable(), at: z57.number().int().min(0) }).nullable(),
5278
- literalIndex: z57.number().int().min(0).max(artifactLintLimits.maxLiterals).nullable()
5279
- });
5280
- var ArtifactCheckObservationSchema = z57.strictObject({
5281
- checkId: id11,
5282
- kind: z57.enum(artifactCheckKinds),
5283
- required: z57.boolean(),
5284
- method: z57.enum(["deterministic", "semantic"]),
5285
- status: z57.enum(artifactCheckStatuses),
5286
- occurrences: z57.number().int().min(0),
5287
- parsedValue: z57.number().nullable(),
5288
- caseValue: z57.number().nullable()
5289
- });
5290
- var ArtifactLintRecordBodySchema = z57.strictObject({
5291
- schema: z57.literal("felspar.lint-record.draft/v1"),
5292
- requestId: id11,
5293
- status: z57.enum(["pass", "revise", "unavailable", "review_required"]),
5294
- caseContext: z57.enum(["bound", "not_required"]),
5295
- binding: z57.strictObject({
6148
+ insertionAnchor: z63.strictObject({ sectionId: id13.nullable(), at: z63.number().int().min(0) }).nullable(),
6149
+ literalIndex: z63.number().int().min(0).max(artifactLintLimits.maxLiterals).nullable()
6150
+ });
6151
+ var ArtifactCheckObservationSchema = z63.strictObject({
6152
+ checkId: id13,
6153
+ kind: z63.enum(artifactCheckKinds),
6154
+ required: z63.boolean(),
6155
+ method: z63.enum(["deterministic", "semantic"]),
6156
+ status: z63.enum(artifactCheckStatuses),
6157
+ occurrences: z63.number().int().min(0),
6158
+ parsedValue: z63.number().nullable(),
6159
+ caseValue: z63.number().nullable()
6160
+ });
6161
+ var ArtifactLintRecordBodySchema = z63.strictObject({
6162
+ schema: z63.literal("felspar.lint-record.draft/v1"),
6163
+ requestId: id13,
6164
+ status: z63.enum(["pass", "revise", "unavailable", "review_required"]),
6165
+ caseContext: z63.enum(["bound", "not_required"]),
6166
+ binding: z63.strictObject({
5296
6167
  scope: DraftApplicationScopeSchema,
5297
- releaseId: id11,
5298
- releaseDigest: digest26,
5299
- materialDigest: digest26,
5300
- obligationsDigest: digest26.optional(),
5301
- caseFactsDigest: digest26.optional(),
5302
- jobId: id11,
5303
- manifestId: id11,
5304
- manifestDigest: digest26,
5305
- contract: z57.strictObject({ id: id11, digest: digest26 }),
5306
- caseId: id11,
5307
- purposeRef: id11,
5308
- useRef: id11.nullable(),
5309
- artifactRequirementId: id11.nullable(),
5310
- decisionReceiptDigest: digest26.nullable(),
5311
- obligationsAssessmentDigest: digest26.nullable()
6168
+ releaseId: id13,
6169
+ releaseDigest: digest28,
6170
+ materialDigest: digest28,
6171
+ obligationsDigest: digest28.optional(),
6172
+ caseFactsDigest: digest28.optional(),
6173
+ jobId: id13,
6174
+ manifestId: id13,
6175
+ manifestDigest: digest28,
6176
+ contract: z63.strictObject({ id: id13, digest: digest28 }),
6177
+ caseId: id13,
6178
+ purposeRef: id13,
6179
+ useRef: id13.nullable(),
6180
+ artifactRequirementId: id13.nullable(),
6181
+ decisionReceiptDigest: digest28.nullable(),
6182
+ obligationsAssessmentDigest: digest28.nullable()
5312
6183
  }),
5313
- artifact: z57.strictObject({
5314
- id: id11,
5315
- revision: id11,
5316
- mediaType: z57.enum(artifactLintMediaTypes),
5317
- exportProfile: id11.nullable(),
5318
- contentDigest: digest26,
5319
- sections: z57.array(z57.strictObject({
5320
- id: id11,
5321
- units: z57.number().int().min(0),
5322
- contentDigest: digest26.nullable()
6184
+ artifact: z63.strictObject({
6185
+ id: id13,
6186
+ revision: id13,
6187
+ mediaType: z63.enum(artifactLintMediaTypes),
6188
+ exportProfile: id13.nullable(),
6189
+ contentDigest: digest28,
6190
+ sections: z63.array(z63.strictObject({
6191
+ id: id13,
6192
+ units: z63.number().int().min(0),
6193
+ contentDigest: digest28.nullable()
5323
6194
  })).max(artifactLintLimits.maxSections)
5324
6195
  }),
5325
- checks: z57.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
5326
- findings: z57.array(ArtifactFindingSchema).max(2048),
6196
+ checks: z63.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
6197
+ findings: z63.array(ArtifactFindingSchema).max(2048),
5327
6198
  semantic: ArtifactSemanticRecordSchema.nullable(),
5328
- coverage: z57.strictObject({
5329
- scope: z57.literal("declared_checks_only"),
5330
- declared: z57.number().int().min(0),
5331
- applicable: z57.number().int().min(0),
5332
- completed: z57.number().int().min(0),
5333
- required: z57.number().int().min(0),
5334
- requiredCompleted: z57.number().int().min(0),
5335
- textAssigned: z57.enum(["complete", "incomplete"]),
5336
- semantic: z57.enum(["not_declared", "complete", "incomplete"]),
5337
- nativeDocumentLayout: z57.literal("not_checked")
6199
+ coverage: z63.strictObject({
6200
+ scope: z63.literal("declared_checks_only"),
6201
+ declared: z63.number().int().min(0),
6202
+ applicable: z63.number().int().min(0),
6203
+ completed: z63.number().int().min(0),
6204
+ required: z63.number().int().min(0),
6205
+ requiredCompleted: z63.number().int().min(0),
6206
+ textAssigned: z63.enum(["complete", "incomplete"]),
6207
+ semantic: z63.enum(["not_declared", "complete", "incomplete"]),
6208
+ nativeDocumentLayout: z63.literal("not_checked")
5338
6209
  }),
5339
- actionAuthorized: z57.literal(false)
6210
+ actionAuthorized: z63.literal(false)
5340
6211
  });
5341
6212
  var ArtifactLintRecordSchema = ArtifactLintRecordBodySchema.extend({
5342
- recordDigest: digest26
5343
- });
5344
- var ArtifactLintReceiptSchema = z57.strictObject({
5345
- schema: z57.literal("felspar.lint-receipt.draft/v1"),
5346
- recordDigest: digest26,
5347
- releaseDigest: digest26,
5348
- manifestDigest: digest26,
5349
- contractDigest: digest26,
5350
- caseId: id11,
5351
- caseContext: z57.enum(["bound", "not_required"]),
5352
- decisionReceiptDigest: digest26.nullable(),
5353
- obligationsAssessmentDigest: digest26.nullable(),
5354
- artifactId: id11,
5355
- artifactRevision: id11,
5356
- artifactDigest: digest26,
5357
- actionAuthorized: z57.literal(false),
5358
- receiptDigest: digest26
6213
+ recordDigest: digest28
6214
+ });
6215
+ var ArtifactLintReceiptSchema = z63.strictObject({
6216
+ schema: z63.literal("felspar.lint-receipt.draft/v1"),
6217
+ recordDigest: digest28,
6218
+ releaseDigest: digest28,
6219
+ manifestDigest: digest28,
6220
+ contractDigest: digest28,
6221
+ caseId: id13,
6222
+ caseContext: z63.enum(["bound", "not_required"]),
6223
+ decisionReceiptDigest: digest28.nullable(),
6224
+ obligationsAssessmentDigest: digest28.nullable(),
6225
+ artifactId: id13,
6226
+ artifactRevision: id13,
6227
+ artifactDigest: digest28,
6228
+ actionAuthorized: z63.literal(false),
6229
+ receiptDigest: digest28
5359
6230
  });
5360
6231
 
5361
6232
  // ../schemas/src/draft-hosted-output-check-record.ts
5362
- var id12 = DraftApplicationScopeSchema.shape.authorityId;
5363
- var digest27 = DraftJobReceiptSchema.shape.receiptDigest;
5364
- var HostedOutputCheckInputSchema = z58.strictObject({
5365
- executionId: id12,
5366
- output: id12.optional(),
5367
- text: z58.string().min(1).max(artifactLintLimits.maxTotalBytes).refine(isWellFormedText, "text_not_well_formed"),
5368
- revision: id12.optional()
5369
- });
5370
- var HostedOutputCheckRecordSchema = z58.strictObject({
5371
- schema: z58.literal("felspar.hosted-output-check/v0"),
5372
- checkId: id12,
5373
- jobId: id12,
5374
- output: id12,
5375
- decision: z58.strictObject({ executionId: id12, outcome: id12, receiptDigest: digest27 }),
5376
- release: z58.strictObject({ releaseId: id12, releaseDigest: digest27 }),
6233
+ var id14 = DraftApplicationScopeSchema.shape.authorityId;
6234
+ var digest29 = DraftJobReceiptSchema.shape.receiptDigest;
6235
+ var HostedOutputCheckInputSchema = z64.strictObject({
6236
+ executionId: id14,
6237
+ output: id14.optional(),
6238
+ text: z64.string().min(1).max(artifactLintLimits.maxTotalBytes).refine(isWellFormedText, "text_not_well_formed"),
6239
+ revision: id14.optional()
6240
+ });
6241
+ var HostedOutputCheckRecordSchema = z64.strictObject({
6242
+ schema: z64.literal("felspar.hosted-output-check/v0"),
6243
+ checkId: id14,
6244
+ jobId: id14,
6245
+ output: id14,
6246
+ decision: z64.strictObject({ executionId: id14, outcome: id14, receiptDigest: digest29 }),
6247
+ release: z64.strictObject({ releaseId: id14, releaseDigest: digest29 }),
5377
6248
  record: ArtifactLintRecordSchema,
5378
6249
  receipt: ArtifactLintReceiptSchema.nullable(),
5379
- evaluation: z58.strictObject({
5380
- modelCalls: z58.number().int().min(0),
5381
- reason: z58.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable()
6250
+ evaluation: z64.strictObject({
6251
+ modelCalls: z64.number().int().min(0),
6252
+ reason: z64.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable()
5382
6253
  })
5383
6254
  });
5384
6255
 
5385
6256
  // src/draft-hosted-client.ts
5386
- import { z as z59 } from "zod";
5387
- var digestText = z59.string().regex(/^sha256:[a-f0-9]{64}$/u);
5388
- var HostedOutputCheckReplySchema = z59.object({
5389
- status: z59.enum(["pass", "revise", "review_required", "unavailable"]),
5390
- checkId: z59.string(),
5391
- output: z59.string(),
5392
- findings: z59.array(z59.record(z59.string(), z59.unknown())),
5393
- receipt: z59.object({ receiptDigest: digestText, artifactDigest: digestText }).loose().nullable(),
5394
- decision: z59.object({ executionId: z59.string(), receiptDigest: digestText }),
5395
- actionAuthorized: z59.literal(false)
6257
+ import { z as z67 } from "zod";
6258
+
6259
+ // ../schemas/src/draft-agent-responses.ts
6260
+ import { z as z65 } from "zod";
6261
+ var digestText = z65.string().regex(/^sha256:[a-f0-9]{64}$/u);
6262
+ var HostedOutputCheckReplySchema = z65.object({
6263
+ status: z65.enum(["pass", "revise", "review_required", "unavailable"]),
6264
+ checkId: z65.string(),
6265
+ output: z65.string(),
6266
+ findings: z65.array(z65.record(z65.string(), z65.unknown())),
6267
+ receipt: z65.object({ receiptDigest: digestText, artifactDigest: digestText }).loose().nullable(),
6268
+ decision: z65.object({ executionId: z65.string(), receiptDigest: digestText }),
6269
+ actionAuthorized: z65.literal(false)
5396
6270
  }).loose();
5397
- var quotedWords = z59.object({ text: z59.string() }).loose();
5398
- var FelsparCaseSchema = z59.object({ id: z59.string().min(1).max(200), mode: z59.enum(identityModes) });
5399
- var FelsparRelatedSchema = z59.object({
5400
- relationship: z59.string(),
5401
- subject: z59.string(),
5402
- id: z59.string(),
5403
- questions: z59.array(z59.string())
5404
- });
5405
- var FelsparResultSubjectSchema = z59.object({
5406
- type: z59.string(),
5407
- id: z59.string(),
5408
- related: z59.array(FelsparRelatedSchema)
5409
- });
5410
- var FelsparEscalationSchema = z59.object({
5411
- id: z59.string().min(1).max(200),
5412
- trigger: z59.enum(escalationTriggers),
6271
+ var quotedWords = z65.object({ text: z65.string() }).loose();
6272
+ var FelsparCaseSchema = z65.object({
6273
+ id: z65.string().min(1).max(200),
6274
+ mode: z65.enum(identityModes)
6275
+ });
6276
+ var FelsparRelatedSchema = z65.object({
6277
+ relationship: z65.string(),
6278
+ subject: z65.string(),
6279
+ id: z65.string(),
6280
+ questions: z65.array(z65.string())
6281
+ });
6282
+ var FelsparResultSubjectSchema = z65.object({
6283
+ type: z65.string(),
6284
+ id: z65.string(),
6285
+ related: z65.array(FelsparRelatedSchema)
6286
+ });
6287
+ var FelsparEscalationSchema = z65.object({
6288
+ id: z65.string().min(1).max(200),
6289
+ trigger: z65.enum(escalationTriggers),
5413
6290
  why: quotedWords
5414
6291
  });
5415
- var FelsparJobResultSchema = HostedJobResultSchema.extend({
6292
+ var AgentExecutedResponseSchema = HostedJobResultSchema.extend({
5416
6293
  result: HostedJobResultSchema.shape.result.unwrap().extend({
5417
6294
  case: FelsparCaseSchema.optional(),
5418
6295
  subject: FelsparResultSubjectSchema.optional(),
5419
6296
  escalation: FelsparEscalationSchema.optional(),
5420
- missing: z59.array(z59.string()).optional()
6297
+ missing: z65.array(z65.string()).optional()
5421
6298
  }).nullable()
5422
6299
  });
5423
- var FelsparJobListSchema = z59.object({
5424
- jobs: z59.array(z59.object({ id: z59.string().min(1).max(200) })).max(256)
6300
+ var AgentMissingRelatedResponseSchema = z65.object({
6301
+ status: z65.literal("gap"),
6302
+ reason: z65.literal("related_subject_missing"),
6303
+ result: AgentExecutedResponseSchema.shape.result.unwrap().pick({
6304
+ executionId: true,
6305
+ releaseId: true,
6306
+ releaseDigest: true,
6307
+ case: true,
6308
+ subject: true,
6309
+ escalation: true
6310
+ }).extend({
6311
+ outcome: z65.null(),
6312
+ receipt: z65.null(),
6313
+ missing: z65.array(z65.string()),
6314
+ explanation: z65.object({
6315
+ needs: z65.array(z65.object({
6316
+ key: z65.string(),
6317
+ status: z65.literal("missing"),
6318
+ reasons: z65.array(z65.string())
6319
+ }))
6320
+ })
6321
+ })
5425
6322
  });
6323
+ var FelsparJobResultSchema = z65.union([
6324
+ AgentExecutedResponseSchema,
6325
+ AgentMissingRelatedResponseSchema
6326
+ ]);
6327
+ var FelsparJobListSchema = z65.object({
6328
+ jobs: z65.array(z65.object({ id: z65.string().min(1).max(200) })).max(256)
6329
+ });
6330
+
6331
+ // ../schemas/src/draft-decision-graph.ts
6332
+ import { z as z66 } from "zod";
6333
+
6334
+ // ../schemas/src/draft-trace-budget.ts
6335
+ var traceGraphLimits = Object.freeze({ nodes: 2048, edges: 4096 });
6336
+
6337
+ // ../schemas/src/draft-decision-graph.ts
6338
+ var digest30 = DraftJobReceiptSchema.shape.receiptDigest;
6339
+ var identity = z66.string().min(1).max(200);
6340
+ var nodeId = z66.string().regex(/^n\d+$/u);
6341
+ var DecisionGraphStateSchema = z66.enum([
6342
+ "declared",
6343
+ "active",
6344
+ "inactive",
6345
+ "blocked",
6346
+ "suppressed"
6347
+ ]);
6348
+ var DecisionGraphTopologySchema = z66.strictObject({
6349
+ nodes: z66.array(z66.strictObject({
6350
+ id: nodeId,
6351
+ kind: z66.enum([
6352
+ "subject",
6353
+ "question",
6354
+ "rule",
6355
+ "selection",
6356
+ "outcome",
6357
+ "unresolved",
6358
+ "attempts",
6359
+ "retry",
6360
+ "escalation",
6361
+ "scoring",
6362
+ "score_criterion"
6363
+ ]),
6364
+ key: identity,
6365
+ lines: z66.array(z66.string().max(16384)).min(1).max(128),
6366
+ state: DecisionGraphStateSchema
6367
+ })).max(traceGraphLimits.nodes),
6368
+ edges: z66.array(z66.strictObject({
6369
+ from: nodeId,
6370
+ to: nodeId,
6371
+ kind: z66.enum([
6372
+ "asks",
6373
+ "depends_on",
6374
+ "considers",
6375
+ "selects",
6376
+ "overrides",
6377
+ "unresolved",
6378
+ "retry",
6379
+ "escalates",
6380
+ "scores"
6381
+ ]),
6382
+ state: DecisionGraphStateSchema
6383
+ })).max(traceGraphLimits.edges)
6384
+ }).superRefine((graph, context3) => {
6385
+ const ids3 = new Set(graph.nodes.map((node) => node.id));
6386
+ const edges = new Set(graph.edges.map(({ from, to, kind }) => JSON.stringify([from, to, kind])));
6387
+ if (ids3.size !== graph.nodes.length || edges.size !== graph.edges.length || graph.edges.some((edge) => !ids3.has(edge.from) || !ids3.has(edge.to))) {
6388
+ context3.addIssue({ code: "custom", message: "Duplicate or dangling graph identity" });
6389
+ }
6390
+ });
6391
+ var pins = {
6392
+ jobId: identity,
6393
+ releaseId: identity,
6394
+ releaseDigest: digest30,
6395
+ materialDigest: digest30
6396
+ };
6397
+ var DecisionGraphSchema = z66.discriminatedUnion("status", [
6398
+ z66.strictObject({
6399
+ schema: z66.literal("felspar.decision-graph/v1"),
6400
+ status: z66.literal("ready"),
6401
+ view: z66.enum(["release", "proposal", "run"]),
6402
+ ...pins,
6403
+ topologyDigest: digest30,
6404
+ graph: DecisionGraphTopologySchema,
6405
+ mermaid: z66.string().max(262144),
6406
+ proposalId: identity.optional(),
6407
+ executionObjectId: identity.optional(),
6408
+ receiptDigest: digest30.nullable(),
6409
+ evaluationTime: z66.iso.datetime().nullable(),
6410
+ attempt: DecisionGraphAttemptSchema.nullable(),
6411
+ dashboardUrl: z66.url().optional()
6412
+ }),
6413
+ z66.strictObject({
6414
+ schema: z66.literal("felspar.decision-graph/v1"),
6415
+ status: z66.literal("unavailable"),
6416
+ reason: z66.enum([
6417
+ "graph_limit_exceeded",
6418
+ "unsupported_material",
6419
+ "history_unavailable",
6420
+ "replay_mismatch"
6421
+ ]),
6422
+ dashboardUrl: z66.url().optional()
6423
+ })
6424
+ ]);
6425
+
6426
+ // src/draft-decision-graph-client.ts
6427
+ function decisionGraphCalls(call) {
6428
+ async function read(kind, id15) {
6429
+ const value2 = encodeURIComponent(HostedObjectSchema.shape.id.parse(id15));
6430
+ const graph = await call(`/v0/${kind}/${value2}/graph`, DecisionGraphSchema);
6431
+ if (graph.status !== "ready") {
6432
+ return graph;
6433
+ }
6434
+ const pins2 = {
6435
+ releases: graph.releaseId,
6436
+ proposals: graph.proposalId,
6437
+ executions: graph.executionObjectId
6438
+ };
6439
+ if (pins2[kind] !== id15) {
6440
+ throw new Error("Graph identity differs");
6441
+ }
6442
+ return graph;
6443
+ }
6444
+ return {
6445
+ getReleaseGraph: async (id15) => await read("releases", id15),
6446
+ getProposalGraph: async (id15) => await read("proposals", id15),
6447
+ getDecisionGraph: async (executionObjectId) => await read("executions", executionObjectId)
6448
+ };
6449
+ }
6450
+
6451
+ // src/draft-hosted-client.ts
6452
+ var FelsparJobResultSchema2 = FelsparJobResultSchema;
6453
+ var FelsparJobListSchema2 = FelsparJobListSchema;
5426
6454
  var hostedPartsContentType = "application/x.felspar-content-parts";
5427
- async function partsBody(value) {
5428
- const packed = await packContentParts(value);
6455
+ async function partsBody(value2) {
6456
+ const packed = await packContentParts(value2);
5429
6457
  return packed.text;
5430
6458
  }
5431
- async function factsRequest(value, describeRelease) {
5432
- if (typeof value.expectedReleaseDigest === "string") {
5433
- return HostedFactsRequestSchema.parse({ mode: "facts", ...value });
6459
+ async function factsRequest(value2, describeRelease) {
6460
+ if (typeof value2.expectedReleaseDigest === "string") {
6461
+ return HostedFactsRequestSchema.parse({ mode: "facts", ...value2 });
5434
6462
  }
5435
- const described = await describeRelease(HostedObjectSchema.shape.id.parse(value.jobId));
6463
+ const described = await describeRelease(HostedObjectSchema.shape.id.parse(value2.jobId));
5436
6464
  return HostedFactsRequestSchema.parse({
5437
6465
  mode: "facts",
5438
- ...value,
6466
+ ...value2,
5439
6467
  expectedReleaseDigest: described.release.releaseDigest
5440
6468
  });
5441
6469
  }
@@ -5473,31 +6501,31 @@ ${jobId}`;
5473
6501
  return result;
5474
6502
  };
5475
6503
  }
5476
- var refusalCode = z59.string().regex(/^[a-z][a-z_]{2,63}$/u);
5477
- var fieldPath = z59.array(z59.string().max(256)).max(32);
5478
- var refusalEscalationSchema = z59.object({
5479
- id: z59.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]{0,199}$/u),
5480
- trigger: z59.enum(escalationTriggers),
5481
- why: z59.object({ text: z59.string().max(2e4) })
6504
+ var refusalCode = z67.string().regex(/^[a-z][a-z_]{2,63}$/u);
6505
+ var fieldPath = z67.array(z67.string().max(256)).max(32);
6506
+ var refusalEscalationSchema = z67.object({
6507
+ id: z67.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]{0,199}$/u),
6508
+ trigger: z67.enum(escalationTriggers),
6509
+ why: z67.object({ text: z67.string().max(2e4) })
5482
6510
  });
5483
- var refusalSchema = z59.object({
6511
+ var refusalSchema = z67.object({
5484
6512
  error: refusalCode,
5485
6513
  path: fieldPath.optional(),
5486
- currentReleaseDigest: z59.string().regex(/^sha256:[a-f0-9]{64}$/u).optional(),
5487
- retryAfterSeconds: z59.number().int().min(1).max(3600).optional(),
5488
- escalation: z59.unknown().optional(),
5489
- issues: z59.array(z59.object({ code: refusalCode, path: fieldPath })).max(64).optional()
5490
- }).transform(({ escalation: named, ...value }) => {
5491
- const fix = hostedRefusalFix(value.error);
5492
- const recovery = hostedRefusalRecovery(value.error);
6514
+ currentReleaseDigest: z67.string().regex(/^sha256:[a-f0-9]{64}$/u).optional(),
6515
+ retryAfterSeconds: z67.number().int().min(1).max(3600).optional(),
6516
+ escalation: z67.unknown().optional(),
6517
+ issues: z67.array(z67.object({ code: refusalCode, path: fieldPath })).max(64).optional()
6518
+ }).transform(({ escalation: named, ...value2 }) => {
6519
+ const fix = hostedRefusalFix(value2.error);
6520
+ const recovery = hostedRefusalRecovery(value2.error);
5493
6521
  const escalation = refusalEscalationSchema.safeParse(named).data;
5494
6522
  return {
5495
- ...value,
6523
+ ...value2,
5496
6524
  ...escalation !== void 0 && { escalation },
5497
6525
  ...fix !== null && { fix },
5498
6526
  ...recovery !== null && { recovery },
5499
- ...value.issues && {
5500
- issues: value.issues.map((issue) => {
6527
+ ...value2.issues && {
6528
+ issues: value2.issues.map((issue) => {
5501
6529
  const issueFix = hostedRefusalFix(issue.code);
5502
6530
  return issueFix === null ? issue : { ...issue, fix: issueFix };
5503
6531
  })
@@ -5541,20 +6569,20 @@ function outputCheckCalls(call) {
5541
6569
  const objectId = HostedObjectSchema.shape.id;
5542
6570
  const checksOf = (job) => `/v0/jobs/${encodeURIComponent(objectId.parse(job))}/output-checks`;
5543
6571
  return {
5544
- checkOutput: async (job, value) => await call(checksOf(job), HostedOutputCheckReplySchema, HostedOutputCheckInputSchema.parse(value)),
6572
+ checkOutput: async (job, value2) => await call(checksOf(job), HostedOutputCheckReplySchema, HostedOutputCheckInputSchema.parse(value2)),
5545
6573
  readOutputCheck: async (job, checkId) => await call(`${checksOf(job)}/${encodeURIComponent(objectId.parse(checkId))}`, HostedOutputCheckReplySchema)
5546
6574
  };
5547
6575
  }
5548
6576
  function agentCalls(call) {
5549
6577
  const objectId = HostedObjectSchema.shape.id;
5550
6578
  return {
5551
- listJobs: async () => await call("/v0/jobs", FelsparJobListSchema),
6579
+ listJobs: async () => await call("/v0/jobs", FelsparJobListSchema2),
5552
6580
  describeCurrentJob: async (job) => await call(`/v0/jobs/${encodeURIComponent(objectId.parse(job))}/brief`, HostedJobDescriptionSchema),
5553
- resolveJob: async (id13, value) => {
5554
- const input = HostedSuppliedJobInputSchema.parse(value);
5555
- const releaseId = objectId.parse(id13);
6581
+ resolveJob: async (id15, value2) => {
6582
+ const input = HostedSuppliedJobInputSchema.parse(value2);
6583
+ const releaseId = objectId.parse(id15);
5556
6584
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5557
- return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);
6585
+ return pinnedResult(await call(path3, FelsparJobResultSchema2, input), releaseId, input);
5558
6586
  }
5559
6587
  };
5560
6588
  }
@@ -5573,14 +6601,14 @@ function createHostedFelsparClient(configuration) {
5573
6601
  }
5574
6602
  const authorization = authorizationOf(configuration);
5575
6603
  const fetcher = configuration.fetcher ?? fetch;
5576
- async function call(path3, schema, value) {
6604
+ async function call(path3, schema, value2) {
5577
6605
  const headers = new Headers(authorization === null ? {} : { Authorization: authorization });
5578
- const body = value === void 0 ? void 0 : await partsBody(value);
6606
+ const body = value2 === void 0 ? void 0 : await partsBody(value2);
5579
6607
  if (body !== void 0) {
5580
6608
  headers.set("Content-Type", hostedPartsContentType);
5581
6609
  }
5582
6610
  const response = await fetcher(`${origin.origin}${path3}`, {
5583
- method: value === void 0 ? "GET" : "POST",
6611
+ method: value2 === void 0 ? "GET" : "POST",
5584
6612
  headers,
5585
6613
  credentials: "include",
5586
6614
  redirect: "error",
@@ -5595,21 +6623,22 @@ function createHostedFelsparClient(configuration) {
5595
6623
  const objectId = HostedObjectSchema.shape.id;
5596
6624
  const describe = jobDescriber(async (releaseId, jobId) => await call(describePath(releaseId, jobId), HostedJobDescriptionSchema));
5597
6625
  return {
5598
- submitSource: async (value) => await call("/v0/sources", HostedObjectSchema, HostedSourceInputSchema.parse(value)),
5599
- submitProposal: async (value) => await call("/v0/proposals", HostedObjectSchema, HostedProposalInputSchema.parse(value)),
5600
- approveProposal: async (id13, value) => await call(`/v0/proposals/${encodeURIComponent(objectId.parse(id13))}/approve`, HostedObjectSchema, HostedApprovalInputSchema.parse(value)),
5601
- releasePack: async (id13, value) => await call(`/v0/approvals/${encodeURIComponent(objectId.parse(id13))}/release`, DraftApplicationReleaseSchema, HostedReleaseInputSchema.parse(value)),
5602
- loadRelease: async (id13) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id13))}`, HostedReleaseBundleSchema),
5603
- describeJob: async (id13, job) => await describe(objectId.parse(id13), objectId.parse(job)),
5604
- verifyReceipt: async (executionObjectId, value) => await call(`/v0/executions/${encodeURIComponent(objectId.parse(executionObjectId))}/verify`, HostedReceiptVerificationSchema, HostedReceiptVerificationInputSchema.parse(value)),
6626
+ ...decisionGraphCalls(call),
6627
+ submitSource: async (value2) => await call("/v0/sources", HostedObjectSchema, HostedSourceInputSchema.parse(value2)),
6628
+ submitProposal: async (value2) => await call("/v0/proposals", HostedObjectSchema, HostedProposalInputSchema.parse(value2)),
6629
+ approveProposal: async (id15, value2) => await call(`/v0/proposals/${encodeURIComponent(objectId.parse(id15))}/approve`, HostedObjectSchema, HostedApprovalInputSchema.parse(value2)),
6630
+ releasePack: async (id15, value2) => await call(`/v0/approvals/${encodeURIComponent(objectId.parse(id15))}/release`, DraftApplicationReleaseSchema, HostedReleaseInputSchema.parse(value2)),
6631
+ loadRelease: async (id15) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id15))}`, HostedReleaseBundleSchema),
6632
+ describeJob: async (id15, job) => await describe(objectId.parse(id15), objectId.parse(job)),
6633
+ verifyReceipt: async (executionObjectId, value2) => await call(`/v0/executions/${encodeURIComponent(objectId.parse(executionObjectId))}/verify`, HostedReceiptVerificationSchema, HostedReceiptVerificationInputSchema.parse(value2)),
5605
6634
  ...outputCheckCalls(call),
5606
- executeJob: async (id13, value) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id13))}/jobs`, HostedJobResultSchema, HostedJobInputSchema.parse(value)),
6635
+ executeJob: async (id15, value2) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id15))}/jobs`, HostedJobResultSchema, HostedJobInputSchema.parse(value2)),
5607
6636
  ...agentCalls(call),
5608
- resolveFacts: async (id13, value) => {
5609
- const releaseId = objectId.parse(id13);
5610
- const input = await factsRequest(value, async (jobId) => await describe(releaseId, jobId));
6637
+ resolveFacts: async (id15, value2) => {
6638
+ const releaseId = objectId.parse(id15);
6639
+ const input = await factsRequest(value2, async (jobId) => await describe(releaseId, jobId));
5611
6640
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5612
- return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);
6641
+ return pinnedResult(await call(path3, FelsparJobResultSchema2, input), releaseId, input);
5613
6642
  }
5614
6643
  };
5615
6644
  }