@nakafa/aksara-contracts 2.0.0 → 3.0.1

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 (71) hide show
  1. package/README.md +2 -2
  2. package/dist/artifact/integrity.d.ts +3 -3
  3. package/dist/artifact/integrity.js +2 -2
  4. package/dist/artifact/source.d.ts +2 -2
  5. package/dist/artifact/source.js +2 -8
  6. package/dist/artifact/spec.d.ts +0 -16
  7. package/dist/artifact/spec.js +0 -6
  8. package/dist/artifact/verify.d.ts +1 -1
  9. package/dist/assessment/hash.d.ts +6 -6
  10. package/dist/assessment/snapshot.d.ts +3 -3
  11. package/dist/date.js +1 -1
  12. package/dist/hash/digest.d.ts +7 -7
  13. package/dist/hash/digest.js +9 -30
  14. package/dist/hash/stream.d.ts +1 -1
  15. package/dist/hash/text.d.ts +3 -12
  16. package/dist/hash/text.js +3 -6
  17. package/dist/ids.js +8 -8
  18. package/dist/preview/auth.d.ts +1 -1
  19. package/dist/preview/auth.js +29 -25
  20. package/dist/program/snapshot/digest.d.ts +1 -2
  21. package/dist/program/snapshot/digest.js +2 -4
  22. package/dist/program/snapshot/hash.d.ts +6 -21
  23. package/dist/program/snapshot/hash.js +3 -9
  24. package/dist/projection/digest.d.ts +7 -16
  25. package/dist/projection/digest.js +7 -13
  26. package/dist/projection/hash.d.ts +2 -11
  27. package/dist/projection/hash.js +2 -5
  28. package/dist/projection/material.js +1 -1
  29. package/dist/projection/verify.d.ts +1 -1
  30. package/dist/projection/verify.js +1 -1
  31. package/dist/quran/notes.js +1 -1
  32. package/dist/quran/provenance.d.ts +2 -8
  33. package/dist/quran/provenance.js +1 -4
  34. package/dist/quran/snapshot/digest.d.ts +1 -2
  35. package/dist/quran/snapshot/digest.js +2 -2
  36. package/dist/quran/snapshot/hash.d.ts +3 -10
  37. package/dist/quran/snapshot/hash.js +2 -5
  38. package/dist/quran/snapshot/row/hash.d.ts +3 -12
  39. package/dist/quran/snapshot/row/hash.js +2 -5
  40. package/dist/release/digest.d.ts +7 -16
  41. package/dist/release/digest.js +7 -13
  42. package/dist/release/hash.d.ts +2 -11
  43. package/dist/release/hash.js +2 -6
  44. package/dist/release/items.d.ts +1 -1
  45. package/dist/release/items.js +1 -1
  46. package/dist/release/result/digest.d.ts +5 -13
  47. package/dist/release/result/digest.js +4 -9
  48. package/dist/release/rollback/digest.d.ts +7 -16
  49. package/dist/release/rollback/digest.js +7 -13
  50. package/dist/release/route/digest.d.ts +7 -16
  51. package/dist/release/route/digest.js +7 -13
  52. package/dist/release/route/verify.d.ts +1 -1
  53. package/dist/release/route/verify.js +1 -1
  54. package/dist/release/snapshot/evidence/assessment.d.ts +1 -1
  55. package/dist/release/snapshot/evidence/program.d.ts +1 -1
  56. package/dist/release/snapshot/evidence/quran.d.ts +1 -1
  57. package/dist/release/snapshot/evidence.d.ts +1 -1
  58. package/dist/release/snapshot/verify.d.ts +1 -1
  59. package/dist/release/verify.d.ts +2 -2
  60. package/dist/renderer/compatibility.d.ts +1 -1
  61. package/dist/renderer/component.js +1 -1
  62. package/dist/renderer/contract.d.ts +0 -8
  63. package/dist/renderer/contract.js +0 -3
  64. package/dist/renderer/manifest.d.ts +3 -3
  65. package/dist/renderer/manifest.js +2 -2
  66. package/dist/runtime/verify.d.ts +2 -2
  67. package/dist/signature/key.d.ts +0 -2
  68. package/dist/signature/key.js +37 -88
  69. package/dist/signature/verify.js +31 -46
  70. package/dist/tree.js +1 -1
  71. package/package.json +2 -2
@@ -1,14 +1,5 @@
1
- import { Effect, Schema, Stream } from "effect";
2
- import { ReleaseIdSchema } from "#contracts/ids";
1
+ import { Effect, Stream } from "effect";
3
2
  import { type ContentProjection } from "#contracts/projection/spec";
4
- declare const ProjectionHashError_base: Schema.Class<ProjectionHashError, Schema.TaggedStruct<"ProjectionHashError", {
5
- readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
6
- }>, import("effect/Cause").YieldableError & {
7
- readonly brand: unique symbol;
8
- }>;
9
- /** SHA-256 computation failed before projection integrity was established. */
10
- export declare class ProjectionHashError extends ProjectionHashError_base {
11
- }
12
3
  /** Keeps the digest stream private while exposing only canonical counters. */
13
4
  declare class ProjectionDigestState {
14
5
  #private;
@@ -18,16 +9,16 @@ declare class ProjectionDigestState {
18
9
  /** Adds one canonical projection to this invocation-owned digest. */
19
10
  update(projection: ContentProjection): void;
20
11
  /** Digests the complete stream once and returns its branded immutable identity. */
21
- digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
12
+ digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
22
13
  }
23
14
  /** Creates a fresh domain-separated projection digest state. */
24
15
  export declare const createProjectionDigest: Effect.Effect<ProjectionDigestState, never, never>;
25
16
  /** Adds one canonical content projection to an incremental digest. */
26
17
  export declare function updateProjectionDigest(state: ProjectionDigestState, projection: ContentProjection): Effect.Effect<ProjectionDigestState, never, never>;
27
- /** Finalizes one projection digest with a typed hash failure. */
28
- export declare function finalizeProjectionDigest(releaseId: typeof ReleaseIdSchema.Type, state: ProjectionDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ProjectionHashError, never>;
29
- /** Digests a projection stream. Its canonical bytes are held until one Web Crypto digest runs. */
30
- export declare const digestProjections: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, projections: Stream.Stream<{
18
+ /** Finalizes one projection digest. */
19
+ export declare function finalizeProjectionDigest(state: ProjectionDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
20
+ /** Digests a projection stream. Its canonical bytes are held until one digest runs. */
21
+ export declare const digestProjections: <E, R>(projections: Stream.Stream<{
31
22
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
32
23
  readonly articleRouteSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleRouteSlug">;
33
24
  readonly articleSlug: string & import("effect/Brand").Brand<"@NakafaAI/AksaraArticleSlug">;
@@ -114,5 +105,5 @@ export declare const digestProjections: <E, R>(releaseId: string & import("effec
114
105
  }, E, R>) => Effect.Effect<{
115
106
  count: number;
116
107
  digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
117
- }, E | ProjectionHashError, R>;
108
+ }, E, R>;
118
109
  export {};
@@ -1,11 +1,7 @@
1
- import { Effect, Schema, Stream } from "effect";
1
+ import { Effect, Stream } from "effect";
2
2
  import { DigestStream } from "#contracts/hash/stream";
3
- import { ReleaseIdSchema } from "#contracts/ids";
4
3
  import { canonicalizeContentProjection, } from "#contracts/projection/spec";
5
4
  const CONTENT_PROJECTION_DIGEST_DOMAIN = "nakafa.aksara.content-projections";
6
- /** SHA-256 computation failed before projection integrity was established. */
7
- export class ProjectionHashError extends Schema.TaggedError()("ProjectionHashError", { releaseId: ReleaseIdSchema }) {
8
- }
9
5
  /** Keeps the digest stream private while exposing only canonical counters. */
10
6
  class ProjectionDigestState {
11
7
  #stream = new DigestStream();
@@ -35,16 +31,14 @@ export function updateProjectionDigest(state, projection) {
35
31
  return state;
36
32
  });
37
33
  }
38
- /** Finalizes one projection digest with a typed hash failure. */
39
- export function finalizeProjectionDigest(releaseId, state) {
40
- return state
41
- .digest()
42
- .pipe(Effect.mapError(() => new ProjectionHashError({ releaseId })));
34
+ /** Finalizes one projection digest. */
35
+ export function finalizeProjectionDigest(state) {
36
+ return state.digest();
43
37
  }
44
- /** Digests a projection stream. Its canonical bytes are held until one Web Crypto digest runs. */
45
- export const digestProjections = Effect.fn("AksaraContracts.digestProjections")(function* (releaseId, projections) {
38
+ /** Digests a projection stream. Its canonical bytes are held until one digest runs. */
39
+ export const digestProjections = Effect.fn("AksaraContracts.digestProjections")(function* (projections) {
46
40
  const initial = yield* createProjectionDigest;
47
41
  const state = yield* projections.pipe(Stream.runFoldEffect(() => initial, (current, projection) => updateProjectionDigest(current, projection)));
48
- const digest = yield* finalizeProjectionDigest(releaseId, state);
42
+ const digest = yield* finalizeProjectionDigest(state);
49
43
  return { count: state.count, digest };
50
44
  });
@@ -1,12 +1,4 @@
1
- import { Effect, Schema } from "effect";
2
- declare const ContentProjectionHashError_base: Schema.Class<ContentProjectionHashError, Schema.TaggedStruct<"ContentProjectionHashError", {
3
- readonly contentKey: Schema.String;
4
- }>, import("effect/Cause").YieldableError & {
5
- readonly brand: unique symbol;
6
- }>;
7
- /** The projection identity could not be computed for one content key. */
8
- export declare class ContentProjectionHashError extends ContentProjectionHashError_base {
9
- }
1
+ import { Effect } from "effect";
10
2
  /** Hashes one canonical projection for authoritative content-head diffing. */
11
3
  export declare const hashContentProjection: (projection: {
12
4
  readonly appLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">;
@@ -92,5 +84,4 @@ export declare const hashContentProjection: (projection: {
92
84
  };
93
85
  readonly sitemap: true;
94
86
  readonly sourcePath: string & import("effect/Brand").Brand<"@NakafaAI/AksaraCorpusSourcePath">;
95
- }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ContentProjectionHashError, never>;
96
- export {};
87
+ }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
@@ -1,8 +1,5 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { hashText } from "#contracts/hash/text";
3
3
  import { canonicalizeContentProjection, } from "#contracts/projection/spec";
4
- /** The projection identity could not be computed for one content key. */
5
- export class ContentProjectionHashError extends Schema.TaggedError()("ContentProjectionHashError", { contentKey: Schema.String }) {
6
- }
7
4
  /** Hashes one canonical projection for authoritative content-head diffing. */
8
- export const hashContentProjection = Effect.fn("AksaraContracts.hashContentProjection")((projection) => hashText(canonicalizeContentProjection(projection)).pipe(Effect.mapError(() => new ContentProjectionHashError({ contentKey: projection.contentKey }))));
5
+ export const hashContentProjection = Effect.fn("AksaraContracts.hashContentProjection")((projection) => hashText(canonicalizeContentProjection(projection)));
@@ -6,7 +6,7 @@ import { ContentKeySchema, PublicPathSchema } from "#contracts/ids";
6
6
  import { AppLocaleSchema, ArtifactLocaleSchema, } from "#contracts/locale";
7
7
  import { encodeJsonText } from "#contracts/text/json";
8
8
  const MATERIAL_KEY_PATTERN = /^lesson\.[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/u;
9
- const SECTION_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+ const SECTION_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
10
10
  const SEARCH_TITLE_MAX_LENGTH = 70;
11
11
  const SINGLE_SPACED_LINE_PATTERN = /^[^\p{Cc}\p{Cf}\s]+(?: [^\p{Cc}\p{Cf}\s]+)*$/u;
12
12
  const MaterialPublicPathSchema = PublicPathSchema.pipe(Schema.check(Schema.makeFilter((value) => value.includes("/"), {
@@ -143,5 +143,5 @@ export declare const verifyContentProjections: <E, R>(input: {
143
143
  readonly projections: Stream.Stream<unknown, E, R>;
144
144
  }) => Effect.Effect<{
145
145
  count: number;
146
- }, E | ProjectionCountError | ProjectionDecodeError | ProjectionDigestError | import("#contracts/projection/digest").ProjectionHashError | ProjectionOrderError | ProjectionRouteError, R>;
146
+ }, E | ProjectionCountError | ProjectionDecodeError | ProjectionDigestError | ProjectionOrderError | ProjectionRouteError, R>;
147
147
  export {};
@@ -64,7 +64,7 @@ export function decodeContentProjections(projections) {
64
64
  }
65
65
  /** Authenticates a replayable projection stream against its signed manifest. */
66
66
  export const verifyContentProjections = Effect.fn("AksaraContracts.verifyContentProjections")(function* (input) {
67
- const summary = yield* digestProjections(input.manifest.releaseId, decodeContentProjections(input.projections));
67
+ const summary = yield* input.projections.pipe(decodeContentProjections, digestProjections);
68
68
  if (summary.count !== input.manifest.projectionCount) {
69
69
  return yield* new ProjectionCountError({
70
70
  actualCount: summary.count,
@@ -54,7 +54,7 @@ const QuranTranslationSourceSchema = Schema.Struct({
54
54
  /** Reads every numeric marker without treating editorial brackets as notes. */
55
55
  function readMarkers(source) {
56
56
  const markers = MutableList.make();
57
- for (const match of source.matchAll(/\[(\d+)\]/gu)) {
57
+ for (const match of source.matchAll(/\[\d+\]/gu)) {
58
58
  const rawNumber = match[0].slice(1, -1);
59
59
  const start = match.index;
60
60
  const number = Number(rawNumber);
@@ -123,19 +123,13 @@ declare const QuranProvenanceCoverageError_base: Schema.Class<QuranProvenanceCov
123
123
  /** Quran provenance omitted or misordered an active-locale scope. */
124
124
  export declare class QuranProvenanceCoverageError extends QuranProvenanceCoverageError_base {
125
125
  }
126
- declare const QuranProvenanceHashError_base: Schema.Class<QuranProvenanceHashError, Schema.TaggedStruct<"QuranProvenanceHashError", {}>, import("effect/Cause").YieldableError & {
127
- readonly brand: unique symbol;
128
- }>;
129
- /** Node could not compute the deterministic provenance digest. */
130
- export declare class QuranProvenanceHashError extends QuranProvenanceHashError_base {
131
- }
132
126
  /** Produces stable JSON for one reviewed Quran provenance record. */
133
127
  export declare function canonicalizeQuranProvenance(record: QuranProvenanceRecord): string;
134
128
  /** Digests exact ordered provenance records under their active locale set. */
135
129
  export declare const hashQuranProvenance: (input: {
136
130
  readonly activeAppLocales: ActiveAppLocaleList;
137
131
  readonly records: readonly QuranProvenanceRecord[];
138
- }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, QuranProvenanceHashError, never>;
132
+ }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
139
133
  /** Builds a snapshot provenance gate from exact reviewed source records. */
140
134
  export declare const makeQuranProvenanceManifest: (input: {
141
135
  readonly activeAppLocales: ActiveAppLocaleList;
@@ -257,5 +251,5 @@ export declare const makeQuranProvenanceManifest: (input: {
257
251
  readonly status: "approved" | "blocked";
258
252
  }[]];
259
253
  readonly status: "approved" | "blocked";
260
- }, QuranProvenanceCoverageError | QuranProvenanceHashError, never>;
254
+ }, QuranProvenanceCoverageError, never>;
261
255
  export {};
@@ -102,9 +102,6 @@ export class QuranProvenanceCoverageError extends Schema.TaggedError()("QuranPro
102
102
  actualScopes: Schema.Array(QuranProvenanceScopeSchema),
103
103
  }) {
104
104
  }
105
- /** Node could not compute the deterministic provenance digest. */
106
- export class QuranProvenanceHashError extends Schema.TaggedError()("QuranProvenanceHashError", {}) {
107
- }
108
105
  const PROVENANCE_DOMAIN = "nakafa.aksara.quran-provenance";
109
106
  /** Produces stable JSON for one reviewed Quran provenance record. */
110
107
  export function canonicalizeQuranProvenance(record) {
@@ -121,7 +118,7 @@ export const hashQuranProvenance = Effect.fn("AksaraContracts.hashQuranProvenanc
121
118
  for (const record of input.records) {
122
119
  canonical += `${canonicalizeQuranProvenance(record)}\n`;
123
120
  }
124
- return yield* hashText(canonical).pipe(Effect.mapError(() => new QuranProvenanceHashError()));
121
+ return yield* hashText(canonical);
125
122
  });
126
123
  /** Builds a snapshot provenance gate from exact reviewed source records. */
127
124
  export const makeQuranProvenanceManifest = Effect.fn("AksaraContracts.makeQuranProvenanceManifest")(function* (input) {
@@ -1,7 +1,6 @@
1
1
  import { Effect, Schema, Stream } from "effect";
2
2
  import type { ActiveAppLocaleList } from "#contracts/locale";
3
3
  import type { QuranSnapshotRow } from "#contracts/quran/snapshot/row";
4
- import { QuranRowHashError } from "#contracts/quran/snapshot/row/hash";
5
4
  declare const QuranRowIntegrityError_base: Schema.Class<QuranRowIntegrityError, Schema.TaggedStruct<"QuranRowIntegrityError", {
6
5
  readonly actual: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
7
6
  readonly expected: Schema.brand<Schema.String, "@NakafaAI/AksaraSha256Hash">;
@@ -33,5 +32,5 @@ export declare const digestQuranRows: <E, R>(input: {
33
32
  projectionCount: number;
34
33
  runtimeCount: number;
35
34
  searchCount: number;
36
- }, E | QuranRowHashError | QuranRowIntegrityError | QuranRowOrderError, R>;
35
+ }, E | QuranRowIntegrityError | QuranRowOrderError, R>;
37
36
  export {};
@@ -2,7 +2,7 @@ import { Array as Arr, Effect, Option, Schema, Stream } from "effect";
2
2
  import { DigestStream } from "#contracts/hash/stream";
3
3
  import { Sha256HashSchema } from "#contracts/ids";
4
4
  import { AppLocaleSchema } from "#contracts/locale";
5
- import { hashQuranRow, QuranRowHashError, } from "#contracts/quran/snapshot/row/hash";
5
+ import { hashQuranRow } from "#contracts/quran/snapshot/row/hash";
6
6
  import { quranSourceIds } from "#contracts/quran/source";
7
7
  import { QURAN_ATTRIBUTION_COUNT, QURAN_CHUNK_SIZE, QURAN_SURAH_COUNT, QURAN_VERSE_COUNT, } from "#contracts/quran/spec";
8
8
  import { encodeJsonText } from "#contracts/text/json";
@@ -211,7 +211,7 @@ class QuranDigestState {
211
211
  runtimeCount: this.runtimeCount,
212
212
  searchCount: this.searchCount,
213
213
  ...digests,
214
- })), Effect.mapError(() => new QuranRowHashError({ scope: "row" })));
214
+ })));
215
215
  }
216
216
  }
217
217
  /** Authenticates one current row before advancing ordered state. */
@@ -1,11 +1,5 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { type QuranSnapshot, type QuranSnapshotFacts } from "#contracts/quran/snapshot/spec";
3
- declare const QuranSnapshotHashError_base: Schema.Class<QuranSnapshotHashError, Schema.TaggedStruct<"QuranSnapshotHashError", {}>, import("effect/Cause").YieldableError & {
4
- readonly brand: unique symbol;
5
- }>;
6
- /** Node could not compute a deterministic Quran snapshot identity. */
7
- export declare class QuranSnapshotHashError extends QuranSnapshotHashError_base {
8
- }
9
3
  /** Serializes Quran snapshot facts in stable signed field order. */
10
4
  export declare function canonicalizeQuranSnapshot(input: QuranSnapshotFacts): string;
11
5
  /** Creates the content-addressed identity of one complete Quran snapshot. */
@@ -47,7 +41,6 @@ export declare const makeQuranSnapshot: (input: {
47
41
  readonly verseCount: number;
48
42
  readonly format: "localized-quran-snapshot";
49
43
  readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
50
- }, QuranSnapshotHashError, never>;
44
+ }, never, never>;
51
45
  /** Recomputes the content identity of one stored current snapshot. */
52
- export declare function verifyQuranSnapshotHash(snapshot: QuranSnapshot): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, QuranSnapshotHashError, never>;
53
- export {};
46
+ export declare function verifyQuranSnapshotHash(snapshot: QuranSnapshot): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
@@ -1,11 +1,8 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { hashText } from "#contracts/hash/text";
3
3
  import { QURAN_SNAPSHOT_FORMAT, QuranSnapshotSchema, } from "#contracts/quran/snapshot/spec";
4
4
  import { encodeJsonText } from "#contracts/text/json";
5
5
  const SNAPSHOT_DOMAIN = "nakafa.aksara.localized-quran-snapshot";
6
- /** Node could not compute a deterministic Quran snapshot identity. */
7
- export class QuranSnapshotHashError extends Schema.TaggedError()("QuranSnapshotHashError", {}) {
8
- }
9
6
  /** Serializes Quran snapshot facts in stable signed field order. */
10
7
  export function canonicalizeQuranSnapshot(input) {
11
8
  return encodeJsonText({
@@ -31,7 +28,7 @@ export function canonicalizeQuranSnapshot(input) {
31
28
  }
32
29
  /** Creates the content-addressed identity of one complete Quran snapshot. */
33
30
  export const makeQuranSnapshot = Effect.fn("AksaraContracts.makeQuranSnapshot")(function* (input) {
34
- const snapshotId = yield* hashText(`${SNAPSHOT_DOMAIN}\n${canonicalizeQuranSnapshot(input)}`).pipe(Effect.mapError(() => new QuranSnapshotHashError()));
31
+ const snapshotId = yield* hashText(`${SNAPSHOT_DOMAIN}\n${canonicalizeQuranSnapshot(input)}`);
35
32
  return QuranSnapshotSchema.make({
36
33
  ...input,
37
34
  format: QURAN_SNAPSHOT_FORMAT,
@@ -1,13 +1,5 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { type QuranRowPayload } from "#contracts/quran/snapshot/row";
3
- declare const QuranRowHashError_base: Schema.Class<QuranRowHashError, Schema.TaggedStruct<"QuranRowHashError", {
4
- readonly scope: Schema.Literals<readonly ["digest", "row"]>;
5
- }>, import("effect/Cause").YieldableError & {
6
- readonly brand: unique symbol;
7
- }>;
8
- /** Node could not compute a deterministic Quran row identity. */
9
- export declare class QuranRowHashError extends QuranRowHashError_base {
10
- }
11
3
  /** Produces stable JSON for one exhaustive current Quran payload. */
12
4
  export declare function canonicalizeQuranRow(payload: QuranRowPayload): string;
13
5
  /** Computes one current row's domain-separated identity. */
@@ -254,7 +246,7 @@ export declare const hashQuranRow: (payload: {
254
246
  readonly surahNumber: number;
255
247
  readonly text: string;
256
248
  readonly title: string;
257
- }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, QuranRowHashError, never>;
249
+ }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
258
250
  /** Creates one snapshot-bound current row. */
259
251
  export declare const bindQuranRow: (snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, payload: {
260
252
  readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
@@ -746,5 +738,4 @@ export declare const bindQuranRow: (snapshotId: string & import("effect/Brand").
746
738
  };
747
739
  readonly rowHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
748
740
  readonly snapshotId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
749
- }, QuranRowHashError, never>;
750
- export {};
741
+ }, never, never>;
@@ -1,13 +1,10 @@
1
- import { Array as Arr, Effect, Schema } from "effect";
1
+ import { Array as Arr, Effect } from "effect";
2
2
  import { canonicalizeLearningGraphIdentity } from "#contracts/graph/spec";
3
3
  import { hashText } from "#contracts/hash/text";
4
4
  import { canonicalizeQuranAttribution } from "#contracts/quran/attribution";
5
5
  import { QuranSnapshotRowSchema, } from "#contracts/quran/snapshot/row";
6
6
  import { encodeJsonText } from "#contracts/text/json";
7
7
  const ROW_DOMAIN = "nakafa.aksara.quran-row";
8
- /** Node could not compute a deterministic Quran row identity. */
9
- export class QuranRowHashError extends Schema.TaggedError()("QuranRowHashError", { scope: Schema.Literals(["digest", "row"]) }) {
10
- }
11
8
  /** Serializes one published translation list in signed field order. */
12
9
  function canonicalizeTranslations(translations) {
13
10
  return Arr.map(translations, (translation) => ({
@@ -102,7 +99,7 @@ export function canonicalizeQuranRow(payload) {
102
99
  });
103
100
  }
104
101
  /** Computes one current row's domain-separated identity. */
105
- export const hashQuranRow = Effect.fn("AksaraContracts.hashQuranRow")((payload) => hashText(`${ROW_DOMAIN}\n${canonicalizeQuranRow(payload)}`).pipe(Effect.mapError(() => new QuranRowHashError({ scope: "row" }))));
102
+ export const hashQuranRow = Effect.fn("AksaraContracts.hashQuranRow")((payload) => hashText(`${ROW_DOMAIN}\n${canonicalizeQuranRow(payload)}`));
106
103
  /** Creates one snapshot-bound current row. */
107
104
  export const bindQuranRow = Effect.fn("AksaraContracts.bindQuranRow")(function* (snapshotId, payload) {
108
105
  const rowHash = yield* hashQuranRow(payload);
@@ -1,14 +1,5 @@
1
- import { Effect, Schema, Stream } from "effect";
2
- import { type ReleaseId } from "#contracts/ids";
1
+ import { Effect, Stream } from "effect";
3
2
  import type { ContentReleaseItem } from "#contracts/release/spec";
4
- declare const ReleaseItemsHashComputationError_base: Schema.Class<ReleaseItemsHashComputationError, Schema.TaggedStruct<"ReleaseItemsHashComputationError", {
5
- readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
6
- }>, import("effect/Cause").YieldableError & {
7
- readonly brand: unique symbol;
8
- }>;
9
- /** SHA-256 computation failed before item integrity was established. */
10
- export declare class ReleaseItemsHashComputationError extends ReleaseItemsHashComputationError_base {
11
- }
12
3
  /** Keeps the digest stream private while exposing canonical operation counts. */
13
4
  declare class ReleaseItemsDigestState {
14
5
  #private;
@@ -20,16 +11,16 @@ declare class ReleaseItemsDigestState {
20
11
  /** Adds one canonical release item and updates operation counts. */
21
12
  update(item: ContentReleaseItem): void;
22
13
  /** Digests the complete stream once and returns its branded identity. */
23
- digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
14
+ digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
24
15
  }
25
16
  /** Creates a fresh domain-separated digest state for one release stream. */
26
17
  export declare const createReleaseItemsDigest: Effect.Effect<ReleaseItemsDigestState, never, never>;
27
18
  /** Adds one canonical release item to its incremental digest and counts. */
28
19
  export declare function updateReleaseItemsDigest(state: ReleaseItemsDigestState, item: ContentReleaseItem): Effect.Effect<ReleaseItemsDigestState, never, never>;
29
- /** Finalizes one incremental release-item digest with typed hash failures. */
30
- export declare function finalizeReleaseItemsDigest(releaseId: ReleaseId, state: ReleaseItemsDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ReleaseItemsHashComputationError, never>;
31
- /** Digests a release-item stream. Its canonical bytes are held until one Web Crypto digest runs. */
32
- export declare const digestItems: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, items: Stream.Stream<{
20
+ /** Finalizes one incremental release-item digest. */
21
+ export declare function finalizeReleaseItemsDigest(state: ReleaseItemsDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
22
+ /** Digests a release-item stream. Its canonical bytes are held until one digest runs. */
23
+ export declare const digestItems: <E, R>(items: Stream.Stream<{
33
24
  readonly change: {
34
25
  readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
35
26
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
@@ -52,5 +43,5 @@ export declare const digestItems: <E, R>(releaseId: string & import("effect/Bran
52
43
  deleteCount: number;
53
44
  digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
54
45
  upsertCount: number;
55
- }, E | ReleaseItemsHashComputationError, R>;
46
+ }, E, R>;
56
47
  export {};
@@ -1,11 +1,7 @@
1
- import { Effect, Schema, Stream } from "effect";
1
+ import { Effect, Stream } from "effect";
2
2
  import { DigestStream } from "#contracts/hash/stream";
3
- import { ReleaseIdSchema } from "#contracts/ids";
4
3
  import { canonicalizeContentReleaseItem } from "#contracts/release/canonical";
5
4
  const CONTENT_RELEASE_ITEMS_DIGEST_DOMAIN = "nakafa.aksara.content-release-items";
6
- /** SHA-256 computation failed before item integrity was established. */
7
- export class ReleaseItemsHashComputationError extends Schema.TaggedError()("ReleaseItemsHashComputationError", { releaseId: ReleaseIdSchema }) {
8
- }
9
5
  /** Keeps the digest stream private while exposing canonical operation counts. */
10
6
  class ReleaseItemsDigestState {
11
7
  #stream = new DigestStream();
@@ -42,17 +38,15 @@ export function updateReleaseItemsDigest(state, item) {
42
38
  return state;
43
39
  });
44
40
  }
45
- /** Finalizes one incremental release-item digest with typed hash failures. */
46
- export function finalizeReleaseItemsDigest(releaseId, state) {
47
- return state
48
- .digest()
49
- .pipe(Effect.mapError(() => new ReleaseItemsHashComputationError({ releaseId })));
41
+ /** Finalizes one incremental release-item digest. */
42
+ export function finalizeReleaseItemsDigest(state) {
43
+ return state.digest();
50
44
  }
51
- /** Digests a release-item stream. Its canonical bytes are held until one Web Crypto digest runs. */
52
- export const digestItems = Effect.fn("AksaraContracts.digestItems")(function* (releaseId, items) {
45
+ /** Digests a release-item stream. Its canonical bytes are held until one digest runs. */
46
+ export const digestItems = Effect.fn("AksaraContracts.digestItems")(function* (items) {
53
47
  const initial = yield* createReleaseItemsDigest;
54
48
  const state = yield* items.pipe(Stream.runFoldEffect(() => initial, (current, item) => updateReleaseItemsDigest(current, item)));
55
- const digest = yield* finalizeReleaseItemsDigest(releaseId, state);
49
+ const digest = yield* finalizeReleaseItemsDigest(state);
56
50
  return {
57
51
  count: state.count,
58
52
  deleteCount: state.deleteCount,
@@ -1,12 +1,4 @@
1
- import { Effect, Schema } from "effect";
2
- declare const ReleaseHashComputationError_base: Schema.Class<ReleaseHashComputationError, Schema.TaggedStruct<"ReleaseHashComputationError", {
3
- readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
4
- }>, import("effect/Cause").YieldableError & {
5
- readonly brand: unique symbol;
6
- }>;
7
- /** SHA-256 computation failed before release authenticity was established. */
8
- export declare class ReleaseHashComputationError extends ReleaseHashComputationError_base {
9
- }
1
+ import { Effect } from "effect";
10
2
  /** Computes the immutable identity of one canonical release manifest. */
11
3
  export declare const hashContentReleaseManifest: (manifest: {
12
4
  readonly baseActiveAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]] | null;
@@ -64,5 +56,4 @@ export declare const hashContentReleaseManifest: (manifest: {
64
56
  readonly upsertCount: number;
65
57
  readonly activeAppLocales: readonly [("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">, ...(("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraAppLocale">)[]];
66
58
  readonly format: "localized-content-release";
67
- }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ReleaseHashComputationError, never>;
68
- export {};
59
+ }) => Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
@@ -1,9 +1,5 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { hashText } from "#contracts/hash/text";
3
- import { ReleaseIdSchema } from "#contracts/ids";
4
3
  import { canonicalizeContentReleaseManifest } from "#contracts/release/signing";
5
- /** SHA-256 computation failed before release authenticity was established. */
6
- export class ReleaseHashComputationError extends Schema.TaggedError()("ReleaseHashComputationError", { releaseId: ReleaseIdSchema }) {
7
- }
8
4
  /** Computes the immutable identity of one canonical release manifest. */
9
- export const hashContentReleaseManifest = Effect.fn("AksaraContracts.hashContentReleaseManifest")((manifest) => hashText(canonicalizeContentReleaseManifest(manifest)).pipe(Effect.mapError(() => new ReleaseHashComputationError({ releaseId: manifest.releaseId }))));
5
+ export const hashContentReleaseManifest = Effect.fn("AksaraContracts.hashContentReleaseManifest")((manifest) => hashText(canonicalizeContentReleaseManifest(manifest)));
@@ -111,5 +111,5 @@ export declare const verifyContentReleaseItems: <E, R>(input: {
111
111
  }) => Effect.Effect<{
112
112
  deleteCount: number;
113
113
  upsertCount: number;
114
- }, E | ReleaseItemCountMismatchError | ReleaseItemDecodeError | ReleaseItemIndexMismatchError | ReleaseItemOperationCountMismatchError | ReleaseItemOrderError | ReleaseItemReleaseMismatchError | ReleaseItemScopeError | ReleaseItemsDigestMismatchError | import("#contracts/release/digest").ReleaseItemsHashComputationError, R>;
114
+ }, E | ReleaseItemCountMismatchError | ReleaseItemDecodeError | ReleaseItemIndexMismatchError | ReleaseItemOperationCountMismatchError | ReleaseItemOrderError | ReleaseItemReleaseMismatchError | ReleaseItemScopeError | ReleaseItemsDigestMismatchError, R>;
115
115
  export {};
@@ -95,7 +95,7 @@ export function decodeContentReleaseItems(input) {
95
95
  }
96
96
  /** Authenticates a replayable ordered stream against its signed manifest. */
97
97
  export const verifyContentReleaseItems = Effect.fn("AksaraContracts.verifyContentReleaseItems")(function* (input) {
98
- const summary = yield* digestItems(input.manifest.releaseId, decodeContentReleaseItems(input));
98
+ const summary = yield* digestItems(decodeContentReleaseItems(input));
99
99
  if (summary.count !== input.manifest.itemCount) {
100
100
  return yield* new ReleaseItemCountMismatchError({
101
101
  actualCount: summary.count,
@@ -2,14 +2,6 @@ import { Effect, Schema, Stream } from "effect";
2
2
  import { type PublicPath, type ReleaseId, type Sha256HashSchema } from "#contracts/ids";
3
3
  import { type ArtifactLocale } from "#contracts/locale";
4
4
  import { type ContentHead } from "#contracts/release/head";
5
- declare const ResultCatalogHashError_base: Schema.Class<ResultCatalogHashError, Schema.TaggedStruct<"ResultCatalogHashError", {
6
- readonly releaseId: Schema.brand<Schema.String, "@NakafaAI/AksaraReleaseId">;
7
- }>, import("effect/Cause").YieldableError & {
8
- readonly brand: unique symbol;
9
- }>;
10
- /** SHA-256 computation failed before result-catalog integrity was established. */
11
- export declare class ResultCatalogHashError extends ResultCatalogHashError_base {
12
- }
13
5
  declare const ResultCatalogOrderError_base: Schema.Class<ResultCatalogOrderError, Schema.TaggedStruct<"ResultCatalogOrderError", {
14
6
  readonly artifactLocale: Schema.brand<Schema.Literals<readonly ["en", "id", "de"]>, "@NakafaAI/AksaraArtifactLocale">;
15
7
  readonly contentKey: Schema.brand<Schema.String, "@NakafaAI/AksaraContentKey">;
@@ -63,15 +55,15 @@ declare class ResultCatalogDigestState {
63
55
  /** Adds one canonical compact head and advances ordering evidence. */
64
56
  update(head: ContentHead): void;
65
57
  /** Digests the complete stream once and returns its branded immutable identity. */
66
- digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, import("effect/PlatformError").PlatformError, never>;
58
+ digest(): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
67
59
  }
68
60
  /** Creates a fresh domain-separated digest state for one result catalog. */
69
61
  export declare const createResultCatalogDigest: Effect.Effect<ResultCatalogDigestState, never, never>;
70
62
  /** Adds one canonically ordered compact head to a result digest. */
71
63
  export declare function updateResultCatalogDigest(releaseId: ReleaseId, state: ResultCatalogDigestState, head: ContentHead): Effect.Effect<ResultCatalogDigestState, ResultCatalogOrderError | ResultCatalogRouteError>;
72
64
  /** Finalizes one incremental result-catalog digest. */
73
- export declare function finalizeResultCatalogDigest(releaseId: ReleaseId, state: ResultCatalogDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, ResultCatalogHashError, never>;
74
- /** Digests one complete compact-head stream. Its canonical bytes are held until one Web Crypto digest runs. */
65
+ export declare function finalizeResultCatalogDigest(state: ResultCatalogDigestState): Effect.Effect<string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">, never, never>;
66
+ /** Digests one complete compact-head stream. Its canonical bytes are held until one digest runs. */
75
67
  export declare const digestResultCatalog: <E, R>(releaseId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraReleaseId">, heads: Stream.Stream<{
76
68
  readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
77
69
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
@@ -111,7 +103,7 @@ export declare const digestResultCatalog: <E, R>(releaseId: string & import("eff
111
103
  }, E, R>) => Effect.Effect<{
112
104
  count: number;
113
105
  digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
114
- }, E | ResultCatalogHashError | ResultCatalogOrderError | ResultCatalogRouteError, R>;
106
+ }, E | ResultCatalogOrderError | ResultCatalogRouteError, R>;
115
107
  /** Authenticates one complete replayed catalog against its signed result root. */
116
108
  export declare const verifyResultCatalog: <E, R>(input: {
117
109
  readonly expectedCount: number;
@@ -121,5 +113,5 @@ export declare const verifyResultCatalog: <E, R>(input: {
121
113
  }) => Effect.Effect<{
122
114
  count: number;
123
115
  digest: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
124
- }, E | ResultCatalogCountMismatchError | ResultCatalogDigestMismatchError | ResultCatalogHashError | ResultCatalogOrderError | ResultCatalogRouteError, R>;
116
+ }, E | ResultCatalogCountMismatchError | ResultCatalogDigestMismatchError | ResultCatalogOrderError | ResultCatalogRouteError, R>;
125
117
  export {};
@@ -6,9 +6,6 @@ import { AppLocaleSchema } from "#contracts/locale";
6
6
  import { canonicalizeContentHead, } from "#contracts/release/head";
7
7
  import { ReleaseCountMismatchFields, ReleaseDigestMismatchFields, } from "#contracts/release/mismatch";
8
8
  import { RESULT_CATALOG_DIGEST_DOMAIN } from "#contracts/release/result/spec";
9
- /** SHA-256 computation failed before result-catalog integrity was established. */
10
- export class ResultCatalogHashError extends Schema.TaggedError()("ResultCatalogHashError", { releaseId: ReleaseIdSchema }) {
11
- }
12
9
  /** A result catalog is duplicated or outside canonical content-head order. */
13
10
  export class ResultCatalogOrderError extends Schema.TaggedError()("ResultCatalogOrderError", {
14
11
  ...ContentHeadIdentitySchema.fields,
@@ -88,16 +85,14 @@ export function updateResultCatalogDigest(releaseId, state, head) {
88
85
  });
89
86
  }
90
87
  /** Finalizes one incremental result-catalog digest. */
91
- export function finalizeResultCatalogDigest(releaseId, state) {
92
- return state
93
- .digest()
94
- .pipe(Effect.mapError(() => new ResultCatalogHashError({ releaseId })));
88
+ export function finalizeResultCatalogDigest(state) {
89
+ return state.digest();
95
90
  }
96
- /** Digests one complete compact-head stream. Its canonical bytes are held until one Web Crypto digest runs. */
91
+ /** Digests one complete compact-head stream. Its canonical bytes are held until one digest runs. */
97
92
  export const digestResultCatalog = Effect.fn("AksaraContracts.digestResultCatalog")(function* (releaseId, heads) {
98
93
  const initial = yield* createResultCatalogDigest;
99
94
  const state = yield* heads.pipe(Stream.runFoldEffect(() => initial, (current, head) => updateResultCatalogDigest(releaseId, current, head)));
100
- const digest = yield* finalizeResultCatalogDigest(releaseId, state);
95
+ const digest = yield* finalizeResultCatalogDigest(state);
101
96
  return { count: state.count, digest };
102
97
  });
103
98
  /** Authenticates one complete replayed catalog against its signed result root. */