---
name: "task-planning-rollup"
type: task
description: "Scheduled lift of the planning records that task-cycle-planning and task-owner-standup write into Linear documents into assoc-one/claude-ops under data/planning, so they survive the documents' replacement and reach the planning trend view (osclaude.vitals Phase 5). Mondays it fetches each team's cycle-goal documents for the current and two prior ISO weeks and lifts the planning-week records; every weekday it lifts the owner-queue block from owner.standup-agenda. It then runs npm run planning:rollup, validate:planning and the planning-dashboard rebuild, opens one data PR on a backing ticket, and routes it to Relay under the no-judgement merge rule. A self-contained task with no skill. Cloud Routine on a claude-ops clone with the Linear connector. Never edits a Linear document, never hand-writes a record, never merges in the driver. Runs only after APP-2444 is Done. Owned by Relay."
license: CC BY-NC-SA 4.0
---

You are running the **planning rollup** for Aled's delivery teams, on Relay's behalf. Two connector-only tasks write planning records into Linear documents as fenced JSON blocks: `task-cycle-planning` writes one `planning-week` block into each `<team>.cycle-goal.YYYY-Www` document (open at the commit, closed at the first run after the cycle's `endsAt`), and `task-owner-standup` writes one `owner-queue` block at the foot of `owner.standup-agenda`, which it full-replaces every weekday. Neither can reach the repo. Without this lift, each day's Owner-queue snapshot is destroyed by the next morning's replace, and the weekly records never reach the planning trend view (APP-2425). This task lifts both into `assoc-one/claude-ops` under `data/planning/` with the repo's own script, validates them, rebuilds the dashboard data, and opens a data PR (APP-2437, serving the Owner's 2026-10-19 rulings on APP-2400).

**Write scope — what you may and may not change.** You **read** Linear documents and never edit one: not a block, not a line, not a typo. You write, in the repo, **only what the scripts write** — files under `data/planning/<team>/`, `data/planning/owner-queue/` and `dashboard/planning/planning.json` — on one branch, as one data PR. You file and update **one backing ticket per PR**. You never hand-write or hand-correct a record: a block that is wrong is reported, and the fix belongs to the task that wrote it. You never commit a fetched document — the goal documents and the agenda carry client names and commercial detail, so they live outside the repo working tree and are never staged (APP-2426, PR #469). You **never merge** — the merge is the Relay leg's, run as its own subagent (Step 6). You never write a cycle, a cycle-goal document, the stand-up agenda or any canon artefact.

## Step 0 — Fire time, mode and the precondition

1. **State the actual fire time against the cadence** (`core-operating-model`, the catch-up contract): this task's cadence is Monday after the cycle-planning commit, and Tuesday to Friday after the stand-up agenda write (*Setup*). Resolve today's date and weekday in **Europe/London**.
2. **Choose the mode from the London weekday**, never from the cron that fired you:
   - **Monday** → the *cycle-goal pass* (Step 2) **and** the *owner-queue pass* (Step 3).
   - **Tuesday to Friday** → the *owner-queue pass* only.
   - **Saturday or Sunday** → report "no rollup on a weekend: the agenda is not written and no cycle boundary record is due" and stop.
   - **On demand**, the invocation may name either pass or both; run what it names, on any weekday, and say so.
3. **Precondition — APP-2444 must be Done.** Read `get_issue("APP-2444")`. That ticket stops `scripts/planning-rollup.ts` writing outside `--out` when a block's `team` field is a path; Prism reproduced the escape on APP-2426 at `4f5fef1`, and it becomes a live risk the moment the script runs unattended on whatever the documents contain. Where APP-2444 is **not** Done, report "waiting on APP-2444 (`<state>`) — nothing lifted" and stop: no fetch, no branch, no ticket. This check is permanent rather than removable: once APP-2444 is Done it passes in one read.

## Step 1 — Prepare the checkout and the inputs folder

1. In the `claude-ops` clone: `git fetch origin`, then cut a working branch off fresh `origin/main` (named in Step 6, once the backing ticket exists; until then work on a local branch). Record `origin/main`'s short SHA — every repo statement in your report is made against it.
2. Run `npm ci`. A fresh cloud clone has no `node_modules`, and every script below runs under `tsx`, a dev dependency (repo `CLAUDE.md`, *Running scripts*).
3. Create an **inputs folder outside the repo working tree** (the session's scratch directory, never a path under the clone). Every fetched document is saved there, verbatim, **named exactly after its Linear document title plus `.md`** — `apps.cycle-goal.2026-W44.md`, `owner.standup-agenda.md`. The name is load-bearing: the script checks that a `planning-week` block's team and week match a file named `<team>.cycle-goal.<week>`, and refuses a mismatch by name. Saving under any other name switches that check off.

**What "verbatim" means here, because the connector has no save-to-file path.** `get_document` returns a document's content into the run's context and nothing more — there is no connector-to-file call — so "saved verbatim" is a write the run makes itself out of what it is holding, and on a large document that is a transcription, with a transcription's risk (**reported**: the 2026-10-21 owner-queue pass, whose agenda carried about 270 items, had no non-manual path to a full-body file — APP-2516). Two forms are acceptable and a third is not:

- **Full body.** Where the run holds the whole document, write it to the inputs folder with the session's own file write, under the `<document title>.md` name the rule above fixes. The name rule is load-bearing and is unchanged by this.
- **Block-only.** Where the body is too large to re-emit faithfully, the input may be the **fenced block alone** — the `owner-queue` block, or the document's `planning-week` block — saved under that same `<document title>.md` name. The script reads a document for its fenced blocks, so a block-only input carries everything the lift needs (`scripts/planning-rollup.ts`, APP-2426 — **premise unverified, no repo is readable from this surface**; confirm the block-only input is accepted against the script before relying on it). Report the input as **block-only** by name, and check the block's own item count against the count the document states — the 2026-10-21 pass did exactly that, and the check is what makes the short form safe.
- **Never a retyped record.** A record is never re-keyed, re-ordered, reformatted or repaired by hand on the way to the file, in either form. That is the *script is the only writer of a record* guardrail and it is unchanged: a block that is wrong is passed through and reported, never corrected here.

## Step 2 — Cycle-goal pass (Mondays)

1. **The weeks.** Let **N** be the ISO week containing today's London date — the week whose cycle opened at last night's boundary (`task-cycle-planning` names a goal document by the ISO week of the Monday its cycle opens). Fetch weeks **N, N-1 and N-2**, because the two writes land on different days: week N's record is opened at this week's commit (normally given in the Monday session or the preceding Friday's `work.Planning`); week N-2's record was closed by last Friday's ceremony, the first run after its `endsAt`; and week N-1 is re-read so a commit given after last Monday's run is still lifted. The script is idempotent and never rewrites an unchanged file, so re-reading a week already lifted costs a read and changes nothing.
2. **The teams.** The four delivery teams that run cycles — Apps, A1, MBN and Mr Pritchard — whose goal documents are stemmed `apps`, `a1`, `mbn` and `mrp` (the stems in PR #469's live run against the four `*.cycle-goal.2026-W43` documents, 2026-10-19 — **reported**, not re-read here). Where `task-cycle-planning`'s team list and this one disagree, the ceremony's list wins and the difference is a line in your report, never a silent skip and never a guessed stem.
3. **Fetch each document by exact title.** For each team and week, search the documents store for the exact title `<stem>.cycle-goal.<YYYY-Www>`. Exactly one match → `get_document` and save its content verbatim to the inputs folder under that title. **No match** → record "no goal document" for that team and week; there is nothing to lift, and `task-cycle-planning` already reports a missing goal document in its own summary (APP-1273). **More than one match** → record the ambiguity by title and lift neither. **A read that overflows or errors** (`get_document` hard-errors past roughly 61k characters — `convention-linear`, *Reading Linear safely*) → record it by title as unread; never lift from a partial body.
4. **Classify each fetched document before the run — so an expected absence is reported as expected and a real one fails by name.** Look for a fence line whose info string's first word is `planning-week`:
   - **A `planning-week` fence is present** (one or several) → pass the file to the script. The script decides whether it holds exactly one valid block.
   - **No fence, and `data/planning/<stem>/<week>.json` already exists on `origin/main`** → skip and report "no `planning-week` block; the repo record from the backfill stands". This is the state of every document written before the block canon was saved — all four `*.cycle-goal.2026-W43` documents among them, committed at 08:56Z on 2026-10-19 under the earlier format (PR #469).
   - **No fence, week N, and no `Committed by Aled — <date>` line in the document** → skip and report "week N uncommitted — no record to lift yet". A proposal awaiting approval carries no block by design (`task-cycle-planning`, *The planning-week record*).
   - **No fence in any other case** — a committed document with no record, or a past week with neither a block nor a repo record → **pass it to the script anyway**, so the absence is reported by input name and counted as a failure. Never drop it from the run.

## Step 3 — Owner-queue pass (every weekday)

1. Fetch `owner.standup-agenda` (the standing document on the os.Claude project) by exact title and save it verbatim to the inputs folder as `owner.standup-agenda.md`.
2. Pass it to the script **whether or not it carries an `owner-queue` block**. `task-owner-standup` emits the block on every run (Step 3, *The record block*), so an absent one is a failure to report by name — and an unlifted snapshot is lost at the next morning's replace, which is the whole reason this pass is daily.
3. **Check the block's `date` against today's London date** after the run. Where they differ, the agenda was not rewritten today: say so, name the date the block carries, and treat the lift as that date's snapshot. The script writes `owner-queue/<date>.json` from the block's own `date` and leaves an identical file untouched, so a stale agenda re-lifted produces no change rather than a mislabelled one.

## Step 4 — Run the rollup

Run, from the clone root, with every input on one line:

```
npm run planning:rollup -- --cycle-goal <file.md> [--cycle-goal <file.md> …] [--owner-queue owner.standup-agenda.md] --out data/planning
```

Use the flags exactly as merged on `origin/main` (`scripts/planning-rollup.ts`, APP-2426, merged `6731f23`): `--cycle-goal` repeats, once per document; `--owner-queue` may be given **once**; `--out` defaults to `data/planning/` and is passed explicitly so the target is never inferred. An unknown flag, a flag with no value or a run with no inputs throws before anything is read. On the owner-queue-only weekdays, pass `--owner-queue` alone.

**Read the output line by line — the exit code is not the verdict.** The script prints one line per input: `<input>: <kind>: written <path>` or `unchanged <path>` on success, and `<input>: <kind>: <field path>: <message>` on stderr for each problem, then a summary `[planning-rollup] N input(s): W written, U unchanged, F failed`. It exits **1 when any input failed**, and it **still writes every valid input** — one bad document never holds back the rest. So:

- Exit 0 → every input written or unchanged.
- Exit 1 → carry on with what was written, and report each failure by input name and message. Two messages have a known cause, and the report names it: **`has no \`planning-week\` block` / `has no \`owner-queue\` block`** — the writing task did not emit it; and **`is not valid JSON (it holds Linear <issue> markup …)`** — a ticket ID inside the block was rewritten by Linear on save, which both writing tasks are required to read back for. **`is "open", but … is already closed`** is the script refusing to downgrade a closed record (the close is always the later write) and is reported as a refusal, not a document defect. A team/week mismatch with the file name, or two inputs lifting to one file, is reported verbatim.
- Any other non-zero exit, or a thrown usage error → stop, report the output verbatim, open nothing.

Never edit an output file to make a failure pass, and never re-run with a document removed to turn exit 1 into exit 0.

## Step 5 — Validate, rebuild, and bound the diff

1. `npm run validate:planning` over the whole tree. It validates planning-week records against `planning-week.v1` plus the cross-field rules, and `owner-queue/` snapshots against `owner-queue.v1`, and prints `[validate-planning] N record(s) checked: V valid, I invalid (Q of them owner-queue snapshots)`. **Non-zero → stop**: report each `<file>: <field path>: <message>` line, open no PR, and leave the working tree uncommitted.
2. `npm run build:planning-dashboard` to regenerate `dashboard/planning/planning.json`, then `npm run build:planning-dashboard -- --check`, which must print `… is up to date`. The generator reads only planning-week records and `changelog.json`, never `owner-queue/`, so on an owner-queue-only weekday the dashboard file normally does not change — that is expected, not a fault. A generator that throws (an invalid record, a mismatched stored `unplanned_share`) → stop and report.
3. **Bound the diff.** `git status --porcelain` may show changes **only** under `data/planning/<team>/`, `data/planning/owner-queue/` and to `dashboard/planning/planning.json`. Anything else — a fetched document, a stray file, a change outside those paths — means the run went wrong: stop, report the paths, commit nothing.
4. **No change at all → no PR.** Report "nothing new to lift" with the per-input outcomes and end at Step 7.

## Step 6 — Open the data PR and route it to Relay

1. **File the backing ticket first** — a PR with no backing ticket gives Prism and the merge gate nothing to read (`skill-merge-pr`, *Context*; `convention-ticket`, *Obligations belong in structure, not prose*). Team Apps, project os.Claude, title `OPS: planning rollup data — <YYYY-MM-DD>`, label `type:task`, no cycle, body from the `type:task` template with both literal checkbox sections:
   - `## Acceptance criteria` — the rollup ran on the inputs listed (named) with the per-input outcomes recorded; `validate:planning` passes; `build:planning-dashboard -- --check` passes; the diff touches only `data/planning/<team>/`, `data/planning/owner-queue/` and `dashboard/planning/planning.json`; no fetched Linear document is committed.
   - `## Definition of done` — PR against `assoc-one/claude-ops`; CI present, concluded and green; review verdict posted.
   Read the created ticket back and repair any field the create dropped.
2. **Branch, commit, push, PR.** Branch `claude/<ticket-id>` off the `origin/main` recorded in Step 1 (`convention-github`, *Branch naming* — a Cloud Routine cuts one per ticket). Commit only the paths Step 5 allowed. The PR body carries: the ticket link; the mode and fire time; the exact `planning:rollup` command; each input's outcome line; every skip from Step 2 with its reason; the `validate:planning` summary line; the dashboard `--check` line; and the `origin/main` SHA it was cut from.
3. **Hand to Prism.** Move the ticket to In Review with executor `agent:PR-1SM`. Then run the review as a **separate, tool-scoped Prism subagent** that loads `skill-review-pr` and posts its `[qa] HEAD: <sha7>` verdict at the live head — never in your own context (`convention-agent-runtime`, *Isolation*; `routine-delivery-loop`'s leg discipline).
4. **Route on the verdict — the no-judgement merge rule.** A data lift from Owner-approved documents meets no human-review criterion by construction: no `Human gate: required` marker, no embedded human sign-off. So where Prism is clean at the live head and nothing is blocked, route the ticket to `agent:R3-LAY` and run the **Relay merge leg as its own subagent**, loading `skill-merge-pr`. **No Owner signal is asked for, and you never merge yourself** (`skill-merge-pr`, *Context*, and its guardrail *A no-judgement merge never goes to the Owner, and the operator never merges*; `skill-operating-loop` step 4; APP-1756, APP-2427). Where Prism flags or blocks, or the merge leg reports not-ready, leave the ticket exactly where that leg routed it, report the hand-off, and stop — the delivery loop and the operator lanes pick it up from there.
5. **Every Owner-facing channel stays with you, the driver.** Each subagent prompt says in so many words that the subagent may not message the Owner, send a file, or push a notification — the whole class, not one tool (`convention-agent-runtime`, *Isolation*).

One PR per run, merged the same day where the legs are clean. A branch holding an unmerged snapshot is a snapshot not yet in `main`, and five small PRs a week are cheaper to review than one that accretes across days and needs a fresh verdict at each new head.

## Step 7 — Report

One short report, no preamble: fire time against cadence and the mode run; the APP-2444 read; `origin/main` SHA; inputs fetched, by title, and every input skipped with its Step 2 reason; each `planning:rollup` outcome line and the summary; the `validate:planning` and dashboard `--check` lines; the backing ticket and PR, with the Prism verdict, the route taken and the merge outcome — or the hand-off where a leg stopped; and the owner-queue block's `date` against today. Mark each figure **observed** (read this run) or **reported** (taken from another surface), per `convention-comms-owner`.

## Step 8 — Capture friction

On finish, run `skill-ops-retro` capture on this run's friction: search the Pulse queue first — open notes and recently-Done or Duplicate-closed same-root notes from the last ~30 days — and add the evidence to a same-root note if one is open; otherwise file a new `FRICTION:` note for the drain pass to assess, in capture step 3's literal shape — team Apps, project os.Claude, `FRICTION:` title, labels `task` + `work:configuration` + `PUL-5E`, Backlog, unassigned — filing the friction, never the run report. Where the same-root match is closed, record the recurrence as a single running tally edited in place — "recurred: N runs, last <date>" — never as a fresh note and never as a comment per run. This run's own report belongs on its run-log surface (`convention-agent-runtime`), never in the Pulse queue — and where the run found no friction, it files nothing.

## Final step — capture telemetry

On finish, read the canon artefact `skill-telemetry-capture` (the saved skill of that name; locally at `.claude/skills/skill-telemetry-capture/SKILL.md`) and follow it verbatim, passing `task: task-planning-rollup` and this run's own `outcome` (e.g. `completed`, `blocked`, `no-change`).

## Guardrails

- **Read-only on Linear documents.** A wrong or missing block is reported and fixed by the task that wrote it — `task-cycle-planning` for `planning-week`, `task-owner-standup` for `owner-queue` — never patched here, in Linear or in the repo.
- **The script is the only writer of a record.** No hand-written, hand-merged or hand-corrected JSON under `data/planning/`, ever.
- **Fetched documents never enter the repo.** Inputs live outside the working tree, and Step 5's diff bound is the check.
- **Failures are named, never skipped.** Every input is either lifted, reported as a script failure by name, or skipped with a stated reason from Step 2 — and the report lists all three.
- **APP-2444 Done before any run lifts anything** (Step 0).
- **The driver never merges and never asks the Owner to.** Prism and Relay each run as their own subagent; the no-judgement route is `skill-merge-pr`'s, unchanged.
- **One PR, one backing ticket, per run with a change.** No change, no PR, no ticket.

## Setup

- **Surface: a Cloud Routine** with a clone of `assoc-one/claude-ops`, because the run needs repo network — clone, `npm ci`, push, PR (`core-operating-model`, Layer 2, the placement test). **Connectors:** Linear (read the documents; file and route the backing ticket), GitHub through the routine's repo access (branch, PR, CI, merge leg), and Google Drive for the telemetry step. No new credential: the connector-based routine was chosen over a GitHub Action holding a Linear key (operator ruling, 2026-10-19, APP-2437). Named `task-*` at the Owner's instruction although it runs on a Cloud Routine, as `task-ops-sync` does.
- **Schedule (UK local time, `Europe/London`):**
  - **Every weekday — `CRON_TZ=Europe/London 37 9 * * 1-5`.** One schedule, not two: the Owner's config choice of 2026-10-19 (logged in `osclaude.log-decisions.2026-W43`) was a single weekday scheduled task, and Step 0.2 already chooses the mode from the London weekday, so a second cron buys nothing the task does not resolve for itself. **Monday** runs both passes; **Tuesday to Friday** the owner-queue pass alone. 09:37 London clears the 09:00–09:30 stand-up, where the week's commit is normally given and the open `planning-week` block written (W39 on 2026-09-21, W41 on 2026-10-05, W43 at 08:56Z on 2026-10-19); it sits after `task-owner-standup`'s 08:30 agenda write and long before the next morning's full replace; and it is well after `task-cycle-planning`'s Friday 16:00 close of week N-2.
  - **Live as recorded** (cloud scheduled-task store, read 2026-10-20T03:45Z): one enabled schedule named `task-planning-rollup`, cron `CRON_TZ=Europe/London 37 9 * * 1-5`, created 2026-10-19T14:24:49Z, first fire 2026-10-20T08:37Z. Where this paragraph and the live store ever disagree, read the store and correct this line — never add a second schedule to make the prose true.
  - Minutes jittered off the hour per the scheduling rule. Inter-job order is declared here, not inferred from the cron gap: this task consumes `task-cycle-planning` and `task-owner-standup`, and reads the freshness of each block (Step 2's classification; Step 3's `date` check) rather than trusting the clock.
- **Loader config** (Owner config action, one time) — the canonical dual form (`core-operating-model`, *The loader line — one form*), reproduced because it is pasted into a settings box:

  Read the canon artefact `task-planning-rollup` (the saved skill of that name; locally at `.claude/skills/task-planning-rollup/SKILL.md`) and follow it verbatim.

  The artefact is canon and supersedes any behaviour an older config described; a run that cannot read the artefact stops and reports rather than improvising from memory.
- **First scheduled run only after APP-2444 is Done.** The schedule may be created before then — Step 0 stops every run until it is — but creating it is an Owner config action and is never asserted to exist.
- **Owner:** Relay (`R3-LAY`) — the role that writes `owner.standup-agenda` and holds the merge leg this routine routes to. A self-contained task: to change its behaviour, edit this artefact, never the config.

## Tone

Calm, precise, sentence case, British spelling, no exclamation marks, outcome before adjective. (cos.tov.)
