@cello-protocol/protocol-types 0.0.54 → 0.0.56
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/dist/document-amendment.d.ts +27 -22
- package/dist/document-amendment.d.ts.map +1 -1
- package/dist/document-amendment.js +63 -181
- package/dist/document-amendment.js.map +1 -1
- package/dist/document-derive.d.ts +96 -0
- package/dist/document-derive.d.ts.map +1 -0
- package/dist/document-derive.js +605 -0
- package/dist/document-derive.js.map +1 -0
- package/dist/document-envelope.d.ts +18 -8
- package/dist/document-envelope.d.ts.map +1 -1
- package/dist/document-envelope.js +35 -19
- package/dist/document-envelope.js.map +1 -1
- package/dist/document-governance.d.ts +1 -1
- package/dist/document-governance.d.ts.map +1 -1
- package/dist/document-governance.js +41 -6
- package/dist/document-governance.js.map +1 -1
- package/dist/document-proposal.d.ts +6 -0
- package/dist/document-proposal.d.ts.map +1 -1
- package/dist/document-proposal.js +21 -0
- package/dist/document-proposal.js.map +1 -1
- package/dist/document-reconcile.d.ts +100 -0
- package/dist/document-reconcile.d.ts.map +1 -0
- package/dist/document-reconcile.js +197 -0
- package/dist/document-reconcile.js.map +1 -0
- package/dist/index.d.ts +10 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +18 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/package.json +2 -2
- package/dist/document-ack.d.ts +0 -111
- package/dist/document-ack.d.ts.map +0 -1
- package/dist/document-ack.js +0 -228
- package/dist/document-ack.js.map +0 -1
- package/dist/document-control.d.ts +0 -74
- package/dist/document-control.d.ts.map +0 -1
- package/dist/document-control.js +0 -174
- package/dist/document-control.js.map +0 -1
- package/dist/document-join-answer.d.ts +0 -34
- package/dist/document-join-answer.d.ts.map +0 -1
- package/dist/document-join-answer.js +0 -100
- package/dist/document-join-answer.js.map +0 -1
- package/dist/document-join.d.ts +0 -83
- package/dist/document-join.d.ts.map +0 -1
- package/dist/document-join.js +0 -225
- package/dist/document-join.js.map +0 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Signed, chained to its predecessor, epoch-incrementing, and carrying `state_hash` — the
|
|
15
15
|
* canonical-hash-at-boundary slot — as DEFINED-ABSENT (`null`) while the tier is `authenticated`.
|
|
16
16
|
* Tier 2 fills the slot; it does not migrate the frame. Dropping the slot "because Tier 1 doesn't
|
|
17
|
-
* use it" is the exact seam violation M14 forbade
|
|
17
|
+
* use it" is the exact seam violation M14 forbade.
|
|
18
18
|
*
|
|
19
19
|
* ── WHO MUST SIGN IS INJECTED ─────────────────────────────────────────────────────────────────
|
|
20
20
|
*
|
|
@@ -25,13 +25,23 @@
|
|
|
25
25
|
* promotion.
|
|
26
26
|
*/
|
|
27
27
|
import { type MultisigCollection } from "./document-multisig.js";
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Domain tag in slot 0 of the to-be-signed array. Sibling of the other CELLO-DOCUMENT-* tags.
|
|
30
|
+
* v2 (SYNC-P1): the preimage gained the causal fields — author, sequence, parents. A v1 frame is
|
|
31
|
+
* refused by the mandatory-field discipline below; no compatibility is owed (all holders upgrade
|
|
32
|
+
* together).
|
|
33
|
+
*/
|
|
34
|
+
export declare const DOCUMENT_AMENDMENT_DOMAIN = "CELLO-DOCUMENT-AMENDMENT-v3";
|
|
35
|
+
/**
|
|
36
|
+
* Ceiling on an entry's parent list. The honest frontier is bounded by the holder cap (D5: 20);
|
|
37
|
+
* the ceiling exists so a hostile daemon cannot make every ancestry walk unbounded.
|
|
38
|
+
*/
|
|
39
|
+
export declare const MAX_ENTRY_PARENTS = 64;
|
|
30
40
|
/** The `subject_kind` an amendment's multisig collection must carry. */
|
|
31
41
|
export declare const AMENDMENT_SUBJECT_KIND = "document_amendment";
|
|
32
42
|
/** D5 (ruled 2026-08-11): documents inherit the group-room cap. Enforced at amendment validation. */
|
|
33
43
|
export declare const MAX_DOCUMENT_HOLDERS = 20;
|
|
34
|
-
export declare const AMENDMENT_KINDS: readonly ["add_holder", "remove_holder", "promote_admin", "remove_admin", "change_property"];
|
|
44
|
+
export declare const AMENDMENT_KINDS: readonly ["add_holder", "remove_holder", "promote_admin", "remove_admin", "change_property", "consent", "refuse_join", "close", "kill"];
|
|
35
45
|
export type AmendmentKind = (typeof AMENDMENT_KINDS)[number];
|
|
36
46
|
/**
|
|
37
47
|
* Properties an amendment may change. Deliberately NARROW to start: the seam properties are owned
|
|
@@ -43,10 +53,6 @@ export type AmendmentKind = (typeof AMENDMENT_KINDS)[number];
|
|
|
43
53
|
export declare const AMENDABLE_PROPERTIES: Set<string>;
|
|
44
54
|
export interface DocumentAmendmentBody {
|
|
45
55
|
document_id: string;
|
|
46
|
-
/** The epoch this amendment MINTS: previous epoch + 1. Genesis is epoch 0 and is not an amendment. */
|
|
47
|
-
epoch_id: number;
|
|
48
|
-
/** Hex hash of the predecessor amendment's TBS; null for the first (anchored to genesis via document_id). */
|
|
49
|
-
prev_amendment_hash: string | null;
|
|
50
56
|
kind: AmendmentKind;
|
|
51
57
|
/** The holder the amendment is about (pubkey hex). Null exactly for `change_property`. */
|
|
52
58
|
subject_agent_id: string | null;
|
|
@@ -61,6 +67,17 @@ export interface DocumentAmendmentBody {
|
|
|
61
67
|
*/
|
|
62
68
|
state_hash: Uint8Array | null;
|
|
63
69
|
authored_at_ms: number;
|
|
70
|
+
/**
|
|
71
|
+
* SYNC-P1 — the causal fields. The accountable initiator (MUST appear in the collection's
|
|
72
|
+
* required set), their own-chain counter, and the frontier heads applied when authoring. For
|
|
73
|
+
* `author_seq > 1` the author's previous entry MUST be among the ancestors the parents reach —
|
|
74
|
+
* a direct parent is the common case, not the requirement. Signed: a forwarder cannot
|
|
75
|
+
* re-attribute, re-sequence, or re-parent without every signature failing (SYNC-R2).
|
|
76
|
+
*/
|
|
77
|
+
author_agent_id: string;
|
|
78
|
+
author_seq: number;
|
|
79
|
+
/** Entry hashes (64-hex), CANONICAL: strictly ascending, no duplicates. Empty anchors to genesis. */
|
|
80
|
+
parents: readonly string[];
|
|
64
81
|
}
|
|
65
82
|
export interface DocumentAmendmentEnvelope {
|
|
66
83
|
body: DocumentAmendmentBody;
|
|
@@ -91,6 +108,8 @@ export interface ArrangementGenesis {
|
|
|
91
108
|
export interface Arrangement {
|
|
92
109
|
epoch: number;
|
|
93
110
|
participants: ReadonlySet<string>;
|
|
111
|
+
/** SYNC-P2: admitted-not-yet-answered (R22). Optional while the interim join surface lives. */
|
|
112
|
+
invited?: ReadonlySet<string>;
|
|
94
113
|
admins: ReadonlySet<string>;
|
|
95
114
|
/** The DERIVED view — genesis properties + applied change_property amendments. */
|
|
96
115
|
properties: Record<string, string | number | boolean | undefined>;
|
|
@@ -111,18 +130,4 @@ export type SignerPolicy = (kind: AmendmentKind, subjectAgentId: string | null,
|
|
|
111
130
|
ok: false;
|
|
112
131
|
reason: string;
|
|
113
132
|
};
|
|
114
|
-
export type DeriveResult = {
|
|
115
|
-
ok: true;
|
|
116
|
-
arrangement: Arrangement;
|
|
117
|
-
} | {
|
|
118
|
-
ok: false;
|
|
119
|
-
reason: string;
|
|
120
|
-
epoch: number;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Replay: genesis + the ordered amendment chain → the current arrangement, or a loud refusal
|
|
124
|
-
* naming the epoch and the cause. NEVER a partial arrangement — a holder that cannot derive the
|
|
125
|
-
* whole chain has no arrangement, which is what makes "invalid everywhere" computable.
|
|
126
|
-
*/
|
|
127
|
-
export declare function deriveArrangement(genesis: ArrangementGenesis, amendments: readonly DocumentAmendmentEnvelope[], policy: SignerPolicy, verify: (agentId: string, tbs: Uint8Array, signature: Uint8Array) => boolean): DeriveResult;
|
|
128
133
|
//# sourceMappingURL=document-amendment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-amendment.d.ts","sourceRoot":"","sources":["../src/document-amendment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,EACzE,kBAAkB,EAAE,SAAS,MAAM,EAAE,KAClC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Signed, chained to its predecessor, epoch-incrementing, and carrying `state_hash` — the
|
|
15
15
|
* canonical-hash-at-boundary slot — as DEFINED-ABSENT (`null`) while the tier is `authenticated`.
|
|
16
16
|
* Tier 2 fills the slot; it does not migrate the frame. Dropping the slot "because Tier 1 doesn't
|
|
17
|
-
* use it" is the exact seam violation M14 forbade
|
|
17
|
+
* use it" is the exact seam violation M14 forbade.
|
|
18
18
|
*
|
|
19
19
|
* ── WHO MUST SIGN IS INJECTED ─────────────────────────────────────────────────────────────────
|
|
20
20
|
*
|
|
@@ -26,9 +26,19 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { createHash } from "node:crypto";
|
|
28
28
|
import { encodeCbor, decodeCbor } from "./cbor.js";
|
|
29
|
-
import {
|
|
30
|
-
/**
|
|
31
|
-
|
|
29
|
+
import { encodeMultisigCollection, decodeMultisigCollection, } from "./document-multisig.js";
|
|
30
|
+
/**
|
|
31
|
+
* Domain tag in slot 0 of the to-be-signed array. Sibling of the other CELLO-DOCUMENT-* tags.
|
|
32
|
+
* v2 (SYNC-P1): the preimage gained the causal fields — author, sequence, parents. A v1 frame is
|
|
33
|
+
* refused by the mandatory-field discipline below; no compatibility is owed (all holders upgrade
|
|
34
|
+
* together).
|
|
35
|
+
*/
|
|
36
|
+
export const DOCUMENT_AMENDMENT_DOMAIN = "CELLO-DOCUMENT-AMENDMENT-v3";
|
|
37
|
+
/**
|
|
38
|
+
* Ceiling on an entry's parent list. The honest frontier is bounded by the holder cap (D5: 20);
|
|
39
|
+
* the ceiling exists so a hostile daemon cannot make every ancestry walk unbounded.
|
|
40
|
+
*/
|
|
41
|
+
export const MAX_ENTRY_PARENTS = 64;
|
|
32
42
|
/** The `subject_kind` an amendment's multisig collection must carry. */
|
|
33
43
|
export const AMENDMENT_SUBJECT_KIND = "document_amendment";
|
|
34
44
|
/** D5 (ruled 2026-08-11): documents inherit the group-room cap. Enforced at amendment validation. */
|
|
@@ -39,6 +49,17 @@ export const AMENDMENT_KINDS = [
|
|
|
39
49
|
"promote_admin",
|
|
40
50
|
"remove_admin",
|
|
41
51
|
"change_property",
|
|
52
|
+
// SYNC-P2 (R21/R24): the subject's own acts. A `consent` answers an admission and names what
|
|
53
|
+
// it agrees to in the signed property slots ({ key: "consents_to", value: "<tier>/<version>" });
|
|
54
|
+
// a `refuse_join` ends the invitation. Both are authored, subject-ed, and signed by the same
|
|
55
|
+
// party — nobody consents for you.
|
|
56
|
+
"consent",
|
|
57
|
+
"refuse_join",
|
|
58
|
+
// SYNC-P4 (R26-R28): endings are governance entries like everything else. A `close` is the
|
|
59
|
+
// closer's own signed agreement to end; the document is CLOSED when every current participant
|
|
60
|
+
// holds one (derived, never tracked). A `kill` is any single admin's immediate one-sided end.
|
|
61
|
+
"close",
|
|
62
|
+
"kill",
|
|
42
63
|
];
|
|
43
64
|
/**
|
|
44
65
|
* Properties an amendment may change. Deliberately NARROW to start: the seam properties are owned
|
|
@@ -57,8 +78,6 @@ export function buildDocumentAmendmentTbs(body, opts = {}) {
|
|
|
57
78
|
const preimage = encodeCbor([
|
|
58
79
|
DOCUMENT_AMENDMENT_DOMAIN,
|
|
59
80
|
body.document_id,
|
|
60
|
-
body.epoch_id,
|
|
61
|
-
body.prev_amendment_hash,
|
|
62
81
|
body.kind,
|
|
63
82
|
body.subject_agent_id,
|
|
64
83
|
body.property_change?.key ?? null,
|
|
@@ -68,6 +87,9 @@ export function buildDocumentAmendmentTbs(body, opts = {}) {
|
|
|
68
87
|
typeof body.authored_at_ms === "number" && body.authored_at_ms > 0xffffffff
|
|
69
88
|
? BigInt(body.authored_at_ms)
|
|
70
89
|
: body.authored_at_ms,
|
|
90
|
+
body.author_agent_id,
|
|
91
|
+
body.author_seq,
|
|
92
|
+
[...body.parents],
|
|
71
93
|
]);
|
|
72
94
|
if (opts.preHash === false)
|
|
73
95
|
return preimage;
|
|
@@ -85,13 +107,14 @@ export function encodeDocumentAmendment(env) {
|
|
|
85
107
|
type: "document_amendment",
|
|
86
108
|
body: {
|
|
87
109
|
document_id: env.body.document_id,
|
|
88
|
-
epoch_id: env.body.epoch_id,
|
|
89
|
-
prev_amendment_hash: env.body.prev_amendment_hash,
|
|
90
110
|
kind: env.body.kind,
|
|
91
111
|
subject_agent_id: env.body.subject_agent_id,
|
|
92
112
|
property_change: env.body.property_change,
|
|
93
113
|
state_hash: env.body.state_hash,
|
|
94
114
|
authored_at_ms: env.body.authored_at_ms,
|
|
115
|
+
author_agent_id: env.body.author_agent_id,
|
|
116
|
+
author_seq: env.body.author_seq,
|
|
117
|
+
parents: [...env.body.parents],
|
|
95
118
|
},
|
|
96
119
|
collection: encodeMultisigCollection(env.collection),
|
|
97
120
|
});
|
|
@@ -124,20 +147,11 @@ export function decodeDocumentAmendment(input) {
|
|
|
124
147
|
throw new Error("document_amendment_field_type: body must be a CBOR map");
|
|
125
148
|
}
|
|
126
149
|
const b = rawBody;
|
|
127
|
-
const epochId = present(b, "epoch_id");
|
|
128
|
-
if (typeof epochId !== "number" || !Number.isInteger(epochId) || epochId < 1) {
|
|
129
|
-
throw new Error(`document_amendment_epoch: must be a positive integer (genesis is epoch 0 and is not an ` +
|
|
130
|
-
`amendment), got ${String(epochId)}`);
|
|
131
|
-
}
|
|
132
150
|
const kind = str(b, "kind");
|
|
133
151
|
if (!AMENDMENT_KINDS.includes(kind)) {
|
|
134
152
|
throw new Error(`document_amendment_kind: "${kind}" is not an amendment kind this build knows ` +
|
|
135
153
|
`(${AMENDMENT_KINDS.join(", ")})`);
|
|
136
154
|
}
|
|
137
|
-
const prevHash = present(b, "prev_amendment_hash");
|
|
138
|
-
if (prevHash !== null && (typeof prevHash !== "string" || !/^[0-9a-f]{64}$/.test(prevHash))) {
|
|
139
|
-
throw new Error("document_amendment_field_type: prev_amendment_hash must be 64-hex or explicit null");
|
|
140
|
-
}
|
|
141
155
|
const subject = present(b, "subject_agent_id");
|
|
142
156
|
if (subject !== null && (typeof subject !== "string" || subject.length === 0)) {
|
|
143
157
|
throw new Error("document_amendment_field_type: subject_agent_id must be a non-empty string or explicit null");
|
|
@@ -164,6 +178,35 @@ export function decodeDocumentAmendment(input) {
|
|
|
164
178
|
if (typeof authoredAt !== "number" || !Number.isInteger(authoredAt)) {
|
|
165
179
|
throw new Error("document_amendment_field_type: authored_at_ms must be an integer");
|
|
166
180
|
}
|
|
181
|
+
const author = present(b, "author_agent_id");
|
|
182
|
+
if (typeof author !== "string" || !/^[0-9a-f]{64}$/.test(author)) {
|
|
183
|
+
throw new Error("document_amendment_field_type: author_agent_id must be a 64-hex agent pubkey");
|
|
184
|
+
}
|
|
185
|
+
const authorSeq = present(b, "author_seq");
|
|
186
|
+
if (typeof authorSeq !== "number" || !Number.isInteger(authorSeq) || authorSeq < 1) {
|
|
187
|
+
throw new Error(`document_amendment_author_seq: must be a positive integer (an author's own chain starts ` +
|
|
188
|
+
`at 1), got ${String(authorSeq)}`);
|
|
189
|
+
}
|
|
190
|
+
const rawParents = present(b, "parents");
|
|
191
|
+
if (!Array.isArray(rawParents)) {
|
|
192
|
+
throw new Error("document_amendment_field_type: parents must be an array of entry hashes");
|
|
193
|
+
}
|
|
194
|
+
if (rawParents.length > MAX_ENTRY_PARENTS) {
|
|
195
|
+
throw new Error(`document_amendment_parents_cap: ${rawParents.length} parents exceeds the ceiling of ` +
|
|
196
|
+
`${MAX_ENTRY_PARENTS} — an honest frontier is bounded by the holder cap`);
|
|
197
|
+
}
|
|
198
|
+
for (const p of rawParents) {
|
|
199
|
+
if (typeof p !== "string" || !/^[0-9a-f]{64}$/.test(p)) {
|
|
200
|
+
throw new Error("document_amendment_field_type: parents must be 64-hex entry hashes");
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const parents = rawParents;
|
|
204
|
+
for (let i = 1; i < parents.length; i++) {
|
|
205
|
+
if (parents[i] <= parents[i - 1]) {
|
|
206
|
+
throw new Error("document_amendment_parents_canonical: parents must be strictly ascending with no " +
|
|
207
|
+
"duplicates — one entry, one identity");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
167
210
|
const rawCollection = present(map, "collection");
|
|
168
211
|
if (!(rawCollection instanceof Uint8Array)) {
|
|
169
212
|
throw new Error("document_amendment_field_type: collection must be a CBOR byte string");
|
|
@@ -171,177 +214,16 @@ export function decodeDocumentAmendment(input) {
|
|
|
171
214
|
return {
|
|
172
215
|
body: {
|
|
173
216
|
document_id: str(b, "document_id"),
|
|
174
|
-
epoch_id: epochId,
|
|
175
|
-
prev_amendment_hash: prevHash,
|
|
176
217
|
kind: kind,
|
|
177
218
|
subject_agent_id: subject,
|
|
178
219
|
property_change: propertyChange,
|
|
179
220
|
state_hash: stateHash === null ? null : new Uint8Array(stateHash),
|
|
180
221
|
authored_at_ms: authoredAt,
|
|
222
|
+
author_agent_id: author,
|
|
223
|
+
author_seq: authorSeq,
|
|
224
|
+
parents,
|
|
181
225
|
},
|
|
182
226
|
collection: decodeMultisigCollection(new Uint8Array(rawCollection)),
|
|
183
227
|
};
|
|
184
228
|
}
|
|
185
|
-
function refuse(reason, epoch) {
|
|
186
|
-
return { ok: false, reason, epoch };
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Replay: genesis + the ordered amendment chain → the current arrangement, or a loud refusal
|
|
190
|
-
* naming the epoch and the cause. NEVER a partial arrangement — a holder that cannot derive the
|
|
191
|
-
* whole chain has no arrangement, which is what makes "invalid everywhere" computable.
|
|
192
|
-
*/
|
|
193
|
-
export function deriveArrangement(genesis, amendments, policy, verify) {
|
|
194
|
-
const participants = new Set([genesis.proposerAgentId, genesis.peerAgentId]);
|
|
195
|
-
const admins = new Set(genesis.adminSet);
|
|
196
|
-
if (admins.size === 0) {
|
|
197
|
-
return refuse("arrangement_admin_set_empty: a document with no admins can never be amended — the " +
|
|
198
|
-
"creation flow must name at least one", 0);
|
|
199
|
-
}
|
|
200
|
-
for (const admin of admins) {
|
|
201
|
-
if (!participants.has(admin)) {
|
|
202
|
-
return refuse(`arrangement_admin_not_participant: ${admin} holds admin power but is not a holder — ` +
|
|
203
|
-
`admins are always holders`, 0);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const properties = { ...genesis.properties };
|
|
207
|
-
let epoch = 0;
|
|
208
|
-
let lastHash = null;
|
|
209
|
-
for (const env of amendments) {
|
|
210
|
-
const body = env.body;
|
|
211
|
-
const at = body.epoch_id;
|
|
212
|
-
if (body.document_id !== genesis.documentId) {
|
|
213
|
-
return refuse(`amendment_wrong_document: names ${body.document_id}, replaying ${genesis.documentId}`, at);
|
|
214
|
-
}
|
|
215
|
-
if (body.epoch_id !== epoch + 1) {
|
|
216
|
-
return refuse(`amendment_chain_gap: expected epoch ${epoch + 1} next, got ${body.epoch_id} — a missing ` +
|
|
217
|
-
`amendment is a gap to resolve, never to skip`, at);
|
|
218
|
-
}
|
|
219
|
-
if (body.prev_amendment_hash !== lastHash) {
|
|
220
|
-
return refuse(`amendment_chain_broken: epoch ${at} chains to ${body.prev_amendment_hash ?? "genesis"} ` +
|
|
221
|
-
`but the replayed predecessor is ${lastHash ?? "genesis"} — a fork, not a gap`, at);
|
|
222
|
-
}
|
|
223
|
-
// WHITELIST, not an equality on the benign value: only a tier that DEFINES the slot may fill
|
|
224
|
-
// it. An equality check on "authenticated" silently accepted a Tier 2 field whenever the
|
|
225
|
-
// genesis lacked the tier property — a mis-built genesis running degraded instead of refusing.
|
|
226
|
-
if (body.state_hash !== null && properties["assurance_tier"] !== "attested") {
|
|
227
|
-
return refuse(`amendment_state_hash_tier: epoch ${at} carries a canonical state hash but the document's ` +
|
|
228
|
-
`tier is ${JSON.stringify(properties["assurance_tier"] ?? null)} — only "attested" ` +
|
|
229
|
-
`(Tier 2) defines that slot`, at);
|
|
230
|
-
}
|
|
231
|
-
// Subject semantics against the CURRENT state — a no-op amendment is refused, not absorbed:
|
|
232
|
-
// silently absorbing "add someone who already holds" would let two amendments with one
|
|
233
|
-
// meaning carry different signatures.
|
|
234
|
-
const subject = body.subject_agent_id;
|
|
235
|
-
switch (body.kind) {
|
|
236
|
-
case "add_holder": {
|
|
237
|
-
if (subject === null)
|
|
238
|
-
return refuse(`amendment_subject_required: add_holder names nobody`, at);
|
|
239
|
-
if (participants.has(subject)) {
|
|
240
|
-
return refuse(`amendment_subject_already_holder: ${subject} already holds this document`, at);
|
|
241
|
-
}
|
|
242
|
-
if (participants.size + 1 > MAX_DOCUMENT_HOLDERS) {
|
|
243
|
-
return refuse(`amendment_holder_cap: admitting ${subject} would make ${participants.size + 1} holders ` +
|
|
244
|
-
`and the cap is ${MAX_DOCUMENT_HOLDERS} (D5)`, at);
|
|
245
|
-
}
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case "remove_holder": {
|
|
249
|
-
if (subject === null)
|
|
250
|
-
return refuse(`amendment_subject_required: remove_holder names nobody`, at);
|
|
251
|
-
if (!participants.has(subject)) {
|
|
252
|
-
return refuse(`amendment_subject_not_holder: ${subject} does not hold this document`, at);
|
|
253
|
-
}
|
|
254
|
-
if (admins.has(subject) && admins.size === 1) {
|
|
255
|
-
return refuse(`amendment_last_admin: removing ${subject} would leave the document with no admins — ` +
|
|
256
|
-
`it could never be amended again`, at);
|
|
257
|
-
}
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
case "promote_admin": {
|
|
261
|
-
if (subject === null)
|
|
262
|
-
return refuse(`amendment_subject_required: promote_admin names nobody`, at);
|
|
263
|
-
if (!participants.has(subject)) {
|
|
264
|
-
return refuse(`amendment_subject_not_holder: ${subject} does not hold this document`, at);
|
|
265
|
-
}
|
|
266
|
-
if (admins.has(subject)) {
|
|
267
|
-
return refuse(`amendment_subject_already_admin: ${subject} is already an admin`, at);
|
|
268
|
-
}
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
case "remove_admin": {
|
|
272
|
-
if (subject === null)
|
|
273
|
-
return refuse(`amendment_subject_required: remove_admin names nobody`, at);
|
|
274
|
-
if (!admins.has(subject)) {
|
|
275
|
-
return refuse(`amendment_subject_not_admin: ${subject} holds no admin power to remove`, at);
|
|
276
|
-
}
|
|
277
|
-
if (admins.size === 1) {
|
|
278
|
-
return refuse(`amendment_last_admin: demoting ${subject} would leave the document with no admins — ` +
|
|
279
|
-
`it could never be amended again`, at);
|
|
280
|
-
}
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
case "change_property": {
|
|
284
|
-
if (subject !== null) {
|
|
285
|
-
return refuse(`amendment_subject_forbidden: change_property is about the document, not a holder`, at);
|
|
286
|
-
}
|
|
287
|
-
if (body.property_change === null) {
|
|
288
|
-
return refuse(`amendment_property_missing: change_property carries no change`, at);
|
|
289
|
-
}
|
|
290
|
-
if (!AMENDABLE_PROPERTIES.has(body.property_change.key)) {
|
|
291
|
-
return refuse(`amendment_property_not_amendable: "${body.property_change.key}" is not amendable — ` +
|
|
292
|
-
`the amendable set is {${[...AMENDABLE_PROPERTIES].join(", ")}}; tier and schema ` +
|
|
293
|
-
`changes are Tier 2 epoch events, topology and profile are a new agreement`, at);
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
// The collection: bound to THIS amendment, its claimed required set ACCEPTABLE TO THE POLICY
|
|
299
|
-
// for the state BEFORE it, and complete. Order matters — a mismatch in what the collection claims is
|
|
300
|
-
// reported before whether it gathered enough names for the wrong claim.
|
|
301
|
-
const expectedHash = documentAmendmentHash(body);
|
|
302
|
-
if (env.collection.document_id !== body.document_id) {
|
|
303
|
-
return refuse(`amendment_collection_document_mismatch: collection names ${env.collection.document_id}`, at);
|
|
304
|
-
}
|
|
305
|
-
if (env.collection.subject_kind !== AMENDMENT_SUBJECT_KIND) {
|
|
306
|
-
return refuse(`amendment_collection_kind: collection signs "${env.collection.subject_kind}", not an amendment`, at);
|
|
307
|
-
}
|
|
308
|
-
if (Buffer.compare(env.collection.subject_hash, expectedHash) !== 0) {
|
|
309
|
-
return refuse(`amendment_collection_subject_mismatch: the collection signs a different amendment than ` +
|
|
310
|
-
`the one it rides with`, at);
|
|
311
|
-
}
|
|
312
|
-
const verdict = policy(body.kind, subject, { participants, admins }, env.collection.required_signers);
|
|
313
|
-
if (!verdict.ok) {
|
|
314
|
-
// The policy's reason IS the diagnosis — epoch context prepended, nothing substituted.
|
|
315
|
-
return refuse(`epoch ${at}: ${verdict.reason}`, at);
|
|
316
|
-
}
|
|
317
|
-
const status = collectionStatus(env.collection, verify);
|
|
318
|
-
if (!status.complete) {
|
|
319
|
-
return refuse(`amendment_collection_incomplete: epoch ${at} — missing [${status.missing.join(", ")}], ` +
|
|
320
|
-
`invalid [${status.invalidSigners.join(", ")}], unknown [${status.unknown.join(", ")}], ` +
|
|
321
|
-
`duplicate [${status.duplicates.join(", ")}]`, at);
|
|
322
|
-
}
|
|
323
|
-
// Apply.
|
|
324
|
-
switch (body.kind) {
|
|
325
|
-
case "add_holder":
|
|
326
|
-
participants.add(subject);
|
|
327
|
-
break;
|
|
328
|
-
case "remove_holder":
|
|
329
|
-
participants.delete(subject);
|
|
330
|
-
admins.delete(subject);
|
|
331
|
-
break;
|
|
332
|
-
case "promote_admin":
|
|
333
|
-
admins.add(subject);
|
|
334
|
-
break;
|
|
335
|
-
case "remove_admin":
|
|
336
|
-
admins.delete(subject);
|
|
337
|
-
break;
|
|
338
|
-
case "change_property":
|
|
339
|
-
properties[body.property_change.key] = body.property_change.value;
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
epoch = body.epoch_id;
|
|
343
|
-
lastHash = Buffer.from(expectedHash).toString("hex");
|
|
344
|
-
}
|
|
345
|
-
return { ok: true, arrangement: { epoch, participants, admins, properties, lastAmendmentHash: lastHash } };
|
|
346
|
-
}
|
|
347
229
|
//# sourceMappingURL=document-amendment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-amendment.js","sourceRoot":"","sources":["../src/document-amendment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,kGAAkG;AAClG,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D,qGAAqG;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,eAAe;IACf,eAAe;IACf,cAAc;IACd,iBAAiB;CACT,CAAC;AAGX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AA2B7D;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAA2B,EAC3B,OAA8B,EAAE;IAEhC,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC1B,yBAAyB;QACzB,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,mBAAmB;QACxB,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,gBAAgB;QACrB,IAAI,CAAC,eAAe,EAAE,GAAG,IAAI,IAAI;QACjC,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,IAAI;QACnC,IAAI,CAAC,UAAU;QACf,8FAA8F;QAC9F,OAAO,IAAI,CAAC,cAAc,KAAK,QAAQ,IAAI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YACJ,WAAW,EAAE,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC;YAClC,IAAI,EAAE,IAAqB;YAC3B,gBAAgB,EAAE,OAAO;YACzB,eAAe,EAAE,cAAc;YAC/B,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC;YACjE,cAAc,EAAE,UAAU;YAC1B,eAAe,EAAE,MAAM;YACvB,UAAU,EAAE,SAAS;YACrB,OAAO;SACR;QACD,UAAU,EAAE,wBAAwB,CAAC,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SYNC-P1 — the causal derivation. ONE derivation of a document's state for every holder: the
|
|
3
|
+
* fold over the entry DAG in a deterministic total order. Same entry set → same state, everywhere,
|
|
4
|
+
* always. This file replaces the linear epoch replay; the fold rules are M14B Build Journal
|
|
5
|
+
* Entries 48–49 (SYNC-G2's finding plus its admin-floor addendum).
|
|
6
|
+
*
|
|
7
|
+
* The total order is Kahn's topological sort refined by ascending entry hash — a pure function of
|
|
8
|
+
* the entry SET. The hash tie-break resolves only what is semantically arbitrary (which property
|
|
9
|
+
* value wins). It never resolves authority: causal concurrency is author-claimable (a modified
|
|
10
|
+
* daemon backdates its parents at will), so any rule where a concurrent act could beat a removal
|
|
11
|
+
* would make removal defeatable. Hence the fold rules:
|
|
12
|
+
*
|
|
13
|
+
* F1. A non-removal entry takes effect iff it validates against the folded state at its position
|
|
14
|
+
* AND it is not concurrent with an ancestor-valid removal of its author.
|
|
15
|
+
* F2. A removal is judged at its OWN ancestors (the state derived from its ancestor closure) and
|
|
16
|
+
* is exempt from F1's concurrency void — the exemption is what keeps mutual removals from
|
|
17
|
+
* being circular. At fold position it is void only by the admin floor: a removal that would
|
|
18
|
+
* leave zero admins does not take effect.
|
|
19
|
+
* F3. Content admissibility is R20's (ancestor-based) and is NOT this module's concern.
|
|
20
|
+
* F4. A void entry stays in the linearization — history, not refusal — and contributes nothing.
|
|
21
|
+
*/
|
|
22
|
+
import { type DocumentAmendmentEnvelope, type ArrangementGenesis, type SignerPolicy } from "./document-amendment.js";
|
|
23
|
+
export interface DocumentStateView {
|
|
24
|
+
participants: ReadonlySet<string>;
|
|
25
|
+
/** Admitted, not yet answered (R22) — a seat at the table, not a voice. Counts toward the cap. */
|
|
26
|
+
invited: ReadonlySet<string>;
|
|
27
|
+
admins: ReadonlySet<string>;
|
|
28
|
+
/** R27/R28 — DERIVED, never tracked: "closed" when every current participant has closed;
|
|
29
|
+
* "killed" on any admin's kill; null while live. */
|
|
30
|
+
ended: "closed" | "killed" | null;
|
|
31
|
+
/** Who has agreed to close — the surface's "waiting on" list is its complement. */
|
|
32
|
+
closedBy: ReadonlySet<string>;
|
|
33
|
+
properties: Record<string, string | number | boolean | undefined>;
|
|
34
|
+
/** The total order actually folded (applied AND void entries — F4 keeps voids in history). */
|
|
35
|
+
order: readonly string[];
|
|
36
|
+
/** Heads: included entries no other included entry names as a parent. Ascending. */
|
|
37
|
+
frontier: readonly string[];
|
|
38
|
+
/** Fold-void entries, each with the reason it contributed nothing. */
|
|
39
|
+
voids: readonly {
|
|
40
|
+
hash: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
}[];
|
|
43
|
+
/** Entries whose ancestry is not fully present — held out entirely, never guessed at (R14). */
|
|
44
|
+
excluded: readonly {
|
|
45
|
+
hash: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
}[];
|
|
48
|
+
/** Highest seq per author among included entries — the watermark seed. */
|
|
49
|
+
authorSeqs: ReadonlyMap<string, number>;
|
|
50
|
+
/** Interim carrier fields until P4 deletes the epoch spine (D7, gated on SYNC-G1). */
|
|
51
|
+
interimLastHash: string | null;
|
|
52
|
+
}
|
|
53
|
+
export type DeriveDocumentStateResult = {
|
|
54
|
+
ok: true;
|
|
55
|
+
state: DocumentStateView;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
reason: string;
|
|
59
|
+
};
|
|
60
|
+
type VerifyFn = (agentId: string, tbs: Uint8Array, signature: Uint8Array) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* SYNC-G1 — the derivation AT a named governance frontier: the fold restricted to the ancestor
|
|
63
|
+
* closure of `frontierHashes`. This is what content admissibility rules on (R20/R30): was the
|
|
64
|
+
* envelope's author a participant in the world its signed `governance_parents` name? Judged
|
|
65
|
+
* from the named ancestors alone — the same bounded backdating concession Entry 48 accepted
|
|
66
|
+
* for governance: a lying daemon admits exactly what an honest holder AT THAT POSITION could
|
|
67
|
+
* have authored, and the fold's removal dominance keeps it out of governance regardless.
|
|
68
|
+
*
|
|
69
|
+
* A frontier hash not present in `entries` is the caller's signal to reconcile first — this
|
|
70
|
+
* function reports it rather than guessing (`missing`).
|
|
71
|
+
*/
|
|
72
|
+
export declare function deriveDocumentStateAt(genesis: ArrangementGenesis, entries: readonly DocumentAmendmentEnvelope[], frontierHashes: readonly string[], policy: SignerPolicy, verify: VerifyFn): {
|
|
73
|
+
ok: true;
|
|
74
|
+
state: DocumentStateView;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
reason: string;
|
|
78
|
+
missing?: string[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The STATE-INDEPENDENT admission check — what an inbound path may refuse outright, because no
|
|
82
|
+
* future entry can ever make it good: the collection must bind to this entry, the claimed author
|
|
83
|
+
* must be in the required set, and every claimed signature must verify. Everything else — subject
|
|
84
|
+
* semantics, policy, concurrency — is the fold's ruling, and a fold-void entry is still HISTORY
|
|
85
|
+
* (F4): it must be stored and shared, never bounced at the door, or two holders end up holding
|
|
86
|
+
* different sets.
|
|
87
|
+
*/
|
|
88
|
+
export declare function checkEntryAdmissible(env: DocumentAmendmentEnvelope, verify: VerifyFn): {
|
|
89
|
+
ok: true;
|
|
90
|
+
} | {
|
|
91
|
+
ok: false;
|
|
92
|
+
reason: string;
|
|
93
|
+
};
|
|
94
|
+
export declare function deriveDocumentState(genesis: ArrangementGenesis, entries: readonly DocumentAmendmentEnvelope[], policy: SignerPolicy, verify: VerifyFn): DeriveDocumentStateResult;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=document-derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-derive.d.ts","sourceRoot":"","sources":["../src/document-derive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,kGAAkG;IAClG,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B;yDACqD;IACrD,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IAClC,mFAAmF;IACnF,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAClE,8FAA8F;IAC9F,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,oFAAoF;IACpF,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,KAAK,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,+FAA+F;IAC/F,QAAQ,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,0EAA0E;IAC1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