Skip to content

fix(tasks): keep monthly repeats on one task per month - #1309

Open
saariuslystoned wants to merge 4 commits into
openclaw:mainfrom
saariuslystoned:fix/tasks-repeat-month-end
Open

saariuslystoned wants to merge 4 commits into
openclaw:mainfrom
saariuslystoned:fix/tasks-repeat-month-end

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

gog tasks add --repeat monthly (also --recur monthly and --recur-rrule FREQ=MONTHLY) materializes each occurrence with time.AddDate(0, n, 0). AddDate normalizes an overflowing day into the following month, so a series that starts on a day the target month lacks skips that month and lands early in the next:

$ gog tasks add <list> --title Rent --due 2026-01-31 --repeat monthly --repeat-count 4
Rent (#1/4)  2026-01-31
Rent (#2/4)  2026-03-03   <- February missing
Rent (#3/4)  2026-03-31   <- second March task
Rent (#4/4)  2026-05-01   <- April missing

Yearly series from February 29 move to March 1 in common years for the same reason. Any start on the 29th, 30th or 31st is affected. --repeat-until series are affected too, and can end with fewer tasks than months.

Change

addRepeat now adds calendar months and keeps the start's day of month, using the target month's last day when the month is shorter: January 31 is followed by February 28, March 31 and April 30. Each occurrence is still computed from the start date, so later months return to the 31st. Yearly series step 12 months, so February 29 falls on February 28 in common years. Daily and weekly series are unchanged, and so is the time of day for --due values that carry a time.

Why clamp, not RFC 5545 skipping

RFC 5545 §3.3.10 says a recurrence rule that generates an invalid date, such as February 30 or February 29 in a common year, must ignore that instance and must not count it. Under that rule, FREQ=MONTHLY;COUNT=4 from January 31 gives January 31, March 31, May 31 and July 31, and a February 29 yearly series occurs only in leap years.

This PR clamps instead, for three reasons:

  • --recur-rrule is not an RRULE engine. parseRepeatRRule accepts only FREQ and INTERVAL and rejects BYMONTHDAY, COUNT, UNTIL and every other part. Its help calls it an "Alias for --repeat cadence via RRULE", so all three flags share one cadence rule.
  • The Tasks API stores no recurrence (Feature request: true recurring Google Tasks (single task with recurrence metadata) #401). gog materializes one task per occurrence, and --repeat-count 4 reads as "four monthly tasks". Clamping keeps one task per month. Skipping would spread four tasks over seven months, and a February 29 yearly series would produce one task every four years.
  • Clamping is what common add-months functions do: java.time.LocalDate.plusMonths, .NET DateTime.AddMonths, date-fns addMonths, dateutil relativedelta.

Either choice fixes the current output, which follows neither rule (two March tasks and none in February). If you prefer RFC 5545 skipping, the change is confined to addMonthsClamped and the expected dates in the three tests.

Evidence

  • Regressions in internal/cmd/tasks_repeat_test.go drive TasksAddCmd against an httptest Tasks server and check each inserted due: monthly from Jan 31 with --repeat-count, --recur-rrule FREQ=MONTHLY with --repeat-until and a time of day, and yearly from Feb 29. All three fail on main (e8428c3) with the schedules above and pass with this change.

  • The target month is computed in UTC, then the start's clock time and location are applied. Building the first of the month at the start's clock time in a local zone can land in the previous month where daylight saving begins at midnight. America/Asuncion skipped 00:00 on 2023-10-01, so a local --due "2023-09-15 00:00" monthly series stayed in September. TestAddMonthsClampedIgnoresMidnightDSTGap covers this: it fails on the first revision of this PR and passes on 80b6440. Date-only and offset --due values parse in UTC or a fixed zone and were never affected.

  • A built bin/gog from main and from this branch was run against a local Tasks stand-in through GOG_GOOGLE_API_BASE_URL, with an empty GOG_HOME and the file keyring. The stand-in is not Google and logs each inserted due:

    main:   due=2026-01-31T00:00:00Z, 2026-03-03T00:00:00Z, 2026-03-31T00:00:00Z, 2026-05-01T00:00:00Z
    branch: due=2026-01-31T00:00:00Z, 2026-02-28T00:00:00Z, 2026-03-31T00:00:00Z, 2026-04-30T00:00:00Z
    
  • make ci passed locally on 80b6440 (macOS arm64, go1.27.3): fmt-check, lint, deadcode, the full test suite, docs-check and agent-skills-check.

The schedule is computed locally, before any request, so the change does not depend on Google Tasks behavior. No live Google account was used.

🤖 Generated with Claude Code

addRepeat used time.AddDate for monthly and yearly series. AddDate
carries an overflowing day into the next month, so a monthly series from
January 31 produced January 31, March 3, March 31 and May 1, and a
February 29 yearly series moved to March 1. Add calendar months instead
and use the target month's last day when it is shorter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: ready, awaiting a maintainer decision.

What this changes

This PR clamps monthly and yearly task dates to the last valid day of shorter months.

Example: Create four monthly Rent tasks starting on 2026-01-31.

  • Before: Due dates are January 31, March 3, March 31, and May 1.
  • After: Due dates are January 31, February 28, March 31, and April 30.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and supplied CLI evidence are sound, with no remaining code findings; readiness depends on the owner's recurrence-policy decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The contributor reports running built main and branch CLIs on macOS arm64 through the real Tasks client against a local endpoint, whose recorded inserted due values demonstrate corrected monthly scheduling; this proves local date generation without claiming live Google behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Monthly task series can omit short months and place two tasks in another month; leap-day yearly tasks move into March.
Reason: Correcting overflow has clear value, but uniform clamping changes the established recurrence output and needs the area owner's choice between the explicitly presented date policies.

Merge readiness

⏳ Ready, awaiting maintainer decision

This PR fixes a current scheduling defect, and the prior changelog finding is resolved; an area owner should confirm the proposed short-month semantics.

Priority: P2
Reviewed head: 80b6440e99eedb34f460e19a14225c07d36c97bb
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should monthly and yearly materialized task cadences clamp invalid dates, including when selected through --recur-rrule?
  • Recommendation: Approve uniform clamping: Keep one task per requested period and restore the original day in later months, as implemented and documented here.
  • Why: The contributor explains clamping versus RFC-style skipping, but the existing owner decisions establish only materialization and shared aliases, without choosing between those date semantics.

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Tasks CLI parses recurrence flags, expands dates locally, and inserts a separate Google Task for each occurrence.

flowchart LR
A[Tasks add flags] --> B[Date and cadence plan]
B --> C[Repeat schedule]
C --> D[Clamped calendar dates]
D --> E[Tasks API inserts]
E --> F[Created tasks and CLI output]
Loading

Technical review

Best possible solution:

Confirm one short-month rule for all cadence aliases and retain the focused repair in the existing schedule owner.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly explains the overflowing dates, and the contributor supplies matching before-and-after CLI traces; no target code was run during this read-only review.

Is this the best way to solve the issue?

The patch is a small shared-owner repair with distinct regression coverage; its remaining question is the intended calendar semantics rather than an identified implementation defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31.

Provenance checked

  • Monthly and yearly date expansion changes intended behavior with a stated reason (2cdeb8b: The original feature implemented materialized repeats with AddDate; the original PR records no deliberate invalid-date policy.)
  • Shared recurrence aliases keeps the original intent (2fe9d95: The landed alias feature intentionally maps FREQ and INTERVAL onto the existing materialized cadence scheduler.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2fe9d95 adds internal/cmd/tasks_repeat.go:141 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2fe9d9524e04; files: internal/cmd/tasks_repeat.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove status: ⏳ waiting on author: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • P2: Monthly dates near month end and yearly leap-day dates generate incorrectly placed tasks, with limited impact on the broader CLI.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-08T12:45:56.337Z sha e03feb3 :: blocked before merge. :: [P3] Credit the contributor in the Unreleased entry

Reviewed November 8, 2026, 8:15 AM ET / 13:15 UTC (Revision 2).

saariuslystoned and others added 2 commits November 8, 2026 07:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
addMonthsClamped built the first day of the target month at the start's
clock time in the start's location. Where daylight saving begins at
midnight (America/Asuncion on 2023-10-01), that local time does not
exist and normalized into the previous month, so a local 00:00 monthly
series stayed in September. Compute the target month in UTC, then apply
the original clock and location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Pushed 80b6440: the month-end clamp now picks the target month in UTC, so a local midnight start in a zone where daylight saving begins at midnight (America/Asuncion, 2023-10-01) no longer stays in the same month. A regression test covers it, the CHANGELOG line has the contributor credit, and the body now states the RFC 5545 skip rule next to the clamp choice. make ci passes locally.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant