---
phase: 11-individual-planning
plan: 01
subsystem: planning
tags: [planning, events, postgres, sqlc, htmx, templ]

requires:
  - phase: 10-events
    provides: ListUserEventsRange and tablo Events deep-link target
provides:
  - Protected /planning route
  - 14-day personal agenda window with previous/today/next navigation
  - Owned-only event aggregation across tablos
  - Event source links back to tablo Events tab
affects: [planning, events, router, templates]

tech-stack:
  added: []
  patterns:
    - "Planning page handlers use injected Now for deterministic local-date tests."
    - "Planning event rows use ListUserEventsRange and link back to /tablos/{id}/events?month=YYYY-MM."

key-files:
  created:
    - backend/internal/web/handlers_planning.go
    - backend/internal/web/handlers_planning_test.go
    - backend/templates/planning.templ
    - backend/templates/planning_forms.go
  modified:
    - backend/internal/web/router.go
    - backend/cmd/web/main.go

key-decisions:
  - "Use a dedicated PlanningDeps with optional Now injection so date-window behavior is deterministic in tests."
  - "Keep /planning as a normal protected full page inside Layout instead of an HTMX-only fragment."
  - "Use Phase 10 ListUserEventsRange unchanged so cross-tablo aggregation stays filtered by tablos.user_id."

patterns-established:
  - "Personal planning navigation uses start=YYYY-MM-DD for shareable 14-day windows."
  - "Planning agenda rows show compact event metadata and source tablo links without exposing event descriptions."

requirements-completed: [PLAN-01, PLAN-02, PLAN-03, PLAN-04]

duration: ~15min
completed: 2026-05-16
---

# Phase 11: Individual Planning Plan 01 Summary

**Protected Go/HTMX planning agenda with owned cross-tablo event aggregation and 14-day navigation**

## Performance

- **Duration:** ~15 min
- **Started:** 2026-05-16T05:22:55Z
- **Completed:** 2026-05-16T05:38:00Z
- **Tasks:** 2
- **Files modified:** 15

## Accomplishments

- Added RED DB-backed planning tests for auth, default 14-day range, ordering, ownership, navigation links, empty state, invalid date fallback, and source tablo links.
- Added `PlanningPageHandler` and `PlanningDeps` with authenticated-user aggregation through `ListUserEventsRange`.
- Added server-rendered planning templates for the restrained agenda UI required by `11-UI-SPEC.md`.
- Wired `/planning` into the protected router group and updated all router call sites.

## Task Commits

Each task was committed atomically:

1. **Task 1: Add RED coverage for protected planning agenda behavior** - `c5c3bbe` (test)
2. **Task 2: Implement the protected planning route, handler, view models, and agenda template** - `2989c0b` (feat)

## Files Created/Modified

- `backend/internal/web/handlers_planning_test.go` - Adds DB-backed planning route and agenda tests.
- `backend/internal/web/handlers_planning.go` - Adds `/planning` handler, date parsing, and owned aggregation query.
- `backend/templates/planning.templ` - Adds the server-rendered planning agenda page.
- `backend/templates/planning_forms.go` - Adds planning agenda view models and URL/date helpers.
- `backend/internal/web/router.go` - Mounts `/planning` in the protected route group and accepts planning deps.
- `backend/cmd/web/main.go` - Wires `PlanningDeps` into the production router.
- Existing web test helpers - Updated `NewRouter` call sites for the new dependency parameter.

## Decisions Made

- `Today` links to `/planning`, while previous/next windows use `start=YYYY-MM-DD`.
- The event link month is derived from each event's `event_date`, not from the current planning window.
- Invalid `start` query values fall back to today's local date instead of returning an error.

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None.

## User Setup Required

None - no external service configuration required.

## Verification

- `cd backend && go test ./internal/web -run 'TestPlanning' -count=1` failed in RED before implementation because `PlanningDeps` and router wiring did not exist.
- `cd backend && just generate && go test ./internal/web -run 'TestPlanning' -count=1` passed after implementation.
- `cd backend && git diff --check` passed.

## Self-Check: PASSED

- Key created files exist on disk.
- Task commits exist for `11-01`.
- PLAN-01 through PLAN-04 are covered by automated tests or implemented behavior.
- No open deviations.

## Next Phase Readiness

The first planning page slice is ready for Plan 11-02 full backend verification and browser UAT approval.

---
*Phase: 11-individual-planning*
*Completed: 2026-05-16*
