aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-12 13:03:57 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-12 13:03:57 +0200
commitca3403893bfbebb325fe3ab6a98081640574bf2a (patch)
tree86e25dc915343b021ac88db2952020be020b9877 /scripts
parent2386a4551aec94252168a8554269ee423d516882 (diff)
downloadlectio-ca3403893bfbebb325fe3ab6a98081640574bf2a.tar.gz
lectio-ca3403893bfbebb325fe3ab6a98081640574bf2a.zip
test(ef): strengthen the oracle test to assert rank and colour
internal/calendar/oracle_ef_test.go asserted Season only. lectio's own EF oracle test comment said as much ("rank/colour are reported informationally"), which is exactly why several precedence/colour defects in precedence_ef.go and temporal_ef.go shipped without ever failing a test: the suite was green while the observed office's own rank and liturgical colour could be wrong. Rebuild the oracle from the committed missalemeum snapshot (sources/snapshot.tar.gz, missalemeum/en/YYYY-MM-DD.json, 2026-01-01 .. 2027-12-31, 730 days) instead of a live 2025-2026 fetch, via a rewritten scripts/build-oracle-ef.sh -- offline, reproducible, and correctly separating info.rank/info.colors from info.id (whose embedded rank is the rank of the propers REUSED that day, not the day's own rank -- e.g. 2026-01-02 is a class-4 feria carrying id "sancti:01-01:1:w" because it reuses the Circumcision's propers). info.colors is an array (14 of 730 days carry two values -- Gaudete/ Laetare "pv", Palm Sunday "rv", Good Friday "bv", Holy Saturday "vw"), so the new Colour assertion is membership, not equality. The strengthened assertions immediately expose several real defects (rank mismatches on every Advent/Lent Sunday, the Ember days, the late-Advent and Christmas-octave ferias, and more) -- that is the point, this is the regression net subsequent commits fix against. Since the repo's convention is go test ./... green at every commit, TestOracleEF is gated behind LECTIO_EF_ORACLE_STRICT=1 for now rather than landed red; a later commit removes the gate once the fixes are in. Season alone stays green throughout (unchanged, always was). A small, cited allow-list (efAllowList) is included from this commit: genuine, defensible divergences unrelated to the fixes ahead of it -- RG 91 entry 27's un-built BVM Saturday Office, the pre-existing 6-13 January Christmastide/time-after-Epiphany season-boundary divergence, missalemeum's own RG 33 gap on a Sunday 9 August, and one collision (St Joseph vs the Friday of Passion Week, 2027) left explicitly unresolved even by the sibling project's much deeper primary-source pass. None of the four is one of the seven defects this branch fixes.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-oracle-ef.sh56
1 files changed, 30 insertions, 26 deletions
diff --git a/scripts/build-oracle-ef.sh b/scripts/build-oracle-ef.sh
index 2864551..32cb385 100755
--- a/scripts/build-oracle-ef.sh
+++ b/scripts/build-oracle-ef.sh
@@ -1,38 +1,42 @@
#!/usr/bin/env bash
-# build-oracle-ef.sh — generate the EF (1962) regression oracle by fetching
-# missalemeum's per-date proper API (the same source lectio's trad scraper uses,
-# built on Divinum Officium data) for 2025-2026.
+# build-oracle-ef.sh — build the EF (1962) regression oracle from the committed
+# missalemeum snapshot (sources/snapshot.tar.gz, missalemeum/en/YYYY-MM-DD.json,
+# 2026-01-01 .. 2027-12-31, 730 days), not a live fetch, so the oracle is
+# reproducible offline and pinned to a known-good snapshot.
#
-# NOT run by `go test`. Requires network + curl + jq + GNU date. From repo root:
+# Three things about this data that cost hours to learn (see oracle_ef_test.go):
+# 1. info.id looks like "sancti:MM-DD:rank:colour", but its embedded rank is
+# the rank of the PROPERS USED that day, not the day's own rank (e.g.
+# 2026-01-02 is a class-4 feria whose id is "sancti:01-01:1:w" because it
+# reuses the Circumcision's propers). Extracted here for provenance only
+# -- never parse rank/colour out of it. Use info.rank/info.colors.
+# 2. info.colors is an array; 14 of 730 days carry two values (Gaudete/
+# Laetare "pv", Palm Sunday "rv", Good Friday "bv", Holy Saturday "vw").
+# The Go test compares by membership, not equality.
+# 3. A two-colour value on a weekday can be a proper-reuse artifact (a feria
+# inside Gaudete/Laetare week reusing the Sunday's own propers) rather
+# than a claim about that weekday's own colour.
+#
+# From repo root:
# scripts/build-oracle-ef.sh
# Writes internal/calendar/testdata/oracle-ef.json:
-# { "YYYY-MM-DD": {"tempora": "...", "title": "...", "rank": N, "colour": "w"} }
-# tempora is "" when missalemeum returns null (then the temporal identity is in
-# title); the Go test derives the season from tempora-or-title.
+# { "YYYY-MM-DD": {"id":"...", "tempora":"...", "title":"...", "rank":N, "colours":["w",...]} }
set -euo pipefail
out=internal/calendar/testdata/oracle-ef.json
-mkdir -p "$(dirname "$out")"
work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
-for y in 2025 2026; do
- d="$y-01-01"
- while [ "$(date -d "$d" +%Y)" = "$y" ]; do
- echo "$d"
- d=$(date -d "$d +1 day" +%F)
- done
-done > "$work/dates"
+tar xzf sources/snapshot.tar.gz -C "$work" missalemeum/en
-fetch() {
- local d="$1"
- local j
- j=$(curl -sf --max-time 25 "https://www.missalemeum.com/en/api/v5/proper/$d" || true)
- printf '%s' "$j" | jq -c --arg d "$d" \
- '{($d): (.[0].info | {id:(.id // ""), tempora:(.tempora // ""), title:.title, rank:.rank, colour:(.colors|join(""))})}' \
- 2>/dev/null || true
-}
-export -f fetch
+jq -s '
+ map({(.[0].info.date): {
+ id: (.[0].info.id // ""),
+ tempora: (.[0].info.tempora // ""),
+ title: .[0].info.title,
+ rank: .[0].info.rank,
+ colours: .[0].info.colors
+ }}) | add
+' "$work"/missalemeum/en/*.json > "$out"
-xargs -P 12 -I{} bash -c 'fetch "$@"' _ {} < "$work/dates" | jq -s 'add' > "$out"
echo "wrote $out ($(jq 'length' "$out") days)" >&2
-rm -rf "$work"