# Implementation Plan - Fix `r.replace is not a function`

## Phase 1: Reproduction & Test Setup [checkpoint: df0ddaf]
- [x] Task: Create a reproduction test case 1a36c64
    - [x] Create a new test case in `icalendar_test.ts` that mocks an event with a non-string `rrule` property (e.g., an object or number).
    - [x] Run the test to confirm it fails with the expected `TypeError`.
- [x] Task: Conductor - User Manual Verification 'Reproduction & Test Setup' (Protocol in workflow.md)

## Phase 2: Implementation [checkpoint: 1c48f78]
- [x] Task: Implement defensive check in `icalendar.ts` d7401dd
    - [x] Modify `expandRecurrences` function to check if `rruleStr` is a string before calling `.replace()`.
    - [x] If `rruleStr` is not a string, log a warning and return the original event (non-recurring fallback).
    - [x] Run the reproduction test again to confirm it passes.
- [x] Task: Conductor - User Manual Verification 'Implementation' (Protocol in workflow.md)

## Phase 3: Verification & Cleanup
- [x] Task: Verify fix and check for regressions
    - [x] Run all tests in `icalendar_test.ts` to ensure existing functionality is preserved.
    - [x] (Optional) Verify with actual calendar sync if possible/safe.
- [x] Task: Conductor - User Manual Verification 'Verification & Cleanup' (Protocol in workflow.md)