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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .ytstack/DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1218,3 +1218,24 @@ Plus: ops-layer split during the same session (yopstack created as own public re
**Chose:** A roadmap status `backlog` (frontmatter and the global ROADMAP column): planned, kept, not picked by `ytstack-frontier` while no milestone is current. Making it current sets `status: planned` and `current_milestone` again.

**Supersedes:** None. Extends the roadmap state values in `docs/ux/skill-structure.md`.

## 2026-11-15: New artifacts follow the directory a milestone already lives in (issue #70)

**Context:** Reading tolerated `milestones/`, `milestones/*/`, `backlog/` and `backlog/*/` since M018-S03, but every skill and hook wrote flat into `.ytstack/`. A consumer that moved 299 files of older milestones into `.ytstack/milestones/M###/` got the next plan or summary of such a milestone back at the top level, beside the moved ones.

**Options considered:**
- A) Keep writing flat and let `reconcile` move stragglers. Leaves the split after every task and needs a cleanup run per milestone.
- B) Move a milestone's files into `milestones/M###/` as soon as ytstack writes one. Moves user-owned files, which only `reconcile` may do, and changes this repository's own layout.
- C) Write where the milestone already lives: the directory that holds its roadmap, else any of its files, else flat.

**Chose:** C.

**Reason:** The person decided the layout by moving the files; ytstack follows it without moving anything. A milestone that lives flat, and every new milestone, stays flat, so nothing changes for projects that never moved files.

**How to apply:**
- One lookup in `hooks/lib/git-ctx.sh`: `yt_artifact_dir <yt_dir> <id>` for the directory, `yt_artifact_path <yt_dir> <file>` for one file (where it exists, else in that directory). No skill or hook builds a milestone path as `$YT_DIR/M###-...` any more.
- Skills that write or read a milestone's files print `ARTIFACT_DIR` and fall back to `YT_DIR` when the library is not reachable.
- A file of the milestone that already exists elsewhere (a summary that landed flat before this fix) is read and replaced where it is, not duplicated.
- `bin/ytstack-risk` counts `M###-*` files in those directories as process records, like the flat ones.

**Supersedes:** None. Narrows "Writing stays flat" of M018-S03 (`yt_find_artifacts`).
10 changes: 5 additions & 5 deletions .ytstack/spec/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sources:
- docs/ux/signal-format.md
- docs/statusline.md
- docs/ux/external-plans.md
verified_at: c5b405d
verified_at: db07481
---

# artifacts
Expand All @@ -36,7 +36,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory
- `yt_resolve_yt_dir` in `hooks/lib/git-ctx.sh` picks the directory: `<toplevel>/.ytstack` if it exists (project scope, tracked in git), otherwise `~/.ytstack/projects/<repo key>` (user scope), otherwise none. The repo key is a hash of the git common dir, so all worktrees of a repository share one user-scope directory.
- `init-project` asks for project, user or both and records the answer as `scope:` in the `PROJECT.md` frontmatter. `both` writes identical files to both directories; the resolver then reads the project one. `adopt-brownfield` always uses project scope.
- In project scope a linked worktree has its own copy of `.ytstack/` at its branch's state.
- Skills write a flat layout: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`.
- Skills write a flat layout by default: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`. A milestone whose files already live in a subdirectory keeps getting its new files there (issue #70). `yt_artifact_dir <yt_dir> <id>` names the directory: the one that holds `<prefix>-ROADMAP.md`, else the one that holds any `<prefix>-*` file, searched flat first, then in `milestones/`, `milestones/*/`, `backlog/`, `backlog/*/`; else the flat directory. The prefix is the id up to its first `-` (`M005` for `M005-S02-T01`, `OPS` for a backlog prefix). `yt_artifact_path <yt_dir> <file>` gives one file: where it exists, else in that directory. The skills that write or read a milestone's files print it as `ARTIFACT_DIR` (with `$_YT_DIR` as the fallback when the library is not reachable); `hooks/post-tool-use-bash` and `hooks/task-completed` write their summaries there. Skills and hooks that count or list a milestone's files read every layout, one file per name, so files that landed flat before the milestone moved count too. Nothing is moved, and a milestone that lives flat stays flat; `plan-milestone` counts moved milestones when it picks the next number.

### Files and writers

Expand Down Expand Up @@ -165,9 +165,9 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact
- Templates: `skills/init-project/SKILL.md` and `skills/adopt-brownfield/SKILL.md` (the core files, `codebase/`, `backlog/`), `skills/plan-milestone/SKILL.md`, `skills/slice-milestone/SKILL.md`, `skills/plan-task/SKILL.md`, `skills/summarize-task/SKILL.md`, `skills/quick-task/SKILL.md`, `skills/handoff-session/SKILL.md`.
- Cleanup: `skills/reconcile/SKILL.md`. States `dropped` and `shipped-informally`: `skills/reassess-roadmap/SKILL.md`.
- 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_state_base`, `yt_state_dir`, `yt_ensure_gitignore`.
- `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), `tests/skill-preambles.test.sh` (`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).

## How to verify

Expand All @@ -191,7 +191,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact
- 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: 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)"
- DECISIONS.md -- "2026-04-23: `.ytstack/` location is user-chosen (project vs user vs both)"
- 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)"
- DECISIONS.md -- "2026-05-31: active_slice is plan-task-owned and team-member-guarded (M012 / issue #21-RC1)"
- DECISIONS.md -- "2026-05-31: post-tool-use-bash is stub-once; summarize-task owns commit-to-task linking (M015 / issue #22)"
- 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)
Expand Down
4 changes: 2 additions & 2 deletions .ytstack/spec/checks-and-evals.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sources:
- docs/ux/signal-format.md
- docs/ux/external-plans.md
- docs/ux/upstream-feedback.md
verified_at: c5b405d
verified_at: db07481
---

# checks-and-evals
Expand Down Expand Up @@ -61,7 +61,7 @@ Everything that tells a contributor whether a change is acceptable: the static c

**`bin/ytstack-risk`: whether a change may merge without a person** (`docs/ux/review-policy-format.md`)

- `floor --base <sha> --head <sha>` 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.
- `floor --base <sha> --head <sha>` 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 <file>] [--pr <n> [--repo <owner/name>]] --base <sha> --head <sha> --author <worker>` 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 <dir>` writes hash and name of every image into the `MANIFEST` of an evidence directory.

Expand Down
2 changes: 1 addition & 1 deletion .ytstack/spec/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ paths:
- NOTICE
- hooks/lib/git-ctx.sh
- bin/ytstack-gstack-diff
verified_at: 8ca816a
verified_at: db07481
---

# dependencies
Expand Down
4 changes: 2 additions & 2 deletions .ytstack/spec/hooks-and-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sources:
- docs/statusline.md
- docs/pr-watch.md
- docs/kimi.md
verified_at: c5b405d
verified_at: db07481
---

# hooks-and-state
Expand All @@ -35,7 +35,7 @@ The lifecycle hooks under `hooks/` and the shared library `hooks/lib/git-ctx.sh`
- `yt_epoch` turns an ISO time into seconds with BSD `date -j`, GNU `date -d`, or, for BusyBox, `date -d` on the form `YYYY-MM-DD HH:MM:SS`.
- `yt_brownfield_signals` counts up to six signs of an existing codebase and names which file would feed which artifact. The comment above the function lists the counted signals and the hint-only ones.
- `yt_commit_ref_pattern` renders a task's commit pattern from `commit_ref_pattern` in `PREFERENCES.md`, or from the default. `yt_task_commits` lists commits whose subject matches it. When none match, it falls back to the commits on the current branch after the merge-base with the default branch, and reports which source it used.
- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. Writing stays flat.
- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. `yt_artifact_dir` and `yt_artifact_path` say where a milestone's files live and where its new ones go: the directory that already holds its roadmap or files, else flat ([artifacts.md](artifacts.md), "Location and scope"). `post-tool-use-bash`, `task-completed`, `stop`, `pre-tool-use-edit` and `session-start` find the milestone's files through them; `task-created` and `teammate-idle` list its slice plans in every layout through `yt_find_artifacts`, one per name, so a plan that landed flat before the milestone moved counts too.
- `yt_factory_notices` returns one line per factory tool that is off although the project would use it, from local files only: risk routing (`spec/` without `REVIEW.md` or without an area whose frontmatter allows `auto_merge: low|normal`, quotes allowed, read with `yt_fm`, the reader `bin/ytstack-risk` uses; while `merge_by` is `risk`), the PR watch on a GitHub `origin` (no line in `~/.ytstack/config` that turns the hook on, read as `hooks/pr-watch` does: any `pr_watch=on` line; or `on` with a heartbeat missing or 10 minutes old; `yt_pr_watch_heartbeat` reads `watch.sqlite3`, else the time of `worker.lock`), and `RUNTIME.md` without "Release" or "Signals" while deploy or signal evidence exists (`ytstack-runtime sections`). `merge_by: human|coordinator` and `pr_watch=off` are choices and stay silent. `yt_read_stdin` also sets `YT_SOURCE`.
- `yt_standing` lists the standing instructions in force from `.ytstack/standing/` (name, `given`, `scope`, tab separated), newest first by the time in the name (missing seconds count as `00`), without the entries another entry names in `supersedes`. It prints nothing without the directory; `STANDING.md` is read by the skills themselves.

Expand Down
8 changes: 4 additions & 4 deletions .ytstack/spec/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sources:
- docs/ux/skill-structure.md
- docs/ux/askuserquestion-format.md
- docs/ux/agent-structure.md
verified_at: b448b13
verified_at: db07481
---

# skills
Expand Down Expand Up @@ -42,9 +42,9 @@ Every native procedure and every wrapper starts its first shell block with the r
- `yt_git_ctx "$PWD"`: the checkout is where the shell runs. It yields the toplevel, whether this is a linked worktree, and a repo key (a hash of the git common dir, shared by all worktrees of a repository).
- `yt_resolve_yt_dir`: `<toplevel>/.ytstack` if it exists (project scope), otherwise `~/.ytstack/projects/<repo key>` (user scope), otherwise none.

Further lib functions the preambles call: `yt_prefs`, `yt_state_lint`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_brownfield_signals`, `yt_ensure_gitignore`, `yt_state_base`.
Further lib functions the preambles call: `yt_prefs`, `yt_state_lint`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_artifact_dir`, `yt_artifact_path`, `yt_brownfield_signals`, `yt_ensure_gitignore`, `yt_state_base`. A skill that writes or reads a milestone's files prints `ARTIFACT_DIR`, the directory the milestone already lives in (flat, or `milestones/M###/`, see [artifacts.md](artifacts.md)), and writes its new files there. A skill that counts or lists a milestone's files (`reassess-roadmap`, `retro`, `spawn-milestone-team`, `plan-eng-review`) reads every layout through `yt_find_artifacts`, one file per name. Shell parameters in skill text are written `${1}`, awk fields `$ 1`, because Kimi expands `$1` in loaded skill text.

When the host does not substitute `${CLAUDE_SKILL_DIR}`, the block's fallback branch resolves project scope only. Lib-only values then print as defaults or `unknown`, and user scope is not found.
When the host does not substitute `${CLAUDE_SKILL_DIR}`, the block's fallback branch resolves project scope only. Lib-only values then print as defaults or `unknown`, `ARTIFACT_DIR` is the flat directory, and user scope is not found.

A preamble prints `KEY: value` lines. The procedure refers to them by name. Each preamble prints the flags its own procedure uses; `HAS_YTSTACK` is the only one all of them print.

Expand Down Expand Up @@ -158,7 +158,7 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess
- `hooks/session-start`: injection of `using-ytstack` and the `minimal-code` pointer.
- `vendor/superpowers/skills/`: the inlined procedures.
- `bin/ytstack-check`: `check_skill`, `check_agent`, `check_cross_refs`, `check_resolver_contract`, `check_inline_leaks`, `check_gstack_adapted`.
- Tests: `tests/skill-preambles.test.sh` (every preamble in a main checkout and a linked worktree, preference flags, fallback branch), `tests/ytstack-check.test.sh` (checker rules), `tests/git-ctx.test.sh` (resolver, `yt_prefs`), `tests/hooks-readonly.test.sh` (injection size, `minimal_code` pointer).
- Tests: `tests/skill-preambles.test.sh` (every preamble in a main checkout and a linked worktree, preference flags, fallback branch, a milestone in `milestones/M###/`, `backlog/<dir>/` and split between there and flat), `tests/ytstack-check.test.sh` (checker rules), `tests/git-ctx.test.sh` (resolver, `yt_prefs`), `tests/hooks-readonly.test.sh` (injection size, `minimal_code` pointer).
- `evals/`: one trigger and outcome case per lifecycle skill, see `evals/README.md`.

## How to verify
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- **New artifacts follow the directory their milestone lives in** (issue #70):
when a milestone's roadmap or files already sit in
`.ytstack/milestones/M###/` (or a `backlog/<PREFIX>/` directory), new plans,
summaries, reviews and retros of that milestone are written there instead of
flat into `.ytstack/`. The lib functions `yt_artifact_dir` and
`yt_artifact_path` decide; skills print `ARTIFACT_DIR`. Flat stays the
default and nothing is moved. Readers that built flat paths (plan-task,
summarize-task, slice-milestone, reassess-roadmap, retro, the review and
execution skills, finish-branch, ship, spawn-milestone-team, grill,
handoff-session, and the stop, pre-tool-use-edit, session-start,
task-created, teammate-idle hooks) now find those files there too.
`plan-milestone` counts moved milestones when it numbers the next one, and
`ytstack-risk` counts their files as process records (at most one directory
below `milestones/` or `backlog/`). Readers that count or list a milestone's
files (reassess-roadmap, retro, spawn-milestone-team, task-created,
teammate-idle) also see files of that milestone that landed flat before it
moved.
- `teammate-idle` no longer fails on a slice plan without an open task (`grep
-c ... || echo 0` produced `0` twice and broke the sum).

## [0.11.0] - 2026-11-15

### Added
Expand Down
Loading
Loading