From 46bbd3df217e338760562ed5f43748a8628e092a Mon Sep 17 00:00:00 2001 From: Stoney Jackson Date: Tue, 13 Oct 2026 14:56:54 +0000 Subject: [PATCH 1/3] fix(check): require --root and check the repo that runs the hooks Co-Authored-By: Claude Opus 5.5 --- .githooks/pre-commit | 2 +- .githooks/pre-push | 2 +- bin/check.py | 7 ++++--- tests/test_check.py | 31 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index fa0a3d4..1583be0 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,2 +1,2 @@ #!/bin/sh -exec python3 "$(git rev-parse --show-toplevel)/bin/check.py" +exec python3 "$(dirname "$0")/../bin/check.py" --root "$(git rev-parse --show-toplevel)" diff --git a/.githooks/pre-push b/.githooks/pre-push index d64a6be..e4e51bd 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,2 +1,2 @@ #!/bin/sh -exec python3 "$(git rev-parse --show-toplevel)/bin/check.py" --pre-push +exec python3 "$(dirname "$0")/../bin/check.py" --root "$(git rev-parse --show-toplevel)" --pre-push diff --git a/bin/check.py b/bin/check.py index 2ae4809..bbc0588 100755 --- a/bin/check.py +++ b/bin/check.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 """Consistency checks for the ourPLCC change-request tracker. -Standard library only: this runs on maintainers' hosts (pre-push hook) as -well as in containers, without Node or Backlog.md. +Standard library only: this runs from the hooks and in CI without Node or +Backlog.md. --root names the tracker repo (ourPLCC/change-requests). """ import argparse import re @@ -132,7 +132,8 @@ def rel(path): def main(argv=None): parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) - parser.add_argument("--root", default=str(Path(__file__).resolve().parent.parent)) + parser.add_argument("--root", required=True, + help="root of the tracker repo, which holds backlog/") parser.add_argument("--pre-push", action="store_true", help="also fail on uncommitted changes under backlog/") args = parser.parse_args(argv) diff --git a/tests/test_check.py b/tests/test_check.py index fc14e70..388f50b 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -142,6 +142,37 @@ def test_cli_exit_code_on_error(self): self.assertEqual(result.returncode, 1) self.assertIn("check: ", result.stderr) + def test_cli_requires_root(self): + result = subprocess.run( + [sys.executable, str(ROOT / "bin" / "check.py")], + capture_output=True, text=True) + self.assertEqual(result.returncode, 2) + self.assertIn("--root", result.stderr) + self.assertNotIn("Traceback", result.stderr) + + def hook(self, name): + git = ["git", "-c", "user.name=t", "-c", "user.email=t@t", "-C", str(self.root)] + subprocess.run(git + ["init", "-q"], check=True) + subprocess.run(git + ["add", "-A"], check=True) + subprocess.run(git + ["commit", "-q", "-m", "x"], check=True) + return subprocess.run(["sh", str(ROOT / ".githooks" / name)], + cwd=self.root, capture_output=True, text=True) + + def test_pre_commit_hook_checks_the_repo_that_runs_it(self): + self.add("tasks", "cr-1000 - A.md", record("CR-1000", project="nope")) + result = self.hook("pre-commit") + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("project", result.stderr) + + def test_pre_push_hook_checks_the_repo_that_runs_it(self): + result = self.hook("pre-push") + self.assertEqual(result.returncode, 0, result.stderr) + self.add("tasks", "cr-1000 - A.md", record("CR-1000")) + result = subprocess.run(["sh", str(ROOT / ".githooks" / "pre-push")], + cwd=self.root, capture_output=True, text=True) + self.assertEqual(result.returncode, 1) + self.assertIn("uncommitted change under backlog/", result.stderr) + if __name__ == "__main__": unittest.main() From ee6bd378dcdebc745ba404ebeb3e1c235539eee8 Mon Sep 17 00:00:00 2001 From: Stoney Jackson Date: Tue, 13 Oct 2026 14:58:28 +0000 Subject: [PATCH 2/3] ci: check ourPLCC/change-requests from dev's CI Also say in the docs that the tracker data lives in change-requests. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/check.yml | 10 +++++++++- CONTRIBUTING.md | 3 ++- README.md | 10 ++++++---- dev-docs/tracker.md | 18 +++++++++++------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 38b5653..94aa9de 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -4,11 +4,18 @@ on: push: pull_request: +permissions: + contents: read + jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: ourPLCC/change-requests + path: change-requests - uses: actions/setup-python@v5 with: python-version: "3.12" @@ -22,6 +29,7 @@ jobs: python3 -m unittest discover -s tests -t . python3 -m unittest discover -s migrate/tests -t . - name: Consistency check - run: python3 bin/check.py --pre-push + run: python3 bin/check.py --pre-push --root change-requests - name: Backlog.md doctor + working-directory: change-requests run: backlog doctor diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 06791cd..c4a84b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,8 @@ Repo docs link to this guide rather than restating it, even to agree with it. reports a problem or suggests an idea by opening an issue on the relevant code repo. - **Change requests (CRs)** are the work we commit to, tracked centrally in - this repo with [Backlog.md](https://github.com/MrLesk/Backlog.md). A CR is + [ourPLCC/change-requests](https://github.com/ourPLCC/change-requests) with + [Backlog.md](https://github.com/MrLesk/Backlog.md). A CR is work in exactly one repo with testable acceptance criteria, and has an ID `CR-N`. Work spanning repos is one CR per repo, linked by dependencies. - **Drafts** are ideas we have not committed to. Never cite one. diff --git a/README.md b/README.md index f5c4338..b84f563 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ -# ourPLCC developer docs and change requests +# ourPLCC developer docs How we build ourPLCC, for maintainers, their agents, and new developers: the developer guide shared by every ourPLCC repository, org-wide specs, agent -rules, and the central change-request tracker for work on plcc-ng, -languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and course-materials-ng. +rules, and the tooling for the change-request tracker. The tracker itself, for +work on plcc-ng, languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and +course-materials-ng, is +[ourPLCC/change-requests](https://github.com/ourPLCC/change-requests). **Reporting a problem or suggesting an idea?** Open a GitHub issue on the relevant code repository instead. GitHub Issues are where humans talk to us; -this repository is where maintainers track the resulting work. +the tracker is where maintainers track the resulting work. **Start with [CONTRIBUTING.md](CONTRIBUTING.md)**, the developer guide. diff --git a/dev-docs/tracker.md b/dev-docs/tracker.md index 40d2567..e8351af 100644 --- a/dev-docs/tracker.md +++ b/dev-docs/tracker.md @@ -2,7 +2,9 @@ The central tracker for work on the ourPLCC code repositories: plcc-ng, languages-ng, plcc-ng-demo, plcc-ng-devcontainer, and course-materials-ng. It -is managed with [Backlog.md](https://github.com/MrLesk/Backlog.md). This is +is managed with [Backlog.md](https://github.com/MrLesk/Backlog.md). Its data +lives in [ourPLCC/change-requests](https://github.com/ourPLCC/change-requests); +its checks and tooling live here, in `dev`. This is the full guide to using it; the [developer guide](../CONTRIBUTING.md) gives the short version and the workflow around it. @@ -59,7 +61,8 @@ this guide wins. decision that binds more than one repo); update the CR's acceptance criteria to match and add the spec as a reference: `backlog task edit CR-N --add-ref ../../../plcc-ng/dev-docs/specs/.md` - (for this repo: `../../dev-docs/specs/.md`). Specs do not cite CRs. + (for this repo: `../../../dev/dev-docs/specs/.md`). Specs do not cite + CRs. 2. **Plan and execute:** the plan lives in `.plans/` inside the worktree (gitignored) and is deleted with it. Plans are not kept. During automated execution, record discovered work in the CR's notes — @@ -102,7 +105,7 @@ dependency as satisfied, so review the CRs that depended on it. - **Demote** (`backlog task demote CR-N`) only when nothing cites the CR: ```bash - grep -rn 'CR-N\b' /workspaces/dev/backlog /workspaces/ --include='*.md' + grep -rn 'CR-N\b' /workspaces/change-requests/backlog /workspaces/ --include='*.md' git -C /workspaces/ log --all --oneline -i --grep 'cr-N\b' ``` @@ -124,7 +127,8 @@ version impact; its branch may carry other commit types too. Every CR has exactly one `project`: `plcc-ng`, `languages-ng`, `plcc-ng-demo`, `plcc-ng-devcontainer`, `course-materials-ng`, or `dev` (this repo: the org -docs and specs, the tracker's config, checks, CI, and migration tooling). Work spanning repos is one +docs and specs, and the tracker's checks, CI, and migration tooling; the +config is `change-requests`' `backlog/config.yml`). Work spanning repos is one CR per repo linked with `--dep` (no umbrella CRs); `backlog task list --ready` hides a CR until its dependencies are done. @@ -172,7 +176,7 @@ to renumber the unpushed CR, commit, and push. CI runs the same check plus ## Checks (`bin/check.py`) -Fails on: duplicate IDs (drafts included) or a filename that does not match its `id`; a +`bin/check.py --root ` fails on: duplicate IDs (drafts included) or a filename that does not match its `id`; a `DRAFT-N` cited outside its own file; a CR without exactly one configured `project` or `type`; an unconfigured label; anything in `archive/`; and, with `--pre-push`, uncommitted changes under `backlog/`. `CR-999` is exempt from @@ -222,8 +226,8 @@ checks run on hosts as well as in containers. Run what CI runs ```bash python3 -m unittest discover -s tests -t . python3 -m unittest discover -s migrate/tests -t . -python3 bin/check.py --pre-push -backlog doctor +python3 bin/check.py --pre-push --root /workspaces/change-requests +(cd /workspaces/change-requests && backlog doctor) ``` A new rule in `bin/check.py` gets a test in `tests/test_check.py` and a line From 44979c79734542127d5a2ef2a9e0952299b840be Mon Sep 17 00:00:00 2001 From: Stoney Jackson Date: Tue, 13 Oct 2026 15:06:13 +0000 Subject: [PATCH 3/3] fix(check): say so when --root holds no tracker Co-Authored-By: Claude Opus 5.5 --- bin/check.py | 2 ++ tests/test_check.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/bin/check.py b/bin/check.py index bbc0588..8866b18 100755 --- a/bin/check.py +++ b/bin/check.py @@ -71,6 +71,8 @@ def _as_list(value): def check(root, pre_push=False): root = Path(root) backlog = root / "backlog" + if not (backlog / "config.yml").is_file(): + return [f"{root}: no backlog/config.yml; --root must name the tracker repo"] config = load_config(backlog / "config.yml") projects = _as_list(config.get("projects")) types = _as_list(config.get("types")) diff --git a/tests/test_check.py b/tests/test_check.py index 388f50b..1f6a687 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -150,6 +150,16 @@ def test_cli_requires_root(self): self.assertIn("--root", result.stderr) self.assertNotIn("Traceback", result.stderr) + def test_root_without_tracker_is_a_clear_error(self): + empty = self.root / "not-a-tracker" + empty.mkdir() + result = subprocess.run( + [sys.executable, str(ROOT / "bin" / "check.py"), "--root", str(empty)], + capture_output=True, text=True) + self.assertEqual(result.returncode, 1) + self.assertIn("no backlog/config.yml", result.stderr) + self.assertNotIn("Traceback", result.stderr) + def hook(self, name): git = ["git", "-c", "user.name=t", "-c", "user.email=t@t", "-C", str(self.root)] subprocess.run(git + ["init", "-q"], check=True)