From 97beca9c96c894b9be8be5434e879eedb9e3abd9 Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 19:44:13 +0100 Subject: [PATCH 1/9] feat: escalate preference, the closed list of what goes to a person (#78) yt_prefs reads escalate: as a comma separated subset of violation, deviation, irreversible, secret, spend (default all five) into YT_PREF_ESCALATE. An invalid item warns and reads as all five, so a typo never takes a class away from the person. Co-Authored-By: Claude Opus 5.5 --- .ytstack/spec/hooks-and-state.md | 2 +- hooks/lib/git-ctx.sh | 15 +++++++++++++++ tests/git-ctx.test.sh | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.ytstack/spec/hooks-and-state.md b/.ytstack/spec/hooks-and-state.md index 5636d1b..05396f1 100644 --- a/.ytstack/spec/hooks-and-state.md +++ b/.ytstack/spec/hooks-and-state.md @@ -31,7 +31,7 @@ The lifecycle hooks under `hooks/` and the shared library `hooks/lib/git-ctx.sh` - `yt_resolve_yt_dir` finds the `.ytstack` directory: `/.ytstack` first (scope `project`), else `~/.ytstack/projects/` (scope `user`), else none. A linked worktree uses its own copy, not the main checkout's. - Volatile state lives outside the tree under `/repos//worktrees//sessions//`. `yt_state_base` defines the order of candidate bases. A missing session id becomes `nosession`. - If the base cannot be created, the state directory falls back to `/.ytstack/.local` when the checkout has a `.ytstack`, else to a per-user temp directory. `yt_ensure_gitignore` adds the ignore line for that fallback. Skills call it, hooks do not. -- `yt_pref` reads one key from `PREFERENCES.md` (`key: value` or `key=value`; quotes and a trailing comment are stripped). `yt_prefs` reads the ceremony dials and sets `YT_PREF_MERGE_BY` (default `risk`) and `YT_PREF_EVIDENCE_DIR` (default `.ytstack/evidence`). An invalid value is replaced by its default and reported in `YT_PREF_WARNINGS`; an invalid `merge_by` is replaced by `human`, so that a typo never merges without a person. `yt_upstream_feedback` (called by `yt_prefs`) sets `YT_PREF_UPSTREAM_FEEDBACK` from `PREFERENCES.md`, else from the last `upstream_feedback=` line of `~/.ytstack/config`, else `suggest`, and `YT_PREF_UPSTREAM_FEEDBACK_FROM` (`preferences`, `config`, `default`); an invalid value reads as `suggest`, so that a typo never publishes. `hooks/session-start` injects nothing for it; the injected `using-ytstack` names the channel. +- `yt_pref` reads one key from `PREFERENCES.md` (`key: value` or `key=value`; quotes and a trailing comment are stripped). `yt_prefs` reads the ceremony dials and sets `YT_PREF_MERGE_BY` (default `risk`) and `YT_PREF_EVIDENCE_DIR` (default `.ytstack/evidence`). An invalid value is replaced by its default and reported in `YT_PREF_WARNINGS`; an invalid `merge_by` is replaced by `human`, so that a typo never merges without a person. `YT_PREF_ESCALATE` is the comma separated escalation list (default and fallback for an invalid item: all five of `violation, deviation, irreversible, secret, spend`), so that a typo never takes a class away from the person. `yt_upstream_feedback` (called by `yt_prefs`) sets `YT_PREF_UPSTREAM_FEEDBACK` from `PREFERENCES.md`, else from the last `upstream_feedback=` line of `~/.ytstack/config`, else `suggest`, and `YT_PREF_UPSTREAM_FEEDBACK_FROM` (`preferences`, `config`, `default`); an invalid value reads as `suggest`, so that a typo never publishes. `hooks/session-start` injects nothing for it; the injected `using-ytstack` names the channel. - `yt_epoch` turns an ISO time into seconds with BSD `date -j`, GNU `date -d`, or, for BusyBox, `date -d` on the form `YYYY-MM-DD HH:MM:SS`. - `yt_brownfield_signals` counts up to six signs of an existing codebase and names which file would feed which artifact. The comment above the function lists the counted signals and the hint-only ones. - `yt_commit_ref_pattern` renders a task's commit pattern from `commit_ref_pattern` in `PREFERENCES.md`, or from the default. `yt_task_commits` lists commits whose subject matches it. When none match, it falls back to the commits on the current branch after the merge-base with the default branch, and reports which source it used. diff --git a/hooks/lib/git-ctx.sh b/hooks/lib/git-ctx.sh index 098030f..db41311 100644 --- a/hooks/lib/git-ctx.sh +++ b/hooks/lib/git-ctx.sh @@ -299,6 +299,9 @@ yt_pref() { # value reads as human, see below) # YT_PREF_EVIDENCE_DIR where a visual review stores its screenshots # (default .ytstack/evidence) +# YT_PREF_ESCALATE what goes to a person (issue #78): a comma separated +# subset of violation, deviation, irreversible, secret, +# spend (default all five; an invalid item reads as all five) # YT_PREF_UPSTREAM_FEEDBACK suggest | file | off (default suggest; falls # back to ~/.ytstack/config, see yt_upstream_feedback) # YT_PREF_WARNINGS one line per invalid value (reset to default) @@ -335,6 +338,18 @@ yt_prefs() { }merge_by: '$YT_PREF_MERGE_BY' is not human|coordinator|risk (using human)"; YT_PREF_MERGE_BY=human ;; esac YT_PREF_EVIDENCE_DIR=$(yt_pref "$ytd" evidence_dir .ytstack/evidence) case "$YT_PREF_EVIDENCE_DIR" in ?*/) YT_PREF_EVIDENCE_DIR=${YT_PREF_EVIDENCE_DIR%/} ;; esac + # escalate (issue #78, docs/ux/coordinator-format.md "Who decides"): like + # merge_by, a typo never takes a class away from the person. + local _esc_all="violation, deviation, irreversible, secret, spend" _esc_i _esc_out="" _esc_bad="" + YT_PREF_ESCALATE=$(yt_pref "$ytd" escalate "$_esc_all") + for _esc_i in $(printf '%s' "$YT_PREF_ESCALATE" | tr ',' ' '); do + case "$_esc_i" in violation|deviation|irreversible|secret|spend) _esc_out="${_esc_out:+$_esc_out, }$_esc_i" ;; *) _esc_bad=1 ;; esac + done + if [ -n "$_esc_bad" ] || [ -z "$_esc_out" ]; then + YT_PREF_WARNINGS="${YT_PREF_WARNINGS:+$YT_PREF_WARNINGS +}escalate: '$YT_PREF_ESCALATE' is not a list of violation|deviation|irreversible|secret|spend (using all five)"; _esc_out="$_esc_all" + fi + YT_PREF_ESCALATE="$_esc_out" yt_upstream_feedback "$ytd" return 0 } diff --git a/tests/git-ctx.test.sh b/tests/git-ctx.test.sh index 4bf7407..62e5a62 100644 --- a/tests/git-ctx.test.sh +++ b/tests/git-ctx.test.sh @@ -216,6 +216,14 @@ for v in human coordinator risk; do done printf 'merge_by: robot\nevidence_dir: shots/\n' > "$MP/PREFERENCES.md" eq "merge_by: invalid -> human + warning; evidence_dir without the trailing slash" "human|shots|merge_by: 'robot' is not human|coordinator|risk (using human)" "$(merge_pref "$MP")" +# escalate (issue #78, docs/ux/coordinator-format.md "Who decides"): a typo never takes a class from the person +esc_pref() { ( . "$LIB"; yt_prefs "$1" >/dev/null; printf '%s|%s' "$YT_PREF_ESCALATE" "${YT_PREF_WARNINGS:-}" ); } +EP="$TMP/escprefs"; mkdir -p "$EP" +eq "escalate: default all five" "violation, deviation, irreversible, secret, spend|" "$(esc_pref "$EP")" +printf 'escalate: secret,violation # only these\n' > "$EP/PREFERENCES.md" +eq "escalate: a subset, in its order" "secret, violation|" "$(esc_pref "$EP")" +printf 'escalate: critical\n' > "$EP/PREFERENCES.md" +eq "escalate: invalid -> all five + warning" "violation, deviation, irreversible, secret, spend|escalate: 'critical' is not a list of violation|deviation|irreversible|secret|spend (using all five)" "$(esc_pref "$EP")" # upstream_feedback (M033, docs/ux/upstream-feedback.md): PREFERENCES first, then ~/.ytstack/config, then suggest up_pref() { ( . "$LIB"; HOME="$UH"; yt_prefs "$1" >/dev/null; printf '%s|%s|%s' "$YT_PREF_UPSTREAM_FEEDBACK" "$YT_PREF_UPSTREAM_FEEDBACK_FROM" "${YT_PREF_WARNINGS:-}" ); } UP="$TMP/upprefs"; UH="$TMP/uphome"; mkdir -p "$UP" "$UH/.ytstack" From 35f5f0f73558f3cc1b30f781049529b44bb9e23b Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 19:44:23 +0100 Subject: [PATCH 2/9] feat: question class, escalation item and context gate (#78) ytstack-questions new --decides needs --because (escalate list or reserved) and writes class: escalation; --info writes class: info. ask refuses a question whose Context has no Source: or Purpose: line. check validates class and because; files without them stay valid and read as escalation. ytstack-upkeep writes its report as class info. The format and the Who decides list live in docs/ux/coordinator-format.md, with line 6 of the operating checklist. Co-Authored-By: Claude Opus 5.5 --- .ytstack/spec/artifacts.md | 4 +- .ytstack/spec/checks-and-evals.md | 4 +- bin/ytstack-questions | 78 +++++++++++++++++--- bin/ytstack-upkeep | 12 ++-- docs/ux/coordinator-format.md | 34 ++++++++- tests/ytstack-questions.test.sh | 116 ++++++++++++++++++++++++++---- tests/ytstack-upkeep.test.sh | 1 + 7 files changed, 218 insertions(+), 31 deletions(-) diff --git a/.ytstack/spec/artifacts.md b/.ytstack/spec/artifacts.md index 55a1b46..9a54cd1 100644 --- a/.ytstack/spec/artifacts.md +++ b/.ytstack/spec/artifacts.md @@ -65,7 +65,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory | `spec/SPEC.md`, `spec/.md` | `init-project` (every area `planned`), `adopt-brownfield` (pointer-only over existing documents; also for a project that has `.ytstack/` and no spec) | the task that changes the area, in its own commits; `reassess-roadmap` sets `verified_at` when it answers the drift report | | `HANDOFF.md` | `handoff-session`; `coordinate` when it rotates (its format with the "Rotation" block of `docs/ux/coordinator-format.md`) | the user; the rotating coordinator appends its workers' reports under "Reports after the rotation"; no hook writes it | | `LANES.md` | `bin/ytstack-frontier claim` or `peer set` (first write) | `bin/ytstack-frontier` (`set`, `release`), one row per call; called by `spawn-milestone-team`, `coordinate`, `finish-lane`; its `## Peers` lines (sessions in other repositories) by `ytstack-frontier peer set` from `coordinate` | -| `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 | +| `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 ...`) | `class: escalation` with `because: ` (`--decides --because`) or `class: info` (`--info`); a file without `class` reads as escalation. The agent fills Context (first `Source:` and `Purpose:`, which `ask` requires), Options, Recommendation; `ask` and `answer` change the state; the answer text is the human's | | `standing/-.md`, `STANDING.md` | `coordinate` through `bin/ytstack-standing add`, when the human gives an instruction that holds beyond the task: a new file with `given`, `scope`, `supersedes` and optionally `until`, `until-condition`, `until-check`, `check` (`docs/ux/coordinator-format.md`), by default on the day's `standing/` branch and pull request; appended to `STANDING.md` only where no `standing/` exists | an entry is never edited; a newer one supersedes it by name, an ended one is closed by an entry of `kind: end` (`ytstack-standing end`), readers skip both and an entry whose `until` passed; `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`, with a `## Upstream` section like the retro's | appended on a second run of the same day | @@ -189,7 +189,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - DECISIONS.md -- "2026-11-13: The technical spec is a set of artifacts of its own under `.ytstack/spec/` (M022, issue #36)" - DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)" (the `Runs:` line, `## Gates`, `## Review`, the evidence fields of a summary) - DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)"; "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)" (the external plan class) -- DECISIONS.md -- "2026-11-13: 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-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), narrowed by "2026-11-15: A coordinator decides what nobody reserved; a person gets only a closed list of escalations, and a question names its source and purpose (issue #78)" (`class`, `because`, `Source:` and `Purpose:` of a question file) - DECISIONS.md -- "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", extended by "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)" - DECISIONS.md -- "2026-04-23: `.ytstack/` location is user-chosen (project vs user vs both)"; "2026-11-15: New artifacts follow the directory a milestone already lives in (issue #70)" - DECISIONS.md -- "2026-05-31: active_slice is plan-task-owned and team-member-guarded (M012 / issue #21-RC1)" diff --git a/.ytstack/spec/checks-and-evals.md b/.ytstack/spec/checks-and-evals.md index 9cdb88c..7f71d77 100644 --- a/.ytstack/spec/checks-and-evals.md +++ b/.ytstack/spec/checks-and-evals.md @@ -94,7 +94,7 @@ Everything that tells a contributor whether a change is acceptable: the static c - `bin/ytstack-frontier`: `list` prints lane, state and detail per slice (done, claimed, blocked, ready) of the current milestone (with `none`: the highest roadmap not `done`, `dropped`, `shipped-informally` or `backlog`), then one lesson lane `lesson-F###` per open or planned lesson whose target is a check (blocked without non-empty "Files" and "Verification" in the lesson; listed also without a milestone); `claim` refuses a held lane and names the holder; `claim`, `set` and `release` change one row of `LANES.md` under a lock; `check` validates the file and then prints one `stale:` line per lane that stalls, exit 2 (issue #84): a `running` row whose worktree no longer exists, an `implement` row whose branch had no commit for `--minutes` (default 60, from the claim when that is newer, or from the first sight of its fix round when the row carries a pull request), a `review` or `prepare` row running 3 x `--minutes` since its claim, and a `ready` lane nobody claimed for `--minutes` since a check first saw it (first sights in `/repos//frontier-seen`, outside the tree, under a noclobber lock); `peer set` and `peer list` keep the `## Peers` lines of `LANES.md` (role, repository, address, last contact), list items that no table reader sees. The lock is the file `LANES.md.lock`, created by the shell under noclobber and not by `mkdir`, which is no lock on Ubuntu 26.04 (see `.ytstack/KNOWLEDGE.md`). - `bin/ytstack-plans` (`docs/ux/external-plans.md`): `scan` counts the work rows (task-list items, rows of tables with a status or checkbox column, nothing in a code fence) of `plans/`, `roadmap/` and their variants and prints one line per directory with `verdict=large` from 10 open rows and the answer recorded in `PREFERENCES.md`; exit 0 only for a large directory without an answer. `rows` prints `path:line`, state, id, section and title per row; a relative PATH is read from where the command was started, else from the repository root, and the output names files relative to the root. It writes nothing; the mapping is the agent's (`reconcile`, `adopt-brownfield`). -- `bin/ytstack-questions`: `new`, `list`, `next`, `ask` (once), `answer` (refused without text under "Answer"), `check`. `bin/ytstack-standing` (`docs/ux/coordinator-format.md`, "standing/"): `add` writes one entry, validated by `ytstack-check --standing` before anything is committed, by default in its own worktree outside the checkout on `standing/` with a commit, a push and one pull request per UTC day (opened through `ytstack-pr-watch create` when `pr_watch=on` and the session has an id, else `gh pr create`; updated when one is open); `--here` and user scope write into the resolved directory only; exit 3 when the commit stands but the push or the PR failed; a new day's branch starts from the newest pending standing branch, an earlier one with unpushed commits is pushed first. `end` writes the closing entry of `kind: end`, also of a pending entry. `list` prints the newest entry's age and the human prompts since (from the coordinate session's counter), the active entries with the pending ones marked (local `standing/*` branches and their upstreams only), then the ended ones, the conditions to check and the failed checks; it is the only place `until-check` and `check` run, and only for a working-tree entry identical to the default branch's (bash in its own process group, killed on timeout, stdin closed, `YTSTACK_STANDING_TIMEOUT` seconds each, default 5, at most ten per call, every one not run says why), `--no-checks` runs none. Its suite uses a stand-in for `gh`, a local bare remote behind an `insteadOf` URL and the real `ytstack-pr-watch create`. +- `bin/ytstack-questions`: `new` (`--decides` needs `--because` with an item of `escalate` or `reserved`, exit 64 otherwise; `--info` writes `class: info`), `list`, `next`, `ask` (once, and refused while `## Context` has no `Source:` or no `Purpose:` line with a value), `answer` (refused without text under "Answer"), `check` (also `class` and `because`; a file without them is valid). `bin/ytstack-standing` (`docs/ux/coordinator-format.md`, "standing/"): `add` writes one entry, validated by `ytstack-check --standing` before anything is committed, by default in its own worktree outside the checkout on `standing/` with a commit, a push and one pull request per UTC day (opened through `ytstack-pr-watch create` when `pr_watch=on` and the session has an id, else `gh pr create`; updated when one is open); `--here` and user scope write into the resolved directory only; exit 3 when the commit stands but the push or the PR failed; a new day's branch starts from the newest pending standing branch, an earlier one with unpushed commits is pushed first. `end` writes the closing entry of `kind: end`, also of a pending entry. `list` prints the newest entry's age and the human prompts since (from the coordinate session's counter), the active entries with the pending ones marked (local `standing/*` branches and their upstreams only), then the ended ones, the conditions to check and the failed checks; it is the only place `until-check` and `check` run, and only for a working-tree entry identical to the default branch's (bash in its own process group, killed on timeout, stdin closed, `YTSTACK_STANDING_TIMEOUT` seconds each, default 5, at most ten per call, every one not run says why), `--no-checks` runs none. Its suite uses a stand-in for `gh`, a local bare remote behind an `insteadOf` URL and the real `ytstack-pr-watch create`. - `bin/ytstack-finish-lane`: one step per call (`leftovers`, `commit`, `push`, `open-pr`, `wait-head`, `body-check`, `gates`, `merge`, `route`); every gate is read from GitHub through `gh` at the moment of the call, and `merge` passes the reviewed commit to the host so that a moved head cannot be merged. `route --lane [--pr ]` reads the lane's worker (the author) and plan from `LANES.md` and runs `bin/ytstack-risk route`; with `--pr` it passes the pull request on, and a lane without a plan file is routed from the host's reviews. `leftovers` and `commit` leave the evidence directory out. Its suite uses a stand-in for `gh` and a local bare remote. - `bin/ytstack-handover`: `new` copies `skills/handover-step/template.sh`; `check` is the static verification of a staged script (syntax, unchanged helper block, no raw command, a confirmation of its own before every mutation, no pipe into a shell). The helpers hold the same rule when the script runs: one yes carries one change. - `bin/ytstack-watch`: polls pull requests through `gh` and prints a line only when head, checks, review or mergeability changed; `--once` prints the snapshot with its read time. `release --commit ` runs `deployed` of "Release" until it names the commit (or `--timeout`, default 900 s), then `healthy` for the settle time, and ends with five receipt lines (`Target:`, `Commit:`, `Arrived:`, `Health:`, `Result:`) with read times. Exit 0 released or no health command, 2 not arrived, 3 unhealthy, 4 no "Release" section, 1 `RUNTIME.md` fails its check. It runs only those two commands and changes nothing. @@ -188,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`. "2026-11-15: Feedback about ytstack itself goes through one channel with a setting; a script checks the body, the agent posts (M033-S01, issue #55)" is the source of `bin/ytstack-upstream`. - DECISIONS.md -- "2026-11-13: The technical spec is a set of artifacts of its own under `.ytstack/spec/` (M022, issue #36)". Source of `bin/ytstack-spec` and the two spec checks. - DECISIONS.md -- "2026-11-13: Verification, review and orchestration work are bounded like code (M023, issue #35)". Source of `bin/ytstack-brief`. -- DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)". Source of the five coordinator scripts; the pipeline and the watcher support GitHub through `gh` only. Extended by "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", the source of `check_standing`, by "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)", the source of `bin/ytstack-standing` and the optional keys of `check_standing`, and by "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)", the source of `bin/ytstack-plans`. +- DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)". Source of the five coordinator scripts; the pipeline and the watcher support GitHub through `gh` only. Extended by "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)", the source of `check_standing`, by "2026-11-15: Standing entries end by `until`, `until-condition` or `until-check` and are closed by an entry of `kind: end`; their commands run only in `ytstack-standing list` (issues #73, #74)", the source of `bin/ytstack-standing` and the optional keys of `check_standing`, and by "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)", the source of `bin/ytstack-plans`. Narrowed by "2026-11-15: A coordinator decides what nobody reserved; a person gets only a closed list of escalations, and a question names its source and purpose (issue #78)", the source of the `--because` and `--info` checks of `ytstack-questions new`, the Context gate of `ask` and the `class`/`because` lines of `check`. - 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/bin/ytstack-questions b/bin/ytstack-questions index 7733ca0..0e5aa33 100755 --- a/bin/ytstack-questions +++ b/bin/ytstack-questions @@ -4,7 +4,7 @@ # # ytstack-questions [-C DIR] list [--state open|asked|answered] # ytstack-questions [-C DIR] next -# ytstack-questions [-C DIR] new --question TEXT --decides WHO [--blocks REFS] +# ytstack-questions [-C DIR] new --question TEXT (--decides WHO --because ITEM | --info WHO) [--blocks REFS] # ytstack-questions [-C DIR] ask # ytstack-questions [-C DIR] answer # ytstack-questions [-C DIR] check @@ -13,12 +13,21 @@ # (default: $PWD). ask and answer change the frontmatter only; the text of an # answer is written into the file by whoever heard it, never by this script. # +# Who decides (issue #78): --decides writes class escalation and needs +# --because, one item of `escalate:` in PREFERENCES.md (default violation, +# deviation, irreversible, secret, spend) or `reserved` (a plan line or a +# standing entry reserves the verdict). Everything else the coordinator +# decides itself. --info writes class info: WHO supplies a fact or takes +# note, the decision stays with the coordinator. +# # Exit codes # list 0; one line per file: id, state, decides, blocks, question (tab # separated); without --state the open and the asked ones # next 0 "" of the oldest open question; 1 none is open -# new 0 the path of the new file; 1 no .ytstack directory; 64 usage -# ask 0; 1 unknown id, or the state is not open (a question is asked once) +# new 0 the path of the new file; 1 no .ytstack directory; 64 usage, +# also --decides without an item of the list +# ask 0; 1 unknown id, the state is not open (a question is asked once), +# or "## Context" has no "Source:" or no "Purpose:" line with a value # answer 0; 1 unknown id, already answered, or no text under "## Answer" # check 0 clean, or "no questions" without the directory; 1 one line per problem @@ -31,6 +40,8 @@ if [ "${1:-}" = "-C" ]; then DIR="${2:-}"; shift 2 || true; fi CMD="${1:-}"; [ $# -gt 0 ] && shift usage() { sed -n '5,10p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } +# The items --because takes beside the project's list; check knows all of them. +REASONS_ALL="violation|deviation|irreversible|secret|spend|reserved" die() { echo "ytstack-questions: $*" >&2; exit 1; } case "$CMD" in list|next|new|ask|answer|check) ;; -h|--help|help) usage; exit 0 ;; *) usage >&2; exit 64 ;; esac # The resolver falls back to $PWD for a missing directory: refuse it here. @@ -89,6 +100,19 @@ answer_text() { on && NF && $0 !~ /^[ \t]*<.*>[ \t]*$/ { print } ' "$1" } +# context_names