Skip to content

docs(wikidata): PRD-0011 + ADR-0016/0017 — Wikidata as a first-class SP42 target#105

Merged
schiste merged 9 commits into
mainfrom
claude/wikidata
Jul 3, 2026
Merged

docs(wikidata): PRD-0011 + ADR-0016/0017 — Wikidata as a first-class SP42 target#105
schiste merged 9 commits into
mainfrom
claude/wikidata

Conversation

@tieguy

@tieguy tieguy commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Design docs (no code) establishing Wikidata as a first-class SP42 target — not
just a book-metadata source, but a patrol target and a bidirectional bridge with the
citation work. SP42 already resolves wikidatawiki/testwikidatawiki (ADR-0014)
but can't review them: a Wikidata revision is entity JSON, so the diff view renders
raw JSON and every wikitext signal misfires.

  • PRD-0011 — Wikidata as a first-class target: the shared read module + a
    patrol-read MVP, with the use-case family (book/entity enrichment, citation→Wikidata
    facts, Wikidata→sources) sequenced as follow-ons. Six design decisions resolved
    in-doc.
  • ADR-0016 (platform) — Wikidata entity content-model: per-revision content_model
    (routing keys on the revision, never the wiki id), entity revision read, a new
    EntityDiff (full statement depth, never-a-no-op), ContentDiff routing, and
    content-model capability gating.
  • ADR-0017 (platform) — Wikidata statement-proposal write contract: reuses
    ADR-0010 propose/confirm with an entity+lastrevid locator and a grounded,
    referenced statement payload; respects the FRBR work/edition split.
  • Design plan 2026-07-01-wikidata-read-model.md — the shared platform Wikidata
    read model and a line-by-line convergence mapping from PR Citation verification over MCP — read-only agent surface (MVP) #103's wikidata.rs.

New docs/domains/wikidata/ domain, indexed in docs/README.md and
docs/domains/README.md.

Type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Build, CI, or release
  • Security-sensitive change

Validation Required

Docs-only change (Markdown under docs/); no source, build, or test surface touched.

# nothing to run — no code changed

Risk

  • Touches auth/session/cookies/CSRF
  • Touches deployment/runtime configuration
  • Touches desktop packaging
  • Touches scoring or Wikimedia action behavior
  • Needs an ADR

Two ADRs are included here (ADR-0016, ADR-0017), both Proposed. No further ADR is
required to merge these drafts.

Notes For Reviewers

Coordination dependency — PR #103 (PRD-0010, MCP surface). #103 ships the first
Wikidata read in the codebase (verify_wikidata_statement, sp42-mcp/src/wikidata.rs)
but in the sp42-mcp shell. Per the reuse-by-design rule, ADR-0016 promotes that
entity/statement parser into platform
so patrol, the MCP verb, and the write lane
share one read model. The design plan gives the line-by-line mapping; #103's own design
plan already anticipated a platform home for the renderer, so this is convergence, not
conflict. Whichever of #103 / this lands first, the other consumes or refactors onto
the shared module — #103's public verb contract (PRD-0010) is unchanged either way.

ADR-0017 is the exact inverse of #103's verb (propose a referenced statement vs. verify
an existing one).

Numbering. #99 holds ADR-0015 (fetch edge), so these took the next free global
numbers, 0016/0017. PRD is 0011 (0010 is #103's).

Ecosystem due-diligence (baked into the docs). OL and Wikidata already sync (P648;
OL's official Wikidata Integration; cdrini/openlibrary-wikidata-bot). SP42 does not
rebuild identifier sync — its value is the grounded/referenced-statement layer, which
answers the standing WikiProject complaint that most bots add unsourced statements. And
ADR-0017 respects the FRBR work/edition split (ISBN/publisher on the edition item,
sourced there; decline rather than create a missing edition — avoiding the ~40k
mis-placed-edition-ID class of bulk-import error). A follow-up note tracks mirroring the
de-dup point into PRD-0009 (PR #104).

Most worth scrutiny: ADR-0016 Decision 5 (content-model capability gating as a new
axis on the profile) and the PRD's resolved Q1 (hybrid/defer on domain placement — no
new crate for the MVP). Everything is Draft/Proposed; this PR exists to get the
design reviewed before code.

🤖 Generated with Claude Code


Generated by Claude Code

claude added 7 commits July 1, 2026 18:03
Establishes Wikidata as a patrol target and a referenced source/sink of facts
for the citation work. Splits the design along the reuse-by-design rule: a
shared platform entity read mechanism (revision read + EntityDiff +
content-model routing/gating, spawned as ADR-0015) versus thin Wikidata-native
workflows. MVP is the patrol read experience (entity diff render, scoring gated
off, testwikidatawiki) with the use-case family — book/entity enrichment,
citation→Wikidata facts, Wikidata→sources — sequenced as follow-ons. Continues
ADR-0014. Adds the wikidata domain README and indexes it in docs/README and
docs/domains/README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
Fold in the six design-review decisions and convert Open questions to Resolved:
Q1 hybrid/defer (read mechanism -> platform, patrol-Wikidata -> patrolling, no
new crate; write-lane home deferred); Q2 read production wikidatawiki, gate
writes to testwikidatawiki; Q3 chronological over a bot-filtered stream
(rcshow=!bot); Q4 full statement depth (property/value/qualifiers/rank/
references) with the never-a-no-op invariant; Q5 citation->facts first; Q6
ADR-0015 read now + a separate ADR-0016 write contract. Updates the header,
Proposal, DoD, and the domain README to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
…tement-write contract)

Draft both ADRs PRD-0011 spawns, up front, so the PRD's forward references are
concrete before review.

ADR-0015 (read mechanism, platform): content_model as an additive per-revision
fact (default wikitext) with routing keyed on the revision — never the wiki id,
since wikidata.org has wikitext pages and Wikipedias have JSON; entity revision
read via the Action API prop=revisions; a new EntityDiff sibling to
StructuredDiff diffing statements at full depth (property/value/qualifiers/rank/
references) with a never-a-no-op invariant; a ContentDiff sum for routing;
feature gating by content model as a separate axis from the OAuth-derived
capability profile; bot filtering reuses the existing rcshow=!bot flag; scoring
skipped, not faked.

ADR-0016 (write contract, platform): reuses ADR-0010 propose/confirm, swapping
the wikitext node locator for entity id + lastrevid drift and the payload for a
grounded, referenced statement; structured triples gated by ADR-0007; sibling
apply route; per-operator Wikidata auth; testwikidatawiki write gate.

Reconciles the PRD-0011 and wikidata README ADR references and indexes
ADR-0013..0016 in the platform README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
…#99)

PR #99 already claims ADR-0015 (references/adr, rules-compliant fetch edge).
ADR numbering is global, so the Wikidata entity-read and statement-write ADRs
move to the next free numbers: read -> ADR-0016, write -> ADR-0017. Renames the
two files and updates every cross-reference in PRD-0011, the wikidata README,
and the platform README index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
…P surface)

Cross-check against PR #103's verify_wikidata_statement, which is the first
Wikidata read in the codebase (Special:EntityData + statement/P854 parser) but
lives in the sp42-mcp shell. Reconcile:

- ADR-0016 Decision 2: adopt and PROMOTE #103's entity/statement parser out of
  sp42-mcp into platform so the MCP verb, patrol entity diff, and the write lane
  share one Wikidata read model; endpoint (Action API prop=revisions vs
  Special:EntityData?revision=) is an impl detail on shared, endpoint-agnostic
  parsing. Add a Relation-to-#103 note and coordination point.
- ADR-0017: record that #103's verb is the exact inverse of the statement-write
  contract (verify existing reference vs propose new referenced statement); same
  statement + P854 model and ADR-0007 grounding, two ends of one loop.
- PRD-0011: Wikidata->sources reuses #103's statement/reference read (note the
  external Wikimedia-DE Wikidata MCP as an alternative read source); citation->
  facts noted as ADR-0017-governed and #103's inverse.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
…#103

Add a pre-implementation design-plan sketch of the typed Wikidata read model
(Entity/Statement/Snak/WikibaseValue/Reference, endpoint-agnostic parse, label
resolution, statement rendering, EntityDiff/ContentDiff, StatementRef and the
ADR-0017 StatementProposal) that lives in platform (sp42-platform::wikibase)
rather than the sp42-mcp shell. Includes a line-by-line mapping from PR #103's
current wikidata.rs onto the shared API (get_json/parse_statement/render_value/
extract_ref_url/label_of -> the typed model), the additive delta patrol and the
write lane need, and four open points to settle with #103 (ContentDiff home,
diff fetch endpoint, merge order, renderer fidelity). Link it from ADR-0016.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
…nd PRD-0011

Research check on existing Open Library <-> Wikidata data sharing surfaced two
things worth encoding before review:

- Existing sync (do not duplicate): P648 links OL<->Wikidata; OL runs an
  official Wikidata Integration (author bios/photos/awards in, OL IDs out) plus
  cdrini/openlibrary-wikidata-bot for identifier sync. SP42's distinct value is
  the grounded/referenced-statement layer, answering the standing WikiProject
  complaint that most bots add unsourced statements. Recorded in ADR-0017
  Relation + a PRD-0011 risk (with a follow-up to mirror it into PRD-0009).
- FRBR work/edition split (real modeling constraint): ISBN/publisher/pagination
  belong on the edition item and are sourced there, not the work; a past bulk
  import mis-placed ~40k edition IDs on non-edition items. ADR-0017 Decision 8
  now targets the edition a citation identifies and declines when no edition
  item exists rather than creating one; PRD-0011 risk records it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
@tieguy tieguy requested a review from schiste as a code owner July 1, 2026 20:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99f14c6960

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread docs/domains/wikidata/prd/0011-wikidata-first-class-target.md Outdated
…review)

Codex review correctly flagged that an action binds to the (wiki, rev_id) of
the change — the workbench copies the event's wiki_id into the action request
and the server acts on exactly that wiki — so "read production wikidatawiki,
write to testwikidatawiki" is impossible as worded: a production revision does
not exist on the test wiki, and patrol/rollback cannot be redirected cross-wiki.

Reword Q2 (MVP proposal, DoD, Resolved) to the coherent form that preserves the
intent: production wikidatawiki is review-only (real change volume validates the
entity diff at zero write risk); the patrol/rollback action loop runs on
testwikidatawiki in place (a test change reviewed and acted on there) as the live
write gate; production actions stay disabled until proven. This matches the
shipped Wikipedia posture (production reviewed, edit/action gate on testwiki).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012u5MVp3vAN44KhsVg3vroY
tieguy added a commit that referenced this pull request Jul 2, 2026
PRD-0011 is claimed by the Wikidata target PRD (#105) and ADR-0015 by the
fetch-edge ADR already on main; the citation-insertion draft this PRD
depends on becomes PRD-0012.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@schiste schiste merged commit d1d6f56 into main Jul 3, 2026
4 checks passed
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.

3 participants