openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Bot Account Application: extend AgenticCommonsBot scope to remote_ids.wikidata backfill

Open WendyLee07 opened this issue 4 months ago • 4 comments

Bot Account Application Request (Scope Extension)

Account Name: AgenticCommonsBot (existing account, no new account requested) GitHub Username: WendyLee07 (working as part of the Agentic Commons project) Purpose: Extend the existing AgenticCommonsBot scope to also backfill missing remote_ids.wikidata on OpenLibrary author records, using Wikidata P648 reverse claims and multi-field entity resolution as evidence.

Request

This is a scope extension for the same agenticcommonsbot account whose original application is #12887 (alternate_names). We're keeping one bot account and adding a second field-scoped write path under it.

  • Please grant / retain bot privileges on the AgenticCommonsBot account
  • Please confirm the "API" usergroup grant covers remote_ids.wikidata PUTs (same endpoint, different field)

Why this matters

Around 67% of OL author records have an empty remote_ids.wikidata. Backfilling this identity anchor also unblocks author-record deduplication — as @tfmorris pointed out during the alternate_names review, merging duplicates like the multiple Su Tong records is the higher-value task, and the Q-id is the strongest cross-source join key for that decision. Filling remote_ids.wikidata first gives the dedup effort a reliable anchor to work from.

Bot behavior (per edit)

For one author at a time:

  1. GET /authors/OL...A.json
  2. Verify remote_ids.wikidata is still empty (skip if already populated — never overwrite)
  3. GET Wikidata Special:EntityData/<Q-id>.json — re-validate the entity exists, is a Q5 human, and the evidence claims (P648 for Source A; P569/P570/P106 for Source B) are still present
  4. Append remote_ids.wikidata = "Q..." (all other identifiers untouched)
  5. PUT the updated record with a factual-citation edit comment
  6. Verify via re-fetch GET

Scope guardrails

  • Author pages only (/authors/OL...A). No work / edition / subject edits.
  • Append-only — never overwrites the remote_ids.wikidata value or touches other remote_ids entries (VIAF, ISNI, LCNAF, ...).
  • Skips authors with remote_ids.wikidata already populated (goes to human conflict review, never to the bot).
  • Skips authors with empty birth_date on OL side (identity too weak for name-only matching).
  • ≤ 8 edits/day total, well below polite-bot thresholds.

Evidence requirement

Two candidate paths, both audited upstream before the bot sees the proposal:

  • Source A (P648 reverse): Wikidata already declares wdt:P648 = OLID. The bot re-fetches the Wikidata entity and confirms the P648 claim is still present pointing at the same OLID. Reflects a link Wikidata has already committed to.
  • Source B (entity resolution): name + birth date (required) + at least one of {death date, occupation P106/P101, notable works overlap} matched against Wikidata Q5 (humans). Evidence must cite specific Wikidata field IDs (e.g. "Wikidata Q12345 P569=1928"), not paraphrases.

Ambiguous or single-field-only candidates are dropped upstream — no speculative or low-confidence writes.

Edit comment format

Pure factual citation, no slogans or project attribution.

Source A example:

Adding remote_ids.wikidata=Q778276 per Wikidata P648 cross-reference (https://www.wikidata.org/wiki/Q778276).

Source B example:

Adding remote_ids.wikidata=Q778276. Wikidata Q778276 P31=Q5 (human), P569=1963-01-23 matches OL birth_date=1963-01-23, P106=Q49757 (novelist) matches OL author bio.

Pipeline architecture

Same shape as the alternate_names pipeline in #12887:

  1. Streaming filter over the monthly OL author dump (ol_dump_authors_latest.txt.gz) — no OL crawling.
  2. Research worker gathers structured evidence and produces a proposal (found / ambiguous / not_found).
  3. Independent QA gate re-fetches Wikidata and verifies the QID exists, is Q5, and the evidence claims are still present before the bot sees the proposal.
  4. Only found proposals with high-confidence evidence reach the bot, which performs the single PUT and post-verify GET.

The bot's input is a structured proposal whose QID it re-fetches from Wikidata at PUT time. remote_ids.wikidata is an identity anchor — writing the wrong Q-id fuses two authors together — so the review bar is deliberately higher than for alternate_names.

Code

Filed at openlibrary-bots#453 — single-file Python 3 stdlib script in AgenticCommonsBot/wikidata_backfill/, with a real proposal (Liu Xiaobo → Q41617 for OL4155123A) and captured dry-run output. Login HTTP 200 and GET 200 already verified against the live bot account; PUT pending this grant.

Related: openlibrary-bots#452 (design discussion).

Operator contact

Thank you for reviewing! 🙏

@mekarpeles @hornc

WendyLee07 avatar Jul 08 '26 07:07 WendyLee07

Thank you @WendyLee07 for submitting this issue!

⚠️ Contributors, this issue will be ready to work on once:

  • [ ] Needs: Staff Decision — @mekarpeles needs to decide whether to grant/extend AgenticCommonsBot's privileges, and whether that decision should wait on the still-open original grant request below.

Context

  • The account this issue asks to extend, AgenticCommonsBot, has not yet been granted any bot privileges. Its original scope request, #12887, is still open and labeled Needs: Response — the last comment (@hornc) explicitly defers the grant decision to @mekarpeles and separately raises a concern about the bot's scope "rapidly drift[ing]" from its original proposal. This issue asks to add a second write scope before the first has been decided.
  • The implementation PR for this request, openlibrary-bots#453, and its companion design-discussion issue, openlibrary-bots#452, currently have zero maintainer comments — the code was written before any approval-in-principle was given on the design.
  • remote_ids.wikidata is not a passive display field: openlibrary/core/models.py:851-853 shows Author.wikidata() reads it and resolves it via get_wikidata_entity(), so a downstream consumer already trusts this value once set — raising the cost of a wrong write.
  • The Lead: @guyjeangilles (Bots Lead) label is marked Emeritus — there is currently no active bots-lead, so this decision has no owner besides @mekarpeles.

Issue Assessment

Open questions:

  • Should this scope-extension request be decided together with, or only after, the still-pending original grant in #12887?
  • Given @hornc's scope-drift concern on #12887, how does adding a second field-write path before the first is approved address that concern rather than reinforce it?
  • What is the destination/owner for the "human conflict review" queue when Source A/B evidence disagrees with an existing (different) OL-side remote_ids.wikidata value? The proposal defines when a record goes to conflict review but not who processes it.

Action items:

  • [ ] Confirm whether @mekarpeles wants #12887 resolved first, given this is presented as an extension of that same account/grant.
  • [ ] If evaluated in parallel, specify who owns/processes the conflict-review queue.
Full triage checklist (maintainers / Richy)
  • [x] Triage — correct labels applied (Theme: Bots, Needs: Staff Decision)
  • [x] Problem / opportunity — clear: extend an existing (ungranted) bot account to a second field
  • [ ] Scope — scope-extension request precedes resolution of the underlying account grant (#12887)
  • [x] Justification — stated (dedup anchor value), not independently verified by Richy
  • [ ] Success & testing criteria — grant criteria and review period not explicitly defined
  • [x] Proposal & breakdown — concrete, detailed bot behavior and guardrails
  • [ ] If bug: environment & repro steps — n/a, not a bug
  • [x] Risks, concerns, open questions — identity-anchor risk and conflict-review ownership surfaced above
  • [x] Richy context — #12887, openlibrary-bots#451/#452/#453, and core/models.py usage reviewed
  • [x] References — linked PRs/issues and code sample present

[!NOTE] This comment was automatically generated by Richy, via PAM, Open Library's Project AI Manager, on behalf of @mekarpeles. Richy is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

openlibrary-bot avatar Jul 08 '26 07:07 openlibrary-bot

Thanks Richy for the triage. Quick responses:

On sequencing: we'd prefer parallel review of #12887 and this. The two scopes are disjoint — alternate_names (append-only strings) vs remote_ids.wikidata (single-value identity anchor). They have different risk profiles and evidence bars; approving one shouldn't gate the other. Shared account is just because OL's usergroup grant is account-level — one edit history, one revoke path.

On scope drift: the wikidata backfill scope has been consistent since #452 — Source A and Source B were both in the original issue, the sample matches, the guardrails haven't moved. Happy to freeze the current scope as a contract if that helps.

On conflict-queue owner: [email protected]. When the bot sees a conflicting Q-id already on OL, it skips and emails that mailbox with both Q-ids + evidence. Reconciliation goes to Wikidata first; the bot never overwrites. Can add this to the PR README if useful.

WendyLee07 avatar Jul 08 '26 08:07 WendyLee07

We are both tight on human bandwidth right now and have a stream of priorities that need to land in Aug - Sept (in prep for our yearly in-person event) and we're also working on a fairly major revamp of our import system so it may take time to come to a decision and act on this; apologies and thanks in advance for your patience. Will move it forward as quickly as we can.

mekarpeles avatar Jul 29 '26 04:07 mekarpeles

Thanks @mekarpeles — understood. We'll wait patiently.

WendyLee07 avatar Jul 30 '26 03:07 WendyLee07