@nakafa/aksara-contracts 0.51.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.
package/LICENSE CHANGED
@@ -1,185 +1,240 @@
1
- # Nakafa Source Available License 1.0
1
+ # Nakafa Source Available License 2.0
2
2
 
3
- Effective date: April 24, 2026
3
+ Effective date: October 24, 2026
4
4
 
5
5
  Copyright (c) 2026 PT NAKAFA TEKNO KREATIF. All rights reserved.
6
6
 
7
- This is not an open-source license. Nakafa source code is public so people can
8
- inspect it, learn from it, review it, and propose improvements. The public
9
- source code does not grant permission to rebrand, redistribute, host, sell,
10
- monetize, or turn Nakafa into another product without written permission.
7
+ Nakafa is source available. It is not open source, and it is not free to
8
+ reuse. The source is public for one reason: so that anyone can read it, audit
9
+ it, and understand how Nakafa works. It is not public so that anyone can copy
10
+ it, fork it, rebrand it, publish it, or gain anything from it.
11
11
 
12
- ## 1. Definitions
13
-
14
- `Nakafa` means the software, source code, build files, configuration, scripts,
15
- database schema, prompts, UI, and related code made available in this repository.
16
-
17
- `You` means the individual or entity receiving or using Nakafa.
18
-
19
- `Personal use` means use by one individual for that individual's own learning,
20
- research, testing, security review, or hobby evaluation. Personal use does not
21
- include use for an employer, client, school, organization, product, service,
22
- team, or business purpose.
12
+ By reading, cloning, downloading, forking, running, or otherwise using Nakafa,
13
+ you accept this license. If you do not accept it, do not use Nakafa.
23
14
 
24
- `Local use` means use on a device or development environment controlled by you,
25
- without making Nakafa available to any other person over the internet, an
26
- intranet, a private network, a shared server, or any hosted environment.
15
+ ## 1. Definitions
27
16
 
28
- `Written permission` means a separate written agreement signed by PT NAKAFA
29
- TEKNO KREATIF, or a written approval sent from an official Nakafa email address.
17
+ `Nakafa` means the software in this repository, in the Aksara repository, and
18
+ in every earlier version of them: source code, build files, configuration,
19
+ scripts, database schema, prompts, tests, documentation, user interface,
20
+ design, and the material the software produces or the official services serve.
21
+
22
+ `Official services` means `https://nakafa.com`, its subdomains, and the
23
+ official Nakafa apps and APIs.
24
+
25
+ `You` means the person or entity that receives, reads, or uses Nakafa.
26
+
27
+ `Benefit` means any advantage, with or without money, for you or for anyone
28
+ else. It includes revenue, payment, salary, sponsorship, advertising or
29
+ affiliate income, donations, grants, prizes, followers, subscribers, views,
30
+ likes, audience growth, attention, virality, reputation, portfolio or career
31
+ value, hiring, investment, traffic, leads, data, and any product or
32
+ competitive advantage. These are not a Benefit: learning that stays private to
33
+ one person; a grade, score, or certificate that a school, university, or exam
34
+ body gives you for your own work; and submitting a contribution to an official
35
+ Nakafa repository under `.github/CONTRIBUTING.md`, with the public record of
36
+ that submission.
37
+
38
+ `Personal private use` means use by one natural person, alone, for that
39
+ person's own learning, audit, or evaluation, that produces no Benefit and is
40
+ not done for, shown to, or shared with any employer, client, school,
41
+ organization, team, community, channel, or social media account. Using the
42
+ official services with your own account under their terms is personal private
43
+ use.
44
+
45
+ `Publish` means to make something available to, or perceivable by, anyone other
46
+ than you, by any means. It includes repositories, forks, mirrors, archives,
47
+ packages, releases, hosted or deployed instances whether public or private,
48
+ screenshots, recordings, live streams, videos, posts, articles, courses,
49
+ slides, talks, demos, datasets, and output of AI systems.
50
+
51
+ `Copy` means a reproduction of Nakafa in whole or in part, or a modified
52
+ version, translation, port, or reimplementation that reproduces Nakafa's code
53
+ or content, whether made by hand or with AI tools. Ideas, methods, and
54
+ functions are not protected by this license; work that does not reproduce
55
+ Nakafa's code or content is not a copy, even if it covers the same subject.
56
+
57
+ `Written permission` means a written agreement signed by an authorized
58
+ representative of PT NAKAFA TEKNO KREATIF, or a written approval sent from the
59
+ official address in Section 15 that names you and the exact use it allows. A
60
+ written permission given before the effective date stays valid for the use it
61
+ covers.
30
62
 
31
63
  ## 2. Scope
32
64
 
33
- This license applies to the software source code in this repository unless a
34
- file says that a different license applies.
35
-
36
- This license does not apply to:
65
+ This license applies to Nakafa unless a license file names a different license
66
+ for a file. It does not apply to:
37
67
 
38
- - Third-party dependencies, packages, services, fonts, or libraries, which keep
68
+ - Third-party dependencies, packages, services, fonts, and libraries, which keep
39
69
  their own licenses.
40
70
  - Educational content, articles, exercises, explanations, datasets, copy,
41
- images, video, audio, and other non-code materials, which are covered by
42
- `CONTENT_LICENSE.md` unless a file says otherwise.
43
- - The Nakafa name, logos, domains, product names, visual identity, and other
44
- brand assets, which are covered by `TRADEMARKS.md`.
45
- - Prior copies of Nakafa that were lawfully received under a previous license.
46
- Those older copies remain under the license terms that applied when they were
47
- received. New changes published after the effective date above are covered by
48
- this license.
49
-
50
- All rights not expressly granted by this license are reserved by PT NAKAFA TEKNO
51
- KREATIF.
52
-
53
- ## 3. Allowed Use Without Written Permission
54
-
55
- You may do only the following without written permission from PT NAKAFA TEKNO
56
- KREATIF:
57
-
58
- - View, read, inspect, and audit the source code.
59
- - Clone or download one copy for personal review.
60
- - Create a GitHub fork only to prepare and submit contributions back to Nakafa,
61
- as long as the fork is not used as a standalone project, hosted service,
62
- mirror, product, rebrand, or distribution channel.
63
- - Run the unmodified software locally for your own personal, non-commercial
64
- learning, research, testing, security review, or hobby evaluation.
65
- - Make temporary technical copies that are necessary for the allowed personal
66
- local use above.
67
- - Submit issues, suggestions, or pull requests under the contribution terms in
68
- `.github/CONTRIBUTING.md`.
71
+ images, video, audio, and other non-code material, which `CONTENT_LICENSE.md`
72
+ covers.
73
+ - The Nakafa name, logos, domains, product names, mascot, characters, and visual
74
+ identity, which `TRADEMARKS.md` covers.
75
+
76
+ All rights that this license does not expressly grant are reserved by
77
+ PT NAKAFA TEKNO KREATIF.
78
+
79
+ ## 3. What You May Do
80
+
81
+ Without written permission, you may do only the following:
82
+
83
+ - Use the official services under their terms.
84
+ - Read, view, inspect, audit, and study the source code, including how it works,
85
+ only within personal private use.
86
+ - Keep one copy of Nakafa, plus any backup copy that applicable law lets you
87
+ make, run it, and change it, only within personal private use.
88
+ - Ask an AI system to explain or review Nakafa that you lawfully have, for your
89
+ own personal private use, with a setting that does not keep or train on your
90
+ input where your provider offers one, without publishing the output.
91
+ - Create a fork on GitHub only to prepare and submit a pull request to an
92
+ official Nakafa repository. The fork may not be used for anything else: no
93
+ releases, packages, pages, deployments, promotion, or independent
94
+ development. Delete it within 7 days after the pull request is merged or
95
+ closed, and in any case when it has had no open pull request for 14 days.
96
+ GitHub's terms let any user create a fork of a public repository; this
97
+ license grants no other right in that fork.
98
+ - Report security issues privately as `SECURITY.md` describes, and open issues
99
+ and pull requests under `.github/CONTRIBUTING.md`, without pasting Nakafa's
100
+ code into them beyond the lines needed to show the problem.
101
+ - Mention Nakafa by name and link to an official repository or to
102
+ `https://nakafa.com`, truthfully, without reproducing Nakafa, as
103
+ `TRADEMARKS.md` allows.
69
104
 
70
105
  These permissions are personal, limited, non-exclusive, non-transferable, and
71
- revocable if you violate this license.
72
-
73
- ## 4. Permission Required
74
-
75
- You must get prior written permission from PT NAKAFA TEKNO KREATIF before doing
76
- anything not listed in Section 3.
77
-
78
- The following uses always require prior written permission:
79
-
80
- - Commercial use.
81
- - Revenue-generating use.
82
- - Use in a product, service, course, school system, learning management system,
83
- SaaS, API, internal company tool, agency project, client project, consulting
84
- work, paid training, or paid content.
85
- - Use by a company, school, institution, nonprofit organization, government
86
- organization, team, or other entity outside personal local evaluation.
87
- - Any hosted deployment outside your own local machine, whether public or
88
- private, and whether or not anyone else can access it.
89
- - Distribution, redistribution, mirroring, publishing, uploading, packaging,
90
- reselling, sublicensing, or sharing copies of the software.
91
- - Modification, forked product development, derivative works, white-label use,
92
- private-label use, rebranding, or presenting Nakafa as your own project.
93
- - Removing, hiding, or changing copyright, license, attribution, source,
94
- trademark, or brand notices.
95
- - Using Nakafa code, content, structure, datasets, or outputs to train,
96
- fine-tune, benchmark, evaluate, seed, or improve AI models, search indexes,
97
- datasets, embeddings, retrieval systems, or competing educational products.
98
-
99
- Commercial or revenue-generating use includes use connected to subscriptions,
100
- ads, sponsorships, affiliate revenue, lead generation, paid access, paid
101
- support, paid tutoring, paid courses, paid school services, sales enablement,
102
- customer acquisition, investor demos, or any other direct or indirect business
103
- benefit.
104
-
105
- ## 5. Brand Rights
106
-
107
- This license grants no trademark, service mark, trade name, domain name, logo,
108
- design, or brand rights. You may not use the Nakafa brand in a way that suggests
109
- ownership, endorsement, partnership, official status, or source confusion.
110
-
111
- See `TRADEMARKS.md` for the brand rules.
112
-
113
- ## 6. Content Rights
114
-
115
- This license grants no rights to copy, redistribute, sell, mirror, scrape,
116
- repackage, rebrand, or monetize Nakafa educational content.
117
-
118
- See `CONTENT_LICENSE.md` for the content rules.
119
-
120
- ## 7. Contributions
121
-
122
- By submitting a contribution, you agree to the contribution terms in
123
- `.github/CONTRIBUTING.md`.
124
-
125
- If you cannot grant those contribution rights, do not submit the contribution.
126
-
127
- ## 8. Termination
128
-
129
- Your rights under this license end immediately if you violate any term.
130
-
131
- After termination, you must stop using the software and delete all copies under
132
- your control, except copies you are required to keep for legal compliance.
133
-
134
- PT NAKAFA TEKNO KREATIF may reinstate your rights only in writing.
135
-
136
- ## 9. Mandatory Legal Rights
137
-
138
- This license does not limit rights that applicable law says cannot be waived,
139
- limited, or conditioned by contract.
106
+ non-sublicensable.
107
+
108
+ ## 4. What Is Forbidden
109
+
110
+ Everything that Section 3 does not list is forbidden without written
111
+ permission. In particular, you may not:
112
+
113
+ - Publish Nakafa or any copy, in whole or in part.
114
+ - Fork, mirror, redistribute, package, sublicense, sell, rent, lend, host, or
115
+ deploy Nakafa or any copy, for anyone, including on a private network or for
116
+ a team, school, or organization.
117
+ - Rebrand, rename, or white-label Nakafa or any copy, or present it as your own
118
+ work, as someone else's work, or as a new or independent project.
119
+ - Use Nakafa or any copy to obtain any Benefit, for you or for anyone else,
120
+ except the search and answer use that `CONTENT_LICENSE.md` Section 4 allows.
121
+ - Use Nakafa's code, content, structure, or output, or anything you learned
122
+ from them, in any work shown to or shared with anyone other than you,
123
+ including an explanation, review, walkthrough, tutorial, talk, slide deck,
124
+ course, quiz, lesson, or rewritten text, whether or not it copies the words
125
+ or code.
126
+ - Use Nakafa for or within any employer, client, school, organization, team,
127
+ community, product, service, course, competition, hackathon, channel, or
128
+ account, other than your own use of the official services.
129
+ - Show, record, stream, or post Nakafa's source code, your copy, your changed
130
+ version, or their screens or output.
131
+ - Train, fine-tune, evaluate, or benchmark an AI model with Nakafa; build a
132
+ dataset, embedding store, or retrieval index from it; have an AI system or
133
+ another person rewrite, translate, port, or reimplement Nakafa from your
134
+ reading of it; or give Nakafa to an AI system except as Section 3 allows.
135
+ - Remove, hide, or change any copyright, license, attribution, source, or
136
+ brand notice.
137
+ - Get around any access control or technical protection of the official
138
+ services.
139
+
140
+ ## 5. Credit Is Not Permission
141
+
142
+ Credit, attribution, or a link to Nakafa does not make a forbidden use allowed.
143
+ This is true whether the credit comes before, during, or after the use,
144
+ including after a post has spread or gone viral. Deleting a post or
145
+ apologizing later does not undo a breach or the Benefit already obtained.
146
+
147
+ ## 6. Brand, Content, Hosting, and Contributions
148
+
149
+ This license grants no right in the Nakafa brand; see `TRADEMARKS.md`. It grants
150
+ no right in Nakafa content; see `CONTENT_LICENSE.md`.
151
+
152
+ Nakafa's repositories are hosted by a third-party platform whose own terms may
153
+ let that platform use hosted content. This license grants no such right to
154
+ anyone else.
155
+
156
+ Contributions are made under `.github/CONTRIBUTING.md`; do not contribute if you
157
+ cannot grant the rights it describes.
158
+
159
+ ## 7. Termination and Remedies
160
+
161
+ Sections 3, 4, and 5 are conditions of your rights. If you breach a condition,
162
+ your rights end automatically, without notice. For any other breach,
163
+ PT NAKAFA TEKNO KREATIF may give written notice, and your rights end if you do
164
+ not cure the breach within 30 days after it. Where copyright or another right
165
+ protects a use, using it after your rights end is infringement.
166
+
167
+ When your rights end, you must stop using Nakafa, delete every copy, fork,
168
+ clone, mirror, deployment, recording, and post under your control within two
169
+ business days, except copies you must keep to comply with law, and confirm the
170
+ deletion in writing when PT NAKAFA TEKNO KREATIF asks.
171
+
172
+ PT NAKAFA TEKNO KREATIF may seek every remedy the law allows, including
173
+ takedowns, injunctions, damages, and the value of any Benefit obtained through
174
+ the breach. Only PT NAKAFA TEKNO KREATIF can reinstate your rights, and only by
175
+ written permission. Sections 5 and 7 to 14 continue after your rights end.
176
+
177
+ ## 8. Rights the Law Gives You
178
+
179
+ This license does not limit any right that applicable law gives you and that a
180
+ contract cannot remove. Nothing in it stops you, while you lawfully use Nakafa,
181
+ from making a backup copy you need, from observing, studying, or testing how a
182
+ program works, or from decompiling it for interoperability, to the extent the
183
+ law does not let a contract stop these acts; nor does it remove statutory
184
+ exceptions for quotation, education, and research. It does not expand those
185
+ rights either, and any use under them must name Nakafa as the source.
186
+
187
+ ## 9. Moral Rights
188
+
189
+ The authors' moral rights, including the right to be named and the right to
190
+ object to distortion, are not waived.
140
191
 
141
192
  ## 10. No Warranty
142
193
 
143
194
  Nakafa is provided "as is" and "as available", without warranties or conditions
144
- of any kind, whether express, implied, statutory, or otherwise.
145
-
146
- PT NAKAFA TEKNO KREATIF does not warrant that Nakafa is accurate, secure,
147
- complete, uninterrupted, error-free, fit for a particular purpose, or
148
- non-infringing.
195
+ of any kind, whether express, implied, statutory, or otherwise. PT NAKAFA TEKNO
196
+ KREATIF does not warrant that Nakafa is accurate, secure, complete,
197
+ uninterrupted, error-free, fit for a particular purpose, or non-infringing.
149
198
 
150
199
  ## 11. Limitation of Liability
151
200
 
152
- To the fullest extent permitted by law, PT NAKAFA TEKNO KREATIF will not be
153
- liable for any indirect, incidental, special, consequential, exemplary, punitive,
154
- or similar damages, or for any loss of profits, revenue, data, goodwill, or
201
+ To the fullest extent the law allows, PT NAKAFA TEKNO KREATIF is not liable for
202
+ any indirect, incidental, special, consequential, exemplary, punitive, or
203
+ similar damages, or for any loss of profits, revenue, data, goodwill, or
155
204
  business opportunity, arising from or related to Nakafa or this license.
156
205
 
157
206
  ## 12. Governing Law and Venue
158
207
 
159
- This license is governed by the laws of the Republic of Indonesia, without
160
- regard to conflict of law principles.
161
-
162
- Except where prohibited by applicable law, any dispute arising out of or related
163
- to this license or Nakafa must be brought exclusively in the courts of the
164
- Republic of Indonesia.
165
-
166
- ## 13. No Waiver
208
+ This license's contract terms are governed by the laws of the Republic of
209
+ Indonesia, without regard to conflict of law principles. Copyright and trademark
210
+ infringement is governed by the law of each country where protection is sought.
211
+ Nothing in this license removes a consumer's right to bring a claim at home or
212
+ to rely on the mandatory protections of their home law. Other disputes are
213
+ decided by the courts of the Republic of Indonesia, except where the law
214
+ forbids this. PT NAKAFA TEKNO KREATIF may also seek an injunction or other
215
+ relief in any court where the infringing use takes place or that has
216
+ jurisdiction over you.
167
217
 
168
- If PT NAKAFA TEKNO KREATIF does not enforce a term immediately, that does not
169
- waive the right to enforce that term later.
218
+ ## 13. Earlier Versions
170
219
 
171
- Any waiver must be in writing and signed by PT NAKAFA TEKNO KREATIF.
220
+ A copy that you lawfully received before the effective date under version 1.0
221
+ stays under version 1.0 for that copy, and only for the acts version 1.0
222
+ allowed. Every act you start on or after the effective date, including a fork,
223
+ publication, recording, post, Benefit, or AI use, is under this version.
224
+ Version 1.0 is the text at commit ec5cb15359fcab334397fe0dc42730d52a2330d3 of
225
+ the nakafa.com repository and commit 9b8cbbd9cc82704d9d7e36af04eb6bb439953fcd
226
+ of the Aksara repository.
172
227
 
173
- ## 14. Severability
228
+ ## 14. No Waiver and Severability
174
229
 
175
- If any part of this license is found unenforceable, the rest remains in effect.
176
- The unenforceable part will be interpreted as narrowly as possible so it becomes
177
- enforceable while preserving the original intent.
230
+ If PT NAKAFA TEKNO KREATIF does not enforce a term at once, it keeps the right
231
+ to enforce it later. A waiver counts only as written permission.
178
232
 
179
- ## 15. Written Permission
233
+ If a court finds any part of this license unenforceable, the rest stays in
234
+ effect, and that part is read as narrowly as needed to be enforceable while
235
+ keeping its purpose.
180
236
 
181
- Commercial, hosted, institutional, redistribution, modification, white-label,
182
- private-label, rebrand, AI-training, or other non-personal use requires a
183
- separate written agreement.
237
+ ## 15. Contact
184
238
 
185
- Contact: nakafaai@gmail.com
239
+ Written permission, licensing questions, and reports of misuse:
240
+ nakafaai@gmail.com
package/README.md CHANGED
@@ -25,6 +25,9 @@ remains trusted executable source.
25
25
 
26
26
  Current consumers use unversioned semantic Interfaces:
27
27
 
28
+ - `tree` owns the signed content tree: a fragment of intrinsic tags, renderer
29
+ components, and text, whose props are JSON data or nested elements.
30
+ `canonicalizeContentTree` gives the bytes that hashes and signatures cover.
28
31
  - `graph/family` classifies either a complete graph identity or one exact
29
32
  asset ID into its application locale and content family.
30
33
  - `tryout/catalog` owns minimal catalog node schemas, while `tryout/identity`
@@ -1,14 +1,20 @@
1
1
  import { Effect } from "effect";
2
- import { ArtifactHashComputationError, ArtifactHashMismatchError, ArtifactVerificationDecodeError } from "#contracts/artifact/spec";
2
+ import { ArtifactHashComputationError, ArtifactHashMismatchError, ArtifactTreeComponentUnlistedError, ArtifactVerificationDecodeError } from "#contracts/artifact/spec";
3
3
  /** Computes the immutable identity of one canonical compiled payload. */
4
4
  export declare const hashCompiledContentPayload: (payload: {
5
5
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
6
- readonly byteLength: number;
7
- readonly compiledCode: string;
8
6
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
9
- readonly compilerVersion: "0.1.0";
7
+ readonly compilerVersion: "0.2.0";
10
8
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
11
- readonly format: "mdx-function-body";
9
+ readonly contentTree: {
10
+ readonly $node: "element";
11
+ readonly children: readonly import("#contracts/tree").ContentTreeChild[];
12
+ readonly name: import("#contracts/tree").ContentTreeElementName;
13
+ readonly props: {
14
+ readonly [key: string]: import("#contracts/tree").ContentTreeValue;
15
+ };
16
+ };
17
+ readonly format: "content-tree";
12
18
  readonly mdxCompilerVersion: "3.1.1";
13
19
  readonly plainText: string;
14
20
  readonly rawMdx: string;
@@ -22,12 +28,18 @@ export declare const verifySignedContentArtifactIntegrity: (input: unknown) => E
22
28
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
23
29
  readonly payload: {
24
30
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
25
- readonly byteLength: number;
26
- readonly compiledCode: string;
27
31
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
28
- readonly compilerVersion: "0.1.0";
32
+ readonly compilerVersion: "0.2.0";
29
33
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
30
- readonly format: "mdx-function-body";
34
+ readonly contentTree: {
35
+ readonly $node: "element";
36
+ readonly children: readonly import("#contracts/tree").ContentTreeChild[];
37
+ readonly name: import("#contracts/tree").ContentTreeElementName;
38
+ readonly props: {
39
+ readonly [key: string]: import("#contracts/tree").ContentTreeValue;
40
+ };
41
+ };
42
+ readonly format: "content-tree";
31
43
  readonly mdxCompilerVersion: "3.1.1";
32
44
  readonly plainText: string;
33
45
  readonly rawMdx: string;
@@ -36,4 +48,4 @@ export declare const verifySignedContentArtifactIntegrity: (input: unknown) => E
36
48
  readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
37
49
  };
38
50
  readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
39
- }, import("#contracts/artifact/spec").ArtifactCompiledByteLengthMismatchError | ArtifactHashComputationError | ArtifactHashMismatchError | import("#contracts/artifact/spec").ArtifactPayloadFieldByteLimitError | import("#contracts/artifact/spec").ArtifactSourceHashComputationError | import("#contracts/artifact/spec").ArtifactSourceHashMismatchError | import("#contracts/artifact/spec").ArtifactVerificationByteLimitError | ArtifactVerificationDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("../signature/spec.js").SignatureCheckError | import("../signature/spec.js").SignatureInvalidError | import("../signature/spec.js").SigningKeyNotFoundError | import("../signature/spec.js").SigningKeyResolutionError, import("../signature/spec.js").ContentVerificationKeyResolver>;
51
+ }, ArtifactHashComputationError | ArtifactHashMismatchError | import("#contracts/artifact/spec").ArtifactPayloadFieldByteLimitError | import("#contracts/artifact/spec").ArtifactSourceHashComputationError | import("#contracts/artifact/spec").ArtifactSourceHashMismatchError | ArtifactTreeComponentUnlistedError | import("#contracts/artifact/spec").ArtifactVerificationByteLimitError | ArtifactVerificationDecodeError | import("../signature/spec.js").PublicKeyParseError | import("../signature/spec.js").PublicKeyTypeError | import("../signature/spec.js").SignatureCheckError | import("../signature/spec.js").SignatureInvalidError | import("../signature/spec.js").SigningKeyNotFoundError | import("../signature/spec.js").SigningKeyResolutionError, import("../signature/spec.js").ContentVerificationKeyResolver>;
@@ -1,10 +1,11 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Array as Arr, Effect, Option, Schema } from "effect";
2
2
  import { validateArtifactByteIntegrity } from "#contracts/artifact/limits";
3
3
  import { verifyCompiledContentSourceHash } from "#contracts/artifact/source";
4
- import { ArtifactHashComputationError, ArtifactHashMismatchError, ArtifactVerificationDecodeError, } from "#contracts/artifact/spec";
4
+ import { ArtifactHashComputationError, ArtifactHashMismatchError, ArtifactTreeComponentUnlistedError, ArtifactVerificationDecodeError, } from "#contracts/artifact/spec";
5
5
  import { canonicalizeCompiledContentPayload, canonicalizeContentArtifactSigningInput, SignedContentArtifactSchema, } from "#contracts/content";
6
6
  import { hashText } from "#contracts/hash/text";
7
7
  import { verifyEd25519Signature } from "#contracts/signature/verify";
8
+ import { contentTreeComponentNames } from "#contracts/tree";
8
9
  /** Computes the immutable identity of one canonical compiled payload. */
9
10
  export const hashCompiledContentPayload = Effect.fn("AksaraContracts.hashCompiledContentPayload")((payload) => hashText(canonicalizeCompiledContentPayload(payload)).pipe(Effect.mapError(() => new ArtifactHashComputationError({ contentKey: payload.contentKey }))));
10
11
  /** Confirms that an artifact envelope identifies its canonical payload. */
@@ -18,6 +19,18 @@ function validateArtifactHash(artifact, actualHash) {
18
19
  expectedHash: artifact.artifactHash,
19
20
  }));
20
21
  }
22
+ /** Confirms that every component the content tree renders is one the artifact requires. */
23
+ function validateTreeComponents(payload) {
24
+ const declared = payload.requiredComponents;
25
+ const unlisted = Arr.findFirst(contentTreeComponentNames(payload.contentTree), (componentName) => !Arr.contains(declared, componentName));
26
+ if (Option.isNone(unlisted)) {
27
+ return Effect.void;
28
+ }
29
+ return Effect.fail(new ArtifactTreeComponentUnlistedError({
30
+ componentName: unlisted.value,
31
+ contentKey: payload.contentKey,
32
+ }));
33
+ }
21
34
  /** Verifies immutable bytes, hashes, source, and signature without a renderer. */
22
35
  function authenticateSignedArtifact(artifact) {
23
36
  return Effect.gen(function* () {
@@ -30,6 +43,7 @@ function authenticateSignedArtifact(artifact) {
30
43
  subject: "artifact",
31
44
  });
32
45
  yield* validateArtifactByteIntegrity(artifact);
46
+ yield* validateTreeComponents(artifact.payload);
33
47
  yield* verifyCompiledContentSourceHash(artifact.payload);
34
48
  return artifact;
35
49
  });
@@ -1,17 +1,23 @@
1
1
  import { Effect } from "effect";
2
- import { ArtifactCompiledByteLengthMismatchError, ArtifactPayloadFieldByteLimitError, ArtifactVerificationByteLimitError } from "#contracts/artifact/spec";
3
- /** Verifies complete wire, declared bytes, and every bounded payload field. */
2
+ import { ArtifactPayloadFieldByteLimitError, ArtifactVerificationByteLimitError } from "#contracts/artifact/spec";
3
+ /** Verifies the complete wire and every bounded payload field. */
4
4
  export declare const validateArtifactByteIntegrity: (artifact: {
5
5
  readonly artifactHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
6
6
  readonly keyId: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSigningKeyId">;
7
7
  readonly payload: {
8
8
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
9
- readonly byteLength: number;
10
- readonly compiledCode: string;
11
9
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
12
- readonly compilerVersion: "0.1.0";
10
+ readonly compilerVersion: "0.2.0";
13
11
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
14
- readonly format: "mdx-function-body";
12
+ readonly contentTree: {
13
+ readonly $node: "element";
14
+ readonly children: readonly import("#contracts/tree").ContentTreeChild[];
15
+ readonly name: import("#contracts/tree").ContentTreeElementName;
16
+ readonly props: {
17
+ readonly [key: string]: import("#contracts/tree").ContentTreeValue;
18
+ };
19
+ };
20
+ readonly format: "content-tree";
15
21
  readonly mdxCompilerVersion: "3.1.1";
16
22
  readonly plainText: string;
17
23
  readonly rawMdx: string;
@@ -20,4 +26,4 @@ export declare const validateArtifactByteIntegrity: (artifact: {
20
26
  readonly sourceHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
21
27
  };
22
28
  readonly signature: string & import("effect/Brand").Brand<"@NakafaAI/AksaraEd25519Signature">;
23
- }) => Effect.Effect<undefined, ArtifactCompiledByteLengthMismatchError | ArtifactPayloadFieldByteLimitError | ArtifactVerificationByteLimitError, never>;
29
+ }) => Effect.Effect<void, ArtifactPayloadFieldByteLimitError | ArtifactVerificationByteLimitError, never>;
@@ -1,7 +1,8 @@
1
1
  import { Effect } from "effect";
2
- import { ArtifactCompiledByteLengthMismatchError, ArtifactPayloadFieldByteLimitError, ArtifactVerificationByteLimitError, } from "#contracts/artifact/spec";
2
+ import { ArtifactPayloadFieldByteLimitError, ArtifactVerificationByteLimitError, } from "#contracts/artifact/spec";
3
3
  import { canonicalizeCompiledContentPayload, canonicalizeSignedContentArtifact, } from "#contracts/content";
4
- import { MAX_CANONICAL_PAYLOAD_BYTES, MAX_COMPILED_CODE_BYTES, MAX_PLAIN_TEXT_BYTES, MAX_RAW_MDX_BYTES, MAX_SIGNED_ARTIFACT_BYTES, } from "#contracts/limits";
4
+ import { MAX_CANONICAL_PAYLOAD_BYTES, MAX_CONTENT_TREE_BYTES, MAX_PLAIN_TEXT_BYTES, MAX_RAW_MDX_BYTES, MAX_SIGNED_ARTIFACT_BYTES, } from "#contracts/limits";
5
+ import { canonicalizeContentTree } from "#contracts/tree";
5
6
  /** Rejects a complete signed artifact envelope above its wire ceiling. */
6
7
  function enforceSignedWireLimit(artifact) {
7
8
  const actualBytes = new TextEncoder().encode(canonicalizeSignedContentArtifact(artifact)).byteLength;
@@ -26,20 +27,12 @@ function enforcePayloadFieldLimit(payload, field, value, maxBytes) {
26
27
  maxBytes,
27
28
  }));
28
29
  }
29
- /** Verifies complete wire, declared bytes, and every bounded payload field. */
30
+ /** Verifies the complete wire and every bounded payload field. */
30
31
  export const validateArtifactByteIntegrity = Effect.fn("AksaraContracts.validateArtifactByteIntegrity")(function* (artifact) {
31
32
  yield* enforceSignedWireLimit(artifact);
32
33
  const { payload } = artifact;
33
- const compiledBytes = new TextEncoder().encode(payload.compiledCode).byteLength;
34
- if (payload.byteLength !== compiledBytes) {
35
- return yield* new ArtifactCompiledByteLengthMismatchError({
36
- actualBytes: compiledBytes,
37
- contentKey: payload.contentKey,
38
- declaredBytes: payload.byteLength,
39
- });
40
- }
41
34
  yield* enforcePayloadFieldLimit(payload, "rawMdx", payload.rawMdx, MAX_RAW_MDX_BYTES);
42
- yield* enforcePayloadFieldLimit(payload, "compiledCode", payload.compiledCode, MAX_COMPILED_CODE_BYTES);
35
+ yield* enforcePayloadFieldLimit(payload, "contentTree", canonicalizeContentTree(payload.contentTree), MAX_CONTENT_TREE_BYTES);
43
36
  yield* enforcePayloadFieldLimit(payload, "plainText", payload.plainText, MAX_PLAIN_TEXT_BYTES);
44
37
  yield* enforcePayloadFieldLimit(payload, "canonicalPayload", canonicalizeCompiledContentPayload(payload), MAX_CANONICAL_PAYLOAD_BYTES);
45
38
  });
@@ -3,12 +3,18 @@ import { ArtifactSourceHashComputationError, ArtifactSourceHashMismatchError } f
3
3
  /** Verifies that sourceHash identifies the complete authenticated raw MDX. */
4
4
  export declare const verifyCompiledContentSourceHash: (payload: {
5
5
  readonly artifactLocale: ("de" | "en" | "id") & import("effect/Brand").Brand<"@NakafaAI/AksaraArtifactLocale">;
6
- readonly byteLength: number;
7
- readonly compiledCode: string;
8
6
  readonly compilerConfigHash: string & import("effect/Brand").Brand<"@NakafaAI/AksaraSha256Hash">;
9
- readonly compilerVersion: "0.1.0";
7
+ readonly compilerVersion: "0.2.0";
10
8
  readonly contentKey: string & import("effect/Brand").Brand<"@NakafaAI/AksaraContentKey">;
11
- readonly format: "mdx-function-body";
9
+ readonly contentTree: {
10
+ readonly $node: "element";
11
+ readonly children: readonly import("../tree.js").ContentTreeChild[];
12
+ readonly name: import("../tree.js").ContentTreeElementName;
13
+ readonly props: {
14
+ readonly [key: string]: import("../tree.js").ContentTreeValue;
15
+ };
16
+ };
17
+ readonly format: "content-tree";
12
18
  readonly mdxCompilerVersion: "3.1.1";
13
19
  readonly plainText: string;
14
20
  readonly rawMdx: string;