Refactor Matins psalmody overrides to category-keyed data

Split the store into categories/*.yml (generic Common-category psalm-
number/versicle/canticle scheme) and saints/*.yml (per-saint proper
antiphon overrides, unchanged shape) per the mechanism's own flagged
next step. St. Lawrence's file moves into saints/ with a category
cross-reference; resolution behavior (per-saint lookup, ferial
fallback when unauthored) is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 06:42:48 -04:00
parent f550412c61
commit 2bac28d36c
2 changed files with 69 additions and 26 deletions
+52 -26
View File
@@ -1,29 +1,35 @@
/** Matins' own analogue of hours/lauds-psalmody-overrides.ts, but keyed
* by Common category rather than per-saint: live-verified (see
* data/hours/matins-psalmody-overrides/st-lawrence.yml's own header)
* that the psalm *numbers* for Nocturns 1-2 are shared across saints of
* the same Common category (a plain-Duplex Martyr and a plain-Duplex
* Martyr-Bishop share all but one of the same twelve psalm numbers) —
* only the antiphon text varies, proper to the individual saint when
* authored, generic Common-of-* text otherwise. Deliberately the
* opposite indexing choice from Lauds' own per-feast override (see that
* file's own doc comment) — Lauds' 5-antiphon pool is shared across
* every Duplex-majus+ feast regardless of category, so per-feast is the
* natural key there; Matins' pool varies *by* category, so per-category
* is the natural key here.
/** Matins' own analogue of hours/lauds-psalmody-overrides.ts. Two data
* stores, both keyed by id:
*
* - `data/hours/matins-psalmody-overrides/categories/*.yml` — the
* generic Common-of-* Matins psalmody (psalm numbers, versicles,
* canticle refs, and the plain Common antiphon text), one file per
* `SaintRecord.common` category. Live-verified against a saint with no
* proper antiphon of his own (so his own output *is* the category
* default) — see e.g. `categories/common-of-a-martyr.yml`'s own doc
* comment. Reference/documentation content only: not consulted by
* `getMatinsPsalmodyOverride` below, per this project's "stay on the
* ferial fallback until proper antiphon text is authored per-saint"
* decision (2026-08) — a saint without their own entry in `saints/`
* still falls all the way back to matins.ts's own plain ferial table,
* never to a category's generic antiphon text. Recorded so the next
* saint authored in an already-proven category doesn't have to
* re-derive/re-verify the same shared psalm numbers and versicles.
*
* - `data/hours/matins-psalmody-overrides/saints/*.yml` — real proper
* antiphon text for one specific saint (only authored where a saint
* genuinely has proper text of their own, confirmed against the live
* engine, not merely inherited Common text). Each carries its own
* `category` field cross-referencing the file above, but is otherwise
* fully self-contained (own psalm numbers, not merged with the
* category file at load time) — a saint's proper psalmody occasionally
* swaps one slot's psalm number from the category default too (see
* `saints/st-lawrence.yml`'s own note), so per-saint files stay
* authoritative rather than being computed as a diff.
*
* `id` is looked up against `hours/resolve-common.ts`'s
* `resolveOfficeWinner(day).id` when it's sanctoral, exactly like every
* other per-feast/per-category content lookup in this app — but the
* `id` values populated so far are individual saint ids (St. Lawrence
* proper), not Common-category ids, since only the live-verified proof
* has been authored; extending this to a real Common-category key
* (`common-of-a-martyr`, etc., matching `SaintRecord.common`) with
* per-saint antiphon overrides layered on top is the deferred bulk-
* content work (see TODO.md) — not built yet, so a saint without their
* own entry here falls back to the plain ferial weekday table
* (matins.ts's own fallback), not to some other saint's proper
* antiphons. */
* other per-feast/per-category content lookup in this app. */
export interface MatinsPsalmodyGroup {
psalms: number[];
antiphon: Partial<Record<string, string>>;
@@ -40,22 +46,42 @@ export interface MatinsPsalmodyNocturn {
versicle: { v: Partial<Record<string, string>>; r: Partial<Record<string, string>> };
}
export interface MatinsPsalmodyOverride {
id: string;
category?: string;
nocturn1: MatinsPsalmodyNocturn;
nocturn2: MatinsPsalmodyNocturn;
nocturn3: MatinsPsalmodyNocturn;
}
export interface MatinsPsalmodyCategory {
id: string;
nocturn1: MatinsPsalmodyNocturn;
nocturn2: MatinsPsalmodyNocturn;
nocturn3: MatinsPsalmodyNocturn;
}
const modules = import.meta.glob<{ default: MatinsPsalmodyOverride }>(
'../data/hours/matins-psalmody-overrides/*.yml',
const saintModules = import.meta.glob<{ default: MatinsPsalmodyOverride }>(
'../data/hours/matins-psalmody-overrides/saints/*.yml',
{ eager: true },
);
const categoryModules = import.meta.glob<{ default: MatinsPsalmodyCategory }>(
'../data/hours/matins-psalmody-overrides/categories/*.yml',
{ eager: true },
);
const overrides = new Map<string, MatinsPsalmodyOverride>();
for (const mod of Object.values(modules)) {
for (const mod of Object.values(saintModules)) {
overrides.set(mod.default.id, mod.default);
}
const categories = new Map<string, MatinsPsalmodyCategory>();
for (const mod of Object.values(categoryModules)) {
categories.set(mod.default.id, mod.default);
}
export function getMatinsPsalmodyOverride(id: string | undefined): MatinsPsalmodyOverride | undefined {
return id ? overrides.get(id) : undefined;
}
export function getMatinsPsalmodyCategory(id: string | undefined): MatinsPsalmodyCategory | undefined {
return id ? categories.get(id) : undefined;
}