diff --git a/.ytstack/DECISIONS.md b/.ytstack/DECISIONS.md index a709b45f..fd1c4c11 100644 --- a/.ytstack/DECISIONS.md +++ b/.ytstack/DECISIONS.md @@ -1061,3 +1061,26 @@ Plus: ops-layer split during the same session (yopstack created as own public re **How to apply:** SessionStart and PostCompact prepare pending context; UserPromptSubmit emits and removes it at most once. PreCompact and SessionEnd delegate to the shared scripts. Document the tested versions and host limits, including headless SessionEnd #4380, interactive Ctrl+C-twice close and unverified web close paths. Do not add a Kimi `extra_skill_dirs` requirement or external gstack install. **Supersedes:** The user-level setup proposed in issue #30. The 2026-11-09 shared-source rule and the 2026-11-14 in-tree gstack adaptations remain in force. + +--- + +## 2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57) + +**Context:** In a busy repository almost every coordinator pull request appended a line to `STANDING.md`. The appends land at the end of the same file, so parallel pull requests conflicted there, and a private repository on the Team plan has no merge queue to absorb it. A consumer (meinKontext) had already moved its instructions to `.ytstack/standing/-.md` with the frontmatter `given`, `scope`, `supersedes` and kept `STANDING.md` as an index, while `coordinate` still read only `STANDING.md`. + +**Options considered:** +- A) Keep the single file and rely on a merge queue or on rebasing each pull request. +- B) One file per instruction in `.ytstack/standing/`, the shape `questions/` already has, with `STANDING.md` still read where it exists. +- C) One file per instruction and `STANDING.md` rendered from them on demand. + +**Chose:** B, in the consumer's format, so that its files pass unchanged. Name `-.md` (UTC, seconds optional, lowercase slug). Frontmatter `given` (ISO UTC in the minute of the name), `scope` (not empty), `supersedes` (empty, or the name of an earlier entry without `.md`). The body is the instruction. An entry is never edited; a replacement is a new file that supersedes the old one. + +**Reason:** Two pull requests that each add an instruction add two files and cannot conflict. Superseding by name keeps the history that a struck-through line kept, without editing an old line. A rendered `STANDING.md` (C) would bring the conflict back on every render. + +**How to apply:** +- Readers (`coordinate`, `finish-lane`, `signal-intake`, `handover-step`, `review-lessons`) take the entries newest first and skip every superseded one (`yt_standing` in `hooks/lib/git-ctx.sh`), and still read `STANDING.md` where it exists, also when it is only an index. +- `coordinate` writes a new instruction as a new file, also in a project that has neither form yet. It appends to `STANDING.md` only in a project that has `STANDING.md` and no `standing/` directory. +- `bin/ytstack-risk` routes a change under `.ytstack/standing/` to a person, like `STANDING.md`. +- `bin/ytstack-check --standing []` validates the names, the frontmatter and that every `supersedes` names an earlier existing entry; the full run checks the plugin's own directory. + +**Supersedes:** None. Extends the 2026-11-13 coordinator-mode entry: `STANDING.md` is no longer the only place for standing instructions. diff --git a/.ytstack/spec/artifacts.md b/.ytstack/spec/artifacts.md index 5f2f1ef8..cdf7a49a 100644 --- a/.ytstack/spec/artifacts.md +++ b/.ytstack/spec/artifacts.md @@ -19,7 +19,7 @@ sources: - docs/ux/runtime-format.md - docs/ux/signal-format.md - docs/statusline.md -verified_at: 08dab40 +verified_at: 54a25e7 --- # artifacts @@ -65,7 +65,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory | `HANDOFF.md` | `handoff-session` | the user; no hook writes it | | `LANES.md` | `bin/ytstack-frontier claim` (first claim) | `bin/ytstack-frontier` (`set`, `release`), one row per call; called by `spawn-milestone-team`, `coordinate`, `finish-lane` | | `questions/Q###-.md` | `bin/ytstack-questions new` (from `coordinate`, `reassess-roadmap`, `review-lessons` (a proposed line for a role file, `blocks:` the finding), and from `bin/ytstack-upkeep --question`, which keeps at most one open or asked file titled `Upkeep found ...`) | the agent fills Context, Options, Recommendation; `ask` and `answer` change the state; the answer text is the human's | -| `STANDING.md` | `coordinate`, when the human gives an instruction that holds beyond the task | appended; an overtaken line is struck through and dated, not removed | +| `standing/-.md`, `STANDING.md` | `coordinate`, when the human gives an instruction that holds beyond the task: a new file with `given`, `scope`, `supersedes` (`docs/ux/coordinator-format.md`); appended to `STANDING.md` only where no `standing/` exists | an entry is never edited; a newer one supersedes it by name, readers skip it; `STANDING.md` alone stays valid, also as an index, and is read beside the directory | | `handover/-.sh` and its receipt | `handover-step` through `bin/ytstack-handover new`; the receipt by the script when the human runs it | a script that ran is not edited | | `retro/LANES-.md` | `lane-retro` | appended on a second run of the same day | | `archive//`, `archive/INDEX.md`, `RECONCILE-.md` | `reconcile` | -- | @@ -141,7 +141,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - No state lives in `~/.ytstack/.` sentinel files. An ask-once answer is recorded in the artifact it concerns (`docs/ux/skill-structure.md`, "Ask-once answers"). - `RUNTIME.md` written by `adopt-brownfield` records environment variable names, never values. The three sections of `RUNTIME.md` hold names of credentials, never values; `bin/ytstack-runtime check` fails on a token-looking string there. In those sections only list lines are read; a section without a list line counts as absent. - The commands under "Release" and "Signals" of `RUNTIME.md` only read. No skill and no script runs a command that changes a target; a mitigation is a handover script a person runs. -- A change to `spec/REVIEW.md`, `DECISIONS.md`, `STANDING.md`, `PREFERENCES.md`, an instruction file, the frontmatter of an area file (a `verified_at` stamp on its own excepted) or its sections "Invariants and security boundaries" and "Decisions that apply now" always goes to a person (`bin/ytstack-risk floor`). +- A change to `spec/REVIEW.md`, `DECISIONS.md`, `STANDING.md`, a file under `standing/`, `PREFERENCES.md`, an instruction file, the frontmatter of an area file (a `verified_at` stamp on its own excepted) or its sections "Invariants and security boundaries" and "Decisions that apply now" always goes to a person (`bin/ytstack-risk floor`). - `## Decisions` of an incident record holds only what a person ordered, in own words. ## Error behavior @@ -190,6 +190,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - 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)" - 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-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)" diff --git a/.ytstack/spec/checks-and-evals.md b/.ytstack/spec/checks-and-evals.md index ed8984a4..f0b411e2 100644 --- a/.ytstack/spec/checks-and-evals.md +++ b/.ytstack/spec/checks-and-evals.md @@ -26,7 +26,7 @@ sources: - docs/ux/review-policy-format.md - docs/ux/runtime-format.md - docs/ux/signal-format.md -verified_at: 1b7bfc8 +verified_at: 851b2f4 --- # checks-and-evals @@ -40,6 +40,7 @@ Everything that tells a contributor whether a change is acceptable: the static c **`bin/ytstack-check`: static contracts** - A Python script on the standard library. It finds the plugin root by walking up to `.claude-plugin/plugin.json`; an optional path argument sets where it starts. +- `check_standing` validates `.ytstack/standing/` (`docs/ux/coordinator-format.md`): the name `-.md` with a date and time that exist, `given` as an existing ISO UTC time in the minute of the name, a `scope`, a body, and a `supersedes` that names an earlier existing entry (missing seconds count as `00`). The full run checks the plugin's own directory; `--standing []` runs only this check in any project with `.ytstack/`, resolved through `hooks/lib/git-ctx.sh` like the preambles (user scope included), and needs no plugin root (exit 0 or 1). - It reads `skills/*/SKILL.md`, `agents/*.md`, the scripts in `hooks/`, both manifests in `.claude-plugin/` and this repository's own `.ytstack/spec/`. One function per contract: `check_skill`, `check_agent`, `check_cross_refs`, `check_vendor_sibling_refs`, `check_resolver_contract`, `check_inline_leaks`, `check_gstack_adapted`, `check_spec`, `check_keeping_block`. Those functions are the complete rule list; the two groups below summarize them. - `check_spec` runs `bin/ytstack-spec lint` and `drift` on the plugin root and is skipped when the tree has no `.ytstack/spec/`. A format error is a failure; an area whose paths changed after its description is a warning to look. `check_keeping_block` fails when the "Keeping this true" block in `skills/init-project/SKILL.md` or `skills/adopt-brownfield/SKILL.md` differs from the one in `docs/ux/spec-format.md`. - Failures (`[fail]`): skill frontmatter missing, `name` different from the directory, no description or one over the length limit; a procedure skill without `## Checklist` or `## Terminal State`; an agent file that breaks `docs/ux/agent-structure.md` (required fields, examples, existing `ytstack:` skills, hard line limit); a role named in `skills/spawn-milestone-team/SKILL.md` without `agents/.md`; a wrapper naming a vendored `SKILL.md` that does not exist; a banned shell pattern (`_BANNED`) in a skill or hook; a preamble or hook that does not source `hooks/lib/git-ctx.sh`; inlined vendor text without a covering `## Namespace note`; an adapted gstack skill without `metadata.upstream`, with a gstack runtime reference, a symlink or an em-dash. @@ -173,10 +174,10 @@ Run from the repository root. - `bash tests/run-all.sh` -- pass: exit 0, one `PASS` line per file in `tests/*.test.sh`, last line `ALL SUITES PASSED`. - `python3 -m unittest discover -s tests -p 'codex*_test.py'` -- pass: last line `OK`. - `python3 -m unittest discover -s tests -p 'kimi_plugin_test.py' -v` and the same pattern for `kimi_lifecycle_test.py` -- pass: two and nine tests, each `OK`. -- `python3 -m unittest discover -s tests -p 'kimi_live_test.py' -v` -- seven native tests on a machine with Kimi; local 2.5.3 and official Linux 2.6.2 each passed without skips at `verified_at`. +- `python3 -m unittest discover -s tests -p 'kimi_live_test.py' -v` -- seven native tests on a machine with Kimi; local 2.5.3 and official Linux 2.6.2 each passed without skips at `1b7bfc8`. - `claude plugin validate .` -- pass: `✔ Validation passed`, exit 0. -Not covered by these checks: `claude plugin eval` (costs money). `bash tests/run-all.sh --linux` (Docker) also passed all 26 suites from an export of `verified_at`. +Not covered by these checks: `claude plugin eval` (costs money). `bash tests/run-all.sh --linux` (Docker) also passed all 26 suites from an export of `1b7bfc8`. ## Decisions that apply now @@ -187,7 +188,7 @@ Not covered by these checks: `claude plugin eval` (costs money). `bash tests/run - 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`. - 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: 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. +- 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`. - 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)" - DECISIONS.md -- "2026-11-07: Hooks never write relative to CLAUDE_PROJECT_DIR; volatile state lives out-of-tree, per session and per worktree". Source of the banned shell patterns and the shared-resolver rule in the checker. diff --git a/.ytstack/spec/dependencies.md b/.ytstack/spec/dependencies.md index 227f7648..6c1a3369 100644 --- a/.ytstack/spec/dependencies.md +++ b/.ytstack/spec/dependencies.md @@ -7,7 +7,7 @@ paths: - NOTICE - hooks/lib/git-ctx.sh - bin/ytstack-gstack-diff -verified_at: 1ae7f2c +verified_at: 851b2f4 --- # dependencies diff --git a/.ytstack/spec/hooks-and-state.md b/.ytstack/spec/hooks-and-state.md index f747fddf..10fd04ec 100644 --- a/.ytstack/spec/hooks-and-state.md +++ b/.ytstack/spec/hooks-and-state.md @@ -10,7 +10,7 @@ sources: - docs/statusline.md - docs/pr-watch.md - docs/kimi.md -verified_at: 08dab40 +verified_at: 851b2f4 --- # hooks-and-state @@ -36,6 +36,7 @@ The lifecycle hooks under `hooks/` and the shared library `hooks/lib/git-ctx.sh` - `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_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. ### STATE lint and progress block diff --git a/.ytstack/spec/skills.md b/.ytstack/spec/skills.md index 74c73c41..f70076d0 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: 1b7bfc8 +verified_at: 54a25e7 --- # skills @@ -105,7 +105,7 @@ No other skill reads the flag. Formats: `docs/ux/coordinator-format.md`. The four skills below are for the session that owns a plan and delegates all of it; none of them writes product code. -- `coordinate` is a loop with a fixed order: start from `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`, with the PR watch on (flag set and a worker heartbeat under 10 minutes old) register the repository's open pull requests to itself as their owning session (`ytstack-pr-watch register --all-open` without `--session`, at the start and after every restart) and otherwise poll through `bin/ytstack-watch`, ask one question at a time from a question file, write a standing instruction down when it is given, stop a lane that failed verification twice or needs a third review, and rotate through a handoff after the first compaction. +- `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`, with the PR watch on (flag set and a worker heartbeat under 10 minutes old) register the repository's open pull requests to itself as their owning session (`ytstack-pr-watch register --all-open` without `--session`, at the start and after every restart) and otherwise poll through `bin/ytstack-watch`, ask one question at a time from a question file, write a standing instruction down when it is given (a new file in `standing/`; `STANDING.md` only where no `standing/` exists), stop a lane that failed verification twice or needs a third review, and rotate through a handoff after the first compaction. - `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: the one skill 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. 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. @@ -196,5 +196,5 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess - 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: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)" +- 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)" - 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)" diff --git a/CHANGELOG.md b/CHANGELOG.md index 765c8b44..9c809a1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- **Standing instructions as one file each** (issue #57): what you asked for + once and for all can live in `.ytstack/standing/`, one file per instruction + named `-.md`, with `given`, `scope` and `supersedes` + in its frontmatter. Two pull requests that each add an instruction no + longer conflict over the end of `STANDING.md`. `coordinate` (0.3.0) writes + new instructions there and replaces one with a newer file that supersedes + it; `coordinate`, `finish-lane`, `signal-intake`, `handover-step` and + `review-lessons` read the entries newest first and skip superseded ones. + `STANDING.md` alone keeps working and is still read next to the directory, + also as a short index. `ytstack-risk` sends a change under + `.ytstack/standing/` to a person, and `ytstack-check --standing` checks the + names, the frontmatter and that every `supersedes` names an earlier entry. + ### Changed - **The PR watch stays readable under load.** With many open pull requests diff --git a/QUICKSTART.md b/QUICKSTART.md index 7850249f..a7659925 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -235,7 +235,7 @@ Agent fires `ytstack:coordinate`. It writes no product code. What it keeps, it k - `.ytstack/LANES.md` -- one row per delegated lane (who holds it, branch, pull request, reviewed commit, round, next action). `bin/ytstack-frontier` lists what may start: open, unblocked (`**Blocked by:**` in the slice plans) and unclaimed. A lane is claimed before it is dispatched. - `.ytstack/questions/` -- one file per question for you, with context, options and a recommendation. You get one at a time, as late as the work allows, and never the same one twice. -- `.ytstack/STANDING.md` -- what you ask for once and for all ("status only at slice boundaries") is written down when you say it. +- `.ytstack/standing/` -- what you ask for once and for all ("status only at slice boundaries") is written down when you say it, one file per instruction, so parallel pull requests do not conflict over it. A project that keeps `.ytstack/STANDING.md` alone keeps working. - A finished lane goes through `ytstack:finish-lane`: commit, push, pull request, review pinned to the commit the host shows (the reviewer states the risk class and the invariants the change touches), the lenses your `.ytstack/spec/REVIEW.md` requires for that kind of change, the route, gates read from the host, merge at the reviewed commit, then the release watch when `RUNTIME.md` has a "Release" section. Under `merge_by: risk` (the default) the coordinator merges only when `bin/ytstack-risk route` says `unattended`; otherwise you merge and get the reasons. A project with no `auto_merge` in its area files sends everything to you. `merge_by: human` sends everything to you anyway. - A step only you may perform (a production action, a check in a GUI) arrives as one script: `bash .ytstack/handover/-.sh`. It checks first, asks before every change and leaves a receipt. diff --git a/README.md b/README.md index 1cb451b0..de9d8fb9 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ Milestone states are data, not prose: `planned`, `in-progress`, `done`, `dropped | `ytstack:visual-review` | the lens reviewer of a user interface change: starts the product at the reviewed commit, operates it in a browser, its own screenshots against your guidelines; `not run` when it cannot, never a pass | | `ytstack:handover-step`, `bin/ytstack-handover` | a step only you may perform arrives as one staged script with read-only checks, a confirmation before every change and a receipt; the agent checks it and never runs it | | `.ytstack/questions/`, `bin/ytstack-questions` | one file per question for you, asked once, decision-ready | -| `.ytstack/STANDING.md` | what you asked for once and for all, written down when you say it | +| `.ytstack/standing/`, `bin/ytstack-check --standing` | what you asked for once and for all, written down when you say it: one file per instruction, a newer one supersedes an older one by name; `.ytstack/STANDING.md` alone stays valid | | `bin/ytstack-watch` | polls pull requests outside the model and prints a line only when something changed; `release --commit ` follows a merged commit until the target serves it and stays healthy, and prints one receipt | | `ytstack:lane-retro` | samples finished lanes; a mechanical mistake becomes a check that replaces an instruction line | | `bin/ytstack-upkeep` | one read-only run over `.ytstack/` that lists what needs a look (spec, STATE, gates, questions, lanes, runtime, review policy); `--question` leaves one question file. On a schedule: [`docs/recipes/recurring-upkeep.md`](./docs/recipes/recurring-upkeep.md) | diff --git a/bin/ytstack-check b/bin/ytstack-check index d4baafa0..48cf6438 100755 --- a/bin/ytstack-check +++ b/bin/ytstack-check @@ -6,6 +6,8 @@ Run from the plugin root (or pass path): bin/ytstack-check /path/to/ytstack bin/ytstack-check --strict # warnings become failures bin/ytstack-check --quiet # only print on failure + bin/ytstack-check --standing [] + # only .ytstack/standing/ of any project Exit codes: 0 = pass, 1 = fail, 2 = warnings only (non-strict). @@ -750,6 +752,148 @@ def check_keeping_block(root): return fails, [] +# ---------- check: standing instructions, one file per entry (issue #57) ---------- + +_STANDING_NAME = re.compile(r"^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})?Z-[a-z0-9]+(?:-[a-z0-9]+)*\.md$") +_STANDING_GIVEN = re.compile(r"^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z$") + + +def _fm_scalar(fm, key): + """A one-line frontmatter value without quotes; "" when absent or empty, + None when the value is a list.""" + v = fm.get(key, "") + if isinstance(v, list): + return "" if not v else None + v = v.strip() + if len(v) >= 2 and v[0] == v[-1] and v[0] in "\"'": + v = v[1:-1].strip() + return v + + +def _standing_time(groups): + """(year, month, day, hour, minute, second-or-None) -> a sortable + YYYYMMDDHHMMSS key (missing seconds count as 00), or None when the date + or time does not exist (month 13, February 30, hour 24, minute 60).""" + import datetime + y, mo, d, h, mi, s = (int(g) if g is not None else 0 for g in groups) + try: + datetime.datetime(y, mo, d, h, mi, s) + except ValueError: + return None + return f"{y:04d}{mo:02d}{d:02d}{h:02d}{mi:02d}{s:02d}" + + +def check_standing(yt_dir): + """`.ytstack/standing/-.md`, one standing instruction + per file (docs/ux/coordinator-format.md). Each entry has the frontmatter + `given` (UTC, the same minute as its name), `scope` and optionally + `supersedes` (the name of an earlier entry, `.md` optional) and the + instruction as its body. README.md is allowed as a note for people. + Skipped when the directory does not exist.""" + fails = [] + sdir = Path(yt_dir) / "standing" + if not sdir.is_dir(): + return fails, [] + entries = {} + for p in sorted(sdir.iterdir()): + if not p.is_file() or not p.name.endswith(".md") or p.name == "README.md": + continue + rel = f".ytstack/standing/{p.name}" + nm = _STANDING_NAME.match(p.name) + if not nm: + fails.append(f"{rel}: name is not -.md (UTC time, lowercase slug)") + continue + key = _standing_time(nm.groups()) + if key is None: + fails.append(f"{rel}: the time in the name is not a real UTC date and time") + continue + fm, body = parse_frontmatter(p) + if fm is None: + fails.append(f"{rel}: no frontmatter (given, scope, supersedes)") + continue + entries[p.name[:-3]] = (rel, fm, key) + given = _fm_scalar(fm, "given") or "" + gm = _STANDING_GIVEN.match(given) + if not gm: + fails.append(f"{rel}: given '{given}' is not an ISO UTC time (YYYY-MM-DDTHH:MMZ or with seconds)") + elif _standing_time(gm.groups()) is None: + fails.append(f"{rel}: given {given} is not a real UTC date and time") + elif gm.groups()[:5] != nm.groups()[:5]: + fails.append(f"{rel}: given {given} and the time in the name differ (newest first reads the name)") + if not _fm_scalar(fm, "scope"): + fails.append(f"{rel}: scope is empty (where the instruction applies)") + if not body.strip(): + fails.append(f"{rel}: no instruction below the frontmatter") + for name, (rel, fm, key) in sorted(entries.items()): + sup = _fm_scalar(fm, "supersedes") + if sup is None: + fails.append(f"{rel}: supersedes names one entry, not a list") + continue + if sup in ("", "none", "None", "-"): + continue + if sup.endswith(".md"): + sup = sup[:-3] + if sup == name: + fails.append(f"{rel}: supersedes names the entry itself") + elif sup not in entries: + fails.append(f"{rel}: supersedes '{sup}' names no entry in .ytstack/standing/") + elif entries[sup][2] > key: + fails.append(f"{rel}: supersedes '{sup}', which is newer than this entry") + return fails, [] + + +def _resolve_yt_dir(start): + """The .ytstack dir the skill preambles resolve for `start`: the shared + resolver of hooks/lib/git-ctx.sh (project scope, then user scope under + ~/.ytstack/projects/). None when it resolves nothing or the + library is not reachable.""" + import subprocess + lib = Path(__file__).resolve().parent.parent / "hooks" / "lib" / "git-ctx.sh" + if not lib.is_file() or not start.is_dir(): + return None + proc = subprocess.run( + ["bash", "-c", '. "$1"; yt_git_ctx "$PWD"; yt_resolve_yt_dir', "ytstack-check", str(lib)], + cwd=str(start), capture_output=True, text=True) + out = proc.stdout.strip() + return Path(out) if out and Path(out).is_dir() else None + + +def standing_main(args): + """`ytstack-check --standing []`: only the standing entries of + a project, for any repository that has `.ytstack/` in project or user + scope (resolved like the skill preambles; no plugin root needed). Exit + 0 = pass or no directory, 1 = fail.""" + path_args = [a for a in args if not a.startswith("--")] + start = Path(path_args[0] if path_args else Path.cwd()).resolve() + yt = None + if start.name == ".ytstack" and start.is_dir(): + yt = start + else: + yt = _resolve_yt_dir(start) + for p in ([] if yt else [start, *start.parents]): + if p.name == ".ytstack" and p.is_dir(): + yt = p + break + if (p / ".ytstack").is_dir(): + yt = p / ".ytstack" + break + if yt is None: + print(f"no .ytstack/ found from {start}") + sys.exit(0) + fails, _ = check_standing(yt) + if fails: + print(f"FAIL: {len(fails)} error(s)") + for line in fails: + print(f" [fail] {line}") + sys.exit(1) + if not (yt / "standing").is_dir(): + print(f"OK: no {yt}/standing/ (STANDING.md alone is valid)") + else: + n = len([p for p in (yt / "standing").glob("*.md") if p.name != "README.md"]) + print(f"OK: {n} standing entr{'y' if n == 1 else 'ies'} in {yt}/standing/") + sys.exit(0) + + # ---------- main ---------- def main(): @@ -759,6 +903,9 @@ def main(): path_args = [a for a in args if not a.startswith("--")] root_arg = path_args[0] if path_args else None + if "--standing" in args: + standing_main(args) + root = find_plugin_root(root_arg) all_fails = [] @@ -811,6 +958,11 @@ def main(): all_fails.extend(f) all_warns.extend(w) + # Standing instructions, one file per entry (issue #57) + f, w = check_standing(root / ".ytstack") + all_fails.extend(f) + all_warns.extend(w) + # --tests: run the shell test suites (tests/run-all.sh) and fold the result in if "--tests" in args: import subprocess diff --git a/bin/ytstack-risk b/bin/ytstack-risk index 96b86594..2c333116 100755 --- a/bin/ytstack-risk +++ b/bin/ytstack-risk @@ -460,7 +460,7 @@ compute() { while IFS= read -r p; do [ -n "$p" ] || continue case "$p" in - .ytstack/spec/REVIEW.md|.ytstack/DECISIONS.md|.ytstack/STANDING.md|.ytstack/PREFERENCES.md) + .ytstack/spec/REVIEW.md|.ytstack/DECISIONS.md|.ytstack/STANDING.md|.ytstack/PREFERENCES.md|.ytstack/standing/*) note person "$p" "always a person: rule document"; echo "$p" >> "$W/exempt" ;; .github/workflows/*|.gitlab-ci.yml) note person "$p" "always a person: the checks themselves"; echo "$p" >> "$W/exempt" ;; diff --git a/docs/concept.md b/docs/concept.md index 60ba90f2..e7a845e3 100644 --- a/docs/concept.md +++ b/docs/concept.md @@ -245,7 +245,7 @@ Lifecycle + artifact + orchestration pieces that GSD inspired but we re-implemen - Per-task: `M###-S##-T##-PLAN.md`, `M###-S##-T##-SUMMARY.md` - Per-pitch (greenfield input): `OFFICE-HOURS.md` (pre-init) -> `OFFICE-HOURS-.md` (post-init, moved into `.ytstack/`) - Technical spec (M022, DECISIONS 2026-11-13): `spec/SPEC.md` (entry point, one page) and `spec/.md` (one per system area). They say what applies now; plans and summaries stay the history. Written by `init-project` (every area `planned`) and `adopt-brownfield` (pointer-only over existing documents, also for an initialized project without a spec), kept true by `plan-task` ("Spec impact"), `summarize-task` (closure check), `code-review`, the verifier and `reassess-roadmap` (drift answer). Format and maintenance rules: `docs/ux/spec-format.md`; checked by `bin/ytstack-spec`. -- Coordinator mode (M024, DECISIONS 2026-11-13; formats in `docs/ux/coordinator-format.md`): `LANES.md` (one row per delegated lane, written through `bin/ytstack-frontier`), `questions/Q###-.md` (one file per question for the human: open, asked, answered), `STANDING.md` (instructions that hold beyond the task), `handover/` (staged scripts for human-only steps and their receipts), `retro/LANES-.md` (lane retro candidates). Skills: `coordinate`, `finish-lane`, `handover-step`, `lane-retro`. Host facts (pull request state, checks, deployed build) are never stored there as current. +- Coordinator mode (M024, DECISIONS 2026-11-13; formats in `docs/ux/coordinator-format.md`): `LANES.md` (one row per delegated lane, written through `bin/ytstack-frontier`), `questions/Q###-.md` (one file per question for the human: open, asked, answered), `standing/-.md` (one file per instruction that holds beyond the task, a newer one supersedes an older one by name; `STANDING.md` alone stays valid, DECISIONS 2026-11-14), `handover/` (staged scripts for human-only steps and their receipts), `retro/LANES-.md` (lane retro candidates). Skills: `coordinate`, `finish-lane`, `handover-step`, `lane-retro`. Host facts (pull request state, checks, deployed build) are never stored there as current. - Risk gate (M025, DECISIONS 2026-11-13; format `docs/ux/review-policy-format.md`): `spec/REVIEW.md` (the project's floor extensions and lenses), `auto_merge` per area file, the extended `## Review` lines (class, invariants, reviewer; one line per lens), `evidence/` (screenshots of a visual review with a hashed `MANIFEST`). `bin/ytstack-risk` decides the route; `merge_by: risk` (default) merges without a person only when it says `unattended`. Skill: `visual-review`. - `RUNTIME.md` sections "Run", "Release", "Signals" (M025-S01; format `docs/ux/runtime-format.md`), read through `bin/ytstack-runtime`; `bin/ytstack-watch release` and `bin/ytstack-upkeep` (M026). - Production (M027; format `docs/ux/signal-format.md`): `signals/F###-.md` (one finding each, written through `bin/ytstack-signals`), `incidents/-.md`. Skills: `signal-intake`, `incident`. Read only; a mitigation is a handover script a person runs. diff --git a/docs/methodology.md b/docs/methodology.md index 946adb7d..9c2a0428 100644 --- a/docs/methodology.md +++ b/docs/methodology.md @@ -87,7 +87,7 @@ The external source distinguishes multiple agent types with specific roles. We d Coordinator mode (`coordinate`, `finish-lane`, `handover-step`, `lane-retro`, `bin/ytstack-frontier`, `bin/ytstack-questions`, `docs/ux/coordinator-format.md`) adapts concepts from that collection, reviewed at `4ae2317`: -- A coordinating session whose memory outlives it, written as history (`LANES.md`, `STANDING.md`) +- A coordinating session whose memory outlives it, written as history (`LANES.md`, the standing instructions in `standing/`) - Blocking edges and a frontier of ready work, a claim before any work - A brief with checkable completion criteria (`bin/ytstack-brief`) - A staged script for a step only the human may perform (`handover-step`) diff --git a/docs/ux/coordinator-format.md b/docs/ux/coordinator-format.md index 58fb5905..6d502ccc 100644 --- a/docs/ux/coordinator-format.md +++ b/docs/ux/coordinator-format.md @@ -145,10 +145,39 @@ Rules: `bin/ytstack-questions list` prints the open and asked ones; `check` validates the files. -## `STANDING.md` -- what the human asked for once and for all +## `standing/` -- what the human asked for once and for all An instruction that holds beyond the task at hand ("never merge without my word", "status only at slice boundaries") is written down when it is given, because a summary after a compaction does not keep it. +One file per instruction: `.ytstack/standing/-.md`, the UTC time it was given and a lowercase slug. Two pull requests that each add an instruction add two files and never touch the same line. + +```markdown +--- +given: 2026-11-13T09:05:00Z +scope: every lane of this project +supersedes: 20261112T1640Z-review-every-push +--- + +One review per lane, a second only for the fix. +``` + +| Key | Holds | +|---|---| +| `given` | The UTC time, ISO (`YYYY-MM-DDTHH:MMZ`, seconds optional). The same minute as the file name, whose time orders the entries; missing seconds count as `00`. | +| `scope` | Where the instruction applies. Not empty. | +| `supersedes` | Empty, or the file name (without `.md`) of the earlier entry this one replaces. | + +Rules: + +- Own words, never a quotation. The body is the instruction. +- An entry is not edited after it is written and nothing is deleted. An instruction that replaces another is a new file whose `supersedes` names the old one; from then on the old one no longer holds. +- Readers take the entries newest first and skip every entry that another entry supersedes. `yt_standing` in `hooks/lib/git-ctx.sh` prints them; the preambles of `coordinate`, `finish-lane` and `signal-intake` list them between `STANDING_ENTRIES_BEGIN` and `STANDING_ENTRIES_END`. The coordinator reads every listed file at every start and after every compaction, before it acts. +- A `README.md` in the directory is a note for people and is not an entry. + +### `STANDING.md` + +The single file of earlier versions stays valid. A project without `standing/` keeps it as it was: one line per instruction, time, the instruction, its scope; a replaced line is struck through and dated. + ```markdown # Standing instructions @@ -156,7 +185,7 @@ An instruction that holds beyond the task at hand ("never merge without my word" - 2026-11-12T16:40Z -- ~~Reviews run on every push.~~ Superseded 2026-11-13T09:05Z: one review per lane, a second only for the fix. ``` -Own words, never a quotation. One line each: time, the instruction, its scope. The coordinator reads the file at every start and after every compaction, before it acts. +Where both exist, both are read: `STANDING.md` may be a short index that points at the directory, and lines it still holds keep holding. New instructions go into `standing/`; the coordinator appends to `STANDING.md` only in a project that has no `standing/` directory yet. ## Checked mechanically @@ -164,3 +193,4 @@ Own words, never a quotation. One line each: time, the instruction, its scope. T - `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-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`). 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 a9ceb83a..5452b449 100644 --- a/docs/ux/review-policy-format.md +++ b/docs/ux/review-policy-format.md @@ -32,7 +32,7 @@ There is one `reason:` line per path and rule that raised the floor. A rule name **Always a person** (`person`): -- a change to `.ytstack/spec/REVIEW.md`, `.ytstack/DECISIONS.md`, `.ytstack/STANDING.md`, `.ytstack/PREFERENCES.md`, or to an instruction file of the repository (`AGENTS.md`, `CLAUDE.md`, at any depth) +- a change to `.ytstack/spec/REVIEW.md`, `.ytstack/DECISIONS.md`, `.ytstack/STANDING.md`, a file under `.ytstack/standing/`, `.ytstack/PREFERENCES.md`, or to an instruction file of the repository (`AGENTS.md`, `CLAUDE.md`, at any depth) - a change to the frontmatter of an area file, or to the text of its sections "Invariants and security boundaries" and "Decisions that apply now"; the same section of `SPEC.md` ("Invariants that hold everywhere"); an area file or a `SPEC.md` that the change adds or deletes. Other edits of an area file are ordinary: a task that changes behaviour updates "Behavior" in the same commits. So is a `verified_at` stamp on its own: it answers a drift report (`docs/ux/spec-format.md`, "Drift") and changes no policy. `area`, `status`, `paths`, `sources` and `auto_merge` stay `person` - a change to the checks themselves: `.github/workflows/**`, `.gitlab-ci.yml`, and whatever the project lists - a changed path that no area covers (see "Ceilings"), other than the process records of the work itself. An area file counts as covered by its own area and touches it; `SPEC.md` needs no area. A renamed or deleted file counts with its old and its new path diff --git a/hooks/lib/git-ctx.sh b/hooks/lib/git-ctx.sh index 71efdfc3..a9637b23 100644 --- a/hooks/lib/git-ctx.sh +++ b/hooks/lib/git-ctx.sh @@ -609,6 +609,42 @@ yt_find_artifacts() { return 0 } +# ---- standing instructions, one file per entry (issue #57) -------------------- +# yt_standing -> the standing entries in force, newest first, one per +# line: TAB TAB . Entries live in +# /standing/-.md (docs/ux/coordinator-format.md); +# the time in the name orders them (missing seconds count as 00). An entry that another entry names in `supersedes` +# is skipped. Prints nothing when the directory does not exist; STANDING.md +# is read by the caller as before. +yt_standing() { + local sd="$1/standing" names + [ -n "$1" ] && [ -d "$sd" ] || return 0 + names=$(ls "$sd" 2>/dev/null | grep -E '^[0-9]{8}T[0-9]{4}([0-9]{2})?Z-[A-Za-z0-9._-]+\.md$') + [ -n "$names" ] || return 0 + # shellcheck disable=SC2086 # the names match the pattern above: no spaces + ( cd "$sd" && awk -v q="'" ' + function clean(v, f) { + gsub(/^[ \t]+|[ \t]+$/, "", v) + f = substr(v, 1, 1) + if (length(v) >= 2 && (f == q || f == "\"") && substr(v, length(v)) == f) v = substr(v, 2, length(v) - 2) + return v + } + # Sort key YYYYMMDDHHMMSS: a name without seconds counts as :00, so that + # 20261114T1225Z sorts before 20261114T122530Z. + function out( k) { k = substr(fn, 1, 8) substr(fn, 10, 4) (substr(fn, 14, 1) == "Z" ? "00" : substr(fn, 14, 2)); print k "\t" fn "\t" g "\t" s "\t" u } + FNR == 1 { if (fn != "") out(); fn = FILENAME; infm = ($0 == "---"); g = ""; s = ""; u = ""; next } + infm && /^---[ \t]*$/ { infm = 0; next } + infm && /^given:/ { g = clean(substr($0, 7)) } + infm && /^scope:/ { s = clean(substr($0, 7)) } + infm && /^supersedes:/ { u = clean(substr($0, 12)); sub(/\.md$/, "", u) } + END { if (fn != "") out() } + ' $names ) | sort -r | awk -F '\t' ' + { n[NR] = $2; l[NR] = $2 "\t" $3 "\t" $4; if ($5 != "" && $5 != "none" && $5 != "None" && $5 != "-") sup[$5] = 1 } + END { for (i = 1; i <= NR; i++) { b = n[i]; sub(/\.md$/, "", b); if (!(b in sup)) print l[i] } } + ' + return 0 +} + # yt_resolve_yt_dir -> the .ytstack dir for the resolved toplevel: project # scope (/.ytstack) first, then user scope keyed by YT_REPO_KEY. # Sets YT_DIR and YT_SCOPE (project|user|none). No basename slugs. diff --git a/skills/coordinate/SKILL.md b/skills/coordinate/SKILL.md index eb1fd528..af42352d 100644 --- a/skills/coordinate/SKILL.md +++ b/skills/coordinate/SKILL.md @@ -3,7 +3,7 @@ name: coordinate description: "Coordinator mode for the session that owns a plan and delegates all of it, writing no product code itself. Use when many lanes are in flight, when a plan has dozens of work packages, when a session with open lanes continues after a compaction or a resume, or when the user says coordinate this, run the plan, you are the coordinator, keep the lanes moving, where does each lane stand. Not for one milestone with a handful of independent slices (spawn-milestone-team) and not for doing a task yourself (plan-task)." metadata: tier: task - version: 0.2.2 + version: 0.3.0 allowed-tools: - Bash - Read @@ -15,7 +15,7 @@ allowed-tools: # coordinate -One session owns the plan and hands out all of the work. Its state lives in four files (`LANES.md`, the frontier, `questions/`, `STANDING.md`; formats in `docs/ux/coordinator-format.md`), so it can lose its context, or be replaced by another session, person or host, and continue. It edits `.ytstack/` and pull request bodies. Nothing else. +One session owns the plan and hands out all of the work. Its state lives in four places (`LANES.md`, the frontier, `questions/`, the standing instructions in `standing/` or `STANDING.md`; formats in `docs/ux/coordinator-format.md`), so it can lose its context, or be replaced by another session, person or host, and continue. It edits `.ytstack/` and pull request bodies. Nothing else. Do NOT edit product code, tests or configuration, do NOT review a diff yourself, and do NOT state anything about a pull request, its checks or a deployed build that you did not read from the host for this statement. This applies to EVERY lane regardless of how small the change looks. @@ -23,7 +23,7 @@ Do NOT edit product code, tests or configuration, do NOT review a diff yourself, ## Anti-Pattern: "I know where the lanes stand" -After the first compaction you know a summary. In a long run a coordinator reported a production build that had been replaced and a pull request as open that had merged, and it lost instructions the human had given once. Who holds what comes from `LANES.md`. What the host says is read when it is needed and carries its read time. What the human asked for once and for all is in `STANDING.md`. +After the first compaction you know a summary. In a long run a coordinator reported a production build that had been replaced and a pull request as open that had merged, and it lost instructions the human had given once. Who holds what comes from `LANES.md`. What the host says is read when it is needed and carries its read time. What the human asked for once and for all is in the standing instructions (`standing/`, `STANDING.md`). ## Anti-Pattern: "I'll add a rule so that this does not happen again" @@ -41,7 +41,7 @@ You MUST create a TodoWrite task for each of these items. Items 4 to 13 are one 6. **Finish reported lanes** -- `ytstack:finish-lane`, one lane at a time per pull request 7. **Keep the watcher running** -- `ytstack-watch` in the background for the open pull requests, and `ytstack-watch release` for a commit that merged 8. **Queue and ask questions** -- look up, write the file, ask one, late -9. **Record standing instructions** -- into `STANDING.md` when they are given +9. **Record standing instructions** -- one file per instruction in `standing/` when they are given 10. **Stop loops that do not converge** -- a diagnosis to the human instead of another dispatch 11. **Report status** -- only on a change the human acts on, or at a boundary he set 12. **Rotate** -- after one compaction or with a large context: handoff, files current, fresh session @@ -107,6 +107,14 @@ _PR_HOST=none [ -n "$(git remote 2>/dev/null | head -1)" ] && command -v gh >/dev/null 2>&1 && _PR_HOST=gh echo "PR_HOST: $_PR_HOST" echo "STANDING: $([ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STANDING.md" ] && echo yes || echo no)" +# One file per standing instruction (.ytstack/standing/): the ones in force, newest first. +echo "STANDING_ENTRIES_BEGIN" +if [ -n "$_YT_DIR" ] && [ -d "$_YT_DIR/standing" ]; then + command -v yt_standing >/dev/null 2>&1 && yt_standing "$_YT_DIR" || echo "list $_YT_DIR/standing/ yourself: newest first, skip superseded" +else + echo "no standing directory" +fi +echo "STANDING_ENTRIES_END" echo "LANES_BEGIN" _ROWS="" @@ -155,7 +163,7 @@ The scripts live in `${CLAUDE_SKILL_DIR}/../../bin/`; the commands below are wri **Step 2 -- HARD-GATE.** `HAS_YTSTACK: no`: stop, "run `ytstack:init-project` or `ytstack:adopt-brownfield` first". `SLICE_PLANS: 0` and `no lanes`: stop, "nothing to coordinate; run `ytstack:slice-milestone`". One milestone with a handful of independent slices and no lane yet: `ytstack:spawn-milestone-team` does that with less ceremony; say so and stop unless the user asked for coordinator mode. -**Step 3 -- Start from files.** At the first start, after every compaction and after every resume, before anything else: read `STANDING.md` in full, the rows between `LANES_BEGIN` and `LANES_END`, the frontier, every file listed between `QUESTIONS_BEGIN` and `QUESTIONS_END`, and the newer of the two handoffs. Do not rebuild who holds what from a conversation summary. Where a summary and a file disagree, the file is the claim, and Step 4 checks it against the host before anybody acts on it. A `running` row whose worker no longer exists in this session is not dispatched again blindly: read its branch (`git log ..`), then `ytstack-frontier release ` and claim it for a new worker that continues on that branch, or write a question. +**Step 3 -- Start from files.** At the first start, after every compaction and after every resume, before anything else: read the standing instructions in full (every file listed between `STANDING_ENTRIES_BEGIN` and `STANDING_ENTRIES_END`, newest first, and `STANDING.md` when `STANDING: yes`; an entry that another entry supersedes is not listed and no longer holds), the rows between `LANES_BEGIN` and `LANES_END`, the frontier, every file listed between `QUESTIONS_BEGIN` and `QUESTIONS_END`, and the newer of the two handoffs. Do not rebuild who holds what from a conversation summary. Where a summary and a file disagree, the file is the claim, and Step 4 checks it against the host before anybody acts on it. A `running` row whose worker no longer exists in this session is not dispatched again blindly: read its branch (`git log ..`), then `ytstack-frontier release ` and claim it for a new worker that continues on that branch, or write a question. **Step 4 -- Read host facts fresh.** Before a status, and before an action that depends on the state of a pull request, its checks, a review or a deployed build, read now: @@ -174,7 +182,7 @@ One line per pull request (state, head, checks, newest review and its commit, me A lane named in the `blocks:` of an open or asked question is not ready, whatever the frontier prints. Look at the frontier again whenever a lane changes state: a merge unblocks lanes. Lanes that need nothing from each other go out in one message. -**Step 6 -- Finish reported lanes.** A `reported` lane goes through `ytstack:finish-lane`: the review at a pinned head with the class its reviewer states, the route of the change, the gates read from the host, the merge at the reviewed commit or not at all. Who merges follows `merge_by` in `PREFERENCES.md`. With `risk`, the default, `finish-lane` merges a lane itself when `bin/ytstack-finish-lane route` printed `route: unattended` and the host's gates hold; every other lane stops at `ready` with its merge command and the reasons, and waits for a person. You state no class and you change no ceiling: the class is the reviewer's, the ceiling stands in the area file of the technical spec (`docs/ux/review-policy-format.md`). A change that requires lenses (`.ytstack/spec/REVIEW.md`) gets one more fresh reviewer per lens from `finish-lane`. A lens reviewer is a lane of kind `review` and never the lane's worker; a lens with visual evidence needs a session that can start the product and has a browser tool. One lane at a time per pull request. `finish-lane` writes the reviewed head and the round into the lane's row; a row that lacks them after a review is repaired before anything else (`ytstack-frontier set --head --round --pr `). Never merge around it. A cap on open pull requests, when the project or `STANDING.md` sets one, is a gate of `finish-lane`: a lane that waits for it stays where it is. +**Step 6 -- Finish reported lanes.** A `reported` lane goes through `ytstack:finish-lane`: the review at a pinned head with the class its reviewer states, the route of the change, the gates read from the host, the merge at the reviewed commit or not at all. Who merges follows `merge_by` in `PREFERENCES.md`. With `risk`, the default, `finish-lane` merges a lane itself when `bin/ytstack-finish-lane route` printed `route: unattended` and the host's gates hold; every other lane stops at `ready` with its merge command and the reasons, and waits for a person. You state no class and you change no ceiling: the class is the reviewer's, the ceiling stands in the area file of the technical spec (`docs/ux/review-policy-format.md`). A change that requires lenses (`.ytstack/spec/REVIEW.md`) gets one more fresh reviewer per lens from `finish-lane`. A lens reviewer is a lane of kind `review` and never the lane's worker; a lens with visual evidence needs a session that can start the product and has a browser tool. One lane at a time per pull request. `finish-lane` writes the reviewed head and the round into the lane's row; a row that lacks them after a review is repaired before anything else (`ytstack-frontier set --head --round --pr `). Never merge around it. A cap on open pull requests, when the project or a standing instruction sets one, is a gate of `finish-lane`: a lane that waits for it stays where it is. **Step 7 -- Keep the watcher running.** Polling happens outside the model: @@ -186,7 +194,7 @@ The PR watch counts as on only when `pr_watch=on` is set in `~/.ytstack/config` Start it as a background process; on a host with a monitor tool, through that tool, so that each new line reaches you as an event. It prints a line only when a head moved, the checks changed, a review arrived, mergeability changed or a pull request closed, and it ends when all are merged or closed. Act on the line: red checks go back to the lane's worker with the name of the check; a review on a commit that is not the head is no review of the head. A pull request that merged, also when a person merged it: set its lane to `merged` and watch the release of its merge commit as `ytstack:finish-lane` describes ("Watch the release"), with `ytstack-watch release --commit ` in the background. Its receipt goes into the next status; `not arrived` or `unhealthy` is a status at once. You deploy nothing and roll nothing back: a countermeasure on the target is a step for the human (`ytstack:handover-step`). Start the watcher again with the new list when a pull request opens. Never read status in a loop from the conversation, with or without a sleep. The single read of Step 4 before an action is not polling. -**Step 8 -- Queue and ask questions.** First look the question up: the plan, `DECISIONS.md`, the answered files in `questions/`. What they answer is not asked. Otherwise `ytstack-questions new --question "" --decides "" --blocks ""` and fill Context, Options and Recommendation until the human can answer from the file alone. The state is `open` and the lanes that do not depend on it go on. Ask as late as the work allows: when nothing ready is left that is independent of it, or at a boundary from `STANDING.md`. Ask one (`ytstack-questions next`), mark it (`ytstack-questions ask `), and use AskUserQuestion: +**Step 8 -- Queue and ask questions.** First look the question up: the plan, `DECISIONS.md`, the answered files in `questions/`. What they answer is not asked. Otherwise `ytstack-questions new --question "" --decides "" --blocks ""` and fill Context, Options and Recommendation until the human can answer from the file alone. The state is `open` and the lanes that do not depend on it go on. Ask as late as the work allows: when nothing ready is left that is independent of it, or at a boundary from a standing instruction. Ask one (`ytstack-questions next`), mark it (`ytstack-questions ask `), and use AskUserQuestion: > **{Q### -- the title}** in **{project}** on `{BRANCH}`. It blocks {blocks}; {n} lanes go on without it. > @@ -201,13 +209,13 @@ Start it as a background process; on a host with a monitor tool, through that to An `asked` question is never asked again: name it as waiting since its time. When the human answers, write what he said under `## Answer`, run `ytstack-questions answer `, and add a `DECISIONS.md` entry when it decides something that lasts. Never record an answer the human did not give, and never take a verdict a plan reserves for a person. At a slice boundary the open gates go out together through `ytstack:reassess-roadmap` (its Step 3b). A step only the human may perform (a secret, a production switch, a merge he reserved) goes through `ytstack:handover-step` as one staged script. `YTSTACK_NON_INTERACTIVE: true`: ask nothing; the files stay `open` and are listed in the status under "Waiting on a person". -**Step 9 -- Record standing instructions.** When the human gives an instruction that holds beyond the task at hand (when to report, what never to merge, what not to touch), append it to `STANDING.md` at once, before the next dispatch: `- -- . Scope: `. Never a quotation. An instruction that replaces an older one strikes the old line (`~~...~~ Superseded : ...`); nothing is deleted. +**Step 9 -- Record standing instructions.** When the human gives an instruction that holds beyond the task at hand (when to report, what never to merge, what not to touch), write it down at once, before the next dispatch, as a new file `$_YT_DIR/standing/-.md` (`YT_DIR` from the preamble: `.ytstack/` in the repository, or `~/.ytstack/projects//` in user scope; UTC now): frontmatter `given` (the same time, ISO), `scope` (where it applies) and `supersedes` (empty), and the instruction in your own words as its body (`docs/ux/coordinator-format.md`). Never a quotation. An instruction that replaces an older one is a new file whose `supersedes` names the older file without `.md`; the older file is not edited and nothing is deleted. Then run `ytstack-check --standing` and fix what it prints. One file per instruction keeps two pull requests that each add one from touching the same line. `STANDING.md` is not edited per entry; only a project that has `STANDING.md` and no `standing/` directory yet keeps its form: append `- -- . Scope: ` and strike a replaced line (`~~...~~ Superseded : ...`). **Step 10 -- Stop loops that do not converge.** A lane gets the rounds `ytstack:code-review` allows ("Bounded review": round 1 complete, round 2 the fix, no third). A lane that failed verification twice, or that would need a third review, is not dispatched again: `ytstack-frontier set --status blocked --next "Q### with the human"`, and a question file with the diagnosis (the plan never decided the point, two rules conflict, or each fix moved the problem). -**Step 11 -- Report status.** Only when something changed that the human acts on (a question, a blocker, a finished plan, a lane that waits for his merge), or at a boundary he set in `STANDING.md`. No interim reports that work is running. A lane that merged without a person is no reason for a status of its own: the next status that is due names it in one line, with its class and the ceiling it merged under. A status is two to four full sentences with pointers (files, commits, pull request numbers). When the plan has gates it carries two numbers side by side, closed by work and accepted, as `ytstack:reassess-roadmap` counts them. Every host fact in it comes from a read made for this status and carries `read `. When the human asks where the lanes stand, answer per lane instead: the status and the next action of its row as written, then the open and asked questions with what they block. +**Step 11 -- Report status.** Only when something changed that the human acts on (a question, a blocker, a finished plan, a lane that waits for his merge), or at a boundary he set in a standing instruction. No interim reports that work is running. A lane that merged without a person is no reason for a status of its own: the next status that is due names it in one line, with its class and the ceiling it merged under. A status is two to four full sentences with pointers (files, commits, pull request numbers). When the plan has gates it carries two numbers side by side, closed by work and accepted, as `ytstack:reassess-roadmap` counts them. Every host fact in it comes from a read made for this status and carries `read `. When the human asks where the lanes stand, answer per lane instead: the status and the next action of its row as written, then the open and asked questions with what they block. -**Step 12 -- Rotate.** When the session has been compacted once (a summary stands where the conversation was, or `HANDOFF_AUTO` is from this session), or its context is large by the host's indicator, do not wait for the next compaction. After Step 3: bring the rows' next actions up to date, run `ytstack-frontier check` and `ytstack-questions check`, make sure `STANDING.md` holds every instruction given so far, write a handoff with `ytstack:handoff-session` (pointers only), and tell the user that a fresh session continues from the files with `ytstack:coordinate`. The watcher and running workers do not depend on this session's context. The same files let another person or another host take over. +**Step 12 -- Rotate.** When the session has been compacted once (a summary stands where the conversation was, or `HANDOFF_AUTO` is from this session), or its context is large by the host's indicator, do not wait for the next compaction. After Step 3: bring the rows' next actions up to date, run `ytstack-frontier check` and `ytstack-questions check`, make sure the standing instructions hold every instruction given so far, write a handoff with `ytstack:handoff-session` (pointers only), and tell the user that a fresh session continues from the files with `ytstack:coordinate`. The watcher and running workers do not depend on this session's context. The same files let another person or another host take over. **Step 13 -- Sample finished lanes.** About every fifth finished lane, run `ytstack:lane-retro`, the lanes that went wrong first. diff --git a/skills/finish-lane/SKILL.md b/skills/finish-lane/SKILL.md index 22dd9746..2b73d477 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.3.0 + version: 0.3.1 allowed-tools: - Bash - Read @@ -137,6 +137,12 @@ echo "FINISH_TOOL: ${_TOOL:-missing}" echo "MERGE_BY: $_MERGE_BY" [ -n "$_MERGE_BY_NOTE" ] && echo "MERGE_BY_NOTE: $_MERGE_BY_NOTE" echo "STANDING: $([ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STANDING.md" ] && echo "$_YT_DIR/STANDING.md" || echo none)" +# One file per standing instruction (.ytstack/standing/): the ones in force, newest first. +echo "STANDING_ENTRIES_BEGIN" +if [ -n "$_YT_DIR" ] && [ -d "$_YT_DIR/standing" ]; then + command -v yt_standing >/dev/null 2>&1 && yt_standing "$_YT_DIR" || echo "list $_YT_DIR/standing/ yourself: newest first, skip superseded" +fi +echo "STANDING_ENTRIES_END" # Own reviewers in REVIEW.md (M030): after its own merge this skill runs the escape check. _RISK="${CLAUDE_SKILL_DIR}/../../bin/ytstack-risk"; [ -f "$_RISK" ] || _RISK=$(command -v ytstack-risk 2>/dev/null) echo "OWN_REVIEWERS: $([ -n "$_RISK" ] && [ -n "$(bash "$_RISK" -C "$_PROJECT_DIR" reviewers 2>/dev/null)" ] && echo yes || echo no)" @@ -165,7 +171,7 @@ In the calls below `{WT}` is the lane's worktree: the `Worktree` cell of its row `MERGE_BY` is the project's `merge_by:` in `PREFERENCES.md`: `risk` (the default), `human` or `coordinator`. Step 11 says what each means. -If `STANDING` names a file, read it in full now, before anything is pushed. Its lines are what the human asked for once and for all; they override the defaults of this skill: who merges, when a status is due, a cap on open pull requests. +Read the standing instructions in full now, before anything is pushed: every file listed between `STANDING_ENTRIES_BEGIN` and `STANDING_ENTRIES_END` (newest first; superseded entries are not listed) and the file `STANDING` names, if any. They are what the human asked for once and for all; they override the defaults of this skill: who merges, when a status is due, a cap on open pull requests. ### Step 3: Read the report, commit leftovers diff --git a/skills/handover-step/SKILL.md b/skills/handover-step/SKILL.md index 088add8a..9f2e2e95 100644 --- a/skills/handover-step/SKILL.md +++ b/skills/handover-step/SKILL.md @@ -3,7 +3,7 @@ name: handover-step description: "Prepares a step that only the human may perform (a production action, a check in a GUI application, anything behind their credentials or their eyes) as one staged script they start with one short command. Use when the plan, a gate or a standing instruction reserves a step for the human, or when the user says hand this over, prepare the production step, give me a script for it. Not for a step the agent may do itself, and not for a decision only the human can take (that is a question file under .ytstack/questions/, written with bin/ytstack-questions)." metadata: tier: task - version: 0.1.0 + version: 0.1.1 allowed-tools: - Bash - Read @@ -131,7 +131,7 @@ echo "HANDOVER_FILES_END" ### Step 2: Establish the step -Read the plan that names the step (the task plan, the slice plan with its `## Gates`, `DECISIONS.md`, `.ytstack/STANDING.md` when it exists). Write down, in one sentence each, what the step is and why it is the human's. It is the human's when one of these holds: +Read the plan that names the step (the task plan, the slice plan with its `## Gates`, `DECISIONS.md`, the standing instructions: the files in `.ytstack/standing/` that no other entry supersedes and `.ytstack/STANDING.md`, where they exist). Write down, in one sentence each, what the step is and why it is the human's. It is the human's when one of these holds: - the plan, a gate or a standing instruction reserves it ("never deploy without me"); - it needs credentials you do not hold and must not be given; diff --git a/skills/review-lessons/SKILL.md b/skills/review-lessons/SKILL.md index 3edbb4e5..dc31408a 100644 --- a/skills/review-lessons/SKILL.md +++ b/skills/review-lessons/SKILL.md @@ -3,7 +3,7 @@ name: review-lessons description: "Looks at the review-bot findings of merged pull requests that the project's own review roles missed and turns repeated or severe ones into a proposed line for the owning role's file, as a question for a person. Use after a pull request merged in a project whose REVIEW.md declares own reviewers, when PR watch or bin/ytstack-upkeep says a merged pull request has no escape check, or when the user says what did the bots catch that our reviewers missed, review lessons, learn from the bot findings. Not for reviewing a change before it merges (code-review) and not for what production reports (signal-intake)." metadata: tier: task - version: 0.1.0 + version: 0.1.1 allowed-tools: - Bash - Read @@ -274,7 +274,7 @@ Then put the question id into the finding's `## Next`: `Proposed as Q###. After cd "{PROJECT_DIR}" && bash "{SIGNALS_TOOL}" check && bash "{QUESTIONS_TOOL}" check ``` -A problem in a file you wrote in this run: fix it and check again. A problem in an older file: leave it and put the line into the report. Commit only when the prompt, the schedule or `STANDING.md` says that this run commits; then exactly `.ytstack/signals/` and `.ytstack/questions/`, with the message `chore: review lessons {date}`. Never push. +A problem in a file you wrote in this run: fix it and check again. A problem in an older file: leave it and put the line into the report. Commit only when the prompt, the schedule or a standing instruction (`.ytstack/standing/`, newest first and not superseded, or `STANDING.md`) says that this run commits; then exactly `.ytstack/signals/` and `.ytstack/questions/`, with the message `chore: review lessons {date}`. Never push. ### Step 9: Report diff --git a/skills/signal-intake/SKILL.md b/skills/signal-intake/SKILL.md index 1645efaa..14b0ef0c 100644 --- a/skills/signal-intake/SKILL.md +++ b/skills/signal-intake/SKILL.md @@ -3,7 +3,7 @@ name: signal-intake description: "Reads the signal sources a project declares under Signals in RUNTIME.md (an error tracker, a latency report, alerts, logs) and records what is new, seen again or back after a fix as findings under .ytstack/signals/, changing nothing else. Use in a scheduled or unattended run, or when the user says look at what production reports, check the error tracker, anything new in production, go through the alerts, run the signal intake. Not for an outage that is happening now (incident), not for finding the cause of one finding (systematic-debugging) and not for watching a release after a merge (finish-lane)." metadata: tier: task - version: 0.1.0 + version: 0.1.1 allowed-tools: - Bash - Read @@ -118,6 +118,12 @@ fi echo "SIGNALS_TOOL: ${_SIG:-unavailable}" echo "RUNTIME_TOOL: ${_RT:-unavailable}" echo "STANDING: $([ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STANDING.md" ] && echo yes || echo no)" +# One file per standing instruction (.ytstack/standing/): the ones in force, newest first. +echo "STANDING_ENTRIES_BEGIN" +if [ -n "$_YT_DIR" ] && [ -d "$_YT_DIR/standing" ]; then + command -v yt_standing >/dev/null 2>&1 && yt_standing "$_YT_DIR" || echo "list $_YT_DIR/standing/ yourself: newest first, skip superseded" +fi +echo "STANDING_ENTRIES_END" echo "NOW: $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "RUNTIME_CHECK: $([ -n "$_RT" ] && bash "$_RT" check 2>&1 | head -10)" # One line per source: name, kind, read, scope (tab separated). @@ -241,7 +247,7 @@ cd "{PROJECT_DIR}" && bash "{SIGNALS_TOOL}" check `signals ok: N finding(s)` is the result. A problem in a file you wrote in this run: fix it and check again. A problem in an older file: leave the file alone and put the line into the report. -The files under `.ytstack/signals/` are the memory of the intake: without them the next run records everything as new. Commit only when the prompt, the schedule or `STANDING.md` says that this run commits; then exactly `.ytstack/signals/`, with the message `chore: signal intake {date}`. Never push on your own, and never commit another path. +The files under `.ytstack/signals/` are the memory of the intake: without them the next run records everything as new. Commit only when the prompt, the schedule or a standing instruction (an entry between `STANDING_ENTRIES_BEGIN` and `STANDING_ENTRIES_END`, or `STANDING.md`) says that this run commits; then exactly `.ytstack/signals/`, with the message `chore: signal intake {date}`. Never push on your own, and never commit another path. ### Step 7: Report diff --git a/tests/git-ctx.test.sh b/tests/git-ctx.test.sh index 7ccfa290..ab3e8436 100644 --- a/tests/git-ctx.test.sh +++ b/tests/git-ctx.test.sh @@ -355,6 +355,29 @@ eq "find: backlog subdirs" 1 "$(fa "$FA" 'item.md' | grep -c .)" eq "find: specific plan missing -> empty" "" "$(fa "$FA" 'M009-S01-T01-PLAN.md')" eq "find: missing dir -> empty" "" "$(fa "$TMP/nope" '*.md')" +# ---- yt_standing: one file per standing instruction (issue #57) ---- +echo "# standing entries" +ST="$TMP/st/.ytstack"; mkdir -p "$ST/standing" +TAB=$(printf '\t') +st() { ( . "$LIB"; yt_standing "$1" ); } +eq "standing: no directory -> empty" "" "$(st "$TMP/nope")" +eq "standing: empty directory -> empty" "" "$(st "$ST")" +printf -- '---\ngiven: 2026-11-14T12:25:00Z\nscope: every author\nsupersedes:\n---\n\nAt most 10 open pull requests.\n' > "$ST/standing/20261114T1225Z-at-most-ten.md" +printf -- '---\ngiven: 2026-11-14T13:00:00Z\nscope: "every message"\nsupersedes:\n---\n\nReport results only.\n' > "$ST/standing/20261114T1300Z-results-only.md" +printf -- '---\ngiven: 2026-11-14T14:36:00Z\nscope: every lane\nsupersedes: 20261114T1225Z-at-most-ten\n---\n\nAt most 15.\n' > "$ST/standing/20261114T1436Z-at-most-fifteen.md" +printf '# Standing\n\nOne file per instruction.\n' > "$ST/standing/README.md" +OUT=$(st "$ST") +eq "standing: in force, newest first, superseded skipped, README ignored" \ + "20261114T1436Z-at-most-fifteen.md${TAB}2026-11-14T14:36:00Z${TAB}every lane +20261114T1300Z-results-only.md${TAB}2026-11-14T13:00:00Z${TAB}every message" "$OUT" +printf -- '---\ngiven: 2026-11-14T15:00:00Z\nscope: x\nsupersedes: "20261114T1300Z-results-only.md"\n---\n\nStatus at slice boundaries.\n' > "$ST/standing/20261114T1500Z-boundaries.md" +eq "standing: supersedes with quotes and .md also skips" 2 "$(st "$ST" | grep -c .)" +case "$(st "$ST")" in *results-only*) bad "standing: the quoted supersedes target is gone";; *) ok "standing: the quoted supersedes target is gone";; esac +ST2="$TMP/st2/.ytstack"; mkdir -p "$ST2/standing" +printf -- '---\ngiven: 2026-11-14T12:25:00Z\nscope: x\nsupersedes:\n---\n\nOld.\n' > "$ST2/standing/20261114T1225Z-old.md" +printf -- '---\ngiven: 2026-11-14T12:25:30Z\nscope: x\nsupersedes:\n---\n\nNew.\n' > "$ST2/standing/20261114T122530Z-new.md" +eq "standing: optional seconds sort as :00 (12:25:30 before 12:25)" "20261114T122530Z-new.md 20261114T1225Z-old.md" "$(st "$ST2" | cut -f1 | tr '\n' ' ' | sed 's/ $//')" + echo echo "$PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/skill-preambles.test.sh b/tests/skill-preambles.test.sh index 8ebe6d2e..a29ebea3 100644 --- a/tests/skill-preambles.test.sh +++ b/tests/skill-preambles.test.sh @@ -245,6 +245,20 @@ for s in $SKILLS; do run_pre "$P" "$WT" has "$s: task-ref commit -> COMMITS_SOURCE task-ref" "$OUT" "COMMITS_SOURCE: task-ref" case "$OUT" in *"BASE_SHA: none"*) bad "$s: task-ref commit -> BASE_SHA resolved";; *) ok "$s: task-ref commit -> BASE_SHA resolved";; esac ;; + coordinate) + # standing instructions, one file per entry (issue #57); STANDING.md alone stays valid + has "$s: no standing directory" "$OUT" "STANDING: no" + has "$s: and no entries" "$OUT" "no standing directory" + mkdir -p "$WT/.ytstack/standing" + printf -- '---\ngiven: 2026-11-14T12:25:00Z\nscope: every author\nsupersedes:\n---\n\nAt most 10.\n' > "$WT/.ytstack/standing/20261114T1225Z-at-most-ten.md" + printf -- '---\ngiven: 2026-11-14T14:36:00Z\nscope: every lane\nsupersedes: 20261114T1225Z-at-most-ten\n---\n\nAt most 15.\n' > "$WT/.ytstack/standing/20261114T1436Z-at-most-fifteen.md" + printf '# Standing instructions\n\nSee standing/.\n' > "$WT/.ytstack/STANDING.md" + run_pre "$P" "$WT" + has "$s: STANDING.md as an index is still named" "$OUT" "STANDING: yes" + has "$s: the entry in force is listed" "$OUT" "STANDING_ENTRIES_BEGIN +20261114T1436Z-at-most-fifteen.md 2026-11-14T14:36:00Z every lane +STANDING_ENTRIES_END" + rm -rf "$WT/.ytstack/standing" "$WT/.ytstack/STANDING.md" ;; finish-lane) # who merges (M025): risk unless PREFERENCES says otherwise; a typo reads as human has "$s: no merge_by in PREFERENCES -> risk" "$OUT" "MERGE_BY: risk" diff --git a/tests/ytstack-check.test.sh b/tests/ytstack-check.test.sh index de041504..a1101aac 100644 --- a/tests/ytstack-check.test.sh +++ b/tests/ytstack-check.test.sh @@ -328,6 +328,91 @@ OUT=$("$CHECK" "$ROOT" 2>&1) eq "a drifted copy of the maintenance block -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "init-project/SKILL.md: the 'Keeping this true' block differs")" cp "$TMP/init.bak" "$ROOT/skills/init-project/SKILL.md" +# ---- standing instructions, one file per entry (issue #57) ------------------- +echo "# standing entries" +PRJ="$TMP/project"; SD="$PRJ/.ytstack/standing"; mkdir -p "$PRJ/.ytstack" +entry() { # entry [body] + printf -- '---\ngiven: %s\nscope: %s\nsupersedes: %s\n---\n\n%s\n' "$2" "$3" "$4" "${5-An instruction.}" > "$SD/$1.md" +} +OUT=$("$CHECK" --standing "$PRJ" 2>&1); EC=$? +eq "--standing without a directory: exit 0 (STANDING.md alone is valid)" 0 "$EC" +mkdir -p "$SD" +entry 20261114T1225Z-at-most-ten 2026-11-14T12:25:00Z "every author" "" +entry 20261114T1436Z-at-most-fifteen 2026-11-14T14:36:00Z "every lane" 20261114T1225Z-at-most-ten +printf '# Standing\n' > "$SD/README.md" +OUT=$("$CHECK" --standing "$PRJ" 2>&1); EC=$? +eq "--standing: well-formed entries, README ignored -> exit 0" 0 "$EC" +eq "--standing: counts the entries" 1 "$(printf '%s' "$OUT" | grep -c 'OK: 2 standing entries')" +OUT=$("$CHECK" --standing "$PRJ/.ytstack" 2>&1); EC=$? +eq "--standing: the .ytstack dir itself is accepted" 0 "$EC" +entry 20261114T1500Z-gone 2026-11-14T15:00:00Z "x" 20261114T0900Z-never-written +entry 20261114T1510Z-later 2026-11-14T15:10:00Z "x" 20261114T1600Z-future.md +entry 20261114T1600Z-future 2026-11-14T16:00:00Z "x" "" +entry 20261114T1520Z-bad-given 2026-11-14 "x" "" +entry 20261114T1530Z-wrong-minute 2026-11-14T15:31:00Z "x" "" +entry 20261114T1540Z-no-scope 2026-11-14T15:40:00Z "" "" +entry 20261114T1550Z-no-body 2026-11-14T15:50:00Z "x" "" "" +entry 20261114T1555Z-self 2026-11-14T15:55:00Z "x" 20261114T1555Z-self +printf 'no frontmatter\n' > "$SD/20261114T1700Z-plain.md" +printf -- '---\ngiven: 2026-11-14T17:00:00Z\nscope: x\n---\n\nx\n' > "$SD/Report-Results.md" +OUT=$("$CHECK" --standing "$PRJ" 2>&1); EC=$? +eq "--standing: broken entries -> exit 1" 1 "$EC" +eq "supersedes naming no entry -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1500Z-gone.md: supersedes '20261114T0900Z-never-written' names no entry")" +eq "supersedes naming a newer entry (.md suffix allowed) -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1510Z-later.md: supersedes '20261114T1600Z-future', which is newer")" +eq "given not an ISO time -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1520Z-bad-given.md: given '2026-11-14' is not an ISO UTC time")" +eq "given and the name differ -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1530Z-wrong-minute.md: given 2026-11-14T15:31:00Z and the time in the name differ")" +eq "empty scope -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1540Z-no-scope.md: scope is empty")" +eq "no body -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1550Z-no-body.md: no instruction below the frontmatter")" +eq "supersedes itself -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1555Z-self.md: supersedes names the entry itself")" +eq "no frontmatter -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1700Z-plain.md: no frontmatter")" +eq "a name without the UTC prefix -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "Report-Results.md: name is not")" +eq "the well-formed entries stay quiet" 0 "$(printf '%s' "$OUT" | grep -c "at-most-\(ten\|fifteen\)")" +# optional seconds: 12:25:30 is newer than 12:25 (Codex finding on PR #63) +rm -f "$SD"/*.md +entry 20261114T1225Z-old 2026-11-14T12:25:00Z "x" "" +entry 20261114T122530Z-new 2026-11-14T12:25:30Z "x" 20261114T1225Z-old +OUT=$("$CHECK" --standing "$PRJ" 2>&1); EC=$? +eq "seconds: 12:25:30 may supersede 12:25 -> exit 0" 0 "$EC" +entry 20261114T1225Z-old 2026-11-14T12:25:00Z "x" 20261114T122530Z-new +entry 20261114T122530Z-new 2026-11-14T12:25:30Z "x" "" +OUT=$("$CHECK" --standing "$PRJ" 2>&1) +eq "seconds: 12:25 superseding 12:25:30 -> newer FAIL" 1 "$(printf '%s' "$OUT" | grep -c "1225Z-old.md: supersedes '20261114T122530Z-new', which is newer")" +# impossible dates and times, in the name and in given +rm -f "$SD"/*.md +entry 20261340T2960Z-bad-name 2026-13-40T29:60Z "x" "" +entry 20240229T1200Z-leap-day 2024-02-29T12:00:00Z "x" "" +entry 20250229T1200Z-no-leap-day 2025-02-29T12:00:00Z "x" "" +entry 20261114T2359Z-bad-given-seconds 2026-11-14T23:59:60Z "x" "" +entry 20261131T1200Z-november-31 2026-11-31T12:00Z "x" "" +OUT=$("$CHECK" --standing "$PRJ" 2>&1) +eq "time: month 13, day 40, hour 29, minute 60 in the name -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "20261340T2960Z-bad-name.md: the time in the name is not a real")" +eq "time: 29 February of a leap year passes" 0 "$(printf '%s' "$OUT" | grep -c "standing/20240229T1200Z-leap-day.md")" +eq "time: 29 February of a common year -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "no-leap-day.md: the time in the name is not a real")" +eq "time: 31 November -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "november-31.md: the time in the name is not a real")" +eq "time: second 60 in given -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "bad-given-seconds.md: given 2026-11-14T23:59:60Z is not a real")" +rm -f "$SD"/*.md +# user scope: no .ytstack in the repository, the entries under ~/.ytstack/projects/ +UREPO="$TMP/userscope"; mkdir -p "$UREPO" "$TMP/home" +( cd "$UREPO" && git init -q ) >/dev/null 2>&1 +UKEY=$(cd "$UREPO" && HOME="$TMP/home" bash -c '. "$1"; yt_git_ctx "$PWD"; printf %s "$YT_REPO_KEY"' x "$SRC/hooks/lib/git-ctx.sh") +USD="$TMP/home/.ytstack/projects/$UKEY/standing"; mkdir -p "$USD" +printf -- '---\ngiven: 2026-11-14T12:25:00Z\nscope: x\nsupersedes: 20261114T0900Z-missing\n---\n\nx\n' > "$USD/20261114T1225Z-user.md" +# the real interpreter: a version-manager shim may not run with another HOME +PYREAL=$(python3 -c 'import sys; print(sys.executable)') +OUT=$(cd "$UREPO" && HOME="$TMP/home" "$PYREAL" "$CHECK" --standing 2>&1); EC=$? +eq "user scope: --standing from the repository finds ~/.ytstack/projects/ -> exit 1" 1 "$EC" +eq "user scope: the broken entry is named" 1 "$(printf '%s' "$OUT" | grep -c "1225Z-user.md: supersedes '20261114T0900Z-missing' names no entry")" +OUT=$(cd "$TMP/home" && HOME="$TMP/nohome" "$PYREAL" "$CHECK" --standing 2>&1); EC=$? +eq "no .ytstack anywhere: still exit 0" 0 "$EC" +# the plugin's own .ytstack/standing/ is part of the full run +mkdir -p "$ROOT/.ytstack/standing" +entry 20261114T1500Z-gone 2026-11-14T15:00:00Z "x" 20261114T0900Z-never-written +cp "$SD/20261114T1500Z-gone.md" "$ROOT/.ytstack/standing/" +OUT=$("$CHECK" "$ROOT" 2>&1); EC=$? +eq "full run: a broken own standing entry -> FAIL" 1 "$(printf '%s' "$OUT" | grep -c "\[fail\] .ytstack/standing/20261114T1500Z-gone.md: supersedes")" +eq "full run: exit 1" 1 "$EC" +rm -rf "$ROOT/.ytstack" + echo echo "$PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/ytstack-risk.test.sh b/tests/ytstack-risk.test.sh index c3e0114d..1587cb2c 100644 --- a/tests/ytstack-risk.test.sh +++ b/tests/ytstack-risk.test.sh @@ -132,6 +132,8 @@ change "$R" decisions 'echo x >> .ytstack/DECISIONS.md' person "DECISIONS.md" "reason: .ytstack/DECISIONS.md -- always a person: rule document" change "$R" standing 'echo x > .ytstack/STANDING.md' person "STANDING.md" "reason: .ytstack/STANDING.md -- always a person: rule document" +change "$R" standing-entry 'mkdir -p .ytstack/standing && echo x > .ytstack/standing/20261114T1225Z-report-results-only.md' +person "a standing entry file" "reason: .ytstack/standing/20261114T1225Z-report-results-only.md -- always a person: rule document" change "$R" prefs 'echo x >> .ytstack/PREFERENCES.md' person "PREFERENCES.md" "reason: .ytstack/PREFERENCES.md -- always a person: rule document" change "$R" agents 'echo x >> AGENTS.md'