From d6d5c7a17e39d606ad7f1f73c7ac63afdbe8ca68 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Thu, 22 Oct 2026 06:09:30 -0500 Subject: [PATCH] docs(repo): rewrite feature-plan as a stepwise S7 planner Granular numbered steps with interfaces first, hard and soft edges, file collisions as blocking edges, [P] waves, tiers, tests first and deferred decisions with defaults. A fresh-context validator checks the plan (with a mechanical plan_check.py first), a zero-context reader checks every implement and orchestration issue, and issues are created in wave order with blocked-by links. Worker branches follow research//s-. --- .agents/skills/feature-plan/SKILL.md | 104 ++++++++++++---- .../skills/feature-plan/references/issues.md | 79 ++++++++++++ .../feature-plan/references/plan-outline.md | 113 ++++++++++++++++++ .../feature-plan/references/validation.md | 66 ++++++++++ .../skills/feature-plan/scripts/plan_check.py | 109 +++++++++++++++++ 5 files changed, 451 insertions(+), 20 deletions(-) create mode 100644 .agents/skills/feature-plan/references/issues.md create mode 100644 .agents/skills/feature-plan/references/plan-outline.md create mode 100644 .agents/skills/feature-plan/references/validation.md create mode 100644 .agents/skills/feature-plan/scripts/plan_check.py diff --git a/.agents/skills/feature-plan/SKILL.md b/.agents/skills/feature-plan/SKILL.md index 49665ef81f..78a786eee9 100644 --- a/.agents/skills/feature-plan/SKILL.md +++ b/.agents/skills/feature-plan/SKILL.md @@ -1,35 +1,99 @@ --- name: feature-plan -description: Turn approved designs into granular end-to-end implementation plans with numbered steps, test contracts, and worktree partitions. Use during Stage 7 feature planning. +description: "Turn a settled design into an implementation plan in planning/plans/ from planning/templates/plan.md, then publish one implement issue per step and the orchestration issue that runs them (S7 of a workflow research package, worked from a plan issue). Steps are granular and numbered, shared interfaces come first, and each step states its tier (crucial, recommended or contingent), goal, what it enables, owned files, the failing test it starts from and a done check a command can run. Hard blockers are kept apart from soft rework-if-early edges, file collisions become blocking edges, and steps form waves with [P] parallel markers. Decisions that depend on implementation details are deferred with defaults. A fresh-context validator checks the plan, a zero-context reader checks each issue, and issues carry blocked-by links. Use when given a plan issue, or asked to plan, break down, sequence or ticket a design. Running the steps is implementation-orchestrate; settling the design is design-orchestrate." --- -# Feature Plan (Stage 7) +# Feature plan (S7) -Translate an approved design or consolidated research into a granular, execution-ready implementation plan. Full specification lives in [/planning/templates/plan.md](/planning/templates/plan.md) and [/planning/workflow/ordering.md](/planning/workflow/ordering.md). +You turn one settled design, usually one sub-feature named by a plan issue, into a plan that parallel workers can build without asking anything: granular numbered steps, interfaces first, hard and soft edges, waves, tiers, tests and deferred decisions with defaults. Then you publish one implement issue per step and one orchestration issue. You plan; you never design and never implement. If the design is wrong or silent, defer the question with a default, tell the design side, and keep planning. -## Procedure +The stage contract is in [stages.md](/planning/workflow/stages.md), edge and wave semantics and the step fields in [ordering.md](/planning/workflow/ordering.md), relation kinds and tiers in [DEPENDENCIES.md](/planning/DEPENDENCIES.md), branch, lease and PR rules in [collaboration.md](/planning/workflow/collaboration.md), and decision sources and coverage in [decisions.md](/planning/workflow/decisions.md). The plan follows the [plan template](/planning/templates/plan.md); the issues follow the [implement](/planning/workflow/templates/issue-implement.md) and [orchestration](/planning/workflow/templates/issue-orchestration.md) templates. This skill does not restate those rules. -1. **Review Design & Boundaries**: - Read the design record, decision records, and acceptance criteria. Fence the scope: clearly state what the feature will _not_ do. +## Set up -2. **Define Test Seams First**: - Specify automated test commands and observable outputs that will fail before the change and pass after it. +```sh +source /home/user/.local/share/plaza-tools/git-env.sh # the profile's git_env +rw() { python3 -I scripts/research_workflow.py "$@"; } # run from the repository root +PKG=doc/_research_; ITEM=C001.4 # package; the item in the plan issue's marker +PLAN=planning/plans/.md # the plan this run writes +NAME=planner--<4 hex> # your agent name +LIVE="$(git rev-parse --git-common-dir)/agent-work/${PKG##*/}-S7"; mkdir -p "$LIVE/issues" +``` -3. **Phase & Step Breakdown**: - Break implementation into phases (`1.0`, `2.0`, ...) and numbered steps (`1.1.1`, `1.1.2`, ...). Mark parallel-capable steps with `[P]`. +Each log line is `$NAME : `, appended to `$LIVE/$NAME.md`, with a `heartbeat` at least every 10 minutes. If a command fails with `invalid choice` or an unknown flag, use the router's [tool fallbacks](../research-workflow/references/tool-fallbacks.md). Outside a research package (a design record with no package), skip the `rw` commands and the package records; every other step holds. -4. **Map Worktree Partitions & Dependency Edges**: - Assign file ownership partitions to prevent concurrent builders from modifying the same files. Declare explicit `requires` and `shares-files-with` relations. +## Steps -5. **Create Implementation Issues**: - Publish granular implementation issues and generate the implementation orchestration issue. Save the plan to `planning/plans/.md`. +1. **Boot and claim.** Create your own worktree and branch from a fresh `origin/main` (the plan issue's branch name, else `research//s7-` with the item in lowercase, such as `research/docs-pipeline/s7-c001.4`), push it empty, take the lease `$ITEM` (`rw lease acquire`), record the trunk SHA and the UTC time, and append `start`. + Done when `git ls-remote` shows the branch, the lease is listed, and the log has `start` with the SHA. -## Turn Report +2. **Verify the entry state.** The plan issue is open. Its design orchestration issue is closed. The consolidated design record, its decision records and `human-review.md` are on `origin/main`. No other branch, PR or plan file exists for `$ITEM` (run the marker search in the [templates README](/planning/workflow/templates/README.md) and `git ls-remote origin 'refs/heads/research//*'`). If a condition fails, comment `Blocked: ` on the plan issue and stop. + Done when every condition is checked against the recorded SHA, with the output in the log. + +3. **Read the design and map the code.** Read the plan issue's "Read first" list in order. Then launch read-only subagents in parallel, one per area of code the design touches, each returning the files, symbols and tests involved as `file:line` at the recorded SHA. Pass them paths and URLs, not summaries. + Done when every section of the design maps to code paths with `file:line` evidence, or is marked "new file". + +4. **Fence the goal and scope.** Copy the plan template to `$PLAN` and fill the header, Goal and Scope as in [references/plan-outline.md](references/plan-outline.md). Every `Out` item names where it is tracked. Commit, push, and open a draft PR into `main` before writing the steps (collaboration rule 3). + Done when the draft PR exists and its head equals your last pushed SHA. + +5. **Pin interfaces first.** List every interface two or more steps will share: types, schemas, file formats, CLI flags, config keys, paths and module boundaries. Each gets one owner, a step behind a contract test or the plan's own text, and every step that uses it requires that owner. No other step defines or changes it. + Done when the plan's Interfaces section gives each shared interface exactly one owner that comes before all of its users. + +6. **Write granular steps.** Number them in one sequence in dependency order, so a step only ever requires lower numbers. Each is one PR and one fresh session, in the step format of `references/plan-outline.md`: tier, goal, what it enables, owned files, the decisions and items it cites, the failing test it starts from, a done check as a command, edges and size. + Done when every step has every field and none needs more than one PR. + +7. **Mark edges, waves and `[P]`.** Use `Requires:` only when one step's output is a real input to another, and `After:` with the rework it costs to start early. Two steps that write one file: reassign the file, or make the collision a `Requires:` that names it. Prefer the arrangement with the fewest hard edges. Group the steps into waves, mark `[P]` on each step that shares no edge and no file with the others in its wave, and write the critical path, peak parallelism against `max_parallel_writers` and the estimate in sessions. + Done when every `After:` states its rework, every file collision is reassigned or a hard edge, and the critical path is written down. + +8. **Tier and order by value.** Mark each step `crucial` (the goal fails without it), `recommended` (worth doing now, the goal holds without it) or `contingent` (only if its named trigger fires). No crucial step may require a non-crucial one: raise the blocker's tier or drop the edge. Within a wave, crucial steps come first, then by what they enable. + Done when every step has a tier, every contingent step names its trigger, and no crucial step requires a lower tier. + +9. **Write tests and evidence.** For each step, name the test that fails before the change and passes after it; workers write it first. Name the integration or end-to-end checks the last wave runs and the profile's `validation_commands`. + Done when every done check is a runnable command and every step names a test that would fail at the recorded SHA. + +10. **Defer what depends on implementation.** In "Deferred decisions", give each open question its default, the step whose worker settles it, the step it must be settled before, and what changes if the answer differs. List the `human-review.md` defaults the plan builds on, with the steps that would redo work if a human reverses one. Product or architecture questions go back to the design side as a comment on the design orchestration issue; the plan continues on the default. + Done when every open question from the design is answered by a step, deferred with every field, or listed as a human-review default. + +11. **Validate with fresh context.** Fill Rollout and rollback, Risks and Progress, run `scripts/plan_check.py`, push, and give the plan to one fresh read-only validator with the prompt in [references/validation.md](references/validation.md). Fix every blocking finding and re-run with a new validator, at most three rounds; what still blocks becomes a deferred decision or a tracked `Out` item. + Done when `plan_check.py` prints `ok` and the last validator return has no blocking finding, both saved in the log. + +12. **Publish the implement issues.** Follow [references/issues.md](references/issues.md): draft the bodies in parallel with read-only subagents, one step each, give each draft to a fresh [zero-context reader](/planning/workflow/templates/prompts/zero-context-reader.md), then create the issues in wave order, blockers first, with `--blocked-by` and the plan issue as `--parent`. Contingent steps get no issue until their trigger fires. + Done when every crucial and recommended step has an open implement issue that ends with its marker, whose `blockedBy` equals the step's `Requires:`, and whose last zero-context read has no blocking question. + +13. **Publish the orchestration issue.** Fill the orchestration template's S8 lines with the graph in wave order, run the zero-context reader on it, publish it, and comment its URL on every implement issue and on the plan issue. + Done when it is open, ends with its marker, and every implement issue links it. + +14. **Record and report.** Write the issue links into the plan and its Progress section, add the plan to the plan catalog, and update the package records (`references/issues.md`, "Recording"). Run `prettier --write` on your files and `rw check --repo-root .`, merge `origin/main`, push, mark the PR ready, comment it on the plan issue, `rw lease release`, and append `end `. Never merge your own PR. + Done when the check passes and `git ls-remote origin ` equals the PR head and the SHA you report. + +## Parallelism and ownership + +One agent per plan issue, so sub-features plan in parallel. You are the only writer of `$PLAN`, its line in the plan catalog, your item's lines in `main.md` and blocks in `design.md`, the concept state block while you hold its lease, and the issues you create. Mapping, drafting, validating and zero-context subagents are read-only leaves that return text; none of them writes files or creates issues. You never edit design or decision records: send a note to the concept (`rw note`) and comment on the design orchestration issue instead ([collaboration.md](/planning/workflow/collaboration.md), rules 1 to 10). + +If the harness cannot launch subagents, do the mapping, drafting and reading yourself one at a time, but still give the plan and every issue body to a reader that did not write them, and say so in the turn report. + +## Should load / should not load + +- Load for: "work plan issue #540"; "turn this approved design into a granular implementation plan"; "break the C003 design into numbered steps with tests"; "sequence these steps into waves and mark what can run in parallel"; "make the implement tickets and the orchestration issue for this plan". +- Don't load for these, which belong to the named skill: settling the design, merging design PRs or deciding between options (`design-orchestrate`); running implement issues, merging builder PRs or the final reviews (`implementation-orchestrate`); writing research or design child issues (`issue-handoff`); finding the next stage of a package (`research-workflow`); writing code for one step (follow its implement issue). + +## References + +- [references/plan-outline.md](references/plan-outline.md): read in steps 4 to 10 (sections, the step format, interfaces, edges, waves, tiers, deferred decisions). +- [references/validation.md](references/validation.md): read in step 11 (the mechanical checks, the validator prompt, the stop rule). +- [references/issues.md](references/issues.md): read in steps 12 to 14 (titles and markers, links before the plan merges, drafting, creating, the orchestration issue, recording). +- [scripts/plan_check.py](scripts/plan_check.py): run in step 11 and after every fix. + +## Turn report End every turn with: -- Done: -- Verified: -- Remaining: -- Questions (non-blocking): default> -- Blocked on user: +```text +Done: +Verified: ok>, no blocking finding>, no blocking question>, ok>, ok> +Remaining: <"implementation-orchestrate on ", or what is left> +Questions (non-blocking): default in use>, or none +Blocked on user: , or none +``` + +The final turn also gives the branch, the PR URL, the last pushed SHA, the critical path and the estimate in sessions. diff --git a/.agents/skills/feature-plan/references/issues.md b/.agents/skills/feature-plan/references/issues.md new file mode 100644 index 0000000000..c582432070 --- /dev/null +++ b/.agents/skills/feature-plan/references/issues.md @@ -0,0 +1,79 @@ +# Implement issues, the orchestration issue and recording + +Read in steps 12 to 14. The bodies follow the [implement](/planning/workflow/templates/issue-implement.md) and [orchestration](/planning/workflow/templates/issue-orchestration.md) issue templates; the marker search is in the [templates README](/planning/workflow/templates/README.md). This file says how to fill, check, create and record them without duplicates. + +## 1. Titles, markers and branches + +Step numbers restart in every plan, and one concept can have several sub-feature plans. So every implement and orchestration issue names the item, not only the concept. + +| Issue | Title | Marker | +| ------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | +| Implement | `Implement: (··step )` | `{"package":"","concept":"C001","item":"C001.4","stage":"S7","kind":"implement","step":"3"}` | +| Orchestration | `Handoff: Orchestrate implementation of (·) as an orchestrator using subagents` | `{"package":"","concept":"C001","item":"C001.4","stage":"S7","kind":"orchestration"}` | + +Each step's issue names its worker branch in "Owned outputs": `research//s8--step-`, for example `research/docs-pipeline/s8-c001.4-step-3`, with the worktree `/research--s8--step-`. `` is the package slug, and the item is lowercase. + +## 2. Links before the plan merges + +The issues are created while the plan PR is open, so a link to `blob//planning/plans/.md` does not resolve yet. In "Read first", give the trunk link (the one that lasts) followed by `(until PR # merges: )`, where the permalink is `blob//planning/plans/.md#wave-`. A zero-context reader can then follow both. + +## 3. Drafting (step 12) + +Launch one read-only subagent per crucial or recommended step, all in parallel. Each gets paths and URLs only: the implement template, the plan at its permalink and the step number, the design record, the decisions the step cites, its `file:line` map from step 3, and its branch name. Each returns a title and a body; none creates an issue or writes a file. + +- **Blockers.** A blocker's issue number does not exist yet when the drafts are written. Drafts write `{step 1}` for each one; you replace it with the issue number as you create issues in wave order. +- **Current state** is verified against the recorded trunk SHA, with `file:line`. "Blocking steps merged" is `none yet`. +- **Your role.** Keep the template's quote. Add: write the "Test first" test before the change, push it, and show it failing in the PR before the fix; do not fix failures that already exist on the trunk, file them. +- **Prerequisites.** `Blocked by` is exactly the step's `Requires:`, including file-collision edges. `Parallel-safe with` is the other `[P]` steps of its wave. `After:` edges go in "Current state" with their rework, so the worker knows what assumption it runs on. +- **Deferred decisions.** A step that settles one says so and gives the default. A step that depends on one names it and the default it builds on. +- **Not verified** says honestly what the drafter could not check. + +Save each draft as `$LIVE/issues/step-.md`. + +## 4. The zero-context read + +Give each draft body, and nothing else, to its own fresh [zero-context reader](/planning/workflow/templates/prompts/zero-context-reader.md), all in parallel. Fix every blocking question and unresolvable link in the draft, not in a comment. Re-read a changed draft with a new reader, at most three rounds; a question still standing after that gets its answer written into the body as a default. Save each return as `$LIVE/issues/step-.zcr-.md`. + +## 5. Creating (step 12) + +Create in wave order, crucial first, so every blocker exists before the issue it blocks: + +```sh +marker='{"package":"","concept":"C001","item":"C001.4","stage":"S7","kind":"implement","step":"3"}' +# 1. The marker search from the templates README; reuse the URL if it prints one. +# 2. Otherwise: +gh issue create --repo --title "" --body-file "$LIVE/issues/step-3.md" \ + --blocked-by <issue of step 1>,<issue of step 2> --parent <plan issue number> +# 3. Record the URL in the log at once, then confirm: +gh issue view <url> --json url,state,body,blockedBy,parent +``` + +Confirm that the body ends with its marker, `blockedBy` holds exactly the issues of the step's `Requires:`, and `parent` is the plan issue. If `--blocked-by` or `--parent` is refused, create the issue without it, add the links with `gh issue edit <n> --add-blocked-by <n,...>` and `--parent <n>`, and keep the `Blocked by:` line in the body either way. Use existing labels only. Contingent steps get no issue; the orchestration issue lists them with their triggers. + +## 6. The orchestration issue (step 13) + +Keep the template's S8 lines and delete the S6 ones. "The graph" lists every step in wave order, crucial first, one line each: + +```markdown +1. [#551 Implement: Lock layout](https://github.com/<issue_repository>/issues/551) — step 1, wave 1, crucial — blocked by: none. Parallel with: #552. +2. [#553 Implement: Lease list command](https://github.com/<issue_repository>/issues/553) — step 3, wave 2, crucial — blocked by: #551 (requires: the lock layout). After: #552 (rework if early: the owner line may gain a field). +3. Step 9, contingent — no issue until: the benchmark in step 7 exceeds 200 ms. +``` + +"Read first" links the plan (trunk link and permalink, as in section 2), the consolidated design record, `human-review.md` and the [implementation-orchestrate skill](/.agents/skills/implementation-orchestrate/SKILL.md). Run the marker search, give the body to a fresh zero-context reader, fix, then publish with `--parent <plan issue number>`. Comment its URL on every implement issue and on the plan issue (`gh issue comment <n> --body "Orchestrated by <url>"`). + +## 7. Recording (step 14) + +All on your plan branch, in the same PR: + +- **The plan.** Fill `Issues:` in the header (plan, orchestration, then each step's issue by number), and add a Progress line: `- <UTC>: <n> implement issues and orchestration #<n> published`. +- **Plan catalog.** Take the `file-planning__plans__README.md` lease, add one line for the plan under a `## Plans` heading in `planning/plans/README.md` (create the heading above "Plans written before this folder existed" if it is missing), and release the lease after you push. +- **Roadmap.** If the plan's roadmap row exists, link the plan from it and set its status to `planned`, under that file's lease. +- **Package.** Only inside a research package: + - `rw item add --package "$PKG" --parent "$ITEM" --stage S7 --text "S7 · <UTC> — plan at <path>; <n> steps in <w> waves; orchestration #<n>"`. + - In the concept state block, add the implement and orchestration issues to `issues` with stage `S7` and `item`, and append a `history` entry. Set `disposition` to `planned` only when every crucial sub-feature of the concept has a merged or open plan PR; otherwise leave it. + - In `design.md`, under the concept's "Initial research stages", add a dated block `S7 · <UTC> · <ITEM> plan`: the plan, the orchestration issue, and the implement issues by wave with tiers and edges. Never rewrite earlier blocks. + - `rw render --package "$PKG"`, then one `changes.md` line. +- **Checks.** `prettier --write` on every markdown file you touched, `rw check --repo-root .`, and `rw check --package "$PKG"` inside a package. + +Then merge `origin/main` into your branch, push, and mark the PR ready. The PR body says `Closes #<plan issue>`, lists the deferred decisions and any finding the validator stop rule left open, and links the orchestration issue. Comment the PR URL on the plan issue. Never merge your own PR. diff --git a/.agents/skills/feature-plan/references/plan-outline.md b/.agents/skills/feature-plan/references/plan-outline.md new file mode 100644 index 0000000000..cfbfec4802 --- /dev/null +++ b/.agents/skills/feature-plan/references/plan-outline.md @@ -0,0 +1,113 @@ +# Plan outline: sections, steps, edges, waves, tiers, deferred decisions + +Read in steps 4 to 10. The [plan template](/planning/templates/plan.md) owns the base sections. [ordering.md](/planning/workflow/ordering.md#plans) owns the step fields and what they mean, and [DEPENDENCIES.md](/planning/DEPENDENCIES.md) owns the relation kinds and tiers. This file says how to fill them in for one sub-feature of a settled design. + +## 1. File, header, goal and scope (step 4) + +- **Path.** `planning/plans/<slug>.md`, where `<slug>` is the sub-feature's short name, or `<UTC>_<slug>.md` when order matters ([plans README](/planning/plans/README.md)). One plan per plan issue. +- **Header.** The template's four lines, plus two: + - `Status: draft`. The S8 orchestrator moves it to `in-progress` and `done`. + - `Roadmap item:` the row in `planning/roadmaps/<area>.md`, or `none: <why>`. + - `Design:` the consolidated design record, then the decision ids the plan builds on. + - `Issues:` the plan issue now; the orchestration issue and the implement issues by step once they exist. + - `Package: <PKG> · <ITEM>` and `Planned against: origin/<trunk> at <sha>`. +- **Goal.** One paragraph: what is true when the plan is done that is not true now. Start from the sub-feature's goal and "enables" in the consolidated record's "Sub-features" section. +- **Scope.** `In:` what the plan changes. `Out:` what it leaves alone, each item with where it is tracked: another plan issue, a contingent item, a roadmap row or an issue. An `Out` item with no link is a dropped requirement. + +## 2. Section order + +The template lacks three sections. The full order is: header, Goal, Scope, **Interfaces**, Steps (one `### Wave <n>` sub-section per wave, then the critical path), **Deferred decisions**, Tests and evidence, Rollout and rollback, Risks, Progress. S8 adds `## Retro` at the end; never write it yourself. + +## 3. Interfaces (step 5) + +An interface is anything two or more steps must agree on: a type, a schema, a file format or path, a CLI flag or subcommand, a config key, an error string a test matches, a module boundary. List each one: + +```markdown +## Interfaces + +- **Lock directory layout** `agent-work/<package>-<stage>/locks/<resource>.lock/owner`. Owner: step 1. Contract test: `test_lock_layout`. Used by: 3, 4, 6. +- **Branch name** `research/<slug>/s8-<item>-step-<n>`. Owner: plan (no code). Used by: 5, 7. +``` + +- One owner each: a step, or `plan` when the text above is the whole contract. +- Every step that uses an interface owned by a step `Requires:` that step. +- No other step defines or changes it. A worker who finds the interface wrong stops and reports; the S8 orchestrator adds a step. +- Shared names the design already pinned in its "Shared names" section are copied with a link, never renamed. + +## 4. The step format (step 6) + +Use the [ordering.md](/planning/workflow/ordering.md#plans) format with two more fields, `Test first:` and `Size:`: + +```markdown +### Wave 2 + +3. **[P] Lease list command.** Add `lease list`, which prints every live lease of a package and skips expired ones. + - Tier: crucial. Goal: an orchestrator sees every live lease with one command. Enables: 5, 6, C004. + - Requires: 1 (the lock layout). After: 2, rework if early: the owner line may gain a field. + - Files: `scripts/research_workflow_leases.py`, `scripts/tests/test_leases.py`. Cites: D003, C001.4.2. + - Test first: `test_lease_list_skips_expired` fails at `<sha>` with `invalid choice: 'lease'`. + - Done when: `python3 -m pytest scripts/tests/test_leases.py -q` passes. + - Size: S. +``` + +- **Numbering.** One sequence across the whole plan, in dependency order, so a step requires only lower numbers. Once issues exist, numbers never change; a step added later takes the next free number. Implement issues link the step's wave heading (`#wave-2`) and name the number. +- **Granular.** One PR, one fresh session, one concern, a diff a reviewer reads in one sitting. `Size:` is `S` (under about 300 changed lines) or `M` (under about 800). Split anything bigger, and anything that mixes a refactor with a behaviour change. +- **Goal** is a state, not an activity: "the web view shows what the terminal shows", not "work on the presenter". +- **Enables** names later step numbers and the concept or item ids the step unlocks. A step that enables nothing and is not a deliverable of the goal is a candidate to cut. +- **Files** lists every path the step writes, tests included, as exact paths (`new` is fine). A directory only when the step creates it. +- **Cites** the decisions and items the step implements. Together the steps cite every `stated` and `human-confirmed` decision and every accepted item of `$ITEM` ([decisions.md](/planning/workflow/decisions.md#coverage)). +- **Test first** names the test the worker writes before the change and how it fails at the recorded SHA. A step with no runtime behaviour (docs, config) names a command that fails first instead, such as `rw check` on a missing link or `grep -q`. Never `n/a`. +- **Done when** is one command or CI job. Never "reviewed" or "looks right". + +## 5. Edges (step 7) + +| Edge | Use it when | Write it as | +| --------------------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | +| `Requires:` (hard) | The target's output is a real input: an interface, a generated file, a migration, behaviour the test exercises. | `Requires: 1 (the lock layout)` | +| `After:` (soft) | Starting early is possible but may cost rework. | `After: 2, rework if early: <what is redone>` | +| File collision | Two steps must write the same file and the file cannot be reassigned to one of them. | `Requires: 4 (shares scripts/x.py)` | +| `conflicts-with` (not here) | Two steps implement incompatible choices. | A design gap: section 9, never a plan edge | +| `optional-if` (contingent) | The step runs only if something happens. | `Tier: contingent. Trigger: <observable fact>` | + +- Prefer the arrangement with the fewest hard edges. For each `Requires:`, ask whether the step could build against a pinned interface instead; if so, drop the edge or make it `After:`. +- Resolve a file collision by reassigning first: move the shared change into the step that owns the file, or into an interface step both require. Only then serialize with a hard edge, whose reason names the file. The S8 orchestrator relies on this: a collision is always a `blocked-by` link, never a wave convention. +- A cycle is rejected. Break it by extracting the shared part into an interface step. + +## 6. Waves, `[P]` and the critical path (step 7) + +- A step's wave is one more than the highest wave of its `Requires:` targets; an `After:` source goes one wave past its target ([ordering.md](/planning/workflow/ordering.md#waves), rule 3). Steps with no edges are in wave 1, after any interface steps they require. +- Mark `[P]` on a step when another step in its wave exists and the two share no file and no edge. A step that must run alone (a migration, a repo-wide rename, a lockfile or integration step) has no `[P]` and gets its own wave. +- Under the last wave, write `Critical path: 1 → 3 → 6 → 9 (4 sessions)` (the longest `Requires:` chain), `Peak parallelism: 4 of max_parallel_writers 5`, and `Estimate: <n> sessions over <w> waves`. A wave wider than the cap runs in batches, crucial first. + +## 7. Tiers and value order (step 8) + +- `crucial`, `recommended` and `contingent` mean what [DEPENDENCIES.md](/planning/DEPENDENCIES.md#2-priority-tiers) says, measured against this plan's goal. Start from the sub-feature's tier in the consolidated record. +- No crucial step requires a non-crucial one. Raise the blocker's tier, or drop the edge by pinning an interface. +- A contingent step names its trigger as an observable fact and who checks it, for example `Trigger: the benchmark in step 7 exceeds 200 ms (S8 orchestrator, after step 7 merges)`. It gets no issue until the trigger holds. +- Within a wave: crucial steps first, then the step that enables the most later steps, then the smaller one. + +## 8. Tests and evidence (step 9) + +Fill the template's section with what the steps do not already say: the integration or end-to-end checks, which step runs them (usually the last wave, without `[P]`), what each proves, and the profile's `validation_commands`. Name every test that must fail before the change. + +## 9. Deferred decisions (step 10) + +```markdown +## Deferred decisions + +- **Q1. Owner line: one line or JSON?** Default: one line, as in collaboration.md. Settled by: step 1's worker, from what the parser needs. Before: step 3 starts. If it differs: steps 3 and 5 change their parsers; their briefs state the default. + +Human-review defaults this plan builds on: + +- **D007** (default: leases in the git common directory). Steps 1, 3 and 6 redo work if a human reverses it. +``` + +- Defer only what depends on implementation details: a format, a library, a threshold, a name a worker will see first. Each entry has all five parts: question, default, the step whose worker settles it, the step it must be settled before, and what changes if the answer differs. +- A product or architecture question, or a `conflicts-with` the design left open, is not deferred here. Comment it on the design orchestration issue with the default you plan on, and keep planning. +- You never write decision records. The S8 orchestrator records each settled answer as a dated line under its entry. + +## 10. Rollout, rollback, risks and progress (step 11) + +- **Rollout and rollback.** How it ships (default on or behind a flag), what a user or operator must do, and how to undo it: revert the merge commits in reverse wave order, and how any migrated data goes back. +- **Risks.** Each with its likelihood, its effect, the mitigation and the step that owns the mitigation. +- **Progress.** One dated line per event, starting with `- <UTC>: plan drafted against <sha>, PR #<n>`. S8 keeps it current. diff --git a/.agents/skills/feature-plan/references/validation.md b/.agents/skills/feature-plan/references/validation.md new file mode 100644 index 0000000000..6826b6d9dc --- /dev/null +++ b/.agents/skills/feature-plan/references/validation.md @@ -0,0 +1,66 @@ +# Validating the plan with fresh context + +Read in step 11. You wrote the plan, so you cannot see what it leaves out. A validator that took no part in writing it reads the plan as a worker will. Run the mechanical checks first, so the validator spends its context on judgement, not counting. + +## 1. Mechanical checks + +```sh +python3 -I .agents/skills/feature-plan/scripts/plan_check.py "$PLAN" "$PKG" +``` + +It reads the steps under the `### Wave <n>` headings and reports: + +- a step missing any field of the step format in [plan-outline.md](plan-outline.md#4-the-step-format-step-6); +- a done check with no command in backticks; +- a `Requires:` target that is not a lower-numbered step in an earlier wave; +- a file written by two steps of one wave, and a step without `[P]` that shares its wave; +- with the package path, a `stated` or `human-confirmed` decision that no step cites. + +Fix everything it prints before launching the validator. Save the final `ok` line in the log. Outside a package, leave out `"$PKG"`. + +## 2. The validator prompt + +Give it to one fresh, read-only subagent. Pass paths, the branch SHA and URLs; never a summary of the plan ([collaboration.md](/planning/workflow/collaboration.md#the-rules), rule 9). + +```text +You are the plan validator. You wrote none of this plan. Do not edit files; run only read-only commands. + +Plan: <path> on branch <branch> at <sha>, PR <url>. Planned against: origin/<trunk> at <trunk sha>. +Must satisfy: <plan issue URL>; <consolidated design record>; <decision record paths>; <human-review.md>; + the plan format in planning/templates/plan.md, planning/workflow/ordering.md (Plans) and + .agents/skills/feature-plan/references/plan-outline.md. + +Check each point. Cite step numbers, and file:line at <trunk sha> for claims about code: +1. Coverage: every section of the design, every stated or human-confirmed decision and every accepted item + of <ITEM> is cited by a step, or listed under Scope: Out with where it is tracked. +2. Granularity: each step fits one PR and one fresh session. Name any that does not, and how to split it. +3. Edges: each Requires names a real input; each After states its rework; each file two steps write is + either reassigned or a Requires; nothing that is only a preference is a hard edge. +4. Waves: no two steps in a wave share a file; [P] steps in a wave share no file and no edge; the critical + path is the longest Requires chain. +5. Interfaces: every type, path, flag, format or name two steps share has one owner step before its users. +6. Tiers: no crucial step requires a lower tier; every contingent step names an observable trigger. +7. Tests: each step's "Test first" would fail at <trunk sha> (the behaviour it tests does not exist yet); + each "Done when" is a command that runs. +8. Deferred decisions: each has a default, the step that settles it, the step it must precede and what + changes if it differs; no step depends on a question that has none of these. +9. Could a worker holding only one step and its links start without asking a question? Name the step and + the question if not. + +Return: +Blocking: <step or section - problem - evidence - fix> +Non-blocking: <same> +Not checked: <what you did not verify> +``` + +Save the return verbatim as `$LIVE/validator-<round>.md`. + +## 3. Acting on findings + +- **Blocking.** Fix the plan, re-run `plan_check.py`, push, and give the new SHA to a new fresh validator. Never reuse a validator: it has seen the old plan. +- **Stop rule.** At most three rounds. After the third, each blocking finding still standing becomes a deferred decision with a default (plan-outline section 9), or a `Scope: Out` entry with a tracking issue. List each one in the PR body. +- **Non-blocking.** Fix it if it is cheap; otherwise list it in the PR body. Never let a non-blocking finding start another round. +- **Disagreeing.** If a blocking finding is wrong, write why in the log and the PR body, and give that reason to the next validator with the plan. Planning choices are yours to make; design choices are not (plan-outline section 9). +- **Design gaps.** A finding that the design is silent or contradictory is not fixed in the plan. Defer it with a default and comment it on the design orchestration issue. + +Done for step 11 means the last return has no blocking finding, or the stop rule has run and every remaining finding is deferred or tracked. diff --git a/.agents/skills/feature-plan/scripts/plan_check.py b/.agents/skills/feature-plan/scripts/plan_check.py new file mode 100644 index 0000000000..1d7d32962d --- /dev/null +++ b/.agents/skills/feature-plan/scripts/plan_check.py @@ -0,0 +1,109 @@ +"""Mechanical checks for a feature plan written in the ordering.md step format. + +Usage: python3 -I plan_check.py <plan.md> [<package dir>] + +Prints one line per problem, or "ok: <n> steps in <w> waves". With a package +directory it also lists `stated` and `human-confirmed` decisions no step cites. +Exits 1 when it finds a problem. +""" + +import re +import sys +from collections import defaultdict +from pathlib import Path + +FIELDS = ( + "Tier:", + "Goal:", + "Enables:", + "Requires:", + "Files:", + "Cites:", + "Test first:", + "Done when:", + "Size:", +) + + +def parse(text): + wave, step, steps = None, None, {} + for line in text.splitlines(): + if found := re.match(r"### Wave (\d+)", line): + wave, step = int(found[1]), None + elif line.startswith("## "): + wave, step = None, None + elif wave and (found := re.match(r"(\d+)\. \*\*(\[P\] )?", line)): + step = int(found[1]) + steps[step] = {"wave": wave, "parallel": bool(found[2]), "text": ""} + elif step and line.startswith(" - "): + steps[step]["text"] += line + "\n" + for fields in steps.values(): + text = fields["text"] + files = re.search(r"Files: (.*?)(?: Cites:|$)", text, re.MULTILINE) + fields["files"] = re.findall(r"`([^`]+)`", files[1]) if files else [] + bare = re.sub(r"\([^)]*\)", "", text) + requires = re.search(r"Requires: ([^.\n]*)", bare) + fields["requires"] = ( + [int(n) for n in re.findall(r"\d+", requires[1])] if requires else [] + ) + return steps + + +def problems(steps, package): + found = [] + for number, step in steps.items(): + found += [ + f"step {number}: missing {f}" for f in FIELDS if f not in step["text"] + ] + done = re.search(r"Done when: (.*)", step["text"]) + if done and "`" not in done[1]: + found.append(f"step {number}: done check is not a command") + for target in step["requires"]: + if target >= number or target not in steps: + found.append(f"step {number}: requires {target}, not a lower step") + elif steps[target]["wave"] >= step["wave"]: + found.append( + f"step {number}: requires {target} in its own or a later wave" + ) + waves = defaultdict(list) + for number, step in steps.items(): + waves[step["wave"]].append(number) + for wave, numbers in sorted(waves.items()): + writers = defaultdict(list) + for number in numbers: + for path in steps[number]["files"]: + writers[path].append(number) + if len(numbers) > 1 and not steps[number]["parallel"]: + found.append( + f"wave {wave}: step {number} has no [P] but shares the wave" + ) + found += [ + f"wave {wave}: {path} written by steps {', '.join(map(str, ns))}" + for path, ns in writers.items() + if len(ns) > 1 + ] + if package: + cited = "".join(step["text"] for step in steps.values()) + for record in sorted(Path(package, "decisions").glob("D*.md")): + source = re.search(r"^- Source: (\S+)", record.read_text(), re.MULTILINE) + decision = record.name.split("-")[0] + confirmed = source and source[1] in {"stated", "human-confirmed"} + if confirmed and not re.search(rf"\b{decision}\b", cited): + found.append(f"{decision} ({source[1]}) is cited by no step") + return found + + +def main(): + if len(sys.argv) not in (2, 3): + sys.exit(__doc__) + steps = parse(Path(sys.argv[1]).read_text(encoding="utf-8")) + found = problems(steps, sys.argv[2] if len(sys.argv) == 3 else None) + if not steps: + found.append("no steps found under '### Wave <n>' headings") + waves = len({step["wave"] for step in steps.values()}) + print("\n".join(found) or f"ok: {len(steps)} steps in {waves} waves") + sys.exit(1 if found else 0) + + +if __name__ == "__main__": + main()