---
name: okstra-schedule-gen
description: Use when the user asks for a task-group work schedule, a consolidated implementation plan across multiple tasks in a task-group, or wants to generate a schedule or work plan for non-done tasks.
model: opus
---

# OKSTRA Schedule Gen

Generate a consolidated work schedule for the selected `implementation-planning` stages of every non-done task in a given `task-group` (or a single `task-id`). For each task the skill reads the source-aware **Stage Map**, records the user's stage choices in a temporary selection contract, and gates the same draft through deterministic validation followed by an independent narrative review. It runs as a **lead + verifier** flow; the frontmatter `model: opus` switches supporting harnesses to Opus-class for the turn — stage-level cross-task synthesis needs that reasoning depth.

## When to Use

- User asks to generate a work schedule / plan / "schedule" for an entire `task-group`
- User wants a single document that summarizes all non-done tasks with effort, risk, and dependencies

**Do NOT use** for single-task analysis (use `okstra-inspect status`) or to execute one task (use `okstra-run`).

Public invocation: `/okstra-schedule-gen [task-group]`. A title or directive may be supplied in the host conversation. If none is, name the schedule after the work itself — read the task titles in scope and write what they do (e.g. `폰트 업로드 경로 개선 — 작업 일정`). Never title it after the group token: that is a directory name, not what the work is.

## Step 0: Preflight

<!-- BEGIN FRAGMENT: bash-invocation-rule -->
Run one Bash tool call, starting with the literal token `okstra` (never wrapped in `if`/`eval`/`export`/`$(...)`/`VAR=...`/`||`/`&&`/`npx` — a non-literal leading token defeats the `Bash(okstra:*)` permission match):
<!-- END FRAGMENT: bash-invocation-rule -->

```bash
okstra preflight --runtime claude-code
```

On `Okstra preflight: ready`, carry the fixed `Project root` line for the later `model-io` calls. On `Okstra preflight: failed`, show `Reason` and `Recovery`, then stop.

<!-- BEGIN FRAGMENT: preflight-outdated-cli -->
If the call fails with `unknown command: preflight`, the `okstra` binary on PATH predates this skill — tell the user to update it (`npm i -g okstra@latest`), then stop (`/okstra-setup` does not update the binary).
<!-- END FRAGMENT: preflight-outdated-cli -->

## What the finished document looks like

The rules below are long because each one was learned from a published schedule
that failed a reader. This is the shape they add up to — read it once before
Step 4, and again at Step 7.

| Section | Holds | Never holds |
|---|---|---|
| `## At a Glance` | one row per task: work name, category, priority, effort, days, risk | task-ids, taskType, a `Task ID` column |
| `## Executive Summary` | `**목적**`, `**달라지는 것**` (limits included), scope/order, how the days were derived; then the effort and priority/risk scales | okstra vocabulary, the plan's review history |
| `## Task Dependency Graph` | cross-task edges — **omitted entirely** when there are none | stage order (the Work Breakdown owns it) |
| `## Gantt Chart` | one bar per selected stage, label and bar only | `days=`, per-row `! crit`/`est` |
| `## Task Details` | per task: Item/Detail, Problem, Solution, Work Breakdown, one block per stage (`Steps` + `Exit criteria`), Verification Commands, Rollback | `Value`, `Acceptance`, a risk section, a cross-task section, a next-actions list |

Every one of those "never holds" entries was in a shipped schedule. Four
restated a table that sat directly above or below them.

## Audience & authority (READ FIRST — drives everything below)

**The schedule is shared with people who do not run okstra.** It is the team's work-plan document, not a record of a run. The body names neither the tool nor its vocabulary — `okstra`, `task-group`, `task-key`, `taskType`, a run's phase names — and the validator refuses a body that does. The title is the work's name, the one metadata line is `> 작성일 <YYYY-MM-DD> · 대상 저장소 <repo>`, and At a Glance identifies each task by name rather than by task-id. That extends to paths: a plan often puts its own scaffolding under the run's working tree — `.okstra/…`, or the `qa/…` scratch it holds — and those are places the reader cannot open and does not own. Name the artefact instead ("계약 캡처 도구", "위반 대장") and keep the path out. Real repository paths — `package.json`, `src/**`, `eval/**`, `.github/workflows/**` — are content and stay.

**The schedule is a client-facing work plan.** It assumes the team has all permissions and can proceed without further approval. Even when the underlying per-task reports flag blocking items, missing approvals, or "items requiring user confirmation", **the schedule MUST NOT surface them** — those belong in the internal report. Never emit a decision checklist, a `#### Items requiring user confirmation` sub-section, `Done`/`Ready?`/`Blocking Decisions` columns, or checkbox lists; "Status" reflects work phase only.

**Assume the user and their team hold full authority and every permission required.** External approvals, access grants, sign-off, and vendor coordination are treated as already satisfied unless a report names a concrete external dependency outside the user's control. Concretely:

- **Effort sizing & day totals** count engineering work only — strip approval-waiting / coordination buffers from source sizings (note the adjustment in `## Executive Summary` if material).
- **Gantt bars** represent engineering duration only; no dead-time gaps for approval cycles. `(after <TASK-ID>)` marks genuine engineering dependencies only.
- **Steps and Exit criteria** are concrete engineering work; items like "permission check", "approval request", "stakeholder alignment" MUST NOT be emitted.

**The schedule must be self-contained.** Opaque codes pulled from internal reports (`FC-5`, `UC-12`, `M1`, decision-item letters, …) must not appear unresolved. Choose one per identifier: **Form A** (≤3 codes) — replace the code inline with a 5–20 character one-line description of the item; **Form B** (≥4 recurring codes) — keep the codes and emit a `## Glossary` table as the last section resolving every one. Decision-item letters (`A1`, `B2`, …) are approval items and may not appear at all. TASK-IDs listed in `## At a Glance` need neither.

**Enforced:** `validators/validate-schedule.py` `_validate_format` rejects a schedule body carrying a blocking/approval item, and `_check_self_contained_identifiers` rejects a decision-item code and an unresolved opaque identifier that neither Form A nor a `## Glossary` row resolves.

## Contract SSOT — template + validator

The installed template `~/.okstra/templates/reports/schedule.template.md` is the **byte-for-byte SSOT** for the output shape: frontmatter, top header block, the mandatory `##` heading list and order, per-task `Item / Detail` field labels and sub-section order, table column shapes, the ASCII Gantt format (relative day axis, plain fence, bar-only rows), the dependency-graph shapes, and the optional `## Glossary` gate. **Read the template before writing the schedule and follow it exactly** — do not re-derive section shapes from memory. Headings and field labels stay English literals regardless of the source-report language; body prose is Korean. When a section has no data, render its heading with `_none_` — never delete or reorder headings. Never emit mermaid or any graph DSL.

`~/.okstra/lib/validators/validate-schedule.py` is the enforcement for all of the above (heading order, field labels, controlled vocabulary — e.g. `Med-High` is the canonical risk form — forbidden translations, checkbox bans, Gantt fence rules, unresolved-code detection). The Step 4 ambiguous-classification rationale line is the one rule the validator does not yet enforce — emit it yourself.

One computation rule the template scaffold cannot carry inline:

- **Effort-to-Day mapping**: day ranges per size are defined once in the template's `### Effort Sizing Criteria` table, and a task's `Days` cell takes its range from that row. `XXL` is the exception — it has no finite upper bound there, so an XXL task is sized by its own stage decomposition and its `Days` cell is the sum of its Work Breakdown rows. The At a Glance totals line sums every in-scope task's `Days`, XXL included. Append ` (est)` to a `Days` range the schedule derived rather than read from the plan; implementation-planning states no durations, so that is every range today.

## Procedure

### Step 1: Resolve task-group and collect tasks

1. **Resolve which task-group to schedule — never silently guess.** The user may name it in the `/okstra-schedule-gen [task-group]` argument. If the user did not name one, ask one free-text question for its task-group token before continuing.
2. Render the group's authoritative task metadata with the fixed view:

   ```bash
   okstra model-io schedule-input --project-root <projectRoot> --task-group <task-group>
   ```

   The `## Tasks` section is authoritative for each task's key, status,
   category, type, and current phase. If it is `- None`, output `That
   task-group could not be found.` and stop without creating a file. Do not
   read task catalogs or task manifests directly.
3. **Derive `<project-id>`** for the header from the fixed view's `Project ID`.
   Do not invent a value.

### Step 2: Filter by workStatus

For inference when `workStatus` is missing or empty, defer to the inference table in `skills/okstra-inspect/SKILL.md` (`status.4` → "Default value convention") — do not duplicate it here. Then filter: resolved `done` → exclude; everything else (`todo` / `in-progress` / `blocked` / `phase-done` / inferred non-done) → include.

If 0 tasks remain, output `All tasks in this task-group are done. There is no schedule to generate.` and stop **without creating a file**.

### Step 3: Per-task stage extraction (Stage Map source)

For each in-scope task, the **authoritative source is its `implementation-planning` Stage Map resolved by the CLI**. Do not hand-parse it or use `latestReportRecordPath` to choose its source. Call:

```bash
okstra stage-map <task-key> --text
```

The fixed response is source-aware. It carries `Status`, `Task key`, `Task root`, `State`, `Source plan path`, plus lossless numbered `Stages`, `Done stages`, and `Planning` count/name/value rows. Stage fields include `stage_number`, `title`, `depends_on`, `step_count`, `exit_contract_summary` and — from a schema-v2 report — that stage's `stepwiseExecution` (`action`, `files`, `command`, `expected`), `sliceValue`, `acceptance` and `exitContract`. Planning fields include `rollbackStrategy`, `validationChecklist`, `crossProjectDependencies`, `dependencyMigrationRisk`, and `recommendedOption`. Branch on those fixed fields explicitly:

The resolved source, when ready, is a report under `runs/implementation-planning`; the CLI owns choosing exactly one report from that domain.

- `Status: ready`, `State: ready` — preserve `Source plan path`, stage rows, and done stages. Compute unfinished stages as stages minus done stages. Only unfinished stages can be selected. Every selected stage's transitive prerequisites must be either selected or done; the completed prerequisite closure is retained as evidence, never rendered as forward work.
- `Status: ready`, `State: missing` — record an empty source and empty stage sets. Tag the task `[NEEDS-PLANNING]`, skip the stage picker, and render task-level metadata only, with no forward Work Breakdown row, Gantt row, or day total.
- `Status: error` or any state other than `ready` and `missing` — stop before drafting, preserve `Failure stage` and `Failure reason` in the user-facing error, and do not guess from another report.

For `ready`, the CLI response is the source for everything the schedule renders — stage rows and `planning` together. Read `sourcePlanPath` only for the task-level Priority / Risk / Scope / Repos that the payload does not carry, and read no further into it: transcribing the payload is the whole point of Step 4. Take task key, category, status, type, and current phase from the fixed `model-io schedule-input` view. Blocking and approval items are not extracted (see Audience & authority).

If unfinished stages are empty while `workStatus` is not `done`, render `_Complete — no remaining stage_` under the task's phase section and contribute no forward day total.

### Step 3.5: Stage selection (per task, user input)

Run this **once per in-scope task that has a non-empty `remainingStages`**, sequentially. A single `task-id` invocation runs it once; a `task-group` runs it per task-id in At-a-Glance order.

**Build dependency-closed cumulative bundles over `remainingStages`:**

1. Order `remainingStages` topologically by `depends_on` (a stage may only appear after all its `depends_on` stages).
2. Pick natural cut points to form up to **3 cumulative bundles**: `B1` = through the first milestone, `B2` = through the core, `B3` = all remaining. Each bundle is a **dependency-closed prefix** — selecting it never omits a prerequisite stage. Label each bundle with its stage list and summed `step_count` (e.g. `B2: stage 1–4 (steps 12)`).
3. If `remainingStages` has ≤2 stages, emit only the bundles that are distinct (1–2), never pad to 3.

**Render the picker** with `AskUserQuestion` (one question for this task):
- Options = the distinct bundles + a final `"All remaining stages"` option. `AskUserQuestion`'s built-in Other slot serves the `Enter directly` (arbitrary stage subset) case; when the user supplies a custom subset, close it under `depends_on` before accepting.
- **Degenerate skip:** if only one distinct bundle exists AND it already equals all remaining stages, skip the picker for this task and set `selectedStages = remainingStages` (log `> _Stage picker skipped: remaining stages form a single dependency chain._`).

Record the chosen `selectedStages` for this task. Reject and re-prompt any custom selection whose transitive `depends_on` closure is not covered by `selectedStages ∪ doneStages`.

### Step 4: Task ordering and per-task transcription

The canonical categories come from `scripts/okstra_ctl/work_categories.py::WORK_CATEGORIES`. Do not infer or publish another category.

**There are no phase buckets and no priority table.** `## Task Details` holds one `### <n>. <Title>` block per in-scope task, numbered from 1 in At a Glance order. The heading is the work's name — the task-id is a machine key and belongs in the At a Glance row, not in a heading the reader has to decode; the block binds to its row by number. At a Glance is already sorted Priority-first, so that ordering carries priority; sequence lives in the stages; and what to do next is Stage 1's first step. In the per-task `Item / Detail` table, `Status` says where the work stands in plain words — "구현 계획 승인됨 — 실행 미착수", not `implementation-planning / implementation-planning`. Derive it from `taskType` and `workflow.currentPhase`, but never print those tokens: they are okstra's phase names and the reader has no phases.

Order At a Glance by Priority (`P0` first), breaking ties by `workCategory` in this canonical order: `bugfix`, `feature`, `refactor`, `ops`, `improvement`. A task whose `workCategory` is unmatched or missing sorts last within its priority and keeps its raw value in the `Category` cell — never substitute a category that is not in that list.

Within a task's block, selected stages become the Work Breakdown rows under the exact header `| Stage | Title | Steps | Depends On | Days |`. Render one row per selected stage using its Stage Map `title`, `step_count`, and `depends_on`, plus its proportional day range. Stages excluded because they are already done are listed once as `> _Done stages: stage <n>, …_` and carry no forward effort.

**Write the schedule FOR the team executing it, FROM the plan.** Two different duties:

- **Facts are carried exactly.** File paths, commands, counts, day ranges, rollback triggers, the number of specs or tables — a wrong path or a dropped item is a defect. This is what a hand-written summary of the report loses, and why `okstra stage-map` hands them over structurally.
- **Prose is rewritten for the reader doing the work.** Say what the step does, why it exists, and what they should see when it succeeds. Do NOT paste a source field wholesale: the planning report was written to justify a design to a reviewer, so it carries sentences arguing for the approach — `sliceValue` is exactly that — which tell an implementer nothing. A schedule full of them reads as a record of someone else's deliberation.

Selecting which source rows belong in a schedule is not summarising. Dropping a justification is correct; dropping a file path is not.

**The reader has no access to the plan's review history.** A sentence like "this answers the objection that sank the direction the first time" or "the reporter's rationale is …" assumes the reader watched the plan being argued. State the engineering reason directly — *why this order, what breaks without it* — and never cite a prior revision, a reviewer, or a decision's provenance. The same applies to okstra's own vocabulary: `task-group`, `implementation-planning`, a `taskType` printed as a Status, a sibling task-id nobody outside the run can look up. Every enum the schedule prints is either defined on the page or replaced by words — the `Kind` / `Direction` labels on the risk and dependency tables classify rows for the plan's author and tell an implementer nothing.

**Stage titles and every table cell are written in the schedule's prose language.** Headings and field labels stay English literals; the content beside them does not. A Work Breakdown whose `Title` column is English next to a `Steps` table in Korean makes the reader switch languages inside one block. The selection contract carries the same titles the schedule prints, so the two stay comparable.

**`## Executive Summary` opens with `**목적**` and `**달라지는 것**`; the validator requires both.** A reader who opens only that section must learn why the work happens and what is true when it ends — scope and day arithmetic alone say neither. The material is in the report's `humanSummary` (`headline`, `outcome`, `whyItMatters`), which `okstra stage-map` carries as `planning.reportSummary`. Rewrite it: that field addresses an approver ("your two questions", "the option you approved"), and that framing must not survive. `decisions`, `actions` and `blockers` are not carried at all — they ask for sign-off.

**State the limits in the outcome list.** When the work stops short of what its name suggests, the summary says so. Here the migration ships with three ports still vendor-shaped, so the schedule says "디렉터리 구조 완료, 격리 미완" rather than letting the reader assume the isolation is finished. A summary that only lists wins is the kind a reader stops trusting on the first surprise.

**A stage block is `Steps` plus `Exit criteria`, and nothing else.** The `Steps` table comes from `stepwiseExecution` — one row per step with what it does (keep the leading `RED:` / `GREEN:` marker), the files it touches, and what the executor should see when it succeeds, from that step's `expected`. In the 대상 column separate entries with `<br>`, not a comma: a comma-joined path list stretches that column and squeezes the two text columns into a gutter. `Exit criteria` is one line from `exitContract` saying when the stage is finished.

Do not render `sliceValue` — it argues why the plan sliced the work this way, which is a reviewer's question, not an implementer's. Do not render `acceptance` alongside `exitContract`: they restate each other. Measured on one real plan, `acceptance`'s four claims all reappeared in `exitContract`, which then added two more. Sort `Verification Commands` `pre` → `mid` → `post` and introduce those three values above the table — source order interleaves them, and a reader working down the table would run a precondition after the checks it gates.

**The schedule has no risk section, no cross-task section and no next-actions list.** Every row those carried restated a stage: a risk's mitigation *is* the stage that answers it, an upstream dependency *is* the step that gates on it, and the next action *is* Stage 1's first step. Carry `dependencyMigrationRisk` and `crossProjectDependencies` by making sure the stage they point at says what they demand — and put anything genuinely not a stage (a freeze agreed with another team, a coupling the stages only imply) in that task's **Solution** or **Repo** cell.

**Transcribing means the content, never the source row's `id`.** `VC-001`, `RB-003`, `XP-001`, `DM-002`, `EO-015` and their kin index a report the schedule's reader cannot open, so the self-contained rule rejects them and the validator enforces it. Drop the id column, and where a row's body cites a sibling code, replace the citation with the thing it names ("the boot probe asserts all 29 keys", not "VC-006").

### Step 5: Gantt decision (render by default)

`## Gantt Chart` is **rendered by default** — skip ONLY when literally no day signal exists (every in-scope task lacks both effort sizing and stage decomposition). An XXL task is not a skip reason: it is sized by its stages. Render whenever any of these hold: 2+ tasks with effort sizing; 1 task whose effort yields a range (mid-point bar, or `lo`/`hi` two-bar form); 1 task with Part/Phase/Step decomposition in the source (bars at decomposition-unit level); total estimated effort ≥ 3 days. When per-unit day allocations aren't itemized, split the parent range across the visible units yourself and append the `est` annotation (or add `> Per-day allocation is an estimate; refresh recommended after blocking items are resolved.`). "Range is wide", "single task", "user decisions pending" are NOT skip reasons — render an estimate-tagged chart instead.

When the source is a Stage Map, the Gantt bars are selected stages. A row is labelled `Stage <n>` when exactly one task is scheduled, and `<TASK-ID> Stage <n>` when more than one is. Spell the stage out — `S1` costs the reader a lookup and saves five characters. A row is a label and a bar and nothing else: no `days=` annotation (the Work Breakdown owns those numbers, and the validator compares the bar against that column), and no per-row `! crit` / `est` markers, which distinguish nothing when every row carries them. One line above the fence states the column unit and what `█` and `░` mean — that is the whole legend, because those two glyphs are the only notation left. Split the task effort range proportionally by `step_count`; round every stage except the last to 0.5 day and let the last stage absorb the remainder. Cross-stage dependency annotations follow `depends_on`. Already-done and non-selected stages never get a bar. A task tagged `[NEEDS-PLANNING]` contributes no bars.

**Bar geometry is checked, not decorative.** One column is half a day: a bar runs `lower / 0.5` filled cells `█` then `(upper - lower) / 0.5` open cells `░`. A bar drawn to any other width is a validation error, as is an axis whose last tick overshoots the scheduled work by 5 days or more.

**Every controlled code the schedule prints must be defined on the page.** The template's `### Priority & Risk Scale` resolves `P0`–`P3` and `Very Low`–`High`; the validator requires that subsection and both header literals. Stage labels are spelled out for the same reason — Gantt rows read `Stage 3`, and `Depends On` cells read `None` / `Stage 2` / `Stage 1 (done)` rather than a bare number the reader has to match against the Stage column of the same table. A reader who never saw the source report cannot rank `P0` against `P1`, calibrate `High`, or expand `S3`; those are opaque codes wearing a friendlier shape.

**`## Task Dependency Graph` is optional and carries cross-task edges only.** Stage order already lives in the Work Breakdown's `Depends On` column; drawing it again as an arrow list makes the reader cross-reference one table against another to learn nothing new. Omit the section entirely — heading included — when no task depends on another, which is always true of a single-task schedule. A heading whose body only redirects to another table is noise, the same defect as a priority table that restates At a Glance.

An unrepresentable half-day allocation is a validation error. Do not switch to a fallback allocation algorithm or publish that draft.

When you do skip, insert in the section's position exactly: `> _Gantt Chart skipped: <concrete reason referencing the actual data>._`

**Directive override (highest priority).** Before applying the heuristic, check for a `## Directive` section, first hit wins: (1) the `--directive-file <abs-path>` argument; (2) `<PROJECT_ROOT>/.okstra/tasks/<task-group-segment>/schedule/instruction-set/analysis-material.md`; (3) none → apply the default heuristic silently. A found directive overrides the render/skip heuristic for the affected section — note it inline as `> _Per Directive directive: <verbatim short excerpt>._` — and its pre-supplied day allocations / phase weights are used verbatim as bar lengths. A directive file without a `## Directive` heading counts as "no directive".

### Step 5.5: Draft, verify, gate

1. **Write paired staging artifacts.** Write the schedule to `.okstra/tasks/<task-group-segment>/schedule/.draft/<YYYY-MM-DD_HH-MM-SS>.md` and its temporary selection contract to the sibling `.draft/<YYYY-MM-DD_HH-MM-SS>.selection.json`. Use the same timestamp and auto-create the parent.
2. **Write schema version 1 selection JSON.** Include every in-scope task, including `missing` and ready tasks with no unfinished stage. Map CLI stage fields to the validator's camel-case boundary:

```json
{
  "schemaVersion": 1,
  "tasks": [{
    "taskKey": "<project>:<group>:<task>",
    "taskId": "<TASK-ID>",
    "state": "ready",
    "sourcePlanPath": "<resolved planning report>",
    "selectedStages": [2, 3],
    "doneStages": [1],
    "stages": [
      {
        "stageNumber": 1,
        "title": "Prepare port",
        "dependsOn": [],
        "stepCount": 2
      },
      {
        "stageNumber": 2,
        "title": "Build adapter",
        "dependsOn": [1],
        "stepCount": 3
      },
      {
        "stageNumber": 3,
        "title": "Wire consumer",
        "dependsOn": [2],
        "stepCount": 2
      }
    ]
  }]
}
```

3. **Run the deterministic gate first.** Execute `python3 ~/.okstra/lib/validators/validate-schedule.py <draft> --selection-json <selection>`. Do not dispatch the narrative verifier when this exits non-zero.
4. **Run the independent LLM verifier second.** Only after the deterministic gate passes, create
   `.okstra/agent-invocations/schedule-verification/<invocation-id>.instructions.md` containing the draft,
   selection JSON, and checks below, but none of the lead's reasoning. Materialize its sibling `.prompt.md`
   with `okstra agent-prompt materialize`, `--purpose schedule-verification`,
   `--audience schedule-verifier`, the current host runtime, the selected provider, and
   `--model-role analyser`. Run `okstra agent-prompt verify` against the returned `metadataPath` before
   dispatch. A native host call receives the verified prompt body and `hostModelValue`; a deterministic
   provider process runs `okstra worker-dispatch` with the prompt path and `modelExecutionValue`. These
   values are not interchangeable.
   The verifier returns `pass` plus concrete findings. Give it these checks:
   - **Executable ordering** — stage sequence, `Depends On`, and Gantt bar positions tell the same story; nothing depends on something scheduled after it.
   - **Arithmetic** — the Work Breakdown `Days` column sums to the At a Glance `Days` cell and to the `Effort sum` line.
   - **Engineering-only scope** — no approval gate, permission check, stakeholder alignment or decision checklist.
   - **Prose vs structure** — the narrative does not contradict the tables.
   - **No assumed background.** Flag any sentence that only parses if the reader watched the plan being argued: a cited objection, a prior revision, "the reporter's rationale", a decision's provenance. Flag okstra's own vocabulary reaching the page — `task-group`, a `taskType` printed as a status, a task-id nobody outside the run can look up — and any enum printed without being defined on the page.
   - **Written for the executor.** Each step says what to do and what the executor should see; a step that only explains why the plan chose this shape is a finding.
   - **One language.** Table cells and stage titles follow the schedule's prose language; only headings and field labels stay English literals.

   These last three are the checks no validator can make. Do not accept a `pass` that skipped them.

   Capture the raw return under `.okstra/agent-invocations/schedule-verification/.tmp/`, then run
   `okstra agent-prompt materialize-result`, `okstra agent-prompt complete`, and
   `okstra agent-prompt verify-completion` in that order. Parse only the `returnedBody` emitted by
   `verify-completion`; an inline or unverified response cannot pass this gate.
5. **Revise from the first gate after every change.** If either gate requests a change, the lead revises the same draft in place, then starts again at the deterministic `--selection-json` gate. Allow **Max 2 revise cycles** total across both gates.
6. **Gate publication.** Only the same draft that passes both gates may be promoted in Step 6. If it still fails after the second revision, do not write the final file; remove the paired staging artifacts and report the residual findings in Korean.

### Step 6: Write the schedule file

Reached only after both Step 5.5 gates return `pass`. Promote the verified same draft to the final path; do not re-render or regenerate it:

```
.okstra/tasks/<task-group-segment>/schedule/<task-group-segment>-plan-<YYYY-MM-DD_HH-MM-SS>.md
```

`<task-group-segment>` comes from the manifest's `taskGroupPathSegment` verbatim. Timestamp is current local time. Auto-create the parent directory. Never overwrite an existing file — on a same-second collision append `-2`, `-3`, ….

### Step 7: Self-validate before reporting completion

1. Re-read the file you just promoted and confirm it is byte-identical to the gate-passing draft content.
2. Run `python3 ~/.okstra/lib/validators/validate-schedule.py <output-path>` as a final format check; use the repository validator only when the installed validator is absent.
3. Delete the temporary `.selection.json` only after that final check passes. Do not print the Step 8 message while the selection contract still exists or validation is failing.

**Then read the document once as its reader.** The validator settles structure, arithmetic, controlled vocabulary and run-internal leakage; it cannot judge any of the following, and each has shipped in a published schedule before:

- Does the summary say **why** the work happens and what is **true when it ends** — including what stays unfinished? A list of wins that omits a known limit is the kind a reader stops trusting at the first surprise.
- Does every step say what to **do**, or does some row only explain why the plan chose this shape? The second is the report's voice, not the schedule's.
- Does any sentence assume the reader watched the plan being argued — a cited objection, a prior revision, "the reporter's rationale"?
- Is anything said twice? A section that restates a table, a cell that repeats its neighbour, a sentence that ends "…is in the table below" — the redirect is the tell.
- Would a reader who is not on this team understand every code and label on the page?
- If a translation exists, do its section count, stage blocks, steps per stage, verification rows, rollback rows and day figures match the original exactly? Compare the counts; a translation that drops rows looks complete on its own.

### Step 8: Completion message (Korean)

```
✓ Schedule generated: <relative-path>
- Included tasks: N
- Excluded (done) tasks: M
- Estimated effort: X.X ~ Y.Y days (Effort sum)
- Mode: lead + verifier
```

## Edge Cases

| Case | Handling |
|------|----------|
| `workStatus` absent or empty | Resolve via the `okstra-inspect status.4` inference table; include unless resolved `done` |
| Filtered task count is 0 | Emit the "all tasks are done" message; do NOT create a file |
| No implementation-planning report | List with a `[NEEDS-PLANNING]` banner only; no stage picker / Gantt / day total |
| 0 remaining stages (all done, workStatus unmarked) | `_Complete — no remaining stage_`, no forward computation |
| ≤2 remaining stages | Emit only as many cumulative bundles as arise (1–2); a single chain skips the picker and proceeds with all |
| either validation gate still fails after two revisions | Final file not written; report residual findings to the user |
| `task-group` matches no tasks | "That task-group could not be found." and stop |
| Catalog and manifest disagree on `workStatus` | Manifest wins (catalog may be stale) |
| task-group casing / punctuation variants | Normalise both sides (lowercase + strip non-`[a-z0-9]`), compare against `taskGroupPathSegment` only; use the manifest's segment verbatim for path output |

## Output Rules

- All user-facing messages in Korean; schedule body prose Korean by default, headings/field labels English (template literals).
- **The document declares its language** as `lang:` in frontmatter, and the validator checks it against that language's labels — a faithful translation must not fail for being a translation. `SCHEDULE_LABELS` in `validators/validate-schedule.py` is the SSOT for which languages exist and what their title suffix, metadata line, summary labels and scale headers are. Writing a schedule in a language absent from that table means adding it there first.
- **A translated schedule is a sibling file, not a rewrite**: `<name>-<lang>.md` beside the original. It carries the same structure — same section count, same stage blocks, same step count per stage, same verification and rollback row counts, same day figures. Compare those counts against the original before publishing; a translation that quietly drops rows is the failure mode here, and it does not show up in either gate.
- The document names no okstra concept. Title, metadata line and At a Glance carry the work's name and its repository — not the task-key, the task-group, or the run's phase.
- Use project-relative paths in completion messages.
- Each detail `Status` is derived from `taskType` and `workflow.currentPhase` but written in plain words; `workStatus` only filters candidates and is never printed.
- Per-task section Work Breakdown rows are **selected stages**, not free-form items; done stages are summarized, never scheduled forward.
