openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Bot Account Application: pillarsdotnetBot339

Open pillarsdotnet opened this issue 4 months ago • 10 comments

Bot Account Application Request

Account Name: pillarsdotnetBot339 — rename to pillarsdotnetBot requested below GitHub Username: pillarsdotnet Purpose: Fill empty physical-description fields on editions I own a copy of, from the copy in hand, one human-approved edit at a time.

Request

  • Please grant bot privileges to the pillarsdotnetBot339 account
  • Please add it to the "API" usergroup
  • If possible, please rename it to pillarsdotnetBot (see below) — the bot convention is that the username ends in Bot, and mine currently ends in 339

About the name

My first registration used an email address that turned out to be undeliverable ([email protected] — hyphens are not valid in Gmail usernames, so it bounced and I never got the confirmation). That dead registration still claimed the pillarsdotnetBot screenname on the archive.org side. When I registered again with a working address, the screenname collided and append_random_suffix() gave me pillarsdotnetBot339.

So the name I want is held by an unverified account of my own that can never be confirmed. I have since changed the archive.org screen name to pillarsdotnetBot, but that is only the display name — the account identifier is unchanged, and my Open Library profile is still /people/pillarsdotnetbot339.

If someone can release the orphaned name and rename this account, the bot ends in Bot as the convention intends. If that is more trouble than it is worth, I am happy to keep pillarsdotnetbot339 — I would just rather Recent Changes be able to filter it as a bot.

To be clear about why I am asking, since this is not a bulk import: I am not requesting /api/import access and this bot creates no records. I need /usergroup/api because can_write() gates every API PUT, so even a single human-reviewed field edit returns 403 without it. If there is a lighter-weight way to grant that, I would prefer it.

Superseded in part — see the amendment at the end of this issue. I have since asked to add /api/import as well, for books Open Library has no edition of. The paragraph above stands as originally filed; the amendment says what changed and why.

Why this matters

Open Library is where my home-library app gets its metadata, and it is very good at bibliographic data and thin on physical description — how tall the book is, how it is bound, how many pages it actually has. Those are exactly the things you can only know by holding the book, and I am holding several hundred of them. This is an attempt to pay back what I take on every ISBN lookup.

What is queued right now

Rather than describe this in the abstract: the queue has been running against live Open Library records with the write disabled, which is a shadow window by another name. As of filing it holds 47 proposals across 19 books — every one computed from a real record, none sent:

Field Record Queued
physical_dimensions edition 18
physical_format edition 13
number_of_pages edition 6
series: subject tag work 5
cover image edition 5

Two of each, verbatim, as they would be sent:

Book Edition / Work Field Value to add
Artemis OL28218453M physical_dimensions 20.2 x 13.2 x 2.2 centimeters
Divine Rivals OL38122429M physical_dimensions 24.1 x 16.2 x 3.1 centimeters
Alchemy's Daughter OL34834798M physical_format paperback
Divine Rivals OL38122429M physical_format hardback
Alchemy's Daughter OL34834798M number_of_pages 264
How to Become the Dark Lord… OL50710754M number_of_pages 419
Enchanted OL17838987W series series:Woodcutter Sisters
Hero OL19969990W series series:Woodcutter Sisters
Alchemy's Daughter OL34834798M cover my photograph of the copy
Enchanted OL28492402M cover my photograph of the copy

Note the series rows point at works (OL…W) and everything else at editions (OL…M), per the contributors' FAQ on series tags. Happy to post the full list of 47 if that is more useful than a sample.

Scope

Five fields, and only ever when Open Library has nothing there:

Field Record Source
physical_dimensions edition measured to the nearest mm, sent in cm
physical_format edition the binding of the copy in hand (hardback / paperback only)
number_of_pages edition see convention below
series:<name> subject tag work per the contributors' FAQ on series tags
cover image edition my own photograph of the copy

Guardrails (per edit)

  1. GET the edition (and the work, for a series tag).
  2. Propose only fields that are absent — a blank, a zero, an empty array, or a missing key. A value already present is never touched, even where mine differs. A disagreement is not a correction.
  3. The proposal goes into a review queue and waits for me to look at it.
  4. On approval, re-read the live record and abort if the blank has been filled since it was queued.
  5. PUT the record back whole, with a factual edit comment.
  • Never overwrites, never deletes, never reorders. The series tag is appended to subjects; existing subjects are preserved untouched.
  • No creation of works, editions or authors; no merges; no author edits.
  • Digital formats are never sent as a binding — an ebook is not a binding.
  • Partial dimensions are never sent: all three of height/width/thickness, or nothing.

Page count convention

This is the field where "missing" and "different" get confused, so it is stated in the edit comment every time: the highest explicitly numbered page, disregarding unnumbered pages. And because editions honestly differ on what counts, a page count Open Library already holds is left alone even when mine disagrees.

Series position, and why none is sent

The sanctioned series:Name tag has nowhere to put a position, which suits me, because position is contested in the same way page count is — and I would rather not import my opinion into your catalogue.

Take Travis Baldree's Legends & Lattes books. I shelve them in in-story chronological order:

  1. Bookshops & Bonedust
  2. Legends & Lattes
  3. Brigands & Breadknives

Plenty of sources order them by publication instead, which swaps the first two. And Open Library currently holds a third answer — the edition record for Bookshops & Bonedust carries series: ["Legends & Lattes, #0"], numbering the prequel zero, while Legends & Lattes itself carries a bare ["Legends & Lattes"].

Three defensible orderings, none of them wrong. My reading order is a shelving preference, not a fact about the book, so it stays on my shelf: the tag names the series and stops there. (My own lookup code takes a position from Open Library when an edition offers one, but never sends one back — and it reads #0 as "no position" rather than as book zero.)

Edit comments

Verbatim, from the source:

Add physical dimensions measured from the book. Add the binding, taken from the copy in hand. Add a page count: the highest explicitly numbered page, disregarding unnumbered pages. Add a series tag for this work. Add a cover photograph of this edition.

Volume

Human-paced, because a human approves each one. Realistically a handful of edits in a sitting, as I work through a shelf — not a batch job, and it has no unattended mode. I am happy to accept an explicit rate cap as a condition.

Not an LLM editing Open Library

The values come from the book and from my own database, not from a model. There is no generation step anywhere in the write path.

Code

This is a feature of a self-hosted home-library app rather than a standalone script, which I realise is different from most applications here. The relevant module is one file with no dependencies — openlibrary.js — covering gap detection, the never-overwrite rule and the send path, with tests in test/openlibrary.test.mjs. If you would rather review it as a PR against openlibrary-bots, say so and I will extract it into a standalone script there.

Dry run against a live record (OL34834798M, whose physical_dimensions is empty), one edit, nothing else:

POST /account/login.json      -> 200, session cookie received
GET  /books/OL34834798M.json  -> 200
PUT  /books/OL34834798M.json  -> 403 Forbidden
                                 "Permission Denied."

The record is unchanged by the attempt — still revision 2, last_modified 2023-01-15, physical_dimensions still null. The 403 is can_write() doing its job, which is exactly what this request is about: the account is not in /usergroup/api (checked against the public /usergroup/api.json), so every API PUT is refused regardless of how small or how well reviewed.

Operator contact

  • GitHub: @pillarsdotnet
  • Open Library account: pillarsdotnetBot

Happy to narrow the scope, drop any field you would rather not receive this way, or keep the queue in its current write-disabled state for as long as you would like to watch what it proposes.

@mekarpeles @hornc


Amendment (2026-07-21): I would also like to import books Open Library does not have

I am flagging a change to my own request rather than quietly widening it later. The original text above says I am not requesting /api/import access and that this bot creates no records. Having looked at my shelf against yours, I would like to ask for that too — and I would rather raise it now, while nothing has been granted, than come back for it after approval.

If you would prefer to keep this application to the field-filling scope and handle imports as a separate request later, say so and I will withdraw this part without argument.

Why

A sample of 60 of my books with ISBNs: 14 have no Open Library edition at all — a little under a quarter. There is nothing to contribute to on those, however good the data. The gap is not random; it is mostly recent technical publishing:

0997671106     The ABCs of RPGs
9781593278939  Absolute FreeBSD, 3rd Edition
9781593275235  Absolute OpenBSD
9781098199173  AI and ML for Coders in PyTorch
9780760376355  The Anime Chef Cookbook
9781593279936  Automate the Boring Stuff with Python
9781718502659  The Book of Kubernetes
9781593276218  The Book of PF

These are all books I own, so what I would be adding is first-hand: the record comes off the copyright page and the physical copy, not from a scrape.

How it would work

Same review queue, same one-at-a-time human approval as everything else, plus a rehearsal step:

  1. GET /isbn/{isbn}.json — proceed only on a 404. If Open Library has the edition, this is a field-filling case, not an import.
  2. Build the record. Complete where the book allows (title, authors, publishers, publish_date), otherwise title plus a strong identifier, per import_validator. Physical description is included when known: number_of_pages, physical_format, physical_dimensions.
  3. POST /api/import?preview=true — the rehearsal. Your own matching runs and nothing is saved.
  4. If the preview reports edition.status == "matched", stop: the book already exists under another identifier and the queue records which record it matched. Only a preview that would genuinely create something goes on to
  5. POST /api/import for real, one book, on my explicit approval.

Deduplication is decided by your matcher, not by my code. A duplicate that a librarian then has to merge is the failure mode I am most trying to avoid, since I could not clean it up myself.

The feature is switched off in the code (OPENLIBRARY_ALLOW_IMPORT, unset by default) precisely because the application above says it creates nothing. It stays off until you tell me otherwise.

The question I actually need answered

What source_records prefix should I use?

import_validator requires a non-empty source_records, and the prefix identifies where a record came from. I have deliberately not invented one — making up a provenance string seems like exactly the wrong thing to put in a public catalogue. If there is an existing convention for a personal-library contributor, I will use it; otherwise I am happy to be assigned something like pillarsdotnetbot:<isbn>.

I need this from you whether or not the import scope is granted today, so it is worth asking regardless.

pillarsdotnet avatar Jul 21 '26 19:07 pillarsdotnet

Amendment (2026-07-21): I would also like to import books Open Library does not have

I am flagging a change to my own request rather than quietly widening it later. The original text above says I am not requesting /api/import access and that this bot creates no records. Having looked at my shelf against yours, I would like to ask for that too — and I would rather raise it now, while nothing has been granted, than come back for it after approval.

If you would prefer to keep this application to the field-filling scope and handle imports as a separate request later, say so and I will withdraw this part without argument.

Why

A sample of 60 of my books with ISBNs: 14 have no Open Library edition at all — a little under a quarter. There is nothing to contribute to on those, however good the data. The gap is not random; it is mostly recent technical publishing:

0997671106     The ABCs of RPGs
9781593278939  Absolute FreeBSD, 3rd Edition
9781593275235  Absolute OpenBSD
9781098199173  AI and ML for Coders in PyTorch
9780760376355  The Anime Chef Cookbook
9781593279936  Automate the Boring Stuff with Python
9781718502659  The Book of Kubernetes
9781593276218  The Book of PF

These are all books I own, so what I would be adding is first-hand: the record comes off the copyright page and the physical copy, not from a scrape.

How it would work

Same review queue, same one-at-a-time human approval as everything else, plus a rehearsal step:

  1. GET /isbn/{isbn}.json — proceed only on a 404. If Open Library has the edition, this is a field-filling case, not an import.
  2. Build the record. Complete where the book allows (title, authors, publishers, publish_date), otherwise title plus a strong identifier, per import_validator. Physical description is included when known: number_of_pages, physical_format, physical_dimensions.
  3. POST /api/import?preview=true — the rehearsal. Your own matching runs and nothing is saved.
  4. If the preview reports edition.status == "matched", stop: the book already exists under another identifier and the queue records which record it matched. Only a preview that would genuinely create something goes on to
  5. POST /api/import for real, one book, on my explicit approval.

Deduplication is decided by your matcher, not by my code. A duplicate that a librarian then has to merge is the failure mode I am most trying to avoid, since I could not clean it up myself.

The feature is switched off in the code (OPENLIBRARY_ALLOW_IMPORT, unset by default) precisely because the application above says it creates nothing. It stays off until you tell me otherwise.

The question I actually need answered

What source_records prefix should I use?

import_validator requires a non-empty source_records, and the prefix identifies where a record came from. I have deliberately not invented one — making up a provenance string seems like exactly the wrong thing to put in a public catalogue. If there is an existing convention for a personal-library contributor, I will use it; otherwise I am happy to be assigned something like pillarsdotnetbot:<isbn>.

I need this from you whether or not the import scope is granted today, so it is worth asking regardless.

pillarsdotnet avatar Jul 21 '26 19:07 pillarsdotnet

Thank you @pillarsdotnet for submitting this issue!

[!WARNING] This issue requires access to internal infrastructure, production systems, or institutional knowledge unavailable to community contributors. It can only be resolved by a maintainer or staff member.

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

  • [ ] Needs: Staff Decision — a maintainer must decide (1) whether to grant pillarsdotnetBot339 bot//usergroup/api privileges, (2) whether the account can be renamed to pillarsdotnetBot given the orphaned-name collision, (3) whether to grant the amended /api/import request, and (4) what source_records prefix to assign for personal-library imports
  • [ ] Needs: Staff / Internal — granting usergroup membership and renaming an account both require admin/internal tooling only staff can execute

Context

  • The 403 behavior described in the dry run matches can_write() exactly: a user can write only if their key is in /usergroup/api, /usergroup/admin, or has the bot flag set in the account store — https://github.com/internetarchive/openlibrary/blob/838a8e546f0f946b8a7e5e7b573e17966f8f3020/openlibrary/plugins/openlibrary/code.py#L852-L859. The bot-flag check reads web.ctx.site.store.values(type="account", name="bot", value="true") — https://github.com/internetarchive/openlibrary/blob/838a8e546f0f946b8a7e5e7b573e17966f8f3020/openlibrary/plugins/openlibrary/code.py#L840-L843.
  • import_validator.py (openlibrary/plugins/importapi/import_validator.py) requires source_records to be a non-empty list of non-empty strings but does not enforce any allowlist of prefixes — confirming the requester's read that there's no existing code-level convention to follow; the source_records prefix is genuinely a naming/policy call for a maintainer, not something answerable from the codebase.
  • Related precedent — this repo already has an established pattern for bot account applications, all under Lead: @mekarpeles + Theme: Bots:
    • #12887 — Bot Account Application: AgenticCommonsBot
    • #13136 — extend AgenticCommonsBot scope to remote_ids.wikidata backfill (carries Needs: Staff Decision)
    • #13222 — Bot account request: import Portuguese books from Biblioteca Nacional de Portugal (also import-scoped, also carries Needs: Staff Decision and Module: Import)
    • #11315 (closed) — Bot Account Application: ISBNLookupBot
    • #10644 (closed) — Application for Bot Account Privileges

Issue Assessment

Open questions

  • Should the field-filling scope (physical dimensions/format/page count/series tag/cover) and the amended import scope (/api/import) be decided together, or should the import request be split into its own issue as the author offered?
  • What source_records prefix should be assigned for this contributor's imports? (Confirmed above: no existing code enforces or suggests one — this needs a maintainer's naming decision.)
  • Is renaming pillarsdotnetBot339 → pillarsdotnetBot something staff are willing/able to do given the orphaned unverified account holding the name?

🔔 Stakeholders

@hornc — the amended request adds /api/import scope for personal-library metadata; imports and metadata are your area per the stakeholders list.


Full triage checklist
  • [x] Triage — labels applied: Theme: Bots, Module: Import, Needs: Staff / Internal, Needs: Staff Decision
  • [x] Problem / opportunity — clear: contributor wants to fill empty physical-description fields and (per amendment) import missing editions from their personal collection
  • [x] Scope — well-scoped and explicitly bounded (5 fields, never-overwrite rule, human-approved one-at-a-time), though the amendment does widen scope beyond the original title
  • [x] Justification — concrete: 47 queued proposals across 19 books, sample data on OL edition gaps (14/60 ISBNs with no edition) provided
  • [x] Success & testing criteria — a dry run against a live record (OL34834798M) is documented showing the current 403, and the mechanism matches can_write() exactly (verified above)
  • [x] Proposal & breakdown — concrete guardrails, workflow steps, and edit-comment text all specified in detail
  • [ ] If bug: environment & repro steps — n/a, this is an access request, not a bug
  • [x] Risks, concerns, open questions — privilege-grant and naming questions surfaced above; this is fundamentally a policy/access decision, not a code question
  • [x] Richy context — related bot-application precedent reviewed above; no duplicate found for this specific applicant
  • [x] References — code links to own repo (openlibrary.js, tests) and a live dry-run trace provided

[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.

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

@mekarpeles @hornc

Any chance y'all can take a look at this?

pillarsdotnet avatar Aug 04 '26 14:08 pillarsdotnet

Hi @pillarsdotnet, apologies for the delay, I've added the Bot flag to your account because I have access to do that. I'm not sure how to grant API usergroup without making the account a bot account, or whether there is a meaningful difference in permissions.

This sounds more like a user request for standard API access, and TBH I'm surprised that this is more locked down than I realised.

User supplied add-new-books via the UI do not require a source-records, which is by design. That path actually by-passes the /api/import , which has always seemed like a gap to me. The UI add-book method supports fewer fields, so API added books can be much richer.

For these hand curated imports, omitting source_records seems correct to me, and better than making one up, as there is no real expectation that there is a stable external source record to check up on later, which is the purpose of the value in the bulk import system. I get that now it is required field, and this will be blocking your imports.

@mekarpeles there doesn't seem to be a proper bot request on-boarding process, and I keep getting tagged for these. This seems more like a user request for API access, which is reasonable, but is not fully supported as yet (which is surprising).

Enforcing source_records on bulk editing bot accounts seems useful to me -- if my bot misses a source on an import, it's an error and I want to be notified. The usecase of an authorised user making edits via API seems totally reasonable too, this sounds like the intent of the API usergroup, but I'm not sure the code supports this. Correct me if I'm wrong.

hornc avatar Aug 05 '26 21:08 hornc

Is there any way you can do this using a script on your account? I'm assume the volume is fairly contained (e.g. < 500). It would be safer if to run a script locally that iterates over each record and adds data.

We do have a way (for anyone with an account) to submit a batch of items to be imported: https://openlibrary.org/import/batch/new

This is a much safer way for us to proceed because staff can review/approve records to import. With batch imports, it's more challenging to perform targeted updates (as opposed to importing things that don't exist)

mekarpeles avatar Aug 12 '26 14:08 mekarpeles

@mekarpeles — yes, and that is already what it is: a local script on my own account, one record at a time, with me approving each edit before it is sent. No hosted service, no unattended mode.

Volume looks to be inside your guess, with one honest caveat. My catalogue currently holds 675 editions, 311 of them with an ISBN — but I still have four bookshelves I have not entered yet, so that number will grow. I would expect the final figure to stay comfortably under your 500; I cannot promise it, and I would rather say that now than have it creep past a number I quoted you.

Of the 311, I have checked 19 against Open Library so far, which produced 47 proposals. I can run the full comparison and post real totals once the shelves are in.

The field-filling half looks already unblocked

I should say so rather than let it sit: @hornc set the bot flag on my account on 5 August, and that turns out to be sufficient. I re-tested today with POST /api/import?preview=true, which runs the whole path with save=False, so nothing was written to the catalogue:

POST /account/login.json        -> 200, session cookie
POST /api/import?preview=true   -> 200, preview edits returned, nothing saved

That is can_write() passing. And since api.can_write = can_write patches over infogami's own check, the same grant covers PUT /books/OL…M.json — so the 403 in my original application is stale. The bot flag alone did it; no /usergroup/api membership was needed, which may answer hornc's question about whether there is a meaningful difference between the two.

I am not sending anything yet — I would rather finish cataloguing the remaining shelves first, so that what I send is a considered pass rather than a trickle. When I do start it will be at a human pace, and every one of those 47 is "fill a field that is currently empty" — never an overwrite, and each one re-reads the live record and aborts if the blank has been filled since it was queued. Say so if you would rather I held off entirely for now.

On imports, I will take the batch route

That is plainly the safer path and staff review is the point of it. Two things worth flagging as I move over:

  1. You note that batch import is poor at targeted updates. Agreed — which is why I would like to keep the two halves separate rather than fold everything into batches: batch import for editions Open Library has no record of, and the API for filling blanks on records that already exist. The second is the bulk of what I have, and it is the half that batch import cannot express.

  2. source_records is the one thing I still cannot resolve myself. @hornc suggested omitting it for hand-curated imports, which reads right to me, but the validator refuses:

    POST /api/import?preview=true (no source_records) -> 400
    "1 validation error for CompleteBook: source_records:
       Field required [type=missing]"
    

    Batch import needs one too, so whichever route the imports take I need either a prefix assigned or the requirement relaxed. I would still rather be given one than invent one — pillarsdotnetbot:<isbn> if there is nothing better.

The rename to pillarsdotnetBot is cosmetic; happy to drop it if it is admin trouble that is not worth anyone's time.

@mekarpeles @hornc — the only thing I actually need from you now is the source_records decision: a prefix to use, or the requirement relaxed for hand-curated imports. Everything else I can either live with or work around.

pillarsdotnet avatar Aug 13 '26 02:08 pillarsdotnet

Correcting my own volume figure before it misleads the decision. I said above that this would stay "comfortably under your 500". That was wrong, and wrong by about a factor of four.

I misdescribed what is left to catalogue: it is four bookcases, of five or more shelves each — not four shelves. The whole collection is somewhere around 2000 books. The 675 editions currently in my database are roughly a third of it.

So the honest answer to your sizing question is: no, this is not contained in the sense you meant. I do not yet know how many of the 2000 carry ISBNs, nor how many of those have blanks worth filling — the 19 books I have compared against Open Library produced 47 proposals, but that is far too small a sample to extrapolate from and I would rather not hand you an invented multiplier. I will have real numbers once the shelves are entered, and I am content to report them before sending anything at all.

And it is not a fixed backlog either, which I should be equally clear about. I intend to scan library books as we borrow them — books that never join my shelves — precisely because dimensions and page count are worth recording from any copy I have in hand. So the catalogue grows past the size of the house, at whatever rate we visit the library. There is no total I can give you that stays true, only a rate. That is a fair thing to want capped, and I would rather you capped it knowing this than discovered it from Recent Changes later.

That may well change your recommendation, and I would rather hear that now than after I have started. If a few thousand candidate edits is too many to arrive one API call at a time, I am happy to:

  • accept an explicit rate cap, or
  • put the field edits through a staff-reviewed mechanism too, if one exists for updates rather than imports, or
  • send nothing until you have seen the real totals.

The guardrails do not change with the volume — still only ever filling a field that is empty, still never an overwrite, still re-reading the live record before each write. But "a handful of edits in a sitting" was written when I thought this was a few hundred books, and you should be able to hold me to a rate rather than to a total that will not hold still.

@mekarpeles @hornc

pillarsdotnet avatar Aug 13 '26 02:08 pillarsdotnet

@mekarpeles @hornc

Since I haven't received any guidance on what the source_records field should contain, I've rewritten my code to send pillarsdotnet_library: followed by the 13-digit ISBN. I'll test a few updates with this convention and let you know if it seems to work from my end.

pillarsdotnet avatar Sep 22 '26 13:09 pillarsdotnet

I've been able to submit 63 contributions, mostly page-count and physical dimensions. Notably, it does not appear possible to submit a cover image from a bot account. I'm working on redirecting those contributions so that the user may submit each one from a non-bot account.

pillarsdotnet avatar Sep 22 '26 19:09 pillarsdotnet

I've successfully redirected cover contributions to a user browser for human verification; the process is a bit circuitous but it works. 77 contributions submitted so far.

pillarsdotnet avatar Sep 22 '26 20:09 pillarsdotnet