Skip to content

feat(iid, iid-spec): typed Wikidata identity int:wd:<slug>:Q… — spec amendment and reference implementation (P16) - #28

Open
jonathanprozzi wants to merge 3 commits into
update/v1.1.0-alphafrom
codex/p16-typed-wd
Open

jonathanprozzi wants to merge 3 commits into
update/v1.1.0-alphafrom
codex/p16-typed-wd

Conversation

@jonathanprozzi

@jonathanprozzi jonathanprozzi commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Child PR of the v1.1.0-alpha umbrella (#15). Tracking: ENG-15883. First of three stacked typed-wd PRs (this → iid-ladder → iid-registry).

Current (train)

The wd scheme is bare: int:wd:Q42, polymorphic at scheme level, never anchor-eligible, with no notion of what kind of thing a QID names.

Need

The reference implementation (intuition-v2 feat/intuition-app @ 1b877506d) types the value: int:wd:<slug>:Q…, where the slug is one of eleven pinned Wikidata EntitySchema bindings (three active: film, television-series, human). A typed value with an active binding is unambiguous and anchor-eligible; a dormant binding is valid but not mintable; bare values are unchanged. Ruled canonical for the packages.

Reconciliation

One unit, because the iid conformance test executes the iid-spec vectors.

  • iid-spec: schemes/wd.md (grammar ^(?:<slug>:)?Q[1-9]\d*$, ordered canonicalization, value-typed typing, the closed binding table with pinned revisions, vectors); spec §7.3 defines value-typed schemes; spec §9.3.1 adds the additive value-grammar extension clause; the conformance corpus gains valueTyped on scheme entries and optional per-vector typing; 18 new wd vectors, all 145 base vectors unchanged apart from one note.
  • iid: pinned, deep-frozen bindings table; typed-aware wd canonicalizer (URL forms never infer a slug; slug lowercased and must be registered; QID uppercased); per-value inspection (wdSlug on the valid branch, dormant-wd-binding ineligibility reason); typed derivation on the train's declarative ladder engine (the reference's callback engine is not ported); SCHEME_TYPING.wd stays polymorphic.

Defaults in effect, for ratification in this review

  • Spec freeze rule: typed-wd lands as an in-place MINOR amendment under a new §9.3.1 clause (every existing canonical value byte-identical, no existing identifier changes validity or eligibility, the new forms were previously invalid, vectors prove it). The external spec-repo PR is a separate governance step.
  • Slugless rungs keep minting bare values, and bare values only; a typed raw value (human:Q42) cannot mint through a rung that declares no slug. The classifications package has 13 generated ladders with slugless rungs; refusing them now would silently drop a rung from each. Flips with the classifications follow-on.
  • Typing is per value, not per scheme, so existing scheme-level reads in registry, classifications and primitives keep working until their own PRs.
  • The train's ratified whitespace trim is kept for every wd form; the reference's stricter ASCII-only trim would change canonicalization of existing inputs, which the freeze rule forbids.

Surfaced, pre-existing, not changed here

Weak account handles (int:acct:x:@jack): the ratified spec says both forms are anchor-eligible; the reference floors the weak form. Outside typed-wd; to be reconciled when the app swaps to this package.

Evidence

  • iid-spec: 163 vectors. iid: 263 tests, typecheck, check, build. Consumers against the rebuilt dist: iid-registry 42, iid-ladder 12, classifications 38, primitives 140. Pack dry run.
  • Independent review: round 1 found three real issues (a trim regression, typed values minting through slugless rungs, a mutable bindings table), all fixed; combined re-review found no new defect.

Review notes

CI shows the base branch's expired supply-chain exception until the CI-fix child PR merges; this branch is rebased after that. Merge before the iid-ladder PR.

Update 2026-10-03: this week's reference changes folded in

The reference moved to develop (the feature branch was consolidated into main on 9/24). Per the maintainers' call, this week's iid changes (through develop @ 83a003bc1) are folded into this PR as a second commit rather than a follow-up.

  • Music identity policy (MUSIC_IDENTITY_RUNG_POLICY, isPlainWdPrimaryAllowed): verbatim data and predicate. Nothing in iid mints on them; the ladder PR consumes them for policy-gated plain-QID primaries (see feat(iid-ladder): typed-wd ladder policy, category rungs, rung aliases and pinned P31 closure (P16b) #29).
  • normalizePodcastFeedUrl: folds scheme and host case, strips the scheme and trailing slashes, preserves userinfo, port, path and query bytes. derivePodcastGuid is unchanged.
  • ISNI URL form: the canonicalizer also accepts https://isni.org/isni/<id> (with or without www., host case-insensitive), stripping it to the bare form before the existing canonicalization. Every existing canonical output is byte-identical. Recorded in the spec's ISNI scheme doc as an additive value-grammar extension under §9.3.1, with four additive conformance vectors. For ratification in this review.
  • Typed-wd itself is unchanged by this commit: SCHEME_TYPING, the bindings table, parse.ts and derive.ts have no diff.
  • Gates after the refresh: spec corpus 167 vectors; iid 270 tests, typecheck, check, build; iid-ladder 12, iid-registry 42, classifications 38, primitives 140 against the rebuilt dist; pack dry run. Independent conformance and adversarial review on the refresh commit: round 1 found one wording gap (the spec note said scheme and host are case-insensitive; the ported regex folds the whole prefix including the /isni/ path, as the reference does), fixed by aligning the note, adding a vector and a test; round 2 clean on both gates.

…c amendment and reference implementation (P16)

Ports intuition-v2's typed-wd identity onto the release train as one unit,
because the iid conformance test executes the iid-spec vectors.

iid-spec
- schemes/wd.md: value grammar `^(?:<slug>:)?Q[1-9]\d*$`, ordered
  canonicalization for typed forms, value-typed scheme typing (bare
  polymorphic; typed with an active EntitySchema binding unambiguous and
  P0-eligible; dormant binding valid but not mintable), the closed
  binding table with pinned revisions, typed vectors, ladder-rung note
- spec/07 §7.3: value-typed schemes defined; wd rows split bare/typed
- spec/09 §9.3.1: additive value-grammar extensions (in-place MINOR
  ratification under four conditions); wd is the first instance
- conformance: value-typed corpus support (`valueTyped` on scheme
  entries, optional per-vector `typing`, validator effective-typing
  guards); 18 new wd vectors; all 145 base vectors unchanged apart from
  one note; scheme typing entries unchanged
- README / schemes README updated

iid
- wd-entityschema-bindings.ts: the 11 pinned bindings (film,
  television-series, human active), deep-frozen table/rows/anchorQids,
  frozen slug list, membership guards
- schemes.ts: typed-aware wd canonicalizer (URL forms never infer a slug,
  ASCII slug lowercased and must be registered, QID uppercased); the
  ratified whitespace trim is kept for every form; SCHEME_TYPING.wd stays
  polymorphic
- types.ts: `wdSlug` on the declarative scheme rung, `dormant-wd-binding`
  ineligibility reason, `wdSlug` on the valid inspection branch
- parse.ts: per-value inspection for typed wd (active → unambiguous and
  eligible; dormant → ineligible)
- derive.ts: typed derivation on the declarative engine (active slug
  only, same-slug check, bare-prefixing, length bound); slugless wd rungs
  keep minting bare values and bare values only
- index.ts exports; README section; tests re-expressed against
  declarative ladders, fence test replaced by a positive export test

Ruled: R1 (typed-wd canonical for the packages). Default-in-effect,
pending ratification: R17 (§9.3.1), D-P16-1..5. No version or
dependency changes; the version freeze is a separate commit.

Gates: iid-spec 163 vectors; iid 263 tests, typecheck, check, build;
iid-registry 42, iid-ladder 12, classifications 38, primitives 140
against the rebuilt dist; pack dry run. Review: round 1 pair found three
real issues (trim regression, typed values minting through slugless
rungs, mutable bindings table), fixed; round-2 combined re-review found
no new defect.
…003bc1 — music identity policy, podcast feed-URL normalization, ISNI URL form (P16 refresh)

Second commit on the typed-wd PR: this week's reference changes, folded
into the open PR per JP (10/3) instead of a follow-up.

iid
- music-identity-policy.ts (new, verbatim): MUSIC_IDENTITY_RUNG_POLICY
  (artist → MusicGroup: isni, mbid:artist, wd, spotify:artist;
  music-album → MusicAlbum: mbid:release-group, wd, spotify:album) and
  isPlainWdPrimaryAllowed(schemaType). The iid-ladder refresh consumes
  it for policy-gated plain-QID primaries (R23).
- uuid5.ts: normalizePodcastFeedUrl (folds scheme/host case, strips the
  scheme and trailing slashes, preserves userinfo, port, path and query
  bytes). derivePodcastGuid unchanged.
- schemes.ts: the ISNI canonicalizer also accepts the
  https://isni.org/isni/<id> URL form (with or without www., host
  case-insensitive), stripping it to the bare form before the existing
  canonicalization. Every existing canonical output is byte-identical.
- index.ts exports; README section; two new tests (feed normalization
  preserves bytes; isni.org evidence canonicalizes, wrong hosts and
  checksums rejected).

iid-spec (R24)
- schemes/isni.md: accepted input forms note; the URL form is an
  additive value-grammar extension under §9.3.1 (previously invalid
  input becomes valid, canonical bytes unchanged), provenance
  intuition-v2 develop @ 83a003bc1.
- conformance: four additive ISNI vectors (canonicalization,
  validation); no existing vector changed. Corpus: 167 vectors.

Typed-wd itself is unchanged: SCHEME_TYPING, the bindings table,
parse.ts and derive.ts are untouched. No version or dependency changes.

Gates: iid-spec corpus 167 vectors OK; iid 270 tests, typecheck, check,
build; iid-ladder 12, iid-registry 42, classifications 38, primitives
140 against the rebuilt dist; pack dry run.
…ely as a whole, including the /isni/ path (P16 refresh review)

The adversarial review of the refresh found the spec note narrower than
the ported canonicalizer: the regex's case-insensitive flag folds the
whole prefix, so `https://isni.org/ISNI/<id>` is accepted, exactly as the
reference implementation accepts it. No behavior change on the train;
the scheme doc now states the whole-prefix fold, the corpus gains a
vector for the upper-case path form (168 vectors), and the schemes test
asserts it (iid 271 tests).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant