Skip to content

refactor(sync): retire dead graph zone option and dedupe microsoft recurrence mapping - #4844

Merged
tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-i9ovqz
Oct 26, 2026
Merged

tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-i9ovqz

Conversation

@tyler-dane

@tyler-dane tyler-dane commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Technical-debt sweep over the merged changes from the last seven days. The Microsoft Graph provider was by far the hottest churn in that window (microsoft-event.normalizer.ts touched six times, microsoft-recurrence.ts four), and two kinds of debt had accumulated there: a configuration option that was never actually configurable, and four-way copy-paste in the recurrence mapper. Two commits, one per debt item, no behavior change in either.

1. simplify(sync): drop the always-UTC graphPreferTimeZone option. NormalizeMicrosoftEventOptions.graphPreferTimeZone looked like a seam but had exactly one value. Every production caller (reader delta pages, writer fetchEvent, writer fetchInstanceAt) passed MICROSOFT_GRAPH_OUTLOOK_TIMEZONE; every test passed the same literal "UTC"; omitting it defaulted to that same constant. Both guards that read it compared it against that constant, so graphPreferTimeZone === MICROSOFT_GRAPH_OUTLOOK_TIMEZONE was a tautology and the dayjs.tz(raw, timeZone) branch in toOffsetIso was unreachable from any caller. Removing the option lets mapSchedule drop the options bag entirely and lets resolveTimedEventTimeZone read as the rule it always implemented: a non-UTC start field is the event's real zone, and a UTC one falls back to the recurrence zone, then the original start zone. The Prefer header itself is untouched, and the zone each event resolves to is identical.

2. refactor(sync): dedupe the recurrence weekday tables and field guards. RRULE_TO_GRAPH_DAY restated GRAPH_TO_RRULE_DAY backwards, so a weekday correction meant editing two tables with nothing checking them against each other; it is now derived by inverting the forward table. requireDayOfMonth/requireMonth/requireCount/requireEndDate were the same eight lines four times, differing only in the interpolated field name, and collapse into one requireField (the numbered-range message now names the Graph field, numberOfOccurrences, instead of the local variable). The "Multiple BYDAY ordinals" rule was thrown verbatim from both splitRelativeByDay and byweekdayToTokens, and both now call one assertSingleOrdinal.

GRAPH_DAY_ORDER and RRULE_WEEKDAY_TOKENS deliberately stay as they are. They are not restatements of the token map: the first carries Graph's Sunday-first ordering, the second rrule's Monday-based weekday indexes.

Net effect across both commits: 7 files, +70 / -154, with the existing suites covering the behavior unchanged.

Verify

bun run verify --strict

Selected packages: sync
Checks run: test:sync:fast, type-check, lint, knip
Checks skipped: (none)

✓ All checks passed
VERDICT: PASS

bun test packages/sync/src/providers/microsoft/microsoft-recurrence.test.ts: 60 pass, 0 fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_018gVNGW5WLSrqPjZaT1ReM4

…tion

`NormalizeMicrosoftEventOptions.graphPreferTimeZone` was configurable in
name only. Every production caller (reader delta pages, writer fetchEvent,
writer fetchInstanceAt) passed `MICROSOFT_GRAPH_OUTLOOK_TIMEZONE`, every
test passed the same `"UTC"`, and the option defaulted to that constant
when omitted. Both guards that read it compared it against that very
constant, so `graphPreferTimeZone === MICROSOFT_GRAPH_OUTLOOK_TIMEZONE`
was a tautology and the non-UTC branch in `toOffsetIso` was unreachable.

Remove the option and collapse the two branches it fed. `mapSchedule` no
longer needs the options bag at all, and `resolveTimedEventTimeZone` now
reads as the rule it always implemented: a non-UTC start field is the
event's real zone, and a UTC one falls back to the recurrence zone and
then the original start zone. Zone resolution and the Prefer header are
unchanged, so there is no behavior change.

VERDICT: PASS

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gVNGW5WLSrqPjZaT1ReM4
…guards

Three pieces of copy-paste had built up in the Graph recurrence mapper:

- `RRULE_TO_GRAPH_DAY` restated `GRAPH_TO_RRULE_DAY` backwards, so adding
  or correcting a weekday meant editing two tables that nothing checked
  against each other. Invert the forward table instead.
- `requireDayOfMonth`, `requireMonth`, `requireCount`, and `requireEndDate`
  were the same eight lines four times over, differing only in the field
  name they interpolated. One `requireField` covers all four, and the
  numbered-range message now names the Graph field
  (`numberOfOccurrences`) rather than the local variable.
- The "Multiple BYDAY ordinals" rule was thrown verbatim from both
  `splitRelativeByDay` and `byweekdayToTokens`. Both now call
  `assertSingleOrdinal`.

`GRAPH_DAY_ORDER` and `RRULE_WEEKDAY_TOKENS` stay as they are: the first
carries Graph's Sunday-first ordering and the second rrule's Monday-based
weekday indexes, which are separate facts rather than restatements of the
token map.

VERDICT: PASS

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gVNGW5WLSrqPjZaT1ReM4
@tyler-dane
tyler-dane marked this pull request as ready for review October 26, 2026 10:09
@tyler-dane tyler-dane added the agent-automerge Agent-loop finished; merge-guard may squash-merge label Oct 26, 2026 — with Claude
@tyler-dane
tyler-dane enabled auto-merge October 26, 2026 10:09

Copy link
Copy Markdown
Contributor Author

Technical-debt sweep summary for the 2026-10-19 → 2026-10-26 window (49 merged commits reviewed).

Debt addressed in this PR

Item Smell Where
graphPreferTimeZone normalizer option Speculative generality: one value in every caller, tautological guard, unreachable branch microsoft-event.normalizer.ts, reader/writer adapters
RRULE_TO_GRAPH_DAY Duplicated inverse table, drift risk microsoft-recurrence.ts
requireDayOfMonth / requireMonth / requireCount / requireEndDate Four-way copy-paste differing only in a field name microsoft-recurrence.ts
"Multiple BYDAY ordinals" throw Duplicated rule in two readers microsoft-recurrence.ts

Reviewed and deliberately left alone


Generated by Claude Code

@tyler-dane
tyler-dane added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 258922a Oct 26, 2026
28 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-i9ovqz branch October 26, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-automerge Agent-loop finished; merge-guard may squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants