37ac31c3f2
Deploy / deploy (push) Successful in 39s
Corrects and completes the occurrence rules, based on a design discussion plus one concrete data point: St. Anthony Abbot (plain Duplex) was found outright winning against an ordinary Sunday in the real Monastic 1617 engine, which the old duplex-1-classis-only threshold got wrong. - FeastClass gains `vigil`, inserted between `simplex` and `semiduplex` — one ordering that correctly serves both "does this win against a Sunday" (vigil behaves like simplex there) and "which of two saints wins a landing-day collision" (vigil beats simplex, loses to semiduplex). - LiturgicalDay.occurring (a flat OccurringFeast[] that could only ever express a losing *sanctoral* candidate) is replaced by `winner: DayWinner` + `commemorations: Commemoration[]` — a discriminated list that can hold the temporal day itself, one or more sanctoral entries, or (not built yet, but the shape already accommodates it) a future octave kind. - commemorations.ts: ordinary Sundays let Duplex+ win outright (Sunday commemorated in return), Semiduplex/Vigil transfer elsewhere (too substantial a feast to cheapen with a bare commemoration), Simplex stays and is commemorated. Privileged Sundays never displace; Duplex-majus+ commemorated, everything else transfers. - collision.ts (new): resolves two sanctoral candidates wanting the same day (a transfer landing on an already-occupied day, or two native saints sharing a date) — duplex > semiduplex > vigil > simplex, loser always commemorated, ties favor the native occupant. - temporal-id.ts (new): maps any date to one of the 52 real Sunday-collect ids from the previous commit, so a temporal winner/commemoration can actually be looked up, not just labeled "temporal" in the abstract. - index.ts's resolveDay orchestrates all of it, including the actual Monday/Saturday transfer mechanism. Landing on a privileged feria (the concrete case: Holy Week, right after Palm Sunday) is explicitly deferred rather than guessed at — it needs its own Easter-keyed lookup table, the same way the reference engine handles it. Added the Vigil of St. Lawrence (Aug 9) as real content specifically to exercise the backward-transfer rule end-to-end: Aug 9, 2026 is a Sunday, so the vigil transfers cleanly back to Saturday, verified by a new integration test alongside the unit-level rule and collision tests.
106 lines
5.0 KiB
TypeScript
106 lines
5.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { decideOccurrence, compareFeastClass, isAtLeast } from '../../src/calendar/commemorations';
|
|
import type { SanctoralIdentity } from '../../src/calendar/types';
|
|
|
|
function saint(rank: SanctoralIdentity['rank']): SanctoralIdentity {
|
|
return { id: 'x', name: 'St. Ereden', rank };
|
|
}
|
|
|
|
describe('compareFeastClass / isAtLeast', () => {
|
|
it('orders the seven ranks low to high, with vigil between simplex and semiduplex', () => {
|
|
expect(compareFeastClass('simplex', 'vigil')).toBeLessThan(0);
|
|
expect(compareFeastClass('vigil', 'semiduplex')).toBeLessThan(0);
|
|
expect(compareFeastClass('semiduplex', 'duplex')).toBeLessThan(0);
|
|
expect(compareFeastClass('duplex-1-classis', 'simplex')).toBeGreaterThan(0);
|
|
expect(compareFeastClass('duplex', 'duplex')).toBe(0);
|
|
});
|
|
|
|
it('isAtLeast is inclusive of the threshold itself', () => {
|
|
expect(isAtLeast('duplex-majus', 'duplex-majus')).toBe(true);
|
|
expect(isAtLeast('duplex', 'duplex-majus')).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('decideOccurrence — no candidate', () => {
|
|
it('temporal wins trivially when nothing is assigned to the date', () => {
|
|
expect(decideOccurrence('ordinary-feria', 'some-feria-id', null)).toEqual({
|
|
winner: { kind: 'temporal', id: 'some-feria-id' },
|
|
commemorations: [],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('decideOccurrence — ordinary-feria', () => {
|
|
it('always yields to any real feast, uncommemorated, whatever its rank', () => {
|
|
for (const rank of ['simplex', 'vigil', 'semiduplex', 'duplex', 'duplex-1-classis'] as const) {
|
|
const result = decideOccurrence('ordinary-feria', 'id', saint(rank));
|
|
expect(result.winner).toEqual({ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank });
|
|
expect(result.commemorations).toEqual([]);
|
|
expect(result.transfer).toBeUndefined();
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('decideOccurrence — privileged-feria', () => {
|
|
it('yields to nothing short of the top class', () => {
|
|
const majus = decideOccurrence('privileged-feria', 'id', saint('duplex-2-classis'));
|
|
expect(majus.winner).toEqual({ kind: 'temporal', id: 'id' });
|
|
expect(majus.commemorations).toEqual([]);
|
|
|
|
const top = decideOccurrence('privileged-feria', 'id', saint('duplex-1-classis'));
|
|
expect(top.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'duplex-1-classis' }]);
|
|
});
|
|
});
|
|
|
|
describe('decideOccurrence — ordinary-sunday', () => {
|
|
it('duplex or higher wins outright, and the Sunday itself is commemorated', () => {
|
|
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('duplex'));
|
|
expect(result.winner).toEqual({ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'duplex' });
|
|
expect(result.commemorations).toEqual([{ kind: 'temporal', id: 'post-epiphany-2' }]);
|
|
expect(result.transfer).toBeUndefined();
|
|
});
|
|
|
|
it('simplex stays and is commemorated, not transferred', () => {
|
|
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('simplex'));
|
|
expect(result.winner).toEqual({ kind: 'temporal', id: 'post-epiphany-2' });
|
|
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'simplex' }]);
|
|
expect(result.transfer).toBeUndefined();
|
|
});
|
|
|
|
it('semiduplex gets nothing here — transfers forward', () => {
|
|
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' });
|
|
});
|
|
|
|
it('vigil gets nothing here — transfers backward', () => {
|
|
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('vigil'));
|
|
expect(result.transfer).toEqual({ candidate: saint('vigil'), direction: 'backward' });
|
|
});
|
|
});
|
|
|
|
describe('decideOccurrence — privileged-sunday', () => {
|
|
it('is never displaced; duplex-majus and up are commemorated', () => {
|
|
for (const rank of ['duplex-majus', 'duplex-2-classis', 'duplex-1-classis'] as const) {
|
|
const result = decideOccurrence('privileged-sunday', 'advent-1', saint(rank));
|
|
expect(result.winner).toEqual({ kind: 'temporal', id: 'advent-1' });
|
|
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank }]);
|
|
expect(result.transfer).toBeUndefined();
|
|
}
|
|
});
|
|
|
|
it('duplex, semiduplex, and simplex all transfer forward — no bare commemoration here', () => {
|
|
for (const rank of ['duplex', 'semiduplex', 'simplex'] as const) {
|
|
const result = decideOccurrence('privileged-sunday', 'advent-1', saint(rank));
|
|
expect(result.commemorations).toEqual([]);
|
|
expect(result.transfer).toEqual({ candidate: saint(rank), direction: 'forward' });
|
|
}
|
|
});
|
|
|
|
it('vigil transfers backward, same as on an ordinary Sunday', () => {
|
|
const result = decideOccurrence('privileged-sunday', 'advent-1', saint('vigil'));
|
|
expect(result.transfer).toEqual({ candidate: saint('vigil'), direction: 'backward' });
|
|
});
|
|
});
|