From f43f030a6af40e01e21f7a4baddcd712fdaccf33 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Tue, 18 Aug 2026 10:59:50 -0400 Subject: [PATCH] Fix ordinary-Sunday precedence and unify getDayLabel's commemoration rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two related fixes surfaced while chasing why St. Gregory Thaumaturgus appeared to be misdated on Nov 18: - calendar/commemorations.ts's `ordinary-sunday` case was transferring a Semiduplex (or lower) saint off the Sunday instead of commemorating it in place — an earlier, unverified guess. Live-verified against both Tridentine 1906 and Divino Afflatu 1954 (St. Gregory Thaumaturgus, St. Clement, St. Apollinaris, St. Thomas Becket, all real cases): the saint stays and is commemorated on the Sunday itself, same as Simplex, never pushed to the next open day. This is what was actually moving Gregory onto Nov 18 — not a data error. `applyChristmasOctaveSunday`'s own Dec 26-29 special case needed a matching adjustment (per its own documented intent, the displaced saint there is deliberately *not* commemorated in place, since he reappears in full on Dec 30 instead). - getDayLabel had five branches, each hand-assembling its own filter/format logic for which commemorations to show — which is why the octave phrasing, the closing-day title, and a missing Sunday commemoration turned into three separate bugs earlier instead of one. Replaced with a single shared `collectCommemorations` used by every branch. This also exposed that the sanctoral-winner branch never showed any commemorated saint at all, and every other branch only showed the *first* one (`.find()`), silently dropping real collisions — both now show every commemorated saint, matching this app's own generous-commemoration design. Co-Authored-By: Claude Sonnet 5 --- src/calendar/commemorations.ts | 20 ++- src/calendar/day-label.ts | 169 +++++++++++++--------- src/calendar/index.ts | 17 +++ tests/calendar/christ-the-king.test.ts | 7 +- tests/calendar/commemorations.test.ts | 11 +- tests/calendar/day-label.test.ts | 107 +++++++++++--- tests/calendar/january-sanctoral.test.ts | 13 +- tests/calendar/july-sanctoral.test.ts | 26 +++- tests/calendar/november-sanctoral.test.ts | 34 +++-- 9 files changed, 281 insertions(+), 123 deletions(-) diff --git a/src/calendar/commemorations.ts b/src/calendar/commemorations.ts index e2949e4..e477649 100644 --- a/src/calendar/commemorations.ts +++ b/src/calendar/commemorations.ts @@ -159,14 +159,22 @@ export function decideOccurrence( // Duplex+ wins outright; the Sunday itself is commemorated in return. return { winner: sanctoralWinner(sanctoral), commemorations: [{ kind: 'temporal', id: temporalId }] }; } - if (sanctoral.rank === 'simplex') { - // Too minor to warrant its own day, but a plain commemoration - // doesn't cheapen it the way it would a Semiduplex. + if (sanctoral.rank !== 'vigil') { + // Semiduplex or Simplex: commemorated, not transferred — live- + // verified (both Tridentine 1906 and Divino Afflatu 1954, the two + // calendar tracks this app blends): St. Gregory Thaumaturgus + // (Semiduplex) lands on the 6th Sunday after Epiphany, 2024-11-17, + // and is commemorated right there ("Commemoratio: S. Gregorii + // Thaumaturgi..."), not pushed to the next open day. Corrects an + // earlier, unverified guess that Semiduplex was "too important to + // merely commemorate" — Monastic Tridentinum 1617's own structural + // rubric *does* transfer him, but precedence here follows Divino + // Afflatu, not Monastic 1617's own (see CLAUDE.md). return { winner: temporalWinner, commemorations: [sanctoralCommemoration(sanctoral)] }; } - // Semiduplex or Vigil: no room here at all, in either direction — - // better to preserve the feast whole on another day than downgrade - // it to a bare commemoration. + // A Vigil still transfers (backward, per transferDirectionOf) — a + // distinct rule from Semiduplex/Simplex above, not verified against + // this same live case and left as-is. return { winner: temporalWinner, commemorations: [], diff --git a/src/calendar/day-label.ts b/src/calendar/day-label.ts index 43e4ff7..4ba7198 100644 --- a/src/calendar/day-label.ts +++ b/src/calendar/day-label.ts @@ -9,7 +9,7 @@ // become a configurable choice later (the same day->id indirection // philosophy already used for the sanctoral calendar), not hardcoded here // forever — just not built yet. -import type { Commemoration, FeastClass, LiturgicalDay, TemporalCategory } from './types'; +import type { FeastClass, LiturgicalDay, TemporalCategory } from './types'; import { easterSunday } from './easter'; import { adventStart, firstSundayStrictlyAfter, sundayOnOrBefore } from './temporal'; import { addDays, daysBetween, toIsoDate } from './date-math'; @@ -107,14 +107,14 @@ const ORDINAL_SEASONS: Partial> = { * octave, but nobody calls it that). Advent's own anchor (Advent I Sunday) * doesn't take this branch — it's already "the 1st Sunday of Advent" via * the ordinal path below. */ -function anchorDayName(day: LiturgicalDay): string | undefined { +function anchorDayName(day: LiturgicalDay, withRank = true): string | undefined { const config = ORDINAL_SEASONS[day.season]; if (!config || config.includeAnchorWeek) { return undefined; } const year = Number(day.date.slice(0, 4)); if (day.date === config.anchorDate(year)) { - return config.anchorRank ? `${config.anchorName} (${formatRank(config.anchorRank)})` : config.anchorName; + return withRank && config.anchorRank ? `${config.anchorName} (${formatRank(config.anchorRank)})` : config.anchorName; } return undefined; } @@ -242,43 +242,65 @@ function octaveCommemorationLabel(octave: ActiveOctave): string { return octaveCoreName(octave); } -/** Every `kind: 'octave'` commemoration on `day` other than `excludeId` — - * an octave already serving as the day's own headline (a sanctoral - * winner sharing an octave's id, or the octave `resolveActiveOctave` - * itself picked as primary below) would be redundant to list again. - * Plain names, not `octaveLabel`'s "Nth Day within the Octave of ..." - * phrasing — that fuller phrasing is reserved for an octave that's - * actually the day's own primary identity, not a secondary mention - * alongside it (same plain-name convention `commemoratedSaint` already - * uses below). Real gap this closes: a *second*, non-winning active - * octave (e.g. the Assumption's own day 3, alongside St. Lawrence's - * winning closing day) was previously dropped from the label entirely, - * regardless of which branch below actually renders the primary name. */ -function otherActiveOctaveNames(day: LiturgicalDay, excludeId: string | undefined): string[] { - return day.commemorations - .filter((c): c is Extract => c.kind === 'octave' && c.id !== excludeId) - .map((c) => c.name); -} - -/** Same commemoration-filtering as `otherActiveOctaveNames`, but rendered - * with `octaveCommemorationLabel`'s fuller "Nth Day within the Octave of X" - * phrasing rather than a plain name — the real DO title an octave day - * carries even when it *lost* outright to an occurring saint (e.g. Aug 19's - * real Divino Afflatu 1954 title is "S. Joannis Eudes Confessoris ~ Duplex" - * with the commemoration read as "Quinta die infra Octavam S. Assumptionis - * Beatæ Mariæ Virginis", not a bare "The Assumption of the Blessed Virgin - * Mary"). Only used from the sanctoral-winner branch below — the - * octave-vs-octave secondary mention (`otherActiveOctaveNames` itself, - * still used in the octave-headline branch further down) keeps its plain - * name on purpose, per that function's own doc comment. */ -function commemoratedOctaveDayLabels(day: LiturgicalDay, excludeId: string | undefined): string[] { - const active = activeOctavesFor(day.date); - return day.commemorations - .filter((c): c is Extract => c.kind === 'octave' && c.id !== excludeId) - .map((c) => { - const octave = active.find((a) => a.id === c.id); - return octave ? octaveCommemorationLabel(octave) : c.name; - }); +/** Every commemoration on `day`, resolved to display strings and grouped + * by kind — the single place that decides both "is this commemoration + * eligible to show at all here" and "how is it formatted", so every + * caller below shares the same answer instead of each hand-rolling its + * own filter/format pass (that duplication is exactly how Aug 19's octave + * phrasing, Aug 17's closing-day title, and Aug 16's missing Sunday + * commemoration ended up as three separate bugs instead of one). Callers + * still decide their own *order* — e.g. the octave-headline branch wants + * octaves before a commemorated saint, while a plain Sunday/feria wants a + * commemorated saint *before* its own temporal label — since that + * ordering reflects a real, deliberate liturgical convention per branch, + * not an accident to unify away. + * + * - `sanctoral`: every commemorated saint, plain name, no rank (multiple + * real ones can coexist — e.g. two colliding saints on the same date — + * this app's own "generous commemorations" design keeps every one of + * them, not just the first). + * - `temporal`: the day's own real Sunday/feria identity, if + * `decideOccurrence` demoted it to a commemoration (`ordinary-sunday`/ + * `privileged-feria`/`privileged-feria-minor`) — matched by id against + * `resolveTemporalId(day.date)` specifically, not "any temporal-kind + * commemoration present", so unrelated side-notes like + * `applyEpiphany6Commemoration`'s fixed `post-epiphany-6` don't get + * mistaken for it. Rendered via `anchorDayName`/`temporalLabel`, the + * same machinery a primary temporal label uses, minus the rank. + * - `octave`: every active octave other than `excludeOctaveId` (the + * octave already serving as the day's own headline, if any) — only + * when `showOctaves` is true. Live-verified this is *not* simply "is an + * octave active": on a Sunday or privileged feria a saint won outright + * against, an unrelated active octave isn't commemorated at all (Aug + * 16's St. Joachim names only the Sunday, not St. Lawrence's/the + * Assumption's octaves, even though both are technically active) — + * octaves are only shown on `ordinary-feria` (no real standing of its + * own to prefer instead) or when the octave itself is governing the + * headline. Rendered via `octaveCommemorationLabel` — the "Nth Day + * within the Octave of X" phrasing, no rank. + */ +function collectCommemorations( + day: LiturgicalDay, + opts: { showOctaves: boolean; excludeOctaveId?: string }, +): { sanctoral: string[]; temporal: string[]; octaves: string[] } { + const temporalId = resolveTemporalId(day.date); + const activeOctaves = opts.showOctaves ? activeOctavesFor(day.date) : []; + const sanctoral: string[] = []; + const temporal: string[] = []; + const octaves: string[] = []; + for (const c of day.commemorations) { + if (c.kind === 'sanctoral') { + sanctoral.push(c.name); + } else if (c.kind === 'temporal') { + if (c.id === temporalId) { + temporal.push(anchorDayName(day, false) ?? temporalLabel(day)); + } + } else if (opts.showOctaves && c.id !== opts.excludeOctaveId) { + const octave = activeOctaves.find((a) => a.id === c.id); + octaves.push(octave ? octaveCommemorationLabel(octave) : c.name); + } + } + return { sanctoral, temporal, octaves }; } const RANK_LABELS: Record = { @@ -319,49 +341,54 @@ const TEMPORAL_CATEGORY_RANK_LABELS: Record = { }; /** - * The full "day being celebrated" label: a feast name when - * calendar/commemorations.ts says the day has one, combined with (or - * replaced by) the ordinal temporal label depending on whether the feast - * won outright or was merely commemorated. See the plan discussion this - * came from for the three cases. + * The full "day being celebrated" label: the day's own primary identity + * (a sanctoral winner, a named temporal feast, a season's own anchor day, + * an octave governing the day, or the plain ordinal temporal label — in + * that precedence order) plus whatever `collectCommemorations` finds + * eligible to ride along with it. Each branch below only decides two + * things: what the primary label is, and what commemoration *groups* are + * eligible here and in what order — the actual filtering/formatting work + * is `collectCommemorations`'s alone, shared by every branch. */ export function getDayLabel(day: LiturgicalDay): string { if (day.winner.kind === 'sanctoral') { - // A sanctoral winner can still share the day with an active octave - // it didn't come from (e.g. winning a tie-break against one octave - // while a second, unrelated octave is also active) — append those, - // same "winner is primary, commemorations ride along" shape every - // other branch below already uses. Gated on `ordinary-feria`, same - // as the octave-headline branch further down: a day with real - // standing of its own (e.g. Trinity Sunday, which is incidentally - // also day 8 of Pentecost's own octave) never mentions an octave — - // same "nobody calls it that" convention anchorDayName's own doc - // comment already established for the anchor-day case. - const otherOctaves = day.temporalCategory === 'ordinary-feria' ? commemoratedOctaveDayLabels(day, undefined) : []; + // Octaves only ride along here on `ordinary-feria` — a day with real + // standing of its own (a Sunday, a privileged feria) doesn't mention + // an unrelated active octave even though it's technically active + // (live-verified: Aug 16, 2026, St. Joachim wins outright on a Sunday + // that's also within both St. Lawrence's and the Assumption's octave + // windows, and Divino Afflatu 1954's own commemoration line names + // only the Sunday, no octave). + const { sanctoral, temporal, octaves } = collectCommemorations(day, { + showOctaves: day.temporalCategory === 'ordinary-feria', + }); const winnerName = `${day.winner.name} (${formatRank(day.winner.rank)})`; - return [winnerName, ...otherOctaves].join(' — '); + return [winnerName, ...temporal, ...sanctoral, ...octaves].join(' — '); } // A named temporal feast (Christmas, Pentecost, Marian Saturday, ...) // shows its own name rather than the ordinal week label — same // "winner displaces, doesn't combine" rule a sanctoral winner gets // above. Most temporal ids don't have a record at all (see - // temporal-feasts.ts) and fall through to the ordinal label as before. + // temporal-feasts.ts) and fall through further down. const namedFeast = getTemporalFeastRecord(day.winner.id); if (namedFeast) { - return namedFeast.rank ? `${namedFeast.name} (${formatRank(namedFeast.rank)})` : namedFeast.name; + const primary = namedFeast.rank ? `${namedFeast.name} (${formatRank(namedFeast.rank)})` : namedFeast.name; + const { sanctoral } = collectCommemorations(day, { showOctaves: false }); + return [primary, ...sanctoral].join(' — '); } - const commemoratedSaint = day.commemorations.find((c) => c.kind === 'sanctoral'); - // A season's own named anchor day (Trinity Sunday, Easter, Ash // Wednesday, Epiphany) outranks an active octave, same reasoning as // anchorDayName's own doc comment — checked before the octave case // below since Trinity Sunday, e.g., also happens to be day 8 of // Pentecost's octave, and the anchor name is what actually governs. + // Existing convention: a commemorated saint *leads* here, before the + // anchor name — not "winner first" like every branch above. const anchorName = anchorDayName(day); if (anchorName) { - return commemoratedSaint ? `${commemoratedSaint.name} — ${anchorName}` : anchorName; + const { sanctoral } = collectCommemorations(day, { showOctaves: false }); + return [...sanctoral, anchorName].join(' — '); } // An active octave (St. Lawrence's, ...) is this day's real primary @@ -387,20 +414,20 @@ export function getDayLabel(day: LiturgicalDay): string { // disagree. When more than one octave is active at once // (resolveActiveOctave), the highest-ranked wins the headline (ties // broken by whichever started more recently) — every other active - // octave still gets named too (otherActiveOctaveNames), not dropped: - // live-verified real case, Aug 17 -- St. Lawrence's own elevated - // closing day wins the headline, but the Assumption's own day 3 (a - // real, distinct, simultaneously-active octave, not a duplicate of - // Lawrence's) still belongs in the label alongside St. Hyacinth's - // commemoration. + // octave still gets named too, not dropped: live-verified real case, + // Aug 17 -- St. Lawrence's own elevated closing day wins the headline, + // but the Assumption's own day 3 (a real, distinct, simultaneously- + // active octave, not a duplicate of Lawrence's) still belongs in the + // label alongside St. Hyacinth's commemoration. const activeOctave = day.temporalCategory === 'ordinary-feria' ? resolveActiveOctave(day.date) : octaveGoverningPrivilegedDay(day); if (activeOctave) { + const { sanctoral, octaves } = collectCommemorations(day, { showOctaves: true, excludeOctaveId: activeOctave.id }); const primary = octaveLabel(activeOctave); - const rest = [...otherActiveOctaveNames(day, activeOctave.id), ...(commemoratedSaint ? [commemoratedSaint.name] : [])]; - return [primary, ...rest].join(' — '); + return [primary, ...octaves, ...sanctoral].join(' — '); } const temporal = `${temporalLabel(day)} (${TEMPORAL_CATEGORY_RANK_LABELS[day.temporalCategory]})`; - return commemoratedSaint ? `${commemoratedSaint.name} — ${temporal}` : temporal; + const { sanctoral } = collectCommemorations(day, { showOctaves: false }); + return [...sanctoral, temporal].join(' — '); } diff --git a/src/calendar/index.ts b/src/calendar/index.ts index cca3c51..d40aa54 100644 --- a/src/calendar/index.ts +++ b/src/calendar/index.ts @@ -197,6 +197,23 @@ function applyChristmasOctaveSunday( const day = Number(dayStr); if (day >= 26 && day <= 29 && weekday === 'sunday') { + // The displaced saint isn't commemorated in place (per this + // function's own doc comment, "he reappears in full on Dec 30 + // instead") — strip the sanctoral commemoration `decideOccurrence` + // already pushed for him before this override ran, the same + // candidate the Dec 30 branch below will look up again to revive. + // Only became reachable once `commemorations.ts`'s `ordinary-sunday` + // case started commemorating Semiduplex/Simplex in place instead of + // transferring them (see its own doc comment) — before that fix, a + // `transfer` signal carried the candidate forward instead of a + // commemoration, so there was nothing here to strip. + const displaced = getSanctoralCandidatesFor(isoDate)[0]; + if (displaced) { + const idx = commemorations.findIndex((c) => c.kind === 'sanctoral' && c.id === displaced.id); + if (idx !== -1) { + commemorations.splice(idx, 1); + } + } return { kind: 'temporal', id: 'christmas-octave-sunday' }; } diff --git a/tests/calendar/christ-the-king.test.ts b/tests/calendar/christ-the-king.test.ts index e4e2851..5889d64 100644 --- a/tests/calendar/christ-the-king.test.ts +++ b/tests/calendar/christ-the-king.test.ts @@ -11,7 +11,12 @@ describe('Christ the King (applyChristTheKing)', () => { const day = resolveDay('2026-10-25'); // last Sunday of October 2026 expect(day.winner).toEqual({ kind: 'temporal', id: 'christ-the-king' }); expect(day.commemorations).toContainEqual({ kind: 'temporal', id: 'post-pentecost-22' }); - expect(getDayLabel(day)).toBe('Christ the King (Duplex I Class)'); + // Live-verified (Divino Afflatu 1954): the day's own commemoration + // line also names whichever sanctoral entry the ordinary Sunday was + // already carrying (Ss. Chrysanthus and Daria, Simplex, per the next + // test below) -- this app's day label now surfaces every commemorated + // saint, not just the Sunday itself. + expect(getDayLabel(day)).toBe('Christ the King (Duplex I Class) — Ss. Chrysanthus and Daria, Martyrs'); }); it('preserves a nested commemoration: a Simplex saint already commemorated under the ordinary Sunday stays commemorated', () => { diff --git a/tests/calendar/commemorations.test.ts b/tests/calendar/commemorations.test.ts index bb4b4ec..c9a3de0 100644 --- a/tests/calendar/commemorations.test.ts +++ b/tests/calendar/commemorations.test.ts @@ -122,11 +122,16 @@ describe('decideOccurrence — ordinary-sunday', () => { expect(result.transfer).toBeUndefined(); }); - it('semiduplex gets nothing here — transfers forward', () => { + it('semiduplex stays and is commemorated, not transferred', () => { + // Live-verified (both Tridentine 1906 and Divino Afflatu 1954): St. + // Gregory Thaumaturgus (Semiduplex) lands on the 6th Sunday after + // Epiphany and is commemorated right there, not pushed to the next + // open day — same treatment as Simplex above, not a separate + // "too important to merely commemorate" tier. const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('semiduplex')); expect(result.winner).toEqual({ kind: 'temporal', id: 'post-epiphany-2' }); - expect(result.commemorations).toEqual([]); - expect(result.transfer).toEqual({ candidate: saint('semiduplex'), direction: 'forward' }); + expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'semiduplex' }]); + expect(result.transfer).toBeUndefined(); }); it('vigil gets nothing here — transfers backward', () => { diff --git a/tests/calendar/day-label.test.ts b/tests/calendar/day-label.test.ts index e55ee30..302d422 100644 --- a/tests/calendar/day-label.test.ts +++ b/tests/calendar/day-label.test.ts @@ -23,8 +23,13 @@ describe('getDayLabel — ordinal temporal label', () => { // here per the normal ordinary-Sunday rule (see // tests/calendar/transfer.test.ts's own May 31 case for the full // winner/commemorations breakdown), so the label now reflects her, - // not Trinity Sunday itself. - expect(getDayLabel(resolveDay('2026-05-31'))).toBe('The Queenship of the Blessed Virgin Mary (Duplex II Class)'); + // not Trinity Sunday itself — but Trinity Sunday is still + // commemorated in return (`decideOccurrence`'s own `ordinary-sunday` + // branch), by bare name only — a commemoration never carries a rank + // parenthetical, only the day's own winner does. + expect(getDayLabel(resolveDay('2026-05-31'))).toBe( + 'The Queenship of the Blessed Virgin Mary (Duplex II Class) — Trinity Sunday', + ); expect(getDayLabel(resolveDay('2026-04-05'))).toBe('Easter (Duplex I Class)'); expect(getDayLabel(resolveDay('2026-02-18'))).toBe('Ash Wednesday'); }); @@ -77,16 +82,29 @@ describe('getDayLabel — resumed post-Epiphany Sunday (overflow years)', () => ); // 2024-11-11 is St. Martin of Tours (Duplex, pre-existing content) -- // an ordinary (non-privileged) Monday fully yields to a real winning - // saint, so the label is just his name, not the ferial fallback; see - // the 2035-10-29 assertion below for that fallback format on a - // genuinely saint-free overflow-week Monday instead (no single - // Nov-dated Monday near this Sunday pair is clean any more, now that - // Nov 4/8/15/16/20 are all fixed real content). - expect(getDayLabel(resolveDay('2024-11-11'))).toBe('St. Martin of Tours, Bishop and Confessor (Duplex Majus)'); - expect(getDayLabel(resolveDay('2024-11-17'))).toBe('The 6th Sunday after Epiphany (Semiduplex)'); + // saint, so the label is just his name (plus St. Menna, Simplex, also + // real and commemorated alongside him -- live-verified, Divino + // Afflatu 1954), not the ferial fallback; see the 2035-10-29 assertion + // below for that fallback format on a genuinely saint-free + // overflow-week Monday instead (no single Nov-dated Monday near this + // Sunday pair is clean any more, now that Nov 4/8/15/16/20 are all + // fixed real content). + expect(getDayLabel(resolveDay('2024-11-11'))).toBe( + 'St. Martin of Tours, Bishop and Confessor (Duplex Majus) — St. Menna, Martyr', + ); + // St. Gregory Thaumaturgus (Semiduplex, his real date) is commemorated + // right here, not transferred to Nov 18 -- live-verified (both + // Tridentine 1906 and Divino Afflatu 1954): a Semiduplex saint landing + // on an ordinary Sunday stays and is commemorated there, the same as + // Simplex, not pushed to the next open day (see + // calendar/commemorations.ts's `ordinary-sunday` case). + expect(getDayLabel(resolveDay('2024-11-17'))).toBe( + 'St. Gregory Thaumaturgus, Bishop and Confessor — The 6th Sunday after Epiphany (Semiduplex)', + ); // 2024-11-18 is the Dedication of the Basilicas of Ss. Peter and Paul - // (pre-existing fixed content) -- again a real winning saint, not the - // ferial fallback. + // (pre-existing fixed content) alone now -- again a real winning + // saint, not the ferial fallback, and no longer also carrying St. + // Gregory Thaumaturgus (he stays on his own real day, Nov 17, above). expect(getDayLabel(resolveDay('2024-11-18'))).toBe('Dedication of the Basilicas of Ss. Peter and Paul (Duplex)'); // 2035-10-29, a Monday in the 3rd week of a different overflow // stretch, is genuinely clean (no sanctoral entry, no commemoration) @@ -102,15 +120,39 @@ describe('getDayLabel — resumed post-Epiphany Sunday (overflow years)', () => // Every year 1900-2100 lands on this same id for its own last Sunday // before Advent, so this ordinal is fixed, not overflow-year-specific // -- confirmed against a non-overflow year (1943) too. - expect(getDayLabel(resolveDay('2026-11-22'))).toBe('The 23rd Sunday after Trinity (Semiduplex)'); + // St. Cecilia (Semiduplex, her real date) is commemorated right here + // too, not transferred -- live-verified (Divino Afflatu 1954), same + // rule as St. Gregory Thaumaturgus above. + expect(getDayLabel(resolveDay('2026-11-22'))).toBe( + 'St. Cecilia, Virgin and Martyr — The 23rd Sunday after Trinity (Semiduplex)', + ); // 1943-11-21 is also the Presentation of the BVM (Duplex Majus, added - // 2026-08 — see presentation-of-the-bvm.yml), which meets this app's - // existing privileged-Sunday rank threshold (commemorations.ts's - // `privileged-sunday` case requires only duplex-majus+) and so wins - // outright rather than being commemorated — a pre-existing rule, not - // new behavior from adding her. 2026-11-22 above (no saint collision) - // still covers the fixed-ordinal label itself. - expect(getDayLabel(resolveDay('1943-11-21'))).toBe('The Presentation of the Blessed Virgin Mary (Duplex Majus)'); + // 2026-08 — see presentation-of-the-bvm.yml). It's `ordinary-sunday` + // here (this app's Trinitytide Sundays, including the fixed final + // one, carry no special first-class standing of their own), so + // commemorations.ts's `ordinary-sunday` case's plain Duplex+ threshold + // is what lets her win outright rather than being commemorated — a + // pre-existing rule, not new behavior from adding her. This case + // additionally confirms the displaced Sunday is still commemorated in + // return, using the same fixed 23rd-after-Trinity ordinal, not a raw + // elapsed-week count recomputed for 1943. + expect(getDayLabel(resolveDay('1943-11-21'))).toBe( + 'The Presentation of the Blessed Virgin Mary (Duplex Majus) — The 23rd Sunday after Trinity', + ); + }); +}); + +describe('getDayLabel — commemorated Sunday/feria under a sanctoral winner', () => { + it('a saint winning outright on a privileged-feria-minor day still leaves that feria commemorated', () => { + // 2027-12-07, a Tuesday of Advent: St. Ambrose (Duplex) clears + // privileged-feria-minor's own Semiduplex+ threshold and wins + // outright, but Advent's own feria is still commemorated in return + // (`decideOccurrence`'s `privileged-feria-minor` branch) -- live- + // verified shape, same mechanism as the ordinary-Sunday case above, + // for the feria-tier branch instead. + expect(getDayLabel(resolveDay('2027-12-07'))).toBe( + 'St. Ambrose, Bishop, Confessor and Doctor of the Church (Duplex) — Tuesday in the 2nd week of Advent', + ); }); }); @@ -171,20 +213,39 @@ describe('getDayLabel — active octave', () => { // occurring saint (see octaves.test.ts and the December/September // sanctoral tests for those counterexamples). The Assumption's own // day 3 (semiduplex, genuinely active but outranked by Lawrence's - // elevated duplex) still gets named, not dropped, alongside it. + // elevated duplex) still gets named, not dropped, alongside it -- with + // its own full "Nth Day within the Octave of X" phrasing, not a bare + // name: live-verified directly (Divino Afflatu 1954, where Aug 17's + // real winner is Hyacinth himself, not Lawrence's octave -- a + // different rubric-track outcome, but the same commemoration phrasing + // question): "Commemoratio: Tertia die infra Octavam S. Assumptionis + // Beatæ Mariæ Virginis", not a bare "The Assumption of the Blessed + // Virgin Mary". expect(getDayLabel(resolveDay('2026-08-17'))).toBe( - 'Octave of St. Lawrence, Martyr (Duplex) — The Assumption of the Blessed Virgin Mary — St. Hyacinth, Confessor', + 'Octave of St. Lawrence, Martyr (Duplex) — 3rd Day within the Octave of The Assumption of the Blessed Virgin Mary — St. Hyacinth, Confessor', ); expect(getDayLabel(resolveDay('2026-08-18'))).toBe( '4th Day within the Octave of The Assumption of the Blessed Virgin Mary (Semiduplex)', ); }); - it('a real Sunday with standing of its own wins over both octaves entirely, showing the plain ordinal Sunday label -- not an octave name at all', () => { + it('a sanctoral winner on a Sunday still leaves the Sunday commemorated, but neither octave it also happens to overlap -- not an octave name at all', () => { // 2026-08-16 is a Sunday genuinely within both St. Lawrence's and the - // Assumption's overlapping octave windows. + // Assumption's overlapping octave windows -- St. Joachim (Duplex II + // Class) wins outright per the ordinary-Sunday Duplex+ threshold, not + // the Sunday itself (this test's own name was wrong about that before + // this case existed). Live-verified against Divino Afflatu 1954: the + // commemoration line reads only "Dominica XII Post Pentecosten" (this + // app's own Trinity-counted display is one week off from that + // Pentecost-counted number, so "11th ... after Trinity" here) -- no + // octave named at all, even though both are technically active, same + // as this app's own established `ordinary-feria`-only gate for + // octave mentions alongside a sanctoral winner. const day = resolveDay('2026-08-16'); expect(day.weekday).toBe('sunday'); + expect(getDayLabel(day)).toBe( + 'St. Joachim, Confessor, Father of the Blessed Virgin Mary (Duplex II Class) — The 11th Sunday after Trinity', + ); expect(getDayLabel(day)).not.toContain('Octave'); }); diff --git a/tests/calendar/january-sanctoral.test.ts b/tests/calendar/january-sanctoral.test.ts index 0aa1fae..91549ea 100644 --- a/tests/calendar/january-sanctoral.test.ts +++ b/tests/calendar/january-sanctoral.test.ts @@ -48,10 +48,21 @@ describe('January sanctoral pull (first pass)', () => { it('a simplex saint on an ordinary Sunday is commemorated, not dropped or made to win', () => { // Jan 14, 2029 is the Second Sunday after Epiphany (ordinary, not // privileged) — St. Felix (simplex) is commemorated per the ordinary- - // Sunday rule, matching the historical calendar exactly. + // Sunday rule, matching the historical calendar exactly. St. Hilary of + // Poitiers (Semiduplex, also native to this date) is commemorated too + // -- live-verified (Divino Afflatu 1954) as the real, sole + // commemoration named there; this app's own generous-commemoration + // design (see CLAUDE.md) additionally keeps St. Felix rather than + // dropping him now that Hilary no longer needs the day to himself. const day = resolveDay('2029-01-14'); expect(day.winner).toEqual({ kind: 'temporal', id: 'post-epiphany-2' }); expect(day.commemorations).toEqual([ + { + kind: 'sanctoral', + id: 'st-hilary-of-poitiers', + name: 'St. Hilary of Poitiers, Bishop, Confessor and Doctor of the Church', + rank: 'semiduplex', + }, { kind: 'sanctoral', id: 'st-felix-presbyter', name: 'St. Felix, Priest and Martyr', rank: 'simplex' }, ]); }); diff --git a/tests/calendar/july-sanctoral.test.ts b/tests/calendar/july-sanctoral.test.ts index 9d50a99..1de34fa 100644 --- a/tests/calendar/july-sanctoral.test.ts +++ b/tests/calendar/july-sanctoral.test.ts @@ -32,15 +32,25 @@ describe('July sanctoral pull (first pass)', () => { ]); }); - it('the Vigil of St. James resolves alongside its own commemorated saint, distinct from St. James Day itself', () => { + it('St. Apollinaris (Semiduplex) is commemorated on his own Sunday rather than transferring, so the Vigil of St. James the next day is unaffected', () => { + // Corrects an earlier, unverified "transfer+collision" assumption — + // live-verified (Divino Afflatu 1954): a Semiduplex saint landing on + // an ordinary Sunday is commemorated right there, not pushed forward + // (see calendar/commemorations.ts's `ordinary-sunday` case). 2028's + // Jul 23 is a Sunday. + const sunday = resolveDay('2028-07-23'); + expect(sunday.winner).toEqual({ kind: 'temporal', id: 'post-pentecost-07' }); + expect(sunday.commemorations).toEqual([ + { kind: 'sanctoral', id: 'st-apollinaris', name: 'St. Apollinaris, Bishop and Martyr', rank: 'semiduplex' }, + { kind: 'sanctoral', id: 'st-liborius', name: 'St. Liborius, Bishop and Confessor', rank: 'simplex' }, + ]); + // The Vigil of St. James wins its own day outright (Vigil outranks + // Simplex), with St. Christina commemorated -- no incoming transfer + // to contend with any more. const day = resolveDay('2028-07-24'); - expect(day.winner.kind).toBe('sanctoral'); - // 2028's Jul 23 is a Sunday, so St. Apollinaris transfers forward into - // this day and wins the collision against the Vigil/St. Christina — - // real transfer+collision interaction, not a data error. - expect(day.commemorations.map((c) => (c.kind === 'sanctoral' ? c.id : null)).sort()).toEqual([ - 'st-christina', - 'vigil-of-st-james', + expect(day.winner).toEqual({ kind: 'sanctoral', id: 'vigil-of-st-james', name: 'Vigil of St. James the Greater', rank: 'vigil' }); + expect(day.commemorations).toEqual([ + { kind: 'sanctoral', id: 'st-christina', name: 'St. Christina, Virgin and Martyr', rank: 'simplex' }, ]); }); diff --git a/tests/calendar/november-sanctoral.test.ts b/tests/calendar/november-sanctoral.test.ts index 56dd86a..be7186f 100644 --- a/tests/calendar/november-sanctoral.test.ts +++ b/tests/calendar/november-sanctoral.test.ts @@ -53,7 +53,15 @@ describe('November sanctoral pull (first pass)', () => { expect(day.commemorations).toEqual([]); }); - it('St. Clement transfers forward into St. Chrysogonus\'s day whenever his own date falls on a Sunday -- a single-day transfer this app models correctly, unlike August\'s multi-day-skip case', () => { + it("St. Clement (Semiduplex) is commemorated on his own Sunday rather than transferring, so St. Chrysogonus's own following day is unaffected either way", () => { + // Corrects an earlier, unverified assumption that a Semiduplex saint + // landing on an ordinary Sunday transfers forward -- live-verified + // (Divino Afflatu 1954) St. Clement is commemorated right there on + // Nov 23 ("Commemoratio: S. Clementis Papæ et Martyris"), same + // treatment Simplex already got (see calendar/commemorations.ts's + // `ordinary-sunday` case). St. Felicitas (Simplex, also native to + // Nov 23) is commemorated alongside him too, per this app's own + // generous-commemoration design. const clean = resolveDay('2032-11-24'); // Nov 23, 2032 is not a Sunday expect(clean.winner).toEqual({ kind: 'sanctoral', @@ -61,16 +69,22 @@ describe('November sanctoral pull (first pass)', () => { name: 'St. Chrysogonus, Martyr', rank: 'simplex', }); - const transferred = resolveDay('2025-11-24'); // Nov 23, 2025 IS a Sunday - expect(transferred.winner).toEqual({ - kind: 'sanctoral', - id: 'st-clement', - name: 'St. Clement I, Pope and Martyr', - rank: 'semiduplex', - }); - expect(transferred.commemorations).toEqual([ - { kind: 'sanctoral', id: 'st-chrysogonus', name: 'St. Chrysogonus, Martyr', rank: 'simplex' }, + const onceASunday = resolveDay('2025-11-23'); // a Sunday + expect(onceASunday.winner).toEqual({ kind: 'temporal', id: 'post-pentecost-24' }); + expect(onceASunday.commemorations).toEqual([ + { kind: 'sanctoral', id: 'st-clement', name: 'St. Clement I, Pope and Martyr', rank: 'semiduplex' }, + { kind: 'sanctoral', id: 'st-felicitas', name: 'St. Felicitas, Martyr', rank: 'simplex' }, ]); + // St. Chrysogonus's own following day is untouched either way -- no + // incoming transfer any more. + const followingDay = resolveDay('2025-11-24'); + expect(followingDay.winner).toEqual({ + kind: 'sanctoral', + id: 'st-chrysogonus', + name: 'St. Chrysogonus, Martyr', + rank: 'simplex', + }); + expect(followingDay.commemorations).toEqual([]); }); it('St. Andrew wins outright at Duplex II. classis with a real proper collect and antiphon, commemorating the Advent feria itself in years his fixed date falls within Advent', () => {