|
| 1 | +# NIP porting ledger |
| 2 | + |
| 3 | +One row per NIP the relay advertises, and the evidence behind the claim. This is the artifact |
| 4 | +[`kpis.md` §1](kpis.md) names as the only one of the six KPIs that has to be built; its |
| 5 | +reading is `ported / advertised`, and the cutover gate is 25 of 25. |
| 6 | + |
| 7 | +## 1. The denominator |
| 8 | + |
| 9 | +The set is `supportedNips` in `package.json:7` at the v3 grading tip `041fe34e` — the same 25 |
| 10 | +the Phase 0 audit used in [`nip-parity.md` §2](nip-parity.md). It is **not** the Rust |
| 11 | +`SUPPORTED_NIPS` (`crates/nostream-core/src/constants.rs:17`), which carries 34, and the two |
| 12 | +differ in both directions: |
| 13 | + |
| 14 | +- **In the Rust list, not the v3 one (10):** `05 56 59 62 66 67 70 89 90 98` — behaviour the |
| 15 | + audit found implemented but unadvertised at 3.5.1 (§7 there). |
| 16 | +- **In the v3 list, not the Rust one (1):** `15` — the audit's own verdict is that the number |
| 17 | + now means Marketplace, and that nostream's NIP-15 is the obsolete EOSE NIP. |
| 18 | + |
| 19 | +Both sets are defensible and they answer different questions. The gate measures *"does the |
| 20 | +rewrite reproduce what v3 promised"*, so it uses the v3 set. The Rust list is a decision about |
| 21 | +what the rewrite will claim afterwards, recorded in `nip-parity.md` §10 and asserted by |
| 22 | +`crates/nostream-core/tests/supported_nips.rs`. A row here does not move because the Rust |
| 23 | +advertisement changed; it moves because a test appeared or disappeared. |
| 24 | + |
| 25 | +## 2. What a row means |
| 26 | + |
| 27 | +- **`oracle`** — the test at `041fe34e` that pins the behaviour today. TypeScript is the |
| 28 | + oracle for observable behaviour (`nip-parity.md` §1): a Rust module must reproduce what the |
| 29 | + TS suite proved, not what a `src/…` file happened to do. |
| 30 | +- **`rust test`** — the Rust test that proves the same behaviour on `rewrite/main`. |
| 31 | +- **`teeth`** — the inversion that makes that test fail. A test whose failure mode cannot be |
| 32 | + reached does not earn `ported`, however green it is; the obligation is the one `build.md` |
| 33 | + rows already carry. |
| 34 | +- **`status`** — `ported` needs all three columns filled and the inversion recorded. |
| 35 | + `partial` is a Rust test that proves part of the behaviour. `open` is no qualifying test. |
| 36 | + |
| 37 | +A row with an empty `teeth` cell is not `ported`, whatever the `rust test` cell says. That is |
| 38 | +the distinction the two cheap proxies got wrong: presence is not coverage. |
| 39 | + |
| 40 | +## 3. The ledger |
| 41 | + |
| 42 | +Rows are ordered by NIP number. The `teeth` cell names the change that would turn the test |
| 43 | +red, in the same shape as a `build.md` row's `inversion:`. |
| 44 | + |
| 45 | +| nip | oracle (v3 `041fe34e`) | rust test (`rewrite/main`) | teeth | status | |
| 46 | +|---|---|---|---|---| |
| 47 | +| 01 | `test/unit/utils/event.spec.ts`, `test/integration/features/nip-01/nip-01.feature` | `nostream-core/tests/filter_truth_table.rs::line_1_exact_tag_value_matches` (31 probe lines); `nostream-relay/tests/handlers.rs::req_streams_a_stored_event_then_eose` | any probe line's answer flips, or the stored frame stops preceding EOSE | **partial** — `limit: 0` is asserted at the store (`parity_lmdb.rs::a_zero_limit_returns_no_rows`), not on the wire | |
| 48 | +| 02 | `nip-02.feature` | `nostream-relay/tests/strategies.rs::contact_list_updates_the_wot_graph_with_the_p_tagged_pubkeys_when_newly_stored`, `::contact_list_upserts_the_event` | a `p` tag stops producing a follow edge, or a second kind 3 stops replacing the first | ported | |
| 49 | +| 03 | `nip-03.feature` | `nostream-relay/tests/strategies.rs::timestamp_stores_and_broadcasts_a_valid_proof` | a kind 1040 proof is refused, stored but not broadcast, or answered without OK | ported | |
| 50 | +| 04 | `nip-04.feature` | none specific — the generic store/serve path (`handlers.rs::req_streams_a_stored_event_then_eose`) | a kind 4 event refused or served differently from any other kind | **partial** — v3's `DEFAULT_RESTRICTED_READ_KINDS` behaviour has no test here | |
| 51 | +| 09 | `nip-09.feature` | `nostream-relay/tests/strategies.rs::delete_soft_deletes_the_events_its_e_tags_name`, `::delete_soft_deletes_an_addressable_event_named_by_an_a_tag` | an `e`- or `a`-named target survives the kind-5, or the request itself is deleted | ported | |
| 52 | +| 11 | `nip-11.feature` | none — nothing serves an HTTP document; `supported_nips.rs` asserts the constant only | a served NIP-11 document omits an advertised id or a `limitation` key | **open** — no HTTP surface yet (decision D1, `nip-parity.md` §10) | |
| 53 | +| 12 | `test/unit/schemas/filter-schema.spec.ts`, `test/unit/utils/event.spec.ts` | `nostream-core/tests/filter_truth_table.rs` (the single-letter tag lines) | a `#e` or `#p` line's match flips | ported | |
| 54 | +| 13 | `nip-13.feature` | `nostream-relay/tests/handlers.rs::the_static_proof_of_work_requirements_are_enforced` | an event under the leading-zero-bit floor is accepted | **partial** — the `nonce`/`difficulty` tag is never exercised | |
| 55 | +| 14 | `test/unit/schemas/event-schema.spec.ts` (`accepts subject tag on text note events`) | `nostream-relay/tests/nip_vectors.rs::nip14_a_kind_1_event_returns_its_subject_tag` | the `subject` tag is dropped or rewritten across store and serve | ported | |
| 56 | +| 15 | tombstone — EOSE is the `nip-01.feature` row | `nostream-relay/tests/handlers.rs::req_streams_a_stored_event_then_eose` | EOSE is omitted, or sent before the stored events | ported | |
| 57 | +| 16 | `nip-16.feature` | `nostream-relay/tests/nip_vectors.rs::nip28_channel_metadata_is_replaceable_and_channel_events_are_not` (over the wire: two kind 41s, one served); `strategies.rs::replaceable_upserts_the_event`, `::ephemeral_sends_ok_and_broadcasts_without_storing` | the upsert stops being keyed on `(author, kind)`, a newer replaceable stops displacing the older, or an ephemeral is stored | ported — the strategy tests assert the upsert *call*, the wire test asserts the surviving row | |
| 58 | +| 17 | `nip-17.feature` | `nostream-relay/tests/strategies.rs::gift_wrap_stores_a_valid_wrap`; `handlers.rs::inner_kinds_must_be_gift_wrapped` | a kind 1059 wrap is refused, or a bare 13/14/15/444 is accepted | ported | |
| 59 | +| 20 | `test/unit/handlers/event-message-handler.spec.ts` (the OK assertions) | `nostream-relay/tests/handlers.rs::the_default_strategy_answers_ok_and_duplicate`, `::a_restricted_only_req_from_an_unauthenticated_client_is_closed` | a duplicate is accepted twice, or CLOSED loses its machine-readable prefix | ported | |
| 60 | +| 22 | `nip-22.feature` | `nostream-relay/tests/nip_vectors.rs::nip22_a_kind_1111_comment_is_stored_and_served_unchanged` | a comment's `K`/`E`/`P`/`k`/`e`/`p` tag is dropped on re-serve — the test asserts each tag with `contains`, so reordering stays green | ported — the code implements Comment, not the retired `created_at` limits | |
| 61 | +| 25 | `nip-25.feature` | `nostream-core/tests/wire_codec.rs::strict_event_schema_checks_the_refinements` | a kind 7 with no `e`/`a` target is accepted | **partial** — content `+`/`-`/emoji is never asserted, and no reaction is stored or served | |
| 62 | +| 28 | `nip-28.feature` | `nostream-relay/tests/nip_vectors.rs::nip28_channel_metadata_is_replaceable_and_channel_events_are_not` | kind 41 stops replacing, or kind 42 starts replacing | **partial** — kinds 43–49 are not exercised | |
| 63 | +| 33 | `nip-33.feature` | `nostream-relay/tests/strategies.rs::parameterized_replaceable_uses_the_first_d_tag_value`; `nip_vectors.rs::nip89_recommendation_and_handler_events_are_stored_and_served` | the dedup key becomes a later `d` value, or the older `d`-twin is served | ported | |
| 64 | +| 40 | `nip-40.feature` | `nostream-relay/tests/handlers.rs::an_expired_event_is_rejected`; `connection.rs::an_event_expired_when_the_read_starts_is_not_delivered` | an expired event is stored, or served by a read that started after expiry | ported | |
| 65 | +| 42 | `test/unit/adapters/web-socket-adapter.spec.ts`, `event-message-handler.spec.ts` | `nostream-relay/tests/handlers.rs::auth_outcomes_are_the_captures_seven`, `::a_restricted_read_delivers_only_to_the_author_or_a_p_tagged_reader` | one of the seven AUTH rejections becomes an accept, or a restricted REQ is served unauthenticated | ported | |
| 66 | +| 43 | `test/unit/handlers/event-message-handler.spec.ts`, `event-strategies/invite-request-event-strategy.spec.ts`, `leave-request-event-strategy.spec.ts` | `nostream-relay/tests/handlers.rs::an_invite_request_mints_one_kind_28935_event_before_eose`; `strategies.rs::the_join_request_admits_and_answers_with_the_welcome` | the invite is minted twice, minted for an unauthenticated socket, or a join is admitted without spending the code | **partial** — no kind 13534 membership list and no relay-signed membership event | |
| 67 | +| 44 | `test/unit/utils/nip44.spec.ts` | `nostream-core/tests/nip44_parity.rs::produces_the_canonical_payload_from_the_nip44_spec_test_vector`, `::decrypts_the_canonical_nip44_spec_test_vector` | one byte of the canonical v2 payload changes, in either direction | ported | |
| 68 | +| 45 | `nip-45.feature`, `test/unit/handlers/count-message-handler.spec.ts` | `nostream-relay/tests/handlers.rs::count_answers_with_the_count_object` | the `COUNT` reply shape changes, or a disabled COUNT is still answered | **partial** — every COUNT test counts an empty store; no non-empty match set is counted | |
| 69 | +| 50 | `nip-50.feature` | `nostream-storage/tests/parity_lmdb.rs::a_search_returns_the_recorded_rows_in_rank_order`, `::a_search_orders_by_proximity_then_event_id`, `::a_limited_count_counts_the_rank_page`; `nostream-relay/tests/nip_vectors.rs::nip50_a_search_filter_is_served_only_when_enabled` | the recorded rank order changes, a proximity tie stops breaking on event id, or a non-matching note is served with the setting on | **partial** — rank order is proven at the store; the relay test asserts membership only, so nothing asserts that the served frame order matches the store's rank | |
| 70 | +| 65 | `nip-65.feature` | `nostream-relay/tests/nip_vectors.rs::nip65_a_relay_list_is_stored_and_replaces_the_previous_one` | a second kind 10002 stops replacing the first | ported | |
| 71 | +| 77 | `test/unit/handlers/neg-open-message-handler.spec.ts` | none — the relay answers `NEG-OPEN` with `["NOTICE","invalid: Invalid input"]` (`handlers.rs::an_invalid_frame_gets_the_capture_notice`) and both encoders return `NotImplemented` | negentropy sync never happens, which is today's whole surface | **open** — `negentropy_parity.rs` asserts library frames, never relay sync | |
| 72 | + |
| 73 | +## 4. Counting |
| 74 | + |
| 75 | +`ported` counts cells, not intentions: the number in `kpis.md` §1 is the count of rows whose |
| 76 | +status reads `ported`, out of 25. Nothing else is aggregated — a percentage over `partial` rows |
| 77 | +would mix a missing branch with a missing feature. |
| 78 | + |
| 79 | +**Measured on `rewrite/main` at `f01cb5f3`: 15 of 25 `ported`, 8 `partial`, 2 `open`.** Every |
| 80 | +Rust citation above was checked to exist at that commit, and the two `open` rows were read in |
| 81 | +the code rather than inferred from a missing file. |
| 82 | + |
| 83 | +| status | nips | |
| 84 | +|---|---| |
| 85 | +| ported | `02 03 09 12 14 15 16 17 20 22 33 40 42 44 65` | |
| 86 | +| partial | `01 04 13 25 28 43 45 50` | |
| 87 | +| open | `11 77` | |
| 88 | + |
| 89 | +## 5. What the missing ten cost |
| 90 | + |
| 91 | +The gap is not uniform, and the fix differs per row, which is why the ledger lists them |
| 92 | +instead of a percentage: |
| 93 | + |
| 94 | +- **Two are unbuilt surfaces, not untested code.** NIP-11 needs an HTTP document served at the |
| 95 | + relay's own URI (decision D1 defers it), and NIP-77 needs negentropy on the wire — the relay |
| 96 | + answers `NEG-OPEN` as an invalid frame today. Neither moves until someone builds it, and |
| 97 | + neither can be closed by a test. |
| 98 | +- **Seven are branches a test was never written for**, each named in its row: `limit: 0` on the |
| 99 | + wire (01), the restricted-read default (04), the `nonce`/`difficulty` tag (13), reaction |
| 100 | + content and store/serve (25), kinds 43–49 (28), a non-empty `COUNT` (45), and served-frame |
| 101 | + order matching the store's rank (50). The behaviour exists in each case; only the test is |
| 102 | + missing. |
| 103 | +- **One needs code, not a test.** NIP-43's kind 13534 membership list and its relay-signed |
| 104 | + membership event do not exist in Rust: `JoinRequestStrategy` spends the invite, admits the |
| 105 | + pubkey and answers the welcome, and nothing mints or serves a membership list. Counting it |
| 106 | + among the "test-only" rows would let cutover work skip building it. |
| 107 | +- **One is a counting artefact worth naming.** NIP-15 is a tombstone whose behaviour is EOSE, |
| 108 | + so its row cites the base-protocol test; that is not double-counting NIP-01, because the two |
| 109 | + rows ask different questions of the same assertion. |
| 110 | + |
| 111 | +So of the ten rows short of `ported`: two need a surface built (11, 77), one needs a feature |
| 112 | +built (43), and seven need a test written. Only the last seven are cheap, and none of them is |
| 113 | +optional — the gate counts `ported` rows, not intentions. |
0 commit comments