Skip to content

feat(licenses): per-book licenses from Sefaria versions.json - #106

Merged
kdroidFilter merged 1 commit into
masterfrom
feat/book-licenses
Oct 8, 2026
Merged

kdroidFilter merged 1 commit into
masterfrom
feat/book-licenses

Conversation

@kdroidFilter

Copy link
Copy Markdown
Owner

What

  • Schema: license (get-or-create on code, nullable permission flags), edition (versionTitle + source URL), book_edition (per-book license + licenseInferred), and the book_license_v view, the single place to read a book's licenses.
  • generator/common: Licenses (canonical codes + permissions), upsertLicense / upsertEdition bindings, LICENSE / EDITION id tables; new tables added to the patch tables and the logical content hash.
  • Sefaria importer: merged.json versions joined with versions.json from the SefariaExport release (feat: export versions.json with Hebrew version licenses SefariaExport#6). An unknown version inherits its edition's license when all known versions of that edition agree (licenseInferred = 1); otherwise it stays unknown. All versions are resolved before inserting; a missing one fails the build.

Non-Sefaria books get no row yet (= unknown).

Verification

  • ./gradlew :generator-common:jvmTest :sefariasqlite:jvmTest :delta-updater:jvmTest :dao:jvmTest
  • 3-book fixture from the 2026-10-08 export with the production build state: book/line ids identical to production (חולין = 132, line 102062); חולין gets CC-BY-NC inferred, משנה ברורה Public Domain + unknown.
  • On the full export (Python dry run of the same rules): 731 → 570 books with an unknown version.

Notes

  • Requires a Sefaria export with versions.json (release 2026-10-08 or later); the local build/sefaria/export cache must be refreshed.
  • Schema change: full DB regeneration.

🤖 Generated with Claude Code

Add license / edition / book_edition tables and the book_license_v view.
Licenses are get-or-create (Licenses.canonicalCode folds PD/Public Domain
and blank/unknown); permission flags are known for the CC/PD family only.

The Sefaria importer reads each book's merged versions from merged.json
and resolves their license from versions.json (SefariaExport >= 2026-10-08).
An unknown version inherits the license of its edition when all the
edition's known versions agree, flagged as inferred; otherwise unknown.
Every version is resolved before any insert, failing on a missing one.

License and edition ids go through the IdAllocator, and the new tables
are tracked by the patch producer and the logical content hash.

Signed-off-by: Elie Gambache <elyahou.hadass@gmail.com>
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