Skip to content

Fix token glosses shifted past ketiv/qere, and audit re-imports - #19

Open
wirelessdreamer wants to merge 2 commits into
mainfrom
claude/exciting-faraday-aa0870
Open

wirelessdreamer wants to merge 2 commits into
mainfrom
claude/exciting-faraday-aa0870

Conversation

@wirelessdreamer

Copy link
Copy Markdown
Owner

Summary

In verses with a ketiv/qere, every token after the ketiv carried the gloss of the word before it. In Ps 24:6, for example, Selah was glossed "O Jacob" and the glosses before it were shifted. Codex prompts list these glosses next to each token, so drafts were misled.

Cause. full_psalm_import_service joined OSHB tokens to MACULA by word position. OSHB has the ketiv as a word and keeps the qere in a <note>. MACULA follows WLC numbering: it leaves the ketiv's number empty and gives each qere word its own number. So after a ketiv, the OSHB position was one (or two) behind MACULA. Strong and morph come from OSHB, so they stayed correct while gloss, lemma, transliteration and Greek shifted.

Changes

  • OSHB tokens now carry a qere-aware macula_word_number for the join. token_id and ref keep the OSHB position, so token IDs, alignments and the MT source snapshot are unchanged.
  • A ketiv token now reads as its qere: it gets the merged MACULA enrichment of the qere word(s). Ps 24:6 t003 is "of those who seek him", and the two-word qeres at 10:10 and 55:16 are merged. Strong and morph still come from the OSHB ketiv.
  • import_vendored_psalms now writes one AuditRecord (change_type: "import", created_by: "import-psalms") for each existing unit it changes. Before this, re-imports, including the one on daemon restart, wrote no audit trail.
  • The content was regenerated with python scripts/import_psalms.py on this branch (second commit).

Units changed

2,235 units in total, each with one import audit record.

  • 65 units have corrected token enrichment: the 56 where glosses were shifted, plus verses where only the ketiv token gained its qere gloss.
  • The other ~2,170 units only refresh occurrence_index and *_occurrence_refs, which moved with the corrected lemmas.

Re-importing without the fix produces 0 diffs, so every change here comes from this fix.

65 units with corrected enrichment

ps005.v009.a, ps006.v004.a, ps009.v013.a, ps009.v019.a, ps010.v005.a, ps010.v010.a, ps010.v012.a, ps011.v001.a, ps017.v011.a, ps017.v014.a, ps018.v051.a, ps021.v002.a, ps024.v006.a, ps026.v002.a, ps030.v004.a, ps038.v021.a, ps039.v001.a, ps041.v003.a, ps042.v009.a, ps049.v015.a, ps051.v004.a, ps054.v007.a, ps055.v016.a, ps056.v007.a, ps058.v008.a, ps059.v011.a, ps059.v016.a, ps060.v007.a, ps066.v007.a, ps071.v012.a, ps071.v020.a, ps072.v017.a, ps073.v002.a, ps073.v010.a, ps073.v016.a, ps074.v006.a, ps074.v011.a, ps077.v001.a, ps077.v012.a, ps077.v020.a, ps079.v010.a, ps085.v002.a, ps089.v018.a, ps089.v029.a, ps090.v008.a, ps092.v016.a, ps100.v003.a, ps101.v005.a, ps102.v024.a, ps105.v018.a, ps105.v028.a, ps106.v045.a, ps119.v079.a, ps119.v147.a, ps119.v161.a, ps126.v004.a, ps129.v003.a, ps139.v006.a, ps139.v016.a, ps140.v010.a, ps140.v011.a, ps140.v013.a, ps145.v006.a, ps147.v019.a, ps148.v002.a

Layer(s) changed

  • gloss
  • literal
  • phrase
  • concept
  • lyric
  • metered_lyric
  • parallelism_lyric

Only source-token enrichment changes: display_gloss, gloss_parts, lemma, transliteration, greek, word_sense and occurrence refs. No renderings are touched.

Canonical or alternate

  • Canonical change
  • Alternate addition/update

No renderings change. Proposed (not canonical) renderings exist in 5:9, 6:4, 26:2, 66:7, 77:1, 77:12 and 77:20. The proposed literal ones (26:2, 77:1, 77:12, 77:20) may have been drafted from the shifted glosses and are worth re-checking. None of the affected units have alignments.

Linked issues

None. Found while drafting a Psalm 24 song setting that must sing Selah at 24:6.

Evidence

  • Raw OSHB Ps.24.6: <w type="x-ketiv">דרש/ו</w><note type="variant">…<rdg type="x-qere"><w>דֹּרְשָׁ֑י/ו</w>. Raw MACULA has refs PSA 24:6!1, !2, !4 … !8 and no !3.
  • Corpus scan: 65 verses contain a ketiv (68 ketiv tokens); 55 had following tokens shifted. After the fix, the four remaining OSHB/MACULA Strong mismatches in those verses are lexicon disagreements (e.g. 5713 vs 5715), not misalignment.
  • Ps 24:6 now reads: this / is the generation / of those who seek him / those who seek / (of) your face / O Jacob / Selah.
  • Regression test: test_ketiv_reads_as_its_qere_and_later_words_keep_their_own_enrichment (24:6 and 10:10). It fails without the fix.

Validation checklist

  • python scripts/validate_content.py (no errors, before and after regeneration)
  • python scripts/build_indexes.py: not run. Derived and not committed; rebuild after merge so concordance search shows the corrected glosses.
  • python scripts/generate_reports.py --release-id draft
  • License audit reviewed: no source or license changes.
  • Alignment coverage reviewed: no alignments in affected units, and token IDs are unchanged.

pytest tests/unit tests/integration: 722 passed.

Reviewer checklist

  • Hebrew review complete: worth a look at the ketiv-reads-as-qere choice.
  • Alignment review complete
  • Lyric/style review complete if applicable
  • Audit trail complete
  • Canonical promotion has required human approvals: n/a, no canonical changes.

Not fixed (follow-ups)

  • UXLC source_hebrew drops ketiv/qere words entirely; 24:6 source_hebrew has no דרשו.
  • lemma takes the last MACULA component, so suffixed words show the suffix lemma (e.g. הוּא for פָנֶיךָ).

🤖 Generated with Claude Code

wirelessdreamer and others added 2 commits November 23, 2026 18:58
MACULA numbers each qere word after its ketiv and leaves the ketiv's
number empty; OSHB keeps the qere in a note. The importer joined on the
OSHB word position, so every token after a ketiv took the enrichment of
the word before it (Ps 24:6 Selah read "O Jacob"). 56 verses were hit.

Tokens now join MACULA on a qere-aware word number; token ids and refs
keep the OSHB position. A ketiv token reads as its qere word(s). The
importer now writes an AuditRecord for each existing unit it changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regenerated with scripts/import_psalms.py on 02ad560. 65 verses get
corrected token enrichment (the 56 where glosses were shifted past a
ketiv, plus ketiv tokens now read as their qere); the rest of the
2,235 units refresh occurrence indexes and refs that moved with the
corrected lemmas. Each changed unit carries one "import" AuditRecord.
validate_content.py passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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