Skip to content

Store workout plans by date - #6

Merged
lagrangee merged 1 commit into
mainfrom
codex/planned-day-canonical-storage
Aug 30, 2026
Merged

lagrangee merged 1 commit into
mainfrom
codex/planned-day-canonical-storage

Conversation

@lagrangee

Copy link
Copy Markdown
Owner

Summary:

  • make Athlete-local Planned Days the canonical schedule truth while retaining seven-day Plan Revisions as immutable prescription provenance
  • add validated and idempotent Planned Day move APIs plus MCP readback, Calendar provenance, export, and D1 migration 0013
  • preserve partial-overlap semantics and bound D1 Agent writes below the query budget

Validation:

  • npm run release-check
  • Agent Planned Day move: 24 D1 queries with 201 Sessions (budget 45, limit 50)
  • browser smoke passed in a real local Chromium run

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T06:16:31.398103Z 8b9e673 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b9e6738b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/planned-days.js
const sourceDate = move?.source_date;
const targetDate = move?.target_date;
if (typeof sourceDate !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(sourceDate)) errors.push({ path: "/source_date", message: "source_date must be YYYY-MM-DD" });
if (typeof targetDate !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(targetDate)) errors.push({ path: "/target_date", message: "target_date must be YYYY-MM-DD" });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject nonexistent target dates before moving workouts

Validate calendar semantics rather than only the YYYY-MM-DD shape. A target such as 2027-99-99 passes this check, is treated as an available no-plan day, and can be applied; the source workout is then removed from its valid date and stored under a date that schedule endpoints will reject, effectively making the workout inaccessible.

Useful? React with 👍 / 👎.

Comment thread src/plan.js
Comment on lines +74 to 78
if (!day || day.kind === "no_plan" || slot === null) return {
date, weekday: weekdayKey(date), kind: "no_plan", title: null, module_count: null, estimated_duration_min: null,
prescription_ref: null, scheduled_workout_key: null, session_key: null,
is_due: false, is_overdue_unstarted: false, source_ref: `schedule:${date}:no_plan`, revision_key: null,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve move provenance when the source becomes no-plan

Include moved_to_date in this branch. Moving a workout onto an allowed no-plan target leaves the source as kind: "no_plan", but this early return drops the provenance written by applyPlannedDayMove; consequently the Agent schedule violates its moved-entry shape and the MCP apply flow reports readback_mismatch even though the mutation succeeded.

Useful? React with 👍 / 👎.

Comment thread mcp/bridge.mjs
Comment on lines +326 to +329
const from = args.move.source_date < args.move.target_date ? args.move.source_date : args.move.target_date;
const to = args.move.source_date > args.move.target_date ? args.move.source_date : args.move.target_date;
try {
const schedule = await this.getSchedule({ from, to, expand: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Read back distant move dates without one oversized range

Read the two affected dates separately, or constrain validation to the schedule limit. The move API permits any future target, but this constructs one inclusive schedule request; when the dates are more than 366 days apart, the schedule endpoint rejects the request after the move has already succeeded, so the advertised apply-and-readback tool deterministically returns a failed verification.

Useful? React with 👍 / 👎.

@lagrangee
lagrangee merged commit c5fa3b5 into main Aug 30, 2026
1 check passed
@lagrangee
lagrangee deleted the codex/planned-day-canonical-storage branch August 30, 2026 06:17
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.

1 participant