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
22 changes: 22 additions & 0 deletions .ytstack/DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,28 @@ Plus: ops-layer split during the same session (yopstack created as own public re

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

## 2026-11-15: PR watch bulk registration takes only your own ready PRs; bins are called through `YT_BIN` (issue #85)

**Context:** A coordinator ran `ytstack-pr-watch register --all-open`. It registered every open PR of the repository, including another author's do-not-merge prototype, which was then injected as `action_required` 967 times; single status blocks reached 8.4k characters and 34 PRs, re-sent whole whenever one line changed; `status` printed 1,176 watches of every repository and session. The same coordinator called the bins by the versioned cache path it had seen (`.../ytstack/0.7.0/bin/ytstack-frontier`), kept doing so after an update, and one call failed with exit 127.

**Options considered:**
- Bulk registration: A) only PRs whose author is the `gh` login, drafts and do-not-merge labels skipped, `--author`, `--include-drafts`, `--include-labelled` to widen; B) keep "every open PR" and rely on `pause`; C) filter by branch bindings of the session.
- Bins: D) print `YT_BIN=<bin of the running version>` in the `coordinate` preamble and at the end of the SessionStart context, and have the skill run bins as `"$YT_BIN/ytstack-<name>"`; E) a stable `~/.ytstack/bin` shim that points at the active version.

**Chose:** A and D.

**Reason:** A coordinator's lanes open their PRs under the same login, so the author is the cheapest fact that separates them from a colleague's, and one REST call (`gh api user`) gets it. B is what failed. C misses exactly the PRs `--all-open` exists for: those a session without hooks opened. `--author` adds to the login instead of replacing it, so widening never drops one's own PRs. For bins, D needs nothing outside the plugin and gives the coordinator one current value to copy instead of a path it remembers from an earlier context. E is a file in the user's home that some command must install and keep current across hosts and versions, and it would point at whatever version was active last, not at the one the session runs; ytstack never edits host settings or `PATH`, so a shim would still need a path to be called by.

**How to apply:**
- `register --pr N` registers one PR whatever its author or label; the filters apply to `--all-open` only, and every skipped PR is named with its reason.
- A do-not-merge label is any label that, lowercased with `-`, `_`, `/`, `:` and `.` read as spaces, contains the words "do not merge" or `dnm`. Logins compare without case and without a `[bot]` suffix. When the login cannot be read, only an explicit `--author` list is used (with a warning); without one the command stops.
- A rerun that skips a PR this session already watches pauses that watch and names it: the filter exists to stop such reports, and `resume` undoes it.
- The status block lists changed lines, `- N unchanged`, and one last `closed` line for a PR of the previous block (a merge without a bot finding has no other report); a PR `action_required` without a head or status change for 24 hours (NULL `changed_at` counts as older) gets one `pause` suggestion per stretch, remembered apart from the block fingerprint so SessionStart does not repeat it. `status` shows the current session and repository (compared without case) unless `--all`.
- The SessionStart line comes on every source but only where it still fits under the injection guard: this repository's injection sits within about 50 characters of it with a long Next action, and the excerpt matters more. The `coordinate` preamble is the source that always prints it. A session started before an update runs the old version's hooks, so after an update the line is renewed by reloading the skill (the version notice asks for that), not by the hook.
- A skill that runs ytstack bins over a long session names them through `YT_BIN`; a short skill keeps `${CLAUDE_SKILL_DIR}/../../bin`, which the host substitutes when it loads the skill.

**Supersedes:** None. Narrows `register --all-open` of "2026-11-14: PR watch ships inside ytstack as an optional, opt-in tool" (issue #54).

## 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.
Expand Down
2 changes: 1 addition & 1 deletion .ytstack/spec/checks-and-evals.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Everything that tells a contributor whether a change is acceptable: the static c
- Plain bash, no framework. A suite prints one line per assertion and ends with its pass and fail count; fixtures live in `mktemp` directories. The comment at the top of each file states the contract it pins.
- `tests/run-all.sh` runs every suite from a neutral temporary directory and prints `PASS` or `FAIL` per suite with that suite's last line. It stops at the first failing suite, prints up to ten of its `FAIL` lines and exits 1. The last line is `ALL SUITES PASSED` or `SUITE FAILURE`. `--linux` runs the same inside an `alpine/git` container with the repository mounted read-only; without a working Docker daemon it prints a skip line and exits 0.
- `tests/ytstack-check.test.sh` tests the checker on a copy of the plugin tree. `tests/ytstack-spec.test.sh` tests `bin/ytstack-spec` on fixture repositories, one case per rule. `tests/ytstack-brief.test.sh` does the same for `bin/ytstack-brief` and compares the rendered contract with the real `skills/minimal-code/SKILL.md`. `tests/evidence-rule.test.sh` pins the evidence reuse rule: the verifier, the dispatcher and the skills area reuse a PASS only for the same commit, and its git fixture shows why (an unchanged planned file, a changed imported helper, a failing check).
- `tests/pr-watch.test.sh` runs the PR watch engine's `unittest` suite (`tests/pr_watch/`, standard library, `gh` and the Codex daemon mocked) and then shell cases for `hooks/pr-watch` (off, on, malformed input), `bin/ytstack-pr-watch` (enable/disable, install-worker and migrate plans, migrate copy, the worker launcher's engine choice; `register --all-open` is covered in `tests/pr_watch/test_register_all.py`, the `claude:` qualification of a bare session id in `test_session_spelling.py`, the handover to a successor session in `test_handover.py`, skipped checks, a moved head (with `remote_head` against a real temporary repository), the once-per-change status block and the merge suggestion in `test_under_load.py`) under a temporary HOME. The resolver rule of `bin/ytstack-check` exempts `hooks/pr-watch` by name (`_HOOKS_WITHOUT_RESOLVER`).
- `tests/pr-watch.test.sh` runs the PR watch engine's `unittest` suite (`tests/pr_watch/`, standard library, `gh` and the Codex daemon mocked) and then shell cases for `hooks/pr-watch` (off, on, malformed input), `bin/ytstack-pr-watch` (enable/disable, install-worker and migrate plans, migrate copy, the worker launcher's engine choice; `register --all-open` with its author, draft and label filters is covered in `tests/pr_watch/test_register_all.py`, the changed-lines block, the pause suggestion and the `status` scope in `test_scope.py`, the `claude:` qualification of a bare session id in `test_session_spelling.py`, the handover to a successor session in `test_handover.py`, skipped checks, a moved head (with `remote_head` against a real temporary repository), the once-per-change status block and the merge suggestion in `test_under_load.py`) under a temporary HOME. The resolver rule of `bin/ytstack-check` exempts `hooks/pr-watch` by name (`_HOOKS_WITHOUT_RESOLVER`).

**Python host tests: `tests/*_test.py`**

Expand Down
4 changes: 3 additions & 1 deletion .ytstack/spec/hooks-and-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ W8 and W9 are prompts for `ytstack:reconcile`, which moves history out with cons

Every hook except `pr-watch` sources the library and resolves from the payload `cwd`. Every hook except `session-start` and `pr-watch` exits 0 silently when no `.ytstack` directory resolves.

`pr-watch` (SessionStart, UserPromptSubmit, PreToolUse and PostToolUse on `Bash|mcp__.*create_pull_request.*`; for Codex also Stop, via `bin/ytstack-codex hook pr-watch`) is the opt-in PR watch: it exits 0 with no output and without starting Python unless `~/.ytstack/config` has `pr_watch=on`, then hands the payload to `tools/pr-watch/pr-watch.py hook`. It works for any repository, with or without `.ytstack`, and fails open (an engine error is one stderr line, exit 0). Engine, state (`~/.ytstack/pr-watch/`), worker and migration are described in `docs/pr-watch.md`; `bin/ytstack-check` exempts this hook from the resolver rule by name. For Claude Code the UserPromptSubmit output is injected only when a status line changed since the last injection in that session (fingerprint in `meta` key `surface:<session>`, reset on SessionStart) or a notice is pending; a `git push` the PostToolUse hook sees in a bound worktree sets `pushed_at` on that branch's watch when `refs/remotes/origin/<branch>` (without one, `refs/heads/<branch>`) then differs from the watched head, which shows `head moved` and makes the worker read it next tick (`tests/pr_watch/test_under_load.py`). A merge the worker observes queues one notice per PR when the watch saw a bot finding on it (outbox key `merged:<repo>:<n>`, a fixed template that names `ytstack:review-lessons`); it is delivered without the fresh GitHub read other notices get and is never cancelled by a later read (`tests/pr_watch/test_merge_notice.py`). `handover --from <session> [--to <session>]` moves a session's watches, its undelivered notices (not a Codex notice with a `dispatch_id`), bindings and candidates to its successor and writes `meta` key `handover:<from>`; `register` follows that chain, so a PR a subagent of the old session opens later goes to the successor, and discovery counts a binding of the old session as its successor (no "Multiple sessions" ambiguity). A bare `--from`/`--to` id is qualified to `claude:<id>` when only that is stored, and a bare `--to` naming nothing follows a Claude `--from` (`tests/pr_watch/test_handover.py`).
`pr-watch` (SessionStart, UserPromptSubmit, PreToolUse and PostToolUse on `Bash|mcp__.*create_pull_request.*`; for Codex also Stop, via `bin/ytstack-codex hook pr-watch`) is the opt-in PR watch: it exits 0 with no output and without starting Python unless `~/.ytstack/config` has `pr_watch=on`, then hands the payload to `tools/pr-watch/pr-watch.py hook`. It works for any repository, with or without `.ytstack`, and fails open (an engine error is one stderr line, exit 0). Engine, state (`~/.ytstack/pr-watch/`), worker and migration are described in `docs/pr-watch.md`; `bin/ytstack-check` exempts this hook from the resolver rule by name. For Claude Code the UserPromptSubmit output is injected only when a status line changed since the last injection in that session (one fingerprint per PR line in `meta` key `surface:<session>`, reset on SessionStart) or a notice is pending, and it lists only the changed lines plus `- N unchanged`, and one `closed (merged)` / `closed` line for a watch of the last block that closed since; an `action_required` watch that is not paused and whose `changed_at` is 24 h old or NULL gets one `pause` suggestion per stretch (`meta` key `pause-hint:<session>`, PR to `changed_at`, not reset on SessionStart) (`tests/pr_watch/test_scope.py`); a `git push` the PostToolUse hook sees in a bound worktree sets `pushed_at` on that branch's watch when `refs/remotes/origin/<branch>` (without one, `refs/heads/<branch>`) then differs from the watched head, which shows `head moved` and makes the worker read it next tick (`tests/pr_watch/test_under_load.py`). A merge the worker observes queues one notice per PR when the watch saw a bot finding on it (outbox key `merged:<repo>:<n>`, a fixed template that names `ytstack:review-lessons`); it is delivered without the fresh GitHub read other notices get and is never cancelled by a later read (`tests/pr_watch/test_merge_notice.py`). `handover --from <session> [--to <session>]` moves a session's watches, its undelivered notices (not a Codex notice with a `dispatch_id`), bindings and candidates to its successor and writes `meta` key `handover:<from>`; `register` follows that chain, so a PR a subagent of the old session opens later goes to the successor, and discovery counts a binding of the old session as its successor (no "Multiple sessions" ambiguity). A bare `--from`/`--to` id is qualified to `claude:<id>` when only that is stored, and a bare `--to` naming nothing follows a Claude `--from` (`tests/pr_watch/test_handover.py`). `register --all-open` takes only PRs whose author is the `gh` login or a login of `--author` (case-insensitive, a `[bot]` suffix ignored; without a readable login only `--author`, else an error), and skips drafts and labels that contain the words "do not merge" or `dnm` after `-_/:.` read as spaces unless `--include-drafts` / `--include-labelled` (which, like `--author`, need `--all-open`), naming each skipped PR with its reason and pausing a skipped PR this session already watches (`tests/pr_watch/test_register_all.py`). `status` is scoped to the current session and the `origin` repository of the working directory (`--session`, `--repo` compared without case; `--all` for everything; what does not resolve does not narrow) and prints the `scope` it used; `health` stays whole.

| Hook | Event | Reads from the payload | Effect | Exit |
|---|---|---|---|---|
Expand Down Expand Up @@ -93,6 +93,7 @@ Every hook except `pr-watch` sources the library and resolves from the payload `
- `.ytstack` without `STATE.md`: a one-line repair notice.
- Otherwise a state block, in this order: scope, project, pointer, last update, working tree with the linked-worktree flag, `.ytstack` path, a Next action excerpt, the three newest summary names, a notice when more than one milestone roadmap is `in-progress`, the manual and the latest automatic handoff, a lifecycle hint for a finished slice or a finished milestone without retro, up to five STATE lint findings, the minimal-code line when `minimal_code` is on, a "Factory tools" block with the lines of `yt_factory_notices` (only when the payload `source` is `startup` or `clear`, or absent on a SessionStart, so it is said once per session without a file), and a closing line that names the files as the source of truth. When `spec/SPEC.md` exists, the closing line names it as the place for what applies now.
- Cap: the hook measures the injection without the host context. Above the guard threshold in the script, which sits just under the host's 10,000-character limit, it cuts the Next action excerpt to what still fits and marks the cut; when less than a useful rest would remain, it replaces the excerpt with a one-line note. Next, the Factory tools block shrinks to one line that counts them and names `bin/ytstack-upkeep`. If the text is still above the threshold, it warns on stderr and emits the text anyway. Nothing else is dropped.
- Last, with a state block and on every source (also resume and compaction): one line `YT_BIN=<the running plugin's bin/, canonical>`, the directory skills run ytstack's bins from as `"$YT_BIN/ytstack-<name>"` (issue #85). It is added only when it still fits under the guard, so it never costs the Next action excerpt; the `coordinate` preamble prints it too.
- Output is the existing Claude-compatible JSON envelope by default. `YTSTACK_HOOK_FORMAT=plain` emits the raw context instead. Kimi's helper uses this mode only to prepare pending context, not as a claim that SessionStart stdout is consumed.

### Kimi pending bridge
Expand Down Expand Up @@ -176,6 +177,7 @@ python3 -m unittest discover -s tests -p 'kimi_lifecycle_test.py' -v
## Decisions that apply now

- DECISIONS.md -- "2026-11-15: SessionStart stays read-only; factory-tool notices are said on startup only, the plugin version is recorded by a prompt hook (M031-S03)"
- DECISIONS.md -- "2026-11-15: PR watch bulk registration takes only your own ready PRs; bins are called through `YT_BIN` (issue #85)"
- DECISIONS.md -- "2026-11-14: Kimi uses native plugin bootstrap and pending lifecycle context (M020)" (plain output is explicit, the helper owns pending context and consumes it once)
- DECISIONS.md -- "2026-11-13: Whether a person looks at a change is decided per change: a floor from the diff, the class an independent reviewer states, a ceiling per area, lenses per kind of change (M025)" (`merge_by` and `evidence_dir` in `yt_prefs`)
- DECISIONS.md -- "2026-11-07: Hooks never write relative to CLAUDE_PROJECT_DIR; volatile state lives out-of-tree, per session and per worktree"
Expand Down
Loading
Loading