@nakafa/aksara-contracts 0.36.0 → 0.38.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 (38) hide show
  1. package/dist/cache/content.d.ts +14 -36
  2. package/dist/cache/content.js +22 -64
  3. package/dist/math/base.d.ts +1 -2
  4. package/dist/math/base.js +9 -5
  5. package/dist/math/plane.d.ts +2 -4
  6. package/dist/math/plane.js +2 -3
  7. package/dist/math/space.d.ts +2 -4
  8. package/dist/math/space.js +2 -3
  9. package/dist/math/visual.d.ts +4 -8
  10. package/dist/preview/artifact.js +2 -2
  11. package/dist/projection/digest.d.ts +0 -36
  12. package/dist/projection/question.d.ts +1 -159
  13. package/dist/projection/question.js +15 -75
  14. package/dist/projection/spec.d.ts +1 -199
  15. package/dist/projection/spec.js +1 -8
  16. package/dist/projection/verify.d.ts +64 -100
  17. package/dist/release/current/evidence.d.ts +6 -21
  18. package/dist/release/current/state.d.ts +10 -35
  19. package/dist/release/hash.d.ts +0 -5
  20. package/dist/release/items.js +1 -2
  21. package/dist/release/lifecycle.d.ts +4 -14
  22. package/dist/release/rollback/spec.d.ts +12 -228
  23. package/dist/release/snapshot/scope.d.ts +3 -48
  24. package/dist/release/snapshot/scope.js +7 -69
  25. package/dist/release/snapshot/spec.js +2 -3
  26. package/dist/release/snapshot/verify.d.ts +31 -31
  27. package/dist/release/spec.d.ts +6 -21
  28. package/dist/release/verify.d.ts +0 -5
  29. package/dist/runtime/spec.d.ts +26 -41
  30. package/dist/runtime/verify.d.ts +44 -54
  31. package/dist/transport/batch.d.ts +0 -405
  32. package/dist/transport/batch.js +2 -14
  33. package/dist/transport/group.d.ts +33 -633
  34. package/dist/transport/group.js +1 -2
  35. package/dist/transport/request.d.ts +375 -1435
  36. package/dist/transport/response.d.ts +145 -503
  37. package/dist/tryout/catalog-hash.d.ts +18 -18
  38. package/package.json +1 -1
@@ -1,52 +1,30 @@
1
1
  import { Schema } from "effect";
2
- import { type ContentFamily } from "#contracts/content";
3
- import { type ReleaseId, type Sha256Hash } from "#contracts/ids";
4
- /** Global content-runtime tag always invalidated before narrower tags. */
5
- export declare const CONTENT_CACHE_GLOBAL_TAG = "content-runtime";
6
- /** Maximum exact artifact tags carried with global and family cache tags. */
7
- export declare const MAX_CONTENT_CACHE_ARTIFACTS = 98;
2
+ import { type Sha256Hash } from "#contracts/ids";
3
+ /** Mutable publication dependencies owned by the signed source contracts. */
4
+ export declare const ContentCacheScopeSchema: Schema.Literals<readonly ["article", "material", "page", "question", "program", "quran", "tryout"]>;
5
+ export type ContentCacheScope = typeof ContentCacheScopeSchema.Type;
8
6
  /** One immutable published-artifact cache tag derived only from its hash. */
9
7
  export declare const ArtifactCacheTagSchema: Schema.brand<Schema.String, "@NakafaAI/AksaraArtifactCacheTag">;
10
8
  export type ArtifactCacheTag = typeof ArtifactCacheTagSchema.Type;
11
- /** One exact content-family cache tag derived from the family contract. */
12
- export declare const ContentFamilyCacheTagSchema: Schema.brand<Schema.String, "@NakafaAI/AksaraContentFamilyCacheTag">;
13
- export type ContentFamilyCacheTag = typeof ContentFamilyCacheTagSchema.Type;
14
- /**
15
- * Ordered cache tags shared by Aksara and Nakafa.
16
- *
17
- * Global and exact family tags come first; remaining tags name exact changed
18
- * artifacts while keeping one invalidation request at or below 100 tags.
19
- */
20
- export declare const ContentCacheTagsSchema: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Literal<"content-runtime">, Schema.brand<Schema.String, "@NakafaAI/AksaraContentFamilyCacheTag">]>, readonly [Schema.brand<Schema.String, "@NakafaAI/AksaraArtifactCacheTag">]>;
21
- export type ContentCacheTags = typeof ContentCacheTagsSchema.Type;
22
- /** One changed family plus its optional newly published immutable artifact. */
9
+ /** A changed item or snapshot invalidates its mutable selection dependency. */
23
10
  export declare const ContentCacheChangeSchema: Schema.Struct<{
24
- readonly artifactHash: Schema.optional<Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">>;
25
- readonly family: Schema.Literals<readonly ["article", "material", "page", "question"]>;
11
+ readonly scope: Schema.Literals<readonly ["article", "material", "page", "question", "program", "quran", "tryout"]>;
26
12
  }>;
27
13
  export type ContentCacheChange = typeof ContentCacheChangeSchema.Type;
28
- /** Derives the canonical cache tag for one already-canonical artifact hash. */
29
- export declare function makeArtifactCacheTag(hash: Sha256Hash): ArtifactCacheTag;
30
- /** Derives the canonical cache tag for one implemented content family. */
31
- export declare function makeContentFamilyCacheTag(family: ContentFamily): ContentFamilyCacheTag;
32
- /** One release-bound, family-exact cache invalidation request. */
14
+ /** One release-bound invalidation cannot name global or immutable cache tags. */
33
15
  export declare const ContentCacheRequestSchema: Schema.Struct<{
34
- readonly family: Schema.Literals<readonly ["article", "material", "page", "question"]>;
35
16
  readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
36
- readonly tags: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Literal<"content-runtime">, Schema.brand<Schema.String, "@NakafaAI/AksaraContentFamilyCacheTag">]>, readonly [Schema.brand<Schema.String, "@NakafaAI/AksaraArtifactCacheTag">]>;
17
+ readonly scope: Schema.Literals<readonly ["article", "material", "page", "question", "program", "quran", "tryout"]>;
37
18
  }>;
38
19
  export type ContentCacheRequest = typeof ContentCacheRequestSchema.Type;
39
- /** Nakafa proof that one exact release-bound invalidation completed. */
20
+ /** Nakafa proof that one exact release-bound dependency was invalidated. */
40
21
  export declare const ContentCacheReceiptSchema: Schema.Struct<{
41
- readonly family: Schema.Literals<readonly ["article", "material", "page", "question"]>;
42
22
  readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
23
+ readonly scope: Schema.Literals<readonly ["article", "material", "page", "question", "program", "quran", "tryout"]>;
43
24
  readonly revalidated: Schema.Literal<true>;
44
- readonly tags: Schema.TupleWithRest<Schema.Tuple<readonly [Schema.Literal<"content-runtime">, Schema.brand<Schema.String, "@NakafaAI/AksaraContentFamilyCacheTag">]>, readonly [Schema.brand<Schema.String, "@NakafaAI/AksaraArtifactCacheTag">]>;
45
25
  }>;
46
26
  export type ContentCacheReceipt = typeof ContentCacheReceiptSchema.Type;
47
- /** Builds one ordered invalidation request for one exact content family. */
48
- export declare function makeContentCacheRequest(input: {
49
- readonly artifactHashes: readonly Sha256Hash[];
50
- readonly family: ContentFamily;
51
- readonly releaseId: ReleaseId;
52
- }): ContentCacheRequest;
27
+ /** Derives the canonical cache tag for one already-canonical artifact hash. */
28
+ export declare function makeArtifactCacheTag(hash: Sha256Hash): ArtifactCacheTag;
29
+ /** Derives the same mutable dependency tag in the reader and invalidator. */
30
+ export declare function makeContentCacheTag(scope: ContentCacheScope): string;
@@ -1,80 +1,38 @@
1
1
  import { Schema } from "effect";
2
2
  import { ContentFamilySchema } from "#contracts/content";
3
3
  import { ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
4
- /** Global content-runtime tag always invalidated before narrower tags. */
5
- export const CONTENT_CACHE_GLOBAL_TAG = "content-runtime";
4
+ import { ContentSnapshotKindSchema } from "#contracts/release/snapshot/scope";
6
5
  const ARTIFACT_CACHE_PREFIX = "content-artifact:";
7
- const FAMILY_CACHE_PREFIX = "content-family:";
8
- /** Maximum exact artifact tags carried with global and family cache tags. */
9
- export const MAX_CONTENT_CACHE_ARTIFACTS = 98;
6
+ const SCOPE_CACHE_PREFIX = "content-scope:";
7
+ /** Mutable publication dependencies owned by the signed source contracts. */
8
+ export const ContentCacheScopeSchema = Schema.Literals([
9
+ ...ContentFamilySchema.literals,
10
+ ...ContentSnapshotKindSchema.literals,
11
+ ]);
10
12
  /** One immutable published-artifact cache tag derived only from its hash. */
11
13
  export const ArtifactCacheTagSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((tag) => tag.startsWith(ARTIFACT_CACHE_PREFIX) &&
12
14
  Schema.is(Sha256HashSchema)(tag.slice(ARTIFACT_CACHE_PREFIX.length)), {
13
15
  message: "Expected content-artifact followed by one canonical SHA-256 hash.",
14
16
  })), Schema.brand("@NakafaAI/AksaraArtifactCacheTag"));
15
- /** One exact content-family cache tag derived from the family contract. */
16
- export const ContentFamilyCacheTagSchema = Schema.String.pipe(Schema.check(Schema.makeFilter((tag) => tag.startsWith(FAMILY_CACHE_PREFIX) &&
17
- Schema.is(ContentFamilySchema)(tag.slice(FAMILY_CACHE_PREFIX.length)), { message: "Expected one canonical content-family cache tag." })), Schema.brand("@NakafaAI/AksaraContentFamilyCacheTag"));
18
- /** Checks one cache request carries no redundant exact artifact tags. */
19
- function hasUniqueArtifactTags(tags) {
20
- const artifacts = tags.slice(2);
21
- return new Set(artifacts).size === artifacts.length;
22
- }
23
- /**
24
- * Ordered cache tags shared by Aksara and Nakafa.
25
- *
26
- * Global and exact family tags come first; remaining tags name exact changed
27
- * artifacts while keeping one invalidation request at or below 100 tags.
28
- */
29
- export const ContentCacheTagsSchema = Schema.TupleWithRest(Schema.Tuple([
30
- Schema.Literal(CONTENT_CACHE_GLOBAL_TAG),
31
- ContentFamilyCacheTagSchema,
32
- ]), [ArtifactCacheTagSchema]).pipe(Schema.check(Schema.isMaxLength(MAX_CONTENT_CACHE_ARTIFACTS + 2)), Schema.check(Schema.makeFilter(hasUniqueArtifactTags, {
33
- message: "Expected unique exact artifact cache tags.",
34
- })));
35
- /** One changed family plus its optional newly published immutable artifact. */
17
+ /** A changed item or snapshot invalidates its mutable selection dependency. */
36
18
  export const ContentCacheChangeSchema = Schema.Struct({
37
- artifactHash: Schema.optional(Sha256HashSchema),
38
- family: ContentFamilySchema,
19
+ scope: ContentCacheScopeSchema,
39
20
  });
40
- /** Derives the canonical cache tag for one already-canonical artifact hash. */
41
- export function makeArtifactCacheTag(hash) {
42
- return ArtifactCacheTagSchema.make(`${ARTIFACT_CACHE_PREFIX}${hash}`);
43
- }
44
- /** Derives the canonical cache tag for one implemented content family. */
45
- export function makeContentFamilyCacheTag(family) {
46
- return ContentFamilyCacheTagSchema.make(`${FAMILY_CACHE_PREFIX}${family}`);
47
- }
48
- /** Checks the explicit family and ordered family cache tag cannot disagree. */
49
- function hasCoherentFamily(input) {
50
- return input.tags[1] === makeContentFamilyCacheTag(input.family);
51
- }
52
- /** One release-bound, family-exact cache invalidation request. */
21
+ /** One release-bound invalidation cannot name global or immutable cache tags. */
53
22
  export const ContentCacheRequestSchema = Schema.Struct({
54
- family: ContentFamilySchema,
55
23
  releaseId: ReleaseIdSchema,
56
- tags: ContentCacheTagsSchema,
57
- }).pipe(Schema.check(Schema.makeFilter(hasCoherentFamily, {
58
- message: "Expected the cache family to match its ordered family tag.",
59
- })));
60
- /** Nakafa proof that one exact release-bound invalidation completed. */
24
+ scope: ContentCacheScopeSchema,
25
+ });
26
+ /** Nakafa proof that one exact release-bound dependency was invalidated. */
61
27
  export const ContentCacheReceiptSchema = Schema.Struct({
62
- family: ContentFamilySchema,
63
- releaseId: ReleaseIdSchema,
28
+ ...ContentCacheRequestSchema.fields,
64
29
  revalidated: Schema.Literal(true),
65
- tags: ContentCacheTagsSchema,
66
- }).pipe(Schema.check(Schema.makeFilter(hasCoherentFamily, {
67
- message: "Expected the cache family to match its ordered family tag.",
68
- })));
69
- /** Builds one ordered invalidation request for one exact content family. */
70
- export function makeContentCacheRequest(input) {
71
- return ContentCacheRequestSchema.make({
72
- family: input.family,
73
- releaseId: input.releaseId,
74
- tags: [
75
- CONTENT_CACHE_GLOBAL_TAG,
76
- makeContentFamilyCacheTag(input.family),
77
- ...input.artifactHashes.map(makeArtifactCacheTag),
78
- ],
79
- });
30
+ });
31
+ /** Derives the canonical cache tag for one already-canonical artifact hash. */
32
+ export function makeArtifactCacheTag(hash) {
33
+ return ArtifactCacheTagSchema.make(`${ARTIFACT_CACHE_PREFIX}${hash}`);
34
+ }
35
+ /** Derives the same mutable dependency tag in the reader and invalidator. */
36
+ export function makeContentCacheTag(scope) {
37
+ return `${SCOPE_CACHE_PREFIX}${scope}`;
80
38
  }
@@ -21,8 +21,6 @@ export declare const MathAxisRangeSchema: Schema.Struct<{
21
21
  readonly max: Schema.Finite;
22
22
  readonly min: Schema.Finite;
23
23
  }>;
24
- /** Semantic visibility of one mathematical frame feature. */
25
- export declare const MathFeatureVisibilitySchema: Schema.Literals<readonly ["hidden", "visible"]>;
26
24
  /** Stable visual roles that Nakafa maps to its current design system. */
27
25
  export declare const MathAppearanceSchema: Schema.Literals<readonly ["answer", "construction", "highlight", "primary", "reference", "secondary", "warning"]>;
28
26
  /** Screen-relative placement of one rich label around its exact anchor. */
@@ -44,6 +42,7 @@ export declare function mathVisualIdentityIssues(objects: readonly {
44
42
  readonly id: string;
45
43
  }[], labels: readonly {
46
44
  readonly key: string;
45
+ readonly objectId: string;
47
46
  }[]): readonly Schema.FilterIssue[];
48
47
  /** Checks that an authored coordinate sequence contains no repeated position. */
49
48
  export declare function hasUniquePositions<T>(values: readonly T[], same: (left: T, right: T) => boolean): boolean;
package/dist/math/base.js CHANGED
@@ -24,11 +24,6 @@ export const MathAxisRangeSchema = Schema.Struct({
24
24
  }).pipe(Schema.check(Schema.makeFilter(({ max, min }) => min < max, {
25
25
  message: "Expected an axis range whose minimum is below its maximum.",
26
26
  })));
27
- /** Semantic visibility of one mathematical frame feature. */
28
- export const MathFeatureVisibilitySchema = Schema.Literals([
29
- "hidden",
30
- "visible",
31
- ]);
32
27
  /** Stable visual roles that Nakafa maps to its current design system. */
33
28
  export const MathAppearanceSchema = Schema.Literals([
34
29
  "answer",
@@ -86,6 +81,7 @@ function duplicateKeyIndexes(values, keyOf) {
86
81
  }
87
82
  /** Reports every repeated scene identity at its exact authored key path. */
88
83
  export function mathVisualIdentityIssues(objects, labels) {
84
+ const objectIds = new Set(objects.map(({ id }) => id));
89
85
  return [
90
86
  ...duplicateKeyIndexes(objects, ({ id }) => id).map((index) => ({
91
87
  issue: "Expected a unique mathematical object id.",
@@ -95,6 +91,14 @@ export function mathVisualIdentityIssues(objects, labels) {
95
91
  issue: "Expected a unique mathematical label key.",
96
92
  path: ["labels", index, "key"],
97
93
  })),
94
+ ...labels.flatMap((label, index) => objectIds.has(label.objectId)
95
+ ? []
96
+ : [
97
+ {
98
+ issue: "Expected a label to reference an existing mathematical object.",
99
+ path: ["labels", index, "objectId"],
100
+ },
101
+ ]),
98
102
  ];
99
103
  }
100
104
  /** Checks that an authored coordinate sequence contains no repeated position. */
@@ -112,8 +112,6 @@ export declare const PlaneMathObjectSchema: Schema.Union<readonly [Schema.Struct
112
112
  export type PlaneMathObject = typeof PlaneMathObjectSchema.Type;
113
113
  /** Exact Cartesian frame presented behind a plane construction. */
114
114
  export declare const PlaneMathFrameSchema: Schema.Struct<{
115
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
116
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
117
115
  readonly kind: Schema.Literal<"cartesian">;
118
116
  readonly x: Schema.Struct<{
119
117
  readonly max: Schema.Finite;
@@ -138,14 +136,13 @@ export declare const PlaneLabelAnchorSchema: Schema.Struct<{
138
136
  readonly y: Schema.Finite;
139
137
  }>;
140
138
  readonly key: Schema.String;
139
+ readonly objectId: Schema.String;
141
140
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
142
141
  }>;
143
142
  export type PlaneLabelAnchor = typeof PlaneLabelAnchorSchema.Type;
144
143
  /** Complete stable plane visual before rich labels are attached. */
145
144
  export declare const PlaneMathVisualSchema: Schema.Struct<{
146
145
  readonly frame: Schema.Struct<{
147
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
148
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
149
146
  readonly kind: Schema.Literal<"cartesian">;
150
147
  readonly x: Schema.Struct<{
151
148
  readonly max: Schema.Finite;
@@ -162,6 +159,7 @@ export declare const PlaneMathVisualSchema: Schema.Struct<{
162
159
  readonly y: Schema.Finite;
163
160
  }>;
164
161
  readonly key: Schema.String;
162
+ readonly objectId: Schema.String;
165
163
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
166
164
  }>>>;
167
165
  readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { ArcStartDegreesSchema, ArcSweepDegreesSchema, GEOMETRY_TOLERANCE, hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathFeatureVisibilitySchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PlanePointSchema, PositiveMeasureSchema, samePlanePoint, } from "#contracts/math/base";
2
+ import { ArcStartDegreesSchema, ArcSweepDegreesSchema, GEOMETRY_TOLERANCE, hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PlanePointSchema, PositiveMeasureSchema, samePlanePoint, } from "#contracts/math/base";
3
3
  import { planeBoundsIssues } from "#contracts/math/bounds";
4
4
  import { planeResolutionIssues } from "#contracts/math/resolution";
5
5
  const ObjectFields = {
@@ -126,8 +126,6 @@ export const PlaneMathObjectSchema = Schema.Union([
126
126
  ]);
127
127
  /** Exact Cartesian frame presented behind a plane construction. */
128
128
  export const PlaneMathFrameSchema = Schema.Struct({
129
- axes: MathFeatureVisibilitySchema,
130
- grid: MathFeatureVisibilitySchema,
131
129
  kind: Schema.Literal("cartesian"),
132
130
  x: MathAxisRangeSchema,
133
131
  y: MathAxisRangeSchema,
@@ -141,6 +139,7 @@ export const PlaneMathViewSchema = Schema.Struct({
141
139
  export const PlaneLabelAnchorSchema = Schema.Struct({
142
140
  at: PlanePointSchema,
143
141
  key: MathVisualKeySchema,
142
+ objectId: MathVisualKeySchema,
144
143
  placement: Schema.optionalKey(MathLabelPlacementSchema),
145
144
  });
146
145
  /** Complete stable plane visual before rich labels are attached. */
@@ -106,8 +106,6 @@ export declare const SpaceMathObjectSchema: Schema.Union<readonly [Schema.Struct
106
106
  export type SpaceMathObject = typeof SpaceMathObjectSchema.Type;
107
107
  /** Exact Cartesian frame presented behind a space construction. */
108
108
  export declare const SpaceMathFrameSchema: Schema.Struct<{
109
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
110
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
111
109
  readonly kind: Schema.Literal<"cartesian">;
112
110
  readonly x: Schema.Struct<{
113
111
  readonly max: Schema.Finite;
@@ -156,14 +154,13 @@ export declare const SpaceLabelAnchorSchema: Schema.Struct<{
156
154
  readonly z: Schema.Finite;
157
155
  }>;
158
156
  readonly key: Schema.String;
157
+ readonly objectId: Schema.String;
159
158
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
160
159
  }>;
161
160
  export type SpaceLabelAnchor = typeof SpaceLabelAnchorSchema.Type;
162
161
  /** Complete stable space visual before rich labels are attached. */
163
162
  export declare const SpaceMathVisualSchema: Schema.Struct<{
164
163
  readonly frame: Schema.Struct<{
165
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
166
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
167
164
  readonly kind: Schema.Literal<"cartesian">;
168
165
  readonly x: Schema.Struct<{
169
166
  readonly max: Schema.Finite;
@@ -185,6 +182,7 @@ export declare const SpaceMathVisualSchema: Schema.Struct<{
185
182
  readonly z: Schema.Finite;
186
183
  }>;
187
184
  readonly key: Schema.String;
185
+ readonly objectId: Schema.String;
188
186
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
189
187
  }>>>;
190
188
  readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathFeatureVisibilitySchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PositiveMeasureSchema, SpacePointSchema, sameSpacePoint, } from "#contracts/math/base";
2
+ import { hasUniquePositions, MathAppearanceSchema, MathAxisRangeSchema, MathLabelPlacementSchema, MathViewPaddingSchema, MathVisualKeySchema, mathVisualIdentityIssues, PositiveMeasureSchema, SpacePointSchema, sameSpacePoint, } from "#contracts/math/base";
3
3
  import { spaceBoundsIssues } from "#contracts/math/bounds";
4
4
  import { spaceResolutionIssues } from "#contracts/math/resolution";
5
5
  import { hasCoplanarArea } from "#contracts/math/vector";
@@ -75,8 +75,6 @@ export const SpaceMathObjectSchema = Schema.Union([
75
75
  ]);
76
76
  /** Exact Cartesian frame presented behind a space construction. */
77
77
  export const SpaceMathFrameSchema = Schema.Struct({
78
- axes: MathFeatureVisibilitySchema,
79
- grid: MathFeatureVisibilitySchema,
80
78
  kind: Schema.Literal("cartesian"),
81
79
  x: MathAxisRangeSchema,
82
80
  y: MathAxisRangeSchema,
@@ -105,6 +103,7 @@ export const SpaceMathViewSchema = Schema.Union([
105
103
  export const SpaceLabelAnchorSchema = Schema.Struct({
106
104
  at: SpacePointSchema,
107
105
  key: MathVisualKeySchema,
106
+ objectId: MathVisualKeySchema,
108
107
  placement: Schema.optionalKey(MathLabelPlacementSchema),
109
108
  });
110
109
  /** Complete stable space visual before rich labels are attached. */
@@ -2,8 +2,6 @@ import { Effect, Schema } from "effect";
2
2
  /** Pure mathematical scene data shared by Aksara authoring and Nakafa. */
3
3
  export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
4
4
  readonly frame: Schema.Struct<{
5
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
6
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
7
5
  readonly kind: Schema.Literal<"cartesian">;
8
6
  readonly x: Schema.Struct<{
9
7
  readonly max: Schema.Finite;
@@ -20,6 +18,7 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
20
18
  readonly y: Schema.Finite;
21
19
  }>;
22
20
  readonly key: Schema.String;
21
+ readonly objectId: Schema.String;
23
22
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
24
23
  }>>>;
25
24
  readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
@@ -138,8 +137,6 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
138
137
  }>;
139
138
  }>, Schema.Struct<{
140
139
  readonly frame: Schema.Struct<{
141
- readonly axes: Schema.Literals<readonly ["hidden", "visible"]>;
142
- readonly grid: Schema.Literals<readonly ["hidden", "visible"]>;
143
140
  readonly kind: Schema.Literal<"cartesian">;
144
141
  readonly x: Schema.Struct<{
145
142
  readonly max: Schema.Finite;
@@ -161,6 +158,7 @@ export declare const MathVisualSchema: Schema.Union<readonly [Schema.Struct<{
161
158
  readonly z: Schema.Finite;
162
159
  }>;
163
160
  readonly key: Schema.String;
161
+ readonly objectId: Schema.String;
164
162
  readonly placement: Schema.optionalKey<Schema.Literals<readonly ["above", "above-left", "above-right", "below", "below-left", "below-right", "center", "left", "right"]>>;
165
163
  }>>>;
166
164
  readonly objects: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
@@ -295,8 +293,6 @@ export type MathVisual = typeof MathVisualSchema.Type;
295
293
  /** Strictly decodes one untrusted mathematical scene into its stable contract. */
296
294
  export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
297
295
  readonly frame: {
298
- readonly axes: "hidden" | "visible";
299
- readonly grid: "hidden" | "visible";
300
296
  readonly kind: "cartesian";
301
297
  readonly x: {
302
298
  readonly max: number;
@@ -313,6 +309,7 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
313
309
  readonly y: number;
314
310
  };
315
311
  readonly key: string;
312
+ readonly objectId: string;
316
313
  readonly placement?: "above" | "above-left" | "above-right" | "below" | "below-left" | "below-right" | "center" | "left" | "right";
317
314
  }[];
318
315
  readonly objects: readonly [{
@@ -539,8 +536,6 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
539
536
  };
540
537
  } | {
541
538
  readonly frame: {
542
- readonly axes: "hidden" | "visible";
543
- readonly grid: "hidden" | "visible";
544
539
  readonly kind: "cartesian";
545
540
  readonly x: {
546
541
  readonly max: number;
@@ -562,6 +557,7 @@ export declare const decodeMathVisual: (input: unknown) => Effect.Effect<{
562
557
  readonly z: number;
563
558
  };
564
559
  readonly key: string;
560
+ readonly objectId: string;
565
561
  readonly placement?: "above" | "above-left" | "above-right" | "below" | "below-left" | "below-right" | "center" | "left" | "right";
566
562
  }[];
567
563
  readonly objects: readonly [{
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { Sha256HashSchema } from "#contracts/ids";
3
- import { CurrentContentProjectionSchema } from "#contracts/projection/spec";
3
+ import { ContentProjectionSchema } from "#contracts/projection/spec";
4
4
  export const LOCAL_PREVIEW_ARTIFACT_PREFIX = "/v1/artifacts/";
5
5
  /** Builds the one content-addressed path owned by the preview protocol. */
6
6
  export function localPreviewArtifactPath(artifactHash) {
@@ -14,7 +14,7 @@ function hasCoherentArtifactPath(input) {
14
14
  export const PreviewArtifactSchema = Schema.Struct({
15
15
  artifactHash: Sha256HashSchema,
16
16
  artifactPath: Schema.Trimmed.check(Schema.isNonEmpty()),
17
- projection: CurrentContentProjectionSchema,
17
+ projection: ContentProjectionSchema,
18
18
  }).pipe(Schema.check(Schema.makeFilter(hasCoherentArtifactPath, {
19
19
  message: "Expected the artifact path to match its signed hash.",
20
20
  })));
@@ -184,42 +184,6 @@ export declare const digestProjections: <E, R>(releaseId: string & import("effec
184
184
  readonly title: string;
185
185
  };
186
186
  readonly stimulusKey?: string;
187
- } | {
188
- readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
189
- readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
190
- readonly peerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
191
- readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
192
- readonly questionNumber: number;
193
- readonly setKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionSetKey">;
194
- readonly bodyKind: "question";
195
- readonly kind: "question-body";
196
- readonly metadata: {
197
- readonly authors: readonly {
198
- readonly name: string;
199
- }[];
200
- readonly date: string;
201
- readonly title: string;
202
- };
203
- readonly choices: {
204
- label: string;
205
- value: boolean;
206
- }[];
207
- } | {
208
- readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
209
- readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
210
- readonly peerContentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
211
- readonly questionKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionKey">;
212
- readonly questionNumber: number;
213
- readonly setKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraQuestionSetKey">;
214
- readonly bodyKind: "answer";
215
- readonly kind: "question-body";
216
- readonly metadata: {
217
- readonly authors: readonly {
218
- readonly name: string;
219
- }[];
220
- readonly date: string;
221
- readonly title: string;
222
- };
223
187
  }, E, R>) => Effect.Effect<{
224
188
  count: number;
225
189
  digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
@@ -174,164 +174,6 @@ export declare const QuestionBodyProjectionSchema: Schema.Union<readonly [Schema
174
174
  readonly stimulusKey: Schema.optionalKey<Schema.String>;
175
175
  }>]>;
176
176
  export type QuestionBodyProjection = typeof QuestionBodyProjectionSchema.Type;
177
- /**
178
- * Exact predecessor Question bytes retained for authenticated rollback reads.
179
- * Delete only after two accepted scoped rebuilds and an authoritative
180
- * current/prior audit reports zero `choices` and `date` projections.
181
- */
182
- export declare const HistoricalQuestionBodyProjectionSchema: Schema.Union<readonly [Schema.Struct<{
183
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
184
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
185
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
186
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
187
- readonly questionNumber: Schema.Finite;
188
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
189
- readonly bodyKind: Schema.Literal<"question">;
190
- readonly kind: Schema.Literal<"question-body">;
191
- readonly metadata: Schema.Struct<{
192
- readonly authors: Schema.$Array<Schema.Struct<{
193
- readonly name: Schema.String;
194
- }>>;
195
- readonly date: Schema.String;
196
- readonly title: Schema.String;
197
- }>;
198
- readonly choices: Schema.mutable<Schema.$Array<Schema.Struct<{
199
- readonly label: Schema.mutableKey<Schema.String>;
200
- readonly value: Schema.mutableKey<Schema.Boolean>;
201
- }>>>;
202
- }>, Schema.Struct<{
203
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
204
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
205
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
206
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
207
- readonly questionNumber: Schema.Finite;
208
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
209
- readonly bodyKind: Schema.Literal<"answer">;
210
- readonly kind: Schema.Literal<"question-body">;
211
- readonly metadata: Schema.Struct<{
212
- readonly authors: Schema.$Array<Schema.Struct<{
213
- readonly name: Schema.String;
214
- }>>;
215
- readonly date: Schema.String;
216
- readonly title: Schema.String;
217
- }>;
218
- }>]>;
219
- export type HistoricalQuestionBodyProjection = typeof HistoricalQuestionBodyProjectionSchema.Type;
220
- /** Current Question values plus exact predecessor rollback bytes. */
221
- export declare const ReadableQuestionBodyProjectionSchema: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
222
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
223
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
224
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
225
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
226
- readonly questionNumber: Schema.Finite;
227
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
228
- readonly bodyKind: Schema.Literal<"question">;
229
- readonly blueprint: Schema.optionalKey<Schema.Struct<{
230
- readonly cognitiveLevel: Schema.String;
231
- readonly contentDomain: Schema.String;
232
- readonly topic: Schema.String;
233
- }>>;
234
- readonly kind: Schema.Literal<"question-body">;
235
- readonly metadata: Schema.Struct<{
236
- readonly dateModified: Schema.optionalKey<Schema.String>;
237
- readonly datePublished: Schema.String;
238
- readonly authors: Schema.$Array<Schema.Struct<{
239
- readonly name: Schema.String;
240
- }>>;
241
- readonly title: Schema.String;
242
- }>;
243
- readonly stimulusKey: Schema.optionalKey<Schema.String>;
244
- readonly response: Schema.Union<readonly [Schema.Struct<{
245
- readonly categories: Schema.$Array<Schema.Struct<{
246
- readonly categoryKey: Schema.String;
247
- readonly label: Schema.String;
248
- readonly order: Schema.Int;
249
- }>>;
250
- readonly kind: Schema.Literal<"category">;
251
- readonly statements: Schema.$Array<Schema.Struct<{
252
- readonly correctCategoryKey: Schema.String;
253
- readonly label: Schema.String;
254
- readonly order: Schema.Int;
255
- readonly statementKey: Schema.String;
256
- }>>;
257
- }>, Schema.Struct<{
258
- readonly kind: Schema.Literal<"multiple-choice">;
259
- readonly options: Schema.$Array<Schema.Struct<{
260
- readonly isCorrect: Schema.Boolean;
261
- readonly label: Schema.String;
262
- readonly optionKey: Schema.String;
263
- readonly order: Schema.Int;
264
- }>>;
265
- }>, Schema.Struct<{
266
- readonly kind: Schema.Literal<"single-choice">;
267
- readonly options: Schema.$Array<Schema.Struct<{
268
- readonly isCorrect: Schema.Boolean;
269
- readonly label: Schema.String;
270
- readonly optionKey: Schema.String;
271
- readonly order: Schema.Int;
272
- }>>;
273
- }>]>;
274
- }>, Schema.Struct<{
275
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
276
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
277
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
278
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
279
- readonly questionNumber: Schema.Finite;
280
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
281
- readonly bodyKind: Schema.Literal<"answer">;
282
- readonly blueprint: Schema.optionalKey<Schema.Struct<{
283
- readonly cognitiveLevel: Schema.String;
284
- readonly contentDomain: Schema.String;
285
- readonly topic: Schema.String;
286
- }>>;
287
- readonly kind: Schema.Literal<"question-body">;
288
- readonly metadata: Schema.Struct<{
289
- readonly dateModified: Schema.optionalKey<Schema.String>;
290
- readonly datePublished: Schema.String;
291
- readonly authors: Schema.$Array<Schema.Struct<{
292
- readonly name: Schema.String;
293
- }>>;
294
- readonly title: Schema.String;
295
- }>;
296
- readonly stimulusKey: Schema.optionalKey<Schema.String>;
297
- }>]>, Schema.Union<readonly [Schema.Struct<{
298
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
299
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
300
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
301
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
302
- readonly questionNumber: Schema.Finite;
303
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
304
- readonly bodyKind: Schema.Literal<"question">;
305
- readonly kind: Schema.Literal<"question-body">;
306
- readonly metadata: Schema.Struct<{
307
- readonly authors: Schema.$Array<Schema.Struct<{
308
- readonly name: Schema.String;
309
- }>>;
310
- readonly date: Schema.String;
311
- readonly title: Schema.String;
312
- }>;
313
- readonly choices: Schema.mutable<Schema.$Array<Schema.Struct<{
314
- readonly label: Schema.mutableKey<Schema.String>;
315
- readonly value: Schema.mutableKey<Schema.Boolean>;
316
- }>>>;
317
- }>, Schema.Struct<{
318
- readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
319
- readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
320
- readonly peerContentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
321
- readonly questionKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionKey">;
322
- readonly questionNumber: Schema.Finite;
323
- readonly setKey: Schema.brand<Schema.String, "@NakafaAI/AksaraQuestionSetKey">;
324
- readonly bodyKind: Schema.Literal<"answer">;
325
- readonly kind: Schema.Literal<"question-body">;
326
- readonly metadata: Schema.Struct<{
327
- readonly authors: Schema.$Array<Schema.Struct<{
328
- readonly name: Schema.String;
329
- }>>;
330
- readonly date: Schema.String;
331
- readonly title: Schema.String;
332
- }>;
333
- }>]>]>;
334
- export type ReadableQuestionBodyProjection = typeof ReadableQuestionBodyProjectionSchema.Type;
335
177
  interface QuestionProjectionInput {
336
178
  readonly artifactLocale: typeof ArtifactLocaleSchema.Type;
337
179
  readonly bodyKind: QuestionBodyKind;
@@ -506,5 +348,5 @@ export declare const makeQuestionBodyProjection: (input: QuestionProjectionInput
506
348
  kind: "question-body";
507
349
  }, import("#contracts/question/item").QuestionResponseLocaleMissingError, never>;
508
350
  /** Serializes one question projection with stable signed field order. */
509
- export declare function canonicalizeQuestionProjection(projection: ReadableQuestionBodyProjection): string;
351
+ export declare function canonicalizeQuestionProjection(projection: QuestionBodyProjection): string;
510
352
  export {};