From 862f73d26d7e458372147b9c9174709f2d5b35c4 Mon Sep 17 00:00:00 2001 From: Worph Date: Wed, 9 Sep 2026 17:58:15 +0200 Subject: [PATCH] cid rank remove --- .../src/lib/hash-compute/MultiHashData.ts | 11 +- .../meta-hash/src/tests/cid-rank-vectors.json | 178 ------------------ 2 files changed, 9 insertions(+), 180 deletions(-) delete mode 100644 packages/shared/meta-hash/src/tests/cid-rank-vectors.json diff --git a/packages/shared/meta-hash/src/lib/hash-compute/MultiHashData.ts b/packages/shared/meta-hash/src/lib/hash-compute/MultiHashData.ts index 986fe20..191ae57 100644 --- a/packages/shared/meta-hash/src/lib/hash-compute/MultiHashData.ts +++ b/packages/shared/meta-hash/src/lib/hash-compute/MultiHashData.ts @@ -1,10 +1,17 @@ /** * Multicodec / multihash codes for every digest meta-hash can compute. * - * Source of truth for these numbers, mirrored in: + * Source of truth for these numbers. The same codes appear in the CID utility + * RANK, which is a separate thing this file does not implement: * - `packages/meta-core/internal/cid/rank.go` * - the `cid_rank.rs` in each of meta-search and meta-share - * - `/cid-rank-vectors.json` (the golden fixture that pins them all together) + * - `/cid-rank-vectors.json` (the golden fixture pinning those three together) + * + * ⚠ This package used to vendor that fixture at `src/tests/cid-rank-vectors.json` + * and no test ever loaded it, so every vector added cost a commit here for + * nothing. Removed 2026-09-09. If a TypeScript rank implementation is ever + * written, re-add the path to `scripts/check-cid-vectors.sh` *and* a test that + * asserts it — a vendored fixture nobody reads is not a guard. * * ⚠ meta-hash encodes `codec == multihash code` (see `ComputeHash.cidFinalize`: * `CID.createV1(code, create(code, digest))`), whereas the fullhash plugin and diff --git a/packages/shared/meta-hash/src/tests/cid-rank-vectors.json b/packages/shared/meta-hash/src/tests/cid-rank-vectors.json deleted file mode 100644 index 977e5e8..0000000 --- a/packages/shared/meta-hash/src/tests/cid-rank-vectors.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "$schema": "cid-rank-vectors/v1", - "$comment": [ - "CANONICAL golden vectors for the CID utility rank. THE single source of truth.", - "The rank decides which of a record's several CIDs is elected canonical - the cid a", - "record is advertised and addressed by. It is reimplemented in Go, 2x Rust and 3x TS;", - "they cannot share code (independent submodules, no cargo path-dep). These vectors are", - "the only thing holding them in sync: every implementation's test suite loads this file.", - "", - "This file is VENDORED into each consuming submodule (submodule CI cannot read above its", - "own tree). scripts/check-cid-vectors.sh diffs every copy against this one.", - "", - "Ranking is by UTILITY for external retrieval, not cryptographic strength.", - "Ties break on the lexicographically smaller cid, so the election is deterministic", - "across peers and does not churn.", - "", - "See METADATA_KEYS.md section 2/14.13 and docs/cid-formats.md." - ], - "ladder": { - "40": "dag-pb (IPFS block)", - "30": "sha2-256 / sha3-256 / sha3-384 - real content digests", - "25": "nzb-posting - content-derived (Message-ID set digest), but not itself fetchable", - "20": "BitTorrent infohashes - swarm interop", - "10": "midhash256 - the record address", - "5": "opaque locators (nzb-release, url, card, yt-video, ext-play) - never outrank a real digest", - "0": "weak/unknown digests, unparseable input" - }, - "tieBreak": "lexicographically smaller cid wins", - "vectors": [ - { - "name": "ipfs-dagpb", - "cid": "bafybeiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 40, - "note": "dag-pb codec 0x70 - chunked IPFS file, broadest network reach" - }, - { - "name": "sha2-256-raw-codec", - "cid": "bafkreiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 30, - "note": "fullhash/gateway convention: raw codec 0x55, mh names the algo" - }, - { - "name": "sha2-256-codec-eq-mh", - "cid": "baejbeibku6ua2l6r5olnggx4pto2sii2s5jeeawgh4cbkhlbmp52gudbua", - "rank": 30, - "note": "REAL meta-hash fixture; meta-hash sets codec == mh" - }, - { - "name": "sha3-256", - "cid": "baelbmidner7x3dd7t2kldh6wiq4w6lsye7qrwo6uoqot2t52zkhqk56fnq", - "rank": 30, - "note": "REAL meta-hash fixture" - }, - { - "name": "sha3-384", - "cid": "baekrkmeglipkjf33exqexdvijl4twipruay4wsbvt44akce43lq5rgccxgr7v6dwksmj3sxedakevc53g6ga", - "rank": 30, - "note": "REAL meta-hash fixture" - }, - { - "name": "nzb-posting", - "cid": "bagbsaeraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 25, - "note": "codec 0x1003 + REAL sha2-256 multihash (0x12) over the normalised, sorted Message-ID set - NOT a locator, so it sits ABOVE tier 5, but it addresses no fetchable block (bitswap can never satisfy a want for it - the digest is over an id set, not over any block's bytes), so it stays BELOW a real content digest (30): once meta-share materialises the media and re-seeds it, that genuine sha2-256 cid must win the canonical election, not this one. Rank MUST match on codec BEFORE falling through to the mh switch, or this scores 30 (same trap as nzb-release/url, in reverse: those need a codec check because their mh is identity 0x00; this needs one because its mh is REAL sha2-256 and would otherwise tie with tier 30)." - }, - { - "name": "btih-v2-codec-eq-mh", - "cid": "bag3sdnzbeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 20, - "note": "meta-hash encoder convention" - }, - { - "name": "btih-v2-raw-codec", - "cid": "bafk3oijaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 20, - "note": "fullhash encoder convention - SAME tier, both conventions must match" - }, - { - "name": "btih-v1-file", - "cid": "bagasbajacqaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 20, - "note": "gateway per-file BitTorrent v1" - }, - { - "name": "btih-v2-file", - "cid": "bagbcbaraeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 20, - "note": "gateway per-file BitTorrent v2" - }, - { - "name": "midhash256-codec-eq-mh", - "cid": "bagacbabaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 10, - "note": "the record address; internally meaningful, externally invisible" - }, - { - "name": "midhash256-raw-codec", - "cid": "bafkyaibaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 10 - }, - { - "name": "nzb-release-locator", - "cid": "bagcsaaazcbqxa2jonz5gez3fmvvs42lomzx55ln657fp4aab", - "rank": 5, - "note": "codec 0x1005 + IDENTITY multihash 0x00. The locator code is in the CODEC slot, not the mh slot - rank MUST match on codec. Tier 5 = below midhash: a locator never outranks a real digest, it wins only as a record's sole cid." - }, - { - "name": "url-locator", - "cid": "bagdcaaaznb2hi4dthixs6zlymfwxa3dffzxxezzpmexhazdg", - "rank": 5, - "note": "codec 0x1006 + IDENTITY multihash 0x00. Same tier/reasoning as nzb-release." - }, - { - "name": "card-locator", - "cid": "bagdsaaanar2g2zdcor3duojvgq3ts", - "rank": 5, - "note": "codec 0x1007 + IDENTITY multihash 0x00, digest = varint(len(source)) || source || id — here (\"tmdb\",\"tv:95479\"). Same codec-slot rule as nzb-release/url: match on the CODEC, never the mh. The limit case of the family — the only CID in MetaMesh with NO bytes behind it anywhere, ever: it addresses a *work* (a series, a film), not a file, so the byte path 404s by design and bitswap never offers it (seeding is gated on sha2-256). Tier 5 is load-bearing for the planned cross-source merge: one card record may carry BOTH a TMDB and a MyAnimeList locator, and if a real card body is ever added (see card-tier-search.md §4.3) its sha2-256 must win the canonical election over both locators without any addressing change. Ranking it 0 instead would still lose to a digest, but would put the implementations back out of agreement — which is the exact failure this fixture exists to prevent." - }, - { - "name": "yt-video-locator", - "cid": "bagecaaarav3gszdfn42ein3vgvfumn2tka4a", - "rank": 5, - "note": "codec 0x1008 + IDENTITY multihash 0x00, digest = varint(len(kind)) || kind || id — here (\"video\",\"4D7u5KF7SP8\"). DELEGATED PLAYBACK: the limit case beyond card. A card addresses a work with no bytes anywhere; this addresses a *rendition* whose bytes exist but are permanently someone else's — an external player renders it, nothing is transported, seeded or content-addressed. Framing is byte-identical to card (0x1007) on purpose, so each implementation extends the parser it already wrote. Same codec-slot rule: match on the CODEC, never the mh (identity 0x00 would fall through and score 0). Tier 5 is load-bearing for the on-ramp: a delegated reference and a real archived copy can sit on ONE record, and that sha2-256 must win the canonical election over this locator with no addressing change. NOTE the byte path must REFUSE this (400), not 404 — see docs/cid-formats.md §7.4." - }, - { - "name": "ext-play-locator", - "cid": "bagesaabenb2hi4dthixs6zlymfwxa3dffzrgc3temnqw24bomnxw2l3bnrrhk3jppa", - "rank": 5, - "note": "codec 0x1009 + IDENTITY multihash 0x00, digest = the verbatim UTF-8 URL. WIRE-IDENTICAL to url (0x1006) apart from the codec, and that difference is the entire contract: 0x1006 means 'fetch these bytes once and seed them', 0x1009 means 'open this in a browser, there are no bytes for us'. A decoder that matched on SHAPE rather than on the codec slot would see an identity multihash wrapping an http(s) URL, take the 0x1006 path, fetch a watch/Bandcamp page, chunk it, seed the HTML and link that content CID onto the record AS THE FILE — the MSR1 poisoning shape, except permanent and replicated. Same tier/reasoning as the rest of the locator family." - }, - { - "name": "sha1", - "cid": "baeircff3eqvxxaqqot2lt242stkdtk3gq4c2vra", - "rank": 0, - "note": "REAL meta-hash fixture; weak digest" - }, - { - "name": "md5", - "cid": "bahkqdvibcatpcfl7ine2n625eb5ml5mzkfaa", - "rank": 0, - "note": "REAL meta-hash fixture; weak digest" - }, - { - "name": "crc32", - "cid": "bagzafmqcathsbnrk", - "rank": 0, - "note": "REAL meta-hash fixture; weak digest" - }, - { - "name": "bt-pieces-root", - "cid": "bafkyf3qceaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 0, - "note": "torrent-internal merkle root, NOT a file-identity cid" - }, - { - "name": "cidv0-rejected", - "cid": "QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG", - "rank": 0, - "note": "TRAP: Go rejected this (rank 0) while Rust's MsCid::from_str ACCEPTED it and ranked it 40 (dag-pb). Strict parse = CIDv1 base32-lower only. This vector pins the fix." - }, - { - "name": "token-form-rejected", - "cid": "midhash256:bagacbabaeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "rank": 0, - "note": "TRAP: the deprecated : token form. Rust used to strip the prefix and rank it 10. It must now be rejected." - }, - { - "name": "garbage", - "cid": "not-a-cid", - "rank": 0 - }, - { - "name": "empty", - "cid": "", - "rank": 0 - } - ] -}