@ainize/core 0.1.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 +21 -0
- package/README.md +20 -0
- package/dist/ain-ledger.d.ts +191 -0
- package/dist/ain-ledger.d.ts.map +1 -0
- package/dist/ain-ledger.js +714 -0
- package/dist/ain-ledger.js.map +1 -0
- package/dist/browser.d.ts +15 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +16 -0
- package/dist/browser.js.map +1 -0
- package/dist/bytes.d.ts +3 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +14 -0
- package/dist/bytes.js.map +1 -0
- package/dist/canonical.d.ts +5 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +70 -0
- package/dist/canonical.js.map +1 -0
- package/dist/catalog.d.ts +181 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +496 -0
- package/dist/catalog.js.map +1 -0
- package/dist/config-schema.d.ts +222 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +302 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +128 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +330 -0
- package/dist/config.js.map +1 -0
- package/dist/events.d.ts +14 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +20 -0
- package/dist/events.js.map +1 -0
- package/dist/identity.d.ts +15 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +59 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +134 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +2 -0
- package/dist/ledger.js.map +1 -0
- package/dist/lineage.d.ts +63 -0
- package/dist/lineage.d.ts.map +1 -0
- package/dist/lineage.js +156 -0
- package/dist/lineage.js.map +1 -0
- package/dist/local-ledger.d.ts +74 -0
- package/dist/local-ledger.d.ts.map +1 -0
- package/dist/local-ledger.js +229 -0
- package/dist/local-ledger.js.map +1 -0
- package/dist/npz.d.ts +107 -0
- package/dist/npz.d.ts.map +1 -0
- package/dist/npz.js +502 -0
- package/dist/npz.js.map +1 -0
- package/dist/ops.d.ts +65 -0
- package/dist/ops.d.ts.map +1 -0
- package/dist/ops.js +9 -0
- package/dist/ops.js.map +1 -0
- package/dist/teach-auth.d.ts +19 -0
- package/dist/teach-auth.d.ts.map +1 -0
- package/dist/teach-auth.js +33 -0
- package/dist/teach-auth.js.map +1 -0
- package/dist/types.d.ts +1096 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +98 -0
- package/dist/types.js.map +1 -0
- package/dist/x402.d.ts +35 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +84 -0
- package/dist/x402.js.map +1 -0
- package/package.json +49 -0
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog derivation — turns ledger records into the marketplace view.
|
|
3
|
+
* Status machine (도 16): DRAFT → ANNOUNCED → VERIFYING → LISTED | REJECTED; LISTED → CHALLENGED → VERIFYING;
|
|
4
|
+
* LISTED → SUPERSEDED when a newer patch on the same benchmark schema overlaps its address set.
|
|
5
|
+
*/
|
|
6
|
+
import { effectiveRoyaltyShare, effectiveVerifierShare, MAX_CONTRIBUTORS, sameAddr } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* How far a record's self-reported `created_at` may run ahead of the `ts` its signature covers.
|
|
9
|
+
*
|
|
10
|
+
* Clocks differ, and a record written a few minutes "in the future" is a normal clock, not an attack. A date
|
|
11
|
+
* further ahead than this is refused rather than trusted, because several rules here read `created_at` as an
|
|
12
|
+
* ordering key and a date far enough ahead makes them unsatisfiable for ever.
|
|
13
|
+
*/
|
|
14
|
+
const CLOCK_SKEW_MS = 5 * 60_000;
|
|
15
|
+
/**
|
|
16
|
+
* Which of one verifier's attestations counts for an entry.
|
|
17
|
+
* - after a challenge: the newest attestation written after it (re-verification answers the challenge and replaces
|
|
18
|
+
* the pre-challenge result — otherwise a challenged patch could never return to LISTED, since every verifier has
|
|
19
|
+
* already attested it);
|
|
20
|
+
* - otherwise: the first one, upgraded to the first attestation that actually executed the benchmark
|
|
21
|
+
* (a real run beats an earlier hash-only check by the same node).
|
|
22
|
+
*/
|
|
23
|
+
export function effectiveAttestation(list, challengedAt = 0) {
|
|
24
|
+
if (challengedAt > 0) {
|
|
25
|
+
const after = list.filter((a) => a.created_at > challengedAt).sort((a, b) => b.created_at - a.created_at);
|
|
26
|
+
if (after.length)
|
|
27
|
+
return after[0];
|
|
28
|
+
}
|
|
29
|
+
// A recheck (item 339) is this verifier saying "I measured it again on purpose". A failing one WITHDRAWS the
|
|
30
|
+
// earlier pass — that is the whole point of offering it instead of a challenge — so it wins over the first record.
|
|
31
|
+
const withdrawn = list.filter((a) => a.recheck && !a.passed).sort((a, b) => b.created_at - a.created_at)[0];
|
|
32
|
+
if (withdrawn)
|
|
33
|
+
return withdrawn;
|
|
34
|
+
const first = list[0];
|
|
35
|
+
if (first.verified_on === 'hash-only')
|
|
36
|
+
return list.find((a) => a.verified_on !== 'hash-only') ?? first;
|
|
37
|
+
return first;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How a verification count is written for a human: the numerator never exceeds the quorum (`3/2` is arithmetic no
|
|
41
|
+
* reader can interpret), and any attestations beyond it are reported as a separate, honest count.
|
|
42
|
+
*/
|
|
43
|
+
export function verificationCount(e) {
|
|
44
|
+
const shown = Math.min(e.passed, e.quorum);
|
|
45
|
+
return { shown, fraction: `${shown}/${e.quorum}`, extra: e.passed - shown };
|
|
46
|
+
}
|
|
47
|
+
export function deriveCatalog(anchors, attestations, settlements, challenges, supersedes, quorum, localDrafts = [],
|
|
48
|
+
/** Dev/single-node setting (`verifier.allowSelfAttest`): when true, an author's attestation of its own anchor counts. Default false — the shipped behaviour. */
|
|
49
|
+
allowSelfAttest = false) {
|
|
50
|
+
const byId = new Map();
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
for (const rec of anchors) {
|
|
53
|
+
if (seen.has(rec.body.id))
|
|
54
|
+
continue; // first anchor wins (immutable)
|
|
55
|
+
seen.add(rec.body.id);
|
|
56
|
+
byId.set(rec.body.id, {
|
|
57
|
+
anchor: rec.body, status: 'ANNOUNCED', attestations: [], passed: 0, integrity_checks: 0, self_checks: 0, quorum, quorum_ok: false, sellable: false,
|
|
58
|
+
challenge_log: [], verifiers: [], executors: [], executors_unknown: 0, no_baseline: 0, stale_attestations: 0,
|
|
59
|
+
settlements: [], downloads: 0, buyers: 0, revenue: '0', revenue_net: '0', revenue_shared: '0', self_purchases: 0,
|
|
60
|
+
challenges: [], superseded_by: [], supersedes: [], children: [],
|
|
61
|
+
record_hash: rec.hash,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const d of localDrafts) {
|
|
65
|
+
if (!byId.has(d.id))
|
|
66
|
+
byId.set(d.id, {
|
|
67
|
+
anchor: d, status: 'DRAFT', attestations: [], passed: 0, integrity_checks: 0, self_checks: 0, quorum, quorum_ok: false, sellable: false,
|
|
68
|
+
challenge_log: [], verifiers: [], executors: [], executors_unknown: 0, no_baseline: 0, stale_attestations: 0,
|
|
69
|
+
settlements: [], downloads: 0, buyers: 0, revenue: '0', revenue_net: '0', revenue_shared: '0', self_purchases: 0,
|
|
70
|
+
challenges: [], superseded_by: [], supersedes: [], children: [], record_hash: '',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Every attestation is kept per verifier here; which one of a verifier's attestations counts is decided below,
|
|
74
|
+
// once the challenges are known (a re-verification written after a challenge replaces the pre-challenge one).
|
|
75
|
+
const byVerifier = new Map();
|
|
76
|
+
for (const rec of attestations) {
|
|
77
|
+
const e = byId.get(rec.body.patch_id);
|
|
78
|
+
if (!e)
|
|
79
|
+
continue;
|
|
80
|
+
// The chain rule for an attestation is `auth.addr === $verifier`; the gossip path had no equivalent, so a
|
|
81
|
+
// record claiming to be somebody else's verdict was taken at its word off-chain. `rec.author` is signed.
|
|
82
|
+
if (!sameAddr(rec.author, rec.body.verifier))
|
|
83
|
+
continue;
|
|
84
|
+
const per = byVerifier.get(rec.body.patch_id) ?? new Map();
|
|
85
|
+
const list = per.get(rec.body.verifier) ?? [];
|
|
86
|
+
list.push(rec.body);
|
|
87
|
+
per.set(rec.body.verifier, list);
|
|
88
|
+
byVerifier.set(rec.body.patch_id, per);
|
|
89
|
+
}
|
|
90
|
+
for (const rec of settlements) {
|
|
91
|
+
const e = byId.get(rec.body.patch_id);
|
|
92
|
+
if (!e)
|
|
93
|
+
continue;
|
|
94
|
+
/**
|
|
95
|
+
* A sale is written by one of the two parties to it — the chain rule is "buyer or seller" and this is that rule
|
|
96
|
+
* off-chain. Without it a third node could invent sales of anybody's knowledge, and `downloads`, `buyers` and
|
|
97
|
+
* `revenue` — the numbers a stranger reads to decide what is worth buying — were whatever the loudest peer said.
|
|
98
|
+
*
|
|
99
|
+
* What this does NOT close: a seller who also controls the buyer address. `self_purchases` already drops the
|
|
100
|
+
* case where they are literally the same address, but a second address costs nothing, so the sales figures
|
|
101
|
+
* remain self-assertable by a determined seller. Closing that needs the transfer behind `tx_hash` checked
|
|
102
|
+
* against the chain, which this function cannot do — it is pure by design, and every node derives its catalogue
|
|
103
|
+
* from it on every read. The check belongs on ingest, where the ledger is in hand; until it exists, treat these
|
|
104
|
+
* counters as "what the parties claim", which is what the field docs now say.
|
|
105
|
+
*/
|
|
106
|
+
if (!sameAddr(rec.author, rec.body.buyer) && !sameAddr(rec.author, rec.body.seller))
|
|
107
|
+
continue;
|
|
108
|
+
e.settlements.push(rec.body);
|
|
109
|
+
}
|
|
110
|
+
for (const rec of challenges) {
|
|
111
|
+
const e = byId.get(rec.body.patch_id);
|
|
112
|
+
if (!e)
|
|
113
|
+
continue;
|
|
114
|
+
// A challenge is signed by its challenger, or it is not a challenge. `body.challenger` used to be believed on
|
|
115
|
+
// its own, so one hostile peer could file unlimited challenges under invented addresses — `Market.challenge`'s
|
|
116
|
+
// "one open challenge per address" and its cooldown are both keyed on this field — and hold any listing off
|
|
117
|
+
// sale for ever. `rec.author` is what the signature covers.
|
|
118
|
+
if (!sameAddr(rec.author, rec.body.challenger))
|
|
119
|
+
continue;
|
|
120
|
+
// A challenge dated in the future is unanswerable by construction: `current` below keeps only attestations
|
|
121
|
+
// written AFTER the open challenge, so a date years ahead means no attestation can ever answer it while every
|
|
122
|
+
// verifier re-runs the benchmark for it on every round. Records may not be dated after they were written.
|
|
123
|
+
if (rec.body.created_at > rec.ts + CLOCK_SKEW_MS)
|
|
124
|
+
continue;
|
|
125
|
+
e.challenges.push(rec.body);
|
|
126
|
+
}
|
|
127
|
+
for (const rec of supersedes) {
|
|
128
|
+
const oldE = byId.get(rec.body.old_patch_id);
|
|
129
|
+
const newE = byId.get(rec.body.new_patch_id);
|
|
130
|
+
// A supersede is a publisher retiring their OWN earlier version (items 151, 363). `supersedable()` enforces
|
|
131
|
+
// that where this node WRITES one; nothing enforced it where every node READS one, so a stranger could sign a
|
|
132
|
+
// supersede naming a competitor's LISTED anchor and every peer's catalogue marked it "newer version
|
|
133
|
+
// available", dropped it down the ranking and told its buyers. The author of the record must be the author of
|
|
134
|
+
// BOTH anchors — retiring an anchor you do not own is not yours to do, and crediting an anchor you do not own
|
|
135
|
+
// as the replacement is not either.
|
|
136
|
+
if (oldE && !sameAddr(rec.author, oldE.anchor.author))
|
|
137
|
+
continue;
|
|
138
|
+
if (newE && !sameAddr(rec.author, newE.anchor.author))
|
|
139
|
+
continue;
|
|
140
|
+
// A supersede naming a `new_patch_id` this node has never seen cannot be shown to anyone as "the newer
|
|
141
|
+
// version", and it is the shape a fabricated one takes: the old id is real, the new one is not.
|
|
142
|
+
if (!newE)
|
|
143
|
+
continue;
|
|
144
|
+
if (oldE)
|
|
145
|
+
oldE.superseded_by.push(rec.body.new_patch_id);
|
|
146
|
+
newE.supersedes.push(rec.body.old_patch_id);
|
|
147
|
+
}
|
|
148
|
+
for (const e of byId.values()) {
|
|
149
|
+
for (const p of e.anchor.parents)
|
|
150
|
+
byId.get(p)?.children.push(e.anchor.id);
|
|
151
|
+
const latestChallenge = e.challenges.sort((a, b) => b.created_at - a.created_at)[0];
|
|
152
|
+
e.attestations = [...(byVerifier.get(e.anchor.id) ?? new Map()).values()]
|
|
153
|
+
.map((list) => effectiveAttestation(list, latestChallenge?.created_at ?? 0));
|
|
154
|
+
// A patch that ships benchmark samples must be *executed* by verifiers; hash-only checks are recorded but do not list it.
|
|
155
|
+
const needsBenchmark = (e.anchor.benchmark.samples?.length ?? 0) > 0;
|
|
156
|
+
// An author attesting its own anchor is a self-check, never a verification: it is shown but excluded from every count
|
|
157
|
+
// that decides LISTED, so an attestation already on the chain stops counting the moment this node reads it.
|
|
158
|
+
const isSelf = (a) => !allowSelfAttest && sameAddr(a.verifier, e.anchor.author);
|
|
159
|
+
const independent = e.attestations.filter((a) => !isSelf(a));
|
|
160
|
+
/*
|
|
161
|
+
* What happened to each challenge: the attestations written after it are the verifiers' answer (item 328) — and
|
|
162
|
+
* ONLY those (item 330). A challenge used to be cleared by a single fresh PASS from anyone, after which the
|
|
163
|
+
* second quorum slot was filled by a pre-challenge record, including the challenger's own: on the demo chain
|
|
164
|
+
* node-b challenged at 11:54:51, node-c alone re-ran at 11:56:06, and the item was LISTED 2/2 with node-b's
|
|
165
|
+
* 11:53:42 row still counted while node-b's own re-run had not finished. A challenge is a question addressed to
|
|
166
|
+
* the verifiers, so it is answered when the QUORUM is re-established by measurements taken after it — and one
|
|
167
|
+
* verifier that fails the re-run upholds it whatever anyone else measured.
|
|
168
|
+
*/
|
|
169
|
+
const answersFor = (from, until) => independent.filter((a) => a.created_at > from && a.created_at < until && a.baseline !== false && (!needsBenchmark || a.verified_on !== 'hash-only'));
|
|
170
|
+
const byTime = [...e.challenges].sort((a, b) => a.created_at - b.created_at);
|
|
171
|
+
e.challenge_log = byTime.map((ch, i) => {
|
|
172
|
+
const answers = answersFor(ch.created_at, byTime[i + 1]?.created_at ?? Infinity);
|
|
173
|
+
const failed = answers.filter((a) => !a.passed).sort((a, b) => a.created_at - b.created_at)[0];
|
|
174
|
+
if (failed)
|
|
175
|
+
return { challenge: ch, state: 'upheld', answered_at: failed.created_at, answered_by: failed.verifier };
|
|
176
|
+
const passes = answers.filter((a) => a.passed).sort((a, b) => a.created_at - b.created_at);
|
|
177
|
+
if (passes.length >= quorum)
|
|
178
|
+
return { challenge: ch, state: 'dismissed', answered_at: passes[quorum - 1].created_at, answered_by: passes[quorum - 1].verifier };
|
|
179
|
+
return { challenge: ch, state: 'open' };
|
|
180
|
+
});
|
|
181
|
+
// A challenge nobody has answered yet is open whatever the status is (item 242): an ANNOUNCED / VERIFYING /
|
|
182
|
+
// REJECTED entry is exactly where the publisher needs the re-run, and the verifier round reads this flag.
|
|
183
|
+
const openChallenge = e.challenge_log.filter((c) => c.state === 'open').map((c) => c.challenge).sort((a, b) => b.created_at - a.created_at)[0];
|
|
184
|
+
if (openChallenge)
|
|
185
|
+
e.open_challenge = openChallenge;
|
|
186
|
+
// While a challenge is open, an attestation written BEFORE it is not an answer to it and does not count (item 330).
|
|
187
|
+
// The records stay in `attestations` — they are permanent, and the verification tab shows which ones answered.
|
|
188
|
+
const current = e.open_challenge ? independent.filter((a) => a.created_at > e.open_challenge.created_at) : independent;
|
|
189
|
+
e.stale_attestations = independent.length - current.length;
|
|
190
|
+
// A run on a table where the knowledge was ALREADY applied has no un-patched baseline of its own: the record is
|
|
191
|
+
// kept (it is on the ledger for ever) but it is not a verification of anything (item 329).
|
|
192
|
+
const counted = current.filter((a) => a.baseline !== false);
|
|
193
|
+
e.no_baseline = current.length - counted.length;
|
|
194
|
+
const executed = counted.filter((a) => a.passed && (!needsBenchmark || a.verified_on !== 'hash-only'));
|
|
195
|
+
e.passed = executed.length;
|
|
196
|
+
e.verifiers = [...new Set(executed.map((a) => a.verifier))];
|
|
197
|
+
// Independence is a claim about the MACHINE, not the address: two verifier processes on one vLLM produce one
|
|
198
|
+
// executor fingerprint, and the entry says so instead of counting them as two independent verifications.
|
|
199
|
+
e.executors = [...new Set(executed.map((a) => a.executor?.instance).filter((x) => !!x))];
|
|
200
|
+
e.executors_unknown = executed.filter((a) => !a.executor?.instance).length;
|
|
201
|
+
e.integrity_checks = counted.filter((a) => a.verified_on === 'hash-only').length;
|
|
202
|
+
e.self_checks = e.attestations.length - independent.length;
|
|
203
|
+
/**
|
|
204
|
+
* The quorum is a count of MACHINES, not of addresses.
|
|
205
|
+
*
|
|
206
|
+
* `e.passed` counts attestations, which are deduplicated per verifier address — so three node processes sharing
|
|
207
|
+
* one vLLM, which is how a single host runs a cluster, produced three "independent" verifications of the same
|
|
208
|
+
* bytes on the same weights and opened the sale. The fingerprint that says otherwise was already computed on
|
|
209
|
+
* the line above, and was shown to people (`sharedEngine` on the knowledge page, a warning line in the CLI)
|
|
210
|
+
* while the gate that decides `sellable` went on counting addresses. A warning nobody is obliged to read is
|
|
211
|
+
* not the promise this product makes about verification.
|
|
212
|
+
*
|
|
213
|
+
* Attestations written before `executor` existed carry no fingerprint and cannot be grouped by machine; they
|
|
214
|
+
* are counted per address, as they always were, so no published knowledge loses a verification it already had.
|
|
215
|
+
* The two are added, never mixed: a fingerprinted attestation is counted by its machine and by nothing else.
|
|
216
|
+
* `executor.instance` is inside the signed body (verifier.ts), so claiming a machine you are not on is forgery
|
|
217
|
+
* rather than an accident of deployment — which is the line this check is meant to draw.
|
|
218
|
+
*/
|
|
219
|
+
e.quorum_ok = e.executors.length + e.executors_unknown >= quorum;
|
|
220
|
+
// Items 365 / 194 — a sale to yourself is not a sale, and a sale is not what the seller was paid.
|
|
221
|
+
const fmtAmt = (n) => n.toFixed(6).replace(/\.?0+$/, '') || '0';
|
|
222
|
+
const real = e.settlements.filter((x) => !sameAddr(x.buyer, x.seller));
|
|
223
|
+
e.self_purchases = e.settlements.length - real.length;
|
|
224
|
+
e.downloads = real.length;
|
|
225
|
+
e.buyers = new Set(real.map((x) => (x.buyer ?? '').toLowerCase())).size;
|
|
226
|
+
e.revenue = fmtAmt(real.reduce((s, x) => s + Number(x.amount || 0), 0));
|
|
227
|
+
// The author's own line in the royalty map is what reached them; a settlement written before the map existed
|
|
228
|
+
// paid the whole amount to the seller, which is what the fallback says.
|
|
229
|
+
const netOf = (x) => {
|
|
230
|
+
const entries = Object.entries(x.royalty ?? {});
|
|
231
|
+
if (!entries.length)
|
|
232
|
+
return Number(x.amount || 0);
|
|
233
|
+
return entries.filter(([addr]) => sameAddr(addr, e.anchor.author)).reduce((n, [, amt]) => n + Number(amt || 0), 0);
|
|
234
|
+
};
|
|
235
|
+
const net = real.reduce((s, x) => s + netOf(x), 0);
|
|
236
|
+
e.revenue_net = fmtAmt(net);
|
|
237
|
+
e.revenue_shared = fmtAmt(Math.max(0, real.reduce((s, x) => s + Number(x.amount || 0), 0) - net));
|
|
238
|
+
if (e.status === 'DRAFT') {
|
|
239
|
+
e.sellable = false;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const failed = counted.filter((a) => !a.passed && (!needsBenchmark || a.verified_on !== 'hash-only')).length;
|
|
243
|
+
// What the entry had established BEFORE the open challenge discounted those records (item 330): an item that was
|
|
244
|
+
// on sale and is now disputed reads CHALLENGED, not "back to VERIFYING" — the sale stopped, the history did not.
|
|
245
|
+
const everPassed = independent.filter((a) => a.baseline !== false && a.passed && (!needsBenchmark || a.verified_on !== 'hash-only'));
|
|
246
|
+
if (e.quorum_ok) {
|
|
247
|
+
e.status = 'LISTED';
|
|
248
|
+
e.listed_at = Math.max(...executed.map((a) => a.created_at));
|
|
249
|
+
// An unanswered challenge holds the entry until a QUORUM of verifiers re-runs it (item 330).
|
|
250
|
+
if (e.open_challenge)
|
|
251
|
+
e.status = 'CHALLENGED';
|
|
252
|
+
if (e.superseded_by.length && e.status !== 'CHALLENGED')
|
|
253
|
+
e.status = 'SUPERSEDED';
|
|
254
|
+
}
|
|
255
|
+
else if (failed >= quorum) {
|
|
256
|
+
e.status = 'REJECTED';
|
|
257
|
+
}
|
|
258
|
+
else if (e.open_challenge && everPassed.length >= quorum) {
|
|
259
|
+
e.status = 'CHALLENGED';
|
|
260
|
+
e.listed_at = Math.max(...everPassed.map((a) => a.created_at));
|
|
261
|
+
}
|
|
262
|
+
else if (e.attestations.length > 0) {
|
|
263
|
+
e.status = 'VERIFYING';
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
e.status = 'ANNOUNCED';
|
|
267
|
+
}
|
|
268
|
+
// A disputed entry is not for sale at any price: the 402 gate, `patch buy` and the agent all read this flag.
|
|
269
|
+
e.sellable = e.quorum_ok && e.status !== 'CHALLENGED';
|
|
270
|
+
}
|
|
271
|
+
return [...byId.values()].sort((a, b) => b.anchor.created_at - a.anchor.created_at);
|
|
272
|
+
}
|
|
273
|
+
/** A caller-supplied value was malformed (HTTP layers map it to 400 instead of 500). */
|
|
274
|
+
export class ValidationError extends Error {
|
|
275
|
+
constructor(message) { super(message); this.name = 'ValidationError'; }
|
|
276
|
+
}
|
|
277
|
+
/** Anchor price: a non-negative decimal string (`'0'`, `'0.1'`, `'25'`); negative or non-numeric prices would produce negative royalties. */
|
|
278
|
+
export const PRICE_RE = /^\d+(\.\d+)?$/;
|
|
279
|
+
export function validatePrice(price, label = 'price') {
|
|
280
|
+
if (typeof price !== 'string' || !PRICE_RE.test(price.trim()))
|
|
281
|
+
throw new ValidationError(`${label} must be a non-negative number (e.g. "0", "0.1", "25")`);
|
|
282
|
+
return price.trim();
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Validate an anchor's contributor list (createDraft / updateDraft / publish). Returns a normalised copy.
|
|
286
|
+
* Rules: ≤ MAX_CONTRIBUTORS entries, unique addresses, 0 ≤ share ≤ 1 each and Σ share ≤ 1, role 'data_provider',
|
|
287
|
+
* proof 'signed' | 'declared', name ≤ 40 chars. Throws ValidationError(<message>) on the first violation.
|
|
288
|
+
*/
|
|
289
|
+
export function validateContributors(list) {
|
|
290
|
+
if (list === undefined || list === null)
|
|
291
|
+
return [];
|
|
292
|
+
if (!Array.isArray(list))
|
|
293
|
+
throw new ValidationError('contributors must be an array');
|
|
294
|
+
if (list.length > MAX_CONTRIBUTORS)
|
|
295
|
+
throw new ValidationError(`at most ${MAX_CONTRIBUTORS} contributors per patch`);
|
|
296
|
+
const out = [];
|
|
297
|
+
const seen = new Set();
|
|
298
|
+
let sum = 0;
|
|
299
|
+
for (const raw of list) {
|
|
300
|
+
const c = raw;
|
|
301
|
+
if (!c || typeof c !== 'object')
|
|
302
|
+
throw new ValidationError('contributor must be an object');
|
|
303
|
+
if (typeof c.address !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(c.address))
|
|
304
|
+
throw new ValidationError('contributor.address must be an AIN address (0x + 40 hex)');
|
|
305
|
+
const address = c.address.toLowerCase();
|
|
306
|
+
if (seen.has(address))
|
|
307
|
+
throw new ValidationError(`duplicate contributor address: ${c.address}`);
|
|
308
|
+
seen.add(address);
|
|
309
|
+
if (typeof c.share !== 'number' || !Number.isFinite(c.share) || c.share < 0 || c.share > 1)
|
|
310
|
+
throw new ValidationError('contributor.share must be a number between 0 and 1');
|
|
311
|
+
sum += c.share;
|
|
312
|
+
if (sum > 1 + 1e-9)
|
|
313
|
+
throw new ValidationError('contributor shares add up to more than 1');
|
|
314
|
+
if (c.role !== undefined && c.role !== 'data_provider')
|
|
315
|
+
throw new ValidationError(`unsupported contributor role: ${String(c.role)}`);
|
|
316
|
+
if (c.proof !== undefined && c.proof !== 'signed' && c.proof !== 'declared')
|
|
317
|
+
throw new ValidationError(`unsupported contributor proof: ${String(c.proof)}`);
|
|
318
|
+
if (c.name !== undefined && (typeof c.name !== 'string' || c.name.length > 40))
|
|
319
|
+
throw new ValidationError('contributor.name must be a string of at most 40 chars');
|
|
320
|
+
if (c.signer !== undefined && (typeof c.signer !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(c.signer)))
|
|
321
|
+
throw new ValidationError('contributor.signer must be an AIN address');
|
|
322
|
+
if (c.sig !== undefined && typeof c.sig !== 'string')
|
|
323
|
+
throw new ValidationError('contributor.sig must be a string');
|
|
324
|
+
const entry = { address: c.address, share: c.share, role: 'data_provider', proof: c.proof ?? (c.sig ? 'signed' : 'declared') };
|
|
325
|
+
if (c.signer)
|
|
326
|
+
entry.signer = c.signer;
|
|
327
|
+
if (c.name)
|
|
328
|
+
entry.name = c.name.trim();
|
|
329
|
+
if (c.sig)
|
|
330
|
+
entry.sig = c.sig;
|
|
331
|
+
out.push(entry);
|
|
332
|
+
}
|
|
333
|
+
return out;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Non-throwing variant for anchors we did not write (peer gossip, chain reads): a malformed contributor list is treated as
|
|
337
|
+
* "no contributors" so a hostile peer anchor (share 5, 40 entries, junk addresses) can never inflate a payout here.
|
|
338
|
+
*/
|
|
339
|
+
export function sanitizeContributors(list) {
|
|
340
|
+
if (list === undefined || list === null)
|
|
341
|
+
return undefined;
|
|
342
|
+
try {
|
|
343
|
+
const out = validateContributors(list);
|
|
344
|
+
return out.length ? out : undefined;
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/** Cycle-safe ceiling on the lineage walk. Replaces the old `depth > 16` cut, which paid an 18-hop ancestor nothing. */
|
|
351
|
+
export const MAX_LINEAGE_ANCHORS = 4096;
|
|
352
|
+
export function royaltyPlan(entry, all, amount, share, opts = {}) {
|
|
353
|
+
const seller = entry.anchor.author;
|
|
354
|
+
const same = (a, b) => (a ?? '').toLowerCase() === (b ?? '').toLowerCase();
|
|
355
|
+
const shareUsed = effectiveRoyaltyShare(entry.anchor, share);
|
|
356
|
+
const verifiers = [...new Set((opts.verifiers ?? entry.verifiers ?? []).filter((v) => typeof v === 'string' && v && !same(v, seller)))];
|
|
357
|
+
const verifierShareUsed = verifiers.length ? effectiveVerifierShare(entry.anchor, opts.verifierShare) : 0;
|
|
358
|
+
// Defensive: shares outside [0, 1] (unvalidated peer / chain anchors) are clamped and the total carve of one anchor can
|
|
359
|
+
// never exceed the slice it is carved from, so Σ payouts ≤ amount holds whatever the lineage carries.
|
|
360
|
+
const safeShare = (c) => (typeof c.share === 'number' && Number.isFinite(c.share) ? Math.min(1, Math.max(0, c.share)) : 0);
|
|
361
|
+
// ---- the walk: every ancestor anchor, breadth-first, cycle-safe, with no depth cut (item 192)
|
|
362
|
+
const outside = []; // unique ancestor authors ≠ seller, first-seen order
|
|
363
|
+
const anchorsByAuthor = new Map();
|
|
364
|
+
const selfAncestors = []; // ancestor anchors published by the seller itself
|
|
365
|
+
const unresolvedIds = []; // parent ids no anchor and no `parent_authors` entry names
|
|
366
|
+
const visited = new Set([entry.anchor.id]); // the sold anchor is never its own ancestor
|
|
367
|
+
const noteAuthor = (author, pe) => {
|
|
368
|
+
if (same(author, seller)) {
|
|
369
|
+
if (pe)
|
|
370
|
+
selfAncestors.push(pe);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const key = outside.find((a) => same(a, author)) ?? (outside.push(author), author);
|
|
374
|
+
if (pe) {
|
|
375
|
+
const list = anchorsByAuthor.get(key) ?? [];
|
|
376
|
+
list.push(pe);
|
|
377
|
+
anchorsByAuthor.set(key, list);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
let truncated = false;
|
|
381
|
+
const queue = [entry.anchor.id];
|
|
382
|
+
for (let head = 0; head < queue.length; head++) {
|
|
383
|
+
// The anchor being sold is read from the ENTRY the caller handed us, never from the map: a caller settling a
|
|
384
|
+
// draft, a fork or an anchor this node's catalogue snapshot does not carry yet used to walk no parents at all
|
|
385
|
+
// and silently pay the whole lineage pool to the seller. The map is authoritative for the ancestors only.
|
|
386
|
+
const e = queue[head] === entry.anchor.id ? entry : all.get(queue[head]);
|
|
387
|
+
if (!e)
|
|
388
|
+
continue;
|
|
389
|
+
const parents = e.anchor.parents ?? [];
|
|
390
|
+
for (let i = 0; i < parents.length; i++) {
|
|
391
|
+
const p = parents[i];
|
|
392
|
+
if (visited.has(p))
|
|
393
|
+
continue;
|
|
394
|
+
if (visited.size >= MAX_LINEAGE_ANCHORS) {
|
|
395
|
+
truncated = true;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
visited.add(p);
|
|
399
|
+
const pe = all.get(p);
|
|
400
|
+
if (pe) {
|
|
401
|
+
noteAuthor(pe.anchor.author, pe);
|
|
402
|
+
queue.push(p);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
// The anchor is not in this node's map. The record that names it also names its author — use that, and only
|
|
406
|
+
// give up (and say so on the settlement) when nothing does.
|
|
407
|
+
const named = e.anchor.parent_authors?.[i];
|
|
408
|
+
if (named && typeof named === 'string')
|
|
409
|
+
noteAuthor(named);
|
|
410
|
+
else
|
|
411
|
+
unresolvedIds.push(p);
|
|
412
|
+
}
|
|
413
|
+
if (truncated)
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
const sums = {};
|
|
417
|
+
const keyFor = new Map(); // lower-cased address → the spelling we sum under
|
|
418
|
+
const add = (addr, n) => {
|
|
419
|
+
const lower = (addr ?? '').toLowerCase();
|
|
420
|
+
const key = keyFor.get(lower) ?? (keyFor.set(lower, addr), addr);
|
|
421
|
+
sums[key] = (sums[key] ?? 0) + n;
|
|
422
|
+
};
|
|
423
|
+
// ---- pass 1 / 1b / 1c: the lineage pool
|
|
424
|
+
const payees = outside.length + unresolvedIds.length;
|
|
425
|
+
const pool = payees ? amount * shareUsed : 0;
|
|
426
|
+
const each = payees ? pool / payees : 0;
|
|
427
|
+
const unresolved = {};
|
|
428
|
+
for (const a of outside) {
|
|
429
|
+
const anchors = anchorsByAuthor.get(a) ?? [];
|
|
430
|
+
if (!anchors.length) {
|
|
431
|
+
add(a, each);
|
|
432
|
+
continue;
|
|
433
|
+
} // named by `parent_authors` but not held here
|
|
434
|
+
const sub = each / anchors.length;
|
|
435
|
+
for (const pe of anchors) {
|
|
436
|
+
let rem = sub;
|
|
437
|
+
for (const c of Array.isArray(pe.anchor.contributors) ? pe.anchor.contributors : []) {
|
|
438
|
+
if (!c || typeof c.address !== 'string' || same(c.address, a))
|
|
439
|
+
continue; // folds back into the author anyway
|
|
440
|
+
const carve = Math.min(rem, sub * safeShare(c));
|
|
441
|
+
add(c.address, carve);
|
|
442
|
+
rem -= carve;
|
|
443
|
+
}
|
|
444
|
+
add(a, rem);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
for (const id of unresolvedIds)
|
|
448
|
+
unresolved[id] = (each).toFixed(6).replace(/\.?0+$/, '') || '0';
|
|
449
|
+
// ---- pass 2: the seller side
|
|
450
|
+
const sellerSide = amount - pool;
|
|
451
|
+
let remainder = sellerSide;
|
|
452
|
+
const verification = {};
|
|
453
|
+
const verifierPool = sellerSide * verifierShareUsed;
|
|
454
|
+
if (verifiers.length && verifierPool > 0) {
|
|
455
|
+
const per = verifierPool / verifiers.length;
|
|
456
|
+
for (const v of verifiers) {
|
|
457
|
+
const carve = Math.min(remainder, per);
|
|
458
|
+
add(v, carve);
|
|
459
|
+
verification[v] = carve.toFixed(6).replace(/\.?0+$/, '') || '0';
|
|
460
|
+
remainder -= carve;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
// Contributors credited on the sold anchor and on the seller's own ancestor anchors, once per address at the
|
|
464
|
+
// largest share they hold; every carve is a fraction of the SAME base, so two 0.5 providers are 50 % and 50 %.
|
|
465
|
+
const base = remainder;
|
|
466
|
+
const providers = new Map();
|
|
467
|
+
for (const pe of [entry, ...selfAncestors]) {
|
|
468
|
+
for (const c of Array.isArray(pe.anchor.contributors) ? pe.anchor.contributors : []) {
|
|
469
|
+
if (!c || typeof c.address !== 'string' || same(c.address, seller))
|
|
470
|
+
continue;
|
|
471
|
+
const lower = c.address.toLowerCase();
|
|
472
|
+
const cur = providers.get(lower);
|
|
473
|
+
if (!cur || safeShare(c) > cur.share)
|
|
474
|
+
providers.set(lower, { address: cur?.address ?? c.address, share: Math.max(cur?.share ?? 0, safeShare(c)) });
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
for (const { address, share: sh } of providers.values()) {
|
|
478
|
+
const carve = Math.min(remainder, base * sh);
|
|
479
|
+
add(address, carve);
|
|
480
|
+
remainder -= carve;
|
|
481
|
+
}
|
|
482
|
+
add(seller, remainder);
|
|
483
|
+
const fmt = (n) => n.toFixed(6).replace(/\.?0+$/, '');
|
|
484
|
+
const royalty = {};
|
|
485
|
+
for (const [addr, n] of Object.entries(sums)) {
|
|
486
|
+
if (!same(addr, seller) && n <= 0)
|
|
487
|
+
continue;
|
|
488
|
+
royalty[addr] = fmt(n) || '0';
|
|
489
|
+
}
|
|
490
|
+
return { royalty, unresolved, verification, truncated, share: shareUsed, verifier_share: verifierShareUsed };
|
|
491
|
+
}
|
|
492
|
+
/** The payout map alone — the shape every caller before the lineage/verifier work expected. */
|
|
493
|
+
export function royaltySplit(entry, all, amount, share, opts = {}) {
|
|
494
|
+
return royaltyPlan(entry, all, amount, share, opts).royalty;
|
|
495
|
+
}
|
|
496
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6EvG;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAmB,EAAE,YAAY,GAAG,CAAC;IACxE,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,Y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