@cello-protocol/protocol-types 0.0.53 → 0.0.55

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 (41) hide show
  1. package/dist/document-amendment.d.ts +133 -0
  2. package/dist/document-amendment.d.ts.map +1 -0
  3. package/dist/document-amendment.js +229 -0
  4. package/dist/document-amendment.js.map +1 -0
  5. package/dist/document-derive.d.ts +96 -0
  6. package/dist/document-derive.d.ts.map +1 -0
  7. package/dist/document-derive.js +605 -0
  8. package/dist/document-derive.js.map +1 -0
  9. package/dist/document-envelope.d.ts +18 -8
  10. package/dist/document-envelope.d.ts.map +1 -1
  11. package/dist/document-envelope.js +35 -19
  12. package/dist/document-envelope.js.map +1 -1
  13. package/dist/document-governance.d.ts +40 -0
  14. package/dist/document-governance.d.ts.map +1 -0
  15. package/dist/document-governance.js +145 -0
  16. package/dist/document-governance.js.map +1 -0
  17. package/dist/document-multisig.d.ts +81 -0
  18. package/dist/document-multisig.d.ts.map +1 -0
  19. package/dist/document-multisig.js +185 -0
  20. package/dist/document-multisig.js.map +1 -0
  21. package/dist/document-proposal.d.ts +29 -14
  22. package/dist/document-proposal.d.ts.map +1 -1
  23. package/dist/document-proposal.js +101 -7
  24. package/dist/document-proposal.js.map +1 -1
  25. package/dist/document-reconcile.d.ts +100 -0
  26. package/dist/document-reconcile.d.ts.map +1 -0
  27. package/dist/document-reconcile.js +197 -0
  28. package/dist/document-reconcile.js.map +1 -0
  29. package/dist/index.d.ts +14 -6
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +9 -4
  32. package/dist/index.js.map +1 -1
  33. package/package.json +2 -2
  34. package/dist/document-ack.d.ts +0 -111
  35. package/dist/document-ack.d.ts.map +0 -1
  36. package/dist/document-ack.js +0 -228
  37. package/dist/document-ack.js.map +0 -1
  38. package/dist/document-control.d.ts +0 -74
  39. package/dist/document-control.d.ts.map +0 -1
  40. package/dist/document-control.js +0 -174
  41. package/dist/document-control.js.map +0 -1
@@ -0,0 +1,185 @@
1
+ /**
2
+ * DOD-MP-SIG-1 — the multi-signature primitive: N Ed25519 signatures over ONE preimage.
3
+ *
4
+ * A collection is COMPLETE only when every signer in the required set has a verifying signature —
5
+ * no more, no fewer, no substitutes. Anything short of that is a partial collection: storable
6
+ * while signatures are being gathered, never valid. Completeness is computed independently by any
7
+ * holder from the collection alone plus a verifier; there is no coordinator whose word settles it.
8
+ *
9
+ * ── GENERIC BY CONSTRUCTION ───────────────────────────────────────────────────────────────────
10
+ *
11
+ * Nothing in this module knows what an amendment is. The subject is carried as
12
+ * `(subject_kind, subject_hash)` — the hash of the subject's OWN to-be-signed structure — so the
13
+ * amendment record (its first consumer) and Tier 2's N-way quiescence agreement (its named second)
14
+ * use the same preimage builder and the same completeness rule. Anything subject-specific growing
15
+ * in here is the drift the M14B Tier-2-readiness lens blocks.
16
+ *
17
+ * ── THE PREIMAGE COMMITS TO WHO MUST SIGN ─────────────────────────────────────────────────────
18
+ *
19
+ * `required_signers` is inside the signed bytes, sorted so the set — not the order it was typed
20
+ * in — is what is committed. Each signer therefore signs knowing exactly which co-signatures the
21
+ * collection needs: a signature given as "the sole required signer" cannot be replayed into a
22
+ * collection claiming a different signer set, because the preimage differs and the signature
23
+ * stops verifying. Replay across chain positions is the SUBJECT's job to prevent (its TBS chains
24
+ * to its predecessor), not this layer's.
25
+ *
26
+ * Signatures are Ed25519 (RFC 8032) over the SHA-256 of the preimage array, matching the sibling
27
+ * envelope builders. Verification is injected — the same seam the proposal path uses — so this
28
+ * module stays pure types + bytes.
29
+ */
30
+ import { createHash } from "node:crypto";
31
+ import { encodeCbor, decodeCbor } from "./cbor.js";
32
+ /** Domain tag in slot 0 of the to-be-signed array. Distinct from every sibling envelope domain. */
33
+ export const DOCUMENT_MULTISIG_DOMAIN = "CELLO-DOCUMENT-MULTISIG-v1";
34
+ /**
35
+ * The signer set, validated and canonicalized: non-empty, no duplicates, sorted.
36
+ *
37
+ * Duplicates are REFUSED rather than deduped — a duplicate in a required set is a builder bug,
38
+ * and silently collapsing it would change the preimage under a caller who believes they know
39
+ * what they asked N parties to sign.
40
+ */
41
+ function canonicalSigners(signers) {
42
+ if (signers.length === 0) {
43
+ throw new Error("multisig_empty_signer_set: a collection nobody is required to sign is not a rule — " +
44
+ "the required set must name at least one signer");
45
+ }
46
+ const sorted = [...signers].sort();
47
+ for (let i = 1; i < sorted.length; i++) {
48
+ if (sorted[i] === sorted[i - 1]) {
49
+ throw new Error(`multisig_duplicate_signer: ${sorted[i]} appears more than once in the required set`);
50
+ }
51
+ }
52
+ for (const s of sorted) {
53
+ if (typeof s !== "string" || s.length === 0) {
54
+ throw new Error("multisig_signer_type: every required signer must be a non-empty string");
55
+ }
56
+ }
57
+ return sorted;
58
+ }
59
+ /**
60
+ * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
61
+ * SHA-256 pre-hashed by default, matching the sibling builders.
62
+ */
63
+ export function buildDocumentMultisigTbs(subject, opts = {}) {
64
+ const preimage = encodeCbor([
65
+ DOCUMENT_MULTISIG_DOMAIN,
66
+ subject.document_id,
67
+ subject.subject_kind,
68
+ subject.subject_hash,
69
+ canonicalSigners(subject.required_signers),
70
+ ]);
71
+ if (opts.preHash === false)
72
+ return preimage;
73
+ return new Uint8Array(createHash("sha256").update(preimage).digest());
74
+ }
75
+ /**
76
+ * Completeness, computed from the collection alone plus an injected verifier.
77
+ *
78
+ * Every defect class is NAMED rather than folded into a boolean, because the operator-facing
79
+ * question differs: "waiting on C" (missing), "B's signature is bad" (invalid), "someone outside
80
+ * the arrangement signed" (unknown — refused because extra names must not make a collection look
81
+ * more agreed than the rule it commits to), and "B signed twice" (duplicate).
82
+ */
83
+ export function collectionStatus(collection, verify) {
84
+ const required = new Set(canonicalSigners(collection.required_signers));
85
+ const tbs = buildDocumentMultisigTbs(collection);
86
+ const seen = new Set();
87
+ const invalidSigners = [];
88
+ const unknown = [];
89
+ const duplicates = [];
90
+ for (const { signer_agent_id, signature } of collection.signatures) {
91
+ if (seen.has(signer_agent_id)) {
92
+ duplicates.push(signer_agent_id);
93
+ continue;
94
+ }
95
+ seen.add(signer_agent_id);
96
+ if (!required.has(signer_agent_id)) {
97
+ unknown.push(signer_agent_id);
98
+ continue;
99
+ }
100
+ if (!verify(signer_agent_id, tbs, signature)) {
101
+ invalidSigners.push(signer_agent_id);
102
+ }
103
+ }
104
+ // A signer whose signature failed is INVALID, not missing — the two send the operator to
105
+ // different fixes — so missing is strictly "no row present at all".
106
+ const missing = [...required].filter((id) => !seen.has(id));
107
+ return {
108
+ complete: missing.length === 0 &&
109
+ invalidSigners.length === 0 &&
110
+ unknown.length === 0 &&
111
+ duplicates.length === 0,
112
+ missing,
113
+ invalidSigners,
114
+ unknown,
115
+ duplicates,
116
+ };
117
+ }
118
+ export function encodeMultisigCollection(collection) {
119
+ return encodeCbor({
120
+ document_id: collection.document_id,
121
+ subject_kind: collection.subject_kind,
122
+ subject_hash: collection.subject_hash,
123
+ required_signers: canonicalSigners(collection.required_signers),
124
+ signatures: collection.signatures.map((s) => ({
125
+ signer_agent_id: s.signer_agent_id,
126
+ signature: s.signature,
127
+ })),
128
+ });
129
+ }
130
+ function present(map, field) {
131
+ if (!(field in map)) {
132
+ throw new Error(`multisig_missing_field: ${field} is mandatory and was not present`);
133
+ }
134
+ return map[field];
135
+ }
136
+ function str(map, field) {
137
+ const v = present(map, field);
138
+ if (typeof v !== "string" || v.length === 0) {
139
+ throw new Error(`multisig_field_type: ${field} must be a non-empty text string`);
140
+ }
141
+ return v;
142
+ }
143
+ function bytes(map, field) {
144
+ const v = present(map, field);
145
+ if (!(v instanceof Uint8Array)) {
146
+ throw new Error(`multisig_field_type: ${field} must be a CBOR byte string`);
147
+ }
148
+ // Copied — cbor-x returns views into the decoded buffer.
149
+ return new Uint8Array(v);
150
+ }
151
+ export function decodeMultisigCollection(input) {
152
+ const decoded = decodeCbor(input);
153
+ if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
154
+ throw new Error("multisig_malformed: not a CBOR map");
155
+ }
156
+ const map = decoded;
157
+ const rawSigners = present(map, "required_signers");
158
+ if (!Array.isArray(rawSigners) || rawSigners.some((s) => typeof s !== "string")) {
159
+ throw new Error("multisig_field_type: required_signers must be an array of strings");
160
+ }
161
+ const rawSignatures = present(map, "signatures");
162
+ if (!Array.isArray(rawSignatures)) {
163
+ throw new Error("multisig_field_type: signatures must be an array");
164
+ }
165
+ const signatures = rawSignatures.map((entry, i) => {
166
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
167
+ throw new Error(`multisig_field_type: signatures[${i}] must be a CBOR map`);
168
+ }
169
+ const e = entry;
170
+ return {
171
+ signer_agent_id: str(e, "signer_agent_id"),
172
+ signature: bytes(e, "signature"),
173
+ };
174
+ });
175
+ return {
176
+ document_id: str(map, "document_id"),
177
+ subject_kind: str(map, "subject_kind"),
178
+ subject_hash: bytes(map, "subject_hash"),
179
+ // Canonicalized on decode as well — a wire producer that shipped duplicates or an empty set
180
+ // is refused here, before any completeness question is asked.
181
+ required_signers: canonicalSigners(rawSigners),
182
+ signatures,
183
+ };
184
+ }
185
+ //# sourceMappingURL=document-multisig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-multisig.js","sourceRoot":"","sources":["../src/document-multisig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,mGAAmG;AACnG,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAwBrE;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,OAA0B;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,qFAAqF;YACnF,gDAAgD,CACnD,CAAC;IACJ,CAAC;IACD,MAAM,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AC,CAAC,EAAE,WAAW,CAAC;SACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC;QACpC,YAAY,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC;QACtC,YAAY,EAAE,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC;QACxC,4FAA4F;QAC5F,8DAA8D;QAC9D,gBAAgB,EAAE,gBAAgB,CAAC,UAAsB,CAAC;QAC1D,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * ── THE SEAM (§3.4, §11.1) ────────────────────────────────────────────────────────────────────
14
14
  *
15
- * Three properties are DECLARED in V1 but support exactly one value each, and the pattern is
15
+ * Seam properties are DECLARED with a closed accepted-value set, and the pattern is
16
16
  * deliberate — §3.3 chose it for `schema_enforcement` and §16.1 generalized it. Declaring a field
17
17
  * that only accepts one value looks redundant until you need the second value: the field is
18
18
  * already on the wire and already signed, so V2 is a validation change rather than a wire break
@@ -31,17 +31,27 @@
31
31
  * answered and the operator sees a hang. `documentFeatureIncompatibility` turns that into "your
32
32
  * peer's client doesn't support shared documents yet — ask them to upgrade".
33
33
  */
34
+ import type { ArrangementGenesis } from "./document-amendment.js";
34
35
  /** Domain tag in slot 0 of the to-be-signed array. Distinct from the UPDATE envelope's domain. */
35
36
  export declare const DOCUMENT_PROPOSAL_DOMAIN = "CELLO-DOCUMENT-PROPOSAL-v1";
36
37
  /**
37
38
  * The document feature version this build speaks. Bumped when the document wire changes in a way
38
39
  * a peer must understand; see `documentFeatureIncompatibility` for what a mismatch produces.
39
40
  */
40
- export declare const DOCUMENT_FEATURE_VERSION = 1;
41
+ export declare const DOCUMENT_FEATURE_VERSION = 2;
41
42
  /** §6 — Tier 1. Tier 2 (attested) is V2; the field exists so V2 is a validation change. */
42
43
  export declare const ASSURANCE_TIER_V1 = "authenticated";
43
- /** §11 — the pairwise two-document form. Mesh is deferred (§11.1). */
44
- export declare const TOPOLOGY_V1 = "hub-and-spoke";
44
+ /**
45
+ * DOD-MP-TOPOLOGY-1 (ruling D4, 2026-08-13): `mesh` is the DEFAULT — one document, N holders,
46
+ * everyone delivers to everyone, which is what the M14B machinery does regardless of the label.
47
+ * `hub-and-spoke` survives as an accepted VALUE only (the wire field is signed into
48
+ * `document_id`, and a document so labeled behaves identically — the broker case is served by
49
+ * construction: two ordinary documents). Nothing else is accepted; the refusal names the
50
+ * mismatch at BOTH ends, because the proposer and accepter run different builds and one-sided
51
+ * validation lets whichever side is newer decide for both.
52
+ */
53
+ export declare const TOPOLOGY_DEFAULT = "mesh";
54
+ export declare const SUPPORTED_TOPOLOGIES: ReadonlySet<string>;
45
55
  export type DocumentConsentState = "pending" | "accepted" | "refused";
46
56
  /**
47
57
  * The properties agreed at handshake (§3.4). **Immutable after accept** — a property change is an
@@ -54,7 +64,7 @@ export interface DocumentProperties {
54
64
  assurance_tier: string;
55
65
  /** Only `false` in V1 — the schema-as-first-update path (§3.3) is V2. */
56
66
  schema_enforcement: boolean;
57
- /** Only `hub-and-spoke` in V1. */
67
+ /** `mesh` (the default) or `hub-and-spoke` anything else refuses at both ends. */
58
68
  topology: string;
59
69
  /** Receiver-local append-only enforcement (§16.7-1). Freely settable — not a seam field. */
60
70
  append_only: boolean;
@@ -71,6 +81,15 @@ export interface DocumentProperties {
71
81
  * 412" is not.
72
82
  */
73
83
  content_profile?: string;
84
+ /**
85
+ * M14B / DOD-MP-AMEND-1 — the admin set fixed at creation (ruling D2, 2026-08-11): the
86
+ * pubkey-hex identities holding admin power over this document's arrangement. Signed into the
87
+ * preimage — and therefore into `document_id` — because WHO governs the document is part of
88
+ * what the invitee consents to. Absent means EVERY genesis participant is an admin (the
89
+ * bilateral default: either party can invite). The set is canonicalized sorted; membership
90
+ * must be ⊆ the genesis participants, enforced at accept and again at every replay.
91
+ */
92
+ admin_set?: string[];
74
93
  }
75
94
  export interface DocumentProposalEnvelope {
76
95
  type: "document_proposal";
@@ -93,15 +112,6 @@ export interface DocumentProposalEnvelope {
93
112
  /** Ed25519 (RFC 8032) over `buildDocumentProposalTbs`. */
94
113
  signature: Uint8Array;
95
114
  }
96
- /**
97
- * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
98
- *
99
- * The properties are flattened into their own slots rather than nested as a map. `encodeCbor` is
100
- * not deterministic for maps — keys follow insertion order — so a nested `properties` object would
101
- * make the signature depend on the order the proposer happened to build it in, and two honest
102
- * builds of the same proposal would produce different `document_id`s. For this envelope that is
103
- * worse than a bad signature: the id IS the hash, so the two parties would be on two documents.
104
- */
105
115
  export declare function buildDocumentProposalTbs(env: DocumentProposalEnvelope, opts?: {
106
116
  preHash?: boolean;
107
117
  }): Uint8Array;
@@ -137,4 +147,9 @@ export declare function encodeDocumentProposal(env: DocumentProposalEnvelope): U
137
147
  * version exists to replace.
138
148
  */
139
149
  export declare function decodeDocumentProposal(input: Uint8Array): DocumentProposalEnvelope;
150
+ /**
151
+ * The genesis PROPOSAL as the fold's anchor (SYNC-P1). Lived in the join-offer module until D5
152
+ * deleted it; the conversion belongs to the proposal itself — every derivation starts here.
153
+ */
154
+ export declare function arrangementGenesisFromProposal(genesis: DocumentProposalEnvelope): ArrangementGenesis;
140
155
  //# sourceMappingURL=document-proposal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-proposal.d.ts","sourceRoot":"","sources":["../src/document-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AACjD,sEAAsE;AACtE,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,UAAU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BAAkB,CAAC;IAC/B;;;;OAIG;IACH,gBAAgB,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,yFAAyF;IACzF,KAAK,EAAE,UAAU,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,SAAS,EAAE,UAAU,CAAC;CACvB;AAgCD,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,wBAAwB,EAC7B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/B,UAAU,CA8CZ;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,wBAAwB,GAAG,MAAM,CAI5E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAkDtE;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAoB/F;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,wBAAwB,GAAG,UAAU,CA4BhF;AA6BD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,GAAG,wBAAwB,CAoFlF;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,wBAAwB,GAChC,kBAAkB,CAgBpB"}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * ── THE SEAM (§3.4, §11.1) ────────────────────────────────────────────────────────────────────
14
14
  *
15
- * Three properties are DECLARED in V1 but support exactly one value each, and the pattern is
15
+ * Seam properties are DECLARED with a closed accepted-value set, and the pattern is
16
16
  * deliberate — §3.3 chose it for `schema_enforcement` and §16.1 generalized it. Declaring a field
17
17
  * that only accepts one value looks redundant until you need the second value: the field is
18
18
  * already on the wire and already signed, so V2 is a validation change rather than a wire break
@@ -39,11 +39,20 @@ export const DOCUMENT_PROPOSAL_DOMAIN = "CELLO-DOCUMENT-PROPOSAL-v1";
39
39
  * The document feature version this build speaks. Bumped when the document wire changes in a way
40
40
  * a peer must understand; see `documentFeatureIncompatibility` for what a mismatch produces.
41
41
  */
42
- export const DOCUMENT_FEATURE_VERSION = 1;
42
+ export const DOCUMENT_FEATURE_VERSION = 2;
43
43
  /** §6 — Tier 1. Tier 2 (attested) is V2; the field exists so V2 is a validation change. */
44
44
  export const ASSURANCE_TIER_V1 = "authenticated";
45
- /** §11 — the pairwise two-document form. Mesh is deferred (§11.1). */
46
- export const TOPOLOGY_V1 = "hub-and-spoke";
45
+ /**
46
+ * DOD-MP-TOPOLOGY-1 (ruling D4, 2026-08-13): `mesh` is the DEFAULT — one document, N holders,
47
+ * everyone delivers to everyone, which is what the M14B machinery does regardless of the label.
48
+ * `hub-and-spoke` survives as an accepted VALUE only (the wire field is signed into
49
+ * `document_id`, and a document so labeled behaves identically — the broker case is served by
50
+ * construction: two ordinary documents). Nothing else is accepted; the refusal names the
51
+ * mismatch at BOTH ends, because the proposer and accepter run different builds and one-sided
52
+ * validation lets whichever side is newer decide for both.
53
+ */
54
+ export const TOPOLOGY_DEFAULT = "mesh";
55
+ export const SUPPORTED_TOPOLOGIES = new Set(["mesh", "hub-and-spoke"]);
47
56
  /**
48
57
  * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
49
58
  *
@@ -53,6 +62,24 @@ export const TOPOLOGY_V1 = "hub-and-spoke";
53
62
  * builds of the same proposal would produce different `document_id`s. For this envelope that is
54
63
  * worse than a bad signature: the id IS the hash, so the two parties would be on two documents.
55
64
  */
65
+ /** Sorted, duplicate-refusing canonical form — the SET is what is signed, not the typing order. */
66
+ function canonicalAdminSet(adminSet) {
67
+ const sorted = [...adminSet].sort();
68
+ for (let i = 0; i < sorted.length; i++) {
69
+ // 64-hex ENFORCED, not assumed. The TBS folds the set to a ","-joined scalar, and the join is
70
+ // collision-free only because a pubkey cannot contain the separator — an unvalidated entry
71
+ // like "aa,bb" would let two different admin sets share one preimage, one document_id, and
72
+ // one valid signature. The charset IS the boundary.
73
+ if (typeof sorted[i] !== "string" || !/^[0-9a-f]{64}$/.test(sorted[i])) {
74
+ throw new Error("document_proposal_admin_set: every admin must be a 64-hex Ed25519 pubkey — got " +
75
+ JSON.stringify(sorted[i]));
76
+ }
77
+ if (i > 0 && sorted[i] === sorted[i - 1]) {
78
+ throw new Error(`document_proposal_admin_set: ${sorted[i]} appears more than once`);
79
+ }
80
+ }
81
+ return sorted;
82
+ }
56
83
  export function buildDocumentProposalTbs(env, opts = {}) {
57
84
  const preimage = encodeCbor([
58
85
  DOCUMENT_PROPOSAL_DOMAIN,
@@ -77,6 +104,11 @@ export function buildDocumentProposalTbs(env, opts = {}) {
77
104
  // `null` when the proposer named none, so the slot is always occupied and no field's meaning
78
105
  // depends on whether the one before it was present.
79
106
  env.properties.content_profile ?? null,
107
+ // DOD-MP-AMEND-1's slot, feature_version 2. A SCALAR — sorted-unique pubkeys joined with
108
+ // "," (hex carries no comma) — because this preimage's flatness invariant (no nested
109
+ // containers, pinned by test) is what keeps the id independent of any container encoding.
110
+ // `null` when the proposer named none, so the slot is always occupied.
111
+ env.properties.admin_set === undefined ? null : canonicalAdminSet(env.properties.admin_set).join(","),
80
112
  env.starting_content,
81
113
  env.nonce,
82
114
  // BIGINT past 0xffffffff — the same coercion three sibling builders carry and which
@@ -139,9 +171,22 @@ export function seamViolation(props) {
139
171
  return (`content_profile must be a profile NAME (a string) or absent; this build cannot agree a ` +
140
172
  `document whose character space is declared as something else`);
141
173
  }
142
- if (props.topology !== TOPOLOGY_V1) {
143
- return (`document_seam_topology: this version supports "${TOPOLOGY_V1}" only, and the proposal asks ` +
144
- `for "${props.topology}" mesh documents (§11.1) are not yet built`);
174
+ if (props.admin_set !== undefined) {
175
+ if (!Array.isArray(props.admin_set) || props.admin_set.length === 0) {
176
+ return ("document_proposal_admin_set: when declared, the admin set must be a non-empty list of " +
177
+ "pubkeys — an empty list is a document nobody can ever amend");
178
+ }
179
+ try {
180
+ canonicalAdminSet(props.admin_set);
181
+ }
182
+ catch (err) {
183
+ return err instanceof Error ? err.message : String(err);
184
+ }
185
+ }
186
+ if (!SUPPORTED_TOPOLOGIES.has(props.topology)) {
187
+ return (`document_seam_topology: this version supports ${[...SUPPORTED_TOPOLOGIES]
188
+ .map((v) => `"${v}"`)
189
+ .join(" and ")}, and the proposal asks for "${props.topology}"`);
145
190
  }
146
191
  return null;
147
192
  }
@@ -178,6 +223,16 @@ export function encodeDocumentProposal(env) {
178
223
  schema_enforcement: env.properties.schema_enforcement,
179
224
  topology: env.properties.topology,
180
225
  append_only: env.properties.append_only,
226
+ // Present only when declared — the TBS signs this slot (`?? null`), so an encoding that
227
+ // drops it has the receiver rebuild a different preimage and refuse the signature of every
228
+ // profiled proposal. Absent stays absent so profile-less proposals keep their pre-profile
229
+ // byte encoding.
230
+ ...(env.properties.content_profile !== undefined
231
+ ? { content_profile: env.properties.content_profile }
232
+ : {}),
233
+ ...(env.properties.admin_set !== undefined
234
+ ? { admin_set: canonicalAdminSet(env.properties.admin_set) }
235
+ : {}),
181
236
  },
182
237
  starting_content: env.starting_content,
183
238
  nonce: env.nonce,
@@ -242,6 +297,22 @@ export function decodeDocumentProposal(input) {
242
297
  if (typeof appendOnly !== "boolean") {
243
298
  throw new Error("document_proposal_field_type: properties.append_only must be a boolean");
244
299
  }
300
+ // OPTIONAL, unlike the seam fields above — documents agreed before profiles existed carry none,
301
+ // and `present` would refuse every one of them. When declared it must be a name; membership in
302
+ // the closed set is the gate's question (`seamViolation` checks shape, the daemon checks names).
303
+ // CANONICAL FORM: absent is the only encoding of "no profile". The TBS folds absent and null to
304
+ // the same signed slot, but an explicit `content_profile: null` on the wire is REFUSED here —
305
+ // one preimage, one decodable byte encoding. A second implementation must emit absent, not null.
306
+ const adminSet = "admin_set" in p ? p["admin_set"] : undefined;
307
+ if (adminSet !== undefined) {
308
+ if (!Array.isArray(adminSet) || adminSet.length === 0 || adminSet.some((s) => typeof s !== "string")) {
309
+ throw new Error("document_proposal_field_type: properties.admin_set must be a non-empty array of strings when present");
310
+ }
311
+ }
312
+ const contentProfile = "content_profile" in p ? p["content_profile"] : undefined;
313
+ if (contentProfile !== undefined && (typeof contentProfile !== "string" || contentProfile.length === 0)) {
314
+ throw new Error("document_proposal_field_type: properties.content_profile must be a non-empty text string when present");
315
+ }
245
316
  const startingContent = present(map, "starting_content");
246
317
  if (startingContent !== null && !(startingContent instanceof Uint8Array)) {
247
318
  throw new Error("document_proposal_field_type: starting_content must be a CBOR byte string or explicit null");
@@ -261,6 +332,8 @@ export function decodeDocumentProposal(input) {
261
332
  schema_enforcement: schemaEnforcement,
262
333
  topology: str(p, "topology"),
263
334
  append_only: appendOnly,
335
+ ...(contentProfile !== undefined ? { content_profile: contentProfile } : {}),
336
+ ...(adminSet !== undefined ? { admin_set: canonicalAdminSet(adminSet) } : {}),
264
337
  },
265
338
  starting_content: startingContent === null ? null : new Uint8Array(startingContent),
266
339
  nonce: bytes(map, "nonce"),
@@ -268,4 +341,25 @@ export function decodeDocumentProposal(input) {
268
341
  signature: bytes(map, "signature"),
269
342
  };
270
343
  }
344
+ /**
345
+ * The genesis PROPOSAL as the fold's anchor (SYNC-P1). Lived in the join-offer module until D5
346
+ * deleted it; the conversion belongs to the proposal itself — every derivation starts here.
347
+ */
348
+ export function arrangementGenesisFromProposal(genesis) {
349
+ return {
350
+ documentId: documentIdFromProposal(genesis),
351
+ proposerAgentId: genesis.proposer_agent_id,
352
+ peerAgentId: genesis.peer_agent_id,
353
+ adminSet: genesis.properties.admin_set ?? [genesis.proposer_agent_id, genesis.peer_agent_id],
354
+ properties: {
355
+ assurance_tier: genesis.properties.assurance_tier,
356
+ schema_enforcement: genesis.properties.schema_enforcement,
357
+ topology: genesis.properties.topology,
358
+ append_only: genesis.properties.append_only,
359
+ ...(genesis.properties.content_profile !== undefined
360
+ ? { content_profile: genesis.properties.content_profile }
361
+ : {}),
362
+ },
363
+ };
364
+ }
271
365
  //# sourceMappingURL=document-pro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AAW;YAC3C,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,KAAK,SAAS;gBAClD,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE;gBACzD,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * SYNC-P3 (R10–R16) — the reconcile frame: ONE wire shape for all three exchange steps.
3
+ *
4
+ * | Step | Direction | Carries |
5
+ * |------|-----------|---------|
6
+ * | 1 | A → B | per document: A's positions + A's refusal set (payload arrays empty) |
7
+ * | 2 | B → A | entries/envelopes A lacks, plus B's positions + refusal set |
8
+ * | 3 | A → B | entries/envelopes B lacks — sent only if B is behind |
9
+ *
10
+ * One shape means a lost reply degrades to a fresh exchange; there is no half-open protocol
11
+ * state to wedge, and reconciling stays idempotent by construction (R15).
12
+ *
13
+ * POSITION IS THE R7 PRIMITIVE, both halves:
14
+ * - governance: per author, the highest CONTIGUOUS entry seq held, with the head hash(es) at
15
+ * that seq — plural heads make a forked (equivocating) author visible on the wire instead of
16
+ * silently divergent (the Entry 48 §3 finding).
17
+ * - content: per author, the length of that author's own envelope chain held, with its head —
18
+ * the store's chain-linkage invariant already guarantees every sender's links form one
19
+ * unbroken chain, so the primitive is the same shape. Refused envelopes occupy chain
20
+ * positions (they are bridged as payload-less stubs); the refusal set is what stops their
21
+ * payloads from being re-offered (R36).
22
+ *
23
+ * NOT SIGNED, deliberately: the frame rides an authenticated session, and a position is
24
+ * advisory by design (R44 — no correctness decision reads it; a peer lying about its position
25
+ * earns wasted bytes, spec §5). What is load-bearing — every entry and envelope carried — is
26
+ * individually signed by its author, and the receiver verifies each itself (R2: forwarding
27
+ * confers no trust).
28
+ */
29
+ /** R11: a version mismatch is refused BY NAME at both ends, with both versions in the sentence. */
30
+ export declare const DOCUMENT_RECONCILE_EXCHANGE_VERSION = 1;
31
+ /** R16 batching ceiling — one frame cannot be made unbounded by naming every document at once. */
32
+ export declare const MAX_RECONCILE_DOCUMENTS = 32;
33
+ export interface GovernancePosition {
34
+ author: string;
35
+ /** Highest contiguous entry seq held from this author (R13: contiguous, never highest-received). */
36
+ seq: number;
37
+ /** Entry hash(es) at that seq. More than one = a fork, visible by design. */
38
+ head_hashes: string[];
39
+ }
40
+ export interface ContentPosition {
41
+ author: string;
42
+ /** How many of this author's own-chain envelopes are held (refused stubs included). */
43
+ count: number;
44
+ /** The envelope hash at the head of this author's chain as held. */
45
+ head_hash: string;
46
+ }
47
+ export interface DocumentReconcileBlock {
48
+ document_id: string;
49
+ governance: GovernancePosition[];
50
+ content: ContentPosition[];
51
+ /** Hashes this holder has refused (entries or envelopes) — never re-offer these (R36). */
52
+ refused: string[];
53
+ /** Governance entry wires the peer lacks. Empty on step 1. */
54
+ entries: Uint8Array[];
55
+ /** Content envelope wires the peer lacks. Empty on step 1. */
56
+ envelopes: Uint8Array[];
57
+ /**
58
+ * SYNC-R35: this holder's OWN signed refusal records (document_rejection wires) for this
59
+ * document — the refusal travels by the ordinary exchange like anything else, so a third
60
+ * holder wedged behind a refused hash can learn its name and reason from any reply, not only
61
+ * from the refuser's one-shot frame. Few by construction (each is a retry round); attached
62
+ * whole and deduplicated by the receiver.
63
+ */
64
+ refusals?: Uint8Array[];
65
+ /**
66
+ * The signed genesis proposal, included when the peer's position shows them holding NOTHING —
67
+ * a joiner is simply very far behind (spec §4), and the anchor everything derives from is the
68
+ * one record that is not an entry. Harmless when they already hold it: the bootstrap is
69
+ * idempotent, like everything else in the exchange.
70
+ */
71
+ genesis?: Uint8Array;
72
+ /**
73
+ * A PER-DOCUMENT refusal (P3 review F4): in a batched frame, one document's stranger or
74
+ * removed ruling must not be silenced by another document's ordinary reply — refused-by-name
75
+ * is per document, so the refusal rides the block. May coexist with entries: a removed
76
+ * holder's block carries their own removal's closure AND the terminal ruling (R32 + R17).
77
+ */
78
+ refusal?: {
79
+ reason: string;
80
+ terminal: boolean;
81
+ };
82
+ }
83
+ export interface DocumentReconcileFrame {
84
+ type: "document_reconcile";
85
+ exchange_version: number;
86
+ documents: DocumentReconcileBlock[];
87
+ /**
88
+ * R11: a refusal rides the SAME frame — a version mismatch (or an entitlement refusal) is
89
+ * answered by name with a sentence, never by silence, and inventing a second frame kind for
90
+ * "no" would be the second carrier this design exists to avoid. A refusal reply carries no
91
+ * documents.
92
+ */
93
+ refusal?: {
94
+ reason: string;
95
+ terminal: boolean;
96
+ };
97
+ }
98
+ export declare function encodeDocumentReconcile(frame: DocumentReconcileFrame): Uint8Array;
99
+ export declare function decodeDocumentReconcile(input: Uint8Array): DocumentReconcileFrame;
100
+ //# sourceMappingURL=document-reconcile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-reconcile.d.ts","sourceRoot":"","sources":["../src/document-reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,mGAAmG;AACnG,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD,kGAAkG;AAClG,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,GAAG,EAAE,MAAM,CAAC;IACZ,6EAA6E;IAC7E,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,0FAA0F;IAC1F,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8DAA8D;IAC9D,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,8DAA8D;IAC9D,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