Blackout / unavailability (ARCHITECTURE §4.7 / §5.3 rule 5 / §5.4):
- src/domain/availability.ts — pure isUnavailable(records, date); a record
covers the date if active and its inclusive range [starts_on, ends_on]
contains it OR its rrule matches. No DB imports.
- src/domain/availability.test.ts — 11 tests named after the rule, incl.
the inclusive-end case (2026-11-21..2026-11-28 covers 11-28).
- src/db/schema.ts — unavailability table: CHECK ends_on >= starts_on,
CHECK span <= 365 days, unique (user_id, starts_on, ends_on) WHERE active.
- src/db/unavailability.ts — list/get/create/update/cancel (soft-delete);
range + rrule validated on write.
- src/app/api/dev/unavailability/route.ts — GET/POST/PATCH; bad range/rrule
-> 400, cancel flips status=cancelled.
- drizzle/0008_needy_stryfe.sql + migration applied to DB on :5433.
date columns stored as strings (mode: string) to match the YYYY-MM-DD
domain; Postgres date is mode-agnostic so the migration is unchanged.
Constraints enforced twice: validateUnavailabilityRange at the API,
chk_unavailability_* at the DB.
.env added to .gitignore (real secret was not ignored; .env.* missed the
bare .env).
Fixes the A4 blocker: /api/dev/complete now establishes the Auth.js session.
Root cause was UntrustedHost (trustHost defaulted false in pnpm start /
production because setEnvDefaults derives it from AUTH_URL, not NEXTAUTH_URL,
and assertConfig checks it before that default applies). Added trustHost: true
to the auth config; rebuilt. Complete response now sets authjs.session-token,
/schedule returns 200, and all 4 e2e shell tests pass.
Also ignores test-results/ artifacts.