@nakafa/aksara-contracts 0.48.5 → 0.48.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
1
  import { Schema } from "effect";
2
+ import type { PlaneLabelAnchor, PlaneMathObject } from "#contracts/math/plane";
3
+ import type { SpaceLabelAnchor, SpaceMathObject } from "#contracts/math/space";
2
4
  /** Relative floating-point tolerance used by normalized geometry predicates. */
3
5
  export declare const GEOMETRY_TOLERANCE: number;
4
6
  /** Stable source identity shared by visual objects and rich-label anchors. */
@@ -41,11 +43,6 @@ export declare function samePlanePoint(left: PlanePoint, right: PlanePoint): boo
41
43
  /** Returns whether two space positions are exactly the same authored point. */
42
44
  export declare function sameSpacePoint(left: SpacePoint, right: SpacePoint): boolean;
43
45
  /** Reports every repeated scene identity at its exact authored key path. */
44
- export declare function mathVisualIdentityIssues(objects: readonly {
45
- readonly id: string;
46
- }[], labels: readonly {
47
- readonly key: string;
48
- readonly objectId: string;
49
- }[]): readonly Schema.FilterIssue[];
46
+ export declare function mathVisualIdentityIssues(objects: readonly Pick<PlaneMathObject | SpaceMathObject, "id">[], labels: readonly Pick<PlaneLabelAnchor | SpaceLabelAnchor, "key" | "objectId">[]): readonly Schema.FilterIssue[];
50
47
  /** Checks that an authored coordinate sequence contains no repeated position. */
51
48
  export declare function hasUniquePositions<T>(values: readonly T[], same: (left: T, right: T) => boolean): boolean;
@@ -74,17 +74,20 @@ function planeObjectIssues(frame, object, index, threshold) {
74
74
  }
75
75
  return objectResolutionIssues(frame, object, index, threshold);
76
76
  }
77
- /** Reports every frame axis whose non-zero span collapses in the envelope. */
77
+ /**
78
+ * Reports every frame axis whose non-zero span collapses in the envelope. Each
79
+ * entry pairs one axis with its range.
80
+ */
78
81
  function frameIssues(entries, threshold) {
79
- return Arr.flatMap(entries, ({ axis, range }) => spanUnresolved(range, threshold) ? [issue(["frame", axis])] : []);
82
+ return Arr.flatMap(entries, ([axis, range]) => spanUnresolved(range, threshold) ? [issue(["frame", axis])] : []);
80
83
  }
81
84
  /** Reports every plane delta that a normalized renderer cannot preserve. */
82
85
  export function planeResolutionIssues(frame, objects, labels, view) {
83
86
  const threshold = renderThreshold([frame.x, frame.y], view.padding ?? 0);
84
87
  return uniqueIssues([
85
88
  ...frameIssues([
86
- { axis: "x", range: frame.x },
87
- { axis: "y", range: frame.y },
89
+ ["x", frame.x],
90
+ ["y", frame.y],
88
91
  ], threshold),
89
92
  ...measureIssue(view.padding ?? 0, threshold, ["view", "padding"]),
90
93
  ...Arr.map(coordinateCollisionPaths(planeSceneCoordinates(frame, objects, labels, threshold), threshold), issue),
@@ -104,9 +107,9 @@ export function spaceResolutionIssues(frame, objects, labels, view) {
104
107
  const threshold = renderThreshold([frame.x, frame.y, frame.z], view.kind === "fit" ? (view.padding ?? 0) : 0, envelopePairs);
105
108
  return uniqueIssues([
106
109
  ...frameIssues([
107
- { axis: "x", range: frame.x },
108
- { axis: "y", range: frame.y },
109
- { axis: "z", range: frame.z },
110
+ ["x", frame.x],
111
+ ["y", frame.y],
112
+ ["z", frame.z],
110
113
  ], threshold),
111
114
  ...measureIssue(view.kind === "fit" ? (view.padding ?? 0) : 0, threshold, [
112
115
  "view",
@@ -28,7 +28,7 @@ export class ProjectionDigestError extends Schema.TaggedError()("ProjectionDiges
28
28
  function projectionState() {
29
29
  return {
30
30
  firstIndexByRoute: MutableHashMap.empty(),
31
- previous: undefined,
31
+ previous: Option.none(),
32
32
  };
33
33
  }
34
34
  const VerifiedContentProjectionsSchema = Schema.Struct({
@@ -37,11 +37,11 @@ const VerifiedContentProjectionsSchema = Schema.Struct({
37
37
  /** Decodes one row and applies canonical order and route uniqueness rules. */
38
38
  const decodeProjection = Effect.fn("AksaraContracts.decodeProjection")(function* (state, source, projectionIndex) {
39
39
  const projection = yield* Schema.decodeUnknownEffect(ContentProjectionSchema)(source, { onExcessProperty: "error" }).pipe(Effect.mapError(() => new ProjectionDecodeError({ projectionIndex })));
40
- if (state.previous &&
41
- compareContentHeads(state.previous, projection) >= 0) {
40
+ if (Option.isSome(state.previous) &&
41
+ compareContentHeads(state.previous.value, projection) >= 0) {
42
42
  return yield* new ProjectionOrderError({ projectionIndex });
43
43
  }
44
- state.previous = projection;
44
+ state.previous = Option.some(projection);
45
45
  if (projection.kind === "question-body") {
46
46
  return projection;
47
47
  }
@@ -34,7 +34,10 @@ function hasOrderedScale(criterion) {
34
34
  return criterion.levels.length === 2 && lower?.points === 0;
35
35
  }
36
36
  const ORDERED_SCALE_MESSAGE = "Rubric criteria need two or more levels whose points strictly ascend, and a final-answer criterion needs exactly a zero level and one higher level.";
37
- /** Checks one or more criteria and the stable keys derived from their order. */
37
+ /**
38
+ * Checks one or more criteria and the stable keys derived from their order. A
39
+ * labeled criterion is a scale criterion with labels, so both kinds pass here.
40
+ */
38
41
  function hasCanonicalCriteria(criteria) {
39
42
  return (criteria.length > 0 &&
40
43
  Arr.every(criteria, ({ criterionKey, levels, order }, index) => order === index + 1 &&
@@ -60,7 +60,7 @@ function readMarkers(source) {
60
60
  const number = Number(rawNumber);
61
61
  if (rawNumber !== String(number) ||
62
62
  !Schema.is(QuranTranslationNoteNumberSchema)(number)) {
63
- return { _tag: "Failure" };
63
+ return Option.none();
64
64
  }
65
65
  MutableList.append(markers, {
66
66
  end: start + match[0].length,
@@ -68,7 +68,7 @@ function readMarkers(source) {
68
68
  start,
69
69
  });
70
70
  }
71
- return { _tag: "Success", markers: MutableList.toArray(markers) };
71
+ return Option.some(MutableList.toArray(markers));
72
72
  }
73
73
  /** Converts the translation body to text and note-reference segments. */
74
74
  function segmentTranslation(source, markers) {
@@ -102,12 +102,11 @@ function segmentTranslation(source, markers) {
102
102
  function analyzeTranslation(source) {
103
103
  const referencesResult = readMarkers(source.text);
104
104
  const definitionsResult = readMarkers(source.footnotes);
105
- if (referencesResult._tag === "Failure" ||
106
- definitionsResult._tag === "Failure") {
105
+ if (Option.isNone(referencesResult) || Option.isNone(definitionsResult)) {
107
106
  return { _tag: "Failure", reason: "invalid-marker" };
108
107
  }
109
- const references = referencesResult.markers;
110
- const definitions = definitionsResult.markers;
108
+ const references = referencesResult.value;
109
+ const definitions = definitionsResult.value;
111
110
  const uniqueReferences = Arr.filter(references, (reference, index) => Option.contains(Arr.findFirstIndex(references, ({ number }) => number === reference.number), index));
112
111
  const noteCandidates = Arr.map(definitions, (definition, index) => ({
113
112
  definition,
@@ -1,5 +1,5 @@
1
1
  import { Array as Arr, Effect, HashSet, Schema } from "effect";
2
- import { SignedContentArtifactSchema, } from "#contracts/content";
2
+ import { SignedContentArtifactSchema } from "#contracts/content";
3
3
  import { decodeContract } from "#contracts/decode";
4
4
  import { ProtectedContentDeliverySchema, } from "#contracts/delivery";
5
5
  import { ContentKeySchema, CorpusSourcePathSchema, Sha256HashSchema, } from "#contracts/ids";
@@ -1,4 +1,4 @@
1
- import { Array as Arr, Effect } from "effect";
1
+ import { Array as Arr, Effect, Option } from "effect";
2
2
  import { verifySignedContentArtifact } from "#contracts/artifact/verify";
3
3
  import { hashContentProjection } from "#contracts/projection/hash";
4
4
  import { verifyContentReleaseBundle } from "#contracts/release/verify";
@@ -62,7 +62,11 @@ const verifyPublicRelease = Effect.fn("AksaraContracts.verifyPublicRelease")(fun
62
62
  });
63
63
  }
64
64
  });
65
- /** Authenticates one public response and applies its explicit use policy. */
65
+ /**
66
+ * Authenticates one public response. With a live renderer manifest it also
67
+ * proves that the renderer can execute the artifact; without one the response
68
+ * is evidence only.
69
+ */
66
70
  const verifyPublicRuntimeExchange = Effect.fn("AksaraContracts.verifyPublicRuntimeExchange")(function* (input) {
67
71
  const request = yield* decodePublicContentRuntimeRequest(input.request);
68
72
  const response = yield* decodePublicContentRuntimeResponse(input.response);
@@ -79,10 +83,10 @@ const verifyPublicRuntimeExchange = Effect.fn("AksaraContracts.verifyPublicRunti
79
83
  artifact: response.artifact,
80
84
  rendererManifest: bundle.rendererManifest,
81
85
  });
82
- if (input.policy.kind === "evidence") {
86
+ if (Option.isNone(input.rendererManifest)) {
83
87
  return response;
84
88
  }
85
- const liveRenderer = yield* validateRendererManifestHash(input.policy.rendererManifest);
89
+ const liveRenderer = yield* validateRendererManifestHash(input.rendererManifest.value);
86
90
  if (liveRenderer.hash !== bundle.rendererManifest.hash) {
87
91
  yield* verifyContentRendererCompatibility({
88
92
  payload: artifact.payload,
@@ -100,7 +104,7 @@ const verifyPublicRuntimeExchange = Effect.fn("AksaraContracts.verifyPublicRunti
100
104
  export const verifyContentRuntimeEvidenceExchange = Effect.fn("AksaraContracts.verifyContentRuntimeEvidenceExchange")(function* (input) {
101
105
  return yield* verifyPublicRuntimeExchange({
102
106
  ...input,
103
- policy: { kind: "evidence" },
107
+ rendererManifest: Option.none(),
104
108
  });
105
109
  });
106
110
  /**
@@ -111,10 +115,7 @@ export const verifyContentRuntimeEvidenceExchange = Effect.fn("AksaraContracts.v
111
115
  */
112
116
  export const verifyContentRuntimeExchange = Effect.fn("AksaraContracts.verifyContentRuntimeExchange")(function* (input) {
113
117
  return yield* verifyPublicRuntimeExchange({
114
- policy: {
115
- kind: "execution",
116
- rendererManifest: input.rendererManifest,
117
- },
118
+ rendererManifest: Option.some(input.rendererManifest),
118
119
  request: input.request,
119
120
  response: input.response,
120
121
  });
@@ -1,7 +1,6 @@
1
1
  import { Effect, MutableHashMap, MutableList, Schema } from "effect";
2
- import type { TryoutCatalogRow, TryoutSection, TryoutSet } from "#contracts/tryout/catalog";
2
+ import type { TryoutCatalogRow } from "#contracts/tryout/catalog";
3
3
  import type { TryoutPlacement } from "#contracts/tryout/placement";
4
- import type { TryoutScoring } from "#contracts/tryout/spec";
5
4
  declare const TryoutScoringError_base: Schema.Class<TryoutScoringError, Schema.TaggedStruct<"TryoutScoringError", {
6
5
  readonly code: Schema.Literals<readonly ["marks", "rubric", "strategy"]>;
7
6
  readonly identity: Schema.String;
@@ -16,9 +15,62 @@ export declare class TryoutScoringError extends TryoutScoringError_base {
16
15
  }
17
16
  /** Creates empty scoring facts for one snapshot verification pass. */
18
17
  export declare function makeTryoutScoringFacts(): {
19
- readonly exams: MutableHashMap.MutableHashMap<string, TryoutScoring>;
20
- readonly sections: MutableList.MutableList<TryoutSection>;
21
- readonly sets: MutableHashMap.MutableHashMap<string, TryoutSet>;
18
+ readonly exams: MutableHashMap.MutableHashMap<string, "irt" | "penalized" | "raw">;
19
+ readonly sections: MutableList.MutableList<{
20
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
21
+ readonly description?: string | undefined;
22
+ readonly graph: {
23
+ readonly alignmentId: string;
24
+ readonly assetId: string;
25
+ readonly conceptId: string;
26
+ readonly learningObjectId: string;
27
+ readonly lensId: string;
28
+ };
29
+ readonly sourceRevision: string;
30
+ readonly title: string;
31
+ readonly countryKey: string;
32
+ readonly examKey: string;
33
+ readonly kind: "section";
34
+ readonly marks?: {
35
+ readonly blank: number;
36
+ readonly correct: number;
37
+ readonly wrong: number;
38
+ };
39
+ readonly order: number;
40
+ readonly publicPath?: (string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">) | undefined;
41
+ readonly questionCount: number;
42
+ readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
43
+ readonly sectionKey: string;
44
+ readonly setKey: string;
45
+ readonly timeLimitSeconds: number;
46
+ readonly trackKey: string;
47
+ readonly visibility: "internal-entry" | "visible";
48
+ }>;
49
+ readonly sets: MutableHashMap.MutableHashMap<string, {
50
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
51
+ readonly description?: string | undefined;
52
+ readonly graph: {
53
+ readonly alignmentId: string;
54
+ readonly assetId: string;
55
+ readonly conceptId: string;
56
+ readonly learningObjectId: string;
57
+ readonly lensId: string;
58
+ };
59
+ readonly sourceRevision: string;
60
+ readonly title: string;
61
+ readonly countryKey: string;
62
+ readonly examKey: string;
63
+ readonly internalEntrySectionKey?: string | undefined;
64
+ readonly kind: "set";
65
+ readonly order: number;
66
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
67
+ readonly questionCount: number;
68
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
69
+ readonly sectionCount: number;
70
+ readonly setKey: string;
71
+ readonly trackKey: string;
72
+ readonly visibleSectionCount: number;
73
+ }>;
22
74
  };
23
75
  /** Exam strategies, sets, and sections gathered while a catalog is read. */
24
76
  export type TryoutScoringFacts = ReturnType<typeof makeTryoutScoringFacts>;
@@ -29,9 +81,62 @@ export declare function recordTryoutScoringFacts(facts: TryoutScoringFacts, row:
29
81
  * sections of penalized sets, once the complete catalog has been recorded.
30
82
  */
31
83
  export declare const validateTryoutScoringFacts: (facts: {
32
- readonly exams: MutableHashMap.MutableHashMap<string, TryoutScoring>;
33
- readonly sections: MutableList.MutableList<TryoutSection>;
34
- readonly sets: MutableHashMap.MutableHashMap<string, TryoutSet>;
84
+ readonly exams: MutableHashMap.MutableHashMap<string, "irt" | "penalized" | "raw">;
85
+ readonly sections: MutableList.MutableList<{
86
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
87
+ readonly description?: string | undefined;
88
+ readonly graph: {
89
+ readonly alignmentId: string;
90
+ readonly assetId: string;
91
+ readonly conceptId: string;
92
+ readonly learningObjectId: string;
93
+ readonly lensId: string;
94
+ };
95
+ readonly sourceRevision: string;
96
+ readonly title: string;
97
+ readonly countryKey: string;
98
+ readonly examKey: string;
99
+ readonly kind: "section";
100
+ readonly marks?: {
101
+ readonly blank: number;
102
+ readonly correct: number;
103
+ readonly wrong: number;
104
+ };
105
+ readonly order: number;
106
+ readonly publicPath?: (string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">) | undefined;
107
+ readonly questionCount: number;
108
+ readonly questionSourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
109
+ readonly sectionKey: string;
110
+ readonly setKey: string;
111
+ readonly timeLimitSeconds: number;
112
+ readonly trackKey: string;
113
+ readonly visibility: "internal-entry" | "visible";
114
+ }>;
115
+ readonly sets: MutableHashMap.MutableHashMap<string, {
116
+ readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
117
+ readonly description?: string | undefined;
118
+ readonly graph: {
119
+ readonly alignmentId: string;
120
+ readonly assetId: string;
121
+ readonly conceptId: string;
122
+ readonly learningObjectId: string;
123
+ readonly lensId: string;
124
+ };
125
+ readonly sourceRevision: string;
126
+ readonly title: string;
127
+ readonly countryKey: string;
128
+ readonly examKey: string;
129
+ readonly internalEntrySectionKey?: string | undefined;
130
+ readonly kind: "set";
131
+ readonly order: number;
132
+ readonly publicPath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraPublicPath">;
133
+ readonly questionCount: number;
134
+ readonly scoringStrategy: "irt" | "penalized" | "raw";
135
+ readonly sectionCount: number;
136
+ readonly setKey: string;
137
+ readonly trackKey: string;
138
+ readonly visibleSectionCount: number;
139
+ }>;
35
140
  }) => Effect.Effect<void, TryoutScoringError, never>;
36
141
  /**
37
142
  * Requires one rubric placement to belong to a raw-scored set, because a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakafa/aksara-contracts",
3
- "version": "0.48.5",
3
+ "version": "0.48.6",
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",