@nakafa/aksara-contracts 0.48.4 → 0.48.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/content.d.ts +2 -2
  2. package/dist/content.js +2 -1
  3. package/dist/delivery.d.ts +3 -0
  4. package/dist/delivery.js +5 -0
  5. package/dist/math/base.d.ts +6 -6
  6. package/dist/math/base.js +2 -0
  7. package/dist/math/collision.js +2 -1
  8. package/dist/math/coordinate.d.ts +3 -3
  9. package/dist/math/coordinate.js +3 -2
  10. package/dist/math/extent.js +2 -2
  11. package/dist/math/intersection.d.ts +2 -1
  12. package/dist/math/intersection.js +1 -0
  13. package/dist/math/object.d.ts +24 -0
  14. package/dist/math/object.js +27 -0
  15. package/dist/math/plane.js +16 -24
  16. package/dist/math/precision.d.ts +2 -2
  17. package/dist/math/resolution.js +10 -7
  18. package/dist/math/space.js +14 -22
  19. package/dist/projection/verify.d.ts +114 -114
  20. package/dist/projection/verify.js +13 -20
  21. package/dist/question/response.d.ts +20 -0
  22. package/dist/question/response.js +6 -3
  23. package/dist/question/rubric.js +4 -1
  24. package/dist/quran/notes.js +5 -6
  25. package/dist/quran/provenance.js +1 -1
  26. package/dist/quran/snapshot/row.d.ts +2 -0
  27. package/dist/quran/snapshot/row.js +3 -1
  28. package/dist/release/head.js +15 -33
  29. package/dist/release/items.js +14 -18
  30. package/dist/release/mismatch.d.ts +12 -0
  31. package/dist/release/mismatch.js +14 -0
  32. package/dist/release/result/digest.js +8 -17
  33. package/dist/release/rollback/digest.js +3 -10
  34. package/dist/release/route/verify.d.ts +1 -1
  35. package/dist/release/route/verify.js +8 -11
  36. package/dist/release/snapshot/evidence/requirement.d.ts +2 -1
  37. package/dist/release/snapshot/evidence/requirement.js +2 -1
  38. package/dist/release/snapshot/spec.d.ts +4 -1
  39. package/dist/release/snapshot/spec.js +6 -1
  40. package/dist/release/snapshot/verify.d.ts +52 -52
  41. package/dist/runtime/protected/spec.js +4 -3
  42. package/dist/runtime/spec.d.ts +23 -23
  43. package/dist/runtime/verify.d.ts +30 -30
  44. package/dist/runtime/verify.js +10 -9
  45. package/dist/transport/group.js +2 -5
  46. package/dist/transport/request.d.ts +4442 -4442
  47. package/dist/transport/response.d.ts +56 -56
  48. package/dist/transport/response.js +22 -105
  49. package/dist/transport/success.d.ts +12 -0
  50. package/dist/transport/success.js +13 -0
  51. package/dist/tryout/catalog.d.ts +2 -0
  52. package/dist/tryout/catalog.js +5 -1
  53. package/dist/tryout/hash/catalog.d.ts +23 -23
  54. package/dist/tryout/scoring.d.ts +113 -8
  55. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
- import type { ContentReleaseManifest } from "#contracts/release/spec";
2
+ import { type ContentReleaseManifest } from "#contracts/release/spec";
3
3
  declare const ProjectionDecodeError_base: Schema.Class<ProjectionDecodeError, Schema.TaggedStruct<"ProjectionDecodeError", {
4
4
  readonly projectionIndex: Schema.Finite;
5
5
  }>, import("effect/Cause").YieldableError>;
@@ -43,90 +43,6 @@ declare const VerifiedContentProjectionsSchema: Schema.Struct<{
43
43
  export type VerifiedContentProjections = typeof VerifiedContentProjectionsSchema.Type;
44
44
  /** Strictly decodes a replayable canonical content projection stream. */
45
45
  export declare function decodeContentProjections<E, R>(projections: Stream.Stream<unknown, E, R>): Stream.Stream<{
46
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
47
- readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
48
- readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
49
- readonly pageKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPageKey">;
50
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
51
- readonly kind: "public-page";
52
- readonly metadata: {
53
- readonly dateModified?: string;
54
- readonly datePublished: string;
55
- readonly description: string;
56
- readonly title: string;
57
- };
58
- readonly sitemap: true;
59
- readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
60
- } | {
61
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
62
- readonly articleRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
63
- readonly articleSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleSlug">;
64
- readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
65
- readonly category: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleCategory">;
66
- readonly categoryRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
67
- readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
68
- readonly graph: {
69
- readonly alignmentId: string;
70
- readonly assetId: string;
71
- readonly conceptId: string;
72
- readonly learningObjectId: string;
73
- readonly lensId: string;
74
- };
75
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
76
- readonly categoryTitle: string;
77
- readonly kind: "article";
78
- readonly metadata: {
79
- readonly dateModified?: string;
80
- readonly datePublished: string;
81
- readonly authors: readonly {
82
- readonly name: string;
83
- }[];
84
- readonly description?: string | undefined;
85
- readonly title: string;
86
- };
87
- readonly official: boolean;
88
- readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
89
- readonly references: readonly {
90
- readonly authors: string;
91
- readonly citation?: string | undefined;
92
- readonly details?: string | undefined;
93
- readonly publication?: string | undefined;
94
- readonly title: string;
95
- readonly url?: string | undefined;
96
- readonly year: number;
97
- }[];
98
- readonly sitemap: true;
99
- } | {
100
- readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
101
- readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
102
- readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
103
- readonly graph: {
104
- readonly alignmentId: string;
105
- readonly assetId: string;
106
- readonly conceptId: string;
107
- readonly learningObjectId: string;
108
- readonly lensId: string;
109
- };
110
- readonly materialKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialKey">;
111
- readonly order: number;
112
- readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
113
- readonly sectionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialSection">;
114
- readonly kind: "subject-lesson";
115
- readonly metadata: {
116
- readonly dateModified?: string;
117
- readonly datePublished: string;
118
- readonly authors: readonly {
119
- readonly name: string;
120
- }[];
121
- readonly description?: string | undefined;
122
- readonly searchTitle?: string;
123
- readonly subject?: string | undefined;
124
- readonly title: string;
125
- };
126
- readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
127
- readonly sitemap: true;
128
- readonly topicTitle: string;
129
- } | {
130
46
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
131
47
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
132
48
  readonly peerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
@@ -150,35 +66,6 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
150
66
  };
151
67
  readonly stimulusKey?: string;
152
68
  readonly response: {
153
- readonly categories: readonly {
154
- readonly categoryKey: string;
155
- readonly label: string;
156
- readonly order: number;
157
- }[];
158
- readonly kind: "category";
159
- readonly statements: readonly {
160
- readonly correctCategoryKey: string;
161
- readonly label: string;
162
- readonly order: number;
163
- readonly statementKey: string;
164
- }[];
165
- } | {
166
- readonly kind: "multiple-choice";
167
- readonly options: readonly {
168
- readonly isCorrect: boolean;
169
- readonly label: string;
170
- readonly optionKey: string;
171
- readonly order: number;
172
- }[];
173
- } | {
174
- readonly kind: "single-choice";
175
- readonly options: readonly {
176
- readonly isCorrect: boolean;
177
- readonly label: string;
178
- readonly optionKey: string;
179
- readonly order: number;
180
- }[];
181
- } | {
182
69
  readonly criteria: readonly {
183
70
  readonly criterionKey: string;
184
71
  readonly finalAnswer?: {
@@ -213,6 +100,35 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
213
100
  }[];
214
101
  }[];
215
102
  readonly kind: "rubric";
103
+ } | {
104
+ readonly categories: readonly {
105
+ readonly categoryKey: string;
106
+ readonly label: string;
107
+ readonly order: number;
108
+ }[];
109
+ readonly kind: "category";
110
+ readonly statements: readonly {
111
+ readonly correctCategoryKey: string;
112
+ readonly label: string;
113
+ readonly order: number;
114
+ readonly statementKey: string;
115
+ }[];
116
+ } | {
117
+ readonly kind: "multiple-choice";
118
+ readonly options: readonly {
119
+ readonly isCorrect: boolean;
120
+ readonly label: string;
121
+ readonly optionKey: string;
122
+ readonly order: number;
123
+ }[];
124
+ } | {
125
+ readonly kind: "single-choice";
126
+ readonly options: readonly {
127
+ readonly isCorrect: boolean;
128
+ readonly label: string;
129
+ readonly optionKey: string;
130
+ readonly order: number;
131
+ }[];
216
132
  } | {
217
133
  readonly key: {
218
134
  readonly acceptsFractions: boolean;
@@ -253,6 +169,90 @@ export declare function decodeContentProjections<E, R>(projections: Stream.Strea
253
169
  readonly title: string;
254
170
  };
255
171
  readonly stimulusKey?: string;
172
+ } | {
173
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
174
+ readonly articleRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
175
+ readonly articleSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleSlug">;
176
+ readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
177
+ readonly category: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleCategory">;
178
+ readonly categoryRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
179
+ readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
180
+ readonly graph: {
181
+ readonly alignmentId: string;
182
+ readonly assetId: string;
183
+ readonly conceptId: string;
184
+ readonly learningObjectId: string;
185
+ readonly lensId: string;
186
+ };
187
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
188
+ readonly categoryTitle: string;
189
+ readonly kind: "article";
190
+ readonly metadata: {
191
+ readonly dateModified?: string;
192
+ readonly datePublished: string;
193
+ readonly authors: readonly {
194
+ readonly name: string;
195
+ }[];
196
+ readonly description?: string | undefined;
197
+ readonly title: string;
198
+ };
199
+ readonly official: boolean;
200
+ readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
201
+ readonly references: readonly {
202
+ readonly authors: string;
203
+ readonly citation?: string | undefined;
204
+ readonly details?: string | undefined;
205
+ readonly publication?: string | undefined;
206
+ readonly title: string;
207
+ readonly url?: string | undefined;
208
+ readonly year: number;
209
+ }[];
210
+ readonly sitemap: true;
211
+ } | {
212
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
213
+ readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
214
+ readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
215
+ readonly graph: {
216
+ readonly alignmentId: string;
217
+ readonly assetId: string;
218
+ readonly conceptId: string;
219
+ readonly learningObjectId: string;
220
+ readonly lensId: string;
221
+ };
222
+ readonly materialKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialKey">;
223
+ readonly order: number;
224
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
225
+ readonly sectionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraMaterialSection">;
226
+ readonly kind: "subject-lesson";
227
+ readonly metadata: {
228
+ readonly dateModified?: string;
229
+ readonly datePublished: string;
230
+ readonly authors: readonly {
231
+ readonly name: string;
232
+ }[];
233
+ readonly description?: string | undefined;
234
+ readonly searchTitle?: string;
235
+ readonly subject?: string | undefined;
236
+ readonly title: string;
237
+ };
238
+ readonly parentPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
239
+ readonly sitemap: true;
240
+ readonly topicTitle: string;
241
+ } | {
242
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
243
+ readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
244
+ readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
245
+ readonly pageKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPageKey">;
246
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
247
+ readonly kind: "public-page";
248
+ readonly metadata: {
249
+ readonly dateModified?: string;
250
+ readonly datePublished: string;
251
+ readonly description: string;
252
+ readonly title: string;
253
+ };
254
+ readonly sitemap: true;
255
+ readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
256
256
  }, E | ProjectionDecodeError | ProjectionOrderError | ProjectionRouteError, R>;
257
257
  /** Authenticates a replayable projection stream against its signed manifest. */
258
258
  export declare const verifyContentProjections: <E, R>(input: {
@@ -1,41 +1,34 @@
1
1
  import { Effect, MutableHashMap, Option, Schema, Stream } from "effect";
2
2
  import { compareContentHeads, routeIdentity } from "#contracts/content";
3
- import { PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
3
+ import { PublicPathSchema } from "#contracts/ids";
4
4
  import { digestProjections } from "#contracts/projection/digest";
5
5
  import { ContentProjectionSchema, } from "#contracts/projection/spec";
6
- const ProjectionIndexSchema = Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0)));
6
+ import { ReleaseCountMismatchFields, ReleaseDigestMismatchFields, } from "#contracts/release/mismatch";
7
+ import { ReleaseCountSchema, } from "#contracts/release/spec";
7
8
  /** One streamed projection failed strict schema decoding. */
8
- export class ProjectionDecodeError extends Schema.TaggedError()("ProjectionDecodeError", { projectionIndex: ProjectionIndexSchema }) {
9
+ export class ProjectionDecodeError extends Schema.TaggedError()("ProjectionDecodeError", { projectionIndex: ReleaseCountSchema }) {
9
10
  }
10
11
  /** Projections are duplicated or not in canonical content-head order. */
11
- export class ProjectionOrderError extends Schema.TaggedError()("ProjectionOrderError", { projectionIndex: ProjectionIndexSchema }) {
12
+ export class ProjectionOrderError extends Schema.TaggedError()("ProjectionOrderError", { projectionIndex: ReleaseCountSchema }) {
12
13
  }
13
14
  /** Two content projections claim the same locale-specific public route. */
14
15
  export class ProjectionRouteError extends Schema.TaggedError()("ProjectionRouteError", {
15
- duplicateIndex: ProjectionIndexSchema,
16
- firstIndex: ProjectionIndexSchema,
16
+ duplicateIndex: ReleaseCountSchema,
17
+ firstIndex: ReleaseCountSchema,
17
18
  publicPath: PublicPathSchema,
18
19
  }) {
19
20
  }
20
21
  /** The streamed projection count differs from the signed manifest. */
21
- export class ProjectionCountError extends Schema.TaggedError()("ProjectionCountError", {
22
- actualCount: ProjectionIndexSchema,
23
- expectedCount: ProjectionIndexSchema,
24
- releaseId: ReleaseIdSchema,
25
- }) {
22
+ export class ProjectionCountError extends Schema.TaggedError()("ProjectionCountError", { ...ReleaseCountMismatchFields }) {
26
23
  }
27
24
  /** The streamed projection digest differs from the signed manifest. */
28
- export class ProjectionDigestError extends Schema.TaggedError()("ProjectionDigestError", {
29
- actualDigest: Sha256HashSchema,
30
- expectedDigest: Sha256HashSchema,
31
- releaseId: ReleaseIdSchema,
32
- }) {
25
+ export class ProjectionDigestError extends Schema.TaggedError()("ProjectionDigestError", { ...ReleaseDigestMismatchFields }) {
33
26
  }
34
27
  /** Creates the replay state that one stream of projections shares while it decodes. */
35
28
  function projectionState() {
36
29
  return {
37
30
  firstIndexByRoute: MutableHashMap.empty(),
38
- previous: undefined,
31
+ previous: Option.none(),
39
32
  };
40
33
  }
41
34
  const VerifiedContentProjectionsSchema = Schema.Struct({
@@ -44,11 +37,11 @@ const VerifiedContentProjectionsSchema = Schema.Struct({
44
37
  /** Decodes one row and applies canonical order and route uniqueness rules. */
45
38
  const decodeProjection = Effect.fn("AksaraContracts.decodeProjection")(function* (state, source, projectionIndex) {
46
39
  const projection = yield* Schema.decodeUnknownEffect(ContentProjectionSchema)(source, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new ProjectionDecodeError({ projectionIndex })));
47
- if (state.previous &&
48
- compareContentHeads(state.previous, projection) >= 0) {
40
+ if (Option.isSome(state.previous) &&
41
+ compareContentHeads(state.previous.value, projection) >= 0) {
49
42
  return yield* new ProjectionOrderError({ projectionIndex });
50
43
  }
51
- state.previous = projection;
44
+ state.previous = Option.some(projection);
52
45
  if (projection.kind === "question-body") {
53
46
  return projection;
54
47
  }
@@ -6,6 +6,26 @@ import { Schema } from "effect";
6
6
  */
7
7
  export declare const QuestionResponseKindSchema: Schema.Literals<readonly ["category", "multiple-choice", "rubric", "short-answer", "single-choice"]>;
8
8
  export type QuestionResponseKind = typeof QuestionResponseKindSchema.Type;
9
+ /** One option of a single or multiple choice response, keyed by its identity. */
10
+ export declare const QuestionOptionSchema: Schema.Struct<{
11
+ readonly isCorrect: Schema.Boolean;
12
+ readonly label: Schema.String;
13
+ readonly optionKey: Schema.String;
14
+ readonly order: Schema.Int;
15
+ }>;
16
+ /** One named category of a category response, keyed by its identity. */
17
+ export declare const QuestionCategorySchema: Schema.Struct<{
18
+ readonly categoryKey: Schema.String;
19
+ readonly label: Schema.String;
20
+ readonly order: Schema.Int;
21
+ }>;
22
+ /** One statement classified into one category, keyed by its identity. */
23
+ export declare const QuestionCategoryStatementSchema: Schema.Struct<{
24
+ readonly correctCategoryKey: Schema.String;
25
+ readonly label: Schema.String;
26
+ readonly order: Schema.Int;
27
+ readonly statementKey: Schema.String;
28
+ }>;
9
29
  /** Frozen locale-specific response used from publication through review. */
10
30
  export declare const QuestionResponseSchema: Schema.Union<readonly [Schema.Struct<{
11
31
  readonly categories: Schema.$Array<Schema.Struct<{
@@ -18,7 +18,8 @@ export const QuestionResponseKindSchema = Schema.Literals([
18
18
  "short-answer",
19
19
  "single-choice",
20
20
  ]);
21
- const QuestionOptionSchema = Schema.Struct({
21
+ /** One option of a single or multiple choice response, keyed by its identity. */
22
+ export const QuestionOptionSchema = Schema.Struct({
22
23
  isCorrect: Schema.Boolean,
23
24
  label: QuestionResponseLabelSchema,
24
25
  optionKey: Schema.String.pipe(Schema.check(Schema.isPattern(OPTION_KEY_PATTERN))),
@@ -45,12 +46,14 @@ const MultipleChoiceResponseSchema = Schema.Struct({
45
46
  }).pipe(Schema.check(Schema.makeFilter(({ options }) => hasCanonicalOptions(options, "multiple-choice"), {
46
47
  message: "Multiple-choice responses require canonical options, several correct answers, and one distractor.",
47
48
  })));
48
- const QuestionCategorySchema = Schema.Struct({
49
+ /** One named category of a category response, keyed by its identity. */
50
+ export const QuestionCategorySchema = Schema.Struct({
49
51
  categoryKey: Schema.String.pipe(Schema.check(Schema.isPattern(CATEGORY_KEY_PATTERN))),
50
52
  label: QuestionResponseLabelSchema,
51
53
  order: PositiveOrderSchema,
52
54
  });
53
- const QuestionCategoryStatementSchema = Schema.Struct({
55
+ /** One statement classified into one category, keyed by its identity. */
56
+ export const QuestionCategoryStatementSchema = Schema.Struct({
54
57
  correctCategoryKey: Schema.String.pipe(Schema.check(Schema.isPattern(CATEGORY_KEY_PATTERN))),
55
58
  label: QuestionResponseLabelSchema,
56
59
  order: PositiveOrderSchema,
@@ -34,7 +34,10 @@ function hasOrderedScale(criterion) {
34
34
  return criterion.levels.length === 2 && lower?.points === 0;
35
35
  }
36
36
  const ORDERED_SCALE_MESSAGE = "Rubric criteria need two or more levels whose points strictly ascend, and a final-answer criterion needs exactly a zero level and one higher level.";
37
- /** Checks one or more criteria and the stable keys derived from their order. */
37
+ /**
38
+ * Checks one or more criteria and the stable keys derived from their order. A
39
+ * labeled criterion is a scale criterion with labels, so both kinds pass here.
40
+ */
38
41
  function hasCanonicalCriteria(criteria) {
39
42
  return (criteria.length > 0 &&
40
43
  Arr.every(criteria, ({ criterionKey, levels, order }, index) => order === index + 1 &&
@@ -60,7 +60,7 @@ function readMarkers(source) {
60
60
  const number = Number(rawNumber);
61
61
  if (rawNumber !== String(number) ||
62
62
  !Schema.is(QuranTranslationNoteNumberSchema)(number)) {
63
- return { _tag: "Failure" };
63
+ return Option.none();
64
64
  }
65
65
  MutableList.append(markers, {
66
66
  end: start + match[0].length,
@@ -68,7 +68,7 @@ function readMarkers(source) {
68
68
  start,
69
69
  });
70
70
  }
71
- return { _tag: "Success", markers: MutableList.toArray(markers) };
71
+ return Option.some(MutableList.toArray(markers));
72
72
  }
73
73
  /** Converts the translation body to text and note-reference segments. */
74
74
  function segmentTranslation(source, markers) {
@@ -102,12 +102,11 @@ function segmentTranslation(source, markers) {
102
102
  function analyzeTranslation(source) {
103
103
  const referencesResult = readMarkers(source.text);
104
104
  const definitionsResult = readMarkers(source.footnotes);
105
- if (referencesResult._tag === "Failure" ||
106
- definitionsResult._tag === "Failure") {
105
+ if (Option.isNone(referencesResult) || Option.isNone(definitionsResult)) {
107
106
  return { _tag: "Failure", reason: "invalid-marker" };
108
107
  }
109
- const references = referencesResult.markers;
110
- const definitions = definitionsResult.markers;
108
+ const references = referencesResult.value;
109
+ const definitions = definitionsResult.value;
111
110
  const uniqueReferences = Arr.filter(references, (reference, index) => Option.contains(Arr.findFirstIndex(references, ({ number }) => number === reference.number), index));
112
111
  const noteCandidates = Arr.map(definitions, (definition, index) => ({
113
112
  definition,
@@ -4,7 +4,7 @@ import { Sha256HashSchema } from "#contracts/ids";
4
4
  import { ActiveAppLocaleListSchema, AppLocaleSchema, ENGLISH_APP_LOCALE_CODE, GERMAN_APP_LOCALE_CODE, INDONESIAN_APP_LOCALE_CODE, } from "#contracts/locale";
5
5
  import { canonicalizeQuranAttribution } from "#contracts/quran/attribution";
6
6
  import { QuranNameProvenanceScopeSchema, QuranTranslationProvenanceScopeSchema, quranNameProvenanceScope, quranNameSourceForScope, quranTafsirSourceId, quranTranslationProvenanceScope, quranTranslationSourceForScope, } from "#contracts/quran/identity";
7
- import { QuranProvenanceStatusSchema } from "#contracts/quran/snapshot/spec";
7
+ import { QuranProvenanceStatusSchema, } from "#contracts/quran/snapshot/spec";
8
8
  import { hasCompleteQuranSourceCopy, QuranSourceAttributionSchema, } from "#contracts/quran/source";
9
9
  import { encodeJsonText } from "#contracts/text/json";
10
10
  /** Quran source fields that require independent provenance decisions. */
@@ -8,6 +8,8 @@ export declare const QuranLocalizedTranslationSchema: Schema.Struct<{
8
8
  }>;
9
9
  }>;
10
10
  export type QuranLocalizedTranslation = typeof QuranLocalizedTranslationSchema.Type;
11
+ /** Sajda obligation of one verse, present only where the source assigns one. */
12
+ export declare const QuranSajdaSchema: Schema.Literals<readonly ["obligatory", "recommended"]>;
11
13
  /** One exact verse with explicit translation locale entries. */
12
14
  export declare const QuranRuntimeVerseSchema: Schema.Struct<{
13
15
  readonly meta: Schema.Struct<{
@@ -25,6 +25,8 @@ const QuranRuntimeTafsirSchema = Schema.Struct({
25
25
  footnotes: Schema.NullOr(Schema.String),
26
26
  text: QuranMeaningfulTextSchema,
27
27
  });
28
+ /** Sajda obligation of one verse, present only where the source assigns one. */
29
+ export const QuranSajdaSchema = Schema.Literals(["obligatory", "recommended"]);
28
30
  /** One exact verse with explicit translation locale entries. */
29
31
  export const QuranRuntimeVerseSchema = Schema.Struct({
30
32
  meta: Schema.Struct({
@@ -33,7 +35,7 @@ export const QuranRuntimeVerseSchema = Schema.Struct({
33
35
  manzil: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))),
34
36
  page: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))),
35
37
  ruku: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))),
36
- sajda: Schema.NullOr(Schema.Literals(["obligatory", "recommended"])),
38
+ sajda: Schema.NullOr(QuranSajdaSchema),
37
39
  }),
38
40
  number: Schema.Struct({
39
41
  inQuran: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))),
@@ -1,5 +1,5 @@
1
1
  import { Array as Arr, Schema } from "effect";
2
- import { ContentFamilySchema, compareContentHeads } from "#contracts/content";
2
+ import { ContentFamilySchema, compareContentHeads, } from "#contracts/content";
3
3
  import { ContentDeliveryClassSchema } from "#contracts/delivery";
4
4
  import { ContentKeySchema, CorpusSourcePathSchema, PublicPathSchema, ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
5
5
  import { ArtifactLocaleSchema } from "#contracts/locale";
@@ -95,38 +95,20 @@ const HeadPageFields = {
95
95
  done: Schema.Boolean,
96
96
  nextCursor: HeadCursorSchema,
97
97
  };
98
- const ArticleHeadPageSchema = Schema.Struct({
99
- ...HeadPageFields,
100
- family: Schema.Literal("article"),
101
- heads: Schema.Array(ArticleHeadSchema).pipe(Schema.check(Schema.isMaxLength(MAX_HEAD_PAGE_COUNT))),
102
- }).pipe(Schema.check(Schema.makeFilter(hasCanonicalHeadPage, {
103
- message: "Expected canonical article heads with coherent cursor progress.",
104
- })));
105
- const MaterialHeadPageSchema = Schema.Struct({
106
- ...HeadPageFields,
107
- family: Schema.Literal("material"),
108
- heads: Schema.Array(MaterialHeadSchema).pipe(Schema.check(Schema.isMaxLength(MAX_HEAD_PAGE_COUNT))),
109
- }).pipe(Schema.check(Schema.makeFilter(hasCanonicalHeadPage, {
110
- message: "Expected canonical material heads with coherent cursor progress.",
111
- })));
112
- const PageHeadPageSchema = Schema.Struct({
113
- ...HeadPageFields,
114
- family: Schema.Literal("page"),
115
- heads: Schema.Array(PageHeadSchema).pipe(Schema.check(Schema.isMaxLength(MAX_HEAD_PAGE_COUNT))),
116
- }).pipe(Schema.check(Schema.makeFilter(hasCanonicalHeadPage, {
117
- message: "Expected canonical page heads with coherent cursor progress.",
118
- })));
119
- const QuestionHeadPageSchema = Schema.Struct({
120
- ...HeadPageFields,
121
- family: Schema.Literal("question"),
122
- heads: Schema.Array(QuestionHeadSchema).pipe(Schema.check(Schema.isMaxLength(MAX_HEAD_PAGE_COUNT))),
123
- }).pipe(Schema.check(Schema.makeFilter(hasCanonicalHeadPage, {
124
- message: "Expected canonical question heads with coherent cursor progress.",
125
- })));
98
+ /** Builds one family-owned head page whose heads share that family's shape. */
99
+ function headPageSchema(family, head) {
100
+ return Schema.Struct({
101
+ ...HeadPageFields,
102
+ family: Schema.Literal(family),
103
+ heads: Schema.Array(head).pipe(Schema.check(Schema.isMaxLength(MAX_HEAD_PAGE_COUNT))),
104
+ }).pipe(Schema.check(Schema.makeFilter(hasCanonicalHeadPage, {
105
+ message: `Expected canonical ${family} heads with coherent cursor progress.`,
106
+ })));
107
+ }
126
108
  /** Bounded canonical page proving one exact family-owned head inventory. */
127
109
  export const HeadPageSchema = Schema.Union([
128
- ArticleHeadPageSchema,
129
- MaterialHeadPageSchema,
130
- PageHeadPageSchema,
131
- QuestionHeadPageSchema,
110
+ headPageSchema("article", ArticleHeadSchema),
111
+ headPageSchema("material", MaterialHeadSchema),
112
+ headPageSchema("page", PageHeadSchema),
113
+ headPageSchema("question", QuestionHeadSchema),
132
114
  ]);
@@ -1,41 +1,37 @@
1
1
  import { Array as Arr, Effect, MutableRef, Option, Schema, Stream, } from "effect";
2
2
  import { compareContentHeads } from "#contracts/content";
3
- import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
3
+ import { ReleaseIdSchema } from "#contracts/ids";
4
4
  import { digestItems } from "#contracts/release/digest";
5
- import { ContentReleaseItemSchema, } from "#contracts/release/spec";
6
- const ItemCountSchema = Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThanOrEqualTo(0)));
5
+ import { ReleaseDigestMismatchFields } from "#contracts/release/mismatch";
6
+ import { ContentReleaseItemSchema, ReleaseCountSchema, } from "#contracts/release/spec";
7
7
  /** One release item failed strict wire decoding. */
8
- export class ReleaseItemDecodeError extends Schema.TaggedError()("ReleaseItemDecodeError", { itemOffset: ItemCountSchema }) {
8
+ export class ReleaseItemDecodeError extends Schema.TaggedError()("ReleaseItemDecodeError", { itemOffset: ReleaseCountSchema }) {
9
9
  }
10
10
  /** The separate item stream does not have the signed manifest length. */
11
- export class ReleaseItemCountMismatchError extends Schema.TaggedError()("ReleaseItemCountMismatchError", { actualCount: ItemCountSchema, expectedCount: ItemCountSchema }) {
11
+ export class ReleaseItemCountMismatchError extends Schema.TaggedError()("ReleaseItemCountMismatchError", { actualCount: ReleaseCountSchema, expectedCount: ReleaseCountSchema }) {
12
12
  }
13
13
  /** Upsert and delete totals do not match the counts signed by the manifest. */
14
14
  export class ReleaseItemOperationCountMismatchError extends Schema.TaggedError()("ReleaseItemOperationCountMismatchError", {
15
- actualDeletes: ItemCountSchema,
16
- actualUpserts: ItemCountSchema,
17
- expectedDeletes: ItemCountSchema,
18
- expectedUpserts: ItemCountSchema,
15
+ actualDeletes: ReleaseCountSchema,
16
+ actualUpserts: ReleaseCountSchema,
17
+ expectedDeletes: ReleaseCountSchema,
18
+ expectedUpserts: ReleaseCountSchema,
19
19
  }) {
20
20
  }
21
21
  /** An item belongs to another release envelope. */
22
- export class ReleaseItemReleaseMismatchError extends Schema.TaggedError()("ReleaseItemReleaseMismatchError", { itemOffset: ItemCountSchema, releaseId: ReleaseIdSchema }) {
22
+ export class ReleaseItemReleaseMismatchError extends Schema.TaggedError()("ReleaseItemReleaseMismatchError", { itemOffset: ReleaseCountSchema, releaseId: ReleaseIdSchema }) {
23
23
  }
24
24
  /** An item is missing, duplicated, or out of its signed sequence. */
25
- export class ReleaseItemIndexMismatchError extends Schema.TaggedError()("ReleaseItemIndexMismatchError", { actualIndex: ItemCountSchema, expectedIndex: ItemCountSchema }) {
25
+ export class ReleaseItemIndexMismatchError extends Schema.TaggedError()("ReleaseItemIndexMismatchError", { actualIndex: ReleaseCountSchema, expectedIndex: ReleaseCountSchema }) {
26
26
  }
27
27
  /** Item heads are duplicated or not in canonical content-head order. */
28
- export class ReleaseItemOrderError extends Schema.TaggedError()("ReleaseItemOrderError", { itemOffset: ItemCountSchema }) {
28
+ export class ReleaseItemOrderError extends Schema.TaggedError()("ReleaseItemOrderError", { itemOffset: ReleaseCountSchema }) {
29
29
  }
30
30
  /** One signed item falls outside the release's exact publication scope. */
31
- export class ReleaseItemScopeError extends Schema.TaggedError()("ReleaseItemScopeError", { itemOffset: ItemCountSchema }) {
31
+ export class ReleaseItemScopeError extends Schema.TaggedError()("ReleaseItemScopeError", { itemOffset: ReleaseCountSchema }) {
32
32
  }
33
33
  /** The separate ordered items do not match the signed digest. */
34
- export class ReleaseItemsDigestMismatchError extends Schema.TaggedError()("ReleaseItemsDigestMismatchError", {
35
- actualDigest: Sha256HashSchema,
36
- expectedDigest: Sha256HashSchema,
37
- releaseId: ReleaseIdSchema,
38
- }) {
34
+ export class ReleaseItemsDigestMismatchError extends Schema.TaggedError()("ReleaseItemsDigestMismatchError", { ...ReleaseDigestMismatchFields }) {
39
35
  }
40
36
  const VerifiedContentReleaseItemsSchema = Schema.Struct({
41
37
  deleteCount: Schema.Finite,
@@ -0,0 +1,12 @@
1
+ /** Fields that name one signed release digest and the replayed digest that failed. */
2
+ export declare const ReleaseDigestMismatchFields: {
3
+ actualDigest: import("effect/Schema").brand<import("effect/Schema").String, "@NakafaAI/AksaraSha256Hash">;
4
+ expectedDigest: import("effect/Schema").brand<import("effect/Schema").String, "@NakafaAI/AksaraSha256Hash">;
5
+ releaseId: import("effect/Schema").brand<import("effect/Schema").String, "@NakafaAI/AksaraReleaseId">;
6
+ };
7
+ /** Fields that name one signed release count and the replayed count that failed. */
8
+ export declare const ReleaseCountMismatchFields: {
9
+ actualCount: import("effect/Schema").Finite;
10
+ expectedCount: import("effect/Schema").Finite;
11
+ releaseId: import("effect/Schema").brand<import("effect/Schema").String, "@NakafaAI/AksaraReleaseId">;
12
+ };
@@ -0,0 +1,14 @@
1
+ import { ReleaseIdSchema, Sha256HashSchema } from "#contracts/ids";
2
+ import { ReleaseCountSchema } from "#contracts/release/spec";
3
+ /** Fields that name one signed release digest and the replayed digest that failed. */
4
+ export const ReleaseDigestMismatchFields = {
5
+ actualDigest: Sha256HashSchema,
6
+ expectedDigest: Sha256HashSchema,
7
+ releaseId: ReleaseIdSchema,
8
+ };
9
+ /** Fields that name one signed release count and the replayed count that failed. */
10
+ export const ReleaseCountMismatchFields = {
11
+ actualCount: ReleaseCountSchema,
12
+ expectedCount: ReleaseCountSchema,
13
+ releaseId: ReleaseIdSchema,
14
+ };