@nakafa/aksara-contracts 1.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +10 -27
  2. package/dist/artifact/integrity.d.ts +3 -3
  3. package/dist/artifact/integrity.js +2 -2
  4. package/dist/artifact/source.d.ts +2 -2
  5. package/dist/artifact/source.js +2 -8
  6. package/dist/artifact/spec.d.ts +0 -16
  7. package/dist/artifact/spec.js +0 -6
  8. package/dist/artifact/verify.d.ts +1 -1
  9. package/dist/{question → assessment}/answer.d.ts +14 -58
  10. package/dist/{question → assessment}/answer.js +13 -60
  11. package/dist/assessment/catalog.d.ts +235 -0
  12. package/dist/assessment/catalog.js +115 -0
  13. package/dist/assessment/chart.d.ts +62 -0
  14. package/dist/assessment/chart.js +64 -0
  15. package/dist/assessment/closure.d.ts +28 -0
  16. package/dist/assessment/closure.js +164 -0
  17. package/dist/assessment/explanation.d.ts +13 -8
  18. package/dist/assessment/explanation.js +14 -8
  19. package/dist/assessment/figure.d.ts +140 -1
  20. package/dist/assessment/figure.js +9 -2
  21. package/dist/assessment/hash.d.ts +352 -212
  22. package/dist/assessment/hash.js +14 -0
  23. package/dist/assessment/inline.d.ts +3 -1
  24. package/dist/assessment/inline.js +20 -5
  25. package/dist/assessment/item.d.ts +8 -4
  26. package/dist/assessment/item.js +6 -2
  27. package/dist/assessment/key.js +6 -6
  28. package/dist/assessment/paper.d.ts +74 -74
  29. package/dist/assessment/snapshot.d.ts +3778 -0
  30. package/dist/assessment/snapshot.js +192 -0
  31. package/dist/cache/content.d.ts +4 -4
  32. package/dist/canonical.d.ts +6 -0
  33. package/dist/canonical.js +8 -1
  34. package/dist/content.d.ts +1 -1
  35. package/dist/content.js +0 -1
  36. package/dist/delivery.d.ts +0 -3
  37. package/dist/delivery.js +0 -5
  38. package/dist/hash/digest.d.ts +7 -7
  39. package/dist/hash/digest.js +9 -30
  40. package/dist/hash/stream.d.ts +1 -1
  41. package/dist/hash/text.d.ts +3 -12
  42. package/dist/hash/text.js +3 -6
  43. package/dist/ids.js +8 -8
  44. package/dist/preview/artifact.d.ts +1 -120
  45. package/dist/preview/auth.d.ts +1 -1
  46. package/dist/preview/auth.js +29 -25
  47. package/dist/preview/document.d.ts +0 -586
  48. package/dist/preview/document.js +1 -47
  49. package/dist/preview/spec.d.ts +6 -1984
  50. package/dist/preview/spec.js +7 -47
  51. package/dist/preview/target.d.ts +0 -173
  52. package/dist/preview/target.js +1 -70
  53. package/dist/program/snapshot/digest.d.ts +1 -2
  54. package/dist/program/snapshot/digest.js +2 -4
  55. package/dist/program/snapshot/hash.d.ts +6 -21
  56. package/dist/program/snapshot/hash.js +3 -9
  57. package/dist/projection/digest.d.ts +7 -143
  58. package/dist/projection/digest.js +7 -13
  59. package/dist/projection/hash.d.ts +2 -138
  60. package/dist/projection/hash.js +2 -5
  61. package/dist/projection/material.js +1 -1
  62. package/dist/projection/spec.d.ts +6 -211
  63. package/dist/projection/spec.js +4 -18
  64. package/dist/projection/verify.d.ts +1 -128
  65. package/dist/projection/verify.js +1 -4
  66. package/dist/quran/provenance.d.ts +2 -8
  67. package/dist/quran/provenance.js +1 -4
  68. package/dist/quran/snapshot/digest.d.ts +1 -2
  69. package/dist/quran/snapshot/digest.js +2 -2
  70. package/dist/quran/snapshot/hash.d.ts +3 -10
  71. package/dist/quran/snapshot/hash.js +2 -5
  72. package/dist/quran/snapshot/row/hash.d.ts +3 -12
  73. package/dist/quran/snapshot/row/hash.js +2 -5
  74. package/dist/release/canonical.d.ts +2 -2
  75. package/dist/release/current/evidence.d.ts +24 -24
  76. package/dist/release/current/state.d.ts +28 -56
  77. package/dist/release/current/state.js +1 -6
  78. package/dist/release/digest.d.ts +9 -18
  79. package/dist/release/digest.js +7 -13
  80. package/dist/release/hash.d.ts +7 -16
  81. package/dist/release/hash.js +2 -6
  82. package/dist/release/head.d.ts +10 -57
  83. package/dist/release/head.js +3 -14
  84. package/dist/release/identity.d.ts +3 -3
  85. package/dist/release/items.d.ts +3 -3
  86. package/dist/release/items.js +1 -1
  87. package/dist/release/lifecycle.d.ts +18 -18
  88. package/dist/release/policy.d.ts +3 -4
  89. package/dist/release/policy.js +2 -11
  90. package/dist/release/result/digest.d.ts +11 -31
  91. package/dist/release/result/digest.js +5 -11
  92. package/dist/release/rollback/digest.d.ts +11 -35
  93. package/dist/release/rollback/digest.js +7 -13
  94. package/dist/release/rollback/spec.d.ts +30 -792
  95. package/dist/release/rollback/spec.js +1 -4
  96. package/dist/release/route/digest.d.ts +7 -16
  97. package/dist/release/route/digest.js +7 -13
  98. package/dist/release/route/verify.d.ts +1 -1
  99. package/dist/release/route/verify.js +1 -1
  100. package/dist/release/snapshot/data.d.ts +599 -249
  101. package/dist/release/snapshot/data.js +11 -28
  102. package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
  103. package/dist/release/snapshot/evidence/assessment.js +44 -0
  104. package/dist/release/snapshot/evidence/program.d.ts +1 -1
  105. package/dist/release/snapshot/evidence/quran.d.ts +1 -1
  106. package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
  107. package/dist/release/snapshot/evidence.d.ts +19 -19
  108. package/dist/release/snapshot/evidence.js +2 -2
  109. package/dist/release/snapshot/scope.d.ts +5 -5
  110. package/dist/release/snapshot/scope.js +1 -1
  111. package/dist/release/snapshot/spec.d.ts +15 -15
  112. package/dist/release/snapshot/spec.js +8 -8
  113. package/dist/release/snapshot/verify.d.ts +1278 -268
  114. package/dist/release/snapshot/verify.js +8 -5
  115. package/dist/release/spec.d.ts +33 -33
  116. package/dist/release/verify.d.ts +7 -7
  117. package/dist/renderer/compatibility.d.ts +1 -1
  118. package/dist/renderer/component.js +1 -1
  119. package/dist/renderer/contract.d.ts +0 -8
  120. package/dist/renderer/contract.js +0 -3
  121. package/dist/renderer/manifest.d.ts +3 -3
  122. package/dist/renderer/manifest.js +2 -2
  123. package/dist/runtime/spec.d.ts +38 -38
  124. package/dist/runtime/spec.js +4 -5
  125. package/dist/runtime/verify.d.ts +42 -42
  126. package/dist/signature/key.d.ts +0 -2
  127. package/dist/signature/key.js +37 -88
  128. package/dist/signature/spec.d.ts +5 -5
  129. package/dist/signature/spec.js +0 -1
  130. package/dist/signature/verify.js +31 -46
  131. package/dist/transport/batch.d.ts +6 -244
  132. package/dist/transport/failure.d.ts +6 -20
  133. package/dist/transport/failure.js +0 -10
  134. package/dist/transport/group.d.ts +1969 -1369
  135. package/dist/transport/group.js +0 -2
  136. package/dist/transport/request.d.ts +10691 -5086
  137. package/dist/transport/request.js +0 -3
  138. package/dist/transport/response.d.ts +219 -1442
  139. package/dist/transport/response.js +0 -4
  140. package/dist/transport/snapshot.d.ts +1187 -487
  141. package/dist/tree.js +1 -1
  142. package/package.json +188 -296
  143. package/dist/projection/question.d.ts +0 -1067
  144. package/dist/projection/question.js +0 -121
  145. package/dist/question/identity.d.ts +0 -175
  146. package/dist/question/identity.js +0 -207
  147. package/dist/question/item.d.ts +0 -450
  148. package/dist/question/item.js +0 -174
  149. package/dist/question/label.d.ts +0 -3
  150. package/dist/question/label.js +0 -3
  151. package/dist/question/points.d.ts +0 -18
  152. package/dist/question/points.js +0 -22
  153. package/dist/question/response.d.ts +0 -289
  154. package/dist/question/response.js +0 -167
  155. package/dist/question/rubric.d.ts +0 -234
  156. package/dist/question/rubric.js +0 -186
  157. package/dist/release/current/runtime.d.ts +0 -4
  158. package/dist/release/current/runtime.js +0 -15
  159. package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
  160. package/dist/release/snapshot/evidence/tryout.js +0 -91
  161. package/dist/runtime/protected/limits.d.ts +0 -10
  162. package/dist/runtime/protected/limits.js +0 -16
  163. package/dist/runtime/protected/spec.d.ts +0 -310
  164. package/dist/runtime/protected/spec.js +0 -80
  165. package/dist/runtime/protected/verify.d.ts +0 -83
  166. package/dist/runtime/protected/verify.js +0 -70
  167. package/dist/transport/runtime.d.ts +0 -77
  168. package/dist/transport/runtime.js +0 -33
  169. package/dist/tryout/canonical.d.ts +0 -12
  170. package/dist/tryout/canonical.js +0 -7
  171. package/dist/tryout/catalog.d.ts +0 -396
  172. package/dist/tryout/catalog.js +0 -155
  173. package/dist/tryout/closure/accounting.d.ts +0 -20
  174. package/dist/tryout/closure/accounting.js +0 -70
  175. package/dist/tryout/closure/locale.d.ts +0 -14
  176. package/dist/tryout/closure/locale.js +0 -113
  177. package/dist/tryout/closure/placement.d.ts +0 -5
  178. package/dist/tryout/closure/placement.js +0 -32
  179. package/dist/tryout/digest.d.ts +0 -34
  180. package/dist/tryout/digest.js +0 -57
  181. package/dist/tryout/hash/catalog.d.ts +0 -364
  182. package/dist/tryout/hash/catalog.js +0 -209
  183. package/dist/tryout/hash/content.d.ts +0 -215
  184. package/dist/tryout/hash/content.js +0 -75
  185. package/dist/tryout/hash/placement.d.ts +0 -242
  186. package/dist/tryout/hash/placement.js +0 -56
  187. package/dist/tryout/identity.d.ts +0 -12
  188. package/dist/tryout/identity.js +0 -47
  189. package/dist/tryout/key.d.ts +0 -4
  190. package/dist/tryout/key.js +0 -8
  191. package/dist/tryout/language.d.ts +0 -24
  192. package/dist/tryout/language.js +0 -30
  193. package/dist/tryout/placement.d.ts +0 -331
  194. package/dist/tryout/placement.js +0 -96
  195. package/dist/tryout/runtime/canonical.d.ts +0 -8
  196. package/dist/tryout/runtime/canonical.js +0 -34
  197. package/dist/tryout/runtime/hash.d.ts +0 -34
  198. package/dist/tryout/runtime/hash.js +0 -13
  199. package/dist/tryout/runtime/source.d.ts +0 -44
  200. package/dist/tryout/runtime/source.js +0 -47
  201. package/dist/tryout/runtime/spec.d.ts +0 -58
  202. package/dist/tryout/runtime/spec.js +0 -21
  203. package/dist/tryout/runtime/verify.d.ts +0 -69
  204. package/dist/tryout/runtime/verify.js +0 -67
  205. package/dist/tryout/scoring.d.ts +0 -148
  206. package/dist/tryout/scoring.js +0 -98
  207. package/dist/tryout/snapshot/canonical.d.ts +0 -7
  208. package/dist/tryout/snapshot/canonical.js +0 -18
  209. package/dist/tryout/snapshot/hash.d.ts +0 -49
  210. package/dist/tryout/snapshot/hash.js +0 -22
  211. package/dist/tryout/snapshot/spec.d.ts +0 -46
  212. package/dist/tryout/snapshot/spec.js +0 -30
  213. package/dist/tryout/spec.d.ts +0 -41
  214. package/dist/tryout/spec.js +0 -46
@@ -1,186 +0,0 @@
1
- import { Array as Arr, Schema, Struct } from "effect";
2
- import { ActiveAppLocaleCodeSchema } from "#contracts/locale";
3
- import { canonicalQuestionAnswerKey, canonicalQuestionAnswerKeyStructure, QuestionAnswerKeySchema, } from "#contracts/question/answer";
4
- import { QuestionResponseLabelSchema } from "#contracts/question/label";
5
- const CRITERION_KEY_PATTERN = /^criterion-[1-9]\d*$/u;
6
- const LEVEL_KEY_PATTERN = /^level-[1-9]\d*$/u;
7
- const PositiveOrderSchema = Schema.Int.check(Schema.isGreaterThan(0));
8
- const LevelPointsSchema = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
9
- /**
10
- * One learner-facing rubric label written for every active app locale. A
11
- * learner reads it after the attempt in the app locale, even when the prompt
12
- * is delivered in a fixed assessed language, so every rubric copy carries all
13
- * locales.
14
- */
15
- export const QuestionRubricLabelSchema = Schema.Record(ActiveAppLocaleCodeSchema, QuestionResponseLabelSchema);
16
- /**
17
- * Checks one criterion scale: two or more levels whose points strictly
18
- * ascend. A final-answer criterion has exactly two levels and its lower level
19
- * is worth zero, because a wrong result earns nothing. The criterion holds the
20
- * scale facts shared by authored, frozen, and label-free rubric criteria.
21
- */
22
- function hasOrderedScale(criterion) {
23
- let previous = -1;
24
- for (const { points } of criterion.levels) {
25
- if (points <= previous) {
26
- return false;
27
- }
28
- previous = points;
29
- }
30
- if (criterion.finalAnswer === undefined) {
31
- return criterion.levels.length >= 2;
32
- }
33
- const [lower] = criterion.levels;
34
- return criterion.levels.length === 2 && lower?.points === 0;
35
- }
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
- /**
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
- */
41
- function hasCanonicalCriteria(criteria) {
42
- return (criteria.length > 0 &&
43
- Arr.every(criteria, ({ criterionKey, levels, order }, index) => order === index + 1 &&
44
- criterionKey === `criterion-${order}` &&
45
- Arr.every(levels, (level, levelIndex) => level.order === levelIndex + 1 &&
46
- level.levelKey === `level-${level.order}`)));
47
- }
48
- const CANONICAL_CRITERIA_MESSAGE = "Rubric criteria and levels require canonical keys and order.";
49
- const LevelScaleFields = {
50
- levelKey: Schema.String.check(Schema.isPattern(LEVEL_KEY_PATTERN)),
51
- order: PositiveOrderSchema,
52
- points: LevelPointsSchema,
53
- };
54
- const CriterionScaleFields = {
55
- criterionKey: Schema.String.check(Schema.isPattern(CRITERION_KEY_PATTERN)),
56
- finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
57
- order: PositiveOrderSchema,
58
- };
59
- /** One label-free rubric criterion with its ordered level scale. */
60
- const QuestionRubricCriterionScaleSchema = Schema.Struct({
61
- ...CriterionScaleFields,
62
- levels: Schema.Array(Schema.Struct(LevelScaleFields)),
63
- }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
64
- /**
65
- * Locale-neutral rubric scale that grading reads: ordered criteria with
66
- * stable keys, ordered levels with points, and optional final-answer keys. It
67
- * ignores labels, so content written in one language, such as a School
68
- * tenant's rubric, validates its scale here and owns its own labels. A judged
69
- * criterion maps onto one Effect `Decision.rate` decision keyed by
70
- * `criterionKey`: its level keys are the rating scale from lowest to highest,
71
- * a rating answer's probabilities are keyed by them, and the chosen level's
72
- * points are earned. A final-answer criterion is graded with
73
- * `matchesAnswerKey` instead: a match earns its upper level and any other
74
- * answer its zero level. A blank answer earns zero on every criterion.
75
- */
76
- export const QuestionRubricScaleSchema = Schema.Struct({
77
- criteria: Schema.Array(QuestionRubricCriterionScaleSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
78
- message: CANONICAL_CRITERIA_MESSAGE,
79
- })),
80
- kind: Schema.Literal("rubric"),
81
- });
82
- /** One frozen scoring level of a rubric criterion. */
83
- const QuestionRubricLevelSchema = Schema.Struct({
84
- ...LevelScaleFields,
85
- label: QuestionRubricLabelSchema,
86
- });
87
- /** One frozen rubric criterion with its ordered level scale. */
88
- const QuestionRubricCriterionSchema = Schema.Struct({
89
- ...CriterionScaleFields,
90
- label: QuestionRubricLabelSchema,
91
- levels: Schema.Array(QuestionRubricLevelSchema),
92
- }).check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
93
- /**
94
- * Frozen open-response rubric of Aksara content: the rubric scale with every
95
- * criterion and level labeled in every active app locale.
96
- */
97
- export const QuestionRubricResponseSchema = Schema.Struct({
98
- criteria: Schema.Array(QuestionRubricCriterionSchema).check(Schema.makeFilter(hasCanonicalCriteria, {
99
- message: CANONICAL_CRITERIA_MESSAGE,
100
- })),
101
- kind: Schema.Literal("rubric"),
102
- });
103
- /** One authored scoring level before its stable key is derived. */
104
- const QuestionRubricLevelSourceSchema = Schema.Struct({
105
- label: QuestionRubricLabelSchema,
106
- points: LevelPointsSchema,
107
- }).mapFields(Struct.map(Schema.mutableKey));
108
- /** One authored criterion before its stable key and order are derived. */
109
- const QuestionRubricCriterionSourceSchema = Schema.Struct({
110
- finalAnswer: Schema.optionalKey(QuestionAnswerKeySchema),
111
- label: QuestionRubricLabelSchema,
112
- levels: Schema.Array(QuestionRubricLevelSourceSchema).pipe(Schema.mutable),
113
- })
114
- .mapFields(Struct.map(Schema.mutableKey))
115
- .check(Schema.makeFilter(hasOrderedScale, { message: ORDERED_SCALE_MESSAGE }));
116
- /** One rubric authored in array order without duplicated runtime keys. */
117
- export const QuestionRubricResponseSourceSchema = Schema.Struct({
118
- criteria: Schema.Array(QuestionRubricCriterionSourceSchema).pipe(Schema.mutable, Schema.check(Schema.makeFilter((criteria) => criteria.length > 0, {
119
- message: "Expected at least one rubric criterion.",
120
- }))),
121
- kind: Schema.Literal("rubric"),
122
- }).mapFields(Struct.map(Schema.mutableKey));
123
- /** Derives stable criterion and level keys once from authored array order. */
124
- export function freezeQuestionRubric(source) {
125
- return QuestionRubricResponseSchema.make({
126
- criteria: Arr.map(source.criteria, (criterion, index) => ({
127
- criterionKey: `criterion-${index + 1}`,
128
- ...(criterion.finalAnswer === undefined
129
- ? {}
130
- : { finalAnswer: criterion.finalAnswer }),
131
- label: criterion.label,
132
- levels: Arr.map(criterion.levels, ({ label, points }, levelIndex) => ({
133
- label,
134
- levelKey: `level-${levelIndex + 1}`,
135
- order: levelIndex + 1,
136
- points,
137
- })),
138
- order: index + 1,
139
- })),
140
- kind: "rubric",
141
- });
142
- }
143
- /** Returns one label with every active app locale in alphabetical order. */
144
- function canonicalRubricLabel(label) {
145
- return { de: label.de, en: label.en, id: label.id };
146
- }
147
- /** Serializes criteria in stable field order with one answer-key encoding. */
148
- function canonicalRubricCriteria(rubric, canonicalKey) {
149
- return Arr.map(rubric.criteria, ({ criterionKey, finalAnswer, label, levels, order }) => ({
150
- criterionKey,
151
- ...(finalAnswer === undefined
152
- ? {}
153
- : { finalAnswer: canonicalKey(finalAnswer) }),
154
- label: canonicalRubricLabel(label),
155
- levels: Arr.map(levels, (level) => ({
156
- label: canonicalRubricLabel(level.label),
157
- levelKey: level.levelKey,
158
- order: level.order,
159
- points: level.points,
160
- })),
161
- order,
162
- }));
163
- }
164
- /**
165
- * Returns the rubric facts shared by every delivery language: keys, order,
166
- * points, labels in every active app locale, and final-answer rules without
167
- * accepted text written in one delivery language.
168
- */
169
- export function canonicalQuestionRubricStructure(rubric) {
170
- return {
171
- criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKeyStructure),
172
- kind: rubric.kind,
173
- };
174
- }
175
- /** Returns every rubric fact, accepted final-answer text included. */
176
- export function canonicalQuestionRubric(rubric) {
177
- return {
178
- criteria: canonicalRubricCriteria(rubric, canonicalQuestionAnswerKey),
179
- kind: rubric.kind,
180
- };
181
- }
182
- /** Returns the rubric total: the sum of every criterion's highest level. */
183
- export function questionRubricPoints(rubric) {
184
- return Arr.reduce(rubric.criteria, 0, (total, { levels }) => total +
185
- Arr.reduce(levels, 0, (highest, { points }) => Math.max(highest, points)));
186
- }
@@ -1,4 +0,0 @@
1
- import type { ActiveContentRelease } from "#contracts/release/current/evidence";
2
- import type { SignedTryoutRuntimeBundle } from "#contracts/tryout/runtime/spec";
3
- /** Accepts only the permanent runtime bound to the active try-out snapshot. */
4
- export declare function hasCurrentTryoutRuntimeBundle(active: ActiveContentRelease | null, bundle: SignedTryoutRuntimeBundle | null): boolean;
@@ -1,15 +0,0 @@
1
- /** Accepts only the permanent runtime bound to the active try-out snapshot. */
2
- export function hasCurrentTryoutRuntimeBundle(active, bundle) {
3
- if (active === null) {
4
- return bundle === null;
5
- }
6
- const snapshotId = active.release.manifest.snapshots.tryout.resultSnapshotId;
7
- if (snapshotId === null || snapshotId === undefined) {
8
- return bundle === null;
9
- }
10
- if (bundle === null) {
11
- return false;
12
- }
13
- return (snapshotId === bundle.payload.snapshot.snapshotId &&
14
- active.rendererManifest.hash === bundle.payload.rendererManifestHash);
15
- }
@@ -1,22 +0,0 @@
1
- import { Effect } from "effect";
2
- import { type SnapshotRowSource } from "#contracts/release/snapshot/evidence/requirement";
3
- /** Verifies all try-out hashes, digests, counts, routes, and identity. */
4
- export declare const verifyTryoutSnapshotRows: <E, R>(snapshot: {
5
- readonly family: "tryout";
6
- readonly manifest: {
7
- readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
8
- readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
9
- readonly counts: {
10
- readonly country: number;
11
- readonly exam: number;
12
- readonly section: number;
13
- readonly set: number;
14
- readonly track: number;
15
- };
16
- readonly placementCount: number;
17
- readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
18
- readonly routeCount: number;
19
- readonly format: "localized-tryout-snapshot";
20
- readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
21
- };
22
- }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("effect/PlatformError").PlatformError | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../../tryout/canonical.js").TryoutCanonicalHashError | import("../../../tryout/closure/accounting.js").TryoutClosureError | import("../../../tryout/digest.js").TryoutDigestError | import("../../../tryout/scoring.js").TryoutScoringError, R>;
@@ -1,91 +0,0 @@
1
- import { Effect, Result, Schema, Stream } from "effect";
2
- import { requireSnapshotEvidence, } from "#contracts/release/snapshot/evidence/requirement";
3
- import { verifyTryoutLocaleClosure } from "#contracts/tryout/closure/locale";
4
- import { digestTryoutCatalog } from "#contracts/tryout/hash/catalog";
5
- import { digestTryoutPlacements } from "#contracts/tryout/hash/placement";
6
- import { makeTryoutSnapshot } from "#contracts/tryout/snapshot/hash";
7
- import { TryoutCatalogCountsSchema } from "#contracts/tryout/snapshot/spec";
8
- const TryoutCatalogEvidenceSchema = Schema.Struct({
9
- counts: TryoutCatalogCountsSchema,
10
- routeCount: Schema.Finite,
11
- });
12
- /** Selects current hierarchy rows while preserving source failures. */
13
- function currentTryoutCatalog(rows) {
14
- return rows.pipe(Stream.filterMap((row) => row.family === "tryout" && row.rowKind === "catalog"
15
- ? Result.succeed(row.record)
16
- : Result.failVoid));
17
- }
18
- /** Selects current placements while preserving source failures. */
19
- function currentPlacements(rows) {
20
- return rows.pipe(Stream.filterMap((row) => row.family === "tryout" && row.rowKind === "placement"
21
- ? Result.succeed(row.record)
22
- : Result.failVoid));
23
- }
24
- /** Derives signed per-kind and public-route counts from catalog rows. */
25
- function summarizeTryoutCatalog(records) {
26
- const initial = {
27
- counts: { country: 0, exam: 0, section: 0, set: 0, track: 0 },
28
- routeCount: 0,
29
- };
30
- return records.pipe(Stream.runFold(() => initial, (state, { row }) => ({
31
- counts: {
32
- ...state.counts,
33
- [row.kind]: state.counts[row.kind] + 1,
34
- },
35
- routeCount: state.routeCount + (row.publicPath === undefined ? 0 : 1),
36
- })));
37
- }
38
- /** Verifies all try-out hashes, digests, counts, routes, and identity. */
39
- export const verifyTryoutSnapshotRows = Effect.fn("AksaraContracts.verifyTryoutSnapshotRows")(function* (snapshot, rows) {
40
- const [placementDigest, catalogDigest, catalogEvidence] = yield* Effect.all([
41
- rows.pipe(currentPlacements, digestTryoutPlacements),
42
- rows.pipe(currentTryoutCatalog, digestTryoutCatalog),
43
- rows.pipe(currentTryoutCatalog, summarizeTryoutCatalog),
44
- ]);
45
- yield* verifyTryoutLocaleClosure({
46
- activeAppLocales: snapshot.manifest.activeAppLocales,
47
- catalog: currentTryoutCatalog(rows),
48
- placements: currentPlacements(rows),
49
- });
50
- yield* requireSnapshotEvidence({
51
- actual: catalogDigest.digest,
52
- expected: snapshot.manifest.catalogDigest,
53
- family: "tryout",
54
- field: "catalogDigest",
55
- });
56
- yield* requireSnapshotEvidence({
57
- actual: placementDigest.count,
58
- expected: snapshot.manifest.placementCount,
59
- family: "tryout",
60
- field: "placementCount",
61
- });
62
- yield* requireSnapshotEvidence({
63
- actual: placementDigest.digest,
64
- expected: snapshot.manifest.placementDigest,
65
- family: "tryout",
66
- field: "placementDigest",
67
- });
68
- for (const kind of ["country", "exam", "section", "set", "track"]) {
69
- yield* requireSnapshotEvidence({
70
- actual: catalogEvidence.counts[kind],
71
- expected: snapshot.manifest.counts[kind],
72
- family: "tryout",
73
- field: `${kind}Count`,
74
- });
75
- }
76
- yield* requireSnapshotEvidence({
77
- actual: catalogEvidence.routeCount,
78
- expected: snapshot.manifest.routeCount,
79
- family: "tryout",
80
- field: "routeCount",
81
- });
82
- const { format: _format, snapshotId, ...facts } = snapshot.manifest;
83
- const actualId = (yield* makeTryoutSnapshot(facts)).snapshotId;
84
- yield* requireSnapshotEvidence({
85
- actual: actualId,
86
- expected: snapshotId,
87
- family: "tryout",
88
- field: "snapshotId",
89
- });
90
- return catalogDigest.count + placementDigest.count;
91
- });
@@ -1,10 +0,0 @@
1
- /** Maximum protected selectors accepted in one retained-snapshot read. */
2
- export declare const MAX_PROTECTED_RUNTIME_SELECTORS = 64;
3
- /** Maximum UTF-8 bytes accepted by the protected batch endpoint. */
4
- export declare const MAX_PROTECTED_RUNTIME_REQUEST_BYTES: number;
5
- /** Maximum UTF-8 bytes returned by the protected batch endpoint. */
6
- export declare const MAX_PROTECTED_RUNTIME_RESPONSE_BYTES: number;
7
- /** Measures the exact JSON bytes written by the protected HTTP response. */
8
- export declare function protectedRuntimeResponseBytes(response: object): number;
9
- /** Keeps every found result inside the protected response wire ceiling. */
10
- export declare function hasBoundedProtectedRuntimeResponse(response: object): boolean;
@@ -1,16 +0,0 @@
1
- import { encodeJsonText } from "#contracts/text/json";
2
- /** Maximum protected selectors accepted in one retained-snapshot read. */
3
- export const MAX_PROTECTED_RUNTIME_SELECTORS = 64;
4
- /** Maximum UTF-8 bytes accepted by the protected batch endpoint. */
5
- export const MAX_PROTECTED_RUNTIME_REQUEST_BYTES = 64 * 1024;
6
- /** Maximum UTF-8 bytes returned by the protected batch endpoint. */
7
- export const MAX_PROTECTED_RUNTIME_RESPONSE_BYTES = 4 * 1024 * 1024;
8
- /** Measures the exact JSON bytes written by the protected HTTP response. */
9
- export function protectedRuntimeResponseBytes(response) {
10
- return new TextEncoder().encode(encodeJsonText(response)).byteLength;
11
- }
12
- /** Keeps every found result inside the protected response wire ceiling. */
13
- export function hasBoundedProtectedRuntimeResponse(response) {
14
- return (protectedRuntimeResponseBytes(response) <=
15
- MAX_PROTECTED_RUNTIME_RESPONSE_BYTES);
16
- }