Fix Matins reading-pool ordering when Nocturn 2/3 come from different sources

buildReadingPool concatenated readings in id-processing order, so a later
post-Pentecost Sunday's Nocturn 3 (from its own temporalId file) could land
ahead of its Nocturn 2 (from the newly-added month-week id) in the pool,
flipping which nocturn slot each landed in. Group by each reading's own
nocturn tag instead, ascending, preserving id/file order within each group.

Also logs three follow-up items to TODO.md: displaying "Te decet laus",
the missing responsory marker convention in nocturn-readings content, and
removing Ps 129/50 from the Lauds/Vespers ferial Preces.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWzE3kaSZCs79fPBrrE1aF
This commit is contained in:
2026-08-23 08:02:16 -04:00
parent 72a0f8072e
commit ca28f2ef5f
2 changed files with 70 additions and 2 deletions
+19 -2
View File
@@ -394,11 +394,28 @@ function buildReadingPool(day: LiturgicalDay, temporalId: string, date: string):
responsory: r.responsory ? { text: r.responsory, status: { la: 'verified', en: 'verified' } } : undefined,
});
}
for (const id of nocturnReadingIds(day, temporalId, date)) {
// Grouped by the reading's own `nocturn` tag (ascending), not by which id
// contributed it — a later post-Pentecost Sunday's Nocturn 2 now comes
// from a different source (the month-week id) than its Nocturn 3 (its own
// temporalId file), and pooling in plain id order would put that Nocturn
// 3 content ahead of the Nocturn 2 content supplied by a later-processed
// id. Within each nocturn-number group, id order (and each file's own
// reading order) is preserved, matching this pool's usual priority rule.
// Not hardcoded to [2, 3]: Ember days' own nocturn-readings files use
// `nocturn: 1` (their single-nocturn structure), so every tag present
// must be handled, not just the usual Sunday/feast pair.
const ids = nocturnReadingIds(day, temporalId, date);
const byNocturn = new Map<number, ResolvedPart[]>();
for (const id of ids) {
for (const reading of getNocturnReadings(id)) {
parts.push(nocturnReadingPart(reading));
const bucket = byNocturn.get(reading.nocturn) ?? [];
bucket.push(nocturnReadingPart(reading));
byNocturn.set(reading.nocturn, bucket);
}
}
for (const nocturnNumber of [...byNocturn.keys()].sort((a, b) => a - b)) {
parts.push(...byNocturn.get(nocturnNumber)!);
}
for (const octave of activeOctavesFor(date)) {
const reading = getOctaveReading(octave.id, octave.dayNumber);
if (reading) {