@nakafa/aksara-contracts 0.50.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +207 -152
  2. package/README.md +3 -0
  3. package/dist/artifact/integrity.d.ts +33 -8
  4. package/dist/artifact/integrity.js +19 -17
  5. package/dist/artifact/limits.d.ts +13 -7
  6. package/dist/artifact/limits.js +7 -15
  7. package/dist/artifact/source.d.ts +10 -4
  8. package/dist/artifact/source.js +4 -8
  9. package/dist/artifact/spec.d.ts +54 -22
  10. package/dist/artifact/spec.js +7 -8
  11. package/dist/artifact/verify.d.ts +11 -5
  12. package/dist/assessment/hash.d.ts +3 -1
  13. package/dist/assessment/paper.d.ts +3 -1
  14. package/dist/content.d.ts +37 -11
  15. package/dist/content.js +7 -21
  16. package/dist/errors.d.ts +3 -1
  17. package/dist/graph/family.d.ts +6 -2
  18. package/dist/graph/identity.d.ts +3 -1
  19. package/dist/hash/digest.d.ts +10 -0
  20. package/dist/hash/digest.js +40 -0
  21. package/dist/hash/stream.d.ts +12 -0
  22. package/dist/hash/stream.js +27 -0
  23. package/dist/hash/text.d.ts +3 -1
  24. package/dist/hash/text.js +2 -15
  25. package/dist/limits.d.ts +2 -2
  26. package/dist/limits.js +2 -2
  27. package/dist/preview/auth.d.ts +4 -2
  28. package/dist/preview/auth.js +26 -12
  29. package/dist/program/snapshot/digest.d.ts +3 -1
  30. package/dist/program/snapshot/digest.js +14 -22
  31. package/dist/program/snapshot/hash.d.ts +6 -2
  32. package/dist/program/snapshot/hash.js +10 -21
  33. package/dist/projection/digest.d.ts +11 -9
  34. package/dist/projection/digest.js +23 -32
  35. package/dist/projection/hash.d.ts +222 -2
  36. package/dist/projection/hash.js +6 -8
  37. package/dist/projection/verify.d.ts +16 -6
  38. package/dist/question/item.d.ts +3 -1
  39. package/dist/question/item.js +3 -1
  40. package/dist/quran/notes.d.ts +3 -1
  41. package/dist/quran/provenance.d.ts +6 -2
  42. package/dist/quran/provenance.js +8 -15
  43. package/dist/quran/snapshot/digest.d.ts +9 -5
  44. package/dist/quran/snapshot/digest.js +33 -41
  45. package/dist/quran/snapshot/hash.d.ts +3 -1
  46. package/dist/quran/snapshot/hash.js +9 -15
  47. package/dist/quran/snapshot/row/hash.d.ts +3 -1
  48. package/dist/quran/snapshot/row/hash.js +2 -8
  49. package/dist/release/digest.d.ts +10 -8
  50. package/dist/release/digest.js +22 -31
  51. package/dist/release/hash.d.ts +3 -1
  52. package/dist/release/hash.js +3 -8
  53. package/dist/release/items.d.ts +25 -9
  54. package/dist/release/items.js +12 -3
  55. package/dist/release/policy.d.ts +3 -1
  56. package/dist/release/result/digest.d.ts +23 -13
  57. package/dist/release/result/digest.js +20 -29
  58. package/dist/release/rollback/digest.d.ts +16 -10
  59. package/dist/release/rollback/digest.js +25 -32
  60. package/dist/release/rollback/spec.d.ts +102 -24
  61. package/dist/release/route/digest.d.ts +10 -8
  62. package/dist/release/route/digest.js +22 -31
  63. package/dist/release/route/verify.d.ts +16 -6
  64. package/dist/release/route/verify.js +8 -2
  65. package/dist/release/snapshot/evidence/requirement.d.ts +3 -1
  66. package/dist/release/snapshot/evidence/tryout.d.ts +1 -1
  67. package/dist/release/snapshot/evidence/tryout.js +1 -1
  68. package/dist/release/snapshot/evidence.d.ts +1 -1
  69. package/dist/release/snapshot/verify.d.ts +19 -7
  70. package/dist/release/snapshot/verify.js +20 -18
  71. package/dist/release/verify.d.ts +9 -3
  72. package/dist/renderer/compatibility.d.ts +6 -2
  73. package/dist/renderer/compatibility.js +3 -1
  74. package/dist/renderer/contract.d.ts +9 -3
  75. package/dist/renderer/contract.js +3 -1
  76. package/dist/runtime/error.d.ts +3 -1
  77. package/dist/runtime/protected/spec.d.ts +61 -16
  78. package/dist/runtime/protected/verify.d.ts +11 -5
  79. package/dist/runtime/spec.d.ts +44 -12
  80. package/dist/runtime/verify.d.ts +22 -10
  81. package/dist/runtime/verify.js +2 -1
  82. package/dist/signature/key.d.ts +21 -0
  83. package/dist/signature/key.js +104 -0
  84. package/dist/signature/spec.d.ts +18 -6
  85. package/dist/signature/spec.js +16 -4
  86. package/dist/transport/batch.d.ts +34 -8
  87. package/dist/transport/group.d.ts +51 -12
  88. package/dist/transport/request.d.ts +826 -764
  89. package/dist/transport/response.d.ts +148 -58
  90. package/dist/tree.d.ts +52 -0
  91. package/dist/tree.js +162 -0
  92. package/dist/tryout/canonical.d.ts +11 -1
  93. package/dist/tryout/canonical.js +6 -10
  94. package/dist/tryout/closure/accounting.d.ts +3 -1
  95. package/dist/tryout/digest.d.ts +12 -6
  96. package/dist/tryout/digest.js +21 -14
  97. package/dist/tryout/hash/catalog.d.ts +228 -3
  98. package/dist/tryout/hash/catalog.js +5 -7
  99. package/dist/tryout/hash/content.d.ts +113 -2
  100. package/dist/tryout/hash/content.js +10 -8
  101. package/dist/tryout/hash/placement.d.ts +236 -5
  102. package/dist/tryout/hash/placement.js +7 -8
  103. package/dist/tryout/runtime/hash.d.ts +3 -1
  104. package/dist/tryout/runtime/hash.js +3 -1
  105. package/dist/tryout/runtime/source.d.ts +3 -1
  106. package/dist/tryout/runtime/verify.d.ts +13 -5
  107. package/dist/tryout/runtime/verify.js +1 -1
  108. package/dist/tryout/scoring.d.ts +3 -1
  109. package/dist/tryout/snapshot/hash.d.ts +45 -4
  110. package/dist/tryout/snapshot/hash.js +9 -7
  111. package/package.json +22 -2
@@ -232,12 +232,25 @@ export declare const RollbackUpsertStateSchema: Schema.Struct<{
232
232
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
233
233
  readonly payload: Schema.Struct<{
234
234
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
235
- readonly byteLength: Schema.Finite;
236
- readonly compiledCode: Schema.String;
237
235
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
238
- readonly compilerVersion: Schema.Literal<"0.1.0">;
236
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
239
237
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
240
- readonly format: Schema.Literal<"mdx-function-body">;
238
+ readonly contentTree: Schema.Codec<{
239
+ readonly $node: "element";
240
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
241
+ readonly name: import("../../tree.js").ContentTreeElementName;
242
+ readonly props: {
243
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
244
+ };
245
+ }, {
246
+ readonly $node: "element";
247
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
248
+ readonly name: import("../../tree.js").ContentTreeElementName;
249
+ readonly props: {
250
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
251
+ };
252
+ }, never, never>;
253
+ readonly format: Schema.Literal<"content-tree">;
241
254
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
242
255
  readonly plainText: Schema.String;
243
256
  readonly rawMdx: Schema.String;
@@ -480,12 +493,25 @@ export declare const RollbackStateSchema: Schema.Union<readonly [Schema.Struct<{
480
493
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
481
494
  readonly payload: Schema.Struct<{
482
495
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
483
- readonly byteLength: Schema.Finite;
484
- readonly compiledCode: Schema.String;
485
496
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
486
- readonly compilerVersion: Schema.Literal<"0.1.0">;
497
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
487
498
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
488
- readonly format: Schema.Literal<"mdx-function-body">;
499
+ readonly contentTree: Schema.Codec<{
500
+ readonly $node: "element";
501
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
502
+ readonly name: import("../../tree.js").ContentTreeElementName;
503
+ readonly props: {
504
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
505
+ };
506
+ }, {
507
+ readonly $node: "element";
508
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
509
+ readonly name: import("../../tree.js").ContentTreeElementName;
510
+ readonly props: {
511
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
512
+ };
513
+ }, never, never>;
514
+ readonly format: Schema.Literal<"content-tree">;
489
515
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
490
516
  readonly plainText: Schema.String;
491
517
  readonly rawMdx: Schema.String;
@@ -726,12 +752,25 @@ export declare const RollbackRecordSchema: Schema.Struct<{
726
752
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
727
753
  readonly payload: Schema.Struct<{
728
754
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
729
- readonly byteLength: Schema.Finite;
730
- readonly compiledCode: Schema.String;
731
755
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
732
- readonly compilerVersion: Schema.Literal<"0.1.0">;
756
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
733
757
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
734
- readonly format: Schema.Literal<"mdx-function-body">;
758
+ readonly contentTree: Schema.Codec<{
759
+ readonly $node: "element";
760
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
761
+ readonly name: import("../../tree.js").ContentTreeElementName;
762
+ readonly props: {
763
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
764
+ };
765
+ }, {
766
+ readonly $node: "element";
767
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
768
+ readonly name: import("../../tree.js").ContentTreeElementName;
769
+ readonly props: {
770
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
771
+ };
772
+ }, never, never>;
773
+ readonly format: Schema.Literal<"content-tree">;
735
774
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
736
775
  readonly plainText: Schema.String;
737
776
  readonly rawMdx: Schema.String;
@@ -970,12 +1009,25 @@ export declare const RollbackRecordSchema: Schema.Struct<{
970
1009
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
971
1010
  readonly payload: Schema.Struct<{
972
1011
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
973
- readonly byteLength: Schema.Finite;
974
- readonly compiledCode: Schema.String;
975
1012
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
976
- readonly compilerVersion: Schema.Literal<"0.1.0">;
1013
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
977
1014
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
978
- readonly format: Schema.Literal<"mdx-function-body">;
1015
+ readonly contentTree: Schema.Codec<{
1016
+ readonly $node: "element";
1017
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1018
+ readonly name: import("../../tree.js").ContentTreeElementName;
1019
+ readonly props: {
1020
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1021
+ };
1022
+ }, {
1023
+ readonly $node: "element";
1024
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1025
+ readonly name: import("../../tree.js").ContentTreeElementName;
1026
+ readonly props: {
1027
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1028
+ };
1029
+ }, never, never>;
1030
+ readonly format: Schema.Literal<"content-tree">;
979
1031
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
980
1032
  readonly plainText: Schema.String;
981
1033
  readonly rawMdx: Schema.String;
@@ -1228,12 +1280,25 @@ export declare const RollbackPageSchema: Schema.Struct<{
1228
1280
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
1229
1281
  readonly payload: Schema.Struct<{
1230
1282
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
1231
- readonly byteLength: Schema.Finite;
1232
- readonly compiledCode: Schema.String;
1233
1283
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
1234
- readonly compilerVersion: Schema.Literal<"0.1.0">;
1284
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
1235
1285
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
1236
- readonly format: Schema.Literal<"mdx-function-body">;
1286
+ readonly contentTree: Schema.Codec<{
1287
+ readonly $node: "element";
1288
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1289
+ readonly name: import("../../tree.js").ContentTreeElementName;
1290
+ readonly props: {
1291
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1292
+ };
1293
+ }, {
1294
+ readonly $node: "element";
1295
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1296
+ readonly name: import("../../tree.js").ContentTreeElementName;
1297
+ readonly props: {
1298
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1299
+ };
1300
+ }, never, never>;
1301
+ readonly format: Schema.Literal<"content-tree">;
1237
1302
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
1238
1303
  readonly plainText: Schema.String;
1239
1304
  readonly rawMdx: Schema.String;
@@ -1472,12 +1537,25 @@ export declare const RollbackPageSchema: Schema.Struct<{
1472
1537
  readonly keyId: Schema.brand<Schema.String, "@NakafaAI/AksaraSigningKeyId">;
1473
1538
  readonly payload: Schema.Struct<{
1474
1539
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
1475
- readonly byteLength: Schema.Finite;
1476
- readonly compiledCode: Schema.String;
1477
1540
  readonly compilerConfigHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
1478
- readonly compilerVersion: Schema.Literal<"0.1.0">;
1541
+ readonly compilerVersion: Schema.Literal<"0.2.0">;
1479
1542
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
1480
- readonly format: Schema.Literal<"mdx-function-body">;
1543
+ readonly contentTree: Schema.Codec<{
1544
+ readonly $node: "element";
1545
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1546
+ readonly name: import("../../tree.js").ContentTreeElementName;
1547
+ readonly props: {
1548
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1549
+ };
1550
+ }, {
1551
+ readonly $node: "element";
1552
+ readonly children: readonly import("../../tree.js").ContentTreeChild[];
1553
+ readonly name: import("../../tree.js").ContentTreeElementName;
1554
+ readonly props: {
1555
+ readonly [key: string]: import("../../tree.js").ContentTreeValue;
1556
+ };
1557
+ }, never, never>;
1558
+ readonly format: Schema.Literal<"content-tree">;
1481
1559
  readonly mdxCompilerVersion: Schema.Literal<"3.1.1">;
1482
1560
  readonly plainText: Schema.String;
1483
1561
  readonly rawMdx: Schema.String;
@@ -3,28 +3,30 @@ import { type ReleaseId } from "#contracts/ids";
3
3
  import { type ContentRouteItem } from "#contracts/release/route/spec";
4
4
  declare const RouteHashError_base: Schema.Class<RouteHashError, Schema.TaggedStruct<"RouteHashError", {
5
5
  readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
6
- }>, import("effect/Cause").YieldableError>;
6
+ }>, import("effect/Cause").YieldableError & {
7
+ readonly brand: unique symbol;
8
+ }>;
7
9
  /** SHA-256 computation failed before route integrity was established. */
8
10
  export declare class RouteHashError extends RouteHashError_base {
9
11
  }
10
- /** Keeps incremental route hash state private to one release preparation. */
12
+ /** Keeps incremental route digest state private to one release preparation. */
11
13
  declare class RouteDigestState {
12
14
  #private;
13
15
  count: number;
14
- /** Initializes a domain-separated incremental route hash. */
16
+ /** Starts a domain-separated route digest. */
15
17
  constructor();
16
18
  /** Adds one canonical route item to this invocation-owned digest. */
17
19
  update(item: ContentRouteItem): void;
18
- /** Consumes the route hash and returns its branded identity. */
19
- digest(): string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
20
+ /** Digests the complete route stream once and returns its branded identity. */
21
+ digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
20
22
  }
21
23
  /** Creates fresh domain-separated route digest state. */
22
- export declare function createRouteDigest(releaseId: ReleaseId): Effect.Effect<RouteDigestState, RouteHashError, never>;
24
+ export declare const createRouteDigest: Effect.Effect<RouteDigestState, never, never>;
23
25
  /** Adds one canonical route item to an incremental digest. */
24
- export declare function updateRouteDigest(releaseId: ReleaseId, state: RouteDigestState, item: ContentRouteItem): Effect.Effect<RouteDigestState, RouteHashError, never>;
26
+ export declare function updateRouteDigest(state: RouteDigestState, item: ContentRouteItem): Effect.Effect<RouteDigestState, never, never>;
25
27
  /** Completes one incremental route digest with typed hash failures. */
26
28
  export declare function completeRouteDigest(releaseId: ReleaseId, state: RouteDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, RouteHashError, never>;
27
- /** Digests a canonical route stream without retaining its rows. */
29
+ /** Digests a canonical route stream. Its canonical bytes are held until one Web Crypto digest runs. */
28
30
  export declare const digestRoutes: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, routes: Stream.Stream<{
29
31
  readonly change: {
30
32
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
@@ -1,59 +1,50 @@
1
- import { createHash } from "node:crypto";
2
1
  import { Effect, Schema, Stream } from "effect";
3
- import { ReleaseIdSchema, Sha256HashSchema, } from "#contracts/ids";
2
+ import { DigestStream } from "#contracts/hash/stream";
3
+ import { ReleaseIdSchema } from "#contracts/ids";
4
4
  import { canonicalizeContentRouteItem, } from "#contracts/release/route/spec";
5
5
  const CONTENT_ROUTE_DIGEST_DOMAIN = "nakafa.aksara.content-routes";
6
6
  /** SHA-256 computation failed before route integrity was established. */
7
7
  export class RouteHashError extends Schema.TaggedError()("RouteHashError", { releaseId: ReleaseIdSchema }) {
8
8
  }
9
- /** Keeps incremental route hash state private to one release preparation. */
9
+ /** Keeps incremental route digest state private to one release preparation. */
10
10
  class RouteDigestState {
11
- #hash = createHash("sha256");
11
+ #stream = new DigestStream();
12
12
  count = 0;
13
- /** Initializes a domain-separated incremental route hash. */
13
+ /** Starts a domain-separated route digest. */
14
14
  constructor() {
15
- this.#hash.update(CONTENT_ROUTE_DIGEST_DOMAIN);
16
- this.#hash.update("\n");
15
+ this.#stream.add(CONTENT_ROUTE_DIGEST_DOMAIN);
16
+ this.#stream.add("\n");
17
17
  }
18
18
  /** Adds one canonical route item to this invocation-owned digest. */
19
19
  update(item) {
20
- this.#hash.update(canonicalizeContentRouteItem(item));
21
- this.#hash.update("\n");
20
+ this.#stream.add(canonicalizeContentRouteItem(item));
21
+ this.#stream.add("\n");
22
22
  this.count += 1;
23
23
  }
24
- /** Consumes the route hash and returns its branded identity. */
24
+ /** Digests the complete route stream once and returns its branded identity. */
25
25
  digest() {
26
- return Sha256HashSchema.make(`sha256:${this.#hash.digest("hex")}`);
26
+ return this.#stream.digest();
27
27
  }
28
28
  }
29
29
  /** Creates fresh domain-separated route digest state. */
30
- export function createRouteDigest(releaseId) {
31
- return Effect.try({
32
- catch: () => new RouteHashError({ releaseId }),
33
- try: () => new RouteDigestState(),
34
- });
35
- }
30
+ export const createRouteDigest = Effect.sync(() => new RouteDigestState());
36
31
  /** Adds one canonical route item to an incremental digest. */
37
- export function updateRouteDigest(releaseId, state, item) {
38
- return Effect.try({
39
- catch: () => new RouteHashError({ releaseId }),
40
- try: () => {
41
- state.update(item);
42
- return state;
43
- },
32
+ export function updateRouteDigest(state, item) {
33
+ return Effect.sync(() => {
34
+ state.update(item);
35
+ return state;
44
36
  });
45
37
  }
46
38
  /** Completes one incremental route digest with typed hash failures. */
47
39
  export function completeRouteDigest(releaseId, state) {
48
- return Effect.try({
49
- catch: () => new RouteHashError({ releaseId }),
50
- try: () => state.digest(),
51
- });
40
+ return state
41
+ .digest()
42
+ .pipe(Effect.mapError(() => new RouteHashError({ releaseId })));
52
43
  }
53
- /** Digests a canonical route stream without retaining its rows. */
44
+ /** Digests a canonical route stream. Its canonical bytes are held until one Web Crypto digest runs. */
54
45
  export const digestRoutes = Effect.fn("AksaraContracts.digestRoutes")(function* (releaseId, routes) {
55
- const initial = yield* createRouteDigest(releaseId);
56
- const state = yield* routes.pipe(Stream.runFoldEffect(() => initial, (current, route) => updateRouteDigest(releaseId, current, route)));
46
+ const initial = yield* createRouteDigest;
47
+ const state = yield* routes.pipe(Stream.runFoldEffect(() => initial, (current, route) => updateRouteDigest(current, route)));
57
48
  const digest = yield* completeRouteDigest(releaseId, state);
58
49
  return { count: state.count, digest };
59
50
  });
@@ -2,27 +2,35 @@ import { Effect, Schema, Stream } from "effect";
2
2
  import type { ContentReleaseManifest } from "#contracts/release/spec";
3
3
  declare const RouteDecodeError_base: Schema.Class<RouteDecodeError, Schema.TaggedStruct<"RouteDecodeError", {
4
4
  readonly routeOffset: Schema.Finite;
5
- }>, import("effect/Cause").YieldableError>;
5
+ }>, import("effect/Cause").YieldableError & {
6
+ readonly brand: unique symbol;
7
+ }>;
6
8
  /** One streamed route failed strict wire decoding. */
7
9
  export declare class RouteDecodeError extends RouteDecodeError_base {
8
10
  }
9
11
  declare const RouteIdentityError_base: Schema.Class<RouteIdentityError, Schema.TaggedStruct<"RouteIdentityError", {
10
12
  readonly routeOffset: Schema.Finite;
11
- }>, import("effect/Cause").YieldableError>;
13
+ }>, import("effect/Cause").YieldableError & {
14
+ readonly brand: unique symbol;
15
+ }>;
12
16
  /** One route belongs to another release or sequence position. */
13
17
  export declare class RouteIdentityError extends RouteIdentityError_base {
14
18
  }
15
19
  declare const RouteDuplicateError_base: Schema.Class<RouteDuplicateError, Schema.TaggedStruct<"RouteDuplicateError", {
16
20
  readonly firstIndex: Schema.Finite;
17
21
  readonly publicPath: Schema.brand<Schema.String, "@NakafaAI/AksaraPublicPath">;
18
- }>, import("effect/Cause").YieldableError>;
22
+ }>, import("effect/Cause").YieldableError & {
23
+ readonly brand: unique symbol;
24
+ }>;
19
25
  /** Two changes in one release target the same locale-specific route. */
20
26
  export declare class RouteDuplicateError extends RouteDuplicateError_base {
21
27
  }
22
28
  declare const RouteCountError_base: Schema.Class<RouteCountError, Schema.TaggedStruct<"RouteCountError", {
23
29
  readonly actualCount: Schema.Finite;
24
30
  readonly expectedCount: Schema.Finite;
25
- }>, import("effect/Cause").YieldableError>;
31
+ }>, import("effect/Cause").YieldableError & {
32
+ readonly brand: unique symbol;
33
+ }>;
26
34
  /** The streamed route count differs from its signed manifest. */
27
35
  export declare class RouteCountError extends RouteCountError_base {
28
36
  }
@@ -30,14 +38,16 @@ declare const RouteDigestError_base: Schema.Class<RouteDigestError, Schema.Tagge
30
38
  readonly actualDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
31
39
  readonly expectedDigest: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
32
40
  readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
33
- }>, import("effect/Cause").YieldableError>;
41
+ }>, import("effect/Cause").YieldableError & {
42
+ readonly brand: unique symbol;
43
+ }>;
34
44
  /** The streamed route digest differs from its signed manifest. */
35
45
  export declare class RouteDigestError extends RouteDigestError_base {
36
46
  }
37
47
  declare const VerifiedContentRoutesSchema: Schema.Struct<{
38
48
  readonly count: Schema.Finite;
39
49
  }>;
40
- /** Count authenticated without retaining complete route rows. */
50
+ /** Count authenticated against the signed manifest. The digest holds every canonical byte until its one final call, so its memory grows with the stream. */
41
51
  export type VerifiedContentRoutes = typeof VerifiedContentRoutesSchema.Type;
42
52
  /** Strictly decodes one replayable canonical route stream. */
43
53
  export declare function decodeContentRoutes<E, R>(input: {
@@ -12,10 +12,16 @@ export class RouteDecodeError extends Schema.TaggedError()("RouteDecodeError", {
12
12
  export class RouteIdentityError extends Schema.TaggedError()("RouteIdentityError", { routeOffset: ReleaseCountSchema }) {
13
13
  }
14
14
  /** Two changes in one release target the same locale-specific route. */
15
- export class RouteDuplicateError extends Schema.TaggedError()("RouteDuplicateError", { firstIndex: ReleaseCountSchema, publicPath: PublicPathSchema }) {
15
+ export class RouteDuplicateError extends Schema.TaggedError()("RouteDuplicateError", {
16
+ firstIndex: ReleaseCountSchema,
17
+ publicPath: PublicPathSchema,
18
+ }) {
16
19
  }
17
20
  /** The streamed route count differs from its signed manifest. */
18
- export class RouteCountError extends Schema.TaggedError()("RouteCountError", { actualCount: ReleaseCountSchema, expectedCount: ReleaseCountSchema }) {
21
+ export class RouteCountError extends Schema.TaggedError()("RouteCountError", {
22
+ actualCount: ReleaseCountSchema,
23
+ expectedCount: ReleaseCountSchema,
24
+ }) {
19
25
  }
20
26
  /** The streamed route digest differs from its signed manifest. */
21
27
  export class RouteDigestError extends Schema.TaggedError()("RouteDigestError", { ...ReleaseDigestMismatchFields }) {
@@ -7,7 +7,9 @@ declare const SnapshotEvidenceError_base: Schema.Class<SnapshotEvidenceError, Sc
7
7
  readonly expected: Schema.String;
8
8
  readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
9
9
  readonly field: Schema.String;
10
- }>, import("effect/Cause").YieldableError>;
10
+ }>, import("effect/Cause").YieldableError & {
11
+ readonly brand: unique symbol;
12
+ }>;
11
13
  /** Signed snapshot evidence differs from its authenticated row stream. */
12
14
  export declare class SnapshotEvidenceError extends SnapshotEvidenceError_base {
13
15
  }
@@ -19,4 +19,4 @@ export declare const verifyTryoutSnapshotRows: <E, R>(snapshot: {
19
19
  readonly format: "localized-tryout-snapshot";
20
20
  readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
21
21
  };
22
- }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../../tryout/closure/accounting.js").TryoutClosureError | import("../../../tryout/digest.js").TryoutDigestError | import("../../../tryout/scoring.js").TryoutScoringError, R>;
22
+ }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("effect/PlatformError").PlatformError | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../../tryout/canonical.js").TryoutCanonicalHashError | import("../../../tryout/closure/accounting.js").TryoutClosureError | import("../../../tryout/digest.js").TryoutDigestError | import("../../../tryout/scoring.js").TryoutScoringError, R>;
@@ -80,7 +80,7 @@ export const verifyTryoutSnapshotRows = Effect.fn("AksaraContracts.verifyTryoutS
80
80
  field: "routeCount",
81
81
  });
82
82
  const { format: _format, snapshotId, ...facts } = snapshot.manifest;
83
- const actualId = makeTryoutSnapshot(facts).snapshotId;
83
+ const actualId = (yield* makeTryoutSnapshot(facts)).snapshotId;
84
84
  yield* requireSnapshotEvidence({
85
85
  actual: actualId,
86
86
  expected: snapshotId,
@@ -55,4 +55,4 @@ export declare const verifySnapshotRows: <E, R>(snapshot: {
55
55
  readonly format: "localized-tryout-snapshot";
56
56
  readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
57
57
  };
58
- }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("../../program/snapshot/digest.js").ProgramDigestError | import("../../program/snapshot/hash.js").ProgramRowHashError | import("../../program/snapshot/hash.js").ProgramSnapshotHashError | import("../../quran/snapshot/row/hash.js").QuranRowHashError | import("../../quran/snapshot/digest.js").QuranRowIntegrityError | import("../../quran/snapshot/digest.js").QuranRowOrderError | import("../../quran/snapshot/hash.js").QuranSnapshotHashError | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../tryout/closure/accounting.js").TryoutClosureError | import("../../tryout/digest.js").TryoutDigestError | import("../../tryout/scoring.js").TryoutScoringError, R>;
58
+ }, rows: SnapshotRowSource<E, R>) => Effect.Effect<number, E | import("effect/PlatformError").PlatformError | import("../../program/snapshot/digest.js").ProgramDigestError | import("../../program/snapshot/hash.js").ProgramRowHashError | import("../../program/snapshot/hash.js").ProgramSnapshotHashError | import("../../quran/snapshot/row/hash.js").QuranRowHashError | import("../../quran/snapshot/digest.js").QuranRowIntegrityError | import("../../quran/snapshot/digest.js").QuranRowOrderError | import("../../quran/snapshot/hash.js").QuranSnapshotHashError | import("#contracts/release/snapshot/evidence/requirement").SnapshotEvidenceError | import("../../tryout/canonical.js").TryoutCanonicalHashError | import("../../tryout/closure/accounting.js").TryoutClosureError | import("../../tryout/digest.js").TryoutDigestError | import("../../tryout/scoring.js").TryoutScoringError, R>;
@@ -2,7 +2,9 @@ import { Effect, Schema, Stream } from "effect";
2
2
  import { type ContentSnapshotSet } from "#contracts/release/snapshot/spec";
3
3
  declare const SnapshotManifestDecodeError_base: Schema.Class<SnapshotManifestDecodeError, Schema.TaggedStruct<"SnapshotManifestDecodeError", {
4
4
  readonly manifestIndex: Schema.Int;
5
- }>, import("effect/Cause").YieldableError>;
5
+ }>, import("effect/Cause").YieldableError & {
6
+ readonly brand: unique symbol;
7
+ }>;
6
8
  /** One replacement manifest failed strict wire decoding. */
7
9
  export declare class SnapshotManifestDecodeError extends SnapshotManifestDecodeError_base {
8
10
  }
@@ -10,26 +12,34 @@ declare const SnapshotManifestOrderError_base: Schema.Class<SnapshotManifestOrde
10
12
  readonly actualFamily: Schema.Literals<readonly ["program", "quran", "tryout"]>;
11
13
  readonly manifestIndex: Schema.Int;
12
14
  readonly previousFamily: Schema.Literals<readonly ["program", "quran", "tryout"]>;
13
- }>, import("effect/Cause").YieldableError>;
15
+ }>, import("effect/Cause").YieldableError & {
16
+ readonly brand: unique symbol;
17
+ }>;
14
18
  /** Replacement manifests are duplicated or outside canonical family order. */
15
19
  export declare class SnapshotManifestOrderError extends SnapshotManifestOrderError_base {
16
20
  }
17
21
  declare const SnapshotRowDecodeError_base: Schema.Class<SnapshotRowDecodeError, Schema.TaggedStruct<"SnapshotRowDecodeError", {
18
22
  readonly rowIndex: Schema.Int;
19
- }>, import("effect/Cause").YieldableError>;
23
+ }>, import("effect/Cause").YieldableError & {
24
+ readonly brand: unique symbol;
25
+ }>;
20
26
  /** One structured snapshot row failed strict wire decoding. */
21
27
  export declare class SnapshotRowDecodeError extends SnapshotRowDecodeError_base {
22
28
  }
23
29
  declare const SnapshotRowFamilyError_base: Schema.Class<SnapshotRowFamilyError, Schema.TaggedStruct<"SnapshotRowFamilyError", {
24
30
  readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
25
31
  readonly rowIndex: Schema.Int;
26
- }>, import("effect/Cause").YieldableError>;
32
+ }>, import("effect/Cause").YieldableError & {
33
+ readonly brand: unique symbol;
34
+ }>;
27
35
  /** A staged row belongs to a family this release does not replace. */
28
36
  export declare class SnapshotRowFamilyError extends SnapshotRowFamilyError_base {
29
37
  }
30
38
  declare const SnapshotTransitionError_base: Schema.Class<SnapshotTransitionError, Schema.TaggedStruct<"SnapshotTransitionError", {
31
39
  readonly family: Schema.Literals<readonly ["program", "quran", "tryout"]>;
32
- }>, import("effect/Cause").YieldableError>;
40
+ }>, import("effect/Cause").YieldableError & {
41
+ readonly brand: unique symbol;
42
+ }>;
33
43
  /** A replacement manifest cannot form a coherent forward transition. */
34
44
  export declare class SnapshotTransitionError extends SnapshotTransitionError_base {
35
45
  }
@@ -37,7 +47,9 @@ declare const SnapshotStagedCountError_base: Schema.Class<SnapshotStagedCountErr
37
47
  readonly actualCount: Schema.Int;
38
48
  readonly expectedCount: Schema.Int;
39
49
  readonly verifiedCount: Schema.Int;
40
- }>, import("effect/Cause").YieldableError>;
50
+ }>, import("effect/Cause").YieldableError & {
51
+ readonly brand: unique symbol;
52
+ }>;
41
53
  /** The staged row stream count differs from all signed family evidence. */
42
54
  export declare class SnapshotStagedCountError extends SnapshotStagedCountError_base {
43
55
  }
@@ -730,5 +742,5 @@ export declare const verifyContentSnapshots: <ManifestError, ManifestContext, Ro
730
742
  };
731
743
  };
732
744
  stagedRows: number;
733
- }, ManifestError | RowError | import("../../program/snapshot/digest.js").ProgramDigestError | import("../../program/snapshot/hash.js").ProgramRowHashError | import("../../program/snapshot/hash.js").ProgramSnapshotHashError | import("../../quran/snapshot/row/hash.js").QuranRowHashError | import("../../quran/snapshot/digest.js").QuranRowIntegrityError | import("../../quran/snapshot/digest.js").QuranRowOrderError | import("../../quran/snapshot/hash.js").QuranSnapshotHashError | import("./evidence/requirement.js").SnapshotEvidenceError | SnapshotManifestDecodeError | SnapshotManifestOrderError | SnapshotRowDecodeError | SnapshotRowFamilyError | SnapshotStagedCountError | SnapshotTransitionError | import("../../tryout/closure/accounting.js").TryoutClosureError | import("../../tryout/digest.js").TryoutDigestError | import("../../tryout/scoring.js").TryoutScoringError, ManifestContext | RowContext>;
745
+ }, ManifestError | RowError | import("effect/PlatformError").PlatformError | import("../../program/snapshot/digest.js").ProgramDigestError | import("../../program/snapshot/hash.js").ProgramRowHashError | import("../../program/snapshot/hash.js").ProgramSnapshotHashError | import("../../quran/snapshot/row/hash.js").QuranRowHashError | import("../../quran/snapshot/digest.js").QuranRowIntegrityError | import("../../quran/snapshot/digest.js").QuranRowOrderError | import("../../quran/snapshot/hash.js").QuranSnapshotHashError | import("./evidence/requirement.js").SnapshotEvidenceError | SnapshotManifestDecodeError | SnapshotManifestOrderError | SnapshotRowDecodeError | SnapshotRowFamilyError | SnapshotStagedCountError | SnapshotTransitionError | import("../../tryout/canonical.js").TryoutCanonicalHashError | import("../../tryout/closure/accounting.js").TryoutClosureError | import("../../tryout/digest.js").TryoutDigestError | import("../../tryout/scoring.js").TryoutScoringError, ManifestContext | RowContext>;
734
746
  export {};
@@ -46,16 +46,16 @@ const familyOrder = {
46
46
  /** Derives one replacement's aggregate row evidence in its owning runtime. */
47
47
  function snapshotRowEvidence(snapshot) {
48
48
  if (snapshot.family === "program") {
49
- return {
49
+ return Effect.succeed({
50
50
  rowCount: snapshot.manifest.rowCount,
51
51
  rowDigest: snapshot.manifest.rowDigest,
52
- };
52
+ });
53
53
  }
54
54
  if (snapshot.family === "quran") {
55
- return {
55
+ return Effect.succeed({
56
56
  rowCount: snapshot.manifest.projectionCount,
57
57
  rowDigest: snapshot.manifest.projectionDigest,
58
- };
58
+ });
59
59
  }
60
60
  return tryoutSnapshotRowEvidence(snapshot.manifest);
61
61
  }
@@ -92,20 +92,22 @@ export function decodeContentSnapshotRows(rows) {
92
92
  }
93
93
  /** Replaces one inherited family state without weakening schema filters. */
94
94
  function replaceSnapshotState(snapshots, snapshot) {
95
- return Effect.try({
96
- catch: () => new SnapshotTransitionError({ family: snapshot.family }),
97
- try: () => {
98
- const baseSnapshotId = snapshots[snapshot.family].resultSnapshotId;
99
- const evidence = snapshotRowEvidence(snapshot);
100
- return ContentSnapshotSetSchema.make({
101
- ...snapshots,
102
- [snapshot.family]: replaceContentSnapshot({
103
- baseSnapshotId,
104
- resultSnapshotId: snapshot.manifest.snapshotId,
105
- ...evidence,
106
- }),
107
- });
108
- },
95
+ return Effect.gen(function* () {
96
+ const evidence = yield* snapshotRowEvidence(snapshot);
97
+ return yield* Effect.try({
98
+ catch: () => new SnapshotTransitionError({ family: snapshot.family }),
99
+ try: () => {
100
+ const baseSnapshotId = snapshots[snapshot.family].resultSnapshotId;
101
+ return ContentSnapshotSetSchema.make({
102
+ ...snapshots,
103
+ [snapshot.family]: replaceContentSnapshot({
104
+ baseSnapshotId,
105
+ resultSnapshotId: snapshot.manifest.snapshotId,
106
+ ...evidence,
107
+ }),
108
+ });
109
+ },
110
+ });
109
111
  });
110
112
  }
111
113
  /** Derives all fixed family states from prior results and replacements. */
@@ -2,7 +2,9 @@ import { Effect, Schema } from "effect";
2
2
  import { type ContentReleaseBundle, type RollbackContentReleaseBundle } from "#contracts/release/lifecycle";
3
3
  declare const ReleaseVerificationDecodeError_base: Schema.Class<ReleaseVerificationDecodeError, Schema.TaggedStruct<"ReleaseVerificationDecodeError", {
4
4
  readonly message: Schema.Literal<"Release verification input does not satisfy its exact wire contract.">;
5
- }>, import("effect/Cause").YieldableError>;
5
+ }>, import("effect/Cause").YieldableError & {
6
+ readonly brand: unique symbol;
7
+ }>;
6
8
  /** Unknown release input did not exactly satisfy its signed wire contract. */
7
9
  export declare class ReleaseVerificationDecodeError extends ReleaseVerificationDecodeError_base {
8
10
  }
@@ -10,13 +12,17 @@ declare const ReleaseManifestHashMismatchError_base: Schema.Class<ReleaseManifes
10
12
  readonly actualHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
11
13
  readonly expectedHash: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
12
14
  readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
13
- }>, import("effect/Cause").YieldableError>;
15
+ }>, import("effect/Cause").YieldableError & {
16
+ readonly brand: unique symbol;
17
+ }>;
14
18
  /** The envelope hash does not identify its complete canonical manifest. */
15
19
  export declare class ReleaseManifestHashMismatchError extends ReleaseManifestHashMismatchError_base {
16
20
  }
17
21
  declare const ReleaseBundleVerificationDecodeError_base: Schema.Class<ReleaseBundleVerificationDecodeError, Schema.TaggedStruct<"ReleaseBundleVerificationDecodeError", {
18
22
  readonly message: Schema.Literal<"Release bundle verification input does not satisfy its exact wire contract.">;
19
- }>, import("effect/Cause").YieldableError>;
23
+ }>, import("effect/Cause").YieldableError & {
24
+ readonly brand: unique symbol;
25
+ }>;
20
26
  /** Stored release recovery input does not satisfy its exact bundle contract. */
21
27
  export declare class ReleaseBundleVerificationDecodeError extends ReleaseBundleVerificationDecodeError_base {
22
28
  }
@@ -4,14 +4,18 @@ import type { CompiledContentPayload } from "#contracts/content";
4
4
  import { type RendererManifestEnvelope } from "#contracts/renderer/contract";
5
5
  declare const RendererManifestDomainUnpublishedError_base: Schema.Class<RendererManifestDomainUnpublishedError, Schema.TaggedStruct<"RendererManifestDomainUnpublishedError", {
6
6
  readonly rendererDomain: Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>;
7
- }>, import("effect/Cause").YieldableError>;
7
+ }>, import("effect/Cause").YieldableError & {
8
+ readonly brand: unique symbol;
9
+ }>;
8
10
  /** A live renderer no longer publishes one domain frozen by a signed release. */
9
11
  export declare class RendererManifestDomainUnpublishedError extends RendererManifestDomainUnpublishedError_base {
10
12
  }
11
13
  declare const RendererManifestComponentUnsupportedError_base: Schema.Class<RendererManifestComponentUnsupportedError, Schema.TaggedStruct<"RendererManifestComponentUnsupportedError", {
12
14
  readonly componentName: Schema.String;
13
15
  readonly rendererScope: Schema.Union<readonly [Schema.Literal<"base">, Schema.Literals<readonly ["ai-ds", "biology", "chemistry", "mathematics", "physics", "politics", "site", "snbt-general", "snbt-math", "snbt-plain", "snbt-quant", "tka-math"]>]>;
14
- }>, import("effect/Cause").YieldableError>;
16
+ }>, import("effect/Cause").YieldableError & {
17
+ readonly brand: unique symbol;
18
+ }>;
15
19
  /** A live renderer no longer supports one required frozen renderer name. */
16
20
  export declare class RendererManifestComponentUnsupportedError extends RendererManifestComponentUnsupportedError_base {
17
21
  }
@@ -9,7 +9,9 @@ const RendererCapabilityScopeSchema = Schema.Union([
9
9
  RendererDomainSchema,
10
10
  ]);
11
11
  /** A live renderer no longer publishes one domain frozen by a signed release. */
12
- export class RendererManifestDomainUnpublishedError extends Schema.TaggedError()("RendererManifestDomainUnpublishedError", { rendererDomain: RendererDomainSchema }) {
12
+ export class RendererManifestDomainUnpublishedError extends Schema.TaggedError()("RendererManifestDomainUnpublishedError", {
13
+ rendererDomain: RendererDomainSchema,
14
+ }) {
13
15
  }
14
16
  /** A live renderer no longer supports one required frozen renderer name. */
15
17
  export class RendererManifestComponentUnsupportedError extends Schema.TaggedError()("RendererManifestComponentUnsupportedError", {