Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions planning/workflow/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow templates

Templates for the files and GitHub issues the [research-to-delivery workflow](../README.md) produces, and for the prompts its orchestrators give subagents. Each template opens with when to use it, then holds the text to copy in one fenced block. Replace every `<...>`; keep the headings, markers and section order.

## Filling in

- IDs come from the tool (`init`, `ids`, `item add`). Never invent `C001`, `C001.2`, `T001` or `D001`.
- Some files are written by a command: concept stubs (`init`), notes (`note`), receipts (`resolve-note`), item lines (`item add`, `item set-status`) and generated views (`render`). Their templates show the shape; use the command.
- Only `render` writes between `<!-- workflow:view <name> -->` and `<!-- /workflow:view <name> -->`. Generated markdown uses headings, `-` bullets, `**bold**`, backticks, links and blank lines; no tables, no `*emphasis*`.
Comment on lines +7 to +9

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 Document only workflow commands that are available

The CLI help in this commit registers only init, check, status, ready, note, and resolve-note (scripts/research_workflow.py:1015); ids, item add, item set-status, and render all fail as invalid commands. Because these instructions also prohibit manually assigning IDs or editing items and generated views, following the template workflow leaves writers unable to perform the required updates.

Useful? React with 👍 / 👎.

- Package files link relatively (`concepts/C001-<slug>.md`, `/planning/workflow/stages.md`). Issue bodies use full URLs (`https://github.com/<issue_repository>/blob/<trunk>/...`), because an issue is read outside the tree. `<issue_repository>`, `<trunk>`, `<git_env>` and `<worktree_root>` are keys of the [profile](../profile.md).
- Run `prettier --write` on every filled markdown file and `python3 scripts/research_workflow.py check --package <package path>` before committing.

## Package files

Written into `doc/<UTC>_research_<slug>/` ([layout](../records.md)).

| Template | File | Written by |
| ---------------------------------- | ------------------------------- | ------------------------------------------ |
| [main.md](main.md) | `main.md` | `init` at S0, then PRs |
| [design.md](design.md) | `design.md` | `init` at S0, then PRs; S5 fills stages |
| [changes.md](changes.md) | `changes.md` | every writer, one line per change |
| [concept.md](concept.md) | `concepts/C001-<slug>.md` | `init`, then only the concept's owner |
| [note.md](note.md) | `notes/C001__to__C002__<id>.md` | `note`, by the sender, once |
| [receipt.md](receipt.md) | `receipts/<note-id>.md` | `resolve-note`, by the receiver |

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 Make resolve-note create the documented receipt

The implemented resolve-note command never writes under receipts/; it appends a workflow:resolution block directly to the receiving concept document, and the checker only scans those concept blocks. Thus invoking the documented command produces no file at the path promised by this table, so consumers following the package layout cannot find the add-only receipt record.

AGENTS.md reference: AGENTS.md:L43-L44

Useful? React with 👍 / 👎.

| [decision.md](decision.md) | `decisions/D001-<slug>.md` | S6 workers and decision subagents |
| [human-review.md](human-review.md) | `human-review.md` | S6 orchestrator, from the decision records |

## Issues

Titles follow the table. The marker's `stage` is the stage that creates the issue; the issue is worked at the next one.

| Template | Title | Created | Worked | Marker `kind` |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------- | ------ | --------------- |
| [issue-research.md](issue-research.md) | `Research: <concept> (<package>·C001)` | S1 | S2-S3 | `research` |
| [issue-parent.md](issue-parent.md) | `Handoff: Investigate and plan <concept> (<package>·C001)` | S4 | S5 | `handoff` |
| [issue-child.md](issue-child.md) | `Design: <facet> (<package>·C001.3)` | S5 | S6 | `design` |
| [issue-orchestration.md](issue-orchestration.md) | `Handoff: Orchestrate <design or implementation> of <concept> (<package>·C001) as an orchestrator using subagents` | S5, S7 | S6, S8 | `orchestration` |
Comment on lines +35 to +37

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 Align the issue rows with the linked templates

The three existing templates do not implement the contracts declared here: issue-parent.md is titled Research: and has an S1 marker without kind, issue-child.md is titled Research Facet: and uses facet rather than item, and issue-orchestration.md uses type rather than kind and omits the concept. Copying those linked templates therefore creates different issue types than the table promises, and the exact-marker lookup described below cannot recognize them on retry, allowing duplicate issues.

Useful? React with 👍 / 👎.

| [issue-plan.md](issue-plan.md) | `Plan: <concept> (<package>·C001)` | S6 | S7 | `plan` |
| [issue-implement.md](issue-implement.md) | `Implement: <step> (<package>·C001·step <n>)` | S7 | S8 | `implement` |

Every issue body ends with one marker line, for example `<!-- workflow:issue {"package":"<package>","concept":"C001","stage":"S1","kind":"research"} -->` (child issues add `"item"`, implement issues add `"step"`). Before creating an issue, look for its marker so a retry never makes a duplicate; this prints the URL of any issue that already carries it:

```sh
gh issue list --repo <issue_repository> --state all --limit 1000 --json url,body |

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 Search beyond the first 1,000 issues for duplicate markers

In a repository with more than 1,000 issues, this lookup can omit an older issue carrying the same marker and falsely report that no match exists, allowing a retry to create a duplicate despite the stated guarantee. The checked gh issue list --help defines --limit as the maximum number of issues fetched, so use complete pagination or a marker-qualified search rather than a fixed 1,000-issue window.

Useful? React with 👍 / 👎.

jq -r --argjson want '<marker JSON>' '.[] | select([.body | scan("<!-- workflow:issue (\\{.*?\\}) -->")[0] | fromjson] | any(. == $want)) | .url'
```

Use existing labels only. Before publishing, give the draft body, and nothing else, to the `zero-context reader` and fix every gap it finds.

## Prompts

Prompts an orchestrator gives to subagents, in [prompts/](prompts/).

| Prompt | Launched by | When |
| -------------------------------------------------------- | -------------------------- | ---------------------------------------------------- |
| `worker-brief.md` | any orchestrator | dispatching one unit of work |
| `orchestrator-brief.md` | router, a human | starting an S6 or S8 orchestrator |
| `merger.md` | S6, S8 orchestrators | landing a finished worker PR |
| [reviewer.md](prompts/reviewer.md) | S6, S8 orchestrators | a disagreement (with critic, investigator) or a PR |
| [critic.md](prompts/critic.md) | S6 orchestrator | a disagreement |
| [investigator.md](prompts/investigator.md) | S6 orchestrator | a disagreement, or a decision the challenge reopened |
| [challenge-pass.md](prompts/challenge-pass.md) | S6 orchestrator | before closing S6 |
| [zero-context-reader.md](prompts/zero-context-reader.md) | anyone publishing an issue | before creating any issue or long brief |
15 changes: 15 additions & 0 deletions planning/workflow/templates/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Change log template

`init` writes a package's first `changes.md`. It is the one shared package file every writer adds to directly: one line at the end, in the same commit as the change it records. `.gitattributes` gives it `merge=union`, so parallel branches merge without conflicts; that only works if each line stands alone. Never edit or remove a line; correct one with a new line.

```markdown
# Changes

[Main reference](main.md)

- <UTC> | <stage> | <status> | <IDs>: <what changed>, by <writer> (<path, PR or commit>)
```

- `<stage>` is `S0` to `S8`; `<status>` is the item status, disposition or run status the change set ([records](../records.md)).
- `item add` and `item set-status` append their own line; add one by hand only for changes no command records.
- Example: `- 2026-10-21T10:00:00Z | S2 | clarified | C001.2, C001.2.1: split the nuance into its own item, by c001-research (#512)`.
106 changes: 81 additions & 25 deletions planning/workflow/templates/concept.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,101 @@
# {{ID}}: {{TITLE}}
# Concept file template

[Main reference](../main.md#{{ANCHOR}})
`init` writes one of these per concept at S0, as `concepts/C001-<slug>.md`. From then on only the concept's current owner writes it: S1 adds the repository map and research questions, S2 the research, S3 the outcome of each incoming note, and every stage appends to `history` in the state block and to the change log at the bottom. Anyone else who wants a change here sends a note (`note`) instead.

<!-- workflow:state -->
````markdown
# C001: <title>

```workflow-state
{
"id": "{{ID}}",
"title": "{{TITLE}}",
"stage": "intake",
"status": "created",
"priority": "recommended",
"horizon": "next",
"goal": "{{GOAL}}",
"enables": [],
"relations": []
"disposition": "proposed",
"enables": [],
"goal": "<end goal this concept serves>",
"history": [
{
"at": "<UTC>",
"note": "Created at intake.",
"ref": "transcript.txt",
"stage": "S0",
"status": "created"
}
],
"horizon": "<now, next, later, ideas or unspecified>",
"id": "C001",
"issues": [],
"kind": "<new or edit>",
"priority": "<crucial, recommended, contingent or unspecified>",
"prs": [],
"relations": [],
"segments": [
"T007-T009",
"T031"
],
"slug": "<slug>",
"stage": "S0",
"status": "created",
"targets": [
"<repository path this concept creates or edits>"
],
"title": "<title>",
"type": "<topic, hint, constraint or directive>"
}
```

<!-- /workflow:state -->
[Main reference section](../main.md#c001-<title-anchor>) · [Transcript](../transcript.txt) · [Meta design](../design.md)

## Relevant transcript excerpts
## Transcript excerpts

<!-- workflow:excerpt {{ID}} {{START}} {{END}} -->
The exact text of every segment assigned to this concept.

[Transcript lines {{START}}-{{END}}](../transcript.txt#L{{START}}-L{{END}})
[T007-T009 in transcript.txt](../transcript.txt)

```text
{{EXCERPT}}
```workflow-excerpt T007-T009

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 the checker’s exact excerpt representation

check_package() requires every source range to contain the exact representation emitted by excerpt(): an HTML workflow:excerpt marker, a line-anchored transcript link, and a text fence. The new canonical template instead shows a workflow-excerpt fence, so any concept created or normalized to this advertised shape fails check --package with exact source excerpt missing or changed; the template needs to retain the parser-compatible form.

Useful? React with 👍 / 👎.

<exact text of T007 to T009>
```

## Normalized purpose
## Purpose

{{SUMMARY}}
Inference: <the concept restated as a goal, in plain words>.

## Initial thoughts

{{THOUGHTS}}
- <preliminary thought>

## Hinted or missed ideas

- Inference: <an idea the transcript only hints at, or that seems missing, kept for consideration>.

## Current repository state

S1: what exists today, each with a path or link (code, docs, designs, plans, earlier requests).

## Research questions

S1: what S2 must answer, most consequential first.

1. <question>

## Research

S2: the definitive record for this concept; no length limit. Feasibility, prior art and example projects, use cases, user anecdotes, alternatives (each steelmanned), risks with mitigations and fallbacks.

## Sources

- <title>, <publisher>, <date or undated> — <exact URL the tool returned> — <what it supports>

## Notes

S3: every note sent and received, with its receipt.

## Inferred suggestions
- `notes/C002__to__C001__<id>.md` — `<disposition>`: <where it landed or why not>.

{{SUGGESTIONS}}
## Change log

## Stage results
- <UTC> · S0 — Created by `init`.
````

Pending: research, synthesis, design, planning and implementation have not run.
- The state block is JSON with 2-space indent, sorted keys and a trailing newline, in a `workflow-state` fence so prettier leaves it alone. Only the owner edits it; `history` is append-only, newest last.
- `relations` entries: `{"kind": "requires", "reason": "<why it blocks>", "to": "C002"}`. `recommended-after` adds `"rework_if_early"`, `optional-if` adds `"trigger"`. Kinds: `requires`, `recommended-after`, `shares-files-with`, `conflicts-with`, `enables`, `optional-if`, `supersedes`, `contradicts`, `part-of` ([ordering](../ordering.md)).
- `issues` and `prs` entries: `{"number": <n>, "stage": "S1", "state": "open", "url": "https://github.com/<issue_repository>/issues/<n>"}`.
- A `hint` concept is never ready for research until a note or a human answer changes its `type`. A `deferred` or `rejected` disposition records its reason, and for `deferred` the revisit trigger, in the history entry's `note`.
- The excerpt fence must be longer than any backtick run inside the excerpt.
49 changes: 31 additions & 18 deletions planning/workflow/templates/decision.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
# {{ID}}: {{TITLE}}
# Decision record template

- Status: preliminary | confirmed | reversed
- Source: stated | inferred | agent-preliminary | human-confirmed
- Date: {{TIMESTAMP}}
- Affects: {{CONCEPTS}}
- Reversal cost: Low | Medium | High
One file per decision, `decisions/D001-<slug>.md` (ID from `ids`), written at S6 by the worker or decision subagent that makes it. The orchestrator does not decide disagreements; it records what the reviewer, critic and investigator conclude ([decisions](../decisions.md)). Nothing downstream promotes `agent-preliminary` to `human-confirmed`; only a human does.

```markdown
# D001: <question, short>

- Status: <preliminary, confirmed or reversed>
- Source: <stated, inferred, agent-preliminary or human-confirmed>
- Date: <UTC>
- Affects: <IDs: C001, C001.3, D002>
- Reversal cost: <low, medium or high> — <what reversing would redo>
- Decided by: <agent names, with the PR or issue URL>

## Question

{{QUESTION}}
<The question, with the facts both sides agree on.>

## Options

### A: <option>

- Steelman: <the strongest case for it>
- Against: <the strongest case against it>

## Options Considered
### B: <option>

### Option A: {{OPTION_A_TITLE}}
- Steelman: <...>
- Against: <...>

- Steelman: {{OPTION_A_STEELMAN}}
- Downsides: {{OPTION_A_DOWNSIDES}}
## Choice

### Option B: {{OPTION_B_TITLE}}
<A or B>.

- Steelman: {{OPTION_B_STEELMAN}}
- Downsides: {{OPTION_B_DOWNSIDES}}
## Rationale

## Choice & Rationale
<Why, with evidence links. Say which best practice or expert view it follows when the evidence alone does not settle it.>

{{CHOICE_AND_RATIONALE}}
## Human review

## Consequential Human Review Items
<"Not needed: <why it is obvious>", or "Listed in human-review.md: <why it is a genuine toss-up>".>
```

{{HUMAN_REVIEW_NOTES}}
Reversing a decision: set `Status: reversed`, add a dated line under "Choice", and find the rework with `git grep -l D001`.
58 changes: 58 additions & 0 deletions planning/workflow/templates/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Meta design template

Use at S0 (`request-intake`): `init` writes a package's first `design.md` in this shape, the intake agent writes the first-pass review order, and S5 (`issue-handoff` fanout) fills "Initial research stages". After intake it changes only through PRs. Waves and the run table are generated views (`ready`, `render`, `status --live`); never type a run status by hand.

```markdown
# Meta design: <request title>

[Main reference](main.md) · [Transcript](transcript.txt) · [Change log](changes.md) · [Human review](human-review.md)

<One paragraph: what this design orders, and the end goal the concepts serve together.>

## Review order

First pass at the order in which to prepare, research and design the concepts. Default, when nothing blocks anything and nothing stands out: run one agent per concept, all at once, and track each in the run table.

1. **C001** <title> — <why here: crucial, horizon now, required by C002>.
2. **C002** <title> — requires C001: <reason>.
3. **C003** <title> — recommended-after C001: can start now; if it does, <what gets reworked>.

## Waves

<!-- workflow:view waves -->

- **Wave 1**: C001, C003
- **Wave 2**: C002 (requires C001)

<!-- /workflow:view waves -->

## Run table

<!-- workflow:view run-table -->

- **C001** <title> — S1 `not-started` · branch none · PR none · updated <UTC>
- **C002** <title> — S1 `not-started` · branch none · PR none · updated <UTC>

<!-- /workflow:view run-table -->

## Initial research stages

Filled at S5. Every GitHub issue made for or related to this request, in recommended order. Issues on the same numbered line run in parallel.

### C001 <title>

- Parent: [#<n> Handoff: Investigate and plan <title>](https://github.com/<issue_repository>/issues/<n>)
- Orchestration: [#<n> Handoff: Orchestrate design of <title>](https://github.com/<issue_repository>/issues/<n>)

1. [#<n> Design: <facet>](https://github.com/<issue_repository>/issues/<n>) (C001.3) — <one line>. Priority: crucial. Blocked by: none.
2. [#<n> Design: <facet>](https://github.com/<issue_repository>/issues/<n>) (C001.4) and [#<n> Design: <facet>](https://github.com/<issue_repository>/issues/<n>) (C001.5) — <one line each>. Priority: recommended. Blocked by: #<n>.

## Links

- Workflow: [stages](/planning/workflow/stages.md), [ordering](/planning/workflow/ordering.md), [decisions](/planning/workflow/decisions.md)
- Order across requests: [DEPENDENCIES.md](/planning/DEPENDENCIES.md)
- Feature plans land in [planning/plans/](/planning/plans/README.md), from the [plan template](/planning/templates/plan.md)
```

- Run statuses: `not-started`, `claimed`, `running`, `pushed`, `pr-open`, `merged`, `validated`, `blocked`, `abandoned`. `pushed`, `pr-open` and `merged` come from git and GitHub through `status --live`.
- A soft edge (`recommended-after`) names the rework it costs; a hard edge (`requires`) names why it blocks ([ordering](../ordering.md)).
30 changes: 30 additions & 0 deletions planning/workflow/templates/human-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Human review template

The S6 orchestrator (`design-orchestrate`) writes `human-review.md` at the package root from the decision records, and regenerates it whenever a decision changes. It lists only the genuine toss-ups: preliminary decisions that work is already built on, ranked by effect, each with its default, alternatives and the cost of reversing. Obvious decisions are made, recorded in `decisions/`, and not listed. Nothing the transcript already states is asked again ([decisions](../decisions.md)).

```markdown
# Human review: <request title>

[Main reference](main.md) · [Meta design](design.md) · [Decision records](decisions/)

Work continues on every default below. To change one, comment on <issue URL> with the decision ID and your choice. A reversal starts rework scoped by `git grep -l <decision ID>`.

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 Scope reversal searches to the current package

Decision IDs are package-local and restart at D001, but this command searches the entire repository. With multiple research packages it returns files for unrelated D007 decisions, and it already matches the canonical template itself, so it cannot reliably identify the files affected by this choice and may initiate unrelated rework; use a package-qualified reference or restrict the search path.

Useful? React with 👍 / 👎.


<!-- workflow:view human-review -->

- **D007** <question> — reversal cost <low, medium or high> · affects <IDs>
- Default in effect: <choice>, because <one-line rationale>.
- Alternatives: <option B>; <option C>.
- If reversed: <what changes>; `git grep -l D007` lists <n> files today.
- Record: [D007 <slug>](decisions/D007-<slug>.md)

<!-- /workflow:view human-review -->

## Questions

Batched and ranked by effect. Each has the default in use.

1. <question> — Default: <answer assumed>. Affects: <IDs>.
```

- A decision belongs here only when its options are genuinely balanced and choosing wrong would be costly to reverse. "None" is a valid list.
- Only a human moves a decision from `agent-preliminary` to `human-confirmed` or `reversed`.

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 Keep decision source and status transitions separate

The decision format defines agent-preliminary and human-confirmed as values of the Source field, while reversed is a value of the separate Status field. Describing all three as states that a decision is moved between leaves a human reversal ambiguous and can produce an invalid record; the instruction should state which field is updated for confirmation and which fields are updated for reversal.

Useful? React with 👍 / 👎.

Loading
Loading