diff --git a/.ytstack/DECISIONS.md b/.ytstack/DECISIONS.md index 0fd25f9a..f2e8b2c0 100644 --- a/.ytstack/DECISIONS.md +++ b/.ytstack/DECISIONS.md @@ -1377,3 +1377,111 @@ Plus: ops-layer split during the same session (yopstack created as own public re **Reason:** "Merged" is the one state in which a person looked at the command (a change under `standing/` goes to a person). C would drop the compliance check of issue #74. Starting the new day from the pending branch keeps one pull request per day and lets `end`/`--supersedes` see what waits; the cost is that a day's pull request carries the earlier day's commits until that one merges. **Supersedes:** Narrows "2026-11-15: Standing entries end by `until` ...": the commands run only for merged entries. + +## 2026-11-15: The spec delta is the report's existing `Spec:` label, checked for its form (issue #75) + +**Context:** Lanes of a long coordinator run updated receipts and changelogs and never the area files their change made false. The brief listed the area files only as reading context, and the report's `Spec:` line accepted any text. + +**Options considered:** +- A) A twelfth label `Spec delta:` beside `Spec:`. +- B) Rename `Spec:` to `Spec delta:`. +- C) Keep `Spec:` and give it a checked form: `: (
)` per edited section, joined by `;`, or `none -- `, with the brief stating the duty to edit the section. + +**Chose:** C. + +**Reason:** The label already says what the plan's `## Spec impact` promised, in the plan's own two forms (`summarize-task` records the same two forms under `## Spec`). A second label would hold the same fact twice; a rename breaks every report and fixture for no gain. What was missing was the duty in the brief and a check that a bare `none` or prose fails. + +**How to apply:** +- The reasons after `none --` are the plan rule's: restores the described behaviour, no behaviour or contract changes, not covered by an area. +- `bin/ytstack-brief check` checks the form only; whether the diff matches the delta is checked by `bin/ytstack-finish-lane route`. + +**Supersedes:** None. + +## 2026-11-15: A brief for an unplanned task makes the task plan its first deliverable (issue #76) + +**Context:** In a long coordinator run no lane planned its tasks. `ytstack-brief render` said "not planned yet: run ytstack:plan-task first, or plan it yourself", so lanes coded without Files, Verification or Spec impact. + +**Options considered:** +- A) `render` runs `plan-task` inline before the brief. +- B) A plan-first brief: the worker writes the task plan in `plan-task`'s format first, commits it alone, then implements what it names. +- C) Refuse to render until the plan exists. + +**Chose:** B. + +**Reason:** A script cannot run a skill, and `plan-task` asks questions a coordinator answers poorly at dispatch time (A). C was the old behaviour for `--task` and is what coordinators routed around by writing briefs by hand. B keeps the dispatch on the rendered path and leaves a plan on disk that `summarize-task`, `ytstack-spec impact` and `finish-lane` can check. + +**How to apply:** +- The plan goes beside the slice plan; the slice plan's backticked paths of the task line are hints, not the scope. +- A review of an unplanned task still has no brief: there is nothing to review against. + +**Supersedes:** None. + +## 2026-11-15: `finish-lane`'s route checks the spec delta; a gap routes to a person (issue #75) + +**Context:** `summarize-task` checks a plan's spec impact, but lanes that skip it merged with no check at all. `finish-lane` read the receipt and the gates, never the spec. + +**Options considered:** +- A) A separate `finish-lane` step `spec` the skill has to call. +- B) Inside `ytstack-finish-lane route`: after `ytstack-risk route`, the spec delta; a gap is a `reason: spec` line and makes the route `person`. +- C) Inside `ytstack-risk route`, for every caller. + +**Chose:** B. + +**Reason:** A step that can be skipped is the failure this issue reports. `route` is already the one call a merge without a person needs. `ytstack-risk` reads a policy at the base commit and stays a function of the diff and the review records; the worker's report is a lane artifact, which only `finish-lane` holds (C would make it read a file it has no record of). + +**How to apply:** +- Plans first: a plan that states `## Spec impact` is checked with `ytstack-spec impact --base --head`, and the report cannot override it. Without one, an area the diff touches needs its area file or a source in the diff, or `Spec: none -- ` in the report given with `--report`. +- The area files are read from the coordinating checkout's working tree, not at the base commit; a change to an area file's frontmatter is a `person` floor anyway. +- Under `merge_by: coordinator` a `reason: spec` line still sends the lane back to the worker. +- No technical spec: `spec: no technical spec`, nothing changes. + +**Supersedes:** None. + +## 2026-11-15: The checks inventory is a `## Checks` section of `REVIEW.md`, not an area file (issue #75) + +**Context:** A guard that a lane added (component levels in CI) was described only in its receipt; reviewers had no place that says which machine checks they can rely on. + +**Options considered:** +- A) `.ytstack/spec/checks.md` as an area file. +- B) A sixth section `## Checks` in `REVIEW.md`: ` | file: | guards: `. + +**Chose:** B. + +**Reason:** An area file describes a part of the system with fixed sections, `paths` and a `status` (`docs/ux/spec-format.md`); an inventory of checks across areas has none of these, and `lint`, `drift` and `impact` would read it as an area. `REVIEW.md` is already the page of what reviewers go by, it is read at the base commit and its changes are `person`, so the inventory cannot be relaxed on the route it informs. + +**How to apply:** +- The line says what holds; the rule itself stays in the area file or its source. +- `ytstack-risk check` checks the form and that `file` exists. Whether a change adds a guard is the reviewer's judgment (`code-review`); `finish-lane` only notes a CI edit without an inventory change. +- This repository keeps no `REVIEW.md` yet; its checks are listed in `checks-and-evals.md`. + +**Supersedes:** None. + +## 2026-11-15: `reconcile` writes task-plan skeletons and fixes the STATE pointer, after asking; the logic is `bin/ytstack-reconcile` (issue #76) + +**Context:** A project ran three milestones with no task plans, and `current_milestone` stayed two milestones behind while the lint warned at every start. `reconcile` did not touch either: it never wrote plans and never edited the pointer. + +**Options considered:** +- A) A new skill (`ytstack-adopt-plan`). +- B) Two classes of `reconcile`, one question each, with a script that lists without writing and writes only with `--write` / `--fix`. + +**Chose:** B. + +**Reason:** Both are leftovers of work that went past the loop, which is what `reconcile` is for, and its contract (ask per class, never delete, log every choice) is the one these edits need. The listing has to be exact (open milestones, slices with no task plan at all, the newest roadmap in progress), so it is a tested script and not prose. + +**How to apply:** +- Only slices with no task plan at all are listed: a slice planned one task at a time is the normal loop, not a leftover. +- A skeleton fills only what the slice plan says and marks the rest `TODO`; its Spec impact is not accepted by `ytstack-spec impact` until a person or `plan-task` fills it. Existing plans are never written over. +- The pointer target is the newest roadmap with `status: in-progress`; a planned or backlog milestone is never made current here (the user picks, as after an external-plan mapping). `active_task` becomes `none`. +- This narrows the rule "no edits to STATE.md pointer fields" of `reconcile` (Step 4, and the artifacts area) to: only through `pointer --fix`, after a yes. + +**Supersedes:** None. + +## 2026-11-15: The spec delta of a lane is checked per area, from the plans of its own range (PR #88 review) + +**Context:** An independent review of PR #88 found that one task plan with a "Spec impact" switched the area check off for the whole slice diff (a second area merged unchecked), that task plans of earlier work were checked against the lane's range (a false `person`), and that the report could name any changed file as a "spec edit". + +**Chose:** The check runs per area. Every area the diff touches (renames with both paths, as `ytstack-risk` reads a diff) needs its area file or a source in the diff, a plan of the range that says `none -- ` for the files of its own commits, or the report's reason. A plan belongs to the range when it changed in it or a commit of its task is in it. A path the report names is the area file or a source of that area. + +**How to apply:** This replaces the first two "How to apply" points of "2026-11-15: `finish-lane`'s route checks the spec delta; a gap routes to a person (issue #75)": a plan of the range that names an area is still checked with `impact` and the report cannot override it, but a plan no longer stands in for areas its task did not touch. + +**Supersedes:** None. Narrows the entry named above. diff --git a/.ytstack/spec/artifacts.md b/.ytstack/spec/artifacts.md index 55a1b465..78bd9c83 100644 --- a/.ytstack/spec/artifacts.md +++ b/.ytstack/spec/artifacts.md @@ -44,7 +44,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory |---|---|---| | `PROJECT.md`, `PREFERENCES.md` | `init-project` or `adopt-brownfield` (both templates write `upstream_feedback: suggest`) | the user; the only skill edit is one `external_plans: mapped\|declined ` line in `PREFERENCES.md` per answered external plan (`reconcile`, `adopt-brownfield`, `docs/ux/external-plans.md`) | | `RUNTIME.md` | `init-project` or `adopt-brownfield`, with the headings "Run", "Release" and "Signals" and one line of free text each | the user; key lines in the three sections follow `docs/ux/runtime-format.md` and are read only through `bin/ytstack-runtime`; `adopt-brownfield` writes a key line only for a command a document or script of the project states and names that source. "Release" is run by `bin/ytstack-watch release`, "Signals" by `signal-intake` and `incident` | -| `spec/REVIEW.md` | a person (optional), linked from `SPEC.md` | a person; five sections (Always a person, Never low, Lenses, Size, Own reviewers); a change to it always goes to a person | +| `spec/REVIEW.md` | a person (optional), linked from `SPEC.md` | a person; six sections (Always a person, Never low, Lenses, Size, Own reviewers, Checks); a change to it always goes to a person | | `evidence////` with `MANIFEST` (`evidence_dir` of `PREFERENCES.md`) | `visual-review`, in the main checkout of the repository; `bin/ytstack-risk manifest` writes hash and name per image | -- ; a process record; committing it is the project's choice | | `signals/F###-.md` | `bin/ytstack-signals new` (from `signal-intake`; `--kind review` from `review-lessons` for an escaped review-bot finding; `lesson new` from `lesson` for what an incident of any class taught, key `lesson::` and a `target`) | `bin/ytstack-signals new` (a second sighting: count, last seen), `set` (state, ref, a lesson's target); format `docs/ux/signal-format.md` | | `signals/review-checks` | `bin/ytstack-signals review-checked` | the same command, one line appended per merged pull request whose escape check ran; never rewritten | @@ -57,7 +57,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory | `M###-CONTEXT.md` | `plan-milestone`; `reconcile` or `adopt-brownfield` when they map an external plan (`## Source` names the plan file) | `grill` (decisions), `reassess-roadmap` (reassessment note, backlog sweep, note for `shipped-informally`) | | `M###-ROADMAP.md` | `plan-milestone`; the external plan mapping | `slice-milestone` (slice names), `plan-task` and `summarize-task` (`status`), `reassess-roadmap` (slices, checkboxes, counts, `status`), `plan-ceo-review`, `reconcile` (`status`) | | `M###-S##-PLAN.md` | `slice-milestone`; the external plan mapping (`**Source:**` with `path:line` and the row id, every task line with its pointer) | `summarize-task` (checkbox, count, `status`), `plan-eng-review`, `hooks/task-completed` (checkbox) | -| `M###-S##-T##-PLAN.md` | `plan-task` | notes by `test-driven-development` and `systematic-debugging` | +| `M###-S##-T##-PLAN.md` | `plan-task`; the worker of a plan-first brief (`bin/ytstack-brief`); a skeleton with `TODO` fields by `reconcile` (`bin/ytstack-reconcile skeletons --write`, `skeleton:` in the frontmatter) | notes by `test-driven-development` and `systematic-debugging`; the `TODO` fields of a skeleton by a person or `plan-task` | | `M###-S##-T##-SUMMARY.md` | `summarize-task`; a draft stub by `hooks/post-tool-use-bash`; an auto summary by `hooks/task-completed` | `summarize-task` replaces a stub; `reconcile` may mark it `closed: abandoned` | | `M###-RETRO.md` | `retro`; its `## Upstream` section says what of the milestone concerns ytstack itself and what happened to it (`docs/ux/upstream-feedback.md`) | -- | | `quick/Q###-PLAN.md`, `quick/Q###-SUMMARY.md` | `quick-task` | `quick-task` (`status`) | @@ -126,10 +126,10 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact ### Ownership and cleanup - Every file under `.ytstack/` is user-owned. Skills, agents and hooks do not delete, move, truncate or revert it. -- `reconcile` is the only path that moves artifacts. It lists the leftovers by class (draft stubs, unfilled hook drafts, milestones planned and never sliced, untracked files, a `.local` directory that is not ignored, history inside `STATE.md`, slice and task files of closed milestones) and asks per class: close, archive or keep. A large plan outside `.ytstack/` that `bin/ytstack-plans scan` reports is one more class with map or leave. +- `reconcile` is the only path that moves artifacts. It lists the leftovers by class (draft stubs, unfilled hook drafts, milestones planned and never sliced, untracked files, a `.local` directory that is not ignored, history inside `STATE.md`, slice and task files of closed milestones) and asks per class: close, archive or keep. A large plan outside `.ytstack/` that `bin/ytstack-plans scan` reports is one more class with map or leave. Two migration classes come from `bin/ytstack-reconcile`: tasks of open slices that never got a task plan (write skeletons, for named slices, or keep) and a `STATE.md` pointer on a closed or older milestone than the newest one in progress (fix or keep). - The history class moves earlier status paragraphs of `STATE.md` verbatim to `archive//STATE-history.md` and leaves the frontmatter, the current status, "Next action" and "Open decisions". It is the only edit to the body of `STATE.md` that `reconcile` makes, and only after its question was answered with yes. The closed-milestone class exists only in a project with a technical spec and keeps each milestone's `CONTEXT` and `ROADMAP` in place. - At the last slice of a milestone `reassess-roadmap` folds what still holds into the area files (changed behaviour, decisions in force, limits) and names the archive offer; it moves nothing. -- Archiving moves files to `archive//` inside `.ytstack/` (`git mv` when tracked) and adds a line to `archive/INDEX.md`. `reconcile` edits only `status:` and `closed:` fields and `ROADMAP.md` rows, never runs `rm`, never edits the `STATE.md` pointer, and logs to `RECONCILE-.md`. Mapping an external plan only adds milestone and slice files with `status: planned` and `ROADMAP.md` rows; the plan itself is read and never written. +- Archiving moves files to `archive//` inside `.ytstack/` (`git mv` when tracked) and adds a line to `archive/INDEX.md`. `reconcile` edits only `status:` and `closed:` fields and `ROADMAP.md` rows, never runs `rm`, edits the `STATE.md` pointer fields only through `ytstack-reconcile pointer --fix` after a yes to that class, adds task-plan skeletons without writing over an existing plan, and logs to `RECONCILE-.md`. Mapping an external plan only adds milestone and slice files with `status: planned` and `ROADMAP.md` rows; the plan itself is read and never written. - `init-project` stops when `.ytstack/` exists. `adopt-brownfield` stops when `.ytstack/` and `spec/SPEC.md` exist; with `.ytstack/` and no spec it writes only `spec/` and the codebase map files that are missing. It does not overwrite a file under `.ytstack/`. - An area file is rewritten when its area changes; it carries no history. The other artifacts are appended to or advanced. @@ -167,7 +167,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - Technical spec: scaffolds in `skills/init-project/SKILL.md` (Step 7) and `skills/adopt-brownfield/SKILL.md` (Steps 2 and 7); "Spec impact" in `skills/plan-task/SKILL.md` (Step 7); the closure check in `skills/summarize-task/SKILL.md` (preamble and Step 8); the tool `bin/ytstack-spec`; this repository's own spec under `.ytstack/spec/`. - `hooks/lib/git-ctx.sh`: `yt_resolve_yt_dir`, `yt_state_lint`, `yt_progress_parse`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_artifact_dir`, `yt_artifact_path`, `yt_state_base`, `yt_state_dir`, `yt_ensure_gitignore`. - Hooks that touch artifacts: `hooks/post-tool-use-bash`, `hooks/task-completed`. Out-of-tree writers: `hooks/pre-compact`, `hooks/session-end`. -- Tests: `tests/git-ctx.test.sh` (scope resolution, state dirs, commit discovery, lint, `progress`, gitignore block, the artifact directory), `tests/skill-preambles.test.sh` (a milestone in `milestones/M###/`, `reconcile` classes, the external plan offer of `reconcile` and `adopt-brownfield`, `Q###` numbering, tracker, handoff lookup), `tests/post-tool-use-bash.test.sh` (stub once, ref match), `tests/pre-compact.test.sh` (`HANDOFF.md` untouched), `tests/ytstack-status.test.sh` (`progress` block). +- Tests: `tests/git-ctx.test.sh` (scope resolution, state dirs, commit discovery, lint, `progress`, gitignore block, the artifact directory), `tests/skill-preambles.test.sh` (a milestone in `milestones/M###/`, `reconcile` classes, the external plan offer of `reconcile` and `adopt-brownfield`, `Q###` numbering, tracker, handoff lookup), `tests/post-tool-use-bash.test.sh` (stub once, ref match), `tests/pre-compact.test.sh` (`HANDOFF.md` untouched), `tests/ytstack-status.test.sh` (`progress` block), `tests/ytstack-reconcile.test.sh` (task-plan skeletons, the STATE pointer). ## How to verify @@ -188,7 +188,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - DECISIONS.md -- "2026-11-13: Production findings and incidents are skill work on read-only access; a mitigation is a handover script a person runs (M027)" (`signals/`, `incidents/`) - DECISIONS.md -- "2026-11-13: The technical spec is a set of artifacts of its own under `.ytstack/spec/` (M022, issue #36)" - DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)" (the `Runs:` line, `## Gates`, `## Review`, the evidence fields of a summary) -- DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)"; "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)" (the external plan class) +- DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)"; "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)" (the external plan class); "2026-11-15: `reconcile` writes task-plan skeletons and fixes the STATE pointer, after asking; the logic is `bin/ytstack-reconcile` (issue #76)"; "2026-11-15: A brief for an unplanned task makes the task plan its first deliverable (issue #76)" (the second writer of a task plan) - DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)" (the lanes table is not part of `STATE.md`, which narrows the proposal in issue #34) - DECISIONS.md -- "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", extended by "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)" - DECISIONS.md -- "2026-04-23: `.ytstack/` location is user-chosen (project vs user vs both)"; "2026-11-15: New artifacts follow the directory a milestone already lives in (issue #70)" @@ -197,4 +197,4 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - DECISIONS.md -- "2026-11-07: Hooks never write relative to CLAUDE_PROJECT_DIR; volatile state lives out-of-tree, per session and per worktree" (extends the stub-once entry to all hooks; ends hook writes to `HANDOFF.md` and the in-tree journal; user scope is keyed by the repo key, which narrows the slug path in the 2026-04-23 entry) - DECISIONS.md -- "2026-11-07: Ceremony scales with the change -- granularity, autonomy, quick lane and minimal-code guard are project preferences with loud defaults" (artifact states, `Q###` artifacts, `reconcile`, user-owned artifacts) - DECISIONS.md -- "2026-11-07: Brownfield adoption is a reference-first distillation, never a pitch" (existing documents stay the source of truth; `.ytstack/` links to them) -- DECISIONS.md -- "2026-11-11: Status line progress is one optional `progress` block in STATE.md, read by a plugin script (M021, issue #31)" +- DECISIONS.md -- "2026-11-11: Status line progress is one optional `progress` block in STATE.md, read by a plugin script (M021, issue #31)" \ No newline at end of file diff --git a/.ytstack/spec/checks-and-evals.md b/.ytstack/spec/checks-and-evals.md index 9cdb88cd..1885dffa 100644 --- a/.ytstack/spec/checks-and-evals.md +++ b/.ytstack/spec/checks-and-evals.md @@ -17,6 +17,7 @@ paths: - bin/ytstack-signals - bin/ytstack-upkeep - bin/ytstack-plans + - bin/ytstack-reconcile - bin/ytstack-upstream - tests/** - evals/** @@ -31,7 +32,7 @@ sources: - docs/ux/signal-format.md - docs/ux/external-plans.md - docs/ux/upstream-feedback.md -verified_at: 1234c16 +verified_at: 53a0f84 --- # checks-and-evals @@ -56,7 +57,7 @@ Everything that tells a contributor whether a change is acceptable: the static c **`bin/ytstack-spec`: the technical spec of any project** -- A bash script on git and awk. `lint` checks the format of `.ytstack/spec/`, `drift` lists areas whose `paths` changed after the description or one of its `sources` was last touched, `impact` checks a task plan's "Spec impact" against what the task changed, `areas` names the area of a path. Rules and exit codes: `docs/ux/spec-format.md` and the comment at the top of the script. +- A bash script on git and awk. `lint` checks the format of `.ytstack/spec/`, `drift` lists areas whose `paths` changed after the description or one of its `sources` was last touched, `impact` checks a task plan's "Spec impact" against what the task changed (with `--base` and `--head` against that commit range only, renames with both paths, without the working tree: a lane's branch read from another checkout; a `TODO` field of a skeleton fails, the word inside a filled line does not), `areas` names the area of a path. Rules and exit codes: `docs/ux/spec-format.md` and the comment at the top of the script. - `drift` is advisory and exits 0 unless `--exit-code` is given. It never reads `verified_at`; an area file that is new or edited in the working tree is skipped. - `lint` fails on an `auto_merge` outside `none`, `low` and `normal`, on a `REVIEW.md` that `SPEC.md` does not link, and on every line `bin/ytstack-risk check` prints. `REVIEW.md` is not an area file: `drift`, `impact` and `areas` do not read it. @@ -64,7 +65,7 @@ Everything that tells a contributor whether a change is acceptable: the static c - `floor --base --head ` prints the lowest class of the tree difference (`low`, `normal` or `person`), one `reason:` per path and rule, the touched areas, their ceiling and the required lenses. It reads the policy at the base commit, never from the working tree; git matches the globs. Process records (exempt from coverage and size) are the files the source lists, a milestone's files also in `milestones/` or `backlog/` and at most one directory below them. - `route [--plan ] [--pr [--repo ]] --base --head --author ` exits 0 with `route: unattended` only when the floor is not `person`, the newest round line approves, states `risk` and `invariants: none`, names a reviewer other than the author and is valid for the head, the class is within the ceiling, and every required lens has a passing line with its evidence (for `evidence: visual` a `MANIFEST` whose hashes match). Every other case exits 10 with `route: person` and one reason per failed condition. `by: self` and a missing `--author` always route to a person. With `--pr` the round and lens lines come first from the bodies of the pull request's reviews (one `gh api` read; submitted, not dismissed, by an owner, member or collaborator; the reviewer of a used line must have `admin`, `maintain` or `write` permission, read once per reviewer, a failed read routes to a person), each taken for the `commit_id` the host tied its review to; the plan counts only when no review carries a line of that kind, and a `round:` line names the source. A line naming another commit than the host's, a review that requests changes (also one without a record line, when it is its reviewer's newest review) and a failed read route to a person. -- `check` validates `REVIEW.md`, its "Own reviewers" too (slug names, a unique `marker`, a `lessons` file that exists); `reviewers` prints the own reviewers tab separated; `manifest ` writes hash and name of every image into the `MANIFEST` of an evidence directory. +- `check` validates `REVIEW.md`, its "Own reviewers" too (slug names, a unique `marker`, a `lessons` file that exists) and its "Checks", the inventory of machine checks reviewers rely on (a slug name, a `file` that exists, `guards`); `reviewers` prints the own reviewers tab separated; `manifest ` writes hash and name of every image into the `MANIFEST` of an evidence directory. **`bin/ytstack-review-escapes`: review-bot findings the own reviewers missed** (`docs/ux/review-policy-format.md`, "Escapes") @@ -86,16 +87,16 @@ Everything that tells a contributor whether a change is acceptable: the static c **`bin/ytstack-brief`: the brief of a dispatched worker and its report** -- A bash script on awk. `render --task ` or `--slice ` prints a brief built from the plan files and `skills/spawn-milestone-team/brief-template.md`, and includes the body of `skills/minimal-code/SKILL.md` as the work contract, read at render time. It prints no brief when the plan, its `## Files` section, the template or the contract is missing (exit 1). +- A bash script on awk. `render --task ` or `--slice ` prints a brief built from the plan files and `skills/spawn-milestone-team/brief-template.md`, and includes the body of `skills/minimal-code/SKILL.md` as the work contract, read at render time. It prints no brief when the plan, its `## Files` section, the template or the contract is missing (exit 1). An open task of a slice plan with its own `## Files` (granularity slice) is briefed from the slice plan; a task it does not list open gets no brief. Any other task without a plan whose slice plan lists it as open gets a plan-first brief (not for `--kind review`): its first deliverable is the task plan beside the slice plan, in the format of `plan-task` Step 9 (Files, What this does, Spec impact, Verification), committed alone, then the files that plan names; Scope lists the backticked paths of the task line as hints. A slice brief names the plan to write for each unplanned task. No brief tells the worker to plan it some other way. - `render --kind implement|review|prepare` adds what the worker may do; a review brief pins the commit range it reviews (`--head`, optionally `--base`) and has no Git section. Every brief carries a section "Standing instructions" with the active entries for its kind (`review`: the reviewer role, else lane; `yt_standing_lines`), left out when there are none. `render --lesson F###` builds the brief of the lesson lane `lesson-F###` from the lesson in `signals/` (outcome from its title, target and "Assessment"; scope and check from its "Files" and "Verification"; commit prefix the lane). -- `check` validates a worker's report from a file or stdin: the labels of the template's "Report" section, each with a value, an exit code in every `Checks run:` line, one of the three `Status:` values and its consistency with `Blockers:`. It prints one line per problem and exits 1, or `report ok`. +- `check` validates a worker's report from a file or stdin: the labels of the template's "Report" section, each with a value, an exit code in every `Checks run:` line, one of the three `Status:` values and its consistency with `Blockers:`, and a spec delta under `Spec:` (`none -- `, or `: ` per edited section, joined by `;`, backticks ignored, the path running to the closing `(
)` (spaces allowed); a bare `none` fails; run in a project with a spec, each path is the area file or one of its sources). It prints one line per problem and exits 1, or `report ok`. The brief's "Spec impact" section makes the edit a duty: a change that makes a sentence of a listed area file false edits that section in the same commits. **The coordinator scripts** (formats and rules: `docs/ux/coordinator-format.md`; each has a suite of the same name under `tests/`) - `bin/ytstack-frontier`: `list` prints lane, state and detail per slice (done, claimed, blocked, ready) of the current milestone (with `none`: the highest roadmap not `done`, `dropped`, `shipped-informally` or `backlog`), then one lesson lane `lesson-F###` per open or planned lesson whose target is a check (blocked without non-empty "Files" and "Verification" in the lesson; listed also without a milestone); `claim` refuses a held lane and names the holder; `claim`, `set` and `release` change one row of `LANES.md` under a lock; `check` validates the file and then prints one `stale:` line per lane that stalls, exit 2 (issue #84): a `running` row whose worktree no longer exists, an `implement` row whose branch had no commit for `--minutes` (default 60, from the claim when that is newer, or from the first sight of its fix round when the row carries a pull request), a `review` or `prepare` row running 3 x `--minutes` since its claim, and a `ready` lane nobody claimed for `--minutes` since a check first saw it (first sights in `/repos//frontier-seen`, outside the tree, under a noclobber lock); `peer set` and `peer list` keep the `## Peers` lines of `LANES.md` (role, repository, address, last contact), list items that no table reader sees. The lock is the file `LANES.md.lock`, created by the shell under noclobber and not by `mkdir`, which is no lock on Ubuntu 26.04 (see `.ytstack/KNOWLEDGE.md`). -- `bin/ytstack-plans` (`docs/ux/external-plans.md`): `scan` counts the work rows (task-list items, rows of tables with a status or checkbox column, nothing in a code fence) of `plans/`, `roadmap/` and their variants and prints one line per directory with `verdict=large` from 10 open rows and the answer recorded in `PREFERENCES.md`; exit 0 only for a large directory without an answer. `rows` prints `path:line`, state, id, section and title per row; a relative PATH is read from where the command was started, else from the repository root, and the output names files relative to the root. It writes nothing; the mapping is the agent's (`reconcile`, `adopt-brownfield`). +- `bin/ytstack-plans` (`docs/ux/external-plans.md`): `scan` counts the work rows (task-list items, rows of tables with a status or checkbox column, nothing in a code fence) of `plans/`, `roadmap/` and their variants and prints one line per directory with `verdict=large` from 10 open rows and the answer recorded in `PREFERENCES.md`; exit 0 only for a large directory without an answer. `rows` prints `path:line`, state, id, section and title per row; a relative PATH is read from where the command was started, else from the repository root, and the output names files relative to the root. It writes nothing; the mapping is the agent's (`reconcile`, `adopt-brownfield`). `bin/ytstack-reconcile` (the two migration classes of `reconcile`, issue #76): `skeletons` lists, per open task of a slice that has no task plan at all and no `## Files` of its own, in a milestone not done, dropped, shipped-informally or backlog, the task, the plan to write beside the slice plan and the number of paths found; `--write` (optionally `--slice M###-S##`) writes each in `plan-task`'s format with Files from the task line's backticked paths or the slice plan's `Own:`/`Files:` lines, Spec impact lines per area with `TODO` fields that `ytstack-spec impact` rejects until filled, a `TODO` verification, `skeleton: reconcile `, and never over an existing file. `pointer` says `ok`, `no milestone in progress` or `behind` (exit 10) when `current_milestone` is closed, `none` or older than the newest roadmap `in-progress`; `--fix` sets `current_milestone`, `active_slice` (its first open slice), `active_task: none` and `last_updated` in the pointer block only (the frontmatter, or the `key: value` lines a file without one starts with), adds the keys that are missing there, refuses a file with neither (exit 1, nothing written) and reports what the file says after the write. - `bin/ytstack-questions`: `new`, `list`, `next`, `ask` (once), `answer` (refused without text under "Answer"), `check`. `bin/ytstack-standing` (`docs/ux/coordinator-format.md`, "standing/"): `add` writes one entry, validated by `ytstack-check --standing` before anything is committed, by default in its own worktree outside the checkout on `standing/` with a commit, a push and one pull request per UTC day (opened through `ytstack-pr-watch create` when `pr_watch=on` and the session has an id, else `gh pr create`; updated when one is open); `--here` and user scope write into the resolved directory only; exit 3 when the commit stands but the push or the PR failed; a new day's branch starts from the newest pending standing branch, an earlier one with unpushed commits is pushed first. `end` writes the closing entry of `kind: end`, also of a pending entry. `list` prints the newest entry's age and the human prompts since (from the coordinate session's counter), the active entries with the pending ones marked (local `standing/*` branches and their upstreams only), then the ended ones, the conditions to check and the failed checks; it is the only place `until-check` and `check` run, and only for a working-tree entry identical to the default branch's (bash in its own process group, killed on timeout, stdin closed, `YTSTACK_STANDING_TIMEOUT` seconds each, default 5, at most ten per call, every one not run says why), `--no-checks` runs none. Its suite uses a stand-in for `gh`, a local bare remote behind an `insteadOf` URL and the real `ytstack-pr-watch create`. -- `bin/ytstack-finish-lane`: one step per call (`leftovers`, `commit`, `push`, `open-pr`, `wait-head`, `body-check`, `gates`, `merge`, `route`); every gate is read from GitHub through `gh` at the moment of the call, and `merge` passes the reviewed commit to the host so that a moved head cannot be merged. `route --lane [--pr ]` reads the lane's worker (the author) and plan from `LANES.md` and runs `bin/ytstack-risk route`; with `--pr` it passes the pull request on, and a lane without a plan file is routed from the host's reviews. `leftovers` and `commit` leave the evidence directory out. Its suite uses a stand-in for `gh` and a local bare remote. +- `bin/ytstack-finish-lane`: one step per call (`leftovers`, `commit`, `push`, `open-pr`, `wait-head`, `body-check`, `gates`, `merge`, `route`); every gate is read from GitHub through `gh` at the moment of the call, and `merge` passes the reviewed commit to the host so that a moved head cannot be merged. `route --lane [--pr ] [--report ]` reads the lane's worker (the author) and plan from `LANES.md` and runs `bin/ytstack-risk route`; with `--pr` it passes the pull request on, and a lane without a plan file is routed from the host's reviews. With a technical spec it then checks the spec delta and prints `spec:` lines: every plan of the lane that belongs to the range (changed in it, or a commit `:` in it; a slice lane's task plans too) with a "Spec impact" through `ytstack-spec impact --base --head`; then every area the diff touches (`--no-renames`) needs its area file or a source in the diff, a plan of the range with `none -- ` for the files of its commits, or `Spec: none -- ` in the worker's report; a path the report names is the area file or a source of its area, and in the diff. Each gap is a `reason: spec` line and turns `unattended` into `person` (exit 10). When `REVIEW.md` keeps a "Checks" section and the diff edits CI without touching `REVIEW.md`, one `checks:` line says so (a note, CI changes go to a person anyway). `leftovers` and `commit` leave the evidence directory out. Its suite uses a stand-in for `gh` and a local bare remote. - `bin/ytstack-handover`: `new` copies `skills/handover-step/template.sh`; `check` is the static verification of a staged script (syntax, unchanged helper block, no raw command, a confirmation of its own before every mutation, no pipe into a shell). The helpers hold the same rule when the script runs: one yes carries one change. - `bin/ytstack-watch`: polls pull requests through `gh` and prints a line only when head, checks, review or mergeability changed; `--once` prints the snapshot with its read time. `release --commit ` runs `deployed` of "Release" until it names the commit (or `--timeout`, default 900 s), then `healthy` for the settle time, and ends with five receipt lines (`Target:`, `Commit:`, `Arrived:`, `Health:`, `Result:`) with read times. Exit 0 released or no health command, 2 not arrived, 3 unhealthy, 4 no "Release" section, 1 `RUNTIME.md` fails its check. It runs only those two commands and changes nothing. @@ -162,9 +163,8 @@ Everything that tells a contributor whether a change is acceptable: the static c - `bin/ytstack-check` -- the checker; its docstring names the flags and exit codes. `bin/ytstack-spec` (the spec tool) and `bin/ytstack-brief` (brief renderer and report check), pinned by `tests/ytstack-spec.test.sh` and `tests/ytstack-brief.test.sh`. - `bin/ytstack-frontier`, `bin/ytstack-questions`, `bin/ytstack-standing`, `bin/ytstack-finish-lane`, `bin/ytstack-handover`, `bin/ytstack-watch` -- the coordinator scripts, each with `tests/.test.sh`. -- `bin/ytstack-risk`, `bin/ytstack-review-escapes`, `bin/ytstack-runtime`, `bin/ytstack-signals`, `bin/ytstack-upkeep`, `bin/ytstack-plans`, `bin/ytstack-upstream`, each with `tests/.test.sh` (the live cases of `ytstack-runtime` need `python3` and are skipped without it). Suites under `pipefail` read pipes to the end (`grep_q`, not `grep -q`: SIGPIPE). `tests/evals-frontmatter.test.sh` lints every `evals/*/prompt.md` frontmatter for plain scalars holding `: ` or ` #`, which keep a case from loading. -- `tests/run-all.sh` -- the suite runner. `tests/*.test.sh` -- the suites. `tests/codex_plugin_test.py`, `kimi_plugin_test.py`, `kimi_lifecycle_test.py`, `kimi_live_test.py` -- the Python host tests. `evals//` -- the eval cases. `evals/README.md` -- how to run them. -- `.github/workflows/ci.yml`, `plugin-check.yml`, `secret-scan.yml`; `CONTRIBUTING.md` ("Release checklist") -- the checks expected before a release. +- `bin/ytstack-risk`, `bin/ytstack-review-escapes`, `bin/ytstack-runtime`, `bin/ytstack-signals`, `bin/ytstack-upkeep`, `bin/ytstack-plans`, `bin/ytstack-reconcile`, `bin/ytstack-upstream`, each with `tests/.test.sh` (the live cases of `ytstack-runtime` need `python3` and are skipped without it). Suites under `pipefail` read pipes to the end (`grep_q`, not `grep -q`: SIGPIPE). `tests/evals-frontmatter.test.sh` lints every `evals/*/prompt.md` frontmatter for plain scalars holding `: ` or ` #`, which keep a case from loading. +- `tests/run-all.sh` -- the suite runner. `tests/*.test.sh` -- the suites. `tests/codex_plugin_test.py`, `kimi_plugin_test.py`, `kimi_lifecycle_test.py`, `kimi_live_test.py` -- the Python host tests. `evals//` -- the eval cases. `evals/README.md` -- how to run them. The workflows: `.github/workflows/ci.yml`, `plugin-check.yml`, `secret-scan.yml`; `CONTRIBUTING.md` ("Release checklist") -- the checks expected before a release. - `docs/ux/skill-structure.md`, `docs/ux/agent-structure.md`, `docs/ux/writing-style.md` -- the contracts the checker enforces in part. ## How to verify @@ -187,7 +187,7 @@ Not covered by these checks: `claude plugin eval` (costs money). `bash tests/run - DECISIONS.md -- "2026-11-13: After a merge the release is watched, not driven; upkeep is a script and a recipe, not a skill (M026)". Source of `release` and `bin/ytstack-upkeep`. Extended by "2026-11-15: Lane liveness is part of `ytstack-frontier check`, worktree cleanup only prints commands, peers are list lines in `LANES.md` (issue #84)": the `stale:` lines, `ytstack-upkeep --worktrees`, `peer set` and `peer list`. - DECISIONS.md -- "2026-11-13: Production findings and incidents are skill work on read-only access; a mitigation is a handover script a person runs (M027)". Source of `bin/ytstack-signals`. "2026-11-15: Feedback about ytstack itself goes through one channel with a setting; a script checks the body, the agent posts (M033-S01, issue #55)" is the source of `bin/ytstack-upstream`. - DECISIONS.md -- "2026-11-13: The technical spec is a set of artifacts of its own under `.ytstack/spec/` (M022, issue #36)". Source of `bin/ytstack-spec` and the two spec checks. -- DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)". Source of `bin/ytstack-brief`. +- DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)". Source of `bin/ytstack-brief`. Extended by "2026-11-15: The spec delta is the report's existing `Spec:` label, checked for its form (issue #75)" and "2026-11-15: A brief for an unplanned task makes the task plan its first deliverable (issue #76)". "2026-11-15: `finish-lane`'s route checks the spec delta; a gap routes to a person (issue #75)" and "2026-11-15: The checks inventory is a `## Checks` section of `REVIEW.md`, not an area file (issue #75)" are the source of the `spec:` and `checks:` lines of `ytstack-finish-lane route`, `ytstack-spec impact --head` and the "Checks" rules of `ytstack-risk check`; "2026-11-15: `reconcile` writes task-plan skeletons and fixes the STATE pointer, after asking; the logic is `bin/ytstack-reconcile` (issue #76)" of `bin/ytstack-reconcile`. - DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)". Source of the five coordinator scripts; the pipeline and the watcher support GitHub through `gh` only. Extended by "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", the source of `check_standing`, by "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)", the source of `bin/ytstack-standing` and the optional keys of `check_standing`, and by "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)", the source of `bin/ytstack-plans`. - DECISIONS.md -- "2026-04-23: UX contracts enforced by CI, not convention" - DECISIONS.md -- "2026-05-31: Add `kind: reference` skill class (exempt from procedure-section contract)" diff --git a/.ytstack/spec/skills.md b/.ytstack/spec/skills.md index 21991839..04395674 100644 --- a/.ytstack/spec/skills.md +++ b/.ytstack/spec/skills.md @@ -8,7 +8,7 @@ sources: - docs/ux/skill-structure.md - docs/ux/askuserquestion-format.md - docs/ux/agent-structure.md -verified_at: db07481 +verified_at: 53a0f84 --- # skills @@ -59,7 +59,7 @@ Read from `PREFERENCES.md` in the resolved `.ytstack` directory by `yt_prefs` in | `quick_lane` | `off`: `quick-task` stops at its gate and points at `plan-task`. `on`: `using-ytstack` routes one-sentence changes with a known cause to `quick-task`. | `quick-task`, `using-ytstack` | | `minimal_code` | `on`: `hooks/session-start` adds a pointer that tells the agent to load `minimal-code` before writing code or adding a check, and the TDD wrapper applies its ladder in the GREEN step. `off`: no pointer. A rendered brief carries the contract in both cases. | `hooks/session-start`, `test-driven-development`, `bin/ytstack-brief` | | `team` | `off`: `spawn-milestone-team` dispatches worktree subagents. `on`: it emits an Agent Teams instruction and requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`. | `spawn-milestone-team` | -| `merge_by` | `risk` (default): the coordinator merges when `bin/ytstack-risk route` says `unattended` and the host's gates hold, otherwise a person. `human`: always a person. `coordinator`: always the coordinator. A value outside the three reads as `human`. | `finish-lane` | +| `merge_by` | `risk` (default): the coordinator merges when `bin/ytstack-risk route` says `unattended` and the host's gates hold, otherwise a person. `human`: always a person. `coordinator`: always the coordinator, except that a `reason: spec` line of the route sends the lane back to the worker first. A value outside the three reads as `human`. | `finish-lane` | | `evidence_dir` | Where a visual review stores its screenshots, default `.ytstack/evidence`, relative to the main checkout. | `visual-review`, `bin/ytstack-risk`, `bin/ytstack-finish-lane` | | `upstream_feedback` | What concerns ytstack itself (`docs/ux/upstream-feedback.md`). `suggest` (default): a draft checked by `bin/ytstack-upstream check`, shown to the person, nothing sent. `file`: searched, then filed or commented at Yesterday-AI/ytstack with `gh`; without a `gh` login, or in a non-interactive, CI or teammate session, it reads as `suggest`. `off`: nothing. Without the key, the last `upstream_feedback=` line of `~/.ytstack/config`; an invalid value reads as `suggest`. `using-ytstack` names the channel at every session start. | `using-ytstack`, `retro`, `lane-retro`, `lesson`, `bin/ytstack-upstream` | @@ -84,7 +84,7 @@ Read from `PREFERENCES.md` in the resolved `.ytstack` directory by `yt_prefs` in ### The technical spec in the loop - `plan-task` works out a task's spec impact from the area files that cover the planned files; `summarize-task` does not close a task whose named area was not updated ([artifacts.md](artifacts.md)). -- `code-review` gives the reviewer the plan's "Spec impact" and the area files of the changed paths. The reviewer reads those against the diff and nothing else of the spec. The verifier does the same for the task it verifies. +- `code-review` gives the reviewer the plan's "Spec impact" and the area files of the changed paths. The reviewer reads those against the diff and nothing else of the spec; with a `## Checks` section in `REVIEW.md`, a guard the diff adds or changes without its line there is a finding too. The verifier does the same for the task it verifies. - `reassess-roadmap` answers the drift report of `bin/ytstack-spec` at the slice boundary, once per area: correct the description, or set `verified_at`. - `resume-session`, `handoff-session` and the SessionStart injection name `spec/SPEC.md`; they do not restate it. `quick-task` corrects an area file only when the change made a statement in it false. @@ -92,7 +92,7 @@ Read from `PREFERENCES.md` in the resolved `.ytstack` directory by `yt_prefs` in `skills/minimal-code/SKILL.md` is the one text that says how much work is enough: the smallest complete change and the smallest sufficient evidence. The other skills apply it at their decision point and do not restate it. -- **Dispatch.** `bin/ytstack-brief render` builds a worker's brief from the plan files and includes the body of `minimal-code` verbatim. `spawn-milestone-team` dispatches with that text and checks the worker's report with `bin/ytstack-brief check` before a verifier runs. A brief has a kind (`implement`, `review`, `prepare`) that says what the worker may do. The report has the fixed labels of `docs/ux/coordinator-format.md` ("The report"), among them `Status:` (complete, partial, blocked), "Not checked:" and `Next:`. +- **Dispatch.** `bin/ytstack-brief render` builds a worker's brief from the plan files and includes the body of `minimal-code` verbatim. `spawn-milestone-team` dispatches with that text and checks the worker's report with `bin/ytstack-brief check` before a verifier runs. A brief has a kind (`implement`, `review`, `prepare`) that says what the worker may do. The report has the fixed labels of `docs/ux/coordinator-format.md` ("The report"), among them `Status:` (complete, partial, blocked), "Not checked:", `Next:` and `Spec:`, the spec delta: the edited sections as `: (
)` or `none -- `; the brief's "Spec impact" section makes editing the section a change makes false a duty. A task its slice plan lists without a task plan gets a plan-first brief: its first deliverable is the task plan in `plan-task`'s format, committed alone; a slice plan with its own `## Files` stands in for its tasks' plans. - **Plan.** A task plan's Verification section names the command, `Runs:` and `Environment:`. What work cannot produce is a gate line under `## Gates` (what, who decides, how, when it lapses). A gate never holds a task open. - **Slice boundary.** `reassess-roadmap` collects the open gates of the milestone and work that repeats without advancing (three or more review rounds on a task), puts them to the human in one question, records only what was answered, and reports two numbers: slices closed by work and slices accepted. In non-interactive mode it asks nothing and records nothing. - **Review.** `code-review` counts rounds from the `## Review` lines in the task plan. Round 1 reviews the whole change, round 2 the fix, and from round 3 no reviewer is dispatched: the skill diagnoses scope, conflicting rules or solution and asks the human. The reviewer states the assumed load, gives a concrete case and "If skipped" per finding and follows the project's severity policy. @@ -107,7 +107,7 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess - `coordinate` is a loop with a fixed order: start from the standing instructions (the entries of `standing/` in the resolved `YT_DIR`, project or user scope, newest first without superseded ones, and `STANDING.md`), `LANES.md`, the frontier and the questions (never from a conversation summary), read host facts fresh and stamp them with their read time, claim a lane before dispatching it, finish lanes through `finish-lane`, run the factory tools of Step 7 (one table of command, when and skip condition; the preamble prints `MERGE_BY`, `REVIEW_POLICY`, `OWN_REVIEWERS`, `PR_WATCH` with the heartbeat age, `RELEASE` and `SIGNALS`, and `YT_BIN=`, through which it runs every bin): the route before every merge, also one it makes itself outside `finish-lane` (then through `ytstack-finish-lane merge` and `finish-lane`'s rule of who merges), with the PR watch on (flag set and a worker heartbeat under 10 minutes old) register the repository's open pull requests by its own GitHub login, without drafts and do-not-merge labels, to itself as their owning session (`ytstack-pr-watch register --all-open` without `--session`, at the start, after every restart or rotation and after a worker opened one) and otherwise poll through `bin/ytstack-watch`, `ytstack-watch release` after every merge to production, `signal-intake` / `incident` for signals and `review-lessons` after a merge with a bot finding, `lesson` on a red `main` and on every slip of a lane or its own (the open lessons in every status from the preamble's `LESSONS` line, a lesson proposal asked with the daily question, lesson lanes `lesson-F###` dispatched from the frontier with `ytstack-brief render --lesson` and set `fixed` after their merge), ask one question at a time from a question file, write a standing instruction down when it is given, before the next dispatch, with `ytstack-standing add` (a new file in `standing/` on the day's standing branch and pull request, `--here` in user scope; `STANDING.md` only where no `standing/` exists; agent memory is no substitute), close an ended one with `ytstack-standing end`, act on the ended, to-check and failed-check lines its preamble prints from `ytstack-standing list` (with the newest entry's age and the human prompts since), its preamble writes the coordinate session marker (the resolved `.ytstack` and the repository key) the coordinate-mode hooks act on, finds the automatic handoff through `yt_latest_handoff`, and prints the operating checklist of `docs/ux/coordinator-format.md` (the same block `session-start` injects), stop a lane that failed verification twice or needs a third review, and rotate after the first compaction in one step while lanes run: a handoff written from the files with the "Rotation" block of `docs/ux/coordinator-format.md` (PR watch session, background watches, each running worker's address), the successor's Step 3 takes the PR watches over with `ytstack-pr-watch handover --from `, and the old session stays open only as a relay that appends its workers' reports to `HANDOFF.md`. It also prints the sessions in other repositories it works with between `PEERS_BEGIN` and `PEERS_END` (`ytstack-frontier peer list`, the `## Peers` lines of `LANES.md`), carries them under `Peers:` in the Rotation block, and takes progress per phase for a status from `ytstack-status --phases` (issues #81, #84). - `spawn-milestone-team` claims each lane with `bin/ytstack-frontier` before it dispatches, keeps the lane's row current, and looks at the frontier again whenever a lane is verified or merged. -- `finish-lane` takes a reported lane to a merged pull request with `bin/ytstack-finish-lane`: review pinned to the host's head, the required lenses, `route`, the gates read from the host, the merge decided by `merge_by` and the route, then `bin/ytstack-watch release` on the merge commit when `RUNTIME.md` has a "Release" section (in the background; the receipt goes into the report, nothing is rolled back). A merge without a person is reported in one line with class, ceiling and lenses. After a merge it made itself, and when `REVIEW.md` declares own reviewers, it invokes `review-lessons` for the pull request. Before a lane goes back for a review that requested changes, a failed lens or a failed check, it invokes `lesson` (its Step 14). These two are the skills it may invoke. The pipeline supports GitHub through `gh` only; on another host the skill stops after the route. +- `finish-lane` takes a reported lane to a merged pull request with `bin/ytstack-finish-lane`: review pinned to the host's head, the required lenses, `route` with the worker's report (its spec delta is checked against the diff, so a lane that skipped `summarize-task` and changed an area without its description or a reason goes to a person, under `merge_by: coordinator` back to the worker; a `checks:` line notes a CI edit that the checks inventory of `REVIEW.md` did not follow and goes to the person who merges), the gates read from the host, the merge decided by `merge_by` and the route, then `bin/ytstack-watch release` on the merge commit when `RUNTIME.md` has a "Release" section (in the background; the receipt goes into the report, nothing is rolled back). A merge without a person is reported in one line with class, ceiling and lenses. After a merge it made itself, and when `REVIEW.md` declares own reviewers, it invokes `review-lessons` for the pull request. Before a lane goes back for a review that requested changes, a failed lens or a failed check, it invokes `lesson` (its Step 14). These two are the skills it may invoke. The pipeline supports GitHub through `gh` only; on another host the skill stops after the route. - **The class of a change.** `code-review` prints the floor of `bin/ytstack-risk` and has a reviewer that is not the author end with `Risk:`, `Severity:`, `Reach:` and `Invariants touched:`, read against "Invariants and security boundaries" and "Decisions that apply now" of the touched areas, also when only code moved. The round line records class, invariants and reviewer; a session reviewing its own change writes `by: self`, which routes to a person. On a pull request `finish-lane` and `code-review` post the round and lens lines in the body of a review on the reviewed head, and `finish-lane` routes with `--pr`: the record needs no commit that would move the head away from a head-bound review. Each lens the floor names gets a separate fresh reviewer with the lens brief (`bin/ytstack-brief render --kind review --lens `) and one lens line. - `visual-review` is the lens reviewer of a user interface change: its own worktree at the reviewed commit, `bin/ytstack-runtime up`, a browser tool that renders and returns screenshots, its own screenshots of the changed views, states and two widths, reviewed against the lens documents; evidence with `MANIFEST` in the main checkout. It is `not run`, never `pass`, when the reviewer is the author, a document or the "Run" section is missing, the product does not come up or no browser tool exists. It edits no product file. - `signal-intake` reads every source of "Signals" once with its read time, separates findings from noise by stated rules, records through `bin/ytstack-signals new` (an unreadable source is a finding too) and changes nothing else. `incident` puts the mitigation before the cause: facts with read times, timeline, hypotheses, mitigations as handover scripts it never runs, one question at a time, and never picks a mitigation without a person; once mitigated it records the lesson through `lesson` with `--incident`, and the cause goes to `systematic-debugging` afterwards, which records the cause's lesson the same way. @@ -130,7 +130,7 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess - `vendor/**` is never edited. Different behavior goes into the wrapper. - No skill installs, calls or references a gstack runtime. `bin/ytstack-check` (`check_gstack_adapted`) fails an adapted skill without `metadata.upstream`, with such a reference, a symlink or an em-dash. - No preamble uses the banned patterns listed in `docs/ux/skill-structure.md`; `bin/ytstack-check` fails on them and on a shell preamble that does not source the lib. -- Skills and agents never delete, move or revert `.ytstack/` artifacts. `reconcile` is the only skill that moves them, and it asks first. +- Skills and agents never delete, move or revert `.ytstack/` artifacts. `reconcile` is the only skill that moves them, and it asks first; it is also the one that writes task-plan skeletons for tasks that ran without a plan and moves a `STATE.md` pointer that is behind, each after its own question ([artifacts.md](artifacts.md)). - No skill merges to a shared branch, pushes or opens a pull request unless the user asked for it (`ship`, `finish-branch`). - Directives are not user-invocable. @@ -195,6 +195,6 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess - DECISIONS.md -- "2026-11-07: Brownfield adoption is a reference-first distillation, never a pitch" (narrows the greenfield flow: an existing codebase skips the pitch) - DECISIONS.md -- "2026-10-13: Remove generated Codex copies; load the existing skills directly" (one skill tree for both hosts) - DECISIONS.md -- "2026-11-13: The technical spec is a set of artifacts of its own under `.ytstack/spec/` (M022, issue #36)" (the spec steps in the loop) -- DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)" (the work contract; extends the ceremony entry of 2026-11-07 from code to evidence and review) +- DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)" (the work contract; extends the ceremony entry of 2026-11-07 from code to evidence and review), extended by "2026-11-15: The spec delta is the report's existing `Spec:` label, checked for its form (issue #75)", "2026-11-15: A brief for an unplanned task makes the task plan its first deliverable (issue #76)", "2026-11-15: `finish-lane`'s route checks the spec delta; a gap routes to a person (issue #75)" as narrowed by "2026-11-15: The spec delta of a lane is checked per area, from the plans of its own range (PR #88 review)", and "2026-11-15: The checks inventory is a `## Checks` section of `REVIEW.md`, not an area file (issue #75)" (the `code-review` finding) - DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)", extended by "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", by "2026-11-15: PR watch bulk registration takes only your own ready PRs; bins are called through `YT_BIN` (issue #85)", by "2026-11-15: Lane liveness is part of `ytstack-frontier check`, worktree cleanup only prints commands, peers are list lines in `LANES.md` (issue #84)" (the peers of `coordinate`), by "2026-11-15: Coordinate mode is a session marker the coordinate preamble writes; the standing hooks act only with it (issue #72)", "2026-11-15: In coordinate mode the operating path is injected and checked by hooks that warn; a lint repeated in three sessions blocks once (issue #76)" and "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)" -- DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)" +- DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)"; "2026-11-15: `reconcile` writes task-plan skeletons and fixes the STATE pointer, after asking; the logic is `bin/ytstack-reconcile` (issue #76)" narrows its rule that `reconcile` leaves the pointer alone diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a5de996..948f2ca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 hook warns when `LANES.md` lags the session's dispatches or the STATE pointer is behind, and holds the stop once when that came three sessions in a row. +- **A checks inventory in `REVIEW.md`** (issue #75): a `## Checks` section + lists the machine checks a reviewer can rely on, one line each + (` | file: | guards: `); `ytstack-risk check` + validates it. A pull request that adds a guard adds its line there: + `code-review` 0.5.2 treats a guard without its line as a finding, and + `ytstack-finish-lane route` prints a `checks:` line when a change edits CI + and the inventory did not move. +- **`reconcile` migrates a project that ran past `plan-task`** (issue #76): + two new classes, each asked once. Tasks of open slices without any task + plan get skeletons in `plan-task`'s format (Files from the task line or the + slice plan's `Own:` lines, Spec impact per area with `TODO` fields that + `ytstack-spec impact` rejects until filled, a `TODO` verification); a + `STATE.md` pointer on a closed or older milestone than the newest one in + progress is moved to it. The logic is the new `bin/ytstack-reconcile` + (`skeletons [--write] [--slice]`, `pointer [--fix]`). `reconcile` 0.4.0. ### Changed @@ -87,6 +102,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `ytstack-standing list` runs an entry's `check` and `until-check` only when the entry is merged on the default branch, never from a pending or a remote-only branch; a timeout kills the command's whole process group. +- **A worker's report carries a spec delta** (issue #75): the brief's + "Spec impact" section now says that a change which makes a sentence of an + area file false edits that section in the same commits, and the report's + `Spec:` line names the edited sections (`: (
)`) or + says `none -- `. `ytstack-brief check` fails a bare `none` and prose + without an area and a path. `spawn-milestone-team` 0.5.2 (brief template). +- **A brief for an unplanned task plans it first** (issue #76): `ytstack-brief + render --task` on a task its slice plan lists without a task plan no longer + fails or says "plan it yourself"; the brief's first deliverable is the task + plan beside the slice plan, in `plan-task`'s format (Files, What this does, + Spec impact, Verification), committed alone, then the files it names. A + slice brief names the plan file to write per unplanned task. A task of a + slice plan with its own `## Files` (granularity slice) is briefed from that + slice plan instead. +- **`finish-lane` checks the spec delta before a merge without you** (issue + #75): `ytstack-finish-lane route --report ` runs `ytstack-spec impact` + on the lane's commits for every plan of the range that states a "Spec + impact"; every area the diff touches (a moved file with both paths) needs + its area file or a source in the diff, a plan of the range that says + `none -- ` for its own files, or `Spec: none -- ` in the + worker's report. A path the report names must be the area file or one of + its sources (`ytstack-brief check` checks that too in a project with a + spec), and `impact` rejects a `TODO` placeholder. A gap prints + `reason: spec -- ...` and turns `unattended` into `person`, so a lane that + skipped `summarize-task` is still caught. `ytstack-spec impact` takes + `--head` to check a commit range that is not checked out. `finish-lane` + 0.6.0. ### Fixed diff --git a/bin/ytstack-brief b/bin/ytstack-brief index 2eaaaba8..08bd7cbf 100755 --- a/bin/ytstack-brief +++ b/bin/ytstack-brief @@ -21,6 +21,11 @@ # else. Skeleton, fixed sentences and the report shape: # skills/spawn-milestone-team/brief-template.md. # +# A task without a plan whose slice plan lists it as open (implement or +# prepare): the brief makes the task plan the first deliverable, in the format +# of skills/plan-task (Step 9), beside the slice plan, then the implementation +# of what that plan names. A slice brief says the same per unplanned task. +# # KIND says what the worker may do (docs/ux/coordinator-format.md, "Lane kinds"): # implement (default) change files inside the scope, commit with the prefix # review read only: review the range --base..--head, or the commit --head @@ -42,7 +47,12 @@ # check validates the eleven labels of the template's "Report" section: each # present at the start of a line and with a value, an exit code in every # "Checks run:" line, "Status:" one of complete, partial, blocked, and -# consistent with "Blockers:" (blocked names one, complete has none). A report +# consistent with "Blockers:" (blocked names one, complete has none), and +# "Spec:" a spec delta: "none -- ", or ": " per edited +# section (a "(
)" may follow), several joined by ";", backticks +# ignored; when DIR (default $PWD) has a technical spec, each path is the +# area file or one of its sources. A task of a slice plan that has its own +# "## Files" (granularity slice) is briefed from the slice plan. A report # that carries one of the four labels of a review (Risk, Severity, Reach, # Invariants touched) has to carry all four with a value, and "Risk:" is low, # normal or high. A report that carries "Lens:" or "Evidence:" has to carry @@ -104,6 +114,40 @@ add() { x=$(section "$2" Gates); [ -z "$x" ] || B_GATES=$(para "$B_GATES" "$l$x") } +# fill : the sentences of that name with the path of the +# plan to write and the plan format filled in; a template without them ends +# the render. +fill() { + local s m='{{PLAN}}' f='{{PLAN_FORMAT}}' p + s=$(lens_snip "$1") || exit 1 + p=$(rel "$2"); s=${s//"$m"/"$p"} + s=${s//"$f"/"$ROOT/skills/plan-task/SKILL.md"} + printf '%s' "$s" +} + +# plan_first : the brief of a task its slice plan lists +# and no task plan describes (issue #76). Its first deliverable is the task +# plan in the format of skills/plan-task (Step 9), then what that plan names. +plan_first() { + local t=${2##*-} line to x + line=$(section "$1" Tasks | sed -n "s/^- \[ \] $t -- //p" | head -1) + [ -n "$line" ] || die "no plan for $2, and $(rel "$1") lists no open task $t" + to="$(dirname "$1")/$2-PLAN.md" + x=$(fill plan-first "$to") || exit 1 + B_OUTCOME=$(para "$line" "${x//$NL/$NL$NL}") + B_FILES=$(fill plan-first-scope "$to") || exit 1 + # The paths the task line names in backticks: a hint for the plan, and what + # the area lookup below reads (it takes the backticked tokens, so they keep + # their backticks here). + ALL_FILES=$(printf '%s\n' "$line" | grep -oE '`[^`]+`' | grep -E '[/.]' | sort -u) + if [ -n "$ALL_FILES" ]; then + x=$(lens_snip plan-first-hint) || exit 1 + B_FILES=$(para "$B_FILES" "$x$NL$NL$(printf '%s\n' "$ALL_FILES" | sed 's/^/- /')") + fi + B_VERIFICATION=$(lens_snip plan-first-verification) || exit 1 + B_SPEC_IMPACT=$(lens_snip plan-first-spec-impact) || exit 1 +} + # ---- the lens of a review ------------------------------------------------------ # lens_def : REVIEW.md on stdin; the lens of that name as four lines: its # line, its reads (comma separated), its evidence, its skill. Nothing when the @@ -232,6 +276,11 @@ cmd_render() { ref="lesson-$ref" else plan=$(find_plan "$ref") + # A task without a plan whose slice plan exists: the brief to plan it first. + # A review has nothing to review against without one. + if [ -z "$plan" ] && [ "$kind" = task ] && [ "$lane" != review ]; then + plan=$(find_plan "${ref%-T[0-9][0-9]}"); [ -z "$plan" ] || kind=unplanned + fi [ -n "$plan" ] || die "no plan for $ref: looked for ${YT_DIR:-$TOP/.ytstack}/$ref-PLAN.md" fi @@ -250,6 +299,14 @@ cmd_render() { elif [ "$kind" = task ]; then B_OUTCOME=$(para "$(field "$plan" Summary)" "$(section "$plan" "What this does")") add "" "$plan" + elif [ "$kind" = unplanned ] && [ -n "$(section "$plan" Files)" ]; then + # granularity: slice -- the slice plan is the plan of each of its tasks + x=$(section "$plan" Tasks | sed -n "s/^- \[ \] ${ref##*-} -- //p" | head -1) + [ -n "$x" ] || die "no plan for $ref, and $(rel "$plan") lists no open task ${ref##*-}" + B_OUTCOME=$(para "$x" "$(para "$(field "$plan" Goal)" "$(section "$plan" "What this does")")") + add "" "$plan" + elif [ "$kind" = unplanned ]; then + plan_first "$plan" "$ref" else B_COMMIT_PREFIX="$ref-T##" B_OUTCOME=$(para "$(field "$plan" Goal)" "$(section "$plan" Tasks)") @@ -264,7 +321,8 @@ cmd_render() { for t in $ids; do tp=$(find_plan "$ref-$t") if [ -n "$tp" ]; then add "$t" "$tp"; continue; fi - B_FILES=$(para "$B_FILES" "**$t** -- $(snip unplanned)") + x=$(fill unplanned "$(dirname "$plan")/$ref-$t-PLAN.md") || exit 1 + B_FILES=$(para "$B_FILES" "**$t** -- $x") B_VERIFICATION=$(para "$B_VERIFICATION" "**$t** -- $(snip unplanned-part)") B_SPEC_IMPACT=$(para "$B_SPEC_IMPACT" "**$t** -- $(snip unplanned-part)") done @@ -378,7 +436,8 @@ cmd_check() { [ -r "$1" ] && [ ! -d "$1" ] || { echo "ytstack-brief: cannot read report '$1'" >&2; return 64; } exec < "$1" fi - awk ' + local out ec bad=0 a p f + out=$(awk ' BEGIN { n = split("Task|Status|Outcome|Commits|Uncommitted|Checks run|Spec|Deviations|Blockers|Not checked|Next", L, "|") # What a review (four) and a lens (two) add after the eleven; read as @@ -408,6 +467,21 @@ cmd_check() { else if (empty[i]) { print "empty: " L[i]; bad = 1 } } for (i = 1; i <= nc; i++) { print "Checks run: no exit code in \"" nocode[i] "\""; bad = 1 } + # The spec delta: "none -- ", or one ": " entry per + # edited section, joined by ";". + sp = V["Spec"] + if (sp != "" && sp !~ /^[Nn]one -- [^ ]/) { + k = split(sp, E, ";"); fine = 1 + for (i = 1; i <= k; i++) { e = E[i]; gsub(/`/, "", e); gsub(/^[ \t]+|[ \t]+$/, "", e); if (e !~ /^[a-z0-9][a-z0-9-]*: [^ <>|]+/) fine = 0 } + if (!fine) { print "Spec: \"" sp "\" is no spec delta: name each edited section as \": (
)\", or write \"none -- \""; bad = 1 } + # Well formed: the caller checks the paths against the project spec. + else for (i = 1; i <= k; i++) { + e = E[i]; gsub(/`/, "", e); gsub(/^[ \t]+|[ \t]+$/, "", e) + # the path runs to the "(
)" at the end; it may hold spaces + p = substr(e, index(e, ": ") + 2); sub(/[ \t]*\([^()]*\)$/, "", p) + print "@entry " substr(e, 1, index(e, ": ") - 1) "\t" p + } + } s = V["Status"]; b = V["Blockers"] if (s != "" && s !~ /^(complete|partial|blocked)$/) { print "Status: \"" s "\" is not complete, partial or blocked"; bad = 1 } if (b != "") { @@ -436,9 +510,31 @@ cmd_check() { if (e != "" && e != "none" && e !~ / \([0-9]+ images?\)$/) { print "Evidence: \"" e "\" is neither \"none\" nor \" ( images)\""; bad = 1 } } if (bad) exit 1 - print "report ok" } - ' + ') + ec=$? + printf '%s\n' "$out" | grep -v '^@entry ' | grep -v '^$' + [ "$ec" -eq 0 ] || return 1 + # In a project with a technical spec, an edited section lies in the area + # file or in one of the sources it names. + if [ -d "$DIR" ]; then + . "$ROOT/hooks/lib/git-ctx.sh" + yt_git_ctx "$DIR"; yt_resolve_yt_dir >/dev/null; TOP="$YT_TOPLEVEL" + if [ -n "${YT_DIR:-}" ] && [ -f "$YT_DIR/spec/SPEC.md" ]; then + while IFS=' ' read -r a p; do + [ -n "$a" ] || continue + f="$YT_DIR/spec/$a.md" + if [ ! -f "$f" ]; then echo "Spec: \"$a: $p\" names no area of this project ($(rel "$f") does not exist)"; bad=1; continue; fi + [ "$p" = "$(rel "$f")" ] && continue + yt_fm "$f" | awk -F'\t' -v p="$p" '$1 == "sources" && $2 == p { hit = 1 } END { exit !hit }' && continue + echo "Spec: \"$a: $p\" is neither $(rel "$f") nor one of its sources"; bad=1 + done <:" in it) and states a +# "Spec impact" is checked with `ytstack-spec impact` on +# --base..--head. Every area whose paths the diff touches (a +# rename with both paths) needs its area file or a source in the +# diff, a plan of the range that says "none -- " for the +# files of its commits, or "Spec: none -- " in the +# worker's report (--report F). A path the report names is the +# area file or a source of that area, and in the diff. Printed as +# "spec:" lines; each gap is a "reason: spec -- ..." line and +# turns "unattended" into "person". # # Exit codes: 0 done; 1 refused or a gate does not hold (the reason is # printed); 64 usage. route: 0 "route: unattended"; 10 "route: person"; 65 git @@ -483,14 +495,156 @@ cmd_merge() { } # ---- route --------------------------------------------------------------------- +# touched_by : is the path, or a file under it, in CHANGED? +touched_by() { + local p s="${1%/}" + while IFS= read -r p; do + case "$p" in "$s"|"$s"/*) return 0 ;; esac + done <: the area file (relative to the root) and its sources, one +# per line; status 1 when the project has no such area. +area_paths() { + local f="$YT_DIR/spec/$1.md" + [ -f "$f" ] || return 1 + printf '%s\n' "${f#"$TOP"/}" + yt_fm "$f" | awk -F'\t' '$1 == "sources" { print $2 }' +} +# areas_of: the areas whose paths cover the paths on stdin, one per line +areas_of() { + local p + set -- + while IFS= read -r p; do [ -z "$p" ] || set -- "$@" "$p"; done + [ $# -eq 0 ] || bash "$SELF_DIR/ytstack-spec" -C "$TOP" areas --names "$@" 2>/dev/null +} +trim() { printf '%s' "$1" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'; } + +# spec_delta : whether the technical spec +# moved with the change (issue #75). Prints "spec: ..." lines for what holds and +# one "reason: spec -- ..." line per gap; returns 1 when there is a gap. +# 1. The plans of the lane that belong to this range (changed in it, or with a +# commit ":" / "-..." in it; a slice lane's task plans too) and +# state a "Spec impact" are checked with bin/ytstack-spec impact on +# base..head. One that says "none -- " covers the areas of the +# files its own commits changed. +# 2. What the report's "Spec:" line names: "none" needs a reason; each +# ": " is the area file or a source of that area, and in the +# diff. Backticks do not count. +# 3. Every area whose paths the diff touches (a rename with its old and its +# new path) needs its area file or a source in the diff, a plan of 1 that +# covers it, or the report's reason. +# The area files are read from this checkout's working tree. +spec_delta() { + local lane="$1" base="$2" head="$3" report="$4" spec="$SELF_DIR/ytstack-spec" bad=0 + local claim="" noneclaim="" subjects cover="" p rp ref out ec l e a ep f s why r + [ -f "$YT_DIR/spec/SPEC.md" ] || { echo "spec: no technical spec"; return 0; } + [ -f "$spec" ] || { echo "reason: spec -- bin/ytstack-spec is not next to this script: the spec delta is unknown"; return 1; } + [ -z "$report" ] || claim=$(sed -n 's/^Spec:[[:space:]]*//p' "$report" | head -1 | tr -d '`') + subjects=$(git log --no-merges --format=%s "$base..$head" 2>/dev/null) + + while IFS= read -r p; do + [ -n "$p" ] || continue + rp=${p#"$TOP"/}; ref=$(basename "$p" -PLAN.md) + touched_by "$rp" || printf '%s\n' "$subjects" | grep -E "^$ref[:-]" >/dev/null || continue + out=$(bash "$spec" -C "$TOP" impact --plan "$p" --base "$base" --head "$head" 2>&1); ec=$? + case "$ec" in + 3) continue ;; + 0) echo "spec: $rp -- $(printf '%s\n' "$out" | grep -v '^$' | tr '\n' ';' | sed 's/;$//; s/;/; /g')" + case "$out" in "spec impact: "[Nn]one" -- "*) + r=${out#spec impact: * -- } + for a in $(git -c core.quotePath=false log --no-merges --no-renames --name-only --format= -E --grep "^$ref[:-]" "$base..$head" 2>/dev/null | areas_of); do + cover="$cover$a $r ($rp) +" + done ;; + esac ;; + *) bad=1 + while IFS= read -r l; do + case "$l" in FAIL*|UNVERIFIABLE*|impact:*) echo "reason: spec -- $rp: $l" ;; esac + done <)" at the end; it may hold spaces. + e=$(trim "$e"); a=${e%%:*}; ep=${e#*: } + case "$ep" in *"("*")") ep=$(trim "${ep%(*}") ;; esac + [ -n "$ep" ] && [ "$ep" != "$e" ] || continue + if ! area_paths "$a" | grep -Fx -- "$ep" >/dev/null; then + echo "reason: spec -- the report names $ep for $a, which is neither ${YT_DIR#"$TOP"/}/spec/$a.md nor one of its sources"; bad=1 + elif ! touched_by "$ep"; then + echo "reason: spec -- the report names $ep, which the change does not touch"; bad=1 + fi + done <\" in the report given with --report)" + bad=1 + fi + done + return "$bad" +} + +# checks_note: when REVIEW.md keeps a checks inventory ("## Checks", the +# machine checks reviewers rely on) and the change edits CI without touching +# REVIEW.md, one "checks:" line: a guard the change adds or changes gets its +# line there. A note, not a gap: a change to CI goes to a person anyway. +checks_note() { + local p ci="" + [ -f "$YT_DIR/spec/REVIEW.md" ] && grep -E '^## Checks[[:space:]]*$' "$YT_DIR/spec/REVIEW.md" >/dev/null || return 0 + touched_by "${YT_DIR#"$TOP"/}/spec/REVIEW.md" && return 0 + while IFS= read -r p; do + case "$p" in .github/workflows/*|.gitlab-ci.yml) ci="$ci${ci:+, }$p" ;; esac + done </dev/null) + if ! s=$(spec_delta "$lane" "$base" "$head" "$report") && [ "$ec" -eq 0 ]; then + r=$(printf '%s\n' "$r" | sed '1s/^route: unattended$/route: person/'); ec=10 + fi + n=$(checks_note); [ -z "$n" ] || s="$s${s:+$'\n'}$n" + fi + printf '%s\n' "$r" + [ -z "${s:-}" ] || printf '%s\n' "$s" + exit "$ec" } case "$CMD" in diff --git a/bin/ytstack-reconcile b/bin/ytstack-reconcile new file mode 100755 index 00000000..eb8f6a7d --- /dev/null +++ b/bin/ytstack-reconcile @@ -0,0 +1,243 @@ +#!/usr/bin/env bash +# ytstack reconcile helpers: the two migration classes of ytstack:reconcile +# (issue #76) that need more than a file list. The skill asks first; this +# script lists without writing, and writes only with --write or --fix. +# +# ytstack-reconcile [-C DIR] skeletons [--write] [--slice M###-S## ...] +# ytstack-reconcile [-C DIR] pointer [--fix] +# +# skeletons one tab separated line per open task ("- [ ] T## -- ...") of a +# slice that has no task plan at all and no "## Files" of its own, +# in a slice that is not done or dropped, of a milestone whose +# roadmap is not done, dropped, shipped-informally or backlog: +# +# The plan goes beside the slice plan. --write writes each one in +# the format of skills/plan-task (Step 9), never over a file: +# Files from the task line's backticked paths, else from the slice +# plan's "Own:" or "Files:" lines, else a TODO; Spec impact one +# line per area of those paths (bin/ytstack-spec areas) with TODO +# fields, which `ytstack-spec impact` does not accept until filled; +# a TODO verification. Frontmatter "skeleton: reconcile ". +# --slice (repeatable) keeps the tasks of the named slices. +# pointer "pointer: ok -- ...", "pointer: no milestone in progress", or +# "pointer: behind -- ..." when current_milestone in STATE.md is +# not the newest milestone whose roadmap is in-progress and is +# older than it, none, or closed (done, dropped, +# shipped-informally). Names the first open slice of the target +# ("- [ ] S##" in its roadmap). --fix sets current_milestone, +# active_slice, active_task (none) and last_updated in the pointer +# block of STATE.md (its frontmatter, or without one the +# "key: value" lines it starts with), adds the keys missing there +# and touches nothing else. It reports what the file says after +# the write. +# +# Exit codes: 0 done; 10 pointer behind (without --fix); 1 no .ytstack, no +# STATE.md, or a STATE.md without a pointer block for --fix (nothing is +# written); 64 usage. + +set -uo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +. "$ROOT/hooks/lib/git-ctx.sh" + +DIR="$PWD" +if [ "${1:-}" = "-C" ]; then DIR="${2:-}"; shift 2 || true; fi +CMD="${1:-}"; [ $# -gt 0 ] && shift + +usage() { sed -n '6,7p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } +bad_usage() { usage >&2; exit 64; } +[ -d "$DIR" ] || bad_usage +case "$CMD" in skeletons|pointer) ;; -h|--help|help) usage; exit 0 ;; *) bad_usage ;; esac + +yt_git_ctx "$DIR" +yt_resolve_yt_dir >/dev/null +TOP="$YT_TOPLEVEL" +[ -n "${YT_DIR:-}" ] && [ -d "$YT_DIR" ] || { echo "ytstack-reconcile: no .ytstack directory for $DIR" >&2; exit 1; } + +rel() { case "$1" in "$TOP"/*) printf '%s' "${1#"$TOP"/}" ;; *) printf '%s' "$1" ;; esac; } +status_of() { sed -n '2,20{s/^status:[ ]*//p;}' "$1" | head -1; } +# section : the body of "## ", fences respected +section() { + awk -v h="## $2" ' + /^```/ { fence = !fence } + !fence && /^## / { t = $0; sub(/[ \t]+$/, "", t); on = (t == h); next } + on { print } + ' "$1" +} +# paths_in: backticked tokens on stdin that look like paths +paths_in() { grep -oE '`[^`]+`' | tr -d '`' | grep -E '[/.]' | awk '!seen[$0]++'; } +# open_milestones: roadmap files of milestones still to be worked on +open_milestones() { + local f + yt_find_artifacts "$YT_DIR" "M[0-9][0-9][0-9]-ROADMAP.md" | while IFS= read -r f; do + case "$(status_of "$f")" in done|dropped|shipped-informally|backlog) ;; *) printf '%s\t%s\n' "$(basename "$f")" "$f" ;; esac + done | sort | cut -f2- +} + +# ---- skeletons ----------------------------------------------------------------- +# candidates: "\t\t\t\t" per task +candidates() { + local rm m sp s t line to paths + open_milestones | while IFS= read -r rm; do + m=$(basename "$rm" -ROADMAP.md) + yt_find_artifacts "$YT_DIR" "$m-S[0-9][0-9]-PLAN.md" | sort | while IFS= read -r sp; do + s=$(basename "$sp" -PLAN.md) + case "$(status_of "$sp")" in done|dropped) continue ;; esac + [ -z "$(section "$sp" Files | grep -v '^[[:space:]]*$')" ] || continue + [ -z "$(yt_find_artifacts "$YT_DIR" "$s-T[0-9][0-9]-PLAN.md")" ] || continue + section "$sp" Tasks | sed -n 's/^- \[ \] \(T[0-9][0-9]\) -- \(.*\)$/\1 \2/p' | while IFS=' ' read -r t line; do + to="$(dirname "$sp")/$s-$t-PLAN.md" + paths=$(printf '%s\n' "$line" | paths_in) + # The slice plan's owner lines stand in when the task line names nothing. + [ -n "$paths" ] || paths=$(grep -E '^[-* ]*(\*\*)?(Own|Owns|Files)(\*\*)?:' "$sp" | paths_in) + printf '%s\t%s\t%s\t%s\t%s\n' "$s-$t" "$to" "$(printf '%s' "$paths" | grep -c .)" "$sp" "$line" + done + done + done +} + +write_skeleton() { # + local ref="$1" to="$2" sp="$3" line="$4" paths p areas a project now + paths=$(printf '%s\n' "$line" | paths_in) + [ -n "$paths" ] || paths=$(grep -E '^[-* ]*(\*\*)?(Own|Owns|Files)(\*\*)?:' "$sp" | paths_in) + project=$(sed -n '2,10{s/^name:[ ]*//p;}' "$YT_DIR/PROJECT.md" 2>/dev/null | head -1 | tr -d '"') + now=$(date -u +%Y-%m-%dT%H:%M:%SZ) + { + printf -- '---\nmilestone: %s\nslice: %s\ntask: %s\nproject: %s\ncreated: %s\nstatus: planned\nskeleton: reconcile %s\n---\n\n' \ + "${ref%%-*}" "$(printf '%s' "$ref" | cut -d- -f2)" "${ref##*-}" "${project:-$(basename "$TOP")}" "$now" "${now%%T*}" + printf '# %s -- Task Plan\n\n**Summary:** %s\n\n## Files\n\n' "$ref" "$line" + if [ -n "$paths" ]; then + printf '%s\n' "$paths" | sed 's/^/- `/; s/$/`/' + printf -- '- TODO: check these paths (taken from %s) and add Create/Modify/Delete\n' "$(rel "$sp")" + else + printf -- '- TODO: the exact paths to create, modify or delete (%s names none for this task)\n' "$(rel "$sp")" + fi + printf '\n## What this does\n\nTODO: what the code does, in prose or pseudocode. From the slice plan: %s\n\n## Spec impact\n\n' "$line" + if [ ! -f "$YT_DIR/spec/SPEC.md" ]; then + printf 'none -- the project has no technical spec\n' + else + set -- + while IFS= read -r p; do [ -z "$p" ] || set -- "$@" "$p"; done </dev/null) + if [ -n "$areas" ]; then + for a in $areas; do printf -- '- %s: TODO section -- TODO what changes\n' "$a"; done + printf '\nTODO: keep the lines of the areas this task changes; when it changes none, replace them with "none -- ".\n' + elif [ -n "$paths" ]; then + printf 'TODO: none -- not covered by an area (confirm, or name the area that should cover these paths)\n' + else + printf 'TODO: one line per area the task changes, "- :
-- ", or "none -- "\n' + fi + fi + printf '\n## Verification\n\n```bash\nTODO: one or two commands that show this task done\n```\n\nRuns: once. Environment: local checkout.\n\n' + printf 'Success: command exits 0 and shows expected output. Failure: re-read plan, check if spec drifted.\n\n' + printf '## Done signal\n\nRun `/ytstack:summarize-task` after execution to mark complete and advance STATE.md.\n' + } > "$to.tmp.$$" || { rm -f "$to.tmp.$$"; return 1; } + # Never over an existing plan: the link fails when the name is taken. + # A taken name of any kind (a directory would take the link inside it). + if [ ! -e "$to" ] && [ ! -L "$to" ] && ln "$to.tmp.$$" "$to" 2>/dev/null; then rm -f "$to.tmp.$$"; echo "wrote $(rel "$to")" + else rm -f "$to.tmp.$$"; echo "kept $(rel "$to"): it exists"; fi +} + +cmd_skeletons() { + local write=no only="" ref to n sp line + while [ $# -gt 0 ]; do + case "$1" in + --write) write=yes ;; + --slice) case "${2:-}" in M[0-9][0-9][0-9]-S[0-9][0-9]) only="$only $2 "; shift ;; *) bad_usage ;; esac ;; + *) bad_usage ;; + esac + shift + done + candidates | while IFS=' ' read -r ref to n sp line; do + case "$only" in ""|*" ${ref%-T[0-9][0-9]} "*) ;; *) continue ;; esac + if [ "$write" = yes ]; then write_skeleton "$ref" "$to" "$sp" "$line" + else printf '%s\t%s\t%s\n' "$ref" "$(rel "$to")" "$n"; fi + done +} + +# ---- pointer ------------------------------------------------------------------- +cmd_pointer() { + local fix=no sf="$YT_DIR/STATE.md" m s t target="" tslice rm now head_block + while [ $# -gt 0 ]; do + case "$1" in --fix) fix=yes ;; *) bad_usage ;; esac + shift + done + [ -f "$sf" ] || { echo "ytstack-reconcile: no STATE.md in $(rel "$YT_DIR")" >&2; return 1; } + # The pointer lines: the frontmatter, or without one the key lines the file + # starts with (up to the first line that is no "key: value"). + head_block=$(pointer_block "$sf") + m=$(printf '%s\n' "$head_block" | sed -n 's/^current_milestone:[ ]*//p' | head -1); m=${m:-none} + s=$(printf '%s\n' "$head_block" | sed -n 's/^active_slice:[ ]*//p' | head -1) + t=$(printf '%s\n' "$head_block" | sed -n 's/^active_task:[ ]*//p' | head -1) + while IFS= read -r rm; do + [ -n "$rm" ] && [ "$(status_of "$rm")" = in-progress ] && target=$(basename "$rm" -ROADMAP.md) + done <&2 + return 1 + fi + now=$(date -u +%Y-%m-%dT%H:%M:%SZ) + # Replace the keys inside the pointer block; add the missing ones at its end. + awk -v m="$target" -v s="$tslice" -v now="$now" ' + function add() { + if (!c) print "current_milestone: " m + if (!sl) print "active_slice: " s + if (!tk) print "active_task: none" + if (!lu) print "last_updated: " now + blk = 0; done = 1 + } + NR == 1 && $0 == "---" { fm = 1; blk = 1; print; next } + NR == 1 { blk = 1 } + blk && fm && $0 == "---" { add(); print; next } + blk && !fm && $0 !~ /^[A-Za-z_][A-Za-z0-9_]*:/ { add() } + blk && /^current_milestone:/ { print "current_milestone: " m; c = 1; next } + blk && /^active_slice:/ { print "active_slice: " s; sl = 1; next } + blk && /^active_task:/ { print "active_task: none"; tk = 1; next } + blk && /^last_updated:/ { print "last_updated: " now; lu = 1; next } + { print } + END { if (blk && !done) add() } + ' "$sf" > "$sf.tmp.$$" && mv "$sf.tmp.$$" "$sf" || { rm -f "$sf.tmp.$$"; echo "ytstack-reconcile: could not write $(rel "$sf")" >&2; return 1; } + # Report what the file now says, never what was meant to be written. + head_block=$(pointer_block "$sf") + [ "$(printf '%s\n' "$head_block" | sed -n 's/^current_milestone:[ ]*//p' | head -1)" = "$target" ] \ + && [ "$(printf '%s\n' "$head_block" | sed -n 's/^active_slice:[ ]*//p' | head -1)" = "$tslice" ] \ + && [ "$(printf '%s\n' "$head_block" | sed -n 's/^active_task:[ ]*//p' | head -1)" = none ] \ + || { echo "ytstack-reconcile: STATE.md does not show the new pointer after the write; look at $(rel "$sf")" >&2; return 1; } + echo "fixed: current_milestone $m -> $target, active_slice ${s:-(missing)} -> $tslice, active_task ${t:-(missing)} -> none" +} + +# pointer_block : the frontmatter lines, or without frontmatter the +# "key: value" lines the file starts with; nothing when it has neither. +pointer_block() { + awk ' + NR == 1 && $0 == "---" { fm = 1; next } + fm { if ($0 == "---") exit; print; next } + /^[A-Za-z_][A-Za-z0-9_]*:/ { print; next } + { exit } + ' "$1" +} + +case "$CMD" in + skeletons) cmd_skeletons "$@" ;; + pointer) cmd_pointer "$@" ;; +esac diff --git a/bin/ytstack-risk b/bin/ytstack-risk index 7ea911fc..436c3657 100755 --- a/bin/ytstack-risk +++ b/bin/ytstack-risk @@ -201,6 +201,7 @@ section() { # review_parse: REVIEW.md on stdin as records, one per line: # person| neverlow| size|| # lens||||| +# own|||| check||| # bad| # Everything that can be judged without the file system is judged here, so # check and floor agree on what is malformed. @@ -217,8 +218,8 @@ review_parse() { fence { next } /^## / { sec = trim(substr($0, 4)) - if (sec != "Always a person" && sec != "Never low" && sec != "Lenses" && sec != "Size" && sec != "Own reviewers") { - bad("section \047## " sec "\047 is not one of Always a person, Never low, Lenses, Size, Own reviewers"); sec = "" + if (sec != "Always a person" && sec != "Never low" && sec != "Lenses" && sec != "Size" && sec != "Own reviewers" && sec != "Checks") { + bad("section \047## " sec "\047 is not one of Always a person, Never low, Lenses, Size, Own reviewers, Checks"); sec = "" } next } @@ -273,6 +274,23 @@ review_parse() { else mk[marker] = name if (lessons == "") bad("own reviewer " name " has no lessons") print "own|" name "|" marker "|" lessons "|" bots + next + } + # A machine check reviewers rely on: " | file: | guards: ". + sec == "Checks" { + n = split(item, part, "|"); name = trim(part[1]) + file = ""; guards = "" + for (i = 2; i <= n; i++) { + p = trim(part[i]); k = p; sub(/:.*/, "", k); v = trim(substr(p, length(k) + 2)) + if (k == "file") file = v + else if (k == "guards") guards = v + else bad("check " name ": field \047" k "\047 is not file or guards") + } + if (name !~ /^[a-z0-9][a-z0-9-]*$/) bad("check name \047" name "\047 is not a lowercase slug") + if (chk[name]++) bad("check " name " is defined twice") + if (file == "") bad("check " name " has no file") + if (guards == "") bad("check " name " has no guards") + print "check|" name "|" file "|" guards } ' } @@ -299,7 +317,7 @@ EOF # ---- check --------------------------------------------------------------------- cmd_check() { - local f="${YT_DIR:+$YT_DIR/spec/REVIEW.md}" bad=0 n=0 o=0 kind a b c d e doc + local f="${YT_DIR:+$YT_DIR/spec/REVIEW.md}" bad=0 n=0 o=0 k=0 kind a b c d e doc [ $# -eq 0 ] || { usage >&2; return 64; } if [ -z "$f" ] || [ ! -f "$f" ]; then echo "no review policy"; return 0; fi while IFS='|' read -r kind a b c d e; do @@ -308,6 +326,9 @@ cmd_check() { own) o=$((o + 1)) [ -z "$c" ] || [ -e "$TOP/$c" ] || { bad=$((bad + 1)); echo "REVIEW.md: own reviewer $a: lessons $c does not exist"; } ;; + check) + k=$((k + 1)) + [ -z "$b" ] || [ -e "$TOP/$b" ] || { bad=$((bad + 1)); echo "REVIEW.md: check $a: file $b does not exist"; } ;; lens) n=$((n + 1)) while IFS= read -r doc; do @@ -321,7 +342,7 @@ EOD $(review_parse < "$f") EOF [ "$bad" -eq 0 ] || return 1 - echo "review policy ok: $n lens(es), $o own reviewer(s)" + echo "review policy ok: $n lens(es), $o own reviewer(s), $k check(s)" } # ---- reviewers ----------------------------------------------------------------- diff --git a/bin/ytstack-spec b/bin/ytstack-spec index 5f3e8097..c57860f4 100755 --- a/bin/ytstack-spec +++ b/bin/ytstack-spec @@ -3,8 +3,10 @@ # # ytstack-spec lint format of .ytstack/spec/ (SPEC.md + area files) # ytstack-spec drift [--exit-code] areas whose paths changed after their description -# ytstack-spec impact --plan FILE [--grep ERE] [--base SHA] +# ytstack-spec impact --plan FILE [--grep ERE] [--base SHA [--head SHA]] # a task's "## Spec impact" against what it changed +# (--head: only the commits base..head, not the +# working tree; for a lane's branch) # ytstack-spec areas [--names] PATH... which area describes a path (--names: the area names only) # # All commands take -C DIR first (default: $PWD). @@ -12,7 +14,8 @@ # Exit codes # lint 0 clean, 2 warnings only, 1 failures (or no spec) # drift 0 always; with --exit-code 2 when an area is listed -# impact 0 satisfied or "none", 1 not satisfied, 3 the plan states no impact, +# impact 0 satisfied or "none", 1 not satisfied (a TODO placeholder too), +# 3 the plan states no impact, # 4 unverifiable: an area file lies outside the repository (user # scope, ~/.ytstack/projects//) and no source of it changed; # the line says whether the file was modified after the task's @@ -49,7 +52,7 @@ DIR="$PWD" if [ "${1:-}" = "-C" ]; then DIR="${2:-}"; shift 2 || true; fi CMD="${1:-}"; [ $# -gt 0 ] && shift -usage() { sed -n '2,12p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } +usage() { sed -n '2,14p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } case "$CMD" in lint|drift|impact|areas) ;; -h|--help|help) usage; exit 0 ;; *) usage >&2; exit 64 ;; esac yt_git_ctx "$DIR" @@ -306,18 +309,20 @@ EOF # ---- impact -------------------------------------------------------------------- cmd_impact() { - local plan="" pat="" base="" body first line area f changed committed fails=0 unver=0 hit how s first_ct="" + local plan="" pat="" base="" head="" body first line area f changed committed fails=0 unver=0 hit how s first_ct="" while [ $# -gt 0 ]; do [ $# -ge 2 ] || { echo "impact: $1 needs a value" >&2; return 64; } case "$1" in --plan) plan="$2" ;; --grep) pat="$2" ;; --base) base="$2" ;; + --head) head="$2" ;; *) echo "impact: unknown argument $1" >&2; return 64 ;; esac shift 2 done [ -f "$plan" ] || { echo "impact: plan file '$plan' not found" >&2; return 64; } + [ -z "$head" ] || [ -n "$base" ] || { echo "impact: --head needs --base" >&2; return 64; } body=$(awk ' /^```/ { fence = !fence } @@ -328,6 +333,11 @@ cmd_impact() { echo "spec impact: not stated -- the plan has no '## Spec impact' section; state the impact in the summary" return 3 fi + # A skeleton's placeholder (bin/ytstack-reconcile) is no statement yet: a + # field that is TODO ("TODO: ...", ": TODO ...", "-- TODO ..."), not + # the word inside a filled line. + line=$(printf '%s\n' "$body" | grep -m1 -E '(^|^- |: |-- )TODO([[:space:]:]|$)') + if [ -n "$line" ]; then echo "FAIL placeholder (fill it in): $line"; return 1; fi first=$(printf '%s\n' "$body" | head -1) case "$first" in [Nn]one*|"- "[Nn]one*) echo "spec impact: ${first#- }"; return 0 ;; @@ -339,8 +349,14 @@ cmd_impact() { # Paths come as NUL-delimited records (-z): the plain output quotes a name # with a space or a non-ASCII byte, and a quoted name never equals the path # a plan or an area file names. - committed="" - if [ "$YT_IS_GIT" = yes ]; then + committed=""; changed="" + if [ "$YT_IS_GIT" = yes ] && [ -n "$head" ]; then + # A range that need not be checked out (a lane read from the coordinating + # checkout): its commits only, the working tree belongs to somebody else. + # --no-renames: a renamed file counts with its old and its new path. + committed=$(git -C "$TOP" diff --no-renames --name-only -z "$base..$head" 2>/dev/null | nul_paths) + first_ct=$(git -C "$TOP" log --format='%ct %h' "$base..$head" 2>/dev/null | tail -1) + elif [ "$YT_IS_GIT" = yes ]; then if [ -n "$pat" ]; then committed=$(git -C "$TOP" log --no-merges -E --grep "$pat" --name-only -z --format= 2>/dev/null | nul_paths) first_ct=$(git -C "$TOP" log --no-merges -E --grep "$pat" --format='%ct %h' 2>/dev/null | tail -1) @@ -350,8 +366,6 @@ cmd_impact() { first_ct=$(git -C "$TOP" log --format='%ct %h' "$base..HEAD" 2>/dev/null | tail -1) fi changed=$(git -C "$TOP" status --porcelain -z --untracked-files=all 2>/dev/null | status_paths) - else - changed="" fi # outside_when : the file's modification time against the task's first diff --git a/docs/ux/coordinator-format.md b/docs/ux/coordinator-format.md index 3302e708..52423fe8 100644 --- a/docs/ux/coordinator-format.md +++ b/docs/ux/coordinator-format.md @@ -136,7 +136,7 @@ Outcome: Commits: ..HEAD, or "none"> Uncommitted: Checks run: -- exit at in -Spec: +Spec: : (
); ... | none -- Deviations: Blockers: Not checked: @@ -145,6 +145,8 @@ Next: `partial` and `blocked` are values of `Status:`, never a word in a paragraph. `Status: blocked` needs a `Blockers:` value other than `none`; `Status: complete` needs `Blockers: none`. +`Spec:` is the **spec delta**: what the change did to the technical spec (`docs/ux/spec-format.md`). Either one entry per edited section, `: (
)` with the area file or the source it names, several joined by `;`, or `none -- ` with a reason from the plan rule (restores the described behaviour, no behaviour or contract changes, not covered by an area). It is the worker's side of the plan's `## Spec impact`: the plan says what will change, the report what did. A bare `none` and prose without a path are no delta. `finish-lane` checks the delta against the diff before a merge without a person (`bin/ytstack-finish-lane route --report`). + ## `questions/` -- what only the human can decide One file per pending question: `.ytstack/questions/Q###-.md`. @@ -310,6 +312,6 @@ The old session stays open as a relay until every listed worker has reported. Pe - `bin/ytstack-upkeep --worktrees`: the linked worktrees (not the main one, not the one it runs in) and local branches with the state of their pull request (an open one first, else the newest), the age of the last commit, uncommitted changes, unpushed commits and the lane of the main checkout's `LANES.md` that holds them, and the `git worktree remove` / `git branch -D` commands for those whose pull request is merged or closed, with no open one, nothing unpushed, clean, unlocked and unheld. It prints the commands and runs none. - `bin/ytstack-status --phases [--json]`: done, in review and total per milestone and in total, with each change since the last text report, its cause and the phases that joined or left (`docs/statusline.md`, "Progress per phase"). - `bin/ytstack-questions check`: ids are unique and match the file name, `state` holds a listed value, `asked` and `answered` are set exactly when the state says so, an answered file has text under `## Answer`. -- `bin/ytstack-brief check`: the report labels, the three `Status:` values and their consistency with `Blockers:`. +- `bin/ytstack-brief check`: the report labels, the three `Status:` values and their consistency with `Blockers:`, and the form of the spec delta under `Spec:`. - `bin/ytstack-handover check`: the staged script of a human-only step (see `skills/handover-step/SKILL.md`). - `bin/ytstack-check --standing []`: every entry in `standing/` has a name of the form above with a date and time that exist, `given` as an existing ISO UTC time in the minute of its name, a `scope` and a body, and every `supersedes` names an earlier entry that exists (missing seconds count as `00`); `until` is an existing ISO UTC time after `given`, `until-condition`, `until-check` and `check` are one non-empty line when present, `kind` is `end` or absent, and an `end` names the entry it closes. Without a directory argument it resolves `.ytstack` like the skill preambles, user scope included. diff --git a/docs/ux/review-policy-format.md b/docs/ux/review-policy-format.md index b0add60f..d77211ca 100644 --- a/docs/ux/review-policy-format.md +++ b/docs/ux/review-policy-format.md @@ -90,6 +90,11 @@ It is the highest class that may merge into this area without a person. No field - code | marker: (`code`) | lessons: .github/reviewers/code.md | bots: cursor, greptile-apps - tests | marker: (`tests`) | lessons: .github/reviewers/tests.md + +## Checks + +- component-levels | file: scripts/check-levels.mjs | guards: an atom imports no molecule; the import directions of .ytstack/spec/web.md +- secret-scan | file: .github/workflows/secret-scan.yml | guards: no token reaches a pushed commit ``` Paths are git pathspec globs relative to the repository root, one per line. Every section is optional. Git itself matches them, the way `bin/ytstack-spec lint` and `drift` read `paths`: `*` stays inside one directory, `**` crosses directories, and `**/name` also matches at the root. @@ -144,6 +149,18 @@ A lesson is a change to the `lessons` file, and that is a rule change: it is pro `bin/ytstack-risk reviewers` prints the section, one tab separated line per role: name, marker, lessons, bots. +## Checks: what a reviewer can rely on + +A project that runs machine checks of its own (a guard script, a lint rule, a CI step, a test that pins a contract) lists them here, so that a reviewer knows what it does not have to read for and a new rule is not only told in a receipt. Without the section nothing changes. + +| Field | Required | Holds | +|---|---|---| +| name | yes | A lowercase slug, unique. | +| `file` | yes | The file that is the check, or that runs it. It exists in the repository. | +| `guards` | yes | What holds when the check passes, in one line; the rule itself stays in the area file or the source it names. | + +A pull request that adds a guard, or changes what one guards, adds or updates its line here in the same commits. `bin/ytstack-finish-lane route` prints a `checks:` line when the project keeps the section and a change edits CI (`.github/workflows/`, `.gitlab-ci.yml`) without touching `REVIEW.md`; a change to CI goes to a person anyway, and that person reads the line. `code-review` treats a guard added without its line as a finding. + ## Escapes `bin/ytstack-review-escapes [-C ] --pr [--repo ]` reads one pull request through `gh` and prints one tab separated line per review-bot thread under a header: @@ -281,7 +298,7 @@ The route is `unattended` only when all of this holds: 3. The class (the higher of floor and stated risk) is not above the ceiling of the touched areas. A change that touches no area has the ceiling `none`. 4. Every required lens has a newest line with `pass` that is valid for the head, from a reviewer other than the author, and its `reads` documents exist at the head. For `evidence: visual` the directory the line names holds a `MANIFEST` with at least one image; every listed image is there with the listed SHA-256, and its line states `url`, `viewport` and `shows`. -The route reads the host only for the review records, and only with `--pr`; it says nothing about the host's gates. `finish-lane` reads the host's gates (checks, review threads, mergeability, the reviewed commit) as before, and merges on its own only when both hold and `merge_by` is `risk`. +The route reads the host only for the review records, and only with `--pr`; it says nothing about the host's gates. `finish-lane` reads the host's gates (checks, review threads, mergeability, the reviewed commit) as before, and merges on its own only when both hold and `merge_by` is `risk`. Its own `route` (`bin/ytstack-finish-lane route`) adds the spec delta: a change to an area's paths without its area file or a source in the diff, without a plan that states the impact and without `Spec: none -- ` in the worker's report is `person` (`docs/ux/spec-format.md`, "Before a merge"). | `merge_by` | Who merges | |---|---| @@ -291,7 +308,7 @@ The route reads the host only for the review records, and only with `--pr`; it s ## Checked mechanically -`bin/ytstack-risk check` reads the `REVIEW.md` of the working tree. It fails on a section outside the five, a lens whose name is not a lowercase slug, a lens without `applies`, `reads` or `evidence`, a lens field outside the five, an `evidence` outside the two values, a `reads` document that does not exist, a lens name used twice, a `size` line that is not two numbers, an own reviewer whose name is not a lowercase slug or is used twice, one without `marker` or `lessons`, a marker another role has, a `lessons` file that does not exist, and an own reviewer field outside the three. It prints one line per problem (`REVIEW.md: `) and exits 1; a clean policy and a project without `REVIEW.md` exit 0. +`bin/ytstack-risk check` reads the `REVIEW.md` of the working tree. It fails on a section outside the six, a lens whose name is not a lowercase slug, a lens without `applies`, `reads` or `evidence`, a lens field outside the five, an `evidence` outside the two values, a `reads` document that does not exist, a lens name used twice, a `size` line that is not two numbers, an own reviewer whose name is not a lowercase slug or is used twice, one without `marker` or `lessons`, a marker another role has, a `lessons` file that does not exist, an own reviewer field outside the three, and a check whose name is not a lowercase slug or is used twice, one without `file` or `guards`, a `file` that does not exist and a check field outside the two. It prints one line per problem (`REVIEW.md: `) and exits 1; a clean policy and a project without `REVIEW.md` exit 0. `bin/ytstack-spec lint` runs that check when `REVIEW.md` exists and counts each line as a failure. It also fails on an `auto_merge` outside the three values and on a `REVIEW.md` that `SPEC.md` does not link. diff --git a/docs/ux/spec-format.md b/docs/ux/spec-format.md index 729c8924..ee147e66 100644 --- a/docs/ux/spec-format.md +++ b/docs/ux/spec-format.md @@ -159,6 +159,10 @@ A spec in user scope (`~/.ytstack/projects//spec/`) lies outside the reposi The summary records what was updated under `## Spec`: the area, the file and section, or `none` with the plan's reason. +### Before a merge + +A dispatched worker states the spec delta in its report's `Spec:` line: the edited sections as `: (
)`, or `none -- ` (`docs/ux/coordinator-format.md`, "The report"). `bin/ytstack-finish-lane route` checks it against the lane's diff before a merge without a person, so a lane that never ran `summarize-task` is still caught: each plan of the lane that belongs to the range and has a `## Spec impact` goes through `impact` on the commit range; every area whose paths the diff touches (a moved file with both paths) needs its area file or a source in the diff, a plan of the range that says `none -- ` for the files of its commits, or the report's reason. A path the report names as edited is the area file or a source of that area, and in the diff; `bin/ytstack-brief check` checks the first half of that where it runs in the project. A `TODO` field in a plan's "Spec impact" (`TODO: ...`, `: TODO ...`, `-- TODO`) fails `impact`: a placeholder is no statement. The word inside a filled line is no placeholder. A gap sends the change to a person. + ### Drift `bin/ytstack-spec drift` compares, for every area that is not `planned`, the commits that touched its `paths` with the last commit that touched the area file or one of its `sources`. When code changed after that commit, it prints a **possible documentation impact**. That is a prompt to look, not a finding that the description is wrong: a refactoring changes paths and leaves the contract alone. diff --git a/skills/code-review/SKILL.md b/skills/code-review/SKILL.md index 947080fe..377a9672 100644 --- a/skills/code-review/SKILL.md +++ b/skills/code-review/SKILL.md @@ -2,7 +2,7 @@ name: code-review metadata: tier: task - version: 0.5.1 + version: 0.5.2 description: "Reviews the active task's commits with a fresh-context reviewer subagent and handles the feedback with technical rigor, through the vendored superpowers requesting-code-review and receiving-code-review procedures, with the task plan and commit range injected. Use after a task's commits exist and before summarize-task, before a merge or PR, or when the user says review this, code review, check my changes. Not for reviewing a plan (plan-eng-review) and not without commits for the task." allowed-tools: - Bash @@ -107,7 +107,7 @@ You are invoked inside a ytstack project after the active task's commits exist. HARD-GATE: if `IS_GIT=no`, abort. If `ACTIVE_TASK` has `none` in it or `TASK_PLAN_EXISTS=no`, abort with "no active task plan; run `ytstack:plan-task` or review a plain diff without ytstack". If `COMMITS_SOURCE=none` or `BASE_SHA=none`, abort with "no commits found for the task; commit with the `M###-S##-T##:` prefix (or set `commit_ref_pattern` in PREFERENCES) and re-run". -**Spec check, bounded to the touched area.** When `SPEC_EXISTS=yes`, add to the reviewer's requirements the plan's `## Spec impact` section and the paths listed under `SPEC_AREAS` (the area files of `.ytstack/spec/` that cover the changed files). The reviewer reads those area files, and the section of a `sources` document they point to, against the diff. Two things are findings: the diff changes behaviour, an interface, an invariant or an error path that an area file describes while the plan says `none`; or an area file (or its source) now states something the diff contradicts. A change that restores the described behaviour needs no spec edit and is not a finding. The reviewer does not audit the rest of the spec, other areas or the repository's documentation. +**Spec check, bounded to the touched area.** When `SPEC_EXISTS=yes`, add to the reviewer's requirements the plan's `## Spec impact` section and the paths listed under `SPEC_AREAS` (the area files of `.ytstack/spec/` that cover the changed files). The reviewer reads those area files, and the section of a `sources` document they point to, against the diff. Two things are findings: the diff changes behaviour, an interface, an invariant or an error path that an area file describes while the plan says `none`; or an area file (or its source) now states something the diff contradicts. A change that restores the described behaviour needs no spec edit and is not a finding. A third is a finding when `.ytstack/spec/REVIEW.md` keeps a `## Checks` section (the machine checks reviewers rely on, `docs/ux/review-policy-format.md`): the diff adds a guard or changes what one guards (a check script, a lint rule, a CI step) and the section did not change with it. The reviewer does not audit the rest of the spec, other areas or the repository's documentation. ## Bounded review (ytstack) diff --git a/skills/finish-lane/SKILL.md b/skills/finish-lane/SKILL.md index cf52a6ce..ad478434 100644 --- a/skills/finish-lane/SKILL.md +++ b/skills/finish-lane/SKILL.md @@ -3,7 +3,7 @@ name: finish-lane description: "Takes a delegated lane from the worker's report to a pull request merged at the reviewed commit, with every gate read from the host. Use in the coordinating session when a lane reported and its work has to become a merged pull request, or when the user says finish the lane, land this lane, get this lane merged. Not for the session's own branch (finish-branch), not for a release (ship) and not for the worker of the lane." metadata: tier: task - version: 0.5.0 + version: 0.6.0 allowed-tools: - Bash - Read @@ -41,7 +41,7 @@ You MUST create a TodoWrite task for each of these items and complete them in or 6. **Commission the review** -- a `review` lane pinned to that commit, in a fresh context; at most two rounds 7. **Post the review, record head and round** -- on the pull request with the round line in its body, then `ytstack-frontier set`, then the same line in the lane's plan where you may write 8. **Dispatch the required lenses** (only if `floor` names some) -- one fresh reviewer per lens with the lens brief, the lens lines posted as a review and in the lane's plan -9. **Read the route** -- `route --pr`: `unattended`, or `person` with its reasons +9. **Read the route** -- `route --pr --report`: `unattended`, or `person` with its reasons, the spec delta among them 10. **Read the gates** -- `gates`; a failing gate is handled by what it is 11. **Merge or hand over** -- `MERGE_BY: risk` with route `unattended`, or `coordinator`: `merge`; every other case: stop with the command and the reasons 12. **Watch the release** (only after a merge, by anyone) -- `ytstack-watch release --commit `; the receipt goes into the report; `not arrived` and `unhealthy` go to the person at once @@ -179,7 +179,7 @@ Read the standing instructions in full now, before anything is pushed: every fil ### Step 3: Read the report, commit leftovers -Read the worker's report by its labels (`docs/ux/coordinator-format.md`, "The report"). A report that has not passed `bin/ytstack-brief check` yet is checked first. `Status:` other than `complete` is not finished work: the lane goes back to whoever dispatched it, with the `Blockers:` value. +Read the worker's report by its labels (`docs/ux/coordinator-format.md`, "The report"). A report that has not passed `bin/ytstack-brief check` yet is checked first. `Status:` other than `complete` is not finished work: the lane goes back to whoever dispatched it, with the `Blockers:` value. Save the report as it came to a file outside the worktree, `{REPORT_FILE}`: Step 9 checks its `Spec:` line, the spec delta, against the diff. A `prepare` lane commits nothing by design, and any lane can leave files behind. If the lane's kind is `prepare` or `Uncommitted:` is not `none`: @@ -337,10 +337,12 @@ Post the lens lines as one more review on the pull request (`gh pr review {N} -- Whether a person has to look at this change is decided per change, from its risk (`docs/ux/review-policy-format.md`, "The route"). Run this in the checkout of this session, without `-C {WT}`: it reads `LANES.md` and the lane's plan here, and the reviews of the pull request on the host. ```bash -"${CLAUDE_SKILL_DIR}/../../bin/ytstack-finish-lane" route --lane {REF} --base {BASE_SHA} --head {SHA} --pr {N} +"${CLAUDE_SKILL_DIR}/../../bin/ytstack-finish-lane" route --lane {REF} --base {BASE_SHA} --head {SHA} --pr {N} --report {REPORT_FILE} ``` -On a host other than GitHub leave out `--pr`: the plan is then the only record. The first line says what it read: the lane, the worker of its row as the author, the plan, the pull request. Then come the lines of `bin/ytstack-risk route`: `route: unattended` or `route: person`, `class:`, `ceiling:`, `floor:`, `areas:`, `lenses:`, `round:` (where the round line came from: a review on the host, the plan, or none), and one `reason:` per condition that failed. Exit 0 means `unattended`. Everything else, an error included, means "not unattended". Keep the lines for the report. +On a host other than GitHub leave out `--pr`: the plan is then the only record. The first line says what it read: the lane, the worker of its row as the author, the plan, the pull request. Then come the lines of `bin/ytstack-risk route`: `route: unattended` or `route: person`, `class:`, `ceiling:`, `floor:`, `areas:`, `lenses:`, `round:` (where the round line came from: a review on the host, the plan, or none), and one `reason:` per condition that failed. Last come the `spec:` lines of the spec delta. Exit 0 means `unattended`. Everything else, an error included, means "not unattended". Keep the lines for the report. + +**The spec delta.** With a technical spec, `route` checks itself that the spec moved with the change, also for a lane that never ran `summarize-task`: every plan of the lane that belongs to this range (changed in it, or with a commit of its task in it; a slice lane's task plans too) and states a `## Spec impact` is checked with `bin/ytstack-spec impact` on `{BASE_SHA}..{SHA}`. Then every area whose paths the diff touches, a moved file with both paths, needs its area file or one of its `sources` in the diff, a plan of the range that says `none -- ` for the files of its commits, or `Spec: none -- ` in the report. A path the report names as edited is the area file or a source of that area, and in the diff. Each gap is a `reason: spec -- ...` line and makes the route `person`. The repair is the worker's: edit the section the change made false, or state the reason in the report, and the fix round follows. You do not edit the area file and you do not write the reason for the worker. A `checks:` line says that the change edits CI while the project's checks inventory (`## Checks` in `REVIEW.md`) did not change: it goes to the person who merges, and back to the worker when the change adds a guard. `unattended` needs all of this: a floor from the diff that is not `person`; a newest round line that approves, is valid for `{SHA}`, states `risk` and `invariants: none`, and names a reviewer other than the lane's worker; a class within the ceiling (`auto_merge`) of every area the change touches; and for every required lens a newest line that says `pass`, comes from a reviewer other than the worker, is valid for `{SHA}` and, for a visual lens, names an evidence directory whose `MANIFEST` matches its images. A project that declared nothing gets `person` for every change, which is what `merge_by: human` does. @@ -374,7 +376,7 @@ Who merges is the project's decision, not this session's. It is read from `MERGE | `risk` (the default) | `unattended` | You merge at `{SHA}`. The person gets one line in the report: what merged without them, at which class, under which ceiling, with which lenses. | | `risk` | `person`, or no answer | Stop. A person merges; they get the command and the `reason:` lines. | | `human` | any | Stop. A person merges; the route lines go along for information. | -| `coordinator` | any | You merge at `{SHA}`. The route is printed in the report and not applied. | +| `coordinator` | any | You merge at `{SHA}`. The route is printed in the report and not applied, except a `reason: spec` line: that lane goes back to the worker first. | A standing instruction that reserves the merge wins over every row: a person merges. @@ -443,6 +445,7 @@ A review that requested changes, a lens that failed and a check that failed are > - review: round {n}, {verdict}, at {SHA}; risk {the reviewer's class}, invariants {none | what it named} > - lenses: {per lens: verdict, reviewer, evidence directory | none required} > - route: {unattended | person}, class {class}, ceiling {ceiling}, round from {the `round:` value}; {the `reason:` lines, or "no reason"} +> - spec: {the `spec:` lines of the route} > - gates: {the gate lines}, read {UTC time} > - merge: {merged unattended at : class , ceiling , lenses | merged at (merge_by: coordinator, the route said ) | ready, a person merges: ; because: | not ready: } > - release: {the five receipt lines | watching since | not watched: | nothing merged} diff --git a/skills/reconcile/SKILL.md b/skills/reconcile/SKILL.md index 3f492572..d94345f3 100644 --- a/skills/reconcile/SKILL.md +++ b/skills/reconcile/SKILL.md @@ -1,9 +1,9 @@ --- name: reconcile -description: "Consent-based cleanup of .ytstack/ leftovers: draft summary stubs, unfilled auto-drafts, milestones planned but never sliced, untracked .ytstack files, a .ytstack/.local without gitignore, history that grew inside STATE.md, slice and task files of closed milestones, and a large plan outside .ytstack/ (plans/*.md tables or checklists) that ytstack-frontier cannot see. Use when the SessionStart STATE lint reports warnings, or when the user says reconcile, clean up .ytstack, tidy the artifacts, the frontier shows nothing, map our plans into milestones. Never deletes; the only sanctioned way to move .ytstack artifacts." +description: "Consent-based cleanup of .ytstack/ leftovers: draft summary stubs, unfilled auto-drafts, milestones planned but never sliced, untracked .ytstack files, a .ytstack/.local without gitignore, history that grew inside STATE.md, slice and task files of closed milestones, slices whose tasks have no task plans, a STATE pointer behind the milestone in progress, and a large plan outside .ytstack/ (plans/*.md tables or checklists) that ytstack-frontier cannot see. Use when the SessionStart STATE lint reports warnings, or when the user says reconcile, clean up .ytstack, tidy the artifacts, the frontier shows nothing, map our plans into milestones. Never deletes; the only sanctioned way to move .ytstack artifacts." metadata: tier: core - version: 0.3.0 + version: 0.4.0 allowed-tools: - Bash - Read @@ -26,8 +26,8 @@ You MUST create a TodoWrite task for each of these items and complete them in or 1. **Run preamble** -- counts and file lists per leftover class 2. **HARD-GATE** -- `.ytstack` present; nothing to do -> report and stop -3. **Per class: ask** -- close / archive / keep (one AskUserQuestion per non-empty class); map / leave for an external plan (only if `EXTERNAL_PLAN_OFFER: yes`) -4. **Apply** -- moves inside `.ytstack/` only, status edits, gitignore block; after a yes to the external plan, its open rows as new milestones and slices +3. **Per class: ask** -- close / archive / keep (one AskUserQuestion per non-empty class); write / keep for task-plan skeletons (only if `TASKS_WITHOUT_PLAN` is above zero); fix / keep for the STATE pointer (only if `STATE_POINTER` says `behind`); map / leave for an external plan (only if `EXTERNAL_PLAN_OFFER: yes`) +4. **Apply** -- moves inside `.ytstack/` only, status edits, gitignore block; after a yes, the task-plan skeletons and the STATE pointer through `bin/ytstack-reconcile`; after a yes to the external plan, its open rows as new milestones and slices 5. **Write `RECONCILE-.md`** -- what was found, what was chosen 6. **Report + return** @@ -124,9 +124,19 @@ if [ -n "$_YT_DIR" ] && [ -f "$_PLANS_BIN" ]; then _EXT_PLAN=$(bash "$_PLANS_BIN" -C "$_PROJECT_DIR" scan 2>/dev/null) && _EXT_OFFER=yes fi +# Tasks of open slices that never got a task plan, and a STATE pointer behind +# the milestone in progress (issue #76): listed by bin/ytstack-reconcile. +_SKELETONS=""; _POINTER="unknown (bin/ytstack-reconcile not reachable)" +_RECONCILE_BIN="${CLAUDE_SKILL_DIR}/../../bin/ytstack-reconcile" +if [ -n "$_YT_DIR" ] && [ -f "$_RECONCILE_BIN" ]; then + _SKELETONS=$(bash "$_RECONCILE_BIN" -C "$_PROJECT_DIR" skeletons 2>/dev/null) + _POINTER=$(bash "$_RECONCILE_BIN" -C "$_PROJECT_DIR" pointer 2>/dev/null) || true +fi + echo "BRANCH: $(git branch --show-current 2>/dev/null || echo unknown)" echo "PROJECT_SLUG: $_PROJECT_SLUG" echo "HAS_YTSTACK: $_HAS_YTSTACK" +echo "YTSTACK_NON_INTERACTIVE: $([ -n "$YTSTACK_NON_INTERACTIVE$OPENCLAW_SESSION$CLAUDE_AGENT_TEAM_MEMBER" ] && echo true || echo false)" echo "DRAFT_STUBS: $(_count "$_DRAFT_STUBS")" echo "UNFILLED_DRAFTS: $(_count "$_UNFILLED")" echo "PLANNED_NEVER_SLICED: $(_count "$_NEVER_SLICED")" @@ -134,6 +144,8 @@ echo "UNTRACKED: $(_count "$_UNTRACKED")" echo "LOCAL_DIR: $_LOCAL_DIR (gitignored: $_LOCAL_IGNORED)" echo "STATE_HISTORY: $_STATE_CLASS ($_STATE_HIST earlier status paragraph(s), $_STATE_BYTES bytes, bound $_STATE_MAX)" echo "CLOSED_MILESTONES: $(_count "$_CLOSED_MS")" +echo "TASKS_WITHOUT_PLAN: $(_count "$_SKELETONS")" +echo "STATE_POINTER: ${_POINTER:-unknown}" echo "EXTERNAL_PLAN_OFFER: $_EXT_OFFER" echo "EXTERNAL_PLAN:"; printf '%s\n' "$_EXT_PLAN" | sed 's/^/ /' echo "LISTS_BEGIN" @@ -142,6 +154,7 @@ echo "LISTS_BEGIN" [ -n "$_UNFILLED" ] && { echo "[unfilled auto-drafts]"; printf '%s\n' "$_UNFILLED" | head -20; } [ -n "$_NEVER_SLICED" ] && { echo "[planned, never sliced]"; printf '%s\n' "$_NEVER_SLICED"; } [ -n "$_UNTRACKED" ] && { echo "[untracked]"; printf '%s\n' "$_UNTRACKED" | head -20; } +[ -n "$_SKELETONS" ] && { echo "[tasks without plan] (task, plan to write, paths found)"; printf '%s\n' "$_SKELETONS" | head -40; } echo "LISTS_END" ``` @@ -149,7 +162,7 @@ echo "LISTS_END" ### Step 2: HARD-GATE -`HAS_YTSTACK=no`: "Nothing to reconcile: no `.ytstack/` here." STOP. All counts zero, `STATE_HISTORY: no`, `LOCAL_DIR: no` (or gitignored) and `EXTERNAL_PLAN_OFFER: no`: "`.ytstack/` is clean." STOP. +`HAS_YTSTACK=no`: "Nothing to reconcile: no `.ytstack/` here." STOP. All counts zero, `STATE_HISTORY: no`, `LOCAL_DIR: no` (or gitignored), `STATE_POINTER` not `pointer: behind` and `EXTERNAL_PLAN_OFFER: no`: "`.ytstack/` is clean." STOP. ### Step 3: Ask per non-empty class @@ -167,7 +180,7 @@ Use AskUserQuestion once per class, in this order: draft stubs, unfilled auto-dr Untracked files use `stage` (git add) / `archive` / `keep`. For the `.local` dir without gitignore the only action is `yt_ensure_gitignore "$_PROJECT_DIR"` (ask yes/no). -Two more classes, each with its own question, after the ones above: +More classes, each with its own question, after the ones above and in this order: **STATE.md history** (`STATE_HISTORY: yes`). `STATE.md` is the pointer: where the work stands and what is next. Earlier status paragraphs, and a ledger that grew inside it, make every session read history first and push the next action out of the SessionStart injection. @@ -193,6 +206,45 @@ On A: write the archive file first, then remove from `STATE.md` exactly the text > A) archive -- move each milestone's `M###-S##-*.md` files to `.ytstack/archive/{YYYY-MM-DD}/M###/`, one `INDEX.md` line per milestone. (Completeness: 9/10, tier: core) > B) keep -- no change. (Completeness: 6/10, tier: core) +**Tasks without a plan** (`TASKS_WITHOUT_PLAN` above zero). Slices of open milestones whose tasks never got an `M###-S##-T##-PLAN.md`: work ran past `plan-task`, so no task names its files, its verification or what it changes in the spec, and `summarize-task` and `finish-lane` have nothing to check against. `bin/ytstack-reconcile skeletons` listed them between `LISTS_BEGIN` and `LISTS_END` (task, the plan to write, how many paths it found). If `YTSTACK_NON_INTERACTIVE` is `true`, take A and log `[ytstack:reconcile] auto-picked A (write skeletons) because YTSTACK_NON_INTERACTIVE=true`. Otherwise use AskUserQuestion: + +> Reconciling `.ytstack/` for **{PROJECT_SLUG}** on branch `{BRANCH}`. {N} task(s) in {slice list} have no task plan: {up to five task refs}. +> +> A task plan is the page that says which files a task touches, how you check it is done, and which part of the project description it changes. Without it nobody can check a finished task against anything. A skeleton is that page with what the slice plan already says filled in (the task line, the file paths it names) and `TODO` where a person or the next session has to decide. Nothing that exists is changed. +> +> RECOMMENDATION: Choose A because the skeletons cost nothing to write and every `TODO` is visible: `ytstack-spec impact` fails until the Spec impact is filled. +> +> A) Write the skeletons -- one task plan per listed task, beside its slice plan; existing files are never overwritten +> Completeness: 9/10, effort: human: fill the TODOs ~5 min per task / CC: ~1 min, tier: core +> +> B) Write them for the slices I name -- tell me which slices +> Completeness: 7/10, effort: human: ~2 min / CC: ~1 min, tier: core +> +> C) Keep -- no change; the tasks stay unplanned +> Completeness: 3/10, effort: human: 0 / CC: 0, tier: core +> +> (to re-ask later: run `ytstack:reconcile` again; nothing is recorded for this class) + +On A run `"${CLAUDE_SKILL_DIR}/../../bin/ytstack-reconcile" skeletons --write` in a Bash call; on B the same with one `--slice M###-S##` per slice the user named. The script prints one `wrote` or `kept` line per file. Then name the `TODO` lines that need a person: the exact Files, the Verification command, the Spec impact section. + +**STATE pointer** (`STATE_POINTER` starts with `pointer: behind`). `STATE.md` names a milestone that is closed or older than the newest milestone in progress, so every session starts from the wrong place and the STATE lint warns at each start. If `YTSTACK_NON_INTERACTIVE` is `true`, take A and log `[ytstack:reconcile] auto-picked A (fix the pointer) because YTSTACK_NON_INTERACTIVE=true`. Otherwise use AskUserQuestion: + +> Reconciling `.ytstack/` for **{PROJECT_SLUG}** on branch `{BRANCH}`. {the `STATE_POINTER` line}. +> +> `STATE.md` is the bookmark every session opens first. It points at {old milestone}, while the work happens in {new milestone}. Fixing it moves the bookmark: the milestone, the slice (the first open one) and the task (`none`, `plan-task` sets it). The rest of the file stays as it is. +> +> RECOMMENDATION: Choose A because the milestone in progress is the one the roadmap says is being worked on, and a bookmark that is wrong makes every session read the wrong plans. +> +> A) Fix the pointer -- `current_milestone`, `active_slice`, `active_task: none` and `last_updated` in the frontmatter +> Completeness: 10/10, effort: human: 0 / CC: ~1 min, tier: core +> +> B) Keep -- no change; the lint keeps warning +> Completeness: 4/10, effort: human: 0 / CC: 0, tier: core +> +> (to re-ask later: run `ytstack:reconcile` again; the lint shows the pointer at every session start) + +On A run `"${CLAUDE_SKILL_DIR}/../../bin/ytstack-reconcile" pointer --fix` and put its `fixed:` line into the log. + **External plan** (`EXTERNAL_PLAN_OFFER: yes`), last. A directory such as `plans/` holds tables or checklists of open work, and `ytstack-frontier` reads only milestones and slices inside `.ytstack/`: the lanes for that work get tracked by hand. The rules (what counts, thresholds, the mapping, the pointer back) are in `${CLAUDE_SKILL_DIR}/../../docs/ux/external-plans.md`; read it before you ask. Ask once per directory with `verdict=large answer=none` in `EXTERNAL_PLAN`. First run `"${CLAUDE_SKILL_DIR}/../../bin/ytstack-plans" rows --open {dir}` and count the open rows per file, so the question can name the files. If `YTSTACK_NON_INTERACTIVE` is set, take the RECOMMENDATION (for B: the file with the most open rows) and log `[ytstack:reconcile] auto-picked {X} for the external plan in {dir} because YTSTACK_NON_INTERACTIVE=true`. Otherwise use AskUserQuestion: @@ -218,15 +270,15 @@ On A or B, map by the document's section "The mapping" and run its "Afterwards" ### Step 4: Apply -Moves only inside `.ytstack/` (`git mv` when tracked, `mv` otherwise), edits only to frontmatter `status:`/`closed:` fields and the global `ROADMAP.md` rows. No `rm`. No edits to STATE.md pointer fields. The one edit to the body of `STATE.md` is the history move of the class above, and only after its answer A. The external plan class adds files and changes none: new `M###-CONTEXT.md`, `M###-ROADMAP.md` and `M###-S##-PLAN.md` files, a `ROADMAP.md` row per new milestone and one line in `PREFERENCES.md`. Nothing outside `.ytstack/` is written; the external plan is read only. +Moves only inside `.ytstack/` (`git mv` when tracked, `mv` otherwise), edits only to frontmatter `status:`/`closed:` fields and the global `ROADMAP.md` rows. No `rm`. The STATE.md pointer fields change only through `ytstack-reconcile pointer --fix`, after answer A of the pointer class. The one edit to the body of `STATE.md` is the history move of the class above, and only after its answer A. The task-plan class adds files and changes none: `ytstack-reconcile skeletons --write` never writes over an existing plan. The external plan class adds files and changes none: new `M###-CONTEXT.md`, `M###-ROADMAP.md` and `M###-S##-PLAN.md` files, a `ROADMAP.md` row per new milestone and one line in `PREFERENCES.md`. Nothing outside `.ytstack/` is written; the external plan is read only. ### Step 5: Write the log -`.ytstack/RECONCILE-{YYYY-MM-DD}.md`: per class the items found and the choice made, plus the archive path. For the external plan: the directory, the files mapped, and per new milestone its slices with the source file. +`.ytstack/RECONCILE-{YYYY-MM-DD}.md`: per class the items found and the choice made, plus the archive path. For the task plans: each file written or kept. For the pointer: the `fixed:` line. For the external plan: the directory, the files mapped, and per new milestone its slices with the source file. ### Step 6: Report + return -> Reconciled `.ytstack/`: {N closed}, {N archived} (-> `archive/{date}/`), {N kept}{, external plan `{dir}/`: {M} milestones with {S} slices mapped (`M###`..`M###`), the frontier lists them | declined}. Log: `RECONCILE-{date}.md`. +> Reconciled `.ytstack/`: {N closed}, {N archived} (-> `archive/{date}/`), {N kept}{, {N} task-plan skeletons written, TODOs to fill: {files}}{, STATE pointer {old} -> {new}}{, external plan `{dir}/`: {M} milestones with {S} slices mapped (`M###`..`M###`), the frontier lists them | declined}. Log: `RECONCILE-{date}.md`. ## Terminal State diff --git a/skills/spawn-milestone-team/SKILL.md b/skills/spawn-milestone-team/SKILL.md index 287e3cac..663a43ed 100644 --- a/skills/spawn-milestone-team/SKILL.md +++ b/skills/spawn-milestone-team/SKILL.md @@ -3,7 +3,7 @@ name: spawn-milestone-team description: "Dispatches the current milestone's slices to parallel workers: by default one worktree-isolated implementer subagent per slice plus a fresh verifier per slice, orchestrated from the main session which never edits source; with PREFERENCES team on, a Claude Code Agent Team instead. Use after slice-milestone and plan-eng-review when the slices are independent, or when the user says spawn the team, run the slices in parallel, dispatch the milestone. Not for a single slice or sequential work (plan-task)." metadata: tier: task - version: 0.5.1 + version: 0.5.2 triggers: - spawn team - dispatch milestone diff --git a/skills/spawn-milestone-team/brief-template.md b/skills/spawn-milestone-team/brief-template.md index b8e313c8..2a6d7460 100644 --- a/skills/spawn-milestone-team/brief-template.md +++ b/skills/spawn-milestone-team/brief-template.md @@ -3,8 +3,15 @@ - + + + + + + + + @@ -72,6 +79,8 @@ The human gave these once and for all; they override the defaults of this brief. {{SPEC_IMPACT}} +This is a duty, not background. When your change makes a sentence of an area file under "Read for context" false (behaviour, a contract, a guard, an error path, where it is implemented), edit that section in the same commits, or the source the area file names. The report's `Spec:` line names what you edited; an unchanged spec needs its reason there. + ## Gates {{GATES}} @@ -97,6 +106,7 @@ End with exactly this report: all eleven labels, in this order, each at the star - `Status:` is one of the three words and nothing else. `partial` and `blocked` are said there, never in a paragraph. `blocked` names what blocks under `Blockers:`; `complete` has `Blockers: none`. - One `Checks run:` line per check, with the raw exit code. No check ran: `Checks run: none -- `. - `Uncommitted:` names every file you changed and did not commit. +- `Spec:` is the spec delta: per section you edited `: (
)`, several joined by `;`, or `none -- ` (restores the described behaviour, no behaviour or contract changes, not covered by an area). A bare `none` fails the check, and a change to behaviour, a contract or a guard without an edited section or a reason does not merge without a person. - Claim nothing that has no line here. What you did not run goes under `Not checked:`, not into `Outcome:`. ``` @@ -106,7 +116,7 @@ Outcome: Commits: ..HEAD, or "none"> Uncommitted: Checks run: -- exit at in -Spec: +Spec: : (
); ... | none -- Deviations: Blockers: Not checked: diff --git a/tests/skill-preambles.test.sh b/tests/skill-preambles.test.sh index b6b511fc..52b32dd5 100644 --- a/tests/skill-preambles.test.sh +++ b/tests/skill-preambles.test.sh @@ -217,6 +217,18 @@ for s in $SKILLS; do has "$s: planned-never-sliced counted" "$OUT" "PLANNED_NEVER_SLICED: 1" has "$s: untracked counted (3 new files)" "$OUT" "UNTRACKED: 3" rm -f "$WT/.ytstack/M999-S01-T09-SUMMARY.md" "$WT/.ytstack/M777-ROADMAP.md" "$WT/.ytstack/stray.md" + has "$s: clean fixture -> no task without a plan" "$OUT" "TASKS_WITHOUT_PLAN: 0" + has "$s: clean fixture -> the pointer is not behind" "$OUT" "STATE_POINTER: pointer: no milestone in progress" + # issue #76: a slice in progress whose task has no plan, STATE on a closed milestone + cp "$WT/.ytstack/M999-ROADMAP.md" "$TMP/rm999.bak" + printf -- '---\nmilestone: M999\nstatus: done\n---\n- [x] S01 -- x\n' > "$WT/.ytstack/M999-ROADMAP.md" + printf -- '---\nmilestone: M888\nstatus: in-progress\n---\n- [ ] S01 -- y\n' > "$WT/.ytstack/M888-ROADMAP.md" + printf -- '---\nstatus: planned\n---\n## Tasks\n\n- [ ] T01 -- y in `src/y.sh`\n' > "$WT/.ytstack/M888-S01-PLAN.md" + run_pre "$P" "$WT" + has "$s: a task without a plan is counted" "$OUT" "TASKS_WITHOUT_PLAN: 1" + has "$s: and listed with the plan to write" "$OUT" "M888-S01-T01 .ytstack/M888-S01-T01-PLAN.md 1" + has "$s: a pointer on a closed milestone is behind" "$OUT" "STATE_POINTER: pointer: behind -- current_milestone M999" + cp "$TMP/rm999.bak" "$WT/.ytstack/M999-ROADMAP.md"; rm -f "$WT/.ytstack/M888-ROADMAP.md" "$WT/.ytstack/M888-S01-PLAN.md" ext_plan_checks ;; reassess-roadmap) # bounded work (M023): open gates, non-converging reviews, the two numbers diff --git a/tests/ytstack-brief.test.sh b/tests/ytstack-brief.test.sh index d994b24f..310fe256 100644 --- a/tests/ytstack-brief.test.sh +++ b/tests/ytstack-brief.test.sh @@ -9,7 +9,9 @@ # technical spec covers the planned files; Gates only when # the plan has some; Git only with --branch # render --slice goal and task list; per planned task its parts; a task -# without a plan is named as not planned +# without a plan gets the plan to write as its first step +# render --task of a task the slice plan lists and no plan describes: a +# plan-first brief, the task plan is the first deliverable # render --kind "## Kind" says what the worker may do: implement (the # default) commits with the prefix; review is read only, pins # the range from --head (a commit hash, required) and --base, @@ -180,7 +182,7 @@ has "a plan under milestones/M###/ is found" '- `.ytstack/milestones/M002/M002-S # ---- 2. render --slice -------------------------------------------------------- echo "# render --slice" R=$(new_repo slice) -printf -- '---\nstatus: planned\n---\n\n# Slice Plan\n\n**Goal:** Token login works end to end\n\n## Tasks\n\n- [ ] T01 -- accept a token\n- [ ] T02 -- reject an expired token\n\n## Gates\n\n- [ ] G01 -- pilot customer agrees | decides: Kim | how: call | lapses: unknown\n\n## Done when\n\nAll tasks done.\n' > "$R/.ytstack/M001-S01-PLAN.md" +printf -- '---\nstatus: planned\n---\n\n# Slice Plan\n\n**Goal:** Token login works end to end\n\n## Tasks\n\n- [ ] T01 -- accept a token\n- [ ] T02 -- reject an expired token in `src/auth/login.sh`\n\n## Gates\n\n- [ ] G01 -- pilot customer agrees | decides: Kim | how: call | lapses: unknown\n\n## Done when\n\nAll tasks done.\n' > "$R/.ytstack/M001-S01-PLAN.md" plan "$R/.ytstack/M001-S01-T01-PLAN.md" "Accept a token" yes run "$R" render --slice M001-S01 --branch ytstack/M001-S01 eq "a slice with one planned and one unplanned task renders" 0 "$EC" @@ -191,7 +193,8 @@ S=$(part Scope) has "Scope: the planned task's files under its label" '**T01** - Modify: `src/auth/login.sh:10-20`' "$S" -has "Scope: the unplanned task is named as such" "**T02** -- not planned yet: run ytstack:plan-task first, or plan it yourself with exact files and a verification command before you write code" "$S" +has "Scope: the unplanned task's plan is its first deliverable" "**T02** -- not planned yet: first write its plan \`.ytstack/M001-S01-T02-PLAN.md\` in the format of \`ytstack:plan-task\`" "$S" +hasnt "nobody is told to plan it himself" "plan it yourself" "$OUT" C=$(part "Read for context") has "Context: the slice plan" '- `.ytstack/M001-S01-PLAN.md`' "$C" has "Context: the task plan" '- `.ytstack/M001-S01-T01-PLAN.md`' "$C" @@ -204,12 +207,58 @@ has "Gates: the slice's gate" "G01 -- pilot customer agrees" "$G" has "Gates: the task's gate" "G01 -- sign-off" "$G" has "Git: one prefix per task" 'prefix `M001-S01-T##:`' "$(part Git)" +# An unplanned task of a planned slice (issue #76): a plan-first brief whose +# first deliverable is the task plan, then the implementation. +run "$R" render --task M001-S01-T02 --branch ytstack/M001-S01 +eq "an unplanned task of a planned slice renders" 0 "$EC" +eq "plan first: the brief marker is the first line (hooks/pre-tool-use-agent)" "# Brief: M001-S01-T02 (acme)" "$(printf '%s\n' "$OUT" | head -1)" +O=$(part Outcome) +has "plan first: the task line" "reject an expired token" "$O" +has "plan first: the plan is the first deliverable" 'Your first deliverable is its plan: write `.ytstack/M001-S01-T02-PLAN.md`' "$O" +has "plan first: in the format of plan-task" "Step 9 of \`$ROOT/skills/plan-task/SKILL.md\`" "$O" +has "plan first: the sections of a task plan" '`## Files` with the exact paths' "$O" +has "plan first: the plan is committed before the code" "it goes into your first commit, alone" "$O" +hasnt "plan first: nobody is told to plan it himself" "plan it yourself" "$OUT" +S=$(part Scope) +has "plan first: Scope starts with the plan file" '`.ytstack/M001-S01-T02-PLAN.md` (the plan you write first), then the files that plan names under `## Files`.' "$S" +has "plan first: the paths the slice plan names for the task" '- `src/auth/login.sh`' "$S" +has "plan first: Verification comes from the plan the worker writes" 'The command your plan names under `## Verification`.' "$(part Verification)" +has "plan first: Spec impact comes from that plan too" 'What your plan names under `## Spec impact`.' "$(part "Spec impact")" +has "plan first: the slice plan is read" '- `.ytstack/M001-S01-PLAN.md`' "$(part "Read for context")" +has "plan first: the commit prefix is the task" 'prefix `M001-S01-T02:`' "$(part Git)" +run "$R" render --task M001-S01-T02 --kind review --head abc1234 +eq "plan first: a review of an unplanned task has nothing to review against: exit 1" 1 "$EC" +run "$R" render --task M001-S01-T07 +eq "plan first: a task the slice plan does not list: exit 1" 1 "$EC" + # granularity: slice -- the slice plan carries Files and Verification itself plan "$R/.ytstack/M002-S01-PLAN.md" "unused" printf '\n**Goal:** Whole slice in one plan\n\n## Tasks\n\n- [ ] T01 -- all of it\n' >> "$R/.ytstack/M002-S01-PLAN.md" run "$R" render --slice M002-S01 hasnt "a slice plan with its own Files has no unplanned tasks" "not planned yet" "$OUT" has "and its own files are the scope" '- Create: `tests/login.test.sh`' "$(part Scope)" +# review #88 item 9: a task of such a slice is not asked for a task plan +run "$R" render --task M002-S01-T01 +eq "granularity slice: a task of a slice plan with its own Files renders" 0 "$EC" +eq "granularity slice: the brief marker is the first line" "# Brief: M002-S01-T01 (acme)" "$(printf '%s\n' "$OUT" | head -1)" +hasnt "granularity slice: no task plan is demanded" "first deliverable" "$OUT" +has "granularity slice: the slice plan's files are the scope" '- Create: `tests/login.test.sh`' "$(part Scope)" +has "granularity slice: the slice plan's verification" "bash tests/login.test.sh" "$(part Verification)" +has "granularity slice: the task line is the outcome" "all of it" "$(part Outcome)" +# Codex P2 on #88: only an open task of the slice plan gets a brief +run "$R" render --task M002-S01-T99 +eq "granularity slice: a task the slice plan does not list: exit 1" 1 "$EC" +printf -- '- [x] T02 -- done already\n' >> "$R/.ytstack/M002-S01-PLAN.md" # the file ends in "## Tasks" +run "$R" render --task M002-S01-T02 +eq "granularity slice: a ticked task: exit 1" 1 "$EC" + +# review #88 item 3: the plan-first brief names the area of the task line's paths +mkdir -p "$R/.ytstack/spec" +printf -- '---\nproject: acme\n---\n\n# spec\n' > "$R/.ytstack/spec/SPEC.md" +printf -- '---\narea: auth\nstatus: planned\npaths:\n - src/auth/**\n---\n' > "$R/.ytstack/spec/auth.md" +run "$R" render --task M001-S01-T02 +has "plan first: the area file of the task line's paths is read" '- `.ytstack/spec/auth.md`' "$(part "Read for context")" +rm -rf "$R/.ytstack/spec" # ---- 3. render --kind --------------------------------------------------------- echo "# render --kind" @@ -443,13 +492,14 @@ Blockers: none Not checked: the CI run, it starts after the push Next: dispatch the verifier on abc1234' # chk : sets OUT and EC -chk() { OUT=$(printf '%s\n' "$1" | bash "$BIN" check 2>&1); EC=$?; } +# (from $TMP: in a project with a spec, check also reads its area files) +chk() { OUT=$(cd "$TMP" && printf '%s\n' "$1" | bash "$BIN" check 2>&1); EC=$?; } chk "$GOOD" eq "a complete report passes" 0 "$EC" eq "and says so" "report ok" "$OUT" printf '%s\n' "$GOOD" > "$TMP/report.txt" -OUT=$(bash "$BIN" check "$TMP/report.txt" 2>&1); eq "a report file is read like stdin" "report ok" "$OUT" +OUT=$(bash "$BIN" -C "$TMP" check "$TMP/report.txt" 2>&1); eq "a report file is read like stdin" "report ok" "$OUT" for L in "Task" "Status" "Outcome" "Commits" "Uncommitted" "Checks run" "Spec" "Deviations" "Blockers" "Not checked" "Next"; do chk "$(printf '%s\n' "$GOOD" | grep -v "^$L:")" @@ -470,6 +520,37 @@ eq "Status: blocked with a blocker passes, also one that starts with 'none'" "re chk "$(printf '%s\n' "$GOOD" | sed -e 's/^Status:.*/Status: partial/' -e 's/^Blockers:.*/Blockers: None./')" eq "Status: partial passes with or without a blocker" "report ok" "$OUT" +# The spec delta (issue #75): the edited spec section with its path, or +# "none -- "; a bare "none" or prose is no delta. +chk "$(printf '%s\n' "$GOOD" | sed 's#^Spec:.*#Spec: auth: .ytstack/spec/auth.md (Behavior); billing: docs/billing.md (Export)#')" +eq "Spec: two edited sections with their paths pass" "report ok" "$OUT" +chk "$(printf '%s\n' "$GOOD" | sed 's/^Spec:.*/Spec: none -- restores the described behaviour/')" +eq "Spec: none with a reason passes" "report ok" "$OUT" +chk "$(printf '%s\n' "$GOOD" | sed 's/^Spec:.*/Spec: none/')" +eq "Spec: a bare none fails" 1 "$EC" +eq "and says what it needs" 'Spec: "none" is no spec delta: name each edited section as ": (
)", or write "none -- "' "$OUT" +chk "$(printf '%s\n' "$GOOD" | sed 's/^Spec:.*/Spec: updated the auth docs/')" +eq "Spec: prose without an area and a path fails" 'Spec: "updated the auth docs" is no spec delta: name each edited section as ": (
)", or write "none -- "' "$OUT" +chk "$(printf '%s\n' "$GOOD" | sed 's#^Spec:.*#Spec: auth: .ytstack/spec/auth.md; the rest is unchanged#')" +eq "Spec: every entry needs an area and a path" 1 "$EC" +chk "$(printf '%s\n' "$GOOD" | sed 's#^Spec:.*#Spec: auth: `.ytstack/spec/auth.md` (Behavior)#')" +eq "Spec: a path in backticks is read like a bare one" "report ok" "$OUT" +# review #88 item 1: in a project with a spec, the path is the area file or one of its sources +SR=$(new_repo specchk); mkdir -p "$SR/.ytstack/spec" "$SR/docs"; echo d > "$SR/docs/auth.md" +printf -- '---\nproject: acme\n---\n\n# spec\n' > "$SR/.ytstack/spec/SPEC.md" +printf -- '---\narea: auth\nstatus: planned\npaths:\n - src/auth/**\nsources:\n - docs/auth.md\n---\n' > "$SR/.ytstack/spec/auth.md" +# schk : the report with that Spec: line, checked in the project +schk() { OUT=$(printf '%s\n' "$GOOD" | sed "s#^Spec:.*#Spec: $1#" | bash "$BIN" -C "$SR" check 2>&1); EC=$?; } +schk 'auth: src/auth/login.sh (Behavior)' +eq "a code file is no spec edit" 'Spec: "auth: src/auth/login.sh" is neither .ytstack/spec/auth.md nor one of its sources' "$OUT" +schk 'auth: .ytstack/spec/auth.md (Behavior); auth: `docs/auth.md` (Login)' +eq "the area file and a source pass" "report ok" "$OUT" +printf -- '---\narea: auth\nstatus: planned\npaths:\n - src/auth/**\nsources:\n - docs/Auth Guide.md\n---\n' > "$SR/.ytstack/spec/auth.md" +schk 'auth: docs/Auth Guide.md (Login)' +eq "a source with a space in its name is read whole" "report ok" "$OUT" +schk 'billing: .ytstack/spec/billing.md (Behavior)' +eq "an area the project does not have fails" 'Spec: "billing: .ytstack/spec/billing.md" names no area of this project (.ytstack/spec/billing.md does not exist)' "$OUT" + chk "$(printf '%s\n' "$GOOD" | sed 's/^Not checked:.*/Not checked: /')" eq "an empty Not checked fails" 1 "$EC" eq "and is named" "empty: Not checked" "$OUT" @@ -545,10 +626,13 @@ SHAPE=$(part Report) eq "the shape names the eleven labels, in the order of the format document" \ "Task,Status,Outcome,Commits,Uncommitted,Checks run,Spec,Deviations,Blockers,Not checked,Next," \ "$(printf '%s\n' "$SHAPE" | sed -n 's/^\([A-Z][A-Za-z ]*\): <.*/\1/p' | tr '\n' ',')" +has "the shape says the spec delta is a duty" 'is the spec delta' "$SHAPE" +has "Spec impact: the duty to edit the area file" 'edit that section in the same commits' "$(part "Spec impact")" chk "$SHAPE" eq "the unfilled report shape does not pass" 'Checks run: no exit code in " -- exit at in " +Spec: ": (
); ... | none -- " is no spec delta: name each edited section as ": (
)", or write "none -- " Status: "" is not complete, partial or blocked' "$OUT" -chk "$(printf '%s\n' "$SHAPE" | sed -e 's/exit /exit 0/' -e 's/^Status:.*/Status: partial/')" +chk "$(printf '%s\n' "$SHAPE" | sed -e 's/exit /exit 0/' -e 's/^Status:.*/Status: partial/' -e 's/^Spec:.*/Spec: none -- no behaviour or contract changes/')" eq "with an exit code and a status filled in, its labels are complete" "report ok" "$OUT" OUT=$(bash "$BIN" check "$TMP/none.txt" 2>&1); eq "an unreadable report file: exit 64" 64 "$?" diff --git a/tests/ytstack-finish-lane.test.sh b/tests/ytstack-finish-lane.test.sh index 7601c4fb..a7a9717e 100644 --- a/tests/ytstack-finish-lane.test.sh +++ b/tests/ytstack-finish-lane.test.sh @@ -24,7 +24,9 @@ # host is read without --pr; the evidence of a visual lens is # read from the main checkout, also when the session works in a # linked worktree; with --pr the round comes from the review on -# the host, also for a lane without a plan +# the host, also for a lane without a plan; with a technical +# spec a change to an area's paths without its area file, a +# plan's impact or a reason in the report (--report) is "person" # usage exit 64 # # The host is a fake `gh` first in PATH that answers from fixture files and @@ -493,6 +495,131 @@ has "the plan is named as the source" "round: plan" "$OUT" quiet; run "$RT" route --lane M001-S01 --base "$RB" --head "$RH" --pr seven eq "a pull request that is no number: exit 64" 64 "$EC" +# The spec delta (issue #75): with a technical spec, a change to an area's +# paths needs an edited area file, a plan that states the impact, or a reason +# in the worker's report; otherwise it does not merge without a person. +RS="$TMP/routes"; mkdir -p "$RS/src" "$RS/.ytstack/spec" +( cd "$RS" || exit 1 + git init -q -b main && git config user.email t@t.t && git config user.name t && git config commit.gpgsign false || exit 1 + echo a > src/a.sh + printf -- '---\nproject: p\n---\n\n# p\n\n## Areas\n\n| Area | File |\n|---|---|\n| core | [core.md](core.md) |\n\n## Keeping this true\n\n- x\n' > .ytstack/spec/SPEC.md + printf -- '---\narea: core\nstatus: implemented\npaths:\n - src/**\nauto_merge: low\n---\n\n# core\n\n## Behavior\n\n- a\n\n## Invariants and security boundaries\n\n- x\n\n## Decisions that apply now\n\n- none\n' > .ytstack/spec/core.md + git add -A && git commit -qm base + git checkout -q -b code && echo b >> src/a.sh && git commit -qam "M001-S01-T01: change a" + git checkout -q -b documented && awk '{ print } /^- a$/ { print "- b" }' .ytstack/spec/core.md > core.tmp && mv core.tmp .ytstack/spec/core.md && git commit -qam "M001-S01-T01: describe b" + git checkout -q main ) >/dev/null 2>&1 +SB=$(git -C "$RS" rev-parse main); SC=$(git -C "$RS" rev-parse code); SD=$(git -C "$RS" rev-parse documented) +printf -- '---\nupdated: 2026-11-13T10:00:00Z\n---\n\n# Lanes\n\n| Lane | Kind | Status | Claimed by | Branch | Worktree | PR | Reviewed head | Round | Next action |\n|---|---|---|---|---|---|---|---|---|---|\n| M001-S01 | implement | in-review | impl-M001-S01 2026-11-13T09:00Z | code | - | 7 | - | 1 | - |\n' > "$RS/.ytstack/LANES.md" +# splan : the slice plan with an approving round on that head +splan() { + printf -- '---\nstatus: in-progress\n---\n\n# Slice Plan\n\n## Review\n\n- Round 1: %s..%s -- approved; blocking: 0; follow-ups: 0; risk: low; invariants: none; by: review-M001-S01\n' "${SB:0:7}" "${1:0:7}" > "$RS/.ytstack/M001-S01-PLAN.md" +} +# report : a worker's report with that Spec: line +report() { printf 'Task: M001-S01\nStatus: complete\nSpec: %s\nNext: review\n' "$1" > "$TMP/report.md"; } +sroute() { quiet; run "$RS" route --lane M001-S01 --base "$SB" --head "$1" ${2:+--report "$TMP/report.md"}; } + +splan "$SC"; sroute "$SC" +eq "code changed, no plan states an impact, no report: exit 10" 10 "$EC" +has "the route is person" "route: person" "$OUT" +hasnt "and never unattended" "route: unattended" "$OUT" +has "the spec delta is the reason" "reason: spec -- core: the change touches its paths, neither .ytstack/spec/core.md nor its sources changed" "$OUT" +report "none -- no behaviour or contract changes"; sroute "$SC" r +eq "the report states why the spec is unchanged: exit 0" 0 "$EC" +has "the reason is printed" "spec: core unchanged -- no behaviour or contract changes (the worker's report)" "$OUT" +report "core: .ytstack/spec/core.md (Behavior)"; sroute "$SC" r +eq "the report names an edit the diff does not have: exit 10" 10 "$EC" +has "and says so" "reason: spec -- the report names .ytstack/spec/core.md, which the change does not touch" "$OUT" +splan "$SD"; sroute "$SD" +eq "the lane edited the area file: exit 0" 0 "$EC" +has "and the edit is named" "spec: core -- .ytstack/spec/core.md changed" "$OUT" +splan "$SC" +printf -- '---\ntask: T01\n---\n\n# plan\n\n## Files\n\n- `src/a.sh`\n\n## Spec impact\n\n- core: Behavior -- b\n' > "$RS/.ytstack/M001-S01-T01-PLAN.md" +report "none -- no behaviour or contract changes"; sroute "$SC" r +eq "a task plan names the area and the lane did not edit it: exit 10, the report does not override the plan" 10 "$EC" +has "the impact check is the reason" "reason: spec -- .ytstack/M001-S01-T01-PLAN.md: FAIL core: neither .ytstack/spec/core.md nor its sources" "$OUT" +printf -- '---\ntask: T01\n---\n\n# plan\n\n## Files\n\n- `src/a.sh`\n\n## Spec impact\n\nnone -- restores the described behaviour\n' > "$RS/.ytstack/M001-S01-T01-PLAN.md" +sroute "$SC" +eq "the task plan states none with a reason: exit 0" 0 "$EC" +has "and its line is printed" "spec: .ytstack/M001-S01-T01-PLAN.md -- spec impact: none -- restores the described behaviour" "$OUT" +rm -f "$RS/.ytstack/M001-S01-T01-PLAN.md" +# review #88 items 1, 6, 11: what the report names is checked against the spec +report "core: src/a.sh (Behavior)"; sroute "$SC" r +eq "the report names a code file as the spec edit: exit 10" 10 "$EC" +has "and says that it is no spec file" "reason: spec -- the report names src/a.sh for core, which is neither .ytstack/spec/core.md nor one of its sources" "$OUT" +splan "$SD"; report 'core: `.ytstack/spec/core.md` (Behavior)'; sroute "$SD" r +eq "a path in backticks is read like a bare one: exit 0" 0 "$EC" +splan "$SC"; report "none -- "; sroute "$SC" r +eq "none without a reason: exit 10" 10 "$EC" +has "and says so" "reason: spec -- the report's Spec: line gives no reason after \"none --\"" "$OUT" +# item 2: a task plan of a task with no commit in the range, unchanged by it, does not count +printf -- '---\ntask: T05\n---\n\n# plan\n\n## Spec impact\n\n- core: Behavior -- c\n' > "$RS/.ytstack/M001-S01-T05-PLAN.md" +report "none -- no behaviour or contract changes"; sroute "$SC" r +eq "a plan of a task outside the range is not checked: exit 0" 0 "$EC" +hasnt "and is not named" "M001-S01-T05-PLAN.md" "$OUT" +rm -f "$RS/.ytstack/M001-S01-T05-PLAN.md" + +# item 2: in a slice lane one task's stated impact covers its own areas only +R2="$TMP/routes2"; mkdir -p "$R2/src" "$R2/web" "$R2/.ytstack/spec" +( cd "$R2" || exit 1 + git init -q -b main && git config user.email t@t.t && git config user.name t && git config commit.gpgsign false || exit 1 + echo a > src/a.sh; echo w > web/w.ts + printf -- '---\nproject: p\n---\n\n# p\n\n## Areas\n\n| Area | File |\n|---|---|\n| core | [core.md](core.md) |\n| web | [web.md](web.md) |\n\n## Keeping this true\n\n- x\n' > .ytstack/spec/SPEC.md + for A in core web; do P=src; [ "$A" = web ] && P=web + printf -- '---\narea: %s\nstatus: implemented\npaths:\n - %s/**\nauto_merge: low\n---\n\n# %s\n\n## Behavior\n\n- a\n\n## Invariants and security boundaries\n\n- x\n\n## Decisions that apply now\n\n- none\n' "$A" "$P" "$A" > ".ytstack/spec/$A.md" + done + git add -A && git commit -qm base + git checkout -q -b code && echo b >> src/a.sh && git commit -qam "M001-S01-T01: a" && echo z >> web/w.ts && git commit -qam "M001-S01-T02: web behaviour" + git checkout -q -b moved main && mkdir lib && git mv src/a.sh lib/a.sh && git commit -qm "M001-S01-T01: move" + git checkout -q main ) >/dev/null 2>&1 +B2=$(git -C "$R2" rev-parse main); C2=$(git -C "$R2" rev-parse code); M2=$(git -C "$R2" rev-parse moved) +cp "$RS/.ytstack/LANES.md" "$R2/.ytstack/LANES.md" +r2plan() { printf -- '---\nstatus: in-progress\n---\n\n# Slice Plan\n\n## Tasks\n\n- [x] T01 -- a\n- [x] T02 -- web\n\n## Review\n\n- Round 1: %s..%s -- approved; blocking: 0; follow-ups: 0; risk: low; invariants: none; by: review-M001-S01\n' "${B2:0:7}" "${1:0:7}" > "$R2/.ytstack/M001-S01-PLAN.md"; } +r2plan "$C2" +printf -- '---\ntask: T01\n---\n\n# plan\n\n## Files\n\n- `src/a.sh`\n\n## Spec impact\n\nnone -- restores the described behaviour\n' > "$R2/.ytstack/M001-S01-T01-PLAN.md" +quiet; run "$R2" route --lane M001-S01 --base "$B2" --head "$C2" +eq "T01 says none, T02 changed another area unplanned: exit 10" 10 "$EC" +has "T01's statement covers core" "spec: core unchanged -- restores the described behaviour (.ytstack/M001-S01-T01-PLAN.md)" "$OUT" +has "web needs its own edit or reason" "reason: spec -- web: the change touches its paths" "$OUT" +# Codex P2 on #88: a source with a space in its name is read whole +( cd "$R2" && git checkout -q -b guide main && mkdir -p docs && echo g > "docs/Web Guide.md" && echo y >> web/w.ts \ + && git add -A docs web && git commit -qm "M001-S01-T02: web and its guide" && git checkout -q main ) >/dev/null 2>&1 +G2=$(git -C "$R2" rev-parse guide); cp "$R2/.ytstack/spec/web.md" "$TMP/web.md.bak" +awk '{ print } /^ - web\/\*\*$/ { print "sources:"; print " - docs/Web Guide.md" }' "$TMP/web.md.bak" > "$R2/.ytstack/spec/web.md" +r2plan "$G2"; rm -f "$R2/.ytstack/M001-S01-T01-PLAN.md" +printf 'Task: M001-S01\nStatus: complete\nSpec: web: docs/Web Guide.md (Usage)\nNext: review\n' > "$TMP/report2.md" +quiet; run "$R2" route --lane M001-S01 --base "$B2" --head "$G2" --report "$TMP/report2.md" +has "a spaced source named in the report counts" "spec: web -- docs/Web Guide.md changed" "$OUT" +hasnt "and is not truncated" "reason: spec -- the report names docs/Web" "$OUT" +cp "$TMP/web.md.bak" "$R2/.ytstack/spec/web.md" +# Codex P2 on #88: a plan's own files with a non-ASCII name still count for its area +( cd "$R2" && git checkout -q -b cafe main && echo c > "src/café.sh" && git add src && git commit -qm "M001-S01-T01: café" && git checkout -q main ) >/dev/null 2>&1 +CF=$(git -C "$R2" rev-parse cafe); r2plan "$CF" +printf -- '---\ntask: T01\n---\n\n# plan\n\n## Spec impact\n\nnone -- restores the described behaviour\n' > "$R2/.ytstack/M001-S01-T01-PLAN.md" +quiet; run "$R2" route --lane M001-S01 --base "$B2" --head "$CF" +has "a non-ASCII file of the plan's commit is covered by its statement" "spec: core unchanged -- restores the described behaviour (.ytstack/M001-S01-T01-PLAN.md)" "$OUT" +hasnt "and needs no other reason" "reason: spec -- core" "$OUT" +rm -f "$R2/.ytstack/M001-S01-T01-PLAN.md" +# item 4: a file renamed out of an area still touches it +r2plan "$M2"; rm -f "$R2/.ytstack/M001-S01-T01-PLAN.md" +quiet; run "$R2" route --lane M001-S01 --base "$B2" --head "$M2" +has "a file moved out of an area counts for that area" "reason: spec -- core: the change touches its paths" "$OUT" +quiet; run "$RS" route --lane M001-S01 --base "$SB" --head "$SC" --report "$TMP/none.md" +eq "a report file that cannot be read: exit 64" 64 "$EC" +# The checks inventory: a CI change without its line in REVIEW.md "## Checks". +( cd "$RS" && git checkout -q -b ci main && mkdir -p .github/workflows && echo 'on: push' > .github/workflows/levels.yml \ + && git add -A .github && git commit -qm "M001-S01-T01: level guard" && git checkout -q main ) >/dev/null 2>&1 +SG=$(git -C "$RS" rev-parse ci); splan "$SG" +printf '# Review policy\n\n## Checks\n\n- spec | file: .ytstack/spec/core.md | guards: x\n' > "$RS/.ytstack/spec/REVIEW.md" +sroute "$SG" +has "a CI change without its line in the checks inventory is named" 'checks: the change edits CI (.github/workflows/levels.yml) and .ytstack/spec/REVIEW.md "## Checks" did not change' "$OUT" +rm -f "$RS/.ytstack/spec/REVIEW.md"; sroute "$SG" +hasnt "without an inventory there is no such line" "checks:" "$OUT" +# Codex P2 on #88: the heading is read the way ytstack-risk reads it +printf '# Review policy\n\n## Checks \n\n- spec | file: .ytstack/spec/core.md | guards: x\n' > "$RS/.ytstack/spec/REVIEW.md" +sroute "$SG" +has "a Checks heading with trailing spaces is the inventory" 'checks: the change edits CI' "$OUT" +rm -f "$RS/.ytstack/spec/REVIEW.md" + # A visual lens. The reviewer stored its images in the main checkout; the # coordinating session works in a linked worktree of the same repository. RV="$TMP/routev"; RW="$TMP/routev-wt"; mkdir -p "$RV/src/ui" "$RV/docs" "$RV/.ytstack/spec" diff --git a/tests/ytstack-reconcile.test.sh b/tests/ytstack-reconcile.test.sh new file mode 100644 index 00000000..dd442114 --- /dev/null +++ b/tests/ytstack-reconcile.test.sh @@ -0,0 +1,200 @@ +#!/usr/bin/env bash +# Tests for bin/ytstack-reconcile: the two migration classes of ytstack:reconcile +# (issue #76) that need more than a list. +# +# Contract: +# skeletons one line per open task of a slice that has no task plan +# at all, in an open milestone: ref, the plan to write +# (beside the slice plan), the number of paths found. +# Not listed: a slice with one task plan, a slice plan +# with its own "## Files", a done slice, a ticked task, +# a milestone that is done, dropped, shipped-informally +# or backlog. Writes nothing. +# skeletons --write writes each listed plan in the format of plan-task: +# Files from the task line's backticked paths, else from +# the slice plan's "Own:" / "Files:" lines, else a TODO; +# Spec impact per area of those paths (TODO lines that +# `ytstack-spec impact` does not accept); a TODO +# verification. Never overwrites a file. +# pointer "pointer: ok" or "pointer: behind" (exit 10) when +# current_milestone is older than, or not, the newest +# milestone in progress; names the first open slice. +# pointer --fix sets current_milestone, active_slice, active_task: none +# and last_updated in the frontmatter (or the leading +# key lines of a file without one), adds missing keys, +# refuses a file with neither and writes nothing then. +# usage exit 64; no .ytstack: exit 1 +# +# Run: /bin/bash tests/ytstack-reconcile.test.sh (exit 0 = all pass; macOS bash 3.2) + +set -uo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" +BIN="$ROOT/bin/ytstack-reconcile" + +PASS=0; FAIL=0 +ok() { PASS=$((PASS+1)); echo " ok - $1"; } +bad() { FAIL=$((FAIL+1)); echo " FAIL - $1${2:+ ($2)}"; } +eq() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1" "expected '$2' got '$3'"; fi; } +has() { case "$3" in *"$2"*) ok "$1" ;; *) bad "$1" "no '$2' in: $3" ;; esac; } +hasnt() { case "$3" in *"$2"*) bad "$1" "unexpected '$2' in: $3" ;; *) ok "$1" ;; esac; } + +if [ ! -x "$BIN" ]; then + bad "bin/ytstack-reconcile exists and is executable" + echo "$PASS passed, $FAIL failed" + exit 1 +fi + +TMP=$(mktemp -d "${TMPDIR:-/tmp}/ytrec.XXXXXX"); TMP=$(cd "$TMP" && pwd -P) +trap 'rm -rf "$TMP"' EXIT + +run() { local d="$1"; shift; OUT=$(bash "$BIN" -C "$d" "$@" 2>&1); EC=$?; } + +R="$TMP/proj"; Y="$R/.ytstack"; mkdir -p "$Y/spec" "$R/src/auth" "$R/web" +( cd "$R" || exit 1 + git init -q -b main && git config user.email t@t.t && git config user.name t && git config commit.gpgsign false + echo a > src/auth/login.sh; echo w > web/app.ts + git add -A && git commit -qm base ) >/dev/null 2>&1 || { echo "FATAL fixture"; exit 2; } +printf -- '---\nname: acme\n---\n' > "$Y/PROJECT.md" +printf -- '---\nlast_updated: 2026-11-01T10:00:00Z\ncurrent_milestone: M044\nactive_slice: S02\nactive_task: T03\n---\n\n# State\n\n**Status:** M044 / S02.\n' > "$Y/STATE.md" +# roadmap +roadmap() { printf -- '---\nmilestone: %s\nstatus: %s\n---\n\n# %s\n\n%b\n' "$1" "$2" "$1" "$3" > "$Y/$1-ROADMAP.md"; } +# slice [extra] +slice() { printf -- '---\nstatus: %s\n---\n\n# %s -- Slice Plan\n\n**Goal:** g\n\n%b## Tasks\n\n%b\n' "$2" "$1" "${4:-}" "$3" > "$Y/$1-PLAN.md"; } + +roadmap M044 done '- [x] S01 -- old\n- [x] S02 -- old' +slice M044-S02 done '- [ ] T04 -- left behind' +roadmap M045 in-progress '- [x] S01 -- a\n- [ ] S02 -- b' +slice M045-S01 done '- [x] T01 -- a' +slice M045-S02 planned '- [ ] T01 -- b' +printf -- '---\ntask: T01\n---\n' > "$Y/M045-S02-T01-PLAN.md" +roadmap M046 in-progress '- [x] S01 -- first\n- [ ] S02 -- login\n- [ ] S03 -- web' +slice M046-S01 done '- [x] T01 -- done' +slice M046-S02 in-progress '- [x] T01 -- token parser in `src/auth/token.sh`\n- [ ] T02 -- reject expired tokens in `src/auth/login.sh` and `tests/login.test.sh`\n- [ ] T03 -- document it' +slice M046-S03 planned '- [ ] T01 -- the page' '**Own:** `web/app.ts`, `web/page.ts`\n\n' +roadmap M047 backlog '- [ ] S01 -- later' +slice M047-S01 planned '- [ ] T01 -- later' +roadmap M048 in-progress '- [ ] S01 -- whole slice' +slice M048-S01 planned '- [ ] T01 -- all' '## Files\n\n- `src/x.sh`\n\n' + +# ---- 1. skeletons ------------------------------------------------------------- +echo "# skeletons" +run "$R" skeletons +eq "skeletons lists and exits 0" 0 "$EC" +eq "one line per open task of a slice without any task plan, in open milestones" \ +"M046-S02-T02 .ytstack/M046-S02-T02-PLAN.md 2 +M046-S02-T03 .ytstack/M046-S02-T03-PLAN.md 0 +M046-S03-T01 .ytstack/M046-S03-T01-PLAN.md 2" "$OUT" +eq "and writes nothing" "" "$(ls "$Y" | grep -- '-T0[23]-PLAN.md\|M046-S03-T01-PLAN.md')" +run "$R" skeletons --slice M046-S03 +eq "--slice keeps the named slice" "M046-S03-T01 .ytstack/M046-S03-T01-PLAN.md 2" "$OUT" +run "$R" skeletons --slice S03; eq "--slice needs a slice reference" 64 "$EC" + +# a technical spec: the area of the paths becomes a Spec impact line to fill +printf -- '---\nproject: acme\n---\n\n# spec\n' > "$Y/spec/SPEC.md" +printf -- '---\narea: auth\nstatus: planned\npaths:\n - src/auth/**\n---\n' > "$Y/spec/auth.md" +run "$R" skeletons --write +eq "--write: exit 0" 0 "$EC" +has "--write names each file it wrote" "wrote .ytstack/M046-S02-T02-PLAN.md" "$OUT" +P=$(cat "$Y/M046-S02-T02-PLAN.md") +has "frontmatter of a task plan" "milestone: M046 +slice: S02 +task: T02 +project: acme" "$P" +has "status planned" "status: planned" "$P" +has "marked as a skeleton" "skeleton: reconcile" "$P" +has "Summary is the task line" "**Summary:** reject expired tokens in \`src/auth/login.sh\` and \`tests/login.test.sh\`" "$P" +has "Files from the task line" "## Files + +- \`src/auth/login.sh\` +- \`tests/login.test.sh\`" "$P" +has "Spec impact: one line per area of those paths, to fill" "- auth: TODO section -- TODO what changes" "$P" +has "Verification: a TODO block" "TODO: one or two commands that show this task done" "$P" +has "the sections plan-task writes" "## What this does" "$P" +P=$(cat "$Y/M046-S03-T01-PLAN.md") +has "Files from the slice plan's Own line when the task line names none" "- \`web/app.ts\` +- \`web/page.ts\`" "$P" +has "a path no area covers: the Spec impact says so, to confirm" "TODO: none -- not covered by an area" "$P" +P=$(cat "$Y/M046-S02-T03-PLAN.md") +has "no path anywhere: a TODO for the files" "- TODO: the exact paths" "$P" +# Codex P2 on #88: a backticked path with a space is kept whole +slice M046-S04 planned '- [ ] T01 -- the guide in `docs/Web Guide.md`' +run "$R" skeletons --slice M046-S04 +eq "a spaced path is listed and counted" "M046-S04-T01 .ytstack/M046-S04-T01-PLAN.md 1" "$OUT" +rm -f "$Y/M046-S04-PLAN.md" +OUTP=$(bash "$ROOT/bin/ytstack-spec" -C "$R" impact --plan "$Y/M046-S02-T02-PLAN.md" --base HEAD 2>&1); ECP=$? +eq "an unfilled Spec impact does not pass ytstack-spec impact" 1 "$ECP" +run "$R" skeletons +eq "after --write the slice has task plans and is not listed again" "" "$OUT" +rm -f "$Y"/M046-S0[23]-T0[123]-PLAN.md +# The guard itself (review #88 item 8): the name of the plan to write is taken +# by something the plan lookup does not see (here an empty directory). +mkdir "$Y/M046-S03-T01-PLAN.md" +run "$R" skeletons --write +has "a taken name is kept, not written" "kept .ytstack/M046-S03-T01-PLAN.md: it exists" "$OUT" +eq "and nothing is written into it" "" "$(ls -A "$Y/M046-S03-T01-PLAN.md")" +rmdir "$Y/M046-S03-T01-PLAN.md"; rm -f "$Y"/M046-S0[23]-T0[123]-PLAN.md + +# a plan under milestones/M###/ (the nested layout) is found and written beside its slice plan +mkdir -p "$Y/milestones/M049" +roadmap M049 in-progress '- [ ] S01 -- nested'; mv "$Y/M049-ROADMAP.md" "$Y/milestones/M049/" +slice M049-S01 planned '- [ ] T01 -- nested in `src/n.sh`'; mv "$Y/M049-S01-PLAN.md" "$Y/milestones/M049/" +run "$R" skeletons +has "a nested slice is listed with its own directory" "M049-S01-T01 .ytstack/milestones/M049/M049-S01-T01-PLAN.md 1" "$OUT" +rm -rf "$Y/milestones" + +# ---- 2. pointer --------------------------------------------------------------- +echo "# pointer" +run "$R" pointer +eq "a pointer behind the newest milestone in progress: exit 10" 10 "$EC" +eq "names both and the first open slice" "pointer: behind -- current_milestone M044, active_slice S02; newest milestone in progress: M048, first open slice S01" "$OUT" +roadmap M048 done '- [x] S01 -- whole slice' +run "$R" pointer +eq "the newest in progress is the target, not a backlog or done milestone" "pointer: behind -- current_milestone M044, active_slice S02; newest milestone in progress: M046, first open slice S02" "$OUT" +cp "$Y/STATE.md" "$TMP/state.before" +run "$R" pointer --fix +eq "--fix: exit 0" 0 "$EC" +eq "--fix says what it changed" "fixed: current_milestone M044 -> M046, active_slice S02 -> S02, active_task T03 -> none" "$OUT" +S=$(cat "$Y/STATE.md") +has "current_milestone set" "current_milestone: M046" "$S" +has "active_task reset" "active_task: none" "$S" +hasnt "last_updated moved" "last_updated: 2026-11-01T10:00:00Z" "$S" +eq "the body is untouched" "$(sed -n '/^# State/,$p' "$TMP/state.before")" "$(sed -n '/^# State/,$p' "$Y/STATE.md")" +run "$R" pointer +eq "afterwards the pointer is ok" "pointer: ok -- current_milestone M046" "$OUT" +eq "and exits 0" 0 "$EC" +run "$R" pointer --fix +eq "--fix on an ok pointer changes nothing" "pointer: ok -- current_milestone M046" "$OUT" +# review #88 item 7: STATE.md without frontmatter, and keys that are missing +printf 'project: acme\nlast_updated: 2026-11-01T10:00:00Z\ncurrent_milestone: M044\nactive_slice: S01\nactive_task: T03\n\n# State\n\ncurrent_milestone: M044 is the old one\n' > "$Y/STATE.md" +run "$R" pointer --fix +eq "no frontmatter: the leading key lines are the pointer" "fixed: current_milestone M044 -> M046, active_slice S01 -> S02, active_task T03 -> none" "$OUT" +has "and are written" "current_milestone: M046 +active_slice: S02 +active_task: none" "$(cat "$Y/STATE.md")" +has "the body is untouched" "current_milestone: M044 is the old one" "$(cat "$Y/STATE.md")" +printf -- '---\nproject: acme\ncurrent_milestone: M044\nlast_updated: 2026-11-01T10:00:00Z\n---\n\n# State\n' > "$Y/STATE.md" +run "$R" pointer --fix +eq "missing keys are added and said so" "fixed: current_milestone M044 -> M046, active_slice (missing) -> S02, active_task (missing) -> none" "$OUT" +eq "inside the frontmatter" "---,project: acme,current_milestone: M046,last_updated:,active_slice: S02,active_task: none,---" \ + "$(sed -n '1,/^---$/p;' "$Y/STATE.md" | sed -n '1,7p' | sed 's/^last_updated:.*/last_updated:/' | tr '\n' ',' | sed 's/,$//')" +printf '# State\n\nnothing here\n' > "$Y/STATE.md"; cp "$Y/STATE.md" "$TMP/state.none" +run "$R" pointer --fix +eq "no pointer lines at all: refused" 1 "$EC" +has "with a reason" "STATE.md has no frontmatter and no pointer lines" "$OUT" +eq "and the file is unchanged" "$(cat "$TMP/state.none")" "$(cat "$Y/STATE.md")" +for m in M045 M046; do roadmap "$m" done '- [x] S01 -- x'; done +run "$R" pointer +eq "no milestone in progress: nothing to point at" "pointer: no milestone in progress" "$OUT" +eq "exit 0" 0 "$EC" + +# ---- 3. usage ----------------------------------------------------------------- +echo "# usage" +run "$R" sideways; eq "unknown command: 64" 64 "$EC" +run "$R" skeletons --all; eq "unknown option: 64" 64 "$EC" +run "$TMP/gone" skeletons; eq "-C to a missing directory: 64" 64 "$EC" +mkdir -p "$TMP/bare"; ( cd "$TMP/bare" && git init -q ) >/dev/null 2>&1 +run "$TMP/bare" skeletons; eq "no .ytstack: exit 1" 1 "$EC" + +echo "$PASS passed, $FAIL failed" +[ "$FAIL" -eq 0 ] diff --git a/tests/ytstack-risk.test.sh b/tests/ytstack-risk.test.sh index 81f2affc..8343e116 100644 --- a/tests/ytstack-risk.test.sh +++ b/tests/ytstack-risk.test.sh @@ -289,7 +289,17 @@ check_fails() { #