aboutsummaryrefslogtreecommitdiff
path: root/lib/rites/rite_ef/precedence_ef.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rites/rite_ef/precedence_ef.ml')
-rw-r--r--lib/rites/rite_ef/precedence_ef.ml224
1 files changed, 215 insertions, 9 deletions
diff --git a/lib/rites/rite_ef/precedence_ef.ml b/lib/rites/rite_ef/precedence_ef.ml
index 374e9a4..5a2d307 100644
--- a/lib/rites/rite_ef/precedence_ef.ml
+++ b/lib/rites/rite_ef/precedence_ef.ml
@@ -514,7 +514,18 @@ let privilege_of (c : Vocab_ef.rank Precedence.candidate) : Precedence.privilege
let is_temporal = c.Precedence.origin = Precedence.Temporal in
let open Vocab_ef in
(* (a) RG 109(a) (§4): "of a Sunday" -- the same slug marker RG 33's
- [impedes_vigil] already reads to answer "is this candidate a Sunday". *)
+ [impedes_vigil] already reads to answer "is this candidate a Sunday".
+
+ FRAGILITY, named here because this is the decision point (fix-round
+ re-review, F5): [is_sunday_slug] is a SUBSTRING match, so the Holy Name
+ of Jesus obtains this privilege on its Sunday shape only because its
+ slug happens to read "ef-holy-name-sunday". That is a naming accident,
+ not a cited rule. The real warrant is RG 17's own closing paragraph
+ (quoted in full at temporal_ef.ml's [holy_name_sunday]): "Haec festa
+ locum tenent dominicae occurrentis cum omnibus iuribus et privilegiis"
+ -- these feasts hold the occurring Sunday's place WITH ALL ITS RIGHTS
+ AND PRIVILEGES, of which RG 109(a)'s privilege is one. A slug rename
+ would silently drop it while every test stayed green. *)
if is_sunday_slug slug then Precedence.Privileged
(* (b) RG 109(b) (§4): "of a I-class day" -- the candidate's own
rank. In this codebase's current disposition rules the ONLY way a
@@ -1039,6 +1050,191 @@ let rec take n = function
still the pair, not the triple; only the INPUT carries [band]. *)
let drop_band (c, p, (_ : int)) = (c, p)
+(* RG 110 (docs/research/rules-register.md §4, Caput XIV, "De dierum
+ liturgicorum occurrentia perpetua"), full text, both photographic scans,
+ word for word: "110. In Officio et Missa S. Petri semper fit
+ commemoratio S. Pauli, et vicissim. Haec commemoratio dicitur
+ inseparabilis; et duae orationes adeo in unam coalescere censentur ut, in
+ numero orationum computando, pro unica habeantur. Proinde: a) in Officio
+ S. Petri aut S. Pauli, oratio alterius Apostoli additur, ad Laudes et ad
+ Vesperas, sub unica conclusione, orationi diei, absque antiphona et
+ versu; b) in Missa S. Petri aut S. Pauli, oratio alterius Apostoli
+ additur, sub unica conclusione, orationi diei; c) quoties vero oratio
+ unius Apostoli addenda est ad modum commemorationis, huic orationi
+ additur altera immediate, ante omnes alias commemorationes." -- in the
+ Office and Mass of St Peter, a commemoration of St Paul is ALWAYS made,
+ and vice versa. This commemoration is called INSEPARABLE, and the two
+ orations are held to coalesce into one so much that, in counting the
+ number of orations [RG 111's own admission cap], they are counted AS
+ ONE. Accordingly: (a)/(b) in the Office/Mass OF Peter or Paul [i.e. when
+ one of them is the day's own observed office], the other Apostle's
+ oration is added, under a single conclusion, to the oration of the day;
+ (c) whenever the oration of ONE Apostle must be added AS A
+ COMMEMORATION [i.e. when one of them is not the day's own office but is
+ itself only being admitted as an ordinary/privileged commemoration
+ elsewhere], the OTHER is added to it immediately, BEFORE ALL OTHER
+ COMMEMORATIONS.
+
+ Three real pairs in this codebase's data, all three confirmed on both
+ photographic scans (register §4): 25 January's [conversion-of-st-paul] +
+ [peter]; 22 February's [chair-of-st-peter] + [paul]; 30 June's
+ [in-commemoratione-sancti-pauli-apostoli] + [commemoration-of-st-peter]
+ (data/ef/adjustments.sexp's own `Add` directive -- lectio has no
+ equivalent entry at all, a genuine upstream data gap, not merely a
+ colitur bootstrap miss). 29 June ([sts-peter-paul]) needs none: it is
+ already the JOINT feast, not one Apostle's office alone. [peter]/[paul]
+ already existed as ordinary [Commemoration_only] sanctoral candidates
+ before this task (Task 10's bootstrap) -- part of RG 110's own machinery,
+ just wired into the ORDINARY, CAPPED RG 111 admission contest instead of
+ this rule's own UNCAPPED one, which is the defect this closes: measured
+ (1583-9999, `tools/`'s own throwaway scan, reproduced and discarded per
+ this task's own report) at 3,533 years where [chair-of-st-peter] is
+ observed but [paul] loses the day's single non-Sunday-II-class slot to a
+ competing privileged Advent/Lent/Ember feria (RG 109(e)/(d)), and a
+ FURTHER 593 years of shape (c) below, where [chair-of-st-peter] itself
+ loses outright to an ordinary (ordinary, i.e. non-I-class) II-class
+ Sunday and is admitted only AS a commemoration -- [paul] was entirely
+ absent in every one of those 593 years too, before this fix. 25
+ January/30 June never show shape (c) at all: both trigger candidates are
+ [Class3], below RG 111(b)'s "de festo II classis" floor, so neither can
+ ever be admitted as a mere ordinary commemoration on a II-class Sunday
+ in the first place -- confirmed by the same scan, 0 instances either
+ way, not assumed absent.
+
+ [rg110_companion_slug] reads ONLY the candidate's own slug -- the same
+ convention every other not-an-RG-citation lookup in this file uses
+ ({!universal_layer}, {!vigil_suffix}, {!nativity_octave_prefix}) -- not
+ [subject]/[rank]/anything else, because "which slug pairs with which" is
+ RG 110's own closed, three-pair list, not a general property [band]/
+ [disposition] could derive structurally the way (say) [is_sunday_slug]
+ derives Sunday-ness from a naming convention. A rename of any of the six
+ slugs involved (either side of a pair) has nowhere else to be caught but
+ here -- flagged the same way {!annunciation_slug} already is. *)
+let rg110_companion_slug (slug : string) : string option =
+ if slug = "chair-of-st-peter" then Some "paul"
+ else if slug = "conversion-of-st-paul" then Some "peter"
+ else if slug = "in-commemoratione-sancti-pauli-apostoli" then Some "commemoration-of-st-peter"
+ else None
+
+(* Looks [companion_slug] up directly in [comms] -- the SAME full candidate
+ pool {!admit} itself sorts from, before any cap is applied, so this finds
+ the companion regardless of whether the NORMAL admission process would
+ have kept it (it never would: {!band} always ranks a [Commemoration_only]
+ candidate at {!unclassified}, worse than literally any real table entry,
+ so a companion competing on its own merits never survives a contested
+ slot -- RG 110's entire point is that it should not have to). Returns the
+ ORIGINAL triple's candidate/privilege pair, unrebuilt, for the same
+ physical-equality reason {!drop_band} and this function's own top comment
+ already document -- reusing the [privilege] {!disposition}/{!privilege_of}
+ already computed for it rather than inventing a new tag here. *)
+let rg110_find_companion comms companion_slug =
+ List.find_map
+ (fun (c, p, (_ : int)) ->
+ if Slug.to_string c.Precedence.cel.Celebration.slug = companion_slug then Some (c, p) else None)
+ comms
+
+(* RG 110's own uncapped addition, applied to [normal] -- the day's ALREADY-
+ COMPUTED, ORDINARILY-CAPPED admission result (every branch of {!admit}
+ below, unchanged otherwise). Two triggers, covering RG 110(a)/(b) and
+ RG 110(c) respectively, in this function's own comment above -- and,
+ fix round 1, TWO DIFFERENT ORDERINGS, not one, because the two shapes'
+ own primary texts say different things about where the companion goes:
+
+ - [observed] itself is one of the three trigger slugs (shape (a)/(b):
+ Peter's or Paul's own Office/Mass IS today's day) -- the companion is
+ looked up directly and PREPENDED to [normal]. (a)/(b)'s own text,
+ "oratio alterius Apostoli additur ... orationi diei" (the OTHER
+ Apostle's oration is added ... TO THE DAY'S OWN oration), has nothing
+ in [normal] to order the companion AGAINST in the first place: the
+ day's own oration is [observed], not a member of this list, so
+ leading the list is simply where an item with nothing to be "before"
+ or "after" inside it goes -- not itself a citation for a POSITION
+ the primary text does not describe a list position for at all.
+ - one of [normal]'s OWN members is a trigger slug (shape (c): Peter's or
+ Paul's own office lost the day outright but is itself being admitted
+ as an ordinary/privileged commemoration of whatever else won) -- the
+ companion is looked up the same way, but SPLICED IN IMMEDIATELY AFTER
+ its own trigger, not prepended to the whole list. RG 110(c)'s own
+ text, word for word: "quoties vero oratio unius Apostoli addenda est
+ ad modum commemorationis, HUIC ORATIONI ADDITUR ALTERA immediate, ante
+ omnes alias commemorationes" -- "huic orationi" (dative, "to THIS
+ oration") refers back to "oratio unius Apostoli" (the trigger's OWN
+ oration, the one just named as "addenda... ad modum commemorationis")
+ -- so "additur altera" (the OTHER is added) means the companion is
+ added TO the trigger's own oration, i.e. FOLLOWS it, not precedes it;
+ the pair as a BLOCK then precedes "omnes ALIAS commemorationes"
+ ("alias" = OTHER, unrelated ones -- cannot include the pair's own
+ first member). CORRECTED, fix round 1: the original version of this
+ function prepended in BOTH shapes uniformly, citing (c)'s own "ante
+ omnes alias" for shape (a)/(b) too by analogy -- which is fine for
+ WHERE the pair sits relative to unrelated commemorations, but wrongly
+ also reordered the PAIR'S OWN internal order in shape (c), producing
+ `paul, chair-of-st-peter` where the primary text requires
+ `chair-of-st-peter, paul` (verified against BOTH photographic scans,
+ word for word, no divergence to adjudicate). Confirmed live: every one
+ of the 593 shape-(c) days measured in this task's own report emitted
+ the companion FIRST before this fix; RG 111's own admission branches
+ never build a second, unrelated commemoration alongside a shape-(c)
+ trigger in today's data (RG 111(b) admits exactly one candidate on a
+ II-class Sunday, the only day shape (c) ever occurs), so this
+ splice-after-trigger behaviour is Total the same way {!take}/
+ {!drop_band} are, but has no OTHER live witness to also prove the
+ "ante omnes alias" half of (c) against.
+
+ Both shapes can never fire together on one call ({!Precedence.resolve}
+ only ever calls {!Precedence.rules.admit} once per date, and all three
+ trigger slugs are distinct FIXED calendar dates -- 25 January, 22
+ February, 30 June -- so at most one of [observed]/[normal]'s own members
+ is ever a trigger for a given call).
+
+ A companion already present in [normal] on its own merits (structurally
+ unreachable today -- {!unclassified}'s own comment above -- but not
+ provably so for every future rite/data shape) is not added a second
+ time: [List.exists] guards both branches.
+
+ NEW BLIND SPOT, fix round 1: no validation layer in this codebase
+ compares commemoration ORDER at all -- the lectio differential does not
+ compare commemorations (its own "limit 1"); the oracle's own
+ [identity_diff] sorts both sides into a multiset before comparing;
+ and [describe] (test_golden.ml) sorts its own comms field too, for the
+ same reason presence/identity checks should not be order-sensitive by
+ accident. (CORRECTED, fix-round re-review: this previously also named
+ {!Colitur_kernel.Record}. Record.t has NO commemorations field at all --
+ see record.mli -- so it neither sorts nor carries them.) This function's own [admit_cases] unit
+ test (test_precedence_ef.ml) is therefore the ONLY place in this
+ codebase's test suite where commemoration order is asserted at all --
+ flagged here, and in CLAUDE.md's own "know what each layer cannot see"
+ section, as a genuine, permanent limit, not merely this fix's own gap. *)
+let rg110_additions (comms : (Vocab_ef.rank Precedence.candidate * Precedence.privilege * int) list)
+ ~(observed : Vocab_ef.rank Precedence.candidate)
+ (normal : (Vocab_ef.rank Precedence.candidate * Precedence.privilege) list) :
+ (Vocab_ef.rank Precedence.candidate * Precedence.privilege) list =
+ let already_has slug =
+ List.exists (fun (c, _) -> Slug.to_string c.Precedence.cel.Celebration.slug = slug) normal
+ in
+ match rg110_companion_slug (Slug.to_string observed.Precedence.cel.Celebration.slug) with
+ | Some companion_slug when not (already_has companion_slug) -> (
+ (* Shape (a)/(b): prepend -- see this function's own comment above. *)
+ match rg110_find_companion comms companion_slug with
+ | Some companion -> companion :: normal
+ | None -> normal)
+ | _ ->
+ (* Shape (c): splice each trigger's companion in immediately after it
+ -- {!List.concat_map} rather than a fold, so a trigger with no
+ companion found (defensive; {!rg110_find_companion} returning
+ [None]) simply passes through unchanged, and a member that is not
+ a trigger at all ([rg110_companion_slug] returns [None]) is never
+ touched. *)
+ List.concat_map
+ (fun ((c, _) as pair) ->
+ match rg110_companion_slug (Slug.to_string c.Precedence.cel.Celebration.slug) with
+ | Some companion_slug when not (already_has companion_slug) -> (
+ match rg110_find_companion comms companion_slug with
+ | Some companion -> [ pair; companion ]
+ | None -> [ pair ])
+ | _ -> [ pair ])
+ normal
+
let admit ~(observed : Vocab_ef.rank Precedence.candidate)
~(temporal : Vocab_ef.rank Precedence.candidate)
(comms : (Vocab_ef.rank Precedence.candidate * Precedence.privilege * int) list) :
@@ -1073,14 +1269,22 @@ let admit ~(observed : Vocab_ef.rank Precedence.candidate)
is_sunday_slug (Slug.to_string temporal.Precedence.cel.Celebration.slug)
in
let open Vocab_ef in
- match (observed_rank, day_is_sunday) with
- | Class1, _ ->
+ (* RG 110's own uncapped additions are layered on AFTER this match --
+ {!rg110_additions}'s own top comment -- never inside any one branch:
+ the three trigger slugs can each reach [observed] via any rank/Sunday
+ combination the table admits (a Class2 fixed feast, here, but nothing
+ in {!rg110_additions} itself assumes that), so computing it once,
+ uniformly, over whatever this match already decided is both simpler
+ and safer than duplicating the same lookup into every branch. *)
+ let normal =
+ match (observed_rank, day_is_sunday) with
+ | Class1, _ ->
(* RG 111: "I class: none save one privileged." Ordinary commemorations
never get a slot at all on a I-class day, no matter how many are
due; at most one privileged one does, the highest-precedence one
(RG 113: {!band}'s own table order) if several are. *)
(match List.filter is_privileged sorted with [] -> [] | best :: _ -> [ drop_band best ])
- | Class2, true ->
+ | Class2, true ->
(* RG 111(b), primary text, RE-VERIFIED word for word against the scan
(final fix wave; this sentence is the sole textual basis for the
shipped rank-floor fix below, and the register's own §4 "RG 111"
@@ -1121,16 +1325,18 @@ let admit ~(observed : Vocab_ef.rank Precedence.candidate)
match List.filter (fun (c, _, _) -> c.Precedence.cel.Celebration.rank = Class2) sorted with
| [] -> []
| best :: _ -> [ drop_band best ]))
- | Class2, false ->
+ | Class2, false ->
(* RG 111: "other II class: one" -- no privilege-override clause here,
unlike the Sunday case immediately above, so the day's one slot
goes to whichever candidate outranks the rest by RG 113's own
table-of-precedence order ({!band}), privileged or not. *)
(match sorted with [] -> [] | best :: _ -> [ drop_band best ])
- | (Class3 | Class4), _ ->
- (* RG 111: "III-IV class: at most two" -- by RG 113's table order, same
- as the non-Sunday II-class case, just with room for two. *)
- List.map drop_band (take 2 sorted)
+ | (Class3 | Class4), _ ->
+ (* RG 111: "III-IV class: at most two" -- by RG 113's table order, same
+ as the non-Sunday II-class case, just with room for two. *)
+ List.map drop_band (take 2 sorted)
+ in
+ rg110_additions comms ~observed normal
(* Task 11: RG 96 -- where an impeded I-class feast lands (docs/research/
rules-register.md §4, "Transfer/translation"). [band] decides who is