@nakafa/aksara-contracts 0.49.0 → 0.51.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.
- package/dist/artifact/integrity.d.ts +15 -2
- package/dist/artifact/integrity.js +3 -15
- package/dist/artifact/limits.js +3 -4
- package/dist/artifact/source.js +4 -8
- package/dist/artifact/spec.d.ts +30 -10
- package/dist/assessment/hash.d.ts +251 -213
- package/dist/assessment/item.d.ts +44 -7
- package/dist/assessment/item.js +19 -9
- package/dist/assessment/joint.d.ts +62 -0
- package/dist/assessment/joint.js +85 -0
- package/dist/assessment/paper.d.ts +22 -2
- package/dist/assessment/profile.d.ts +6 -0
- package/dist/assessment/scoring.d.ts +55 -2
- package/dist/assessment/scoring.js +63 -8
- package/dist/assessment/stimulus.d.ts +3 -3
- package/dist/assessment/stimulus.js +2 -2
- package/dist/errors.d.ts +3 -1
- package/dist/graph/family.d.ts +6 -2
- package/dist/graph/identity.d.ts +3 -1
- package/dist/hash/digest.d.ts +10 -0
- package/dist/hash/digest.js +40 -0
- package/dist/hash/stream.d.ts +12 -0
- package/dist/hash/stream.js +27 -0
- package/dist/hash/text.d.ts +3 -1
- package/dist/hash/text.js +2 -15
- package/dist/locale.d.ts +9 -0
- package/dist/locale.js +25 -1
- package/dist/preview/auth.d.ts +4 -2
- package/dist/preview/auth.js +26 -12
- package/dist/program/snapshot/digest.d.ts +3 -1
- package/dist/program/snapshot/digest.js +14 -22
- package/dist/program/snapshot/hash.d.ts +6 -2
- package/dist/program/snapshot/hash.js +10 -21
- package/dist/projection/digest.d.ts +11 -9
- package/dist/projection/digest.js +23 -32
- package/dist/projection/hash.d.ts +222 -2
- package/dist/projection/hash.js +6 -8
- package/dist/projection/verify.d.ts +16 -6
- package/dist/question/item.d.ts +3 -1
- package/dist/question/item.js +3 -1
- package/dist/quran/notes.d.ts +3 -1
- package/dist/quran/provenance.d.ts +6 -2
- package/dist/quran/provenance.js +8 -15
- package/dist/quran/snapshot/digest.d.ts +9 -5
- package/dist/quran/snapshot/digest.js +33 -41
- package/dist/quran/snapshot/hash.d.ts +3 -1
- package/dist/quran/snapshot/hash.js +9 -15
- package/dist/quran/snapshot/row/hash.d.ts +3 -1
- package/dist/quran/snapshot/row/hash.js +2 -8
- package/dist/release/digest.d.ts +10 -8
- package/dist/release/digest.js +22 -31
- package/dist/release/hash.d.ts +3 -1
- package/dist/release/hash.js +3 -8
- package/dist/release/items.d.ts +25 -9
- package/dist/release/items.js +12 -3
- package/dist/release/policy.d.ts +3 -1
- package/dist/release/result/digest.d.ts +23 -13
- package/dist/release/result/digest.js +20 -29
- package/dist/release/rollback/digest.d.ts +16 -10
- package/dist/release/rollback/digest.js +25 -32
- package/dist/release/route/digest.d.ts +10 -8
- package/dist/release/route/digest.js +22 -31
- package/dist/release/route/verify.d.ts +16 -6
- package/dist/release/route/verify.js +8 -2
- package/dist/release/snapshot/evidence/requirement.d.ts +3 -1
- package/dist/release/snapshot/evidence/tryout.d.ts +1 -1
- package/dist/release/snapshot/evidence/tryout.js +1 -1
- package/dist/release/snapshot/evidence.d.ts +1 -1
- package/dist/release/snapshot/verify.d.ts +19 -7
- package/dist/release/snapshot/verify.js +20 -18
- package/dist/release/verify.d.ts +9 -3
- package/dist/renderer/compatibility.d.ts +6 -2
- package/dist/renderer/compatibility.js +3 -1
- package/dist/renderer/contract.d.ts +9 -3
- package/dist/renderer/contract.js +3 -1
- package/dist/runtime/error.d.ts +3 -1
- package/dist/runtime/protected/verify.d.ts +1 -1
- package/dist/runtime/verify.d.ts +2 -2
- package/dist/runtime/verify.js +2 -1
- package/dist/signature/key.d.ts +21 -0
- package/dist/signature/key.js +104 -0
- package/dist/signature/spec.d.ts +18 -6
- package/dist/signature/spec.js +16 -4
- package/dist/transport/request.d.ts +728 -728
- package/dist/transport/response.d.ts +26 -26
- package/dist/tryout/canonical.d.ts +11 -1
- package/dist/tryout/canonical.js +6 -10
- package/dist/tryout/closure/accounting.d.ts +3 -1
- package/dist/tryout/digest.d.ts +12 -6
- package/dist/tryout/digest.js +21 -14
- package/dist/tryout/hash/catalog.d.ts +228 -3
- package/dist/tryout/hash/catalog.js +5 -7
- package/dist/tryout/hash/content.d.ts +113 -2
- package/dist/tryout/hash/content.js +10 -8
- package/dist/tryout/hash/placement.d.ts +236 -5
- package/dist/tryout/hash/placement.js +7 -8
- package/dist/tryout/runtime/hash.d.ts +3 -1
- package/dist/tryout/runtime/hash.js +3 -1
- package/dist/tryout/runtime/source.d.ts +3 -1
- package/dist/tryout/runtime/verify.d.ts +13 -5
- package/dist/tryout/runtime/verify.js +1 -1
- package/dist/tryout/scoring.d.ts +3 -1
- package/dist/tryout/snapshot/hash.d.ts +45 -4
- package/dist/tryout/snapshot/hash.js +9 -7
- package/package.json +22 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Hex } from "effect/encoding";
|
|
3
3
|
import { withPublicationDates } from "#contracts/date";
|
|
4
|
+
import { digestSha256 } from "#contracts/hash/digest";
|
|
4
5
|
import { AppLocaleSchema, ArtifactLocaleSchema, DeliveryLanguageSchema, } from "#contracts/locale";
|
|
5
6
|
import { QuestionKeySchema } from "#contracts/question/identity";
|
|
6
7
|
import { canonicalQuestionBlueprint, QuestionBlueprintSchema, } from "#contracts/question/item";
|
|
@@ -64,10 +65,11 @@ export function canonicalizeTryoutContent(input) {
|
|
|
64
65
|
: { stimulusKey: input.stimulusKey }),
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
/**
|
|
68
|
-
export
|
|
69
|
-
const digest = createHash("sha256")
|
|
70
|
-
.update(canonicalizeTryoutContent(input), "utf8")
|
|
71
|
-
.digest("hex");
|
|
72
|
-
return TryoutContentHashSchema.make(digest);
|
|
68
|
+
/** Web Crypto could not hash one canonical try-out content identity. */
|
|
69
|
+
export class TryoutContentHashError extends Schema.TaggedError()("TryoutContentHashError", {}) {
|
|
73
70
|
}
|
|
71
|
+
/** Hashes one complete current question pair through its canonical identity. */
|
|
72
|
+
export const hashTryoutContent = Effect.fn("AksaraContracts.hashTryoutContent")(function* (input) {
|
|
73
|
+
const digest = yield* digestSha256(new TextEncoder().encode(canonicalizeTryoutContent(input))).pipe(Effect.mapError(() => new TryoutContentHashError()));
|
|
74
|
+
return TryoutContentHashSchema.make(Hex.encode(digest));
|
|
75
|
+
});
|
|
@@ -1,11 +1,242 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { Effect, type Stream } from "effect";
|
|
2
2
|
import { type TryoutPlacement, type TryoutPlacementRecord } from "#contracts/tryout/placement";
|
|
3
3
|
/** Serializes one artifact-bound placement with stable field order. */
|
|
4
4
|
export declare function canonicalizeTryoutPlacement(row: TryoutPlacement): string;
|
|
5
5
|
/** Creates one immutable authenticated placement record. */
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare const makeTryoutPlacementRecord: (row: {
|
|
7
|
+
readonly answerArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
8
|
+
readonly answerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
9
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
10
|
+
readonly blueprint?: {
|
|
11
|
+
readonly cognitiveLevel: string;
|
|
12
|
+
readonly contentDomain: string;
|
|
13
|
+
readonly topic: string;
|
|
14
|
+
};
|
|
15
|
+
readonly countryKey: string;
|
|
16
|
+
readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
17
|
+
readonly examKey: string;
|
|
18
|
+
readonly languagePolicy: {
|
|
19
|
+
readonly kind: "app-locale";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "fixed";
|
|
22
|
+
readonly language: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
23
|
+
};
|
|
24
|
+
readonly points?: number;
|
|
25
|
+
readonly questionArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
26
|
+
readonly questionContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
27
|
+
readonly questionOrder: number;
|
|
28
|
+
readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
29
|
+
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
30
|
+
readonly response: {
|
|
31
|
+
readonly kind: "single-choice";
|
|
32
|
+
readonly options: readonly {
|
|
33
|
+
readonly isCorrect: boolean;
|
|
34
|
+
readonly label: string;
|
|
35
|
+
readonly optionKey: string;
|
|
36
|
+
readonly order: number;
|
|
37
|
+
}[];
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "multiple-choice";
|
|
40
|
+
readonly options: readonly {
|
|
41
|
+
readonly isCorrect: boolean;
|
|
42
|
+
readonly label: string;
|
|
43
|
+
readonly optionKey: string;
|
|
44
|
+
readonly order: number;
|
|
45
|
+
}[];
|
|
46
|
+
} | {
|
|
47
|
+
readonly categories: readonly {
|
|
48
|
+
readonly categoryKey: string;
|
|
49
|
+
readonly label: string;
|
|
50
|
+
readonly order: number;
|
|
51
|
+
}[];
|
|
52
|
+
readonly kind: "category";
|
|
53
|
+
readonly statements: readonly {
|
|
54
|
+
readonly correctCategoryKey: string;
|
|
55
|
+
readonly label: string;
|
|
56
|
+
readonly order: number;
|
|
57
|
+
readonly statementKey: string;
|
|
58
|
+
}[];
|
|
59
|
+
} | {
|
|
60
|
+
readonly criteria: readonly {
|
|
61
|
+
readonly criterionKey: string;
|
|
62
|
+
readonly finalAnswer?: {
|
|
63
|
+
readonly acceptsFractions: boolean;
|
|
64
|
+
readonly kind: "number";
|
|
65
|
+
readonly tolerance?: {
|
|
66
|
+
readonly kind: "absolute" | "relative";
|
|
67
|
+
readonly value: string;
|
|
68
|
+
};
|
|
69
|
+
readonly value: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
72
|
+
readonly collapseWhitespace: boolean;
|
|
73
|
+
readonly ignoreCase: boolean;
|
|
74
|
+
readonly kind: "text";
|
|
75
|
+
};
|
|
76
|
+
readonly order: number;
|
|
77
|
+
readonly label: {
|
|
78
|
+
readonly de: string;
|
|
79
|
+
readonly en: string;
|
|
80
|
+
readonly id: string;
|
|
81
|
+
};
|
|
82
|
+
readonly levels: readonly {
|
|
83
|
+
readonly levelKey: string;
|
|
84
|
+
readonly order: number;
|
|
85
|
+
readonly points: number;
|
|
86
|
+
readonly label: {
|
|
87
|
+
readonly de: string;
|
|
88
|
+
readonly en: string;
|
|
89
|
+
readonly id: string;
|
|
90
|
+
};
|
|
91
|
+
}[];
|
|
92
|
+
}[];
|
|
93
|
+
readonly kind: "rubric";
|
|
94
|
+
} | {
|
|
95
|
+
readonly key: {
|
|
96
|
+
readonly acceptsFractions: boolean;
|
|
97
|
+
readonly kind: "number";
|
|
98
|
+
readonly tolerance?: {
|
|
99
|
+
readonly kind: "absolute" | "relative";
|
|
100
|
+
readonly value: string;
|
|
101
|
+
};
|
|
102
|
+
readonly value: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
105
|
+
readonly collapseWhitespace: boolean;
|
|
106
|
+
readonly ignoreCase: boolean;
|
|
107
|
+
readonly kind: "text";
|
|
108
|
+
};
|
|
109
|
+
readonly kind: "short-answer";
|
|
110
|
+
};
|
|
111
|
+
readonly scope: "server";
|
|
112
|
+
readonly sectionKey: string;
|
|
113
|
+
readonly setKey: string;
|
|
114
|
+
readonly sourceRevision: string;
|
|
115
|
+
readonly stimulusKey?: string;
|
|
116
|
+
readonly trackKey: string;
|
|
117
|
+
readonly answerArtifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
118
|
+
readonly contentHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraTryoutContentHash">;
|
|
119
|
+
readonly questionArtifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
120
|
+
}) => Effect.Effect<{
|
|
121
|
+
readonly row: {
|
|
122
|
+
readonly answerArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
123
|
+
readonly answerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
124
|
+
readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
|
|
125
|
+
readonly blueprint?: {
|
|
126
|
+
readonly cognitiveLevel: string;
|
|
127
|
+
readonly contentDomain: string;
|
|
128
|
+
readonly topic: string;
|
|
129
|
+
};
|
|
130
|
+
readonly countryKey: string;
|
|
131
|
+
readonly deliveryLanguage: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
132
|
+
readonly examKey: string;
|
|
133
|
+
readonly languagePolicy: {
|
|
134
|
+
readonly kind: "app-locale";
|
|
135
|
+
} | {
|
|
136
|
+
readonly kind: "fixed";
|
|
137
|
+
readonly language: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraDeliveryLanguage">;
|
|
138
|
+
};
|
|
139
|
+
readonly points?: number;
|
|
140
|
+
readonly questionArtifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
141
|
+
readonly questionContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
|
|
142
|
+
readonly questionOrder: number;
|
|
143
|
+
readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
|
|
144
|
+
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
145
|
+
readonly response: {
|
|
146
|
+
readonly kind: "single-choice";
|
|
147
|
+
readonly options: readonly {
|
|
148
|
+
readonly isCorrect: boolean;
|
|
149
|
+
readonly label: string;
|
|
150
|
+
readonly optionKey: string;
|
|
151
|
+
readonly order: number;
|
|
152
|
+
}[];
|
|
153
|
+
} | {
|
|
154
|
+
readonly kind: "multiple-choice";
|
|
155
|
+
readonly options: readonly {
|
|
156
|
+
readonly isCorrect: boolean;
|
|
157
|
+
readonly label: string;
|
|
158
|
+
readonly optionKey: string;
|
|
159
|
+
readonly order: number;
|
|
160
|
+
}[];
|
|
161
|
+
} | {
|
|
162
|
+
readonly categories: readonly {
|
|
163
|
+
readonly categoryKey: string;
|
|
164
|
+
readonly label: string;
|
|
165
|
+
readonly order: number;
|
|
166
|
+
}[];
|
|
167
|
+
readonly kind: "category";
|
|
168
|
+
readonly statements: readonly {
|
|
169
|
+
readonly correctCategoryKey: string;
|
|
170
|
+
readonly label: string;
|
|
171
|
+
readonly order: number;
|
|
172
|
+
readonly statementKey: string;
|
|
173
|
+
}[];
|
|
174
|
+
} | {
|
|
175
|
+
readonly criteria: readonly {
|
|
176
|
+
readonly criterionKey: string;
|
|
177
|
+
readonly finalAnswer?: {
|
|
178
|
+
readonly acceptsFractions: boolean;
|
|
179
|
+
readonly kind: "number";
|
|
180
|
+
readonly tolerance?: {
|
|
181
|
+
readonly kind: "absolute" | "relative";
|
|
182
|
+
readonly value: string;
|
|
183
|
+
};
|
|
184
|
+
readonly value: string;
|
|
185
|
+
} | {
|
|
186
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
187
|
+
readonly collapseWhitespace: boolean;
|
|
188
|
+
readonly ignoreCase: boolean;
|
|
189
|
+
readonly kind: "text";
|
|
190
|
+
};
|
|
191
|
+
readonly order: number;
|
|
192
|
+
readonly label: {
|
|
193
|
+
readonly de: string;
|
|
194
|
+
readonly en: string;
|
|
195
|
+
readonly id: string;
|
|
196
|
+
};
|
|
197
|
+
readonly levels: readonly {
|
|
198
|
+
readonly levelKey: string;
|
|
199
|
+
readonly order: number;
|
|
200
|
+
readonly points: number;
|
|
201
|
+
readonly label: {
|
|
202
|
+
readonly de: string;
|
|
203
|
+
readonly en: string;
|
|
204
|
+
readonly id: string;
|
|
205
|
+
};
|
|
206
|
+
}[];
|
|
207
|
+
}[];
|
|
208
|
+
readonly kind: "rubric";
|
|
209
|
+
} | {
|
|
210
|
+
readonly key: {
|
|
211
|
+
readonly acceptsFractions: boolean;
|
|
212
|
+
readonly kind: "number";
|
|
213
|
+
readonly tolerance?: {
|
|
214
|
+
readonly kind: "absolute" | "relative";
|
|
215
|
+
readonly value: string;
|
|
216
|
+
};
|
|
217
|
+
readonly value: string;
|
|
218
|
+
} | {
|
|
219
|
+
readonly acceptedAnswers: readonly [string, ...string[]];
|
|
220
|
+
readonly collapseWhitespace: boolean;
|
|
221
|
+
readonly ignoreCase: boolean;
|
|
222
|
+
readonly kind: "text";
|
|
223
|
+
};
|
|
224
|
+
readonly kind: "short-answer";
|
|
225
|
+
};
|
|
226
|
+
readonly scope: "server";
|
|
227
|
+
readonly sectionKey: string;
|
|
228
|
+
readonly setKey: string;
|
|
229
|
+
readonly sourceRevision: string;
|
|
230
|
+
readonly stimulusKey?: string;
|
|
231
|
+
readonly trackKey: string;
|
|
232
|
+
readonly answerArtifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
233
|
+
readonly contentHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraTryoutContentHash">;
|
|
234
|
+
readonly questionArtifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
235
|
+
};
|
|
236
|
+
readonly rowHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
237
|
+
}, import("#contracts/tryout/canonical").TryoutCanonicalHashError, never>;
|
|
238
|
+
/** Digests canonically ordered placements. Their canonical bytes are held until one Web Crypto digest runs. */
|
|
239
|
+
export declare function digestTryoutPlacements<E, R>(records: Stream.Stream<TryoutPlacementRecord, E, R>): Effect.Effect<{
|
|
9
240
|
count: number;
|
|
10
241
|
digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
11
|
-
}, E | import("#contracts/tryout/digest").TryoutDigestError, R>;
|
|
242
|
+
}, E | import("effect/PlatformError").PlatformError | import("#contracts/tryout/canonical").TryoutCanonicalHashError | import("#contracts/tryout/digest").TryoutDigestError, R>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import { canonicalQuestionBlueprint } from "#contracts/question/item";
|
|
2
3
|
import { canonicalQuestionResponse } from "#contracts/question/response";
|
|
3
4
|
import { encodeJsonText } from "#contracts/text/json";
|
|
@@ -39,19 +40,17 @@ export function canonicalizeTryoutPlacement(row) {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
/** Creates one immutable authenticated placement record. */
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
/** Digests canonically ordered placements in constant space. */
|
|
43
|
+
export const makeTryoutPlacementRecord = Effect.fn("AksaraContracts.makeTryoutPlacementRecord")(function* (row) {
|
|
44
|
+
const rowHash = yield* hashTryoutCanonical(PLACEMENT_DOMAIN, canonicalizeTryoutPlacement(row));
|
|
45
|
+
return TryoutPlacementRecordSchema.make({ row, rowHash });
|
|
46
|
+
});
|
|
47
|
+
/** Digests canonically ordered placements. Their canonical bytes are held until one Web Crypto digest runs. */
|
|
49
48
|
export function digestTryoutPlacements(records) {
|
|
50
49
|
return digestTryoutRecords({
|
|
51
50
|
canonicalize: canonicalizeTryoutPlacement,
|
|
52
51
|
domain: PLACEMENT_DOMAIN,
|
|
53
52
|
identity: tryoutPlacementIdentity,
|
|
54
53
|
records,
|
|
55
|
-
rowHash: (row) => makeTryoutPlacementRecord(row).rowHash,
|
|
54
|
+
rowHash: (row) => makeTryoutPlacementRecord(row).pipe(Effect.map((record) => record.rowHash)),
|
|
56
55
|
});
|
|
57
56
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
declare const TryoutRuntimeBundleHashComputationError_base: Schema.Class<TryoutRuntimeBundleHashComputationError, Schema.TaggedStruct<"TryoutRuntimeBundleHashComputationError", {
|
|
3
3
|
readonly sourceReleaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
|
|
4
|
-
}>, import("effect/Cause").YieldableError
|
|
4
|
+
}>, import("effect/Cause").YieldableError & {
|
|
5
|
+
readonly brand: unique symbol;
|
|
6
|
+
}>;
|
|
5
7
|
/** SHA-256 computation failed before bundle authenticity was established. */
|
|
6
8
|
export declare class TryoutRuntimeBundleHashComputationError extends TryoutRuntimeBundleHashComputationError_base {
|
|
7
9
|
}
|
|
@@ -3,7 +3,9 @@ import { hashText } from "#contracts/hash/text";
|
|
|
3
3
|
import { ReleaseIdSchema } from "#contracts/ids";
|
|
4
4
|
import { canonicalizeTryoutRuntimeBundlePayload } from "#contracts/tryout/runtime/canonical";
|
|
5
5
|
/** SHA-256 computation failed before bundle authenticity was established. */
|
|
6
|
-
export class TryoutRuntimeBundleHashComputationError extends Schema.TaggedError()("TryoutRuntimeBundleHashComputationError", {
|
|
6
|
+
export class TryoutRuntimeBundleHashComputationError extends Schema.TaggedError()("TryoutRuntimeBundleHashComputationError", {
|
|
7
|
+
sourceReleaseId: ReleaseIdSchema,
|
|
8
|
+
}) {
|
|
7
9
|
}
|
|
8
10
|
/** Computes the immutable identity of one canonical runtime bundle payload. */
|
|
9
11
|
export const hashTryoutRuntimeBundlePayload = Effect.fn("AksaraContracts.hashTryoutRuntimeBundlePayload")((payload) => hashText(canonicalizeTryoutRuntimeBundlePayload(payload)).pipe(Effect.mapError(() => new TryoutRuntimeBundleHashComputationError({
|
|
@@ -3,7 +3,9 @@ import type { SignedContentRelease } from "#contracts/release/spec";
|
|
|
3
3
|
import type { SignedTryoutRuntimeBundle } from "#contracts/tryout/runtime/spec";
|
|
4
4
|
declare const TryoutRuntimeBundleSourceError_base: Schema.Class<TryoutRuntimeBundleSourceError, Schema.TaggedStruct<"TryoutRuntimeBundleSourceError", {
|
|
5
5
|
readonly reason: Schema.Literals<readonly ["release", "manifest", "revision", "renderer", "snapshot"]>;
|
|
6
|
-
}>, import("effect/Cause").YieldableError
|
|
6
|
+
}>, import("effect/Cause").YieldableError & {
|
|
7
|
+
readonly brand: unique symbol;
|
|
8
|
+
}>;
|
|
7
9
|
/** A runtime bundle does not describe a pair authenticated by its Git release. */
|
|
8
10
|
export declare class TryoutRuntimeBundleSourceError extends TryoutRuntimeBundleSourceError_base {
|
|
9
11
|
}
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
declare const TryoutRuntimeBundleVerificationDecodeError_base: Schema.Class<TryoutRuntimeBundleVerificationDecodeError, Schema.TaggedStruct<"TryoutRuntimeBundleVerificationDecodeError", {
|
|
3
3
|
readonly message: Schema.Literal<"Try-out runtime bundle verification input does not satisfy its exact wire contract.">;
|
|
4
|
-
}>, import("effect/Cause").YieldableError
|
|
4
|
+
}>, import("effect/Cause").YieldableError & {
|
|
5
|
+
readonly brand: unique symbol;
|
|
6
|
+
}>;
|
|
5
7
|
/** Unknown input did not exactly satisfy the signed runtime-bundle contract. */
|
|
6
8
|
export declare class TryoutRuntimeBundleVerificationDecodeError extends TryoutRuntimeBundleVerificationDecodeError_base {
|
|
7
9
|
}
|
|
8
10
|
declare const TryoutRuntimeBundleHashMismatchError_base: Schema.Class<TryoutRuntimeBundleHashMismatchError, Schema.TaggedStruct<"TryoutRuntimeBundleHashMismatchError", {
|
|
9
11
|
readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
10
12
|
readonly expectedHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
11
|
-
}>, import("effect/Cause").YieldableError
|
|
13
|
+
}>, import("effect/Cause").YieldableError & {
|
|
14
|
+
readonly brand: unique symbol;
|
|
15
|
+
}>;
|
|
12
16
|
/** The envelope hash does not identify its complete canonical payload. */
|
|
13
17
|
export declare class TryoutRuntimeBundleHashMismatchError extends TryoutRuntimeBundleHashMismatchError_base {
|
|
14
18
|
}
|
|
15
19
|
declare const TryoutRuntimeBundleSnapshotMismatchError_base: Schema.Class<TryoutRuntimeBundleSnapshotMismatchError, Schema.TaggedStruct<"TryoutRuntimeBundleSnapshotMismatchError", {
|
|
16
20
|
readonly actualSnapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
17
21
|
readonly expectedSnapshotId: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
18
|
-
}>, import("effect/Cause").YieldableError
|
|
22
|
+
}>, import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly brand: unique symbol;
|
|
24
|
+
}>;
|
|
19
25
|
/** The embedded snapshot identity does not match its semantic facts. */
|
|
20
26
|
export declare class TryoutRuntimeBundleSnapshotMismatchError extends TryoutRuntimeBundleSnapshotMismatchError_base {
|
|
21
27
|
}
|
|
22
28
|
declare const TryoutRuntimeBundleRendererMismatchError_base: Schema.Class<TryoutRuntimeBundleRendererMismatchError, Schema.TaggedStruct<"TryoutRuntimeBundleRendererMismatchError", {
|
|
23
29
|
readonly actualRendererManifestHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
24
30
|
readonly expectedRendererManifestHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
25
|
-
}>, import("effect/Cause").YieldableError
|
|
31
|
+
}>, import("effect/Cause").YieldableError & {
|
|
32
|
+
readonly brand: unique symbol;
|
|
33
|
+
}>;
|
|
26
34
|
/** The supplied renderer is not the renderer authenticated by the bundle. */
|
|
27
35
|
export declare class TryoutRuntimeBundleRendererMismatchError extends TryoutRuntimeBundleRendererMismatchError_base {
|
|
28
36
|
}
|
|
@@ -57,5 +65,5 @@ export declare const verifySignedTryoutRuntimeBundle: (input: {
|
|
|
57
65
|
readonly sourceReleaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">;
|
|
58
66
|
};
|
|
59
67
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
60
|
-
}, import("#contracts/errors").ContractDecodeError | import("../../signature/spec.js").PublicKeyParseError | import("../../signature/spec.js").PublicKeyTypeError | import("../../renderer/contract.js").RendererManifestHashComputeError | import("../../renderer/contract.js").RendererManifestHashMismatchError | import("../../signature/spec.js").SignatureCheckError | import("../../signature/spec.js").SignatureInvalidError | import("../../signature/spec.js").SigningKeyNotFoundError | import("../../signature/spec.js").SigningKeyResolutionError | import("#contracts/tryout/runtime/hash").TryoutRuntimeBundleHashComputationError | TryoutRuntimeBundleHashMismatchError | TryoutRuntimeBundleRendererMismatchError | TryoutRuntimeBundleSnapshotMismatchError | TryoutRuntimeBundleVerificationDecodeError, import("../../signature/spec.js").ContentVerificationKeyResolver>;
|
|
68
|
+
}, import("#contracts/errors").ContractDecodeError | import("../../signature/spec.js").PublicKeyParseError | import("../../signature/spec.js").PublicKeyTypeError | import("../../renderer/contract.js").RendererManifestHashComputeError | import("../../renderer/contract.js").RendererManifestHashMismatchError | import("../../signature/spec.js").SignatureCheckError | import("../../signature/spec.js").SignatureInvalidError | import("../../signature/spec.js").SigningKeyNotFoundError | import("../../signature/spec.js").SigningKeyResolutionError | import("../canonical.js").TryoutCanonicalHashError | import("#contracts/tryout/runtime/hash").TryoutRuntimeBundleHashComputationError | TryoutRuntimeBundleHashMismatchError | TryoutRuntimeBundleRendererMismatchError | TryoutRuntimeBundleSnapshotMismatchError | TryoutRuntimeBundleVerificationDecodeError, import("../../signature/spec.js").ContentVerificationKeyResolver>;
|
|
61
69
|
export {};
|
|
@@ -37,7 +37,7 @@ const authenticateTryoutRuntimeBundle = Effect.fn("AksaraContracts.authenticateT
|
|
|
37
37
|
expectedHash: bundle.bundleHash,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const expectedSnapshotId = makeTryoutSnapshot(bundle.payload.snapshot).snapshotId;
|
|
40
|
+
const expectedSnapshotId = (yield* makeTryoutSnapshot(bundle.payload.snapshot)).snapshotId;
|
|
41
41
|
if (expectedSnapshotId !== bundle.payload.snapshot.snapshotId) {
|
|
42
42
|
return yield* new TryoutRuntimeBundleSnapshotMismatchError({
|
|
43
43
|
actualSnapshotId: bundle.payload.snapshot.snapshotId,
|
package/dist/tryout/scoring.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import type { TryoutPlacement } from "#contracts/tryout/placement";
|
|
|
4
4
|
declare const TryoutScoringError_base: Schema.Class<TryoutScoringError, Schema.TaggedStruct<"TryoutScoringError", {
|
|
5
5
|
readonly code: Schema.Literals<readonly ["marks", "rubric", "strategy"]>;
|
|
6
6
|
readonly identity: Schema.String;
|
|
7
|
-
}>, import("effect/Cause").YieldableError
|
|
7
|
+
}>, import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly brand: unique symbol;
|
|
9
|
+
}>;
|
|
8
10
|
/**
|
|
9
11
|
* A signed try-out row cannot be scored as published. `strategy` means a set
|
|
10
12
|
* disagrees with its exam's strategy, `marks` means a section of a penalized
|
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from "effect";
|
|
2
2
|
/** Creates one complete content-addressed try-out snapshot. */
|
|
3
|
-
export declare
|
|
3
|
+
export declare const makeTryoutSnapshot: (input: {
|
|
4
|
+
readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
|
|
5
|
+
readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
6
|
+
readonly counts: {
|
|
7
|
+
readonly country: number;
|
|
8
|
+
readonly exam: number;
|
|
9
|
+
readonly section: number;
|
|
10
|
+
readonly set: number;
|
|
11
|
+
readonly track: number;
|
|
12
|
+
};
|
|
13
|
+
readonly placementCount: number;
|
|
14
|
+
readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
15
|
+
readonly routeCount: number;
|
|
16
|
+
}) => Effect.Effect<{
|
|
17
|
+
readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
|
|
18
|
+
readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
19
|
+
readonly counts: {
|
|
20
|
+
readonly country: number;
|
|
21
|
+
readonly exam: number;
|
|
22
|
+
readonly section: number;
|
|
23
|
+
readonly set: number;
|
|
24
|
+
readonly track: number;
|
|
25
|
+
};
|
|
26
|
+
readonly placementCount: number;
|
|
27
|
+
readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
28
|
+
readonly routeCount: number;
|
|
29
|
+
readonly format: "localized-tryout-snapshot";
|
|
30
|
+
readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
31
|
+
}, import("#contracts/tryout/canonical").TryoutCanonicalHashError, never>;
|
|
4
32
|
/** Returns exact structured row evidence authenticated by a snapshot. */
|
|
5
|
-
export declare
|
|
33
|
+
export declare const tryoutSnapshotRowEvidence: (input: {
|
|
34
|
+
readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
|
|
35
|
+
readonly catalogDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
36
|
+
readonly counts: {
|
|
37
|
+
readonly country: number;
|
|
38
|
+
readonly exam: number;
|
|
39
|
+
readonly section: number;
|
|
40
|
+
readonly set: number;
|
|
41
|
+
readonly track: number;
|
|
42
|
+
};
|
|
43
|
+
readonly placementCount: number;
|
|
44
|
+
readonly placementDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
45
|
+
readonly routeCount: number;
|
|
46
|
+
}) => Effect.Effect<{
|
|
6
47
|
rowCount: number;
|
|
7
48
|
rowDigest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
8
|
-
}
|
|
49
|
+
}, import("#contracts/tryout/canonical").TryoutCanonicalHashError, never>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { Array as Arr, Record as Rec } from "effect";
|
|
1
|
+
import { Array as Arr, Effect, Record as Rec } from "effect";
|
|
2
2
|
import { hashTryoutCanonical } from "#contracts/tryout/canonical";
|
|
3
3
|
import { canonicalizeTryoutSnapshot, TRYOUT_SNAPSHOT_DOMAIN, TRYOUT_SNAPSHOT_ROWS_DOMAIN, } from "#contracts/tryout/snapshot/canonical";
|
|
4
4
|
import { TRYOUT_SNAPSHOT_FORMAT, TryoutSnapshotSchema, } from "#contracts/tryout/snapshot/spec";
|
|
5
5
|
/** Creates one complete content-addressed try-out snapshot. */
|
|
6
|
-
export
|
|
6
|
+
export const makeTryoutSnapshot = Effect.fn("AksaraContracts.makeTryoutSnapshot")(function* (input) {
|
|
7
|
+
const snapshotId = yield* hashTryoutCanonical(TRYOUT_SNAPSHOT_DOMAIN, canonicalizeTryoutSnapshot(input));
|
|
7
8
|
return TryoutSnapshotSchema.make({
|
|
8
9
|
...input,
|
|
9
10
|
format: TRYOUT_SNAPSHOT_FORMAT,
|
|
10
|
-
snapshotId
|
|
11
|
+
snapshotId,
|
|
11
12
|
});
|
|
12
|
-
}
|
|
13
|
+
});
|
|
13
14
|
/** Returns exact structured row evidence authenticated by a snapshot. */
|
|
14
|
-
export
|
|
15
|
+
export const tryoutSnapshotRowEvidence = Effect.fn("AksaraContracts.tryoutSnapshotRowEvidence")(function* (input) {
|
|
16
|
+
const rowDigest = yield* hashTryoutCanonical(TRYOUT_SNAPSHOT_ROWS_DOMAIN, `${input.catalogDigest}\n${input.placementDigest}`);
|
|
15
17
|
return {
|
|
16
18
|
rowCount: Arr.reduce(Rec.values(input.counts), 0, (total, count) => total + count) +
|
|
17
19
|
input.placementCount,
|
|
18
|
-
rowDigest
|
|
20
|
+
rowDigest,
|
|
19
21
|
};
|
|
20
|
-
}
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nakafa/aksara-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Schemas and verification contracts for Nakafa content releases.",
|
|
5
5
|
"homepage": "https://github.com/nakafaai/aksara#readme",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"directory": "packages/contracts"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"effect": "4.0.
|
|
24
|
+
"effect": "4.0.5"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
"./content": {
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
"types": "./dist/assessment/item.d.ts",
|
|
109
109
|
"import": "./dist/assessment/item.js"
|
|
110
110
|
},
|
|
111
|
+
"./assessment/joint": {
|
|
112
|
+
"types": "./dist/assessment/joint.d.ts",
|
|
113
|
+
"import": "./dist/assessment/joint.js"
|
|
114
|
+
},
|
|
111
115
|
"./assessment/key": {
|
|
112
116
|
"types": "./dist/assessment/key.d.ts",
|
|
113
117
|
"import": "./dist/assessment/key.js"
|
|
@@ -184,6 +188,22 @@
|
|
|
184
188
|
"types": "./dist/projection/hash.d.ts",
|
|
185
189
|
"node": "./dist/projection/hash.js"
|
|
186
190
|
},
|
|
191
|
+
"./hash/digest": {
|
|
192
|
+
"types": "./dist/hash/digest.d.ts",
|
|
193
|
+
"import": "./dist/hash/digest.js"
|
|
194
|
+
},
|
|
195
|
+
"./hash/text": {
|
|
196
|
+
"types": "./dist/hash/text.d.ts",
|
|
197
|
+
"import": "./dist/hash/text.js"
|
|
198
|
+
},
|
|
199
|
+
"./signature/key": {
|
|
200
|
+
"types": "./dist/signature/key.d.ts",
|
|
201
|
+
"import": "./dist/signature/key.js"
|
|
202
|
+
},
|
|
203
|
+
"./tryout/canonical": {
|
|
204
|
+
"types": "./dist/tryout/canonical.d.ts",
|
|
205
|
+
"import": "./dist/tryout/canonical.js"
|
|
206
|
+
},
|
|
187
207
|
"./projection/spec": {
|
|
188
208
|
"types": "./dist/projection/spec.d.ts",
|
|
189
209
|
"import": "./dist/projection/spec.js"
|