@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.
- package/README.md +10 -27
- package/dist/artifact/integrity.d.ts +3 -3
- package/dist/artifact/integrity.js +2 -2
- package/dist/artifact/source.d.ts +2 -2
- package/dist/artifact/source.js +2 -8
- package/dist/artifact/spec.d.ts +0 -16
- package/dist/artifact/spec.js +0 -6
- package/dist/artifact/verify.d.ts +1 -1
- package/dist/{question → assessment}/answer.d.ts +14 -58
- package/dist/{question → assessment}/answer.js +13 -60
- package/dist/assessment/catalog.d.ts +235 -0
- package/dist/assessment/catalog.js +115 -0
- package/dist/assessment/chart.d.ts +62 -0
- package/dist/assessment/chart.js +64 -0
- package/dist/assessment/closure.d.ts +28 -0
- package/dist/assessment/closure.js +164 -0
- package/dist/assessment/explanation.d.ts +13 -8
- package/dist/assessment/explanation.js +14 -8
- package/dist/assessment/figure.d.ts +140 -1
- package/dist/assessment/figure.js +9 -2
- package/dist/assessment/hash.d.ts +352 -212
- package/dist/assessment/hash.js +14 -0
- package/dist/assessment/inline.d.ts +3 -1
- package/dist/assessment/inline.js +20 -5
- package/dist/assessment/item.d.ts +8 -4
- package/dist/assessment/item.js +6 -2
- package/dist/assessment/key.js +6 -6
- package/dist/assessment/paper.d.ts +74 -74
- package/dist/assessment/snapshot.d.ts +3778 -0
- package/dist/assessment/snapshot.js +192 -0
- package/dist/cache/content.d.ts +4 -4
- package/dist/canonical.d.ts +6 -0
- package/dist/canonical.js +8 -1
- package/dist/content.d.ts +1 -1
- package/dist/content.js +0 -1
- package/dist/delivery.d.ts +0 -3
- package/dist/delivery.js +0 -5
- package/dist/hash/digest.d.ts +7 -7
- package/dist/hash/digest.js +9 -30
- package/dist/hash/stream.d.ts +1 -1
- package/dist/hash/text.d.ts +3 -12
- package/dist/hash/text.js +3 -6
- package/dist/ids.js +8 -8
- package/dist/preview/artifact.d.ts +1 -120
- package/dist/preview/auth.d.ts +1 -1
- package/dist/preview/auth.js +29 -25
- package/dist/preview/document.d.ts +0 -586
- package/dist/preview/document.js +1 -47
- package/dist/preview/spec.d.ts +6 -1984
- package/dist/preview/spec.js +7 -47
- package/dist/preview/target.d.ts +0 -173
- package/dist/preview/target.js +1 -70
- package/dist/program/snapshot/digest.d.ts +1 -2
- package/dist/program/snapshot/digest.js +2 -4
- package/dist/program/snapshot/hash.d.ts +6 -21
- package/dist/program/snapshot/hash.js +3 -9
- package/dist/projection/digest.d.ts +7 -143
- package/dist/projection/digest.js +7 -13
- package/dist/projection/hash.d.ts +2 -138
- package/dist/projection/hash.js +2 -5
- package/dist/projection/material.js +1 -1
- package/dist/projection/spec.d.ts +6 -211
- package/dist/projection/spec.js +4 -18
- package/dist/projection/verify.d.ts +1 -128
- package/dist/projection/verify.js +1 -4
- package/dist/quran/provenance.d.ts +2 -8
- package/dist/quran/provenance.js +1 -4
- package/dist/quran/snapshot/digest.d.ts +1 -2
- package/dist/quran/snapshot/digest.js +2 -2
- package/dist/quran/snapshot/hash.d.ts +3 -10
- package/dist/quran/snapshot/hash.js +2 -5
- package/dist/quran/snapshot/row/hash.d.ts +3 -12
- package/dist/quran/snapshot/row/hash.js +2 -5
- package/dist/release/canonical.d.ts +2 -2
- package/dist/release/current/evidence.d.ts +24 -24
- package/dist/release/current/state.d.ts +28 -56
- package/dist/release/current/state.js +1 -6
- package/dist/release/digest.d.ts +9 -18
- package/dist/release/digest.js +7 -13
- package/dist/release/hash.d.ts +7 -16
- package/dist/release/hash.js +2 -6
- package/dist/release/head.d.ts +10 -57
- package/dist/release/head.js +3 -14
- package/dist/release/identity.d.ts +3 -3
- package/dist/release/items.d.ts +3 -3
- package/dist/release/items.js +1 -1
- package/dist/release/lifecycle.d.ts +18 -18
- package/dist/release/policy.d.ts +3 -4
- package/dist/release/policy.js +2 -11
- package/dist/release/result/digest.d.ts +11 -31
- package/dist/release/result/digest.js +5 -11
- package/dist/release/rollback/digest.d.ts +11 -35
- package/dist/release/rollback/digest.js +7 -13
- package/dist/release/rollback/spec.d.ts +30 -792
- package/dist/release/rollback/spec.js +1 -4
- package/dist/release/route/digest.d.ts +7 -16
- package/dist/release/route/digest.js +7 -13
- package/dist/release/route/verify.d.ts +1 -1
- package/dist/release/route/verify.js +1 -1
- package/dist/release/snapshot/data.d.ts +599 -249
- package/dist/release/snapshot/data.js +11 -28
- package/dist/release/snapshot/evidence/assessment.d.ts +26 -0
- package/dist/release/snapshot/evidence/assessment.js +44 -0
- package/dist/release/snapshot/evidence/program.d.ts +1 -1
- package/dist/release/snapshot/evidence/quran.d.ts +1 -1
- package/dist/release/snapshot/evidence/requirement.d.ts +1 -1
- package/dist/release/snapshot/evidence.d.ts +19 -19
- package/dist/release/snapshot/evidence.js +2 -2
- package/dist/release/snapshot/scope.d.ts +5 -5
- package/dist/release/snapshot/scope.js +1 -1
- package/dist/release/snapshot/spec.d.ts +15 -15
- package/dist/release/snapshot/spec.js +8 -8
- package/dist/release/snapshot/verify.d.ts +1278 -268
- package/dist/release/snapshot/verify.js +8 -5
- package/dist/release/spec.d.ts +33 -33
- package/dist/release/verify.d.ts +7 -7
- package/dist/renderer/compatibility.d.ts +1 -1
- package/dist/renderer/component.js +1 -1
- package/dist/renderer/contract.d.ts +0 -8
- package/dist/renderer/contract.js +0 -3
- package/dist/renderer/manifest.d.ts +3 -3
- package/dist/renderer/manifest.js +2 -2
- package/dist/runtime/spec.d.ts +38 -38
- package/dist/runtime/spec.js +4 -5
- package/dist/runtime/verify.d.ts +42 -42
- package/dist/signature/key.d.ts +0 -2
- package/dist/signature/key.js +37 -88
- package/dist/signature/spec.d.ts +5 -5
- package/dist/signature/spec.js +0 -1
- package/dist/signature/verify.js +31 -46
- package/dist/transport/batch.d.ts +6 -244
- package/dist/transport/failure.d.ts +6 -20
- package/dist/transport/failure.js +0 -10
- package/dist/transport/group.d.ts +1969 -1369
- package/dist/transport/group.js +0 -2
- package/dist/transport/request.d.ts +10691 -5086
- package/dist/transport/request.js +0 -3
- package/dist/transport/response.d.ts +219 -1442
- package/dist/transport/response.js +0 -4
- package/dist/transport/snapshot.d.ts +1187 -487
- package/dist/tree.js +1 -1
- package/package.json +188 -296
- package/dist/projection/question.d.ts +0 -1067
- package/dist/projection/question.js +0 -121
- package/dist/question/identity.d.ts +0 -175
- package/dist/question/identity.js +0 -207
- package/dist/question/item.d.ts +0 -450
- package/dist/question/item.js +0 -174
- package/dist/question/label.d.ts +0 -3
- package/dist/question/label.js +0 -3
- package/dist/question/points.d.ts +0 -18
- package/dist/question/points.js +0 -22
- package/dist/question/response.d.ts +0 -289
- package/dist/question/response.js +0 -167
- package/dist/question/rubric.d.ts +0 -234
- package/dist/question/rubric.js +0 -186
- package/dist/release/current/runtime.d.ts +0 -4
- package/dist/release/current/runtime.js +0 -15
- package/dist/release/snapshot/evidence/tryout.d.ts +0 -22
- package/dist/release/snapshot/evidence/tryout.js +0 -91
- package/dist/runtime/protected/limits.d.ts +0 -10
- package/dist/runtime/protected/limits.js +0 -16
- package/dist/runtime/protected/spec.d.ts +0 -310
- package/dist/runtime/protected/spec.js +0 -80
- package/dist/runtime/protected/verify.d.ts +0 -83
- package/dist/runtime/protected/verify.js +0 -70
- package/dist/transport/runtime.d.ts +0 -77
- package/dist/transport/runtime.js +0 -33
- package/dist/tryout/canonical.d.ts +0 -12
- package/dist/tryout/canonical.js +0 -7
- package/dist/tryout/catalog.d.ts +0 -396
- package/dist/tryout/catalog.js +0 -155
- package/dist/tryout/closure/accounting.d.ts +0 -20
- package/dist/tryout/closure/accounting.js +0 -70
- package/dist/tryout/closure/locale.d.ts +0 -14
- package/dist/tryout/closure/locale.js +0 -113
- package/dist/tryout/closure/placement.d.ts +0 -5
- package/dist/tryout/closure/placement.js +0 -32
- package/dist/tryout/digest.d.ts +0 -34
- package/dist/tryout/digest.js +0 -57
- package/dist/tryout/hash/catalog.d.ts +0 -364
- package/dist/tryout/hash/catalog.js +0 -209
- package/dist/tryout/hash/content.d.ts +0 -215
- package/dist/tryout/hash/content.js +0 -75
- package/dist/tryout/hash/placement.d.ts +0 -242
- package/dist/tryout/hash/placement.js +0 -56
- package/dist/tryout/identity.d.ts +0 -12
- package/dist/tryout/identity.js +0 -47
- package/dist/tryout/key.d.ts +0 -4
- package/dist/tryout/key.js +0 -8
- package/dist/tryout/language.d.ts +0 -24
- package/dist/tryout/language.js +0 -30
- package/dist/tryout/placement.d.ts +0 -331
- package/dist/tryout/placement.js +0 -96
- package/dist/tryout/runtime/canonical.d.ts +0 -8
- package/dist/tryout/runtime/canonical.js +0 -34
- package/dist/tryout/runtime/hash.d.ts +0 -34
- package/dist/tryout/runtime/hash.js +0 -13
- package/dist/tryout/runtime/source.d.ts +0 -44
- package/dist/tryout/runtime/source.js +0 -47
- package/dist/tryout/runtime/spec.d.ts +0 -58
- package/dist/tryout/runtime/spec.js +0 -21
- package/dist/tryout/runtime/verify.d.ts +0 -69
- package/dist/tryout/runtime/verify.js +0 -67
- package/dist/tryout/scoring.d.ts +0 -148
- package/dist/tryout/scoring.js +0 -98
- package/dist/tryout/snapshot/canonical.d.ts +0 -7
- package/dist/tryout/snapshot/canonical.js +0 -18
- package/dist/tryout/snapshot/hash.d.ts +0 -49
- package/dist/tryout/snapshot/hash.js +0 -22
- package/dist/tryout/snapshot/spec.d.ts +0 -46
- package/dist/tryout/snapshot/spec.js +0 -30
- package/dist/tryout/spec.d.ts +0 -41
- package/dist/tryout/spec.js +0 -46
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@ package, its immutable release archive, and the renderer manifest that its
|
|
|
6
6
|
releases sign.
|
|
7
7
|
|
|
8
8
|
This package contains schemas, branded identifiers, canonical wire encodings,
|
|
9
|
-
and
|
|
9
|
+
and Ed25519 signature verification on Effect's `effect/crypto` services. It contains no corpus, renderer
|
|
10
10
|
implementation, signing key, deployment credential, or browser-side MDX
|
|
11
11
|
runtime.
|
|
12
12
|
|
|
13
13
|
Consumers install the exact `@nakafa/aksara-contracts` version from npm and
|
|
14
|
-
commit its
|
|
14
|
+
commit its `bun.lock` integrity. npm provenance and the matching immutable
|
|
15
15
|
GitHub Release bind those package bytes to the reviewed Aksara source. A contract
|
|
16
16
|
change ships with the Nakafa renderer that consumes it, in one step.
|
|
17
17
|
|
|
@@ -30,31 +30,10 @@ Current consumers use unversioned semantic Interfaces:
|
|
|
30
30
|
`canonicalizeContentTree` gives the bytes that hashes and signatures cover.
|
|
31
31
|
- `graph/family` classifies either a complete graph identity or one exact
|
|
32
32
|
asset ID into its application locale and content family.
|
|
33
|
-
- `tryout/catalog` owns minimal catalog node schemas, while `tryout/identity`
|
|
34
|
-
builds their pure lookup identities before complete signed rows are loaded.
|
|
35
33
|
- `projection/material` owns the application-locale material namespace and
|
|
36
34
|
validates every signed route and projection against it. Lesson metadata may
|
|
37
35
|
carry an optional `searchTitle` for the HTML title, while `title` stays the
|
|
38
36
|
short navigation name.
|
|
39
|
-
- `question/response` owns the frozen response formats: `single-choice`,
|
|
40
|
-
`multiple-choice`, `category`, `short-answer`, and `rubric`.
|
|
41
|
-
- `question/answer` owns deterministic short-answer and final-answer keys: an
|
|
42
|
-
exact canonical decimal with an optional tolerance and an explicit fraction
|
|
43
|
-
flag, or accepted text with explicit normalization rules. Every runtime
|
|
44
|
-
grades a typed answer only through `matchesAnswerKey`, reads a typed number
|
|
45
|
-
only through `readNumberAnswer`, the one number grammar, and decides that a
|
|
46
|
-
typed answer is blank only through `isBlankAnswer`, so whitespace and
|
|
47
|
-
invisible format characters alone never count as an answer.
|
|
48
|
-
- `question/rubric` owns the locale-neutral `QuestionRubricScaleSchema`
|
|
49
|
-
(ordered criteria and levels with points and optional final-answer keys)
|
|
50
|
-
and the Aksara rubric, which labels every criterion and level in every
|
|
51
|
-
active app locale. Each judged criterion maps onto one Effect
|
|
52
|
-
`Decision.rate` decision, and its total is derived, never stored.
|
|
53
|
-
- `question/points` owns a question's worth. Raw, penalized, and IRT scoring
|
|
54
|
-
read it only through `questionPoints`.
|
|
55
|
-
- `tryout/spec` owns the `irt`, `penalized`, and `raw` scoring strategies, the
|
|
56
|
-
per-section marks of a penalized exam, and the `institution`, `subject`, and
|
|
57
|
-
`year` track kinds.
|
|
58
37
|
- `projection/page` owns stable public page identities, localized paths, and
|
|
59
38
|
signed metadata for human, agent, and sitemap delivery.
|
|
60
39
|
- `math/base` owns the unversioned base schemas that mathematical visuals
|
|
@@ -68,15 +47,19 @@ Current consumers use unversioned semantic Interfaces:
|
|
|
68
47
|
with typed `figure` props, twelve `interaction` kinds that hold no answer
|
|
69
48
|
key, `scoring` as data, the `key` and the `explanation` of an item version as
|
|
70
49
|
records of their own, `item` and `stimulus` versions named by a content hash,
|
|
71
|
-
|
|
72
|
-
the
|
|
73
|
-
|
|
50
|
+
the exam `profile`, the frozen `paper`, and the `tools` registry. `answer`
|
|
51
|
+
owns the typed-answer keys: every runtime grades a typed answer only through
|
|
52
|
+
`matchesAnswerKey`, reads a typed number only through `readNumberAnswer`, the
|
|
53
|
+
one number grammar, and decides that a typed answer is blank only through
|
|
54
|
+
`isBlankAnswer`. `catalog` owns the try-out navigation rows, each set naming
|
|
55
|
+
its paper, and `snapshot` the `assessment` snapshot family that publishes all
|
|
56
|
+
of it in one signed release.
|
|
74
57
|
[ADR 0005](https://github.com/nakafaai/aksara/blob/main/docs/adr/assessment.md)
|
|
75
58
|
records the decisions.
|
|
76
59
|
|
|
77
60
|
## Publication dates
|
|
78
61
|
|
|
79
|
-
Article, material, public page
|
|
62
|
+
Article, material, and public page metadata carry one required
|
|
80
63
|
`datePublished` and one optional `dateModified`, both as exact `DateOnly`
|
|
81
64
|
values.
|
|
82
65
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { ArtifactHashMismatchError, ArtifactTreeComponentUnlistedError, ArtifactVerificationDecodeError } from "#contracts/artifact/spec";
|
|
3
3
|
/** Computes the immutable identity of one canonical compiled payload. */
|
|
4
4
|
export declare const hashCompiledContentPayload: (payload: {
|
|
5
5
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
@@ -21,7 +21,7 @@ export declare const hashCompiledContentPayload: (payload: {
|
|
|
21
21
|
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
22
22
|
readonly requiredComponents: readonly string[];
|
|
23
23
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
24
|
-
}) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">,
|
|
24
|
+
}) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
|
|
25
25
|
/** Strictly authenticates artifact integrity without renderer compatibility. */
|
|
26
26
|
export declare const verifySignedContentArtifactIntegrity: (input: unknown) => Effect.Effect<{
|
|
27
27
|
readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
@@ -48,4 +48,4 @@ export declare const verifySignedContentArtifactIntegrity: (input: unknown) => E
|
|
|
48
48
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
49
49
|
};
|
|
50
50
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
51
|
-
},
|
|
51
|
+
}, ArtifactHashMismatchError | import("#contracts/artifact/spec").ArtifactPayloadFieldByteLimitError | import("#contracts/artifact/spec").ArtifactSourceHashMismatchError | ArtifactTreeComponentUnlistedError | import("#contracts/artifact/spec").ArtifactVerificationByteLimitError | ArtifactVerificationDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("../signature/spec.js").SignatureCheckError | import("../signature/spec.js").SignatureInvalidError | import("../signature/spec.js").SigningKeyNotFoundError | import("../signature/spec.js").SigningKeyResolutionError, import("../signature/spec.js").ContentVerificationKeyResolver>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Array as Arr, Effect, Option, Schema } from "effect";
|
|
2
2
|
import { validateArtifactByteIntegrity } from "#contracts/artifact/limits";
|
|
3
3
|
import { verifyCompiledContentSourceHash } from "#contracts/artifact/source";
|
|
4
|
-
import {
|
|
4
|
+
import { ArtifactHashMismatchError, ArtifactTreeComponentUnlistedError, ArtifactVerificationDecodeError, } from "#contracts/artifact/spec";
|
|
5
5
|
import { canonicalizeCompiledContentPayload, canonicalizeContentArtifactSigningInput, SignedContentArtifactSchema, } from "#contracts/content";
|
|
6
6
|
import { hashText } from "#contracts/hash/text";
|
|
7
7
|
import { verifyEd25519Signature } from "#contracts/signature/verify";
|
|
8
8
|
import { contentTreeComponentNames } from "#contracts/tree";
|
|
9
9
|
/** Computes the immutable identity of one canonical compiled payload. */
|
|
10
|
-
export const hashCompiledContentPayload = Effect.fn("AksaraContracts.hashCompiledContentPayload")((payload) => hashText(canonicalizeCompiledContentPayload(payload))
|
|
10
|
+
export const hashCompiledContentPayload = Effect.fn("AksaraContracts.hashCompiledContentPayload")((payload) => hashText(canonicalizeCompiledContentPayload(payload)));
|
|
11
11
|
/** Confirms that an artifact envelope identifies its canonical payload. */
|
|
12
12
|
function validateArtifactHash(artifact, actualHash) {
|
|
13
13
|
if (artifact.artifactHash === actualHash) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { ArtifactSourceHashMismatchError } from "#contracts/artifact/spec";
|
|
3
3
|
/** Verifies that sourceHash identifies the complete authenticated raw MDX. */
|
|
4
4
|
export declare const verifyCompiledContentSourceHash: (payload: {
|
|
5
5
|
readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
|
|
@@ -21,4 +21,4 @@ export declare const verifyCompiledContentSourceHash: (payload: {
|
|
|
21
21
|
readonly rendererDomain: "ai-ds" | "biology" | "chemistry" | "mathematics" | "physics" | "politics" | "site" | "snbt-general" | "snbt-math" | "snbt-plain" | "snbt-quant" | "tka-math";
|
|
22
22
|
readonly requiredComponents: readonly string[];
|
|
23
23
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
24
|
-
}) => Effect.Effect<void,
|
|
24
|
+
}) => Effect.Effect<void, ArtifactSourceHashMismatchError, never>;
|
package/dist/artifact/source.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { ArtifactSourceHashMismatchError } from "#contracts/artifact/spec";
|
|
3
3
|
import { hashText } from "#contracts/hash/text";
|
|
4
|
-
/** Computes the authenticated hash of the complete authored MDX source. */
|
|
5
|
-
function hashAuthoredSource(payload) {
|
|
6
|
-
return hashText(payload.rawMdx).pipe(Effect.mapError(() => new ArtifactSourceHashComputationError({
|
|
7
|
-
contentKey: payload.contentKey,
|
|
8
|
-
})));
|
|
9
|
-
}
|
|
10
4
|
/** Verifies that sourceHash identifies the complete authenticated raw MDX. */
|
|
11
|
-
export const verifyCompiledContentSourceHash = Effect.fn("AksaraContracts.verifyCompiledContentSourceHash")((payload) =>
|
|
5
|
+
export const verifyCompiledContentSourceHash = Effect.fn("AksaraContracts.verifyCompiledContentSourceHash")((payload) => hashText(payload.rawMdx).pipe(Effect.flatMap((actualHash) => {
|
|
12
6
|
if (actualHash === payload.sourceHash) {
|
|
13
7
|
return Effect.void;
|
|
14
8
|
}
|
package/dist/artifact/spec.d.ts
CHANGED
|
@@ -74,14 +74,6 @@ declare const ArtifactPayloadFieldByteLimitError_base: Schema.Class<ArtifactPayl
|
|
|
74
74
|
/** One authenticated payload field exceeded its shared runtime ceiling. */
|
|
75
75
|
export declare class ArtifactPayloadFieldByteLimitError extends ArtifactPayloadFieldByteLimitError_base {
|
|
76
76
|
}
|
|
77
|
-
declare const ArtifactHashComputationError_base: Schema.Class<ArtifactHashComputationError, Schema.TaggedStruct<"ArtifactHashComputationError", {
|
|
78
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
79
|
-
}>, import("effect/Cause").YieldableError & {
|
|
80
|
-
readonly brand: unique symbol;
|
|
81
|
-
}>;
|
|
82
|
-
/** SHA-256 computation failed before authenticity could be established. */
|
|
83
|
-
export declare class ArtifactHashComputationError extends ArtifactHashComputationError_base {
|
|
84
|
-
}
|
|
85
77
|
declare const ArtifactHashMismatchError_base: Schema.Class<ArtifactHashMismatchError, Schema.TaggedStruct<"ArtifactHashMismatchError", {
|
|
86
78
|
readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
87
79
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
@@ -92,14 +84,6 @@ declare const ArtifactHashMismatchError_base: Schema.Class<ArtifactHashMismatchE
|
|
|
92
84
|
/** The signed artifact hash does not identify its canonical payload. */
|
|
93
85
|
export declare class ArtifactHashMismatchError extends ArtifactHashMismatchError_base {
|
|
94
86
|
}
|
|
95
|
-
declare const ArtifactSourceHashComputationError_base: Schema.Class<ArtifactSourceHashComputationError, Schema.TaggedStruct<"ArtifactSourceHashComputationError", {
|
|
96
|
-
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
|
97
|
-
}>, import("effect/Cause").YieldableError & {
|
|
98
|
-
readonly brand: unique symbol;
|
|
99
|
-
}>;
|
|
100
|
-
/** SHA-256 could not be calculated for the authenticated authored source. */
|
|
101
|
-
export declare class ArtifactSourceHashComputationError extends ArtifactSourceHashComputationError_base {
|
|
102
|
-
}
|
|
103
87
|
declare const ArtifactSourceHashMismatchError_base: Schema.Class<ArtifactSourceHashMismatchError, Schema.TaggedStruct<"ArtifactSourceHashMismatchError", {
|
|
104
88
|
readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
|
|
105
89
|
readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
|
package/dist/artifact/spec.js
CHANGED
|
@@ -33,9 +33,6 @@ export class ArtifactPayloadFieldByteLimitError extends Schema.TaggedError()("Ar
|
|
|
33
33
|
maxBytes: Schema.Finite.pipe(Schema.check(Schema.isInt()), Schema.check(Schema.isGreaterThan(0))),
|
|
34
34
|
}) {
|
|
35
35
|
}
|
|
36
|
-
/** SHA-256 computation failed before authenticity could be established. */
|
|
37
|
-
export class ArtifactHashComputationError extends Schema.TaggedError()("ArtifactHashComputationError", { contentKey: ContentKeySchema }) {
|
|
38
|
-
}
|
|
39
36
|
/** Fields that name one content hash, its content key, and the hash that failed. */
|
|
40
37
|
const ContentHashMismatchFields = {
|
|
41
38
|
actualHash: Sha256HashSchema,
|
|
@@ -45,9 +42,6 @@ const ContentHashMismatchFields = {
|
|
|
45
42
|
/** The signed artifact hash does not identify its canonical payload. */
|
|
46
43
|
export class ArtifactHashMismatchError extends Schema.TaggedError()("ArtifactHashMismatchError", { ...ContentHashMismatchFields }) {
|
|
47
44
|
}
|
|
48
|
-
/** SHA-256 could not be calculated for the authenticated authored source. */
|
|
49
|
-
export class ArtifactSourceHashComputationError extends Schema.TaggedError()("ArtifactSourceHashComputationError", { contentKey: ContentKeySchema }) {
|
|
50
|
-
}
|
|
51
45
|
/** The authenticated source hash does not identify the complete raw MDX. */
|
|
52
46
|
export class ArtifactSourceHashMismatchError extends Schema.TaggedError()("ArtifactSourceHashMismatchError", { ...ContentHashMismatchFields }) {
|
|
53
47
|
}
|
|
@@ -26,4 +26,4 @@ export declare const verifySignedContentArtifact: (input: unknown) => Effect.Eff
|
|
|
26
26
|
readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
|
|
27
27
|
};
|
|
28
28
|
readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
|
|
29
|
-
}, import("#contracts/artifact/spec").
|
|
29
|
+
}, import("#contracts/artifact/spec").ArtifactHashMismatchError | import("#contracts/artifact/spec").ArtifactPayloadFieldByteLimitError | import("#contracts/artifact/spec").ArtifactRendererComponentMissingError | import("#contracts/artifact/spec").ArtifactRendererDomainUnpublishedError | import("#contracts/artifact/spec").ArtifactSourceHashMismatchError | import("#contracts/artifact/spec").ArtifactTreeComponentUnlistedError | import("#contracts/artifact/spec").ArtifactVerificationByteLimitError | ArtifactVerificationDecodeError | import("../errors.js").ContractDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("../renderer/contract.js").RendererDomainCapabilityMissingError | 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("../signature/spec.js").ContentVerificationKeyResolver>;
|
|
@@ -7,26 +7,26 @@ import type { AppLocaleCode } from "#contracts/locale";
|
|
|
7
7
|
* Graders compare it exactly through `matchesAnswerKey`, never through binary
|
|
8
8
|
* floating point.
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
11
|
-
export type
|
|
10
|
+
export declare const DecimalSchema: Schema.String;
|
|
11
|
+
export type Decimal = typeof DecimalSchema.Type;
|
|
12
12
|
/**
|
|
13
13
|
* Largest accepted distance from the exact value, inclusive. An absolute
|
|
14
14
|
* tolerance `t` accepts `|answer - value| <= t`. A relative tolerance `r`
|
|
15
15
|
* accepts `|answer - value| <= r * |value|`, is below one, and needs a nonzero
|
|
16
16
|
* value.
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const ToleranceSchema: Schema.Struct<{
|
|
19
19
|
readonly kind: Schema.Literals<readonly ["absolute", "relative"]>;
|
|
20
20
|
readonly value: Schema.String;
|
|
21
21
|
}>;
|
|
22
|
-
export type
|
|
22
|
+
export type Tolerance = typeof ToleranceSchema.Type;
|
|
23
23
|
/**
|
|
24
24
|
* Deterministic numeric answer key. A learner number, read by
|
|
25
25
|
* `readNumberAnswer` in the delivery language, matches when its exact value
|
|
26
26
|
* equals `value`, or lies within `tolerance` when present. A fraction such as
|
|
27
27
|
* `6/8` matches only when `acceptsFractions` is true.
|
|
28
28
|
*/
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const NumberKeySchema: Schema.Struct<{
|
|
30
30
|
readonly acceptsFractions: Schema.Boolean;
|
|
31
31
|
readonly kind: Schema.Literal<"number">;
|
|
32
32
|
readonly tolerance: Schema.optionalKey<Schema.Struct<{
|
|
@@ -35,22 +35,22 @@ export declare const QuestionNumberKeySchema: Schema.Struct<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
readonly value: Schema.String;
|
|
37
37
|
}>;
|
|
38
|
-
export type
|
|
38
|
+
export type NumberKey = typeof NumberKeySchema.Type;
|
|
39
39
|
/**
|
|
40
40
|
* Deterministic text answer key written in the delivery language. A learner
|
|
41
41
|
* answer matches when it normalizes, under `ignoreCase` and
|
|
42
42
|
* `collapseWhitespace`, to the same text as one accepted answer. Accepted
|
|
43
43
|
* answers are plain text, never Markdown, so show them without rich rendering.
|
|
44
44
|
*/
|
|
45
|
-
export declare const
|
|
45
|
+
export declare const TextKeySchema: Schema.Struct<{
|
|
46
46
|
readonly acceptedAnswers: Schema.NonEmptyArray<Schema.Trimmed>;
|
|
47
47
|
readonly collapseWhitespace: Schema.Boolean;
|
|
48
48
|
readonly ignoreCase: Schema.Boolean;
|
|
49
49
|
readonly kind: Schema.Literal<"text">;
|
|
50
50
|
}>;
|
|
51
|
-
export type
|
|
52
|
-
/**
|
|
53
|
-
export declare const
|
|
51
|
+
export type TextKey = typeof TextKeySchema.Type;
|
|
52
|
+
/** A key that a typed answer is graded against: a number or accepted texts. */
|
|
53
|
+
export declare const AnswerKeySchema: Schema.Union<readonly [Schema.Struct<{
|
|
54
54
|
readonly acceptsFractions: Schema.Boolean;
|
|
55
55
|
readonly kind: Schema.Literal<"number">;
|
|
56
56
|
readonly tolerance: Schema.optionalKey<Schema.Struct<{
|
|
@@ -64,18 +64,18 @@ export declare const QuestionAnswerKeySchema: Schema.Union<readonly [Schema.Stru
|
|
|
64
64
|
readonly ignoreCase: Schema.Boolean;
|
|
65
65
|
readonly kind: Schema.Literal<"text">;
|
|
66
66
|
}>]>;
|
|
67
|
-
export type
|
|
67
|
+
export type AnswerKey = typeof AnswerKeySchema.Type;
|
|
68
68
|
/**
|
|
69
69
|
* One learner number read exactly as `numerator / denominator`, with a
|
|
70
70
|
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
71
71
|
* records that the learner wrote `p/q`.
|
|
72
72
|
*/
|
|
73
|
-
declare const
|
|
73
|
+
declare const NumberAnswerSchema: Schema.Struct<{
|
|
74
74
|
readonly denominator: Schema.BigDecimal;
|
|
75
75
|
readonly fraction: Schema.Boolean;
|
|
76
76
|
readonly numerator: Schema.BigDecimal;
|
|
77
77
|
}>;
|
|
78
|
-
export type
|
|
78
|
+
export type NumberAnswer = typeof NumberAnswerSchema.Type;
|
|
79
79
|
/**
|
|
80
80
|
* Checks whether one typed learner answer is blank: nothing remains once it is
|
|
81
81
|
* read as visible text, so whitespace and invisible format characters alone
|
|
@@ -107,49 +107,5 @@ export declare function readNumberAnswer(input: string, language: AppLocaleCode)
|
|
|
107
107
|
* language and compares its exact value, so an unreadable or empty answer
|
|
108
108
|
* never matches.
|
|
109
109
|
*/
|
|
110
|
-
export declare function matchesAnswerKey(key:
|
|
111
|
-
/** Returns one answer key in stable field order for signed canonicalizers. */
|
|
112
|
-
export declare function canonicalQuestionAnswerKey(key: QuestionAnswerKey): {
|
|
113
|
-
acceptedAnswers: [string, ...string[]];
|
|
114
|
-
collapseWhitespace: boolean;
|
|
115
|
-
ignoreCase: boolean;
|
|
116
|
-
kind: "text";
|
|
117
|
-
} | {
|
|
118
|
-
acceptedAnswers?: never;
|
|
119
|
-
collapseWhitespace?: never;
|
|
120
|
-
ignoreCase?: never;
|
|
121
|
-
acceptsFractions: boolean;
|
|
122
|
-
kind: "number";
|
|
123
|
-
tolerance?: {
|
|
124
|
-
kind: "absolute" | "relative";
|
|
125
|
-
value: string;
|
|
126
|
-
};
|
|
127
|
-
value: string;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Returns the grading rules shared by every delivery language. A numeric key is
|
|
131
|
-
* language-neutral and stays whole; text keeps its rules but drops accepted
|
|
132
|
-
* answers, which each delivery language writes in its own words.
|
|
133
|
-
*/
|
|
134
|
-
export declare function canonicalQuestionAnswerKeyStructure(key: QuestionAnswerKey): {
|
|
135
|
-
acceptedAnswers: [string, ...string[]];
|
|
136
|
-
collapseWhitespace: boolean;
|
|
137
|
-
ignoreCase: boolean;
|
|
138
|
-
kind: "text";
|
|
139
|
-
} | {
|
|
140
|
-
acceptedAnswers?: never;
|
|
141
|
-
collapseWhitespace?: never;
|
|
142
|
-
ignoreCase?: never;
|
|
143
|
-
acceptsFractions: boolean;
|
|
144
|
-
kind: "number";
|
|
145
|
-
tolerance?: {
|
|
146
|
-
kind: "absolute" | "relative";
|
|
147
|
-
value: string;
|
|
148
|
-
};
|
|
149
|
-
value: string;
|
|
150
|
-
} | {
|
|
151
|
-
collapseWhitespace: boolean;
|
|
152
|
-
ignoreCase: boolean;
|
|
153
|
-
kind: "text";
|
|
154
|
-
};
|
|
110
|
+
export declare function matchesAnswerKey(key: AnswerKey, answer: string, language: AppLocaleCode): boolean;
|
|
155
111
|
export {};
|
|
@@ -21,9 +21,9 @@ const NUMBER_PATTERNS = {
|
|
|
21
21
|
* Graders compare it exactly through `matchesAnswerKey`, never through binary
|
|
22
22
|
* floating point.
|
|
23
23
|
*/
|
|
24
|
-
export const
|
|
24
|
+
export const DecimalSchema = Schema.String.check(Schema.isPattern(DECIMAL_PATTERN, {
|
|
25
25
|
description: "Exact decimal written in its canonical dot-separated form.",
|
|
26
|
-
identifier: "
|
|
26
|
+
identifier: "AssessmentDecimal",
|
|
27
27
|
message: "Invalid canonical decimal.",
|
|
28
28
|
}));
|
|
29
29
|
/** Checks that one canonical decimal is strictly greater than zero. */
|
|
@@ -36,9 +36,9 @@ function isPositiveDecimal(value) {
|
|
|
36
36
|
* accepts `|answer - value| <= r * |value|`, is below one, and needs a nonzero
|
|
37
37
|
* value.
|
|
38
38
|
*/
|
|
39
|
-
export const
|
|
39
|
+
export const ToleranceSchema = Schema.Struct({
|
|
40
40
|
kind: Schema.Literals(["absolute", "relative"]),
|
|
41
|
-
value:
|
|
41
|
+
value: DecimalSchema.check(Schema.makeFilter(isPositiveDecimal, {
|
|
42
42
|
message: "Expected a positive tolerance.",
|
|
43
43
|
})),
|
|
44
44
|
}).check(Schema.makeFilter(({ kind, value }) => kind === "absolute" || value.startsWith("0."), { message: "Expected a relative tolerance below one." }));
|
|
@@ -48,11 +48,11 @@ export const QuestionToleranceSchema = Schema.Struct({
|
|
|
48
48
|
* equals `value`, or lies within `tolerance` when present. A fraction such as
|
|
49
49
|
* `6/8` matches only when `acceptsFractions` is true.
|
|
50
50
|
*/
|
|
51
|
-
export const
|
|
51
|
+
export const NumberKeySchema = Schema.Struct({
|
|
52
52
|
acceptsFractions: Schema.Boolean,
|
|
53
53
|
kind: Schema.Literal("number"),
|
|
54
|
-
tolerance: Schema.optionalKey(
|
|
55
|
-
value:
|
|
54
|
+
tolerance: Schema.optionalKey(ToleranceSchema),
|
|
55
|
+
value: DecimalSchema,
|
|
56
56
|
}).check(Schema.makeFilter(({ tolerance, value }) => tolerance?.kind !== "relative" || value !== "0", { message: "A relative tolerance cannot measure distance from zero." }));
|
|
57
57
|
/**
|
|
58
58
|
* One accepted answer as a learner types it on one line: trimmed, non-empty,
|
|
@@ -60,7 +60,7 @@ export const QuestionNumberKeySchema = Schema.Struct({
|
|
|
60
60
|
* control or invisible format character. Each key therefore has one signed
|
|
61
61
|
* spelling and can be typed into a single-line answer field.
|
|
62
62
|
*/
|
|
63
|
-
const
|
|
63
|
+
const AcceptedTextSchema = Schema.Trimmed.check(Schema.isNonEmpty(), Schema.makeFilter((text) => !UNTYPABLE_CHARACTER_PATTERN.test(text), {
|
|
64
64
|
message: "Expected one typed line whose only whitespace is the ordinary space.",
|
|
65
65
|
}), Schema.makeFilter((text) => text === text.normalize("NFC"), {
|
|
66
66
|
message: "Expected NFC text.",
|
|
@@ -107,25 +107,22 @@ function hasDistinctAcceptedAnswers(key) {
|
|
|
107
107
|
* `collapseWhitespace`, to the same text as one accepted answer. Accepted
|
|
108
108
|
* answers are plain text, never Markdown, so show them without rich rendering.
|
|
109
109
|
*/
|
|
110
|
-
export const
|
|
111
|
-
acceptedAnswers: Schema.NonEmptyArray(
|
|
110
|
+
export const TextKeySchema = Schema.Struct({
|
|
111
|
+
acceptedAnswers: Schema.NonEmptyArray(AcceptedTextSchema),
|
|
112
112
|
collapseWhitespace: Schema.Boolean,
|
|
113
113
|
ignoreCase: Schema.Boolean,
|
|
114
114
|
kind: Schema.Literal("text"),
|
|
115
115
|
}).check(Schema.makeFilter(hasDistinctAcceptedAnswers, {
|
|
116
116
|
message: "Accepted answers must stay distinct after normalization.",
|
|
117
117
|
}));
|
|
118
|
-
/**
|
|
119
|
-
export const
|
|
120
|
-
QuestionNumberKeySchema,
|
|
121
|
-
QuestionTextKeySchema,
|
|
122
|
-
]);
|
|
118
|
+
/** A key that a typed answer is graded against: a number or accepted texts. */
|
|
119
|
+
export const AnswerKeySchema = Schema.Union([NumberKeySchema, TextKeySchema]);
|
|
123
120
|
/**
|
|
124
121
|
* One learner number read exactly as `numerator / denominator`, with a
|
|
125
122
|
* positive integer denominator that is one for a typed decimal. `fraction`
|
|
126
123
|
* records that the learner wrote `p/q`.
|
|
127
124
|
*/
|
|
128
|
-
const
|
|
125
|
+
const NumberAnswerSchema = Schema.Struct({
|
|
129
126
|
denominator: Schema.BigDecimal,
|
|
130
127
|
fraction: Schema.Boolean,
|
|
131
128
|
numerator: Schema.BigDecimal,
|
|
@@ -217,47 +214,3 @@ export function matchesAnswerKey(key, answer, language) {
|
|
|
217
214
|
}
|
|
218
215
|
return Option.exists(readNumberAnswer(answer, language), (number) => matchesNumberKey(key, number));
|
|
219
216
|
}
|
|
220
|
-
/** Copies accepted answers while keeping their non-empty tuple type. */
|
|
221
|
-
function canonicalAcceptedAnswers(answers) {
|
|
222
|
-
const [first, ...rest] = answers;
|
|
223
|
-
return [first, ...rest];
|
|
224
|
-
}
|
|
225
|
-
/** Returns one answer key in stable field order for signed canonicalizers. */
|
|
226
|
-
export function canonicalQuestionAnswerKey(key) {
|
|
227
|
-
if (key.kind === "text") {
|
|
228
|
-
return {
|
|
229
|
-
acceptedAnswers: canonicalAcceptedAnswers(key.acceptedAnswers),
|
|
230
|
-
collapseWhitespace: key.collapseWhitespace,
|
|
231
|
-
ignoreCase: key.ignoreCase,
|
|
232
|
-
kind: key.kind,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
acceptsFractions: key.acceptsFractions,
|
|
237
|
-
kind: key.kind,
|
|
238
|
-
...(key.tolerance === undefined
|
|
239
|
-
? {}
|
|
240
|
-
: {
|
|
241
|
-
tolerance: {
|
|
242
|
-
kind: key.tolerance.kind,
|
|
243
|
-
value: key.tolerance.value,
|
|
244
|
-
},
|
|
245
|
-
}),
|
|
246
|
-
value: key.value,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Returns the grading rules shared by every delivery language. A numeric key is
|
|
251
|
-
* language-neutral and stays whole; text keeps its rules but drops accepted
|
|
252
|
-
* answers, which each delivery language writes in its own words.
|
|
253
|
-
*/
|
|
254
|
-
export function canonicalQuestionAnswerKeyStructure(key) {
|
|
255
|
-
if (key.kind === "text") {
|
|
256
|
-
return {
|
|
257
|
-
collapseWhitespace: key.collapseWhitespace,
|
|
258
|
-
ignoreCase: key.ignoreCase,
|
|
259
|
-
kind: key.kind,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
return canonicalQuestionAnswerKey(key);
|
|
263
|
-
}
|