Skip to content

fix(macos): decode server occurrence ids in the split projection - #5207

Merged
tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-e7rxq0
Nov 10, 2026
Merged

tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-e7rxq0

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

No issue: finding from the scheduled tech-debt sweep over the 17 merges after
the 2026-11-09 sweep (#5189 to #5206).

What and why

The thisAndFollowing split projection in ProjectRecurringEdit.swift parsed
and composed app-facing occurrence ids with |. The canonical format is
${eventId}::${recurrenceId}, owned by packages/core/src/util/occurrence-id.ts:
the backend mints it at event-list.translation.ts:68 and decodes it back into
a single-occurrence command target at event-command.translation.ts:135. On a
real server-minted id, Swift's split(separator: "|") returns a single element,
so .last was the whole id and the intended scheduleStartString fallback was
unreachable. That gave two silent divergences: the whole id became the splitAt
fed to SeriesSplit.remainderMasterId, so macOS hashed
<seriesId>:<seriesId>::<stamp> while sync hashed <seriesId>:<stamp>
(series-exception.ts:176) and one split resolved to two different remainder
masters, defeating the deterministic id whose whole purpose is that it resolves
to one; and repointed occurrences became <newMaster>|<oldMaster>::<stamp>,
which decodeOccurrenceId rejects, so a later scope-"this" action on one
escalated to the whole series exactly as that module's comment warns. No test
caught it because every macOS split fixture composed its own ids with |, the
demo-seeder convention, so the projection agreed with its fixtures and diverged
only against the real server. OccurrenceIdFormat now mirrors the core codec in
CompassKit with the same shape validation, so a nested local id falls back
instead of being guessed at; the projection reads both formats, which keeps
demo-seeded | ids working, and only ever mints the canonical one. Two guards
come with it: a pinned cross-language vector for remainderMasterId, which was
previously unpinned on the Swift side so CryptoKit and the hand-rolled SHA-256
in core could drift apart unnoticed, and a Linux-runnable check tying the Swift
separator to core's. Deliberately left alone and recorded in
judged-fine.md: the | demo-seeder convention itself (converting it would
change what a demo store holds and touch its UI-test launch args, a contract
decision rather than debt) and the timed/all-day normalization difference in the
non-composite fallback (needs a date-parsing decision on the Swift side).

Verify

VERDICT: PASS from bun run verify --strict.

Checks run: test:scripts:fast, type-check, lint, knip. Checks skipped:
none. No PRE-EXISTING or FLAKY lists: nothing failed.

CI-only, so unverified locally and the point of the required macos check on
this PR: test:macos and test:macos:packages. Both Swift test files here
(OccurrenceIdFormatTests, the updated ProjectRecurringEditTests) and the
updated EventsStoreRecurringTests first compile and run there, since this
machine has no Xcode.


Generated by Claude Code

The thisAndFollowing split projection parsed and composed app-facing
occurrence ids with `|`. The canonical format is `${eventId}::${recurrenceId}`,
owned by packages/core/src/util/occurrence-id.ts: the backend mints it in
event-list.translation.ts and decodes it back into a single-occurrence command
target in event-command.translation.ts.

On a real server-minted id, Swift's `split(separator: "|")` returns one
element, so `.last` is the WHOLE id and the intended schedule-start fallback
was dead code. Two consequences:

- The whole id became the `splitAt` fed to `SeriesSplit.remainderMasterId`, so
  macOS hashed `<seriesId>:<seriesId>::<stamp>` while sync hashed
  `<seriesId>:<stamp>`. The deterministic remainder-master id exists so one
  split always resolves to one master; instead macOS and the server derived
  different masters and a split forked in two.
- Repointed occurrences became `<newMaster>|<oldMaster>::<stamp>`, which
  `decodeOccurrenceId` rejects, so a later scope-"this" action on one silently
  escalated to the whole series.

No test caught it because every macOS split fixture composed its own ids with
`|` (the demo-seeder convention), so the projection agreed with its fixtures
and diverged only against the real server.

`OccurrenceIdFormat` now mirrors the core codec in CompassKit, validating the
id shape as core does so a nested local id falls back instead of guessing. The
projection reads both formats, keeping demo-seeded `|` ids working, and only
ever mints the canonical one. Guards: a pinned cross-language vector for
`remainderMasterId` (CryptoKit on one side, a hand-rolled SHA-256 on the
other, previously unpinned on the Swift side) and a Linux-runnable check tying
the Swift separator to core's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQFVTgaGuPMYCVA35kD
@tyler-dane
tyler-dane enabled auto-merge November 10, 2026 11:18
@tyler-dane
tyler-dane added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit aa44139 Nov 10, 2026
32 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-e7rxq0 branch November 10, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants